galaxyhaxz / smw-src

Source code to Super Mario World (SNES disassembly)
35 stars 5 forks source link

Compatibility with newer versions of WLA-DX #3

Open imsys opened 1 year ago

imsys commented 1 year ago

My knowledge in Assembly extremely limited, but I was going to see if ChatGPT would help me. xD

As I mostly use Linux for coding, I was trying to use the linux binaries for wla-dx. I did many tests and I could not get it working, but I'm sharing the progress I got, so maybe someone can continue from here.

The included wla-dx binaries are for version 9.7b, the 7zip says it is from about july 29, 2016.

If I compile the point with the 9.7 tag, I get:

../../tool/wla-dx/binaries/wla-65816 -I../../include -o main.o main.S
equates/memory.i:461: DIRECTIVE_ERROR: Unexpected symbol "DL" in .ENUM.
equates/memory.i:461: ERROR: Couldn't parse "DL".
make: *** [makefile:32: main.o] Error 1

version 9.8 and 9.10 builds and starts the game, shows the company logo, produce sound, but as the logo fade out, it stays in the black screen.

I got errors trying to compile wla-dx 9.9.

wla-dx 9.11 onwards, I get:

wla-65816 -I../../include -o main.o main.S
game.s:785: ERROR: Unknown symbol "JMP".
make: *** [makefile:32: main.o] Error 1

game.s:785 contains:

    JMP [m0]

It seems to be from this change: https://github.com/vhelin/wla-dx/blame/a6f2bd33dd623bee295890e5cdab8479d617003d/i65816.c#L324

   { "JMP (?)", 0x6C, 2, 0 },
-  { "JMP (?,X)", 0x7C, 2, 0 },
-  { "JMP [?]", 0xDC, 2, 0 },
+  { "JMP [|?]", 0xDC, 2, 0 },
   { "JML [?]", 0xDC, 2, 0 },
+  { "JMP (|?,X)", 0x7C, 2, 0 },
+  { "JMP (?,X)", 0x7C, 2, 0 },

The replacement of JMP [?] to JMP [|?]. That commit says it shouldn't affect previous code, but maybe it's an unexpected behavior, idk. So as I saw there were a JML just bellow with the same hexadecimal, I thought it could work as a replacement? idk. So I changed all places where there was JMP [m0] to JML [m0] and it compiles.

But then I get some reference erros:

wlalink -v -S -L../../lib linkfile mw_e10.sfc
main.o: game.s:3353: FIX_REFERENCES: Reference to an unknown label "sm_Main.Data.EventsTriggered".
make: *** [makefile:22: all] Error 1

I'm not really sure how to fix that.

Anyway, for now it compiles just fine using wine to run the binaries distributed. I may do some more tests later.

galaxyhaxz commented 1 year ago

Hello, glad to see someone take interest in this project :)

Regarding the error DIRECTIVE_ERROR: Unexpected symbol "DL" in .ENUM., I recall sending a pull request to WLA to add the .DL directive which adds 24-bit data integers, but it wasn't added officially until later. The binaries provided in the repo have a few updates made to them. I'm not sure if I made any other updates, as I lost the source long ago.

Hopefully you can figure out the last error, I can update the repo if you do. Although unless you're specifically interested in the WLA-DX build, there are two other Super Mario World disassemblies which are more recent and both use ASAR. One of them is a continuation of my disassembly and should be cleaner and more updated.

https://github.com/Yoshifanatic1/SMW-SMAS-SMASW-Disassembly (based on this one) https://github.com/IsoFrieze/SMWDisX

imsys commented 1 year ago

Thanks for the reply. Those other repos are definitely useful. I also just found your custom WLA source in the files you shared in SMWCentral. My intention is to use your C proof of concept shared in the forum and go from there, and test if ChatGPT could handle converting block by block to C.