xbox-scene.com - your xbox news information source
Quick Links: Main Forums | Xbox360 Forums | Xbox1 Forums | PS3 Forums
Xbox-Scene Forum Help  Search Xbox-Scene Forums   Xbox-Scene Forum Members   Xbox-Scene Calendar

Giganews Offers: days binary retention, 99%+ Completion, and Unlimited Access!
Try Giganews' no obligation free trial!

Support this site - buy the X-Scene Tshirt $17.95


Welcome Guest ( Log In | Register )

 Forum Rules Rules
 
Reply to this topicStart new topic
> Openxdk Tutorial For Beginners
openxdkman
post Oct 4 2006, 08:44 AM
Post #1


X-S Genius
****

Group: Moderator
Posts: 790
Joined: 2-August 06
Member No.: 292548
Xbox Version: unk
360 version: unknown



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

EDIT:
Shortest procedure (warn me if it fails) :
http://minilgos.perso.sfr.fr/openxdk.zip
This is May 2007 version (1st version compatible with pbKit, natively).
Unzip it to its proper place (use pathes stored in zip archive).
Try to make hello.c (as described below)

Now, the normal, longer procedure :

Procedure for installing clean and legal development environment for XBOX (OpenXDK) on Windows :
(successfully tested on October 1st 2006)

(based on page http://www.openxdk.org/installing.html, but with some very important details missing there)

EDIT: openxdk.org may be expired.
Here is a mirror : http://openxdk.maturion.de/installing.html (Thx Maturion)

EDIT: Maturion uploaded 2007 version and useful stuff at sourceforge.net! Thx!

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 (take them all). That can take all the day. Be patient.
Repository in Belgium is very good. Will consume several gigabytes of disk space. Try to have 20Gb 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.

2) Download OpenXDK directly from CVS
Start the cygwin icon to start a unix session and navigate :
cd ..
cd ..
cd usr
cd home
You are now in /usr/home (c:\cygwin\usr\home for Windows)
You may download last versions of file right here (that will overwrite old versions) but personally I rather like to create another directory and download changes there so I can compare files, make backups, etc...
I had trouble to find what command is working with CVS client (included in cygwin), there is a serious lack of samples in CVS documentation... Here they are :
"cvs -d:pserver:anonymous@openxdk.cvs.sourceforge.net:/cvsroot/openxdk login"
I think you need to do this one only once in your life. It creates a .cvspass file in /home/~yourname that allows later calls to reuse the login parameter you just used now (anonymous connection)
Each time you want to download source do this one :
"cvs -d:pserver:anonymous@openxdk.cvs.sourceforge.net:/cvsroot/openxdk
export -r HEAD OpenXDK"
Other interesting stuff to download (sdldoom requires a .wad in .xbe directory):
"cvs -d:pserver:anonymous@openxdk.cvs.sourceforge.net:/cvsroot/openxdk
export -r HEAD Doom"
"cvs -d:pserver:anonymous@openxdk.cvs.sourceforge.net:/cvsroot/openxdk
export -r HEAD Samples"
If you want just to browse them and see differences between file versions and comments, use this url:
"http://openxdk.cvs.sourceforge.net/openxdk/"

3) Autogenerate makefiles and compile libraries
As said in "installing" openxdk.org page, there are commands to do in order to produce OpenXDK libraries.
cd /usr/home/openxdk
./autogen.sh
./configure --prefix=/usr/local/openxdk
make all install
That will create a new OpenXDK directory in /usr/local. That's the one you will use for your own compilations.
OpenXDK libraries should be in /usr/local/openxdk/lib now (lib*.a files). Takes a few minutes I think.

4) Create a sample program
Return home! (just close cygwin window and reopen one)
For Windows that place is c:\cygwin\home\<yourname>

- Create file "hello.c" (you can use windows explorer and click New->Text file in menu):

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" :
EDIT: 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!)

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

This post has been edited by openxdkman: Mar 28 2009, 10:40 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Sirmatto
post Oct 4 2006, 02:09 PM
Post #2


X-S X-perience
**

Group: Members
Posts: 412
Joined: 10-December 04
From: Puyallup, WA
Member No.: 174948
Xbox Version: v1.0
360 version: v3.0 (falcon)



Awesome news!

Is there a chance OpenXDK will ever support MinGW+MSYS instead of Cygwin?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
openxdkman
post Oct 4 2006, 02:43 PM
Post #3


X-S Genius
****

Group: Moderator
Posts: 790
Joined: 2-August 06
Member No.: 292548
Xbox Version: unk
360 version: unknown



It supports MingW already, I've heard. Xbox-linux also, I've heard. But I can't issue tutorials for these.
I don't know what is MSYS. Just give it a try. MingW related infos are available on openxdk.org, I think.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post





Reply to this topicStart new topic

 

Lo-Fi Version Time is now: 9th September 2010 - 08:17 AM