Jump to content
IGNORED

Does my Kernel code is Efficient?


fromo

Recommended Posts

Hi!

 

I am just about to finish Andrew's 2600 Tutorial, but I decided to start again, because I felt that I needed more confidence at the moment I were doing my firts programs, so I decided to go to Kernel section.

 

I tried to modify a little bit the program that explain how to make the first Kernel, trying to make some blue stripes on the background, starting with light color blue, and ending with a little hard color blue, repeating in all the background, in order to share to you (the masters), this simple code (but great achievement for me), and know if I am in the right way.

 

Warning,,,,I am aware that this code is far to be efficient, so I would like to know what tricks I need to be present in order to make efficient code.

 

Sorry for the spanish comments that are included in my code, but Masters, is only a Kernel.

 

 

 

My best regards

Fernando Romo

Kernel1.ZIP

Link to comment
Share on other sites

Hi Fernando,

 

a few comments:

 

-generally speaking, you want to enable VBLANK at the start of the overscan and disable VBLANK immediately before drawing your picture (right before you begin the kernel) - your code as written is writing to the screen during the entire vblank period. I noticed this by running your .bin in z26; notice the line way at the bottom of the screen? That's where you are turning the screen back on right before VSYNC.

 

-you should mostly count down all your loops whenever possible:

               ldx #0
VerticalBlank   sta WSYNC
              inx
              cpx #37
              bne VerticalBlank

Would be better written as:

               ldx #37
VerticalBlank   sta WSYNC
              dex
               bne VerticalBlank

 

-and while we are looking at your vertical blank code, you will almost always want to use the timer, rather than counting scanlines, during the vertical blank and during the overscan.

 

-bob

 

 

 

Hi!

 

  I am just about to finish Andrew's 2600 Tutorial, but I decided to start again, because I felt that I needed more confidence at the moment I were doing my firts programs, so I decided to go to Kernel section.

 

  I tried to modify a little bit the program that explain how to make the first Kernel, trying to make some blue stripes on the background, starting with light color blue, and ending with a little hard color blue, repeating in all the background, in order to share to you (the masters), this simple code (but great achievement for me), and know if I am in the right way.

 

  Warning,,,,I am aware that this code is far to be efficient, so I would like to know what tricks I need to be present in order to make efficient code.

 

  Sorry for the spanish comments that are included in my code, but Masters, is only a Kernel.

 

 

 

My best regards

Fernando Romo

906147[/snapback]

Link to comment
Share on other sites

Hi Fernando,

 

a few comments:

 

-generally speaking, you want to enable VBLANK at the start of the overscan and disable VBLANK immediately before drawing your picture (right before you begin the kernel) - your code as written is writing to the screen during the entire vblank period.  I noticed this by running your .bin in z26; notice the line way at the bottom of the screen?  That's where you are turning the screen back on right before VSYNC.

 

-you should mostly count down all your loops whenever possible:

               ldx #0
VerticalBlank   sta WSYNC
              inx
              cpx #37
              bne VerticalBlank

Would be better written as:

               ldx #37
VerticalBlank   sta WSYNC
              dex
               bne VerticalBlank

 

-and while we are looking at your vertical blank code, you will almost always want to use the timer, rather than counting scanlines, during the vertical blank and during the overscan.

 

-bob

 

 

 

Hi!

 

  I am just about to finish Andrew's 2600 Tutorial, but I decided to start again, because I felt that I needed more confidence at the moment I were doing my firts programs, so I decided to go to Kernel section.

 

  I tried to modify a little bit the program that explain how to make the first Kernel, trying to make some blue stripes on the background, starting with light color blue, and ending with a little hard color blue, repeating in all the background, in order to share to you (the masters), this simple code (but great achievement for me), and know if I am in the right way.

 

  Warning,,,,I am aware that this code is far to be efficient, so I would like to know what tricks I need to be present in order to make efficient code.

 

  Sorry for the spanish comments that are included in my code, but Masters, is only a Kernel.

 

 

 

My best regards

Fernando Romo

906147[/snapback]

906934[/snapback]

 

 

Bob :

 

Thanks a lot for your comments, I would try to use the count down concept and also the timer, but regarding the way I am trying to do the things?, I mean, my goal was to see some blue stripes (horizontaly), over the background and I did it, but I don´t know if they were made in the right way?

 

My best regards

Fernando

Link to comment
Share on other sites

Bob :

 

  Thanks a lot for your comments, I would try to use the count down concept and also the timer, but regarding the way I am trying to do the things?, I mean, my goal was to see some blue stripes (horizontaly), over the background and I did it, but I don´t know if they were made in the right way?

 

My best regards

Fernando

907260[/snapback]

You're welcome.

 

I couldn't completely understand your code due to the spanish comments (as long as you understand them!) but here's how I would accomplish what you did:

 

With two, nested loops:

   ldy #24
OuterLoop
  ldx #LIGHTCOLOR
InnerLoop
  sta WSYNC
  stx COLUBK
  dex
  dex
  cpx #DARKCOLOR
  bne InnerLoop
  dey
  bne Outerloop

Edited by vdub_bobby
Link to comment
Share on other sites

Bob :

 

  Thanks a lot for your comments, I would try to use the count down concept and also the timer, but regarding the way I am trying to do the things?, I mean, my goal was to see some blue stripes (horizontaly), over the background and I did it, but I don´t know if they were made in the right way?

 

My best regards

Fernando

907260[/snapback]

You're welcome.

 

I couldn't completely understand your code due to the spanish comments (as long as you understand them!) but here's how I would accomplish what you did:

 

With two, nested loops:

   ldy #24
OuterLoop
  ldx #LIGHTCOLOR
InnerLoop
  sta WSYNC
  stx COLUBK
  dex
  dex
  cpx #DARKCOLOR
  bne InnerLoop
  dey
  bne Outerloop

907265[/snapback]

 

Bob :

 

Very Impresive,,,,with only some lines you showed how to make a background like I wanted. So in order that you could understand a little bit what I tried to document "comments", in my program, I have just translated those comments to English (I hope that you could understand).

 

I appreciate a lot the time that you are spending on me. :)

 

Inicializar

ldy #173 ;begin with light blue

lda #0 ;load the Acumulator with zeros

sta TIEMPO ;initialize TIME var with zeros

 

 

Picture

sty COLUBK ;apply background color

inc TIEMPO ;inc, TIEMPO variable (width horizontal stripes)

sty COLOR ;stores current color in COLOR variable

ldy TIEMPO ;load "y", with TIEMPO value

cpy #5 ;Did it pass five scanlines?

bne no_decrementar ;NOP?, then, we must go to "no_decrementar" label

;YES?, the program flow continues here

;here (if we count 5 times, we must initialize TIEMPO)

 

;--------------------------------------------------------------------------

; This little section of the program is to decrement the "y" register

; in order to apply a darknest color in the background

;--------------------------------------------------------------------------

 

ldy COLOR ;we rescue COLOR value in "y" register

dey ;decrement the background color

sty COLOR ;store the new color COLOR variable

cpy #162 ;due we want that our color background from light to darknest

;we need to compare those values

 

beq valor_inicial_y ;if the values are the same, then, we must jump to

;"valor_inicial_y" label

;because there we must initiate again our background color to

;the original blue color (173)

;if the values are not the same, then,

; the flow of the program follows here

;if you remember when we compare against value 5, was true

;I mean, TIEMPO value was equal to 5

;then, we have to initialize TIEMPO variable to zeros

 

 

lda #0 ;load the Acumulator with zeros

sta TIEMPO ;store the Acumulator value to TIEMPO variable

jmp no_decrementar ;I did not found another smart idea,,but we need to jump

;to "no_decrementar" label

;---------------------------------------------------------------------------------

; This section "valor_inicial_y", does initiate the y register value

; with the color that we want to apply in the background of our Kernel

;---------------------------------------------------------------------------------

valor_inicial_y

ldy #173 ;load y with the initial color value

;that we want to apply to our background

lda #0 ;load A with zeros (to set TIEMPO)

sta TIEMPO ;store that value in TIEMPO

sty COLOR ;store y value in COLOR variable

;---------------------------------------------------------------------------------

 

no_decrementar

ldy COLOR

sta WSYNC

inx

cpx #192

bne Picture

 

 

 

Thanks a lot for your help!!!

 

 

My best regards

Fernando

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...