forked from AhmedAmrNabil/brick-breaker-assembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawPad.asm
172 lines (146 loc) · 3.55 KB
/
drawPad.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
EXTRN PADDLE1_X:WORD
EXTRN PADDLE2_X:WORD
EXTRN PADDLE_WIDTH:WORD
EXTRN PADDLE2_WIDTH:WORD
PUBLIC drawPaddle
PUBLIC drawPaddle2
PUBLIC clearPaddle
PUBLIC clearPaddle2
.MODEL SMALL
.STACK 100h
.DATA
PADDLE_HEIGHT equ 10
EDGE_WIDTH equ 2
PADDLE_Y equ 180
.CODE
drawPaddle PROC FAR
MOV DX, PADDLE_Y
drawRow:
PUSH DX
MOV CX, PADDLE1_X
drawPixel:
MOV AX, CX
SUB AX, PADDLE1_X
CMP AX, EDGE_WIDTH
JL drawRed
MOV AX, CX
SUB AX, PADDLE1_X
MOV BX,PADDLE_WIDTH
SUB BX,AX
CMP BX,EDGE_WIDTH
JLE drawRed
drawGrey:
MOV AH, 0Ch
MOV AL, 08h
MOV BH, 00h
INT 10h
JMP nextPixel
drawRed:
MOV AH, 0Ch
MOV AL, 04h
MOV BH, 00h
INT 10h
nextPixel:
INC CX
MOV AX, CX
SUB AX, PADDLE1_X
CMP AX, PADDLE_WIDTH
JL drawPixel
POP DX
INC DX
MOV AX, DX
SUB AX, PADDLE_Y
CMP AX, PADDLE_HEIGHT
JL drawRow
RET
drawPaddle ENDP
drawPaddle2 PROC FAR
MOV DX, PADDLE_Y
drawRow2:
PUSH DX
MOV CX, PADDLE2_X
drawPixel2:
MOV AX, CX
SUB AX, PADDLE2_X
CMP AX, EDGE_WIDTH
JL drawRed2
MOV AX, CX
SUB AX, PADDLE2_X
MOV BX,PADDLE2_WIDTH
SUB BX,AX
CMP BX,EDGE_WIDTH
JLE drawRed2
drawGrey2:
MOV AH, 0Ch
MOV AL, 08h
MOV BH, 00h
INT 10h
JMP nextPixel2
drawRed2:
MOV AH, 0Ch
MOV AL, 04h
MOV BH, 00h
INT 10h
nextPixel2:
INC CX
MOV AX, CX
SUB AX, PADDLE2_X
CMP AX, PADDLE2_WIDTH
JL drawPixel2
POP DX
INC DX
MOV AX, DX
SUB AX, PADDLE_Y
CMP AX, PADDLE_HEIGHT
JL drawRow2
RET
drawPaddle2 ENDP
clearPaddle PROC FAR
MOV DX, PADDLE_Y
clearRow:
PUSH DX
MOV CX, PADDLE1_X
drawBlack:
MOV AH, 0Ch
MOV AL, 00h
MOV BH, 00h
INT 10h
clearNextPixel:
INC CX
MOV AX, CX
SUB AX, PADDLE1_X
CMP AX, PADDLE_WIDTH
JL drawBlack
POP DX
INC DX
MOV AX, DX
SUB AX, PADDLE_Y
CMP AX, PADDLE_HEIGHT
JL clearRow
RET
clearPaddle ENDP
clearPaddle2 PROC FAR
MOV DX, PADDLE_Y
clearRow2:
PUSH DX
MOV CX, PADDLE2_X
drawBlack2:
MOV AH, 0Ch
MOV AL, 00h
MOV BH, 00h
INT 10h
clearNextPixel2:
INC CX
MOV AX, CX
SUB AX, PADDLE2_X
CMP AX, PADDLE2_WIDTH
JL drawBlack2
POP DX
INC DX
MOV AX, DX
SUB AX, PADDLE_Y
CMP AX, PADDLE_HEIGHT
JL clearRow2
RET
clearPaddle2 ENDP
END