Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAM limitations #7

Open
azihassan opened this issue Sep 28, 2024 · 10 comments
Open

RAM limitations #7

azihassan opened this issue Sep 28, 2024 · 10 comments

Comments

@azihassan
Copy link
Owner

azihassan commented Sep 28, 2024

According to this reply and this one, the game requires 32 MB of RAM. The Dreamcast has 16 MB and 8 MB of VRAM, so I'm not sure if it's enough to meet the requirements.

So far, the game crashed with an out of memory error once when I was storing save files in RAM. It didn't crash when I retried, probably because it generated a less ambitious level, but I estimate that the save files were using about 1 MB of RAM at that point.

I tested the first hell level on emulator (in multiplayer mode) and it didn't crash in the loading screen, but more tests need to be conducted to make sure that the game is playable in its entirety.

@AJenbo
Copy link

AJenbo commented Oct 22, 2024

Multiplayer uses more run time memory where singeplayer use larger save games (they are sued as swap files for level info). Of cause if you don't have much space for saving that isn't really any help :)

@azihassan
Copy link
Owner Author

azihassan commented Nov 16, 2024

Update: I played through the hell levels on Flycast but it eventually OOMed on the 16th level. I'll try again without sound

hell-16.mp4

@AJenbo
Copy link

AJenbo commented Nov 16, 2024

sooo close

@azihassan
Copy link
Owner Author

azihassan commented Nov 22, 2024

I changed trigs.cpp to get the hell entry to throw me right into level 16 to make testing easier. After narrowing down the crash to InitAllMonsterGFX, I sprinkled some RAM logging statements thanks to ian micheal's logging module from Discord. malloc_stats only reports 10 MBs (in max system bytes below) during the crash which made it unreliable. Never mind the PVR part in the logs, I disabled it because I didn't want to accidentally mess with SDL:

INFO: Loading monster graphics: golem\golem     x1

---------
RAM stats (MB):
Total: 16.00, Free: 3.17, Used: 12.83, PVR: 0.00
---------
max system bytes =   10199744
system bytes     =   10199744
in use bytes     =    9763312
INFO: 



INFO: Loaded monster graphics: golem\golem      297 KiB   x1

---------
RAM stats (MB):
Total: 16.00, Free: 2.88, Used: 13.12, PVR: 0.00
---------
max system bytes =   10506944
system bytes     =   10506944
in use bytes     =   10067672
INFO: 



INFO: Loading monster graphics: diablo\diablo   x1

---------
RAM stats (MB):
Total: 16.00, Free: 2.88, Used: 13.12, PVR: 0.00
---------
max system bytes =   10506944
system bytes     =   10506944
in use bytes     =   10067672
INFO: 



Out of memory. Requested sbrk_base 0x8d06a000, was 0x8cd1f000, diff 3452928
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
arch: aborting the system

It reaches the limit when it attempts to load the diablo*.clx files, which occupy 3.3ish megs:

# https://www.baeldung.com/linux/sum-the-size-of-files#1-using-awk-to-sum-file-sizes
$ ls -l build/data/diabdat/monsters/diablo/*.clx | awk '{ sum += $5 } END{ print sum/1024/1024 }'
3.29322

The diablo walking animation (diablow.clx) is the smallest one at 236 kB. I replaced all the other animations with it (1.6 megs total) and the level loaded, but for some reason I got instakilled by a large horde of monsters. I think it's because I messed with the triggers, I suspect it's loading monsters from levels 15 and 14 as well because this issue didn't happen when I restored the trigger and loaded the game with the 32 MB extension enabled on Flycast.

The next thing I'm gonna try is to look for a way to downgrade the animations to make them smaller in size. Another option is to try and skip the death/win initially (diablod.clx, 817 kB and diablon.clx I think, 648 kB), and load them when the time is right (after freeing the regular walk/attack/spell animations ones). This way we gain 1.4 megs without degrading the quality, but I think that change might be too invasive.

Edit: turns out diablon.clx is an idle animation, I thought it was a little dance Diablo does after killing the player 🤦‍♂️

@azihassan
Copy link
Owner Author

@AJenbo I looked into the animations with https://github.com/diasurgical/d1-graphics-tool. I was initially thinking of keeping half the sprites in each animation (keep 1/x, skip 2/x, keep 3/x), would this have an effect on game logic? I'm worried about it affecting things like hitboxes

@azihassan azihassan moved this to In progress in Devilutionx Dreamcast port Nov 22, 2024
@AJenbo
Copy link

AJenbo commented Nov 22, 2024

The game originally didn't use the graphics for hitbox at all and instead used tiles and a set number for each monster type. It's only something we are adding in the next release for mouse select and dropping frames won't have a negative on it.

The engine does support playing animations at different speeds.

Dropping half the frames is also on of the cuts the PlayStation did.

@azihassan
Copy link
Owner Author

azihassan commented Dec 1, 2024

I ended up changing the standby and death animations of Diablo (diablon.clx, diablod.clx and monstdat.tsv) as well as the death animations of the blackd.clx file. I noticed that the "knight" death animation looks similar (edit: but not identical) regardless of their orientation so I only kept the south facing one, and made sure the knights are turned to face south before the animation is triggered. The downside is that their corpses are all facing south. Here's what it looks like (please ignore the cheap tactic of spamming holy hadoukens):

diablo-death.mp4

I'm gonna have to try again in normal speed because I can't really tell if there's a difference here

@AJenbo
Copy link

AJenbo commented Dec 1, 2024

What about the mages I thought it looked like they might all be the same animation regardless of angle, but I'm not 100% sure.

@azihassan
Copy link
Owner Author

azihassan commented Dec 1, 2024

Thanks, nice catch! The knight death animations were similar but not identical, but the mages have the same ones frame for frame.

I forgot to mention this but at some point in the loading screen of level 15 or 14, the game complains about a missing snakb.trn and crashes. It wasn't available in my diabdat.mpq, at least not in the unpacked version. Any idea why? I copied the existing snakbl.trn into snakb.trn to bypass the error in the meantime.

Edit: forgot that I'm behind upstream, I should probably update the fork and test it again

@AJenbo
Copy link

AJenbo commented Dec 2, 2024

snakb is used for the Azure Drake, looks like it was a bug in the script that removes unused content when creating the unpacked data: diasurgical/devilutionx-mpq-tools@f4aa8b1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

No branches or pull requests

2 participants