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
|
2019-11-27 23:24:59 +00:00
|
|
|
jsr ROM_IN0
|
|
|
|
jsr ROM_PR0
|
2019-09-29 15:08:57 +00:00
|
|
|
jsr Has64K ; check for 64K (required)
|
2019-08-27 17:55:54 +00:00
|
|
|
bcc +
|
|
|
|
|
|
|
|
ldy #@no64Klen
|
|
|
|
- lda @s_no64K,y
|
|
|
|
sta $6B6,y
|
|
|
|
dey
|
|
|
|
bpl -
|
|
|
|
@hang bmi @hang
|
2019-09-06 00:15:02 +00:00
|
|
|
@s_no64K !scrxor $80,"REQUIRES 64K"
|
|
|
|
@no64Klen=(*-@s_no64K)-1
|
2019-08-27 17:55:54 +00:00
|
|
|
|
2019-10-05 01:34:49 +00:00
|
|
|
+
|
|
|
|
lda #0
|
|
|
|
sta zpMachineStatus
|
2019-11-21 04:05:35 +00:00
|
|
|
sta SETC3ROM
|
|
|
|
jsr HasVidHDCard ; check for VidHD card (allows super hi-res artwork even on non-IIgs machines)
|
|
|
|
sta CLRC3ROM
|
|
|
|
ror zpMachineStatus
|
2019-09-23 03:31:41 +00:00
|
|
|
lda ROM_MACHINEID
|
|
|
|
cmp #$06
|
2019-11-21 04:05:35 +00:00
|
|
|
bne @NotGS
|
2019-09-22 18:04:48 +00:00
|
|
|
sec
|
|
|
|
jsr $FE1F ; check for IIgs (allows super hi-res artwork)
|
2019-11-21 04:05:35 +00:00
|
|
|
bcs @NotGS
|
2019-07-29 16:00:59 +00:00
|
|
|
jsr ROM_TEXT2COPY ; set alternate display mode on IIgs (required for some games)
|
2019-11-21 04:05:35 +00:00
|
|
|
lda #$80
|
|
|
|
sta zpMachineStatus
|
|
|
|
@NotGS 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-11-21 04:05:35 +00:00
|
|
|
ror zpMachineStatus ; now bit 5 = 1 if VidHD or IIgs
|
2019-01-13 23:55:40 +00:00
|
|
|
; bit 6 = 1 if 128K
|
2018-11-07 23:56:39 +00:00
|
|
|
; bit 7 = 1 if joystick
|
2019-11-21 04:05:35 +00:00
|
|
|
; and all other bits are 0 (we'll set bit 4 after copying it to LC RAM)
|
2019-08-27 17:55:54 +00:00
|
|
|
|
|
|
|
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 -
|
|
|
|
|
2019-10-14 01:38:54 +00:00
|
|
|
!ifndef RELEASE {
|
|
|
|
lda #$D6
|
|
|
|
sta $28
|
|
|
|
lda #$07
|
|
|
|
sta $29
|
|
|
|
lda LoaderBuild
|
|
|
|
ldx LoaderBuild+1
|
|
|
|
ldy #0
|
|
|
|
jsr PrintAsDecimal
|
|
|
|
}
|
|
|
|
|
2019-08-27 17:55:54 +00:00
|
|
|
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
|
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
|
|
|
|
2019-09-30 18:18:57 +00:00
|
|
|
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
|
2019-06-20 01:50:48 +00:00
|
|
|
inx
|
|
|
|
bne @LM
|
|
|
|
inc @LM+2
|
|
|
|
inc @LM+5
|
|
|
|
dey
|
|
|
|
bne @LM
|
|
|
|
|
2019-10-08 23:54:09 +00:00
|
|
|
+READ_ROM_NO_WRITE
|
2019-10-05 01:34:49 +00:00
|
|
|
jsr BuildAcceleratorFunction
|
2019-10-08 23:54:09 +00:00
|
|
|
+READ_RAM2_WRITE_RAM2
|
2019-10-05 01:34:49 +00:00
|
|
|
+STAY @accelSrc
|
|
|
|
dex
|
|
|
|
-
|
|
|
|
@accelSrc=*+1
|
|
|
|
lda $FDFD,x ; copy (de)acceleration functions to RAM bank 2
|
|
|
|
sta DisableAccelerator,x
|
|
|
|
dex
|
|
|
|
bpl -
|
|
|
|
|
2018-11-07 23:56:39 +00:00
|
|
|
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
|
2019-01-13 23:55:40 +00:00
|
|
|
!source "src/hw.vidhd.a"
|
2018-11-07 23:56:39 +00:00
|
|
|
!source "src/hw.memcheck.a"
|
|
|
|
!source "src/hw.joystick.a"
|
2019-08-27 17:55:54 +00:00
|
|
|
TOTAL
|
|
|
|
!text "T O T A L"
|
|
|
|
REPLAY
|
|
|
|
!text "R E P L A Y"
|
2019-10-14 01:38:54 +00:00
|
|
|
!ifndef RELEASE {
|
|
|
|
LoaderVersion
|
|
|
|
!byte 5
|
|
|
|
!text "build"
|
|
|
|
LoaderBuild
|
|
|
|
!word BUILDNUMBER
|
|
|
|
} else {
|
2019-08-27 17:55:54 +00:00
|
|
|
LoaderVersion
|
2019-10-12 17:40:22 +00:00
|
|
|
!byte 12
|
2019-10-14 01:38:54 +00:00
|
|
|
!text "v3.0-alpha.2"
|
|
|
|
}
|
2019-08-27 17:55:54 +00:00
|
|
|
Loader64K
|
|
|
|
!byte 3
|
|
|
|
!text "64K"
|
|
|
|
Loader64KAndJoystick
|
|
|
|
!byte 14
|
|
|
|
!text "joystick + 64K"
|
|
|
|
Loader128K
|
|
|
|
!byte 4
|
|
|
|
!text "128K"
|
|
|
|
Loader128KAndJoystick
|
|
|
|
!byte 15
|
|
|
|
!text "joystick + 128K"
|
|
|
|
|
2019-10-14 02:29:25 +00:00
|
|
|
!ifndef RELEASE {
|
2019-10-14 01:38:54 +00:00
|
|
|
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
|
2019-10-14 02:29:25 +00:00
|
|
|
}
|
2019-10-14 01:38:54 +00:00
|
|
|
|
2019-10-09 17:15:33 +00:00
|
|
|
!source "src/hw.accel.a"
|
2019-09-19 03:49:24 +00:00
|
|
|
!source "src/parse.games.a"
|
2019-06-24 02:32:18 +00:00
|
|
|
|
2018-11-07 23:56:39 +00:00
|
|
|
OneTimeSetup
|
2019-06-27 13:51:17 +00:00
|
|
|
lda zpMachineStatus
|
2019-10-05 01:34:49 +00:00
|
|
|
sta MachineStatus ; save machine status in LC RAM
|
2019-10-01 20:08:50 +00:00
|
|
|
ldy #$0b
|
|
|
|
CopyDevs
|
|
|
|
lda $BF13,y
|
|
|
|
sta promote + $13,y
|
|
|
|
dey
|
|
|
|
bpl CopyDevs
|
|
|
|
|
|
|
|
lda $BF30
|
2019-09-09 21:28:13 +00:00
|
|
|
sta promote + ProDOS_unit - $bf00
|
|
|
|
; save unit in LC bank 2 while overriding !pseudopc
|
|
|
|
|
2018-11-07 23:56:39 +00:00
|
|
|
lda hddopendir+1 ; save current directory as 'root'
|
|
|
|
ldy hddopendir+3
|
2019-09-20 13:33:23 +00:00
|
|
|
jsr SwitchToBank1
|
2018-11-07 23:56:39 +00:00
|
|
|
+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
|
2018-11-07 23:56:39 +00:00
|
|
|
!word gGamesListStore
|
2019-09-10 02:58:16 +00:00
|
|
|
!word -
|
2018-12-29 18:38:18 +00:00
|
|
|
|
2019-09-20 23:42:26 +00:00
|
|
|
+LDADDR gGamesListStore
|
2019-06-23 18:24:09 +00:00
|
|
|
jsr okvs_len
|
2019-07-03 22:31:50 +00:00
|
|
|
sta GameCount
|
2019-09-25 17:19:31 +00:00
|
|
|
sta SAVE
|
2019-09-15 21:55:16 +00:00
|
|
|
|
2019-09-16 17:36:48 +00:00
|
|
|
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
|
2019-10-05 01:34:49 +00:00
|
|
|
asl
|
|
|
|
asl
|
2019-12-11 23:57:22 +00:00
|
|
|
asl
|
|
|
|
asl ; A = #$10 or #$00
|
2019-10-05 01:34:49 +00:00
|
|
|
ora MachineStatus
|
2019-12-11 23:57:22 +00:00
|
|
|
sta MachineStatus ; set bit 4 of MachineStatus
|
2019-09-15 21:55:16 +00:00
|
|
|
|
2019-06-23 18:24:09 +00:00
|
|
|
; calculate and update visible game count (3-digit decimal number as ASCII string)
|
2019-09-16 17:36:48 +00:00
|
|
|
dey ; Y = 0
|
2019-06-23 18:24:09 +00:00
|
|
|
@outer
|
|
|
|
lda #0
|
|
|
|
pha
|
|
|
|
@inner
|
|
|
|
lda SAVE
|
2019-06-30 19:10:09 +00:00
|
|
|
cmp @kPowersOfTen,y
|
2019-06-23 18:24:09 +00:00
|
|
|
bcc @digitDone
|
2019-06-30 19:10:09 +00:00
|
|
|
sbc @kPowersOfTen,y
|
2019-06-23 18:24:09 +00:00
|
|
|
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
|
2019-06-23 18:24:09 +00:00
|
|
|
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
|
2018-11-17 14:43:20 +00:00
|
|
|
|
2019-06-30 19:10:09 +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
|
|
|
|
2019-06-30 19:10:09 +00:00
|
|
|
@kPowersOfTen
|
2019-06-23 18:24:09 +00:00
|
|
|
!byte 100
|
|
|
|
!byte 10
|
|
|
|
!byte 1
|