Author Topic: Unaligned read/write support  (Read 5385 times)

Offline Toad King

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
Unaligned read/write support
« on: August 01, 2013, 07:32:33 PM »
I'm working on an emscripten port of FBA and found out that FBA is not friendly to platforms that don't support unaligned reads/writes of 16/32 bit datatypes. Both CPS2 and NeoGeo games get stuck in a loop doing RAM tests over and over (or whatever that screen flicker in NeoGeo is supposed to be). Do you know where changes would have to be made for unaligned memory support to work, or would it just be too much work to fix all the different drivers/CPUs?
« Last Edit: August 02, 2013, 06:03:24 PM by Toad King »

Offline Squarepusher2

  • New Member
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Unaligned read/write support
« Reply #1 on: August 04, 2013, 08:31:58 AM »
Toad King is a RetroArch dev and this Emscripten/Javascript port of FBA is the libretro version of FBA.

I didn't see this mentioned in the original OP so just thought I'd mention it.

And yeah, we are stuck on this issue and could really need some help from the FBA devs.

kev

  • Guest
Re: Unaligned read/write support
« Reply #2 on: August 04, 2013, 06:02:02 PM »
Is what you've done already available somewhere?


Offline Toad King

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Unaligned read/write support
« Reply #3 on: August 04, 2013, 08:40:39 PM »
Right now I'm using the libretro FBA repo - https://github.com/libretro/fba-libretro I haven't done any edits besides what's already been done in that repo (Except for makefile changes to get it to compile).

Specifically, I'm using the stripped-down cores that have just CPS2 or Neo-Geo support. A full build in Emscripten will be too much for browsers.

If you want I can get a demo webpage up so you can see the issue.
« Last Edit: August 04, 2013, 08:42:10 PM by Toad King »

Offline Toad King

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Unaligned read/write support
« Reply #4 on: November 10, 2013, 06:21:06 AM »
I got around to finding areas where the unaligned memory access was happening and worked around enough of them to get Neo-Geo and CPS2 games working.

My relevant changes:
https://github.com/libretro/fba-libretro/commit/c3075d6c4093a674c5c75f93e7ccdcd7eefadad3
https://github.com/libretro/fba-libretro/commit/6f0743a012b80eea40c528006e2d1a00a9b043ff

There will no doubt be more areas that need to be fixed, but that will require a lot of work and testing to identify all the pointer casts that are actual unaligned memory access risks from ones that are not.

If you actually want to try the final product, you can run it here: http://toadking.com/retroarch/fba.html (WARNING: clicking this link will absolutely hang your browser for a minute as it tries to parse the javascript on the page. It is a 40MB+ file uncompressed.)