Vanilla-Conquer: Nintendo DSi port

CrashMidnick

Well-Known Member
Member
Joined
Jul 22, 2015
Messages
737
Trophies
0
Age
41
XP
2,870
Country
France
Here is a version of VanillaTD that somewhat works with the Opera expansion pak. It may work with other expansions, but those aren't emulated by MelonDS.

What doesn't work:
- Shape cache (every sprite sheet will be decompressed each frame. Performance hit)
- Sounds effects (ARM7 doesn't seems to like reading from the expansion pak while the ARM9 is doing so).
- Button text (I suspect that it is VRAM discarding 8-bit write's fault. DSi seems fine with those).

I am concerned that fixing the sound effects will take a lot of effort and probably I will do that last, if I will ever do that. I designed the sound engine of the game to run completely asynchronously with the ARM9, so some sort of AUD cache will have to be implemented on ARM9 side for the sound effects to work.

OTOH, Red Alert doesn't boot. It still complains about corrupt files. But I don't think it will ever work with the Opera expansion, as RA requires 15Mb of RAM to work and I already did some footprint reduction to make it run on DSi.

I will test tomorrow with my gba movie player. Thanks for your hard work. Maybe the emulation is not complete, let’s see what happens ;)
 

CrashMidnick

Well-Known Member
Member
Joined
Jul 22, 2015
Messages
737
Trophies
0
Age
41
XP
2,870
Country
France
Well I tested very quickly :

It works on my side (voices, music, movies...) :)

2.jpg



However I can't see anything in the main menu :

1.jpg
 

mrparrot2

Well-Known Member
OP
Member
Joined
Nov 29, 2021
Messages
110
Trophies
0
Age
29
Location
SP, Brazil
XP
582
Country
Brazil
I fixed the fonts not showing up and made the shape cache work. This should improve performance.

Some menus looks broken (UI elements not showing up) but they are functional so it is quite negligible. Everything in-game seems to work correctly.

Sound effects such as guns and explosions still doesn't work.
 

Attachments

  • vanillatd_expansionpak_2.zip
    510.4 KB · Views: 45

mrparrot2

Well-Known Member
OP
Member
Joined
Nov 29, 2021
Messages
110
Trophies
0
Age
29
Location
SP, Brazil
XP
582
Country
Brazil
New experimental version of VanillaTD with sound effects for the retail DS with Expansion Pak released. Check first post of this thread.

Now, I did some experiments with Red Alert and, although it is possible to make it work with the expansion pak, it would be a lot of work, more than I am willing to do, so DS support for Red Alert is scrapped.

Why? Memory consumption. For it to work I would need to move the game's map structures to the expansion pak. But that also means I need to check every 8-bit writes into the Map structure and patch it to be 16-bit. The map structure is quite large.
 

mrparrot2

Well-Known Member
OP
Member
Joined
Nov 29, 2021
Messages
110
Trophies
0
Age
29
Location
SP, Brazil
XP
582
Country
Brazil
Fast turnaround to implement such things starting from a DSi base. Glad you got the problems with things solved here.
I had to pull out some tricks.

  • First one was memory management on the expansion pak. There is none :rofl: What I did was allocate memory there like the `sbrk` function in older versions of Unix. Basically whenever you call sbrk(x) it increments the heap size in 'x' bytes (with some care with alignment). I did not implement a `free`, so the game may crash if it changes the theater (desert, winter, temperate) multiple times during a single gameplay.

Then the was the problem that the expansion pak discarded 8-bit writes. Someone in MelonDS discord channel (thanks, Generic) provided me a version of memcpy that always generate 16-bit writes. For now on I only had to find where it happened.

Since MelonDS discards those 8-bit writes as well, there had to be code explicitly discarding those writes in the emulator. So I found where it did that and patched the emulator to print out the instruction location where the write was discarded. After that was a matter of patching my code to use the 16-bit safe memcpy.

Now the sound effects where quite annoying, since I designed the sound engine to run asynchronously in the ARM7 for performance reasons. Since I am loading the sound effects on the expansion pak memory AND graphical stuff to save space in 4MB DS PSRAM, I could not switch the GBA slot memory bus to the ARM7, else the ARM9 could not access the graphics asset. The way I fixed that was whenever the ARM7 get an sound asset in a address that it can not read, it asks the ARM9 through a message to copy it in a shared buffer. This works in the most part, the problem is just the 360kb I had to use for that, which I stole from the shapes cache, and perhaps a flood in the message queue depending of how many sounds were playing simultaneously (which did happen when the credits tick effect played).

If you play that you will notice that the money tick sound is not playing. Sorry but i had to remove those.
 
  • Like
Reactions: CrashMidnick

CrashMidnick

Well-Known Member
Member
Joined
Jul 22, 2015
Messages
737
Trophies
0
Age
41
XP
2,870
Country
France
I had to pull out some tricks.

  • First one was memory management on the expansion pak. There is none :rofl: What I did was allocate memory there like the `sbrk` function in older versions of Unix. Basically whenever you call sbrk(x) it increments the heap size in 'x' bytes (with some care with alignment). I did not implement a `free`, so the game may crash if it changes the theater (desert, winter, temperate) multiple times during a single gameplay.

Then the was the problem that the expansion pak discarded 8-bit writes. Someone in MelonDS discord channel (thanks, Generic) provided me a version of memcpy that always generate 16-bit writes. For now on I only had to find where it happened.

Since MelonDS discards those 8-bit writes as well, there had to be code explicitly discarding those writes in the emulator. So I found where it did that and patched the emulator to print out the instruction location where the write was discarded. After that was a matter of patching my code to use the 16-bit safe memcpy.

Now the sound effects where quite annoying, since I designed the sound engine to run asynchronously in the ARM7 for performance reasons. Since I am loading the sound effects on the expansion pak memory AND graphical stuff to save space in 4MB DS PSRAM, I could not switch the GBA slot memory bus to the ARM7, else the ARM9 could not access the graphics asset. The way I fixed that was whenever the ARM7 get an sound asset in a address that it can not read, it asks the ARM9 through a message to copy it in a shared buffer. This works in the most part, the problem is just the 360kb I had to use for that, which I stole from the shapes cache, and perhaps a flood in the message queue depending of how many sounds were playing simultaneously (which did happen when the credits tick effect played).

If you play that you will notice that the money tick sound is not playing. Sorry but i had to remove those.
Tested on real hardware and the music is broken. Once you begin the 1st mission and the 1st sfx are played (guns), de music enter in a boot loop mode :( SFX are very loud too compared to the DSi version.

Can someone with a slot 2 exp card confirm this ?

For now I will stick with your "V2" exe.

About RA, I am really sad to read that (this is my fav one) but I understand that it is a lot of work.

Again and again, thanks for your hard work ! Very appreciated.
 
  • Like
Reactions: Indy13

mrparrot2

Well-Known Member
OP
Member
Joined
Nov 29, 2021
Messages
110
Trophies
0
Age
29
Location
SP, Brazil
XP
582
Country
Brazil
Tested on real hardware and the music is broken. Once you begin the 1st mission and the 1st sfx are played (guns), de music enter in a boot loop mode :( SFX are very loud too compared to the DSi version.

Can you please describe what is "boot loop" mode, or show a video of it happening?

You can lower the SFX volume in options ingame. Music can also be disabled there.
 

CrashMidnick

Well-Known Member
Member
Joined
Jul 22, 2015
Messages
737
Trophies
0
Age
41
XP
2,870
Country
France
It is like when you play a scratched compact disc, it tries to play 1 second the track and come back to one second earlier and so on. It is like the sfx stream takes the advantage over the music.
 
  • Like
Reactions: Indy13

mrparrot2

Well-Known Member
OP
Member
Joined
Nov 29, 2021
Messages
110
Trophies
0
Age
29
Location
SP, Brazil
XP
582
Country
Brazil
It is like when you play a scratched compact disc, it tries to play 1 second the track and come back to one second earlier and so on. It is like the sfx stream takes the advantage over the music.
Does the sounds at least works when there is no music?

This sounds like the music circular buffer isn't updating fast enough. Perhaps the ARM9 takes too much time to respond and the queue is starving. That is very bad news.
 
  • Like
Reactions: Indy13

CrashMidnick

Well-Known Member
Member
Joined
Jul 22, 2015
Messages
737
Trophies
0
Age
41
XP
2,870
Country
France
Does the sounds at least works when there is no music?

This sounds like the music circular buffer isn't updating fast enough. Perhaps the ARM9 takes too much time to respond and the queue is starving. That is very bad news.

I can't tell because I have no time to click on the option menu, once the problem occurs (less than half a sec after you're ingame), the touch screen becomes unresponsive and sometimes the game just freeze. I had a red guru once.
 
  • Like
Reactions: Indy13

mrparrot2

Well-Known Member
OP
Member
Joined
Nov 29, 2021
Messages
110
Trophies
0
Age
29
Location
SP, Brazil
XP
582
Country
Brazil
I can't tell because I have no time to click on the option menu, once the problem occurs (less than half a sec after you're ingame), the touch screen becomes unresponsive and sometimes the game just freeze. I had a red guru once.
Well, this sounds like an out-of-bounds access. I will read my code carefully to check if I find any.
 

mrparrot2

Well-Known Member
OP
Member
Joined
Nov 29, 2021
Messages
110
Trophies
0
Age
29
Location
SP, Brazil
XP
582
Country
Brazil
Please check if this ROM works. I found that the address of the SFX sound is not always 4-byte aligned. That may be causing the ARM9 to write garbage on the sound sample size.
 

Attachments

  • vanillatd_unaligned_fix.zip
    510.5 KB · Views: 41

CrashMidnick

Well-Known Member
Member
Joined
Jul 22, 2015
Messages
737
Trophies
0
Age
41
XP
2,870
Country
France
Please check if this ROM works. I found that the address of the SFX sound is not always 4-byte aligned. That may be causing the ARM9 to write garbage on the sound sample size.

Thanks for this update. It is working fine now, all good. I tested it few minutes and nothing wrong happened :)

The sound volume is now normal without changing anything in the options ;)

I will test it more on Sunday.
 
  • Like
Reactions: Indy13

Indy13

Well-Known Member
Member
Joined
Jan 26, 2017
Messages
609
Trophies
0
Age
45
XP
1,288
Country
France
Thank you @mrparrot2 ,

Like @CrashMidnick , I had the same problems on the previous version, I tested the new version, it works well for me too, I passed the first mission without any problem, everything seems normal, I started the second mission, I haven't tested the backup system yet, I will push the test too during the weekend, once again thank you for this update.
 
  • Like
Reactions: CrashMidnick

mrparrot2

Well-Known Member
OP
Member
Joined
Nov 29, 2021
Messages
110
Trophies
0
Age
29
Location
SP, Brazil
XP
582
Country
Brazil
Thanks for testing! I've updated the homepage package with a new DS version with the fix plus some refactoring. I released around 200kb that was allocated back to the shapes cache.

I will now focus on getting an unified ROM for both NDSi and NDS.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BigOnYa @ BigOnYa:
    I thought I saw a puttie snatch...
  • BigOnYa @ BigOnYa:
    I'm so pumped, NCAA football video game is back after a 10 year hiatus, coming to SeriesS/X, PS5 in July.
  • BigOnYa @ BigOnYa:
    Wish they would let us play the NCAA football 14 on newer xbox, its one of the only games I love and own on disc still, that is not back compatible, bs.
  • AdenTheThird @ AdenTheThird:
    @BigOnYa My dad recently bought a spare Series X off of me, got game pass, and saw Madden '24 on Game Pass, decided to try it out.

    ...He was a bit taken aback by the 60GB download size. Poor guy's still living in the 90s!
    +1
  • SylverReZ @ SylverReZ:
    @AdenTheThird, Bro's still in the PS2 age.
  • K3Nv2 @ K3Nv2:
    Lol charging your dad's classic unless he's the type that doesn't like taking things like that
  • AdenTheThird @ AdenTheThird:
    @K3Nv2 He was looking into consoles for his house anyway (for my younger siblings and himself) and I had a spare XSX and Switch I ended up selling him at pretty steep cuts. I would just give them to him, but I did buy them with the intent to sell them... and college is super expensive.
  • BigOnYa @ BigOnYa:
    A little yeah...
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, [insert wut here]
    +1
  • BigOnYa @ BigOnYa:
    I'm a little hi, but bout to fix that.
    +1
  • BigOnYa @ BigOnYa:
    Now I'm low, i was upstairs in my wifeys kitchen, now I'm downstairs in my dungeon.(My basement)
    +1
  • BakerMan @ BakerMan:
    do you mind? i snuck in with amiibo and jars, and am trying to do my thing brony style
  • BakerMan @ BakerMan:
    have you ever regretted saying something immediately after saying it?
    +1
  • BakerMan @ BakerMan:
    nah what i was doing was trying to cure my ever-so-apparent crabs
  • Xdqwerty @ Xdqwerty:
    @SylverReZ,
    my younger brother is forcing me to play with him and my cousins are here *sigh*
    +1
  • BigOnYa @ BigOnYa:
    @SylverReZ that Hack a hacked 360 vid was neat, never knew it existed.
    +1
  • SylverReZ @ SylverReZ:
    @BigOnYa, I thought it was interesting.
    +1
  • Xdqwerty @ Xdqwerty:
    nvm this video is clickbait
    Xdqwerty @ Xdqwerty: nvm this video is clickbait