Browse code

Improving the drag example

neauoire authored on 17/02/2021 01:03:24
Showing 2 changed files
... ...
@@ -36,11 +36,11 @@ BRK
36 36
 		,update JSR
37 37
 	BRK
38 38
 	@on-drag
39
+
39 40
 		( clear last rect )
40 41
 		#00 =color
41 42
 		~x ~y ~w ~h ,fillrect JSR
42
-		( draw new rect )
43
-		#03 =color
43
+
44 44
 		#00 IOR2 ~touchx SUBS2 ~x ADDS2 =x
45 45
 		#02 IOR2 ~touchy SUBS2 ~y ADDS2 =y
46 46
 		#00 IOR2 =touchx #02 IOR2 =touchy
... ...
@@ -48,12 +48,26 @@ BRK
48 48
 	BRK
49 49
 
50 50
 	@update
51
-		~x ~y ~w ~h ,fillrect JSR
51
+
52
+		( draw new rect )
53
+		#03 =color
54
+		~x ~y ~w ~h ,linerect JSR
55
+
56
+		#0000 ,rounds_chr ~x #0010 ADD2 ~y #0010 ADD2 ,drawsprite JSR
57
+		#0100 ,eyeeye_chr ~x #0040 ADD2 ~y #0020 ADD2 ,drawsprite JSR
58
+
52 59
 		,redraw JSR
53 60
 	BRK
54 61
 
55 62
 BRK
56 63
 
64
+@putpixel 
65
+	IOW2 ( y short )
66
+	IOW2 ( x short )
67
+	,color LDR IOW  ( color byte )
68
+	#00 IOW  ( redraw byte )
69
+	RTS
70
+
57 71
 @fillrect
58 72
 	=h =w =y =x ( store values in variables )
59 73
 	~x =drawx ~y =drawy ( store draw pos in variables )
... ...
@@ -67,17 +81,44 @@ BRK
67 81
 		~drawy ~h ~y ADD2 LTH2 ,fillrectrow ROT JMP? POP2
68 82
 	RTS
69 83
 
84
+@linerect
85
+	,h STR2 ,w STR2 ,y STR2 ,x STR2
86
+	,x LDR2 ,drawx STR2 ,y LDR2 ,drawy STR2
87
+	@linerectcol
88
+		( draw ) ,x LDR2 ,drawy LDR2 ,putpixel JSR
89
+		( draw ) ,x LDR2 ,w LDR2 ADD2 ,drawy LDR2 ,putpixel JSR
90
+		,drawy LDR2 #0001 ADD2 ,drawy STR2 
91
+		,drawy LDR2 ,h LDR2 ,y LDR2 ADD2 LTH2 ,linerectcol ROT JMP? POP2
92
+	@linerectrow
93
+		( draw ) ,drawx LDR2 ,y LDR2 ,putpixel JSR
94
+		( draw ) ,drawx LDR2 ,y LDR2 ,h LDR2 ADD2 ,putpixel JSR
95
+		,drawx LDR2 #0001 ADD2 ,drawx STR2 
96
+		,drawx LDR2 ,w LDR2 ,x LDR2 ADD2 #0001 ADD2 LTH2 ,linerectrow ROT JMP? POP2
97
+	RTS
98
+
70 99
 @getmouse
71 100
 	#00 IOR2 ( get mouse x )
72 101
 	#02 IOR2 ( get mouse y )
73 102
 	RTS
74 103
 
104
+@drawsprite
105
+	#02 =dev/w                           ( set dev/write to sprite ) 
106
+	IOW2 ( y short )
107
+	IOW2 ( x short )
108
+	IOW2 ( sprite address )
109
+	IOW2 ( redraw byte )
110
+	RTS
111
+
75 112
 @redraw
113
+	#01 =dev/w                           ( set dev/write to sprite ) 
76 114
 	#0000 IOW2
77 115
 	#0000 IOW2
78 116
 	#00 IOW
79 117
 	#01 IOW
80 118
 	RTS
81 119
 
120
+@rounds_chr [ 3844 92aa 9244 3800 0038 7c7c 7c38 0000 ]
121
+@eyeeye_chr [ aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 ]
122
+
82 123
 |d000 @ERROR BRK 
83 124
 |FFFA .RESET .FRAME .ERROR
84 125
new file mode 100644
85 126
Binary files /dev/null and b/untitled.chr differ