-
Notifications
You must be signed in to change notification settings - Fork 1
/
c64dvd-glsl.bas
4192 lines (3813 loc) · 255 KB
/
c64dvd-glsl.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
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
' c64.bas
/'
# Predication (computer architecture)
In computer science, predication is an architectural feature that provides an alternative to conditional transfer of control,
implemented by machine instructions such as conditional branch, conditional call, conditional return, and branch tables.
Predication works by executing instructions from both paths of the branch and only permitting those instructions from the taken
path to modify architectural state. The instructions from the taken path are permitted to modify architectural state because they
have been associated (predicate) with a predicate, a Boolean value used by the instruction to control whether the instruction is
allowed to modify the architectural state or not.
# Branch Predictor
In computer architecture, a branch predictor is a digital circuit that tries to guess which way a branch (e.g., an
if–then–else structure) will go before this is known definitively. The purpose of the branch predictor is to improve the
flow in the instruction pipeline. Branch predictors play a critical role in achieving high effective performance in many
modern pipelined microprocessor architectures such as x86.
# Cache prefetching
Cache prefetching is a technique used by computer processors to boost execution performance by fetching instructions or data
from their original storage in slower memory to a faster local memory before it is actually needed (hence the term 'prefetch').
Most modern computer processors have fast and local cache memory in which prefetched data is held until it is required. The
source for the prefetch operation is usually main memory. Because of their design, accessing cache memories is typically much
faster than accessing main memory, so prefetching data and then accessing it from caches is usually many orders of magnitude
faster than accessing it directly from main memory. Prefetching can be done with non-blocking cache control instructions.
'/
' Extended Memory Table 1
' Define SYSTEM_TYPE based on the operating system
#IF DEFINED(__FB_WIN32__)
#DEFINE SYSTEM_TYPE ULONGINT
#ELSEIF DEFINED(__FB_DOS__)
#DEFINE SYSTEM_TYPE ULONGINT
#ELSEIF DEFINED(__FB_CYGWIN__)
#DEFINE SYSTEM_TYPE ULONGINT
#ELSEIF DEFINED(__FB_PCOS__)
#DEFINE SYSTEM_TYPE ULONGINT
#ELSEIF DEFINED(__FB_UNIX__)
#DEFINE SYSTEM_TYPE DOUBLE
#ELSEIF DEFINED(__FB_LINUX__)
#DEFINE SYSTEM_TYPE DOUBLE
#ELSEIF DEFINED(__FB_FREEBSD__)
#DEFINE SYSTEM_TYPE DOUBLE
#ELSEIF DEFINED(__FB_NETBSD__)
#DEFINE SYSTEM_TYPE DOUBLE
#ELSEIF DEFINED(__FB_OPENBSD__)
#DEFINE SYSTEM_TYPE DOUBLE
#ELSEIF DEFINED(__FB_DARWIN__)
#DEFINE SYSTEM_TYPE DOUBLE
#ENDIF
' declare def poke64(byval adr as SYSTEM_TYPE, byval v as SYSTEM_TYPE)
' Zeropage addressing (0-255)
#define NUM_WAITING_KEYBOARD_ENTRIES_PTR &H00C6 ' (198) Number of waiting keyboard entries
#define REVERSE_PRINT_PTR &H00C7 ' (199) Reverse Print (0=Off)
' Enhanced Zeropage contains the stack (256-511)
' No specific definitions provided for this range
' Operating System and BASIC pointers (512-1023)
#define FG_COLOR_PTR &H0286 ' (646) Foreground Color
#define HI_BYTE_TEXT_SCREEN_ADDRESS_PTR &H0288 ' (648) High-byte of text screen address
#define A_REG_STORAGE_PTR &H030C ' (780) Storage Area for A Register
#define X_REG_STORAGE_PTR &H030D ' (781) Storage Area for X Register
#define Y_REG_STORAGE_PTR &H030E ' (782) Storage Area for Y Register
#define P_REG_STORAGE_PTR &H030F ' (783) Storage Area for P Register
' Function call pointers (32370-32375)
#define FUNC_CALL_1_PTR &H7E72 ' (32370)
#define FUNC_CALL_2_PTR &H7E73 ' (32371)
#define FUNC_CALL_3_PTR &H7E74 ' (32372)
#define FUNC_CALL_4_PTR &H7E75 ' (32373)
#define FUNC_CALL_5_PTR &H7E76 ' (32374)
#define FUNC_CALL_6_PTR &H7E77 ' (32375)
' Cartridge ROM (low) (32768-40959)
' No specific definitions provided for this range
' BASIC interpreter ROM or cartridge ROM (high) (40960-49151)
' No specific definitions provided for this range
' Free machine language program storage area (49152-53247)
#define PLAY_DVD_PTR &HC000 ' (49152) Play DVD
#define DISPLAY_DVD_MENU_PTR &HC001 ' (49153) Display DVD Menu
#define FG_RED_PTR &HC002 ' (49154) Foreground Red
#define FG_GREEN_PTR &HC003 ' (49155) Foreground Green
#define FG_BLUE_PTR &HC004 ' (49156) Foreground Blue
#define FG_ALPHA_PTR &HC005 ' (49157) Foreground Alpha
#define BG_RED_PTR &HC006 ' (49158) Background Red
#define BG_GREEN_PTR &HC007 ' (49159) Background Green
#define BG_BLUE_PTR &HC008 ' (49160) Background Blue
#define BG_ALPHA_PTR &HC009 ' (49161) Background Alpha
#define X0_PTR &HC00A ' (49162)
#define X0_1_PTR &HC00B ' (49163)
#define X0_2_PTR &HC00C ' (49164)
#define X0_3_PTR &HC00D ' (49165)
#define X0_4_PTR &HC00E ' (49166)
#define X0_5_PTR &HC00F ' (49167)
#define Y0_PTR &HC010 ' (49168)
#define Y0_1_PTR &HC011 ' (49169)
#define Y0_2_PTR &HC012 ' (49170)
#define Y0_3_PTR &HC013 ' (49171)
#define Y0_4_PTR &HC014 ' (49172)
#define Y0_5_PTR &HC015 ' (49173)
#define Z0_PTR &HC016 ' (49174)
#define Z0_1_PTR &HC017 ' (49175)
#define Z0_2_PTR &HC018 ' (49176)
#define Z0_3_PTR &HC019 ' (49177)
#define Z0_4_PTR &HC01A ' (49178)
#define Z0_5_PTR &HC01B ' (49179)
#define X1_LD_PTR &HC01C ' (49180) Loads all data from $C01D to $C021 into x1
#define X1_1_PTR &HC01D ' (49181)
#define X1_2_PTR &HC01E ' (49182)
#define X1_3_PTR &HC01F ' (49183)
#define X1_4_PTR &HC020 ' (49184)
#define X1_5_PTR &HC021 ' (49185)
#define LD_Y1_PTR &HC022 ' (49186) Loads all data from $C023 to $C027 into y1
#define Y1_1_PTR &HC023 ' (49187)
#define Y1_2_PTR &HC024 ' (49188)
#define Y1_3_PTR &HC025 ' (49189)
#define Y1_4_PTR &HC026 ' (49190)
#define Y1_5_PTR &HC027 ' (49191)
#define LD_Z1_PTR &HC028 ' (49192) Loads all data from $C029 to $C02D into z1
#define Z1_1_PTR &HC029 ' (49193)
#define Z1_2_PTR &HC02A ' (49194)
#define Z1_3_PTR &HC02B ' (49195)
#define Z1_4_PTR &HC02C ' (49196)
#define Z1_5_PTR &HC02D ' (49197)
#define LD_R0_PTR &HC02E ' (49198) Loads all data from $C02F to $C033 into r0
#define R0_1_PTR &HC02F ' (49199)
#define R0_2_PTR &HC030 ' (49200)
#define R0_3_PTR &HC031 ' (49201)
#define R0_4_PTR &HC032 ' (49202)
#define R0_5_PTR &HC033 ' (49203)
#define LD_R1_PTR &HC034 ' (49204) Loads all data from $C035 to $C039 into r1
#define R1_1_PTR &HC035 ' (49205)
#define R1_2_PTR &HC036 ' (49206)
#define R1_3_PTR &HC037 ' (49207)
#define R1_4_PTR &HC038 ' (49208)
#define R1_5_PTR &HC039 ' (49209)
#define LD_R2_PTR &HC03A ' (49210) Loads all data from $C03B to $C03F into r2
#define R2_1_PTR &HC03B ' (49211)
#define R2_2_PTR &HC03C ' (49313)
#define R2_3_PTR &HC03D ' (49314)
#define R2_4_PTR &HC03E ' (49315)
#define R2_5_PTR &HC03F ' (49316)
#define LD_R3_PTR &HC040 ' (49216) Loads all data from $C041 to $C046 into r3
#define R3_1_PTR &HC041 ' (49217)
#define R3_2_PTR &HC042 ' (49218)
#define R3_3_PTR &HC043 ' (49219)
#define R3_4_PTR &HC044 ' (49220)
#define R3_5_PTR &HC045 ' (49221)
#define LD_R4_PTR &HC047 ' (49223) Loads all data from $C048 to $C04C into r4
#define R4_1_PTR &HC048 ' (49224)
#define R4_2_PTR &HC049 ' (49225)
#define R4_3_PTR &HC04A ' (49226)
#define R4_4_PTR &HC04B ' (49227)
#define R4_5_PTR &HC04C ' (49228)
#define LD_R5_PTR &HC04B ' (49227) Loads all data from $C04D to $C051 into r5
#define R5_1_PTR &HC04D ' (49229)
#define R5_2_PTR &HC04E ' (49230)
#define R5_3_PTR &HC04F ' (49231)
#define R5_4_PTR &HC050 ' (49232)
#define R5_5_PTR &HC051 ' (49233)
#define LD_R6_PTR &HC052 ' (49234) Loads all data from $C053 to $C057 into r6
#define R6_1_PTR &HC053 ' (49235)
#define R6_2_PTR &HC054 ' (49236)
#define R6_3_PTR &HC055 ' (49237)
#define R6_4_PTR &HC056 ' (49238)
#define R6_5_PTR &HC057 ' (49239)
#define LD_R7_PTR &HC058 ' (49240) Loads all data from $C059 to $C05D into r7
#define R7_1_PTR &HC059 ' (49241)
#define R7_2_PTR &HC05A ' (49242)
#define R7_3_PTR &HC05B ' (49243)
#define R7_4_PTR &HC05C ' (49244)
#define R7_5_PTR &HC05D ' (49245)
#define LD_R8_PTR &HC05E ' (49246) Loads all data from $C05F to $C063 into r8
#define R8_1_PTR &HC05F ' (49247)
#define R8_2_PTR &HC060 ' (49248)
#define R8_3_PTR &HC061 ' (49249)
#define R8_4_PTR &HC062 ' (49250)
#define R8_5_PTR &HC063 ' (49251)
#define LD_R9_PTR &HC064 ' (49252) Loads all data from $C065 to $C069 into r9
#define R9_1_PTR &HC065 ' (49253)
#define R9_2_PTR &HC066 ' (49254)
#define R9_3_PTR &HC067 ' (49255)
#define R9_4_PTR &HC068 ' (49256)
#define R9_5_PTR &HC069 ' (49257)
#define LD_R10_PTR &HC06A ' (49258) Loads all data from $C06B to $C06F into r10
#define R10_1_PTR &HC06B ' (49259)
#define R10_2_PTR &HC06C ' (49260)
#define R10_3_PTR &HC06D ' (49261)
#define R10_4_PTR &HC06E ' (49262)
#define R10_5_PTR &HC06F ' (49263)
#define LD_R11_PTR &HC070 ' (49264) Loads all data from $C071 to $C075 into r11
#define R11_1_PTR &HC071 ' (49265)
#define R11_2_PTR &HC072 ' (49266)
#define R11_3_PTR &HC073 ' (49267)
#define R11_4_PTR &HC074 ' (49268)
#define R11_5_PTR &HC075 ' (49269)
#define LD_ROT0_PTR &HC076 ' (49270) Loads all data from $C077 to $C07B into rot0
#define ROT0_1_PTR &HC077 ' (49271)
#define ROT0_2_PTR &HC078 ' (49272)
#define ROT0_3_PTR &HC079 ' (49273)
#define ROT0_4_PTR &HC07A ' (49274)
#define ROT0_5_PTR &HC07B ' (49275)
#define LD_ROT1_PTR &HC07C ' (49276) Loads all data from $C07D to $C081 into rot1
#define ROT1_1_PTR &HC07D ' (49277)
#define ROT1_2_PTR &HC07E ' (49278)
#define ROT1_3_PTR &HC07F ' (49279)
#define ROT1_4_PTR &HC080 ' (49280)
#define ROT1_5_PTR &HC081 ' (49281)
#define LD_ROT2_PTR &HC082 ' (49282) Loads all data from $C083 to $C087 into rot2
#define ROT2_1_PTR &HC083 ' (49283)
#define ROT2_2_PTR &HC084 ' (49284)
#define ROT2_3_PTR &HC085 ' (49285)
#define ROT2_4_PTR &HC086 ' (49286)
#define ROT2_5_PTR &HC087 ' (49287)
#define LD_ROT3_PTR &HC088 ' (49288) Loads all data from $C089 to $C08D into rot3
#define ROT3_1_PTR &HC089 ' (49289)
#define ROT3_2_PTR &HC08A ' (49290)
#define ROT3_3_PTR &HC08B ' (49291)
#define ROT3_4_PTR &HC08C ' (49292)
#define ROT3_5_PTR &HC08D ' (49293)
#define LD_ROT4_PTR &HC08E ' (49294) Loads all data from $C08F to $C093 into rot4
#define ROT4_1_PTR &HC08F ' (49295)
#define ROT4_2_PTR &HC090 ' (49296)
#define ROT4_3_PTR &HC091 ' (49297)
#define ROT4_4_PTR &HC092 ' (49298)
#define ROT4_5_PTR &HC093 ' (49299)
#define LD_SCRO_X_ROT5_PTR &HC094 ' (49300) Loads all data from $C095 to $C099 into rot5
#define SCRO_X_ROT5_1_PTR &HC095 ' (49301)
#define SCRO_X_ROT5_2_PTR &HC096 ' (49302)
#define SCRO_X_ROT5_3_PTR &HC097 ' (49303)
#define SCRO_X_ROT5_4_PTR &HC098 ' (49304)
#define SCRO_X_ROT5_5_PTR &HC099 ' (49305)
#define LD_SCRO_Y_ROT6_PTR &HC09A ' (49306) Loads all data from $C09B to $C09F into rot6
#define SCRO_Y_ROT6_1_PTR &HC09B ' (49307)
#define SCRO_Y_ROT6_2_PTR &HC09C ' (49308)
#define SCRO_Y_ROT6_3_PTR &HC09D ' (49309)
#define SCRO_Y_ROT6_4_PTR &HC09E ' (49310)
#define SCRO_Y_ROT6_5_PTR &HC09F ' (49311)
#define SET_SCREEN_RESOLUTION_PTR &HC0A0 ' (49312) r8 sets screen width, r9 sets screen height
' GLSL/OS and keyword database functions
#define EXEC_GLSL_OS_PTR &HC0A1 ' (49313) Execute GLSL/OS, keyword database
' 0 - Compile and execute GLSL
' 1 - Opens POV-Ray device
' 2 - Closes POV-Ray device
' 3 - Render using POV-Ray
' 4 - Sets offset in video memory using r8
' 5 - Animation player (r8 sets first frame, r9 sets last frame)
' 6-22 - Keyword Database uses r10 as selector
#define LANG_TERM_SELECTOR_PTR &HC0A2 ' (49314) Language/Terminal Selector
' 0 - Blender terminal
' 1 - COBOL terminal
' 2 - POV-Ray terminal
' 3 - FreeBASIC terminal
' 4 - FreeBASIC QB terminal
' 5 - GLSL terminal
' 6 - COBOL compiler
' 7 - Fortran compiler
' 8 - Pascal compiler
' 9 - OSL compiler
' 10 - POV-Ray compiler
' 11 - Java compiler
' 12 - C compiler
' 13 - C++ compiler
' 14 - C# compiler
' 15 - JavaScript compiler
' 16 - PHP compiler
' 17 - Python compiler
' 18 - Swift compiler
' 19 - Octave compiler
' 20 - Kotlin compiler
' 21 - R compiler
' 22 - Dart compiler
' 23 - Scala compiler
' 24 - Open File
' 25 - Close File
' 26 - Compile and execute program
' 27 - 90 column text editor
#define LOAD_COMPILE_GLSL_PTR &HC0A3 ' (49315) Load and compile tmp.glsl
' Mouse driver and related functions
#define MOUSE_LOCATION_STATUS_PTR &HC0AA ' (49322) Mouse driver return address
' Mouse screen location is returned to x0 and y0
' Wheel status is returned to z0
' Button status is returned to x1
#define PCOPY_PAGE_PTR &HC0AB ' (49323) PCOPY from page x0 to page y0
' Foreground and background color pointers
'#define FG_COLOR_PTR &HC0C9 ' (49353) Loads all data from $C002 to $C005 into fg_color
#define BG_COLOR_PTR &HC0CA ' (49354) Loads all data from $C006 to $C009 into bg_color
#define LD_X0_PTR &HC0CB ' (49355) Loads all data from $C00B to $C00F into x0
#define LD_Y0_PTR &HC0CC ' (49356) Loads all data from $C011 to $C015 into y0
#define LD_Z0_PTR &HC0CD ' (49357) Loads all data from $C017 to $C01B into z0
' Additional registers
'#define X0_PTR &HC0CB ' (49355)
'#define Y0_PTR &HC0CC ' (49356)
'#define Z0_PTR &HC0CD ' (49357)
#define X1_PTR &HC0CE ' (49358)
#define Y2_PTR &HC0CF ' (49359)
#define Z2_PTR &HC0D0 ' (49360)
#define R0_PTR &HC0D1 ' (49361)
#define R1_PTR &HC0D2 ' (49362)
#define R2_PTR &HC0D3 ' (49363)
#define R3_PTR &HC0D4 ' (49364)
#define R4_PTR &HC0D5 ' (49365)
#define R5_PTR &HC0D6 ' (49366)
#define R6_PTR &HC0D7 ' (49367)
#define R7_PTR &HC0D8 ' (49368)
#define R8_PTR &HC0D9 ' (49369)
#define R9_PTR &HC0DA ' (49370)
#define R10_PTR &HC0DB ' (49371)
#define R11_PTR &HC0DD ' (49372)
#define ROT0_PTR &HC0DE ' (49373)
#define ROT1_PTR &HC0DF ' (49374)
#define ROT2_PTR &HC0E0 ' (49375)
#define ROT3_PTR &HC0E1 ' (49377)
#define ROT4_PTR &HC0E2 ' (49378)
#define SCRO_X_ROT5_PTR &HC0E3 ' (49379)
#define SCRO_Y_ROT6_PTR &HC0E4 ' (49380)
#define LOAD_MONOCHROME_FONT_PTR &HC0E6 ' (49382) Loads Monochrome 8x8 font
#define FONT_FLIP_PTR &HC0E7 ' (49383) Font Flip
#define FONT_OFFSET_PTR &HC0E8 ' (49384) Font Offset
#define FONT_WIDTH_PTR &HC0E9 ' (49385) Font Width
#define FONT_HEIGHT_PTR &HC0EA ' (49386) Font Height
#define HAM_FG_COLOR_PTR &HC0EB ' (49387) Amiga style Hold-and-Modify (Foreground color)
#define HAM_BORDER_COLOR_PTR &HC0EC ' (49388) Amiga style Hold-and-Modify (Border color)
#define HAM_BG_COLOR_PTR &HC0ED ' (49389) Amiga style Hold-and-Modify (Background color)
#define HAM_DRAW_FILLED_BOX_FG_PTR &HC0EE ' (49390) Amiga style Hold-and-Modify (Draw filled box using x0, y0, x1, y1, FG)
#define HAM_DRAW_FILLED_BOX_BG_PTR &HC0EF ' (49391) Amiga style Hold-and-Modify (Draw filled box using x0, y0, x1, y1, BG)
#define CHAIN_COMMAND_PTR &HC0F0 ' (49392) CHAIN command uses strCode
#define EXEC_MS_WINDOWS_PROGRAM_PTR &HC0F1 ' (49393) Execute MS-Windows program uses strCode
#define EXEC_MS_DOS_PROGRAM_PTR &HC0F2 ' (49394) Execute MS-DOS program uses strCode
#define OPEN_INTEL_ASM_FILE_PTR &HC0F3 ' (49395) Open Intel Assembly Language File uses strCode
#define WRITE_INTEL_ASM_FILE_PTR &HC0F4 ' (49396) Write to Intel ASM file uses strCode
#define EXEC_NASM_ASSEMBLER_PTR &HC0F6 ' (49398) Execute NASM assembler uses strCode
#define EXEC_EXTERNAL_BOOT_SECTOR_PTR &HC0F7 ' (49399) Execute external boot sector uses strCode
#define SHELL_COMMAND_PTR &HC0F8 ' (49400) SHELL command uses strCode
#define SWCH_PTR &HC0F9 ' (49401)
#define ADD_BYTE_TO_STR_CODE_PTR &HC0FA ' (49402) Add BYTE to strCode
#define WRITE_STR_CODE_TO_FILE_PTR &HC0FB ' (49403) Write strCode to file
#define PRINT_REVERSE_CHARACTERS_PTR &HC0FC ' (49404) Print Reverse Characters (0=No)
#define CLOSE_FILE_PTR &HC0FD ' (49405) Close file
#define ADD_BYTE_TO_FILE_NAME_PTR &HC0FE ' (49406) Add byte to file name
#define COMPILE_EXEC_GLSL_PTR &HC0FF ' (49407) Compile and execute GLSL program
#define TEXT_BUFFER_BACK_SWITCHING_PTR &HC100 ' (49408) Text buffer back switching
#define DRAW_SHAPES_3D_PTR &HC101 ' (49409) Draw shapes in 3D space
' 0 - Draw shaded box using r8, r9, r10, r11
' 5 - Render GLSL in 32-bit 120x60 text mode
' 6 - Render GLSL in 32-bit 40x25 text mode
' 7 - Render GLSL in 32-bit 90x60 text mode
#define SCREEN_LOCK_PTR &HC102 ' (49410) Screen lock
#define SCREEN_UNLOCK_PTR &HC103 ' (49411) Screen unlock uses y0, y0
#define SCREEN_UNLOCK_YS_PTR &HC104 ' (49412) Screen unlock uses ys, ys+8
#define WRITE_FG_BG_PTR &HC106 ' (49414) Write to foreground/background
' 0 - Draw pixel(FG) using r0, r1, fg_color
' 1 - Draw pixel(BG) using r0, r1, bg_color
' 2 - Draw line(FG) using r0, r1, r2, r3, fg_color
' 3 - Draw line(BG) using r0, r1, r2, r3, bg_color
' 4 - Draw box(FG) using r0, r1, r2, r3, fg_color
' 5 - Draw box(BG) using r0, r1, r2, r3, bg_color
' 6 - Draw filled box(FG) using r0, r1, r2, r3, fg_color
' 7 - Draw filled box(BG) using r0, r1, r2, r3, bg_color
' 8 - Draw circle(FG) using r0, r1, r2, fg_color
' 9 - Draw circle(BG) using r0, r1, r2, bg_color
' 10 - Draw pattern(FG) using r0, r1, r2, r3, fg_color
' 11 - Draw pattern(BG) using r0, r1, r2, r3, bg_color
#define E6510CPU_PTR &HC108 ' (49416)
#define LD_PC_PTR &HC109 ' (49417) Loads all data from $C10B to $C10F into pc
#define PC_PTR &HC10A ' (49418) Uses r3
#define LD_ADR0_PTR &HC110 ' (49424) Loads all data from $C111 to $C116 into adr0
#define ADR0_PTR &HC111 ' (49425) Uses pc and r3
#define LD_ADR1_PTR &HC117 ' (49431) Loads all data from $C118 to $C11D into adr1
#define LD_ADR2_PTR &HC11E ' (49438) Loads all data from $C11F to $C124 into adr2
#define LD_ADR3_PTR &HC125 ' (49445) Loads all data from $C126 to $C12B into adr3
#define SCR_PTR_ADR3 &HC12B ' (49451)
#define LD_PC_STATUS_PTR &HC12C
' Character generator ROM
#define CHAR_GEN_ROM_START &HD000
#define CHAR_GEN_ROM_END &HDFFF
' KERNAL ROM or cartridge ROM (high)
#define KERNAL_ROM_START &HE000
#define KERNAL_ROM_END &HFFFF
' Color pointers
#define LD_FG_COLOR_PTR &HC0C9
#define LD_BG_COLOR_PTR &HC0CA
' Extended Memory Table 2
' declare def pokeb(byval adr as SYSTEM_TYPE, byval v as SYSTEM_TYPE)
#define LD_FG_RGBA_PTR &H000E00000
#define LD_BG_RGBA_PTR &H000E00001
' Libc datatypes:
#include once "crt.bi" ' math.bi ...
#define K_MASK &H7ffL
#define K_SHIFT 20
#define K_BIAS 1022L
union Cheat
as double d
type
as long ls
as long ms
end type
end union
#undef NAN
static shared as double NAN = 0.0/0.0
static shared as double POS_INF = 1.0 /0.0
static shared as double NEG_INF = -1.0/0.0
#define EPSILON 1e-7
#ifdef __FLT_EVAL_METHOD__
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#else
#define FLT_EVAL_METHOD 0
#endif
#define LDBL_TRUE_MIN 3.6451995318824746025e-4951L
#define LDBL_MIN 3.3621031431120935063e-4932L
#define LDBL_MAX 1.1897314953572317650e+4932L
#define LDBL_EPSILON 1.0842021724855044340e-19L
#define LDBL_MANT_DIG 64
#define LDBL_MIN_EXP (-16381)
#define LDBL_MAX_EXP 16384
#define LDBL_DIG 18
#define LDBL_MIN_10_EXP (-4931)
#define LDBL_MAX_10_EXP 4932
#define DECIMAL_DIG 21
#undef int32_t
#undef intptr_t
#undef ptrdiff_t
#undef time_t
#undef size_t
#undef ssize_t
#undef uint32_t
#undef uintptr_t
#undef wchar_t
#undef wint_t
#undef NULL
#if defined(__ARMEB__) or defined(__AARCH64EB__)
#define __BYTE_ORDER __BIG_ENDIAN
#else
#define __BYTE_ORDER __LITTLE_ENDIAN
#endif
#define LONG_BIT 64
#define LONG_MAX &H7fffffffffffffffL
#define LLONG_MAX &H7fffffffffffffffLL
type as byte int8_t
type as short int16_t
type as long int32_t
type as longint int64_t
type as longint intmax_t
type as longint intptr_t
type as longint ptrdiff_t
dim as ulongint __jmp_buf(8) ' typedef unsigned long long __jmp_buf[8];
type as ulongint size_t
type as longint ssize_t
type as longint time_t
type as longint suseconds_t
type as ubyte uint8_t
type as ushort uint16_t
type as ulong uint32_t
type as ulongint uint64_t
type as ulongint uintmax_t
type as ulongint uintptr_t
type as longint wchar_t
type as longint wint_t
type as byte char
type as ubyte uchar
type as byte int8
type as ubyte uint8
type as short int16
type as ushort uint16
type as long int32
type as ulong uint32
type as longint int64
type as ulongint uint64
type as double float
type as integer int_t
type as uinteger uint_t
#define __suseconds_t_defined 1
#define NULL 0L
type as float max_align_t
#define CHAR_MIN (-128)
#define CHAR_MAX 127
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
#define SHRT_MIN (-1 - &H7fff)
#define SHRT_MAX &H7fff
#define USHRT_MAX &Hffff
#define INT_MIN (-1 - &H7fffffff)
#define INT_MAX &H7fffffff
#define UINT_MAX &HffffffffU
#define LONG_MIN (-LONG_MAX - 1)
#define ULONG_MAX (2UL * LONG_MAX + 1)
#define LLONG_MIN (-LLONG_MAX - 1)
#define ULLONG_MAX (2ULL * LLONG_MAX + 1)
#define MB_LEN_MAX 4
#define FBCALL
#if defined(__FB_DOS__)
#include once ".\DOS\MBOOT.BI"
' Flags accepted by Screen and ScreenRes
'
' Usage examples:
' SCREEN 14, 16,, GFX_FULLSCREEN
' SCREEN 18, 32,, GFX_OPENGL OR GFX_STENCIL_BUFFER
'
#define GFX_NULL -1
#define GFX_WINDOWED &H00
#define GFX_FULLSCREEN &H01
#define GFX_OPENGL &H02
#define GFX_NO_SWITCH &H04
#define GFX_NO_FRAME &H08
#define GFX_SHAPED_WINDOW &H10
#define GFX_ALWAYS_ON_TOP &H20
#define GFX_ALPHA_PRIMITIVES &H40
#define GFX_HIGH_PRIORITY &H80
#define GFX_SCREEN_EXIT &H80000000l
#else
#include once "fbgfx.bi"
#include once "./src/kernel/include/multiboot.bi"
using FB
#endif
static shared as multiboot_info ptr MB_INFO
#if defined(__FB_DOS__)
#include once ".\DOS\ADRR.BI"
#else
#include once "address.bi"
#endif
' #if defined(__FB_DOS__) or defined(__FB_WIN32__) or defined(__FB_WIN64__)
' #define SYSTEM_TYPE uint64
' #else
' #define SYSTEM_TYPE float
' #endif
#if defined(__FB_DOS__)
'Ring 3 - c64dvd
static shared as SYSTEM_TYPE mem64 (01048575) ' Ram
#elseif defined(__FB_WIN32__) or defined(__WIN64__)
'Ring 3 - c64dvd
static shared as SYSTEM_TYPE mem64 (04194303) ' Ram
#else
'Ring 3 - c64dvd
static shared as SYSTEM_TYPE mem64 (16777215) ' Ram
#endif
#include once "qb64.bi"
/'
#if defined(__FB_LINUX__) or defined(__FB_CYGWIN__) or defined(__FB_FREEBSD__) or defined(__FB_NETBSD__) or _
defined(__FB_OPENBSD__) or defined(__FB_DARWIN__) or defined(__FB_XBOX__) or defined(__FB_UNIX__) or _
defined(__FB_64BIT__) or defined(__FB_ARM__)
#define I_INT &H4A2DC8
#define C_INT &H482C98
#define N0000 &H4A2DA0
#define N0001 &H4A2DA1
#define N0010 &H4A2DA2
#define N0011 &H4A2DA3
#define N0100 &H4A2DA4
#define N0101 &H4A2DA5
#define N0110 &H4A2DA6
#define N0111 &H4A2DA7
#define N1000 &H4A2DA8
#define N1001 &H4A2DA9
#define N1010 &H4A2DAA
#define N1011 &H4A2DAB
#define N1100 &H4A2DAC
#define N1101 &H4A2DAD
#define N1110 &H4A2DAE
#define N1111 &H4A2DAF
#endif
#if defined(__FB_DOS__)
#define I_INT &H1239D0
#define C_INT &H7719C
#define N0000 &H1239E8
#define N0001 &H1239E9
#define N0010 &H1239EA
#define N0011 &H1239EB
#define N0100 &H1239EC
#define N0101 &H1239ED
#define N0110 &H1239EE
#define N0111 &H1239EF
#define N1000 &H1239F0
#define N1001 &H1239F1
#define N1010 &H1239F2
#define N1011 &H1239F3
#define N1100 &H1239F4
#define N1101 &H1239F5
#define N1110 &H1239F6
#define N1111 &H1239F7
#endif
#if defined(__FB_WIN32__)
#define I_INT &H495DC8
#define C_INT &H475C98
#define N0000 &H513688
#define N0001 &H513689
#define N0010 &H51368A
#define N0011 &H51368B
#define N0100 &H51368C
#define N0101 &H51368D
#define N0110 &H51368E
#define N0111 &H51368F
#define N1000 &H513690
#define N1001 &H513691
#define N1010 &H513692
#define N1011 &H513693
#define N1100 &H513694
#define N1101 &H513695
#define N1110 &H513696
#define N1111 &H513697
#endif
'/
'#define M_PI 3.1415926535897932384626433832795028
#ifdef _DEBUG
# define dprint(msg) open err for output as #99:print #99,"debug: " & msg:close #99
#else
# define dprint(msg) :
#endif
'TCL keywords
#define proc function
'Python keywords
#define def sub
#define in
#define range(x, y) x to y
'Assembly Mnemonics
#define equ = 'Equal
#define add + 'Add
#define subt - 'Subtract
#define mul * 'Multiply
#define ndiv / 'Divide
#define idiv \ 'Integer Devide
#define expt ^ 'Exponentiate
#define neg - 'Negate
#define mov(x, y) x equ y 'Move
#define jmp goto 'Jump
#define cmp if 'Compare
#define eq = 'Equal
#define ne <> 'Not equal
#define lt < 'Less than
#define ls <= 'Less than or equal
#define gs >= 'Greater than or equal
#define gt > 'Greater than
#define db data
#define dw db
#define dd dw
#define df dd
#define dl dl
#define ds ds
#define opr operator
' def SYSTEM_BUS_T.pokeb(byval adr as SYSTEM_TYPE, byval v as SYSTEM_TYPE)
#define mov_r0(x) computer.cpu_mos6510->mem->pokeb &H000000001, x ' move r0, [number]
#define mov_r1(x) computer.cpu_mos6510->mem->pokeb &H000000002, x ' move r1, [number]
#define mov_r2(x) computer.cpu_mos6510->mem->pokeb &H000000003, x ' move r2, [number]
#define mov_r0_r1 computer.cpu_mos6510->mem->pokeb &H000000004, 0 ' move r0, r1
#define mov_r0_r2 computer.cpu_mos6510->mem->pokeb &H000000005, 0 ' move r0, r2
#define mov_r1_r0 computer.cpu_mos6510->mem->pokeb &H000000006, 0 ' move r1, r0
#define mov_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000007, 0 ' move r1, r2
#define mov_r2_r0 computer.cpu_mos6510->mem->pokeb &H000000008, 0 ' move r2, r0
#define mov_r2_r1 computer.cpu_mos6510->mem->pokeb &H000000009, 0 ' move r2, r1
#define mov_pc_r0 computer.cpu_mos6510->mem->pokeb &H00000000A, 0 ' move pc, r0
#define mov_pc_r1 computer.cpu_mos6510->mem->pokeb &H00000000B, 0 ' move pc, r1
#define mov_pc_r2 computer.cpu_mos6510->mem->pokeb &H00000000C, 0 ' move pc, r2
#define mov_adr0_r0 computer.cpu_mos6510->mem->pokeb &H00000000D, 0 ' move adr0, r0
#define mov_adr0_r1 computer.cpu_mos6510->mem->pokeb &H00000000E, 0 ' move adr0, r1
#define mov_adr0_r2 computer.cpu_mos6510->mem->pokeb &H00000000F, 0 ' move adr0, r2
#define mov_adr1_r0 computer.cpu_mos6510->mem->pokeb &H000000010, 0 ' move adr1, r0
#define mov_adr1_r1 computer.cpu_mos6510->mem->pokeb &H000000011, 0 ' move adr1, r1
#define mov_adr1_r2 computer.cpu_mos6510->mem->pokeb &H000000012, 0 ' move adr1, r2
#define mov_adr2_r0 computer.cpu_mos6510->mem->pokeb &H000000013, 0 ' move adr2, r0
#define mov_adr2_r1 computer.cpu_mos6510->mem->pokeb &H000000014, 0 ' move adr2, r1
#define mov_adr2_r2 computer.cpu_mos6510->mem->pokeb &H000000015, 0 ' move adr2, r2
#define mov_red1_r0 computer.cpu_mos6510->mem->pokeb &H000000016, 0 ' move red1, r0
#define mov_red2_r0 computer.cpu_mos6510->mem->pokeb &H000000017, 0 ' move red2, r0
#define mov_red3_r0 computer.cpu_mos6510->mem->pokeb &H000000018, 0 ' move red3, r0
#define mov_green1_r0 computer.cpu_mos6510->mem->pokeb &H000000019, 0 ' move green1, r0
#define mov_green2_r0 computer.cpu_mos6510->mem->pokeb &H00000001A, 0 ' move green2, r0
#define mov_green3_r0 computer.cpu_mos6510->mem->pokeb &H00000001B, 0 ' move green3, r0
#define mov_blue1_r0 computer.cpu_mos6510->mem->pokeb &H00000001C, 0 ' move blue1, r0
#define mov_blue2_r0 computer.cpu_mos6510->mem->pokeb &H00000001D, 0 ' move blue2, r0
#define mov_blue3_r0 computer.cpu_mos6510->mem->pokeb &H00000001E, 0 ' move blue3, r0
#define mov_alpha1_r0 computer.cpu_mos6510->mem->pokeb &H00000001F, 0 ' move alpha1, r0
#define mov_alpha2_r0 computer.cpu_mos6510->mem->pokeb &H000000020, 0 ' move alpha2, r0
#define mov_alpha3_r0 computer.cpu_mos6510->mem->pokeb &H000000021, 0 ' move alpha3, r0
#define mov_x0_r0 computer.cpu_mos6510->mem->pokeb &H000000022, 0 ' move x0, r0
#define mov_x1_r0 computer.cpu_mos6510->mem->pokeb &H000000023, 0 ' move x1, r0
#define mov_y0_r0 computer.cpu_mos6510->mem->pokeb &H000000024, 0 ' move y0, r0
#define mov_y1_r0 computer.cpu_mos6510->mem->pokeb &H000000025, 0 ' move y1, r0
#define mov_z0_r0 computer.cpu_mos6510->mem->pokeb &H000000026, 0 ' move z0, r0
#define mov_z1_r0 computer.cpu_mos6510->mem->pokeb &H000000027, 0 ' move z1, r0
#define mov_fg_color_r0 computer.cpu_mos6510->mem->pokeb &H000000028, 0 ' move fg_color, r0
#define mov_bg_color_r0 computer.cpu_mos6510->mem->pokeb &H000000029, 0 ' move bg_color, r0
#define mov_char_h_r0 computer.cpu_mos6510->mem->pokeb &H00000002A, 0 ' move char_h, r0
#define mov_char_w_r0 computer.cpu_mos6510->mem->pokeb &H00000002B, 0 ' move char_w, r0
#define mov_char_ptr,r0 computer.cpu_mos6510->mem->pokeb &H00000002C, 0 ' move char_ptr, r0
#define mov_char_buffer_r0 computer.cpu_mos6510->mem->pokeb &H00000002D, 0 ' move char_buffer, r0
#define mov_bitmask_r0 computer.cpu_mos6510->mem->pokeb &H00000002E, 0 ' move bitmask, r0
#define mov_pixel_size_r0 computer.cpu_mos6510->mem->pokeb &H00000002F, 0 ' move pixel_size, r0
#define mov_radius_r0 computer.cpu_mos6510->mem->pokeb &H000000030, 0 ' move radius, r0
#define mov_string_adr_r0 computer.cpu_mos6510->mem->pokeb &H000000031, 0 ' move string_adr, r0
#define mov_string_len_r0 computer.cpu_mos6510->mem->pokeb &H000000032, 0 ' move string_len, r0
#define mov_r0_x0 computer.cpu_mos6510->mem->pokeb &H000000033, 0 ' move r0, x0
#define mov_x0_r0_2 computer.cpu_mos6510->mem->pokeb &H000000034, 0 ' move x0, r0
#define mov_r0_y0 computer cpu_mos6510->mem->pokeb &H000000035, 0 ' move r0, y0
#define mov_y0_r0_2 computer cpu_mos6510->mem->pokeb &H000000036, 0 ' move y0, r0
#define mov_r0_z0 computer.cpu_mos6510->mem->pokeb &H000000037, 0 ' move r0, z0
#define mov_r0_x1 computer.cpu_mos6510->mem->pokeb &H000000038, 0 ' move r0, x1
#define mov_r0_y1 computer.cpu_mos6510->mem->pokeb &H000000039, 0 ' move r0, y1
#define mov_r0_z1 computer.cpu_mos6510->mem->pokeb &H00000003A, 0 ' move r0, z1
#define mov_z0_r0_2 computer.cpu_mos6510->mem->pokeb &H00000003B, 0 ' move z0, r0
#define mov_r0_z1_2 computer.cpu_mos6510->mem->pokeb &H00000003D, 0 ' move r0, z1
#define mov_r0_a1 computer.cpu_mos6510->mem->pokeb &H00000003E, 0 ' move r0, a1
#define mov_r0_a2 computer.cpu_mos6510->mem->pokeb &H00000003F, 0 ' move r0, a2
#define mov_r0_a3 computer.cpu_mos6510->mem->pokeb $H000000040, 0 ' move r0, a3
#define mov_r0_a4 computer.cpu_mos6510->mem->pokeb &H000000041, 0 ' move r0, a4
#define mov_r0_a5 computer.cpu_mos6510->mem->pokeb &H000000042, 0 ' move r0, a5
#define mov_r0_a6 computer.cpu_mos6510->mem->pokeb &H000000043, 0 ' move r0, a6
#define mov_r0_a7 computer.cpu_mos6510->mem->pokeb &H000000044, 0 ' move r0, a7
#define mov_r0_a8 computer.cpu_mos6510->mem->pokeb &H000000045, 0 ' move r0, a8
#define mov_r0_z1_3 computer.cpu_mos6510->mem->pokeb &H000000046, 0 ' move r0, z0
#define add_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000047, 0 ' add r1, r2
#define sub_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000048, 0 ' sub r1, r2
#define mul_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000049, 0 ' mul r1, r2
#define div_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H00000004A, 0 ' div r1, r2
#define idiv_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H00000004B, 0 ' idiv r1, r2
#define exp_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H00000004C, 0 ' expt r1, r2
#define mod_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H00000004D, 0 ' mod r1, r2
#define neg_r0 computer.cpu_mos6510->mem->pokeb &H00000004E, 0 ' neg r0
#define shl_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H00000004F, 0 ' shl r1, r2
#define shr_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000050, 0 ' shr r1, r2
#define eq_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000051, 0 ' eq r1, r2
#define ne_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000052, 0 ' ne r1, r2
#define lt_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000053, 0 ' lt r1, r2
#define lte_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000054, 0 ' lte r1, r2
#define gte_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000055, 0 ' gte r1, r2
#define gt_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000056, 0 ' gt r1, r2
#define and_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000057, 0 ' and r1, r2
#define eqv_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000058, 0 ' eqv r1, r2
#define imp_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H000000059, 0 ' imp r1, r2
#define or_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H00000005A, 0 ' or r1, r2
#define xor_r0_r1_r2 computer.cpu_mos6510->mem->pokeb &H00000005B, 0 ' xor r1, r2
#define mov_r1_r0_2 computer.cpu_mos6510->mem->pokeb &H00000005C, 0 ' mov r1, r0
#define mov_r2_r0_2 computer.cpu_mos6510->mem->pokeb &H00000005D, 0 ' mov r2, r0
#define inc_r0 computer.cpu_mos6510->mem->pokeb &H00000005E, 0 ' inc r0
#define inc_r1 computer.cpu_mos6510->mem->pokeb &H00000005F, 0 ' inc r1
#define inc_r2 computer.cpu_mos6510->mem->pokeb &H000000060, 0 ' inc r2
#define dec_r0 computer.cpu_mos6510->mem->pokeb &H000000061, 0 ' dec r0
#define dec_r1 computer.cpu_mos6510->mem->pokeb &H000000062, 0 ' dec r1
#define dec_r2 computer.cpu_mos6510->mem->pokeb &H000000063, 0 ' dec r2
'Microcode
'Get P Register
#define get_status_flag computer.cpu_mos6510->p ' get status flag
#define get_carry_flag computer.cpu_mos6510->f.c ' gets cary flag
#define get_sero_flag computer.cpu_mos6510->f.z ' gets zero flag
#define get_interrupt_flag computer.cpu_mos6510->f.i ' gets interrupt flag
#define get_decimal_flag computer.cpu_mos6510->f.d ' gets decimal flag
#define get_borrow_flag computer.cpu_mos6510->f.b ' gets borrow flag
#define get_half_carry_flag computer.cpu_mos6510->f.h ' gets half carry flag
#define get_overflow_flag computer.cpu_mos6510->f.v ' gets overflow flag
#define get_negative_flag computer.cpu_mos6510->f.n ' gets negtive flag
'Set P Register
#define set_status_flag(x) mov(computer.cpu_mos6510->p, x) ' set status flag
#define set_carry_flag(x) mov(computer.cpu_mos6510->f.c, x) ' sets cary flag
#define set_sero_flag(x) mov(computer.cpu_mos6510->f.z, x) ' sets zero flag
#define set_interrupt_flag(x) mov(computer.cpu_mos6510->f.i, x) ' sets interrupt flag
#define set_decimal_flag(x) mov(computer.cpu_mos6510->f.d, x) ' sets decimal flag
#define set_borrow_flag(x) mov(computer.cpu_mos6510->f.b, x) ' sets borrow flag
#define set_half_carry_flag(x) mov(computer.cpu_mos6510->f.h, x) ' sets half carry flag
#define set_overflow_flag(x) mov(computer.cpu_mos6510->f.v, x) ' sets overflow flag
#define set_negative_flag(x) mov(computer.cpu_mos6510->f.n, x) ' sets negtive flag
'Addressing Modes
#define fun_adr_imm computer.cpu_mos6510->adr_imm
#define fun_adr_rel computer.cpu_mos6510->adr_rel
#define fun_adr_zero computer.cpu_mos6510->adr_zero
#define fun_adr_zero_x computer.cpu_mos6510->adr_zerox
#define fun_adr_zero_y computer.cpu_mos6510->adr_zeroy
#define fun_adr_abs computer.cpu_mos6510->adr_abs
#define fun_adr_abs_x computer.cpu_mos6510->adr_absx
#define fun_adr_abs_y computer.cpu_mos6510->adr_absy
#define fun_adr_ind computer.cpu_mos6510->adr_ind
#define fun_adr_ind_x computer.cpu_mos6510->adr_indx
#define fun_adr_ind_y computer.cpu_mos6510->adr_indy
#define fun_adr_unk computer.cpu_mos6510->adr_unk
#define sub_push(x) computer.cpu_mos6510->push(x) ' pushes dat on to the stack
#define fun_pull() computer.cpU_mos6510->pull() ' pulls data from off the stack
'Get Registers
#define get_a computer.cpu_mos6510->a ' get accumulator(unsigned)
#define get_x computer.cpu_mos6510->x ' get index register X(unsigned)
#define get_y computer.cpu_mos6510->y ' get index register Y(unsigned)
#define get_pc computer.cpu_mos6510->pc ' get program counter
#define get_pl computer.cpu_mos6510->pl ' get program counter(low byte)
#define get_ph computer.cpu_mos6510->ph ' get program counter(high byte)
#define get_sp computer.cpu_mos6510->sp ' get stack pointer
#define get_s computer.cpu_mos6510->s ' get stack pointer(low byte/LSB)
#define get_msb computer.cpu_mos6510->msb ' get stack pointer(high byte/MSB)
#define get_sa computer.cpu_mos6510->sa ' get accumulator(signed)
#define get_sx computer.cpu_mos6510->sx ' get index register X(signed)
#define get_sy computer.cpu_mos6510->sy ' get index register Y(signed)
'Set Registers
#define set_a(r) mov(computer.cpu_mos6510->a, r) ' set accumulator(unsigned)
#define set_x(r) mov(computer.cpu_mos6510->x, r) ' set index register X(unsigned)
#define set_y(r) mov(computer.cpu_mos6510->y, r) ' set index register Y(unsigned)
#define set_pc(r) mov(computer.cpu_mos6510->pc, r) ' set program counter
#define set_pl(r) mov(computer.cpu_mos6510->pl, r) ' set program counter(low byte)
#define set_ph(r) mov(computer.cpu_mos6510->ph, r) ' set program counter(high byte)
#define set_sp(r) mov(computer.cpu_mos6510->sp, r) ' set stack pointer
#define set_s(r) mov(computer.cpu_mos6510->s, r) ' set stack pointer(low byte/LSB)
#define set_msb(r) mov(computer.cpu_mos6510->msb, r) ' set stack pointer(high byte/MSB)
#define set_sa(r) mov(computer.cpu_mos6510->sa, r) ' set accumulator(signed)
#define set_sx(r) mov(computer.cpu_mos6510->sx, r) ' set index register X(signed)
#define set_sy(r) mov(computer.cpu_mos6510->sy, r) ' set index register Y(signed)
#define fun_readbyte(x) computer.cpu_mos6510->mem->readbyte(x) ' read signed byte from memory
#define fun_readubyte(x) computer.cpu_mos6510->mem->readubyte(x) ' read unsigned byte from memory
#define fun_readushort(x) computer.cpu_mos6510->mem->readushort(x) ' read unsigned short from memory
#define sub_writebyte(x, y) computer.cpu_mom6510->mem->writebyte(x, y) ' write byte to memory
#define sub_writeubyte(x, y) computer.cpu_mos6510->mem->writeubyte(x, y) ' write unsigned byte to memory
#define sub_writeushort(x, y) computer.cpu_mos6510->mem->writeushort(x, y) ' write unsigned short to memory
'mov(computer.cpu_mos6510->A,0)
'Logic Gates
#define logic_xnor(x, y) not(x xor y) 'XNOR
#define logic_xor(x, y) x xor y 'XOR
#define logic_nor(x, y) not(x or y) 'NOR
#define logic_or(x, y) x or y 'OR
#define logic_nand(x, y) not(x and y) 'NAND
#define logic_and(x, y) x and y 'AND
#define logic_not(x) not x 'NOT
'Byte Operations
#define check_bit(x, y) (logic_and((x),(1 shl (y))))
#define low_nibble(x) (logic_and(x,&H0F))
#define high_nibble(x) ((logic_and(x,&HF0)) shr 4)
'ASCII To PETSCII converter
'#define ASCII_TO_PETSCII(adr, a) if logic_and(mem64(adr add a) gt 31,mem64(adr add a) lt 64) then _
' mov(mem64(adr add a),mem64(adr add a) add 32
'Fast PSET
#Define PutPixel(_x, _y, colour) *cptr(any ptr, pScrn + (_y) * pitch + (_x) shl 2) = (colour)
'Fast POINT
#Define GetPixel(_x, _y) *cptr(any ptr, pScrn + (_y) * pitch + (_x) shl 2)
#if defined(__FB_DOS__) or defined(__FB_WIN32__) or defined(__FB_WIN64__)
#include once ".\DOS\RAY.BI"
#include once ".\DOS\GLSL4.BI"
#define vector2 vec2
#define vector3 vec3
#define vector4 vec4
#else
#include once "glsl.bi"
#include once "raytracer.bi"
#include once "glslstyle.bi"
#endif
' memory registers
static shared as SYSTEM_TYPE pc,old_pc=&H00,adr0,adr1,adr2,adr3,pc_status
' general purpose registers
static shared as SYSTEM_TYPE r0, r1, r2, r3, r4, r5
' video registers
static shared as SYSTEM_TYPE radius
#if defined(__FB_DOS__) or defined(__FB_WIN32__) or defined(__FB_WIN64__)
static shared as SYSTEM_TYPE fc, bc
static shared as uchar fr = &HFF, fg = &HFF, fb = &HFF, fa = &HFF
static shared as uchar br = &H00, bg = &H00, bb = &H00, ba = &H00
#endif
static shared as SYSTEM_TYPE red2=&HFF,green2=&HFF,blue2=&HFF,xalpha2=&HFF
static shared as SYSTEM_TYPE x_axis0, y_axis0, z_axis0, col0, col1,char_h=&H5A
static shared as SYSTEM_TYPE x_axis1, y_axis1, z_axis1, char_ptr, char_w=&H5A
static shared as SYSTEM_TYPE char_buffer=&H000004000, bitmask=&HFF, pixel_size
static shared as float occ
static shared as float ambient
static shared as float diffuse
static shared as float bac
static shared as float dom
static shared as float fr
static shared as float specular
static shared as float iGlobalTime ' shader playback time (in seconds)
static shared as float rTime
static shared as float iTime
static shared as SYSTEM_TYPE cr
static shared as float t
static shared as float m
static shared as float sca
static shared as float hr
static shared as float dd2
static shared as float EPS
static shared as float resf ' float res
static shared as float h
static shared as float mint
static shared as float tmax
static shared as float tmin
static shared as float precis
static shared as float s
static shared as mat2 m2 ' mat2 m
#if defined(__FB_DOS__) or defined(__FB_WIN32__) or defined(__FB_WIN64__)
static shared as vec3 iResolution ' viewport resolution (in pixels)
static shared as vec4 iMouse ' mouse pixel coords. xy: current (if MLB down), zw: click
static shared as vec4 fragColor
static shared as vec2 fragCoord
static shared as vec2 q
static shared as vec2 p
static shared as vec3 ro
static shared as vec3 ta
static shared as mat3 ca
static shared as vec3 rd
static shared as vec3 col
static shared as vec2 uv
static shared as vec3 cw
static shared as vec3 cp
static shared as vec3 cu
static shared as vec3 cv
static shared as vec3 lin
static shared as vec3 ref
static shared as vec3 light
static shared as vec3 p3 ' vector3 p
static shared as vec3 nor
static shared as vec2 res2
static shared as vec3 aopos
#else
static shared as vector3 iResolution ' viewport resolution (in pixels)
static shared as vector4 iMouse ' mouse pixel coords. xy: current (if MLB down), zw: click
static shared as vector4 fragColor
static shared as vector2 fragCoord
static shared as vector2 q
static shared as vector2 p2 ' vector2 p
static shared as vector3 ro
static shared as vector3 ta
static shared as mat3 ca
static shared as vector3 rd
static shared as vector3 col
static shared as vector2 uv
static shared as vector3 cw
static shared as vector3 cp
static shared as vector3 cu
static shared as vector3 cv
static shared as vector3 lin
static shared as vector3 ref
static shared as vector3 light
static shared as vector3 p3 ' vector3 p
static shared as vector3 nor
static shared as vector2 res2 ' vector2 res
static shared as vector3 aopos
static shared as vector2 rv2 ' vector2 r
#endif
' string registers
static shared as SYSTEM_TYPE string_adr, string_len
static shared as string driver_name, string_data