Topic: Dreamcast Port

I'm on my way to port it to Dreamcast, but it's not easy since there are a lot of things that need to be taken care of....

Is there any way to launch the game directly without the launcher?
the video mode has to be 640x480 and 16bpp color depth.

I removed alpng and i'm using libpng dc port, I wonder if it will work...

Well I'll keep you updated.

Also I'd like to be able to upload it to the svn on some branch for example...

Re: Dreamcast Port

Please make sure you're working with the latest SVN. Take a look:

alexandre@alenet:~$ opensonic --help
Open Sonic usage:
    opensonic [options ...]

where options include:
    --help                    displays this message
    --version                 shows the version of this program
    --fullscreen              fullscreen mode
    --2xsai                   doubles the size of the game window and improves the graphic quality (*)
    --supereagle              doubles the size of the game window and improves the graphic quality (*)
    --tiny                    small game window (improves the speed **)
    --level "FILEPATH"        runs the level located at FILEPATH
    --nomusic                 disables all the musics
    --color-depth X           sets the color depth to X bits/pixel, where X = 8, 16, 24 or 32 (experimental ***)
    --language "FILEPATH"     sets the language file to FILEPATH (for example, languages/english.lng)

(*) This option may be used to improve the graphic quality using an special algorithm.
    You should NOT use this option on slow computers, since it may imply a severe performance hit.

(**) This option should be used on slow computers.

(***) Use 8 bits/pixel (256 colors) to improve even more the performance on slow computers.
      The default value is 16bpp.

Please read the docs for more information.

alexandre@alenet:~$ 

In the latest SVN, 16 bpp is the default color depth and 640x480 (windowed) is the default gfx mode. If you want 640x480x16 fullscreen, you should run:

opensonic --fullscreen

This is the same as:

opensonic --fullscreen --color-depth 16

libpng will probably work smoothly. Once libpng works correctly, you will just need to change few parts of the video module. About the svn thing, I won't give you write privileges unless I'm sure you will really continue the port (you won't abandon it). You must have something to show, to prove that to us.

Re: Dreamcast Port

Well I'm working on the port, as of now it compiles and links properly.
I'm adjusting afew settings, dreamcast homebrew OS ( kos ) is a semi unix so it does not have much of the stuff and things like the command line might now work properly, or even the launcher. Is it mandatory to launch the game with the laucnher or is there a way to simply run the game?

Re: Dreamcast Port

The launcher program isn't necessary at all. The game should execute if you just type

opensonic

on a terminal. Don't know how all this stuff works on Dreamcast, however. Anyway, since you're making a port to DC, it might be interesting to disable (?) the command line options. If you want to force some default settings, take a look at the main.c file. Check out the cmdline_read() function.

Re: Dreamcast Port

Command line options do not work, game must be launched directly. Where can I change that ?
I'm  having some unhandled exceptions I'm fixing but it will work well if the files are on a cd, there isnt enough RAM to put it all on romdisk.

Re: Dreamcast Port

Hi Neoblast,

I'm working on a PSP port, got it running (quite laggy tho because of the fact, the PSP can't handle doubles as fast as floats, so I still have to find a way to replace doubles by floats which results in some problems here and there).

The launcher isn't necessary and not possible on PSP as well as DC, so I set the "command line" switches directly in the code:

main.c

    cmd = cmdline_read(argc, argv);

#ifdef _PSP_FW_VERSION
    // Hard setting the parameters for the PSP version (as the PSP doesn't really make use of command line args)
    cmd.color_depth = 16;
    cmd.disable_music = 0;
    cmd.fullscreen = 1;
    cmd.use_2xsai = 0;
    cmd.use_fast2x = 0;
    cmd.use_supereagle = 0;
#endif 

I hope this helps.

An issue also on the PSP is the use of memory OpenSonic has: After playing 2 levels, i get an out of memory exception when loading the 3rd. (It doesn't matter in which order the levels are played) The PSP has 20MB of user RAM.

Re: Dreamcast Port

Aha thank you this is what I was looking for.
Also it runs out of memory because it's not optimized to free memory, so it keeps increasing, shouldnt we do something about that alexaindre? In PC it does not matter but in other platforms it might kernel panic because of memory.

Re: Dreamcast Port

When I looked at the code (after a level finished), there is space being freed.
I didn't had the chance to look deeper in it yet, as well as measuring the exact memory taken up for a level.

Re: Dreamcast Port

The memory just keeps rising

Re: Dreamcast Port

After you finish some level, Open Sonic releases the memory used by objects like enemies, items, etc. However, there are resources shared by several objects. For example, all instances of that flying mosquito who attacks you on Exotic Paradise Zone share the same spritesheet (animation). The code related to the level releases the instances of those enemies, but not the shared resources. This is something that the resource manager takes care of.

Our resource manager is basically a big hash table. We use that table to store images, sounds, musics and other stuff (see line 402 of util.c - SVN revision 20). If we want to play some music, we first check (automatically) if it's already on memory. If it's not, we load the file and store it in the hash table. If it's stored in the memory, the hash table will tell us where the music is located (i.e., a pointer), and then we can play it. Those resources are released only when the game is closed (see hash_release()).

If we want a very low memory usage during the entire game, we need to modify this algorithm while preserving the same conceptual model (for example, we can play a given music without caring if it's already loaded or not - the resource manager takes care of that automatically). What's the memory limit for DC?

Re: Dreamcast Port

You could also save some CPU power and memory by having more optimal music files with small samples and tight patterns. The MIDI->IT imports it is using now may be a bit of a strain for the ol' DreamCast, and don't take advantage of the format it uses anyway.

I do not know if any optimal alternatives for the current music exists, though. People rather MIDI than do tracker. sad I heard one seascape .xm that sounds a lot like Chaotix though.

Last edited by CharmyBee (2009-06-19 00:15:16)

http://steamcard.com/do/sigcard-tf2/abee.png

Re: Dreamcast Port

Well, the RAM memory limit is 16MB, the game when playing a level uses an average of 15MB you have to add the OS to that so the game "as is" may or may not fit. It has 8MB of VRAM which we might use if needed...
In an extreme case we could remake the engine so it uses  full PVR ( using nativedc video chip painting using kallistiOS ) rather than allegro, but that would be a lot harder...
The music might be changed to adpcm which the dc plays "natively" and so we oculd save some memory.

Then the resource manager need a little re-checking or something because the memory just keeps rising level after level.
Maybe it would be a good idea to free everything and then load only the neccesary stuff in any case.

Re: Dreamcast Port

UPDATE:

Well some things do work now, expect a release soon if everything goes well... version ported is the latest release 0.1.1

Re: Dreamcast Port

0.1.1:
Okay,now it works, joypad has been installed and working properly.
BUT, it will only work in 8bpp mode, in 16bpp mode it will kernel panic because it is out of memory just when loading a level...
I noticed the game pretty much loads everything on the menu ( characters and more... ) and fills almost all memory by doing this...

TODO:
Update the few things to svn r20
Create a VMU logo while playing
Find a way to reduce memory usage to use a decent colour setting...

Music seem to be a problem, it is what takes more memory.
Should we consider using another format?
the whole sample list takes like 1,72 MB which is too much if we could reduce that to the half maybe the game woulnd't have any problems on Dreamcast on 16bpp

Last edited by Neoblast (2009-07-06 12:08:06)

Re: Dreamcast Port

Music seem to be a problem, it is what takes more memory.
Should we consider using another format?
the whole sample list takes like 1,72 MB which is too much if we could reduce that to the half maybe the game woulnd't have any problems on Dreamcast on 16bpp

Can't you just do some streaming? If you do that, you wouldn't need to load the samples and the songs into the memory. Next version will include .ogg music, which is even bigger than most .it files.

Do you use the 2xSaI / SuperEagle modes?

Re: Dreamcast Port

Please keep .it musics as they use less memory and the game versions could still be ported to another systems with limited memory.
The game works fine and mostly everthing is ported BUT the brick PNG's ( island.png, island2.png, etc ) make the DC go kernel panic ( out of memory ) my guess is that it is because it is TOO BIG 800x1400, could you reduce its size? that way the dreamcast could load it.
In 8 bit everything works fine but transparencies... ( that pink colour isnt on 8 bits then no transparencies are shown... ) but in 16 bit it crashes as soon as a big ( I mean BIG png file is loaded ), if we could split the brick png file onto many png files there would be no problem, or reduce its size. If we could do that then we wouldhave no need to downsample music and those kind of things...

I don't use those modes but aren't needed either, it has a lot of quality ( 16bit ) on a tv through RGB cable... 480p ( 60HZ )

Last edited by Neoblast (2009-07-08 11:58:05)

Re: Dreamcast Port

I suggested to use more simpler music, like ones with 8-10 channels only and slow pattern speeds with low frequency for samples. Dirty midi imports and slow processors do not go well together.

Last edited by CharmyBee (2009-07-08 13:08:10)

http://steamcard.com/do/sigcard-tf2/abee.png

Re: Dreamcast Port

I'm working on the .ogg playback right now. Song files will become bigger, but they'll be loaded as streams. In other words, songs won't be totally loaded into memory (just to simplify things, let's say that they will be played directly from the disk), and this should actually reduce the memory usage. Anyway, .it/.mod/.xm/.s3m support won't be dropped, at least not in version 0.1.2.

About the PNGs, you can reduce them if you want, but that's not a good solution. Future versions of the game will have more and more levels, so even if we reduce the PNGs, DC will run out of memory anyway. Forget a little bit about the musics and tell me: what's the major concern? PNG images? WAV samples?

Memory usage isn't really a major concern in the PC version, but we can take a look at it. There could be some automatic system that would detect if a given resource is being used or not. Can you plot a graph or something that tell us the memory usage on DC during some scenes of the game? (introduction, main menu, stage 1, stage 2...)

Re: Dreamcast Port

Okay, now it works flawlessly.
At full 60 fps and does not run out of ram thanks to the low memory option.
Now I just need to access SVN to upload the source code, and upload binaries too cool
Version ported is the latest SVN as of NOW.