forked from fenok/pixelator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPixelator.3.0.txt
More file actions
2854 lines (2640 loc) · 71.9 KB
/
Pixelator.3.0.txt
File metadata and controls
2854 lines (2640 loc) · 71.9 KB
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
; _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
; | _ | | | \ \/ / | _ _| | | / \ |_ _ _ _| | _ | | _ |
; | |_| | | | \ / | |_ _ | | / _ \ | | | | | | | |_| |
; | _ _| | | / \ | _ _| | | / /_\ \ | | | | | | | _|
; | | | | / /\ \ | |_ _ | |_ _ / _ _ \ | | | |_| | | |\ \
; |_| |_| /_/ \_\ |_ _ _| |_ _ _| /_/ \_\ |_| |_ _ _| |_| \_\
; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
;
;PIXELATOR
;Per-pixel image editor
;By Fen-ok
;Version: 3.0
;Date: 27 July 2013
;---------------------
;CURRENT FEATURES:
;---------------------
;- GUI (where possible).
;- Fullscreen.
;- Per-pixel editing.
;- Up to 128 different editable symbols.
;- Foreground and background colors.
;- Border color.
;- Blinking.
;- Drawing lines.
;- Drawing ellipses (not perfect yet).
;- Changeable palette.
;- Disk support.
;- Compatible with PSI File Type (File Format) and PUS File System.
;- Contains documentation within itself.
;- Handmade numbers!
;---------------------
;CONTROLS:
;---------------------
;Controls (and description) can be viewed within the program.
;---------------------
;CHANGELOG FROM 2.1 TO 3.0:
;---------------------
;- GUI is added (where possible).
;- Controls are shown within the program now.
;- Palette can be changed now.
;- Disk support (saving, loading).
;- New symbol-drawing mode is added.
;- Default font can be viewed while drawing now.
;- An area can be made blinking now.
;- Border color can be changed now.
;- The background symbol can be changed now.
;- Holding buttons for drawing/erasing and applying colors is processed
; correctly now.
;- Behaviour while drawing line/ellipse is improved (correct reaction to
; holding buttons, changing colors, etc).
;- Some optimization.
;- Maybe some less important changes which I can't remember.
;---------------------
;KNOWN ISSUES
;---------------------
;- The algorithm of drawing ellipse doesn't work properly in a lot of
; cases. And it isn't going to be fixed due to tons of overflows I'm too
; lazy to deal with.
;- The "DISK" section potentially contain bugs, because it will be remade
; after implementing some real File System (in version 3.1.).
;- When you exit the program, it just reloads. It's ok and can be "fixed"
; by deleting the last (non-commentary) line of this code.
;---------------------
;LAST WORDS:
;---------------------
;I hope my english wasn't so bad. Enjoy.
;---------------------
;BRUTAL RUSSIAN JUNK CODE BELOW. KEEP OUT.
;---------------------
;//CLEARING MEMORY FROM PREVIOUS RUNS//
:memory_preparing
SET J, null_start
:null_loop
SET [J], 0x0
ADD J, 0x1
IFN J, null_end
SET PC, null_loop
SET [SPACEEXISTFLAG], 0x1
SET [FIGUREFCOLFLAG], 0x1
SET [FIGUREBCOLFLAG], 0x1
SET [BCOL], 0xf
SET [BORDERCOL], 0x7
;//GETTING DEVICES//
HWN J
:get_devices
SUB J, 0x1
HWQ J
IFE A, 0xf615
IFE B, 0x7349
SET [MONITOR], J
IFE A, 0x7406
IFE B, 0x30cf
SET [KEYBOARD], J
IFE A, 0x24c5
IFE B, 0x4fd5
SET [FLOPPY], J
IFN J, 0x0
SET PC, get_devices
;//INITIALIZING MONITOR//
:initialize_monitor
SET A, 0x0
SET B, SCREEN
HWI [MONITOR]
SET A, 0x1
SET B, FONT
HWI [MONITOR]
SET A, 0x5
SET B, DEFAULTPALETTE
HWI [MONITOR]
SET B, PALETTE
HWI [MONITOR]
SET A, 0x2
HWI [MONITOR]
;//INITIAL PREPARING FOR DRAWING//
:screen_preparing
SET J, 0x0
:prepare_screenmem
SET [SCREENMEM+J], 0xf00
ADD J, 0x1
IFN J, 0x180
SET PC, prepare_screenmem
SET [WORD0], 0x0
SET [WORD1], 0x0
SET X, 0x0; Pixel's coordinates inside symbol
SET Y, 0x0;
SET [IMEM], 0x0; Symbol's position on the screen
;//////////////////////////////////////////MAIN MENU/////
:main_menu
SET A, 0x1
SET B, FONT
HWI [MONITOR]
SET A, 0x2
SET B, 0x0
HWI [MONITOR]
SET A, 0x3
SET B, 0x0
HWI [MONITOR]
SET J, 0x0
:set_startscreen
SET [SCREEN+J], [STARTSCREEN+J]
ADD J, 0x1
IFN J, 0x180
SET PC, set_startscreen
SET J, 0x0
:set_startfont
SET [FONT+J], [STARTFONT+J]
ADD J, 0x1
IFN J, 0x100
SET PC, set_startfont
;/////////////
SET I, 0xa2
SET J, 0x2 ;green color
SHL J, 0x8
SET [SCREEN+I],J
;////////////
:wait_key_press_start
SET A, 0x1
HWI [KEYBOARD]
IFE C, 0x83 ; ->
JSR main_choice
IFE C, 0x82; <-
JSR main_choice
IFE C, 0x11
SET PC, choose_selection
IFE C, 0x1b
SET PC, exit_pixelator
SET PC, wait_key_press_start
:main_choice
SET J, 0x4 ;red color
SHL J, 0x8
SET [SCREEN+I],J
IFE C, 0x83
ADD I, 0x7
IFE C, 0x82
SUB I, 0x7
IFL I, 0xa2
ADD I, 0x1c
IFG I, 0xb7
SUB I, 0x1c
SET J, 0x2
SHL J, 0x8
SET [SCREEN+I], J
SET PC, POP
:choose_selection
IFE I, 0xa2
SET PC, begin_drawing
IFE I, 0xa9
SET PC, change_palette
IFE I, 0xb0
SET PC, disc
IFE I, 0xb7
SET PC, show_controls
SET PC, wait_key_press_start
;//////////////////////////////SHOWING CONTROLS/////
:show_controls
SET A, 0x1
SET B, 0x0
HWI [MONITOR]
SET A, 0x3
SET B, 0x7
HWI [MONITOR]
SET I, 0x0
:disc_clearscreen_cont
SET [SCREEN+I], 0xf20
ADD I, 0x1
IFN I, 0x180
SET PC, disc_clearscreen_cont
SET I, 0x0
:output_start_controls_loop
AND [SCREEN+I], 0xff00
BOR [SCREEN+I], [CONTROLSMSG+I]
ADD I, 0x1
IFN I, 0x180
SET PC, output_start_controls_loop
SET I, 0x0
:wait_key_press_controls
SET A, 0x1
HWI [KEYBOARD]
IFE C, 0x81;\/
JSR controls_choice_down
IFE C, 0x80; /\
JSR controls_choice_up
IFE C, 0x1b ;esc
SET PC, main_menu
IFE C, 0x0
SET PC, wait_key_press_controls
SET A, 0x0
HWI [KEYBOARD]
SET PC, wait_key_press_controls
:controls_choice_down
SET J, I
ADD J, 0x180
IFE [CONTROLSMSG+J], 0x0
SET PC, POP
ADD I, 0x20
JSR update_controls_output
SET PC, POP
:controls_choice_up
IFE I, 0x0
SET PC, POP
SUB I, 0x20
JSR update_controls_output
SET PC, POP
:update_controls_output
SET Z, 0x0
SET J, I
:update_controls_output_loop
AND [SCREEN+Z], 0xff00
BOR [SCREEN+Z], [CONTROLSMSG+J]
ADD Z, 0x1
ADD J, 0x1
IFN Z, 0x180
SET PC, update_controls_output_loop
SET PC, POP
;////////////////////////////////////////DISK/////
:disc
SET A, 0x1
SET B, 0x0
HWI [MONITOR]
SET A, 0x3
SET B, 0x7
HWI [MONITOR]
SET I, 0x0
:disc_clearscreen
SET [SCREEN+I], 0xf20
ADD I, 0x1
IFN I, 0x180
SET PC, disc_clearscreen
SET I, 0x0
:output_discstate_header
AND [SCREEN+I], 0xff00
BOR [SCREEN+I], [DISCSTATEHEADER+I]
ADD I, 0x1
IFN I, 0xc
SET PC, output_discstate_header
SET I, 0x20
SET J, 0x0
:output_discfs_header
AND [SCREEN+I], 0xff00
BOR [SCREEN+I], [DISCFSHEADER+J]
ADD I, 0x1
ADD J, 0x1
IFN J, 0xc
SET PC, output_discfs_header
SET I, 0x40
SET J, 0x0
:output_disc_header
AND [SCREEN+I], 0xff00
BOR [SCREEN+I], [DISCHEADER+J]
ADD I, 0x1
ADD J, 0x1
IFN J, 0x20
SET PC, output_disc_header
SET I, 0x140
SET J, 0x0
:output_disc_down
AND [SCREEN+I], 0xff00
BOR [SCREEN+I], [DISCDOWN+J]
ADD I, 0x1
ADD J, 0x1
IFN J, 0x20
SET PC, output_disc_down
SET [DISCSTATECODE], 0xa
SET [DISCFSCODE], 0x0
SET [DISCERRORCODE], 0x0
SET A, 0x0
IAQ A
SET A, disc_interrupt
IAS A
SET A, 0x1
SET X, 0x1
HWI [FLOPPY]
SET A, 0x1
INT A
;//////////////////////DISK: BUTTONS TRACKING////
:wait_key_press_disc
SET A, 0x1
HWI [KEYBOARD]
IFE C, [FORMAT]
JSR format_disc
IFE C, [INFO]
JSR disc_get_info
IFE C, [LOAD]
JSR disc_load
IFE C, [SAVE]
JSR disc_save
IFE C, 0x83 ; ->
JSR disc_choice_right
IFE C, 0x81;\/
JSR disc_choice_down
IFE C, 0x82; <-
JSR disc_choice_left
IFE C, 0x80; /\
JSR disc_choice_up
IFE C, 0x11
JSR disc_choose_selection
IFE C, 0x1b ;esc
SET PC, from_disc_to_main_menu
IFE C, 0x0
SET PC, wait_key_press_disc
SET A, 0x0
HWI [KEYBOARD]
SET PC, wait_key_press_disc
:from_disc_to_main_menu
SET A, 0x0
IAS A
SET A, 0x1
SET X, 0x0
HWI [FLOPPY]
SET PC, main_menu
;///////////////////FILE'S SAVING/////
:disc_save
IFN [DISCFSCODE], 0x1
SET PC, POP
JSR get_filename
SET [DISCMSGCODE], 0x3
JSR output_discmsg
SET [DISCBUF], 0xf00f
SET J, 0x1
SET [DISCBUF+J], 0x5034
ADD J, 0x1
SET Z, 0x0
:save_name_loop
SET [DISCBUF+J], [FILENAME+Z]
ADD J, 0x1
ADD Z, 0x1
IFN J, 0x11
SET PC, save_name_loop
SET Z, 0x0
:save_font_loop
SET [DISCBUF+J], [FONTMEMTWO+Z]
ADD J, 0x1
ADD Z, 0x1
IFN Z, 0x100
SET PC, save_font_loop
SET Z, 0x0
:save_palette_loop
SET [DISCBUF+J], [PALETTE+Z]
ADD J, 0x1
ADD Z, 0x1
IFN Z, 0x10
SET PC, save_palette_loop
SET [DISCBUF+J], [BORDERCOL]
ADD J, 0x1
SET Z, 0x0
:save_screen_loop
SET [DISCBUF+J], [SCREENMEM+Z]
ADD J, 0x1
ADD Z, 0x1
IFN Z, 0x180
SET PC, save_screen_loop
SET A, 0x3
SET X, 0x0
SET Y, DISCBUF
HWI [FLOPPY]
IFN B, 0x1
SET PC, saving_failed
:saving_wait
IFE [DISCSTATECODE], 0x3
SET PC, saving_wait
SET A, 0x3
SET X, 0x1
SET Y, DISCBUF1
HWI [FLOPPY]
IFN B, 0x1
SET PC, saving_failed
:saving_wait_two
IFE [DISCSTATECODE], 0x3
SET PC, saving_wait_two
IFN [DISCERRORCODE], 0
SET PC, saving_failed
SET [DISCMSGCODE], 0x0
JSR clear_discfs
JSR output_discmsg
SET PC, POP
:saving_failed
SET [DISCMSGCODE], 0x1
JSR output_discmsg
JSR output_discerror
SET PC, POP
;///////////////////FILE NAME INPUT//////
:get_filename
SET J, 0x0
:null_filename_loop
SET [FILENAME+J], 0x0
ADD J, 0x1
IFN J, 0xf
SET PC, null_filename_loop
SET [DISCMSGCODE], 0x6
JSR output_discmsg
SET Z, 0x16c
SET J, 0x0
AND [SCREEN+Z], 0xff00
BOR [SCREEN+Z], 0x5f
XOR [SCREEN+Z], 0x80
:wait_key_press_get_name
SET A, 0x1
HWI [KEYBOARD]
;//////tracking alphanumeric symbols, "_", ".". May have a use later
;IFG C, 0x2f
; IFL C, 0x3a
; JSR add_letter
;IFG C, 0x40
; IFL C, 0x5b
; JSR add_letter
;IFG C, 0x60
; IFL C, 0x7b
; JSR add_letter
;IFE C, 0x5f
; JSR add_letter
;IFE C, 0x2e
; JSR add_letter
;/////////////
IFG C, 0x1f
IFL C, 0x7f
JSR add_letter
IFE C, 0x10
JSR remove_letter
IFE C, 0x11
SET PC, POP
IFE C, 0x0
SET PC, wait_key_press_get_name
SET A, 0x0
HWI [KEYBOARD]
SET PC, wait_key_press_get_name
:add_letter
IFE J, 0xf
SET PC, POP
SET [FILENAME+J], C
AND [SCREEN+Z], 0xff00
BOR [SCREEN+Z], C
ADD J, 0x1
ADD Z, 0x1
AND [SCREEN+Z], 0xff00
BOR [SCREEN+Z], 0x5f
XOR [SCREEN+Z], 0x80
SET PC, POP
:remove_letter
IFE J, 0x0
SET PC, POP
SET [SCREEN+Z], 0xf20
SUB J, 0x1
SUB Z, 0x1
SET [FILENAME+J], 0x0
AND [SCREEN+Z], 0xff00
BOR [SCREEN+Z], 0x5f
XOR [SCREEN+Z], 0x80
SET PC, POP
;///////////////////FILE'S LOADING/////
:disc_load
IFN [DISCFSCODE], 0x1
SET PC, POP
SET [DISCMSGCODE], 0x2
JSR output_discmsg
SET A, 0x2
SET X, 0x1
SET Y, DISCBUF1
HWI [FLOPPY]
IFN B, 0x1
SET PC, loading_failed
:loading_wait
IFE [DISCSTATECODE], 0x3
SET PC, loading_wait
IFN [DISCERRORCODE], 0
SET PC, loading_failed
SET [DISCMSGCODE], 0x0
JSR output_discmsg
SET PC, cont_loading
:loading_failed
SET [DISCMSGCODE], 0x1
JSR output_discmsg
JSR output_discerror
SET PC, POP
:cont_loading
SET J, 0x1
IFN [DISCBUF+J], 0x5034
SET PC, POP
SET J, 0x11
SET Z, 0x0
:load_font_loop
SET [FONTMEMTWO+Z], [DISCBUF+J]
ADD Z, 0x1
ADD J, 0x1
IFN Z, 0x100
SET PC, load_font_loop
SET Z, 0x0
:load_palette_loop
SET [PALETTE+Z], [DISCBUF+J]
ADD Z, 0x1
ADD J, 0x1
IFN Z, 0x10
SET PC, load_palette_loop
SET [BORDERCOL], [DISCBUF+J]
ADD J, 0x1
SET Z, 0x0
:load_screen_loop
SET [SCREENMEM+Z], [DISCBUF+J]
ADD Z, 0x1
ADD J, 0x1
IFN Z, 0x180
SET PC, load_screen_loop
SET [XMEM], 0x0
SET [YMEM], 0x0
SET Z, 0x0
:null_fontmem_loop
SET [FONTMEM+Z], 0x0
ADD Z, 0x1
IFN Z, 0x80
SET PC, null_fontmem_loop
SET Z, 0x0
:find_fontmem_loop
SET J, [SCREENMEM+Z]
SHL J, 0x9
SHR J, 0x9
ADD [FONTMEM+J], 0x1
ADD Z, 0x1
IFN Z, 0x180
SET PC, find_fontmem_loop
SET Z, 0x1
:find_imem_loop_one
IFE [FONTMEM+Z], 0x0
SET PC, load_ok_one
ADD Z, 0x1
IFN Z, 0x80
SET PC, find_imem_loop_one
SET Z, 0x1
:find_imem_loop_two
IFE [FONTMEM+Z], 0x1
SET PC, load_ok_two
ADD Z, 0x1
IFN Z, 0x80
SET PC, find_imem_loop_two
SET [SMBMODEFLAG], 0x1
SET J, 0xffff
:find_imem_for_mode
ADD J, 0x1
SET Z, [SCREENMEM+J]
SHL Z, 0x9
SHR Z, 0x9
IFE Z, 0x0
SET PC, find_imem_for_mode
SET [IMEM], J
:load_end
SET PC, POP
:load_ok_one
SET [IMEM], 0x0
SET [SMBMODEFLAG], 0x0
SET PC, load_end
:load_ok_two
SET [IMEM], Z
SET J, 0xffff
:find_imem_loop_add
ADD J, 0x1
SET Z, [SCREENMEM+J]
SHL Z, 0x9
SHR Z, 0x9
IFN Z, [IMEM]
SET PC, find_imem_loop_add
SET [IMEM], J
SET [SMBMODEFLAG], 0x0
SET PC, load_end
;//////////////////////CHOOSING FILES, DIRECTORIES, ETC (for future)/////////
:disc_choice_right
SET PC, POP
:disc_choice_down
SET PC, POP
:disc_choice_left
SET PC, POP
:disc_choice_up
SET PC, POP
:disc_choose_selection
SET PC, POP
;/////////////////////////LOADING AND OUTPUT THE FILESYSTEM (without files-directories)/////
:get_and_output_discfs
SET A, 0x2
SET X, 0x0
SET Y, DISCBUF
HWI [FLOPPY]
IFN B, 0x1
SET PC, getting_discfs_failed
:getting_discfs_wait
IFE [DISCSTATECODE], 0x3
SET PC, getting_discfs_wait
IFN [DISCERRORCODE], 0
SET PC, getting_discfs_failed
SET [DISCMSGCODE], 0x0
JSR output_discmsg
IFE [DISCBUF], 0xf00f
SET [DISCFSCODE], 0x1
JSR output_discfs
SET PC, POP
:getting_discfs_failed
SET [DISCMSGCODE], 0x1
JSR output_discmsg
JSR output_discerror
SET PC, POP
;/////////////////////OUTPUTTING DISK MESSAGE///////////
:output_discmsg
SET Z, 0x16c
:null_error_output_loop
SET [SCREEN+Z], 0xf20
ADD Z, 0x1
IFN Z, 0x180
SET PC, null_error_output_loop
SET J, [DISCMSGCODE]
MUL J, 0xc
SET Z, 0x160
:output_discmsg_loop
AND [SCREEN+Z], 0xff00
BOR [SCREEN+Z], [DISCMSGSUCCESS+J]
ADD Z, 0x1
ADD J, 0x1
IFN Z, 0x16c
SET PC, output_discmsg_loop
SET PC, POP
;///////////////////OUTPUTTING DISK ERROR//////////
:output_discerror
SET J, [DISCERRORCODE]
MUL J, 0x14
SET Z, 0x16c
:output_discerror_loop
AND [SCREEN+Z], 0xff00
BOR [SCREEN+Z], [DISCERROR0+J]
ADD Z, 0x1
ADD J, 0x1
IFN Z, 0x180
SET PC, output_discerror_loop
SET [DISCERRORCODE], 0x0
SET PC, POP
;///////////////////OUTPUTTING THE FILESYSTEM (without files-directories)////
:output_discfs
SET J, [DISCFSCODE]
MUL J, 0x14
SET Z, 0x2c
:output_discfs_loop
AND [SCREEN+Z], 0xff00
BOR [SCREEN+Z], [DISCFS0+J]
ADD Z, 0x1
ADD J, 0x1
IFN Z, 0x40
SET PC, output_discfs_loop
SET PC, POP
;///////////////////OUTPUTTING DISK STATE//////
:output_discstate
SET J, [DISCSTATECODE]
MUL J, 0x14
SET Z, 0xc
:output_discstate_loop
AND [SCREEN+Z], 0xff00
BOR [SCREEN+Z], [DISCSTATE0+J]
ADD Z, 0x1
ADD J, 0x1
IFN Z, 0x20
SET PC, output_discstate_loop
SET PC, POP
;///////////////////HANDLING DISK INTERRUPT////
:disc_interrupt
IFN A, 0x1
SET PC, exit_interrupt
SET PUSH, C
SET PUSH, B
SET A, 0x0
HWI [FLOPPY]
IFN [DISCSTATECODE], B
JSR update_discstate
IFN C, 0x0
SET [DISCERRORCODE], C
:exit_interrupt
SET B, POP
SET C, POP
RFI A
:update_discstate
SET [DISCSTATECODE], B
JSR output_discstate
IFE B, 0x0
JSR clear_discfs
SET PC, POP
;//////////////////////DELETING THE FILESYSTEM FROM THE SCREEN (with files-directories)////
:clear_discfs
SET [DISCFSCODE], 0x0
SET Z, 0x2c
:clear_discfs_loop
SET [SCREEN+Z], 0xf20
ADD Z, 0x1
IFN Z, 0x40
SET PC, clear_discfs_loop
SET Z, 0x60
:clear_filenames_loop
SET [SCREEN+Z], 0xf20
ADD Z, 0x1
IFN Z, 0x140
SET PC, clear_filenames_loop
SET PC, POP
;////////////////////CLEARING DISK BUFFER/////
:clear_buf
SET J, 0x0
:clear_buf_loop
SET [DISCBUF+J], 0x0
ADD J, 0x1
IFN J, 0x200
SET PC, clear_buf_loop
SET PC, POP
;////////////////////DISK FORMATING/////////
:format_disc
SET [DISCMSGCODE], 0x4
JSR output_discmsg
JSR clear_discfs
JSR clear_buf
SET [DISCBUF], 0xf00f
SET A, 0x3
SET X, 0x0
SET Y, DISCBUF
HWI [FLOPPY]
IFN B, 0x1
SET PC, formatting_failed
:formatting_wait
IFE [DISCSTATECODE], 0x3
SET PC, formatting_wait
IFN [DISCERRORCODE], 0
SET PC, formatting_failed
SET [DISCMSGCODE], 0x0
JSR output_discmsg
SET PC, POP
:formatting_failed
SET [DISCMSGCODE], 0x1
JSR output_discmsg
JSR output_discerror
SET PC, POP
;///////////////////LOADING AND OUTPUT THE WHOLE FILE SYSTEM/////
:disc_get_info
SET [DISCMSGCODE], 0x5
JSR output_discmsg
JSR get_and_output_discfs
IFE [DISCFSCODE], 0x0
SET PC, POP
SET J, 0x1
IFN [DISCBUF+J], 0x5034
SET PC, POP
ADD J, 0x1
SET Z, 0x60
IFE [DISCBUF+J], 0x0
SET PC, POP
:output_names_loop
AND [SCREEN+Z], 0xff00
BOR [SCREEN+Z], [DISCBUF+J]
ADD Z, 0x1
ADD J, 0x1
IFE J, 0x11
SET PC, POP
IFN [DISCBUF+J], 0x0
SET PC, output_names_loop
SET PC, POP
;//////////////////////////////////PALETTE////////////
:change_palette
SET A, 0x2
SET B, PALETTE
HWI [MONITOR]
SET A, 0x3
SET B, 0x7
HWI [MONITOR]
SET J, 0x0
:load_palette_screen
SET [SCREEN+J], [PALETTESCREEN+J]
ADD J, 0x1
IFN J, 0x180
SET PC, load_palette_screen
SET J, 0x0
:load_palette_font
SET [FONT+J], [PALETTEFONT+J]
ADD J, 0x1
IFN J, 0x100
SET PC, load_palette_font
JSR null_key_symbols_red
JSR null_key_symbols_green
JSR null_key_symbols_blue
SET I, 0x0
SET [COUNTER0], 0x0
JSR palette_activate
;Different emulators behave differently, sometimes enter is triggered
;Clearing keyboard to avoid that
SET A, 0x0
HWI [KEYBOARD]
:wait_key_press_palette
SET A, 0x1
HWI [KEYBOARD]
IFE C, 0x83 ; ->
JSR palette_choice_right
IFE C, 0x81;\/
JSR palette_choice_down
IFE C, 0x82; <-
JSR palette_choice_left
IFE C, 0x80; /\
JSR palette_choice_up
IFE C, 0x11
SET PC, palette_choose_selection
IFE C, 0x1b ;esc
SET PC, main_menu
SET PC, wait_key_press_palette
:palette_activate
XOR [SCREEN+I], 0xf000
ADD I, 0x1
XOR [SCREEN+I], 0xf000
ADD I, 0x1
XOR [SCREEN+I], 0xf000
ADD I, 0x1
XOR [SCREEN+I], 0xf000
ADD I, 0x20
XOR [SCREEN+I], 0xf000
SUB I, 0x1
XOR [SCREEN+I], 0xf000
SUB I, 0x1
XOR [SCREEN+I], 0xf000
SUB I, 0x1
XOR [SCREEN+I], 0xf000
SUB I, 0x20
SET PC, POP
:palette_choice_right
JSR palette_activate
ADD I, 0x4
ADD [COUNTER0], 0x1
IFE I, 0x20
JSR p_c_r_correction_up
IFE I, 0x60
JSR p_c_r_correction_down
JSR palette_activate
SET PC, POP
:p_c_r_correction_up
SET I, 0x0
SET [COUNTER0], 0x0
SET PC, POP
:p_c_r_correction_down
SET I, 0x40
SET [COUNTER0], 0x8
SET PC, POP
:palette_choice_down
JSR palette_activate
ADD I, 0x40
ADD [COUNTER0], 0x8
IFG I, 0x5c
JSR p_c_d_correction
JSR palette_activate
SET PC, POP
:p_c_d_correction
SUB I, 0x80
SUB [COUNTER0], 0x10
SET PC, POP
:palette_choice_left
JSR palette_activate
SUB I, 0x4
SUB [COUNTER0], 0x1
IFG I, 0x5c
JSR p_c_l_correction_up
IFE I, 0x3c
JSR p_c_l_correction_down
JSR palette_activate
SET PC, POP
:p_c_l_correction_up
SET I, 0x1c
SET [COUNTER0], 0x7
SET PC, POP
:p_c_l_correction_down
SET I, 0x5c
SET [COUNTER0], 0xf
SET PC, POP
:palette_choice_up
JSR palette_activate
SUB I, 0x40
SUB [COUNTER0], 0x8
IFG I, 0x5c
JSR p_c_u_correction
JSR palette_activate
SET PC, POP
:p_c_u_correction
ADD I, 0x80
ADD [COUNTER0], 0x10
SET PC, POP
:null_key_symbols_red
SET Z, 0x38
:null_key_symbols_red_loop
SET [FONT+Z], 0x0
ADD Z, 0x1
IFN Z, 0x3c
SET PC, null_key_symbols_red_loop
SET PC, POP
:null_key_symbols_green
SET Z, 0x3c
:null_key_symbols_green_loop
SET [FONT+Z], 0x0
ADD Z, 0x1
IFN Z, 0x40
SET PC, null_key_symbols_green_loop