2021-07-12 05:16:18 +00:00
|
|
|
MoveLeft
|
|
|
|
clc
|
2021-07-20 05:02:20 +00:00
|
|
|
adc StartX ; Increment the virtual X-position
|
|
|
|
jsr SetBG0XPos
|
2021-07-16 22:05:29 +00:00
|
|
|
|
2021-08-19 06:22:36 +00:00
|
|
|
lda StartX
|
|
|
|
lsr
|
|
|
|
jsr SetBG1XPos
|
2021-07-16 22:05:29 +00:00
|
|
|
|
2021-08-10 12:59:14 +00:00
|
|
|
jsr Render
|
2021-07-12 05:16:18 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
MoveRight
|
|
|
|
pha
|
2021-07-20 05:02:20 +00:00
|
|
|
lda StartX
|
2021-07-12 05:16:18 +00:00
|
|
|
sec
|
2021-07-20 05:02:20 +00:00
|
|
|
sbc 1,s
|
|
|
|
bpl *+5
|
|
|
|
lda #0
|
|
|
|
jsr SetBG0XPos
|
2021-07-17 04:09:08 +00:00
|
|
|
|
2021-08-19 06:22:36 +00:00
|
|
|
lda StartX
|
|
|
|
lsr
|
|
|
|
jsr SetBG1XPos
|
2021-07-17 04:09:08 +00:00
|
|
|
|
2021-08-10 12:59:14 +00:00
|
|
|
jsr Render
|
2021-07-12 05:16:18 +00:00
|
|
|
pla
|
|
|
|
rts
|
|
|
|
|
2021-07-18 02:00:46 +00:00
|
|
|
MoveUp
|
2021-07-12 05:16:18 +00:00
|
|
|
clc
|
2021-07-20 05:02:20 +00:00
|
|
|
adc StartY ; Increment the virtual Y-position
|
2021-08-09 11:08:09 +00:00
|
|
|
pha
|
|
|
|
|
|
|
|
lda #240 ; virtual play field height
|
|
|
|
sec
|
|
|
|
sbc ScreenHeight
|
|
|
|
tax
|
|
|
|
cmp 1,s
|
|
|
|
bcc *+4
|
|
|
|
lda 1,s
|
2021-07-20 05:02:20 +00:00
|
|
|
jsr SetBG0YPos
|
2021-08-09 11:08:09 +00:00
|
|
|
pla
|
2021-07-17 04:09:08 +00:00
|
|
|
|
2021-08-09 11:08:09 +00:00
|
|
|
; lda StartY
|
|
|
|
; lsr
|
|
|
|
; jsr SetBG1YPos
|
2021-07-17 04:09:08 +00:00
|
|
|
|
2021-08-10 12:59:14 +00:00
|
|
|
jsr Render
|
2021-07-12 05:16:18 +00:00
|
|
|
rts
|
|
|
|
|
2021-07-18 02:00:46 +00:00
|
|
|
MoveDown
|
2021-07-12 05:16:18 +00:00
|
|
|
pha
|
2021-07-20 05:02:20 +00:00
|
|
|
lda StartY
|
2021-07-12 05:16:18 +00:00
|
|
|
sec
|
2021-07-20 05:02:20 +00:00
|
|
|
sbc 1,s
|
|
|
|
bpl *+5
|
|
|
|
lda #0
|
|
|
|
jsr SetBG0YPos
|
2021-07-17 04:09:08 +00:00
|
|
|
|
2021-08-10 12:59:14 +00:00
|
|
|
; lda StartY
|
|
|
|
; lsr
|
|
|
|
; jsr SetBG1YPos
|
2021-07-17 04:09:08 +00:00
|
|
|
|
2021-08-10 12:59:14 +00:00
|
|
|
jsr Render
|
2021-07-12 05:16:18 +00:00
|
|
|
pla
|
|
|
|
rts
|
|
|
|
|
|
|
|
; Very simple, scroll as fast as possible
|
2021-07-20 05:02:20 +00:00
|
|
|
oldOneSecondCounter ds 2
|
|
|
|
frameCount ds 2
|
|
|
|
lastTick ds 2
|
2021-07-12 05:16:18 +00:00
|
|
|
Demo
|
2021-07-20 05:02:20 +00:00
|
|
|
lda OneSecondCounter
|
|
|
|
sta oldOneSecondCounter
|
|
|
|
stz frameCount
|
2021-07-20 03:42:51 +00:00
|
|
|
|
2021-07-20 17:42:21 +00:00
|
|
|
; Set a timer to fire every 16 ticks
|
|
|
|
|
2021-07-29 10:35:09 +00:00
|
|
|
; lda #6
|
|
|
|
; sta Timers
|
|
|
|
; sta Timers+2
|
|
|
|
; lda #UpdateBG1Rotation
|
|
|
|
; sta Timers+4
|
2021-07-20 17:42:21 +00:00
|
|
|
|
|
|
|
; Every 3 ticks (20 fps) cycle some colors
|
|
|
|
|
2021-07-29 10:35:09 +00:00
|
|
|
lda #3
|
|
|
|
sta Timers+8
|
|
|
|
sta Timers+10
|
|
|
|
lda #DoColorCycle
|
|
|
|
sta Timers+12
|
2021-07-12 05:16:18 +00:00
|
|
|
:loop
|
2021-07-20 05:02:20 +00:00
|
|
|
PushLong #0
|
|
|
|
_GetTick
|
|
|
|
pla
|
|
|
|
plx
|
2021-07-20 03:42:51 +00:00
|
|
|
|
2021-07-20 05:02:20 +00:00
|
|
|
cmp lastTick ; Throttle to 60 fps
|
|
|
|
beq :loop
|
2021-07-20 17:42:21 +00:00
|
|
|
tax ; Calculate the increment
|
|
|
|
sec
|
|
|
|
sbc lastTick
|
|
|
|
stx lastTick
|
2021-07-29 10:35:09 +00:00
|
|
|
; jsr _DoTimers
|
2021-07-20 05:02:20 +00:00
|
|
|
|
2021-07-20 17:42:21 +00:00
|
|
|
; lda #1
|
|
|
|
; jsr MoveLeft
|
2021-07-29 10:35:09 +00:00
|
|
|
jsr UpdateBG1Rotation
|
|
|
|
; jsr DoColorCycle
|
2021-08-10 12:59:14 +00:00
|
|
|
jsr Render
|
2021-07-20 05:02:20 +00:00
|
|
|
|
|
|
|
inc frameCount
|
|
|
|
|
|
|
|
ldal KBD_STROBE_REG
|
|
|
|
bit #$0080
|
|
|
|
beq :nokey
|
|
|
|
and #$007F
|
|
|
|
cmp #'s'
|
|
|
|
bne :nokey
|
2021-07-20 03:42:51 +00:00
|
|
|
|
2021-07-12 05:16:18 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
:nokey
|
2021-07-20 05:02:20 +00:00
|
|
|
lda OneSecondCounter
|
|
|
|
cmp oldOneSecondCounter
|
|
|
|
beq :loop
|
|
|
|
|
|
|
|
sta oldOneSecondCounter
|
|
|
|
lda ScreenWidth
|
|
|
|
cmp #150
|
|
|
|
bcs :loop
|
|
|
|
|
|
|
|
lda #FPSStr
|
|
|
|
ldx #0 ; top-left corner
|
|
|
|
ldy #$7777
|
|
|
|
jsr DrawString
|
|
|
|
|
|
|
|
lda frameCount
|
|
|
|
ldx #4*4
|
|
|
|
jsr DrawWord
|
|
|
|
|
|
|
|
stz frameCount
|
|
|
|
bra :loop
|
|
|
|
|
|
|
|
FPSStr str 'FPS'
|
|
|
|
|
2021-07-29 10:35:09 +00:00
|
|
|
; Move some colors around color (6 - 11) address 12 - 22
|
2021-07-20 17:42:21 +00:00
|
|
|
DoColorCycle
|
2021-07-29 10:35:09 +00:00
|
|
|
ldal $E19E0C
|
|
|
|
pha
|
|
|
|
ldal $E19E0E
|
|
|
|
pha
|
|
|
|
ldal $E19E10
|
|
|
|
pha
|
|
|
|
ldal $E19E12
|
|
|
|
pha
|
|
|
|
ldal $E19E14
|
|
|
|
pha
|
|
|
|
ldal $E19E16
|
|
|
|
stal $E19E0C
|
|
|
|
pla
|
|
|
|
stal $E19E16
|
|
|
|
pla
|
|
|
|
stal $E19E14
|
|
|
|
pla
|
|
|
|
stal $E19E12
|
|
|
|
pla
|
|
|
|
stal $E19E10
|
|
|
|
pla
|
|
|
|
stal $E19E0E
|
2021-07-20 17:42:21 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
; Triggered timer to sway the background
|
|
|
|
UpdateBG1Offset
|
|
|
|
lda BG1OffsetIndex
|
|
|
|
inc
|
|
|
|
inc
|
|
|
|
cmp #32 ; 16 entries x 2 for indexing
|
|
|
|
bcc *+5
|
|
|
|
sbc #32
|
|
|
|
sta BG1OffsetIndex
|
|
|
|
rts
|
|
|
|
|
2021-07-24 14:00:52 +00:00
|
|
|
AngleUp
|
|
|
|
lda angle
|
|
|
|
inc
|
|
|
|
cmp #64
|
|
|
|
bcc *+5
|
|
|
|
sbc #64
|
|
|
|
sta angle
|
|
|
|
jsr _ApplyAngle
|
2021-08-10 12:59:14 +00:00
|
|
|
jsr Render
|
2021-07-24 14:00:52 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
AngleDown
|
|
|
|
lda angle
|
|
|
|
dec
|
|
|
|
bpl *+6
|
|
|
|
clc
|
|
|
|
adc #64
|
|
|
|
sta angle
|
|
|
|
jsr _ApplyAngle
|
2021-08-10 12:59:14 +00:00
|
|
|
jsr Render
|
2021-07-24 14:00:52 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
angle dw 0
|
|
|
|
UpdateBG1Rotation
|
|
|
|
jsr _ApplyAngle
|
|
|
|
; Increment the angle
|
|
|
|
lda angle
|
|
|
|
inc
|
|
|
|
cmp #64
|
|
|
|
bcc *+5
|
|
|
|
lda #0
|
|
|
|
sta angle
|
|
|
|
rts
|
|
|
|
|
2021-07-30 13:01:16 +00:00
|
|
|
x_angles EXT
|
|
|
|
y_angles EXT
|
2021-07-24 14:00:52 +00:00
|
|
|
_ApplyAngle
|
|
|
|
lda angle ; debug with angle = 0
|
|
|
|
asl
|
|
|
|
tax
|
2021-07-30 13:01:16 +00:00
|
|
|
ldal x_angles,x ; load the address of addressed for this angle
|
2021-07-24 14:00:52 +00:00
|
|
|
tay
|
|
|
|
phx
|
|
|
|
jsr _ApplyBG1XPosAngle
|
|
|
|
plx
|
|
|
|
|
2021-07-30 13:01:16 +00:00
|
|
|
ldal y_angles,x ; load the address of addresses for this angle
|
2021-07-24 14:00:52 +00:00
|
|
|
tay
|
|
|
|
jsr _ApplyBG1YPosAngle
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
2021-07-20 17:42:21 +00:00
|
|
|
; A collection of 8 timers that are triggered when their countdown
|
2021-07-24 14:00:52 +00:00
|
|
|
; goes below zero. Each timer takes up 8 bytes
|
|
|
|
;
|
|
|
|
; A timer can fire multiple times during a singular evaluation. For example, if the
|
|
|
|
; timer delay is set to 1 and 3 VBL ticks happen, then the timer delta is -2, will fire,
|
|
|
|
; have the delay added and get -1, fire again, increment to zero, first again and then
|
|
|
|
; finally reset to 1.
|
2021-07-20 17:42:21 +00:00
|
|
|
;
|
|
|
|
; +0 counter decremented by the number of ticks since last run
|
|
|
|
; +2 reset copied into counter when triggered. 0 turns off the timer.
|
|
|
|
; +4 addr address of time routine
|
|
|
|
; +6 reserved
|
|
|
|
MAX_TIMERS equ 4
|
|
|
|
Timers ds 8*MAX_TIMERS
|
|
|
|
|
|
|
|
; Countdown the timers
|
|
|
|
;
|
|
|
|
; A = number of elapsed ticks
|
|
|
|
_DoTimers
|
|
|
|
pha
|
|
|
|
ldx #0
|
|
|
|
:loop
|
2021-07-24 14:00:52 +00:00
|
|
|
lda Timers,x ; A zero means do not fire
|
2021-07-20 17:42:21 +00:00
|
|
|
beq :skip
|
|
|
|
|
|
|
|
sec
|
|
|
|
sbc 1,s ; subtract the number of ticks
|
|
|
|
sta Timers,x
|
|
|
|
|
2021-07-24 14:00:52 +00:00
|
|
|
:retry beq :fire ; getting <= zero triggers
|
2021-07-20 17:42:21 +00:00
|
|
|
bpl :skip
|
|
|
|
|
2021-07-24 14:00:52 +00:00
|
|
|
:fire pha ; Save the counter
|
2021-07-20 17:42:21 +00:00
|
|
|
phx ; Save our index
|
|
|
|
jsr (Timers+4,x)
|
|
|
|
plx
|
2021-07-24 14:00:52 +00:00
|
|
|
pla
|
|
|
|
|
|
|
|
clc
|
|
|
|
adc Timers+2,x ; Add the increment
|
|
|
|
sta Timers,x ; Store in the count
|
|
|
|
bra :retry ; See if we have >0 ticks to wait until the next trigger
|
2021-07-20 17:42:21 +00:00
|
|
|
|
|
|
|
:skip txa
|
|
|
|
clc
|
|
|
|
adc #8
|
|
|
|
tax
|
|
|
|
cpx #8*MAX_TIMERS
|
|
|
|
bcc :loop
|
|
|
|
|
|
|
|
pla
|
|
|
|
rts
|
2021-08-09 11:08:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-08-10 12:59:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-08-19 06:22:36 +00:00
|
|
|
|