Decimal short output successful

This commit is contained in:
Luxferre
2022-08-03 21:51:07 +03:00
parent 948b81084a
commit 6fedde4634
2 changed files with 108 additions and 4 deletions
+87 -2
View File
@@ -56,9 +56,24 @@
CHAR-TO-NF LDA2 ;sprite4 JSR2 CHAR-TO-NF LDA2 ;sprite4 JSR2
JMP2r 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 ;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 JMP2r
( output a complete null-terminated string at x y ) ( output a complete null-terminated string at x y )
@@ -75,8 +90,23 @@
INC2 ,&loop JMP INC2 ,&loop JMP
&eof POP2 JMP2r &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 ) ( draw decimal short )
@print-dec ( x y value* -- x y ) @print-dec ( x y value* -- x y )
#00 ,&sflag STR
SWP2 ,&coords STR2 ( value* -- ) SWP2 ,&coords STR2 ( value* -- )
#2710 ,&parse JSR #2710 ,&parse JSR
#03e8 ,&parse JSR #03e8 ,&parse JSR
@@ -88,10 +118,65 @@
&parse &parse
DIV2k ( value* divisor* -- value* divisor* div* ) DIV2k ( value* divisor* -- value* divisor* div* )
DUP ( value* divisor* div* divlonib -- ) DUP ( value* divisor* div* divlonib -- )
DUP #00 EQU ,&sk JCN
#01 ,&sflag STR
&sk
,&emit JSR ( value* divisor* div* -- ) ,&emit JSR ( value* divisor* div* -- )
MUL2 ( value* divisor* div* -- value* wholevalue* ) MUL2 ( value* divisor* div* -- value* wholevalue* )
SUB2 ( value* wholevalue* -- rem* ) SUB2 ( value* wholevalue* -- rem* )
JMP2r 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 &emit
#30 ADD #30 ADD
,&coords LDR2 ,&coords LDR2
+21 -2
View File
@@ -8,13 +8,30 @@
BRK BRK
@on-frame @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 ) 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* -- ) .DateTime/year LDZ2 ( year-x year-y year* -- )
;print-dec JSR2 ( mv-x mv-y year-x year-y -- ) ;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 -- ) POP2 ( mv-x mv-y -- )
;moveme ;draw-str JSR2 ;moveme ;draw-str JSR2
( drawing static strings should always end with POP2 )
#02 #2b ;addr ;draw-str JSR2 POP2 #02 #2b ;addr ;draw-str JSR2 POP2
SWP #20 SUB SWP ( restore x coord between frames ) SWP #20 SUB SWP ( restore x coord between frames )
;&adv KP-A JMPKEY ;&adv KP-A JMPKEY
@@ -31,6 +48,8 @@ BRK
@addr "SR.HT/~LUXFERRE/ESOP 00 @addr "SR.HT/~LUXFERRE/ESOP 00
@longtxt "HELLO 20 "FROM 20 "ESOP, 20 "NEW 20 "PHONE 20 "RUNTIME 00
( include ESOP stdlib routines ) ( include ESOP stdlib routines )
~esop-lib-subs.tal ~esop-lib-subs.tal