Merged sprite in screen device

This commit is contained in:
neauoire 2021-04-09 10:01:53 -07:00
parent 79949be735
commit ffded2f642
18 changed files with 597 additions and 632 deletions

View File

@ -32,7 +32,7 @@ else
fi
echo "Assembling.."
./bin/assembler projects/software/noodle.usm bin/boot.rom
./bin/assembler projects/examples/gui.shapes.usm bin/boot.rom
echo "Running.."
if [ "${2}" = '--cli' ];

View File

@ -28,8 +28,7 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
@ -223,14 +222,14 @@ RTN
@move-head ( -- )
( clear )
~trkframe.y1 8- =Sprite.y
~trkframe.x1 #00 ~head.pos ADD2 =Sprite.x
,head_icn =Sprite.addr
#00 =Sprite.color
~trkframe.y1 8- =Screen.y
~trkframe.x1 #00 ~head.pos ADD2 =Screen.x
,head_icn =Screen.addr
#20 =Screen.color
( incr ) ~head.pos #01 ADD =head.pos
~trkframe.x1 #00 ~head.pos ADD2 =Sprite.x
,head_icn =Sprite.addr
#01 ( if note ) TRACK #00 ~head.pos #08 DIV ADD2 PEK2 #00 NEQ ADD =Sprite.color
~trkframe.x1 #00 ~head.pos ADD2 =Screen.x
,head_icn =Screen.addr
#21 ( if note ) TRACK #00 ~head.pos #08 DIV ADD2 PEK2 #00 NEQ ADD =Screen.color
RTN
@ -239,10 +238,10 @@ RTN
#00 #20
$loop
( load ) OVR #00 SWP TRACK ADD2 PEK2
DUP STH #00 SWP #0e SWP SUB 8* ~trkframe.y1 ADD2 =Sprite.y
OVR #00 SWP 8* ~trkframe.x1 ADD2 =Sprite.x
DUP STH #00 SWP #0e SWP SUB 8* ~trkframe.y1 ADD2 =Screen.y
OVR #00 SWP 8* ~trkframe.x1 ADD2 =Screen.x
STHr #00 EQU ^$skip JNZ
#00 =Sprite.color
#20 =Screen.color
$skip
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$loop JNZ
@ -255,11 +254,11 @@ RTN
#00 #20
$notes-loop
( load ) OVR #00 SWP TRACK ADD2 PEK2
DUP STH #00 SWP #0e SWP SUB 8* ~trkframe.y1 ADD2 =Sprite.y
OVR #00 SWP 8* ~trkframe.x1 ADD2 =Sprite.x
,note_icn =Sprite.addr
DUP STH #00 SWP #0e SWP SUB 8* ~trkframe.y1 ADD2 =Screen.y
OVR #00 SWP 8* ~trkframe.x1 ADD2 =Screen.x
,note_icn =Screen.addr
STHr #00 EQU ^$skip JNZ
#05 =Sprite.color
#25 =Screen.color
$skip
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$notes-loop JNZ
@ -273,14 +272,14 @@ RTN
~trkframe.x1 ~trkframe.y1 ~trkframe.x2 ~trkframe.y2 #01 ,line-rect JSR2
( grid )
~trkframe.y1 #0010 SUB2 =Sprite.y
,font_hex =Sprite.addr
~trkframe.y1 #0010 SUB2 =Screen.y
,font_hex =Screen.addr
#0000 #0100
$loop
OVR2 SWP POP #02 DIV #0f AND #00 NEQ ^$skip JNZ
OVR2 ~trkframe.x1 ADD2 =Sprite.x
#02 =Sprite.color
~Sprite.addr 8+ =Sprite.addr
OVR2 ~trkframe.x1 ADD2 =Screen.x
#22 =Screen.color
~Screen.addr 8+ =Screen.addr
OVR2 ~trkframe.x1 ADD2 ~trkframe.y1 ++ ~trkframe.y2 #01 ,line-vertical-dotted JSR2
$skip
OVR2 ~trkframe.x1 ADD2 ~trkframe.y1 ~trkframe.y2 #01 ,line-vertical-dotted JSR2
@ -295,18 +294,18 @@ RTN
@draw-octave ( x y -- )
=Sprite.y
=Sprite.x
,octave_icn =Sprite.addr
~Sprite.y ~Sprite.y #0038 ADD2
=Screen.y
=Screen.x
,octave_icn =Screen.addr
~Screen.y ~Screen.y #0038 ADD2
$loop
OVR2 =Sprite.y
#01 =Sprite.color
~Sprite.addr 8+ =Sprite.addr
~Sprite.x 8+ =Sprite.x
#01 =Sprite.color
~Sprite.addr 8+ =Sprite.addr
~Sprite.x 8- =Sprite.x
OVR2 =Screen.y
#21 =Screen.color
~Screen.addr 8+ =Screen.addr
~Screen.x 8+ =Screen.x
#21 =Screen.color
~Screen.addr 8+ =Screen.addr
~Screen.x 8- =Screen.x
SWP2 8+ SWP2
OVR2 OVR2 LTH2 ^$loop JNZ
POP2
@ -318,20 +317,20 @@ RTN
~trkframe.x1 #0018 SUB2 DUP2 ~trkframe.y1 ,draw-octave JSR2
~trkframe.y1 #0038 ADD2 ,draw-octave JSR2
~trkframe.x1 #0028 SUB2 =Sprite.x
~trkframe.y1 #0030 ADD2 =Sprite.y
,font_hex #0028 ADD2 =Sprite.addr
#03 =Sprite.color
~trkframe.x1 #0030 SUB2 =Sprite.x
,font_hex #0060 ADD2 =Sprite.addr
#03 =Sprite.color
~trkframe.x1 #0028 SUB2 =Sprite.x
~trkframe.y1 #0068 ADD2 =Sprite.y
,font_hex #0020 ADD2 =Sprite.addr
#03 =Sprite.color
~trkframe.x1 #0030 SUB2 =Sprite.x
,font_hex #0060 ADD2 =Sprite.addr
#03 =Sprite.color
~trkframe.x1 #0028 SUB2 =Screen.x
~trkframe.y1 #0030 ADD2 =Screen.y
,font_hex #0028 ADD2 =Screen.addr
#23 =Screen.color
~trkframe.x1 #0030 SUB2 =Screen.x
,font_hex #0060 ADD2 =Screen.addr
#23 =Screen.color
~trkframe.x1 #0028 SUB2 =Screen.x
~trkframe.y1 #0068 ADD2 =Screen.y
,font_hex #0020 ADD2 =Screen.addr
#23 =Screen.color
~trkframe.x1 #0030 SUB2 =Screen.x
,font_hex #0060 ADD2 =Screen.addr
#23 =Screen.color
RTN
@ -345,19 +344,19 @@ RTN
@draw-knob ( x* y* value -- )
( load ) =knob.value =knob.y =knob.x
~knob.x =Sprite.x
~knob.y =Sprite.y ,knob_icns =Sprite.addr #01 =Sprite.color
~knob.x 8+ =Sprite.x ,knob_icns 8+ =Sprite.addr #01 =Sprite.color
~knob.y 8+ =Sprite.y ,knob_icns #0018 ADD2 =Sprite.addr #01 =Sprite.color
~knob.x =Sprite.x ,knob_icns #0010 ADD2 =Sprite.addr #01 =Sprite.color
~knob.x #00 #00 ~knob.value ,knob_offsetx ADD2 PEK2 ADD2 =Sprite.x
~knob.y #00 #00 ~knob.value ,knob_offsety ADD2 PEK2 ADD2 =Sprite.y
,knob_icns #0020 ADD2 =Sprite.addr
#05 =Sprite.color
~knob.x #0004 ADD2 =Sprite.x
~knob.y #0010 ADD2 =Sprite.y
,font_hex #00 ~knob.value #08 MUL ADD2 =Sprite.addr
#01 =Sprite.color
~knob.x =Screen.x
~knob.y =Screen.y ,knob_icns =Screen.addr #21 =Screen.color
~knob.x 8+ =Screen.x ,knob_icns 8+ =Screen.addr #21 =Screen.color
~knob.y 8+ =Screen.y ,knob_icns #0018 ADD2 =Screen.addr #21 =Screen.color
~knob.x =Screen.x ,knob_icns #0010 ADD2 =Screen.addr #21 =Screen.color
~knob.x #00 #00 ~knob.value ,knob_offsetx ADD2 PEK2 ADD2 =Screen.x
~knob.y #00 #00 ~knob.value ,knob_offsety ADD2 PEK2 ADD2 =Screen.y
,knob_icns #0020 ADD2 =Screen.addr
#25 =Screen.color
~knob.x #0004 ADD2 =Screen.x
~knob.y #0010 ADD2 =Screen.y
,font_hex #00 ~knob.value #08 MUL ADD2 =Screen.addr
#21 =Screen.color
RTN
@ -365,7 +364,7 @@ RTN
~ctlframe.x1 ~ctlframe.y1 ~ctlframe.x2 ~ctlframe.y2 #01 ,line-rect JSR2
( env )
~ctlframe.x1 8+ ~ctlframe.y1 8+ #02 ,env_txt ,draw-label JSR2
~ctlframe.x1 8+ ~ctlframe.y1 8+ #22 ,env_txt ,draw-label JSR2
~ctlframe.x1 8+ ~ctlframe.y1 #0010 ADD2
,adsr #00 ~track.active #04 MUL ADD2 PEK2 #04 SFT
,draw-knob JSR2
@ -379,7 +378,7 @@ RTN
,adsr #00 ~track.active #04 MUL ADD2 #0003 ADD2 PEK2 #04 SFT
,draw-knob JSR2
( vol )
~ctlframe.x1 #0058 ADD2 ~ctlframe.y1 8+ #02 ,vol_txt ,draw-label JSR2
~ctlframe.x1 #0058 ADD2 ~ctlframe.y1 8+ #22 ,vol_txt ,draw-label JSR2
~ctlframe.x1 #0058 ADD2 ~ctlframe.y1 #0010 ADD2
,volume #00 ~track.active ADD2 PEK2 #04 SFT
,draw-knob JSR2
@ -392,27 +391,27 @@ RTN
@draw-channels
~chnframe.x1 ~chnframe.y1 ~chnframe.x2 ~chnframe.y2 #01 ,line-rect JSR2
~chnframe.x1 8+ ~chnframe.y1 8+ #01 ~track.active #00 EQU #07 MUL ADD ,ch1_txt ,draw-label JSR2
~chnframe.x1 8+ ~chnframe.y1 #0010 ADD2 #01 ~track.active #01 EQU #07 MUL ADD ,ch2_txt ,draw-label JSR2
~chnframe.x1 8+ ~chnframe.y1 #0018 ADD2 #01 ~track.active #02 EQU #07 MUL ADD ,ch3_txt ,draw-label JSR2
~chnframe.x1 8+ ~chnframe.y1 #0020 ADD2 #01 ~track.active #03 EQU #07 MUL ADD ,ch4_txt ,draw-label JSR2
~chnframe.x1 8+ ~chnframe.y1 8+ #21 ~track.active #00 EQU #07 MUL ADD ,ch1_txt ,draw-label JSR2
~chnframe.x1 8+ ~chnframe.y1 #0010 ADD2 #21 ~track.active #01 EQU #07 MUL ADD ,ch2_txt ,draw-label JSR2
~chnframe.x1 8+ ~chnframe.y1 #0018 ADD2 #21 ~track.active #02 EQU #07 MUL ADD ,ch3_txt ,draw-label JSR2
~chnframe.x1 8+ ~chnframe.y1 #0020 ADD2 #21 ~track.active #03 EQU #07 MUL ADD ,ch4_txt ,draw-label JSR2
RTN
@draw-cursor ( -- )
( clear last cursor )
,clear_icn =Sprite.addr
~pointer.x =Sprite.x
~pointer.y =Sprite.y
#10 =Sprite.color
,clear_icn =Screen.addr
~pointer.x =Screen.x
~pointer.y =Screen.y
#30 =Screen.color
( record pointer positions )
~Mouse.x =pointer.x ~Mouse.y =pointer.y
( draw new cursor )
,cursor_icn =Sprite.addr
~pointer.x =Sprite.x
~pointer.y =Sprite.y
#12 ~Mouse.state #00 NEQ ADD =Sprite.color
,cursor_icn =Screen.addr
~pointer.x =Screen.x
~pointer.y =Screen.y
#32 ~Mouse.state #00 NEQ ADD =Screen.color
RTN
@ -420,12 +419,12 @@ RTN
@draw-label ( x y color addr -- )
( load ) =label.addr =label.color =Sprite.y =Sprite.x
( load ) =label.addr =label.color =Screen.y =Screen.x
~label.addr
$loop
( draw ) DUP2 PEK2 #00 SWP 8* ,font ADD2 =Sprite.addr ~label.color =Sprite.color
( draw ) DUP2 PEK2 #00 SWP 8* ,font ADD2 =Screen.addr ~label.color =Screen.color
( incr ) ++
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Screen.x 8+ =Screen.x
DUP2 PEK2 #00 NEQ ^$loop JNZ
POP2

View File

@ -11,8 +11,7 @@
( devices )
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 p1 1 }
|0200
@ -21,46 +20,46 @@
( vectors ) ,FRAME =Screen.vector
( set origin )
~Screen.width 2/ =Sprite.x
~Screen.height 2/ =Sprite.y
,default_icn =Sprite.addr
#11 =Sprite.color
#0a =slime
~Screen.width 2/ =Screen.x
~Screen.height 2/ =Screen.y
,default_icn =Screen.addr
#31 =Screen.color
#2a =slime
BRK
@FRAME
#0a =slime
,default_icn =Sprite.addr
#2a =slime
,default_icn =Screen.addr
( hold ctrl key to change slime color )
~Controller.p1 #0f AND
DUP #01 NEQ ^$no-ctrl JNZ #05 =slime $no-ctrl
DUP #02 NEQ ^$no-alt JNZ #0f =slime $no-alt
DUP #01 NEQ ^$no-ctrl JNZ #25 =slime $no-ctrl
DUP #02 NEQ ^$no-alt JNZ #2f =slime $no-alt
POP
( clear ) #10 =Sprite.color
( clear ) #30 =Screen.color
( detect movement )
~Controller.p1 #f0 AND
DUP #04 SFT #01 AND #01 NEQ ^$no-up JNZ
( move ) ~Sprite.y -- =Sprite.y ,up_icn =Sprite.addr $no-up
( move ) ~Screen.y -- =Screen.y ,up_icn =Screen.addr $no-up
DUP #05 SFT #01 AND #01 NEQ ^$no-down JNZ
( move ) ~Sprite.y ++ =Sprite.y ,down_icn =Sprite.addr $no-down
( move ) ~Screen.y ++ =Screen.y ,down_icn =Screen.addr $no-down
DUP #06 SFT #01 AND #01 NEQ ^$no-left JNZ
( move ) ~Sprite.x -- =Sprite.x ,left_icn =Sprite.addr $no-left
( move ) ~Screen.x -- =Screen.x ,left_icn =Screen.addr $no-left
DUP #07 SFT #01 AND #01 NEQ ^$no-right JNZ
( move ) ~Sprite.x ++ =Sprite.x ,right_icn =Sprite.addr $no-right
( move ) ~Screen.x ++ =Screen.x ,right_icn =Screen.addr $no-right
POP
( draw face )
#11 =Sprite.color
#31 =Screen.color
( draw slime )
,slime_icn =Sprite.addr
~slime =Sprite.color
,slime_icn =Screen.addr
~slime =Screen.color
BRK

View File

@ -5,7 +5,7 @@
%8* { #0030 SFT2 }
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 1 }
@ -22,10 +22,10 @@ BRK
@KEY
,cursor_icn =Sprite.addr
,font #00 ~Keys.key 8* ADD2 =Sprite.addr
( draw ) #01 =Sprite.color
~Sprite.x 8+ =Sprite.x
,cursor_icn =Screen.addr
,font #00 ~Keys.key 8* ADD2 =Screen.addr
( draw ) #21 =Screen.color
~Screen.x 8+ =Screen.x
( release ) #00 =Keys.key
,draw-cursor JSR2
@ -35,9 +35,9 @@ BRK
( enter key )
~Controller.button #08 NEQ ^$no-return JNZ
#00 =Sprite.color
#0000 =Sprite.x
( incr ) ~Sprite.y 8+ =Sprite.y
#20 =Screen.color
#0000 =Screen.x
( incr ) ~Screen.y 8+ =Screen.y
( release ) #00 =Controller.button
,draw-cursor JSR2
$no-return
@ -46,7 +46,7 @@ BRK
@draw-cursor
,cursor_icn =Sprite.addr #02 =Sprite.color
,cursor_icn =Screen.addr #22 =Screen.color
RTN

View File

@ -9,8 +9,7 @@
;circle { xc 2 yc 2 x 2 y 2 r 2 d 2 }
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
( program )
@ -48,19 +47,19 @@ BRK
@draw-cursor ( -- )
( clear last cursor )
,clear_icn =Sprite.addr
~pointer.x =Sprite.x
~pointer.y =Sprite.y
#10 =Sprite.color
,clear_icn =Screen.addr
~pointer.x =Screen.x
~pointer.y =Screen.y
#30 =Screen.color
( record pointer positions )
~Mouse.x =pointer.x ~Mouse.y =pointer.y
( draw new cursor )
,cursor_icn =Sprite.addr
~pointer.x =Sprite.x
~pointer.y =Sprite.y
#11 ~Mouse.state #00 NEQ ADD =Sprite.color
,cursor_icn =Screen.addr
~pointer.x =Screen.x
~pointer.y =Screen.y
#31 ~Mouse.state #00 NEQ ADD =Screen.color
RTN

View File

@ -22,8 +22,7 @@
}
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
( program )
@ -130,11 +129,11 @@ RTN
POP2 POP2
( draw blending modes )
#0020 =Sprite.x #0020 =Sprite.y ,icon_icn =Sprite.addr
#00 #10
#0000 =Screen.x #0020 =Screen.y ,icon_icn =Screen.addr
#20 #30
$draw-blends
( move ) OVR #00 SWP #0008 MUL2 #0020 ADD2 =Sprite.x
( draw ) OVR =Sprite.color
( move ) OVR #00 SWP #0008 MUL2 =Screen.x
( draw ) OVR =Screen.color
( incr ) SWP #01 ADD SWP
DUP2 LTH ^$draw-blends JNZ
POP POP
@ -149,52 +148,52 @@ RTN
~window.x1 ~window.y1 ~window.x2 ~window.y2 #01 ,line-rect JSR2
~window.x1 #0002 SUB2 ~window.y1 #0002 SUB2 ~window.x2 #0002 ADD2 ~window.y2 #0002 ADD2 #01 ,line-rect JSR2
~window.x1 #0008 ADD2 ~window.y1 #0010 ADD2 #05 ,red_txt ,draw-label JSR2
~window.x1 #0008 ADD2 ~window.y1 #0020 ADD2 #05 ,green_txt ,draw-label JSR2
~window.x1 #0008 ADD2 ~window.y1 #0030 ADD2 #05 ,blue_txt ,draw-label JSR2
~window.x1 #0008 ADD2 ~window.y1 #0010 ADD2 #25 ,red_txt ,draw-label JSR2
~window.x1 #0008 ADD2 ~window.y1 #0020 ADD2 #25 ,green_txt ,draw-label JSR2
~window.x1 #0008 ADD2 ~window.y1 #0030 ADD2 #25 ,blue_txt ,draw-label JSR2
~window.x1 #0050 ADD2 ~window.y1 #0010 ADD2 ~window.x1 #0080 ADD2 #00 ,theme.r1 ~selection ADD PEK2 #0004 MUL2 #01 ,draw-slider JSR2
~window.x1 #0050 ADD2 ~window.y1 #0020 ADD2 ~window.x1 #0080 ADD2 #00 ,theme.g1 ~selection ADD PEK2 #0004 MUL2 #01 ,draw-slider JSR2
~window.x1 #0050 ADD2 ~window.y1 #0030 ADD2 ~window.x1 #0080 ADD2 #00 ,theme.b1 ~selection ADD PEK2 #0004 MUL2 #01 ,draw-slider JSR2
~window.x1 #0050 ADD2 =Sprite.x
~window.y1 #0040 ADD2 =Sprite.y
,radio_icns #00 ~selection #00 EQU #0008 MUL2 ADD2 =Sprite.addr
#05 =Sprite.color
~window.x1 #0050 ADD2 =Screen.x
~window.y1 #0040 ADD2 =Screen.y
,radio_icns #00 ~selection #00 EQU #0008 MUL2 ADD2 =Screen.addr
#25 =Screen.color
~window.x1 #0060 ADD2 =Sprite.x
~window.y1 #0040 ADD2 =Sprite.y
,radio_icns #00 ~selection #01 EQU #0008 MUL2 ADD2 =Sprite.addr
#05 =Sprite.color
~window.x1 #0060 ADD2 =Screen.x
~window.y1 #0040 ADD2 =Screen.y
,radio_icns #00 ~selection #01 EQU #0008 MUL2 ADD2 =Screen.addr
#25 =Screen.color
~window.x1 #0070 ADD2 =Sprite.x
~window.y1 #0040 ADD2 =Sprite.y
,radio_icns #00 ~selection #02 EQU #0008 MUL2 ADD2 =Sprite.addr
#05 =Sprite.color
~window.x1 #0070 ADD2 =Screen.x
~window.y1 #0040 ADD2 =Screen.y
,radio_icns #00 ~selection #02 EQU #0008 MUL2 ADD2 =Screen.addr
#25 =Screen.color
~window.x1 #0080 ADD2 =Sprite.x
~window.y1 #0040 ADD2 =Sprite.y
,radio_icns #00 ~selection #03 EQU #0008 MUL2 ADD2 =Sprite.addr
#05 =Sprite.color
~window.x1 #0080 ADD2 =Screen.x
~window.y1 #0040 ADD2 =Screen.y
,radio_icns #00 ~selection #03 EQU #0008 MUL2 ADD2 =Screen.addr
#25 =Screen.color
RTN
@draw-cursor
( clear last cursor )
,clear_icn =Sprite.addr
~pointer.x =Sprite.x
~pointer.y =Sprite.y
#10 =Sprite.color
,clear_icn =Screen.addr
~pointer.x =Screen.x
~pointer.y =Screen.y
#30 =Screen.color
( record pointer positions )
~Mouse.x =pointer.x ~Mouse.y =pointer.y
( draw new cursor )
,pointer_icn =Sprite.addr
~pointer.x =Sprite.x
~pointer.y =Sprite.y
#13 =Sprite.color
,pointer_icn =Screen.addr
~pointer.x =Screen.x
~pointer.y =Screen.y
#33 =Screen.color
RTN
@ -202,26 +201,26 @@ RTN
( load ) =color =slider.pos =slider.x2 =slider.y =slider.x1
~slider.x1 =Sprite.x
~slider.y =Sprite.y
,halftone_icn =Sprite.addr
~slider.x1 =Screen.x
~slider.y =Screen.y
,halftone_icn =Screen.addr
,slidera_icn =Sprite.addr
( draw ) #05 =Sprite.color
,sliderb_icn =Sprite.addr
,slidera_icn =Screen.addr
( draw ) #25 =Screen.color
,sliderb_icn =Screen.addr
$loop
( incr ) ~Sprite.x 8+ =Sprite.x
( draw ) #05 =Sprite.color
~Sprite.x ~slider.x2 #0008 ADD2 LTH2 ^$loop JNZ
( incr ) ~Screen.x 8+ =Screen.x
( draw ) #25 =Screen.color
~Screen.x ~slider.x2 #0008 ADD2 LTH2 ^$loop JNZ
( incr ) ~Sprite.x #0004 ADD2 =Sprite.x
,sliderc_icn =Sprite.addr
( draw ) #05 =Sprite.color
( incr ) ~Screen.x #0004 ADD2 =Screen.x
,sliderc_icn =Screen.addr
( draw ) #25 =Screen.color
~slider.x1 ~slider.pos ADD2 =Sprite.x
,sliderd_icn =Sprite.addr
( draw ) #0a =Sprite.color
~slider.x1 ~slider.pos ADD2 =Screen.x
,sliderd_icn =Screen.addr
( draw ) #2a =Screen.color
RTN
@ -258,11 +257,11 @@ RTN
@draw-label ( x y color addr )
( load ) =label.addr =color =Sprite.y =Sprite.x ~label.addr
( load ) =label.addr =color =Screen.y =Screen.x ~label.addr
$loop
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~color =Sprite.color
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~color =Screen.color
( incr ) ++
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Screen.x 8+ =Screen.x
DUP2 PEK2 #00 NEQ ^$loop JNZ
POP2

View File

@ -15,8 +15,7 @@
( devices )
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|01a0 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dotw 1 doty 2 isdst 1 refresh 1 }
( program )
@ -69,26 +68,26 @@ BRK
POP2
( display )
~Screen.height #0002 DIV2 #0048 ADD2 =Sprite.y
~Screen.height #0002 DIV2 #0048 ADD2 =Screen.y
~Screen.width #0002 DIV2
DUP2 #0020 SUB2 =Sprite.x
,font_hex #00 ~DateTime.hour #0a DIV #08 MUL ADD2 =Sprite.addr
#02 =Sprite.color
DUP2 #0018 SUB2 =Sprite.x
,font_hex #00 ~DateTime.hour #0a MOD #08 MUL ADD2 =Sprite.addr
#02 =Sprite.color
DUP2 #0008 SUB2 =Sprite.x
,font_hex #00 ~DateTime.minute #0a DIV #08 MUL ADD2 =Sprite.addr
#02 =Sprite.color
DUP2 =Sprite.x
,font_hex #00 ~DateTime.minute #0a MOD #08 MUL ADD2 =Sprite.addr
#02 =Sprite.color
DUP2 #0010 ADD2 =Sprite.x
,font_hex #00 ~DateTime.second #0a DIV #08 MUL ADD2 =Sprite.addr
#02 =Sprite.color
DUP2 #0018 ADD2 =Sprite.x
,font_hex #00 ~DateTime.second #0a MOD #08 MUL ADD2 =Sprite.addr
#02 =Sprite.color
DUP2 #0020 SUB2 =Screen.x
,font_hex #00 ~DateTime.hour #0a DIV #08 MUL ADD2 =Screen.addr
#22 =Screen.color
DUP2 #0018 SUB2 =Screen.x
,font_hex #00 ~DateTime.hour #0a MOD #08 MUL ADD2 =Screen.addr
#22 =Screen.color
DUP2 #0008 SUB2 =Screen.x
,font_hex #00 ~DateTime.minute #0a DIV #08 MUL ADD2 =Screen.addr
#22 =Screen.color
DUP2 =Screen.x
,font_hex #00 ~DateTime.minute #0a MOD #08 MUL ADD2 =Screen.addr
#22 =Screen.color
DUP2 #0010 ADD2 =Screen.x
,font_hex #00 ~DateTime.second #0a DIV #08 MUL ADD2 =Screen.addr
#22 =Screen.color
DUP2 #0018 ADD2 =Screen.x
,font_hex #00 ~DateTime.second #0a MOD #08 MUL ADD2 =Screen.addr
#22 =Screen.color
POP2
BRK

View File

@ -12,8 +12,7 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
@ -65,19 +64,19 @@ BRK
@draw-cursor
( clear last cursor )
,clear_icn =Sprite.addr
~pointer.x =Sprite.x
~pointer.y =Sprite.y
#10 =Sprite.color
,clear_icn =Screen.addr
~pointer.x =Screen.x
~pointer.y =Screen.y
#30 =Screen.color
( record pointer positions )
~Mouse.x =pointer.x ~Mouse.y =pointer.y
( draw new cursor )
~pointer.sprite =Sprite.addr
~pointer.x =Sprite.x
~pointer.y =Sprite.y
#11 =Sprite.color
~pointer.sprite =Screen.addr
~pointer.x =Screen.x
~pointer.y =Screen.y
#31 =Screen.color
RTN

View File

@ -7,8 +7,7 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
@ -30,22 +29,22 @@
( incr ) ~Screen.y #0002 ADD2 =Screen.y
~Screen.y ~Screen.height LTH2 ^$draw-ver JNZ
~center.x ~center.y #0010 SUB2 #0c ,text1 ,draw-label-left JSR2
~center.x ~center.y #0c ,text2 ,draw-label-middle JSR2
~center.x ~center.y #0010 ADD2 #0c ,text3 ,draw-label-right JSR2
~center.x ~center.y #0020 ADD2 #0c ,text4 ,draw-label-middle JSR2
~center.x ~center.y #0030 ADD2 #0c ,text5 ,draw-label-middle JSR2
~center.x ~center.y #0010 SUB2 #2c ,text1 ,draw-label-left JSR2
~center.x ~center.y #2c ,text2 ,draw-label-middle JSR2
~center.x ~center.y #0010 ADD2 #2c ,text3 ,draw-label-right JSR2
~center.x ~center.y #0020 ADD2 #2c ,text4 ,draw-label-middle JSR2
~center.x ~center.y #0030 ADD2 #2c ,text5 ,draw-label-middle JSR2
BRK
@draw-label-left ( x y color addr )
( load ) =label.addr =label.color =Sprite.y =Sprite.x
( load ) =label.addr =label.color =Screen.y =Screen.x
~label.addr
$loop
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~label.color =Screen.color
( incr ) #0001 ADD2
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
( incr ) ~Screen.x #0008 ADD2 =Screen.x
DUP2 PEK2 #00 NEQ ^$loop JNZ
POP2
@ -53,13 +52,13 @@ RTN
@draw-label-middle ( x y color addr )
( load ) =label.addr =label.color =Sprite.y
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 =Sprite.x
( load ) =label.addr =label.color =Screen.y
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 =Screen.x
~label.addr
$loop
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~label.color =Screen.color
( incr ) #0001 ADD2
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
( incr ) ~Screen.x #0008 ADD2 =Screen.x
DUP2 PEK2 #00 NEQ ^$loop JNZ
POP2
@ -67,13 +66,13 @@ RTN
@draw-label-right ( x y color addr )
( load ) =label.addr =label.color =Sprite.y
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 =Sprite.x
( load ) =label.addr =label.color =Screen.y
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 =Screen.x
~label.addr
$loop
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
( draw ) DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr ~label.color =Screen.color
( incr ) #0001 ADD2
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
( incr ) ~Screen.x #0008 ADD2 =Screen.x
DUP2 PEK2 #00 NEQ ^$loop JNZ
POP2

View File

@ -6,8 +6,7 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
@ -18,24 +17,24 @@
( theme ) #0ffc =System.r #0f0b =System.g #0f03 =System.b
#0000 #0000 #0100 #0100 #01 ,pict_large ,draw-picture JSR2
#0098 #0060 #0080 #0080 #01 ,pict_medium ,draw-picture JSR2
#0020 #0090 #0020 #0020 #0a ,pict_small ,draw-picture JSR2
#0000 #0000 #0100 #0100 #21 ,pict_large ,draw-picture JSR2
#0098 #0060 #0080 #0080 #21 ,pict_medium ,draw-picture JSR2
#0020 #0090 #0020 #0020 #2a ,pict_small ,draw-picture JSR2
BRK
@draw-picture ( x y width height color addr )
DUP2 =Sprite.addr =pict.addr =pict.color =pict.height =pict.width DUP2 =Sprite.y =pict.y =pict.x
DUP2 =Screen.addr =pict.addr =pict.color =pict.height =pict.width DUP2 =Screen.y =pict.y =pict.x
$ver
~pict.x =Sprite.x
~pict.x =Screen.x
$hor
( draw ) ~pict.color =Sprite.color
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
( incr ) ~Sprite.addr #0008 ADD2 =Sprite.addr
~Sprite.x ~pict.width ~pict.x ADD2 LTH2 ^$hor JNZ
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
~Sprite.y ~pict.height ~pict.y ADD2 LTH2 ^$ver JNZ
( draw ) ~pict.color =Screen.color
( incr ) ~Screen.x #0008 ADD2 =Screen.x
( incr ) ~Screen.addr #0008 ADD2 =Screen.addr
~Screen.x ~pict.width ~pict.x ADD2 LTH2 ^$hor JNZ
( incr ) ~Screen.y #0008 ADD2 =Screen.y
~Screen.y ~pict.height ~pict.y ADD2 LTH2 ^$ver JNZ
RTN

View File

@ -14,8 +14,7 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
@ -33,10 +32,10 @@
#0080 #0030 #00b0 #0070 #02 ,line-rect JSR2
#0090 #0040 #00c0 #0080 #03 ,line-rect JSR2
#0000 #0080 #0020 #0020 #01 ,pict_small ,draw-picture JSR2
#0010 #0088 #0020 #0020 #02 ,pict_small ,draw-picture JSR2
#0020 #0090 #0020 #0020 #03 ,pict_small ,draw-picture JSR2
#0030 #0098 #0020 #0020 #04 ,pict_small ,draw-picture JSR2
#0000 #0080 #0020 #0020 #21 ,pict_small ,draw-picture JSR2
#0010 #0088 #0020 #0020 #22 ,pict_small ,draw-picture JSR2
#0020 #0090 #0020 #0020 #23 ,pict_small ,draw-picture JSR2
#0030 #0098 #0020 #0020 #24 ,pict_small ,draw-picture JSR2
#0020 #0020 #0070 #0080 #01 ,draw-line JSR2
#0020 #0080 #0070 #0030 #02 ,draw-line JSR2
@ -108,16 +107,16 @@ RTN
@draw-picture ( x y width height color addr )
( load ) DUP2 =Sprite.addr =pict.addr =pict.color =pict.height =pict.width DUP2 =Sprite.y =pict.y =pict.x
( load ) DUP2 =Screen.addr =pict.addr =pict.color =pict.height =pict.width DUP2 =Screen.y =pict.y =pict.x
$ver
~pict.x =Sprite.x
~pict.x =Screen.x
$hor
( draw ) ~pict.color =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Sprite.addr 8+ =Sprite.addr
~Sprite.x ~pict.width ~pict.x ADD2 LTH2 ^$hor JNZ
( incr ) ~Sprite.y 8+ =Sprite.y
~Sprite.y ~pict.height ~pict.y ADD2 LTH2 ^$ver JNZ
( draw ) ~pict.color =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~Screen.addr 8+ =Screen.addr
~Screen.x ~pict.width ~pict.x ADD2 LTH2 ^$hor JNZ
( incr ) ~Screen.y 8+ =Screen.y
~Screen.y ~pict.height ~pict.y ADD2 LTH2 ^$ver JNZ
RTN

View File

@ -44,11 +44,10 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { buttons 1 }
|0150 ;Keys { key 1 }
|0160 ;Mouse { x 2 y 2 state 1 chord 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
|0170 ;File { pad 8 name 2 length 2 load 2 save 2 }
( program )
@ -56,7 +55,9 @@
|0200 @RESET
( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b
( vectors ) ,FRAME =Screen.vector
( vectors ) ,on-mouse =Mouse.vector
( vectors ) ,on-key =Keys.vector
( vectors ) ,on-button =Controller.vector
( load file )
,filepath ,load-file JSR2
@ -69,102 +70,96 @@
BRK
@FRAME
@on-key
( ctrl )
~Controller #00 EQU ~lock #00 NEQ #0000 NEQ2 ,$ctrl-end JNZ2
( lock ) #04 =lock
~Keys #08 NEQ ^$no-backspace JNZ
( erase )
~selection.to ~selection.from SUB2 #0001 NEQ2 ^$erase-multiple JNZ
~selection.to ~selection.from SUB2 ,shift-left JSR2
,$erase-end JMP2
$erase-multiple
~selection.from ++ =selection.from
~selection.to ~selection.from SUB2 ++ ,shift-left JSR2
$erase-end
~selection.from -- =selection.from
^$keys-end JMP
$no-backspace
( alt + arrow )
~Controller #0f AND #02 NEQ ^$no-alt JNZ
~Controller #04 SFT
DUP #01 NEQ ^$no-aup JNZ
( sel word ) ,find-wordstart JSR2 =selection.to $no-aup
DUP #02 NEQ ^$no-adown JNZ
( sel word ) ,find-wordend JSR2 =selection.to $no-adown
DUP #04 NEQ ^$no-aleft JNZ
( sel decr ) ~selection.to -- =selection.to $no-aleft
DUP #08 NEQ ^$no-aright JNZ
( sel incr ) ~selection.to ++ =selection.to $no-aright
POP
,clamp-selection JSR2
,redraw JSR2
,$ctrl-end JMP2
$no-alt
( insert )
~selection.to ~selection.from SUB2 ,shift-right JSR2
~Keys ~selection.from POK2
~selection.from ++ =selection.from
( ctrl + arrow )
~Controller #0f AND #01 NEQ ^$no-ctrl JNZ
~Controller #04 SFT
DUP #01 NEQ ^$no-cup JNZ
( jump scroll ) #0004 ,scroll-up JSR2 $no-cup
DUP #02 NEQ ^$no-cdown JNZ
( jump scroll ) #0004 ,scroll-down JSR2 $no-cdown
DUP #04 NEQ ^$no-cleft JNZ
( jump line ) ,goto-linestart JSR2 $no-cleft
DUP #08 NEQ ^$no-cright JNZ
( jump line ) ,goto-lineend JSR2 $no-cright
POP
,redraw JSR2
,$ctrl-end JMP2
$no-ctrl
$keys-end
~selection.from ++ =selection.to
( release ) #00 =Keys
,redraw JSR2
( arrow )
~Controller #f0 AND #00 EQU ,$no-arrow JNZ2
~Controller #f0 AND
DUP #10 NEQ ^$no-arrowup JNZ
( clamp ) ~position.y #0000 EQU2 ^$no-arrowup JNZ
,find-lineoffset JSR2 =position.x ~position.y -- =position.y
,find-selection JSR2 DUP2 =selection.from ++ =selection.to $no-arrowup
DUP #20 NEQ ^$no-arrowdown JNZ
( clamp:TODO )
,find-lineoffset JSR2 =position.x ~position.y ++ =position.y
,find-selection JSR2 DUP2 =selection.from ++ =selection.to $no-arrowdown
DUP #40 NEQ ^$no-arrowleft JNZ
( clamp ) ~selection.from ,document.body EQU2 ^$no-arrowleft JNZ
~selection.from -- DUP2 =selection.from ++ =selection.to $no-arrowleft
DUP #80 NEQ ^$no-arrowright JNZ
( clamp:TODO )
#aa =Console.byte
~selection.from ++ DUP2 =selection.from ++ =selection.to $no-arrowright
POP
,clamp-selection JSR2
,follow-selection JSR2
,redraw JSR2
$no-arrow
BRK
$ctrl-end
( keys )
~Keys #00 EQU ,$no-keys JNZ2
~Keys #08 NEQ ^$no-backspace JNZ
( erase )
~selection.to ~selection.from SUB2 #0001 NEQ2 ^$erase-multiple JNZ
~selection.to ~selection.from SUB2 ,shift-left JSR2
,$erase-end JMP2
$erase-multiple
~selection.from ++ =selection.from
~selection.to ~selection.from SUB2 ++ ,shift-left JSR2
$erase-end
~selection.from -- =selection.from
^$keys-end JMP
$no-backspace
( insert )
~selection.to ~selection.from SUB2 ,shift-right JSR2
~Keys ~selection.from POK2
~selection.from ++ =selection.from
$keys-end
~selection.from ++ =selection.to
( release ) #00 =Keys
@on-button ( -> )
( alt + arrow )
~Controller #0f AND #02 NEQ ^$no-alt JNZ
~Controller #04 SFT
DUP #01 NEQ ^$no-aup JNZ
( sel word ) ,find-wordstart JSR2 =selection.to $no-aup
DUP #02 NEQ ^$no-adown JNZ
( sel word ) ,find-wordend JSR2 =selection.to $no-adown
DUP #04 NEQ ^$no-aleft JNZ
( sel decr ) ~selection.to -- =selection.to $no-aleft
DUP #08 NEQ ^$no-aright JNZ
( sel incr ) ~selection.to ++ =selection.to $no-aright
POP
,clamp-selection JSR2
,redraw JSR2
BRK
$no-alt
$no-keys
( ctrl + arrow )
~Controller #0f AND #01 NEQ ^$no-ctrl JNZ
~Controller #04 SFT
DUP #01 NEQ ^$no-cup JNZ
( jump scroll ) #0004 ,scroll-up JSR2 $no-cup
DUP #02 NEQ ^$no-cdown JNZ
( jump scroll ) #0004 ,scroll-down JSR2 $no-cdown
DUP #04 NEQ ^$no-cleft JNZ
( jump line ) ,goto-linestart JSR2 $no-cleft
DUP #08 NEQ ^$no-cright JNZ
( jump line ) ,goto-lineend JSR2 $no-cright
POP
,redraw JSR2
BRK
$no-ctrl
( mouse )
( arrow )
~Controller #f0 AND #00 EQU ,$no-arrow JNZ2
~Controller #f0 AND
DUP #10 NEQ ^$no-arrowup JNZ
( clamp ) ~position.y #0000 EQU2 ^$no-arrowup JNZ
,find-lineoffset JSR2 =position.x ~position.y -- =position.y
,find-selection JSR2 DUP2 =selection.from ++ =selection.to $no-arrowup
DUP #20 NEQ ^$no-arrowdown JNZ
( clamp:TODO )
,find-lineoffset JSR2 =position.x ~position.y ++ =position.y
,find-selection JSR2 DUP2 =selection.from ++ =selection.to $no-arrowdown
DUP #40 NEQ ^$no-arrowleft JNZ
( clamp ) ~selection.from ,document.body EQU2 ^$no-arrowleft JNZ
~selection.from -- DUP2 =selection.from ++ =selection.to $no-arrowleft
DUP #80 NEQ ^$no-arrowright JNZ
( clamp:TODO )
#aa =Console.byte
~selection.from ++ DUP2 =selection.from ++ =selection.to $no-arrowright
POP
,clamp-selection JSR2
,follow-selection JSR2
,redraw JSR2
$no-arrow
BRK
@on-mouse ( -> )
~Mouse.state #00 EQU ^$touch-end JNZ
~Mouse.x #0010 LTH2 ,touch-linebar JNZ2
~Mouse.x ~Screen.width 8- LTH2 ,touch-body JNZ2
@ -173,11 +168,9 @@ BRK
~Mouse.state =touch.state
( unlock ) ~lock #00 EQU ,skip-unlock JNZ2 ~lock #01 SUB =lock @skip-unlock
,draw-cursor JSR2
BRK
BRK
@touch-linebar ( -- )
@ -463,64 +456,60 @@ RTN
,draw-titlebar JSR2
( save/load icons )
~Screen.height 8- =Sprite.y
~Screen.height 8- =Screen.y
~Screen.width #0030 SUB2 =Sprite.x
,eye_icn =Sprite.addr
#02 =Sprite.color
~Screen.width #0030 SUB2 =Screen.x
,eye_icn =Screen.addr
#22 =Screen.color
~Screen.width #0028 SUB2 =Sprite.x
,name_icn =Sprite.addr
#02 =Sprite.color
~Screen.width #0028 SUB2 =Screen.x
,name_icn =Screen.addr
#22 =Screen.color
~Screen.width #0020 SUB2 =Sprite.x
,load_icn =Sprite.addr
#02 =Sprite.color
~Screen.width #0020 SUB2 =Screen.x
,load_icn =Screen.addr
#22 =Screen.color
~Screen.width #0018 SUB2 =Sprite.x
,save_icn =Sprite.addr
#02 =Sprite.color
~Screen.width #0018 SUB2 =Screen.x
,save_icn =Screen.addr
#22 =Screen.color
RTN
@draw-short ( short )
=addr
,font_hex #00 ,addr PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
( draw ) #0e =Sprite.color
~Sprite.x 8+ =Sprite.x
,font_hex #00 ,addr PEK2 #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #0e =Sprite.color
~Sprite.x 8+ =Sprite.x
,font_hex #00 ,addr ++ PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
( draw ) #0e =Sprite.color
~Sprite.x 8+ =Sprite.x
,font_hex #00 ,addr ++ PEK2 #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #0e =Sprite.color
,font_hex #00 ,addr PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
( draw ) #2e =Screen.color
~Screen.x 8+ =Screen.x
,font_hex #00 ,addr PEK2 #0f AND #08 MUL ADD2 =Screen.addr
( draw ) #2e =Screen.color
~Screen.x 8+ =Screen.x
,font_hex #00 ,addr ++ PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
( draw ) #2e =Screen.color
~Screen.x 8+ =Screen.x
,font_hex #00 ,addr ++ PEK2 #0f AND #08 MUL ADD2 =Screen.addr
( draw ) #2e =Screen.color
RTN
@draw-cursor
~mouse.x ~Mouse.x NEQ2
~mouse.y ~Mouse.y NEQ2
#0000 EQU2 RTN? ( Return if unchanged )
( clear last cursor )
~mouse.x =Sprite.x
~mouse.y =Sprite.y
,blank_icn =Sprite.addr
#10 =Sprite.color
~mouse.x =Screen.x
~mouse.y =Screen.y
,blank_icn =Screen.addr
#30 =Screen.color
( record mouse positions )
~Mouse.x =mouse.x
~Mouse.y =mouse.y
( draw new cursor )
~mouse.x =Sprite.x
~mouse.y =Sprite.y
,cursor_icn =Sprite.addr
#1f ~Mouse.state #01 EQU #0a MUL SUB =Sprite.color
~mouse.x =Screen.x
~mouse.y =Screen.y
,cursor_icn =Screen.addr
#3f ~Mouse.state #01 EQU #0a MUL SUB =Screen.color
RTN
@ -538,55 +527,55 @@ RTN
~textarea.addr PEK2 #00 NEQ ^$find-offset JNZ
$find-offset-end
#0018 =Sprite.x #0000 =Sprite.y
#0018 =Screen.x #0000 =Screen.y
~textarea.addr =i
$loop
~Sprite.y ~Screen.height #0010 SUB2 GTH2 ,$end JNZ2
~Screen.y ~Screen.height #0010 SUB2 GTH2 ,$end JNZ2
~i PEK2 #0a NEQ ~i PEK2 #0d NEQ #0101 EQU2 ,$no-linebreak JNZ2
( draw linebreak )
,linebreak_icn =Sprite.addr
,linebreak_icn =Screen.addr
( draw ) #02
~i ~selection.from -- GTH2
~i ~selection.to LTH2 #0101 EQU2
#06 MUL ADD =Sprite.color
#26 MUL ADD =Screen.color
( fill clear )
$fill-clear
( incr ) ~Sprite.x 8+ =Sprite.x
,font =Sprite.addr
#01 =Sprite.color
~Sprite.x ~Screen.width 8- LTH2 ^$fill-clear JNZ
( incr ) ~Screen.x 8+ =Screen.x
,font =Screen.addr
#21 =Screen.color
~Screen.x ~Screen.width 8- LTH2 ^$fill-clear JNZ
( draw line number )
#0000 =Sprite.x
~scroll.y ~Sprite.y 8/ ADD2 DUP2 SWP POP =k
#0000 =Screen.x
~scroll.y ~Screen.y 8/ ADD2 DUP2 SWP POP =k
~position.y EQU2 #05 MUL =l
,font_hex #00 ~k #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
#04 ~l ADD =Sprite.color
#0008 =Sprite.x
,font_hex #00 ~k #0f AND #08 MUL ADD2 =Sprite.addr
#04 ~l ADD =Sprite.color
,font_hex #00 ~k #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
#24 ~l ADD =Screen.color
#0008 =Screen.x
,font_hex #00 ~k #0f AND #08 MUL ADD2 =Screen.addr
#24 ~l ADD =Screen.color
#0010 =Sprite.x
( incr ) ~Sprite.y 8+ =Sprite.y
#0010 =Screen.x
( incr ) ~Screen.y 8+ =Screen.y
$no-linebreak
( get character )
,font #00 ~i PEK2 #20 SUB 8* ADD2 =Sprite.addr
,font #00 ~i PEK2 #20 SUB 8* ADD2 =Screen.addr
( is a special character )
~i PEK2 #20 GTH ^$no-tab JNZ ,font =Sprite.addr $no-tab
~i PEK2 #20 GTH ^$no-tab JNZ ,font =Screen.addr $no-tab
( draw ) #01
( draw ) #21
~i ~selection.from -- GTH2
~i ~selection.to LTH2 #0101 EQU2
#05 MUL ADD =Sprite.color
#05 MUL ADD =Screen.color
( incr ) ~i ++ =i
( incr ) ~Sprite.x #0007 ADD2 =Sprite.x
( incr ) ~Screen.x #0007 ADD2 =Screen.x
~i PEK2 #00 NEQ ,$loop JNZ2
@ -598,40 +587,40 @@ RTN
,scrollbar_icn ( keeping a copy on stack )
~Screen.width 8- =Sprite.x
#0008 =Sprite.y
DUP2 =Sprite.addr
~Screen.width 8- =Screen.x
#0008 =Screen.y
DUP2 =Screen.addr
#0008 ~Screen.height 8-
$loop
( draw ) #01 =Sprite.color
( incr ) SWP2 8+ DUP2 =Sprite.y SWP2
( draw ) #21 =Screen.color
( incr ) SWP2 8+ DUP2 =Screen.y SWP2
OVR2 OVR2 LTH2 ^$loop JNZ
POP2 POP2
~scroll.y 8+ =Sprite.y
DUP2 #0008 ADD2 =Sprite.addr
( draw ) #01 =Sprite.color
~scroll.y 8+ =Screen.y
DUP2 #0008 ADD2 =Screen.addr
( draw ) #21 =Screen.color
#0000 =Sprite.y
DUP2 #0010 ADD2 =Sprite.addr
( draw ) #04 =Sprite.color
#0000 =Screen.y
DUP2 #0010 ADD2 =Screen.addr
( draw ) #24 =Screen.color
~Screen.height 8- =Sprite.y
#0018 ADD2 =Sprite.addr
( draw ) #04 =Sprite.color
~Screen.height 8- =Screen.y
#0018 ADD2 =Screen.addr
( draw ) #24 =Screen.color
RTN
@draw-titlebar
#0018 ~Screen.height 8- #09 ,filepath
( load ) =label.addr =label.color =Sprite.y =Sprite.x
#0018 ~Screen.height 8- #29 ,filepath
( load ) =label.addr =label.color =Screen.y =Screen.x
~label.addr
$loop
( draw ) DUP2 PEK2 #00 SWP #20 SUB 8* ,font ADD2 =Sprite.addr ~label.color =Sprite.color
( draw ) DUP2 PEK2 #00 SWP #20 SUB 8* ,font ADD2 =Screen.addr ~label.color =Screen.color
( incr ) ++
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Screen.x 8+ =Screen.x
DUP2 PEK2 #00 NEQ ^$loop JNZ
POP2
( selection )

View File

@ -33,8 +33,7 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
@ -254,65 +253,65 @@ RTN
( position )
~bankview.x =Sprite.x
~bankview.y #0010 SUB2 =Sprite.y
~bankview.x =Screen.x
~bankview.y #0010 SUB2 =Screen.y
~bankview.addr ,draw-short JSR2
( toolbar )
~bankview.x #0068 ADD2 =Sprite.x
~bankview.y #0010 SUB2 =Sprite.y
,tool_selector =Sprite.addr
#01 ~bankview.mode #00 EQU ADD =Sprite.color
~bankview.x #0068 ADD2 =Screen.x
~bankview.y #0010 SUB2 =Screen.y
,tool_selector =Screen.addr
#21 ~bankview.mode #00 EQU ADD =Screen.color
~Sprite.x 8+ =Sprite.x
,tool_hand =Sprite.addr
#01 ~bankview.mode #01 EQU ADD =Sprite.color
~Screen.x 8+ =Screen.x
,tool_hand =Screen.addr
#21 ~bankview.mode #01 EQU ADD =Screen.color
~Sprite.x 8+ =Sprite.x
,tool_eraser =Sprite.addr
#01 ~bankview.mode #02 EQU ADD =Sprite.color
~Screen.x 8+ =Screen.x
,tool_eraser =Screen.addr
#21 ~bankview.mode #02 EQU ADD =Screen.color
~tileview.x #0070 ADD2 =Sprite.x
,load_icn =Sprite.addr
#01 =Sprite.color
~tileview.x #0070 ADD2 =Screen.x
,load_icn =Screen.addr
#21 =Screen.color
~tileview.x #0078 ADD2 =Sprite.x
,save_icn =Sprite.addr
#01 =Sprite.color
~tileview.x #0078 ADD2 =Screen.x
,save_icn =Screen.addr
#21 =Screen.color
( guides )
#00 =i ,font_hex =Sprite.addr
#00 =i ,font_hex =Screen.addr
$guides
~bankview.x #0010 SUB2 =Sprite.x
~bankview.y #00 ~i #08 MUL ADD2 =Sprite.y
( draw ) #02 =Sprite.color
~bankview.x #00 ~i #08 MUL ADD2 =Sprite.x
~bankview.y #0088 ADD2 =Sprite.y
( draw ) #02 =Sprite.color
~Sprite.addr 8+ =Sprite.addr
~bankview.x #0010 SUB2 =Screen.x
~bankview.y #00 ~i #08 MUL ADD2 =Screen.y
( draw ) #22 =Screen.color
~bankview.x #00 ~i #08 MUL ADD2 =Screen.x
~bankview.y #0088 ADD2 =Screen.y
( draw ) #22 =Screen.color
~Screen.addr 8+ =Screen.addr
( incr ) ~i #01 ADD =i
~i #10 LTH ^$guides JNZ
( body )
~bankview.x =Sprite.x ~bankview.y =Sprite.y
#00 =pt.x #00 =pt.y ~bankview.addr =Sprite.addr
~bankview.x =Screen.x ~bankview.y =Screen.y
#00 =pt.x #00 =pt.y ~bankview.addr =Screen.addr
$ver
#00 =pt.x
~bankview.x =Sprite.x
~bankview.x =Screen.x
$hor
( draw ) #01
~Sprite.addr ~tileview.addr LTH2
~Sprite.addr ~tileview.addr #0018 ADD2 GTH2
#0000 EQU2 #06 MUL ADD =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Sprite.addr 8+ =Sprite.addr
( draw ) #21
~Screen.addr ~tileview.addr LTH2
~Screen.addr ~tileview.addr #0018 ADD2 GTH2
#0000 EQU2 #06 MUL ADD =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~Screen.addr 8+ =Screen.addr
( incr ) ~pt.x #01 ADD =pt.x
~pt.x #10 LTH ,$hor JNZ2
( incr ) ~pt.y #01 ADD =pt.y
( incr ) ~Sprite.y 8+ =Sprite.y
( incr ) ~Screen.y 8+ =Screen.y
~pt.y #10 LTH ,$ver JNZ2
RTN
@ -321,36 +320,36 @@ RTN
~tileview.x #0002 SUB2 ~tileview.y #0002 SUB2 ~tileview.x #0080 ADD2 ~tileview.y #0081 ADD2 #03 ,line-rect JSR2
~tileview.x #0028 ADD2 =Sprite.x
~tileview.y #0010 SUB2 =Sprite.y
~tileview.addr =Sprite.addr
#03 =Sprite.color
~tileview.x #0028 ADD2 =Screen.x
~tileview.y #0010 SUB2 =Screen.y
~tileview.addr =Screen.addr
#23 =Screen.color
( position )
~tileview.x =Sprite.x
~tileview.y #0010 SUB2 =Sprite.y
~tileview.x =Screen.x
~tileview.y #0010 SUB2 =Screen.y
~tileview.addr ,draw-short JSR2
( body )
~tileview.x =Sprite.x
~tileview.y =Sprite.y
~tileview.x =Screen.x
~tileview.y =Screen.y
~tileview.addr =tileview.addr
,draw-tileview-icn JSR2
~tileview.x #0040 ADD2 =Sprite.x
~tileview.y =Sprite.y
~tileview.x #0040 ADD2 =Screen.x
~tileview.y =Screen.y
~tileview.addr 8+ =tileview.addr
,draw-tileview-icn JSR2
~tileview.x =Sprite.x
~tileview.y #0040 ADD2 =Sprite.y
~tileview.x =Screen.x
~tileview.y #0040 ADD2 =Screen.y
~tileview.addr 8+ =tileview.addr
,draw-tileview-icn JSR2
~tileview.x #0040 ADD2 =Sprite.x
~tileview.y #0040 ADD2 =Sprite.y
~tileview.x #0040 ADD2 =Screen.x
~tileview.y #0040 ADD2 =Screen.y
~tileview.addr 8+ =tileview.addr
,draw-tileview-icn JSR2
@ -374,43 +373,43 @@ RTN
( bytes )
~tileview.y #0018 ADD2 =Sprite.y
~tileview.y #0018 ADD2 =Screen.y
#00 =i
$bytes
~tileview.x #0088 ADD2 =Sprite.x
,font_hex #00 ~tileview.addr #00 ~i ADD2 PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
( draw ) #02 =Sprite.color
~Sprite.x 8+ =Sprite.x
,font_hex #00 ~tileview.addr #00 ~i ADD2 PEK2 #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #02 =Sprite.color
~tileview.x #0088 ADD2 =Screen.x
,font_hex #00 ~tileview.addr #00 ~i ADD2 PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
( draw ) #22 =Screen.color
~Screen.x 8+ =Screen.x
,font_hex #00 ~tileview.addr #00 ~i ADD2 PEK2 #0f AND #08 MUL ADD2 =Screen.addr
( draw ) #22 =Screen.color
( incr ) ~i #01 ADD =i
( incr ) ~Sprite.y 8+ =Sprite.y
( incr ) ~Screen.y 8+ =Screen.y
~i #08 LTH ,$bytes JNZ2
( operations )
~Sprite.y 8+ =Sprite.y
,movedown_icn =Sprite.addr
#01 =Sprite.color
~Sprite.x 8- =Sprite.x
,moveup_icn =Sprite.addr
#01 =Sprite.color
~Screen.y 8+ =Screen.y
,movedown_icn =Screen.addr
#21 =Screen.color
~Screen.x 8- =Screen.x
,moveup_icn =Screen.addr
#21 =Screen.color
( draw tiles )
~tileview.y =Sprite.y
#00 =pt.x #00 =pt.y ~tileview.addr =Sprite.addr
~tileview.y =Screen.y
#00 =pt.x #00 =pt.y ~tileview.addr =Screen.addr
$tiles-ver
#00 =pt.x
~tileview.x #0088 ADD2 =Sprite.x
~tileview.x #0088 ADD2 =Screen.x
$tiles-hor
( draw ) #03 =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Sprite.addr 8+ =Sprite.addr
( draw ) #23 =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~Screen.addr 8+ =Screen.addr
( incr ) ~pt.x #01 ADD =pt.x
~pt.x #02 LTH ,$tiles-hor JNZ2
( incr ) ~pt.y #01 ADD =pt.y
( incr ) ~Sprite.y 8+ =Sprite.y
( incr ) ~Screen.y 8+ =Screen.y
~pt.y #02 LTH ,$tiles-ver JNZ2
RTN
@ -424,14 +423,14 @@ RTN
( get bit )
,blank_icn #00
~tileview.addr #00 ~pt.y ADD2 PEK2 #07 ~pt.x SUB SFT #01 AND ( get bit )
8* ADD2 =Sprite.addr ( add *8 )
( draw ) #01 =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
8* ADD2 =Screen.addr ( add *8 )
( draw ) #21 =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~pt.x #01 ADD =pt.x
~pt.x #08 LTH ,$hor JNZ2
( incr ) ~Sprite.y 8+ =Sprite.y
( incr ) ~Screen.y 8+ =Screen.y
( incr ) ~pt.y #01 ADD =pt.y
~Sprite.x #0040 SUB2 =Sprite.x
~Screen.x #0040 SUB2 =Screen.x
~pt.y #08 LTH ,$ver JNZ2
RTN
@ -444,37 +443,37 @@ RTN
#0000 EQU2 RTN? ( Return if unchanged )
( clear last cursor )
~mouse.x =Sprite.x
~mouse.y =Sprite.y
,blank_icn =Sprite.addr
#10 =Sprite.color
~mouse.x =Screen.x
~mouse.y =Screen.y
,blank_icn =Screen.addr
#30 =Screen.color
( record mouse positions )
~Mouse.x =mouse.x
~Mouse.y =mouse.y
( draw new cursor )
~mouse.x =Sprite.x
~mouse.y =Sprite.y
,tool_selector #00 ~bankview.mode #08 MUL ADD2 =Sprite.addr
#12 =Sprite.color
~mouse.x =Screen.x
~mouse.y =Screen.y
,tool_selector #00 ~bankview.mode #08 MUL ADD2 =Screen.addr
#32 =Screen.color
RTN
@draw-short ( short )
=addr
,font_hex #00 ,addr PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
( draw ) #02 =Sprite.color
~Sprite.x 8+ =Sprite.x
,font_hex #00 ,addr PEK2 #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #02 =Sprite.color
~Sprite.x 8+ =Sprite.x
,font_hex #00 ,addr ++ PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
( draw ) #02 =Sprite.color
~Sprite.x 8+ =Sprite.x
,font_hex #00 ,addr ++ PEK2 #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #02 =Sprite.color
,font_hex #00 ,addr PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
( draw ) #22 =Screen.color
~Screen.x 8+ =Screen.x
,font_hex #00 ,addr PEK2 #0f AND #08 MUL ADD2 =Screen.addr
( draw ) #22 =Screen.color
~Screen.x 8+ =Screen.x
,font_hex #00 ,addr ++ PEK2 #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
( draw ) #22 =Screen.color
~Screen.x 8+ =Screen.x
,font_hex #00 ,addr ++ PEK2 #0f AND #08 MUL ADD2 =Screen.addr
( draw ) #22 =Screen.color
RTN

View File

@ -13,8 +13,7 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|01a0 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dotw 1 doty 2 isdst 1 pad 4 refresh 1 }
( program )
@ -50,7 +49,7 @@
,neralie-lines JSR2
BRK
#02 =Sprite.color
#22 =Screen.color
#0000 #00 ~number.count DUP2 ,h JSR2
~number.count #01 ADD =number.count
@ -76,8 +75,8 @@
JMP2r
@arvelie-text ( -- )
~Screen.width #0002 DIV2 #0034 SUB2 =Sprite.x
~Screen.height #0008 SUB2 =Sprite.y
~Screen.width #0002 DIV2 #0034 SUB2 =Screen.x
~Screen.height #0008 SUB2 =Screen.y
~DateTime.year #07d6 SUB2
#000a ,modf JSR2 ,digit JSR2
,digit JSR2
@ -88,7 +87,7 @@
JMP2r
@neralie-text ( -- )
~Screen.width #0002 DIV2 #0004 SUB2 =Sprite.x
~Screen.width #0002 DIV2 #0004 SUB2 =Screen.x
~neralie.n0123
#03e8 ,modf JSR2 ^digit JSR
#0064 ,modf JSR2 ^digit JSR
@ -100,14 +99,14 @@
JMP2r
@letter ( index* -- )
#0008 MUL2 ,font-letters ADD2 =Sprite.addr
#0008 MUL2 ,font-letters ADD2 =Screen.addr
^digit-middle JMP
@digit ( index* -- )
#0008 MUL2 ,font-numbers ADD2 =Sprite.addr
#0008 MUL2 ,font-numbers ADD2 =Screen.addr
$middle
~neralie.color =Sprite.color
~Sprite.x #0008 ADD2 =Sprite.x
~neralie.color #20 ADD =Screen.color
~Screen.x #0008 ADD2 =Screen.x
JMP2r
@neralie-lines ( -- )
@ -116,14 +115,14 @@
,neralie.n4 SWP POP ~neralie.n0123
DUP2 ,$h JSR2
,$next JSR2 #0001 =Sprite.x ~neralie.y #0003 SUB2 =Sprite.y ^digit JSR
,$next JSR2 #0001 =Screen.x ~neralie.y #0003 SUB2 =Screen.y ^digit JSR
DUP2 ,$v JSR2
#04 ,v-spacing POK2
~lines.y1 #0003 SUB2 ~neralie.y ~neralie.x ,v JSR2
#01 ,v-spacing POK2
^$next JSR #0001 =Sprite.y ~neralie.x #0003 SUB2 =Sprite.x ,digit JSR2
^$next JSR #0001 =Screen.y ~neralie.x #0003 SUB2 =Screen.x ,digit JSR2
DUP2 ^$h JSR
^$next JSR ~Screen.width #0009 SUB2 =Sprite.x ~neralie.y #0003 SUB2 =Sprite.y ,digit JSR2
^$next JSR ~Screen.width #0009 SUB2 =Screen.x ~neralie.y #0003 SUB2 =Screen.y ,digit JSR2
DUP2 ^$v JSR
^$next JSR POP2
DUP2 ^$h JSR

View File

@ -53,8 +53,7 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 1 }
@ -99,12 +98,12 @@ BRK
@on-screen ( -- )
~document.edit #01 NEQ ^$no-edit JNZ
#0008 =Sprite.x
~Screen.height #0010 SUB2 =Sprite.y
#0008 =Screen.x
~Screen.height #0010 SUB2 =Screen.y
,path.name #01 ~timer #04 DIV #03 AND #03 MUL ADD ,draw-label JSR2
$clear
#00 =Sprite.color
~Sprite.x 8+ DUP2 =Sprite.x
#20 =Screen.color
~Screen.x 8+ DUP2 =Screen.x
~Screen.width LTH2 ^$clear JNZ
( blink ) ~timer #01 ADD =timer
$no-edit
@ -623,37 +622,37 @@ RTN
~zoom.active #01 EQU ,draw-canvas-zoom JNZ2
~canvas.y1 =Sprite.y
,data =Sprite.addr
~canvas.y1 =Screen.y
,data =Screen.addr
$ver
~canvas.x1 =Sprite.x
~canvas.x1 =Screen.x
$hor
( draw ) #09 =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Sprite.addr 8+ =Sprite.addr
~Sprite.x ~canvas.x2 NEQ2 ^$hor JNZ
( incr ) ~Sprite.y 8+ =Sprite.y
~Sprite.y ~canvas.y2 NEQ2 ^$ver JNZ
( draw ) #29 =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~Screen.addr 8+ =Screen.addr
~Screen.x ~canvas.x2 NEQ2 ^$hor JNZ
( incr ) ~Screen.y 8+ =Screen.y
~Screen.y ~canvas.y2 NEQ2 ^$ver JNZ
RTN
@draw-canvas-zoom ( -- )
~zoom.y =pt1.y
~canvas.y1 =Sprite.y
,data =Sprite.addr
~canvas.y1 =Screen.y
,data =Screen.addr
$ver
~canvas.x1 =Sprite.x
~canvas.x1 =Screen.x
~zoom.x =pt1.x
$hor
( incr ) ,bigpixel_icn #0008 #00 ~pt1.x ~pt1.y ,get-pixel JSR2 MUL2 ADD2 =Sprite.addr
( draw ) #09 =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ,bigpixel_icn #0008 #00 ~pt1.x ~pt1.y ,get-pixel JSR2 MUL2 ADD2 =Screen.addr
( draw ) #29 =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~pt1.x ++ =pt1.x
~Sprite.x ~canvas.x2 NEQ2 ^$hor JNZ
( incr ) ~Sprite.y 8+ =Sprite.y
~Screen.x ~canvas.x2 NEQ2 ^$hor JNZ
( incr ) ~Screen.y 8+ =Screen.y
( incr ) ~pt1.y ++ =pt1.y
~Sprite.y ~canvas.y2 NEQ2 ^$ver JNZ
~Screen.y ~canvas.y2 NEQ2 ^$ver JNZ
RTN
@ -666,11 +665,11 @@ RTN
#00 NEQ
#0101 EQU2 RTN? ( Return if unchanged )
,blank_icn =Sprite.addr
,blank_icn =Screen.addr
( clear brush size )
~cursor.x #0003 SUB2 =Sprite.x ~cursor.y #0003 SUB2 =Sprite.y #10 =Sprite.color
~cursor.x #0003 SUB2 =Screen.x ~cursor.y #0003 SUB2 =Screen.y #30 =Screen.color
( clear last cursor )
~cursor.x =Sprite.x ~cursor.y =Sprite.y #10 =Sprite.color
~cursor.x =Screen.x ~cursor.y =Screen.y #30 =Screen.color
( record cursor positions )
~Mouse.x =cursor.x ~Mouse.y =cursor.y
( draw size cursor )
@ -683,15 +682,15 @@ RTN
~Mouse.x CLN2r ~toolpane.x1 GTH2 STH2r ~toolpane.x2 LTH2 #0101 EQU2 ~Mouse.y CLN2r ~toolpane.y1 GTH2 STH2r ~toolpane.y2 LTH2 #0101 EQU2 #0101 EQU2 ,$outside-canvas JNZ2
~Mouse.x CLN2r ~sizepane.x1 GTH2 STH2r ~sizepane.x2 LTH2 #0101 EQU2 ~Mouse.y CLN2r ~sizepane.y1 GTH2 STH2r ~sizepane.y2 LTH2 #0101 EQU2 #0101 EQU2 ,$outside-canvas JNZ2
~Mouse.x CLN2r ~pattpane.x1 GTH2 STH2r ~pattpane.x2 LTH2 #0101 EQU2 ~Mouse.y CLN2r ~pattpane.y1 GTH2 STH2r ~pattpane.y2 LTH2 #0101 EQU2 #0101 EQU2 ,$outside-canvas JNZ2
~cursor.x #0003 SUB2 =Sprite.x ~cursor.y #0003 SUB2 =Sprite.y
,brush_icns #00 ~brush.size 8* ADD2 =Sprite.addr
#11 ~Mouse.state #02 MUL ADD =Sprite.color
~cursor.x #0003 SUB2 =Screen.x ~cursor.y #0003 SUB2 =Screen.y
,brush_icns #00 ~brush.size 8* ADD2 =Screen.addr
#31 ~Mouse.state #02 MUL ADD =Screen.color
~Mouse.state #00 EQU ^$outside-canvas JNZ RTN
$outside-canvas
( draw new cursor )
~cursor.x =Sprite.x ~cursor.y =Sprite.y
,pointers_icn #00 ~Controller.button #02 EQU 8* ADD2 =Sprite.addr
#1f ~Mouse.state #01 EQU #0a MUL SUB =Sprite.color
~cursor.x =Screen.x ~cursor.y =Screen.y
,pointers_icn #00 ~Controller.button #02 EQU 8* ADD2 =Screen.addr
#3f ~Mouse.state #01 EQU #0a MUL SUB =Screen.color
RTN
@ -703,18 +702,18 @@ RTN
~toolpane.x1 -- ~toolpane.y1 -- ~toolpane.x2 ~toolpane.y2 #00 ,line-rect JSR2
~toolpane.x1 #0002 SUB2 ~toolpane.y1 #0002 SUB2 ~toolpane.x2 ~toolpane.y2 #01 ,line-rect JSR2
~toolpane.x1 =Sprite.x ~toolpane.y1 =Sprite.y ,tool_icns =Sprite.addr
~toolpane.x1 =Screen.x ~toolpane.y1 =Screen.y ,tool_icns =Screen.addr
$loop
( draw ) #01 ~Sprite.x ~toolpane.x1 SUB2 8/ SWP POP ~brush.tool EQU #02 MUL ADD =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Sprite.addr 8+ =Sprite.addr
~Sprite.x ~toolpane.x2 LTH2 ^$loop JNZ
( draw ) #21 ~Screen.x ~toolpane.x1 SUB2 8/ SWP POP ~brush.tool EQU #02 MUL ADD =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~Screen.addr 8+ =Screen.addr
~Screen.x ~toolpane.x2 LTH2 ^$loop JNZ
~zoom.active #01 NEQ ^$no-zoom JNZ
~Sprite.x #0008 SUB2 =Sprite.x
,tool_icns #0028 ADD2 =Sprite.addr
#01 #04 ~brush.tool EQU #02 MUL ADD =Sprite.color
~Screen.x #0008 SUB2 =Screen.x
,tool_icns #0028 ADD2 =Screen.addr
#21 #04 ~brush.tool EQU #02 MUL ADD =Screen.color
$no-zoom
RTN
@ -727,13 +726,13 @@ RTN
~pattpane.x1 -- ~pattpane.y1 -- ~pattpane.x2 ~pattpane.y2 #00 ,line-rect JSR2
~pattpane.x1 #0002 SUB2 ~pattpane.y1 #0002 SUB2 ~pattpane.x2 ~pattpane.y2 #01 ,line-rect JSR2
~pattpane.x1 =Sprite.x ~pattpane.y1 =Sprite.y ,patt_icns =Sprite.addr
~pattpane.x1 =Screen.x ~pattpane.y1 =Screen.y ,patt_icns =Screen.addr
$loop
( draw ) #01 ~Sprite.x ~pattpane.x1 SUB2 8/ SWP POP ~brush.patt EQU #02 MUL ADD =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Sprite.addr 8+ =Sprite.addr
~Sprite.x ~pattpane.x2 LTH2 ^$loop JNZ
( draw ) #21 ~Screen.x ~pattpane.x1 SUB2 8/ SWP POP ~brush.patt EQU #02 MUL ADD =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~Screen.addr 8+ =Screen.addr
~Screen.x ~pattpane.x2 LTH2 ^$loop JNZ
RTN
@ -745,13 +744,13 @@ RTN
~sizepane.x1 -- ~sizepane.y1 -- ~sizepane.x2 ~sizepane.y2 #00 ,line-rect JSR2
~sizepane.x1 #0002 SUB2 ~sizepane.y1 #0002 SUB2 ~sizepane.x2 ~sizepane.y2 #01 ,line-rect JSR2
~sizepane.x1 =Sprite.x ~sizepane.y1 =Sprite.y ,size_icns =Sprite.addr
~sizepane.x1 =Screen.x ~sizepane.y1 =Screen.y ,size_icns =Screen.addr
$loop
( draw ) #01 ~Sprite.x ~sizepane.x1 SUB2 8/ SWP POP ~brush.size EQU #02 MUL ADD =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Sprite.addr 8+ =Sprite.addr
~Sprite.x ~sizepane.x2 LTH2 ^$loop JNZ
( draw ) #21 ~Screen.x ~sizepane.x1 SUB2 8/ SWP POP ~brush.size EQU #02 MUL ADD =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~Screen.addr 8+ =Screen.addr
~Screen.x ~sizepane.x2 LTH2 ^$loop JNZ
RTN
@ -763,13 +762,13 @@ RTN
~viewpane.x1 -- ~viewpane.y1 -- ~viewpane.x2 ~viewpane.y2 #00 ,line-rect JSR2
~viewpane.x1 #0002 SUB2 ~viewpane.y1 #0002 SUB2 ~viewpane.x2 ~viewpane.y2 #01 ,line-rect JSR2
~viewpane.x1 =Sprite.x ~viewpane.y1 =Sprite.y ,view_icns =Sprite.addr
~viewpane.x1 =Screen.x ~viewpane.y1 =Screen.y ,view_icns =Screen.addr
$loop
( draw ) #01 =Sprite.color
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Sprite.addr 8+ =Sprite.addr
~Sprite.x ~viewpane.x2 LTH2 ^$loop JNZ
( draw ) #21 =Screen.color
( incr ) ~Screen.x 8+ =Screen.x
( incr ) ~Screen.addr 8+ =Screen.addr
~Screen.x ~viewpane.x2 LTH2 ^$loop JNZ
RTN
@ -791,35 +790,35 @@ RTN
~document.presentation #01 EQU ,$skip-size JNZ2
( draw size )
#0010 =Sprite.y
#0010 =Screen.y
( draw width )
~Screen.width #00a0 SUB2 =Sprite.x ,font_hex ~canvas.w #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
( draw ) #01 =Sprite.color
~Sprite.x 8+ =Sprite.x ,font_hex ~canvas.w #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #01 =Sprite.color
~Screen.width #00a0 SUB2 =Screen.x ,font_hex ~canvas.w #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
( draw ) #21 =Screen.color
~Screen.x 8+ =Screen.x ,font_hex ~canvas.w #0f AND #08 MUL ADD2 =Screen.addr
( draw ) #21 =Screen.color
( draw height )
~Sprite.x 8+ =Sprite.x ,font_hex ~canvas.h #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
( draw ) #01 =Sprite.color
~Sprite.x 8+ =Sprite.x ,font_hex ~canvas.h #0f AND #08 MUL ADD2 =Sprite.addr
( draw ) #01 =Sprite.color
~Screen.x 8+ =Screen.x ,font_hex ~canvas.h #f0 AND #04 SFT #08 MUL ADD2 =Screen.addr
( draw ) #21 =Screen.color
~Screen.x 8+ =Screen.x ,font_hex ~canvas.h #0f AND #08 MUL ADD2 =Screen.addr
( draw ) #21 =Screen.color
$skip-size
( draw save/load/guides icons )
~Screen.height #0010 SUB2 =Sprite.y
~Screen.width #0028 SUB2 =Sprite.x
,eye_icn #00 ~document.presentation #08 MUL ADD2 =Sprite.addr
#03 =Sprite.color
~Sprite.x 8+ =Sprite.x
,filestate_icn =Sprite.addr
#03 =Sprite.color
~Sprite.x 8+ =Sprite.x
,load_icn =Sprite.addr
#03 =Sprite.color
~Sprite.x 8+ =Sprite.x
,save_icn =Sprite.addr
#03 =Sprite.color
~Screen.height #0010 SUB2 =Screen.y
~Screen.width #0028 SUB2 =Screen.x
,eye_icn #00 ~document.presentation #08 MUL ADD2 =Screen.addr
#23 =Screen.color
~Screen.x 8+ =Screen.x
,filestate_icn =Screen.addr
#23 =Screen.color
~Screen.x 8+ =Screen.x
,load_icn =Screen.addr
#23 =Screen.color
~Screen.x 8+ =Screen.x
,save_icn =Screen.addr
#23 =Screen.color
#0008 =Sprite.x
#0008 =Screen.x
,path.name #01 ,draw-label JSR2
RTN
@ -861,10 +860,10 @@ RTN
=color
$loop
DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr
( draw ) ~color =Sprite.color
DUP2 PEK2 #00 SWP #0008 MUL2 ,font ADD2 =Screen.addr
( draw ) ~color #20 ADD =Screen.color
( incr ) #0001 ADD2
( incr ) ~Sprite.x 8+ =Sprite.x
( incr ) ~Screen.x 8+ =Screen.x
( loop ) DUP2 PEK2 #00 NEQ ^$loop JNZ
POP2

View File

@ -28,7 +28,7 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 2 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 color 1 }
|0120 ;Screen { vector 2 width 2 height 2 pad 2 x 2 y 2 addr 2 color 1 }
|0130 ;Sprite { vector 2 pad 6 x 2 y 2 addr 2 color 1 }
|0140 ;Controller { vector 2 button 1 }
|0150 ;Keys { vector 2 key 1 }

View File

@ -210,29 +210,15 @@ console_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
Uint8
screen_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
{
Uint8 *m = u->ram.dat;
ptr += 8;
if(b0 == 0x0c) {
Uint16 x = (m[ptr] << 8) + m[ptr + 1];
Uint16 y = (m[ptr + 2] << 8) + m[ptr + 3];
Uint8 *layer = b1 >> 4 & 0xf ? ppu.fg : ppu.bg;
putpixel(&ppu, layer, x, y, b1 & 0xf);
reqdraw = 1;
}
return b1;
}
Uint8
sprite_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1)
{
Uint8 *m = u->ram.dat;
ptr += 8;
if(b0 == 0x0e) {
Uint16 x = (m[ptr] << 8) + m[ptr + 1];
Uint16 y = (m[ptr + 2] << 8) + m[ptr + 3];
Uint8 *layer = (b1 >> 4) & 0xf ? ppu.fg : ppu.bg;
Uint8 *sprite = &m[(m[ptr + 4] << 8) + m[ptr + 5]];
putsprite(&ppu, layer, x, y, sprite, b1 & 0xf);
Uint16 x = mempeek16(u, ptr + 8);
Uint16 y = mempeek16(u, ptr + 10);
Uint8 *addr = &u->ram.dat[mempeek16(u, ptr + 12)];
Uint8 *layer = (b1 >> 4 & 0xf) % 2 ? ppu.fg : ppu.bg;
if((b1 >> 4 & 0xf) / 2)
putsprite(&ppu, layer, x, y, addr, b1 & 0xf);
else
putpixel(&ppu, layer, x, y, b1 & 0xf);
reqdraw = 1;
}
return b1;
@ -398,7 +384,7 @@ main(int argc, char **argv)
devsystem = portuxn(&u, 0x00, "system", system_poke);
portuxn(&u, 0x01, "console", console_poke);
devscreen = portuxn(&u, 0x02, "screen", screen_poke);
portuxn(&u, 0x03, "sprite", sprite_poke);
portuxn(&u, 0x03, "---", ppnil);
devctrl = portuxn(&u, 0x04, "controller", ppnil);
devkey = portuxn(&u, 0x05, "key", ppnil);
devmouse = portuxn(&u, 0x06, "mouse", ppnil);

View File

@ -46,5 +46,7 @@ int loaduxn(Uxn *c, char *filepath);
int bootuxn(Uxn *c);
int inituxn(Uxn *u, Uint16 vec);
int evaluxn(Uxn *u, Uint16 vec);
Device *portuxn(Uxn *u, Uint8 id, char *name, Uint8 (*pofn)(Uxn *, Uint16, Uint8, Uint8));
void mempoke16(Uxn *u, Uint16 a, Uint16 b);
void mempoke16(Uxn *u, Uint16 a, Uint16 b);
Uint16 mempeek16(Uxn *u, Uint16 a);
Device *portuxn(Uxn *u, Uint8 id, char *name, Uint8 (*pofn)(Uxn *, Uint16, Uint8, Uint8));