Skip to content

Instantly share code, notes, and snippets.

@BILLPC2684
Created September 9, 2021 04:26
Show Gist options
  • Save BILLPC2684/6ba37f7250b69c2fe94af543cdc77582 to your computer and use it in GitHub Desktop.
Save BILLPC2684/6ba37f7250b69c2fe94af543cdc77582 to your computer and use it in GitHub Desktop.
TGR testing in rust...
#![allow(non_snake_case)]
use winit::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
//use std::path::Path;
use image::{Pixel, DynamicImage as DymImage};
use image::io::Reader as ImageReader;
use winit::window::{Icon, Window};
use std::{thread, mem};
/*.__________.
|MEMORY_MAP|___________________________________________.
|Name:"."."."."Length:"."."Starting:"."Ending:"."Size:"|
|\ROM: . . . . 0x1800000 > 0x0000000 - 0x17FFFFF[.24MB]|
|\SAV: . . . . 0x0800000 > 0x1800000 - 0x1FFFFFF[. 8MB]|
|\Work RAM:. . 0x7FBFE00 > 0x2000000 - 0x9FBFDFF[112MB]|
|\Stack Mem: . 0x0040000 > 0x9FBFE00 - 0x9FFFDFF[256KB]|
|\Static Mem:. 0x0000200 > 0x9FFFE00 - 0x9FFFFFF[512BT]|
|\VRAM:. . . . 0x4000000 > 0xA000000 - 0xDFFFFFF[.64MB]|
|\TOTAL: . . . 0xE000000 . . . . . . . . . . . . . . . |
|______________________________________________________|*/
fn main() {
static mut RAM: &'static [i8;0xE000000]=&[0;0xE000000];
let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap();
let img = ImageReader::open("./bin/TGR-logo(alone).png").unwrap().decode().unwrap().to_rgba8();
let (image_width,image_height,image_vec)=(img.width(),img.height(),img.into_raw());
Window::set_window_icon(&window, Icon::from_rgba(image_vec,image_width,image_height).map_or(None, |ico| Some(ico)));
// println!("{:?}",icon);
let CPU0 = thread::spawn(|| {CPU_Thread(0,&RAM);}); //use of mutable static
let CPU1 = thread::spawn(|| {CPU_Thread(1,&RAM);}); //use of mutable static
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
match event {
Event::WindowEvent {
event: WindowEvent::CloseRequested,
window_id,
} if window_id == window.id() => *control_flow = ControlFlow::Exit,
_ => (),
}
});
}
fn CPU_Thread(ID:i8,RAM:&&'static[i8;0xE000000]) {
println!("my ID is: {}, RAMSize {}",ID,mem::size_of_val(&*RAM));
&RAM[0]=1; //Errors: cannot assign | i have no idea how to edit this value...
println!("RAM[0] = {};",RAM[0]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment