peasant: add confirmation dialog for load/save

This commit is contained in:
Vince Weaver 2021-09-28 21:08:46 -04:00
parent 51e28a622e
commit 36090911c7
4 changed files with 40 additions and 71 deletions

View File

@ -102,6 +102,7 @@ qload.inc: generate_common QLOAD
./generate_common -a 0xb00 -s hgr_draw_sprite_7x28 qload.lst >> qload.inc
./generate_common -a 0xb00 -s input_buffer qload.lst >> qload.inc
./generate_common -a 0xb00 -s hgr_text_box qload.lst >> qload.inc
./generate_common -a 0xb00 -s hgr_text_box_nosave qload.lst >> qload.inc
./generate_common -a 0xb00 -s hgr_partial_restore qload.lst >> qload.inc
./generate_common -a 0xb00 -s clear_bottom qload.lst >> qload.inc
./generate_common -a 0xb00 -s hgr_input qload.lst >> qload.inc

View File

@ -1,3 +1,5 @@
;===========================
; hgr text box
;===========================
@ -32,7 +34,12 @@ hgr_text_box:
lda (OUTL),Y
sta BOX_Y2
skip_box_save_smc:
lda #1
beq skip_box_save
jsr hgr_partial_save
skip_box_save:
jsr draw_box
@ -99,3 +106,14 @@ disp_put_string_done:
rts
;============================
; like above, but don't save
;============================
hgr_text_box_nosave:
lda #0
sta skip_box_save_smc+1
jsr hgr_text_box
lda #1
sta skip_box_save_smc+1
rts

View File

@ -417,16 +417,11 @@ overwrite_loop_ls:
;===================================
load_game:
; FIXME: print are you sure message
; print are you sure message
; lda #<load_message
; sta OUTL
; lda #>load_message
; sta OUTH
jsr confirm_action
; jsr confirm_slot
; bcs done_load
bcs done_load
; actually load it
lda INVENTORY_Y
@ -453,7 +448,7 @@ done_load:
rts
.if 0
;===================================
;===================================
; save the game
@ -462,12 +457,13 @@ done_load:
save_game:
.if 0
; lda #<save_message
; sta OUTL
; lda #>save_message
; sta OUTH
; jsr confirm_slot
; jsr confirm_action
; bcs done_save
@ -518,7 +514,7 @@ copy_loop:
done_save:
jsr change_location ; restore graphics
.endif
rts
@ -526,34 +522,25 @@ done_save:
;================================
; confirm and get slot number
;================================
;=======================================
; confirm action
;=======================================
; call with first message in OUTL/OUTH
; return: carry set if skipping
confirm_slot:
confirm_action:
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
jsr move_and_print
lda #<are_you_sure
sta OUTL
lda #>are_you_sure
sta OUTH
jsr move_and_print
jsr page_flip
jsr hgr_text_box_nosave
wait_confirmation:
lda KEYPRESS
@ -565,33 +552,6 @@ wait_confirmation:
cmp #'Y'
bne dont_do_it
;===============================
; 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_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
@ -600,21 +560,10 @@ dont_do_it:
rts
which_message:
.byte 9,5,"WHICH SLOT (1-5)?",0
;load_message:
;.byte 10,5,"LOAD GAME FROM DISK",0
;save_message:
;.byte 11,5,"SAVE GAME TO DISK",0
are_you_sure:
.byte 10,7,"ARE YOU SURE? (Y/N)",0
;save_filename:
;.byte "SAVE0",0
.endif
.byte 0,43,40, 0,240,90
.byte 10,61
.byte "ARE YOU SURE? (Y/N)",0
load_slot_levels:

View File

@ -1,7 +1,7 @@
load_file =$0b20
decompress_lzsa2_fast =$0de6
getsrc_smc =$0edc
hgr2 =$16d1
hgr2 =$16e3
hgr_make_tables =$15c0
hgr_put_string =$0ee9
save_bg_7x28 =$1417
@ -9,15 +9,16 @@ restore_bg_7x28 =$1438
hgr_draw_sprite_7x28 =$13bd
input_buffer =$1598
hgr_text_box =$1636
hgr_text_box_nosave =$16aa
hgr_partial_restore =$1516
clear_bottom =$16a6
clear_bottom =$16b8
hgr_input =$153e
hgr_partial_save =$14e7
draw_box =$126e
disp_put_string =$1668
disp_one_line =$167c
disp_put_string =$166c
disp_one_line =$1680
invert_smc1 =$0f64
disp_put_string_cursor =$1678
disp_put_string_cursor =$167c
hgr_put_char_cursor =$0f15
vgi_simple_rectangle =$12ef
hposn_high = $BA00