I was looking at loads of arcade stuff today, really want one of those swanky Atomiswave arcade setups.. in one of those lovely candy cabs *dreams*, anyhoo I decided for the moment I can't be arsed with the ZX spectrum stuff. I'll go back to that once I can find a program that'll let my generate the bitmaps I need to get my top secret project working. The speccy is a very simple beast, essentially a Z80, some memory, a keyboard and an apparently very difficult to use buzzer. Right now I want something more, but nothing too shiny and new as there will be too much hardware to work out.. so I settled on the Gameboy Advance, it has some actual console-style hardware and has a pretty big coding community. Getting assemblers for console and micros is hard enough for Windows users, getting them for Linux is a complete pain in the arse! There seems to be quite a bit out there for the GBA even for Linux. I was going to get myself a GBA and Flashkit off 'ye olde ebay but I can't really afford it right now. These days 50 quid will get you a GBA and all the dev hardware you need though! I like emulators for dev'ing though, a lot less fiddly than the real thing in most cases, I do intend to get a real test platform sometime though… anyone want to give me a job?”^^
Googling around I found a lot of stuff. Most of it either outdated or totally bloody useless. Something I came across a lot was Devkit Advance which is a GNU based toolchain with some sort of GBA link libraries. Devkit Advance hasn't moved since 2003 by the look of it, and I'm always wary of running abandoned software. I don't like the feeling that I'll get attached to it, write a big bunch of stuff around it, and then find out a little tiny thing doesn't work that totally screws up my project and no one will fix it.. I go for Supported, Maintained, and most importantly documented! Another problem with old software and Linux is that a lot of the time libc changes will break the shipped binaries and newer GCC versions will break the source. I've done a few GCC fixes in my time, namely for the Wonderswan emulators that have long since been left for dead, not my idea of spending the weekend however. But I digress, so the from Devkit Advance I found out two things, one; people use GNU based toolchains to do gba stuff, two; there are some mature/featured libraries out there so hopefully there'll be less deadends than with the speccy. Looking around I found the Devkit Pro series of toolchains+libraries, these guys have done them for not only the gba but also the ds, psp and so forth so it's looking pretty good! I decided to use the VisualBoyAdvance emulator as it's in Debian and has debugging support, very handy!
The Devkit pro chappies supply the Devkit ARM flavour for ARM based machines, gba and gp* consoles. They seem to want to hide the Linux releases away and there doesn't seem to be a link from their main site.. their sourceforge project listing can be found here. Basically here you need the latest Devkit ARM release .tar.bz, the libgba one and the gba-examples one. You should probably make a dir called gbadev, extract the devkit arm package there and it should be contained in it's own directory, for the libgba and gba-examples packages make libgba and gbaexamples directories first, they really do need to be kept away from the Devkit ARM tree for the sake of upgrading later. Now you should be able to build the gba-examples. A bit like this;
cd /home/daniel/gbadev/gbaexamples export DEVKITARM=/home/daniel/gbadev/devkitARM/ export DEVKITPRO=/home/daniel/gbadev/ make
It might be useful to make a little script to set DEVKITARM and DEVKITPRO or put them somewhere so they get exported on login. If all goes well you should be able to browse around in the directories inside gbaexamples and find some .gba roms ready to stick into visual boy! That sounds a little bit rude, if you happen to know someone called visual boy don't stick them into him, I mean the emulator. Anyhow, I loaded the SimpleBGScroll example into old visualboy..
Yay!
Very impressive.. To cut a long story short the only example that really worked with visualboy was PCXView which you can see below.
Visualboy doesn't seem all that happy when you connect a debugger to it's gdb port either.
I've decided I don't need the debugger so much at this point, I'm going to be working in C to start with anyhow. Next task is my old favourite, getting some shit on the screen!
Tell visualboy to load and wait, then connect the debugger, don't tell it to run. Debugger is so unstable it's next to useless however.
Hmm I think I know why half the frick'in examples and tutorials for GBA stuff out there doesn't work.. I've got a feeling they rely on the fact that the startup code linked in does some interrupt initialisation stuff, maybe a leftover from Devkit Advance? Anyways, this doesn't seem to happen in any of the examples in the gbaexamples package apart from the PCXView… so I looked around in the PCXView's makefile to see if there was something that wasn't getting linked .. oh the PCXView is compiled -O0 .. everything else -O3 .. nope something else .. I gutted out the PCXViewer and added little bit of demo code from somewhere else. Still no luck, ah! but the PCXViewer uses mode 4.. and this code is writing to the video memory as it would be in mode 3.. small change the screen initialisation in the gutted PCXView.. ta da!
All the problems stem from broken linker scripts in the latest Devkit pro release gah! Fixed 'um and all the examples work now. Damn!
I gave in and Ebay'ed a GBA and a Flashcart kit today, hopefully they'll get here soon.. and hopefully the Flashcart with work with the Linux software available, it seems to be a re-labled EZ-Flash as it's advertised to have the RTC and support EEPROM saves.. I hope it does, I really want to play pokemon!, not really. The GBA is coming with Dukenukem though! yay!
Not much coding today, I managed to slash my hand with a blunt bread knife.. mental. Anyhoo, I've decided to port oswan the Wonderswan emulator to the GBA! shouldn't be that much work.. I think the CPU emulation will compile as is, and then I'll initially use parts of the SDL port to write to the GBA screen as a bitmap, then move on to using the GBA's hardware to speed things up. Just looking for the oswan source again so I can see how much of this is going to actually compile..
Hmm after a few hours of work the Nec V30 core from oswan is almost building .. the core itself builds, but it relies on a few bits from the rest of the oswan source that aren't 100% there. The main problem seems to be the weird types that have been defined all over the place, and that malloc doesn't work with the devkitarm stuff somewhere? going to have to look it up, I probably need to replace the malloc-related functions in the memory handler with a little less civilised code, the GBA isn't a PC after all, that implements the memory handler within the GBA's 256k scratch ram. I would finish it off tonight and get the core running, but the code is a serious mess, for example it's all pure C but has .cpp for extensions… and the makefile then tries to compile the stuff with g++… and I need to think about endians and alignments before I can go about fixing the malloc stuff. In other words, I'm toying with some speccy ideas tonight instead.
I wanted a rom dumper… I want to extract the 'firmware' or loader from my flash cart and work out how it ticks… Upload this little proggy to the GBA over a xboo cable and it'll start dumping out the contents of the gamepak. People seem to want SRAM readers so they can get their saves.. might be able to do that. ^^
Nailed a few bugs out, and started writing everything to a file… actually generating perfect and playable dumps now! Had some problems with pointers when I moved from reading a byte each iteration to 4 bytes but I got it worked out. ^^ I've dumped 32mbit from the start of my flashcart to see if I can figure out how it works .. but it crashes in both VBA and no$cashgba so it looks like I'm going to have to take it apart with a disassembler and maybe mappy vm.