Fixed issue with controller.key

This commit is contained in:
neauoire 2021-04-10 20:55:31 -07:00
parent ad19620b82
commit 86a52e1091
5 changed files with 35 additions and 44 deletions

View File

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

View File

@ -45,8 +45,7 @@
|0100 ;System { vector 2 pad 6 r 2 g 2 b 2 } |0100 ;System { vector 2 pad 6 r 2 g 2 b 2 }
|0110 ;Console { pad 8 char 1 byte 1 short 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 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 } |0140 ;Controller { vector 2 button 1 key 1 }
|0150 ;Keys { vector 2 key 1 }
|0160 ;Mouse { vector 2 x 2 y 2 state 1 chord 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 } |0170 ;File { pad 8 name 2 length 2 load 2 save 2 }
@ -56,7 +55,6 @@
( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b ( theme ) #e0fa =System.r #30fa =System.g #30fa =System.b
( vectors ) ,on-mouse =Mouse.vector ( vectors ) ,on-mouse =Mouse.vector
( vectors ) ,on-key =Keys.vector
( vectors ) ,on-button =Controller.vector ( vectors ) ,on-button =Controller.vector
( load file ) ( load file )
@ -70,38 +68,11 @@
BRK BRK
@on-key
~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
,redraw JSR2
BRK
@on-button ( -> ) @on-button ( -> )
( alt + arrow ) ( alt + arrow )
~Controller #0f AND #02 NEQ ^$no-alt JNZ ~Controller.button #0f AND #02 NEQ ^$no-alt JNZ
~Controller #04 SFT ~Controller.button #04 SFT
DUP #01 NEQ ^$no-aup JNZ DUP #01 NEQ ^$no-aup JNZ
( sel word ) ,find-wordstart JSR2 =selection.to $no-aup ( sel word ) ,find-wordstart JSR2 =selection.to $no-aup
DUP #02 NEQ ^$no-adown JNZ DUP #02 NEQ ^$no-adown JNZ
@ -117,8 +88,8 @@ BRK
$no-alt $no-alt
( ctrl + arrow ) ( ctrl + arrow )
~Controller #0f AND #01 NEQ ^$no-ctrl JNZ ~Controller.button #0f AND #01 NEQ ^$no-ctrl JNZ
~Controller #04 SFT ~Controller.button #04 SFT
DUP #01 NEQ ^$no-cup JNZ DUP #01 NEQ ^$no-cup JNZ
( jump scroll ) #0004 ,scroll-up JSR2 $no-cup ( jump scroll ) #0004 ,scroll-up JSR2 $no-cup
DUP #02 NEQ ^$no-cdown JNZ DUP #02 NEQ ^$no-cdown JNZ
@ -133,8 +104,8 @@ BRK
$no-ctrl $no-ctrl
( arrow ) ( arrow )
~Controller #f0 AND #00 EQU ,$no-arrow JNZ2 ~Controller.button #f0 AND #00 EQU ,$no-arrow JNZ2
~Controller #f0 AND ~Controller.button #f0 AND
DUP #10 NEQ ^$no-arrowup JNZ DUP #10 NEQ ^$no-arrowup JNZ
( clamp ) ~position.y #0000 EQU2 ^$no-arrowup JNZ ( clamp ) ~position.y #0000 EQU2 ^$no-arrowup JNZ
,find-lineoffset JSR2 =position.x ~position.y -- =position.y ,find-lineoffset JSR2 =position.x ~position.y -- =position.y
@ -156,6 +127,28 @@ BRK
,redraw JSR2 ,redraw JSR2
$no-arrow $no-arrow
~Controller.key #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
~selection.from ++ =selection.to
,redraw JSR2
BRK
$no-backspace
( insert )
~selection.to ~selection.from SUB2 ,shift-right JSR2
~Controller.key ~selection.from POK2
~selection.from ++ =selection.from
~selection.from ++ =selection.to
,redraw JSR2
BRK BRK
@on-mouse ( -> ) @on-mouse ( -> )
@ -199,7 +192,7 @@ BRK
BRK BRK
$no-chords $no-chords
( drag ) ( drag )
~Mouse.state ~touch.state NEQ ~Controller #0f AND #02 NEQ #0101 EQU2 ^$no-drag JNZ ~Mouse.state ~touch.state NEQ ~Controller.button #0f AND #02 NEQ #0101 EQU2 ^$no-drag JNZ
( on drag ) ( on drag )
,find-selection JSR2 ++ =selection.to ,find-selection JSR2 ++ =selection.to
,clamp-selection JSR2 ,clamp-selection JSR2

View File

@ -303,7 +303,6 @@ BRK
~path.length #1f EQU ^$edit-end JNZ ~path.length #1f EQU ^$edit-end JNZ
~Controller.key ,path.name #00 ~path.length ADD2 POK2 ~Controller.key ,path.name #00 ~path.length ADD2 POK2
~path.length #01 ADD =path.length ~path.length #01 ADD =path.length
~Controller.key =Console.byte
$edit-end $edit-end
#00 ,path.name #00 ~path.length ADD2 POK2 #00 ,path.name #00 ~path.length ADD2 POK2
BRK BRK

View File

@ -84,7 +84,6 @@ BRK
~Controller.key #00 EQU ^$no-key JNZ ~Controller.key #00 EQU ^$no-key JNZ
~selection.x1 ~selection.y1 ~Controller.key SET-CELL ~selection.x1 ~selection.y1 ~Controller.key SET-CELL
~Controller.key =Console.byte
,redraw JSR2 ,redraw JSR2
$no-key $no-key
@ -108,8 +107,7 @@ BRK
~selection.x2 #01 ADD =selection.x2 $no-right ~selection.x2 #01 ADD =selection.x2 $no-right
POP POP
~Controller.button #04 NEQ ^$no-backspace JNZ ~Controller.key #08 NEQ ^$no-backspace JNZ
~Controller.button =Console.byte
~selection.x1 ~selection.y1 #2e SET-CELL ( put . char ) ~selection.x1 ~selection.y1 #2e SET-CELL ( put . char )
$no-backspace $no-backspace

View File

@ -164,8 +164,8 @@ doctrl(Uxn *u, SDL_Event *event, int z)
switch(event->key.keysym.sym) { switch(event->key.keysym.sym) {
case SDLK_LCTRL: flag = 0x01; break; case SDLK_LCTRL: flag = 0x01; break;
case SDLK_LALT: flag = 0x02; break; case SDLK_LALT: flag = 0x02; break;
case SDLK_ESCAPE: flag = 0x04; break; case SDLK_LSHIFT: flag = 0x04; break;
case SDLK_LSHIFT: flag = 0x08; break; case SDLK_ESCAPE: flag = 0x08; break;
case SDLK_UP: flag = 0x10; break; case SDLK_UP: flag = 0x10; break;
case SDLK_DOWN: flag = 0x20; break; case SDLK_DOWN: flag = 0x20; break;
case SDLK_LEFT: flag = 0x40; break; case SDLK_LEFT: flag = 0x40; break;
@ -332,6 +332,7 @@ start(Uxn *u)
doctrl(u, &event, event.type == SDL_KEYDOWN); doctrl(u, &event, event.type == SDL_KEYDOWN);
evaluxn(u, devctrl->vector); evaluxn(u, devctrl->vector);
u->ram.dat[devctrl->addr + 3] = 0; u->ram.dat[devctrl->addr + 3] = 0;
break;
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION: