Homebrew CitrAGB - 3DS GBA Emulator (WIP)

shinyquagsire23

SALT/Sm4sh Leak Guy
OP
Member
Joined
Nov 18, 2012
Messages
1,970
Trophies
0
Age
24
Location
Las Vegas
XP
3,638
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,970
Trophies
0
Age
24
Location
Las Vegas
XP
3,638
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
0
Age
33
XP
1,181
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
855
Trophies
0
Age
27
XP
1,194
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,787
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
 
General chit-chat
Help Users
    KenniesNewName @ KenniesNewName: If you're selling drugs dm me