0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-23 06:15:10 +00:00

Added chorded controls to left

This commit is contained in:
neauoire 2021-03-12 11:37:45 -08:00
parent 9f264959a3
commit 4431d59b17
2 changed files with 70 additions and 28 deletions

View file

@ -282,9 +282,9 @@ domouse(Uxn *u, SDL_Event *event)
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
setflag(&u->ram.dat[addr + 4], flag, 1); setflag(&u->ram.dat[addr + 4], flag, 1);
if(flag == 0x01 && getflag(&u->ram.dat[addr + 4], 0x10))
u->ram.dat[addr + 5] = 0x01;
if(flag == 0x10 && getflag(&u->ram.dat[addr + 4], 0x01)) if(flag == 0x10 && getflag(&u->ram.dat[addr + 4], 0x01))
u->ram.dat[addr + 5] = 0x01;
if(flag == 0x01 && getflag(&u->ram.dat[addr + 4], 0x10))
u->ram.dat[addr + 5] = 0x10; u->ram.dat[addr + 5] = 0x10;
break; break;
} }
@ -340,8 +340,8 @@ console_poke(Uint8 *m, Uint16 ptr, Uint8 b0, Uint8 b1)
{ {
switch(b0) { switch(b0) {
case 0x08: printf("%c", b1); break; case 0x08: printf("%c", b1); break;
case 0x09: printf("%02x", b1); break; case 0x09: printf("0x%02x\n", b1); break;
case 0x0b: printf("%04x", (m[ptr + 0x0a] << 8) + b1); break; case 0x0b: printf("0x%04x\n", (m[ptr + 0x0a] << 8) + b1); break;
} }
fflush(stdout); fflush(stdout);
(void)m; (void)m;

View file

@ -2,7 +2,6 @@
app/left : text editor app/left : text editor
TODO TODO
- Copy/Cut/Paste
- Save/Load - Save/Load
- Double-click select word - Double-click select word
- Right-click find next instance of selection - Right-click find next instance of selection
@ -14,7 +13,7 @@
- Real scrolling distance - Real scrolling distance
) )
&Console { pad 8 stdio 1 } &Console { pad 8 char 1 byte 1 short 2 }
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } &Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
&Sprite { pad 8 x 2 y 2 addr 2 color 1 } &Sprite { pad 8 x 2 y 2 addr 2 color 1 }
&Controller { buttons 1 } &Controller { buttons 1 }
@ -23,6 +22,7 @@
&File { pad 8 name 2 length 2 load 2 save 2 } &File { pad 8 name 2 length 2 load 2 save 2 }
&Document { eof 2 body 8000 } &Document { eof 2 body 8000 }
&Clip { len 2 body 256 }
&Range2d { from 2 to 2 } &Range2d { from 2 to 2 }
&Point2d { x 2 y 2 } &Point2d { x 2 y 2 }
@ -162,15 +162,16 @@ BRK
@touch-scrollbar @touch-scrollbar
,no-click-scroll-up ~MOUS.y #0008 GTH2 JMP2? POP2 ,$no-up ~MOUS.y #0008 GTH2 JMP2? POP2
( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y ( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y
,redraw JSR2 ,touch-end JMP2 ^$end JMPS
@no-click-scroll-up $no-up
,no-click-scroll-down ~MOUS.y ~SCRN.height #0008 SUB2 LTH2 JMP2? POP2 ,$no-down ~MOUS.y ~SCRN.height #0008 SUB2 LTH2 JMP2? POP2
( incr ) ~scroll.y #0001 ADD2 =scroll.y ( incr ) ~scroll.y #0001 ADD2 =scroll.y
,redraw JSR2 ,touch-end JMP2 ^$end JMPS
@no-click-scroll-down $no-down
~MOUS.y #0008 SUB2 =scroll.y ~MOUS.y #0008 SUB2 =scroll.y
$end
,redraw JSR2 ,redraw JSR2
,touch-end JMP2 ,touch-end JMP2
@ -190,16 +191,28 @@ RTS
~MOUS.y #0008 DIV2 ~scroll.y ADD2 =position.y ~MOUS.y #0008 DIV2 ~scroll.y ADD2 =position.y
~MOUS.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x ~MOUS.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x
,touch-when ~MOUS.state ~touch.state NEQ ~CTRL #0f AND #02 NEQ #0101 EQU2 JMP2? POP2 ,$no-chord-cut ~MOUS.chord #01 NEQ JMP2? POP2
,cut JSR2
( release ) #00 DUP =MOUS.state =MOUS.chord
^$end JMPS
$no-chord-cut
,$no-chord-paste ~MOUS.chord #10 NEQ JMP2? POP2
,paste JSR2
( release ) #00 DUP =MOUS.state =MOUS.chord
^$end JMPS
$no-chord-paste
,$end ~MOUS.state #11 EQU JMP2? POP2
,$no-drag ~MOUS.state ~touch.state NEQ ~CTRL #0f AND #02 NEQ #0101 EQU2 JMP2? POP2
( on drag ) ( on drag )
,find-selection JSR2 #0001 ADD2 =selection.to ,find-selection JSR2 #0001 ADD2 =selection.to
,clamp-selection JSR2 ,clamp-selection JSR2
,redraw JSR2 ^$end JMPS
,touch-end JMP2 $no-drag
@touch-when
( on click ) ( on click )
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to ,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to
$end
,redraw JSR2 ,redraw JSR2
,touch-end JMP2 ,touch-end JMP2
@ -208,7 +221,6 @@ RTS
@load-file ( path ) @load-file ( path )
=FILE.name #8000 =FILE.length ,document.body =FILE.load =FILE.name #8000 =FILE.length ,document.body =FILE.load
( get file length ) ( get file length )
,document.body =document.eof ,document.body =document.eof
$loop NOP $loop NOP
@ -333,9 +345,7 @@ RTS
@find-selection ( position -> addr ) @find-selection ( position -> addr )
,find-line JSR2 ( find line ) ,find-line JSR2 ( find line )
#0000 =pt.x #0000 =pt.x
$loop NOP $loop NOP
,$end ~j ~pt.x ADD2 LDR #0a EQU JMP2? POP2 ,$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 #0d EQU JMP2? POP2
@ -346,10 +356,41 @@ RTS
RTS RTS
@cut
,copy JSR2
~selection.to ~selection.from SUB2 ,shift-left JSR2
~selection.from #0001 ADD2 =selection.to
RTS
@copy ( selection )
#0000 =i ( start )
~selection.to ~selection.from SUB2 =j ( end )
~j =clip.len
$loop
~selection.from ~i ADD2 LDR ,clip.body ~i ADD2 STR
( incr ) ~i #0001 ADD2 =i
,$loop ~i ~j LTH2 JMP2? POP2
RTS
@paste
~clip.len ,shift-right JSR2
#0000 =i ( start )
~clip.len =j ( end )
$loop
,clip.body ~i ADD2 LDR ~selection.from ~i ADD2 STR
( incr ) ~i #0001 ADD2 =i
,$loop ~i ~j LTH2 JMP2? POP2
RTS
@select ( position -> selection ) @select ( position -> selection )
,document.body =selection.from #0000 =pt.x #0000 =pt.y ,document.body =selection.from #0000 =pt.x #0000 =pt.y
$loop $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? POP2
( incr ) ~pt.y #0001 ADD2 =pt.y ( incr ) ~pt.y #0001 ADD2 =pt.y
@ -623,14 +664,15 @@ RTS
@arrowdown_icn [ 0010 1010 fe7c 3810 ] @arrowdown_icn [ 0010 1010 fe7c 3810 ]
@load_icn [ feaa d6aa d4aa f400 ] @load_icn [ feaa d6aa d4aa f400 ]
@save_icn [ fe82 8282 848a f400 ] @save_icn [ fe82 8282 848a f400 ]
@filepath [ projects/examples/gui.hover.usm 00 ] @filepath1 [ projects/examples/gui.hover.usm 00 ]
@filepath1 [ projects/software/left.usm 00 ] @filepath [ projects/software/left.usm 00 ]
|4000 ;document Document |3000 ;document Document
|c000 ;clip Clip
|d000 @ERROR BRK |d000 @ERROR BRK
|FF00 ;dev/console Console |FF00 ;CNSL Console
|FF10 ;SCRN Screen |FF10 ;SCRN Screen
|FF20 ;SPRT Sprite |FF20 ;SPRT Sprite
|FF30 ;CTRL Controller |FF30 ;CTRL Controller