8-Bit Software Online Conversion
Amoeba In C - Listing
0 DATA"
"
10 DATA" 10 000
01 "
20 DATA" 10 111
01 "
30 DATA" 10 000
000 01 "
40 DATA" 10 111
111 01 "
50 DATA" 10 000 000
000 01 "
60 DATA" 10 111 111
111 01 "
70 DATA"10 000 000 000
000 01 "
80 DATA" 10 111 111 111
111 01 "
90 DATA" 10 000 000
1100 0101 "
100 DATA" 10 00010 0011
000 01 "
110 DATA" 10 000 00010
0011 01 "
120 DATA" 10 000 000
000 111 01 "
130 DATA" 10 00010 0011
1100 0101 "
140 DATA" 10 000 00010
0011 111 01 "
150 DATA" 10 111 111
1100 0101 "
160 DATA" 10 10111 0011
111 01 "
170 DATA" 10 10111 0011
1100 0101 "
180 DATA" 10 111 111
111 000 01 "
190 DATA" 10 111 10111 0
011 01 "
200 DATA" 10 111 10111 0
011 000 01 "
210 DATA" 10 1100 0011
01 "
220 DATA" 10 00010 0011
01 "
230 DATA" 10 000 000
111 01 "
240 DATA" 10 00010 0011
111 01 "
250 DATA" 1010 0011 1100
0101 "
260 DATA" 10 111 111
000 01 "
270 DATA" 10 10111 0011
01 "
280 DATA" 10 10111 0011
000 01 "
290 DATA" 1010 0011
111 01 "
300 DATA" 1010 0011
000 01 "
310 DATA" 1010 00100
0001 01 "
320 DATA" 10 1000 0011
000 01 "
330 DATA" 10 1000 00100
0001 01 "
340 DATA" 10 1110 0011
111 01 "
350 DATA" 1010 11011
0111 01 "
360 DATA" 10 1110 11011
0111 01 "
370 DATA" 1010 10011
0011 01 "
380 DATA" 101010 000011
0011 01 "
390 DATA" 10 1000 0011
111 01 "
400 DATA" 10 000 1000 0011
111 01 "
410 DATA" 1010 00110
0011 01 "
420 DATA" 101010 001111
0011 01 "
430 DATA" 10 1110 0011
000 01 "
440 DATA" 10 111 1110 0011
000 01 "
450
460 REM ***********************
470 MODE7
472 VDU3
480 *FX21
490 VDU23,1,0;0;0;0;
500 B=129
510 C1=134:C2=131:F1=C1:F2=C2
520 C3=150:C4=147:F3=C3:F4=C4
530 REPEAT:VDU(30)
540 IF F1=C1 F1=C2 ELSE F1=C1
550 IF F1=C1 F2=C2
560 IF F1=C2 F2=C1
570 IF F3=C3 F3=C4 ELSE F3=C3
580 IF F3=C3 F4=C4
590 IF F3=C4 F4=C3
600 PRINTCHR$(B)CHR$(157)
610 PRINTCHR$(B)CHR$(157)CHR$(F3)" 8
££)08£d£d`&££d`&£,`&££d`&££d"
620 PRINTCHR$(B)CHR$(157)CHR$(F3)" 5
55 j jj jj`p j`ppjj j"
630 PRINTCHR$(B)CHR$(157)CHR$(F3)" =
££)55 j jj jj! j! ij&££n"
640 PRINTCHR$(B)CHR$(157)CHR$(F3)" 5
55 j jjpppzjpppjpppzj j"
650 PRINTCHR$(B)CHR$(157)
660 PRINTCHR$(B)CHR$(157)
670 PRINTCHR$(B)CHR$(157)CHR$(F1)CHR$(
141)" 1...Display Source"
680 PRINTCHR$(B)CHR$(157)CHR$(F2)CHR$(
141)" 1...Display Source"
690 PRINTCHR$(B)CHR$(157)
700 PRINTCHR$(B)CHR$(157)CHR$(F1)CHR$(
141)" 2...Print Cards"
710 PRINTCHR$(B)CHR$(157)CHR$(F2)CHR$(
141)" 2...Print Cards"
720 PRINTCHR$(B)CHR$(157)
730 PRINTCHR$(B)CHR$(157)CHR$(F1)CHR$(
141)" 3...Return to Menu"
740 PRINTCHR$(B)CHR$(157)CHR$(F2)CHR$(
141)" 3...Return to Menu"
750 PRINTCHR$(B)CHR$(157)
760 PRINTCHR$(B)CHR$(157)CHR$(F1)CHR$(
141)" 4...Amoeba Mode 4"
770 PRINTCHR$(B)CHR$(157)CHR$(F2)CHR$(
141)" 4...Amoeba Mode 4"
780 PRINTCHR$(B)CHR$(157)
790 PRINTCHR$(B)CHR$(157)CHR$(F1)CHR$(
141)" 7...Amoeba Mode 7"
800 PRINTCHR$(B)CHR$(157)CHR$(F2)CHR$(
141)" 7...Amoeba Mode 7"
810 PRINTCHR$(B)CHR$(157)
820 PRINTCHR$(B)CHR$(157)
830 PRINTCHR$(B)CHR$(157)
840 PRINTCHR$(B)CHR$(157);
850 A$=INKEY$(50)
860 IF ASC(A$)<0 A$=" "
862 IF A$="2" MODE4:PROCprinter:MODE7:
VDU23,1,0;0;0;0;
870 UNTIL INSTR("1347",A$)
880:
890REM *DIR:2
910 IF A$="3" THEN VDU11:OSCLI"DIR $":
OSCLI"EXEC !BOOT":END
920 IF A$="4" MODE4:OSCLI"/A4or7st"
930 IF A$="7" MODE7:OSCLI"/A4or7st"
940:
950buffer=&5000
960bufsize=&2000
970F$="A4or7`c"
980HIMEM=buffer
990DIMcode 400,scr%(20)
1000ONERROR RUN
1010*FX4,1
1020PROCasscode
1030REMPROCfile
1040F%=OPENIN F$
1050REM" Colour toggles on c
1060?&74=1:?&72=130
1070B%=&900:times%=0:back%=0:new%=0
1080div=EXT#F%/100
1090:
1100REPEAT
1110new%=1:PROCld
1120 REPEAT
1130 start%=G%:?&73=0:scol%=?&72
1140 REPEAT
1150 CALL gline
1160 UNTIL ?&73=24 OR G%>=T%
1170 IF ?&73<>24:REPEAT:PRINTSTRING$(40
," ");:?&73=?&73+1:UNTIL ?&73=24
1180 depth=(bufsize*(times%-1)+G%-buffe
r)/div
1190 REPEAT
1200 PRINTTAB(0,24)CHR$(157)CHR$(132);
1210 IF depth<10 PRINT" ";
1220 IF depth<100 PRINT" ";
1230 PRINTSTR$(INT(depth))"%";
1240 IF EOF#F% AND G%>=T% PRINTCHR$(136
)" Any Key Finishes or B,[ "; ELSE PRIN
T" Any Key [,],B,F or P ";
1250 IFstart%=buffer:VDU7:E%=1:PRINT"(
TOB) ";
1260 IFE%=0:IFG%>=T%:VDU7:E%=1:PRINT"(
BOB) ";
1270 IFE%:E%=0 ELSE PRINT" ";
1280 PRINTTAB(0,24);
1290 *FX21
1300 K%=GET:G$=CHR$(K%)
1310 IF K%=136 OR K%=139 PROCback1
1320 IF K%=137 OR K%=138 PROCforward1
1330 IFINSTR("Bb",G$) PROCjumpback
1340 IFINSTR("Ff",G$) PROCjumpforward
1350 IFINSTR("Cc",G$) PROCcolour
1360 IFINSTR("Pp",G$) PROCprtScreen
1370 UNTIL K%
1380 UNTILG%>=T%
1390UNTILEOF#F%
1400:
1410CLOSE#F%
1420*FX4,0
1430RUN
1440END
1450:
1460DEFPROCcolour
1470?&74=?&74 EOR 1
1480IF ?&74 ?&72=130 ELSE ?&72=0
1490G%=start%
1500ENDPROC
1510:
1520DEFPROCcolminus
1530?&72=?&72-1
1540IF?&72=132:?&72=131
1550IF?&72=129:?&72=134
1560ENDPROC
1570:
1580DEFPROCcolplus
1590?&72=?&72+1
1600IF?&72=132:?&72=133
1610IF?&72=135:?&72=130
1620ENDPROC
1630:
1640DEFPROCld
1650IFback% times%=times%-1:PTR#F%=scr%
(times%)
1660IFnew%:times%=times%+1:scr%(times%)
=PTR#F%
1670IF EXT#F%-PTR#F%>(bufsize-1) H%=buf
size ELSE H%=EXT#F%-PTR#F%
1680PRINTTAB(0,24)CHR$(157)CHR$(132)" L
oading Please Wait ";TAB(
0,24);
1690A%=4
1700X%=B% MOD 256
1710Y%=B% DIV 256
1720B%?0=F%
1730B%!1=buffer
1740B%!5=H%
1750CALL&FFD1
1760D%=0:back%=0:new%=0:G%=buffer:T%=G%
+H%+D%
1770IF PTR#F%=EXT#F% ENDPROC
1780S%=&6FFF
1790REPEAT
1800D%=D%+1
1810S%=S%+1
1820R%=BGET#F%
1830?S%=R%
1840UNTIL?S%=13 AND ?(S%-1)=13
1850S%?1=&FF
1860T%=G%+H%+D%
1870ENDPROC
1880:
1890DEFPROCfile
1900REPEAT
1910*.
1920PRINT'"Filename :";
1930INPUT F$
1940IF LEFT$(F$,1)="*" OSCLI+F$
1950UNTILLEFT$(F$,1)<>"*"
1960ENDPROC
1970:
1980DEFPROCback1
1990IFstart%=buffer:IFtimes%>1:G$="B":E
NDPROC
2000IFstart%=buffer:K%=0:ENDPROC
2010?&72=scol%
2020IF?&74:IF?start%=13:PROCcolminus
2030VDU30:G%=start%-1
2040REPEAT:G%=G%-1:UNTIL ?G%=13 OR G%=&
3000
2050IF G%<>buffer:G%=G%+1
2060ENDPROC
2070:
2080DEFPROCforward1
2090IFG%>=T%:G$="F":ENDPROC
2100?&72=scol%
2110VDU30:G%=start%-1
2120REPEAT:G%=G%+1:UNTIL ?G%=13
2130G%=G%+1
2140IF?&74:IF ?G%=13 PROCcolplus
2150ENDPROC
2160:
2170DEFPROCjumpback
2180IFG%<=(buffer+&600) AND times%=1:G%
=buffer:ENDPROC
2190IFG%>(buffer+&600):G%=G%-&600:REPEA
T:G%=G%-1:UNTIL ?G%=13 OR G%=buffer:ENDP
ROC
2200back%=1
2210PROCld:G%=&6A00:REPEAT:G%=G%-1:UNTI
L ?G%=13
2220ENDPROC
2230:
2240DEFPROCjumpforward
2250IFG%>(T%-&380):ENDPROC
2260G%=G%+&300
2270REPEAT:G%=G%+1:UNTIL?G%=13
2280ENDPROC
2290:
2300DEFPROCprtScreen
2310U%=start%:E%=0:cnt%=0:VDU2
2320REPEAT
2330REPEAT
2340A%=?U%
2350IFA%=141:E%=1
2360IFA%>126:A%=32
2370IFA%>31:VDU1,A%
2380U%=U%+1
2390UNTIL?U%=13 OR U%>T%
2400IFE%:REPEAT:U%=U%+1:UNTIL?U%=13:cnt
%=cnt%+1:VDU1,13:E%=0
2410cnt%=cnt%+1:VDU1,13
2420UNTILcnt%=24 OR U%>T%
2430VDU1,13,3:K%=0
2440ENDPROC
2450:
2460DEFPROCerror
2470CLOSE#F%
2480*FX4,0
2490PRINT
2500ENDPROC
2510:
2520DEFPROCasscode
2530FOR I%=0 TO 2 STEP 2
2540P%=code
2550[OPTI%
2560.gline
2570LDX &74:STX &76
2580LDA &72:JSR &FFEE
2590.loopa
2600JSR get
2610CMP #13:BEQ a2
2620CMP #126:BCS a1
2630CMP #32:BCC a1
2640JSR &FFEE:INC &76
2650.a1
2660LDX &76:CPX #40:BNE loopa
2670INC &7F
2680.a2
2690LDX &74:BEQ a3
2700JSR seeatg:CMP #13:BNE a3
2710LDX &7F:BEQ d2
2720LDA &404:PHA
2730JSR get:JSR seeatg
2740LDX &41C:BNE d1:DEC &41D
2750.d1
2760DEC &41C
2770TAX:PLA:STA &404
2780CPX #13:BNE a3
2790.d2
2800JSR chcol
2810.a3
2820LDX #0:STX &7F
2830LDA &404:CMP #13:BNE a4
2840LDA #32
2850.cloop
2860LDX &76:CPX #40:BEQ a4
2870JSR &FFEE:INC &76:BNE cloop
2880.a4
2890LDA &404:CMP #13:BEQ a5
2900CMP #32:BEQ a5:JSR back
2910.a5
2920INC &73
2930RTS
2940½ ******* subroutines ********
2950.get
2960LDX &41C:STX &80
2970LDX &41D:STX &81
2980LDY #0:LDA (&80),Y:STA &404
2990INC &41C:BNE g1:INC &41D
3000.g1
3010RTS
3020.seeatg
3030LDX &41C:STX &80
3040LDX &41D:STX &81
3050LDY #0:LDA (&80),Y
3060RTS
3070.chcol
3080INC &72:LDX &72
3090CPX #132:BNE c1
3100LDY #133:STY &72
3110.c1
3120CPX #135:BNE c2
3130LDY #130:STY &72
3140.c2
3150RTS
3160.back
3170JSR seeatg
3180CMP #32:BEQ b0
3190CMP #13:BNE b2
3200.b0
3210INC &41C:BNE b1:INC &41D
3220.b1
3230RTS
3240.b2
3250LDX &41C:STX &82:LDX &41D:STX &83
3260LDX #0:STX &75
3270.loopb1
3280LDY #2
3290.b3
3300LDX &41C:BNE b4:DEC &41D
3310.b4
3320DEC &41C:DEY:BNE b3
3330JSR get:INC &75:DEC &76
3340CMP #32:BEQ b6
3350LDX &76:CPX &74:BNE loopb1
3360.b5
3370LDX #0:STX &75
3380LDX &82:STX &41C
3390LDX &83:STX &41D
3400JSR seeatg:CMP #13:BNE b6
3410INC &41C:BNE b6:INC &41D
3420.b6
3430LDX &75:BEQ b7:LDA #127
3440.loopb2
3450JSR &FFEE:DEC &75:BNE loopb2
3460JSR &FFE7
3470.b7
3480RTS
3490]NEXT:ENDPROC
3500:
3510 DEFPROCprinter
3512 VDU23,1,0;0;0;0;
3520 ONERROR RUN
3530 VDU23,244,&18,&18,&30,&E3,&C7,&0C,
&18,&18
3540 VDU23,245,&18,&18,&0C,&C7,&E3,&30,
&18,&18
3550 CLS
3560 PRINT"These cards do not quite fit
on a"
3570 PRINT"sheet of A4, but will do if
the paper"
3580 PRINT"is turned half way, so this
program"
3590 PRINT"prompts you to do so."
3600 PRINT''"Ready printer press a key
when ready."
3610 A=GET
3620 CLS
3630 FOR I=1 TO 44 STEP 4
3640 IF I=21 PROCturnpage
3650 FOR N=0 TO 3
3660 PROCgetcard(I+N)
3670 PROCdcard(N,25,G$)
3680 NEXT
3690 PROCprint
3700 REMA=GET
3710 NEXT
3720
3730 ENDPROC
3740
3750 DEFPROCturnpage
3760 PRINTTAB(0,10)"TURN PAPER AND PRES
S A KEY":A=GET
3770 CLS
3780 ENDPROC
3790
3800 DEFPROCgetcard(C%)
3810 RESTORE C%*10
3820 READ G$
3830 ENDPROC
3840
3850 DEFPROCdcard(x,y,G$)
3860 FOR SY%=1 TO LEN(G$) STEP 7
3870 N%=SY% DIV 7 +y
3880 C$=MID$(G$,SY%,7)
3890 PRINTTAB(x*10,N%);
3900 FOR J%=1 TO 7
3910 IF MID$(C$,J%,1)="1" VDU244
3920 IF MID$(C$,J%,1)="0" VDU245
3930 IF MID$(C$,J%,1)=" " VDU32
3940 NEXT
3950 NEXT
3960 ENDPROC
3970
3980 DEFPROCprint
3990 PROCassemble
4000 REM*LOAD SCREEN
4010 *FX 5,1
4020 VDU2,1,27,1,65,1,8
4030 FOR Y%=255 TO 0 STEP -32
4040 VDU 1,27,1,75,1,64,1,1
4050 FOR X%=0 TO 1279 STEP 4
4060 !Xlo=X%+Y%*&10000
4070 ?bitstodo=8
4080 CALL makebyte
4090 NEXT
4100 VDU1,10
4110 NEXT
4120 REMVDU1,12,3
4130 VDU3
4140 ENDPROC
4150
4160 DEF PROCassemble
4170 OSWORD=&FFF1
4180 OSWRCH=&FFEE
4190 DIM S% 80
4200 Xlo=S%
4210 Xhi=S%+1
4220 Ylo=S%+2
4230 Yhi=S%+3
4240 colour=S%+4
4250 byte=S%+5
4260 bitstodo=S%+6
4270 S%=S%+7
4280 FOR opt=0 TO 2 STEP 2
4290 P%=S%
4300 [OPT opt
4310 .makebyte LDA #9
4320 LDX #Xlo MOD 256
4330 LDY #Xlo DIV 256
4340 JSR OSWORD
4350 CLC
4360 LDA colour
4370 BNE rotate
4380 SEC
4390 .rotate ROL byte
4400 SEC
4410 LDA Ylo
4420 SBC #4
4430 STA Ylo
4440 BCC dec`Yhi
4450 JMP decdone
4460 .dec`Yhi DEC Yhi
4470 .decdone DEC bitstodo
4480 BNE makebyte
4490 LDA #1
4500 JSR OSWRCH
4510 LDA byte
4520 EOR #&FF
4530 JSR OSWRCH
4540 RTS
4550 ]
4560 NEXT opt
4570 ENDPROC