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

View File

@ -6,8 +6,10 @@
; YE OLDE GRAND UNIFIED MEMORY MAP
;
; LC RAM BANK 1
; D000.. - data structures (e.g. gGamesListStore)
; ..FFFB - main program code
; D000..E180 - persistent data structures (gGlobalPrefsStore, gGamesListStore)
; ...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
;
; LC RAM BANK 2
@ -15,20 +17,36 @@
; D400..D5FF - ProRWTS code
; D600..D9FF - HGR font data
; 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
STOREOFF = $C000 ; write to use following 4 flags:
READMAINMEM = $C002 ; write to R main mem
READAUXMEM = $C003 ; write to R aux mem
WRITEMAINMEM = $C004 ; write to W main mem
WRITEAUXMEM = $C005 ; write to W aux mem
;
SLOT3STATUS = $C017 ; read high bit only
KBD = $C000 ; last key pressed (if any)
CLEARKBD = $C010 ; clear last key pressed
STOREOFF = $C000 ; STA then use the following 4 flags:
READMAINMEM = $C002 ; STA to read from main mem
READAUXMEM = $C003 ; STA to read from aux mem
WRITEMAINMEM = $C004 ; STA to write to main mem
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
MACHINEID = $FBB3
; ROM routines and addresses
; (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
PARAM = $00 ; used by PARAMS_ON_STACK macro, so basically everywhere
@ -38,6 +56,7 @@ DEST = $06
SAVE = $08
HTAB = $24
VTAB = $25
RNDSEED = $4E ; word
Timeout = $ED ; 3 bytes (used by SearchMode)
zpMachineStatus= $F0 ; bit 7 = 1 if machine has joystick
; bit 6 = 1 if machine has 128K
@ -56,5 +75,3 @@ gVal = $1F81
; actual constants
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|
;------------------------------------------------------------------------------
Prelaunch
; entry point to return to launcher (used by self-running demos)
lda $C088
; copied to $0100 in main memory
; main entry point to return to launcher (used by self-running demos, vectors)
+READ_RAM1_NO_WRITE
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
lda ldrlo2 ; set up game entry point in stack page
ldy ldrhi2 ; (last load address - 1)
@ -173,20 +178,20 @@ Prelaunch
inx
bne -
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
sta $4F ; how long that one took to debug.
jsr $FE89 ; Initialize machine like a cold boot.
jsr $FE93 ; Many games assume a 'clean slate' and
jsr $FE84 ; rely on zero page values set by these
sta $C000 ; ROM routines,
sta $C002 ; e.g. Wavy Navy just prints out text via
sta $C004 ; $FDED and expects it to work. Having it
sta $C00C ; print all null characters is amusing, in
sta $C00E ; a quiet way, but not really helpful.
jsr $FB2F
jsr $FC58
bit $C010
sta RNDSEED+1 ; how long that one took to debug.
jsr ROM_IN0 ; Initialize machine like a cold boot.
jsr ROM_PR0 ; Many games assume a 'clean slate' and
jsr ROM_NORMAL ; rely on zero page values set by these
sta STOREOFF ; ROM routines,
sta READMAINMEM ; e.g. Wavy Navy just prints out text via
sta WRITEMAINMEM ; $FDED and expects it to work. Having it
sta CLR80VID ; print all null characters is amusing, in
sta PRIMARYCHARSET ; a quiet way, but not really helpful.
jsr ROM_TEXT
jsr ROM_HOME
bit CLEARKBD
ldx #$FD ; Jump to game entry point via stack pop.
txs
rts

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -74,7 +74,7 @@ kSFXFizzleFile
SHRArtworkCallback
+STAY PTR
lda $C000
lda KBD
bpl +
rts
+
@ -96,25 +96,26 @@ SHRArtworkCallback
; .BlankSHR [private]
; clear and show SHR mode without flickering
;
; in: machine is a IIgs or has a VidHD card that responds appropriately to
; IIgs-specific softswitches for graphics and memory modes
; NOTE: THIS ROUTINE WILL CRASH ON AN APPLE //C due to writing $C029,
; so it is imperative that the caller ensure the machine type
; in: Machine is a IIgs or has a VidHD card that responds appropriately to
; IIgs-specific softswitches for graphics and memory modes.
; NOTE: THIS ROUTINE WILL CRASH ON AN APPLE //C due to writing to $C029,
; 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)
; $2000..$9FFF/aux cleared
;------------------------------------------------------------------------------
.BlankSHR
jsr Home
lda $C029 ; set GS NEWVIDEO mode to turn on linearize
lda NEWVIDEO ; set GS NEWVIDEO mode to turn on linearize
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
sta $C035
sta SHADOW
lda #$20 ; clear $2000..$9FFF in auxmem
sta @a+2
@ -128,11 +129,11 @@ SHRArtworkCallback
dex
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
sta $C029
sta NEWVIDEO
rts

View File

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

View File

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