Page 2 of 2

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

Posted: Wed Aug 31, 2011 11:03 pm
by WinterMute
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.

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

Posted: Thu Sep 01, 2011 9:34 am
by tueidj
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.

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

Posted: Thu Sep 01, 2011 11:59 am
by WinterMute
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.

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

Posted: Mon Jun 04, 2012 8:47 pm
by owen
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?

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

Posted: Tue Jun 05, 2012 3:00 pm
by WinterMute
Yes, this feature is available with the latest version of wiiload distributed with devkitPPC

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

Posted: Wed Jun 06, 2012 7:35 pm
by owen
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. :(

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

Posted: Thu Jun 07, 2012 12:30 am
by WinterMute
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;
}

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

Posted: Thu Jun 07, 2012 2:21 am
by owen
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. :(