Homebrew gbaemu4ds: GBA emulator for DS(i) (DSi Entry)

Is the graphic better if you use the sc Version and the upper screen on a 3DS

  • I can't do that (have no 3DS) (have not tested that)

    Votes: 110 40.3%
  • Yes

    Votes: 48 17.6%
  • No

    Votes: 26 9.5%
  • I don't know

    Votes: 89 32.6%

  • Total voters
    273

roytam1

Well-Known Member
Newcomer
Joined
Dec 24, 2017
Messages
67
Trophies
0
Age
37
XP
71
Country
Hong Kong
I think we should ask @ichichfly first. The current source code compiles in older devkitarm, but generates several .LUB files (which are really standalone, recompiled versions of the gbaemu4ds source code). Then you use hbmenu as launcher to boot these .LUB files. The hbmenu launcher chooses a file, which then is passed as a fullpath to each standalone version, so game boots.

The problem:

- the source code has several parts unused, some VBA ARM/THUMB cpu core is recompiled as arm assembly, really un maintainable and not required. Since the ARM/THUMB code is recompiled from sources (C/C++)

- the shared stacks: depending on the part gbaemu4ds runs from (say, a irq interrupt or data abort) the stack is shuffled. It is not linear: say, the usual way for an ARM program would be two interrupts to happen at the same time, the context is saved to stack then restored in full descending nature by default. In gbaemu4ds case, depending on code section, the stacks are mixed (interleaved)

- the gbaemu4ds code recompiles the SAME VBA ARM/THUMB cpu core at least twice. One for normal VBA CPU Core and another for half software emulation + MPU aborts (which just redirect to NDS map that is the same as GBA map), which is faster. Best case scenario (which I tried at some point years ago), was to have the first cpu core (full software), but either some games would stop working or the interrupts would have to be handled through software, because MPU layer would just redirect to actual NDS interrupts (for instance reading and writing IE/IF would be available from GBA mode only if that map was MPU protected)

- overall code was a bit messy, but nothing too terrible when you know already how everything goes together.

To be fair, I would rather update the code so it runs on devkitpro, THEN I would move it to ToolchainGenericDS. For now I just have the barebone stuff for building in TGDS. So homebrew would be equally maintained I guess.
I saw your TGDS repo, does TGDS-build of gbaemu4ds work now?

--------------------- MERGED ---------------------------

Weird. Is the card formatted to FAT32 with 32K clusters?
It is a 16GB FAT32 card.
I don't know its cluster size though.
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
I saw your TGDS repo, does TGDS-build of gbaemu4ds work now?
nope it does not. I just added some TGDS parts so it would compile in TGDS. I just succeeded at that

And it won't work for a while so don't get your hopes high for ToolchainGenericDS support .... yet
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
If someone feels like giving gbaemu4ds a try (added some new stuff by me):

https://bitbucket.org/Coto88/gbaemu4ds/src/master/

from the readme:

These sources use devkitARM r43. And any dldi "carts" are supported.

Hello, after years of work (2015), and about 150 "testing builds" I managed to create at least three branches from (different) gbaemu4ds sources. Of which I managed to merge together into a single branch.

Currently it support more or less the same games gbaemu4ds alpha2fix4 does but the compatibility is a bit better (just a bit, I got to boot a few games that didn't boot in alpha2fix4) since I added/merged some GBA Cpu stuff that was missing or that caused issues.

I planned originally to release gbaemu4ds sources using TGDS toolchain, but I think that will happen later. In fact that was the only thing really holding me back from releasing gbaemu4ds updates, but since it's been 3 years later. Yuck... it's time now. PS: If you are a coder, use always differencing and merging tools. These really work

  • Fixed hblank irqs, fixes pokemon fire red / green leaf battles
  • use the MPU/Caches to speedup gba wram: the gba wram runs directly from nds ewram, but gba mirrored wram is handled by the MPU. Fixes some obscure bugs and gives speedup.
  • SRAM/EEprom/Flash saves supported. Note: press Y mid-game -only- after the game saved.
  • RTC support
  • cleanup gbaemu4ds source code. Definitely needs more code cleanup.
  • mode 1 support. Other Background modes may work or show artifacts.
  • Soft reset works: Either in-game soft-reset method (A+B+SELECT+START) or gbaemu4ds menu (LEFT+UP+A+B) -> "reset GBA"
[SaveFix Support]:
1) Added Pokemon Sapphire / Ruby (any region) proper Save Format [Flash 128K]. Will prevent the "Save is Corrupted" screen. You can start a new game and the savefile will be generated correctly. On the other hand if you don't want to lose your savefile, but you have the former error screen, keep reading!

2) Added Save-Fix mechanism: Since the only games I could test was Pokemon Sapphire /Ruby... if you have a savefile from Pokemon Sapphire / Ruby that shows "Save is Corrupted" screen whose filesize is 64K (ie: Corrupted savefile, but still readable), gbaemu4ds will fix that savefile for you into a fully correct CRC save.

Case scenario: make sure to use the same filename for both the gba file and the sav file (say, 64K sav file). Boot up gbaemu4ds and run the gba file. If the save was detected as corrupted, the DS console will show a "SaveFix" message, mentioning, that you must save in-game, and then, press Y to write back to file the fixed savefile.



Instructions:


Step 1):

How to Boot:
  • Follow Step 1)
  • Copy the /release folder contents, to SD:/ root folder. (where SD is the Mounted Media according your OS), if it prompts for overwrite: Yes to All.
  • Create a /gba folder in SD:/ root folder. (where SD is the Mounted Media according your OS). Copy your homebrew , etc here.
  • Now run hbmenu.nds, and press A to browse through the /gba directory. Press A to choose the file a lot of times and that's it.
How to build:
  • Follow Step 1)
  • Unzip gbaemu4ds sources. Write down that dir path.
  • Open msys2 console: Head to same directory path written earlier, write "make clean", then "make", wait for the build to happen. After building is done, copy the /build folder contents to SD:/ root folder. (where SD is the Mounted Media according your OS).



Coto.

ps: if you have no sound, do the soft-reset button combo, it will fix the sound if available.
 
Last edited by Coto,

pgattic

Active Member
Newcomer
Joined
Sep 4, 2018
Messages
35
Trophies
0
Age
21
Location
Michigan
Website
pgattic.github.io
XP
353
Country
United States
Hey guys I just had an idea, I'm not sure if this was already thought of, or if I'm retarded or something, but would it be possible to take a disassembled GBA ROM and then assemble it into a NDS ROM instead of trying to emulate it? Again I'm not sure if that is possible/compatible etc.
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
Hey guys I just had an idea, I'm not sure if this was already thought of, or if I'm retarded or something, but would it be possible to take a disassembled GBA ROM and then assemble it into a NDS ROM instead of trying to emulate it? Again I'm not sure if that is possible/compatible etc.
once assembled, the object behaves and relates totally to the machine it was compiled for. Reverse Engineering a game that uses specific hardware (such as writing to hardware registers) ends up in emulating the pieces it requires, so it can run. This is the birth of an emulator.

To assemble a game you need to have the SDK and any BIOS-like functions. You could build an entire game without bios, but then the system would require anyway a BIOS so it initializes hardware and redirects to external media. Also the standardized functions allow game devs to abstract all the lower level parts to hardware designers, so the game just works, while preventing static, non-standard game functions.

What gbaemu4ds does is to run the ARMv4 assembly code in an hypervisor environment. And the NDS registers are very, very similar to GBA registers (and the differences are noticeable instantaneously, such as the GBA background modes running in real NDS hardware). So :

1) The ARM7 assembly code is understood natively by the ARM9 processor.

2) The wrapper layer emulates whatever the DS has not mapped, while the GBA mode does. So the wrapper layer redirects and emulates the rest of the parts.

3) The hypervisor environment allows to run emulator code, or hardware directly, that causes speedups, but requires much better exception handling in edge cases where a bit would do something entirely different in NDS mode, vs the GBA mode.

More info:
https://github.com/ichfly/gbaemu4DS/issues/4
 

pgattic

Active Member
Newcomer
Joined
Sep 4, 2018
Messages
35
Trophies
0
Age
21
Location
Michigan
Website
pgattic.github.io
XP
353
Country
United States
Hey guys I tried all the most recent release of gbaemu4ds-alive emulator branch by coto from bitbucket https://bitbucket.org/Coto88/gbaemu4ds/downloads/?tab=branches (not sure if i am allowed to have this link here) on my R4 SDHC Dual-Core from r4isdhc.com and when I launched it, every time it would get stuck on loading the .nds emulator file after I selected it. Funny thing is that I tried the same file on my friend's TT-DS card, it loaded SMA4 and Pokemon Ruby perfectly and it could save and everything, which I could never do on ANY gbaemu4ds release by ANYONE, or even with GBARunner2. Can someone please help me or give me some tips? I've even tried loading the emulator using YSMenu on my card, but got DLDI errors, which is weird because I thought that stuff does automatic DLDI patching now?

Edit: in other branches of gbaemu4ds I was able to save, then I pushed Y, but then when I'd get back on it wouldn't load the saves, like on Ruby it would just say, "The save file has been deleted..."

Edit2: NO WAY I JUST GOT IT TO WORK COMPLETELY :bow: I used the YSMenu tutorial found here: https://gbatemp.net/threads/how-to-install-ysmenu-woodr4-on-r4i-sdhc-3ds-rts.470619/ If anyone needs help with an R4 clone, use that!!!:yaynds:
 
Last edited by pgattic,
  • Like
Reactions: Tarmfot

Telon363

Member
Newcomer
Joined
Dec 21, 2018
Messages
5
Trophies
0
XP
56
Country
Italy
Hi,
I have downloaded gbaemu4nds alive and copied the gbaemu4nds.nds file in the root folder but there is a problem... it tells that it couldnt open the directory. What should I do?
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
I updated the codebase a bit, check it out.

Hi,
I have downloaded gbaemu4nds alive and copied the gbaemu4nds.nds file in the root folder but there is a problem... it tells that it couldnt open the directory. What should I do?
That means either your card wasn't DLDI patched or you didn't have a gba folder in root SD folder
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: @SylverReZ, lol +1