(icnsix) Helper funcitons

This commit is contained in:
neauoire 2023-10-28 20:24:37 -07:00
parent a1461fd46a
commit 2c237005d3
1 changed files with 37 additions and 4 deletions

View File

@ -17,18 +17,19 @@
BRK }
POP
( | get size )
;src scap #0009 SUB2 get-size
;src scap #0009 SUB2 parse-size
( h ) ;img/height STA
( w ) ;img/width STA
( | load data )
( | get data )
;src .File/name DEO2
#00 ;img/width LDA #00 ;img/height LDA #30 SFT2 MUL2 .File/length DEO2
;img/data .File/read DEO2
<convert>
#010e DEO
#010f DEO
BRK
@get-size ( 00x00* -- w h )
@parse-size ( 00x00* -- w h )
DUP2 sbyte #00 EQU ?&cancel
INC2k INC2 LDA LIT "x NEQ ?&cancel
INC2k INC2 INC2 sbyte #00 EQU ?&cancel
@ -36,6 +37,37 @@
( x ) sbyte STHr JMP2r
&cancel POP2 #0000 JMP2r
(
@| core )
@<convert> ( -- )
#00 ;img/height LDA #30 SFT2 #0000
&v ( -- )
STH2k
#00 ;img/width LDA #30 SFT2 #0000
&w ( -- )
DUP2 STH2kr get-pixel phex/b #2018 DEO
INC2 GTH2k ?&w
POP2 POP2
POP2r
INC2 GTH2k ?&v
POP2 POP2
JMP2r
@get-row ( x* y* -- row* )
STH2k
( ) #03 SFT2 SWP2
( ) #03 SFT2 SWP2
( ) #00 ;img/width LDA MUL2 ADD2 #30 SFT2
( ) STH2r #0007 AND2 ADD2
( ) ;img/data ADD2 JMP2r
@get-pixel ( x* y* -- b )
( keep x* ) OVR2 NIP #07 AND STH
( get byte ) get-row LDA
( flag ) #07 STHr SUB SFT #01 AND JMP2r
(
@|stdlib )
@ -68,7 +100,8 @@
(
@|memory )
@img &size &width $1
@img ( )
&size &width $1
&height $1
&data