progress on sprites

This commit is contained in:
JJ Bliss
2026-04-25 22:07:55 -04:00
parent c94e19c434
commit caf345df15
2 changed files with 26 additions and 6 deletions
+19 -5
View File
@@ -64,6 +64,14 @@ export fn get_window_size(state: *uxn) struct{width: u16, height: u16} = {
return result;
};
export fn set_window_size(w: u16, h: u16, state: *uxn) void = {
state.dev[0x22] = (w >> 8): u8;
state.dev[0x23] = (w): u8;
state.dev[0x24] = (h >> 8): u8;
state.dev[0x25] = (h): u8;
};
fn emu_dei(port: u8, state: *uxn) u8 = {
let val = state.dev[port];
// fmt::printfln("Read {:x} from port {:x}", val, port)!;
@@ -252,10 +260,16 @@ fn copy_sprite_to_screen(bpp2: bool, colors: u8, x: u16, y: u16, addr: u16, flip
};
for(let p .. pixels){
const color = p; //TODO handle right;
fmt::printfln("Drawing 2bpp: {} Sprite Pixel to x: {} y: {} color: {}", bpp2, x+xoff, y+yoff, p)!;
if(layer1) { state.screen.1[x+xoff][y+yoff] = p; }
else {state.screen.0[x+xoff][y+yoff] = p; };
const color: u8 = if (bpp2){
yield p: u8; // implement real value based on colors value
}else {
if( p == 0 ) yield 0: u8;
yield colors: u8;
} & 0b00000011;
// fmt::printfln("Drawing 2bpp: {} Sprite Pixel to x: {} y: {} color: {}", bpp2, x+xoff, y+yoff, p)!;
if(layer1) { state.screen.1[x+xoff][y+yoff] = color; }
else {state.screen.0[x+xoff][y+yoff] = color; };
xoff += 1;
if(xoff >= 8){
xoff = 0;
@@ -272,7 +286,7 @@ export fn get_color(x: u16, y: u16, state: *uxn) u16 = {
// check layer 1
let color = state.screen.1[x][y] & 0b00000011;
if(color == 0){
color = state.screen.0[x][y];
color = state.screen.0[x][y] & 0b00000011;
};
return state.palette[color];
};