rovertronic / Mario-Builder-64

Mario Builder 64 is a Super Mario 64 ROM hack that allows you to create custom levels in-game.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Level list is empty after selecting "Save & Quit" option from level editor

Polprzewodnikowy opened this issue · comments

Steps to reproduce:

  1. Run ROM
  2. Start building new level
  3. Add some blocks
  4. Open level settings
  5. Navigate to system tab
  6. Select "Save & Quit"
  7. Message pops up: "No levels currently loaded yet."

Expected outcome:
After save & quit I should see last saved level in the list

Environment:
NTSC N64 console with SummerCart64 flashcart and exFAT file system on the SD card

I've submitted a fix here: #13

Thank you! I'll merge this in a bit. Out of curiosity, why does using chdir cause problems on flashcarts? I'd like to know for future reference.

Main issues seems to be stemming from:

  1. No error checking. Didn't find the exact function that causes chdir to fail, but f_opendir in load_level_files_from_sd_card function returns FR_NO_PATH so somewhere the path is getting desynced. I've tried to use f_getcwd to look what's going on but it just returned empty string, which should mean root directory.
  2. Incorrect usage of pointers. In many places level directory string was incorrectly passed to the function. Since string already is a pointer, there's no need to add & to get the address. Compiler warnings are very clear about that.
    image
    image

As of why this works in the Parallel launcher and not on the real hardware, my assumption is just inaccurate emulation. Maybe there's some place where cache coherency is not taken care of - emulators usually don't implement CPU cache correctly.

If you want to keep f_chdir then quick fix seems to be to always chdir into absolute path (add / at the beginning):
Screenshot 2024-05-23 105538
But I strongly recommend just sticking to the absolute paths. Doing f_chdir in random places is error prone and confusing to the uninitiated reader.