User avatar
felix3008
Posts: 38
Joined: Sun Dec 30, 2012 2:04 am

[Tutorial] gpSP - Full Speed GBA Emulator with Sound and GUI

Sun Mar 17, 2013 2:23 pm

Hi guys,

If you enjoy the 3rd gen Pokemon games as much as i do,
you probably want a full speed gpa emulator on the pi.
I'm going to write down all steps needed to get it running.
(Video demo: http://www.youtube.com/watch?v=AfFK1YeHr14)


There are two ways to get gpSP.
You can compile it from the source (slow installation, allows you to tweak the code)
or just install the pre-compiled binary i already compiled.(Fast installation, you can't modify it)

Also you can check out the Github repositorys for the current state of development:
https://github.com/DPRCZ/gpsp.git or https://github.com/notaz/gpsp.git

From Source:

1. Download the gpSP source.

Code: Select all

wget https://dl.dropbox.com/u/24838026/gpsp-ffa573f.tar.gz
2. Extract the source

Code: Select all

tar xzf gpsp-ffa573f.tar.gz
3. Remove the uneeded file

Code: Select all

rm gpsp-ffa573f.tar.gz
4. Cd into the new directory

Code: Select all

cd gpsp-ffa573f
5. remove gui.c

Code: Select all

rm gui.c
6. Download my patched gui.c

Code: Select all

wget https://dl.dropbox.com/u/24838026/gui.c
(7. Optional: Tweak the code)

8. cd into raspberrypi

Code: Select all

cd raspberrypi
9. Compile it!

Code: Select all

make -i
10. Done. (You still need to complete the additional steps down bellow)
-----------------------------------------

Pre-Build

1. make a directory for the Emulator and cd into it

Code: Select all

mkdir gpSP
cd gpSP
2. Download my pre-build binary

Code: Select all

wget https://dl.dropbox.com/u/24838026/gpsp
3. Make it "runnable"

Code: Select all

chmod +x gpsp
4. Done! (You still need to complete the additional steps down bellow)
-----------------------------------------

Additional Steps:

1. The gba emulator needs to hava a gba bios file due to the lack of HLE Emulation.
I can not provide you a link to this file as it is illegal to distribute it. Google "gba_bios.bin download"
to find it, or rip it from your game boy.
However, the file must then be placed in the same directory as the executable.

2. Same thing goes for roms. Google it! Roms can be placed anywhere.

3. To run gpSP, simply go to the directory it is in and enter:

Code: Select all

./gpsp
to run it.
-----------------------------------------

Note that it is still WIP.

Default controlls are:

Code: Select all

KEYBOARD
---------
Up		Up Arrow
Down		Down Arrow
Left		Left Arrow
Right		Right Arrow
A		Z
B		X
Start		Enter
Select		Backspace
L		A
R		S

Exit 		Esc
Menu		F10

GAMEPAD
-------
Up		XAsix -
Down		XAsix +
Left		YAsix -
Right		YAsix +
A		Button 1
B		Button 2
Start		Button 3
Select		Button 4
L		Button 5
R		Button 6

-----------------------------------------

Credits

Notaz - For making an awesome emulator
DPRCZ - For making a awesome port of an awesome emulator

-----------------------------------------

I hope my bad English skills were bearable,
I would be happy about some feedback, thanks for that in advance.

Felix3008
Last edited by felix3008 on Mon Mar 18, 2013 5:44 pm, edited 1 time in total.

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Sun Mar 17, 2013 6:36 pm

felix3008
I Compiled the Source Code, when completed get the Following -

failed to add service - already in use? (Having not seen this warning before I couldn't decide how to continue)

Also, the "Binary" Download didn't contain the Binary (It seems to Download the same Source Code Folder?)
"The list of things I have heard now contains everything!"

User avatar
felix3008
Posts: 38
Joined: Sun Dec 30, 2012 2:04 am

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Sun Mar 17, 2013 7:59 pm

Hmm, i don't know what went wrong, but the binary download is working for me, and the binary itself also works. Maybe you could try to download it to your pc, and then transferring it to your pi. (in case dropbox messes anything up).
Regarding the error: It seems to be an issue with your mem split. Keep in mind that all rendering is done by the gpu so it needs a bit of ram.
Also could you please give me the full error message and when it appears? (While compiling or while running)

Felix3008

welshy
Posts: 1667
Joined: Mon Oct 29, 2012 2:07 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Sun Mar 17, 2013 8:07 pm

felix3008
Ah, that is probably it! (I use minimal GPU Split)
Also I DID Download on PC/Transfer!

Update -
Nice Job! Works exellently and a SERIOUS performance improvement over Mednafen! I'm guessing the warning related to the fact I was in "X" and there wasn't enough Memory Left for the GPU! (I was using my "Build" Image (Which I use for Compiling) which only has 16MEG Applied to the GPU)
"The list of things I have heard now contains everything!"

User avatar
felix3008
Posts: 38
Joined: Sun Dec 30, 2012 2:04 am

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Sun Mar 17, 2013 9:19 pm

Glad to hear you got it working. Have fun with it!

Felix3008

DPR
Posts: 21
Joined: Mon Mar 18, 2013 12:45 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Mon Mar 18, 2013 12:52 pm

Hi Felix,
I'm glad that you find my port of gpsp for raspberry pi. Please note that the source of this code is on https://github.com/DPRCZ/gpsp.git or https://github.com/notaz/gpsp.git.
Dave

User avatar
felix3008
Posts: 38
Joined: Sun Dec 30, 2012 2:04 am

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Mon Mar 18, 2013 5:29 pm

Oh, I didnt know it was your source code. Sorry if it looked like I was taking all the credit, that was not my intention. I just found the archive while browsing through random FTP servers, thought i'd give it a try and wanted to share this because people keeped asking about it.

Your source code seems to have a bug in gui.c though. The variable PLAT_BUTTON_MENU was not declared. I just hacked it by declaring as an integer and setting it to "1" right before it is used, which fixed the problem (in a dirty way). But other than that, GREAT WORK, i highly appreciate it.

I don't know if i can edit the first post, but if i can, i will put the Github links in it and credit you. (EDIT: I can edit it, links put)

Have a nice evening/morning/day (timezones are dumb :lol: )

Felix3008

DPR
Posts: 21
Joined: Mon Mar 18, 2013 12:45 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Tue Mar 19, 2013 10:57 pm

Felix thank you for bug report, I've repaired this problem in reposity. Please continue in this topic, I've done my port of gpsp with aim to share it . But I have not had time to public notice about my port. Anyway as you see English is not my primary language.

User avatar
Aloshi
Posts: 359
Joined: Sat Jun 23, 2012 6:42 pm
Contact: Website

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Wed Mar 20, 2013 5:55 pm

A heads up to anyone with a Raspberry Pi with 256mb of RAM who wants to build from source: it doesn't seem to be possible to compile memory.c, even with only 16mb allocated to the GPU. One way around this is to remove the optimization flag in the Makefile (remove the "-O3" in one of the CFLAGS += lines), but I'm not sure of the impact on the binary's speed.

(And I couldn't get it to compile with -O2 or -O1, if you're wondering.)

DPR
Posts: 21
Joined: Mon Mar 18, 2013 12:45 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Thu Mar 21, 2013 7:48 am

Another way how to compile it - make bigger swap file.

ti84
Posts: 70
Joined: Wed Feb 06, 2013 9:09 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Fri Mar 22, 2013 2:54 pm

how do you make a 'bigger swap file'

I am not sure what a swap file is?

Sato
Posts: 17
Joined: Sun Apr 29, 2012 3:56 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Fri Mar 22, 2013 7:11 pm

Not compiling correctly for me, here's the log:

Code: Select all

gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o rpi.o rpi.c
In file included from /opt/vc/include/bcm_host.h:50:0,
                 from rpi.c:25:
/opt/vc/include/interface/vmcs_host/vcgencmd.h:33:27: fatal error: vchost_config.                  h: No such file or directory
compilation terminated.
make: [rpi.o] Error 1 (ignored)
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o main.o ../main.c
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads -Wno-unused-variable -Wno-unused-labe                  l   -c -o cpu.o ../cpu.c
../cpu.c: In function âexecute_armâ:
../cpu.c:4371:7: warning: variable âold_pcâ set but not used [-Wunused-but-set-va                  riable]
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o memory.o ../memory.c
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o video.o ../video.c
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o input.o ../input.c
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o sound.o ../sound.c
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o gui.o ../gui.c
../gui.c: In function âload_fileâ:
../gui.c:145:20: warning: variable âchosen_dirâ set but not used [-Wunused-but-se                  t-variable]
../gui.c:145:7: warning: variable âchosen_fileâ set but not used [-Wunused-but-se                  t-variable]
../gui.c: In function âmenuâ:
../gui.c:1166:22: warning: unused variable âgamepad_config_buttonsâ [-Wunused-var                  iable]
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o cheats.o ../cheats.c
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o zip.o ../zip.c
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads -c -o arm_stub.o ../arm/arm_stub.S
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o warm.o ../arm/warm.c
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads -Wno-unused-variable -Wno-unused-labe                  l   -c -o cpu_threaded.o ../cpu_threaded.c
../cpu_threaded.c: In function âtranslate_block_armâ:
../cpu_threaded.c:3395:1: warning: variable âflag_statusâ set but not used [-Wunu                  sed-but-set-variable]
../cpu_threaded.c: In function âtranslate_block_thumbâ:
../cpu_threaded.c:3396:1: warning: variable âlast_conditionâ set but not used [-W                  unused-but-set-variable]
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads   -c -o gles_video.o gles_video.c
In file included from /opt/vc/include/bcm_host.h:50:0,
                 from gles_video.c:1:
/opt/vc/include/interface/vmcs_host/vcgencmd.h:33:27: fatal error: vchost_config.                  h: No such file or directory
compilation terminated.
make: [gles_video.o] Error 1 (ignored)
gcc -DARM_ARCH -DRPI_BUILD -Wall -mfpu=vfp `sdl-config --cflags` -I/opt/vc/includ                  e -I/opt/vc/include/interface/vcos/pthreads -c -o video_blend.o ../arm/video_blen                  d.S
gcc rpi.o main.o cpu.o memory.o video.o input.o sound.o gui.o cheats.o zip.o  arm                  _stub.o  warm.o cpu_threaded.o gles_video.o video_blend.o `sdl-config --libs` -ld                  l -lpthread -lz -L/opt/vc/lib/ -lGLESv2 -lEGL -lopenmaxil -lbcm_host -lvcos -lvch                  iq_arm  -lrt -o gpsp
gcc: error: rpi.o: No such file or directory
gcc: error: gles_video.o: No such file or directory
make: [gpsp] Error 1 (ignored)
I tried Aloshi's idea of removing the "-O3" from the Cflag, but it made no difference. Any ideas?

DPR
Posts: 21
Joined: Mon Mar 18, 2013 12:45 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Fri Mar 22, 2013 8:14 pm

Resizing swapfile:

sudo swapoff -a
sudo nano /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo swapon -a

DPR
Posts: 21
Joined: Mon Mar 18, 2013 12:45 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Fri Mar 22, 2013 8:21 pm

I made build on Raspbian “wheezy”. Google suggested for this problem: add -I/opt/vc/include/interface/vmcs_host/linux to CFLAG in makefile.

floba
Posts: 4
Joined: Thu Mar 21, 2013 9:48 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Tue Mar 26, 2013 12:38 pm

nice thx!
is it possible to integrate it into simulationstation?

maybe easy through a shell script?

User avatar
Aloshi
Posts: 359
Joined: Sat Jun 23, 2012 6:42 pm
Contact: Website

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Wed Apr 17, 2013 5:29 pm

To anyone interested, the RetroPie-Setup script just merged a change that replaces the slow RetroArch GBA core with gpSP.

JBaker1225
Posts: 48
Joined: Wed Apr 17, 2013 10:27 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Wed Apr 17, 2013 10:30 pm

Aloshi wrote:To anyone interested, the RetroPie-Setup script just merged a change that replaces the slow RetroArch GBA core with gpSP.
What exactly do I need to do to swap out my RetroArch GBA emulator for this new one?
I'm running RetroPie on Raspbian right now.
Just run the RetroPie-Setup script and pull the new one? Or do I need to update RetroPie first? If so, how exactly do I do that from the Raspbian terminal?
And do I need to delete the RetroArch GBA emulator in order for it to switch over to gbSP when I have it installed?

Sorry for all the questions, but I am VERY new to all of this, and just know I would LOVE a GBA emu that runs better than the RetroArch one, which is basically unplayable.
Thanks in advance.

Vanfanel
Posts: 433
Joined: Sat Aug 18, 2012 5:58 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Thu Apr 18, 2013 12:12 am

This emulator is incredible, period. Fullspeed, constant 60FPS GBA emulation on the Raspberry Pi. I wouldn't have believed it if I hadn't seen it myself.
However, what's the trick here? Is there any kind of ARM cpu virtualization taking advantage of similar architecture? I don't believe it's bruteforce emulation.

User avatar
Aloshi
Posts: 359
Joined: Sat Jun 23, 2012 6:42 pm
Contact: Website

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Thu Apr 18, 2013 1:24 pm

JBaker1225 wrote:What exactly do I need to do to swap out my RetroArch GBA emulator for this new one?
First, update RetroPie-Setup - cd into that directory and run "git pull" to update.
Next, run RetroPie-Setup with "sudo ./retropie_setup.sh". Choose source-based installation, and use Space to only select "Install Game Boy Advance emulator (gpSP)" and "(C) Generate config file for Emulation Station".
Let it run, it'll take a while; make sure you don't have too much RAM allocated to the GPU, or the compile might fail. After that, you're done.

JBaker1225
Posts: 48
Joined: Wed Apr 17, 2013 10:27 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Thu Apr 18, 2013 5:32 pm

Aloshi wrote:
JBaker1225 wrote:What exactly do I need to do to swap out my RetroArch GBA emulator for this new one?
First, update RetroPie-Setup - cd into that directory and run "git pull" to update.
Next, run RetroPie-Setup with "sudo ./retropie_setup.sh". Choose source-based installation, and use Space to only select "Install Game Boy Advance emulator (gpSP)" and "(C) Generate config file for Emulation Station".
Let it run, it'll take a while; make sure you don't have too much RAM allocated to the GPU, or the compile might fail. After that, you're done.
So, I guess this is a stupid follow-up, but how exactly do I run the update?
I typed
cd
git clone --depth=0 git://github.com/petrockblog/RetroPie-Setup.git

Into the terminal. But that just says that I already have RetroPie-Setup. Do I need to type "git pull" after that? Or is there some other step I need to type in before that?

Sorry for the questions, but I'm very new at this and not sure exactly what I'm doing. I'm able to follow step-by-step instructions like a monkey, but things like "update RetroPie-Setup - cd into that directory and run "git pull" are confusing to me.

Thanks in advance for the help.

User avatar
Aloshi
Posts: 359
Joined: Sat Jun 23, 2012 6:42 pm
Contact: Website

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Thu Apr 18, 2013 7:15 pm

Sorry! I mean:

Code: Select all

cd ~/RetroPie-Setup
git pull
sudo ./retropie_setup
Here's what it means, if you're interested: git is the version control system that RetroPie uses. It's a fancy way of letting developers keep track of different software revisions. "git clone", the command you used the first time, sets up a "local repository," a "clone" of the remote repository on the GitHub website. To get the most recent changes, you have to tell git to "pull" changes from the remote repository. You have to "cd" to change your current working directory to the RetroPie-Setup folder. This is so git knows what repository you're talking about - one computer can have many simultaneous projects.

JBaker1225
Posts: 48
Joined: Wed Apr 17, 2013 10:27 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Thu Apr 18, 2013 7:22 pm

Thanks a lot!
The instructions and the explanation are both much appreciated. It makes a lot more sense to me now.

JBaker1225
Posts: 48
Joined: Wed Apr 17, 2013 10:27 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Fri Apr 19, 2013 4:53 am

Wow. I got it up and running and I just have to say thank you, thank you, thank you to the people that created this, ported it, and helped me get it running.
I thought all the GBA ROMs I uploaded were going to go to waste, but this makes it 150 times better. Running brilliantly.

pjexposito
Posts: 1
Joined: Sun Jan 27, 2013 2:27 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Fri Apr 19, 2013 7:21 am

Hi,

can I use xboxdrv with this emulator? How? I've installed the xboxdrv but there is not joystick on the menu section.

Thanks.

Vanfanel
Posts: 433
Joined: Sat Aug 18, 2012 5:58 pm

Re: [Tutorial] gpSP - Full Speed GBA Emulator with Sound and

Fri Apr 19, 2013 9:29 am

Is there a way to remap USB joypad buttons?

Return to “Gaming”