M .gitignore => .gitignore +2 -0
@@ 1,2 1,4 @@
*.rom
*.sym
+games/
+*~
A bfc.tal => bfc.tal +129 -0
@@ 0,0 1,129 @@
+|0 @System &pad $e &debug $1 &state $1
+|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
+
+( program structure:
+ 0x00 .. 0xff = brainfuck tape
+ 0x0100..0xffff = program rom
+
+ stack contents between instructions: ( addr val )
+ return stack always stores 0x01
+
+ [ +++ ] => @l0000 DUP #00 EQU ?{ INC INC INC !l0000 }
+)
+
+%dbg { LIT2 01 -System/debug DEO }
+
+|100
+@on-reset ( -> )
+ ;on-console .Console/vector DEO2
+ ;Code/intro Code/emit-line
+ ;Code/intro2 Code/emit-line
+ BRK
+
+@on-console ( -> )
+ .Console/type DEI #04 NEQ ?{
+ Loops/not-empty? ?{ ;errs/mismatch errs/die }
+ }
+ .Console/read DEI
+ DUP [ LIT "[ ] NEQ ?{ Loops/open }
+ DUP [ LIT "] ] NEQ ?{ Loops/close }
+ Code/emit
+ BRK
+
+
+@putn2 ( n* -- )
+ SWP putn
+ ( >> )
+@putn ( n -- )
+ #10 DIVk DUP putbcd
+ MUL SUB putbcd
+ JMP2r
+@putbcd ( n -- )
+ DUP #0a LTH ?{ #27 ADD }
+ #30 ADD .Console/write DEO
+ JMP2r
+
+
+@Code/tab
+ "+ =/add
+ "- =/sub
+ "> =/next
+ "< =/prev
+ ". =/out
+ ", =/in
+ "[ =/open
+ "] =/close
+ $1
+
+&add "INC 0a
+&sub "STHrk 20 "SUB 0a
+&next "OVR 20 "STZ 20 "INC 20 "LDZk 0a
+&prev "OVR 20 "STZ 20 "STHrk 20 "SUB 20 "LDZk 0a
+&out "DUP 20 "#18 20 "DEO 0a
+&in "POP 20 ";{ 20 "#10 20 "DEO2 20 "BRK 20 "} 20 "#12 20 "DEI 0a
+&open 20 "DUP 20 "#00 20 "EQU 20 "?{ 0a
+&close 20 "} 0a
+
+&intro "|100 20 "( 20 "generated 20 "by 20 "bfc.rom 20 ") 0a
+&intro2 "LITr 20 "01 0a
+
+&trailer "#800f 20 "DEO 20 "BRK 0a
+
+&emit ( c -- )
+ LIT2r =/tab
+ ( >> )
+
+&search ( c `addr* -- )
+ DUP LDArk STHr DUP
+ #00 NEQ ?{ POP2r POP2 POP JMP2r }
+ EQU ?{ INC2r INC2r INC2r !/search }
+ POP STH2r INC2 LDA2
+ ( >> )
+
+&emit-line ( addr* -- )
+ LDAk .Console/write DEO
+ LDAk #0a EQU ?{ INC2 !/emit-line }
+ POP2 JMP2r
+
+
+@Loops/open ( -- )
+ [ LIT2 &ctr $2 ] INC2k ,/ctr STR2 ( get next loop idx )
+ DUP2 /print-label ( "@lXXXX" )
+ [ LIT2 &ptr =/stack ] INC2k INC2 ,/ptr STR2 ( increment stack pointer )
+ STA2 ( store idx )
+ JMP2r
+
+&close ( -- )
+ ,/ptr LDR2 #0002 SUB2
+ LDA2k INC2k ORA ?{ ;errs/underflow errs/die }
+ /print-jmi
+ ,/ptr STR2
+ JMP2r
+
+¬-empty? ( -- empty )
+ ,/ptr LDR2 ;/stack EQU2
+ JMP2r
+
+&print-label ( n* -- )
+ [ LIT2 "@ -Console/write ] DEO
+ !/print-name
+&print-jmi ( n* -- )
+ [ LIT2 "! -Console/write ] DEO
+ ( >> )
+&print-name ( n* -- )
+ [ LIT2 "l -Console/write ] DEO
+ putn2
+ JMP2r
+
+
+@errs/die ( addr* -- )
+ LDAk DUP ?{ #ff .System/state DEO BRK }
+ .Console/error DEO
+ INC2 !/die
+
+&underflow "fatal: 20 "too 20 "many 20 "closing 20 "braces. 0a $1
+&mismatch "fatal: 20 "not 20 "enough 20 "closing 20 "braces. 0a $1
+
+
+@Loops/guard [ ffff ]
+&stack ( goes to end of ram )
A gif.tal => gif.tal +68 -0
@@ 0,0 1,68 @@
+|00 @System/vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
+|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
+|a0 @File1/vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
+
+|00
+ @input/path $2f &end $1
+
+%dbg! ( -- ) { #00 ?{ LIT2 01 -System/debug DEO } }
+|100
+@on-reset ( -> )
+ ;meta .System/metadata DEO2
+ .Console/type DEI ?{ ;errs/usage die }
+ ;on-input .Console/vector DEO2
+ BRK
+
+@on-input ( -> )
+ #0403 .Console/type DEI
+ NEQk ?{ ;errs/usage die } NIP
+ NEQk ?{ !readloop } POP2
+
+ [ LIT2 -input/end &ptr -input/path ]
+ NEQk ?{ ;errs/pathlimit die }
+ .Console/read DEI SWP STZk INC ,&ptr STR
+ POP2 BRK
+
+@readloop ( -- )
+ ;input/path .File1/name DEO2
+ .File1/success DEI
+ BRK
+
+@die ( str* -- )
+ perr [ LIT2 81 -System/state ] DEO
+ BRK
+@pout ( str* -- )
+ .Console/write ;puts/target STA
+ !puts
+@perr ( str* -- )
+ .Console/error ;puts/target STA
+ ( >> )
+
+@puts ( str* -- )
+ LDAk DUP ?{ POP POP2 JMP2r }
+ [ LIT &target -Console/write ] DEO
+ INC2 !puts
+
+
+@gif/chunk &magic $ff
+ &screen &wid $2 &hei $2 &pack $1 &bg $1 &aspect $1
+ &colortab $300
+
+@gif/init ( -- )
+ #06 /read
+ /magic-ok? ?{ ;errs/corrupt die }
+@gif/read ( len* -- )
+ #00 SWP .File1/length DEO2
+ ;/chunk .File1/read
+ JMP2r
+
+
+@errs/usage "usage: 20 "gif.rom 20 "image.gif 0a $1
+ &pathlimit "GIF 20 "path 20 "limit 20 "exceeded. 0a $1
+ &filename ": 20 "file 20 "unreadable 0a $1
+
+@meta $1
+ ( name ) "GIF 0a
+ ( desc ) ".gif 20 "file 20 "renderer 0a
+ ( auth ) "By 20 "Aleteoryx 0a
+ ( date ) "20250319 $2
M mkfile => mkfile +3 -1
@@ 1,6 1,8 @@
roms=\
arvelie.rom\
- nanpa.rom
+ nanpa.rom\
+ bfc.rom\
+ gif.rom
all:VQ: $roms