fix major stack bug

This commit is contained in:
~d6 2023-01-23 20:54:52 -05:00
parent a58b0f1133
commit 5366902b51
1 changed files with 51 additions and 18 deletions

View File

@ -23,6 +23,7 @@
|10 @Console [ &vect $2 &r $1 &pad $5 &w $1 ]
|20 @Screen [ &vect $2 &w $2 &h $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
|80 @Controller [ &vect $2 &button $1 &key $1 &fn $1 ]
|a0 @File [ &vect $2 &ok $2 &stat $2 &del $1 &append $1 &name $2 &len $2 &r $2 &w $2 ]
|0000
@tint $1 ( draw mode. 01=regular, 04=inverted )
@ -68,7 +69,10 @@
;on-key .Controller/vect DEO2 ( set up keyboard )
;on-read .Console/vect DEO2 ( set up stdin )
( return )
( set up debug log )
;debug .File/name DEO2
#01 .File/append DEO
BRK
@first-addr ( -> )
@ -164,8 +168,8 @@
,ctrl? JSR ,on-ctrl-key JCN
.Controller/key DEI .Console/w DEO BRK
@ctrl? ( -> down? ) .Controller/button DEI #01 AND JMP2r
@alt? ( -> down? ) .Controller/button DEI #02 AND JMP2r
@ctrl? ( -> is-down? ) .Controller/button DEI #01 AND JMP2r
@alt? ( -> is-down? ) .Controller/button DEI #02 AND JMP2r
( alt-XYZ emits ESC and then emits XYZ )
@on-alt-key ( -> )
@ -192,8 +196,22 @@
DUP LIT "9 GTH ;end-arg JCN2
;add-to-arg JMP2
@debug-seq ( c^ -> )
;scratch STH2
LIT "1 STH2kr STA INC2r
LIT "b STH2kr STA INC2r
#20 STH2kr STA INC2r
LIT "[ STH2kr STA INC2r
#20 STH2kr STA INC2r
STH2kr STA INC2r
#0a STH2r STA
#0007 .File/len DEO2
;scratch .File/w DEO2
JMP2r
@end-arg ( c^ -> )
;on-read .Console/vect DEO2
DUP ,debug-seq JSR
DUP LIT "h EQU ;exec-noop JCN2 ( enable line wrap )
DUP LIT "l EQU ;exec-noop JCN2 ( disable line wrap )
DUP LIT "m EQU ;exec-noop JCN2 ( set attr )
@ -273,8 +291,20 @@
#0001 ;read-arg-2 JSR2 #0001 SUB2 ( col )
;goto JSR2 BRK
@debug-esc ( c^ -> )
;scratch STH2
LIT "1 STH2kr STA INC2r
LIT "b STH2kr STA INC2r
#20 STH2kr STA INC2r
STH2kr STA INC2r
#0a STH2r STA
#0005 .File/len DEO2
;scratch .File/w DEO2
JMP2r
@on-read-esc ( -> )
.Console/r DEI LIT "[ EQU ;start-seq JCN2
.Console/r DEI ,debug-esc JSR
;on-read .Console/vect DEO2
;on-read JMP2
@ -287,7 +317,7 @@
.Console/r DEI
DUP ,&ok JCN POP BRK
&ok #41 .tint STZ
;read JSR2 BRK
;read JMP2
@read ( c^ -> )
DUP #20 LTH ;read-ctrl JCN2
@ -303,7 +333,7 @@
DUP #1b EQU ;read-esc JCN2
@read-bel ( 07 -> )
POP JMP2r ( TODO: flash terminal )
POP BRK ( TODO: flash terminal )
@read-bs ( 08 -> )
POP
@ -316,7 +346,7 @@
POP ;on-read-esc .Console/vect DEO2 BRK
@read-del ( 7f -> )
POP JMP2r
POP BRK
( @read-tab POP JMP2r )
@read-tab
@ -330,19 +360,19 @@
POP JMP2r
@read-cr ( 0d -> )
POP ;hide-cursor JSR2 #0000 .cur-x STZ2 JMP2r
POP ;hide-cursor JSR2 #0000 .cur-x STZ2 BRK
@at-max-y ( -> true? )
.cur-y LDZ2 .max-y LDZ2 EQU2 JMP2r
@read-nl ( 0a -> )
POP ;hide-cursor JSR2
,at-max-y JSR ;scroll JCN2 ;down JMP2
,at-max-y JSR ;scroll JCN2 ;down JSR2 BRK
@read-printable ( c -> )
DUP ;cursor-addr JSR2 STA
;draw-tile JSR2
;forward JMP2
;forward JSR2 BRK
@goto ( y* x* -> )
;hide-cursor JSR2
@ -389,7 +419,7 @@
INC2r GTH2kr STHr ,&loop JCN
POP2r POP2r
#01 .dirty? STZ
;show-cursor JMP2
;show-cursor JSR2 BRK
@cursor-addr ( -> addr* )
.cur-y LDZ2 .cols LDZ2 MUL2
@ -447,6 +477,9 @@
INCr STHkr ,&loop JCN
POPr POP2 POP2 JMP2r
@debug "debug_term.log 00
@scratch $40
( store up to 8 arguments for control sequences )
@args $10 &pos $2