mirror of https://git.sr.ht/~rabbits/uxn
Fixed issue with dev/ctrl
This commit is contained in:
parent
38ce9fb0b6
commit
c79118bd90
2
build.sh
2
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
|
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
||||||
|
|
||||||
# run
|
# run
|
||||||
./bin/assembler examples/dev.mouse.usm bin/boot.rom
|
./bin/assembler examples/dev.ctrl.usm bin/boot.rom
|
||||||
./bin/emulator bin/boot.rom
|
./bin/emulator bin/boot.rom
|
||||||
|
|
10
emulator.c
10
emulator.c
|
@ -304,18 +304,16 @@ doctrl(Uxn *u, SDL_Event *event, int z)
|
||||||
Uint16 addr = devctrl->addr;
|
Uint16 addr = devctrl->addr;
|
||||||
if(z && event->key.keysym.sym == SDLK_h && SDL_GetModState() & KMOD_LCTRL)
|
if(z && event->key.keysym.sym == SDLK_h && SDL_GetModState() & KMOD_LCTRL)
|
||||||
GUIDES = !GUIDES;
|
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) {
|
switch(event->key.keysym.sym) {
|
||||||
|
case SDLK_LCTRL: flag = 0x01; break;
|
||||||
|
case SDLK_LALT: flag = 0x02; break;
|
||||||
case SDLK_BACKSPACE:
|
case SDLK_BACKSPACE:
|
||||||
flag = 0x04;
|
flag = 0x04;
|
||||||
if(z) u->ram.dat[0xff40] = 0x08;
|
if(z) u->ram.dat[devkey->addr] = 0x08;
|
||||||
break;
|
break;
|
||||||
case SDLK_RETURN:
|
case SDLK_RETURN:
|
||||||
flag = 0x08;
|
flag = 0x08;
|
||||||
if(z) u->ram.dat[0xff40] = 0x0d;
|
if(z) u->ram.dat[devkey->addr] = 0x0d;
|
||||||
break;
|
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;
|
||||||
|
|
|
@ -9,47 +9,39 @@ file_extensions:
|
||||||
scope: source.usm
|
scope: source.usm
|
||||||
|
|
||||||
contexts:
|
contexts:
|
||||||
prototype:
|
|
||||||
- include: comments
|
|
||||||
|
|
||||||
main:
|
main:
|
||||||
- include: keywords
|
# pointer
|
||||||
- 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?'
|
|
||||||
scope: string.control
|
|
||||||
pop: true
|
|
||||||
- match: '\;(\S+)\s?'
|
|
||||||
scope: string.control
|
|
||||||
pop: true
|
|
||||||
- match: '\@(\S+)\s?'
|
- match: '\@(\S+)\s?'
|
||||||
scope: string.control
|
scope: string.control
|
||||||
pop: true
|
pop: true
|
||||||
|
# jump
|
||||||
|
- match: '\|(\S+)\s?'
|
||||||
|
scope: variable.control
|
||||||
|
pop: true
|
||||||
|
# variables
|
||||||
|
- match: '\;(\S+)\s?'
|
||||||
|
scope: string.control
|
||||||
|
pop: true
|
||||||
|
# constants
|
||||||
|
- match: '\:(\S+)\s?'
|
||||||
|
scope: string.control
|
||||||
|
pop: true
|
||||||
|
# structs
|
||||||
- match: '\&(\S+)\s?'
|
- match: '\&(\S+)\s?'
|
||||||
scope: string.control
|
scope: string.control
|
||||||
pop: true
|
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?'
|
- match: '\,(\S+)\s?'
|
||||||
scope: keyword.control
|
scope: keyword.control
|
||||||
pop: true
|
pop: true
|
||||||
|
@ -58,21 +50,31 @@ contexts:
|
||||||
pop: true
|
pop: true
|
||||||
- match: '\.(\S+)\s?'
|
- match: '\.(\S+)\s?'
|
||||||
scope: keyword.control
|
scope: keyword.control
|
||||||
|
- match: '\+(\S+)\s?'
|
||||||
|
scope: string.control
|
||||||
pop: true
|
pop: true
|
||||||
- match: '\"(\S+)\s?'
|
- match: '\-(\S+)\s?'
|
||||||
scope: keyword.control
|
scope: string.control
|
||||||
pop: true
|
|
||||||
- match: '\['
|
# Blocks
|
||||||
scope: punctuation.definition.keyword.usm
|
|
||||||
|
- match: '\{'
|
||||||
|
scope: variable.control
|
||||||
push:
|
push:
|
||||||
- meta_scope: keyword.line.double-slash.usm
|
- meta_scope: variable.control
|
||||||
- match: '\]'
|
- match: '\}'
|
||||||
pop: true
|
pop: true
|
||||||
|
|
||||||
comments:
|
|
||||||
- match: '\('
|
- match: '\('
|
||||||
scope: punctuation.definition.comment.usm
|
scope: comment
|
||||||
push:
|
push:
|
||||||
- meta_scope: comment.line.double-slash.usm
|
- meta_scope: comment.line
|
||||||
- match: '\)'
|
- match: '\)'
|
||||||
pop: true
|
pop: true
|
||||||
|
|
||||||
|
- match: '\['
|
||||||
|
scope: keyword
|
||||||
|
push:
|
||||||
|
- meta_scope: keyword.line
|
||||||
|
- match: '\]'
|
||||||
|
pop: true
|
||||||
|
|
|
@ -4,58 +4,70 @@
|
||||||
&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 }
|
||||||
|
|
||||||
&Point2d { x 2 y 2 }
|
;slime-color 1
|
||||||
|
|
||||||
;pos Point2d
|
|
||||||
;sprite 2
|
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
( set origin )
|
( set origin )
|
||||||
~dev/screen.width #0002 DIV2 =pos.x
|
~dev/screen.width #0002 DIV2 =dev/sprite.x
|
||||||
~dev/screen.height #0002 DIV2 =pos.y
|
~dev/screen.height #0002 DIV2 =dev/sprite.y
|
||||||
|
,default_icn =dev/sprite.addr
|
||||||
#12 ,up_icn ~pos.y ~pos.x ,draw-sprite JSR
|
#11 =dev/sprite.color
|
||||||
|
#0a =slime-color
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|c000 @FRAME
|
|c000 @FRAME
|
||||||
|
|
||||||
,default_icn =sprite
|
#0a =slime-color
|
||||||
|
( hold ctrl key to change slime color )
|
||||||
~dev/ctrl.buttons #10 NEQ ,next1 ROT JMP? POP2
|
,no-ctrl ~dev/ctrl.buttons #0f AND #01 NEQ JMP? POP2
|
||||||
,up_icn =sprite
|
#05 =slime-color
|
||||||
~pos.y #0001 SUB2 =pos.y
|
@no-ctrl
|
||||||
@next1
|
( hold alt key to change slime color )
|
||||||
~dev/ctrl.buttons #20 NEQ ,next2 ROT JMP? POP2
|
,no-alt ~dev/ctrl.buttons #0f AND #02 NEQ JMP? POP2
|
||||||
,down_icn =sprite
|
#0f =slime-color
|
||||||
~pos.y #0001 ADD2 =pos.y
|
@no-alt
|
||||||
@next2
|
( detect movement )
|
||||||
~dev/ctrl.buttons #40 NEQ ,next3 ROT JMP? POP2
|
,no-up ~dev/ctrl.buttons #f0 AND #10 NEQ JMP? POP2
|
||||||
,left_icn =sprite
|
( clear ) #10 =dev/sprite.color
|
||||||
~pos.x #0001 SUB2 =pos.x
|
( move ) ~dev/sprite.y #0001 SUB2 =dev/sprite.y ,up_icn =dev/sprite.addr
|
||||||
@next3
|
( draw ) ,redraw JSR BRK
|
||||||
~dev/ctrl.buttons #80 NEQ ,end ROT JMP? POP2
|
@no-up
|
||||||
,right_icn =sprite
|
,no-down ~dev/ctrl.buttons #f0 AND #20 NEQ JMP? POP2
|
||||||
~pos.x #0001 ADD2 =pos.x
|
( clear ) #10 =dev/sprite.color
|
||||||
@end
|
( move ) ~dev/sprite.y #0001 ADD2 =dev/sprite.y ,down_icn =dev/sprite.addr
|
||||||
( redraw )
|
( draw ) ,redraw JSR BRK
|
||||||
#13 ~sprite ~pos.y ~pos.x ,draw-sprite JSR
|
@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
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@redraw
|
||||||
|
|
||||||
|
( draw face )
|
||||||
|
#11 =dev/sprite.color
|
||||||
|
( draw slime )
|
||||||
|
,slime_icn =dev/sprite.addr
|
||||||
|
~slime-color =dev/sprite.color
|
||||||
|
|
||||||
|
RTS
|
||||||
|
|
||||||
@default_icn [ 3c7e ffdb ffe7 7e3c ]
|
@default_icn [ 3c7e ffdb ffe7 7e3c ]
|
||||||
@up_icn [ 2466 e7db ffff 7e3c ]
|
@up_icn [ 2466 e7db ffff 7e3c ]
|
||||||
@down_icn [ 3c7e ffff dbe7 6624 ]
|
@down_icn [ 3c7e ffff dbe7 6624 ]
|
||||||
@left_icn [ 3c7e ef1f 1fef 7e3c ]
|
@left_icn [ 3c7e ef1f 1fef 7e3c ]
|
||||||
@right_icn [ 3c7e f7f8 f8f7 7e3c ]
|
@right_icn [ 3c7e f7f8 f8f7 7e3c ]
|
||||||
|
@slime_icn [ 0000 183c 3c18 0000 ]
|
||||||
@draw-sprite
|
|
||||||
=dev/sprite.x
|
|
||||||
=dev/sprite.y
|
|
||||||
=dev/sprite.addr
|
|
||||||
=dev/sprite.color
|
|
||||||
RTS
|
|
||||||
|
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|
@ -63,5 +75,5 @@ BRK
|
||||||
|FF20 ;dev/sprite Sprite
|
|FF20 ;dev/sprite Sprite
|
||||||
|FF30 ;dev/ctrl Controller
|
|FF30 ;dev/ctrl Controller
|
||||||
|
|
||||||
|FFF0 [ 02ac 05bb 0b53 ] ( palette )
|
|FFF0 [ 0daf 02ff 035f ] ( palette )
|
||||||
|FFFA .RESET .FRAME .ERROR
|
|FFFA .RESET .FRAME .ERROR
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
:dev/w fff9 ( std write port )
|
:dev/w fff9 ( std write port )
|
||||||
|
|
||||||
&Point2d { x 2 y 2 }
|
&Point2d { x 2 y 2 }
|
||||||
|
|
||||||
;mouse Point2d
|
;mouse Point2d
|
||||||
;state 1 ;color 1 ;brush 2
|
;state 1 ;color 1 ;brush 2
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue