ClassiCube icon indicating copy to clipboard operation
ClassiCube copied to clipboard

GameCube version does not compile?

Open GK6475 opened this issue 1 year ago • 35 comments

No matter what I do, I cannot get the GameCube version to compile under MinGW-W64, even though I have installed LiboGC and the other required things. The error looks like this:

User@GK-PC MINGW64 ~/ClassiCube $ make gamecube make -f Makefile_gamecube PLAT=gamecube make[1]: Entering directory '/home/User/ClassiCube' make[1]: Makefile_gamecube: No such file or directory make[1]: *** No rule to make target 'Makefile_gamecube'. Stop. make[1]: Leaving directory '/home/User/ClassiCube' make: *** [Makefile:157: gamecube] Error 2

I guess the makefile for GameCube does not exist?

GK6475 avatar Jul 26 '23 00:07 GK6475

I might be wrong but I don't think GameCube/Wii are buildable at this point in time

MisterSheeple avatar Jul 26 '23 00:07 MisterSheeple

Ok, thanks for letting me know. I'll have to pay attention to see when they become buildable. Thanks for your reply.

GK6475 avatar Jul 26 '23 00:07 GK6475

You should be able to build for Wii/GameCube (although I may sometimes accidentally break them unintentionally)

It's due to a mistake in the main makefile which I forgot to fix in the actual live code (I only fixed the copy in my testing VM)

If you look at the wii entry, you'll notice it is structured like this:

wii:
	$(MAKE) -f src/Makefile_wii ...

Whereas the gamecube entry is structured like this:

gamecube:
	$(MAKE) -f Makefile_gamecube ..

Changing it to src/Makefile_gamecube instead should fix the error

(I have only tested compiling Wii/GameCube builds on Linux though)

UnknownShadow200 avatar Jul 26 '23 01:07 UnknownShadow200

Ok, I tried that, and came up with this:

linking ... ClassiCube-gc.elf c:/msys64/opt/devkitpro/devkitppc/bin/../lib/gcc/powerpc-eabi/10.2.0/../../../../powerpc-eabi/bin/ld.exe: c:/msys64/opt/devkitpro/devkitppc/bin/../lib/gcc/powerpc-eabi/10.2.0/../../../../powerpc-eabi/bin/ld.exe: DWARF error: can't find .debug_ranges section. C:/msys64/opt/devkitpro/libogc/lib/cube\libogc.a(lwp_threads.o): in function __lwp_thread_start': lwp_threads.c:(.text.__lwp_thread_start+0xce): undefined reference to __sf' c:/msys64/opt/devkitpro/devkitppc/bin/../lib/gcc/powerpc-eabi/10.2.0/../../../../powerpc-eabi/bin/ld.exe: lwp_threads.c:(.text.__lwp_thread_start+0xd6): undefined reference to `__sf' collect2.exe: error: ld returned 1 exit status make[1]: *** [/opt/devkitpro/devkitPPC/gamecube_rules:30: ClassiCube-gc.elf] Error 1 make[1]: Leaving directory '/home/User/ClassiCube' make: *** [Makefile:157: gamecube] Error 2

Any ideas?

Update: Nevermind, I was using the wrong MSYS install. I had to use the DevkitPRO version, then it built correctly.

GK6475 avatar Jul 26 '23 18:07 GK6475

Well, starting it up gives this error: 20230726_140608 Is this supposed to happen?

GK6475 avatar Jul 26 '23 19:07 GK6475

Is this supposed to happen?

It isn't, although the GameCube build hasn't been tested on real hardware before (as far as I know), so I probably did something wrong that doesn't work on real hardware

If you can, please upload or send me your ClassiCube-gc.elf so I can look into the crash

UnknownShadow200 avatar Jul 26 '23 21:07 UnknownShadow200

Here: ClassiCube-gc.zip

GK6475 avatar Jul 27 '23 02:07 GK6475

Based on disassembling the provided .elf file, it's crashing in the mkdir function due to trying to create a directory on an invalid device (probably because there's no SD card)

Although I has tried to work around this in the past by not calling mkdir/open etc if fatInitDefault failed, I need to do something more than just that (because e.g. fatInitDefault may succeed, but be mounted on memory card 0 instead of SD card)


Although probably not of interest, here's what I did to work that out:

  1. Open up ClassiCube-gc.elf in Ghidra
  2. Based on the core dump, the address of the instruction crashed was probably 0x800b59bc
  3. Navigated to 0x800b59bc in Ghidra and verified that the instructions there did indeed match the values in the core dump image
  4. Cleaned up the decompiled mkdir code a bit by renaming some variables
  5. Became suspicious of the fact that mkdir accessed devoptab_list without checking device ID is >= 0 image
  6. Checked whether FindDevice can return -1 in some circumstances - and it can image
  7. Checked the PowerPC documentation for what CPU register is used to store a function return value, and it's GPR03. Hmmm
  8. Working through the instructions from FindDevice to the crash, noticed that the rlwinm instruction was being used to multiply GPR03 by 4, which would explain why it had the value of -4 (aka FFFFFFFC) at the point of crash image
  9. Realised that I had just rediscovered the same problem I found 2 months ago, oops

UnknownShadow200 avatar Jul 27 '23 10:07 UnknownShadow200

Can you please try compiling and running this test program that prints the working directory?

https://gist.github.com/UnknownShadow200/af17394f87d13f19457d738239eacd47

UnknownShadow200 avatar Jul 27 '23 12:07 UnknownShadow200

Yes, I'll try that on my GameCube when I get home later. Also, I have SD cards in Serial port 2 and in an SD Gecko in Memory card slot A. I can try switching to slot B to see if that makes a difference, I know that some homebrew applications work better there.

GK6475 avatar Jul 27 '23 19:07 GK6475

It reports the current directory as Card A. Do I need to put any files on the card, like textures or other resources?

GK6475 avatar Jul 27 '23 22:07 GK6475

What's the full path that is being reported as the current directory?

UnknownShadow200 avatar Jul 27 '23 22:07 UnknownShadow200

Current directory: carda:/ It repeats this constantly.

GK6475 avatar Jul 27 '23 22:07 GK6475

Can you please try again with the latest commit? I tried to address this in c47f48d18750126b5d9af25b0487cdb0b723d891

UnknownShadow200 avatar Jul 28 '23 14:07 UnknownShadow200

Yes, I'll try that in a bit.

GK6475 avatar Jul 28 '23 17:07 GK6475

20230728_130553 Got this error upon trying the latest commit.

GK6475 avatar Jul 28 '23 18:07 GK6475

Oops. The perils of trying to write code very late at night

image

Should be fixed with latest commit

UnknownShadow200 avatar Jul 29 '23 00:07 UnknownShadow200

Okay, it booted up this time. However, the game does not have any text, and all blocks are white. Also, the camera stick is the left stick and movement is done on the DPAD. I would suggest having the camera work on the right (c) stick and having movement on the left joystick. Also, camera acceleration is very slow. Pictures may look a bit strange because my phone camera really doesn't work that well with CRT displays.

20230728_203510 20230728_203536 20230728_203552

GK6475 avatar Jul 29 '23 01:07 GK6475

If you try again with latest commit, launcher menus should display text now

For this line of code in Drawer2D.c you'll probably also want to change false to true:

Drawer2D.BitmappedText    = Game_ClassicMode || !Options_GetBool(OPT_USE_CHAT_FONT, false);

That way in-game should also display text too

UnknownShadow200 avatar Jul 29 '23 06:07 UnknownShadow200

Also, the camera stick is the left stick and movement is done on the DPAD. I would suggest having the camera work on the right (c) stick and having movement on the left joystick.

I've changed the camera to use the right stick instead, thanks for the suggestion

Having movement on the left joystick is a bit trickier - ClassiCube actually doesn't currently support joystick input for player movement, hence why I just use the DPAD currently

Also, camera acceleration is very slow.

Unfortunately, it's challenging for me to work out what joystick scaling factors should be used, as I am unable to test on real hardware myself

I would suggest altering the scaling factors in ProcessPAD_Game in Window_GCWii.c to see if you can get better behaviour

Event_RaiseRawMove(&PointerEvents.RawMoved, dx / 32.0f, dy / 32.0f);

UnknownShadow200 avatar Jul 29 '23 10:07 UnknownShadow200

Ok, text works now, but only on the title menu, and it errors when downloading resources, since it does not have internet connectivity. Can I get these resources and load them onto the SD card somehow? Also there is no deadzone for the joystick, so there is some drifting that happens. I was able to fix camera movement by reducing the values above. The Y-Axis was also inverted, so I fixed that. You could just bind D-pad controls to the left josytick for now, too, since the GameCube controller's D-pad is very tiny.

Event_RaiseRawMove(&PointerEvents.RawMoved, dx / 6.0f, dy / -6.0f);

Also set this to true:

Drawer2D.BitmappedText = Game_ClassicMode || !Options_GetBool(OPT_USE_CHAT_FONT, true);

This did not change in game text, the pause menu and inventory is still blank.

GK6475 avatar Jul 29 '23 18:07 GK6475

Ok, text works now, but only on the title menu, and it errors when downloading resources, since it does not have internet connectivity. Can I get these resources and load them onto the SD card somehow?

If ClassiCube was able to successfully access the SD card, then there should be a classicube folder generated on the SD card. Inside that there should be a texpacks folder, and you can copy either default.zip or classicube.zip from a PC copy of ClassiCube into that folder

Also set this to true:

Drawer2D.BitmappedText = Game_ClassicMode || !Options_GetBool(OPT_USE_CHAT_FONT, true);

This did not change in game text, the pause menu and inventory is still blank.

Maybe just do Drawer2D.BitmappedText = false;

UnknownShadow200 avatar Jul 29 '23 23:07 UnknownShadow200

@GK6475 Are you using an SD2SP2 or an SDgecko?

MisterSheeple avatar Jul 29 '23 23:07 MisterSheeple

I am using both, technically, but I am booting from a GC-Loader. I just tried making a classicube folder on the SD Gecko and it worked. Textures appear now, and the original font loads. Sound doesn't work, however, and I cannot make any selections in the pause menu.

GK6475 avatar Jul 30 '23 02:07 GK6475

I cannot make any selections in the pause menu.

All the in-game menus are currently only really designed for using with mouse (or touch) input, so it will take me a bit more time to change them to work properly with controller input too

I've attempted to add a deadzone for the gamecube controller, and changed the scaling factors so that the camera is more responsive by default

UnknownShadow200 avatar Jul 30 '23 14:07 UnknownShadow200

Ok, that helps. What I did for the responsiveness was a value of 4.0f or 6.0f and I made the Y negative to make the camera feel more natural, similar to how it worked on the console versions of Minecraft. Also, after testing, the deadzone needs to be a little bigger, maybe around 5-10% of the stick or so.

GK6475 avatar Jul 30 '23 16:07 GK6475

I made the Y negative to make the camera feel more natural, similar to how it worked on the console versions of Minecraft. Also, after testing, the deadzone needs to be a little bigger, maybe around 5-10% of the stick or so.

Not sure if it's enough, but I tired increasing the deadzone

Y has also been inverted too now

UnknownShadow200 avatar Aug 01 '23 14:08 UnknownShadow200

That fixed the drift issues completely. Works much better now.

GK6475 avatar Aug 01 '23 23:08 GK6475

Is broadband adapter multiplayer support in the works? I don't own one but it would be really neat for the people that do.

GK6475 avatar Aug 04 '23 02:08 GK6475

Is broadband adapter multiplayer support in the works? I don't own one but it would be really neat for the people that do.

Yes. I own one and have been testing with it lately. It hasn't worked so far (testing over LAN for now) but eventually it probably will.

MisterSheeple avatar Aug 04 '23 02:08 MisterSheeple