mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2025-02-21 12:29:07 +00:00
Make the test demo more sophisticated; multiple sprites
This commit is contained in:
parent
24ebb1f3af
commit
83ec527b06
@ -15,8 +15,12 @@
|
|||||||
|
|
||||||
TSZelda EXT ; tileset buffer
|
TSZelda EXT ; tileset buffer
|
||||||
|
|
||||||
|
MAX_SPRITES equ 1
|
||||||
|
|
||||||
ScreenX equ 0
|
ScreenX equ 0
|
||||||
ScreenY equ 2
|
ScreenY equ 2
|
||||||
|
Tmp0 equ 4
|
||||||
|
Tmp1 equ 6
|
||||||
|
|
||||||
; Typical init
|
; Typical init
|
||||||
phk
|
phk
|
||||||
@ -53,30 +57,43 @@ palette dw $0000,$08C1,$0C41,$0F93,$0777,$0FDA,$00A0,$0000,$0D20,$0FFF,$023E
|
|||||||
sprt
|
sprt
|
||||||
|
|
||||||
; Create stamps for the sprites we are going to use
|
; Create stamps for the sprites we are going to use
|
||||||
HERO_SPRITE_1 equ SPRITE_16X16+1
|
HERO_SPRITE equ SPRITE_16X16+1
|
||||||
HERO_SLOT equ 0
|
|
||||||
|
|
||||||
pea HERO_SPRITE_1 ; sprint id
|
pea HERO_SPRITE ; sprint id
|
||||||
pea VBUFF_SPRITE_START ; vbuff address
|
pea VBUFF_SPRITE_START ; vbuff address
|
||||||
_GTECreateSpriteStamp
|
_GTECreateSpriteStamp
|
||||||
|
|
||||||
; Create sprites
|
; Create sprites
|
||||||
pea HERO_SPRITE_1 ; sprite id
|
stz Tmp0
|
||||||
pea #11 ; screen x-position (<256)
|
stz Tmp1
|
||||||
pea #23 ; screen y-position (<256)
|
|
||||||
pea HERO_SLOT ; sprite slot (0 - 15)
|
ldx Tmp0
|
||||||
|
:sloop
|
||||||
|
pea HERO_SPRITE ; sprite id
|
||||||
|
lda PlayerX,x
|
||||||
|
pha
|
||||||
|
lda PlayerY,x
|
||||||
|
pha
|
||||||
|
pei Tmp1
|
||||||
_GTEAddSprite
|
_GTEAddSprite
|
||||||
|
|
||||||
pea HERO_SLOT ; update the sprite in this slot
|
pei Tmp1 ; update the sprite in this slot
|
||||||
pea $0000 ; with these flags (h/v flip)
|
pea $0000 ; with these flags (h/v flip)
|
||||||
pea VBUFF_SPRITE_START ; and use this stamp
|
pea VBUFF_SPRITE_START ; and use this stamp
|
||||||
_GTEUpdateSprite
|
_GTEUpdateSprite
|
||||||
|
|
||||||
|
inc Tmp1
|
||||||
|
ldx Tmp0
|
||||||
|
inx
|
||||||
|
inx
|
||||||
|
stx Tmp0
|
||||||
|
cpx #MAX_SPRITES*2
|
||||||
|
bcc :sloop
|
||||||
|
|
||||||
; Manually fill in the 41x26 tiles of the TileStore with a test pattern of trees
|
; Manually fill in the 41x26 tiles of the TileStore with a test pattern of trees
|
||||||
;
|
;
|
||||||
; Tile 65 Tile 66
|
; Tile 65 Tile 66
|
||||||
; Tile 97 Tile 98
|
; Tile 97 Tile 98
|
||||||
|
|
||||||
stz 0 ; X
|
stz 0 ; X
|
||||||
stz 2 ; Y
|
stz 2 ; Y
|
||||||
|
|
||||||
@ -123,6 +140,10 @@ HERO_SLOT equ 0
|
|||||||
cmp #25
|
cmp #25
|
||||||
bcc :tloop
|
bcc :tloop
|
||||||
|
|
||||||
|
; Initialize the frame counter
|
||||||
|
|
||||||
|
stz FrameCount
|
||||||
|
|
||||||
; Set the screen coordinates
|
; Set the screen coordinates
|
||||||
|
|
||||||
lda #8
|
lda #8
|
||||||
@ -136,8 +157,29 @@ HERO_SLOT equ 0
|
|||||||
pla
|
pla
|
||||||
and #$00FF
|
and #$00FF
|
||||||
cmp #'q'
|
cmp #'q'
|
||||||
beq :exit
|
bne :3
|
||||||
|
brl :exit
|
||||||
|
:3
|
||||||
|
cmp #'s'
|
||||||
|
bne :4
|
||||||
|
inc PlayerY
|
||||||
|
brl :next
|
||||||
|
:4
|
||||||
|
cmp #'w'
|
||||||
|
bne :5
|
||||||
|
dec PlayerY
|
||||||
|
brl :next
|
||||||
|
:5
|
||||||
|
cmp #'d'
|
||||||
|
bne :6
|
||||||
|
inc PlayerX
|
||||||
|
brl :next
|
||||||
|
:6
|
||||||
|
cmp #'a'
|
||||||
|
bne :7
|
||||||
|
dec PlayerX
|
||||||
|
brl :next
|
||||||
|
:7
|
||||||
cmp #$15 ; left = $08, right = $15, up = $0B, down = $0A
|
cmp #$15 ; left = $08, right = $15, up = $0B, down = $0A
|
||||||
bne :8
|
bne :8
|
||||||
inc ScreenX
|
inc ScreenX
|
||||||
@ -146,53 +188,101 @@ HERO_SLOT equ 0
|
|||||||
:8 cmp #$08
|
:8 cmp #$08
|
||||||
bne :9
|
bne :9
|
||||||
dec ScreenX
|
dec ScreenX
|
||||||
bra :next
|
brl :next
|
||||||
|
|
||||||
:9 cmp #$0B
|
:9 cmp #$0B
|
||||||
bne :10
|
bne :10
|
||||||
inc ScreenY
|
inc ScreenY
|
||||||
bra :next
|
brl :next
|
||||||
|
|
||||||
:10 cmp #$0A
|
:10 cmp #$0A
|
||||||
bne :next
|
bne :next
|
||||||
dec ScreenY
|
dec ScreenY
|
||||||
|
|
||||||
:next
|
:next
|
||||||
|
inc ScreenX
|
||||||
|
|
||||||
pei ScreenX
|
pei ScreenX
|
||||||
pei ScreenY
|
pei ScreenY
|
||||||
_GTESetBG0Origin
|
_GTESetBG0Origin
|
||||||
|
|
||||||
; Update the sprite each frame for testing
|
stz Tmp0
|
||||||
; pea HERO_SLOT
|
stz Tmp1
|
||||||
; pea $0000
|
|
||||||
; pea VBUFF_SPRITE_START
|
ldx Tmp0
|
||||||
; _GTEUpdateSprite
|
loopX
|
||||||
|
lda PlayerX,x
|
||||||
|
clc
|
||||||
|
adc PlayerU,x
|
||||||
|
sta PlayerX,x
|
||||||
|
bpl is_posx
|
||||||
|
lda PlayerU,x
|
||||||
|
eor #$FFFF
|
||||||
|
inc
|
||||||
|
sta PlayerU,x
|
||||||
|
bra do_y
|
||||||
|
is_posx cmp #128
|
||||||
|
bcc do_y
|
||||||
|
lda PlayerU,x
|
||||||
|
eor #$FFFF
|
||||||
|
inc
|
||||||
|
sta PlayerU,x
|
||||||
|
|
||||||
|
do_y
|
||||||
|
lda PlayerY,x
|
||||||
|
clc
|
||||||
|
adc PlayerV,x
|
||||||
|
sta PlayerY,x
|
||||||
|
bpl is_posy
|
||||||
|
lda PlayerV,x
|
||||||
|
eor #$FFFF
|
||||||
|
inc
|
||||||
|
sta PlayerV,x
|
||||||
|
bra do_z
|
||||||
|
is_posy cmp #160
|
||||||
|
bcc do_z
|
||||||
|
lda PlayerV,x
|
||||||
|
eor #$FFFF
|
||||||
|
inc
|
||||||
|
sta PlayerV,x
|
||||||
|
do_z
|
||||||
|
pei Tmp1
|
||||||
|
lda PlayerX,x
|
||||||
|
pha
|
||||||
|
lda PlayerY,x
|
||||||
|
pha
|
||||||
|
_GTEMoveSprite
|
||||||
|
|
||||||
|
inc Tmp1
|
||||||
|
ldx Tmp0
|
||||||
|
inx
|
||||||
|
inx
|
||||||
|
stx Tmp0
|
||||||
|
cpx #MAX_SPRITES*2
|
||||||
|
bcc loopX
|
||||||
|
|
||||||
_GTERender
|
_GTERender
|
||||||
brl :evt_loop
|
inc FrameCount
|
||||||
|
|
||||||
; Debug stuff
|
; Debug stuff
|
||||||
ldx #$100
|
pha
|
||||||
lda StartX,x
|
_GTEGetSeconds
|
||||||
|
pla
|
||||||
|
cmp LastSecond
|
||||||
|
beq :no_fps
|
||||||
|
sta LastSecond
|
||||||
|
|
||||||
|
lda FrameCount
|
||||||
ldx #0
|
ldx #0
|
||||||
|
ldy #$FFFF
|
||||||
jsr DrawWord
|
jsr DrawWord
|
||||||
|
|
||||||
ldx #$100
|
stz FrameCount
|
||||||
lda StartY,x
|
:no_fps
|
||||||
ldx #160*8
|
|
||||||
jsr DrawWord
|
|
||||||
|
|
||||||
lda ScreenX
|
; tdc
|
||||||
ldx #160*16
|
; ldx #160*32
|
||||||
jsr DrawWord
|
; jsr DrawWord
|
||||||
|
|
||||||
lda ScreenY
|
|
||||||
ldx #160*24
|
|
||||||
jsr DrawWord
|
|
||||||
|
|
||||||
tdc
|
|
||||||
ldx #160*32
|
|
||||||
jsr DrawWord
|
|
||||||
|
|
||||||
brl :evt_loop
|
brl :evt_loop
|
||||||
|
|
||||||
@ -203,6 +293,12 @@ HERO_SLOT equ 0
|
|||||||
qtRec adrl $0000
|
qtRec adrl $0000
|
||||||
da $00
|
da $00
|
||||||
|
|
||||||
|
; Array of sprite positions and velocities
|
||||||
|
PlayerX dw 0,14,29,34,45,67,81,83,92,101,39,22,7,74,111,9
|
||||||
|
PlayerY dw 7,24,13,56,35,72,23,8,93,123,134,87,143,14,46,65
|
||||||
|
PlayerU dw 1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4
|
||||||
|
PlayerV dw 1,1,1,1,2,2,2,4,3,3,3,3,4,4,4,4
|
||||||
|
|
||||||
; Load the GTE User Tool and install it
|
; Load the GTE User Tool and install it
|
||||||
GTEStartUp
|
GTEStartUp
|
||||||
pea $0000
|
pea $0000
|
||||||
@ -257,6 +353,8 @@ GTEStartUp
|
|||||||
|
|
||||||
MyUserId ds 2
|
MyUserId ds 2
|
||||||
ToolPath str '1/Tool160'
|
ToolPath str '1/Tool160'
|
||||||
|
FrameCount ds 2
|
||||||
|
LastSecond dw 0
|
||||||
|
|
||||||
PUT App.Msg.s
|
PUT App.Msg.s
|
||||||
PUT font.s
|
PUT font.s
|
||||||
|
@ -53,4 +53,7 @@ _GTEUpdateSprite MAC
|
|||||||
<<<
|
<<<
|
||||||
_GTERemoveSprite MAC
|
_GTERemoveSprite MAC
|
||||||
UserTool $1300+GTEToolNum
|
UserTool $1300+GTEToolNum
|
||||||
|
<<<
|
||||||
|
_GTEGetSeconds MAC
|
||||||
|
UserTool $1400+GTEToolNum
|
||||||
<<<
|
<<<
|
@ -1,5 +1,5 @@
|
|||||||
; Feature flags
|
; Feature flags
|
||||||
NO_INTERRUPTS equ 1 ; turn off for crossrunner debugging
|
NO_INTERRUPTS equ 0 ; turn off for crossrunner debugging
|
||||||
NO_MUSIC equ 1 ; turn music + tool loading off
|
NO_MUSIC equ 1 ; turn music + tool loading off
|
||||||
|
|
||||||
; External data space provided by the main program segment
|
; External data space provided by the main program segment
|
||||||
@ -267,8 +267,7 @@ ClearKbdStrobe sep #$20
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
; Read the keyboard and paddle controls and return in a game-controller-like format
|
; Read the keyboard and paddle controls and return in a game-controller-like format
|
||||||
_ReadControl
|
_ReadControl pea $0000 ; low byte = key code, high byte = %------AB
|
||||||
pea $0000 ; low byte = key code, high byte = %------AB
|
|
||||||
|
|
||||||
sep #$20
|
sep #$20
|
||||||
ldal OPTION_KEY_REG ; 'B' button
|
ldal OPTION_KEY_REG ; 'B' button
|
||||||
|
16
src/Tool.s
16
src/Tool.s
@ -56,6 +56,8 @@ _CallTable
|
|||||||
adrl _TSMoveSprite-1
|
adrl _TSMoveSprite-1
|
||||||
adrl _TSUpdateSprite-1
|
adrl _TSUpdateSprite-1
|
||||||
adrl _TSRemoveSprite-1
|
adrl _TSRemoveSprite-1
|
||||||
|
|
||||||
|
adrl _TSGetSeconds-1
|
||||||
_CTEnd
|
_CTEnd
|
||||||
_GTEAddSprite MAC
|
_GTEAddSprite MAC
|
||||||
UserTool $1000+GTEToolNum
|
UserTool $1000+GTEToolNum
|
||||||
@ -202,12 +204,12 @@ width equ FirstParam+2
|
|||||||
|
|
||||||
; ReadControl()
|
; ReadControl()
|
||||||
_TSReadControl
|
_TSReadControl
|
||||||
output equ FirstParam
|
:output equ FirstParam
|
||||||
|
|
||||||
_TSEntry
|
_TSEntry
|
||||||
|
|
||||||
jsr _ReadControl
|
jsr _ReadControl
|
||||||
sta output,s
|
sta :output,s
|
||||||
|
|
||||||
_TSExit #0;#0
|
_TSExit #0;#0
|
||||||
|
|
||||||
@ -339,6 +341,16 @@ _TSRemoveSprite
|
|||||||
|
|
||||||
_TSExit #0;#2
|
_TSExit #0;#2
|
||||||
|
|
||||||
|
_TSGetSeconds
|
||||||
|
:output equ FirstParam
|
||||||
|
|
||||||
|
_TSEntry
|
||||||
|
|
||||||
|
ldal OneSecondCounter
|
||||||
|
sta :output,s
|
||||||
|
|
||||||
|
_TSExit #0;#0
|
||||||
|
|
||||||
; Insert the GTE code
|
; Insert the GTE code
|
||||||
|
|
||||||
put Math.s
|
put Math.s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user