<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.28.1">
</HEAD>
<BODY>
Hi,<BR>
<BR>
I've cross-compiled Gambit Scheme using devkitPPC for a Wii.<BR>
I have used the example Wii 'template' program as the basis for my initial efforts.<BR>
<BR>
My goal is to attempt to produce a Wii executable that has SLIME/EMACS capability and also has all of the good libraries linked in with FFI wrappers eg GRRLIB etc. This means that I should be able to run the Gambit version from the Homebrew Browser and then connect and develop remotely, ultimately using 'gsc' to produce the final stand-a-lone executable once the hacking is over.<BR>
<BR>
I've followed the efforts of James Long and managed to incorporate Gambit into some of my iPhone applications (none for sale yet!) so I know that it does cross-compile and does work, but for now, I am having great difficulties in getting *anything* except register dumps when I call  a function defined with (c-define).<BR>
<BR>
I remember having similar issues on the iPhone but it was because on James' site, he hadn't fully described what he-d done but a few PM-s got that sorted just fine. Thanks James!<BR>
<BR>
First of all, here is how I built the gsc/gsi tools with devkitPPC,<BR>
<BR>
./configure --prefix=/usr/local/Gambit-C/wii --enable-single-host=yes --host=powerpc-eabi<BR>
<BR>
That produces for me /usr/local/Gambit-C/wii/lib/libgambc.a and presumably it is PPC correct with respect to architecture.<BR>
I then wrote a small test file called scode.scm in the same folder as the template.c program:<BR>
<BR>
(c-define (wii_blast ) () void "wii_blast" "extern"<BR>
          ;; stub<BR>
          42)<BR>
<BR>
and use gsc -link scode.scm to produce the scode.c and scode_.c files which the Makefile picks up and uses.<BR>
<BR>
In the template.c file I declare it as...<BR>
<BR>
extern void wii_blast();<BR>
<BR>
Every time I call it I get a register dump and I don't know why! I have reduced the function to void/void so as to remove any possibilities of stack corruption caused by incorrect push/pops due to a misinterpreted function signature etc, I cut my teeth 25 years ago with assembler and you never forget the basics! LOL.<BR>
<BR>
I have included the full template,c at the end of this mail along with the modified makefile incase anybody could tell me what is wrong. I am assuming that the build of 'libgambc.a' is fine because my program does call ___setup() and ___close() with no problems but they would appear to be native C functions and I am assuming that the wii_blast() function is maybe a byte-code thing happening or is it truly C code at this time? That is my ignorance of the internals of GambitC showing now.<BR>
<BR>
My next step is to try to produce a link map and a disassembly of the wii_blast function and then code a function foo:<BR>
<BR>
void foo(void)<BR>
{<BR>
}<BR>
<BR>
and compare the pre-call and post-call operations to see what is going on... in the  meantime, if anybody cares to point out what I may/am doing wrong I would be most grateful as I really want to be able to build an interactive Wii development toolkit based on scheme, that wraps GRRLIB and libogc in the first instance.<BR>
<BR>
My *real* problem started from that fact that I wanted to be able to use the 'gsc -exe' route to build a complete Wii application in one pass i.e. have a main SCM file that pulls in everything else and then the --cc-options and --ld-options flags would do the rest.... the problem I had is that I couldn't work out how to tell the native gsc to use the target compilers in /opt/devkitpro/devkitPPC/bin !! Is it just setting 'CC' or GAMBC_CC_COMMAND etc etc?<BR>
<BR>
Either way, so far I am pleased with my progress but I am a little stuck right now! Marc Feely, if you are out there dude, got any tips? <IMG SRC="cid:1272022510.24626.6.camel@dev-objitsu" ALIGN="middle" ALT=":)" BORDER="0"><BR>
<BR>
Thanks,<BR>
Sean Charles.<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
</BODY>
</HTML>