diff --git a/projects/examples/blank.tal b/projects/examples/blank.tal index 050eefe..82d7b27 100644 --- a/projects/examples/blank.tal +++ b/projects/examples/blank.tal @@ -29,7 +29,7 @@ |40 @Audio1 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 |50 @Audio2 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 |60 @Audio3 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 -|80 @Controller &vector $2 &button $1 &key $1 +|80 @Controller &vector $2 &button $1 &key $1 &func $1 |90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 |a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 |b0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 diff --git a/projects/software/supervisor.tal b/projects/software/supervisor.tal index 3fa5910..45972f6 100644 --- a/projects/software/supervisor.tal +++ b/projects/software/supervisor.tal @@ -29,6 +29,7 @@ |00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 +|80 @Controller &vector $2 &button $1 &key $1 &func $1 ( variables ) @@ -53,6 +54,7 @@ ( vectors ) ;on-error .System/vector DEO2 ;on-frame .Screen/vector DEO2 + ;on-button .Controller/vector DEO2 BRK @@ -63,6 +65,12 @@ BRK BRK +@on-button ( -> ) + + .Controller/func DEI DEBUG + +BRK + @on-error ( -> ) ( background ) diff --git a/src/devices/controller.c b/src/devices/controller.c index a330f47..cfc19e7 100644 --- a/src/devices/controller.c +++ b/src/devices/controller.c @@ -39,4 +39,14 @@ controller_key(Device *d, Uint8 key) uxn_eval(d->u, d->vector); d->dat[3] = 0x00; } +} + +void +controller_special(Device *d, Uint8 key) +{ + if(key) { + d->dat[4] = key; + uxn_eval(d->u, d->vector); + d->dat[4] = 0x00; + } } \ No newline at end of file diff --git a/src/devices/controller.h b/src/devices/controller.h index 3dec305..d1e96a7 100644 --- a/src/devices/controller.h +++ b/src/devices/controller.h @@ -12,4 +12,5 @@ WITH REGARD TO THIS SOFTWARE. void controller_down(Device *d, Uint8 mask); void controller_up(Device *d, Uint8 mask); -void controller_key(Device *d, Uint8 key); \ No newline at end of file +void controller_key(Device *d, Uint8 key); +void controller_special(Device *d, Uint8 key); \ No newline at end of file diff --git a/src/uxnemu.c b/src/uxnemu.c index 143828f..45fe066 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -272,8 +272,8 @@ start(Uxn *u, char *rom) /* audio2 */ uxn_port(u, 0x5, 0xffff, audio_dei, audio_deo); /* audio3 */ uxn_port(u, 0x6, 0xffff, audio_dei, audio_deo); /* unused */ uxn_port(u, 0x7, 0xffff, nil_dei, nil_deo); - /* control */ devctrl = uxn_port(u, 0x8, 0xffff, nil_dei, nil_deo); - /* mouse */ devmouse = uxn_port(u, 0x9, 0xffff, nil_dei, nil_deo); + /* control */ devctrl = uxn_port(u, 0x8, 0x0000, nil_dei, nil_deo); + /* mouse */ devmouse = uxn_port(u, 0x9, 0x0000, nil_dei, nil_deo); /* file */ uxn_port(u, 0xa, 0xffff, nil_dei, file_deo); /* datetime */ uxn_port(u, 0xb, 0xffff, datetime_dei, nil_deo); /* unused */ uxn_port(u, 0xc, 0xffff, nil_dei, nil_deo); @@ -285,6 +285,7 @@ start(Uxn *u, char *rom) uxn_port(&supervisor, 0x0, 0xffff, system_dei, system_deo); uxn_port(&supervisor, 0x1, 0xffff, nil_dei, console_deo); uxn_port(&supervisor, 0x2, 0xffff, screen_dei, screen_deo); + uxn_port(&supervisor, 0x8, 0x0000, nil_dei, nil_deo); uxn_eval(&supervisor, PAGE_PROGRAM); @@ -348,6 +349,22 @@ get_button(SDL_Event *event) return 0x00; } +static Uint8 +get_fkey(SDL_Event *event) +{ + switch(event->key.keysym.sym) { + case SDLK_F1: return 0x01; + case SDLK_F2: return 0x02; + case SDLK_F3: return 0x04; + case SDLK_F4: return 0x08; + case SDLK_F5: return 0x10; + case SDLK_F6: return 0x20; + case SDLK_F7: return 0x40; + case SDLK_F8: return 0x80; + } + return 0x00; +} + static Uint8 get_button_joystick(SDL_Event *event) { @@ -442,6 +459,8 @@ run(Uxn *u) controller_key(devctrl, get_key(&event)); else if(get_button(&event)) controller_down(devctrl, get_button(&event)); + else if(get_fkey(&event)) + controller_special(&supervisor.dev[0x8], get_fkey(&event)); else do_shortcut(u, &event); ksym = event.key.keysym.sym;