A C64 Game - Step 29

posted in New Old Things
Published October 29, 2011
Advertisement

And yet another cosmetic step. The highscores receive a nice color warp. Pretty easy to implement, on every frame simply exchange the color bits where the score is displayed, and voila!




First setup up the fade counter in front of the TitleLoop:

          ;init color fade counter
          lda #0
          sta COLOR_FADE_POS


And the quite simple effect. First increase the counter (and check for overflow via AND). To get the proper offsets in the color RAM we reuse the screen line offset table (the lo byte is the same) and add on the differece in the hi byte.

For every line the fade pos is offset by one so the effect is applied diagonally. Read the color value from the table, write to color RAM, repeat for all lines, done.
 

          ;apply color fadeinc COLOR_FADE_POS
          lda COLOR_FADE_POS
          and #( COLOR_FADE_LENGTH - 1 )
          sta COLOR_FADE_POS
          
          lda #0
          sta PARAM1
          
.FadeLine
          lda PARAM1
          clcadc #10
          tay
          lda SCREEN_LINE_OFFSET_TABLE_LO,y
          sta ZEROPAGE_POINTER_1
          lda SCREEN_LINE_OFFSET_TABLE_HI,y
          clcadc #( ( ( SCREEN_COLOR - SCREEN_CHAR ) & $ff00 ) >> 8 )
          sta ZEROPAGE_POINTER_1 + 1
          ldy #6
          lda COLOR_FADE_POS
          clcadc PARAM1
          and #( COLOR_FADE_LENGTH - 1 )
          tax
          
.FadeColorNextChar
          lda COLOR_FADE_1,x
          sta (ZEROPAGE_POINTER_1),y
          iny
          cpy #35
          beq .FadeColorLineDone
          
          inx
          cpx #COLOR_FADE_LENGTH
          bne .FadeColorNextChar
          
          ldx #0jmp .FadeColorNextChar
          
.FadeColorLineDoneinc PARAM1
          lda PARAM1
          cmp #8
          bne .FadeLine
          
          .. common TitleLoop code


And here's the used constants. You can play around with these, but keep in mind, COLOR_FADE_LENGTH needs to be a power of 2. Also, since the charset mode is set to multi color you can only safely use color indices below 8.


COLOR_FADE_LENGTH = 16
COLOR_FADE_1
          !byte 0,0,6,6,3,3,1,1,1,1,1,1,3,3,6,6

step29.zip


Previous Step Next Step

Previous Entry A C64 Game - Step 28
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement
Advertisement