Author Topic: Mednafen cross-compilation for gcw0  (Read 4343 times)

enodr (OP)

  • Posts: 54
Mednafen cross-compilation for gcw0
« on: April 17, 2015, 08:04:23 pm »
Here are some advises for people like me learning how to cross-compile a project for the gcw0. My aim was to compile a command line friendly PC Engine emulator. I choosed mednafen for it's very good pce_fast core.

This post lists the steps I did to successfully compile it.

Code: [Select]
1/ Install the toolchain as explained on the gcw0 website

2/ Get mednafen latest code source

3/ export correct PATh to the toolchain and compiler:
export PATH=$PATH:/opt/gcw0-toolchain/usr/bin:/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin

4/ configure (note: for the moment we don't care about libsndfile)
./configure --host mipsel-gcw0-linux-uclibc --prefix=/tmp --with-sysroot=/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot --without-libsndfile

5/ make and install in /tmp as I don't want to mess with my host fs nor the toolchain sysroot
make install DESTDIR=/tmp/

6/ You should have some errors in the compilation, like glu.h not found. We require opengl to build mednafen, but that doesn't imply we will run opengl

apt-get install libglu1-mesa-dev

cd /opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/
[email protected]:/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include# cp -r /usr/include/GL .

7/ Some more errors:
mednafen.cpp: In function ‘void LoadCustomPalette()’:
mednafen.cpp:673:15: error: ‘to_string’ is not a member of ‘std’
      vfszs += std::to_string(3 * *vec);
Solution:
in mednafen.cpp add and replace the call to std::to_string by "to_string" we will create:
    #include<sstream>
    template <typename T>
    std::string to_string(T value)
    {
      //create an output string stream
      std::ostringstream os ;

      //throw the value into the string stream
      os << value ;

      //convert the string stream into a string and return
      return os.str() ;
    }

You should now have a working binary in /tmp

Use the following cfg file in /media/data/local/home/.mednafen/mednafen-09x.cfg
http://pastebin.com/pJaz2Nqn

Launch through telnet or ssh with the term opened:
Code: [Select]
./mednafen -force_module pce_fast -video.driver sdl -video.fs 1 -video.frameskip 0 -pce_fast.xres 0 -pce_fast.yres 0 /media/data/roms/pcengine/super\ star\ soldier\ \(japan\).pce

The good news: the pce_fast core is running

The bad news: in super star soldier you can see an awfull screen tearing effect (sort of horizontal line wrapping repeating every 1/5th of the screen). I tried to enable triple buffering, IPU scaling, even compiled against SDL2 lib (lot of patches!!!) but nothing fixes the problem. I suspect the problem might be in the core code and maybe only affects mips cpu?

Edit: fixed, see below.
« Last Edit: April 17, 2015, 10:56:43 pm by enodr »

David Knight

  • Posts: 577
Re: Mednafen cross-compilation for gcw0
« Reply #1 on: April 17, 2015, 08:16:28 pm »
Could you post a screenshot of the tearing?
Is it a bad rom?
Is there a reason why you are using 298x240 resolution?

enodr (OP)

  • Posts: 54
Re: Mednafen cross-compilation for gcw0
« Reply #2 on: April 17, 2015, 09:38:54 pm »
No special reason for the 298x240 resolution, I made so many tests. I have edited the original post and put the good parameter (0 means use the full width and height)

Edit: this is totally crazy, the problem has disappeared! I have deleted all the config files, rebooted the gcw and tried every older build I made and no matter what I do it now works without any tearing... It drives me quite crazy but I am happy it works :)

Edit2: finally found out... When you call mednafen with some command line parameter they get saved to the cfg file and used by default the next time you launch it. So if you don't specify this particular parameter it will use the value saved in the cfg (I don't like at all this behavior).
The -pce_fact.fetch was the cullprit. Set to 0 and everything is ok now.
« Last Edit: April 17, 2015, 10:27:00 pm by enodr »

fiver

  • Posts: 84
Re: Mednafen cross-compilation for gcw0
« Reply #3 on: April 18, 2015, 03:36:46 am »
How is the speed? I heard that since Mednafen hadn't been optimized for the Zero it would be very slow.

enodr (OP)

  • Posts: 54
Re: Mednafen cross-compilation for gcw0
« Reply #4 on: April 18, 2015, 11:07:39 am »
I don't manage to display the fps counter but I feel it runs fullspeed. Note that I am running the pce_fast core not the pce core which is very slow.

I only have  a problem with daimakai mura (ghost and goblins) which is a supergrafx game. The music is playing fine then after a  few seconds it seems corrupted and has lot of crackles. This is the only game I had this problem.

Binary available here to test: https://mega.co.nz/#!7lpiAaCQ!UTu3Tg45jlIJ5aSxdVE9Fj25LwVa7tHvra4YueCbN1A

zhongtiao1

  • Posts: 249
Re: Mednafen cross-compilation for gcw0
« Reply #5 on: May 07, 2015, 03:07:46 am »
Would a port of the PC-FX mednafen core (at a reasonable speed) be possible? Or will it just be too slow as a cross compiled opk?

qbertaddict

  • * Former Staff
  • The Doctor
  • Posts: 1184
    • about.me
Re: Mednafen cross-compilation for gcw0
« Reply #6 on: May 07, 2015, 07:23:20 am »
This runs nice! CD support works as well. I can't wait until we don't have to run from telnet. Speed seems to be perfect even Supergrafx. I wonder what is causing the sound glitch in Ghouls and Ghosts

enodr (OP)

  • Posts: 54
Re: Mednafen cross-compilation for gcw0
« Reply #7 on: May 07, 2015, 07:48:23 am »
I can't wait until we don't have to run from telnet.

IMHO using Emulationstation is the best solution. You can try the config files I have posted in the emulationstation thread, it uses mednafen as the PCE emulator.

Awakened

  • Posts: 96
Re: Mednafen cross-compilation for gcw0
« Reply #8 on: May 07, 2015, 09:34:36 pm »
IMHO using Emulationstation is the best solution. You can try the config files I have posted in the emulationstation thread, it uses mednafen as the PCE emulator.
Would it be super hard to get it working from GMenu?

 

Post a new topic