Mac <-> DC Programmer Thread

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
User avatar
I.M. Weasel
Iron Muskateer Weasel
Posts: 2780
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Fri Jan 04, 2002 4:45 am
Location: The city of the future, Los Braingeles
Has thanked: 1 time
Been thanked: 3 times
Contact:

Mac <-> DC Programmer Thread

Post by I.M. Weasel »

this is a sticky.

lets start simple.

________________

KOS - C functions Library for the Dreamcast
SH4 Toolchain/enviroment - The Dreamcast platform (i.e. Windows,mac,unix,dc :smile:)
Cross Compiling - Making a program for an OS not currently running
CygWin - A program that lets you use UNIX on PC (OS X has it already :P )
________________

How?

Know a little C.
Setup the SH4 cross compiling enviroment on your Mac.
Configure and Make the KOS library.
Write in C! with KOS functions/usage included.
Upload the compiled program to your dc ,either via cd or serial cable

________________
Programs

Stalin's Script - http://stalin.thegypsy.com/bscript.shtml a UNIX script that will setup the SH4 enviroment automatically (some variables Need to be changed.)

DC Serial Cable on Mac - macemu.com/~dreamcast/dc_apps.htm Developed by the Mac pack Team. Needs - A computer with old-school serial ports (modem or printer).
An Adapter (that i cant find on ebay).


_________________

Resources

What i've found.

*Small tutorial on getting everything ready on lunix http://www.atani-software.net/dcprog/

* A new adapter which has the 9 pin serial port that the serial cable uses, and connects to your mac via USB. Widely available on eBay. Pic Below.

Image

I dont think it will work with the DC_Serial on Mac package, because the package contains a program that speaks to the serial port. Although from that, the correct software may be included. If not,it can be located on VersionTracker, i bet.
Last edited by I.M. Weasel on Wed May 07, 2003 1:05 am, edited 2 times in total.
:arrow: http://tofuheavyindustries.com
Mac Dream Tool / Mac Dream Tool Services (released Sept. 2019)
Creator of Various awesome Video Games

"You don't have to be forgiven. Clint Eastwood taught us that."
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

There's no USB coders cable. I don't have a cable or a BBA, so I actually have to use a load of multisession CD-Rs. Ouch.
cypher35
DCEmu Newbie
DCEmu Newbie
Posts: 2
Joined: Wed May 28, 2003 5:26 pm
Location: Minnesota
Has thanked: 0
Been thanked: 0
Contact:

Cool

Post by cypher35 »

this section is very helpful, i've been looking at programming for dc with my mac for some time, but couldn't find any info anywhere. :D
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

So, how much have you guys got working so far, if anything?

If the USB serial adapter behaves anything like it does on a PC, it should show up as a standard serial port. Of course, that's really doubtful, since MacOS X probably doesn't support any kind of serial ports anyway.

I don't know how different MacOS X is to a standard Unix system, but once you've got the serial adapter and plugged it in, it should show up somewhere in the /dev tree. If it shows up there, and behaves basically the same as a serial port does on any other Unix system (which it can probably be made to), you should just be able to use the Unix versions of the DC->PC comm software, compile it under OSX, and it should work. Probably.

As for the software side... I think the first step would have to be getting Binutils set up and working for an OSX host and a SH-4 target. GCC's the native compiler for OSX, isn't it? So I assume that it would basically compile under OSX, right?

Simplest way to test it would be to download the source code for binutils, and do something like this at a terminal

Code: Select all

tar -xzvf binutils-version.tar.gz
mkdir binutils-build
cd binutils-build
../binutils-version/configure
make
That should (theoretically) build an OSX targetted version of binutils (but not install it). If that works, then there's a good chance compiling for an SH-4 target would work too. Basically, that's the same as above, but you need to specify a few additional paramaters to the configure script:

Code: Select all

tar -xzvf binutils-version.tar.gz
mkdir binutils-build
cd binutils-build
../binutils-version/configure --prefix=/usr/local/dc/sh-elf --target=sh-elf
make all install
That should build SH-4 targetted binutils, and install them to /usr/local/dc/sh-elf. Presumably, that would be different on a Mac. Of course, under a standard Unix system, that'll only work if you're logged in as the root user, since you need write permissions to /usr, and standard users don't have that. You could install it to your own home directory, like this:

Code: Select all

tar -xzvf binutils-version.tar.gz
mkdir binutils-build
cd binutils-build
../binutils-version/configure --prefix=~/dc-build/sh-elf --target=sh-elf
make all install
jaredfogle
DCEmu Turkey Baster
DCEmu Turkey Baster
Posts: 2663
Joined: Tue Feb 26, 2002 8:34 pm
Has thanked: 0
Been thanked: 0

Post by jaredfogle »

Yes, a USB2serial adapter would show up in /dev.

Standard users can just use sudo to alter /usr (anyone messing with DC programming would know what root is and how to enable it).
Where's toastman? I'm bored.
Renoberator
DCEmu Newbie
DCEmu Newbie
Posts: 1
Joined: Thu May 29, 2003 2:43 pm
Has thanked: 0
Been thanked: 0

Mac OS X build environment working

Post by Renoberator »

I managed to build binutils and gcc to target SH4 & ARM in Mac OS X.

I used Stalin's script found at http://stalin.thegypsy.com/bscript.shtml (from the links in the above posts). I used version 0.3.

I don't think I have a working C++ compiler yet since there were some errors with that build portion, but the C compiler works. I tested this by using KOS 1.1.9 (binaries, haven't tried building KOS yet). I built a couple of the samples and copied the binaries over to my linux box which has the dc coders cable & dc-tool set up (it's my current dc dev environment until i get all the mac stuff worked out). from there i was able to send the executables to the dc.

Here's what I did to get this stuff to work (using Terminal and tcsh):

Create a directory where you want to put all this stuff. As an example I'll use /usr/local/dreamcast.

download stalin's script and put it in /usr/local/dreamcast. I called it "build_script".

edit build_script w/ your favorite text editor. change the stuff that you want to in it. i only had to change the prefix setting. change that to the dir you want everything to be based from -- /usr/local/dreamcast

save it.

make it executable:

Code: Select all

chmod +x build_script
download all the source tars:

Code: Select all

./build_script download
extract all the tars:

Code: Select all

./build_script extract
Now, on Jaguar (I'm on 10.2.6) I had to modify one of the source files in binutils. that file is binutils-2.11.2/libiberty/strerror.c ... this mod should work if you're using binutils 2.11.2. should be around line 468.

original line looks like this:
extern int sys_nerr;

change it to:
extern __const int sys_nerr;

go back out to your base dir (/usr/local/dreamcast).
from there you can do:

Code: Select all

./build_script build_sh4
take a nap or something while you wait. unless you hit errors this could take awhile to complete.

when that's done you should have the binutils targetting sh4, gcc targetting sh4 and newlib built for sh4. if you get a working C++ compiler that's another bonus.

next:

Code: Select all

./build_script build_arm
same thing as build_sh4. it will take a bit and in the end you'll get everything targeted for arm.

One problem I ran into when doing sh4, but didn't with arm -- for some reason once the binutils built even though the dir was on the PATH make couldn't find them, so the gcc build complained about missing sh-elf-ar. all i had to do was close the Terminal window and open a new one and it worked. i tried rehash but that didn't seem to cut it, but for some reason restarting the terminal did. hope you don't hit the same problem, I really don't know why it happened.

KOS is another story. Get the binaries from sourceforge.net. I'll put the details for that in another message.

Hope this helps!
User avatar
I.M. Weasel
Iron Muskateer Weasel
Posts: 2780
Joined: Fri Jan 04, 2002 4:45 am
Location: The city of the future, Los Braingeles
Has thanked: 1 time
Been thanked: 3 times
Contact:

Post by I.M. Weasel »

Reno wrote: One problem I ran into when doing sh4, but didn't with arm -- for some reason once the binutils built even though the dir was on the PATH make couldn't find them, so the gcc build complained about missing sh-elf-ar. all i had to do was close the Terminal window and open a new one and it worked. i tried rehash but that didn't seem to cut it, but for some reason restarting the terminal did. hope you don't hit the same problem, I really don't know why it happened.
Could you elaborate a bit more on what you did? closed the active window it was built in,did you do a rebuld in the new window?
:arrow: http://tofuheavyindustries.com
Mac Dream Tool / Mac Dream Tool Services (released Sept. 2019)
Creator of Various awesome Video Games

"You don't have to be forgiven. Clint Eastwood taught us that."
User avatar
I.M. Weasel
Iron Muskateer Weasel
Posts: 2780
Joined: Fri Jan 04, 2002 4:45 am
Location: The city of the future, Los Braingeles
Has thanked: 1 time
Been thanked: 3 times
Contact:

Post by I.M. Weasel »

BlackAura wrote:
As for the software side... I think the first step would have to be getting Binutils set up and working for an OSX host and a SH-4 target. GCC's the native compiler for OSX, isn't it? So I assume that it would basically compile under OSX, right?

Simplest way to test it would be to download the source code for binutils, and do something like this at a terminal

Code: Select all

tar -xzvf binutils-version.tar.gz
mkdir binutils-build
cd binutils-build
../binutils-version/configure
make
That should (theoretically) build an OSX targetted version of binutils (but not install it). If that works, then there's a good chance compiling for an SH-4 target would work too. Basically, that's the same as above, but you need to specify a few additional paramaters to the configure script:

Code: Select all

tar -xzvf binutils-version.tar.gz
mkdir binutils-build
cd binutils-build
../binutils-version/configure --prefix=/usr/local/dc/sh-elf --target=sh-elf
make all install
That should build SH-4 targetted binutils, and install them to /usr/local/dc/sh-elf. Presumably, that would be different on a Mac. Of course, under a standard Unix system, that'll only work if you're logged in as the root user, since you need write permissions to /usr, and standard users don't have that. You could install it to your own home directory, like this:

Code: Select all

tar -xzvf binutils-version.tar.gz
mkdir binutils-build
cd binutils-build
../binutils-version/configure --prefix=~/dc-build/sh-elf --target=sh-elf
make all install
I tried to that way,but it states thats

Code: Select all

[Terminals-Computer:~/binutils-build] termshort% ../binutils-version/configure  
../binutils-version/configure: Command not found.


so it doesnt function at all. I am have been using stalins script but have not gotten it working yet...
:arrow: http://tofuheavyindustries.com
Mac Dream Tool / Mac Dream Tool Services (released Sept. 2019)
Creator of Various awesome Video Games

"You don't have to be forgiven. Clint Eastwood taught us that."
User avatar
I.M. Weasel
Iron Muskateer Weasel
Posts: 2780
Joined: Fri Jan 04, 2002 4:45 am
Location: The city of the future, Los Braingeles
Has thanked: 1 time
Been thanked: 3 times
Contact:

Post by I.M. Weasel »

Update: I spent 8 hours yesterday night setting up the sh4 cross compiler while being walked through by BlackAura. I think I know what I did, I worked from 11pm to 9am, and by the end it was becoming quite a blur. I must run a few more testing, i.e. compiling a dc program to see if it all works. If so I'll write it up into a tutorial. And if so,all thats left is the hardware side. :mrgreen: :mrgreen:
:arrow: http://tofuheavyindustries.com
Mac Dream Tool / Mac Dream Tool Services (released Sept. 2019)
Creator of Various awesome Video Games

"You don't have to be forgiven. Clint Eastwood taught us that."
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

So, KOS finished compiling without any errors this time?

I remember pretty much what we did, so I'll have a look at the tutorial when you're done with it, and make sure you've not got anything too wrong.

And, if I'm not mistaken, that's ten hours, not eight. :D
erise
Insane DCEmu
Insane DCEmu
Posts: 143
Joined: Wed Oct 17, 2001 7:44 pm
Has thanked: 0
Been thanked: 0

Post by erise »

Good job I.M. Weasel and BlackAura! I'd love to be able to write Dreamcast games and modify existing homebrew games that have the sources available. :mrgreen:
User avatar
I.M. Weasel
Iron Muskateer Weasel
Posts: 2780
Joined: Fri Jan 04, 2002 4:45 am
Location: The city of the future, Los Braingeles
Has thanked: 1 time
Been thanked: 3 times
Contact:

Post by I.M. Weasel »

i know it was around 10 hours. felt like a time warp with all that compilng.I saved all the terminal windows as text files and our IM convo.so Im gonna take the tutorial from there. I have a few small questions to ask you when i get back from work.(blackaura)
:arrow: http://tofuheavyindustries.com
Mac Dream Tool / Mac Dream Tool Services (released Sept. 2019)
Creator of Various awesome Video Games

"You don't have to be forgiven. Clint Eastwood taught us that."
hikikomori
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 33
Joined: Thu May 22, 2003 3:48 pm
Has thanked: 0
Been thanked: 0

Post by hikikomori »

Renoberator, actually you're my hero! the build worked perfect, it even didn't have the problem that made you to restart the terminal! I think c++ will work fine also :D


Now to KOS!

Did you do something special or just followed the included included instructions modifiying the paths on environ-dc.tcsh?


thanks!


hkkm
hikikomori
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 33
Joined: Thu May 22, 2003 3:48 pm
Has thanked: 0
Been thanked: 0

Post by hikikomori »

Renoberator, I've posted your instructions on KOS dev list to share with others.

Also from the list, Christian Groessler posted this message:
Hi,

for those who don't want to compile a MacOS-X hosted toolchain by
themselves, I've put up a precompiled one some time ago.

It's on

ftp://ftp.aladdin.de/pub/people/chris/d ... -toolchain

Still gcc 3.0.4...

regards,
chris
(it is better to use a ftp app such as transmit)

wich I think is a nice solution. it is also perfect for people with pretty limited disk space to make the builds!



cheers!
hikikomori
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 33
Joined: Thu May 22, 2003 3:48 pm
Has thanked: 0
Been thanked: 0

Post by hikikomori »

I.M. Weasel wrote:glad to hear someones chiming in on this issue
yeah
ToeJam wrote:Apparently it's an anonymous login type thing? I'm downloading them now with Transmit. (just copy the address, and then in transmit hit Edit:Paste, and connect/download)

that's OK, alternatively I've found you can use also these direct links:

ftp://ftp.aladdin.de/pub/people/chris/d ... .4.tar.bz2
ftp://ftp.aladdin.de/pub/people/chris/d ... .4.tar.bz2


hkkm
hikikomori
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 33
Joined: Thu May 22, 2003 3:48 pm
Has thanked: 0
Been thanked: 0

Post by hikikomori »

ToeJam wrote: Well duh, or you could browse the folder through your web browser or any other number of tools, I just mentioned one of many ways to the files that work oh so lovely (actually I have to try compiling some dc stuff).
sure, I just wanted to bring the fastest pointer :(

well, I'm already trying to buids KOS 1.2.0 but get this error:

Code: Select all

make -C utils
make -C genromfs
cc -O2 -Wall    -c -o genromfs.o genromfs.c
genromfs.c:80: header file 'sys/sysmacros.h' not found
cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
make[2]: *** [genromfs.o] Error 1
make[1]: *** [all] Error 2
make: *** [build-utils] Error 2
I've found the conflicting code, is this one:

Code: Select all

#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#	include <sys/sysmacros.h>
#endif
I did make a search on the entire HS and sysmacros.h isn't there.
Is anybody having the same problem?


cheers
hkkm
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

MacOS is a kind of BSD, as are FreeBSD and NetBSD. Those lines are supposed to include that header file, which isn't found on BSD systems, only if the system is not BSD. I had the same trouble when I was helping I. M. Weasel with this. Basically, you can either comment it out (bad idea) or add another !defined() thingy to it. I can't remember what that definition should be.
hikikomori
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 33
Joined: Thu May 22, 2003 3:48 pm
Has thanked: 0
Been thanked: 0

Post by hikikomori »

BlackAura wrote:MacOS is a kind of BSD, as are FreeBSD and NetBSD. Those lines are supposed to include that header file, which isn't found on BSD systems, only if the system is not BSD. I had the same trouble when I was helping I. M. Weasel with this. Basically, you can either comment it out (bad idea) or add another !defined() thingy to it. I can't remember what that definition should be.
thanks BA, I'm working on it and I have found an inelegant workaround, I have this:

Code: Select all

#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#      include <sys/types.h>
#endif
so that problem has gone by now, but I have a new one (how not)... vqenc.c asks for malloc.h do you know how to solve this? :cry2:

thanks!

hkkm
User avatar
I.M. Weasel
Iron Muskateer Weasel
Posts: 2780
Joined: Fri Jan 04, 2002 4:45 am
Location: The city of the future, Los Braingeles
Has thanked: 1 time
Been thanked: 3 times
Contact:

Post by I.M. Weasel »

blackaura told me originally to delete the references to all malloc.h defines
:arrow: http://tofuheavyindustries.com
Mac Dream Tool / Mac Dream Tool Services (released Sept. 2019)
Creator of Various awesome Video Games

"You don't have to be forgiven. Clint Eastwood taught us that."
hikikomori
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 33
Joined: Thu May 22, 2003 3:48 pm
Has thanked: 0
Been thanked: 0

Post by hikikomori »

I.M. Weasel wrote:blackaura told me originally to delete the references to all malloc.h defines
thanks! I'm going to do it now, I hope there aren't many files....

[edit] 62 #include <malloc.h> have been commented (nice to have project builder available)... now the hellz compiler doesn't find jpeglib.h!

hkkm
Post Reply