diff --git a/res/DEMO/ALIEN.DOWNPOUR b/res/DEMO/ALIEN.DOWNPOUR index aff0a99f7..e8f92b33a 100755 Binary files a/res/DEMO/ALIEN.DOWNPOUR and b/res/DEMO/ALIEN.DOWNPOUR differ diff --git a/res/DEMO/CHOPLIFTER b/res/DEMO/CHOPLIFTER index 184ba600c..13a16a30c 100755 Binary files a/res/DEMO/CHOPLIFTER and b/res/DEMO/CHOPLIFTER differ diff --git a/res/DEMO/NIGHT.STALKER b/res/DEMO/NIGHT.STALKER index a07f501a3..4c7435f1c 100755 Binary files a/res/DEMO/NIGHT.STALKER and b/res/DEMO/NIGHT.STALKER differ diff --git a/res/DEMO/SNEAKERS b/res/DEMO/SNEAKERS index 96714ec24..cfc899fb9 100644 Binary files a/res/DEMO/SNEAKERS and b/res/DEMO/SNEAKERS differ diff --git a/res/DEMO/SPACE.QUARKS b/res/DEMO/SPACE.QUARKS index abe2d39ef..97c70f505 100755 Binary files a/res/DEMO/SPACE.QUARKS and b/res/DEMO/SPACE.QUARKS differ diff --git a/res/DEMO/TB b/res/DEMO/TB index 4c901f6eb..88fb44eda 100755 Binary files a/res/DEMO/TB and b/res/DEMO/TB differ diff --git a/res/DEMO/WAVY.NAVY b/res/DEMO/WAVY.NAVY index cd567893b..43166f65a 100644 Binary files a/res/DEMO/WAVY.NAVY and b/res/DEMO/WAVY.NAVY differ diff --git a/src/constants.a b/src/constants.a index 72f547713..53f1a72e2 100644 --- a/src/constants.a +++ b/src/constants.a @@ -7,7 +7,7 @@ ; ; LC RAM BANK 1 ; D000..E789 - persistent data structures (gGlobalPrefsStore, gGamesListStore) -; E911..FFF1 - main program code +; E981..FFF1 - main program code ; FFF2..FFF9 - API functions and global constants available for main program ; code, prelaunchers, transition effects, &c. ; (Wait/UnwaitForVBL, MockingboardStuff, MachineStatus) @@ -16,8 +16,8 @@ ; LC RAM BANK 2 ; D000..D3FF - ProRWTS data ; D400..D66F - ProRWTS code -; D670..DB95 - HGR font code & ProRWTS glue code -; DB96..DBA5 - backup of stack (during gameplay and self-running demos) +; D670..DB93 - HGR font code & ProRWTS glue code +; DB94..DBA3 - backup of stack (during gameplay and self-running demos) ; ...unused... ; DBB4..DBFF - (de)acceleration function ; DC00..DFFF - HGR font data @@ -148,8 +148,7 @@ CHEATS_ENABLED = %00001000 iCurBlockLo = $D401 iCurBlockHi = $D403 iProDOS_enter = $D670 -LoadFileDirect = $DAF9 -iAuxReq = $DB1F +LoadFileDirect = $DAF6 launchpatch = $D60E iAddToPath = $FE78 itraverse = $D8D8 diff --git a/src/demosrc/alien.downpour.a b/src/demo/alien.downpour.a similarity index 100% rename from src/demosrc/alien.downpour.a rename to src/demo/alien.downpour.a diff --git a/src/demosrc/choplifter.a b/src/demo/choplifter.a similarity index 100% rename from src/demosrc/choplifter.a rename to src/demo/choplifter.a diff --git a/src/demosrc/night.stalker.a b/src/demo/night.stalker.a similarity index 100% rename from src/demosrc/night.stalker.a rename to src/demo/night.stalker.a diff --git a/src/demosrc/sneakers.a b/src/demo/sneakers.a similarity index 100% rename from src/demosrc/sneakers.a rename to src/demo/sneakers.a diff --git a/src/demosrc/space.quarks.a b/src/demo/space.quarks.a similarity index 100% rename from src/demosrc/space.quarks.a rename to src/demo/space.quarks.a diff --git a/src/demosrc/tubeway.a b/src/demo/tubeway.a similarity index 100% rename from src/demosrc/tubeway.a rename to src/demo/tubeway.a diff --git a/src/demosrc/wavy.navy.a b/src/demo/wavy.navy.a similarity index 100% rename from src/demosrc/wavy.navy.a rename to src/demo/wavy.navy.a diff --git a/src/glue.launch.a b/src/glue.launch.a index 825a40b49..0c2bc0c8a 100644 --- a/src/glue.launch.a +++ b/src/glue.launch.a @@ -30,8 +30,7 @@ gGameToLaunch ;------------------------------------------------------------------------------ AnyGameSelected +LD16 gGameToLaunch - +CMP16 $FFFF - bne ForceGoodResult + +CMP16_NE $FFFF, ForceGoodResult rts ; CMP sets carry when equal ;------------------------------------------------------------------------------ @@ -136,9 +135,9 @@ GetGameDisplayName +ST16 SAVE jsr okvs_get_current ; get value for this key ; (PTR) -> truncated game display name + info bitfield - ldy #0 + ; Y = 0 lda (PTR), y ; A = length of truncated game display name + info bitfield - cmp #1 ; 1 means there's no title, just info bitfield (1 byte) + lsr ;;cmp #1 ; 1 means there's no title, just info bitfield (1 byte) beq + +LD16 PTR clc diff --git a/src/glue.prorwts2.a b/src/glue.prorwts2.a index cb76476b0..c0c1ab5c5 100644 --- a/src/glue.prorwts2.a +++ b/src/glue.prorwts2.a @@ -49,15 +49,8 @@ ; gPathname clobbered ;------------------------------------------------------------------------------ LoadFile - +PARAMS_ON_STACK 6 - +LDPARAM 1 - jsr SetPath - +LDPARAM 3 - jsr AddToPath - +LDPARAMPTR 5, ldrlo ; set load address - jsr SwitchToBank2 - jsr LoadFileInternal - jmp SwitchToBank1 + ldx #7 + bne .loadcommon ;------------------------------------------------------------------------------ ; LoadAuxFile @@ -74,16 +67,8 @@ LoadFile ; gPathname clobbered ;------------------------------------------------------------------------------ LoadAuxFile - +PARAMS_ON_STACK 6 - +LDPARAM 1 - jsr SetPath - +LDPARAM 3 - jsr AddToPath - +LDPARAMPTR 5, ldrlo ; set load address - jsr SwitchToBank2 - lda #1 ; request aux memory - jsr LoadFileAuxInternal - jmp SwitchToBank1 + ldx #6 + bne .loadcommon ;------------------------------------------------------------------------------ ; LoadDHRFile @@ -102,13 +87,44 @@ LoadAuxFile ; stack set to next instruction after parameters ;------------------------------------------------------------------------------ LoadDHRFile - +PARAMS_ON_STACK 4 + ldx #$84 +.loadcommon + pla + sta PARAM + txa + pha + and #6 + clc + adc PARAM + tay + pla + tax + pla + sta PARAM+1 + adc #0 + pha + tya + pha + txa + pha +LDPARAM 1 jsr SetPath +LDPARAM 3 jsr AddToPath - jsr SwitchToBank2 - jsr LoadDHRFileInternal + plp + php + bmi + + +LDPARAMPTR 5, ldrlo ; set load address ++ jsr SwitchToBank2 + plp + bmi ++ + bcc + + jsr LoadFileInternal + jmp SwitchToBank1 ++ ldx #1 ; request aux memory + jsr LoadFileAuxInternal + jmp SwitchToBank1 +++ jsr LoadDHRFileInternal jmp SwitchToBank1 ;------------------------------------------------------------------------------ @@ -132,12 +148,8 @@ LoadDHRFile ;------------------------------------------------------------------------------ LoadIndexedFile +PARAMS_ON_STACK 6 - +LDPARAM 1 - +ST16 @filename - +LDPARAM 3 - +ST16 @address - +LDPARAM 5 - +ST16 zpword + jsr @set_nameaddr + +LDPARAMPTR 5, zpword inc $BF0E ; disable ROM mapping on return ldx #2 ldy #0 @@ -169,6 +181,19 @@ LoadIndexedFile dec $BF0E ; re-enable ROM mapping on return jmp SwitchToBank1 +@set_nameaddr + ldx #0 + ldy #1 + jsr + + iny + ldx #@address - @filename ++ lda (PARAM), y + sta @filename, x + iny + lda (PARAM), y + sta @filename + 1, x + rts + @c8_parms !byte 3 @filename diff --git a/src/glue.prorwts2.lc2.a b/src/glue.prorwts2.lc2.a index c68bfcc3b..843f1e57e 100644 --- a/src/glue.prorwts2.lc2.a +++ b/src/glue.prorwts2.lc2.a @@ -8,25 +8,26 @@ ; and parse.prefs which handle bank switching for you. LoadFileInternal - lda #0 ; 0 = read into main memory + ldx #0 ; 0 = read into main memory LoadFileAuxInternal - sta @auxreq+1 ; call with A=1 to load directly into aux memory +LDADDR gPathname !if RELBASE != $2000 { !ifdef PASS2 { } else { ;PASS2 !if * != LoadFileDirect { - !error "LoadFileDirect=",*, ", fix constants.a" + !error "LoadFileDirect=",*, ", fix constants.a, rebuild all src/demo and src/prelaunch" } } } +ST16 namlo ; set filename + txa + pha jsr traverse ; go to subdirectory, set up filename for read lda #cmdread ; read (instead of write) sta reqcmd lsr sta auxreq - lda ldrlo+1 + lda ldrhi bne + ; if caller provided a load address, use it sta sizelo ; otherwise query the load address from file metadata sta sizehi ; 0 = query load address @@ -35,16 +36,7 @@ LoadFileAuxInternal +ST16 ldrlo + lda #$FF ; read entire file (ProRWTS2 will figure out exact size) sta sizehi -!if RELBASE != $2000 { - !ifdef PASS2 { - } else { ;PASS2 - !if *+1 != iAuxReq { - !error "iAuxReq=",*+1, ", fix constants.a" - } - } -} -@auxreq - lda #0 + pla sta auxreq JumpOpen jmp hddopendir ; exit via ProRWTS2 diff --git a/src/macros.a b/src/macros.a index 79669a53b..85fe3c683 100755 --- a/src/macros.a +++ b/src/macros.a @@ -1,5 +1,5 @@ ;license:MIT -;(c) 2018-2020 by 4am +;(c) 2018-2021 by 4am & qkumba ; ; common assembler macros (6502 compatible) ; @@ -123,37 +123,51 @@ } ; compare a 16-bit value in A (low) and Y (high) to an absolute address +; branch to target if no match ; zeroes A! -!macro CMP16ADDR .addr { +!macro CMP16ADDR_NE .addr, .target { eor .addr - bne + + bne .target cpy .addr+1 -+ + bne .target } ; compare a 16-bit value in X (low) and Y (high) to an absolute address -!macro CPX16ADDR .addr { +; branch to target if no match +!macro CPX16ADDR_NE .addr, .target { cpx .addr - bne + + bne .target cpy .addr+1 + bne .target +} + +; compare a 16-bit value in A (low) and Y (high) to an immediate value +; branch to target if match +!macro CMP16_E .val, .target { + cmp #<.val + bne + + cpy #>.val + beq .target + } ; compare a 16-bit value in A (low) and Y (high) to an immediate value -!macro CMP16 .val { +; branch to target if no match +!macro CMP16_NE .val, .target { cmp #<.val - bne + + bne .target cpy #>.val -+ + bne .target } ; compare a 16-bit value in X (low) and Y (high) against zero +; branch to target if not zero ; requires LDX16 immediately prior, since Y comparison is implicit! ; destroys A! -!macro CPX16_0 { - bne + +!macro CPX16_0_NE .target { + bne .target txa -+ + bne .target } !macro LBPL .target { @@ -377,15 +391,17 @@ ; load an external file by pathname ; LC RAM 2 MUST BE BANKED IN ; LOW BYTE OF .addr MUST BE $00 +; set .addr to $0000 to load anywhere in main !macro LOAD_FILE_AT .filepath, .addr { - lda #0 - sta iAuxReq ; read to main memory + !if .addr > 0 { lda #>.addr sta ldrhi + } lda iCurBlockLo pha lda iCurBlockHi pha + ldx #0 ; read to main memory +LDADDR .filepath jsr LoadFileDirect pla diff --git a/src/okvs.a b/src/okvs.a index 191706b40..0a4df8d9c 100644 --- a/src/okvs.a +++ b/src/okvs.a @@ -319,8 +319,7 @@ okvs_next + jsr okvs_len +LD16 WINDEX - +CMP16ADDR WCOUNT - bne + + +CMP16ADDR_NE WCOUNT, + sta WINDEX sta WINDEX+1 + @@ -444,8 +443,7 @@ okvs_iter_values lda (PTR),y beq @exit ; no keys, exit immediately + - +LDPARAM 3 - +ST16 @callback + +LDPARAMPTR 3, @callback jsr incptr4 ; PTR -> first record lda #0 @@ -510,6 +508,7 @@ okvs_iter_values ; internal functions okvs_get_current +; out: Y = 0 +ST16 PTR jsr stepptr bne incptr diff --git a/src/parse.common.a b/src/parse.common.a index 353bdcb50..742a8f1a6 100644 --- a/src/parse.common.a +++ b/src/parse.common.a @@ -31,7 +31,7 @@ ParseKeyValueList +PARAMS_ON_STACK 5 - +LDPARAM 1 + +LDPARAM 1 ; not LDPARAMPTR, SetKeyPtr requires A/Y! +ST16 @store2 jsr SetKeyPtr ldy #5 diff --git a/src/parse.prefs.a b/src/parse.prefs.a index 380f5ec1f..7e73ecc37 100644 --- a/src/parse.prefs.a +++ b/src/parse.prefs.a @@ -1,5 +1,5 @@ ;license:MIT -;(c) 2018-2020 by 4am +;(c) 2018-2021 by 4am & qkumba ; ; Parser for global preferences file ; @@ -113,12 +113,11 @@ PREFRTS rts ;------------------------------------------------------------------------------ pref_get +PARAMS_ON_STACK 4 - +LDPARAMPTR 1, + - +LDPARAMPTR 3, .store1 + jsr .set_store01 jsr okvs_get ; look up pref key in prefs store, sets PTR to value !word gGlobalPrefsStore -+ !word $FDFD ; SMC +.store0 !word $FDFD ; SMC bcs .useDefaultValue ; if pref key is not found, use default value ldx .store1+1 beq PREFRTS ; if no OKVS to validate against, we're done @@ -137,6 +136,24 @@ pref_get +LD16 .store1 jmp okvs_nth +.set_store01 + ldx #0 + lda #.store1 - .store0 + +.set_store23 + pha + ldy #1 + jsr + + iny + pla + tax ++ lda (PARAM), y + sta .store0, x + iny + lda (PARAM), y + sta .store0 + 1, x + rts + ;------------------------------------------------------------------------------ ; pref_set ; set pref value by pref key, serialize prefs, and write them to disk @@ -152,13 +169,14 @@ pref_get ;------------------------------------------------------------------------------ pref_set +PARAMS_ON_STACK 4 - +LDPARAMPTR 1, + - +LDPARAMPTR 3, ++ + ldx #.store2 - .store0 + lda #.store3 - .store0 + jsr .set_store23 jsr okvs_update ; save that in prefs store !word gGlobalPrefsStore -+ !word $FDFD ; SMC -++ !word $FDFD ; SMC +.store2 !word $FDFD ; SMC +.store3 !word $FDFD ; SMC +LDADDR kGlobalPrefsBuffer ; clear prefs buffer +ST16 $FE diff --git a/src/ui.attract.mode.a b/src/ui.attract.mode.a index ed1fcc354..f1c00e81c 100644 --- a/src/ui.attract.mode.a +++ b/src/ui.attract.mode.a @@ -106,7 +106,8 @@ MiniAttractMode jsr okvs_nth ; get the next module on the list +ST16 SAVE jsr okvs_get_current ; get module type - ldy #1 + ; Y = 0 + iny lda (PTR),y tax ; X = module type +LD16 SAVE ; A/Y = address of module name @@ -150,11 +151,10 @@ RunAttractModule jsr FindGame bcs ATTRTS ; if game doesn't exist, skip the demo +LD16 WINDEX - +CMP16 $FFFF - beq + + +CMP16_E $FFFF, @nogame +ST16 gGameToLaunch ; if this demo corresponds to a game, save its index ; in case user presses RETURN during the demo (we will launch the game) -+ +@nogame jsr ClearScreens ; avoid seeing code load into the HGR page ; (clobbers $106, must do now before loading prelaunch code) @@ -191,6 +191,9 @@ RunAttractModule !word $800 + !word $FDFD ; SMC pla ; restore module type + +HIDE_NEXT_2_BYTES +@dispatchSingle + adc #(@singleslo-@slideshowslo)-1 - and #$0F ; convert ASCII digit to int tax @@ -201,10 +204,6 @@ RunAttractModule +LD16 @key ; pass in module name @jmp jmp $FDFD ; SMC -@dispatchSingle - adc #(@singleslo-@slideshowslo)-1 - bne - ; always branches - @slideshowslo !byte 0 { bne @BrowseDispatch ldx #kBrowseSearch +} ; execution falls through here @BrowseDispatch @@ -67,8 +69,7 @@ OnBrowseSearch OnBrowsePrevious +LDX16 gGameToLaunch - +CPX16_0 - bne @notFirstGame + +CPX16_0_NE @notFirstGame +LDX16 GameCount @notFirstGame +DEX16 @@ -77,8 +78,7 @@ OnBrowsePrevious OnBrowseNext +LDX16 gGameToLaunch +INX16 - +CPX16ADDR GameCount - bne notLastGame + +CPX16ADDR_NE GameCount, notLastGame ldx #0 ldy #0 notLastGame diff --git a/winmake.bat b/winmake.bat index b5687daaf..d847a57d8 100644 --- a/winmake.bat +++ b/winmake.bat @@ -113,6 +113,11 @@ cscript /nologo bin\changebootloader.js "build\%DISK%" build\proboothd goto :EOF ) +if "%1" equ "demo" ( +for %%q in (src\demo\*) do %acme% %1 +goto :EOF +) + echo usage: %0 clean / asm / dsk goto :EOF