esop

Essential Stack-Operated Phone (concept)
git clone git://git.luxferre.top/esop.git
Log | Files | Refs | README | LICENSE

commit 6fedde4634251c86aae094943d75d8f5aa1a21ba
parent 948b81084a6e8daebff3bbb095f34e5947402b4c
Author: Luxferre <lux@ferre>
Date:   Wed,  3 Aug 2022 21:51:07 +0300

Decimal short output successful

Diffstat:
Mtal-lib/esop-lib-subs.tal | 89+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mtal-lib/moveme.tal | 23+++++++++++++++++++++--
2 files changed, 108 insertions(+), 4 deletions(-)

diff --git a/tal-lib/esop-lib-subs.tal b/tal-lib/esop-lib-subs.tal @@ -56,9 +56,24 @@ CHAR-TO-NF LDA2 ;sprite4 JSR2 JMP2r -@putc ( same as drawc but auto increment x coord ) +( same as drawc but auto increment x coord ) +@putc ( x y char -- x y ) ;drawc JSR2 - SWP #04 ADD SWP + SWP ( y x -- ) + #04 ADD + SWP ( x y -- ) + JMP2r + +( same as drawc but auto increment x coord and correct x and y coords if it's outside the screen ) +@putc-wrapover-xy ( x y char -- x y ) + ;drawc JSR2 + SWP ( y x -- ) + #04 ADD + DUP #51 LTH ( y x flg -- ) + ,&skp JCN + POP #04 ADD #00 ( replace x coord with 0 and add 4 to y coord ) + &skp + SWP ( x y -- ) JMP2r ( output a complete null-terminated string at x y ) @@ -75,8 +90,23 @@ INC2 ,&loop JMP &eof POP2 JMP2r +( output a complete null-terminated string at x y with auto line breaks ) +@draw-long-str ( x y s* -- x y ) + &loop + LDAk ( x y s* c -- ) + #00 EQU ,&eof JCN ( eof on #00 ) + ( x y s* -- ) + LDAk ( x y s* c -- ) + ROT ROT ( x y c s* -- ) + STH2 ( x y c -- ) + ;putc-wrapover-xy JSR2 ( x y -- ) + STH2r ( x y s* ) + INC2 ,&loop JMP + &eof POP2 JMP2r + ( draw decimal short ) @print-dec ( x y value* -- x y ) + #00 ,&sflag STR SWP2 ,&coords STR2 ( value* -- ) #2710 ,&parse JSR #03e8 ,&parse JSR @@ -88,11 +118,66 @@ &parse DIV2k ( value* divisor* -- value* divisor* div* ) DUP ( value* divisor* div* divlonib -- ) + DUP #00 EQU ,&sk JCN + #01 ,&sflag STR + &sk ,&emit JSR ( value* divisor* div* -- ) MUL2 ( value* divisor* div* -- value* wholevalue* ) SUB2 ( value* wholevalue* -- rem* ) JMP2r &emit + ,&sflag LDR ,&nsk JCN + POP JMP2r + &nsk + #30 ADD + ,&coords LDR2 + ROT + ;putc JSR2 + ,&coords STR2 + JMP2r + LIT &coords $2 + LIT &sflag $1 + +( draw decimal byte ) +@print-dec-byte ( x y value -- x y ) + ROT ROT ,&coords STR2 ( value -- ) + #64 ,&parse JSR + #0a ,&parse JSR + ,&emit JSR + ,&coords LDR2 + JMP2r + &parse + DIVk ( value divisor -- value divisor div ) + DUP ( value divisor div div -- ) + ,&emit JSR ( value divisor div -- ) + MUL ( value divisor div -- value wholevalue ) + SUB ( value wholevalue -- rem ) + JMP2r + &emit + #30 ADD + ,&coords LDR2 + ROT + ;putc JSR2 + ,&coords STR2 + JMP2r + LIT &coords $2 + +( draw decimal byte limited to 2 digits ) +@print-dec2-byte ( x y value -- x y ) + ROT ROT ,&coords STR2 ( value -- ) + #64 DIVk MUL SUB + #0a ,&parse JSR + ,&emit JSR + ,&coords LDR2 + JMP2r + &parse + DIVk ( value divisor -- value divisor div ) + DUP ( value divisor div div -- ) + ,&emit JSR ( value divisor div -- ) + MUL ( value divisor div -- value wholevalue ) + SUB ( value wholevalue -- rem ) + JMP2r + &emit #30 ADD ,&coords LDR2 ROT diff --git a/tal-lib/moveme.tal b/tal-lib/moveme.tal @@ -8,13 +8,30 @@ BRK @on-frame + ( drawing static strings should always end with POP2 ) + #00 #04 ;longtxt ;draw-long-str JSR2 POP2 DATETIME-COMPAT ( get datetime info into #00c0 ) - #10 #12 ( year-x year-y -- ) + #04 #12 ( year-x year-y -- ) .DateTime/year LDZ2 ( year-x year-y year* -- ) ;print-dec JSR2 ( mv-x mv-y year-x year-y -- ) + LIT '. ;putc JSR2 + .DateTime/month LDZ + ;print-dec2-byte JSR2 + LIT '. ;putc JSR2 + .DateTime/day LDZ + ;print-dec2-byte JSR2 + POP2 ( mv-x mv-y -- ) + #04 #16 ( hms-x hms-y -- ) + .DateTime/hour LDZ + ;print-dec2-byte JSR2 + LIT ': ;putc JSR2 + .DateTime/minute LDZ + ;print-dec2-byte JSR2 + LIT ': ;putc JSR2 + .DateTime/second LDZ + ;print-dec2-byte JSR2 POP2 ( mv-x mv-y -- ) ;moveme ;draw-str JSR2 - ( drawing static strings should always end with POP2 ) #02 #2b ;addr ;draw-str JSR2 POP2 SWP #20 SUB SWP ( restore x coord between frames ) ;&adv KP-A JMPKEY @@ -31,6 +48,8 @@ BRK @addr "SR.HT/~LUXFERRE/ESOP 00 +@longtxt "HELLO 20 "FROM 20 "ESOP, 20 "NEW 20 "PHONE 20 "RUNTIME 00 + ( include ESOP stdlib routines ) ~esop-lib-subs.tal