iigs-game-engine/demos/tool/App.Main.s

207 lines
5.0 KiB
ArmAsm
Raw Normal View History

REL
DSK MAINSEG
use Locator.Macs
use Load.Macs
use Mem.Macs
use Misc.Macs
use Util.Macs
use EDS.GSOS.Macs
2022-04-24 19:45:07 +00:00
use GTE.Macs
2022-05-20 04:39:19 +00:00
use ../../src/Defs.s
mx %00
TSZelda EXT ; tileset buffer
ScreenX equ 0
ScreenY equ 2
; Typical init
phk
plb
2022-05-20 04:39:19 +00:00
sta MyUserId ; GS/OS passes the memory manager user ID for the aoplication into the program
2022-04-24 19:45:07 +00:00
_MTStartUp ; GTE requires the miscellaneous toolset to be running
2022-04-24 19:45:07 +00:00
jsr GTEStartUp ; Load and install the GTE User Tool
; Initialize the graphics screen to a 256x160 playfield
pea #256
pea #160
_GTESetScreenMode
; Load a tileset
pea #^TSZelda
pea #TSZelda
_GTELoadTileSet
; Manually fill in the 41x26 tiles of the TileStore with a test pattern.
ldx #0
ldy #0
:loop
phx
phy
phx
phy
pei 0
_GTESetTile
lda 0
inc
and #$001F
sta 0
ply
plx
inx
cpx #41
bcc :loop
ldx #0
iny
cpy #26
bcc :loop
; Set the origin of the screen
2022-05-20 04:39:19 +00:00
lda #3
sta ScreenX
lda #10
sta ScreenY
pea #3
pea #10
_GTESetBG0Origin
2022-04-24 19:45:07 +00:00
; Very simple actions
2022-05-20 04:39:19 +00:00
:evt_loop
2022-04-24 19:45:07 +00:00
pha ; space for result, with pattern
_GTEReadControl
pla
and #$00FF
cmp #'q'
beq :exit
2022-05-20 04:39:19 +00:00
cmp #$15 ; left = $08, right = $15, up = $0B, down = $0A
bne :8
inc ScreenX
bra :next
:8 cmp #$08
bne :9
dec ScreenX
bra :next
:9 cmp #$0B
bne :10
inc ScreenY
bra :next
:10 cmp #$0A
bne :next
dec ScreenY
:next
2022-04-29 17:38:04 +00:00
pei ScreenX
pei ScreenY
_GTESetBG0Origin
_GTERender
2022-05-20 04:39:19 +00:00
; Debug stuff
ldx #$100
lda StartX,x
ldx #0
jsr DrawWord
ldx #$100
lda StartY,x
ldx #160*8
jsr DrawWord
lda ScreenX
ldx #160*16
jsr DrawWord
lda ScreenY
ldx #160*24
jsr DrawWord
tdc
ldx #160*32
jsr DrawWord
brl :evt_loop
; Shut down everything
:exit
2022-04-24 19:45:07 +00:00
_GTEShutDown
_QuitGS qtRec
qtRec adrl $0000
da $00
2022-04-24 19:45:07 +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
2022-05-20 04:39:19 +00:00
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
2022-04-24 19:45:07 +00:00
pea $0000 ; No extra capabilities
2022-05-20 04:39:19 +00:00
lda MyUserId ; Pass the userId for memory allocation
pha
_GTEStartUp
bcc :ok3
brk $03
:ok3
rts
2022-05-20 04:39:19 +00:00
MyUserId ds 2
ToolPath str '1/Tool160'
PUT App.Msg.s
PUT font.s