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
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,10 +118,65 @@
&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