iigs-game-engine/src/Actions.s

164 lines
3.4 KiB
ArmAsm
Raw Normal View History

2021-07-12 05:16:18 +00:00
MoveLeft
clc
adc StartX ; Increment the virtual X-position
jsr SetBG0XPos
2021-07-16 22:05:29 +00:00
lda StartX
2021-07-16 22:05:29 +00:00
lsr
jsr SetBG1XPos
2021-07-16 22:05:29 +00:00
jsr DoFrame
2021-07-12 05:16:18 +00:00
rts
MoveRight
pha
lda StartX
2021-07-12 05:16:18 +00:00
sec
sbc 1,s
bpl *+5
lda #0
jsr SetBG0XPos
lda StartX
lsr
jsr SetBG1XPos
jsr DoFrame
2021-07-12 05:16:18 +00:00
pla
rts
MoveUp
2021-07-12 05:16:18 +00:00
clc
adc StartY ; Increment the virtual Y-position
jsr SetBG0YPos
lda StartY
lsr
jsr SetBG1YPos
jsr DoFrame
2021-07-12 05:16:18 +00:00
rts
MoveDown
2021-07-12 05:16:18 +00:00
pha
lda StartY
2021-07-12 05:16:18 +00:00
sec
sbc 1,s
bpl *+5
lda #0
jsr SetBG0YPos
lda StartY
lsr
jsr SetBG1YPos
jsr DoFrame
2021-07-12 05:16:18 +00:00
pla
rts
; Very simple, scroll as fast as possible
oldOneSecondCounter ds 2
frameCount ds 2
lastTick ds 2
2021-07-12 05:16:18 +00:00
Demo
lda OneSecondCounter
sta oldOneSecondCounter
stz frameCount
2021-07-12 05:16:18 +00:00
:loop
PushLong #0
_GetTick
pla
plx
cmp lastTick ; Throttle to 60 fps
beq :loop
sta lastTick
2021-07-12 05:16:18 +00:00
and #$003C ; An 4-step animation that fires every 16 ticks
lsr
sta BG1OffsetIndex ; Set the value
lda #1
jsr MoveLeft
jsr DoFrame
inc frameCount
ldal KBD_STROBE_REG
bit #$0080
beq :nokey
and #$007F
cmp #'s'
bne :nokey
2021-07-12 05:16:18 +00:00
rts
:nokey
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-12 05:16:18 +00:00
2021-07-16 22:05:29 +00:00
2021-07-18 13:59:19 +00:00