mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 01:21:34 +11:00
patch in cycles output
This commit is contained in:
parent
be77d97f00
commit
cda7e95a28
40
mgba-test-runner/add_cycles_register.patch
Normal file
40
mgba-test-runner/add_cycles_register.patch
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
diff --git a/include/mgba/internal/gba/io.h b/include/mgba/internal/gba/io.h
|
||||||
|
index 9875061f3..bdeafdcd3 100644
|
||||||
|
--- a/include/mgba/internal/gba/io.h
|
||||||
|
+++ b/include/mgba/internal/gba/io.h
|
||||||
|
@@ -157,6 +157,7 @@ enum GBAIORegisters {
|
||||||
|
REG_DEBUG_STRING = 0xFFF600,
|
||||||
|
REG_DEBUG_FLAGS = 0xFFF700,
|
||||||
|
REG_DEBUG_ENABLE = 0xFFF780,
|
||||||
|
+ REG_DEBUG_CYCLES = 0xFFF800,
|
||||||
|
};
|
||||||
|
|
||||||
|
mLOG_DECLARE_CATEGORY(GBA_IO);
|
||||||
|
diff --git a/src/gba/io.c b/src/gba/io.c
|
||||||
|
index cc39e1192..d34dcb4b4 100644
|
||||||
|
--- a/src/gba/io.c
|
||||||
|
+++ b/src/gba/io.c
|
||||||
|
@@ -573,6 +573,11 @@ void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) {
|
||||||
|
case REG_DEBUG_ENABLE:
|
||||||
|
gba->debug = value == 0xC0DE;
|
||||||
|
return;
|
||||||
|
+ case REG_DEBUG_CYCLES: {
|
||||||
|
+ int32_t number_of_cycles = mTimingCurrentTime(&gba->timing);
|
||||||
|
+ mLOG(GBA_DEBUG, INFO, "Cycles: %d Tag: %hd", number_of_cycles, value);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
case REG_DEBUG_FLAGS:
|
||||||
|
if (gba->debug) {
|
||||||
|
GBADebug(gba, value);
|
||||||
|
@@ -936,6 +941,11 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) {
|
||||||
|
return 0x1DEA;
|
||||||
|
}
|
||||||
|
// Fall through
|
||||||
|
+ case REG_DEBUG_CYCLES: {
|
||||||
|
+ int32_t number_of_cycles = mTimingCurrentTime(&gba->timing);
|
||||||
|
+ mLOG(GBA_DEBUG, INFO, "Cycles: %d", number_of_cycles);
|
||||||
|
+ return number_of_cycles;
|
||||||
|
+ }
|
||||||
|
default:
|
||||||
|
mLOG(GBA_IO, GAME_ERROR, "Read from unused I/O register: %03X", address);
|
||||||
|
return GBALoadBad(gba->cpu);
|
|
@ -2,12 +2,14 @@
|
||||||
|
|
||||||
MGBA_VERSION=$1
|
MGBA_VERSION=$1
|
||||||
OUT_DIRECTORY=$2
|
OUT_DIRECTORY=$2
|
||||||
|
CURRENT_DIRECTORY=$(pwd)
|
||||||
|
|
||||||
cd ${OUT_DIRECTORY}
|
cd ${OUT_DIRECTORY}
|
||||||
curl -L https://github.com/mgba-emu/mgba/archive/refs/tags/${MGBA_VERSION}.tar.gz -o mgba-${MGBA_VERSION}.tar.gz
|
curl -L https://github.com/mgba-emu/mgba/archive/refs/tags/${MGBA_VERSION}.tar.gz -o mgba-${MGBA_VERSION}.tar.gz
|
||||||
tar -xvf mgba-${MGBA_VERSION}.tar.gz
|
tar -xvf mgba-${MGBA_VERSION}.tar.gz
|
||||||
cd mgba-${MGBA_VERSION}
|
cd mgba-${MGBA_VERSION}
|
||||||
rm -rf build
|
rm -rf build
|
||||||
|
patch --strip=1 < ${CURRENT_DIRECTORY}/add_cycles_register.patch
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build
|
cd build
|
||||||
cmake .. \
|
cmake .. \
|
||||||
|
|
|
@ -29,4 +29,9 @@ fn main() {
|
||||||
bindings
|
bindings
|
||||||
.write_to_file(&out_path.join("runner-bindings.rs"))
|
.write_to_file(&out_path.join("runner-bindings.rs"))
|
||||||
.expect("Couldn't write bindings!");
|
.expect("Couldn't write bindings!");
|
||||||
|
|
||||||
|
println!("cargo:rerun-if-changed=c/test-runner.c");
|
||||||
|
println!("cargo:rerun-if-changed=c/test-runner.h");
|
||||||
|
println!("cargo:rerun-if-changed=build-mgba.sh");
|
||||||
|
println!("cargo:rerun-if-changed=add_cycles_register.patch");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue