Update old demos to current APIs

This commit is contained in:
Lucas Scharenbroich 2022-07-21 22:56:32 -05:00
parent 8aa816037c
commit d09f8e3681
4 changed files with 205 additions and 67 deletions

View File

@ -42,6 +42,7 @@ NO_MUSIC equ 1 ; turn music + tool loadi
pea #MyPalette
_GTESetPalette
pea $0000
pea $0000
_GTESetScreenMode
@ -56,6 +57,8 @@ NO_MUSIC equ 1 ; turn music + tool loadi
sta BankLoad ; Store "Bank Pointer"
jsr MovePlayerToOrigin ; Put the player at the beginning of the map
lda #193 ; Tile ID of '0'
jsr InitOverlay ; Initialize the status bar
EvtLoop

View File

@ -74,6 +74,7 @@ ScreenHeight equ 14
jsr TileAnimInit
jsr SetLimits
lda #193 ; Tile ID of '0'
jsr InitOverlay ; Initialize the status bar
stz frameCount
pha
@ -317,9 +318,6 @@ EvtLoop
pha
_GTEMoveSprite ; Move the sprite to this local position
; Update the timers
; jsl DoTimers
; Let's see what it looks like!
; lda vsync
@ -342,6 +340,12 @@ EvtLoop
; jsl SetBorderColor
;:no_vsync2
lda runningCount
inc
sta runningCount
pha
_GTESetBG1Rotation
; Update the performance counters
inc frameCount
@ -353,6 +357,7 @@ EvtLoop
sta oldOneSecondCounter
jsr UdtOverlay
stz frameCount
:noudt
brl EvtLoop
@ -401,6 +406,7 @@ MaxBG0Y ds 2
oldOneSecondCounter ds 2
frameCount ds 2
runningCount dw 0
MyUserId ds 2
MyDirectPage ds 2

View File

@ -26,6 +26,7 @@ DOWN_ARROW equ $0A
StartX equ 4
StartY equ 6
tmp0 equ 8
TSet EXT
; Typical init
@ -115,27 +116,50 @@ OKTOROK_SLOT_4 equ 4
_GTEUpdateSprite
; Add 4 octoroks
pea OKTOROK_ID
lda OktorokX
pha
lda OktorokY
pha
pea OKTOROK_SLOT_1
_GTEAddSprite
ldx #0
:oktorok_loop
phx ; save the index
pea OKTOROK_SLOT_1
txa ; calculate the SLOT ID
lsr
inc
tay
; _GTEUpdateSprite parameters
phy
pea $0000 ; with these flags (h/v flip)
pea OKTOROK_VBUFF ; and use this stamp
; _GTEAddSprite parameters
pea OKTOROK_ID
lda OktorokX,x
pha
lda OktorokY,x
pha
phy
_GTEAddSprite
_GTEUpdateSprite
plx
dex
dex
bpl :oktorok_loop
; Draw the initial screen
pea $0000
_GTERender
; Set up a very specific test. First, we draw a sprite into the sprite plane, and then
; leave it alone. We are just testing the ability to merge sprite plane data into
; the play field tiles.
EvtLoop
lda #2
jsr _SetBorderColor
pha
_GTEReadControl
pla
@ -219,6 +243,9 @@ EvtLoop
:not_w
:do_render
lda #3
jsr _SetBorderColor
pea HERO_SLOT
lda PlayerX
pha
@ -228,49 +255,62 @@ EvtLoop
; Based on the frame count, move an oktorok
; jsr _GetVBLTicks
; pha
; and #$0003
; asl
; tax
jsr _GetVBLTicks
pha
; pla
; and #$007C
; lsr
; tay
; pha ; save the vbl value for a second
; and #$0003 ; pick which oktorok to move
lda #4
jsr _SetBorderColor
; lda OktorokX,x
; clc
; adc OktorokDelta,y
plx
phx
lda #0
jsr MoveEnemy
; phx
plx
phx
lda #1
; jsr MoveEnemy
; ldy OktorokY,x
; tax
; pla
; inc
; inc
; jsl MoveSprite
plx
phx
lda #2
; jsr MoveEnemy
plx
lda #3
; jsr MoveEnemy
; Let's see what it looks like!
lda vsync
beq :no_vsync
:vsyncloop jsr _GetVBL ; 8-bit value
cmp #12
bcc :vsyncloop
cmp #16
bcs :vsyncloop ; Wait until we're within the top 4 scanlines
; lda vsync
; beq :no_vsync
;:vsyncloop jsr _GetVBL ; 8-bit value
; cmp #12
; bcc :vsyncloop
; cmp #16
; bcs :vsyncloop ; Wait until we're within the top 4 scanlines
lda #0
jsr _SetBorderColor
ldx #8
jsr _WaitForScanline
lda #1
jsr _SetBorderColor
:no_vsync
pea $0000
_GTERenderDirty
; brk $03
lda vsync
beq :no_vsync2
lda #0
jsr _SetBorderColor
; lda vsync
; beq :no_vsync2
; lda #0
; jsr _SetBorderColor
:no_vsync2
brl EvtLoop
@ -294,6 +334,8 @@ TransitionRight
adc #128
sta TransitionX
jsr HideEnemies
:loop lda StartX
cmp TransitionX
bcs :out
@ -317,11 +359,11 @@ TransitionRight
pha
_GTEMoveSprite
:nosprite
pea $0000
_GTERender ; Do full renders since the playfield is scrolling
bra :loop
:out
jsr ShowEnemies
inc MapScreenX ; Move the index to the next screen
:done
rts
@ -332,6 +374,8 @@ TransitionLeft
cmp #0
beq :done
jsr HideEnemies
lda StartX ; Scroll 128 bytes to the left
sec
sbc #128
@ -361,14 +405,81 @@ TransitionLeft
pha
_GTEMoveSprite
:nosprite
pea $0000
_GTERender
bra :loop
:out
jsr ShowEnemies
dec MapScreenX ; Move the index to the next screen
:done
rts
; Move an oktorok. A = 0 - 3, X = animation frame
MoveEnemy
phx
tay
iny ; Oktoroks are in slots 1 - 4
asl
tax ; Update this oktorok
pla ; Pop the VBL value
and #$007C
lsr
phy ; push the SLOT ID
tay
lda OktorokX,x
clc
adc OktorokDelta,y
pha ; Push the X position
lda OktorokY,x
pha
_GTEMoveSprite
rts
; Set the hidden flag on the enemy sprites during the screen transition
HideEnemies
ldx #6
:loop
phx
txa
lsr
inc
pha
pea SPRITE_HIDE
pea OKTOROK_VBUFF
_GTEUpdateSprite
plx
dex
dex
bpl :loop
rts
ShowEnemies
ldx #6
:loop
phx
txa
lsr
inc
pha
pea $0000
pea OKTOROK_VBUFF
_GTEUpdateSprite
plx
dex
dex
bpl :loop
rts
ToolPath str '1/Tool160'
MyUserId ds 2
; Color palette
@ -382,7 +493,7 @@ PlayerX ds 2
PlayerY ds 2
OktorokX dw 32,32,96,96
OktorokY dw 48,96,56,72
OktorokY dw 64,96,56,72
OktorokDelta dw 0,1,2,3,4,5,6,7,6,5,4,3,2,1,0,-1,-2,-3,-4,-5,-6,-7,-8,-7,-6,-5,-4,-3,-2,-1,0,0,0
TransitionX ds 2
TransitionY ds 2
@ -457,6 +568,24 @@ GTEStartUp
BORDER_REG equ $E0C034 ; 0-3 = border, 4-7 Text color
VBL_VERT_REG equ $E0C02E
VBL_HORZ_REG equ $E0C02F
VBL_STATE_REG equ $E0C019
_WaitForVBL
sep #$20
:wait1 ldal VBL_STATE_REG ; If we are already in VBL, then wait
bmi :wait1
:wait2 ldal VBL_STATE_REG
bpl :wait2 ; spin until transition into VBL
rep #$20
rts
_WaitForScanline
jsr _GetVBL
and #$FFFE
sta tmp0
cpx tmp0
bne _WaitForScanline
rts
_GetVBL
sep #$20

View File

@ -33,9 +33,9 @@ Tile_Layer_1
dw $006b,$006c,$006d,$006e,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0069,$006a,$006d,$006e,$0081,$0081,$0081,$0081,$0081,$0081,$0069,$006a,$006b,$006c,$006b,$006c,$006d,$006e,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0061,$0062
dw $004d,$004e,$0081,$0081,$0081,$0081,$0043,$0044,$0081,$0081,$0043,$0044,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0043,$0044,$0081,$0081,$0081,$0081,$0049,$004a,$004d,$004e,$0081,$0081,$0081,$0081,$0081,$0081,$0041,$0042,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0041,$0042,$0081,$0081,$0081,$0081,$0081,$0081,$0041,$0042,$0081,$0081,$0041,$0042
dw $004d,$004e,$0081,$0081,$0081,$0081,$0043,$0044,$0081,$0081,$4043,$4044,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0043,$0044,$0081,$0081,$0081,$0081,$0049,$004a,$004d,$004e,$0081,$0081,$0081,$0081,$0081,$0081,$0041,$0042,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0041,$0042,$0081,$0081,$0081,$0081,$0081,$0081,$0041,$0042,$0081,$0081,$0041,$0042
dw $006d,$006e,$0081,$0081,$0081,$0081,$0063,$0064,$0081,$0081,$0063,$0064,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0063,$0064,$0081,$0081,$0081,$0081,$0069,$006a,$006d,$006e,$0081,$0081,$0081,$0081,$0081,$0081,$0061,$0062,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0061,$0062,$0081,$0081,$0081,$0081,$0081,$0081,$0061,$0062,$0081,$0081,$0061,$0062
dw $006d,$006e,$0081,$0081,$0081,$0081,$0063,$0064,$0081,$0081,$4063,$4064,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0063,$0064,$0081,$0081,$0081,$0081,$0069,$006a,$006d,$006e,$0081,$0081,$0081,$0081,$0081,$0081,$0061,$0062,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0061,$0062,$0081,$0081,$0081,$0081,$0081,$0081,$0061,$0062,$0081,$0081,$0061,$0062
dw $0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0041,$0042,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081,$0081