Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMEM with SAVEID is broken at least in Chrome #850

Closed
nesbox opened this issue Jun 5, 2019 · 5 comments
Closed

PMEM with SAVEID is broken at least in Chrome #850

nesbox opened this issue Jun 5, 2019 · 5 comments
Assignees
Labels
bug platform: html5 For issues affecting browser version of TIC80

Comments

@nesbox
Copy link
Owner

nesbox commented Jun 5, 2019

No description provided.

@nesbox nesbox added the bug label Jun 5, 2019
@StinkerB06
Copy link

StinkerB06 commented Jun 10, 2019

I tried @btco's "PMEM TEST" cartridge on Chrome.

Upon the first reset of the cart, the PMEM didn't save (it resets to 0), but resetting the cart more saved the contents of the PMEM like it should. That's why you must reset the cart when it launches after the TIC-80 splash screen has played.

@BuoYancYdabl
Copy link

BuoYancYdabl commented Jun 21, 2019

Yes, thats the weird thing. Also map and other stuff is reseting. Im talking about random generated and saved by sync() map.

@nesbox nesbox added this to the 0.80.0 milestone Sep 27, 2019
@nesbox nesbox self-assigned this Sep 27, 2019
@Anrock Anrock added the platform: html5 For issues affecting browser version of TIC80 label Nov 6, 2019
@borbware
Copy link
Contributor

borbware commented May 6, 2020

I have noticed similar behaviour on native Windows builds. To my knowledge, resetting the cart with reset() doesn't fix the bug, but resetting from the ESC menu does. And this has to be performed every time TIC-80 is opened.

I'm suspecting the SAVEID doesn't get registered until a successful reset, and the default SAVEID is used instead.

@stefandevai
Copy link
Contributor

So I spent quite some time trying to figure this out today but sadly I ran out of time, so I'm gonna continue tomorrow.

These are some things I found:

  • You're right @borbware, the SAVEID is not saved until a reset from the menu. Somehow the saveid tag it's not being read here:
diff --git a/src/tic.c b/src/tic.c
index 41e48e2..6a10b59 100644
--- a/src/tic.c
+++ b/src/tic.c
@@ -1749,6 +1749,10 @@ static void updateSaveid(tic_mem* memory)
 {
     memset(memory->saveid, 0, sizeof memory->saveid);
     const char* saveid = readMetatag(memory->cart.code.data, "saveid", tic_core_script_config(memory)->singleComment);
+
+    // saveid is only saved to memory after a reset from the menu
+    printf(saveid);
+
     if(saveid)
     {
         strncpy(memory->saveid, saveid, TIC_SAVEID_SIZE-1);
  • The problem is, after a reset() from lua the updateSaveid function is called and the saveid is actually saved into memory. But still the persistent memory is not being read correctly. The only difference from a reset from lua and a reset from the menu is the call of setStudioMode:
diff --git a/src/menu.c b/src/menu.c
index 3b3c68e..c67cd9e 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -47,6 +47,8 @@ static void resetGame(Menu* menu)

     tic_api_reset(tic);

+    // that's the only difference when reseting from the menu compared
+    // to reseting with the API
     setStudioMode(TIC_RUN_MODE);
 }

@@ -523,4 +525,4 @@ void initMenu(Menu* menu, tic_mem* tic, FileSystem* fs)
         },
         .mode = MAIN_MENU_MODE,
     };
-}
\ No newline at end of file
+}

@nesbox nesbox removed this from the 0.80.0 milestone Jul 15, 2020
nesbox added a commit that referenced this issue Jul 17, 2020
@nesbox
Copy link
Owner Author

nesbox commented Jul 17, 2020

Fixed here c9ac879.
Thanks.

@nesbox nesbox closed this as completed Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug platform: html5 For issues affecting browser version of TIC80
Projects
None yet
Development

No branches or pull requests

6 participants