Added mouse-down detect to example
This commit is contained in:
parent
347b1055f6
commit
a1267aea4e
|
@ -147,11 +147,14 @@ domouse(SDL_Event *event)
|
|||
{
|
||||
int x = event->motion.x / ZOOM - PAD * 8;
|
||||
int y = event->motion.y / ZOOM - PAD * 8;
|
||||
|
||||
devmouse->mem[0] = x;
|
||||
devmouse->mem[1] = y;
|
||||
switch(event->type) {
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
devmouse->mem[2] = 0;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
devmouse->mem[0] = x;
|
||||
devmouse->mem[1] = y;
|
||||
devmouse->mem[2] = event->button.button == SDL_BUTTON_LEFT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,20 @@
|
|||
BRK
|
||||
|
||||
|c000 @FRAME
|
||||
,01 ,01 ( redraw color )
|
||||
,00 ,01 ,02 IOR ( grab y )
|
||||
,00 ,00 ,02 IOR ( grab x )
|
||||
|
||||
( get mouse button, or break )
|
||||
,02 ,02 IOR
|
||||
,01 NEQ
|
||||
BRK?
|
||||
|
||||
( print A to console on click )
|
||||
,02 ,02 IOR
|
||||
,41 ADD
|
||||
,putbyte JSR
|
||||
|
||||
( paint a white pixel )
|
||||
,01 ,01
|
||||
,getmouse JSR
|
||||
,putpixel JSR
|
||||
BRK
|
||||
|
||||
|
@ -23,5 +34,13 @@ BRK
|
|||
,01 IOW ( redraw )
|
||||
RTS
|
||||
|
||||
@getmouse ( push y,x to stack )
|
||||
,00 ,01 ,02 IOR ( grab y )
|
||||
,00 ,00 ,02 IOR ( grab x )
|
||||
RTS
|
||||
|
||||
@putbyte ( print to console )
|
||||
,00 IOW RTS
|
||||
|
||||
|d000 @ERROR BRK
|
||||
|FFFA .RESET .FRAME .ERROR
|
||||
|
|
Loading…
Reference in New Issue