-
Notifications
You must be signed in to change notification settings - Fork 0
/
MICROE.BAS
600 lines (485 loc) · 11.2 KB
/
MICROE.BAS
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
'******************************
'* MICRO E-FOREST for PC-98 *
'* EL_BASICˆÚA”Å *
'******************************
'History
'ver 0.1 2020.2.24 PC-98 EL_BASICˆÚA”Å쬊JŽn
'ver 0.2 2020.5.5 Add Pallet configuration
'***********
' Variables
'***********
INTEGER size
INTEGER c_block(256)
INTEGER c_tree(256)
INTEGER c_player11(256)
INTEGER c_player12(256)
INTEGER c_erase(256)
INTEGER c_enemy11(256)
INTEGER c_enemy12(256)
INTEGER c_enemy21(256)
INTEGER c_enemy22(256)
INTEGER c_buf(256)
INTEGER tree_x, tree_y
INTEGER pX, pY
INTEGER ppX, ppY
INTEGER pakX, pakY
INTEGER pH
INTEGER mxpH
INTEGER eX(8), eY(8)
INTEGER eX_buf, eY_buf
INTEGER peX, peY
INTEGER eakS
INTEGER eakX(8), eakY(8)
INTEGER peakX, peakY
INTEGER eH(8)
INTEGER mxeH(8)
INTEGER ept1, ept2, ept3, ept4
STRING pK
INTEGER i
'************************
' Subroutine Protoptypes
'************************
SUBDEF createchar1(CONST INTEGER x1, CONST INTEGER y1, CONST INTEGER size)
SUBDEF getchar1(CONST INTEGER x1, CONST INTEGER y1, CONST INTEGER x2, CONST INTEGER y2)
SUBDEF calcpXY(REFERENCE STRING pK, REFERENCE INTEGER pX, REFERENCE INTEGER pY, REFERENCE INTEGER pakX, REFERENCE INTEGER pakY)
SUBDEF calceXY(CONST INTEGER pX, CONST INTEGER pY, REFERENCE INTEGER eX, REFERENCE INTEGER eY)
SUBDEF set6A(CONST INTEGER dat)
SUBDEF setApal(CONST INTEGER palN, CONST INTEGER R, CONST INTEGER G, CONST INTEGER B)
'************
' Initialize
'************
pX = 200
pY = 100
pakX = pX + 16
pakY = pY
pH = 30
mxpH = 30
eX(0) = 280
eY(0) = 100
eakX(0) = eX(0) + 16
eakY(0) = eY(0)
eH(0) = 3
mxeH(0) = 3
eX(1) = 100
eY(1) = 150
eakX(1) = eX(1) + 16
eakY(1) = eY(1)
eH(1) = 5
mxeH(1) = 5
'**********
' Settings
'**********
'Screen
'Palette
CALL set6A(&h01)
CALL setApal(0, &h00, &h00, &h00) '0
CALL setApal(1, &h03, &h05, &h05) '1
CALL setApal(2, &h0F, &h06, &h04) '4
CALL setApal(3, &h0C, &h0C, &h0C) '5
CALL setApal(4, &h02, &h09, &h02) '2
CALL setApal(5, &h0F, &h0A, &h06) '3
CALL setApal(6, &h09, &h04, &h01) '6
CALL setApal(7, &h00, &h06, &h00) '7
'************
' Main Codes
'************
'Opening
CLS 3
FOR i = 0 TO 2
TEXTCOLOR 18 + i
LOCATE 30, 8
PRINT "MICRO E-FOREST for PC-98"
LOCATE 35, 10
PRINT "EL_BASICˆÚA”Å"
SLEEP 1
NEXT
TEXTCOLOR 47
LOCATE 30, 18
PRINT "Press Any Key to Start."
'Create Character
size = 2
CALL createchar1(100,220,size)
CALL createchar1(200,220,size)
CALL createchar1(300,220,size)
CALL createchar1(320,220,size)
CALL createchar1(400,220,size)
CALL createchar1(100,240,size)
CALL createchar1(120,240,size)
CALL createchar1(140,240,size)
CALL createchar1(160,240,size)
CALL getchar1(100, 220, 100+size*8, 220+size*8)
FOR i=0 TO 255
SWAP c_buf(i), c_block(i)
NEXT
CALL getchar1(200, 220, 200+size*8, 220+size*8 )
FOR i=0 TO 255
SWAP c_buf(i), c_tree(i)
NEXT
CALL getchar1(300, 220, 300+size*8, 220+size*8 )
FOR i=0 TO 255
SWAP c_buf(i), c_player11(i)
NEXT
CALL getchar1(320, 220, 320+size*8, 220+size*8 )
FOR i=0 TO 255
SWAP c_buf(i), c_player12(i)
NEXT
CALL getchar1(400, 220, 400+size*8, 220+size*8 )
FOR i=0 TO 255
SWAP c_buf(i), c_erase(i)
NEXT
CALL getchar1(100, 240, 100+size*8, 240+size*8 )
FOR i=0 TO 255
SWAP c_buf(i), c_enemy11(i)
NEXT
CALL getchar1(120, 240, 120+size*8, 240+size*8 )
FOR i=0 TO 255
SWAP c_buf(i), c_enemy12(i)
NEXT
CALL getchar1(140, 240, 140+size*8, 240+size*8 )
FOR i=0 TO 255
SWAP c_buf(i), c_enemy21(i)
NEXT
CALL getchar1(160, 240, 160+size*8, 240+size*8 )
FOR i=0 TO 255
SWAP c_buf(i), c_enemy22(i)
NEXT
WHILE INKEY$ = "" WEND
CLS 3
'Create Map
FOR i=0 to 39
PUT (16*i,384), c_block, 0
NEXT
FOR i=0 to 18
PUT (624,368-16*i), c_block, 0
NEXT
FOR i=0 to 39
PUT (16*i,64), c_block, 0
NEXT
FOR i= 0 to 18
PUT (0,368-16*i), c_block, 0
NEXT
FOR i=0 to 29
tree_x = RND(592)+16
tree_y = RND(288)+80
PUT (tree_x,tree_y), c_tree, 0
NEXT
'Place Character
PUT (pX,pY), c_player11, 1
PUT (eX(0), eY(0)), c_enemy11, 1
PUT (eakX(0), eakY(0)), c_enemy12, 1
PUT (eX(1), eY(1)), c_enemy21, 1
PUT (eakX(1), eakY(1)), c_enemy22, 1
'Instruction
WHILE INKEY$ <> "" WEND
LOCATE 30, 8
PRINT "ãˆÚ“® : Key 8"
LOCATE 30, 9
PRINT "‰ºˆÚ“® : Key 2"
LOCATE 30, 10
PRINT "¶ˆÚ“® : Key 4"
LOCATE 30, 11
PRINT "‰EˆÚ“® : Key 6"
LOCATE 30, 12
PRINT "UŒ‚ : Key a"
SLEEP 1
WHILE INKEY$ = "" WEND
CLS 1
'Player Action
pK = ""
WHILE (pK <> "Q" AND pK <> "q")
pK = INKEY$
ppX = pX
ppY = pY
CALL calcpXY(pK, pX, pY, pakX, pakY)
IF (pX <> ppX or pY <> ppY) THEN
PUT (ppX,ppY), c_erase, 0
PUT (pX,pY), c_player11, 1
ENDIF
IF (pk = "A" OR pK = "a") THEN
PUT (pakX,pakY), c_player12, 0
FOR i=0 to 1
ept1 = POINT (eX(i), eY(i))
ept2 = POINT (eX(i)+15, eY(i))
ept3 = POINT (eX(i), eY(i)+15)
ept4 = POINT (eX(i)+15, eY(i)+15)
IF ept1 = 6 THEN
eH(i) = eH(i) - 1
ELSEIF ept2 = 6 THEN
eH(i) = eH(i) - 1
ELSEIF ept3 = 6 THEN
eH(i) = eH(i) - 1
ELSEIF ept4 = 6 THEN
eH(i) = eH(i) - 1
ENDIF
SLEEP 1
IF (eH(i) = 0) THEN
PUT (eX(i),eY(i)), c_erase, 0
PUT (eakX(i),eakY(i)), c_erase, 0
ENDIF
PUT (pakX,pakY), c_erase, 0
NEXT
ENDIF
'Enemy Action
FOR i=0 to 1
IF (pX <> ppX OR pY <> ppY) THEN
IF (eH(i) > 0) THEN
peX = eX(i)
peY = eY(i)
peakX = eakX(i)
peakY = eakY(i)
PUT (peakX,peakY), c_erase, 0
eX_buf = eX(i)
eY_buf = eY(i)
CALL calceXY(pX, pY, eX_buf, eY_buf)
eX(i) = eX_buf
eY(i) = eY_buf
IF (eX(i) <> peX OR eY(i) <> peY) THEN
PUT (peX,peY), c_erase, 0
IF (i = 0) THEN
PUT (eX(i),eY(i)), c_enemy11, 1
ELSEIF (i = 1) THEN
PUT (eX(i),eY(i)), c_enemy21, 1
ENDIF
ENDIF
eakS = (RND 4) - 1
IF (eakS = 0) THEN
eakX(i) = eX(i)
eakY(i) = eY(i)-16
ELSEIF (eakS = 1) THEN
eakX(i) = eX(i)
eakY(i) = eY(i)+16
ELSEIF (eakS = 2) THEN
eakX(i) = eX(i)-16
eakY(i) = eY(i)
ELSEIF (eakS = 3) THEN
eakX(i) = eX(i)+16
eakY(i) = eY(i)
ENDIF
IF (i = 0) THEN
PUT (eakX(i),eakY(i)), c_enemy12, 1
ELSEIF (i = 1) THEN
PUT (eakX(i),eakY(i)), c_enemy22, 1
ENDIF
IF POINT (pX, pY) = 3 THEN
pH = pH - 1
ELSEIF POINT (pX+15, pY) = 3 THEN
pH = pH - 1
ELSEIF POINT (pX, pY+15) = 3 THEN
pH = pH - 1
ELSEIF POINT (pX+15, pY+15) = 3 THEN
pH = pH - 1
ENDIF
ENDIF
ENDIF
NEXT
'Update Status
LOCATE 1, 1
PRINT "Player HP:"; pH; "/"; mxpH
LOCATE 19, 1
IF (eH(0) > 0) THEN
IF (ABS pX-eX(0) < 32) THEN
PRINT "Enemy1 HP:"; eH(0); "/"; mxeH(0)
ENDIF
ENDIF
LOCATE 19, 1
IF (eH(1) > 0) THEN
IF (ABS pX-eX(1) < 32) THEN
PRINT "Enemy2 HP:"; eH(1); "/"; mxeH(1)
ENDIF
ENDIF
IF (pH = 0) THEN
LOCATE 30,8
PRINT "Game Over!!"
SLEEP 1
WHILE INKEY$ <> "" WEND
LOCATE 30,18
PRINT "Press Any Key."
WHILE INKEY$ = "" WEND
pK = "q"
ENDIF
IF (eH(0) = 0 AND eH(1) = 0) THEN
LOCATE 30,8
PRINT "You saved the world!!"
SLEEP 1
WHILE INKEY$ <> "" WEND
LOCATE 30,18
PRINT "Press Any Key."
WHILE INKEY$ = "" WEND
pK = "q"
ENDIF
WEND
'Ending
CLS 3
CALL setApal(0, &h00, &h00, &h00)
CALL setApal(1, &h00, &h00, &h0F)
CALL setApal(2, &h0F, &h00, &h00)
CALL setApal(3, &h0F, &h00, &h0F)
CALL setApal(4, &h00, &h0F, &h00)
CALL setApal(5, &h00, &h0F, &h0F)
CALL setApal(6, &h0F, &h0F, &h00)
CALL setApal(7, &h0F, &h0F, &h0F)
END
'***************
' Subroutines
'***************
'Create Character
SUB createchar1(CONST INTEGER x1, CONST INTEGER y1, CONST INTEGER size)
STRING data_s
STRING c_s
INTEGER c_val
INTEGER i, j
FOR j = 0 TO 7
READ data_s
FOR i = 0 TO 7
c_s = "&h"+MID$(data_s, i+1, 1)
c_val = INT(VAL(c_s))
LINE (x1+size*i, y1+size*j)-(x1+size*(i+1), y1+size*(j+1)), c_val, BF
NEXT
NEXT
ENDSUB
'Get character
SUB getchar1(CONST INTEGER x1, CONST INTEGER y1, CONST INTEGER x2, CONST INTEGER y2)
INTEGER w
INTEGER h
w = x2-x1+1
h = y2-y1+1
'PRINT IMAGESIZE(x1,y1,x2-1,y2-1)
GET (x1,y1)-(x2-1,y2-1), c_buf
ENDSUB
'Calculate player coordinate
SUB calcpXY(REFERENCE STRING pK, REFERENCE INTEGER pX, REFERENCE INTEGER pY, REFERENCE INTEGER pakX, REFERENCE INTEGER pakY)
IF (pK = "8") THEN
IF (pY < 400) THEN
pY = pY - 8
pakX = pX
pakY = pY - 16
ENDIF
ELSEIF (pK = "2") THEN
IF (pY > 0) THEN
pY = pY + 8
pakX = pX
pakY = pY + 16
ENDIF
ELSEIF (pK = "4") THEN
IF (pX > 0) THEN
pX = pX - 8
pakX = pX - 16
pakY = pY
ENDIF
ELSEIF (pK = "6") THEN
IF (pX < 640) THEN
pX = pX + 8
pakX = pX + 16
pakY = pY
ENDIF
ENDIF
ENDSUB
'Calculate enemy coordinate
SUB calceXY(CONST INTEGER pX, CONST INTEGER pY, REFERENCE INTEGER eX, REFERENCE INTEGER eY)
IF (pX - eX > 0) THEN
eX = eX + 1
ELSEIF (pX - eX < 0) THEN
eX = eX - 1
ENDIF
IF (pY - eY > 0) THEN
eY = eY + 1
ELSEIF (pY - eY < 0) THEN
eY = eY - 1
ENDIF
ENDSUB
'Set Port 6Ah
SUB set6A(CONST INTEGER dat)
OUT &h006A, dat
ENDSUB
'Set Analog Pallet
SUB setApal(CONST INTEGER palN, CONST INTEGER R, CONST INTEGER G, CONST INTEGER B)
OUT &h00A8, palN
OUT &h00AA, G
OUT &h00AC, R
OUT &h00AE, B
ENDSUB
'*******
' Data
'*******
'Characters
'Block
DATA "60066666"
DATA "66660006"
DATA "60066666"
DATA "66666666"
DATA "60066666"
DATA "66660006"
DATA "60066666"
DATA "66666666"
'Tree
DATA "00222200"
DATA "02622620"
DATA "02622620"
DATA "02266220"
DATA "00766700"
DATA "00066000"
DATA "00066000"
DATA "00666600"
'Player Body
DATA "00111105"
DATA "01111116"
DATA "01033016"
DATA "55333356"
DATA "66111116"
DATA "66111113"
DATA "66111100"
DATA "00566500"
'Player Attack
DATA "66644666"
DATA "66644666"
DATA "46644664"
DATA "44466444"
DATA "44466444"
DATA "46644664"
DATA "66644666"
DATA "66644666"
'Erase
DATA "00000000"
DATA "00000000"
DATA "00000000"
DATA "00000000"
DATA "00000000"
DATA "00000000"
DATA "00000000"
DATA "00000000"
'Enemy1 Body
DATA "00003000"
DATA "30033303"
DATA "30033303"
DATA "30333303"
DATA "33733733"
DATA "03366330"
DATA "00333300"
DATA "00033000"
'Enemy1 Attack
DATA "34444443"
DATA "43444434"
DATA "44344344"
DATA "44433444"
DATA "44433444"
DATA "44344344"
DATA "43444434"
DATA "34444443"
'Enemy2 Body
DATA "00111100"
DATA "04400040"
DATA "04400040"
DATA "04000040"
DATA "00600600"
DATA "40066004"
DATA "41111114"
DATA "01144110"
'Enemy2 Attack
DATA "34444443"
DATA "43444434"
DATA "44344344"
DATA "44433444"
DATA "44433444"
DATA "44344344"
DATA "43444434"
DATA "34444443"