mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2024-06-04 05:29:33 +00:00
Basic working user tool framework
This commit is contained in:
parent
1f9f2aee0c
commit
76180b6feb
|
@ -7,10 +7,7 @@
|
||||||
use Misc.Macs
|
use Misc.Macs
|
||||||
use Util.Macs
|
use Util.Macs
|
||||||
use EDS.GSOS.Macs
|
use EDS.GSOS.Macs
|
||||||
|
use GTE.Macs
|
||||||
_GTEStartUp MAC
|
|
||||||
UserTool $02A0
|
|
||||||
<<<
|
|
||||||
|
|
||||||
mx %00
|
mx %00
|
||||||
|
|
||||||
|
@ -18,31 +15,27 @@ _GTEStartUp MAC
|
||||||
phk
|
phk
|
||||||
plb
|
plb
|
||||||
|
|
||||||
sta UserId ; GS/OS passed the memory manager user ID for the aoplication into the program
|
sta UserId ; GS/OS passes the memory manager user ID for the aoplication into the program
|
||||||
|
_MTStartUp ; GTE requires the miscellaneous toolset to be running
|
||||||
|
|
||||||
jsr ToolStartUp ; Start up the basic tools: Locator, Memory Manager, Misc
|
jsr GTEStartUp ; Load and install the GTE User Tool
|
||||||
jsr GTEStartUp
|
|
||||||
|
|
||||||
|
; Very simple actions
|
||||||
|
:loop
|
||||||
|
pha ; space for result, with pattern
|
||||||
|
_GTEReadControl
|
||||||
|
pla
|
||||||
|
and #$00FF
|
||||||
|
cmp #'q'
|
||||||
|
bne :loop
|
||||||
|
|
||||||
|
; Shut down eveything
|
||||||
|
_GTEShutDown
|
||||||
_QuitGS qtRec
|
_QuitGS qtRec
|
||||||
|
|
||||||
bcs Fatal
|
|
||||||
Fatal brk $00
|
|
||||||
qtRec adrl $0000
|
qtRec adrl $0000
|
||||||
da $00
|
da $00
|
||||||
|
|
||||||
ToolStartUp
|
; Load the GTE User Tool and install it
|
||||||
; _TLStartUp ; normal tool initialization
|
|
||||||
; pha
|
|
||||||
; _MMStartUp
|
|
||||||
; pla
|
|
||||||
; sta MasterId ; our master handle references the memory allocated to us
|
|
||||||
; ora #$0100 ; set auxID = $01 (valid values $01-0f)
|
|
||||||
; sta UserId ; any memory we request must use our own id
|
|
||||||
|
|
||||||
_MTStartUp ; just start up the miscellaneous tools
|
|
||||||
rts
|
|
||||||
|
|
||||||
; Load the GTE User Tool and register it
|
|
||||||
GTEStartUp
|
GTEStartUp
|
||||||
pea $0000
|
pea $0000
|
||||||
_LoaderStatus
|
_LoaderStatus
|
||||||
|
@ -60,12 +53,10 @@ GTEStartUp
|
||||||
pea #^ToolPath
|
pea #^ToolPath
|
||||||
pea #ToolPath
|
pea #ToolPath
|
||||||
pea $0001 ; do not load into special memory
|
pea $0001 ; do not load into special memory
|
||||||
; pea $0001 ; GS/OS string for the argument
|
|
||||||
_InitialLoad
|
_InitialLoad
|
||||||
bcc :ok1
|
bcc :ok1
|
||||||
brk $01
|
brk $01
|
||||||
|
|
||||||
|
|
||||||
:ok1
|
:ok1
|
||||||
ply
|
ply
|
||||||
pla ; Address of the loaded tool
|
pla ; Address of the loaded tool
|
||||||
|
@ -86,7 +77,8 @@ GTEStartUp
|
||||||
tdc
|
tdc
|
||||||
adc #$0100
|
adc #$0100
|
||||||
pha
|
pha
|
||||||
lda UserId
|
pea $0000 ; No extra capabilities
|
||||||
|
lda UserId ; Pass the userId for memory allocation
|
||||||
pha
|
pha
|
||||||
_GTEStartUp
|
_GTEStartUp
|
||||||
bcc :ok3
|
bcc :ok3
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run build && build-image.bat %npm_package_config_cadius% && %npm_package_config_gsport%",
|
"test": "npm run build && build-image.bat %npm_package_config_cadius% && %npm_package_config_gsport%",
|
||||||
"debug": "%npm_package_config_crossrunner% GTEToolTest -Source GTEToolTest_S02_MAINSEG_Output.txt -Debug -CompatibilityLayer",
|
"debug": "%npm_package_config_crossrunner% GTEToolDemo -Source MAINSEG_Output.txt -Debug -CompatibilityLayer",
|
||||||
"build": "%npm_package_config_merlin32% -V %npm_package_config_macros% App.s"
|
"build": "%npm_package_config_merlin32% -V %npm_package_config_macros% App.s"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
26
macros/GTE.Macs.s
Normal file
26
macros/GTE.Macs.s
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
* Generic Tile Engine Macros
|
||||||
|
* by Lucas Scharenbroich
|
||||||
|
|
||||||
|
GTEToolNum equ $A0
|
||||||
|
|
||||||
|
_GTEBootInit MAC
|
||||||
|
UserTool $100+GTEToolNum
|
||||||
|
<<<
|
||||||
|
_GTEStartUp MAC
|
||||||
|
UserTool $200+GTEToolNum
|
||||||
|
<<<
|
||||||
|
_GTEShutDown MAC
|
||||||
|
UserTool $300+GTEToolNum
|
||||||
|
<<<
|
||||||
|
_GTEVersion MAC
|
||||||
|
UserTool $400+GTEToolNum
|
||||||
|
<<<
|
||||||
|
_GTEReset MAC
|
||||||
|
UserTool $500+GTEToolNum
|
||||||
|
<<<
|
||||||
|
_GTEStatus MAC
|
||||||
|
UserTool $600+GTEToolNum
|
||||||
|
<<<
|
||||||
|
_GTEReadControl MAC
|
||||||
|
UserTool $900+GTEToolNum
|
||||||
|
<<<
|
|
@ -85,8 +85,7 @@ Overlay EXT
|
||||||
|
|
||||||
mx %00
|
mx %00
|
||||||
|
|
||||||
; A = memory manager userId
|
; Assumes the direct page is set and EngineMode and UserId has been initialized
|
||||||
; X = tool number
|
|
||||||
_CoreStartUp
|
_CoreStartUp
|
||||||
jsr IntStartUp ; Enable certain interrupts
|
jsr IntStartUp ; Enable certain interrupts
|
||||||
|
|
||||||
|
@ -194,7 +193,7 @@ EngineReset
|
||||||
stz OldStartY
|
stz OldStartY
|
||||||
stz StartYMod208
|
stz StartYMod208
|
||||||
|
|
||||||
stz EngineMode
|
; stz EngineMode
|
||||||
stz DirtyBits
|
stz DirtyBits
|
||||||
stz LastRender
|
stz LastRender
|
||||||
stz LastPatchOffset
|
stz LastPatchOffset
|
||||||
|
|
|
@ -34,6 +34,8 @@ StartX equ 16 ; Which code buffer byte is the left ed
|
||||||
StartY equ 18 ; Which code buffer line is the top of the screen. Range = 0 to 207
|
StartY equ 18 ; Which code buffer line is the top of the screen. Range = 0 to 207
|
||||||
EngineMode equ 20 ; Defined the mode/capabilities that are enabled
|
EngineMode equ 20 ; Defined the mode/capabilities that are enabled
|
||||||
; bit 0: 0 = Single Background, 1 = Parallax
|
; bit 0: 0 = Single Background, 1 = Parallax
|
||||||
|
; bit 1: 0 = No Dynamic Tiles, 1 = Allocate Bank 00 space for dynamic tiles
|
||||||
|
; bit 2: 0 = No static buffer, 1 = Allocation Bank 00 space for a static screen buffer
|
||||||
DirtyBits equ 22 ; Identify values that have changed between frames
|
DirtyBits equ 22 ; Identify values that have changed between frames
|
||||||
|
|
||||||
BG1DataBank equ 24 ; Data bank that holds BG1 layer data
|
BG1DataBank equ 24 ; Data bank that holds BG1 layer data
|
||||||
|
@ -143,7 +145,12 @@ FREE_SPACE_DP2 equ 160
|
||||||
|
|
||||||
; End direct page values
|
; End direct page values
|
||||||
|
|
||||||
|
; EngineMode definitions
|
||||||
|
ENGINE_MODE_TWO_LAYER equ $0001
|
||||||
|
ENGINE_MODE_DYN_TILES equ $0002
|
||||||
|
ENGINE_MODE_BNK0_BUFF equ $0004
|
||||||
|
|
||||||
|
; DirtyBits definitions
|
||||||
DIRTY_BIT_BG0_X equ $0001
|
DIRTY_BIT_BG0_X equ $0001
|
||||||
DIRTY_BIT_BG0_Y equ $0002
|
DIRTY_BIT_BG0_Y equ $0002
|
||||||
DIRTY_BIT_BG1_X equ $0004
|
DIRTY_BIT_BG1_X equ $0004
|
||||||
|
|
21
src/Memory.s
21
src/Memory.s
|
@ -16,7 +16,11 @@
|
||||||
|
|
||||||
mx %00
|
mx %00
|
||||||
|
|
||||||
InitMemory PushLong #0 ; space for result
|
InitMemory lda EngineMode
|
||||||
|
bit #ENGINE_MODE_BNK0_BUFF
|
||||||
|
beq :no_bnk0_buff
|
||||||
|
|
||||||
|
PushLong #0 ; space for result
|
||||||
PushLong #$008000 ; size (32k)
|
PushLong #$008000 ; size (32k)
|
||||||
PushWord UserId
|
PushWord UserId
|
||||||
PushWord #%11000000_00010111 ; Fixed location
|
PushWord #%11000000_00010111 ; Fixed location
|
||||||
|
@ -27,6 +31,7 @@ InitMemory PushLong #0 ; space for result
|
||||||
_Deref
|
_Deref
|
||||||
stx Buff00
|
stx Buff00
|
||||||
sta Buff00+2
|
sta Buff00+2
|
||||||
|
:no_bnk0_buff
|
||||||
|
|
||||||
PushLong #0 ; space for result
|
PushLong #0 ; space for result
|
||||||
PushLong #$008000 ; size (32k)
|
PushLong #$008000 ; size (32k)
|
||||||
|
@ -41,7 +46,15 @@ InitMemory PushLong #0 ; space for result
|
||||||
sta Buff01+2
|
sta Buff01+2
|
||||||
|
|
||||||
PushLong #0 ; space for result
|
PushLong #0 ; space for result
|
||||||
PushLong #$000A00 ; size (10 pages)
|
|
||||||
|
pea #0000 ; size (2 or 10 pages)
|
||||||
|
lda EngineMode
|
||||||
|
bit #ENGINE_MODE_DYN_TILES
|
||||||
|
beq :no_dyn_tiles
|
||||||
|
pea #$0A00 ; 10 pages if dynamic tiles are enabled
|
||||||
|
bra :dyn_done
|
||||||
|
:no_dyn_tiles pea #$0200 ; 2 pages if dynamic tiles are disabled
|
||||||
|
:dyn_done
|
||||||
PushWord UserId
|
PushWord UserId
|
||||||
PushWord #%11000000_00010101 ; Page-aligned, fixed bank
|
PushWord #%11000000_00010101 ; Page-aligned, fixed bank
|
||||||
PushLong #$000000
|
PushLong #$000000
|
||||||
|
@ -52,11 +65,15 @@ InitMemory PushLong #0 ; space for result
|
||||||
stx BlitterDP
|
stx BlitterDP
|
||||||
|
|
||||||
; Allocate banks of memory for BG1
|
; Allocate banks of memory for BG1
|
||||||
|
lda EngineMode
|
||||||
|
bit #ENGINE_MODE_TWO_LAYER
|
||||||
|
beq :no_bg1
|
||||||
jsr AllocOneBank2
|
jsr AllocOneBank2
|
||||||
sta BG1DataBank
|
sta BG1DataBank
|
||||||
|
|
||||||
jsr AllocOneBank2
|
jsr AllocOneBank2
|
||||||
sta BG1AltBank
|
sta BG1AltBank
|
||||||
|
:no_bg1
|
||||||
|
|
||||||
; Allocate the 13 banks of memory we need and store in double-length array
|
; Allocate the 13 banks of memory we need and store in double-length array
|
||||||
]step equ 0
|
]step equ 0
|
||||||
|
|
66
src/Tool.s
66
src/Tool.s
|
@ -14,6 +14,25 @@
|
||||||
|
|
||||||
ToStrip equ $E10184
|
ToStrip equ $E10184
|
||||||
|
|
||||||
|
; Define some macros to help streamline the entry and exit from the toolbox calls
|
||||||
|
_TSEntry mac
|
||||||
|
phd
|
||||||
|
phb
|
||||||
|
tcd
|
||||||
|
phk ; Default to setting the data back to the current bank.
|
||||||
|
plb
|
||||||
|
<<<
|
||||||
|
|
||||||
|
_TSExit mac
|
||||||
|
plb
|
||||||
|
pld
|
||||||
|
ldx ]1 ; Error code
|
||||||
|
ldy ]2 ; Number of stack bytes to remove
|
||||||
|
jml ToStrip
|
||||||
|
<<<
|
||||||
|
|
||||||
|
FirstParam equ 10 ; When using the _TSEntry macro, the first parameter is at 10,s
|
||||||
|
|
||||||
mx %00
|
mx %00
|
||||||
|
|
||||||
_CallTable
|
_CallTable
|
||||||
|
@ -27,7 +46,8 @@ _CallTable
|
||||||
adrl _TSReserved-1
|
adrl _TSReserved-1
|
||||||
adrl _TSReserved-1
|
adrl _TSReserved-1
|
||||||
|
|
||||||
adrl _TSSetScreenMode
|
adrl _TSReadControl-1
|
||||||
|
adrl _TSSetScreenMode-1
|
||||||
_CTEnd
|
_CTEnd
|
||||||
|
|
||||||
; Do nothing when the tool set is installed
|
; Do nothing when the tool set is installed
|
||||||
|
@ -39,13 +59,14 @@ _TSBootInit
|
||||||
; Call the regular GTE startup function after setting the Work Area Pointer (WAP). The caller must provide
|
; Call the regular GTE startup function after setting the Work Area Pointer (WAP). The caller must provide
|
||||||
; one page of Bank 0 memory for the tool set's private use and a userId to use for allocating memory
|
; one page of Bank 0 memory for the tool set's private use and a userId to use for allocating memory
|
||||||
;
|
;
|
||||||
; X = tool set number in low byte and function umber in high byte
|
; X = tool set number in low byte and function number in high byte
|
||||||
;
|
;
|
||||||
; StartUp(dPageAddr, userId)
|
; StartUp(dPageAddr, capFlags, userId)
|
||||||
_TSStartUp
|
_TSStartUp
|
||||||
|
|
||||||
userId = 7
|
userId = 7
|
||||||
zpToUse = userId+2
|
capFlags = userId+2
|
||||||
|
zpToUse = userId+4
|
||||||
|
|
||||||
lda zpToUse,s ; Get the direct page address
|
lda zpToUse,s ; Get the direct page address
|
||||||
phd ; Save the current direct page
|
phd ; Save the current direct page
|
||||||
|
@ -58,6 +79,9 @@ zpToUse = userId+2
|
||||||
lda userId+2,s ; Get the userId for memory allocations
|
lda userId+2,s ; Get the userId for memory allocations
|
||||||
sta UserId
|
sta UserId
|
||||||
|
|
||||||
|
lda capFlags+2,s ; Get the engine capability bits
|
||||||
|
sta EngineMode
|
||||||
|
|
||||||
jsr _CoreStartUp ; Initialize the library
|
jsr _CoreStartUp ; Initialize the library
|
||||||
|
|
||||||
; SetWAP(userOrSystem, tsNum, waptPtr)
|
; SetWAP(userOrSystem, tsNum, waptPtr)
|
||||||
|
@ -71,9 +95,10 @@ zpToUse = userId+2
|
||||||
pld ; Restore the caller's direct page
|
pld ; Restore the caller's direct page
|
||||||
|
|
||||||
ldx #0 ; No error
|
ldx #0 ; No error
|
||||||
ldy #4 ; Remove the 4 input bytes
|
ldy #6 ; Remove the 6 input bytes
|
||||||
jml ToStrip
|
jml ToStrip
|
||||||
|
|
||||||
|
; ShutDown()
|
||||||
_TSShutDown
|
_TSShutDown
|
||||||
cmp #0 ; Acc is low word of the WAP (direct page)
|
cmp #0 ; Acc is low word of the WAP (direct page)
|
||||||
beq :inactive
|
beq :inactive
|
||||||
|
@ -114,7 +139,7 @@ _TSStatus
|
||||||
sta 1,s
|
sta 1,s
|
||||||
tya
|
tya
|
||||||
ora 1,s
|
ora 1,s
|
||||||
sta 1,s ; 0 if WAP is null, non-zero if WAP is set
|
sta 1,s ; 0 if WAP is null, non-zero if WAP is set
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
clc
|
clc
|
||||||
|
@ -129,37 +154,28 @@ _TSReserved
|
||||||
|
|
||||||
; SetScreenMode(width, height)
|
; SetScreenMode(width, height)
|
||||||
_TSSetScreenMode
|
_TSSetScreenMode
|
||||||
:height equ 9
|
height equ FirstParam
|
||||||
:width equ 11
|
width equ FirstParam+2
|
||||||
|
|
||||||
phd ; Preserve the direct page
|
_TSEntry
|
||||||
tcd ; Set the tool set direct pafe from WAP
|
|
||||||
|
|
||||||
lda :height,s
|
lda height,s
|
||||||
tay
|
tay
|
||||||
lda :width,s
|
lda width,s
|
||||||
tax
|
tax
|
||||||
; jsr _SetScreenMode ; Not implemented yet
|
; jsr _SetScreenMode ; Not implemented yet
|
||||||
|
|
||||||
pld ; Restore direct page
|
_TSExit #0;#4
|
||||||
|
|
||||||
ldx #0 ; No error
|
|
||||||
ldy #4 ; Remove the 4 input bytes
|
|
||||||
jml ToStrip
|
|
||||||
|
|
||||||
_TSReadControl
|
_TSReadControl
|
||||||
:output equ 9
|
output equ FirstParam
|
||||||
|
|
||||||
phd ; Preserve the direct page
|
_TSEntry
|
||||||
tcd
|
|
||||||
|
|
||||||
jsr _ReadControl
|
jsr _ReadControl
|
||||||
sta :output,s
|
sta output,s
|
||||||
|
|
||||||
pld
|
_TSExit #0;#0
|
||||||
ldx #0 ; No error
|
|
||||||
ldy #0 ; Remove zero input bytes
|
|
||||||
jml ToStrip
|
|
||||||
|
|
||||||
; Insert the core GTE functions
|
; Insert the core GTE functions
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user