commit bfbe94d018d294d33c1a6a6ba2039d42e609d58b
parent 8b1456a49cee9cb195bc2febd60fb36e24679610
Author: Luxferre <lux@ferre>
Date: Sat, 30 Jul 2022 20:18:39 +0300
reorganize ESOP stdlib
Diffstat:
4 files changed, 144 insertions(+), 135 deletions(-)
diff --git a/tal-lib/esop-lib-macro.tal b/tal-lib/esop-lib-macro.tal
@@ -0,0 +1,67 @@
+( ESOP stdlib, macro part )
+( by Luxferre, 2022, public domain )
+
+|00 @Control [ &framevec $2 &io $2 &random $1 &status $1 &sound $1 &syscall $1 ]
+
+( control block macros )
+
+%SETSCRVEC { .Control/framevec DEO2 }
+%INKEY { .Control/io DEI2 }
+%PXL { .Control/io DEO2 }
+%PXLk { DUP2 PXL }
+%RND { .Control/random DEI }
+%STACKTRACE { #ff .Control/random DEO }
+%DEVSTAT { .Control/status DEI }
+%SND { .Control/sound DEO }
+%SYS { .Control/syscall DEO }
+
+( some syscall macros )
+
+%HLT { #1f SYS }
+( val -- )
+%DBG { #20 SYS SYS }
+( val -- val )
+%DBGBYTE { DUP DBG }
+( val* -- val* )
+%DBGSHORT { DUP2 SWP DBG DBG }
+
+( input helper macros )
+
+%KP-0 { #0001 }
+%KP-1 { #0002 }
+%KP-2 { #0004 }
+%KP-3 { #0008 }
+%KP-4 { #0010 }
+%KP-5 { #0020 }
+%KP-6 { #0040 }
+%KP-7 { #0080 }
+%KP-8 { #0100 }
+%KP-9 { #0200 }
+%KP-A { #0400 }
+%KP-B { #0800 }
+%KP-C { #1000 }
+%KP-D { #2000 }
+%KP-STAR { #4000 }
+%KP-HASH { #8000 }
+
+( jump to label or subroutine if a particular key is pressed )
+( label* keymask* -- )
+%JMPKEY { INKEY AND2 ORA ROT ROT JCN2 }
+%JSRKEY { INKEY AND2 SWP2 JSR2 }
+
+( misc macros )
+
+( byte to short )
+%BTS { #00 SWP }
+
+( decrement )
+%DEC { #01 SUB }
+
+( get the bit or the nibble of a specific number )
+( val bitnum -- bit )
+%GETBIT { SFT #01 AND }
+( val* bitnum -- bit )
+%GETBIT2 { SFT2 #0001 AND2 NIP }
+( val* nibnum -- nibble )
+%GETNIBBLE { #20 SFT SFT2 NIP #0f AND }
+
diff --git a/tal-lib/esop-lib-subs.tal b/tal-lib/esop-lib-subs.tal
@@ -0,0 +1,74 @@
+( ESOP stdlib, subroutine part )
+( by Luxferre, 2022, public domain )
+
+( sprite and text drawing routines )
+
+( subtract #20 from the ASCII code and get the absolute offset from the nanofont label )
+%CHAR-TO-NF { #20 SUB BTS #10 SFT2 ;nanofont ADD2 }
+
+( 4x1 scanline output from the nibble )
+( x y nibble -- x y )
+@line4
+ #04 ( x y nibble counter -- )
+ &lp
+ DEC ( first effective counter value is 3 )
+ DUP2 ( x y nibble counter nibble counter -- )
+ GETBIT ( x y nibble counter bit -- )
+ ,&dpxl JCN
+ ,&skip JMP
+ &dpxl ( x y nibble counter -- )
+ SWP2 PXLk SWP2
+ &skip ( x y nibble counter -- )
+ SWP2 SWP ( nibble counter y x -- )
+ INC ( increment x coord )
+ SWP SWP2 ( x y nibble counter -- )
+ DUP ,&lp JCN
+ POP2 ( x y nibble counter -- x y )
+ SWP #04 SUB SWP ( restore x coord )
+ JMP2r
+
+( 4x4 sprite output from the short )
+( x y sprval* -- x y )
+@sprite4
+ SWP2 OVR2 ( sprval* x y sprval* -- )
+ ( line 1 )
+ #0c SFT2 NIP ( sprval* x y nibble -- )
+ ;line4 JSR2 ( sprval* x y -- )
+ ( line 2 )
+ INC ( increment y coord )
+ OVR2 ( sprval* x y sprval* -- )
+ #08 SFT2 NIP #0f AND ( sprval* x y nibble -- )
+ ;line4 JSR2 ( sprval* x y -- )
+ ( line 3 )
+ INC ( increment y coord )
+ OVR2 ( sprval* x y sprval* -- )
+ #04 SFT2 NIP #0f AND ( sprval* x y nibble -- )
+ ;line4 JSR2 ( sprval* x y -- )
+ ( line 4 )
+ INC ( increment y coord )
+ OVR2 ( sprval* x y sprval* -- )
+ NIP #0f AND ( sprval* x y nibble -- )
+ ;line4 JSR2 ( sprval* x y -- )
+ #03 SUB ( restore y coord )
+ SWP2 POP2 ( x y -- )
+ JMP2r
+
+( nanofont character sprite output )
+( x y char -- x y )
+@drawc
+ CHAR-TO-NF LDA2 ;sprite4 JSR2
+ JMP2r
+( same as drawc but auto increment x coord )
+@putc
+ ;drawc JSR2
+ SWP #04 ADD SWP
+ JMP2r
+
+@draw-str ( s* -> )
+ &loop LDAk #00 EQU ,&eof JCN ( did we reach \0 ? )
+ LDAk ;putc JSR2 INC2 ,&loop JMP ( no so emit a char and repeat )
+ &eof POP2 JMP2r ( yes so return )
+
+( nanofont glyphs for ESOP, courtesy of Michaelangel007 )
+
+@nanofont 0000 4400 aa00 aee0 64c4 ce60 4c60 4000 4840 4240 6600 4e40 0088 0e00 0080 2480 4a40 8440 c460 e6e0 ae20 64c0 8ee0 e220 6ec0 ee20 4040 0448 4840 e0e0 4240 6240 cc20 4ea0 cee0 6860 cac0 ece0 ec80 cae0 aea0 4440 22c0 aca0 88e0 eea0 eaa0 eae0 ee80 eac0 cea0 64c0 e440 aae0 aa40 aee0 a4a0 a440 e4e0 c8c0 8420 6260 4a00 00e0 8400 04c0 8cc0 0cc0 4cc0 08c0 4880 0ccc 8cc0 0880 0448 8ca0 8840 0ce0 0ca0 0cc0 0cc8 0cc4 0c80 0480 4c60 0ae0 0a40 0e60 0cc0 0ae2 0840 6c60 4444 c6c0 6c00 a4a4
diff --git a/tal-lib/esop-lib.tal b/tal-lib/esop-lib.tal
@@ -1,66 +0,0 @@
-( ESOP stdlib, macro part )
-
-|00 @Control [ &framevec $2 &io $2 &random $1 &status $1 &sound $1 &syscall $1 ]
-
-( control block macros )
-
-%SETSCRVEC { .Control/framevec DEO2 }
-%INKEY { .Control/io DEI2 }
-%PXL { .Control/io DEO2 }
-%PXLk { DUP2 PXL }
-%RND { .Control/random DEI }
-%STACKTRACE { #ff .Control/random DEO }
-%DEVSTAT { .Control/status DEI }
-%SND { .Control/sound DEO }
-%SYS { .Control/syscall DEO }
-
-( some syscall macros )
-
-%HLT { #1f SYS }
-( val -- )
-%DBG { #20 SYS SYS }
-( val -- val )
-%DBGBYTE { DUP DBG }
-( val* -- val* )
-%DBGSHORT { DUP2 SWP DBG DBG }
-
-( input helper macros )
-
-%KP-0 { #0001 }
-%KP-1 { #0002 }
-%KP-2 { #0004 }
-%KP-3 { #0008 }
-%KP-4 { #0010 }
-%KP-5 { #0020 }
-%KP-6 { #0040 }
-%KP-7 { #0080 }
-%KP-8 { #0100 }
-%KP-9 { #0200 }
-%KP-A { #0400 }
-%KP-B { #0800 }
-%KP-C { #1000 }
-%KP-D { #2000 }
-%KP-STAR { #4000 }
-%KP-HASH { #8000 }
-
-( jump to label or subroutine if a particular key is pressed )
-( label* keymask* -- )
-%JMPKEY { INKEY AND2 ORA ROT ROT JCN2 }
-%JSRKEY { INKEY AND2 SWP2 JSR2 }
-
-( misc macros )
-
-( byte to short )
-%BTS { #00 SWP }
-
-( decrement )
-%DEC { #01 SUB }
-
-( get the bit or the nibble of a specific number )
-( val bitnum -- bit )
-%GETBIT { SFT #01 AND }
-( val* bitnum -- bit )
-%GETBIT2 { SFT2 #0001 AND2 NIP }
-( val* nibnum -- nibble )
-%GETNIBBLE { #20 SFT SFT2 #000f AND2 NIP }
-
diff --git a/tal-lib/font.tal b/tal-lib/font.tal
@@ -1,4 +1,4 @@
-~esop-lib.tal
+~esop-lib-macro.tal
|0100
;on-frame SETSCRVEC
@@ -23,74 +23,8 @@ BRK
INC
BRK
-( sprite and text drawing routines )
-( subtract #20 from the ASCII code and get the absolute offset from the nanofont label )
-%CHAR-TO-NF { #20 SUB BTS #10 SFT2 ;nanofont ADD2 }
-( 4x1 scanline output from the nibble )
-( x y nibble -- x y )
-@line4
- #04 ( x y nibble counter -- )
- &lp
- DEC ( first effective counter value is 3 )
- DUP2 ( x y nibble counter nibble counter -- )
- GETBIT ( x y nibble counter bit -- )
- ,&dpxl JCN
- ,&skip JMP
- &dpxl ( x y nibble counter -- )
- SWP2 PXLk SWP2
- &skip ( x y nibble counter -- )
- SWP2 SWP ( nibble counter y x -- )
- INC ( increment x coord )
- SWP SWP2 ( x y nibble counter -- )
- DUP ,&lp JCN
- POP2 ( x y nibble counter -- x y )
- SWP #04 SUB SWP ( restore x coord )
- JMP2r
+( include ESOP stdlib routines )
-( 4x4 sprite output from the short )
-( x y sprval* -- x y )
-@sprite4
- SWP2 OVR2 ( sprval* x y sprval* -- )
- ( line 1 )
- #0c SFT2 NIP ( sprval* x y nibble -- )
- ;line4 JSR2 ( sprval* x y -- )
- ( line 2 )
- INC ( increment y coord )
- OVR2 ( sprval* x y sprval* -- )
- #08 SFT2 NIP #0f AND ( sprval* x y nibble -- )
- ;line4 JSR2 ( sprval* x y -- )
- ( line 3 )
- INC ( increment y coord )
- OVR2 ( sprval* x y sprval* -- )
- #04 SFT2 NIP #0f AND ( sprval* x y nibble -- )
- ;line4 JSR2 ( sprval* x y -- )
- ( line 4 )
- INC ( increment y coord )
- OVR2 ( sprval* x y sprval* -- )
- NIP #0f AND ( sprval* x y nibble -- )
- ;line4 JSR2 ( sprval* x y -- )
- #03 SUB ( restore y coord )
- SWP2 POP2 ( x y -- )
- JMP2r
-
-( nanofont character sprite output )
-( x y char -- x y )
-@drawc
- CHAR-TO-NF LDA2 ;sprite4 JSR2
- JMP2r
-( same as drawc but auto increment x coord )
-@putc
- ;drawc JSR2
- SWP #04 ADD SWP
- JMP2r
-
-@draw-str ( s* -> )
- &loop LDAk #00 EQU ,&eof JCN ( did we reach \0 ? )
- LDAk ;putc JSR2 INC2 ,&loop JMP ( no so emit a char and repeat )
- &eof POP2 JMP2r ( yes so return )
-
-( nanofont glyphs for ESOP, courtesy of Michaelangel007 )
-
-@nanofont 0000 4400 aa00 aee0 64c4 ce60 4c60 4000 4840 4240 6600 4e40 0088 0e00 0080 2480 4a40 8440 c460 e6e0 ae20 64c0 8ee0 e220 6ec0 ee20 4040 0448 4840 e0e0 4240 6240 cc20 4ea0 cee0 6860 cac0 ece0 ec80 cae0 aea0 4440 22c0 aca0 88e0 eea0 eaa0 eae0 ee80 eac0 cea0 64c0 e440 aae0 aa40 aee0 a4a0 a440 e4e0 c8c0 8420 6260 4a00 00e0 8400 04c0 8cc0 0cc0 4cc0 08c0 4880 0ccc 8cc0 0880 0448 8ca0 8840 0ce0 0ca0 0cc0 0cc8 0cc4 0c80 0480 4c60 0ae0 0a40 0e60 0cc0 0ae2 0840 6c60 4444 c6c0 6c00 a4a4
+~esop-lib-subs.tal