Skip to content

Commit c0b4f49

Browse files
committed
Added close buttons to load and save dialogs, warning for unknown keys
1 parent c8384d9 commit c0b4f49

File tree

4 files changed

+51
-20
lines changed

4 files changed

+51
-20
lines changed

engine/xgf.asm

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ __xgf_dir_fn: .byte "XGFDIR.BIN"
2828
__end_xgf_dir_fn:
2929

3030
__xgf_saveas_dialog:
31-
.byte " "
31+
.byte " X"
3232
.byte " NAME: ________ "
3333
.byte " "
3434
.byte " [CLEAR] [SAVE] "
@@ -37,7 +37,7 @@ __xgf_saveas_dialog:
3737
__xgf_load_lengths: .byte 0,0,0,0,0,0,0,0
3838
__xgf_load_num: .byte 0
3939
__xgf_load_dialog:
40-
.byte " "
40+
.byte " X"
4141
.byte " Select File to Load: "
4242
.byte " -------------------- "
4343
.byte " | "
@@ -52,6 +52,8 @@ XGF_SAVEAS_X = 12
5252
XGF_SAVEAS_Y = 6
5353
XGF_SAVEAS_WIDTH = 16
5454
XGF_SAVEAS_HEIGHT = 5
55+
XGF_SAVEAS_CLOSE_X = 27
56+
XGF_SAVEAS_CLOSE_Y = 6
5557
XGF_CURSOR_X_MIN = XGF_SAVEAS_X + 7
5658
XGF_CURSOR_Y = XGF_SAVEAS_Y + 1
5759
XGF_SAVEAS_BTN_Y = XGF_SAVEAS_Y + 3
@@ -64,6 +66,8 @@ XGF_LOAD_X = 9
6466
XGF_LOAD_Y = 9
6567
XGF_LOAD_WIDTH = 22
6668
XGF_LOAD_HEIGHT = 9
69+
XGF_LOAD_CLOSE_X = 30
70+
XGF_LOAD_CLOSE_Y = 9
6771
XGF_LOAD_L_X_MIN = XGF_LOAD_X + 2
6872
XGF_LOAD_L_X_MAX = XGF_LOAD_L_X_MIN + XGF_PREFIX_MAX
6973
XGF_LOAD_R_X_MIN = XGF_LOAD_X + 13
@@ -384,6 +388,8 @@ __xgf_saveas_tick:
384388
lda mouse_left_click
385389
beq @return
386390
lda mouse_tile_y
391+
cmp #XGF_SAVEAS_CLOSE_Y
392+
beq @check_close
387393
cmp #XGF_SAVEAS_BTN_Y
388394
bne @return
389395
lda mouse_tile_x
@@ -400,6 +406,12 @@ __xgf_saveas_tick:
400406
@clear:
401407
jsr __xgf_clear_btn_click
402408
bra @return
409+
@check_close:
410+
lda mouse_tile_x
411+
cmp #XGF_SAVEAS_CLOSE_X
412+
bne @return
413+
stz saveas_visible
414+
jsr tile_restore
403415
@return:
404416
rts
405417

@@ -580,6 +592,8 @@ __xgf_load_tick:
580592
lda mouse_left_click
581593
beq @return
582594
lda mouse_tile_y
595+
cmp #XGF_LOAD_CLOSE_Y
596+
beq @check_close
583597
cmp #XGF_LOAD_Y_MIN
584598
bmi @return
585599
cmp #XGF_LOAD_Y_MAX
@@ -594,6 +608,11 @@ __xgf_load_tick:
594608
cmp #XGF_LOAD_R_X_MIN
595609
bpl @right_col
596610
bra @return
611+
@check_close:
612+
lda mouse_tile_x
613+
cmp #XGF_LOAD_CLOSE_X
614+
beq @restore
615+
jmp @return
597616
@left_col:
598617
ldx #0
599618
bra @check_num

example/APPENDIX.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,30 @@ This was done to better scale the level to the avatar sprite, which makes its fi
8585
```
8686
init
8787
if kitchen_to_foyer
88-
sprite_frames 1 0 1H 2H 3H 2H 1H 4H 5H 4H
89-
sprite 1 288 128
9088
clear_state near_door
9189
clear_state kitchen_to_foyer
90+
set_state near_kitchen
91+
end_if
92+
if near_kitchen
93+
sprite_frames 1 0 1H 2H 3H 2H 1H 4H 5H 4H
94+
sprite 1 288 128
9295
end_if
9396
if lr_to_foyer
94-
sprite_frames 1 0 1 2 3 2 1 4 5 4
95-
sprite 1 18 128
9697
clear_state lr_to_foyer
9798
set_state near_door
9899
end_if
99100
if front_to_foyer
100-
sprite_frames 1 0 1 2 3 2 1 4 5 4
101-
sprite 1 18 128
102101
clear_state front_to_foyer
103102
set_state near_door
104103
end_if
104+
if near_door
105+
sprite_frames 1 0 1 2 3 2 1 4 5 4
106+
sprite 1 18 128
107+
end_if
105108
end_anim
106109
```
107110

108-
The **init** sequence consists entirely of conditional sub-sequences, so there is no animation that is guaranteed to run during this level. Each sub-sequence is based on a state that indicates which level we came from. The first time we reach this level it is from the kitchen, so ```kitchen_to_foyer``` will be true. So, the avatar sprite (index 1) is placed by the doorway to the kitchen and facing left. Sprite frames 1-5 are the avatar facing left, so the defined sequence has all of those frames flipped horizontally. The other two sub-sequences start the avatar from the opposite end of the foyer, within reach of both doors. Here you can see that in each case the sprite is set to use the left-facing frames and the ```near_door``` state is set to true so that the player can immediately open either door, but would have to walk across the foyer to get back to the kitchen.
111+
The **init** sequence consists entirely of conditional sub-sequences, so there is no animation that is guaranteed to run during this level. Each sub-sequence is based on a state that indicates which level we came from. The first time we reach this level it is from the kitchen, so ```kitchen_to_foyer``` will be true, and then ```near_kitchen``` will be set to true. So, the avatar sprite (index 1) is placed by the doorway to the kitchen and facing left. Sprite frames 1-5 are the avatar facing left, so the defined sequence has all of those frames flipped horizontally. The other two sub-sequences start the avatar from the opposite end of the foyer, within reach of both doors. Here you can see that in each case the sprite is set to use the left-facing frames and the ```near_door``` state is set to true so that the player can immediately open either door, but would have to walk across the foyer to get back to the kitchen.
109112

110113
```
111114
first
@@ -178,7 +181,8 @@ This trigger is also for the living room door, but this time for "looking" at it
178181

179182
```
180183
tool_trigger walk 0 8 5 18
181-
if_not near_door
184+
if near_kitchen
185+
clear_state near_kitchen
182186
sprite_move 1 4 135 -2 0
183187
wait 255
184188
wait 255
@@ -188,11 +192,12 @@ end_if
188192
end_anim
189193
```
190194

191-
This trigger is for "walking" to the left end of the foyer. The trigger area included both the doors, but also has some previously unclaimed space between them, so the "walk" cursor will automatically appear when the mouse is moved there. The whole area can be used for the trigger if the "walk" tool is explicitly selected. First, it checks to make sure the avatar is not already near the door, then kicks off the animation to walk there 2 pixels at a time every 4 jiffys. This takes a while to accomplish all 135 steps, so three **wait** instructions are needed to wait a grand total of 525 jiffys, or 8.75 seconds. Then the ```near_door``` state is set to true so that the player can open one of the doors. If the avatar is already near the door when this trigger occurs, nothing happens, as the whole sequence is taken up with the ```if_not near_door``` sub-sequence.
195+
This trigger is for "walking" to the left end of the foyer. The trigger area included both the doors, but also has some previously unclaimed space between them, so the "walk" cursor will automatically appear when the mouse is moved there. The whole area can be used for the trigger if the "walk" tool is explicitly selected. First, it checks to make sure the avatar is near the kitchen, then kicks off the animation to walk there 2 pixels at a time every 4 jiffys. This takes a while to accomplish all 135 steps, so three **wait** instructions are needed to wait a grand total of 525 jiffys, or 8.75 seconds. Then the ```near_door``` state is set to true so that the player can open one of the doors. If the avatar is already near the door when this trigger occurs, nothing happens, as the whole sequence is taken up with the ```if_not near_door``` sub-sequence.
192196

193197
```
194198
tool_trigger run 0 8 5 18
195-
if_not near_door
199+
if near_kitchen
200+
clear_state near_kitchen
196201
sprite_move 1 2 135 -2 0
197202
wait 255
198203
wait 15

example/mygame_z1_level0.xci

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,26 @@ music zone0.vgm
55

66
init
77
if kitchen_to_foyer
8-
sprite_frames 1 0 1H 2H 3H 2H 1H 4H 5H 4H
9-
sprite 1 288 128
108
clear_state near_door
119
clear_state kitchen_to_foyer
10+
set_state near_kitchen
11+
end_if
12+
if near_kitchen
13+
sprite_frames 1 0 1H 2H 3H 2H 1H 4H 5H 4H
14+
sprite 1 288 128
1215
end_if
1316
if lr_to_foyer
14-
sprite_frames 1 0 1 2 3 2 1 4 5 4
15-
sprite 1 18 128
1617
clear_state lr_to_foyer
1718
set_state near_door
1819
end_if
1920
if front_to_foyer
20-
sprite_frames 1 0 1 2 3 2 1 4 5 4
21-
sprite 1 18 128
2221
clear_state front_to_foyer
2322
set_state near_door
2423
end_if
24+
if near_door
25+
sprite_frames 1 0 1 2 3 2 1 4 5 4
26+
sprite 1 18 128
27+
end_if
2528
end_anim
2629

2730
first
@@ -74,7 +77,8 @@ text 1 That's the door to the living room.
7477
end_anim
7578

7679
tool_trigger walk 0 8 5 18
77-
if_not near_door
80+
if near_kitchen
81+
clear_state near_kitchen
7882
sprite_move 1 4 135 -2 0
7983
wait 255
8084
wait 255
@@ -84,7 +88,8 @@ end_if
8488
end_anim
8589

8690
tool_trigger run 0 8 5 18
87-
if_not near_door
91+
if near_kitchen
92+
clear_state near_kitchen
8893
sprite_move 1 2 135 -2 0
8994
wait 255
9095
wait 15

sdk/config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ int parse_config (const char *cfg_fn, xci_config_t *cfg) {
3636
if (pos == 0) {
3737
key = key2idx(tok);
3838
if ((int)key < 0) {
39+
printf("WARNING: unknown key \"%s\" found in %s\n",
40+
tok, cfg_fn);
3941
break;
4042
}
4143
node = malloc(sizeof(xci_config_node_t));

0 commit comments

Comments
 (0)