mirror of
https://github.com/kirjavascript/trueLMAO.git
synced 2024-06-02 19:47:21 -04:00
hq4x
This commit is contained in:
parent
440b60d1ec
commit
86b2f76aae
|
@ -14,10 +14,15 @@ crate-type = ["cdylib", "rlib"]
|
|||
|
||||
[dependencies]
|
||||
emu = { path = "../emu" }
|
||||
egui = "0.18.0"
|
||||
eframe = { version = "0.18.0", features = ["persistence"] }
|
||||
|
||||
# egui = "0.18.0"
|
||||
# eframe = { version = "0.18.0", features = ["persistence"] }
|
||||
egui = { path = "/home/cake/dev/egui/egui" }
|
||||
eframe = { path = "/home/cake/dev/egui/eframe" }
|
||||
# egui = { git = "https://github.com/emilk/egui", branch = "master" }
|
||||
# eframe = { git = "https://github.com/emilk/egui", branch = "master" }
|
||||
# hqx = { git = "https://github.com/CryZe/wasmboy-rs", branch = "master" }
|
||||
|
||||
serde = { version = "1", features = ["derive"] } # You only need this if you want app persistence
|
||||
|
||||
# native:
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
use emu::Megadrive;
|
||||
|
||||
/// We derive Deserialize/Serialize so we can persist app state on shutdown.
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
#[serde(default)] // if we add new fields, give them default values when deserializing old state
|
||||
pub struct Frontend {
|
||||
// Example stuff:
|
||||
#[serde(skip)]
|
||||
emu: Megadrive,
|
||||
fullscreen: bool,
|
||||
tmp_zoom: f32,
|
||||
|
@ -13,7 +8,6 @@ pub struct Frontend {
|
|||
|
||||
impl Default for Frontend {
|
||||
fn default() -> Self {
|
||||
|
||||
let buf: Vec<u8> = include_bytes!("/home/cake/sonic/roms/s1p.bin").to_vec();
|
||||
Self {
|
||||
emu: Megadrive::new(buf),
|
||||
|
@ -52,13 +46,6 @@ impl Frontend {
|
|||
}
|
||||
|
||||
impl eframe::App for Frontend {
|
||||
/// Called by the frame work to save state before shutdown.
|
||||
fn save(&mut self, storage: &mut dyn eframe::Storage) {
|
||||
eframe::set_value(storage, eframe::APP_KEY, self);
|
||||
}
|
||||
|
||||
/// Called each time the UI needs repainting, which may be many times per second.
|
||||
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
|
||||
if self.fullscreen {
|
||||
|
@ -84,6 +71,7 @@ impl eframe::App for Frontend {
|
|||
size: [320, 240],
|
||||
pixels,
|
||||
},
|
||||
egui::TextureFilter::Nearest
|
||||
);
|
||||
let img_size = ui.available_height() * texture.size_vec2() / texture.size_vec2().y;
|
||||
|
||||
|
@ -135,7 +123,7 @@ impl eframe::App for Frontend {
|
|||
});
|
||||
|
||||
|
||||
egui::Window::new("test").show(ctx, |ui| {
|
||||
egui::Window::new("filter").show(ctx, |ui| {
|
||||
|
||||
let texture: &egui::TextureHandle = &ui.ctx().load_texture(
|
||||
"test",
|
||||
|
@ -148,8 +136,9 @@ impl eframe::App for Frontend {
|
|||
egui::Color32::from_rgb(0, 0, 255),
|
||||
],
|
||||
},
|
||||
egui::TextureFilter::Nearest
|
||||
);
|
||||
let img_size = 400. * texture.size_vec2() / texture.size_vec2().y;
|
||||
let img_size = 20. * texture.size_vec2() / texture.size_vec2().y;
|
||||
ui.image(texture, img_size);
|
||||
|
||||
});
|
||||
|
@ -186,12 +175,66 @@ impl eframe::App for Frontend {
|
|||
pixels,
|
||||
},
|
||||
// TODO: blurryness https://github.com/emilk/egui/pull/1636
|
||||
// egui::TextureFilter::Nearest
|
||||
egui::TextureFilter::Nearest
|
||||
);
|
||||
let img_size = self.tmp_zoom * texture.size_vec2() / texture.size_vec2().y;
|
||||
ui.image(texture, img_size);
|
||||
|
||||
});
|
||||
|
||||
// egui::Window::new("hq3x").show(ctx, |ui| {
|
||||
// ctx.request_repaint();
|
||||
|
||||
|
||||
// let mut pixels3: [u8; 320*240*4] = [0;320*240*4];
|
||||
// let mut pixels2: [egui::Color32; 320*240] = [egui::Color32::DARK_RED;320*240];
|
||||
// static mut pixels32: [u32; 320*240] = [0;320*240];
|
||||
// let mut pixels4: [u32; 320*240*3*3] = [0;320*240*3*3];
|
||||
// let mut pixels42: [egui::Color32; 320*240*3*3] = [egui::Color32::DARK_RED;320*240*3*3];
|
||||
|
||||
// self.emu.gfx.screen.chunks_exact(3)
|
||||
// .enumerate()
|
||||
// .for_each(|(i, p)| {
|
||||
// let index = i * 4;
|
||||
// pixels3[index] = p[0];
|
||||
// pixels3[index+1] = p[1];
|
||||
// pixels3[index+2] = p[2];
|
||||
// pixels3[index+3] = 255;
|
||||
// });
|
||||
|
||||
// pixels3.chunks_exact(4)
|
||||
// .enumerate()
|
||||
// .for_each(|(i, p)| {
|
||||
// unsafe {
|
||||
// pixels32[i] = ((p[0]as u32) << 24) + ((p[1]as u32) <<16) + ((p[2]as u32)<<8 ) + 255;
|
||||
// }
|
||||
// });
|
||||
|
||||
// unsafe {
|
||||
|
||||
// hqx::hq3x(&pixels32, &mut pixels4, 320, 240);
|
||||
// }
|
||||
|
||||
// for (i, foo) in pixels4.iter().enumerate() {
|
||||
// pixels42[i] = egui::Color32::from_rgb(
|
||||
// (foo >> 24) as u8,
|
||||
// (foo >> 16) as u8 & 0xFF,
|
||||
// (foo >> 8) as u8 & 0xFF,
|
||||
// );
|
||||
// }
|
||||
// let texture: &egui::TextureHandle = &ui.ctx().load_texture(
|
||||
// "viewport",
|
||||
// egui::ColorImage {
|
||||
// size: [320*3, 240*3 ],
|
||||
// pixels: pixels42.to_vec(),
|
||||
// },
|
||||
// egui::TextureFilter::Nearest
|
||||
// );
|
||||
// let img_size = self.tmp_zoom * texture.size_vec2() / texture.size_vec2().y;
|
||||
// ui.image(texture, img_size);
|
||||
|
||||
// });
|
||||
|
||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||
// The top panel is often a good place for a menu bar:
|
||||
egui::menu::bar(ui, |ui| {
|
||||
|
|
|
@ -23,31 +23,6 @@ function takeObject(idx) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
|
||||
cachedTextDecoder.decode();
|
||||
|
||||
let cachegetUint8Memory0 = null;
|
||||
function getUint8Memory0() {
|
||||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetUint8Memory0;
|
||||
}
|
||||
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
|
||||
function addHeapObject(obj) {
|
||||
if (heap_next === heap.length) heap.push(heap.length + 1);
|
||||
const idx = heap_next;
|
||||
heap_next = heap[idx];
|
||||
|
||||
heap[idx] = obj;
|
||||
return idx;
|
||||
}
|
||||
|
||||
function isLikeNone(x) {
|
||||
return x === undefined || x === null;
|
||||
}
|
||||
|
@ -70,6 +45,14 @@ function getInt32Memory0() {
|
|||
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
|
||||
let cachegetUint8Memory0 = null;
|
||||
function getUint8Memory0() {
|
||||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetUint8Memory0;
|
||||
}
|
||||
|
||||
const cachedTextEncoder = new TextEncoder('utf-8');
|
||||
|
||||
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
||||
|
@ -123,6 +106,23 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|||
return ptr;
|
||||
}
|
||||
|
||||
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
|
||||
cachedTextDecoder.decode();
|
||||
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
|
||||
function addHeapObject(obj) {
|
||||
if (heap_next === heap.length) heap.push(heap.length + 1);
|
||||
const idx = heap_next;
|
||||
heap_next = heap[idx];
|
||||
|
||||
heap[idx] = obj;
|
||||
return idx;
|
||||
}
|
||||
|
||||
function debugString(val) {
|
||||
// primitive types
|
||||
const type = typeof val;
|
||||
|
@ -215,7 +215,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
|
|||
function __wbg_adapter_24(arg0, arg1) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h344b4850b9a4b9c7(retptr, arg0, arg1);
|
||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hd1ba4f1b874fbd63(retptr, arg0, arg1);
|
||||
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
if (r1) {
|
||||
|
@ -226,16 +226,16 @@ function __wbg_adapter_24(arg0, arg1) {
|
|||
}
|
||||
}
|
||||
|
||||
function __wbg_adapter_27(arg0, arg1, arg2) {
|
||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3dafae52d1e1c889(arg0, arg1, addHeapObject(arg2));
|
||||
function __wbg_adapter_27(arg0, arg1) {
|
||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hd2db381f0b7a919d(arg0, arg1);
|
||||
}
|
||||
|
||||
function __wbg_adapter_30(arg0, arg1) {
|
||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__he9c208075855233b(arg0, arg1);
|
||||
function __wbg_adapter_30(arg0, arg1, arg2) {
|
||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h6c61c324d378a011(arg0, arg1, addHeapObject(arg2));
|
||||
}
|
||||
|
||||
function __wbg_adapter_33(arg0, arg1, arg2) {
|
||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3dafae52d1e1c889(arg0, arg1, addHeapObject(arg2));
|
||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h6c61c324d378a011(arg0, arg1, addHeapObject(arg2));
|
||||
}
|
||||
|
||||
function __wbg_adapter_36(arg0, arg1, arg2) {
|
||||
|
@ -319,10 +319,6 @@ async function init(input) {
|
|||
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
||||
takeObject(arg0);
|
||||
};
|
||||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
||||
const ret = getStringFromWasm0(arg0, arg1);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbg_log_02e20a3c32305fb7 = function(arg0, arg1) {
|
||||
try {
|
||||
console.log(getStringFromWasm0(arg0, arg1));
|
||||
|
@ -366,15 +362,6 @@ async function init(input) {
|
|||
wasm.__wbindgen_free(arg0, arg1);
|
||||
}
|
||||
};
|
||||
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
||||
const obj = takeObject(arg0).original;
|
||||
if (obj.cnt-- == 1) {
|
||||
obj.a = 0;
|
||||
return true;
|
||||
}
|
||||
const ret = false;
|
||||
return ret;
|
||||
};
|
||||
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
||||
const obj = getObject(arg1);
|
||||
const ret = typeof(obj) === 'number' ? obj : undefined;
|
||||
|
@ -389,6 +376,19 @@ async function init(input) {
|
|||
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
||||
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
||||
};
|
||||
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
||||
const obj = takeObject(arg0).original;
|
||||
if (obj.cnt-- == 1) {
|
||||
obj.a = 0;
|
||||
return true;
|
||||
}
|
||||
const ret = false;
|
||||
return ret;
|
||||
};
|
||||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
||||
const ret = getStringFromWasm0(arg0, arg1);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_boolean_get = function(arg0) {
|
||||
const v = getObject(arg0);
|
||||
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
||||
|
@ -1064,9 +1064,6 @@ async function init(input) {
|
|||
const ret = getObject(arg0).getBoundingClientRect();
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbg_log_e8ba7b992c7ad0eb = function(arg0) {
|
||||
console.log(getObject(arg0));
|
||||
};
|
||||
imports.wbg.__wbg_scrollTop_f1031b88f039d8df = function(arg0) {
|
||||
const ret = getObject(arg0).scrollTop;
|
||||
return ret;
|
||||
|
@ -1351,24 +1348,24 @@ async function init(input) {
|
|||
const ret = wasm.memory;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper840 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 225, __wbg_adapter_24);
|
||||
imports.wbg.__wbindgen_closure_wrapper855 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 279, __wbg_adapter_24);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper842 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 225, __wbg_adapter_27);
|
||||
imports.wbg.__wbindgen_closure_wrapper856 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 279, __wbg_adapter_27);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper844 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 225, __wbg_adapter_30);
|
||||
imports.wbg.__wbindgen_closure_wrapper859 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 279, __wbg_adapter_30);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper846 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 225, __wbg_adapter_33);
|
||||
imports.wbg.__wbindgen_closure_wrapper861 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 279, __wbg_adapter_33);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_closure_wrapper1059 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 347, __wbg_adapter_36);
|
||||
imports.wbg.__wbindgen_closure_wrapper908 = function(arg0, arg1, arg2) {
|
||||
const ret = makeMutClosure(arg0, arg1, 306, __wbg_adapter_36);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue