colorized
This commit is contained in:
@@ -21,6 +21,9 @@ in the original.
|
|||||||
|
|
||||||
- PAL frame loop synced by polling the raster beam (no interrupts), one
|
- PAL frame loop synced by polling the raster beam (no interrupts), one
|
||||||
state update per frame — title, play and game over are `updvec` states.
|
state update per frame — title, play and game over are `updvec` states.
|
||||||
|
- The background is raster-split at the horizon: sky above, grass below.
|
||||||
|
The road is a grey wedge of inverse-space characters between painted
|
||||||
|
white edge lines, with trees along both shoulders.
|
||||||
- The player is hardware sprite 0; up to seven rabbits live on sprites
|
- The player is hardware sprite 0; up to seven rabbits live on sprites
|
||||||
1–7. Rabbits follow the road's perspective: a linear y ramp and a t²
|
1–7. Rabbits follow the road's perspective: a linear y ramp and a t²
|
||||||
horizontal fan-out, both precomputed into tables at assembly time
|
horizontal fan-out, both precomputed into tables at assembly time
|
||||||
|
|||||||
+102
-19
@@ -46,47 +46,126 @@ pt_loop:
|
|||||||
bne pt_loop
|
bne pt_loop
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; ---- the road: two diagonals from the horizon apex down to
|
; ---- set scrlo/hi + collo/hi to the start of char row X ----
|
||||||
; the screen corners, plus a tree on the left shoulder ----
|
row_ptr:
|
||||||
draw_road:
|
lda mul40lo,x
|
||||||
ldx #0
|
|
||||||
dr_loop:
|
|
||||||
txa
|
|
||||||
clc
|
|
||||||
adc #6 ; road runs from char row 6 to row 24
|
|
||||||
tay
|
|
||||||
lda mul40lo,y
|
|
||||||
sta scrlo
|
sta scrlo
|
||||||
lda mul40hi,y
|
sta collo
|
||||||
|
lda mul40hi,x
|
||||||
clc
|
clc
|
||||||
adc #>SCREEN
|
adc #>SCREEN
|
||||||
sta scrhi
|
sta scrhi
|
||||||
|
clc
|
||||||
|
adc #$d4 ; COLRAM - SCREEN high byte distance
|
||||||
|
sta colhi
|
||||||
|
rts
|
||||||
|
|
||||||
|
; ---- the road: grey surface between two painted edge lines,
|
||||||
|
; from the horizon apex down to the screen corners, then the
|
||||||
|
; trees along both shoulders ----
|
||||||
|
draw_road:
|
||||||
|
ldx #0
|
||||||
|
dr_loop:
|
||||||
stx drtmp
|
stx drtmp
|
||||||
|
txa
|
||||||
|
clc
|
||||||
|
adc #6 ; road runs from char row 6 to row 24
|
||||||
|
tax
|
||||||
|
jsr row_ptr
|
||||||
lda #19 ; left edge: one column left per row
|
lda #19 ; left edge: one column left per row
|
||||||
sec
|
sec
|
||||||
sbc drtmp
|
sbc drtmp
|
||||||
tay
|
tay
|
||||||
|
sty drleft
|
||||||
lda #$4e ; '/' diagonal
|
lda #$4e ; '/' diagonal
|
||||||
sta (scrlo),y
|
sta (scrlo),y
|
||||||
|
lda #COL_EDGE
|
||||||
|
sta (collo),y
|
||||||
lda #20 ; right edge: one column right per row
|
lda #20 ; right edge: one column right per row
|
||||||
clc
|
clc
|
||||||
adc drtmp
|
adc drtmp
|
||||||
tay
|
tay
|
||||||
lda #$4d ; '\' diagonal
|
lda #$4d ; '\' diagonal
|
||||||
sta (scrlo),y
|
sta (scrlo),y
|
||||||
|
lda #COL_EDGE
|
||||||
|
sta (collo),y
|
||||||
|
dey ; fill the surface between the edges
|
||||||
|
dr_fill:
|
||||||
|
cpy drleft
|
||||||
|
beq dr_rowdone
|
||||||
|
lda #$a0 ; inverse space: solid block
|
||||||
|
sta (scrlo),y
|
||||||
|
lda #COL_ROAD
|
||||||
|
sta (collo),y
|
||||||
|
dey
|
||||||
|
jmp dr_fill
|
||||||
|
dr_rowdone:
|
||||||
|
ldx drtmp
|
||||||
inx
|
inx
|
||||||
cpx #19
|
cpx #19
|
||||||
bne dr_loop
|
bne dr_loop
|
||||||
; tree on the left shoulder
|
; falls through: the roadside trees
|
||||||
lda #$51 ; ball
|
draw_trees:
|
||||||
sta SCREEN+10*40+3
|
lda #0
|
||||||
sta SCREEN+11*40+2
|
sta ttidx
|
||||||
sta SCREEN+11*40+3
|
dt_loop:
|
||||||
sta SCREEN+11*40+4
|
ldx ttidx
|
||||||
lda #$5d ; trunk
|
lda tree_tbl,x
|
||||||
sta SCREEN+12*40+3
|
sta trow
|
||||||
|
lda tree_tbl+1,x
|
||||||
|
sta tcol
|
||||||
|
jsr draw_tree
|
||||||
|
inc ttidx
|
||||||
|
inc ttidx
|
||||||
|
lda ttidx
|
||||||
|
cmp #NTREES*2
|
||||||
|
bne dt_loop
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; ---- one tree: crown of balls on trow, top ball above,
|
||||||
|
; trunk below (trow/tcol = middle row, left column) ----
|
||||||
|
draw_tree:
|
||||||
|
ldx trow
|
||||||
|
dex
|
||||||
|
jsr row_ptr
|
||||||
|
ldy tcol
|
||||||
|
iny
|
||||||
|
jsr tree_ball
|
||||||
|
ldx trow
|
||||||
|
jsr row_ptr
|
||||||
|
ldy tcol
|
||||||
|
jsr tree_ball
|
||||||
|
iny
|
||||||
|
jsr tree_ball
|
||||||
|
iny
|
||||||
|
jsr tree_ball
|
||||||
|
ldx trow
|
||||||
|
inx
|
||||||
|
jsr row_ptr
|
||||||
|
ldy tcol
|
||||||
|
iny
|
||||||
|
lda #$5d ; trunk
|
||||||
|
sta (scrlo),y
|
||||||
|
lda #BROWN
|
||||||
|
sta (collo),y
|
||||||
|
rts
|
||||||
|
|
||||||
|
tree_ball:
|
||||||
|
lda #$51 ; foliage ball
|
||||||
|
sta (scrlo),y
|
||||||
|
lda #LGREEN
|
||||||
|
sta (collo),y
|
||||||
|
rts
|
||||||
|
|
||||||
|
NTREES = 6
|
||||||
|
tree_tbl: ; middle row, left column - far trees sit
|
||||||
|
!byte 9, 4 ; higher and closer to the road
|
||||||
|
!byte 14, 6
|
||||||
|
!byte 19, 3
|
||||||
|
!byte 8, 31
|
||||||
|
!byte 12, 34
|
||||||
|
!byte 17, 36
|
||||||
|
|
||||||
; ---- input ----
|
; ---- input ----
|
||||||
|
|
||||||
; read joystick port 2 merged with the a/d keys,
|
; read joystick port 2 merged with the a/d keys,
|
||||||
@@ -488,6 +567,10 @@ rowidx: !byte 0
|
|||||||
bitcnt: !byte 0
|
bitcnt: !byte 0
|
||||||
curbits: !byte 0
|
curbits: !byte 0
|
||||||
drtmp: !byte 0 ; draw_road internals
|
drtmp: !byte 0 ; draw_road internals
|
||||||
|
drleft: !byte 0
|
||||||
|
ttidx: !byte 0 ; draw_trees internals
|
||||||
|
trow: !byte 0
|
||||||
|
tcol: !byte 0
|
||||||
rslot: !byte 0 ; rab_pos internals
|
rslot: !byte 0 ; rab_pos internals
|
||||||
rt: !byte 0
|
rt: !byte 0
|
||||||
rlane: !byte 0
|
rlane: !byte 0
|
||||||
|
|||||||
@@ -28,8 +28,25 @@ SPR_COL = $d027 ; sprite 0 color, +1 = sprite 1, ...
|
|||||||
; ---- colors ----
|
; ---- colors ----
|
||||||
BLACK = 0
|
BLACK = 0
|
||||||
WHITE = 1
|
WHITE = 1
|
||||||
|
RED = 2
|
||||||
|
CYAN = 3
|
||||||
|
GREEN = 5
|
||||||
|
BLUE = 6
|
||||||
|
YELLOW = 7
|
||||||
|
ORANGE = 8
|
||||||
|
BROWN = 9
|
||||||
|
DGREY = 11
|
||||||
|
MGREY = 12
|
||||||
|
LGREEN = 13
|
||||||
|
LBLUE = 14
|
||||||
LGREY = 15
|
LGREY = 15
|
||||||
|
|
||||||
|
; ---- scene palette ----
|
||||||
|
COL_SKY = LBLUE ; background above the horizon
|
||||||
|
COL_GRASS = GREEN ; background below it
|
||||||
|
COL_ROAD = MGREY ; road surface (inverse-space fill)
|
||||||
|
COL_EDGE = WHITE ; painted road edge lines
|
||||||
|
|
||||||
; ---- joystick port 2 bits (after read_joy, active high) ----
|
; ---- joystick port 2 bits (after read_joy, active high) ----
|
||||||
JOY_LEFT = 4
|
JOY_LEFT = 4
|
||||||
JOY_RIGHT = 8
|
JOY_RIGHT = 8
|
||||||
@@ -46,6 +63,7 @@ T_EXP = 192 ; ... and where the sprite gets double-sized
|
|||||||
REP_HOLD = 12 ; frames before a held direction auto-repeats
|
REP_HOLD = 12 ; frames before a held direction auto-repeats
|
||||||
REP_PERIOD = 6 ; frames between auto-repeat steps
|
REP_PERIOD = 6 ; frames between auto-repeat steps
|
||||||
RAS_SYNC = 251 ; raster line polled for the frame sync
|
RAS_SYNC = 251 ; raster line polled for the frame sync
|
||||||
|
RAS_SPLIT = 97 ; horizon line: sky/grass background split
|
||||||
|
|
||||||
; ---- zero page pointers (same slots as the c64-demo) ----
|
; ---- zero page pointers (same slots as the c64-demo) ----
|
||||||
txtlo = $f5 ; text pointer for the print routines (2 bytes)
|
txtlo = $f5 ; text pointer for the print routines (2 bytes)
|
||||||
|
|||||||
@@ -37,19 +37,21 @@
|
|||||||
start:
|
start:
|
||||||
sei ; no KERNAL IRQ - raster polling must not jitter
|
sei ; no KERNAL IRQ - raster polling must not jitter
|
||||||
|
|
||||||
; LCD look: black bezel border, pale screen, black artwork
|
; sunny scene: black frame, sky above the horizon split
|
||||||
lda #BLACK
|
lda #BLACK
|
||||||
sta BORDER
|
sta BORDER
|
||||||
lda #LGREY
|
lda #COL_SKY
|
||||||
sta BG
|
sta BG
|
||||||
|
|
||||||
; sprites: all black, hires, in front of the characters
|
; sprites: red scooter, white rabbits, hires, in front
|
||||||
|
lda #RED
|
||||||
|
sta SPR_COL
|
||||||
ldx #7
|
ldx #7
|
||||||
sprcol:
|
sprcol:
|
||||||
lda #BLACK
|
lda #WHITE
|
||||||
sta SPR_COL,x
|
sta SPR_COL,x
|
||||||
dex
|
dex
|
||||||
bpl sprcol
|
bne sprcol
|
||||||
lda #0
|
lda #0
|
||||||
sta SPR_EN
|
sta SPR_EN
|
||||||
sta SPR_MC
|
sta SPR_MC
|
||||||
@@ -72,9 +74,17 @@ sprcol:
|
|||||||
; ============================================================
|
; ============================================================
|
||||||
main:
|
main:
|
||||||
jsr wait_frame
|
jsr wait_frame
|
||||||
|
lda #COL_SKY ; repaint the sky while the beam is off screen
|
||||||
|
sta BG
|
||||||
inc framectr
|
inc framectr
|
||||||
jsr rand8 ; stir the RNG once per frame
|
jsr rand8 ; stir the RNG once per frame
|
||||||
jsr call_update
|
jsr call_update ; finishes long before the horizon line
|
||||||
|
wait_grass:
|
||||||
|
lda RASTER ; split the background at the horizon:
|
||||||
|
cmp #RAS_SPLIT ; sky above, grass below
|
||||||
|
bne wait_grass
|
||||||
|
lda #COL_GRASS
|
||||||
|
sta BG
|
||||||
jmp main
|
jmp main
|
||||||
|
|
||||||
call_update:
|
call_update:
|
||||||
|
|||||||
@@ -26,18 +26,27 @@ oi_row:
|
|||||||
lda mul40hi,y
|
lda mul40hi,y
|
||||||
adc #>SCREEN
|
adc #>SCREEN
|
||||||
sta scrhi
|
sta scrhi
|
||||||
|
sta colhi ; color RAM pointer for the same cells
|
||||||
|
lda scrlo
|
||||||
|
sta collo
|
||||||
|
lda colhi
|
||||||
|
clc
|
||||||
|
adc #$d4
|
||||||
|
sta colhi
|
||||||
ldy #BOXW-1
|
ldy #BOXW-1
|
||||||
oi_col:
|
oi_col:
|
||||||
jsr box_char
|
jsr box_char
|
||||||
sta (scrlo),y
|
sta (scrlo),y
|
||||||
|
lda #WHITE
|
||||||
|
sta (collo),y
|
||||||
dey
|
dey
|
||||||
bpl oi_col
|
bpl oi_col
|
||||||
inx
|
inx
|
||||||
cpx #5
|
cpx #5
|
||||||
bne oi_row
|
bne oi_row
|
||||||
|
|
||||||
+prtext BOXROW+1, 15, BLACK, txt_over, 9
|
+prtext BOXROW+1, 15, WHITE, txt_over, 9
|
||||||
+prtext BOXROW+2, 15, BLACK, txt_score, 5
|
+prtext BOXROW+2, 15, WHITE, txt_score, 5
|
||||||
|
|
||||||
; final score digits next to the label
|
; final score digits next to the label
|
||||||
lda sc_d0
|
lda sc_d0
|
||||||
@@ -49,6 +58,10 @@ oi_col:
|
|||||||
lda sc_d2
|
lda sc_d2
|
||||||
ora #48
|
ora #48
|
||||||
sta SCREEN+(BOXROW+2)*40+23
|
sta SCREEN+(BOXROW+2)*40+23
|
||||||
|
lda #YELLOW
|
||||||
|
sta COLRAM+(BOXROW+2)*40+21
|
||||||
|
sta COLRAM+(BOXROW+2)*40+22
|
||||||
|
sta COLRAM+(BOXROW+2)*40+23
|
||||||
|
|
||||||
+setupd over_update
|
+setupd over_update
|
||||||
rts
|
rts
|
||||||
@@ -100,10 +113,10 @@ over_update:
|
|||||||
lda framectr
|
lda framectr
|
||||||
and #32
|
and #32
|
||||||
bne ou_hide
|
bne ou_hide
|
||||||
+prtext BOXROW+3, 14, BLACK, txt_retry, 12
|
+prtext BOXROW+3, 14, YELLOW, txt_retry, 12
|
||||||
jmp ou_start
|
jmp ou_start
|
||||||
ou_hide:
|
ou_hide:
|
||||||
+prtext BOXROW+3, 14, BLACK, txt_blank, 12
|
+prtext BOXROW+3, 14, YELLOW, txt_blank, 12
|
||||||
ou_start:
|
ou_start:
|
||||||
jsr start_edge
|
jsr start_edge
|
||||||
beq ou_done
|
beq ou_done
|
||||||
|
|||||||
@@ -35,6 +35,17 @@ pi_clr:
|
|||||||
lda #2 ; start in the middle lane
|
lda #2 ; start in the middle lane
|
||||||
sta player_lane
|
sta player_lane
|
||||||
|
|
||||||
|
; sprite colors back to red scooter + white rabbits
|
||||||
|
; (the title borrows sprites 1-4 as red scooters)
|
||||||
|
ldx #7
|
||||||
|
pi_col:
|
||||||
|
lda #WHITE
|
||||||
|
sta SPR_COL,x
|
||||||
|
dex
|
||||||
|
bne pi_col
|
||||||
|
lda #RED
|
||||||
|
sta SPR_COL
|
||||||
|
|
||||||
; player sprite: scooter, fixed row, rabbits come per frame
|
; player sprite: scooter, fixed row, rabbits come per frame
|
||||||
lda #SPRP_SCOOT
|
lda #SPRP_SCOOT
|
||||||
sta SPRPTR
|
sta SPRPTR
|
||||||
@@ -266,6 +277,8 @@ add_miss:
|
|||||||
ldy miss ; Y: the rabbit loop still needs X
|
ldy miss ; Y: the rabbit loop still needs X
|
||||||
lda #24 ; 'x'
|
lda #24 ; 'x'
|
||||||
sta SCREEN+34,y ; marks land on columns 35-37
|
sta SCREEN+34,y ; marks land on columns 35-37
|
||||||
|
lda #RED
|
||||||
|
sta COLRAM+34,y
|
||||||
lda #12
|
lda #12
|
||||||
sta flash
|
sta flash
|
||||||
rts
|
rts
|
||||||
|
|||||||
@@ -8,11 +8,17 @@ title_init:
|
|||||||
jsr clear_screen
|
jsr clear_screen
|
||||||
jsr draw_road
|
jsr draw_road
|
||||||
|
|
||||||
+prbig 1, 8, BLACK, txt_rabbit, 6
|
+prbig 1, 8, RED, txt_rabbit, 6
|
||||||
+prtext 6, 16, BLACK, txt_scooter, 7
|
+prtext 6, 16, WHITE, txt_scooter, 7
|
||||||
+prtext 17, 4, BLACK, txt_info, 31
|
+prtext 17, 4, WHITE, txt_info, 31
|
||||||
|
|
||||||
; one parked scooter per lane on sprites 0-4
|
; one parked scooter per lane on sprites 0-4, all in red
|
||||||
|
ldx #4
|
||||||
|
ti_col:
|
||||||
|
lda #RED
|
||||||
|
sta SPR_COL,x
|
||||||
|
dex
|
||||||
|
bne ti_col
|
||||||
ldx #4
|
ldx #4
|
||||||
ti_scoot:
|
ti_scoot:
|
||||||
txa
|
txa
|
||||||
@@ -80,10 +86,10 @@ tu_pos:
|
|||||||
lda framectr
|
lda framectr
|
||||||
and #32
|
and #32
|
||||||
bne tu_hide
|
bne tu_hide
|
||||||
+prtext 15, 10, BLACK, txt_press, 19
|
+prtext 15, 10, YELLOW, txt_press, 19
|
||||||
jmp tu_start
|
jmp tu_start
|
||||||
tu_hide:
|
tu_hide:
|
||||||
+prtext 15, 10, BLACK, txt_blank, 19
|
+prtext 15, 10, YELLOW, txt_blank, 19
|
||||||
tu_start:
|
tu_start:
|
||||||
jsr start_edge
|
jsr start_edge
|
||||||
beq tu_done
|
beq tu_done
|
||||||
|
|||||||
Reference in New Issue
Block a user