Sanity Check | Testing Setup with Hello World

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
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Sat Feb 02, 2008 6:58 pm

I posted the following topic on gamedev.net and was referred here:

"I ran the build script found at http://cadcdev.svn.sourceforge.net/view ... /dc-chain/ in order to setup my tools, but I want to test them out. KOS comes with a few example programs, namely a hello world, but I don't know whether I have to burn a CD-R, buy a broadband calbe, or if I can run a quick test on an emulator. I don't have a Dreamcast anymore, but I'm going to buy a pair soon. I'd like to be able to test my setup now on an emulator, however, does anyone know how I would do that?


NOTE: I have setup GCC 3.4.6 for the ARM and SH4 platforms and have obtained the newest snapshots of KOS and KOS ports. The KOS documentation says that I should not use anything beyond 3.0.4, but I suspect the readme is outdated. I downloaded the version of GCC that the build script required, so I think I should be fine."

If anyone could help out, I'd appreciate it.
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY

Re: Sanity Check | Testing Setup with Hello World

Post by OneThirty8 » Sat Feb 02, 2008 9:26 pm

There are a few emulators. nullDC, lxdream, etc (there's a third, and I should know the name but I'm drawing a blank). You could try it in an emulator, but just because it works (or doesn't work) there doesn't mean the same is true for the real machine. If I remember correctly, "Hello World" won't do much for you (unless it uses the bios font drawing routines instead of printf). If you get the PNG example running you're probably good to go.

SDL needs to be patched if you're going to use it. The timer doesn't work right, the joystick needs a couple of small changes, and the sound code needs to be patched. There should be a patch for the joystick and sound stuff on the KOS sourceforge page. In the timer code, you'll just need to replace the stuff that refers to 'jiffies' with 'timer_ms_gettime_64();' to get it to work like you'd expect.

If you get a broadband adapter or coder's cable, you don't need to burn a CD each time you compile your program. You can use DCLoad/DCTool. Others can help you there--I burn discs. If you burn CDs, you can use a multisession disc. Download and burn a copy of DCHakker or Demomenu to use as a boot disc. It's fairly easy. You only need to burn whatever data files your program uses once per disc, and just keep replacing the executable each time you burn a new session.

That's about it. Your GCC should be good. That's about what everyone is using now--mine might be a couple of versions older, but 3.4.6 should work just fine.
User avatar
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Re: Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Sat Feb 02, 2008 11:42 pm

Thanks for the informative post. Testing the png example will suffice until a scrape up the money to buy a DC and broadband cable. I have a couple of additional question, however... Will I have to do anything special to set up code::blocks, or will I just have to tell it to use my newly built compilers? If it spits out the binaries, do I have to create a romdisk image in order for it to emulate properly or something like that?
anothrsignature, anothrsite, anothrguitarist
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY

Re: Sanity Check | Testing Setup with Hello World

Post by OneThirty8 » Sun Feb 03, 2008 12:59 am

I'm really not experienced with code::blocks or the emulators. I think that the emulators run iso images, but I'm not positive.

For Code::Blocks, fackue has created a package for Windows users that should have it all set up for you. If that doesn't meet your needs, there was a thread in this forum about getting it to work before fackue put together his package. The Search function should unearth it.

You are aware that a broadband adapter is probably going to set you back over $100, right? A coder's cable will probably be much cheaper. You can also develop without either, but you just won't be able to see anything printed to the console. I've been doing this for several years and have always just used a multi-session CD-R.
User avatar
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Re: Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Sun Feb 03, 2008 6:38 pm

I think I'm going to start over because I hadn't built KOS after all. I've been forgetting to mention that I'm not on Windows, and I would prefer to use Ubuntu 7.10 with 32-bit architecture for my development. Do you think you could help me get started? Here's my plan:

- Download Stalin's build script to build my compilers.
- Download the latest version of KOS and KOS-ports, which I think can be found [url = "http://cadcdev.svn.sourceforge.net/view ... athrev=556"]here[/url]*
- Edit my environ.sh appropriately
- Build KOS
- Manually edit code::blocks

I don't think I will have a problem getting code::blocks set up correctly, but it can be easy to make a mistake. Stalin's build script made everything easy; I just need to make sure that I am using the right version of KOS. Additionally, I've been having a few problems getting KOS to build. I started editing source code and downloading different versions of various files from the repository, thus I think I should just start over in order to avoid errors down the road. Before I start, can you point me to an up-to-date tutorial that describes how to get the latest version of KOS and set everything up? I've searched, but I can't seem to find anything that is current.

*Is this the latest version of KOS, and is it possible to import a working copy? If not, do you know where to get the latest stable version of KOS and KOS-ports?
anothrsignature, anothrsite, anothrguitarist
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY

Re: Sanity Check | Testing Setup with Hello World

Post by OneThirty8 » Sun Feb 03, 2008 8:43 pm

See http://cadcdev.sourceforge.net/softprj/kos/dcsetup.php for info on building everything.
See http://cadcdev.sourceforge.net/softprj/kos/svn.php for info on checking out KOS from the svn repository.

And the thread on code::blocks is viewtopic.php?f=29&t=74733&hilit=+code+blocks

To set up your environ.sh file, you should just need to edit it to reflect the paths for where you put everything on your system.
User avatar
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Re: Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Sun Feb 03, 2008 8:53 pm

Thank you. I can't wait to set everything up a little later on ... Calculus beckons right now, but I'll let you know how things went.
anothrsignature, anothrsite, anothrguitarist
User avatar
henzenmann
Insane DCEmu
Insane DCEmu
Posts: 186
Joined: Wed Jul 12, 2006 4:58 pm
Contact:

Re: Sanity Check | Testing Setup with Hello World

Post by henzenmann » Sun Feb 03, 2008 9:55 pm

Current instructions are here:
http://www.dreamcast-scene.com/index.ph ... xToolchain

A script for completely automatic setup is here:
http://www.elliptique.net/wiki/index.ph ... evelopment
User avatar
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Re: Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Sun Feb 03, 2008 9:58 pm

Thank you!

EDIT: That was easy... now all I have to do is set up code::blocks. I'll let you know how it goes.
anothrsignature, anothrsite, anothrguitarist
User avatar
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Re: Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Mon Feb 04, 2008 12:15 am

I'm having a little trouble setting up code::blocks. I followed the tutorial in the following thread and changed all of the directories to /home/john/kos-checkout/:
viewtopic.php?f=29&t=74733&hilit=+code+blocks

Yet for some reason, my build log prints the following (I have emphasized the problematic line):

"-------------- Build: Release in TestingKOS4 ---------------

Compiling: main.c
/home/john/Desktop/Programming/TestingKOS4/main.c: In function `main':
/home/john/Desktop/Programming/TestingKOS4/main.c:22: warning: implicit declaration of function `usleep'
Linking console executable: bin/Release/TestingKOS4
sh-elf-g++: C:cygwinusrlocaldckoskoskernelarchdreamcastkernelstartup.o: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 1 warnings"


I'm not sure why it is looking in C:cygwinusrlocal etcetera because I thought that I had changed the directories appropriately. If anyone could help out, I'd appreciate it.
anothrsignature, anothrsite, anothrguitarist
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY

Re: Sanity Check | Testing Setup with Hello World

Post by OneThirty8 » Mon Feb 04, 2008 1:06 am

It looks like you didn't change this part:
pnpbios wrote: Go to the second primary tab labled Linker. Add the folowing lines to the Other Options box.

Code: Select all

-g -fno-builtin -fno-strict-aliasing  -ml -m4-single-only -Wl,-Ttext=0x8c010000
-nostartfiles -nostdlib
C:\cygwin\usr\local\dc\kos\kos\kernel\arch\dreamcast\kernel\startup.o
-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group
User avatar
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Re: Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Mon Feb 04, 2008 1:24 am

That was it, but I could have sworn that I had changed the directory. All is working great so far. I'm pretty confident that KOS is set up correctly, but I still need to test it on an emulator. I should probably build the png test program as well. Thanks again for your help.
anothrsignature, anothrsite, anothrguitarist
User avatar
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Re: Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Mon Feb 04, 2008 3:04 am

Having a few problems. Firstly, when I tried the png example, the linker cannot find png.h or zlib.h, which is odd because I have told the linker to look in the appropriate directories. So I decided to try the other suggestion found on the following thread because I would like to use c++ as well:
viewtopic.php?f=29&t=74733&hilit=+code+blocks

I tried using the gnu_wrapper, but now I receive the following output when trying to build the program that worked earlier:

-------------- Build: Release in TestingKOS7 ---------------

Compiling: main.c
exec: 52: -Wall: not found
Process terminated with status 2 (0 minutes, 0 seconds)
0 errors, 0 warnings


Any help would be appreciated.
anothrsignature, anothrsite, anothrguitarist
User avatar
henzenmann
Insane DCEmu
Insane DCEmu
Posts: 186
Joined: Wed Jul 12, 2006 4:58 pm
Contact:

Re: Sanity Check | Testing Setup with Hello World

Post by henzenmann » Mon Feb 04, 2008 3:52 pm

That probably means that you did not set up or "source" your environ.sh correctly, so the wrappers cannot fill in the variable for the compiler binary (meaning the command line then looks like "-Wall ..." instead of "sh-elf-gcc -Wall ...", leading to the error you got).

Also, if you had set up your env. correctly, simply running "make" in the png example directory should work perfectly. From the compiler output you could then also see the exact preprocessor/compiler/linker options that work.
User avatar
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Re: Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Mon Feb 04, 2008 7:54 pm

Are you saying that I did not set up my environ.sh correctly before I built KOS?
anothrsignature, anothrsite, anothrguitarist
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY

Re: Sanity Check | Testing Setup with Hello World

Post by OneThirty8 » Tue Feb 05, 2008 1:56 am

If you were able to compile KOS, then no. Each time you start compiling Dreamcast programs in a new terminal window, you need to type 'source /path/to/environ.sh' to load it and set all the variables to the proper values. You will need to do something similar in code::blocks.
User avatar
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Re: Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Tue Feb 05, 2008 3:29 am

Thanks for clearing that up, you guys are very resourceful.
anothrsignature, anothrsite, anothrguitarist
User avatar
emptythought
DC Developer
DC Developer
Posts: 2015
Joined: Wed Jan 30, 2002 9:14 am
Location: UNITED STATES NRN
Contact:

Re: Sanity Check | Testing Setup with Hello World

Post by emptythought » Sun Feb 10, 2008 4:17 am

OneThirty8 wrote:In the timer code, you'll just need to replace the stuff that refers to 'jiffies' with 'timer_ms_gettime_64();' to get it to work like you'd expect.
I don't wanna hijack this thread but -- where is this defined at?
EDIT: Oooh, It's timer_ms_gettime64().

And when you say the joystick code needs to be patched, is the patch on SourceForge all that's needed?
Last edited by emptythought on Sun Feb 10, 2008 4:51 pm, edited 1 time in total.
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY

Re: Sanity Check | Testing Setup with Hello World

Post by OneThirty8 » Sun Feb 10, 2008 4:43 pm

fackue wrote:
OneThirty8 wrote:In the timer code, you'll just need to replace the stuff that refers to 'jiffies' with 'timer_ms_gettime_64();' to get it to work like you'd expect.
I don't wanna hijack this thread but -- where is this defined at?
It's in kos-ports/SDL/base/src/timer/dc/SDL_systimer.c:

Code: Select all

void SDL_StartTicks(void)
   48 {
   49 	/* Set first ticks value */
   50 	start = jiffies;
   51 }
   52 
   53 Uint32 SDL_GetTicks(void)
   54 {
   55 	return((jiffies-start)*1000/HZ);
   56 }
That code doesn't really work right, and programs that rely on it for timing and whatnot will run too slowly. Reaper used to just mess with the value in SDL_GetTicks, but that's not exactly going to be accurate either. What I do is use the timer_ms_gettime() or timer_ms_gettime64() function from KOS. This will let you get the value in milliseconds, which is what it's supposed to do. So in SDL_StartTicks, you should be able to just say "start = timer_ms_gettime64();" and in SDL_GetTicks, just do a timer_ms_gettime64() and subract "start" to get the number of milliseconds since SDL started. I think somebody said that Chui's version has something similar already in it but using timer_ms_gettime();. GPF said that he changed his to do what I described above.
fackue wrote: And when you say the joystick code needs to be patched, is the patch on SourceForge all that's needed?
Yes.
User avatar
anothrguitarist
DCEmu Freak
DCEmu Freak
Posts: 52
Joined: Sat Feb 02, 2008 6:55 pm

Re: Sanity Check | Testing Setup with Hello World

Post by anothrguitarist » Wed Feb 13, 2008 7:24 pm

Alright, it looks like I'm still having problems. I was able to build the png example from the make file, and I was able to build the hello world example in code::blocks. However, I thought I was able to build the png from code::blocks as well, but I was wrong. I'm getting the following errors

Code: Select all


-------------- Build: Release in ProjectScholar ---------------

Compiling: main.c
Linking console executable: bin/Release/ProjectScholar.elf
obj/Release/main.o: In function `back_init':
/home/john/Desktop/Programming/Project Scholar/main.c:27: undefined reference to `_png_to_texture'
obj/Release/main.o: In function `font_init':
/home/john/Desktop/Programming/Project Scholar/main.c:54: undefined reference to `_wfont'
obj/Release/main.o: In function `text_init':
/home/john/Desktop/Programming/Project Scholar/main.c:69: undefined reference to `_zlib_getlength'
/home/john/Desktop/Programming/Project Scholar/main.c:69: undefined reference to `_gzopen'
/home/john/Desktop/Programming/Project Scholar/main.c:69: undefined reference to `_gzread'
/home/john/Desktop/Programming/Project Scholar/main.c:69: undefined reference to `_gzclose'
obj/Release/main.o:(.data+0x0): undefined reference to `_romdisk_boot'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
7 errors, 0 warnings
I've tried various things to fix this, such as linking the project to libz.a found in kos/addons/libs, but I'm unable to figure out the problem. I've added the romdisk_boot folder to my project as well, so that shouldn't be the source of my problem.. It seems to me that I am missing an include, included the png header incorrectly, or am not linking to the right libraries. Can anyone help me out?
anothrsignature, anothrsite, anothrguitarist
Post Reply