## I did it! -OR- The 3DO homebrewer's thread

Homebrew and Mods (For Software & Hardware)
Mobius

### I did it! -OR- The 3DO homebrewer's thread

I finally did it! After spending way too much time re-learning assembly, learning the GNU assembler and linking tools and their quirks, and pulling my hair out while googling random error messages, I finally managed to compile my first 3DO program!

Of course, it's nothing very special. In fact, you've all seen it before. It's the "sonic_test" demo from http://thdo-homebrew.narod.ru. BUT it was an important first step, and one that opens the doors to more interesting work.

So, my intention with this thread is to document my work and share technical information, as well as create a home here at 3DO Zone for technical homebrew discussion. I'll keep this first post updated with new information as I learn it.

The Basics
• The CPU is a 32-bit ARM60 running in big-endian mode
• 3 MB of RAM starting at 0x0
• 1 MB of Video RAM starting at address 0x200000, directly accessible by CPU
• The frame buffer for the video mode that initializes when FreeDO boots starts at address 0x2c0000
• The above video mode is 320*240 at 16 bits (2 bytes) per pixel, so it uses a total of 153600 bytes of memory
There's lots more info out there, but this is all that I've played with so far. So, that means it's all that I really understand. As I explore and learn more, I'll add more to the list. Basically, I'm just documenting the stuff I've actually worked with!

Some Homebrew Resources
How To Get Started
1. Download and install Cygwin to do development from Windows... Cygwin is a Linux emulation layer for Windows. Essentially, it lets you run a Linux environment on top of your Windows filesystem. I recommend you choose to include Nano in your install. It's a simple, easy to use text editor.
2. Download and install GNUARM for your development environment (probably Cygwin)... This is a set of the GNU GCC tools compiled for ARM development. Install GNUARM with Big-Endian support and allow it to add itself to your path.
3. Once GNUARM is installed, copy crt0.o and libc.a from C:\Program Files\GNUARM\arm-elf\lib\be to C:\Program Files\GNUARM\arm-elf\lib. If you don't do this, you'll get compilation errors!
4. If you want to start digging deeper, get the 3DO SDK. Be sure to read the README, as it has info on what tools are included and how to read the HFV files on a Windows system.
Guides:
Last edited by Mobius on Sat Mar 10, 2007 7:42 pm, edited 3 times in total.

T2KFreeker
3DO ZERO USER
Posts: 1241
Joined: Wed Feb 07, 2007 6:41 am
Location: Parts Unknown
Well, it is nice to see that these things actually still inspire people to do this kind of work. Over at JSII, there is a "Playground" for learning these kinds of things where programmers try and teach other people that are interrested to code for the Jaguar. Perhaps something like this would be ideal here? Especially if we are all serious about coding and getting games really going for the 3DO.
This is a stick up! Put all of your 3DO games in the bag and nobody gets hurt!

Trev
3DO ZONE MOD
Posts: 4033
Joined: Thu Jan 25, 2007 7:19 pm
Location: States
Contact:
Awesome! I really wish I had something to contribute to help you in your work. Rest assured though, your efforts are very much appreciated by 3DO laymen like myself. Again I say, awesome!

3DOKid
Posts: 4683
Joined: Sat Jan 13, 2007 4:21 pm
Location: Cambridgeshire, UK
Contact:

### Re: I did it! -OR- The 3DO homebrewer's thread

Mobius wrote:I finally did it! After spending way too much time re-learning assembly, learning the GNU assembler and linking tools and their quirks, and pulling my hair out while googling random error messages, I finally managed to compile my first 3DO program!

Of course, it's nothing very special. In fact, you've all seen it before. It's the "sonic_test" demo from http://thdo-homebrew.narod.ru. BUT it was an important first step, and one that opens the doors to more interesting work.

So, my intention with this thread is to document my work and share technical information, as well as create a home here at 3DO Zone for technical homebrew discussion. I'll keep this first post updated with new information as I learn it.

The Basics
• The CPU is a 32-bit ARM60 running in big-endian mode
• 3 MB of RAM starting at 0x0
• 1 MB of Video RAM starting at address 0x200000, directly accessible by CPU
• The frame buffer for the video mode that initializes at console boot starts at address 0x2c0000
There's lots more info out there, but this is all that I've played with so far. So, that means it's all that I really understand. As I explore and learn more, I'll add more to the list. Basically, I'm just documenting the stuff I've actually worked with!

Some Homebrew Resources
How To Get Started
1. Download and install Cygwin to do development from Windows... Cygwin is a Linux emulation layer for Windows. Essentially, it lets you run a Linux environment on top of your Windows filesystem. I recommend you choose to include Nano in your install. It's a simple, easy to use text editor.
2. Download and install GNUARM for your development environment (probably Cygwin)... This is a set of the GNU GCC tools compiled for ARM development. Install GNUARM with Big-Endian support and allow it to add itself to your path.
3. Once GNUARM is installed, copy crt0.o and libc.a from C:\Program Files\GNUARM\arm-elf\lib\be to C:\Program Files\GNUARM\arm-elf\lib. If you don't do this, you'll get compilation errors!
Coming soon: How to compile and run your first 3DO demo on FreeDO!
OMG.

I'm going to give this a go.

This demo runs on Freedo right?

3DO Kid.

zenkov
3DO ZERO USER
Posts: 68
Joined: Thu Jan 25, 2007 7:09 am
Contact:
Viva GNU

Mobius

### Re: I did it! -OR- The 3DO homebrewer's thread

3DOKid wrote: OMG.

I'm going to give this a go.

This demo runs on Freedo right?

3DO Kid.
Sure does. I'm working on writing my own basic demo. If I get that working in the next couple days, I'll write my "How to compile a demo" instructions on that. If not, I'll just stick with the sonic_test demo.

I'm writing it in assembly... Too bad my C skills are even more abysmal, or this would be a little easier.

Mobius
Just a quick update... I did get my demo working. It's very basic -- just outputting a bunch of colors to the screen -- but it runs, and it's purely code I wrote myself, so it's pretty satisfying.

I'll have a step-by-step on how to compile an assembly program for the 3DO within 24 hours.

3DOKid
Posts: 4683
Joined: Sat Jan 13, 2007 4:21 pm
Location: Cambridgeshire, UK
Contact:
and the only thing standing between this and running it on the 3DO proper is the encryption? Which that chap reckons is broken...?

Mobius
Well, there are a few things still in the way.

#1 is that FreeDO initializes video output as soon as it starts, but from what I understand, the physical consoles don't do that. So, that's some additional code that would have to be included.

#2 is to understand the disc layout. You can't just slap a binary on a CD and have the system run it. The 3DO expects a certain directory structure and file layout so that it knows what to do and what to run. It seems like this is partially documented, at least. I know the binary has to be called "LaunchMe," but there's a bit more to it. I can probably figure this part out by using the various tools that read the Opera filesystem.

#3 is, of course, the encryption issue.

Mobius
So you want to compile your own 3DO game*?

As I said above, I did manage to write my own little graphical demo that runs on FreeDO. I've decided that I'm going to save that for another day and walk through the compilation process using the sonic_test demo.

Here's the step-by-step:
1. Go through the "How to get started" section in the first post and make sure your tools are installed.
3. Unpack the file using WinRAR. You should be left with a sonic_test.3bn file and a directory called "source". Within the source directory is a file called "sonic_test.asm" and six .raw files. The .raw files are the individual frames that will make up our final animation.
4. Fire up cygwin and switch to the directory containing your source files. Open sonic_test.asm in Nano (you did install Nano, right?) and have a look around. What you're seeing is ARM assembly language. This is basically one step above programming in binary! Guess what? We get to edit this! But don't worry, I've done the dirty work for you...
5. Apparently, the demo was originally written for the official ARM development tools. Those cost money, so we're not using them. Instead, we're using free tools that behave slightly differently. So, the code has to be updated to work with our tools. Here's the final working code that I was able to compile:

Code: Select all

	.text
.global _start

_start:
mov r8,#0x6
l1:
ldr r5,=0x002ca100
.ltorg
mov r4,#0
l2:
mov r3,#0
l3:
ldr r2,[r0],#0x4
str r2,[r5,r3]
cmp r3,#0xe0
bne l3
cmp r4,#0x32
bne l2
mov r12,#0x24000
l4:
subs r12,r12,#0x1
bne l4
subs r8,r8,#0x1
beq _start
b l1

@Pos:
@.word	0x002ca100

Sprites:
.incbin	"./sonic1.raw"
.incbin	"./sonic2.raw"
.incbin	"./sonic3.raw"
.incbin	"./sonic4.raw"
.incbin	"./sonic5.raw"
.incbin	"./sonic6.raw"

.end
6. Take a minute to look over it and compare it to the original file. Edit the file to match the code above, character for character, then save it.
7. Congratulations, you just worked on assembly... Add it to your resume!
8. Now that the code is in a working form, we can go ahead and compile it. This will be a three step process, using three different tools. Start with arm-elf-as and run the following command:

Code: Select all

arm-elf-as -mcpu=arm60 -mbig-endian sonic_test.asm
This runs the GNU assembler called "as" and converts your source code to a binary object. That file is named a.out and will appear in the same directory you're working out of. The parameters specify that we're compiling for an ARM60 (the kind of processor the 3DO has) and that the byte order is big-endian. Don't worry about what that means for now.
9. Now that we've got a binary object file, we need to put the finishing touches on it and make it an executable. This is called "linking" and is done with arm-elf-ld. After you've run arm-elf-as, run this command:

Code: Select all

arm-elf-ld -EB -o sonic_test.elf a.out
This will output a file called sonic_test.elf and, again, we're specifying that this is being done for a big-endian processor.
10. At this point, we have code that would run on some processors, but not the 3DO's. For a binary file to run on the 3DO, it needs to be a pure binary executable, not one in the ELF format (which is the format arm-elf-ld outputs). To rectify this, we'll run our final step with a third tool, arm-elf-objcopy. This will strip out the extraneous information in the file and leave us with a pure binary file. After you've run arm-elf-ld, run this command:

Code: Select all

arm-elf-objcopy -O binary sonic_test.elf sonic_test.3bn
This outputs a raw binary version of sonic_test.elf and saves it as sonic_test.3bn.
11. Now it's time to test the fruit of our labors! Open up FreeDO and choose File-->Load Binary... Point it to your sonic_test.3bn (the one we made, not the one you originally downloaded with the source code!) and then click CPU-->Start.
12. The final step is to enjoy the animation! Assuming all went well, that is...
If you're playing along at home, feel free to ask questions!

*By game, I actually mean "Graphical demo in no way resembling a playable game

Windows Killer
3DO ZERO USER
Posts: 98
Joined: Wed Jan 24, 2007 12:33 pm
Location: Germany
Contact:
Mobius wrote:#2 is to understand the disc layout. You can't just slap a binary on a CD and have the system run it. The 3DO expects a certain directory structure and file layout so that it knows what to do and what to run. It seems like this is partially documented, at least. I know the binary has to be called "LaunchMe," but there's a bit more to it. I can probably figure this part out by using the various tools that read the Opera filesystem.
Just use the cd mastering tool that is included with the sdk.

The disc layout really isn't that complicated. When I started to play around with it, I was able to create a working disc just by using a hex editor. (after a few weeks of learning, of course)

For 3DO "M1", you need the System directory (same for every disc), a rom_tags file and the main executable which must be named LaunchMe. Using the sdk to master a disc is really the easiest way.

do you want me to add some tools on my "webpage" ?

That's great what you are doing for the 3DO. You must post your work on a website (as forums could be purged sometimes).

Mobius
Madroms wrote:do you want me to add some tools on my "webpage" ?

That's great what you are doing for the 3DO. You must post your work on a website (as forums could be purged sometimes).
If you have the SDK tools and whatever documentation came with them, I would greatly appreciate it if you added those!

Otherwise, WindowsKiller, can you PM me some contact info?

As far as a website goes, I will probably set up a small one when I have a little more to share.

Here is what I have:

3DO SDK (for Mac) with:
[ pf12tk13.hfv
pf13updt.hfv
pf25.hfv
tk13updat.hfv
Online Doc ]

(shared on IRC some years ago on a now dead channel/server).

I don't think I can put it on my free account but I can send it to you by ftp/irc/...

Mobius
Madroms wrote:Here is what I have:

3DO SDK (for Mac) with:
Oh yeah, Mac... That's pretty useless to me. I might be able to get some use out of the "3DO Libs & Headers" and "Online Doc" portions, though. How big are they? I could probably set up temporary FTP access to my webserver if it's not feasible to send by e-mail or AIM.

zenkov
3DO ZERO USER
Posts: 68
Joined: Thu Jan 25, 2007 7:09 am
Contact:
You can use Mac emu.

The complete dir is 100MB only.
OnLineDoc is 4.65MB

Mobius
Madroms wrote:The complete dir is 100MB only.
OnLineDoc is 4.65MB

Cheers

Mobius
Oh wow, this is an absolute goldmine of information. All this time, I thought there wasn't much 3DO homebrew because it wasn't well-documented. Really, it must be lack of interest. Maybe because people know the encryption would keep anyone from running homebrew programs on a home system? Who knows.

Anyway, I think I have a solid weekend's worth of reading ahead of me...

Edit: I've made the SDK available here: http://www.infinitydev.net/3DO/ and the link will be added to the first post.

Gir Draxa
3DO ZERO USER
Posts: 243
Joined: Sat Feb 10, 2007 8:34 pm
Location: USA (occasionally Thailand)
Contact:
Does anyone have an image reader & builder for 3DO for the PC? There are some but so far none that can decrypt all the frames of an ANIM, let alone make one.

Drax
CEO of The (in search of a home) CD-i & 3DO Collectives

Just slightly behind at being ahead of our time!

Mobius
Mobius wrote:Well, there are a few things still in the way.

#1 is that FreeDO initializes video output as soon as it starts, but from what I understand, the physical consoles don't do that. So, that's some additional code that would have to be included.

#2 is to understand the disc layout. You can't just slap a binary on a CD and have the system run it. The 3DO expects a certain directory structure and file layout so that it knows what to do and what to run. It seems like this is partially documented, at least. I know the binary has to be called "LaunchMe," but there's a bit more to it. I can probably figure this part out by using the various tools that read the Opera filesystem.

#3 is, of course, the encryption issue.
Well, #1 and #2 are covered in the SDK, so I guess that really does just leave us with the encryption problem...

Mobius
Ugh, I just spent hours getting Basilisk II (a Mac emulator) up and running so I could use more of the SDK. Of course it doesn't recognize the .hfv files! That would be too easy...

*grumble*

Edit: Got it! Creating a new HFV and copying the contents of the old ones to it seemed to work just fine.

I am happy you found some help on the SDK.
Enjoy it and make us some cool demos

Mobius
Well... I have a fully configured 3DO development workstation running under Basilisk II now. I got all the 3DO tools installed and built some of the example programs included in the SDK. But, I tried to run them in FreeDO and all I got was a blank screen.

I don't know if I did something wrong, or if it's just FreeDO not properly emulating the system.

Gir Draxa
3DO ZERO USER
Posts: 243
Joined: Sat Feb 10, 2007 8:34 pm
Location: USA (occasionally Thailand)
Contact:
Here's a link to a little home video of Mobius' first successful demo running on my testers station.

Bouncing Logo Demo

Drax
CEO of The (in search of a home) CD-i & 3DO Collectives

Just slightly behind at being ahead of our time!

Mobius
Gir Draxa wrote:Here's a link to a little home video of Mobius' first successful demo running on my testers station.

Bouncing Logo Demo

Drax

Gir Draxa
3DO ZERO USER
Posts: 243
Joined: Sat Feb 10, 2007 8:34 pm
Location: USA (occasionally Thailand)
Contact:
I guess this shoud be posted to.

3DO Bouncing logo demo version 2

Drax
CEO of The (in search of a home) CD-i & 3DO Collectives

Just slightly behind at being ahead of our time!

3DOKid
Posts: 4683
Joined: Sat Jan 13, 2007 4:21 pm
Location: Cambridgeshire, UK
Contact:
WOW. I liked.

...Needs scroll text mind and greetz Perhaps a little techno sound track and the Terminator 2 font but still - WOW!

Mobius
3DOKid wrote:WOW. I liked.

...Needs scroll text mind and greetz Perhaps a little techno sound track and the Terminator 2 font but still - WOW!
To be fair, the demo was written by 3DO and included in the SDK... But the fact you're seeing these videos means I've figured out how to set up a working development environment, how to compile a program, and also how to master a working CD image. All very important things!

And I spent four and a half hours on a plane today, where I managed to dedicate a couple hours to reading more of the development docs and understanding some graphical demos. As soon as I figure out how to create images in the right formats, I'll write my own little demo.

I have to say, I'm really enjoying learning all this, and I think the 3DO is an interesting platform to develop for. It has a very robust OS for an early 90s video game system. Maybe even a little ahead of its time?