forked from AhmedAmrNabil/brick-breaker-assembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.asm
166 lines (126 loc) · 2.43 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
PUBLIC choice
PUBLIC mainMenu
.MODEL medium
.386
.DATA
filename db 'menu.bin', 0
buffer_size equ 64001d
buffer db buffer_size dup(?)
IMAGE_HEIGHT equ 200
IMAGE_WIDTH equ 320
SCREEN_WIDTH equ 320
SCREEN_HEIGHT equ 200
choice dw 0
startArrow dw 55
endArrow dw 55+15
startPositions dw 55,153,251
arrowHeight equ 140
.CODE
drawArrow PROC FAR
MOV AX,choice
MOV SI,AX
SHL SI,1
MOV BX,startPositions[SI]
MOV startArrow,BX
ADD BX,15
MOV endArrow,BX
MOV CX, startArrow
MOV DX, arrowHeight
MOV AH, 0CH
MOV AL, 15d
drawArrowRowLoop:
INT 10h
INC CX
CMP CX,endArrow
JL drawArrowRowLoop
INC DX
INC startArrow
DEC endArrow
MOV CX,startArrow
MOV BX,endArrow
CMP BX,startArrow
JGE drawArrowRowLoop
RET
drawArrow ENDP
clearArrow PROC FAR
MOV AX,choice
MOV SI,AX
SHL SI,1
MOV BX,startPositions[SI]
MOV startArrow,BX
ADD BX,15
MOV endArrow,BX
MOV CX, startArrow
MOV DX, arrowHeight
MOV AH, 0CH
MOV AL, 00d
clearArrowRowLoop:
INT 10h
INC CX
CMP CX,endArrow
JL clearArrowRowLoop
INC DX
INC startArrow
DEC endArrow
MOV CX,startArrow
MOV BX,endArrow
CMP BX,startArrow
JGE clearArrowRowLoop
RET
clearArrow ENDP
drawImage PROC
MOV AX, 0A000h
MOV ES, AX
MOV DI, 0
MOV SI, offset buffer
MOV CX, 320 * 200 ; Total pixels in the screen (320x200)
REP MOVSB
RET
drawImage ENDP
displayMenu PROC
mov ah, 03Dh
mov al, 0 ; open attribute: 0 - read-only, 1 - write-only, 2 -read&write
mov dx, offset filename ; ASCIIZ filename to open
int 21h
mov bx, AX
mov ah, 03Fh
mov cx, buffer_size ; number of bytes to read
mov dx, offset buffer ; were to put read data
int 21h
mov ah, 3Eh ; DOS function: close file
INT 21H
call drawImage
RET
displayMenu ENDP
mainMenu PROC FAR
mov ah,0
mov al,13h
int 10h
CALL displayMenu
MOV choice, 0
choiceLoop:
call drawArrow
MOV AH, 00H
INT 16H
PUSHA
call clearArrow
POPA
CMP AH,4BH
JNE skipDecrement
CMP choice,0
JE skipDecrement
DEC choice
skipDecrement:
CMP AH,4DH
JNE skipIncrement
CMP choice,2
JE skipIncrement
INC choice
skipIncrement:
CMP AH,1CH
JE exitMainMenu
jmp choiceLoop
exitMainMenu:
RET
mainMenu ENDP
END