commit 97ab50b
Devine Lu Linvega
·
2024-11-19 22:44:12 +0000 UTC
parent dd8348d
Improving 1bpp drawing function
2 files changed,
+18,
-15
+8,
-5
1@@ -22,14 +22,17 @@
2 #80 .Screen/pixel DEO )
3 ( <draw-guide> )
4 ( | cursor )
5- #0a18 DEOk DEOk DEOk DEO
6- .Mouse/x DEI2 #0004 SUB2 .Screen/x DEO2
7- .Mouse/y DEI2 #0004 SUB2 .Screen/y DEO2
8+ ( #0a18 DEOk DEOk DEOk DEO )
9+ .Mouse/x DEI2 .Screen/x DEO2
10+ .Mouse/y DEI2 .Screen/y DEO2
11 ;cursor-icn .Screen/addr DEO2
12 #41 .Screen/sprite DEO
13
14- .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
15- .Mouse/y DEI2 #0014 SUB2 .Screen/y DEO2
16+ .Mouse/x DEI2 #0018 SUB2 .Screen/x DEO2
17+ #61 .Screen/sprite DEO
18+
19+
20+ .Mouse/x DEI2 #0010 ADD2 .Screen/x DEO2
21 #61 .Screen/sprite DEO
22
23
+10,
-10
1@@ -46,26 +46,26 @@ static void
2 screen_1bpp(Uint8 *layer, Uint8 *addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy)
3 {
4 int xi, y;
5- Uint16 top = y1, bottom = y1 + 8, offset2 = 0;
6- int row, w = uxn_screen.width, h = uxn_screen.height, opaque = (color % 5);
7- Uint16 ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
8+ Uint16 top = y1, bottom = y1 + 8, left = x1, right = x1 + 8, offset2 = 0;
9+ int row, w = uxn_screen.width, opaque = (color % 5);
10 Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
11- /* find bounds */
12+ /* find vertical bounds */
13 if(top > 0x8000){
14 top = 0;
15- if(bottom > 0x8000)
16- bottom = 0;
17+ if(bottom > 0x8000) bottom = 0;
18 offset2 = 0 - y1;
19 }
20- printf("(%d)%d,%d -> mod:%d,%d -> max:%d,%d[%d,%d]\n",
21- fy, x1,y1,xmod,ymod, xmax, ymax, top, bottom);
22+ else if(bottom > uxn_screen.height){
23+ bottom = uxn_screen.height;
24+ if(top > uxn_screen.height) top = uxn_screen.height;
25+ }
26
27 for(y = top; y < bottom; y++) {
28 int yi = y-top;
29 int offset = fy < 0 ? 7 - yi : yi;
30 int byte = addr[offset+(offset2*fy)];
31- printf("- %d[%d=%d.. %d]\n", y, yi, y-top, offset2);
32- for(x = x1 + xmod, row = (y) * w, xi = 0; x != xmax; x -= fx, xi++) {
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];