Testing .elf on real hardware

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.
Post Reply
ant512
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 27
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Thu Sep 29, 2016 12:31 am
Has thanked: 0
Been thanked: 0

Testing .elf on real hardware

Post by ant512 »

I've got this far in my quest to get a game running on the Dreamcast:

- Installed the KOS devkit (OSX and Ubuntu versions; thanks bogglez);
- Installed an emulator (lxdream);
- Re-acquired a Dreamcast;
- Acquired a serial port SD card reader (plus DreamShell RC4 and beta 4, and a compatible SD card);
- Restructured one of my existing Nintendo DS homebrew games so it will also compile and run under lxdream.

Now I have a .elf file that I can play with in an emulator, but how do I get that running on the Dreamcast? DreamShell RC4 refuses to have anything to do with the file. Beta 4 appears to try and load it but gets stuck after showing its console. I found this suggestion to convert the .elf to a .bin file, but neither version of DreamShell will load the resultant file (RC4 doesn't try; beta 4 switches to console and again gets stuck).

Which steps am I missing?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5690
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 10 times
Been thanked: 70 times
Contact:

Re: Testing .elf on real hardware

Post by BlueCrab »

sh-elf-objcopy (or kos-objcopy) should do the trick to create an unscrambled binary for you. You don't need the "-R .stack" part any more (and haven't for a while now), but that effectively doesn't do anything anyway.

Honestly, I know pretty much nothing about DreamShell, so I can't really help other than to confirm that objcopy is what you should need...
nymus
DC Developer
DC Developer
Posts: 968
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has thanked: 5 times
Been thanked: 6 times

Re: Testing .elf on real hardware

Post by nymus »

I haven't used Dreamshell but it seems that you can write standalone programs for it which might be why it's trying to load your .elf.

Apparently, Dreamshell is able to load iso images so I would suggest converting your elf into a bootable iso by converting to binary, scrambling, creating iso, inserting ip.bin etc. KOS might have a script for automating this or you could follow the instructions on the legendary Marcus Comstedt's site http://mc.pp.se/dc/cdr.html

I have a broadband adapter so I boot dcload from a Cdr and use the host program to load elf files directly.
behold the mind
inspired by Dreamcast
ant512
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 27
Joined: Thu Sep 29, 2016 12:31 am
Has thanked: 0
Been thanked: 0

Re: Testing .elf on real hardware

Post by ant512 »

Hmm; on a subsequent attempt using

Code: Select all

sh-elf-objcopy -O binary blah.elf blah.bin
it works fine in RC4. Weird. But, success!

Here's my first hastily cobbled together Dreamcast game:

HankyAlienDC

It's still got a few issues to sort out (I forgot that 320x240@60Hz really means 320x200@60Hz, so stuff on the edge of the screen is missing, and the graphics are the wrong color because the DS and the DC order their RGB components differently), but it all seems to be working.
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Testing .elf on real hardware

Post by bogglez »

ant512 wrote: - Installed the KOS devkit (OSX and Ubuntu versions; thanks bogglez)
:3

Which libraries did you use to make the game in the end?
I wonder whether SDL2 can be ported to the Dreamcast easily. Didn't find porting instructions and don't feel like exploring their code base right now.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
ant512
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 27
Joined: Thu Sep 29, 2016 12:31 am
Has thanked: 0
Been thanked: 0

Re: Testing .elf on real hardware

Post by ant512 »

Almost nothing Dreamcast-specific. I use the Maple functions for polling the joypad, a waitvbl function, and vram_s[] for writing to the framebuffer. Everything else is a homegrown set of libraries that gives me a reference counted, object oriented MVC GUI framework in C that compiles for Nintendo DS, SDL2 and now Dreamcast. But for the next project I'll probably switch to DC sprites.
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: Testing .elf on real hardware

Post by bogglez »

You're writing to vram_s directly? I noticed better performance by writing to a framebuffer in ram first and then copying everything over to vram using store queues or dma. Best way would of course be to use the pvr (sprite mode even)
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
ant512
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 27
Joined: Thu Sep 29, 2016 12:31 am
Has thanked: 0
Been thanked: 0

Re: Testing .elf on real hardware

Post by ant512 »

(Switches to store queues.)

Wow, so much faster! Thanks! :D
nymus
DC Developer
DC Developer
Posts: 968
Joined: Tue Feb 11, 2003 4:12 pm
Location: In a Dream
Has thanked: 5 times
Been thanked: 6 times

Re: Testing .elf on real hardware

Post by nymus »

Good Work ant512! Your game is fun! My very first experience with a computer was on an NCR system where I played a game just like this one. :)
behold the mind
inspired by Dreamcast
ant512
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 27
Joined: Thu Sep 29, 2016 12:31 am
Has thanked: 0
Been thanked: 0

Re: Testing .elf on real hardware

Post by ant512 »

Thanks! Here's an update:

HankyAlienDC

Changes are:

- Switched to store queues instead of writing to VRAM directly (much faster);
- Enabled sound (though I've only tested it in lxdream, where it sounds horrible, so hopefully it sounds better on the real hardware);
- Restored the correct color palette;
- Reorganized the screen layout to fit on an NTSC TV.
User avatar
Basil
Insane DCEmu
Insane DCEmu
Posts: 200
Joined: Wed Apr 09, 2008 9:04 am
Has thanked: 13 times
Been thanked: 0
Contact:

Re: Testing .elf on real hardware

Post by Basil »

ant512 wrote:Thanks! Here's an update:

HankyAlienDC

Changes are:

- Switched to store queues instead of writing to VRAM directly (much faster);
- Enabled sound (though I've only tested it in lxdream, where it sounds horrible, so hopefully it sounds better on the real hardware);
- Restored the correct color palette;
- Reorganized the screen layout to fit on an NTSC TV.
Hi,
The game works pretty good, i like it.
I completely forgot how to record Dreamcast videos correct but here is a video https://www.youtube.com/watch?v=YoAQmBj-Dag
Is there should be any background music?
ant512
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 27
Joined: Thu Sep 29, 2016 12:31 am
Has thanked: 0
Been thanked: 0

Re: Testing .elf on real hardware

Post by ant512 »

Is that real hardware or an emulator? Is the SD loader a custom BIOS?

There isn't any background music other than the "boop" sounds played when the aliens move.

Looks like the sounds are playing at double the correct speed...
User avatar
Basil
Insane DCEmu
Insane DCEmu
Posts: 200
Joined: Wed Apr 09, 2008 9:04 am
Has thanked: 13 times
Been thanked: 0
Contact:

Re: Testing .elf on real hardware

Post by Basil »

Is that real hardware or an emulator? Is the SD loader a custom BIOS?
Real hardware, i use burnt cd-r with a sd loader to load from a sd card.
ant512
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 27
Joined: Thu Sep 29, 2016 12:31 am
Has thanked: 0
Been thanked: 0

Re: Testing .elf on real hardware

Post by ant512 »

ant512 wrote:Looks like the sounds are playing at double the correct speed...
Oh, KOS only supports 16-bit WAV files. Makes sense. Now to figure out why the sounds are looping?
brmanuk
DCEmu Crazy Poster
DCEmu Crazy Poster
Posts: 33
Joined: Thu Dec 04, 2003 11:54 am
Has thanked: 0
Been thanked: 0

Re: Testing .elf on real hardware

Post by brmanuk »

I downloaded Hanky Alien but I can't figure out how to convert .elf to .iso for use on DreamShell! Anyone able to help?
Post Reply