.dol vs .elf?

Post Reply
Kwilco
Posts: 2
Joined: Wed Jun 04, 2008 10:04 pm

.dol vs .elf?

Post by Kwilco » Wed Jun 04, 2008 10:15 pm

I was wondering what the difference between .dol and .elf files are. I'm getting started with homebrew for the Wii, and am trying to wrap my head around the hello world example. I'm using the programmers notebook program that comes with it to run the provided makefile. It seems to compile fine, but it seems to be outputting both types of files.

Both of these files run on my Wii. Is one for gamecube mode and the other for Wii mode? Does it matter, since I see lots of apps in both formats? Does one have more hardware access than the other, or are they interchangeable, or what? Also, is there any documentation for stuff like SD card file system access? The .h files seemed to just have the function signatures, and I'm not too clear on how to actually use them.

I haven't been able to find any resources about this, and it's confusing to me.

Thanks for any answers or links!

And also a huge thank you the developers of devkitPro, this must be a lot of work, and you have a really cool toolchain going on. I'm hoping to be able to donate soon when I get paid.

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

Re: .dol vs .elf?

Post by WinterMute » Thu Jun 05, 2008 11:24 am

dol files are the pure binary native executable format of both the Wii and the Gamecube. ELF files are the format output by the linker which contain debugging information, dol files are created from the elf files. The dol format is the preferred and recommended format for distribution.

SD card file system access is easy, all you do is link your application with libfat, call fatInitDefault() and use normal stdio functions.

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <wiiuse/wpad.h>

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

//---------------------------------------------------------------------------------
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!");
	
	// Initialise libfat
	fatInitDefault();
	
	// Open a file for reading
	FILE *file = fopen("myfile.txt","rb");
	
	// find the size of the file
	fseek(file, 0L, SEEK_END);
		
	int size = ftell(handle);
		
	fseek(handle, 0L, SEEK_SET);
		
	// allocat buffer for file & read
	void *buffer = malloc(size);
	fread(buffer,1,size,handle);
	fclose(handle);

	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;
}
In the Makefile change the LIBS line

Code: Select all

LIBS	:=	-lwiiuse -lbte -lfat -logc -lm
Help keep devkitPro toolchains free, Donate today

Personal Blog

Kwilco
Posts: 2
Joined: Wed Jun 04, 2008 10:04 pm

Re: .dol vs .elf?

Post by Kwilco » Thu Jun 05, 2008 3:34 pm

Thank you very much, that's very helpful information!

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests