Welcome!

Final Burn Neo => FBN Development => Topic started by: lantus on January 24, 2012, 10:57:52 AM

Title: FBAlpha Big Endian Patches
Post by: lantus on January 24, 2012, 10:57:52 AM
Hi guys,

ive been updating from the main code base now. Here are some additional big endian patches that can be applied to the repo. They should apply and not affect win32 builds in anyway. If we could get these updated in SVN it would save me a ton of headaches :)

there are more to come but i will get started here

cheers!

Title: Re: FBAlpha Big Endian Patches
Post by: lantus on January 24, 2012, 12:16:02 PM
minor capcom big endian palette update

Title: Re: FBAlpha Big Endian Patches
Post by: lantus on January 24, 2012, 01:40:03 PM
cave big endian

Title: Re: FBAlpha Big Endian Patches
Post by: lantus on January 24, 2012, 04:23:27 PM
cps3run big endian fixes

Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on January 24, 2012, 04:29:52 PM
Thanks lantus, as you've probably seen, all these have been merged into the repo.
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on January 24, 2012, 04:39:37 PM
thanks for that. Ill keep them coming. The misc drivers are the painful ones to deal with =)
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on January 24, 2012, 04:48:39 PM
thanks for that. Ill keep them coming. The misc drivers are the painful ones to deal with =)

Yeah, but at least now they'll get integrated into the tree. :)
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on January 24, 2012, 08:36:32 PM
irem driver endian fixes
nec/vez cpu endian fixes
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on January 25, 2012, 04:12:40 PM
Thanks lantus, I applied the patches to the repo.

I moved the LSB_FIRST define from burnint.h to a makefile flag, since burnint.h isn't always used by cpu cores.
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on January 25, 2012, 11:42:33 PM
thanks Treble. That makes life easier for me as i now wont need to comment out the #define in burnint.h each time

some psykio endian updates (d_psykio4.cpp/d_psykiosh.cpp)

Title: Re: FBAlpha Big Endian Patches
Post by: lantus on January 26, 2012, 02:40:15 PM
megadrive bigendian updates
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on January 26, 2012, 03:58:50 PM
Thanks lantus, the repo is up-to-date with the patches again.
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on January 28, 2012, 12:47:12 AM
pgm big endian

Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on January 28, 2012, 04:45:42 AM
pgm big endian

Thanks lantus - applied again.

Would this;

Code: [Select]
- if (gptr[i] == (0xffff - i)) gptr[i] = 0x4e75;
+ if (gptr[i] == (0xffff - i))
+ {
+#ifdef LSB_FIRST
+                            gptr[i] = 0x4e75;
+#else
+                            gptr[i] = 0x754e;
+#endif
+ }
+

not be better as;

Code: [Select]
- if (gptr[i] == (0xffff - i)) gptr[i] = 0x4e75;
+ if (gptr[i] == (0xffff - i)) gptr[i] = (BURN_SWAP_ENDIAN_INT16(0x4e75);

?
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on January 28, 2012, 01:42:54 PM
it would be, go ahead and change that if you like. thats what late night coding does :)
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on January 28, 2012, 03:57:23 PM
it would be, go ahead and change that if you like. thats what late night coding does :)

Ok, changed that one and a similar one in the same file.
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on January 31, 2012, 07:05:43 PM
additional nec/vez cpu endian fixes.

i added the following code to bitswap.h also

Code: [Select]
/* ----- macros for accessing bytes and words within larger chunks ----- */
#ifdef LSB_FIRST
#define BYTE_XOR_BE(a)  ((a) ^ 1) /* read/write a byte to a 16-bit space */
#define BYTE_XOR_LE(a)  (a)
#define BYTE4_XOR_BE(a) ((a) ^ 3) /* read/write a byte to a 32-bit space */
#define BYTE4_XOR_LE(a) (a)
#define WORD_XOR_BE(a)  ((a) ^ 2) /* read/write a word to a 32-bit space */
#define WORD_XOR_LE(a)  (a)
#else
#define BYTE_XOR_BE(a)  (a)
#define BYTE_XOR_LE(a)  ((a) ^ 1) /* read/write a byte to a 16-bit space */
#define BYTE4_XOR_BE(a) (a)
#define BYTE4_XOR_LE(a) ((a) ^ 3) /* read/write a byte to a 32-bit space */
#define WORD_XOR_BE(a)  (a)
#define WORD_XOR_LE(a)  ((a) ^ 2) /* read/write a word to a 32-bit space */
#endif

and uncommented out the BYTE_XOR_LE() calls in nec/vez which now gives us toaplan sound on big endian :)
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on February 02, 2012, 11:52:19 PM
about 1/2 way through pst90s patches.

here they are

Title: Re: FBAlpha Big Endian Patches
Post by: lantus on February 21, 2012, 12:21:04 PM
more incoming. first up - CPS palette fix for your r350 changes
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on February 21, 2012, 03:53:25 PM
more incoming. first up - CPS palette fix for your r350 changes

Thanks - I knew something would need making endian-safe in it.
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on February 26, 2012, 04:38:19 AM
d_seta.cpp & d_seta2.cpp

Title: Re: FBAlpha Big Endian Patches
Post by: lantus on February 26, 2012, 11:14:18 PM
d_lordgun.cpp & d_mcatadv.cpp
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on February 27, 2012, 12:25:15 AM
d_gauntlet.cpp
d_raiden.cpp
d_vmetal.cpp
nec.cpp reverted (fixed d_raiden.cpp)
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on February 27, 2012, 04:49:11 PM
thanks Treble

we have a few more to go but just about there now :)
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on February 27, 2012, 04:51:19 PM
thanks Treble

we have a few more to go but just about there now :)

nice - thanks for your work lantus.
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on March 04, 2012, 09:30:24 PM
- konami needed quite a bit of work
- be patches for phoenixed cps2
- sega fd1089 protection big endian
- some more misc driver updates
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on March 19, 2012, 04:58:59 PM
more misc 90s

- d_gaelco.cpp
- d_gaiden.cpp
- d_galspnbl.cpp
- d_suna16.cpp
- d_tecmosys.cpp
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on March 20, 2012, 05:22:22 PM
more misc 90s

- d_gaelco.cpp
- d_gaiden.cpp
- d_galspnbl.cpp
- d_suna16.cpp
- d_tecmosys.cpp

Thanks lantus, sorry for the delay in applying these.
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on March 20, 2012, 07:58:09 PM
no problem Treble :)

more....

pre90s ones this time

- d_sf.cpp
- d_snk68.cpp
- d_toki.cpp

Title: Re: FBAlpha Big Endian Patches
Post by: lantus on March 22, 2012, 02:28:16 AM
- data east big endian
- some more PGM Big endian updates

Title: Re: FBAlpha Big Endian Patches
Post by: lantus on March 30, 2012, 10:01:13 AM
arm cpu
more data east
sega16 sprite fix

we are really at the home stretch now..just a few minor fixes here and there i believe :)

Title: Re: FBAlpha Big Endian Patches
Post by: iq_132 on March 30, 2012, 10:21:24 AM
Hey lantus, could you do me a favor and see if you could possibly track down a crash bug in the PGM code for me please? It seems to pop up at random, sometimes fba crashes on exit, sometimes not. I'm not sure where it's happening, if you could at least point me in a direction, i could fix it. :S
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on March 30, 2012, 10:57:56 AM
i've noticed that too iq..ill take a look
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on March 30, 2012, 03:09:11 PM
we are really at the home stretch now..just a few minor fixes here and there i believe :)

Very cool - nice work lantus. :)
Title: Re: FBAlpha Big Endian Patches
Post by: neocvera on March 30, 2012, 03:36:29 PM
I really hope someone might have a few moments to spare to enlighten me about this "big endian" business. I just really would like to know what its all about. Is it a new efficient coding scheme? Is this being done for the sake of consistency with mame updates? Or is there a bigger picture behind all of this? I'm sure everyone has much more important things to do but it would but a cliff-notes summary would be greatly appreciated.

Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on March 30, 2012, 03:40:58 PM
It's for cross-platform support (eg, xBox-360). It's implemented in such a way so as to not affect the Win32 code or performance at all.

It's built into the main tree now, to prevent lantus having to redo his work every version. :)
Title: Re: FBAlpha Big Endian Patches
Post by: neocvera on March 30, 2012, 04:00:32 PM
It's for cross-platform support (eg, xBox-360). It's implemented in such a way so as to not affect the Win32 code or performance at all.

It's built into the main tree now, to prevent lantus having to redo his work every version. :)

ahh, very nice, thanks for that.
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on March 30, 2012, 04:15:03 PM
Hey lantus, could you do me a favor and see if you could possibly track down a crash bug in the PGM code for me please? It seems to pop up at random, sometimes fba crashes on exit, sometimes not. I'm not sure where it's happening, if you could at least point me in a direction, i could fix it. :S

Hmm, was going to take a look, but I can't produce a crash at all. Any tips on anything that is more likely to make it crash? :)
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on March 30, 2012, 04:31:51 PM
it seems to happen at random..if i can find a test case that i can reproduce ill share it

attached a few more neogeo endian patches
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on March 30, 2012, 04:39:13 PM
I really hope someone might have a few moments to spare to enlighten me about this "big endian" business. I just really would like to know what its all about. Is it a new efficient coding scheme? Is this being done for the sake of consistency with mame updates? Or is there a bigger picture behind all of this? I'm sure everyone has much more important things to do but it would but a cliff-notes summary would be greatly appreciated.

short answer is:

if you want fbalpha to run on the following

- Xbox360
- PS3
- Nintendo Wii
- Nintendo Gamecube
- Power PC Amiga computers
- PPC based Mac's
- PPC Mac Mini's
- any other system that has a 'big endian' cpu either now or in future (PS4, Xbox720, WiiU perhaps)

then these patches are a good thing

it improves portability to as many different systems as possible.





Title: Re: FBAlpha Big Endian Patches
Post by: JacKc on March 30, 2012, 04:53:41 PM
Hmm, was going to take a look, but I can't produce a crash at all. Any tips on anything that is more likely to make it crash? :)
yeah it happens randomly but more chance to have this crash with kovs sets (maybe something related to nvram?)
Title: Re: FBAlpha Big Endian Patches
Post by: iq_132 on March 30, 2012, 10:39:09 PM
Hmm, was going to take a look, but I can't produce a crash at all. Any tips on anything that is more likely to make it crash? :)

I run demon front through the intro/demo loop a few times, then play the first level, then reset, then intro again. lol
Sometimes it crashes fba on exit, sometimes not.
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on March 31, 2012, 03:18:09 AM
I run demon front through the intro/demo loop a few times, then play the first level, then reset, then intro again. lol
Sometimes it crashes fba on exit, sometimes not.

It looks it's writing outside of allocated memory somewhere. If I let demon front run through the demo/intro until the IGS logo appears again gdb reports heap corruption on exiting the driver.

Code: [Select]
warning: HEAP[fbas.exe]:
warning: Heap block at 11FB1058 modified at 11FE2060 past requested size of 31000

warning: HEAP[fbas.exe]:
warning: Heap block at 05F7C118 modified at 05F94920 past requested size of 18800
Title: Re: FBAlpha Big Endian Patches
Post by: Haze on March 31, 2012, 12:03:31 PM
in my experience the easiest place to end up with such bugs is sprite rendering code, if you're not checking your clipping properly....

of course it can actually be anywhere, sound buffers, ram/shared ram allocations...  just those are more likely to crash consistently because they're more likely to be making bad accesses on a frequent basis.

Title: Re: FBAlpha Big Endian Patches
Post by: Twinaphex on March 31, 2012, 04:15:57 PM
Thanks to the big-endian patches by Lantus, FBA mainline now runs on 360, Wii and PS3 through SSNES/libsnes.

Perhaps one small change can be pushed upstream to make my life a bit easier - the header file that needs to be included for a big-endian port is called 'endian.h' right now - if this could be changed to some other name it would be much appreciated. The reason for changing it is that Linux has a system header file by that name and it conflicts when I build FBA libsnes on a Linux system (I compile PS3 builds on a Linux system with the Win32 PS3 toolchain running through WINE) - so right now with every new version of FBA that is released I always have to change the name to something that won't conflict, such as 'big_endian.h'.
Title: Re: FBAlpha Big Endian Patches
Post by: iq_132 on March 31, 2012, 08:10:18 PM
Ok, pretty sure I've got it fixed. There's a crash when NVRAM is corrupted too, but that's somewhat of a non-issue atm imo.
Title: Re: FBAlpha Big Endian Patches
Post by: Twinaphex on March 31, 2012, 08:11:50 PM
Noticed a bug while testing FBA libsnes on SSNES PS3 - if a savestate was made with any CPS3 game, the screen colors would be distorted heavily. This would only partly go away in the next round, but the colors would still be off.

You can see an image of what would happen here:

https://imgur.com/A5QOy

The following needs to be changed in cps3run.cpp - line 689 - change:

Code: [Select]
RamPal[(paldma_dest + i) ^ 1] = coldata;

to:

Code: [Select]
#ifdef LSB_FIRST
RamPal[(paldma_dest + i) ^ 1] = coldata;
#else
RamPal[(paldma_dest + i)] = coldata;
#endif

That fixed the issue for me at least.
Title: Re: FBAlpha Big Endian Patches
Post by: iq_132 on March 31, 2012, 08:17:39 PM
Noticed a bug while testing FBA libsnes on SSNES PS3 - if a savestate was made with any CPS3 game, the screen colors would be distorted heavily. This would only partly go away in the next round, but the colors would still be off.

You can see an image of what would happen here:

https://imgur.com/A5QOy

The following needs to be changed in cps3run.cpp - line 689 - change:

Code: [Select]
RamPal[(paldma_dest + i) ^ 1] = coldata;

to:

Code: [Select]
#ifdef LSB_FIRST
RamPal[(paldma_dest + i) ^ 1] = coldata;
#else
RamPal[(paldma_dest + i)] = coldata;
#endif

That fixed the issue for me at least.

Cool. ^^ Pushed this to the SVN.
Title: Re: FBAlpha Big Endian Patches
Post by: Twinaphex on March 31, 2012, 09:59:21 PM
Small typo in d_psikyo4.cpp for big-endian code path -

change line 452 from:

Code: [Select]
DrvSprRAM((address) & 0x3fff] = data;

to:

Code: [Select]
DrvSprRAM[(address) & 0x3fff] = data;
Title: Re: FBAlpha Big Endian Patches
Post by: iq_132 on March 31, 2012, 10:08:54 PM
Cool. Fixed :)
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on April 01, 2012, 04:58:49 AM
Thanks to the big-endian patches by Lantus, FBA mainline now runs on 360, Wii and PS3 through SSNES/libsnes.

Perhaps one small change can be pushed upstream to make my life a bit easier - the header file that needs to be included for a big-endian port is called 'endian.h' right now - if this could be changed to some other name it would be much appreciated. The reason for changing it is that Linux has a system header file by that name and it conflicts when I build FBA libsnes on a Linux system (I compile PS3 builds on a Linux system with the Win32 PS3 toolchain running through WINE) - so right now with every new version of FBA that is released I always have to change the name to something that won't conflict, such as 'big_endian.h'.

Thanks for pointing it out, I changed the include to burn_endian.h.
Title: Re: FBAlpha Big Endian Patches
Post by: Barry Harris on April 01, 2012, 05:09:00 AM
Ok, pretty sure I've got it fixed. There's a crash when NVRAM is corrupted too, but that's somewhat of a non-issue atm imo.

gdb no longer reports the heap warnings on exit (and I got them 100% of the time before).
Title: Re: FBAlpha Big Endian Patches
Post by: iq_132 on April 01, 2012, 08:23:52 AM
gdb no longer reports the heap warnings on exit (and I got them 100% of the time before).
Wonderful. :D
Title: Re: FBAlpha Big Endian Patches
Post by: vbt on April 04, 2012, 04:16:53 PM
don't forget Saturn, I'm back :)
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on April 04, 2012, 06:07:28 PM
welcome back =)
Title: Re: FBAlpha Big Endian Patches
Post by: lantus on April 26, 2012, 09:30:58 AM
d_cps1 endian updates for the new stuff and some bootlegs i never bothered with in the past



Title: Re: FBAlpha Big Endian Patches
Post by: lantus on May 16, 2012, 07:32:08 PM
a small endian cps1 fix for SF2MDT



Title: Re: FBAlpha Big Endian Patches
Post by: lantus on May 21, 2012, 08:35:53 PM
- endian fix for System16A tiles (Shinbo set 1 and 6)
- endian fix for d_tecmo.cpp palette (rygar)

Title: Re: FBAlpha Big Endian Patches
Post by: lantus on August 14, 2012, 10:01:49 AM
- endian fix for d_cybertnk

Title: Re: FBAlpha Big Endian Patches
Post by: lantus on November 27, 2012, 10:22:41 AM
These Big Endian patches are from MagicSeb. Verified and tested working.

 - d_cbuster.cpp : Colorfix + No crash
 - d_simpl156.cpp : Sprites fix
 - d_supbtime.cpp : Colorfix + No crash