Implemented devctrl
This commit is contained in:
parent
b014a73bcd
commit
527d6508e2
|
@ -297,9 +297,10 @@ dotext(SDL_Event *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
doctrl(SDL_Event *event, int z)
|
doctrl(Uxn *u, SDL_Event *event, int z)
|
||||||
{
|
{
|
||||||
Uint8 flag = 0x00;
|
Uint8 flag = 0x00;
|
||||||
|
Uint16 addr = 0xff30; /* TODO: get dynamically */
|
||||||
if(z && event->key.keysym.sym == SDLK_h)
|
if(z && event->key.keysym.sym == SDLK_h)
|
||||||
GUIDES = !GUIDES;
|
GUIDES = !GUIDES;
|
||||||
if(SDL_GetModState() & KMOD_LCTRL || SDL_GetModState() & KMOD_RCTRL)
|
if(SDL_GetModState() & KMOD_LCTRL || SDL_GetModState() & KMOD_RCTRL)
|
||||||
|
@ -320,7 +321,7 @@ doctrl(SDL_Event *event, int z)
|
||||||
case SDLK_LEFT: flag = 0x40; break;
|
case SDLK_LEFT: flag = 0x40; break;
|
||||||
case SDLK_RIGHT: flag = 0x80; break;
|
case SDLK_RIGHT: flag = 0x80; break;
|
||||||
}
|
}
|
||||||
setflag(&devcontroller->mem[0], flag, z);
|
setflag(&u->ram.dat[addr], flag, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Devices
|
#pragma mark - Devices
|
||||||
|
@ -439,8 +440,8 @@ start(Uxn *u)
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
case SDL_MOUSEMOTION: domouse(u, &event); break;
|
case SDL_MOUSEMOTION: domouse(u, &event); break;
|
||||||
case SDL_TEXTINPUT: dotext(&event); break;
|
case SDL_TEXTINPUT: dotext(&event); break;
|
||||||
case SDL_KEYDOWN: doctrl(&event, 1); break;
|
case SDL_KEYDOWN: doctrl(u, &event, 1); break;
|
||||||
case SDL_KEYUP: doctrl(&event, 0); break;
|
case SDL_KEYUP: doctrl(u, &event, 0); break;
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
if(event.window.event == SDL_WINDOWEVENT_EXPOSED)
|
if(event.window.event == SDL_WINDOWEVENT_EXPOSED)
|
||||||
redraw(pixels, u);
|
redraw(pixels, u);
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
( blank )
|
( blank )
|
||||||
|
|
||||||
&Console { pad 8 stdio 1 }
|
&Console { pad 8 stdio 1 }
|
||||||
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
||||||
&Sprite { pad 8 y 2 x 2 addr 2 color 1 }
|
&Sprite { pad 8 y 2 x 2 addr 2 color 1 }
|
||||||
&Mouse { x 2 y 2 state 1 chord 1 }
|
&Controller { buttons 1 }
|
||||||
|
&Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|
|
||||||
|0100 @RESET BRK
|
|0100 @RESET BRK
|
||||||
|c000 @FRAME BRK
|
|c000 @FRAME BRK
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
|FF00 ;dev/console Console
|
|FF00 ;dev/console Console
|
||||||
|FF10 ;dev/screen Screen
|
|FF10 ;dev/screen Screen
|
||||||
|FF20 ;dev/sprite Sprite
|
|FF20 ;dev/sprite Sprite
|
||||||
|
|FF30 ;dev/ctrl Controller
|
||||||
|FF50 ;dev/mouse Mouse
|
|FF50 ;dev/mouse Mouse
|
||||||
|
|
||||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
( controller )
|
( controller )
|
||||||
|
|
||||||
:dev/r fff8 ( const read port )
|
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
||||||
:dev/w fff9 ( const write port )
|
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|
&Controller { buttons 1 }
|
||||||
|
|
||||||
&Point2d { x 2 y 2 }
|
&Point2d { x 2 y 2 }
|
||||||
|
|
||||||
|
@ -10,38 +11,36 @@
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
#03 =dev/r ( set dev/read to controller )
|
( set origin )
|
||||||
#02 =dev/w ( set dev/write to sprite )
|
~dev/screen.width #0002 DIV2 =pos.x
|
||||||
#0080 =pos.x #0040 =pos.y ( origin )
|
~dev/screen.height #0002 DIV2 =pos.y
|
||||||
|
|
||||||
#12 ,up_icn ~pos.x ~pos.y ,draw-sprite JSR
|
#12 ,up_icn ~pos.y ~pos.x ,draw-sprite JSR
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|c000 @FRAME
|
|c000 @FRAME
|
||||||
|
|
||||||
#03 =dev/r ( set dev/read to controller )
|
|
||||||
|
|
||||||
,default_icn =sprite
|
,default_icn =sprite
|
||||||
|
|
||||||
#00 IOR #10 NEQ ,next1 ROT JMP? POP2
|
~dev/ctrl.buttons #10 NEQ ,next1 ROT JMP? POP2
|
||||||
,up_icn =sprite
|
,up_icn =sprite
|
||||||
~pos.y #0001 SUB2 =pos.y
|
~pos.y #0001 SUB2 =pos.y
|
||||||
@next1
|
@next1
|
||||||
#00 IOR #20 NEQ ,next2 ROT JMP? POP2
|
~dev/ctrl.buttons #20 NEQ ,next2 ROT JMP? POP2
|
||||||
,down_icn =sprite
|
,down_icn =sprite
|
||||||
~pos.y #0001 ADD2 =pos.y
|
~pos.y #0001 ADD2 =pos.y
|
||||||
@next2
|
@next2
|
||||||
#00 IOR #40 NEQ ,next3 ROT JMP? POP2
|
~dev/ctrl.buttons #40 NEQ ,next3 ROT JMP? POP2
|
||||||
,left_icn =sprite
|
,left_icn =sprite
|
||||||
~pos.x #0001 SUB2 =pos.x
|
~pos.x #0001 SUB2 =pos.x
|
||||||
@next3
|
@next3
|
||||||
#00 IOR #80 NEQ ,end ROT JMP? POP2
|
~dev/ctrl.buttons #80 NEQ ,end ROT JMP? POP2
|
||||||
,right_icn =sprite
|
,right_icn =sprite
|
||||||
~pos.x #0001 ADD2 =pos.x
|
~pos.x #0001 ADD2 =pos.x
|
||||||
@end
|
@end
|
||||||
( redraw )
|
( redraw )
|
||||||
#13 ~sprite ~pos.x ~pos.y ,draw-sprite JSR
|
#13 ~sprite ~pos.y ~pos.x ,draw-sprite JSR
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@ -52,13 +51,17 @@ BRK
|
||||||
@right_icn [ 3c7e f7f8 f8f7 7e3c ]
|
@right_icn [ 3c7e f7f8 f8f7 7e3c ]
|
||||||
|
|
||||||
@draw-sprite
|
@draw-sprite
|
||||||
IOW2 ( y byte )
|
=dev/sprite.x
|
||||||
IOW2 ( x byte )
|
=dev/sprite.y
|
||||||
IOW2 ( sprite address )
|
=dev/sprite.addr
|
||||||
IOW ( layer-color )
|
=dev/sprite.color
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|
|FF10 ;dev/screen Screen
|
||||||
|
|FF20 ;dev/sprite Sprite
|
||||||
|
|FF30 ;dev/ctrl Controller
|
||||||
|
|
||||||
|FFF0 [ 02ac 05bb 0b53 ] ( palette )
|
|FFF0 [ 02ac 05bb 0b53 ] ( palette )
|
||||||
|FFFA .RESET .FRAME .ERROR
|
|FFFA .RESET .FRAME .ERROR
|
|
@ -1,7 +1,7 @@
|
||||||
( mouse )
|
( mouse )
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
||||||
&Sprite { pad 8 y 2 x 2 addr 2 color 1 }
|
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
&Mouse { x 2 y 2 state 1 chord 1 }
|
&Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|
|
||||||
&Point2d { x 2 y 2 }
|
&Point2d { x 2 y 2 }
|
||||||
|
@ -91,15 +91,15 @@ RTS
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@draw-sprite
|
@draw-sprite
|
||||||
=dev/sprite.x
|
|
||||||
=dev/sprite.y
|
=dev/sprite.y
|
||||||
|
=dev/sprite.x
|
||||||
=dev/sprite.addr
|
=dev/sprite.addr
|
||||||
=dev/sprite.color
|
=dev/sprite.color
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@draw-sprite-chr
|
@draw-sprite-chr
|
||||||
=dev/sprite.x
|
|
||||||
=dev/sprite.y
|
=dev/sprite.y
|
||||||
|
=dev/sprite.x
|
||||||
=dev/sprite.addr
|
=dev/sprite.addr
|
||||||
#20 =dev/sprite.color
|
#20 =dev/sprite.color
|
||||||
RTS
|
RTS
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
( blank )
|
|
||||||
|
|
||||||
:dev/r fff8 ( std read port )
|
|
||||||
:dev/w fff9 ( std write port )
|
|
||||||
|
|
||||||
&Console { stdout 1 }
|
|
||||||
|
|
||||||
|0100 @RESET
|
|
||||||
|
|
||||||
|
|
||||||
BRK
|
|
||||||
|
|
||||||
|c000 @FRAME BRK
|
|
||||||
|d000 @ERROR BRK
|
|
||||||
|
|
||||||
|FF00 ;dev/console Console
|
|
||||||
|FF08 ;device2 Device
|
|
||||||
|
|
||||||
|FFF0 [ f2ac 35bb 2b53 ] ( palette )
|
|
||||||
|FFFA .RESET .FRAME .ERROR
|
|
Loading…
Reference in New Issue