Automated pop on cond?

This commit is contained in:
neauoire 2021-03-15 15:27:43 -07:00
parent c92b2009a3
commit 82d1c276f9
15 changed files with 189 additions and 162 deletions

View File

@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
# run
./bin/assembler projects/examples/dev.controller.usm bin/boot.rom
./bin/assembler projects/software/left.usm bin/boot.rom
./bin/emulator bin/boot.rom

View File

@ -42,7 +42,7 @@ RTN
@blink-cursor
,skip ~timer #10 LTH JMP2? POP2
,skip ~timer #10 LTH JMP2?
#00 =timer
~blink #00 EQU =blink
,cursor =Sprite.addr
@ -61,9 +61,9 @@ RTN
$hor
( draw ) ~color =Sprite.color
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
,$hor ~Sprite.x ~rect.x2 LTH2 JMP2? POP2
,$hor ~Sprite.x ~rect.x2 LTH2 JMP2?
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
,$ver ~Sprite.y ~rect.y2 LTH2 JMP2? POP2
,$ver ~Sprite.y ~rect.y2 LTH2 JMP2?
RTN
@ -75,9 +75,9 @@ RTN
$hor
( draw ) ~color =Screen.color
( incr ) ~Screen.x #0001 ADD2 =Screen.x
,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
,$hor ~Screen.x ~rect.x2 LTH2 JMP2?
( incr ) ~Screen.y #0001 ADD2 =Screen.y
,$ver ~Screen.y ~rect.y2 LTH2 JMP2? POP2
,$ver ~Screen.y ~rect.y2 LTH2 JMP2?
RTN
@ -88,13 +88,13 @@ RTN
( incr ) ~Screen.x #0001 ADD2 =Screen.x
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
,$hor ~Screen.x ~rect.x2 LTH2 JMP2?
~rect.y1 =Screen.y
$ver
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
( incr ) ~Screen.y #0001 ADD2 =Screen.y
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2?
RTN
@ -105,14 +105,14 @@ RTN
$loop
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~textarea.color =Sprite.color
( detect linebreaks )
DUP2 LDR #0d NEQ ,$no-return ROT JMP2? POP2
DUP2 LDR #0d NEQ ,$no-return ROT JMP2?
~textarea.x1 =Sprite.x
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
( decr ) ~Sprite.x #0008 SUB2 =Sprite.x
$no-return
( incr ) #0001 ADD2
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
DUP2 LDR #00 NEQ ,$loop ROT JMP2?
POP2
RTN
@ -120,10 +120,10 @@ RTN
@do-textarea
( ,blink-cursor JSR2 )
,do-textarea-end ~Keys #00 EQU JMP2? POP2 ( skip on no key )
,do-textarea-end ~Keys #00 EQU JMP2? ( skip on no key )
( backspace )
,any-key ~Keys #08 NEQ JMP2? POP2
,input-end ~textarea.cursor #00 EQU JMP2? POP2
,any-key ~Keys #08 NEQ JMP2?
,input-end ~textarea.cursor #00 EQU JMP2?
( decr ) ~textarea.cursor #01 SUB =textarea.cursor
#00 ~textarea.addr #00 ~textarea.cursor ADD2 STR
,input-end JMP2
@ -142,7 +142,7 @@ RTN
@do-cursor
,skip-drag ~Mouse.state #01 NEQ JMP2? POP2
,skip-drag ~Mouse.state #01 NEQ JMP2?
~mouse.x =textarea.x1 ~mouse.y =textarea.y1
,redraw-window JSR2
,redraw JSR2

View File

@ -22,23 +22,23 @@ BRK
,draw-cursor JSR2
( reset timer -> move cat tail )
,no-click ~Mouse.state #00 EQU JMP2? POP2
,no-click ~Mouse.state #00 EQU JMP2?
#50 =timer
@no-click
( detect click )
,no-click12 ~Mouse.state #11 NEQ JMP2? POP2
,no-click12 ~Mouse.state #11 NEQ JMP2?
#0058 #0040 #01 ,mouse12_text ,draw-label JSR2
#10 ,cursor_icn ~pointer.x ~pointer.y ,draw-sprite JSR2
~color ,mouse12_icn #0048 #0040 ,draw-sprite JSR2
,end-click JMP2
@no-click12
,no-click1 ~Mouse.state #01 NEQ JMP2? POP2
,no-click1 ~Mouse.state #01 NEQ JMP2?
#0058 #0040 #01 ,mouse1_text ,draw-label JSR2
#12 ,cursor_icn ~pointer.x ~pointer.y ,draw-sprite JSR2
~color ,mouse1_icn #0048 #0040 ,draw-sprite JSR2
,end-click JMP2
@no-click1
,no-click2 ~Mouse.state #10 NEQ JMP2? POP2
,no-click2 ~Mouse.state #10 NEQ JMP2?
#0058 #0040 #01 ,mouse2_text ,draw-label JSR2
#13 ,cursor_icn ~pointer.x ~pointer.y ,draw-sprite JSR2
~color ,mouse2_icn #0048 #0040 ,draw-sprite JSR2
@ -91,18 +91,18 @@ RTN
@animate-polycat
( tail )
~timer #50 NEQ ,animate-polycat-tail-next0 ROT JMP2? POP2
~timer #50 NEQ ,animate-polycat-tail-next0 ROT JMP2?
,polycat #00c0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR2
@animate-polycat-tail-next0
~timer #58 NEQ ,animate-polycat-tail-next1 ROT JMP2? POP2
~timer #58 NEQ ,animate-polycat-tail-next1 ROT JMP2?
,polycat #00d0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR2
@animate-polycat-tail-next1
~timer #60 NEQ ,animate-polycat-tail-next2 ROT JMP2? POP2
~timer #60 NEQ ,animate-polycat-tail-next2 ROT JMP2?
,polycat #00b0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR2
@animate-polycat-tail-next2
( look-at )
~pointer.x ~cat.x #0008 ADD2 GTH2 ,animate-polycat-right ROT JMP2? POP2
~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-left-down ROT JMP2? POP2
~pointer.x ~cat.x #0008 ADD2 GTH2 ,animate-polycat-right ROT JMP2?
~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-left-down ROT JMP2?
,polycat #0040 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
,polycat #0050 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
RTN
@ -111,7 +111,7 @@ RTN
,polycat #0030 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
RTN
@animate-polycat-right
~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-right-down ROT JMP2? POP2
~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-right-down ROT JMP2?
,polycat #0060 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
,polycat #0070 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
RTN
@ -130,7 +130,7 @@ RTN
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
( incr ) #0001 ADD2
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
DUP2 #0001 ADD2 LDR #00 NEQ ,$loop ROT JMP2? POP2
DUP2 #0001 ADD2 LDR #00 NEQ ,$loop ROT JMP2?
POP2
RTN

View File

@ -15,7 +15,7 @@
$draw-hor NOP
( draw ) #01 =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.x SWP2
OVR2 OVR2 LTH2 ^$draw-hor SWP JMPS? POP
OVR2 OVR2 LTH2 ^$draw-hor SWP JMPS?
POP2 POP2
( draw ver line )
@ -24,7 +24,7 @@
$draw-ver NOP
( draw ) #02 =Screen.color
( incr ) SWP2 #0002 ADD2 DUP2 =Screen.y SWP2
OVR2 OVR2 LTH2 ^$draw-ver SWP JMPS? POP
OVR2 OVR2 LTH2 ^$draw-ver SWP JMPS?
POP2 POP2
( draw blending modes )
@ -34,7 +34,7 @@
( move ) OVR #00 SWP #0008 MUL2 #0020 ADD2 =Sprite.x
( draw ) OVR =Sprite.color
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-blends SWP JMPS? POP
DUP2 LTH ^$draw-blends SWP JMPS?
POP POP
BRK
@ -42,16 +42,16 @@ BRK
@FRAME
( update colors every 40 frames )
~timer #40 NEQ ,skip1 ROT JMP2? POP2
~timer #40 NEQ ,skip1 ROT JMP2?
#0fac #fffa STR2 #f0bb #fffc STR2 #f053 #fff8 STR2
@skip1
~timer #80 NEQ ,skip2 ROT JMP2? POP2
~timer #80 NEQ ,skip2 ROT JMP2?
#00fc #fffc STR2 #f0bb #fff8 STR2 #f053 #fffa STR2
@skip2
~timer #c0 NEQ ,skip3 ROT JMP2? POP2
~timer #c0 NEQ ,skip3 ROT JMP2?
#000f #fff8 STR2 #0f0f #fffa STR2 #ff00 #fffc STR2
@skip3
~timer #00 NEQ ,skip4 ROT JMP2? POP2
~timer #00 NEQ ,skip4 ROT JMP2?
#f0ac #fff8 STR2 #f0bb #fffa STR2 #f053 #fffc STR2
@skip4
~timer #01 ADD =timer

View File

@ -26,15 +26,15 @@ BRK
@FRAME
,no-ctrl ~Controller.buttons #00 EQU JMP2? POP2
,no-ctrl ~Controller.buttons #00 EQU JMP2?
,no-ctrl-up ~Controller.buttons #10 EQU JMP2? POP2
,no-ctrl-up ~Controller.buttons #10 EQU JMP2?
~editor.addr #0001 ADD2 =editor.addr
,draw-window JSR2
,draw-editor JSR2
@no-ctrl-up
,no-ctrl-down ~Controller.buttons #20 EQU JMP2? POP2
,no-ctrl-down ~Controller.buttons #20 EQU JMP2?
~editor.addr #0001 SUB2 =editor.addr
,draw-window JSR2
,draw-editor JSR2
@ -42,7 +42,7 @@ BRK
@no-ctrl
,no-click ~Mouse.state #00 EQU JMP2? POP2
,no-click ~Mouse.state #00 EQU JMP2?
( load ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 LDR
( mask ) #01 #07 ~Mouse.x ~editor.x1 SUB2 #0008 DIV2 SWP POP SUB ROL
@ -85,10 +85,10 @@ RTN
( draw ) #08 =Sprite.color
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
( incr ) ~pixel.x #01 ADD =pixel.x
,$hor ~Sprite.x ~editor.x1 #0040 ADD2 LTH2 JMP2? POP2
,$hor ~Sprite.x ~editor.x1 #0040 ADD2 LTH2 JMP2?
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
( incr ) ~pixel.y #01 ADD =pixel.y
,$ver ~Sprite.y ~editor.y1 #0040 ADD2 LTH2 JMP2? POP2
,$ver ~Sprite.y ~editor.y1 #0040 ADD2 LTH2 JMP2?
~editor.addr =Sprite.addr
~window.y1 =Sprite.y
~window.x2 #0008 SUB2 =Sprite.x

View File

@ -28,22 +28,22 @@ BRK
( matrix comparison )
~Mouse.x ~r1.x1 GTH2 ~Mouse.x ~r1.x2 LTH2 #0101 EQU2
~Mouse.y ~r1.y1 GTH2 ~Mouse.y ~r1.y2 LTH2 #0101 EQU2
#0101 NEQ2 ,$draw1 ROT JMP2? POP2 #02 =color ,hand_icn =pointer.sprite
#0101 NEQ2 ,$draw1 ROT JMP2? #02 =color ,hand_icn =pointer.sprite
$draw1 ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR2
#01 =color
( 2-step comparison )
,$draw2 ~Mouse.x ~r2.x1 GTH2 ~Mouse.x ~r2.x2 LTH2 #0101 NEQ2 JMP2? POP2
,$draw2 ~Mouse.y ~r2.y1 GTH2 ~Mouse.y ~r2.y2 LTH2 #0101 NEQ2 JMP2? POP2
,$draw2 ~Mouse.x ~r2.x1 GTH2 ~Mouse.x ~r2.x2 LTH2 #0101 NEQ2 JMP2?
,$draw2 ~Mouse.y ~r2.y1 GTH2 ~Mouse.y ~r2.y2 LTH2 #0101 NEQ2 JMP2?
#03 =color ,hand_icn =pointer.sprite
$draw2 ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR2
#01 =color
( 4-step comparison )
,$draw3 ~Mouse.x ~r3.x1 LTH2 JMP2? POP2
,$draw3 ~Mouse.x ~r3.x2 GTH2 JMP2? POP2
,$draw3 ~Mouse.y ~r3.y1 LTH2 JMP2? POP2
,$draw3 ~Mouse.y ~r3.y2 GTH2 JMP2? POP2
,$draw3 ~Mouse.x ~r3.x1 LTH2 JMP2?
,$draw3 ~Mouse.x ~r3.x2 GTH2 JMP2?
,$draw3 ~Mouse.y ~r3.y1 LTH2 JMP2?
,$draw3 ~Mouse.y ~r3.y2 GTH2 JMP2?
#02 =color ,hand_icn =pointer.sprite
$draw3 ~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR2
@ -77,13 +77,13 @@ RTN
( incr ) ~Screen.x #0001 ADD2 =Screen.x
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
,$hor ~Screen.x ~rect.x2 LTH2 JMP2?
~rect.y1 =Screen.y
$ver
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
( incr ) ~Screen.y #0001 ADD2 =Screen.y
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2?
RTN

View File

@ -16,7 +16,7 @@
$draw-ver
( draw ) #02 =Screen.color
( incr ) ~Screen.y #0002 ADD2 =Screen.y
,$draw-ver ~Screen.y ~Screen.height LTH2 JMP2? POP2
,$draw-ver ~Screen.y ~Screen.height LTH2 JMP2?
~center.x ~center.y #0010 SUB2 #0c ,text1 ,draw-label-left JSR2
~center.x ~center.y #0c ,text2 ,draw-label-middle JSR2
@ -34,7 +34,7 @@ BRK
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
( incr ) #0001 ADD2
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
DUP2 LDR #00 NEQ ,$loop ROT JMP2?
POP2
RTN
@ -48,7 +48,7 @@ RTN
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
( incr ) #0001 ADD2
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
DUP2 LDR #00 NEQ ,$loop ROT JMP2?
POP2
RTN
@ -62,7 +62,7 @@ RTN
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
( incr ) #0001 ADD2
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
DUP2 LDR #00 NEQ ,$loop ROT JMP2?
POP2
RTN
@ -72,7 +72,7 @@ RTN
#0000 ( counter )
$loop
( incr ) #0001 ADD2 OVR2 OVR2 ADD2
LDR #00 NEQ ,$loop ROT JMP2? POP2
LDR #00 NEQ ,$loop ROT JMP2?
SWP2 POP2
RTN

View File

@ -19,9 +19,9 @@ BRK
( draw ) ~pict.color =Sprite.color
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
( incr ) ~Sprite.addr #0008 ADD2 =Sprite.addr
,$hor ~Sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2? POP2
,$hor ~Sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2?
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? POP2
,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2?
RTN

View File

@ -33,13 +33,13 @@ BRK
( incr ) ~Screen.x #0001 ADD2 =Screen.x
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
,$hor ~Screen.x ~rect.x2 LTH2 JMP2?
~rect.y1 =Screen.y
$ver
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
( incr ) ~Screen.y #0001 ADD2 =Screen.y
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2?
RTN
@ -51,9 +51,9 @@ RTN
$hor
( draw ) ~color =Screen.color
( incr ) ~Screen.x #0001 ADD2 =Screen.x
,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
,$hor ~Screen.x ~rect.x2 LTH2 JMP2?
( incr ) ~Screen.y #0001 ADD2 =Screen.y
,$ver ~Screen.y ~rect.y2 LTH2 JMP2? POP2
,$ver ~Screen.y ~rect.y2 LTH2 JMP2?
RTN
@ -66,9 +66,9 @@ RTN
( draw ) ~pict.color =Sprite.color
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
( incr ) ~Sprite.addr #0008 ADD2 =Sprite.addr
,$hor ~Sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2? POP2
,$hor ~Sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2?
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? POP2
,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2?
RTN
@ -79,7 +79,7 @@ RTN
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
( incr ) #0001 ADD2
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
DUP2 LDR #00 NEQ ,$loop ROT JMP2?
POP2
RTN

View File

@ -46,62 +46,62 @@ BRK
( ctrl )
,ctrl-end ~Controller #00 EQU ~lock #00 NEQ #0000 NEQ2 JMP2? POP2
,ctrl-end ~Controller #00 EQU ~lock #00 NEQ #0000 NEQ2 JMP2?
( lock ) #04 =lock
,no-ctrl-up ~Controller #10 NEQ JMP2? POP2
( clamp ) ,no-ctrl-up ~position.y #0000 EQU2 JMP2? POP2
,no-ctrl-up ~Controller #10 NEQ JMP2?
( clamp ) ,no-ctrl-up ~position.y #0000 EQU2 JMP2?
,find-lineoffset JSR2 =position.x
~position.y #0001 SUB2 =position.y
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to
,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-ctrl-up
,no-ctrl-down ~Controller #20 NEQ JMP2? POP2
,no-ctrl-down ~Controller #20 NEQ JMP2?
,find-lineoffset JSR2 =position.x ~position.y #0001 ADD2 =position.y
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to
,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-ctrl-down
,no-ctrl-left ~Controller #40 NEQ JMP2? POP2
( clamp ) ,no-ctrl-left ~selection.from ,document.body EQU2 JMP2? POP2
,no-ctrl-left ~Controller #40 NEQ JMP2?
( clamp ) ,no-ctrl-left ~selection.from ,document.body EQU2 JMP2?
~selection.from #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to
,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-ctrl-left
,no-ctrl-right ~Controller #80 NEQ JMP2? POP2
,no-ctrl-right ~Controller #80 NEQ JMP2?
~selection.from #0001 ADD2 DUP2 =selection.from #0001 ADD2 =selection.to
,clamp-selection JSR2 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-ctrl-right
( alt )
,no-alt ~Controller #0f AND #02 NEQ JMP2? POP2
,no-aup ~Controller #04 ROR #01 NEQ JMP2? POP2
,no-alt ~Controller #0f AND #02 NEQ JMP2?
,no-aup ~Controller #04 ROR #01 NEQ JMP2?
,find-wordstart JSR2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-aup
,no-adown ~Controller #04 ROR #02 NEQ JMP2? POP2
,no-adown ~Controller #04 ROR #02 NEQ JMP2?
,find-wordend JSR2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-adown
,no-aleft ~Controller #04 ROR #04 NEQ JMP2? POP2
,no-aleft ~Controller #04 ROR #04 NEQ JMP2?
~selection.to #0001 SUB2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-aleft
,no-aright ~Controller #04 ROR #08 NEQ JMP2? POP2
,no-aright ~Controller #04 ROR #08 NEQ JMP2?
~selection.to #0001 ADD2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-aright
@no-alt
( ctrl )
,no-ctrl ~Controller #0f AND #01 NEQ JMP2? POP2
,no-cup ~Controller #04 ROR #01 NEQ JMP2? POP2
,no-ctrl ~Controller #0f AND #01 NEQ JMP2?
,no-cup ~Controller #04 ROR #01 NEQ JMP2?
#0004 ,scroll-up JSR2
,redraw JSR2 ,ctrl-end JMP2
@no-cup
,no-cdown ~Controller #04 ROR #02 NEQ JMP2? POP2
,no-cdown ~Controller #04 ROR #02 NEQ JMP2?
#0004 ,scroll-down JSR2
,redraw JSR2 ,ctrl-end JMP2
@no-cdown
,no-cleft ~Controller #04 ROR #04 NEQ JMP2? POP2
,no-cleft ~Controller #04 ROR #04 NEQ JMP2?
,goto-linestart JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-cleft
,no-cright ~Controller #04 ROR #08 NEQ JMP2? POP2
,no-cright ~Controller #04 ROR #08 NEQ JMP2?
,goto-lineend JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-cright
@no-ctrl
@ -110,11 +110,11 @@ BRK
( keys )
,no-keys ~Keys #00 EQU JMP2? POP2
,no-keys ~Keys #00 EQU JMP2?
,$no-backspace ~Keys #08 NEQ JMP2? POP2
,$no-backspace ~Keys #08 NEQ JMP2?
( erase )
,$erase-multiple ~selection.to ~selection.from SUB2 #0001 NEQ2 JMP2? POP2
,$erase-multiple ~selection.to ~selection.from SUB2 #0001 NEQ2 JMP2?
~selection.to ~selection.from SUB2 ,shift-left JSR2
,$erase-end JMP2
$erase-multiple
@ -139,28 +139,28 @@ BRK
( mouse )
,no-change ~Mouse.state ~touch.state EQU JMP2? POP2
,no-change ~Mouse.state ~touch.state EQU JMP2?
#0000 =Sprite.x ~Screen.height #0008 SUB2 =Sprite.y
,mouse00icn =Sprite.addr
,nobutton1 ~Mouse.state #01 NEQ JMP2? POP2 ,mouse01icn =Sprite.addr @nobutton1
,nobutton2 ~Mouse.state #10 NEQ JMP2? POP2 ,mouse10icn =Sprite.addr @nobutton2
,nobutton3 ~Mouse.state #11 NEQ JMP2? POP2 ,mouse11icn =Sprite.addr @nobutton3
,nobutton1 ~Mouse.state #01 NEQ JMP2? ,mouse01icn =Sprite.addr @nobutton1
,nobutton2 ~Mouse.state #10 NEQ JMP2? ,mouse10icn =Sprite.addr @nobutton2
,nobutton3 ~Mouse.state #11 NEQ JMP2? ,mouse11icn =Sprite.addr @nobutton3
#01 =Sprite.color
@no-change
,touch-end ~Mouse.state #00 EQU JMP2? POP2
,touch-end ~Mouse.state #00 EQU JMP2?
,touch-linebar ~Mouse.x #0010 LTH2 JMP2? POP2
,touch-body ~Mouse.x ~Screen.width #0008 SUB2 LTH2 JMP2? POP2
,touch-linebar ~Mouse.x #0010 LTH2 JMP2?
,touch-body ~Mouse.x ~Screen.width #0008 SUB2 LTH2 JMP2?
,touch-scrollbar JMP2
@touch-end
~Mouse.state =touch.state
( unlock ) ,skip-unlock ~lock #00 EQU JMP2? POP2 ~lock #01 SUB =lock @skip-unlock
( unlock ) ,skip-unlock ~lock #00 EQU JMP2? ~lock #01 SUB =lock @skip-unlock
,draw-cursor JSR2
@ -168,11 +168,11 @@ BRK
@touch-scrollbar
,$no-up ~Mouse.y #0008 GTH2 JMP2? POP2
,$no-up ~Mouse.y #0008 GTH2 JMP2?
( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y
^$end JMPS
$no-up
,$no-down ~Mouse.y ~Screen.height #0008 SUB2 LTH2 JMP2? POP2
,$no-down ~Mouse.y ~Screen.height #0008 SUB2 LTH2 JMP2?
( incr ) ~scroll.y #0001 ADD2 =scroll.y
^$end JMPS
$no-down
@ -197,20 +197,20 @@ RTN
~Mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y
~Mouse.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x
,$no-chord-cut ~Mouse.chord #01 NEQ JMP2? POP2
,$no-chord-cut ~Mouse.chord #01 NEQ JMP2?
,cut JSR2
( release ) #00 DUP =Mouse.state =Mouse.chord
^$end JMPS
$no-chord-cut
,$no-chord-paste ~Mouse.chord #10 NEQ JMP2? POP2
,$no-chord-paste ~Mouse.chord #10 NEQ JMP2?
,paste JSR2
( release ) #00 DUP =Mouse.state =Mouse.chord
^$end JMPS
$no-chord-paste
,$end ~Mouse.state #11 EQU JMP2? POP2
,$end ~Mouse.state #11 EQU JMP2?
,$no-drag ~Mouse.state ~touch.state NEQ ~Controller #0f AND #02 NEQ #0101 EQU2 JMP2? POP2
,$no-drag ~Mouse.state ~touch.state NEQ ~Controller #0f AND #02 NEQ #0101 EQU2 JMP2?
( on drag )
,find-selection JSR2 #0001 ADD2 =selection.to
,clamp-selection JSR2
@ -237,7 +237,7 @@ RTN
@scroll-up ( length )
DUP2 ~scroll.y LTH2 ,$clamp ROT JMP2? POP2
DUP2 ~scroll.y LTH2 ,$clamp ROT JMP2?
#0000 =scroll.y POP2 RTN
$clamp
~scroll.y SWP2 SUB2 =scroll.y
@ -277,10 +277,10 @@ RTN
@follow-selection
,$no-up ~position.y ~scroll.y GTH2 JMP2? POP2
,$no-up ~position.y ~scroll.y GTH2 JMP2?
~position.y =scroll.y RTN
$no-up
,$no-down ~position.y ~Screen.height #0010 SUB2 #0008 DIV2 ~scroll.y ADD2 LTH2 JMP2? POP2
,$no-down ~position.y ~Screen.height #0010 SUB2 #0008 DIV2 ~scroll.y ADD2 LTH2 JMP2?
~position.y ~Screen.height #0010 SUB2 #0008 DIV2 SUB2 =scroll.y RTN
$no-down
@ -324,9 +324,9 @@ RTN
~selection.to =j
$loop NOP
( decr ) ~j #0001 SUB2 =j
,$end ~j LDR #20 EQU JMP2? POP2
,$end ~j LDR #0a EQU JMP2? POP2
,$end ~j LDR #0d EQU JMP2? POP2
,$end ~j LDR #20 EQU JMP2?
,$end ~j LDR #0a EQU JMP2?
,$end ~j LDR #0d EQU JMP2?
~j ,document.body GTH2 ^$loop MUL JMPS
$end
( return ) ~j #0001 SUB2
@ -338,9 +338,9 @@ RTN
~selection.to =j
$loop NOP
( incr ) ~j #0001 ADD2 =j
,$end ~j LDR #20 EQU JMP2? POP2
,$end ~j LDR #0a EQU JMP2? POP2
,$end ~j LDR #0d EQU JMP2? POP2
,$end ~j LDR #20 EQU JMP2?
,$end ~j LDR #0a EQU JMP2?
,$end ~j LDR #0d EQU JMP2?
~j ,document.body GTH2 ^$loop MUL JMPS
$end
( return ) ~j #0001 ADD2
@ -352,8 +352,8 @@ RTN
#0000 =j
$loop NOP
( incr ) ~j #0001 ADD2 =j
,$end ~selection.from ~j SUB2 LDR #0a EQU JMP2? POP2
,$end ~selection.from ~j SUB2 LDR #0d EQU JMP2? POP2
,$end ~selection.from ~j SUB2 LDR #0a EQU JMP2?
,$end ~selection.from ~j SUB2 LDR #0d EQU JMP2?
~selection.from ~j SUB2 ,document.body GTH2 ^$loop MUL JMPS
$end
( return ) ~j
@ -364,8 +364,8 @@ RTN
,document.body =j #0000 =pt.y
$loop NOP
,$end ~pt.y ~position.y #0001 SUB2 GTH2 JMP2? POP2
,$no-space ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? POP2
,$end ~pt.y ~position.y #0001 SUB2 GTH2 JMP2?
,$no-space ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2?
( incr ) ~pt.y #0001 ADD2 =pt.y
$no-space
( incr ) ~j #0001 ADD2 =j
@ -380,8 +380,8 @@ RTN
,find-line JSR2 ( find line )
#0000 =pt.x
$loop NOP
,$end ~j ~pt.x ADD2 LDR #0a EQU JMP2? POP2
,$end ~j ~pt.x ADD2 LDR #0d EQU JMP2? POP2
,$end ~j ~pt.x ADD2 LDR #0a EQU JMP2?
,$end ~j ~pt.x ADD2 LDR #0d EQU JMP2?
( incr ) ~pt.x #0001 ADD2 =pt.x
~pt.x ~position.x #0001 SUB2 LTH2 ^$loop MUL JMPS
$end
@ -425,17 +425,17 @@ RTN
,document.body =selection.from #0000 =pt.x #0000 =pt.y
$loop
,$no-space ~selection.from LDR #0a NEQ ~selection.from LDR #0d NEQ #0101 EQU2 JMP2? POP2
,$no-space ~selection.from LDR #0a NEQ ~selection.from LDR #0d NEQ #0101 EQU2 JMP2?
( incr ) ~pt.y #0001 ADD2 =pt.y
#0000 =pt.x
$no-space
,$no-reached ~pt.y ~position.y #0001 SUB2 GTH2 ~pt.x ~position.x #0001 SUB2 GTH2 #0101 NEQ2 JMP2? POP2
,$no-reached ~pt.y ~position.y #0001 SUB2 GTH2 ~pt.x ~position.x #0001 SUB2 GTH2 #0101 NEQ2 JMP2?
~selection.from #0001 ADD2 =selection.to
RTN
$no-reached
( incr ) ~pt.x #0001 ADD2 =pt.x
( incr ) ~selection.from #0001 ADD2 =selection.from
,$loop ~selection.from LDR #00 NEQ JMP2? POP2
,$loop ~selection.from LDR #00 NEQ JMP2?
RTN
@ -507,8 +507,8 @@ RTN
( scroll to position )
#0000 =j ( j is linebreaks )
$find-offset NOP
,$find-offset-end ~scroll.y ~j EQU2 JMP2? POP2
,$no-break ~textarea.addr LDR #0a NEQ ~textarea.addr LDR #0d NEQ #0101 EQU2 JMP2? POP2
,$find-offset-end ~scroll.y ~j EQU2 JMP2?
,$no-break ~textarea.addr LDR #0a NEQ ~textarea.addr LDR #0d NEQ #0101 EQU2 JMP2?
( incr ) ~j #0001 ADD2 =j
$no-break
( incr ) ~textarea.addr #0001 ADD2 =textarea.addr
@ -520,7 +520,7 @@ RTN
$loop
,$end ~Sprite.y ~Screen.height #0010 SUB2 GTH2 JMP2? POP2
,$end ~Sprite.y ~Screen.height #0010 SUB2 GTH2 JMP2?
( get character )
,font #00 ~i LDR #20 SUB #0008 MUL2 ADD2 =Sprite.addr
@ -530,7 +530,7 @@ RTN
~i ~selection.to LTH2 #0101 EQU2
#05 MUL ADD ~i ~selection.from EQU2 ADD =Sprite.color
,$no-linebreak ~i LDR #0a NEQ ~i LDR #0d NEQ #0101 EQU2 JMP2? POP2
,$no-linebreak ~i LDR #0a NEQ ~i LDR #0d NEQ #0101 EQU2 JMP2?
( draw linebreak )
,linebreak_icn =Sprite.addr
( draw ) #02
@ -542,7 +542,7 @@ RTN
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
,font =Sprite.addr
#01 =Sprite.color
,$fill-clear ~Sprite.x ~Screen.width #0008 SUB2 LTH2 JMP2? POP2
,$fill-clear ~Sprite.x ~Screen.width #0008 SUB2 LTH2 JMP2?
( draw line number )
@ -562,7 +562,7 @@ RTN
( incr ) ~i #0001 ADD2 =i
( incr ) ~Sprite.x #0007 ADD2 =Sprite.x
,$loop ~i LDR #00 NEQ JMP2? POP2
,$loop ~i LDR #00 NEQ JMP2?
$end

View File

@ -34,28 +34,28 @@ BRK
( keyboard controls )
,no-key ~KEYS #00 EQU JMP2? POP2
,no-key ~KEYS #00 EQU JMP2?
,no-key ~KEYS #31 LTH JMP2? POP2
,no-key ~KEYS #33 GTH JMP2? POP2
,no-key ~KEYS #31 LTH JMP2?
,no-key ~KEYS #33 GTH JMP2?
( select ) ~KEYS #31 SUB =bankview.mode
( release ) #00 =KEYS
,redraw JSR2
@no-key
,no-ctrl ~CTRL.buttons #00 EQU JMP2? POP2
,no-ctrl ~CTRL.buttons #00 EQU JMP2?
,no-ctrl-up ~CTRL.buttons #10 EQU JMP2? POP2
,no-ctrl-up ~CTRL.buttons #10 EQU JMP2?
~tileview.addr #0080 ADD2 =tileview.addr
@no-ctrl-up
,no-ctrl-down ~CTRL.buttons #20 EQU JMP2? POP2
,no-ctrl-down ~CTRL.buttons #20 EQU JMP2?
~tileview.addr #0080 SUB2 =tileview.addr
@no-ctrl-down
,no-ctrl-left ~CTRL.buttons #40 EQU JMP2? POP2
,no-ctrl-left ~CTRL.buttons #40 EQU JMP2?
~tileview.addr #0008 ADD2 =tileview.addr
@no-ctrl-left
,no-ctrl-right ~CTRL.buttons #80 EQU JMP2? POP2
,no-ctrl-right ~CTRL.buttons #80 EQU JMP2?
~tileview.addr #0008 SUB2 =tileview.addr
@no-ctrl-right
~tileview.addr #0800 DIV2 #0800 MUL2 =bankview.addr
@ -65,28 +65,28 @@ BRK
( mouse controls )
,click-end ~MOUS.state #00 EQU JMP2? POP2
,click-end ~MOUS.state #00 EQU JMP2?
( toolbar )
,no-toolbar-click ~MOUS.y ~bankview.y #0010 SUB2 SUB2 #0008 DIV2 #0000 NEQ2 JMP2? POP2
,no-toolbar-click ~MOUS.y ~bankview.y #0010 SUB2 SUB2 #0008 DIV2 #0000 NEQ2 JMP2?
( brush )
,no-brush-click ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #000d LTH2 JMP2? POP2
,no-brush-click ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #000f GTH2 JMP2? POP2
,no-brush-click ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #000d LTH2 JMP2?
,no-brush-click ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #000f GTH2 JMP2?
( select ) ~mouse.x ~bankview.x SUB2 #0008 DIV2 #000d SUB2 SWP POP =bankview.mode
( release ) #00 =MOUS.state
,redraw JSR2 ,click-end JMP2
@no-brush-click
,no-load-click ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #000e NEQU2 JMP2? POP2
,no-load-click ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #000e NEQU2 JMP2?
( load ) ,filename =FILE.name #0800 =FILE.length ~bankview.addr =FILE.load
( release ) #00 =MOUS.state
,redraw JSR2 ,click-end JMP2
@no-load-click
,no-save-click ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #000f NEQU2 JMP2? POP2
,no-save-click ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #000f NEQU2 JMP2?
( save ) ,filename =FILE.name #0800 =FILE.length ~bankview.addr =FILE.save
( release ) #00 =MOUS.state
,redraw JSR2 ,click-end JMP2
@ -98,9 +98,9 @@ BRK
~MOUS.x ~bankview.x GTH2 ~MOUS.x ~bankview.x #0080 ADD2 LTH2 #0101 EQU2
~MOUS.y ~bankview.y GTH2 ~MOUS.y ~bankview.y #0080 ADD2 LTH2 #0101 EQU2
#0101 NEQ2 ,no-bank-click ROT JMP2? POP2
#0101 NEQ2 ,no-bank-click ROT JMP2?
,not-copy-mode ~bankview.mode #01 NEQ JMP2? POP2
,not-copy-mode ~bankview.mode #01 NEQ JMP2?
#00 =i
@copy-loop NOP
( load ) ~tileview.addr ~i ADD LDR
@ -113,7 +113,7 @@ BRK
,redraw JSR2 ,click-end JMP2
@not-copy-mode
,not-erase-mode ~bankview.mode #02 NEQ JMP2? POP2
,not-erase-mode ~bankview.mode #02 NEQ JMP2?
#00 =i
@erase-loop NOP
#00
@ -137,7 +137,7 @@ BRK
~MOUS.x ~tileview.x GTH2 ~MOUS.x ~tileview.x #0080 ADD2 LTH2 #0101 EQU2
~MOUS.y ~tileview.y GTH2 ~MOUS.y ~tileview.y #0080 ADD2 LTH2 #0101 EQU2
#0101 NEQ2 ,no-tile-click ROT JMP2? POP2
#0101 NEQ2 ,no-tile-click ROT JMP2?
~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0008 MUL2 #0040 DIV2
~MOUS.y ~tileview.y SUB2 #0008 DIV2 #0008 MUL2 #0040 DIV2 #0002 MUL2 ADD2
@ -145,11 +145,11 @@ BRK
~tileview.addr ADD2 =addr ( addr offset )
~MOUS.x ~tileview.x SUB2 ~MOUS.x ~tileview.x SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.x
~MOUS.y ~tileview.y SUB2 ~MOUS.y ~tileview.y SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.y
,no-fill-mode ~bankview.mode #01 NEQ JMP2? POP2
,no-fill-mode ~bankview.mode #01 NEQ JMP2?
( fill row ) #ff ~addr ~pos.y #0008 DIV2 ADD2 STR
,redraw JSR2 ,click-end JMP2
@no-fill-mode
,no-erase-mode ~bankview.mode #02 NEQ JMP2? POP2
,no-erase-mode ~bankview.mode #02 NEQ JMP2?
( erase row ) #00 ~addr ~pos.y #0008 DIV2 ADD2 STR
,redraw JSR2 ,click-end JMP2
@no-erase-mode
@ -163,15 +163,15 @@ BRK
( operations )
,no-operations ~MOUS.y ~tileview.y SUB2 #0008 DIV2 #000c NEQ2 JMP2? POP2
,no-operations ~MOUS.y ~tileview.y SUB2 #0008 DIV2 #000c NEQ2 JMP2?
,no-move-up ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0011 NEQ2 JMP2? POP2
,no-move-up ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0011 NEQ2 JMP2?
,op_shiftup JSR2
( release ) #00 =MOUS.state
,redraw JSR2 ,click-end JMP2
@no-move-up
,no-move-down ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0012 NEQ2 JMP2? POP2
,no-move-down ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0012 NEQ2 JMP2?
,op_shiftdown JSR2
( release ) #00 =MOUS.state
,redraw JSR2 ,click-end JMP2
@ -265,7 +265,7 @@ RTN
( draw ) #02 =SPRT.color
~SPRT.addr #0008 ADD2 =SPRT.addr
( incr ) ~i #01 ADD =i
,$guides ~i #10 LTH JMP2? POP2
,$guides ~i #10 LTH JMP2?
( body )
@ -276,17 +276,17 @@ RTN
~bankview.x =SPRT.x
$hor
( draw ) #01 =SPRT.color
,$no-highlight ~SPRT.addr ~tileview.addr LTH2 JMP2? POP2
,$no-highlight ~SPRT.addr ~tileview.addr #0018 ADD2 GTH2 JMP2? POP2
,$no-highlight ~SPRT.addr ~tileview.addr LTH2 JMP2?
,$no-highlight ~SPRT.addr ~tileview.addr #0018 ADD2 GTH2 JMP2?
( draw ) #0c =SPRT.color
$no-highlight
( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
( incr ) ~SPRT.addr #0008 ADD2 =SPRT.addr
( incr ) ~pt.x #01 ADD =pt.x
,$hor ~pt.x #10 LTH JMP2? POP2
,$hor ~pt.x #10 LTH JMP2?
( incr ) ~pt.y #01 ADD =pt.y
( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
,$ver ~pt.y #10 LTH JMP2? POP2
,$ver ~pt.y #10 LTH JMP2?
RTN
@ -333,7 +333,7 @@ RTN
$line-hor
( draw ) #03 =SCRN.color
( incr ) ~SCRN.x #0002 ADD2 =SCRN.x
~SCRN.x ~tileview.x #0082 ADD2 LTH2 ,$line-hor ROT JMP2? POP2
~SCRN.x ~tileview.x #0082 ADD2 LTH2 ,$line-hor ROT JMP2?
( line ver )
~tileview.y =SCRN.y
@ -341,7 +341,7 @@ RTN
$line-ver
( draw ) #03 =SCRN.color
( incr ) ~SCRN.y #0002 ADD2 =SCRN.y
~SCRN.y ~tileview.y #0081 ADD2 LTH2 ,$line-ver ROT JMP2? POP2
~SCRN.y ~tileview.y #0081 ADD2 LTH2 ,$line-ver ROT JMP2?
( rewind ) ~tileview.addr #0018 SUB2 =tileview.addr
@ -358,7 +358,7 @@ RTN
( draw ) #02 =SPRT.color
( incr ) ~i #01 ADD =i
( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
,$bytes ~i #08 LTH JMP2? POP2
,$bytes ~i #08 LTH JMP2?
( operations )
@ -381,10 +381,10 @@ RTN
( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
( incr ) ~SPRT.addr #0008 ADD2 =SPRT.addr
( incr ) ~pt.x #01 ADD =pt.x
,$tiles-hor ~pt.x #02 LTH JMP2? POP2
,$tiles-hor ~pt.x #02 LTH JMP2?
( incr ) ~pt.y #01 ADD =pt.y
( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
,$tiles-ver ~pt.y #02 LTH JMP2? POP2
,$tiles-ver ~pt.y #02 LTH JMP2?
RTN
@ -401,11 +401,11 @@ RTN
( draw ) #01 =SPRT.color
( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
( incr ) ~pt.x #01 ADD =pt.x
,$hor ~pt.x #08 LTH JMP2? POP2
,$hor ~pt.x #08 LTH JMP2?
( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
( incr ) ~pt.y #01 ADD =pt.y
~SPRT.x #0040 SUB2 =SPRT.x
,$ver ~pt.y #08 LTH JMP2? POP2
,$ver ~pt.y #08 LTH JMP2?
RTN

24
projects/tests/cond.usm Normal file
View File

@ -0,0 +1,24 @@
( tests/cond )
|0100 @RESET
#00 #d0
$loop NOP
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$loop SWP JMPS?
POP =Console.byte
BRK
@routine
RTN
|c000 @FRAME
|d000 @ERROR
|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )

View File

@ -23,7 +23,7 @@ BRK
#33 =Console.byte
,skip1 #12 #34 LTH JMP2? POP2
,skip1 #12 #34 LTH JMP2?
#ff =Console.byte
@skip1

View File

@ -25,7 +25,7 @@ RTN
$loop
~b #01 ADD =b
,$loop ~b #d0 LTH JMP2? POP2
,$loop ~b #d0 LTH JMP2?
~b =Console.byte
RTN
@ -34,7 +34,7 @@ RTN
$loop NOP
~c #01 ADD =c
~c #d0 LTH ^$loop SWP JMPS? POP
~c #d0 LTH ^$loop SWP JMPS?
~c =Console.byte
RTN
@ -44,7 +44,7 @@ RTN
#00 #d0
$loop NOP
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$loop SWP JMPS? POP
DUP2 LTH ^$loop SWP JMPS?
POP =Console.byte
RTN
@ -54,7 +54,7 @@ RTN
#0000 #0d00
$loop NOP
( incr ) SWP2 #0001 ADD2 SWP2
OVR2 OVR2 LTH2 ^$loop SWP JMPS? POP
OVR2 OVR2 LTH2 ^$loop SWP JMPS?
POP2 =Console.short
RTN

9
uxn.c
View File

@ -138,13 +138,14 @@ lituxn(Uxn *u, Uint8 instr)
int
opcuxn(Uxn *u, Uint8 instr)
{
Uint8 op = instr & 0x1f;
Uint8 op = instr & 0x1f, fcond;
setflag(&u->status, FLAG_SHORT, (instr >> 5) & 1);
setflag(&u->status, FLAG_SIGN, (instr >> 6) & 1);
setflag(&u->status, FLAG_COND, (instr >> 7) & 1);
fcond = getflag(&u->status, FLAG_COND);
if(getflag(&u->status, FLAG_SHORT))
op += 32;
if(u->wst.ptr < opr[op][0])
if(u->wst.ptr < opr[op][0] || (fcond && u->wst.ptr < 1))
return haltuxn(u, "Working-stack underflow", op);
if(u->wst.ptr + opr[op][1] - opr[op][0] >= 255)
return haltuxn(u, "Working-stack overflow", instr);
@ -152,8 +153,10 @@ opcuxn(Uxn *u, Uint8 instr)
return haltuxn(u, "Return-stack underflow", op);
if(u->rst.ptr + opr[op][3] - opr[op][2] >= 255)
return haltuxn(u, "Return-stack overflow", instr);
if(!getflag(&u->status, FLAG_COND) || (getflag(&u->status, FLAG_COND) && pop8(&u->wst)))
if(!fcond || (fcond && pop8(&u->wst)))
(*ops[op])(u);
else if(opr[op][0] >= opr[op][1])
u->wst.ptr -= opr[op][0] - opr[op][1];
return 1;
}