commit dd8348d

Devine Lu Linvega  ·  2024-11-19 20:46:00 +0000 UTC
parent 580a89c
(screen.c) Improving 1bbp sprite
3 files changed,  +43, -16
+17, -7
 1@@ -9,10 +9,10 @@
 2 	#286c .System/g DEO2
 3 	#2358 .System/b DEO2
 4 	;on-mouse .Mouse/vector DEO2
 5-	<draw-guide>
 6+	( <draw-guide> )
 7 	.Screen/width DEI2 #01 SFT2 .Screen/x DEO2
 8 	.Screen/height DEI2 #01 SFT2 .Screen/y DEO2
 9-	<redraw>
10+	( <redraw> )
11 	BRK
12 
13 @on-mouse ( -> )
14@@ -20,10 +20,20 @@
15 	( #0000 DUP2 .Screen/x DEO2
16 	.Screen/y DEO2
17 	#80 .Screen/pixel DEO )
18-	<draw-guide>
19+	( <draw-guide> )
20 	( | cursor )
21-	#41 ;cursor-icn <update-cursor>
22-	<redraw>
23+	#0a18 DEOk DEOk DEOk DEO
24+	.Mouse/x DEI2 #0004 SUB2 .Screen/x DEO2
25+	.Mouse/y DEI2 #0004 SUB2 .Screen/y DEO2
26+	;cursor-icn .Screen/addr DEO2
27+	#41 .Screen/sprite DEO
28+
29+	.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
30+	.Mouse/y DEI2 #0014 SUB2 .Screen/y DEO2
31+	#61 .Screen/sprite DEO
32+	
33+	
34+	( <redraw> )
35 	BRK
36 
37 @<redraw> ( -- )
38@@ -91,8 +101,8 @@
39 	.Screen/addr DEO2
40 
41 @<draw-cursor> ( color -- )
42-	[ LIT2 &x $2 ] .Screen/x DEO2
43-	[ LIT2 &y $2 ] .Screen/y DEO2
44+	[ LIT2 &x $2 ] #0004 SUB2 .Screen/x DEO2
45+	[ LIT2 &y $2 ] #0004 SUB2 .Screen/y DEO2
46 	.Screen/sprite DEO
47 	JMP2r
48 
+3, -0
 1@@ -15,6 +15,9 @@ run: all bin/mouse.rom
 2 	@ bin/uxn11 bin/mouse.rom
 3 debug: bin/uxnasm-debug bin/uxncli-debug bin/uxn11-debug bin/opctest.rom
 4 	@ bin/uxncli-debug bin/opctest.rom
 5+screen: bin/uxn11 
 6+	@ uxnasm etc/screen.bounds.tal bin/test.rom
 7+	@ bin/uxn11 bin/test.rom
 8 test: all bin/opctest.rom
 9 	bin/uxncli
10 	bin/uxncli -v
+23, -9
 1@@ -45,17 +45,31 @@ screen_2bpp(Uint8 *layer, Uint8 *addr, Uint16 x1, Uint16 y1, Uint16 color, int f
 2 static void
 3 screen_1bpp(Uint8 *layer, Uint8 *addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy)
 4 {
 5+	int xi, y;
 6+	Uint16 top = y1, bottom = y1 + 8, offset2 = 0;
 7 	int row, w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
 8-	Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
 9+	Uint16 ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
10 	Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
11-	for(y = y1 + ymod; y != ymax; y += fy) {
12-		int c = *addr++;
13-		if(y < h)
14-			for(x = x1 + xmod, row = y * w; x != xmax; x -= fx, c >>= 1) {
15-				Uint8 ch = c & 1;
16-				if((opaque || ch) && x < w)
17-					layer[x + row] = blending[ch][color];
18-			}
19+	/* find bounds */
20+	if(top > 0x8000){
21+		top = 0;
22+		if(bottom > 0x8000)
23+			bottom = 0;
24+		offset2 = 0 - y1;
25+	}
26+	printf("(%d)%d,%d -> mod:%d,%d -> max:%d,%d[%d,%d]\n",
27+		fy, x1,y1,xmod,ymod, xmax, ymax, top, bottom);
28+
29+	for(y = top; y < bottom; y++) {
30+		int yi = y-top;
31+		int offset = fy < 0 ? 7 - yi : yi;
32+		int byte = addr[offset+(offset2*fy)];
33+		printf("- %d[%d=%d.. %d]\n", y, yi, y-top, offset2);
34+		for(x = x1 + xmod, row = (y) * w, xi = 0; x != xmax; x -= fx, xi++) {
35+			Uint8 ch = (byte >> xi) & 1;
36+			if((opaque || ch) && x < w)
37+				layer[x + row] = blending[ch][color];
38+		}
39 	}
40 }
41