mode7: update checkerboard demo to have scrolling sky

This commit is contained in:
Vince Weaver 2017-12-21 13:57:29 -05:00
parent 7d667bf5f4
commit b79bf2fbda
3 changed files with 108 additions and 6 deletions

79
asm_routines/bg_scroll.s Normal file
View File

@ -0,0 +1,79 @@
;==================
; scroll background
;==================
; background already loaded
; ANGLE 0-15 sets angle
; CV is Y position to display at
; 182/220... 220/16 = 13.75
; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
; 0 11 22 34 45 56 68 79 91 102 113 125 136 147 159 170 182
scroll_offsets:
.byte 0,11,22,34,45,56,68,79,91,102,113,125,136,147,159,170
scroll_background:
ldy ANGLE ; use angle
lda scroll_offsets,Y ; lookup in table
sta OFFSET ; calculate offset
ldx #0
ldy CV ; lookup Y co-ord
lsr ; and set up self-modify code
lda gr_offsets,Y ; get position
sta bgsm1+1
lda gr_offsets+2,Y ; get position
sta bgsm2+1
lda gr_offsets+4,Y ; get position
sta bgsm3+1
lda gr_offsets+6,Y ; get position
sta bgsm4+1
iny
clc
lda gr_offsets,Y ; get position
adc DRAW_PAGE
sta bgsm1+2
lda gr_offsets+2,Y ; get position
adc DRAW_PAGE
sta bgsm2+2
lda gr_offsets+4,Y ; get position
adc DRAW_PAGE
sta bgsm3+2
lda gr_offsets+6,Y ; get position
adc DRAW_PAGE
sta bgsm4+2
ldy OFFSET
bgdraw_loop:
lda scroll_row1,Y
bgsm1:
sta $400,X
lda scroll_row2,Y
bgsm2:
sta $480,X
lda scroll_row3,Y
bgsm3:
sta $500,X
lda scroll_row4,Y
bgsm4:
sta $580,X
iny
inx
cpx #40
bne bgdraw_loop
rts

View File

@ -45,7 +45,9 @@ mode7_checkerboard.o: mode7.s checkerboard_lookup.s \
../asm_routines/gr_setpage.s \
../asm_routines/keypress.s \
../asm_routines/gr_putsprite.s \
../asm_routines/text_print.s
../asm_routines/text_print.s \
../asm_routines/gr_scroll.s \
../asm_routines/bg_scroll.s
ca65 -o mode7_checkerboard.o mode7.s -D CHECKERBOARD_MAP=1 -l mode7.lst
MODE7_RAINBOW: mode7_rainbow.o

View File

@ -32,6 +32,14 @@ CONST_LOWRES_HALF_F EQU $00
; Initialize the 2kB of multiply lookup tables
jsr init_multiply_tables
.if .def(CHECKERBOARD_MAP)
lda #>sky_background
sta INH
lda #<sky_background
sta INL
jsr decompress_scroll
.endif
;===============
; Init Variables
;===============
@ -603,11 +611,6 @@ update_z_factor:
draw_background_mode7:
.if .def(CHECKERBOARD_MAP)
.else
; Only draw sky if necessary
; (at start, or if we have switched to text, we never overwrite it)
@ -615,6 +618,14 @@ draw_background_mode7:
beq no_draw_sky ;^2nt/3
;==============
; 6
.if .def(CHECKERBOARD_MAP)
lda #0
sta CV
jsr scroll_background
.else
; Draw Sky
; not performance critical as this happens rarely
@ -1110,6 +1121,12 @@ exit:
.include "../asm_routines/gr_putsprite.s"
.include "../asm_routines/text_print.s"
.if .def(CHECKERBOARD_MAP)
.include "../asm_routines/gr_scroll.s"
.include "../asm_routines/bg_scroll.s"
.endif
.include "sprites.inc"
;===============================================
@ -1120,6 +1137,10 @@ exit:
.include "island_map.inc"
.endif
.if .def(CHECKERBOARD_MAP)
.include "starry_sky.scroll"
.endif
.include "../asm_routines/multiply_fast.s"