named constants

This commit is contained in:
4am
2019-06-27 10:55:07 -04:00
parent 6648010cf2
commit 531abf6076
12 changed files with 107 additions and 78 deletions

View File

@@ -7,13 +7,14 @@
; .SYSTEM file is loaded ; .SYSTEM file is loaded
; ;
sta $C00E ; 40-column +READ_ROM_NO_WRITE
sta $C00C sta PRIMARYCHARSET
sta $C004 sta CLR80VID
sta $C002 sta STOREOFF
sta $C000 sta READMAINMEM
jsr $FB2F sta WRITEMAINMEM
jsr $FC58 jsr ROM_TEXT
jsr ROM_HOME
jsr Has64K ; check for 64K (required) jsr Has64K ; check for 64K (required)
bcs @no64K bcs @no64K
jsr DisableAccelerator ; set to 1 MHz (supports IIgs and many common accelerator cards) jsr DisableAccelerator ; set to 1 MHz (supports IIgs and many common accelerator cards)
@@ -156,7 +157,7 @@ OneTimeSetup
ldx #$A4 ldx #$A4
stx $3F4 stx $3F4
bit $C010 bit CLEARKBD
jmp ($FFFC) ; continue from |Reentry| in LC RAM bank jmp ($FFFC) ; continue from |Reentry| in LC RAM bank

View File

@@ -6,8 +6,10 @@
; YE OLDE GRAND UNIFIED MEMORY MAP ; YE OLDE GRAND UNIFIED MEMORY MAP
; ;
; LC RAM BANK 1 ; LC RAM BANK 1
; D000.. - data structures (e.g. gGamesListStore) ; D000..E180 - persistent data structures (gGlobalPrefsStore, gGamesListStore)
; ..FFFB - main program code ; ...end of data and start of code are approximate, in between is unused...
; ...if they ever overlap, things will go boom...
; E900..FFFB - main program code
; FFFC..FFFF - reset and other vectors ; FFFC..FFFF - reset and other vectors
; ;
; LC RAM BANK 2 ; LC RAM BANK 2
@@ -15,20 +17,36 @@
; D400..D5FF - ProRWTS code ; D400..D5FF - ProRWTS code
; D600..D9FF - HGR font data ; D600..D9FF - HGR font data
; DA00..DEFF - unused ; DA00..DEFF - unused
; DF00..DFFF - backup of stack during self-running demos ; DF00..DFFF - backup of stack (during gameplay and self-running demos)
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; soft switches ; soft switches
STOREOFF = $C000 ; write to use following 4 flags: KBD = $C000 ; last key pressed (if any)
READMAINMEM = $C002 ; write to R main mem CLEARKBD = $C010 ; clear last key pressed
READAUXMEM = $C003 ; write to R aux mem STOREOFF = $C000 ; STA then use the following 4 flags:
WRITEMAINMEM = $C004 ; write to W main mem READMAINMEM = $C002 ; STA to read from main mem
WRITEAUXMEM = $C005 ; write to W aux mem READAUXMEM = $C003 ; STA to read from aux mem
; WRITEMAINMEM = $C004 ; STA to write to main mem
SLOT3STATUS = $C017 ; read high bit only WRITEAUXMEM = $C005 ; STA to write to aux mem
CLR80VID = $C00C ; 40 columns (also used to get out of DHGR mode)
SET80VID = $C00D ; 80 columns (also used to get into DHGR mode)
PRIMARYCHARSET= $C00E ; no mousetext for you
SLOT3STATUS = $C017 ; bit 7 only
NEWVIDEO = $C029 ; IIgs graphics modes
SPEAKER = $C030 ; chirp chirp
SHADOW = $C035 ; IIgs auxmem-to-bank-E1 shadowing
DHIRESON = $C05E ; double hi-res on switch
DHIRESOFF = $C05F ; double hi-res off switch
; ROM ; ROM routines and addresses
MACHINEID = $FBB3 ; (prefixed because so much of the program runs from LC RAM, so don't call
; these without thinking about memory banks first)
ROM_TEXT = $FB2F
ROM_MACHINEID =$FBB3
ROM_HOME = $FC58
ROM_NORMAL = $FE84 ; NORMAL text (instead of INVERSE or FLASH)
ROM_IN0 = $FE89 ; SETKBD
ROM_PR0 = $FE93 ; SETVID
; zero page ; zero page
PARAM = $00 ; used by PARAMS_ON_STACK macro, so basically everywhere PARAM = $00 ; used by PARAMS_ON_STACK macro, so basically everywhere
@@ -38,6 +56,7 @@ DEST = $06
SAVE = $08 SAVE = $08
HTAB = $24 HTAB = $24
VTAB = $25 VTAB = $25
RNDSEED = $4E ; word
Timeout = $ED ; 3 bytes (used by SearchMode) Timeout = $ED ; 3 bytes (used by SearchMode)
zpMachineStatus= $F0 ; bit 7 = 1 if machine has joystick zpMachineStatus= $F0 ; bit 7 = 1 if machine has joystick
; bit 6 = 1 if machine has 128K ; bit 6 = 1 if machine has 128K
@@ -56,5 +75,3 @@ gVal = $1F81
; actual constants ; actual constants
SUPPORTS_SHR = %00110000 ; AND mask for MachineStatus SUPPORTS_SHR = %00110000 ; AND mask for MachineStatus
kAttractMode = %10000000
kSearchMode = %00000000

View File

@@ -153,11 +153,16 @@ Launch
; manually enabling LC RAM then JMP |Reenter| ; manually enabling LC RAM then JMP |Reenter|
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
Prelaunch Prelaunch
; entry point to return to launcher (used by self-running demos) ; copied to $0100 in main memory
lda $C088 ; main entry point to return to launcher (used by self-running demos, vectors)
+READ_RAM1_NO_WRITE
jmp Reenter jmp Reenter
; entry point to launch game (must be Prelaunch+6) !if * != Prelaunch+6 {
!error "Prelaunch entry points are messed up"
}
; copied to $0106 in main memory
; main entry point to launch game
+READ_ROM_NO_WRITE +READ_ROM_NO_WRITE
lda ldrlo2 ; set up game entry point in stack page lda ldrlo2 ; set up game entry point in stack page
ldy ldrhi2 ; (last load address - 1) ldy ldrhi2 ; (last load address - 1)
@@ -173,20 +178,20 @@ Prelaunch
inx inx
bne - bne -
lda #$65 ; Initialize 'random' seed. These are lda #$65 ; Initialize 'random' seed. These are
sta $4E ; arbitrary values. Some games like Pooyan sta RNDSEED ; arbitrary values. Some games like Pooyan
lda #$02 ; require these to be non-zero. Ask me lda #$02 ; require these to be non-zero. Ask me
sta $4F ; how long that one took to debug. sta RNDSEED+1 ; how long that one took to debug.
jsr $FE89 ; Initialize machine like a cold boot. jsr ROM_IN0 ; Initialize machine like a cold boot.
jsr $FE93 ; Many games assume a 'clean slate' and jsr ROM_PR0 ; Many games assume a 'clean slate' and
jsr $FE84 ; rely on zero page values set by these jsr ROM_NORMAL ; rely on zero page values set by these
sta $C000 ; ROM routines, sta STOREOFF ; ROM routines,
sta $C002 ; e.g. Wavy Navy just prints out text via sta READMAINMEM ; e.g. Wavy Navy just prints out text via
sta $C004 ; $FDED and expects it to work. Having it sta WRITEMAINMEM ; $FDED and expects it to work. Having it
sta $C00C ; print all null characters is amusing, in sta CLR80VID ; print all null characters is amusing, in
sta $C00E ; a quiet way, but not really helpful. sta PRIMARYCHARSET ; a quiet way, but not really helpful.
jsr $FB2F jsr ROM_TEXT
jsr $FC58 jsr ROM_HOME
bit $C010 bit CLEARKBD
ldx #$FD ; Jump to game entry point via stack pop. ldx #$FD ; Jump to game entry point via stack pop.
txs txs
rts rts

View File

@@ -42,7 +42,7 @@ Has64K
Has128K Has128K
+READ_ROM_NO_WRITE +READ_ROM_NO_WRITE
sta STOREOFF sta STOREOFF
lda MACHINEID lda ROM_MACHINEID
cmp #6 cmp #6
bne @no ; earlier than //e -> no 128K bne @no ; earlier than //e -> no 128K
lda SLOT3STATUS lda SLOT3STATUS

View File

@@ -35,5 +35,4 @@ HasVidHDCard
clc ; not found clc ; not found
rts rts
@kVidHDMagicBytes @kVidHDMagicBytes
!byte $00, $00, $00 !byte $24, $EA, $4C
; !byte $24, $EA, $4C

View File

@@ -68,6 +68,10 @@
} }
; various language card configurations ; various language card configurations
!macro READ_RAM1_NO_WRITE {
bit $C088
}
!macro READ_RAM1_WRITE_RAM1 { !macro READ_RAM1_WRITE_RAM1 {
bit $C08B bit $C08B
bit $C08B bit $C08B

View File

@@ -128,7 +128,7 @@ kDFXConfFile
.DHGRTitleCallback .DHGRTitleCallback
+STAY PTR +STAY PTR
lda $C000 lda KBD
bpl + bpl +
rts rts
+ +
@@ -158,7 +158,7 @@ kDFXConfFile
.DHGRActionCallback .DHGRActionCallback
+STAY PTR +STAY PTR
lda $C000 lda KBD
bpl + bpl +
rts rts
+ +

View File

@@ -46,7 +46,7 @@ HGRSingle
.HGRTitleCallback .HGRTitleCallback
+STAY PTR +STAY PTR
lda $C000 lda KBD
bpl + bpl +
rts rts
+ +
@@ -75,7 +75,7 @@ HGRSingle
+STAY @key +STAY @key
+STAY @key2 +STAY @key2
lda $C000 lda KBD
bpl + bpl +
rts rts
+ +

View File

@@ -18,6 +18,7 @@
; out: never returns to caller (may JMP to other major modes) ; out: never returns to caller (may JMP to other major modes)
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
MegaAttractMode MegaAttractMode
+READ_RAM1_WRITE_RAM1
ldx #$FF ldx #$FF
txs txs
@@ -80,7 +81,7 @@ MegaAttractMode
tax ; X = module type tax ; X = module type
+LDAY @key ; A/Y = address of module name +LDAY @key ; A/Y = address of module name
jsr RunAttractModule jsr RunAttractModule
lda $C000 lda KBD
bpl @jmpattract bpl @jmpattract
cmp #$8D ; Enter plays the game shown on screen. cmp #$8D ; Enter plays the game shown on screen.
bne @jmpsearch ; Any other key switches to Search Mode. bne @jmpsearch ; Any other key switches to Search Mode.
@@ -94,7 +95,7 @@ MegaAttractMode
; MiniAttractMode ; MiniAttractMode
; run attract modules related to one game ; run attract modules related to one game
; ;
; in: X = index in gGamesStore of game ; in: X = index in gGamesListStore
; gGlobalPrefsStore must be initialized ; gGlobalPrefsStore must be initialized
; out: all flags and registers clobbered ; out: all flags and registers clobbered
; assume all of main memory has been clobbered ; assume all of main memory has been clobbered
@@ -146,7 +147,7 @@ MiniAttractMode
jsr RunAttractModule ; execute the module jsr RunAttractModule ; execute the module
inc @MiniAttractIndex inc @MiniAttractIndex
lda $C000 lda KBD
bpl @loop bpl @loop
@exit rts @exit rts
@MiniAttractIndex @MiniAttractIndex

View File

@@ -74,7 +74,7 @@ kSFXFizzleFile
SHRArtworkCallback SHRArtworkCallback
+STAY PTR +STAY PTR
lda $C000 lda KBD
bpl + bpl +
rts rts
+ +
@@ -96,25 +96,26 @@ SHRArtworkCallback
; .BlankSHR [private] ; .BlankSHR [private]
; clear and show SHR mode without flickering ; clear and show SHR mode without flickering
; ;
; in: machine is a IIgs or has a VidHD card that responds appropriately to ; in: Machine is a IIgs or has a VidHD card that responds appropriately to
; IIgs-specific softswitches for graphics and memory modes ; IIgs-specific softswitches for graphics and memory modes.
; NOTE: THIS ROUTINE WILL CRASH ON AN APPLE //C due to writing $C029, ; NOTE: THIS ROUTINE WILL CRASH ON AN APPLE //C due to writing to $C029,
; so it is imperative that the caller ensure the machine type ; so it is imperative that the caller ensures the machine type.
; Thanks to John Brooks for explaining all of this to me.
; out: text page clobbered (but screen holes preserved) ; out: text page clobbered (but screen holes preserved)
; $2000..$9FFF/aux cleared ; $2000..$9FFF/aux cleared
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
.BlankSHR .BlankSHR
jsr Home jsr Home
lda $C029 ; set GS NEWVIDEO mode to turn on linearize lda NEWVIDEO ; set GS NEWVIDEO mode to turn on linearize
ora #$40 ora #$40
sta $C029 sta NEWVIDEO
sta $C005 ; writes go to auxmem sta WRITEAUXMEM ; writes go to auxmem
lda $C035 ; enable auxmem-to-bank-E1 shadowing on IIgs lda SHADOW ; enable auxmem-to-bank-E1 shadowing on IIgs
and #$F7 and #$F7
sta $C035 sta SHADOW
lda #$20 ; clear $2000..$9FFF in auxmem lda #$20 ; clear $2000..$9FFF in auxmem
sta @a+2 sta @a+2
@@ -128,11 +129,11 @@ SHRArtworkCallback
dex dex
bne @a bne @a
sta $C004 ; writes go to main memory sta WRITEMAINMEM ; writes go to main memory
lda $C029 ; set GS NEWVIDEO mode to turn on SHR mode lda NEWVIDEO ; set GS NEWVIDEO mode to turn on SHR mode
ora #$81 ora #$81
sta $C029 sta NEWVIDEO
rts rts

View File

@@ -27,10 +27,10 @@ SoftBell
ldx #32 ldx #32
- lda #2 - lda #2
jsr @wait jsr @wait
bit $C030 bit SPEAKER
lda #33 lda #33
jsr @wait jsr @wait
bit $C030 bit SPEAKER
dex dex
bne - bne -
pla pla
@@ -59,12 +59,12 @@ Home
lda MachineStatus lda MachineStatus
and #SUPPORTS_SHR and #SUPPORTS_SHR
beq @noSHR beq @noSHR
lda $C035 lda SHADOW
ora #$08 ora #$08
sta $C035 ; turn off auxmem-to-bank-E1 shadowing sta SHADOW ; turn off auxmem-to-bank-E1 shadowing
lda $C029 lda NEWVIDEO
and #$7F and #$7F
sta $C029 ; get out of SHR mode sta NEWVIDEO ; get out of SHR mode
@noSHR @noSHR
ldx #(@end-@start-1) ldx #(@end-@start-1)
- lda @start,x - lda @start,x
@@ -75,10 +75,10 @@ Home
@start @start
; this will be run from main memory ; this will be run from main memory
+READ_ROM_NO_WRITE +READ_ROM_NO_WRITE
sta $C00C ; get out of DHGR mode sta CLR80VID ; get out of DHGR mode
sta $C05F ; get out of DHGR mode sta DHIRESOFF ; get out of DHGR mode
jsr $FB2F ; TEXT jsr ROM_TEXT ; TEXT
jsr $FC58 ; HOME jsr ROM_HOME ; HOME
+READ_RAM1_WRITE_RAM1 +READ_RAM1_WRITE_RAM1
rts rts
@end @end
@@ -111,15 +111,15 @@ BlankHGR
BlankDHGR BlankDHGR
jsr Home jsr Home
jsr .ClearHGR1 ; clear hi-res screen 1 jsr .ClearHGR1 ; clear hi-res screen 1
sta $C005 sta WRITEAUXMEM
jsr .ClearHGR1 ; clear hi-res screen 1 in auxmem jsr .ClearHGR1 ; clear hi-res screen 1 in auxmem
sta $C004 sta WRITEMAINMEM
sta $c00d sta SET80VID
sta $c057 sta $c057
sta $c054 sta $c054
sta $c052 sta $c052
sta $c050 sta $c050
sta $c05e sta DHIRESON
rts rts
ExecuteTransitionAndWait ExecuteTransitionAndWait

View File

@@ -16,6 +16,7 @@
; out: never returns to caller (may JMP to other major modes) ; out: never returns to caller (may JMP to other major modes)
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
SearchMode SearchMode
+READ_RAM1_WRITE_RAM1
ldx #$FF ldx #$FF
txs txs
stx SelectedIndex ; no game selected stx SelectedIndex ; no game selected
@@ -26,11 +27,11 @@ SearchMode
bit $C052 bit $C052
bit $C057 bit $C057
bit $C050 ; show HGR page 1 bit $C050 ; show HGR page 1
bit $C010 bit CLEARKBD
jsr _ResetInputTimeout jsr _ResetInputTimeout
_SearchModeInputLoop _SearchModeInputLoop
lda $C000 lda KBD
bmi @gotKey bmi @gotKey
inc $4F ; these are only ever incremented, never inc $4F ; these are only ever incremented, never
@@ -47,7 +48,7 @@ _SearchModeInputLoop
jmp MegaAttractMode ; mega-attract mode jmp MegaAttractMode ; mega-attract mode
@gotKey @gotKey
bit $C010 bit CLEARKBD
jsr _ResetInputTimeout jsr _ResetInputTimeout
cmp #$9B ; Esc clears the input buffer (if any) cmp #$9B ; Esc clears the input buffer (if any)