Start from .bas source code, tokenize it, and embed.

This commit is contained in:
giomba 2022-12-04 20:43:52 +01:00
parent ba41f285d4
commit 4a2b889b86
4 changed files with 89 additions and 2 deletions

View File

@ -4,9 +4,13 @@
ASM=$(wildcard src/*asm) ASM=$(wildcard src/*asm)
vic20term.prg: env $(ASM) vic20term.bin: env $(ASM) build/demo.raw
dasm src/main.asm -Isrc/ -f3 -T1 -sbuild/vic20term.prg.symbols.txt -obin/vic20term.bin dasm src/main.asm -Isrc/ -f3 -T1 -sbuild/vic20term.prg.symbols.txt -obin/vic20term.bin
build/demo.raw: env src/demo.bas
petcat -w2 -l 1001 -o build/demo.prg -- src/demo.bas
dd if=build/demo.prg of=build/demo.raw bs=1 skip=2
env: env:
mkdir -p {bin,build} mkdir -p {bin,build}

9
README.md Normal file
View File

@ -0,0 +1,9 @@
- From .prg to .BAS
```
petcat -2 -o program.bas -- program.prg
```
- From .bas to .prg
```
petcat -w2 -l 1001 -o program.prg -- program.bas
```

73
src/demo.bas Normal file
View File

@ -0,0 +1,73 @@
5 print"merry christmas"
10 data"vs g3a1g2e6, c3a1g2e6"
12 data"vs d3r1d2b6, c3r1c2g6"
14 data"vs a3r1a2c3b1a2, g3a1g2e4r2"
16 data"vs a3r1a2c3b1a2, g3a1g2e5r1"
18 data"vs d3r1d2f3d1b2, c6e4r2"
20 data"vs c3g1e2g3f1d2, c6c4r2"
22 data"vt c3r1c1r1c5r1, c3r1c1r1c6"
24 data"vt g3r1g1r1g6, c3r1c1r1c6"
26 data"vt f3r1f1r1f6, c3r1c1r1c5r1"
28 data"vt f3r1f1r1f6, c3r1c1r1c6"
30 data"vt g3r1g1r1g6, c6c5r1"
32 data"vt g3r1g1r1g6, c6c4r2"
34 data"va e3f1e2c6, e3f1e2c6"
36 data"va f6d6, e6e6"
38 data"va f4c2a3g1f2, e3f1e2c6"
40 data"va f6a3g1f2, e3f1e2c6"
42 data"va f6d3f1d2, e6g5r1"
44 data"va e4c2e3d1b2, e6e4r2"
46 data"x"
100 ns%=2:vt=36874:dimn%(ns%,80),tm%(ns%),sp%(ns%)
160 fori=0tons%:n%(i,0)=0:next
190 sh%=16:cv=2:in$="":c$=""
230 gosub800
240 ifc$="x"then510
250 ifc$<>"v"then340
260 gosub800
280 ifc$="s"thencv=2
290 ifc$="a"thencv=1
300 ifc$="t"thencv=0
310 goto230
340 fr=-1
350 ifc$="c"thenfr=225
360 ifc$="d"thenfr=228
370 ifc$="e"thenfr=231
380 ifc$="f"thenfr=232
390 ifc$="g"thenfr=235
400 ifc$="a"thenfr=237
410 ifc$="b"thenfr=239
420 ifc$="r"thenfr=0
430 iffr=-1thenprint"?";c$;"in";in$:stop
440 gosub800
450 i%=n%(cv,0)+1:n%(cv,0)=i%
480 n%(cv,i%)=val(c$)+sh%*fr
490 goto230
510 fori=0tons%
520 sp%(i)=1:tm%(i)=0
550 nexti
570 fori=0to4:pokevt+i,8:nexti
580 ford=0to1
590 fori=0tons%
600 j=sp%(i)
610 ifj>n%(i,0)then670
620 d=0
630 nt%=(n%(i,j)/sh%-int(n%(i,j)/sh%))*sh%
640 iftm%(i)>=nt%then750
650 tm%(i)=tm%(i)+1
660 pokevt+i,int(n%(i,j)/sh%)
670 nexti
680 forj=0to70:nextj
690 nextd
700 fori=0to4
710 pokevt+1,0:nexti
730 printfre(x);"bytes left"
740 sys49148
750 sp%(i)=j+1
760 tm%(i)=0:goto600
800 ifc$="x"thenreturn
810 iflen(in$)=0thenreadin$
820 c$=left$(in$,1)
830 in$=right$(in$,len(in$)-1)
850 ifc$=" "orc$=","thengoto800
860 return

View File

@ -154,9 +154,10 @@ message:
; https://www.commodore.ca/manuals/funet/cbm/vic20/demos.basic/unexpanded/Stillenacht.prg ; https://www.commodore.ca/manuals/funet/cbm/vic20/demos.basic/unexpanded/Stillenacht.prg
demo_start: demo_start:
.incbin "res/stillenacht.raw" .incbin "build/demo.raw"
demo_end: demo_end:
DEMO_LEN SET demo_end - demo_start DEMO_LEN SET demo_end - demo_start
ECHO DEMO_LEN
. = $bffc . = $bffc
jmp coldstart jmp coldstart