Mark Wickens

10 ' CosmicV4.bas
20 '  Cosmic-Fly for VX-4/FX-870P,
30 '   programmed by BLUE, 2003,
40 '   original by Gernot Fink for PB-1000,
50 '   loader rewritten by 123 for readability, usability and portability,
60 '     built at 6th,Nov.,2010.
70 ' At least 1520-byte machine code area must be made by extended CLEAR.
80 ' VX-4 with only 8KB is not supported in short of RAM. 
90 '
100 CLS:GOSUB 850:MODE110(EX):END
110 '
840 'Quick Loader(FX-870P/VX-4)
845 'LDAD+2,3:destination addr; LDAD+6,7:source start addr; LDAD+10,11:source end addr
850 CGRAM=&H153C:LDAD=&H1A3C:'addr of DEFCHR$() and Mac-loader(in SAVE/LOAD buffer)
855 DEFCHR$(252)="D6403C1AD600":DEFCHR$(253)="3C15D6205315":DEFCHR$(254)="D8566054F700"
860 MODE110(CGRAM):'relocatable mac-loader is transfered to LDAD by itself
865 IOBF=&H1895:IOBF=PEEK(IOBF)+PEEK(IOBF+1)*256
870 RESTORE 1000:READ ST,ED,EX:C=INT((ED-ST)/24)
875 IF ED>=IOBF THEN BEEP:PRINT"Cannot alloc memory!":PRINT"Make mac area at least";ED-ST+1;"bytes":END 
880 GOSUB 980
885 P=0
890 FOR I=0 TO 23
895   IF PEEK(ST+I)=PEEK(CGRAM+I) THEN P=P+1
900 NEXT
905 IF P<>24 THEN 915 ELSE BEEP 1:PRINT"Mac codes already loaded.":PRINT"Hit any key."
910 A$=INKEY$:IF A$="" THEN 910 ELSE RETURN
915 CLS
920 ST0=ST
925 FOR I=0 TO C
930   POKE LDAD+2,(ST MOD 256):POKE LDAD+3,INT(ST/256):'change destination
935   IF (ED-ST)<23 THEN POKE LDAD+10,&H3C+(ED-ST):ST=ED-23:'change transfer size
940   MODE110(LDAD):ST=ST+24:'execute data transfer by 24 bytes, basically
945   LOCATE 0,2:PRINT"BLOAD:";ST-ST0;"bytes";
950   IF I<C THEN GOSUB 980:'data preparation for mac-loader
955 NEXT
960 PRINT" -- completed."
965 RETURN
970 '
975 '*DATPRE:'data preparation
980 READ A$,B$,C$,D$
985 DEFCHR$(252)=A$:DEFCHR$(253)=B$:DEFCHR$(254)=C$:DEFCHR$(255)=D$
990 RETURN
995 '
1000 DATA 7376,8895,7376
1001 DATA D6003C15D620,FB15D640D519,D8D100A921D0,400000D100A8
1002 DATA 215040037716,2077AA1D7736,1D771F1EB028,779321779321
1003 DATA D640A8213F1E,B495D640A921,AB00A9028142,B103A1007728
1004 DATA 1D774C1D7700,1EB0BB77281D,566054F7D640,3C15D600D519
1005 DATA D620941AD8F7,778D21D600A0,228F40420208,A2000922B485
1006 DATA 774C1DF7D640,7A13D1000A22,0E23776321D1,00AB219140D6
1007 DATA 409D13773621,D6403A14D100,1122776321D1,00A9219140D6
1008 DATA 405D14773621,D640FA14D100,1822776321D1,00A82111540C
1009 DATA 7414B010D600,1F22E800A0E3,00A00934B489,F7CF40A0E300
1010 DATA A0F7778D21D6,403C12D100AD,210E23776321,D640FC12D100
1011 DATA BE21776321D6,40BC13D100CB,21776321D640,7C14D100DC21
1012 DATA 776321774C1D,779321779921,D100A921D040,0000D1022E03
1013 DATA 779D21D102A4,03779D214100,0DB492F7D640,0413D100EF21
1014 DATA 0E23776321D6,40D413D100FF,217763217799,2177EC1DF702
1015 DATA 161C004C007F,4E00401620D1,1B002C8F7818,77581F093DB4
1016 DATA 86421D5A776F,1EF008310431,B00477891F77,BD1E0431B018
1017 DATA 7799210C7616,B010D100A921,9140D6405D14,773621021641
1018 DATA 1CFFB4B90E20,F757000577B3,1E410004B408,011CB004491C
1019 DATA 0257000777B3,1E410001B409,411C64B00448,1C0257000977
1020 DATA B31E410004B4,084419FFB403,023B57000177,B31E410080F4
1021 DATA 0F40F79F609F,61016001B488,F7411CFFF0D6,007A142A601C
1022 DATA 441B07B00847,17FFB0039E18,D64030224200,0D294128494C
1023 DATA 09F80E610920,410920B48FD1,003A128158B5,234200FF9618
1024 DATA 680207410207,B0044402FF60,0007B41D4102,07D100C00060
1025 DATA 01C789D80F44,19FFB0089618,02006000C702,19F74217FF82
1026 DATA 300236D102A9,219160028A60,109060020219,6019C7421B05
1027 DATA 9E13D6404622,42000C2B0122,0169010B6001,BF0920B48DF7
1028 DATA 1C02D1000400,441BFFB01389,5A4117FFB006,047A17B0064F
1029 DATA 02C01622F742,17214414FFB0,0CD6405E2296,1377461F0214
1030 DATA F7420D08D10E,8022020C9162,0E772720882E,882E092DB48D
1031 DATA 779420420D08,D10E8022020A,960E9F600200,280B017C0BB5
1032 DATA 044200021F6B,0F6B0D4C0B05,B0040260014C,000228014701
1033 DATA FFB037022A41,0164B1033C00,02204401FFB0,033E00282144
1034 DATA 01FFB0033E20,1F600F60080C,201860282141,010FB1033C20
1035 DATA 91620E420CFF,772720882E88,2E092DB4E404,2AB002F7D600
1036 DATA 8022420A1068,00102200092A,B488F7020947,02FFB0660260
1037 DATA 034C00074C02,7F026103D600,3B12440118B0,086A04BF4981
1038 DATA 088B2A6402D6,403D22420405,296604020502,48070CB00B44
1039 DATA 0807B0069846,09A88928080F,68060C680C20,086808C04108
1040 DATA AAB40A420C0F,4209FF10690E,0F68050C680C,6008C02A0809
1041 DATA 24B4BEF7D100,A02208354202,0891464406FF,B421D1038022
1042 DATA 02651508354C,050718650E63,059163034103,FFB0610E2390
1043 DATA 438266030263,07D6003B122A,68064206804C,0307B0061846
1044 DATA 09A38941071E,B40742060777,27214C0718B0,086A03BF4987
1045 DATA 088B6006024C,067FB4046086,BE9146082790,46410720B516
1046 DATA 020360030209,661C490609B1,04421CFF8F66,069046882088
1047 DATA 200922319D20,F7420C031C0D,4F0DC0162D09,2CB48AF71E62
1048 DATA 566065420304,D60060000264,014C04F01844,026504184518
1049 DATA 45096405E865,A4E305A09A20,0923B1A11662,F711440C6404
1050 DATA B02349042002,059864826604,986688640696,041E62566065
1051 DATA E804A01662E3,04A08820B7A8,F7D102DF2AB7,0BD102B333B7
1052 DATA 05D1020F93D1,002353A60156,6054DE020000,000000232320
1053 DATA 436F736D6963,20466C792023,23004B657920,46756E637469
1054 DATA 6F6E004C6566,745B345D2052,696768745B36,5D0053686F74
1055 DATA 5B305D205374,6172745B4558,455D002A2A20,47414D45204F
1056 DATA 564552202A2A,005055534820,5B4558455D00,48492D53433A
1057 DATA 0053434F5245,3A0053484950,203A00040C1C,0C0400000000
1058 DATA 000000000000,000000000001,030303070303,03010000C0D0
1059 DATA 20D0C0000000,510AA58F46AA,49AA8FA50A51,8A50A5F24EAA
1060 DATA 4BAAF2A5508A,000000000000,000000000000,000000000000
1061 DATA 000000000000,000000000000,000000000001,180338075803
1062 DATA 001118123813,581400011803,380758030010,181038105810
1063 DATA 000000000000,000000000000,000000000000,000000000000
1064 DATA 000000000000,000000000000,000000000000,000000000000
1100 'end of program