-
Notifications
You must be signed in to change notification settings - Fork 25
/
menu.asm
2131 lines (1956 loc) · 36.7 KB
/
menu.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#define ITEM_LINK 0
#define ITEM_CMD 1
#define ITEM_DIGIT 2
#define ITEM_OPTION 3
#define ITEM_KEY 4
#define ITEM_ROM 5
#define ITEM_ROMONLY $80
#define ROMS_PER_PAGE 15
#define UNMAPPED_KEY 41
ApplyConfiguration:
; Display next frame always
ld a,$4F ;LD R,A
ld (z80codebase+updateSTAT_enable_catchup_smc),a
ld (z80codebase+updateSTAT_full_enable_catchup_smc),a
ld (z80codebase+ppu_mode0_enable_catchup_smc),a
ld (z80codebase+ppu_mode2_enable_catchup_smc),a
ld (z80codebase+ppu_lyc_enable_catchup_smc),a
; Frameskip value
ld ix,FrameskipValue
call read_config_item
ld (speed_display_smc_0),a
inc a
ld (frameskip_value_smc),a
ld (skippable_frames),a
; Frameskip type
call read_config_item
ld c,a
sub 2
jr nz,_
ld (speed_display_smc_0),a
_
and $10
add a,$18
ld (frameskip_type_smc),a
ld a,c
or a
jr z,_
ld a,no_frameskip - (frameskip_type_smc+2)
_
ld (frameskip_type_smc+1),a
; Speed display
call read_config_item
ld c,a
sub 1
sbc a,a
and NoSpeedDisplay - YesSpeedDisplay
add a,YesSpeedDisplay - (speed_display_smc_1 + 1)
ld (speed_display_smc_1),a
ld a,c
sub 2
and $10
add a,$CE
ld (speed_display_smc_3),a
ld a,c
sub 3
and $10
add a,$18
ld (speed_display_smc_2),a
; Auto Save State
call read_config_item
ld (should_auto_save),a
; Palette selection
call read_config_item
ld hl,default_palette
or a
ld bc,0
jr z,_
APTR(ManualPaletteIndexTable-1)
ld c,a
add hl,bc
_
push hl
; Time zone
call read_config_item
ld c,a
; Daylight saving time
call read_config_item
APTR(TimeZoneOffsetTable)
add hl,bc
ld e,(hl)
ld d,225
mlt de
sbc hl,hl
or a
jr z,_
ld hl,60*60
_
sbc hl,de
ld a,c
cp 19
jr nc,_
add hl,de
add hl,de
_
ld (timeZoneOffset),hl
; Scaling mode
call read_config_item
ld (active_scaling_mode),a
; Skin display
inc ix
; Turbo toggle
call read_config_item
dec a
and turbo_skip_toggle - (turbo_toggle_smc+1)
ld (turbo_toggle_smc),a
ld a,(turbo_active)
add a,a
add a,a
add a,a
add a,$20
ld (turbo_keypress_smc),a
; Scaling type
call read_config_item
ld (active_scaling_type),a
; Message display
inc ix
pop hl
ld a,(regs_saved + STATE_SYSTEM_TYPE)
or a
jr nz,_
; Disable color adjustment for classic palette
ld a,(hl)
sub $1D
_
; Adjust colors
call nz,read_config_item
push af
; Load palettes and setup color adjustment tables
ld c,(hl)
ACALL(LoadPalettes)
; BC=0
pop bc
; Set gamma setting based on color adjustment
ACALL(SetupGamma)
inc bc ;BC=0
; Check for conflicting keys between configs
ld e,b
key_conflict_retry:
ld ix,KeyConfig
ld d,key_config_count
key_conflict_loop:
call read_config_item
jr nz,_
; This key is inherited from global, so make sure it has no conflict
; among game-specific keys
ld hl,GameKeyConfig
ld c,key_config_count
cpir
jr nz,_
; If a conflict was found, reset it to global and start over
dec hl
ld e,$FF
ld (hl),e
jr key_conflict_retry
_
dec d
jr nz,key_conflict_loop
push de
; Key configuration
APTR(KeySMCList)
ex de,hl
ld hl,key_smc_turbo
lea ix,ix-key_config_count
ld b,key_config_count
key_config_loop:
call read_config_item
dec a
ld c,a
cpl
and %00111000
rrca
rrca
ld (hl),a
inc hl
ld a,c
and %00000111
add a,a
add a,a
add a,a
add a,$46
ld (hl),a
ld a,(de)
inc de
add a,l
jr nc,_
ld l,$FF
inc hl
_
ld l,a
djnz key_config_loop
pop af
ret nc
ld a,ERROR_KEY_CONFLICT
AJUMP(DisplayWarning)
RefreshRomListFrame:
ld a,(romListFrameStart)
ld hl,(romTotalCount)
ld h,ROMS_PER_PAGE
or a
jr z,+++_
sub l
jr c,++_
_
sub h
jr nc,-_
_
add a,l
_
ld (romListFrameStart),a
sub l
neg
cp h
jr c,_
ld a,h
_
inc a
ld (romListFrameCount),a
ld hl,main_menu_selection + 1
cp (hl)
ret nc
ld (hl),a
ret
ClearMenuBuffer:
ld hl,menu_frame_buffer
ld (current_buffer),hl
MEMSET_FAST_TAIL(menu_frame_buffer, 320*240, BLUE)
; Input: C = palette index, A = color adjust mode
; Output: BC = 0
; Destroys: AF,DE,HL,IX
LoadPalettes:
ld d,$C9 ;RET
or a
jr z,LoadPalettesNoColorAdjust
ld d,a
ld e,40
mlt de
ld hl,GreenAdjustOffsetsGBC-40
add hl,de
ex de,hl
ld ix,(ArcBase)
add ix,de
ld de,adjust_color_lut
LoadPaletteColorAdjustRowLoop:
ld a,e
and 3
jr nz,LoadPaletteColorAdjustNextByte
ld l,(ix)
inc ix
ld h,a
add hl,hl
LoadPaletteColorAdjustNextByte:
ld b,(ix)
inc ix
LoadPaletteColorAdjustNextBit:
; Assign new value of low 3 green bits (mask $8C)
xor e
and $8C
xor e
ld e,a
; Conditionally decrement green offset
sla b
ld a,l
jr nc,_
sub $20
ld l,a
jr nc,_
dec h
_
; Write green offset to LUT
dec d ;adjust_green_lsb_lut
ld (de),a
ld a,h
inc d
inc d ;adjust_green_msb_lut
ld (de),a
; Fill low byte conversion LUT as well
ld a,e
sra a \ sra a \ sra a
and $8C
dec d ;adjust_color_lut
ld (de),a
; Increment low 3 green bits (mask $8C)
ld a,e
or d ;$73
inc a
jr nz,LoadPaletteColorAdjustNextBit
; Increment upper 2 green bits and 3 blue bits (mask $73)
; This works because the $8C bits are already set in E
inc e
jr nz,LoadPaletteColorAdjustRowLoop
ld d,$21 ;LD HL,
LoadPalettesNoColorAdjust:
ld a,d
ld (adjust_color_enable_smc),a
ld a,c
ld ix,(ArcBase)
ld bc,PaletteIndex
add ix,bc
ld e,a
and $1F
ld c,a
ld b,3
mlt bc
add ix,bc
ld a,(regs_saved + STATE_SYSTEM_TYPE)
or a
ld a,d
rla
ld a,e
ld hl,update_palettes_gbc_smc
ld de,prepare_next_frame_gbc_smc+1
jr z,LoadPalettesGB
push hl
ld a,$18 ;JR
ld (hl),a
inc hl
ld (hl),update_palettes_gbc - (update_palettes_gbc_smc+2)
ld hl,mpLcdPalette + (SCREEN_OFF_COLOR*2)
ld (hl),$FF
inc hl
ld (hl),$FF
ex de,hl
ld (hl),prepare_next_frame_gbc_no_adjust - (prepare_next_frame_gbc_smc+2)
jr c,_
ld (hl),prepare_next_frame_gbc_adjust - (prepare_next_frame_gbc_smc+2)
_
dec hl
ld (hl),a
jp (hl)
LoadPalettesGB:
ld (hl),$21 ;LD HL,
ex de,hl
ld (hl),BGP_max_value & $FF
dec hl
ld (hl),$3A ;LD A,(BGP_max_value)
; Load BGP
ld de,overlapped_bg_palette_colors
ld c,(ix+2)
ACALL(LoadSinglePalette)
ex de,hl
ld l,bg_palette_colors & $FF
ld de,mpLcdPalette + (BG_COLOR_0 * 2)
ld c,4*2
ldir
; Load OBP0
ld c,(ix)
bit 5,a
jr nz,_
ld c,(ix+2)
_
ACALL(LoadSinglePalette)
; Load OBP1
ld c,(ix+1)
rlca
jr c,_
ld c,(ix)
rlca
jr c,_
ld c,(ix+2)
_
; Input: BC = palette offset, DE = output table ptr
; Output: DE = next output table ptr, BC = 0
LoadSinglePalette:
push af
push ix
ld hl,(ArcBase)
add hl,bc
ld bc,PaletteDictionary
add hl,bc
ld ix,overlapped_palette_index_lut
load_single_palette_input_loop:
push hl
ld bc,(hl)
call adjust_color
or a
load_single_palette_output_loop:
sbc hl,hl
ld l,(ix)
add hl,hl
add hl,de
ld (hl),c
inc hl
ld (hl),b
ld a,ixl
add a,16
ld ixl,a
jr nc,load_single_palette_output_loop
pop hl
inc hl
inc hl
ld bc,4
adc a,c
ld ixl,a
and 3
jr nz,load_single_palette_input_loop
ld hl,64*2
add hl,de
ex de,hl
ldir
pop ix
pop af
ret
SetupOriginalGamma:
ld b,3
SetupGamma:
ld c,spiGammaConfigSize
mlt bc
ld hl,spiGammaUniform
add hl,bc
ex de,hl
ld b,spiGammaCmdSize
call spiFastTransferArc
ex de,hl
ld de,mpLcdPalette + (BLUE * 2)
ld c,menuPaletteSize
ldir
; Write black and white to the palette
ex de,hl
ld (hl),c
inc hl
dec bc
ld (hl),bc
inc (hl)
ret
BackupAndShowConfirmStateOperation:
ACALL(BackupMiniScreen)
ShowConfirmStateOperation:
; Just return NZ if the state does not exist
call check_valid_state
dec a
ret m
ld de,ConfirmLoadState
ld hl,(main_menu_selection)
ShowConfirmRestartOperation:
; Return NZ if confirmation is disabled for this type
ld ix,ConfirmStateOperation
call read_config_item
and l
dec a
ret m
jr z,_
ld de,ConfirmSaveState
_
push de
ACALL(SetMenuWindow)
pop de
ld hl,(current_state)
ShowConfirmationDialog:
push hl
ld hl,(ArcBase)
add hl,de
push hl
ACALL(ClearMenuBuffer)
ld a,WHITE
ld hl,1<<8|5
ACALL(PutStringFormatColorXY)
pop hl
pop hl
ld b,2
ld c,b
ConfirmationDialogDisplayLoop:
ld hl,1<<8|20
ld (cursorRowCol),hl
APTR(ConfirmText)
push bc
_
ld a,WHITE
ld e,'>'-' '
djnz _
ld a,OLIVE
ld e,b ;' '-' '
_
call SetStringColor
ld a,e
push bc
push hl
call PutCharTranslated
pop hl
ACALL(PutString)
pop bc
dec c
jr nz,--_
ConfirmationDialogKeyLoop:
ACALL(WaitForKey)
pop bc
ret z
cp 1
jr nz,_
ld b,a
jr ConfirmationDialogDisplayLoop
_
cp 4
jr nz,_
ld b,2
jr ConfirmationDialogDisplayLoop
_
cp 15
jr z,_
push bc
cp 9
jr z,++_
cp 54
jr z,++_
jr ConfirmationDialogKeyLoop
_
ld b,2
push bc
_
ACALL(GetKeyCode)
or a
jr nz,-_
pop bc
dec b
dec b
ret
ItemSelectCmd:
ld hl,CmdList
ld c,a
ld b,2
mlt bc
add hl,bc
ld bc,(ArcBase)
add hl,bc
ld hl,(hl)
dec.s hl
add hl,bc
jp (hl)
ItemSelectRom:
APTR(CmdExit)
push hl
GetSelectedROMName:
ld l,a
ld h,3
mlt hl
ld de,romListStart
add hl,de
ld hl,(hl)
ld bc,(hl)
ld de,ROMNameToLoad+1
push hl
push de
_
ld a,(hl)
ld (de),a
dec hl
inc de
djnz -_
xor a
ld (de),a
pop de
pop ix
inc a
jp GetRomDescriptionFromVAT
ItemSelectKey:
sub KeyConfig-OptionConfig
sbc hl,hl
ld l,a
ld a,(current_config)
or a
ld bc,KeyConfig
jr z,_
ld bc,GameKeyConfig
_
add hl,bc
push bc
ld c,(hl)
ld (hl),0
push bc
push hl
ACALL(draw_current_menu)
ACALL(WaitForKey)
pop de
pop bc
pop hl
jr nz,_
ld a,c
_
ld b,a
ld a,c
cp UNMAPPED_KEY
ld a,b
jr z,RemapKey
ld b,key_config_count
_
cp (hl)
jr nz,_
ld (hl),c
_
inc hl
djnz --_
_
ld (de),a
ACALL(draw_current_menu)
jr menu_loop
RemapKey:
ld bc,key_config_count
cpir
jr nz,-_
ld a,UNMAPPED_KEY
jr -_
CmdRestart:
; Use the Load State confirmation setting
ld l,1
ld de,ConfirmRestartGame
ACALL(ShowConfirmRestartOperation)
ld a,RestartExitReason
jr _
ItemSelectDigit:
cp 2
jr z,menu_loop
ACALL(ShowConfirmStateOperation)
ld a,4
_
jr nz,CmdExit
xor a
jr ItemSelectLink
emulator_menu_ingame:
ld a,(regs_saved + STATE_SYSTEM_TYPE)
or a
call z,convert_palette_for_menu
xor a
emulator_menu:
push af
ACALL(BackupMiniScreen)
.db $3E ;LD A,
emulator_menu_no_backup:
push af
ACALL(SetMenuWindow)
; If the state slot was changed, verify load state is valid
ld hl,main_menu_selection
ld b,(hl)
djnz _
call check_valid_state
jr nz,_
inc (hl)
_
pop af
ItemSelectLink:
ld (current_menu),a
or a
sbc hl,hl
ld l,a
ld de,main_menu_selection
add hl,de
ld (current_menu_selection),hl
dec a
jr nz,_
ACALL(ROMSearch)
_
ACALL(redraw_current_menu)
ItemSelectOption:
menu_loop:
ACALL(WaitForKey)
jr nz,_
ld a,2
jr CmdExit
_
call get_current_menu_selection
dec a
jr z,menu_down
cp 3
jr c,menu_left_right
jr z,menu_up
cp 9-1
jr z,menu_select
cp 54-1
jr z,menu_select
cp 56-1
jr z,menu_delete
cp 15-1
jr nz,menu_loop
ld hl,current_menu
xor a
cp (hl)
jr nz,ItemSelectLink
CmdExit:
ld (exitReason),a
ex af,af'
_
ACALL(GetKeyCode)
or a
jr nz,-_
ret
menu_up:
ld a,(menuPrevItem)
ld (bc),a
ACALL(draw_current_menu)
menu_loop_trampoline:
jr menu_loop
menu_down:
ld a,(menuNextItem)
ld (bc),a
ACALL(draw_current_menu)
jr menu_loop_trampoline
menu_left_right:
dec a
add a,a
dec a
ld de,ItemChangeCallbacks
_
ACALL(DoCurrentItemCallback)
jr menu_loop_trampoline
menu_delete:
ld de,ItemDeleteCallbacks
jr -_
menu_select:
ld de,ItemSelectCallbacks
DoCurrentItemCallback:
ld hl,(current_item_ptr)
DoItemCallback:
ld c,(hl)
res 7,c
inc hl
ex de,hl
ld b,2
mlt bc
add hl,bc
ld bc,(ArcBase)
add hl,bc
ld hl,(hl)
dec.s hl
add hl,bc
ld b,a
ld c,0
ld a,(de)
jp (hl)
ItemDeleteRom:
ACALL(GetSelectedROMName)
; Don't allow deleting the currently loaded ROM
ld bc,(current_description)
sbc hl,bc
ret z
ex de,hl
ld de,ConfirmDeleteROM
ItemDeleteStateFinish:
ACALL(ShowConfirmationDialog)
jr z,redraw_current_menu_trampoline
pop de
ld a,5
jr CmdExit
ItemDeleteState:
call check_valid_state
ret z
ld de,ConfirmDeleteState
ld hl,(current_state)
jr ItemDeleteStateFinish
ItemChangeRom:
ld hl,romListFrameStart
ld a,(hl)
djnz _
add a,ROMS_PER_PAGE
jr ++_
_
sub ROMS_PER_PAGE
jr c,redraw_current_menu
_
ld (hl),a
redraw_current_menu_trampoline:
jr redraw_current_menu
ItemChangeDigit:
ld e,a
ld hl,current_state
sub 2
jr nz,_
dec hl
or (hl) ;current_config
ld hl,FrameskipValue
jr z,_
ld c,(hl)
ld hl,GameFrameskipValue
ld a,(hl)
inc a
jr nz,_
ld (hl),c
_
ld a,b
and 9
ld d,a
_
rrd
add a,d
daa
rld
ld a,e
or a
call z,check_valid_state
jr z,-_
jr draw_current_menu_trampoline
ItemDeleteDigit:
cp 2
jr nz,ItemDeleteState
ld a,(current_config)
dec a
ret nz
dec a
ld (GameFrameskipValue),a
jr draw_current_menu_trampoline
ItemDeleteKey:
ItemDeleteOption:
ld d,a
ACALL(GetOption)
jr nz,ItemRevertGameSpecific
ld a,d
sub KeyConfig-OptionConfig
ret c
; Don't allow unmapping in-game buttons or menu
dec a
cp UndeletableKeysEnd-UndeletableKeysStart
ret c
ld a,(bc)
cp UNMAPPED_KEY
ret z
ld a,UNMAPPED_KEY
jr ItemDeleteKeyUnmapFinish
ItemRevertGameSpecific:
ld a,-1
ItemDeleteKeyUnmapFinish:
ld (bc),a
draw_current_menu_trampoline:
jr draw_current_menu
ItemChangeOption:
ld d,b
ACALL(GetOption)
add a,d
add a,(hl)
_
sub (hl)
jr nc,-_
add a,(hl)
ld (bc),a
jr draw_current_menu
redraw_current_menu:
ACALL(RefreshRomListFrame)
; Apply configuration if ROM is loaded (updates palette settings)
ld a,(ROMName+1)
or a
push af
jr z,_
ACALL(ApplyConfiguration)
_
ACALL(ClearMenuBuffer)
pop af
; Skip description display if on ROM list
ld hl,(current_menu)
dec l
jr z,draw_current_menu
; Display only description if no ROM is loaded
or a
ld c,35
jr z,draw_current_description
; Draw mini screen if on main menu
inc l
jr nz,_
ACALL(draw_mini_screen)
_
; Draw ROM internal name and checksum
ld ix,(rom_start)
ld bc,$0134
add ix,bc
ld b,(ix+$014E-$0134)
ld c,(ix+$014F-$0134)
push bc
push ix
APTR(TitleChecksumFormat)
push hl
ld a,MAGENTA
ld de,1<<8|40
ACALL(PutStringFormatColorXYIgnoreInvalid)
pop hl
pop hl
pop hl
ld c,30
draw_current_description:
ld b,1
ld hl,(current_description)
ld a,MAGENTA
ACALL(PutNStringColorXY)
draw_current_menu:
; Erase the help text
MEMSET_FAST(menu_frame_buffer+(320*205), 320*30, BLUE)
call get_current_menu_selection
ld a,(bc)
ld c,a
push af
; HL = menu structure, C = highlighted item index
draw_menu:
ld b,(hl)
inc hl
inc b
push bc
ld a,WHITE
call SetStringColor
ex de,hl
ld hl,$FF00
ld c,l
push hl
jr draw_menu_title
draw_menu_loop:
dec c
push bc
jr nz,_
push de
ld a,MAGENTA
ld bc,1<<8|205
ACALL(PutStringColorXY)
ld (current_item_ptr),hl
ld a,WHITE
jr draw_menu_item
_
xor a
cpir
ld a,(hl)
add a,a
jr nc,_
cp ITEM_DIGIT<<1
ld a,(ROMName+1)
call z,check_valid_load_state
or a
ld a,GRAY
jr z,draw_menu_item_push
_
pop bc
push bc
; Update the "next item" offset
ld a,c
cp e
jr c,_
ld e,a
_
; Update the "prev item" (minus 1) offset
dec a
cp d
jr nc,_
ld d,a
_
ld a,OLIVE
draw_menu_item_push:
push de
draw_menu_item:
call SetStringColor