mist: fix bugs with save games on real hardware

didn't trigger on cffa3k or emulator

first was I was accidentally forcing slot 6

the other was the timing-sensitive write routine was straddling
a page boundary, leading to the cycle-counted write code taking
the wrong number of cycles
This commit is contained in:
Vince Weaver 2020-09-06 17:17:12 -04:00
parent 526985249d
commit b1baf474aa
6 changed files with 38 additions and 34 deletions

View File

@ -10,7 +10,8 @@ For release 1.0
-- MIST_ROCKET_PATH_PAD probably missing ship-raised background -- MIST_ROCKET_PATH_PAD probably missing ship-raised background
+ OCTAGON + OCTAGON
-- load "red page" sound into LC and play it? -- animation on the fireplace opening/closing
-- load "red page" sound clip into LC and play it?
-- show "burnt" books if click on non-avail book -- show "burnt" books if click on non-avail book
-- adjust grabbing of actual books -- adjust grabbing of actual books
-- longer speeches from brothers, most notably the -- longer speeches from brothers, most notably the

View File

@ -2,50 +2,50 @@
; external routines ; external routines
; linking_noise.s ; linking_noise.s
play_link_noise =$158b play_link_noise =$1463
; decompress_fast_v2.s ; decompress_fast_v2.s
decompress_lzsa2_fast =$15a7 decompress_lzsa2_fast =$147f
getsrc_smc =$169d getsrc_smc =$1575
; draw_pointer.s ; draw_pointer.s
draw_pointer =$16aa draw_pointer =$1582
; end_level.s ; end_level.s
end_level =$181c end_level =$16f4
; gr_copy.s ; gr_copy.s
gr_copy_to_current =$183e gr_copy_to_current =$1716
; gr_fast_clear.s ; gr_fast_clear.s
clear_bottom =$1964 clear_bottom =$183c
clear_all =$19a2 clear_all =$187a
clear_all_color =$19c7 clear_all_color =$189f
; gr_offsets.s ; gr_offsets.s
gr_offsets =$19e5 gr_offsets =$18bd
; gr_page_flip.s ; gr_page_flip.s
page_flip =$1a15 page_flip =$18ed
; gr_putsprite_crop.s ; gr_putsprite_crop.s
put_sprite_crop =$1a2f put_sprite_crop =$1907
psc_smc1 =$1a52 psc_smc1 =$192a
psc_smc2 =$1ac4 psc_smc2 =$199c
; keyboard.s ; keyboard.s
handle_keypress =$1ac4 handle_keypress =$199c
change_direction =$1bcf change_direction =$1aa7
change_location =$1c02 change_location =$1ada
; text_print.s ; text_print.s
move_and_print =$1c9a move_and_print =$1b72
ps_smc1 =$1cc7 ps_smc1 =$1b9f
; page_sprites.inc ; page_sprites.inc
blue_page_sprite =$1e16 blue_page_sprite =$1cee
red_page_sprite =$1e2c red_page_sprite =$1d04
white_page_sprite =$1e42 white_page_sprite =$1d1a
blue_page_small_sprite =$1e58 blue_page_small_sprite =$1d30
red_page_small_sprite =$1e60 red_page_small_sprite =$1d38

View File

@ -22,6 +22,7 @@
znibble = $fe ; only during init znibble = $fe ; only during init
zmask = $ff ; only during init zmask = $ff ; only during init
WHICH_SLOT = $DA
; $26/$27 sector read location (ROM) ; $26/$27 sector read location (ROM)
; $3D sector number (ROM) ; $3D sector number (ROM)
@ -61,6 +62,7 @@ boot_entry:
; this routine reads sector in $3D on track in $41 ; this routine reads sector in $3D on track in $41
; to address in $26/$27 ; to address in $26/$27
; when it's done it jumps back to $801 ; when it's done it jumps back to $801
stx WHICH_SLOT ; save for later
txa ; x is slot# << 4 txa ; x is slot# << 4
lsr lsr

View File

@ -24,15 +24,12 @@ try_for_d5:
jsr readnib jsr readnib
rts rts
;================================ ;================================
; set up the self-modifying code ; set up the self-modifying code
; to point to the proper slot ; to point to the proper slot
;================================ ;================================
; slot number is in high nibble of A ; slot number is in high nibble of A
popwr_init: popwr_init:
lda #$60
and #$70 ; the slot number is in the top here and #$70 ; the slot number is in the top here
sta slotpatchw1+1 ; self modify the code sta slotpatchw1+1 ; self modify the code
sta slotpatchw2+1 sta slotpatchw2+1
@ -41,7 +38,6 @@ popwr_init:
rts rts
;================================ ;================================
; write a sector ; write a sector
;================================ ;================================
@ -70,6 +66,10 @@ frombuff_smc:
tya tya
bne aa bne aa
jmp cmpsecwr
.align $100
; look for the proper sector to write ; look for the proper sector to write
cmpsecwr: cmpsecwr:

View File

@ -9,7 +9,7 @@
qload_start: qload_start:
; init the write code ; init the write code
lda WHICH_SLOT
jsr popwr_init jsr popwr_init
; first time entry ; first time entry
@ -131,12 +131,12 @@ fnf_keypress:
; first sector now in $c00 ; first sector now in $c00
; offset 59 ; offset 59
; disk1 = $d0 ; disk1 = $0a
; disk2 = $32 ('2') ; disk2 = $32 ('2')
; disk3 = $33 ('3') ; disk3 = $33 ('3')
lda $c59 lda $c59
cmp #$d0 cmp #$0a
beq is_disk1 beq is_disk1
cmp #$32 cmp #$32
beq is_disk2 beq is_disk2
@ -221,8 +221,6 @@ length_array:
.byte 1,1,1,1,1 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5 .byte 1,1,1,1,1 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
.byte 1 ; FIRST_SECTOR .byte 1 ; FIRST_SECTOR
.include "qkumba_popwr.s"
.include "audio.s" .include "audio.s"
.include "linking_noise.s" .include "linking_noise.s"
.include "decompress_fast_v2.s" .include "decompress_fast_v2.s"
@ -241,6 +239,8 @@ length_array:
.include "page_sprites.inc" .include "page_sprites.inc"
.include "common_sprites.inc" .include "common_sprites.inc"
.include "qkumba_popwr.s"
qload_end: qload_end:
.assert (>qload_end - >qload_start) < $e , error, "loader too big" .assert (>qload_end - >qload_start) < $e , error, "loader too big"

View File

@ -285,6 +285,7 @@ END_OF_SAVE = $D9
; done game puzzle state ; done game puzzle state
WHICH_SLOT = $DA
JS_BUTTON_STATE = $DB JS_BUTTON_STATE = $DB
CURRENT_DISK = $DC CURRENT_DISK = $DC
JOYSTICK_ENABLED= $DD JOYSTICK_ENABLED= $DD