-
Notifications
You must be signed in to change notification settings - Fork 0
/
EDITOR.asm
1659 lines (1475 loc) · 29.4 KB
/
EDITOR.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
; Copyright (C) 2006 Remy Glaser
;
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 3
; of the License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
; gpl-3.0.txt for more details.
;
.NOLIST
#define equ .equ
#define EQU .equ
#define END .end
.LIST
_CLRLCDFULL equ 4755h
_runIndicOff equ 4795h
_clrScrnFull equ 475Dh
_puts equ 470Dh
_CLOSEPROG equ 4E06h
_ZEROOP1 equ 428Eh
_putmap equ 4701h
_OP1TOOP5 equ 41BEh
_OP5TOOP1 equ 419Eh
__bank_ret equ 0000h
_ILINE equ 4AE4h
_getcsc equ 4014h
_GRBUFCPY equ 4B9Ch
_vputmap equ 477Dh
_cphlde equ 4004h
_divHLbyA equ 400Ch
_HTIMESL equ 4382h
_VPUTBLANK equ 4C53h
_SFONT_LEN equ 4A6Ch
_CHKFINDSYM equ 442Ah
_EDITPROG equ 4E02h
_GRBUFCLR equ 515Bh
_CREATEPROG equ 448Ah
_OP4TOOP1 equ 419Ah
_closeEditBuf equ 4C2Bh
_putc equ 4705h
_RSTRSHADOW equ 47A1h
_saveCmdShadow equ 4799h
_OP1TOOP6 equ 41BAh
_FindAlphaup equ 4E1Ah
_FindAlphadn equ 4E1Eh
_CLRTXTSHD equ 4765h
.org 9327h
call _CLRLCDFULL
call _runIndicOff
res 6, (iy+09h)
set 7, (iy+14h)
res 1, (iy+02h)
res 2, (iy+08h)
ld (0858Fh), sp
xor a
ld (iy+21h), a
set 1, (iy+21h)
ld hl, 08592h
ld b, 15h
Label1:
ld (hl), 00h
inc hl
djnz Label1
Label10:
call _clrScrnFull
ld hl, 00100h
ld (0800Ch), hl
ld hl, Str1
call _puts
ld hl, 0002h
ld (0800Ch), hl
ld hl, Str2
call _puts
ld hl, 0003h
ld (0800Ch), hl
ld hl, Str3
call _puts
ld hl, 0005h
ld (0800Ch), hl
ld hl, Str4
call _puts
bit 0, (iy+21h)
jp z, Label2
ld hl, 0004h
ld (0800Ch), hl
ld hl, Str5
call _puts
Label2:
call Label3
cp 0Fh
jp z, Label4
cp 22h
jp z, Label5
cp 1Ah
jp z, Label6
cp 23h
jp z, Label7
bit 0, (iy+21h)
jp z, Label2
cp 12h
jp z, Label8
jp Label2
Label6:
bit 1, (iy+21h)
call z, Label9
jp c, Label10
bit 0, (iy+21h)
call nz, _CLOSEPROG
call _ZEROOP1
ld a, 05h
ld (08039h), a
call Label11
jp c, Label12
Label85:
call _clrScrnFull
ld hl, 00200h
ld (0800Ch), hl
ld a, 05h
call _putmap
ld a, 0Dh
ld (0800Dh), a
ld a, 0CFh
call _putmap
call _OP1TOOP5
ld b, 08h
Label14:
ld h, 04h
ld a, 08h
sub b
ld l, a
ld (0800Ch), hl
ld hl, 0803Ah
call _puts
push bc
call Label11
pop bc
jp c, Label13
djnz Label14
Label13:
call Label3
cp 0Fh
jp z, Label10
cp 04h
jp z, Label15
cp 01h
jp z, Label16
cp 09h
jp nz, Label13
call _OP5TOOP1
Label87:
call Label17
Label54:
call Label18
ld hl, __bank_ret
ld (08252h), hl
Label26:
ld a, (08253h)
ld b, a
ld a, 3Fh
sub b
ld c, a
sub 05h
ld e, a
ld h, 02h
ld a, (08252h)
ld b, a
ld d, a
call _ILINE
ld b, 28h
res 2, (iy+12h)
Label25:
ld a, b
ld (08592h), a
ld b, 0FFh
Label24:
push af
pop af
call _getcsc
bit 4, (iy+09h)
jp nz, Label19
cp 01h
jp z, Label20
cp 02h
jp z, Label21
cp 03h
jp z, Label22
cp 04h
jp z, Label23
cp 0Fh
jp z, Label19
djnz Label24
ld a, (08592h)
ld b, a
djnz Label25
jp Label26
Label4:
bit 0, (iy+21h)
jp z, Label10
ld a, (085A1h)
ld (iy+05h), a
call _GRBUFCPY
jp Label26
Label79:
set 2, (iy+21h)
ret
Label23:
bit 2, (iy+21h)
jp nz, Label26
ld a, (08252h)
push af
call Label27
pop af
ld (08252h), a
ld hl, (0859Bh)
ld (0859Dh), hl
ld a, (iy+05h)
ld (085A2h), a
call Label28
jp c, Label29
ld b, 02h
Label33:
push bc
ld a, (hl)
cp 0D6h
jp z, Label30
cp 0FFh
jp z, Label31
call Label28
jp c, Label32
jp Label33
Label32:
pop bc
ld a, b
cp 02h
jp z, Label29
ld b, 00h
jp Label34
Label31:
pop bc
ld a, b
cp 02h
jp z, Label35
push bc
Label30:
pop bc
call Label28
jp c, Label32
djnz Label33
call Label36
ld a, (08252h)
and a
jp z, Label37
Label39:
call Label36
jp c, Label34
ld a, (hl)
cp 0D6h
jp z, Label34
cp 0FFh
jp z, Label34
call Label38
ld c, a
ld a, b
add a, c
ld b, a
push bc
ld a, 0FFh
sub b
ld b, a
ld a, (08252h)
add a, b
pop bc
jp nc, Label37
jp Label39
Label37:
ld a, b
ld (08252h), a
ld a, (08253h)
sub 06h
ld (08253h), a
call Label36
jp Label26
Label34:
ld a, b
ld (08252h), a
ld a, (08253h)
sub 06h
ld (08253h), a
jp Label26
Label20:
bit 2, (iy+21h)
jp nz, Label26
ld a, (08252h)
push af
call Label27
pop af
ld (08252h), a
ld hl, (0859Bh)
ld (0859Dh), hl
ld a, (iy+05h)
ld (085A2h), a
Label42:
ld a, (hl)
cp 0D6h
jp z, Label40
cp 0FFh
jp z, Label41
call Label36
jp nc, Label42
Label29:
ld hl, (0859Dh)
ld (0859Bh), hl
ld a, (085A2h)
ld (iy+05h), a
jp Label26
Label40:
ld b, 00h
ld a, (08252h)
and a
jp z, Label43
Label45:
call Label36
jp c, Label44
ld a, (hl)
cp 0D6h
jp z, Label44
cp 0FFh
jp z, Label44
call Label38
ld c, a
ld a, b
add a, c
ld b, a
push bc
ld a, 0FFh
sub b
ld b, a
ld a, (08252h)
add a, b
pop bc
jp nc, Label43
jp Label45
Label43:
ld a, b
ld (08252h), a
ld a, (08253h)
add a, 06h
ld (08253h), a
call Label36
jp Label26
Label44:
ld a, b
ld (08252h), a
ld a, (08253h)
add a, 06h
ld (08253h), a
jp Label26
Label21:
bit 2, (iy+21h)
jp nz, Label26
ld a, (08252h)
push af
call Label27
pop af
ld (08252h), a
call Label28
jp c, Label26
ld a, (hl)
cp 0D6h
jp z, Label46
cp 0FFh
jp z, Label35
call Label38
ld b, a
ld a, (08252h)
sub b
ld (08252h), a
jp Label26
Label35:
ld hl, (0859Bh)
push hl
ld a, (iy+05h)
push af
Label48:
call Label28
jp c, Label47
ld a, (hl)
cp 0FFh
jr nz, Label48
call Label36
Label47:
call Label18
pop af
pop hl
ld (0859Bh), hl
push hl
push af
xor a
ld (08252h), a
jp Label49
Label46:
pop af
ld a, (08253h)
sub 06h
ld (08253h), a
ld hl, (0859Bh)
push hl
ld a, (iy+05h)
push af
xor a
ld (08252h), a
Label49:
call Label28
jp c, Label50
ld a, (hl)
cp 0D6h
jp z, Label50
cp 0FFh
jp z, Label50
call Label38
ld b, a
ld a, (08252h)
add a, b
ld (08252h), a
jp Label49
Label50:
pop af
ld (iy+05h), a
pop hl
ld (0859Bh), hl
jp Label26
Label22:
bit 2, (iy+21h)
jp nz, Label26
call Label51
jp c, Label26
ld hl, (0859Bh)
ld a, (hl)
cp 0D6h
jr z, Label52
cp 0FFh
jp z, Label41
call _vputmap
call _GRBUFCPY
call Label36
jp Label26
Label52:
ld a, (08253h)
add a, 06h
cp 3Ch
jp z, Label26
push af
call Label53
call _GRBUFCPY
pop af
ld (08253h), a
xor a
ld (08252h), a
call Label36
jp Label26
Label41:
call Label36
jp Label54
Label19:
ld a, (iy+05h)
ld (085A1h), a
res 3, (iy+05h)
jp Label10
Label51:
set 0, (iy+23h)
jr Label55
Label36:
res 0, (iy+23h)
Label55:
ld hl, (0859Bh)
ld (0859Fh), hl
ld a, (iy+05h)
ld (085A1h), a
Label73:
call Label56
ret c
ld a, (hl)
cp 0F9h
jp z, Label57
cp 0FAh
jp z, Label58
cp 0FBh
jp z, Label59
cp 0FCh
jp z, Label60
cp 0FDh
jp z, Label61
bit 0, (iy+23h)
jp nz, Label62
jp Label63
set 0, (iy+23h)
jr Label64
Label28:
res 0, (iy+23h)
Label64:
ld hl, (0859Bh)
ld (0859Fh), hl
ld a, (iy+05h)
ld (085A1h), a
Label75:
call Label65
ret c
ld a, (hl)
cp 0F9h
jp z, Label66
cp 0FAh
jp z, Label67
cp 0FBh
jp z, Label68
cp 0FCh
jp z, Label69
cp 0FDh
jp z, Label70
bit 0, (iy+23h)
jp nz, Label62
Label63:
ld hl, (0859Fh)
ld (0859Bh), hl
ld a, (085A1h)
ld (iy+05h), a
jp Label62
Label56:
ld hl, (08096h)
ex de, hl
ld hl, (0859Fh)
inc hl
call _cphlde
jp z, Label71
ld (0859Fh), hl
jp Label62
Label65:
ld hl, (08094h)
ex de, hl
ld hl, (0859Fh)
dec hl
call _cphlde
jp z, Label71
ld (0859Fh), hl
jp Label62
Label57:
ld b, 03h
jp Label72
Label58:
ld b, 05h
Label72:
call Label56
ret c
djnz Label72
jp Label73
Label66:
ld b, 03h
jp Label74
Label67:
ld b, 05h
Label74:
call Label65
ret c
djnz Label74
jp Label75
Label59:
call Label57
ret c
ld a, (hl)
ld l, a
ld h, 00h
ld a, 08h
call _divHLbyA
push hl
call Label56
ret c
ld a, (hl)
pop hl
ld h, a
call _HTIMESL
ld de, __bank_ret
Label76:
exx
call Label56
ret c
exx
dec hl
call _cphlde
jp nz, Label76
jp Label57
Label68:
call Label65
ret c
ld a, (hl)
ld c, a
call Label65
ret c
ld a, (hl)
ld b, a
Label77:
call Label65
ret c
dec bc
ld d, b
ld e, c
ld hl, __bank_ret
call _cphlde
jr nz, Label77
jp Label67
Label60:
call Label56
ret c
ld a, (hl)
cp 0FCh
jp nz, Label60
jp Label73
Label69:
call Label65
ret c
ld a, (hl)
cp 0FCh
jp nz, Label69
jp Label75
Label61:
ld a, (085A1h)
xor 08h
ld (085A1h), a
jp Label73
Label70:
ld a, (085A1h)
xor 08h
ld (085A1h), a
jp Label75
Label27:
ld hl, (0859Bh)
ld a, (hl)
cp 0D6h
jp z, Label53
cp 0FFh
jp z, Label53
call _vputmap
jp Label78
Label53:
ld a, (iy+05h)
push af
res 3, (iy+05h)
call _VPUTBLANK
pop af
ld (iy+05h), a
Label78:
call _GRBUFCPY
ret
Label71:
scf
ld hl, (0859Bh)
ret
Label38:
exx
ld l, a
ld h, 08h
call _HTIMESL
call _SFONT_LEN
ld a, b
exx
ret
Label17:
res 2, (iy+21h)
set 1, (iy+21h)
set 0, (iy+21h)
call _CHKFINDSYM
ld a, (de)
ld l, a
inc de
ld a, (de)
ld h, a
push de
ld de, 0003h
call _cphlde
call z, Label79
pop de
ld b, 03h
Label80:
inc de
djnz Label80
ld a, (de)
ld (iy+22h), a
xor a
call _EDITPROG
ld hl, (08094h)
ld (0859Bh), hl
ex de, hl
call Label36
ret
Label18:
ld hl, __bank_ret
ld (08252h), hl
call _GRBUFCLR
ld hl, (0859Bh)
ld (0859Dh), hl
dec hl
ld (0859Bh), hl
ld a, (iy+05h)
ld (085A2h), a
Label83:
call Label36
jp c, Label81
ld a, (hl)
cp 0D6h
jp z, Label82
cp 0FFh
jp z, Label81
call _vputmap
jp Label83
Label82:
ld a, (08253h)
add a, 06h
cp 3Ch
jp z, Label81
ld (08253h), a
xor a
ld (08252h), a
jp Label83
Label81:
call _GRBUFCPY
ld hl, (0859Dh)
ld (0859Bh), hl
ld a, (085A2h)
ld (iy+05h), a
ret
Label15:
call _OP5TOOP1
call Label84
jp c, Label13
jp Label85
Label16:
call _OP5TOOP1
call Label11
jp c, Label13
jp Label85
Label12:
call _CLRLCDFULL
ld hl, 0001h
ld (0800Ch), hl
ld hl, Str6
call _puts
call Label3
jp Label10
Label5:
bit 1, (iy+21h)
call z, Label9
jp c, Label10
bit 0, (iy+21h)
call nz, _CLOSEPROG
call _ZEROOP1
xor a
ld (iy+22h), a
call Label86
ld hl, 0003h
call _CREATEPROG
ld (hl), 06h
inc de
inc de
ld a, 0D9h
ld (de), a
inc de
ld a, 3Fh
ld (de), a
inc de
ld a, (iy+22h)
ld (de), a
call _OP4TOOP1
jp Label87
Label9:
call _clrScrnFull
ld hl, __bank_ret
ld (0800Ch), hl
ld hl, Str7
call _puts
set 4, (iy+12h)
set 7, (iy+12h)
call Label3
cp 2Ch
jp z, Label88
cp 25h
jp z, Label89
cp 22h
jp z, Label89
scf
ret
Label89:
call _CLOSEPROG
res 0, (iy+21h)
jp Label62
Label8:
call _CLOSEPROG
call _CHKFINDSYM
ld a, (de)
ld l, a
inc de
ld a, (de)
ld h, a
inc de
push de
push hl
call Label86
pop hl
push hl
call _CREATEPROG
exx
call _OP4TOOP1
exx
ld (hl), 06h
inc de
inc de
pop bc
pop hl
ldir
call Label17
res 3, (iy+05h)
ld a, (iy+05h)
ld (085A1h), a
jp Label10
Label90:
inc de
djnz Label90
xor a
call _EDITPROG
jp Label10
Label88:
call _closeEditBuf
res 0, (iy+21h)
jp Label62
Label86:
call Label91
call _clrScrnFull
ld hl, 00100h
ld (0800Ch), hl
ld hl, Str8
call _puts
ld hl, 00102h
ld (0800Ch), hl
ld hl, Str9
call _puts
ld hl, 00203h
ld (0800Ch), hl
ld hl, Str10
call _puts
ld hl, 00204h
ld (0800Ch), hl
ld hl, Str11
call _puts
ld hl, 00205h
ld (0800Ch), hl
ld hl, Str12
call _puts
ld hl, 00206h
ld (0800Ch), hl
ld hl, Str13
call _puts
ld hl, 00107h
ld (0800Ch), hl
ld hl, Str14
call _puts
ld a, 02h
ld (08591h), a
ld hl, 0002h
ld (0800Ch), hl
ld a, 05h
call _putc
bit 7, (iy+22h)
call nz, Label92
bit 6, (iy+22h)
call nz, Label93
bit 5, (iy+22h)
call nz, Label94
bit 4, (iy+22h)
call nz, Label95
Label99:
ld a, (08591h)
cp 02h
jp z, Label96
call Label3
cp 04h
jp z, Label97
cp 01h
jp z, Label98
cp 09h
jp nz, Label99
ld a, (08591h)
cp 03h
jp z, Label100
cp 04h
jp z, Label101
cp 05h
jp z, Label102
cp 06h
jp z, Label103
cp 07h
jp nz, Label99
ld a, (0917Dh)
cp 20h
jp z, Label99
ld a, 06h
ld (08039h), a
call _CHKFINDSYM
call nc, Label104
ret