Clean up screen.ha
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
fn draw_pixel(value: u8, state: *uxn) void = {
|
fn draw_pixel(value: u8, state: *uxn) void = {
|
||||||
//TODO handle fill
|
|
||||||
const color = value & 0b00000011;
|
const color = value & 0b00000011;
|
||||||
const x = short_from_bytes(state.dev[0x28],state.dev[0x29]);
|
const x = short_from_bytes(state.dev[0x28],state.dev[0x29]);
|
||||||
const y = short_from_bytes(state.dev[0x2a],state.dev[0x2b]);
|
const y = short_from_bytes(state.dev[0x2a],state.dev[0x2b]);
|
||||||
@@ -11,7 +10,6 @@ fn draw_pixel(value: u8, state: *uxn) void = {
|
|||||||
|
|
||||||
|
|
||||||
if(!fill){
|
if(!fill){
|
||||||
// fmt::printfln("Pixel at x: {:x} y: {:x} color: {:x}", x, y, color)!;
|
|
||||||
const auto = state.dev[0x26];
|
const auto = state.dev[0x26];
|
||||||
let count = ((auto & 0xf0) >> 4): i8;
|
let count = ((auto & 0xf0) >> 4): i8;
|
||||||
const auto_x = (auto & 0b00000001) != 0;
|
const auto_x = (auto & 0b00000001) != 0;
|
||||||
@@ -24,7 +22,6 @@ fn draw_pixel(value: u8, state: *uxn) void = {
|
|||||||
}else{
|
}else{
|
||||||
yield x + 1;
|
yield x + 1;
|
||||||
};
|
};
|
||||||
// const new_x = x + 1;
|
|
||||||
state.dev[0x28] = (new_x >> 8): u8;
|
state.dev[0x28] = (new_x >> 8): u8;
|
||||||
state.dev[0x29] = (new_x): u8;
|
state.dev[0x29] = (new_x): u8;
|
||||||
|
|
||||||
@@ -35,24 +32,19 @@ fn draw_pixel(value: u8, state: *uxn) void = {
|
|||||||
}else{
|
}else{
|
||||||
yield y + 1;
|
yield y + 1;
|
||||||
};
|
};
|
||||||
// const new_y = y + 1;
|
|
||||||
state.dev[0x2a] = (new_y >> 8): u8;
|
state.dev[0x2a] = (new_y >> 8): u8;
|
||||||
state.dev[0x2b] = (new_y): u8;
|
state.dev[0x2b] = (new_y): u8;
|
||||||
|
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
//TODO see if auto still happens with fill
|
|
||||||
// fmt::println("Doing Fill")!;
|
|
||||||
const dims = get_window_size(state);
|
const dims = get_window_size(state);
|
||||||
const startx: u16 = if(flipx) {yield 0; }else{ yield x; };
|
const startx: u16 = if(flipx) {yield 0; }else{ yield x; };
|
||||||
const starty: u16 = if(flipy) {yield 0; }else{ yield y; };
|
const starty: u16 = if(flipy) {yield 0; }else{ yield y; };
|
||||||
const endx: u16 = if(flipx) {yield x; }else{ yield dims.width; };
|
const endx: u16 = if(flipx) {yield x; }else{ yield dims.width; };
|
||||||
const endy: u16 = if(flipy) {yield y; }else{ yield dims.height; };
|
const endy: u16 = if(flipy) {yield y; }else{ yield dims.height; };
|
||||||
|
|
||||||
// fmt::printfln("Fill startx: {:x} endx: {:x} starty: {:x} endy: {:x}", startx, endx, starty, endy)!;
|
|
||||||
for(let xl = startx; xl < endx; xl+=1){
|
for(let xl = startx; xl < endx; xl+=1){
|
||||||
for(let yl = starty; yl < endy; yl+=1){
|
for(let yl = starty; yl < endy; yl+=1){
|
||||||
// fmt::printfln("Filling at x: {:x} y: {:x} color: {:x}", xl, yl, color)!;
|
|
||||||
set_pixel(layer1,xl,yl,color,state);
|
set_pixel(layer1,xl,yl,color,state);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -84,14 +76,12 @@ fn regenerate_palettes(state: *uxn) void = {
|
|||||||
state.palette[1] = ((r & 0x0f00) >> 0) | ((g & 0x0f00) >> 4) | ((b & 0x0f00) >> 8);
|
state.palette[1] = ((r & 0x0f00) >> 0) | ((g & 0x0f00) >> 4) | ((b & 0x0f00) >> 8);
|
||||||
state.palette[2] = ((r & 0x00f0) << 4) | ((g & 0x00f0) >> 0) | ((b & 0x00f0) >> 4);
|
state.palette[2] = ((r & 0x00f0) << 4) | ((g & 0x00f0) >> 0) | ((b & 0x00f0) >> 4);
|
||||||
state.palette[3] = ((r & 0x000f) << 8) | ((g & 0x000f) << 4) | ((b & 0x000f) >> 0);
|
state.palette[3] = ((r & 0x000f) << 8) | ((g & 0x000f) << 4) | ((b & 0x000f) >> 0);
|
||||||
// fmt::printfln("Palette Color0: {:x} Color1: {:x} Color2: {:x} Color3: {:x}", state.palette[0], state.palette[1],state.palette[2],state.palette[3])!;
|
|
||||||
state.screen_update = true;
|
state.screen_update = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn draw_sprite(value: u8, state: *uxn) void = {
|
fn draw_sprite(value: u8, state: *uxn) void = {
|
||||||
//TODO handle fill
|
|
||||||
const colors = value & 0b00001111;
|
const colors = value & 0b00001111;
|
||||||
const auto = state.dev[0x26];
|
const auto = state.dev[0x26];
|
||||||
let count = ((auto & 0xf0) >> 4): u8;
|
let count = ((auto & 0xf0) >> 4): u8;
|
||||||
@@ -107,7 +97,6 @@ fn draw_sprite(value: u8, state: *uxn) void = {
|
|||||||
const y = short_from_bytes(state.dev[0x2a],state.dev[0x2b]);
|
const y = short_from_bytes(state.dev[0x2a],state.dev[0x2b]);
|
||||||
if(count == 0){
|
if(count == 0){
|
||||||
const addr = short_from_bytes(state.dev[0x2c],state.dev[0x2d]);
|
const addr = short_from_bytes(state.dev[0x2c],state.dev[0x2d]);
|
||||||
// const x = if(flipx) { yield x - i * 8; } else { yield x + i * 8; };
|
|
||||||
copy_sprite_to_screen(bpp2,colors,x,y,addr,flipx,flipy,layer1,state);
|
copy_sprite_to_screen(bpp2,colors,x,y,addr,flipx,flipy,layer1,state);
|
||||||
if(auto_a){
|
if(auto_a){
|
||||||
const new_addr = if(bpp2) { yield addr + 16; } else { yield addr + 8; };
|
const new_addr = if(bpp2) { yield addr + 16; } else { yield addr + 8; };
|
||||||
@@ -128,7 +117,6 @@ fn draw_sprite(value: u8, state: *uxn) void = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
}else {
|
}else {
|
||||||
// fmt::printfln("Multi-Sprite! Auto-x: {} Auto-y: {} Flip-x: {} Flip-y: {}",auto_x,auto_y,flipx,flipy)!;
|
|
||||||
for(let i: u16 = 0; i <= count; i+=1){
|
for(let i: u16 = 0; i <= count; i+=1){
|
||||||
const addr = short_from_bytes(state.dev[0x2c],state.dev[0x2d]);
|
const addr = short_from_bytes(state.dev[0x2c],state.dev[0x2d]);
|
||||||
let x = x;
|
let x = x;
|
||||||
|
|||||||
Reference in New Issue
Block a user