Dune 2 DS ?

Nikokaro

Lost philosopher... searching for a way out...
Member
Joined
Feb 3, 2020
Messages
2,184
Trophies
1
Location
Nautilus (under) Lake Como, Italy 🇮🇹
XP
6,749
Country
Italy
Hi buddy, where had you been all this time? 😉 I fully support your proposal, hoping that some of our brainiacs will come forward to implement it. I usually prefer t-rpg games over rts games, but since it is free and concerns my beloved DS, why not give it a chance?
Regarding then the needed tools, as you may surmise, I have no clue. 🤣
 
  • Like
Reactions: Indy13

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,321
Country
United Kingdom
More involved games have been ported before.

First to cover the obvious. The versions of dosbox available for the DS are on the weaker side ( http://dsx86.patrickaalto.com/ ) but I think can just about squeak to working here (Dune II is mentioned in changelogs at least), enhanced flash carts (mostly going to be the DSTwo) and homebrew enabled DSi could be better still, you could emulate the megadrive/genesis version on most things (not the best port and emulation also questionable for some things here but still pretty workable) and possibly the amiga version on said enhanced flash carts.

Porting itself is a project by project affair.

The main toolchain people use for DS code is devkitpro (or more specifically its devkitarm subset, libnds being its main library).
https://devkitpro.org/
This gives you the C programming language and ARM assembly. C++ might be technically possible but its overhead is too much for anything serious. There are other programming languages available too ( https://gbatemp.net/threads/attempt...amming-languages-available-for-the-ds.357792/ ) but we can ignore those for these purposes as it would be rather too involved.

Code part of your link
https://sourceforge.net/p/dunelegacy/code/ci/master/tree/

The would be porter gets an array of things to look at.
https://gbatemp.net/threads/can-i-aka-you-as-i-cant-wont-code-port-this-game-to-this-device.576997/ covers a bit.

In an ideal world the code will be using the basic libraries afforded by the C programming language and compile straight away. This does not really apply to anything other than most things people learn to code with and minor conversion tools so then comes the fun.

You can look at the libraries it uses and see if there are equivalents for the DS. In your link I see SDL mentioned.
SDL is short for software developer's library and is a popular series of libraries and can make porting things around rather nice actually. The DS technically has some things here already made but it is a weaker version than what I am seeing there (it was a quite old/primitive version compared to what was then current, and what the PSP managed to get working for it). You could replicate what functionality you can in your own libraries, or adapt code to work with other things but that is part of the fun of porting.

This repeats for all libraries, all parts of the code (the DS for instance does not handle floating point at all in hardware so you only have slow software methods or converting to fixed point which it can do better).

That said it is not the only version
https://pdroms.de/?s=dune&post_type=post mentions a bunch for various platforms.

You also have to consider the differences in hardware. Resolution is probably going to be the first one to contemplate
256x192 pixel and 2 lots of it http://problemkaputt.de/gbatek.htm#dstechnicaldata which is low even by 486 standards, and lower than some of the console efforts. Code in a zoom (not really a thing in the game but common enough in later RTS efforts, at least until it is considered cheating), drop the resolution of sprites, have an even tighter zoom than the original game (already a hard enough time trying to manage my base and watch for sandworms in my harvesters or run a remote attack on an opponent, might be mitigated by a touchscreen minimap or similar but more on that shortly), redo the maps/mechanics to accomodate, combo of various things there... all possibilities, and also have implications for what mods are supported.
Resolution is but one aspect but I don't imagine too much trouble with the CPU (doubt this game does much with floating point numbers you have to work around), RAM is probably going to be enough but might be tight in the end (you can do expansion packs https://gbatemp.net/threads/vanilla-conquer-nintendo-dsi-port.603701/ to boost but that limits audience a bit).

You may also wish to consider the game itself; Dune II nowadays is generally recommended to be played with various mods to bring it more into line with modern RTS (or indeed just that which was known by the Command and Conquer, Warcraft and such heyday) as while it was not the first RTS it was still close enough that the UI is quite questionable by today's standards.
https://dunedynasty.sourceforge.net/ , also ported to various open handhelds if the pdroms link above is anything to go by, being one such thing. The input discussion is one to have though, especially if you have two screens to maybe kick some UI to and streamline some things, or make work better with a touchscreen.
 
  • Like
Reactions: Indy13

mrparrot2

Well-Known Member
Member
Joined
Nov 29, 2021
Messages
106
Trophies
0
Age
29
Location
SP, Brazil
XP
562
Country
Brazil
Dune II is rougthly a previous version of Command & Conquer, which has already been ported to DS. I don't think it would be really troublesome to port It to DS and I would not be surprised If someone manage to port it to the GBA.

However, I personally dont think one should invest time in porting It to DS: There is a very good Port of this game to the Genesis and It can be emulated flawlessly on the DS. Google for "Dune: The battle for Arrakis"
 
  • Like
Reactions: Indy13

Indy13

Well-Known Member
OP
Member
Joined
Jan 26, 2017
Messages
602
Trophies
0
Age
45
XP
1,278
Country
France
Hi friends,

Thank you for your answers, I don't know yet if this project will see the light of day but it's been several years that I want to create something and especially on NDS.

You're going to tell me, but if you've wanted to program something for so long, why didn't you do it before?

And I must admit that you are right but despite everything, the idea continues to run through my head so I have to try even if it does not lead to anything.

Until now I never really had a chance to find help easily, I mean in real life, because here on the forum I always found cool people to help me doing little things but learning to program in a language (English) which is not a language that I master perfectly, that complicates things, but it so happens that a year ago I went back to school (at forty past ^^) to resume studies in computer science and I find myself in an environment in which I can evolve more easily with people who are passionate about all areas of computer science, in particular programming and development, so it is in fact an opportunity for me to try to do what I always wanted to do, namely create a program on my nintendo ds :)

If I ask the question for Dune 2, it's for several reasons, first for personal reasons, DOS games represent my childhood, then even if I knew that DSx86 did the job, I thought that when there was a little too many machines moving on the screen in Dune 2 it caused some slowdown that's why I was thinking about a port to have a standalone version maybe more efficient, I don't know.

I had also thought of a port of sdlpop, just as useless since there again DSx86 does the job^^ but maybe it can improve the gameplay (at least the allocation of keys).

Finally, here are all the reasons that push me to find out about all this in the hope that it can lead one day to something concrete.
 

mrparrot2

Well-Known Member
Member
Joined
Nov 29, 2021
Messages
106
Trophies
0
Age
29
Location
SP, Brazil
XP
562
Country
Brazil
Hi,

Sorry, that was not meant to disincentive you in this task. My point was that porting Dune II to DS is not something that would bring new content to the DS platform, as there is already a port to the SEGA Genesis and that could be emulated.

If you really want to go along this project, here are a few tips I can suggest you, since I got to know the Westwood RTS engine in Command & Conquer and it was heavily based on Dune II sourcecode.

The first thing you should do is get the source code to compile. You will need to edit the build scripts (CMake, Makefile, ... whichever tool they use) to use the devkitpro toolchain (compiler and linker). Here is the CMake configuration file I wrote for devkitarm: https://github.com/giulianobelinass.../ndsi_new/cmake/devkitarm-nds-toolchain.cmake

You will probably take some time to achive this task because, as I mentined somewhere else, devkitarm doesn't provice a fully feature standard C library and you will probably have to implement some of their functions by your own or create fake functions to get it to work. Here is an example of a port of the `fnmatch` function that was used by the game. I took it from newlib and patched it to work on DS: https://github.com/giulianobelinassi/Vanilla-Conquer/blob/ndsi_new/common/fnmatch.cpp

There will most likely be problems with the graphical and sound libraries they are using in the game. It is most likely they have a compatibility layer interfacing the original game calls with SDL2. Nintendo DS doens't support SDL2 so you will have to remove the calls to SDL2 for now, and then later understand what they are supposed to do and implement them.

Once you get it to compile and a ROM generated, then you will try to run on a real DS only to find that the game will crash, probably at some point because the filesystem was not properly initialized or they don't know where to open a file. So you will have to tell the game how to initialize the filesystem and interface it with the game.

Here is an example of what I had to do: Here I implemented which path should the game find the game files: https://github.com/giulianobelinassi/Vanilla-Conquer/blob/ndsi_new/common/paths_nds.cpp

Here I hacked the game's Linux port of finding files to properly call the libfatfs initialization: https://github.com/giulianobelinassi/Vanilla-Conquer/blob/ndsi_new/common/file_posix.cpp

Once you get all files to be properly found and open, you should continue to get the video engine to work.

Command & Conquer (and most likely Dune II) did not assume the hardware had many acceleration features like today games do. They just set the VGA to 320x200 pixels and 8-bit indexed paletted mode. Then it assumes that there exists an address to which when it writes bytes on that, stuff get displayed on the screen. This is easy to emulate on the Nintendo DS, as it supports 512x256 8-bit backgrounds that can be downscaled to fit the screen. You will see that on video initialization it sets up the background accordingly: https://github.com/giulianobelinassi/Vanilla-Conquer/blob/ndsi_new/common/video_nds.cpp

You will also see that I emulate the VGA cursor support using a single DS sprite. That probably won't be needed because I think Dune II could not assume that it was supported by the card at the time. So who knows :P

As for the controls, I just emulate the mouse using the touchscreen and the keyboard using the keypads: https://github.com/giulianobelinass...9aa28e64a4f2fbe512/common/wwkeyboard.cpp#L662

With this you should have a playable game, but without music. Getting music to work in the DS is troublesome and very hard. I had to rewrite the sound engine of Command & Conquer for the DS. Dune II should be even harder in this respect because it uses MIDI music playback, so you will have to emulate an OPL somehow.

LibNDS unfortunatelly do not provide too much control of the sound engine from the ARM9 side, so will probably will want to have the code to run on the ARM7. That said, you will probably have a lot of problems debugging it. And also limited amount of RAM.

Here is the interface I wrote from the ARM9 side interfacing the game: https://github.com/giulianobelinassi/Vanilla-Conquer/blob/ndsi_new/common/soundio_nds.cpp

Here is the DS sound engine I wrote for the game running on ARM7 side: https://github.com/giulianobelinassi/Vanilla-Conquer/blob/ndsi_new/arm7/audio.cpp

Here is an overview of how the sound engine works: It defines 5 sound trackers that will be used. I known that the Nintendo DS supports more trackers, but I can't use them because of memory usage concerns. The sounds are stored compressed in memory, and decompressed as they are being played. In order to do that, I set the trackers in repeat and divide the buffer into two parts. While one part is being played, the other is being updated. This is called double-buffering. To realize when should I update the buffers, there is a *very precise* timer counting how much time was spent since the last update. This is where things get really complicated. DirectSound (PC) allows inspecting where the sound hardware is at the current sample. Nintendo DS do not have that. There is even extra code there to load the sound samples from the Expansion Pak, but I doubt you will need to use it. Dune II will probably run fine with 4MB of RAM.


In summary, that is a long but interesting project to work on. You will learn a lot if you do it, as I did learn a lot. But don't expect to finish it on a week or two, it will probably take years. It took me one year to port both Command & Conquer games to the DS.
 
  • Like
Reactions: Indy13 and r1vver

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/watch?v=pkYA4rALqEE