2018-12-29 18:38:18 +00:00
|
|
|
;license:MIT
|
2019-06-24 02:32:18 +00:00
|
|
|
;(c) 2018-9 by 4am
|
|
|
|
;
|
|
|
|
; first-run initialization code
|
|
|
|
;
|
|
|
|
; This file is included directly and is run from $2000/main as soon as the
|
|
|
|
; .SYSTEM file is loaded
|
2018-12-29 18:38:18 +00:00
|
|
|
;
|
|
|
|
|
2019-06-27 14:55:07 +00:00
|
|
|
+READ_ROM_NO_WRITE
|
|
|
|
sta PRIMARYCHARSET
|
|
|
|
sta CLR80VID
|
|
|
|
sta STOREOFF
|
|
|
|
sta READMAINMEM
|
|
|
|
sta WRITEMAINMEM
|
|
|
|
jsr ROM_TEXT
|
|
|
|
jsr ROM_HOME
|
2018-11-07 23:56:39 +00:00
|
|
|
jsr Has64K ; check for 64K (required)
|
|
|
|
bcs @no64K
|
2019-01-13 23:55:40 +00:00
|
|
|
jsr DisableAccelerator ; set to 1 MHz (supports IIgs and many common accelerator cards)
|
|
|
|
jsr IsGS ; check for IIgs (allows super hi-res artwork)
|
2019-06-27 13:51:17 +00:00
|
|
|
ror zpMachineStatus
|
2019-01-13 23:55:40 +00:00
|
|
|
jsr HasVidHDCard ; check for VidHD card (allows super hi-res artwork even on non-IIgs machines)
|
2019-06-27 13:51:17 +00:00
|
|
|
ror zpMachineStatus
|
2019-01-13 23:55:40 +00:00
|
|
|
jsr Has128K ; check for 128K (allows DHGR slideshows and 128K games)
|
2019-06-27 13:51:17 +00:00
|
|
|
ror zpMachineStatus
|
2019-01-13 23:55:40 +00:00
|
|
|
jsr HasJoystick ; check for joystick (absence is OK but we filter out some games that require a joystick)
|
2019-06-27 13:51:17 +00:00
|
|
|
ror zpMachineStatus ; now bit 4 = 1 if IIgs
|
2019-01-13 23:55:40 +00:00
|
|
|
; bit 5 = 1 if VidHD
|
|
|
|
; bit 6 = 1 if 128K
|
2018-11-07 23:56:39 +00:00
|
|
|
; bit 7 = 1 if joystick
|
|
|
|
|
2019-06-20 01:36:49 +00:00
|
|
|
+READ_ROM_WRITE_RAM2
|
2019-06-20 01:50:48 +00:00
|
|
|
jsr init ; initialize and relocate ProRWTS2 to $D400 in RAM bank 2
|
2019-06-21 16:43:43 +00:00
|
|
|
; ProRWTS2 disk-data live at $D000-D3FF
|
2019-06-20 01:50:48 +00:00
|
|
|
ldx #$00 ; relocate program code to top of language card
|
2019-06-21 16:43:43 +00:00
|
|
|
; since we end at $0000 now, adjust low offset to avoid destroying zpage
|
|
|
|
@FM lda FirstMover - (RELBASE & $FF),x
|
|
|
|
sta RELBASE & $FF00,x
|
2018-11-07 23:56:39 +00:00
|
|
|
inx
|
|
|
|
bne @FM
|
|
|
|
inc @FM+2
|
|
|
|
inc @FM+5
|
|
|
|
bne @FM
|
2019-06-20 01:50:48 +00:00
|
|
|
|
|
|
|
+ ldy #$04
|
|
|
|
@LM lda LastMover,x ; relocate font data to $D600 in RAM bank 2
|
|
|
|
sta $D600,x
|
|
|
|
inx
|
|
|
|
bne @LM
|
|
|
|
inc @LM+2
|
|
|
|
inc @LM+5
|
|
|
|
dey
|
|
|
|
bne @LM
|
|
|
|
|
2018-11-07 23:56:39 +00:00
|
|
|
jmp OneTimeSetup
|
|
|
|
|
|
|
|
@no64K
|
|
|
|
ldy #@no64Klen
|
|
|
|
- lda @s_no64K,y
|
|
|
|
sta $6B6,y
|
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
@hang bmi @hang
|
|
|
|
@s_no64K !raw "REQUIRES 64K"
|
|
|
|
@no64Klen=*-@s_no64K
|
|
|
|
|
|
|
|
; ProRWTS2 has its own function to relocate itself
|
|
|
|
!source "src/prorwts2.a"
|
|
|
|
ProRWTSBuffer
|
2018-11-10 13:36:36 +00:00
|
|
|
; these routines will only be called once, from main memory, before relocating to language card
|
2019-01-13 23:55:40 +00:00
|
|
|
!source "src/hw.iigs.a"
|
|
|
|
!source "src/hw.vidhd.a"
|
2018-11-07 23:56:39 +00:00
|
|
|
!source "src/hw.memcheck.a"
|
|
|
|
!source "src/hw.joystick.a"
|
|
|
|
!source "src/hw.normfast.a"
|
|
|
|
*=ProRWTSBuffer+512 ; ProRWTS needs a 512-byte buffer for its init function
|
|
|
|
; so we reuse as much of the 1-time code as possible
|
|
|
|
; and fill the rest with zeros
|
2019-06-24 02:32:18 +00:00
|
|
|
|
|
|
|
!source "src/parse.games.a" ; this needs to be outside the buffer because it's not used
|
|
|
|
; until after ProRWTS initialization
|
|
|
|
|
2018-11-07 23:56:39 +00:00
|
|
|
OneTimeSetup
|
2019-06-27 13:51:17 +00:00
|
|
|
lda zpMachineStatus
|
|
|
|
sta MachineStatus ; save machine status
|
2019-06-23 18:24:09 +00:00
|
|
|
jsr SaveOrRestoreScreenHoles ; save initial copy of screen hole content
|
2018-11-26 19:43:39 +00:00
|
|
|
lda #$91
|
|
|
|
sta holepatch ; enable restoring of copy from now on
|
2018-11-07 23:56:39 +00:00
|
|
|
lda hddopendir+1 ; save current directory as 'root'
|
|
|
|
ldy hddopendir+3
|
2019-06-20 01:10:56 +00:00
|
|
|
+READ_RAM1_WRITE_RAM1
|
2018-11-07 23:56:39 +00:00
|
|
|
+STAY gRootDirectory
|
|
|
|
|
2019-01-10 17:42:50 +00:00
|
|
|
lda $43
|
|
|
|
sta promote + ProDOS_unit - $bf00
|
|
|
|
; save unit while overriding !pseudopc
|
|
|
|
|
2019-06-19 02:40:17 +00:00
|
|
|
+LDADDR kGlobalPrefsFilename
|
|
|
|
jsr SetPath
|
2018-12-28 20:08:36 +00:00
|
|
|
jsr LoadFile ; load preferences file into $8000
|
2018-11-10 15:08:14 +00:00
|
|
|
|
2018-12-29 18:38:18 +00:00
|
|
|
jsr ParseKeyValueList ; parse contents into OKVS data structure into LC RAM bank
|
2018-11-10 15:08:14 +00:00
|
|
|
!word gGlobalPrefsStore
|
2018-12-29 18:38:18 +00:00
|
|
|
!word ldrlo2 ; (ldrlo2) points to last load address, so $8000
|
2018-11-10 15:08:14 +00:00
|
|
|
!byte 16
|
2018-12-29 18:38:18 +00:00
|
|
|
+LDAY SRC ; (SRC) points to free space after the OKVS data structure we just created
|
2018-11-10 15:08:14 +00:00
|
|
|
+STAY gGamesListStore ; save pointer to free space for next store
|
|
|
|
|
2019-06-19 02:40:17 +00:00
|
|
|
+LDADDR kGameListConfFile
|
|
|
|
jsr SetPath
|
2018-12-29 18:38:18 +00:00
|
|
|
jsr LoadFile ; load games list file into $8000
|
2019-06-19 02:40:17 +00:00
|
|
|
|
2018-12-29 18:38:18 +00:00
|
|
|
jsr ParseGamesList ; parse games list into OKVS data structure in LC RAM bank
|
2018-11-07 23:56:39 +00:00
|
|
|
!word gGamesListStore
|
2018-12-29 18:38:18 +00:00
|
|
|
!word ldrlo2 ; (ldrlo2) points to last load address, so $8000
|
|
|
|
|
2019-06-23 18:24:09 +00:00
|
|
|
jsr okvs_len
|
|
|
|
!word gGamesListStore
|
|
|
|
sta SAVE
|
|
|
|
; calculate and update visible game count (3-digit decimal number as ASCII string)
|
|
|
|
ldy #0
|
|
|
|
@outer
|
|
|
|
lda #0
|
|
|
|
pha
|
|
|
|
@inner
|
|
|
|
lda SAVE
|
|
|
|
cmp kPowersOfTen,y
|
|
|
|
bcc @digitDone
|
|
|
|
sbc kPowersOfTen,y
|
|
|
|
sta SAVE
|
|
|
|
lda SAVE+1
|
|
|
|
sbc #0
|
|
|
|
sta SAVE+1
|
|
|
|
pla
|
|
|
|
adc #0
|
|
|
|
pha
|
|
|
|
jmp @inner
|
|
|
|
@digitDone
|
|
|
|
pla
|
|
|
|
ora #$30
|
|
|
|
sta UILine2_GameCount,y
|
|
|
|
iny
|
|
|
|
cpy #$03
|
|
|
|
bcc @outer
|
|
|
|
|
|
|
|
ldx #5
|
|
|
|
- lda Prelaunch,x ; copy reentry wrapper to bottom of stack
|
2019-06-24 02:32:18 +00:00
|
|
|
sta $100,x ; (used as reset vector because ][+ always
|
|
|
|
dex ; switches to ROM on Ctrl-Reset)
|
2019-06-23 18:24:09 +00:00
|
|
|
bpl -
|
2019-06-24 02:32:18 +00:00
|
|
|
|
2019-06-23 18:24:09 +00:00
|
|
|
inx
|
|
|
|
stx $3F2 ; page 3 reset vector to ($100)
|
|
|
|
inx
|
|
|
|
stx $3F3
|
|
|
|
ldx #$A4
|
|
|
|
stx $3F4
|
2019-06-24 02:32:18 +00:00
|
|
|
|
2019-06-27 14:55:07 +00:00
|
|
|
bit CLEARKBD
|
2019-06-24 02:32:18 +00:00
|
|
|
|
|
|
|
jmp ($FFFC) ; continue from |Reentry| in LC RAM bank
|
2018-11-17 14:43:20 +00:00
|
|
|
|
2018-11-07 23:56:39 +00:00
|
|
|
kGameListConfFile
|
2018-12-29 18:38:18 +00:00
|
|
|
!byte 10
|
2018-11-07 23:56:39 +00:00
|
|
|
!text "GAMES.CONF"
|
2019-06-23 18:24:09 +00:00
|
|
|
|
|
|
|
kPowersOfTen
|
|
|
|
!byte 100
|
|
|
|
!byte 10
|
|
|
|
!byte 1
|