-
Notifications
You must be signed in to change notification settings - Fork 410
Adding Opera (3DO) as emulation core in Bizhawk #4264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SergioMartin86
wants to merge
82
commits into
TASEmulators:master
Choose a base branch
from
SergioMartin86:opera
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
c82506a
Adding base
SergioMartin86 fc8fa94
Progress with opera and adding 3do firmwares
SergioMartin86 b90d6f6
Adding missing callbacks
SergioMartin86 bc213ed
Adding missing callbacks
SergioMartin86 63a5ac6
3DO core starting
SergioMartin86 d3be088
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 e7aeebb
Now passing inputs
SergioMartin86 98f2191
Passing gamepad inputs
SergioMartin86 57af521
Fixing input names
SergioMartin86 face41a
Now supporting mouse
SergioMartin86 400f4b9
Adding mouse support
SergioMartin86 935a4d1
Added flightstick
SergioMartin86 4a507cb
Added flight stick
SergioMartin86 d85bf7e
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 5994501
Adding last inputs and fixing audio
SergioMartin86 2cef3f1
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 b09d17e
Adding controllers and fixing audio
SergioMartin86 6866911
Adding orbatak
SergioMartin86 cce05d7
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 4c97d6d
Fixing mnemonics, added orbatak
SergioMartin86 707f890
Adding font roms
SergioMartin86 8f6ffe5
Adding font roms
SergioMartin86 95b7a93
Adding region
SergioMartin86 3adcba0
Adding region
SergioMartin86 6445eea
Fixing mouse issue
SergioMartin86 3fb18a6
Fixed initialization bug in fresh installs
SergioMartin86 634fcd7
Setting mouse to relative inputs
SergioMartin86 14d77aa
Using mouse as relative
SergioMartin86 6375152
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 339b3fa
Bypassing bios checks to enable bizhawk to pass whatever bios it wants
SergioMartin86 62922cb
Adding default inputs for 3DO
SergioMartin86 d141155
Adding detection of nvram changes
SergioMartin86 59c1f7c
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 3937334
Adding lag frame and nvram saving
SergioMartin86 24f496b
Adding cd use detection
SergioMartin86 4505b66
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 6523c94
Adding cdrom light
SergioMartin86 1201035
Using cd callbacks
SergioMartin86 26f9501
Using cd callbacks
SergioMartin86 95dec71
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 db9d212
Bypassing image name check
SergioMartin86 0e5030c
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 7a4be1d
Adding multidisc support
SergioMartin86 58dc832
merging upstream
SergioMartin86 f74d7ec
Removing 3do-iso special extension
SergioMartin86 4b68111
Fixing build
SergioMartin86 02e8313
Attempting to add disc swapping
SergioMartin86 158f91e
Trying to add multidisc support
SergioMartin86 ad3636a
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 4fcb12b
Uncommenting cd functions
SergioMartin86 90f0673
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 5f3ed39
revert unrelated changes
Morilli 833663d
misc unmanaged integration
Morilli 5c31c3a
Update waterbox-cores.yml
Morilli f1222c2
Added reset button, removed eject/insert
SergioMartin86 543e1e5
Added reset button, removed eject/insert
SergioMartin86 fe75a5c
Fix line endings in `Bk2MnemonicLookup.cs` changes
YoshiRulz e0f6f05
Fix indentation
YoshiRulz f93584c
Fix spaces in `Opera.cs`
YoshiRulz 633c2c3
Alphabetise
YoshiRulz fba0d59
Make `Opera`'s `ISaveRam` implementations `override`
YoshiRulz 39f566d
Misc. code style changes
YoshiRulz 710d0ba
Fix casting array index to `uint` for comparisons
YoshiRulz fecbc9e
Adding default framerate and removing message duration parameter
SergioMartin86 b7260d1
Refactoring input parsing and fixing some errors
SergioMartin86 0dcdcaf
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 7fa5f53
Fixing indentation
SergioMartin86 2669fda
Exposing non volatile ram
SergioMartin86 b503e08
Adding automatic sram management
SergioMartin86 aa88205
Now letting bk manage saveram automatically
SergioMartin86 ea69752
Fixing indentation and removing unncessary flag
SergioMartin86 3abad35
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 683ae9b
Removing dead code
SergioMartin86 6e24c6b
Removing dead code
SergioMartin86 0de3211
Removing unnecessary mnemonic fallbacks
SergioMartin86 06a3684
Keep fixing indentation errors
SergioMartin86 d286bd0
Removing struct for memory areas
SergioMartin86 496ca8c
Adding proper detection of input reading
SergioMartin86 ed08e48
Changing namespace to not have an underscore
SergioMartin86 701931a
Merge branch 'opera' of github.com:SergioMartin86/BizHawk into opera
SergioMartin86 f3ca025
fix whitespace in PlatformFrameRates
Morilli adc640c
make waterbox function non-virtual
Morilli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
using System.Runtime.InteropServices; | ||
using BizHawk.BizInvoke; | ||
using BizHawk.Emulation.Cores.Waterbox; | ||
|
||
namespace BizHawk.Emulation.Consoles.ThreeDO | ||
{ | ||
public abstract class LibOpera : LibWaterboxCore | ||
{ | ||
// NTSC Specifications | ||
public const int NTSC_WIDTH = 320; | ||
public const int NTSC_HEIGHT = 240; | ||
public const int NTSC_VIDEO_NUMERATOR = 60; | ||
public const int NTSC_VIDEO_DENOMINATOR = 1; | ||
|
||
// PAL1 Specifications | ||
public const int PAL1_WIDTH = 320; | ||
public const int PAL1_HEIGHT = 288; | ||
public const int PAL1_VIDEO_NUMERATOR = 50; | ||
public const int PAL1_VIDEO_DENOMINATOR = 1; | ||
|
||
// PAL2 Specifications | ||
public const int PAL2_WIDTH = 384; | ||
public const int PAL2_HEIGHT = 288; | ||
public const int PAL2_VIDEO_NUMERATOR = 50; | ||
public const int PAL2_VIDEO_DENOMINATOR = 1; | ||
|
||
[UnmanagedFunctionPointer(CC)] | ||
public delegate void CDReadCallback(int lba, IntPtr dst); | ||
|
||
[UnmanagedFunctionPointer(CC)] | ||
public delegate int CDSectorCountCallback(); | ||
|
||
[BizImport(CC)] | ||
public abstract void SetCdCallbacks(CDReadCallback cdrc, CDSectorCountCallback cdscc); | ||
|
||
[BizImport(CC, Compatibility = true)] | ||
public abstract bool Init(string gameFile, string biosFile, string fontFile, int port1Type, int port2Type, int videoStandard); | ||
|
||
[BizImport(CC, Compatibility = true)] | ||
public abstract bool sram_changed(); | ||
|
||
[BizImport(CC, Compatibility = true)] | ||
public abstract int get_sram_size(); | ||
|
||
[BizImport(CC, Compatibility = true)] | ||
public abstract void get_sram(IntPtr sramBuffer); | ||
|
||
[BizImport(CC, Compatibility = true)] | ||
public abstract void set_sram(IntPtr sramBuffer); | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public struct GamepadInputs | ||
{ | ||
public int up; | ||
public int down; | ||
public int left; | ||
public int right; | ||
public int start; | ||
public int select; | ||
public int buttonA; | ||
public int buttonB; | ||
public int buttonX; | ||
public int buttonY; | ||
public int buttonL; | ||
public int buttonR; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public struct MouseInputs | ||
{ | ||
public int dX; | ||
public int dY; | ||
public int leftButton; | ||
public int middleButton; | ||
public int rightButton; | ||
public int fourthButton; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public struct FlightStickInputs | ||
{ | ||
public int up; | ||
public int down; | ||
public int left; | ||
public int right; | ||
public int fire; | ||
public int buttonA; | ||
public int buttonB; | ||
public int buttonC; | ||
public int buttonX; | ||
public int buttonP; | ||
public int leftTrigger; | ||
public int rightTrigger; | ||
public int horizontalAxis; | ||
public int verticalAxis; | ||
public int altitudeAxis; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public struct LightGunInputs | ||
{ | ||
public int trigger; | ||
public int select; | ||
public int reload; | ||
public int isOffScreen; | ||
public int screenX; | ||
public int screenY; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public struct ArcadeLightGunInputs | ||
{ | ||
public int trigger; | ||
public int select; | ||
public int start; | ||
public int reload; | ||
public int auxA; | ||
public int isOffScreen; | ||
public int screenX; | ||
public int screenY; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public struct OrbatakTrackballInputs | ||
{ | ||
public int dX; | ||
public int dY; | ||
public int startP1; | ||
public int startP2; | ||
public int coinP1; | ||
public int coinP2; | ||
public int service; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public struct GameInput | ||
{ | ||
public GamepadInputs gamepad; | ||
public MouseInputs mouse; | ||
public FlightStickInputs flightStick; | ||
public LightGunInputs lightGun; | ||
public ArcadeLightGunInputs arcadeLightGun; | ||
public OrbatakTrackballInputs orbatakTrackball; | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public new class FrameInfo : LibWaterboxCore.FrameInfo | ||
{ | ||
public GameInput port1; | ||
public GameInput port2; | ||
public int isReset = 0; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason these are all
int
s instead of a type more closely resembling their data range, likebool
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did try using
bool
but I keep getting false at the core side, even when I send trues from the bk side. I looked high and low for a discrepancy in the apis, but everything looks correct.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using bool, was the core actually using bool too, or just ints? The struct sizes need to match up.
Also the
Compatibility = true
would also probably cause issues regardless if you did that, as that would go under "normal" marshalling rules (i.e. the struct is converted into one with 4 byte bools instead of just directly pinning the original struct). You generally shouldn't use Compatibility = true unless you need "normal" marshalling as that slower.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried again, making sure again that the structs coincide. You can find them here:
[BK Side]
https://github.com/SergioMartin86/BizHawk/blob/b4836176a8df5d2eba2d77598412036767840d8d/src/BizHawk.Emulation.Cores/Consoles/3DO/LibOpera.cs#L58
[WBX side] https://github.com/SergioMartin86/BizHawk/blob/b4836176a8df5d2eba2d77598412036767840d8d/waterbox/opera/bizhawk.hpp#L13
The values are simply not passed around:

Perhaps you will see the discrepancy -- I just don't see it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably got something to do with the bullshit default bool marshalling rules that nobody wants, although
BizInvoke
should usually get rid of that...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but there is no compatibility in the usage of this struct (just the frame advance call as far as I can see)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, in that case it's getting placed into a class rather than a struct, which has some strange behavior in this regard, since this isn't strictly blittable behavior overall. For saving space and just using bools,
byte
would be used C# side (or maybe rather bit flags if ypu really want to conserve space, which might or might not be wanted since bigger frame info means more GC pressure)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a
uint64_t xdd;
at the start ofstruct gamePad_t
makes it work, so apparently there's 8 extra padding bytes in the c# class somehow. There more I've read into marshalling and blitting the more confused I get as to how things even work in other cores. It's possible everything that is working is just working by pure chance.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be weird mismatch of C# vs C padding rules? In the perspective of marshalling, a lot of usual knowledge doesn't strictly apply per se, since the class instance just gets pinned down and the pointer to such is passed on, so it matters how C# is internally ordering the data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the bool
isReset
is getting tagged onto the baseFrameInfo
before the structs.Using https://github.com/SergeyTeplyakov/ObjectLayoutInspector this is the actual layout:
Full managed memory layout
Having any of the struct's fields be
bool
makes it no longer align for reasons I cannot tell you.