mist: verify disk was switched before loading files from it

not a very robust check, mostly just a sanity check
This commit is contained in:
Vince Weaver 2020-09-03 14:27:03 -04:00
parent 5acc2ed492
commit 173ca45680
3 changed files with 81 additions and 25 deletions

View File

@ -58,6 +58,7 @@ LOAD_SAVE2 = 18
LOAD_SAVE3 = 19
LOAD_SAVE4 = 20
LOAD_SAVE5 = 21
LOAD_FIRST_SECTOR= 22
;================================
; Level definitions

View File

@ -2,50 +2,50 @@
; external routines
; linking_noise.s
play_link_noise =$1428
play_link_noise =$145e
; decompress_fast_v2.s
decompress_lzsa2_fast =$1444
getsrc_smc =$153a
decompress_lzsa2_fast =$147a
getsrc_smc =$1570
; draw_pointer.s
draw_pointer =$1547
draw_pointer =$157d
; end_level.s
end_level =$16b5
end_level =$16eb
; gr_copy.s
gr_copy_to_current =$16d7
gr_copy_to_current =$170d
; gr_fast_clear.s
clear_bottom =$17fd
clear_all =$183b
clear_all_color =$1860
clear_bottom =$1833
clear_all =$1871
clear_all_color =$1896
; gr_offsets.s
gr_offsets =$187e
gr_offsets =$18b4
; gr_page_flip.s
page_flip =$18ae
page_flip =$18e4
; gr_putsprite_crop.s
put_sprite_crop =$18c8
psc_smc1 =$18eb
psc_smc2 =$1983
put_sprite_crop =$18fe
psc_smc1 =$1921
psc_smc2 =$19b9
; keyboard.s
handle_keypress =$1a04
change_direction =$1ac8
change_location =$1b01
handle_keypress =$1a3a
change_direction =$1afe
change_location =$1b37
; text_print.s
move_and_print =$1b99
ps_smc1 =$1bc6
move_and_print =$1bcf
ps_smc1 =$1bfc
; page_sprites.inc
blue_page_sprite =$1ce2
red_page_sprite =$1cf8
white_page_sprite =$1d0e
blue_page_small_sprite =$1d24
red_page_small_sprite =$1d2c
blue_page_sprite =$1d18
red_page_sprite =$1d2e
white_page_sprite =$1d44
blue_page_small_sprite =$1d5a
red_page_small_sprite =$1d62

View File

@ -59,6 +59,7 @@ load_file:
cmp CURRENT_DISK
bne change_disk
load_file_no_diskcheck:
lda load_address_array,X
sta load_address
@ -119,7 +120,56 @@ fnf_keypress:
bpl fnf_keypress
bit KEYRESET
; FIXME: actually verify proper disk is there
;==============================================
; actually verify proper disk is there
; read T0:S0 and verify proper disk
lda WHICH_LOAD
pha
ldx #LOAD_FIRST_SECTOR ; load track 0 sector 0
stx WHICH_LOAD
jsr load_file_no_diskcheck
pla
sta WHICH_LOAD
tax
; first sector now in $c00
; offset 59
; disk1 = $d0
; disk2 = $32 ('2')
; disk3 = $33 ('3')
lda $c59
cmp #$d0
beq is_disk1
cmp #$32
beq is_disk2
cmp #$33
beq is_disk3
bne change_disk ; unknown disk
is_disk1:
lda #1
bne disk_compare
is_disk2:
lda #2
bne disk_compare
is_disk3:
lda #3
disk_compare:
cmp which_disk_array,X
bne change_disk ; disk mismatch
;==============================================
; all good, retry original load
jsr HOME
ldx WHICH_LOAD
lda which_disk_array,X
@ -139,6 +189,7 @@ which_disk_array:
.byte 1,1,1,3 ; SHIP,GENERATOR,D'NI,SUB
.byte 1 ; TEXT_TITLE
.byte 1,1,1,1,1 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
.byte $f ; FIRST_SECTOR
load_address_array:
.byte $40,$20,$20,$20 ; MIST_TITLE,MIST,MECHE,SELENA
@ -148,6 +199,7 @@ load_address_array:
.byte $08 ; TEXT_TITLE
.byte $0E,$0E,$0E,$0E
.byte $0E ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
.byte $0C ; FIRST_SECTOR
track_array:
.byte 2, 8, 1,11 ; MIST_TITLE,MIST,MECHE,SELENA
@ -156,6 +208,7 @@ track_array:
.byte 30,32,28,31 ; SHIP,GENERATOR,D'NI,SUB
.byte 0 ; TEXT_TITLE
.byte 0, 0, 0, 0, 0 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
.byte 0 ; FIRST_SECTOR
sector_array:
.byte 0, 0, 0, 0 ; MIST_TITLE,MIST,MECHE,SELENA
@ -164,6 +217,7 @@ sector_array:
.byte 0,12, 0, 0 ; SHIP,GENERATOR,D'NI,SUB
.byte 6 ; TEXT_TITLE
.byte 11,12,13,14,15 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
.byte 0 ; FIRST_SECTOR
length_array:
.byte 83,159,157,145 ; MIST_TITLE,MIST,MECHE,SELENA
@ -172,6 +226,7 @@ length_array:
.byte 20, 33, 27, 54 ; SHIP,GENERATOR,D'NI,SUB
.byte 3 ; TEXT_TITLE
.byte 1,1,1,1,1 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
.byte 1 ; FIRST_SECTOR
; .include "qkumba_popwr.s"