progress on sprites
This commit is contained in:
+7
-1
@@ -132,6 +132,9 @@ export fn main() void = {
|
|||||||
// fmt::printfln("Setting window to width: {:x} height: {:x}", dims.width, dims.height)!;
|
// fmt::printfln("Setting window to width: {:x} height: {:x}", dims.width, dims.height)!;
|
||||||
if((dims.width != 0) && (dims.height !=0)){
|
if((dims.width != 0) && (dims.height !=0)){
|
||||||
sdl3::DestroyTexture(meadow_texture);
|
sdl3::DestroyTexture(meadow_texture);
|
||||||
|
free(pixeldata);
|
||||||
|
pixeldata = alloc([0...])!; //TODO figure out actual size
|
||||||
|
|
||||||
let w: int = dims.width: int;
|
let w: int = dims.width: int;
|
||||||
let h: int = dims.height: int;
|
let h: int = dims.height: int;
|
||||||
|
|
||||||
@@ -184,11 +187,14 @@ export fn main() void = {
|
|||||||
if((dims.width != w: u16) || (dims.height != h: u16)){
|
if((dims.width != w: u16) || (dims.height != h: u16)){
|
||||||
// fmt::println("Dimensions not allowed!")!;
|
// fmt::println("Dimensions not allowed!")!;
|
||||||
//TODO handle this maybe
|
//TODO handle this maybe
|
||||||
|
uxn::set_window_size(w: u16,h: u16,state);
|
||||||
sdl3::DestroyTexture(meadow_texture);
|
sdl3::DestroyTexture(meadow_texture);
|
||||||
|
free(pixeldata);
|
||||||
|
pixeldata = alloc([0...])!; //TODO figure out actual size
|
||||||
let old_w: int = dims.width: int;
|
let old_w: int = dims.width: int;
|
||||||
let old_h: int = dims.height: int;
|
let old_h: int = dims.height: int;
|
||||||
|
|
||||||
fmt::printfln("Setting window to width: {} height: {}", w, h)!;
|
fmt::printfln("User setting window to width: {} height: {}", w, h)!;
|
||||||
sdl3::SetWindowSize(win,w,h)!;
|
sdl3::SetWindowSize(win,w,h)!;
|
||||||
|
|
||||||
meadow_texture = sdl3::CreateTexture(render,
|
meadow_texture = sdl3::CreateTexture(render,
|
||||||
|
|||||||
+19
-5
@@ -64,6 +64,14 @@ export fn get_window_size(state: *uxn) struct{width: u16, height: u16} = {
|
|||||||
return result;
|
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 = {
|
fn emu_dei(port: u8, state: *uxn) u8 = {
|
||||||
let val = state.dev[port];
|
let val = state.dev[port];
|
||||||
// fmt::printfln("Read {:x} from port {:x}", val, 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){
|
for(let p .. pixels){
|
||||||
const color = p; //TODO handle right;
|
const color: u8 = if (bpp2){
|
||||||
fmt::printfln("Drawing 2bpp: {} Sprite Pixel to x: {} y: {} color: {}", bpp2, x+xoff, y+yoff, p)!;
|
yield p: u8; // implement real value based on colors value
|
||||||
if(layer1) { state.screen.1[x+xoff][y+yoff] = p; }
|
}else {
|
||||||
else {state.screen.0[x+xoff][y+yoff] = p; };
|
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;
|
xoff += 1;
|
||||||
if(xoff >= 8){
|
if(xoff >= 8){
|
||||||
xoff = 0;
|
xoff = 0;
|
||||||
@@ -272,7 +286,7 @@ export fn get_color(x: u16, y: u16, state: *uxn) u16 = {
|
|||||||
// check layer 1
|
// check layer 1
|
||||||
let color = state.screen.1[x][y] & 0b00000011;
|
let color = state.screen.1[x][y] & 0b00000011;
|
||||||
if(color == 0){
|
if(color == 0){
|
||||||
color = state.screen.0[x][y];
|
color = state.screen.0[x][y] & 0b00000011;
|
||||||
};
|
};
|
||||||
return state.palette[color];
|
return state.palette[color];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user