fix randomly corrupted DHGR

This commit is contained in:
Peter Ferrie 2019-11-20 20:05:35 -08:00
parent 938b69ae7a
commit ae58fdf0a4
7 changed files with 1191 additions and 755 deletions

View File

@ -45,7 +45,6 @@ Reenter
jsr DisableAccelerator ; back to 1 MHz (especially important on IIgs
; which restores default speed on Ctrl-Reset)
jsr CloseHandles ; close any open handles to restore ProRWTS
jsr SaveOrRestoreScreenHoles ; restore original screen hole contents
ldx #5
- lda ResetVector,x ; copy reentry wrapper to bottom of stack
sta $100,x ; (used as reset vector because ][+ always
@ -132,10 +131,10 @@ SwitchToBank2
; 7 6 5 4 3 2 1 0
; | | | | | | | +- bit 0 reserved
; | | | | | | +--- bit 1 reserved
; | | | | | +----- bit 2 = 1 if cheats are enabled
; | | | | +------- bit 3 = 1 if IIc
; | | | +--------- bit 4 = 1 if IIgs
; | | +----------- bit 5 = 1 if VidHD
; | | | | | +----- bit 2 reserved
; | | | | +------- bit 3 reserved
; | | | +--------- bit 4 = 1 if cheats are enabled
; | | +----------- bit 5 = 1 if VidHD or IIgs
; | +------------- bit 6 = 1 if 128K
; +--------------- bit 7 = 1 if joystick
; Use the bit masks defined in constants.a
@ -194,7 +193,7 @@ EvenLasterMover
!ifdef PASS2 {
} else { ;PASS2
!set PASS2=1
!warn "ProRWTS ends at ", hddcodeend - 1
!warn "ProRWTS ends at ", hdddataend - 1
!warn "STACK at ", STACKBASE
!warn "LCRAM2 ends at ", LCRAM2_END - 1
!warn "RELBASE = ", $10000 - (LastMover - FirstMover)

View File

@ -30,34 +30,26 @@
+
lda #0
sta zpMachineStatus
lda ROM_MACHINEID
cmp #$06
bne @NotIIc
lda $FBC0
beq @IsIIc
@NotIIc clc
@IsIIc ror zpMachineStatus
sec
jsr $FE1F ; check for IIgs (allows super hi-res artwork)
bcs NotGS
jsr ROM_TEXT2COPY ; set alternate display mode on IIgs (required for some games)
+ sec
+HIDE_NEXT_BYTE
NotGS clc
ror zpMachineStatus
sta SETC3ROM
jsr HasVidHDCard ; check for VidHD card (allows super hi-res artwork even on non-IIgs machines)
ror zpMachineStatus
sta CLRC3ROM
jsr Has128K ; check for 128K (allows DHGR slideshows and 128K games)
ror zpMachineStatus
lda ROM_MACHINEID
cmp #$06
bne @NotGS
sec
jsr $FE1F ; check for IIgs (allows super hi-res artwork)
bcs @NotGS
jsr ROM_TEXT2COPY ; set alternate display mode on IIgs (required for some games)
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 3 = 1 if IIc
; bit 4 = 1 if IIgs
; bit 5 = 1 if VidHD
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 2 after copying it to LC RAM)
; and all other bits are 0 (we'll set bit 4 after copying it to LC RAM)
lda ROM_MACHINEID
cmp #$06
@ -241,9 +233,6 @@ PrintAsDecimal
OneTimeSetup
lda zpMachineStatus
sta MachineStatus ; save machine status in LC RAM
jsr SaveOrRestoreScreenHoles ; save initial copy of screen hole content
lda #$91
sta holepatch ; enable restoring of copy from now on
ldy #$0b
CopyDevs
lda $BF13,y

View File

@ -9,14 +9,14 @@
; D000..E611 - persistent data structures (per-game cheat categories,
; gGlobalPrefsStore, gGamesListStore)
; ...unused...
; ECC8..FFF9 - main program code
; ECC6..FFF9 - main program code
; FFFA..FFFF - NMI, reset, IRQ vectors
;
; LC RAM BANK 2
; D000..D3FF - ProRWTS data
; D400..D5F7 - ProRWTS code
; D5F8..DB52 - HGR font code & ProRWTS glue code
; DB53..DB6E - backup of stack (during gameplay and self-running demos)
; D400..D671 - ProRWTS code
; D672..DB6D - HGR font code & ProRWTS glue code
; DB6E..DB7D - backup of stack (during gameplay and self-running demos)
; ...unused...
; DBB6..DBFF - (de)acceleration function
; DC00..DFFF - HGR font data
@ -116,6 +116,5 @@ DisableAccelerator = $DBB6
EnableAccelerator = DisableAccelerator+3
; AND masks for MachineStatus
SUPPORTS_SHR = %00110000
IS_IIC = %00001000
CHEATS_ENABLED = %00000100
SUPPORTS_SHR = %00100000
CHEATS_ENABLED = %00010000

View File

@ -16,12 +16,10 @@ WaitForVBL
pha
+READ_ROM_NO_WRITE
lda $FBB3
+READ_RAM1_WRITE_RAM1
cmp #$06
bne @nop
lda MachineStatus
and #IS_IIC
bne @iic
lda $FBC0
beq @iic
+LDADDR WaitForVBL_iie
bne +
@iic
@ -38,6 +36,7 @@ WaitForVBL
lda #$4C ; JMP opcode
sta WaitForVBL
+READ_RAM1_WRITE_RAM1
pla
tay
pla
@ -71,5 +70,4 @@ UnwaitForVBL
sta $C07F ; enable access to VBL register
sta $C05A ; enable VBL polling
sta $C07E ; disable access to VBL register
cli
rts

View File

@ -8,7 +8,6 @@
; which handle bank switching for you.
LaunchInternal
jsr SaveOrRestoreScreenHoles ; save screen hole contents
ldy #$F1
- lda $100,y
sta STACKBASE - $F0,y ; back up stack

View File

@ -528,42 +528,3 @@ ProDOS_prefix=gPathname
; !fill $2e
}
end_promote
;------------------------------------------------------------------------------
; SaveOrRestoreScreenHoles
; preserve screen hole contents across demo execution
; to avoid crashing later on disk access
;
; in: nothing
; out: all flags clobbered
; all registers clobbered
;------------------------------------------------------------------------------
SaveOrRestoreScreenHoles
lda #4
sta namhi
ldx #0
stx namlo
sta bloklo
-- ldy #$78
- lda (namlo),y
pha
lda holey_stuff,x
holepatch ;sta->lda
lda (namlo),y
pla
sta holey_stuff,x
inx
tya
eor #$80
tay
bmi -
iny
bpl -
inc namhi
dec bloklo
bne --
rts
holey_stuff
!fill 64

File diff suppressed because it is too large Load Diff