-
Notifications
You must be signed in to change notification settings - Fork 1
/
GUI.ASM
1659 lines (1320 loc) · 48.5 KB
/
GUI.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
; --------------------------------------------------------------------
; BrMSX v:1.32
; Copyright (C) 1997 by Ricardo Bittencourt
; module: GUI.ASM
; --------------------------------------------------------------------
.386p
code32 segment para public use32
assume cs:code32, ds:code32
include pmode.inc
include z80.inc
include io.inc
include bit.inc
include vdp.inc
include psg.inc
include blit.inc
include mouse.inc
include debug.inc
include saveload.inc
include mount.inc
include v9938.inc
extrn blitbuffer: dword
extrn filenamelist: dword
extrn read_rom: near
extrn cart1: dword
extrn rommapper: dword
extrn rommappera: dword
extrn load_disk_image: near
extrn drivea_name: byte
extrn msxmodel: dword
extrn alf_uncompressed: dword
public rendercounter
public spritecounter
public blitcounter
public guicounter
public psgcounter
public renderrate
public spriterate
public blitrate
public guirate
public psgrate
public psggraph
public draw_gui
public start_gui
public turnoff_flag
public patch__47
public uncompress_alf
; DATA ---------------------------------------------------------------
align 4
include number.inc
include alf.inc
include logo.inc
include cursor.inc
include scroll.inc
align 4
rendercounter db 8 dup (0)
spritecounter db 8 dup (0)
blitcounter db 8 dup (0)
guicounter db 8 dup (0)
psgcounter db 8 dup (0)
z80acc db 8 dup (0)
renderacc db 8 dup (0)
spriteacc db 8 dup (0)
blitacc db 8 dup (0)
guiacc db 8 dup (0)
psgacc db 8 dup (0)
renderrate dd 0
spriterate dd 0
blitrate dd 0
guirate dd 0
psgrate dd 0
z80number dd 0
rendernumber dd 0
spritenumber dd 0
blitnumber dd 0
guinumber dd 0
psgnumber dd 0
framenumber dd 0
lastmouse dd 0
psggraph dd 0
turnoff_flag dd 0
msx2_cpu_mask dd 0
; vars for main menu
menu_selected dd 0
menu_last dd 0
menu_number dd 10
menu_locked dd 0
menu_child dd 0
menu_callback:
dd offset unpause_cpu
dd offset reset_cpu_now
menu_callback_xxx:
dd offset turn_off_now
dd offset load_rom
dd offset load_dsk
dd offset changebargraph
dd offset change_psggraph
dd offset change_sound
dd offset save_sta
dd offset load_sta
dd offset quit_emulator
menu_msg:
dd offset msg_reset
dd offset msg_turn_xxx
dd offset msg_load_cart
dd offset msg_load_dsk
dd offset msg_bargraph
dd offset msg_psggraph
dd offset msg_sound
dd offset msg_save_sta
dd offset msg_load_sta
dd offset msg_quit
msg_reset db 'Reset',0
msg_turn_xxx db 'Turn OFF',0
msg_load_cart db 'Load ROM',0
msg_load_dsk db 'Load DSK',0
msg_bargraph db 'CPU Graph',0
msg_psggraph db 'PSG Graph',0
msg_sound db 'Sound',0
msg_save_sta db 'Save State',0
msg_load_sta db 'Load State',0
msg_quit db 'Quit',0
msg_turn_on db 'Turn ON ',0
msg_turn_off db 'Turn OFF',0
; vars for load rom menu
align 4
load_rom_selected dd 0
load_rom_last dd 0
load_rom_scroll dd 0
firstrom dd 0
totalrom dd 0
gui_mask dd 0
actual_mask dd offset rom_mask
save_videomode dd 0
name_buffer db 16 dup (0)
rom_mask db '*.ROM',0
dsk_mask db '*.DSK',0
rom_extension db '.ROM',0
dsk_extension db '.DSK',0
; psg color bars
psgcolor:
db 12,12,12,12,03,03,03,03
db 10,10,11,11,09,09,08,08
; CODE ---------------------------------------------------------------
; uncompress_alf -----------------------------------------------------
; uncompress the alf
uncompress_alf:
mov ecx,16384/8
mov esi,offset alf_pattern_z
mov edi,alf_uncompressed
uncompress_alf_loop:
mov bl,[esi]
irp i,<0,1,2,3,4,5,6,7>
rol bl,1
sbb al,al
mov [edi],al
inc edi
endm
inc esi
dec ecx
jnz uncompress_alf_loop
ret
; draw_gui -----------------------------------------------------------
; draw the gui in blitbuffer
draw_gui:
;call draw_wave_graph
cmp bargraphmode,0
je draw_gui_psg
call draw_bar_graph
draw_gui_psg:
cmp psggraph,0
je _ret
call draw_psggraph
ret
; --------------------------------------------------------------------
draw_wave_graph:
;mov esi,dmastart
mov ecx,252
mov edx,0
draw_wave_graph_loop:
movzx eax,byte ptr [esi]
movzx ebx,byte ptr [esi+1]
add eax,ebx
movzx ebx,byte ptr [esi+2]
add eax,ebx
movzx ebx,byte ptr [esi+3]
add eax,ebx
shr eax,2
shr eax,1
shl eax,8
add eax,edx
add eax,blitbuffer
add eax,256*100
mov byte ptr [eax],013
add esi,3
inc edx
dec ecx
jnz draw_wave_graph_loop
ret
; --------------------------------------------------------------------
draw_bar_graph:
; draw the bar graph
mov edi,0
mov ebp,z80number
mov eax,z80rate
call drawline
mov edi,8
mov ebp,rendernumber
mov eax,renderrate
call drawline
mov edi,16
mov ebp,spritenumber
mov eax,spriterate
call drawline
mov edi,24
mov ebp,blitnumber
mov eax,blitrate
call drawline
mov edi,32
mov ebp,guinumber
mov eax,guirate
call drawline
mov edi,40
mov ebp,psgnumber
mov eax,psgrate
call drawline
; --------------------------------------------------------------------
; update the counters
mov eax,z80rate
mov ebx,offset z80acc
mov ecx,offset z80number
call evalcounter
mov eax,renderrate
mov ebx,offset renderacc
mov ecx,offset rendernumber
call evalcounter
mov eax,spriterate
mov ebx,offset spriteacc
mov ecx,offset spritenumber
call evalcounter
mov eax,blitrate
mov ebx,offset blitacc
mov ecx,offset blitnumber
call evalcounter
mov eax,guirate
mov ebx,offset guiacc
mov ecx,offset guinumber
call evalcounter
mov eax,psgrate
mov ebx,offset psgacc
mov ecx,offset psgnumber
call evalcounter
inc framenumber
cmp framenumber,10
jne draw_update0
mov framenumber,0
draw_update0:
; --------------------------------------------------------------------
; update the dirty table
mov eax,001010101h
mov ebx,000010101h
mov edi,offset dirtyname
irp j,<0,1,2,3,4,5>
or [edi+j*32],eax
or [edi+4+j*32],ebx
endm
ret
; draw_psggraph ------------------------------------------------------
; draw bar graph for PSG-VU meter
draw_psggraph:
irp i,<0,1,2>
movzx eax,byte ptr [offset psgreg+8+i]
and eax,0Fh
mov edi,30*8+i*4
call draw_psggraph_channel
endm
mov word ptr [offset dirtyname+30+0*32],0101h
mov word ptr [offset dirtyname+30+1*32],0101h
mov word ptr [offset dirtyname+30+2*32],0101h
mov word ptr [offset dirtyname+30+3*32],0101h
cmp sccenabled,0
je draw_psggraph_fmpac
irp i,<0,1,2,3,4>
movzx eax,byte ptr [offset sccregs+10+i]
and eax,0Fh
mov edi,27*8+i*4
call draw_psggraph_channel
endm
mov dword ptr [offset dirtyname+27+0*32],01010101h
mov dword ptr [offset dirtyname+27+1*32],01010101h
mov dword ptr [offset dirtyname+27+2*32],01010101h
mov dword ptr [offset dirtyname+27+3*32],01010101h
draw_psggraph_fmpac:
cmp fmenabled,1
jne _ret
irp i,<0,1,2,3,4,5,6,7,8>
movzx eax,byte ptr [offset fmreg+30h+i]
and eax,0Fh
xor eax,0Fh
mov ah,byte ptr [offset fmreg+20h+i]
shr ah,5
sbb ah,ah
and al,ah
mov ah,0
mov edi,21*8+i*4
call draw_psggraph_channel
endm
mov dword ptr [offset dirtyname+21+0*32],01010101h
mov dword ptr [offset dirtyname+21+1*32],01010101h
mov dword ptr [offset dirtyname+21+2*32],01010101h
mov dword ptr [offset dirtyname+21+3*32],01010101h
or dword ptr [offset dirtyname+25+0*32],01010101h
or dword ptr [offset dirtyname+25+1*32],01010101h
or dword ptr [offset dirtyname+25+2*32],01010101h
or dword ptr [offset dirtyname+25+3*32],01010101h
ret
draw_psggraph_channel:
add edi,blitbuffer
add edi,256
mov ecx,15
draw_psggraph_channel_loop:
cmp ecx,eax
ja draw_psggraph_channel_next
mov bl,[offset psgcolor+ecx]
mov [edi+1],bl
mov [edi+2],bl
mov [edi+3],bl
cmp ecx,1
je draw_psggraph_channel_next
mov byte ptr [edi+1+256],01h
mov word ptr [edi+2+256],0101h
draw_psggraph_channel_next:
add edi,512
dec ecx
jnz draw_psggraph_channel_loop
ret
DRAW_NUMBER macro x_offset
local draw_msx2,draw_exit,draw_now
cmp videomode,7
je draw_now
cmp actualscreen,6
je draw_msx2
cmp actualscreen,7
je draw_msx2
draw_now:
irp i,<0,1,2,3,4>
mov ebx,[esi+i*8]
mov ecx,[esi+i*8+4]
and [edi+(i+1)*256+x_offset],ebx
and [edi+(i+1)*256+4+x_offset],ecx
xor ebx,0FFFFFFFFh
xor ecx,0FFFFFFFFh
and ebx,004040404h
and ecx,004040404h
or [edi+(i+1)*256+x_offset],ebx
or [edi+(i+1)*256+4+x_offset],ecx
endm
jmp draw_exit
draw_msx2:
irp i,<0,1,2,3,4>
irp j,<0,1,2,3,4,5,6,7>
mov bl,[esi+i*8+j]
and [edi+(i+1)*512+(j+x_offset)*2],bl
and [edi+(i+1)*512+(j+x_offset)*2+1],bl
xor bl,0FFh
and bl,004h
or [edi+(i+1)*512+(j+x_offset)*2],bl
or [edi+(i+1)*512+(j+x_offset)*2+1],bl
endm
endm
draw_exit:
endm
; drawline -----------------------------------------------------------
; draw a single bar in blitbuffer
drawline:
; mov msx2_cpu_mask,0
; cmp msxmodel,1
; jb drawline_msx1
; mov msx2_cpu_mask,1010h
;drawline_msx1:
mov ebx,100
mul ebx
xor edx,edx
mov ebx,dword ptr [offset clockrate]
div ebx
mov ecx,50
mov esi,eax
shr esi,1
mov ebx,0F0Dh
or ebx,msx2_cpu_mask
cmp videomode,7
je draw_now
cmp actualscreen,6
je drawline_msx2
cmp actualscreen,7
je drawline_msx2
draw_now:
shl edi,8
add edi,blitbuffer
drawline1:
cmp ecx,esi
jbe drawline2
irp i,<0,1,2,3,4,5,6>
mov byte ptr [edi+256*i],bh
endm
jmp drawline_loop
drawline2:
irp i,<0,1,2,3,4,5,6>
mov byte ptr [edi+256*i],bl
endm
drawline_loop:
inc edi
dec ecx
jnz drawline1
sub edi,33
jmp drawline_continue
drawline_msx2:
shl edi,9
add edi,blitbuffer
drawline1_msx2:
cmp ecx,esi
jbe drawline2_msx2
irp i,<0,1,2,3,4,5,6>
mov byte ptr [edi+512*i],bh
mov byte ptr [edi+512*i+1],bh
endm
jmp drawline_loop_msx2
drawline2_msx2:
irp i,<0,1,2,3,4,5,6>
mov byte ptr [edi+512*i],bl
mov byte ptr [edi+512*i+1],bl
endm
drawline_loop_msx2:
add edi,2
dec ecx
jnz drawline1_msx2
sub edi,66
drawline_continue:
mov eax,ebp
;sub edi,33
mov ebx,100
xor edx,edx
div ebx
mov esi,eax
shl esi,6
add esi,offset number_font
DRAW_NUMBER 0
mov eax,edx
mov ebx,10
xor edx,edx
div ebx
mov esi,eax
shl esi,6
add esi,offset number_font
DRAW_NUMBER 5
cmp videomode,7
je draw_point_skip
cmp actualscreen,6
je draw_point_msx2
cmp actualscreen,7
je draw_point_msx2
draw_point_skip:
mov byte ptr [edi+5*256+10],04h
jmp draw_point_exit
draw_point_msx2:
mov byte ptr [edi+5*512+10*2],04h
mov byte ptr [edi+5*512+10*2+1],04h
draw_point_exit:
mov esi,edx
shl esi,6
add esi,offset number_font
DRAW_NUMBER 12
ret
; evalcounter --------------------------------------------------------
; update a counter
evalcounter:
add dword ptr [ebx],eax
adc dword ptr [ebx+4],0
cmp framenumber,0
jnz _ret
mov eax,dword ptr [ebx]
mov edi,100
mul edi
mov esi,edx
mov dword ptr [ebx],eax
mov eax,dword ptr [ebx+4]
mul edi
add eax,esi
mov dword ptr [ebx+4],eax
mov eax,dword ptr [ebx]
mov edx,dword ptr [ebx+4]
mov edi,dword ptr [offset clockrate]
div edi
mov dword ptr [ecx],eax
mov dword ptr [ebx],0
mov dword ptr [ebx+4],0
ret
; start_gui ----------------------------------------------------------
; start the gui
start_gui:
call release_button
cmp videomode,8
jb start_gui_now
mov eax,videomode
mov save_videomode,eax
mov videomode,7
call setgraphmode
start_gui_now:
call clear
mov menu_locked,0
; update palette
mov ebx,pal_gui
mov ecx,256
call fill_palette
mov firstscreen,1
start_gui_loop:
cmp enabled,0
jne start_gui_pipeline
mov enabled,1
mov eax,01010101h
mov ecx,32*24/4
mov edi,offset dirtyname
rep stosd
start_gui_pipeline:
call dirty_mouse
call draw_menu_screen
call draw_logo
call read_mouse
call draw_main_menu
call dirty_mouse
call draw_mouse_cursor
call wait_vsync
call blit
call action
cmp cpupaused,1
je start_gui_loop
cmp turnoff_flag,1
je turnoff_trap
start_gui_exit:
mov eax,save_videomode
cmp eax,0
je start_gui_exit_now
mov videomode,eax
call setgraphmode
start_gui_exit_now:
call clear
mov eax,01010101h
mov ecx,32*24/4
mov edi,offset dirtyname
rep stosd
mov ecx,16/4
mov edi,offset dirty_palette
rep stosd
mov firstscreen,1
mov enabled,1
mov palette_scr8,0
call set_correct_palette
ret
turnoff_trap:
cmp quitnow,1
je start_gui_exit
call turn_off_now
jmp start_gui_loop
; draw_menu_screen ---------------------------------------------------
; draw the background for the menu screen
draw_menu_screen:
mov ebx,0
cmp turnoff_flag,1
je draw_noise_screen
call render
call sprite_render
call set_border_color_dark
ret
; action -------------------------------------------------------------
; perform an action if the mouse button has been pressed
action:
mov eax,mouseleft
xor eax,lastmouse
and eax,mouseleft
jz action_end
mov eax,menu_selected
call dword ptr [offset menu_callback+eax*4]
action_end:
mov eax,mouseleft
mov lastmouse,eax
ret
; draw_logo ----------------------------------------------------------
; draw the brmsx logo
draw_logo:
mov edi,135*256
add edi,blitbuffer
mov esi,offset logo_bitmap
mov ecx,57
draw_gui_drawlogo:
mov ebx,89
draw_gui_drawlogo_loop:
mov al,[esi]
or al,al
jz draw_gui_drawlogo_next
mov [edi],al
draw_gui_drawlogo_next:
inc edi
inc esi
dec ebx
jnz draw_gui_drawlogo_loop
add edi,256-89
dec ecx
jnz draw_gui_drawlogo
ret
; draw_mouse_cursor --------------------------------------------------
; draw the mouse cursor
draw_mouse_cursor:
mov edi,mousey
shl edi,8
add edi,mousex
add edi,blitbuffer
mov esi,offset cursor_bitmap
mov ecx,17
draw_cursor:
mov ebx,51
draw_cursor_loop:
mov al,[esi]
or al,al
jz draw_cursor_next
mov [edi],al
draw_cursor_next:
inc edi
inc esi
dec ebx
jnz draw_cursor_loop
add edi,256-51
dec ecx
jnz draw_cursor
ret
; dirty_mouse --------------------------------------------------------
; turn the screen behind the cursor dirty
dirty_mouse:
mov eax,mousey
shr eax,3
shl eax,5
mov ebx,mousex
shr ebx,3
add eax,ebx
add eax,offset dirtyname
mov dword ptr [eax],01010101h
mov dword ptr [eax+4],01010101h
mov dword ptr [eax+32],01010101h
mov dword ptr [eax+4+32],01010101h
mov dword ptr [eax+64],01010101h
mov dword ptr [eax+4+64],01010101h
ret
; draw_main_menu -----------------------------------------------------
; draw the main menu
draw_main_menu:
mov eax,0808h
mov ebx,784Ah
call draw_box
call check_selection
mov ebp,menu_number
mov edi,offset menu_msg
mov ebx,1010h
draw_main_menu_loop:
mov eax,[edi]
call printgr_shaded
add ebx,0800h
add edi,4
dec ebp
jnz draw_main_menu_loop
call draw_menu_child
ret
; draw_box -----------------------------------------------------------
; draw a box window
; enter ah=y coord al=x coord
; bh=y size bl=x size
draw_box:
movzx edi,ax
add edi,blitbuffer
mov esi,edi
movzx edx,bh
movzx ecx,bl
draw_box_loop:
mov al,0F0h
rep stosb
movzx ecx,bl
add edi,256
sub edi,ecx
dec edx
jnz draw_box_loop
; draw the orange lines
lea edi,[esi+1+256]
movzx ecx,bl
mov esi,ecx
sub ecx,2
mov al,0E4h
rep stosb
add edi,256
sub edi,esi
movzx edx,bh
sub edx,4
movzx ecx,bl
sub ecx,2
draw_box_line_loop:
mov byte ptr [edi+2],al
mov byte ptr [edi+ecx+1],al
add edi,256
dec edx
jnz draw_box_line_loop
add edi,2
rep stosb
ret
; printgr_shaded -----------------------------------------------------
; print a string the blit buffer, using shaded colors
; enter: eax -> offset of the message (ASCIIZ)
; bh = y coord , bl = x coord
printgr_shaded:
push ebp edx ebx edi
sub ebx,0101h
mov esi,0D3D3D3D3h
push eax
call printgr
pop eax
add ebx,0101h
mov esi,0FAFAFAFAh
push eax
call printgr
pop eax
pop edi ebx edx ebp
ret
; printgr ------------------------------------------------------------
; print a string the blit buffer
; enter: eax -> offset of the message (ASCIIZ)
; bh = y coord , bl = x coord
; esi = color (replicated four times)
printgr:
movzx edi,bx
add edi,blitbuffer
printgr_loop:
movzx edx,byte ptr [eax]
or edx,edx
jz _ret
shl edx,6
add edx,alf_uncompressed ;offset alf_pattern
irp i,<0,1,2,3,4,5,6,7>
mov ecx,[edx+i*8]
mov ebp,ecx
xor ecx,0FFFFFFFFh
and [edi+i*256],ecx
and ebp,esi
or [edi+i*256],ebp
mov ecx,[edx+i*8+4]
mov ebp,ecx
xor ecx,0FFFFFFFFh
and [edi+i*256+4],ecx
and ebp,esi
or [edi+i*256+4],ebp
endm
inc eax
add edi,6
jmp printgr_loop
; check_selection ----------------------------------------------------
; check if the mouse is over an item that can be selected
; light that item if affirmative
check_selection:
cmp menu_locked,1
je check_selection_locked
; check Y boundaries
mov eax,mousey
add eax,3
sub eax,16
js check_selection_none
mov ebx,menu_number
shl ebx,3
cmp eax,ebx
jae check_selection_none
; check X boundaries
mov ecx,mousex
sub ecx,12
js check_selection_none
cmp ecx,04Ah-8
ja check_selection_none
mov ebx,eax
shr ebx,3
inc ebx
mov menu_selected,ebx
check_selection_drawbar:
and eax,0FFFFFFF8h
add eax,15
mov edi,eax
shl edi,8
add edi,10
add edi,blitbuffer
mov edx,9
mov eax,0D2D2D2D2h
check_selection_draw:
mov ecx,(04Ah-4)
rep stosb
add edi,256-(04Ah-4)
dec edx
jnz check_selection_draw
jmp check_selection_update
check_selection_none:
mov menu_selected,0