Why SDL can't load an image via wiiload instead of sd card ?

support for the powerpc toolchain
WinterMute
Site Admin
Posts: 1404
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Why SDL can't load an image via wiiload instead of sd ca

Post by WinterMute » Wed Aug 31, 2011 11:03 pm

The solution here means that you don't have to change the code when you release it or want to run directly from the SD card (or any other device that can be mounted). As I said, you can't load things directly via wiiload.
Help keep devkitPro toolchains free, Donate today

devkitPro IRC support
Personal Blog

tueidj
Posts: 40
Joined: Thu Dec 10, 2009 9:26 am

Re: Why SDL can't load an image via wiiload instead of sd ca

Post by tueidj » Thu Sep 01, 2011 9:34 am

WinterMute wrote:When the wii SDL port starts up the SD card it will attempt to set the working directory using the path it finds in argv[0].
SDL-Wii doesn't start any IO devices or initialize any filesystems, the main program has to handle it.

WinterMute
Site Admin
Posts: 1404
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Why SDL can't load an image via wiiload instead of sd ca

Post by WinterMute » Thu Sep 01, 2011 11:59 am

Oops, been a while since I looked at the SDL port - there used to be a fatInitDefault in one version that was kicking around. The ability to set argv0 from wilload is still useful though.
Help keep devkitPro toolchains free, Donate today

devkitPro IRC support
Personal Blog

owen
Posts: 13
Joined: Mon Feb 07, 2011 2:05 pm
Contact:

Re: Why SDL can't load an image via wiiload instead of sd ca

Post by owen » Mon Jun 04, 2012 8:47 pm

WinterMute wrote:No, currently you can't load files via wiiload other than from the SD card as you've been doing.

I've just modified wiiload so you can set argv0 from the command line though, this will let you change the initial working directory set when the SD card is initialised. You can either build wiiload yourself, it's in SVN at http://devkitpro.svn.sourceforge.net/vi ... i/wiiload/ , or you can grab the builds I've just put up at https://sourceforge.net/projects/devkitpro/files/misc/ . The tarball only has wiiload 0.5.1 binaries for win32 & OSX atm, I didn't have time to build the linux versions. The binaries are still showing as pending atm but should hopefully be live soon.

when you're running the new wiiload just add the path you want as the first parameter after the dol

Code: Select all

wiiload mysdlapp.dol sd:/apps/SDL/mysdlapp.dol
Adding the name of the dol isn't necessary but the trailing slash is.

I am having the same problem we I have to hard code the absolute path of all my external files/images/models/lua scripts if I want to test my program with wiiload. Has this patch been rolled into in the latest release of wiiload?

WinterMute
Site Admin
Posts: 1404
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Why SDL can't load an image via wiiload instead of sd ca

Post by WinterMute » Tue Jun 05, 2012 3:00 pm

Yes, this feature is available with the latest version of wiiload distributed with devkitPPC
Help keep devkitPro toolchains free, Donate today

devkitPro IRC support
Personal Blog

owen
Posts: 13
Joined: Mon Feb 07, 2011 2:05 pm
Contact:

Re: Why SDL can't load an image via wiiload instead of sd ca

Post by owen » Wed Jun 06, 2012 7:35 pm

my make files has ;

Code: Select all

#---------------------------------------------------------------------------------
run:$(BUILD)
	wiiload $(TARGET).dol "sd:/apps/mygame/"
#---------------------------------------------------------------------------------
but it does not seem to affect it at all. :(

WinterMute
Site Admin
Posts: 1404
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Why SDL can't load an image via wiiload instead of sd ca

Post by WinterMute » Thu Jun 07, 2012 12:30 am

It's working fine for me with some test code. Are you sure you're using the right wiiload? (0.5.1)

Code: Select all


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <gccore.h>
#include <wiiuse/wpad.h>
#include <ogc/lwp_watchdog.h>

#include <fat.h>


static void *xfb = NULL;
static GXRModeObj *rmode = NULL;

extern u64 gettime();

//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------

	// Initialise the video system
	VIDEO_Init();
	
	// This function initialises the attached controllers
	WPAD_Init();
	
	// Obtain the preferred video mode from the system
	// This will correspond to the settings in the Wii menu
	rmode = VIDEO_GetPreferredMode(NULL);

	// Allocate memory for the display in the uncached region
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	
	// Initialise the console, required for printf
	console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
	
	// Set up the video registers with the chosen mode
	VIDEO_Configure(rmode);
	
	// Tell the video hardware where our display memory is
	VIDEO_SetNextFramebuffer(xfb);
	
	// Make the display visible
	VIDEO_SetBlack(FALSE);

	// Flush the video register changes to the hardware
	VIDEO_Flush();

	// Wait for Video setup to complete
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();


	// The console understands VT terminal escape codes
	// This positions the cursor on row 2, column 0
	// we can use variables for this with format codes too
	// e.g. printf ("\x1b[%d;%dH", row, column );
	printf("\x1b[2;0H");
	

	printf("Hello World!\n");
	
	printf("There were %d arguments\n",argc);
	for (int i=0; i<argc; i++ ) {
		printf("%s ",argv[i]);
	}
	printf("\n");
	
	if(fatInitDefault()) {
		char wd[1024];
		getcwd(wd,1024);
		printf("path is %s\n",wd);
		FILE *test = fopen("boot.dol","rb");
		if (test == NULL) {
			printf("failed opening boot.dol\n");
		} else {
			fseek(test,0,SEEK_END);
			int size = ftell(test);
			fclose(test);
			printf("boot.dol is %d bytes.\n",size);
		}
	} else {
		printf("failed intialising FAT\n");
	}

	
	while(1) {

		// Call WPAD_ScanPads each loop, this reads the latest controller states
		WPAD_ScanPads();

		// WPAD_ButtonsDown tells us which buttons were pressed in this loop
		// this is a "one shot" state which will not fire again until the button has been released
		u32 pressed = WPAD_ButtonsDown(0);

		// We return to the launcher application via exit
		if ( pressed & WPAD_BUTTON_HOME ) exit(0);

		// Wait for the next frame
		VIDEO_WaitVSync();
	}

	return 0;
}
Help keep devkitPro toolchains free, Donate today

devkitPro IRC support
Personal Blog

owen
Posts: 13
Joined: Mon Feb 07, 2011 2:05 pm
Contact:

Re: Why SDL can't load an image via wiiload instead of sd ca

Post by owen » Thu Jun 07, 2012 2:21 am

yes I am using the right version

Code: Select all

> "make" run
main.c
linking ... rotationtest2.elf
output ... rotationtest2.dol
wiiload rotationtest2.dol "sd:/apps/rotationtest2/"
wiiload v0.5.1
coded by dhewg

compressing 280160 bytes... 52.87%
connecting to 192.168.0.101:4299
sending upload request
sending file size (148107 bytes)
sending data..
sending arguments (37 bytes)
done.
when I compile your code I get this message;

Code: Select all

Hello world 
there are 1 arguments
sd:/apps/rotationtest2/
path is /
failed opening boot.dol
I expect the working directory to be "sd:/apps/rotationtest2/" but doesn't seem to work (and the directory exists). I simply want it to run as if was being run from the homebrew channel with the working directory set correctly. :(

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest