PDA

View Full Version : [OpenXDK] Installing OpenXDK


Maturion
2007-09-22, 19:04
Installing OpenXDK in Windows
Note: I haven't written

OpenXDK is getting more and more interesting (Friedgold added vbl synced double buffering support in SDL, and Carchiarus added pbKit compatibility).
Time for a simple tutorial!

Get your copy of OpenXDK 0.1!
You can get it at:
http://www.maturion.de/xbox/openxdk/OpenXDK_0_1_bin.zip
http://home.tele2.fr/~fr-51785/openxdk.zip
This is May 2007 version (1st version compatible with pbKit, natively).

What we'll do:

-We setup an OpenXDK enviroment
-We'll compile our first program for OpenXDK

1) Be sure to have last version of cygwin (a free and legal unix-like environment for Windows)
Go on www.cygwin.com, click "install or update now!" in middle of page. The small setup program will offer you to download or update all components of Cygwin. You need at least binutils, automake, gcc and autoconf. Be patient.
Repository in Belgium is very good. Will consume several gigabytes of disk space. Try to have 2GB available for safety. Choose c:\cygwin and c:\cygwin_downloads, for example, when pathes are asked.
Cygwin includes GNU compilers and all stuff you may need later in order to produce your own programs.

After you've installed Cygwin you must install OpenXDK. Extract your copy of OpenXDK in C:\usr\local\openxdk

2) Create a sample program

We've setup our development enviroment! Now you must open Cygwin.
It will create a few directories and files for you.
After this has been done, close Cygwin.

It's time to start coding now!
- Create file "hello.c" in C:\cygwin\home\<yourname>

Code:


#include <hal/input.h>
#include <hal/xbox.h>
#include <openxdk/debug.h>

#include "string.h"
#include "stdio.h"
#include <stdlib.h>


void XBoxStartup(void)
{
int i,done=0;

XInput_Init();

debugPrint("Hello world!\n");
debugPrint("Press B to stop program\n");

while(!done)
{

XInput_GetEvents();

for(i=0; i<4; i++)
{
if(g_Pads[i].PressedButtons.ucAnalogButtons[XPAD_B]) done=1;
}
};

debugPrint("Bye...\n");

XInput_Quit();

XSleep(5000);
XReboot();
}


- Create file "makefile" in C:\cygwin\home\<yourname>


[i]Once you copied/pasted this makefile, replace the <tab> with real tabulations.


Code:


#
# update this variable to wherever you installed the OpenXDK libraries
#
PREFIX = /usr/local/openxdk

CC = gcc
CCAS = gcc
CPP = cpp
CXBE = $(PREFIX)/bin/cxbe

SDLFLAGS = -DENABLE_XBOX -DDISABLE_CDROM
CC_FLAGS = -c -g -std=gnu99 -ffreestanding -nostdlib -fno-builtin -fno-exceptions -mno-cygwin -march=i386 $(SDLFLAGS)
CCAS_FLAGS = -g -O2
INCLUDE = -I$(PREFIX)/i386-pc-xbox/include -I$(PREFIX)/include -I$(PREFIX)/include/SDL

CLINK = -nostdlib
ALIGN = -Wl,--file-alignment,0x20 -Wl,--section-alignment,0x20
SHARED = -shared
ENTRYPOINT = -Wl,--entry,_WinMainCRTStartup
STRIP = -Wl,--strip-all
LD_FLAGS = $(CLINK) $(ALIGN) $(SHARED) $(ENTRYPOINT) $(STRIP)
LD_DIRS = -L$(PREFIX)/i386-pc-xbox/lib -L$(PREFIX)/lib
LD_LIBS = $(LD_DIRS) -lSDL -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc

#LD_LIBS = -lSDL_ttf -lfreetype2 -lSDL_image -lSDL -ljpeg -lpng -lz -lxml2 -lm -lhal -lusb -lopenxdk -lhal -lc -lxboxkrnl -lstdc++ -lgcc

OBJS=hello.o

all: default.exe

.c.o:
<tab>$(CC) -c $< $(CC_FLAGS) $(INCLUDE)


.s.o:
<tab>$(CCAS) -c $< $(CCAS_FLAGS)

default.exe: $(OBJS)
<tab>$(CC) -o $@ $(OBJS) $(LD_LIBS) $(LD_FLAGS)
<tab>$(CXBE) -TITLE:"$@" -DUMPINFO:"default.cxbe" -OUT:"default.xbe" $@ > /dev/null

send: all
<tab>make
<tab>./ftp2xbox.bat

clean:
<tab>rm -f *.o *.exe *.dll *.xbe *.cxbe



5) Compile your own program
use these commands :
"make clean" (delete all binaries)
"make" (compile binaries)
You obtain default.xbe, a little legal xbox program! (not compiled with libraries coming from official xdk)
Of course you need a way to launch homebrew software on your xbox.
Note that if cross references change again in OpenXDK, the order of libraries may need to be changed again (constant LD_LIBS) in case you get link errors not related to your own source (a library may need another one before itself in the list, because it calls it now and didn't call it before).
Makefiles found in samples and sdlDoom may need some update too (especially the libraries order).

Have fun -legally- with your Xbox! (finally!)
Enjoy the fruits of our hard work now!

PS:
Explore pbKit changelog. Very nice demos (sources included) are available!
http://home.tele2.fr/~fr-51785/pbkit/changelog.txt
(pbKit is a low level GPU driver, allowing hardware graphic acceleration)

Thank you openxdkman!

It'd be nice if someone pinned this thread.