Fixed issue drawing sprites

This commit is contained in:
neauoire 2023-11-12 12:34:02 -08:00
parent 9e5dbc043d
commit 8fb1c78180
2 changed files with 50 additions and 4 deletions

View File

@ -9,6 +9,7 @@
#286c .System/g DEO2
#2358 .System/b DEO2
;on-mouse .Mouse/vector DEO2
<draw-guide>
BRK
@on-mouse ( -> )
@ -16,6 +17,7 @@
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
#80 .Screen/pixel DEO
<draw-guide>
( | cursor )
#41 ;cursor-icn <update-cursor>
( | draw portrait )
@ -47,6 +49,44 @@
#05 .Screen/sprite DEOk DEOk DEOk DEO
JMP2r
@<draw-circle> ( color -- )
#01 .Screen/auto DEO
;circle-chr .Screen/addr DEO2
DUP .Screen/sprite DEO
DUP #10 ORA .Screen/sprite DEO
.Screen/y DEI2k #0008 ADD2 ROT DEO2
DUP #20 ORA .Screen/sprite DEO
#30 ORA .Screen/sprite DEO
JMP2r
@<draw-guide> ( -- )
#0000 DUP2 .Screen/x DEO2 .Screen/y DEO2
#f2 .Screen/auto DEO
;guide-icn .Screen/addr DEO2
#1000
&l ( -- )
#01 .Screen/sprite DEO
INC GTHk ?&l
POP2
( | circles )
#0010 DUP2 .Screen/x DEO2 .Screen/y DEO2
#02 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#82 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#05 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#85 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#03 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#83 <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#0a <draw-circle>
.Screen/y DEI2k #0008 ADD2 ROT DEO2
#8a <draw-circle>
JMP2r
@<update-cursor> ( color addr* -- )
[ LIT2 00 -Screen/auto ] DEO
;fill-icn .Screen/addr DEO2
@ -61,6 +101,8 @@
.Screen/sprite DEO
JMP2r
@guide-icn [ 0101 0101 0101 01ff ]
@fill-icn [ ffff ffff ffff ffff ]
@cursor-icn [ 80c0 e0f0 f8e0 1000 ]
@ -93,3 +135,7 @@
4142 4448 5020 1f00 0000 0000 0000 ff00
0000 0000 0000 ff00 8242 2212 0a04 f800 ]
@circle-chr [
071f 3c70 60e3 c7c7 0000 030f 1f1f 3f3f ]

View File

@ -60,8 +60,8 @@ screen_2bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16
{
int width = uxn_screen.width, height = uxn_screen.height, opaque = (color % 5);
Uint8 *ch1 = &ram[addr], *ch2 = ch1 + 8;
Uint16 y, ymod = (fy < 0 ? 8 : 0), ymax = y1 + ymod + fy * 8;
Uint16 x, xmod = (fx > 0 ? 8 : 0), xmax = x1 + xmod - fx * 8;
Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
for(y = y1 + ymod; y != ymax; y += fy) {
Uint16 c = *ch1++ | (*ch2++ << 8);
for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {
@ -77,8 +77,8 @@ screen_1bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16
{
int width = uxn_screen.width, height = uxn_screen.height, opaque = (color % 5);
Uint8 *ch1 = &ram[addr];
Uint16 y, ymod = (fy < 0 ? 8 : 0), ymax = y1 + ymod + fy * 8;
Uint16 x, xmod = (fx > 0 ? 8 : 0), xmax = x1 + xmod - fx * 8;
Uint16 y, ymod = (fy < 0 ? 7 : 0), ymax = y1 + ymod + fy * 8;
Uint16 x, xmod = (fx > 0 ? 7 : 0), xmax = x1 + xmod - fx * 8;
for(y = y1 + ymod; y != ymax; y += fy) {
Uint16 c = *ch1++;
for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {