Neil Stevens wrote:
Has anyone put any thought into what it would take to get SDL running on a
Sega Dreamcast? Or better, has anyone tried to get SDL running in the
Dreamcast WinCE?
I’m not a Dreamcast developer; I’m just curious if I could become one,
with my existing knowlege and experience with SDL. 
A friend and I did some research into this tonight. Here’s what we
found:
a) It’s entirely possible to hack up the (binary only) Linux boot image
that was linked to on Slashdot to supply your own ramdisk. After a bit
of gzip header searching and dd’ing, we managed to produce and boot a CD
image with a modified ramdisk. Once you’ve managed to separate the
kernel from the ramdisk image, you can just gunzip the ramdisk, mount it
as loopback, and modify it to your liking.
This should become easier once the developer releases the Dreamcast
Linux kernel source. (I believe he has to at some point, due to the
GPL.)
b) The Dreamcast Linux kernel is an SH4 2.4.0test8 kernel with a PowerVR
framebuffer driver. The SH3 is commonly used in handhelds, and the SH4
is a step up. The one in the Dreamcast is a 200MHz, 32-bit processor
with both big- and little-endian modes. Memory is only 24 megs, which
must hold the ramdisk and everything else. This will be less of a
problem once the Dreamcast CD drive is supported by the Linux kernel.
Input is accomplished with a keyboard adapter (sold separately).
c) gcc supports the SH4 (obviously, with the kernel working). It’s a
very immature backend, but it seems to be mostly functional. To get the
Dreamcast to execute arbitrary code, you’d compile and link the code
into an ELF file with the entry point at the very beginning and a
particular base address that I can’t remember right now (there are
linker options for these), objcopy it into a raw binary image, use an
open source utility (scramble.c) to scramble the image (since the
Dreamcast uses scatter-loading to obfuscate its binaries), name the file
1ST_READ.BIN, make an ISO image with this one file, append a 32K
bootloader (IP.BIN), and burn a CD. There are some details I’ve omitted;
this stuff is well documented if you know where to look. I’ll try to
gather some links.
d) A significant portion of the Dreamcast has been reverse engineered or
discovered from OEM specs. Audio, 2D video, the controllers, CD-ROM, and
VMU access are documented. Most of this is implemented in libdream, an
open source library. A number of people have already written simple and
not-so-simple games with this. Someone has even created an S3M music
player with a graphical interface. The problem with libdream is that
it’s not meant to work with an operating system; it’s designed for
building raw, to-the-metal binaries. (a hacker’s dream, but no good for
porting)
This leads me to believe that, minus the audio and some input device
code, SDL could just be recompiled with a cross compiler for Dreamcast
fbdev support. Once it was working, we could bring in libdream to
provide full controller and audio support. There’s no reason that the
Dreamcast couldn’t become a fully supported SDL target. It would be
great if we could get some free Dreamcast game development going. We’re
dealing with a cheap, compact 200MHz RISC box with 24 megs of RAM, a
CD-ROM that reads gigabyte CD’s, and high-performance dedicated video
hardware. There’s potential here.
I couldn’t resist having a bit of fun while I was logged into the
Dreamcast:
sh-1.04$ cat /dev/urandom > /dev/fb0
sh-1.04$ cat /dev/urandom > /dev/mem
(after which the kernel raised hell and I started singing “I crashed a
dreamcast! I crashed a dreamcast!”)
-John–
Underfull \account (badness 10000) has occurred while \spend is active
John R. Hall - Student, Georgia Tech - Contractor, Loki Software