0

I have been developing a simple RTS game using C++ in Linux. By the DJGPP, I can also cross-compile the game to DOS build. In Linux, once the game starts, it only uses about 25MB of RAM though many game objects such as game units are created. But when it runs in DOSbox, it is very slow at the beginning and getting slower while the number of created game units is increased. Of course, DOS is old, but I think 25 MB is enough to run the game there.

Could you let me know what's wrong with me?

So my questions are following;

  1. The game uses about 25MB of RAM in Linux, so does it have to use such an amount in DOS, too?
  2. Is there a boundary value that limits the usage of RAM in DOS?
DevShine
  • 3
  • 2
  • 1
    It's probably about emulated CPU speed, not memory. – Sebastian Redl Sep 13 '21 at 07:51
  • Dosbox is fully emulating the CPU. You can try your game in a Freedos VM instead. That should execute the code directly on your CPU. If that is fast, the limitation is CPU, if that's slow too, it's probably graphics. –  Sep 13 '21 at 08:17
  • The memory usage question does not look answerable with the information provided. You should probably try to find some way of measuring it for yourself. –  Sep 13 '21 at 08:25
  • I tried in real FreeDOS, but it is slow, too. – DevShine Sep 13 '21 at 08:43

2 Answers2

0
  1. The game uses about 25MB of RAM in Linux, so does it have to use such an amount in DOS, too?

Linux executables are 32 or 64-bit whereas DOS is a 16-bit OS so many objects will be smaller in DOS. However many 32/64-bit operations in DOS would be longer in DOS due to obvious reasons, which means they'll require larger code space to accommodate. Depending on the code the memory usage in DOS may be smaller or larger

  1. Is there a boundary value that limits the usage of RAM in DOS?

DOS (hence also FreeDOS) doesn't manage memory like that. Only a single process (excluding TSRs) runs at a single time so they own the whole memory space and manage that themselves. There's no need for process protection, a process can access everything

Besides DOS can't support more than 1MB RAM of memory. You have only 640KB of userspace RAM and that's the limit you get

You can access more memory with EMS, XMS but they don't belong to DOS and you'll have to explicitly load those libraries and call the appropriate APIs

For more information read DOS memory management

phuclv
  • 37,963
  • 15
  • 156
  • 475
  • Thanks for your answer, but the game definitely uses more than 1MB in DOSbox, how can you explain this? And Freedos supports much more RAM. – DevShine Sep 13 '21 at 10:12
  • @DevShine where do you see the memory usage? DOS doesn't handle memory and can't know how much RAM you've used. If you check the memory usage of DOSbox then obviously it's the memory usage of the emulator and not DOS – phuclv Sep 13 '21 at 10:24
  • `And Freedos supports much more RAM` who told you that? FreeDOS is an MS-DOS clone so it's still a [16-bit OS](http://wiki.freedos.org/wiki/index.php/32-bit) and supports only 1MB RAM. It does zero memory management exactly like MS-DOS. The programmer must manually handle any memory higher than 1MB. See [Does using FreeDOS allow my program to access more than 64 K of memory?](https://stackoverflow.com/q/20343282/995714), [How can I access full memory space in FreeDOS with C application](https://stackoverflow.com/q/56084263/995714) – phuclv Sep 14 '21 at 02:04
  • 1
    djgpp runs in 32-bit protected mode [source](http://www.delorie.com/djgpp/doc/eli-m17n99.html#v2%20and%20DPMI), the amount of memory available is not the problem –  Sep 14 '21 at 13:16
  • @dratenik yes but that's the job of the compiler and DPMI. DOS itself has no idea about memory above 1MB. Anyway your question has no code so it's off-topic here. There's no way to optimize a program without knowing anything about it – phuclv Sep 14 '21 at 15:58
0

Thanks for your answer, I really want this game to be run in old OS, too. Recently, I found that the reason why the game is so slow in DOSBox is because of the game engine I used. It is self-developed on the basis of open-source, but it had so many issues in the field of performance effectiveness.

So I have optimized the main game loop and game object management modules till now, it runs much faster than before. It seems to be fast more than 10 times!

But it is still slow. Currently, it runs fast in Windows 98, but not in Dosbox and FreeDos.

It takes a few seconds for loading the game scene, but game fps is still low in Dosbox and freedos.

Could anyone teach me how to optimize the game? Of course, I am on doing that, but hope to hear your opinions. :)

DevShine
  • 3
  • 2