aboutsummaryrefslogtreecommitdiff
path: root/examples/minesweeper.s.orig
blob: 78d0d8a8725f51dc23119c3a7e685397d6be739c (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
;                         MINESWEEPER by RHY3756547
;
;                          My first DCPU-16 project
;               Feel free to fork and port for operating systems.
;                           Heavily commented. :>
;
;							Twitter: #RHY3756547

;                    ARROW KEYS to move, ENTER to select.
;                       F to toggle flag on location.

;            Upon winning or losing, press enter to start again.

JSR intro

SET A, tile0
SET B, 89
SET C, 0x8182
JSR storetiles
:restart
SET [gamestate], 0
SET [gametimer], 0
SET [game_started], 0
SET [old_select_x], 10
SET [old_select_y], 10
JSR clear_board
SET A, boardtiles_l1
SET B, 384
SET C, 0x8000
JSR drawtiles

SET A, minestext
SET B, 2
SET C, 0x8122
SET Y, 0x8F00
JSR drawtext
JSR draw_timer

JSR change_selection
SET PC, gameloop

:gametimer DAT 0
:timer_second_value DAT 575
:youwintext DAT 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055
:youlosetext DAT 0x004F, 0x0050, 0x0051, 0x0056, 0x0057, 0x0058, 0x0059
:logosmiley1 DAT 0x0000, 0xF014, 0xF015, 0xF016, 0xF017, 0x0000
:logosmiley2 DAT 0xF033, 0xF034, 0xF035, 0xF036, 0xF037, 0xF038
:logosmiley3 DAT 0x0000, 0xF039, 0xF03A, 0xF03B, 0xF03C, 0x0000
:logosmiley2g DAT 0xF033, 0xF018, 0xF05C, 0xF07C, 0xF01C, 0xF038

:blklogosmiley1 DAT 0xFF00, 0x0F14, 0x0F15, 0x0F16, 0x0F17, 0xFF00
:blklogosmiley2 DAT 0x0F33, 0x0F18, 0x0F5C, 0x0F7C, 0x0F1C, 0x0F38
:blklogosmiley3 DAT 0xFF00, 0x0F39, 0x0F3A, 0x0F3B, 0x0F3C, 0xFF00

:spectrum DAT 0x0001, 0x0009, 0x0003, 0x000B, 0x0003, 0x0009

:glasses1 DAT 0xF019, 0xF01A, 0xF01B, 0xF01C
:glasses2 DAT 0xF01D, 0xF01E, 0xF01F, 0xF03D
:glasses3 DAT 0xF03F, 0xF03F, 0xF03F, 0xF03F
:glasses4 DAT 0x0000, 0xF05F, 0xF07D, 0xF07E
:glasblank DAT 0x0000, 0x0000, 0x0000, 0x0000

:minewhitetop DAT 0xF000, 0xF001, 0xF002, 0xF003, 0xF004, 0xF005, 0xF006, 0xF007, 0xF008, 0xF009, 0xF00A, 0xF00B, 0xF00C, 0xF00D, 0xF00E, 0xF00F, 0xF010, 0xF011, 0xF012

:minewhitebtm DAT 0xF020, 0xF021, 0xF022, 0xF023, 0xF024, 0xF025, 0xF026 0xF027, 0xF028, 0xF029, 0xF02A, 0xF02B, 0xF02C, 0xF02D, 0xF02E, 0xF02F, 0xF030, 0xF031, 0xF032, 0xF032

:sweeperwhitetop DAT 0xF040, 0xF041, 0xF042, 0xF043, 0xF044, 0xF045, 0xF046, 0xF047, 0xF048, 0xF049, 0xF04A, 0xF04B, 0xF04C, 0xF04D, 0xF04E, 0xF04F, 0xF050, 0xF051, 0xF052, 0xF053, 0xF054, 0xF055, 0xF056, 0xF057, 0xF058, 0xF059, 0xF05A, 0xF05B

:sweeperwhitebtm DAT 0xF060, 0xF061, 0xF062, 0xF063, 0xF064, 0xF065, 0xF066 0xF067, 0xF068, 0xF069, 0xF06A, 0xF06B, 0xF06C, 0xF06D, 0xF06E, 0xF06F, 0xF070, 0xF071, 0xF072, 0xF073, 0xF074, 0xF075, 0xF076, 0xF077, 0xF078, 0xF079, 0xF07A, 0xF07B

:mines DAT 10 ;change to your liking
:minestext DAT 0x004E, 0x0045, 0x004E ;you should probably change this too

:intro
SET A, intro0
SET B, 128
SET C, 0x8180
JSR storetiles
SET I, 0
SET A, 0x8000

SET A, logosmiley1
SET B, 5
SET C, 0x808D
JSR drawtiles
SET A, logosmiley2
SET B, 5
SET C, 0x80AD
JSR drawtiles
SET A, logosmiley3
SET B, 5
SET C, 0x80CD
JSR drawtiles

SET I, 0

:glasses_fall_loop ;deal with it, limited memory

SET J, 0
:slowdown_anim
ADD J, 1
IFN J, 1000
	SET PC, slowdown_anim

SET B, 3
SET X, I
MOD X, 3 ;3 animation frames
SET C, 0x800E
SET Z, I
DIV Z, 3 ;y pos
MUL Z, 32
ADD C, Z

IFE X, 0
	SET A, glasses1
IFE X, 1
	SET A, glasses2
IFE X, 2
	SET A, glasses3
    
JSR drawtiles

SET A, glasblank
SUB C, 32
JSR drawtiles
    
IFE X, 2
	JSR glassesbottom

ADD I, 1

IFN I, 17
	SET PC, glasses_fall_loop
    
;draw white smiley
SET A, logosmiley1
SET B, 5
SET C, 0x808D
JSR drawtiles
SET A, logosmiley2g
SET B, 5
SET C, 0x80AD
JSR drawtiles
SET A, logosmiley3
SET B, 5
SET C, 0x80CD
JSR drawtiles    
;draw mine in white
SET A, minewhitetop
SET B, 18
SET C, 0x8046
JSR drawtiles
SET A, minewhitebtm	
SET B, 18
SET C, 0x8066
JSR drawtiles
;draw sweeper in white
SET A, sweeperwhitetop
SET B, 27
SET C, 0x80E2
JSR drawtiles
SET A, sweeperwhitebtm	
SET B, 27
SET C, 0x8102
JSR drawtiles

SET J, 0 ;wait for a bit
:wait_logo
ADD J, 1
IFN J, 1000
	SET PC, wait_logo
    
SET J, 0 ;wait for a bit
SET A, 0x8000
:white_screen
SET [A], 0xFF00
ADD J, 1
ADD A, 1
IFN J, 384
	SET PC, white_screen
   
    
;draw black smiley
SET A, blklogosmiley1
SET B, 5
SET C, 0x808D
JSR drawtiles
SET A, blklogosmiley2
SET B, 5
SET C, 0x80AD
JSR drawtiles
SET A, blklogosmiley3
SET B, 5
SET C, 0x80CD
JSR drawtiles  
    
SET J, 0 ;cycle for a bit
:cycle_logo
ADD J, 1

;draw mine in rainbow
SET A, minewhitetop
SET B, 18
SET C, 0x8046
JSR drawrainbow
SET A, minewhitebtm	
SET B, 18
SET C, 0x8066
JSR drawrainbow
;draw sweeper in rainbow
SET A, sweeperwhitetop
SET B, 27
SET C, 0x80E2
JSR drawrainbow
SET A, sweeperwhitebtm	
SET B, 27
SET C, 0x8102
JSR drawrainbow

IFN J, 66
	SET PC, cycle_logo ;just animate a few times as a kind of wait
    
SET PC, POP

:drawrainbow
SET PUSH, I
SET PUSH, C
SET I, 0
SET X, J
MOD X, 6 ;number of colours in spectrum

:drawrainbow_loop
SET [C], [A]
SHL [C], 8
SHR [C], 8
ADD [C], 0x0F00
SET Y, X
ADD Y, spectrum ;select colour from spectrum
SET Y, [Y]
SHL Y, 12
BOR [C], Y
ADD C, 1
ADD A, 1
ADD I, 1
ADD X, 1
MOD X, 6
IFG I, B
	SET PC, drawrainbow_end
SET PC, drawrainbow_loop

:drawrainbow_end
SET C, POP
SET I, POP
SET PC, POP

:glassesbottom
ADD C, 64
SET A, glasses4
JSR drawtiles
SET PC, POP

:clear_board
SET I, 0
SET J, board
SET Y, flag

:clearboard_loop
SET [J], 0
SET [Y], 0
ADD J, 1
ADD Y, 1
ADD I, 1
IFN I, 81
	SET PC, clearboard_loop
    
SET A, tiletypes_left ;reset mines too, shouldn't be visible
ADD A, 10
SET [A], 0x8701

SET A, tiletypes_right
ADD A, 10
SET [A], 0x8702
    
SET PC, POP

:drawtext ; Y is colour
SET PUSH, I
SET I, 0
SET PUSH, X

:drawtext_loop
SET X, [A]
BOR X, Y
SET [C], X
ADD C, 1
ADD A, 1
ADD I, 1
IFG I, B
	SET PC, drawtext_end
SET PC, drawtext_loop

:drawtext_end
SET X, POP
SET I, POP
SET PC, POP

:gamestate DAT 0 ;0 = normal, 1 = win, 2 = lose

:endgame

IFE [gamestate], 1
	SET A, youwintext
IFE [gamestate], 2
	SET A, youlosetext
SET B, 6
SET C, 0x816C
IFE [gamestate], 1
	SET Y, 0x9700
IFE [gamestate], 2
	SET Y, 0x4700
JSR drawtext

:endgame_loop

SET C, 0x9000
SET B, 0x0000
:buffloop2
	IFN [C], 0
    	SET B, [C]
	SET [C], 0
	ADD C, 1
	IFN C, 0x9010
	SET pc, buffloop2
    
IFE B, 0x000a
	SET PC, restart
    
SET [C], 0
SET C, 0x9000
    
SET PC, endgame_loop

;--------------------------------------------------------------------
;this is the gameloop
;it loops while the game is running
; :)
;--------------------------------------------------------------------

:gameloop
IFN [gamestate], 0 ;won or lost
	SET PC, endgame
ADD [timer], 1
IFE [game_started], 0 ;timer is non functional
	SET PC, skip_timer
    
SET A, [timer]
MOD A, [timer_second_value]
IFN A, 0
	SET PC, skip_timer
    
ADD [gametimer], 1
IFG [gametimer], 999
	SET [gametimer], 999
    
JSR draw_timer
    
:skip_timer
SET C, 0x9000
SET B, 0x0000
:buffloop
	IFN [C], 0
    	SET B, [C]
	SET [C], 0
	ADD C, 1
	IFN C, 0x9010
	SET pc, buffloop
    
SET A, 0
IFE B, 0x0025
	SET A, 2
IFE B, 0x0026
	SET A, 4
IFE B, 0x0027
	SET A, 1
IFE B, 0x0028
	SET A, 3
IFE B, 0x000a
    JSR action
IFE B, 0x0066 ;f to flag
    JSR flagspace

IFN A, 0
	JSR select_move
    
SET [C], 0

	
SET PC, gameloop

:select_move
IFE A, 1 ;right
	ADD [select_x], 1
IFE A, 2 ;left
	SUB [select_x], 1
IFE A, 3 ;down
	ADD [select_y], 1
IFE A, 4 ;up
	SUB [select_y], 1
IFG [select_x], 10
	SET [select_x], 0
IFG [select_y], 10
	SET [select_y], 0
IFG [select_x], 8
	SET [select_x], 8
IFG [select_y], 8
	SET [select_y], 8
        
JSR change_selection
SET PC, POP

:draw_timer
SET PUSH, A
SET PUSH, B
SET PUSH, C
SET A, 0x813B ;timer's positon on the screen

SET C, [gametimer]
DIV C, 100 ;to get NXX (n being this character)
MOD C, 10 ;get lowest int
SET B, 0x8F44
ADD B, C ;get tile pos
IFE C, 0
	SET B, 0x8F4E ;0
    
SET [A], B
ADD A, 1

SET C, [gametimer]
DIV C, 10 ;to get XNX (n being this character)
MOD C, 10 ;get lowest int
SET B, 0x8F44
ADD B, C ;get tile pos
IFE C, 0
	SET B, 0x8F4E ;0
    
SET [A], B
ADD A, 1

SET C, [gametimer]
MOD C, 10 ;get lowest int
SET B, 0x8F44
ADD B, C ;get tile pos
IFE C, 0
	SET B, 0x8F4E ;0
    
SET [A], B

SET C, POP
SET B, POP
SET A, POP
SET PC, POP

:flagspace
SET PUSH, A
SET A, [select_x]
SET B, [select_y]
MUL B, 9
ADD A, B
ADD A, flag ;move to flag memory
ADD [A], 1 ;change flag value
MOD [A], 2 ;can only be 0 or 1

JSR redraw_board

SET A, POP
SET PC, POP

:action
IFE [game_started], 0
	JSR, generate_board
    
SET [game_started], 1

SET PUSH, A
SET PUSH, C

SET A, [select_x]
SET B, [select_y]
SET X, A ;get normal position for mine seeking
SET Y, B ;^^^
MUL B, 9
ADD A, B
SET Z, A
ADD Z, flag ;move to flag memory
ADD A, board ;move to board memory

IFE [Z], 1 ;space is flagged
	SET PC, end_action ;yo don't do it bro

IFE [A], 0
	SET PC, mine_seek
IFE [A], 10
	JSR lose
    
:end_action

SET C, POP
SET A, POP
;SET J, POP ;j-pop is shit
SET PC, POP

:mine_seek
SET Z, 1
SET I, 0
SET J, surrounding_work
IFG [A], 0
	ADD I, 1
IFG 10, [A]
	ADD I, 1
IFG I, 1 ;within selected tile range
	SET PC, POP ;do nothing because the tile's already selected
    
SET PUSH, A
SET PUSH, B
SET PUSH, C
    
SET A, surprised_top
SET B, 3
SET C, 0x800E
JSR drawtiles

SET A, surprised_btm
SET B, 3
SET C, 0x802E
JSR drawtiles

SET C, POP
SET B, POP
SET A, POP

SET I, 0
JSR check_surroundings ;check the surroundings of the selected tile
IFE I, 0
	SET PC, skip_surrounding_loop ;if it's secluded don't do anything (or it'll like crash or something)

:mine_seek_loop ;oh god
JSR move_surrounding_table
SET J, surrounding_work
SET I, 0

:surrounding_process_loop
IFE [J], 0
	SET PC, skip_surrounding
SET Y, J
SUB Y, surrounding_work
SET A, Y
ADD A, board
DIV Y, 9 ;remove x
SET X, J
SUB X, surrounding_work
MOD X, 9 
JSR check_surroundings ;check the surroundings of the selected tile
:skip_surrounding
ADD J, 1
IFN [J], 2 ;end byte 2
	SET PC, surrounding_process_loop
    
IFN I, 0 ;if nothing was added to surrounding exit the loops
	SET PC mine_seek_loop

:skip_surrounding_loop

JSR redraw_board

SET A, norm_top
SET B, 3
SET C, 0x800E
JSR drawtiles

SET A, norm_btm
SET B, 3
SET C, 0x802E
JSR drawtiles

JSR wincheck

SET PC, end_action

:wincheck
SET A, board
SET I, 0

:wincheckloop
IFE [A], 0
	SET PC, POP
ADD I, 1
ADD A, 1
IFN I, 81
	SET PC, wincheckloop
SET [gamestate], 1 ;win is gamestate 1
SET PC, POP

:move_surrounding_table
SET A, surrounding_next
SET B, surrounding_work

:move_s_table_loop
SET [B], [A] ;just put it into the read table
SET [A], 0 ;simultaneously clearing the write table
ADD A, 1
ADD B, 1
IFN [A], 2 ;if it hasn't reached the end byte (2, how imaginative) then loop
	SET PC, move_s_table_loop
SET PC, POP

:redraw_board
SET X, 0
SET Y, 0
SET I, 0
SET A, board
SET Z, flag
SET PC, redraw_loop


:tiletypes_left DAT 0x8701, 0x7F1E, 0x7F21, 0x7F23, 0x7F25, 0x7F27, 0x7F29, 0x7F2B, 0x7F2D, 0x7F2F, 0x8701, 0x3B31


:tiletypes_right DAT 0x8702, 0x7F1F, 0x7F22, 0x7F24, 0x7F26, 0x7F28, 0x7F2A, 0x7F2C, 0x7F2E, 0x7F30, 0x8702, 0x3B32

:redraw_loop
SET B, X
SET C, Y
MUL B, 2
ADD B, 7 ;change board pos to screen pos
ADD C, 2
MUL C, 32
ADD B, C
ADD B, 0x8000 ;move to video ram

SET C, [A]

IFN [Z], 1 ;flagged
	SET PC, ingame_continue
    
SET J, tiletypes_left
ADD J, [A]

IFE [J], 0x8701 ;if hidden and flagged then show the flag
	SET C, 11
    
:ingame_continue
SET J, tiletypes_left
ADD J, C
SET [B], [J]
    
ADD B, 1

SET J, tiletypes_right
ADD J, C
SET [B], [J]

ADD I, 1
ADD X, 1
ADD A, 1
ADD Z, 1
IFG X, 8
	ADD Y, 1
IFG X, 8
	SET X, 0
IFG 81, I
	SET PC, redraw_loop ; loop until whole thing is done
    
JSR redefine_selection ; the selected tile may have changed   
JSR change_selection

ADD [moves], 1

SET PC, POP

:moves DAT 0

:redefine_selection
SET B, [select_x]
SET C, [select_y]
MUL B, 2
ADD B, 7 ;change board pos to screen pos
ADD C, 2
MUL C, 32
ADD B, C
ADD B, 0x8000 ;move to video ram
SET [old_select_tile1], [B]
ADD B, 1
SET [old_select_tile2], [B]
SET PC, POP

:check_surroundings ;i had to fix endless bugs with this
SET Z, 1

ADD X, 1 ;check right
ADD A, 1
	JSR checkblock
SUB Y, 1 ;check up-right
SUB A, 9
	JSR checkblock
SUB X, 1 ;check up
SUB A, 1
	JSR checkblock
SUB X, 1 ;check up-left
SUB A, 1
	JSR checkblock
ADD Y, 1 ;check left
ADD A, 9
	JSR checkblock
ADD Y, 1 ;check down-left
ADD A, 9
	JSR checkblock
ADD X, 1 ;check down
ADD A, 1
	JSR checkblock
ADD X, 1 ;check down-right
ADD A, 1
	JSR checkblock
SUB X, 1
SUB Y, 1
SUB A, 10 ;back to center
SET [A], Z ;set tile type
IFG 2, Z
	JSR countsurroundings ;if this isn't a number then every surrounding block becomes visible
SET PC, POP
    
:countsurroundings
ADD X, 1 ;check right
ADD A, 1
IFE [A], 0
	JSR add_to_surroundings
SUB Y, 1 ;check up-right
SUB A, 9
IFE [A], 0
	JSR add_to_surroundings
SUB X, 1 ;check up
SUB A, 1
IFE [A], 0
	JSR add_to_surroundings
SUB X, 1 ;check up-left
SUB A, 1
IFE [A], 0
	JSR add_to_surroundings
ADD Y, 1 ;check left
ADD A, 9
IFE [A], 0
	JSR add_to_surroundings
ADD Y, 1 ;check down-left
ADD A, 9
IFE [A], 0
	JSR add_to_surroundings
ADD X, 1 ;check down
ADD A, 1
IFE [A], 0
	JSR add_to_surroundings
ADD X, 1 ;check down-right
ADD A, 1
IFE [A], 0
	JSR add_to_surroundings
    
SET PC, POP

:add_to_surroundings
ADD I, 1
IFG X, 8 ;illegal block
	SET PC, POP
IFG Y, 8 ;illegal block
	SET PC, POP
SET B, A
SUB B, board
ADD B, surrounding_next ;change from board id into surroundings id
SET [B], 1 ;1 means active
SET PC, POP
    
:checkblock
IFG X, 8 ;illegal block
	SET PC, POP
IFG Y, 8 ;illegal block
	SET PC, POP
IFE [A], 10
	ADD Z, 1 ;increment block number
SET PC, POP

:lose
SET A, wtf_top
SET B, 3
SET C, 0x800E
JSR drawtiles

SET A, wtf_btm
SET B, 3
SET C, 0x802E
JSR drawtiles

SET A, tiletypes_left
ADD A, 10
SET [A], 0x4C33

SET A, tiletypes_right
ADD A, 10
SET [A], 0x4C34

JSR redraw_board

SET [gamestate], 2 ;2 is lose

SET PC, POP ;????


:generate_board
SET PUSH, A
SET PUSH, B
SET PUSH, C
SET PUSH, X
SET PUSH, I ;iterator
SET I, 0

:g_board_loop
ADD [timer], 1
SET A, [timer]
MUL A, A ;entropy
MOD A, 9 ;a is x of random mine placement
SET B, [timer]
ADD B, 317 ;b is y of mine placement, needs to be very different from A
MUL B, B
MOD B, 9

SET C, A ;check if in proximity to cursor, if yes then position again. x
SUB C, [select_x]
ADD C, 10 ;work around underflow
SET X, 0 ;used for checking and condition
IFG C, 8
	ADD X, 1
IFG 12, C
	ADD X, 1
    
SET C, B ;do it for the y placement too
SUB C, [select_y]
ADD C, 10 ;work around underflow
IFG C, 8
	ADD X, 1
IFG 12, C
	ADD X, 1
    
    
IFE X, 4
	SET PC g_board_loop
    
MUL B, 9
ADD A, B
SET C, board
ADD C, A
IFE [C], 10  ;defined at top
	SET PC g_board_loop ;already a mine there
SET [C], 10  
    
ADD I, 1
IFG [mines], I
	SET PC g_board_loop ;not enough mines
    
SET [timer], 0

SET I, POP
SET X, POP
SET C, POP
SET B, POP
SET A, POP
SET PC, POP

:old_select_operation
SET [A], [old_select_tile1]
ADD A, 1 ;and the other side
SET [A], [old_select_tile2]
SET PC, POP

:change_selection
SET PUSH, A ; x value
SET PUSH, B	; y value
SET A, [old_select_x]
SET B, [old_select_y]
JSR get_selection

IFN [old_select_x], 10 ;10 is the number which tells it not to do anything
	JSR old_select_operation

SET A, [select_x]
SET B, [select_y]
JSR get_selection

SET [old_select_tile1], [A]
SHL [A], 4 ;remove highest 2 bits
SHR [A], 4
BOR [A], 0x2A00
ADD A, 1 ;and the other side
SET [old_select_tile2], [A]
SHL [A], 4 ;remove highest 2 bits
SHR [A], 4	
BOR [A], 0x2A00

SET [old_select_x], [select_x]
SET [old_select_y], [select_y]

SET B, POP
SET A, POP
SET PC, POP

:get_selection
ADD B, 2
MUL A, 2
ADD A, 7 ;change x and y into screen position instead of game position
MUL B, 32 ;multiply y by screen width to get memory offset
ADD A, B ;the final offset moves into A
ADD A, 0x8000 ;now it's the memory address, wasn't that fun
SET PC, POP

:old_select_x DAT 10 ;doesn't exist
:old_select_y DAT 10 ;doesn't exist
:old_select_tile1 DAT 10 ;ok that does exist but you get the point
:old_select_tile2 DAT 10
:select_x DAT 4
:select_y DAT 4

:timer DAT 0
:game_started DAT 0

:flag DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0

:board DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 ;10 for mines, 0 for undiscovered, 1-9 for selected, 11 for flagged.

:surrounding_work DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 ;working table, reads from
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0, 2

:surrounding_next DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 ;next table, writes to
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0 
DAT 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 ;board of surrounding tiles because my last idea overflowed all the way into the graphics :@

:end
SET PC, end

:drawtiles
SET PUSH, I
SET PUSH, C
SET I, 0

:drawtiles_loop
SET [C], [A]
ADD C, 1
ADD A, 1
ADD I, 1
IFG I, B
	SET PC, drawtiles_end
SET PC, drawtiles_loop

:drawtiles_end
SET C, POP
SET I, POP
SET PC, POP

;tilemap data for the main map

:norm_top DAT 0x6F03, 0x6F04, 0x6F05, 0x6F06
:norm_btm DAT 0x6F07, 0x6F08, 0x6F09, 0x6F0A

:surprised_top DAT 0x6F35, 0x6F36, 0x6F37, 0x6F38
:surprised_btm DAT 0x6F39, 0x6F3A, 0x6F3B, 0x6F3C

:wtf_top DAT 0x6F3D, 0x6F3E, 0x6F3F, 0x6F40
:wtf_btm DAT 0x6F41, 0x6F42, 0x6F43, 0x6F44

:boardtiles_l1 DAT 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x6F03, 0x6F04, 0x6F05, 0x6F06, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720

:boardtiles_l2 DAT 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x70B, 0x711, 0x711, 0x711, 0x711, 0x711, 0x711, 0x711, 0x6F07, 0x6F08, 0x6F09, 0x6F0A, 0x711, 0x711, 0x711, 0x711, 0x711, 0x711, 0x711, 0x70C, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720

:boardtiles_l3 DAT 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x70F, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x710, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720 

:boardtiles_l4 DAT 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x70F, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x710, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720 

:boardtiles_l5 DAT 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x70F, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x710, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720 

:boardtiles_l6 DAT 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x70F, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x710, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720 

:boardtiles_l7 DAT 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x70F, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x710, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720 

:boardtiles_l8 DAT 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x70F, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x710, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720 

:boardtiles_l9 DAT 0x8720, 0x8713, 0x8714, 0x8715, 0x8716, 0x8717, 0x70F, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x710, 0x8718, 0x8719, 0x871A, 0x871B, 0x871C, 0x8720 

:boardtiles_20 DAT 0x8720, 0x871D, 0x8F20, 0x8F20, 0x8F20, 0x8710, 0x70F, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x710, 0x871D, 0x8F20, 0x8F20, 0x8F20, 0x8710, 0x8720 

:boardtiles_21 DAT 0x8720, 0x870D, 0x8712, 0x8712, 0x8712, 0x870E, 0x70F, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x8701, 0x8702, 0x710, 0x870D, 0x8712, 0x8712, 0x8712, 0x870E, 0x8720 

:boardtiles_22 DAT 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x70D, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x70E, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720

:boardtiles_22 DAT 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x70D, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x712, 0x70E, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720, 0x8720


; Tiles.

:tile0 DAT 0xff83, 0x45a9
:tile1 DAT 0x51b9, 0x7dff
:tile2 DAT 0xff01, 0x1c1
:tile3 DAT 0x7151, 0xc9c9
:tile4 DAT 0x49c9, 0xd171
:tile5 DAT 0xc101, 0x1ff
:tile6 DAT 0xff80, 0x8083
:tile7 DAT 0x8c89, 0x9292
:tile8 DAT 0x9290, 0x888c
:tile9 DAT 0x8380, 0x80ff
:tile10 DAT 0x0, 0x80
:tile11 DAT 0x8000, 0x0
:tile12 DAT 0x0, 0x1
:tile13 DAT 0x100, 0x0
:tile14 DAT 0x0, 0x55ff
:tile15 DAT 0xff00, 0x0
:tile16 DAT 0xc080, 0xc080
:tile17 DAT 0x101, 0x101
:tile18 DAT 0x3c, 0x888
:tile19 DAT 0xbc80, 0xbc80
:tile20 DAT 0xbc88, 0x90bc
:tile21 DAT 0x80bc, 0xaca4
:tile22 DAT 0x8028, 0x2414
:tile23 DAT 0x0, 0x84
:tile24 DAT 0xbc84, 0x80bc
:tile25 DAT 0x80bc, 0x8888
:tile26 DAT 0xbc80, 0xbcac
:tile27 DAT 0xa400, 0x0
:tile28 DAT 0x0, 0xff
:tile29 DAT 0xff01, 0x101
:tile30 DAT 0x101, 0x101
:tile31 DAT 0x0, 0x0
:tile32 DAT 0xff01, 0x149
:tile33 DAT 0x7d41, 0x101
:tile34 DAT 0xff01, 0x149
:tile35 DAT 0x6559, 0x101
:tile36 DAT 0xff01, 0x145
:tile37 DAT 0x5539, 0x101
:tile38 DAT 0xff01, 0x11d
:tile39 DAT 0x117d, 0x101
:tile40 DAT 0xff01, 0x15d
:tile41 DAT 0x5525, 0x101
:tile42 DAT 0xff01, 0x139
:tile43 DAT 0x5525, 0x101
:tile44 DAT 0xff01, 0x145
:tile45 DAT 0x350d, 0x101
:tile46 DAT 0xff01, 0x129
:tile47 DAT 0x5529, 0x101
:tile48 DAT 0xff83, 0x10d
:tile49 DAT 0xd7d, 0x183
:tile50 DAT 0xff01, 0x5539
:tile51 DAT 0x6d39, 0x5501
:tile52 DAT 0xff01, 0x1e1
:tile53 DAT 0x3131, 0xa969
:tile54 DAT 0x69a9, 0x7171
:tile55 DAT 0xa101, 0x1ff
:tile56 DAT 0xff80, 0x8083
:tile57 DAT 0x8c88, 0x9096
:tile58 DAT 0x9690, 0x888c
:tile59 DAT 0x8380, 0x80ff
:tile60 DAT 0xff01, 0x1c1
:tile61 DAT 0x3151, 0xc949
:tile62 DAT 0x2999, 0x1131
:tile63 DAT 0xc101, 0x1ff
:tile64 DAT 0xff80, 0x8083
:tile65 DAT 0xcc88, 0xd0de
:tile66 DAT 0x9ed0, 0xc8cc
:tile67 DAT 0x8380, 0x80ff
:tile68 DAT 0x48, 0x7c40
:tile69 DAT 0x48, 0x6458
:tile70 DAT 0x44, 0x5438
:tile71 DAT 0x1c, 0x107c
:tile72 DAT 0x5c, 0x5424
:tile73 DAT 0x38, 0x5424
:tile74 DAT 0x44, 0x340c
:tile75 DAT 0x28, 0x5428
:tile76 DAT 0x48, 0x5438
:tile77 DAT 0x38, 0x4438
:tile78 DAT 0x18, 0xe018
:tile79 DAT 0x60, 0x9060
:tile80 DAT 0x70, 0x80f0
:tile81 DAT 0x0, 0xf8
:tile82 DAT 0x8040, 0x80f8
:tile83 DAT 0xe8, 0xf0
:tile84 DAT 0x20e0, 0x0
:tile85 DAT 0xf8, 0x8080
:tile86 DAT 0x60, 0x9060
:tile87 DAT 0xb0, 0x90d0
:tile88 DAT 0xf0, 0x90b0

;1kb worth of tiles used for the intro sequence. worth it!


:intro0 DAT 0x0, 0x101
:intro1 DAT 0xc3eb, 0xebeb
:intro2 DAT 0xebea, 0xe8e0
:intro3 DAT 0xc000, 0x80e0
:intro4 DAT 0xe0e8, 0xeaeb
:intro5 DAT 0xebeb, 0xb01
:intro6 DAT 0x101, 0x0
:intro7 DAT 0x1, 0x1e1
:intro8 DAT 0xebeb, 0xebeb
:intro9 DAT 0xeb0b, 0x101
:intro10 DAT 0x100, 0x101
:intro11 DAT 0xc1eb, 0xebeb
:intro12 DAT 0xebea, 0xe8eb
:intro13 DAT 0xe3eb, 0x2b03
:intro14 DAT 0x101, 0x0
:intro15 DAT 0x101, 0xc1eb
:intro16 DAT 0xebeb, 0xebeb
:intro17 DAT 0xeb43, 0xc1c1
:intro18 DAT 0x303, 0xb00
:intro19 DAT 0x0, 0x0
:intro20 DAT 0xf0f0, 0x3030
:intro21 DAT 0xc0c, 0xc0c
:intro22 DAT 0xc0c, 0xc0c
:intro23 DAT 0x3030, 0xf0f0
:intro24 DAT 0x303, 0x3333
:intro25 DAT 0x303, 0x303
:intro26 DAT 0xf0f, 0xf0f
:intro27 DAT 0x303, 0xf0f
:intro28 DAT 0xf0f, 0x303
:intro29 DAT 0x1818, 0x1818
:intro30 DAT 0x7878, 0x7878
:intro31 DAT 0x1818, 0x7878
:intro32 DAT 0x4040, 0x6078
:intro33 DAT 0x7f61, 0x434f
:intro34 DAT 0x1f7f, 0x3f1f
:intro35 DAT 0x4f47, 0x417f
:intro36 DAT 0x7f7f, 0x7f7f
:intro37 DAT 0x7f6f, 0x4040
:intro38 DAT 0x0, 0x40
:intro39 DAT 0x4040, 0x787f
:intro40 DAT 0x7f7f, 0x7f7f
:intro41 DAT 0x4740, 0x4040
:intro42 DAT 0x40, 0x6070
:intro43 DAT 0x7f71, 0x6347
:intro44 DAT 0xf1f, 0x3f7f
:intro45 DAT 0x7f0f, 0x0
:intro46 DAT 0x0, 0x4040
:intro47 DAT 0x4060, 0x7f7f
:intro48 DAT 0x7f7f, 0x7f7f
:intro49 DAT 0x4340, 0x6073
:intro50 DAT 0x703c, 0x600
:intro51 DAT 0x0, 0xffff
:intro52 DAT 0x0, 0x3030
:intro53 DAT 0xc3c3, 0xc0c0
:intro54 DAT 0xc0c0, 0x303
:intro55 DAT 0x0, 0x0
:intro56 DAT 0xffff, 0x0
:intro57 DAT 0xf0f, 0xc0c
:intro58 DAT 0x3030, 0x3030
:intro59 DAT 0x3030, 0x3030
:intro60 DAT 0xc0c, 0xf0f
:intro61 DAT 0x7878, 0x1818
:intro62 DAT 0xc0c0, 0xc0c0
:intro63 DAT 0xc0c0, 0xc0c0
:intro64 DAT 0xc0d0, 0xd4d4
:intro65 DAT 0xd2d2, 0xc2c6
:intro66 DAT 0xc6d6, 0x601
:intro67 DAT 0x0, 0x216
:intro68 DAT 0xd6d6, 0xd6d6
:intro69 DAT 0xd6d2, 0x12d0
:intro70 DAT 0xd0d0, 0xd4d4
:intro71 DAT 0xd486, 0x284
:intro72 DAT 0x4416, 0x602
:intro73 DAT 0x2, 0x2d6
:intro74 DAT 0xd6d6, 0xd6d6
:intro75 DAT 0xd686, 0x8282
:intro76 DAT 0x616, 0x0
:intro77 DAT 0x2, 0x2d6
:intro78 DAT 0xd6d6, 0xd6d6
:intro79 DAT 0xd686, 0x8282
:intro80 DAT 0x616, 0x0
:intro81 DAT 0x2, 0x2d6
:intro82 DAT 0xd6d6, 0xd6d6
:intro83 DAT 0xd602, 0x2d6
:intro84 DAT 0xd400, 0x2
:intro85 DAT 0x2d6, 0xd6d6
:intro86 DAT 0xd6d6, 0xd686
:intro87 DAT 0x8282, 0x616
:intro88 DAT 0x0, 0x0
:intro89 DAT 0x202, 0xd6d6
:intro90 DAT 0xd6d6, 0xd6d6
:intro91 DAT 0x606, 0x8454
:intro92 DAT 0xcfcf, 0xcfcf
:intro93 DAT 0xc0c0, 0xc0c0
:intro94 DAT 0xc0c0, 0xc0c0
:intro95 DAT 0x303, 0x303
:intro96 DAT 0xfb67, 0xcf8f
:intro97 DAT 0x9f9f, 0x9f7f
:intro98 DAT 0x7f1f, 0x700
:intro99 DAT 0x0, 0x0
:intro100 DAT 0xf7f, 0xffff
:intro101 DAT 0x3f1f, 0xe03
:intro102 DAT 0xf3f, 0xff7f
:intro103 DAT 0x3f0f, 0x601
:intro104 DAT 0x0, 0x80
:intro105 DAT 0x8080, 0xf0ff
:intro106 DAT 0xffff, 0xffff
:intro107 DAT 0x87c0, 0xc3e7
:intro108 DAT 0xf00c, 0x80
:intro109 DAT 0x8080, 0xf0ff
:intro110 DAT 0xffff, 0xffff
:intro111 DAT 0x87c0, 0xc3e7
:intro112 DAT 0xf00c, 0x80
:intro113 DAT 0x80c0, 0xfeff
:intro114 DAT 0xffff, 0xffff
:intro115 DAT 0x8282, 0x301
:intro116 DAT 0x80, 0x8080
:intro117 DAT 0xf0ff, 0xffff
:intro118 DAT 0xffff, 0x87c0
:intro119 DAT 0xc3e7, 0xf00c
:intro120 DAT 0x0, 0x8080
:intro121 DAT 0xc0fe, 0xffff
:intro122 DAT 0xffff, 0xbf81
:intro123 DAT 0x83ff, 0xfffe
:intro124 DAT 0xc3c3, 0xf0f
:intro125 DAT 0x0, 0x303
:intro126 DAT 0x303, 0x0
:intro127 DAT 0x0, 0x0

	

:storetiles ;A = Data to Read, B = Length, C = Destination, I = Iterator
SET PUSH, I
MUL B, 2 ;2 words to a character
SET I, 0

:storetiles_loop
SET [C], [A]
ADD A, 1
ADD I, 1
ADD C, 1
IFE I, B
    SET PC, storetiles_end
SET PC, storetiles_loop

:storetiles_end
SET I, POP
SET PC, POP