commit c79118bd9021ec665ec348940202dbfa6b353309
parent 38ce9fb0b62f6c7627fc21fc953a2cce01ef928a
Author: neauoire <aliceffekt@gmail.com>
Date: Sun, 28 Feb 2021 09:40:19 -0800
Fixed issue with dev/ctrl
Diffstat:
5 files changed, 96 insertions(+), 83 deletions(-)
diff --git a/build.sh b/build.sh
@@ -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 examples/dev.mouse.usm bin/boot.rom
+./bin/assembler examples/dev.ctrl.usm bin/boot.rom
./bin/emulator bin/boot.rom
diff --git a/emulator.c b/emulator.c
@@ -304,18 +304,16 @@ doctrl(Uxn *u, SDL_Event *event, int z)
Uint16 addr = devctrl->addr;
if(z && event->key.keysym.sym == SDLK_h && SDL_GetModState() & KMOD_LCTRL)
GUIDES = !GUIDES;
- if(SDL_GetModState() & KMOD_LCTRL || SDL_GetModState() & KMOD_RCTRL)
- flag = 0x01;
- if(SDL_GetModState() & KMOD_LALT || SDL_GetModState() & KMOD_RALT)
- flag = 0x02;
switch(event->key.keysym.sym) {
+ case SDLK_LCTRL: flag = 0x01; break;
+ case SDLK_LALT: flag = 0x02; break;
case SDLK_BACKSPACE:
flag = 0x04;
- if(z) u->ram.dat[0xff40] = 0x08;
+ if(z) u->ram.dat[devkey->addr] = 0x08;
break;
case SDLK_RETURN:
flag = 0x08;
- if(z) u->ram.dat[0xff40] = 0x0d;
+ if(z) u->ram.dat[devkey->addr] = 0x0d;
break;
case SDLK_UP: flag = 0x10; break;
case SDLK_DOWN: flag = 0x20; break;
diff --git a/etc/usm.sublime-syntax b/etc/usm.sublime-syntax
@@ -9,47 +9,39 @@ file_extensions:
scope: source.usm
contexts:
- prototype:
- - include: comments
-
main:
- - include: keywords
- - include: numbers
- - include: strings
-
- numbers:
- - match: '\|(\S+)\s?'
- scope: punctuation.definition
- pop: true
- - match: '\_(\S+)\s?'
- scope: punctuation.definition
- pop: true
- - match: '\+(\S+)\s?'
- scope: keyword.control
- pop: true
- - match: '\-(\S+)\s?'
- scope: keyword.control
- pop: true
- - match: '\~(\S+)\s?'
- scope: keyword.control
- pop: true
- - match: '\=(\S+)\s?'
- scope: keyword.control
- pop: true
-
- strings:
- - match: '\:(\S+)\s?'
+ # pointer
+ - match: '\@(\S+)\s?'
scope: string.control
pop: true
+ # jump
+ - match: '\|(\S+)\s?'
+ scope: variable.control
+ pop: true
+ # variables
- match: '\;(\S+)\s?'
scope: string.control
pop: true
- - match: '\@(\S+)\s?'
+ # constants
+ - match: '\:(\S+)\s?'
scope: string.control
pop: true
+ # structs
- match: '\&(\S+)\s?'
scope: string.control
pop: true
+
+ # Special
+
+ - match: '\~(\S+)\s?'
+ scope: entity.name.type
+ pop: true
+ - match: '\=(\S+)\s?'
+ scope: entity.name.type
+ pop: true
+
+ # Pushing to stack
+
- match: '\,(\S+)\s?'
scope: keyword.control
pop: true
@@ -58,21 +50,31 @@ contexts:
pop: true
- match: '\.(\S+)\s?'
scope: keyword.control
+ - match: '\+(\S+)\s?'
+ scope: string.control
pop: true
- - match: '\"(\S+)\s?'
- scope: keyword.control
- pop: true
- - match: '\['
- scope: punctuation.definition.keyword.usm
+ - match: '\-(\S+)\s?'
+ scope: string.control
+
+ # Blocks
+
+ - match: '\{'
+ scope: variable.control
push:
- - meta_scope: keyword.line.double-slash.usm
- - match: '\]'
+ - meta_scope: variable.control
+ - match: '\}'
pop: true
- comments:
- match: '\('
- scope: punctuation.definition.comment.usm
+ scope: comment
push:
- - meta_scope: comment.line.double-slash.usm
+ - meta_scope: comment.line
- match: '\)'
pop: true
+
+ - match: '\['
+ scope: keyword
+ push:
+ - meta_scope: keyword.line
+ - match: '\]'
+ pop: true
diff --git a/examples/dev.ctrl.usm b/examples/dev.ctrl.usm
@@ -4,58 +4,70 @@
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
&Controller { buttons 1 }
-&Point2d { x 2 y 2 }
-
-;pos Point2d
-;sprite 2
+;slime-color 1
|0100 @RESET
( set origin )
- ~dev/screen.width #0002 DIV2 =pos.x
- ~dev/screen.height #0002 DIV2 =pos.y
-
- #12 ,up_icn ~pos.y ~pos.x ,draw-sprite JSR
+ ~dev/screen.width #0002 DIV2 =dev/sprite.x
+ ~dev/screen.height #0002 DIV2 =dev/sprite.y
+ ,default_icn =dev/sprite.addr
+ #11 =dev/sprite.color
+ #0a =slime-color
BRK
|c000 @FRAME
+
+ #0a =slime-color
+ ( hold ctrl key to change slime color )
+ ,no-ctrl ~dev/ctrl.buttons #0f AND #01 NEQ JMP? POP2
+ #05 =slime-color
+ @no-ctrl
+ ( hold alt key to change slime color )
+ ,no-alt ~dev/ctrl.buttons #0f AND #02 NEQ JMP? POP2
+ #0f =slime-color
+ @no-alt
+ ( detect movement )
+ ,no-up ~dev/ctrl.buttons #f0 AND #10 NEQ JMP? POP2
+ ( clear ) #10 =dev/sprite.color
+ ( move ) ~dev/sprite.y #0001 SUB2 =dev/sprite.y ,up_icn =dev/sprite.addr
+ ( draw ) ,redraw JSR BRK
+ @no-up
+ ,no-down ~dev/ctrl.buttons #f0 AND #20 NEQ JMP? POP2
+ ( clear ) #10 =dev/sprite.color
+ ( move ) ~dev/sprite.y #0001 ADD2 =dev/sprite.y ,down_icn =dev/sprite.addr
+ ( draw ) ,redraw JSR BRK
+ @no-down
+ ,no-left ~dev/ctrl.buttons #f0 AND #40 NEQ JMP? POP2
+ ( clear ) #10 =dev/sprite.color
+ ( move ) ~dev/sprite.x #0001 SUB2 =dev/sprite.x ,left_icn =dev/sprite.addr
+ ( draw ) ,redraw JSR BRK
+ @no-left
+ ,no-right ~dev/ctrl.buttons #f0 AND #80 NEQ JMP? POP2
+ ( clear ) #10 =dev/sprite.color
+ ( move ) ~dev/sprite.x #0001 ADD2 =dev/sprite.x ,right_icn =dev/sprite.addr
+ ( draw ) ,redraw JSR BRK
+ @no-right
- ,default_icn =sprite
+BRK
- ~dev/ctrl.buttons #10 NEQ ,next1 ROT JMP? POP2
- ,up_icn =sprite
- ~pos.y #0001 SUB2 =pos.y
- @next1
- ~dev/ctrl.buttons #20 NEQ ,next2 ROT JMP? POP2
- ,down_icn =sprite
- ~pos.y #0001 ADD2 =pos.y
- @next2
- ~dev/ctrl.buttons #40 NEQ ,next3 ROT JMP? POP2
- ,left_icn =sprite
- ~pos.x #0001 SUB2 =pos.x
- @next3
- ~dev/ctrl.buttons #80 NEQ ,end ROT JMP? POP2
- ,right_icn =sprite
- ~pos.x #0001 ADD2 =pos.x
- @end
- ( redraw )
- #13 ~sprite ~pos.y ~pos.x ,draw-sprite JSR
+@redraw
+
+ ( draw face )
+ #11 =dev/sprite.color
+ ( draw slime )
+ ,slime_icn =dev/sprite.addr
+ ~slime-color =dev/sprite.color
-BRK
+RTS
@default_icn [ 3c7e ffdb ffe7 7e3c ]
@up_icn [ 2466 e7db ffff 7e3c ]
@down_icn [ 3c7e ffff dbe7 6624 ]
@left_icn [ 3c7e ef1f 1fef 7e3c ]
@right_icn [ 3c7e f7f8 f8f7 7e3c ]
-
-@draw-sprite
- =dev/sprite.x
- =dev/sprite.y
- =dev/sprite.addr
- =dev/sprite.color
- RTS
+@slime_icn [ 0000 183c 3c18 0000 ]
|d000 @ERROR BRK
@@ -63,5 +75,5 @@ BRK
|FF20 ;dev/sprite Sprite
|FF30 ;dev/ctrl Controller
-|FFF0 [ 02ac 05bb 0b53 ] ( palette )
+|FFF0 [ 0daf 02ff 035f ] ( palette )
|FFFA .RESET .FRAME .ERROR
diff --git a/examples/old.paint.usm b/examples/old.paint.usm
@@ -4,6 +4,7 @@
:dev/w fff9 ( std write port )
&Point2d { x 2 y 2 }
+
;mouse Point2d
;state 1 ;color 1 ;brush 2