mirror of
https://github.com/a2-4am/4cade.git
synced 2024-09-27 12:57:21 +00:00
329 lines
8.4 KiB
Plaintext
329 lines
8.4 KiB
Plaintext
;license:MIT
|
|
;(c) 2018-20 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
|
|
;
|
|
|
|
+READ_ROM_NO_WRITE
|
|
sta PRIMARYCHARSET
|
|
sta CLR80VID
|
|
sta STOREOFF
|
|
sta READMAINMEM
|
|
sta WRITEMAINMEM
|
|
jsr ROM_TEXT
|
|
jsr ROM_HOME
|
|
jsr ROM_NORMAL
|
|
jsr ROM_IN0
|
|
jsr ROM_PR0
|
|
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
|
|
|
|
+
|
|
lda #0
|
|
sta zpMachineStatus
|
|
sta SETC3ROM
|
|
jsr HasVidHDCard ; check for VidHD card (allows super hi-res artwork even on non-IIgs machines)
|
|
sta CLRC3ROM
|
|
ror zpMachineStatus
|
|
lda ROM_MACHINEID
|
|
cmp #$06
|
|
bne @NotGS
|
|
sec
|
|
jsr $FE1F ; check for IIgs (allows super hi-res artwork)
|
|
bcs @NotGS
|
|
lda #$80
|
|
sta zpMachineStatus
|
|
@NotGS jsr Has128K ; check for 128K (allows DHGR slideshows and 128K games)
|
|
ror zpMachineStatus
|
|
jsr HasJoystick ; check for joystick (absence is OK but we filter out some games that require a joystick)
|
|
ror zpMachineStatus ; now bit 5 = 1 if VidHD or IIgs
|
|
; bit 6 = 1 if 128K
|
|
; bit 7 = 1 if joystick
|
|
; and all other bits are 0 (we'll set bit 4 after copying it to LC RAM)
|
|
|
|
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 -
|
|
|
|
!ifndef RELEASE {
|
|
lda #$D6
|
|
sta $28
|
|
lda #$07
|
|
sta $29
|
|
lda LoaderBuild
|
|
ldx LoaderBuild+1
|
|
ldy #0
|
|
jsr PrintAsDecimal
|
|
}
|
|
|
|
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
|
|
+READ_ROM_WRITE_RAM2
|
|
jsr init ; initialize and relocate ProRWTS2 to $D400 in RAM bank 2
|
|
; ProRWTS2 disk-data live at $D000-D3FF
|
|
ldx #$00 ; relocate program code to top of language card
|
|
; 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
|
|
|
|
ldy #4
|
|
@ELM lda FONTSRC,x
|
|
; relocate font data to RAM bank 2
|
|
sta FONTDST,x
|
|
inx
|
|
bne @ELM
|
|
inc @ELM+2
|
|
inc @ELM+5
|
|
dey
|
|
bne @ELM
|
|
|
|
ldy #>(255 + EvenLasterMover - LastMover)
|
|
@LM lda COPYSRC,x ; relocate pseudo-ProDOS to RAM bank 2
|
|
sta COPYDST,x
|
|
inx
|
|
bne @LM
|
|
inc @LM+2
|
|
inc @LM+5
|
|
dey
|
|
bne @LM
|
|
|
|
+READ_ROM_NO_WRITE
|
|
jsr BuildAcceleratorFunction
|
|
+READ_RAM2_WRITE_RAM2
|
|
+STAY @accelSrc
|
|
dex
|
|
-
|
|
@accelSrc=*+1
|
|
lda $FDFD,x ; copy (de)acceleration functions to RAM bank 2
|
|
sta DisableAccelerator,x
|
|
dex
|
|
bpl -
|
|
|
|
jmp OneTimeSetup
|
|
|
|
; ProRWTS2 has its own function to relocate itself
|
|
!source "src/prorwts2.a"
|
|
ProRWTSBuffer
|
|
; these routines will only be called once, from main memory, before relocating to language card
|
|
!source "src/hw.vidhd.a"
|
|
!source "src/hw.memcheck.a"
|
|
!source "src/hw.joystick.a"
|
|
TOTAL
|
|
!text "T O T A L"
|
|
REPLAY
|
|
!text "R E P L A Y"
|
|
!ifndef RELEASE {
|
|
LoaderVersion
|
|
!byte 5
|
|
!text "build"
|
|
LoaderBuild
|
|
!word BUILDNUMBER
|
|
} else {
|
|
LoaderVersion
|
|
!byte 4
|
|
!text "v3.0"
|
|
}
|
|
Loader64K
|
|
!byte 3
|
|
!text "64K"
|
|
Loader64KAndJoystick
|
|
!byte 14
|
|
!text "joystick + 64K"
|
|
Loader128K
|
|
!byte 4
|
|
!text "128K"
|
|
Loader128KAndJoystick
|
|
!byte 15
|
|
!text "joystick + 128K"
|
|
|
|
!ifndef RELEASE {
|
|
PrintAsDecimal
|
|
jsr $FF4A
|
|
-- lda #$00
|
|
clv
|
|
ldx #$18
|
|
- cmp #$05
|
|
bcc +
|
|
sbc #$85
|
|
sec
|
|
+ rol $45
|
|
rol $46
|
|
rol $47
|
|
rol
|
|
dex
|
|
bne -
|
|
pha
|
|
lda #$FD
|
|
pha
|
|
lda #$E1
|
|
pha
|
|
bvs --
|
|
rts
|
|
}
|
|
|
|
!source "src/hw.accel.a"
|
|
!source "src/parse.games.a"
|
|
|
|
OneTimeSetup
|
|
lda zpMachineStatus
|
|
sta MachineStatus ; save machine status in LC RAM
|
|
ldy #$0b
|
|
CopyDevs
|
|
lda $BF13,y
|
|
sta promote + $13,y
|
|
dey
|
|
bpl CopyDevs
|
|
|
|
lda $BF30
|
|
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
|
|
jsr SwitchToBank1
|
|
+STAY gRootDirectory
|
|
|
|
jsr LoadFile ; load preferences file into $8000
|
|
!word kRootDirectory
|
|
!word kGlobalPrefsFilename
|
|
- !word $8000
|
|
jsr ParseKeyValueList ; parse contents into OKVS data structure into LC RAM bank
|
|
!word gGlobalPrefsStore
|
|
!word -
|
|
!byte 16
|
|
+LDAY SRC ; (SRC) points to free space after the OKVS data structure we just created
|
|
+STAY gGamesListStore ; save pointer to free space for next store
|
|
|
|
jsr LoadFile ; load games list file into $8000
|
|
!word kRootDirectory
|
|
!word @kGameListConfFile
|
|
- !word $8000
|
|
jsr ParseGamesList ; parse games list into OKVS data structure in LC RAM bank
|
|
!word gGamesListStore
|
|
!word -
|
|
|
|
+LDADDR gGamesListStore
|
|
jsr okvs_len
|
|
sta GameCount
|
|
sta SAVE
|
|
|
|
jsr pref_get ; see if cheats are enabled by default
|
|
!word kCheat
|
|
!word 0
|
|
+STAY PTR ; (PTR) -> cheat pref value as length-prefixed string '1' or '0'
|
|
ldy #1
|
|
lda (PTR),y ; A = #$B1 or #$B0
|
|
and #1 ; A = #$01 or #$00
|
|
asl
|
|
asl
|
|
asl
|
|
asl ; A = #$10 or #$00
|
|
ora MachineStatus
|
|
sta MachineStatus ; set bit 4 of MachineStatus
|
|
|
|
; calculate and update visible game count (3-digit decimal number as ASCII string)
|
|
dey ; Y = 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 VisibleGameCount,y
|
|
iny
|
|
cpy #$03
|
|
bcc @outer
|
|
|
|
bit CLEARKBD
|
|
jmp Reenter
|
|
|
|
@kGameListConfFile
|
|
!byte 10
|
|
!text "GAMES.CONF"
|
|
|
|
@kPowersOfTen
|
|
!byte 100
|
|
!byte 10
|
|
!byte 1
|