2017-06-25 15:29:10 +00:00
|
|
|
; os memory map
|
|
|
|
CLRTEXT = $c050
|
|
|
|
SETTEXT = $c051
|
|
|
|
CLRMIXED = $c052
|
|
|
|
SETMIXED = $c053
|
|
|
|
TXTPAGE1 = $c054
|
|
|
|
TXTPAGE2 = $c055
|
|
|
|
CLRHIRES = $c056
|
|
|
|
SETHIRES = $c057
|
|
|
|
|
|
|
|
; ROM entry points
|
|
|
|
COUT = $fded
|
|
|
|
ROMWAIT = $fca8
|
|
|
|
|
|
|
|
; Zero page locations we use (unused by Monitor, Applesoft, or ProDOS)
|
|
|
|
PARAM0 = $06
|
|
|
|
PARAM1 = $07
|
|
|
|
PARAM2 = $08
|
|
|
|
PARAM3 = $09
|
|
|
|
SCRATCH0 = $19
|
|
|
|
SCRATCH1 = $1a
|
|
|
|
SPRITEPTR_L = $1b
|
|
|
|
SPRITEPTR_H = $1c
|
2017-06-30 21:43:28 +00:00
|
|
|
RENDERCOUNT = $ce
|
2017-06-30 06:14:39 +00:00
|
|
|
BGSTORE = $fa
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-29 18:48:25 +00:00
|
|
|
BGTOP = $c0 ; page number of first byte beyond top of backing store stack
|
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
; constants
|
2017-06-29 19:39:29 +00:00
|
|
|
MAXPOSX = 250
|
|
|
|
MAXPOSY = 192 - 16
|
2017-06-25 15:29:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
*= $6000
|
|
|
|
|
|
|
|
start
|
|
|
|
bit CLRTEXT ; start with HGR page 1, full screen
|
|
|
|
bit CLRMIXED
|
|
|
|
bit TXTPAGE1
|
|
|
|
bit SETHIRES
|
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
;jsr clrscr
|
|
|
|
jsr initsprites
|
|
|
|
|
2017-06-25 15:29:10 +00:00
|
|
|
gameloop
|
2017-06-26 19:32:55 +00:00
|
|
|
jsr renderstart
|
|
|
|
jsr movestart
|
2017-06-30 20:02:47 +00:00
|
|
|
dec fasttoggle
|
|
|
|
bpl gofast
|
2017-06-26 19:32:55 +00:00
|
|
|
jsr wait
|
2017-06-30 20:02:47 +00:00
|
|
|
gofast
|
2017-06-29 18:48:25 +00:00
|
|
|
jsr restorebg_driver
|
2017-06-26 19:32:55 +00:00
|
|
|
jmp gameloop
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-30 20:02:47 +00:00
|
|
|
fasttoggle
|
|
|
|
.byte 0
|
|
|
|
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
initsprites
|
2017-06-29 18:48:25 +00:00
|
|
|
jsr restorebg_init
|
2017-06-26 19:32:55 +00:00
|
|
|
rts
|
|
|
|
|
2017-06-25 15:29:10 +00:00
|
|
|
|
|
|
|
; Draw sprites by looping through the list of sprites
|
2017-06-26 19:32:55 +00:00
|
|
|
renderstart
|
2017-06-30 21:43:28 +00:00
|
|
|
lda #sprite_l - sprite_active
|
|
|
|
sta RENDERCOUNT
|
|
|
|
inc renderroundrobin+1
|
|
|
|
|
|
|
|
renderroundrobin
|
2017-06-25 15:29:10 +00:00
|
|
|
ldy #0
|
2017-06-30 19:52:15 +00:00
|
|
|
sty PARAM3
|
2017-06-25 15:29:10 +00:00
|
|
|
|
|
|
|
renderloop
|
2017-06-30 21:43:28 +00:00
|
|
|
lda PARAM3
|
|
|
|
and #sprite_l - sprite_active - 1
|
|
|
|
tay
|
2017-06-26 19:32:55 +00:00
|
|
|
lda sprite_active,y
|
|
|
|
beq renderskip ; skip if zero
|
|
|
|
lda sprite_l,y
|
2017-06-25 15:29:10 +00:00
|
|
|
sta jsrsprite+1
|
2017-06-26 19:32:55 +00:00
|
|
|
lda sprite_h,y
|
2017-06-25 15:29:10 +00:00
|
|
|
sta jsrsprite+2
|
2017-06-26 19:32:55 +00:00
|
|
|
lda sprite_x,y
|
2017-06-25 15:29:10 +00:00
|
|
|
sta PARAM0
|
2017-06-26 19:32:55 +00:00
|
|
|
lda sprite_y,y
|
2017-06-25 15:29:10 +00:00
|
|
|
sta PARAM1
|
|
|
|
|
|
|
|
jsrsprite
|
2017-06-26 19:32:55 +00:00
|
|
|
jsr $ffff ; wish you could JSR ($nnnn)
|
|
|
|
renderskip
|
2017-06-30 19:52:15 +00:00
|
|
|
inc PARAM3
|
2017-06-30 21:43:28 +00:00
|
|
|
dec RENDERCOUNT
|
|
|
|
bne renderloop
|
2017-06-26 19:32:55 +00:00
|
|
|
|
|
|
|
renderend
|
|
|
|
rts
|
2017-06-25 15:29:10 +00:00
|
|
|
|
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
movestart
|
2017-06-30 21:43:28 +00:00
|
|
|
lda #sprite_l - sprite_active
|
|
|
|
sta RENDERCOUNT
|
2017-06-26 19:32:55 +00:00
|
|
|
ldy #0
|
|
|
|
|
|
|
|
moveloop
|
|
|
|
lda sprite_active,y
|
|
|
|
bmi moveend
|
|
|
|
beq movenext
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
movex
|
2017-06-25 15:29:10 +00:00
|
|
|
; Apply X velocity to X coordinate
|
2017-06-29 19:39:29 +00:00
|
|
|
lda sprite_dirx,y
|
|
|
|
bpl move_right
|
|
|
|
sec
|
|
|
|
lda sprite_x,y
|
|
|
|
sbc sprite_dx,y
|
|
|
|
cmp #MAXPOSX
|
|
|
|
bcc movex_end
|
|
|
|
lda #1
|
|
|
|
sta sprite_dirx,y
|
|
|
|
lda #0
|
|
|
|
sta sprite_x,y
|
|
|
|
bpl movey
|
|
|
|
|
|
|
|
move_right
|
2017-06-25 15:29:10 +00:00
|
|
|
clc
|
2017-06-26 19:32:55 +00:00
|
|
|
lda sprite_x,y
|
|
|
|
adc sprite_dx,y
|
2017-06-25 15:29:10 +00:00
|
|
|
cmp #MAXPOSX
|
2017-06-29 19:39:29 +00:00
|
|
|
bcc movex_end
|
|
|
|
lda #-1
|
|
|
|
sta sprite_dirx,y
|
|
|
|
lda #MAXPOSX
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-29 19:39:29 +00:00
|
|
|
movex_end
|
2017-06-25 15:29:10 +00:00
|
|
|
; Store the new X
|
2017-06-26 19:32:55 +00:00
|
|
|
sta sprite_x,y
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
movey
|
2017-06-25 15:29:10 +00:00
|
|
|
; Apply Y velocity to Y coordinate
|
2017-06-29 19:39:29 +00:00
|
|
|
lda sprite_diry,y
|
|
|
|
bpl move_down
|
|
|
|
sec
|
|
|
|
lda sprite_y,y
|
|
|
|
sbc sprite_dy,y
|
|
|
|
cmp #MAXPOSY ; checking wraparound
|
|
|
|
bcc movey_end ; less than => not wrapped
|
|
|
|
lda #1
|
|
|
|
sta sprite_diry,y
|
|
|
|
lda #0
|
|
|
|
sta sprite_y,y
|
|
|
|
bpl movenext
|
|
|
|
|
|
|
|
move_down
|
2017-06-25 15:29:10 +00:00
|
|
|
clc
|
2017-06-26 19:32:55 +00:00
|
|
|
lda sprite_y,y
|
|
|
|
adc sprite_dy,y
|
2017-06-25 15:29:10 +00:00
|
|
|
cmp #MAXPOSY
|
2017-06-29 19:39:29 +00:00
|
|
|
bcc movey_end
|
|
|
|
lda #-1
|
|
|
|
sta sprite_diry,y
|
|
|
|
lda #MAXPOSY
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-29 19:39:29 +00:00
|
|
|
movey_end
|
|
|
|
; Store the new X
|
2017-06-26 19:32:55 +00:00
|
|
|
sta sprite_y,y
|
|
|
|
|
|
|
|
movenext
|
|
|
|
iny
|
2017-06-30 21:43:28 +00:00
|
|
|
dec RENDERCOUNT
|
2017-06-26 19:32:55 +00:00
|
|
|
bne moveloop
|
|
|
|
|
|
|
|
moveend
|
|
|
|
rts
|
2017-06-25 15:29:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wait
|
|
|
|
ldy #$06 ; Loop a bit
|
|
|
|
wait_outer
|
|
|
|
ldx #$ff
|
|
|
|
wait_inner
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
dex
|
|
|
|
bne wait_inner
|
|
|
|
dey
|
|
|
|
bne wait_outer
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
clrscr
|
|
|
|
lda #0
|
|
|
|
sta clr1+1
|
|
|
|
lda #$20
|
|
|
|
sta clr1+2
|
|
|
|
clr0
|
|
|
|
lda #$81
|
|
|
|
ldy #0
|
|
|
|
clr1
|
|
|
|
sta $ffff,y
|
|
|
|
iny
|
|
|
|
bne clr1
|
|
|
|
inc clr1+2
|
|
|
|
ldx clr1+2
|
|
|
|
cpx #$40
|
|
|
|
bcc clr1
|
|
|
|
rts
|
|
|
|
|
2017-06-29 18:48:25 +00:00
|
|
|
; Sprite data is interleaved so a simple indexed mode can be used. This is not
|
|
|
|
; convenient to set up but makes faster accessing because you don't have to
|
|
|
|
; increment the index register. For example, all the info about sprite #2 can
|
|
|
|
; be indexed using Y = 2 on the indexed operators, e.g. "lda sprite_active,y",
|
|
|
|
; "lda sprite_x,y", etc.
|
2017-06-30 21:43:28 +00:00
|
|
|
;
|
|
|
|
; Number of sprites must be a power of 2
|
2017-06-29 18:48:25 +00:00
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
sprite_active
|
2017-06-30 21:43:28 +00:00
|
|
|
.byte 1, 1, 1, 1, 1, 1, 1, 1 ; 1 = active, 0 = skip
|
2017-06-26 19:32:55 +00:00
|
|
|
|
|
|
|
sprite_l
|
2017-06-30 06:14:39 +00:00
|
|
|
.byte <APPLE_SPRITE9X11, <APPLE_SPRITE9X11, <APPLE_SPRITE9X11, <APPLE_SPRITE9X11, <APPLE_SPRITE9X11, <APPLE_SPRITE9X11, <MOLDY_BURGER, <MOLDY_BURGER
|
2017-06-26 19:32:55 +00:00
|
|
|
|
|
|
|
sprite_h
|
2017-06-30 06:14:39 +00:00
|
|
|
.byte >APPLE_SPRITE9X11, >APPLE_SPRITE9X11, >APPLE_SPRITE9X11, >APPLE_SPRITE9X11, >APPLE_SPRITE9X11, >APPLE_SPRITE9X11, >MOLDY_BURGER, >MOLDY_BURGER
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
sprite_x
|
2017-06-29 19:39:29 +00:00
|
|
|
.byte 80, 164, 33, 245, 4, 9, 255, 18
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
sprite_y
|
2017-06-29 18:48:25 +00:00
|
|
|
.byte 116, 126, 40, 60, 80, 100, 120, 140
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
sprite_dx
|
2017-06-29 19:39:29 +00:00
|
|
|
.byte 1, 2, 3, 4, 1, 2, 3, 4
|
|
|
|
|
|
|
|
sprite_dirx
|
|
|
|
.byte -1, -1, -1, -1, 1, 1, 1, 1
|
2017-06-25 15:29:10 +00:00
|
|
|
|
2017-06-26 19:32:55 +00:00
|
|
|
sprite_dy
|
2017-06-29 19:39:29 +00:00
|
|
|
.byte 4, 3, 2, 1, 4, 3, 2, 1
|
|
|
|
|
|
|
|
sprite_diry
|
|
|
|
.byte 1, 1, 1, 1, -1, -1, -1, -1
|
|
|
|
|
2017-06-25 15:29:10 +00:00
|
|
|
|
|
|
|
|
2017-06-30 06:14:39 +00:00
|
|
|
.include multitest-sprite-driver.s
|
|
|
|
.include backingstore.s
|
|
|
|
.include backingstore-3x11.s
|