commit 34cfbc3211b2373c0ff1e21275747b1d7ee53ff7
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Tue Jan 18 21:40:08 2022 -0700
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Tue Jan 18 21:40:08 2022 -0700
Update hwstate and default values
---
source/PicoRam.h | 41 +++++++++++++++++++++++++++++------------
test/vmtests.cpp | 21 +++++++++++++++------
2 files changed, 44 insertions(+), 18 deletions(-)
diff --git a/source/PicoRam.h b/source/PicoRam.h
index 7963091..8df5ccd 100644
--- a/source/PicoRam.h
+++ b/source/PicoRam.h
@@ -181,6 +181,7 @@ struct drawState_t {
uint8_t lineInvalid;
+ //hardware extension
uint8_t unknown05f36;
uint8_t unknown05f37;
@@ -196,29 +197,41 @@ struct drawState_t {
struct hwState_t {
//audio hardware mods
+ //0x5f40
uint8_t half_rate;
+ //0x5f41
uint8_t reverb;
+ //0x5f42
uint8_t distort;
+ //0x5f43
uint8_t lowpass;
-
+ //0x5f44..0x5f4b
uint32_t rngState[2];
-
+ //0x5f4c..0x5f53
uint8_t buttonStates[8];
-
- uint8_t unknownInputBlock[8];
-
+ //0x5f54
+ uint8_t spriteSheetMemMapping;
+ //0x5f55
+ uint8_t screenDataMemMapping;
+ //0x5f56
+ uint8_t mapMemMapping;
+ //0x5f57
+ uint8_t widthOfTheMap;
+ //0x5f58..0x5f5b
+ uint8_t printAttributes[4];
+ //0x5f5c
uint8_t btnpRepeatDelay;
-
+ //0x5f5d
uint8_t btnpRepeatInterval;
-
+ //0x5f5e
uint8_t colorBitmask;
-
+ //0x5f5f
uint8_t alternatePaletteFlag;
-
+ //0x5f60..0x5f6f
uint8_t alternatePaletteMap[16];
-
+ //0x5f70..0x5f7f
uint8_t alternatePaletteScreenLineBitfield[16];
-
+ //0x5f80..0x5fff
uint8_t gpioPins[128];
};
@@ -230,9 +243,13 @@ struct PicoRam
void Reset() {
memset(data, 0, 0x4300);
//leave general use memory
- memset(data + 0x5600, 0, 0x8000 - 0x5600);
+ memset(data + 0x5600, 0, 0x10000 - 0x5600);
//colorBitmask starts at 255
hwState.colorBitmask = 0xff;
+ hwState.spriteSheetMemMapping = 0x00;
+ hwState.screenDataMemMapping = 0x60;
+ hwState.mapMemMapping = 0x20;
+ hwState.widthOfTheMap = 128;
}
union
diff --git a/test/vmtests.cpp b/test/vmtests.cpp
index 001cac2..b3b2d14 100644
--- a/test/vmtests.cpp
+++ b/test/vmtests.cpp
@@ -23,18 +23,27 @@ TEST_CASE("Vm memory functions") {
SUBCASE("memory data stats with 0"){
CHECK(memory->data[0] == 0);
}
- SUBCASE("resetting memory zeroes out everything except general use and color bitmask"){
- for(int i = 0; i < 0x8000; ++i) {
+ SUBCASE("resetting memory zeroes out everything except general use, color bitmask, screen data mapping, and map width"){
+ for(int i = 0; i < 0x10000; ++i) {
memory->data[i] = i & 255;
}
memory->Reset();
bool correctValues = true;
- for(int i = 0; i < 0x8000; ++i) {
+ for(int i = 0; i < 0x10000; ++i) {
if (i == 0x5f5e) {
correctValues &= memory->data[i] == 255;
}
+ else if (i == 0x5f55) {
+ correctValues &= memory->data[i] == 0x60;
+ }
+ else if (i == 0x5f56) {
+ correctValues &= memory->data[i] == 0x20;
+ }
+ else if (i == 0x5f57) {
+ correctValues &= memory->data[i] == 128;
+ }
else if (i < 0x4300 || i > 0x55ff) {
correctValues &= memory->data[i] == 0;
}
@@ -272,10 +281,10 @@ TEST_CASE("Vm memory functions") {
CHECK_EQ(input->btn(2), false);
CHECK_EQ(input->btn(3), true);
}
- SUBCASE("poking unknown input block") {
- vm->vm_poke(0x5f54, 53);
+ SUBCASE("poking print attributes") {
+ vm->vm_poke(0x5f58, 53);
- CHECK_EQ(memory->hwState.unknownInputBlock[0], 53);
+ CHECK_EQ(memory->hwState.printAttributes[0], 53);
}
SUBCASE("poking btnp repeat delay") {
vm->vm_poke(0x5f5c, 10);