mist: add save game support
had to shar a lot of code with load support so would fit not much room left
This commit is contained in:
parent
cc617a59de
commit
5de9e222fc
|
@ -58,7 +58,7 @@ mist.dsk: QBOOT TEXT_TITLE QLOAD \
|
|||
$(DOS33_RAW) mist.dsk 0 13 SAVE3 0 1
|
||||
$(DOS33_RAW) mist.dsk 0 14 SAVE4 0 1
|
||||
$(DOS33_RAW) mist.dsk 0 15 SAVE5 0 1
|
||||
$(DOS33_RAW) mist.dsk 1 0 QLOAD 0 13
|
||||
$(DOS33_RAW) mist.dsk 1 0 QLOAD 0 14
|
||||
$(DOS33_RAW) mist.dsk 2 0 MIST_TITLE 0 83
|
||||
$(DOS33_RAW) mist.dsk 8 0 MIST 0 159
|
||||
$(DOS33_RAW) mist.dsk 18 0 OCTAGON 0 128
|
||||
|
@ -126,7 +126,7 @@ text_title.o: text_title.s text_print.s wait_a_bit.s
|
|||
QLOAD: qload.o
|
||||
ld65 -o QLOAD qload.o -C ../linker_scripts/apple2_1200.inc
|
||||
|
||||
qload.o: qload.s \
|
||||
qload.o: qload.s qboot.inc \
|
||||
gr_copy.s gr_offsets.s gr_pageflip.s gr_putsprite_crop.s \
|
||||
text_print.s gr_fast_clear.s decompress_fast_v2.s \
|
||||
keyboard.s draw_pointer.s end_level.s audio.s loadstore.s \
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
For release 1.0
|
||||
|
||||
+ QLOAD
|
||||
-- custom boot messages for disk2 and disk3
|
||||
-- code to sanity check right disk is put in?
|
||||
read t0/s0 check fingerprint?
|
||||
|
||||
+ LOADER
|
||||
-- save game
|
||||
|
|
|
@ -2,50 +2,50 @@
|
|||
; external routines
|
||||
|
||||
; linking_noise.s
|
||||
play_link_noise =$145e
|
||||
play_link_noise =$158b
|
||||
|
||||
; decompress_fast_v2.s
|
||||
decompress_lzsa2_fast =$147a
|
||||
getsrc_smc =$1570
|
||||
decompress_lzsa2_fast =$15a7
|
||||
getsrc_smc =$169d
|
||||
|
||||
; draw_pointer.s
|
||||
draw_pointer =$157d
|
||||
draw_pointer =$16aa
|
||||
|
||||
; end_level.s
|
||||
end_level =$16eb
|
||||
end_level =$1818
|
||||
|
||||
; gr_copy.s
|
||||
gr_copy_to_current =$170d
|
||||
gr_copy_to_current =$183a
|
||||
|
||||
; gr_fast_clear.s
|
||||
clear_bottom =$1833
|
||||
clear_all =$1871
|
||||
clear_all_color =$1896
|
||||
clear_bottom =$1960
|
||||
clear_all =$199e
|
||||
clear_all_color =$19c3
|
||||
|
||||
; gr_offsets.s
|
||||
gr_offsets =$18b4
|
||||
gr_offsets =$19e1
|
||||
|
||||
; gr_page_flip.s
|
||||
page_flip =$18e4
|
||||
page_flip =$1a11
|
||||
|
||||
; gr_putsprite_crop.s
|
||||
put_sprite_crop =$18fe
|
||||
psc_smc1 =$1921
|
||||
psc_smc2 =$19b9
|
||||
put_sprite_crop =$1a2b
|
||||
psc_smc1 =$1a4e
|
||||
psc_smc2 =$1ae6
|
||||
|
||||
; keyboard.s
|
||||
handle_keypress =$1a3a
|
||||
change_direction =$1afe
|
||||
change_location =$1b37
|
||||
handle_keypress =$1b67
|
||||
change_direction =$1c2f
|
||||
change_location =$1c68
|
||||
|
||||
; text_print.s
|
||||
move_and_print =$1bcf
|
||||
ps_smc1 =$1bfc
|
||||
move_and_print =$1d00
|
||||
ps_smc1 =$1d2d
|
||||
|
||||
; page_sprites.inc
|
||||
blue_page_sprite =$1d18
|
||||
red_page_sprite =$1d2e
|
||||
white_page_sprite =$1d44
|
||||
blue_page_small_sprite =$1d5a
|
||||
red_page_small_sprite =$1d62
|
||||
blue_page_sprite =$1e4f
|
||||
red_page_sprite =$1e65
|
||||
white_page_sprite =$1e7b
|
||||
blue_page_small_sprite =$1e91
|
||||
red_page_small_sprite =$1e99
|
||||
|
||||
|
|
177
mist/loadstore.s
177
mist/loadstore.s
|
@ -4,68 +4,15 @@
|
|||
; load the game
|
||||
;===================================
|
||||
;===================================
|
||||
|
||||
load_game:
|
||||
bit KEYRESET ; clear keyboard buffer
|
||||
|
||||
;===============================
|
||||
; print "are you sure" message
|
||||
|
||||
bit SET_TEXT ; set text mode
|
||||
|
||||
lda #' '|$80
|
||||
sta clear_all_color+1
|
||||
jsr clear_all ; clear screen
|
||||
|
||||
lda #<load_message
|
||||
sta OUTL
|
||||
lda #>load_message
|
||||
sta OUTH
|
||||
jsr move_and_print
|
||||
|
||||
lda #<are_you_sure
|
||||
sta OUTL
|
||||
lda #>are_you_sure
|
||||
sta OUTH
|
||||
jsr move_and_print
|
||||
jsr confirm_slot
|
||||
|
||||
jsr page_flip
|
||||
|
||||
wait_load_confirmation:
|
||||
lda KEYPRESS
|
||||
bpl wait_load_confirmation
|
||||
|
||||
bit KEYRESET ; clear keypress
|
||||
|
||||
and #$7f
|
||||
cmp #'Y'
|
||||
bne done_load
|
||||
|
||||
;===============================
|
||||
; print "Which one?"
|
||||
|
||||
jsr clear_all ; clear screen
|
||||
|
||||
lda #<which_message
|
||||
sta OUTL
|
||||
lda #>which_message
|
||||
sta OUTH
|
||||
jsr move_and_print
|
||||
|
||||
jsr page_flip
|
||||
|
||||
which_load_confirmation:
|
||||
lda KEYPRESS
|
||||
bpl which_load_confirmation
|
||||
|
||||
bit KEYRESET ; clear keypress
|
||||
|
||||
and #$7f
|
||||
sec
|
||||
sbc #'1'
|
||||
|
||||
bmi done_load
|
||||
cmp #5
|
||||
bcs done_load
|
||||
|
||||
; actually load it
|
||||
|
@ -100,21 +47,91 @@ done_load:
|
|||
;===================================
|
||||
;===================================
|
||||
|
||||
; doesn't do anything yet
|
||||
|
||||
save_game:
|
||||
|
||||
lda #<save_message
|
||||
sta OUTL
|
||||
lda #>save_message
|
||||
sta OUTH
|
||||
|
||||
jsr confirm_slot
|
||||
|
||||
bcs done_save
|
||||
|
||||
pha
|
||||
|
||||
|
||||
;========================
|
||||
; actually save
|
||||
actually_save:
|
||||
|
||||
;===============================
|
||||
; first load something from
|
||||
; disk1/track0 to seek the head there
|
||||
|
||||
lda WHICH_LOAD
|
||||
pha
|
||||
|
||||
lda #LOAD_SAVE1
|
||||
sta WHICH_LOAD
|
||||
jsr load_file
|
||||
|
||||
pla
|
||||
sta WHICH_LOAD
|
||||
|
||||
; copy save data to $d00
|
||||
|
||||
ldx #0
|
||||
copy_loop:
|
||||
lda WHICH_LOAD,X
|
||||
sta $d00,X
|
||||
inx
|
||||
cpx #(END_OF_SAVE-WHICH_LOAD+1)
|
||||
bne copy_loop
|
||||
|
||||
; spin up disk
|
||||
jsr driveon
|
||||
|
||||
; actually save it
|
||||
pla
|
||||
clc
|
||||
adc #11
|
||||
sta requested_sector+1
|
||||
|
||||
jsr sector_write
|
||||
|
||||
jsr driveoff
|
||||
|
||||
done_save:
|
||||
|
||||
jsr change_location ; restore graphics
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;================================
|
||||
; confirm and get slot number
|
||||
;================================
|
||||
; call with first message in OUTL/OUTH
|
||||
; return: carry set if skipping
|
||||
|
||||
confirm_slot:
|
||||
|
||||
bit KEYRESET ; clear keyboard buffer
|
||||
|
||||
;===============================
|
||||
; print "are you sure" message
|
||||
|
||||
bit SET_TEXT ; set text mode
|
||||
|
||||
lda #' '|$80
|
||||
sta clear_all_color+1
|
||||
jsr clear_all ; clear screen
|
||||
|
||||
lda #<save_message
|
||||
sta OUTL
|
||||
lda #>save_message
|
||||
sta OUTH
|
||||
jsr move_and_print
|
||||
|
||||
lda #<are_you_sure
|
||||
|
@ -125,31 +142,53 @@ save_game:
|
|||
|
||||
jsr page_flip
|
||||
|
||||
wait_save_confirmation:
|
||||
wait_confirmation:
|
||||
lda KEYPRESS
|
||||
bpl wait_save_confirmation
|
||||
bpl wait_confirmation
|
||||
|
||||
bit KEYRESET ; clear keypress
|
||||
|
||||
and #$7f
|
||||
cmp #'Y'
|
||||
bne done_load
|
||||
bne dont_do_it
|
||||
|
||||
; actually load it
|
||||
;===============================
|
||||
; print "Which one?"
|
||||
|
||||
jsr clear_all ; clear screen
|
||||
|
||||
done_store:
|
||||
lda #<which_message
|
||||
sta OUTL
|
||||
lda #>which_message
|
||||
sta OUTH
|
||||
jsr move_and_print
|
||||
|
||||
jsr page_flip
|
||||
|
||||
bit SET_GR ; turn graphics back on
|
||||
which_slot:
|
||||
lda KEYPRESS
|
||||
bpl which_slot
|
||||
|
||||
bit KEYRESET ; clear keypress
|
||||
|
||||
and #$7f
|
||||
sec
|
||||
sbc #'1'
|
||||
|
||||
bmi dont_do_it
|
||||
cmp #5
|
||||
bcs dont_do_it
|
||||
|
||||
clc
|
||||
rts
|
||||
|
||||
dont_do_it:
|
||||
sec
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
which_message:
|
||||
.byte 9,5,"LOAD WHICH GAME (1-5)?",0
|
||||
.byte 9,5,"WHICH SLOT (1-5)?",0
|
||||
|
||||
load_message:
|
||||
.byte 10,5,"LOAD GAME FROM DISK",0
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
seek = $1126
|
||||
driveon = $119D
|
||||
driveoff = $1122
|
||||
load_new = $11AB
|
||||
load_address=$11C4
|
||||
load_track=load_address+1
|
||||
load_sector=load_address+2
|
||||
load_length=load_address+3
|
|
@ -1,7 +1,9 @@
|
|||
; fast seek/multi-read
|
||||
; copyright (c) Peter Ferrie 2015-16
|
||||
|
||||
sectors = 13 ; user-defined
|
||||
; Paramaters for loading QLOAD
|
||||
|
||||
sectors = 14 ; user-defined
|
||||
firsttrk = 1 ; user-defined, first track to read
|
||||
firstsec = 0 ; user-defined, first sector to read
|
||||
address = $12 ; user-defined
|
||||
|
@ -95,7 +97,7 @@ patch_loop:
|
|||
|
||||
; patch self-modifying code for turning motor on
|
||||
clc
|
||||
adc #1 ; MOTOROFF (c088) -> c0e9
|
||||
adc #1 ; MOTORON (c089) -> c0e9
|
||||
sta slotpatch9+1
|
||||
|
||||
; patch self-modifying code for phase off
|
||||
|
|
|
@ -311,12 +311,15 @@ partial2: .byte $00
|
|||
code_end:
|
||||
|
||||
|
||||
load_new:
|
||||
|
||||
;==========================
|
||||
; enable drive motor
|
||||
;==========================
|
||||
|
||||
driveon:
|
||||
|
||||
slotpatch9:
|
||||
lda $c0e9 ; fixme, patch
|
||||
lda $c0d1
|
||||
|
||||
; wait 1s
|
||||
|
||||
|
@ -327,15 +330,11 @@ wait_1s:
|
|||
dex
|
||||
bne wait_1s
|
||||
|
||||
; setup return on stack
|
||||
; is value - 1
|
||||
rts
|
||||
|
||||
; lda load_address
|
||||
; sec
|
||||
; sbc #1
|
||||
; pha
|
||||
; lda #$ff
|
||||
; pha
|
||||
load_new:
|
||||
|
||||
jsr driveon
|
||||
|
||||
lda load_track
|
||||
asl ; track to start*2
|
||||
|
@ -362,4 +361,3 @@ load_sector:
|
|||
load_length:
|
||||
.byte $00
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,28 @@
|
|||
; popwr -- code provided by qkumba
|
||||
|
||||
; !cpu 6502
|
||||
; !to "popwr",plain
|
||||
; *=$d500
|
||||
|
||||
;bit2tbl=$dc00 ; in loader.s
|
||||
|
||||
frombuff=$d00 ; sector data to write
|
||||
|
||||
; note these must be contiguous
|
||||
encbuf=$e00 ; nibble buffer must be page alined
|
||||
bit2tbl=$f00
|
||||
|
||||
readnib = $1001
|
||||
|
||||
|
||||
readd5aa:
|
||||
|
||||
try_again:
|
||||
jsr readnib
|
||||
try_for_d5:
|
||||
cmp #$d5
|
||||
bne try_again
|
||||
jsr readnib
|
||||
cmp #$aa
|
||||
bne try_for_d5
|
||||
|
||||
jsr readnib
|
||||
rts
|
||||
|
||||
|
||||
;================================
|
||||
|
@ -76,10 +90,7 @@ b3:
|
|||
|
||||
|
||||
requested_sector:
|
||||
tay
|
||||
; at this point A has the sector number
|
||||
; this code assumes you want sector 0
|
||||
|
||||
cmp #$d1
|
||||
|
||||
bne cmpsecwr ; retry if not what we want?
|
||||
|
||||
|
|
19
mist/qload.s
19
mist/qload.s
|
@ -4,9 +4,14 @@
|
|||
.include "hardware.inc"
|
||||
|
||||
.include "common_defines.inc"
|
||||
.include "qboot.inc"
|
||||
|
||||
qload_start:
|
||||
|
||||
; init the write code
|
||||
|
||||
jsr popwr_init
|
||||
|
||||
; first time entry
|
||||
; start by loading text title
|
||||
|
||||
|
@ -37,18 +42,6 @@ not_title:
|
|||
jsr $2000
|
||||
jmp main_game_loop
|
||||
|
||||
|
||||
|
||||
; FIXME: have to keep these in sync
|
||||
|
||||
driveoff =$1122
|
||||
load_new = $119D
|
||||
load_address=$11C0
|
||||
load_track=load_address+1
|
||||
load_sector=load_address+2
|
||||
load_length=load_address+3
|
||||
|
||||
|
||||
;====================================
|
||||
; loads file specified by WHICH_LOAD
|
||||
;====================================
|
||||
|
@ -228,7 +221,7 @@ length_array:
|
|||
.byte 1,1,1,1,1 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
|
||||
.byte 1 ; FIRST_SECTOR
|
||||
|
||||
; .include "qkumba_popwr.s"
|
||||
.include "qkumba_popwr.s"
|
||||
|
||||
.include "audio.s"
|
||||
.include "linking_noise.s"
|
||||
|
|
|
@ -37,13 +37,13 @@ text_loop:
|
|||
|
||||
|
||||
boot_message:
|
||||
.byte 0,0,"LOADING MIST V0.99.5",0
|
||||
.byte 0,3,"CONTROLS:",0
|
||||
.byte 5,4,"MOVE CURSOR : ARROWS OR WASD",0
|
||||
.byte 5,5,"FORWARD/ACTION : ENTER",0
|
||||
.byte 5,7,"JOYSTICK (TODO): J",0
|
||||
.byte 5,8,"LOAD GAME : CONTROL-L",0
|
||||
.byte 5,9,"SAVE (TODO) : CONTROL-S",0
|
||||
.byte 0,0, "LOADING MIST V0.99.6",0
|
||||
.byte 0,3, "CONTROLS:",0
|
||||
.byte 5,4, "MOVE CURSOR : ARROWS OR WASD",0
|
||||
.byte 5,5, "FORWARD/ACTION : ENTER",0
|
||||
.byte 5,7, "JOYSTICK (TODO): J",0
|
||||
.byte 5,8, "LOAD GAME : CONTROL-L",0
|
||||
.byte 5,9, "SAVE : CONTROL-S",0
|
||||
.byte 5,10,"TOGGLE SOUND : CONTROL-T",0
|
||||
.byte 0,13,"BASED ON MYST BY CYAN INC",0
|
||||
.byte 0,14,"APPLE II PORT: VINCE WEAVER",0
|
||||
|
|
Loading…
Reference in New Issue