2021-10-13 20:13:52 +00:00
|
|
|
; Test driver to exercise graphics routines.
|
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
REL
|
|
|
|
DSK MAINSEG
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
use Locator.Macs
|
|
|
|
use Load.Macs
|
|
|
|
use Mem.Macs
|
|
|
|
use Misc.Macs
|
|
|
|
use Tool222.Macs.s
|
|
|
|
use Util.Macs
|
|
|
|
use EDS.GSOS.Macs
|
|
|
|
use GTE.Macs
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
; use ../../src/Defs.s
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
mx %00
|
|
|
|
|
|
|
|
TSet EXT ; tileset buffer
|
2021-10-13 20:13:52 +00:00
|
|
|
|
|
|
|
; Keycodes
|
2022-06-25 16:18:50 +00:00
|
|
|
LEFT_ARROW equ $08
|
|
|
|
RIGHT_ARROW equ $15
|
|
|
|
UP_ARROW equ $0B
|
|
|
|
DOWN_ARROW equ $0A
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
; Direct page space
|
|
|
|
appTmp0 equ 0
|
|
|
|
BankLoad equ 2
|
|
|
|
StartX equ 4
|
|
|
|
StartY equ 6
|
|
|
|
TileMapWidth equ 8
|
|
|
|
TileMapHeight equ 10
|
|
|
|
ScreenWidth equ 12
|
|
|
|
ScreenHeight equ 14
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
phk
|
|
|
|
plb
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
sta MyUserId ; GS/OS passes the memory manager user ID for the application into the program
|
2022-06-27 16:24:04 +00:00
|
|
|
tdc
|
|
|
|
sta MyDirectPage ; Keep a copy for the overlay callback
|
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
_MTStartUp ; GTE requires the miscellaneous toolset to be running
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
jsr GTEStartUp ; Load and install the GTE User Tool
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
; Initialize local variables
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
stz appTmp0
|
|
|
|
stz BankLoad
|
|
|
|
stz StartX
|
|
|
|
stz StartY
|
|
|
|
|
|
|
|
; Initialize the graphics screen to a 256x160 playfield
|
|
|
|
|
|
|
|
pea #320
|
|
|
|
pea #200
|
|
|
|
_GTESetScreenMode
|
|
|
|
|
|
|
|
; Load a tileset
|
|
|
|
|
|
|
|
pea #^TSet
|
|
|
|
pea #TSet
|
|
|
|
_GTELoadTileSet
|
|
|
|
|
|
|
|
pea $0000
|
|
|
|
pea #^MyPalette
|
|
|
|
pea #MyPalette
|
|
|
|
_GTESetPalette
|
|
|
|
|
|
|
|
; Set up our level data
|
|
|
|
jsr BG0SetUp
|
2022-06-27 03:08:42 +00:00
|
|
|
jsr TileAnimInit
|
2022-06-25 16:18:50 +00:00
|
|
|
jsr SetLimits
|
|
|
|
|
2022-07-22 03:56:32 +00:00
|
|
|
lda #193 ; Tile ID of '0'
|
2022-06-27 16:24:04 +00:00
|
|
|
jsr InitOverlay ; Initialize the status bar
|
2022-06-25 16:18:50 +00:00
|
|
|
stz frameCount
|
|
|
|
pha
|
|
|
|
_GTEGetSeconds
|
|
|
|
pla
|
|
|
|
sta oldOneSecondCounter
|
2022-06-27 16:24:04 +00:00
|
|
|
jsr UdtOverlay
|
2021-10-31 00:24:23 +00:00
|
|
|
|
2021-11-15 18:23:38 +00:00
|
|
|
; Allocate a buffer for loading files
|
2022-06-25 16:18:50 +00:00
|
|
|
jsl AllocBank ; Alloc 64KB for Load/Unpack
|
|
|
|
sta BankLoad ; Store "Bank Pointer"
|
2021-11-15 18:23:38 +00:00
|
|
|
|
|
|
|
; Load in the 256 color background into BG1 buffer
|
2022-06-27 05:32:44 +00:00
|
|
|
; brl :nobackground
|
2021-11-15 18:23:38 +00:00
|
|
|
DoLoadBG1
|
2022-06-25 16:18:50 +00:00
|
|
|
lda BankLoad
|
|
|
|
ldx #BG1DataFile
|
|
|
|
jsr LoadFile
|
2021-11-15 18:23:38 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
lda BankLoad
|
|
|
|
pha
|
|
|
|
pea $0000
|
|
|
|
_GTECopyPicToBG1
|
2021-11-15 18:23:38 +00:00
|
|
|
|
|
|
|
; Copy the palettes into place
|
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
stz appTmp0
|
2021-11-15 18:23:38 +00:00
|
|
|
:ploop
|
2022-06-25 16:18:50 +00:00
|
|
|
lda appTmp0
|
|
|
|
pha ; Palette number
|
|
|
|
ldy BankLoad
|
|
|
|
phy ; High word pointer to palette
|
|
|
|
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
clc
|
|
|
|
adc #$7E00
|
|
|
|
pha ; Low word pointer to palette
|
|
|
|
_GTESetPalette
|
2021-11-15 18:23:38 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
inc appTmp0
|
|
|
|
lda appTmp0
|
|
|
|
cmp #16
|
|
|
|
bcc :ploop
|
2021-11-15 18:23:38 +00:00
|
|
|
|
|
|
|
; Bind the SCBs
|
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
lda BankLoad
|
|
|
|
ora #$8000 ; set high bit to bind to BG1 Y-position
|
|
|
|
pha
|
|
|
|
pea $7D00
|
|
|
|
_GTEBindSCBArray
|
2021-11-20 20:03:00 +00:00
|
|
|
:nobackground
|
2021-11-15 18:23:38 +00:00
|
|
|
|
2021-10-31 20:44:03 +00:00
|
|
|
; Initialize the sprite's global position (this is tracked outside of the tile engine)
|
2022-06-25 16:18:50 +00:00
|
|
|
lda #16
|
|
|
|
sta PlayerGlobalX
|
|
|
|
lda MaxGlobalY
|
|
|
|
sec
|
|
|
|
lda #40 ; 32 for tiles, 8 for sprite
|
|
|
|
sta PlayerGlobalY
|
|
|
|
|
|
|
|
stz PlayerXVel
|
|
|
|
stz PlayerYVel
|
|
|
|
|
|
|
|
; Create the sprites
|
|
|
|
HERO_ID equ {SPRITE_16X16+145}
|
|
|
|
HERO_VBUFF equ VBUFF_SPRITE_START+0*VBUFF_SPRITE_STEP
|
|
|
|
HERO_SLOT equ 1
|
|
|
|
MUSHROOM_ID equ {SPRITE_16X16+255}
|
|
|
|
MUSHROOM_VBUFF equ VBUFF_SPRITE_START+1*VBUFF_SPRITE_STEP
|
2022-06-27 03:08:42 +00:00
|
|
|
MUSHROOM_SLOT equ 0
|
2022-06-25 16:18:50 +00:00
|
|
|
|
|
|
|
pea HERO_ID ; sprint id
|
|
|
|
pea HERO_VBUFF ; vbuff address
|
|
|
|
_GTECreateSpriteStamp
|
|
|
|
|
|
|
|
pea MUSHROOM_ID ; sprint id
|
|
|
|
pea MUSHROOM_VBUFF ; vbuff address
|
|
|
|
_GTECreateSpriteStamp
|
2022-06-27 03:08:42 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
pea MUSHROOM_ID ; Put the mushroom in Slot 0
|
|
|
|
pea #80 ; at x=80, y=152
|
|
|
|
pea #152
|
2022-06-27 03:08:42 +00:00
|
|
|
pea MUSHROOM_SLOT
|
2022-06-25 16:18:50 +00:00
|
|
|
_GTEAddSprite
|
|
|
|
|
2022-06-27 03:08:42 +00:00
|
|
|
pea MUSHROOM_SLOT
|
2022-06-25 16:18:50 +00:00
|
|
|
pea $0000 ; with these flags (h/v flip)
|
|
|
|
pea MUSHROOM_VBUFF ; and use this stamp
|
|
|
|
_GTEUpdateSprite
|
|
|
|
|
2022-06-27 03:08:42 +00:00
|
|
|
jsr UpdatePlayerLocal
|
2022-06-25 16:18:50 +00:00
|
|
|
|
|
|
|
pea HERO_ID
|
|
|
|
lda PlayerX
|
|
|
|
pha
|
|
|
|
lda PlayerY
|
|
|
|
pha
|
|
|
|
pea HERO_SLOT ; Put the player in slot 1
|
|
|
|
_GTEAddSprite
|
|
|
|
|
|
|
|
pea HERO_SLOT
|
|
|
|
pea $0000
|
|
|
|
pea HERO_VBUFF ; and use this stamp
|
|
|
|
_GTEUpdateSprite
|
2021-10-22 05:56:12 +00:00
|
|
|
|
2021-10-29 02:41:01 +00:00
|
|
|
; 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.
|
2021-10-13 20:13:52 +00:00
|
|
|
EvtLoop
|
2022-06-25 16:18:50 +00:00
|
|
|
pha
|
|
|
|
_GTEReadControl
|
2021-10-31 20:44:03 +00:00
|
|
|
|
|
|
|
; Check the buttons first
|
2022-06-25 16:18:50 +00:00
|
|
|
lda 1,s
|
|
|
|
|
|
|
|
bit #$0100
|
|
|
|
beq :no_jump
|
|
|
|
lda PlayerStanding
|
|
|
|
beq :no_jump
|
|
|
|
lda #$FFF8
|
|
|
|
sta PlayerYVel
|
2021-10-31 20:44:03 +00:00
|
|
|
:no_jump
|
2021-11-12 17:27:43 +00:00
|
|
|
|
|
|
|
; Enable/disable v-sync
|
2022-06-25 16:18:50 +00:00
|
|
|
lda 1,s
|
|
|
|
bit #$0400
|
|
|
|
beq :no_key_down
|
|
|
|
and #$007F
|
|
|
|
cmp #'v'
|
|
|
|
bne :not_v
|
|
|
|
lda #$0001
|
|
|
|
eor vsync
|
|
|
|
sta vsync
|
2021-11-12 17:27:43 +00:00
|
|
|
:not_v
|
2022-06-25 16:18:50 +00:00
|
|
|
cmp #'f'
|
|
|
|
bne :not_f
|
|
|
|
lda SpriteToggle
|
|
|
|
eor #SPRITE_HIDE
|
|
|
|
sta SpriteToggle
|
|
|
|
bne :not_f
|
|
|
|
stz SpriteCount
|
2021-11-22 19:27:27 +00:00
|
|
|
|
|
|
|
:not_f
|
2021-11-12 17:27:43 +00:00
|
|
|
:no_key_down
|
2022-06-25 16:18:50 +00:00
|
|
|
pla
|
|
|
|
and #$007F ; Ignore the buttons for now
|
2021-11-12 17:27:43 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
cmp #'q'
|
|
|
|
bne :not_q
|
|
|
|
brl Exit
|
2021-11-12 17:27:43 +00:00
|
|
|
|
2021-10-31 00:24:23 +00:00
|
|
|
:not_q
|
2022-06-25 16:18:50 +00:00
|
|
|
cmp #'d'
|
|
|
|
bne :not_d
|
|
|
|
lda StartX
|
|
|
|
cmp MaxBG0X
|
|
|
|
bcc *+5
|
|
|
|
brl :do_render
|
|
|
|
inc StartX
|
|
|
|
pei StartX
|
|
|
|
pei StartY
|
|
|
|
_GTESetBG0Origin
|
|
|
|
brl :do_render
|
2021-10-31 20:44:03 +00:00
|
|
|
:not_d
|
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
cmp #'a'
|
|
|
|
bne :not_a
|
|
|
|
lda StartX
|
|
|
|
bne *+5
|
|
|
|
brl :do_render
|
|
|
|
dec StartX
|
|
|
|
pei StartX
|
|
|
|
pei StartY
|
|
|
|
_GTESetBG0Origin
|
|
|
|
brl :do_render
|
2021-10-31 20:44:03 +00:00
|
|
|
:not_a
|
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
cmp #'s'
|
|
|
|
bne :not_s
|
|
|
|
lda StartY
|
|
|
|
cmp MaxBG0Y
|
|
|
|
bcs :do_render
|
|
|
|
inc StartY
|
|
|
|
pei StartX
|
|
|
|
pei StartY
|
|
|
|
_GTESetBG0Origin
|
|
|
|
bra :do_render
|
2021-10-31 20:44:03 +00:00
|
|
|
:not_s
|
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
cmp #'w'
|
|
|
|
bne :not_w
|
|
|
|
lda StartY
|
|
|
|
beq :do_render
|
|
|
|
dec StartY
|
|
|
|
pei StartX
|
|
|
|
pei StartY
|
|
|
|
_GTESetBG0Origin
|
|
|
|
bra :do_render
|
2021-10-31 20:44:03 +00:00
|
|
|
:not_w
|
|
|
|
|
|
|
|
; Do j,l to move the character left/right
|
2022-06-25 16:18:50 +00:00
|
|
|
cmp #'j'
|
|
|
|
bne :not_j
|
|
|
|
lda PlayerXVel
|
|
|
|
bpl :pos_xvel
|
|
|
|
cmp #$FFFA
|
|
|
|
bcc :not_j
|
|
|
|
:pos_xvel dec
|
|
|
|
dec
|
|
|
|
sta PlayerXVel
|
|
|
|
bra :do_render
|
2021-10-31 20:44:03 +00:00
|
|
|
:not_j
|
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
cmp #'l'
|
|
|
|
bne :not_l
|
|
|
|
lda PlayerXVel
|
|
|
|
bmi :neg_xvel
|
|
|
|
cmp #6
|
|
|
|
bcs :not_l
|
|
|
|
:neg_xvel inc
|
|
|
|
inc
|
|
|
|
sta PlayerXVel
|
|
|
|
bra :do_render
|
2021-10-31 20:44:03 +00:00
|
|
|
:not_l
|
|
|
|
|
|
|
|
; Update the camera position
|
|
|
|
:do_render
|
2022-06-25 16:18:50 +00:00
|
|
|
jsr UpdatePlayerPos ; Moves in global cordinates
|
|
|
|
jsr UpdateCameraPos ; Moves the screen
|
|
|
|
jsr UpdatePlayerLocal ; Gets local sprite coordinates
|
2021-10-29 05:17:23 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
pea HERO_SLOT
|
|
|
|
lda PlayerX
|
|
|
|
pha
|
|
|
|
lda PlayerY
|
|
|
|
pha
|
|
|
|
_GTEMoveSprite ; Move the sprite to this local position
|
2021-10-29 02:41:01 +00:00
|
|
|
|
|
|
|
; Let's see what it looks like!
|
2021-11-18 21:36:36 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
; lda vsync
|
|
|
|
; beq :no_vsync
|
|
|
|
;:vsyncloop jsl GetVerticalCounter ; 8-bit value
|
|
|
|
; cmp ScreenY0
|
|
|
|
; bcc :vsyncloop
|
|
|
|
; sec
|
|
|
|
; sbc ScreenY0
|
|
|
|
; cmp #8
|
|
|
|
; bcs :vsyncloop
|
|
|
|
; lda #1
|
|
|
|
; jsl SetBorderColor
|
|
|
|
;:no_vsync
|
2022-07-22 21:01:19 +00:00
|
|
|
pea $0000
|
2022-06-25 16:18:50 +00:00
|
|
|
_GTERender
|
2021-11-12 17:27:43 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
; lda vsync
|
|
|
|
; beq :no_vsync2
|
|
|
|
; lda #0
|
|
|
|
; jsl SetBorderColor
|
|
|
|
;:no_vsync2
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-07-22 03:56:32 +00:00
|
|
|
lda runningCount
|
|
|
|
inc
|
|
|
|
sta runningCount
|
|
|
|
pha
|
|
|
|
_GTESetBG1Rotation
|
|
|
|
|
2021-10-31 00:24:23 +00:00
|
|
|
; Update the performance counters
|
|
|
|
|
|
|
|
inc frameCount
|
2022-06-25 16:18:50 +00:00
|
|
|
pha
|
|
|
|
_GTEGetSeconds
|
|
|
|
pla
|
2021-10-31 00:24:23 +00:00
|
|
|
cmp oldOneSecondCounter
|
|
|
|
beq :noudt
|
|
|
|
sta oldOneSecondCounter
|
2022-06-27 16:24:04 +00:00
|
|
|
jsr UdtOverlay
|
2021-10-31 00:24:23 +00:00
|
|
|
stz frameCount
|
2022-07-22 03:56:32 +00:00
|
|
|
|
2021-10-31 00:24:23 +00:00
|
|
|
:noudt
|
2021-10-13 20:13:52 +00:00
|
|
|
brl EvtLoop
|
|
|
|
|
|
|
|
; Exit code
|
|
|
|
Exit
|
2022-06-25 16:18:50 +00:00
|
|
|
_GTEShutDown
|
2021-10-13 20:13:52 +00:00
|
|
|
_QuitGS qtRec
|
|
|
|
|
|
|
|
bcs Fatal
|
|
|
|
Fatal brk $00
|
|
|
|
|
2022-06-27 03:08:42 +00:00
|
|
|
Hold
|
|
|
|
_GTERender
|
|
|
|
:busy
|
|
|
|
pha
|
|
|
|
_GTEReadControl
|
|
|
|
pla
|
|
|
|
and #$00FF
|
|
|
|
cmp #'q'
|
|
|
|
bne :busy
|
|
|
|
jmp Exit
|
|
|
|
|
2021-11-18 21:36:36 +00:00
|
|
|
BG1DataFile strl '1/sunset.c1'
|
2021-11-15 18:23:38 +00:00
|
|
|
|
|
|
|
; Color palette
|
2021-11-20 20:03:00 +00:00
|
|
|
MyPalette dw $068F,$0EDA,$0000,$0000,$0BF1,$00A0,$0EEE,$0456,$0FA4,$0F59,$0E30,$01CE,$02E3,$0870,$0F93,$0FD7
|
2021-11-15 18:23:38 +00:00
|
|
|
; B&W Palette
|
2022-06-27 03:08:42 +00:00
|
|
|
; MyPalette dw $0000,$0EDA,$0000,$0E51,$0BF1,$00A0,$0EEE,$0456,$0FA4,$0F59,$0E30,$01CE,$02E3,$0870,$0F93,$0FFF
|
2021-10-31 20:44:03 +00:00
|
|
|
PlayerGlobalX ds 2
|
|
|
|
PlayerGlobalY ds 2
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2021-10-29 02:41:01 +00:00
|
|
|
PlayerID ds 2
|
|
|
|
PlayerX ds 2
|
2021-10-29 03:19:18 +00:00
|
|
|
PlayerXOld ds 2
|
2021-10-29 02:41:01 +00:00
|
|
|
PlayerY ds 2
|
2021-10-29 05:52:54 +00:00
|
|
|
PlayerYOld ds 2
|
2021-10-29 03:19:18 +00:00
|
|
|
PlayerLastPos ds 2
|
2021-10-29 05:52:54 +00:00
|
|
|
PlayerXVel ds 2
|
|
|
|
PlayerYVel ds 2
|
2021-10-29 16:12:58 +00:00
|
|
|
KeyState ds 2
|
2021-10-31 20:44:03 +00:00
|
|
|
PlayerStanding ds 2
|
|
|
|
MaxGlobalX ds 2
|
|
|
|
MaxGlobalY ds 2
|
|
|
|
MaxBG0X ds 2
|
|
|
|
MaxBG0Y ds 2
|
2021-10-29 05:52:54 +00:00
|
|
|
|
2021-10-31 00:24:23 +00:00
|
|
|
oldOneSecondCounter ds 2
|
|
|
|
frameCount ds 2
|
2022-07-22 03:56:32 +00:00
|
|
|
runningCount dw 0
|
2022-06-25 16:18:50 +00:00
|
|
|
MyUserId ds 2
|
2022-06-27 16:24:04 +00:00
|
|
|
MyDirectPage ds 2
|
2021-10-31 00:24:23 +00:00
|
|
|
|
2021-10-31 20:44:03 +00:00
|
|
|
PLAYER_X_MIN equ 0
|
|
|
|
PLAYER_X_MAX equ 160-4
|
|
|
|
PLAYER_Y_MIN equ 0
|
|
|
|
PLAYER_Y_MAX equ 200-8
|
2021-10-31 00:24:23 +00:00
|
|
|
|
2021-11-03 03:01:31 +00:00
|
|
|
EMPTY_TILE equ 33 ; the tile that makes up the background
|
2021-10-29 05:52:54 +00:00
|
|
|
|
2021-10-31 20:44:03 +00:00
|
|
|
SetLimits
|
2022-06-25 16:18:50 +00:00
|
|
|
pha ; Allocate space for width (in tiles), height (in tiles), pointer
|
|
|
|
pha
|
|
|
|
pha
|
|
|
|
pha
|
|
|
|
_GTEGetBG0TileMapInfo
|
|
|
|
pla
|
|
|
|
sta TileMapWidth
|
|
|
|
pla
|
|
|
|
sta TileMapHeight
|
|
|
|
pla
|
|
|
|
pla ; discard the pointer
|
|
|
|
|
|
|
|
pha ; Allocate space for x, y, width, height
|
|
|
|
pha
|
|
|
|
pha
|
|
|
|
pha
|
|
|
|
_GTEGetScreenInfo
|
|
|
|
pla
|
|
|
|
pla ; Discard screen corner
|
|
|
|
pla
|
|
|
|
sta ScreenWidth
|
|
|
|
pla
|
|
|
|
sta ScreenHeight
|
|
|
|
|
2021-10-31 20:44:03 +00:00
|
|
|
lda TileMapWidth
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
sta MaxGlobalX
|
|
|
|
sec
|
|
|
|
sbc ScreenWidth
|
|
|
|
sta MaxBG0X
|
2021-10-31 00:24:23 +00:00
|
|
|
|
2021-10-31 20:44:03 +00:00
|
|
|
lda TileMapHeight
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
sta MaxGlobalY
|
|
|
|
sec
|
|
|
|
sbc ScreenHeight
|
|
|
|
sta MaxBG0Y
|
|
|
|
rts
|
2021-10-31 00:24:23 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
; Set the scroll position based on the global coordinates of the player
|
2021-10-31 20:44:03 +00:00
|
|
|
; Try to center the player on the screen
|
|
|
|
UpdateCameraPos
|
|
|
|
lda ScreenWidth
|
|
|
|
lsr
|
2022-06-25 16:18:50 +00:00
|
|
|
sta appTmp0
|
2021-10-31 20:44:03 +00:00
|
|
|
lda PlayerGlobalX
|
|
|
|
sec
|
2022-06-25 16:18:50 +00:00
|
|
|
sbc appTmp0
|
2021-10-31 20:44:03 +00:00
|
|
|
bpl :x_pos
|
|
|
|
lda #0
|
|
|
|
:x_pos cmp MaxBG0X
|
|
|
|
bcc :x_ok
|
|
|
|
lda MaxBG0X
|
2022-06-27 04:50:03 +00:00
|
|
|
:x_ok sta StartX
|
2021-10-31 20:44:03 +00:00
|
|
|
|
|
|
|
lda ScreenHeight
|
|
|
|
lsr
|
2022-06-25 16:18:50 +00:00
|
|
|
sta appTmp0
|
2021-10-31 20:44:03 +00:00
|
|
|
lda PlayerGlobalY
|
|
|
|
sec
|
2022-06-25 16:18:50 +00:00
|
|
|
sbc appTmp0
|
2021-10-31 20:44:03 +00:00
|
|
|
bpl :y_pos
|
|
|
|
lda #0
|
|
|
|
:y_pos cmp MaxBG0Y
|
|
|
|
bcc :y_ok
|
|
|
|
lda MaxBG0Y
|
2022-06-27 04:50:03 +00:00
|
|
|
:y_ok sta StartY
|
|
|
|
|
|
|
|
pei StartX
|
|
|
|
pei StartY
|
2022-06-25 16:18:50 +00:00
|
|
|
_GTESetBG0Origin
|
2021-11-15 18:23:38 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
pea $0000
|
2021-11-15 18:23:38 +00:00
|
|
|
lda StartY
|
|
|
|
lsr
|
2022-06-25 16:18:50 +00:00
|
|
|
pha
|
|
|
|
_GTESetBG1Origin
|
2021-10-31 00:24:23 +00:00
|
|
|
rts
|
|
|
|
|
2021-10-31 20:44:03 +00:00
|
|
|
; Convert the global coordinates to adjusted local coordinated (compensating for wrap-around)
|
|
|
|
UpdatePlayerLocal
|
|
|
|
lda PlayerGlobalX
|
|
|
|
sec
|
|
|
|
sbc StartX
|
|
|
|
sta PlayerX
|
|
|
|
|
|
|
|
lda PlayerGlobalY
|
|
|
|
sec
|
|
|
|
sbc StartY
|
|
|
|
sta PlayerY
|
|
|
|
rts
|
|
|
|
|
|
|
|
; Simple updates with gravity and collisions. It's important that eveything in this
|
|
|
|
; subroutine be done against
|
|
|
|
UpdatePlayerPos
|
|
|
|
stz PlayerStanding
|
|
|
|
lda PlayerYVel
|
|
|
|
bmi :no_ground_check
|
|
|
|
|
|
|
|
; Check if the player is standing on the ground at their current local position
|
|
|
|
|
2022-06-27 03:08:42 +00:00
|
|
|
pha ; space for result
|
2022-06-25 16:18:50 +00:00
|
|
|
lda PlayerX
|
|
|
|
pha
|
2021-10-31 20:44:03 +00:00
|
|
|
lda PlayerY
|
|
|
|
clc
|
2021-11-11 23:06:38 +00:00
|
|
|
adc #16
|
2022-06-25 16:18:50 +00:00
|
|
|
pha
|
|
|
|
_GTEGetTileAt
|
|
|
|
pla
|
|
|
|
and #TILE_ID_MASK
|
2021-10-31 20:44:03 +00:00
|
|
|
cmp #EMPTY_TILE
|
|
|
|
beq :no_ground_check
|
|
|
|
|
|
|
|
lda PlayerGlobalY
|
|
|
|
and #$fff8
|
|
|
|
sta PlayerGlobalY
|
|
|
|
stz PlayerYVel
|
|
|
|
lda #1
|
|
|
|
sta PlayerStanding
|
|
|
|
|
|
|
|
:no_ground_check
|
|
|
|
lda PlayerGlobalY
|
|
|
|
clc
|
|
|
|
adc PlayerYVel
|
|
|
|
bpl *+5
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
cmp MaxGlobalY
|
|
|
|
bcc *+5
|
|
|
|
lda MaxGlobalY
|
|
|
|
sta PlayerGlobalY
|
|
|
|
|
|
|
|
lda PlayerGlobalX
|
|
|
|
clc
|
|
|
|
adc PlayerXVel
|
|
|
|
bpl *+5
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
cmp MaxGlobalX
|
|
|
|
bcc *+5
|
|
|
|
lda MaxGlobalX
|
|
|
|
sta PlayerGlobalX
|
|
|
|
|
2021-11-20 20:03:00 +00:00
|
|
|
ldx LastHFlip
|
2021-10-31 20:44:03 +00:00
|
|
|
lda PlayerXVel
|
|
|
|
beq :no_dxv
|
|
|
|
bpl :pos_dxv
|
2021-11-20 18:16:03 +00:00
|
|
|
ldx #SPRITE_HFLIP
|
2021-10-31 20:44:03 +00:00
|
|
|
inc
|
|
|
|
bra :no_dxv
|
|
|
|
:pos_dxv
|
2021-11-20 20:03:00 +00:00
|
|
|
ldx #0
|
2021-10-31 20:44:03 +00:00
|
|
|
dec
|
|
|
|
:no_dxv
|
|
|
|
sta PlayerXVel
|
2021-11-20 20:03:00 +00:00
|
|
|
stx LastHFlip
|
2021-10-31 20:44:03 +00:00
|
|
|
|
2021-11-20 18:16:03 +00:00
|
|
|
ldx #0
|
2021-11-02 04:36:53 +00:00
|
|
|
lda PlayerStanding
|
|
|
|
bne :too_fast
|
|
|
|
|
2021-10-31 20:44:03 +00:00
|
|
|
lda PlayerYVel
|
|
|
|
inc
|
|
|
|
bmi :is_neg
|
|
|
|
cmp #4
|
|
|
|
bcs :too_fast
|
|
|
|
:is_neg
|
2021-11-20 18:16:03 +00:00
|
|
|
ldx #SPRITE_VFLIP
|
2021-10-31 20:44:03 +00:00
|
|
|
sta PlayerYVel
|
|
|
|
:too_fast
|
2021-11-20 18:16:03 +00:00
|
|
|
|
|
|
|
txa
|
2021-11-20 20:03:00 +00:00
|
|
|
ora LastHFlip
|
2022-06-25 16:18:50 +00:00
|
|
|
ora #HERO_ID
|
2021-11-21 02:33:27 +00:00
|
|
|
sta SpriteFrame
|
|
|
|
|
2021-11-22 19:27:27 +00:00
|
|
|
lda SpriteCount
|
|
|
|
eor SpriteToggle
|
|
|
|
sta SpriteCount
|
|
|
|
|
2021-11-21 02:33:27 +00:00
|
|
|
; If the player is standing and XVel != 0, pick a frame
|
|
|
|
lda PlayerStanding
|
|
|
|
beq :frame
|
|
|
|
lda PlayerXVel
|
|
|
|
beq :frame
|
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
jsr _GetVBLTicks
|
2021-11-21 02:33:27 +00:00
|
|
|
and #$0003
|
|
|
|
inc
|
|
|
|
and #$0003
|
|
|
|
asl
|
|
|
|
adc SpriteFrame
|
|
|
|
sta SpriteFrame
|
|
|
|
:frame
|
2021-11-22 19:27:27 +00:00
|
|
|
lda SpriteFrame
|
|
|
|
ora SpriteCount
|
|
|
|
tax
|
2021-11-21 02:33:27 +00:00
|
|
|
|
2021-11-20 18:16:03 +00:00
|
|
|
lda PlayerID
|
2022-06-25 16:18:50 +00:00
|
|
|
; jsl UpdateSprite ; Change the tile ID and / or flags
|
2021-11-20 18:16:03 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
; pea HERO_SLOT
|
|
|
|
; pei Flips ; with these flags (h/v flip)
|
|
|
|
; pea VBUFF_SPRITE_START ; and use this stamp
|
|
|
|
; _GTEUpdateSprite
|
|
|
|
|
2021-10-31 20:44:03 +00:00
|
|
|
rts
|
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
ToolPath str '1/Tool160'
|
2021-11-20 20:03:00 +00:00
|
|
|
LastHFlip dw 0
|
2021-11-21 02:33:27 +00:00
|
|
|
SpriteFrame ds 2
|
2021-11-22 19:27:27 +00:00
|
|
|
SpriteCount dw 0
|
|
|
|
SpriteToggle dw 0
|
2021-11-21 02:33:27 +00:00
|
|
|
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2021-11-15 18:23:38 +00:00
|
|
|
openRec dw 2 ; pCount
|
|
|
|
ds 2 ; refNum
|
|
|
|
adrl BG1DataFile ; pathname
|
|
|
|
|
|
|
|
eofRec dw 2 ; pCount
|
|
|
|
ds 2 ; refNum
|
|
|
|
ds 4 ; eof
|
|
|
|
|
|
|
|
readRec dw 4 ; pCount
|
|
|
|
ds 2 ; refNum
|
|
|
|
ds 4 ; dataBuffer
|
|
|
|
ds 4 ; requestCount
|
|
|
|
ds 4 ; transferCount
|
|
|
|
|
|
|
|
closeRec dw 1 ; pCount
|
|
|
|
ds 2 ; refNum
|
|
|
|
|
2021-10-13 20:13:52 +00:00
|
|
|
qtRec adrl $0000
|
|
|
|
da $00
|
|
|
|
|
2021-11-12 17:27:43 +00:00
|
|
|
vsync dw $0000
|
|
|
|
|
2021-11-15 18:23:38 +00:00
|
|
|
|
|
|
|
LoadFile
|
|
|
|
stx openRec+4 ; X=File, A=Bank (high word) assumed zero for low
|
|
|
|
stz readRec+4
|
|
|
|
sta readRec+6
|
|
|
|
|
|
|
|
:openFile _OpenGS openRec
|
|
|
|
bcs :openReadErr
|
|
|
|
lda openRec+2
|
|
|
|
sta eofRec+2
|
|
|
|
sta readRec+2
|
|
|
|
|
|
|
|
_GetEOFGS eofRec
|
|
|
|
lda eofRec+4
|
|
|
|
sta readRec+8
|
|
|
|
lda eofRec+6
|
|
|
|
sta readRec+10
|
|
|
|
|
|
|
|
_ReadGS readRec
|
|
|
|
bcs :openReadErr
|
|
|
|
|
|
|
|
:closeFile _CloseGS closeRec
|
|
|
|
clc
|
|
|
|
lda eofRec+4 ; File Size
|
|
|
|
rts
|
|
|
|
|
|
|
|
:openReadErr jsr :closeFile
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
|
|
|
|
PushWord #0
|
|
|
|
PushLong #msgLine1
|
|
|
|
PushLong #msgLine2
|
|
|
|
PushLong #msgLine3
|
|
|
|
PushLong #msgLine4
|
|
|
|
_TLTextMountVolume
|
|
|
|
pla
|
|
|
|
cmp #1
|
|
|
|
bne :loadFileErr
|
|
|
|
brl :openFile
|
|
|
|
:loadFileErr sec
|
|
|
|
rts
|
|
|
|
|
|
|
|
msgLine1 str 'Unable to load File'
|
|
|
|
msgLine2 str 'Press a key :'
|
|
|
|
msgLine3 str ' -> Return to Try Again'
|
|
|
|
msgLine4 str ' -> Esc to Quit'
|
|
|
|
|
2021-10-13 20:13:52 +00:00
|
|
|
|
2022-06-25 16:18:50 +00:00
|
|
|
; Load the GTE User Tool and install it
|
|
|
|
GTEStartUp
|
|
|
|
pea $0000
|
|
|
|
_LoaderStatus
|
|
|
|
pla
|
|
|
|
|
|
|
|
pea $0000
|
|
|
|
pea $0000
|
|
|
|
pea $0000
|
|
|
|
pea $0000
|
|
|
|
pea $0000 ; result space
|
|
|
|
|
|
|
|
lda MyUserId
|
|
|
|
pha
|
|
|
|
|
|
|
|
pea #^ToolPath
|
|
|
|
pea #ToolPath
|
|
|
|
pea $0001 ; do not load into special memory
|
|
|
|
_InitialLoad
|
|
|
|
bcc :ok1
|
|
|
|
brk $01
|
|
|
|
|
|
|
|
:ok1
|
|
|
|
ply
|
|
|
|
pla ; Address of the loaded tool
|
|
|
|
plx
|
|
|
|
ply
|
|
|
|
ply
|
|
|
|
|
|
|
|
pea $8000 ; User toolset
|
|
|
|
pea $00A0 ; Set the tool set number
|
|
|
|
phx
|
|
|
|
pha ; Address of function pointer table
|
|
|
|
_SetTSPtr
|
|
|
|
bcc :ok2
|
|
|
|
brk $02
|
|
|
|
|
|
|
|
:ok2
|
|
|
|
clc ; Give GTE a page of direct page memory
|
|
|
|
tdc
|
|
|
|
adc #$0100
|
|
|
|
pha
|
|
|
|
pea #ENGINE_MODE_DYN_TILES+ENGINE_MODE_TWO_LAYER ; Enable Dynamic Tiles and Two Layer
|
|
|
|
lda MyUserId ; Pass the userId for memory allocation
|
|
|
|
pha
|
|
|
|
_GTEStartUp
|
|
|
|
bcc :ok3
|
|
|
|
brk $03
|
|
|
|
|
|
|
|
:ok3
|
|
|
|
rts
|
|
|
|
|
|
|
|
_Deref MAC
|
|
|
|
phb ; save caller's data bank register
|
|
|
|
pha ; push high word of handle on stack
|
|
|
|
plb ; sets B to the bank byte of the pointer
|
|
|
|
lda |$0002,x ; load the high word of the master pointer
|
|
|
|
pha ; and save it on the stack
|
|
|
|
lda |$0000,x ; load the low word of the master pointer
|
|
|
|
tax ; and return it in X
|
|
|
|
pla ; restore the high word in A
|
|
|
|
plb ; pull the handle's high word high byte off the
|
|
|
|
; stack
|
|
|
|
plb ; restore the caller's data bank register
|
|
|
|
<<<
|
|
|
|
|
|
|
|
AllocBank PushLong #0
|
|
|
|
PushLong #$10000
|
|
|
|
PushWord MyUserId
|
|
|
|
PushWord #%11000000_00011100
|
|
|
|
PushLong #0
|
|
|
|
_NewHandle
|
|
|
|
plx ; base address of the new handle
|
|
|
|
pla ; high address 00XX of the new handle (bank)
|
|
|
|
_Deref
|
|
|
|
rts
|
|
|
|
|
|
|
|
_GetVBLTicks
|
|
|
|
PushLong #0
|
|
|
|
_GetTick
|
|
|
|
pla
|
|
|
|
plx
|
|
|
|
rts
|
|
|
|
|
2022-06-27 16:24:04 +00:00
|
|
|
PUT ../shell/Overlay.s
|
|
|
|
PUT gen/App.TileMapBG0.s
|
|
|
|
PUT gen/App.TileSetAnim.s
|