Homebrew CitrAGB - 3DS GBA Emulator (WIP)

shinyquagsire23

SALT/Sm4sh Leak Guy
OP
Member
Joined
Nov 18, 2012
Messages
1,977
Trophies
2
Age
26
Location
Las Vegas
XP
3,765
Country
United States
Greets all,

So I've been working on a thing for a while. I had originally abandoned the project because I thought it was unable to be done without the use of dynamic recompilation, however as it turns out it was in fact possible. I present my 3DS GBA Emulator: CitrAGB, a 3DS GBA emulator based on gpsp.

t0wIZum.png

ht0cjXh.png


As of now, compatibility is technically on-par with whatever gpsp's interpreter is able to handle, however, due to the nature of the port some games will not run or crash on particular parts. Flipping the screen to it's proper orientation did a bit of damage which might take a bit to get fixed up, and a lot of things still need implementation. But, on the plus side, many games that do run actually run fairly well, around 50% speed in optimal cases, or as low as 20% if the game uses extremely inefficient idle loops. In the future I also plan on hopefully porting gpsp's dynrec CPU to be able to work on the 3DS as well, once smea updated ninjhax to allow developers to set RAM pages executable. This will increase emulation speed dramatically.

Controls:
A, B, Start, Select, L, R, and the D/C-Pad all map out to their rightful GBA buttons. Y is bound to select, and X currently exits back to the homebrew menu

Sauce Code:
You can find the source code for CitrAGB on my GitHub here. Once again, this is very much a work in progress and extremely buggy, but the bugs will be fixed and the emulator refined with time. However, if you encounter bugs let me know the game name and when the bug occurs so I have games to test against while fixing bugs.

Installation Instructions:

For Ninjhax:
First, grab the .3dsx here and rename it/place it in sd:/3ds/<name of .3dsx>. You can also grab the smdh here and give it the same name and place it in the same directory as the 3dsx. Next, download game_config.txt from here and a sample homebrew application here to make sure everything is set up right before you run regular GBA ROMs. The last thing you will need is gba_bios.bin. You can either dump this/find this online, or you can use Normatt's open source GBA bios here. A proper GBA bios dump is preferred, Normatt's bios has shown issues with some games. Once you have gba_bios.bin, place it either in the root of your SD card or in /gba.

For CFW:
Grab the .cia from here and place it anywhere on your SD card. Use a .cia manager such as FBI, BRM, or DevMen to install it. Next, download game_config.txt from here and a sample homebrew application here to make sure everything is set up right before you run regular GBA ROMs. The last thing you will need is gba_bios.bin. You can either dump this/find this online, or you can use Normatt's open source GBA bios here. A proper GBA bios dump is preferred, although Normatt's bios hasn't shown any issues as of yet. Once you have gba_bios.bin, place it either in the root of your SD card or in /gba.

After downloading everything, your SD card structure should look something like this:
game_config.txt
gba_bios.bin
demo.gba
/3ds/<3dsx name>/<3dsx name>.3dsx
(3dsx only)
/3ds/<3dsx name>/<3dsx name>.smdh (3dsx only)

Currently Known Bugs:
  • Any video issues which may arise
Special Thanks
Big thanks to Normatt, smea, yellows8 and plutoo for helping me get this working. Probably wouldn't have got anywhere in some places without your help. Special thanks to @aliaspider for pointing out a fix for .cia.
 
Last edited by shinyquagsire23,

shinyquagsire23

SALT/Sm4sh Leak Guy
OP
Member
Joined
Nov 18, 2012
Messages
1,977
Trophies
2
Age
26
Location
Las Vegas
XP
3,765
Country
United States
Does not work for me. I boot up the 3dsx file and 3/4 of the screen turns grey on both screens. Then it boots back to the system menu and restarts.

Hm, can't say I've gotten that. Any particular 3DS/system version you're running on? Make sure you've copied the file correctly, it should be 1.2MB in size. On that note, I'll also try re-uploading the .3dsx as well.
 

kane159

Well-Known Member
Member
Joined
May 28, 2013
Messages
215
Trophies
1
Age
34
XP
1,234
Country
Taiwan
Does not work for me. I boot up the 3dsx file and 3/4 of the screen turns grey on both screens. Then it boots back to the system menu and restarts.
me too ,and when i tried to build from source it gaves me this error,donno whats wrong :/

E:\gpsp-master\3ds>make
arm_stub.s video_blend.s
font.bin
gpspFont.bin
cheats.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/cheats.d -g -Wall -O3 -m
word-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -m
float-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/inc
lude -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3
ds/../cheats.c -o cheats.o
cpu.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/cpu.d -g -Wall -O3 -mwor
d-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mflo
at-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/includ
e -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -Wno-unused-variable -
Wno-unused-label -c /e/gpsp-master/3ds/../cpu.c -o cpu.o
cpu_threaded.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/cpu_threaded.d -g -Wall
-O3 -mword-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpc
ore -mfloat-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libct
ru/include -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -Wno-unused-v
ariable -Wno-unused-label -c /e/gpsp-master/3ds/../cpu_threaded.c -o cpu_threade
d.o
gui.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/gui.d -g -Wall -O3 -mwor
d-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mflo
at-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/includ
e -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3ds/
../gui.c -o gui.o
input.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/input.d -g -Wall -O3 -mw
ord-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mf
loat-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/incl
ude -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3d
s/../input.c -o input.o
main.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/main.d -g -Wall -O3 -mwo
rd-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mfl
oat-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/inclu
de -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3ds
/../main.c -o main.o
memory.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/memory.d -g -Wall -O3 -m
word-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -m
float-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/inc
lude -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3
ds/../memory.c -o memory.o
sound.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/sound.d -g -Wall -O3 -mw
ord-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mf
loat-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/incl
ude -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3d
s/../sound.c -o sound.o
video.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/video.d -g -Wall -O3 -mw
ord-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mf
loat-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/incl
ude -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3d
s/../video.c -o video.o
zip.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/zip.d -g -Wall -O3 -mwor
d-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mflo
at-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/includ
e -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3ds/
../zip.c -o zip.o
_3ds.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/_3ds.d -g -Wall -O3 -mwo
rd-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mfl
oat-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/inclu
de -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3ds
/./_3ds.c -o _3ds.o
draw.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/draw.d -g -Wall -O3 -mwo
rd-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mfl
oat-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/inclu
de -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3ds
/./draw.c -o draw.o
font.c
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/font.d -g -Wall -O3 -mwo
rd-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mfl
oat-abi=softfp -I/e/gpsp-master/3ds/include -IE:\devkitPro\ctrulib\libctru/inclu
de -I/e/gpsp-master/3ds/build -DARM11 -D_3DS -DARM_ARCH -w -c /e/gpsp-master/3ds
/./font.c -o font.o
arm_stub.s
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/arm_stub.d -x assembler-
with-cpp -g -march=armv6k -mtune=mpcore -mfloat-abi=softfp -c /e/gpsp-master/3ds
/../arm/arm_stub.s -o arm_stub.o
video_blend.s
arm-none-eabi-gcc -MMD -MP -MF /e/gpsp-master/3ds/build/video_blend.d -x assembl
er-with-cpp -g -march=armv6k -mtune=mpcore -mfloat-abi=softfp -c /e/gpsp-master/
3ds/../arm/video_blend.s -o video_blend.o
linking 3ds.elf
font.o:(.data+0x0): undefined reference to `font1Data'
font.o:(.data+0x4): undefined reference to `font1Desc'
font.o:(.data+0xc): undefined reference to `font1Data'
font.o:(.data+0x10): undefined reference to `font1Desc'
font.o:(.data+0x1c): undefined reference to `font1Desc'
font.o:(.data+0x28): undefined reference to `font1Desc'
font.o:(.data+0x34): undefined reference to `font1Desc'
font.o:(.data+0x40): undefined reference to `font1Desc'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [/e/gpsp-master/3ds/3ds.elf] Error 1
make: *** [build] Error 2

E:\gpsp-master\3ds>pause
 

Idaho

Well-Known Member
Member
Joined
Oct 3, 2013
Messages
884
Trophies
1
Age
29
XP
1,405
Country
France
That's great, will we be able to also have it as .cia ? GBA emulation is one of the main goal in term on emulation on the 3DS, let's make it happen :3
 

Shadowtrance

Well-Known Member
Member
Joined
May 9, 2014
Messages
2,493
Trophies
0
Location
Hervey Bay, Queensland
XP
1,807
Country
Well copying the font1.c from hb menu got past that error with compiling, only to run into another one haha

All fine until it gets here near the end...

linking 3ds.elf
_3ds.o: In function `gpsp_plat_init':
c:/Users/Vortex/Desktop/gpsp/3ds/_3ds.c:79: undefined reference to `gfxSetDoubleBuffering'
c:/Users/Vortex/Desktop/gpsp/3ds/_3ds.c:80: undefined reference to `gfxSetDoubleBuffering'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [/c/Users/Vortex/Desktop/gpsp/3ds/3ds.elf] Error 1
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • The Real Jdbye @ The Real Jdbye:
    cyberpunk at 4k without DLSS/fidelityfx *might* exceed 12gb
    +1
  • The Real Jdbye @ The Real Jdbye:
    but that game barely runs at native 4k
  • Psionic Roshambo @ Psionic Roshambo:
    I think it was some newer games and probably poorly optimized PS4 or PS5 ports
  • The Real Jdbye @ The Real Jdbye:
    they definitely will age better but i feel dlss might outweigh that since it looks about as good as native resolution and much less demanding
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    When I played Cyberpunk on my old 2080 Ti it sucked lol
  • The Real Jdbye @ The Real Jdbye:
    AMD could introduce something comparable to DLSS but nvidia's got a lot more experience with that
  • The Real Jdbye @ The Real Jdbye:
    least amd 7xxx has tensor cores which the previous generations didn't so there is the potential for AI upscaling
  • Psionic Roshambo @ Psionic Roshambo:
    They have FSR or whatever it's called and yeah it's still not great
  • The Real Jdbye @ The Real Jdbye:
    so AMD seem to finally be starting to take AI seriously
  • Psionic Roshambo @ Psionic Roshambo:
    Oh yeah those new 8000 CPUs have AI cores built in that's interesting
  • Psionic Roshambo @ Psionic Roshambo:
    Maybe they plan on offloading to the CPU?
  • Psionic Roshambo @ Psionic Roshambo:
    Would be kinda cool to have the CPU and GPU working in random more
  • Psionic Roshambo @ Psionic Roshambo:
    Tandem even
  • The Real Jdbye @ The Real Jdbye:
    i think i heard of that, it's a good idea, shouldn't need a dedicated GPU just to run a LLM or video upscaling
  • The Real Jdbye @ The Real Jdbye:
    even the nvidia shield tv has AI video upscaling
  • The Real Jdbye @ The Real Jdbye:
    LLMs can be run on cpu anyway but it's quite slow
  • BakerMan @ BakerMan:
    Have you ever been beaten by a wet spaghetti noodle by your girlfriend because she has a twin sister, and you got confused and fucked her dad?
  • Psionic Roshambo @ Psionic Roshambo:
    I had a girlfriend who had a twin sister and they would mess with me constantly.... Until one chipped a tooth then finally I could tell them apart.... Lol
  • Psionic Roshambo @ Psionic Roshambo:
    They would have the same hair style the same clothes everything... Really messed with my head lol
  • Psionic Roshambo @ Psionic Roshambo:
    @The Real Jdbye, I could see AMD trying to pull off the CPU GPU tandem thing, would be a way to maybe close the gap a bit with Nvidia. Plus it would kinda put Nvidia at a future disadvantage since Nvidia can't make X86/64 CPUs? Intel and AMD licensing issues... I wonder how much that has held back innovation.
  • The Real Jdbye @ The Real Jdbye:
    i don't think nvidia wants to get in the x64 cpu market anyways
  • The Real Jdbye @ The Real Jdbye:
    you've seen how much intel is struggling getting into the gpu market
  • The Real Jdbye @ The Real Jdbye:
    and nvidia is already doing ARM
  • The Real Jdbye @ The Real Jdbye:
    i don't think they want to take more focus away from their gpus
    The Real Jdbye @ The Real Jdbye: i don't think they want to take more focus away from their gpus