Skip to content

Commit bda54dc

Browse files
committed
WIP
1 parent 888afe8 commit bda54dc

File tree

5 files changed

+44
-8
lines changed

5 files changed

+44
-8
lines changed

Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ vitasdk-sys = { version = "0.3.2", features = [
5353
# "SceRazorCapture_stub",
5454
] }
5555

56+
[dev-dependencies]
57+
58+
[profile.release-debug]
59+
inherits = "dev"
60+
opt-level = 3
61+
overflow-checks = true
62+
debug-assertions = true
63+
debug = true
64+
panic = "abort"
65+
5666
[profile.release]
5767
panic = "abort"
5868
lto = "fat"

build.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
use bindgen::Formatter;
2+
use std::fs::File;
3+
use std::io::Write;
24
use std::path::PathBuf;
35
use std::process::Command;
46
use std::{env, fs};
57

68
fn main() {
9+
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
10+
11+
let build_profile_name = out_path.to_str().unwrap().split(std::path::MAIN_SEPARATOR).nth_back(3).unwrap();
12+
let build_profile_name_file = out_path.join("build_profile_name");
13+
File::create(build_profile_name_file).unwrap().write_all(build_profile_name.as_bytes()).unwrap();
14+
715
let target = env::var("TARGET").unwrap();
816
if target != "armv7-sony-vita-newlibeabihf" {
917
// Running IDE on anything other than linux will fail, so ignore compile error
@@ -17,7 +25,6 @@ fn main() {
1725
let vitasdk_include_path = vitasdk_path.join("arm-vita-eabi").join("include");
1826
let vitasdk_lib_path = vitasdk_path.join("arm-vita-eabi").join("lib");
1927

20-
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
2128
let bindings_file = out_path.join("imgui_bindings.rs");
2229

2330
const IMGUI_HEADERS: [&str; 3] = ["imgui.h", "imgui_internal.h", "imgui_impl_vitagl.h"];

src/jit/jit_asm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ fn emit_code_block_internal<const CPU: CpuType, const THUMB: bool>(store_host_sp
217217
asm.emit(&mut block_asm);
218218
}
219219

220-
// if DEBUG_LOG {
221-
// block_asm.save_context();
222-
// block_asm.call2(debug_after_exec_op::<CPU> as *const (), asm.jit_buf.current_pc, asm.jit_buf.current_inst().opcode);
223-
// block_asm.restore_reg(Reg::CPSR);
224-
// }
220+
if DEBUG_LOG {
221+
block_asm.save_context();
222+
block_asm.call2(debug_after_exec_op::<CPU> as *const (), asm.jit_buf.current_pc, asm.jit_buf.current_inst().opcode);
223+
block_asm.restore_reg(Reg::CPSR);
224+
}
225225
}
226226

227227
let opcodes = block_asm.finalize(guest_pc, THUMB);

src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::jit::jit_asm::JitAsm;
2323
use crate::logging::debug_println;
2424
use crate::presenter::{PresentEvent, Presenter, PRESENTER_AUDIO_BUF_SIZE};
2525
use crate::settings::Settings;
26-
use crate::utils::{set_thread_prio_affinity, HeapMemU32, ThreadAffinity, ThreadPriority};
26+
use crate::utils::{const_str_equal, set_thread_prio_affinity, HeapMemU32, ThreadAffinity, ThreadPriority};
2727
use std::cell::UnsafeCell;
2828
use std::cmp::min;
2929
use std::intrinsics::{likely, unlikely};
@@ -46,7 +46,8 @@ mod presenter;
4646
mod settings;
4747
mod utils;
4848

49-
pub const DEBUG_LOG: bool = cfg!(debug_assertions);
49+
const BUILD_PROFILE_NAME: &str = include_str!(concat!(env!("OUT_DIR"), "/build_profile_name"));
50+
pub const DEBUG_LOG: bool = const_str_equal(BUILD_PROFILE_NAME, "debug");
5051
pub const DEBUG_LOG_BRANCH_OUT: bool = DEBUG_LOG;
5152

5253
fn run_cpu(

src/utils.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,21 @@ pub fn rgb6_to_float8(color: u32) -> (f32, f32, f32) {
260260
let b = ((color >> 12) & 0x3F) as f32;
261261
(r / 63f32, g / 63f32, b / 63f32)
262262
}
263+
264+
pub const fn const_bytes_equal(lhs: &[u8], rhs: &[u8]) -> bool {
265+
if lhs.len() != rhs.len() {
266+
return false;
267+
}
268+
let mut i = 0;
269+
while i < lhs.len() {
270+
if lhs[i] != rhs[i] {
271+
return false;
272+
}
273+
i += 1;
274+
}
275+
true
276+
}
277+
278+
pub const fn const_str_equal(lhs: &str, rhs: &str) -> bool {
279+
const_bytes_equal(lhs.as_bytes(), rhs.as_bytes())
280+
}

0 commit comments

Comments
 (0)