-
Notifications
You must be signed in to change notification settings - Fork 0
/
PSGENV.ASM
418 lines (350 loc) · 5.58 KB
/
PSGENV.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
;
; PSGにエンベローブをかけちゃうぞ!
;
; Made by Ken/ichiro
;
.286C
CRT EQU 0AH
ON EQU -1
OFF EQU 0
CODE SEGMENT PUBLIC
ASSUME CS:CODE,DS:CODE,ES:CODE
ORG 0
DB "PSGENV LOADED"
ORG 1CH
LVLFLAG DB OFF
DW OFFSET PATBASE
ALREADY_INIT DB OFF
ORG 20H
START:
PUSHA
MOV AX,CS
MOV DS,AX
MOV ES,AX
MOV AL,ALREADY_INIT
CMP AL,OFF
JNE TOCLOSE
CALL INIT
JMP EXIT
TOCLOSE: CALL CLOSE
EXIT:
POPA
IRET
INIT PROC
PUSH ES
XOR AX,AX
MOV ES,AX
MOV SI,CRT*4
MOV CX,4
MOV DI,OFFSET OLD_CRTV_VECT
LOAD_OLD_CRTV: MOV AL,ES:[SI]
MOV [DI],AL
INC SI
INC DI
LOOP LOAD_OLD_CRTV
MOV DI,CRT*4
MOV AX,OFFSET PSGENV
CLI
MOV ES:[DI],AX
INC DI
INC DI
MOV ES:[DI],CS
STI
POP ES
IN AL,02H
MOV OLD_INT_MASK,AL
AND AL,0FBH
OUT 02H,AL
OUT 64H,AL
MOV AL,ON
MOV ALREADY_INIT,AL
RET
INIT ENDP
CLOSE PROC
PUSH ES
XOR AX,AX
MOV ES,AX
MOV DI,CRT*4
MOV CX,4
MOV SI,OFFSET OLD_CRTV_VECT
CLI
STORE_OLD_CRTV: MOV AL,[SI]
MOV ES:[DI],AL
INC SI
INC DI
LOOP STORE_OLD_CRTV
STI
MOV AX,0A000H
MOV ES,AX
MOV BX,24*80*2
MOV ES:[BX],BYTE PTR 20H
INC BX
INC BX
MOV ES:[BX],BYTE PTR 20H
INC BX
INC BX
MOV ES:[BX],BYTE PTR 20H
POP ES
MOV AL,OFF
MOV ALREADY_INIT,AL
MOV AL,OLD_INT_MASK
OUT 02H,AL
RET
CLOSE ENDP
PSGENV PROC FAR
CLI
PUSH AX
PUSH DI
PUSH DS
MOV AX,CS
MOV DS,AX
MOV AH,7
CALL INP
MOV ZURU,AL
INC A_COUNT
MOV AH,8
CALL INP
MOV AH,A_VOL
OR AL,AL
JNZ A_NZ
MOV A_VOL,AL
JMP A_DONE
A_NZ: CMP AL,AH
JNE A_FRESH
MOV DI,A_NOWB
INC DI
MOV AL,[DI]
OR AL,AL
JZ A_DONE
MOV AH,A_COUNT
CMP AH,AL
JBE A_DONE
INC DI
MOV A_NOWB,DI
MOV AL,[DI]
MOV AH,8
CALL OUTP
MOV A_VOL,AL
XOR AH,AH
MOV A_COUNT,AH
JMP A_DONE
A_FRESH: MOV AH,11
CALL INP
XOR AH,AH
SHL AX,1
MOV DI,OFFSET PATBASE
ADD DI,AX
MOV DI,[DI]
MOV A_NOWB,DI
MOV AL,[DI]
MOV A_VOL,AL
MOV AH,1
MOV A_COUNT,AH
OR AL,AL
JZ A_DONE
MOV AH,8
CALL OUTP
A_DONE:
INC B_COUNT
MOV AH,9
CALL INP
MOV AH,B_VOL
OR AL,AL
JNZ B_NZ
MOV B_VOL,AL
JMP B_DONE
B_NZ: CMP AL,AH
JNE B_FRESH
MOV DI,B_NOWB
INC DI
MOV AL,[DI]
OR AL,AL
JZ B_DONE
MOV AH,B_COUNT
CMP AH,AL
JBE B_DONE
INC DI
MOV B_NOWB,DI
MOV AL,[DI]
MOV AH,9
CALL OUTP
MOV B_VOL,AL
XOR AH,AH
MOV B_COUNT,AH
JMP B_DONE
B_FRESH: MOV AH,12
CALL INP
XOR AH,AH
SHL AX,1
MOV DI,OFFSET PATBASE
ADD DI,AX
MOV DI,[DI]
MOV B_NOWB,DI
MOV AL,[DI]
MOV B_VOL,AL
OR AL,AL
JZ B_DONE
MOV AH,1
MOV B_COUNT,AH
MOV AH,9
CALL OUTP
B_DONE:
INC C_COUNT
MOV AH,10
CALL INP
MOV AH,C_VOL
OR AL,AL
JNZ C_NZ
MOV C_VOL,AL
JMP C_DONE
C_NZ: CMP AL,AH
JNE C_FRESH
MOV DI,C_NOWB
INC DI
MOV AL,[DI]
OR AL,AL
JZ C_DONE
MOV AH,C_COUNT
CMP AH,AL
JBE C_DONE
INC DI
MOV C_NOWB,DI
MOV AL,[DI]
MOV AH,10
CALL OUTP
MOV C_VOL,AL
XOR AH,AH
MOV C_COUNT,AH
JMP C_DONE
C_FRESH: MOV AH,13
CALL INP
XOR AH,AH
SHL AX,1
MOV DI,OFFSET PATBASE
ADD DI,AX
MOV DI,[DI]
MOV C_NOWB,DI
MOV AL,[DI]
MOV C_VOL,AL
OR AL,AL
JZ C_DONE
MOV AH,1
MOV C_COUNT,AH
MOV AH,10
CALL OUTP
C_DONE:
PUSH ES
MOV DI,0A000H
MOV ES,DI
MOV AH,LVLFLAG
OR AH,AH
JNZ PUTLVL
MOV DI,24*80*2
MOV ES:[DI],BYTE PTR 'P'
JMP LVLEND
PUTLVL: MOV AH,8
CALL INP
AND AX,0FH
MOV DI,OFFSET HEX
ADD DI,AX
MOV AL,[DI]
MOV DI,24*80*2
MOV ES:[DI],AL
MOV AH,9
CALL INP
AND AX,0FH
MOV DI,OFFSET HEX
ADD DI,AX
MOV AL,[DI]
MOV DI,24*80*2+2
MOV ES:[DI],AL
MOV AH,10
CALL INP
AND AX,0FH
MOV DI,OFFSET HEX
ADD DI,AX
MOV AL,[DI]
MOV DI,24*80*2+4
MOV ES:[DI],AL
LVLEND: POP ES
MOV AH,7
MOV AL,ZURU
CALL OUTP
XOR AL,AL
OUT 64H,AL
POP DS
POP DI
POP AX
STI
JMP CS:[OLD_CRTV_VECT]
PSGENV ENDP
OUTP PROC
; AH=REG NO : AL=DATA
PUSH DX
PUSH AX
MOV DX,188H
YM_BUSY_WAIT: IN AL,DX
AND AL,80H
JNZ YM_BUSY_WAIT
POP AX
XCHG AH,AL
OUT DX,AL
XCHG AH,AL
MOV DX,18AH
OUT DX,AL
POP DX
RET
OUTP ENDP
INP PROC
; AH=REG NO : AL=DATA
PUSH DX
PUSH AX
MOV DX,188H
YM_BUSY_WAIT2: IN AL,DX
AND AL,80H
JNZ YM_BUSY_WAIT2
POP AX
XCHG AH,AL
OUT DX,AL
XCHG AH,AL
MOV DX,18AH
IN AL,DX
POP DX
RET
INP ENDP
;************************************************
HEX DB "0123456789ABCDEFH"
ZURU DB ?
OLD_CRTV_VECT DD ?
OLD_INT_MASK DB ?
A_NOWB DW OFFSET NOENV
B_NOWB DW OFFSET NOENV
C_NOWB DW OFFSET NOENV
A_VOL DB 0
B_VOL DB 0
C_VOL DB 0
A_COUNT DB 0
B_COUNT DB 0
C_COUNT DB 0
DB 8 DUP (' ')
DB "PSGENV--Made by Ken/ichiro"
DB 8 DUP (' ')
;PATTERN DATA ***********************************
PATBASE DW OFFSET NOENV
DW OFFSET PAT_1
DW OFFSET PAT_2
DW OFFSET PAT_3
DW OFFSET PAT_4
NOENV DW 0
; LEVEL,TIME(0 IS END)
PAT_1 DB 15,19, 14,19, 13,19, 12,19, 11,19, 10,19, 9,19, 8,19
DB 7,19, 6, 19, 5, 0
PAT_2 DB 15, 4, 14, 4, 13, 4, 12, 4, 11, 4, 10, 4, 9, 4, 8, 4
DB 7, 4, 6, 4, 5, 4, 4, 4, 3, 4, 2, 4, 1, 4, 0, 0
PAT_3 DB 11, 1, 13, 1, 14,12, 13,12, 12,12, 11,12, 10,12
DB 9,12, 8,12, 7,12, 6,12, 5, 0
PAT_4 DB 15, 4, 13,40, 12,40, 11,40, 10, 0
;************************************************
CODE ENDS
END