4cade/src/4cade.init.a

259 lines
7.5 KiB
Plaintext
Raw Normal View History

2018-12-29 18:38:18 +00:00
;license:MIT
;(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
jsr IsLowPartition ; check if running from partition 1-4 (required)
bcc +
ldy #@noHighPartlen
- lda @s_noHighPart,y
sta $6B1,y
dey
bpl -
bmi @hang
@s_noHighPart !scrxor $80,"RUN FROM PARTITION 1-4"
@noHighPartlen=(*-@s_noHighPart)-1
+ jsr Has64K ; check for 64K (required)
bcc +
ldy #@no64Klen
- lda @s_no64K,y
sta $6B6,y
dey
bpl -
@hang bmi @hang
@s_no64K !scrxor $80,"REQUIRES 64K"
@no64Klen=(*-@s_no64K)-1
+ jsr DisableAccelerator ; set to 1 MHz (supports IIgs and many common accelerator cards)
2019-01-13 23:55:40 +00:00
jsr IsGS ; check for IIgs (allows super hi-res artwork)
php
bcc +
jsr ROM_TEXT2COPY ; set alternate display mode on IIgs (required for some games)
+ plp
ror zpMachineStatus
sta SETC3ROM
2019-01-13 23:55:40 +00:00
jsr HasVidHDCard ; check for VidHD card (allows super hi-res artwork even on non-IIgs machines)
ror zpMachineStatus
sta CLRC3ROM
2019-01-13 23:55:40 +00:00
jsr Has128K ; check for 128K (allows DHGR slideshows and 128K games)
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)
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
; bit 7 = 1 if joystick
lda ROM_MACHINEID
cmp #$06
beq +
lda #$DF
+HIDE_NEXT_2_BYTES
+ lda #$FF
sta zpCharMask
ldy #8
- lda TOTAL,y
ora #$80
sta $04B7,y
dey
bpl -
ldy #10
- lda REPLAY,y
ora #$80
sta $0536,y
dey
bpl -
ldy LoaderVersion
- lda LoaderVersion,y
ora #$80
+FORCE_UPPERCASE_IF_REQUIRED
sta $07CF,y
dey
bne -
bit zpMachineStatus
bvc ++
bpl +
+LDADDR Loader128KAndJoystick
bne @ShowLoadScreen
+
+LDADDR Loader128K
bne @ShowLoadScreen
++
bpl +
+LDADDR Loader64KAndJoystick
bne @ShowLoadScreen
+
+LDADDR Loader64K
@ShowLoadScreen
+STAY PTR
ldy #0
lda (PTR),y
tay
- lda (PTR),y
ora #$80
+FORCE_UPPERCASE_IF_REQUIRED
@load sta $07F7
dec @load+1
dey
bne -
@Relocate
2019-06-20 01:36:49 +00:00
+READ_ROM_WRITE_RAM2
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
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
inx
bne @FM
inc @FM+2
inc @FM+5
bne @FM
2019-09-06 22:12:17 +00:00
+ ldy #>(255 + EvenLasterMover - LastMover)
@LM lda LastMover,x ; relocate font data to $D600 in RAM bank 2
2019-09-06 22:12:17 +00:00
sta $D600,x ; and pseudo-ProDOS to $DA00 in RAM bank 2
inx
bne @LM
inc @LM+2
inc @LM+5
dey
bne @LM
jmp OneTimeSetup
; 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
!source "src/hw.diskcheck.a"
2019-01-13 23:55:40 +00:00
!source "src/hw.iigs.a"
!source "src/hw.vidhd.a"
!source "src/hw.memcheck.a"
!source "src/hw.joystick.a"
!source "src/hw.normfast.a"
TOTAL
!text "T O T A L"
REPLAY
!text "R E P L A Y"
LoaderVersion
2019-09-15 02:57:52 +00:00
!byte 10
!text "v3.0-alpha"
Loader64K
!byte 3
!text "64K"
Loader64KAndJoystick
!byte 14
!text "joystick + 64K"
Loader128K
!byte 4
!text "128K"
Loader128KAndJoystick
!byte 15
!text "joystick + 128K"
*=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
!source "src/parse.games.a" ; this needs to be outside the buffer because it's not used
; until after ProRWTS initialization
OneTimeSetup
lda zpMachineStatus
sta MachineStatus ; save machine status
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
2019-09-09 21:28:13 +00:00
lda $43
sta promote + ProDOS_unit - $bf00
; save unit in LC bank 2 while overriding !pseudopc
lda hddopendir+1 ; save current directory as 'root'
ldy hddopendir+3
2019-06-20 01:10:56 +00:00
+READ_RAM1_WRITE_RAM1
+STAY gRootDirectory
2019-09-10 02:58:16 +00:00
jsr LoadFile ; load preferences file into $8000
2019-09-10 02:38:17 +00:00
!word kRootDirectory
!word kGlobalPrefsFilename
2019-09-10 02:58:16 +00:00
- !word $8000
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
2019-09-10 02:58:16 +00:00
!word -
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-09-10 02:58:16 +00:00
jsr LoadFile ; load games list file into $8000
2019-09-10 02:38:17 +00:00
!word kRootDirectory
!word @kGameListConfFile
2019-09-10 02:58:16 +00:00
- !word $8000
2018-12-29 18:38:18 +00:00
jsr ParseGamesList ; parse games list into OKVS data structure in LC RAM bank
!word gGamesListStore
2019-09-10 02:58:16 +00:00
!word -
2018-12-29 18:38:18 +00:00
jsr okvs_len
!word gGamesListStore
2019-07-03 22:31:50 +00:00
sta GameCount
sta SAVE
lda #$80 ; TODO make this a pref
sta gCheatsEnabled
; calculate and update visible game count (3-digit decimal number as ASCII string)
ldy #0
@outer
lda #0
pha
@inner
lda SAVE
2019-06-30 19:10:09 +00:00
cmp @kPowersOfTen,y
bcc @digitDone
2019-06-30 19:10:09 +00:00
sbc @kPowersOfTen,y
sta SAVE
lda SAVE+1
sbc #0
sta SAVE+1
pla
adc #0
pha
jmp @inner
@digitDone
pla
ora #$30
2019-06-27 15:37:23 +00:00
sta VisibleGameCount,y
iny
cpy #$03
bcc @outer
2019-06-27 14:55:07 +00:00
bit CLEARKBD
2019-09-15 02:57:52 +00:00
jmp Reenter
2019-06-30 19:10:09 +00:00
@kGameListConfFile
2018-12-29 18:38:18 +00:00
!byte 10
!text "GAMES.CONF"
2019-06-30 19:10:09 +00:00
@kPowersOfTen
!byte 100
!byte 10
!byte 1