Pages

Friday, January 20, 2012

Hugo emulator ported to playbook

Hugo is a PC Engine,  TG16 emulator that has been around for years. This tiny 8bit console was slapped into a giant fridge of a plastic case for the TurboGrafix16 I guess to appeal to the Western market... 




download v1.0.0.1 signed bar file

HuGo!

Status

Currently I have a ROM 'cycler' that can trigger reload of cartridges automatically but ... it crashes when the 2nd load occurs due to malloc,mem corruption. Normally the emulator shuts everything down including SDL but I want to keep graphics up since we are not on a desktop we only need to reset the core emulation.  The core itself dynamically allocates various blocks during InitPCE() and then clears them in TrashPCE() however something is going nuts after the second restart cycle.  I also changed the graphic mode to 32bit instead of the 8bit SDL mode I think it looks a little better even if arguably it's more CPU expensive. 




The porting procedure ...

A little more code tweaking was required than FCEUX but it was mostly done in one night. One thing I did was to generate Linux build since its another Autotools job meaning it's worth generating for a Unix/Linux like target first then import the code. This saves time when you import into Momentics, because the config.h file is pre-generated and if done on Linux is setting POSIX includes and other common defines. It also sets the emulator flags and SDL target so I can get a rough idea which source files matter and which dont.  Anyway after compiling and playing around with the emu on Linux I deleted some obviously redundant code e.g. windows, gtk_xxx files then  zipped up the source so I now have a unix like mini SDL build that is fairly close to QNX/PB ...


Getting a project like HuGo! into Momentics is a two step procedure:

Step 1) Create an empty tablet project
            gets me bar-descriptor.xml etc

Step 2) Import existing filesystem into the 'src' directory of the new created project
            gets the C code in this case into the project 

At this point I could hit compile and watch it explode ... but there's a couple more things to do before we hit compile and work out the issues...


Modify the project settings Build settings to reference libs, headers etc.

We need to set any special compile flags  e.g. NEW_GFX_ENGINE, -DSDL etc
We need to set up include directories  e.g. {workspace}:/SDL/include etc
We need to add -L library paths to libSDL12.so  and libTouchControlOverLay.so
We need to  import build settings from FCEUX or some other Tablet project to get Device-Release, Device-Debug etc. Or you can manually add the ARM compiler chain , I just import from a similar project.

Update bar-descriptor.xml  with your token,  enable file access, add libSDL12.so etc.

disable warnings, yeah I said it ... At this point lets fix up errors first...
set -O2 optimization for a Device-Release build don't need debug at this point.
add __QNXNTO__ flag and __PLAYBOOK__ flags to compile we will use this to isolate incompatible code. I actually only use __QNXNTO__ most of the time since I want all QNX devices to be able to compile this code and not just PB.


Now hit compile and get this thing running on Playbook ...

Bang!   Every project starts out this way, the first file dies due to missing headers, wrong types, some windows code getting compiled.  So we just solve each little problem one step at a time.  Any code that looks like windows gets deleted, if it's loaded with windows hooks just delete the module, ditto for any other platform we don't care about.  Hit compile again ...


  • syntax error before '(' or before a variable it's an unknown type ,  check the headers
  • can't find argp.h  oops ... I copied this from GNU pages since it's not part of QNX build.
  • GL code hooks - for now if they are not isolated with preprocessor flags
  • GTK code littered throughout ...  this is where the __PLAYBOOK__ flag comes in handy  

Wrapping unsupported code with flags ...

#ifndef __PLAYBOOK__
original code here that was causing a compiler break ...
#endif

#ifndef __PLAYBOOK__
SDL OpenGL code here..
#endif

No comments:

Post a Comment