Browse code

Added mouse-down detect to example

neauoire authored on 10/02/2021 01:43:53
Showing 2 changed files
... ...
@@ -147,11 +147,14 @@ domouse(SDL_Event *event)
147 147
 {
148 148
 	int x = event->motion.x / ZOOM - PAD * 8;
149 149
 	int y = event->motion.y / ZOOM - PAD * 8;
150
+
151
+	devmouse->mem[0] = x;
152
+	devmouse->mem[1] = y;
150 153
 	switch(event->type) {
151 154
 	case SDL_MOUSEBUTTONUP:
155
+		devmouse->mem[2] = 0;
156
+		break;
152 157
 	case SDL_MOUSEBUTTONDOWN:
153
-		devmouse->mem[0] = x;
154
-		devmouse->mem[1] = y;
155 158
 		devmouse->mem[2] = event->button.button == SDL_BUTTON_LEFT;
156 159
 	}
157 160
 }
... ...
@@ -10,9 +10,20 @@
10 10
 BRK
11 11
 
12 12
 |c000 @FRAME 
13
-	,01 ,01 ( redraw color )
14
-	,00 ,01 ,02 IOR ( grab y )
15
-	,00 ,00 ,02 IOR ( grab x )
13
+	
14
+	( get mouse button, or break )
15
+	,02 ,02 IOR
16
+	,01 NEQ
17
+	BRK?
18
+
19
+	( print A to console on click )
20
+	,02 ,02 IOR
21
+	,41 ADD 
22
+	,putbyte JSR
23
+
24
+	( paint a white pixel )
25
+	,01 ,01 
26
+	,getmouse JSR
16 27
 	,putpixel JSR
17 28
 BRK 
18 29
 
... ...
@@ -23,5 +34,13 @@ BRK
23 34
 	,01 IOW ( redraw )
24 35
 	RTS
25 36
 
37
+@getmouse ( push y,x to stack )
38
+	,00 ,01 ,02 IOR ( grab y )
39
+	,00 ,00 ,02 IOR ( grab x )
40
+	RTS
41
+
42
+@putbyte ( print to console )
43
+	,00 IOW RTS 
44
+
26 45
 |d000 @ERROR BRK 
27 46
 |FFFA .RESET .FRAME .ERROR