From 27b5ab00035f8ccd9502b0b943514e85f3b38a53 Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 23 Feb 2021 16:27:20 -0800 Subject: [PATCH] Fixed blending mode --- emulator.c | 8 +++++--- examples/paint.usm | 21 ++++++++++----------- examples/struct.usm | 29 ----------------------------- examples/window.usm | 12 ++++++++---- 4 files changed, 23 insertions(+), 47 deletions(-) delete mode 100644 examples/struct.usm diff --git a/emulator.c b/emulator.c index 2f8f3a6..600549d 100644 --- a/emulator.c +++ b/emulator.c @@ -14,8 +14,8 @@ WITH REGARD TO THIS SOFTWARE. #include "uxn.h" -#define HOR 32 -#define VER 18 +#define HOR 64 / 2 +#define VER 48 / 2 #define PAD 2 #define RES (HOR * VER * 16) @@ -112,6 +112,8 @@ painticn(Uint8 *dst, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 blend) for(v = 0; v < 8; v++) for(h = 0; h < 8; h++) { Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1); + if(ch1 == 0 && (blend == 0x05 || blend == 0x0a || blend == 0x0f)) + continue; paintpixel(dst, x + h, y + v, ch1 ? blend % 4 : blend / 4); } } @@ -193,7 +195,7 @@ drawdebugger(Uint32 *dst, Uxn *u) Uint8 x = (i % 8) * 3 + 3, y = i / 8 + 3, b = u->ram.dat[i]; drawicn(dst, x * 8, y * 8, icons[(b >> 4) & 0xf], 1, 0); drawicn(dst, x * 8 + 8, y * 8, icons[b & 0xf], 1, 0); - y = i / 8 + 0x11, b = u->wst.dat[i]; + y = VER - i / 8, b = u->wst.dat[i]; drawicn(dst, x * 8, y * 8, icons[(b >> 4) & 0xf], 1 + (u->wst.ptr == i), 0); drawicn(dst, x * 8 + 8, y * 8, icons[b & 0xf], 1 + (u->wst.ptr == i), 0); } diff --git a/examples/paint.usm b/examples/paint.usm index a9b6c8e..0865018 100644 --- a/examples/paint.usm +++ b/examples/paint.usm @@ -3,7 +3,8 @@ :dev/r fff8 ( std read port ) :dev/w fff9 ( std write port ) -;mousex 2 ;mousey 2 ;lastx 2 ;lasty 2 +&Point2d { x 2 y 2 } +;mouse Point2d ;state 1 ;color 1 ;brush 2 |0100 @RESET @@ -21,11 +22,11 @@ BRK |c000 @FRAME ( clear last cursor ) - #10 ,clear_icn ~lastx ~lasty ,draw-sprite JSR + #10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR ( record mouse values ) - #00 IOR2 =mousex #02 IOR2 =mousey + #00 IOR2 =mouse.x #02 IOR2 =mouse.y #04 IOR #11 ADD =state - ~state ,cursor_icn ~mousex ~mousey ,draw-sprite JSR + ~state ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR ( check click ) #04 IOR #00 EQU ,end-touch ROT JMP? POP2 @@ -47,20 +48,18 @@ BRK #05 =color BRK @option4 #02 IOR2 #0008 DIV2 #000c NEQ2 ,option5 ROT JMP? POP2 - #06 =color BRK + #0a =color BRK @option5 #02 IOR2 #0008 DIV2 #000d NEQ2 ,option6 ROT JMP? POP2 - #07 =color BRK + #0f =color BRK @option6 BRK @end-interface - ~color ~brush ~mousex #0004 SUB2 ~mousey #0004 SUB2 ,draw-sprite JSR + ~color ~brush ~mouse.x #0004 SUB2 ~mouse.y #0004 SUB2 ,draw-sprite JSR @end-touch - ~mousex =lastx ~mousey =lasty ( update last post ) - BRK @draw-interface @@ -68,8 +67,8 @@ BRK #05 ,brush_small #0008 #0028 ,draw-sprite JSR #05 ,brush_tiny #0008 #0030 ,draw-sprite JSR #05 ,brush_large #0008 #0058 ,draw-sprite JSR - #06 ,brush_large #0008 #0060 ,draw-sprite JSR - #07 ,brush_large #0008 #0068 ,draw-sprite JSR + #0a ,brush_large #0008 #0060 ,draw-sprite JSR + #0f ,brush_large #0008 #0068 ,draw-sprite JSR RTS @draw-sprite diff --git a/examples/struct.usm b/examples/struct.usm deleted file mode 100644 index f0dfa63..0000000 --- a/examples/struct.usm +++ /dev/null @@ -1,29 +0,0 @@ -( blank ) - -:dev/r fff8 ( std read port ) -:dev/w fff9 ( std write port ) - -&Rect2d { x 2 y 2 width 2 height 2 } -&ColorRGB { r 1 g 1 b 1 } - -;rc1 Rect2d -;red ColorRGB - -|0100 @RESET - - ( byte mode ) - #ff =red.r - ~red.r - - ( short mode ) - #1234 =rc1.x - #abcd =rc1.height - ~rc1.height - -BRK - -|c000 @FRAME BRK -|d000 @ERROR BRK - -|FFF0 [ 0f32 0f32 0f32 ] ( palette ) -|FFFA .RESET .FRAME .ERROR diff --git a/examples/window.usm b/examples/window.usm index e7f2534..174ecc5 100644 --- a/examples/window.usm +++ b/examples/window.usm @@ -3,9 +3,13 @@ :dev/r fff8 ( std read port ) :dev/w fff9 ( std write port ) +&Point2d { x 2 y 2 } + +;mouse Point2d + ( window ) ;wx1 2 ;wy1 2 ;wx2 2 ;wy2 2 ( drawing ) ;color 1 ;x1 2 ;x2 2 ;y1 2 ;y2 2 -( mouse ) ;mousex 2 ;mousey 2 ;state 1 +( mouse ) ;state 1 |0100 @RESET @@ -22,9 +26,9 @@ BRK |c000 @FRAME ( clear last cursor ) - #10 ,clear_icn ~mousex ~mousey ,draw-sprite JSR + #10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR ( record mouse positions ) - #00 IOR2 =mousex #02 IOR2 =mousey + #00 IOR2 =mouse.x #02 IOR2 =mouse.y ( record mouse state ) #04 IOR #11 ADD =state @@ -33,7 +37,7 @@ BRK @no-touch ( draw mouse ) - ~state ,cursor_icn ~mousex ~mousey ,draw-sprite JSR + ~state ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR BRK