foxygit / fake-08-xbox360 Log in
commit 1287f2b2a92b8f7540d18d53c92f2d466117c32c
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Fri Apr 8 07:22:55 2022 -0600
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Fri Apr 8 07:22:55 2022 -0600

    Another try at fixing cartdata serialization
---
 source/vm.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/source/vm.cpp b/source/vm.cpp
index 687fc4f..fb3401f 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -414,13 +414,16 @@ std::string Vm::getSerializedCartData() {

     char hex_string[9] = "00000000";

+    //ATTN: writing one byte at a time instead of one 32 bit int at a time
+    //to ensure same behavior across platforms and cpu architectures
     for(int i = 0; i < 64; i++){
-        fix32 val = vm_dget((uint8_t)i);
-        int32_t bitsVal = val.bits();
+        for(int b = 3; b >= 0; b--){
+            uint8_t byte = _memory->data[0x5e00 + (i*4) + b];

-        sprintf(hex_string, "%08x", bitsVal);
+            sprintf(hex_string, "%02x", byte);

-        outputstr.append(hex_string);
+            outputstr.append(hex_string);
+        }

         if ((i + 1) % 8 == 0) {
             outputstr.append("\n");