diff --git a/.gitignore b/.gitignore index 2b540361b5..20ffa86c34 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ ExternalCoreProjects/Virtu/bin/*.* libsnes/vs2015/libsnes.VC.db waterbox/**/*.wbx waterbox/**/*.wbx.in +/BizHawkTool_template.zip diff --git a/Assets/EmuHawkMono.sh b/Assets/EmuHawkMono.sh new file mode 100755 index 0000000000..a42a52a5f6 --- /dev/null +++ b/Assets/EmuHawkMono.sh @@ -0,0 +1,18 @@ +#!/bin/sh +cd "$(dirname "$0")" +if [ "$(ps -C "mono" -o "cmd" --no-headers | grep "EmuHawk.exe")" ]; then + echo "EmuHawk is already running, exiting..." + exit 0 +fi +libpath="" +if [ "$(command -v lsb_release)" ]; then + case "$(lsb_release -i | cut -c17- | tr -d "\n")" in + "Arch"|"ManjaroLinux") libpath="/usr/lib/wine";; + "Debian"|"Ubuntu"|"LinuxMint") libpath="/usr/lib/x86_64-linux-gnu/wine";; + esac +fi +if [ -z "$libpath" ]; then + printf "%s\n" "Unknown distro, assuming WINE library location is /usr/lib/wine..." + libpath="/usr/lib/wine" +fi +LD_LIBRARY_PATH="$libpath" mono ./EmuHawk.exe diff --git a/Assets/defctrl.json b/Assets/defctrl.json index 64ab6bdc4a..dabbc31374 100644 --- a/Assets/defctrl.json +++ b/Assets/defctrl.json @@ -1,1499 +1,1529 @@ { - "AllTrollers": { - "LibRetro Controls": { - "P1 RetroPad Up": "UpArrow,J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 RetroPad Down": "DownArrow,J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 RetroPad Left": "LeftArrow,J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 RetroPad Right": "RightArrow,J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 RetroPad Select": "Space, J1 B9, X1 Back", - "P1 RetroPad Start": "Return, J1 B10, X1 Start", - "P1 RetroPad Y": "A, J1 B1, X1 X", - "P1 RetroPad B": "Z, J1 B2, X1 A", - "P1 RetroPad X": "S, J1 B4, X1 Y", - "P1 RetroPad A": "X, J1 B3, X1 B", - "P1 RetroPad L": "W, J1 B5, X1 LeftShoulder", - "P1 RetroPad R": "E, J1 B6, X1 RightShoulder", - "P2 RetroPad Up": "", - "P2 RetroPad Down": "", - "P2 RetroPad Left": "", - "P2 RetroPad Right": "", - "P2 RetroPad Select": "", - "P2 RetroPad Start": "", - "P2 RetroPad Y": "", - "P2 RetroPad B": "", - "P2 RetroPad X": "", - "P2 RetroPad A": "", - "P2 RetroPad L": "", - "P2 RetroPad R": "", - "Pointer Pressed": "WMouse L", - "Key Backspace": "Backspace", - "Key Tab": "Tab", - "Key Clear": "", - "Key Return": "Return", - "Key Pause": "", - "Key Escape": "Escape", - "Key Space": "Space", - "Key Exclaim": "", - "Key QuoteDbl": "", - "Key Hash": "", - "Key Dollar": "", - "Key Ampersand": "", - "Key Quote": "", - "Key LeftParen": "", - "Key RightParen": "", - "Key Asterisk": "", - "Key Plus": "", - "Key Comma": "Comma", - "Key Minus": "Minus", - "Key Period": "Period", - "Key Slash": "Slash", - "Key 0": "D0", - "Key 1": "D1", - "Key 2": "D2", - "Key 3": "D3", - "Key 4": "D4", - "Key 5": "D5", - "Key 6": "D6", - "Key 7": "D7", - "Key 8": "D8", - "Key 9": "D9", - "Key Colon": "", - "Key Semicolon": "Semicolon", - "Key Less": "", - "Key Equals": "Equals", - "Key Greater": "", - "Key Question": "", - "Key At": "", - "Key LeftBracket": "LeftBracket", - "Key Backslash": "Backslash", - "Key RightBracket": "RightBracket", - "Key Caret": "", - "Key Underscore": "", - "Key Backquote": "Grave", - "Key A": "A", - "Key B": "B", - "Key C": "C", - "Key D": "D", - "Key E": "E", - "Key F": "F", - "Key G": "G", - "Key H": "H", - "Key I": "I", - "Key J": "J", - "Key K": "K", - "Key L": "L", - "Key M": "M", - "Key N": "N", - "Key O": "O", - "Key P": "P", - "Key Q": "Q", - "Key R": "R", - "Key S": "S", - "Key T": "T", - "Key U": "U", - "Key V": "V", - "Key W": "W", - "Key X": "X", - "Key Y": "Y", - "Key Z": "Z", - "Key Delete": "Delete", - "Key KP0": "NumberPad0", - "Key KP1": "NumberPad1", - "Key KP2": "NumberPad2", - "Key KP3": "NumberPad3", - "Key KP4": "NumberPad4", - "Key KP5": "NumberPad5", - "Key KP6": "NumberPad6", - "Key KP7": "NumberPad7", - "Key KP8": "NumberPad8", - "Key KP9": "NumberPad9", - "Key KP_Period": "NumberPadPeriod", - "Key KP_Divide": "NumberPadSlash", - "Key KP_Multiply": "NumberPadStar", - "Key KP_Minus": "NumberPadMinus", - "Key KP_Plus": "NumberPadPlus", - "Key KP_Enter": "NumberPadEnter", - "Key KP_Equals": "", - "Key Up": "UpArrow", - "Key Down": "DownArrow", - "Key Left": "LeftArrow", - "Key Insert": "LeftControl", - "Key Home": "Home", - "Key End": "End", - "Key PageUp": "PageUp", - "Key PageDown": "PageDown", - "Key F1": "F1", - "Key F2": "F2", - "Key F3": "F3", - "Key F4": "F4", - "Key F5": "F5", - "Key F6": "F6", - "Key F7": "F7", - "Key F8": "F8", - "Key F9": "F9", - "Key F10": "F10", - "Key F11": "F11", - "Key F12": "F12", - "Key F13": "", - "Key F14": "", - "Key F15": "", - "Key NumLock": "NumberLock", - "Key CapsLock": "CapsLock", - "Key ScrollLock": "ScrollLock", - "Key RShift": "RightShift", - "Key LShift": "LeftShift", - "Key RCtrl": "RightControl", - "Key LCtrl": "LeftControl", - "Key RAlt": "RightAlt", - "Key LAlt": "LeftAlt", - "Key RMeta": "", - "Key LMeta": "", - "Key LSuper": "", - "Key RSuper": "", - "Key Mode": "", - "Key Compose": "", - "Key Help": "", - "Key Print": "", - "Key SysReq": "", - "Key Break": "", - "Key Menu": "Applications", - "Key Power": "", - "Key Euro": "", - "Key Undo": "", - "Key Right": "RightArrow" - }, - "NES Controller": { - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Start": "Return, J1 B10, X1 Start", - "P1 Select": "Space, J1 B9, X1 Back", - "P1 B": "Z, J1 B1, X1 X", - "P1 A": "X, J1 B2, X1 A", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 Start": "", - "P2 Select": "", - "P2 B": "", - "P2 A": "", - "P2 Fire": "WMouse L", - "P2 Microphone": "", - "P3 Fire": "WMouse L", - "Reset": "", - "Power": "" - }, - "SNES Controller": { - "Reset": "", - "Power": "", - "P1 Up": "UpArrow,J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow,J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow,J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow,J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Select": "Space, J1 B9, X1 Back", - "P1 Start": "Return, J1 B10, X1 Start", - "P1 Y": "A, J1 B1, X1 X", - "P1 X": "S, J1 B4, X1 Y", - "P1 B": "Z, J1 B2, X1 A", - "P1 A": "X, J1 B3, X1 B", - "P1 L": "W, J1 B5, X1 LeftShoulder", - "P1 R": "E, J1 B6, X1 RightShoulder", - "P1 Mouse Left": "Z, J1 B1, X1 X", - "P1 Mouse Right": "X, J1 B2, X1 A", - "P2 Trigger": "Z, J1 B1, X1 X", - "P2 Cursor": "X, J1 B2, X1 A", - "P2 Turbo": "A, J1 B3 X1 Y", - "P2 Pause": "S, J1 B4 X1 B" - }, - "Nintento 64 Controller": { - "P1 A Up": "UpArrow, J1 POV1U", - "P1 A Down": "DownArrow, J1 POV1D", - "P1 A Left": "LeftArrow, J1 POV1L", - "P1 A Right": "RightArrow, J1 POV1R", - "P1 DPad U": "X1 DpadUp", - "P1 DPad D": "X1 DpadDown", - "P1 DPad L": "X1 DpadLeft", - "P1 DPad R": "X1 DpadRight", - "P1 Start": "Return, J1 B10, X1 Start", - "P1 Z": "D, J1 B3, X1 B", - "P1 B": "S, J1 B1, X1 X", - "P1 A": "A, J1 B2, X1 A", - "P1 C Up": "NumberPad8, J1 RotationZ-, X1 RStickUp", - "P1 C Down": "NumberPad2, J1 RotationZ+, X1 RStickDown", - "P1 C Left": "NumberPad4, J1 Z-, X1 RStickLeft", - "P1 C Right": "NumberPad6, J1 Z+, X1 RStickRight", - "P1 L": "Q, J1 B5, X1 LeftShoulder", - "P1 R": "W, J1 B6, X1 RightShoulder", - "P2 X Axis": "", - "P2 Y Axis": "", - "P2 A Up": "", - "P2 A Down": "", - "P2 A Left": "", - "P2 A Right": "", - "P2 DPad U": "", - "P2 DPad D": "", - "P2 DPad L": "", - "P2 DPad R": "", - "P2 Start": "", - "P2 Z": "", - "P2 B": "", - "P2 A": "", - "P2 C Up": "", - "P2 C Down": "", - "P2 C Left": "", - "P2 C Right": "", - "P2 L": "", - "P2 R": "", - "P3 X Axis": "", - "P3 Y Axis": "", - "P3 A Up": "", - "P3 A Down": "", - "P3 A Left": "", - "P3 A Right": "", - "P3 DPad U": "", - "P3 DPad D": "", - "P3 DPad L": "", - "P3 DPad R": "", - "P3 Start": "", - "P3 Z": "", - "P3 B": "", - "P3 A": "", - "P3 C Up": "", - "P3 C Down": "", - "P3 C Left": "", - "P3 C Right": "", - "P3 L": "", - "P3 R": "", - "P4 X Axis": "", - "P4 Y Axis": "", - "P4 A Up": "", - "P4 A Down": "", - "P4 A Left": "", - "P4 A Right": "", - "P4 DPad U": "", - "P4 DPad D": "", - "P4 DPad L": "", - "P4 DPad R": "", - "P4 Start": "", - "P4 Z": "", - "P4 B": "", - "P4 A": "", - "P4 C Up": "", - "P4 C Down": "", - "P4 C Left": "", - "P4 C Right": "", - "P4 L": "", - "P4 R": "", - "Reset": "", - "Power": "" - }, - "Gameboy Controller": { - "Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "Start": "Return, J1 B10, X1 Start", - "Select": "Space, J1 B9, X1 Back", - "B": "Z, J1 B1, X1 X", - "A": "X, J1 B2, X1 A", - "Power": "", - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Start": "Return, J1 B10, X1 Start", - "P1 Select": "Space, J1 B9, X1 Back", - "P1 B": "Z, J1 B1, X1 X", - "P1 A": "X, J1 B2, X1 A" - }, - "GBA Controller": { - "Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "Start": "Return, J1 B10, X1 Start", - "Select": "Space, J1 B9, X1 Back", - "B": "Z, J1 B1, X1 X", - "A": "X, J1 B2, X1 A", - "L": "W, J1 B5, X1 LeftShoulder", - "R": "E, J1 B6, X1 RightShoulder", - "Power": "" - }, - "Atari 2600 Basic Controller": { - "Reset": "D, J1 B9, X1 Back", - "Select": "S, J1 B10, X1 Start", - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow,J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow,J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Button": "Z, J1 B1, X1 X", - "P2 Up": "NumberPad8, J1 RotationZ-, X1 RStickUp", - "P2 Down": "NumberPad2, J1 RotationZ+, X1 RStickDown", - "P2 Left": "NumberPad4, J1 Z-, X1 RStickLeft", - "P2 Right": "NumberPad6, J1 Z+, X1 RStickRight", - "P2 Button": "NumberPad1, J1 B2, X1 A" - }, - "Atari 7800 ProLine Joystick Controller": { - "Power": "", - "Reset": "D, J1 B9, X1 Back", - "Select": "S, J1 B10, X1 Start", - "Pause": "", - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Trigger": "Z, J1 B1, X1 X", - "P1 Trigger 2": "X, J1 B2, X1 A", - "P2 Up": "NumberPad8, J1 RotationZ-, X1 RStickUp", - "P2 Down": "NumberPad2, J1 RotationZ+, X1 RStickDown", - "P2 Left": "NumberPad4, J1 Z-, X1 RStickLeft", - "P2 Right": "NumberPad6, J1 Z+, X1 RStickRight", - "P2 Trigger": "NumberPad1, J1 B4, X1 Y", - "P2 Trigger 2": "NumberPad3, J1 B3, X1 B" - }, - "Atari 7800 Joystick Controller": { - "Power": "", - "Reset": "D, J1 B9, X1 Back", - "Select": "S, J1 B10, X1 Start", - "Pause": "", - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Trigger": "Z, J1 B1, X1 X", - "P1 Trigger 2": "X, J1 B2, X1 A", - "P2 Up": "NumberPad8, J1 RotationZ-, X1 RStickUp", - "P2 Down": "NumberPad2, J1 RotationZ+, X1 RStickDown", - "P2 Left": "NumberPad4, J1 Z-, X1 RStickLeft", - "P2 Right": "NumberPad6, J1 Z+, X1 RStickRight", - "P2 Trigger": "NumberPad1, J1 B4, X1 Y" - }, - "Atari 7800 Light Gun Controller": { - "Power": "", - "Reset": "D, J1 B9, X1 Back", - "Select": "S, J1 B10, X1 Start", - "Pause": "", - "P1 Trigger": "WMouse L" - }, - "Atari 7800 Paddle Controller": { - "Power": "", - "Reset": "D, J1 B9, X1 Back", - "Select": "S, J1 B10, X1 Start", - "Pause": "", - "P2 Trigger": "NumberPad1, J1 B4, X1 Y" - }, - "Commodore 64 Controller": { - "P1 Up": "NumberPad8, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "NumberPad2, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "NumberPad4, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "NumberPad6, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Button": "NumberPad1, J1 B1, X1 X", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 Button": "", - "Key F1": "F1", - "Key F3": "F3", - "Key F5": "F5", - "Key F7": "F7", - "Key Left Arrow": "Grave", - "Key 1": "D1", - "Key 2": "D2", - "Key 3": "D3", - "Key 4": "D4", - "Key 5": "D5", - "Key 6": "D6", - "Key 7": "D7", - "Key 8": "D8", - "Key 9": "D9", - "Key 0": "D0", - "Key Plus": "Equals", - "Key Minus": "Minus", - "Key Pound": "Insert", - "Key Clear/Home": "Delete", - "Key Insert/Delete": "Backspace", - "Key Control": "Tab", - "Key Q": "Q", - "Key W": "W", - "Key E": "E", - "Key R": "R", - "Key T": "T", - "Key Y": "Y", - "Key U": "U", - "Key I": "I", - "Key O": "O", - "Key P": "P", - "Key At": "LeftBracket", - "Key Asterisk": "RightBracket", - "Key Up Arrow": "Backslash", - "Key Restore": "", - "Key Run/Stop": "CapsLock", - "Key Lck": "", - "Key A": "A", - "Key S": "S", - "Key D": "D", - "Key F": "F", - "Key G": "G", - "Key H": "H", - "Key J": "J", - "Key K": "K", - "Key L": "L", - "Key Colon": "Semicolon", - "Key Semicolon": "Apostrophe", - "Key Equal": "RightControl", - "Key Return": "Return", - "Key Commodore": "LeftControl", - "Key Left Shift": "LeftShift", - "Key Z": "Z", - "Key X": "X", - "Key C": "C", - "Key V": "V", - "Key B": "B", - "Key N": "N", - "Key M": "M", - "Key Comma": "Comma", - "Key Period": "Period", - "Key Slash": "Slash", - "Key Right Shift": "RightShift", - "Key Cursor Up/Down": "DownArrow", - "Key Cursor Left/Right": "RightArrow", - "Key Space": "Space" - }, - "ZXSpectrum Controller": { - "P1 Up": "NumberPad8, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "NumberPad2, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "NumberPad4, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "NumberPad6, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Button": "NumberPad1, J1 B1, X1 X", - "Key True Video": "", - "Key Inv Video": "", - "Key 1": "D1", - "Key 2": "D2", - "Key 3": "D3", - "Key 4": "D4", - "Key 5": "D5", - "Key 6": "D6", - "Key 7": "D7", - "Key 8": "D8", - "Key 9": "D9", - "Key 0": "D0", - "Key Break": "Delete", - "Key Delete": "Backspace", - "Key Graph": "", - "Key Q": "Q", - "Key W": "W", - "Key E": "E", - "Key R": "R", - "Key T": "T", - "Key Y": "Y", - "Key U": "U", - "Key I": "I", - "Key O": "O", - "Key P": "P", - "Key Extend Mode": "", - "Key Edit": "", - "Key A": "A", - "Key S": "S", - "Key D": "D", - "Key F": "F", - "Key G": "G", - "Key H": "H", - "Key J": "J", - "Key K": "K", - "Key L": "L", - "Key Return": "Return", - "Key Caps Shift": "LeftShift, RightShift", - "Key Caps Lock": "", - "Key Z": "Z", - "Key X": "X", - "Key C": "C", - "Key V": "V", - "Key B": "B", - "Key N": "N", - "Key M": "M", - "Key Period": "Period", - "Key Symbol Shift": "LeftControl, RightControl", - "Key Semi-Colon": "Semicolon", - "Key Inverted-Comma": "", - "Key Left Cursor": "LeftArrow", - "Key Right Cursor": "RightArrow", - "Key Space": "Space", - "Key Up Cursor": "UpArrow", - "Key Down Cursor": "DownArrow", - "Key Comma": "Comma", - "Play Tape": "F1", - "Stop Tape": "F2", - "RTZ Tape": "F3", - "Record Tape": "", - "Key Quote": "Shift+D2", - "Insert Next Tape": "F6", - "Insert Previous Tape": "F5", - "Next Tape Block": "F8", - "Prev Tape Block": "F7", - "Get Tape Status": "F9", - "Insert Next Disk": "F11", - "Insert Previous Disk": "F10", - "Get Disk Status": "F12" - }, - "Intellivision Controller": { - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 L": "Z, J1 B1, X1 X", - "P1 R": "X, J1 B2, X1 A", - "P1 Key0": "NumberPad0", - "P1 Key1": "NumberPad1", - "P1 Key2": "NumberPad2", - "P1 Key3": "NumberPad3", - "P1 Key4": "NumberPad4", - "P1 Key5": "NumberPad5", - "P1 Key6": "NumberPad6", - "P1 Key7": "NumberPad7", - "P1 Key8": "NumberPad9", - "P1 Key9": "NumberPad9", - "P1 Enter": "NumberPadEnter", - "P1 Clear": "NumberPadPeriod", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 L": "", - "P2 R": "", - "P2 Key0": "", - "P2 Key1": "", - "P2 Key2": "", - "P2 Key3": "", - "P2 Key4": "", - "P2 Key5": "", - "P2 Key6": "", - "P2 Key7": "", - "P2 Key8": "", - "P2 Key9": "", - "P2 Enter": "", - "P2 Clear": "" - }, - "PC-FX Controller": { - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 I": "C, J1 B1, X1 X", - "P1 II": "X, J1 B2, X1 A", - "P1 III": "Z, J1 B4, X1 Y", - "P1 IV": "D, J1 B3, X1 B", - "P1 V": "S, J1 B11, X1 X", - "P1 VI": "A, J1 B12, X1 X", - "P1 Select": "Space, J1 B9, X1 Back", - "P1 Run": "Return, J1 B10, X1 Start", - "P1 Mode 1": "", - "P1 Mode 2": "", - "P2 Mouse Left": "NumberPad1", - "P2 Mouse Right": "NumberPad2", - "Power": "", - "Reset": "", - "Previous Disk": "", - "Next Disk": "", - "P2 Mouse Left": "WMouse L", - "P2 Mouse Right": "WMouse R", - }, - "Saturn Controller": { - "Power": "", - "Reset": "", - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Start": "Return, J1 B10, X1 Start", - "P1 X": "D, J1 B3, X1 B", - "P1 Y": "S, J1 B11, X1 X", - "P1 Z": "A, J1 B12, X1 X", - "P1 A": "C, J1 B1, X1 X", - "P1 B": "X, J1 B2, X1 A", - "P1 C": "Z, J1 B4, X1 Y", - "P1 L": "Q, J1 B5, X1 LeftShoulder", - "P1 R": "W, J1 B6, X1 RightShoulder", - "P1 Mouse Left": "WMouse L", - "P1 Mouse Center": "WMouse M", - "P1 Mouse Right": "WMouse R", - "P1 Escape": "Escape", - "P1 F1": "F1", - "P1 F2": "F2", - "P1 F3": "F3", - "P1 F4": "F4", - "P1 F5": "F5", - "P1 F6": "F6", - "P1 F7": "F7", - "P1 F8": "F8", - "P1 F9": "F9", - "P1 F10": "F10", - "P1 F11": "F11", - "P1 F12": "F12", - "P1 Grave`": "Grave", - "P1 1(One)": "D1", - "P1 2": "D2", - "P1 3": "D3", - "P1 4": "D4", - "P1 5": "D5", - "P1 6": "D6", - "P1 7": "D7", - "P1 8": "D8", - "P1 9": "D9", - "P1 0(Zero)": "D0", - "P1 Minus-": "Minus", - "P1 Equals=": "Equals", - "P1 Backslash\\": "Backslash", - "P1 Backspace": "Backspace", - "P1 Tab": "Tab", - "P1 Q": "Q", - "P1 W": "W", - "P1 E": "E", - "P1 R(Key)": "R", - "P1 T": "T", - "P1 Y(Key)": "Y", - "P1 U": "U", - "P1 I": "I", - "P1 O": "O", - "P1 P": "P", - "P1 LeftBracket[": "LeftBracket", - "P1 RightBracket]": "RightBracket", - "P1 Enter": "Return", - "P1 CapsLock": "CapsLock", - "P1 A(Key)": "A", - "P1 S": "S", - "P1 D": "D", - "P1 F": "F", - "P1 G": "G", - "P1 H": "H", - "P1 J": "J", - "P1 K": "K", - "P1 L(Key)": "L", - "P1 Semicolon;": "Semicolon", - "P1 Quote'": "Apostrophe", - "P1 LeftShift": "LeftShift", - "P1 Z(Key)": "Z", - "P1 X(Key)": "X", - "P1 C(Key)": "C", - "P1 V": "V", - "P1 B(Key)": "B", - "P1 N": "N", - "P1 M": "M", - "P1 Comma,": "Comma", - "P1 Period.": "Period", - "P1 Slash/": "Slash", - "P1 RightShift": "RightShift", - "P1 LeftCtrl": "LeftControl", - "P1 LeftAlt": "LeftAlt", - "P1 Space": "Space", - "P1 RightAlt": "RightAlt", - "P1 RightCtrl": "RightControl", - "P1 PrintScreen": "", - "P1 ScrollLock": "ScrollLock", - "P1 Pause": "Pause", - "P1 Insert": "Insert", - "P1 Delete": "Delete", - "P1 Home": "Home", - "P1 End": "End", - "P1 PageUp": "PageUp", - "P1 PageDown": "PageDown", - "P1 Up": "UpArrow", - "P1 Down": "DownArrow", - "P1 CursorLeft": "LeftArrow", - "P1 Right": "RightArrow", - "P1 NumLock": "NumberLock", - "P1 KeypadSlash(Divide)": "NumberPadSlash", - "P1 KeypadAsterisk(Multiply)": "NumberPadStar", - "P1 KeypadMinus": "NumberPadMinus", - "P1 KeypadHome/7": "NumberPad7", - "P1 KeypadUp/8": "NumberPad8", - "P1 KeypadPageup/9": "NumberPad9", - "P1 KeypadPlus": "NumberPadPlus", - "P1 KeypadLeft/4": "NumberPad4", - "P1 KeypadCenter/5": "NumberPad5", - "P1 KeypadRight/6": "NumberPad6", - "P1 KeypadEnd/1": "NumberPad1", - "P1 KeypadDown/2": "NumberPad2", - "P1 KeypadPagedown/3": "NumberPad3", - "P1 KeypadEnter": "NumberPadEnter", - "P1 KeypadInsert/0": "NumberPad0", - "P1 KeypadDelete": "NumberPadPeriod" - }, - "PC Engine Controller": { - "Reset": "", - "Power": "", - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 B2": "Z, J1 B1, X1 X", - "P1 B1": "X, J1 B2, X1 A", - "P1 Select": "V, J1 B9, X1 Back", - "P1 Run": "Return, J1 B10, X1 Start", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 B1": "", - "P2 B2": "", - "P2 Select": "", - "P2 Run": "", - "P3 Up": "", - "P3 Down": "", - "P3 Left": "", - "P3 Right": "", - "P3 B1": "", - "P3 B2": "", - "P3 Select": "", - "P3 Run": "", - "P4 Up": "", - "P4 Down": "", - "P4 Left": "", - "P4 Right": "", - "P4 B1": "", - "P4 B2": "", - "P4 Select": "", - "P4 Run": "", - "P5 Up": "", - "P5 Down": "", - "P5 Left": "", - "P5 Right": "", - "P5 B1": "", - "P5 B2": "", - "P5 Select": "", - "P5 Run": "" - }, - "ColecoVision Basic Controller": { - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 L": "Z, J1 B5, X1 LeftShoulder", - "P1 R": "X, J1 B6, X1 RightShoulder", - "P1 Key 1": "NumberPad1, J1 B1, X1 X", - "P1 Key 2": "NumberPad2, J1 B2, X1 A", - "P1 Key 3": "NumberPad3, J1 B3, X1 B", - "P1 Key 4": "NumberPad4, J1 B4, X1 Y", - "P1 Key 5": "NumberPad5, J1 RotationZ-, X1 RStickUp", - "P1 Key 6": "NumberPad6, J1 RotationZ+, X1 RStickDown", - "P1 Key 7": "NumberPad7, J1 Z-, X1 RStickLeft", - "P1 Key 8": "NumberPad8, J1 Z+, X1 RStickRight", - "P1 Key 9": "NumberPad9, J1 B11, X1 LeftThumb", - "P1 Star": "NumberPadEnter, J1 B9, X1 Back", - "P1 Key 0": "NumberPad0, J1 B12, X1 RightThumb", - "P1 Pound": "NumberPadPeriod, J1 B10, X1 Start", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 L": "", - "P2 R": "", - "P2 Key1": "", - "P2 Key2": "", - "P2 Key3": "", - "P2 Key4": "", - "P2 Key5": "", - "P2 Key6": "", - "P2 Key7": "", - "P2 Key8": "", - "P2 Key9": "", - "P2 Star": "", - "P2 Key0": "", - "P2 Pound": "" - }, - "SMS Controller": { - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 B1": "Z, J1 B1, X1 X", - "P1 B2": "X, J1 B2, X1 A", - "Reset": "J1 B9, X1 Back", - "Pause": "J1 B10, X1 Start", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 B1": "", - "P2 B2": "" - }, - "SMS Paddle Controller": { - "P1 Left": "LeftArrow, J1 POV1L", - "P1 Right": "RightArrow, J1 POV1R", - "P1 B1": "Z, J1 B1, X1 X", - "Reset": "J1 B9, X1 Back", - "Pause": "J1 B10, X1 Start" - }, - "SMS Light Phaser Controller": { - "P1 Trigger": "Z, J1 B1, X1 X, WMouse L", - "Reset": "J1 B9, X1 Back", - "Pause": "J1 B10, X1 Start" - }, - "SMS Sports Pad Controller": { - "P1 Up": "UpArrow, J1 POV1U", - "P1 Down": "DownArrow, J1 POV1D", - "P1 Left": "LeftArrow, J1 POV1L", - "P1 Right": "RightArrow, J1 POV1R", - "P1 B1": "Z, J1 B1, X1 X", - "P1 B2": "X, J1 B2, X1 A", - "Reset": "J1 B9, X1 Back", - "Pause": "J1 B10, X1 Start", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 B1": "", - "P2 B2": "" - }, - "SMS Keyboard Controller": { - "Key 1": "D1", - "Key 2": "D2", - "Key 3": "D3", - "Key 4": "D4", - "Key 5": "D5", - "Key 6": "D6", - "Key 7": "D7", - "Key 8": "D8", - "Key 9": "D9", - "Key 0": "D0", - "Key Minus": "Minus", - "Key Caret": "Equals", - "Key Yen": "Backspace", - "Key Break": "Delete", - - "Key Function": "Tab", - "Key Q": "Q", - "Key W": "W", - "Key E": "E", - "Key R": "R", - "Key T": "T", - "Key Y": "Y", - "Key U": "U", - "Key I": "I", - "Key O": "O", - "Key P": "P", - "Key At": "LeftBracket", - "Key Left Bracket": "RightBracket", - "Key Return": "Return", - "Key Up Arrow": "UpArrow", - - "Key Control": "CapsLock", - "Key A": "A", - "Key S": "S", - "Key D": "D", - "Key F": "F", - "Key G": "G", - "Key H": "H", - "Key J": "J", - "Key K": "K", - "Key L": "L", - "Key Semicolon": "Semicolon", - "Key Colon": "Apostrophe", - "Key Right Bracket": "Backslash", - "Key Left Arrow": "LeftArrow", - "Key Right Arrow": "RightArrow", - - "Key Shift": "LeftShift", - "Key Z": "Z", - "Key X": "X", - "Key C": "C", - "Key V": "V", - "Key B": "B", - "Key N": "N", - "Key M": "M", - "Key Comma": "Comma", - "Key Period": "Period", - "Key Slash": "Slash", - "Key PI": "RightShift", - "Key Down Arrow": "DownArrow", - - "Key Graph": "PageUp", - "Key Kana": "PageDown", - "Key Space": "Space", - "Key Home/Clear": "Home", - "Key Insert/Delete": "Insert", - - "P1 Up": "J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 B1": "J1 B1, X1 X", - "P1 B2": "J1 B2, X1 A", - "Reset": "J1 B9, X1 Back", - "Pause": "J1 B10, X1 Start", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 B1": "", - "P2 B2": "" - }, - "GG Controller": { - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 B1": "Z, J1 B1, X1 X", - "P1 B2": "X, J1 B2, X1 A", - "Reset": "J1 B9, X1 Back", - "P1 Start": "Return, J1 B10, X1 Start" - }, - "Dual Gameboy Controller": { - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Start": "Return, J1 B10, X1 Start", - "P1 Select": "Space, J1 B9, X1 Space", - "P1 B": "Z, J1 B1, X1 X", - "P1 A": "X, J1 B2, X1 A", - "P1 Power": "", - "P2 Up": "NumberPad8, J1 RotationZ-, X1 RStickUp", - "P2 Down": "NumberPad2, J1 RotationZ+, X1 RStickDown", - "P2 Left": "NumberPad4, J1 Z-, X1 RStickLeft", - "P2 Right": "NumberPad6, J1 Z+, X1 RStickRight", - "P2 Start": "RightBracket, J1 B5, X1 LeftShoulder", - "P2 Select": "LeftBracket, J1 B6, X1 RightShoulder", - "P2 B": "C, J1 B4, X1 Y", - "P2 A": "V, J1 B3, X1 B", - "P2 Power": "" - }, - "TI83 Controller": { - "0": "NumberPad0", - "1": "NumberPad1", - "2": "NumberPad2", - "3": "NumberPad3", - "4": "NumberPad4", - "5": "NumberPad5", - "6": "NumberPad6", - "7": "NumberPad7", - "8": "NumberPad8", - "9": "NumberPad9", - "DOT": "NumberPadPeriod", - "ON": "Space", - "ENTER": "Return, NumberPadEnter", - "DOWN": "DownArrow", - "UP": "UpArrow", - "LEFT": "LeftArrow", - "RIGHT": "RightArrow", - "PLUS": "NumberPadPlus", - "MINUS": "NumberPadMinus", - "MULTIPLY": "NumberPadStar", - "DIVIDE": "NumberPadSlash", - "CLEAR": "Escape", - "EXP": "6", - "DASH": "Minus", - "PARACLOSE": "0", - "TAN": "T", - "VARS": "V", - "PARAOPEN": "9", - "COS": "C", - "PRGM": "R", - "STAT": "S", - "SIN": "Period", - "MATRIX": "LeftBracket", - "X": "X", - "STO": "Insert", - "LN": "L", - "LOG": "O", - "SQUARED": "2", - "NEG1": "1", - "MATH": "M", - "ALPHA": "A", - "GRAPH": "G", - "TRACE": "Home", - "ZOOM": "Z", - "WINDOW": "W", - "Y": "Y", - "SECOND": "Slash", - "MODE": "BackSlash", - "DEL": "Delete", - "COMMA": "Comma" - }, - "GPGX Genesis Controller": { - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 A": "Z, J1 B1, X1 X", - "P1 B": "X, J1 B2, X1 A", - "P1 C": "C, J1 B4, X1 Y", - "P1 Start": "Return, J1 B10, X1 Start", - "P1 X": "A, J1 B3, X1 B", - "P1 Y": "S, J1 B5, X1 LeftShoulder", - "P1 Z": "D, J1 B6, X1 RightShoulder", - "P1 Mode": "E, J1 B9, X1 Back", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 A": "", - "P2 B": "", - "P2 C": "", - "P2 Start": "", - "P2 X": "", - "P2 Y": "", - "P2 Z": "", - "P2 Mode": "", - "P2 Lightgun Trigger": "WMouse L", - "P2 Lightgun Start": "NumberPad5", - "P2 Mouse Left": "WMouse L", - "P2 Mouse Center": "WMouse M", - "P2 Mouse Right": "WMouse R", - "P2 Mouse Start": "NumberPad5", - "Power": "", - "Reset": "" - }, - "PicoDrive Genesis Controller": { - "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 A": "Z, J1 B1, X1 X", - "P1 B": "X, J1 B2, X1 A", - "P1 C": "C, J1 B4, X1 Y", - "P1 Start": "Return, J1 B10, X1 Start", - "P1 X": "A, J1 B3, X1 B", - "P1 Y": "S, J1 B5, X1 LeftShoulder", - "P1 Z": "D, J1 B6, X1 RightShoulder", - "P1 Mode": "E, J1 B9, X1 Back", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 A": "", - "P2 B": "", - "P2 C": "", - "P2 Start": "", - "P2 X": "", - "P2 Y": "", - "P2 Z": "", - "P2 Mode": "", - "Power": "", - "Reset": "" - }, - "WonderSwan Controller": { - "P1 X1": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P1 X3": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P1 X4": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P1 X2": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P1 Y1": "NumberPad8, J1 RotationZ-, X1 RStickUp", - "P1 Y3": "NumberPad2, J1 RotationZ+, X1 RStickDown", - "P1 Y4": "NumberPad4, J1 Z-, X1 RStickLeft", - "P1 Y2": "NumberPad6, J1 Z+, X1 RStickRight", - "P1 Start": "Return, J1 B10, X1 Start", - "P1 B": "Z, J1 B1, X1 X", - "P1 A": "X, J1 B2, X1 A", - "P2 X1": "", - "P2 X3": "X, J1 B2, X1 A", - "P2 X4": "Z, J1 B1, X1 X", - "P2 X2": "", - "P2 Y1": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", - "P2 Y3": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", - "P2 Y4": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", - "P2 Y2": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", - "P2 Start": "Return, J1 B10, X1 Start", - "P2 B": "", - "P2 A": "", - "Power": "" - }, - "PSX DualShock Controller": { - "P1 Up": "X1 DpadUp,UpArrow", - "P1 Down": "X1 DpadDown,DownArrow", - "P1 Left": "X1 DpadLeft,LeftArrow", - "P1 Right": "X1 DpadRight,RightArrow", - "P1 Select": "X1 Back,Space", - "P1 Start": "X1 Start,Return", - "P1 Square": "X1 X,A", - "P1 Triangle": "X1 Y,S", - "P1 Circle": "X1 B,X", - "P1 Cross": "X1 A,Z", - "P1 L1": "X1 LeftShoulder,Q", - "P1 R1": "X1 RightShoulder,W", - "P1 L2": "X1 LeftTrigger,E", - "P1 R2": "X1 RightTrigger,R", - "P1 L3": "X1 LeftThumb,T", - "P1 R3": "X1 RightThumb,Y", - "P1 MODE": "D" - }, - "Lynx Controller": { - "Up": "UpArrow", - "Down": "DownArrow", - "Left": "LeftArrow", - "Right": "RightArrow", - "A": "X", - "B": "Z", - "Option 1": "A", - "Option 2": "S", - "Pause": "Return", - "Power": "" - }, - "Apple IIe Keyboard": { - "Delete": "Delete", - "Left": "LeftArrow", - "Tab": "Tab", - "Down": "DownArrow", - "Up": "UpArrow", - "Return": "Return", - "Right": "RightArrow", - "Escape": "", - "Space": "Space", - "'": "Apostrophe", - ",": "Comma", - "-": "Minus", - ".": "Period", - "/": "Slash", - "0": "NumberPad0", - "1": "NumberPad1", - "2": "NumberPad2", - "3": "NumberPad3", - "4": "NumberPad4", - "5": "NumberPad5", - "6": "NumberPad6", - "7": "NumberPad7", - "8": "NumberPad8", - "9": "NumberPad9", - ";": "Semicolon", - "=": "Equals", - "[": "LeftBracket", - "\\": "Backslash", - "]": "RightBracket", - "`": "Grave", - "A": "A", - "B": "B", - "C": "C", - "D": "D", - "E": "E", - "F": "F", - "G": "G", - "H": "H", - "I": "I", - "J": "J", - "K": "K", - "L": "L", - "M": "M", - "N": "N", - "O": "O", - "P": "P", - "Q": "Q", - "R": "R", - "S": "S", - "T": "T", - "U": "U", - "V": "V", - "W": "W", - "X": "X", - "Y": "Y", - "Z": "Z", - "Control": "RightControl", - "Shift": "RightShift", - "Caps Lock": "CapsLock", - "Previous Disk": "", - "Next Disk": "" - }, - "VirtualBoy Controller": { - "L_Up": "UpArrow, X1 DpadUp, X1 LStickUp", - "L_Down": "DownArrow, X1 DpadDown, X1 LStickDown", - "L_Left": "LeftArrow, X1 DpadLeft, X1 LStickLeft", - "L_Right": "RightArrow, X1 DpadRight, X1 LStickRight", - "R_Up": "NumberPad8, X1 RStickUp", - "R_Down": "NumberPad2, X1 RStickDown", - "R_Left": "NumberPad4, X1 RStickLeft", - "R_Right": "NumberPad6, X1 RStickRight", - "B": "Z, X1 X", - "A": "X, X1 A", - "R": "W, X1 LeftShoulder", - "L": "E, X1 RightShoulder", - "Select": "Space, X1 Back", - "Start": "Return, X1 Start", - "Power": "" - }, - "NeoGeo Portable Controller": { - "Up": "UpArrow, X1 DpadUp, X1 LStickUp", - "Down": "DownArrow, X1 DpadDown, X1 LStickDown", - "Left": "LeftArrow, X1 DpadLeft, X1 LStickLeft", - "Right": "RightArrow, X1 DpadRight, X1 LStickRight", - "B": "Z, J1 B1, X1 X", - "A": "X, J1 B2, X1 A", - "Option": "Return, J1 B10, X1 Start", - "Power": "" - } - }, - "AllTrollersAutoFire": { - "NES Controller": { - "P1 Up": "", - "P1 Down": "", - "P1 Left": "", - "P1 Right": "", - "P1 Start": "", - "P1 Select": "", - "P1 B": "A", - "P1 A": "S", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 Start": "", - "P2 Select": "", - "P2 B": "", - "P2 A": "", - "P2 Fire": "", - "P2 Microphone": "", - "P3 Fire": "", - "Reset": "", - "Power": "" - }, - "Gameboy Controller": { - "Up": "", - "Down": "", - "Left": "", - "Right": "", - "Start": "", - "Select": "", - "B": "A", - "A": "S", - "Power": "" - }, - "GBAController": { - "Up": "", - "Down": "", - "Left": "", - "Right": "", - "Start": "", - "Select": "", - "B": "A", - "A": "S", - "L": "", - "R": "", - "Power": "" - }, - "Atari 2600 Basic Controller": { - "Reset": "", - "Select": "", - "P1 Up": "", - "P1 Down": "", - "P1 Left": "", - "P1 Right": "", - "P1 Button": "A", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 Button": "S" - }, - "PC Engine Controller": { - "Reset": "", - "Power": "", - "P1 Up": "", - "P1 Down": "", - "P1 Left": "", - "P1 Right": "", - "P1 B2": "A", - "P1 B1": "S", - "P1 Select": "", - "P1 Run": "", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 B2": "", - "P2 B1": "", - "P2 Select": "", - "P2 Run": "", - "P3 Up": "", - "P3 Down": "", - "P3 Left": "", - "P3 Right": "", - "P3 B2": "", - "P3 B1": "", - "P3 Select": "", - "P3 Run": "", - "P4 Up": "", - "P4 Down": "", - "P4 Left": "", - "P4 Right": "", - "P4 B2": "", - "P4 B1": "", - "P4 Select": "", - "P4 Run": "", - "P5 Up": "", - "P5 Down": "", - "P5 Left": "", - "P5 Right": "", - "P5 B2": "", - "P5 B1": "", - "P5 Select": "", - "P5 Run": "" - }, - "SMS Controller": { - "P1 Up": "", - "P1 Down": "", - "P1 Left": "", - "P1 Right": "", - "P1 B1": "A", - "P1 B2": "S", - "Reset": "", - "Pause": "", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 B1": "", - "P2 B2": "" - }, - "GPGX Genesis Controller": { - "P1 Up": "", - "P1 Down": "", - "P1 Left": "", - "P1 Right": "", - "P1 A": "", - "P1 B": "", - "P1 C": "", - "P1 Start": "", - "P1 X": "", - "P1 Y": "", - "P1 Z": "", - "P1 Mode": "", - "P2 Up": "", - "P2 Down": "", - "P2 Left": "", - "P2 Right": "", - "P2 A": "", - "P2 B": "", - "P2 C": "", - "P2 Start": "", - "P2 X": "", - "P2 Y": "", - "P2 Z": "", - "P2 Mode": "", - "Power": "", - "Reset": "" - }, - "GBA Controller": { - "Up": "", - "Down": "", - "Left": "", - "Right": "", - "Start": "", - "Select": "", - "B": "A", - "A": "S", - "L": "", - "R": "", - "Power": "" - }, - "WonderSwan Controller": { - "P1 B": "A", - "P1 A": "S", - "P2 X4": "A", - "P2 X3": "S", - "Power": "" - }, - "Lynx Controller": { - "Up": "", - "Down": "", - "Left": "", - "Right": "", - "A": "", - "B": "", - "Option 1": "", - "Option 2": "", - "Pause": "", - "Power": "" - }, - "Apple IIe Keyboard": { - "Delete": "", - "Left": "", - "Tab": "", - "Down": "", - "Up": "", - "Return": "Return", - "Right": "", - "Escape": "", - "Space": "", - "'": "", - ",": "", - "-": "", - ".": "", - "/": "", - "0": "", - "1": "", - "2": "", - "3": "", - "4": "", - "5": "", - "6": "", - "7": "", - "8": "", - "9": "", - ";": "", - "=": "", - "[": "", - "\\": "", - "]": "", - "`": "", - "A": "", - "B": "", - "C": "", - "D": "", - "E": "", - "F": "", - "G": "", - "H": "", - "I": "", - "J": "", - "K": "", - "L": "", - "M": "", - "N": "", - "O": "", - "P": "", - "Q": "", - "R": "", - "S": "", - "T": "", - "U": "", - "V": "", - "W": "", - "X": "", - "Y": "", - "Z": "", - "Control": "", - "Shift": "", - "Caps Lock": "", - "Previous Disk": "", - "Next Disk": "" - }, - "VirtualBoy Controller": { - "L_Up": "", - "L_Down": "", - "L_Left": "", - "L_Right": "", - "R_Up": "", - "R_Down": "", - "R_Left": "", - "R_Right": "", - "B": "", - "A": "", - "R": "", - "L": "", - "Select": "", - "Start": "", - "Power": "" - }, - "NeoGeo Portable Controller": { - "Up": "", - "Down": "", - "Left": "", - "Right": "", - "B": "", - "A": "", - "Option": "", - "Power": "" - } - }, + "AllTrollers": { + "LibRetro Controls": { + "P1 RetroPad Up": "UpArrow,J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 RetroPad Down": "DownArrow,J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 RetroPad Left": "LeftArrow,J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 RetroPad Right": "RightArrow,J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 RetroPad Select": "Space, J1 B9, X1 Back", + "P1 RetroPad Start": "Return, J1 B10, X1 Start", + "P1 RetroPad Y": "A, J1 B1, X1 X", + "P1 RetroPad B": "Z, J1 B2, X1 A", + "P1 RetroPad X": "S, J1 B4, X1 Y", + "P1 RetroPad A": "X, J1 B3, X1 B", + "P1 RetroPad L": "W, J1 B5, X1 LeftShoulder", + "P1 RetroPad R": "E, J1 B6, X1 RightShoulder", + "P2 RetroPad Up": "", + "P2 RetroPad Down": "", + "P2 RetroPad Left": "", + "P2 RetroPad Right": "", + "P2 RetroPad Select": "", + "P2 RetroPad Start": "", + "P2 RetroPad Y": "", + "P2 RetroPad B": "", + "P2 RetroPad X": "", + "P2 RetroPad A": "", + "P2 RetroPad L": "", + "P2 RetroPad R": "", + "Pointer Pressed": "WMouse L", + "Key Backspace": "Backspace", + "Key Tab": "Tab", + "Key Clear": "", + "Key Return": "Return", + "Key Pause": "", + "Key Escape": "Escape", + "Key Space": "Space", + "Key Exclaim": "", + "Key QuoteDbl": "", + "Key Hash": "", + "Key Dollar": "", + "Key Ampersand": "", + "Key Quote": "", + "Key LeftParen": "", + "Key RightParen": "", + "Key Asterisk": "", + "Key Plus": "", + "Key Comma": "Comma", + "Key Minus": "Minus", + "Key Period": "Period", + "Key Slash": "Slash", + "Key 0": "D0", + "Key 1": "D1", + "Key 2": "D2", + "Key 3": "D3", + "Key 4": "D4", + "Key 5": "D5", + "Key 6": "D6", + "Key 7": "D7", + "Key 8": "D8", + "Key 9": "D9", + "Key Colon": "", + "Key Semicolon": "Semicolon", + "Key Less": "", + "Key Equals": "Equals", + "Key Greater": "", + "Key Question": "", + "Key At": "", + "Key LeftBracket": "LeftBracket", + "Key Backslash": "Backslash", + "Key RightBracket": "RightBracket", + "Key Caret": "", + "Key Underscore": "", + "Key Backquote": "Grave", + "Key A": "A", + "Key B": "B", + "Key C": "C", + "Key D": "D", + "Key E": "E", + "Key F": "F", + "Key G": "G", + "Key H": "H", + "Key I": "I", + "Key J": "J", + "Key K": "K", + "Key L": "L", + "Key M": "M", + "Key N": "N", + "Key O": "O", + "Key P": "P", + "Key Q": "Q", + "Key R": "R", + "Key S": "S", + "Key T": "T", + "Key U": "U", + "Key V": "V", + "Key W": "W", + "Key X": "X", + "Key Y": "Y", + "Key Z": "Z", + "Key Delete": "Delete", + "Key KP0": "NumberPad0", + "Key KP1": "NumberPad1", + "Key KP2": "NumberPad2", + "Key KP3": "NumberPad3", + "Key KP4": "NumberPad4", + "Key KP5": "NumberPad5", + "Key KP6": "NumberPad6", + "Key KP7": "NumberPad7", + "Key KP8": "NumberPad8", + "Key KP9": "NumberPad9", + "Key KP_Period": "NumberPadPeriod", + "Key KP_Divide": "NumberPadSlash", + "Key KP_Multiply": "NumberPadStar", + "Key KP_Minus": "NumberPadMinus", + "Key KP_Plus": "NumberPadPlus", + "Key KP_Enter": "NumberPadEnter", + "Key KP_Equals": "", + "Key Up": "UpArrow", + "Key Down": "DownArrow", + "Key Left": "LeftArrow", + "Key Insert": "LeftControl", + "Key Home": "Home", + "Key End": "End", + "Key PageUp": "PageUp", + "Key PageDown": "PageDown", + "Key F1": "F1", + "Key F2": "F2", + "Key F3": "F3", + "Key F4": "F4", + "Key F5": "F5", + "Key F6": "F6", + "Key F7": "F7", + "Key F8": "F8", + "Key F9": "F9", + "Key F10": "F10", + "Key F11": "F11", + "Key F12": "F12", + "Key F13": "", + "Key F14": "", + "Key F15": "", + "Key NumLock": "NumberLock", + "Key CapsLock": "CapsLock", + "Key ScrollLock": "ScrollLock", + "Key RShift": "RightShift", + "Key LShift": "LeftShift", + "Key RCtrl": "RightControl", + "Key LCtrl": "LeftControl", + "Key RAlt": "RightAlt", + "Key LAlt": "LeftAlt", + "Key RMeta": "", + "Key LMeta": "", + "Key LSuper": "", + "Key RSuper": "", + "Key Mode": "", + "Key Compose": "", + "Key Help": "", + "Key Print": "", + "Key SysReq": "", + "Key Break": "", + "Key Menu": "Applications", + "Key Power": "", + "Key Euro": "", + "Key Undo": "", + "Key Right": "RightArrow" + }, + "NES Controller": { + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Start": "Return, J1 B10, X1 Start", + "P1 Select": "Space, J1 B9, X1 Back", + "P1 B": "Z, J1 B1, X1 X", + "P1 A": "X, J1 B2, X1 A", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 Start": "", + "P2 Select": "", + "P2 B": "", + "P2 A": "", + "P2 Fire": "WMouse L", + "P2 Microphone": "", + "P3 Fire": "WMouse L", + "Reset": "", + "Power": "" + }, + "SNES Controller": { + "Reset": "", + "Power": "", + "P1 Up": "UpArrow,J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow,J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow,J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow,J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Select": "Space, J1 B9, X1 Back", + "P1 Start": "Return, J1 B10, X1 Start", + "P1 Y": "A, J1 B1, X1 X", + "P1 X": "S, J1 B4, X1 Y", + "P1 B": "Z, J1 B2, X1 A", + "P1 A": "X, J1 B3, X1 B", + "P1 L": "W, J1 B5, X1 LeftShoulder", + "P1 R": "E, J1 B6, X1 RightShoulder", + "P1 Mouse Left": "Z, J1 B1, X1 X", + "P1 Mouse Right": "X, J1 B2, X1 A", + "P2 Trigger": "Z, J1 B1, X1 X", + "P2 Cursor": "X, J1 B2, X1 A", + "P2 Turbo": "A, J1 B3 X1 Y", + "P2 Pause": "S, J1 B4 X1 B" + }, + "Nintento 64 Controller": { + "P1 A Up": "UpArrow, J1 POV1U", + "P1 A Down": "DownArrow, J1 POV1D", + "P1 A Left": "LeftArrow, J1 POV1L", + "P1 A Right": "RightArrow, J1 POV1R", + "P1 DPad U": "X1 DpadUp", + "P1 DPad D": "X1 DpadDown", + "P1 DPad L": "X1 DpadLeft", + "P1 DPad R": "X1 DpadRight", + "P1 Start": "Return, J1 B10, X1 Start", + "P1 Z": "D, J1 B3, X1 B", + "P1 B": "S, J1 B1, X1 X", + "P1 A": "A, J1 B2, X1 A", + "P1 C Up": "NumberPad8, J1 RotationZ-, X1 RStickUp", + "P1 C Down": "NumberPad2, J1 RotationZ+, X1 RStickDown", + "P1 C Left": "NumberPad4, J1 Z-, X1 RStickLeft", + "P1 C Right": "NumberPad6, J1 Z+, X1 RStickRight", + "P1 L": "Q, J1 B5, X1 LeftShoulder", + "P1 R": "W, J1 B6, X1 RightShoulder", + "P2 X Axis": "", + "P2 Y Axis": "", + "P2 A Up": "", + "P2 A Down": "", + "P2 A Left": "", + "P2 A Right": "", + "P2 DPad U": "", + "P2 DPad D": "", + "P2 DPad L": "", + "P2 DPad R": "", + "P2 Start": "", + "P2 Z": "", + "P2 B": "", + "P2 A": "", + "P2 C Up": "", + "P2 C Down": "", + "P2 C Left": "", + "P2 C Right": "", + "P2 L": "", + "P2 R": "", + "P3 X Axis": "", + "P3 Y Axis": "", + "P3 A Up": "", + "P3 A Down": "", + "P3 A Left": "", + "P3 A Right": "", + "P3 DPad U": "", + "P3 DPad D": "", + "P3 DPad L": "", + "P3 DPad R": "", + "P3 Start": "", + "P3 Z": "", + "P3 B": "", + "P3 A": "", + "P3 C Up": "", + "P3 C Down": "", + "P3 C Left": "", + "P3 C Right": "", + "P3 L": "", + "P3 R": "", + "P4 X Axis": "", + "P4 Y Axis": "", + "P4 A Up": "", + "P4 A Down": "", + "P4 A Left": "", + "P4 A Right": "", + "P4 DPad U": "", + "P4 DPad D": "", + "P4 DPad L": "", + "P4 DPad R": "", + "P4 Start": "", + "P4 Z": "", + "P4 B": "", + "P4 A": "", + "P4 C Up": "", + "P4 C Down": "", + "P4 C Left": "", + "P4 C Right": "", + "P4 L": "", + "P4 R": "", + "Reset": "", + "Power": "" + }, + "Gameboy Controller": { + "Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "Start": "Return, J1 B10, X1 Start", + "Select": "Space, J1 B9, X1 Back", + "B": "Z, J1 B1, X1 X", + "A": "X, J1 B2, X1 A", + "Power": "", + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Start": "Return, J1 B10, X1 Start", + "P1 Select": "Space, J1 B9, X1 Back", + "P1 B": "Z, J1 B1, X1 X", + "P1 A": "X, J1 B2, X1 A" + }, + "Gameboy Controller H": { + "Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "Start": "Return, J1 B10, X1 Start", + "Select": "Space, J1 B9, X1 Back", + "B": "Z, J1 B1, X1 X", + "A": "X, J1 B2, X1 A", + "Power": "", + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Start": "Return, J1 B10, X1 Start", + "P1 Select": "Space, J1 B9, X1 Back", + "P1 B": "Z, J1 B1, X1 X", + "P1 A": "X, J1 B2, X1 A" + }, + "GBA Controller": { + "Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "Start": "Return, J1 B10, X1 Start", + "Select": "Space, J1 B9, X1 Back", + "B": "Z, J1 B1, X1 X", + "A": "X, J1 B2, X1 A", + "L": "W, J1 B5, X1 LeftShoulder", + "R": "E, J1 B6, X1 RightShoulder", + "Power": "" + }, + "Atari 2600 Basic Controller": { + "Reset": "D, J1 B9, X1 Back", + "Select": "S, J1 B10, X1 Start", + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow,J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow,J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Button": "Z, J1 B1, X1 X", + "P2 Up": "NumberPad8, J1 RotationZ-, X1 RStickUp", + "P2 Down": "NumberPad2, J1 RotationZ+, X1 RStickDown", + "P2 Left": "NumberPad4, J1 Z-, X1 RStickLeft", + "P2 Right": "NumberPad6, J1 Z+, X1 RStickRight", + "P2 Button": "NumberPad1, J1 B2, X1 A" + }, + "Atari 7800 ProLine Joystick Controller": { + "Power": "", + "Reset": "D, J1 B9, X1 Back", + "Select": "S, J1 B10, X1 Start", + "Pause": "", + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Trigger": "Z, J1 B1, X1 X", + "P1 Trigger 2": "X, J1 B2, X1 A", + "P2 Up": "NumberPad8, J1 RotationZ-, X1 RStickUp", + "P2 Down": "NumberPad2, J1 RotationZ+, X1 RStickDown", + "P2 Left": "NumberPad4, J1 Z-, X1 RStickLeft", + "P2 Right": "NumberPad6, J1 Z+, X1 RStickRight", + "P2 Trigger": "NumberPad1, J1 B4, X1 Y", + "P2 Trigger 2": "NumberPad3, J1 B3, X1 B" + }, + "Atari 7800 Joystick Controller": { + "Power": "", + "Reset": "D, J1 B9, X1 Back", + "Select": "S, J1 B10, X1 Start", + "Pause": "", + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Trigger": "Z, J1 B1, X1 X", + "P1 Trigger 2": "X, J1 B2, X1 A", + "P2 Up": "NumberPad8, J1 RotationZ-, X1 RStickUp", + "P2 Down": "NumberPad2, J1 RotationZ+, X1 RStickDown", + "P2 Left": "NumberPad4, J1 Z-, X1 RStickLeft", + "P2 Right": "NumberPad6, J1 Z+, X1 RStickRight", + "P2 Trigger": "NumberPad1, J1 B4, X1 Y" + }, + "Atari 7800 Light Gun Controller": { + "Power": "", + "Reset": "D, J1 B9, X1 Back", + "Select": "S, J1 B10, X1 Start", + "Pause": "", + "P1 Trigger": "WMouse L" + }, + "Atari 7800 Paddle Controller": { + "Power": "", + "Reset": "D, J1 B9, X1 Back", + "Select": "S, J1 B10, X1 Start", + "Pause": "", + "P2 Trigger": "NumberPad1, J1 B4, X1 Y" + }, + "Commodore 64 Controller": { + "P1 Up": "NumberPad8, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "NumberPad2, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "NumberPad4, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "NumberPad6, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Button": "NumberPad1, J1 B1, X1 X", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 Button": "", + "Key F1": "F1", + "Key F3": "F3", + "Key F5": "F5", + "Key F7": "F7", + "Key Left Arrow": "Grave", + "Key 1": "D1", + "Key 2": "D2", + "Key 3": "D3", + "Key 4": "D4", + "Key 5": "D5", + "Key 6": "D6", + "Key 7": "D7", + "Key 8": "D8", + "Key 9": "D9", + "Key 0": "D0", + "Key Plus": "Equals", + "Key Minus": "Minus", + "Key Pound": "Insert", + "Key Clear/Home": "Delete", + "Key Insert/Delete": "Backspace", + "Key Control": "Tab", + "Key Q": "Q", + "Key W": "W", + "Key E": "E", + "Key R": "R", + "Key T": "T", + "Key Y": "Y", + "Key U": "U", + "Key I": "I", + "Key O": "O", + "Key P": "P", + "Key At": "LeftBracket", + "Key Asterisk": "RightBracket", + "Key Up Arrow": "Backslash", + "Key Restore": "", + "Key Run/Stop": "CapsLock", + "Key Lck": "", + "Key A": "A", + "Key S": "S", + "Key D": "D", + "Key F": "F", + "Key G": "G", + "Key H": "H", + "Key J": "J", + "Key K": "K", + "Key L": "L", + "Key Colon": "Semicolon", + "Key Semicolon": "Apostrophe", + "Key Equal": "RightControl", + "Key Return": "Return", + "Key Commodore": "LeftControl", + "Key Left Shift": "LeftShift", + "Key Z": "Z", + "Key X": "X", + "Key C": "C", + "Key V": "V", + "Key B": "B", + "Key N": "N", + "Key M": "M", + "Key Comma": "Comma", + "Key Period": "Period", + "Key Slash": "Slash", + "Key Right Shift": "RightShift", + "Key Cursor Up/Down": "DownArrow", + "Key Cursor Left/Right": "RightArrow", + "Key Space": "Space" + }, + "ZXSpectrum Controller": { + "P1 Up": "NumberPad8, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "NumberPad2, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "NumberPad4, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "NumberPad6, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Button": "NumberPad1, J1 B1, X1 X", + "Key True Video": "", + "Key Inv Video": "", + "Key 1": "D1", + "Key 2": "D2", + "Key 3": "D3", + "Key 4": "D4", + "Key 5": "D5", + "Key 6": "D6", + "Key 7": "D7", + "Key 8": "D8", + "Key 9": "D9", + "Key 0": "D0", + "Key Break": "Delete", + "Key Delete": "Backspace", + "Key Graph": "", + "Key Q": "Q", + "Key W": "W", + "Key E": "E", + "Key R": "R", + "Key T": "T", + "Key Y": "Y", + "Key U": "U", + "Key I": "I", + "Key O": "O", + "Key P": "P", + "Key Extend Mode": "", + "Key Edit": "", + "Key A": "A", + "Key S": "S", + "Key D": "D", + "Key F": "F", + "Key G": "G", + "Key H": "H", + "Key J": "J", + "Key K": "K", + "Key L": "L", + "Key Return": "Return", + "Key Caps Shift": "LeftShift, RightShift", + "Key Caps Lock": "", + "Key Z": "Z", + "Key X": "X", + "Key C": "C", + "Key V": "V", + "Key B": "B", + "Key N": "N", + "Key M": "M", + "Key Period": "Period", + "Key Symbol Shift": "LeftControl, RightControl", + "Key Semi-Colon": "Semicolon", + "Key Inverted-Comma": "", + "Key Left Cursor": "LeftArrow", + "Key Right Cursor": "RightArrow", + "Key Space": "Space", + "Key Up Cursor": "UpArrow", + "Key Down Cursor": "DownArrow", + "Key Comma": "Comma", + "Play Tape": "F1", + "Stop Tape": "F2", + "RTZ Tape": "F3", + "Record Tape": "", + "Key Quote": "Shift+D2", + "Insert Next Tape": "F6", + "Insert Previous Tape": "F5", + "Next Tape Block": "F8", + "Prev Tape Block": "F7", + "Get Tape Status": "F9", + "Insert Next Disk": "F11", + "Insert Previous Disk": "F10", + "Get Disk Status": "F12" + }, + "Intellivision Controller": { + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 L": "Z, J1 B1, X1 X", + "P1 R": "X, J1 B2, X1 A", + "P1 Key0": "NumberPad0", + "P1 Key1": "NumberPad1", + "P1 Key2": "NumberPad2", + "P1 Key3": "NumberPad3", + "P1 Key4": "NumberPad4", + "P1 Key5": "NumberPad5", + "P1 Key6": "NumberPad6", + "P1 Key7": "NumberPad7", + "P1 Key8": "NumberPad9", + "P1 Key9": "NumberPad9", + "P1 Enter": "NumberPadEnter", + "P1 Clear": "NumberPadPeriod", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 L": "", + "P2 R": "", + "P2 Key0": "", + "P2 Key1": "", + "P2 Key2": "", + "P2 Key3": "", + "P2 Key4": "", + "P2 Key5": "", + "P2 Key6": "", + "P2 Key7": "", + "P2 Key8": "", + "P2 Key9": "", + "P2 Enter": "", + "P2 Clear": "" + }, + "PC-FX Controller": { + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 I": "C, J1 B1, X1 X", + "P1 II": "X, J1 B2, X1 A", + "P1 III": "Z, J1 B4, X1 Y", + "P1 IV": "D, J1 B3, X1 B", + "P1 V": "S, J1 B11, X1 X", + "P1 VI": "A, J1 B12, X1 X", + "P1 Select": "Space, J1 B9, X1 Back", + "P1 Run": "Return, J1 B10, X1 Start", + "P1 Mode 1": "", + "P1 Mode 2": "", + "P2 Mouse Left": "NumberPad1", + "P2 Mouse Right": "NumberPad2", + "Power": "", + "Reset": "", + "Previous Disk": "", + "Next Disk": "", + "P2 Mouse Left": "WMouse L", + "P2 Mouse Right": "WMouse R" + }, + "Saturn Controller": { + "Power": "", + "Reset": "", + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Start": "Return, J1 B10, X1 Start", + "P1 X": "D, J1 B3, X1 B", + "P1 Y": "S, J1 B11, X1 X", + "P1 Z": "A, J1 B12, X1 X", + "P1 A": "C, J1 B1, X1 X", + "P1 B": "X, J1 B2, X1 A", + "P1 C": "Z, J1 B4, X1 Y", + "P1 L": "Q, J1 B5, X1 LeftShoulder", + "P1 R": "W, J1 B6, X1 RightShoulder", + "P1 Mouse Left": "WMouse L", + "P1 Mouse Center": "WMouse M", + "P1 Mouse Right": "WMouse R", + "P1 Escape": "Escape", + "P1 F1": "F1", + "P1 F2": "F2", + "P1 F3": "F3", + "P1 F4": "F4", + "P1 F5": "F5", + "P1 F6": "F6", + "P1 F7": "F7", + "P1 F8": "F8", + "P1 F9": "F9", + "P1 F10": "F10", + "P1 F11": "F11", + "P1 F12": "F12", + "P1 Grave`": "Grave", + "P1 1(One)": "D1", + "P1 2": "D2", + "P1 3": "D3", + "P1 4": "D4", + "P1 5": "D5", + "P1 6": "D6", + "P1 7": "D7", + "P1 8": "D8", + "P1 9": "D9", + "P1 0(Zero)": "D0", + "P1 Minus-": "Minus", + "P1 Equals=": "Equals", + "P1 Backslash\\": "Backslash", + "P1 Backspace": "Backspace", + "P1 Tab": "Tab", + "P1 Q": "Q", + "P1 W": "W", + "P1 E": "E", + "P1 R(Key)": "R", + "P1 T": "T", + "P1 Y(Key)": "Y", + "P1 U": "U", + "P1 I": "I", + "P1 O": "O", + "P1 P": "P", + "P1 LeftBracket[": "LeftBracket", + "P1 RightBracket]": "RightBracket", + "P1 Enter": "Return", + "P1 CapsLock": "CapsLock", + "P1 A(Key)": "A", + "P1 S": "S", + "P1 D": "D", + "P1 F": "F", + "P1 G": "G", + "P1 H": "H", + "P1 J": "J", + "P1 K": "K", + "P1 L(Key)": "L", + "P1 Semicolon;": "Semicolon", + "P1 Quote'": "Apostrophe", + "P1 LeftShift": "LeftShift", + "P1 Z(Key)": "Z", + "P1 X(Key)": "X", + "P1 C(Key)": "C", + "P1 V": "V", + "P1 B(Key)": "B", + "P1 N": "N", + "P1 M": "M", + "P1 Comma,": "Comma", + "P1 Period.": "Period", + "P1 Slash/": "Slash", + "P1 RightShift": "RightShift", + "P1 LeftCtrl": "LeftControl", + "P1 LeftAlt": "LeftAlt", + "P1 Space": "Space", + "P1 RightAlt": "RightAlt", + "P1 RightCtrl": "RightControl", + "P1 PrintScreen": "", + "P1 ScrollLock": "ScrollLock", + "P1 Pause": "Pause", + "P1 Insert": "Insert", + "P1 Delete": "Delete", + "P1 Home": "Home", + "P1 End": "End", + "P1 PageUp": "PageUp", + "P1 PageDown": "PageDown", + "P1 Up": "UpArrow", + "P1 Down": "DownArrow", + "P1 CursorLeft": "LeftArrow", + "P1 Right": "RightArrow", + "P1 NumLock": "NumberLock", + "P1 KeypadSlash(Divide)": "NumberPadSlash", + "P1 KeypadAsterisk(Multiply)": "NumberPadStar", + "P1 KeypadMinus": "NumberPadMinus", + "P1 KeypadHome/7": "NumberPad7", + "P1 KeypadUp/8": "NumberPad8", + "P1 KeypadPageup/9": "NumberPad9", + "P1 KeypadPlus": "NumberPadPlus", + "P1 KeypadLeft/4": "NumberPad4", + "P1 KeypadCenter/5": "NumberPad5", + "P1 KeypadRight/6": "NumberPad6", + "P1 KeypadEnd/1": "NumberPad1", + "P1 KeypadDown/2": "NumberPad2", + "P1 KeypadPagedown/3": "NumberPad3", + "P1 KeypadEnter": "NumberPadEnter", + "P1 KeypadInsert/0": "NumberPad0", + "P1 KeypadDelete": "NumberPadPeriod" + }, + "PC Engine Controller": { + "Reset": "", + "Power": "", + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 B2": "Z, J1 B1, X1 X", + "P1 B1": "X, J1 B2, X1 A", + "P1 Select": "V, J1 B9, X1 Back", + "P1 Run": "Return, J1 B10, X1 Start", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 B1": "", + "P2 B2": "", + "P2 Select": "", + "P2 Run": "", + "P3 Up": "", + "P3 Down": "", + "P3 Left": "", + "P3 Right": "", + "P3 B1": "", + "P3 B2": "", + "P3 Select": "", + "P3 Run": "", + "P4 Up": "", + "P4 Down": "", + "P4 Left": "", + "P4 Right": "", + "P4 B1": "", + "P4 B2": "", + "P4 Select": "", + "P4 Run": "", + "P5 Up": "", + "P5 Down": "", + "P5 Left": "", + "P5 Right": "", + "P5 B1": "", + "P5 B2": "", + "P5 Select": "", + "P5 Run": "" + }, + "ColecoVision Basic Controller": { + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 L": "Z, J1 B5, X1 LeftShoulder", + "P1 R": "X, J1 B6, X1 RightShoulder", + "P1 Key 1": "NumberPad1, J1 B1, X1 X", + "P1 Key 2": "NumberPad2, J1 B2, X1 A", + "P1 Key 3": "NumberPad3, J1 B3, X1 B", + "P1 Key 4": "NumberPad4, J1 B4, X1 Y", + "P1 Key 5": "NumberPad5, J1 RotationZ-, X1 RStickUp", + "P1 Key 6": "NumberPad6, J1 RotationZ+, X1 RStickDown", + "P1 Key 7": "NumberPad7, J1 Z-, X1 RStickLeft", + "P1 Key 8": "NumberPad8, J1 Z+, X1 RStickRight", + "P1 Key 9": "NumberPad9, J1 B11, X1 LeftThumb", + "P1 Star": "NumberPadEnter, J1 B9, X1 Back", + "P1 Key 0": "NumberPad0, J1 B12, X1 RightThumb", + "P1 Pound": "NumberPadPeriod, J1 B10, X1 Start", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 L": "", + "P2 R": "", + "P2 Key1": "", + "P2 Key2": "", + "P2 Key3": "", + "P2 Key4": "", + "P2 Key5": "", + "P2 Key6": "", + "P2 Key7": "", + "P2 Key8": "", + "P2 Key9": "", + "P2 Star": "", + "P2 Key0": "", + "P2 Pound": "" + }, + "SMS Controller": { + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 B1": "Z, J1 B1, X1 X", + "P1 B2": "X, J1 B2, X1 A", + "Reset": "J1 B9, X1 Back", + "Pause": "J1 B10, X1 Start", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 B1": "", + "P2 B2": "" + }, + "SMS Paddle Controller": { + "P1 Left": "LeftArrow, J1 POV1L", + "P1 Right": "RightArrow, J1 POV1R", + "P1 B1": "Z, J1 B1, X1 X", + "Reset": "J1 B9, X1 Back", + "Pause": "J1 B10, X1 Start" + }, + "SMS Light Phaser Controller": { + "P1 Trigger": "Z, J1 B1, X1 X, WMouse L", + "Reset": "J1 B9, X1 Back", + "Pause": "J1 B10, X1 Start" + }, + "SMS Sports Pad Controller": { + "P1 Up": "UpArrow, J1 POV1U", + "P1 Down": "DownArrow, J1 POV1D", + "P1 Left": "LeftArrow, J1 POV1L", + "P1 Right": "RightArrow, J1 POV1R", + "P1 B1": "Z, J1 B1, X1 X", + "P1 B2": "X, J1 B2, X1 A", + "Reset": "J1 B9, X1 Back", + "Pause": "J1 B10, X1 Start", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 B1": "", + "P2 B2": "" + }, + "SMS Keyboard Controller": { + "Key 1": "D1", + "Key 2": "D2", + "Key 3": "D3", + "Key 4": "D4", + "Key 5": "D5", + "Key 6": "D6", + "Key 7": "D7", + "Key 8": "D8", + "Key 9": "D9", + "Key 0": "D0", + "Key Minus": "Minus", + "Key Caret": "Equals", + "Key Yen": "Backspace", + "Key Break": "Delete", + + "Key Function": "Tab", + "Key Q": "Q", + "Key W": "W", + "Key E": "E", + "Key R": "R", + "Key T": "T", + "Key Y": "Y", + "Key U": "U", + "Key I": "I", + "Key O": "O", + "Key P": "P", + "Key At": "LeftBracket", + "Key Left Bracket": "RightBracket", + "Key Return": "Return", + "Key Up Arrow": "UpArrow", + + "Key Control": "CapsLock", + "Key A": "A", + "Key S": "S", + "Key D": "D", + "Key F": "F", + "Key G": "G", + "Key H": "H", + "Key J": "J", + "Key K": "K", + "Key L": "L", + "Key Semicolon": "Semicolon", + "Key Colon": "Apostrophe", + "Key Right Bracket": "Backslash", + "Key Left Arrow": "LeftArrow", + "Key Right Arrow": "RightArrow", + + "Key Shift": "LeftShift", + "Key Z": "Z", + "Key X": "X", + "Key C": "C", + "Key V": "V", + "Key B": "B", + "Key N": "N", + "Key M": "M", + "Key Comma": "Comma", + "Key Period": "Period", + "Key Slash": "Slash", + "Key PI": "RightShift", + "Key Down Arrow": "DownArrow", + + "Key Graph": "PageUp", + "Key Kana": "PageDown", + "Key Space": "Space", + "Key Home/Clear": "Home", + "Key Insert/Delete": "Insert", + + "P1 Up": "J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 B1": "J1 B1, X1 X", + "P1 B2": "J1 B2, X1 A", + "Reset": "J1 B9, X1 Back", + "Pause": "J1 B10, X1 Start", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 B1": "", + "P2 B2": "" + }, + "GG Controller": { + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 B1": "Z, J1 B1, X1 X", + "P1 B2": "X, J1 B2, X1 A", + "Reset": "J1 B9, X1 Back", + "P1 Start": "Return, J1 B10, X1 Start" + }, + "Dual Gameboy Controller": { + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Start": "Return, J1 B10, X1 Start", + "P1 Select": "Space, J1 B9, X1 Space", + "P1 B": "Z, J1 B1, X1 X", + "P1 A": "X, J1 B2, X1 A", + "P1 Power": "", + "P2 Up": "NumberPad8, J1 RotationZ-, X1 RStickUp", + "P2 Down": "NumberPad2, J1 RotationZ+, X1 RStickDown", + "P2 Left": "NumberPad4, J1 Z-, X1 RStickLeft", + "P2 Right": "NumberPad6, J1 Z+, X1 RStickRight", + "P2 Start": "RightBracket, J1 B5, X1 LeftShoulder", + "P2 Select": "LeftBracket, J1 B6, X1 RightShoulder", + "P2 B": "C, J1 B4, X1 Y", + "P2 A": "V, J1 B3, X1 B", + "P2 Power": "" + }, + "TI83 Controller": { + "0": "NumberPad0", + "1": "NumberPad1", + "2": "NumberPad2", + "3": "NumberPad3", + "4": "NumberPad4", + "5": "NumberPad5", + "6": "NumberPad6", + "7": "NumberPad7", + "8": "NumberPad8", + "9": "NumberPad9", + "DOT": "NumberPadPeriod", + "ON": "Space", + "ENTER": "Return, NumberPadEnter", + "DOWN": "DownArrow", + "UP": "UpArrow", + "LEFT": "LeftArrow", + "RIGHT": "RightArrow", + "PLUS": "NumberPadPlus", + "MINUS": "NumberPadMinus", + "MULTIPLY": "NumberPadStar", + "DIVIDE": "NumberPadSlash", + "CLEAR": "Escape", + "EXP": "6", + "DASH": "Minus", + "PARACLOSE": "0", + "TAN": "T", + "VARS": "V", + "PARAOPEN": "9", + "COS": "C", + "PRGM": "R", + "STAT": "S", + "SIN": "Period", + "MATRIX": "LeftBracket", + "X": "X", + "STO": "Insert", + "LN": "L", + "LOG": "O", + "SQUARED": "2", + "NEG1": "1", + "MATH": "M", + "ALPHA": "A", + "GRAPH": "G", + "TRACE": "Home", + "ZOOM": "Z", + "WINDOW": "W", + "Y": "Y", + "SECOND": "Slash", + "MODE": "BackSlash", + "DEL": "Delete", + "COMMA": "Comma" + }, + "GPGX Genesis Controller": { + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 A": "Z, J1 B1, X1 X", + "P1 B": "X, J1 B2, X1 A", + "P1 C": "C, J1 B4, X1 Y", + "P1 Start": "Return, J1 B10, X1 Start", + "P1 X": "A, J1 B3, X1 B", + "P1 Y": "S, J1 B5, X1 LeftShoulder", + "P1 Z": "D, J1 B6, X1 RightShoulder", + "P1 Mode": "E, J1 B9, X1 Back", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 A": "", + "P2 B": "", + "P2 C": "", + "P2 Start": "", + "P2 X": "", + "P2 Y": "", + "P2 Z": "", + "P2 Mode": "", + "P2 Lightgun Trigger": "WMouse L", + "P2 Lightgun Start": "NumberPad5", + "P2 Mouse Left": "WMouse L", + "P2 Mouse Center": "WMouse M", + "P2 Mouse Right": "WMouse R", + "P2 Mouse Start": "NumberPad5", + "Power": "", + "Reset": "" + }, + "PicoDrive Genesis Controller": { + "P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 Down": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 Left": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 Right": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 A": "Z, J1 B1, X1 X", + "P1 B": "X, J1 B2, X1 A", + "P1 C": "C, J1 B4, X1 Y", + "P1 Start": "Return, J1 B10, X1 Start", + "P1 X": "A, J1 B3, X1 B", + "P1 Y": "S, J1 B5, X1 LeftShoulder", + "P1 Z": "D, J1 B6, X1 RightShoulder", + "P1 Mode": "E, J1 B9, X1 Back", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 A": "", + "P2 B": "", + "P2 C": "", + "P2 Start": "", + "P2 X": "", + "P2 Y": "", + "P2 Z": "", + "P2 Mode": "", + "Power": "", + "Reset": "" + }, + "WonderSwan Controller": { + "P1 X1": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P1 X3": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P1 X4": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P1 X2": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P1 Y1": "NumberPad8, J1 RotationZ-, X1 RStickUp", + "P1 Y3": "NumberPad2, J1 RotationZ+, X1 RStickDown", + "P1 Y4": "NumberPad4, J1 Z-, X1 RStickLeft", + "P1 Y2": "NumberPad6, J1 Z+, X1 RStickRight", + "P1 Start": "Return, J1 B10, X1 Start", + "P1 B": "Z, J1 B1, X1 X", + "P1 A": "X, J1 B2, X1 A", + "P2 X1": "", + "P2 X3": "X, J1 B2, X1 A", + "P2 X4": "Z, J1 B1, X1 X", + "P2 X2": "", + "P2 Y1": "LeftArrow, J1 POV1L, X1 DpadLeft, X1 LStickLeft", + "P2 Y3": "RightArrow, J1 POV1R, X1 DpadRight, X1 LStickRight", + "P2 Y4": "DownArrow, J1 POV1D, X1 DpadDown, X1 LStickDown", + "P2 Y2": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp", + "P2 Start": "Return, J1 B10, X1 Start", + "P2 B": "", + "P2 A": "", + "Power": "" + }, + "PSX DualShock Controller": { + "P1 Up": "X1 DpadUp,UpArrow", + "P1 Down": "X1 DpadDown,DownArrow", + "P1 Left": "X1 DpadLeft,LeftArrow", + "P1 Right": "X1 DpadRight,RightArrow", + "P1 Select": "X1 Back,Space", + "P1 Start": "X1 Start,Return", + "P1 Square": "X1 X,A", + "P1 Triangle": "X1 Y,S", + "P1 Circle": "X1 B,X", + "P1 Cross": "X1 A,Z", + "P1 L1": "X1 LeftShoulder,Q", + "P1 R1": "X1 RightShoulder,W", + "P1 L2": "X1 LeftTrigger,E", + "P1 R2": "X1 RightTrigger,R", + "P1 L3": "X1 LeftThumb,T", + "P1 R3": "X1 RightThumb,Y", + "P1 MODE": "D" + }, + "Lynx Controller": { + "Up": "UpArrow", + "Down": "DownArrow", + "Left": "LeftArrow", + "Right": "RightArrow", + "A": "X", + "B": "Z", + "Option 1": "A", + "Option 2": "S", + "Pause": "Return", + "Power": "" + }, + "Apple IIe Keyboard": { + "Delete": "Delete", + "Left": "LeftArrow", + "Tab": "Tab", + "Down": "DownArrow", + "Up": "UpArrow", + "Return": "Return", + "Right": "RightArrow", + "Escape": "", + "Space": "Space", + "'": "Apostrophe", + ",": "Comma", + "-": "Minus", + ".": "Period", + "/": "Slash", + "0": "NumberPad0", + "1": "NumberPad1", + "2": "NumberPad2", + "3": "NumberPad3", + "4": "NumberPad4", + "5": "NumberPad5", + "6": "NumberPad6", + "7": "NumberPad7", + "8": "NumberPad8", + "9": "NumberPad9", + ";": "Semicolon", + "=": "Equals", + "[": "LeftBracket", + "\\": "Backslash", + "]": "RightBracket", + "`": "Grave", + "A": "A", + "B": "B", + "C": "C", + "D": "D", + "E": "E", + "F": "F", + "G": "G", + "H": "H", + "I": "I", + "J": "J", + "K": "K", + "L": "L", + "M": "M", + "N": "N", + "O": "O", + "P": "P", + "Q": "Q", + "R": "R", + "S": "S", + "T": "T", + "U": "U", + "V": "V", + "W": "W", + "X": "X", + "Y": "Y", + "Z": "Z", + "Control": "RightControl", + "Shift": "RightShift", + "Caps Lock": "CapsLock", + "Previous Disk": "", + "Next Disk": "" + }, + "VirtualBoy Controller": { + "L_Up": "UpArrow, X1 DpadUp, X1 LStickUp", + "L_Down": "DownArrow, X1 DpadDown, X1 LStickDown", + "L_Left": "LeftArrow, X1 DpadLeft, X1 LStickLeft", + "L_Right": "RightArrow, X1 DpadRight, X1 LStickRight", + "R_Up": "NumberPad8, X1 RStickUp", + "R_Down": "NumberPad2, X1 RStickDown", + "R_Left": "NumberPad4, X1 RStickLeft", + "R_Right": "NumberPad6, X1 RStickRight", + "B": "Z, X1 X", + "A": "X, X1 A", + "R": "W, X1 LeftShoulder", + "L": "E, X1 RightShoulder", + "Select": "Space, X1 Back", + "Start": "Return, X1 Start", + "Power": "" + }, + "NeoGeo Portable Controller": { + "Up": "UpArrow, X1 DpadUp, X1 LStickUp", + "Down": "DownArrow, X1 DpadDown, X1 LStickDown", + "Left": "LeftArrow, X1 DpadLeft, X1 LStickLeft", + "Right": "RightArrow, X1 DpadRight, X1 LStickRight", + "B": "Z, J1 B1, X1 X", + "A": "X, J1 B2, X1 A", + "Option": "Return, J1 B10, X1 Start", + "Power": "" + } + }, + "AllTrollersAutoFire": { + "NES Controller": { + "P1 Up": "", + "P1 Down": "", + "P1 Left": "", + "P1 Right": "", + "P1 Start": "", + "P1 Select": "", + "P1 B": "A", + "P1 A": "S", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 Start": "", + "P2 Select": "", + "P2 B": "", + "P2 A": "", + "P2 Fire": "", + "P2 Microphone": "", + "P3 Fire": "", + "Reset": "", + "Power": "" + }, + "Gameboy Controller": { + "Up": "", + "Down": "", + "Left": "", + "Right": "", + "Start": "", + "Select": "", + "B": "A", + "A": "S", + "Power": "" + }, + "Gameboy Controller H": { + "Up": "", + "Down": "", + "Left": "", + "Right": "", + "Start": "", + "Select": "", + "B": "A", + "A": "S", + "Power": "" + }, + "GBAController": { + "Up": "", + "Down": "", + "Left": "", + "Right": "", + "Start": "", + "Select": "", + "B": "A", + "A": "S", + "L": "", + "R": "", + "Power": "" + }, + "Atari 2600 Basic Controller": { + "Reset": "", + "Select": "", + "P1 Up": "", + "P1 Down": "", + "P1 Left": "", + "P1 Right": "", + "P1 Button": "A", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 Button": "S" + }, + "PC Engine Controller": { + "Reset": "", + "Power": "", + "P1 Up": "", + "P1 Down": "", + "P1 Left": "", + "P1 Right": "", + "P1 B2": "A", + "P1 B1": "S", + "P1 Select": "", + "P1 Run": "", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 B2": "", + "P2 B1": "", + "P2 Select": "", + "P2 Run": "", + "P3 Up": "", + "P3 Down": "", + "P3 Left": "", + "P3 Right": "", + "P3 B2": "", + "P3 B1": "", + "P3 Select": "", + "P3 Run": "", + "P4 Up": "", + "P4 Down": "", + "P4 Left": "", + "P4 Right": "", + "P4 B2": "", + "P4 B1": "", + "P4 Select": "", + "P4 Run": "", + "P5 Up": "", + "P5 Down": "", + "P5 Left": "", + "P5 Right": "", + "P5 B2": "", + "P5 B1": "", + "P5 Select": "", + "P5 Run": "" + }, + "SMS Controller": { + "P1 Up": "", + "P1 Down": "", + "P1 Left": "", + "P1 Right": "", + "P1 B1": "A", + "P1 B2": "S", + "Reset": "", + "Pause": "", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 B1": "", + "P2 B2": "" + }, + "GPGX Genesis Controller": { + "P1 Up": "", + "P1 Down": "", + "P1 Left": "", + "P1 Right": "", + "P1 A": "", + "P1 B": "", + "P1 C": "", + "P1 Start": "", + "P1 X": "", + "P1 Y": "", + "P1 Z": "", + "P1 Mode": "", + "P2 Up": "", + "P2 Down": "", + "P2 Left": "", + "P2 Right": "", + "P2 A": "", + "P2 B": "", + "P2 C": "", + "P2 Start": "", + "P2 X": "", + "P2 Y": "", + "P2 Z": "", + "P2 Mode": "", + "Power": "", + "Reset": "" + }, + "GBA Controller": { + "Up": "", + "Down": "", + "Left": "", + "Right": "", + "Start": "", + "Select": "", + "B": "A", + "A": "S", + "L": "", + "R": "", + "Power": "" + }, + "WonderSwan Controller": { + "P1 B": "A", + "P1 A": "S", + "P2 X4": "A", + "P2 X3": "S", + "Power": "" + }, + "Lynx Controller": { + "Up": "", + "Down": "", + "Left": "", + "Right": "", + "A": "", + "B": "", + "Option 1": "", + "Option 2": "", + "Pause": "", + "Power": "" + }, + "Apple IIe Keyboard": { + "Delete": "", + "Left": "", + "Tab": "", + "Down": "", + "Up": "", + "Return": "Return", + "Right": "", + "Escape": "", + "Space": "", + "'": "", + ",": "", + "-": "", + ".": "", + "/": "", + "0": "", + "1": "", + "2": "", + "3": "", + "4": "", + "5": "", + "6": "", + "7": "", + "8": "", + "9": "", + ";": "", + "=": "", + "[": "", + "\\": "", + "]": "", + "`": "", + "A": "", + "B": "", + "C": "", + "D": "", + "E": "", + "F": "", + "G": "", + "H": "", + "I": "", + "J": "", + "K": "", + "L": "", + "M": "", + "N": "", + "O": "", + "P": "", + "Q": "", + "R": "", + "S": "", + "T": "", + "U": "", + "V": "", + "W": "", + "X": "", + "Y": "", + "Z": "", + "Control": "", + "Shift": "", + "Caps Lock": "", + "Previous Disk": "", + "Next Disk": "" + }, + "VirtualBoy Controller": { + "L_Up": "", + "L_Down": "", + "L_Left": "", + "L_Right": "", + "R_Up": "", + "R_Down": "", + "R_Left": "", + "R_Right": "", + "B": "", + "A": "", + "R": "", + "L": "", + "Select": "", + "Start": "", + "Power": "" + }, + "NeoGeo Portable Controller": { + "Up": "", + "Down": "", + "Left": "", + "Right": "", + "B": "", + "A": "", + "Option": "", + "Power": "" + } + }, "AllTrollersAnalog": { "NES Controller": { "P2 Paddle": { diff --git a/Assets/gamedb/gamedb_a2600.txt b/Assets/gamedb/gamedb_a2600.txt index 604912bc87..93ce35d520 100644 --- a/Assets/gamedb/gamedb_a2600.txt +++ b/Assets/gamedb/gamedb_a2600.txt @@ -2699,3 +2699,4 @@ sha1:00CCF622E7BA4D0A39DCBABAB771CE815B0FB8FE Boulder Dash (2005) (Andrew Davie sha1:650DA2339D41D1D2F180A6CAFE8DC311AC588ACD Boulder Dash Intro Tune (2005) (Erik Ehrling) A26 m=4K;NTSC=true sha1:F28E52921646A18467577370808454F494C15EFE 0840 EconoBanking A26 m=0840;NTSC=true sha1:2A9647E27AB27E6CF82B3BF122EDF212FA34AE86 Halo2600 Final A26 m=m4K +sha1:341BB93E67C21063F3910845D1AF59FEA129FF21 Bang! A26 m=F4SC \ No newline at end of file diff --git a/Assets/gamedb/gamedb_nes.txt b/Assets/gamedb/gamedb_nes.txt index 5ccc1128a5..b837ef1be5 100644 --- a/Assets/gamedb/gamedb_nes.txt +++ b/Assets/gamedb/gamedb_nes.txt @@ -346,6 +346,7 @@ sha1:D89EE629F8F60613999EAD84A3C7B2F6B38C399F fme7ramtest_128k NES board=MAPPE sha1:78C4441E42C8F423EBF6558AA00AB6D0DBCC2B4B 34_test_1 NES board=AVE-NINA-01;PRG=64;CHR=64;WRAM=8;VRAM=0;PAD_V=1;PAD_H=0 sha1:F2D5CB78D78831CB6A2A17CD418A753F3C99C7F4 34_test_2 NES board=NES-BNROM;PRG=256;CHR=0;WRAM=8;VRAM=8;PAD_V=1;PAD_H=0 sha1:77C5C2473AF13003B7BD8273A5E23BE4964107A3 M34_P128K_H NES board=AVE-NINA-07;PRG=128;CHR=0;WRAM=0;VRAM=8;PAD_V=1;PAD_H=0 +sha1:B6721E1C1EC2E2F215180ED7BB31EDA80BCDE869 2nd2006_next_level NES board=MAPPER000;PRG=16;CHR=8;PAD_V=1;PAD_H=0 ;other sha1:4180276C50DF9958DEDD6C6D19C9E7AEBB75A89F o Galaxian (Japan) NES board=NAMCOT-3301;PRG=16;CHR=8;WRAM=8;VRAM=0;PAD_V=1;PAD_H=0 diff --git a/Assets/libblip_buf.so b/Assets/libblip_buf.so new file mode 100755 index 0000000000..9c060d4189 Binary files /dev/null and b/Assets/libblip_buf.so differ diff --git a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj index 9205707a7e..c99d27ef6f 100644 --- a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj +++ b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj @@ -37,6 +37,10 @@ + + False + ..\..\Users\uptho\Documents\BizHawk-2.3\dll\System.Data.SQLite.dll + @@ -48,6 +52,19 @@ + + + + + + + + + + + + + @@ -62,7 +79,25 @@ + + + + + + + + + + + + + + + + + + @@ -95,4 +130,4 @@ --> - + \ No newline at end of file diff --git a/BizHawk.Client.ApiHawk/Classes/Api/EmuApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/EmuApi.cs new file mode 100644 index 0000000000..015bd52093 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/EmuApi.cs @@ -0,0 +1,459 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; + +using BizHawk.Client.Common; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common.IEmulatorExtensions; +using BizHawk.Emulation.Cores.Nintendo.NES; +using BizHawk.Emulation.Cores.Nintendo.SNES; +using BizHawk.Emulation.Cores.PCEngine; +using BizHawk.Emulation.Cores.Consoles.Sega.gpgx; +using BizHawk.Emulation.Cores.Sega.MasterSystem; +using BizHawk.Emulation.Cores.WonderSwan; +using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES; + +namespace BizHawk.Client.ApiHawk +{ + [Description("A library for interacting with the currently loaded emulator core")] + public sealed class EmuApi : IEmu + { + private static class EmuStatic + { + public static void DisplayVsync(bool enabled) + { + Global.Config.VSync = enabled; + } + public static string GetSystemId() + { + return Global.Game.System; + } + public static void LimitFramerate(bool enabled) + { + Global.Config.ClockThrottle = enabled; + } + + public static void MinimizeFrameskip(bool enabled) + { + Global.Config.AutoMinimizeSkipping = enabled; + } + + } + [RequiredService] + private IEmulator Emulator { get; set; } + + [OptionalService] + private IDebuggable DebuggableCore { get; set; } + + [OptionalService] + private IDisassemblable DisassemblableCore { get; set; } + + [OptionalService] + private IMemoryDomains MemoryDomains { get; set; } + + [OptionalService] + private IInputPollable InputPollableCore { get; set; } + + [OptionalService] + private IRegionable RegionableCore { get; set; } + + [OptionalService] + private IBoardInfo BoardInfo { get; set; } + + public Action FrameAdvanceCallback { get; set; } + public Action YieldCallback { get; set; } + + public EmuApi() + { } + + public void DisplayVsync(bool enabled) + { + EmuStatic.DisplayVsync(enabled); + } + + public void FrameAdvance() + { + FrameAdvanceCallback(); + } + + public int FrameCount() + { + return Emulator.Frame; + } + + public object Disassemble(uint pc, string name = "") + { + try + { + if (DisassemblableCore == null) + { + throw new NotImplementedException(); + } + + MemoryDomain domain = MemoryDomains.SystemBus; + + if (!string.IsNullOrEmpty(name)) + { + domain = MemoryDomains[name]; + } + + int l; + var d = DisassemblableCore.Disassemble(domain, pc, out l); + return new { disasm = d, length = l }; + } + catch (NotImplementedException) + { + Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDisassemblable.Disassemble)}()"); + return null; + } + } + + public ulong? GetRegister(string name) + { + try + { + if (DebuggableCore == null) + { + throw new NotImplementedException(); + } + + var registers = DebuggableCore.GetCpuFlagsAndRegisters(); + ulong? value = null; + if (registers.ContainsKey(name)) value = registers[name].Value; + return value; + } + catch (NotImplementedException) + { + Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.GetCpuFlagsAndRegisters)}()"); + return null; + } + } + + public Dictionary GetRegisters() + { + var table = new Dictionary(); + + try + { + if (DebuggableCore == null) + { + throw new NotImplementedException(); + } + + foreach (var kvp in DebuggableCore.GetCpuFlagsAndRegisters()) + { + table[kvp.Key] = kvp.Value.Value; + } + } + catch (NotImplementedException) + { + Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.GetCpuFlagsAndRegisters)}()"); + } + + return table; + } + + public void SetRegister(string register, int value) + { + try + { + if (DebuggableCore == null) + { + throw new NotImplementedException(); + } + + DebuggableCore.SetCpuRegister(register, value); + } + catch (NotImplementedException) + { + Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.SetCpuRegister)}()"); + } + } + + public long TotalExecutedycles() + { + try + { + if (DebuggableCore == null) + { + throw new NotImplementedException(); + } + + return DebuggableCore.TotalExecutedCycles; + } + catch (NotImplementedException) + { + Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.TotalExecutedCycles)}()"); + + return 0; + } + } + + public string GetSystemId() + { + return EmuStatic.GetSystemId(); + } + + public bool IsLagged() + { + if (InputPollableCore != null) + { + return InputPollableCore.IsLagFrame; + } + + Console.WriteLine($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); + return false; + } + + public void SetIsLagged(bool value = true) + { + if (InputPollableCore != null) + { + InputPollableCore.IsLagFrame = value; + } + else + { + Console.WriteLine($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); + } + } + + public int LagCount() + { + if (InputPollableCore != null) + { + return InputPollableCore.LagCount; + } + + Console.WriteLine($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); + return 0; + } + + public void SetLagCount(int count) + { + if (InputPollableCore != null) + { + InputPollableCore.LagCount = count; + } + else + { + Console.WriteLine($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); + } + } + + public void LimitFramerate(bool enabled) + { + EmuStatic.LimitFramerate(enabled); + } + + public void MinimizeFrameskip(bool enabled) + { + EmuStatic.MinimizeFrameskip(enabled); + } + + public void Yield() + { + YieldCallback(); + } + + public string GetDisplayType() + { + if (RegionableCore != null) + { + return RegionableCore.Region.ToString(); + } + + return ""; + } + + public string GetBoardName() + { + if (BoardInfo != null) + { + return BoardInfo.BoardName; + } + + return ""; + } + public object GetSettings() + { + if (Emulator is GPGX) + { + var gpgx = Emulator as GPGX; + return gpgx.GetSettings(); + } + else if (Emulator is LibsnesCore) + { + var snes = Emulator as LibsnesCore; + return snes.GetSettings(); + } + else if (Emulator is NES) + { + var nes = Emulator as NES; + return nes.GetSettings(); + } + else if (Emulator is QuickNES) + { + var quicknes = Emulator as QuickNES; + return quicknes.GetSettings(); + } + else if (Emulator is PCEngine) + { + var pce = Emulator as PCEngine; + return pce.GetSettings(); + } + else if (Emulator is SMS) + { + var sms = Emulator as SMS; + return sms.GetSettings(); + } + else if (Emulator is WonderSwan) + { + var ws = Emulator as WonderSwan; + return ws.GetSettings(); + } + else + { + return null; + } + } + public bool PutSettings(object settings) + { + if (Emulator is GPGX) + { + var gpgx = Emulator as GPGX; + return gpgx.PutSettings(settings as GPGX.GPGXSettings); + } + else if (Emulator is LibsnesCore) + { + var snes = Emulator as LibsnesCore; + return snes.PutSettings(settings as LibsnesCore.SnesSettings); + } + else if (Emulator is NES) + { + var nes = Emulator as NES; + return nes.PutSettings(settings as NES.NESSettings); + } + else if (Emulator is QuickNES) + { + var quicknes = Emulator as QuickNES; + return quicknes.PutSettings(settings as QuickNES.QuickNESSettings); + } + else if (Emulator is PCEngine) + { + var pce = Emulator as PCEngine; + return pce.PutSettings(settings as PCEngine.PCESettings); + } + else if (Emulator is SMS) + { + var sms = Emulator as SMS; + return sms.PutSettings(settings as SMS.SMSSettings); + } + else if (Emulator is WonderSwan) + { + var ws = Emulator as WonderSwan; + return ws.PutSettings(settings as WonderSwan.Settings); + } + else + { + return false; + } + } + public void SetRenderPlanes(params bool[] luaParam) + { + if (Emulator is GPGX) + { + var gpgx = Emulator as GPGX; + var s = gpgx.GetSettings(); + s.DrawBGA = luaParam[0]; + s.DrawBGB = luaParam[1]; + s.DrawBGW = luaParam[2]; + s.DrawObj = luaParam[3]; + gpgx.PutSettings(s); + + } + else if (Emulator is LibsnesCore) + { + var snes = Emulator as LibsnesCore; + var s = snes.GetSettings(); + s.ShowBG1_0 = s.ShowBG1_1 = luaParam[0]; + s.ShowBG2_0 = s.ShowBG2_1 = luaParam[1]; + s.ShowBG3_0 = s.ShowBG3_1 = luaParam[2]; + s.ShowBG4_0 = s.ShowBG4_1 = luaParam[3]; + s.ShowOBJ_0 = luaParam[4]; + s.ShowOBJ_1 = luaParam[5]; + s.ShowOBJ_2 = luaParam[6]; + s.ShowOBJ_3 = luaParam[7]; + snes.PutSettings(s); + } + else if (Emulator is NES) + { + // in the future, we could do something more arbitrary here. + // but this isn't any worse than the old system + var nes = Emulator as NES; + var s = nes.GetSettings(); + s.DispSprites = luaParam[0]; + s.DispBackground = luaParam[1]; + nes.PutSettings(s); + } + else if (Emulator is QuickNES) + { + var quicknes = Emulator as QuickNES; + var s = quicknes.GetSettings(); + + // this core doesn't support disabling BG + bool showsp = GetSetting(0, luaParam); + if (showsp && s.NumSprites == 0) + { + s.NumSprites = 8; + } + else if (!showsp && s.NumSprites > 0) + { + s.NumSprites = 0; + } + + quicknes.PutSettings(s); + } + else if (Emulator is PCEngine) + { + var pce = Emulator as PCEngine; + var s = pce.GetSettings(); + s.ShowOBJ1 = GetSetting(0, luaParam); + s.ShowBG1 = GetSetting(1, luaParam); + if (luaParam.Length > 2) + { + s.ShowOBJ2 = GetSetting(2, luaParam); + s.ShowBG2 = GetSetting(3, luaParam); + } + + pce.PutSettings(s); + } + else if (Emulator is SMS) + { + var sms = Emulator as SMS; + var s = sms.GetSettings(); + s.DispOBJ = GetSetting(0, luaParam); + s.DispBG = GetSetting(1, luaParam); + sms.PutSettings(s); + } + else if (Emulator is WonderSwan) + { + var ws = Emulator as WonderSwan; + var s = ws.GetSettings(); + s.EnableSprites = GetSetting(0, luaParam); + s.EnableFG = GetSetting(1, luaParam); + s.EnableBG = GetSetting(2, luaParam); + ws.PutSettings(s); + } + } + + private static bool GetSetting(int index, bool[] settings) + { + if (index < settings.Length) + { + return settings[index]; + } + + return true; + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/Api/GameInfoApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/GameInfoApi.cs new file mode 100644 index 0000000000..ca74d09da6 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/GameInfoApi.cs @@ -0,0 +1,86 @@ +using System.Collections.Generic; + +using BizHawk.Client.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.ApiHawk +{ + public sealed class GameInfoApi : IGameInfo + { + [OptionalService] + private IBoardInfo BoardInfo { get; set; } + + public GameInfoApi() + { } + + public string GetRomName() + { + if (Global.Game != null) + { + return Global.Game.Name ?? ""; + } + + return ""; + } + + public string GetRomHash() + { + if (Global.Game != null) + { + return Global.Game.Hash ?? ""; + } + + return ""; + } + + public bool InDatabase() + { + if (Global.Game != null) + { + return !Global.Game.NotInDatabase; + } + + return false; + } + + public string GetStatus() + { + if (Global.Game != null) + { + return Global.Game.Status.ToString(); + } + + return ""; + } + + public bool IsStatusBad() + { + if (Global.Game != null) + { + return Global.Game.IsRomStatusBad(); + } + + return true; + } + + public string GetBoardType() + { + return BoardInfo?.BoardName ?? ""; + } + + public Dictionary GetOptions() + { + var options = new Dictionary(); + + if (Global.Game != null) + { + foreach (var option in Global.Game.GetOptionsDict()) + { + options[option.Key] = option.Value; + } + } + + return options; + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/Api/JoypadApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/JoypadApi.cs new file mode 100644 index 0000000000..a1074d5507 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/JoypadApi.cs @@ -0,0 +1,222 @@ +using System; +using System.Collections.Generic; + +using BizHawk.Client.Common; + +namespace BizHawk.Client.ApiHawk +{ + public sealed class JoypadApi : IJoypad + { + public JoypadApi() + { } + + public Dictionary Get(int? controller = null) + { + var buttons = new Dictionary(); + var adaptor = Global.AutofireStickyXORAdapter; + foreach (var button in adaptor.Source.Definition.BoolButtons) + { + if (!controller.HasValue) + { + buttons[button] = adaptor.IsPressed(button); + } + else if (button.Length >= 3 && button.Substring(0, 2) == $"P{controller}") + { + buttons[button.Substring(3)] = adaptor.IsPressed($"P{controller} {button.Substring(3)}"); + } + } + + foreach (var button in adaptor.Source.Definition.FloatControls) + { + if (controller == null) + { + buttons[button] = adaptor.GetFloat(button); + } + else if (button.Length >= 3 && button.Substring(0, 2) == $"P{controller}") + { + buttons[button.Substring(3)] = adaptor.GetFloat($"P{controller} {button.Substring(3)}"); + } + } + + buttons["clear"] = null; + buttons["getluafunctionslist"] = null; + buttons["output"] = null; + + return buttons; + } + + // TODO: what about float controls? + public Dictionary GetImmediate() + { + var buttons = new Dictionary(); + var adaptor = Global.ActiveController; + foreach (var button in adaptor.Definition.BoolButtons) + { + buttons[button] = adaptor.IsPressed(button); + } + foreach (var button in adaptor.Definition.FloatControls) + { + buttons[button] = adaptor.GetFloat(button); + } + + return buttons; + } + + public void SetFromMnemonicStr(string inputLogEntry) + { + try + { + var lg = Global.MovieSession.MovieControllerInstance(); + lg.SetControllersAsMnemonic(inputLogEntry); + + foreach (var button in lg.Definition.BoolButtons) + { + Global.LuaAndAdaptor.SetButton(button, lg.IsPressed(button)); + } + + foreach (var floatButton in lg.Definition.FloatControls) + { + Global.LuaAndAdaptor.SetFloat(floatButton, lg.GetFloat(floatButton)); + } + } + catch (Exception) + { + Console.WriteLine($"invalid mnemonic string: {inputLogEntry}"); + } + } + + public void Set(Dictionary buttons, int? controller = null) + { + try + { + foreach (var button in buttons.Keys) + { + var invert = false; + bool? theValue; + var theValueStr = buttons[button].ToString(); + + if (!string.IsNullOrWhiteSpace(theValueStr)) + { + if (theValueStr.ToLower() == "false") + { + theValue = false; + } + else if (theValueStr.ToLower() == "true") + { + theValue = true; + } + else + { + invert = true; + theValue = null; + } + } + else + { + theValue = null; + } + + var toPress = button.ToString(); + if (controller.HasValue) + { + toPress = $"P{controller} {button}"; + } + + if (!invert) + { + if (theValue.HasValue) // Force + { + Global.LuaAndAdaptor.SetButton(toPress, theValue.Value); + Global.ActiveController.Overrides(Global.LuaAndAdaptor); + } + else // Unset + { + Global.LuaAndAdaptor.UnSet(toPress); + Global.ActiveController.Overrides(Global.LuaAndAdaptor); + } + } + else // Inverse + { + Global.LuaAndAdaptor.SetInverse(toPress); + Global.ActiveController.Overrides(Global.LuaAndAdaptor); + } + } + } + catch + { + /*Eat it*/ + } + } + public void Set(string button, bool? state = null, int? controller = null) + { + try + { + var toPress = button; + if (controller.HasValue) + { + toPress = $"P{controller} {button}"; + } + if (state.HasValue) + Global.LuaAndAdaptor.SetButton(toPress, state.Value); + else + Global.LuaAndAdaptor.UnSet(toPress); + Global.ActiveController.Overrides(Global.LuaAndAdaptor); + } + catch + { + /*Eat it*/ + } + } + public void SetAnalog(Dictionary controls, object controller = null) + { + try + { + foreach (var name in controls.Keys) + { + var theValueStr = controls[name].ToString(); + float? theValue = null; + + if (!string.IsNullOrWhiteSpace(theValueStr)) + { + float f; + if (float.TryParse(theValueStr, out f)) + { + theValue = f; + } + } + + if (controller == null) + { + Global.StickyXORAdapter.SetFloat(name.ToString(), theValue); + } + else + { + Global.StickyXORAdapter.SetFloat($"P{controller} {name}", theValue); + } + } + } + catch + { + /*Eat it*/ + } + } + public void SetAnalog(string control, float? value = null, object controller = null) + { + try + { + if (controller == null) + { + Global.StickyXORAdapter.SetFloat(control, value); + } + else + { + Global.StickyXORAdapter.SetFloat($"P{controller} {control}", value); + } + } + catch + { + /*Eat it*/ + } + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/Api/MemApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/MemApi.cs new file mode 100644 index 0000000000..f54b282550 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/MemApi.cs @@ -0,0 +1,288 @@ +using System; +using System.Collections.Generic; + +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common.IEmulatorExtensions; +using BizHawk.Common.BufferExtensions; + +namespace BizHawk.Client.ApiHawk +{ + public sealed class MemApi : MemApiBase, IMem + { + private MemoryDomain _currentMemoryDomain; + private bool _isBigEndian = false; + public MemApi() + : base() + { + } + + protected override MemoryDomain Domain + { + get + { + if (MemoryDomainCore != null) + { + if (_currentMemoryDomain == null) + { + _currentMemoryDomain = MemoryDomainCore.HasSystemBus + ? MemoryDomainCore.SystemBus + : MemoryDomainCore.MainMemory; + } + + return _currentMemoryDomain; + } + + var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains"; + Console.WriteLine(error); + throw new NotImplementedException(error); + } + } + + #region Unique Library Methods + + public void SetBigEndian(bool enabled = true) + { + _isBigEndian = enabled; + } + + public List GetMemoryDomainList() + { + var list = new List(); + + foreach (var domain in DomainList) + { + list.Add(domain.Name); + } + + return list; + } + + public uint GetMemoryDomainSize(string name = "") + { + if (string.IsNullOrEmpty(name)) + { + return (uint)Domain.Size; + } + + return (uint)DomainList[VerifyMemoryDomain(name)].Size; + } + + public string GetCurrentMemoryDomain() + { + return Domain.Name; + } + + public uint GetCurrentMemoryDomainSize() + { + return (uint)Domain.Size; + } + + public bool UseMemoryDomain(string domain) + { + try + { + if (DomainList[domain] != null) + { + _currentMemoryDomain = DomainList[domain]; + return true; + } + + Console.WriteLine($"Unable to find domain: {domain}"); + return false; + } + catch // Just in case + { + Console.WriteLine($"Unable to find domain: {domain}"); + } + + return false; + } + + public string HashRegion(long addr, int count, string domain = null) + { + var d = string.IsNullOrEmpty(domain) ? Domain : DomainList[VerifyMemoryDomain(domain)]; + + // checks + if (addr < 0 || addr >= d.Size) + { + string error = $"Address {addr} is outside the bounds of domain {d.Name}"; + Console.WriteLine(error); + throw new ArgumentOutOfRangeException(error); + } + if (addr + count > d.Size) + { + string error = $"Address {addr} + count {count} is outside the bounds of domain {d.Name}"; + Console.WriteLine(error); + throw new ArgumentOutOfRangeException(error); + } + + byte[] data = new byte[count]; + for (int i = 0; i < count; i++) + { + data[i] = d.PeekByte(addr + i); + } + + using (var hasher = System.Security.Cryptography.SHA256.Create()) + { + return hasher.ComputeHash(data).BytesToHexString(); + } + } + + #endregion + + #region Endian Handling + + private int ReadSigned(long addr, int size, string domain = null) + { + if (_isBigEndian) return ReadSignedBig(addr, size, domain); + else return ReadSignedLittle(addr, size, domain); + } + + private uint ReadUnsigned(long addr, int size, string domain = null) + { + if (_isBigEndian) return ReadUnsignedBig(addr, size, domain); + else return ReadUnsignedLittle(addr, size, domain); + } + + private void WriteSigned(long addr, int value, int size, string domain = null) + { + if (_isBigEndian) WriteSignedBig(addr, value, size, domain); + else WriteSignedLittle(addr, value, size, domain); + } + + private void WriteUnsigned(long addr, uint value, int size, string domain = null) + { + if (_isBigEndian) WriteUnsignedBig(addr, value, size, domain); + else WriteUnsignedLittle(addr, value, size, domain); + } + + #endregion + + #region Common Special and Legacy Methods + + public uint ReadByte(long addr, string domain = null) + { + return ReadUnsignedByte(addr, domain); + } + + public void WriteByte(long addr, uint value, string domain = null) + { + WriteUnsignedByte(addr, value, domain); + } + + public new List ReadByteRange(long addr, int length, string domain = null) + { + return base.ReadByteRange(addr, length, domain); + } + + public new void WriteByteRange(long addr, List memoryblock, string domain = null) + { + base.WriteByteRange(addr, memoryblock, domain); + } + + public float ReadFloat(long addr, string domain = null) + { + return base.ReadFloat(addr, _isBigEndian, domain); + } + + public void WriteFloat(long addr, double value, string domain = null) + { + base.WriteFloat(addr, value, _isBigEndian, domain); + } + + #endregion + + #region 1 Byte + + public int ReadS8(long addr, string domain = null) + { + return (sbyte)ReadUnsignedByte(addr, domain); + } + + public uint ReadU8(long addr, string domain = null) + { + return (byte)ReadUnsignedByte(addr, domain); + } + + public void WriteS8(long addr, int value, string domain = null) + { + WriteSigned(addr, value, 1, domain); + } + + public void WriteU8(long addr, uint value, string domain = null) + { + WriteUnsignedByte(addr, value, domain); + } + + #endregion + + #region 2 Byte + public int ReadS16(long addr, string domain = null) + { + return (short)ReadSigned(addr, 2, domain); + } + + public void WriteS16(long addr, int value, string domain = null) + { + WriteSigned(addr, value, 2, domain); + } + + public uint ReadU16(long addr, string domain = null) + { + return (ushort)ReadUnsigned(addr, 2, domain); + } + + public void WriteU16(long addr, uint value, string domain = null) + { + WriteUnsigned(addr, value, 2, domain); + } + #endregion + + #region 3 Byte + + public int ReadS24(long addr, string domain = null) + { + return ReadSigned(addr, 3, domain); + } + public void WriteS24(long addr, int value, string domain = null) + { + WriteSigned(addr, value, 3, domain); + } + + public uint ReadU24(long addr, string domain = null) + { + return ReadUnsigned(addr, 3, domain); + } + + public void WriteU24(long addr, uint value, string domain = null) + { + WriteUnsigned(addr, value, 3, domain); + } + + #endregion + + #region 4 Byte + + public int ReadS32(long addr, string domain = null) + { + return ReadSigned(addr, 4, domain); + } + + public void WriteS32(long addr, int value, string domain = null) + { + WriteSigned(addr, value, 4, domain); + } + + public uint ReadU32(long addr, string domain = null) + { + return ReadUnsigned(addr, 4, domain); + } + + public void WriteU32(long addr, uint value, string domain = null) + { + WriteUnsigned(addr, value, 4, domain); + } + + #endregion + } +} \ No newline at end of file diff --git a/BizHawk.Client.ApiHawk/Classes/Api/MemApiBase.cs b/BizHawk.Client.ApiHawk/Classes/Api/MemApiBase.cs new file mode 100644 index 0000000000..dd6a6377a9 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/MemApiBase.cs @@ -0,0 +1,240 @@ +using System; +using System.Collections.Generic; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common.IEmulatorExtensions; + +namespace BizHawk.Client.ApiHawk +{ + /// + /// Base class for the Memory and MainMemory plugin libraries + /// + public abstract class MemApiBase : IExternalApi + { + [RequiredService] + protected IEmulator Emulator { get; set; } + + [OptionalService] + protected IMemoryDomains MemoryDomainCore { get; set; } + + protected abstract MemoryDomain Domain { get; } + + protected MemApiBase() + { } + + protected IMemoryDomains DomainList + { + get + { + if (MemoryDomainCore != null) + { + return MemoryDomainCore; + } + + var error = $"Error: {Emulator.Attributes().CoreName} does not implement memory domains"; + Console.WriteLine(error); + throw new NotImplementedException(error); + } + } + + public string VerifyMemoryDomain(string domain) + { + try + { + if (DomainList[domain] == null) + { + Console.WriteLine($"Unable to find domain: {domain}, falling back to current"); + return Domain.Name; + } + + return domain; + } + catch // Just in case + { + Console.WriteLine($"Unable to find domain: {domain}, falling back to current"); + } + + return Domain.Name; + } + + protected uint ReadUnsignedByte(long addr, string domain = null) + { + var d = string.IsNullOrEmpty(domain) ? Domain : DomainList[VerifyMemoryDomain(domain)]; + if (addr < d.Size) + { + return d.PeekByte(addr); + } + + Console.WriteLine($"Warning: attempted read of {addr} outside the memory size of {d.Size}"); + return 0; + } + + protected void WriteUnsignedByte(long addr, uint v, string domain = null) + { + var d = string.IsNullOrEmpty(domain) ? Domain : DomainList[VerifyMemoryDomain(domain)]; + if (d.CanPoke()) + { + if (addr < d.Size) + { + d.PokeByte(addr, (byte)v); + } + else + { + Console.WriteLine($"Warning: attempted write to {addr} outside the memory size of {d.Size}"); + } + } + else + { + Console.WriteLine($"Error: the domain {d.Name} is not writable"); + } + } + + protected static int U2S(uint u, int size) + { + var s = (int)u; + s <<= 8 * (4 - size); + s >>= 8 * (4 - size); + return s; + } + + protected int ReadSignedLittle(long addr, int size, string domain = null) + { + return U2S(ReadUnsignedLittle(addr, size, domain), size); + } + + protected uint ReadUnsignedLittle(long addr, int size, string domain = null) + { + uint v = 0; + for (var i = 0; i < size; ++i) + { + v |= ReadUnsignedByte(addr + i, domain) << (8 * i); + } + + return v; + } + + protected int ReadSignedBig(long addr, int size, string domain = null) + { + return U2S(ReadUnsignedBig(addr, size, domain), size); + } + + protected uint ReadUnsignedBig(long addr, int size, string domain = null) + { + uint v = 0; + for (var i = 0; i < size; ++i) + { + v |= ReadUnsignedByte(addr + i, domain) << (8 * (size - 1 - i)); + } + + return v; + } + + protected void WriteSignedLittle(long addr, int v, int size, string domain = null) + { + WriteUnsignedLittle(addr, (uint)v, size, domain); + } + + protected void WriteUnsignedLittle(long addr, uint v, int size, string domain = null) + { + for (var i = 0; i < size; ++i) + { + WriteUnsignedByte(addr + i, (v >> (8 * i)) & 0xFF, domain); + } + } + + protected void WriteSignedBig(long addr, int v, int size, string domain = null) + { + WriteUnsignedBig(addr, (uint)v, size, domain); + } + + protected void WriteUnsignedBig(long addr, uint v, int size, string domain = null) + { + for (var i = 0; i < size; ++i) + { + WriteUnsignedByte(addr + i, (v >> (8 * (size - 1 - i))) & 0xFF, domain); + } + } + + #region public Library implementations + + protected List ReadByteRange(long addr, int length, string domain = null) + { + var d = string.IsNullOrEmpty(domain) ? Domain : DomainList[VerifyMemoryDomain(domain)]; + var lastAddr = length + addr; + var list = new List(); + for (; addr <= lastAddr; addr++) + { + if (addr < d.Size) + list.Add(d.PeekByte(addr)); + else { + Console.WriteLine($"Warning: Attempted read {addr} outside memory domain size of {d.Size} in {nameof(ReadByteRange)}()"); + list.Add(0); + } + } + + return list; + } + + protected void WriteByteRange(long addr, List memoryblock, string domain = null) + { + var d = string.IsNullOrEmpty(domain) ? Domain : DomainList[VerifyMemoryDomain(domain)]; + if (d.CanPoke()) + { + for (var i = 0; i < memoryblock.Count; i++) + { + if (addr < d.Size) + { + d.PokeByte(addr++, memoryblock[i]); + } + else + { + Console.WriteLine($"Warning: Attempted write {addr} outside memory domain size of {d.Size} in {nameof(WriteByteRange)}()"); + } + } + } + else + { + Console.WriteLine($"Error: the domain {d.Name} is not writable"); + } + } + + protected float ReadFloat(long addr, bool bigendian, string domain = null) + { + var d = string.IsNullOrEmpty(domain) ? Domain : DomainList[VerifyMemoryDomain(domain)]; + if (addr < d.Size) + { + var val = d.PeekUint(addr, bigendian); + var bytes = BitConverter.GetBytes(val); + return BitConverter.ToSingle(bytes, 0); + } + + Console.WriteLine($"Warning: Attempted read {addr} outside memory size of {d.Size}"); + + return 0; + } + + protected void WriteFloat(long addr, double value, bool bigendian, string domain = null) + { + var d = string.IsNullOrEmpty(domain) ? Domain : DomainList[VerifyMemoryDomain(domain)]; + if (d.CanPoke()) + { + if (addr < d.Size) + { + var dv = (float)value; + var bytes = BitConverter.GetBytes(dv); + var v = BitConverter.ToUInt32(bytes, 0); + d.PokeUint(addr, v, bigendian); + } + else + { + Console.WriteLine($"Warning: Attempted write {addr} outside memory size of {d.Size}"); + } + } + else + { + Console.WriteLine($"Error: the domain {Domain.Name} is not writable"); + } + } + + #endregion + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/Api/MemEventsApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/MemEventsApi.cs new file mode 100644 index 0000000000..5848df5fc3 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/MemEventsApi.cs @@ -0,0 +1,45 @@ +using System; + +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common.IEmulatorExtensions; + +namespace BizHawk.Client.ApiHawk +{ + public sealed class MemEventsApi : IMemEvents + { + [RequiredService] + private IDebuggable DebuggableCore { get; set; } + + public MemEventsApi () : base() + { } + + public void AddReadCallback(Action cb, uint address, string domain) + { + if (DebuggableCore.MemoryCallbacksAvailable()) + { + DebuggableCore.MemoryCallbacks.Add(new MemoryCallback(domain, MemoryCallbackType.Read, "Plugin Hook", cb, address, null)); + } + } + public void AddWriteCallback(Action cb, uint address, string domain) + { + if (DebuggableCore.MemoryCallbacksAvailable()) + { + DebuggableCore.MemoryCallbacks.Add(new MemoryCallback(domain, MemoryCallbackType.Write, "Plugin Hook", cb, address, null)); + } + } + public void AddExecCallback(Action cb, uint address, string domain) + { + if (DebuggableCore.MemoryCallbacksAvailable() && DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable) + { + DebuggableCore.MemoryCallbacks.Add(new MemoryCallback(domain, MemoryCallbackType.Execute, "Plugin Hook", cb, address, null)); + } + } + public void RemoveMemoryCallback(Action cb) + { + if (DebuggableCore.MemoryCallbacksAvailable()) + { + DebuggableCore.MemoryCallbacks.Remove(cb); + } + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/Api/MemorySaveStateApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/MemorySaveStateApi.cs new file mode 100644 index 0000000000..b22eaa7540 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/MemorySaveStateApi.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.IO; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.ApiHawk +{ + public sealed class MemorySaveStateApi : IMemorySaveState + { + public MemorySaveStateApi() + { } + + [RequiredService] + private IStatable StatableCore { get; set; } + + private readonly Dictionary _memorySavestates = new Dictionary(); + + public string SaveCoreStateToMemory() + { + var guid = Guid.NewGuid(); + var bytes = (byte[])StatableCore.SaveStateBinary().Clone(); + + _memorySavestates.Add(guid, bytes); + + return guid.ToString(); + } + + public void LoadCoreStateFromMemory(string identifier) + { + var guid = new Guid(identifier); + + try + { + var state = _memorySavestates[guid]; + + using (var ms = new MemoryStream(state)) + using (var br = new BinaryReader(ms)) + { + StatableCore.LoadStateBinary(br); + } + } + catch + { + Console.WriteLine("Unable to find the given savestate in memory"); + } + } + + public void DeleteState(string identifier) + { + var guid = new Guid(identifier); + _memorySavestates.Remove(guid); + } + + public void ClearInMemoryStates() + { + _memorySavestates.Clear(); + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/Api/MovieApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/MovieApi.cs new file mode 100644 index 0000000000..049cdb4fa3 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/MovieApi.cs @@ -0,0 +1,288 @@ +using System; +using System.Collections.Generic; +using System.IO; + +using BizHawk.Client.Common; + +namespace BizHawk.Client.ApiHawk +{ + public sealed class MovieApi : IMovie + { + private static class MoviePluginStatic + { + public static string Filename() + { + return Global.MovieSession.Movie.Filename; + } + + public static bool GetReadOnly() + { + return Global.MovieSession.ReadOnly; + } + + public static ulong GetRerecordCount() + { + return Global.MovieSession.Movie.Rerecords; + } + + public static bool GetRerecordCounting() + { + return Global.MovieSession.Movie.IsCountingRerecords; + } + + public static bool IsLoaded() + { + return Global.MovieSession.Movie.IsActive; + } + + public static double Length() + { + return Global.MovieSession.Movie.FrameCount; + } + + public static string Mode() + { + if (Global.MovieSession.Movie.IsFinished) + { + return "FINISHED"; + } + + if (Global.MovieSession.Movie.IsPlaying) + { + return "PLAY"; + } + + if (Global.MovieSession.Movie.IsRecording) + { + return "RECORD"; + } + + return "INACTIVE"; + } + + public static void SetReadOnly(bool readOnly) + { + Global.MovieSession.ReadOnly = readOnly; + } + + public static void SetRerecordCount(double count) + { + // Lua numbers are always double, integer precision holds up + // to 53 bits, so throw an error if it's bigger than that. + const double PrecisionLimit = 9007199254740992d; + + if (count > PrecisionLimit) + { + throw new Exception("Rerecord count exceeds Lua integer precision."); + } + + Global.MovieSession.Movie.Rerecords = (ulong)count; + } + + public static void SetRerecordCounting(bool counting) + { + Global.MovieSession.Movie.IsCountingRerecords = counting; + } + + public static void Stop() + { + Global.MovieSession.Movie.Stop(); + } + + public static double GetFps() + { + if (Global.MovieSession.Movie.IsActive) + { + var movie = Global.MovieSession.Movie; + var system = movie.HeaderEntries[HeaderKeys.PLATFORM]; + var pal = movie.HeaderEntries.ContainsKey(HeaderKeys.PAL) && + movie.HeaderEntries[HeaderKeys.PAL] == "1"; + + return new PlatformFrameRates()[system, pal]; + } + + return 0.0; + } + + } + public MovieApi() + { } + + public bool StartsFromSavestate() + { + return Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSavestate; + } + + public bool StartsFromSaveram() + { + return Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.StartsFromSaveRam; + } + + public Dictionary GetInput(int frame) + { + if (!Global.MovieSession.Movie.IsActive) + { + Console.WriteLine("No movie loaded"); + return null; + } + + var input = new Dictionary(); + var adapter = Global.MovieSession.Movie.GetInputState(frame); + + if (adapter == null) + { + Console.WriteLine("Can't get input of the last frame of the movie. Use the previous frame"); + return null; + } + + foreach (var button in adapter.Definition.BoolButtons) + { + input[button] = adapter.IsPressed(button); + } + + foreach (var button in adapter.Definition.FloatControls) + { + input[button] = adapter.GetFloat(button); + } + + return input; + } + + public string GetInputAsMnemonic(int frame) + { + if (Global.MovieSession.Movie.IsActive && frame < Global.MovieSession.Movie.InputLogLength) + { + var lg = Global.MovieSession.LogGeneratorInstance(); + lg.SetSource(Global.MovieSession.Movie.GetInputState(frame)); + return lg.GenerateLogEntry(); + } + + return ""; + } + + public void Save(string filename = "") + { + if (!Global.MovieSession.Movie.IsActive) + { + return; + } + + if (!string.IsNullOrEmpty(filename)) + { + filename += $".{Global.MovieSession.Movie.PreferredExtension}"; + var test = new FileInfo(filename); + if (test.Exists) + { + Console.WriteLine($"File {filename} already exists, will not overwrite"); + return; + } + + Global.MovieSession.Movie.Filename = filename; + } + + Global.MovieSession.Movie.Save(); + } + + public Dictionary GetHeader() + { + var table = new Dictionary(); + if (Global.MovieSession.Movie.IsActive) + { + foreach (var kvp in Global.MovieSession.Movie.HeaderEntries) + { + table[kvp.Key] = kvp.Value; + } + } + + return table; + } + + public List GetComments() + { + var list = new List(Global.MovieSession.Movie.Comments.Count); + if (Global.MovieSession.Movie.IsActive) + { + for (int i = 0; i < Global.MovieSession.Movie.Comments.Count; i++) + { + list[i] = Global.MovieSession.Movie.Comments[i]; + } + } + + return list; + } + + public List GetSubtitles() + { + var list = new List(Global.MovieSession.Movie.Subtitles.Count); + if (Global.MovieSession.Movie.IsActive) + { + for (int i = 0; i < Global.MovieSession.Movie.Subtitles.Count; i++) + { + list[i] = Global.MovieSession.Movie.Subtitles[i].ToString(); + } + } + + return list; + } + + public string Filename() + { + return MoviePluginStatic.Filename(); + } + + public bool GetReadOnly() + { + return MoviePluginStatic.GetReadOnly(); + } + + public ulong GetRerecordCount() + { + return MoviePluginStatic.GetRerecordCount(); + } + + public bool GetRerecordCounting() + { + return MoviePluginStatic.GetRerecordCounting(); + } + + public bool IsLoaded() + { + return MoviePluginStatic.IsLoaded(); + } + + public double Length() + { + return MoviePluginStatic.Length(); + } + + public string Mode() + { + return MoviePluginStatic.Mode(); + } + + public void SetReadOnly(bool readOnly) + { + MoviePluginStatic.SetReadOnly(readOnly); + } + + public void SetRerecordCount(double count) + { + MoviePluginStatic.SetRerecordCount(count); + } + + public void SetRerecordCounting(bool counting) + { + MoviePluginStatic.SetRerecordCounting(counting); + } + + public void Stop() + { + MoviePluginStatic.Stop(); + } + + public double GetFps() + { + return MoviePluginStatic.GetFps(); + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/Api/PluginBase.cs b/BizHawk.Client.ApiHawk/Classes/Api/PluginBase.cs new file mode 100644 index 0000000000..24bf62c727 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/PluginBase.cs @@ -0,0 +1,50 @@ +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.ApiHawk +{ + public abstract class PluginBase : IPlugin + { + /// + /// The base class from which all + /// plugins will be derived + /// + /// Actual plugins should implement + /// one of the below callback methods + /// or register memory callbacks in + /// their Init function. + /// + protected IApiContainer _api; + + public PluginBase() { } + + public abstract string Name { get; } + public abstract string Description { get; } + + public bool Enabled => Running; + public bool Paused => !Running; + + public bool Running { get; set; } + + public void Stop() + { + Running = false; + } + + public void Toggle() + { + Running = !Running; + } + + public virtual void PreFrameCallback() { } + public virtual void PostFrameCallback() { } + public virtual void SaveStateCallback(string name) { } + public virtual void LoadStateCallback(string name) { } + public virtual void InputPollCallback() { } + public virtual void ExitCallback() { } + public virtual void Init (IApiContainer api) + { + _api = api; + Running = true; + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/Api/SqlApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/SqlApi.cs new file mode 100644 index 0000000000..4b66a827f9 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/SqlApi.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data.SQLite; + +namespace BizHawk.Client.ApiHawk +{ + public sealed class SqlApi : ISql + { + public SqlApi() : base() + { } + + SQLiteConnection m_dbConnection; + string connectionString; + + public string CreateDatabase(string name) + { + try + { + SQLiteConnection.CreateFile(name); + return "Database Created Successfully"; + } + catch (SQLiteException sqlEX) + { + return sqlEX.Message; + } + + } + + public string OpenDatabase(string name) + { + try + { + SQLiteConnectionStringBuilder connBuilder = new SQLiteConnectionStringBuilder(); + connBuilder.DataSource = name; + connBuilder.Version = 3; //SQLite version + connBuilder.JournalMode = SQLiteJournalModeEnum.Wal; //Allows for reads and writes to happen at the same time + connBuilder.DefaultIsolationLevel = System.Data.IsolationLevel.ReadCommitted; //This only helps make the database lock left. May be pointless now + connBuilder.SyncMode = SynchronizationModes.Off; //This shortens the delay for do synchronous calls. + m_dbConnection = new SQLiteConnection(connBuilder.ToString()); + connectionString = connBuilder.ToString(); + m_dbConnection.Open(); + m_dbConnection.Close(); + return "Database Opened Successfully"; + } + catch (SQLiteException sqlEX) + { + return sqlEX.Message; + } + } + + public string WriteCommand(string query = "") + { + if (query == "") + { + return "query is empty"; + } + try + { + m_dbConnection.Open(); + string sql = query; + SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); + command.ExecuteNonQuery(); + m_dbConnection.Close(); + + return "Command ran successfully"; + + } + catch (NullReferenceException nullEX) + { + return "Database not open."; + } + catch (SQLiteException sqlEX) + { + m_dbConnection.Close(); + return sqlEX.Message; + } + } + + public dynamic ReadCommand(string query = "") + { + if (query == "") + { + return "query is empty"; + } + try + { + var table = new Dictionary(); + m_dbConnection.Open(); + string sql = $"PRAGMA read_uncommitted =1;{query}"; + SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); + SQLiteDataReader reader = command.ExecuteReader(); + bool rows = reader.HasRows; + long rowCount = 0; + var columns = new List(); + for (int i = 0; i < reader.FieldCount; ++i) //Add all column names into list + { + columns.Add(reader.GetName(i)); + } + while (reader.Read()) + { + for (int i = 0; i < reader.FieldCount; ++i) + { + table[$"{columns[i]} {rowCount}"] = reader.GetValue(i); + } + rowCount += 1; + } + reader.Close(); + m_dbConnection.Close(); + if (rows == false) + { + return "No rows found"; + } + + return table; + + } + catch (NullReferenceException) + { + return "Database not opened."; + } + catch (SQLiteException sqlEX) + { + m_dbConnection.Close(); + return sqlEX.Message; + } + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/Api/UserDataApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/UserDataApi.cs new file mode 100644 index 0000000000..735fe397b9 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/Api/UserDataApi.cs @@ -0,0 +1,52 @@ +using System; +using System.ComponentModel; + +using BizHawk.Client.Common; + +namespace BizHawk.Client.ApiHawk +{ + public sealed class UserDataApi : IUserData + { + public UserDataApi() : base() + { } + + public void Set(string name, object value) + { + if (value != null) + { + var t = value.GetType(); + if (!t.IsPrimitive && t != typeof(string)) + { + throw new InvalidOperationException("Invalid type for userdata"); + } + } + + Global.UserBag[name] = value; + } + + public object Get(string key) + { + if (Global.UserBag.ContainsKey(key)) + { + return Global.UserBag[key]; + } + + return null; + } + + public void Clear() + { + Global.UserBag.Clear(); + } + + public bool Remove(string key) + { + return Global.UserBag.Remove(key); + } + + public bool ContainsKey(string key) + { + return Global.UserBag.ContainsKey(key); + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/ApiInjector.cs b/BizHawk.Client.ApiHawk/Classes/ApiInjector.cs new file mode 100644 index 0000000000..811807659f --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/ApiInjector.cs @@ -0,0 +1,79 @@ +using System; +using System.Linq; + +using BizHawk.Common.ReflectionExtensions; + +namespace BizHawk.Client.ApiHawk +{ + /// + /// injects Apis into other classes + /// + public static class ApiInjector + { + /// + /// clears all Apis from a target + /// + public static void ClearApis(object target) + { + Type targetType = target.GetType(); + object[] tmp = new object[1]; + + foreach (var propinfo in + targetType.GetPropertiesWithAttrib(typeof(RequiredApiAttribute)) + .Concat(targetType.GetPropertiesWithAttrib(typeof(OptionalApiAttribute)))) + { + propinfo.GetSetMethod(true).Invoke(target, tmp); + } + } + + /// + /// Feeds the target its required Apis. + /// + /// false if update failed + public static bool UpdateApis(IExternalApiProvider source, object target) + { + Type targetType = target.GetType(); + object[] tmp = new object[1]; + + foreach (var propinfo in targetType.GetPropertiesWithAttrib(typeof(RequiredApiAttribute))) + { + tmp[0] = source.GetApi(propinfo.PropertyType); + if (tmp[0] == null) + { + return false; + } + + propinfo.GetSetMethod(true).Invoke(target, tmp); + } + + foreach (var propinfo in targetType.GetPropertiesWithAttrib(typeof(OptionalApiAttribute))) + { + tmp[0] = source.GetApi(propinfo.PropertyType); + propinfo.GetSetMethod(true).Invoke(target, tmp); + } + + return true; + } + + /// + /// Determines whether a target is available, considering its dependencies + /// and the Apis provided by the emulator core. + /// + public static bool IsAvailable(IExternalApiProvider source, Type targetType) + { + return targetType.GetPropertiesWithAttrib(typeof(RequiredApiAttribute)) + .Select(pi => pi.PropertyType) + .All(source.HasApi); + } + } + + [AttributeUsage(AttributeTargets.Property)] + public class RequiredApiAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Property)] + public class OptionalApiAttribute : Attribute + { + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/BasicApiProvider.cs b/BizHawk.Client.ApiHawk/Classes/BasicApiProvider.cs new file mode 100644 index 0000000000..75da59a6d4 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Classes/BasicApiProvider.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace BizHawk.Client.ApiHawk +{ + /// + /// A generic implementation of IExternalApi provider that provides + /// this functionality to any core. + /// The provider will scan an IExternal and register all IExternalApis + /// that the core object itself implements. In addition it provides + /// a Register() method to allow the core to pass in any additional Apis + /// + /// + public class BasicApiProvider : IExternalApiProvider + { + private readonly Dictionary _Apis = new Dictionary(); + + public BasicApiProvider(IApiContainer container) + { + // simplified logic here doesn't scan for possible Apis; just adds what it knows is implemented by the PluginApi + // this removes the possibility of automagically picking up a Api in a nested class, (find the type, then + // find the field), but we're going to keep such logic out of the basic provider. Anything the passed + // container doesn't implement directly needs to be added with Register() + // this also fully allows apis that are not IExternalApi + var libs = container.Libraries; + + _Apis = libs; + } + + /// + /// the client can call this to register an additional Api + /// + /// The to register + public void Register(T api) + where T : IExternalApi + { + if (api == null) + { + throw new ArgumentNullException(nameof(api)); + } + + _Apis[typeof(T)] = api; + } + + public T GetApi() + where T : IExternalApi + { + return (T)GetApi(typeof(T)); + } + + public object GetApi(Type t) + { + IExternalApi Api; + KeyValuePair[] k = _Apis.Where(kvp => t.IsAssignableFrom(kvp.Key)).ToArray(); + if (k.Length > 0) + { + return k[0].Value; + } + + return null; + } + + public bool HasApi() + where T : IExternalApi + { + return HasApi(typeof(T)); + } + + public bool HasApi(Type t) + { + return _Apis.ContainsKey(t); + } + + public IEnumerable AvailableApis + { + get + { + return _Apis.Select(d => d.Key); + } + } + } +} diff --git a/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs b/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs index 935df8122f..a9d0fdafe6 100644 --- a/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs +++ b/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs @@ -102,6 +102,9 @@ namespace BizHawk.Client.ApiHawk case "AmstradCPC": return CoreSystem.AmstradCPC; + case "GGL": + return CoreSystem.GGL; + case "VB": case "NGP": case "DNGP": @@ -112,7 +115,7 @@ namespace BizHawk.Client.ApiHawk return 0; // like I give a shit default: - throw new IndexOutOfRangeException(string.Format("{0} is missing in convert list", value)); + throw new IndexOutOfRangeException($"{value} is missing in convert list"); } } @@ -218,7 +221,7 @@ namespace BizHawk.Client.ApiHawk return "AmstradCPC"; default: - throw new IndexOutOfRangeException(string.Format("{0} is missing in convert list", value.ToString())); + throw new IndexOutOfRangeException($"{value.ToString()} is missing in convert list"); } } diff --git a/BizHawk.Client.ApiHawk/Classes/ClientApi.cs b/BizHawk.Client.ApiHawk/Classes/ClientApi.cs index 767d755105..0a1e1caa42 100644 --- a/BizHawk.Client.ApiHawk/Classes/ClientApi.cs +++ b/BizHawk.Client.ApiHawk/Classes/ClientApi.cs @@ -5,6 +5,7 @@ using System.Reflection; using System.Threading.Tasks; using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.PCEngine; using BizHawk.Emulation.Cores.Sega.MasterSystem; @@ -21,6 +22,9 @@ namespace BizHawk.Client.ApiHawk { #region Fields + private static IEmulator Emulator; + private static IVideoProvider VideoProvider; + private static readonly Assembly clientAssembly; private static readonly object clientMainFormInstance; private static readonly Type mainFormClass; @@ -68,24 +72,57 @@ namespace BizHawk.Client.ApiHawk mainFormClass = clientAssembly.GetType("BizHawk.Client.EmuHawk.MainForm"); } + public static void UpdateEmulatorAndVP(IEmulator emu = null) + { + Emulator = emu; + VideoProvider = Emulation.Common.IEmulatorExtensions.Extensions.AsVideoProviderOrDefault(emu); + } + #endregion #region Methods + #region Helpers + + private static void InvokeMainFormMethod(string name, dynamic[] paramList = null) + { + List typeList = new List(); + MethodInfo method; + if (paramList != null) + { + foreach (var obj in paramList) + { + typeList.Add(obj.GetType()); + } + method = mainFormClass.GetMethod(name, typeList.ToArray()); + } + else method = mainFormClass.GetMethod(name); + method.Invoke(clientMainFormInstance, paramList); + } + + private static object GetMainFormField(string name) + { + return mainFormClass.GetField(name); + } + + private static void SetMainFormField(string name, object value) + { + mainFormClass.GetField(name).SetValue(clientMainFormInstance, value); + } + + #endregion + #region Public /// /// THE FrameAdvance stuff /// public static void DoFrameAdvance() { - MethodInfo method = mainFormClass.GetMethod("FrameAdvance"); - method.Invoke(clientMainFormInstance, null); + InvokeMainFormMethod("FrameAdvance", null); - method = mainFormClass.GetMethod("StepRunLoop_Throttle", BindingFlags.NonPublic | BindingFlags.Instance); - method.Invoke(clientMainFormInstance, null); + InvokeMainFormMethod("StepRunLoop_Throttle", null); - method = mainFormClass.GetMethod("Render", BindingFlags.NonPublic | BindingFlags.Instance); - method.Invoke(clientMainFormInstance, null); + InvokeMainFormMethod("Render", null); } /// @@ -108,7 +145,7 @@ namespace BizHawk.Client.ApiHawk { if (player < 1 || player > RunningSystem.MaxControllers) { - throw new IndexOutOfRangeException(string.Format("{0} does not support {1} controller(s)", RunningSystem.DisplayName, player)); + throw new IndexOutOfRangeException($"{RunningSystem.DisplayName} does not support {player} controller(s)"); } else { @@ -124,8 +161,7 @@ namespace BizHawk.Client.ApiHawk /// Savetate friendly name public static void LoadState(string name) { - MethodInfo method = mainFormClass.GetMethod("LoadState"); - method.Invoke(clientMainFormInstance, new object[] { Path.Combine(PathManager.GetSaveStatePath(Global.Game), string.Format("{0}.{1}", name, "State")), name, false, false }); + InvokeMainFormMethod("LoadState", new object[] { Path.Combine(PathManager.GetSaveStatePath(Global.Game), $"{name}.{"State"}"), name, false, false }); } @@ -194,12 +230,11 @@ namespace BizHawk.Client.ApiHawk /// /// Raise when a rom is successfully Loaded /// - public static void OnRomLoaded() + public static void OnRomLoaded(IEmulator emu) { - if (RomLoaded != null) - { - RomLoaded(null, EventArgs.Empty); - } + Emulator = emu; + VideoProvider = Emulation.Common.IEmulatorExtensions.Extensions.AsVideoProviderOrDefault(emu); + RomLoaded?.Invoke(null, EventArgs.Empty); allJoypads = new List(RunningSystem.MaxControllers); for (int i = 1; i <= RunningSystem.MaxControllers; i++) @@ -215,10 +250,55 @@ namespace BizHawk.Client.ApiHawk /// Savetate friendly name public static void SaveState(string name) { - MethodInfo method = mainFormClass.GetMethod("SaveState"); - method.Invoke(clientMainFormInstance, new object[] { Path.Combine(PathManager.GetSaveStatePath(Global.Game), string.Format("{0}.{1}", name, "State")), name, false }); + InvokeMainFormMethod("SaveState", new object[] { Path.Combine(PathManager.GetSaveStatePath(Global.Game), $"{name}.{"State"}"), name, false }); } + /// + /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements + /// + /// Left padding + /// Top padding + /// Right padding + /// Bottom padding + public static void SetGameExtraPadding(int left, int top, int right, int bottom) + { + FieldInfo f = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin").GetField("DisplayManager"); + object displayManager = f.GetValue(null); + f = f.FieldType.GetField("GameExtraPadding"); + f.SetValue(displayManager, new Padding(left, top, right, bottom)); + + InvokeMainFormMethod("FrameBufferResized"); + } + + /// + /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements + /// + /// Left padding + public static void SetGameExtraPadding(int left) + { + SetGameExtraPadding(left, 0, 0, 0); + } + + /// + /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements + /// + /// Left padding + /// Top padding + public static void SetGameExtraPadding(int left, int top) + { + SetGameExtraPadding(left, top, 0, 0); + } + + /// + /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements + /// + /// Left padding + /// Top padding + /// Right padding + public static void SetGameExtraPadding(int left, int top, int right) + { + SetGameExtraPadding(left, top, right, 0); + } /// /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements @@ -234,8 +314,7 @@ namespace BizHawk.Client.ApiHawk f = f.FieldType.GetField("ClientExtraPadding"); f.SetValue(displayManager, new Padding(left, top, right, bottom)); - MethodInfo resize = mainFormClass.GetMethod("FrameBufferResized"); - resize.Invoke(clientMainFormInstance, null); + InvokeMainFormMethod("FrameBufferResized"); } /// @@ -268,7 +347,6 @@ namespace BizHawk.Client.ApiHawk SetExtraPadding(left, top, right, 0); } - /// /// Set inputs in specified to specified player /// @@ -280,7 +358,7 @@ namespace BizHawk.Client.ApiHawk { if (player < 1 || player > RunningSystem.MaxControllers) { - throw new IndexOutOfRangeException(string.Format("{0} does not support {1} controller(s)", RunningSystem.DisplayName, player)); + throw new IndexOutOfRangeException($"{RunningSystem.DisplayName} does not support {player} controller(s)"); } else { @@ -298,11 +376,11 @@ namespace BizHawk.Client.ApiHawk AutoFireStickyXorAdapter joypadAdaptor = Global.AutofireStickyXORAdapter; if (RunningSystem == SystemInfo.GB) { - joypadAdaptor.SetSticky(string.Format("{0}", JoypadConverter.ConvertBack(button, RunningSystem)), true); + joypadAdaptor.SetSticky($"{JoypadConverter.ConvertBack(button, RunningSystem)}", true); } else { - joypadAdaptor.SetSticky(string.Format("P{0} {1}", player, JoypadConverter.ConvertBack(button, RunningSystem)), true); + joypadAdaptor.SetSticky($"P{player} {JoypadConverter.ConvertBack(button, RunningSystem)}", true); } } } @@ -314,8 +392,8 @@ namespace BizHawk.Client.ApiHawk AutoFireStickyXorAdapter joypadAdaptor = Global.AutofireStickyXORAdapter; for (int i = 1; i <= RunningSystem.MaxControllers; i++) { - joypadAdaptor.SetFloat(string.Format("P{0} X Axis", i), allJoypads[i - 1].AnalogX); - joypadAdaptor.SetFloat(string.Format("P{0} Y Axis", i), allJoypads[i - 1].AnalogY); + joypadAdaptor.SetFloat($"P{i} X Axis", allJoypads[i - 1].AnalogX); + joypadAdaptor.SetFloat($"P{i} Y Axis", allJoypads[i - 1].AnalogY); } }*/ } @@ -327,8 +405,7 @@ namespace BizHawk.Client.ApiHawk /// public static void UnpauseEmulation() { - MethodInfo method = mainFormClass.GetMethod("UnpauseEmulator"); - method.Invoke(clientMainFormInstance, null); + InvokeMainFormMethod("UnpauseEmulator", null); } #endregion Public @@ -369,12 +446,281 @@ namespace BizHawk.Client.ApiHawk { for (int i = 1; i <= RunningSystem.MaxControllers; i++) { - allJoypads[i - 1].AnalogX = joypadAdaptor.GetFloat(string.Format("P{0} X Axis", i)); - allJoypads[i - 1].AnalogY = joypadAdaptor.GetFloat(string.Format("P{0} Y Axis", i)); + allJoypads[i - 1].AnalogX = joypadAdaptor.GetFloat($"P{i} X Axis"); + allJoypads[i - 1].AnalogY = joypadAdaptor.GetFloat($"P{i} Y Axis"); } } } + public static void CloseEmulator() + { + InvokeMainFormMethod("CloseEmulator"); + } + + public static void CloseEmulatorWithCode(int exitCode) + { + InvokeMainFormMethod("CloseEmulator", new object[] {exitCode}); + } + + public static int BorderHeight() + { + var point = new System.Drawing.Point(0, 0); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin"); + FieldInfo f = t.GetField("DisplayManager"); + object displayManager = f.GetValue(null); + MethodInfo m = t.GetMethod("TransFormPoint"); + point = (System.Drawing.Point) m.Invoke(displayManager, new object[] { point }); + return point.Y; + } + + public static int BorderWidth() + { + var point = new System.Drawing.Point(0, 0); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin"); + FieldInfo f = t.GetField("DisplayManager"); + object displayManager = f.GetValue(null); + MethodInfo m = t.GetMethod("TransFormPoint"); + point = (System.Drawing.Point)m.Invoke(displayManager, new object[] { point }); + return point.X; + } + + public static int BufferHeight() + { + return VideoProvider.BufferHeight; + } + + public static int BufferWidth() + { + return VideoProvider.BufferWidth; + } + + public static void ClearAutohold() + { + InvokeMainFormMethod("ClearHolds"); + } + + public static void CloseRom() + { + InvokeMainFormMethod("CloseRom"); + } + + public static void DisplayMessages(bool value) + { + Global.Config.DisplayMessages = value; + } + + public static void EnableRewind(bool enabled) + { + InvokeMainFormMethod("EnableRewind", new object[] {enabled}); + } + + public static void FrameSkip(int numFrames) + { + if (numFrames > 0) + { + Global.Config.FrameSkip = numFrames; + InvokeMainFormMethod("FrameSkipMessage"); + } + else + { + Console.WriteLine("Invalid frame skip value"); + } + } + + public static int GetTargetScanlineIntensity() + { + return Global.Config.TargetScanlineFilterIntensity; + } + + public static int GetWindowSize() + { + return Global.Config.TargetZoomFactors[Emulator.SystemId]; + } + + public static void SetSoundOn(bool enable) + { + Global.Config.SoundEnabled = enable; + } + + public static bool GetSoundOn() + { + return Global.Config.SoundEnabled; + } + + public static bool IsPaused() + { + return (bool) GetMainFormField("EmulatorPaused"); + } + + public static bool IsTurbo() + { + return (bool)GetMainFormField("IsTurboing"); + } + + public static bool IsSeeking() + { + return (bool)GetMainFormField("IsSeeking"); + } + + public static void OpenRom(string path) + { + var ioa = OpenAdvancedSerializer.ParseWithLegacy(path); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin.MainForm.LoadRomArgs"); + object o = Activator.CreateInstance(t); + t.GetField("OpenAdvanced").SetValue(o, ioa); + + InvokeMainFormMethod("LoadRom", new object[] {path, o}); + } + + public static void Pause() + { + InvokeMainFormMethod("PauseEmulator"); + } + + public static void PauseAv() + { + SetMainFormField("PauseAvi", true); + } + + public static void RebootCore() + { + InvokeMainFormMethod("RebootCore"); + } + + public static void SaveRam() + { + InvokeMainFormMethod("FlushSaveRAM"); + } + + public static int ScreenHeight() + { + Type t = GetMainFormField("PresentationPanel").GetType(); + object o = GetMainFormField("PresentationPanel"); + o = t.GetField("NativeSize").GetValue(o); + t = t.GetField("NativeSize").GetType(); + + return (int) t.GetField("Height").GetValue(o); + } + + public static void Screenshot(string path = null) + { + if (path == null) + { + InvokeMainFormMethod("TakeScreenshot"); + } + else + { + InvokeMainFormMethod("TakeScreenshot", new object[] {path}); + } + } + + public static void ScreenshotToClipboard() + { + InvokeMainFormMethod("TakeScreenshotToClipboard"); + } + + public static void SetTargetScanlineIntensity(int val) + { + Global.Config.TargetScanlineFilterIntensity = val; + } + + public static void SetScreenshotOSD(bool value) + { + Global.Config.Screenshot_CaptureOSD = value; + } + + public static int ScreenWidth() + { + Type t = GetMainFormField("PresentationPanel").GetType(); + object o = GetMainFormField("PresentationPanel"); + o = t.GetField("NativeSize").GetValue(o); + t = t.GetField("NativeSize").GetType(); + + return (int) t.GetField("Width").GetValue(o); + } + + public static void SetWindowSize(int size) + { + if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10) + { + Global.Config.TargetZoomFactors[Emulator.SystemId] = size; + InvokeMainFormMethod("FrameBufferResized"); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin"); + FieldInfo f = t.GetField("OSD"); + object osd = f.GetValue(null); + t = f.GetType(); + MethodInfo m = t.GetMethod("AddMessage"); + m.Invoke(osd, new Object[] { $"Window size set to {size}x" }); + } + else + { + Console.WriteLine("Invalid window size"); + } + } + + public static void SpeedMode(int percent) + { + if (percent > 0 && percent < 6400) + { + InvokeMainFormMethod("ClickSpeedItem", new object[] {percent}); + } + else + { + Console.WriteLine("Invalid speed value"); + } + } + + public static void TogglePause() + { + InvokeMainFormMethod("TogglePause"); + } + + public static int TransformPointX(int x) + { + var point = new System.Drawing.Point(x, 0); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin"); + FieldInfo f = t.GetField("DisplayManager"); + object displayManager = f.GetValue(null); + MethodInfo m = t.GetMethod("TransFormPoint"); + point = (System.Drawing.Point)m.Invoke(displayManager, new object[] { point }); + return point.X; + } + + public static int TransformPointY(int y) + { + var point = new System.Drawing.Point(0, y); + Type t = clientAssembly.GetType("BizHawk.Client.EmuHawk.GlobalWin"); + FieldInfo f = t.GetField("DisplayManager"); + object displayManager = f.GetValue(null); + MethodInfo m = t.GetMethod("TransFormPoint"); + point = (System.Drawing.Point)m.Invoke(displayManager, new object[] { point }); + return point.Y; + } + + public static void Unpause() + { + InvokeMainFormMethod("UnpauseEmulator"); + } + + public static void UnpauseAv() + { + SetMainFormField("PauseAvi", false); + } + + public static int Xpos() + { + object o = GetMainFormField("DesktopLocation"); + Type t = mainFormClass.GetField("DesktopLocation").GetType(); + return (int)t.GetField("X").GetValue(o); + } + + public static int Ypos() + { + object o = GetMainFormField("DesktopLocation"); + Type t = mainFormClass.GetField("DesktopLocation").GetType(); + return (int)t.GetField("Y").GetValue(o); + } + #endregion #region Properties @@ -427,11 +773,11 @@ namespace BizHawk.Client.ApiHawk } else { - return SystemInfo.DualGB; + return SystemInfo.DualGB; } default: - return SystemInfo.FindByCoreSystem(SystemIdConverter.Convert(Global.Emulator.SystemId)); + return SystemInfo.FindByCoreSystem(SystemIdConverter.Convert(Global.Emulator.SystemId)); } } } diff --git a/BizHawk.Client.ApiHawk/Classes/ExternalToolManager.cs b/BizHawk.Client.ApiHawk/Classes/ExternalToolManager.cs index 54a9ccfa37..b9371e7358 100644 --- a/BizHawk.Client.ApiHawk/Classes/ExternalToolManager.cs +++ b/BizHawk.Client.ApiHawk/Classes/ExternalToolManager.cs @@ -94,7 +94,7 @@ namespace BizHawk.Client.ApiHawk item.ToolTipText = attribute.Description; if (attribute.IconResourceName != "") { - Stream s = externalToolFile.GetManifestResourceStream(string.Format("{0}.{1}", externalToolFile.GetName().Name, attribute.IconResourceName)); + Stream s = externalToolFile.GetManifestResourceStream($"{externalToolFile.GetName().Name}.{attribute.IconResourceName}"); if (s != null) { item.Image = new Bitmap(s); diff --git a/BizHawk.Client.ApiHawk/Classes/Joypad.cs b/BizHawk.Client.ApiHawk/Classes/Joypad.cs index d13273e64e..6848a106bd 100644 --- a/BizHawk.Client.ApiHawk/Classes/Joypad.cs +++ b/BizHawk.Client.ApiHawk/Classes/Joypad.cs @@ -29,7 +29,7 @@ namespace BizHawk.Client.ApiHawk { if (player < 1 || player > system.MaxControllers) { - throw new InvalidOperationException(string.Format("{0} is invalid for {1}", player, system.DisplayName)); + throw new InvalidOperationException($"{player} is invalid for {system.DisplayName}"); } _System = system; diff --git a/BizHawk.Client.ApiHawk/Classes/JoypadStringToEnumConverter.cs b/BizHawk.Client.ApiHawk/Classes/JoypadStringToEnumConverter.cs index 0e82da2ea2..638e93b329 100644 --- a/BizHawk.Client.ApiHawk/Classes/JoypadStringToEnumConverter.cs +++ b/BizHawk.Client.ApiHawk/Classes/JoypadStringToEnumConverter.cs @@ -91,7 +91,7 @@ namespace BizHawk.Client.ApiHawk return JoypadButton.R; default: - throw new IndexOutOfRangeException(string.Format("{0} is missing in convert list", value)); + throw new IndexOutOfRangeException($"{value} is missing in convert list"); } } @@ -210,7 +210,7 @@ namespace BizHawk.Client.ApiHawk return "R"; default: - throw new IndexOutOfRangeException(string.Format("{0} is missing in convert list", value)); + throw new IndexOutOfRangeException($"{value} is missing in convert list"); } } diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IApiContainer.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IApiContainer.cs new file mode 100644 index 0000000000..ec169fee9d --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IApiContainer.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IApiContainer + { + Dictionary Libraries { get; set; } + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IComm.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IComm.cs new file mode 100644 index 0000000000..9ef8a5e0c0 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IComm.cs @@ -0,0 +1,35 @@ +namespace BizHawk.Client.ApiHawk +{ + public interface IComm : IExternalApi + { + #region Sockets + string SocketServerScreenShot(); + string SocketServerScreenShotResponse(); + string SocketServerSend(string SendString); + string SocketServerResponse(); + bool SocketServerSuccessful(); + void SocketServerSetTimeout(int timeout); + #endregion + + #region MemoryMappedFiles + void MmfSetFilename(string filename); + string MmfSetFilename(); + int MmfScreenshot(); + int MmfWrite(string mmf_filename, string outputString); + string MmfRead(string mmf_filename, int expectedSize); + #endregion + + #region HTTP + string HttpTest(); + string HttpTestGet(); + string HttpGet(string url); + string HttpPost(string url, string payload); + string HttpPostScreenshot(); + void HttpSetTimeout(int timeout); + void HttpSetPostUrl(string url); + void HttpSetGetUrl(string url); + string HttpGetPostUrl(); + string HttpGetGetUrl(); + #endregion + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IEmu.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IEmu.cs new file mode 100644 index 0000000000..51136126ac --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IEmu.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IEmu : IExternalApi + { + Action FrameAdvanceCallback { get; set; } + Action YieldCallback { get; set; } + void DisplayVsync(bool enabled); + void FrameAdvance(); + int FrameCount(); + object Disassemble(uint pc, string name = ""); + ulong? GetRegister(string name); + Dictionary GetRegisters(); + void SetRegister(string register, int value); + long TotalExecutedycles(); + string GetSystemId(); + bool IsLagged(); + void SetIsLagged(bool value = true); + int LagCount(); + void SetLagCount(int count); + void LimitFramerate(bool enabled); + void MinimizeFrameskip(bool enabled); + void Yield(); + string GetDisplayType(); + string GetBoardName(); + object GetSettings(); + bool PutSettings(object settings); + void SetRenderPlanes(params bool[] param); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IExternalApi.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IExternalApi.cs new file mode 100644 index 0000000000..8dc7c9da03 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IExternalApi.cs @@ -0,0 +1,10 @@ +namespace BizHawk.Client.ApiHawk +{ + /// + /// This interface specifies that a client exposes a given interface, such as , + /// for use by external tools. + /// + public interface IExternalApi + { + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IGameInfo.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IGameInfo.cs new file mode 100644 index 0000000000..814a6d268c --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IGameInfo.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IGameInfo : IExternalApi + { + string GetRomName(); + string GetRomHash(); + bool InDatabase(); + string GetStatus(); + bool IsStatusBad(); + string GetBoardType(); + Dictionary GetOptions(); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IGui.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IGui.cs new file mode 100644 index 0000000000..03e3247e51 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IGui.cs @@ -0,0 +1,51 @@ +using System.Drawing; +using System.Drawing.Imaging; +using System.Windows.Forms; + +namespace BizHawk.Client.ApiHawk +{ + public interface IGui : IExternalApi + { + #region Gui API + void ToggleCompositingMode(); + ImageAttributes GetAttributes(); + void SetAttributes(ImageAttributes a); + void DrawNew(string name, bool? clear = true); + void DrawFinish(); + bool HasGUISurface { get; } + #endregion + + #region Helpers + void SetPadding(int all); + void SetPadding(int x, int y); + void SetPadding(int l, int t, int r, int b); + Padding GetPadding(); + #endregion + + void AddMessage(string message); + void ClearGraphics(); + void ClearText(); + void SetDefaultForegroundColor(Color color); + void SetDefaultBackgroundColor(Color color); + void SetDefaultTextBackground(Color color); + void SetDefaultPixelFont(string fontfamily); + void DrawBezier(Point p1, Point p2, Point p3, Point p4, Color? color = null); + void DrawBeziers(Point[] points, Color? color = null); + void DrawBox(int x, int y, int x2, int y2, Color? line = null, Color? background = null); + void DrawEllipse(int x, int y, int width, int height, Color? line = null, Color? background = null); + void DrawIcon(string path, int x, int y, int? width = null, int? height = null); + void DrawImage(string path, int x, int y, int? width = null, int? height = null, bool cache = true); + void ClearImageCache(); + void DrawImageRegion(string path, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int? dest_width = null, int? dest_height = null); + void DrawLine(int x1, int y1, int x2, int y2, Color? color = null); + void DrawAxis(int x, int y, int size, Color? color = null); + void DrawPie(int x, int y, int width, int height, int startangle, int sweepangle, Color? line = null, Color? background = null); + void DrawPixel(int x, int y, Color? color = null); + void DrawPolygon(Point[] points, Color? line = null, Color? background = null); + void DrawRectangle(int x, int y, int width, int height, Color? line = null, Color? background = null); + void DrawString(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, int? fontsize = null, + string fontfamily = null, string fontstyle = null, string horizalign = null, string vertalign = null); + void DrawText(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, string fontfamily = null); + void Text(int x, int y, string message, Color? forecolor = null, string anchor = null); + } +} \ No newline at end of file diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IInput.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IInput.cs new file mode 100644 index 0000000000..507bb024bf --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IInput.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IInput : IExternalApi + { + Dictionary Get(); + Dictionary GetMouse(); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IJoypad.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IJoypad.cs new file mode 100644 index 0000000000..1a8ce3340a --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IJoypad.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IJoypad : IExternalApi + { + Dictionary Get(int? controller = null); + + // TODO: what about float controls? + Dictionary GetImmediate(); + void SetFromMnemonicStr(string inputLogEntry); + void Set(Dictionary buttons, int? controller = null); + void Set(string button, bool? state = null, int? controller = null); + void SetAnalog(Dictionary controls, object controller = null); + void SetAnalog(string control, float? value = null, object controller = null); + + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IMem.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IMem.cs new file mode 100644 index 0000000000..7c8961ac5f --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IMem.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + public interface IMem : IExternalApi + { + void SetBigEndian(bool enabled = true); + + #region Domains + List GetMemoryDomainList(); + uint GetMemoryDomainSize(string name = ""); + string GetCurrentMemoryDomain(); + uint GetCurrentMemoryDomainSize(); + bool UseMemoryDomain(string domain); + string HashRegion(long addr, int count, string domain = null); + #endregion + #region Read + #region Special and Legacy Methods + uint ReadByte(long addr, string domain = null); + List ReadByteRange(long addr, int length, string domain = null); + float ReadFloat(long addr, string domain = null); + #endregion + #region Signed + int ReadS8(long addr, string domain = null); + int ReadS16(long addr, string domain = null); + int ReadS24(long addr, string domain = null); + int ReadS32(long addr, string domain = null); + #endregion + #region Unsigned + uint ReadU8(long addr, string domain = null); + uint ReadU16(long addr, string domain = null); + uint ReadU24(long addr, string domain = null); + uint ReadU32(long addr, string domain = null); + #endregion + #endregion + #region Write + #region Special and Legacy Methods + void WriteByte(long addr, uint value, string domain = null); + void WriteByteRange(long addr, List memoryblock, string domain = null); + void WriteFloat(long addr, double value, string domain = null); + #endregion + #region Signed + void WriteS8(long addr, int value, string domain = null); + void WriteS16(long addr, int value, string domain = null); + void WriteS24(long addr, int value, string domain = null); + void WriteS32(long addr, int value, string domain = null); + #endregion + #region Unigned + void WriteU8(long addr, uint value, string domain = null); + void WriteU16(long addr, uint value, string domain = null); + void WriteU24(long addr, uint value, string domain = null); + void WriteU32(long addr, uint value, string domain = null); + #endregion + #endregion + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IMemEvents.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IMemEvents.cs new file mode 100644 index 0000000000..b8650a9139 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IMemEvents.cs @@ -0,0 +1,12 @@ +using System; + +namespace BizHawk.Client.ApiHawk +{ + public interface IMemEvents : IExternalApi + { + void AddReadCallback(Action cb, uint address, string domain); + void AddWriteCallback(Action cb, uint address, string domain); + void AddExecCallback(Action cb, uint address, string domain); + void RemoveMemoryCallback(Action cb); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IMemorySavestate.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IMemorySavestate.cs new file mode 100644 index 0000000000..e3444c7bb5 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IMemorySavestate.cs @@ -0,0 +1,10 @@ +namespace BizHawk.Client.ApiHawk +{ + public interface IMemorySaveState : IExternalApi + { + string SaveCoreStateToMemory(); + void LoadCoreStateFromMemory(string identifier); + void DeleteState(string identifier); + void ClearInMemoryStates(); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IMovie.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IMovie.cs new file mode 100644 index 0000000000..c983ec1df1 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IMovie.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +namespace BizHawk.Client.ApiHawk +{ + public interface IMovie : IExternalApi + { + bool StartsFromSavestate(); + bool StartsFromSaveram(); + string Filename(); + Dictionary GetInput(int frame); + string GetInputAsMnemonic(int frame); + bool GetReadOnly(); + ulong GetRerecordCount(); + bool GetRerecordCounting(); + bool IsLoaded(); + double Length(); + string Mode(); + void Save(string filename = ""); + void SetReadOnly(bool readOnly); + void SetRerecordCount(double count); + void SetRerecordCounting(bool counting); + void Stop(); + double GetFps(); + Dictionary GetHeader(); + List GetComments(); + List GetSubtitles(); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/ISaveState.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/ISaveState.cs new file mode 100644 index 0000000000..8f595610fe --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/ISaveState.cs @@ -0,0 +1,10 @@ +namespace BizHawk.Client.ApiHawk +{ + public interface ISaveState : IExternalApi + { + void Load(string path); + void LoadSlot(int slotNum); + void Save(string path); + void SaveSlot(int slotNum); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/ISql.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/ISql.cs new file mode 100644 index 0000000000..99407ac1c2 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/ISql.cs @@ -0,0 +1,10 @@ +namespace BizHawk.Client.ApiHawk +{ + public interface ISql : IExternalApi + { + string CreateDatabase(string name); + string OpenDatabase(string name); + string WriteCommand(string query = ""); + dynamic ReadCommand(string query = ""); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/ITool.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/ITool.cs new file mode 100644 index 0000000000..ce4cdce516 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/ITool.cs @@ -0,0 +1,16 @@ +using System; +namespace BizHawk.Client.ApiHawk +{ + public interface ITool : IExternalApi + { + Type GetTool(string name); + object CreateInstance(string name); + void OpenCheats(); + void OpenHexEditor(); + void OpenRamWatch(); + void OpenRamSearch(); + void OpenTasStudio(); + void OpenToolBox(); + void OpenTraceLogger(); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/Api/IUserData.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IUserData.cs new file mode 100644 index 0000000000..234a7d4695 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IUserData.cs @@ -0,0 +1,11 @@ +namespace BizHawk.Client.ApiHawk +{ + public interface IUserData : IExternalApi + { + void Set(string name, object value); + object Get(string key); + void Clear(); + bool Remove(string key); + bool ContainsKey(string key); + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/IExternalApiProvider.cs b/BizHawk.Client.ApiHawk/Interfaces/IExternalApiProvider.cs new file mode 100644 index 0000000000..d44299f7b1 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/IExternalApiProvider.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; + +namespace BizHawk.Client.ApiHawk +{ + /// + /// This interface defines the mechanism by which External tools can retrieve + /// from a client implementation + /// An implementation should collect all available IExternalApi instances. + /// This interface defines only the external interaction. This interface does not specify the means + /// by which a api provider will be populated with available apis. However, an implementation + /// by design must provide this mechanism + /// + /// + public interface IExternalApiProvider + { + /// e + /// Returns whether or not T is available + /// + /// The to check + bool HasApi() where T : IExternalApi; + + /// + /// Returns whether or not t is available + /// + bool HasApi(Type t); + + /// + /// Returns an instance of T if T is available + /// Else returns null + /// + /// The requested + T GetApi() where T : IExternalApi; + + /// + /// Returns an instance of t if t is available + /// Else returns null + /// + object GetApi(Type t); + + /// + /// Gets a list of all currently registered Apis available to be retrieved + /// + IEnumerable AvailableApis { get; } + } +} diff --git a/BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs b/BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs new file mode 100644 index 0000000000..444ecec8b2 --- /dev/null +++ b/BizHawk.Client.ApiHawk/Interfaces/IPlugin.cs @@ -0,0 +1,12 @@ +namespace BizHawk.Client.ApiHawk +{ + interface IPlugin + { + void PreFrameCallback(); + void PostFrameCallback(); + void SaveStateCallback(string name); + void LoadStateCallback(string name); + void InputPollCallback(); + void Init(IApiContainer api); + } +} diff --git a/BizHawk.Client.Common/7z/LibraryManager.cs b/BizHawk.Client.Common/7z/LibraryManager.cs index d52dce3772..ac0aedd2ee 100644 --- a/BizHawk.Client.Common/7z/LibraryManager.cs +++ b/BizHawk.Client.Common/7z/LibraryManager.cs @@ -14,6 +14,8 @@ along with SevenZipSharp. If not, see . */ +using BizHawk.Common; + using System; using System.Collections.Generic; #if !WINCE && !MONO @@ -61,7 +63,7 @@ namespace SevenZip /// 7z.dll (from the 7-zip distribution) supports every InArchiveFormat for encoding and decoding. /// //private static string _libraryFileName = ConfigurationManager.AppSettings["7zLocation"] ?? Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "7z.dll"); - private static string _libraryFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "7z.dll"); + private static string _libraryFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "dll\\7z.dll"); #endif #if WINCE @@ -87,6 +89,8 @@ namespace SevenZip // private static string _LibraryVersion; private static bool? _modifyCapabale; + private static readonly PlatformLinkedLibSingleton.PlatformLinkedLibManager libLoader = PlatformLinkedLibSingleton.LinkedLibManager; + private static void InitUserInFormat(object user, InArchiveFormat format) { if (!_inArchives.ContainsKey(user)) @@ -148,16 +152,16 @@ namespace SevenZip //{ // throw new SevenZipLibraryException("DLL file does not exist."); //} - if ((_modulePtr = NativeMethods.LoadLibrary(_libraryFileName)) == IntPtr.Zero) + if ((_modulePtr = libLoader.LoadPlatformSpecific(_libraryFileName)) == IntPtr.Zero) { //try a different directory string alternateFilename = Path.Combine(Path.Combine(Path.GetDirectoryName(_libraryFileName),"dll"),"7z.dll"); - if ((_modulePtr = NativeMethods.LoadLibrary(alternateFilename)) == IntPtr.Zero) + if ((_modulePtr = libLoader.LoadPlatformSpecific(alternateFilename)) == IntPtr.Zero) throw new SevenZipLibraryException("failed to load library."); } - if (NativeMethods.GetProcAddress(_modulePtr, "GetHandlerProperty") == IntPtr.Zero) + if (libLoader.GetProcAddr(_modulePtr, "GetHandlerProperty") == IntPtr.Zero) { - NativeMethods.FreeLibrary(_modulePtr); + libLoader.FreePlatformSpecific(_modulePtr); throw new SevenZipLibraryException("library is invalid."); } } @@ -431,7 +435,7 @@ namespace SevenZip if (_totalUsers == 0) { #if !WINCE && !MONO - NativeMethods.FreeLibrary(_modulePtr); + libLoader.FreePlatformSpecific(_modulePtr); #endif _modulePtr = IntPtr.Zero; @@ -466,7 +470,7 @@ namespace SevenZip } var createObject = (NativeMethods.CreateObjectDelegate) Marshal.GetDelegateForFunctionPointer( - NativeMethods.GetProcAddress(_modulePtr, "CreateObject"), + libLoader.GetProcAddr(_modulePtr, "CreateObject"), typeof(NativeMethods.CreateObjectDelegate)); if (createObject == null) { @@ -525,7 +529,7 @@ namespace SevenZip } var createObject = (NativeMethods.CreateObjectDelegate) Marshal.GetDelegateForFunctionPointer( - NativeMethods.GetProcAddress(_modulePtr, "CreateObject"), + libLoader.GetProcAddr(_modulePtr, "CreateObject"), typeof(NativeMethods.CreateObjectDelegate)); if (createObject == null) { diff --git a/BizHawk.Client.Common/7z/NativeMethods.cs b/BizHawk.Client.Common/7z/NativeMethods.cs index 02ef5e7eb4..33fbcd9998 100644 --- a/BizHawk.Client.Common/7z/NativeMethods.cs +++ b/BizHawk.Client.Common/7z/NativeMethods.cs @@ -35,18 +35,8 @@ namespace SevenZip [MarshalAs(UnmanagedType.Interface)] out object outObject); #endregion - - [DllImport("kernel32.dll", BestFitMapping = false, ThrowOnUnmappableChar = true)] - public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string fileName); - - [DllImport("kernel32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool FreeLibrary(IntPtr hModule); - - [DllImport("kernel32.dll", BestFitMapping = false, ThrowOnUnmappableChar = true)] - public static extern IntPtr GetProcAddress(IntPtr hModule, [MarshalAs(UnmanagedType.LPStr)] string procName); #endif - + #if WINCE [DllImport("7z.dll", EntryPoint="CreateObject")] public static extern int CreateCOMObject( diff --git a/BizHawk.Client.Common/Api/CoreSystem.cs b/BizHawk.Client.Common/Api/CoreSystem.cs index d76625b963..48a10efbfc 100644 --- a/BizHawk.Client.Common/Api/CoreSystem.cs +++ b/BizHawk.Client.Common/Api/CoreSystem.cs @@ -31,6 +31,7 @@ VirtualBoy, NeoGeoPocket, ZXSpectrum, - AmstradCPC + AmstradCPC, + GGL } } diff --git a/BizHawk.Client.Common/BinarySaveStates.cs b/BizHawk.Client.Common/BinarySaveStates.cs index 188894bf2c..baa4b327ae 100644 --- a/BizHawk.Client.Common/BinarySaveStates.cs +++ b/BizHawk.Client.Common/BinarySaveStates.cs @@ -260,7 +260,7 @@ namespace BizHawk.Client.Common if (abort) { - throw new Exception("Essential zip section not found: " + lump.ReadName); + throw new Exception($"Essential zip section not found: {lump.ReadName}"); } return false; diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index 9816bf2bfb..cee56ac8a8 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -64,6 +64,7 @@ + @@ -244,6 +245,7 @@ + diff --git a/BizHawk.Client.Common/CoreFileProvider.cs b/BizHawk.Client.Common/CoreFileProvider.cs index d251915264..197ee0e031 100644 --- a/BizHawk.Client.Common/CoreFileProvider.cs +++ b/BizHawk.Client.Common/CoreFileProvider.cs @@ -53,7 +53,7 @@ namespace BizHawk.Client.Common { if (required) { - var fullmsg = $"Couldn't find required firmware \"{sysID}:{firmwareID}\". This is fatal{(msg != null ? ": " + msg : ".")}"; + var fullmsg = $"Couldn't find required firmware \"{sysID}:{firmwareID}\". This is fatal{(msg != null ? $": {msg}" : ".")}"; throw new MissingFirmwareException(fullmsg); } diff --git a/BizHawk.Client.Common/Global.cs b/BizHawk.Client.Common/Global.cs index 3631df9a7b..c233e7a7ec 100644 --- a/BizHawk.Client.Common/Global.cs +++ b/BizHawk.Client.Common/Global.cs @@ -159,7 +159,5 @@ namespace BizHawk.Client.Common } public static Dictionary UserBag = new Dictionary(); - - public static bool RunningOnUnix = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX; } } diff --git a/BizHawk.Client.EmuHawk/OpenAdvanced.cs b/BizHawk.Client.Common/OpenAdvanced.cs similarity index 89% rename from BizHawk.Client.EmuHawk/OpenAdvanced.cs rename to BizHawk.Client.Common/OpenAdvanced.cs index 9a9cfc1c91..251d49d89e 100644 --- a/BizHawk.Client.EmuHawk/OpenAdvanced.cs +++ b/BizHawk.Client.Common/OpenAdvanced.cs @@ -10,7 +10,7 @@ using Newtonsoft.Json; //this file contains some cumbersome self-"serialization" in order to gain a modicum of control over what the serialized output looks like //I don't want them to look like crufty json -namespace BizHawk.Client.EmuHawk +namespace BizHawk.Client.Common { public interface IOpenAdvanced { @@ -60,7 +60,7 @@ namespace BizHawk.Client.EmuHawk else if (type == OpenAdvancedTypes.LibretroNoGame) ioa = new OpenAdvanced_LibretroNoGame(); else ioa = null; if (ioa == null) - throw new InvalidOperationException("IOpenAdvanced deserialization error"); + throw new InvalidOperationException($"{nameof(IOpenAdvanced)} deserialization error"); ioa.Deserialize(token); return ioa; } @@ -74,7 +74,7 @@ namespace BizHawk.Client.EmuHawk } } - class OpenAdvanced_Libretro : IOpenAdvanced, IOpenAdvancedLibretro + public class OpenAdvanced_Libretro : IOpenAdvanced, IOpenAdvancedLibretro { public OpenAdvanced_Libretro() { @@ -87,7 +87,7 @@ namespace BizHawk.Client.EmuHawk public Token token = new Token(); public string TypeName { get { return "Libretro"; } } - public string DisplayName { get { return string.Format("{0}:{1}", Path.GetFileNameWithoutExtension(token.CorePath), token.Path); } } + public string DisplayName { get { return $"{Path.GetFileNameWithoutExtension(token.CorePath)}:{token.Path}"; } } public string SimplePath { get { return token.Path; } } public void Deserialize(string str) @@ -103,7 +103,7 @@ namespace BizHawk.Client.EmuHawk public string CorePath { get { return token.CorePath; } set { token.CorePath = value; } } } - class OpenAdvanced_LibretroNoGame : IOpenAdvanced, IOpenAdvancedLibretro + public class OpenAdvanced_LibretroNoGame : IOpenAdvanced, IOpenAdvancedLibretro { //you might think ideally we'd fetch the libretro core name from the core info inside it //but that would involve spinning up excess libretro core instances, which probably isnt good for stability, no matter how much we wish otherwise, not to mention slow. @@ -140,7 +140,7 @@ namespace BizHawk.Client.EmuHawk public string CorePath { get { return _corePath; } set { _corePath = value; } } } - class OpenAdvanced_OpenRom : IOpenAdvanced + public class OpenAdvanced_OpenRom : IOpenAdvanced { public OpenAdvanced_OpenRom() {} diff --git a/BizHawk.Client.Common/PathManager.cs b/BizHawk.Client.Common/PathManager.cs index c908157956..14af64ccbb 100644 --- a/BizHawk.Client.Common/PathManager.cs +++ b/BizHawk.Client.Common/PathManager.cs @@ -13,6 +13,11 @@ namespace BizHawk.Client.Common { public static class PathManager { + static PathManager() + { + SetDefaultIniPath(MakeProgramRelativePath("config.ini")); + } + public static string GetExeDirectoryAbsolute() { var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); @@ -29,7 +34,7 @@ namespace BizHawk.Client.Common /// public static string MakeProgramRelativePath(string path) { - return MakeAbsolutePath("%exe%/" + path, null); + return MakeAbsolutePath($"%exe%/{path}", null); } public static string GetDllDirectory() @@ -40,7 +45,12 @@ namespace BizHawk.Client.Common /// /// The location of the default INI file /// - public static string DefaultIniPath => MakeProgramRelativePath("config.ini"); + public static string DefaultIniPath { get; private set; } + + public static void SetDefaultIniPath(string newDefaultIniPath) + { + DefaultIniPath = newDefaultIniPath; + } /// /// Gets absolute base as derived from EXE @@ -252,13 +262,13 @@ namespace BizHawk.Client.Common var name = FilesystemSafeName(game); if (Global.MovieSession.Movie.IsActive) { - name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename); + name += $".{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}"; } var pathEntry = Global.Config.PathEntries[game.System, "Save RAM"] ?? Global.Config.PathEntries[game.System, "Base"]; - return Path.Combine(MakeAbsolutePath(pathEntry.Path, game.System), name) + ".SaveRAM"; + return $"{Path.Combine(MakeAbsolutePath(pathEntry.Path, game.System), name)}.SaveRAM"; } public static string AutoSaveRamPath(GameInfo game) @@ -279,7 +289,7 @@ namespace BizHawk.Client.Common if (Global.MovieSession.Movie.IsActive) { - name = Path.Combine(name, "movie-" + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)); + name = Path.Combine(name, $"movie-{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}"); } var pathEntry = Global.Config.PathEntries[game.System, "Save RAM"] ?? @@ -327,34 +337,34 @@ namespace BizHawk.Client.Common // Neshawk and Quicknes have incompatible savestates, store the name to keep them separate if (Global.Emulator.SystemId == "NES") { - name += "." + Global.Emulator.Attributes().CoreName; + name += $".{Global.Emulator.Attributes().CoreName}"; } // Gambatte and GBHawk have incompatible savestates, store the name to keep them separate if (Global.Emulator.SystemId == "GB") { - name += "." + Global.Emulator.Attributes().CoreName; + name += $".{Global.Emulator.Attributes().CoreName}"; } if (Global.Emulator is Snes9x) // Keep snes9x savestate away from libsnes, we want to not be too tedious so bsnes names will just have the profile name not the core name { - name += "." + Global.Emulator.Attributes().CoreName; + name += $".{Global.Emulator.Attributes().CoreName}"; } // Bsnes profiles have incompatible savestates so save the profile name if (Global.Emulator is LibsnesCore) { - name += "." + (Global.Emulator as LibsnesCore).CurrentProfile; + name += $".{((LibsnesCore)Global.Emulator).CurrentProfile}"; } if (Global.Emulator.SystemId == "GBA") { - name += "." + Global.Emulator.Attributes().CoreName; + name += $".{Global.Emulator.Attributes().CoreName}"; } if (Global.MovieSession.Movie.IsActive) { - name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename); + name += $".{Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename)}"; } var pathEntry = Global.Config.PathEntries[game.System, "Savestates"] ?? diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index ef007eeac6..fe093b2532 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -14,8 +14,10 @@ using BizHawk.Emulation.Cores.Computers.Commodore64; using BizHawk.Emulation.Cores.Consoles.Sega.gpgx; using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Nintendo.GBHawk; +using BizHawk.Emulation.Cores.Nintendo.GBHawkLink; using BizHawk.Emulation.Cores.Nintendo.SNES; using BizHawk.Emulation.Cores.PCEngine; +using BizHawk.Emulation.Cores.Sega.GGHawkLink; using BizHawk.Emulation.Cores.Sega.Saturn; using BizHawk.Emulation.Cores.Sony.PSP; using BizHawk.Emulation.Cores.Sony.PSX; @@ -217,7 +219,7 @@ namespace BizHawk.Client.Common else if (discMountJob.OUT_ErrorLevel) { - throw new InvalidOperationException("\r\n" + discMountJob.OUT_Log); + throw new InvalidOperationException($"\r\n{discMountJob.OUT_Log}"); } else if (disc == null) @@ -426,7 +428,7 @@ namespace BizHawk.Client.Common if (discMountJob.OUT_ErrorLevel) { - throw new InvalidOperationException("\r\n" + discMountJob.OUT_Log); + throw new InvalidOperationException($"\r\n{discMountJob.OUT_Log}"); } if (disc == null) @@ -494,7 +496,7 @@ namespace BizHawk.Client.Common if (discMountJob.OUT_ErrorLevel) { - throw new InvalidOperationException("\r\n" + discMountJob.OUT_Log); + throw new InvalidOperationException($"\r\n{discMountJob.OUT_Log}"); } var disc = discMountJob.OUT_Disc; @@ -630,7 +632,20 @@ namespace BizHawk.Client.Common var left = Database.GetGameInfo(leftBytes, "left.gb"); var right = Database.GetGameInfo(rightBytes, "right.gb"); - nextEmulator = new GambatteLink( + if (Global.Config.GB_UseGBHawk) + { + nextEmulator = new GBHawkLink( + nextComm, + left, + leftBytes, + right, + rightBytes, + GetCoreSettings(), + GetCoreSyncSettings()); + } + else + { + nextEmulator = new GambatteLink( nextComm, left, leftBytes, @@ -639,7 +654,8 @@ namespace BizHawk.Client.Common GetCoreSettings(), GetCoreSyncSettings(), Deterministic); - + } + // other stuff todo break; case "AppleII": @@ -713,7 +729,7 @@ namespace BizHawk.Client.Common if (discMountJob.OUT_ErrorLevel) { - throw new InvalidOperationException("\r\n" + discMountJob.OUT_Log); + throw new InvalidOperationException($"\r\n{discMountJob.OUT_Log}"); } if (disc == null) @@ -790,6 +806,22 @@ namespace BizHawk.Client.Common } nextEmulator = new GPGX(nextComm, null, genDiscs, GetCoreSettings(), GetCoreSyncSettings()); break; + case "Game Gear": + var leftBytesGG = xmlGame.Assets.First().Value; + var rightBytesGG = xmlGame.Assets.Skip(1).First().Value; + + var leftGG = Database.GetGameInfo(leftBytesGG, "left.gg"); + var rightGG = Database.GetGameInfo(rightBytesGG, "right.gg"); + + nextEmulator = new GGHawkLink( + nextComm, + leftGG, + leftBytesGG, + rightGG, + rightBytesGG, + GetCoreSettings(), + GetCoreSyncSettings()); + break; default: return false; } @@ -958,7 +990,14 @@ namespace BizHawk.Client.Common if (preference == "neshawk") { - core = CoreInventory.Instance["NES", "NesHawk"]; + if (Global.Config.UseSubNESHawk) + { + core = CoreInventory.Instance["NES", "SubNESHawk"]; + } + else + { + core = CoreInventory.Instance["NES", "NesHawk"]; + } } else { @@ -1132,12 +1171,12 @@ namespace BizHawk.Client.Common // handle exceptions thrown by the new detected systems that bizhawk does not have cores for else if (ex is NoAvailableCoreException) { - DoLoadErrorCallback(ex.Message + "\n\n" + ex, system); + DoLoadErrorCallback($"{ex.Message}\n\n{ex}", system); } else { - DoLoadErrorCallback("A core accepted the rom, but threw an exception while loading it:\n\n" + ex, system); + DoLoadErrorCallback($"A core accepted the rom, but threw an exception while loading it:\n\n{ex}", system); } return false; diff --git a/BizHawk.Client.Common/SaveSlotManager.cs b/BizHawk.Client.Common/SaveSlotManager.cs index 5996ac4a9c..8584312e7e 100644 --- a/BizHawk.Client.Common/SaveSlotManager.cs +++ b/BizHawk.Client.Common/SaveSlotManager.cs @@ -29,8 +29,7 @@ namespace BizHawk.Client.Common for (int i = 0; i < 10; i++) { - var file = new FileInfo( - PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave" + i + ".State"); + var file = new FileInfo($"{PathManager.SaveStatePrefix(Global.Game)}.QuickSave{i}.State"); if (file.Directory != null && file.Directory.Exists == false) { file.Directory.Create(); @@ -108,8 +107,8 @@ namespace BizHawk.Client.Common { // Takes the .state and .bak files and swaps them var state = new FileInfo(path); - var backup = new FileInfo(path + ".bak"); - var temp = new FileInfo(path + ".bak.tmp"); + var backup = new FileInfo($"{path}.bak"); + var temp = new FileInfo($"{path}.bak.tmp"); if (!state.Exists || !backup.Exists) { @@ -121,9 +120,9 @@ namespace BizHawk.Client.Common temp.Delete(); } - backup.CopyTo(path + ".bak.tmp"); + backup.CopyTo($"{path}.bak.tmp"); backup.Delete(); - state.CopyTo(path + ".bak"); + state.CopyTo($"{path}.bak"); state.Delete(); temp.CopyTo(path); temp.Delete(); diff --git a/BizHawk.Client.Common/SystemInfo.cs b/BizHawk.Client.Common/SystemInfo.cs index dc9e7be92b..258b5b1c4d 100644 --- a/BizHawk.Client.Common/SystemInfo.cs +++ b/BizHawk.Client.Common/SystemInfo.cs @@ -198,14 +198,19 @@ namespace BizHawk.Client.Common /// public static SystemInfo AmstradCPC { get; } = new SystemInfo("Amstrad CPC", CoreSystem.AmstradCPC, 2); - #endregion Get SystemInfo + /// + /// Gets the instance for AmstradCPC + /// + public static SystemInfo GGL { get; } = new SystemInfo("Game Gear Linked", CoreSystem.GGL, 2); - /// - /// Get a by its - /// - /// you're looking for - /// - public static SystemInfo FindByCoreSystem(CoreSystem system) + #endregion Get SystemInfo + + /// + /// Get a by its + /// + /// you're looking for + /// + public static SystemInfo FindByCoreSystem(CoreSystem system) { return _allSystemInfos.Find(s => s.System == system); } diff --git a/BizHawk.Client.Common/XmlGame.cs b/BizHawk.Client.Common/XmlGame.cs index 27022fdc9f..af6d4d6693 100644 --- a/BizHawk.Client.Common/XmlGame.cs +++ b/BizHawk.Client.Common/XmlGame.cs @@ -69,7 +69,7 @@ namespace BizHawk.Client.Common } else { - throw new Exception("Couldn't load XMLGame Asset \"" + filename + "\""); + throw new Exception($"Couldn't load XMLGame Asset \"{filename}\""); } } else @@ -98,7 +98,7 @@ namespace BizHawk.Client.Common } catch { - throw new Exception("Couldn't load XMLGame LoadAsset \"" + filename + "\""); + throw new Exception($"Couldn't load XMLGame LoadAsset \"{filename}\""); } } diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index b7f72ab639..2ff5988861 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -363,6 +363,12 @@ namespace BizHawk.Client.Common public float DispCustomUserARX = -1; public float DispCustomUserARY = -1; + //these default to 0 because by default we crop nothing + public int DispCropLeft = 0; + public int DispCropTop = 0; + public int DispCropRight = 0; + public int DispCropBottom = 0; + // Sound options #if WINDOWS public ESoundOutputMethod SoundOutputMethod = ESoundOutputMethod.DirectSound; @@ -554,6 +560,7 @@ namespace BizHawk.Client.Common // as this setting spans multiple cores and doesn't actually affect the behavior of any core, // it hasn't been absorbed into the new system public bool GB_AsSGB = false; + public bool UseSubNESHawk = false; public bool NES_InQuickNES = true; public bool SNES_InSnes9x = true; public bool GBA_UsemGBA = true; diff --git a/BizHawk.Client.Common/config/PathEntry.cs b/BizHawk.Client.Common/config/PathEntry.cs index 9b6b710212..3cc3f6d04c 100644 --- a/BizHawk.Client.Common/config/PathEntry.cs +++ b/BizHawk.Client.Common/config/PathEntry.cs @@ -73,8 +73,8 @@ namespace BizHawk.Client.Common } // we don't have anything for the system in question. add a set of stock paths - var systempath = PathManager.RemoveInvalidFileSystemChars(system) + "_INTERIM"; - var systemdisp = system + " (INTERIM)"; + var systempath = $"{PathManager.RemoveInvalidFileSystemChars(system)}_INTERIM"; + var systemdisp = $"{system} (INTERIM)"; Paths.AddRange(new[] { diff --git a/BizHawk.Client.Common/config/ToolDialogSettings.cs b/BizHawk.Client.Common/config/ToolDialogSettings.cs index 0ca9e031a2..e59b8e4b04 100644 --- a/BizHawk.Client.Common/config/ToolDialogSettings.cs +++ b/BizHawk.Client.Common/config/ToolDialogSettings.cs @@ -79,7 +79,7 @@ namespace BizHawk.Client.Common return new Point(_wndx.Value, _wndy.Value); } - throw new InvalidOperationException("TopLeft can not be used when one of the coordinates is null"); + throw new InvalidOperationException($"{nameof(TopLeft)} can not be used when one of the coordinates is null"); } } diff --git a/BizHawk.Client.Common/inputAdapters/UDLRController.cs b/BizHawk.Client.Common/inputAdapters/UDLRController.cs index 38222679a3..6f0822d849 100644 --- a/BizHawk.Client.Common/inputAdapters/UDLRController.cs +++ b/BizHawk.Client.Common/inputAdapters/UDLRController.cs @@ -32,7 +32,7 @@ namespace BizHawk.Client.Common } prefix = button.GetPrecedingString("Down"); - string other = prefix + "Up"; + string other = $"{prefix}Up"; if (Source.IsPressed(other)) { if (_unpresses.Contains(button)) @@ -61,7 +61,7 @@ namespace BizHawk.Client.Common } prefix = button.GetPrecedingString("Up"); - string other = prefix + "Down"; + string other = $"{prefix}Down"; if (Source.IsPressed(other)) { if (_unpresses.Contains(button)) @@ -90,7 +90,7 @@ namespace BizHawk.Client.Common } prefix = button.GetPrecedingString("Right"); - string other = prefix + "Left"; + string other = $"{prefix}Left"; if (Source.IsPressed(other)) { if (_unpresses.Contains(button)) @@ -119,7 +119,7 @@ namespace BizHawk.Client.Common } prefix = button.GetPrecedingString("Left"); - string other = prefix + "Right"; + string other = $"{prefix}Right"; if (Source.IsPressed(other)) { if (_unpresses.Contains(button)) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs index 2ce9d776f3..da767ebb4c 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs @@ -93,7 +93,7 @@ namespace BizHawk.Client.Common } catch (NotImplementedException) { - Log($"Error: {Emulator.Attributes().CoreName} does not yet implement disassemble()"); + Log($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDisassemblable.Disassemble)}()"); return null; } } @@ -117,7 +117,7 @@ namespace BizHawk.Client.Common } catch (NotImplementedException) { - Log($"Error: {Emulator.Attributes().CoreName} does not yet implement getregister()"); + Log($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.GetCpuFlagsAndRegisters)}()"); return 0; } } @@ -142,7 +142,7 @@ namespace BizHawk.Client.Common } catch (NotImplementedException) { - Log($"Error: {Emulator.Attributes().CoreName} does not yet implement getregisters()"); + Log($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.GetCpuFlagsAndRegisters)}()"); } return table; @@ -163,7 +163,7 @@ namespace BizHawk.Client.Common } catch (NotImplementedException) { - Log($"Error: {Emulator.Attributes().CoreName} does not yet implement setregister()"); + Log($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.SetCpuRegister)}()"); } } @@ -182,7 +182,7 @@ namespace BizHawk.Client.Common } catch (NotImplementedException) { - Log($"Error: {Emulator.Attributes().CoreName} does not yet implement totalexecutedcycles()"); + Log($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.TotalExecutedCycles)}()"); return 0; } @@ -204,7 +204,7 @@ namespace BizHawk.Client.Common return InputPollableCore.IsLagFrame; } - Log($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); + Log($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); return false; } @@ -218,7 +218,7 @@ namespace BizHawk.Client.Common } else { - Log($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); + Log($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); } } @@ -231,7 +231,7 @@ namespace BizHawk.Client.Common return InputPollableCore.LagCount; } - Log($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); + Log($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); return 0; } @@ -245,7 +245,7 @@ namespace BizHawk.Client.Common } else { - Log($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); + Log($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); } } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs index f8d94f10e8..7038915c81 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Events.cs @@ -62,10 +62,7 @@ namespace BizHawk.Client.Common } catch (Exception e) { - Log( - "error running function attached by lua function event.onsavestate" + - "\nError message: " + - e.Message); + Log($"error running function attached by lua function event.onsavestate\nError message: {e.Message}"); } } } @@ -84,10 +81,7 @@ namespace BizHawk.Client.Common } catch (Exception e) { - Log( - "error running function attached by lua function event.onloadstate" + - "\nError message: " + - e.Message); + Log($"error running function attached by lua function event.onloadstate\nError message: {e.Message}"); } } } @@ -106,10 +100,7 @@ namespace BizHawk.Client.Common } catch (Exception e) { - Log( - "error running function attached by lua function event.onframestart" + - "\nError message: " + - e.Message); + Log($"error running function attached by lua function event.onframestart\nError message: {e.Message}"); } } } @@ -128,10 +119,7 @@ namespace BizHawk.Client.Common } catch (Exception e) { - Log( - "error running function attached by lua function event.onframeend" + - "\nError message: " + - e.Message); + Log($"error running function attached by lua function event.onframeend\nError message: {e.Message}"); } } } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs index c098594f37..61d2d4afb0 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.GameInfo.cs @@ -19,7 +19,7 @@ namespace BizHawk.Client.Common public override string Name => "gameinfo"; [LuaMethodExample("local stgamget = gameinfo.getromname( );")] - [LuaMethod("getromname", "returns the path of the currently loaded rom, if a rom is loaded")] + [LuaMethod("getromname", "returns the name of the currently loaded rom, if a rom is loaded")] public string GetRomName() { if (Global.Game != null) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs index e5bc81d9be..b80c6ac99f 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Joypad.cs @@ -25,9 +25,9 @@ namespace BizHawk.Client.Common { buttons[button] = adaptor.IsPressed(button); } - else if (button.Length >= 3 && button.Substring(0, 2) == "P" + controller) + else if (button.Length >= 3 && button.Substring(0, 2) == $"P{controller}") { - buttons[button.Substring(3)] = adaptor.IsPressed("P" + controller + " " + button.Substring(3)); + buttons[button.Substring(3)] = adaptor.IsPressed($"P{controller} {button.Substring(3)}"); } } @@ -37,9 +37,9 @@ namespace BizHawk.Client.Common { buttons[button] = adaptor.GetFloat(button); } - else if (button.Length >= 3 && button.Substring(0, 2) == "P" + controller) + else if (button.Length >= 3 && button.Substring(0, 2) == $"P{controller}") { - buttons[button.Substring(3)] = adaptor.GetFloat("P" + controller + " " + button.Substring(3)); + buttons[button.Substring(3)] = adaptor.GetFloat($"P{controller} {button.Substring(3)}"); } } @@ -85,7 +85,7 @@ namespace BizHawk.Client.Common } catch (Exception) { - Log("invalid mnemonic string: " + inputLogEntry); + Log($"invalid mnemonic string: {inputLogEntry}"); } } @@ -125,7 +125,7 @@ namespace BizHawk.Client.Common var toPress = button.ToString(); if (controller.HasValue) { - toPress = "P" + controller + " " + button; + toPress = $"P{controller} {button}"; } if (!invert) @@ -180,7 +180,7 @@ namespace BizHawk.Client.Common } else { - Global.StickyXORAdapter.SetFloat("P" + controller + " " + name, theValue); + Global.StickyXORAdapter.SetFloat($"P{controller} {name}", theValue); } } } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs index 4131788a70..74e15136fb 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs @@ -149,7 +149,7 @@ namespace BizHawk.Client.Common if (!string.IsNullOrEmpty(filename)) { - filename += "." + Global.MovieSession.Movie.PreferredExtension; + filename += $".{Global.MovieSession.Movie.PreferredExtension}"; var test = new FileInfo(filename); if (test.Exists) { diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.SQL.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.SQL.cs index 5738e975db..ac03a3c9d4 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.SQL.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.SQL.cs @@ -1,9 +1,8 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using System.Data.SQLite; using NLua; -using System.Collections.Generic; namespace BizHawk.Client.Common { @@ -106,7 +105,7 @@ namespace BizHawk.Client.Common { var table = Lua.NewTable(); m_dbConnection.Open(); - string sql = "PRAGMA read_uncommitted =1;" + query; + string sql = $"PRAGMA read_uncommitted =1;{query}"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); bool rows = reader.HasRows; @@ -120,7 +119,7 @@ namespace BizHawk.Client.Common { for (int i = 0; i < reader.FieldCount; ++i) { - table[columns[i] + " " + rowCount.ToString()] = reader.GetValue(i); + table[$"{columns[i]} {rowCount}"] = reader.GetValue(i); } rowCount += 1; } diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs index d73936aa17..ba1afd211e 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.String.cs @@ -24,7 +24,7 @@ namespace BizHawk.Client.Common var hex = $"{num:X}"; if (hex.Length == 1) { - hex = "0" + hex; + hex = $"0{hex}"; } return hex; @@ -46,7 +46,7 @@ namespace BizHawk.Client.Common var octal = Convert.ToString(num, 8); if (octal.Length == 1) { - octal = "0" + octal; + octal = $"0{octal}"; } return octal; diff --git a/BizHawk.Client.Common/lua/LuaDocumentation.cs b/BizHawk.Client.Common/lua/LuaDocumentation.cs index c52c4316fb..8b6b40737e 100644 --- a/BizHawk.Client.Common/lua/LuaDocumentation.cs +++ b/BizHawk.Client.Common/lua/LuaDocumentation.cs @@ -26,10 +26,10 @@ __Types and notation__ * ? (question mark) ** A question mark next to a value indicates that it is a Nullable type (only applies to types that are not normally nullable) * [[]] (brackets) -** Brackets around a parameter indicate that the parameter is optional. optional parameters have an equals sign followed by the value that will be used if no value is supplied. +** Brackets around a parameter indicate that the parameter is optional. Optional parameters have an equals sign followed by the value that will be used if no value is supplied. ** Brackets after a parameter type indicate it is an array * null -** null is equivalent to the lua nil +** null is equivalent to the lua nil. Lua doesn't support named arguments, it checks the arguments by position. So if you're sending an optional argument that goes ''after'' other optional arguments you don't want to send, replace those with lua nil. * Color ** This is a .NET System.Drawing.Color struct. The value passed from lua is any value acceptable in the Color constructor. This means either a string with the color name such as ""red"", or a 0xAARRGGBB integer value. Unless specified, this is not a nullable value * object @@ -102,7 +102,7 @@ __Types and notation__ { var completion = new SublimeCompletions.Completion { - Trigger = f.Library + "." + f.Name + Trigger = $"{f.Library}.{f.Name}" }; var sb = new StringBuilder(); diff --git a/BizHawk.Client.Common/lua/LuaLibraryBase.cs b/BizHawk.Client.Common/lua/LuaLibraryBase.cs index bcf0a6845e..797be96ebc 100644 --- a/BizHawk.Client.Common/lua/LuaLibraryBase.cs +++ b/BizHawk.Client.Common/lua/LuaLibraryBase.cs @@ -101,7 +101,7 @@ namespace BizHawk.Client.Common foreach (var method in methods) { var luaMethodAttr = (LuaMethodAttribute)method.GetCustomAttributes(luaAttr, false).First(); - var luaName = Name + "." + luaMethodAttr.Name; + var luaName = $"{Name}.{luaMethodAttr.Name}"; Lua.RegisterFunction(luaName, this, method); docs?.Add(new LibraryFunction(Name, callingLibrary.Description(), method)); diff --git a/BizHawk.Client.Common/lua/LuaMemoryBase.cs b/BizHawk.Client.Common/lua/LuaMemoryBase.cs index b0b814983c..1cd965d288 100644 --- a/BizHawk.Client.Common/lua/LuaMemoryBase.cs +++ b/BizHawk.Client.Common/lua/LuaMemoryBase.cs @@ -67,8 +67,7 @@ namespace BizHawk.Client.Common return d.PeekByte(addr); } - Log("Warning: attempted read of " + addr + - " outside the memory size of " + d.Size); + Log($"Warning: attempted read of {addr} outside the memory size of {d.Size}"); return 0; } @@ -83,8 +82,7 @@ namespace BizHawk.Client.Common } else { - Log("Warning: attempted write to " + addr + - " outside the memory size of " + d.Size); + Log($"Warning: attempted write to {addr} outside the memory size of {d.Size}"); } } else @@ -188,8 +186,7 @@ namespace BizHawk.Client.Common } else { - Log("Warning: Attempted read " + lastAddr + " outside memory domain size of " + - d.Size + " in readbyterange()"); + Log($"Warning: Attempted read {lastAddr} outside memory domain size of {d.Size} in readbyterange()"); } return table; @@ -209,8 +206,7 @@ namespace BizHawk.Client.Common } else { - Log("Warning: Attempted write " + addr + " outside memory domain size of " + - d.Size + " in writebyterange()"); + Log($"Warning: Attempted write {addr} outside memory domain size of {d.Size} in writebyterange()"); } } } @@ -230,8 +226,7 @@ namespace BizHawk.Client.Common return BitConverter.ToSingle(bytes, 0); } - Log("Warning: Attempted read " + addr + - " outside memory size of " + d.Size); + Log($"Warning: Attempted read {addr} outside memory size of {d.Size}"); return 0; } @@ -250,8 +245,7 @@ namespace BizHawk.Client.Common } else { - Log("Warning: Attempted write " + addr + - " outside memory size of " + d.Size); + Log($"Warning: Attempted write {addr} outside memory size of {d.Size}"); } } else diff --git a/BizHawk.Client.Common/lua/LuaSandbox.cs b/BizHawk.Client.Common/lua/LuaSandbox.cs index 7a025ebfa6..920984300d 100644 --- a/BizHawk.Client.Common/lua/LuaSandbox.cs +++ b/BizHawk.Client.Common/lua/LuaSandbox.cs @@ -27,7 +27,7 @@ namespace BizHawk.Client.Common private bool CoolSetCurrentDirectory(string path, string currDirSpeedHack = null) { - string target = _currentDirectory + "\\"; + string target = $"{_currentDirectory}\\"; // first we'll bypass it with a general hack: dont do any setting if the value's already there (even at the OS level, setting the directory can be slow) // yeah I know, not the smoothest move to compare strings here, in case path normalization is happening at some point @@ -45,7 +45,7 @@ namespace BizHawk.Client.Common // WARNING: setting the current directory is SLOW!!! security checks for some reason. // so we're bypassing it with windows hacks #if WINDOWS - fixed (byte* pstr = &System.Text.Encoding.Unicode.GetBytes(target + "\0")[0]) + fixed (byte* pstr = &System.Text.Encoding.Unicode.GetBytes($"{target}\0")[0]) return SetCurrentDirectoryW(pstr); #else if (System.IO.Directory.Exists(CurrentDirectory)) // race condition for great justice diff --git a/BizHawk.Client.Common/lua/NamedLuaFunction.cs b/BizHawk.Client.Common/lua/NamedLuaFunction.cs index d10d2eb0b3..828f97968a 100644 --- a/BizHawk.Client.Common/lua/NamedLuaFunction.cs +++ b/BizHawk.Client.Common/lua/NamedLuaFunction.cs @@ -23,11 +23,7 @@ namespace BizHawk.Client.Common } catch (Exception ex) { - logCallback( - "error running function attached by the event " + - Event + - "\nError message: " + - ex.Message); + logCallback($"error running function attached by the event {Event}\nError message: {ex.Message}"); } }; } diff --git a/BizHawk.Client.Common/movie/MovieSession.cs b/BizHawk.Client.Common/movie/MovieSession.cs index 1a4a5940e7..9ec8475cca 100644 --- a/BizHawk.Client.Common/movie/MovieSession.cs +++ b/BizHawk.Client.Common/movie/MovieSession.cs @@ -201,7 +201,7 @@ namespace BizHawk.Client.Common var result = Movie.Stop(saveChanges); if (result) { - Output(Path.GetFileName(Movie.Filename) + " written to disk."); + Output($"{Path.GetFileName(Movie.Filename)} written to disk."); } Output(message); @@ -225,7 +225,7 @@ namespace BizHawk.Client.Common if (Movie.IsPlaying) { Movie.ClearFrame(Global.Emulator.Frame); - Output("Scrubbed input at frame " + Global.Emulator.Frame); + Output($"Scrubbed input at frame {Global.Emulator.Frame}"); } } diff --git a/BizHawk.Client.Common/movie/MultitrackRecording.cs b/BizHawk.Client.Common/movie/MultitrackRecording.cs index 2b2de2b7aa..37ef517a90 100644 --- a/BizHawk.Client.Common/movie/MultitrackRecording.cs +++ b/BizHawk.Client.Common/movie/MultitrackRecording.cs @@ -35,7 +35,7 @@ namespace BizHawk.Client.Common return "Recording None"; } - return "Recording Player " + CurrentPlayer; + return $"Recording Player {CurrentPlayer}"; } } diff --git a/BizHawk.Client.Common/movie/Subtitle.cs b/BizHawk.Client.Common/movie/Subtitle.cs index b59be8679f..ffc3e847f7 100644 --- a/BizHawk.Client.Common/movie/Subtitle.cs +++ b/BizHawk.Client.Common/movie/Subtitle.cs @@ -59,19 +59,9 @@ namespace BizHawk.Client.Common int startTime = (int)(start * 1000 / fps); int endTime = (int)(end * 1000 / fps); - var startString = string.Format( - "{0:d2}:{1:d2}:{2:d2},{3:d3}", - startTime / 3600000, - (startTime / 60000) % 60, - (startTime / 1000) % 60, - startTime % 1000); + var startString = $"{startTime / 3600000:d2}:{(startTime / 60000) % 60:d2}:{(startTime / 1000) % 60:d2},{startTime % 1000:d3}"; - var endString = string.Format( - "{0:d2}:{1:d2}:{2:d2},{3:d3}", - endTime / 3600000, - (endTime / 60000) % 60, - (endTime / 1000) % 60, - endTime % 1000); + var endString = $"{endTime / 3600000:d2}:{(endTime / 60000) % 60:d2}:{(endTime / 1000) % 60:d2},{endTime % 1000:d3}"; sb.Append(startString); sb.Append(" --> "); diff --git a/BizHawk.Client.Common/movie/SubtitleList.cs b/BizHawk.Client.Common/movie/SubtitleList.cs index d3f5fee533..0f9fa61ee2 100644 --- a/BizHawk.Client.Common/movie/SubtitleList.cs +++ b/BizHawk.Client.Common/movie/SubtitleList.cs @@ -103,7 +103,7 @@ namespace BizHawk.Client.Common if (i > 0 && lastframe == subs[i].Frame) { - subs[i].Message = subs[i - 1].Message + " " + subs[i].Message; + subs[i].Message = $"{subs[i - 1].Message} {subs[i].Message}"; subs.Remove(subs[i - 1]); i--; } diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs index f56331b533..c7d63a4c8d 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs @@ -166,6 +166,12 @@ namespace BizHawk.Client.Common protected virtual void Write(string fn, bool backup = false) { + if (Global.Emulator is BizHawk.Emulation.Cores.Nintendo.SubNESHawk.SubNESHawk) + { + var _subnes = (BizHawk.Emulation.Cores.Nintendo.SubNESHawk.SubNESHawk)Global.Emulator; + Header["VBlankCount"] = _subnes.VBL_CNT.ToString(); + } + var file = new FileInfo(fn); if (!file.Directory.Exists) { diff --git a/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs index 9d9ac17618..fafc214ad0 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs @@ -250,10 +250,7 @@ namespace BizHawk.Client.Common return true; } - errorMessage = "The savestate is from frame " - + newLog.Count - + " which is greater than the current movie length of " - + Log.Count; + errorMessage = $"The savestate is from frame {newLog.Count} which is greater than the current movie length of {Log.Count}"; return false; } @@ -262,9 +259,7 @@ namespace BizHawk.Client.Common { if (Log[i] != newLog[i]) { - errorMessage = "The savestate input does not match the movie input at frame " - + (i + 1) - + "."; + errorMessage = $"The savestate input does not match the movie input at frame {(i + 1)}."; return false; } diff --git a/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs b/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs index 5e44bdcd56..8a1ee67237 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmControllerAdapter.cs @@ -253,7 +253,7 @@ namespace BizHawk.Client.Common string prefix = ""; if (ControlType != "Gameboy Controller" && ControlType != "TI83 Controller") { - prefix = "P" + player + " "; + prefix = $"P{player} "; } foreach (string button in BkmMnemonicConstants.Buttons[ControlType].Keys) @@ -352,7 +352,7 @@ namespace BizHawk.Client.Common int start = 3; foreach (string button in BkmMnemonicConstants.Buttons[ControlType].Keys) { - Force("P" + player + " " + button, c[srcindex + start++]); + Force($"P{player} {button}", c[srcindex + start++]); } } } @@ -393,7 +393,7 @@ namespace BizHawk.Client.Common int start = 3; foreach (string button in BkmMnemonicConstants.Buttons["GPGX 3-Button Controller"].Keys) { - Force("P" + player + " " + button, c[srcindex + start++]); + Force($"P{player} {button}", c[srcindex + start++]); } } } @@ -429,7 +429,7 @@ namespace BizHawk.Client.Common int start = 3; foreach (var button in BkmMnemonicConstants.Buttons[ControlType].Keys) { - Force("P" + player + " " + button, c[srcindex + start++]); + Force($"P{player} {button}", c[srcindex + start++]); } } } @@ -497,12 +497,12 @@ namespace BizHawk.Client.Common int start = 3; foreach (string button in BkmMnemonicConstants.Buttons[ControlType].Keys) { - Force("P" + player + " " + button, c[srcindex + start++]); + Force($"P{player} {button}", c[srcindex + start++]); } foreach (string name in BkmMnemonicConstants.Analogs[ControlType].Keys) { - Force("P" + player + " " + name, int.Parse(mnemonic.Substring(srcindex + start, 4))); + Force($"P{player} {name}", int.Parse(mnemonic.Substring(srcindex + start, 4))); start += 5; } } @@ -539,7 +539,7 @@ namespace BizHawk.Client.Common int start = 3; foreach (string button in BkmMnemonicConstants.Buttons[ControlType].Keys) { - Force("P" + player + " " + button, c[srcindex + start++]); + Force($"P{player} {button}", c[srcindex + start++]); } } } @@ -585,7 +585,7 @@ namespace BizHawk.Client.Common foreach (string button in BkmMnemonicConstants.Buttons[ControlType].Keys) { - Force("P" + player + " " + button, c[srcindex + start++]); + Force($"P{player} {button}", c[srcindex + start++]); } } } @@ -635,7 +635,7 @@ namespace BizHawk.Client.Common int start = 1; foreach (var button in BkmMnemonicConstants.Buttons[ControlType].Keys) { - Force("P" + player + " " + button, c[srcindex + start++]); + Force($"P{player} {button}", c[srcindex + start++]); } } diff --git a/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs b/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs index d444507047..721fdd3ae6 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmLogEntryGenerator.cs @@ -165,7 +165,7 @@ namespace BizHawk.Client.Common var prefix = ""; if (_controlType != "Gameboy Controller" && _controlType != "TI83 Controller") { - prefix = "P" + player + " "; + prefix = $"P{player} "; } foreach (var button in BkmMnemonicConstants.Buttons[_controlType].Keys) @@ -313,7 +313,7 @@ namespace BizHawk.Client.Common { foreach (var button in BkmMnemonicConstants.Buttons[_controlType].Keys) { - input.Append(IsBasePressed("P" + player + " " + button) ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); + input.Append(IsBasePressed($"P{player} {button}") ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); } input.Append("|"); @@ -330,7 +330,7 @@ namespace BizHawk.Client.Common { foreach (var button in BkmMnemonicConstants.Buttons[_controlType].Keys) { - input.Append(IsBasePressed("P" + player + " " + button) ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); + input.Append(IsBasePressed($"P{player} {button}") ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); } input.Append('|'); @@ -398,7 +398,7 @@ namespace BizHawk.Client.Common { foreach (var button in BkmMnemonicConstants.Buttons[_controlType].Keys) { - input.Append(IsBasePressed("P" + player + " " + button) ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); + input.Append(IsBasePressed($"P{player} {button}") ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); } input.Append('|'); @@ -448,7 +448,7 @@ namespace BizHawk.Client.Common { foreach (var button in BkmMnemonicConstants.Buttons[_controlType].Keys) { - input.Append(IsBasePressed("P" + player + " " + button) ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); + input.Append(IsBasePressed($"P{player} {button}") ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); } if (BkmMnemonicConstants.Analogs[_controlType].Keys.Count > 0) @@ -460,37 +460,37 @@ namespace BizHawk.Client.Common // Nasty hackery if (name == "Y Axis") { - if (IsBasePressed("P" + player + " A Up")) + if (IsBasePressed($"P{player} A Up")) { val = 127; } - else if (IsBasePressed("P" + player + " A Down")) + else if (IsBasePressed($"P{player} A Down")) { val = -127; } else { - val = (int)GetBaseFloat("P" + player + " " + name); + val = (int)GetBaseFloat($"P{player} {name}"); } } else if (name == "X Axis") { - if (IsBasePressed("P" + player + " A Left")) + if (IsBasePressed($"P{player} A Left")) { val = -127; } - else if (IsBasePressed("P" + player + " A Right")) + else if (IsBasePressed($"P{player} A Right")) { val = 127; } else { - val = (int)GetBaseFloat("P" + player + " " + name); + val = (int)GetBaseFloat($"P{player} {name}"); } } else { - val = (int)GetBaseFloat("P" + player + " " + name); + val = (int)GetBaseFloat($"P{player} {name}"); } if (val >= 0) @@ -532,7 +532,7 @@ namespace BizHawk.Client.Common { foreach (var button in BkmMnemonicConstants.Buttons[_controlType].Keys) { - input.Append(IsBasePressed("P" + player + " " + button) ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); + input.Append(IsBasePressed($"P{player} {button}") ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); } input.Append('|'); @@ -563,7 +563,7 @@ namespace BizHawk.Client.Common { foreach (var button in BkmMnemonicConstants.Buttons[_controlType].Keys) { - input.Append(IsBasePressed("P" + player + " " + button) ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); + input.Append(IsBasePressed($"P{player} {button}") ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); } input.Append("|"); @@ -595,7 +595,7 @@ namespace BizHawk.Client.Common { foreach (var button in BkmMnemonicConstants.Buttons[_controlType].Keys) { - input.Append(IsBasePressed("P" + player + " " + button) ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); + input.Append(IsBasePressed($"P{player} {button}") ? BkmMnemonicConstants.Buttons[_controlType][button] : "."); } input.Append("|"); diff --git a/BizHawk.Client.Common/movie/bkm/BkmMovie.IO.cs b/BizHawk.Client.Common/movie/bkm/BkmMovie.IO.cs index 28304ff050..d296be8d35 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmMovie.IO.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmMovie.IO.cs @@ -265,7 +265,7 @@ namespace BizHawk.Client.Common // TODO: clean this up if (_loopOffset.HasValue) { - sw.WriteLine("LoopOffset " + _loopOffset); + sw.WriteLine($"LoopOffset {_loopOffset}"); } foreach (var input in _log) diff --git a/BizHawk.Client.Common/movie/bkm/BkmMovie.InputLog.cs b/BizHawk.Client.Common/movie/bkm/BkmMovie.InputLog.cs index 59cc7bf267..eb5cf0d4ad 100644 --- a/BizHawk.Client.Common/movie/bkm/BkmMovie.InputLog.cs +++ b/BizHawk.Client.Common/movie/bkm/BkmMovie.InputLog.cs @@ -254,10 +254,7 @@ namespace BizHawk.Client.Common return true; } - errorMessage = "The savestate is from frame " - + log.Count - + " which is greater than the current movie length of " - + _log.Count; + errorMessage = $"The savestate is from frame {log.Count} which is greater than the current movie length of {_log.Count}"; return false; } @@ -266,9 +263,7 @@ namespace BizHawk.Client.Common { if (_log[i] != log[i]) { - errorMessage = "The savestate input does not match the movie input at frame " - + (i + 1) - + "."; + errorMessage = $"The savestate input does not match the movie input at frame {(i + 1)}."; return false; } diff --git a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs index dd5c1e36c4..ac88cba786 100644 --- a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs +++ b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs @@ -4,6 +4,7 @@ using System.Linq; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.Gameboy; +using BizHawk.Emulation.Cores.Nintendo.SubNESHawk; using BizHawk.Emulation.Cores.Sega.MasterSystem; using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Emulation.Cores.Consoles.Sega.gpgx; @@ -15,7 +16,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions { public static TasMovie ToTasMovie(this IMovie old, bool copy = false) { - string newFilename = old.Filename + "." + TasMovie.Extension; + string newFilename = $"{old.Filename}.{TasMovie.Extension}"; if (File.Exists(newFilename)) { @@ -25,7 +26,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions { if (File.Exists(newFilename)) { - newFilename = old.Filename + " (" + fileNum + ")" + "." + TasMovie.Extension; + newFilename = $"{old.Filename} ({fileNum}).{TasMovie.Extension}"; fileNum++; } else @@ -125,7 +126,17 @@ namespace BizHawk.Client.Common.MovieConversionExtensions public static TasMovie ConvertToSavestateAnchoredMovie(this TasMovie old, int frame, byte[] savestate) { - string newFilename = old.Filename + "." + TasMovie.Extension; + string newFilename = old.Filename; + + if (old.Filename.Contains("tasproj")) + { + newFilename = newFilename.Remove(newFilename.Length - 7, 7); + newFilename = $"{newFilename}nfn.{TasMovie.Extension}"; + } + else + { + newFilename = $"{old.Filename}.{TasMovie.Extension}"; + } if (File.Exists(newFilename)) { @@ -135,7 +146,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions { if (File.Exists(newFilename)) { - newFilename = old.Filename + " (" + fileNum + ")" + "." + TasMovie.Extension; + newFilename = $"{old.Filename} ({fileNum}).{TasMovie.Extension}"; fileNum++; } else @@ -200,7 +211,17 @@ namespace BizHawk.Client.Common.MovieConversionExtensions public static TasMovie ConvertToSaveRamAnchoredMovie(this TasMovie old, byte[] saveRam) { - string newFilename = old.Filename + "." + TasMovie.Extension; + string newFilename = old.Filename; + + if (old.Filename.Contains("tasproj")) + { + newFilename = newFilename.Remove(newFilename.Length - 7, 7); + newFilename = $"{newFilename}nfsr.{TasMovie.Extension}"; + } + else + { + newFilename = $"{old.Filename}.{TasMovie.Extension}"; + } if (File.Exists(newFilename)) { @@ -210,7 +231,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions { if (File.Exists(newFilename)) { - newFilename = old.Filename + " (" + fileNum + ")" + "." + TasMovie.Extension; + newFilename = $"{old.Filename} ({fileNum}).{TasMovie.Extension}"; fileNum++; } else @@ -302,7 +323,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions { foreach (var firmware in Global.FirmwareManager.RecentlyServed) { - var key = firmware.SystemId + "_Firmware_" + firmware.FirmwareId; + var key = $"{firmware.SystemId}_Firmware_{firmware.FirmwareId}"; if (!movie.HeaderEntries.ContainsKey(key)) { @@ -336,6 +357,11 @@ namespace BizHawk.Client.Common.MovieConversionExtensions movie.HeaderEntries.Add("Is32X", "1"); } + if (Global.Emulator is SubNESHawk) + { + movie.HeaderEntries.Add("VBlankCount", "0"); + } + movie.Core = ((CoreAttribute)Attribute .GetCustomAttribute(Global.Emulator.GetType(), typeof(CoreAttribute))) .CoreName; diff --git a/BizHawk.Client.Common/movie/import/Fm2Import.cs b/BizHawk.Client.Common/movie/import/Fm2Import.cs index 194f7ce244..5463a8794a 100644 --- a/BizHawk.Client.Common/movie/import/Fm2Import.cs +++ b/BizHawk.Client.Common/movie/import/Fm2Import.cs @@ -57,7 +57,7 @@ namespace BizHawk.Client.Common } else { - Result.Movie.Comments.Add(Movieorigin + " .fm2 version 3"); + Result.Movie.Comments.Add($"{Movieorigin} .fm2 version 3"); } } else if (line.ToLower().StartsWith("romfilename")) @@ -139,7 +139,7 @@ namespace BizHawk.Client.Common string length = line.Substring(first + 1, second - first - 1); string message = line.Substring(second + 1).Trim(); - return "subtitle " + frame + " 0 0 " + length + " FFFFFFFF " + message; + return $"subtitle {frame} 0 0 {length} FFFFFFFF {message}"; } return null; diff --git a/BizHawk.Client.Common/movie/import/IMovieImport.cs b/BizHawk.Client.Common/movie/import/IMovieImport.cs index 255b0e6477..91191b7342 100644 --- a/BizHawk.Client.Common/movie/import/IMovieImport.cs +++ b/BizHawk.Client.Common/movie/import/IMovieImport.cs @@ -41,7 +41,7 @@ namespace BizHawk.Client.Common return Result; } - var newFileName = SourceFile.FullName + "." + Bk2Movie.Extension; + var newFileName = $"{SourceFile.FullName}.{Bk2Movie.Extension}"; Result.Movie = new Bk2Movie(newFileName); RunImport(); diff --git a/BizHawk.Client.Common/movie/import/MovieImport.cs b/BizHawk.Client.Common/movie/import/MovieImport.cs index 9110615a37..6f16c63120 100644 --- a/BizHawk.Client.Common/movie/import/MovieImport.cs +++ b/BizHawk.Client.Common/movie/import/MovieImport.cs @@ -57,7 +57,7 @@ namespace BizHawk.Client.Common } else { - messageCallback(Path.GetFileName(fn) + " imported as " + m.Filename); + messageCallback($"{Path.GetFileName(fn)} imported as {m.Filename}"); } if (!Directory.Exists(d)) @@ -83,7 +83,7 @@ namespace BizHawk.Client.Common if (importerType == default(Type)) { - errorMsg = "No importer found for file type " + ext; + errorMsg = $"No importer found for file type {ext}"; return null; } @@ -205,7 +205,7 @@ namespace BizHawk.Client.Common if (m != null) { - m.Filename += "." + BkmMovie.Extension; + m.Filename += $".{BkmMovie.Extension}"; } else { @@ -230,7 +230,7 @@ namespace BizHawk.Client.Common { "BKM", "FCM", "FM2", "FMV", "GMV", "MCM", "MC2", "MMV", "NMV", "LSMV", "SMV", "VBM", "VMV", "YMV", "ZMV" }; - return extensions.Any(ext => extension.ToUpper() == "." + ext); + return extensions.Any(ext => extension.ToUpper() == $".{ext}"); } // Reduce all whitespace to single spaces. @@ -261,7 +261,7 @@ namespace BizHawk.Client.Common for (int section = 2; section < sections.Length - 1; section++) { int player = section - 1; // We start with 1 - string prefix = "P" + player + " "; // "P1" + string prefix = $"P{player} "; // "P1" for (int button = 0; button < buttons.Length; button++) { @@ -344,7 +344,7 @@ namespace BizHawk.Client.Common if (warningMsg != "") { - warningMsg = "Unable to import " + warningMsg + " command on line " + lineNum + "."; + warningMsg = $"Unable to import {warningMsg} command on line {lineNum}."; } } } @@ -397,7 +397,7 @@ namespace BizHawk.Client.Common { // The player number is one less than the section number for the reasons explained above. int player = section + playerOffset; - string prefix = "P" + player + " "; + string prefix = $"P{player} "; // Gameboy doesn't currently have a prefix saying which player the input is for. if (controllers.Definition.Name == "Gameboy Controller") @@ -450,7 +450,7 @@ namespace BizHawk.Client.Common } string message = line.Substring(second + 1).Trim(); - m.Subtitles.AddFromString("subtitle " + frame + " 0 0 " + length + " FFFFFFFF " + message); + m.Subtitles.AddFromString($"subtitle {frame} 0 0 {length} FFFFFFFF {message}"); } return m; @@ -507,14 +507,12 @@ namespace BizHawk.Client.Common } else if (line.ToLower().StartsWith("emuversion")) { - m.Comments.Add( - EMULATIONORIGIN + " " + emulator + " version " + ParseHeader(line, "emuVersion")); + m.Comments.Add($"{EMULATIONORIGIN} {emulator} version {ParseHeader(line, "emuVersion")}"); } else if (line.ToLower().StartsWith("version")) { string version = ParseHeader(line, "version"); - m.Comments.Add( - MOVIEORIGIN + " " + Path.GetExtension(path) + " version " + version); + m.Comments.Add($"{MOVIEORIGIN} {Path.GetExtension(path)} version {version}"); if (Path.GetExtension(path).ToUpper() == ".FM2" && version != "3") { errorMsg = ".FM2 movie version must always be 3."; @@ -683,7 +681,7 @@ namespace BizHawk.Client.Common return null; } - m.Comments.Add(MOVIEORIGIN + " .FCM version " + version); + m.Comments.Add($"{MOVIEORIGIN} .FCM version {version}"); // 008 1-byte flags byte flags = r.ReadByte(); @@ -715,7 +713,7 @@ namespace BizHawk.Client.Common // other: reserved, set to 0 bool syncHack = ((flags >> 4) & 0x1) != 0; - m.Comments.Add(SYNCHACK + " " + syncHack); + m.Comments.Add($"{SYNCHACK} {syncHack}"); // 009 1-byte flags: reserved, set to 0 r.ReadByte(); @@ -749,7 +747,7 @@ namespace BizHawk.Client.Common // 030 4-byte little-endian unsigned int: version of the emulator used uint emuVersion = r.ReadUInt32(); - m.Comments.Add(EMULATIONORIGIN + " FCEU " + emuVersion); + m.Comments.Add($"{EMULATIONORIGIN} FCEU {emuVersion}"); // 034 name of the ROM used - UTF8 encoded nul-terminated string. List gameBytes = new List(); @@ -870,7 +868,7 @@ namespace BizHawk.Client.Common if (warningMsg != "") { - warningMsg = "Unable to import " + warningMsg + " command at frame " + frame + "."; + warningMsg = $"Unable to import {warningMsg} command at frame {frame}."; } } @@ -917,7 +915,7 @@ namespace BizHawk.Client.Common The controller update toggles the affected input. Controller update data is emitted to the movie file only when the state of the controller changes. */ - controllers["P" + player + " " + buttons[button]] = !controllers["P" + player + " " + buttons[button]]; + controllers[$"P{player} {buttons[button]}"] = !controllers[$"P{player} {buttons[button]}"]; } } @@ -1012,12 +1010,12 @@ namespace BizHawk.Client.Common // 010 64-byte zero-terminated emulator identifier string string emuVersion = NullTerminated(r.ReadStringFixedAscii(64)); - m.Comments.Add(EMULATIONORIGIN + " Famtasia version " + emuVersion); - m.Comments.Add(MOVIEORIGIN + " .FMV"); + m.Comments.Add($"{EMULATIONORIGIN} Famtasia version {emuVersion}"); + m.Comments.Add($"{MOVIEORIGIN} .FMV"); // 050 64-byte zero-terminated movie title string string description = NullTerminated(r.ReadStringFixedAscii(64)); - m.Comments.Add(COMMENT + " " + description); + m.Comments.Add($"{COMMENT} {description}"); if (!controller1 && !controller2 && !fds) { warningMsg = "No input recorded."; @@ -1080,7 +1078,7 @@ namespace BizHawk.Client.Common { for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; + controllers[$"P{player} {buttons[button]}"] = ((controllerState >> button) & 0x1) != 0; } } else @@ -1119,8 +1117,8 @@ namespace BizHawk.Client.Common // 00F ASCII-encoded GMV file format version. The most recent is 'A'. (?) string version = r.ReadStringFixedAscii(1); - m.Comments.Add(MOVIEORIGIN + " .GMV version " + version); - m.Comments.Add(EMULATIONORIGIN + " Gens"); + m.Comments.Add($"{MOVIEORIGIN} .GMV version {version}"); + m.Comments.Add($"{EMULATIONORIGIN} Gens"); // 010 4-byte little-endian unsigned int: rerecord count uint rerecordCount = r.ReadUInt32(); @@ -1169,7 +1167,7 @@ namespace BizHawk.Client.Common // 018 40-byte zero-terminated ASCII movie name string string description = NullTerminated(r.ReadStringFixedAscii(40)); - m.Comments.Add(COMMENT + " " + description); + m.Comments.Add($"{COMMENT} {description}"); /* 040 frame data @@ -1213,7 +1211,7 @@ namespace BizHawk.Client.Common { for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = ((controllerState >> button) & 0x1) == 0; + controllers[$"P{player} {buttons[button]}"] = ((controllerState >> button) & 0x1) == 0; } } else @@ -1222,12 +1220,12 @@ namespace BizHawk.Client.Common { if (player1Config == "6") { - controllers["P1 " + other[button]] = ((controllerState >> button) & 0x1) == 0; + controllers[$"P1 {other[button]}"] = ((controllerState >> button) & 0x1) == 0; } if (player2Config == "6") { - controllers["P2 " + other[button]] = ((controllerState >> (button + 4)) & 0x1) == 0; + controllers[$"P2 {other[button]}"] = ((controllerState >> (button + 4)) & 0x1) == 0; } } } @@ -1275,7 +1273,7 @@ namespace BizHawk.Client.Common { if (authorLast != "") { - authorList += authorLast + ", "; + authorList += $"{authorLast}, "; } authorLast = author; @@ -1301,7 +1299,7 @@ namespace BizHawk.Client.Common hf.BindArchiveMember(item.Index); var stream = hf.GetStream(); string coreversion = Encoding.UTF8.GetString(stream.ReadAllBytes()).Trim(); - m.Comments.Add(COREORIGIN + " " + coreversion); + m.Comments.Add($"{COREORIGIN} {coreversion}"); hf.Unbind(); } else if (item.Name == "gamename") @@ -1446,7 +1444,7 @@ namespace BizHawk.Client.Common string rom = Encoding.UTF8.GetString(stream.ReadAllBytes()).Trim(); int pos = item.Name.LastIndexOf(".sha256"); string name = item.Name.Substring(0, pos); - m.Header[SHA256 + "_" + name] = rom; + m.Header[$"{SHA256}_{name}"] = rom; hf.Unbind(); } else if (item.Name == "savestate") @@ -1491,7 +1489,7 @@ namespace BizHawk.Client.Common hf.BindArchiveMember(item.Index); var stream = hf.GetStream(); string systemid = Encoding.UTF8.GetString(stream.ReadAllBytes()).Trim(); - m.Comments.Add(EMULATIONORIGIN + " " + systemid); + m.Comments.Add($"{EMULATIONORIGIN} {systemid}"); hf.Unbind(); } } @@ -1528,11 +1526,11 @@ namespace BizHawk.Client.Common // 008 uint32 Mednafen Version (Current is 0A 08) uint emuVersion = r.ReadUInt32(); - m.Comments.Add(EMULATIONORIGIN + " Mednafen " + emuVersion); + m.Comments.Add($"{EMULATIONORIGIN} Mednafen {emuVersion}"); // 00C uint32 Movie Format Version (Current is 01) uint version = r.ReadUInt32(); - m.Comments.Add(MOVIEORIGIN + " .MCM version " + version); + m.Comments.Add($"{MOVIEORIGIN} .MCM version {version}"); // 010 32-byte MD5 of the ROM used byte[] md5 = r.ReadBytes(16); @@ -1580,7 +1578,7 @@ namespace BizHawk.Client.Common }; if (!platforms.ContainsKey(platform)) { - errorMsg = "Platform " + platform + " not supported."; + errorMsg = $"Platform {platform} not supported."; r.Close(); fs.Close(); return null; @@ -1601,7 +1599,7 @@ namespace BizHawk.Client.Common // TODO: Verify if NTSC/"PAL" mode used for the movie can be detected or not. // 100 variable Input data - SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = name + " Controller" } }; + SimpleController controllers = new SimpleController { Definition = new ControllerDefinition { Name = $"{name} Controller" } }; int bytes = 256; // The input stream consists of 1 byte for power-on and reset, and then X bytes per each input port per frame. @@ -1632,7 +1630,7 @@ namespace BizHawk.Client.Common ushort controllerState = r.ReadByte(); for (int button = 0; button < buttons.Length; button++) { - string prefix = platform == "lynx" ? "" : "P" + player + " "; // hack + string prefix = platform == "lynx" ? "" : $"P{player} "; // hack controllers[prefix + buttons[button]] = ((controllerState >> button) & 0x1) != 0; } } @@ -1677,8 +1675,8 @@ namespace BizHawk.Client.Common // 0004: 4-byte little endian unsigned int: dega version uint emuVersion = r.ReadUInt32(); - m.Comments.Add(EMULATIONORIGIN + " Dega version " + emuVersion); - m.Comments.Add(MOVIEORIGIN + " .MMV"); + m.Comments.Add($"{EMULATIONORIGIN} Dega version {emuVersion}"); + m.Comments.Add($"{MOVIEORIGIN} .MMV"); // 0008: 4-byte little endian unsigned int: frame count uint frameCount = r.ReadUInt32(); @@ -1771,7 +1769,7 @@ namespace BizHawk.Client.Common byte controllerState = r.ReadByte(); for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; + controllers[$"P{player} {buttons[button]}"] = ((controllerState >> button) & 0x1) != 0; } if (player == 1) @@ -1810,8 +1808,8 @@ namespace BizHawk.Client.Common // 004 4-byte version string (example "0960") string emuVersion = r.ReadStringFixedAscii(4); - m.Comments.Add(EMULATIONORIGIN + " Nintendulator version " + emuVersion); - m.Comments.Add(MOVIEORIGIN + " .NMV"); + m.Comments.Add($"{EMULATIONORIGIN} Nintendulator version {emuVersion}"); + m.Comments.Add($"{MOVIEORIGIN} .NMV"); // 008 4-byte file size, not including the 16-byte header r.ReadUInt32(); @@ -1918,7 +1916,7 @@ namespace BizHawk.Client.Common if (warningMsg != "") { - warningMsg = warningMsg + " is not properly supported."; + warningMsg = $"{warningMsg} is not properly supported."; } } } @@ -1945,7 +1943,7 @@ namespace BizHawk.Client.Common }; if (expansion != 0 && warningMsg == "") { - warningMsg = "Expansion port is not properly supported. This movie uses " + expansions[expansion] + "."; + warningMsg = $"Expansion port is not properly supported. This movie uses {expansions[expansion]}."; } // 003 1-byte number of bytes per frame, plus flags @@ -1989,7 +1987,7 @@ namespace BizHawk.Client.Common 00C (variable) null-terminated UTF-8 text, movie description (currently not implemented) */ string movieDescription = NullTerminated(r.ReadStringFixedAscii((int)r.ReadUInt32())); - m.Comments.Add(COMMENT + " " + movieDescription); + m.Comments.Add($"{COMMENT} {movieDescription}"); // ... 4-byte little-endian unsigned int: length of controller data in bytes uint length = r.ReadUInt32(); @@ -2027,7 +2025,7 @@ namespace BizHawk.Client.Common { for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; + controllers[$"P{player} {buttons[button]}"] = ((controllerState >> button) & 0x1) != 0; } } else if (warningMsg == "") @@ -2084,8 +2082,8 @@ namespace BizHawk.Client.Common return null; } - m.Comments.Add(EMULATIONORIGIN + " Snes9x version " + version); - m.Comments.Add(MOVIEORIGIN + " .SMV"); + m.Comments.Add($"{EMULATIONORIGIN} Snes9x version {version}"); + m.Comments.Add($"{MOVIEORIGIN} .SMV"); /* 008 4-byte little-endian integer: movie "uid" - identifies the movie-savestate relationship, also used as the recording time in Unix epoch format @@ -2302,7 +2300,7 @@ namespace BizHawk.Client.Common if (peripheral != "" && warningMsg == "") { - warningMsg = "Unable to import " + peripheral + "."; + warningMsg = $"Unable to import {peripheral}."; } } @@ -2311,13 +2309,13 @@ namespace BizHawk.Client.Common { for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = + controllers[$"P{player} {buttons[button]}"] = ((controllerState >> button) & 0x1) != 0; } } else if (warningMsg == "") { - warningMsg = "Controller " + player + " not supported."; + warningMsg = $"Controller {player} not supported."; } } @@ -2475,7 +2473,7 @@ namespace BizHawk.Client.Common if (isSGB) { - m.Comments.Add(SUPERGAMEBOYMODE + " True"); + m.Comments.Add($"{SUPERGAMEBOYMODE} True"); } m.Header[HeaderKeys.PLATFORM] = platform; @@ -2521,8 +2519,8 @@ namespace BizHawk.Client.Common // 030 1-byte unsigned char: minor version/revision number of current VBM version, the latest is "1" byte minorVersion = r.ReadByte(); - m.Comments.Add(MOVIEORIGIN + " .VBM version " + majorVersion + "." + minorVersion); - m.Comments.Add(EMULATIONORIGIN + " Visual Boy Advance"); + m.Comments.Add($"{MOVIEORIGIN} .VBM version {majorVersion}.{minorVersion}"); + m.Comments.Add($"{EMULATIONORIGIN} Visual Boy Advance"); // 031 1-byte unsigned char: the internal CRC of the ROM used while recording r.ReadByte(); @@ -2559,7 +2557,7 @@ namespace BizHawk.Client.Common // The following 128 bytes are for a description of the movie. Both parts must be null-terminated. string movieDescription = NullTerminated(r.ReadStringFixedAscii(128)); - m.Comments.Add(COMMENT + " " + movieDescription); + m.Comments.Add($"{COMMENT} {movieDescription}"); r.BaseStream.Position = firstFrameOffset; SimpleController controllers = new SimpleController { Definition = new ControllerDefinition() }; controllers.Definition.Name = platform != "GBA" @@ -2615,7 +2613,7 @@ namespace BizHawk.Client.Common { if (((controllerState >> (button + 10)) & 0x1) != 0) { - warningMsg = "Unable to import " + other[button] + " at frame " + frame + "."; + warningMsg = $"Unable to import {other[button]} at frame {frame}."; break; } } @@ -2660,12 +2658,12 @@ namespace BizHawk.Client.Common // 00C 2-byte little-endian integer: movie version 0x0400 ushort version = r.ReadUInt16(); - m.Comments.Add(MOVIEORIGIN + " .VMV version " + version); - m.Comments.Add(EMULATIONORIGIN + " VirtuaNES"); + m.Comments.Add($"{MOVIEORIGIN} .VMV version {version}"); + m.Comments.Add($"{EMULATIONORIGIN} VirtuaNES"); // 00E 2-byte little-endian integer: record version ushort recordVersion = r.ReadUInt16(); - m.Comments.Add(COMMENT + " Record version " + recordVersion); + m.Comments.Add($"{COMMENT} Record version {recordVersion}"); // 010 4-byte flags (control byte) uint flags = r.ReadUInt32(); @@ -2837,12 +2835,12 @@ namespace BizHawk.Client.Common } else { - commandName = "NESCMD_EXCONTROLLER, " + (command & 0xFF00); + commandName = $"NESCMD_EXCONTROLLER, {(command & 0xFF00)}"; } if (commandName != "" && warningMsg == "") { - warningMsg = "Unable to run command \"" + commandName + "\"."; + warningMsg = $"Unable to run command \"{commandName}\"."; } } else if (controllerState == 0xF3) @@ -2852,7 +2850,7 @@ namespace BizHawk.Client.Common // TODO: Make a clearer warning message. if (warningMsg == "") { - warningMsg = "Unable to run SetSyncExData(" + dwdata + ")."; + warningMsg = $"Unable to run SetSyncExData({dwdata})."; } } @@ -2861,7 +2859,7 @@ namespace BizHawk.Client.Common for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; + controllers[$"P{player} {buttons[button]}"] = ((controllerState >> button) & 0x1) != 0; } } @@ -2901,8 +2899,8 @@ namespace BizHawk.Client.Common // 003 2-byte little-endian unsigned int: zsnes version number short version = r.ReadInt16(); - m.Comments.Add(EMULATIONORIGIN + " ZSNES version " + version); - m.Comments.Add(MOVIEORIGIN + " .ZMV"); + m.Comments.Add($"{EMULATIONORIGIN} ZSNES version {version}"); + m.Comments.Add($"{MOVIEORIGIN} .ZMV"); // 005 4-byte little-endian integer: CRC32 of the ROM int crc32 = r.ReadInt32(); @@ -2973,7 +2971,7 @@ namespace BizHawk.Client.Common if (peripheral != "") { - warningMsg = "Unable to import " + peripheral + "."; + warningMsg = $"Unable to import {peripheral}."; } // 027 1-byte flags: @@ -3182,14 +3180,14 @@ namespace BizHawk.Client.Common { for (int button = 0; button < buttons.Length; button++) { - controllers["P" + player + " " + buttons[button]] = + controllers[$"P{player} {buttons[button]}"] = ((controllerState >> button) & 0x1) != 0; } } } else if (warningMsg == "") { - warningMsg = "Controller " + player + " not supported."; + warningMsg = $"Controller {player} not supported."; } } } diff --git a/BizHawk.Client.Common/movie/import/PJMImport.cs b/BizHawk.Client.Common/movie/import/PJMImport.cs index 0ced2f3f15..9429f779e8 100644 --- a/BizHawk.Client.Common/movie/import/PJMImport.cs +++ b/BizHawk.Client.Common/movie/import/PJMImport.cs @@ -45,7 +45,7 @@ namespace BizHawk.Client.Common string magic = new string(br.ReadChars(4)); if (magic != expectedMagic) { - Result.Errors.Add("Not a " + expectedMagic + "file: invalid magic number in file header."); + Result.Errors.Add($"Not a {expectedMagic}file: invalid magic number in file header."); return info; } @@ -221,7 +221,7 @@ namespace BizHawk.Client.Common for (int button = 3; button < buttons.Length; button++) { - controllers["P1 " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; + controllers[$"P1 {buttons[button]}"] = ((controllerState >> button) & 0x1) != 0; if (((controllerState >> button) & 0x1) != 0 && button > 15) { continue; @@ -246,7 +246,7 @@ namespace BizHawk.Client.Common ushort controllerState = br.ReadUInt16(); for (int button = 0; button < buttons.Length; button++) { - controllers["P2 " + buttons[button]] = ((controllerState >> button) & 0x1) != 0; + controllers[$"P2 {buttons[button]}"] = ((controllerState >> button) & 0x1) != 0; if (((controllerState >> button) & 0x1) != 0 && button > 15) { continue; @@ -291,7 +291,7 @@ namespace BizHawk.Client.Common if ((controlState & 0xFC) != 0) { - Result.Warnings.Add("Ignored toggle hack flag on frame " + frame); + Result.Warnings.Add($"Ignored toggle hack flag on frame {frame}"); } movie.AppendFrame(controllers); @@ -336,7 +336,7 @@ namespace BizHawk.Client.Common for (int button = 3; button < buttons.Length; button++) { - controllers["P1 " + buttons[button]] = br.ReadChar() != '.'; + controllers[$"P1 {buttons[button]}"] = br.ReadChar() != '.'; } if (info.Player1Type == OctoshockDll.ePeripheralType.DualShock) @@ -373,7 +373,7 @@ namespace BizHawk.Client.Common for (int button = 3; button < buttons.Length; button++) { - controllers["P2 " + buttons[button]] = br.ReadChar() != '.'; + controllers[$"P2 {buttons[button]}"] = br.ReadChar() != '.'; } if (info.Player2Type == OctoshockDll.ePeripheralType.DualShock) @@ -423,7 +423,7 @@ namespace BizHawk.Client.Common if ((controlState & 0xFC) != 0) { - Result.Warnings.Add("Ignored toggle hack flag on frame " + frame); + Result.Warnings.Add($"Ignored toggle hack flag on frame {frame}"); } // Each controller is terminated with a pipeline. diff --git a/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs b/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs index e02b10a009..98ff514ec0 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasLagLog.cs @@ -50,7 +50,7 @@ namespace BizHawk.Client.Common if (frame > _lagLog.Count) { - System.Diagnostics.Debug.Print("Lag Log error. f" + frame + ", log: " + _lagLog.Count); + System.Diagnostics.Debug.Print($"Lag Log error. f{frame}, log: {_lagLog.Count}"); return; // Can this break anything? } diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs index f08d163849..41bd3de508 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs @@ -14,7 +14,7 @@ namespace BizHawk.Client.Common { if (frame != 0) { - ChangeLog.AddGeneralUndo(frame - 1, frame - 1, "Record Frame: " + frame); + ChangeLog.AddGeneralUndo(frame - 1, frame - 1, $"Record Frame: {frame}"); } base.RecordFrame(frame, source); @@ -35,7 +35,7 @@ namespace BizHawk.Client.Common public override void Truncate(int frame) { - bool endBatch = ChangeLog.BeginNewBatch("Truncate Movie: " + frame, true); + bool endBatch = ChangeLog.BeginNewBatch($"Truncate Movie: {frame}", true); ChangeLog.AddGeneralUndo(frame, InputLogLength - 1); if (frame < Log.Count - 1) @@ -58,7 +58,7 @@ namespace BizHawk.Client.Common public override void PokeFrame(int frame, IController source) { - ChangeLog.AddGeneralUndo(frame, frame, "Set Frame At: " + frame); + ChangeLog.AddGeneralUndo(frame, frame, $"Set Frame At: {frame}"); base.PokeFrame(frame, source); InvalidateAfter(frame); @@ -68,7 +68,7 @@ namespace BizHawk.Client.Common public void SetFrame(int frame, string source) { - ChangeLog.AddGeneralUndo(frame, frame, "Set Frame At: " + frame); + ChangeLog.AddGeneralUndo(frame, frame, $"Set Frame At: {frame}"); SetFrameAt(frame, source); InvalidateAfter(frame); @@ -78,7 +78,7 @@ namespace BizHawk.Client.Common public override void ClearFrame(int frame) { - ChangeLog.AddGeneralUndo(frame, frame, "Clear Frame: " + frame); + ChangeLog.AddGeneralUndo(frame, frame, $"Clear Frame: {frame}"); base.ClearFrame(frame); InvalidateAfter(frame); @@ -88,7 +88,7 @@ namespace BizHawk.Client.Common public void RemoveFrame(int frame) { - bool endBatch = ChangeLog.BeginNewBatch("Remove Frame: " + frame, true); + bool endBatch = ChangeLog.BeginNewBatch($"Remove Frame: {frame}", true); ChangeLog.AddGeneralUndo(frame, InputLogLength - 1); Log.RemoveAt(frame); @@ -181,7 +181,7 @@ namespace BizHawk.Client.Common public void RemoveFrames(int removeStart, int removeUpTo, bool fromHistory = false) { - bool endBatch = ChangeLog.BeginNewBatch("Remove Frames: " + removeStart + "-" + removeUpTo, true); + bool endBatch = ChangeLog.BeginNewBatch($"Remove Frames: {removeStart}-{removeUpTo}", true); ChangeLog.AddGeneralUndo(removeStart, InputLogLength - 1); for (int i = removeUpTo - 1; i >= removeStart; i--) @@ -225,7 +225,7 @@ namespace BizHawk.Client.Common public void InsertInput(int frame, string inputState) { - bool endBatch = ChangeLog.BeginNewBatch("Insert Frame: " + frame, true); + bool endBatch = ChangeLog.BeginNewBatch($"Insert Frame: {frame}", true); ChangeLog.AddGeneralUndo(frame, InputLogLength); Log.Insert(frame, inputState); @@ -258,7 +258,7 @@ namespace BizHawk.Client.Common public void InsertInput(int frame, IEnumerable inputLog) { - bool endBatch = ChangeLog.BeginNewBatch("Insert Frame: " + frame, true); + bool endBatch = ChangeLog.BeginNewBatch($"Insert Frame: {frame}", true); ChangeLog.AddGeneralUndo(frame, InputLogLength + inputLog.Count() - 1); Log.InsertRange(frame, inputLog); @@ -307,7 +307,7 @@ namespace BizHawk.Client.Common public void CopyOverInput(int frame, IEnumerable inputStates) { - ChangeLog.BeginNewBatch("Copy Over Input: " + frame); + ChangeLog.BeginNewBatch($"Copy Over Input: {frame}"); var lg = LogGeneratorInstance(); var states = inputStates.ToList(); @@ -316,7 +316,7 @@ namespace BizHawk.Client.Common ExtendMovieForEdit(states.Count + frame - Log.Count); } - ChangeLog.AddGeneralUndo(frame, frame + inputStates.Count() - 1, "Copy Over Input: " + frame); + ChangeLog.AddGeneralUndo(frame, frame + inputStates.Count() - 1, $"Copy Over Input: {frame}"); for (int i = 0; i < states.Count; i++) { @@ -338,7 +338,7 @@ namespace BizHawk.Client.Common public void InsertEmptyFrame(int frame, int count = 1, bool fromHistory = false) { - bool endBatch = ChangeLog.BeginNewBatch("Insert Empty Frame: " + frame, true); + bool endBatch = ChangeLog.BeginNewBatch($"Insert Empty Frame: {frame}", true); ChangeLog.AddGeneralUndo(frame, InputLogLength + count - 1); var lg = LogGeneratorInstance(); @@ -422,7 +422,7 @@ namespace BizHawk.Client.Common Changes = true; InvalidateAfter(frame); - ChangeLog.AddBoolToggle(frame, buttonName, !adapter.IsPressed(buttonName), "Toggle " + buttonName + ": " + frame); + ChangeLog.AddBoolToggle(frame, buttonName, !adapter.IsPressed(buttonName), $"Toggle {buttonName}: {frame}"); } public void SetBoolState(int frame, string buttonName, bool val) @@ -444,7 +444,7 @@ namespace BizHawk.Client.Common { InvalidateAfter(frame); Changes = true; - ChangeLog.AddBoolToggle(frame, buttonName, old, "Set " + buttonName + "(" + (val ? "On" : "Off") + "): " + frame); + ChangeLog.AddBoolToggle(frame, buttonName, old, $"Set {buttonName}({(val ? "On" : "Off")}): {frame}"); } } @@ -455,7 +455,7 @@ namespace BizHawk.Client.Common ExtendMovieForEdit(frame + count - Log.Count); } - ChangeLog.AddGeneralUndo(frame, frame + count - 1, "Set " + buttonName + "(" + (val ? "On" : "Off") + "): " + frame + "-" + (frame + count - 1)); + ChangeLog.AddGeneralUndo(frame, frame + count - 1, $"Set {buttonName}({(val ? "On" : "Off")}): {frame}-{(frame + count - 1)}"); int changed = -1; for (int i = 0; i < count; i++) @@ -502,7 +502,7 @@ namespace BizHawk.Client.Common { InvalidateAfter(frame); Changes = true; - ChangeLog.AddFloatChange(frame, buttonName, old, val, "Set " + buttonName + "(" + val + "): " + frame); + ChangeLog.AddFloatChange(frame, buttonName, old, val, $"Set {buttonName}({val}): {frame}"); } } @@ -513,7 +513,7 @@ namespace BizHawk.Client.Common ExtendMovieForEdit(frame - Log.Count + 1); } - ChangeLog.AddGeneralUndo(frame, frame + count - 1, "Set " + buttonName + "(" + val + "): " + frame + "-" + (frame + count - 1)); + ChangeLog.AddGeneralUndo(frame, frame + count - 1, $"Set {buttonName}({val}): {frame}-{(frame + count - 1)}"); int changed = -1; for (int i = 0; i < count; i++) diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs index 30f6182037..bce2d0a106 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.History.cs @@ -273,7 +273,7 @@ namespace BizHawk.Client.Common if (name == "") { - name = "Undo step " + _totalSteps; + name = $"Undo step {_totalSteps}"; } bool ret = false; @@ -349,11 +349,11 @@ namespace BizHawk.Client.Common { if (oldPosition == -1) { - name = "Set Marker at frame " + newMarker.Frame; + name = $"Set Marker at frame {newMarker.Frame}"; } else { - name = "Remove Marker at frame " + oldPosition; + name = $"Remove Marker at frame {oldPosition}"; } AddMovieAction(name); diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs index e500a1e833..0a5aee0af2 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs @@ -55,7 +55,7 @@ namespace BizHawk.Client.Common _progressReportWorker = progressReportWorker; if (!Global.Emulator.HasSavestates()) { - throw new InvalidOperationException("Cannot create a TasMovie against a core that does not implement IStatable"); + throw new InvalidOperationException($"Cannot create a {nameof(TasMovie)} against a core that does not implement {nameof(IStatable)}"); } ChangeLog = new TasMovieChangeLog(this); @@ -65,7 +65,7 @@ namespace BizHawk.Client.Common Markers = new TasMovieMarkerList(this); Markers.CollectionChanged += Markers_CollectionChanged; Markers.Add(0, startsFromSavestate ? "Savestate" : "Power on"); - BindMarkersToInput = true; + BindMarkersToInput = false; CurrentBranch = -1; } @@ -74,7 +74,7 @@ namespace BizHawk.Client.Common _progressReportWorker = progressReportWorker; if (!Global.Emulator.HasSavestates()) { - throw new InvalidOperationException("Cannot create a TasMovie against a core that does not implement IStatable"); + throw new InvalidOperationException($"Cannot create a {nameof(TasMovie)} against a core that does not implement {nameof(IStatable)}"); } ChangeLog = new TasMovieChangeLog(this); @@ -84,7 +84,7 @@ namespace BizHawk.Client.Common Markers = new TasMovieMarkerList(this); Markers.CollectionChanged += Markers_CollectionChanged; Markers.Add(0, startsFromSavestate ? "Savestate" : "Power on"); - BindMarkersToInput = true; + BindMarkersToInput = false; CurrentBranch = -1; } @@ -509,17 +509,13 @@ namespace BizHawk.Client.Common Log?.Dispose(); Log = branch.InputLog.Clone(); - _lagLog.FromLagLog(branch.LagLog); - - // if there are branch states, they will be loaded anyway - // but if there's none, or only *after* divergent point, don't invalidate the entire movie anymore if (divergentPoint.HasValue) { - _stateManager.Invalidate(divergentPoint.Value); + InvalidateAfter(divergentPoint.Value); } else { - _stateManager.Invalidate(branch.InputLog.Count); + InvalidateAfter(branch.InputLog.Count); } if (BindMarkersToInput) // pretty critical not to erase them diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs index 3b2920814c..671fb95c05 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs @@ -384,7 +384,17 @@ namespace BizHawk.Client.Common { if (_states.Any()) { - StateManagerState power = _states.Values.First(s => s.Frame == 0); + var temp_state = _states.Values; + StateManagerState power = null; + if (temp_state[0].Frame==0) + { + power = _states.Values.First(s => s.Frame == 0); + } + else + { + power = _states.Values[0]; + } + _states.Clear(); SetState(0, power.State); Used = (ulong)power.State.Length; diff --git a/BizHawk.Client.Common/rewind/StreamBlobDatabase.cs b/BizHawk.Client.Common/rewind/StreamBlobDatabase.cs index c5472d7eef..64a999f3b2 100644 --- a/BizHawk.Client.Common/rewind/StreamBlobDatabase.cs +++ b/BizHawk.Client.Common/rewind/StreamBlobDatabase.cs @@ -192,7 +192,7 @@ namespace BizHawk.Client.Common { if (_mHead == null) { - throw new InvalidOperationException("Attempted to pop from an empty data structure"); + throw new InvalidOperationException($"Attempted to {nameof(Pop)} from an empty data structure"); } var ret = _mHead.Value; @@ -213,7 +213,7 @@ namespace BizHawk.Client.Common { if (_mHead == null) { - throw new InvalidOperationException("Attempted to peek from an empty data structure"); + throw new InvalidOperationException($"Attempted to {nameof(Peek)} from an empty data structure"); } return _mHead.Value; @@ -223,7 +223,7 @@ namespace BizHawk.Client.Common { if (_mTail == null) { - throw new InvalidOperationException("Attempted to dequeue from an empty data structure"); + throw new InvalidOperationException($"Attempted to {nameof(Dequeue)} from an empty data structure"); } var ret = _mTail.Value; diff --git a/BizHawk.Client.Common/tools/Watch/ByteWatch.cs b/BizHawk.Client.Common/tools/Watch/ByteWatch.cs index 7d6c53738c..50531248ba 100644 --- a/BizHawk.Client.Common/tools/Watch/ByteWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/ByteWatch.cs @@ -200,24 +200,7 @@ namespace BizHawk.Client.Common /// Get a string representation of difference /// between current value and the previous one /// - public override string Diff - { - get - { - string diff = ""; - int diffVal = _value - _previous; - if (diffVal > 0) - { - diff = "+"; - } - else if (diffVal < 0) - { - diff = "-"; - } - - return $"{diff}{((byte)Math.Abs(diffVal))}"; - } - } + public override string Diff => $"{_value - (short)_previous:+#;-#;0}"; /// /// Get the maximum possible value diff --git a/BizHawk.Client.Common/tools/Watch/DWordWatch.cs b/BizHawk.Client.Common/tools/Watch/DWordWatch.cs index 1e8c41f055..360966dac0 100644 --- a/BizHawk.Client.Common/tools/Watch/DWordWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/DWordWatch.cs @@ -217,9 +217,9 @@ namespace BizHawk.Client.Common case DisplayType.Hex: return val.ToHexString(8); case DisplayType.FixedPoint_20_12: - return $"{val / 4096.0:0.######}"; + return $"{(int)val / 4096.0:0.######}"; case DisplayType.FixedPoint_16_16: - return $"{val / 65536.0:0.######}"; + return $"{(int)val / 65536.0:0.######}"; case DisplayType.Float: var bytes = BitConverter.GetBytes(val); var _float = BitConverter.ToSingle(bytes, 0); @@ -231,7 +231,7 @@ namespace BizHawk.Client.Common /// Get a string representation of difference /// between current value and the previous one /// - public override string Diff => (_previous - _value).ToString(); + public override string Diff => $"{_value - (long)_previous:+#;-#;0}"; /// /// Get the maximum possible value diff --git a/BizHawk.Client.Common/tools/Watch/Watch.cs b/BizHawk.Client.Common/tools/Watch/Watch.cs index 4b4aa4ca5f..d549f521fc 100644 --- a/BizHawk.Client.Common/tools/Watch/Watch.cs +++ b/BizHawk.Client.Common/tools/Watch/Watch.cs @@ -46,7 +46,7 @@ namespace BizHawk.Client.Common } else { - throw new ArgumentException($"DisplayType {type} is invalid for this type of Watch", nameof(type)); + throw new ArgumentException($"{nameof(DisplayType)} {type} is invalid for this type of {nameof(Watch)}", nameof(type)); } } @@ -573,7 +573,7 @@ namespace BizHawk.Client.Common { if (_domain != null) { - return "X" + (_domain.Size - 1).NumHexDigits(); + return $"X{(_domain.Size - 1).NumHexDigits()}"; } return ""; diff --git a/BizHawk.Client.Common/tools/Watch/WordWatch.cs b/BizHawk.Client.Common/tools/Watch/WordWatch.cs index 968e81e0f8..be6d461bf4 100644 --- a/BizHawk.Client.Common/tools/Watch/WordWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/WordWatch.cs @@ -214,24 +214,7 @@ namespace BizHawk.Client.Common /// Get a string representation of difference /// between current value and the previous one /// - public override string Diff - { - get - { - string diff = ""; - int diffVal = _value - _previous; - if (diffVal > 0) - { - diff = "+"; - } - else if (diffVal < 0) - { - diff = "-"; - } - - return $"{diff}{((ushort)Math.Abs(diffVal))}"; - } - } + public override string Diff => $"{_value - (int)_previous:+#;-#;0}"; /// /// Get the maximum possible value diff --git a/BizHawk.Client.DiscoHawk/About.cs b/BizHawk.Client.DiscoHawk/About.cs index c89e7b4cad..ec2e82ab91 100644 --- a/BizHawk.Client.DiscoHawk/About.cs +++ b/BizHawk.Client.DiscoHawk/About.cs @@ -14,7 +14,7 @@ namespace BizHawk.Client.DiscoHawk public About() { InitializeComponent(); - lblVersion.Text = "v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + lblVersion.Text = $"v{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}"; } private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e) diff --git a/BizHawk.Client.DiscoHawk/AudioExtractor.cs b/BizHawk.Client.DiscoHawk/AudioExtractor.cs index b789d71e0e..bcc20411be 100644 --- a/BizHawk.Client.DiscoHawk/AudioExtractor.cs +++ b/BizHawk.Client.DiscoHawk/AudioExtractor.cs @@ -31,7 +31,7 @@ namespace BizHawk.Client.DiscoHawk for (int sector = 0; sector < trackLength; sector++) dsr.ReadLBA_2352(startLba + sector, waveData, sector * 2352); - string mp3Path = string.Format("{0} - Track {1:D2}.mp3", Path.Combine(path, filebase), track.Number); + string mp3Path = $"{Path.Combine(path, filebase)} - Track {track.Number:D2}.mp3"; if (File.Exists(mp3Path)) { if (!confirmed) diff --git a/BizHawk.Client.DiscoHawk/DiscoHawk.cs b/BizHawk.Client.DiscoHawk/DiscoHawk.cs index ee2b6eda31..ba91359d15 100644 --- a/BizHawk.Client.DiscoHawk/DiscoHawk.cs +++ b/BizHawk.Client.DiscoHawk/DiscoHawk.cs @@ -102,7 +102,7 @@ namespace BizHawk.Client.DiscoHawk return asm; //load missing assemblies by trying to find them in the dll directory - string dllname = new AssemblyName(args.Name).Name + ".dll"; + string dllname = $"{new AssemblyName(args.Name).Name}.dll"; string directory = Path.Combine(GetExeDirectoryAbsolute(), "dll"); string fname = Path.Combine(directory, dllname); if (!File.Exists(fname)) return null; @@ -120,7 +120,7 @@ namespace BizHawk.Client.DiscoHawk static extern bool DeleteFileW([MarshalAs(UnmanagedType.LPWStr)]string lpFileName); static void RemoveMOTW(string path) { - DeleteFileW(path + ":Zone.Identifier"); + DeleteFileW($"{path}:Zone.Identifier"); } static void WhackAllMOTW(string dllDir) @@ -416,8 +416,8 @@ namespace BizHawk.Client.DiscoHawk sw.Write(" "); sw.Write(new string('-', count * 4)); sw.WriteLine(); - sw_dump_chunk_one(string.Format("SRC #{0,6} ({1})", lba, new Timestamp(lba)), lba, src_databuf, addr, count); - sw_dump_chunk_one(string.Format("DST #{0,6} ({1})", lba, new Timestamp(lba)), lba, dst_databuf, addr, count); + sw_dump_chunk_one($"SRC #{lba,6} ({new Timestamp(lba)})", lba, src_databuf, addr, count); + sw_dump_chunk_one($"DST #{lba,6} ({new Timestamp(lba)})", lba, dst_databuf, addr, count); }; //verify each sector contents diff --git a/BizHawk.Client.DiscoHawk/DiscoHawkDialog.cs b/BizHawk.Client.DiscoHawk/DiscoHawkDialog.cs index 557d15aa87..14992bcf97 100644 --- a/BizHawk.Client.DiscoHawk/DiscoHawkDialog.cs +++ b/BizHawk.Client.DiscoHawk/DiscoHawkDialog.cs @@ -95,7 +95,7 @@ namespace BizHawk.Client.DiscoHawk } var cueBin = boundDisc.DumpCueBin(boundDiscRecord.BaseName, GetCuePrefs()); - txtCuePreview.Text = cueBin.cue.Replace("\n", "\r\n"); ; + txtCuePreview.Text = cueBin.cue.Replace("\n", "\r\n"); } private void btnPresetCanonical_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.DiscoHawk/MainDiscoForm.cs b/BizHawk.Client.DiscoHawk/MainDiscoForm.cs index cdd2c1a0f7..a0c1d0ac45 100644 --- a/BizHawk.Client.DiscoHawk/MainDiscoForm.cs +++ b/BizHawk.Client.DiscoHawk/MainDiscoForm.cs @@ -58,7 +58,7 @@ namespace BizHawk.Client.DiscoHawk string baseName = Path.GetFileNameWithoutExtension(file); baseName += "_hawked"; - string outfile = Path.Combine(Path.GetDirectoryName(file), baseName) + ".ccd"; + string outfile = $"{Path.Combine(Path.GetDirectoryName(file), baseName)}.ccd"; CCD_Format.Dump(disc, outfile); } this.Cursor = Cursors.Default; diff --git a/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs b/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs index a74765fa87..2cc69d918b 100644 --- a/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs +++ b/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs @@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk } else { - throw new ArgumentException("AviWriter only takes its own Codec Tokens!"); + throw new ArgumentException($"{nameof(AviWriter)} only takes its own {nameof(CodecToken)}s!"); } } @@ -53,7 +53,7 @@ namespace BizHawk.Client.EmuHawk int counter = 1; for (;;) { - yield return Path.Combine(dir, baseName) + "_" + counter + ext; + yield return Path.Combine(dir, $"{baseName}_{counter}{ext}"); counter++; } } @@ -97,7 +97,7 @@ namespace BizHawk.Client.EmuHawk } catch (Exception e) { - MessageBox.Show("AVIFIL32 Thread died:\n\n" + e); + MessageBox.Show($"AVIFIL32 Thread died:\n\n{e}"); } } @@ -321,11 +321,10 @@ namespace BizHawk.Client.EmuHawk int bytes = 0; if (a_bits == 16) bytes = 2; else if (a_bits == 8) bytes = 1; - else throw new InvalidOperationException("only 8/16 bits audio are supported by AviWriter and you chose: " + a_bits); + else throw new InvalidOperationException($"only 8/16 bits audio are supported by {nameof(AviWriter)} and you chose: {a_bits}"); if (a_channels == 1) { } else if (a_channels == 2) { } - else throw new InvalidOperationException("only 1/2 channels audio are supported by AviWriter and you chose: " + a_channels); - + else throw new InvalidOperationException($"only 1/2 channels audio are supported by {nameof(AviWriter)} and you chose: {a_channels}"); wfex.Init(); wfex.nBlockAlign = (ushort)(bytes * a_channels); wfex.nChannels = (ushort)a_channels; @@ -648,7 +647,7 @@ namespace BizHawk.Client.EmuHawk if (Win32.FAILED(Win32.AVIFileOpenW(ref pAviFile, destPath, Win32.OpenFileStyle.OF_CREATE | Win32.OpenFileStyle.OF_WRITE, 0))) { - throw new InvalidOperationException("Couldnt open dest path for avi file: " + destPath); + throw new InvalidOperationException($"Couldnt open dest path for avi file: {destPath}"); } // initialize the video stream @@ -954,7 +953,7 @@ namespace BizHawk.Client.EmuHawk CodecToken ct = CodecToken.DeSerialize(Global.Config.AVICodecToken); if (ct == null) { - throw new Exception("No default AVICodecToken in config!"); + throw new Exception($"No default {nameof(Global.Config.AVICodecToken)} in config!"); } _currVideoCodecToken = ct; @@ -991,7 +990,7 @@ namespace BizHawk.Client.EmuHawk // using (Font f = new Font(FontFamily.GenericMonospace, 10)) // g.DrawString(i.ToString(), f, Brushes.Black, 0, 0); // } -// //bmp.Save(string.Format("c:\\dump\\{0}.bmp", i), ImageFormat.Bmp); +// //bmp.Save($"c:\\dump\\{i}.bmp", ImageFormat.Bmp); // for (int y = 0, idx = 0; y < 256; y++) // for (int x = 0; x < 256; x++) // video.buffer[idx++] = bmp.GetPixel(x, y).ToArgb(); diff --git a/BizHawk.Client.EmuHawk/AVOut/FFmpegWriter.cs b/BizHawk.Client.EmuHawk/AVOut/FFmpegWriter.cs index 8806900b34..6f71c4b682 100644 --- a/BizHawk.Client.EmuHawk/AVOut/FFmpegWriter.cs +++ b/BizHawk.Client.EmuHawk/AVOut/FFmpegWriter.cs @@ -91,8 +91,7 @@ namespace BizHawk.Client.EmuHawk ffmpeg.StartInfo.FileName = "ffmpeg"; // expecting native version to be in path #endif - string filename = _baseName + (_segment > 0 ? $"_{_segment}" : "") + _ext; - _ffmpeg.StartInfo.Arguments = string.Format("-y -f nut -i - {1} \"{0}\"", filename, _token.Commandline); + _ffmpeg.StartInfo.Arguments = $"-y -f nut -i - {_token.Commandline} \"{_baseName}{(_segment == 0 ? string.Empty : $"_{_segment}")}{_ext}\""; _ffmpeg.StartInfo.CreateNoWindow = true; // ffmpeg sends informative display to stderr, and nothing to stdout @@ -100,7 +99,7 @@ namespace BizHawk.Client.EmuHawk _ffmpeg.StartInfo.RedirectStandardInput = true; _ffmpeg.StartInfo.UseShellExecute = false; - _commandline = "ffmpeg " + _ffmpeg.StartInfo.Arguments; + _commandline = $"ffmpeg {_ffmpeg.StartInfo.Arguments}"; _ffmpeg.ErrorDataReceived += new DataReceivedEventHandler(StderrHandler); @@ -132,7 +131,7 @@ namespace BizHawk.Client.EmuHawk _stderr.Dequeue(); } - _stderr.Enqueue(line.Data + "\n"); + _stderr.Enqueue($"{line.Data}\n"); } } @@ -193,7 +192,7 @@ namespace BizHawk.Client.EmuHawk if (_ffmpeg.HasExited) { - throw new Exception("unexpected ffmpeg death:\n" + ffmpeg_geterror()); + throw new Exception($"unexpected ffmpeg death:\n{ffmpeg_geterror()}"); } var video = source.GetVideoBuffer(); @@ -203,7 +202,7 @@ namespace BizHawk.Client.EmuHawk } catch { - MessageBox.Show("Exception! ffmpeg history:\n" + ffmpeg_geterror()); + MessageBox.Show($"Exception! ffmpeg history:\n{ffmpeg_geterror()}"); throw; } @@ -224,7 +223,7 @@ namespace BizHawk.Client.EmuHawk } else { - throw new ArgumentException("FFmpegWriter can only take its own codec tokens!"); + throw new ArgumentException($"{nameof(FFmpegWriter)} can only take its own codec tokens!"); } } @@ -274,7 +273,7 @@ namespace BizHawk.Client.EmuHawk { if (_ffmpeg.HasExited) { - throw new Exception("unexpected ffmpeg death:\n" + ffmpeg_geterror()); + throw new Exception($"unexpected ffmpeg death:\n{ffmpeg_geterror()}"); } if (samples.Length == 0) @@ -289,7 +288,7 @@ namespace BizHawk.Client.EmuHawk } catch { - MessageBox.Show("Exception! ffmpeg history:\n" + ffmpeg_geterror()); + MessageBox.Show($"Exception! ffmpeg history:\n{ffmpeg_geterror()}"); throw; } } diff --git a/BizHawk.Client.EmuHawk/AVOut/FFmpegWriterForm.cs b/BizHawk.Client.EmuHawk/AVOut/FFmpegWriterForm.cs index 12d526efd0..510ca56392 100644 --- a/BizHawk.Client.EmuHawk/AVOut/FFmpegWriterForm.cs +++ b/BizHawk.Client.EmuHawk/AVOut/FFmpegWriterForm.cs @@ -59,17 +59,17 @@ namespace BizHawk.Client.EmuHawk new FormatPreset("Matroska", "AVC video and Vorbis audio in a Matroska container.", "-c:a libvorbis -c:v libx264 -f matroska", false, "mkv"), new FormatPreset("MP4", "AVC video and AAC audio in an MP4 container.", - "-c:a libvo_aacenc -c:v libx264 -f mp4", false, "mp4"), + "-c:a aac -c:v libx264 -f mp4", false, "mp4"), new FormatPreset("WebM", "VP8 video and Vorbis audio in a WebM container.", - "-c:a libvorbis -c:v libvpx -f webm", false, "webm"), + "-c:a libvorbis -c:v libvpx -auto-alt-ref 0 -f webm", false, "webm"), new FormatPreset("Ogg", "Theora video and Vorbis audio in an Ogg contrainer.", "-c:a libvorbis -c:v libtheora -f ogg", false, "ogg"), new FormatPreset("Xvid", "Xvid video and MP3 audio in an AVI container.", "-c:a libmp3lame -c:v libxvid -f avi", false, "avi"), new FormatPreset("QuickTime", "AVC video and AAC audio in a QuickTime container.", - "-c:a libvo_aacenc -c:v libx264 -f mov", false, "mov"), + "-c:a aac -c:v libx264 -f mov", false, "mov"), new FormatPreset("FLV", "AVC video and AAC audio in a Flash Video container.", - "-c:a libvo_aacenc -c:v libx264 -f flv", false, "flv"), + "-c:a aac -c:v libx264 -f flv", false, "flv"), new FormatPreset("[Custom]", "Write your own ffmpeg command. For advanced users only.", "-c:a foo -c:v bar -f baz", true, "foobar"), }; @@ -142,7 +142,7 @@ namespace BizHawk.Client.EmuHawk if (listBox1.SelectedIndex != -1) { var f = (FormatPreset)listBox1.SelectedItem; - label5.Text = "Extension: " + f.Extension; + label5.Text = $"Extension: {f.Extension}"; label3.Text = f.Desc; textBox1.Text = f.Commandline; } diff --git a/BizHawk.Client.EmuHawk/AVOut/GifWriter.cs b/BizHawk.Client.EmuHawk/AVOut/GifWriter.cs index 34b7a2e47d..79c179622c 100644 --- a/BizHawk.Client.EmuHawk/AVOut/GifWriter.cs +++ b/BizHawk.Client.EmuHawk/AVOut/GifWriter.cs @@ -99,7 +99,7 @@ namespace BizHawk.Client.EmuHawk } else { - throw new ArgumentException("GifWriter only takes its own tokens!"); + throw new ArgumentException($"{nameof(GifWriter)} only takes its own tokens!"); } } diff --git a/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs b/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs index 50217ef9ec..a34867fe81 100644 --- a/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs +++ b/BizHawk.Client.EmuHawk/AVOut/ImageSequenceWriter.cs @@ -45,9 +45,7 @@ namespace BizHawk.Client.EmuHawk public void AddFrame(IVideoProvider source) { string ext = Path.GetExtension(_baseName); - string name = Path.GetFileNameWithoutExtension(_baseName) + "_" + _frame; - name += ext; - name = Path.Combine(Path.GetDirectoryName(_baseName), name); + var name = Path.Combine(Path.GetDirectoryName(_baseName), $"{Path.GetFileNameWithoutExtension(_baseName)}_{_frame}{ext}"); BitmapBuffer bb = new BitmapBuffer(source.BufferWidth, source.BufferHeight, source.GetVideoBuffer()); using (var bmp = bb.ToSysdrawingBitmap()) { diff --git a/BizHawk.Client.EmuHawk/AVOut/JMDWriter.cs b/BizHawk.Client.EmuHawk/AVOut/JMDWriter.cs index 7f7fbfab7d..00286e0120 100644 --- a/BizHawk.Client.EmuHawk/AVOut/JMDWriter.cs +++ b/BizHawk.Client.EmuHawk/AVOut/JMDWriter.cs @@ -182,7 +182,7 @@ namespace BizHawk.Client.EmuHawk { if (!f.CanWrite) { - throw new ArgumentException("Stream must be writable!"); + throw new ArgumentException($"{nameof(Stream)} must be writable!"); } this.f = f; @@ -671,7 +671,7 @@ namespace BizHawk.Client.EmuHawk } catch (Exception e) { - System.Windows.Forms.MessageBox.Show("JMD Worker Thread died:\n\n" + e); + System.Windows.Forms.MessageBox.Show($"JMD Worker Thread died:\n\n{e}"); return; } } diff --git a/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs b/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs index 4c9a2365df..b8d7c772b4 100644 --- a/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs +++ b/BizHawk.Client.EmuHawk/AVOut/NutMuxer.cs @@ -592,7 +592,7 @@ namespace BizHawk.Client.EmuHawk { dest.Write(data, 0, actual_length); _pool.ReleaseBuffer(data); - //dbg.WriteLine(string.Format("{0},{1},{2}", pts, ptsnum, ptsden)); + //dbg.WriteLine($"{pts},{ptsnum},{ptsden}"); } } diff --git a/BizHawk.Client.EmuHawk/AVOut/SynclessRecorder.cs b/BizHawk.Client.EmuHawk/AVOut/SynclessRecorder.cs index 04e731333d..4f488e8195 100644 --- a/BizHawk.Client.EmuHawk/AVOut/SynclessRecorder.cs +++ b/BizHawk.Client.EmuHawk/AVOut/SynclessRecorder.cs @@ -38,11 +38,11 @@ namespace BizHawk.Client.EmuHawk mProjectFile = projFile; mBaseDirectory = Path.GetDirectoryName(mProjectFile); string basename = Path.GetFileNameWithoutExtension(projFile); - string framesDirFragment = basename + "_frames"; + string framesDirFragment = $"{basename}_frames"; mFramesDirectory = Path.Combine(mBaseDirectory, framesDirFragment); StringBuilder sb = new StringBuilder(); sb.AppendLine("version=1"); - sb.AppendLine("framesdir=" + framesDirFragment); + sb.AppendLine($"framesdir={framesDirFragment}"); File.WriteAllText(mProjectFile, sb.ToString()); } @@ -55,7 +55,7 @@ namespace BizHawk.Client.EmuHawk using (var bb = new BitmapBuffer(source.BufferWidth, source.BufferHeight, source.GetVideoBuffer())) { string subpath = GetAndCreatePathForFrameNum(mCurrFrame); - string path = subpath + ".png"; + string path = $"{subpath}.png"; bb.ToSysdrawingBitmap().Save(path, System.Drawing.Imaging.ImageFormat.Png); } } @@ -63,7 +63,7 @@ namespace BizHawk.Client.EmuHawk public void AddSamples(short[] samples) { string subpath = GetAndCreatePathForFrameNum(mCurrFrame); - string path = subpath + ".wav"; + string path = $"{subpath}.wav"; WavWriterV wwv = new WavWriterV(); wwv.SetAudioParameters(paramSampleRate, paramChannels, paramBits); wwv.OpenFile(path); @@ -149,7 +149,7 @@ namespace BizHawk.Client.EmuHawk string subpath = GetPathFragmentForFrameNum(index); string path = mFramesDirectory; path = Path.Combine(path, subpath); - string fpath = path + ".nothing"; + string fpath = $"{path}.nothing"; Directory.CreateDirectory(Path.GetDirectoryName(fpath)); return path; } diff --git a/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs b/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs index 1afbc35bf4..a1e165bb3e 100644 --- a/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs +++ b/BizHawk.Client.EmuHawk/AVOut/SynclessRecordingTools.cs @@ -21,8 +21,8 @@ namespace BizHawk.Client.EmuHawk string subpath = SynclessRecorder.GetPathFragmentForFrameNum(index); string path = mFramesDirectory; path = Path.Combine(path, subpath); - png = path + ".png"; - wav = path + ".wav"; + png = $"{path}.png"; + wav = $"{path}.wav"; } private string mSynclessConfigFile; @@ -32,7 +32,7 @@ namespace BizHawk.Client.EmuHawk { var ofd = new OpenFileDialog { - FileName = PathManager.FilesystemSafeName(Global.Game) + ".syncless.txt", + FileName = $"{PathManager.FilesystemSafeName(Global.Game)}.syncless.txt", InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.AvPathFragment, null) }; diff --git a/BizHawk.Client.EmuHawk/AVOut/WavWriter.cs b/BizHawk.Client.EmuHawk/AVOut/WavWriter.cs index 9fefade2e7..b57f5f846c 100644 --- a/BizHawk.Client.EmuHawk/AVOut/WavWriter.cs +++ b/BizHawk.Client.EmuHawk/AVOut/WavWriter.cs @@ -265,7 +265,7 @@ namespace BizHawk.Client.EmuHawk int counter = 1; while (true) { - yield return new FileStream(Path.Combine(dir, baseName) + "_" + counter + ext, FileMode.Create); + yield return new FileStream($"{Path.Combine(dir, baseName)}_{counter}{ext}", FileMode.Create); counter++; } } diff --git a/BizHawk.Client.EmuHawk/AboutBox.cs b/BizHawk.Client.EmuHawk/AboutBox.cs index 5229ca78c8..92817df5bc 100644 --- a/BizHawk.Client.EmuHawk/AboutBox.cs +++ b/BizHawk.Client.EmuHawk/AboutBox.cs @@ -163,9 +163,9 @@ namespace BizHawk.Client.EmuHawk private void AboutBox_Load(object sender, EventArgs e) { #if DEBUG - Text = "BizHawk Developer Build (DEBUG MODE) GIT " + SubWCRev.GIT_BRANCH + "#" + SubWCRev.GIT_SHORTHASH; + Text = $"BizHawk Developer Build (DEBUG MODE) GIT {SubWCRev.GIT_BRANCH}#{SubWCRev.GIT_SHORTHASH}"; #else - Text = "BizHawk Developer Build (RELEASE MODE) GIT " + SubWCRev.GIT_BRANCH + "#" + SubWCRev.GIT_SHORTHASH; + Text = $"BizHawk Developer Build (RELEASE MODE) GIT {SubWCRev.GIT_BRANCH}#{SubWCRev.GIT_SHORTHASH}"; #endif if (DateTime.Now.Month == 12) if (DateTime.Now.Day > 17 && DateTime.Now.Day <= 25) diff --git a/BizHawk.Client.EmuHawk/Api/ApiContainer.cs b/BizHawk.Client.EmuHawk/Api/ApiContainer.cs new file mode 100644 index 0000000000..6a7b7102a3 --- /dev/null +++ b/BizHawk.Client.EmuHawk/Api/ApiContainer.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Linq; + +using BizHawk.Client.ApiHawk; + +namespace BizHawk.Client.EmuHawk +{ + public sealed class ApiContainer : IApiContainer + { + public IComm Comm => (IComm)Libraries[typeof(CommApi)]; + public IEmu Emu => (IEmu)Libraries[typeof(EmuApi)]; + public IGameInfo GameInfo => (IGameInfo)Libraries[typeof(GameInfoApi)]; + public IGui Gui => (IGui)Libraries[typeof(GuiApi)]; + public IInput Input => (IInput)Libraries[typeof(InputApi)]; + public IJoypad Joypad => (IJoypad)Libraries[typeof(JoypadApi)]; + public IMem Mem => (IMem)Libraries[typeof(MemApi)]; + public IMemEvents MemEvents => (IMemEvents)Libraries[typeof(MemEventsApi)]; + public IMemorySaveState MemorySaveState => (IMemorySaveState)Libraries[typeof(MemorySaveStateApi)]; + public IMovie Movie => (IMovie)Libraries[typeof(MovieApi)]; + public ISaveState SaveState => (ISaveState)Libraries[typeof(SaveStateApi)]; + public ISql Sql => (ISql)Libraries[typeof(SqlApi)]; + public ITool Tool => (ITool)Libraries[typeof(ToolApi)]; + public IUserData UserData => (IUserData)Libraries[typeof(UserDataApi)]; + public Dictionary Libraries { get; set; } + public ApiContainer(Dictionary libs) + { + Libraries = libs; + } + } +} diff --git a/BizHawk.Client.EmuHawk/Api/ApiManager.cs b/BizHawk.Client.EmuHawk/Api/ApiManager.cs new file mode 100644 index 0000000000..9dd5b71087 --- /dev/null +++ b/BizHawk.Client.EmuHawk/Api/ApiManager.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; + +using BizHawk.Common.ReflectionExtensions; +using BizHawk.Emulation.Common; +using BizHawk.Client.ApiHawk; + +namespace BizHawk.Client.EmuHawk + +{ + public static class ApiManager + { + private static ApiContainer container; + private static void Register(IEmulatorServiceProvider serviceProvider) + { + // Register external apis + var apis = Assembly + .Load("BizHawk.Client.ApiHawk") + .GetTypes() + .Where(t => typeof(IExternalApi).IsAssignableFrom(t)) + .Where(t => t.IsSealed) + .Where(t => ServiceInjector.IsAvailable(serviceProvider, t)) + .ToList(); + + apis.AddRange( + Assembly + .GetAssembly(typeof(ApiContainer)) + .GetTypes() + .Where(t => typeof(IExternalApi).IsAssignableFrom(t)) + .Where(t => t.IsSealed) + .Where(t => ServiceInjector.IsAvailable(serviceProvider, t))); + + foreach (var api in apis) + { + var instance = (IExternalApi)Activator.CreateInstance(api); + ServiceInjector.UpdateServices(serviceProvider, instance); + Libraries.Add(api, instance); + } + container = new ApiContainer(Libraries); + GlobalWin.ApiProvider = new BasicApiProvider(container); + } + private static readonly Dictionary Libraries = new Dictionary(); + public static void Restart(IEmulatorServiceProvider newServiceProvider) + { + Libraries.Clear(); + Register(newServiceProvider); + } + } +} diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/CommApi.cs b/BizHawk.Client.EmuHawk/Api/Libraries/CommApi.cs new file mode 100644 index 0000000000..4c27854761 --- /dev/null +++ b/BizHawk.Client.EmuHawk/Api/Libraries/CommApi.cs @@ -0,0 +1,121 @@ +using System; +using System.ComponentModel; + +using BizHawk.Emulation.Common; +using BizHawk.Client.ApiHawk; +using System.Text; +using System.Collections.Generic; +using System.Net.Http; +using System.Windows.Forms; + + +namespace BizHawk.Client.EmuHawk +{ + public sealed class CommApi : IComm + { + [RequiredService] + private IEmulator Emulator { get; set; } + + [RequiredService] + private IVideoProvider VideoProvider { get; set; } + + public CommApi() : base() + { } + + public string SocketServerScreenShot() + { + return GlobalWin.socketServer.SendScreenshot(); + } + public string SocketServerScreenShotResponse() + { + return GlobalWin.socketServer.SendScreenshot(1000).ToString(); + } + + public string SocketServerSend(string SendString) + { + return $"Sent : {GlobalWin.socketServer.SendString(SendString)} bytes"; + } + public string SocketServerResponse() + { + return GlobalWin.socketServer.ReceiveMessage(); + } + + public bool SocketServerSuccessful() + { + return GlobalWin.socketServer.Successful(); + } + public void SocketServerSetTimeout(int timeout) + { + GlobalWin.socketServer.SetTimeout(timeout); + } + // All MemoryMappedFile related methods + public void MmfSetFilename(string filename) + { + GlobalWin.memoryMappedFiles.SetFilename(filename); + } + public string MmfSetFilename() + { + return GlobalWin.memoryMappedFiles.GetFilename(); + } + + public int MmfScreenshot() + { + return GlobalWin.memoryMappedFiles.ScreenShotToFile(); + } + + public int MmfWrite(string mmf_filename, string outputString) + { + return GlobalWin.memoryMappedFiles.WriteToFile(mmf_filename, Encoding.ASCII.GetBytes(outputString)); + } + public string MmfRead(string mmf_filename, int expectedSize) + { + return GlobalWin.memoryMappedFiles.ReadFromFile(mmf_filename, expectedSize).ToString(); + } + // All HTTP related methods + public string HttpTest() + { + var list = new StringBuilder(); + list.AppendLine(GlobalWin.httpCommunication.TestGet()); + list.AppendLine(GlobalWin.httpCommunication.SendScreenshot()); + list.AppendLine("done testing"); + return list.ToString(); + } + public string HttpTestGet() + { + return GlobalWin.httpCommunication.TestGet(); + } + public string HttpGet(string url) + { + return GlobalWin.httpCommunication.ExecGet(url); + } + + public string HttpPost(string url, string payload) + { + return GlobalWin.httpCommunication.ExecPost(url, payload); + } + public string HttpPostScreenshot() + { + return GlobalWin.httpCommunication.SendScreenshot(); + } + public void HttpSetTimeout(int timeout) + { + GlobalWin.httpCommunication.SetTimeout(timeout); + } + public void HttpSetPostUrl(string url) + { + GlobalWin.httpCommunication.SetPostUrl(url); + } + public void HttpSetGetUrl(string url) + { + GlobalWin.httpCommunication.SetGetUrl(url); + } + public string HttpGetPostUrl() + { + return GlobalWin.httpCommunication.GetPostUrl(); + } + public string HttpGetGetUrl() + { + return GlobalWin.httpCommunication.GetGetUrl(); + } + } +} diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs b/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs new file mode 100644 index 0000000000..6f16a229b1 --- /dev/null +++ b/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs @@ -0,0 +1,655 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; +using System.Windows.Forms; +using System.IO; + +using BizHawk.Client.ApiHawk; +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.EmuHawk +{ + public sealed class GuiApi : IGui + { + [RequiredService] + private IEmulator Emulator { get; set; } + private Color _defaultForeground = Color.White; + private Color? _defaultBackground; + private Color? _defaultTextBackground = Color.FromArgb(128, 0, 0, 0); + private int _defaultPixelFont = 1; // gens + private Padding _padding = new Padding(0); + private ImageAttributes _attributes = new ImageAttributes(); + private System.Drawing.Drawing2D.CompositingMode _compositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; + + + public GuiApi() + { } + + private DisplaySurface _GUISurface = null; + + public bool HasGUISurface => _GUISurface != null; + + #region Gui API + public void ToggleCompositingMode() + { + _compositingMode = 1 - _compositingMode; + } + + public ImageAttributes GetAttributes() + { + return _attributes; + } + public void SetAttributes(ImageAttributes a) + { + _attributes = a; + } + + public void Dispose() + { + foreach (var brush in _solidBrushes.Values) + { + brush.Dispose(); + } + + foreach (var brush in _pens.Values) + { + brush.Dispose(); + } + } + + public void DrawNew(string name, bool? clear = true) + { + try + { + DrawFinish(); + _GUISurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear ?? true); + } + catch (InvalidOperationException ex) + { + Console.WriteLine(ex.ToString()); + } + } + + public void DrawFinish() + { + if (_GUISurface != null) + { + GlobalWin.DisplayManager.UnlockLuaSurface(_GUISurface); + } + + _GUISurface = null; + } + #endregion + + #region Helpers + private readonly Dictionary _imageCache = new Dictionary(); + private readonly Dictionary _solidBrushes = new Dictionary(); + private readonly Dictionary _pens = new Dictionary(); + private SolidBrush GetBrush(Color color) + { + SolidBrush b; + if (!_solidBrushes.TryGetValue(color, out b)) + { + b = new SolidBrush(color); + _solidBrushes[color] = b; + } + + return b; + } + + private Pen GetPen(Color color) + { + Pen p; + if (!_pens.TryGetValue(color, out p)) + { + p = new Pen(color); + _pens[color] = p; + } + + return p; + } + + private Graphics GetGraphics() + { + var g = _GUISurface == null ? Graphics.FromImage(new Bitmap(1,1)) : _GUISurface.GetGraphics(); + + // we don't like CoreComm, right? Someone should find a different way to do this then. + var tx = Emulator.CoreComm.ScreenLogicalOffsetX; + var ty = Emulator.CoreComm.ScreenLogicalOffsetY; + if (tx != 0 || ty != 0) + { + var transform = g.Transform; + transform.Translate(-tx, -ty); + g.Transform = transform; + } + + return g; + } + public void SetPadding(int all) + { + _padding = new Padding(all); + } + public void SetPadding(int x, int y) + { + _padding = new Padding(x / 2, y / 2, x / 2 + x & 1, y / 2 + y & 1); + } + public void SetPadding(int l, int t, int r, int b) + { + _padding = new Padding(l, t, r, b); + } + public Padding GetPadding() + { + return _padding; + } + #endregion + + public void AddMessage(string message) + { + GlobalWin.OSD.AddMessage(message); + } + + public void ClearGraphics() + { + _GUISurface.Clear(); + DrawFinish(); + } + + public void ClearText() + { + GlobalWin.OSD.ClearGUIText(); + } + + public void SetDefaultForegroundColor(Color color) + { + _defaultForeground = color; + } + + public void SetDefaultBackgroundColor(Color color) + { + _defaultBackground = color; + } + + public void SetDefaultTextBackground(Color color) + { + _defaultTextBackground = color; + } + + public void SetDefaultPixelFont(string fontfamily) + { + switch (fontfamily) + { + case "fceux": + case "0": + _defaultPixelFont = 0; + break; + case "gens": + case "1": + _defaultPixelFont = 1; + break; + default: + Console.WriteLine($"Unable to find font family: {fontfamily}"); + return; + } + } + + public void DrawBezier(Point p1, Point p2, Point p3, Point p4, Color? color = null) + { + using (var g = GetGraphics()) + { + try + { + g.CompositingMode = _compositingMode; + g.DrawBezier(GetPen(color ?? _defaultForeground), p1, p2, p3, p4); + } + catch (Exception) + { + return; + } + } + } + + public void DrawBeziers(Point[] points, Color? color = null) + { + using (var g = GetGraphics()) + { + try + { + g.CompositingMode = _compositingMode; + g.DrawBeziers(GetPen(color ?? _defaultForeground), points); + } + catch (Exception) + { + return; + } + } + } + public void DrawBox(int x, int y, int x2, int y2, Color? line = null, Color? background = null) + { + using (var g = GetGraphics()) + { + try + { + float w; + float h; + if (x < x2) + { + w = x2 - x; + } + else + { + x2 = x - x2; + x -= x2; + w = Math.Max(x2, 0.1f); + } + + if (y < y2) + { + h = y2 - y; + } + else + { + y2 = y - y2; + y -= y2; + h = Math.Max(y2, 0.1f); + } + + g.CompositingMode = _compositingMode; + g.DrawRectangle(GetPen(line ?? _defaultForeground), x, y, w, h); + + var bg = background ?? _defaultBackground; + if (bg.HasValue) + { + g.FillRectangle(GetBrush(bg.Value), x + 1, y + 1, Math.Max(w - 1, 0), Math.Max(h - 1, 0)); + } + } + catch (Exception) + { + // need to stop the script from here + return; + } + } + } + + public void DrawEllipse(int x, int y, int width, int height, Color? line = null, Color? background = null) + { + using (var g = GetGraphics()) + { + try + { + var bg = background ?? _defaultBackground; + if (bg.HasValue) + { + var brush = GetBrush(bg.Value); + g.FillEllipse(brush, x, y, width, height); + } + + g.CompositingMode = _compositingMode; + g.DrawEllipse(GetPen(line ?? _defaultForeground), x, y, width, height); + } + catch (Exception) + { + // need to stop the script from here + return; + } + } + } + + public void DrawIcon(string path, int x, int y, int? width = null, int? height = null) + { + using (var g = GetGraphics()) + { + try + { + if (!File.Exists(path)) + { + AddMessage($"File not found: {path}"); + return; + } + + Icon icon; + if (width.HasValue && height.HasValue) + { + icon = new Icon(path, width.Value, height.Value); + } + else + { + icon = new Icon(path); + } + + g.CompositingMode = _compositingMode; + g.DrawIcon(icon, x, y); + } + catch (Exception) + { + return; + } + } + } + + public void DrawImage(string path, int x, int y, int? width = null, int? height = null, bool cache = true) + { + if (!File.Exists(path)) + { + Console.WriteLine($"File not found: {path}"); + return; + } + + using (var g = GetGraphics()) + { + Image img; + if (_imageCache.ContainsKey(path)) + { + img = _imageCache[path]; + } + else + { + img = Image.FromFile(path); + if (cache) + { + _imageCache.Add(path, img); + } + } + var destRect = new Rectangle(x, y, width ?? img.Width, height ?? img.Height); + + g.CompositingMode = _compositingMode; + g.DrawImage(img, destRect, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, _attributes); + } + } + + public void ClearImageCache() + { + foreach (var image in _imageCache) + { + image.Value.Dispose(); + } + + _imageCache.Clear(); + } + + public void DrawImageRegion(string path, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int? dest_width = null, int? dest_height = null) + { + if (!File.Exists(path)) + { + Console.WriteLine($"File not found: {path}"); + return; + } + + using (var g = GetGraphics()) + { + Image img; + if (_imageCache.ContainsKey(path)) + { + img = _imageCache[path]; + } + else + { + img = Image.FromFile(path); + _imageCache.Add(path, img); + } + + var destRect = new Rectangle(dest_x, dest_y, dest_width ?? source_width, dest_height ?? source_height); + + g.CompositingMode = _compositingMode; + g.DrawImage(img, destRect, source_x, source_y, source_width, source_height, GraphicsUnit.Pixel, _attributes); + } + } + + public void DrawLine(int x1, int y1, int x2, int y2, Color? color = null) + { + using (var g = GetGraphics()) + { + g.CompositingMode = _compositingMode; + g.DrawLine(GetPen(color ?? _defaultForeground), x1, y1, x2, y2); + } + } + + public void DrawAxis(int x, int y, int size, Color? color = null) + { + DrawLine(x + size, y, x - size, y, color ?? _defaultForeground); + DrawLine(x, y + size, x, y - size, color ?? _defaultForeground); + } + + public void DrawPie(int x, int y, int width, int height, int startangle, int sweepangle, Color? line = null, Color? background = null) + { + using (var g = GetGraphics()) + { + g.CompositingMode = _compositingMode; + var bg = background ?? _defaultBackground; + if (bg.HasValue) + { + var brush = GetBrush(bg.Value); + g.FillPie(brush, x, y, width, height, startangle, sweepangle); + } + + g.DrawPie(GetPen(line ?? _defaultForeground), x + 1, y + 1, width - 1, height - 1, startangle, sweepangle); + } + } + + public void DrawPixel(int x, int y, Color? color = null) + { + using (var g = GetGraphics()) + { + try + { + g.DrawLine(GetPen(color ?? _defaultForeground), x, y, x + 0.1F, y); + } + catch (Exception) + { + return; + } + } + } + + public void DrawPolygon(Point[] points, Color? line = null, Color? background = null) + { + using (var g = GetGraphics()) + { + try + { + g.DrawPolygon(GetPen(line ?? _defaultForeground), points); + var bg = background ?? _defaultBackground; + if (bg.HasValue) + { + g.FillPolygon(GetBrush(bg.Value), points); + } + } + catch (Exception) + { + return; + } + } + } + + public void DrawRectangle(int x, int y, int width, int height, Color? line = null, Color? background = null) + { + using (var g = GetGraphics()) + { + var w = Math.Max(width, 0.1F); + var h = Math.Max(height, 0.1F); + g.DrawRectangle(GetPen(line ?? _defaultForeground), x, y, w, h); + var bg = background ?? _defaultBackground; + if (bg.HasValue) + { + g.FillRectangle(GetBrush(bg.Value), x + 1, y + 1, Math.Max(w - 1, 0), Math.Max(h - 1, 0)); + } + } + } + + public void DrawString(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, int? fontsize = null, + string fontfamily = null, string fontstyle = null, string horizalign = null, string vertalign = null) + { + using (var g = GetGraphics()) + { + try + { + var family = FontFamily.GenericMonospace; + if (fontfamily != null) + { + family = new FontFamily(fontfamily); + } + + var fstyle = FontStyle.Regular; + if (fontstyle != null) + { + switch (fontstyle.ToLower()) + { + default: + case "regular": + break; + case "bold": + fstyle = FontStyle.Bold; + break; + case "italic": + fstyle = FontStyle.Italic; + break; + case "strikethrough": + fstyle = FontStyle.Strikeout; + break; + case "underline": + fstyle = FontStyle.Underline; + break; + } + } + + // The text isn't written out using GenericTypographic, so measuring it using GenericTypographic seemed to make it worse. + // And writing it out with GenericTypographic just made it uglier. :p + var f = new StringFormat(StringFormat.GenericDefault); + var font = new Font(family, fontsize ?? 12, fstyle, GraphicsUnit.Pixel); + Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize(); + if (horizalign != null) + { + switch (horizalign.ToLower()) + { + default: + case "left": + break; + case "center": + x -= sizeOfText.Width / 2; + break; + case "right": + x -= sizeOfText.Width; + break; + } + } + + if (vertalign != null) + { + switch (vertalign.ToLower()) + { + default: + case "bottom": + break; + case "middle": + y -= sizeOfText.Height / 2; + break; + case "top": + y -= sizeOfText.Height; + break; + } + } + + var bg = backcolor ?? _defaultBackground; + if (bg.HasValue) + { + for (var xd = -1; xd <= 1; xd++) + { + for (var yd = -1; yd <= 1; yd++) + { + g.DrawString(message, font, GetBrush(bg.Value), x + xd, y + yd); + } + } + } + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; + g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y); + } + catch (Exception) + { + return; + } + } + } + + public void DrawText(int x, int y, string message, Color? forecolor = null, Color? backcolor = null, string fontfamily = null) + { + using (var g = GetGraphics()) + { + try + { + var index = 0; + if (string.IsNullOrEmpty(fontfamily)) + { + index = _defaultPixelFont; + } + else + { + switch (fontfamily) + { + case "fceux": + case "0": + index = 0; + break; + case "gens": + case "1": + index = 1; + break; + default: + Console.WriteLine($"Unable to find font family: {fontfamily}"); + return; + } + } + + var f = new StringFormat(StringFormat.GenericTypographic) + { + FormatFlags = StringFormatFlags.MeasureTrailingSpaces + }; + var font = new Font(GlobalWin.DisplayManager.CustomFonts.Families[index], 8, FontStyle.Regular, GraphicsUnit.Pixel); + Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize(); + var rect = new Rectangle(new Point(x, y), sizeOfText + new Size(1, 0)); + if (backcolor.HasValue) g.FillRectangle(GetBrush(backcolor.Value), rect); + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; + g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y); + } + catch (Exception) + { + return; + } + } + } + + public void Text(int x, int y, string message, Color? forecolor = null, string anchor = null) + { + var a = 0; + + if (!string.IsNullOrEmpty(anchor)) + { + switch (anchor) + { + case "0": + case "topleft": + a = 0; + break; + case "1": + case "topright": + a = 1; + break; + case "2": + case "bottomleft": + a = 2; + break; + case "3": + case "bottomright": + a = 3; + break; + } + } + else + { + x -= Emulator.CoreComm.ScreenLogicalOffsetX; + y -= Emulator.CoreComm.ScreenLogicalOffsetY; + } + + GlobalWin.OSD.AddGUIText(message, x, y, Color.Black, forecolor ?? Color.White, a); + } + } +} \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/InputApi.cs b/BizHawk.Client.EmuHawk/Api/Libraries/InputApi.cs new file mode 100644 index 0000000000..56e2cd767f --- /dev/null +++ b/BizHawk.Client.EmuHawk/Api/Libraries/InputApi.cs @@ -0,0 +1,44 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using System.Windows.Forms; + +using BizHawk.Client.ApiHawk; +using BizHawk.Client.Common; + +namespace BizHawk.Client.EmuHawk +{ + public sealed class InputApi : IInput + { + public InputApi() : base() + { } + + public Dictionary Get() + { + var buttons = new Dictionary(); + foreach (var kvp in Global.ControllerInputCoalescer.BoolButtons().Where(kvp => kvp.Value)) + { + buttons[kvp.Key] = true; + } + + return buttons; + } + + public Dictionary GetMouse() + { + var buttons = new Dictionary(); + + // TODO - need to specify whether in "emu" or "native" coordinate space. + var p = GlobalWin.DisplayManager.UntransformPoint(Control.MousePosition); + buttons["X"] = p.X; + buttons["Y"] = p.Y; + buttons[MouseButtons.Left.ToString()] = (Control.MouseButtons & MouseButtons.Left) != 0; + buttons[MouseButtons.Middle.ToString()] = (Control.MouseButtons & MouseButtons.Middle) != 0; + buttons[MouseButtons.Right.ToString()] = (Control.MouseButtons & MouseButtons.Right) != 0; + buttons[MouseButtons.XButton1.ToString()] = (Control.MouseButtons & MouseButtons.XButton1) != 0; + buttons[MouseButtons.XButton2.ToString()] = (Control.MouseButtons & MouseButtons.XButton2) != 0; + buttons["Wheel"] = GlobalWin.MainForm.MouseWheelTracker; + return buttons; + } + } +} diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/SaveStateAPI.cs b/BizHawk.Client.EmuHawk/Api/Libraries/SaveStateAPI.cs new file mode 100644 index 0000000000..d4b1cdbe2f --- /dev/null +++ b/BizHawk.Client.EmuHawk/Api/Libraries/SaveStateAPI.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.IO; + +using BizHawk.Client.ApiHawk; + +namespace BizHawk.Client.EmuHawk +{ + public sealed class SaveStateApi : ISaveState + { + public SaveStateApi() : base() + { } + + public void Load(string path) + { + if (!File.Exists(path)) + { + Console.WriteLine($"could not find file: {path}"); + } + else + { + GlobalWin.MainForm.LoadState(path, Path.GetFileName(path), true); + } + } + + public void LoadSlot(int slotNum) + { + if (slotNum >= 0 && slotNum <= 9) + { + GlobalWin.MainForm.LoadQuickSave($"QuickSave{slotNum}", true); + } + } + + public void Save(string path) + { + GlobalWin.MainForm.SaveState(path, path, true); + } + + public void SaveSlot(int slotNum) + { + if (slotNum >= 0 && slotNum <= 9) + { + GlobalWin.MainForm.SaveQuickSave($"QuickSave{slotNum}"); + } + } + } +} diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs b/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs new file mode 100644 index 0000000000..d356761cdf --- /dev/null +++ b/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using BizHawk.Common; +using BizHawk.Emulation.Common; +using BizHawk.Client.ApiHawk; +using BizHawk.Client.Common; + +namespace BizHawk.Client.EmuHawk +{ + public sealed class ToolApi : ITool + { + private class ToolStatic + { + public Type GetTool(string name) + { + var toolType = ReflectionUtil.GetTypeByName(name) + .FirstOrDefault(x => typeof(IToolForm).IsAssignableFrom(x) && !x.IsInterface); + + if (toolType != null) + { + GlobalWin.Tools.Load(toolType); + } + + var selectedTool = GlobalWin.Tools.AvailableTools + .FirstOrDefault(tool => tool.GetType().Name.ToLower() == name.ToLower()); + + if (selectedTool != null) + { + return selectedTool; + } + + return null; + } + + public object CreateInstance(string name) + { + var possibleTypes = ReflectionUtil.GetTypeByName(name); + + if (possibleTypes.Any()) + { + return Activator.CreateInstance(possibleTypes.First()); + } + + return null; + } + + public static void OpenCheats() + { + GlobalWin.Tools.Load(); + } + + public static void OpenHexEditor() + { + GlobalWin.Tools.Load(); + } + + public static void OpenRamWatch() + { + GlobalWin.Tools.LoadRamWatch(loadDialog: true); + } + + public static void OpenRamSearch() + { + GlobalWin.Tools.Load(); + } + + public static void OpenTasStudio() + { + GlobalWin.Tools.Load(); + } + + public static void OpenToolBox() + { + GlobalWin.Tools.Load(); + } + + public static void OpenTraceLogger() + { + GlobalWin.Tools.Load(); + } + + } + [RequiredService] + private static IEmulator Emulator { get; set; } + + [RequiredService] + private static IVideoProvider VideoProvider { get; set; } + + public ToolApi() + { } + + public Type GetTool(string name) + { + var toolType = ReflectionUtil.GetTypeByName(name) + .FirstOrDefault(x => typeof(IToolForm).IsAssignableFrom(x) && !x.IsInterface); + + if (toolType != null) + { + GlobalWin.Tools.Load(toolType); + } + + var selectedTool = GlobalWin.Tools.AvailableTools + .FirstOrDefault(tool => tool.GetType().Name.ToLower() == name.ToLower()); + + if (selectedTool != null) + { + return selectedTool; + } + + return null; + } + + public object CreateInstance(string name) + { + var possibleTypes = ReflectionUtil.GetTypeByName(name); + + if (possibleTypes.Any()) + { + return Activator.CreateInstance(possibleTypes.First()); + } + + return null; + } + + public void OpenCheats() + { + ToolStatic.OpenCheats(); + } + + public void OpenHexEditor() + { + ToolStatic.OpenHexEditor(); + } + + public void OpenRamWatch() + { + ToolStatic.OpenRamWatch(); + } + + public void OpenRamSearch() + { + ToolStatic.OpenRamSearch(); + } + + public void OpenTasStudio() + { + ToolStatic.OpenTasStudio(); + } + + public void OpenToolBox() + { + ToolStatic.OpenToolBox(); + } + + public void OpenTraceLogger() + { + ToolStatic.OpenTraceLogger(); + } + } +} diff --git a/BizHawk.Client.EmuHawk/ArchiveChooser.cs b/BizHawk.Client.EmuHawk/ArchiveChooser.cs index 7e2b248698..3e3f20468d 100644 --- a/BizHawk.Client.EmuHawk/ArchiveChooser.cs +++ b/BizHawk.Client.EmuHawk/ArchiveChooser.cs @@ -145,8 +145,8 @@ namespace BizHawk.Client.EmuHawk errMsg = errMsg.Substring(errMsg.IndexOf('-') + 2); // Balloon is bugged on first invocation - errorBalloon.Show("Error parsing RegEx: " + errMsg, tb); - errorBalloon.Show("Error parsing RegEx: " + errMsg, tb); + errorBalloon.Show($"Error parsing RegEx: {errMsg}", tb); + errorBalloon.Show($"Error parsing RegEx: {errMsg}", tb); } } diff --git a/BizHawk.Client.EmuHawk/ArgParser.cs b/BizHawk.Client.EmuHawk/ArgParser.cs index 0912c68ba9..6c4823af50 100644 --- a/BizHawk.Client.EmuHawk/ArgParser.cs +++ b/BizHawk.Client.EmuHawk/ArgParser.cs @@ -14,6 +14,8 @@ namespace BizHawk.Client.EmuHawk public string cmdRom = null; public string cmdLoadSlot = null; public string cmdLoadState = null; + public string cmdConfigPath = null; + public string cmdConfigFile = null; public string cmdMovie = null; public string cmdDumpType = null; public string cmdDumpName = null; @@ -55,6 +57,10 @@ namespace BizHawk.Client.EmuHawk { cmdLoadState = args[i].Substring(args[i].IndexOf('=') + 1); } + if (arg.StartsWith("--config=")) + { + cmdConfigFile = args[i].Substring(args[i].IndexOf('=') + 1); + } else if (arg.StartsWith("--movie=")) { cmdMovie = args[i].Substring(args[i].IndexOf('=') + 1); diff --git a/BizHawk.Client.EmuHawk/BizBox.cs b/BizHawk.Client.EmuHawk/BizBox.cs index 14da9178bf..a233234d1d 100644 --- a/BizHawk.Client.EmuHawk/BizBox.cs +++ b/BizHawk.Client.EmuHawk/BizBox.cs @@ -31,14 +31,14 @@ namespace BizHawk.Client.EmuHawk mainversion += " (x64)"; if (VersionInfo.DeveloperBuild) { - Text = " BizHawk (GIT " + SubWCRev.GIT_BRANCH + "#" + SubWCRev.GIT_SHORTHASH + ")"; + Text = $" BizHawk (GIT {SubWCRev.GIT_BRANCH}#{SubWCRev.GIT_SHORTHASH})"; } else { - Text = "Version " + mainversion + " (GIT " + SubWCRev.GIT_BRANCH + "#" + SubWCRev.GIT_SHORTHASH + ")"; + Text = $"Version {mainversion} (GIT {SubWCRev.GIT_BRANCH}#{SubWCRev.GIT_SHORTHASH})"; } - VersionLabel.Text = "Version " + mainversion; + VersionLabel.Text = $"Version {mainversion}"; DateLabel.Text = VersionInfo.RELEASEDATE; var cores = Assembly @@ -59,12 +59,12 @@ namespace BizHawk.Client.EmuHawk }); } - linkLabel2.Text = "Commit # " + SubWCRev.GIT_SHORTHASH; + linkLabel2.Text = $"Commit # {SubWCRev.GIT_SHORTHASH}"; } private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - System.Diagnostics.Process.Start("https://github.com/TASVideos/BizHawk/commit/" + SubWCRev.GIT_SHORTHASH); + System.Diagnostics.Process.Start($"https://github.com/TASVideos/BizHawk/commit/{SubWCRev.GIT_SHORTHASH}"); } private void btnCopyHash_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/BizBoxInfoControl.cs b/BizHawk.Client.EmuHawk/BizBoxInfoControl.cs index a8a3c7f7c3..6ea8f276b8 100644 --- a/BizHawk.Client.EmuHawk/BizBoxInfoControl.cs +++ b/BizHawk.Client.EmuHawk/BizBoxInfoControl.cs @@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk if (!string.IsNullOrEmpty(attributes.Author)) { - CoreAuthorLabel.Text = "authors: " + attributes.Author; + CoreAuthorLabel.Text = $"authors: {attributes.Author}"; } else { diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 646beb4e11..bedd659de2 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -45,7 +45,7 @@ true ..\output\ - WINDOWS;DEBUG + DEBUG;WINDOWS;EXE_PROJECT true full AnyCPU @@ -56,7 +56,7 @@ ..\output\ - WINDOWS + WINDOWS;EXE_PROJECT true true pdbonly @@ -113,6 +113,9 @@ + + PlatformLinkedLibSingleton.cs + svnrev.cs @@ -658,6 +661,13 @@ + + + + + + + @@ -731,7 +741,6 @@ NameStateForm.cs - Form @@ -943,6 +952,8 @@ + + Form @@ -1241,6 +1252,7 @@ + diff --git a/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs b/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs index 2787e74bf9..d85e925adb 100644 --- a/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs +++ b/BizHawk.Client.EmuHawk/CoreFeatureAnalysis.cs @@ -229,10 +229,7 @@ namespace BizHawk.Client.EmuHawk .ThenBy(t => t.CoreAttributes.CoreName) .ToList(); - toolStripStatusLabel1.Text = string.Format("Total: {0} Released: {1} Profiled: {2}", - possiblecoretypes.Count, - KnownCores.Values.Count(c => c.Released), - KnownCores.Count); + toolStripStatusLabel1.Text = $"Total: {possiblecoretypes.Count} Released: {KnownCores.Values.Count(c => c.Released)} Profiled: {KnownCores.Count}"; CoreTree.Nodes.Clear(); CoreTree.BeginUpdate(); diff --git a/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs b/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs index 4e0c3e9733..8a2e55146d 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs @@ -36,7 +36,7 @@ namespace BizHawk.Client.EmuHawk _maxSize = domainSize - 1; MaxLength = _maxSize.Value.NumHexDigits(); - _addressFormatStr = "{0:X" + MaxLength + "}"; + _addressFormatStr = $"{{0:X{MaxLength}}}"; //try to preserve the old value, as best we can if(!wasMaxSizeSet) diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs index b62d246e41..e85de140a0 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs @@ -2042,7 +2042,7 @@ namespace BizHawk.Client.EmuHawk // no check will make it crash for user too, not sure which way of alarm we prefer. no alarm at all will cause all sorts of subtle bugs if (ChangedCallback == null) { - System.Diagnostics.Debug.Fail("ColumnChangedCallback has died!"); + System.Diagnostics.Debug.Fail($"{nameof(ColumnChangedCallback)} has died!"); } else { diff --git a/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs b/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs index 0038c26e20..2fd17e6f68 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/TasListView.cs @@ -14,7 +14,7 @@ namespace BizHawk.Client.EmuHawk // Convenience hack public override string ToString() { - return string.IsNullOrEmpty(Column) ? "?" : Column + " - " + (RowIndex.HasValue ? RowIndex.ToString() : "?"); + return string.IsNullOrEmpty(Column) ? "?" : $"{Column} - {(RowIndex.HasValue ? RowIndex.ToString() : "?")}"; } } diff --git a/BizHawk.Client.EmuHawk/CustomControls/VirtualListView.cs b/BizHawk.Client.EmuHawk/CustomControls/VirtualListView.cs index f0a2d07909..6f800dc407 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/VirtualListView.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/VirtualListView.cs @@ -398,7 +398,7 @@ namespace BizHawk.Client.EmuHawk if (value == View.LargeIcon || value == View.SmallIcon) { - throw new ArgumentException("Icon views are invalid for virtual ListViews", "View"); + throw new ArgumentException($"Icon views are invalid for virtual {nameof(ListView)}s", nameof(View)); } base.View = value; @@ -505,7 +505,7 @@ namespace BizHawk.Client.EmuHawk } catch (Exception ex) { - System.Diagnostics.Trace.WriteLine("VirtualListView.SetItemState error=" + ex.Message); + System.Diagnostics.Trace.WriteLine($"VirtualListView.SetItemState error={ex.Message}"); // TODO: should this eat any exceptions? throw; @@ -551,7 +551,7 @@ namespace BizHawk.Client.EmuHawk } catch (Exception e) { - Debug.WriteLine("Failed to copy text name from client: " + e, "VirtualListView.OnDispInfoNotice"); + Debug.WriteLine($"Failed to copy text name from client: {e}", $"{nameof(VirtualListView)}.{nameof(OnDispInfoNotice)}"); } } } @@ -687,7 +687,7 @@ namespace BizHawk.Client.EmuHawk } catch (Exception ex) { - Trace.WriteLine(string.Format("Message {0} caused an exception: {1}", m, ex.Message)); + Trace.WriteLine($"Message {m} caused an exception: {ex.Message}"); } } } @@ -705,7 +705,7 @@ namespace BizHawk.Client.EmuHawk if (item == null) { - throw new ArgumentException("cannot find item " + idx + " via QueryItem event"); + throw new ArgumentException($"cannot find item {idx} via {nameof(QueryItem)} event"); } return item; diff --git a/BizHawk.Client.EmuHawk/CustomControls/Win32.cs b/BizHawk.Client.EmuHawk/CustomControls/Win32.cs index dd11df172e..6c53604b4a 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/Win32.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/Win32.cs @@ -146,7 +146,7 @@ namespace BizHawk.Client.EmuHawk public override string ToString() { - return "{Left: " + _Left + "; " + "Top: " + _Top + "; Right: " + _Right + "; Bottom: " + _Bottom + "}"; + return $"{{Left: {_Left}; Top: {_Top}; Right: {_Right}; Bottom: {_Bottom}}}"; } public override int GetHashCode() diff --git a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs index fc7ccbc84b..cf8783c48d 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs @@ -181,6 +181,13 @@ namespace BizHawk.Client.EmuHawk padding.Bottom += core_padding.Height - core_padding.Height / 2; } + //apply user's crop selections as a negative padding (believe it or not, this largely works) + //is there an issue with the aspect ratio? I dont know--but if there is, there would be with the padding too + padding.Left -= Global.Config.DispCropLeft; + padding.Right -= Global.Config.DispCropRight; + padding.Top -= Global.Config.DispCropTop; + padding.Bottom -= Global.Config.DispCropBottom; + return padding; } @@ -299,7 +306,7 @@ namespace BizHawk.Client.EmuHawk { var pass = retroChain.Passes[i]; var rsp = new Filters.RetroShaderPass(retroChain, i); - string fname = string.Format("{0}[{1}]", name, i); + string fname = $"{name}[{i}]"; program.AddFilter(rsp, fname); rsp.Parameters = properties; } @@ -484,7 +491,7 @@ namespace BizHawk.Client.EmuHawk bufferWidth += padding.Horizontal; bufferHeight += padding.Vertical; - //Console.WriteLine("DISPZOOM " + zoom); //test + //Console.WriteLine($"DISPZOOM {zoom}"); //test //old stuff var fvp = new FakeVideoProvider(); @@ -908,7 +915,7 @@ namespace BizHawk.Client.EmuHawk public DisplaySurface LockLuaSurface(string name, bool clear=true) { if (MapNameToLuaSurface.ContainsKey(name)) - throw new InvalidOperationException("Lua surface is already locked: " + name); + throw new InvalidOperationException($"Lua surface is already locked: {name}"); SwappableDisplaySurfaceSet sdss; if (!LuaSurfaceSets.TryGetValue(name, out sdss)) @@ -932,7 +939,7 @@ namespace BizHawk.Client.EmuHawk height += GameExtraPadding.Vertical; } else if(name == "native") { width = currNativeWidth; height = currNativeHeight; } - else throw new InvalidOperationException("Unknown lua surface name: " +name); + else throw new InvalidOperationException($"Unknown lua surface name: {name}"); DisplaySurface ret = sdss.AllocateSurface(width, height, clear); MapNameToLuaSurface[name] = ret; diff --git a/BizHawk.Client.EmuHawk/DisplayManager/FilterManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/FilterManager.cs index e8a23765bb..02e14934a2 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/FilterManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/FilterManager.cs @@ -138,11 +138,11 @@ namespace BizHawk.Client.EmuHawk.FilterManager public override string ToString() { if (Type == ProgramStepType.Run) - return string.Format("Run {0} ({1})", (int)Args, Comment); + return $"Run {(int)Args} ({Comment})"; if (Type == ProgramStepType.NewTarget) - return string.Format("NewTarget {0}", (Size)Args); + return $"NewTarget {(Size)Args}"; if (Type == ProgramStepType.FinalTarget) - return string.Format("FinalTarget"); + return "FinalTarget"; return null; } } diff --git a/BizHawk.Client.EmuHawk/DisplayManager/Filters/Retro.cs b/BizHawk.Client.EmuHawk/DisplayManager/Filters/Retro.cs index 4e90b9b3ae..72e20b9c7f 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/Filters/Retro.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/Filters/Retro.cs @@ -69,7 +69,7 @@ namespace BizHawk.Client.EmuHawk.Filters Shaders[i] = shader; if (!shader.Available) { - Errors += string.Format("===================\r\nPass {0}:\r\n{1}",i,shader.Errors); + Errors += $"===================\r\nPass {i}:\r\n{shader.Errors}"; ok = false; } } @@ -141,25 +141,25 @@ namespace BizHawk.Client.EmuHawk.Filters sp.Index = i; Passes.Add(sp); - sp.InputFilterLinear = FetchBool(dict, "filter_linear" + i, false); //Should this value not be defined, the filtering option is implementation defined. - sp.OuputFloat = FetchBool(dict, "float_framebuffer" + i, false); - sp.FrameCountMod = FetchInt(dict, "frame_count_mod" + i, 1); - sp.ShaderPath = FetchString(dict, "shader" + i, "?"); //todo - change extension to .cg for better compatibility? just change .cg to .glsl transparently at last second? + sp.InputFilterLinear = FetchBool(dict, $"filter_linear{i}", false); //Should this value not be defined, the filtering option is implementation defined. + sp.OuputFloat = FetchBool(dict, $"float_framebuffer{i}", false); + sp.FrameCountMod = FetchInt(dict, $"frame_count_mod{i}", 1); + sp.ShaderPath = FetchString(dict, $"shader{i}", "?"); //todo - change extension to .cg for better compatibility? just change .cg to .glsl transparently at last second? //If no scale type is assumed, it is assumed that it is set to "source" with scaleN set to 1.0. //It is possible to set scale_type_xN and scale_type_yN to specialize the scaling type in either direction. scale_typeN however overrides both of these. - sp.ScaleTypeX = (ScaleType)Enum.Parse(typeof(ScaleType), FetchString(dict, "scale_type_x" + i, "Source"), true); - sp.ScaleTypeY = (ScaleType)Enum.Parse(typeof(ScaleType), FetchString(dict, "scale_type_y" + i, "Source"), true); - ScaleType st = (ScaleType)Enum.Parse(typeof(ScaleType), FetchString(dict, "scale_type" + i, "NotSet"), true); + sp.ScaleTypeX = (ScaleType)Enum.Parse(typeof(ScaleType), FetchString(dict, $"scale_type_x{i}", "Source"), true); + sp.ScaleTypeY = (ScaleType)Enum.Parse(typeof(ScaleType), FetchString(dict, $"scale_type_y{i}", "Source"), true); + ScaleType st = (ScaleType)Enum.Parse(typeof(ScaleType), FetchString(dict, $"scale_type{i}", "NotSet"), true); if (st != ScaleType.NotSet) sp.ScaleTypeX = sp.ScaleTypeY = st; //scaleN controls both scaling type in horizontal and vertical directions. If scaleN is defined, scale_xN and scale_yN have no effect. - sp.Scale.X = FetchFloat(dict, "scale_x" + i, 1); - sp.Scale.Y = FetchFloat(dict, "scale_y" + i, 1); - float scale = FetchFloat(dict, "scale" + i, -999); + sp.Scale.X = FetchFloat(dict, $"scale_x{i}", 1); + sp.Scale.Y = FetchFloat(dict, $"scale_y{i}", 1); + float scale = FetchFloat(dict, $"scale{i}", -999); if (scale != -999) - sp.Scale.X = sp.Scale.Y = FetchFloat(dict, "scale" + i, 1); + sp.Scale.X = sp.Scale.Y = FetchFloat(dict, $"scale{i}", 1); //TODO - LUTs } @@ -249,10 +249,7 @@ namespace BizHawk.Client.EmuHawk.Filters int RSI; Size OutputSize; - public override string ToString() - { - return string.Format("RetroShaderPass[#{0}]", RSI); - } + public override string ToString() => $"{nameof(RetroShaderPass)}[#{RSI}]"; public RetroShaderPass(RetroShaderChain RSC, int index) { diff --git a/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs index d0befae66e..5b1d7428f9 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs @@ -53,7 +53,7 @@ namespace BizHawk.Client.EmuHawk public void Begin(IBlitter blitter) { - MessageFont = blitter.GetFontType("MessageFont"); + MessageFont = blitter.GetFontType(nameof(MessageFont)); } public Color FixedMessagesColor { get { return Color.FromArgb(Global.Config.MessagesColor); } } diff --git a/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs b/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs index 5f9d3d4832..c125b2286d 100644 --- a/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs +++ b/BizHawk.Client.EmuHawk/Extensions/ToolExtensions.cs @@ -105,8 +105,8 @@ namespace BizHawk.Client.EmuHawk.ToolExtensions //make a menuitem to let you explore to it var tsmiExplore = new ToolStripMenuItem { Text = "&Explore" }; - string explorePath = "\"" + hf.FullPathWithoutMember + "\""; - tsmiExplore.Click += (o, ev) => { System.Diagnostics.Process.Start("explorer.exe", "/select, " + explorePath); }; + string explorePath = $"\"{hf.FullPathWithoutMember}\""; + tsmiExplore.Click += (o, ev) => { System.Diagnostics.Process.Start("explorer.exe", $"/select, {explorePath}"); }; tsdd.Items.Add(tsmiExplore); var tsmiCopyFile = new ToolStripMenuItem { Text = "Copy &File" }; @@ -217,12 +217,12 @@ namespace BizHawk.Client.EmuHawk.ToolExtensions GlobalWin.Sound.StopSound(); if (recent.Frozen) { - var result = MessageBox.Show("Could not open " + path, "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error); + var result = MessageBox.Show($"Could not open {path}", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // ensure topmost, not to have to minimize everything to see and use our modal window, if it somehow got covered - var result = MessageBox.Show(new Form(){TopMost = true},"Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); + var result = MessageBox.Show(new Form(){TopMost = true}, $"Could not open {path}\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { if (encodedPath != null) diff --git a/BizHawk.Client.EmuHawk/GLManager.cs b/BizHawk.Client.EmuHawk/GLManager.cs index 6ea3476a18..f22433bc54 100644 --- a/BizHawk.Client.EmuHawk/GLManager.cs +++ b/BizHawk.Client.EmuHawk/GLManager.cs @@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk public static void CreateInstance(Bizware.BizwareGL.Drivers.OpenTK.IGL_TK mainContext) { - if (Instance != null) throw new InvalidOperationException("Attempt to create more than one GLManager"); + if (Instance != null) throw new InvalidOperationException($"Attempted to create more than one {nameof(GLManager)}"); Instance = new GLManager(); Instance.MainContext = mainContext; } diff --git a/BizHawk.Client.EmuHawk/GlobalWin.cs b/BizHawk.Client.EmuHawk/GlobalWin.cs index 5df3f651bf..06a2bbaab5 100644 --- a/BizHawk.Client.EmuHawk/GlobalWin.cs +++ b/BizHawk.Client.EmuHawk/GlobalWin.cs @@ -1,4 +1,5 @@ using BizHawk.Bizware.BizwareGL; +using BizHawk.Client.ApiHawk; // ReSharper disable StyleCop.SA1401 namespace BizHawk.Client.EmuHawk @@ -7,6 +8,7 @@ namespace BizHawk.Client.EmuHawk { public static MainForm MainForm; public static ToolManager Tools; + public static BasicApiProvider ApiProvider; /// /// the IGL to be used for rendering diff --git a/BizHawk.Client.EmuHawk/Input/GamePad.cs b/BizHawk.Client.EmuHawk/Input/GamePad.cs index 76cc1355cc..b3d373583a 100644 --- a/BizHawk.Client.EmuHawk/Input/GamePad.cs +++ b/BizHawk.Client.EmuHawk/Input/GamePad.cs @@ -220,19 +220,19 @@ namespace BizHawk.Client.EmuHawk for (int i = 0; i < state.GetButtons().Length; i++) { int j = i; - AddItem(string.Format("B{0}", i + 1), () => state.IsPressed(j)); + AddItem($"B{i + 1}", () => state.IsPressed(j)); } for (int i = 0; i < state.GetPointOfViewControllers().Length; i++) { int j = i; - AddItem(string.Format("POV{0}U", i + 1), + AddItem($"POV{i + 1}U", () => { int t = state.GetPointOfViewControllers()[j]; return (t >= 0 && t <= 4500) || (t >= 31500 && t < 36000); }); - AddItem(string.Format("POV{0}D", i + 1), + AddItem($"POV{i + 1}D", () => { int t = state.GetPointOfViewControllers()[j]; return t >= 13500 && t <= 22500; }); - AddItem(string.Format("POV{0}L", i + 1), + AddItem($"POV{i + 1}L", () => { int t = state.GetPointOfViewControllers()[j]; return t >= 22500 && t <= 31500; }); - AddItem(string.Format("POV{0}R", i + 1), + AddItem($"POV{i + 1}R", () => { int t = state.GetPointOfViewControllers()[j]; return t >= 4500 && t <= 13500; }); } } diff --git a/BizHawk.Client.EmuHawk/Input/IPCKeyInput.cs b/BizHawk.Client.EmuHawk/Input/IPCKeyInput.cs index 72d5c7866c..0b5a998f77 100644 --- a/BizHawk.Client.EmuHawk/Input/IPCKeyInput.cs +++ b/BizHawk.Client.EmuHawk/Input/IPCKeyInput.cs @@ -25,7 +25,7 @@ namespace BizHawk.Client.EmuHawk static void IPCThread() { - string pipeName = string.Format("bizhawk-pid-{0}-IPCKeyInput", System.Diagnostics.Process.GetCurrentProcess().Id); + string pipeName = $"bizhawk-pid-{System.Diagnostics.Process.GetCurrentProcess().Id}-IPCKeyInput"; for (; ; ) diff --git a/BizHawk.Client.EmuHawk/Input/Input.cs b/BizHawk.Client.EmuHawk/Input/Input.cs index a812d55017..519594fe34 100644 --- a/BizHawk.Client.EmuHawk/Input/Input.cs +++ b/BizHawk.Client.EmuHawk/Input/Input.cs @@ -2,11 +2,8 @@ using System.Linq; using System.Collections.Generic; using System.Threading; -#if WINDOWS + using SlimDX.DirectInput; -#else -using OpenTK.Input; -#endif using BizHawk.Common; using BizHawk.Client.Common; @@ -116,19 +113,17 @@ namespace BizHawk.Client.EmuHawk private Input() { -#if WINDOWS UpdateThread = new Thread(UpdateThreadProc) { IsBackground = true, Priority = ThreadPriority.AboveNormal //why not? this thread shouldn't be very heavy duty, and we want it to be responsive }; UpdateThread.Start(); -#endif } public static void Initialize() { - if (Global.RunningOnUnix) + if (PlatformLinkedLibSingleton.RunningOnUnix) { OTK_Keyboard.Initialize(); // OTK_Gamepad.Initialize(); @@ -145,10 +140,11 @@ namespace BizHawk.Client.EmuHawk public static void Cleanup() { -#if WINDOWS - KeyInput.Cleanup(); - GamePad.Cleanup(); -#endif + if (!PlatformLinkedLibSingleton.RunningOnUnix) + { + KeyInput.Cleanup(); + GamePad.Cleanup(); + } } public enum InputEventType @@ -202,7 +198,7 @@ namespace BizHawk.Client.EmuHawk public InputEventType EventType; public override string ToString() { - return string.Format("{0}:{1}", EventType.ToString(), LogicalButton.ToString()); + return $"{EventType.ToString()}:{LogicalButton.ToString()}"; } } @@ -238,7 +234,7 @@ namespace BizHawk.Client.EmuHawk if (UnpressState.ContainsKey(button)) { if (newState) return; - Console.WriteLine("Removing Unpress {0} with newState {1}", button, newState); + Console.WriteLine($"Removing Unpress {button} with {nameof(newState)} {newState}"); UnpressState.Remove(button); LastState[button] = false; return; @@ -331,14 +327,22 @@ namespace BizHawk.Client.EmuHawk return FloatValuesCopy; } -#if WINDOWS void UpdateThreadProc() { - for (; ; ) + while (true) { - var keyEvents = KeyInput.Update().Concat(IPCKeyInput.Update()); - GamePad.UpdateAll(); - GamePad360.UpdateAll(); + var keyEvents = PlatformLinkedLibSingleton.RunningOnUnix + ? OTK_Keyboard.Update() + : KeyInput.Update().Concat(IPCKeyInput.Update()); + if (PlatformLinkedLibSingleton.RunningOnUnix) + { + //TODO + } + else + { + GamePad.UpdateAll(); + GamePad360.UpdateAll(); + } //this block is going to massively modify data structures that the binding method uses, so we have to lock it all lock (this) @@ -356,7 +360,7 @@ namespace BizHawk.Client.EmuHawk //analyze xinput foreach (var pad in GamePad360.EnumerateDevices()) { - string xname = "X" + pad.PlayerNumber + " "; + string xname = $"X{pad.PlayerNumber} "; for (int b = 0; b < pad.NumButtons; b++) HandleButton(xname + pad.ButtonName(b), pad.Pressed(b)); foreach (var sv in pad.GetFloats()) @@ -372,7 +376,7 @@ namespace BizHawk.Client.EmuHawk //analyze joysticks foreach (var pad in GamePad.EnumerateDevices()) { - string jname = "J" + pad.PlayerNumber + " "; + string jname = $"J{pad.PlayerNumber} "; for (int b = 0; b < pad.NumButtons; b++) HandleButton(jname + pad.ButtonName(b), pad.Pressed(b)); foreach (var sv in pad.GetFloats()) @@ -441,7 +445,6 @@ namespace BizHawk.Client.EmuHawk Thread.Sleep(10); } } -#endif public void StartListeningForFloatEvents() { @@ -510,7 +513,7 @@ namespace BizHawk.Client.EmuHawk foreach (var kvp in LastState) if (kvp.Value) { - Console.WriteLine("Unpressing " + kvp.Key); + Console.WriteLine($"Unpressing {kvp.Key}"); UnpressState[kvp.Key] = true; } diff --git a/BizHawk.Client.EmuHawk/Input/OTK_Gamepad.cs b/BizHawk.Client.EmuHawk/Input/OTK_Gamepad.cs index e9b5fb575f..da73c5e2ac 100644 --- a/BizHawk.Client.EmuHawk/Input/OTK_Gamepad.cs +++ b/BizHawk.Client.EmuHawk/Input/OTK_Gamepad.cs @@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk JoystickState jss = Joystick.GetState(i); if (jss.IsConnected) { - Console.WriteLine(string.Format("joydevice index: {0}", i)); //OpenTK doesn't expose the GUID, even though it stores it internally... + Console.WriteLine($"joydevice index: {i}"); //OpenTK doesn't expose the GUID, even though it stores it internally... OTK_GamePad ogp = new OTK_GamePad(i); Devices.Add(ogp); @@ -77,7 +77,7 @@ namespace BizHawk.Client.EmuHawk return state; } - public string Name { get { return "Joystick " + _stickIdx; } } + public string Name { get { return $"Joystick {_stickIdx}"; } } public Guid Guid { get { return _guid; } } @@ -122,17 +122,17 @@ namespace BizHawk.Client.EmuHawk int jb = 1; for (int i = 0; i < 64; i++) { - AddItem(string.Format("B{0}", jb), () => state.GetButton(i)==ButtonState.Pressed); + AddItem($"B{jb}", () => state.GetButton(i)==ButtonState.Pressed); jb++; } jb = 1; foreach (JoystickHat enval in Enum.GetValues(typeof(JoystickHat))) { - AddItem(string.Format("POV{0}U", jb), () => state.GetHat(enval).IsUp); - AddItem(string.Format("POV{0}D", jb), () => state.GetHat(enval).IsDown); - AddItem(string.Format("POV{0}L", jb), () => state.GetHat(enval).IsLeft); - AddItem(string.Format("POV{0}R", jb), () => state.GetHat(enval).IsRight); + AddItem($"POV{jb}U", () => state.GetHat(enval).IsUp); + AddItem($"POV{jb}D", () => state.GetHat(enval).IsDown); + AddItem($"POV{jb}L", () => state.GetHat(enval).IsLeft); + AddItem($"POV{jb}R", () => state.GetHat(enval).IsRight); jb++; } } diff --git a/BizHawk.Client.EmuHawk/Input/OTK_Keyboard.cs b/BizHawk.Client.EmuHawk/Input/OTK_Keyboard.cs index 2c8faa7cbb..200c970e6b 100644 --- a/BizHawk.Client.EmuHawk/Input/OTK_Keyboard.cs +++ b/BizHawk.Client.EmuHawk/Input/OTK_Keyboard.cs @@ -6,18 +6,47 @@ namespace BizHawk.Client.EmuHawk { public static class OTK_Keyboard { - private static OpenTK.Input.KeyboardState _kbState; + private static readonly Dictionary KeyEnumMap = new Dictionary + { + // A-Z + {Key.A, SlimDX.DirectInput.Key.A}, {Key.B, SlimDX.DirectInput.Key.B}, {Key.C, SlimDX.DirectInput.Key.C}, {Key.D, SlimDX.DirectInput.Key.D}, {Key.E, SlimDX.DirectInput.Key.E}, {Key.F, SlimDX.DirectInput.Key.F}, {Key.G, SlimDX.DirectInput.Key.G}, {Key.H, SlimDX.DirectInput.Key.H}, {Key.I, SlimDX.DirectInput.Key.I}, {Key.J, SlimDX.DirectInput.Key.J}, {Key.K, SlimDX.DirectInput.Key.K}, {Key.L, SlimDX.DirectInput.Key.L}, {Key.M, SlimDX.DirectInput.Key.M}, {Key.N, SlimDX.DirectInput.Key.N}, {Key.O, SlimDX.DirectInput.Key.O}, {Key.P, SlimDX.DirectInput.Key.P}, {Key.Q, SlimDX.DirectInput.Key.Q}, {Key.R, SlimDX.DirectInput.Key.R}, {Key.S, SlimDX.DirectInput.Key.S}, {Key.T, SlimDX.DirectInput.Key.T}, {Key.U, SlimDX.DirectInput.Key.U}, {Key.V, SlimDX.DirectInput.Key.V}, {Key.W, SlimDX.DirectInput.Key.W}, {Key.X, SlimDX.DirectInput.Key.X}, {Key.Y, SlimDX.DirectInput.Key.Y}, {Key.Z, SlimDX.DirectInput.Key.Z}, + // 0-9 + {Key.Number1, SlimDX.DirectInput.Key.D1}, {Key.Number2, SlimDX.DirectInput.Key.D2}, {Key.Number3, SlimDX.DirectInput.Key.D3}, {Key.Number4, SlimDX.DirectInput.Key.D4}, {Key.Number5, SlimDX.DirectInput.Key.D5}, {Key.Number6, SlimDX.DirectInput.Key.D6}, {Key.Number7, SlimDX.DirectInput.Key.D7}, {Key.Number8, SlimDX.DirectInput.Key.D8}, {Key.Number9, SlimDX.DirectInput.Key.D9}, {Key.Number0, SlimDX.DirectInput.Key.D0}, + // misc. printables (ASCII order) + {Key.Space, SlimDX.DirectInput.Key.Space}, {Key.Quote, SlimDX.DirectInput.Key.Apostrophe}, {Key.Comma, SlimDX.DirectInput.Key.Comma}, {Key.Minus, SlimDX.DirectInput.Key.Minus}, {Key.Period, SlimDX.DirectInput.Key.Period}, {Key.Slash, SlimDX.DirectInput.Key.Slash}, {Key.Semicolon, SlimDX.DirectInput.Key.Semicolon}, {Key.Plus, SlimDX.DirectInput.Key.Equals}, {Key.BracketLeft, SlimDX.DirectInput.Key.LeftBracket}, {Key.BackSlash, SlimDX.DirectInput.Key.Backslash}, {Key.BracketRight, SlimDX.DirectInput.Key.RightBracket}, {Key.Tilde, SlimDX.DirectInput.Key.Grave}, + // misc. (alphabetically) + {Key.BackSpace, SlimDX.DirectInput.Key.Backspace}, {Key.CapsLock, SlimDX.DirectInput.Key.CapsLock}, {Key.Delete, SlimDX.DirectInput.Key.Delete}, {Key.Down, SlimDX.DirectInput.Key.DownArrow}, {Key.End, SlimDX.DirectInput.Key.End}, {Key.Enter, SlimDX.DirectInput.Key.Return}, {Key.Escape, SlimDX.DirectInput.Key.Escape}, {Key.Home, SlimDX.DirectInput.Key.Home}, {Key.Insert, SlimDX.DirectInput.Key.Insert}, {Key.Left, SlimDX.DirectInput.Key.LeftArrow}, {Key.PageDown, SlimDX.DirectInput.Key.PageDown}, {Key.PageUp, SlimDX.DirectInput.Key.PageUp}, {Key.Pause, SlimDX.DirectInput.Key.Pause}, {Key.Right, SlimDX.DirectInput.Key.RightArrow}, {Key.ScrollLock, SlimDX.DirectInput.Key.ScrollLock}, {Key.Tab, SlimDX.DirectInput.Key.Tab}, {Key.Up, SlimDX.DirectInput.Key.UpArrow}, + // modifier + {Key.WinLeft, SlimDX.DirectInput.Key.LeftWindowsKey}, {Key.WinRight, SlimDX.DirectInput.Key.RightWindowsKey}, {Key.ControlLeft, SlimDX.DirectInput.Key.LeftControl}, {Key.ControlRight, SlimDX.DirectInput.Key.RightControl}, {Key.AltLeft, SlimDX.DirectInput.Key.LeftAlt}, {Key.AltRight, SlimDX.DirectInput.Key.RightAlt}, {Key.ShiftLeft, SlimDX.DirectInput.Key.LeftShift}, {Key.ShiftRight, SlimDX.DirectInput.Key.RightShift}, + + // function + {Key.F1, SlimDX.DirectInput.Key.F1}, {Key.F2, SlimDX.DirectInput.Key.F2}, {Key.F3, SlimDX.DirectInput.Key.F3}, {Key.F4, SlimDX.DirectInput.Key.F4}, {Key.F5, SlimDX.DirectInput.Key.F5}, {Key.F6, SlimDX.DirectInput.Key.F6}, {Key.F7, SlimDX.DirectInput.Key.F7}, {Key.F8, SlimDX.DirectInput.Key.F8}, {Key.F9, SlimDX.DirectInput.Key.F9}, {Key.F10, SlimDX.DirectInput.Key.F10}, {Key.F11, SlimDX.DirectInput.Key.F11}, {Key.F12, SlimDX.DirectInput.Key.F12}, + // keypad (alphabetically) + {Key.Keypad0, SlimDX.DirectInput.Key.NumberPad0}, {Key.Keypad1, SlimDX.DirectInput.Key.NumberPad1}, {Key.Keypad2, SlimDX.DirectInput.Key.NumberPad2}, {Key.Keypad3, SlimDX.DirectInput.Key.NumberPad3}, {Key.Keypad4, SlimDX.DirectInput.Key.NumberPad4}, {Key.Keypad5, SlimDX.DirectInput.Key.NumberPad5}, {Key.Keypad6, SlimDX.DirectInput.Key.NumberPad6}, {Key.Keypad7, SlimDX.DirectInput.Key.NumberPad7}, {Key.Keypad8, SlimDX.DirectInput.Key.NumberPad8}, {Key.Keypad9, SlimDX.DirectInput.Key.NumberPad9}, {Key.KeypadAdd, SlimDX.DirectInput.Key.NumberPadPlus}, {Key.KeypadDecimal, SlimDX.DirectInput.Key.NumberPadPeriod}, {Key.KeypadDivide, SlimDX.DirectInput.Key.NumberPadSlash}, {Key.KeypadEnter, SlimDX.DirectInput.Key.NumberPadEnter}, {Key.KeypadMultiply, SlimDX.DirectInput.Key.NumberPadStar}, {Key.KeypadSubtract, SlimDX.DirectInput.Key.NumberPadMinus} + }; + + private static readonly List _eventList = new List(); + private static KeyboardState _kbState; public static void Initialize () { - _kbState = OpenTK.Input.Keyboard.GetState(); + _kbState = Keyboard.GetState(); } - public static void Update () + public static IEnumerable Update () { + _eventList.Clear(); + var lastState = _kbState; try { - _kbState = OpenTK.Input.Keyboard.GetState(); + _kbState = Keyboard.GetState(); + foreach (KeyValuePair entry in KeyEnumMap) + { + if (lastState.IsKeyUp(entry.Key) && _kbState.IsKeyDown(entry.Key)) + _eventList.Add(new KeyInput.KeyEvent { Key = entry.Value, Pressed = true }); + else if (lastState.IsKeyDown(entry.Key) && _kbState.IsKeyUp(entry.Key)) + _eventList.Add(new KeyInput.KeyEvent { Key = entry.Value, Pressed = false }); + } } catch { @@ -30,6 +59,7 @@ namespace BizHawk.Client.EmuHawk System.Console.WriteLine("OpenTK Keyboard thread is angry."); } } + return _eventList; } public static bool IsPressed (Key key) diff --git a/BizHawk.Client.EmuHawk/JumpLists.cs b/BizHawk.Client.EmuHawk/JumpLists.cs index db41963523..d36aabdb3f 100644 --- a/BizHawk.Client.EmuHawk/JumpLists.cs +++ b/BizHawk.Client.EmuHawk/JumpLists.cs @@ -49,7 +49,7 @@ namespace BizHawk.Client.EmuHawk dynamic ji = Activator.CreateInstance(JumpTask); ji.ApplicationPath = exepath; - ji.Arguments = '"' + fullpath + '"'; + ji.Arguments = $"\"{fullpath}\""; ji.Title = title; // for some reason, this doesn't work ji.WorkingDirectory = Path.GetDirectoryName(exepath); diff --git a/BizHawk.Client.EmuHawk/LogConsole.cs b/BizHawk.Client.EmuHawk/LogConsole.cs index eb50cf1d1c..2141dcbfae 100644 --- a/BizHawk.Client.EmuHawk/LogConsole.cs +++ b/BizHawk.Client.EmuHawk/LogConsole.cs @@ -118,7 +118,7 @@ namespace BizHawk.Client.EmuHawk } string remainder = cmdLine.Substring(childCmdLine); string path = cmdLine.Substring(lastSlash, lastGood - lastSlash); - return path + " " + remainder; + return $"{path} {remainder}"; } static IntPtr oldOut, conOut; @@ -164,7 +164,7 @@ namespace BizHawk.Client.EmuHawk hasConsole = true; } else - System.Windows.Forms.MessageBox.Show(string.Format("Couldn't allocate win32 console: {0}", Marshal.GetLastWin32Error())); + System.Windows.Forms.MessageBox.Show($"Couldn't allocate win32 console: {Marshal.GetLastWin32Error()}"); } if(hasConsole) @@ -179,7 +179,7 @@ namespace BizHawk.Client.EmuHawk conOut = Win32.CreateFile("CONOUT$", 0x40000000, 2, IntPtr.Zero, 3, 0, IntPtr.Zero); if (!Win32.SetStdHandle(-11, conOut)) - throw new Exception("SetStdHandle() failed"); + throw new Exception($"{nameof(Win32.SetStdHandle)}() failed"); } //DotNetRewireConout(); diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs index 746d1ebd37..930017ff83 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -199,6 +199,7 @@ this.GBGambatteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.GBGBHawkMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.GBInSGBMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.SubNESHawkMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem16 = new System.Windows.Forms.ToolStripSeparator(); this.allowGameDBCoreOverridesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); @@ -351,7 +352,11 @@ this.SaturnPreferencesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.DGBSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.DGBsettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.GenesisSubMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.DGBHawkSubMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.DGBHawksettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.GGLSubMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.GGLsettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.GenesisSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.vDPViewerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.GenesisGameGenieECDC = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator26 = new System.Windows.Forms.ToolStripSeparator(); @@ -503,7 +508,9 @@ this.N64SubMenu, this.SaturnSubMenu, this.DGBSubMenu, - this.GenesisSubMenu, + this.DGBHawkSubMenu, + this.GGLSubMenu, + this.GenesisSubMenu, this.wonderSwanToolStripMenuItem, this.AppleSubMenu, this.C64SubMenu, @@ -1842,6 +1849,7 @@ this.SGBCoreSubmenu, this.GBCoreSubmenu, this.GBInSGBMenuItem, + this.SubNESHawkMenuItem, this.toolStripMenuItem16, this.allowGameDBCoreOverridesToolStripMenuItem, this.toolStripSeparator8, @@ -1979,6 +1987,13 @@ this.GBInSGBMenuItem.Text = "GB in SGB"; this.GBInSGBMenuItem.Click += new System.EventHandler(this.GbInSgbMenuItem_Click); // + // SubNESHawkMenuItem + // + this.SubNESHawkMenuItem.Name = "SubNESHawkMenuItem"; + this.SubNESHawkMenuItem.Size = new System.Drawing.Size(239, 22); + this.SubNESHawkMenuItem.Text = "SubNESHawk"; + this.SubNESHawkMenuItem.Click += new System.EventHandler(this.SubNESHawkMenuItem_Click); + // // toolStripMenuItem16 // this.toolStripMenuItem16.Name = "toolStripMenuItem16"; @@ -3177,10 +3192,40 @@ this.DGBsettingsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.DGBsettingsToolStripMenuItem.Text = "Settings..."; this.DGBsettingsToolStripMenuItem.Click += new System.EventHandler(this.DgbSettingsMenuItem_Click); - // - // GenesisSubMenu - // - this.GenesisSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + // + // DGBHawkSubMenu + // + this.DGBHawkSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.DGBHawksettingsToolStripMenuItem}); + this.DGBHawkSubMenu.Name = "DGBHawkSubMenu"; + this.DGBHawkSubMenu.Size = new System.Drawing.Size(59, 19); + this.DGBHawkSubMenu.Text = "&GB Link"; + // + // DGBHawksettingsToolStripMenuItem + // + this.DGBHawksettingsToolStripMenuItem.Name = "DGBHawksettingsToolStripMenuItem"; + this.DGBHawksettingsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.DGBHawksettingsToolStripMenuItem.Text = "Settings..."; + this.DGBHawksettingsToolStripMenuItem.Click += new System.EventHandler(this.DgbHawkSettingsMenuItem_Click); + // + // GGLSubMenu + // + this.GGLSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.GGLsettingsToolStripMenuItem}); + this.GGLSubMenu.Name = "GGLSubMenu"; + this.GGLSubMenu.Size = new System.Drawing.Size(59, 19); + this.GGLSubMenu.Text = "&GG Link"; + // + // GGLsettingsToolStripMenuItem + // + this.GGLsettingsToolStripMenuItem.Name = "GGLsettingsToolStripMenuItem"; + this.GGLsettingsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.GGLsettingsToolStripMenuItem.Text = "Settings..."; + this.GGLsettingsToolStripMenuItem.Click += new System.EventHandler(this.GGLSettingsMenuItem_Click); + // + // GenesisSubMenu + // + this.GenesisSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.vDPViewerToolStripMenuItem, this.GenesisGameGenieECDC, this.toolStripSeparator26, @@ -3820,10 +3865,11 @@ this.LinkConnectStatusBarButton.Size = new System.Drawing.Size(16, 17); this.LinkConnectStatusBarButton.Text = "Link connection is currently enabled"; this.LinkConnectStatusBarButton.ToolTipText = "Link connection is currently enabled"; - // - // UpdateNotification - // - this.UpdateNotification.IsLink = true; + this.LinkConnectStatusBarButton.Click += new System.EventHandler(this.LinkConnectStatusBarButton_Click); + // + // UpdateNotification + // + this.UpdateNotification.IsLink = true; this.UpdateNotification.LinkColor = System.Drawing.Color.Red; this.UpdateNotification.Name = "UpdateNotification"; this.UpdateNotification.Size = new System.Drawing.Size(46, 17); @@ -4504,6 +4550,10 @@ private System.Windows.Forms.ToolStripMenuItem FdsEjectDiskMenuItem; private System.Windows.Forms.ToolStripMenuItem DGBSubMenu; private System.Windows.Forms.ToolStripMenuItem DGBsettingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem DGBHawkSubMenu; + private System.Windows.Forms.ToolStripMenuItem DGBHawksettingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem GGLSubMenu; + private System.Windows.Forms.ToolStripMenuItem GGLsettingsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem GenesisSubMenu; private System.Windows.Forms.ToolStripMenuItem GenesisSettingsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem AtariSettingsToolStripMenuItem; @@ -4512,6 +4562,7 @@ private System.Windows.Forms.ToolStripMenuItem MovieSettingsMenuItem; private System.Windows.Forms.ToolStripMenuItem CoresSubMenu; private System.Windows.Forms.ToolStripMenuItem GBInSGBMenuItem; + private System.Windows.Forms.ToolStripMenuItem SubNESHawkMenuItem; private System.Windows.Forms.ToolStripMenuItem batchRunnerToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem DisplayConfigMenuItem; private System.Windows.Forms.ToolStripMenuItem PCEtileViewerToolStripMenuItem; diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 314c2adaaa..65878e36e2 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -10,6 +10,7 @@ using BizHawk.Emulation.Cores.Atari.A7800Hawk; using BizHawk.Emulation.Cores.Calculators; using BizHawk.Emulation.Cores.ColecoVision; using BizHawk.Emulation.Cores.Nintendo.NES; +using BizHawk.Emulation.Cores.Nintendo.SubNESHawk; using BizHawk.Emulation.Cores.Nintendo.N64; using BizHawk.Emulation.Cores.Nintendo.SNES; using BizHawk.Emulation.Cores.Nintendo.SNES9X; @@ -442,12 +443,12 @@ namespace BizHawk.Client.EmuHawk private void SaveToCurrentSlotMenuItem_Click(object sender, EventArgs e) { - SaveQuickSave("QuickSave" + Global.Config.SaveSlot); + SaveQuickSave($"QuickSave{Global.Config.SaveSlot}"); } private void LoadCurrentSlotMenuItem_Click(object sender, EventArgs e) { - LoadQuickSave("QuickSave" + Global.Config.SaveSlot); + LoadQuickSave($"QuickSave{Global.Config.SaveSlot}"); } private void FlushSaveRAMMenuItem_Click(object sender, EventArgs e) @@ -682,7 +683,7 @@ namespace BizHawk.Client.EmuHawk private void ScreenshotAsMenuItem_Click(object sender, EventArgs e) { - var path = string.Format(PathManager.ScreenshotPrefix(Global.Game) + ".{0:yyyy-MM-dd HH.mm.ss}.png", DateTime.Now); + var path = $"{PathManager.ScreenshotPrefix(Global.Game)}.{DateTime.Now:yyyy-MM-dd HH.mm.ss}.png"; var sfd = new SaveFileDialog { @@ -1215,6 +1216,7 @@ namespace BizHawk.Client.EmuHawk private void CoresSubMenu_DropDownOpened(object sender, EventArgs e) { GBInSGBMenuItem.Checked = Global.Config.GB_AsSGB; + SubNESHawkMenuItem.Checked = Global.Config.UseSubNESHawk; allowGameDBCoreOverridesToolStripMenuItem.Checked = Global.Config.CoreForcingViaGameDB; } @@ -1308,6 +1310,16 @@ namespace BizHawk.Client.EmuHawk } } + private void SubNESHawkMenuItem_Click(object sender, EventArgs e) + { + Global.Config.UseSubNESHawk ^= true; + + if (!Emulator.IsNull()) + { + FlagNeedsReboot(); + } + } + private void AllowGameDBCoreOverridesToolStripMenuItem_Click(object sender, EventArgs e) { Global.Config.CoreForcingViaGameDB ^= true; @@ -1352,7 +1364,7 @@ namespace BizHawk.Client.EmuHawk Global.Config = ConfigService.Load(PathManager.DefaultIniPath); Global.Config.ResolveDefaults(); InitControls(); // rebind hotkeys - GlobalWin.OSD.AddMessage("Config file loaded: " + PathManager.DefaultIniPath); + GlobalWin.OSD.AddMessage($"Config file loaded: {PathManager.DefaultIniPath}"); } private void LoadConfigFromMenuItem_Click(object sender, EventArgs e) @@ -1371,7 +1383,7 @@ namespace BizHawk.Client.EmuHawk Global.Config = ConfigService.Load(ofd.FileName); Global.Config.ResolveDefaults(); InitControls(); // rebind hotkeys - GlobalWin.OSD.AddMessage("Config file loaded: " + ofd.FileName); + GlobalWin.OSD.AddMessage($"Config file loaded: {ofd.FileName}"); } } @@ -1386,6 +1398,7 @@ namespace BizHawk.Client.EmuHawk RamSearchMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["RAM Search"].Bindings; HexEditorMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Hex Editor"].Bindings; LuaConsoleMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Lua Console"].Bindings; + LuaConsoleMenuItem.Enabled = GlobalWin.Tools.IsAvailable(); CheatsMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Cheats"].Bindings; TAStudioMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["TAStudio"].Bindings; VirtualPadMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Virtual Pad"].Bindings; @@ -1588,10 +1601,10 @@ namespace BizHawk.Client.EmuHawk for (int i = 0; i < 16; i++) { - var str = "FDS Insert " + i; + var str = $"FDS Insert {i}"; if (Emulator.ControllerDefinition.BoolButtons.Contains(str)) { - FdsInsertDiskMenuAdd("Insert Disk " + i, str, "FDS Disk " + i + " inserted."); + FdsInsertDiskMenuAdd($"Insert Disk {i}", str, $"FDS Disk {i} inserted."); } } } @@ -1622,6 +1635,10 @@ namespace BizHawk.Client.EmuHawk { new NESGraphicsConfig().ShowDialog(this); } + else if (Emulator is SubNESHawk) + { + new NESGraphicsConfig().ShowDialog(this); + } else if (Emulator is QuickNES) { new QuickNesConfig().ShowDialog(this); @@ -1692,6 +1709,10 @@ namespace BizHawk.Client.EmuHawk { new NesControllerSettings().ShowDialog(); } + else if (Emulator is SubNESHawk) + { + new NesControllerSettings().ShowDialog(); + } else if (Emulator is QuickNES) { GenericCoreConfig.DoDialog(this, "QuickNES Controller Settings", true, false); @@ -2349,6 +2370,20 @@ namespace BizHawk.Client.EmuHawk DGBPrefs.DoDGBPrefsDialog(this); } + private void DgbHawkSettingsMenuItem_Click(object sender, EventArgs e) + { + GenericCoreConfig.DoDialog(this, "Gameboy Settings"); + } + + #endregion + + #region GGL + + private void GGLSettingsMenuItem_Click(object sender, EventArgs e) + { + GenericCoreConfig.DoDialog(this, "Game Gear Settings"); + } + #endregion #region GEN @@ -2405,8 +2440,8 @@ namespace BizHawk.Client.EmuHawk { var menuItem = new ToolStripMenuItem { - Name = "Disk" + (i + 1), - Text = "Disk" + (i + 1), + Name = $"Disk{i + 1}", + Text = $"Disk{i + 1}", Checked = appleII.CurrentDisk == i }; @@ -2444,8 +2479,8 @@ namespace BizHawk.Client.EmuHawk { var menuItem = new ToolStripMenuItem { - Name = "Disk" + (i + 1), - Text = "Disk" + (i + 1), + Name = $"Disk{i + 1}", + Text = $"Disk{i + 1}", Checked = c64.CurrentDisk == i }; @@ -2546,8 +2581,8 @@ namespace BizHawk.Client.EmuHawk var menuItem = new ToolStripMenuItem { - Name = i + "_" + name, - Text = i + ": " + name, + Name = $"{i}_{name}", + Text = $"{i}: {name}", Checked = currSel == i }; @@ -2581,8 +2616,8 @@ namespace BizHawk.Client.EmuHawk var menuItem = new ToolStripMenuItem { - Name = i + "_" + name, - Text = i + ": " + name, + Name = $"{i}_{name}", + Text = $"{i}: {name}", Checked = currSel == i }; @@ -2670,8 +2705,8 @@ namespace BizHawk.Client.EmuHawk var menuItem = new ToolStripMenuItem { - Name = i + "_" + name, - Text = i + ": " + name, + Name = $"{i}_{name}", + Text = $"{i}: {name}", Checked = currSel == i }; @@ -2705,8 +2740,8 @@ namespace BizHawk.Client.EmuHawk var menuItem = new ToolStripMenuItem { - Name = i + "_" + name, - Text = i + ": " + name, + Name = $"{i}_{name}", + Text = $"{i}: {name}", Checked = currSel == i }; @@ -2782,7 +2817,7 @@ namespace BizHawk.Client.EmuHawk showMenuVisible = true; // need to always be able to restore this as an emergency measure } - if (argParse._chromeless) + if (argParser._chromeless) { showMenuVisible = true; // I decided this was always possible in chromeless mode, we'll see what they think } @@ -2844,23 +2879,19 @@ namespace BizHawk.Client.EmuHawk } } - var file = new FileInfo( - PathManager.SaveStatePrefix(Global.Game) + - ".QuickSave" + - Global.Config.SaveSlot + - ".State.bak"); + var file = new FileInfo($"{PathManager.SaveStatePrefix(Global.Game)}.QuickSave{Global.Config.SaveSlot}.State.bak"); if (file.Exists) { UndoSavestateContextMenuItem.Enabled = true; if (_stateSlots.IsRedo(Global.Config.SaveSlot)) { - UndoSavestateContextMenuItem.Text = "Redo Save to slot " + Global.Config.SaveSlot; + UndoSavestateContextMenuItem.Text = $"Redo Save to slot {Global.Config.SaveSlot}"; UndoSavestateContextMenuItem.Image = Properties.Resources.redo; } else { - UndoSavestateContextMenuItem.Text = "Undo Save to slot " + Global.Config.SaveSlot; + UndoSavestateContextMenuItem.Text = $"Undo Save to slot {Global.Config.SaveSlot}"; UndoSavestateContextMenuItem.Image = Properties.Resources.undo; } } @@ -2990,13 +3021,9 @@ namespace BizHawk.Client.EmuHawk private void UndoSavestateContextMenuItem_Click(object sender, EventArgs e) { - _stateSlots.SwapBackupSavestate( - PathManager.SaveStatePrefix(Global.Game) + - ".QuickSave" + - Global.Config.SaveSlot + - ".State"); + _stateSlots.SwapBackupSavestate($"{PathManager.SaveStatePrefix(Global.Game)}.QuickSave{Global.Config.SaveSlot}.State"); - GlobalWin.OSD.AddMessage("Save slot " + Global.Config.SaveSlot + " restored."); + GlobalWin.OSD.AddMessage($"Save slot {Global.Config.SaveSlot} restored."); } private void ClearSramContextMenuItem_Click(object sender, EventArgs e) @@ -3043,12 +3070,12 @@ namespace BizHawk.Client.EmuHawk { if (_stateSlots.HasSlot(slot)) { - LoadQuickSave("QuickSave" + slot); + LoadQuickSave($"QuickSave{slot}"); } } else if (e.Button == MouseButtons.Right) { - SaveQuickSave("QuickSave" + slot); + SaveQuickSave($"QuickSave{slot}"); } } @@ -3089,11 +3116,21 @@ namespace BizHawk.Client.EmuHawk ProfileFirstBootLabel.Visible = false; } + private void LinkConnectStatusBarButton_Click(object sender, EventArgs e) + { + // toggle Link status (only outside of a movie session) + if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished) + { + Emulator.AsLinkable().LinkConnected ^= true; + Console.WriteLine("Cable connect status to {0}", Emulator.AsLinkable().LinkConnected); + } + } + private void UpdateNotification_Click(object sender, EventArgs e) { GlobalWin.Sound.StopSound(); DialogResult result = MessageBox.Show(this, - "Version " + Global.Config.Update_LatestVersion + " is now available. Would you like to open the BizHawk homepage?\r\n\r\nClick \"No\" to hide the update notification for this version.", + $"Version {Global.Config.Update_LatestVersion} is now available. Would you like to open the BizHawk homepage?\r\n\r\nClick \"No\" to hide the update notification for this version.", "New Version Available", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); GlobalWin.Sound.StartSound(); @@ -3228,7 +3265,7 @@ namespace BizHawk.Client.EmuHawk } catch (Exception ex) { - MessageBox.Show("Exception on drag and drop:\n" + ex); + MessageBox.Show($"Exception on drag and drop:\n{ex}"); } } diff --git a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs index bc3bb76302..28efe851c4 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs @@ -30,10 +30,10 @@ namespace BizHawk.Client.EmuHawk HardReset(); break; case "Quick Load": - LoadQuickSave("QuickSave" + Global.Config.SaveSlot); + LoadQuickSave($"QuickSave{Global.Config.SaveSlot}"); break; case "Quick Save": - SaveQuickSave("QuickSave" + Global.Config.SaveSlot); + SaveQuickSave($"QuickSave{Global.Config.SaveSlot}"); break; case "Clear Autohold": ClearAutohold(); @@ -126,7 +126,7 @@ namespace BizHawk.Client.EmuHawk break; case "Toggle Skip Lag Frame": Global.Config.SkipLagFrame ^= true; - GlobalWin.OSD.AddMessage("Skip Lag Frames toggled " + (Global.Config.SkipLagFrame ? "On" : "Off")); + GlobalWin.OSD.AddMessage($"Skip Lag Frames toggled {(Global.Config.SkipLagFrame ? "On" : "Off")}"); break; case "Toggle Key Priority": ToggleKeyPriority(); @@ -348,7 +348,7 @@ namespace BizHawk.Client.EmuHawk } Global.CheatList.ToList().ForEach(x => x.Toggle()); - GlobalWin.OSD.AddMessage("Cheats toggled" + type); + GlobalWin.OSD.AddMessage($"Cheats toggled{type}"); } break; @@ -642,7 +642,7 @@ namespace BizHawk.Client.EmuHawk var s = ((Gameboy)Emulator).GetSettings(); s.DisplayBG ^= true; ((Gameboy)Emulator).PutSettings(s); - GlobalWin.OSD.AddMessage("BG toggled " + (s.DisplayBG ? "on" : "off")); + GlobalWin.OSD.AddMessage($"BG toggled {(s.DisplayBG ? "on" : "off")}"); } break; @@ -652,7 +652,7 @@ namespace BizHawk.Client.EmuHawk var s = ((Gameboy)Emulator).GetSettings(); s.DisplayOBJ ^= true; ((Gameboy)Emulator).PutSettings(s); - GlobalWin.OSD.AddMessage("OBJ toggled " + (s.DisplayBG ? "on" : "off")); + GlobalWin.OSD.AddMessage($"OBJ toggled {(s.DisplayBG ? "on" : "off")}"); } break; diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 6f5348da71..523042f42a 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -24,6 +24,8 @@ using BizHawk.Emulation.Cores.Nintendo.GBA; using BizHawk.Emulation.Cores.Nintendo.NES; using BizHawk.Emulation.Cores.Nintendo.SNES; using BizHawk.Emulation.Cores.Nintendo.N64; +using BizHawk.Emulation.Cores.Nintendo.GBHawkLink; +using BizHawk.Emulation.Cores.Sega.GGHawkLink; using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Client.EmuHawk.ToolExtensions; @@ -154,7 +156,7 @@ namespace BizHawk.Client.EmuHawk } }; - argParse.ParseArguments(args); + argParser.ParseArguments(args); Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt")); @@ -270,14 +272,14 @@ namespace BizHawk.Client.EmuHawk Location = new Point(Global.Config.MainWndx, Global.Config.MainWndy); } - if (argParse.cmdRom != null) + if (argParser.cmdRom != null) { // Commandline should always override auto-load - var ioa = OpenAdvancedSerializer.ParseWithLegacy(argParse.cmdRom); - LoadRom(argParse.cmdRom, new LoadRomArgs { OpenAdvanced = ioa }); + var ioa = OpenAdvancedSerializer.ParseWithLegacy(argParser.cmdRom); + LoadRom(argParser.cmdRom, new LoadRomArgs { OpenAdvanced = ioa }); if (Global.Game == null) { - MessageBox.Show("Failed to load " + argParse.cmdRom + " specified on commandline"); + MessageBox.Show($"Failed to load {argParser.cmdRom} specified on commandline"); } } else if (Global.Config.RecentRoms.AutoLoad && !Global.Config.RecentRoms.Empty) @@ -285,7 +287,7 @@ namespace BizHawk.Client.EmuHawk LoadRomFromRecent(Global.Config.RecentRoms.MostRecent); } - if (argParse.cmdMovie != null) + if (argParser.cmdMovie != null) { _supressSyncSettingsWarning = true; // We dont' want to be nagged if we are attempting to automate if (Global.Game == null) @@ -296,21 +298,21 @@ namespace BizHawk.Client.EmuHawk // If user picked a game, then do the commandline logic if (!Global.Game.IsNullInstance) { - var movie = MovieService.Get(argParse.cmdMovie); + var movie = MovieService.Get(argParser.cmdMovie); Global.MovieSession.ReadOnly = true; // if user is dumping and didnt supply dump length, make it as long as the loaded movie - if (argParse._autoDumpLength == 0) + if (argParser._autoDumpLength == 0) { - argParse._autoDumpLength = movie.InputLogLength; + argParser._autoDumpLength = movie.InputLogLength; } // Copy pasta from drag & drop - if (MovieImport.IsValidMovieExtension(Path.GetExtension(argParse.cmdMovie))) + if (MovieImport.IsValidMovieExtension(Path.GetExtension(argParser.cmdMovie))) { string errorMsg; string warningMsg; - var imported = MovieImport.ImportFile(argParse.cmdMovie, out errorMsg, out warningMsg); + var imported = MovieImport.ImportFile(argParser.cmdMovie, out errorMsg, out warningMsg); if (!string.IsNullOrEmpty(errorMsg)) { MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -328,7 +330,7 @@ namespace BizHawk.Client.EmuHawk else { StartNewMovie(movie, false); - Global.Config.RecentMovies.Add(argParse.cmdMovie); + Global.Config.RecentMovies.Add(argParser.cmdMovie); } _supressSyncSettingsWarning = false; @@ -355,36 +357,36 @@ namespace BizHawk.Client.EmuHawk } } - if (argParse.startFullscreen || Global.Config.StartFullscreen) + if (argParser.startFullscreen || Global.Config.StartFullscreen) { _needsFullscreenOnLoad = true; } if (!Global.Game.IsNullInstance) { - if (argParse.cmdLoadState != null) + if (argParser.cmdLoadState != null) { - LoadState(argParse.cmdLoadState, Path.GetFileName(argParse.cmdLoadState)); + LoadState(argParser.cmdLoadState, Path.GetFileName(argParser.cmdLoadState)); } - else if (argParse.cmdLoadSlot != null) + else if (argParser.cmdLoadSlot != null) { - LoadQuickSave("QuickSave" + argParse.cmdLoadSlot); + LoadQuickSave($"QuickSave{argParser.cmdLoadSlot}"); } else if (Global.Config.AutoLoadLastSaveSlot) { - LoadQuickSave("QuickSave" + Global.Config.SaveSlot); + LoadQuickSave($"QuickSave{Global.Config.SaveSlot}"); } } //start Lua Console if requested in the command line arguments - if (argParse.luaConsole) + if (argParser.luaConsole) { GlobalWin.Tools.Load(); } //load Lua Script if requested in the command line arguments - if (argParse.luaScript != null) + if (argParser.luaScript != null) { - GlobalWin.Tools.LuaConsole.LoadLuaFile(argParse.luaScript); + GlobalWin.Tools.LuaConsole.LoadLuaFile(argParser.luaScript); } GlobalWin.Tools.AutoLoad(); @@ -407,9 +409,9 @@ namespace BizHawk.Client.EmuHawk } // start dumping, if appropriate - if (argParse.cmdDumpType != null && argParse.cmdDumpName != null) + if (argParser.cmdDumpType != null && argParser.cmdDumpName != null) { - RecordAv(argParse.cmdDumpType, argParse.cmdDumpName); + RecordAv(argParser.cmdDumpType, argParser.cmdDumpName); } SetMainformMovieInfo(); @@ -916,34 +918,22 @@ namespace BizHawk.Client.EmuHawk public void TakeScreenshot() { - string fmt = "{0}.{1:yyyy-MM-dd HH.mm.ss}{2}.png"; - string prefix = PathManager.ScreenshotPrefix(Global.Game); - var ts = DateTime.Now; + var basename = $"{PathManager.ScreenshotPrefix(Global.Game)}.{DateTime.Now:yyyy-MM-dd HH.mm.ss}"; - string fnameBare = string.Format(fmt, prefix, ts, ""); - string fname = string.Format(fmt, prefix, ts, " (0)"); + var fnameBare = $"{basename}.png"; + var fname = $"{basename} (0).png"; // if the (0) filename exists, do nothing. we'll bump up the number later // if the bare filename exists, move it to (0) // otherwise, no related filename exists, and we can proceed with the bare filename - if (File.Exists(fname)) + if (!File.Exists(fname)) { - } - else if (File.Exists(fnameBare)) - { - File.Move(fnameBare, fname); - } - else - { - fname = fnameBare; + if (File.Exists(fnameBare)) File.Move(fnameBare, fname); + else fname = fnameBare; } - int seq = 0; - while (File.Exists(fname)) - { - var sequence = $" ({seq++})"; - fname = string.Format(fmt, prefix, ts, sequence); - } + for (var seq = 0; File.Exists(fname); seq++) + fname = $"{basename} ({seq}).png"; TakeScreenshot(fname); } @@ -965,10 +955,10 @@ namespace BizHawk.Client.EmuHawk } /* - using (var fs = new FileStream(path + "_test.bmp", FileMode.OpenOrCreate, FileAccess.Write)) + using (var fs = new FileStream($"{path}_test.bmp", FileMode.OpenOrCreate, FileAccess.Write)) QuickBmpFile.Save(Emulator.VideoProvider(), fs, r.Next(50, 500), r.Next(50, 500)); */ - GlobalWin.OSD.AddMessage(fi.Name + " saved."); + GlobalWin.OSD.AddMessage($"{fi.Name} saved."); } public void FrameBufferResized() @@ -994,7 +984,7 @@ namespace BizHawk.Client.EmuHawk } } - Console.WriteLine("Selecting display size " + lastComputedSize); + Console.WriteLine($"Selecting display size {lastComputedSize}"); // Change size Size = new Size(lastComputedSize.Width + borderWidth, lastComputedSize.Height + borderHeight); @@ -1023,15 +1013,15 @@ namespace BizHawk.Client.EmuHawk { // TODO - maybe apply a hack tracked during fullscreen here to override it FormBorderStyle = FormBorderStyle.None; - MainMenuStrip.Visible = Global.Config.DispChrome_MenuFullscreen && !argParse._chromeless; - MainStatusBar.Visible = Global.Config.DispChrome_StatusBarFullscreen && !argParse._chromeless; + MainMenuStrip.Visible = Global.Config.DispChrome_MenuFullscreen && !argParser._chromeless; + MainStatusBar.Visible = Global.Config.DispChrome_StatusBarFullscreen && !argParser._chromeless; } else { - MainStatusBar.Visible = Global.Config.DispChrome_StatusBarWindowed && !argParse._chromeless; - MainMenuStrip.Visible = Global.Config.DispChrome_MenuWindowed && !argParse._chromeless; - MaximizeBox = MinimizeBox = Global.Config.DispChrome_CaptionWindowed && !argParse._chromeless; - if (Global.Config.DispChrome_FrameWindowed == 0 || argParse._chromeless) + MainStatusBar.Visible = Global.Config.DispChrome_StatusBarWindowed && !argParser._chromeless; + MainMenuStrip.Visible = Global.Config.DispChrome_MenuWindowed && !argParser._chromeless; + MaximizeBox = MinimizeBox = Global.Config.DispChrome_CaptionWindowed && !argParser._chromeless; + if (Global.Config.DispChrome_FrameWindowed == 0 || argParser._chromeless) { FormBorderStyle = FormBorderStyle.None; } @@ -1118,11 +1108,7 @@ namespace BizHawk.Client.EmuHawk private void OpenLuaConsole() { -#if WINDOWS GlobalWin.Tools.Load(); -#else - MessageBox.Show("Sorry, Lua is not supported on this platform.", "Lua not supported", MessageBoxButtons.OK, MessageBoxIcon.Error); -#endif } public void NotifyLogWindowClosing() @@ -1178,7 +1164,7 @@ namespace BizHawk.Client.EmuHawk public void FrameSkipMessage() { - GlobalWin.OSD.AddMessage("Frameskipping set to " + Global.Config.FrameSkip); + GlobalWin.OSD.AddMessage($"Frameskipping set to {Global.Config.FrameSkip}"); } public void UpdateCheatStatus() @@ -1255,7 +1241,7 @@ namespace BizHawk.Client.EmuHawk ((Snes9x)Emulator).PutSettings(s); } - GlobalWin.OSD.AddMessage($"BG {layer} Layer " + (result ? "On" : "Off")); + GlobalWin.OSD.AddMessage($"BG {layer} Layer {(result ? "On" : "Off")}"); } private void SNES_ToggleObj(int layer) @@ -1291,7 +1277,7 @@ namespace BizHawk.Client.EmuHawk } ((LibsnesCore)Emulator).PutSettings(s); - GlobalWin.OSD.AddMessage($"Obj {layer} Layer " + (result ? "On" : "Off")); + GlobalWin.OSD.AddMessage($"Obj {layer} Layer {(result ? "On" : "Off")}"); } else if (Emulator is Snes9x) { @@ -1313,7 +1299,7 @@ namespace BizHawk.Client.EmuHawk } ((Snes9x)Emulator).PutSettings(s); - GlobalWin.OSD.AddMessage($"Sprite {layer} Layer " + (result ? "On" : "Off")); + GlobalWin.OSD.AddMessage($"Sprite {layer} Layer {(result ? "On" : "Off")}"); } } @@ -1401,7 +1387,7 @@ namespace BizHawk.Client.EmuHawk private int _lastOpenRomFilter; - private ArgParser argParse = new ArgParser(); + private ArgParser argParser = new ArgParser(); // Resources private Bitmap _statusBarDiskLightOnImage; private Bitmap _statusBarDiskLightOffImage; @@ -1431,7 +1417,7 @@ namespace BizHawk.Client.EmuHawk } } - private void SetWindowText() + public void SetWindowText() { string str = ""; @@ -1450,7 +1436,7 @@ namespace BizHawk.Client.EmuHawk if (!string.IsNullOrEmpty(VersionInfo.CustomBuildString)) { - str += VersionInfo.CustomBuildString + " "; + str += $"{VersionInfo.CustomBuildString} "; } str += Emulator.IsNull() ? "BizHawk" : Global.SystemInfo.DisplayName; @@ -1462,15 +1448,15 @@ namespace BizHawk.Client.EmuHawk if (!Emulator.IsNull()) { - str += " - " + Global.Game.Name; + str += $" - {Global.Game.Name}"; if (Global.MovieSession.Movie.IsActive) { - str += " - " + Path.GetFileName(Global.MovieSession.Movie.Filename); + str += $" - {Path.GetFileName(Global.MovieSession.Movie.Filename)}"; } } - if (!Global.Config.DispChrome_CaptionWindowed || argParse._chromeless) + if (!Global.Config.DispChrome_CaptionWindowed || argParser._chromeless) { str = ""; } @@ -1637,9 +1623,9 @@ namespace BizHawk.Client.EmuHawk path = PathManager.SaveRamPath(Global.Game); } var file = new FileInfo(path); - var newPath = path + ".new"; + var newPath = $"{path}.new"; var newFile = new FileInfo(newPath); - var backupPath = path + ".bak"; + var backupPath = $"{path}.bak"; var backupFile = new FileInfo(backupPath); if (file.Directory != null && !file.Directory.Exists) { @@ -1649,7 +1635,7 @@ namespace BizHawk.Client.EmuHawk } catch { - GlobalWin.OSD.AddMessage("Unable to flush SaveRAM to: " + newFile.Directory); + GlobalWin.OSD.AddMessage($"Unable to flush SaveRAM to: {newFile.Directory}"); return false; } } @@ -1724,6 +1710,8 @@ namespace BizHawk.Client.EmuHawk N64SubMenu.Visible = false; SaturnSubMenu.Visible = false; DGBSubMenu.Visible = false; + DGBHawkSubMenu.Visible = false; + GGLSubMenu.Visible = false; GenesisSubMenu.Visible = false; wonderSwanToolStripMenuItem.Visible = false; AppleSubMenu.Visible = false; @@ -1806,7 +1794,14 @@ namespace BizHawk.Client.EmuHawk SaturnSubMenu.Visible = true; break; case "DGB": - DGBSubMenu.Visible = true; + if (Emulator is GBHawkLink) + { + DGBHawkSubMenu.Visible = true; + } + else + { + DGBSubMenu.Visible = true; + } break; case "WSWAN": wonderSwanToolStripMenuItem.Visible = true; @@ -1840,6 +1835,9 @@ namespace BizHawk.Client.EmuHawk case "AmstradCPC": amstradCPCToolStripMenuItem.Visible = true; break; + case "GGL": + GGLSubMenu.Visible = true; + break; } } @@ -1899,13 +1897,13 @@ namespace BizHawk.Client.EmuHawk { PauseStatusButton.Image = Properties.Resources.Lightning; PauseStatusButton.Visible = true; - PauseStatusButton.ToolTipText = "Emulator is turbo seeking to frame " + PauseOnFrame.Value + " click to stop seek"; + PauseStatusButton.ToolTipText = $"Emulator is turbo seeking to frame {PauseOnFrame.Value} click to stop seek"; } else if (PauseOnFrame.HasValue) { PauseStatusButton.Image = Properties.Resources.YellowRight; PauseStatusButton.Visible = true; - PauseStatusButton.ToolTipText = "Emulator is playing to frame " + PauseOnFrame.Value + " click to stop seek"; + PauseStatusButton.ToolTipText = $"Emulator is playing to frame {PauseOnFrame.Value} click to stop seek"; } else if (EmulatorPaused) { @@ -1957,14 +1955,14 @@ namespace BizHawk.Client.EmuHawk { Global.Config.SpeedPercentAlternate = value; SyncThrottle(); - GlobalWin.OSD.AddMessage("Alternate Speed: " + value + "%"); + GlobalWin.OSD.AddMessage($"Alternate Speed: {value}%"); } private void SetSpeedPercent(int value) { Global.Config.SpeedPercent = value; SyncThrottle(); - GlobalWin.OSD.AddMessage("Speed: " + value + "%"); + GlobalWin.OSD.AddMessage($"Speed: {value}%"); } private void Shutdown() @@ -2318,7 +2316,7 @@ namespace BizHawk.Client.EmuHawk Global.Config.SoundVolume = 100; } - GlobalWin.OSD.AddMessage("Volume " + Global.Config.SoundVolume); + GlobalWin.OSD.AddMessage($"Volume {Global.Config.SoundVolume}"); } private static void VolumeDown() @@ -2329,7 +2327,7 @@ namespace BizHawk.Client.EmuHawk Global.Config.SoundVolume = 0; } - GlobalWin.OSD.AddMessage("Volume " + Global.Config.SoundVolume); + GlobalWin.OSD.AddMessage($"Volume {Global.Config.SoundVolume}"); } private void SoftReset() @@ -2428,7 +2426,7 @@ namespace BizHawk.Client.EmuHawk return; } - GlobalWin.OSD.AddMessage("Screensize set to " + Global.Config.TargetZoomFactors[Emulator.SystemId] + "x"); + GlobalWin.OSD.AddMessage($"Screensize set to {Global.Config.TargetZoomFactors[Emulator.SystemId]}x"); FrameBufferResized(); } @@ -2455,7 +2453,7 @@ namespace BizHawk.Client.EmuHawk return; } - GlobalWin.OSD.AddMessage("Screensize set to " + Global.Config.TargetZoomFactors[Emulator.SystemId] + "x"); + GlobalWin.OSD.AddMessage($"Screensize set to {Global.Config.TargetZoomFactors[Emulator.SystemId]}x"); FrameBufferResized(); } @@ -2614,7 +2612,7 @@ namespace BizHawk.Client.EmuHawk if (Global.MovieSession.Movie.IsActive) { Global.MovieSession.Movie.Save(); - GlobalWin.OSD.AddMessage(Global.MovieSession.Movie.Filename + " saved."); + GlobalWin.OSD.AddMessage($"{Global.MovieSession.Movie.Filename} saved."); } } @@ -2653,6 +2651,8 @@ namespace BizHawk.Client.EmuHawk LinkConnectStatusBarButton.Image = Emulator.AsLinkable().LinkConnected ? _linkCableOn : _linkCableOff; + + LinkConnectStatusBarButton.ToolTipText = $"Link connection is currently {(Emulator.AsLinkable().LinkConnected ? "enabled" : "disabled")}"; } else { @@ -2687,21 +2687,18 @@ namespace BizHawk.Client.EmuHawk private static void ToggleModePokeMode() { Global.Config.MoviePlaybackPokeMode ^= true; - GlobalWin.OSD.AddMessage(Global.Config.MoviePlaybackPokeMode ? "Movie Poke mode enabled" : "Movie Poke mode disabled"); + GlobalWin.OSD.AddMessage($"Movie Poke mode {(Global.Config.MoviePlaybackPokeMode ? "enabled" : "disabled")}"); } private static void ToggleBackgroundInput() { Global.Config.AcceptBackgroundInput ^= true; - GlobalWin.OSD.AddMessage(Global.Config.AcceptBackgroundInput - ? "Background Input enabled" - : "Background Input disabled"); + GlobalWin.OSD.AddMessage($"Background Input {(Global.Config.AcceptBackgroundInput ? "enabled" : "disabled")}"); } private static void VsyncMessage() { - GlobalWin.OSD.AddMessage( - "Display Vsync set to " + (Global.Config.VSync ? "on" : "off")); + GlobalWin.OSD.AddMessage($"Display Vsync set to {(Global.Config.VSync ? "on" : "off")}"); } private static bool StateErrorAskUser(string title, string message) @@ -2945,10 +2942,6 @@ namespace BizHawk.Client.EmuHawk GlobalWin.Tools.UpdateToolsBefore(); } - _framesSinceLastFpsUpdate++; - - UpdateFpsDisplay(currentTimestamp, isRewinding, isFastForwarding); - CaptureRewind(isRewinding); // Set volume, if enabled @@ -2992,7 +2985,7 @@ namespace BizHawk.Client.EmuHawk } bool render = !_throttle.skipNextFrame || (_currAviWriter?.UsesVideo ?? false); - Emulator.FrameAdvance(Global.ControllerOutput, render, renderSound); + bool new_frame = Emulator.FrameAdvance(Global.ControllerOutput, render, renderSound); Global.MovieSession.HandleMovieAfterFrameLoop(); @@ -3031,11 +3024,18 @@ namespace BizHawk.Client.EmuHawk UpdateToolsAfter(SuppressLua); } - if (!PauseAvi) + if (!PauseAvi && new_frame) { AvFrameAdvance(); } + if (new_frame) + { + _framesSinceLastFpsUpdate++; + + UpdateFpsDisplay(currentTimestamp, isRewinding, isFastForwarding); + } + if (GlobalWin.Tools.IsLoaded() && GlobalWin.Tools.TAStudio.LastPositionFrame == Emulator.Frame) { @@ -3055,11 +3055,11 @@ namespace BizHawk.Client.EmuHawk if (IsSeeking && Emulator.Frame == PauseOnFrame.Value) { PauseEmulator(); - PauseOnFrame = null; if (GlobalWin.Tools.IsLoaded()) { GlobalWin.Tools.TAStudio.StopSeeking(); } + PauseOnFrame = null; } } @@ -3259,7 +3259,7 @@ namespace BizHawk.Client.EmuHawk var sfd = new SaveFileDialog(); if (Global.Game != null) { - sfd.FileName = PathManager.FilesystemSafeName(Global.Game) + "." + ext; // dont use Path.ChangeExtension, it might wreck game names with dots in them + sfd.FileName = $"{PathManager.FilesystemSafeName(Global.Game)}.{ext}"; // dont use Path.ChangeExtension, it might wreck game names with dots in them sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.AvPathFragment, null); } else @@ -3368,9 +3368,9 @@ namespace BizHawk.Client.EmuHawk try { // is this the best time to handle this? or deeper inside? - if (argParse._currAviWriterFrameList != null) + if (argParser._currAviWriterFrameList != null) { - if (!argParse._currAviWriterFrameList.Contains(Emulator.Frame)) + if (!argParser._currAviWriterFrameList.Contains(Emulator.Frame)) { goto HANDLE_AUTODUMP; } @@ -3448,18 +3448,18 @@ namespace BizHawk.Client.EmuHawk } catch (Exception e) { - MessageBox.Show("Video dumping died:\n\n" + e); + MessageBox.Show($"Video dumping died:\n\n{e}"); AbortAv(); } HANDLE_AUTODUMP: - if (argParse._autoDumpLength > 0) + if (argParser._autoDumpLength > 0) { - argParse._autoDumpLength--; - if (argParse._autoDumpLength == 0) // finish + argParser._autoDumpLength--; + if (argParser._autoDumpLength == 0) // finish { StopAv(); - if (argParse._autoCloseOnDump) + if (argParser._autoCloseOnDump) { _exitRequestPending = true; } @@ -3514,7 +3514,7 @@ namespace BizHawk.Client.EmuHawk string title = "load error"; if (e.AttemptedCoreLoad != null) { - title = e.AttemptedCoreLoad + " load error"; + title = $"{e.AttemptedCoreLoad} load error"; } MessageBox.Show(this, e.Message, title, MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -3584,30 +3584,12 @@ namespace BizHawk.Client.EmuHawk } try - { - bool deterministic; - - if (args.Deterministic == null) - { - // force deterministic in this case - // this is usually null for most cores - // previously this was getting set to false if a movie was not queued for recording - surely that can't be good.. - deterministic = true; - } - else - { - // a value was actually supplied somehow - use this - deterministic = args.Deterministic.Value; - } - - if (Global.MovieSession.QueuedMovie != null) - { - // movies should require deterministic emulation in ALL cases - // if the core is managing its own DE through SyncSettings a 'deterministic' bool should be passed into the core's constructor - // it is then up to the core itself to override its own local DeterministicEmulation setting - deterministic = true; - } - + { + // movies should require deterministic emulation in ALL cases + // if the core is managing its own DE through SyncSettings a 'deterministic' bool can be passed into the core's constructor + // it is then up to the core itself to override its own local DeterministicEmulation setting + bool deterministic = args.Deterministic ?? Global.MovieSession.QueuedMovie != null; + if (!GlobalWin.Tools.AskSave()) { return false; @@ -3683,7 +3665,7 @@ namespace BizHawk.Client.EmuHawk if (result) { - string loaderName = "*" + OpenAdvancedSerializer.Serialize(ioa); + string loaderName = $"*{OpenAdvancedSerializer.Serialize(ioa)}"; Emulator = loader.LoadedEmulator; Global.Game = loader.Game; CoreFileProvider.SyncCoreCommInputSignals(nextComm); @@ -3715,8 +3697,8 @@ namespace BizHawk.Client.EmuHawk else { xSw.WriteLine(xmlGame.Assets[xg].Key); - xSw.WriteLine("SHA1:" + xmlGame.Assets[xg].Value.HashSHA1()); - xSw.WriteLine("MD5:" + xmlGame.Assets[xg].Value.HashMD5()); + xSw.WriteLine($"SHA1:{xmlGame.Assets[xg].Value.HashSHA1()}"); + xSw.WriteLine($"MD5:{xmlGame.Assets[xg].Value.HashMD5()}"); xSw.WriteLine(); } } @@ -3793,6 +3775,7 @@ namespace BizHawk.Client.EmuHawk } } + ApiManager.Restart(Emulator.ServiceProvider); GlobalWin.Tools.Restart(); if (Global.Config.LoadCheatFileByGame) @@ -3829,7 +3812,7 @@ namespace BizHawk.Client.EmuHawk ToolFormBase.UpdateCheatRelatedTools(null, null); if (Global.Config.AutoLoadLastSaveSlot && _stateSlots.HasSlot(Global.Config.SaveSlot)) { - LoadQuickSave("QuickSave" + Global.Config.SaveSlot); + LoadQuickSave($"QuickSave{Global.Config.SaveSlot}"); } if (Global.FirmwareManager.RecentlyServed.Count > 0) @@ -3841,7 +3824,7 @@ namespace BizHawk.Client.EmuHawk } } - ClientApi.OnRomLoaded(); + ClientApi.OnRomLoaded(Emulator); return true; } else @@ -3852,10 +3835,11 @@ namespace BizHawk.Client.EmuHawk // The ROM has been loaded by a recursive invocation of the LoadROM method. if (!(Emulator is NullEmulator)) { - ClientApi.OnRomLoaded(); + ClientApi.OnRomLoaded(Emulator); return true; } + ClientApi.UpdateEmulatorAndVP(Emulator); HandlePlatformMenus(); _stateSlots.Clear(); UpdateStatusSlots(); @@ -3945,6 +3929,7 @@ namespace BizHawk.Client.EmuHawk var coreComm = CreateCoreComm(); CoreFileProvider.SyncCoreCommInputSignals(coreComm); Emulator = new NullEmulator(coreComm, Global.Config.GetCoreSettings()); + ClientApi.UpdateEmulatorAndVP(Emulator); Global.ActiveController = new Controller(NullController.Instance.Definition); Global.AutoFireController = _autofireNullControls; RewireSound(); @@ -3967,8 +3952,9 @@ namespace BizHawk.Client.EmuHawk Global.Game = GameInfo.NullInstance; GlobalWin.Tools.Restart(); + ApiManager.Restart(Emulator.ServiceProvider); RewireSound(); - Text = "BizHawk" + (VersionInfo.DeveloperBuild ? " (interim) " : ""); + Text = $"BizHawk{(VersionInfo.DeveloperBuild ? " (interim) " : "")}"; HandlePlatformMenus(); _stateSlots.Clear(); UpdateDumpIcon(); @@ -3996,7 +3982,7 @@ namespace BizHawk.Client.EmuHawk public void EnableRewind(bool enabled) { Global.Rewinder.SuspendRewind = !enabled; - GlobalWin.OSD.AddMessage("Rewind " + (enabled ? "enabled" : "suspended")); + GlobalWin.OSD.AddMessage($"Rewind {(enabled ? "enabled" : "suspended")}"); } public void ClearRewindData() @@ -4076,7 +4062,7 @@ namespace BizHawk.Client.EmuHawk if (!supressOSD) { - GlobalWin.OSD.AddMessage("Loaded state: " + userFriendlyStateName); + GlobalWin.OSD.AddMessage($"Loaded state: {userFriendlyStateName}"); } } else @@ -4107,10 +4093,10 @@ namespace BizHawk.Client.EmuHawk return; } - var path = PathManager.SaveStatePrefix(Global.Game) + "." + quickSlotName + ".State"; + var path = $"{PathManager.SaveStatePrefix(Global.Game)}.{quickSlotName}.State"; if (!File.Exists(path)) { - GlobalWin.OSD.AddMessage("Unable to load " + quickSlotName + ".State"); + GlobalWin.OSD.AddMessage($"Unable to load {quickSlotName}.State"); return; } @@ -4137,11 +4123,11 @@ namespace BizHawk.Client.EmuHawk ClientApi.OnStateSaved(this, userFriendlyStateName); - GlobalWin.OSD.AddMessage("Saved state: " + userFriendlyStateName); + GlobalWin.OSD.AddMessage($"Saved state: {userFriendlyStateName}"); } catch (IOException) { - GlobalWin.OSD.AddMessage("Unable to save state " + path); + GlobalWin.OSD.AddMessage($"Unable to save state {path}"); } if (!fromLua) @@ -4171,7 +4157,7 @@ namespace BizHawk.Client.EmuHawk return; } - var path = PathManager.SaveStatePrefix(Global.Game) + "." + quickSlotName + ".State"; + var path = $"{PathManager.SaveStatePrefix(Global.Game)}.{quickSlotName}.State"; var file = new FileInfo(path); if (file.Directory != null && !file.Directory.Exists) @@ -4182,7 +4168,7 @@ namespace BizHawk.Client.EmuHawk // Make backup first if (Global.Config.BackupSavestates) { - Util.TryMoveBackupFile(path, path + ".bak"); + Util.TryMoveBackupFile(path, $"{path}.bak"); } SaveState(path, quickSlotName, false); @@ -4227,7 +4213,7 @@ namespace BizHawk.Client.EmuHawk DefaultExt = "State", Filter = "Save States (*.State)|*.State|All Files|*.*", InitialDirectory = path, - FileName = PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave0.State" + FileName = $"{PathManager.SaveStatePrefix(Global.Game)}.QuickSave0.State" }; var result = sfd.ShowHawkDialog(); diff --git a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs index 8e164865d1..8eff5a7e6e 100644 --- a/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs +++ b/BizHawk.Client.EmuHawk/OpenAdvancedChooser.cs @@ -89,11 +89,11 @@ namespace BizHawk.Client.EmuHawk //print descriptive information var descr = retro.Description; CurrentDescription = descr; - Console.WriteLine("core name: {0} version {1}", descr.LibraryName, descr.LibraryVersion); - Console.WriteLine("extensions: ", descr.ValidExtensions); - Console.WriteLine("NeedsRomAsPath: {0}", descr.NeedsRomAsPath); - Console.WriteLine("AcceptsArchives: {0}", descr.NeedsArchives); - Console.WriteLine("SupportsNoGame: {0}", descr.SupportsNoGame); + Console.WriteLine($"core name: {descr.LibraryName} version {descr.LibraryVersion}"); + Console.WriteLine($"extensions: {descr.ValidExtensions}"); + Console.WriteLine($"{nameof(descr.NeedsRomAsPath)}: {descr.NeedsRomAsPath}"); + Console.WriteLine($"{nameof(descr.NeedsArchives)}: {descr.NeedsArchives}"); + Console.WriteLine($"{nameof(descr.SupportsNoGame)}: {descr.SupportsNoGame}"); foreach (var v in descr.Variables.Values) Console.WriteLine(v); @@ -103,7 +103,7 @@ namespace BizHawk.Client.EmuHawk { if (!bootstrap) { - MessageBox.Show("Couldn't load the selected Libretro core for analysis. It won't be available.\n\nError:\n\n" + ex.ToString()); + MessageBox.Show($"Couldn't load the selected Libretro core for analysis. It won't be available.\n\nError:\n\n{ex}"); } } } diff --git a/BizHawk.Client.EmuHawk/PlatformChooser.cs b/BizHawk.Client.EmuHawk/PlatformChooser.cs index da68589504..806071c570 100644 --- a/BizHawk.Client.EmuHawk/PlatformChooser.cs +++ b/BizHawk.Client.EmuHawk/PlatformChooser.cs @@ -37,11 +37,11 @@ namespace BizHawk.Client.EmuHawk { if (RomGame.RomData.Length > 10 * 1024 * 1024) // If 10mb, show in megabytes { - RomSizeLabel.Text = string.Format("{0:n0}", (RomGame.RomData.Length / 1024 / 1024)) + "mb"; + RomSizeLabel.Text = $"{RomGame.RomData.Length / 1024 / 1024:n0}mb"; } else { - RomSizeLabel.Text = string.Format("{0:n0}", (RomGame.RomData.Length / 1024)) + "kb"; + RomSizeLabel.Text = $"{RomGame.RomData.Length / 1024:n0}kb"; } ExtensionLabel.Text = RomGame.Extension.ToLower(); diff --git a/BizHawk.Client.EmuHawk/Program.cs b/BizHawk.Client.EmuHawk/Program.cs index 051f48faeb..02189ec31d 100644 --- a/BizHawk.Client.EmuHawk/Program.cs +++ b/BizHawk.Client.EmuHawk/Program.cs @@ -17,26 +17,25 @@ namespace BizHawk.Client.EmuHawk { static class Program { - static bool RunningOnUnix = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX; - static Program() { //this needs to be done before the warnings/errors show up Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - PlatformSpecificLinkedLibs libLoader = RunningOnUnix ? (PlatformSpecificLinkedLibs) new UnixMono() : (PlatformSpecificLinkedLibs) new Win32(); + var libLoader = EXE_PROJECT.PlatformLinkedLibSingleton.LinkedLibManager; //http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips //try loading libraries we know we'll need //something in the winforms, etc. code below will cause .net to popup a missing msvcr100.dll in case that one's missing //but oddly it lets us proceed and we'll then catch it here - var d3dx9 = libLoader.LoadPlatformSpecific("d3dx9_43.dll"); - var vc2015 = libLoader.LoadPlatformSpecific("vcruntime140.dll"); - var vc2012 = libLoader.LoadPlatformSpecific("msvcr120.dll"); //TODO - check version? - var vc2010 = libLoader.LoadPlatformSpecific("msvcr100.dll"); //TODO - check version? - var vc2010p = libLoader.LoadPlatformSpecific("msvcp100.dll"); + var libExt = EXE_PROJECT.PlatformLinkedLibSingleton.RunningOnUnix ? ".dll.so" : ".dll"; + var d3dx9 = libLoader.LoadPlatformSpecific($"d3dx9_43{libExt}"); + var vc2015 = libLoader.LoadPlatformSpecific($"vcruntime140{libExt}"); + var vc2012 = libLoader.LoadPlatformSpecific($"msvcr120{libExt}"); //TODO - check version? + var vc2010 = libLoader.LoadPlatformSpecific($"msvcr100{libExt}"); //TODO - check version? + var vc2010p = libLoader.LoadPlatformSpecific($"msvcp100{libExt}"); bool fail = false, warn = false; warn |= d3dx9 == IntPtr.Zero; fail |= vc2015 == IntPtr.Zero; @@ -66,7 +65,7 @@ namespace BizHawk.Client.EmuHawk libLoader.FreePlatformSpecific(vc2010); libLoader.FreePlatformSpecific(vc2010p); - if (!RunningOnUnix) + if (!EXE_PROJECT.PlatformLinkedLibSingleton.RunningOnUnix) { // this will look in subdirectory "dll" to load pinvoked stuff string dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); @@ -90,63 +89,6 @@ namespace BizHawk.Client.EmuHawk return SubMain(args); } - private interface PlatformSpecificLinkedLibs - { - IntPtr LoadPlatformSpecific(string dllToLoad); - IntPtr GetProcAddr(IntPtr hModule, string procName); - void FreePlatformSpecific(IntPtr hModule); - } - private class Win32 : PlatformSpecificLinkedLibs - { - [DllImport("kernel32.dll")] - private static extern IntPtr LoadLibrary(string dllToLoad); - [DllImport("kernel32.dll")] - private static extern IntPtr GetProcAddress(IntPtr hModule, string procName); - [DllImport("kernel32.dll")] - private static extern void FreeLibrary(IntPtr hModule); - public IntPtr LoadPlatformSpecific(string dllToLoad) - { - return LoadLibrary(dllToLoad); - } - public IntPtr GetProcAddr(IntPtr hModule, string procName) - { - return GetProcAddress(hModule, procName); - } - public void FreePlatformSpecific(IntPtr hModule) - { - FreeLibrary(hModule); - } - } - private class UnixMono : PlatformSpecificLinkedLibs - { - // This class is copied from a tutorial, so don't git blame and then email me expecting insight. - const int RTLD_NOW = 2; - [DllImport("libdl.so")] - private static extern IntPtr dlopen(String fileName, int flags); - [DllImport("libdl.so")] - private static extern IntPtr dlerror(); - [DllImport("libdl.so")] - private static extern IntPtr dlsym(IntPtr handle, String symbol); - [DllImport("libdl.so")] - private static extern int dlclose(IntPtr handle); - public IntPtr LoadPlatformSpecific(string dllToLoad) - { - return dlopen(dllToLoad + ".so", RTLD_NOW); - } - public IntPtr GetProcAddr(IntPtr hModule, string procName) - { - dlerror(); - var res = dlsym(hModule, procName); - var errPtr = dlerror(); - if (errPtr != IntPtr.Zero) throw new Exception("dlsym: " + Marshal.PtrToStringAnsi(errPtr)); - return res; - } - public void FreePlatformSpecific(IntPtr hModule) - { - dlclose(hModule); - } - } - private interface PlatformSpecificMainLoopCrashHandler { void TryCatchFinally(string[] args); @@ -183,7 +125,7 @@ namespace BizHawk.Client.EmuHawk { var result = MessageBox.Show( "EmuHawk has thrown a fatal exception and is about to close.\nA movie has been detected. Would you like to try to save?\n(Note: Depending on what caused this error, this may or may not succeed)", - "Fatal error: " + e.GetType().Name, + $"Fatal error: {e.GetType().Name}", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation ); @@ -231,7 +173,7 @@ namespace BizHawk.Client.EmuHawk { var result = MessageBox.Show( "EmuHawk has thrown a fatal exception and is about to close.\nA movie has been detected. Would you like to try to save?\n(Note: Depending on what caused this error, this may or may not succeed)", - "Fatal error: " + e.GetType().Name, + $"Fatal error: {e.GetType().Name}", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation ); @@ -258,7 +200,7 @@ namespace BizHawk.Client.EmuHawk } } } - private static PlatformSpecificMainLoopCrashHandler mainLoopCrashHandler = RunningOnUnix + private static PlatformSpecificMainLoopCrashHandler mainLoopCrashHandler = EXE_PROJECT.PlatformLinkedLibSingleton.RunningOnUnix ? (PlatformSpecificMainLoopCrashHandler) new UnixMonoMainLoopCrashHandler() : (PlatformSpecificMainLoopCrashHandler) new Win32MainLoopCrashHandler(); @@ -284,19 +226,20 @@ namespace BizHawk.Client.EmuHawk BizHawk.Common.TempFileManager.Start(); - HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler(); - string iniPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini"); + ArgParser argParser = new ArgParser(); + argParser.ParseArguments(args); + if (argParser.cmdConfigFile != null) PathManager.SetDefaultIniPath(argParser.cmdConfigFile); try { - Global.Config = ConfigService.Load(iniPath); + Global.Config = ConfigService.Load(PathManager.DefaultIniPath); } catch (Exception e) { new ExceptionBox(e).ShowDialog(); new ExceptionBox("Since your config file is corrupted, we're going to recreate it. Back it up before proceeding if you want to investigate further.").ShowDialog(); - File.Delete(iniPath); - Global.Config = ConfigService.Load(iniPath); + File.Delete(PathManager.DefaultIniPath); + Global.Config = ConfigService.Load(PathManager.DefaultIniPath); } Global.Config.ResolveDefaults(); @@ -322,7 +265,7 @@ namespace BizHawk.Client.EmuHawk GlobalWin.GLManager = GLManager.Instance; //now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen - if (RunningOnUnix) Global.Config.DispMethod = Config.EDispMethod.GdiPlus; + if (EXE_PROJECT.PlatformLinkedLibSingleton.RunningOnUnix) Global.Config.DispMethod = Config.EDispMethod.GdiPlus; REDO_DISPMETHOD: if (Global.Config.DispMethod == Config.EDispMethod.GdiPlus) GlobalWin.GL = new Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus(); @@ -370,7 +313,7 @@ namespace BizHawk.Client.EmuHawk goto REDO_DISPMETHOD; } - if (!RunningOnUnix) + if (!EXE_PROJECT.PlatformLinkedLibSingleton.RunningOnUnix) { //WHY do we have to do this? some intel graphics drivers (ig7icd64.dll 10.18.10.3304 on an unknown chip on win8.1) are calling SetDllDirectory() for the process, which ruins stuff. //The relevant initialization happened just before in "create IGL context". @@ -407,7 +350,7 @@ namespace BizHawk.Client.EmuHawk public static void RemoveMOTW(string path) { - DeleteFileW(path + ":Zone.Identifier"); + DeleteFileW($"{path}:Zone.Identifier"); } static void WhackAllMOTW(string dllDir) @@ -467,7 +410,7 @@ namespace BizHawk.Client.EmuHawk return asm; //load missing assemblies by trying to find them in the dll directory - string dllname = new AssemblyName(requested).Name + ".dll"; + string dllname = $"{new AssemblyName(requested).Name}.dll"; string directory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); string simpleName = new AssemblyName(requested).Name; if (simpleName == "NLua" || simpleName == "KopiLua") directory = Path.Combine(directory, "nlua"); diff --git a/BizHawk.Client.EmuHawk/ScreenSaver.cs b/BizHawk.Client.EmuHawk/ScreenSaver.cs index 70aedf1540..d362b4b2c2 100644 --- a/BizHawk.Client.EmuHawk/ScreenSaver.cs +++ b/BizHawk.Client.EmuHawk/ScreenSaver.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using BizHawk.Client.Common; +using BizHawk.Common; namespace BizHawk.Client.EmuHawk { @@ -40,7 +41,7 @@ namespace BizHawk.Client.EmuHawk //TODO implement } } - private static PlatformSpecificScreenBlankInterface screenBlankInterface = Global.RunningOnUnix + private static PlatformSpecificScreenBlankInterface screenBlankInterface = PlatformLinkedLibSingleton.RunningOnUnix ? (PlatformSpecificScreenBlankInterface) new MiscUnixScreenBlankInterface() : (PlatformSpecificScreenBlankInterface) new WinScreenBlankInterface(); diff --git a/BizHawk.Client.EmuHawk/Sound/Sound.cs b/BizHawk.Client.EmuHawk/Sound/Sound.cs index 93abdb7f40..1edaaae699 100644 --- a/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -4,6 +4,7 @@ using System.Threading; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Client.Common; +using BizHawk.Common; namespace BizHawk.Client.EmuHawk { @@ -26,7 +27,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL) _outputDevice = new OpenALSoundOutput(this); - if (!Global.RunningOnUnix) + if (!PlatformLinkedLibSingleton.RunningOnUnix) { if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound) _outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle); diff --git a/BizHawk.Client.EmuHawk/Sound/Utilities/SoundOutputProvider.cs b/BizHawk.Client.EmuHawk/Sound/Utilities/SoundOutputProvider.cs index 1caa777d46..575bb9c3da 100644 --- a/BizHawk.Client.EmuHawk/Sound/Utilities/SoundOutputProvider.cs +++ b/BizHawk.Client.EmuHawk/Sound/Utilities/SoundOutputProvider.cs @@ -167,7 +167,7 @@ namespace BizHawk.Client.EmuHawk if (extraSampleCount < -maxSamplesDeficit) { int generateSampleCount = -extraSampleCount; - if (LogDebug) Console.WriteLine("Generating " + generateSampleCount + " samples"); + if (LogDebug) Console.WriteLine($"Generating {generateSampleCount} samples"); for (int i = 0; i < generateSampleCount * ChannelCount; i++) { _buffer.Enqueue(0); @@ -177,7 +177,7 @@ namespace BizHawk.Client.EmuHawk else if (extraSampleCount > maxSamplesSurplus) { int discardSampleCount = extraSampleCount; - if (LogDebug) Console.WriteLine("Discarding " + discardSampleCount + " samples"); + if (LogDebug) Console.WriteLine($"Discarding {discardSampleCount} samples"); for (int i = 0; i < discardSampleCount * ChannelCount; i++) { _buffer.Dequeue(); diff --git a/BizHawk.Client.EmuHawk/Throttle.cs b/BizHawk.Client.EmuHawk/Throttle.cs index 3ae65cdc70..af7334ef81 100644 --- a/BizHawk.Client.EmuHawk/Throttle.cs +++ b/BizHawk.Client.EmuHawk/Throttle.cs @@ -4,6 +4,7 @@ using System.Runtime.InteropServices; using System.Threading; using BizHawk.Client.Common; +using BizHawk.Common; //this throttle is nitsuja's fine-tuned techniques from desmume @@ -34,7 +35,7 @@ namespace BizHawk.Client.EmuHawk //notably, if we're frame-advancing, we should be paused. if (signal_paused && !signal_continuousFrameAdvancing) { - //Console.WriteLine("THE THING: {0} {1}", signal_paused ,signal_continuousFrameAdvancing); + //Console.WriteLine($"THE THING: {signal_paused} {signal_continuousFrameAdvancing}"); skipNextFrame = false; framesSkipped = 0; framesToSkip = 0; @@ -159,7 +160,7 @@ namespace BizHawk.Client.EmuHawk return timeBeginPeriod(ms); } } - static PlatformSpecificSysTimer sysTimer = Global.RunningOnUnix ? (PlatformSpecificSysTimer) new UnixMonoSysTimer() : (PlatformSpecificSysTimer) new WinSysTimer(); + static PlatformSpecificSysTimer sysTimer = PlatformLinkedLibSingleton.RunningOnUnix ? (PlatformSpecificSysTimer) new UnixMonoSysTimer() : (PlatformSpecificSysTimer) new WinSysTimer(); static uint TimeBeginPeriod(uint ms) { return sysTimer.TimeBeginPeriod(ms); @@ -197,12 +198,12 @@ namespace BizHawk.Client.EmuHawk int pct = -1; public void SetSpeedPercent(int percent) { - //Console.WriteLine("throttle set percent " + percent); + //Console.WriteLine($"throttle set percent {percent}"); if (pct == percent) return; pct = percent; float fraction = percent / 100.0f; desiredfps = (ulong)(core_desiredfps * fraction); - //Console.WriteLine("throttle set desiredfps " + desiredfps); + //Console.WriteLine($"throttle set desiredfps {desiredfps}"); desiredspf = 65536.0f / desiredfps; AutoFrameSkip_IgnorePreviousDelay(); } diff --git a/BizHawk.Client.EmuHawk/UpdateChecker.cs b/BizHawk.Client.EmuHawk/UpdateChecker.cs index 2b114ee4b8..1b62043c61 100644 --- a/BizHawk.Client.EmuHawk/UpdateChecker.cs +++ b/BizHawk.Client.EmuHawk/UpdateChecker.cs @@ -107,8 +107,8 @@ namespace BizHawk.Client.EmuHawk private static string GetTextFromTag(string info, string tagName) { - string openTag = "[" + tagName + "]"; - string closeTag = "[/" + tagName + "]"; + string openTag = $"[{tagName}]"; + string closeTag = $"[/{tagName}]"; int start = info.IndexOf(openTag, StringComparison.OrdinalIgnoreCase); if (start == -1) return null; start += openTag.Length; diff --git a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs index ba99cd60c5..8175e472ad 100644 --- a/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs +++ b/BizHawk.Client.EmuHawk/config/AmstradCPC/AmstradCPCPokeMemory.cs @@ -10,8 +10,6 @@ namespace BizHawk.Client.EmuHawk { public partial class AmstradCPCPokeMemory : Form { - private AmstradCPC.AmstradCPCSettings _settings; - public AmstradCPCPokeMemory() { InitializeComponent(); diff --git a/BizHawk.Client.EmuHawk/config/ControllerConfig.cs b/BizHawk.Client.EmuHawk/config/ControllerConfig.cs index 4b54d570be..af5da08b62 100644 --- a/BizHawk.Client.EmuHawk/config/ControllerConfig.cs +++ b/BizHawk.Client.EmuHawk/config/ControllerConfig.cs @@ -24,6 +24,8 @@ namespace BizHawk.Client.EmuHawk ControllerImages.Add("SNES Controller", Properties.Resources.SNES_Controller); ControllerImages.Add("Nintento 64 Controller", Properties.Resources.N64); ControllerImages.Add("Gameboy Controller", Properties.Resources.GBController); + ControllerImages.Add("Gameboy Controller H", Properties.Resources.GBController); + ControllerImages.Add("Gameboy Controller + Tilt", Properties.Resources.GBController); ControllerImages.Add("GBA Controller", Properties.Resources.GBA_Controller); ControllerImages.Add("Dual Gameboy Controller", Properties.Resources.GBController); @@ -124,7 +126,7 @@ namespace BizHawk.Client.EmuHawk int i; for (i = MaxPlayers; i > 0; i--) { - if (button.StartsWith("P" + i)) + if (button.StartsWith($"P{i}")) { break; } @@ -160,7 +162,7 @@ namespace BizHawk.Client.EmuHawk { if (buckets[i].Count > 0) { - string tabname = Global.Emulator.SystemId == "WSWAN" ? i == 1 ? "Normal" : "Rotated" : "Player " + i; // hack + string tabname = Global.Emulator.SystemId != "WSWAN" ? $"Player {i}" : i == 1 ? "Normal" : "Rotated"; // hack tt.TabPages.Add(tabname); tt.TabPages[pageidx].Controls.Add(createpanel(settings, buckets[i], tt.Size)); pageidx++; @@ -360,7 +362,7 @@ namespace BizHawk.Client.EmuHawk private void NewControllerConfig_Load(object sender, EventArgs e) { - Text = _theDefinition.Name + " Configuration"; + Text = $"{_theDefinition.Name} Configuration"; } private static TabControl GetTabControl(IEnumerable controls) diff --git a/BizHawk.Client.EmuHawk/config/ControllerConfig/AnalogBindControl.cs b/BizHawk.Client.EmuHawk/config/ControllerConfig/AnalogBindControl.cs index 19de6e3bb8..3ee0acca96 100644 --- a/BizHawk.Client.EmuHawk/config/ControllerConfig/AnalogBindControl.cs +++ b/BizHawk.Client.EmuHawk/config/ControllerConfig/AnalogBindControl.cs @@ -66,13 +66,13 @@ namespace BizHawk.Client.EmuHawk private void TrackBarSensitivity_ValueChanged(object sender, EventArgs e) { _bind.Mult = trackBarSensitivity.Value / 10.0f; - labelSensitivity.Text = $"Sensitivity: {(Bind.Mult * 100)}" + "%"; + labelSensitivity.Text = $"Sensitivity: {Bind.Mult * 100}%"; } private void TrackBarDeadzone_ValueChanged(object sender, EventArgs e) { _bind.Deadzone = trackBarDeadzone.Value / 20.0f; - labelDeadzone.Text = $"Deadzone: {(Bind.Deadzone * 100)}" + "%"; + labelDeadzone.Text = $"Deadzone: {Bind.Deadzone * 100}%"; } private void ButtonFlip_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs index 4e22222325..8d6155f93d 100644 --- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs @@ -37,6 +37,7 @@ this.lblUserFilterName = new System.Windows.Forms.Label(); this.btnSelectUserFilter = new System.Windows.Forms.Button(); this.rbUser = new System.Windows.Forms.RadioButton(); + this.tbScanlineIntensity = new BizHawk.Client.EmuHawk.TransparentTrackBar(); this.rbNone = new System.Windows.Forms.RadioButton(); this.rbScanlines = new System.Windows.Forms.RadioButton(); this.rbHq2x = new System.Windows.Forms.RadioButton(); @@ -64,6 +65,16 @@ this.label5 = new System.Windows.Forms.Label(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tpAR = new System.Windows.Forms.TabPage(); + this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.label16 = new System.Windows.Forms.Label(); + this.label15 = new System.Windows.Forms.Label(); + this.txtCropBottom = new System.Windows.Forms.TextBox(); + this.label17 = new System.Windows.Forms.Label(); + this.txtCropRight = new System.Windows.Forms.TextBox(); + this.txtCropTop = new System.Windows.Forms.TextBox(); + this.label14 = new System.Windows.Forms.Label(); + this.txtCropLeft = new System.Windows.Forms.TextBox(); + this.btnDefaults = new System.Windows.Forms.Button(); this.cbAutoPrescale = new System.Windows.Forms.CheckBox(); this.label11 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); @@ -95,17 +106,17 @@ this.cbStatusBarWindowed = new System.Windows.Forms.CheckBox(); this.label9 = new System.Windows.Forms.Label(); this.cbMenuWindowed = new System.Windows.Forms.CheckBox(); + this.trackbarFrameSizeWindowed = new BizHawk.Client.EmuHawk.TransparentTrackBar(); this.cbCaptionWindowed = new System.Windows.Forms.CheckBox(); this.linkLabel1 = new System.Windows.Forms.LinkLabel(); - this.tbScanlineIntensity = new BizHawk.Client.EmuHawk.TransparentTrackBar(); - this.trackbarFrameSizeWindowed = new BizHawk.Client.EmuHawk.TransparentTrackBar(); - this.btnDefaults = new System.Windows.Forms.Button(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).BeginInit(); this.grpFinalFilter.SuspendLayout(); this.grpARSelection.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tpAR.SuspendLayout(); + this.groupBox6.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudPrescale)).BeginInit(); this.tpDispMethod.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -114,7 +125,6 @@ this.tabPage1.SuspendLayout(); this.groupBox4.SuspendLayout(); this.groupBox2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.trackbarFrameSizeWindowed)).BeginInit(); this.SuspendLayout(); // @@ -196,6 +206,19 @@ this.rbUser.Text = "User"; this.rbUser.UseVisualStyleBackColor = true; // + // tbScanlineIntensity + // + this.tbScanlineIntensity.LargeChange = 32; + this.tbScanlineIntensity.Location = new System.Drawing.Point(83, 55); + this.tbScanlineIntensity.Maximum = 256; + this.tbScanlineIntensity.Name = "tbScanlineIntensity"; + this.tbScanlineIntensity.Size = new System.Drawing.Size(70, 42); + this.tbScanlineIntensity.TabIndex = 3; + this.tbScanlineIntensity.TickFrequency = 32; + this.tbScanlineIntensity.TickStyle = System.Windows.Forms.TickStyle.TopLeft; + this.tbScanlineIntensity.Scroll += new System.EventHandler(this.tbScanlineIntensity_Scroll); + this.tbScanlineIntensity.ValueChanged += new System.EventHandler(this.tbScanlineIntensity_Scroll); + // // rbNone // this.rbNone.AutoSize = true; @@ -474,6 +497,7 @@ // // tpAR // + this.tpAR.Controls.Add(this.groupBox6); this.tpAR.Controls.Add(this.btnDefaults); this.tpAR.Controls.Add(this.cbAutoPrescale); this.tpAR.Controls.Add(this.label11); @@ -492,6 +516,102 @@ this.tpAR.Text = "Scaling & Filtering"; this.tpAR.UseVisualStyleBackColor = true; // + // groupBox6 + // + this.groupBox6.Controls.Add(this.label16); + this.groupBox6.Controls.Add(this.label15); + this.groupBox6.Controls.Add(this.txtCropBottom); + this.groupBox6.Controls.Add(this.label17); + this.groupBox6.Controls.Add(this.txtCropRight); + this.groupBox6.Controls.Add(this.txtCropTop); + this.groupBox6.Controls.Add(this.label14); + this.groupBox6.Controls.Add(this.txtCropLeft); + this.groupBox6.Location = new System.Drawing.Point(218, 195); + this.groupBox6.Name = "groupBox6"; + this.groupBox6.Size = new System.Drawing.Size(302, 61); + this.groupBox6.TabIndex = 9; + this.groupBox6.TabStop = false; + this.groupBox6.Text = "Cropping"; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(217, 25); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(43, 13); + this.label16.TabIndex = 30; + this.label16.Text = "Bottom:"; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(74, 25); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(29, 13); + this.label15.TabIndex = 29; + this.label15.Text = "Top:"; + // + // txtCropBottom + // + this.txtCropBottom.Location = new System.Drawing.Point(261, 22); + this.txtCropBottom.Name = "txtCropBottom"; + this.txtCropBottom.Size = new System.Drawing.Size(34, 20); + this.txtCropBottom.TabIndex = 28; + this.txtCropBottom.Text = "8000"; + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Location = new System.Drawing.Point(144, 25); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(35, 13); + this.label17.TabIndex = 26; + this.label17.Text = "Right:"; + // + // txtCropRight + // + this.txtCropRight.Location = new System.Drawing.Point(180, 22); + this.txtCropRight.Name = "txtCropRight"; + this.txtCropRight.Size = new System.Drawing.Size(34, 20); + this.txtCropRight.TabIndex = 25; + this.txtCropRight.Text = "8000"; + // + // txtCropTop + // + this.txtCropTop.Location = new System.Drawing.Point(104, 22); + this.txtCropTop.Name = "txtCropTop"; + this.txtCropTop.Size = new System.Drawing.Size(34, 20); + this.txtCropTop.TabIndex = 24; + this.txtCropTop.Text = "8000"; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(6, 25); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(28, 13); + this.label14.TabIndex = 16; + this.label14.Text = "Left:"; + // + // txtCropLeft + // + this.txtCropLeft.Location = new System.Drawing.Point(34, 22); + this.txtCropLeft.Name = "txtCropLeft"; + this.txtCropLeft.Size = new System.Drawing.Size(34, 20); + this.txtCropLeft.TabIndex = 15; + this.txtCropLeft.Text = "8000"; + // + // btnDefaults + // + this.btnDefaults.Location = new System.Drawing.Point(447, 262); + this.btnDefaults.Name = "btnDefaults"; + this.btnDefaults.Size = new System.Drawing.Size(75, 23); + this.btnDefaults.TabIndex = 18; + this.btnDefaults.Text = "Defaults"; + this.toolTip1.SetToolTip(this.btnDefaults, "Unless I forgot to update the button\'s code when I changed a default"); + this.btnDefaults.UseVisualStyleBackColor = true; + this.btnDefaults.Click += new System.EventHandler(this.btnDefaults_Click); + // // cbAutoPrescale // this.cbAutoPrescale.AutoSize = true; @@ -602,8 +722,7 @@ this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(359, 27); this.label8.TabIndex = 20; - this.label8.Text = " • Best compatibility\r\n • May have trouble with OpenGL-based cores (N64)\r\n" + - ""; + this.label8.Text = " • Best compatibility\r\n • May have trouble with OpenGL-based cores (N64)\r\n"; // // rbD3D9 // @@ -835,6 +954,17 @@ this.cbMenuWindowed.Text = "Menu"; this.cbMenuWindowed.UseVisualStyleBackColor = true; // + // trackbarFrameSizeWindowed + // + this.trackbarFrameSizeWindowed.LargeChange = 1; + this.trackbarFrameSizeWindowed.Location = new System.Drawing.Point(6, 33); + this.trackbarFrameSizeWindowed.Maximum = 2; + this.trackbarFrameSizeWindowed.Name = "trackbarFrameSizeWindowed"; + this.trackbarFrameSizeWindowed.Size = new System.Drawing.Size(99, 42); + this.trackbarFrameSizeWindowed.TabIndex = 21; + this.trackbarFrameSizeWindowed.Value = 1; + this.trackbarFrameSizeWindowed.ValueChanged += new System.EventHandler(this.trackbarFrameSizeWindowed_ValueChanged); + // // cbCaptionWindowed // this.cbCaptionWindowed.AutoSize = true; @@ -856,41 +986,6 @@ this.linkLabel1.Text = "Documentation"; this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); // - // tbScanlineIntensity - // - this.tbScanlineIntensity.LargeChange = 32; - this.tbScanlineIntensity.Location = new System.Drawing.Point(83, 55); - this.tbScanlineIntensity.Maximum = 256; - this.tbScanlineIntensity.Name = "tbScanlineIntensity"; - this.tbScanlineIntensity.Size = new System.Drawing.Size(70, 42); - this.tbScanlineIntensity.TabIndex = 3; - this.tbScanlineIntensity.TickFrequency = 32; - this.tbScanlineIntensity.TickStyle = System.Windows.Forms.TickStyle.TopLeft; - this.tbScanlineIntensity.Scroll += new System.EventHandler(this.tbScanlineIntensity_Scroll); - this.tbScanlineIntensity.ValueChanged += new System.EventHandler(this.tbScanlineIntensity_Scroll); - // - // trackbarFrameSizeWindowed - // - this.trackbarFrameSizeWindowed.LargeChange = 1; - this.trackbarFrameSizeWindowed.Location = new System.Drawing.Point(6, 33); - this.trackbarFrameSizeWindowed.Maximum = 2; - this.trackbarFrameSizeWindowed.Name = "trackbarFrameSizeWindowed"; - this.trackbarFrameSizeWindowed.Size = new System.Drawing.Size(99, 42); - this.trackbarFrameSizeWindowed.TabIndex = 21; - this.trackbarFrameSizeWindowed.Value = 1; - this.trackbarFrameSizeWindowed.ValueChanged += new System.EventHandler(this.trackbarFrameSizeWindowed_ValueChanged); - // - // btnDefaults - // - this.btnDefaults.Location = new System.Drawing.Point(447, 262); - this.btnDefaults.Name = "btnDefaults"; - this.btnDefaults.Size = new System.Drawing.Size(75, 23); - this.btnDefaults.TabIndex = 18; - this.btnDefaults.Text = "Defaults"; - this.toolTip1.SetToolTip(this.btnDefaults, "Unless I forgot to update the button\'s code when I changed a default"); - this.btnDefaults.UseVisualStyleBackColor = true; - this.btnDefaults.Click += new System.EventHandler(this.btnDefaults_Click); - // // DisplayConfigLite // this.AcceptButton = this.btnOk; @@ -908,6 +1003,7 @@ this.Text = "Display Configuration"; this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).EndInit(); this.grpFinalFilter.ResumeLayout(false); this.grpFinalFilter.PerformLayout(); this.grpARSelection.ResumeLayout(false); @@ -915,6 +1011,8 @@ this.tabControl1.ResumeLayout(false); this.tpAR.ResumeLayout(false); this.tpAR.PerformLayout(); + this.groupBox6.ResumeLayout(false); + this.groupBox6.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudPrescale)).EndInit(); this.tpDispMethod.ResumeLayout(false); this.groupBox3.ResumeLayout(false); @@ -929,7 +1027,6 @@ this.groupBox4.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.trackbarFrameSizeWindowed)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -1009,5 +1106,14 @@ private System.Windows.Forms.CheckBox cbFullscreenHacks; private System.Windows.Forms.Button btnDefaults; private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.GroupBox groupBox6; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.TextBox txtCropBottom; + private System.Windows.Forms.Label label17; + private System.Windows.Forms.TextBox txtCropRight; + private System.Windows.Forms.TextBox txtCropTop; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.TextBox txtCropLeft; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs index 1c5179f74f..a094247ef3 100644 --- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs +++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs @@ -85,6 +85,11 @@ namespace BizHawk.Client.EmuHawk if (Global.Config.DispCustomUserARY != -1) txtCustomARY.Text = Global.Config.DispCustomUserARY.ToString(); + txtCropLeft.Text = Global.Config.DispCropLeft.ToString(); + txtCropTop.Text = Global.Config.DispCropTop.ToString(); + txtCropRight.Text = Global.Config.DispCropRight.ToString(); + txtCropBottom.Text = Global.Config.DispCropBottom.ToString(); + RefreshAspectRatioOptions(); } @@ -173,6 +178,11 @@ namespace BizHawk.Client.EmuHawk if(rbD3D9.Checked) Global.Config.DispMethod = Config.EDispMethod.SlimDX9; + int.TryParse(txtCropLeft.Text, out Global.Config.DispCropLeft); + int.TryParse(txtCropTop.Text, out Global.Config.DispCropTop); + int.TryParse(txtCropRight.Text, out Global.Config.DispCropRight); + int.TryParse(txtCropBottom.Text, out Global.Config.DispCropBottom); + if (oldDisplayMethod != Global.Config.DispMethod) NeedReset = true; @@ -260,7 +270,7 @@ namespace BizHawk.Client.EmuHawk Global.Config.TargetScanlineFilterIntensity = tbScanlineIntensity.Value; int scanlines = Global.Config.TargetScanlineFilterIntensity; float percentage = (float) scanlines / 256 * 100; - lblScanlines.Text = String.Format("{0:F2}", percentage) + "%"; + lblScanlines.Text = $"{percentage:F2}%"; } private void trackbarFrameSizeWindowed_ValueChanged(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.resx b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.resx index 60237ce856..c5e4444e45 100644 --- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.resx +++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.resx @@ -126,4 +126,7 @@ For Windows operating systems >= Vista, with some video cards, the monitors may flicker when going 'windowed fullscreen' while the system disobeys us and goes actual fullscreen instead. This hack prevents that, but may increase frame latency (since in Microsoft's new and disimproved operating systems, windowed mode things may have higher latency) + + 17, 17 + \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs index d7a062cc1e..cbfbb76aaa 100644 --- a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs +++ b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs @@ -109,7 +109,7 @@ namespace BizHawk.Client.EmuHawk } else { - tbbCloseReload.ToolTipText = "Close Firmware Manager and reload " + reloadRomPath; + tbbCloseReload.ToolTipText = $"Close Firmware Manager and reload {reloadRomPath}"; } } @@ -313,7 +313,7 @@ namespace BizHawk.Client.EmuHawk lvi.SubItems[6].Text = ri.Size.ToString(); - if (ri.Hash != null) lvi.SubItems[7].Text = "sha1:" + ri.Hash; + if (ri.Hash != null) lvi.SubItems[7].Text = $"sha1:{ri.Hash}"; else lvi.SubItems[7].Text = ""; } } @@ -443,7 +443,7 @@ namespace BizHawk.Client.EmuHawk } catch (Exception ex) { - MessageBox.Show(this, "There was an issue copying the file. The customization has NOT been set.\n\n" + ex.StackTrace); + MessageBox.Show(this, $"There was an issue copying the file. The customization has NOT been set.\n\n{ex.StackTrace}"); continue; } } @@ -456,7 +456,7 @@ namespace BizHawk.Client.EmuHawk } catch (Exception ex) { - MessageBox.Show(this, "There was an issue during the process. The customization has NOT been set.\n\n" + ex.StackTrace); + MessageBox.Show(this, $"There was an issue during the process. The customization has NOT been set.\n\n{ex.StackTrace}"); return; } @@ -526,7 +526,7 @@ namespace BizHawk.Client.EmuHawk } olvi.SubItems[0].Text = ff.Size.ToString(); olvi.SubItems[0].Font = this.Font; // why doesnt this work? - olvi.SubItems[1].Text = "sha1:" + o.Hash; + olvi.SubItems[1].Text = $"sha1:{o.Hash}"; olvi.SubItems[1].Font = fixedFont; olvi.SubItems[2].Text = ff.RecommendedName; olvi.SubItems[2].Font = this.Font; // why doesnt this work? @@ -648,7 +648,7 @@ namespace BizHawk.Client.EmuHawk if (hf.IsArchive) { // blech. the worst extraction code in the universe. - string extractpath = Path.GetTempFileName() + ".dir"; + string extractpath = $"{Path.GetTempFileName()}.dir"; DirectoryInfo di = Directory.CreateDirectory(extractpath); try diff --git a/BizHawk.Client.EmuHawk/config/GB/BmpView.cs b/BizHawk.Client.EmuHawk/config/GB/BmpView.cs index 9af088c6f6..e7513fbaf8 100644 --- a/BizHawk.Client.EmuHawk/config/GB/BmpView.cs +++ b/BizHawk.Client.EmuHawk/config/GB/BmpView.cs @@ -103,7 +103,7 @@ namespace BizHawk.Client.EmuHawk var sfd = new SaveFileDialog { - FileName = PathManager.FilesystemSafeName(Global.Game) + "-Palettes", + FileName = $"{PathManager.FilesystemSafeName(Global.Game)}-Palettes", InitialDirectory = path, Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*", RestoreDirectory = true diff --git a/BizHawk.Client.EmuHawk/config/GB/ColorChooserForm.cs b/BizHawk.Client.EmuHawk/config/GB/ColorChooserForm.cs index b1a42261eb..0cc0c3bdf2 100644 --- a/BizHawk.Client.EmuHawk/config/GB/ColorChooserForm.cs +++ b/BizHawk.Client.EmuHawk/config/GB/ColorChooserForm.cs @@ -353,7 +353,7 @@ namespace BizHawk.Client.EmuHawk using (var sfd = new SaveFileDialog()) { sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["GB", "Palettes"].Path, "GB"); - sfd.FileName = Global.Game.Name + ".pal"; + sfd.FileName = $"{Global.Game.Name}.pal"; sfd.Filter = "Gambatte Palettes (*.pal)|*.pal|All Files|*.*"; sfd.RestoreDirectory = true; diff --git a/BizHawk.Client.EmuHawk/config/InputCompositeWidget.cs b/BizHawk.Client.EmuHawk/config/InputCompositeWidget.cs index ff429fa0d4..9b3a842a87 100644 --- a/BizHawk.Client.EmuHawk/config/InputCompositeWidget.cs +++ b/BizHawk.Client.EmuHawk/config/InputCompositeWidget.cs @@ -38,13 +38,13 @@ namespace BizHawk.Client.EmuHawk public void RefreshTooltip() { - string widgetText = "Current Binding: " + widget.Text; + string widgetText = $"Current Binding: {widget.Text}"; if (_bindingTooltipText != null) { - widgetText = widgetText + "\r\n---\r\n" + _bindingTooltipText; + widgetText = $"{widgetText}\r\n---\r\n{_bindingTooltipText}"; } - widgetText = widgetText + "\r\n---\r\n" + WidgetTooltipText; + widgetText = $"{widgetText}\r\n---\r\n{WidgetTooltipText}"; _tooltip.SetToolTip(widget, widgetText); } diff --git a/BizHawk.Client.EmuHawk/config/InputWidget.cs b/BizHawk.Client.EmuHawk/config/InputWidget.cs index f02130560c..79167ea11f 100644 --- a/BizHawk.Client.EmuHawk/config/InputWidget.cs +++ b/BizHawk.Client.EmuHawk/config/InputWidget.cs @@ -5,6 +5,8 @@ using System.Linq; using System.Runtime.InteropServices; using System.Windows.Forms; +using BizHawk.Common; + namespace BizHawk.Client.EmuHawk { public sealed class InputWidget : TextBox @@ -69,7 +71,7 @@ namespace BizHawk.Client.EmuHawk protected override void OnMouseClick(MouseEventArgs e) { - HideCaret(Handle); + if (!PlatformLinkedLibSingleton.RunningOnUnix) HideCaret(Handle); base.OnMouseClick(e); } @@ -262,7 +264,7 @@ namespace BizHawk.Client.EmuHawk protected override void OnGotFocus(EventArgs e) { - HideCaret(Handle); + if (!PlatformLinkedLibSingleton.RunningOnUnix) HideCaret(Handle); } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) diff --git a/BizHawk.Client.EmuHawk/config/MessageConfig.cs b/BizHawk.Client.EmuHawk/config/MessageConfig.cs index f6a4f2db00..2878232135 100644 --- a/BizHawk.Client.EmuHawk/config/MessageConfig.cs +++ b/BizHawk.Client.EmuHawk/config/MessageConfig.cs @@ -411,15 +411,15 @@ namespace BizHawk.Client.EmuHawk _dispAutoholdy = _py; } - FpsPosLabel.Text = _dispFpSx + ", " + _dispFpSy; - FCLabel.Text = _dispFrameCx + ", " + _dispFrameCy; - LagLabel.Text = _dispLagx + ", " + _dispLagy; - InpLabel.Text = _dispInpx + ", " + _dispInpy; - WatchesLabel.Text = _dispWatchesx + ", " + _dispWatchesy; - RerecLabel.Text = _dispRecx + ", " + _dispRecy; - MultitrackLabel.Text = _dispMultix + ", " + _dispMultiy; - MessLabel.Text = _dispMessagex + ", " + _dispMessagey; - AutoholdLabel.Text = _dispAutoholdx + ", " + _dispAutoholdy; + FpsPosLabel.Text = $"{_dispFpSx}, {_dispFpSy}"; + FCLabel.Text = $"{_dispFrameCx}, {_dispFrameCy}"; + LagLabel.Text = $"{_dispLagx}, {_dispLagy}"; + InpLabel.Text = $"{_dispInpx}, {_dispInpy}"; + WatchesLabel.Text = $"{_dispWatchesx}, {_dispWatchesy}"; + RerecLabel.Text = $"{_dispRecx}, {_dispRecy}"; + MultitrackLabel.Text = $"{_dispMultix}, {_dispMultiy}"; + MessLabel.Text = $"{_dispMessagex}, {_dispMessagey}"; + AutoholdLabel.Text = $"{_dispAutoholdx}, {_dispAutoholdy}"; } private void ResetDefaultsButton_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/config/N64/N64ControllerSettingControl.cs b/BizHawk.Client.EmuHawk/config/N64/N64ControllerSettingControl.cs index 191acadc1b..682b290ac4 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64ControllerSettingControl.cs +++ b/BizHawk.Client.EmuHawk/config/N64/N64ControllerSettingControl.cs @@ -16,7 +16,7 @@ namespace BizHawk.Client.EmuHawk { InitializeComponent(); - ControllerNameLabel.Text = "Controller " + ControllerNumber; + ControllerNameLabel.Text = $"Controller {ControllerNumber}"; } public int ControllerNumber @@ -82,7 +82,7 @@ namespace BizHawk.Client.EmuHawk public override void Refresh() { - ControllerNameLabel.Text = "Controller " + ControllerNumber; + ControllerNameLabel.Text = $"Controller {ControllerNumber}"; base.Refresh(); } diff --git a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.Designer.cs b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.Designer.cs index 1218ed5ab1..8d880c206b 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.Designer.cs @@ -48,6 +48,9 @@ this.GLideN64Tab = new System.Windows.Forms.TabPage(); this.tabControl3 = new System.Windows.Forms.TabControl(); this.tabPage5 = new System.Windows.Forms.TabPage(); + this.label98 = new System.Windows.Forms.Label(); + this.GLideN64_ShowRenderingResolution = new System.Windows.Forms.CheckBox(); + this.GLideN64_ShowInternalResolution = new System.Windows.Forms.CheckBox(); this.GLideN64_FXAA = new System.Windows.Forms.CheckBox(); this.label88 = new System.Windows.Forms.Label(); this.GLideN64_GammaCorrectionLevel = new System.Windows.Forms.TextBox(); @@ -73,6 +76,7 @@ this.GLideN64_EnableNoise = new System.Windows.Forms.CheckBox(); this.GLideN64_EnableLOD = new System.Windows.Forms.CheckBox(); this.tabPage6 = new System.Windows.Forms.TabPage(); + this.GLideN64_enableHalosRemoval = new System.Windows.Forms.CheckBox(); this.label87 = new System.Windows.Forms.Label(); this.GLideN64_txPath = new System.Windows.Forms.TextBox(); this.GLideN64_txSaveCache = new System.Windows.Forms.CheckBox(); @@ -96,6 +100,23 @@ this.GLideN64_bilinearMode = new System.Windows.Forms.ComboBox(); this.GLideN64_MaxAnisotropy = new System.Windows.Forms.CheckBox(); this.tabPage7 = new System.Windows.Forms.TabPage(); + this.GLideN64_OverscanPalRight = new System.Windows.Forms.TextBox(); + this.GLideN64_OverscanNtscRight = new System.Windows.Forms.TextBox(); + this.GLideN64_OverscanPalLeft = new System.Windows.Forms.TextBox(); + this.GLideN64_OverscanNtscLeft = new System.Windows.Forms.TextBox(); + this.GLideN64_OverscanPalBottom = new System.Windows.Forms.TextBox(); + this.GLideN64_OverscanNtscBottom = new System.Windows.Forms.TextBox(); + this.GLideN64_OverscanPalTop = new System.Windows.Forms.TextBox(); + this.label97 = new System.Windows.Forms.Label(); + this.GLideN64_OverscanNtscTop = new System.Windows.Forms.TextBox(); + this.label96 = new System.Windows.Forms.Label(); + this.label93 = new System.Windows.Forms.Label(); + this.label95 = new System.Windows.Forms.Label(); + this.label92 = new System.Windows.Forms.Label(); + this.label94 = new System.Windows.Forms.Label(); + this.label91 = new System.Windows.Forms.Label(); + this.label90 = new System.Windows.Forms.Label(); + this.GLideN64_EnableOverscan = new System.Windows.Forms.CheckBox(); this.label89 = new System.Windows.Forms.Label(); this.GLideN64_UseNativeResolutionFactor = new System.Windows.Forms.TextBox(); this.GLideN64_DisableFBInfo = new System.Windows.Forms.CheckBox(); @@ -362,25 +383,6 @@ this.SaveButton = new System.Windows.Forms.Button(); this.CancelBT = new System.Windows.Forms.Button(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.GLideN64_ShowInternalResolution = new System.Windows.Forms.CheckBox(); - this.GLideN64_ShowRenderingResolution = new System.Windows.Forms.CheckBox(); - this.GLideN64_EnableOverscan = new System.Windows.Forms.CheckBox(); - this.label90 = new System.Windows.Forms.Label(); - this.label91 = new System.Windows.Forms.Label(); - this.label92 = new System.Windows.Forms.Label(); - this.label93 = new System.Windows.Forms.Label(); - this.GLideN64_OverscanNtscTop = new System.Windows.Forms.TextBox(); - this.GLideN64_OverscanNtscBottom = new System.Windows.Forms.TextBox(); - this.GLideN64_OverscanNtscLeft = new System.Windows.Forms.TextBox(); - this.GLideN64_OverscanNtscRight = new System.Windows.Forms.TextBox(); - this.label94 = new System.Windows.Forms.Label(); - this.label95 = new System.Windows.Forms.Label(); - this.label96 = new System.Windows.Forms.Label(); - this.label97 = new System.Windows.Forms.Label(); - this.GLideN64_OverscanPalTop = new System.Windows.Forms.TextBox(); - this.GLideN64_OverscanPalBottom = new System.Windows.Forms.TextBox(); - this.GLideN64_OverscanPalLeft = new System.Windows.Forms.TextBox(); - this.GLideN64_OverscanPalRight = new System.Windows.Forms.TextBox(); this.N64plugintabcontrol.SuspendLayout(); this.N64vpluginglobaltab.SuspendLayout(); this.GLideN64Tab.SuspendLayout(); @@ -624,6 +626,7 @@ // // tabPage5 // + this.tabPage5.Controls.Add(this.label98); this.tabPage5.Controls.Add(this.GLideN64_ShowRenderingResolution); this.tabPage5.Controls.Add(this.GLideN64_ShowInternalResolution); this.tabPage5.Controls.Add(this.GLideN64_FXAA); @@ -658,10 +661,39 @@ this.tabPage5.Text = "General"; this.tabPage5.UseVisualStyleBackColor = true; // + // label98 + // + this.label98.AutoSize = true; + this.label98.Location = new System.Drawing.Point(3, 253); + this.label98.Name = "label98"; + this.label98.Size = new System.Drawing.Size(107, 26); + this.label98.TabIndex = 82; + this.label98.Text = "(Incompatible with\nN64 Depth Compare)"; + // + // GLideN64_ShowRenderingResolution + // + this.GLideN64_ShowRenderingResolution.AutoSize = true; + this.GLideN64_ShowRenderingResolution.Location = new System.Drawing.Point(309, 234); + this.GLideN64_ShowRenderingResolution.Name = "GLideN64_ShowRenderingResolution"; + this.GLideN64_ShowRenderingResolution.Size = new System.Drawing.Size(158, 17); + this.GLideN64_ShowRenderingResolution.TabIndex = 81; + this.GLideN64_ShowRenderingResolution.Text = "Show Rendering Resolution"; + this.GLideN64_ShowRenderingResolution.UseVisualStyleBackColor = true; + // + // GLideN64_ShowInternalResolution + // + this.GLideN64_ShowInternalResolution.AutoSize = true; + this.GLideN64_ShowInternalResolution.Location = new System.Drawing.Point(309, 210); + this.GLideN64_ShowInternalResolution.Name = "GLideN64_ShowInternalResolution"; + this.GLideN64_ShowInternalResolution.Size = new System.Drawing.Size(144, 17); + this.GLideN64_ShowInternalResolution.TabIndex = 80; + this.GLideN64_ShowInternalResolution.Text = "Show Internal Resolution"; + this.GLideN64_ShowInternalResolution.UseVisualStyleBackColor = true; + // // GLideN64_FXAA // this.GLideN64_FXAA.AutoSize = true; - this.GLideN64_FXAA.Location = new System.Drawing.Point(6, 237); + this.GLideN64_FXAA.Location = new System.Drawing.Point(6, 207); this.GLideN64_FXAA.Name = "GLideN64_FXAA"; this.GLideN64_FXAA.Size = new System.Drawing.Size(53, 17); this.GLideN64_FXAA.TabIndex = 79; @@ -697,7 +729,7 @@ // label81 // this.label81.AutoSize = true; - this.label81.Location = new System.Drawing.Point(3, 210); + this.label81.Location = new System.Drawing.Point(3, 234); this.label81.Name = "label81"; this.label81.Size = new System.Drawing.Size(75, 13); this.label81.TabIndex = 69; @@ -713,7 +745,7 @@ "4", "8", "16"}); - this.GLideN64_MultiSampling.Location = new System.Drawing.Point(128, 207); + this.GLideN64_MultiSampling.Location = new System.Drawing.Point(128, 231); this.GLideN64_MultiSampling.Name = "GLideN64_MultiSampling"; this.GLideN64_MultiSampling.Size = new System.Drawing.Size(138, 21); this.GLideN64_MultiSampling.TabIndex = 68; @@ -1006,6 +1038,7 @@ // // tabPage6 // + this.tabPage6.Controls.Add(this.GLideN64_enableHalosRemoval); this.tabPage6.Controls.Add(this.label87); this.tabPage6.Controls.Add(this.GLideN64_txPath); this.tabPage6.Controls.Add(this.GLideN64_txSaveCache); @@ -1036,6 +1069,16 @@ this.tabPage6.Text = "Texture settings"; this.tabPage6.UseVisualStyleBackColor = true; // + // GLideN64_enableHalosRemoval + // + this.GLideN64_enableHalosRemoval.AutoSize = true; + this.GLideN64_enableHalosRemoval.Location = new System.Drawing.Point(123, 19); + this.GLideN64_enableHalosRemoval.Name = "GLideN64_enableHalosRemoval"; + this.GLideN64_enableHalosRemoval.Size = new System.Drawing.Size(134, 17); + this.GLideN64_enableHalosRemoval.TabIndex = 77; + this.GLideN64_enableHalosRemoval.Text = "Enable Halos Removal"; + this.GLideN64_enableHalosRemoval.UseVisualStyleBackColor = true; + // // label87 // this.label87.AutoSize = true; @@ -1310,6 +1353,146 @@ this.tabPage7.Text = "Frame buffer settings"; this.tabPage7.UseVisualStyleBackColor = true; // + // GLideN64_OverscanPalRight + // + this.GLideN64_OverscanPalRight.Location = new System.Drawing.Point(517, 266); + this.GLideN64_OverscanPalRight.Name = "GLideN64_OverscanPalRight"; + this.GLideN64_OverscanPalRight.Size = new System.Drawing.Size(42, 20); + this.GLideN64_OverscanPalRight.TabIndex = 87; + // + // GLideN64_OverscanNtscRight + // + this.GLideN64_OverscanNtscRight.Location = new System.Drawing.Point(368, 266); + this.GLideN64_OverscanNtscRight.Name = "GLideN64_OverscanNtscRight"; + this.GLideN64_OverscanNtscRight.Size = new System.Drawing.Size(42, 20); + this.GLideN64_OverscanNtscRight.TabIndex = 87; + // + // GLideN64_OverscanPalLeft + // + this.GLideN64_OverscanPalLeft.Location = new System.Drawing.Point(517, 244); + this.GLideN64_OverscanPalLeft.Name = "GLideN64_OverscanPalLeft"; + this.GLideN64_OverscanPalLeft.Size = new System.Drawing.Size(42, 20); + this.GLideN64_OverscanPalLeft.TabIndex = 86; + // + // GLideN64_OverscanNtscLeft + // + this.GLideN64_OverscanNtscLeft.Location = new System.Drawing.Point(368, 244); + this.GLideN64_OverscanNtscLeft.Name = "GLideN64_OverscanNtscLeft"; + this.GLideN64_OverscanNtscLeft.Size = new System.Drawing.Size(42, 20); + this.GLideN64_OverscanNtscLeft.TabIndex = 86; + // + // GLideN64_OverscanPalBottom + // + this.GLideN64_OverscanPalBottom.Location = new System.Drawing.Point(517, 221); + this.GLideN64_OverscanPalBottom.Name = "GLideN64_OverscanPalBottom"; + this.GLideN64_OverscanPalBottom.Size = new System.Drawing.Size(42, 20); + this.GLideN64_OverscanPalBottom.TabIndex = 85; + // + // GLideN64_OverscanNtscBottom + // + this.GLideN64_OverscanNtscBottom.Location = new System.Drawing.Point(368, 221); + this.GLideN64_OverscanNtscBottom.Name = "GLideN64_OverscanNtscBottom"; + this.GLideN64_OverscanNtscBottom.Size = new System.Drawing.Size(42, 20); + this.GLideN64_OverscanNtscBottom.TabIndex = 85; + // + // GLideN64_OverscanPalTop + // + this.GLideN64_OverscanPalTop.Location = new System.Drawing.Point(517, 198); + this.GLideN64_OverscanPalTop.Name = "GLideN64_OverscanPalTop"; + this.GLideN64_OverscanPalTop.Size = new System.Drawing.Size(42, 20); + this.GLideN64_OverscanPalTop.TabIndex = 84; + // + // label97 + // + this.label97.AutoSize = true; + this.label97.Location = new System.Drawing.Point(448, 269); + this.label97.Name = "label97"; + this.label97.Size = new System.Drawing.Size(55, 13); + this.label97.TabIndex = 83; + this.label97.Text = "PAL Right"; + // + // GLideN64_OverscanNtscTop + // + this.GLideN64_OverscanNtscTop.Location = new System.Drawing.Point(368, 198); + this.GLideN64_OverscanNtscTop.Name = "GLideN64_OverscanNtscTop"; + this.GLideN64_OverscanNtscTop.Size = new System.Drawing.Size(42, 20); + this.GLideN64_OverscanNtscTop.TabIndex = 84; + // + // label96 + // + this.label96.AutoSize = true; + this.label96.Location = new System.Drawing.Point(448, 247); + this.label96.Name = "label96"; + this.label96.Size = new System.Drawing.Size(48, 13); + this.label96.TabIndex = 82; + this.label96.Text = "PAL Left"; + // + // label93 + // + this.label93.AutoSize = true; + this.label93.Location = new System.Drawing.Point(290, 269); + this.label93.Name = "label93"; + this.label93.Size = new System.Drawing.Size(64, 13); + this.label93.TabIndex = 83; + this.label93.Text = "NTSC Right"; + // + // label95 + // + this.label95.AutoSize = true; + this.label95.Location = new System.Drawing.Point(448, 224); + this.label95.Name = "label95"; + this.label95.Size = new System.Drawing.Size(63, 13); + this.label95.TabIndex = 81; + this.label95.Text = "PAL Bottom"; + // + // label92 + // + this.label92.AutoSize = true; + this.label92.Location = new System.Drawing.Point(290, 247); + this.label92.Name = "label92"; + this.label92.Size = new System.Drawing.Size(57, 13); + this.label92.TabIndex = 82; + this.label92.Text = "NTSC Left"; + // + // label94 + // + this.label94.AutoSize = true; + this.label94.Location = new System.Drawing.Point(448, 201); + this.label94.Name = "label94"; + this.label94.Size = new System.Drawing.Size(49, 13); + this.label94.TabIndex = 80; + this.label94.Text = "PAL Top"; + // + // label91 + // + this.label91.AutoSize = true; + this.label91.Location = new System.Drawing.Point(290, 224); + this.label91.Name = "label91"; + this.label91.Size = new System.Drawing.Size(72, 13); + this.label91.TabIndex = 81; + this.label91.Text = "NTSC Bottom"; + // + // label90 + // + this.label90.AutoSize = true; + this.label90.Location = new System.Drawing.Point(290, 201); + this.label90.Name = "label90"; + this.label90.Size = new System.Drawing.Size(58, 13); + this.label90.TabIndex = 80; + this.label90.Text = "NTSC Top"; + // + // GLideN64_EnableOverscan + // + this.GLideN64_EnableOverscan.AutoSize = true; + this.GLideN64_EnableOverscan.Enabled = false; + this.GLideN64_EnableOverscan.Location = new System.Drawing.Point(293, 171); + this.GLideN64_EnableOverscan.Name = "GLideN64_EnableOverscan"; + this.GLideN64_EnableOverscan.Size = new System.Drawing.Size(108, 17); + this.GLideN64_EnableOverscan.TabIndex = 79; + this.GLideN64_EnableOverscan.Text = "Enable Overscan"; + this.GLideN64_EnableOverscan.UseVisualStyleBackColor = true; + this.GLideN64_EnableOverscan.CheckedChanged += new System.EventHandler(this.GLideN64_EnableOverscan_CheckedChanged); + // // label89 // this.label89.AutoSize = true; @@ -4432,165 +4615,6 @@ this.toolTip1.ReshowDelay = 100; this.toolTip1.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info; // - // GLideN64_ShowInternalResolution - // - this.GLideN64_ShowInternalResolution.AutoSize = true; - this.GLideN64_ShowInternalResolution.Location = new System.Drawing.Point(309, 210); - this.GLideN64_ShowInternalResolution.Name = "GLideN64_ShowInternalResolution"; - this.GLideN64_ShowInternalResolution.Size = new System.Drawing.Size(144, 17); - this.GLideN64_ShowInternalResolution.TabIndex = 80; - this.GLideN64_ShowInternalResolution.Text = "Show Internal Resolution"; - this.GLideN64_ShowInternalResolution.UseVisualStyleBackColor = true; - // - // GLideN64_ShowRenderingResolution - // - this.GLideN64_ShowRenderingResolution.AutoSize = true; - this.GLideN64_ShowRenderingResolution.Location = new System.Drawing.Point(309, 234); - this.GLideN64_ShowRenderingResolution.Name = "GLideN64_ShowRenderingResolution"; - this.GLideN64_ShowRenderingResolution.Size = new System.Drawing.Size(158, 17); - this.GLideN64_ShowRenderingResolution.TabIndex = 81; - this.GLideN64_ShowRenderingResolution.Text = "Show Rendering Resolution"; - this.GLideN64_ShowRenderingResolution.UseVisualStyleBackColor = true; - // - // GLideN64_EnableOverscan - // - this.GLideN64_EnableOverscan.AutoSize = true; - this.GLideN64_EnableOverscan.Location = new System.Drawing.Point(293, 171); - this.GLideN64_EnableOverscan.Name = "GLideN64_EnableOverscan"; - this.GLideN64_EnableOverscan.Size = new System.Drawing.Size(108, 17); - this.GLideN64_EnableOverscan.TabIndex = 79; - this.GLideN64_EnableOverscan.Text = "Enable Overscan"; - this.GLideN64_EnableOverscan.UseVisualStyleBackColor = true; - this.GLideN64_EnableOverscan.CheckedChanged += new System.EventHandler(this.GLideN64_EnableOverscan_CheckedChanged); - // - // label90 - // - this.label90.AutoSize = true; - this.label90.Location = new System.Drawing.Point(290, 201); - this.label90.Name = "label90"; - this.label90.Size = new System.Drawing.Size(58, 13); - this.label90.TabIndex = 80; - this.label90.Text = "NTSC Top"; - // - // label91 - // - this.label91.AutoSize = true; - this.label91.Location = new System.Drawing.Point(290, 224); - this.label91.Name = "label91"; - this.label91.Size = new System.Drawing.Size(72, 13); - this.label91.TabIndex = 81; - this.label91.Text = "NTSC Bottom"; - // - // label92 - // - this.label92.AutoSize = true; - this.label92.Location = new System.Drawing.Point(290, 247); - this.label92.Name = "label92"; - this.label92.Size = new System.Drawing.Size(57, 13); - this.label92.TabIndex = 82; - this.label92.Text = "NTSC Left"; - // - // label93 - // - this.label93.AutoSize = true; - this.label93.Location = new System.Drawing.Point(290, 269); - this.label93.Name = "label93"; - this.label93.Size = new System.Drawing.Size(64, 13); - this.label93.TabIndex = 83; - this.label93.Text = "NTSC Right"; - // - // GLideN64_OverscanNtscTop - // - this.GLideN64_OverscanNtscTop.Location = new System.Drawing.Point(368, 198); - this.GLideN64_OverscanNtscTop.Name = "GLideN64_OverscanNtscTop"; - this.GLideN64_OverscanNtscTop.Size = new System.Drawing.Size(42, 20); - this.GLideN64_OverscanNtscTop.TabIndex = 84; - // - // GLideN64_OverscanNtscBottom - // - this.GLideN64_OverscanNtscBottom.Location = new System.Drawing.Point(368, 221); - this.GLideN64_OverscanNtscBottom.Name = "GLideN64_OverscanNtscBottom"; - this.GLideN64_OverscanNtscBottom.Size = new System.Drawing.Size(42, 20); - this.GLideN64_OverscanNtscBottom.TabIndex = 85; - // - // GLideN64_OverscanNtscLeft - // - this.GLideN64_OverscanNtscLeft.Location = new System.Drawing.Point(368, 244); - this.GLideN64_OverscanNtscLeft.Name = "GLideN64_OverscanNtscLeft"; - this.GLideN64_OverscanNtscLeft.Size = new System.Drawing.Size(42, 20); - this.GLideN64_OverscanNtscLeft.TabIndex = 86; - // - // GLideN64_OverscanNtscRight - // - this.GLideN64_OverscanNtscRight.Location = new System.Drawing.Point(368, 266); - this.GLideN64_OverscanNtscRight.Name = "GLideN64_OverscanNtscRight"; - this.GLideN64_OverscanNtscRight.Size = new System.Drawing.Size(42, 20); - this.GLideN64_OverscanNtscRight.TabIndex = 87; - // - // label94 - // - this.label94.AutoSize = true; - this.label94.Location = new System.Drawing.Point(448, 201); - this.label94.Name = "label94"; - this.label94.Size = new System.Drawing.Size(49, 13); - this.label94.TabIndex = 80; - this.label94.Text = "PAL Top"; - // - // label95 - // - this.label95.AutoSize = true; - this.label95.Location = new System.Drawing.Point(448, 224); - this.label95.Name = "label95"; - this.label95.Size = new System.Drawing.Size(63, 13); - this.label95.TabIndex = 81; - this.label95.Text = "PAL Bottom"; - // - // label96 - // - this.label96.AutoSize = true; - this.label96.Location = new System.Drawing.Point(448, 247); - this.label96.Name = "label96"; - this.label96.Size = new System.Drawing.Size(48, 13); - this.label96.TabIndex = 82; - this.label96.Text = "PAL Left"; - // - // label97 - // - this.label97.AutoSize = true; - this.label97.Location = new System.Drawing.Point(448, 269); - this.label97.Name = "label97"; - this.label97.Size = new System.Drawing.Size(55, 13); - this.label97.TabIndex = 83; - this.label97.Text = "PAL Right"; - // - // GLideN64_OverscanPalTop - // - this.GLideN64_OverscanPalTop.Location = new System.Drawing.Point(517, 198); - this.GLideN64_OverscanPalTop.Name = "GLideN64_OverscanPalTop"; - this.GLideN64_OverscanPalTop.Size = new System.Drawing.Size(42, 20); - this.GLideN64_OverscanPalTop.TabIndex = 84; - // - // GLideN64_OverscanPalBottom - // - this.GLideN64_OverscanPalBottom.Location = new System.Drawing.Point(517, 221); - this.GLideN64_OverscanPalBottom.Name = "GLideN64_OverscanPalBottom"; - this.GLideN64_OverscanPalBottom.Size = new System.Drawing.Size(42, 20); - this.GLideN64_OverscanPalBottom.TabIndex = 85; - // - // GLideN64_OverscanPalLeft - // - this.GLideN64_OverscanPalLeft.Location = new System.Drawing.Point(517, 244); - this.GLideN64_OverscanPalLeft.Name = "GLideN64_OverscanPalLeft"; - this.GLideN64_OverscanPalLeft.Size = new System.Drawing.Size(42, 20); - this.GLideN64_OverscanPalLeft.TabIndex = 86; - // - // GLideN64_OverscanPalRight - // - this.GLideN64_OverscanPalRight.Location = new System.Drawing.Point(517, 266); - this.GLideN64_OverscanPalRight.Name = "GLideN64_OverscanPalRight"; - this.GLideN64_OverscanPalRight.Size = new System.Drawing.Size(42, 20); - this.GLideN64_OverscanPalRight.TabIndex = 87; - // // N64VideoPluginconfig // this.AcceptButton = this.SaveButton; @@ -5004,5 +5028,7 @@ private System.Windows.Forms.Label label94; private System.Windows.Forms.Label label91; private System.Windows.Forms.Label label90; + private System.Windows.Forms.CheckBox GLideN64_enableHalosRemoval; + private System.Windows.Forms.Label label98; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs index ebb0d105d9..ae8dc93b28 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs +++ b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs @@ -30,6 +30,7 @@ namespace BizHawk.Client.EmuHawk "1600 x 1200", "1920 x 1440", "2048 x 1536", + "2880 x 2160", "Custom" }; @@ -404,6 +405,7 @@ namespace BizHawk.Client.EmuHawk _ss.GLideN64Plugin.bilinearMode = GLideN64_bilinearMode.SelectedItem .ToString() .GetEnumFromDescription(); + _ss.GLideN64Plugin.enableHalosRemoval = GLideN64_enableHalosRemoval.Checked; _ss.GLideN64Plugin.MaxAnisotropy = GLideN64_MaxAnisotropy.Checked; _ss.GLideN64Plugin.CacheSize = GLideN64_CacheSize.Text.IsSigned() ? int.Parse(GLideN64_CacheSize.Text) @@ -531,9 +533,7 @@ namespace BizHawk.Client.EmuHawk VideoResolutionXTextBox.Text = _s.VideoSizeX.ToString(); VideoResolutionYTextBox.Text = _s.VideoSizeY.ToString(); - var videoSetting = _s.VideoSizeX - + " x " - + _s.VideoSizeY; + var videoSetting = $"{_s.VideoSizeX} x {_s.VideoSizeY}"; var index = VideoResolutionComboBox.Items.IndexOf(videoSetting); if (index >= 0) @@ -603,7 +603,7 @@ namespace BizHawk.Client.EmuHawk RiceColorQuality_Combo.SelectedIndex = _ss.RicePlugin.ColorQuality; RiceOpenGLRenderSetting_Combo.SelectedIndex = _ss.RicePlugin.OpenGLRenderSetting; RiceAnisotropicFiltering_TB.Value = _ss.RicePlugin.AnisotropicFiltering; - AnisotropicFiltering_LB.Text = "Anisotropic Filtering: " + RiceAnisotropicFiltering_TB.Value; + AnisotropicFiltering_LB.Text = $"Anisotropic Filtering: {RiceAnisotropicFiltering_TB.Value}"; RiceUseDefaultHacks_CB.Checked = _ss.RicePlugin.UseDefaultHacks; @@ -775,6 +775,7 @@ namespace BizHawk.Client.EmuHawk GLideN64_UseNativeResolutionFactor.Text = _ss.GLideN64Plugin.UseNativeResolutionFactor.ToString(); GLideN64_bilinearMode .PopulateFromEnum(_ss.GLideN64Plugin.bilinearMode); + GLideN64_enableHalosRemoval.Checked = _ss.GLideN64Plugin.enableHalosRemoval; GLideN64_MaxAnisotropy.Checked = _ss.GLideN64Plugin.MaxAnisotropy; GLideN64_CacheSize.Text = _ss.GLideN64Plugin.CacheSize.ToString(); GLideN64_ShowInternalResolution.Checked = _ss.GLideN64Plugin.ShowInternalResolution; @@ -851,7 +852,7 @@ namespace BizHawk.Client.EmuHawk private void RiceAnisotropicFiltering_Tb_Scroll_1(object sender, EventArgs e) { - AnisotropicFiltering_LB.Text = "Anisotropic Filtering: " + RiceAnisotropicFiltering_TB.Value; + AnisotropicFiltering_LB.Text = $"Anisotropic Filtering: {RiceAnisotropicFiltering_TB.Value}"; } private void RiceUseDefaultHacks_Cb_CheckedChanged(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.resx b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.resx index cddb4546e3..915289106f 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.resx +++ b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.resx @@ -120,9 +120,6 @@ 17, 17 - - 17, 17 - Enable/Disable Anisotropic Filtering for Mipmapping (0=no filtering, 2-16=quality). This is uneffective if Mipmapping is 0. diff --git a/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs b/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs index f8c41e16ee..2c3a963428 100644 --- a/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs +++ b/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs @@ -5,6 +5,7 @@ using System.Windows.Forms; using BizHawk.Common; using BizHawk.Client.Common; using BizHawk.Emulation.Cores.Nintendo.NES; +using BizHawk.Emulation.Cores.Nintendo.SubNESHawk; namespace BizHawk.Client.EmuHawk { @@ -15,6 +16,7 @@ namespace BizHawk.Client.EmuHawk // Hotkeys for BG & Sprite display toggle // NTSC filter settings? Hue, Tint (This should probably be a client thing, not a nes specific thing?) private NES _nes; + private SubNESHawk _subneshawk; private NES.NESSettings _settings; private Bitmap _bmp; @@ -25,8 +27,17 @@ namespace BizHawk.Client.EmuHawk private void NESGraphicsConfig_Load(object sender, EventArgs e) { - _nes = (NES)Global.Emulator; - _settings = _nes.GetSettings(); + if (Global.Emulator is NES) + { + _nes = (NES)Global.Emulator; + _settings = _nes.GetSettings(); + } + else + { + _subneshawk = (SubNESHawk)Global.Emulator; + _settings = _subneshawk.GetSettings(); + } + LoadStuff(); } @@ -102,7 +113,7 @@ namespace BizHawk.Client.EmuHawk var data = Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name)); if (showmsg) { - GlobalWin.OSD.AddMessage("Palette file loaded: " + palette.Name); + GlobalWin.OSD.AddMessage($"Palette file loaded: {palette.Name}"); } return data; @@ -146,7 +157,15 @@ namespace BizHawk.Client.EmuHawk _settings.BackgroundColor &= 0x00FFFFFF; } - _nes.PutSettings(_settings); + if (Global.Emulator is NES) + { + _nes.PutSettings(_settings); + } + else + { + _subneshawk.PutSettings(_settings); + } + Close(); } diff --git a/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs b/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs index 068711825f..4141bf067e 100644 --- a/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs +++ b/BizHawk.Client.EmuHawk/config/NES/NesControllerSettings.cs @@ -4,6 +4,7 @@ using System.Windows.Forms; using BizHawk.Client.Common; using BizHawk.Emulation.Cores.Nintendo.NES; +using BizHawk.Emulation.Cores.Nintendo.SubNESHawk; namespace BizHawk.Client.EmuHawk { @@ -14,7 +15,15 @@ namespace BizHawk.Client.EmuHawk public NesControllerSettings() { InitializeComponent(); - _syncSettings = ((NES)Global.Emulator).GetSyncSettings(); + if (Global.Emulator is NES) + { + _syncSettings = ((NES)Global.Emulator).GetSyncSettings(); + } + else + { + _syncSettings = ((SubNESHawk)Global.Emulator).GetSyncSettings(); + } + // TODO: use combobox extension and add descriptions to enum values comboBoxFamicom.Items.AddRange(NESControlSettings.GetFamicomExpansionValues().ToArray()); diff --git a/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.cs b/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.cs index a90dfaa146..703b6c7891 100644 --- a/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.cs +++ b/BizHawk.Client.EmuHawk/config/PSX/PSXControllerConfigNew.cs @@ -113,7 +113,7 @@ namespace BizHawk.Client.EmuHawk } else { - lbl.Text = "P" + lc.PlayerAssignments[i]; + lbl.Text = $"P{lc.PlayerAssignments[i]}"; lbl.Visible = true; } } diff --git a/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs b/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs index ea6a767870..91b1e36367 100644 --- a/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs +++ b/BizHawk.Client.EmuHawk/config/PSX/PSXOptions.cs @@ -178,12 +178,12 @@ namespace BizHawk.Client.EmuHawk private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - MessageBox.Show(@"These options control BizHawk's Display Options to make it act quite a lot like Mednafen: + MessageBox.Show($@"These options control BizHawk's Display Options to make it act quite a lot like Mednafen: -DispManagerAR = System (Use emulator-recommended AR) -DispFixAspectRatio = true (Maintain aspect ratio [letterbox main window as needed]) -DispFinalFilter = bilinear (Like Mednafen) -DispFixScaleInteger = false (Generally unwanted with bilinear filtering) +{nameof(Global.Config.DispManagerAR)} = System (Use emulator-recommended AR) +{nameof(Global.Config.DispFixAspectRatio)} = true (Maintain aspect ratio [letterbox main window as needed]) +{nameof(Global.Config.DispFinalFilter)} = bilinear (Like Mednafen) +{nameof(Global.Config.DispFixScaleInteger)} = false (Generally unwanted with bilinear filtering) This is a good place to write that Mednafen's default behaviour is fantastic for gaming! But: 1. we think we improved on it a tiny bit with the tweaked mode diff --git a/BizHawk.Client.EmuHawk/config/PathConfig.cs b/BizHawk.Client.EmuHawk/config/PathConfig.cs index 6c7ef17e6b..b8f438b543 100644 --- a/BizHawk.Client.EmuHawk/config/PathConfig.cs +++ b/BizHawk.Client.EmuHawk/config/PathConfig.cs @@ -220,7 +220,7 @@ namespace BizHawk.Client.EmuHawk var f = new FolderBrowserEx { - Description = "Set the directory for " + name, + Description = $"Set the directory for {name}", SelectedPath = PathManager.MakeAbsolutePath(box.Text, system) }; var result = f.ShowDialog(); diff --git a/BizHawk.Client.EmuHawk/config/RewindConfig.cs b/BizHawk.Client.EmuHawk/config/RewindConfig.cs index d99daf5456..66fc4cd80d 100644 --- a/BizHawk.Client.EmuHawk/config/RewindConfig.cs +++ b/BizHawk.Client.EmuHawk/config/RewindConfig.cs @@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.Rewinder.HasBuffer) { - FullnessLabel.Text = $"{Global.Rewinder.FullnessRatio * 100:0.00}" + "%"; + FullnessLabel.Text = $"{Global.Rewinder.FullnessRatio * 100:0.00}%"; RewindFramesUsedLabel.Text = Global.Rewinder.Count.ToString(); } else @@ -94,10 +94,10 @@ namespace BizHawk.Client.EmuHawk if (num >= 1024) { num /= 1024.0; - return $"{num:0.00}" + " MB"; + return $"{num:0.00} MB"; } - return $"{num:0.00}" + " KB"; + return $"{num:0.00} KB"; } private void SetStateSize() @@ -344,8 +344,8 @@ namespace BizHawk.Client.EmuHawk double minutes = estTotalFrames / 60 / 60; AverageStoredStateSizeLabel.Text = FormatKB(avgStateSize); - ApproxFramesLabel.Text = $"{estFrames:n0}" + " frames"; - EstTimeLabel.Text = $"{minutes:n}" + " minutes"; + ApproxFramesLabel.Text = $"{estFrames:n0} frames"; + EstTimeLabel.Text = $"{minutes:n} minutes"; } private void BufferSizeUpDown_ValueChanged(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs index de0c799f24..9c3ec12f96 100644 --- a/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs +++ b/BizHawk.Client.EmuHawk/config/ZXSpectrum/ZXSpectrumPokeMemory.cs @@ -10,8 +10,6 @@ namespace BizHawk.Client.EmuHawk { public partial class ZXSpectrumPokeMemory : Form { - private ZXSpectrum.ZXSpectrumSettings _settings; - public ZXSpectrumPokeMemory() { InitializeComponent(); diff --git a/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs b/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs index 730b271e0c..9c2b079bff 100644 --- a/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs +++ b/BizHawk.Client.EmuHawk/movie/EditSubtitlesForm.cs @@ -46,8 +46,8 @@ namespace BizHawk.Client.EmuHawk private void ShowError(int row, int column) { var c = SubGrid.Rows[row].Cells[column]; - var error = "Unable to parse value: " + c.Value; - var caption = "Parse Error Row " + row + " Column " + column; + var error = $"Unable to parse value: {c.Value}"; + var caption = $"Parse Error Row {row} Column {column}"; MessageBox.Show(error, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -104,7 +104,7 @@ namespace BizHawk.Client.EmuHawk c = SubGrid.Rows[x].Cells[3]; c.Value = s.Duration; c = SubGrid.Rows[x].Cells[4]; - c.Value = string.Format("{0:X8}", s.Color); + c.Value = $"{s.Color:X8}"; c.Style.BackColor = Color.FromArgb((int)s.Color); c = SubGrid.Rows[x].Cells[5]; c.Value = s.Message; @@ -127,7 +127,7 @@ namespace BizHawk.Client.EmuHawk c = SubGrid.Rows[index].Cells[3]; c.Value = s.Duration; c = SubGrid.Rows[index].Cells[4]; - c.Value = string.Format("{0:X8}", s.Color); + c.Value = $"{s.Color:X8}"; c.Style.BackColor = Color.FromArgb((int)s.Color); c = SubGrid.Rows[index].Cells[5]; c.Value = s.Message; @@ -229,9 +229,7 @@ namespace BizHawk.Client.EmuHawk File.WriteAllText(fileName, str); // Display success - MessageBox.Show( - string.Format("Subtitles succesfully exported to {0}.", fileName), - "Success"); + MessageBox.Show($"Subtitles succesfully exported to {fileName}.", "Success"); } private void SubGrid_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e) diff --git a/BizHawk.Client.EmuHawk/movie/PlayMovie.cs b/BizHawk.Client.EmuHawk/movie/PlayMovie.cs index 62f072f5e9..6365304e9f 100644 --- a/BizHawk.Client.EmuHawk/movie/PlayMovie.cs +++ b/BizHawk.Client.EmuHawk/movie/PlayMovie.cs @@ -154,8 +154,7 @@ namespace BizHawk.Client.EmuHawk private void UpdateList() { MovieView.Refresh(); - MovieCount.Text = _movieList.Count + " movie" - + (_movieList.Count != 1 ? "s" : ""); + MovieCount.Text = $"{_movieList.Count} {(_movieList.Count == 1 ? "movie" : "movies")}"; } private void PreHighlightMovie() @@ -193,7 +192,7 @@ namespace BizHawk.Client.EmuHawk { foreach (var ext in MovieService.MovieExtensions) { - if (Path.GetExtension(_movieList[indices[i]].Filename).ToUpper() == "." + ext) + if (Path.GetExtension(_movieList[indices[i]].Filename).ToUpper() == $".{ext}") { tas.Add(i); } @@ -266,8 +265,8 @@ namespace BizHawk.Client.EmuHawk } // add movies - fpTodo.AddRange(Directory.GetFiles(dp, "*." + MovieService.DefaultExtension)); - fpTodo.AddRange(Directory.GetFiles(dp, "*." + TasMovie.Extension)); + fpTodo.AddRange(Directory.GetFiles(dp, $"*.{MovieService.DefaultExtension}")); + fpTodo.AddRange(Directory.GetFiles(dp, $"*.{TasMovie.Extension}")); } // in parallel, scan each movie @@ -331,9 +330,8 @@ namespace BizHawk.Client.EmuHawk .Append(_movieList[index].GameName).Append('\t') .Append(PlatformFrameRates.MovieTime(_movieList[index]).ToString(@"hh\:mm\:ss\.fff")) .AppendLine(); - - Clipboard.SetDataObject(copyStr.ToString()); } + Clipboard.SetDataObject(copyStr.ToString()); } } } @@ -347,97 +345,48 @@ namespace BizHawk.Client.EmuHawk private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e) { var columnName = MovieView.Columns[e.Column].Text; - if (_sortedCol != columnName) - { - _sortReverse = false; - } - switch (columnName) { case "File": - if (_sortReverse) - { - _movieList = _movieList - .OrderByDescending(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.GameName) - .ThenBy(x => x.FrameCount) - .ToList(); - } - else - { - _movieList = _movieList - .OrderBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.GameName) - .ThenBy(x => x.FrameCount) - .ToList(); - } + default: + _movieList = _movieList.OrderBy(x => Path.GetFileName(x.Filename)) + .ThenBy(x => x.SystemID) + .ThenBy(x => x.GameName) + .ThenBy(x => x.FrameCount) + .ToList(); break; case "SysID": - if (_sortReverse) - { - _movieList = _movieList - .OrderByDescending(x => x.SystemID) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.GameName) - .ThenBy(x => x.FrameCount) - .ToList(); - } - else - { - _movieList = _movieList - .OrderBy(x => x.SystemID) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.GameName) - .ThenBy(x => x.FrameCount) - .ToList(); - } + _movieList = _movieList.OrderBy(x => x.SystemID) + .ThenBy(x => Path.GetFileName(x.Filename)) + .ThenBy(x => x.GameName) + .ThenBy(x => x.FrameCount) + .ToList(); break; case "Game": - if (_sortReverse) - { - _movieList = _movieList - .OrderByDescending(x => x.GameName) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.FrameCount) - .ToList(); - } - else - { - _movieList = _movieList - .OrderBy(x => x.GameName) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.FrameCount) - .ToList(); - } + _movieList = _movieList.OrderBy(x => x.GameName) + .ThenBy(x => Path.GetFileName(x.Filename)) + .ThenBy(x => x.SystemID) + .ThenBy(x => x.FrameCount) + .ToList(); break; case "Length (est.)": - if (_sortReverse) - { - _movieList = _movieList - .OrderByDescending(x => x.FrameCount) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.FrameCount) - .ToList(); - } - else - { - _movieList = _movieList - .OrderBy(x => x.FrameCount) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.GameName) - .ToList(); - } + _movieList = _movieList.OrderBy(x => x.FrameCount) + .ThenBy(x => Path.GetFileName(x.Filename)) + .ThenBy(x => x.SystemID) + .ThenBy(x => x.GameName) + .ToList(); break; } - - _sortedCol = columnName; - _sortReverse = !_sortReverse; + if (_sortedCol == columnName && _sortReverse) + { + _movieList.Reverse(); + _sortReverse = false; + } + else + { + _sortReverse = true; + _sortedCol = columnName; + } MovieView.Refresh(); } @@ -469,7 +418,7 @@ namespace BizHawk.Client.EmuHawk if (kvp.Value != Global.Game.Hash) { item.BackColor = Color.Pink; - toolTip1.SetToolTip(DetailsView, "Current SHA1: " + Global.Game.Hash); + toolTip1.SetToolTip(DetailsView, $"Current SHA1: {Global.Game.Hash}"); } break; case HeaderKeys.EMULATIONVERSION: @@ -497,7 +446,7 @@ namespace BizHawk.Client.EmuHawk } var FpsItem = new ListViewItem("Fps"); - FpsItem.SubItems.Add(string.Format("{0:0.#######}", Fps(_movieList[firstIndex]))); + FpsItem.SubItems.Add($"{Fps(_movieList[firstIndex]):0.#######}"); DetailsView.Items.Add(FpsItem); var FramesItem = new ListViewItem("Frames"); @@ -626,9 +575,7 @@ namespace BizHawk.Client.EmuHawk { var ofd = new OpenFileDialog { - Filter = "Movie Files (*." + MovieService.DefaultExtension + ")|*." + MovieService.DefaultExtension + - "|TAS project Files (*." + TasMovie.Extension + ")|*." + TasMovie.Extension + - "|All Files|*.*", + Filter = $"Movie Files (*.{MovieService.DefaultExtension})|*.{MovieService.DefaultExtension}|TAS project Files (*.{TasMovie.Extension})|*.{TasMovie.Extension}|All Files|*.*", InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null) }; diff --git a/BizHawk.Client.EmuHawk/movie/RecordMovie.cs b/BizHawk.Client.EmuHawk/movie/RecordMovie.cs index 52ff80339b..8e8e1eeb8f 100644 --- a/BizHawk.Client.EmuHawk/movie/RecordMovie.cs +++ b/BizHawk.Client.EmuHawk/movie/RecordMovie.cs @@ -61,7 +61,7 @@ namespace BizHawk.Client.EmuHawk if (!MovieService.MovieExtensions.Contains(Path.GetExtension(path))) { // If no valid movie extension, add movie extension - path += "." + MovieService.DefaultExtension; + path += $".{MovieService.DefaultExtension}"; } } } @@ -77,7 +77,7 @@ namespace BizHawk.Client.EmuHawk var test = new FileInfo(path); if (test.Exists) { - var result = MessageBox.Show(path + " already exists, overwrite?", "Confirm overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); + var result = MessageBox.Show($"{path} already exists, overwrite?", "Confirm overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { return; @@ -180,10 +180,10 @@ namespace BizHawk.Client.EmuHawk var sfd = new SaveFileDialog { InitialDirectory = movieFolderPath, - DefaultExt = "." + Global.MovieSession.Movie.PreferredExtension, + DefaultExt = $".{Global.MovieSession.Movie.PreferredExtension}", FileName = RecordBox.Text, OverwritePrompt = false, - Filter = "Movie Files (*." + Global.MovieSession.Movie.PreferredExtension + ")|*." + Global.MovieSession.Movie.PreferredExtension + "|All Files|*.*" + Filter = $"Movie Files (*.{Global.MovieSession.Movie.PreferredExtension})|*.{Global.MovieSession.Movie.PreferredExtension}|All Files|*.*" }; var result = sfd.ShowHawkDialog(); diff --git a/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs b/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs index 2c6392854c..d5294581d4 100644 --- a/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs +++ b/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs @@ -27,7 +27,7 @@ namespace BizHawk.Client.EmuHawk if (!string.IsNullOrWhiteSpace(_currentFileName)) { - Text = DialogTitle + " - " + Path.GetFileNameWithoutExtension(_currentFileName); + Text = $"{DialogTitle} - {Path.GetFileNameWithoutExtension(_currentFileName)}"; } else { @@ -125,7 +125,7 @@ namespace BizHawk.Client.EmuHawk .ToString() .Last(); - return "QuickSave" + num; + return $"QuickSave{num}"; } } @@ -350,8 +350,8 @@ namespace BizHawk.Client.EmuHawk set { - var item = StartFromSlotBox.Items. - OfType() + var item = StartFromSlotBox.Items + .OfType() .FirstOrDefault(o => o.ToString() == value); if (item != null) @@ -772,7 +772,7 @@ namespace BizHawk.Client.EmuHawk CurrentFileName = path; Settings.RecentBotFiles.Add(CurrentFileName); - MessageLabel.Text = Path.GetFileNameWithoutExtension(path) + " loaded"; + MessageLabel.Text = $"{Path.GetFileNameWithoutExtension(path)} loaded"; AssessRunButtonStatus(); return true; @@ -814,7 +814,7 @@ namespace BizHawk.Client.EmuHawk File.WriteAllText(path, json); CurrentFileName = path; Settings.RecentBotFiles.Add(CurrentFileName); - MessageLabel.Text = Path.GetFileName(CurrentFileName) + " saved"; + MessageLabel.Text = $"{Path.GetFileName(CurrentFileName)} saved"; } #endregion diff --git a/BizHawk.Client.EmuHawk/tools/BatchRun.cs b/BizHawk.Client.EmuHawk/tools/BatchRun.cs index 4dbda880bf..99f4530175 100644 --- a/BizHawk.Client.EmuHawk/tools/BatchRun.cs +++ b/BizHawk.Client.EmuHawk/tools/BatchRun.cs @@ -33,7 +33,7 @@ namespace BizHawk.Client.EmuHawk private void SetCount() { - label2.Text = string.Format("Number of files: {0}", listBox1.Items.Count); + label2.Text = $"Number of files: {listBox1.Items.Count}"; } private void listBox1_DragDrop(object sender, DragEventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/BatchRunner.cs b/BizHawk.Client.EmuHawk/tools/BatchRunner.cs index 7e25ff3e1e..987b605b76 100644 --- a/BizHawk.Client.EmuHawk/tools/BatchRunner.cs +++ b/BizHawk.Client.EmuHawk/tools/BatchRunner.cs @@ -81,12 +81,12 @@ namespace BizHawk.Client.EmuHawk void OnLoadError(object sender, RomLoader.RomErrorArgs e) { current.Status = Result.EStatus.ErrorOnLoad; - current.Messages.Add(string.Format("OnLoadError: {0}, {1}, {2}", e.AttemptedCoreLoad, e.Message, e.Type.ToString())); + current.Messages.Add($"{nameof(OnLoadError)}: {e.AttemptedCoreLoad}, {e.Message}, {e.Type}"); } void CommMessage(string msg) { - current.Messages.Add(string.Format("CommMessage: {0}", msg)); + current.Messages.Add($"{nameof(CommMessage)}: {msg}"); } int? ChooseArchive(HawkFile hf) diff --git a/BizHawk.Client.EmuHawk/tools/CDL.cs b/BizHawk.Client.EmuHawk/tools/CDL.cs index 54f8f560da..0571d4e4ac 100644 --- a/BizHawk.Client.EmuHawk/tools/CDL.cs +++ b/BizHawk.Client.EmuHawk/tools/CDL.cs @@ -38,7 +38,7 @@ namespace BizHawk.Client.EmuHawk _currentFilename = fname; if (_currentFilename == null) Text = "Code Data Logger"; - else Text = string.Format("Code Data Logger - {0}", fname); + else Text = $"Code Data Logger - {fname}"; } [RequiredService] @@ -147,29 +147,29 @@ namespace BizHawk.Client.EmuHawk long addr = bm[kvp.Key]; var lvi = listContents[idx++] = new string[13]; - lvi[0] = string.Format("{0:X8}", addr); + lvi[0] = $"{addr:X8}"; lvi[1] = kvp.Key; - lvi[2] = string.Format("{0:0.00}%", total / (float)kvp.Value.Length * 100f); + lvi[2] = $"{total / (float)kvp.Value.Length * 100f:0.00}%"; if (tsbViewStyle.SelectedIndex == 2) - lvi[3] = string.Format("{0:0.00}", total / 1024.0f); + lvi[3] = $"{total / 1024.0f:0.00}"; else - lvi[3] = string.Format("{0}", total); + lvi[3] = $"{total}"; if (tsbViewStyle.SelectedIndex == 2) { int n = (int)(kvp.Value.Length / 1024.0f); float ncheck = kvp.Value.Length / 1024.0f; - lvi[4] = string.Format("of {0}{1} KBytes", n == ncheck ? "" : "~", n); + lvi[4] = $"of {(n == ncheck ? "" : "~")}{n} KBytes"; } else - lvi[4] = string.Format("of {0} Bytes", kvp.Value.Length); + lvi[4] = $"of {kvp.Value.Length} Bytes"; for (int i = 0; i < 8; i++) { if (tsbViewStyle.SelectedIndex == 0) - lvi[5 + i] = string.Format("{0:0.00}%", totals[i] / (float)kvp.Value.Length * 100f); + lvi[5 + i] = $"{totals[i] / (float)kvp.Value.Length * 100f:0.00}%"; if (tsbViewStyle.SelectedIndex == 1) - lvi[5 + i] = string.Format("{0}", totals[i]); + lvi[5 + i] = $"{totals[i]}"; if (tsbViewStyle.SelectedIndex == 2) - lvi[5 + i] = string.Format("{0:0.00}", totals[i] / 1024.0f); + lvi[5 + i] = $"{totals[i] / 1024.0f:0.00}"; } } @@ -498,7 +498,7 @@ namespace BizHawk.Client.EmuHawk try { autoloading = true; - var autoresume_file = PathManager.FilesystemSafeName(Global.Game) + ".cdl"; + var autoresume_file = $"{PathManager.FilesystemSafeName(Global.Game)}.cdl"; var autoresume_dir = PathManager.MakeAbsolutePath(Global.Config.PathEntries.LogPathFragment, null); var autoresume_path = Path.Combine(autoresume_dir, autoresume_file); if (File.Exists(autoresume_path)) diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs b/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs index b919d59010..398dce5bbc 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs @@ -349,7 +349,7 @@ namespace BizHawk.Client.EmuHawk } else { - MessageBox.Show(address + " is not a valid address for the domain " + domain.Name, "Index out of range", MessageBoxButtons.OK, MessageBoxIcon.Warning); + MessageBox.Show($"{address} is not a valid address for the domain {domain.Name}", "Index out of range", MessageBoxButtons.OK, MessageBoxIcon.Warning); return Cheat.Separator; } } diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index fd178f17bc..cbc8cd2efe 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -81,9 +81,7 @@ namespace BizHawk.Client.EmuHawk public void UpdateDialog() { CheatListView.ItemCount = Global.CheatList.Count; - TotalLabel.Text = Global.CheatList.CheatCount - + (Global.CheatList.CheatCount == 1 ? " cheat " : " cheats ") - + Global.CheatList.ActiveCount + " active"; + TotalLabel.Text = $"{Global.CheatList.CheatCount} {(Global.CheatList.CheatCount == 1 ? "cheat" : "cheats")} {Global.CheatList.ActiveCount} active"; } private void LoadFileFromRecent(string path) @@ -107,9 +105,11 @@ namespace BizHawk.Client.EmuHawk private void UpdateMessageLabel(bool saved = false) { - MessageLabel.Text = saved - ? Path.GetFileName(Global.CheatList.CurrentFileName) + " saved." - : Path.GetFileName(Global.CheatList.CurrentFileName) + (Global.CheatList.Changes ? " *" : ""); + MessageLabel.Text = saved + ? $"{Path.GetFileName(Global.CheatList.CurrentFileName)} saved." + : Global.CheatList.Changes + ? $"{Path.GetFileName(Global.CheatList.CurrentFileName)} *" + : Path.GetFileName(Global.CheatList.CurrentFileName); } public bool AskSaveChanges() @@ -331,7 +331,7 @@ namespace BizHawk.Client.EmuHawk { var cheat = SelectedCheats.First(); CheatEditor.SetCheat(cheat); - CheatGroupBox.Text = "Editing Cheat " + cheat.Name + " - " + cheat.AddressStr; + CheatGroupBox.Text = $"Editing Cheat {cheat.Name} - {cheat.AddressStr}"; } else { diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs index 133341652f..d8e5001f9f 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs @@ -75,7 +75,7 @@ namespace BizHawk.Client.EmuHawk { if (column == 0) { - text = string.Format("{0:X" + _pcRegisterSize + "}", _disassemblyLines[index].Address); + text = string.Format($"{{0:X{_pcRegisterSize}}}", _disassemblyLines[index].Address); } else if (column == 1) { @@ -139,16 +139,12 @@ namespace BizHawk.Client.EmuHawk { if (e.Type == ScrollEventType.SmallIncrement) { - IncrementCurrentAddress(); - Disassemble(); - DisassemblerView.Refresh(); + SmallIncrement(); } if (e.Type == ScrollEventType.SmallDecrement) { - DecrementCurrentAddress(); - Disassemble(); - DisassemblerView.Refresh(); + SmallDecrement(); } } @@ -166,12 +162,34 @@ namespace BizHawk.Client.EmuHawk } } + private void SmallIncrement() + { + IncrementCurrentAddress(); + Disassemble(); + DisassemblerView.Refresh(); + } + + private void SmallDecrement() + { + DecrementCurrentAddress(); + Disassemble(); + DisassemblerView.Refresh(); + } + private void DisassemblerView_KeyDown(object sender, KeyEventArgs e) { if (e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.C) // Ctrl + C { CopySelectedDisassembler(); } + else if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.PageDown) + { + SmallIncrement(); + } + else if (!e.Control && !e.Shift && !e.Alt && e.KeyCode == Keys.PageUp) + { + SmallDecrement(); + } } private void CopySelectedDisassembler() @@ -188,7 +206,7 @@ namespace BizHawk.Client.EmuHawk blob.AppendLine(); } - blob.Append(string.Format("{0:X" + _pcRegisterSize + "}", _disassemblyLines[index].Address)) + blob.Append(string.Format($"{{0:X{_pcRegisterSize}}}", _disassemblyLines[index].Address)) .Append(" ") .Append(_disassemblyLines[index].Mnemonic); } diff --git a/BizHawk.Client.EmuHawk/tools/GB/GBGPUView.cs b/BizHawk.Client.EmuHawk/tools/GB/GBGPUView.cs index 42a6507166..069d73f458 100644 --- a/BizHawk.Client.EmuHawk/tools/GB/GBGPUView.cs +++ b/BizHawk.Client.EmuHawk/tools/GB/GBGPUView.cs @@ -52,7 +52,7 @@ namespace BizHawk.Client.EmuHawk { _spriteback = Color.FromArgb(255, value); // force fully opaque panelSpriteBackColor.BackColor = _spriteback; - labelSpriteBackColor.Text = string.Format("({0},{1},{2})", _spriteback.R, _spriteback.G, _spriteback.B); + labelSpriteBackColor.Text = $"({_spriteback.R},{_spriteback.G},{_spriteback.B})"; } } @@ -634,9 +634,9 @@ namespace BizHawk.Client.EmuHawk int* pal = (int*)(sprite ? _sppal : _bgpal) + x * 4; int color = pal[y]; - sb.AppendLine(string.Format("Palette {0}", x)); - sb.AppendLine(string.Format("Color {0}", y)); - sb.AppendLine(string.Format("(R,G,B) = ({0},{1},{2})", color >> 16 & 255, color >> 8 & 255, color & 255)); + sb.AppendLine($"Palette {x}"); + sb.AppendLine($"Color {y}"); + sb.AppendLine($"(R,G,B) = ({color >> 16 & 255},{color >> 8 & 255},{color & 255})"); var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, 10), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); int* dest = (int*)lockdata.Scan0; @@ -679,9 +679,9 @@ namespace BizHawk.Client.EmuHawk int tileindex = y * 16 + x; int tileoffs = tileindex * 16; if (_cgb) - sb.AppendLine(string.Format("Tile #{0} @{2}:{1:x4}", tileindex, tileoffs + 0x8000, secondbank ? 1 : 0)); + sb.AppendLine($"Tile #{tileindex} @{(secondbank ? 1 : 0)}:{tileoffs + 0x8000:x4}"); else - sb.AppendLine(string.Format("Tile #{0} @{1:x4}", tileindex, tileoffs + 0x8000)); + sb.AppendLine($"Tile #{tileindex} @{tileoffs + 0x8000:x4}"); var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); DrawTile((byte*)_vram + tileoffs + (secondbank ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)tilespal); @@ -718,18 +718,18 @@ namespace BizHawk.Client.EmuHawk var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); if (!_cgb) { - sb.AppendLine(string.Format("{0} Map ({1},{2}) @{3:x4}", win ? "Win" : "BG", x, y, mapoffs + 0x8000)); - sb.AppendLine(string.Format(" Tile #{0} @{1:x4}", tileindex, tileoffs + 0x8000)); + sb.AppendLine($"{(win ? "Win" : "BG")} Map ({x},{y}) @{mapoffs + 0x8000:x4}"); + sb.AppendLine($" Tile #{tileindex} @{tileoffs + 0x8000:x4}"); DrawTile((byte*)_vram + tileoffs, (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_bgpal); } else { int tileext = mapbase[8192]; - sb.AppendLine(string.Format("{0} Map ({1},{2}) @{3:x4}", win ? "Win" : "BG", x, y, mapoffs + 0x8000)); - sb.AppendLine(string.Format(" Tile #{0} @{2}:{1:x4}", tileindex, tileoffs + 0x8000, tileext.Bit(3) ? 1 : 0)); - sb.AppendLine(string.Format(" Palette {0}", tileext & 7)); - sb.AppendLine(string.Format(" Flags {0}{1}{2}", tileext.Bit(5) ? 'H' : ' ', tileext.Bit(6) ? 'V' : ' ', tileext.Bit(7) ? 'P' : ' ')); + sb.AppendLine($"{(win ? "Win" : "BG")} Map ({x},{y}) @{mapoffs + 0x8000:x4}"); + sb.AppendLine($" Tile #{tileindex} @{(tileext.Bit(3) ? 1 : 0)}:{tileoffs + 0x8000:x4}"); + sb.AppendLine($" Palette {tileext & 7}"); + sb.AppendLine($" Flags {(tileext.Bit(5) ? 'H' : ' ')}{(tileext.Bit(6) ? 'V' : ' ')}{(tileext.Bit(7) ? 'P' : ' ')}"); DrawTileHv((byte*)_vram + tileoffs + (tileext.Bit(3) ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_bgpal + 4 * (tileext & 7), tileext.Bit(5), tileext.Bit(6)); } bmpViewDetails.BMP.UnlockBits(lockdata); @@ -765,26 +765,26 @@ namespace BizHawk.Client.EmuHawk if (tall) tilenum = vflip ? tilenum | 1 : tilenum & ~1; int tileoffs = tilenum * 16; - sb.AppendLine(string.Format("Sprite #{0} @{1:x4}", x, 4 * x + 0xfe00)); - sb.AppendLine(string.Format(" (x,y) = ({0},{1})", sx, sy)); + sb.AppendLine($"Sprite #{x} @{4 * x + 0xfe00:x4}"); + sb.AppendLine($" (x,y) = ({sx},{sy})"); var lockdata = bmpViewDetails.BMP.LockBits(new Rectangle(0, 0, 8, tall ? 16 : 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); if (_cgb) { - sb.AppendLine(string.Format(" Tile #{0} @{2}:{1:x4}", y == 1 ? tilenum ^ 1 : tilenum, tileoffs + 0x8000, flags.Bit(3) ? 1 : 0)); - sb.AppendLine(string.Format(" Palette {0}", flags & 7)); + sb.AppendLine($" Tile #{(y == 1 ? tilenum ^ 1 : tilenum)} @{(flags.Bit(3) ? 1 : 0)}:{tileoffs + 0x8000:x4}"); + sb.AppendLine($" Palette {flags & 7}"); DrawTileHv((byte*)_vram + tileoffs + (flags.Bit(3) ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_sppal + 4 * (flags & 7), hflip, vflip); if (tall) DrawTileHv((byte*)_vram + (tileoffs ^ 16) + (flags.Bit(3) ? 8192 : 0), (int*)(lockdata.Scan0 + lockdata.Stride * 8), lockdata.Stride / sizeof(int), (int*)_sppal + 4 * (flags & 7), hflip, vflip); } else { - sb.AppendLine(string.Format(" Tile #{0} @{1:x4}", y == 1 ? tilenum ^ 1 : tilenum, tileoffs + 0x8000)); - sb.AppendLine(string.Format(" Palette {0}", flags.Bit(4) ? 1 : 0)); + sb.AppendLine($" Tile #{(y == 1 ? tilenum ^ 1 : tilenum)} @{tileoffs + 0x8000:x4}"); + sb.AppendLine($" Palette {(flags.Bit(4) ? 1 : 0)}"); DrawTileHv((byte*)_vram + tileoffs, (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_sppal + (flags.Bit(4) ? 4 : 0), hflip, vflip); if (tall) DrawTileHv((byte*)_vram + (tileoffs ^ 16), (int*)(lockdata.Scan0 + lockdata.Stride * 8), lockdata.Stride / sizeof(int), (int*)_sppal + 4 * (flags.Bit(4) ? 4 : 0), hflip, vflip); } - sb.AppendLine(string.Format(" Flags {0}{1}{2}", hflip ? 'H' : ' ', vflip ? 'V' : ' ', flags.Bit(7) ? 'P' : ' ')); + sb.AppendLine($" Flags {(hflip ? 'H' : ' ')}{(vflip ? 'V' : ' ')}{(flags.Bit(7) ? 'P' : ' ')}"); bmpViewDetails.BMP.UnlockBits(lockdata); labelDetails.Text = sb.ToString(); bmpViewDetails.Refresh(); @@ -946,7 +946,7 @@ namespace BizHawk.Client.EmuHawk { var bv = found as BmpView; Clipboard.SetImage(bv.BMP); - labelClipboard.Text = found.Text + " copied to clipboard."; + labelClipboard.Text = $"{found.Text} copied to clipboard."; _messagetimer.Stop(); _messagetimer.Start(); } diff --git a/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs b/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs index 5a3bc87264..1e88e194af 100644 --- a/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs @@ -458,17 +458,17 @@ namespace BizHawk.Client.EmuHawk GBGGDecode(GGCodeMaskBox.Text, ref val, ref add, ref cmp); if (add > -1) { - AddressBox.Text = string.Format("{0:X4}", add); + AddressBox.Text = $"{add:X4}"; } if (val > -1) { - ValueBox.Text = string.Format("{0:X2}", val); + ValueBox.Text = $"{val:X2}"; } if (cmp > -1) { - CompareBox.Text = string.Format("{0:X2}", cmp); + CompareBox.Text = $"{cmp:X2}"; } else { diff --git a/BizHawk.Client.EmuHawk/tools/GBA/GBAGPUView.cs b/BizHawk.Client.EmuHawk/tools/GBA/GBAGPUView.cs index 41b3baf178..81b7cb32b4 100644 --- a/BizHawk.Client.EmuHawk/tools/GBA/GBAGPUView.cs +++ b/BizHawk.Client.EmuHawk/tools/GBA/GBAGPUView.cs @@ -790,7 +790,7 @@ namespace BizHawk.Client.EmuHawk private void hScrollBar1_ValueChanged(object sender, EventArgs e) { _cbscanline = (hScrollBar1.Value + 160) % 228; - radioButtonScanline.Text = "Scanline " + _cbscanline; + radioButtonScanline.Text = $"Scanline {_cbscanline}"; } private void radioButtonManual_CheckedChanged(object sender, EventArgs e) @@ -838,7 +838,7 @@ namespace BizHawk.Client.EmuHawk if (found is BmpView) { Clipboard.SetImage((found as BmpView).BMP); - labelClipboard.Text = found.Text + " copied to clipboard."; + labelClipboard.Text = $"{found.Text} copied to clipboard."; timerMessage.Stop(); timerMessage.Start(); } diff --git a/BizHawk.Client.EmuHawk/tools/GameShark.cs b/BizHawk.Client.EmuHawk/tools/GameShark.cs index 027630daf2..7cbfefe75e 100644 --- a/BizHawk.Client.EmuHawk/tools/GameShark.cs +++ b/BizHawk.Client.EmuHawk/tools/GameShark.cs @@ -311,9 +311,9 @@ namespace BizHawk.Client.EmuHawk int cmp = 0; parseString = SingleCheat.Replace("-", ""); GBGGDecode(parseString, ref val, ref add, ref cmp); - RAMAddress = string.Format("{0:X4}", add); - RAMValue = string.Format("{0:X2}", val); - RAMCompare = string.Format("{0:X2}", cmp); + RAMAddress = $"{add:X4}"; + RAMValue = $"{val:X2}"; + RAMCompare = $"{cmp:X2}"; } //Game Genie else if (SingleCheat.Contains("-") == true && SingleCheat.LastIndexOf("-") != 7 && SingleCheat.IndexOf("-") != 3) @@ -382,7 +382,7 @@ namespace BizHawk.Client.EmuHawk //Someone broke the world? catch (Exception ex) { - MessageBox.Show("An Error occured: " + ex.GetType().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //Provided by mGBA and endrift @@ -457,8 +457,8 @@ namespace BizHawk.Client.EmuHawk //op1 has the Address //op2 has the Value //Sum, is pointless? - RAMAddress = string.Format("{0:X8}", op1); - RAMValue = string.Format("{0:X8}", op2); + RAMAddress = $"{op1:X8}"; + RAMValue = $"{op2:X8}"; GBAGameShark(); } //We don't do Else If after the if here because it won't allow us to verify the second code check. @@ -492,8 +492,8 @@ namespace BizHawk.Client.EmuHawk //op1 has the Address //op2 has the Value //Sum, is pointless? - RAMAddress = string.Format("{0:X8}", op1); - RAMValue = string.Format("{0:X8}", op2); + RAMAddress = $"{op1:X8}"; + RAMValue = $"{op2:X8}"; blnEncrypted = true; GBAActionReplay(); } @@ -560,9 +560,9 @@ namespace BizHawk.Client.EmuHawk // //op1 has the Address // //op2 has the Value // //Sum, is pointless? - // RAMAddress = string.Format("{0:X8}", op1); + // RAMAddress = $"{op1:X8}"; // //RAMAddress = RAMAddress.Remove(0, 1); - // RAMValue = string.Format("{0:X8}", op2); + // RAMValue = $"{op2:X8}"; // // && RAMAddress[6] == '0' //} @@ -2052,12 +2052,12 @@ namespace BizHawk.Client.EmuHawk string RealAddress = null; string realValue = null; RealAddress = RAMValue.Remove(0, 1); - //MessageBox.Show("Real Address: " + RealAddress); + //MessageBox.Show($"Real Address: {RealAddress}"); //We need the next line try { loopValue += 1; - //MessageBox.Show("Loop Value: " + loopValue.ToString()); + //MessageBox.Show($"Loop Value: {loopValue}"); SingleCheat = txtCheat.Lines[loopValue].ToUpper(); //We need to parse now. if (SingleCheat.Length == 17 && SingleCheat.IndexOf(" ") == 8) @@ -2087,8 +2087,8 @@ namespace BizHawk.Client.EmuHawk //op1 has the Address //op2 has the Value //Sum, is pointless? - RAMAddress = string.Format("{0:X8}", op1); - RAMValue = string.Format("{0:X8}", op2); + RAMAddress = $"{op1:X8}"; + RAMValue = $"{op2:X8}"; } else if (blnEncrypted == false) { @@ -2134,7 +2134,7 @@ namespace BizHawk.Client.EmuHawk catch (Exception ex) { //We should warn the user. - MessageBox.Show("An Error occured: " + ex.GetType().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (RAMAddress.StartsWith("080") == true) @@ -2563,7 +2563,7 @@ namespace BizHawk.Client.EmuHawk //Someone broke the world? catch (Exception ex) { - MessageBox.Show("An Error occured: " + ex.GetType().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } @@ -2691,7 +2691,7 @@ namespace BizHawk.Client.EmuHawk //Someone broke the world? catch (Exception ex) { - MessageBox.Show("An Error occured: " + ex.GetType().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void NES() @@ -2734,9 +2734,9 @@ namespace BizHawk.Client.EmuHawk _NESgameGenieTable.TryGetValue(code[5], out x); Address |= (x & 0x07) << 8; Value |= x & 0x08; - RAMAddress = string.Format("{0:X4}", Address); - RAMValue = string.Format("{0:X2}", Value); - strCompare = string.Format("{0:X2}", Compare); + RAMAddress = $"{Address:X4}"; + RAMValue = $"{Value:X2}"; + strCompare = $"{Compare:X2}"; } else if (SingleCheat.Length == 8) { @@ -2778,9 +2778,9 @@ namespace BizHawk.Client.EmuHawk _NESgameGenieTable.TryGetValue(code[7], out x); Compare |= (x & 0x07) << 4; Value |= x & 0x08; - RAMAddress = string.Format("{0:X4}", Address); - RAMValue = string.Format("{0:X2}", Value); - strCompare = string.Format("{0:X2}", Compare); + RAMAddress = $"{Address:X4}"; + RAMValue = $"{Value:X2}"; + strCompare = $"{Compare:X2}"; } } if (SingleCheat.Length != 6 && SingleCheat.Length != 8) @@ -2816,7 +2816,7 @@ namespace BizHawk.Client.EmuHawk //Someone broke the world? catch (Exception ex) { - MessageBox.Show("An Error occured: " + ex.GetType().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void PSX() @@ -2927,7 +2927,7 @@ namespace BizHawk.Client.EmuHawk //Someone broke the world? catch (Exception ex) { - MessageBox.Show("An Error occured: " + ex.GetType().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -3003,7 +3003,7 @@ namespace BizHawk.Client.EmuHawk //Someone broke the world? catch (Exception ex) { - MessageBox.Show("An Error occured: " + ex.GetType().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //This also handles Game Gear due to shared hardware. Go figure. @@ -3018,9 +3018,9 @@ namespace BizHawk.Client.EmuHawk int cmp = 0; parseString = SingleCheat.Replace("-", ""); GBGGDecode(parseString, ref val, ref add, ref cmp); - RAMAddress = string.Format("{0:X4}", add); - RAMValue = string.Format("{0:X2}", val); - RAMCompare = string.Format("{0:X2}", cmp); + RAMAddress = $"{add:X4}"; + RAMValue = $"{val:X2}"; + RAMCompare = $"{cmp:X2}"; } //Action Replay else if (SingleCheat.IndexOf("-") == 3 && SingleCheat.Length == 9) @@ -3063,7 +3063,7 @@ namespace BizHawk.Client.EmuHawk //Someone broke the world? catch (Exception ex) { - MessageBox.Show("An Error occured: " + ex.GetType().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //Original code from adelikat @@ -3142,8 +3142,8 @@ namespace BizHawk.Client.EmuHawk //We have to remove the - since it will cause issues later on. input = SingleCheat.Replace("-", ""); SnesGGDecode(input, ref val, ref add); - RAMAddress = string.Format("{0:X6}", add); - RAMValue = string.Format("{0:X2}", val); + RAMAddress = $"{add:X6}"; + RAMValue = $"{val:X2}"; //We trim the first value here to make it work. RAMAddress = RAMAddress.Remove(0, 1); //Note, it's not actually a byte, but a Word. However, we are using this to keep from repeating code. @@ -3203,7 +3203,7 @@ namespace BizHawk.Client.EmuHawk //Someone broke the world? catch (Exception ex) { - MessageBox.Show("An Error occured: " + ex.GetType().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"An Error occured: {ex.GetType()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void btnClear_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs b/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs index dd4f38c0d7..907109e9a5 100644 --- a/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs @@ -187,8 +187,8 @@ namespace BizHawk.Client.EmuHawk int val = 0; int add = 0; GenGGDecode(GGCodeMaskBox.Text, ref val, ref add); - AddressBox.Text = string.Format("{0:X6}", add); - ValueBox.Text = string.Format("{0:X4}", val); + AddressBox.Text = $"{add:X6}"; + ValueBox.Text = $"{val:X4}"; AddCheatButton.Enabled = true; } else diff --git a/BizHawk.Client.EmuHawk/tools/Genesis/VDPViewer.cs b/BizHawk.Client.EmuHawk/tools/Genesis/VDPViewer.cs index 921bddef33..70cf9af60e 100644 --- a/BizHawk.Client.EmuHawk/tools/Genesis/VDPViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/Genesis/VDPViewer.cs @@ -169,7 +169,7 @@ namespace BizHawk.Client.EmuHawk int idx = e.Y / 16; idx = Math.Min(3, Math.Max(idx, 0)); palindex = idx; - DrawTiles(); + UpdateValues(); } private void VDPViewer_KeyDown(object sender, KeyEventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index 577fc1bee6..26c3997900 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -394,7 +394,7 @@ namespace BizHawk.Client.EmuHawk return '.'; } - if (val >= 0x80) + if (val >= 0x7F) { return '.'; } @@ -545,7 +545,7 @@ namespace BizHawk.Client.EmuHawk addrStr.Append(" "); } - addrStr.AppendLine(_addr.ToHexString(_numDigits) + " |"); + addrStr.AppendLine($"{_addr.ToHexString(_numDigits)} |"); } return addrStr.ToString(); @@ -700,9 +700,8 @@ namespace BizHawk.Client.EmuHawk private void UpdateGroupBoxTitle() { - var addressesString = "0x" + string.Format("{0:X8}", _domain.Size / DataSize).TrimStart('0'); - MemoryViewerBox.Text = Emulator.SystemId + " " + _domain + (_domain.CanPoke() ? "" : " (READ-ONLY)") + - " - " + addressesString + " addresses"; + var addressesString = "0x" + $"{_domain.Size / DataSize:X8}".TrimStart('0'); + MemoryViewerBox.Text = $"{Emulator.SystemId} {_domain}{(_domain.CanPoke() ? string.Empty : " (READ-ONLY)")} - {addressesString} addresses"; } private void ClearNibbles() @@ -769,8 +768,7 @@ namespace BizHawk.Client.EmuHawk Text += " - Editing Address 0x" + string.Format(_numDigitsStr, _addressHighlighted); if (_secondaryHighlightedAddresses.Any()) { - Text += string.Format(" (Selected 0x{0:X})", _secondaryHighlightedAddresses.Count() + - (_secondaryHighlightedAddresses.Contains(_addressHighlighted) ? 0 : 1)); + Text += $" (Selected 0x{_secondaryHighlightedAddresses.Count() + (_secondaryHighlightedAddresses.Contains(_addressHighlighted) ? 0 : 1):X})"; } } } @@ -797,7 +795,7 @@ namespace BizHawk.Client.EmuHawk } _numDigits = GetNumDigits(_domain.Size); - _numDigitsStr = "{0:X" + _numDigits + "} "; + _numDigitsStr = $"{{0:X{_numDigits}}} "; } private void SetDataSize(int size) @@ -805,7 +803,7 @@ namespace BizHawk.Client.EmuHawk if (size == 1 || size == 2 || size == 4) { DataSize = size; - _digitFormatString = "{0:X" + (DataSize * 2) + "} "; + _digitFormatString = $"{{0:X{DataSize * 2}}} "; SetHeader(); UpdateGroupBoxTitle(); UpdateValues(); @@ -907,7 +905,7 @@ namespace BizHawk.Client.EmuHawk { var extension = Path.GetExtension(RomName); - return "Binary (*" + extension + ")|*" + extension + "|All Files|*.*"; + return $"Binary (*{extension})|*{extension}|All Files|*.*"; } return "Binary (*.bin)|*.bin|All Files|*.*"; @@ -988,7 +986,7 @@ namespace BizHawk.Client.EmuHawk if (_domain.Name == "File on Disk") { - sfd.FileName = Path.GetFileNameWithoutExtension(RomName) + ".txt"; + sfd.FileName = $"{Path.GetFileNameWithoutExtension(RomName)}.txt"; } else { @@ -1386,7 +1384,7 @@ namespace BizHawk.Client.EmuHawk { for (var j = 0; j < 16; j++) { - sb.Append(string.Format("{0:X2} ", _domain.PeekByte((i * 16) + j))); + sb.Append($"{_domain.PeekByte((i * 16) + j):X2} "); } sb.AppendLine(); @@ -1412,7 +1410,7 @@ namespace BizHawk.Client.EmuHawk var ofd = new OpenFileDialog { - FileName = Path.GetFileNameWithoutExtension(romName) + ".tbl", + FileName = $"{Path.GetFileNameWithoutExtension(romName)}.tbl", InitialDirectory = intialDirectory, Filter = "Text Table files (*.tbl)|*.tbl|All Files|*.*", RestoreDirectory = false @@ -2332,7 +2330,7 @@ namespace BizHawk.Client.EmuHawk if (HasNibbles()) { - e.Graphics.DrawString(MakeNibbles(), new Font("Courier New", 8, FontStyle.Italic), Brushes.Black, new Point(158, 4)); + //e.Graphics.DrawString(MakeNibbles(), new Font("Courier New", 8, FontStyle.Italic), Brushes.Black, new Point(158, 4)); } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs index 44a352326c..7d3a8a7fd9 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs @@ -320,7 +320,7 @@ namespace BizHawk.Client.EmuHawk { Global.Config.TargetZoomFactors[Emulator.SystemId] = size; GlobalWin.MainForm.FrameBufferResized(); - GlobalWin.OSD.AddMessage("Window size set to " + size + "x"); + GlobalWin.OSD.AddMessage($"Window size set to {size}x"); } else { diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Communication.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Communication.cs index fdae9f132d..b1f5b4b389 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Communication.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Communication.cs @@ -55,7 +55,7 @@ namespace BizHawk.Client.EmuHawk [LuaMethod("socketServerSend", "sends a string to the Socket server")] public string SocketServerSend(string SendString) { - return "Sent : " + GlobalWin.socketServer.SendString(SendString).ToString() + " bytes"; + return $"Sent : {GlobalWin.socketServer.SendString(SendString)} bytes"; } [LuaMethod("socketServerResponse", "receives a message from the Socket server")] public string SocketServerResponse() diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Console.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Console.cs index 93aa46f4fa..d4eae545c1 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Console.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Console.cs @@ -87,7 +87,7 @@ namespace BizHawk.Client.EmuHawk if (outputs == null) { - GlobalWin.Tools.LuaConsole.WriteToOutputWindow("(no return)" + terminator); + GlobalWin.Tools.LuaConsole.WriteToOutputWindow($"(no return){terminator}"); return; } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs index 3b94fbf40d..a836574ddb 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs @@ -754,7 +754,7 @@ namespace BizHawk.Client.EmuHawk { if (!File.Exists(path)) { - ConsoleLuaLibrary.Log("File not found: " + path + "\nScript Terminated"); + ConsoleLuaLibrary.Log($"File not found: {path}\nScript Terminated"); return; } try @@ -823,7 +823,7 @@ namespace BizHawk.Client.EmuHawk { if (!File.Exists(path)) { - ConsoleLuaLibrary.Log("File not found: " + path + "\nScript Terminated"); + ConsoleLuaLibrary.Log($"File not found: {path}\nScript Terminated"); return; } try diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs index 814c5ea53f..1a4bd40f4f 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs @@ -323,7 +323,7 @@ namespace BizHawk.Client.EmuHawk { if (!File.Exists(path)) { - Log("File not found: " + path); + Log($"File not found: {path}"); return; } @@ -365,7 +365,7 @@ namespace BizHawk.Client.EmuHawk { if (!File.Exists(path)) { - Log("File not found: " + path); + Log($"File not found: {path}"); return; } @@ -511,7 +511,7 @@ namespace BizHawk.Client.EmuHawk } [LuaMethodExample("gui.drawText( 16, 32, \"Some message\", 0x7F0000FF, 0x00007FFF, 8, \"Arial Narrow\", \"bold\", \"center\", \"middle\" );")] - [LuaMethod("drawText", "Draws the given message in the emulator screen space (like all draw functions) at the given x,y coordinates and the given color. The default color is white. A fontfamily can be specified and is monospace generic if none is specified (font family options are the same as the .NET FontFamily class). The fontsize default is 12. The default font style is regular. Font style options are regular, bold, italic, strikethrough, underline. Horizontal alignment options are left (default), center, or right. Vertical alignment options are bottom (default), middle, or top. Alignment options specify which ends of the text will be drawn at the x and y coordinates.")] + [LuaMethod("drawText", "Draws the given message in the emulator screen space (like all draw functions) at the given x,y coordinates and the given color. The default color is white. A fontfamily can be specified and is monospace generic if none is specified (font family options are the same as the .NET FontFamily class). The fontsize default is 12. The default font style is regular. Font style options are regular, bold, italic, strikethrough, underline. Horizontal alignment options are left (default), center, or right. Vertical alignment options are bottom (default), middle, or top. Alignment options specify which ends of the text will be drawn at the x and y coordinates. For pixel-perfect font look, make sure to disable aspect ratio correction.")] public void DrawText( int x, int y, diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs index b07919010d..a99aa9ac88 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Savestate.cs @@ -37,7 +37,7 @@ namespace BizHawk.Client.EmuHawk { if (slotNum >= 0 && slotNum <= 9) { - GlobalWin.MainForm.LoadQuickSave("QuickSave" + slotNum, true); + GlobalWin.MainForm.LoadQuickSave($"QuickSave{slotNum}", true); } } @@ -54,7 +54,7 @@ namespace BizHawk.Client.EmuHawk { if (slotNum >= 0 && slotNum <= 9) { - GlobalWin.MainForm.SaveQuickSave("QuickSave" + slotNum); + GlobalWin.MainForm.SaveQuickSave($"QuickSave{slotNum}"); } } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs index 30b1c40f7c..08efa298d3 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs @@ -13,7 +13,7 @@ using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { - public class EmuLuaLibrary + public class EmuLuaLibrary : PlatformEmuLuaLibrary { public EmuLuaLibrary() { @@ -82,16 +82,6 @@ namespace BizHawk.Client.EmuHawk } } - public bool IsRebootingCore { get; set; } // pretty hacky.. we dont want a lua script to be able to restart itself by rebooting the core - - private readonly Dictionary Libraries = new Dictionary(); - public LuaFileList ScriptList { get; } = new LuaFileList(); - - public IEnumerable RunningScripts - { - get { return ScriptList.Where(lf => lf.Enabled); } - } - private Lua _lua = new Lua(); private Lua _currThread; @@ -101,9 +91,7 @@ namespace BizHawk.Client.EmuHawk private EmulatorLuaLibrary EmulatorLuaLibrary => (EmulatorLuaLibrary)Libraries[typeof(EmulatorLuaLibrary)]; - public GuiLuaLibrary GuiLibrary => (GuiLuaLibrary)Libraries[typeof(GuiLuaLibrary)]; - - public void Restart(IEmulatorServiceProvider newServiceProvider) + public override void Restart(IEmulatorServiceProvider newServiceProvider) { foreach (var lib in Libraries) { @@ -111,7 +99,7 @@ namespace BizHawk.Client.EmuHawk } } - public void StartLuaDrawing() + public override void StartLuaDrawing() { if (ScriptList.Any() && GuiLibrary.SurfaceIsNull) { @@ -119,7 +107,7 @@ namespace BizHawk.Client.EmuHawk } } - public void EndLuaDrawing() + public override void EndLuaDrawing() { if (ScriptList.Any()) { @@ -127,34 +115,35 @@ namespace BizHawk.Client.EmuHawk } } - public LuaDocumentation Docs { get; } public bool IsRunning { get; set; } - public EventWaitHandle LuaWait { get; private set; } public bool FrameAdvanceRequested { get; private set; } - public LuaFunctionList RegisteredFunctions => EventsLibrary.RegisteredFunctions; + public override LuaFunctionList GetRegisteredFunctions() + { + return EventsLibrary.RegisteredFunctions; + } - public void WindowClosed(IntPtr handle) + public override void WindowClosed(IntPtr handle) { FormsLibrary.WindowClosed(handle); } - public void CallSaveStateEvent(string name) + public override void CallSaveStateEvent(string name) { EventsLibrary.CallSaveStateEvent(name); } - public void CallLoadStateEvent(string name) + public override void CallLoadStateEvent(string name) { EventsLibrary.CallLoadStateEvent(name); } - public void CallFrameBeforeEvent() + public override void CallFrameBeforeEvent() { EventsLibrary.CallFrameBeforeEvent(); } - public void CallFrameAfterEvent() + public override void CallFrameAfterEvent() { EventsLibrary.CallFrameAfterEvent(); } @@ -164,7 +153,12 @@ namespace BizHawk.Client.EmuHawk EventsLibrary.CallExitEvent(thread); } - public void Close() + public override void CallExitEvent(LuaFile lf) + { + CallExitEvent(lf.Thread); + } + + public override void Close() { FormsLibrary.DestroyAll(); _lua.Close(); @@ -187,7 +181,12 @@ namespace BizHawk.Client.EmuHawk return lua; } - public void ExecuteString(string command) + public override void SpawnAndSetFileThread(string pathToLoad, LuaFile lf) + { + lf.Thread = SpawnCoroutine(pathToLoad); + } + + public override void ExecuteString(string command) { _currThread = _lua.NewThread(); _currThread.DoString(command); @@ -232,6 +231,11 @@ namespace BizHawk.Client.EmuHawk } } + public override ResumeResult ResumeScriptFromThreadOf(LuaFile lf) + { + return ResumeScript(lf.Thread); + } + public static void Print(params object[] outputs) { ConsoleLuaLibrary.Log(outputs); diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/NotReallyLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/NotReallyLuaLibrary.cs new file mode 100644 index 0000000000..e47b7e750b --- /dev/null +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/NotReallyLuaLibrary.cs @@ -0,0 +1,60 @@ +using System; + +using BizHawk.Client.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.EmuHawk +{ + /// + /// Methods intentionally blank. + /// + public sealed class NotReallyLuaLibrary : PlatformEmuLuaLibrary + { + public override void CallExitEvent(LuaFile lf) + { + } + public override void CallFrameAfterEvent() + { + } + public override void CallFrameBeforeEvent() + { + } + public override void CallLoadStateEvent(string name) + { + } + public override void CallSaveStateEvent(string name) + { + } + public override void Close() + { + } + public override void EndLuaDrawing() + { + } + public override void ExecuteString(string command) + { + } + private static readonly LuaFunctionList EmptyLuaFunList = new LuaFunctionList(); + public override LuaFunctionList GetRegisteredFunctions() + { + return EmptyLuaFunList; + } + public override void Restart(IEmulatorServiceProvider newServiceProvider) + { + } + private static readonly EmuLuaLibrary.ResumeResult EmptyResumeResult = new EmuLuaLibrary.ResumeResult(); + public override EmuLuaLibrary.ResumeResult ResumeScriptFromThreadOf(LuaFile lf) + { + return EmptyResumeResult; + } + public override void SpawnAndSetFileThread(string pathToLoad, LuaFile lf) + { + } + public override void StartLuaDrawing() + { + } + public override void WindowClosed(IntPtr handle) + { + } + } +} \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/PlatformEmuLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/PlatformEmuLuaLibrary.cs new file mode 100644 index 0000000000..93c99a0427 --- /dev/null +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/PlatformEmuLuaLibrary.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +using BizHawk.Client.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.EmuHawk +{ + public abstract class PlatformEmuLuaLibrary + { + public LuaDocumentation Docs { get; protected set; } + + public GuiLuaLibrary GuiLibrary => (GuiLuaLibrary) Libraries[typeof(GuiLuaLibrary)]; + + public bool IsRebootingCore { get; set; } // pretty hacky.. we dont want a lua script to be able to restart itself by rebooting the core + + protected readonly Dictionary Libraries = new Dictionary(); + + public EventWaitHandle LuaWait { get; protected set; } + + public IEnumerable RunningScripts + { + get { return ScriptList.Where(lf => lf.Enabled); } + } + + public readonly LuaFileList ScriptList = new LuaFileList(); + + public abstract void CallExitEvent(LuaFile lf); + public abstract void CallFrameAfterEvent(); + public abstract void CallFrameBeforeEvent(); + public abstract void CallLoadStateEvent(string name); + public abstract void CallSaveStateEvent(string name); + public abstract void Close(); + public abstract void EndLuaDrawing(); + public abstract void ExecuteString(string command); + public abstract LuaFunctionList GetRegisteredFunctions(); + public abstract void Restart(IEmulatorServiceProvider newServiceProvider); + public abstract EmuLuaLibrary.ResumeResult ResumeScriptFromThreadOf(LuaFile lf); + public abstract void SpawnAndSetFileThread(string pathToLoad, LuaFile lf); + public abstract void StartLuaDrawing(); + public abstract void WindowClosed(IntPtr handle); + } +} \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.cs index 58efd9554a..b3d0f5f424 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaCanvas.cs @@ -186,7 +186,7 @@ namespace BizHawk.Client.EmuHawk { if (!File.Exists(path)) { - ConsoleLuaLibrary.Log("File not found: " + path + "\nScript Terminated"); + ConsoleLuaLibrary.Log($"File not found: {path}\nScript Terminated"); return; } @@ -212,7 +212,7 @@ namespace BizHawk.Client.EmuHawk { if (!File.Exists(path)) { - ConsoleLuaLibrary.Log("File not found: " + path + "\nScript Terminated"); + ConsoleLuaLibrary.Log($"File not found: {path}\nScript Terminated"); return; } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 881e32d219..17b646b63c 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -7,10 +7,11 @@ using System.Linq; using System.Text.RegularExpressions; using System.Windows.Forms; -using BizHawk.Emulation.Common; using BizHawk.Client.Common; -using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Client.EmuHawk.ToolExtensions; +using BizHawk.Client.EmuHawk.WinFormExtensions; +using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk { @@ -59,6 +60,19 @@ namespace BizHawk.Client.EmuHawk SaveColumnInfo(LuaListView, Settings.Columns); GlobalWin.DisplayManager.ClearLuaSurfaces(); + + if (GlobalWin.DisplayManager.ClientExtraPadding != Padding.Empty) + { + GlobalWin.DisplayManager.ClientExtraPadding = new Padding(0); + GlobalWin.MainForm.FrameBufferResized(); + } + + if (GlobalWin.DisplayManager.GameExtraPadding != Padding.Empty) + { + GlobalWin.DisplayManager.GameExtraPadding = new Padding(0); + GlobalWin.MainForm.FrameBufferResized(); + } + LuaImp.GuiLibrary.DrawFinish(); CloseLua(); } @@ -78,7 +92,7 @@ namespace BizHawk.Client.EmuHawk LuaSandbox.DefaultLogger = ConsoleLog; } - public EmuLuaLibrary LuaImp { get; private set; } + public PlatformEmuLuaLibrary LuaImp { get; private set; } public bool UpdateBefore => true; @@ -154,15 +168,15 @@ namespace BizHawk.Client.EmuHawk foreach (var file in runningScripts) { - LuaImp.CallExitEvent(file.Thread); + LuaImp.CallExitEvent(file); - var functions = LuaImp.RegisteredFunctions + var functions = LuaImp.GetRegisteredFunctions() .Where(lf => lf.Lua == file.Thread) .ToList(); foreach (var function in functions) { - LuaImp.RegisteredFunctions.Remove(function); + LuaImp.GetRegisteredFunctions().Remove(function); } UpdateRegisteredFunctionsDialog(); @@ -172,13 +186,15 @@ namespace BizHawk.Client.EmuHawk } var currentScripts = LuaImp?.ScriptList; // Temp fix for now - LuaImp = new EmuLuaLibrary(Emulator.ServiceProvider); + LuaImp = PlatformLinkedLibSingleton.RunningOnUnix + ? (PlatformEmuLuaLibrary) new NotReallyLuaLibrary() + : (PlatformEmuLuaLibrary) new EmuLuaLibrary(Emulator.ServiceProvider); if (currentScripts != null) { LuaImp.ScriptList.AddRange(currentScripts); } - InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray()); + InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => $"{a.Library}.{a.Name}").ToArray()); foreach (var file in runningScripts) { @@ -188,7 +204,7 @@ namespace BizHawk.Client.EmuHawk { LuaSandbox.Sandbox(file.Thread, () => { - file.Thread = LuaImp.SpawnCoroutine(pathToLoad); + LuaImp.SpawnAndSetFileThread(pathToLoad, file); LuaSandbox.CreateSandbox(file.Thread, Path.GetDirectoryName(pathToLoad)); file.State = LuaFile.RunState.Running; }, () => @@ -238,7 +254,7 @@ namespace BizHawk.Client.EmuHawk private void OnChanged(object source, FileSystemEventArgs e) { - string message = "File: " + e.FullPath + " " + e.ChangeType; + string message = $"File: {e.FullPath} {e.ChangeType}"; Invoke(new MethodInvoker(delegate { RefreshScriptMenuItem_Click(null, null); @@ -306,7 +322,7 @@ namespace BizHawk.Client.EmuHawk LuaSandbox.Sandbox(null, () => { string pathToLoad = ProcessPath(file.Path); - file.Thread = LuaImp.SpawnCoroutine(file.Path); + LuaImp.SpawnAndSetFileThread(file.Path, file); LuaSandbox.CreateSandbox(file.Thread, Path.GetDirectoryName(pathToLoad)); }, () => { @@ -435,15 +451,15 @@ namespace BizHawk.Client.EmuHawk if (total == 1) { - message += total + " script (" + active + " active, " + paused + " paused)"; + message += $"{total} script ({active} active, {paused} paused)"; } else if (total == 0) { - message += total + " scripts"; + message += $"{total} scripts"; } else { - message += total + " scripts (" + active + " active, " + paused + " paused)"; + message += $"{total} scripts ({active} active, {paused} paused)"; } NumberOfScripts.Text = message; @@ -552,10 +568,10 @@ namespace BizHawk.Client.EmuHawk var prohibit = lf.FrameWaiting && !includeFrameWaiters; if (!prohibit) { - var result = LuaImp.ResumeScript(lf.Thread); + var result = LuaImp.ResumeScriptFromThreadOf(lf); if (result.Terminated) { - LuaImp.CallExitEvent(lf.Thread); + LuaImp.CallExitEvent(lf); lf.Stop(); UpdateDialog(); } @@ -620,7 +636,7 @@ namespace BizHawk.Client.EmuHawk if (file != null) { LuaImp.ScriptList.SaveSession(file.FullName); - OutputMessages.Text = Path.GetFileName(LuaImp.ScriptList.Filename) + " saved."; + OutputMessages.Text = $"{Path.GetFileName(LuaImp.ScriptList.Filename)} saved."; } } @@ -753,7 +769,7 @@ namespace BizHawk.Client.EmuHawk SaveSessionAs(); } - OutputMessages.Text = Path.GetFileName(LuaImp.ScriptList.Filename) + " saved."; + OutputMessages.Text = $"{Path.GetFileName(LuaImp.ScriptList.Filename)} saved."; } } @@ -786,7 +802,7 @@ namespace BizHawk.Client.EmuHawk SelectAllMenuItem.Enabled = LuaImp.ScriptList.Any(); StopAllScriptsMenuItem.Enabled = LuaImp.ScriptList.Any(script => script.Enabled); - RegisteredFunctionsMenuItem.Enabled = LuaImp.RegisteredFunctions.Any(); + RegisteredFunctionsMenuItem.Enabled = LuaImp.GetRegisteredFunctions().Any(); } private void NewScriptMenuItem_Click(object sender, EventArgs e) @@ -840,26 +856,26 @@ namespace BizHawk.Client.EmuHawk else if (!file.Enabled && file.Thread != null) { - LuaImp.CallExitEvent(file.Thread); + LuaImp.CallExitEvent(file); var items = SelectedItems.ToList(); foreach (var sitem in items) { var temp = sitem; - var functions = LuaImp.RegisteredFunctions.Where(lf => lf.Lua == temp.Thread).ToList(); + var functions = LuaImp.GetRegisteredFunctions().Where(lf => lf.Lua == temp.Thread).ToList(); foreach (var function in functions) { - LuaImp.RegisteredFunctions.Remove(function); + LuaImp.GetRegisteredFunctions().Remove(function); } UpdateRegisteredFunctionsDialog(); } - LuaImp.CallExitEvent(file.Thread); + LuaImp.CallExitEvent(file); file.Stop(); if (Global.Config.RemoveRegisteredFunctionsOnToggle) { - LuaImp.RegisteredFunctions.ClearAll(); + LuaImp.GetRegisteredFunctions().ClearAll(); } } } @@ -879,7 +895,7 @@ namespace BizHawk.Client.EmuHawk ? item.Path : PathManager.MakeProgramRelativePath(item.Path); - item.Thread = LuaImp.SpawnCoroutine(pathToLoad); + LuaImp.SpawnAndSetFileThread(pathToLoad, item); LuaSandbox.CreateSandbox(item.Thread, Path.GetDirectoryName(pathToLoad)); }, () => { @@ -895,7 +911,7 @@ namespace BizHawk.Client.EmuHawk } catch (IOException) { - ConsoleLog("Unable to access file " + item.Path); + ConsoleLog($"Unable to access file {item.Path}"); } catch (Exception ex) { @@ -933,10 +949,10 @@ namespace BizHawk.Client.EmuHawk foreach (var item in items) { var temp = item; - var functions = LuaImp.RegisteredFunctions.Where(x => x.Lua == temp.Thread).ToList(); + var functions = LuaImp.GetRegisteredFunctions().Where(x => x.Lua == temp.Thread).ToList(); foreach (var function in functions) { - LuaImp.RegisteredFunctions.Remove(function); + LuaImp.GetRegisteredFunctions().Remove(function); } LuaImp.ScriptList.Remove(item); @@ -957,7 +973,7 @@ namespace BizHawk.Client.EmuHawk { InitialDirectory = Path.GetDirectoryName(script.Path), DefaultExt = ".lua", - FileName = Path.GetFileNameWithoutExtension(script.Path) + " (1)", + FileName = $"{Path.GetFileNameWithoutExtension(script.Path)} (1)", OverwritePrompt = true, Filter = "Lua Scripts (*.lua)|*.lua|All Files (*.*)|*.*" }; @@ -1052,7 +1068,7 @@ namespace BizHawk.Client.EmuHawk private void RegisteredFunctionsMenuItem_Click(object sender, EventArgs e) { - if (LuaImp.RegisteredFunctions.Any()) + if (LuaImp.GetRegisteredFunctions().Any()) { var alreadyOpen = false; foreach (Form form in Application.OpenForms) @@ -1209,7 +1225,7 @@ namespace BizHawk.Client.EmuHawk private void ConsoleContextMenu_Opening(object sender, CancelEventArgs e) { - RegisteredFunctionsContextItem.Enabled = LuaImp.RegisteredFunctions.Any(); + RegisteredFunctionsContextItem.Enabled = LuaImp.GetRegisteredFunctions().Any(); CopyContextItem.Enabled = OutputBox.SelectedText.Any(); ClearConsoleContextItem.Enabled = SelectAllContextItem.Enabled = diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs index 81c9c696b6..8a0aceb800 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaFunctionsForm.cs @@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk if (!string.IsNullOrWhiteSpace(FilterBox.Text)) { _filteredList = FunctionList - .Where(f => (f.Library + "." + f.Name).ToLowerInvariant().Contains(FilterBox.Text.ToLowerInvariant())) + .Where(f => $"{f.Library}.{f.Name}".ToLowerInvariant().Contains(FilterBox.Text.ToLowerInvariant())) .ToList(); } else diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaPictureBox.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaPictureBox.cs index 301cfa90f9..6c8bf524d5 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaPictureBox.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaPictureBox.cs @@ -373,7 +373,6 @@ namespace BizHawk.Client.EmuHawk boxBackground.FillRectangle(GetBrush(backcolor ?? _defaultTextBackground.Value), rect); boxBackground = Graphics.FromImage(Image); boxBackground.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; - boxBackground = Graphics.FromImage(Image); boxBackground.DrawString(message, font, new SolidBrush(forecolor ?? Color.Black), x, y); } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs index 2a53a725e9..194c940646 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs @@ -17,7 +17,7 @@ namespace BizHawk.Client.EmuHawk public void UpdateValues() { - if (GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Any()) + if (GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions().Any()) { PopulateListView(); } @@ -46,7 +46,7 @@ namespace BizHawk.Client.EmuHawk { FunctionView.Items.Clear(); - var nlfs = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.OrderBy(x => x.Event).ThenBy(x => x.Name).ToList(); + var nlfs = GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions().OrderBy(x => x.Event).ThenBy(x => x.Name).ToList(); foreach (var nlf in nlfs) { var item = new ListViewItem { Text = nlf.Event }; @@ -76,7 +76,7 @@ namespace BizHawk.Client.EmuHawk foreach (int index in indices) { var guid = FunctionView.Items[index].SubItems[2].Text; - GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions[guid].Call(); + GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions()[guid].Call(); } } } @@ -89,8 +89,8 @@ namespace BizHawk.Client.EmuHawk foreach (int index in indices) { var guid = FunctionView.Items[index].SubItems[2].Text; - var nlf = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions[guid]; - GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Remove(nlf); + var nlf = GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions()[guid]; + GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions().Remove(nlf); } PopulateListView(); @@ -109,7 +109,7 @@ namespace BizHawk.Client.EmuHawk private void RemoveAllBtn_Click(object sender, EventArgs e) { - GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.ClearAll(); + GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions().ClearAll(); PopulateListView(); } @@ -118,7 +118,7 @@ namespace BizHawk.Client.EmuHawk var indexes = FunctionView.SelectedIndices; CallButton.Enabled = indexes.Count > 0; RemoveButton.Enabled = indexes.Count > 0; - RemoveAllBtn.Enabled = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Any(); + RemoveAllBtn.Enabled = GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions().Any(); } private void FunctionView_KeyDown(object sender, KeyEventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs b/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs index aedb5b5149..aa22771b8f 100644 --- a/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs +++ b/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs @@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk for (int i = 0; i < _buttonBoxes.Length; i++) { if (!_buttonBoxes[i].Checked) - key = key.Replace(_buttonBoxes[i].Text + "|", ""); + key = key.Replace($"{_buttonBoxes[i].Text}|", ""); } key = key.Substring(0, key.Length - 1); diff --git a/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.cs b/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.cs index d20fea3c50..a8ed28bd2a 100644 --- a/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.cs +++ b/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.cs @@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk }; _zones.Add(main); - ZonesList.Items.Add(main.Name + " - length: " + main.Length); + ZonesList.Items.Add($"{main.Name} - length: {main.Length}"); ZonesList.Items[0] += " [Zones don't change!]"; SetUpButtonBoxes(); @@ -150,9 +150,9 @@ namespace BizHawk.Client.EmuHawk } var newZone = new MovieZone(CurrentMovie, (int)StartNum.Value, (int)(EndNum.Value - StartNum.Value + 1)); - newZone.Name = "Zone " + _zones.Count; + newZone.Name = $"Zone {_zones.Count}"; _zones.Add(newZone); - ZonesList.Items.Add(newZone.Name + " - length: " + newZone.Length); + ZonesList.Items.Add($"{newZone.Name} - length: {newZone.Length}"); _unsavedZones.Add(ZonesList.Items.Count - 1); } @@ -193,7 +193,7 @@ namespace BizHawk.Client.EmuHawk } selectedZone.Name = NameTextbox.Text; - ZonesList.Items[ZonesList.SelectedIndex] = selectedZone.Name + " - length: " + selectedZone.Length; + ZonesList.Items[ZonesList.SelectedIndex] = $"{selectedZone.Name} - length: {selectedZone.Length}"; } private void PlaceNum_ValueChanged(object sender, EventArgs e) @@ -266,7 +266,7 @@ namespace BizHawk.Client.EmuHawk if (loadZone != null) { _zones.Add(loadZone); - ZonesList.Items.Add(loadZone.Name + " - length: " + loadZone.Length); + ZonesList.Items.Add($"{loadZone.Name} - length: {loadZone.Length}"); // Options only for TasMovie if (!(CurrentMovie is TasMovie)) @@ -288,7 +288,7 @@ namespace BizHawk.Client.EmuHawk { MovieZone loadZone = new MovieZone(path); _zones.Add(loadZone); - ZonesList.Items.Add(loadZone.Name + " - length: " + loadZone.Length); + ZonesList.Items.Add($"{loadZone.Name} - length: {loadZone.Length}"); } private static string SuggestedFolder() diff --git a/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs b/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs index 1230d9768e..7752de1889 100644 --- a/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs +++ b/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs @@ -129,7 +129,7 @@ namespace BizHawk.Client.EmuHawk { if (movie is TasMovie) { - (movie as TasMovie).ChangeLog.BeginNewBatch("Place Macro at " + Start); + (movie as TasMovie).ChangeLog.BeginNewBatch($"Place Macro at {Start}"); } if (Start > movie.InputLogLength) @@ -203,7 +203,7 @@ namespace BizHawk.Client.EmuHawk header[0] = InputKey; header[1] = Global.Emulator.ControllerDefinition.Name; header[2] = Global.Emulator.ControllerDefinition.PlayerCount.ToString(); - header[3] = Overlay.ToString() + "," + Replace.ToString(); + header[3] = $"{Overlay},{Replace}"; File.WriteAllLines(fileName, header); File.AppendAllLines(fileName, _log); @@ -232,8 +232,7 @@ namespace BizHawk.Client.EmuHawk { if (!emuKeys.Contains(macroKeys[i])) { - System.Windows.Forms.MessageBox.Show("The selected macro is not compatible with the current emulator core." + - "\nMacro controller: " + readText[1] + "\nMacro player count: " + readText[2], "Error"); + System.Windows.Forms.MessageBox.Show($"The selected macro is not compatible with the current emulator core.\nMacro controller: {readText[1]}\nMacro player count: {readText[2]}", "Error"); return; } } diff --git a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs index f6b2a00d07..8b3762e715 100644 --- a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskBundler.Designer.cs @@ -145,7 +145,8 @@ "PSX", "SAT", "ZXSpectrum", - "AmstradCPC"}); + "AmstradCPC", + "Game Gear"}); this.SystemDropDown.Location = new System.Drawing.Point(425, 75); this.SystemDropDown.Name = "SystemDropDown"; this.SystemDropDown.Size = new System.Drawing.Size(69, 21); diff --git a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs index e36f03fa85..f02f38edcd 100644 --- a/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs +++ b/BizHawk.Client.EmuHawk/tools/MultiDiskBundler/MultiDiskFileSelector.cs @@ -114,7 +114,7 @@ namespace BizHawk.Client.EmuHawk } var intName = hf.ArchiveItems[memIdx]; - PathBox.Text = _path + "|" + intName.Name; + PathBox.Text = $"{_path}|{intName.Name}"; } else { diff --git a/BizHawk.Client.EmuHawk/tools/NES/BarcodeEntry.cs b/BizHawk.Client.EmuHawk/tools/NES/BarcodeEntry.cs index 6b3e64fcc5..6b4e0d07f4 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/BarcodeEntry.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/BarcodeEntry.cs @@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk string why; if (!DatachBarcode.ValidString(textBox1.Text, out why)) { - label3.Text = "Invalid: " + why; + label3.Text = $"Invalid: {why}"; label3.Visible = true; button1.Enabled = false; } diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs b/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs index a1bb98d667..b41fa8779c 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/NESMusicRipper.cs @@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk { int tone = note % 12; int octave = note / 12; - return string.Format("{0}{1}", noteNames[tone], octave); + return $"{noteNames[tone]}{octave}"; } //this isnt thoroughly debugged but it seems to work OK @@ -471,7 +471,7 @@ namespace BizHawk.Client.EmuHawk void SyncContents() { - lblContents.Text = string.Format("{0} Rows", Log.Count); + lblContents.Text = $"{Log.Count} Rows"; } private void btnControl_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs index 2726410475..1856b0206a 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs @@ -312,11 +312,11 @@ namespace BizHawk.Client.EmuHawk TileY = e.Y / 16; } - XYLabel.Text = TileX + " : " + TileY; + XYLabel.Text = $"{TileX} : {TileY}"; int PPUAddress = 0x2000 + (NameTable * 0x400) + ((TileY % 30) * 32) + (TileX % 32); - PPUAddressLabel.Text = string.Format("{0:X4}", PPUAddress); + PPUAddressLabel.Text = $"{PPUAddress:X4}"; int TileID = _ppu.PeekPPU(PPUAddress); - TileIDLabel.Text = string.Format("{0:X2}", TileID); + TileIDLabel.Text = $"{TileID:X2}"; TableLabel.Text = NameTable.ToString(); int ytable = 0, yline = 0; diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs b/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs index b7092b59b7..e4238baa17 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs @@ -294,8 +294,8 @@ namespace BizHawk.Client.EmuHawk private void UpdatePaletteSelection() { _forceChange = true; - Table0PaletteLabel.Text = "Palette: " + PatternView.Pal0; - Table1PaletteLabel.Text = "Palette: " + PatternView.Pal1; + Table0PaletteLabel.Text = $"Palette: {PatternView.Pal0}"; + Table1PaletteLabel.Text = $"Palette: {PatternView.Pal1}"; } private static Bitmap Section(Image srcBitmap, Rectangle section, bool is8x16) @@ -532,7 +532,7 @@ namespace BizHawk.Client.EmuHawk return; } - toolStripStatusLabel1.Text = found.Text + " copied to clipboard."; + toolStripStatusLabel1.Text = $"{found.Text} copied to clipboard."; Messagetimer.Stop(); Messagetimer.Start(); @@ -619,11 +619,11 @@ namespace BizHawk.Client.EmuHawk tile &= ~1; } - AddressLabel.Text = "Number: " + string.Format("{0:X2}", spriteNumber); - ValueLabel.Text = "X: " + string.Format("{0:X2}", x); - Value2Label.Text = "Y: " + string.Format("{0:X2}", y); - Value3Label.Text = "Tile: " + string.Format("{0:X2}", tile); - Value4Label.Text = "Color: " + color; + AddressLabel.Text = $"Number: {spriteNumber:X2}"; + ValueLabel.Text = $"X: {x:X2}"; + Value2Label.Text = $"Y: {y:X2}"; + Value3Label.Text = $"Tile: {tile:X2}"; + Value4Label.Text = $"Color: {color}"; Value5Label.Text = flags; if (is8x16) @@ -668,7 +668,7 @@ namespace BizHawk.Client.EmuHawk int column = e.X / 16; int addr = column + baseAddr; - AddressLabel.Text = "Address: 0x" + string.Format("{0:X4}", addr); + AddressLabel.Text = $"Address: 0x{addr:X4}"; int val; var bmp = new Bitmap(64, 64); @@ -679,20 +679,20 @@ namespace BizHawk.Client.EmuHawk if (baseAddr == 0x3F00) { val = PALRAM[PaletteView.BgPalettes[column].Address]; - ValueLabel.Text = "ID: BG" + (column / 4); + ValueLabel.Text = $"ID: BG{column / 4}"; g.FillRectangle(new SolidBrush(PaletteView.BgPalettes[column].Color), 0, 0, 64, 64); } else { val = PALRAM[PaletteView.SpritePalettes[column].Address]; - ValueLabel.Text = "ID: SPR" + (column / 4); + ValueLabel.Text = $"ID: SPR{column / 4}"; g.FillRectangle(new SolidBrush(PaletteView.SpritePalettes[column].Color), 0, 0, 64, 64); } g.Dispose(); - Value3Label.Text = "Color: 0x" + string.Format("{0:X2}", val); - Value4Label.Text = "Offset: " + (addr & 0x03); + Value3Label.Text = $"Color: 0x{val:X2}"; + Value4Label.Text = $"Offset: {addr & 0x03}"; ZoomBox.Image = bmp; } @@ -772,9 +772,9 @@ namespace BizHawk.Client.EmuHawk usage += " (SPR16)"; } - AddressLabel.Text = "Address: " + string.Format("{0:X4}", address); - ValueLabel.Text = "Table " + table; - Value3Label.Text = "Tile " + string.Format("{0:X2}", tile); + AddressLabel.Text = $"Address: {address:X4}"; + ValueLabel.Text = $"Table {table}"; + Value3Label.Text = $"Tile {tile:X2}"; Value4Label.Text = usage; ZoomBox.Image = Section(PatternView.pattern, new Rectangle(new Point((e.X / 8) * 8, (e.Y / 8) * 8), new Size(8, 8)), false); diff --git a/BizHawk.Client.EmuHawk/tools/NES/NameTableViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/NameTableViewer.cs index 90e4a9f09e..7ba1173f50 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/NameTableViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/NameTableViewer.cs @@ -71,7 +71,7 @@ namespace BizHawk.Client.EmuHawk { var sfd = new SaveFileDialog { - FileName = PathManager.FilesystemSafeName(Global.Game) + "-Nametables", + FileName = $"{PathManager.FilesystemSafeName(Global.Game)}-Nametables", InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Screenshots"].Path, "NES"), Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*", RestoreDirectory = true diff --git a/BizHawk.Client.EmuHawk/tools/NES/PaletteViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/PaletteViewer.cs index 19a855ef6b..12f7a126db 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/PaletteViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/PaletteViewer.cs @@ -78,7 +78,7 @@ namespace BizHawk.Client.EmuHawk { var sfd = new SaveFileDialog { - FileName = PathManager.FilesystemSafeName(Global.Game) + "-Palettes", + FileName = $"{PathManager.FilesystemSafeName(Global.Game)}-Palettes", InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Screenshots"].Path, "NES"), Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*", RestoreDirectory = true diff --git a/BizHawk.Client.EmuHawk/tools/NES/PatternViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/PatternViewer.cs index e1521d4b13..6ae8bddff3 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/PatternViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/PatternViewer.cs @@ -39,7 +39,7 @@ namespace BizHawk.Client.EmuHawk { var sfd = new SaveFileDialog { - FileName = PathManager.FilesystemSafeName(Global.Game) + "-Patterns", + FileName = $"{PathManager.FilesystemSafeName(Global.Game)}-Patterns", InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Screenshots"].Path, "NES"), Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*", RestoreDirectory = true diff --git a/BizHawk.Client.EmuHawk/tools/NES/SpriteViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/SpriteViewer.cs index 3613b34cc1..3ca6f07d52 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/SpriteViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/SpriteViewer.cs @@ -44,7 +44,7 @@ namespace BizHawk.Client.EmuHawk { var sfd = new SaveFileDialog { - FileName = PathManager.FilesystemSafeName(Global.Game) + "-Sprites", + FileName = $"{PathManager.FilesystemSafeName(Global.Game)}-Sprites", InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries["NES", "Screenshots"].Path, "NES"), Filter = "PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|All Files|*.*", RestoreDirectory = true diff --git a/BizHawk.Client.EmuHawk/tools/PCE/PCEBGViewer.cs b/BizHawk.Client.EmuHawk/tools/PCE/PCEBGViewer.cs index 3c2eef6155..10e69b4186 100644 --- a/BizHawk.Client.EmuHawk/tools/PCE/PCEBGViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/PCE/PCEBGViewer.cs @@ -145,7 +145,7 @@ namespace BizHawk.Client.EmuHawk int tileNo = vdc.VRAM[(ushort)((yTile * vdc.BatWidth) + xTile)] & 0x07FF; int paletteNo = vdc.VRAM[(ushort)((yTile * vdc.BatWidth) + xTile)] >> 12; TileIDLabel.Text = tileNo.ToString(); - XYLabel.Text = xTile + ":" + yTile; + XYLabel.Text = $"{xTile}:{yTile}"; PaletteLabel.Text = paletteNo.ToString(); } diff --git a/BizHawk.Client.EmuHawk/tools/PCE/PCESoundDebugger.cs b/BizHawk.Client.EmuHawk/tools/PCE/PCESoundDebugger.cs index 9ae289b835..b32faac779 100644 --- a/BizHawk.Client.EmuHawk/tools/PCE/PCESoundDebugger.cs +++ b/BizHawk.Client.EmuHawk/tools/PCE/PCESoundDebugger.cs @@ -190,7 +190,7 @@ namespace BizHawk.Client.EmuHawk private void btnExport_Click(object sender, EventArgs e) { - string tmpf = Path.GetTempFileName() + ".zip"; + string tmpf = $"{Path.GetTempFileName()}.zip"; using (var stream = new FileStream(tmpf, FileMode.Create, FileAccess.Write, FileShare.Read)) { var zip = new ZipOutputStream(stream) @@ -201,7 +201,7 @@ namespace BizHawk.Client.EmuHawk foreach (var entry in PSGEntries) { - var ze = new ZipEntry(entry.name + ".wav") { CompressionMethod = CompressionMethod.Deflated }; + var ze = new ZipEntry($"{entry.name}.wav") { CompressionMethod = CompressionMethod.Deflated }; zip.PutNextEntry(ze); var ms = new MemoryStream(); var bw = new BinaryWriter(ms); diff --git a/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs b/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs index 19fd60cea5..9839c42887 100644 --- a/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs @@ -318,8 +318,8 @@ namespace BizHawk.Client.EmuHawk { int val = 0, add = 0; SnesGGDecode(GGCodeMaskBox.Text, ref val, ref add); - AddressBox.Text = string.Format("{0:X6}", add); - ValueBox.Text = string.Format("{0:X2}", val); + AddressBox.Text = $"{add:X6}"; + ValueBox.Text = $"{val:X2}"; addcheatbt.Enabled = true; } else diff --git a/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs b/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs index 58f4061377..235c17a6c3 100644 --- a/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs +++ b/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs @@ -130,8 +130,8 @@ namespace BizHawk.Client.EmuHawk string FormatVramAddress(int address) { int excess = address & 1023; - if (excess != 0) return "@" + address.ToHexString(4); - else return string.Format("@{0} ({1}K)", address.ToHexString(4), address / 1024); + if (excess != 0) return $"@{address.ToHexString(4)}"; + else return $"@{address.ToHexString(4)} ({address / 1024}K)"; } public void NewUpdate(ToolFormUpdateType type) { } @@ -245,7 +245,7 @@ namespace BizHawk.Client.EmuHawk txtOBSELSizeBits.Text = si.OBSEL_Size.ToString(); txtOBSELBaseBits.Text = si.OBSEL_NameBase.ToString(); txtOBSELT1OfsBits.Text = si.OBSEL_NameSel.ToString(); - txtOBSELSizeDescr.Text = string.Format("{0}, {1}", SNESGraphicsDecoder.ObjSizes[si.OBSEL_Size, 0], SNESGraphicsDecoder.ObjSizes[si.OBSEL_Size, 1]); + txtOBSELSizeDescr.Text = $"{SNESGraphicsDecoder.ObjSizes[si.OBSEL_Size, 0]}, {SNESGraphicsDecoder.ObjSizes[si.OBSEL_Size, 1]}"; txtOBSELBaseDescr.Text = FormatVramAddress(si.OBJTable0Addr); txtOBSELT1OfsDescr.Text = FormatVramAddress(si.OBJTable1Addr); @@ -282,7 +282,7 @@ namespace BizHawk.Client.EmuHawk txtBG1SizeBits.Text = bg.SCSIZE.ToString(); txtBG1SizeInTiles.Text = bg.ScreenSizeInTiles.ToString(); int size = bg.ScreenSizeInTiles.Width * bg.ScreenSizeInTiles.Height * 2 / 1024; - txtBG1MapSizeBytes.Text = string.Format("({0}K)", size); + txtBG1MapSizeBytes.Text = $"({size}K)"; txtBG1SCAddrBits.Text = bg.SCADDR.ToString(); txtBG1SCAddrDescr.Text = FormatVramAddress(bg.ScreenAddr); txtBG1Colors.Text = (1 << bg.Bpp).ToString(); @@ -290,17 +290,17 @@ namespace BizHawk.Client.EmuHawk txtBG1TDAddrBits.Text = bg.TDADDR.ToString(); txtBG1TDAddrDescr.Text = FormatVramAddress(bg.TiledataAddr); - txtBG1Scroll.Text = string.Format("({0},{1})", bg.HOFS, bg.VOFS); + txtBG1Scroll.Text = $"({bg.HOFS},{bg.VOFS})"; if (bg.Bpp != 0) { var pi = bg.PaletteSelection; - txtBGPaletteInfo.Text = string.Format("{0} colors from ${1:X2} - ${2:X2}", pi.size, pi.start, pi.start + pi.size - 1); + txtBGPaletteInfo.Text = $"{pi.size} colors from ${pi.start:X2} - ${pi.start + pi.size - 1:X2}"; } else txtBGPaletteInfo.Text = ""; var sizeInPixels = bg.ScreenSizeInPixels; - txtBG1SizeInPixels.Text = string.Format("{0}x{1}", sizeInPixels.Width, sizeInPixels.Height); + txtBG1SizeInPixels.Text = $"{sizeInPixels.Width}x{sizeInPixels.Height}"; checkTMOBJ.Checked = si.OBJ_MainEnabled; checkTMBG1.Checked = si.BG.BG1.MainEnabled; @@ -724,7 +724,7 @@ namespace BizHawk.Client.EmuHawk static string BGModeShortName(SNESGraphicsDecoder.BGMode mode, int bpp) { if (mode == SNESGraphicsDecoder.BGMode.Unavailable) return "Unavailable"; - if (mode == SNESGraphicsDecoder.BGMode.Text) return string.Format("Text{0}bpp", bpp); + if (mode == SNESGraphicsDecoder.BGMode.Text) return $"Text{bpp}bpp"; if (mode == SNESGraphicsDecoder.BGMode.OBJ) return string.Format("OBJ", bpp); if (mode == SNESGraphicsDecoder.BGMode.Mode7) return "Mode7"; if (mode == SNESGraphicsDecoder.BGMode.Mode7Ext) return "Mode7Ext"; @@ -736,17 +736,17 @@ namespace BizHawk.Client.EmuHawk { if (currObjDataState == null) return; var oam = new SNESGraphicsDecoder.OAMInfo(gd, si, currObjDataState.Number); - txtObjNumber.Text = string.Format("#${0:X2}", currObjDataState.Number); - txtObjCoord.Text = string.Format("({0}, {1})",oam.X,oam.Y); + txtObjNumber.Text = $"#${currObjDataState.Number:X2}"; + txtObjCoord.Text = $"({oam.X}, {oam.Y})"; cbObjHFlip.Checked = oam.HFlip; cbObjVFlip.Checked = oam.VFlip; cbObjLarge.Checked = oam.Size == 1; txtObjSize.Text = SNESGraphicsDecoder.ObjSizes[si.OBSEL_Size, oam.Size].ToString(); txtObjPriority.Text = oam.Priority.ToString(); txtObjPalette.Text = oam.Palette.ToString(); - txtObjPaletteMemo.Text = string.Format("${0:X2}", oam.Palette * 16 + 128); - txtObjName.Text = string.Format("#${0:X3}", oam.Tile); - txtObjNameAddr.Text = string.Format("@{0:X4}", oam.Address); + txtObjPaletteMemo.Text = $"${oam.Palette * 16 + 128:X2}"; + txtObjName.Text = $"#${oam.Tile:X3}"; + txtObjNameAddr.Text = $"@{oam.Address:X4}"; } void UpdateTileDetails() @@ -757,18 +757,18 @@ namespace BizHawk.Client.EmuHawk txtTileMode.Text = BGModeShortName(mode, bpp); txtTileBpp.Text = currTileDataState.Bpp.ToString(); txtTileColors.Text = (1 << currTileDataState.Bpp).ToString(); - txtTileNumber.Text = string.Format("#${0:X3}", currTileDataState.Tile); - txtTileAddress.Text = string.Format("@{0:X4}", currTileDataState.Address); - txtTilePalette.Text = string.Format("#{0:X2}", currTileDataState.Palette); + txtTileNumber.Text = $"#${currTileDataState.Tile:X3}"; + txtTileAddress.Text = $"@{currTileDataState.Address:X4}"; + txtTilePalette.Text = $"#{currTileDataState.Palette:X2}"; } void UpdateMapEntryDetails() { if (currMapEntryState == null) return; - txtMapEntryLocation.Text = string.Format("({0},{1}), @{2:X4}", currMapEntryState.Location.X, currMapEntryState.Location.Y, currMapEntryState.entry.address); - txtMapEntryTileNum.Text = string.Format("${0:X3}", currMapEntryState.entry.tilenum); - txtMapEntryPrio.Text = string.Format("{0}", (currMapEntryState.entry.flags & SNESGraphicsDecoder.TileEntryFlags.Priority)!=0?1:0); - txtMapEntryPalette.Text = string.Format("{0}", currMapEntryState.entry.palette); + txtMapEntryLocation.Text = $"({currMapEntryState.Location.X},{currMapEntryState.Location.Y}), @{currMapEntryState.entry.address:X4}"; + txtMapEntryTileNum.Text = $"${currMapEntryState.entry.tilenum:X3}"; + txtMapEntryPrio.Text = $"{((currMapEntryState.entry.flags & SNESGraphicsDecoder.TileEntryFlags.Priority) != 0 ? 1 : 0)}"; + txtMapEntryPalette.Text = $"{currMapEntryState.entry.palette}"; checkMapEntryHFlip.Checked = (currMapEntryState.entry.flags & SNESGraphicsDecoder.TileEntryFlags.Horz) != 0; checkMapEntryVFlip.Checked = (currMapEntryState.entry.flags & SNESGraphicsDecoder.TileEntryFlags.Vert) != 0; @@ -786,7 +786,7 @@ namespace BizHawk.Client.EmuHawk addr *= 2; addr &= 0xFFFF; - txtMapEntryTileAddr.Text = "@" + addr.ToHexString(4); + txtMapEntryTileAddr.Text = $"@{addr.ToHexString(4)}"; } void UpdateColorDetails() @@ -798,19 +798,19 @@ namespace BizHawk.Client.EmuHawk int color = gd.Colorize(rgb555); pnDetailsPaletteColor.BackColor = Color.FromArgb(color); - txtDetailsPaletteColor.Text = string.Format("${0:X4}", rgb555); - txtDetailsPaletteColorHex.Text = string.Format("#{0:X6}", color & 0xFFFFFF); - txtDetailsPaletteColorRGB.Text = string.Format("({0},{1},{2})", (color >> 16) & 0xFF, (color >> 8) & 0xFF, (color & 0xFF)); + txtDetailsPaletteColor.Text = $"${rgb555:X4}"; + txtDetailsPaletteColorHex.Text = $"#{color & 0xFFFFFF:X6}"; + txtDetailsPaletteColorRGB.Text = $"({(color >> 16) & 0xFF},{(color >> 8) & 0xFF},{(color & 0xFF)})"; - txtPaletteDetailsIndexHex.Text = string.Format("${0:X2}", lastColorNum); - txtPaletteDetailsIndex.Text = string.Format("{0}", lastColorNum); + txtPaletteDetailsIndexHex.Text = $"${lastColorNum:X2}"; + txtPaletteDetailsIndex.Text = $"{lastColorNum}"; //not being used anymore //if (lastColorNum < 128) lblDetailsOBJOrBG.Text = "(BG:)"; else lblDetailsOBJOrBG.Text = "(OBJ:)"; - //txtPaletteDetailsIndexHexSpecific.Text = string.Format("${0:X2}", lastColorNum & 0x7F); - //txtPaletteDetailsIndexSpecific.Text = string.Format("{0}", lastColorNum & 0x7F); + //txtPaletteDetailsIndexHexSpecific.Text = $"${lastColorNum & 0x7F:X2}"; + //txtPaletteDetailsIndexSpecific.Text = $"{lastColorNum & 0x7F}"; - txtPaletteDetailsAddress.Text = string.Format("${0:X3}", lastColorNum * 2); + txtPaletteDetailsAddress.Text = $"${lastColorNum * 2:X3}"; } @@ -1313,7 +1313,7 @@ namespace BizHawk.Client.EmuHawk label = "Map Entry"; if (found.Name == "paletteViewer") label = "Palette"; - labelClipboard.Text = label + " copied to clipboard."; + labelClipboard.Text = $"{label} copied to clipboard."; messagetimer.Stop(); messagetimer.Start(); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs index 8e7adcc47b..a163f97c2e 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -117,7 +117,7 @@ namespace BizHawk.Client.EmuHawk TasBranch branch = GetBranch(index); if (branch != null) { - var record = Tastudio.CurrentTasMovie[branch.Frame]; + var record = Movie[branch.Frame]; if (index == Movie.CurrentBranch) { color = TAStudio.CurrentFrame_InputLog; @@ -146,7 +146,7 @@ namespace BizHawk.Client.EmuHawk private TasBranch GetBranch(int index) { - return Tastudio.CurrentTasMovie.GetBranch(index); + return Movie.GetBranch(index); } public void Branch() @@ -199,13 +199,14 @@ namespace BizHawk.Client.EmuHawk return; } - Tastudio.CurrentTasMovie.LoadBranch(branch); + Movie.LoadBranch(branch); var stateInfo = new KeyValuePair(branch.Frame, branch.CoreData); Tastudio.LoadState(stateInfo); + Movie.TasStateManager.Capture(true); QuickBmpFile.Copy(new BitmapBufferVideoProvider(branch.OSDFrameBuffer), Tastudio.VideoProvider); if (Tastudio.Settings.OldControlSchemeForBranches && Tastudio.TasPlaybackBox.RecordingMode) - Tastudio.CurrentTasMovie.Truncate(branch.Frame); + Movie.Truncate(branch.Frame); GlobalWin.MainForm.PauseOnFrame = null; Tastudio.RefreshDialog(); @@ -225,7 +226,7 @@ namespace BizHawk.Client.EmuHawk Movie.CurrentBranch = index; LoadBranch(SelectedBranch); BranchView.Refresh(); - GlobalWin.OSD.AddMessage("Loaded branch " + Movie.CurrentBranch.ToString()); + GlobalWin.OSD.AddMessage($"Loaded branch {Movie.CurrentBranch}"); } } @@ -242,16 +243,16 @@ namespace BizHawk.Client.EmuHawk private void AddBranchToolStripMenuItem_Click(object sender, EventArgs e) { Branch(); - CallSavedCallback(Tastudio.CurrentTasMovie.BranchCount - 1); - GlobalWin.OSD.AddMessage("Added branch " + Movie.CurrentBranch.ToString()); + CallSavedCallback(Movie.BranchCount - 1); + GlobalWin.OSD.AddMessage($"Added branch {Movie.CurrentBranch}"); } private void AddBranchWithTexToolStripMenuItem_Click(object sender, EventArgs e) { Branch(); EditBranchTextPopUp(Movie.CurrentBranch); - CallSavedCallback(Tastudio.CurrentTasMovie.BranchCount - 1); - GlobalWin.OSD.AddMessage("Added branch " + Movie.CurrentBranch.ToString()); + CallSavedCallback(Movie.BranchCount - 1); + GlobalWin.OSD.AddMessage($"Added branch {Movie.CurrentBranch}"); } private void LoadBranchToolStripMenuItem_Click(object sender, EventArgs e) @@ -291,7 +292,7 @@ namespace BizHawk.Client.EmuHawk UpdateBranch(SelectedBranch); CallSavedCallback(Movie.CurrentBranch); - GlobalWin.OSD.AddMessage("Saved branch " + Movie.CurrentBranch); + GlobalWin.OSD.AddMessage($"Saved branch {Movie.CurrentBranch}"); } } @@ -311,7 +312,7 @@ namespace BizHawk.Client.EmuHawk toolTip1.SetToolTip(UndoBranchButton, "Undo Branch Text Edit"); _branchUndo = BranchUndo.Text; - GlobalWin.OSD.AddMessage("Edited branch " + index.ToString()); + GlobalWin.OSD.AddMessage($"Edited branch {index}"); } } } @@ -357,7 +358,7 @@ namespace BizHawk.Client.EmuHawk CallRemovedCallback(index); Tastudio.RefreshDialog(); - GlobalWin.OSD.AddMessage("Removed branch " + index.ToString()); + GlobalWin.OSD.AddMessage($"Removed branch {index}"); } } @@ -366,13 +367,13 @@ namespace BizHawk.Client.EmuHawk if (_branchUndo == BranchUndo.Load) { LoadBranch(_backupBranch); - CallLoadedCallback(Tastudio.CurrentTasMovie.Branches.IndexOf(_backupBranch)); + CallLoadedCallback(Movie.Branches.IndexOf(_backupBranch)); GlobalWin.OSD.AddMessage("Branch Load canceled"); } else if (_branchUndo == BranchUndo.Update) { Movie.UpdateBranch(Movie.GetBranch(_backupBranch.UniqueIdentifier), _backupBranch); - CallSavedCallback(Tastudio.CurrentTasMovie.Branches.IndexOf(_backupBranch)); + CallSavedCallback(Movie.Branches.IndexOf(_backupBranch)); GlobalWin.OSD.AddMessage("Branch Update canceled"); } else if (_branchUndo == BranchUndo.Text) @@ -384,7 +385,7 @@ namespace BizHawk.Client.EmuHawk { Movie.AddBranch(_backupBranch); BranchView.RowCount = Movie.BranchCount; - CallSavedCallback(Tastudio.CurrentTasMovie.Branches.IndexOf(_backupBranch)); + CallSavedCallback(Movie.Branches.IndexOf(_backupBranch)); GlobalWin.OSD.AddMessage("Branch Removal canceled"); } @@ -577,7 +578,7 @@ namespace BizHawk.Client.EmuHawk var i = new InputPrompt { - Text = "Text for branch " + index, + Text = $"Text for branch {index}", TextInputType = InputPrompt.InputType.Text, Message = "Enter a message", InitialValue = branch.UserText diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs index 612f788cce..d1a4f0dde7 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/GreenzoneSettings.cs @@ -36,7 +36,7 @@ namespace BizHawk.Client.EmuHawk MemStateGapDividerNumeric.Value = NumberExtensions.Clamp(_settings.MemStateGapDivider, MemStateGapDividerNumeric.Minimum, MemStateGapDividerNumeric.Maximum); FileStateGapNumeric.Value = _settings.FileStateGap; - SavestateSizeLabel.Text = Math.Round(_stateSizeMb, 2).ToString() + " MB"; + SavestateSizeLabel.Text = $"{Math.Round(_stateSizeMb, 2)} MB"; CapacityNumeric_ValueChanged(null, null); SaveCapacityNumeric_ValueChanged(null, null); } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs index f24533e8d0..14b9acce8a 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs @@ -183,7 +183,7 @@ namespace BizHawk.Client.EmuHawk { var i = new InputPrompt { - Text = "Marker for frame " + markerFrame, + Text = $"Marker for frame {markerFrame}", TextInputType = InputPrompt.InputType.Text, Message = "Enter a message", InitialValue = @@ -218,7 +218,7 @@ namespace BizHawk.Client.EmuHawk var point = default(Point); var i = new InputPrompt { - Text = "Marker for frame " + markerFrame, + Text = $"Marker for frame {markerFrame}", TextInputType = InputPrompt.InputType.Text, Message = "Enter a message", InitialValue = diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs index ea42894388..dea9ac8e2d 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/PatternsForm.cs @@ -157,7 +157,7 @@ namespace BizHawk.Client.EmuHawk int index = 0; for (int i = 0; i < _counts.Count; i++) { - string str = index + ": "; + string str = $"{index}: "; if (IsBool) { str += _values[i][0] == 'T' ? "On" : "Off"; @@ -167,11 +167,11 @@ namespace BizHawk.Client.EmuHawk str += _values[i]; } - PatternList.Items.Add(str + ("\t(x" + _counts[i] + ")")); + PatternList.Items.Add($"{str}\t(x{_counts[i]})"); index += _counts[i]; } - PatternList.Items.Add("Loop to: " + _loopAt); + PatternList.Items.Add($"Loop to: {_loopAt}"); if (oldIndex >= PatternList.Items.Count) { diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 2ed27e86df..de35d5b4bc 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -344,7 +344,7 @@ namespace BizHawk.Client.EmuHawk catch (Exception ex) { text = ""; - MessageBox.Show("oops\n" + ex); + MessageBox.Show($"oops\n{ex}"); } } @@ -643,7 +643,7 @@ namespace BizHawk.Client.EmuHawk } else { - CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool " + buttonName + " from frame " + frame); + CurrentTasMovie.ChangeLog.BeginNewBatch($"Paint Bool {buttonName} from frame {frame}"); CurrentTasMovie.ToggleBoolState(TasView.CurrentCell.RowIndex.Value, buttonName); _boolPaintState = CurrentTasMovie.BoolIsPressed(frame, buttonName); @@ -683,7 +683,7 @@ namespace BizHawk.Client.EmuHawk if (e.Clicks != 2 && !Settings.SingleClickFloatEdit) { - CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Float " + buttonName + " from frame " + frame); + CurrentTasMovie.ChangeLog.BeginNewBatch($"Paint Float {buttonName} from frame {frame}"); _startFloatDrawColumn = buttonName; } else // Double-click enters float editing mode @@ -694,7 +694,7 @@ namespace BizHawk.Client.EmuHawk } else { - CurrentTasMovie.ChangeLog.BeginNewBatch("Float Edit: " + frame); + CurrentTasMovie.ChangeLog.BeginNewBatch($"Float Edit: {frame}"); _floatEditColumn = buttonName; floatEditRow = frame; _floatTypedValue = ""; @@ -1350,7 +1350,7 @@ namespace BizHawk.Client.EmuHawk } else { - _floatTypedValue = "-" + _floatTypedValue; + _floatTypedValue = $"-{_floatTypedValue}"; } } else if (e.KeyCode == Keys.Back) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 013f04ea77..880445af5f 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk } // need to be fancy here, so call the ofd constructor directly instead of helper - var all = "*." + string.Join(";*.", MovieService.MovieExtensions.Reverse()); + var all = $"*.{string.Join(";*.", MovieService.MovieExtensions.Reverse())}"; var ofd = new OpenFileDialog { FileName = filename, @@ -116,7 +116,7 @@ namespace BizHawk.Client.EmuHawk _autosaveTimer.Start(); } - MessageStatusLabel.Text = CurrentTasMovie.Name + " saved."; + MessageStatusLabel.Text = $"{CurrentTasMovie.Name} saved."; Settings.RecentTas.Add(CurrentTasMovie.Filename); Cursor = Cursors.Default; GlobalWin.Sound.StartSound(); @@ -159,7 +159,7 @@ namespace BizHawk.Client.EmuHawk CurrentTasMovie.Save(); Settings.RecentTas.Add(CurrentTasMovie.Filename); SetTextProperty(); - MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " saved."; + MessageStatusLabel.Text = $"{Path.GetFileName(CurrentTasMovie.Filename)} saved."; Cursor = Cursors.Default; } @@ -169,6 +169,7 @@ namespace BizHawk.Client.EmuHawk _autosaveTimer.Start(); } + Mainform.SetWindowText(); GlobalWin.Sound.StartSound(); } @@ -267,17 +268,41 @@ namespace BizHawk.Client.EmuHawk private void ToBk2MenuItem_Click(object sender, EventArgs e) { _autosaveTimer.Stop(); - var bk2 = CurrentTasMovie.ToBk2(true); + var bk2 = CurrentTasMovie.ToBk2(true, true); MessageStatusLabel.Text = "Exporting to .bk2..."; Cursor = Cursors.WaitCursor; Update(); - bk2.Save(); + string d_exp = " not exported."; + var file = new FileInfo(bk2.Filename); + if (file.Exists) + { + GlobalWin.Sound.StopSound(); + var result = MessageBox.Show( + "Overwrite Existing File?", + "Tastudio", + MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Question, + MessageBoxDefaultButton.Button3); + + GlobalWin.Sound.StartSound(); + if (result == DialogResult.Yes) + { + bk2.Save(); + d_exp = " exported."; + } + } + else + { + bk2.Save(); + d_exp = " exported."; + } + if (Settings.AutosaveInterval > 0) { _autosaveTimer.Start(); } - MessageStatusLabel.Text = bk2.Name + " exported."; + MessageStatusLabel.Text = bk2.Name + d_exp; Cursor = Cursors.Default; } @@ -599,7 +624,7 @@ namespace BizHawk.Client.EmuHawk bool needsToRollback = !(TasView.FirstSelectedIndex > Emulator.Frame); int rollBackFrame = TasView.FirstSelectedIndex.Value; - CurrentTasMovie.ChangeLog.BeginNewBatch("Clear frames " + TasView.SelectedRows.Min() + "-" + TasView.SelectedRows.Max()); + CurrentTasMovie.ChangeLog.BeginNewBatch($"Clear frames {TasView.SelectedRows.Min()}-{TasView.SelectedRows.Max()}"); foreach (int frame in TasView.SelectedRows) { CurrentTasMovie.ClearFrame(frame); @@ -794,7 +819,7 @@ namespace BizHawk.Client.EmuHawk if (!state.SequenceEqual(greenzone)) { - MessageBox.Show("Bad data between frames " + lastState + " and " + Emulator.Frame); + MessageBox.Show($"Bad data between frames {lastState} and {Emulator.Frame}"); return; } @@ -822,6 +847,7 @@ namespace BizHawk.Client.EmuHawk SingleClickFloatEditMenuItem.Checked = Settings.SingleClickFloatEdit; OldControlSchemeForBranchesMenuItem.Checked = Settings.OldControlSchemeForBranches; LoadBranchOnDoubleclickMenuItem.Checked = Settings.LoadBranchOnDoubleClick; + BindMarkersToInputMenuItem.Checked = CurrentTasMovie.BindMarkersToInput; } private void SetMaxUndoLevelsMenuItem_Click(object sender, EventArgs e) @@ -1235,14 +1261,14 @@ namespace BizHawk.Client.EmuHawk for (int i = 1; i < playerMenus.Length; i++) { - playerMenus[i] = new ToolStripMenuItem("Player " + i); + playerMenus[i] = new ToolStripMenuItem($"Player {i}"); } foreach (InputRoll.RollColumn column in columns) { ToolStripMenuItem menuItem = new ToolStripMenuItem { - Text = column.Text + " (" + column.Name + ")", + Text = $"{column.Text} ({column.Name})", Checked = column.Visible, CheckOnClick = true, Tag = column.Name @@ -1286,9 +1312,7 @@ namespace BizHawk.Client.EmuHawk for (int i = 0; i < keysMenus.Length; i++) { - string text = "Keys (" + - keysMenus[i].DropDownItems[0].Tag + " - " + - keysMenus[i].DropDownItems[keysMenus[i].DropDownItems.Count - 1].Tag + ")"; + string text = $"Keys ({keysMenus[i].DropDownItems[0].Tag} - {keysMenus[i].DropDownItems[keysMenus[i].DropDownItems.Count - 1].Tag})"; keysMenus[i].Text = text.Replace("Key ", ""); ColumnsSubMenu.DropDownItems.Add(keysMenus[i]); } @@ -1342,7 +1366,7 @@ namespace BizHawk.Client.EmuHawk { if (playerMenus[i].HasDropDownItems) { - var item = new ToolStripMenuItem("Show Player " + i) + var item = new ToolStripMenuItem($"Show Player {i}") { CheckOnClick = true, Checked = true @@ -1452,14 +1476,20 @@ namespace BizHawk.Client.EmuHawk { if (AskSaveChanges()) { - int index = TasView.SelectedRows.First(); - GoToFrame(index); - - TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie( - SaveRamEmulator.CloneSaveRam()); - - Mainform.PauseEmulator(); - LoadFile(new FileInfo(newProject.Filename), true); + if (SaveRamEmulator.CloneSaveRam() != null) + { + int index = 0; + if (TasView.SelectedRows.Count() > 0) { index = TasView.SelectedRows.First(); } + GoToFrame(index); + TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie( + SaveRamEmulator.CloneSaveRam()); + Mainform.PauseEmulator(); + LoadFile(new FileInfo(newProject.Filename), true); + } + else + { + throw new Exception("No SaveRam"); + } } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 0019b8e3eb..19ccbdb782 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -191,7 +191,7 @@ namespace BizHawk.Client.EmuHawk this.Invoke(() => SavingProgressBar.Visible = true); for (;;) { - if (_seekBackgroundWorker.CancellationPending || !this.IsHandleCreated) + if (_seekBackgroundWorker.CancellationPending || !IsHandleCreated || !Mainform.PauseOnFrame.HasValue) { e.Cancel = true; break; @@ -607,7 +607,7 @@ namespace BizHawk.Client.EmuHawk GoToFrame(CurrentTasMovie.Session.CurrentFrame); } - if (TasView.AllColumns.Count == 0 || file.Extension != "." + TasMovie.Extension) + if (TasView.AllColumns.Count == 0 || file.Extension != $".{TasMovie.Extension}") { SetUpColumns(); } @@ -686,7 +686,7 @@ namespace BizHawk.Client.EmuHawk CurrentTasMovie.ClearChanges(); SetTextProperty(); - MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " loaded."; + MessageStatusLabel.Text = $"{Path.GetFileName(CurrentTasMovie.Filename)} loaded."; return true; } @@ -788,7 +788,7 @@ namespace BizHawk.Client.EmuHawk { return Path.Combine( PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null), - TasMovie.DefaultProjectName + "." + TasMovie.Extension); + $"{TasMovie.DefaultProjectName}.{TasMovie.Extension}"); } /// @@ -798,7 +798,7 @@ namespace BizHawk.Client.EmuHawk { return Path.Combine( PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null), - PathManager.FilesystemSafeName(Global.Game) + "." + TasMovie.Extension); + $"{PathManager.FilesystemSafeName(Global.Game)}.{TasMovie.Extension}"); } private void SetTextProperty() @@ -806,7 +806,7 @@ namespace BizHawk.Client.EmuHawk var text = "TAStudio"; if (CurrentTasMovie != null) { - text += " - " + CurrentTasMovie.Name + (CurrentTasMovie.Changes ? "*" : ""); + text += $" - {CurrentTasMovie.Name}{(CurrentTasMovie.Changes ? "*" : "")}"; } if (InvokeRequired) @@ -986,12 +986,9 @@ namespace BizHawk.Client.EmuHawk private void SetSplicer() { // TODO: columns selected? - SplicerStatusLabel.Text = - "Selected: " + TasView.SelectedRows.Count() + " frame" + - (TasView.SelectedRows.Count() == 1 ? "" : "s") + - ", States: " + CurrentTasMovie.TasStateManager.StateCount.ToString() + - ", Clipboard: " + (_tasClipboard.Any() ? _tasClipboard.Count + " frame" + - (_tasClipboard.Count == 1 ? "" : "s") : "empty"); + var temp = $"Selected: {TasView.SelectedRows.Count()} {(TasView.SelectedRows.Count() == 1 ? "frame" : "frames")}, States: {CurrentTasMovie.TasStateManager.StateCount}"; + if (_tasClipboard.Any()) temp += $", Clipboard: {_tasClipboard.Count} {(_tasClipboard.Count == 1 ? "frame" : "frames")}"; + SplicerStatusLabel.Text = temp; } private void UpdateChangesIndicator() @@ -1098,7 +1095,7 @@ namespace BizHawk.Client.EmuHawk } var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); - if (Path.GetExtension(filePaths[0]) == "." + TasMovie.Extension) + if (Path.GetExtension(filePaths[0]) == $".{TasMovie.Extension}") { FileInfo file = new FileInfo(filePaths[0]); if (file.Exists) @@ -1137,7 +1134,7 @@ namespace BizHawk.Client.EmuHawk if (lagLog.WasLagged.Value && !isLag) { // Deleting this frame requires rewinding a frame. - CurrentTasMovie.ChangeLog.AddInputBind(Emulator.Frame - 1, true, "Bind Input; Delete " + (Emulator.Frame - 1)); + CurrentTasMovie.ChangeLog.AddInputBind(Emulator.Frame - 1, true, $"Bind Input; Delete {Emulator.Frame - 1}"); bool wasRecording = CurrentTasMovie.ChangeLog.IsRecording; CurrentTasMovie.ChangeLog.IsRecording = false; @@ -1150,7 +1147,7 @@ namespace BizHawk.Client.EmuHawk } else if (!lagLog.WasLagged.Value && isLag) { // (it shouldn't need to rewind, since the inserted input wasn't polled) - CurrentTasMovie.ChangeLog.AddInputBind(Emulator.Frame - 1, false, "Bind Input; Insert " + (Emulator.Frame - 1)); + CurrentTasMovie.ChangeLog.AddInputBind(Emulator.Frame - 1, false, $"Bind Input; Insert {Emulator.Frame - 1}"); bool wasRecording = CurrentTasMovie.ChangeLog.IsRecording; CurrentTasMovie.ChangeLog.IsRecording = false; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs index 3bae7f5d49..747d636646 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs @@ -44,7 +44,7 @@ namespace BizHawk.Client.EmuHawk } catch (Exception) { - MessageBox.Show("Invalid mnemonic string: " + inputLogEntry, "Paste Input failed!"); + MessageBox.Show($"Invalid mnemonic string: {inputLogEntry}", "Paste Input failed!"); return null; } } diff --git a/BizHawk.Client.EmuHawk/tools/ToolBox.cs b/BizHawk.Client.EmuHawk/tools/ToolBox.cs index 503714c6b1..67aefdfd0f 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolBox.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolBox.cs @@ -6,7 +6,7 @@ using System.Reflection; using System.Windows.Forms; using BizHawk.Emulation.Common; -using BizHawk.Client.Common; +using BizHawk.Client.ApiHawk; namespace BizHawk.Client.EmuHawk { @@ -66,6 +66,8 @@ namespace BizHawk.Client.EmuHawk continue; if (!ServiceInjector.IsAvailable(Emulator.ServiceProvider, t)) continue; +// if (!ApiInjector.IsAvailable(, t)) +// continue; var instance = Activator.CreateInstance(t); diff --git a/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs b/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs index a1c92dc8ae..870c8da835 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs @@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk { FileName = !string.IsNullOrWhiteSpace(currentFile) ? Path.GetFileName(currentFile) - : PathManager.FilesystemSafeName(Global.Game) + "." + fileExt, + : $"{PathManager.FilesystemSafeName(Global.Game)}.{fileExt}", InitialDirectory = path, Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt), RestoreDirectory = true @@ -52,7 +52,7 @@ namespace BizHawk.Client.EmuHawk { FileName = !string.IsNullOrWhiteSpace(currentFile) ? Path.GetFileName(currentFile) - : PathManager.FilesystemSafeName(Global.Game) + "." + fileExt, + : $"{PathManager.FilesystemSafeName(Global.Game)}.{fileExt}", InitialDirectory = path, Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt), RestoreDirectory = true, diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index 05d530176d..1d4f348f0f 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -7,10 +7,13 @@ using System.Reflection; using System.ComponentModel; using System.Windows.Forms; +using BizHawk.Client.ApiHawk; using BizHawk.Client.Common; -using BizHawk.Emulation.Common; -using BizHawk.Common.ReflectionExtensions; +using BizHawk.Client.EmuHawk; using BizHawk.Client.EmuHawk.CoreExtensions; +using BizHawk.Common; +using BizHawk.Common.ReflectionExtensions; +using BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk { @@ -44,7 +47,7 @@ namespace BizHawk.Client.EmuHawk { if (!typeof(IToolForm).IsAssignableFrom(toolType)) { - throw new ArgumentException($"Type {toolType.Name} does not implement IToolForm."); + throw new ArgumentException($"Type {toolType.Name} does not implement {nameof(IToolForm)}."); } // The type[] in parameter is used to avoid an ambigous name exception @@ -121,6 +124,11 @@ namespace BizHawk.Client.EmuHawk (newTool as Form).Owner = GlobalWin.MainForm; } + if (isExternal) + { + ApiInjector.UpdateApis(GlobalWin.ApiProvider, newTool); + } + ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, newTool); string toolType = typeof(T).ToString(); @@ -228,7 +236,7 @@ namespace BizHawk.Client.EmuHawk if (dest == null) { - throw new InvalidOperationException("IToolFormAutoConfig must have menu to bind to!"); + throw new InvalidOperationException($"{nameof(IToolFormAutoConfig)} must have menu to bind to!"); } int idx = dest.Count; @@ -491,6 +499,8 @@ namespace BizHawk.Client.EmuHawk if ((tool.IsHandleCreated && !tool.IsDisposed) || tool is RamWatch) // Hack for RAM Watch - in display watches mode it wants to keep running even closed, it will handle disposed logic { + if (tool is IExternalToolForm) + ApiInjector.UpdateApis(GlobalWin.ApiProvider, tool); tool.Restart(); } } @@ -621,7 +631,7 @@ namespace BizHawk.Client.EmuHawk tool = Activator.CreateInstanceFrom(dllPath, "BizHawk.Client.EmuHawk.CustomMainForm").Unwrap() as IExternalToolForm; if (tool == null) { - MessageBox.Show("It seems that the object CustomMainForm does not implement IExternalToolForm. Please review the code.", "No, no, no. Wrong Way !", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + MessageBox.Show($"It seems that the object CustomMainForm does not implement {nameof(IExternalToolForm)}. Please review the code.", "No, no, no. Wrong Way !", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return null; } } @@ -730,6 +740,8 @@ namespace BizHawk.Client.EmuHawk return false; } + if (t == typeof(LuaConsole) && PlatformLinkedLibSingleton.RunningOnUnix) return false; + var tool = Assembly .GetExecutingAssembly() .GetTypes() @@ -1011,7 +1023,7 @@ namespace BizHawk.Client.EmuHawk f.Directory.Create(); } - return Path.Combine(path, PathManager.FilesystemSafeName(Global.Game) + ".cht"); + return Path.Combine(path, $"{PathManager.FilesystemSafeName(Global.Game)}.cht"); } } } diff --git a/BizHawk.Client.EmuHawk/tools/TraceLogger.Designer.cs b/BizHawk.Client.EmuHawk/tools/TraceLogger.Designer.cs index c129113c37..b9afaa15a2 100644 --- a/BizHawk.Client.EmuHawk/tools/TraceLogger.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TraceLogger.Designer.cs @@ -39,7 +39,6 @@ this.SelectAllContextMenu = new System.Windows.Forms.ToolStripMenuItem(); this.ClearContextMenu = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1 = new MenuStripEx(); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.SaveLogMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); @@ -149,7 +148,6 @@ // this.menuStrip1.ClickThrough = true; this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItem1, this.FileSubMenu, this.EditSubMenu, this.OptionsSubMenu}); @@ -159,11 +157,6 @@ this.menuStrip1.TabIndex = 2; this.menuStrip1.Text = "menuStrip1"; // - // toolStripMenuItem1 - // - this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(12, 20); - // // FileSubMenu // this.FileSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -371,7 +364,6 @@ private System.Windows.Forms.GroupBox TracerBox; private MenuStripEx menuStrip1; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem FileSubMenu; private System.Windows.Forms.ToolStripMenuItem SaveLogMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; diff --git a/BizHawk.Client.EmuHawk/tools/TraceLogger.cs b/BizHawk.Client.EmuHawk/tools/TraceLogger.cs index 45fac3a489..e1ce7d14d3 100644 --- a/BizHawk.Client.EmuHawk/tools/TraceLogger.cs +++ b/BizHawk.Client.EmuHawk/tools/TraceLogger.cs @@ -174,7 +174,7 @@ namespace BizHawk.Client.EmuHawk putter = (info) => { //no padding supported. core should be doing this! - var data = string.Format("{0} {1}", info.Disassembly, info.RegisterInfo); + var data = $"{info.Disassembly} {info.RegisterInfo}"; _streamWriter.WriteLine(data); _currentSize += (ulong)data.Length; if (_splitFile) @@ -215,7 +215,7 @@ namespace BizHawk.Client.EmuHawk foreach (var instruction in _instructions) { //no padding supported. core should be doing this! - var data = string.Format("{0} {1}", instruction.Disassembly, instruction.RegisterInfo); + var data = $"{instruction.Disassembly} {instruction.RegisterInfo}"; _streamWriter.WriteLine(data); _currentSize += (ulong)data.Length; if (_splitFile) @@ -242,7 +242,7 @@ namespace BizHawk.Client.EmuHawk } else if (_instructions.Any()) { - TracerBox.Text = "Trace log - logging - " + _instructions.Count + " instructions"; + TracerBox.Text = $"Trace log - logging - {_instructions.Count} instructions"; } else { @@ -253,7 +253,7 @@ namespace BizHawk.Client.EmuHawk { if (_instructions.Any()) { - TracerBox.Text = "Trace log - " + _instructions.Count + " instructions"; + TracerBox.Text = $"Trace log - {_instructions.Count} instructions"; } else { @@ -315,7 +315,7 @@ namespace BizHawk.Client.EmuHawk { StartLogFile(); DumpToDisk(); - GlobalWin.OSD.AddMessage("Log dumped to " + LogFile.FullName); + GlobalWin.OSD.AddMessage($"Log dumped to {LogFile.FullName}"); CloseFile(); } } @@ -334,9 +334,7 @@ namespace BizHawk.Client.EmuHawk var blob = new StringBuilder(); foreach (int index in indices) { - blob.Append(string.Format("{0} {1}\n", - _instructions[index].Disassembly, - _instructions[index].RegisterInfo)); + blob.Append($"{_instructions[index].Disassembly} {_instructions[index].RegisterInfo}\n"); } Clipboard.SetDataObject(blob.ToString()); } @@ -415,8 +413,7 @@ namespace BizHawk.Client.EmuHawk private void StartLogFile(bool append = false) { var data = Tracer.Header; - var segment = _segmentCount > 0 ? "_" + _segmentCount.ToString() : ""; - _streamWriter = new StreamWriter(_baseName + segment + _extension, append); + _streamWriter = new StreamWriter($"{_baseName}{(_segmentCount == 0 ? string.Empty : $"_{_segmentCount}")}{_extension}", append); _streamWriter.WriteLine(data); if (append) { diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualpadsTool.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualpadsTool.cs index 5b81afb644..44ca4ac00b 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualpadsTool.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualpadsTool.cs @@ -146,7 +146,7 @@ namespace BizHawk.Client.EmuHawk if (!searchset.Contains(button.Name)) { MessageBox.Show(this, - string.Format("Schema warning: Schema entry '{0}':'{1}' will not correspond to any control in definition '{2}'", schema.DisplayName, button.Name, def.Name), + $"Schema warning: Schema entry '{schema.DisplayName}':'{button.Name}' will not correspond to any control in definition '{def.Name}'", "Dev Warning"); } } diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A26Schema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A26Schema.cs index c915c4015d..900eac92db 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A26Schema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A26Schema.cs @@ -48,7 +48,7 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(174, 74), MaxSize = new Size(174, 74), @@ -56,7 +56,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(23, 15), @@ -64,7 +64,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(23, 36), @@ -72,7 +72,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(2, 24), @@ -80,7 +80,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(44, 24), @@ -88,7 +88,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Button", + Name = $"P{controller} Button", DisplayName = "B", Location = new Point(124, 24), Type = PadSchema.PadInputType.Boolean @@ -101,7 +101,7 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(334, 94), MaxSize = new Size(334, 94), @@ -109,21 +109,21 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Button 1", + Name = $"P{controller} Button 1", DisplayName = "B1", Location = new Point(5, 24), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Button 2", + Name = $"P{controller} Button 2", DisplayName = "B2", Location = new Point(5, 48), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Paddle X 1", + Name = $"P{controller} Paddle X 1", DisplayName = "Paddle X 1", Location = new Point(55, 17), Type = PadSchema.PadInputType.FloatSingle, @@ -133,7 +133,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Paddle X 2", + Name = $"P{controller} Paddle X 2", DisplayName = "Paddle X 2", Location = new Point(193, 17), Type = PadSchema.PadInputType.FloatSingle, @@ -149,7 +149,7 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(334, 94), MaxSize = new Size(334, 94), @@ -157,14 +157,14 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Button", + Name = $"P{controller} Button", DisplayName = "B1", Location = new Point(5, 24), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Wheel X 1", + Name = $"P{controller} Wheel X 1", DisplayName = "Wheel X 1", Location = new Point(55, 17), Type = PadSchema.PadInputType.FloatSingle, @@ -174,7 +174,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Wheel X 2", + Name = $"P{controller} Wheel X 2", DisplayName = "Wheel X 2", Location = new Point(193, 17), Type = PadSchema.PadInputType.FloatSingle, diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A78Schema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A78Schema.cs index 61de5d9c5c..2491618d8e 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A78Schema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A78Schema.cs @@ -55,7 +55,7 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(174, 74), MaxSize = new Size(174, 74), @@ -63,7 +63,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(23, 15), @@ -71,7 +71,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(23, 36), @@ -79,7 +79,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(2, 24), @@ -87,7 +87,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(44, 24), @@ -95,14 +95,14 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Trigger", + Name = $"P{controller} Trigger", DisplayName = "1", Location = new Point(120, 24), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Trigger 2", + Name = $"P{controller} Trigger 2", DisplayName = "2", Location = new Point(145, 24), Type = PadSchema.PadInputType.Boolean @@ -115,7 +115,7 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(174, 74), MaxSize = new Size(174, 74), @@ -123,7 +123,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(23, 15), @@ -131,7 +131,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(23, 36), @@ -139,7 +139,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(2, 24), @@ -147,7 +147,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(44, 24), @@ -155,7 +155,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Trigger", + Name = $"P{controller} Button", DisplayName = "1", Location = new Point(120, 24), Type = PadSchema.PadInputType.Boolean @@ -168,21 +168,21 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(250, 74), Buttons = new[] { new PadSchema.ButtonSchema { - Name = "P" + controller + " Paddle", + Name = $"P{controller} Paddle", DisplayName = "Paddle", Location = new Point(23, 15), Type = PadSchema.PadInputType.FloatSingle }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Trigger", + Name = $"P{controller} Trigger", DisplayName = "1", Location = new Point(12, 90), Type = PadSchema.PadInputType.Boolean @@ -203,18 +203,18 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " VPos", + Name = $"P{controller} VPos", Location = new Point(14, 17), Type = PadSchema.PadInputType.TargetedPair, TargetSize = new Size(256, 240), SecondaryNames = new[] { - "P" + controller + " HPos", + $"P{controller} HPos", } }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Trigger", + Name = $"P{controller} Trigger", DisplayName = "Trigger", Location = new Point(284, 17), Type = PadSchema.PadInputType.Boolean diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/C64Schema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/C64Schema.cs index db6cb551d3..087a49e215 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/C64Schema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/C64Schema.cs @@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(174, 74), MaxSize = new Size(174, 74), @@ -27,7 +27,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(23, 15), @@ -35,7 +35,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(23, 36), @@ -43,7 +43,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(2, 24), @@ -51,7 +51,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(44, 24), @@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Button", + Name = $"P{controller} Button", DisplayName = "B", Location = new Point(124, 24), Type = PadSchema.PadInputType.Boolean diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ColecoSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ColecoSchema.cs index 79dcea2db2..facebe0bbc 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ColecoSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ColecoSchema.cs @@ -46,7 +46,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(50, 11), @@ -54,7 +54,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(50, 32), @@ -62,7 +62,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(29, 22), @@ -70,7 +70,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(71, 22), @@ -78,14 +78,14 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L", + Name = $"P{controller} L", DisplayName = "L", Location = new Point(3, 42), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R", + Name = $"P{controller} R", DisplayName = "R", Location = new Point(100, 42), Type = PadSchema.PadInputType.Boolean @@ -93,21 +93,21 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 1", + Name = $"P{controller} Key 1", DisplayName = "1", Location = new Point(27, 85), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 2", + Name = $"P{controller} Key 2", DisplayName = "2", Location = new Point(50, 85), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 3", + Name = $"P{controller} Key 3", DisplayName = "3", Location = new Point(73, 85), Type = PadSchema.PadInputType.Boolean @@ -115,21 +115,21 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 4", + Name = $"P{controller} Key 4", DisplayName = "4", Location = new Point(27, 108), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 5", + Name = $"P{controller} Key 5", DisplayName = "5", Location = new Point(50, 108), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 6", + Name = $"P{controller} Key 6", DisplayName = "6", Location = new Point(73, 108), Type = PadSchema.PadInputType.Boolean @@ -137,21 +137,21 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 7", + Name = $"P{controller} Key 7", DisplayName = "7", Location = new Point(27, 131), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 8", + Name = $"P{controller} Key 8", DisplayName = "8", Location = new Point(50, 131), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 9", + Name = $"P{controller} Key 9", DisplayName = "9", Location = new Point(73, 131), Type = PadSchema.PadInputType.Boolean @@ -159,21 +159,21 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Star", + Name = $"P{controller} Star", DisplayName = "*", Location = new Point(27, 154), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 0", + Name = $"P{controller} Key 0", DisplayName = "0", Location = new Point(50, 154), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Pound", + Name = $"P{controller} Pound", DisplayName = "#", Location = new Point(73, 154), Type = PadSchema.PadInputType.Boolean @@ -192,7 +192,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Disc X", + Name = $"P{controller} Disc X", MinValue = -127, MidValue = 0, MaxValue = 127, @@ -205,7 +205,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Pedal", + Name = $"P{controller} Pedal", DisplayName = "Pedal", Location = new Point(6, 224), Type = PadSchema.PadInputType.Boolean @@ -224,7 +224,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(50, 11), @@ -232,7 +232,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(50, 32), @@ -240,7 +240,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(29, 22), @@ -248,7 +248,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(71, 22), @@ -257,21 +257,21 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 1", + Name = $"P{controller} Key 1", DisplayName = "1", Location = new Point(27, 85), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 2", + Name = $"P{controller} Key 2", DisplayName = "2", Location = new Point(50, 85), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 3", + Name = $"P{controller} Key 3", DisplayName = "3", Location = new Point(73, 85), Type = PadSchema.PadInputType.Boolean @@ -279,21 +279,21 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 4", + Name = $"P{controller} Key 4", DisplayName = "4", Location = new Point(27, 108), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 5", + Name = $"P{controller} Key 5", DisplayName = "5", Location = new Point(50, 108), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 6", + Name = $"P{controller} Key 6", DisplayName = "6", Location = new Point(73, 108), Type = PadSchema.PadInputType.Boolean @@ -301,21 +301,21 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 7", + Name = $"P{controller} Key 7", DisplayName = "7", Location = new Point(27, 131), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 8", + Name = $"P{controller} Key 8", DisplayName = "8", Location = new Point(50, 131), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 9", + Name = $"P{controller} Key 9", DisplayName = "9", Location = new Point(73, 131), Type = PadSchema.PadInputType.Boolean @@ -323,21 +323,21 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Star", + Name = $"P{controller} Star", DisplayName = "*", Location = new Point(27, 154), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 0", + Name = $"P{controller} Key 0", DisplayName = "0", Location = new Point(50, 154), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Pound", + Name = $"P{controller} Pound", DisplayName = "#", Location = new Point(73, 154), Type = PadSchema.PadInputType.Boolean @@ -345,7 +345,7 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Disc X", + Name = $"P{controller} Disc X", DisplayName = "Disc", Location = new Point(6, 200), TargetSize = new Size(180, 55), @@ -356,28 +356,28 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Yellow", + Name = $"P{controller} Yellow", DisplayName = "Yellow", Location = new Point(126, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Red", + Name = $"P{controller} Red", DisplayName = "Red", Location = new Point(126, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Purple", + Name = $"P{controller} Purple", DisplayName = "Purple", Location = new Point(126, 65), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Blue", + Name = $"P{controller} Blue", DisplayName = "Blue", Location = new Point(126, 90), Type = PadSchema.PadInputType.Boolean diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/DualGBSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/DualGBSchema.cs index 445edd5419..fa2994abd2 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/DualGBSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/DualGBSchema.cs @@ -24,7 +24,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(14, 12), @@ -32,7 +32,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(14, 56), @@ -40,7 +40,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(2, 34), @@ -48,7 +48,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(24, 34), @@ -56,28 +56,28 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(122, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(146, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Select", + Name = $"P{controller} Select", DisplayName = "s", Location = new Point(52, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(74, 34), Type = PadSchema.PadInputType.Boolean diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/GGLSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/GGLSchema.cs new file mode 100644 index 0000000000..ef7a52875f --- /dev/null +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/GGLSchema.cs @@ -0,0 +1,78 @@ +using System.Collections.Generic; +using System.Drawing; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.EmuHawk +{ + [Schema("GGL")] + public class GGLSchema : IVirtualPadSchema + { + public IEnumerable GetPadSchemas(IEmulator core) + { + yield return StandardController(1); + yield return StandardController(2); + } + + private static PadSchema StandardController(int controller) + { + return new PadSchema + { + IsConsole = false, + DefaultSize = new Size(174, 90), + Buttons = new[] + { + new PadSchema.ButtonSchema + { + Name = $"P{controller} Up", + Icon = Properties.Resources.BlueUp, + Location = new Point(14, 12), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Down", + Icon = Properties.Resources.BlueDown, + Location = new Point(14, 56), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Left", + Icon = Properties.Resources.Back, + Location = new Point(2, 34), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Right", + Icon = Properties.Resources.Forward, + Location = new Point(24, 34), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Start", + DisplayName = "S", + Location = new Point(134, 12), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} B1", + DisplayName = "1", + Location = new Point(122, 34), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} B2", + DisplayName = "2", + Location = new Point(146, 34), + Type = PadSchema.PadInputType.Boolean + } + } + }; + } + } +} diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/GenSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/GenSchema.cs index 32f4c0717e..b5a35b32c4 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/GenSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/GenSchema.cs @@ -76,7 +76,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(14, 12), @@ -84,7 +84,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(14, 56), @@ -92,7 +92,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(2, 34), @@ -100,7 +100,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(24, 34), @@ -108,28 +108,28 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(98, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(122, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C", + Name = $"P{controller} C", DisplayName = "C", Location = new Point(146, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(122, 12), Type = PadSchema.PadInputType.Boolean @@ -148,7 +148,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(14, 12), @@ -156,7 +156,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(14, 56), @@ -164,7 +164,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(2, 34), @@ -172,7 +172,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(24, 34), @@ -180,49 +180,49 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(98, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(122, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C", + Name = $"P{controller} C", DisplayName = "C", Location = new Point(146, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X", + Name = $"P{controller} X", DisplayName = "X", Location = new Point(98, 65), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y", + Name = $"P{controller} Y", DisplayName = "Y", Location = new Point(122, 65), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Z", + Name = $"P{controller} Z", DisplayName = "Z", Location = new Point(146, 65), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(122, 12), Type = PadSchema.PadInputType.Boolean @@ -242,26 +242,26 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Lightgun X", + Name = $"P{controller} Lightgun X", Location = new Point(14, 17), Type = PadSchema.PadInputType.TargetedPair, MaxValue = 10000, TargetSize = new Size(320, 240), SecondaryNames = new[] { - "P" + controller + " Lightgun Y", + $"P{controller} Lightgun Y", } }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Lightgun Trigger", + Name = $"P{controller} Lightgun Trigger", DisplayName = "Trigger", Location = new Point(284, 17), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Lightgun Start", + Name = $"P{controller} Lightgun Start", DisplayName = "Start", Location = new Point(284, 40), Type = PadSchema.PadInputType.Boolean @@ -281,40 +281,40 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse X", + Name = $"P{controller} Mouse X", Location = new Point(14, 17), Type = PadSchema.PadInputType.AnalogStick, MaxValue = 255, TargetSize = new Size(520, 570), SecondaryNames = new[] { - "P" + controller + " Mouse Y", + $"P{controller} Mouse Y", } }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Left", + Name = $"P{controller} Mouse Left", DisplayName = "Left", Location = new Point(365, 17), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Center", + Name = $"P{controller} Mouse Center", DisplayName = "Center", Location = new Point(365, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Right", + Name = $"P{controller} Mouse Right", DisplayName = "Right", Location = new Point(365, 63), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Start", + Name = $"P{controller} Mouse Start", DisplayName = "Start", Location = new Point(365, 86), Type = PadSchema.PadInputType.Boolean @@ -360,7 +360,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(47, 10), @@ -368,7 +368,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(47, 73), @@ -376,7 +376,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(15, 43), @@ -384,7 +384,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(80, 43), @@ -392,35 +392,35 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(70, 65), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(70, 20), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C", + Name = $"P{controller} C", DisplayName = "C", Location = new Point(22, 20), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(22, 65), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(47, 43), Type = PadSchema.PadInputType.Boolean @@ -439,56 +439,56 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(98, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(122, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C", + Name = $"P{controller} C", DisplayName = "C", Location = new Point(146, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " D", + Name = $"P{controller} D", DisplayName = "D", Location = new Point(98, 65), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " E1", + Name = $"P{controller} E1", DisplayName = "E¹", Location = new Point(122, 65), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " E2", + Name = $"P{controller} E2", DisplayName = "E²", Location = new Point(152, 65), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "Start", Location = new Point(122, 12), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Select", + Name = $"P{controller} Select", DisplayName = "Select", Location = new Point(162, 12), Type = PadSchema.PadInputType.Boolean diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs index 1ebad3d4de..6299da5f5f 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs @@ -43,91 +43,91 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(148, 332), Buttons = new[] { new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 1", + Name = $"P{controller} Key 1", DisplayName = "1", Location = new Point(25, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 2", + Name = $"P{controller} Key 2", DisplayName = "2", Location = new Point(51, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 3", + Name = $"P{controller} Key 3", DisplayName = "3", Location = new Point(77, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 4", + Name = $"P{controller} Key 4", DisplayName = "4", Location = new Point(25, 41), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 5", + Name = $"P{controller} Key 5", DisplayName = "5", Location = new Point(51, 41), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 6", + Name = $"P{controller} Key 6", DisplayName = "6", Location = new Point(77, 41), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 7", + Name = $"P{controller} Key 7", DisplayName = "7", Location = new Point(25, 67), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 8", + Name = $"P{controller} Key 8", DisplayName = "8", Location = new Point(51, 67), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 9", + Name = $"P{controller} Key 9", DisplayName = "9", Location = new Point(77, 67), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Clear", + Name = $"P{controller} Clear", DisplayName = "C", Location = new Point(25, 93), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 0", + Name = $"P{controller} Key 0", DisplayName = "0", Location = new Point(51, 93), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Enter", + Name = $"P{controller} Enter", DisplayName = "E", Location = new Point(77, 93), Type = PadSchema.PadInputType.Boolean @@ -135,14 +135,14 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Top", + Name = $"P{controller} Top", DisplayName = "T", Location = new Point(2, 41), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Top", + Name = $"P{controller} Top", DisplayName = "T", Location = new Point(100, 41), Type = PadSchema.PadInputType.Boolean @@ -150,14 +150,14 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " L", + Name = $"P{controller} L", DisplayName = "L", Location = new Point(2, 67), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R", + Name = $"P{controller} R", DisplayName = "R", Location = new Point(100, 67), Type = PadSchema.PadInputType.Boolean @@ -167,112 +167,112 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " N", + Name = $"P{controller} N", Icon = Properties.Resources.BlueUp, Location = new Point(51, 124), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " NNE", + Name = $"P{controller} NNE", Icon = Properties.Resources.NNE, Location = new Point(63, 145), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " NNW", + Name = $"P{controller} NNW", Icon = Properties.Resources.NNW, Location = new Point(39, 145), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " NE", + Name = $"P{controller} NE", Icon = Properties.Resources.NE, Location = new Point(75, 166), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " NW", + Name = $"P{controller} NW", Icon = Properties.Resources.NW, Location = new Point(27, 166), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " ENE", + Name = $"P{controller} ENE", Icon = Properties.Resources.ENE, Location = new Point(87, 187), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " WNW", + Name = $"P{controller} WNW", Icon = Properties.Resources.WNW, Location = new Point(15, 187), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " E", + Name = $"P{controller} E", Icon = Properties.Resources.Forward, Location = new Point(99, 208), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " W", + Name = $"P{controller} W", Icon = Properties.Resources.Back, Location = new Point(3, 208), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " ESE", + Name = $"P{controller} ESE", Icon = Properties.Resources.ESE, Location = new Point(87, 229), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " WSW", + Name = $"P{controller} WSW", Icon = Properties.Resources.WSW, Location = new Point(15, 229), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " SE", + Name = $"P{controller} SE", Icon = Properties.Resources.SE, Location = new Point(75, 250), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " SW", + Name = $"P{controller} SW", Icon = Properties.Resources.SW, Location = new Point(27, 250), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " SSE", + Name = $"P{controller} SSE", Icon = Properties.Resources.SSE, Location = new Point(63, 271), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " SSW", + Name = $"P{controller} SSW", Icon = Properties.Resources.SSW, Location = new Point(39, 271), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " S", + Name = $"P{controller} S", Icon = Properties.Resources.BlueDown, Location = new Point(51, 292), Type = PadSchema.PadInputType.Boolean @@ -285,91 +285,91 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(280, 332), Buttons = new[] { new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 1", + Name = $"P{controller} Key 1", DisplayName = "1", Location = new Point(91, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 2", + Name = $"P{controller} Key 2", DisplayName = "2", Location = new Point(117, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 3", + Name = $"P{controller} Key 3", DisplayName = "3", Location = new Point(143, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 4", + Name = $"P{controller} Key 4", DisplayName = "4", Location = new Point(91, 41), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 5", + Name = $"P{controller} Key 5", DisplayName = "5", Location = new Point(117, 41), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 6", + Name = $"P{controller} Key 6", DisplayName = "6", Location = new Point(143, 41), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 7", + Name = $"P{controller} Key 7", DisplayName = "7", Location = new Point(91, 67), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 8", + Name = $"P{controller} Key 8", DisplayName = "8", Location = new Point(117, 67), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 9", + Name = $"P{controller} Key 9", DisplayName = "9", Location = new Point(143, 67), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Clear", + Name = $"P{controller} Clear", DisplayName = "C", Location = new Point(91, 93), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Key 0", + Name = $"P{controller} Key 0", DisplayName = "0", Location = new Point(117, 93), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Enter", + Name = $"P{controller} Enter", DisplayName = "E", Location = new Point(143, 93), Type = PadSchema.PadInputType.Boolean @@ -377,14 +377,14 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Top", + Name = $"P{controller} Top", DisplayName = "T", Location = new Point(68, 41), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Top", + Name = $"P{controller} Top", DisplayName = "T", Location = new Point(166, 41), Type = PadSchema.PadInputType.Boolean @@ -392,21 +392,21 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " L", + Name = $"P{controller} L", DisplayName = "L", Location = new Point(68, 67), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R", + Name = $"P{controller} R", DisplayName = "R", Location = new Point(166, 67), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Disc X", + Name = $"P{controller} Disc X", MinValue = -127, MidValue = 0, MaxValue = 127, diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/N64Schema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/N64Schema.cs index 5d66220a90..e8b1c0e9be 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/N64Schema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/N64Schema.cs @@ -31,7 +31,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " DPad U", + Name = $"P{controller} DPad U", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(24, 230), @@ -39,7 +39,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " DPad D", + Name = $"P{controller} DPad D", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(24, 251), @@ -47,7 +47,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " DPad L", + Name = $"P{controller} DPad L", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(3, 242), @@ -55,7 +55,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " DPad R", + Name = $"P{controller} DPad R", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(45, 242), @@ -63,77 +63,77 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L", + Name = $"P{controller} L", DisplayName = "L", Location = new Point(3, 185), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R", + Name = $"P{controller} R", DisplayName = "R", Location = new Point(191, 185), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Z", + Name = $"P{controller} Z", DisplayName = "Z", Location = new Point(81, 269), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(81, 246), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(127, 246), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(138, 269), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C Up", + Name = $"P{controller} C Up", Icon = Properties.Resources.YellowUp, Location = new Point(173, 210), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C Down", + Name = $"P{controller} C Down", Icon = Properties.Resources.YellowDown, Location = new Point(173, 231), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C Left", + Name = $"P{controller} C Left", Icon = Properties.Resources.YellowLeft, Location = new Point(152, 221), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C Right", + Name = $"P{controller} C Right", Icon = Properties.Resources.YellowRight, Location = new Point(194, 221), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X Axis", + Name = $"P{controller} X Axis", MinValue = -128, MidValue = 0, MaxValue = 127, diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/NesSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/NesSchema.cs index c8032fc0e4..f0a9581b6d 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/NesSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/NesSchema.cs @@ -203,8 +203,8 @@ namespace BizHawk.Client.EmuHawk { buttons.Add(new PadSchema.ButtonSchema { - Name = "FDS Insert " + i, - DisplayName = "Insert " + i, + Name = $"FDS Insert {i}", + DisplayName = $"Insert {i}", Location = new Point(10 + (i * 58), 50), Type = PadSchema.PadInputType.Boolean }); @@ -229,7 +229,7 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(174, 74), MaxSize = new Size(174, 74), @@ -237,7 +237,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(23, 15), @@ -245,7 +245,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(23, 36), @@ -253,7 +253,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(2, 24), @@ -261,7 +261,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(44, 24), @@ -269,28 +269,28 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(124, 24), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(147, 24), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Select", + Name = $"P{controller} Select", DisplayName = "s", Location = new Point(72, 24), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(93, 24), Type = PadSchema.PadInputType.Boolean @@ -312,7 +312,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(23, 15), @@ -320,7 +320,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(23, 36), @@ -328,7 +328,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(2, 24), @@ -336,7 +336,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(44, 24), @@ -344,21 +344,21 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(124, 24), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(147, 24), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Microphone", + Name = $"P{controller} Microphone", DisplayName = "Mic", Location = new Point(72, 24), Type = PadSchema.PadInputType.Boolean @@ -379,18 +379,18 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Zapper X", + Name = $"P{controller} Zapper X", Location = new Point(14, 17), Type = PadSchema.PadInputType.TargetedPair, TargetSize = new Size(256, 240), SecondaryNames = new[] { - "P" + controller + " Zapper Y", + $"P{controller} Zapper Y", } }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Fire", + Name = $"P{controller} Fire", DisplayName = "Fire", Location = new Point(284, 17), Type = PadSchema.PadInputType.Boolean @@ -411,7 +411,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Paddle", + Name = $"P{controller} Paddle", DisplayName = "Arkanoid Paddle", Location = new Point(14, 17), Type = PadSchema.PadInputType.FloatSingle, @@ -420,7 +420,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Fire", + Name = $"P{controller} Fire", DisplayName = "Fire", Location = new Point(14, 85), Type = PadSchema.PadInputType.Boolean @@ -440,56 +440,56 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " PP1", + Name = $"P{controller} PP1", DisplayName = "1 ", Location = new Point(14, 17), Type = PadSchema.PadInputType.Boolean, }, new PadSchema.ButtonSchema { - Name = "P" + controller + " PP2", + Name = $"P{controller} PP2", DisplayName = "2 ", Location = new Point(45, 17), Type = PadSchema.PadInputType.Boolean, }, new PadSchema.ButtonSchema { - Name = "P" + controller + " PP3", + Name = $"P{controller} PP3", DisplayName = "3 ", Location = new Point(76, 17), Type = PadSchema.PadInputType.Boolean, }, new PadSchema.ButtonSchema { - Name = "P" + controller + " PP4", + Name = $"P{controller} PP4", DisplayName = "4 ", Location = new Point(107, 17), Type = PadSchema.PadInputType.Boolean, }, new PadSchema.ButtonSchema { - Name = "P" + controller + " PP5", + Name = $"P{controller} PP5", DisplayName = "5 ", Location = new Point(14, 48), Type = PadSchema.PadInputType.Boolean, }, new PadSchema.ButtonSchema { - Name = "P" + controller + " PP6", + Name = $"P{controller} PP6", DisplayName = "6 ", Location = new Point(45, 48), Type = PadSchema.PadInputType.Boolean, }, new PadSchema.ButtonSchema { - Name = "P" + controller + " PP7", + Name = $"P{controller} PP7", DisplayName = "7 ", Location = new Point(76, 48), Type = PadSchema.PadInputType.Boolean, }, new PadSchema.ButtonSchema { - Name = "P" + controller + " PP8", + Name = $"P{controller} PP8", DisplayName = "8 ", Location = new Point(107, 48), Type = PadSchema.PadInputType.Boolean, @@ -497,28 +497,28 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " PP9", + Name = $"P{controller} PP9", DisplayName = "9 ", Location = new Point(14, 79), Type = PadSchema.PadInputType.Boolean, }, new PadSchema.ButtonSchema { - Name = "P" + controller + " PP10", + Name = $"P{controller} PP10", DisplayName = "10", Location = new Point(45, 79), Type = PadSchema.PadInputType.Boolean, }, new PadSchema.ButtonSchema { - Name = "P" + controller + " PP11", + Name = $"P{controller} PP11", DisplayName = "11", Location = new Point(76, 79), Type = PadSchema.PadInputType.Boolean, }, new PadSchema.ButtonSchema { - Name = "P" + controller + " PP12", + Name = $"P{controller} PP12", DisplayName = "12", Location = new Point(107, 79), Type = PadSchema.PadInputType.Boolean, @@ -539,25 +539,25 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Pen X", + Name = $"P{controller} Pen X", Location = new Point(14, 17), Type = PadSchema.PadInputType.TargetedPair, TargetSize = new Size(256, 240), SecondaryNames = new[] { - "P" + controller + " Pen Y", + $"P{controller} Pen Y", } }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Click", + Name = $"P{controller} Click", DisplayName = "Click", Location = new Point(284, 17), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Touch", + Name = $"P{controller} Touch", DisplayName = "Touch", Location = new Point(284, 48), Type = PadSchema.PadInputType.Boolean @@ -577,504 +577,504 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " F1", + Name = $"P{controller} F1", DisplayName = " F1 ", Location = new Point(23, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " F2", + Name = $"P{controller} F2", DisplayName = " F2 ", Location = new Point(76, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " F3", + Name = $"P{controller} F3", DisplayName = " F3 ", Location = new Point(129, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " F4", + Name = $"P{controller} F4", DisplayName = " F4 ", Location = new Point(182, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " F5", + Name = $"P{controller} F5", DisplayName = " F5 ", Location = new Point(235, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " F6", + Name = $"P{controller} F6", DisplayName = " F6 ", Location = new Point(288, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " F7", + Name = $"P{controller} F7", DisplayName = " F7 ", Location = new Point(341, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " F8", + Name = $"P{controller} F8", DisplayName = " F8 ", Location = new Point(394, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 1", + Name = $"P{controller} 1", DisplayName = "1", Location = new Point(36, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 2", + Name = $"P{controller} 2", DisplayName = "2", Location = new Point(60, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 3", + Name = $"P{controller} 3", DisplayName = "3", Location = new Point(84, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 4", + Name = $"P{controller} 4", DisplayName = "4", Location = new Point(108, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 5", + Name = $"P{controller} 5", DisplayName = "5", Location = new Point(132, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 6", + Name = $"P{controller} 6", DisplayName = "6", Location = new Point(156, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 7", + Name = $"P{controller} 7", DisplayName = "7", Location = new Point(180, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 8", + Name = $"P{controller} 8", DisplayName = "8", Location = new Point(204, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 9", + Name = $"P{controller} 9", DisplayName = "9", Location = new Point(228, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 0", + Name = $"P{controller} 0", DisplayName = "0", Location = new Point(252, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Minus", + Name = $"P{controller} Minus", DisplayName = "-", Location = new Point(276, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Caret", + Name = $"P{controller} Caret", DisplayName = "^", Location = new Point(296, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Yen", + Name = $"P{controller} Yen", DisplayName = "¥", Location = new Point(320, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Stop", + Name = $"P{controller} Stop", DisplayName = "STOP", Location = new Point(344, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Escape", + Name = $"P{controller} Escape", DisplayName = "ESC", Location = new Point(15, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Q", + Name = $"P{controller} Q", DisplayName = "Q", Location = new Point(54, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " W", + Name = $"P{controller} W", DisplayName = "W", Location = new Point(80, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " E", + Name = $"P{controller} E", DisplayName = "E", Location = new Point(108, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R", + Name = $"P{controller} R", DisplayName = "R", Location = new Point(132, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " T", + Name = $"P{controller} T", DisplayName = "T", Location = new Point(158, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y", + Name = $"P{controller} Y", DisplayName = "Y", Location = new Point(182, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " U", + Name = $"P{controller} U", DisplayName = "U", Location = new Point(206, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " I", + Name = $"P{controller} I", DisplayName = "I", Location = new Point(232, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " O", + Name = $"P{controller} O", DisplayName = "O", Location = new Point(252, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " P", + Name = $"P{controller} P", DisplayName = "P", Location = new Point(278, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " At", + Name = $"P{controller} At", DisplayName = "@", Location = new Point(302, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left Bracket", + Name = $"P{controller} Left Bracket", DisplayName = "[", Location = new Point(330, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Return", + Name = $"P{controller} Return", DisplayName = "RETURN", Location = new Point(350, 61), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Control", + Name = $"P{controller} Control", DisplayName = "CTR", Location = new Point(30, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(70, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " S", + Name = $"P{controller} S", DisplayName = "S", Location = new Point(94, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " D", + Name = $"P{controller} D", DisplayName = "D", Location = new Point(118, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " F", + Name = $"P{controller} F", DisplayName = "F", Location = new Point(144, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " G", + Name = $"P{controller} G", DisplayName = "G", Location = new Point(168, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " H", + Name = $"P{controller} H", DisplayName = "H", Location = new Point(194, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " J", + Name = $"P{controller} J", DisplayName = "J", Location = new Point(220, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " K", + Name = $"P{controller} K", DisplayName = "K", Location = new Point(242, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L", + Name = $"P{controller} L", DisplayName = "L", Location = new Point(266, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Semicolon", + Name = $"P{controller} Semicolon", DisplayName = ";", Location = new Point(290, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Colon", + Name = $"P{controller} Colon", DisplayName = ":", Location = new Point(311, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right Bracket", + Name = $"P{controller} Right Bracket", DisplayName = "]", Location = new Point(332, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " カナ", + Name = $"P{controller} カナ", DisplayName = "カナ", Location = new Point(352, 84), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left Shift", + Name = $"P{controller} Left Shift", DisplayName = "SHIFT", Location = new Point(10, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Z", + Name = $"P{controller} Z", DisplayName = "Z", Location = new Point(58, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X", + Name = $"P{controller} X", DisplayName = "X", Location = new Point(82, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C", + Name = $"P{controller} C", DisplayName = "C", Location = new Point(106, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " V", + Name = $"P{controller} V", DisplayName = "V", Location = new Point(130, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(154, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " N", + Name = $"P{controller} N", DisplayName = "N", Location = new Point(178, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " M", + Name = $"P{controller} M", DisplayName = "M", Location = new Point(203, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Comma", + Name = $"P{controller} Comma", DisplayName = ",", Location = new Point(229, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Period", + Name = $"P{controller} Period", DisplayName = ".", Location = new Point(249, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Slash", + Name = $"P{controller} Slash", DisplayName = "/", Location = new Point(270, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Underscore", + Name = $"P{controller} Underscore", DisplayName = "_", Location = new Point(292, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right Shift", + Name = $"P{controller} Right Shift", DisplayName = "SHIFT", Location = new Point(316, 107), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Graph", + Name = $"P{controller} Graph", DisplayName = "GRPH", Location = new Point(82, 130), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Space", + Name = $"P{controller} Space", DisplayName = " SPACE ", Location = new Point(130, 130), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Clear/Home", + Name = $"P{controller} Clear/Home", DisplayName = " CLR\nHOME", Location = new Point(420, 46), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Insert", + Name = $"P{controller} Insert", DisplayName = "\nINS", Location = new Point(470, 46), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Delete", + Name = $"P{controller} Delete", DisplayName = "\nDEL", Location = new Point(506, 46), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = " ↑ ", Location = new Point(468, 86), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = " ↓ ", Location = new Point(468, 134), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = " ← ", Location = new Point(446, 110), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = " ➝ ", Location = new Point(488, 110), Type = PadSchema.PadInputType.Boolean diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PSXSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PSXSchema.cs index 8277cf0d5a..0da6825d37 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PSXSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PSXSchema.cs @@ -49,12 +49,12 @@ namespace BizHawk.Client.EmuHawk { IsConsole = false, DefaultSize = new Size(500, 290), - DisplayName = "DualShock Player" + controller, + DisplayName = $"DualShock Player{controller}", Buttons = new[] { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(32, 50), @@ -62,7 +62,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(32, 71), @@ -70,7 +70,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(11, 62), @@ -78,7 +78,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(53, 62), @@ -86,49 +86,49 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L1", + Name = $"P{controller} L1", DisplayName = "L1", Location = new Point(3, 32), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R1", + Name = $"P{controller} R1", DisplayName = "R1", Location = new Point(191, 32), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L2", + Name = $"P{controller} L2", DisplayName = "L2", Location = new Point(3, 10), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R2", + Name = $"P{controller} R2", DisplayName = "R2", Location = new Point(191, 10), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L3", + Name = $"P{controller} L3", DisplayName = "L3", Location = new Point(72, 90), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R3", + Name = $"P{controller} R3", DisplayName = "R3", Location = new Point(130, 90), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Square", + Name = $"P{controller} Square", DisplayName = "", Icon = Properties.Resources.Square, Location = new Point(148, 62), @@ -136,7 +136,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Triangle", + Name = $"P{controller} Triangle", DisplayName = "", Icon = Properties.Resources.Triangle, Location = new Point(169, 50), @@ -144,7 +144,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Circle", + Name = $"P{controller} Circle", DisplayName = "", Icon = Properties.Resources.Circle, Location = new Point(190, 62), @@ -152,7 +152,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Cross", + Name = $"P{controller} Cross", DisplayName = "", Icon = Properties.Resources.Cross, Location = new Point(169, 71), @@ -160,21 +160,21 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(112, 62), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Select", + Name = $"P{controller} Select", DisplayName = "s", Location = new Point(90, 62), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " LStick X", + Name = $"P{controller} LStick X", MinValue = 0, MidValue = 128, MaxValue = 255, @@ -187,7 +187,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " RStick X", + Name = $"P{controller} RStick X", MinValue = 0, MidValue = 128, MaxValue = 255, @@ -208,12 +208,12 @@ namespace BizHawk.Client.EmuHawk { IsConsole = false, DefaultSize = new Size(240, 115), - DisplayName = "Gamepad Player" + controller, + DisplayName = $"Gamepad Player{controller}", Buttons = new[] { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(37, 55), @@ -221,7 +221,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(37, 76), @@ -229,7 +229,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(16, 67), @@ -237,7 +237,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(58, 67), @@ -245,35 +245,35 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L1", + Name = $"P{controller} L1", DisplayName = "L1", Location = new Point(8, 37), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R1", + Name = $"P{controller} R1", DisplayName = "R1", Location = new Point(196, 37), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L2", + Name = $"P{controller} L2", DisplayName = "L2", Location = new Point(8, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R2", + Name = $"P{controller} R2", DisplayName = "R2", Location = new Point(196, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Square", + Name = $"P{controller} Square", DisplayName = "", Icon = Properties.Resources.Square, Location = new Point(153, 67), @@ -281,7 +281,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Triangle", + Name = $"P{controller} Triangle", DisplayName = "", Icon = Properties.Resources.Triangle, Location = new Point(174, 55), @@ -289,7 +289,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Circle", + Name = $"P{controller} Circle", DisplayName = "", Icon = Properties.Resources.Circle, Location = new Point(195, 67), @@ -297,7 +297,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Cross", + Name = $"P{controller} Cross", DisplayName = "", Icon = Properties.Resources.Cross, Location = new Point(174, 76), @@ -305,14 +305,14 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(112, 67), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Select", + Name = $"P{controller} Select", DisplayName = "s", Location = new Point(90, 67), Type = PadSchema.PadInputType.Boolean @@ -327,12 +327,12 @@ namespace BizHawk.Client.EmuHawk { IsConsole = false, DefaultSize = new Size(343, 195), - DisplayName = "NeGcon Player" + controller, + DisplayName = $"NeGcon Player{controller}", Buttons = new[] { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(36, 83), @@ -340,7 +340,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(36, 104), @@ -348,7 +348,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(15, 95), @@ -356,7 +356,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(57, 95), @@ -364,7 +364,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(78, 118), Type = PadSchema.PadInputType.Boolean @@ -372,14 +372,14 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(278, 38), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(308, 55), Type = PadSchema.PadInputType.Boolean @@ -387,7 +387,7 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " R", + Name = $"P{controller} R", DisplayName = "R", Location = new Point(308, 15), Type = PadSchema.PadInputType.Boolean @@ -395,7 +395,7 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " L", + Name = $"P{controller} L", DisplayName = "L", Location = new Point(5, 15), Type = PadSchema.PadInputType.FloatSingle, @@ -405,7 +405,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Twist", + Name = $"P{controller} Twist", DisplayName = "Twist", Location = new Point(125, 15), Type = PadSchema.PadInputType.FloatSingle, @@ -416,7 +416,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 2", + Name = $"P{controller} 2", DisplayName = "II", Location = new Point(180, 60), Type = PadSchema.PadInputType.FloatSingle, @@ -426,7 +426,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " 1", + Name = $"P{controller} 1", DisplayName = "I", Location = new Point(220, 120), Type = PadSchema.PadInputType.FloatSingle, diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PcfxSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PcfxSchema.cs index 40597c4e78..c461599051 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PcfxSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/PcfxSchema.cs @@ -52,7 +52,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(34, 17), @@ -60,7 +60,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(34, 61), @@ -68,7 +68,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(22, 39), @@ -76,7 +76,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(44, 39), @@ -86,28 +86,28 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Mode 1", + Name = $"P{controller} Mode 1", DisplayName = "Mode 1", Location = new Point(74, 17), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mode 2", + Name = $"P{controller} Mode 2", DisplayName = "Mode 2", Location = new Point(74, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Select", + Name = $"P{controller} Select", DisplayName = "s", Location = new Point(77, 63), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Run", + Name = $"P{controller} Run", DisplayName = "R", Location = new Point(101, 63), Type = PadSchema.PadInputType.Boolean @@ -115,42 +115,42 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " IV", + Name = $"P{controller} IV", DisplayName = "IV", Location = new Point(140, 63), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " V", + Name = $"P{controller} V", DisplayName = "V", Location = new Point(166, 53), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " VI", + Name = $"P{controller} VI", DisplayName = "VI", Location = new Point(192, 43), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " I", + Name = $"P{controller} I", DisplayName = "I", Location = new Point(140, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " II", + Name = $"P{controller} II", DisplayName = "II", Location = new Point(166, 30), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " III", + Name = $"P{controller} III", DisplayName = "III", Location = new Point(192, 20), Type = PadSchema.PadInputType.Boolean @@ -178,14 +178,14 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Left", + Name = $"P{controller} Mouse Left", DisplayName = "Left", Location = new Point(300, 17), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Right", + Name = $"P{controller} Mouse Right", DisplayName = "Right", Location = new Point(300, 47), Type = PadSchema.PadInputType.Boolean diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SatSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SatSchema.cs index 73559c2678..063410e332 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SatSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SatSchema.cs @@ -75,7 +75,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(34, 17), @@ -83,7 +83,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(34, 61), @@ -91,7 +91,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(22, 39), @@ -99,7 +99,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(44, 39), @@ -107,63 +107,63 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(78, 52), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(110, 63), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(134, 53), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C", + Name = $"P{controller} C", DisplayName = "C", Location = new Point(158, 43), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X", + Name = $"P{controller} X", DisplayName = "X", Location = new Point(110, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y", + Name = $"P{controller} Y", DisplayName = "Y", Location = new Point(134, 30), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Z", + Name = $"P{controller} Z", DisplayName = "Z", Location = new Point(158, 20), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L", + Name = $"P{controller} L", DisplayName = "L", Location = new Point(2, 10), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R", + Name = $"P{controller} R", DisplayName = "R", Location = new Point(184, 10), Type = PadSchema.PadInputType.Boolean @@ -182,7 +182,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(290, 77), @@ -190,7 +190,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(290, 121), @@ -198,7 +198,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(278, 99), @@ -206,7 +206,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(300, 99), @@ -214,49 +214,49 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(334, 112), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(366, 123), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(390, 113), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C", + Name = $"P{controller} C", DisplayName = "C", Location = new Point(414, 103), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X", + Name = $"P{controller} X", DisplayName = "X", Location = new Point(366, 100), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y", + Name = $"P{controller} Y", DisplayName = "Y", Location = new Point(390, 90), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Z", + Name = $"P{controller} Z", DisplayName = "Z", Location = new Point(414, 80), Type = PadSchema.PadInputType.Boolean @@ -318,28 +318,28 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Left", + Name = $"P{controller} Mouse Left", DisplayName = "Left", Location = new Point(300, 17), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Center", + Name = $"P{controller} Mouse Center", DisplayName = "Center", Location = new Point(300, 47), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Right", + Name = $"P{controller} Mouse Right", DisplayName = "Right", Location = new Point(300, 77), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "Start", Location = new Point(300, 107), Type = PadSchema.PadInputType.Boolean @@ -369,7 +369,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(150, 20), @@ -377,7 +377,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(150, 43), @@ -385,49 +385,49 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(180, 63), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(204, 53), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C", + Name = $"P{controller} C", DisplayName = "C", Location = new Point(228, 43), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X", + Name = $"P{controller} X", DisplayName = "X", Location = new Point(180, 40), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y", + Name = $"P{controller} Y", DisplayName = "Y", Location = new Point(204, 30), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Z", + Name = $"P{controller} Z", DisplayName = "Z", Location = new Point(228, 20), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "Start", Location = new Point(268, 20), Type = PadSchema.PadInputType.Boolean @@ -448,63 +448,63 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "Start", Location = new Point(45, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L", + Name = $"P{controller} L", DisplayName = "L", Location = new Point(5, 58), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R", + Name = $"P{controller} R", DisplayName = "R", Location = new Point(105, 58), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X", + Name = $"P{controller} X", DisplayName = "X", Location = new Point(30, 43), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y", + Name = $"P{controller} Y", DisplayName = "Y", Location = new Point(55, 43), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Z", + Name = $"P{controller} Z", DisplayName = "Z", Location = new Point(80, 43), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(30, 70), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(55, 70), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " C", + Name = $"P{controller} C", DisplayName = "C", Location = new Point(80, 70), Type = PadSchema.PadInputType.Boolean @@ -525,7 +525,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Throttle", + Name = $"P{controller} Throttle", DisplayName = "Throttle", Location = new Point(135, 13), Type = PadSchema.PadInputType.FloatSingle, @@ -563,7 +563,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left Throttle", + Name = $"P{controller} Left Throttle", DisplayName = "Throttle", Location = new Point(8, 13), Type = PadSchema.PadInputType.FloatSingle, @@ -588,7 +588,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right Throttle", + Name = $"P{controller} Right Throttle", DisplayName = "Throttle", Location = new Point(350, 13), Type = PadSchema.PadInputType.FloatSingle, diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SmsSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SmsSchema.cs index 209c7bd806..9f641beefe 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SmsSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SmsSchema.cs @@ -34,42 +34,42 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", Icon = Properties.Resources.BlueUp, Location = new Point(14, 12), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", Icon = Properties.Resources.BlueDown, Location = new Point(14, 56), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", Icon = Properties.Resources.Back, Location = new Point(2, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", Icon = Properties.Resources.Forward, Location = new Point(24, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B1", + Name = $"P{controller} B1", DisplayName = "1", Location = new Point(122, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B2", + Name = $"P{controller} B2", DisplayName = "2", Location = new Point(146, 34), Type = PadSchema.PadInputType.Boolean @@ -88,49 +88,49 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", Icon = Properties.Resources.BlueUp, Location = new Point(14, 12), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", Icon = Properties.Resources.BlueDown, Location = new Point(14, 56), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", Icon = Properties.Resources.Back, Location = new Point(2, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", Icon = Properties.Resources.Forward, Location = new Point(24, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(134, 12), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B1", + Name = $"P{controller} B1", DisplayName = "1", Location = new Point(122, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B2", + Name = $"P{controller} B2", DisplayName = "2", Location = new Point(146, 34), Type = PadSchema.PadInputType.Boolean diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SnesSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SnesSchema.cs index db530a30c8..3be18684f2 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SnesSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/SnesSchema.cs @@ -117,7 +117,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(34, 17), @@ -125,7 +125,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(34, 61), @@ -133,7 +133,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(22, 39), @@ -141,7 +141,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(44, 39), @@ -149,14 +149,14 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " L", + Name = $"P{controller} L", DisplayName = "L", Location = new Point(2, 10), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " R", + Name = $"P{controller} R", DisplayName = "R", Location = new Point(174, 10), Type = PadSchema.PadInputType.Boolean @@ -164,14 +164,14 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Select", + Name = $"P{controller} Select", DisplayName = "s", Location = new Point(70, 39), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(92, 39), Type = PadSchema.PadInputType.Boolean @@ -179,28 +179,28 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Y", + Name = $"P{controller} Y", DisplayName = "Y", Location = new Point(121, 39), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(145, 52), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X", + Name = $"P{controller} X", DisplayName = "X", Location = new Point(122, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(146, 25), Type = PadSchema.PadInputType.Boolean @@ -219,7 +219,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse X", + Name = $"P{controller} Mouse X", MinValue = -128, MidValue = 0, MaxValue = 127, @@ -232,14 +232,14 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Left", + Name = $"P{controller} Mouse Left", DisplayName = "Left", Location = new Point(275, 15), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Mouse Right", + Name = $"P{controller} Mouse Right", DisplayName = "Right", Location = new Point(275, 45), Type = PadSchema.PadInputType.Boolean @@ -260,39 +260,39 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Scope X", + Name = $"P{controller} Scope X", Location = new Point(14, 17), Type = PadSchema.PadInputType.TargetedPair, TargetSize = new Size(256, 240), SecondaryNames = new[] { - "P" + controller + " Scope Y", + $"P{controller} Scope Y", } }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Trigger", + Name = $"P{controller} Trigger", DisplayName = "Trigger", Location = new Point(284, 17), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Cursor", + Name = $"P{controller} Cursor", DisplayName = "Cursor", Location = new Point(284, 47), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Turbo", + Name = $"P{controller} Turbo", DisplayName = "Turbo", Location = new Point(284, 77), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Pause", + Name = $"P{controller} Pause", DisplayName = "Pause", Location = new Point(284, 107), Type = PadSchema.PadInputType.Boolean @@ -313,25 +313,25 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Justifier X", + Name = $"P{controller} Justifier X", Location = new Point(14, 17), Type = PadSchema.PadInputType.TargetedPair, TargetSize = new Size(256, 240), SecondaryNames = new[] { - "P" + controller + " Justifier Y", + $"P{controller} Justifier Y", } }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Trigger", + Name = $"P{controller} Trigger", DisplayName = "Trigger", Location = new Point(284, 17), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "Start", Location = new Point(284, 47), Type = PadSchema.PadInputType.Boolean @@ -362,7 +362,7 @@ namespace BizHawk.Client.EmuHawk { yield return new PadSchema.ButtonSchema { - Name = "P" + controller + " B" + i, + Name = $"P{controller} B{i}", DisplayName = i.ToString(), Location = new Point(startX + (i * buttonSpacingX), startY), Type = PadSchema.PadInputType.Boolean @@ -373,7 +373,7 @@ namespace BizHawk.Client.EmuHawk { yield return new PadSchema.ButtonSchema { - Name = "P" + controller + " B" + (i + 16), + Name = $"P{controller} B{i + 16}", DisplayName = (i + 16).ToString(), Location = new Point(startX + (i * buttonSpacingX), startY + buttonSpacingY), Type = PadSchema.PadInputType.Boolean diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/WonderSwanSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/WonderSwanSchema.cs index 3497fdf045..132dcca53b 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/WonderSwanSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/WonderSwanSchema.cs @@ -26,28 +26,28 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Y1", + Name = $"P{controller} Y1", DisplayName = "Y1", Location = new Point(23, 12), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y4", + Name = $"P{controller} Y4", DisplayName = "Y4", Location = new Point(9, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y2", + Name = $"P{controller} Y2", DisplayName = "Y2", Location = new Point(38, 34), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y3", + Name = $"P{controller} Y3", DisplayName = "Y3", Location = new Point(23, 56), Type = PadSchema.PadInputType.Boolean @@ -55,28 +55,28 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " X1", + Name = $"P{controller} X1", DisplayName = "X1", Location = new Point(23, 92), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X4", + Name = $"P{controller} X4", DisplayName = "X4", Location = new Point(9, 114), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X2", + Name = $"P{controller} X2", DisplayName = "X2", Location = new Point(38, 114), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X3", + Name = $"P{controller} X3", DisplayName = "X3", Location = new Point(23, 136), Type = PadSchema.PadInputType.Boolean @@ -84,7 +84,7 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(80, 114), Type = PadSchema.PadInputType.Boolean @@ -92,7 +92,7 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(110, 114), Type = PadSchema.PadInputType.Boolean @@ -100,7 +100,7 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(133, 103), Type = PadSchema.PadInputType.Boolean @@ -120,14 +120,14 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " A", + Name = $"P{controller} A", DisplayName = "A", Location = new Point(23, 12), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " B", + Name = $"P{controller} B", DisplayName = "B", Location = new Point(46, 22), Type = PadSchema.PadInputType.Boolean @@ -135,7 +135,7 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Start", + Name = $"P{controller} Start", DisplayName = "S", Location = new Point(32, 58), Type = PadSchema.PadInputType.Boolean @@ -143,28 +143,28 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " Y2", + Name = $"P{controller} Y2", DisplayName = "Y2", Location = new Point(23, 112), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y1", + Name = $"P{controller} Y1", DisplayName = "Y1", Location = new Point(9, 134), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y3", + Name = $"P{controller} Y3", DisplayName = "Y3", Location = new Point(38, 134), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Y4", + Name = $"P{controller} Y4", DisplayName = "Y4", Location = new Point(23, 156), Type = PadSchema.PadInputType.Boolean @@ -172,28 +172,28 @@ namespace BizHawk.Client.EmuHawk new PadSchema.ButtonSchema { - Name = "P" + controller + " X2", + Name = $"P{controller} X2", DisplayName = "X2", Location = new Point(103, 112), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X1", + Name = $"P{controller} X1", DisplayName = "X1", Location = new Point(89, 134), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X3", + Name = $"P{controller} X3", DisplayName = "X3", Location = new Point(118, 134), Type = PadSchema.PadInputType.Boolean }, new PadSchema.ButtonSchema { - Name = "P" + controller + " X4", + Name = $"P{controller} X4", DisplayName = "X4", Location = new Point(103, 156), Type = PadSchema.PadInputType.Boolean diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ZXSpectrumSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ZXSpectrumSchema.cs index cdbf9228c0..fa8150558f 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ZXSpectrumSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/ZXSpectrumSchema.cs @@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk { return new PadSchema { - DisplayName = "Joystick " + controller, + DisplayName = $"Joystick {controller}", IsConsole = false, DefaultSize = new Size(174, 74), MaxSize = new Size(174, 74), @@ -30,7 +30,7 @@ namespace BizHawk.Client.EmuHawk { new PadSchema.ButtonSchema { - Name = "P" + controller + " Up", + Name = $"P{controller} Up", DisplayName = "", Icon = Properties.Resources.BlueUp, Location = new Point(23, 15), @@ -38,7 +38,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Down", + Name = $"P{controller} Down", DisplayName = "", Icon = Properties.Resources.BlueDown, Location = new Point(23, 36), @@ -46,7 +46,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Left", + Name = $"P{controller} Left", DisplayName = "", Icon = Properties.Resources.Back, Location = new Point(2, 24), @@ -54,7 +54,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Right", + Name = $"P{controller} Right", DisplayName = "", Icon = Properties.Resources.Forward, Location = new Point(44, 24), @@ -62,7 +62,7 @@ namespace BizHawk.Client.EmuHawk }, new PadSchema.ButtonSchema { - Name = "P" + controller + " Button", + Name = $"P{controller} Button", DisplayName = "B", Location = new Point(124, 24), Type = PadSchema.PadInputType.Boolean @@ -178,12 +178,12 @@ namespace BizHawk.Client.EmuHawk string disp = b.DisName; if (txtLength == 1) - disp = " " + disp; + disp = $" {disp}"; switch(b.DisName) { - case "SPACE": disp = " " + disp + " "; break; - case "I": disp = " " + disp + " "; break; + case "SPACE": disp = $" {disp} "; break; + case "I": disp = $" {disp} "; break; case "W": disp = b.DisName; break; } diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs index 253ff2aabd..6bddc22761 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs @@ -61,21 +61,10 @@ namespace BizHawk.Client.EmuHawk } AddressBox.SetHexProperties(_watchList[0].Domain.Size); - if (_watchList.Count < 10) // Hack in case an asburd amount of addresses is picked, this can get slow and create a too long string - { - AddressBox.Text = _watchList - .Select(a => a.AddressString) - .Distinct() - .Aggregate((addrStr, nextStr) => addrStr + ("," + nextStr)); - } - else - { - AddressBox.Text = _watchList - .Take(10) - .Select(a => a.AddressString) - .Distinct() - .Aggregate((addrStr, nextStr) => addrStr + ("," + nextStr)); - } + AddressBox.Text = (_watchList.Count > 10 ? _watchList.Take(10) : _watchList) // Hack in case an absurd amount of addresses are picked, this can be slow and create too long of a string + .Select(a => a.AddressString) + .Distinct() + .Aggregate((addrStr, nextStr) => $"{addrStr},{nextStr}"); ValueBox.ByteSize = _watchList[0].Size; ValueBox.Type = _watchList[0].Type; @@ -91,7 +80,7 @@ namespace BizHawk.Client.EmuHawk private void SetTitle() { - Text = "RAM Poke - " + _watchList[0].Domain.Name; + Text = $"RAM Poke - {_watchList[0].Domain.Name}"; } private void Cancel_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index 690acc99e2..a92d3a89fb 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -566,12 +566,12 @@ namespace BizHawk.Client.EmuHawk private void SetRemovedMessage(int val) { - MessageLabel.Text = val + " address" + (val != 1 ? "es" : "") + " removed"; + MessageLabel.Text = $"{val} {(val == 1 ? "address" : "addresses")} removed"; } private void SetTotal() { - TotalSearchLabel.Text = $"{_searches.Count:n0}" + " addresses"; + TotalSearchLabel.Text = $"{_searches.Count:n0} addresses"; } private void SetDomainLabel() @@ -838,7 +838,7 @@ namespace BizHawk.Client.EmuHawk else { _searches.AddRange(addresses, append); - MessageLabel.Text = file.Name + " loaded"; + MessageLabel.Text = $"{file.Name} loaded"; } UpdateList(); @@ -1015,7 +1015,7 @@ namespace BizHawk.Client.EmuHawk if (watches.Save()) { _currentFileName = watches.CurrentFileName; - MessageLabel.Text = Path.GetFileName(_currentFileName) + " saved"; + MessageLabel.Text = $"{Path.GetFileName(_currentFileName)} saved"; Settings.RecentSearches.Add(watches.CurrentFileName); } } @@ -1024,7 +1024,7 @@ namespace BizHawk.Client.EmuHawk var result = watches.SaveAs(GetWatchSaveFileFromUser(watches.CurrentFileName)); if (result) { - MessageLabel.Text = Path.GetFileName(_currentFileName) + " saved"; + MessageLabel.Text = $"{Path.GetFileName(_currentFileName)} saved"; Settings.RecentSearches.Add(watches.CurrentFileName); } } @@ -1042,7 +1042,7 @@ namespace BizHawk.Client.EmuHawk if (watches.SaveAs(GetWatchSaveFileFromUser(watches.CurrentFileName))) { _currentFileName = watches.CurrentFileName; - MessageLabel.Text = Path.GetFileName(_currentFileName) + " saved"; + MessageLabel.Text = $"{Path.GetFileName(_currentFileName)} saved"; Settings.RecentSearches.Add(watches.CurrentFileName); } } @@ -1107,7 +1107,7 @@ namespace BizHawk.Client.EmuHawk { var item = new ToolStripMenuItem { - Name = type + "ToolStripMenuItem", + Name = $"{type}ToolStripMenuItem", Text = Watch.DisplayTypeToString(type), Checked = _settings.Type == type, }; @@ -1246,7 +1246,7 @@ namespace BizHawk.Client.EmuHawk ToggleSearchDependentToolBarItems(); _forcePreviewClear = true; UpdateUndoToolBarButtons(); - MessageLabel.Text = restoredCount + " address" + (restoredCount != 1 ? "es" : "") + " restored"; + MessageLabel.Text = $"{restoredCount} {(restoredCount == 1 ? "address" : "addresses")} restored"; } } @@ -1259,7 +1259,7 @@ namespace BizHawk.Client.EmuHawk ToggleSearchDependentToolBarItems(); _forcePreviewClear = true; UpdateUndoToolBarButtons(); - MessageLabel.Text = restoredCount + " address" + (restoredCount != 1 ? "es" : "") + " removed"; + MessageLabel.Text = $"{restoredCount} {(restoredCount == 1 ? "address" : "addresses")} removed"; } } diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index ed0498a83e..d5fcb1ec3a 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -354,7 +354,7 @@ namespace BizHawk.Client.EmuHawk var sb = new StringBuilder(); foreach (var watch in SelectedItems) { - sb.AppendLine(ToString()); + sb.AppendLine(watch.ToString()); } if (sb.Length > 0) @@ -615,7 +615,7 @@ namespace BizHawk.Client.EmuHawk { if (saved) { - message = Path.GetFileName(_watches.CurrentFileName) + " saved."; + message = $"{Path.GetFileName(_watches.CurrentFileName)} saved."; } else { diff --git a/BizHawk.Client.EmuHawk/tools/Watch/WatchEditor.cs b/BizHawk.Client.EmuHawk/tools/Watch/WatchEditor.cs index c64f671bac..617bb0dac5 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/WatchEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/WatchEditor.cs @@ -84,7 +84,7 @@ namespace BizHawk.Client.EmuHawk NotesBox.Text = ""; AddressBox.Enabled = false; - AddressBox.Text = _watchList.Select(a => a.AddressString).Aggregate((addrStr, nextStr) => addrStr + ("," + nextStr)); + AddressBox.Text = _watchList.Select(a => a.AddressString).Aggregate((addrStr, nextStr) => $"{addrStr},{nextStr}"); BigEndianCheckBox.ThreeState = true; @@ -132,7 +132,7 @@ namespace BizHawk.Client.EmuHawk Text = "New Watch"; break; case Mode.Edit: - Text = "Edit Watch" + (_watchList.Count > 1 ? "es" : ""); + Text = $"Edit {(_watchList.Count == 1 ? "Watch" : "Watches")}"; break; case Mode.Duplicate: Text = "Duplicate Watch"; diff --git a/BizHawk.Client.EmuHawk/tools/Watch/WatchValueBox.cs b/BizHawk.Client.EmuHawk/tools/Watch/WatchValueBox.cs index e5016cfd99..c91ed41e24 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/WatchValueBox.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/WatchValueBox.cs @@ -708,18 +708,18 @@ namespace BizHawk.Client.EmuHawk Text = val.Value.ToHexString(MaxLength); break; case DisplayType.FixedPoint_12_4: - Text = string.Format("{0:F5}", val.Value / 16.0); + Text = $"{val.Value / 16.0:F5}"; break; case DisplayType.FixedPoint_20_12: - Text = string.Format("{0:F5}", val.Value / 4096.0); + Text = $"{val.Value / 4096.0:F5}"; break; case DisplayType.FixedPoint_16_16: - Text = string.Format("{0:F5}", val.Value / 65536.0); + Text = $"{val.Value / 65536.0:F5}"; break; case DisplayType.Float: var bytes = BitConverter.GetBytes(val.Value); float _float = BitConverter.ToSingle(bytes, 0); - Text = string.Format("{0:F6}", _float); + Text = $"{_float:F6}"; break; } } diff --git a/BizHawk.Client.MultiHawk/Input/Input.cs b/BizHawk.Client.MultiHawk/Input/Input.cs index 119c310857..4fa52538d1 100644 --- a/BizHawk.Client.MultiHawk/Input/Input.cs +++ b/BizHawk.Client.MultiHawk/Input/Input.cs @@ -221,7 +221,7 @@ namespace BizHawk.Client.MultiHawk if (UnpressState.ContainsKey(button)) { if (newState) return; - Console.WriteLine("Removing Unpress {0} with newState {1}", button, newState); + Console.WriteLine($"Removing Unpress {button} with {nameof(newState)} {newState}"); UnpressState.Remove(button); LastState[button] = false; return; diff --git a/BizHawk.Client.MultiHawk/movie/PlayMovie.cs b/BizHawk.Client.MultiHawk/movie/PlayMovie.cs index 9a99c3a31f..5c1d3464d2 100644 --- a/BizHawk.Client.MultiHawk/movie/PlayMovie.cs +++ b/BizHawk.Client.MultiHawk/movie/PlayMovie.cs @@ -324,9 +324,8 @@ namespace BizHawk.Client.MultiHawk .Append(_movieList[index].GameName).Append('\t') .Append(PlatformFrameRates.MovieTime(_movieList[index]).ToString(@"hh\:mm\:ss\.fff")) .AppendLine(); - - Clipboard.SetDataObject(copyStr.ToString()); } + Clipboard.SetDataObject(copyStr.ToString()); } } } @@ -340,97 +339,48 @@ namespace BizHawk.Client.MultiHawk private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e) { var columnName = MovieView.Columns[e.Column].Text; - if (_sortedCol != columnName) - { - _sortReverse = false; - } - switch (columnName) { case "File": - if (_sortReverse) - { - _movieList = _movieList - .OrderByDescending(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.GameName) - .ThenBy(x => x.FrameCount) - .ToList(); - } - else - { - _movieList = _movieList - .OrderBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.GameName) - .ThenBy(x => x.FrameCount) - .ToList(); - } + default: + _movieList = _movieList.OrderBy(x => Path.GetFileName(x.Filename)) + .ThenBy(x => x.SystemID) + .ThenBy(x => x.GameName) + .ThenBy(x => x.FrameCount) + .ToList(); break; case "SysID": - if (_sortReverse) - { - _movieList = _movieList - .OrderByDescending(x => x.SystemID) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.GameName) - .ThenBy(x => x.FrameCount) - .ToList(); - } - else - { - _movieList = _movieList - .OrderBy(x => x.SystemID) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.GameName) - .ThenBy(x => x.FrameCount) - .ToList(); - } + _movieList = _movieList.OrderBy(x => x.SystemID) + .ThenBy(x => Path.GetFileName(x.Filename)) + .ThenBy(x => x.GameName) + .ThenBy(x => x.FrameCount) + .ToList(); break; case "Game": - if (_sortReverse) - { - _movieList = _movieList - .OrderByDescending(x => x.GameName) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.FrameCount) - .ToList(); - } - else - { - _movieList = _movieList - .OrderBy(x => x.GameName) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.FrameCount) - .ToList(); - } + _movieList = _movieList.OrderBy(x => x.GameName) + .ThenBy(x => Path.GetFileName(x.Filename)) + .ThenBy(x => x.SystemID) + .ThenBy(x => x.FrameCount) + .ToList(); break; case "Length (est.)": - if (_sortReverse) - { - _movieList = _movieList - .OrderByDescending(x => x.FrameCount) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.FrameCount) - .ToList(); - } - else - { - _movieList = _movieList - .OrderBy(x => x.FrameCount) - .ThenBy(x => Path.GetFileName(x.Filename)) - .ThenBy(x => x.SystemID) - .ThenBy(x => x.GameName) - .ToList(); - } + _movieList = _movieList.OrderBy(x => x.FrameCount) + .ThenBy(x => Path.GetFileName(x.Filename)) + .ThenBy(x => x.SystemID) + .ThenBy(x => x.GameName) + .ToList(); break; } - - _sortedCol = columnName; - _sortReverse = !_sortReverse; + if (_sortedCol == columnName && _sortReverse) + { + _movieList.Reverse(); + _sortReverse = false; + } + else + { + _sortReverse = true; + _sortedCol = columnName; + } MovieView.Refresh(); } diff --git a/BizHawk.Common/AWEMemoryStream.cs b/BizHawk.Common/AWEMemoryStream.cs index 981a6088e2..6efb942a78 100644 --- a/BizHawk.Common/AWEMemoryStream.cs +++ b/BizHawk.Common/AWEMemoryStream.cs @@ -95,7 +95,7 @@ namespace BizHawk.Common set { if (!Ensure(value + 1)) - throw new OutOfMemoryException("Couldn't set AWEMemoryStream to specified Position"); + throw new OutOfMemoryException($"Couldn't set {nameof(AWEMemoryStream)} to specified Position"); mPosition = value; } } @@ -128,7 +128,7 @@ namespace BizHawk.Common public override void SetLength(long value) { if (!Ensure(value)) - throw new OutOfMemoryException("Couldn't set AWEMemoryStream to specified Length"); + throw new OutOfMemoryException($"Couldn't set {nameof(AWEMemoryStream)} to specified Length"); mLength = value; } @@ -151,7 +151,7 @@ namespace BizHawk.Common { mCurrBlock = block; if (!mBlocks[block].Map(mWindow)) - throw new Exception("Couldn't map required memory for AWEMemoryStream.Write"); + throw new Exception($"Couldn't map required memory for {nameof(AWEMemoryStream)}.{nameof(AWEMemoryStream.Write)}"); } Marshal.Copy(IntPtr.Add(mWindow, blockOfs), buffer, offset, todo); count -= todo; @@ -165,7 +165,7 @@ namespace BizHawk.Common { long end = mPosition + count; if (!Ensure(end)) - throw new OutOfMemoryException("Couldn't reserve required resources for AWEMemoryStream.Write"); + throw new OutOfMemoryException($"Couldn't reserve required resources for {nameof(AWEMemoryStream)}.{nameof(AWEMemoryStream.Write)}"); SetLength(end); while (count > 0) { @@ -181,7 +181,7 @@ namespace BizHawk.Common { mCurrBlock = block; if (!mBlocks[block].Map(mWindow)) - throw new Exception("Couldn't map required memory for AWEMemoryStream.Write"); + throw new Exception($"Couldn't map required memory for {nameof(AWEMemoryStream)}.{nameof(AWEMemoryStream.Write)}"); } Marshal.Copy(buffer, offset, IntPtr.Add(mWindow, blockOfs), todo); count -= todo; diff --git a/BizHawk.Common/BinaryQuickSerializer.cs b/BizHawk.Common/BinaryQuickSerializer.cs index 7db5441720..421461c328 100644 --- a/BizHawk.Common/BinaryQuickSerializer.cs +++ b/BizHawk.Common/BinaryQuickSerializer.cs @@ -117,8 +117,8 @@ namespace BizHawk.Common .OrderBy(fi => (int)Marshal.OffsetOf(t, fi.Name)) .ToList(); - var rmeth = new DynamicMethod(t.Name + "_r", null, new[] { typeof(object), typeof(BinaryReader) }, true); - var wmeth = new DynamicMethod(t.Name + "_w", null, new[] { typeof(object), typeof(BinaryWriter) }, true); + var rmeth = new DynamicMethod($"{t.Name}_r", null, new[] { typeof(object), typeof(BinaryReader) }, true); + var wmeth = new DynamicMethod($"{t.Name}_w", null, new[] { typeof(object), typeof(BinaryWriter) }, true); { var il = rmeth.GetILGenerator(); @@ -134,7 +134,7 @@ namespace BizHawk.Common MethodInfo m; if (!Readhandlers.TryGetValue(field.FieldType, out m)) { - throw new InvalidOperationException("(R) Can't handle nested type " + field.FieldType); + throw new InvalidOperationException($"(R) Can't handle nested type {field.FieldType}"); } il.Emit(OpCodes.Callvirt, m); @@ -159,7 +159,7 @@ namespace BizHawk.Common MethodInfo m; if (!Writehandlers.TryGetValue(field.FieldType, out m)) { - throw new InvalidOperationException("(W) Can't handle nested type " + field.FieldType); + throw new InvalidOperationException($"(W) Can't handle nested type {field.FieldType}"); } il.Emit(OpCodes.Callvirt, m); diff --git a/BizHawk.Common/BizHawk.Common.csproj b/BizHawk.Common/BizHawk.Common.csproj index 8b9b8cac99..876c145ad2 100644 --- a/BizHawk.Common/BizHawk.Common.csproj +++ b/BizHawk.Common/BizHawk.Common.csproj @@ -84,6 +84,7 @@ + @@ -109,4 +110,4 @@ --> - + \ No newline at end of file diff --git a/BizHawk.Common/BizInvoke/BizExvoker.cs b/BizHawk.Common/BizInvoke/BizExvoker.cs index 120025f9cd..f5944e7586 100644 --- a/BizHawk.Common/BizInvoke/BizExvoker.cs +++ b/BizHawk.Common/BizInvoke/BizExvoker.cs @@ -67,8 +67,7 @@ namespace BizHawk.Common.BizInvoke .Where(a => a.Attr != null) .ToList(); - var typeBuilder = ImplModuleBuilder.DefineType( - "Bizhawk.BizExvokeHolder" + type.Name, TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed); + var typeBuilder = ImplModuleBuilder.DefineType($"Bizhawk.BizExvokeHolder{type.Name}", TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed); foreach (var a in methods) { diff --git a/BizHawk.Common/BizInvoke/BizInvokeUtilities.cs b/BizHawk.Common/BizInvoke/BizInvokeUtilities.cs index 6bb1436d1b..55a3c9feab 100644 --- a/BizHawk.Common/BizInvoke/BizInvokeUtilities.cs +++ b/BizHawk.Common/BizInvoke/BizInvokeUtilities.cs @@ -27,7 +27,7 @@ namespace BizHawk.Common.BizInvoke // create the delegate type var delegateType = enclosingType.DefineNestedType( - "DelegateType" + method.Name, + $"DelegateType{method.Name}", TypeAttributes.Class | TypeAttributes.NestedPrivate | TypeAttributes.Sealed, typeof(MulticastDelegate)); @@ -85,7 +85,7 @@ namespace BizHawk.Common.BizInvoke return new CustomAttributeBuilder(t.GetConstructor(Type.EmptyTypes), new object[0]); } - throw new InvalidOperationException("Unknown parameter attribute " + t.Name); + throw new InvalidOperationException($"Unknown parameter attribute {t.Name}"); } } } diff --git a/BizHawk.Common/BizInvoke/BizInvoker.cs b/BizHawk.Common/BizInvoke/BizInvoker.cs index 8ebdf321a3..5f47b7ffa8 100644 --- a/BizHawk.Common/BizInvoke/BizInvoker.cs +++ b/BizHawk.Common/BizInvoke/BizInvoker.cs @@ -141,7 +141,7 @@ namespace BizHawk.Common.BizInvoke var uo = baseMethods.FirstOrDefault(a => !a.Info.IsVirtual || a.Info.IsFinal); if (uo != null) { - throw new InvalidOperationException("Method " + uo.Info.Name + " cannot be overriden!"); + throw new InvalidOperationException($"Method {uo.Info.Name} cannot be overriden!"); } // there's no technical reason to disallow this, but we wouldn't be doing anything @@ -149,14 +149,14 @@ namespace BizHawk.Common.BizInvoke var na = baseMethods.FirstOrDefault(a => !a.Info.IsAbstract); if (na != null) { - throw new InvalidOperationException("Method " + na.Info.Name + " is not abstract!"); + throw new InvalidOperationException($"Method {na.Info.Name} is not abstract!"); } } // hooks that will be run on the created proxy object var postCreateHooks = new List>(); - var type = ImplModuleBuilder.DefineType("Bizhawk.BizInvokeProxy" + baseType.Name, TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed, baseType); + var type = ImplModuleBuilder.DefineType($"Bizhawk.BizInvokeProxy{baseType.Name}", TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed, baseType); var monitorField = monitor ? type.DefineField("MonitorField", typeof(IMonitor), FieldAttributes.Public) : null; @@ -210,7 +210,7 @@ namespace BizHawk.Common.BizInvoke // define a field on the class to hold the delegate var field = type.DefineField( - "DelegateField" + baseMethod.Name, + $"DelegateField{baseMethod.Name}", delegateType, FieldAttributes.Public); @@ -293,7 +293,7 @@ namespace BizHawk.Common.BizInvoke // define a field on the type to hold the entry pointer var field = type.DefineField( - "EntryPtrField" + baseMethod.Name, + $"EntryPtrField{baseMethod.Name}", typeof(IntPtr), FieldAttributes.Public); diff --git a/BizHawk.Common/BizInvoke/DynamicLibraryImportResolver.cs b/BizHawk.Common/BizInvoke/DynamicLibraryImportResolver.cs index 5749b6b362..9bc02c487b 100644 --- a/BizHawk.Common/BizInvoke/DynamicLibraryImportResolver.cs +++ b/BizHawk.Common/BizInvoke/DynamicLibraryImportResolver.cs @@ -8,41 +8,24 @@ namespace BizHawk.Common.BizInvoke public class DynamicLibraryImportResolver : IImportResolver, IDisposable { private IntPtr _p; + private readonly PlatformLinkedLibSingleton.PlatformLinkedLibManager libLoader = PlatformLinkedLibSingleton.LinkedLibManager; public DynamicLibraryImportResolver(string dllName) { -#if !MONO - _p = Win32.LoadLibrary(dllName); -#else - // TODO: how can we read name remaps out of app.confg ? - _p = Libdl.dlopen(dllName, Libdl.RTLD_NOW); -#endif - if (_p == IntPtr.Zero) - { - throw new InvalidOperationException("LoadLibrary returned NULL"); - } + _p = libLoader.LoadPlatformSpecific(dllName); + if (_p == IntPtr.Zero) throw new InvalidOperationException($"null pointer returned by {nameof(PlatformLinkedLibSingleton.PlatformLinkedLibManager.LoadPlatformSpecific)}"); } public IntPtr Resolve(string entryPoint) { -#if !MONO - return Win32.GetProcAddress(_p, entryPoint); -#else - return Libdl.dlsym(_p, entryPoint); -#endif + return libLoader.GetProcAddr(_p, entryPoint); } private void Free() { - if (_p != IntPtr.Zero) - { -#if !MONO - Win32.FreeLibrary(_p); -#else - Libdl.dlclose(_p); -#endif - _p = IntPtr.Zero; - } + if (_p == IntPtr.Zero) return; + libLoader.FreePlatformSpecific(_p); + _p = IntPtr.Zero; } public void Dispose() @@ -55,30 +38,5 @@ namespace BizHawk.Common.BizInvoke { Free(); } - -#if !MONO - private static class Win32 - { - [DllImport("kernel32.dll")] - public static extern IntPtr LoadLibrary(string dllToLoad); - - [DllImport("kernel32.dll")] - public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName); - - [DllImport("kernel32.dll")] - public static extern bool FreeLibrary(IntPtr hModule); - } -#else - private static class Libdl - { - [DllImport("libdl.so")] - public static extern IntPtr dlopen(string filename, int flags); - [DllImport("libdl.so")] - public static extern IntPtr dlsym(IntPtr handle, string symbol); - [DllImport("libdl.so")] - public static extern int dlclose(IntPtr handle); - public const int RTLD_NOW = 2; - } -#endif } } diff --git a/BizHawk.Common/BizInvoke/MemoryBlock.cs b/BizHawk.Common/BizInvoke/MemoryBlock.cs index 6f353cbc70..ae3c867adf 100644 --- a/BizHawk.Common/BizInvoke/MemoryBlock.cs +++ b/BizHawk.Common/BizInvoke/MemoryBlock.cs @@ -89,7 +89,7 @@ namespace BizHawk.Common.BizInvoke Kernel32.FileMapProtection.PageExecuteReadWrite | Kernel32.FileMapProtection.SectionCommit, (uint)(size >> 32), (uint)size, null); if (_handle == IntPtr.Zero) - throw new InvalidOperationException("CreateFileMapping() returned NULL"); + throw new InvalidOperationException($"{nameof(Kernel32.CreateFileMapping)}() returned NULL"); Start = start; End = start + size; Size = size; @@ -106,7 +106,7 @@ namespace BizHawk.Common.BizInvoke if (Kernel32.MapViewOfFileEx(_handle, Kernel32.FileMapAccessType.Read | Kernel32.FileMapAccessType.Write | Kernel32.FileMapAccessType.Execute, 0, 0, Z.UU(Size), Z.US(Start)) != Z.US(Start)) { - throw new InvalidOperationException("MapViewOfFileEx() returned NULL"); + throw new InvalidOperationException($"{nameof(Kernel32.MapViewOfFileEx)}() returned NULL"); } ProtectAll(); Active = true; @@ -120,7 +120,7 @@ namespace BizHawk.Common.BizInvoke if (!Active) throw new InvalidOperationException("Not active"); if (!Kernel32.UnmapViewOfFile(Z.US(Start))) - throw new InvalidOperationException("UnmapViewOfFile() returned NULL"); + throw new InvalidOperationException($"{nameof(Kernel32.UnmapViewOfFile)}() returned NULL"); Active = false; } @@ -175,7 +175,7 @@ namespace BizHawk.Common.BizInvoke // that to complicate things Kernel32.MemoryProtection old; if (!Kernel32.VirtualProtect(Z.UU(Start), Z.UU(Size), Kernel32.MemoryProtection.READONLY, out old)) - throw new InvalidOperationException("VirtualProtect() returned FALSE!"); + throw new InvalidOperationException($"{nameof(Kernel32.VirtualProtect)}() returned FALSE!"); _snapshot = new byte[Size]; var ds = new MemoryStream(_snapshot, true); @@ -197,7 +197,7 @@ namespace BizHawk.Common.BizInvoke // temporarily switch the entire block to `R` Kernel32.MemoryProtection old; if (!Kernel32.VirtualProtect(Z.UU(Start), Z.UU(Size), Kernel32.MemoryProtection.READONLY, out old)) - throw new InvalidOperationException("VirtualProtect() returned FALSE!"); + throw new InvalidOperationException($"{nameof(Kernel32.VirtualProtect)}() returned FALSE!"); var ret = WaterboxUtils.Hash(GetStream(Start, Size, false)); ProtectAll(); return ret; @@ -232,7 +232,7 @@ namespace BizHawk.Common.BizInvoke ulong zend = GetStartAddr(i + 1); Kernel32.MemoryProtection old; if (!Kernel32.VirtualProtect(Z.UU(zstart), Z.UU(zend - zstart), p, out old)) - throw new InvalidOperationException("VirtualProtect() returned FALSE!"); + throw new InvalidOperationException($"{nameof(Kernel32.VirtualProtect)}() returned FALSE!"); ps = i + 1; } } @@ -261,7 +261,7 @@ namespace BizHawk.Common.BizInvoke Kernel32.MemoryProtection old; if (!Kernel32.VirtualProtect(Z.UU(computedStart), Z.UU(computedLength), p, out old)) - throw new InvalidOperationException("VirtualProtect() returned FALSE!"); + throw new InvalidOperationException($"{nameof(Kernel32.VirtualProtect)}() returned FALSE!"); } } @@ -302,7 +302,7 @@ namespace BizHawk.Common.BizInvoke private void EnsureNotDisposed() { if (_owner.Start == 0) - throw new ObjectDisposedException("MemoryBlock"); + throw new ObjectDisposedException(nameof(MemoryBlock)); } private MemoryBlock _owner; @@ -442,37 +442,10 @@ namespace BizHawk.Common.BizInvoke private static class Kernel32 { - [DllImport("kernel32.dll", SetLastError = true)] - public static extern UIntPtr VirtualAlloc(UIntPtr lpAddress, UIntPtr dwSize, - AllocationType flAllocationType, MemoryProtection flProtect); - - [DllImport("kernel32.dll", SetLastError = true)] - public static extern bool VirtualFree(UIntPtr lpAddress, UIntPtr dwSize, - FreeType dwFreeType); - [DllImport("kernel32.dll", SetLastError = true)] public static extern bool VirtualProtect(UIntPtr lpAddress, UIntPtr dwSize, MemoryProtection flNewProtect, out MemoryProtection lpflOldProtect); - public enum FreeType : uint - { - DECOMMIT = 0x4000, - RELEASE = 0x8000 - } - - [Flags] - public enum AllocationType : uint - { - COMMIT = 0x1000, - RESERVE = 0x2000, - RESET = 0x80000, - RESET_UNDO = 0x1000000, - LARGE_PAGES = 0x20000000, - PHYSICAL = 0x400000, - TOP_DOWN = 0x100000, - WRITE_WATCH = 0x200000 - } - [Flags] public enum MemoryProtection : uint { diff --git a/BizHawk.Common/Extensions/BufferExtensions.cs b/BizHawk.Common/Extensions/BufferExtensions.cs index e04788f445..d02ded6d2e 100644 --- a/BizHawk.Common/Extensions/BufferExtensions.cs +++ b/BizHawk.Common/Extensions/BufferExtensions.cs @@ -100,7 +100,7 @@ namespace BizHawk.Common.BufferExtensions for (int i = 0; i < buffer.Length && i * 2 < hex.Length; i++) { - var bytehex = "" + hex[i * 2] + hex[(i * 2) + 1]; + var bytehex = $"{hex[i * 2]}{hex[(i * 2) + 1]}"; buffer[i] = byte.Parse(bytehex, NumberStyles.HexNumber); } } @@ -136,7 +136,7 @@ namespace BizHawk.Common.BufferExtensions for (int i = 0; i < buffer.Length && i * 4 < hex.Length; i++) { - var shorthex = "" + hex[i * 4] + hex[(i * 4) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3]; + var shorthex = $"{hex[i * 4]}{hex[(i * 4) + 1]}{hex[(i * 4) + 2]}{hex[(i * 4) + 3]}"; buffer[i] = short.Parse(shorthex, NumberStyles.HexNumber); } } @@ -150,7 +150,7 @@ namespace BizHawk.Common.BufferExtensions for (int i = 0; i < buffer.Length && i * 4 < hex.Length; i++) { - var ushorthex = "" + hex[i * 4] + hex[(i * 4) + 1] + hex[(i * 4) + 2] + hex[(i * 4) + 3]; + var ushorthex = $"{hex[i * 4]}{hex[(i * 4) + 1]}{hex[(i * 4) + 2]}{hex[(i * 4) + 3]}"; buffer[i] = ushort.Parse(ushorthex, NumberStyles.HexNumber); } } diff --git a/BizHawk.Common/Extensions/NumberExtensions.cs b/BizHawk.Common/Extensions/NumberExtensions.cs index 38438659a5..f0a7309902 100644 --- a/BizHawk.Common/Extensions/NumberExtensions.cs +++ b/BizHawk.Common/Extensions/NumberExtensions.cs @@ -7,32 +7,32 @@ namespace BizHawk.Common.NumberExtensions { public static string ToHexString(this int n, int numdigits) { - return string.Format("{0:X" + numdigits + "}", n); + return string.Format($"{{0:X{numdigits}}}", n); } public static string ToHexString(this uint n, int numdigits) { - return string.Format("{0:X" + numdigits + "}", n); + return string.Format($"{{0:X{numdigits}}}", n); } public static string ToHexString(this byte n, int numdigits) { - return string.Format("{0:X" + numdigits + "}", n); + return string.Format($"{{0:X{numdigits}}}", n); } public static string ToHexString(this ushort n, int numdigits) { - return string.Format("{0:X" + numdigits + "}", n); + return string.Format($"{{0:X{numdigits}}}", n); } public static string ToHexString(this long n, int numdigits) { - return string.Format("{0:X" + numdigits + "}", n); + return string.Format($"{{0:X{numdigits}}}", n); } public static string ToHexString(this ulong n, int numdigits) { - return string.Format("{0:X" + numdigits + "}", n); + return string.Format($"{{0:X{numdigits}}}", n); } public static bool Bit(this byte b, int index) diff --git a/BizHawk.Common/HawkFile.cs b/BizHawk.Common/HawkFile.cs index b4b89e3ceb..2e50fc27b5 100644 --- a/BizHawk.Common/HawkFile.cs +++ b/BizHawk.Common/HawkFile.cs @@ -131,7 +131,7 @@ namespace BizHawk.Common { if (_boundStream == null) { - throw new InvalidOperationException("HawkFile: Can't call GetStream() before youve successfully bound something!"); + throw new InvalidOperationException($"{nameof(HawkFile)}: Can't call {nameof(GetStream)}() before you've successfully bound something!"); } return _boundStream; @@ -217,7 +217,7 @@ namespace BizHawk.Common { if (_rootPath != null) { - throw new InvalidOperationException("Don't reopen a HawkFile."); + throw new InvalidOperationException($"Don't reopen a {nameof(HawkFile)}."); } string autobind = null; @@ -334,7 +334,7 @@ namespace BizHawk.Common _extractor.ExtractFile(archiveIndex, _boundStream); _boundStream.Position = 0; _memberPath = _archiveItems[index].Name; // TODO - maybe go through our own list of names? maybe not, its indexes dont match.. - Console.WriteLine("HawkFile bound " + CanonicalFullPath); + Console.WriteLine($"{nameof(HawkFile)} bound {CanonicalFullPath}"); _boundIndex = archiveIndex; return this; } @@ -360,7 +360,7 @@ namespace BizHawk.Common private void BindRoot() { _boundStream = _rootStream; - Console.WriteLine("HawkFile bound " + CanonicalFullPath); + Console.WriteLine($"{nameof(HawkFile)} bound {CanonicalFullPath}"); } /// diff --git a/BizHawk.Common/InstanceDll.cs b/BizHawk.Common/InstanceDll.cs index 3bd1212e56..8a7b558e73 100644 --- a/BizHawk.Common/InstanceDll.cs +++ b/BizHawk.Common/InstanceDll.cs @@ -12,7 +12,7 @@ namespace BizHawk.Common public InstanceDll(string dllPath) { // copy the dll to a temp directory - var path = TempFileManager.GetTempFilename(string.Format("{0}", Path.GetFileNameWithoutExtension(dllPath)),".dll",false); + var path = TempFileManager.GetTempFilename(Path.GetFileNameWithoutExtension(dllPath), ".dll", false); using (var stream = new FileStream(path, FileMode.Create, System.Security.AccessControl.FileSystemRights.FullControl, FileShare.ReadWrite | FileShare.Delete, 4 * 1024, FileOptions.None)) using (var sdll = File.OpenRead(dllPath)) sdll.CopyTo(stream); @@ -24,7 +24,7 @@ namespace BizHawk.Common var envpath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process); try { - string envpath_new = Path.GetDirectoryName(path) + ";" + envpath; + string envpath_new = $"{Path.GetDirectoryName(path)};{envpath}"; Environment.SetEnvironmentVariable("PATH", envpath_new, EnvironmentVariableTarget.Process); _hModule = LoadLibrary(path); //consider using LoadLibraryEx instead of shenanigans? if (_hModule == IntPtr.Zero) diff --git a/BizHawk.Common/NDBDatabase.cs b/BizHawk.Common/NDBDatabase.cs index 3dd2b60966..86bf0a9f2b 100644 --- a/BizHawk.Common/NDBDatabase.cs +++ b/BizHawk.Common/NDBDatabase.cs @@ -43,7 +43,7 @@ namespace BizHawk.Common } if (FreeWatermark == BlockCount) - throw new OutOfMemoryException("NDBDatabase out of reserved space"); + throw new OutOfMemoryException($"{nameof(NDBDatabase)} out of reserved space"); var b = new Block() { Number = FreeWatermark }; FreeWatermark++; @@ -107,10 +107,10 @@ namespace BizHawk.Common public void Store(string name, byte[] buf, int offset, int length) { if (Items.ContainsKey(name)) - throw new InvalidOperationException(string.Format("Can't add already existing key of name {0}", name)); + throw new InvalidOperationException($"Can't add already existing key of name {name}"); if (length > Remain) - throw new OutOfMemoryException(string.Format("Insufficient storage reserved for {0} bytes", length)); + throw new OutOfMemoryException($"Insufficient storage reserved for {length} bytes"); long todo = length; int src = offset; diff --git a/BizHawk.Common/PlatformLinkedLibSingleton.cs b/BizHawk.Common/PlatformLinkedLibSingleton.cs new file mode 100644 index 0000000000..14ed9c29e6 --- /dev/null +++ b/BizHawk.Common/PlatformLinkedLibSingleton.cs @@ -0,0 +1,93 @@ +using System; +using System.Runtime.InteropServices; + +//put in a different namespace for EXE so we can have an instance of this type (by linking to this file rather than copying it) built-in to the exe +//so the exe doesnt implicitly depend on the dll +#if EXE_PROJECT +namespace EXE_PROJECT +#else +namespace BizHawk.Common +#endif +{ + +public sealed class PlatformLinkedLibSingleton + { + public static readonly bool RunningOnUnix = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX; + + private static readonly Lazy lazy = new Lazy(() => RunningOnUnix + ? (PlatformLinkedLibManager) new UnixMonoLinkedLibManager() + : (PlatformLinkedLibManager) new Win32LinkedLibManager()); + + public static PlatformLinkedLibManager LinkedLibManager { get { return lazy.Value; } } + + private PlatformLinkedLibSingleton() {} + + public interface PlatformLinkedLibManager + { + IntPtr LoadPlatformSpecific(string dllToLoad); + IntPtr GetProcAddr(IntPtr hModule, string procName); + int FreePlatformSpecific(IntPtr hModule); + } + + public class UnixMonoLinkedLibManager : PlatformLinkedLibManager + { + // This class is copied from a tutorial, so don't git blame and then email me expecting insight. + const int RTLD_NOW = 2; + [DllImport("libdl.so.2")] + private static extern IntPtr dlopen(String fileName, int flags); + [DllImport("libdl.so.2")] + private static extern IntPtr dlerror(); + [DllImport("libdl.so.2")] + private static extern IntPtr dlsym(IntPtr handle, String symbol); + [DllImport("libdl.so.2")] + private static extern int dlclose(IntPtr handle); + public IntPtr LoadPlatformSpecific(string dllToLoad) + { + return dlopen(dllToLoad, RTLD_NOW); + } + public IntPtr GetProcAddr(IntPtr hModule, string procName) + { + dlerror(); + var res = dlsym(hModule, procName); + var errPtr = dlerror(); + if (errPtr != IntPtr.Zero) throw new InvalidOperationException($"error in dlsym: {Marshal.PtrToStringAnsi(errPtr)}"); + return res; + } + public int FreePlatformSpecific(IntPtr hModule) + { + return dlclose(hModule); + } + } + + public class Win32LinkedLibManager : PlatformLinkedLibManager + { + [DllImport("kernel32.dll")] + private static extern UInt32 GetLastError(); + // was annotated `[DllImport("kernel32.dll", BestFitMapping = false, ThrowOnUnmappableChar = true)]` in SevenZip.NativeMethods + // param dllToLoad was annotated `[MarshalAs(UnmanagedType.LPStr)]` in SevenZip.NativeMethods + [DllImport("kernel32.dll")] + private static extern IntPtr LoadLibrary(string dllToLoad); + // was annotated `[DllImport("kernel32.dll", BestFitMapping = false, ThrowOnUnmappableChar = true)]` in SevenZip.NativeMethods + // param procName was annotated `[MarshalAs(UnmanagedType.LPStr)]` in SevenZip.NativeMethods + [DllImport("kernel32.dll")] + private static extern IntPtr GetProcAddress(IntPtr hModule, string procName); + // was annotated `[return: MarshalAs(UnmanagedType.Bool)]` in SevenZip.NativeMethods + [DllImport("kernel32.dll")] + private static extern bool FreeLibrary(IntPtr hModule); + public IntPtr LoadPlatformSpecific(string dllToLoad) + { + var p = LoadLibrary(dllToLoad); + if (p == IntPtr.Zero) throw new InvalidOperationException($"got null pointer, error code {GetLastError()}"); + return p; + } + public IntPtr GetProcAddr(IntPtr hModule, string procName) + { + return GetProcAddress(hModule, procName); + } + public int FreePlatformSpecific(IntPtr hModule) + { + return FreeLibrary(hModule) ? 1 : 0; + } + } + } +} diff --git a/BizHawk.Common/QuickCollections.cs b/BizHawk.Common/QuickCollections.cs index cacae28a03..776c6b3b90 100644 --- a/BizHawk.Common/QuickCollections.cs +++ b/BizHawk.Common/QuickCollections.cs @@ -58,7 +58,7 @@ namespace BizHawk.Common public void Enqueue(T item) { if (size >= buffer.Length) - throw new Exception("QuickQueue capacity breached!"); + throw new Exception($"{nameof(QuickQueue)} capacity breached!"); buffer[tail] = item; tail = (tail + 1) % buffer.Length; @@ -82,7 +82,7 @@ namespace BizHawk.Common public T Dequeue() { if (size == 0) - throw new Exception("QuickQueue is empty!"); + throw new Exception($"{nameof(QuickQueue)} is empty!"); T item = buffer[head]; head = (head + 1) % buffer.Length; diff --git a/BizHawk.Common/Serializer.cs b/BizHawk.Common/Serializer.cs index 0a882f6f6c..baca009720 100644 --- a/BizHawk.Common/Serializer.cs +++ b/BizHawk.Common/Serializer.cs @@ -658,7 +658,7 @@ namespace BizHawk.Common { if (name.Length > length) { - throw new InvalidOperationException("SyncFixedString too long"); + throw new InvalidOperationException($"{nameof(SyncFixedString)} too long"); } var buf = val.ToCharArray(); @@ -740,7 +740,7 @@ namespace BizHawk.Common } else { - throw new Exception(string.Format("Duplicate key \"{0}\" in serializer savestate!", name)); + throw new Exception($"Duplicate key \"{name}\" in serializer savestate!"); } curs = news; @@ -763,7 +763,7 @@ namespace BizHawk.Common } else { - throw new Exception(string.Format("Duplicate key \"{0}\" in serializer savestate!", key)); + throw new Exception($"Duplicate key \"{key}\" in serializer savestate!"); } } } diff --git a/BizHawk.Common/SettingsUtil.cs b/BizHawk.Common/SettingsUtil.cs index 6741bf7d88..6a8e940692 100644 --- a/BizHawk.Common/SettingsUtil.cs +++ b/BizHawk.Common/SettingsUtil.cs @@ -50,7 +50,7 @@ namespace BizHawk.Common private static DefaultValueSetter CreateSetter(Type t) { - var dyn = new DynamicMethod("SetDefaultValues_" + t.Name, null, new[] { typeof(object), typeof(object[]) }, false); + var dyn = new DynamicMethod($"SetDefaultValues_{t.Name}", null, new[] { typeof(object), typeof(object[]) }, false); var il = dyn.GetILGenerator(); List DefaultValues = new List(); @@ -90,7 +90,7 @@ namespace BizHawk.Common } else { - throw new InvalidOperationException(string.Format("Default value assignment will fail for {0}.{1}", t.Name, prop.Name)); + throw new InvalidOperationException($"Default value assignment will fail for {t.Name}.{prop.Name}"); } il.Emit(OpCodes.Callvirt, method); } diff --git a/BizHawk.Common/SwitcherStream.cs b/BizHawk.Common/SwitcherStream.cs index 50dfc8b42e..0be955d7e4 100644 --- a/BizHawk.Common/SwitcherStream.cs +++ b/BizHawk.Common/SwitcherStream.cs @@ -48,7 +48,7 @@ namespace BizHawk.Common return; } - throw new InvalidOperationException("Cannot set position to non-zero in a SwitcherStream with DenySeekHack=true"); + throw new InvalidOperationException($"Cannot set position to non-zero in a {nameof(SwitcherStream)} with {DenySeekHack}=true"); } _currStream.Position = value; @@ -79,7 +79,7 @@ namespace BizHawk.Common return 0; } - throw new InvalidOperationException("Cannot call Seek with non-zero offset or non-Begin origin in a SwitcherStream with DenySeekHack=true"); + throw new InvalidOperationException($"Cannot call {nameof(Seek)} with non-zero offset or non-{nameof(SeekOrigin.Begin)} origin in a {nameof(SwitcherStream)} with {nameof(DenySeekHack)}=true"); } return _currStream.Seek(offset, origin); diff --git a/BizHawk.Common/TempFileManager.cs b/BizHawk.Common/TempFileManager.cs index 255ab47a66..d21da556bd 100644 --- a/BizHawk.Common/TempFileManager.cs +++ b/BizHawk.Common/TempFileManager.cs @@ -37,7 +37,7 @@ namespace BizHawk.Common throw new InvalidOperationException(); } - filename = "bizdelete-" + filename.Remove(0, 4); + filename = $"bizdelete-{filename.Remove(0, 4)}"; return Path.Combine(dir, filename); } diff --git a/BizHawk.Common/Util.cs b/BizHawk.Common/Util.cs index 9869e60e93..c0d6f94185 100644 --- a/BizHawk.Common/Util.cs +++ b/BizHawk.Common/Util.cs @@ -389,7 +389,7 @@ namespace BizHawk.Common } const string precision = "2"; - return string.Format("{0:N" + precision + "}{1}", size, suffix); + return string.Format($"{{0:N{precision}}}{{1}}", size, suffix); } // http://stackoverflow.com/questions/3928822/comparing-2-dictionarystring-string-instances @@ -510,7 +510,7 @@ namespace BizHawk.Common static SuperGloballyUniqueID() { - StaticPart = "bizhawk-" + System.Diagnostics.Process.GetCurrentProcess().Id + "-" + Guid.NewGuid(); + StaticPart = $"bizhawk-{System.Diagnostics.Process.GetCurrentProcess().Id}-{Guid.NewGuid()}"; } public static string Next() @@ -521,7 +521,7 @@ namespace BizHawk.Common myctr = ctr++; } - return StaticPart + "-" + myctr; + return $"{StaticPart}-{myctr}"; } } diff --git a/BizHawk.Common/Win32Hacks.cs b/BizHawk.Common/Win32Hacks.cs index fd49816c80..77960636ff 100644 --- a/BizHawk.Common/Win32Hacks.cs +++ b/BizHawk.Common/Win32Hacks.cs @@ -456,7 +456,7 @@ namespace BizHawk.Common //I only put this for use here by external cores public static void RemoveMOTW(string path) { - DeleteFileW(path + ":Zone.Identifier"); + DeleteFileW($"{path}:Zone.Identifier"); } [DllImport("kernel32.dll")] diff --git a/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs b/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs index 4a93abc213..29ae44e902 100644 --- a/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs +++ b/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs @@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Common } catch (NotImplementedException) { - throw new InvalidOperationException("GetCpuFlagsAndRegisters is required"); + throw new InvalidOperationException($"{nameof(IDebuggable.GetCpuFlagsAndRegisters)} is required"); } Header = "Instructions"; diff --git a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs index 034d1dfbaf..0983f9651c 100644 --- a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs +++ b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs @@ -33,23 +33,23 @@ namespace BizHawk.Emulation.Common public ControllerDefinition ControllerDefinition => NullController.Instance.Definition; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { if (render == false) { - return; + return true; } if (!_settings.SnowyDisplay) { if (_frameBufferClear) { - return; + return true; } _frameBufferClear = true; Array.Clear(_frameBuffer, 0, 256 * 192); - return; + return true; } _frameBufferClear = false; @@ -70,6 +70,8 @@ namespace BizHawk.Emulation.Common } Frame++; + + return true; } public int Frame { get; private set; } diff --git a/BizHawk.Emulation.Common/Base Implementations/SimpleSyncSoundProvider.cs b/BizHawk.Emulation.Common/Base Implementations/SimpleSyncSoundProvider.cs index 50baa37d7b..eab662fd25 100644 --- a/BizHawk.Emulation.Common/Base Implementations/SimpleSyncSoundProvider.cs +++ b/BizHawk.Emulation.Common/Base Implementations/SimpleSyncSoundProvider.cs @@ -29,7 +29,7 @@ namespace BizHawk.Emulation.Common.Base_Implementations { if (_nsamp != 0) { - Console.WriteLine("Warning: Samples disappeared from SimpleSyncSoundProvider"); + Console.WriteLine($"Warning: Samples disappeared from {nameof(SimpleSyncSoundProvider)}"); } if (_buffer.Length < nsamp * 2) diff --git a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj index 0a8aa6ec09..7287faab8b 100644 --- a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj +++ b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj @@ -121,6 +121,10 @@ + + + + diff --git a/BizHawk.Emulation.Common/Database/Database.cs b/BizHawk.Emulation.Common/Database/Database.cs index 1cd73d701e..edab106cd5 100644 --- a/BizHawk.Emulation.Common/Database/Database.cs +++ b/BizHawk.Emulation.Common/Database/Database.cs @@ -36,7 +36,7 @@ namespace BizHawk.Emulation.Common DB.TryGetValue(hashNotype, out cgi); if (cgi == null) { - Console.WriteLine("DB: hash " + hash + " not in game database."); + Console.WriteLine($"DB: hash {hash} not in game database."); return null; } @@ -187,7 +187,7 @@ namespace BizHawk.Emulation.Common } catch { - Console.WriteLine("Error parsing database entry: " + line); + Console.WriteLine($"Error parsing database entry: {line}"); } } } diff --git a/BizHawk.Emulation.Common/EmulationExceptions.cs b/BizHawk.Emulation.Common/EmulationExceptions.cs index ea85be6924..e61d82bf38 100644 --- a/BizHawk.Emulation.Common/EmulationExceptions.cs +++ b/BizHawk.Emulation.Common/EmulationExceptions.cs @@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Common } public NoAvailableCoreException(string message) - : base ("System is currently NOT emulated: " + message) + : base ($"System is currently NOT emulated: {message}") { } diff --git a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs index 4d3926d6fc..6920136d94 100644 --- a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs +++ b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs @@ -34,7 +34,7 @@ namespace BizHawk.Emulation.Common /// Whether or not to render video, cores will pass false here in cases such as frame skipping /// Whether or not to render audio, cores will pass here false here in cases such as fast forwarding where bypassing sound may improve speed /// - void FrameAdvance(IController controller, bool render, bool rendersound = true); + bool FrameAdvance(IController controller, bool render, bool rendersound = true); /// /// Gets the current frame count diff --git a/BizHawk.Emulation.Common/Interfaces/Services/IDebuggable.cs b/BizHawk.Emulation.Common/Interfaces/Services/IDebuggable.cs index e1655b888a..977ff10ae8 100644 --- a/BizHawk.Emulation.Common/Interfaces/Services/IDebuggable.cs +++ b/BizHawk.Emulation.Common/Interfaces/Services/IDebuggable.cs @@ -57,7 +57,7 @@ namespace BizHawk.Emulation.Common } else if (bitSize > 64 || bitSize == 0) { - throw new System.ArgumentOutOfRangeException(nameof(bitSize), "BitSize must be in 1..64"); + throw new System.ArgumentOutOfRangeException(nameof(bitSize), $"{nameof(BitSize)} must be in 1..64"); } else { diff --git a/BizHawk.Emulation.Common/Interfaces/Services/ILinkable.cs b/BizHawk.Emulation.Common/Interfaces/Services/ILinkable.cs index 8285623eef..c406b57200 100644 --- a/BizHawk.Emulation.Common/Interfaces/Services/ILinkable.cs +++ b/BizHawk.Emulation.Common/Interfaces/Services/ILinkable.cs @@ -9,6 +9,6 @@ /// /// Gets a value indicating whether or not the link cable is currently connected /// - bool LinkConnected { get; } + bool LinkConnected { get; set; } } } diff --git a/BizHawk.Emulation.Common/Sound/Utilities/BlipBuffer.cs b/BizHawk.Emulation.Common/Sound/Utilities/BlipBuffer.cs index 5454adf67c..42d57dbef6 100644 --- a/BizHawk.Emulation.Common/Sound/Utilities/BlipBuffer.cs +++ b/BizHawk.Emulation.Common/Sound/Utilities/BlipBuffer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.InteropServices; // ReSharper disable StyleCop.SA1300 @@ -17,12 +17,12 @@ namespace BizHawk.Emulation.Common /** Creates new buffer that can hold at most sample_count samples. Sets rates so that there are blip_max_ratio clocks per sample. Returns pointer to new buffer, or NULL if insufficient memory. */ - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr blip_new(int sample_count); /** Sets approximate input clock rate and output sample rate. For every clock_rate input clocks, approximately sample_rate samples are generated. */ - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern void blip_set_rates(IntPtr context, double clock_rate, double sample_rate); /** Maximum clock_rate/sample_rate ratio. For a given sample_rate, @@ -30,20 +30,20 @@ namespace BizHawk.Emulation.Common public const int BlipMaxRatio = 1 << 20; /** Clears entire buffer. Afterwards, blip_samples_avail() == 0. */ - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern void blip_clear(IntPtr context); /** Adds positive/negative delta into buffer at specified clock time. */ - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern void blip_add_delta(IntPtr context, uint clock_time, int delta); /** Same as blip_add_delta(), but uses faster, lower-quality synthesis. */ - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern void blip_add_delta_fast(IntPtr context, uint clock_time, int delta); /** Length of time frame, in clocks, needed to make sample_count additional samples available. */ - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern int blip_clocks_needed(IntPtr context, int sample_count); /** Maximum number of samples that can be generated from one time frame. */ @@ -54,24 +54,24 @@ namespace BizHawk.Emulation.Common the new time frame specifies the same clock as clock_duration in the old time frame specified. Deltas can have been added slightly past clock_duration (up to however many clocks there are in two output samples). */ - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern void blip_end_frame(IntPtr context, uint clock_duration); /** Number of buffered samples available for reading. */ - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern int blip_samples_avail(IntPtr context); /** Reads and removes at most 'count' samples and writes them to 'out'. If 'stereo' is true, writes output to every other element of 'out', allowing easy interleaving of two buffers into a stereo sample stream. Outputs 16-bit signed samples. Returns number of samples actually read. */ - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern int blip_read_samples(IntPtr context, short[] @out, int count, int stereo); - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern int blip_read_samples(IntPtr context, IntPtr @out, int count, int stereo); /** Frees buffer. No effect if NULL is passed. */ - [DllImport("blip_buf.dll", CallingConvention = CallingConvention.Cdecl)] + [DllImport("blip_buf", CallingConvention = CallingConvention.Cdecl)] public static extern void blip_delete(IntPtr context); } diff --git a/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs b/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs index 35d48c9880..af0aeb6976 100644 --- a/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs +++ b/BizHawk.Emulation.Common/Sound/Utilities/SpeexResampler.cs @@ -280,13 +280,13 @@ namespace BizHawk.Emulation.Common case LibSpeexDSP.RESAMPLER_ERR.SUCCESS: return; case LibSpeexDSP.RESAMPLER_ERR.ALLOC_FAILED: - throw new InsufficientMemoryException("LibSpeexDSP: Alloc failed"); + throw new InsufficientMemoryException($"{nameof(LibSpeexDSP)}: Alloc failed"); case LibSpeexDSP.RESAMPLER_ERR.BAD_STATE: - throw new Exception("LibSpeexDSP: Bad state"); + throw new Exception($"{nameof(LibSpeexDSP)}: Bad state"); case LibSpeexDSP.RESAMPLER_ERR.INVALID_ARG: - throw new ArgumentException("LibSpeexDSP: Bad Argument"); + throw new ArgumentException($"{nameof(LibSpeexDSP)}: Bad Argument"); case LibSpeexDSP.RESAMPLER_ERR.PTR_OVERLAP: - throw new Exception("LibSpeexDSP: Buffers cannot overlap"); + throw new Exception($"{nameof(LibSpeexDSP)}: Buffers cannot overlap"); } } @@ -304,7 +304,7 @@ namespace BizHawk.Emulation.Common { if (drainer != null && input != null) { - throw new ArgumentException("Can't autofetch without being an ISyncSoundProvider?"); + throw new ArgumentException($"Can't autofetch without being an {nameof(ISoundProvider)}?"); } LibSpeexDSP.RESAMPLER_ERR err = LibSpeexDSP.RESAMPLER_ERR.SUCCESS; @@ -312,7 +312,7 @@ namespace BizHawk.Emulation.Common if (_st == IntPtr.Zero) { - throw new Exception("LibSpeexDSP returned null!"); + throw new Exception($"{nameof(LibSpeexDSP)} returned null!"); } CheckError(err); diff --git a/BizHawk.Emulation.Common/WorkingTypes/wbyte.cs b/BizHawk.Emulation.Common/WorkingTypes/wbyte.cs new file mode 100644 index 0000000000..621ea82131 --- /dev/null +++ b/BizHawk.Emulation.Common/WorkingTypes/wbyte.cs @@ -0,0 +1,116 @@ +using System; +using System.Globalization; +using System.Security; + + +namespace BizHawk.Emulation.Common.WorkingTypes +{ + // + // Summary: + // Represents an 8-bit unsigned integer, that is capable of arithmetic without making you weep. + // Also provides all the base functionality of the standard C# Byte by calling its methods where relevant. + public unsafe class wbyte : IComparable, IFormattable, IComparable, IEquatable + { + private Byte val; + public const Byte MaxValue = Byte.MaxValue; + public const Byte MinValue = Byte.MinValue; + public static implicit operator wbyte(ulong value) + { + return new wbyte(value); + } + public static implicit operator wbyte(wushort value) + { + return new wbyte(value); + } + public static implicit operator byte(wbyte value) + { + return value.val; + } + public wbyte() + { + + } + public wbyte(ulong value) + { + val = (Byte)(value & 0xFF); + } + public wbyte(long value) + { + val = (Byte)(value & 0xFF); + } + public wbyte(double value) + { + val = (Byte)(((long)value) & 0xFF); + } + public static wbyte Parse(string s, NumberStyles style, IFormatProvider provider) + { + return (ulong)Byte.Parse(s, style, provider); + } + public static wbyte Parse(string s, IFormatProvider provider) + { + return (ulong)Byte.Parse(s, provider); + } + public static wbyte Parse(string s) + { + return (ulong)Byte.Parse(s); + } + public static wbyte Parse(string s, NumberStyles style) + { + return (ulong)Byte.Parse(s, style); + } + public static bool TryParse(string s, out wbyte result) + { + result = new wbyte(); + return byte.TryParse(s, out result.val); + } + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out wbyte result) + { + result = new wbyte(); + return byte.TryParse(s, style, provider, out result.val); + } + public int CompareTo(wbyte value) + { + return val.CompareTo(value.val); + } + public int CompareTo(object value) + { + return val.CompareTo(value); + } + public override bool Equals(object obj) + { + return val.Equals(obj); + } + public bool Equals(wbyte obj) + { + return val.Equals(obj); + } + public override int GetHashCode() + { + return val.GetHashCode(); + } + public TypeCode GetTypeCode() + { + return val.GetTypeCode(); + } + [SecuritySafeCritical] + public string ToString(string format, IFormatProvider provider) + { + return val.ToString(format, provider); + } + [SecuritySafeCritical] + public override string ToString() + { + return val.ToString(); + } + [SecuritySafeCritical] + public string ToString(string format) + { + return val.ToString(format); + } + [SecuritySafeCritical] + public string ToString(IFormatProvider provider) + { + return val.ToString(provider); + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Common/WorkingTypes/wsbyte.cs b/BizHawk.Emulation.Common/WorkingTypes/wsbyte.cs new file mode 100644 index 0000000000..187cf46c39 --- /dev/null +++ b/BizHawk.Emulation.Common/WorkingTypes/wsbyte.cs @@ -0,0 +1,111 @@ +using System; +using System.Globalization; +using System.Security; + +namespace BizHawk.Emulation.Common.WorkingTypes +{ + // + // Summary: + // Represents an 8-bit unsigned integer, that is capable of arithmetic without making you weep. + // Also provides all the base functionality of the standard C# SByte by calling its methods where relevant. + public unsafe class wsbyte : IComparable, IFormattable, IComparable, IEquatable + { + private SByte val; + public const SByte MaxValue = SByte.MaxValue; + public const SByte MinValue = SByte.MinValue; + public static implicit operator wsbyte(long value) + { + return new wsbyte(value); + } + public static implicit operator SByte(wsbyte value) + { + return value.val; + } + public wsbyte() + { + + } + public wsbyte(long value) + { + val = (SByte)(value & 0xFF); + } + public wsbyte(ulong value) + { + val = (SByte)(value & 0xFF); + } + public wsbyte(double value) + { + val = (SByte)(((ulong)value) & 0xFF); + } + public static wsbyte Parse(string s, NumberStyles style, IFormatProvider provider) + { + return (long)SByte.Parse(s, style, provider); + } + public static wsbyte Parse(string s, IFormatProvider provider) + { + return (long)SByte.Parse(s, provider); + } + public static wsbyte Parse(string s) + { + return (long)SByte.Parse(s); + } + public static wsbyte Parse(string s, NumberStyles style) + { + return (long)SByte.Parse(s, style); + } + public static bool TryParse(string s, out wsbyte result) + { + result = new wsbyte(); + return SByte.TryParse(s, out result.val); + } + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out wsbyte result) + { + result = new wsbyte(); + return SByte.TryParse(s, style, provider, out result.val); + } + public int CompareTo(wsbyte value) + { + return val.CompareTo(value.val); + } + public int CompareTo(object value) + { + return val.CompareTo(value); + } + public override bool Equals(object obj) + { + return val.Equals(obj); + } + public bool Equals(wsbyte obj) + { + return val.Equals(obj); + } + public override int GetHashCode() + { + return val.GetHashCode(); + } + public TypeCode GetTypeCode() + { + return val.GetTypeCode(); + } + [SecuritySafeCritical] + public string ToString(string format, IFormatProvider provider) + { + return val.ToString(format, provider); + } + [SecuritySafeCritical] + public override string ToString() + { + return val.ToString(); + } + [SecuritySafeCritical] + public string ToString(string format) + { + return val.ToString(format); + } + [SecuritySafeCritical] + public string ToString(IFormatProvider provider) + { + return val.ToString(provider); + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Common/WorkingTypes/wshort.cs b/BizHawk.Emulation.Common/WorkingTypes/wshort.cs new file mode 100644 index 0000000000..aa66438db3 --- /dev/null +++ b/BizHawk.Emulation.Common/WorkingTypes/wshort.cs @@ -0,0 +1,111 @@ +using System; +using System.Globalization; +using System.Security; + +namespace BizHawk.Emulation.Common.WorkingTypes +{ + // + // Summary: + // Represents an 16-bit unsigned integer, that is capable of arithmetic without making you weep. + // Also provides all the base functionality of the standard C# Int16 by calling its methods where relevant. + public unsafe class wshort : IComparable, IFormattable, IComparable, IEquatable + { + private Int16 val; + public const Int16 MaxValue = Int16.MaxValue; + public const Int16 MinValue = Int16.MinValue; + public static implicit operator wshort(long value) + { + return new wshort(value); + } + public static implicit operator Int16(wshort value) + { + return value.val; + } + public wshort() + { + + } + public wshort(long value) + { + val = (Int16)(value & 0xFFFF); + } + public wshort(ulong value) + { + val = (Int16)(value & 0xFFFF); + } + public wshort(double value) + { + val = (Int16)(((ulong)value) & 0xFFFF); + } + public static wshort Parse(string s, NumberStyles style, IFormatProvider provider) + { + return (long)Int16.Parse(s, style, provider); + } + public static wshort Parse(string s, IFormatProvider provider) + { + return (long)Int16.Parse(s, provider); + } + public static wshort Parse(string s) + { + return (long)Int16.Parse(s); + } + public static wshort Parse(string s, NumberStyles style) + { + return (long)Int16.Parse(s, style); + } + public static bool TryParse(string s, out wshort result) + { + result = new wshort(); + return Int16.TryParse(s, out result.val); + } + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out wshort result) + { + result = new wshort(); + return Int16.TryParse(s, style, provider, out result.val); + } + public int CompareTo(wshort value) + { + return val.CompareTo(value.val); + } + public int CompareTo(object value) + { + return val.CompareTo(value); + } + public override bool Equals(object obj) + { + return val.Equals(obj); + } + public bool Equals(wshort obj) + { + return val.Equals(obj); + } + public override int GetHashCode() + { + return val.GetHashCode(); + } + public TypeCode GetTypeCode() + { + return val.GetTypeCode(); + } + [SecuritySafeCritical] + public string ToString(string format, IFormatProvider provider) + { + return val.ToString(format, provider); + } + [SecuritySafeCritical] + public override string ToString() + { + return val.ToString(); + } + [SecuritySafeCritical] + public string ToString(string format) + { + return val.ToString(format); + } + [SecuritySafeCritical] + public string ToString(IFormatProvider provider) + { + return val.ToString(provider); + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Common/WorkingTypes/wushort.cs b/BizHawk.Emulation.Common/WorkingTypes/wushort.cs new file mode 100644 index 0000000000..427a414c6f --- /dev/null +++ b/BizHawk.Emulation.Common/WorkingTypes/wushort.cs @@ -0,0 +1,116 @@ +using System; +using System.Globalization; +using System.Security; + + +namespace BizHawk.Emulation.Common.WorkingTypes +{ + // + // Summary: + // Represents an 16-bit unsigned integer, that is capable of arithmetic without making you weep. + // Also provides all the base functionality of the standard C# UInt16 by calling its methods where relevant. + public unsafe class wushort : IComparable, IFormattable, IComparable, IEquatable + { + private UInt16 val; + public const UInt16 MaxValue = UInt16.MaxValue; + public const UInt16 MinValue = UInt16.MinValue; + public static implicit operator wushort(ulong value) + { + return new wushort(value); + } + public static implicit operator wushort(wbyte value) + { + return new wushort(value); + } + public static implicit operator UInt16(wushort value) + { + return value.val; + } + public wushort() + { + + } + public wushort(ulong value) + { + val = (UInt16)(value & 0xFFFF); + } + public wushort(long value) + { + val = (UInt16)(value & 0xFFFF); + } + public wushort(double value) + { + val = (UInt16)(((long)value) & 0xFFFF); + } + public static wushort Parse(string s, NumberStyles style, IFormatProvider provider) + { + return (uint)UInt16.Parse(s, style, provider); + } + public static wushort Parse(string s, IFormatProvider provider) + { + return (uint)UInt16.Parse(s, provider); + } + public static wushort Parse(string s) + { + return (uint)UInt16.Parse(s); + } + public static wushort Parse(string s, NumberStyles style) + { + return (uint)UInt16.Parse(s, style); + } + public static bool TryParse(string s, out wushort result) + { + result = new wushort(); + return ushort.TryParse(s, out result.val); + } + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out wushort result) + { + result = new wushort(); + return ushort.TryParse(s, style, provider, out result.val); + } + public int CompareTo(wushort value) + { + return val.CompareTo(value.val); + } + public int CompareTo(object value) + { + return val.CompareTo(value); + } + public override bool Equals(object obj) + { + return val.Equals(obj); + } + public bool Equals(wushort obj) + { + return val.Equals(obj); + } + public override int GetHashCode() + { + return val.GetHashCode(); + } + public TypeCode GetTypeCode() + { + return val.GetTypeCode(); + } + [SecuritySafeCritical] + public string ToString(string format, IFormatProvider provider) + { + return val.ToString(format, provider); + } + [SecuritySafeCritical] + public override string ToString() + { + return val.ToString(); + } + [SecuritySafeCritical] + public string ToString(string format) + { + return val.ToString(format); + } + [SecuritySafeCritical] + public string ToString(IFormatProvider provider) + { + return val.ToString(provider); + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index c4d8705210..6b27fb6d5e 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -317,27 +317,33 @@ + - - - - - - - - - - - - - + + NECUPD765.cs + + + NECUPD765.cs + + + NECUPD765.cs + + + NECUPD765.cs + + + NECUPD765.cs + + + NECUPD765.cs + @@ -346,10 +352,6 @@ - - - - @@ -372,30 +374,94 @@ - - - - - - - - - - + + SpectrumBase.cs + + + SpectrumBase.cs + + + SpectrumBase.cs + + + SpectrumBase.cs + + + - + + ZX48.cs + + + ZX48.cs + + + + + + ZX128.cs + + + ZX128.cs + + + + + + ZX128Plus2a.cs + + + ZX128Plus2a.cs + + + + + ZX128Plus3.cs + + + ZX128Plus3.cs + + + + Pentagon128.cs + + + Pentagon128.cs + + + - - - - - - - - - - + + ZXSpectrum.cs + + + ZXSpectrum.cs + + + ZXSpectrum.cs + + + ZXSpectrum.cs + + + ZXSpectrum.cs + + + ZXSpectrum.cs + + + ZXSpectrum.cs + + + ZXSpectrum.cs + + + ZXSpectrum.cs + + + ZXSpectrum.cs + Atari2600.cs @@ -723,6 +789,31 @@ VBANext.cs + + + + GBHawkLink.cs + + + GBHawkLink.cs + + + GBHawkLink.cs + + + GBHawkLink.cs + + + GBHawkLink.cs + + + GBHawkLink.cs + + + GBHawkLink.cs + + + @@ -1110,6 +1201,25 @@ + + + SubNESHawk.cs + + + SubNESHawk.cs + + + SubNESHawk.cs + + + SubNESHawk.cs + + + SubNESHawk.cs + + + SubNESHawk.cs + @@ -1226,6 +1336,31 @@ + + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GPGX.cs @@ -1302,9 +1437,6 @@ SMS.cs - - SMS.cs - SMS.cs @@ -1410,6 +1542,7 @@ + @@ -1441,7 +1574,6 @@ - @@ -1500,13 +1632,7 @@ - - - - - - diff --git a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/IntegerMath.cs b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/IntegerMath.cs index 6d53ae61bc..46dfbd7ce8 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/IntegerMath.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/IntegerMath.cs @@ -189,7 +189,7 @@ namespace BizHawk.Emulation.Cores.Components.M68000 int pc = info.PC + 2; int size = (op >> 6) & 3; int mode = (op >> 3) & 7; - int reg = (op >> 0) & 3; + int reg = (op >> 0) & 7; switch (size) { @@ -516,7 +516,7 @@ namespace BizHawk.Emulation.Cores.Components.M68000 int pc = info.PC + 2; int size = (op >> 6) & 3; int mode = (op >> 3) & 7; - int reg = (op >> 0) & 3; + int reg = (op >> 0) & 7; switch (size) { @@ -1147,4 +1147,4 @@ namespace BizHawk.Emulation.Cores.Components.M68000 info.Length = pc - info.PC; } } -} \ No newline at end of file +} diff --git a/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs b/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs index b2eb45d44b..4d0521fc15 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs @@ -193,15 +193,15 @@ namespace BizHawk.Emulation.Cores.Components.M68000 writer.WriteLine(); writer.WriteLine("PC {0:X6}", PC); - writer.WriteLine("InterruptMaskLevel {0}", InterruptMaskLevel); + writer.WriteLine($"{nameof(InterruptMaskLevel)} {InterruptMaskLevel}"); writer.WriteLine("USP {0:X8}", usp); writer.WriteLine("SSP {0:X8}", ssp); writer.WriteLine("S {0}", s); writer.WriteLine("M {0}", m); writer.WriteLine(); - writer.WriteLine("TotalExecutedCycles {0}", TotalExecutedCycles); - writer.WriteLine("PendingCycles {0}", PendingCycles); + writer.WriteLine($"{nameof(TotalExecutedCycles)} {TotalExecutedCycles}"); + writer.WriteLine($"{nameof(PendingCycles)} {PendingCycles}"); writer.WriteLine("[/{0}]", id); } @@ -232,14 +232,14 @@ namespace BizHawk.Emulation.Cores.Components.M68000 else if (args[0] == "A7") A[7].s32 = int.Parse(args[1], NumberStyles.HexNumber); else if (args[0] == "PC") PC = int.Parse(args[1], NumberStyles.HexNumber); - else if (args[0] == "InterruptMaskLevel") InterruptMaskLevel = int.Parse(args[1]); + else if (args[0] == nameof(InterruptMaskLevel)) InterruptMaskLevel = int.Parse(args[1]); else if (args[0] == "USP") usp = int.Parse(args[1], NumberStyles.HexNumber); else if (args[0] == "SSP") ssp = int.Parse(args[1], NumberStyles.HexNumber); else if (args[0] == "S") s = bool.Parse(args[1]); else if (args[0] == "M") m = bool.Parse(args[1]); - else if (args[0] == "TotalExecutedCycles") TotalExecutedCycles = int.Parse(args[1]); - else if (args[0] == "PendingCycles") PendingCycles = int.Parse(args[1]); + else if (args[0] == nameof(TotalExecutedCycles)) TotalExecutedCycles = int.Parse(args[1]); + else if (args[0] == nameof(PendingCycles)) PendingCycles = int.Parse(args[1]); else Console.WriteLine("Skipping unrecognized identifier " + args[0]); diff --git a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs index 8a4ced6fa0..f1b795f1b8 100644 --- a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs +++ b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs @@ -58,21 +58,21 @@ namespace BizHawk.Emulation.Cores.Components.CP1610 public void SyncState(Serializer ser) { - ser.BeginSection("CP1610"); + ser.BeginSection(nameof(CP1610)); - ser.Sync("Register", ref Register, false); - ser.Sync("FlagS", ref FlagS); - ser.Sync("FlagC", ref FlagC); - ser.Sync("FlagZ", ref FlagZ); - ser.Sync("FlagO", ref FlagO); - ser.Sync("FlagI", ref FlagI); - ser.Sync("FlagD", ref FlagD); - ser.Sync("IntRM", ref IntRM); - ser.Sync("BusRq", ref BusRq); - ser.Sync("BusAk", ref BusAk); - ser.Sync("BusRq", ref BusRq); - ser.Sync("Interruptible", ref Interruptible); - ser.Sync("Interrupted", ref Interrupted); + ser.Sync(nameof(Register), ref Register, false); + ser.Sync(nameof(FlagS), ref FlagS); + ser.Sync(nameof(FlagC), ref FlagC); + ser.Sync(nameof(FlagZ), ref FlagZ); + ser.Sync(nameof(FlagO), ref FlagO); + ser.Sync(nameof(FlagI), ref FlagI); + ser.Sync(nameof(FlagD), ref FlagD); + ser.Sync(nameof(IntRM), ref IntRM); + ser.Sync(nameof(BusRq), ref BusRq); + ser.Sync(nameof(BusAk), ref BusAk); + ser.Sync(nameof(BusRq), ref BusRq); + ser.Sync(nameof(Interruptible), ref Interruptible); + ser.Sync(nameof(Interrupted), ref Interrupted); ser.Sync("Toal_executed_cycles", ref TotalExecutedCycles); ser.Sync("Pending_Cycles", ref PendingCycles); diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs index 9e2e8ad470..27a93c5d2d 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs @@ -70,28 +70,28 @@ namespace BizHawk.Emulation.Cores.Components.H6280 public void SyncState(Serializer ser) { - ser.BeginSection("HuC6280"); - ser.Sync("A", ref A); - ser.Sync("X", ref X); - ser.Sync("Y", ref Y); - ser.Sync("P", ref P); - ser.Sync("PC", ref PC); - ser.Sync("S", ref S); - ser.Sync("MPR", ref MPR, false); - ser.Sync("LagIFlag", ref LagIFlag); - ser.Sync("IRQ1Assert", ref IRQ1Assert); - ser.Sync("IRQ2Assert", ref IRQ2Assert); - ser.Sync("TimerAssert", ref TimerAssert); - ser.Sync("IRQControlByte", ref IRQControlByte); - ser.Sync("IRQNextControlByte", ref IRQNextControlByte); + ser.BeginSection(nameof(HuC6280)); + ser.Sync(nameof(A), ref A); + ser.Sync(nameof(X), ref X); + ser.Sync(nameof(Y), ref Y); + ser.Sync(nameof(P), ref P); + ser.Sync(nameof(PC), ref PC); + ser.Sync(nameof(S), ref S); + ser.Sync(nameof(MPR), ref MPR, false); + ser.Sync(nameof(LagIFlag), ref LagIFlag); + ser.Sync(nameof(IRQ1Assert), ref IRQ1Assert); + ser.Sync(nameof(IRQ2Assert), ref IRQ2Assert); + ser.Sync(nameof(TimerAssert), ref TimerAssert); + ser.Sync(nameof(IRQControlByte), ref IRQControlByte); + ser.Sync(nameof(IRQNextControlByte), ref IRQNextControlByte); ser.Sync("ExecutedCycles", ref TotalExecutedCycles); - ser.Sync("PendingCycles", ref PendingCycles); - ser.Sync("LowSpeed", ref LowSpeed); - ser.Sync("TimerTickCounter", ref TimerTickCounter); - ser.Sync("TimerReloadValue", ref TimerReloadValue); - ser.Sync("TimerValue", ref TimerValue); - ser.Sync("TimerEnabled", ref TimerEnabled); - ser.Sync("InBlockTransfer", ref InBlockTransfer); + ser.Sync(nameof(PendingCycles), ref PendingCycles); + ser.Sync(nameof(LowSpeed), ref LowSpeed); + ser.Sync(nameof(TimerTickCounter), ref TimerTickCounter); + ser.Sync(nameof(TimerReloadValue), ref TimerReloadValue); + ser.Sync(nameof(TimerValue), ref TimerValue); + ser.Sync(nameof(TimerEnabled), ref TimerEnabled); + ser.Sync(nameof(InBlockTransfer), ref InBlockTransfer); ser.Sync("BTFrom", ref btFrom); ser.Sync("BTTo", ref btTo); ser.Sync("BTLen", ref btLen); diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs index 12c13662aa..a4e26f5a7c 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs @@ -396,11 +396,22 @@ namespace BizHawk.Emulation.Common.Components.LR35902 } else { - cur_instr = new ushort[] - {HALT_CHK, - IDLE, - IDLE, + if (is_GBC) + { + cur_instr = new ushort[] + {IDLE, + IDLE, + HALT_CHK, HALT, 0 }; + } + else + { + cur_instr = new ushort[] + {HALT_CHK, + IDLE, + IDLE, + HALT, 0 }; + } } } @@ -580,29 +591,29 @@ namespace BizHawk.Emulation.Common.Components.LR35902 public void SyncState(Serializer ser) { - ser.BeginSection("LR35902"); - ser.Sync("Regs", ref Regs, false); + ser.BeginSection(nameof(LR35902)); + ser.Sync(nameof(Regs), ref Regs, false); ser.Sync("IRQ", ref interrupts_enabled); - ser.Sync("I_use", ref I_use); - ser.Sync("skip_once", ref skip_once); - ser.Sync("Halt_bug_2", ref Halt_bug_2); - ser.Sync("Halt_bug_3", ref Halt_bug_3); + ser.Sync(nameof(I_use), ref I_use); + ser.Sync(nameof(skip_once), ref skip_once); + ser.Sync(nameof(Halt_bug_2), ref Halt_bug_2); + ser.Sync(nameof(Halt_bug_3), ref Halt_bug_3); ser.Sync("Halted", ref halted); ser.Sync("ExecutedCycles", ref totalExecutedCycles); - ser.Sync("EI_pending", ref EI_pending); - ser.Sync("int_src", ref int_src); - ser.Sync("stop_time", ref stop_time); - ser.Sync("stop_check", ref stop_check); - ser.Sync("is_GBC", ref is_GBC); + ser.Sync(nameof(EI_pending), ref EI_pending); + ser.Sync(nameof(int_src), ref int_src); + ser.Sync(nameof(stop_time), ref stop_time); + ser.Sync(nameof(stop_check), ref stop_check); + ser.Sync(nameof(is_GBC), ref is_GBC); - ser.Sync("instr_pntr", ref instr_pntr); - ser.Sync("cur_instr", ref cur_instr, false); - ser.Sync("CB Preifx", ref CB_prefix); + ser.Sync(nameof(instr_pntr), ref instr_pntr); + ser.Sync(nameof(cur_instr), ref cur_instr, false); + ser.Sync("CB Prefix", ref CB_prefix); ser.Sync("Stopped", ref stopped); - ser.Sync("opcode", ref opcode); - ser.Sync("jammped", ref jammed); - ser.Sync("LY", ref LY); - ser.Sync("FlagI", ref FlagI); + ser.Sync(nameof(opcode), ref opcode); + ser.Sync(nameof(jammed), ref jammed); + ser.Sync(nameof(LY), ref LY); + ser.Sync(nameof(FlagI), ref FlagI); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/Operations.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/Operations.cs index e317416265..cddd89dd72 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/Operations.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/Operations.cs @@ -159,7 +159,7 @@ namespace BizHawk.Emulation.Common.Components.LR35902 public void SRL_Func(ushort src) { - FlagC = Regs[src].Bit(0) ? true : false; + FlagC = Regs[src].Bit(0); Regs[src] = (ushort)(Regs[src] >> 1); diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs index 25d28f85c3..c6eed76817 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs @@ -185,6 +185,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 case 0xAE: bytesToAdvance = 3; return string.Format("LDX ${0:X4}", peeker_word(++pc, peeker)); case 0xB0: bytesToAdvance = 2; return string.Format("BCS ${0:X4}", pc + 2 + (sbyte)peeker(++pc)); case 0xB1: bytesToAdvance = 2; return string.Format("LDA (${0:X2}),Y *", peeker(++pc)); + case 0xB3: bytesToAdvance = 2; return string.Format("LAX (${0:X2}),Y *", peeker(++pc)); case 0xB4: bytesToAdvance = 2; return string.Format("LDY ${0:X2},X", peeker(++pc)); case 0xB5: bytesToAdvance = 2; return string.Format("LDA ${0:X2},X", peeker(++pc)); case 0xB6: bytesToAdvance = 2; return string.Format("LDX ${0:X2},Y", peeker(++pc)); @@ -203,6 +204,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 case 0xC8: bytesToAdvance = 1; return "INY"; case 0xC9: bytesToAdvance = 2; return string.Format("CMP #${0:X2}", peeker(++pc)); case 0xCA: bytesToAdvance = 1; return "DEX"; + case 0xCB: bytesToAdvance = 2; return string.Format("AXS ${0:X2}", peeker(++pc)); case 0xCC: bytesToAdvance = 3; return string.Format("CPY ${0:X4}", peeker_word(++pc, peeker)); case 0xCD: bytesToAdvance = 3; return string.Format("CMP ${0:X4}", peeker_word(++pc, peeker)); case 0xCE: bytesToAdvance = 3; return string.Format("DEC ${0:X4}", peeker_word(++pc, peeker)); diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs index 9724899735..5d9282cae4 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs @@ -600,6 +600,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 return; } } + Fetch1_Real(); } @@ -2971,8 +2972,6 @@ namespace BizHawk.Emulation.Cores.Components.M6502 TotalExecutedCycles++; if (!rdy_freeze) { - - interrupt_pending |= Interrupted; } rdy_freeze = false; diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs index 83d94aad78..5fc328f146 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs @@ -74,7 +74,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 "{0:X4}: {1,-9} {2} ", PC, rawbytes, disasm).PadRight(32), RegisterInfo = string.Format( - "A:{0:X2} X:{1:X2} Y:{2:X2} SP:{4:X2} P:{3:X2} {6}{7}{8}{9}{10}{11}{12}{13} Cy:{5}", + "A:{0:X2} X:{1:X2} Y:{2:X2} SP:{4:X2} P:{3:X2} {6}{7}{8}{9}{10}{11}{12}{13} Cy:{5} PPU-Cy:{15}", A, X, Y, P, S, TotalExecutedCycles, FlagN ? "N" : "n", FlagV ? "V" : "v", @@ -84,7 +84,8 @@ namespace BizHawk.Emulation.Cores.Components.M6502 FlagI ? "I" : "i", FlagZ ? "Z" : "z", FlagC ? "C" : "c", - !RDY ? "R" : "r") + !RDY ? "R" : "r", + ext_ppu_cycle) }; } @@ -120,29 +121,33 @@ namespace BizHawk.Emulation.Cores.Components.M6502 public bool NMI; public bool RDY; + // ppu cycle (used with SubNESHawk) + public int ext_ppu_cycle = 0; + public void SyncState(Serializer ser) { - ser.BeginSection("MOS6502X"); - ser.Sync("A", ref A); - ser.Sync("X", ref X); - ser.Sync("Y", ref Y); - ser.Sync("P", ref P); - ser.Sync("PC", ref PC); - ser.Sync("S", ref S); - ser.Sync("NMI", ref NMI); - ser.Sync("IRQ", ref IRQ); - ser.Sync("RDY", ref RDY); - ser.Sync("TotalExecutedCycles", ref TotalExecutedCycles); - ser.Sync("opcode", ref opcode); - ser.Sync("opcode2", ref opcode2); - ser.Sync("opcode3", ref opcode3); - ser.Sync("ea", ref ea); - ser.Sync("alu_temp", ref alu_temp); - ser.Sync("mi", ref mi); - ser.Sync("iflag_pending", ref iflag_pending); - ser.Sync("interrupt_pending", ref interrupt_pending); - ser.Sync("branch_irq_hack", ref branch_irq_hack); - ser.Sync("rdy_freeze", ref rdy_freeze); + ser.BeginSection(nameof(MOS6502X)); + ser.Sync(nameof(A), ref A); + ser.Sync(nameof(X), ref X); + ser.Sync(nameof(Y), ref Y); + ser.Sync(nameof(P), ref P); + ser.Sync(nameof(PC), ref PC); + ser.Sync(nameof(S), ref S); + ser.Sync(nameof(NMI), ref NMI); + ser.Sync(nameof(IRQ), ref IRQ); + ser.Sync(nameof(RDY), ref RDY); + ser.Sync(nameof(TotalExecutedCycles), ref TotalExecutedCycles); + ser.Sync(nameof(opcode), ref opcode); + ser.Sync(nameof(opcode2), ref opcode2); + ser.Sync(nameof(opcode3), ref opcode3); + ser.Sync(nameof(ea), ref ea); + ser.Sync(nameof(alu_temp), ref alu_temp); + ser.Sync(nameof(mi), ref mi); + ser.Sync(nameof(iflag_pending), ref iflag_pending); + ser.Sync(nameof(interrupt_pending), ref interrupt_pending); + ser.Sync(nameof(branch_irq_hack), ref branch_irq_hack); + ser.Sync(nameof(rdy_freeze), ref rdy_freeze); + ser.Sync(nameof(ext_ppu_cycle), ref ext_ppu_cycle); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs index b8b65bdf39..d9a9c4336c 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs @@ -24,10 +24,10 @@ namespace BizHawk.Emulation.Cores.Components.Z80A public int bus_pntr = 0; public int mem_pntr = 0; public int irq_pntr = 0; - public ushort[] cur_instr; - public ushort[] BUSRQ; - public ushort[] MEMRQ; - public ushort[] IRQS; + public ushort[] cur_instr = new ushort[38]; // fixed size - do not change at runtime + public ushort[] BUSRQ = new ushort[19]; // fixed size - do not change at runtime + public ushort[] MEMRQ = new ushort[19]; // fixed size - do not change at runtime + public int IRQS; public byte opcode; public bool NO_prefix, CB_prefix, IX_prefix, EXTD_prefix, IY_prefix, IXCB_prefix, IYCB_prefix; public bool halted; diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Interrupts.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Interrupts.cs index 5eec6cf45f..869dcdac8a 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Interrupts.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Interrupts.cs @@ -36,8 +36,8 @@ namespace BizHawk.Emulation.Cores.Components.Z80A private void NMI_() { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, IDLE, IDLE, @@ -47,11 +47,11 @@ namespace BizHawk.Emulation.Cores.Components.Z80A WR_DEC, SPl, SPh, PCh, TR16, PCl, PCh, NMI_V, ZERO, WAIT, - WR, SPl, SPh, ALU }; + WR, SPl, SPh, ALU); - BUSRQ = new ushort[] { 0, 0, 0, 0, 0, SPh, 0, 0, SPh, 0, 0 }; - MEMRQ = new ushort[] { 0, 0, 0, 0, 0, SPh, 0, 0, SPh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, 0, 0, 0, 0, SPh, 0, 0, SPh, 0, 0); + PopulateMEMRQ(0, 0, 0, 0, 0, SPh, 0, 0, SPh, 0, 0); + IRQS = 11; } // Mode 0 interrupts only take effect if a CALL or RST is on the data bus @@ -61,25 +61,25 @@ namespace BizHawk.Emulation.Cores.Components.Z80A //NOTE: TODO: When a CALL is present on the data bus, adjust WZ accordingly private void INTERRUPT_0(ushort src) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, IORQ, WAIT, IDLE, WAIT, - RD_INC, ALU, PCl, PCh }; + RD_INC, ALU, PCl, PCh); - BUSRQ = new ushort[] { 0, 0, 0, 0, PCh, 0, 0 }; - MEMRQ = new ushort[] { 0, 0, 0, 0, PCh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, 0, 0, 0, PCh, 0, 0); + PopulateMEMRQ(0, 0, 0, 0, PCh, 0, 0); + IRQS = 7; } // Just jump to $0038 private void INTERRUPT_1() { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, IORQ, WAIT, @@ -91,25 +91,25 @@ namespace BizHawk.Emulation.Cores.Components.Z80A WR_DEC, SPl, SPh, PCh, TR16, PCl, PCh, IRQ_V, ZERO, WAIT, - WR, SPl, SPh, ALU }; + WR, SPl, SPh, ALU); - BUSRQ = new ushort[] { 0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0 }; - MEMRQ = new ushort[] { 0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0); + PopulateMEMRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0); + IRQS = 13; } // Interrupt mode 2 uses the I vector combined with a byte on the data bus private void INTERRUPT_2() { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, IORQ, WAIT, FTCH_DB, IDLE, DEC16, SPl, SPh, - TR16, Z, W, DB, I, + TR16, Z, W, DB, I, WAIT, WR_DEC, SPl, SPh, PCh, IDLE, @@ -120,11 +120,11 @@ namespace BizHawk.Emulation.Cores.Components.Z80A RD_INC, PCl, Z, W, IDLE, WAIT, - RD, PCh, Z, W }; + RD, PCh, Z, W); - BUSRQ = new ushort[] { 0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0 ,0 }; - MEMRQ = new ushort[] { 0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0, 0); + PopulateMEMRQ(0, 0, 0, 0, I, 0, 0, SPh, 0, 0, SPh, 0, 0, W, 0, 0, W, 0, 0); + IRQS = 19; } private void ResetInterrupts() diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/NewDisassembler.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/NewDisassembler.cs index 8bc3938c7d..aef7dc8ec5 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/NewDisassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/NewDisassembler.cs @@ -12,28 +12,15 @@ namespace BizHawk.Emulation.Cores.Components.Z80A //d immediately succeeds the opcode //n immediate succeeds the opcode and the displacement (if present) //nn immediately succeeds the opcode and the displacement (if present) - if (format.IndexOf("nn") != -1) - { - byte B = read(addr++); - byte C = read(addr++); - format = format.Replace("nn", string.Format("{0:X4}h", B + C * 256)); - } - if (format.IndexOf("n") != -1) - { - byte B = read(addr++); - format = format.Replace("n", string.Format("{0:X2}h", B)); - } + if (format.IndexOf("nn") != -1) format = format.Replace("nn", $"{read(addr++) + (read(addr++) << 8):X4}h"); // LSB is read first + if (format.IndexOf("n") != -1) format = format.Replace("n", $"{read(addr++):X2}h"); if (format.IndexOf("+d") != -1) format = format.Replace("+d", "d"); - if (format.IndexOf("d") != -1) { - byte B = read(addr++); - bool neg = ((B & 0x80) != 0); - char sign = neg ? '-' : '+'; - int val = neg ? 256 - B : B; - format = format.Replace("d", string.Format("{0}{1:X2}h", sign, val)); + var b = unchecked ((sbyte) read(addr++)); + format = format.Replace("d", $"{(b < 0 ? '-' : '+')}{(b < 0 ? -b : b):X2}h"); } return format; diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs index d643ce06c8..1212430187 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs @@ -267,7 +267,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A public void SRL_Func(ushort src) { - FlagC = Regs[src].Bit(0) ? true : false; + FlagC = Regs[src].Bit(0); Regs[src] = (ushort)(Regs[src] >> 1); diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Direct.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Direct.cs index 6af37ce302..d8ea27b445 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Direct.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Direct.cs @@ -9,111 +9,111 @@ namespace BizHawk.Emulation.Cores.Components.Z80A private void NOP_() { - cur_instr = new ushort[] - {IDLE }; + PopulateCURINSTR + (IDLE); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } // NOTE: In a real Z80, this operation just flips a switch to choose between 2 registers // but it's simpler to emulate just by exchanging the register with it's shadow private void EXCH_() { - cur_instr = new ushort[] - {EXCH }; + PopulateCURINSTR + (EXCH); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } private void EXX_() { - cur_instr = new ushort[] - {EXX }; + PopulateCURINSTR + (EXX); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } // this exchanges 2 16 bit registers private void EXCH_16_(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {EXCH_16, dest_l, dest_h, src_l, src_h }; + PopulateCURINSTR + (EXCH_16, dest_l, dest_h, src_l, src_h); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } private void INC_16(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {INC16, src_l, src_h, + PopulateCURINSTR + (INC16, src_l, src_h, IDLE, - IDLE }; + IDLE); - BUSRQ = new ushort[] { 0, I, I }; - MEMRQ = new ushort[] { 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 1 }; + PopulateBUSRQ(0, I, I); + PopulateMEMRQ(0, 0, 0); + IRQS = 3; } private void DEC_16(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {DEC16, src_l, src_h, + PopulateCURINSTR + (DEC16, src_l, src_h, IDLE, - IDLE }; + IDLE); - BUSRQ = new ushort[] { 0, I, I }; - MEMRQ = new ushort[] { 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 1 }; + PopulateBUSRQ(0, I, I); + PopulateMEMRQ(0, 0, 0); + IRQS = 3; } // this is done in two steps technically, but the flags don't work out using existing funcitons // so let's use a different function since it's an internal operation anyway private void ADD_16(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, TR16, Z, W, dest_l, dest_h, IDLE, INC16, Z, W, IDLE, ADD16, dest_l, dest_h, src_l, src_h, IDLE, - IDLE}; + IDLE); - BUSRQ = new ushort[] { 0, I, I, I, I, I, I, I }; - MEMRQ = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1}; + PopulateBUSRQ(0, I, I, I, I, I, I, I); + PopulateMEMRQ(0, 0, 0, 0, 0, 0, 0, 0); + IRQS = 8; } private void REG_OP(ushort operation, ushort dest, ushort src) { - cur_instr = new ushort[] - {operation, dest, src }; + PopulateCURINSTR + (operation, dest, src); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } // Operations using the I and R registers take one T-cycle longer private void REG_OP_IR(ushort operation, ushort dest, ushort src) { - cur_instr = new ushort[] - {IDLE, - SET_FL_IR, dest, src }; + PopulateCURINSTR + (IDLE, + SET_FL_IR, dest, src); - BUSRQ = new ushort[] { 0, I }; - MEMRQ = new ushort[] { 0, 0 }; - IRQS = new ushort[] { 0, 1 }; + PopulateBUSRQ(0, I); + PopulateMEMRQ(0, 0); + IRQS = 2; } // note: do not use DEC here since no flags are affected by this operation @@ -121,8 +121,8 @@ namespace BizHawk.Emulation.Cores.Components.Z80A { if ((Regs[B] - 1) != 0) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, ASGN, B, (ushort)((Regs[B] - 1) & 0xFF), WAIT, @@ -131,43 +131,43 @@ namespace BizHawk.Emulation.Cores.Components.Z80A IDLE, ASGN, W, 0, ADDS, PCl, PCh, Z, W, - TR16, Z, W, PCl, PCh }; + TR16, Z, W, PCl, PCh); - BUSRQ = new ushort[] { 0, I, PCh, 0, 0, PCh, PCh, PCh, PCh, PCh }; - MEMRQ = new ushort[] { 0, 0, PCh, 0, 0, 0, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, I, PCh, 0, 0, PCh, PCh, PCh, PCh, PCh); + PopulateMEMRQ(0, 0, PCh, 0, 0, 0, 0, 0, 0, 0); + IRQS = 10; } else { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, ASGN, B, (ushort)((Regs[B] - 1) & 0xFF), WAIT, - RD_INC, ALU, PCl, PCh }; + RD_INC, ALU, PCl, PCh); - BUSRQ = new ushort[] { 0, I, PCh, 0, 0 }; - MEMRQ = new ushort[] { 0, 0, PCh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, I, PCh, 0, 0); + PopulateMEMRQ(0, 0, PCh, 0, 0); + IRQS = 5; } } private void HALT_() { - cur_instr = new ushort[] - { HALT }; + PopulateCURINSTR + (HALT); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } private void JR_COND(bool cond) { if (cond) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, PCl, PCh, @@ -175,23 +175,23 @@ namespace BizHawk.Emulation.Cores.Components.Z80A ASGN, W, 0, IDLE, ADDS, PCl, PCh, Z, W, - TR16, Z, W, PCl, PCh }; + TR16, Z, W, PCl, PCh); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, PCh, PCh, PCh, PCh }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, 0, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, PCh, PCh, PCh, PCh); + PopulateMEMRQ(0, PCh, 0, 0, 0, 0, 0, 0, 0); + IRQS = 9; } else { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, - RD_INC, ALU, PCl, PCh }; + RD_INC, ALU, PCl, PCh); - BUSRQ = new ushort[] { 0, PCh, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0); + IRQS = 4; } } @@ -199,82 +199,82 @@ namespace BizHawk.Emulation.Cores.Components.Z80A { if (cond) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, PCl, PCh, IDLE, WAIT, - RD_INC_TR_PC, Z, W, PCl, PCh}; + RD_INC_TR_PC, Z, W, PCl, PCh); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, PCh, 0, 0); + IRQS = 7; } else { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, PCl, PCh, IDLE, WAIT, - RD_INC, W, PCl, PCh }; + RD_INC, W, PCl, PCh); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, PCh, 0, 0); + IRQS = 7; } } private void RET_() { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, SPl, SPh, IDLE, WAIT, - RD_INC_TR_PC, Z, W, SPl, SPh }; + RD_INC_TR_PC, Z, W, SPl, SPh); - BUSRQ = new ushort[] { 0, SPh, 0, 0, SPh, 0, 0 }; - MEMRQ = new ushort[] { 0, SPh, 0, 0, SPh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, SPh, 0, 0, SPh, 0, 0); + PopulateMEMRQ(0, SPh, 0, 0, SPh, 0, 0); + IRQS = 7; } private void RETI_() { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, SPl, SPh, IDLE, WAIT, - RD_INC_TR_PC, Z, W, SPl, SPh }; + RD_INC_TR_PC, Z, W, SPl, SPh); - BUSRQ = new ushort[] { 0, SPh, 0, 0, SPh, 0, 0 }; - MEMRQ = new ushort[] { 0, SPh, 0, 0, SPh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, SPh, 0, 0, SPh, 0, 0); + PopulateMEMRQ(0, SPh, 0, 0, SPh, 0, 0); + IRQS = 7; } private void RETN_() { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, SPl, SPh, EI_RETN, WAIT, - RD_INC_TR_PC, Z, W, SPl, SPh }; + RD_INC_TR_PC, Z, W, SPl, SPh); - BUSRQ = new ushort[] { 0, SPh, 0, 0, SPh, 0, 0 }; - MEMRQ = new ushort[] { 0, SPh, 0, 0, SPh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, SPh, 0, 0, SPh, 0, 0); + PopulateMEMRQ(0, SPh, 0, 0, SPh, 0, 0); + IRQS = 7; } @@ -282,29 +282,29 @@ namespace BizHawk.Emulation.Cores.Components.Z80A { if (cond) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, IDLE, WAIT, - RD_INC, Z, SPl, SPh, - IDLE, + RD_INC, Z, SPl, SPh, + IDLE, WAIT, - RD_INC_TR_PC, Z, W, SPl, SPh}; + RD_INC_TR_PC, Z, W, SPl, SPh); - BUSRQ = new ushort[] { 0, I, SPh, 0, 0, SPh, 0, 0 }; - MEMRQ = new ushort[] { 0, 0, SPh, 0, 0, SPh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, I, SPh, 0, 0, SPh, 0, 0); + PopulateMEMRQ(0, 0, SPh, 0, 0, SPh, 0, 0); + IRQS = 8; } else { - cur_instr = new ushort[] - {IDLE, - IDLE }; + PopulateCURINSTR + (IDLE, + IDLE); - BUSRQ = new ushort[] { 0, I }; - MEMRQ = new ushort[] { 0, 0 }; - IRQS = new ushort[] { 0, 1 }; + PopulateBUSRQ(0, I); + PopulateMEMRQ(0, 0); + IRQS = 2; } } @@ -312,8 +312,8 @@ namespace BizHawk.Emulation.Cores.Components.Z80A { if (cond) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, PCl, PCh, @@ -326,113 +326,113 @@ namespace BizHawk.Emulation.Cores.Components.Z80A WR_DEC, SPl, SPh, PCh, IDLE, WAIT, - WR_TR_PC, SPl, SPh, PCl }; + WR_TR_PC, SPl, SPh, PCl); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, PCh, SPh, 0, 0, SPh, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, 0, SPh, 0, 0, SPh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, 0, 0, PCh, SPh, 0, 0, SPh, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, PCh, 0, 0, 0, SPh, 0, 0, SPh, 0, 0); + IRQS = 14; } else { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, PCl, PCh, IDLE, WAIT, - RD_INC, W, PCl, PCh}; + RD_INC, W, PCl, PCh); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, PCh, 0, 0); + IRQS = 7; } } private void INT_OP(ushort operation, ushort src) { - cur_instr = new ushort[] - {operation, src }; + PopulateCURINSTR + (operation, src); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } private void BIT_OP(ushort operation, ushort bit, ushort src) { - cur_instr = new ushort[] - {operation, bit, src }; + PopulateCURINSTR + (operation, bit, src); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } private void PUSH_(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, DEC16, SPl, SPh, IDLE, WAIT, WR_DEC, SPl, SPh, src_h, IDLE, WAIT, - WR, SPl, SPh, src_l }; + WR, SPl, SPh, src_l); - BUSRQ = new ushort[] { 0, I, SPh, 0, 0, SPh, 0, 0 }; - MEMRQ = new ushort[] { 0, 0, SPh, 0, 0, SPh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, I, SPh, 0, 0, SPh, 0, 0); + PopulateMEMRQ(0, 0, SPh, 0, 0, SPh, 0, 0); + IRQS = 8; } private void POP_(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, src_l, SPl, SPh, IDLE, WAIT, - RD_INC, src_h, SPl, SPh }; + RD_INC, src_h, SPl, SPh); - BUSRQ = new ushort[] { 0, SPh, 0, 0, SPh, 0, 0 }; - MEMRQ = new ushort[] { 0, SPh, 0, 0, SPh, 0, 0 }; - IRQS = new ushort[] {0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, SPh, 0, 0, SPh, 0, 0); + PopulateMEMRQ(0, SPh, 0, 0, SPh, 0, 0); + IRQS = 7; } private void RST_(ushort n) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, DEC16, SPl, SPh, IDLE, WAIT, WR_DEC, SPl, SPh, PCh, RST, n, WAIT, - WR_TR_PC, SPl, SPh, PCl }; + WR_TR_PC, SPl, SPh, PCl); - BUSRQ = new ushort[] { 0, I, SPh, 0, 0, SPh, 0, 0 }; - MEMRQ = new ushort[] { 0, 0, SPh, 0, 0, SPh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, I, SPh, 0, 0, SPh, 0, 0); + PopulateMEMRQ(0, 0, SPh, 0, 0, SPh, 0, 0); + IRQS = 8; } private void PREFIX_(ushort src) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, - PREFIX }; + PREFIX); PRE_SRC = src; - BUSRQ = new ushort[] { 0, PCh, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0 }; // prefix does not get interrupted + PopulateBUSRQ(0, PCh, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0); + IRQS = -1; // prefix does not get interrupted } private void PREFETCH_(ushort src) @@ -448,160 +448,160 @@ namespace BizHawk.Emulation.Cores.Components.Z80A Regs[Z] = Regs[Iyl]; } - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, ALU, PCl, PCh, ADDS, Z, W, ALU, ZERO, WAIT, IDLE, - PREFIX}; + PREFIX); PRE_SRC = src; //Console.WriteLine(TotalExecutedCycles); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, PCh }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0 }; // prefetch does not get interrupted + PopulateBUSRQ(0, PCh, 0, 0, PCh, 0, 0, PCh); + PopulateMEMRQ(0, PCh, 0, 0, PCh, 0, 0, 0); + IRQS = -1; // prefetch does not get interrupted } private void DI_() { - cur_instr = new ushort[] - {DI }; + PopulateCURINSTR + (DI); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } private void EI_() { - cur_instr = new ushort[] - {EI }; + PopulateCURINSTR + (EI); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } private void JP_16(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {TR16, PCl, PCh, src_l, src_h }; + PopulateCURINSTR + (TR16, PCl, PCh, src_l, src_h); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } private void LD_SP_16(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, - TR16, SPl, SPh, src_l, src_h }; + TR16, SPl, SPh, src_l, src_h); - BUSRQ = new ushort[] { 0, I, I }; - MEMRQ = new ushort[] { 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 1 }; + PopulateBUSRQ(0, I, I); + PopulateMEMRQ(0, 0, 0); + IRQS = 3; } private void OUT_() { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, TR, W, A, WAIT, RD_INC, Z, PCl, PCh, - TR, ALU, A, - WAIT, + TR, ALU, A, WAIT, - OUT_INC, Z, ALU, A }; + WAIT, + OUT_INC, Z, ALU, A); - BUSRQ = new ushort[] { 0, PCh, 0, 0, WIO1, WIO2, WIO3, WIO4 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, WIO1, WIO2, WIO3, WIO4 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1}; + PopulateBUSRQ(0, PCh, 0, 0, WIO1, WIO2, WIO3, WIO4); + PopulateMEMRQ(0, PCh, 0, 0, WIO1, WIO2, WIO3, WIO4); + IRQS = 8; } private void OUT_REG_(ushort dest, ushort src) { - cur_instr = new ushort[] - {IDLE, - TR16, Z, W, C, B, - IDLE, + PopulateCURINSTR + (IDLE, + TR16, Z, W, C, B, IDLE, - OUT_INC, Z, W, src }; + IDLE, + OUT_INC, Z, W, src); - BUSRQ = new ushort[] { 0, BIO1, BIO2, BIO3, BIO4 }; - MEMRQ = new ushort[] { 0, BIO1, BIO2, BIO3, BIO4 }; - IRQS = new ushort[] { 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, BIO1, BIO2, BIO3, BIO4); + PopulateMEMRQ(0, BIO1, BIO2, BIO3, BIO4); + IRQS = 5; } private void IN_() { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, TR, W, A, WAIT, RD_INC, Z, PCl, PCh, IDLE, WAIT, WAIT, - IN_A_N_INC, A, Z, W }; + IN_A_N_INC, A, Z, W); - BUSRQ = new ushort[] { 0, PCh, 0, 0, WIO1, WIO2, WIO3, WIO4 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, WIO1, WIO2, WIO3, WIO4 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, WIO1, WIO2, WIO3, WIO4); + PopulateMEMRQ(0, PCh, 0, 0, WIO1, WIO2, WIO3, WIO4); + IRQS = 8; } private void IN_REG_(ushort dest, ushort src) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, TR16, Z, W, C, B, WAIT, WAIT, - IN_INC, dest, Z, W }; + IN_INC, dest, Z, W); - BUSRQ = new ushort[] { 0, BIO1, BIO2, BIO3, BIO4 }; - MEMRQ = new ushort[] { 0, BIO1, BIO2, BIO3, BIO4 }; - IRQS = new ushort[] { 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, BIO1, BIO2, BIO3, BIO4); + PopulateMEMRQ(0, BIO1, BIO2, BIO3, BIO4); + IRQS = 5; } private void REG_OP_16_(ushort op, ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, IDLE, TR16, Z, W, dest_l, dest_h, INC16, Z, W, IDLE, IDLE, - op, dest_l, dest_h, src_l, src_h }; + op, dest_l, dest_h, src_l, src_h); - BUSRQ = new ushort[] { 0, I, I, I, I, I, I, I }; - MEMRQ = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, I, I, I, I, I, I, I); + PopulateMEMRQ(0, 0, 0, 0, 0, 0, 0, 0); + IRQS = 8; } private void INT_MODE_(ushort src) { - cur_instr = new ushort[] - {INT_MODE, src }; + PopulateCURINSTR + (INT_MODE, src); - BUSRQ = new ushort[] { 0 }; - MEMRQ = new ushort[] { 0 }; - IRQS = new ushort[] { 1 }; + PopulateBUSRQ(0); + PopulateMEMRQ(0); + IRQS = 1; } private void RRD_() { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, TR16, Z, W, L, H, WAIT, RD, ALU, Z, W, @@ -611,17 +611,17 @@ namespace BizHawk.Emulation.Cores.Components.Z80A IDLE, IDLE, WAIT, - WR_INC, Z, W, ALU }; + WR_INC, Z, W, ALU); - BUSRQ = new ushort[] { 0, H, 0, 0, H, H, H, H, W, 0, 0 }; - MEMRQ = new ushort[] { 0, H, 0, 0, 0, 0, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, H, 0, 0, H, H, H, H, W, 0, 0); + PopulateMEMRQ(0, H, 0, 0, 0, 0, 0, 0, W, 0, 0); + IRQS = 11; } private void RLD_() { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, TR16, Z, W, L, H, WAIT, RD, ALU, Z, W, @@ -631,11 +631,11 @@ namespace BizHawk.Emulation.Cores.Components.Z80A IDLE, IDLE, WAIT, - WR_INC, Z, W, ALU }; + WR_INC, Z, W, ALU); - BUSRQ = new ushort[] { 0, H, 0, 0, H, H, H, H, W, 0, 0 }; - MEMRQ = new ushort[] { 0, H, 0, 0, 0, 0, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, H, 0, 0, H, H, H, H, W, 0, 0); + PopulateMEMRQ(0, H, 0, 0, 0, 0, 0, 0, W, 0, 0); + IRQS = 11; } } } diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Indirect.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Indirect.cs index 65e0b607f5..4549fa54d1 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Indirect.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Indirect.cs @@ -4,36 +4,36 @@ { private void INT_OP_IND(ushort operation, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD, ALU, src_l, src_h, IDLE, operation, ALU, WAIT, - WR, src_l, src_h, ALU }; + WR, src_l, src_h, ALU); - BUSRQ = new ushort[] { 0, src_h, 0, 0, src_h, src_h, 0, 0 }; - MEMRQ = new ushort[] { 0, src_h, 0, 0, 0, src_h, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, src_h, 0, 0, src_h, src_h, 0, 0); + PopulateMEMRQ(0, src_h, 0, 0, 0, src_h, 0, 0); + IRQS = 8; } private void BIT_OP_IND(ushort operation, ushort bit, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, - WAIT, + WAIT, RD, ALU, src_l, src_h, operation, bit, ALU, IDLE, WAIT, - WR, src_l, src_h, ALU }; + WR, src_l, src_h, ALU); - BUSRQ = new ushort[] { 0, src_h, 0, 0, src_h, src_h, 0, 0 }; - MEMRQ = new ushort[] { 0, src_h, 0, 0, 0, src_h, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, src_h, 0, 0, src_h, src_h, 0, 0); + PopulateMEMRQ(0, src_h, 0, 0, 0, src_h, 0, 0); + IRQS = 8; } // Note that this operation uses I_BIT, same as indexed BIT. @@ -42,62 +42,62 @@ // even though WZ is not assigned to, letting it's value from other operations show through private void BIT_TE_IND(ushort operation, ushort bit, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD, ALU, src_l, src_h, - I_BIT, bit, ALU }; + I_BIT, bit, ALU); - BUSRQ = new ushort[] { 0, src_h, 0, 0, src_h }; - MEMRQ = new ushort[] { 0, src_h, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, src_h, 0, 0, src_h); + PopulateMEMRQ(0, src_h, 0, 0, 0); + IRQS = 5; } private void REG_OP_IND_INC(ushort operation, ushort dest, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, - IDLE, - WAIT, - RD_OP, 1, ALU, src_l, src_h, operation, dest, ALU }; + PopulateCURINSTR + (IDLE, + IDLE, + WAIT, + RD_OP, 1, ALU, src_l, src_h, operation, dest, ALU); - BUSRQ = new ushort[] { 0, src_h, 0, 0 }; - MEMRQ = new ushort[] { 0, src_h, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 1}; + PopulateBUSRQ(0, src_h, 0, 0); + PopulateMEMRQ(0, src_h, 0, 0); + IRQS = 4; } private void REG_OP_IND(ushort operation, ushort dest, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, TR16, Z, W, src_l, src_h, WAIT, - RD_OP, 1, ALU, Z, W, operation, dest, ALU }; + RD_OP, 1, ALU, Z, W, operation, dest, ALU); - BUSRQ = new ushort[] { 0, src_h, 0, 0 }; - MEMRQ = new ushort[] { 0, src_h, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 1 }; + PopulateBUSRQ(0, src_h, 0, 0); + PopulateMEMRQ(0, src_h, 0, 0); + IRQS = 4; } // different because HL doesn't effect WZ private void REG_OP_IND_HL(ushort operation, ushort dest) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, - RD_OP, 0, ALU, L, H, operation, dest, ALU }; + RD_OP, 0, ALU, L, H, operation, dest, ALU); - BUSRQ = new ushort[] { 0, H, 0, 0 }; - MEMRQ = new ushort[] { 0, H, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 1 }; + PopulateBUSRQ(0, H, 0, 0); + PopulateMEMRQ(0, H, 0, 0); + IRQS = 4; } private void LD_16_IND_nn(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, PCl, PCh, @@ -109,17 +109,17 @@ WR_INC, Z, W, src_l, IDLE, WAIT, - WR, Z, W, src_h }; + WR, Z, W, src_h); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, W, 0, 0, W, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, W, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, 0, 0, W, 0, 0, W, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, PCh, 0, 0, W, 0, 0, W, 0, 0); + IRQS = 13; } private void LD_IND_16_nn(ushort dest_l, ushort dest_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, PCl, PCh, @@ -131,17 +131,17 @@ RD_INC, dest_l, Z, W, IDLE, WAIT, - RD, dest_h, Z, W }; + RD, dest_h, Z, W); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, W, 0, 0, W, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, W, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, 0, 0, W, 0, 0, W, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, PCh, 0, 0, W, 0, 0, W, 0, 0); + IRQS = 13; } private void LD_8_IND_nn(ushort src) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, PCl, PCh, @@ -150,17 +150,17 @@ RD_INC, W, PCl, PCh, IDLE, WAIT, - WR_INC_WA, Z, W, src }; + WR_INC_WA, Z, W, src); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, W, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, 0, 0, W, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, PCh, 0, 0, W, 0, 0); + IRQS = 10; } private void LD_IND_8_nn(ushort dest) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, PCl, PCh, @@ -169,172 +169,172 @@ RD_INC, W, PCl, PCh, IDLE, WAIT, - RD_INC, dest, Z, W }; + RD_INC, dest, Z, W); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, W, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, 0, 0, W, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, PCh, 0, 0, W, 0, 0); + IRQS = 10; } private void LD_8_IND(ushort dest_l, ushort dest_h, ushort src) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, TR16, Z, W, dest_l, dest_h, WAIT, - WR_INC_WA, Z, W, src }; + WR_INC_WA, Z, W, src); - BUSRQ = new ushort[] { 0, dest_h, 0, 0 }; - MEMRQ = new ushort[] { 0, dest_h, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 1 }; + PopulateBUSRQ(0, dest_h, 0, 0); + PopulateMEMRQ(0, dest_h, 0, 0); + IRQS = 4; } // seperate HL needed since it doesn't effect the WZ pair private void LD_8_IND_HL(ushort src) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, - WR, L, H, src }; + WR, L, H, src); - BUSRQ = new ushort[] { 0, H, 0, 0 }; - MEMRQ = new ushort[] { 0, H, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 1 }; + PopulateBUSRQ(0, H, 0, 0); + PopulateMEMRQ(0, H, 0, 0); + IRQS = 4; } private void LD_8_IND_IND(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, ALU, src_l, src_h, IDLE, WAIT, - WR, dest_l, dest_h, ALU }; + WR, dest_l, dest_h, ALU); - BUSRQ = new ushort[] { 0, src_h, 0, 0, dest_h, 0, 0 }; - MEMRQ = new ushort[] { 0, src_h, 0, 0, dest_h, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, src_h, 0, 0, dest_h, 0, 0); + PopulateMEMRQ(0, src_h, 0, 0, dest_h, 0, 0); + IRQS = 7; } private void LD_IND_8_INC(ushort dest, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, - RD_INC, dest, src_l, src_h }; + RD_INC, dest, src_l, src_h); - BUSRQ = new ushort[] { 0, src_h, 0, 0 }; - MEMRQ = new ushort[] { 0, src_h, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 1 }; + PopulateBUSRQ(0, src_h, 0, 0); + PopulateMEMRQ(0, src_h, 0, 0); + IRQS = 4; } private void LD_IND_16(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, dest_l, src_l, src_h, IDLE, WAIT, - RD_INC, dest_h, src_l, src_h }; + RD_INC, dest_h, src_l, src_h); - BUSRQ = new ushort[] { 0, src_h, 0, 0, src_h, 0, 0 }; - MEMRQ = new ushort[] { 0, src_h, 0, 0, src_h, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, src_h, 0, 0, src_h, 0, 0); + PopulateMEMRQ(0, src_h, 0, 0, src_h, 0, 0); + IRQS = 7; } private void INC_8_IND(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, - WAIT, + WAIT, RD, ALU, src_l, src_h, INC8, ALU, IDLE, WAIT, - WR, src_l, src_h, ALU }; + WR, src_l, src_h, ALU); - BUSRQ = new ushort[] { 0, src_h, 0, 0, src_h, src_h, 0, 0 }; - MEMRQ = new ushort[] { 0, src_h, 0, 0, 0, src_h, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, src_h, 0, 0, src_h, src_h, 0, 0); + PopulateMEMRQ(0, src_h, 0, 0, 0, src_h, 0, 0); + IRQS = 8; } private void DEC_8_IND(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, - WAIT, + WAIT, RD, ALU, src_l, src_h, DEC8, ALU, IDLE, WAIT, - WR, src_l, src_h, ALU }; + WR, src_l, src_h, ALU); - BUSRQ = new ushort[] { 0, src_h, 0, 0, src_h, src_h, 0, 0 }; - MEMRQ = new ushort[] { 0, src_h, 0, 0, 0, src_h, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, src_h, 0, 0, src_h, src_h, 0, 0); + PopulateMEMRQ(0, src_h, 0, 0, 0, src_h, 0, 0); + IRQS = 8; } // NOTE: WZ implied for the wollowing 3 functions private void I_INT_OP(ushort operation, ushort dest) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD, ALU, Z, W, operation, ALU, TR, dest, ALU, WAIT, - WR, Z, W, ALU }; + WR, Z, W, ALU); - BUSRQ = new ushort[] { 0, W, 0, 0, W, W, 0, 0 }; - MEMRQ = new ushort[] { 0, W, 0, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, W, 0, 0, W, W, 0, 0); + PopulateMEMRQ(0, W, 0, 0, 0, W, 0, 0); + IRQS = 8; } private void I_BIT_OP(ushort operation, ushort bit, ushort dest) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD, ALU, Z, W, operation, bit, ALU, TR, dest, ALU, WAIT, - WR, Z, W, ALU }; + WR, Z, W, ALU); - BUSRQ = new ushort[] { 0, W, 0, 0, W, W, 0, 0 }; - MEMRQ = new ushort[] { 0, W, 0, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 1}; + PopulateBUSRQ(0, W, 0, 0, W, W, 0, 0); + PopulateMEMRQ(0, W, 0, 0, 0, W, 0, 0); + IRQS = 8; } private void I_BIT_TE(ushort bit) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD, ALU, Z, W, - I_BIT, bit, ALU }; + I_BIT, bit, ALU); - BUSRQ = new ushort[] { 0, W, 0, 0, W }; - MEMRQ = new ushort[] { 0, W, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, W, 0, 0, W); + PopulateMEMRQ(0, W, 0, 0, 0); + IRQS = 5; } private void I_OP_n(ushort operation, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD, ALU, PCl, PCh, @@ -349,17 +349,17 @@ operation, ALU, IDLE, WAIT, - WR, Z, W, ALU }; + WR, Z, W, ALU); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, PCh, PCh, PCh, PCh, W, 0, 0, W, W, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, 0, 0, 0, 0, 0, W, 0, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, PCh, PCh, PCh, PCh, W, 0, 0, W, W, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, 0, 0, 0, 0, 0, W, 0, 0, 0, W, 0, 0); + IRQS = 16; } private void I_OP_n_n(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, TR16, Z, W, src_l, src_h, WAIT, RD_INC, ALU, PCl, PCh, @@ -370,17 +370,17 @@ IDLE, INC16, PCl, PCh, WAIT, - WR, Z, W, ALU }; + WR, Z, W, ALU); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, PCh, PCh, W, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, PCh, 0, 0, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, 0, 0, PCh, PCh, W, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, PCh, 0, 0, 0, 0, W, 0, 0); + IRQS = 12; } private void I_REG_OP_IND_n(ushort operation, ushort dest, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD, ALU, PCl, PCh, @@ -391,38 +391,38 @@ IDLE, INC16, PCl, PCh, WAIT, - RD_OP, 0, ALU, Z, W, operation, dest, ALU }; + RD_OP, 0, ALU, Z, W, operation, dest, ALU); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, PCh, PCh, PCh, PCh, W, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, 0, 0, 0, 0, 0, W, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, PCh, PCh, PCh, PCh, W, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, 0, 0, 0, 0, 0, W, 0, 0); + IRQS = 12; } private void I_LD_8_IND_n(ushort dest_l, ushort dest_h, ushort src) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD, ALU, PCl, PCh, IDLE, - IDLE, + IDLE, TR16, Z, W, dest_l, dest_h, ADDS, Z, W, ALU, ZERO, IDLE, INC16, PCl, PCh, WAIT, - WR, Z, W, src }; + WR, Z, W, src); - BUSRQ = new ushort[] { 0, PCh, 0, 0, PCh, PCh, PCh, PCh, PCh, Z, 0, 0 }; - MEMRQ = new ushort[] { 0, PCh, 0, 0, 0, 0, 0, 0, 0, Z, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, PCh, 0, 0, PCh, PCh, PCh, PCh, PCh, Z, 0, 0); + PopulateMEMRQ(0, PCh, 0, 0, 0, 0, 0, 0, 0, Z, 0, 0); + IRQS = 12; } private void LD_OP_R(ushort operation, ushort repeat_instr) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD, ALU, L, H, @@ -430,17 +430,17 @@ WAIT, WR, E, D, ALU, IDLE, - SET_FL_LD_R, 0, operation, repeat_instr}; + SET_FL_LD_R, 0, operation, repeat_instr); - BUSRQ = new ushort[] { 0, H, 0, 0, D, 0, 0, D, D }; - MEMRQ = new ushort[] { 0, H, 0, 0, D, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, H, 0, 0, D, 0, 0, D, D); + PopulateMEMRQ(0, H, 0, 0, D, 0, 0, 0, 0); + IRQS = 9; } private void CP_OP_R(ushort operation, ushort repeat_instr) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD, ALU, L, H, @@ -448,17 +448,17 @@ DEC16, C, B, operation, Z, W, IDLE, - SET_FL_CP_R, 1, operation, repeat_instr}; + SET_FL_CP_R, 1, operation, repeat_instr); - BUSRQ = new ushort[] { 0, H, 0, 0, H, H, H, H, H }; - MEMRQ = new ushort[] { 0, H, 0, 0, 0, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, H, 0, 0, H, H, H, H, H); + PopulateMEMRQ(0, H, 0, 0, 0, 0, 0, 0, 0); + IRQS = 9; } private void IN_OP_R(ushort operation, ushort repeat_instr) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, IDLE, WAIT, @@ -466,55 +466,55 @@ IN, ALU, C, B, IDLE, WAIT, - REP_OP_I, L, H, ALU, operation, 2, operation, repeat_instr }; + REP_OP_I, L, H, ALU, operation, 2, operation, repeat_instr); - BUSRQ = new ushort[] { 0, I, BIO1, BIO2, BIO3, BIO4, H, 0, 0}; - MEMRQ = new ushort[] { 0, 0, BIO1, BIO2, BIO3, BIO4, H, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, I, BIO1, BIO2, BIO3, BIO4, H, 0, 0); + PopulateMEMRQ(0, 0, BIO1, BIO2, BIO3, BIO4, H, 0, 0); + IRQS = 9; } private void OUT_OP_R(ushort operation, ushort repeat_instr) { - cur_instr = new ushort[] - {IDLE, - IDLE, + PopulateCURINSTR + (IDLE, + IDLE, IDLE, WAIT, RD, ALU, L, H, IDLE, WAIT, - WAIT, - REP_OP_O, C, B, ALU, operation, 3, operation, repeat_instr }; + WAIT, + REP_OP_O, C, B, ALU, operation, 3, operation, repeat_instr); - BUSRQ = new ushort[] { 0, I, H, 0, 0, BIO1, BIO2, BIO3, BIO4 }; - MEMRQ = new ushort[] { 0, 0, H, 0, 0, BIO1, BIO2, BIO3, BIO4 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, I, H, 0, 0, BIO1, BIO2, BIO3, BIO4); + PopulateMEMRQ(0, 0, H, 0, 0, BIO1, BIO2, BIO3, BIO4); + IRQS = 9; } // this is an indirect change of a a 16 bit register with memory private void EXCH_16_IND_(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, WAIT, RD_INC, Z, dest_l, dest_h, - IDLE, + IDLE, WAIT, RD, W, dest_l, dest_h, IDLE, IDLE, WAIT, WR_DEC, dest_l, dest_h, src_h, - IDLE, + IDLE, WAIT, WR, dest_l, dest_h, src_l, IDLE, - TR16, src_l, src_h, Z, W }; + TR16, src_l, src_h, Z, W); - BUSRQ = new ushort[] { 0, dest_h, 0, 0, dest_h, 0, 0, dest_h, dest_h, 0, 0, dest_h, 0, 0, dest_h, dest_h }; - MEMRQ = new ushort[] { 0, dest_h, 0, 0, dest_h, 0, 0, 0, dest_h, 0, 0, dest_h, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + PopulateBUSRQ(0, dest_h, 0, 0, dest_h, 0, 0, dest_h, dest_h, 0, 0, dest_h, 0, 0, dest_h, dest_h); + PopulateMEMRQ(0, dest_h, 0, 0, dest_h, 0, 0, 0, dest_h, 0, 0, dest_h, 0, 0, 0, 0); + IRQS = 16; } } } diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs index 6c7c9f3e50..8560300319 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs @@ -104,14 +104,15 @@ namespace BizHawk.Emulation.Cores.Components.Z80A ResetRegisters(); ResetInterrupts(); TotalExecutedCycles = 0; - cur_instr = new ushort[] - {IDLE, - DEC16, F, A, - DEC16, SPl, SPh }; - BUSRQ = new ushort[] { 0, 0, 0 }; - MEMRQ = new ushort[] { 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 1 }; + PopulateCURINSTR + (IDLE, + DEC16, F, A, + DEC16, SPl, SPh); + + PopulateBUSRQ(0, 0, 0); + PopulateMEMRQ(0, 0, 0); + IRQS = 3; instr_pntr = mem_pntr = bus_pntr = irq_pntr = 0; NO_prefix = true; } @@ -459,16 +460,16 @@ namespace BizHawk.Emulation.Cores.Components.Z80A if (((Regs[C] | (Regs[B] << 8)) != 0) && (Ztemp3 > 0)) { - cur_instr = new ushort[] - {DEC16, PCl, PCh, + PopulateCURINSTR + (DEC16, PCl, PCh, DEC16, PCl, PCh, TR16, Z, W, PCl, PCh, INC16, Z, W, - Ztemp2, E, D }; + Ztemp2, E, D); - BUSRQ = new ushort[] { D, D, D, D, D }; - MEMRQ = new ushort[] { 0, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 1 }; + PopulateBUSRQ(D, D, D, D, D); + PopulateMEMRQ(0, 0, 0, 0, 0); + IRQS = 5; instr_pntr = mem_pntr = bus_pntr = irq_pntr = 0; I_skip = true; @@ -488,16 +489,17 @@ namespace BizHawk.Emulation.Cores.Components.Z80A if (((Regs[C] | (Regs[B] << 8)) != 0) && (Ztemp3 > 0) && !FlagZ) { - cur_instr = new ushort[] - {DEC16, PCl, PCh, + + PopulateCURINSTR + (DEC16, PCl, PCh, DEC16, PCl, PCh, TR16, Z, W, PCl, PCh, - INC16, Z, W, - Ztemp2, L, H }; + INC16, Z, W, + Ztemp2, L, H); - BUSRQ = new ushort[] { H, H, H, H, H }; - MEMRQ = new ushort[] { 0, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 1 }; + PopulateBUSRQ(H, H, H, H, H); + PopulateMEMRQ(0, 0, 0, 0, 0); + IRQS = 5; instr_pntr = mem_pntr = bus_pntr = irq_pntr = 0; I_skip = true; @@ -562,16 +564,16 @@ namespace BizHawk.Emulation.Cores.Components.Z80A if ((Regs[B] != 0) && (Ztemp3 > 0)) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, DEC16, PCl, PCh, DEC16, PCl, PCh, - Ztemp2, L, H }; + Ztemp2, L, H); - BUSRQ = new ushort[] { H, H, H, H, H }; - MEMRQ = new ushort[] { 0, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 1 }; + PopulateBUSRQ(H, H, H, H, H); + PopulateMEMRQ(0, 0, 0, 0, 0); + IRQS = 5; instr_pntr = mem_pntr = bus_pntr = irq_pntr = 0; I_skip = true; @@ -613,16 +615,16 @@ namespace BizHawk.Emulation.Cores.Components.Z80A if ((Regs[B] != 0) && (Ztemp3 > 0)) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, IDLE, DEC16, PCl, PCh, DEC16, PCl, PCh, - IDLE }; + IDLE); - BUSRQ = new ushort[] { B, B, B, B, B }; - MEMRQ = new ushort[] { 0, 0, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 0, 1 }; + PopulateBUSRQ(B, B, B, B, B); + PopulateMEMRQ(0, 0, 0, 0, 0); + IRQS = 5; instr_pntr = mem_pntr = bus_pntr = irq_pntr = 0; I_skip = true; @@ -638,7 +640,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A { I_skip = false; } - else if (IRQS[irq_pntr++] == 1) + else if (++irq_pntr == IRQS) { if (EI_pending > 0) { @@ -707,15 +709,15 @@ namespace BizHawk.Emulation.Cores.Components.Z80A // otherwise start a new normal access else if (!halted) { - cur_instr = new ushort[] - {IDLE, + PopulateCURINSTR + (IDLE, WAIT, OP_F, - OP}; + OP); - BUSRQ = new ushort[] { PCh, 0, 0, 0 }; - MEMRQ = new ushort[] { PCh, 0, 0, 0 }; - IRQS = new ushort[] { 0, 0, 0, 1 }; + PopulateBUSRQ(PCh, 0, 0, 0); + PopulateMEMRQ(PCh, 0, 0, 0); + IRQS = 4; instr_pntr = mem_pntr = bus_pntr = irq_pntr = 0; } @@ -781,41 +783,94 @@ namespace BizHawk.Emulation.Cores.Components.Z80A }; } + /// + /// Optimization method to set BUSRQ + /// + private void PopulateBUSRQ(ushort d0 = 0, ushort d1 = 0, ushort d2 = 0, ushort d3 = 0, ushort d4 = 0, ushort d5 = 0, ushort d6 = 0, ushort d7 = 0, ushort d8 = 0, + ushort d9 = 0, ushort d10 = 0, ushort d11 = 0, ushort d12 = 0, ushort d13 = 0, ushort d14 = 0, ushort d15 = 0, ushort d16 = 0, ushort d17 = 0, ushort d18 = 0) + { + BUSRQ[0] = d0; BUSRQ[1] = d1; BUSRQ[2] = d2; + BUSRQ[3] = d3; BUSRQ[4] = d4; BUSRQ[5] = d5; + BUSRQ[6] = d6; BUSRQ[7] = d7; BUSRQ[8] = d8; + BUSRQ[9] = d9; BUSRQ[10] = d10; BUSRQ[11] = d11; + BUSRQ[12] = d12; BUSRQ[13] = d13; BUSRQ[14] = d14; + BUSRQ[15] = d15; BUSRQ[16] = d16; BUSRQ[17] = d17; + BUSRQ[18] = d18; + } + + /// + /// Optimization method to set MEMRQ + /// + private void PopulateMEMRQ(ushort d0 = 0, ushort d1 = 0, ushort d2 = 0, ushort d3 = 0, ushort d4 = 0, ushort d5 = 0, ushort d6 = 0, ushort d7 = 0, ushort d8 = 0, + ushort d9 = 0, ushort d10 = 0, ushort d11 = 0, ushort d12 = 0, ushort d13 = 0, ushort d14 = 0, ushort d15 = 0, ushort d16 = 0, ushort d17 = 0, ushort d18 = 0) + { + MEMRQ[0] = d0; MEMRQ[1] = d1; MEMRQ[2] = d2; + MEMRQ[3] = d3; MEMRQ[4] = d4; MEMRQ[5] = d5; + MEMRQ[6] = d6; MEMRQ[7] = d7; MEMRQ[8] = d8; + MEMRQ[9] = d9; MEMRQ[10] = d10; MEMRQ[11] = d11; + MEMRQ[12] = d12; MEMRQ[13] = d13; MEMRQ[14] = d14; + MEMRQ[15] = d15; MEMRQ[16] = d16; MEMRQ[17] = d17; + MEMRQ[18] = d18; + } + + /// + /// Optimization method to set cur_instr + /// + private void PopulateCURINSTR(ushort d0 = 0, ushort d1 = 0, ushort d2 = 0, ushort d3 = 0, ushort d4 = 0, ushort d5 = 0, ushort d6 = 0, ushort d7 = 0, ushort d8 = 0, + ushort d9 = 0, ushort d10 = 0, ushort d11 = 0, ushort d12 = 0, ushort d13 = 0, ushort d14 = 0, ushort d15 = 0, ushort d16 = 0, ushort d17 = 0, ushort d18 = 0, + ushort d19 = 0, ushort d20 = 0, ushort d21 = 0, ushort d22 = 0, ushort d23 = 0, ushort d24 = 0, ushort d25 = 0, ushort d26 = 0, ushort d27 = 0, ushort d28 = 0, + ushort d29 = 0, ushort d30 = 0, ushort d31 = 0, ushort d32 = 0, ushort d33 = 0, ushort d34 = 0, ushort d35 = 0, ushort d36 = 0, ushort d37 = 0) + { + cur_instr[0] = d0; cur_instr[1] = d1; cur_instr[2] = d2; + cur_instr[3] = d3; cur_instr[4] = d4; cur_instr[5] = d5; + cur_instr[6] = d6; cur_instr[7] = d7; cur_instr[8] = d8; + cur_instr[9] = d9; cur_instr[10] = d10; cur_instr[11] = d11; + cur_instr[12] = d12; cur_instr[13] = d13; cur_instr[14] = d14; + cur_instr[15] = d15; cur_instr[16] = d16; cur_instr[17] = d17; + cur_instr[18] = d18; cur_instr[19] = d19; cur_instr[20] = d20; + cur_instr[21] = d21; cur_instr[22] = d22; cur_instr[23] = d23; + cur_instr[24] = d24; cur_instr[25] = d25; cur_instr[26] = d26; + cur_instr[27] = d27; cur_instr[28] = d28; cur_instr[29] = d29; + cur_instr[30] = d30; cur_instr[31] = d31; cur_instr[32] = d32; + cur_instr[33] = d33; cur_instr[34] = d34; cur_instr[35] = d35; + cur_instr[36] = d36; cur_instr[37] = d37; + } + // State Save/Load public void SyncState(Serializer ser) { - ser.BeginSection("Z80A"); - ser.Sync("Regs", ref Regs, false); + ser.BeginSection(nameof(Z80A)); + ser.Sync(nameof(Regs), ref Regs, false); ser.Sync("NMI", ref nonMaskableInterrupt); ser.Sync("NMIPending", ref nonMaskableInterruptPending); ser.Sync("IM", ref interruptMode); ser.Sync("IFF1", ref iff1); ser.Sync("IFF2", ref iff2); ser.Sync("Halted", ref halted); - ser.Sync("I_skip", ref I_skip); + ser.Sync(nameof(I_skip), ref I_skip); ser.Sync("ExecutedCycles", ref TotalExecutedCycles); - ser.Sync("EI_pending", ref EI_pending); + ser.Sync(nameof(EI_pending), ref EI_pending); - ser.Sync("instr_pntr", ref instr_pntr); - ser.Sync("bus_pntr", ref bus_pntr); - ser.Sync("mem_pntr", ref mem_pntr); - ser.Sync("irq_pntr", ref irq_pntr); - ser.Sync("cur_instr", ref cur_instr, false); - ser.Sync("BUSRQ", ref BUSRQ, false); - ser.Sync("IRQS", ref IRQS, false); - ser.Sync("MEMRQ", ref MEMRQ, false); - ser.Sync("opcode", ref opcode); - ser.Sync("FlagI", ref FlagI); - ser.Sync("FlagW", ref FlagW); + ser.Sync(nameof(instr_pntr), ref instr_pntr); + ser.Sync(nameof(bus_pntr), ref bus_pntr); + ser.Sync(nameof(mem_pntr), ref mem_pntr); + ser.Sync(nameof(irq_pntr), ref irq_pntr); + ser.Sync(nameof(cur_instr), ref cur_instr, false); + ser.Sync(nameof(BUSRQ), ref BUSRQ, false); + ser.Sync(nameof(IRQS), ref IRQS); + ser.Sync(nameof(MEMRQ), ref MEMRQ, false); + ser.Sync(nameof(opcode), ref opcode); + ser.Sync(nameof(FlagI), ref FlagI); + ser.Sync(nameof(FlagW), ref FlagW); - ser.Sync("NO Preifx", ref NO_prefix); - ser.Sync("CB Preifx", ref CB_prefix); - ser.Sync("IX_prefix", ref IX_prefix); - ser.Sync("IY_prefix", ref IY_prefix); - ser.Sync("IXCB_prefix", ref IXCB_prefix); - ser.Sync("IYCB_prefix", ref IYCB_prefix); - ser.Sync("EXTD_prefix", ref EXTD_prefix); - ser.Sync("PRE_SRC", ref PRE_SRC); + ser.Sync(nameof(NO_prefix), ref NO_prefix); + ser.Sync(nameof(CB_prefix), ref CB_prefix); + ser.Sync(nameof(IX_prefix), ref IX_prefix); + ser.Sync(nameof(IY_prefix), ref IY_prefix); + ser.Sync(nameof(IXCB_prefix), ref IXCB_prefix); + ser.Sync(nameof(IYCB_prefix), ref IYCB_prefix); + ser.Sync(nameof(EXTD_prefix), ref EXTD_prefix); + ser.Sync(nameof(PRE_SRC), ref PRE_SRC); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs index 622664bcc7..ba1f2efde3 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Calculators public ControllerDefinition ControllerDefinition => TI83Controller; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { _controller = controller; _lagged = true; @@ -59,6 +59,8 @@ namespace BizHawk.Emulation.Cores.Calculators } _isLag = _lagged; + + return true; } public int Frame diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IStatable.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IStatable.cs index d2bd9192ca..9c18bcbf70 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IStatable.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IStatable.cs @@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Calculators } _cpu.SyncState(ser); - ser.BeginSection("TI83"); + ser.BeginSection(nameof(TI83)); ser.Sync("RAM", ref _ram, false); ser.Sync("romPageLow3Bits", ref _romPageLow3Bits); ser.Sync("romPageHighBit", ref _romPageHighBit); @@ -69,14 +69,14 @@ namespace BizHawk.Emulation.Cores.Calculators ser.Sync("Frame", ref _frame); ser.Sync("LagCount", ref _lagCount); ser.Sync("IsLag", ref _isLag); - ser.Sync("ON_key_int", ref ON_key_int); - ser.Sync("ON_key_int_EN", ref ON_key_int_EN); - ser.Sync("TIM_1_int", ref TIM_1_int); - ser.Sync("TIM_1_int_EN", ref TIM_1_int_EN); - ser.Sync("TIM_frq", ref TIM_frq); - ser.Sync("TIM_mult", ref TIM_mult); - ser.Sync("TIM_count", ref TIM_count); - ser.Sync("TIM_hit", ref TIM_hit); + ser.Sync(nameof(ON_key_int), ref ON_key_int); + ser.Sync(nameof(ON_key_int_EN), ref ON_key_int_EN); + ser.Sync(nameof(TIM_1_int), ref TIM_1_int); + ser.Sync(nameof(TIM_1_int_EN), ref TIM_1_int_EN); + ser.Sync(nameof(TIM_frq), ref TIM_frq); + ser.Sync(nameof(TIM_mult), ref TIM_mult); + ser.Sync(nameof(TIM_count), ref TIM_count); + ser.Sync(nameof(TIM_hit), ref TIM_hit); ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs index 23a2bfb521..bb7fe9b5f3 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public ControllerDefinition ControllerDefinition { get; set; } - public void FrameAdvance(IController controller, bool render, bool renderSound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { _controller = controller; @@ -42,6 +42,8 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { _lagCount++; } + + return true; } public int Frame diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.ISettable.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.ISettable.cs index bea48eedea..d6960d93e0 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.ISettable.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.ISettable.cs @@ -238,7 +238,6 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // output the data splitting and tabbing as neccessary var arr = d.Value.Split(' '); - int cnt = 0; List builder = new List(); string working = ""; diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IStatable.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IStatable.cs index 910e618a17..7f006c8f23 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IStatable.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IStatable.cs @@ -57,10 +57,10 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC if (ser.IsWriter) { - ser.SyncEnum("_machineType", ref _machineType); + ser.SyncEnum(nameof(_machineType), ref _machineType); _cpu.SyncState(ser); - ser.BeginSection("AmstradCPC"); + ser.BeginSection(nameof(AmstradCPC)); _machine.SyncState(ser); ser.Sync("Frame", ref _machine.FrameCount); ser.Sync("LagCount", ref _lagCount); @@ -71,7 +71,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC if (ser.IsReader) { var tmpM = _machineType; - ser.SyncEnum("_machineType", ref _machineType); + ser.SyncEnum(nameof(_machineType), ref _machineType); if (tmpM != _machineType && _machineType.ToString() != "72") { string msg = "SAVESTATE FAILED TO LOAD!!\n\n"; @@ -86,7 +86,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC else { _cpu.SyncState(ser); - ser.BeginSection("AmstradCPC"); + ser.BeginSection(nameof(AmstradCPC)); _machine.SyncState(ser); ser.Sync("Frame", ref _machine.FrameCount); ser.Sync("LagCount", ref _lagCount); diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs index 7bc4c9c247..d9bb008f20 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs @@ -824,15 +824,15 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// public void SyncState(Serializer ser) { - ser.BeginSection("DatacorderDevice"); - ser.Sync("counter", ref counter); - ser.Sync("_currentDataBlockIndex", ref _currentDataBlockIndex); - ser.Sync("_position", ref _position); - ser.Sync("_tapeIsPlaying", ref _tapeIsPlaying); - ser.Sync("_lastCycle", ref _lastCycle); - ser.Sync("_waitEdge", ref _waitEdge); - ser.Sync("currentState", ref currentState); - ser.Sync("TapeMotor", ref tapeMotor); + ser.BeginSection(nameof(DatacorderDevice)); + ser.Sync(nameof(counter), ref counter); + ser.Sync(nameof(_currentDataBlockIndex), ref _currentDataBlockIndex); + ser.Sync(nameof(_position), ref _position); + ser.Sync(nameof(_tapeIsPlaying), ref _tapeIsPlaying); + ser.Sync(nameof(_lastCycle), ref _lastCycle); + ser.Sync(nameof(_waitEdge), ref _waitEdge); + ser.Sync(nameof(currentState), ref currentState); + ser.Sync(nameof(tapeMotor), ref tapeMotor); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.Definitions.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.Definitions.cs index ff1bacb223..950cb07d7b 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.Definitions.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.Definitions.cs @@ -806,15 +806,15 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { ser.BeginSection("ActiveCmdParams"); - ser.Sync("UnitSelect", ref UnitSelect); - ser.Sync("Side", ref Side); - ser.Sync("Cylinder", ref Cylinder); - ser.Sync("Head", ref Head); - ser.Sync("Sector", ref Sector); - ser.Sync("SectorSize", ref SectorSize); - ser.Sync("EOT", ref EOT); - ser.Sync("Gap3Length", ref Gap3Length); - ser.Sync("DTL", ref DTL); + ser.Sync(nameof(UnitSelect), ref UnitSelect); + ser.Sync(nameof(Side), ref Side); + ser.Sync(nameof(Cylinder), ref Cylinder); + ser.Sync(nameof(Head), ref Head); + ser.Sync(nameof(Sector), ref Sector); + ser.Sync(nameof(SectorSize), ref SectorSize); + ser.Sync(nameof(EOT), ref EOT); + ser.Sync(nameof(Gap3Length), ref Gap3Length); + ser.Sync(nameof(DTL), ref DTL); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs index 54510a10fe..96815e78f3 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs @@ -394,6 +394,8 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC sectorSize = 0x80 << ActiveCommandParams.SectorSize; } + var mtc = maxTransferCap; + // get the current track var track = ActiveDrive.Disk.DiskTracks.Where(a => a.TrackNumber == ActiveDrive.CurrentTrackID).FirstOrDefault(); @@ -655,6 +657,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC int buffPos = 0; int sectorSize = 0; int maxTransferCap = 0; + if (maxTransferCap > 0) { } // calculate requested size of data required if (ActiveCommandParams.SectorSize == 0) @@ -967,6 +970,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC int buffPos = 0; int sectorSize = 0; int maxTransferCap = 0; + if (maxTransferCap > 0) { } // calculate requested size of data required if (ActiveCommandParams.SectorSize == 0) @@ -1031,7 +1035,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC break; } - FloppyDisk.Sector sector = null; + //FloppyDisk.Sector sector = null; ActiveDrive.SectorIndex = 0; int secCount = 0; @@ -1371,7 +1375,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // get the first sector var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - int secIndex = 0; + //int secIndex = 0; for (int s = 0; s < track.Sectors.Length; s++) { if (track.Sectors[s].SectorID == endSecID) @@ -1422,7 +1426,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC byte endSecID = ActiveCommandParams.EOT; bool lastSec = false; var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - int secIndex = 0; + //int secIndex = 0; for (int s = 0; s < track.Sectors.Length; s++) { @@ -1664,7 +1668,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // get the first sector var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - int secIndex = 0; + //int secIndex = 0; for (int s = 0; s < track.Sectors.Length; s++) { if (track.Sectors[s].SectorID == endSecID) @@ -1715,7 +1719,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC byte endSecID = ActiveCommandParams.EOT; bool lastSec = false; var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - int secIndex = 0; + //int secIndex = 0; for (int s = 0; s < track.Sectors.Length; s++) { @@ -2397,18 +2401,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC break; } - //if (!CheckTiming()) - //{ - // UnSetBit(MSR_EXM, ref StatusMain); - //} - return StatusMain; } - private int testCount = 0; + /// /// Handles CPU reading from the data register /// - /// private byte ReadDataRegister() { // default return value diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs index ef04817a68..487048bbc6 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs @@ -861,28 +861,28 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public void SyncState(Serializer ser) { - ser.Sync("ID", ref ID); - ser.Sync("FLAG_WRITEPROTECT", ref FLAG_WRITEPROTECT); - //ser.Sync("FLAG_DISKCHANGED", ref FLAG_DISKCHANGED); - //ser.Sync("FLAG_RECALIBRATING", ref FLAG_RECALIBRATING); - //ser.Sync("FLAG_SEEK_INTERRUPT", ref FLAG_SEEK_INTERRUPT); - //ser.Sync("IntStatus", ref IntStatus); - //ser.Sync("ST0", ref ST0); - //ser.Sync("RecalibrationCounter", ref RecalibrationCounter); - ser.Sync("SeekCounter", ref SeekCounter); - ser.Sync("SeekStatus", ref SeekStatus); - ser.Sync("SeekAge", ref SeekAge); - ser.Sync("CurrentSide", ref CurrentSide); - //ser.Sync("CurrentTrack", ref CurrentTrack); - ser.Sync("TrackIndex", ref TrackIndex); - ser.Sync("SeekingTrack", ref SeekingTrack); - //ser.Sync("CurrentSector", ref CurrentSector); - ser.Sync("SectorIndex", ref SectorIndex); - //ser.Sync("RAngles", ref RAngles); - //ser.Sync("DataPointer", ref DataPointer); - //ser.SyncEnum("CurrentState", ref CurrentState); - //ser.SyncEnum("SeekState", ref SeekState); - //ser.SyncEnum("SeekIntState", ref SeekIntState); + ser.Sync(nameof(ID), ref ID); + ser.Sync(nameof(FLAG_WRITEPROTECT), ref FLAG_WRITEPROTECT); + //ser.Sync(nameof(FLAG_DISKCHANGED), ref FLAG_DISKCHANGED); + //ser.Sync(nameof(FLAG_RECALIBRATING), ref FLAG_RECALIBRATING); + //ser.Sync(nameof(FLAG_SEEK_INTERRUPT), ref FLAG_SEEK_INTERRUPT); + //ser.Sync(nameof(IntStatus), ref IntStatus); + //ser.Sync(nameof(ST0), ref ST0); + //ser.Sync(nameof(RecalibrationCounter), ref RecalibrationCounter); + ser.Sync(nameof(SeekCounter), ref SeekCounter); + ser.Sync(nameof(SeekStatus), ref SeekStatus); + ser.Sync(nameof(SeekAge), ref SeekAge); + ser.Sync(nameof(CurrentSide), ref CurrentSide); + //ser.Sync(nameof(CurrentTrack), ref CurrentTrack); + ser.Sync(nameof(TrackIndex), ref TrackIndex); + ser.Sync(nameof(SeekingTrack), ref SeekingTrack); + //ser.Sync(nameof(CurrentSector), ref CurrentSector); + ser.Sync(nameof(SectorIndex), ref SectorIndex); + //ser.Sync(nameof(RAngles), ref RAngles); + //ser.Sync(nameof(DataPointer), ref DataPointer); + //ser.SyncEnum(nameof(CurrentState), ref CurrentState); + //ser.SyncEnum(nameof(SeekState), ref SeekState); + //ser.SyncEnum(nameof(SeekIntState), ref SeekIntState); } #endregion diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.cs index 43f09fb829..a365a7b796 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.cs @@ -159,7 +159,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC #region FDD - ser.Sync("FDD_FLAG_MOTOR", ref FDD_FLAG_MOTOR); + ser.Sync(nameof(FDD_FLAG_MOTOR), ref FDD_FLAG_MOTOR); for (int i = 0; i < 4; i++) { @@ -168,7 +168,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC ser.EndSection(); } - ser.Sync("DiskDriveIndex", ref _diskDriveIndex); + ser.Sync(nameof(DiskDriveIndex), ref _diskDriveIndex); // set active drive DiskDriveIndex = _diskDriveIndex; @@ -186,55 +186,55 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC #region Controller state - ser.Sync("DriveLight", ref DriveLight); - ser.SyncEnum("ActivePhase", ref ActivePhase); - //ser.SyncEnum("ActiveDirection", ref ActiveDirection); - ser.SyncEnum("ActiveInterrupt", ref ActiveInterrupt); - ser.Sync("CommBuffer", ref CommBuffer, false); - ser.Sync("CommCounter", ref CommCounter); - ser.Sync("ResBuffer", ref ResBuffer, false); - ser.Sync("ExecBuffer", ref ExecBuffer, false); - ser.Sync("ExecCounter", ref ExecCounter); - ser.Sync("ExecLength", ref ExecLength); - ser.Sync("InterruptResultBuffer", ref InterruptResultBuffer, false); - ser.Sync("ResCounter", ref ResCounter); - ser.Sync("ResLength", ref ResLength); - ser.Sync("LastSectorDataWriteByte", ref LastSectorDataWriteByte); - ser.Sync("LastSectorDataReadByte", ref LastSectorDataReadByte); - ser.Sync("LastByteReceived", ref LastByteReceived); + ser.Sync(nameof(DriveLight), ref DriveLight); + ser.SyncEnum(nameof(ActivePhase), ref ActivePhase); + //ser.SyncEnum(nameof(ActiveDirection), ref ActiveDirection); + ser.SyncEnum(nameof(ActiveInterrupt), ref ActiveInterrupt); + ser.Sync(nameof(CommBuffer), ref CommBuffer, false); + ser.Sync(nameof(CommCounter), ref CommCounter); + ser.Sync(nameof(ResBuffer), ref ResBuffer, false); + ser.Sync(nameof(ExecBuffer), ref ExecBuffer, false); + ser.Sync(nameof(ExecCounter), ref ExecCounter); + ser.Sync(nameof(ExecLength), ref ExecLength); + ser.Sync(nameof(InterruptResultBuffer), ref InterruptResultBuffer, false); + ser.Sync(nameof(ResCounter), ref ResCounter); + ser.Sync(nameof(ResLength), ref ResLength); + ser.Sync(nameof(LastSectorDataWriteByte), ref LastSectorDataWriteByte); + ser.Sync(nameof(LastSectorDataReadByte), ref LastSectorDataReadByte); + ser.Sync(nameof(LastByteReceived), ref LastByteReceived); - ser.Sync("_cmdIndex", ref _cmdIndex); + ser.Sync(nameof(_cmdIndex), ref _cmdIndex); // resync the ActiveCommand CMDIndex = _cmdIndex; ActiveCommandParams.SyncState(ser); - ser.Sync("IndexPulseCounter", ref IndexPulseCounter); - //ser.SyncEnum("_activeStatus", ref _activeStatus); - //ser.SyncEnum("_statusRaised", ref _statusRaised); + ser.Sync(nameof(IndexPulseCounter), ref IndexPulseCounter); + //ser.SyncEnum(nameof(_activeStatus), ref _activeStatus); + //ser.SyncEnum(nameof(_statusRaised), ref _statusRaised); - ser.Sync("CMD_FLAG_MT", ref CMD_FLAG_MT); - ser.Sync("CMD_FLAG_MF", ref CMD_FLAG_MF); - ser.Sync("CMD_FLAG_SK", ref CMD_FLAG_SK); - ser.Sync("SRT", ref SRT); - ser.Sync("HUT", ref HUT); - ser.Sync("HLT", ref HLT); - ser.Sync("ND", ref ND); - ser.Sync("SRT_Counter", ref SRT_Counter); - ser.Sync("HUT_Counter", ref HUT_Counter); - ser.Sync("HLT_Counter", ref HLT_Counter); + ser.Sync(nameof(CMD_FLAG_MT), ref CMD_FLAG_MT); + ser.Sync(nameof(CMD_FLAG_MF), ref CMD_FLAG_MF); + ser.Sync(nameof(CMD_FLAG_SK), ref CMD_FLAG_SK); + ser.Sync(nameof(SRT), ref SRT); + ser.Sync(nameof(HUT), ref HUT); + ser.Sync(nameof(HLT), ref HLT); + ser.Sync(nameof(ND), ref ND); + ser.Sync(nameof(SRT_Counter), ref SRT_Counter); + ser.Sync(nameof(HUT_Counter), ref HUT_Counter); + ser.Sync(nameof(HLT_Counter), ref HLT_Counter); - ser.Sync("SectorDelayCounter", ref SectorDelayCounter); - ser.Sync("SectorID", ref SectorID); + ser.Sync(nameof(SectorDelayCounter), ref SectorDelayCounter); + ser.Sync(nameof(SectorID), ref SectorID); #endregion #region Timing - ser.Sync("LastCPUCycle", ref LastCPUCycle); - ser.Sync("StatusDelay", ref StatusDelay); - ser.Sync("TickCounter", ref TickCounter); - ser.Sync("DriveCycleCounter", ref DriveCycleCounter); + ser.Sync(nameof(LastCPUCycle), ref LastCPUCycle); + ser.Sync(nameof(StatusDelay), ref StatusDelay); + ser.Sync(nameof(TickCounter), ref TickCounter); + ser.Sync(nameof(DriveCycleCounter), ref DriveCycleCounter); #endregion diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs index 659ca850c5..56706302c3 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs @@ -1103,7 +1103,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC ScreenLines.Clear(); return ScreenBuffer; - + /* switch (borderType) { // crop to 768x272 (544) @@ -1139,18 +1139,19 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } return croppedBuffer; */ + /* + var slWidth = BufferWidth; + return ScreenBuffer; - var slWidth = BufferWidth; - return ScreenBuffer; + break; - break; - - } - return ScreenBuffer; - } + } + */ + //return ScreenBuffer; + } - public void SetupScreenSize() + public void SetupScreenSize() { SysBufferWidth = 800; SysBufferHeight = 600; @@ -1261,34 +1262,34 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public void SyncState(Serializer ser) { ser.BeginSection("GateArray"); - ser.SyncEnum("ChipType", ref ChipType); - ser.Sync("_PENR", ref _PENR); - ser.Sync("_INKR", ref _INKR); - ser.Sync("_RMR", ref _RMR); - ser.Sync("_RAMR", ref _RAMR); - ser.Sync("ColourRegisters", ref ColourRegisters, false); - ser.Sync("CurrentPen", ref CurrentPen); - ser.Sync("ClockCounter", ref ClockCounter); - ser.Sync("FrameClock", ref FrameClock); - ser.Sync("FrameEnd", ref FrameEnd); - ser.Sync("WaitLine", ref WaitLine); - ser.Sync("_interruptCounter", ref _interruptCounter); - ser.Sync("VSYNCDelay", ref VSYNCDelay); - ser.Sync("ScreenMode", ref ScreenMode); - ser.Sync("HSYNC", ref HSYNC); - //ser.Sync("HSYNC_falling", ref HSYNC_falling); - ser.Sync("HSYNC_counter", ref HSYNC_counter); - ser.Sync("VSYNC", ref VSYNC); - ser.Sync("InterruptRaised", ref InterruptRaised); - ser.Sync("InterruptHoldCounter", ref InterruptHoldCounter); - ser.Sync("_MA", ref _MA); - ser.Sync("IsNewFrame", ref IsNewFrame); - ser.Sync("IsNewLine", ref IsNewLine); - ser.Sync("HCC", ref HCC); - ser.Sync("VLC", ref VLC); - ser.Sync("VideoByte1", ref VideoByte1); - ser.Sync("VideoByte2", ref VideoByte2); - ser.Sync("NextVidRamLine", ref NextVidRamLine, false); + ser.SyncEnum(nameof(ChipType), ref ChipType); + ser.Sync(nameof(_PENR), ref _PENR); + ser.Sync(nameof(_INKR), ref _INKR); + ser.Sync(nameof(_RMR), ref _RMR); + ser.Sync(nameof(_RAMR), ref _RAMR); + ser.Sync(nameof(ColourRegisters), ref ColourRegisters, false); + ser.Sync(nameof(CurrentPen), ref CurrentPen); + ser.Sync(nameof(ClockCounter), ref ClockCounter); + ser.Sync(nameof(FrameClock), ref FrameClock); + ser.Sync(nameof(FrameEnd), ref FrameEnd); + ser.Sync(nameof(WaitLine), ref WaitLine); + ser.Sync(nameof(_interruptCounter), ref _interruptCounter); + ser.Sync(nameof(VSYNCDelay), ref VSYNCDelay); + ser.Sync(nameof(ScreenMode), ref ScreenMode); + ser.Sync(nameof(HSYNC), ref HSYNC); + //ser.Sync(nameof(HSYNC_falling), ref HSYNC_falling); + ser.Sync(nameof(HSYNC_counter), ref HSYNC_counter); + ser.Sync(nameof(VSYNC), ref VSYNC); + ser.Sync(nameof(InterruptRaised), ref InterruptRaised); + ser.Sync(nameof(InterruptHoldCounter), ref InterruptHoldCounter); + ser.Sync(nameof(_MA), ref _MA); + ser.Sync(nameof(IsNewFrame), ref IsNewFrame); + ser.Sync(nameof(IsNewLine), ref IsNewLine); + ser.Sync(nameof(HCC), ref HCC); + ser.Sync(nameof(VLC), ref VLC); + ser.Sync(nameof(VideoByte1), ref VideoByte1); + ser.Sync(nameof(VideoByte2), ref VideoByte2); + ser.Sync(nameof(NextVidRamLine), ref NextVidRamLine, false); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRCT_6845.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRCT_6845.cs index 8176b7db14..b68b4e8d21 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRCT_6845.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRCT_6845.cs @@ -1182,24 +1182,24 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public void SyncState(Serializer ser) { ser.BeginSection("CRTC"); - ser.SyncEnum("ChipType", ref ChipType); - ser.Sync("HSYNC", ref HSYNC); - ser.Sync("VSYNC", ref VSYNC); - ser.Sync("DISPTMG", ref DISPTMG); - ser.Sync("MA", ref MA); - ser.Sync("CurrentByteAddress", ref CurrentByteAddress); - ser.Sync("ByteCounter", ref ByteCounter); - ser.Sync("Regs", ref Regs, false); - ser.Sync("SelectedRegister", ref SelectedRegister); - ser.Sync("HCC", ref HCC); - ser.Sync("VCC", ref VCC); - ser.Sync("VLC", ref VLC); - ser.Sync("CycleCounter", ref CycleCounter); - ser.Sync("EndOfScreen", ref EndOfScreen); - ser.Sync("HSYNCWidth", ref HSYNCWidth); - ser.Sync("HSYNCCounter", ref HSYNCCounter); - ser.Sync("VSYNCWidth", ref VSYNCWidth); - ser.Sync("VSYNCCounter", ref VSYNCCounter); + ser.SyncEnum(nameof(ChipType), ref ChipType); + ser.Sync(nameof(HSYNC), ref HSYNC); + ser.Sync(nameof(VSYNC), ref VSYNC); + ser.Sync(nameof(DISPTMG), ref DISPTMG); + ser.Sync(nameof(MA), ref MA); + ser.Sync(nameof(CurrentByteAddress), ref CurrentByteAddress); + ser.Sync(nameof(ByteCounter), ref ByteCounter); + ser.Sync(nameof(Regs), ref Regs, false); + ser.Sync(nameof(SelectedRegister), ref SelectedRegister); + ser.Sync(nameof(HCC), ref HCC); + ser.Sync(nameof(VCC), ref VCC); + ser.Sync(nameof(VLC), ref VLC); + ser.Sync(nameof(CycleCounter), ref CycleCounter); + ser.Sync(nameof(EndOfScreen), ref EndOfScreen); + ser.Sync(nameof(HSYNCWidth), ref HSYNCWidth); + ser.Sync(nameof(HSYNCCounter), ref HSYNCCounter); + ser.Sync(nameof(VSYNCWidth), ref VSYNCWidth); + ser.Sync(nameof(VSYNCCounter), ref VSYNCCounter); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTC6845.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTC6845.cs index 6e2fa4c2cf..6c9c4c50cc 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTC6845.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTC6845.cs @@ -2326,44 +2326,39 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public void SyncState(Serializer ser) { ser.BeginSection("CRCT"); - ser.SyncEnum("ChipType", ref ChipType); - ser.Sync("_VSYNC", ref _VSYNC); - ser.Sync("_HSYNC", ref _HSYNC); - ser.Sync("_DISPTMG", ref _DISPTMG); - ser.Sync("_CUDISP", ref _CUDISP); - ser.Sync("_CLK", ref _CLK); - ser.Sync("_RESET", ref _RESET); - ser.Sync("_LPSTB", ref _LPSTB); - ser.Sync("AddressRegister", ref AddressRegister); - ser.Sync("Register", ref Register, false); - ser.Sync("StatusRegister", ref StatusRegister); - ser.Sync("_CharacterCTR", ref _CharacterCTR); - ser.Sync("_HorizontalSyncWidthCTR", ref _HorizontalSyncWidthCTR); - ser.Sync("_LineCTR", ref _LineCTR); - ser.Sync("_RasterCTR", ref _RasterCTR); - ser.Sync("StartAddressLatch)", ref StartAddressLatch); - //ser.Sync("VDisplay", ref VDisplay); - //ser.Sync("HDisplay", ref HDisplay); - ser.Sync("RowSelects", ref RowSelects); - ser.Sync("DISPTMG_Delay_Counter", ref DISPTMG_Delay_Counter); - ser.Sync("CUDISP_Delay_Counter", ref CUDISP_Delay_Counter); - ser.Sync("AsicStatusRegister1", ref AsicStatusRegister1); - ser.Sync("AsicStatusRegister2", ref AsicStatusRegister2); - ser.Sync("LAG_Counter", ref LAG_Counter); - ser.Sync("LAG_Counter_Latch", ref LAG_Counter_Latch); - ser.Sync("LAG_Counter_RowLatch", ref LAG_Counter_RowLatch); - ser.Sync("s_VS", ref s_VS); - ser.Sync("s_HDISP", ref s_VS); - ser.Sync("s_VDISP", ref s_VDISP); - ser.Sync("s_HSYNC", ref s_HSYNC); - ser.Sync("CUR_Field_Counter", ref CUR_Field_Counter); - //ser.Sync("VS", ref VS); + ser.SyncEnum(nameof(ChipType), ref ChipType); + ser.Sync(nameof(_VSYNC), ref _VSYNC); + ser.Sync(nameof(_HSYNC), ref _HSYNC); + ser.Sync(nameof(_DISPTMG), ref _DISPTMG); + ser.Sync(nameof(_CUDISP), ref _CUDISP); + ser.Sync(nameof(_CLK), ref _CLK); + ser.Sync(nameof(_RESET), ref _RESET); + ser.Sync(nameof(_LPSTB), ref _LPSTB); + ser.Sync(nameof(AddressRegister), ref AddressRegister); + ser.Sync(nameof(Register), ref Register, false); + ser.Sync(nameof(StatusRegister), ref StatusRegister); + ser.Sync(nameof(_CharacterCTR), ref _CharacterCTR); + ser.Sync(nameof(_HorizontalSyncWidthCTR), ref _HorizontalSyncWidthCTR); + ser.Sync(nameof(_LineCTR), ref _LineCTR); + ser.Sync(nameof(_RasterCTR), ref _RasterCTR); + ser.Sync(nameof(StartAddressLatch), ref StartAddressLatch); + //ser.Sync(nameof(VDisplay), ref VDisplay); + //ser.Sync(nameof(HDisplay), ref HDisplay); + ser.Sync(nameof(RowSelects), ref RowSelects); + ser.Sync(nameof(DISPTMG_Delay_Counter), ref DISPTMG_Delay_Counter); + ser.Sync(nameof(CUDISP_Delay_Counter), ref CUDISP_Delay_Counter); + ser.Sync(nameof(AsicStatusRegister1), ref AsicStatusRegister1); + ser.Sync(nameof(AsicStatusRegister2), ref AsicStatusRegister2); + ser.Sync(nameof(LAG_Counter), ref LAG_Counter); + ser.Sync(nameof(LAG_Counter_Latch), ref LAG_Counter_Latch); + ser.Sync(nameof(LAG_Counter_RowLatch), ref LAG_Counter_RowLatch); + ser.Sync(nameof(s_VS), ref s_VS); + ser.Sync(nameof(s_HDISP), ref s_VS); + ser.Sync(nameof(s_VDISP), ref s_VDISP); + ser.Sync(nameof(s_HSYNC), ref s_HSYNC); + ser.Sync(nameof(CUR_Field_Counter), ref CUR_Field_Counter); + //ser.Sync(nameof(VS), ref VS); ser.EndSection(); - - /* - * int ; - int ; - * */ } #endregion diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTDevice.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTDevice.cs index 5f318c47be..b9d83a4723 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTDevice.cs @@ -256,8 +256,8 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC ser.Sync("BufferHeight", ref _bufferHeight); ser.Sync("VirtualHeight", ref _virtualHeight); ser.Sync("VirtualWidth", ref _virtualWidth); - ser.Sync("ScreenBuffer", ref ScreenBuffer, false); - ser.Sync("ScanlineCounter", ref ScanlineCounter); + ser.Sync(nameof(ScreenBuffer), ref ScreenBuffer, false); + ser.Sync(nameof(ScanlineCounter), ref ScanlineCounter); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/PPI/PPI_8255.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/PPI/PPI_8255.cs index 921bf2a332..0f6599c4dd 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/PPI/PPI_8255.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/PPI/PPI_8255.cs @@ -455,7 +455,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public void SyncState(Serializer ser) { ser.BeginSection("PPI"); - ser.Sync("Regs", ref Regs, false); + ser.Sync(nameof(Regs), ref Regs, false); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/SoundOutput/AY38912.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/SoundOutput/AY38912.cs index 240acb9a2c..97c4a964db 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/SoundOutput/AY38912.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/SoundOutput/AY38912.cs @@ -28,8 +28,8 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private short[] _audioBuffer; private int _audioBufferIndex; private int _lastStateRendered; - private int _clockCyclesPerFrame; - private int _cyclesPerSample; + //private int _clockCyclesPerFrame; + //private int _cyclesPerSample; #endregion @@ -827,50 +827,50 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { ser.BeginSection("PSG-AY"); - ser.Sync("ActiveFunction", ref ActiveFunction); + ser.Sync(nameof(ActiveFunction), ref ActiveFunction); - ser.Sync("_tStatesPerFrame", ref _tStatesPerFrame); - ser.Sync("_sampleRate", ref _sampleRate); - ser.Sync("_samplesPerFrame", ref _samplesPerFrame); - //ser.Sync("_tStatesPerSample", ref _tStatesPerSample); - ser.Sync("_audioBufferIndex", ref _audioBufferIndex); - ser.Sync("_audioBuffer", ref _audioBuffer, false); - ser.Sync("PortAInput", ref PortAInput); - ser.Sync("PortBInput", ref PortBInput); + ser.Sync(nameof(_tStatesPerFrame), ref _tStatesPerFrame); + ser.Sync(nameof(_sampleRate), ref _sampleRate); + ser.Sync(nameof(_samplesPerFrame), ref _samplesPerFrame); + //ser.Sync(nameof(_tStatesPerSample), ref _tStatesPerSample); + ser.Sync(nameof(_audioBufferIndex), ref _audioBufferIndex); + ser.Sync(nameof(_audioBuffer), ref _audioBuffer, false); + ser.Sync(nameof(PortAInput), ref PortAInput); + ser.Sync(nameof(PortBInput), ref PortBInput); - ser.Sync("_registers", ref _registers, false); - ser.Sync("_activeRegister", ref _activeRegister); - ser.Sync("_bitA", ref _bitA); - ser.Sync("_bitB", ref _bitB); - ser.Sync("_bitC", ref _bitC); - ser.Sync("_eState", ref _eState); - ser.Sync("_eDirection", ref _eDirection); - ser.Sync("_noiseSeed", ref _noiseSeed); - ser.Sync("_bit0", ref _bit0); - ser.Sync("_bit1", ref _bit1); - ser.Sync("_bit2", ref _bit2); - ser.Sync("_bit3", ref _bit3); - ser.Sync("_bit4", ref _bit4); - ser.Sync("_bit5", ref _bit5); - ser.Sync("_bitN", ref _bitN); - ser.Sync("_eMaskA", ref _eMaskA); - ser.Sync("_eMaskB", ref _eMaskB); - ser.Sync("_eMaskC", ref _eMaskC); - ser.Sync("_vA", ref _vA); - ser.Sync("_vB", ref _vB); - ser.Sync("_vC", ref _vC); - ser.Sync("_countA", ref _countA); - ser.Sync("_countB", ref _countB); - ser.Sync("_countC", ref _countC); - ser.Sync("_countE", ref _countE); - ser.Sync("_countN", ref _countN); - ser.Sync("_dividerA", ref _dividerA); - ser.Sync("_dividerB", ref _dividerB); - ser.Sync("_dividerC", ref _dividerC); - ser.Sync("_dividerE", ref _dividerE); - ser.Sync("_dividerN", ref _dividerN); - ser.SyncEnum("_currentPanTab", ref _currentPanTab); - ser.Sync("_volume", ref nullDump); + ser.Sync(nameof(_registers), ref _registers, false); + ser.Sync(nameof(_activeRegister), ref _activeRegister); + ser.Sync(nameof(_bitA), ref _bitA); + ser.Sync(nameof(_bitB), ref _bitB); + ser.Sync(nameof(_bitC), ref _bitC); + ser.Sync(nameof(_eState), ref _eState); + ser.Sync(nameof(_eDirection), ref _eDirection); + ser.Sync(nameof(_noiseSeed), ref _noiseSeed); + ser.Sync(nameof(_bit0), ref _bit0); + ser.Sync(nameof(_bit1), ref _bit1); + ser.Sync(nameof(_bit2), ref _bit2); + ser.Sync(nameof(_bit3), ref _bit3); + ser.Sync(nameof(_bit4), ref _bit4); + ser.Sync(nameof(_bit5), ref _bit5); + ser.Sync(nameof(_bitN), ref _bitN); + ser.Sync(nameof(_eMaskA), ref _eMaskA); + ser.Sync(nameof(_eMaskB), ref _eMaskB); + ser.Sync(nameof(_eMaskC), ref _eMaskC); + ser.Sync(nameof(_vA), ref _vA); + ser.Sync(nameof(_vB), ref _vB); + ser.Sync(nameof(_vC), ref _vC); + ser.Sync(nameof(_countA), ref _countA); + ser.Sync(nameof(_countB), ref _countB); + ser.Sync(nameof(_countC), ref _countC); + ser.Sync(nameof(_countE), ref _countE); + ser.Sync(nameof(_countN), ref _countN); + ser.Sync(nameof(_dividerA), ref _dividerA); + ser.Sync(nameof(_dividerB), ref _dividerB); + ser.Sync(nameof(_dividerC), ref _dividerC); + ser.Sync(nameof(_dividerE), ref _dividerE); + ser.Sync(nameof(_dividerN), ref _dividerN); + ser.SyncEnum(nameof(_currentPanTab), ref _currentPanTab); + ser.Sync(nameof(_volume), ref nullDump); for (int i = 0; i < 6; i++) { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/SoundOutput/Beeper.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/SoundOutput/Beeper.cs index 5f1f96c92e..cd2732bb21 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/SoundOutput/Beeper.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/SoundOutput/Beeper.cs @@ -202,10 +202,10 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public void SyncState(Serializer ser) { ser.BeginSection("Buzzer"); - ser.Sync("_tStatesPerFrame", ref _tStatesPerFrame); - ser.Sync("_sampleRate", ref _sampleRate); - ser.Sync("LastPulse", ref LastPulse); - ser.Sync("LastPulseTState", ref LastPulseTState); + ser.Sync(nameof(_tStatesPerFrame), ref _tStatesPerFrame); + ser.Sync(nameof(_sampleRate), ref _sampleRate); + ser.Sync(nameof(LastPulse), ref LastPulse); + ser.Sync(nameof(LastPulseTState), ref LastPulseTState); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.cs index 0fb5f9a916..a3c87688f2 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.cs @@ -319,29 +319,29 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public void SyncState(Serializer ser) { ser.BeginSection("CPCMachine"); - ser.Sync("FrameCompleted", ref FrameCompleted); - ser.Sync("OverFlow", ref OverFlow); - ser.Sync("FrameCount", ref FrameCount); - ser.Sync("_frameCycles", ref _frameCycles); - ser.Sync("inputRead", ref inputRead); - ser.Sync("LastFrameStartCPUTick", ref LastFrameStartCPUTick); - ser.Sync("ROMLower", ref ROMLower, false); - ser.Sync("ROM0", ref ROM0, false); - ser.Sync("ROM7", ref ROM7, false); - ser.Sync("RAM0", ref RAM0, false); - ser.Sync("RAM1", ref RAM1, false); - ser.Sync("RAM2", ref RAM2, false); - ser.Sync("RAM3", ref RAM3, false); - ser.Sync("RAM4", ref RAM4, false); - ser.Sync("RAM5", ref RAM5, false); - ser.Sync("RAM6", ref RAM6, false); - ser.Sync("RAM7", ref RAM7, false); + ser.Sync(nameof(FrameCompleted), ref FrameCompleted); + ser.Sync(nameof(OverFlow), ref OverFlow); + ser.Sync(nameof(FrameCount), ref FrameCount); + ser.Sync(nameof(_frameCycles), ref _frameCycles); + ser.Sync(nameof(inputRead), ref inputRead); + ser.Sync(nameof(LastFrameStartCPUTick), ref LastFrameStartCPUTick); + ser.Sync(nameof(ROMLower), ref ROMLower, false); + ser.Sync(nameof(ROM0), ref ROM0, false); + ser.Sync(nameof(ROM7), ref ROM7, false); + ser.Sync(nameof(RAM0), ref RAM0, false); + ser.Sync(nameof(RAM1), ref RAM1, false); + ser.Sync(nameof(RAM2), ref RAM2, false); + ser.Sync(nameof(RAM3), ref RAM3, false); + ser.Sync(nameof(RAM4), ref RAM4, false); + ser.Sync(nameof(RAM5), ref RAM5, false); + ser.Sync(nameof(RAM6), ref RAM6, false); + ser.Sync(nameof(RAM7), ref RAM7, false); - ser.Sync("UpperROMPosition", ref UpperROMPosition); - ser.Sync("UpperROMPaged", ref UpperROMPaged); - ser.Sync("LowerROMPaged", ref LowerROMPaged); - ser.Sync("RAMConfig", ref RAMConfig); - ser.Sync("RAM64KBank", ref RAM64KBank); + ser.Sync(nameof(UpperROMPosition), ref UpperROMPosition); + ser.Sync(nameof(UpperROMPaged), ref UpperROMPaged); + ser.Sync(nameof(LowerROMPaged), ref LowerROMPaged); + ser.Sync(nameof(RAMConfig), ref RAMConfig); + ser.Sync(nameof(RAM64KBank), ref RAM64KBank); CRCT.SyncState(ser); //CRT.SyncState(ser); @@ -350,13 +350,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC TapeBuzzer.SyncState(ser); AYDevice.SyncState(ser); - ser.Sync("tapeMediaIndex", ref tapeMediaIndex); + ser.Sync(nameof(tapeMediaIndex), ref tapeMediaIndex); if (ser.IsReader) TapeMediaIndex = tapeMediaIndex; TapeDevice.SyncState(ser); - ser.Sync("diskMediaIndex", ref diskMediaIndex); + ser.Sync(nameof(diskMediaIndex), ref diskMediaIndex); if (ser.IsReader) DiskMediaIndex = diskMediaIndex; diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs index 768a377b67..cfe9fedf05 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs @@ -216,14 +216,14 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private int CurrentPen; private int ScreenMode; private int INTScanlineCnt; - private int VSYNCDelyCnt; + //private int VSYNCDelyCnt; private int[][] Lookup = new int[4][]; - private bool DoModeUpdate; + //private bool DoModeUpdate; - private int LatchedMode; - private int buffPos; + //private int LatchedMode; + //private int buffPos; public bool FrameEnd; @@ -387,7 +387,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC for (int i = 0; i < 17; i++) PenColours[i] = 0; INTScanlineCnt = 0; - VSYNCDelyCnt = 0; + //VSYNCDelyCnt = 0; } #endregion diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCExtendedFloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCExtendedFloppyDisk.cs index 07919dce7a..34be938128 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCExtendedFloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCExtendedFloppyDisk.cs @@ -236,20 +236,20 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { ser.BeginSection("Plus3FloppyDisk"); - ser.Sync("CylinderCount", ref CylinderCount); - ser.Sync("SideCount", ref SideCount); - ser.Sync("BytesPerTrack", ref BytesPerTrack); - ser.Sync("WriteProtected", ref WriteProtected); - ser.SyncEnum("Protection", ref Protection); + ser.Sync(nameof(CylinderCount), ref CylinderCount); + ser.Sync(nameof(SideCount), ref SideCount); + ser.Sync(nameof(BytesPerTrack), ref BytesPerTrack); + ser.Sync(nameof(WriteProtected), ref WriteProtected); + ser.SyncEnum(nameof(Protection), ref Protection); - ser.Sync("DirtyData", ref DirtyData); + ser.Sync(nameof(DirtyData), ref DirtyData); if (DirtyData) { } // sync deterministic track and sector counters - ser.Sync(" _randomCounter", ref _randomCounter); + ser.Sync(nameof( _randomCounter), ref _randomCounter); RandomCounter = _randomCounter; ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCFloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCFloppyDisk.cs index c30415842e..f1f875b95f 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCFloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCFloppyDisk.cs @@ -223,13 +223,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { ser.BeginSection("Plus3FloppyDisk"); - ser.Sync("CylinderCount", ref CylinderCount); - ser.Sync("SideCount", ref SideCount); - ser.Sync("BytesPerTrack", ref BytesPerTrack); - ser.Sync("WriteProtected", ref WriteProtected); - ser.SyncEnum("Protection", ref Protection); + ser.Sync(nameof(CylinderCount), ref CylinderCount); + ser.Sync(nameof(SideCount), ref SideCount); + ser.Sync(nameof(BytesPerTrack), ref BytesPerTrack); + ser.Sync(nameof(WriteProtected), ref WriteProtected); + ser.SyncEnum(nameof(Protection), ref Protection); - ser.Sync("DirtyData", ref DirtyData); + ser.Sync(nameof(DirtyData), ref DirtyData); if (DirtyData) { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs index 304d53d0ab..3361d96126 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs @@ -77,7 +77,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC tb.PauseInMS = db.PauseInMS; double multiplier = (double)4 / (double)3.5; - double cycleScale = ((40 << 16) / 35); + //double cycleScale = ((40 << 16) / 35); double origPeriods = db.DataPeriods.Count(); for (int i = 0; i < origPeriods; i++) @@ -1372,7 +1372,8 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // get text length int strLen = data[_position++]; - string title = "Info: "; + string title = string.Empty; + title = "Info: "; switch (type) { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/TapeDataBlock.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/TapeDataBlock.cs index 40efa71d1e..8b0f9fafbc 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/TapeDataBlock.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/TapeDataBlock.cs @@ -51,6 +51,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC set { _blockData = value; } } + /* /// /// An array of bytearray encoded strings (stored in this format for easy Bizhawk serialization) /// Its basically tape information @@ -74,6 +75,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC return data; } } + */ #region Block Meta Data @@ -170,11 +172,11 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { ser.BeginSection("DataBlock" + blockPosition); - ser.Sync("_blockID", ref _blockID); - //ser.SyncFixedString("_blockDescription", ref _blockDescription, 200); - ser.SyncEnum("_blockType", ref _blockType); - ser.Sync("_blockData", ref _blockData, true); - ser.SyncEnum("_command", ref _command); + ser.Sync(nameof(_blockID), ref _blockID); + //ser.SyncFixedString(nameof(_blockDescription), ref _blockDescription, 200); + ser.SyncEnum(nameof(_blockType), ref _blockType); + ser.Sync(nameof(_blockData), ref _blockData, true); + ser.SyncEnum(nameof(_command), ref _command); int[] tempArray = null; diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs index 8e41c8ba8c..903fc365bd 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs @@ -14,9 +14,11 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII public bool DeterministicEmulation => true; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { FrameAdv(controller, render, rendersound); + + return true; } public void ResetCounters() diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs index c3fa2f9aab..e7b748e46c 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IStatable.cs @@ -41,13 +41,13 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII { // this is much faster than other possibilities for serialization w.WriteStartObject(); - w.WritePropertyName("Frame"); + w.WritePropertyName(nameof(Frame)); w.WriteValue(Frame); - w.WritePropertyName("LagCount"); + w.WritePropertyName(nameof(LagCount)); w.WriteValue(LagCount); - w.WritePropertyName("IsLagFrame"); + w.WritePropertyName(nameof(IsLagFrame)); w.WriteValue(IsLagFrame); - w.WritePropertyName("CurrentDisk"); + w.WritePropertyName(nameof(CurrentDisk)); w.WriteValue(CurrentDisk); w.WritePropertyName("PreviousDiskPressed"); w.WriteValue(_prevPressed); diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs index 358a02fcff..29aea5b261 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IEmulator.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public ControllerDefinition ControllerDefinition => C64ControllerDefinition; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { _board.Controller = controller; @@ -47,6 +47,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 DoCycle(); } while (_frameCycles != 0); + + return true; } public int Frame => _frame; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IStatable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IStatable.cs index 1bef375cba..d8c3e9840f 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IStatable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IStatable.cs @@ -43,11 +43,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 private void SyncState(Serializer ser) { ser.BeginSection("core"); - ser.Sync("_frameCycles", ref _frameCycles); - ser.Sync("Frame", ref _frame); - ser.Sync("IsLagFrame", ref _isLagFrame); - ser.Sync("LagCount", ref _lagCount); - ser.Sync("CurrentDisk", ref _currentDisk); + ser.Sync(nameof(_frameCycles), ref _frameCycles); + ser.Sync(nameof(Frame), ref _frame); + ser.Sync(nameof(IsLagFrame), ref _isLagFrame); + ser.Sync(nameof(LagCount), ref _lagCount); + ser.Sync(nameof(CurrentDisk), ref _currentDisk); ser.Sync("PreviousDiskPressed", ref _prevPressed); ser.Sync("NextDiskPressed", ref _nextPressed); ser.BeginSection("Board"); diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs index b4b5a7b9b1..d37a27590f 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs @@ -278,83 +278,83 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public void SyncState(Serializer ser) { - ser.BeginSection("Cia0"); + ser.BeginSection(nameof(Cia0)); Cia0.SyncState(ser); ser.EndSection(); - ser.BeginSection("Cia1"); + ser.BeginSection(nameof(Cia1)); Cia1.SyncState(ser); ser.EndSection(); - ser.BeginSection("ColorRam"); + ser.BeginSection(nameof(ColorRam)); ColorRam.SyncState(ser); ser.EndSection(); - ser.BeginSection("Cpu"); + ser.BeginSection(nameof(Cpu)); Cpu.SyncState(ser); ser.EndSection(); - ser.BeginSection("Pla"); + ser.BeginSection(nameof(Pla)); Pla.SyncState(ser); ser.EndSection(); - ser.BeginSection("Ram"); + ser.BeginSection(nameof(Ram)); Ram.SyncState(ser); ser.EndSection(); - ser.BeginSection("Sid"); + ser.BeginSection(nameof(Sid)); Sid.SyncState(ser); ser.EndSection(); - ser.BeginSection("Vic"); + ser.BeginSection(nameof(Vic)); Vic.SyncState(ser); ser.EndSection(); if (CartPort.IsConnected) { - ser.BeginSection("CartPort"); + ser.BeginSection(nameof(CartPort)); CartPort.SyncState(ser); ser.EndSection(); } - ser.BeginSection("Cassette"); + ser.BeginSection(nameof(Cassette)); Cassette.SyncState(ser); ser.EndSection(); - ser.BeginSection("Serial"); + ser.BeginSection(nameof(Serial)); Serial.SyncState(ser); ser.EndSection(); if (TapeDrive != null) // TODO: a tape object is already in a nested class, is it the same reference? do we need this? { - ser.BeginSection("TapeDrive"); + ser.BeginSection(nameof(TapeDrive)); TapeDrive.SyncState(ser); ser.EndSection(); } - ser.BeginSection("User"); + ser.BeginSection(nameof(User)); User.SyncState(ser); ser.EndSection(); if (DiskDrive != null) // TODO: a disk object is already in a nested class, is it the same reference? do we need this? { - ser.BeginSection("DiskDrive"); + ser.BeginSection(nameof(DiskDrive)); DiskDrive.SyncState(ser); ser.EndSection(); } - ser.Sync("Bus", ref Bus); - ser.Sync("InputRead", ref InputRead); - ser.Sync("Irq", ref Irq); - ser.Sync("Nmi", ref Nmi); + ser.Sync(nameof(Bus), ref Bus); + ser.Sync(nameof(InputRead), ref InputRead); + ser.Sync(nameof(Irq), ref Irq); + ser.Sync(nameof(Nmi), ref Nmi); - ser.Sync("_lastReadVicAddress", ref _lastReadVicAddress); - ser.Sync("_lastReadVicData", ref _lastReadVicData); - ser.Sync("_vicBank", ref _vicBank); + ser.Sync(nameof(_lastReadVicAddress), ref _lastReadVicAddress); + ser.Sync(nameof(_lastReadVicData), ref _lastReadVicData); + ser.Sync(nameof(_vicBank), ref _vicBank); - ser.Sync("_joystickPressed", ref _joystickPressed, useNull: false); - ser.Sync("_keyboardPressed", ref _keyboardPressed, useNull: false); - ser.Sync("_restorePressed", ref _restorePressed); + ser.Sync(nameof(_joystickPressed), ref _joystickPressed, useNull: false); + ser.Sync(nameof(_keyboardPressed), ref _keyboardPressed, useNull: false); + ser.Sync(nameof(_restorePressed), ref _restorePressed); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs index 32dd387854..dd208242ab 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs @@ -229,14 +229,14 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge public virtual void SyncState(Serializer ser) { - ser.Sync("pinExRom", ref pinExRom); - ser.Sync("pinGame", ref pinGame); - ser.Sync("pinIRQ", ref pinIRQ); - ser.Sync("pinNMI", ref pinNMI); - ser.Sync("pinReset", ref pinReset); + ser.Sync(nameof(pinExRom), ref pinExRom); + ser.Sync(nameof(pinGame), ref pinGame); + ser.Sync(nameof(pinIRQ), ref pinIRQ); + ser.Sync(nameof(pinNMI), ref pinNMI); + ser.Sync(nameof(pinReset), ref pinReset); - ser.Sync("_driveLightEnabled", ref _driveLightEnabled); - ser.Sync("_driveLightOn", ref _driveLightOn); + ser.Sync(nameof(_driveLightEnabled), ref _driveLightEnabled); + ser.Sync(nameof(_driveLightOn), ref _driveLightOn); } public bool Valid => validCartridge; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgePort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgePort.cs index 19570789ed..055f1fe0af 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgePort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgePort.cs @@ -127,9 +127,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge public void SyncState(Serializer ser) { - ser.Sync("_connected", ref _connected); + ser.Sync(nameof(_connected), ref _connected); - ser.BeginSection("CartridgeDevice"); + ser.BeginSection(nameof(CartridgeDevice)); _cartridgeDevice.SyncState(ser); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000F.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000F.cs index ae623445af..49cd16f657 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000F.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000F.cs @@ -133,8 +133,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge public override void SyncState(Serializer ser) { - ser.Sync("_bankMask", ref _bankMask); - ser.Sync("_bankNumber", ref _bankNumber); + ser.Sync(nameof(_bankMask), ref _bankMask); + ser.Sync(nameof(_bankNumber), ref _bankNumber); base.SyncState(ser); if (ser.IsReader) { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip2114.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip2114.cs index 506545a041..82ed244d69 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip2114.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip2114.cs @@ -42,7 +42,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("_ram", ref _ram, useNull: false); + ser.Sync(nameof(_ram), ref _ram, useNull: false); } public void Write(int addr, int val) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs index ebd81cd2d7..78367804a7 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs @@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("_ram", ref _ram, useNull: false); + ser.Sync(nameof(_ram), ref _ram, useNull: false); } public void Write(int addr, int val) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.cs index 8d3e5125b0..dc99da4183 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.cs @@ -219,14 +219,14 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS _cpu.SyncState(ser); ser.EndSection(); - ser.Sync("_pinNmiLast", ref _pinNmiLast); + ser.Sync(nameof(_pinNmiLast), ref _pinNmiLast); - ser.BeginSection("_port"); + ser.BeginSection(nameof(_port)); _port.SyncState(ser); ser.EndSection(); - ser.Sync("_thisNmi", ref _thisNmi); - ser.Sync("LagCycles", ref LagCycles); + ser.Sync(nameof(_thisNmi), ref _thisNmi); + ser.Sync(nameof(LagCycles), ref LagCycles); } public void Write(int addr, int val) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip90611401.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip90611401.cs index a32f8c71b5..d01280b092 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip90611401.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip90611401.cs @@ -307,20 +307,20 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("_p24", ref _p24); - ser.Sync("_p25", ref _p25); - ser.Sync("_p26", ref _p26); - ser.Sync("_p27", ref _p27); - ser.Sync("_p28", ref _p28); - ser.Sync("_loram", ref _loram); - ser.Sync("_hiram", ref _hiram); - ser.Sync("_game", ref _game); - ser.Sync("_exrom", ref _exrom); - ser.Sync("_charen", ref _charen); - ser.Sync("_a15", ref _a15); - ser.Sync("_a14", ref _a14); - ser.Sync("_a13", ref _a13); - ser.Sync("_a12", ref _a12); + ser.Sync(nameof(_p24), ref _p24); + ser.Sync(nameof(_p25), ref _p25); + ser.Sync(nameof(_p26), ref _p26); + ser.Sync(nameof(_p27), ref _p27); + ser.Sync(nameof(_p28), ref _p28); + ser.Sync(nameof(_loram), ref _loram); + ser.Sync(nameof(_hiram), ref _hiram); + ser.Sync(nameof(_game), ref _game); + ser.Sync(nameof(_exrom), ref _exrom); + ser.Sync(nameof(_charen), ref _charen); + ser.Sync(nameof(_a15), ref _a15); + ser.Sync(nameof(_a14), ref _a14); + ser.Sync(nameof(_a13), ref _a13); + ser.Sync(nameof(_a12), ref _a12); } public int VicRead(int addr) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs index dccf7bab2f..113c0fcfa6 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.cs @@ -533,51 +533,51 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("DelayedInterrupts", ref DelayedInterrupts); - ser.Sync("_pra", ref _pra); - ser.Sync("_prb", ref _prb); - ser.Sync("_ddra", ref _ddra); - ser.Sync("_ddrb", ref _ddrb); - ser.Sync("_ta", ref _ta); - ser.Sync("_tb", ref _tb); - ser.Sync("_latcha", ref _latcha); - ser.Sync("_latchb", ref _latchb); - ser.Sync("_tod10Ths", ref _tod10Ths); - ser.Sync("_todSec", ref _todSec); - ser.Sync("_todMin", ref _todMin); - ser.Sync("_todHr", ref _todHr); - ser.Sync("_latch10Ths", ref _latch10Ths); - ser.Sync("_latchSec", ref _latchSec); - ser.Sync("_latchMin", ref _latchMin); - ser.Sync("_latchHr", ref _latchHr); - ser.Sync("_alm10Ths", ref _alm10Ths); - ser.Sync("_almSec", ref _almSec); - ser.Sync("_almMin", ref _almMin); - ser.Sync("_almHr", ref _almHr); - ser.Sync("_sdr", ref _sdr); - ser.Sync("_icr", ref _icr); - ser.Sync("_cra", ref _cra); - ser.Sync("_crb", ref _crb); - ser.Sync("_intMask", ref _intMask); - ser.Sync("_todLatch", ref _todLatch); - ser.Sync("_taCntPhi2", ref _taCntPhi2); - ser.Sync("_taCntCnt", ref _taCntCnt); - ser.Sync("_tbCntPhi2", ref _tbCntPhi2); - ser.Sync("_tbCntTa", ref _tbCntTa); - ser.Sync("_tbCntCnt", ref _tbCntCnt); - ser.Sync("_taIrqNextCycle", ref _taIrqNextCycle); - ser.Sync("_taPrb6NegativeNextCycle", ref _taPrb6NegativeNextCycle); - ser.Sync("_tbIrqNextCycle", ref _tbIrqNextCycle); - ser.Sync("_tbPrb7NegativeNextCycle", ref _tbPrb7NegativeNextCycle); - ser.Sync("_hasNewCra", ref _hasNewCra); - ser.Sync("_hasNewCrb", ref _hasNewCrb); - ser.SyncEnum("_taState", ref _taState); - ser.SyncEnum("_tbState", ref _tbState); - ser.Sync("_newCra", ref _newCra); - ser.Sync("_newCrb", ref _newCrb); - ser.Sync("_flagLatch", ref _flagLatch); + ser.Sync(nameof(DelayedInterrupts), ref DelayedInterrupts); + ser.Sync(nameof(_pra), ref _pra); + ser.Sync(nameof(_prb), ref _prb); + ser.Sync(nameof(_ddra), ref _ddra); + ser.Sync(nameof(_ddrb), ref _ddrb); + ser.Sync(nameof(_ta), ref _ta); + ser.Sync(nameof(_tb), ref _tb); + ser.Sync(nameof(_latcha), ref _latcha); + ser.Sync(nameof(_latchb), ref _latchb); + ser.Sync(nameof(_tod10Ths), ref _tod10Ths); + ser.Sync(nameof(_todSec), ref _todSec); + ser.Sync(nameof(_todMin), ref _todMin); + ser.Sync(nameof(_todHr), ref _todHr); + ser.Sync(nameof(_latch10Ths), ref _latch10Ths); + ser.Sync(nameof(_latchSec), ref _latchSec); + ser.Sync(nameof(_latchMin), ref _latchMin); + ser.Sync(nameof(_latchHr), ref _latchHr); + ser.Sync(nameof(_alm10Ths), ref _alm10Ths); + ser.Sync(nameof(_almSec), ref _almSec); + ser.Sync(nameof(_almMin), ref _almMin); + ser.Sync(nameof(_almHr), ref _almHr); + ser.Sync(nameof(_sdr), ref _sdr); + ser.Sync(nameof(_icr), ref _icr); + ser.Sync(nameof(_cra), ref _cra); + ser.Sync(nameof(_crb), ref _crb); + ser.Sync(nameof(_intMask), ref _intMask); + ser.Sync(nameof(_todLatch), ref _todLatch); + ser.Sync(nameof(_taCntPhi2), ref _taCntPhi2); + ser.Sync(nameof(_taCntCnt), ref _taCntCnt); + ser.Sync(nameof(_tbCntPhi2), ref _tbCntPhi2); + ser.Sync(nameof(_tbCntTa), ref _tbCntTa); + ser.Sync(nameof(_tbCntCnt), ref _tbCntCnt); + ser.Sync(nameof(_taIrqNextCycle), ref _taIrqNextCycle); + ser.Sync(nameof(_taPrb6NegativeNextCycle), ref _taPrb6NegativeNextCycle); + ser.Sync(nameof(_tbIrqNextCycle), ref _tbIrqNextCycle); + ser.Sync(nameof(_tbPrb7NegativeNextCycle), ref _tbPrb7NegativeNextCycle); + ser.Sync(nameof(_hasNewCra), ref _hasNewCra); + ser.Sync(nameof(_hasNewCrb), ref _hasNewCrb); + ser.SyncEnum(nameof(_taState), ref _taState); + ser.SyncEnum(nameof(_tbState), ref _tbState); + ser.Sync(nameof(_newCra), ref _newCra); + ser.Sync(nameof(_newCrb), ref _newCrb); + ser.Sync(nameof(_flagLatch), ref _flagLatch); - ser.Sync("_todCounter", ref _todCounter); + ser.Sync(nameof(_todCounter), ref _todCounter); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/LatchedPort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/LatchedPort.cs index 70ec16bdf2..13d2e9a387 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/LatchedPort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/LatchedPort.cs @@ -37,8 +37,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("Direction", ref Direction); - ser.Sync("Latch", ref Latch); + ser.Sync(nameof(Direction), ref Direction); + ser.Sync(nameof(Latch), ref Latch); } } @@ -78,8 +78,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("Direction", ref Direction); - ser.Sync("Latch", ref Latch); + ser.Sync(nameof(Direction), ref Direction); + ser.Sync(nameof(Latch), ref Latch); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs index 9122c2d183..e011908307 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs @@ -235,19 +235,19 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("_attack", ref _attack); - ser.Sync("_decay", ref _decay); - ser.Sync("_delay", ref _delay); - ser.Sync("_envCounter", ref _envCounter); - ser.Sync("_expCounter", ref _expCounter); - ser.Sync("_expPeriod", ref _expPeriod); - ser.Sync("_freeze", ref _freeze); - ser.Sync("_lfsr", ref _lfsr); - ser.Sync("_gate", ref _gate); - ser.Sync("_rate", ref _rate); - ser.Sync("_release", ref _release); - ser.Sync("_state", ref _state); - ser.Sync("_sustain", ref _sustain); + ser.Sync(nameof(_attack), ref _attack); + ser.Sync(nameof(_decay), ref _decay); + ser.Sync(nameof(_delay), ref _delay); + ser.Sync(nameof(_envCounter), ref _envCounter); + ser.Sync(nameof(_expCounter), ref _expCounter); + ser.Sync(nameof(_expPeriod), ref _expPeriod); + ser.Sync(nameof(_freeze), ref _freeze); + ser.Sync(nameof(_lfsr), ref _lfsr); + ser.Sync(nameof(_gate), ref _gate); + ser.Sync(nameof(_rate), ref _rate); + ser.Sync(nameof(_release), ref _release); + ser.Sync(nameof(_state), ref _state); + ser.Sync(nameof(_sustain), ref _sustain); } // ------------------------------------ diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs index bf3020e63c..d6e943f9e2 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs @@ -276,30 +276,30 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS // ------------------------------------ public void SyncState(Serializer ser) { - ser.Sync("_accBits", ref _accBits); - ser.Sync("_accNext", ref _accNext); - ser.Sync("_accumulator", ref _accumulator); - ser.Sync("_controlTestPrev", ref _controlTestPrev); - ser.Sync("_controlWavePrev", ref _controlWavePrev); - ser.Sync("_delay", ref _delay); - ser.Sync("_floatOutputTtl", ref _floatOutputTtl); - ser.Sync("_frequency", ref _frequency); - ser.Sync("_msbRising", ref _msbRising); - ser.Sync("_noise", ref _noise); - ser.Sync("_noNoise", ref _noNoise); - ser.Sync("_noNoiseOrNoise", ref _noNoiseOrNoise); - ser.Sync("_noPulse", ref _noPulse); - ser.Sync("_output", ref _output); - ser.Sync("_pulse", ref _pulse); - ser.Sync("_pulseWidth", ref _pulseWidth); - ser.Sync("_ringMod", ref _ringMod); - ser.Sync("_ringMsbMask", ref _ringMsbMask); - ser.Sync("_shiftRegister", ref _shiftRegister); - ser.Sync("_shiftRegisterReset", ref _shiftRegisterReset); - ser.Sync("_sync", ref _sync); - ser.Sync("_test", ref _test); - ser.Sync("_waveform", ref _waveform); - ser.Sync("_waveformIndex", ref _waveformIndex); + ser.Sync(nameof(_accBits), ref _accBits); + ser.Sync(nameof(_accNext), ref _accNext); + ser.Sync(nameof(_accumulator), ref _accumulator); + ser.Sync(nameof(_controlTestPrev), ref _controlTestPrev); + ser.Sync(nameof(_controlWavePrev), ref _controlWavePrev); + ser.Sync(nameof(_delay), ref _delay); + ser.Sync(nameof(_floatOutputTtl), ref _floatOutputTtl); + ser.Sync(nameof(_frequency), ref _frequency); + ser.Sync(nameof(_msbRising), ref _msbRising); + ser.Sync(nameof(_noise), ref _noise); + ser.Sync(nameof(_noNoise), ref _noNoise); + ser.Sync(nameof(_noNoiseOrNoise), ref _noNoiseOrNoise); + ser.Sync(nameof(_noPulse), ref _noPulse); + ser.Sync(nameof(_output), ref _output); + ser.Sync(nameof(_pulse), ref _pulse); + ser.Sync(nameof(_pulseWidth), ref _pulseWidth); + ser.Sync(nameof(_ringMod), ref _ringMod); + ser.Sync(nameof(_ringMsbMask), ref _ringMsbMask); + ser.Sync(nameof(_shiftRegister), ref _shiftRegister); + ser.Sync(nameof(_shiftRegisterReset), ref _shiftRegisterReset); + ser.Sync(nameof(_sync), ref _sync); + ser.Sync(nameof(_test), ref _test); + ser.Sync(nameof(_waveform), ref _waveform); + ser.Sync(nameof(_waveformIndex), ref _waveformIndex); _wave = _waveTable[_waveform & 0x07]; } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.cs index 781cfa569c..87744b909b 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.cs @@ -331,12 +331,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("_databus", ref _databus); - ser.Sync("_cachedCycles", ref _cachedCycles); - ser.Sync("_disableVoice3", ref _disableVoice3); - ser.Sync("_envelopeOutput0", ref _envelopeOutput0); - ser.Sync("_envelopeOutput1", ref _envelopeOutput1); - ser.Sync("_envelopeOutput2", ref _envelopeOutput2); + ser.Sync(nameof(_databus), ref _databus); + ser.Sync(nameof(_cachedCycles), ref _cachedCycles); + ser.Sync(nameof(_disableVoice3), ref _disableVoice3); + ser.Sync(nameof(_envelopeOutput0), ref _envelopeOutput0); + ser.Sync(nameof(_envelopeOutput1), ref _envelopeOutput1); + ser.Sync(nameof(_envelopeOutput2), ref _envelopeOutput2); for (int i = 0; i < _envelopes.Length; i++) { @@ -345,20 +345,20 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS ser.EndSection(); } - ser.Sync("_filterEnable", ref _filterEnable, useNull: false); - ser.Sync("_filterFrequency", ref _filterFrequency); - ser.Sync("_filterResonance", ref _filterResonance); - ser.Sync("_filterSelectBandPass", ref _filterSelectBandPass); - ser.Sync("_filterSelectLoPass", ref _filterSelectLoPass); - ser.Sync("_filterSelectHiPass", ref _filterSelectHiPass); - ser.Sync("_mixer", ref _mixer); - ser.Sync("_potCounter", ref _potCounter); - ser.Sync("_potX", ref _potX); - ser.Sync("_potY", ref _potY); - ser.Sync("_sample", ref _sample); - ser.Sync("_voiceOutput0", ref _voiceOutput0); - ser.Sync("_voiceOutput1", ref _voiceOutput1); - ser.Sync("_voiceOutput2", ref _voiceOutput2); + ser.Sync(nameof(_filterEnable), ref _filterEnable, useNull: false); + ser.Sync(nameof(_filterFrequency), ref _filterFrequency); + ser.Sync(nameof(_filterResonance), ref _filterResonance); + ser.Sync(nameof(_filterSelectBandPass), ref _filterSelectBandPass); + ser.Sync(nameof(_filterSelectLoPass), ref _filterSelectLoPass); + ser.Sync(nameof(_filterSelectHiPass), ref _filterSelectHiPass); + ser.Sync(nameof(_mixer), ref _mixer); + ser.Sync(nameof(_potCounter), ref _potCounter); + ser.Sync(nameof(_potX), ref _potX); + ser.Sync(nameof(_potY), ref _potY); + ser.Sync(nameof(_sample), ref _sample); + ser.Sync(nameof(_voiceOutput0), ref _voiceOutput0); + ser.Sync(nameof(_voiceOutput1), ref _voiceOutput1); + ser.Sync(nameof(_voiceOutput2), ref _voiceOutput2); for (int i = 0; i < _voices.Length; i++) { @@ -367,7 +367,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS ser.EndSection(); } - ser.Sync("_volume", ref _volume); + ser.Sync(nameof(_volume), ref _volume); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Via.Port.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Via.Port.cs index 209c88e0b7..173314dfb5 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Via.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Via.Port.cs @@ -127,7 +127,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("_driveNumber", ref _driveNumber); + ser.Sync(nameof(_driveNumber), ref _driveNumber); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs index 542e853cda..7fd16863de 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Sprite.cs @@ -54,27 +54,27 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("CollideData", ref CollideData); - ser.Sync("CollideSprite", ref CollideSprite); - ser.Sync("Color", ref Color); - ser.Sync("Display", ref Display); - ser.Sync("Dma", ref Dma); - ser.Sync("Enable", ref Enable); - ser.Sync("Loaded", ref Loaded); - ser.Sync("Mc", ref Mc); - ser.Sync("Mcbase", ref Mcbase); - ser.Sync("Multicolor", ref Multicolor); - ser.Sync("MulticolorCrunch", ref MulticolorCrunch); - ser.Sync("Pointer", ref Pointer); - ser.Sync("Priority", ref Priority); - ser.Sync("ShiftEnable", ref ShiftEnable); - ser.Sync("Sr", ref Sr); - ser.Sync("X", ref X); - ser.Sync("XCrunch", ref XCrunch); - ser.Sync("XExpand", ref XExpand); - ser.Sync("Y", ref Y); - ser.Sync("YCrunch", ref YCrunch); - ser.Sync("YExpand", ref YExpand); + ser.Sync(nameof(CollideData), ref CollideData); + ser.Sync(nameof(CollideSprite), ref CollideSprite); + ser.Sync(nameof(Color), ref Color); + ser.Sync(nameof(Display), ref Display); + ser.Sync(nameof(Dma), ref Dma); + ser.Sync(nameof(Enable), ref Enable); + ser.Sync(nameof(Loaded), ref Loaded); + ser.Sync(nameof(Mc), ref Mc); + ser.Sync(nameof(Mcbase), ref Mcbase); + ser.Sync(nameof(Multicolor), ref Multicolor); + ser.Sync(nameof(MulticolorCrunch), ref MulticolorCrunch); + ser.Sync(nameof(Pointer), ref Pointer); + ser.Sync(nameof(Priority), ref Priority); + ser.Sync(nameof(ShiftEnable), ref ShiftEnable); + ser.Sync(nameof(Sr), ref Sr); + ser.Sync(nameof(X), ref X); + ser.Sync(nameof(XCrunch), ref XCrunch); + ser.Sync(nameof(XExpand), ref XExpand); + ser.Sync(nameof(Y), ref Y); + ser.Sync(nameof(YCrunch), ref YCrunch); + ser.Sync(nameof(YExpand), ref YExpand); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs index 39afdfe805..aae4938e95 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.State.cs @@ -160,71 +160,71 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { - ser.Sync("_cyclesExecuted", ref _cyclesExecuted); - ser.Sync("_parseIsSprCrunch", ref _parseIsSprCrunch); - ser.Sync("_srSync", ref _srSync); - ser.Sync("_srColorSync", ref _srColorSync); - ser.Sync("_srColorIndexLatch", ref _srColorIndexLatch); - ser.Sync("_videoMode", ref _videoMode); - ser.Sync("_borderOnShiftReg", ref _borderOnShiftReg); - ser.Sync("_backgroundColor0", ref _backgroundColor0); - ser.Sync("_backgroundColor1", ref _backgroundColor1); - ser.Sync("_backgroundColor2", ref _backgroundColor2); - ser.Sync("_backgroundColor3", ref _backgroundColor3); - ser.Sync("_baCount", ref _baCount); - ser.Sync("_badline", ref _badline); - ser.Sync("_badlineEnable", ref _badlineEnable); - ser.Sync("_bitmapMode", ref _bitmapMode); - ser.Sync("_borderB", ref _borderB); - ser.Sync("_borderCheckLEnable", ref _borderCheckLEnable); - ser.Sync("_borderCheckREnable", ref _borderCheckREnable); - ser.Sync("_borderColor", ref _borderColor); - ser.Sync("_borderL", ref _borderL); - ser.Sync("_borderOnMain", ref _borderOnMain); - ser.Sync("_borderOnVertical", ref _borderOnVertical); - ser.Sync("_borderR", ref _borderR); - ser.Sync("_borderT", ref _borderT); - ser.Sync("_bufferC", ref _bufferC, useNull: false); - ser.Sync("_bufferG", ref _bufferG, useNull: false); - ser.Sync("_cycle", ref _cycle); - ser.Sync("_cycleIndex", ref _cycleIndex); - ser.Sync("_columnSelect", ref _columnSelect); - ser.Sync("_dataC", ref _dataC); - ser.Sync("_dataG", ref _dataG); - ser.Sync("_displayEnable", ref _displayEnable); - ser.Sync("_displayC", ref _displayC); - ser.Sync("_enableIntLightPen", ref _enableIntLightPen); - ser.Sync("_enableIntRaster", ref _enableIntRaster); - ser.Sync("_enableIntSpriteCollision", ref _enableIntSpriteCollision); - ser.Sync("_enableIntSpriteDataCollision", ref _enableIntSpriteDataCollision); - ser.Sync("_extraColorMode", ref _extraColorMode); - ser.Sync("_extraColorModeBuffer", ref _extraColorModeBuffer); - ser.Sync("_idle", ref _idle); - ser.Sync("_intLightPen", ref _intLightPen); - ser.Sync("_intRaster", ref _intRaster); - ser.Sync("_intSpriteCollision", ref _intSpriteCollision); - ser.Sync("_intSpriteDataCollision", ref _intSpriteDataCollision); - ser.Sync("_lightPenX", ref _lightPenX); - ser.Sync("_lightPenY", ref _lightPenY); - ser.Sync("_multicolorMode", ref _multicolorMode); - ser.Sync("_pinAec", ref _pinAec); - ser.Sync("_pinBa", ref _pinBa); - ser.Sync("_pinIrq", ref _pinIrq); - ser.Sync("_pointerCb", ref _pointerCb); - ser.Sync("_pointerVm", ref _pointerVm); - ser.Sync("_rasterInterruptLine", ref _rasterInterruptLine); - ser.Sync("_rasterInterruptTriggered", ref _rasterInterruptTriggered); - ser.Sync("_rasterLine", ref _rasterLine); - ser.Sync("_rasterX", ref _rasterX); - ser.Sync("_rasterXHold", ref _rasterXHold); - ser.Sync("_rc", ref _rc); - ser.Sync("_refreshCounter", ref _refreshCounter); - ser.Sync("_renderEnabled", ref _renderEnabled); - ser.Sync("_rowSelect", ref _rowSelect); - ser.Sync("_spriteBackgroundCollisionClearPending", ref _spriteBackgroundCollisionClearPending); - ser.Sync("_spriteSpriteCollisionClearPending", ref _spriteSpriteCollisionClearPending); - ser.Sync("_spriteMulticolor0", ref _spriteMulticolor0); - ser.Sync("_spriteMulticolor1", ref _spriteMulticolor1); + ser.Sync(nameof(_cyclesExecuted), ref _cyclesExecuted); + ser.Sync(nameof(_parseIsSprCrunch), ref _parseIsSprCrunch); + ser.Sync(nameof(_srSync), ref _srSync); + ser.Sync(nameof(_srColorSync), ref _srColorSync); + ser.Sync(nameof(_srColorIndexLatch), ref _srColorIndexLatch); + ser.Sync(nameof(_videoMode), ref _videoMode); + ser.Sync(nameof(_borderOnShiftReg), ref _borderOnShiftReg); + ser.Sync(nameof(_backgroundColor0), ref _backgroundColor0); + ser.Sync(nameof(_backgroundColor1), ref _backgroundColor1); + ser.Sync(nameof(_backgroundColor2), ref _backgroundColor2); + ser.Sync(nameof(_backgroundColor3), ref _backgroundColor3); + ser.Sync(nameof(_baCount), ref _baCount); + ser.Sync(nameof(_badline), ref _badline); + ser.Sync(nameof(_badlineEnable), ref _badlineEnable); + ser.Sync(nameof(_bitmapMode), ref _bitmapMode); + ser.Sync(nameof(_borderB), ref _borderB); + ser.Sync(nameof(_borderCheckLEnable), ref _borderCheckLEnable); + ser.Sync(nameof(_borderCheckREnable), ref _borderCheckREnable); + ser.Sync(nameof(_borderColor), ref _borderColor); + ser.Sync(nameof(_borderL), ref _borderL); + ser.Sync(nameof(_borderOnMain), ref _borderOnMain); + ser.Sync(nameof(_borderOnVertical), ref _borderOnVertical); + ser.Sync(nameof(_borderR), ref _borderR); + ser.Sync(nameof(_borderT), ref _borderT); + ser.Sync(nameof(_bufferC), ref _bufferC, useNull: false); + ser.Sync(nameof(_bufferG), ref _bufferG, useNull: false); + ser.Sync(nameof(_cycle), ref _cycle); + ser.Sync(nameof(_cycleIndex), ref _cycleIndex); + ser.Sync(nameof(_columnSelect), ref _columnSelect); + ser.Sync(nameof(_dataC), ref _dataC); + ser.Sync(nameof(_dataG), ref _dataG); + ser.Sync(nameof(_displayEnable), ref _displayEnable); + ser.Sync(nameof(_displayC), ref _displayC); + ser.Sync(nameof(_enableIntLightPen), ref _enableIntLightPen); + ser.Sync(nameof(_enableIntRaster), ref _enableIntRaster); + ser.Sync(nameof(_enableIntSpriteCollision), ref _enableIntSpriteCollision); + ser.Sync(nameof(_enableIntSpriteDataCollision), ref _enableIntSpriteDataCollision); + ser.Sync(nameof(_extraColorMode), ref _extraColorMode); + ser.Sync(nameof(_extraColorModeBuffer), ref _extraColorModeBuffer); + ser.Sync(nameof(_idle), ref _idle); + ser.Sync(nameof(_intLightPen), ref _intLightPen); + ser.Sync(nameof(_intRaster), ref _intRaster); + ser.Sync(nameof(_intSpriteCollision), ref _intSpriteCollision); + ser.Sync(nameof(_intSpriteDataCollision), ref _intSpriteDataCollision); + ser.Sync(nameof(_lightPenX), ref _lightPenX); + ser.Sync(nameof(_lightPenY), ref _lightPenY); + ser.Sync(nameof(_multicolorMode), ref _multicolorMode); + ser.Sync(nameof(_pinAec), ref _pinAec); + ser.Sync(nameof(_pinBa), ref _pinBa); + ser.Sync(nameof(_pinIrq), ref _pinIrq); + ser.Sync(nameof(_pointerCb), ref _pointerCb); + ser.Sync(nameof(_pointerVm), ref _pointerVm); + ser.Sync(nameof(_rasterInterruptLine), ref _rasterInterruptLine); + ser.Sync(nameof(_rasterInterruptTriggered), ref _rasterInterruptTriggered); + ser.Sync(nameof(_rasterLine), ref _rasterLine); + ser.Sync(nameof(_rasterX), ref _rasterX); + ser.Sync(nameof(_rasterXHold), ref _rasterXHold); + ser.Sync(nameof(_rc), ref _rc); + ser.Sync(nameof(_refreshCounter), ref _refreshCounter); + ser.Sync(nameof(_renderEnabled), ref _renderEnabled); + ser.Sync(nameof(_rowSelect), ref _rowSelect); + ser.Sync(nameof(_spriteBackgroundCollisionClearPending), ref _spriteBackgroundCollisionClearPending); + ser.Sync(nameof(_spriteSpriteCollisionClearPending), ref _spriteSpriteCollisionClearPending); + ser.Sync(nameof(_spriteMulticolor0), ref _spriteMulticolor0); + ser.Sync(nameof(_spriteMulticolor1), ref _spriteMulticolor1); for (int i = 0; i < _sprites.Length; i++) { @@ -233,17 +233,17 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS ser.EndSection(); } - ser.Sync("_sr", ref _sr); - ser.Sync("_vc", ref _vc); - ser.Sync("_vcbase", ref _vcbase); - ser.Sync("_vmli", ref _vmli); - ser.Sync("_xScroll", ref _xScroll); - ser.Sync("_yScroll", ref _yScroll); - ser.Sync("_bufOffset", ref _bufOffset); - ser.Sync("_pixBuffer", ref _pixBuffer, useNull: false); - ser.Sync("_pixBufferIndex", ref _pixBufferIndex); - ser.Sync("_pixBorderBuffer", ref _pixBorderBuffer, useNull: false); - ser.Sync("_pixBufferBorderIndex", ref _pixBufferBorderIndex); + ser.Sync(nameof(_sr), ref _sr); + ser.Sync(nameof(_vc), ref _vc); + ser.Sync(nameof(_vcbase), ref _vcbase); + ser.Sync(nameof(_vmli), ref _vmli); + ser.Sync(nameof(_xScroll), ref _xScroll); + ser.Sync(nameof(_yScroll), ref _yScroll); + ser.Sync(nameof(_bufOffset), ref _bufOffset); + ser.Sync(nameof(_pixBuffer), ref _pixBuffer, useNull: false); + ser.Sync(nameof(_pixBufferIndex), ref _pixBufferIndex); + ser.Sync(nameof(_pixBorderBuffer), ref _pixBorderBuffer, useNull: false); + ser.Sync(nameof(_pixBufferBorderIndex), ref _pixBufferBorderIndex); if (ser.IsReader) { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/Disk.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/Disk.cs index 4c77366b8d..712c71e03a 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/Disk.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/Disk.cs @@ -167,7 +167,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media public void SyncState(Serializer ser) { - ser.Sync("WriteProtected", ref WriteProtected); + ser.Sync(nameof(WriteProtected), ref WriteProtected); // Currently nothing actually writes to _tracks and so it is always the same as _originalMedia // So commenting out this (very slow) code for now diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/User/UserPort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/User/UserPort.cs index 268ede9a47..e92642d09c 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/User/UserPort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/User/UserPort.cs @@ -69,7 +69,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.User public void SyncState(Serializer ser) { - ser.Sync("_connected", ref _connected); + ser.Sync(nameof(_connected), ref _connected); _device?.SyncState(ser); } } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs index 55e4a1d14c..ccd2065e66 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs @@ -131,13 +131,16 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// Should be fired at the end of every frame - /// Primary purpose is to detect tape traps and manage auto play (if/when this is ever implemented) + /// Primary purpose is to detect tape traps and manage auto play /// public void EndFrame() { MonitorFrame(); } + /// + /// No longer in use + /// public void StartFrame() { //_buzzer.ProcessPulseValue(currentState); @@ -296,14 +299,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum sbd.Append("("); sbd.Append((targetBlockId + 1) + " of " + _dataBlocks.Count()); sbd.Append(") : "); - //sbd.Append("ID" + bl.BlockID.ToString("X2") + " - "); sbd.Append(bl.BlockDescription); if (bl.MetaData.Count > 0) { sbd.Append(" - "); sbd.Append(bl.MetaData.First().Key + ": " + bl.MetaData.First().Value); - //sbd.Append("\n"); - //sbd.Append(bl.MetaData.Skip(1).First().Key + ": " + bl.MetaData.Skip(1).First().Value); } if (skipForward) @@ -522,7 +522,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum sbd.Append("("); sbd.Append((_currentDataBlockIndex + 1) + " of " + _dataBlocks.Count()); sbd.Append(") : "); - //sbd.Append("ID" + bl.BlockID.ToString("X2") + " - "); sbd.Append(bl.BlockDescription); if (bl.MetaData.Count > 0) { @@ -532,14 +531,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _machine.Spectrum.OSD_TapePlayingBlockInfo(sbd.ToString()); } - // increment the current period position _position++; if (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count()) { // we have reached the end of the current block - if (_dataBlocks[_currentDataBlockIndex].DataPeriods.Count() == 0) { // notify about the current block (we are skipping it because its empty) @@ -548,13 +545,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum sbd.Append("("); sbd.Append((_currentDataBlockIndex + 1) + " of " + _dataBlocks.Count()); sbd.Append(") : "); - //sbd.Append("ID" + bl.BlockID.ToString("X2") + " - "); sbd.Append(bl.BlockDescription); if (bl.MetaData.Count > 0) - { - sbd.Append(" - "); - sbd.Append(bl.MetaData.First().Key + ": " + bl.MetaData.First().Value); - } + { + sbd.Append(" - "); + sbd.Append(bl.MetaData.First().Key + ": " + bl.MetaData.First().Value); + } _machine.Spectrum.OSD_TapePlayingSkipBlockInfo(sbd.ToString()); } @@ -583,7 +579,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } _monitorTimeOut = 2000; - break; case TapeCommand.STOP_THE_TAPE_48K: if (is48k) @@ -624,20 +619,16 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } } - // update waitEdge with current position within the current block - _waitEdge = _dataBlocks[_currentDataBlockIndex].DataPeriods[_position]; + // update waitEdge with current position within the current block + _waitEdge = _dataBlocks[_currentDataBlockIndex].DataPeriods.Count() > 0 ? _dataBlocks[_currentDataBlockIndex].DataPeriods[_position] : 0; // flip the current state FlipTapeState(); - } // update lastCycle and return currentstate _lastCycle = cpuCycle - (long)cycles; - // play the buzzer - //_buzzer.ProcessPulseValue(false, currentState); - return currentState; } @@ -649,6 +640,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// Flash loading implementation /// (Deterministic Emulation must be FALSE) + /// CURRENTLY NOT ENABLED/WORKING /// private bool FlashLoad() { @@ -962,47 +954,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (_machine.UPDDiskDevice == null || !_machine.UPDDiskDevice.FDD_IsDiskLoaded) MonitorRead(); - /* - - if (TapeIsPlaying) - { - if (GetEarBit(_cpu.TotalExecutedCycles)) - { - result &= ~(TAPE_BIT); // reset is EAR ON - } - else - { - result |= (TAPE_BIT); // set is EAR Off - } - } - else - { - if (_machine.KeyboardDevice.IsIssue2Keyboard) - { - if ((_machine.LASTULAOutByte & (EAR_BIT + MIC_BIT)) == 0) - { - result &= ~(TAPE_BIT); - } - else - { - result |= (TAPE_BIT); - } - } - else - { - if ((_machine.LASTULAOutByte & EAR_BIT) == 0) - { - result &= ~(TAPE_BIT); - } - else - { - result |= TAPE_BIT; - } - } - } - - */ - return true; } @@ -1032,19 +983,19 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// public void SyncState(Serializer ser) { - ser.BeginSection("DatacorderDevice"); - ser.Sync("counter", ref counter); - ser.Sync("_currentDataBlockIndex", ref _currentDataBlockIndex); - ser.Sync("_position", ref _position); - ser.Sync("_tapeIsPlaying", ref _tapeIsPlaying); - ser.Sync("_lastCycle", ref _lastCycle); - ser.Sync("_waitEdge", ref _waitEdge); - ser.Sync("currentState", ref currentState); - ser.Sync("_lastINCycle", ref _lastINCycle); - ser.Sync("_monitorCount", ref _monitorCount); - ser.Sync("_monitorTimeOut", ref _monitorTimeOut); - ser.Sync("_monitorLastPC", ref _monitorLastPC); - ser.Sync("_monitorLastRegs", ref _monitorLastRegs, false); + ser.BeginSection(nameof(DatacorderDevice)); + ser.Sync(nameof(counter), ref counter); + ser.Sync(nameof(_currentDataBlockIndex), ref _currentDataBlockIndex); + ser.Sync(nameof(_position), ref _position); + ser.Sync(nameof(_tapeIsPlaying), ref _tapeIsPlaying); + ser.Sync(nameof(_lastCycle), ref _lastCycle); + ser.Sync(nameof(_waitEdge), ref _waitEdge); + ser.Sync(nameof(currentState), ref currentState); + ser.Sync(nameof(_lastINCycle), ref _lastINCycle); + ser.Sync(nameof(_monitorCount), ref _monitorCount); + ser.Sync(nameof(_monitorTimeOut), ref _monitorTimeOut); + ser.Sync(nameof(_monitorLastPC), ref _monitorLastPC); + ser.Sync(nameof(_monitorLastRegs), ref _monitorLastRegs, false); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Definitions.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Definitions.cs index 0d025e4e24..cb49b7c6cf 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Definitions.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.Definitions.cs @@ -806,15 +806,15 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { ser.BeginSection("ActiveCmdParams"); - ser.Sync("UnitSelect", ref UnitSelect); - ser.Sync("Side", ref Side); - ser.Sync("Cylinder", ref Cylinder); - ser.Sync("Head", ref Head); - ser.Sync("Sector", ref Sector); - ser.Sync("SectorSize", ref SectorSize); - ser.Sync("EOT", ref EOT); - ser.Sync("Gap3Length", ref Gap3Length); - ser.Sync("DTL", ref DTL); + ser.Sync(nameof(UnitSelect), ref UnitSelect); + ser.Sync(nameof(Side), ref Side); + ser.Sync(nameof(Cylinder), ref Cylinder); + ser.Sync(nameof(Head), ref Head); + ser.Sync(nameof(Sector), ref Sector); + ser.Sync(nameof(SectorSize), ref SectorSize); + ser.Sync(nameof(EOT), ref EOT); + ser.Sync(nameof(Gap3Length), ref Gap3Length); + ser.Sync(nameof(DTL), ref DTL); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs index 62b42c7c09..b06daddf3c 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs @@ -362,6 +362,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // calculate maximum transfer capacity if (!CMD_FLAG_MF) maxTransferCap = 3328; + + if (maxTransferCap == 0) { } } else { @@ -655,6 +657,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum int buffPos = 0; int sectorSize = 0; int maxTransferCap = 0; + if (maxTransferCap > 0) { } // calculate requested size of data required if (ActiveCommandParams.SectorSize == 0) @@ -967,6 +970,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum int buffPos = 0; int sectorSize = 0; int maxTransferCap = 0; + if (maxTransferCap > 0) { } // calculate requested size of data required if (ActiveCommandParams.SectorSize == 0) @@ -1031,7 +1035,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum break; } - FloppyDisk.Sector sector = null; + //FloppyDisk.Sector sector = null; ActiveDrive.SectorIndex = 0; int secCount = 0; @@ -1371,7 +1375,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // get the first sector var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - int secIndex = 0; + //int secIndex = 0; for (int s = 0; s < track.Sectors.Length; s++) { if (track.Sectors[s].SectorID == endSecID) @@ -1422,7 +1426,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum byte endSecID = ActiveCommandParams.EOT; bool lastSec = false; var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - int secIndex = 0; + //int secIndex = 0; for (int s = 0; s < track.Sectors.Length; s++) { @@ -1664,7 +1668,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // get the first sector var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - int secIndex = 0; + //int secIndex = 0; for (int s = 0; s < track.Sectors.Length; s++) { if (track.Sectors[s].SectorID == endSecID) @@ -1715,7 +1719,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum byte endSecID = ActiveCommandParams.EOT; bool lastSec = false; var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - int secIndex = 0; + //int secIndex = 0; for (int s = 0; s < track.Sectors.Length; s++) { @@ -2404,7 +2408,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum return StatusMain; } - private int testCount = 0; + + //private int testCount = 0; /// /// Handles CPU reading from the data register /// diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs index 272930e904..f96ae1938f 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs @@ -869,28 +869,28 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public void SyncState(Serializer ser) { - ser.Sync("ID", ref ID); - ser.Sync("FLAG_WRITEPROTECT", ref FLAG_WRITEPROTECT); - //ser.Sync("FLAG_DISKCHANGED", ref FLAG_DISKCHANGED); - //ser.Sync("FLAG_RECALIBRATING", ref FLAG_RECALIBRATING); - //ser.Sync("FLAG_SEEK_INTERRUPT", ref FLAG_SEEK_INTERRUPT); - //ser.Sync("IntStatus", ref IntStatus); - //ser.Sync("ST0", ref ST0); - //ser.Sync("RecalibrationCounter", ref RecalibrationCounter); - ser.Sync("SeekCounter", ref SeekCounter); - ser.Sync("SeekStatus", ref SeekStatus); - ser.Sync("SeekAge", ref SeekAge); - ser.Sync("CurrentSide", ref CurrentSide); - //ser.Sync("CurrentTrack", ref CurrentTrack); - ser.Sync("TrackIndex", ref TrackIndex); - ser.Sync("SeekingTrack", ref SeekingTrack); - //ser.Sync("CurrentSector", ref CurrentSector); - ser.Sync("SectorIndex", ref SectorIndex); - //ser.Sync("RAngles", ref RAngles); - //ser.Sync("DataPointer", ref DataPointer); - //ser.SyncEnum("CurrentState", ref CurrentState); - //ser.SyncEnum("SeekState", ref SeekState); - //ser.SyncEnum("SeekIntState", ref SeekIntState); + ser.Sync(nameof(ID), ref ID); + ser.Sync(nameof(FLAG_WRITEPROTECT), ref FLAG_WRITEPROTECT); + //ser.Sync(nameof(FLAG_DISKCHANGED), ref FLAG_DISKCHANGED); + //ser.Sync(nameof(FLAG_RECALIBRATING), ref FLAG_RECALIBRATING); + //ser.Sync(nameof(FLAG_SEEK_INTERRUPT), ref FLAG_SEEK_INTERRUPT); + //ser.Sync(nameof(IntStatus), ref IntStatus); + //ser.Sync(nameof(ST0), ref ST0); + //ser.Sync(nameof(RecalibrationCounter), ref RecalibrationCounter); + ser.Sync(nameof(SeekCounter), ref SeekCounter); + ser.Sync(nameof(SeekStatus), ref SeekStatus); + ser.Sync(nameof(SeekAge), ref SeekAge); + ser.Sync(nameof(CurrentSide), ref CurrentSide); + //ser.Sync(nameof(CurrentTrack), ref CurrentTrack); + ser.Sync(nameof(TrackIndex), ref TrackIndex); + ser.Sync(nameof(SeekingTrack), ref SeekingTrack); + //ser.Sync(nameof(CurrentSector), ref CurrentSector); + ser.Sync(nameof(SectorIndex), ref SectorIndex); + //ser.Sync(nameof(RAngles), ref RAngles); + //ser.Sync(nameof(DataPointer), ref DataPointer); + //ser.SyncEnum(nameof(CurrentState), ref CurrentState); + //ser.SyncEnum(nameof(SeekState), ref SeekState); + //ser.SyncEnum(nameof(SeekIntState), ref SeekIntState); } #endregion diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.cs index a78c2f77df..d0c2c5ad20 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.cs @@ -159,7 +159,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum #region FDD - ser.Sync("FDD_FLAG_MOTOR", ref FDD_FLAG_MOTOR); + ser.Sync(nameof(FDD_FLAG_MOTOR), ref FDD_FLAG_MOTOR); for (int i = 0; i < 4; i++) { @@ -168,7 +168,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ser.EndSection(); } - ser.Sync("DiskDriveIndex", ref _diskDriveIndex); + ser.Sync(nameof(DiskDriveIndex), ref _diskDriveIndex); // set active drive DiskDriveIndex = _diskDriveIndex; @@ -186,55 +186,55 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum #region Controller state - ser.Sync("DriveLight", ref DriveLight); - ser.SyncEnum("ActivePhase", ref ActivePhase); - //ser.SyncEnum("ActiveDirection", ref ActiveDirection); - ser.SyncEnum("ActiveInterrupt", ref ActiveInterrupt); - ser.Sync("CommBuffer", ref CommBuffer, false); - ser.Sync("CommCounter", ref CommCounter); - ser.Sync("ResBuffer", ref ResBuffer, false); - ser.Sync("ExecBuffer", ref ExecBuffer, false); - ser.Sync("ExecCounter", ref ExecCounter); - ser.Sync("ExecLength", ref ExecLength); - ser.Sync("InterruptResultBuffer", ref InterruptResultBuffer, false); - ser.Sync("ResCounter", ref ResCounter); - ser.Sync("ResLength", ref ResLength); - ser.Sync("LastSectorDataWriteByte", ref LastSectorDataWriteByte); - ser.Sync("LastSectorDataReadByte", ref LastSectorDataReadByte); - ser.Sync("LastByteReceived", ref LastByteReceived); + ser.Sync(nameof(DriveLight), ref DriveLight); + ser.SyncEnum(nameof(ActivePhase), ref ActivePhase); + //ser.SyncEnum(nameof(ActiveDirection), ref ActiveDirection); + ser.SyncEnum(nameof(ActiveInterrupt), ref ActiveInterrupt); + ser.Sync(nameof(CommBuffer), ref CommBuffer, false); + ser.Sync(nameof(CommCounter), ref CommCounter); + ser.Sync(nameof(ResBuffer), ref ResBuffer, false); + ser.Sync(nameof(ExecBuffer), ref ExecBuffer, false); + ser.Sync(nameof(ExecCounter), ref ExecCounter); + ser.Sync(nameof(ExecLength), ref ExecLength); + ser.Sync(nameof(InterruptResultBuffer), ref InterruptResultBuffer, false); + ser.Sync(nameof(ResCounter), ref ResCounter); + ser.Sync(nameof(ResLength), ref ResLength); + ser.Sync(nameof(LastSectorDataWriteByte), ref LastSectorDataWriteByte); + ser.Sync(nameof(LastSectorDataReadByte), ref LastSectorDataReadByte); + ser.Sync(nameof(LastByteReceived), ref LastByteReceived); - ser.Sync("_cmdIndex", ref _cmdIndex); + ser.Sync(nameof(_cmdIndex), ref _cmdIndex); // resync the ActiveCommand CMDIndex = _cmdIndex; ActiveCommandParams.SyncState(ser); - ser.Sync("IndexPulseCounter", ref IndexPulseCounter); - //ser.SyncEnum("_activeStatus", ref _activeStatus); - //ser.SyncEnum("_statusRaised", ref _statusRaised); + ser.Sync(nameof(IndexPulseCounter), ref IndexPulseCounter); + //ser.SyncEnum(nameof(_activeStatus), ref _activeStatus); + //ser.SyncEnum(nameof(_statusRaised), ref _statusRaised); - ser.Sync("CMD_FLAG_MT", ref CMD_FLAG_MT); - ser.Sync("CMD_FLAG_MF", ref CMD_FLAG_MF); - ser.Sync("CMD_FLAG_SK", ref CMD_FLAG_SK); - ser.Sync("SRT", ref SRT); - ser.Sync("HUT", ref HUT); - ser.Sync("HLT", ref HLT); - ser.Sync("ND", ref ND); - ser.Sync("SRT_Counter", ref SRT_Counter); - ser.Sync("HUT_Counter", ref HUT_Counter); - ser.Sync("HLT_Counter", ref HLT_Counter); + ser.Sync(nameof(CMD_FLAG_MT), ref CMD_FLAG_MT); + ser.Sync(nameof(CMD_FLAG_MF), ref CMD_FLAG_MF); + ser.Sync(nameof(CMD_FLAG_SK), ref CMD_FLAG_SK); + ser.Sync(nameof(SRT), ref SRT); + ser.Sync(nameof(HUT), ref HUT); + ser.Sync(nameof(HLT), ref HLT); + ser.Sync(nameof(ND), ref ND); + ser.Sync(nameof(SRT_Counter), ref SRT_Counter); + ser.Sync(nameof(HUT_Counter), ref HUT_Counter); + ser.Sync(nameof(HLT_Counter), ref HLT_Counter); - ser.Sync("SectorDelayCounter", ref SectorDelayCounter); - ser.Sync("SectorID", ref SectorID); + ser.Sync(nameof(SectorDelayCounter), ref SectorDelayCounter); + ser.Sync(nameof(SectorID), ref SectorID); #endregion #region Timing - ser.Sync("LastCPUCycle", ref LastCPUCycle); - ser.Sync("StatusDelay", ref StatusDelay); - ser.Sync("TickCounter", ref TickCounter); - ser.Sync("DriveCycleCounter", ref DriveCycleCounter); + ser.Sync(nameof(LastCPUCycle), ref LastCPUCycle); + ser.Sync(nameof(StatusDelay), ref StatusDelay); + ser.Sync(nameof(TickCounter), ref TickCounter); + ser.Sync(nameof(DriveCycleCounter), ref DriveCycleCounter); #endregion diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/CursorJoystick.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/CursorJoystick.cs index e0828551f2..68606406ad 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/CursorJoystick.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/CursorJoystick.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// public class CursorJoystick : IJoystick { - private int _joyLine; + //private int _joyLine; private SpectrumBase _machine; #region Construction @@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public CursorJoystick(SpectrumBase machine, int playerNumber) { _machine = machine; - _joyLine = 0; + //_joyLine = 0; _playerNumber = playerNumber; ButtonCollection = new List diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/SinclairJoystick1.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/SinclairJoystick1.cs index e224646913..1b5cc0b779 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/SinclairJoystick1.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/SinclairJoystick1.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// public class SinclairJoystick1 : IJoystick { - private int _joyLine; + //private int _joyLine; private SpectrumBase _machine; #region Construction @@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public SinclairJoystick1(SpectrumBase machine, int playerNumber) { _machine = machine; - _joyLine = 0; + //_joyLine = 0; _playerNumber = playerNumber; ButtonCollection = new List diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/SinclairJoystick2.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/SinclairJoystick2.cs index 6533e76f23..4c391b41a8 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/SinclairJoystick2.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/SinclairJoystick2.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// public class SinclairJoystick2 : IJoystick { - private int _joyLine; + //private int _joyLine; private SpectrumBase _machine; #region Construction @@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public SinclairJoystick2(SpectrumBase machine, int playerNumber) { _machine = machine; - _joyLine = 0; + //_joyLine = 0; _playerNumber = playerNumber; ButtonCollection = new List diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/StandardKeyboard.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/StandardKeyboard.cs index 7e23f843a7..36a55e3d29 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/StandardKeyboard.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/StandardKeyboard.cs @@ -183,7 +183,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum return (byte)index; } - #region IPortIODevice /// @@ -279,8 +278,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public void SyncState(Serializer ser) { ser.BeginSection("Keyboard"); - ser.Sync("LineStatus", ref LineStatus, false); - ser.Sync("_keyLine", ref _keyLine, false); + ser.Sync(nameof(LineStatus), ref LineStatus, false); + ser.Sync(nameof(_keyLine), ref _keyLine, false); ser.EndSection(); } } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/AY38912.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/AY38912.cs index 9ed0a069b9..12c821f345 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/AY38912.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/AY38912.cs @@ -768,46 +768,46 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { ser.BeginSection("PSG-AY"); - ser.Sync("_tStatesPerFrame", ref _tStatesPerFrame); - ser.Sync("_sampleRate", ref _sampleRate); - ser.Sync("_samplesPerFrame", ref _samplesPerFrame); - ser.Sync("_tStatesPerSample", ref _tStatesPerSample); - ser.Sync("_audioBufferIndex", ref _audioBufferIndex); - ser.Sync("_audioBuffer", ref _audioBuffer, false); + ser.Sync(nameof(_tStatesPerFrame), ref _tStatesPerFrame); + ser.Sync(nameof(_sampleRate), ref _sampleRate); + ser.Sync(nameof(_samplesPerFrame), ref _samplesPerFrame); + ser.Sync(nameof(_tStatesPerSample), ref _tStatesPerSample); + ser.Sync(nameof(_audioBufferIndex), ref _audioBufferIndex); + ser.Sync(nameof(_audioBuffer), ref _audioBuffer, false); - ser.Sync("_registers", ref _registers, false); - ser.Sync("_activeRegister", ref _activeRegister); - ser.Sync("_bitA", ref _bitA); - ser.Sync("_bitB", ref _bitB); - ser.Sync("_bitC", ref _bitC); - ser.Sync("_eState", ref _eState); - ser.Sync("_eDirection", ref _eDirection); - ser.Sync("_noiseSeed", ref _noiseSeed); - ser.Sync("_bit0", ref _bit0); - ser.Sync("_bit1", ref _bit1); - ser.Sync("_bit2", ref _bit2); - ser.Sync("_bit3", ref _bit3); - ser.Sync("_bit4", ref _bit4); - ser.Sync("_bit5", ref _bit5); - ser.Sync("_bitN", ref _bitN); - ser.Sync("_eMaskA", ref _eMaskA); - ser.Sync("_eMaskB", ref _eMaskB); - ser.Sync("_eMaskC", ref _eMaskC); - ser.Sync("_vA", ref _vA); - ser.Sync("_vB", ref _vB); - ser.Sync("_vC", ref _vC); - ser.Sync("_countA", ref _countA); - ser.Sync("_countB", ref _countB); - ser.Sync("_countC", ref _countC); - ser.Sync("_countE", ref _countE); - ser.Sync("_countN", ref _countN); - ser.Sync("_dividerA", ref _dividerA); - ser.Sync("_dividerB", ref _dividerB); - ser.Sync("_dividerC", ref _dividerC); - ser.Sync("_dividerE", ref _dividerE); - ser.Sync("_dividerN", ref _dividerN); - ser.SyncEnum("_currentPanTab", ref _currentPanTab); - ser.Sync("_volume", ref nullDump); + ser.Sync(nameof(_registers), ref _registers, false); + ser.Sync(nameof(_activeRegister), ref _activeRegister); + ser.Sync(nameof(_bitA), ref _bitA); + ser.Sync(nameof(_bitB), ref _bitB); + ser.Sync(nameof(_bitC), ref _bitC); + ser.Sync(nameof(_eState), ref _eState); + ser.Sync(nameof(_eDirection), ref _eDirection); + ser.Sync(nameof(_noiseSeed), ref _noiseSeed); + ser.Sync(nameof(_bit0), ref _bit0); + ser.Sync(nameof(_bit1), ref _bit1); + ser.Sync(nameof(_bit2), ref _bit2); + ser.Sync(nameof(_bit3), ref _bit3); + ser.Sync(nameof(_bit4), ref _bit4); + ser.Sync(nameof(_bit5), ref _bit5); + ser.Sync(nameof(_bitN), ref _bitN); + ser.Sync(nameof(_eMaskA), ref _eMaskA); + ser.Sync(nameof(_eMaskB), ref _eMaskB); + ser.Sync(nameof(_eMaskC), ref _eMaskC); + ser.Sync(nameof(_vA), ref _vA); + ser.Sync(nameof(_vB), ref _vB); + ser.Sync(nameof(_vC), ref _vC); + ser.Sync(nameof(_countA), ref _countA); + ser.Sync(nameof(_countB), ref _countB); + ser.Sync(nameof(_countC), ref _countC); + ser.Sync(nameof(_countE), ref _countE); + ser.Sync(nameof(_countN), ref _countN); + ser.Sync(nameof(_dividerA), ref _dividerA); + ser.Sync(nameof(_dividerB), ref _dividerB); + ser.Sync(nameof(_dividerC), ref _dividerC); + ser.Sync(nameof(_dividerE), ref _dividerE); + ser.Sync(nameof(_dividerN), ref _dividerN); + ser.SyncEnum(nameof(_currentPanTab), ref _currentPanTab); + ser.Sync(nameof(_volume), ref nullDump); for (int i = 0; i < 6; i++) { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/Beeper.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/Beeper.cs index 5b518b031c..8ee5dc0067 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/Beeper.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/Beeper.cs @@ -8,9 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// Logical Beeper class /// Represents the piezoelectric buzzer used in the Spectrum to produce sound /// The beeper is controlled by rapidly toggling bit 4 of port &FE - /// /// It is instantiated twice, once for speccy beeper output, and once tape buzzer emulation - /// /// This implementation uses BlipBuffer and should *always* output at 44100 with 882 samples per frame /// (so that it can be mixed easily further down the line) /// @@ -206,10 +204,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public void SyncState(Serializer ser) { ser.BeginSection("Buzzer"); - ser.Sync("_tStatesPerFrame", ref _tStatesPerFrame); - ser.Sync("_sampleRate", ref _sampleRate); - ser.Sync("LastPulse", ref LastPulse); - ser.Sync("LastPulseTState", ref LastPulseTState); + ser.Sync(nameof(_tStatesPerFrame), ref _tStatesPerFrame); + ser.Sync(nameof(_sampleRate), ref _sampleRate); + ser.Sync(nameof(LastPulse), ref LastPulse); + ser.Sync(nameof(LastPulseTState), ref LastPulseTState); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/CPUMonitor.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/CPUMonitor.cs index e163d88682..eabdc7ff30 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/CPUMonitor.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/CPUMonitor.cs @@ -398,9 +398,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public void SyncState(Serializer ser) { - ser.BeginSection("CPUMonitor"); - ser.Sync("lastPortAddr", ref lastPortAddr); - ser.Sync("NextMemReadContended", ref NextMemReadContended); + ser.BeginSection(nameof(CPUMonitor)); + ser.Sync(nameof(lastPortAddr), ref lastPortAddr); + ser.Sync(nameof(NextMemReadContended), ref NextMemReadContended); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs index b64fa125eb..18345b0077 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs @@ -198,7 +198,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { if (!pressed_TapeStatus) { - //Spectrum.OSD_FireInputMessage(TapeStatus); Spectrum.OSD_ShowTapeStatus(); pressed_TapeStatus = true; } @@ -269,7 +268,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { if (!pressed_DiskStatus) { - //Spectrum.OSD_FireInputMessage(TapeStatus); Spectrum.OSD_ShowDiskStatus(); pressed_DiskStatus = true; } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Media.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Media.cs index 57525f6028..46d6a62de2 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Media.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Media.cs @@ -63,6 +63,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // load the media into the tape device tapeMediaIndex = result; + // fire osd message if (!IsLoadState) Spectrum.OSD_TapeInserted(); @@ -232,10 +233,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum Spectrum.CoreComm.ShowMessage("You are trying to load one of more disk images.\n\n Please select ZX Spectrum +3 emulation immediately and reboot the core"); return; } - else - { - //Spectrum.CoreComm.ShowMessage("You are attempting to load a disk into the +3 disk drive.\n\nThis DOES NOT currently work properly but IS under active development."); - } UPDDiskDevice.FDD_LoadDisk(diskImages[diskMediaIndex]); } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs index 7c39525cdf..475c0cd6bd 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Memory.cs @@ -199,6 +199,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// Monitors ROM access /// Used to auto start/stop the tape device when appropriate + /// * This isnt really used anymore for tape trap detection * /// /// public virtual void TestForTapeTraps(int addr) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Port.cs index d1c0f29271..3f5cb5a477 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Port.cs @@ -34,22 +34,5 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// public abstract void WritePort(ushort port, byte value); - - /// - /// Increments the CPU totalCycles counter by the tStates value specified - /// - /// - //public virtual void PortContention(int tStates) - //{ - // CPU.TotalExecutedCycles += tStates; - //} - - /// - /// Simulates IO port contention based on the supplied address - /// This method is for 48k and 128k/+2 machines only and should be overridden for other models - /// - /// - //public abstract void ContendPort(ushort addr); - } } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs index eca5cf0c54..8137e21ea5 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs @@ -72,11 +72,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// public virtual IJoystick[] JoystickCollection { get; set; } - /// - /// Signs whether the disk motor is on or off - /// - //protected bool DiskMotorState; - /// /// +3/2a printer port strobe /// @@ -153,8 +148,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum FrameCompleted = false; - if (UPDDiskDevice == null || !UPDDiskDevice.FDD_IsDiskLoaded) - TapeDevice.StartFrame(); + //if (UPDDiskDevice == null || !UPDDiskDevice.FDD_IsDiskLoaded) + //TapeDevice.StartFrame(); if (_renderSound) { @@ -326,34 +321,34 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public void SyncState(Serializer ser) { ser.BeginSection("ZXMachine"); - ser.Sync("FrameCompleted", ref FrameCompleted); - ser.Sync("OverFlow", ref OverFlow); - ser.Sync("FrameCount", ref FrameCount); - ser.Sync("_frameCycles", ref _frameCycles); - ser.Sync("inputRead", ref inputRead); - ser.Sync("LastFrameStartCPUTick", ref LastFrameStartCPUTick); - ser.Sync("LastULAOutByte", ref LastULAOutByte); - ser.Sync("ROM0", ref ROM0, false); - ser.Sync("ROM1", ref ROM1, false); - ser.Sync("ROM2", ref ROM2, false); - ser.Sync("ROM3", ref ROM3, false); - ser.Sync("RAM0", ref RAM0, false); - ser.Sync("RAM1", ref RAM1, false); - ser.Sync("RAM2", ref RAM2, false); - ser.Sync("RAM3", ref RAM3, false); - ser.Sync("RAM4", ref RAM4, false); - ser.Sync("RAM5", ref RAM5, false); - ser.Sync("RAM6", ref RAM6, false); - ser.Sync("RAM7", ref RAM7, false); - ser.Sync("ROMPaged", ref ROMPaged); - ser.Sync("SHADOWPaged", ref SHADOWPaged); - ser.Sync("RAMPaged", ref RAMPaged); - ser.Sync("PagingDisabled", ref PagingDisabled); - ser.Sync("SpecialPagingMode", ref SpecialPagingMode); - ser.Sync("PagingConfiguration", ref PagingConfiguration); - ser.Sync("ROMhigh", ref ROMhigh); - ser.Sync("ROMlow", ref ROMlow); - ser.Sync("LastContendedReadByte", ref LastContendedReadByte); + ser.Sync(nameof(FrameCompleted), ref FrameCompleted); + ser.Sync(nameof(OverFlow), ref OverFlow); + ser.Sync(nameof(FrameCount), ref FrameCount); + ser.Sync(nameof(_frameCycles), ref _frameCycles); + ser.Sync(nameof(inputRead), ref inputRead); + ser.Sync(nameof(LastFrameStartCPUTick), ref LastFrameStartCPUTick); + ser.Sync(nameof(LastULAOutByte), ref LastULAOutByte); + ser.Sync(nameof(ROM0), ref ROM0, false); + ser.Sync(nameof(ROM1), ref ROM1, false); + ser.Sync(nameof(ROM2), ref ROM2, false); + ser.Sync(nameof(ROM3), ref ROM3, false); + ser.Sync(nameof(RAM0), ref RAM0, false); + ser.Sync(nameof(RAM1), ref RAM1, false); + ser.Sync(nameof(RAM2), ref RAM2, false); + ser.Sync(nameof(RAM3), ref RAM3, false); + ser.Sync(nameof(RAM4), ref RAM4, false); + ser.Sync(nameof(RAM5), ref RAM5, false); + ser.Sync(nameof(RAM6), ref RAM6, false); + ser.Sync(nameof(RAM7), ref RAM7, false); + ser.Sync(nameof(ROMPaged), ref ROMPaged); + ser.Sync(nameof(SHADOWPaged), ref SHADOWPaged); + ser.Sync(nameof(RAMPaged), ref RAMPaged); + ser.Sync(nameof(PagingDisabled), ref PagingDisabled); + ser.Sync(nameof(SpecialPagingMode), ref SpecialPagingMode); + ser.Sync(nameof(PagingConfiguration), ref PagingConfiguration); + ser.Sync(nameof(ROMhigh), ref ROMhigh); + ser.Sync(nameof(ROMlow), ref ROMlow); + ser.Sync(nameof(LastContendedReadByte), ref LastContendedReadByte); KeyboardDevice.SyncState(ser); BuzzerDevice.SyncState(ser); @@ -367,7 +362,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ((AY38912)AYDevice as AY38912).PanningConfiguration = Spectrum.Settings.AYPanConfig; } - ser.Sync("tapeMediaIndex", ref tapeMediaIndex); + ser.Sync(nameof(tapeMediaIndex), ref tapeMediaIndex); if (ser.IsReader) { IsLoadState = true; @@ -378,7 +373,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum TapeDevice.SyncState(ser); - ser.Sync("diskMediaIndex", ref diskMediaIndex); + ser.Sync(nameof(diskMediaIndex), ref diskMediaIndex); if (ser.IsReader) { IsLoadState = true; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULA.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULA.cs index 00a3be3bef..df7541189e 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULA.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULA.cs @@ -785,7 +785,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// public int GetContentionValue(int tstate) { - //tstate += MemoryContentionOffset; if (tstate >= FrameCycleLength) tstate -= FrameCycleLength; @@ -801,7 +800,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// public int GetPortContentionValue(int tstate) { - //tstate += PortContentionOffset; if (tstate >= FrameCycleLength) tstate -= FrameCycleLength; @@ -1037,29 +1035,29 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public void SyncState(Serializer ser) { - ser.BeginSection("ULA"); + ser.BeginSection(nameof(ULA)); if (ScreenBuffer != null) - ser.Sync("ScreenBuffer", ref ScreenBuffer, false); - ser.Sync("BorderColor", ref BorderColor); - ser.Sync("LastTState", ref LastTState); - ser.Sync("flashOn", ref flashOn); - ser.Sync("fetchB1", ref fetchB1); - ser.Sync("fetchA1", ref fetchA1); - ser.Sync("fetchB2", ref fetchB2); - ser.Sync("fetchA2", ref fetchA2); - ser.Sync("ink", ref ink); - ser.Sync("paper", ref paper); - ser.Sync("fetchBorder", ref fetchBorder); - ser.Sync("bright", ref bright); - ser.Sync("flash", ref flash); - ser.Sync("palPaper", ref palPaper); - ser.Sync("palInk", ref palInk); + ser.Sync(nameof(ScreenBuffer), ref ScreenBuffer, false); + ser.Sync(nameof(BorderColor), ref BorderColor); + ser.Sync(nameof(LastTState), ref LastTState); + ser.Sync(nameof(flashOn), ref flashOn); + ser.Sync(nameof(fetchB1), ref fetchB1); + ser.Sync(nameof(fetchA1), ref fetchA1); + ser.Sync(nameof(fetchB2), ref fetchB2); + ser.Sync(nameof(fetchA2), ref fetchA2); + ser.Sync(nameof(ink), ref ink); + ser.Sync(nameof(paper), ref paper); + ser.Sync(nameof(fetchBorder), ref fetchBorder); + ser.Sync(nameof(bright), ref bright); + ser.Sync(nameof(flash), ref flash); + ser.Sync(nameof(palPaper), ref palPaper); + ser.Sync(nameof(palInk), ref palInk); - ser.Sync("LastULATick", ref LastULATick); - ser.Sync("ULACycleCounter", ref ULACycleCounter); - ser.Sync("FrameEnd", ref FrameEnd); + ser.Sync(nameof(LastULATick), ref LastULATick); + ser.Sync(nameof(ULACycleCounter), ref ULACycleCounter); + ser.Sync(nameof(FrameEnd), ref FrameEnd); - ser.Sync("InterruptRaised", ref InterruptRaised); + ser.Sync(nameof(InterruptRaised), ref InterruptRaised); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs index c27f74a265..f681ec3bd0 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs @@ -18,8 +18,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public ZX128Plus3(ZXSpectrum spectrum, Z80A cpu, ZXSpectrum.BorderType borderType, List files, List joysticks) { Spectrum = spectrum; - CPU = cpu; - + CPU = cpu; CPUMon = new CPUMonitor(this); CPUMon.machineType = MachineType.ZXSpectrum128Plus3; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.cs index 1f2508dd63..3291f5c20a 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.cs @@ -22,8 +22,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum CPU = cpu; CPUMon = new CPUMonitor(this); - - //ULADevice = new ULA48(this); ULADevice = new Screen48(this); BuzzerDevice = new Beeper(this); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/CPCFormat/CPCExtendedFloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/CPCFormat/CPCExtendedFloppyDisk.cs index fcc06fdd35..a52f1e3bbd 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/CPCFormat/CPCExtendedFloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/CPCFormat/CPCExtendedFloppyDisk.cs @@ -247,20 +247,20 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { ser.BeginSection("Plus3FloppyDisk"); - ser.Sync("CylinderCount", ref CylinderCount); - ser.Sync("SideCount", ref SideCount); - ser.Sync("BytesPerTrack", ref BytesPerTrack); - ser.Sync("WriteProtected", ref WriteProtected); - ser.SyncEnum("Protection", ref Protection); + ser.Sync(nameof(CylinderCount), ref CylinderCount); + ser.Sync(nameof(SideCount), ref SideCount); + ser.Sync(nameof(BytesPerTrack), ref BytesPerTrack); + ser.Sync(nameof(WriteProtected), ref WriteProtected); + ser.SyncEnum(nameof(Protection), ref Protection); - ser.Sync("DirtyData", ref DirtyData); + ser.Sync(nameof(DirtyData), ref DirtyData); if (DirtyData) { } // sync deterministic track and sector counters - ser.Sync(" _randomCounter", ref _randomCounter); + ser.Sync(nameof( _randomCounter), ref _randomCounter); RandomCounter = _randomCounter; ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/CPCFormat/CPCFloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/CPCFormat/CPCFloppyDisk.cs index 97f3b49cbf..05d99a88d1 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/CPCFormat/CPCFloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/CPCFormat/CPCFloppyDisk.cs @@ -241,13 +241,13 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { ser.BeginSection("Plus3FloppyDisk"); - ser.Sync("CylinderCount", ref CylinderCount); - ser.Sync("SideCount", ref SideCount); - ser.Sync("BytesPerTrack", ref BytesPerTrack); - ser.Sync("WriteProtected", ref WriteProtected); - ser.SyncEnum("Protection", ref Protection); + ser.Sync(nameof(CylinderCount), ref CylinderCount); + ser.Sync(nameof(SideCount), ref SideCount); + ser.Sync(nameof(BytesPerTrack), ref BytesPerTrack); + ser.Sync(nameof(WriteProtected), ref WriteProtected); + ser.SyncEnum(nameof(Protection), ref Protection); - ser.Sync("DirtyData", ref DirtyData); + ser.Sync(nameof(DirtyData), ref DirtyData); if (DirtyData) { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs index f99c0ae179..4ebf4ea26b 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs @@ -59,7 +59,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } catch (Exception ex) { - + var e = ex.ToString(); } } @@ -439,20 +439,20 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { ser.BeginSection("Plus3FloppyDisk"); - ser.Sync("CylinderCount", ref CylinderCount); - ser.Sync("SideCount", ref SideCount); - ser.Sync("BytesPerTrack", ref BytesPerTrack); - ser.Sync("WriteProtected", ref WriteProtected); - ser.SyncEnum("Protection", ref Protection); + ser.Sync(nameof(CylinderCount), ref CylinderCount); + ser.Sync(nameof(SideCount), ref SideCount); + ser.Sync(nameof(BytesPerTrack), ref BytesPerTrack); + ser.Sync(nameof(WriteProtected), ref WriteProtected); + ser.SyncEnum(nameof(Protection), ref Protection); - ser.Sync("DirtyData", ref DirtyData); + ser.Sync(nameof(DirtyData), ref DirtyData); if (DirtyData) { } // sync deterministic track and sector counters - ser.Sync(" _randomCounter", ref _randomCounter); + ser.Sync(nameof( _randomCounter), ref _randomCounter); RandomCounter = _randomCounter; ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/UDIFormat/UDI1_0FloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/UDIFormat/UDI1_0FloppyDisk.cs index d46908a73d..00297c69b7 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/UDIFormat/UDI1_0FloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/UDIFormat/UDI1_0FloppyDisk.cs @@ -141,9 +141,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum s1Pos += blockSize; } } - catch (Exception ex) + catch (Exception) { - + } @@ -195,20 +195,20 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { ser.BeginSection("Plus3FloppyDisk"); - ser.Sync("CylinderCount", ref CylinderCount); - ser.Sync("SideCount", ref SideCount); - ser.Sync("BytesPerTrack", ref BytesPerTrack); - ser.Sync("WriteProtected", ref WriteProtected); - ser.SyncEnum("Protection", ref Protection); + ser.Sync(nameof(CylinderCount), ref CylinderCount); + ser.Sync(nameof(SideCount), ref SideCount); + ser.Sync(nameof(BytesPerTrack), ref BytesPerTrack); + ser.Sync(nameof(WriteProtected), ref WriteProtected); + ser.SyncEnum(nameof(Protection), ref Protection); - ser.Sync("DirtyData", ref DirtyData); + ser.Sync(nameof(DirtyData), ref DirtyData); if (DirtyData) { } // sync deterministic track and sector counters - ser.Sync(" _randomCounter", ref _randomCounter); + ser.Sync(nameof( _randomCounter), ref _randomCounter); RandomCounter = _randomCounter; ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs index 6ada823be8..ed35aadf55 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs @@ -249,7 +249,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum dCount = GetInt32(b, pos); initPulseLevel = (uint)((dCount & 0x80000000) == 0 ? 0 : 1); - t.InitialPulseLevel = initPulseLevel == 1 ? true : false; + t.InitialPulseLevel = initPulseLevel == 1; dCount = (int)(dCount & 0x7FFFFFFF); pos += 4; @@ -334,7 +334,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum var d = GetInt32(b, pos); iniPulseLevel = ((d & 0x80000000) == 0 ? 0 : 1); - t.InitialPulseLevel = iniPulseLevel == 1 ? true : false; + t.InitialPulseLevel = iniPulseLevel == 1; pCount = (d & 0x7FFFFFFF); // convert to tape block diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TAP/TapConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TAP/TapConverter.cs index 97e1b448cf..a9ab6a895a 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TAP/TapConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TAP/TapConverter.cs @@ -335,7 +335,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } // add block pause - int actualPause = PAUSE_MS * 1000; + //int actualPause = PAUSE_MS * 1000; //dataPeriods.Add(actualPause); // default pause for tap files diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs index 052be1824f..1eca78ec5a 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs @@ -1312,9 +1312,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // get text length int strLen = data[_position++]; - string title = "Info: "; + string title = String.Empty; + title = "Info: "; - switch (type) + switch (type) { case 0x00: title = "Full Title: "; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs index adcc0eee97..ee82000d46 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs @@ -51,6 +51,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum set { _blockData = value; } } + /* + /// /// An array of bytearray encoded strings (stored in this format for easy Bizhawk serialization) /// Its basically tape information @@ -74,6 +76,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum return data; } } + */ #region Block Meta Data @@ -170,11 +173,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { ser.BeginSection("DataBlock" + blockPosition); - ser.Sync("_blockID", ref _blockID); - //ser.SyncFixedString("_blockDescription", ref _blockDescription, 200); - ser.SyncEnum("_blockType", ref _blockType); - ser.Sync("_blockData", ref _blockData, true); - ser.SyncEnum("_command", ref _command); + ser.Sync(nameof(_blockID), ref _blockID); + //ser.SyncFixedString(nameof(_blockDescription), ref _blockDescription, 200); + ser.SyncEnum(nameof(_blockType), ref _blockType); + ser.Sync(nameof(_blockData), ref _blockData, true); + ser.SyncEnum(nameof(_command), ref _command); int[] tempArray = null; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs index 07c8d3e300..030900e3c1 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs @@ -37,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// Position counter /// - private int _position = 0; + //private int _position = 0; #region Construction @@ -91,7 +91,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum "This is not a valid WAV format file"); } - _position = 0; + //_position = 0; MemoryStream stream = new MemoryStream(); stream.Write(data, 0, data.Length); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs index 1276521373..56e9f0d376 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IEmulator.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public ControllerDefinition ControllerDefinition { get; set; } - public void FrameAdvance(IController controller, bool render, bool renderSound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { _controller = controller; @@ -42,6 +42,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { _lagCount++; } + + return true; } public int Frame diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IMemoryDomains.cs index 16b439ed71..5a645c8d71 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IMemoryDomains.cs @@ -92,25 +92,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum SyncByteArrayDomain("RAM - BANK 7 (Shadow Screen)", _machine.RAM7); break; } - /* - SyncByteArrayDomain("ROM0", _machine.ROM0); - SyncByteArrayDomain("ROM1", _machine.ROM1); - SyncByteArrayDomain("ROM2", _machine.ROM2); - SyncByteArrayDomain("ROM3", _machine.ROM3); - SyncByteArrayDomain("RAM0", _machine.RAM0); - SyncByteArrayDomain("RAM1", _machine.RAM1); - SyncByteArrayDomain("RAM2", _machine.RAM2); - SyncByteArrayDomain("RAM3", _machine.RAM3); - SyncByteArrayDomain("RAM4", _machine.RAM4); - SyncByteArrayDomain("RAM5", _machine.RAM5); - SyncByteArrayDomain("RAM6", _machine.RAM6); - SyncByteArrayDomain("RAM7", _machine.RAM7); - */ } private void SyncByteArrayDomain(string name, byte[] data) - { - + { if (_memoryDomainsInit || _byteArrayDomains.ContainsKey(name)) { var m = _byteArrayDomains[name]; @@ -120,8 +105,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { var m = new MemoryDomainByteArray(name, MemoryDomain.Endian.Little, data, true, 1); _byteArrayDomains.Add(name, m); - } - + } } } } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs index 5d07d4fc07..096938717d 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs @@ -242,6 +242,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum Dictionary Data = new Dictionary(); + /// + /// Detailed info to be displayed within the settings UIs + /// + /// + /// public static ZXMachineMetaData GetMetaObject(MachineType type) { ZXMachineMetaData m = new ZXMachineMetaData(); @@ -345,6 +350,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum return m; } + /// + /// Returns machine metadata as a formatted string (to be displayed in a textbox) + /// + /// + /// public static string GetMetaString(MachineType type) { var m = GetMetaObject(type); @@ -380,7 +390,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // output the data splitting and tabbing as neccessary var arr = d.Value.Split(' '); - int cnt = 0; + //int cnt = 0; List builder = new List(); string working = ""; @@ -410,8 +420,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum sb.Append(builder[i]); sb.Append("\r\n"); } - - //sb.Append("\r\n"); } return sb.ToString(); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs index 74ab460903..c0b6b4b06d 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs @@ -56,10 +56,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (ser.IsWriter) { - ser.SyncEnum("_machineType", ref _machineType); + ser.SyncEnum(nameof(_machineType), ref _machineType); _cpu.SyncState(ser); - ser.BeginSection("ZXSpectrum"); + ser.BeginSection(nameof(ZXSpectrum)); _machine.SyncState(ser); ser.Sync("Frame", ref _machine.FrameCount); ser.Sync("LagCount", ref _lagCount); @@ -70,7 +70,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (ser.IsReader) { var tmpM = _machineType; - ser.SyncEnum("_machineType", ref _machineType); + ser.SyncEnum(nameof(_machineType), ref _machineType); if (tmpM != _machineType && _machineType.ToString() != "72") { string msg = "SAVESTATE FAILED TO LOAD!!\n\n"; @@ -85,7 +85,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum else { _cpu.SyncState(ser); - ser.BeginSection("ZXSpectrum"); + ser.BeginSection(nameof(ZXSpectrum)); _machine.SyncState(ser); ser.Sync("Frame", ref _machine.FrameCount); ser.Sync("LagCount", ref _lagCount); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Util.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Util.cs index d5a46ca3b3..21fd979f96 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Util.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Util.cs @@ -35,7 +35,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum _machine.WriteBus(addr, value); } - + /// + /// Called by MainForm so that the core label can display a more detailed tooltip about the emulated spectrum model + /// + /// public string GetMachineType() { string m = ""; @@ -59,17 +62,31 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum case MachineType.ZXSpectrum128Plus3: m = "(Amstrad) ZX Spectrum 128K +3"; break; + case MachineType.Pentagon128: + m = "(Clone) Pentagon 128K"; + break; } return m; } + /// + /// Called by MainForm - dumps a close approximation of the Spectaculator SZX snapshot format + /// DEV use only - this is nowhere near accurate + /// + /// public byte[] GetSZXSnapshot() { return SZX.ExportSZX(_machine); - //return System.Text.Encoding.Default.GetString(data); } + /// + /// Utility method to get MemberName from an object + /// + /// + /// + /// + /// public static string GetMemberName(Expression> memberAccess) { return ((MemberExpression)memberAccess.Body).Member.Name; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs index 1dad16b1d3..23585fb39f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IEmulator.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { _controller = controller; @@ -75,6 +75,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } _tia.LineCount = 0; + + return true; } public int Frame => _frame; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IStatable.cs index 69a1191c46..eabaf20fdc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IStatable.cs @@ -46,12 +46,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("Lag", ref _lagcount); ser.Sync("Frame", ref _frame); ser.Sync("IsLag", ref _islag); - ser.Sync("cyc_counter", ref cyc_counter); + ser.Sync(nameof(cyc_counter), ref cyc_counter); ser.Sync("leftDifficultySwitchPressed", ref _leftDifficultySwitchPressed); ser.Sync("rightDifficultySwitchPressed", ref _rightDifficultySwitchPressed); ser.Sync("leftDifficultySwitchHeld", ref _leftDifficultySwitchHeld); ser.Sync("rightDifficultySwitchHeld", ref _rightDifficultySwitchHeld); - ser.Sync("unselect_reset", ref unselect_reset); + ser.Sync(nameof(unselect_reset), ref unselect_reset); _tia.SyncState(ser); _m6532.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600ControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600ControllerDeck.cs index 89604f6516..2578acdd99 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600ControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600ControllerDeck.cs @@ -66,11 +66,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public void SyncState(Serializer ser) { - ser.BeginSection("Port1"); + ser.BeginSection(nameof(Port1)); Port1.SyncState(ser); ser.EndSection(); - ser.BeginSection("Port2"); + ser.BeginSection(nameof(Port2)); Port2.SyncState(ser); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs index e0d83199e8..f4b2856b94 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs @@ -178,7 +178,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public void SyncState(Serializer ser) { - ser.BeginSection("M6532"); + ser.BeginSection(nameof(M6532)); ser.Sync("ddra", ref _ddRa); ser.Sync("ddrb", ref _ddRb); ser.Sync("OutputA", ref _outputA); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs index bb6aa0783d..49d42d352a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs @@ -97,6 +97,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private byte _hmp0Val; private int _hmp1Delay; private byte _hmp1Val; + private int _hmm0Delay; + private byte _hmm0Val; + private int _hmm1Delay; + private byte _hmm1Val; + private int _hmbDelay; + private byte _hmbVal; private int _prg0Delay; private int _prg1Delay; @@ -104,6 +110,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private byte _prg1Val; private bool _doTicks; + private bool hmove_cnt_up; private byte _hsyncCnt; private long _capChargeStart; @@ -208,6 +215,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _hmp0Val = 0; _hmp1Delay = 0; _hmp1Val = 0; + _hmm0Delay = 0; + _hmm0Val = 0; + _hmm1Delay = 0; + _hmm1Val = 0; + _hmbDelay = 0; + _hmbVal = 0; _prg0Delay = 0; _prg1Delay = 0; @@ -338,13 +351,43 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 if (_hmp1Delay > 0) { _hmp1Delay++; - if (_hmp1Delay == 3) + if (_hmp1Delay == 4) { _hmp1Delay = 0; _player1.HM = _hmp1Val; } } + if (_hmm0Delay > 0) + { + _hmm0Delay++; + if (_hmm0Delay == 4) + { + _hmm0Delay = 0; + _player0.Missile.Hm = _hmm0Val; + } + } + + if (_hmm1Delay > 0) + { + _hmm1Delay++; + if (_hmm1Delay == 4) + { + _hmm1Delay = 0; + _player1.Missile.Hm = _hmm1Val; + } + } + + if (_hmbDelay > 0) + { + _hmbDelay++; + if (_hmbDelay == 4) + { + _hmbDelay = 0; + _ball.HM = _hmbVal; + } + } + // Reset the RDY flag when we reach hblank if (_hsyncCnt <= 0) { @@ -359,7 +402,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 if (_hsyncCnt >= (_hmove.LateHBlankReset ? 76 : 68)) { _doTicks = false; - + // TODO: Remove this magic number if ((_hsyncCnt / 4) >= 37) { @@ -614,7 +657,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _hmove.HMoveCnt++; _hmove.HMoveCnt %= 4; - if (_p0Stuff && _hsyncCnt % 4 == 0) + if (_p0Stuff) { _p0Stuff = false; @@ -636,7 +679,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } - if (_p1Stuff && _hsyncCnt % 4 == 0) + if (_p1Stuff) { _p1Stuff = false; @@ -658,7 +701,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } - if (_m0Stuff && _hsyncCnt % 4 == 0) + if (_m0Stuff) { _m0Stuff = false; @@ -680,7 +723,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } - if (_m1Stuff && _hsyncCnt % 4 == 0) + if (_m1Stuff) { _m1Stuff = false; @@ -702,7 +745,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } - if (_bStuff && _hsyncCnt % 4 == 0) + if (_bStuff) { _bStuff = false; @@ -725,15 +768,15 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } - if (_hmove.HMoveDelayCnt < 5) + if (hmove_cnt_up) { _hmove.HMoveDelayCnt++; } - if (_hmove.HMoveDelayCnt == 5) + if ((_hmove.HMoveDelayCnt >= 5) && hmove_cnt_up) { - _hmove.HMoveDelayCnt++; - _hmove.HMoveCnt = 0; + hmove_cnt_up = false; + _hmove.HMoveCnt = 4; _hmove.DecCntEnabled = true; _hmove.test_count_p0 = 0; @@ -1274,15 +1317,18 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } else if (maskedAddr == 0x22) // HMM0 { - _player0.Missile.Hm = (byte)((value & 0xF0) >> 4); + _hmm0Val = (byte)((value & 0xF0) >> 4); + _hmm0Delay = 1; } else if (maskedAddr == 0x23) // HMM1 { - _player1.Missile.Hm = (byte)((value & 0xF0) >> 4); + _hmm1Val = (byte)((value & 0xF0) >> 4); + _hmm1Delay = 1; } else if (maskedAddr == 0x24) // HMBL { - _ball.HM = (byte)((value & 0xF0) >> 4); + _hmbVal = (byte)((value & 0xF0) >> 4); + _hmbDelay = 1; } else if (maskedAddr == 0x25) // VDELP0 { @@ -1307,6 +1353,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 else if (maskedAddr == 0x2A) // HMOVE { _hmove.HMoveEnabled = true; + hmove_cnt_up = true; _hmove.HMoveDelayCnt = 0; } else if (maskedAddr == 0x2B) // HMCLR diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs index fb83e6ef0f..3c84e12bff 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs @@ -196,16 +196,16 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public void SyncState(Serializer ser) { - ser.Sync("AUDC", ref AUDC); - ser.Sync("AUDF", ref AUDF); - ser.Sync("AUDV", ref AUDV); - ser.Sync("sr1", ref sr1); - ser.Sync("sr3", ref sr3); - ser.Sync("sr4", ref sr4); - ser.Sync("sr5", ref sr5); - ser.Sync("sr9", ref sr9); - ser.Sync("freqcnt", ref freqcnt); - ser.Sync("on", ref on); + ser.Sync(nameof(AUDC), ref AUDC); + ser.Sync(nameof(AUDF), ref AUDF); + ser.Sync(nameof(AUDV), ref AUDV); + ser.Sync(nameof(sr1), ref sr1); + ser.Sync(nameof(sr3), ref sr3); + ser.Sync(nameof(sr4), ref sr4); + ser.Sync(nameof(sr5), ref sr5); + ser.Sync(nameof(sr9), ref sr9); + ser.Sync(nameof(freqcnt), ref freqcnt); + ser.Sync(nameof(on), ref on); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.BallData.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.BallData.cs index 93d7505343..f0b8bed111 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.BallData.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.BallData.cs @@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("denabled", ref Denabled); ser.Sync("delay", ref Delay); ser.Sync("size", ref Size); - ser.Sync("HM", ref HM); + ser.Sync(nameof(HM), ref HM); ser.Sync("hPosCnt", ref HPosCnt); ser.Sync("collisions", ref Collisions); ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.PlayerData.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.PlayerData.cs index 8700b4aebb..d57bc7d735 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.PlayerData.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.PlayerData.cs @@ -179,7 +179,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("hPosCnt", ref HPosCnt); ser.Sync("scanCnt", ref ScanCnt); ser.Sync("scanCntInit", ref ScanCntInit); - ser.Sync("HM", ref HM); + ser.Sync(nameof(HM), ref HM); ser.Sync("reflect", ref Reflect); ser.Sync("delay", ref Delay); ser.Sync("nusiz", ref Nusiz); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs index 1f3807247a..43ad77adb1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs @@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { public void SyncState(Serializer ser) { - ser.BeginSection("TIA"); + ser.BeginSection(nameof(TIA)); _ball.SyncState(ser); _hmove.SyncState(ser); ser.Sync("hsyncCnt", ref _hsyncCnt); @@ -44,6 +44,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("hmp0_val", ref _hmp0Val); ser.Sync("hmp1_delay", ref _hmp1Delay); ser.Sync("hmp1_val", ref _hmp1Val); + ser.Sync("hmm0_delay", ref _hmm0Delay); + ser.Sync("hmm0_val", ref _hmm0Val); + ser.Sync("hmm1_delay", ref _hmm1Delay); + ser.Sync("hmm1_val", ref _hmm1Val); + ser.Sync("hmb_delay", ref _hmbDelay); + ser.Sync("hmb_val", ref _hmbVal); ser.Sync("PRG0_delay", ref _prg0Delay); ser.Sync("PRG1_delay", ref _prg1Delay); @@ -51,6 +57,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("PRG1_val", ref _prg1Val); ser.Sync("Ticks", ref _doTicks); + ser.Sync(nameof(hmove_cnt_up), ref hmove_cnt_up); ser.Sync("VBlankDelay", ref _vblankDelay); ser.Sync("VBlankValue", ref _vblankValue); @@ -62,8 +69,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("vblankEnabled", ref _vblankEnabled); ser.Sync("vsyncEnabled", ref _vsyncEnabled); ser.Sync("CurrentScanLine", ref _currentScanLine); - ser.Sync("AudioClocks", ref AudioClocks); - ser.Sync("New_Frame", ref New_Frame); + ser.Sync(nameof(AudioClocks), ref AudioClocks); + ser.Sync(nameof(New_Frame), ref New_Frame); ser.BeginSection("Player0"); _player0.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs index 11ce9c8f23..667ee16c13 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IEmulator.cs @@ -57,7 +57,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public bool slow_access = false; public int slow_countdown; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { if (_tracer.Enabled) { @@ -88,6 +88,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { _lagcount++; } + + return true; } public void RunCPUCycle() diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs index 7a0b6d38fc..3203b0d194 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.IStatable.cs @@ -53,38 +53,38 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk ser.Sync("IsLag", ref _islag); _controllerDeck.SyncState(ser); - ser.Sync("A7800_control_register", ref A7800_control_register); - ser.Sync("_isPAL", ref _isPAL); + ser.Sync(nameof(A7800_control_register), ref A7800_control_register); + ser.Sync(nameof(_isPAL), ref _isPAL); - ser.Sync("Maria_regs", ref Maria_regs, false); - ser.Sync("RAM", ref RAM, false); - ser.Sync("RAM_6532", ref RAM_6532, false); - ser.Sync("hs_bios_mem", ref hs_bios_mem, false); + ser.Sync(nameof(Maria_regs), ref Maria_regs, false); + ser.Sync(nameof(RAM), ref RAM, false); + ser.Sync(nameof(RAM_6532), ref RAM_6532, false); + ser.Sync(nameof(hs_bios_mem), ref hs_bios_mem, false); - ser.Sync("cycle", ref cycle); - ser.Sync("cpu_cycle", ref cpu_cycle); - ser.Sync("cpu_is_haltable", ref cpu_is_haltable); - ser.Sync("cpu_is_halted", ref cpu_is_halted); - ser.Sync("cpu_halt_pending", ref cpu_halt_pending); - ser.Sync("cpu_resume_pending", ref cpu_resume_pending); + ser.Sync(nameof(cycle), ref cycle); + ser.Sync(nameof(cpu_cycle), ref cpu_cycle); + ser.Sync(nameof(cpu_is_haltable), ref cpu_is_haltable); + ser.Sync(nameof(cpu_is_halted), ref cpu_is_halted); + ser.Sync(nameof(cpu_halt_pending), ref cpu_halt_pending); + ser.Sync(nameof(cpu_resume_pending), ref cpu_resume_pending); - ser.Sync("slow_access", ref slow_access); - ser.Sync("slow_access", ref slow_countdown); + ser.Sync(nameof(slow_access), ref slow_access); + ser.Sync(nameof(slow_access), ref slow_countdown); ser.Sync("small flag", ref small_flag); ser.Sync("pal kara", ref PAL_Kara); ser.Sync("Cart RAM", ref cart_RAM); - ser.Sync("is_pokey", ref is_pokey); - ser.Sync("left_toggle", ref left_toggle); - ser.Sync("right_toggle", ref right_toggle); - ser.Sync("left_was_pressed", ref left_was_pressed); - ser.Sync("right_was_pressed", ref right_was_pressed); + ser.Sync(nameof(is_pokey), ref is_pokey); + ser.Sync(nameof(left_toggle), ref left_toggle); + ser.Sync(nameof(right_toggle), ref right_toggle); + ser.Sync(nameof(left_was_pressed), ref left_was_pressed); + ser.Sync(nameof(right_was_pressed), ref right_was_pressed); - ser.Sync("temp_s_tia", ref temp_s_tia); - ser.Sync("temp_s_pokey", ref temp_s_pokey); - ser.Sync("samp_l", ref samp_l); - ser.Sync("samp_c", ref samp_c); - ser.Sync("master_audio_clock", ref master_audio_clock); - ser.Sync("temp", ref temp); + ser.Sync(nameof(temp_s_tia), ref temp_s_tia); + ser.Sync(nameof(temp_s_pokey), ref temp_s_pokey); + ser.Sync(nameof(samp_l), ref samp_l); + ser.Sync(nameof(samp_c), ref samp_c); + ser.Sync(nameof(master_audio_clock), ref master_audio_clock); + ser.Sync(nameof(temp), ref temp); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs index 7d64189dca..2651c1f893 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800Hawk.cs @@ -172,7 +172,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk byte cart_1 = header[0x35]; byte cart_2 = header[0x36]; - _isPAL = (header[0x39] > 0) ? true : false; + _isPAL = (header[0x39] > 0); if (cart_2.Bit(1)) { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllerDeck.cs index 7c761c65b2..a796aedd30 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllerDeck.cs @@ -104,11 +104,11 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public void SyncState(Serializer ser) { - ser.BeginSection("Port1"); + ser.BeginSection(nameof(Port1)); Port1.SyncState(ser); ser.EndSection(); - ser.BeginSection("Port2"); + ser.BeginSection(nameof(Port2)); Port2.SyncState(ser); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs index 3241e128ca..85f62dc6bc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs @@ -158,7 +158,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk private static readonly string[] BaseDefinition = { - "Up", "Down", "Left", "Right", "Trigger" + "Up", "Down", "Left", "Right", "Button" }; private static byte[] HandControllerButtons = diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs index 50798c8fbc..cf2673517e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs @@ -196,7 +196,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public void SyncState(Serializer ser) { - ser.BeginSection("M6532"); + ser.BeginSection(nameof(M6532)); ser.Sync("ddra", ref _ddRa); ser.Sync("ddrb", ref _ddRb); ser.Sync("OutputA", ref _outputA); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs index 160b2a7679..964b5539fc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs @@ -102,7 +102,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public override void SyncState(Serializer ser) { - ser.Sync("RAM", ref RAM, false); + ser.Sync(nameof(RAM), ref RAM, false); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs index bf97fad11c..b308a2e500 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs @@ -167,7 +167,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public override void SyncState(Serializer ser) { ser.Sync("Bank", ref bank); - ser.Sync("RAM", ref RAM, false); + ser.Sync(nameof(RAM), ref RAM, false); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs index 5220d1b525..a82b2583cb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Maria.cs @@ -698,9 +698,9 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk // also since DMA is always killed at scanline boundaries, most related check variables are also not needed public void SyncState(Serializer ser) { - ser.BeginSection("Maria"); + ser.BeginSection(nameof(Maria)); - ser.Sync("GFX_index", ref GFX_index); + ser.Sync(nameof(GFX_index), ref GFX_index); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs index bafb4694cf..2b5d6ff334 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs @@ -311,21 +311,21 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public void SyncState(Serializer ser) { - ser.BeginSection("Pokey"); + ser.BeginSection(nameof(Pokey)); - ser.Sync("Regs", ref Regs, false); + ser.Sync(nameof(Regs), ref Regs, false); - ser.Sync("poly4", ref poly4); - ser.Sync("poly5", ref poly5); - ser.Sync("poly9", ref poly9); - ser.Sync("poly17", ref poly17); - ser.Sync("ch_div", ref ch_div, false); - ser.Sync("inc_ch", ref inc_ch, false); - ser.Sync("ch_out", ref ch_out, false); - ser.Sync("ch_src", ref ch_src, false); - ser.Sync("ch_vol", ref ch_vol, false); - ser.Sync("high_pass_1", ref high_pass_1); - ser.Sync("high_pass_2", ref high_pass_2); + ser.Sync(nameof(poly4), ref poly4); + ser.Sync(nameof(poly5), ref poly5); + ser.Sync(nameof(poly9), ref poly9); + ser.Sync(nameof(poly17), ref poly17); + ser.Sync(nameof(ch_div), ref ch_div, false); + ser.Sync(nameof(inc_ch), ref inc_ch, false); + ser.Sync(nameof(ch_out), ref ch_out, false); + ser.Sync(nameof(ch_src), ref ch_src, false); + ser.Sync(nameof(ch_vol), ref ch_vol, false); + ser.Sync(nameof(high_pass_1), ref high_pass_1); + ser.Sync(nameof(high_pass_2), ref high_pass_2); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs index cf5aa3e0c7..1bda5b3521 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs @@ -196,16 +196,16 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public void SyncState(Serializer ser) { - ser.Sync("AUDC", ref AUDC); - ser.Sync("AUDF", ref AUDF); - ser.Sync("AUDV", ref AUDV); - ser.Sync("sr1", ref sr1); - ser.Sync("sr3", ref sr3); - ser.Sync("sr4", ref sr4); - ser.Sync("sr5", ref sr5); - ser.Sync("sr9", ref sr9); - ser.Sync("freqcnt", ref freqcnt); - ser.Sync("on", ref on); + ser.Sync(nameof(AUDC), ref AUDC); + ser.Sync(nameof(AUDF), ref AUDF); + ser.Sync(nameof(AUDV), ref AUDV); + ser.Sync(nameof(sr1), ref sr1); + ser.Sync(nameof(sr3), ref sr3); + ser.Sync(nameof(sr4), ref sr4); + ser.Sync(nameof(sr5), ref sr5); + ser.Sync(nameof(sr9), ref sr9); + ser.Sync(nameof(freqcnt), ref freqcnt); + ser.Sync(nameof(on), ref on); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.SyncState.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.SyncState.cs index 89a2c50cfd..150358532d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.SyncState.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.SyncState.cs @@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { public void SyncState(Serializer ser) { - ser.BeginSection("TIA"); + ser.BeginSection(nameof(TIA)); ser.Sync("hsyncCnt", ref _hsyncCnt); @@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk // states were always taken at frame boundaries ser.Sync("capChargeStart", ref _capChargeStart); ser.Sync("capCharging", ref _capCharging); - ser.Sync("AudioClocks", ref AudioClocks); + ser.Sync(nameof(AudioClocks), ref AudioClocks); ser.Sync("FrameStartCycles", ref _frameStartCycles); ser.Sync("FrameEndCycles", ref _frameEndCycles); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs index e2c600f015..adad5e2c4b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.IStatable.cs @@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx { if (!LibLynx.BinStateSave(Core, _savebuff, _savebuff.Length)) { - throw new InvalidOperationException("Core's BinStateSave() returned false!"); + throw new InvalidOperationException($"Core's {nameof(LibLynx.BinStateSave)}() returned false!"); } writer.Write(_savebuff.Length); @@ -63,7 +63,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx reader.Read(_savebuff, 0, length); if (!LibLynx.BinStateLoad(Core, _savebuff, _savebuff.Length)) { - throw new InvalidOperationException("Core's BinStateLoad() returned false!"); + throw new InvalidOperationException($"Core's {nameof(LibLynx.BinStateLoad)}() returned false!"); } // other variables diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs index e234ae4455..24fb8a0095 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs @@ -120,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx public IEmulatorServiceProvider ServiceProvider { get; } - public void FrameAdvance(IController controller, bool render, bool rendersound = true) + public bool FrameAdvance(IController controller, bool render, bool rendersound = true) { Frame++; if (controller.IsPressed("Power")) @@ -135,6 +135,8 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx { LagCount++; } + + return true; } public int Frame { get; private set; } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/AY_3_8910_SGM.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/AY_3_8910_SGM.cs index 4f5c0eaca0..d1aef90365 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/AY_3_8910_SGM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/AY_3_8910_SGM.cs @@ -65,21 +65,21 @@ namespace BizHawk.Emulation.Cores.ColecoVision { ser.BeginSection("PSG"); - ser.Sync("Register", ref Register, false); + ser.Sync(nameof(Register), ref Register, false); - ser.Sync("psg_clock", ref psg_clock); - ser.Sync("clock_A", ref clock_A); - ser.Sync("clock_B", ref clock_B); - ser.Sync("clock_C", ref clock_C); - ser.Sync("noise_clock", ref noise_clock); - ser.Sync("env_clock", ref env_clock); - ser.Sync("A_up", ref A_up); - ser.Sync("B_up", ref B_up); - ser.Sync("C_up", ref C_up); - ser.Sync("noise", ref noise); - ser.Sync("env_E", ref env_E); - ser.Sync("E_up_down", ref E_up_down); - ser.Sync("port_sel", ref port_sel); + ser.Sync(nameof(psg_clock), ref psg_clock); + ser.Sync(nameof(clock_A), ref clock_A); + ser.Sync(nameof(clock_B), ref clock_B); + ser.Sync(nameof(clock_C), ref clock_C); + ser.Sync(nameof(noise_clock), ref noise_clock); + ser.Sync(nameof(env_clock), ref env_clock); + ser.Sync(nameof(A_up), ref A_up); + ser.Sync(nameof(B_up), ref B_up); + ser.Sync(nameof(C_up), ref C_up); + ser.Sync(nameof(noise), ref noise); + ser.Sync(nameof(env_E), ref env_E); + ser.Sync(nameof(E_up_down), ref E_up_down); + ser.Sync(nameof(port_sel), ref port_sel); sync_psg_state(); diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs index 162fe4f4f7..457cfd7388 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoControllerDeck.cs @@ -68,13 +68,13 @@ namespace BizHawk.Emulation.Cores.ColecoVision public void SyncState(Serializer ser) { - ser.BeginSection("Port1"); + ser.BeginSection(nameof(Port1)); Port1.SyncState(ser); - ser.Sync("temp_wheel1", ref temp_wheel1); + ser.Sync(nameof(temp_wheel1), ref temp_wheel1); ser.EndSection(); - ser.BeginSection("Port2"); - ser.Sync("temp_wheel2", ref temp_wheel2); + ser.BeginSection(nameof(Port2)); + ser.Sync(nameof(temp_wheel2), ref temp_wheel2); Port2.SyncState(ser); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs index 6d9dda125f..8d8c7b8b48 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IEmulator.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision public ControllerDefinition ControllerDefinition => ControllerDeck.Definition; - public void FrameAdvance(IController controller, bool render, bool renderSound) + public bool FrameAdvance(IController controller, bool render, bool renderSound) { _controller = controller; @@ -163,6 +163,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision { _lagCount++; } + + return true; } public bool use_SGM = false; diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs index c17eb19946..c5b767d73a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IStatable.cs @@ -58,15 +58,15 @@ namespace BizHawk.Emulation.Cores.ColecoVision PSG.SyncState(ser); SGM_sound.SyncState(ser); ser.Sync("UseSGM", ref use_SGM); - ser.Sync("is_MC", ref is_MC); - ser.Sync("MC_bank", ref MC_bank); + ser.Sync(nameof(is_MC), ref is_MC); + ser.Sync(nameof(MC_bank), ref MC_bank); ser.Sync("EnableSGMhigh", ref enable_SGM_high); ser.Sync("EnableSGMlow", ref enable_SGM_low); ser.Sync("Port_0x53", ref port_0x53); ser.Sync("Port_0x7F", ref port_0x7F); ser.Sync("RAM", ref _ram, false); - ser.Sync("SGM_high_RAM", ref SGM_high_RAM, false); - ser.Sync("SGM_low_RAM", ref SGM_low_RAM, false); + ser.Sync(nameof(SGM_high_RAM), ref SGM_high_RAM, false); + ser.Sync(nameof(SGM_low_RAM), ref SGM_low_RAM, false); ser.Sync("Frame", ref _frame); ser.Sync("LagCount", ref _lagCount); ser.Sync("IsLag", ref _isLag); diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/SN76489col.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/SN76489col.cs index 8cdd3e6026..265bfce147 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/SN76489col.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/SN76489col.cs @@ -53,28 +53,28 @@ namespace BizHawk.Emulation.Cores.ColecoVision { ser.BeginSection("SN76489"); - ser.Sync("Chan_vol", ref Chan_vol, false); - ser.Sync("Chan_tone", ref Chan_tone, false); + ser.Sync(nameof(Chan_vol), ref Chan_vol, false); + ser.Sync(nameof(Chan_tone), ref Chan_tone, false); ser.Sync("Chan_sel", ref chan_sel); - ser.Sync("vol_tone", ref vol_tone); - ser.Sync("noise_type", ref noise_type); - ser.Sync("noise_rate", ref noise_rate); + ser.Sync(nameof(vol_tone), ref vol_tone); + ser.Sync(nameof(noise_type), ref noise_type); + ser.Sync(nameof(noise_rate), ref noise_rate); ser.Sync("Clock_A", ref clock_A); ser.Sync("Clock_B", ref clock_B); ser.Sync("Clock_C", ref clock_C); - ser.Sync("noise_clock", ref noise_clock); - ser.Sync("noise_bit", ref noise_bit); + ser.Sync(nameof(noise_clock), ref noise_clock); + ser.Sync(nameof(noise_bit), ref noise_bit); - ser.Sync("psg_clock", ref psg_clock); + ser.Sync(nameof(psg_clock), ref psg_clock); - ser.Sync("A_up", ref A_up); - ser.Sync("B_up", ref B_up); - ser.Sync("C_up", ref C_up); - ser.Sync("noise", ref noise); + ser.Sync(nameof(A_up), ref A_up); + ser.Sync(nameof(B_up), ref B_up); + ser.Sync(nameof(C_up), ref C_up); + ser.Sync(nameof(noise), ref noise); - ser.Sync("current_sample", ref current_sample); + ser.Sync(nameof(current_sample), ref current_sample); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs index 9133312472..4453e69cac 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs @@ -511,13 +511,13 @@ namespace BizHawk.Emulation.Cores.ColecoVision public void SyncState(Serializer ser) { ser.BeginSection("VDP"); - ser.Sync("StatusByte", ref StatusByte); + ser.Sync(nameof(StatusByte), ref StatusByte); ser.Sync("WaitingForLatchByte", ref VdpWaitingForLatchByte); ser.Sync("Latch", ref VdpLatch); ser.Sync("ReadBuffer", ref VdpBuffer); - ser.Sync("VdpAddress", ref VdpAddress); - ser.Sync("Registers", ref Registers, false); - ser.Sync("VRAM", ref VRAM, false); + ser.Sync(nameof(VdpAddress), ref VdpAddress); + ser.Sync(nameof(Registers), ref Registers, false); + ser.Sync(nameof(VRAM), ref VRAM, false); ser.EndSection(); if (ser.IsReader) diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Cartridge.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Cartridge.cs index 71cf602d0e..de01986004 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Cartridge.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Cartridge.cs @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Intellivision ser.BeginSection("Cart"); ser.Sync("mapper", ref _mapper); - ser.Sync("Cart_Ram", ref Cart_Ram, false); + ser.Sync(nameof(Cart_Ram), ref Cart_Ram, false); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllerDeck.cs index fc242d5f67..f765c4fbf0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Controllers/IntellivisionControllerDeck.cs @@ -59,11 +59,11 @@ namespace BizHawk.Emulation.Cores.Intellivision public void SyncState(Serializer ser) { - ser.BeginSection("Port1"); + ser.BeginSection(nameof(Port1)); Port1.SyncState(ser); ser.EndSection(); - ser.BeginSection("Port2"); + ser.BeginSection(nameof(Port2)); Port2.SyncState(ser); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs index 7f7c1e717d..0d0dd5dee2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Intellivision public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { if (_tracer.Enabled) { @@ -124,6 +124,8 @@ namespace BizHawk.Emulation.Cores.Intellivision { SoftReset(); } + + return true; } public int Frame => _frame; diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs index 8a99dfc6c3..79d6c0c4e0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IStatable.cs @@ -43,16 +43,16 @@ namespace BizHawk.Emulation.Cores.Intellivision private void SyncState(Serializer ser) { int version = 1; - ser.BeginSection("Intellivision"); - ser.Sync("version", ref version); + ser.BeginSection(nameof(Intellivision)); + ser.Sync(nameof(version), ref version); ser.Sync("Frame", ref _frame); ser.Sync("stic_row", ref _sticRow); - ser.Sync("ScratchpadRam", ref ScratchpadRam, false); - ser.Sync("SystemRam", ref SystemRam, false); - ser.Sync("ExecutiveRom", ref ExecutiveRom, false); - ser.Sync("GraphicsRom", ref GraphicsRom, false); - ser.Sync("GraphicsRam", ref GraphicsRam, false); + ser.Sync(nameof(ScratchpadRam), ref ScratchpadRam, false); + ser.Sync(nameof(SystemRam), ref SystemRam, false); + ser.Sync(nameof(ExecutiveRom), ref ExecutiveRom, false); + ser.Sync(nameof(GraphicsRom), ref GraphicsRom, false); + ser.Sync(nameof(GraphicsRam), ref GraphicsRam, false); ser.Sync("islag", ref _islag); ser.Sync("lagcount", ref _lagcount); diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/PSG.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/PSG.cs index a15958359b..72c3ad7b81 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/PSG.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/PSG.cs @@ -118,24 +118,24 @@ namespace BizHawk.Emulation.Cores.Intellivision public void SyncState(Serializer ser) { - ser.BeginSection("PSG"); + ser.BeginSection(nameof(PSG)); - ser.Sync("Register", ref Register, false); + ser.Sync(nameof(Register), ref Register, false); ser.Sync("Toal_executed_cycles", ref TotalExecutedCycles); ser.Sync("Pending_Cycles", ref PendingCycles); - ser.Sync("psg_clock", ref psg_clock); - ser.Sync("clock_A", ref clock_A); - ser.Sync("clock_B", ref clock_B); - ser.Sync("clock_C", ref clock_C); - ser.Sync("noise_clock", ref noise_clock); - ser.Sync("env_clock", ref env_clock); - ser.Sync("A_up", ref A_up); - ser.Sync("B_up", ref B_up); - ser.Sync("C_up", ref C_up); - ser.Sync("noise", ref noise); - ser.Sync("env_E", ref env_E); - ser.Sync("E_up_down", ref E_up_down); + ser.Sync(nameof(psg_clock), ref psg_clock); + ser.Sync(nameof(clock_A), ref clock_A); + ser.Sync(nameof(clock_B), ref clock_B); + ser.Sync(nameof(clock_C), ref clock_C); + ser.Sync(nameof(noise_clock), ref noise_clock); + ser.Sync(nameof(env_clock), ref env_clock); + ser.Sync(nameof(A_up), ref A_up); + ser.Sync(nameof(B_up), ref B_up); + ser.Sync(nameof(C_up), ref C_up); + ser.Sync(nameof(noise), ref noise); + ser.Sync(nameof(env_E), ref env_E); + ser.Sync(nameof(E_up_down), ref E_up_down); sync_psg_state(); diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs index 856aea5f8e..dbb20b910c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs @@ -30,15 +30,15 @@ namespace BizHawk.Emulation.Cores.Intellivision public void SyncState(Serializer ser) { - ser.BeginSection("STIC"); + ser.BeginSection(nameof(STIC)); - ser.Sync("Sr1", ref Sr1); - ser.Sync("Sr2", ref Sr2); - ser.Sync("Sst", ref Sst); - ser.Sync("active_display", ref active_display); - ser.Sync("in_vb_1", ref in_vb_1); - ser.Sync("in_vb_2", ref in_vb_2); - ser.Sync("Fgbg", ref Fgbg); + ser.Sync(nameof(Sr1), ref Sr1); + ser.Sync(nameof(Sr2), ref Sr2); + ser.Sync(nameof(Sst), ref Sst); + ser.Sync(nameof(active_display), ref active_display); + ser.Sync(nameof(in_vb_1), ref in_vb_1); + ser.Sync(nameof(in_vb_2), ref in_vb_2); + ser.Sync(nameof(Fgbg), ref Fgbg); ser.Sync("Toal_executed_cycles", ref TotalExecutedCycles); ser.Sync("Pending_Cycles", ref PendingCycles); ser.Sync("Registers", ref Register, false); diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/O2Em.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/O2Em.cs index aaac852c81..b6b0a6ef6c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/O2Em.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/O2Em.cs @@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Magnavox if (!_core.Init(rom, rom.Length, bios, bios.Length)) - throw new InvalidOperationException("Init() failed"); + throw new InvalidOperationException($"{nameof(_core.Init)}() failed"); PostInit(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs index 0028c7b4e9..06c9737275 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs @@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA _core = LibmGBA.BizCreate(bios, file, file.Length, GetOverrideInfo(game), skipBios); if (_core == IntPtr.Zero) { - throw new InvalidOperationException("BizCreate() returned NULL! Bad BIOS? and/or ROM?"); + throw new InvalidOperationException($"{nameof(LibmGBA.BizCreate)}() returned NULL! Bad BIOS? and/or ROM?"); } try @@ -67,7 +67,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA public ControllerDefinition ControllerDefinition => GBA.GBAController; - public void FrameAdvance(IController controller, bool render, bool rendersound = true) + public bool FrameAdvance(IController controller, bool render, bool rendersound = true) { Frame++; if (controller.IsPressed("Power")) @@ -97,6 +97,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA // this should be called in hblank on the appropriate line, but until we implement that, just do it here _scanlinecb?.Invoke(); + + return true; } public int Frame { get; private set; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.ISaveRam.cs index 4058e83441..0f4feb4ac7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.ISaveRam.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA var data = new byte[LibVBANext.SaveRamSize(Core)]; if (!LibVBANext.SaveRamSave(Core, data, data.Length)) { - throw new InvalidOperationException("SaveRamSave() failed!"); + throw new InvalidOperationException($"{nameof(LibVBANext.SaveRamSave)}() failed!"); } return data; @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA // internally, we try to salvage bad-sized saverams if (!LibVBANext.SaveRamLoad(Core, data, data.Length)) { - throw new InvalidOperationException("SaveRamLoad() failed!"); + throw new InvalidOperationException($"{nameof(LibVBANext.SaveRamLoad)}() failed!"); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IStatable.cs index 514b3850c8..4456474a5c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IStatable.cs @@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA public void SaveStateBinary(BinaryWriter writer) { if (!LibVBANext.BinStateSave(Core, _savebuff, _savebuff.Length)) - throw new InvalidOperationException("Core's BinStateSave() returned false!"); + throw new InvalidOperationException($"Core's {nameof(LibVBANext.BinStateSave)}() returned false!"); writer.Write(_savebuff.Length); writer.Write(_savebuff); @@ -56,7 +56,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA throw new InvalidOperationException("Save buffer size mismatch!"); reader.Read(_savebuff, 0, length); if (!LibVBANext.BinStateLoad(Core, _savebuff, _savebuff.Length)) - throw new InvalidOperationException("Core's BinStateLoad() returned false!"); + throw new InvalidOperationException($"Core's {nameof(LibVBANext.BinStateLoad)}() returned false!"); // other variables IsLagFrame = reader.ReadBoolean(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs index 676210608f..72cb7af7ca 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs @@ -57,11 +57,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA Core = LibVBANext.Create(); if (Core == IntPtr.Zero) - throw new InvalidOperationException("Create() returned nullptr!"); + throw new InvalidOperationException($"{nameof(LibVBANext.Create)}() returned nullptr!"); try { if (!LibVBANext.LoadRom(Core, file, (uint)file.Length, biosfile, (uint)biosfile.Length, FES)) - throw new InvalidOperationException("LoadRom() returned false!"); + throw new InvalidOperationException($"{nameof(LibVBANext.LoadRom)}() returned false!"); Tracer = new TraceBuffer() { @@ -95,7 +95,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA public IEmulatorServiceProvider ServiceProvider { get; private set; } - public void FrameAdvance(IController controller, bool render, bool rendersound = true) + public bool FrameAdvance(IController controller, bool render, bool rendersound = true) { Frame++; @@ -108,6 +108,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA if (IsLagFrame) LagCount++; + + return true; } public int Frame { get; private set; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs index 4d16137978..52778985e4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs @@ -950,113 +950,113 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public void SyncState(Serializer ser) { - ser.Sync("Audio_Regs", ref Audio_Regs, false); + ser.Sync(nameof(Audio_Regs), ref Audio_Regs, false); ser.Sync("Wave_Ram", ref Wave_RAM, false); - ser.Sync("SQ1_vol_done", ref SQ1_vol_done); - ser.Sync("SQ1_calc_done", ref SQ1_calc_done); - ser.Sync("SQ1_swp_enable", ref SQ1_swp_enable); + ser.Sync(nameof(SQ1_vol_done), ref SQ1_vol_done); + ser.Sync(nameof(SQ1_calc_done), ref SQ1_calc_done); + ser.Sync(nameof(SQ1_swp_enable), ref SQ1_swp_enable); ser.Sync("SQ1_length_counter", ref SQ1_len_cntr); - ser.Sync("SQ1_enable", ref SQ1_enable); - ser.Sync("SQ1_vol_state", ref SQ1_vol_state); - ser.Sync("SQ1_duty_cntr", ref SQ1_duty_cntr); - ser.Sync("SQ1_frq_shadow", ref SQ1_frq_shadow); - ser.Sync("SQ1_intl_cntr", ref SQ1_intl_cntr); - ser.Sync("SQ1_vol_per", ref SQ1_vol_per); - ser.Sync("SQ1_intl_swp_cnt", ref SQ1_intl_swp_cnt); - ser.Sync("SQ1_len_cntr", ref SQ1_len_cntr); - ser.Sync("SQ1_negate", ref SQ1_negate); - ser.Sync("SQ1_trigger", ref SQ1_trigger); - ser.Sync("SQ1_len_en", ref SQ1_len_en); - ser.Sync("SQ1_env_add", ref SQ1_env_add); - ser.Sync("SQ1_shift", ref SQ1_shift); - ser.Sync("SQ1_duty", ref SQ1_duty); - ser.Sync("SQ1_st_vol", ref SQ1_st_vol); - ser.Sync("SQ1_per", ref SQ1_per); - ser.Sync("SQ1_swp_prd", ref SQ1_swp_prd); - ser.Sync("SQ1_frq", ref SQ1_frq); - ser.Sync("SQ1_length", ref SQ1_length); - ser.Sync("SQ1_output", ref SQ1_output); + ser.Sync(nameof(SQ1_enable), ref SQ1_enable); + ser.Sync(nameof(SQ1_vol_state), ref SQ1_vol_state); + ser.Sync(nameof(SQ1_duty_cntr), ref SQ1_duty_cntr); + ser.Sync(nameof(SQ1_frq_shadow), ref SQ1_frq_shadow); + ser.Sync(nameof(SQ1_intl_cntr), ref SQ1_intl_cntr); + ser.Sync(nameof(SQ1_vol_per), ref SQ1_vol_per); + ser.Sync(nameof(SQ1_intl_swp_cnt), ref SQ1_intl_swp_cnt); + ser.Sync(nameof(SQ1_len_cntr), ref SQ1_len_cntr); + ser.Sync(nameof(SQ1_negate), ref SQ1_negate); + ser.Sync(nameof(SQ1_trigger), ref SQ1_trigger); + ser.Sync(nameof(SQ1_len_en), ref SQ1_len_en); + ser.Sync(nameof(SQ1_env_add), ref SQ1_env_add); + ser.Sync(nameof(SQ1_shift), ref SQ1_shift); + ser.Sync(nameof(SQ1_duty), ref SQ1_duty); + ser.Sync(nameof(SQ1_st_vol), ref SQ1_st_vol); + ser.Sync(nameof(SQ1_per), ref SQ1_per); + ser.Sync(nameof(SQ1_swp_prd), ref SQ1_swp_prd); + ser.Sync(nameof(SQ1_frq), ref SQ1_frq); + ser.Sync(nameof(SQ1_length), ref SQ1_length); + ser.Sync(nameof(SQ1_output), ref SQ1_output); - ser.Sync("SQ2_vol_done", ref SQ2_vol_done); + ser.Sync(nameof(SQ2_vol_done), ref SQ2_vol_done); ser.Sync("SQ2_length_counter", ref SQ2_len_cntr); - ser.Sync("SQ2_enable", ref SQ2_enable); - ser.Sync("SQ2_vol_state", ref SQ2_vol_state); - ser.Sync("SQ2_duty_cntr", ref SQ2_duty_cntr); - ser.Sync("SQ2_intl_cntr", ref SQ2_intl_cntr); - ser.Sync("SQ2_vol_per", ref SQ2_vol_per); - ser.Sync("SQ2_len_cntr", ref SQ2_len_cntr); - ser.Sync("SQ2_trigger", ref SQ2_trigger); - ser.Sync("SQ2_len_en", ref SQ2_len_en); - ser.Sync("SQ2_env_add", ref SQ2_env_add); - ser.Sync("SQ2_duty", ref SQ2_duty); - ser.Sync("SQ2_st_vol", ref SQ2_st_vol); - ser.Sync("SQ2_per", ref SQ2_per); - ser.Sync("SQ2_frq", ref SQ2_frq); - ser.Sync("SQ2_length", ref SQ2_length); - ser.Sync("SQ2_output", ref SQ2_output); + ser.Sync(nameof(SQ2_enable), ref SQ2_enable); + ser.Sync(nameof(SQ2_vol_state), ref SQ2_vol_state); + ser.Sync(nameof(SQ2_duty_cntr), ref SQ2_duty_cntr); + ser.Sync(nameof(SQ2_intl_cntr), ref SQ2_intl_cntr); + ser.Sync(nameof(SQ2_vol_per), ref SQ2_vol_per); + ser.Sync(nameof(SQ2_len_cntr), ref SQ2_len_cntr); + ser.Sync(nameof(SQ2_trigger), ref SQ2_trigger); + ser.Sync(nameof(SQ2_len_en), ref SQ2_len_en); + ser.Sync(nameof(SQ2_env_add), ref SQ2_env_add); + ser.Sync(nameof(SQ2_duty), ref SQ2_duty); + ser.Sync(nameof(SQ2_st_vol), ref SQ2_st_vol); + ser.Sync(nameof(SQ2_per), ref SQ2_per); + ser.Sync(nameof(SQ2_frq), ref SQ2_frq); + ser.Sync(nameof(SQ2_length), ref SQ2_length); + ser.Sync(nameof(SQ2_output), ref SQ2_output); - ser.Sync("WAVE_can_get", ref WAVE_can_get); + ser.Sync(nameof(WAVE_can_get), ref WAVE_can_get); ser.Sync("WAVE_length_counter", ref WAVE_len_cntr); - ser.Sync("WAVE_enable", ref WAVE_enable); - ser.Sync("WAVE_wave_cntr", ref WAVE_wave_cntr); - ser.Sync("WAVE_intl_cntr", ref WAVE_intl_cntr); - ser.Sync("WAVE_len_cntr", ref WAVE_len_cntr); - ser.Sync("WAVE_DAC_pow", ref WAVE_DAC_pow); - ser.Sync("WAVE_trigger", ref WAVE_trigger); - ser.Sync("WAVE_len_en", ref WAVE_len_en); - ser.Sync("WAVE_vol_code", ref WAVE_vol_code); - ser.Sync("WAVE_frq", ref WAVE_frq); - ser.Sync("WAVE_length", ref WAVE_length); - ser.Sync("WAVE_output", ref WAVE_output); + ser.Sync(nameof(WAVE_enable), ref WAVE_enable); + ser.Sync(nameof(WAVE_wave_cntr), ref WAVE_wave_cntr); + ser.Sync(nameof(WAVE_intl_cntr), ref WAVE_intl_cntr); + ser.Sync(nameof(WAVE_len_cntr), ref WAVE_len_cntr); + ser.Sync(nameof(WAVE_DAC_pow), ref WAVE_DAC_pow); + ser.Sync(nameof(WAVE_trigger), ref WAVE_trigger); + ser.Sync(nameof(WAVE_len_en), ref WAVE_len_en); + ser.Sync(nameof(WAVE_vol_code), ref WAVE_vol_code); + ser.Sync(nameof(WAVE_frq), ref WAVE_frq); + ser.Sync(nameof(WAVE_length), ref WAVE_length); + ser.Sync(nameof(WAVE_output), ref WAVE_output); - ser.Sync("NOISE_vol_done", ref NOISE_vol_done); + ser.Sync(nameof(NOISE_vol_done), ref NOISE_vol_done); ser.Sync("NOISE_length_counter", ref NOISE_len_cntr); - ser.Sync("NOISE_enable", ref NOISE_enable); - ser.Sync("NOISE_vol_state", ref NOISE_vol_state); - ser.Sync("NOISE_intl_cntr", ref NOISE_intl_cntr); - ser.Sync("NOISE_vol_per", ref NOISE_vol_per); - ser.Sync("NOISE_LFSR", ref NOISE_LFSR); - ser.Sync("NOISE_len_cntr", ref NOISE_len_cntr); - ser.Sync("NOISE_wdth_md", ref NOISE_wdth_md); - ser.Sync("NOISE_trigger", ref NOISE_trigger); - ser.Sync("NOISE_len_en", ref NOISE_len_en); - ser.Sync("NOISE_env_add", ref NOISE_env_add); - ser.Sync("NOISE_clk_shft", ref NOISE_clk_shft); - ser.Sync("NOISE_div_code", ref NOISE_div_code); - ser.Sync("NOISE_st_vol", ref NOISE_st_vol); - ser.Sync("NOISE_per", ref NOISE_per); - ser.Sync("NOISE_length", ref NOISE_length); - ser.Sync("NOISE_output", ref NOISE_output); + ser.Sync(nameof(NOISE_enable), ref NOISE_enable); + ser.Sync(nameof(NOISE_vol_state), ref NOISE_vol_state); + ser.Sync(nameof(NOISE_intl_cntr), ref NOISE_intl_cntr); + ser.Sync(nameof(NOISE_vol_per), ref NOISE_vol_per); + ser.Sync(nameof(NOISE_LFSR), ref NOISE_LFSR); + ser.Sync(nameof(NOISE_len_cntr), ref NOISE_len_cntr); + ser.Sync(nameof(NOISE_wdth_md), ref NOISE_wdth_md); + ser.Sync(nameof(NOISE_trigger), ref NOISE_trigger); + ser.Sync(nameof(NOISE_len_en), ref NOISE_len_en); + ser.Sync(nameof(NOISE_env_add), ref NOISE_env_add); + ser.Sync(nameof(NOISE_clk_shft), ref NOISE_clk_shft); + ser.Sync(nameof(NOISE_div_code), ref NOISE_div_code); + ser.Sync(nameof(NOISE_st_vol), ref NOISE_st_vol); + ser.Sync(nameof(NOISE_per), ref NOISE_per); + ser.Sync(nameof(NOISE_length), ref NOISE_length); + ser.Sync(nameof(NOISE_output), ref NOISE_output); - ser.Sync("sequencer_len", ref sequencer_len); - ser.Sync("sequencer_vol", ref sequencer_vol); - ser.Sync("sequencer_swp", ref sequencer_swp); - ser.Sync("timer_bit_old", ref timer_bit_old); + ser.Sync(nameof(sequencer_len), ref sequencer_len); + ser.Sync(nameof(sequencer_vol), ref sequencer_vol); + ser.Sync(nameof(sequencer_swp), ref sequencer_swp); + ser.Sync(nameof(timer_bit_old), ref timer_bit_old); - ser.Sync("master_audio_clock", ref master_audio_clock); + ser.Sync(nameof(master_audio_clock), ref master_audio_clock); - ser.Sync("sample", ref sample); - ser.Sync("latched_sample_L", ref latched_sample_L); - ser.Sync("latched_sample_R", ref latched_sample_R); + ser.Sync(nameof(sample), ref sample); + ser.Sync(nameof(latched_sample_L), ref latched_sample_L); + ser.Sync(nameof(latched_sample_R), ref latched_sample_R); - ser.Sync("AUD_CTRL_vin_L_en", ref AUD_CTRL_vin_L_en); - ser.Sync("AUD_CTRL_vin_R_en", ref AUD_CTRL_vin_R_en); - ser.Sync("AUD_CTRL_sq1_L_en", ref AUD_CTRL_sq1_L_en); - ser.Sync("AUD_CTRL_sq2_L_en", ref AUD_CTRL_sq2_L_en); - ser.Sync("AUD_CTRL_wave_L_en", ref AUD_CTRL_wave_L_en); - ser.Sync("AUD_CTRL_noise_L_en", ref AUD_CTRL_noise_L_en); - ser.Sync("AUD_CTRL_sq1_R_en", ref AUD_CTRL_sq1_R_en); - ser.Sync("AUD_CTRL_sq2_R_en", ref AUD_CTRL_sq2_R_en); - ser.Sync("AUD_CTRL_wave_R_en", ref AUD_CTRL_wave_R_en); - ser.Sync("AUD_CTRL_noise_R_en", ref AUD_CTRL_noise_R_en); - ser.Sync("AUD_CTRL_power", ref AUD_CTRL_power); - ser.Sync("AUD_CTRL_vol_L", ref AUD_CTRL_vol_L); - ser.Sync("AUD_CTRL_vol_R", ref AUD_CTRL_vol_R); + ser.Sync(nameof(AUD_CTRL_vin_L_en), ref AUD_CTRL_vin_L_en); + ser.Sync(nameof(AUD_CTRL_vin_R_en), ref AUD_CTRL_vin_R_en); + ser.Sync(nameof(AUD_CTRL_sq1_L_en), ref AUD_CTRL_sq1_L_en); + ser.Sync(nameof(AUD_CTRL_sq2_L_en), ref AUD_CTRL_sq2_L_en); + ser.Sync(nameof(AUD_CTRL_wave_L_en), ref AUD_CTRL_wave_L_en); + ser.Sync(nameof(AUD_CTRL_noise_L_en), ref AUD_CTRL_noise_L_en); + ser.Sync(nameof(AUD_CTRL_sq1_R_en), ref AUD_CTRL_sq1_R_en); + ser.Sync(nameof(AUD_CTRL_sq2_R_en), ref AUD_CTRL_sq2_R_en); + ser.Sync(nameof(AUD_CTRL_wave_R_en), ref AUD_CTRL_wave_R_en); + ser.Sync(nameof(AUD_CTRL_noise_R_en), ref AUD_CTRL_noise_R_en); + ser.Sync(nameof(AUD_CTRL_power), ref AUD_CTRL_power); + ser.Sync(nameof(AUD_CTRL_vol_L), ref AUD_CTRL_vol_L); + ser.Sync(nameof(AUD_CTRL_vol_R), ref AUD_CTRL_vol_R); - ser.Sync("WAVE_output_decay", ref WAVE_output_decay); - ser.Sync("WAVE_output_decay_L", ref WAVE_output_decay_L); - ser.Sync("WAVE_output_decay_R", ref WAVE_output_decay_R); + ser.Sync(nameof(WAVE_output_decay), ref WAVE_output_decay); + ser.Sync(nameof(WAVE_output_decay_L), ref WAVE_output_decay_L); + ser.Sync(nameof(WAVE_output_decay_R), ref WAVE_output_decay_R); } public byte Read_NR52() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs index e6de37117d..c1d420be36 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs @@ -1,5 +1,4 @@ using System; -using BizHawk.Emulation.Common; using BizHawk.Common.NumberExtensions; using BizHawk.Common; @@ -38,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public byte HDMA_ctrl { - get { return (byte)(((HDMA_active ? 0 : 1) << 7) | ((HDMA_length >> 16) - 1)); } + get { return (byte)(((HDMA_active ? 0 : 1) << 7) | ((HDMA_length >> 4) - 1)); } } @@ -54,6 +53,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public int last_HBL; public bool HBL_HDMA_go; public bool HBL_test; + public byte LYC_t; + public int LYC_cd; public override byte ReadReg(int addr) { @@ -81,7 +82,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk case 0xFF54: ret = HDMA_dest_lo; break; // HDMA4 case 0xFF55: ret = HDMA_ctrl; break; // HDMA5 case 0xFF68: ret = BG_pal_ret; break; // BGPI - case 0xFF69: ret = BG_bytes[BG_bytes_index]; break; // BGPD + case 0xFF69: ret = BG_PAL_read(); break; // BGPD case 0xFF6A: ret = OBJ_pal_ret; break; // OBPI case 0xFF6B: ret = OBJ_bytes[OBJ_bytes_index]; break; // OBPD } @@ -89,6 +90,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk return ret; } + public byte BG_PAL_read() + { + if (VRAM_access_read) + { + return BG_bytes[BG_bytes_index]; + } + else + { + return 0xFF; + } + } + public override void WriteReg(int addr, byte value) { switch (addr) @@ -113,11 +126,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk case 0xFF41: // STAT // note that their is no stat interrupt bug in GBC // writing to STAT during mode 0 or 1 causes a STAT IRQ - if (LCDC.Bit(7) && !Core.GBC_compat) + if (LCDC.Bit(7)) { - if (((STAT & 3) == 0) || ((STAT & 3) == 1)) + if (!Core.GBC_compat) { - LYC_INT = true; + if (((STAT & 3) == 0) || ((STAT & 3) == 1)) + { + LYC_INT = true; + } + } + + if (value.Bit(6)) + { + if (LY == LYC) { LYC_INT = true; } + else { LYC_INT = false; } } } STAT = (byte)((value & 0xF8) | (STAT & 7) | 0x80); @@ -135,12 +157,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk LY = 0; /*reset*/ break; case 0xFF45: // LYC - LYC = value; - if (LCDC.Bit(7)) - { - if (LY != LYC) { STAT &= 0xFB; } - else { STAT |= 0x4; } - } + + // tests indicate that latching writes to LYC should take place 4 cycles after the write + // otherwise tests around LY boundaries will fail + LYC_t = value; + LYC_cd = 4; break; case 0xFF46: // DMA DMA_addr = value; @@ -231,8 +252,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk BG_bytes_inc = ((value & 0x80) == 0x80); break; case 0xFF69: // BGPD - BG_transfer_byte = value; - BG_bytes[BG_bytes_index] = value; + if (VRAM_access_write) + { + BG_transfer_byte = value; + BG_bytes[BG_bytes_index] = value; + } // change the appropriate palette color color_compute_BG(); @@ -362,7 +386,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk LY_inc = 1; Core.in_vblank = false; - STAT &= 0xFC; + //STAT &= 0xFC; // special note here, the y coordiate of the window is kept if the window is deactivated // meaning it will pick up where it left off if re-enabled later @@ -396,14 +420,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk STAT &= 0xFC; // also the LCD doesn't turn on right away - // also, the LCD does not enter mode 2 on scanline 0 when first turned on no_scan = true; cycle = 8; } // the VBL stat is continuously asserted - if ((LY >= 144)) + if (LY >= 144) { if (STAT.Bit(4)) { @@ -440,7 +463,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (STAT.Bit(5)) { VBL_INT = false; } } - if ((cycle == 6) && (LY == 153)) + if ((cycle == 8) && (LY == 153)) { LY = 0; LY_inc = 0; @@ -506,6 +529,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (LY != 0) { HBL_INT = false; + if (STAT.Bit(5)) { OAM_INT = true; } } } @@ -513,7 +537,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { // apparently, writes can make it to OAM one cycle longer then reads OAM_access_write = false; - + // here mode 2 will be set to true and interrupts fired if enabled STAT &= 0xFC; STAT |= 0x2; @@ -539,6 +563,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk OAM_INT = false; OAM_access_write = false; VRAM_access_write = false; + + // x-scroll is expected to be latched one cycle later + // this is fine since nothing has started in the rendering until the second cycle + // calculate the column number of the tile to start with + x_tile = (int)Math.Floor((float)(scroll_x) / 8); + render_offset = scroll_x % 8; } // render the screen and handle hblank @@ -556,12 +586,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (LY_inc == 0) { - if (cycle == 10) + if (cycle == 12) { LYC_INT = false; STAT &= 0xFB; } - else if (cycle == 12) + else if (cycle == 14) { // Special case of LY = LYC if ((LY == LYC) && !STAT.Bit(2)) @@ -574,7 +604,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } // here LY=LYC will be asserted or cleared (but only if LY isnt 0 as that's a special case) - if ((cycle == 2) && (LY != 0)) + if ((cycle == 4) && (LY != 0)) { if (LY_inc == 1) { @@ -582,7 +612,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk STAT &= 0xFB; } } - else if ((cycle == 4) && (LY != 0)) + else if ((cycle == 6) && (LY != 0)) { if ((LY == LYC) && !STAT.Bit(2)) { @@ -623,6 +653,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // process latch delays //latch_delay(); + + if (LYC_cd > 0) + { + LYC_cd--; + if (LYC_cd == 0) + { + LYC = LYC_t; + + if (LCDC.Bit(7)) + { + if (LY != LYC) { STAT &= 0xFB; LYC_INT = false; } + else { STAT |= 0x4; LYC_INT = true; } + } + } + } } // might be needed, not sure yet @@ -646,10 +691,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // window X is latched for the scanline, mid-line changes have no effect window_x_latch = window_x; - // calculate the column number of the tile to start with - x_tile = (int)Math.Floor((float)(scroll_x) / 8); - render_offset = scroll_x % 8; - OAM_scan_index = 0; read_case = 0; internal_cycle = 0; @@ -661,6 +702,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk fetch_sprite = false; going_to_fetch = false; first_fetch = true; + consecutive_sprite = -render_offset + 8; no_sprites = false; evaled_sprites = 0; window_pre_render = false; @@ -682,7 +724,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (SL_sprites_index == 0) { no_sprites = true; } // it is much easier to process sprites if we order them according to the rules of sprite priority first if (!no_sprites) { reorder_and_assemble_sprites(); } - } // before anything else, we have to check if windowing is in effect @@ -846,7 +887,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (pixel_counter == 160) { read_case = 8; - hbl_countdown = 1; } } else if (pixel_counter < 0) @@ -1093,23 +1133,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk case 8: // done reading, we are now in phase 0 pre_render = true; - // the other interrupts appear to be delayed by 1 CPU cycle, so do the same here - if (hbl_countdown > 0) - { - hbl_countdown--; - STAT &= 0xFC; - STAT |= 0x00; + STAT &= 0xFC; + STAT |= 0x00; - if (hbl_countdown == 0) - { - if (STAT.Bit(3)) { HBL_INT = true; } + if (STAT.Bit(3)) { HBL_INT = true; } - OAM_access_read = true; - OAM_access_write = true; - VRAM_access_read = true; - VRAM_access_write = true; - } - } + OAM_access_read = true; + OAM_access_write = true; + VRAM_access_read = true; + VRAM_access_write = true; break; case 9: @@ -1155,21 +1187,29 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } } + // x scroll offsets the penalty table // there is no penalty if the next sprites to be fetched are within the currentfetch block (8 pixels) if (first_fetch || (last_eval >= consecutive_sprite)) { - if ((last_eval % 8) == 0) { sprite_fetch_counter += 5; } - else if ((last_eval % 8) == 1) { sprite_fetch_counter += 4; } - else if ((last_eval % 8) == 2) { sprite_fetch_counter += 3; } - else if ((last_eval % 8) == 3) { sprite_fetch_counter += 2; } - else if ((last_eval % 8) == 4) { sprite_fetch_counter += 1; } - else if ((last_eval % 8) == 5) { sprite_fetch_counter += 0; } - else if ((last_eval % 8) == 6) { sprite_fetch_counter += 0; } - else if ((last_eval % 8) == 7) { sprite_fetch_counter += 0; } + if (((last_eval + render_offset) % 8) == 0) { sprite_fetch_counter += 5; } + else if (((last_eval + render_offset) % 8) == 1) { sprite_fetch_counter += 4; } + else if (((last_eval + render_offset) % 8) == 2) { sprite_fetch_counter += 3; } + else if (((last_eval + render_offset) % 8) == 3) { sprite_fetch_counter += 2; } + else if (((last_eval + render_offset) % 8) == 4) { sprite_fetch_counter += 1; } + else if (((last_eval + render_offset) % 8) == 5) { sprite_fetch_counter += 0; } + else if (((last_eval + render_offset) % 8) == 6) { sprite_fetch_counter += 0; } + else if (((last_eval + render_offset) % 8) == 7) { sprite_fetch_counter += 0; } + + consecutive_sprite = (int)Math.Floor((double)(last_eval + render_offset) / 8) * 8 + 8 - render_offset; + + // special case exists here for sprites at zero with non-zero x-scroll. Not sure exactly the reason for it. + if (last_eval == 0 && render_offset != 0) + { + sprite_fetch_counter += render_offset; + } } total_counter += sprite_fetch_counter; - consecutive_sprite = last_eval + (8 - (last_eval % 8)); first_fetch = false; } @@ -1492,31 +1532,34 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { ser.Sync("pal_transfer_byte", ref BG_transfer_byte); ser.Sync("spr_transfer_byte", ref OBJ_transfer_byte); - ser.Sync("HDMA_src_hi", ref HDMA_src_hi); - ser.Sync("HDMA_src_lo", ref HDMA_src_lo); - ser.Sync("HDMA_dest_hi", ref HDMA_dest_hi); - ser.Sync("HDMA_dest_lo", ref HDMA_dest_lo); - ser.Sync("HDMA_tick", ref HDMA_tick); - ser.Sync("HDMA_byte", ref HDMA_byte); + ser.Sync(nameof(HDMA_src_hi), ref HDMA_src_hi); + ser.Sync(nameof(HDMA_src_lo), ref HDMA_src_lo); + ser.Sync(nameof(HDMA_dest_hi), ref HDMA_dest_hi); + ser.Sync(nameof(HDMA_dest_lo), ref HDMA_dest_lo); + ser.Sync(nameof(HDMA_tick), ref HDMA_tick); + ser.Sync(nameof(HDMA_byte), ref HDMA_byte); - ser.Sync("VRAM_sel", ref VRAM_sel); - ser.Sync("BG_V_flip", ref BG_V_flip); - ser.Sync("HDMA_mode", ref HDMA_mode); - ser.Sync("cur_DMA_src", ref cur_DMA_src); - ser.Sync("cur_DMA_dest", ref cur_DMA_dest); - ser.Sync("HDMA_length", ref HDMA_length); - ser.Sync("HDMA_countdown", ref HDMA_countdown); - ser.Sync("HBL_HDMA_count", ref HBL_HDMA_count); - ser.Sync("last_HBL", ref last_HBL); - ser.Sync("HBL_HDMA_go", ref HBL_HDMA_go); - ser.Sync("HBL_test", ref HBL_test); + ser.Sync(nameof(VRAM_sel), ref VRAM_sel); + ser.Sync(nameof(BG_V_flip), ref BG_V_flip); + ser.Sync(nameof(HDMA_mode), ref HDMA_mode); + ser.Sync(nameof(cur_DMA_src), ref cur_DMA_src); + ser.Sync(nameof(cur_DMA_dest), ref cur_DMA_dest); + ser.Sync(nameof(HDMA_length), ref HDMA_length); + ser.Sync(nameof(HDMA_countdown), ref HDMA_countdown); + ser.Sync(nameof(HBL_HDMA_count), ref HBL_HDMA_count); + ser.Sync(nameof(last_HBL), ref last_HBL); + ser.Sync(nameof(HBL_HDMA_go), ref HBL_HDMA_go); + ser.Sync(nameof(HBL_test), ref HBL_test); - ser.Sync("BG_bytes", ref BG_bytes, false); - ser.Sync("OBJ_bytes", ref OBJ_bytes, false); - ser.Sync("BG_bytes_inc", ref BG_bytes_inc); - ser.Sync("OBJ_bytes_inc", ref OBJ_bytes_inc); - ser.Sync("BG_bytes_index", ref BG_bytes_index); - ser.Sync("OBJ_bytes_index", ref OBJ_bytes_index); + ser.Sync(nameof(BG_bytes), ref BG_bytes, false); + ser.Sync(nameof(OBJ_bytes), ref OBJ_bytes, false); + ser.Sync(nameof(BG_bytes_inc), ref BG_bytes_inc); + ser.Sync(nameof(OBJ_bytes_inc), ref OBJ_bytes_inc); + ser.Sync(nameof(BG_bytes_index), ref BG_bytes_index); + ser.Sync(nameof(OBJ_bytes_index), ref OBJ_bytes_index); + + ser.Sync(nameof(LYC_t), ref LYC_t); + ser.Sync(nameof(LYC_cd), ref LYC_cd); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs index be2812ef86..ca42c1472e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs @@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public bool in_vblank; public bool vblank_rise; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { //Console.WriteLine("-----------------------FRAME-----------------------"); @@ -74,6 +74,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { _lagcount++; } + + return true; } public void do_frame() @@ -159,7 +161,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } ticker++; - //if (ticker > 10000000) { vblank_rise = true; }//throw new Exception("ERROR: Unable to Resolve Frame"); } + // if (ticker > 10000000) { vblank_rise = true; }//throw new Exception("ERROR: Unable to Resolve Frame"); } in_vblank_old = in_vblank; REG_FF0F_OLD = REG_FF0F; @@ -168,6 +170,89 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk vblank_rise = false; } + public void do_single_step() + { + // These things do not change speed in GBC double spped mode + audio.tick(); + ppu.tick(); + if (Use_MT) { mapper.Mapper_Tick(); } + + if (!HDMA_transfer) + { + // These things all tick twice as fast in GBC double speed mode + ppu.DMA_tick(); + timer.tick_1(); + serialport.serial_transfer_tick(); + cpu.ExecuteOne(ref REG_FF0F, REG_FFFF); + timer.tick_2(); + + if (double_speed) + { + ppu.DMA_tick(); + timer.tick_1(); + serialport.serial_transfer_tick(); + cpu.ExecuteOne(ref REG_FF0F, REG_FFFF); + timer.tick_2(); + } + } + else + { + timer.tick_1(); + timer.tick_2(); + cpu.TotalExecutedCycles++; + if (double_speed) + { + timer.tick_1(); + timer.tick_2(); + cpu.TotalExecutedCycles++; + } + } + + if (in_vblank && !in_vblank_old) + { + vblank_rise = true; + } + + in_vblank_old = in_vblank; + REG_FF0F_OLD = REG_FF0F; + } + + public void do_controller_check() + { + // check if new input changed the input register and triggered IRQ + byte contr_prev = input_register; + + input_register &= 0xF0; + if ((input_register & 0x30) == 0x20) + { + input_register |= (byte)(controller_state & 0xF); + } + else if ((input_register & 0x30) == 0x10) + { + input_register |= (byte)((controller_state & 0xF0) >> 4); + } + else if ((input_register & 0x30) == 0x00) + { + // if both polls are set, then a bit is zero if either or both pins are zero + byte temp = (byte)((controller_state & 0xF) & ((controller_state & 0xF0) >> 4)); + input_register |= temp; + } + else + { + input_register |= 0xF; + } + + // check for interrupts + if (((contr_prev & 8) > 0) && ((input_register & 8) == 0) || + ((contr_prev & 4) > 0) && ((input_register & 4) == 0) || + ((contr_prev & 2) > 0) && ((input_register & 2) == 0) || + ((contr_prev & 1) > 0) && ((input_register & 1) == 0)) + { + if (REG_FFFF.Bit(4)) { cpu.FlagI = true; } + REG_FF0F |= 0x10; + } + } + // Switch Speed (GBC only) public int SpeedFunc(int temp) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISettable.cs index b6acb3d8d0..bdc6d40ff0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISettable.cs @@ -129,7 +129,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk [JsonIgnore] private int _RTCInitialTime; [JsonIgnore] - public ushort _DivInitialTime; + public ushort _DivInitialTime = 8; public GBSyncSettings Clone() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IStatable.cs index 104274715c..74cd3fa611 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IStatable.cs @@ -55,53 +55,59 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk audio.SyncState(ser); ser.BeginSection("Gameboy"); - ser.Sync("core", ref core, false); + ser.Sync(nameof(core), ref core, false); ser.Sync("Lag", ref _lagcount); ser.Sync("Frame", ref _frame); ser.Sync("IsLag", ref _islag); _controllerDeck.SyncState(ser); - ser.Sync("controller_state", ref controller_state); - ser.Sync("Acc_X_state", ref Acc_X_state); - ser.Sync("Acc_Y_state", ref Acc_Y_state); - ser.Sync("in_vblank", ref in_vblank); - ser.Sync("in_vblank_old", ref in_vblank_old); - ser.Sync("vblank_rise", ref vblank_rise); - ser.Sync("GB_bios_register", ref GB_bios_register); - ser.Sync("input_register", ref input_register); + ser.Sync(nameof(controller_state), ref controller_state); + ser.Sync(nameof(Acc_X_state), ref Acc_X_state); + ser.Sync(nameof(Acc_Y_state), ref Acc_Y_state); + ser.Sync(nameof(in_vblank), ref in_vblank); + ser.Sync(nameof(in_vblank_old), ref in_vblank_old); + ser.Sync(nameof(vblank_rise), ref vblank_rise); + ser.Sync(nameof(GB_bios_register), ref GB_bios_register); + ser.Sync(nameof(input_register), ref input_register); - ser.Sync("REG_FFFF", ref REG_FFFF); - ser.Sync("REG_FF0F", ref REG_FF0F); - ser.Sync("REG_FF0F_OLD", ref REG_FF0F_OLD); + ser.Sync(nameof(REG_FFFF), ref REG_FFFF); + ser.Sync(nameof(REG_FF0F), ref REG_FF0F); + ser.Sync(nameof(REG_FF0F_OLD), ref REG_FF0F_OLD); // memory domains - ser.Sync("RAM", ref RAM, false); - ser.Sync("ZP_RAM", ref ZP_RAM, false); - ser.Sync("VRAM", ref VRAM, false); - ser.Sync("OAM", ref OAM, false); + ser.Sync(nameof(RAM), ref RAM, false); + ser.Sync(nameof(ZP_RAM), ref ZP_RAM, false); + ser.Sync(nameof(VRAM), ref VRAM, false); + ser.Sync(nameof(OAM), ref OAM, false); - ser.Sync("_bios", ref _bios, false); + ser.Sync(nameof(_bios), ref _bios, false); - ser.Sync("RAM_Bank", ref RAM_Bank); - ser.Sync("VRAM_Bank", ref VRAM_Bank); - ser.Sync("is_GBC", ref is_GBC); - ser.Sync("GBC_compat", ref GBC_compat); - ser.Sync("double_speed", ref double_speed); - ser.Sync("speed_switch", ref speed_switch); - ser.Sync("HDMA_transfer", ref HDMA_transfer); + ser.Sync(nameof(RAM_Bank), ref RAM_Bank); + ser.Sync(nameof(VRAM_Bank), ref VRAM_Bank); + ser.Sync(nameof(is_GBC), ref is_GBC); + ser.Sync(nameof(GBC_compat), ref GBC_compat); + ser.Sync(nameof(double_speed), ref double_speed); + ser.Sync(nameof(speed_switch), ref speed_switch); + ser.Sync(nameof(HDMA_transfer), ref HDMA_transfer); - ser.Sync("Use_MT", ref Use_MT); - ser.Sync("addr_access", ref addr_access); + ser.Sync(nameof(undoc_6C), ref undoc_6C); + ser.Sync(nameof(undoc_72), ref undoc_72); + ser.Sync(nameof(undoc_73), ref undoc_73); + ser.Sync(nameof(undoc_74), ref undoc_74); + ser.Sync(nameof(undoc_75), ref undoc_75); + ser.Sync(nameof(undoc_76), ref undoc_76); + ser.Sync(nameof(undoc_77), ref undoc_77); + + ser.Sync(nameof(Use_MT), ref Use_MT); + ser.Sync(nameof(addr_access), ref addr_access); // probably a better way to do this if (cart_RAM != null) { - ser.Sync("cart_RAM", ref cart_RAM, false); + ser.Sync(nameof(cart_RAM), ref cart_RAM, false); } - - - ser.EndSection(); + ser.EndSection(); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs index 2532554bc7..00e89a039e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs @@ -3,7 +3,6 @@ using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.Components.LR35902; -using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy; using System.Runtime.InteropServices; @@ -56,6 +55,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public bool speed_switch; public bool HDMA_transfer; // stalls CPU when in progress + // several undocumented GBC Registers + public byte undoc_6C, undoc_72, undoc_73, undoc_74, undoc_75, undoc_76, undoc_77; + public byte[] _bios; public readonly byte[] _rom; public readonly byte[] header = new byte[0x50]; @@ -272,10 +274,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk private readonly GBHawkControllerDeck _controllerDeck; - private void HardReset() + public void HardReset() { GB_bios_register = 0; // bios enable - GBC_compat = true; + GBC_compat = is_GBC; in_vblank = true; // we start off in vblank since the LCD is off in_vblank_old = true; @@ -480,6 +482,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk mapper.RTC_Get((byte)(remaining & 0xFF), 0); } + + if (mppr == "HuC3") + { + Use_MT = true; + + int years = (int)Math.Floor(_syncSettings.RTCInitialTime / 31536000.0); + + mapper.RTC_Get((byte)years, 24); + + int remaining = _syncSettings.RTCInitialTime - (years * 31536000); + + int days = (int)Math.Floor(remaining / 86400.0); + int days_upper = (days >> 8) & 0xF; + + mapper.RTC_Get((byte)days_upper, 20); + mapper.RTC_Get((byte)(days & 0xFF), 12); + + remaining = remaining - (days * 86400); + + int minutes = (int)Math.Floor(remaining / 60.0); + int minutes_upper = (minutes >> 8) & 0xF; + + mapper.RTC_Get((byte)(minutes_upper), 8); + mapper.RTC_Get((byte)(remaining & 0xFF), 0); + } } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllerDeck.cs index 5f21be47e0..bfd7487f43 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllerDeck.cs @@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public void SyncState(Serializer ser) { - ser.BeginSection("Port1"); + ser.BeginSection(nameof(Port1)); Port1.SyncState(ser); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs index 160516c159..358ff7aa21 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs @@ -211,7 +211,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public void SyncState(Serializer ser) { // since we need rate of change of angle, need to savestate them - ser.Sync("theta", ref theta); + ser.Sync(nameof(theta), ref theta); } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs index 7b6a0ce9cc..a436d4045b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GB_PPU.cs @@ -1,7 +1,5 @@ using System; -using BizHawk.Emulation.Common; using BizHawk.Common.NumberExtensions; -using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { @@ -75,13 +73,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk //if (!STAT.Bit(6)) { LYC_INT = false; } if (!STAT.Bit(4)) { VBL_INT = false; } - break; + break; case 0xFF42: // SCY scroll_y = value; - break; + break; case 0xFF43: // SCX scroll_x = value; - break; + break; case 0xFF44: // LY LY = 0; /*reset*/ break; @@ -197,7 +195,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } // the VBL stat is continuously asserted - if ((LY >= 144)) + if (LY >= 144) { if (STAT.Bit(4)) { @@ -333,6 +331,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk OAM_INT = false; OAM_access_write = false; VRAM_access_write = false; + + // x-scroll is expected to be latched one cycle later + // this is fine since nothing has started in the rendering until the second cycle + // calculate the column number of the tile to start with + x_tile = (int)Math.Floor((float)(scroll_x) / 8); + render_offset = scroll_x % 8; } // render the screen and handle hblank @@ -422,7 +426,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // might be needed, not sure yet public override void latch_delay() { - //BGP_l = BGP; + } public override void render(int render_cycle) @@ -440,10 +444,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // window X is latched for the scanline, mid-line changes have no effect window_x_latch = window_x; - // calculate the column number of the tile to start with - x_tile = (int)Math.Floor((float)(scroll_x) / 8); - render_offset = scroll_x % 8; - OAM_scan_index = 0; read_case = 0; internal_cycle = 0; @@ -455,6 +455,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk fetch_sprite = false; going_to_fetch = false; first_fetch = true; + consecutive_sprite = -render_offset + 8; no_sprites = false; evaled_sprites = 0; window_pre_render = false; @@ -478,7 +479,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (SL_sprites_index == 0) { no_sprites = true; } // it is much easier to process sprites if we order them according to the rules of sprite priority first if (!no_sprites) { reorder_and_assemble_sprites(); } - } // before anything else, we have to check if windowing is in effect @@ -591,7 +591,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (pixel_counter == 160) { read_case = 8; - hbl_countdown = 1; } } else if (pixel_counter < 0) @@ -817,23 +816,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk case 8: // done reading, we are now in phase 0 pre_render = true; - // the other interrupts appear to be delayed by 1 CPU cycle, so do the same here - if (hbl_countdown > 0) - { - hbl_countdown--; - STAT &= 0xFC; - STAT |= 0x00; + STAT &= 0xFC; + STAT |= 0x00; - if (hbl_countdown == 0) - { - if (STAT.Bit(3)) { HBL_INT = true; } + if (STAT.Bit(3)) { HBL_INT = true; } - OAM_access_read = true; - OAM_access_write = true; - VRAM_access_read = true; - VRAM_access_write = true; - } - } + OAM_access_read = true; + OAM_access_write = true; + VRAM_access_read = true; + VRAM_access_write = true; break; case 9: @@ -852,8 +843,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk tile_data_latch[0] = tile_data[0]; tile_data_latch[1] = tile_data[1]; } - - if (consecutive_sprite > 0) { consecutive_sprite -= 1; } } // every in range sprite takes 6 cycles to process @@ -892,10 +881,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk else if (((last_eval + render_offset) % 8) == 5) { sprite_fetch_counter += 0; } else if (((last_eval + render_offset) % 8) == 6) { sprite_fetch_counter += 0; } else if (((last_eval + render_offset) % 8) == 7) { sprite_fetch_counter += 0; } + + consecutive_sprite = (int)Math.Floor((double)(last_eval + render_offset) / 8) * 8 + 8 - render_offset; + + // special case exists here for sprites at zero with non-zero x-scroll. Not sure exactly the reason for it. + if (last_eval == 0 && render_offset != 0) + { + sprite_fetch_counter += render_offset; + } } total_counter += sprite_fetch_counter; - consecutive_sprite = last_eval + (8 - (last_eval % 8)); first_fetch = false; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/HW_Registers.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/HW_Registers.cs index bbb583efda..5124e4371f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/HW_Registers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/HW_Registers.cs @@ -101,7 +101,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // Speed Control for GBC case 0xFF4D: - if (is_GBC) + if (GBC_compat) { ret = (byte)(((double_speed ? 1 : 0) << 7) + ((speed_switch ? 1 : 0))); } @@ -112,7 +112,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk break; case 0xFF4F: // VBK - if (is_GBC) + if (GBC_compat) { ret = VRAM_Bank; } @@ -137,7 +137,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk case 0xFF69: case 0xFF6A: case 0xFF6B: - if (is_GBC) + if (GBC_compat) { ret = ppu.ReadReg(addr); } @@ -149,7 +149,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // Speed Control for GBC case 0xFF70: - if (is_GBC) + if (GBC_compat) { ret = (byte)RAM_Bank; } @@ -159,6 +159,41 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } break; + case 0xFF6C: + if (GBC_compat) { ret = undoc_6C; } + else { ret = 0xFF; } + break; + + case 0xFF72: + if (is_GBC) { ret = undoc_72; } + else { ret = 0xFF; } + break; + + case 0xFF73: + if (is_GBC) { ret = undoc_73; } + else { ret = 0xFF; } + break; + + case 0xFF74: + if (GBC_compat) { ret = undoc_74; } + else { ret = 0xFF; } + break; + + case 0xFF75: + if (is_GBC) { ret = undoc_75; } + else { ret = 0xFF; } + break; + + case 0xFF76: + if (is_GBC) { ret = undoc_76; } + else { ret = 0xFF; } + break; + + case 0xFF77: + if (is_GBC) { ret = undoc_77; } + else { ret = 0xFF; } + break; + // interrupt control register case 0xFFFF: ret = REG_FFFF; @@ -323,7 +358,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // Speed Control for GBC case 0xFF4D: - if (is_GBC) + if (GBC_compat) { speed_switch = (value & 1) > 0; } @@ -331,7 +366,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // VBK case 0xFF4F: - if (is_GBC && !ppu.HDMA_active) + if (GBC_compat && !ppu.HDMA_active) { VRAM_Bank = (byte)(value & 1); } @@ -356,7 +391,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk case 0xFF69: case 0xFF6A: case 0xFF6B: - if (is_GBC) + if (GBC_compat) { ppu.WriteReg(addr, value); } @@ -365,13 +400,41 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // RAM Bank in GBC mode case 0xFF70: //Console.WriteLine(value); - if (is_GBC) + if (GBC_compat) { RAM_Bank = value & 7; if (RAM_Bank == 0) { RAM_Bank = 1; } } break; + case 0xFF6C: + if (GBC_compat) { undoc_6C |= (byte)(value & 1); } + break; + + case 0xFF72: + if (is_GBC) { undoc_72 = value; } + break; + + case 0xFF73: + if (is_GBC) { undoc_73 = value; } + break; + + case 0xFF74: + if (GBC_compat) { undoc_74 = value; } + break; + + case 0xFF75: + if (is_GBC) { undoc_75 |= (byte)(value & 0x70); } + break; + + case 0xFF76: + // read only + break; + + case 0xFF77: + // read only + break; + // interrupt control register case 0xFFFF: REG_FFFF = value; @@ -401,6 +464,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public void Register_Reset() { input_register = 0xCF; // not reading any input + + //undocumented registers + undoc_6C = 0xFE; + undoc_72 = 0; + undoc_73 = 0; + undoc_74 = 0; + undoc_75 = 0x8F; + undoc_76 = 0; + undoc_77 = 0; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC1.cs index 453c83237b..98ef698735 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC1.cs @@ -179,12 +179,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); - ser.Sync("RAM_Bank", ref RAM_bank); - ser.Sync("RAM_Mask", ref RAM_mask); - ser.Sync("RAM_enable", ref RAM_enable); - ser.Sync("IR_signal", ref IR_signal); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); + ser.Sync(nameof(RAM_bank), ref RAM_bank); + ser.Sync(nameof(RAM_mask), ref RAM_mask); + ser.Sync(nameof(RAM_enable), ref RAM_enable); + ser.Sync(nameof(IR_signal), ref IR_signal); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC3.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC3.cs index dab71a0b4b..5347487ed4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC3.cs @@ -1,55 +1,140 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; +using System; +using BizHawk.Common; using BizHawk.Emulation.Common.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { - // Default mapper with no bank switching + // Hudson HuC3 used with Robopon and others public class MapperHuC3 : MapperBase { + public int ROM_bank; + public int RAM_bank; + public bool RAM_enable; + public int ROM_mask; + public int RAM_mask; + public bool IR_signal; + public byte control; + public byte chip_read; + public bool timer_read; + public int time_val_shift; + public uint time; + public int RTC_timer; + public int RTC_low_clock; + public int RTC_seconds; + public override void Initialize() { - // nothing to initialize + ROM_bank = 0; + RAM_bank = 0; + RAM_enable = false; + ROM_mask = Core._rom.Length / 0x4000 - 1; + control = 0; + chip_read = 1; + timer_read = false; + time_val_shift = 0; + + // some games have sizes that result in a degenerate ROM, account for it here + if (ROM_mask > 4) { ROM_mask |= 3; } + + RAM_mask = 0; + if (Core.cart_RAM != null) + { + RAM_mask = Core.cart_RAM.Length / 0x2000 - 1; + if (Core.cart_RAM.Length == 0x800) { RAM_mask = 0; } + } } public override byte ReadMemory(ushort addr) { - if (addr < 0x8000) + if (addr < 0x4000) { return Core._rom[addr]; } - else + else if (addr < 0x8000) { - if (Core.cart_RAM != null) + return Core._rom[(addr - 0x4000) + ROM_bank * 0x4000]; + } + else if ((addr >= 0xA000) && (addr < 0xC000)) + { + if ((control >= 0xB) && (control < 0xE)) { - return Core.cart_RAM[addr - 0xA000]; + if (control == 0xD) + { + return 1; + } + return chip_read; + } + + if (RAM_enable) + { + if (Core.cart_RAM != null) + { + if (((addr - 0xA000) + RAM_bank * 0x2000) < Core.cart_RAM.Length) + { + return Core.cart_RAM[(addr - 0xA000) + RAM_bank * 0x2000]; + } + else + { + return 0xFF; + } + } + else + { + return 0xFF; + } } else { - return 0; + // what to return if RAM not enabled and controller not selected? + return 0xFF; } } + else + { + return 0xFF; + } } public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags) { - if (addr < 0x8000) + if (addr < 0x4000) { SetCDLROM(flags, addr); } - else + else if (addr < 0x8000) { - if (Core.cart_RAM != null) + SetCDLROM(flags, (addr - 0x4000) + ROM_bank * 0x4000); + } + else if ((addr >= 0xA000) && (addr < 0xC000)) + { + if (RAM_enable) { - SetCDLRAM(flags, addr - 0xA000); + if (Core.cart_RAM != null) + { + if (((addr - 0xA000) + RAM_bank * 0x2000) < Core.cart_RAM.Length) + { + SetCDLRAM(flags, (addr - 0xA000) + RAM_bank * 0x2000); + } + else + { + return; + } + } + else + { + return; + } } else { return; } } + else + { + return; + } } public override byte PeekMemory(ushort addr) @@ -61,20 +146,158 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { if (addr < 0x8000) { - // no mapping hardware available + if (addr < 0x2000) + { + RAM_enable = (value & 0xA) == 0xA; + control = value; + } + else if (addr < 0x4000) + { + if (value == 0) { value = 1; } + + ROM_bank = value; + ROM_bank &= ROM_mask; + } + else if (addr < 0x6000) + { + RAM_bank = value; + RAM_bank &= 0xF; + RAM_bank &= RAM_mask; + } } else { - if (Core.cart_RAM != null) + if (RAM_enable && ((control < 0xB) || (control > 0xE))) { - Core.cart_RAM[addr - 0xA000] = value; + if (Core.cart_RAM != null) + { + if (((addr - 0xA000) + RAM_bank * 0x2000) < Core.cart_RAM.Length) + { + Core.cart_RAM[(addr - 0xA000) + RAM_bank * 0x2000] = value; + } + } + } + + if (control == 0xB) + { + switch (value & 0xF0) + { + case 0x10: + if (timer_read) + { + // return timer value + chip_read = (byte)((time >> time_val_shift) & 0xF); + time_val_shift += 4; + if (time_val_shift == 28) { time_val_shift = 0; } + } + break; + case 0x20: + break; + case 0x30: + if (!timer_read) + { + // write to timer + if (time_val_shift == 0) { time = 0; } + if (time_val_shift < 28) + { + time |= (uint)((value & 0x0F) << time_val_shift); + time_val_shift += 4; + if (time_val_shift == 28) { timer_read = true; } + } + } + break; + case 0x40: + // other commands + switch (value & 0xF) + { + case 0x0: + time_val_shift = 0; + break; + case 0x3: + timer_read = false; + time_val_shift = 0; + break; + case 0x7: + timer_read = true; + time_val_shift = 0; + break; + case 0xF: + break; + } + break; + case 0x50: + break; + case 0x60: + timer_read = true; + break; + } + } + else if (control == 0xC) + { + // maybe IR + } + else if (control == 0xD) + { + // maybe IR } } } - public override void PokeMemory(ushort addr, byte value) + public override void RTC_Get(byte value, int index) { - WriteMemory(addr, value); + time |= (uint)((value & 0xFF) << index); + } + + public override void Mapper_Tick() + { + RTC_timer++; + + if (RTC_timer == 128) + { + RTC_timer = 0; + + RTC_low_clock++; + + if (RTC_low_clock == 32768) + { + RTC_low_clock = 0; + + RTC_seconds++; + if (RTC_seconds > 59) + { + RTC_seconds = 0; + time++; + if ((time & 0xFFF) > 1439) + { + time -= 1440; + time += (1 << 12); + if ((time >> 12) > 365) + { + time -= (365 << 12); + time += (1 << 24); + } + } + } + } + } + } + + public override void SyncState(Serializer ser) + { + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); + ser.Sync(nameof(RAM_bank), ref RAM_bank); + ser.Sync(nameof(RAM_mask), ref RAM_mask); + ser.Sync(nameof(RAM_enable), ref RAM_enable); + ser.Sync(nameof(IR_signal), ref IR_signal); + ser.Sync(nameof(control), ref control); + ser.Sync(nameof(chip_read), ref chip_read); + ser.Sync(nameof(timer_read), ref timer_read); + ser.Sync(nameof(time_val_shift), ref time_val_shift); + ser.Sync(nameof(time), ref time); + ser.Sync(nameof(RTC_timer), ref RTC_timer); + ser.Sync(nameof(RTC_low_clock), ref RTC_low_clock); + ser.Sync(nameof(RTC_seconds), ref RTC_seconds); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs index c294059501..f931d33b73 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs @@ -185,12 +185,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); - ser.Sync("RAM_Bank", ref RAM_bank); - ser.Sync("RAM_Mask", ref RAM_mask); - ser.Sync("RAM_enable", ref RAM_enable); - ser.Sync("sel_mode", ref sel_mode); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); + ser.Sync(nameof(RAM_bank), ref RAM_bank); + ser.Sync(nameof(RAM_mask), ref RAM_mask); + ser.Sync(nameof(RAM_enable), ref RAM_enable); + ser.Sync(nameof(sel_mode), ref sel_mode); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1_Multi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1_Multi.cs index 06f64f781a..017debca25 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1_Multi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1_Multi.cs @@ -120,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { if (addr < 0x2000) { - RAM_enable = ((value & 0xA) == 0xA) ? true : false; + RAM_enable = ((value & 0xA) == 0xA); } else if (addr < 0x4000) { @@ -181,12 +181,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); - ser.Sync("RAM_Bank", ref RAM_bank); - ser.Sync("RAM_Mask", ref RAM_mask); - ser.Sync("RAM_enable", ref RAM_enable); - ser.Sync("sel_mode", ref sel_mode); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); + ser.Sync(nameof(RAM_bank), ref RAM_bank); + ser.Sync(nameof(RAM_mask), ref RAM_mask); + ser.Sync(nameof(RAM_enable), ref RAM_enable); + ser.Sync(nameof(sel_mode), ref sel_mode); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC2.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC2.cs index e18a829d62..abd71d724b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC2.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC2.cs @@ -81,7 +81,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { if ((addr & 0x100) == 0) { - RAM_enable = ((value & 0xA) == 0xA) ? true : false; + RAM_enable = ((value & 0xA) == 0xA); } } else if (addr < 0x4000) @@ -108,10 +108,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); - ser.Sync("RAM_Bank", ref RAM_bank); - ser.Sync("RAM_enable", ref RAM_enable); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); + ser.Sync(nameof(RAM_bank), ref RAM_bank); + ser.Sync(nameof(RAM_enable), ref RAM_enable); } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs index 840bc5ba37..378d156429 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs @@ -142,7 +142,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { if (addr < 0x2000) { - RAM_enable = ((value & 0xA) == 0xA) ? true : false; + RAM_enable = ((value & 0xA) == 0xA); } else if (addr < 0x4000) { @@ -258,17 +258,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); - ser.Sync("RAM_Bank", ref RAM_bank); - ser.Sync("RAM_Mask", ref RAM_mask); - ser.Sync("RAM_enable", ref RAM_enable); - ser.Sync("halt", ref halt); - ser.Sync("RTC_regs", ref RTC_regs, false); - ser.Sync("RTC_regs_latch", ref RTC_regs_latch, false); - ser.Sync("RTC_regs_latch_wr", ref RTC_regs_latch_wr); - ser.Sync("RTC_timer", ref RTC_timer); - ser.Sync("RTC_low_clock", ref RTC_low_clock); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); + ser.Sync(nameof(RAM_bank), ref RAM_bank); + ser.Sync(nameof(RAM_mask), ref RAM_mask); + ser.Sync(nameof(RAM_enable), ref RAM_enable); + ser.Sync(nameof(halt), ref halt); + ser.Sync(nameof(RTC_regs), ref RTC_regs, false); + ser.Sync(nameof(RTC_regs_latch), ref RTC_regs_latch, false); + ser.Sync(nameof(RTC_regs_latch_wr), ref RTC_regs_latch_wr); + ser.Sync(nameof(RTC_timer), ref RTC_timer); + ser.Sync(nameof(RTC_low_clock), ref RTC_low_clock); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC5.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC5.cs index 46c8878502..924af960df 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC5.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC5.cs @@ -150,11 +150,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); - ser.Sync("RAM_Bank", ref RAM_bank); - ser.Sync("RAM_Mask", ref RAM_mask); - ser.Sync("RAM_enable", ref RAM_enable); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); + ser.Sync(nameof(RAM_bank), ref RAM_bank); + ser.Sync(nameof(RAM_mask), ref RAM_mask); + ser.Sync(nameof(RAM_enable), ref RAM_enable); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC7.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC7.cs index 1e733479de..aa5d756a2b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC7.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC7.cs @@ -159,31 +159,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); - ser.Sync("RAM_enable_1", ref RAM_enable_1); - ser.Sync("RAM_enable_2", ref RAM_enable_2); - ser.Sync("acc_x_low", ref acc_x_low); - ser.Sync("acc_x_high", ref acc_x_high); - ser.Sync("acc_y_low", ref acc_y_low); - ser.Sync("acc_y_high", ref acc_y_high); - ser.Sync("is_erased", ref is_erased); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); + ser.Sync(nameof(RAM_enable_1), ref RAM_enable_1); + ser.Sync(nameof(RAM_enable_2), ref RAM_enable_2); + ser.Sync(nameof(acc_x_low), ref acc_x_low); + ser.Sync(nameof(acc_x_high), ref acc_x_high); + ser.Sync(nameof(acc_y_low), ref acc_y_low); + ser.Sync(nameof(acc_y_high), ref acc_y_high); + ser.Sync(nameof(is_erased), ref is_erased); - ser.Sync("CS_prev", ref CS_prev); - ser.Sync("CLK_prev", ref CLK_prev); - ser.Sync("DI_prev", ref DI_prev); - ser.Sync("DO", ref DO); - ser.Sync("instr_read", ref instr_read); - ser.Sync("perf_instr", ref perf_instr); - ser.Sync("instr_bit_counter", ref instr_bit_counter); - ser.Sync("instr", ref instr); - ser.Sync("WR_EN", ref WR_EN); - ser.Sync("EE_addr", ref EE_addr); - ser.Sync("instr_case", ref instr_case); - ser.Sync("instr_clocks", ref instr_clocks); - ser.Sync("EE_value", ref EE_value); - ser.Sync("countdown", ref countdown); - ser.Sync("countdown_start", ref countdown_start); + ser.Sync(nameof(CS_prev), ref CS_prev); + ser.Sync(nameof(CLK_prev), ref CLK_prev); + ser.Sync(nameof(DI_prev), ref DI_prev); + ser.Sync(nameof(DO), ref DO); + ser.Sync(nameof(instr_read), ref instr_read); + ser.Sync(nameof(perf_instr), ref perf_instr); + ser.Sync(nameof(instr_bit_counter), ref instr_bit_counter); + ser.Sync(nameof(instr), ref instr); + ser.Sync(nameof(WR_EN), ref WR_EN); + ser.Sync(nameof(EE_addr), ref EE_addr); + ser.Sync(nameof(instr_case), ref instr_case); + ser.Sync(nameof(instr_clocks), ref instr_clocks); + ser.Sync(nameof(EE_value), ref EE_value); + ser.Sync(nameof(countdown), ref countdown); + ser.Sync(nameof(countdown_start), ref countdown_start); } public byte Register_Access_Read(ushort addr) @@ -419,11 +419,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk case 5: if ((instr_clocks >= 0) && (instr_clocks <= 7)) { - DO = ((Core.cart_RAM[EE_addr * 2 + 1] >> (7 - instr_clocks)) & 1) == 1 ? true : false; + DO = ((Core.cart_RAM[EE_addr * 2 + 1] >> (7 - instr_clocks)) & 1) == 1; } else if ((instr_clocks >= 8) && (instr_clocks <= 15)) { - DO = ((Core.cart_RAM[EE_addr * 2] >> (15 - instr_clocks)) & 1) == 1 ? true : false; + DO = ((Core.cart_RAM[EE_addr * 2] >> (15 - instr_clocks)) & 1) == 1; } if (instr_clocks == 15) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_RockMan8.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_RockMan8.cs index e50d297e3d..6e71464da0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_RockMan8.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_RockMan8.cs @@ -82,8 +82,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs index 57af41fd0a..25cf1420ff 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs @@ -174,14 +174,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); - ser.Sync("locked", ref locked); - ser.Sync("ROM_bank_mask", ref ROM_bank_mask); - ser.Sync("BASE_ROM_Bank", ref BASE_ROM_Bank); - ser.Sync("reg_access", ref reg_access); - ser.Sync("addr_last", ref addr_last); - ser.Sync("counter", ref counter); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); + ser.Sync(nameof(locked), ref locked); + ser.Sync(nameof(ROM_bank_mask), ref ROM_bank_mask); + ser.Sync(nameof(BASE_ROM_Bank), ref BASE_ROM_Bank); + ser.Sync(nameof(reg_access), ref reg_access); + ser.Sync(nameof(addr_last), ref addr_last); + ser.Sync(nameof(counter), ref counter); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs index d63f4b47a5..46e680477d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs @@ -208,16 +208,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); - ser.Sync("locked", ref locked); - ser.Sync("locked_GBC", ref locked_GBC); - ser.Sync("finished", ref finished); - ser.Sync("ROM_bank_mask", ref ROM_bank_mask); - ser.Sync("BASE_ROM_Bank", ref BASE_ROM_Bank); - ser.Sync("reg_access", ref reg_access); - ser.Sync("addr_last", ref addr_last); - ser.Sync("counter", ref counter); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); + ser.Sync(nameof(locked), ref locked); + ser.Sync(nameof(locked_GBC), ref locked_GBC); + ser.Sync(nameof(finished), ref finished); + ser.Sync(nameof(ROM_bank_mask), ref ROM_bank_mask); + ser.Sync(nameof(BASE_ROM_Bank), ref BASE_ROM_Bank); + ser.Sync(nameof(reg_access), ref reg_access); + ser.Sync(nameof(addr_last), ref addr_last); + ser.Sync(nameof(counter), ref counter); } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_WisdomTree.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_WisdomTree.cs index 9d1889f007..15825d2fe4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_WisdomTree.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_WisdomTree.cs @@ -34,16 +34,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } } - public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags) - { - if (addr < 0x8000) - { - SetCDLROM(flags, ROM_bank * 0x8000 + addr); - } - else - { - return; - } + public override void MapCDL(ushort addr, LR35902.eCDLogMemFlags flags) + { + if (addr < 0x8000) + { + SetCDLROM(flags, ROM_bank * 0x8000 + addr); + } + else + { + return; + } } public override byte PeekMemory(ushort addr) @@ -67,8 +67,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public override void SyncState(Serializer ser) { - ser.Sync("ROM_Bank", ref ROM_bank); - ser.Sync("ROM_Mask", ref ROM_mask); + ser.Sync(nameof(ROM_bank), ref ROM_bank); + ser.Sync(nameof(ROM_mask), ref ROM_mask); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs index 37ffb9078e..340b61fc2b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs @@ -1,6 +1,4 @@ using System; -using BizHawk.Emulation.Common; -using BizHawk.Common.NumberExtensions; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk @@ -12,7 +10,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public uint[] BG_palette = new uint[32]; public uint[] OBJ_palette = new uint[32]; - public bool HDMA_active; // register variables @@ -44,7 +41,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public bool LCD_was_off; public bool stat_line; public bool stat_line_old; - public int hbl_countdown; // OAM scan public bool DMA_OAM_access; public bool OAM_access_read; @@ -151,7 +147,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } - public virtual void Reset() { @@ -166,99 +161,97 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public virtual void SyncState(Serializer ser) { + ser.Sync(nameof(BG_palette), ref BG_palette, false); + ser.Sync(nameof(OBJ_palette), ref OBJ_palette, false); + ser.Sync(nameof(HDMA_active), ref HDMA_active); - ser.Sync("BG_palette", ref BG_palette, false); - ser.Sync("OBJ_palette", ref OBJ_palette, false); - ser.Sync("HDMA_active", ref HDMA_active); + ser.Sync(nameof(LCDC), ref LCDC); + ser.Sync(nameof(STAT), ref STAT); + ser.Sync(nameof(scroll_y), ref scroll_y); + ser.Sync(nameof(scroll_x), ref scroll_x); + ser.Sync(nameof(LY), ref LY); + ser.Sync(nameof(LY_actual), ref LY_actual); + ser.Sync(nameof(LY_inc), ref LY_inc); + ser.Sync(nameof(LYC), ref LYC); + ser.Sync(nameof(DMA_addr), ref DMA_addr); + ser.Sync(nameof(BGP), ref BGP); + ser.Sync(nameof(obj_pal_0), ref obj_pal_0); + ser.Sync(nameof(obj_pal_1), ref obj_pal_1); + ser.Sync(nameof(window_y), ref window_y); + ser.Sync(nameof(window_x), ref window_x); + ser.Sync(nameof(DMA_start), ref DMA_start); + ser.Sync(nameof(DMA_clock), ref DMA_clock); + ser.Sync(nameof(DMA_inc), ref DMA_inc); + ser.Sync(nameof(DMA_byte), ref DMA_byte); - ser.Sync("LCDC", ref LCDC); - ser.Sync("STAT", ref STAT); - ser.Sync("scroll_y", ref scroll_y); - ser.Sync("scroll_x", ref scroll_x); - ser.Sync("LY", ref LY); - ser.Sync("LY_actual", ref LY_actual); - ser.Sync("LYinc", ref LY_inc); - ser.Sync("LYC", ref LYC); - ser.Sync("DMA_addr", ref DMA_addr); - ser.Sync("BGP", ref BGP); - ser.Sync("obj_pal_0", ref obj_pal_0); - ser.Sync("obj_pal_1", ref obj_pal_1); - ser.Sync("window_y", ref window_y); - ser.Sync("window_x", ref window_x); - ser.Sync("DMA_start", ref DMA_start); - ser.Sync("DMA_clock", ref DMA_clock); - ser.Sync("DMA_inc", ref DMA_inc); - ser.Sync("DMA_byte", ref DMA_byte); + ser.Sync(nameof(cycle), ref cycle); + ser.Sync(nameof(LYC_INT), ref LYC_INT); + ser.Sync(nameof(HBL_INT), ref HBL_INT); + ser.Sync(nameof(VBL_INT), ref VBL_INT); + ser.Sync(nameof(OAM_INT), ref OAM_INT); + ser.Sync(nameof(stat_line), ref stat_line); + ser.Sync(nameof(stat_line_old), ref stat_line_old); + ser.Sync(nameof(LCD_was_off), ref LCD_was_off); + ser.Sync(nameof(OAM_scan_index), ref OAM_scan_index); + ser.Sync(nameof(SL_sprites_index), ref SL_sprites_index); + ser.Sync(nameof(SL_sprites), ref SL_sprites, false); + ser.Sync(nameof(write_sprite), ref write_sprite); + ser.Sync(nameof(no_scan), ref no_scan); - ser.Sync("cycle", ref cycle); - ser.Sync("LYC_INT", ref LYC_INT); - ser.Sync("HBL_INT", ref HBL_INT); - ser.Sync("VBL_INT", ref VBL_INT); - ser.Sync("OAM_INT", ref OAM_INT); - ser.Sync("stat_line", ref stat_line); - ser.Sync("stat_line_old", ref stat_line_old); - ser.Sync("hbl_countdown", ref hbl_countdown); - ser.Sync("LCD_was_off", ref LCD_was_off); - ser.Sync("OAM_scan_index", ref OAM_scan_index); - ser.Sync("SL_sprites_index", ref SL_sprites_index); - ser.Sync("SL_sprites", ref SL_sprites, false); - ser.Sync("write_sprite", ref write_sprite); - ser.Sync("no_scan", ref no_scan); + ser.Sync(nameof(DMA_OAM_access), ref DMA_OAM_access); + ser.Sync(nameof(OAM_access_read), ref OAM_access_read); + ser.Sync(nameof(OAM_access_write), ref OAM_access_write); + ser.Sync(nameof(VRAM_access_read), ref VRAM_access_read); + ser.Sync(nameof(VRAM_access_write), ref VRAM_access_write); - ser.Sync("DMA_OAM_access", ref DMA_OAM_access); - ser.Sync("OAM_access_read", ref OAM_access_read); - ser.Sync("OAM_access_write", ref OAM_access_write); - ser.Sync("VRAM_access_read", ref VRAM_access_read); - ser.Sync("VRAM_access_write", ref VRAM_access_write); + ser.Sync(nameof(read_case), ref read_case); + ser.Sync(nameof(internal_cycle), ref internal_cycle); + ser.Sync(nameof(y_tile), ref y_tile); + ser.Sync(nameof(y_scroll_offset), ref y_scroll_offset); + ser.Sync(nameof(x_tile), ref x_tile); + ser.Sync(nameof(x_scroll_offset), ref x_scroll_offset); + ser.Sync(nameof(tile_byte), ref tile_byte); + ser.Sync(nameof(sprite_fetch_cycles), ref sprite_fetch_cycles); + ser.Sync(nameof(fetch_sprite), ref fetch_sprite); + ser.Sync(nameof(going_to_fetch), ref going_to_fetch); + ser.Sync(nameof(first_fetch), ref first_fetch); + ser.Sync(nameof(sprite_fetch_counter), ref sprite_fetch_counter); + ser.Sync(nameof(sprite_attr_list), ref sprite_attr_list, false); + ser.Sync(nameof(sprite_pixel_list), ref sprite_pixel_list, false); + ser.Sync(nameof(sprite_present_list), ref sprite_present_list, false); + ser.Sync(nameof(temp_fetch), ref temp_fetch); + ser.Sync(nameof(tile_inc), ref tile_inc); + ser.Sync(nameof(pre_render), ref pre_render); + ser.Sync(nameof(pre_render_2), ref pre_render_2); + ser.Sync(nameof(tile_data), ref tile_data, false); + ser.Sync(nameof(tile_data_latch), ref tile_data_latch, false); + ser.Sync(nameof(latch_counter), ref latch_counter); + ser.Sync(nameof(latch_new_data), ref latch_new_data); + ser.Sync(nameof(render_counter), ref render_counter); + ser.Sync(nameof(render_offset), ref render_offset); + ser.Sync(nameof(pixel_counter), ref pixel_counter); + ser.Sync(nameof(pixel), ref pixel); + ser.Sync(nameof(sprite_data), ref sprite_data, false); + ser.Sync(nameof(sl_use_index), ref sl_use_index); + ser.Sync(nameof(sprite_sel), ref sprite_sel, false); + ser.Sync(nameof(no_sprites), ref no_sprites); + ser.Sync(nameof(evaled_sprites), ref evaled_sprites); + ser.Sync(nameof(SL_sprites_ordered), ref SL_sprites_ordered, false); + ser.Sync(nameof(sprite_ordered_index), ref sprite_ordered_index); + ser.Sync(nameof(blank_frame), ref blank_frame); + ser.Sync(nameof(window_latch), ref window_latch); + ser.Sync(nameof(consecutive_sprite), ref consecutive_sprite); + ser.Sync(nameof(last_eval), ref last_eval); - ser.Sync("read_case", ref read_case); - ser.Sync("internal_cycle", ref internal_cycle); - ser.Sync("y_tile", ref y_tile); - ser.Sync("y_scroll_offset", ref y_scroll_offset); - ser.Sync("x_tile", ref x_tile); - ser.Sync("x_scroll_offset", ref x_scroll_offset); - ser.Sync("tile_byte", ref tile_byte); - ser.Sync("sprite_fetch_cycles", ref sprite_fetch_cycles); - ser.Sync("fetch_sprite", ref fetch_sprite); - ser.Sync("going_to_fetch", ref going_to_fetch); - ser.Sync("first_fetch", ref first_fetch); - ser.Sync("sprite_fetch_counter", ref sprite_fetch_counter); - ser.Sync("sprite_attr_list", ref sprite_attr_list, false); - ser.Sync("sprite_pixel_list", ref sprite_pixel_list, false); - ser.Sync("sprite_present_list", ref sprite_present_list, false); - ser.Sync("temp_fetch", ref temp_fetch); - ser.Sync("tile_inc", ref tile_inc); - ser.Sync("pre_render", ref pre_render); - ser.Sync("pre_render_2", ref pre_render_2); - ser.Sync("tile_data", ref tile_data, false); - ser.Sync("tile_data_latch", ref tile_data_latch, false); - ser.Sync("latch_counter", ref latch_counter); - ser.Sync("latch_new_data", ref latch_new_data); - ser.Sync("render_counter", ref render_counter); - ser.Sync("render_offset", ref render_offset); - ser.Sync("pixel_counter", ref pixel_counter); - ser.Sync("pixel", ref pixel); - ser.Sync("sprite_data", ref sprite_data, false); - ser.Sync("sl_use_index", ref sl_use_index); - ser.Sync("sprite_sel", ref sprite_sel, false); - ser.Sync("no_sprites", ref no_sprites); - ser.Sync("evaled_sprites", ref evaled_sprites); - ser.Sync("SL_sprites_ordered", ref SL_sprites_ordered, false); - ser.Sync("sprite_ordered_index", ref sprite_ordered_index); - ser.Sync("blank_frame", ref blank_frame); - ser.Sync("window_latch", ref window_latch); - ser.Sync("consecutive_sprite", ref consecutive_sprite); - ser.Sync("last_eval", ref last_eval); - - ser.Sync("window_counter", ref window_counter); - ser.Sync("window_pre_render", ref window_pre_render); - ser.Sync("window_started", ref window_started); - ser.Sync("window_is_reset", ref window_is_reset); - ser.Sync("window_tile_inc", ref window_tile_inc); - ser.Sync("window_y_tile", ref window_y_tile); - ser.Sync("window_x_tile", ref window_x_tile); - ser.Sync("window_y_tile_inc", ref window_y_tile_inc); - ser.Sync("window_x_latch", ref window_x_latch); + ser.Sync(nameof(window_counter), ref window_counter); + ser.Sync(nameof(window_pre_render), ref window_pre_render); + ser.Sync(nameof(window_started), ref window_started); + ser.Sync(nameof(window_is_reset), ref window_is_reset); + ser.Sync(nameof(window_tile_inc), ref window_tile_inc); + ser.Sync(nameof(window_y_tile), ref window_y_tile); + ser.Sync(nameof(window_x_tile), ref window_x_tile); + ser.Sync(nameof(window_y_tile_inc), ref window_y_tile_inc); + ser.Sync(nameof(window_x_latch), ref window_x_latch); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs index 64de7f5457..c4fb5218e9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs @@ -16,6 +16,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public int serial_bits; public bool clk_internal; public int clk_rate; + public byte going_out; + public byte coming_in; public byte ReadReg(int addr) { @@ -47,7 +49,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if ((value & 1) > 0) { clk_internal = true; - clk_rate = 512; + if (((value & 2) > 0) && Core.GBC_compat) + { + clk_rate = 256; + } + else + { + clk_rate = 512; + } serial_clock = clk_rate; } else @@ -62,7 +71,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if ((value & 1) > 0) { clk_internal = true; - clk_rate = 512; + if (((value & 2) > 0) && Core.GBC_compat) + { + clk_rate = 256; + } + else + { + clk_rate = 512; + } serial_clock = clk_rate; } else @@ -73,7 +89,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } } - serial_control = (byte)(0x7E | (value & 0x81)); // middle six bits always 1 + if (Core.GBC_compat) + { + serial_control = (byte)(0x7C | (value & 0x83)); // extra CGB bit + } + else + { + serial_control = (byte)(0x7E | (value & 0x81)); // middle six bits always 1 + } + break; } } @@ -84,16 +108,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk if (serial_start) { if (serial_clock > 0) { serial_clock--; } + if (serial_clock == 0) { if (serial_bits > 0) { - send_external_bit((byte)(serial_data & 0x80)); - byte temp = get_external_bit(); serial_data = (byte)((serial_data << 1) | temp); serial_bits--; + if (serial_bits == 0) { serial_control &= 0x7F; @@ -122,12 +146,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // no device connected returns 0xFF public byte get_external_bit() { - return 1; + return coming_in; } + // calling this function buts an external bit on the cable line public void send_external_bit(byte bit_send) { - + going_out = (byte)(bit_send >> 7); } public void Reset() @@ -135,17 +160,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk serial_control = 0x7E; serial_start = false; serial_data = 0x00; + going_out = 0; + coming_in = 1; } public void SyncState(Serializer ser) { - ser.Sync("serial_control", ref serial_control); - ser.Sync("serial_data", ref serial_data); - ser.Sync("serial_start", ref serial_start); - ser.Sync("serial_clock", ref serial_clock); - ser.Sync("serial_bits", ref serial_bits); - ser.Sync("clk_internal", ref clk_internal); - ser.Sync("clk_rate", ref clk_rate); + ser.Sync(nameof(serial_control), ref serial_control); + ser.Sync(nameof(serial_data), ref serial_data); + ser.Sync(nameof(serial_start), ref serial_start); + ser.Sync(nameof(serial_clock), ref serial_clock); + ser.Sync(nameof(serial_bits), ref serial_bits); + ser.Sync(nameof(clk_internal), ref clk_internal); + ser.Sync(nameof(clk_rate), ref clk_rate); + ser.Sync(nameof(going_out), ref going_out); + ser.Sync(nameof(coming_in), ref coming_in); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs index 5f3fb8e9ce..a8b5eb541e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs @@ -168,17 +168,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public void SyncState(Serializer ser) { - ser.Sync("divider_reg", ref divider_reg); - ser.Sync("timer_reload", ref timer_reload); - ser.Sync("timer", ref timer); - ser.Sync("timer_old", ref timer_old); - ser.Sync("timer_control", ref timer_control); - ser.Sync("pending_reload", ref pending_reload); - ser.Sync("write_ignore", ref write_ignore); - ser.Sync("old_state", ref old_state); - ser.Sync("state", ref state); - ser.Sync("reload_block", ref reload_block); - ser.Sync("TMA_coincidence", ref TMA_coincidence); + ser.Sync(nameof(divider_reg), ref divider_reg); + ser.Sync(nameof(timer_reload), ref timer_reload); + ser.Sync(nameof(timer), ref timer); + ser.Sync(nameof(timer_old), ref timer_old); + ser.Sync(nameof(timer_control), ref timer_control); + ser.Sync(nameof(pending_reload), ref pending_reload); + ser.Sync(nameof(write_ignore), ref write_ignore); + ser.Sync(nameof(old_state), ref old_state); + ser.Sync(nameof(state), ref state); + ser.Sync(nameof(reload_block), ref reload_block); + ser.Sync(nameof(TMA_coincidence), ref TMA_coincidence); } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ICodeDataLog.cs new file mode 100644 index 0000000000..6ce439f161 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ICodeDataLog.cs @@ -0,0 +1,185 @@ +using System; +using System.IO; + +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common.Components.LR35902; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + public partial class GBHawkLink : ICodeDataLogger + { + private ICodeDataLog _cdl; + + public void SetCDL(ICodeDataLog cdl) + { + _cdl = cdl; + if (cdl == null) + this.L.cpu.CDLCallback = null; + else this.L.cpu.CDLCallback = CDLCpuCallback; + } + + public void NewCDL(ICodeDataLog cdl) + { + cdl["ROM"] = new byte[MemoryDomains["ROM L"].Size]; + cdl["HRAM"] = new byte[MemoryDomains["Zero Page RAM L"].Size]; + + cdl["WRAM"] = new byte[MemoryDomains["Main RAM L"].Size]; + + if (MemoryDomains.Has("Cart RAM L")) + { + cdl["CartRAM"] = new byte[MemoryDomains["Cart RAM L"].Size]; + } + + cdl.SubType = "GB"; + cdl.SubVer = 0; + } + + [FeatureNotImplemented] + void ICodeDataLogger.DisassembleCDL(Stream s, ICodeDataLog cdl) + { + } + + public void SetCDL(LR35902.eCDLogMemFlags flags, string type, int cdladdr) + { + if (type == null) return; + byte val = (byte)flags; + _cdl[type][cdladdr] |= (byte)flags; + } + + void CDLCpuCallback(ushort addr, LR35902.eCDLogMemFlags flags) + { + if (addr < 0x8000) + { + //don't record writes to the ROM, it's just noisy + //NOTE: in principle a mapper could mount a useful resource here, but I doubt it) + if ((flags & LR35902.eCDLogMemFlags.Write) != 0) return; + } + + if (L.ppu.DMA_start) + { + // some of gekkio's tests require these to be accessible during DMA + if (addr < 0x8000) + { + if (L.ppu.DMA_addr < 0x80) + { + return; + } + else + { + L.mapper.MapCDL(addr, flags); + return; + } + } + else if ((addr >= 0xE000) && (addr < 0xF000)) + { + SetCDL(flags, "WRAM", addr - 0xE000); + } + else if ((addr >= 0xF000) && (addr < 0xFE00)) + { + SetCDL(flags, "WRAM", (L.RAM_Bank * 0x1000) + (addr - 0xF000)); + } + else if ((addr >= 0xFE00) && (addr < 0xFEA0) && L.ppu.DMA_OAM_access) + { + return; + } + else if ((addr >= 0xFF00) && (addr < 0xFF80)) // The game GOAL! Requires Hardware Regs to be accessible + { + return; + } + else if ((addr >= 0xFF80)) + { + SetCDL(flags, "HRAM", addr - 0xFF80); + } + + } + + if (addr < 0x900) + { + if (addr < 0x100) + { + // return Either BIOS ROM or Game ROM + if ((L.GB_bios_register & 0x1) == 0) + { + return; + } + else + { + L.mapper.MapCDL(addr, flags); + return; + } + } + else if (addr >= 0x200) + { + // return Either BIOS ROM or Game ROM + if (((L.GB_bios_register & 0x1) == 0) && L.is_GBC) + { + return; + } + else + { + L.mapper.MapCDL(addr, flags); + return; + } + } + else + { + L.mapper.MapCDL(addr, flags); + return; + } + } + else if (addr < 0x8000) + { + L.mapper.MapCDL(addr, flags); + return; + } + else if (addr < 0xA000) + { + return; + } + else if (addr < 0xC000) + { + L.mapper.MapCDL(addr, flags); + return; + } + else if (addr < 0xD000) + { + return; + } + else if (addr < 0xE000) + { + SetCDL(flags, "WRAM", (L.RAM_Bank * 0x1000) + (addr - 0xD000)); + } + else if (addr < 0xF000) + { + SetCDL(flags, "WRAM", addr - 0xE000); + } + else if (addr < 0xFE00) + { + SetCDL(flags, "WRAM", (L.RAM_Bank * 0x1000) + (addr - 0xF000)); + } + else if (addr < 0xFEA0) + { + return; + } + else if (addr < 0xFF00) + { + return; + } + else if (addr < 0xFF80) + { + return; + } + else if (addr < 0xFFFF) + { + SetCDL(flags, "HRAM", addr - 0xFF80); + } + else + { + return; + } + + } + + + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IDebuggable.cs new file mode 100644 index 0000000000..e9b191d02a --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IDebuggable.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + public partial class GBHawkLink : IDebuggable + { + public IDictionary GetCpuFlagsAndRegisters() + { + return new Dictionary + { + /* + ["A"] = cpu.A, + ["X"] = cpu.X, + ["Y"] = cpu.Y, + ["S"] = cpu.S, + ["PC"] = cpu.PC, + ["Flag C"] = cpu.FlagC, + ["Flag Z"] = cpu.FlagZ, + ["Flag I"] = cpu.FlagI, + ["Flag D"] = cpu.FlagD, + ["Flag B"] = cpu.FlagB, + ["Flag V"] = cpu.FlagV, + ["Flag N"] = cpu.FlagN, + ["Flag T"] = cpu.FlagT + */ + }; + } + + public void SetCpuRegister(string register, int value) + { + switch (register) + { + default: + throw new InvalidOperationException(); + case "A": + //cpu.A = (byte)value; + break; + case "X": + //cpu.X = (byte)value; + break; + case "Y": + //cpu.Y = (byte)value; + break; + case "S": + //cpu.S = (byte)value; + break; + case "PC": + //cpu.PC = (ushort)value; + break; + case "Flag I": + //cpu.FlagI = value > 0; + break; + } + } + + public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); + + public bool CanStep(StepType type) + { + return false; + } + + [FeatureNotImplemented] + public void Step(StepType type) + { + throw new NotImplementedException(); + } + + public long TotalExecutedCycles + { + get { return (long)L.cpu.TotalExecutedCycles; } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs new file mode 100644 index 0000000000..e272ccc7ad --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs @@ -0,0 +1,293 @@ +using System; + +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Nintendo.GBHawk; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + public partial class GBHawkLink : IEmulator, IVideoProvider, ISoundProvider + { + public IEmulatorServiceProvider ServiceProvider { get; } + + public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; + + public bool FrameAdvance(IController controller, bool render, bool rendersound) + { + //Console.WriteLine("-----------------------FRAME-----------------------"); + //Update the color palette if a setting changed + if (linkSettings.Palette_L == GBHawk.GBHawk.GBSettings.PaletteType.BW) + { + L.color_palette[0] = color_palette_BW[0]; + L.color_palette[1] = color_palette_BW[1]; + L.color_palette[2] = color_palette_BW[2]; + L.color_palette[3] = color_palette_BW[3]; + } + else + { + L.color_palette[0] = color_palette_Gr[0]; + L.color_palette[1] = color_palette_Gr[1]; + L.color_palette[2] = color_palette_Gr[2]; + L.color_palette[3] = color_palette_Gr[3]; + } + + if (linkSettings.Palette_R == GBHawk.GBHawk.GBSettings.PaletteType.BW) + { + R.color_palette[0] = color_palette_BW[0]; + R.color_palette[1] = color_palette_BW[1]; + R.color_palette[2] = color_palette_BW[2]; + R.color_palette[3] = color_palette_BW[3]; + } + else + { + R.color_palette[0] = color_palette_Gr[0]; + R.color_palette[1] = color_palette_Gr[1]; + R.color_palette[2] = color_palette_Gr[2]; + R.color_palette[3] = color_palette_Gr[3]; + } + + if (_tracer.Enabled) + { + L.cpu.TraceCallback = s => _tracer.Put(s); + } + else + { + L.cpu.TraceCallback = null; + } + + _frame++; + + if (controller.IsPressed("Power")) + { + HardReset(); + } + + bool cablediscosignalNew = controller.IsPressed("Toggle Cable"); + if (cablediscosignalNew && !_cablediscosignal) + { + _cableconnected ^= true; + Console.WriteLine("Cable connect status to {0}", _cableconnected); + } + + _cablediscosignal = cablediscosignalNew; + + _islag = true; + + GetControllerState(controller); + + do_frame(); + + _islag = L._islag; + + if (_islag) + { + _lagcount++; + } + + return true; + } + + public void do_frame() + { + L.do_controller_check(); + R.do_controller_check(); + + // advance one full frame + for (int i = 0; i < 70224; i++) + { + L.do_single_step(); + R.do_single_step(); + + // the signal to shift out a bit is when serial_clock = 1 + if (((L.serialport.serial_clock == 1) || (L.serialport.serial_clock == 2)) && !do_r_next) + { + if (_cableconnected) + { + L.serialport.send_external_bit((byte)(L.serialport.serial_data & 0x80)); + + if ((R.serialport.clk_rate == -1) && R.serialport.serial_start) + { + R.serialport.serial_clock = L.serialport.serial_clock; + R.serialport.send_external_bit((byte)(R.serialport.serial_data & 0x80)); + R.serialport.coming_in = L.serialport.going_out; + } + + L.serialport.coming_in = R.serialport.going_out; + } + } + else if ((R.serialport.serial_clock == 1) || (R.serialport.serial_clock == 2)) + { + do_r_next = false; + + if (_cableconnected) + { + R.serialport.send_external_bit((byte)(R.serialport.serial_data & 0x80)); + + if ((L.serialport.clk_rate == -1) && L.serialport.serial_start) + { + L.serialport.serial_clock = R.serialport.serial_clock; + L.serialport.send_external_bit((byte)(L.serialport.serial_data & 0x80)); + L.serialport.coming_in = R.serialport.going_out; + } + + R.serialport.coming_in = L.serialport.going_out; + } + + if (R.serialport.serial_clock == 2) { do_r_next = true; } + } + else + { + do_r_next = false; + } + + // if we hit a frame boundary, update video + if (L.vblank_rise) + { + buff_L = L.GetVideoBuffer(); + L.vblank_rise = false; + FillVideoBuffer(); + } + if (R.vblank_rise) + { + buff_R = R.GetVideoBuffer(); + R.vblank_rise = false; + FillVideoBuffer(); + } + } + } + + public void GetControllerState(IController controller) + { + InputCallbacks.Call(); + L.controller_state = _controllerDeck.ReadPort1(controller); + R.controller_state = _controllerDeck.ReadPort2(controller); + } + + public int Frame => _frame; + + public string SystemId => "DGB"; + + public bool DeterministicEmulation { get; set; } + + public void ResetCounters() + { + _frame = 0; + _lagcount = 0; + _islag = false; + } + + public CoreComm CoreComm { get; } + + public void Dispose() + { + L.Dispose(); + R.Dispose(); + } + + #region Video provider + + public int _frameHz = 60; + + public int[] _vidbuffer = new int[160 * 2 * 144]; + public int[] buff_L = new int[160 * 144]; + public int[] buff_R = new int[160 * 144]; + + public int[] GetVideoBuffer() + { + return _vidbuffer; + } + + public void FillVideoBuffer() + { + // combine the 2 video buffers from the instances + for (int i = 0; i < 144; i++) + { + for (int j = 0; j < 160; j++) + { + _vidbuffer[i * 320 + j] = buff_L[i * 160 + j]; + _vidbuffer[i * 320 + j + 160] = buff_R[i * 160 + j]; + } + } + } + + public int VirtualWidth => 160 * 2; + public int VirtualHeight => 144; + public int BufferWidth => 160 * 2; + public int BufferHeight => 144; + public int BackgroundColor => unchecked((int)0xFF000000); + public int VsyncNumerator => _frameHz; + public int VsyncDenominator => 1; + + public static readonly uint[] color_palette_BW = { 0xFFFFFFFF , 0xFFAAAAAA, 0xFF555555, 0xFF000000 }; + public static readonly uint[] color_palette_Gr = { 0xFFA4C505, 0xFF88A905, 0xFF1D551D, 0xFF052505 }; + + public uint[] color_palette = new uint[4]; + + #endregion + + #region audio + + public bool CanProvideAsync => false; + + public void SetSyncMode(SyncSoundMode mode) + { + if (mode != SyncSoundMode.Sync) + { + throw new InvalidOperationException("Only Sync mode is supported_"); + } + } + + public SyncSoundMode SyncMode => SyncSoundMode.Sync; + + public void GetSamplesSync(out short[] samples, out int nsamp) + { + short[] temp_samp_L; + short[] temp_samp_R; + + int nsamp_L; + int nsamp_R; + + L.audio.GetSamplesSync(out temp_samp_L, out nsamp_L); + R.audio.GetSamplesSync(out temp_samp_R, out nsamp_R); + + if (linkSettings.AudioSet == GBLinkSettings.AudioSrc.Left) + { + samples = temp_samp_L; + nsamp = nsamp_L; + } + else if (linkSettings.AudioSet == GBLinkSettings.AudioSrc.Right) + { + samples = temp_samp_R; + nsamp = nsamp_R; + } + else + { + samples = new short[0]; + nsamp = 0; + } + } + + public void GetSamplesAsync(short[] samples) + { + throw new NotSupportedException("Async is not available"); + } + + public void DiscardSamples() + { + L.audio.DiscardSamples(); + R.audio.DiscardSamples(); + } + + private void GetSamples(short[] samples) + { + + } + + public void DisposeSound() + { + L.audio.DisposeSound(); + R.audio.DisposeSound(); + } + + #endregion + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IInputPollable.cs new file mode 100644 index 0000000000..021a1ac3a0 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IInputPollable.cs @@ -0,0 +1,24 @@ +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + public partial class GBHawkLink : IInputPollable + { + public int LagCount + { + get { return _lagcount; } + set { _lagcount = value; } + } + + public bool IsLagFrame + { + get { return _islag; } + set { _islag = value; } + } + + public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); + + public bool _islag = true; + private int _lagcount; + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs new file mode 100644 index 0000000000..baa6162919 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + public partial class GBHawkLink + { + private IMemoryDomains MemoryDomains; + + public void SetupMemoryDomains() + { + var domains = new List + { + new MemoryDomainDelegate( + "Main RAM L", + L.RAM.Length, + MemoryDomain.Endian.Little, + addr => L.RAM[addr], + (addr, value) => L.RAM[addr] = value, + 1), + new MemoryDomainDelegate( + "Main RAM R", + R.RAM.Length, + MemoryDomain.Endian.Little, + addr => R.RAM[addr], + (addr, value) => R.RAM[addr] = value, + 1), + new MemoryDomainDelegate( + "Zero Page RAM L", + L.ZP_RAM.Length, + MemoryDomain.Endian.Little, + addr => L.ZP_RAM[addr], + (addr, value) => L.ZP_RAM[addr] = value, + 1), + new MemoryDomainDelegate( + "Zero Page RAM R", + R.ZP_RAM.Length, + MemoryDomain.Endian.Little, + addr => R.ZP_RAM[addr], + (addr, value) => R.ZP_RAM[addr] = value, + 1), + new MemoryDomainDelegate( + "System Bus L", + 0X10000, + MemoryDomain.Endian.Little, + addr => PeekSystemBusL(addr), + (addr, value) => PokeSystemBusL(addr, value), + 1), + new MemoryDomainDelegate( + "System Bus R", + 0X10000, + MemoryDomain.Endian.Little, + addr => PeekSystemBusR(addr), + (addr, value) => PokeSystemBusR(addr, value), + 1), + new MemoryDomainDelegate( + "ROM L", + L._rom.Length, + MemoryDomain.Endian.Little, + addr => L._rom[addr], + (addr, value) => L._rom[addr] = value, + 1), + new MemoryDomainDelegate( + "ROM R", + R._rom.Length, + MemoryDomain.Endian.Little, + addr => R._rom[addr], + (addr, value) => R._rom[addr] = value, + 1), + new MemoryDomainDelegate( + "VRAM L", + L.VRAM.Length, + MemoryDomain.Endian.Little, + addr => L.VRAM[addr], + (addr, value) => L.VRAM[addr] = value, + 1), + new MemoryDomainDelegate( + "VRAM R", + R.VRAM.Length, + MemoryDomain.Endian.Little, + addr => R.VRAM[addr], + (addr, value) => R.VRAM[addr] = value, + 1) + }; + + if (L.cart_RAM != null) + { + var CartRamL = new MemoryDomainByteArray("Cart RAM L", MemoryDomain.Endian.Little, L.cart_RAM, true, 1); + domains.Add(CartRamL); + } + + if (R.cart_RAM != null) + { + var CartRamR = new MemoryDomainByteArray("Cart RAM R", MemoryDomain.Endian.Little, R.cart_RAM, true, 1); + domains.Add(CartRamR); + } + + MemoryDomains = new MemoryDomainList(domains); + (ServiceProvider as BasicServiceProvider).Register(MemoryDomains); + } + + private byte PeekSystemBusL(long addr) + { + ushort addr2 = (ushort)(addr & 0xFFFF); + return L.PeekMemory(addr2); + } + + private byte PeekSystemBusR(long addr) + { + ushort addr2 = (ushort)(addr & 0xFFFF); + return R.PeekMemory(addr2); + } + + private void PokeSystemBusL(long addr, byte value) + { + ushort addr2 = (ushort)(addr & 0xFFFF); + L.WriteMemory(addr2, value); + } + + private void PokeSystemBusR(long addr, byte value) + { + ushort addr2 = (ushort)(addr & 0xFFFF); + R.WriteMemory(addr2, value); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISaveRam.cs new file mode 100644 index 0000000000..1a92caf11b --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISaveRam.cs @@ -0,0 +1,81 @@ +using System; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + public partial class GBHawkLink : ISaveRam + { + public byte[] CloneSaveRam() + { + if ((L.cart_RAM != null) || (R.cart_RAM != null)) + { + int Len1 = 0; + int Len2 = 0; + int index = 0; + + if (L.cart_RAM != null) + { + Len1 = L.cart_RAM.Length; + } + + if (R.cart_RAM != null) + { + Len2 = R.cart_RAM.Length; + } + + byte[] temp = new byte[Len1 + Len2]; + + if (L.cart_RAM != null) + { + for (int i = 0; i < L.cart_RAM.Length; i++) + { + temp[index] = L.cart_RAM[i]; + index++; + } + } + + if (R.cart_RAM != null) + { + for (int i = 0; i < L.cart_RAM.Length; i++) + { + temp[index] = R.cart_RAM[i]; + index++; + } + } + + return temp; + } + else + { + return null; + } + } + + public void StoreSaveRam(byte[] data) + { + if ((L.cart_RAM != null) && (R.cart_RAM == null)) + { + Buffer.BlockCopy(data, 0, L.cart_RAM, 0, L.cart_RAM.Length); + } + else if ((R.cart_RAM != null) && (L.cart_RAM == null)) + { + Buffer.BlockCopy(data, 0, R.cart_RAM, 0, R.cart_RAM.Length); + } + else if ((R.cart_RAM != null) && (L.cart_RAM != null)) + { + Buffer.BlockCopy(data, 0, L.cart_RAM, 0, L.cart_RAM.Length); + Buffer.BlockCopy(data, L.cart_RAM.Length, R.cart_RAM, 0, R.cart_RAM.Length); + } + + Console.WriteLine("loading SRAM here"); + } + + public bool SaveRamModified + { + get + { + return (L.has_bat || R.has_bat) & linkSyncSettings.Use_SRAM; + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs new file mode 100644 index 0000000000..79ab75ecc1 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs @@ -0,0 +1,146 @@ +using System; +using System.ComponentModel; + +using Newtonsoft.Json; + +using BizHawk.Common; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Nintendo.GBHawk; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + public partial class GBHawkLink : IEmulator, IStatable, ISettable + { + public GBLinkSettings GetSettings() + { + return linkSettings.Clone(); + } + + public GBLinkSyncSettings GetSyncSettings() + { + return linkSyncSettings.Clone(); + } + + public bool PutSettings(GBLinkSettings o) + { + linkSettings = o; + return false; + } + + public bool PutSyncSettings(GBLinkSyncSettings o) + { + bool ret = GBLinkSyncSettings.NeedsReboot(linkSyncSettings, o); + linkSyncSettings = o; + return ret; + } + + private GBLinkSettings linkSettings = new GBLinkSettings(); + public GBLinkSyncSettings linkSyncSettings = new GBLinkSyncSettings(); + + public class GBLinkSettings + { + [DisplayName("Color Mode")] + [Description("Pick Between Green scale and Grey scale colors")] + [DefaultValue(GBHawk.GBHawk.GBSettings.PaletteType.BW)] + public GBHawk.GBHawk.GBSettings.PaletteType Palette_L { get; set; } + + [DisplayName("Color Mode")] + [Description("Pick Between Green scale and Grey scale colors")] + [DefaultValue(GBHawk.GBHawk.GBSettings.PaletteType.BW)] + public GBHawk.GBHawk.GBSettings.PaletteType Palette_R { get; set; } + + public enum AudioSrc + { + Left, + Right, + Both + } + + [DisplayName("Audio Selection")] + [Description("Choose Audio Source. Both will produce Stereo sound.")] + [DefaultValue(AudioSrc.Left)] + public AudioSrc AudioSet { get; set; } + + public GBLinkSettings Clone() + { + return (GBLinkSettings)MemberwiseClone(); + } + } + + public class GBLinkSyncSettings + { + [DisplayName("Console Mode L")] + [Description("Pick which console to run, 'Auto' chooses from ROM extension, 'GB' and 'GBC' chooses the respective system")] + [DefaultValue(GBHawk.GBHawk.GBSyncSettings.ConsoleModeType.Auto)] + public GBHawk.GBHawk.GBSyncSettings.ConsoleModeType ConsoleMode_L { get; set; } + + [DisplayName("Console Mode R")] + [Description("Pick which console to run, 'Auto' chooses from ROM extension, 'GB' and 'GBC' chooses the respective system")] + [DefaultValue(GBHawk.GBHawk.GBSyncSettings.ConsoleModeType.Auto)] + public GBHawk.GBHawk.GBSyncSettings.ConsoleModeType ConsoleMode_R { get; set; } + + [DisplayName("CGB in GBA")] + [Description("Emulate GBA hardware running a CGB game, instead of CGB hardware. Relevant only for titles that detect the presense of a GBA, such as Shantae.")] + [DefaultValue(false)] + public bool GBACGB { get; set; } + + [DisplayName("RTC Initial Time L")] + [Description("Set the initial RTC time in terms of elapsed seconds.")] + [DefaultValue(0)] + public int RTCInitialTime_L + { + get { return _RTCInitialTime_L; } + set { _RTCInitialTime_L = Math.Max(0, Math.Min(1024 * 24 * 60 * 60, value)); } + } + + [DisplayName("RTC Initial Time R")] + [Description("Set the initial RTC time in terms of elapsed seconds.")] + [DefaultValue(0)] + public int RTCInitialTime_R + { + get { return _RTCInitialTime_R; } + set { _RTCInitialTime_R = Math.Max(0, Math.Min(1024 * 24 * 60 * 60, value)); } + } + + [DisplayName("Timer Div Initial Time L")] + [Description("Don't change from 0 unless it's hardware accurate. GBA GBC mode is known to be 8.")] + [DefaultValue(8)] + public int DivInitialTime_L + { + get { return _DivInitialTime_L; } + set { _DivInitialTime_L = Math.Min((ushort)65535, (ushort)value); } + } + + [DisplayName("Timer Div Initial Time R")] + [Description("Don't change from 0 unless it's hardware accurate. GBA GBC mode is known to be 8.")] + [DefaultValue(8)] + public int DivInitialTime_R + { + get { return _DivInitialTime_R; } + set { _DivInitialTime_R = Math.Min((ushort)65535, (ushort)value); } + } + + [DisplayName("Use Existing SaveRAM")] + [Description("When true, existing SaveRAM will be loaded at boot up")] + [DefaultValue(false)] + public bool Use_SRAM { get; set; } + + [JsonIgnore] + private int _RTCInitialTime_L; + private int _RTCInitialTime_R; + [JsonIgnore] + public ushort _DivInitialTime_L = 8; + public ushort _DivInitialTime_R = 8; + + public GBLinkSyncSettings Clone() + { + return (GBLinkSyncSettings)MemberwiseClone(); + } + + public static bool NeedsReboot(GBLinkSyncSettings x, GBLinkSyncSettings y) + { + return !DeepEquality.DeepEquals(x, y); + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs new file mode 100644 index 0000000000..9481bfc597 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs @@ -0,0 +1,66 @@ +using System.IO; +using Newtonsoft.Json; + +using BizHawk.Common; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Nintendo.GBHawk; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + public partial class GBHawkLink : IStatable + { + public bool BinarySaveStatesPreferred => true; + + public void SaveStateText(TextWriter writer) + { + L.SaveStateText(writer); + R.SaveStateText(writer); + SyncState(new Serializer(writer)); + } + + public void LoadStateText(TextReader reader) + { + L.LoadStateText(reader); + R.LoadStateText(reader); + SyncState(new Serializer(reader)); + } + + public void SaveStateBinary(BinaryWriter bw) + { + L.SaveStateBinary(bw); + R.SaveStateBinary(bw); + // other variables + SyncState(new Serializer(bw)); + } + + public void LoadStateBinary(BinaryReader br) + { + L.LoadStateBinary(br); + R.LoadStateBinary(br); + // other variables + SyncState(new Serializer(br)); + } + + public byte[] SaveStateBinary() + { + MemoryStream ms = new MemoryStream(); + BinaryWriter bw = new BinaryWriter(ms); + SaveStateBinary(bw); + bw.Flush(); + return ms.ToArray(); + } + + //private JsonSerializer ser = new JsonSerializer { Formatting = Formatting.Indented }; + + private void SyncState(Serializer ser) + { + ser.Sync("Lag", ref _lagcount); + ser.Sync("Frame", ref _frame); + ser.Sync("IsLag", ref _islag); + ser.Sync(nameof(_cableconnected), ref _cableconnected); + ser.Sync(nameof(_cablediscosignal), ref _cablediscosignal); + ser.Sync(nameof(do_r_next), ref do_r_next); + _controllerDeck.SyncState(ser); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs new file mode 100644 index 0000000000..4900fca9b9 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs @@ -0,0 +1,100 @@ +using System; + +using BizHawk.Emulation.Common; + +using BizHawk.Emulation.Cores.Nintendo.GBHawk; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + [Core( + "GBHawkLink", + "", + isPorted: false, + isReleased: true)] + [ServiceNotApplicable(typeof(IDriveLight))] + public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable, + ISettable + { + // we want to create two GBHawk instances that we will run concurrently + // maybe up to 4 eventually? + public GBHawk.GBHawk L; + public GBHawk.GBHawk R; + + // if true, the link cable is currently connected + private bool _cableconnected = true; + + // if true, the link cable toggle signal is currently asserted + private bool _cablediscosignal = false; + + private bool do_r_next = false; + + //[CoreConstructor("GB", "GBC")] + public GBHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) + { + var ser = new BasicServiceProvider(this); + + linkSettings = (GBLinkSettings)settings ?? new GBLinkSettings(); + linkSyncSettings = (GBLinkSyncSettings)syncSettings ?? new GBLinkSyncSettings(); + _controllerDeck = new GBHawkLinkControllerDeck(GBHawkLinkControllerDeck.DefaultControllerName, GBHawkLinkControllerDeck.DefaultControllerName); + + CoreComm = comm; + + var temp_set_L = new GBHawk.GBHawk.GBSettings(); + var temp_set_R = new GBHawk.GBHawk.GBSettings(); + + var temp_sync_L = new GBHawk.GBHawk.GBSyncSettings(); + var temp_sync_R = new GBHawk.GBHawk.GBSyncSettings(); + + temp_sync_L.ConsoleMode = linkSyncSettings.ConsoleMode_L; + temp_sync_R.ConsoleMode = linkSyncSettings.ConsoleMode_R; + + temp_sync_L.DivInitialTime = linkSyncSettings.DivInitialTime_L; + temp_sync_R.DivInitialTime = linkSyncSettings.DivInitialTime_R; + temp_sync_L.RTCInitialTime = linkSyncSettings.RTCInitialTime_L; + temp_sync_R.RTCInitialTime = linkSyncSettings.RTCInitialTime_R; + + L = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, + game_L, rom_L, temp_set_L, temp_sync_L); + + R = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, + game_R, rom_R, temp_set_R, temp_sync_R); + + ser.Register(this); + ser.Register(this); + + _tracer = new TraceBuffer { Header = L.cpu.TraceHeader }; + ser.Register(_tracer); + + ServiceProvider = ser; + + SetupMemoryDomains(); + + HardReset(); + } + + public void HardReset() + { + L.HardReset(); + R.HardReset(); + } + + public DisplayType Region => DisplayType.NTSC; + + public int _frame = 0; + + private readonly GBHawkLinkControllerDeck _controllerDeck; + + private readonly ITraceable _tracer; + + public bool LinkConnected + { + get { return _cableconnected; } + set { _cableconnected = value; } + } + + private void ExecFetch(ushort addr) + { + MemoryCallbacks.CallExecutes(addr, "System Bus"); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs new file mode 100644 index 0000000000..7f789b0059 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using BizHawk.Common; +using BizHawk.Common.ReflectionExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + public class GBHawkLinkControllerDeck + { + public GBHawkLinkControllerDeck(string controller1Name, string controller2Name) + { + if (!ValidControllerTypes.ContainsKey(controller1Name)) + { + throw new InvalidOperationException("Invalid controller type: " + controller1Name); + } + + if (!ValidControllerTypes.ContainsKey(controller2Name)) + { + throw new InvalidOperationException("Invalid controller type: " + controller2Name); + } + + Port1 = (IPort)Activator.CreateInstance(ValidControllerTypes[controller1Name], 1); + Port2 = (IPort)Activator.CreateInstance(ValidControllerTypes[controller2Name], 2); + + Definition = new ControllerDefinition + { + Name = Port1.Definition.Name, + BoolButtons = Port1.Definition.BoolButtons + .Concat(Port2.Definition.BoolButtons) + .Concat(new[] { "Toggle Cable" } ) + .ToList() + }; + } + + public byte ReadPort1(IController c) + { + return Port1.Read(c); + } + + public byte ReadPort2(IController c) + { + return Port2.Read(c); + } + + public ControllerDefinition Definition { get; } + + public void SyncState(Serializer ser) + { + ser.BeginSection(nameof(Port1)); + Port1.SyncState(ser); + ser.EndSection(); + + ser.BeginSection(nameof(Port2)); + Port2.SyncState(ser); + ser.EndSection(); + } + + private readonly IPort Port1; + private readonly IPort Port2; + + private static Dictionary _controllerTypes; + + public static Dictionary ValidControllerTypes + { + get + { + if (_controllerTypes == null) + { + _controllerTypes = typeof(GBHawkLinkControllerDeck).Assembly + .GetTypes() + .Where(t => typeof(IPort).IsAssignableFrom(t)) + .Where(t => !t.IsAbstract && !t.IsInterface) + .ToDictionary(tkey => tkey.DisplayName()); + } + + return _controllerTypes; + } + } + + public static string DefaultControllerName => typeof(StandardControls).DisplayName(); + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllers.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllers.cs new file mode 100644 index 0000000000..b1617ce740 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllers.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink +{ + /// + /// Represents a GB add on + /// + public interface IPort + { + byte Read(IController c); + + ControllerDefinition Definition { get; } + + void SyncState(Serializer ser); + + int PortNum { get; } + } + + [DisplayName("Gameboy Controller")] + public class StandardControls : IPort + { + public StandardControls(int portNum) + { + PortNum = portNum; + Definition = new ControllerDefinition + { + Name = "Gameboy Controller H", + BoolButtons = BaseDefinition + .Select(b => "P" + PortNum + " " + b) + .ToList() + }; + } + + public int PortNum { get; } + + public ControllerDefinition Definition { get; } + + public byte Read(IController c) + { + byte result = 0xFF; + + if (c.IsPressed(Definition.BoolButtons[0])) + { + result -= 4; + } + if (c.IsPressed(Definition.BoolButtons[1])) + { + result -= 8; + } + if (c.IsPressed(Definition.BoolButtons[2])) + { + result -= 2; + } + if (c.IsPressed(Definition.BoolButtons[3])) + { + result -= 1; + } + if (c.IsPressed(Definition.BoolButtons[4])) + { + result -= 128; + } + if (c.IsPressed(Definition.BoolButtons[5])) + { + result -= 64; + } + if (c.IsPressed(Definition.BoolButtons[6])) + { + result -= 32; + } + if (c.IsPressed(Definition.BoolButtons[7])) + { + result -= 16; + } + + return result; + } + + private static readonly string[] BaseDefinition = + { + "Up", "Down", "Left", "Right", "Start", "Select", "B", "A", "Power" + }; + + public void SyncState(Serializer ser) + { + //nothing + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/ReadMe.txt b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/ReadMe.txt new file mode 100644 index 0000000000..bc60bf4b01 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/ReadMe.txt @@ -0,0 +1 @@ +TODO: diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs index 2b55424647..c0b371b389 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs @@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public ControllerDefinition ControllerDefinition => GbController; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { FrameAdvancePrep(controller); if (_syncSettings.EqualLengthFrames) @@ -68,6 +68,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy } FrameAdvancePost(); + + return true; } public int Frame { get; private set; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ILinkable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ILinkable.cs index 05066dfed8..93f65cbff6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ILinkable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ILinkable.cs @@ -10,6 +10,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { public partial class Gameboy : ILinkable { - public bool LinkConnected { get; private set; } + public bool LinkConnected { get; set; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IMemoryDomains.cs index bd862827a5..086ad2b779 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IMemoryDomains.cs @@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy if (!LibGambatte.gambatte_getmemoryarea(GambatteState, which, ref data, ref length)) { - throw new Exception("gambatte_getmemoryarea() failed!"); + throw new Exception($"{nameof(LibGambatte.gambatte_getmemoryarea)}() failed!"); } // if length == 0, it's an empty block; (usually rambank on some carts); that's ok diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IStatable.cs index 55af4c3d1f..b4c83a3c62 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IStatable.cs @@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { if (!LibGambatte.gambatte_newstatesave(GambatteState, _savebuff, _savebuff.Length)) { - throw new Exception("gambatte_newstatesave() returned false"); + throw new Exception($"{nameof(LibGambatte.gambatte_newstatesave)}() returned false"); } writer.Write(_savebuff.Length); @@ -53,7 +53,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy if (!LibGambatte.gambatte_newstateload(GambatteState, _savebuff, _savebuff.Length)) { - throw new Exception("gambatte_newstateload() returned false"); + throw new Exception($"{nameof(LibGambatte.gambatte_newstateload)}() returned false"); } // other variables diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index 1f1891e1a5..ad53a9b698 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy if (GambatteState == IntPtr.Zero) { - throw new InvalidOperationException("gambatte_create() returned null???"); + throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_create)}() returned null???"); } Console.WriteLine(game.System); @@ -92,7 +92,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy if (LibGambatte.gambatte_load(GambatteState, file, (uint)file.Length, GetCurrentTime(), flags, DivInternal) != 0) { - throw new InvalidOperationException("gambatte_load() returned non-zero (is this not a gb or gbc rom?)"); + throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_load)}() returned non-zero (is this not a gb or gbc rom?)"); } if ((flags & LibGambatte.LoadFlags.FORCE_DMG) == LibGambatte.LoadFlags.FORCE_DMG) @@ -103,7 +103,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy if (LibGambatte.gambatte_loaddmgbios(GambatteState, Bios) != 0) { - throw new InvalidOperationException("gambatte_loaddmgbios() returned non-zero (bios error)"); + throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_loaddmgbios)}() returned non-zero (bios error)"); } } else @@ -114,7 +114,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy if (LibGambatte.gambatte_loadgbcbios(GambatteState, Bios) != 0) { - throw new InvalidOperationException("gambatte_loadgbcbios() returned non-zero (bios error)"); + throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_loadgbcbios)}() returned non-zero (bios error)"); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs index 3a835ee5a2..1458fd746e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public ControllerDefinition ControllerDefinition => DualGbController; - public void FrameAdvance(IController controller, bool render, bool rendersound = true) + public bool FrameAdvance(IController controller, bool render, bool rendersound = true) { LCont.Clear(); RCont.Clear(); @@ -34,7 +34,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { _cableconnected ^= true; Console.WriteLine("Cable connect status to {0}", _cableconnected); - LinkConnected = _cableconnected; } _cablediscosignal = cablediscosignalNew; @@ -148,6 +147,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { LagCount++; } + + return true; } public int Frame { get; private set; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index d83ce630f6..2a908e7c23 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -51,7 +51,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy SetMemoryDomains(); } - public bool LinkConnected { get; private set; } + public bool LinkConnected + { + get { return _cableconnected; } + set { _cableconnected = value; } + } private bool _disposed = false; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index b4c68bf03f..342eaef8c4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -221,7 +221,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 RunThreadAction(() => { _pendingThreadTerminate = true; }); } - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { _inputProvider.Controller = controller; @@ -258,6 +258,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 if(!api.IsCrashed) Frame++; + + return true; } public string SystemId { get { return "N64"; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs index de083bf67d..b0e9a8822f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs @@ -18,7 +18,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 AspectRatio = AspectRatioMode.FourThree; BufferSwapMode = SwapMode.OnVIUpdateCall; UseNativeResolutionFactor = 0; - bilinearMode = bilinearFilteringMode.Standard; + bilinearMode = bilinearFilteringMode.ThreePoint; + enableHalosRemoval = false; MaxAnisotropy = false; CacheSize = 8000; ShowInternalResolution = false; @@ -34,12 +35,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 EnableFragmentDepthWrite = true; EnableFBEmulation = true; EnableCopyAuxiliaryToRDRAM = false; - EnableN64DepthCompare = false; + EnableN64DepthCompare = true; DisableFBInfo = true; FBInfoReadColorChunk = false; FBInfoReadDepthChunk = true; - EnableCopyColorToRDRAM = CopyColorToRDRAMMode.AsyncMode; - EnableCopyDepthToRDRAM = CopyDepthToRDRAMMode.DoNotCopy; + EnableCopyColorToRDRAM = CopyColorToRDRAMMode.SyncMode; + EnableCopyDepthToRDRAM = CopyDepthToRDRAMMode.SoftwareRender; EnableCopyColorFromRDRAM = false; txFilterMode = TextureFilterMode.None; txEnhancementMode = TextureEnhancementMode.None; @@ -135,6 +136,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 [Description("Bilinear filtering mode (0=N64 3point, 1=standard)")] public bilinearFilteringMode bilinearMode { get; set; } + [DefaultValue(false)] + [DisplayName("Enable Halos Removal")] + [Description("Remove halos around filtered textures")] + public bool enableHalosRemoval { get; set; } + [DefaultValue(false)] [DisplayName("Max level of Anisotropic Filtering")] [Description("Max level of Anisotropic Filtering, 0 for off")] diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs index c1fdd04a45..c499855ae5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using System.Threading; +using BizHawk.Common; using BizHawk.Emulation.Common; using System.Text; @@ -26,17 +27,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi bool event_frameend = false; bool event_breakpoint = false; - [DllImport("kernel32.dll")] - public static extern UInt32 GetLastError(); - - [DllImport("kernel32.dll")] - public static extern IntPtr LoadLibrary(string dllToLoad); - - [DllImport("kernel32.dll")] - public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName); - - [DllImport("kernel32.dll")] - public static extern bool FreeLibrary(IntPtr hModule); + private static readonly PlatformLinkedLibSingleton.PlatformLinkedLibManager libLoader = PlatformLinkedLibSingleton.LinkedLibManager; public enum m64p_error { @@ -506,7 +497,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi } this.bizhawkCore = bizhawkCore; - CoreDll = LoadLibrary("mupen64plus.dll"); + CoreDll = libLoader.LoadPlatformSpecific("mupen64plus"); if (CoreDll == IntPtr.Zero) throw new InvalidOperationException(string.Format("Failed to load mupen64plus.dll")); @@ -605,41 +596,41 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi /// void connectFunctionPointers() { - m64pCoreStartup = (CoreStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreStartup"), typeof(CoreStartup)); - m64pCoreShutdown = (CoreShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreShutdown"), typeof(CoreShutdown)); - m64pCoreDoCommandByteArray = (CoreDoCommandByteArray)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandByteArray)); - m64pCoreDoCommandPtr = (CoreDoCommandPtr)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandPtr)); - m64pCoreDoCommandRefInt = (CoreDoCommandRefInt)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandRefInt)); - m64pCoreDoCommandFrameCallback = (CoreDoCommandFrameCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandFrameCallback)); - m64pCoreDoCommandVICallback = (CoreDoCommandVICallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandVICallback)); - m64pCoreDoCommandRenderCallback = (CoreDoCommandRenderCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandRenderCallback)); - m64pCoreAttachPlugin = (CoreAttachPlugin)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreAttachPlugin"), typeof(CoreAttachPlugin)); - m64pCoreDetachPlugin = (CoreDetachPlugin)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "CoreDetachPlugin"), typeof(CoreDetachPlugin)); - m64pConfigOpenSection = (ConfigOpenSection)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "ConfigOpenSection"), typeof(ConfigOpenSection)); - m64pConfigSetParameter = (ConfigSetParameter)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "ConfigSetParameter"), typeof(ConfigSetParameter)); - m64pConfigSetParameterStr = (ConfigSetParameterStr)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "ConfigSetParameter"), typeof(ConfigSetParameterStr)); - m64pCoreSaveState = (savestates_save_bkm)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "savestates_save_bkm"), typeof(savestates_save_bkm)); - m64pCoreLoadState = (savestates_load_bkm)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "savestates_load_bkm"), typeof(savestates_load_bkm)); - m64pDebugMemGetPointer = (DebugMemGetPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "DebugMemGetPointer"), typeof(DebugMemGetPointer)); - m64pDebugSetCallbacks = (DebugSetCallbacks)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "DebugSetCallbacks"), typeof(DebugSetCallbacks)); - m64pDebugBreakpointLookup = (DebugBreakpointLookup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "DebugBreakpointLookup"), typeof(DebugBreakpointLookup)); - m64pDebugBreakpointCommand = ( DebugBreakpointCommand )Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "DebugBreakpointCommand"), typeof(DebugBreakpointCommand)); - m64pDebugGetState = (DebugGetState)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "DebugGetState"), typeof(DebugGetState)); - m64pDebugSetRunState = (DebugSetRunState)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "DebugSetRunState"), typeof(DebugSetRunState)); - m64pDebugStep = (DebugStep)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "DebugStep"), typeof(DebugStep)); - m64pMemGetSize = (MemGetSize)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "MemGetSize"), typeof(MemGetSize)); - m64pinit_saveram = (init_saveram)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "init_saveram"), typeof(init_saveram)); - m64psave_saveram = (save_saveram)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "save_saveram"), typeof(save_saveram)); - m64pload_saveram = (load_saveram)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "load_saveram"), typeof(load_saveram)); + m64pCoreStartup = (CoreStartup)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "CoreStartup"), typeof(CoreStartup)); + m64pCoreShutdown = (CoreShutdown)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "CoreShutdown"), typeof(CoreShutdown)); + m64pCoreDoCommandByteArray = (CoreDoCommandByteArray)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandByteArray)); + m64pCoreDoCommandPtr = (CoreDoCommandPtr)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandPtr)); + m64pCoreDoCommandRefInt = (CoreDoCommandRefInt)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandRefInt)); + m64pCoreDoCommandFrameCallback = (CoreDoCommandFrameCallback)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandFrameCallback)); + m64pCoreDoCommandVICallback = (CoreDoCommandVICallback)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandVICallback)); + m64pCoreDoCommandRenderCallback = (CoreDoCommandRenderCallback)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "CoreDoCommand"), typeof(CoreDoCommandRenderCallback)); + m64pCoreAttachPlugin = (CoreAttachPlugin)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "CoreAttachPlugin"), typeof(CoreAttachPlugin)); + m64pCoreDetachPlugin = (CoreDetachPlugin)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "CoreDetachPlugin"), typeof(CoreDetachPlugin)); + m64pConfigOpenSection = (ConfigOpenSection)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "ConfigOpenSection"), typeof(ConfigOpenSection)); + m64pConfigSetParameter = (ConfigSetParameter)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "ConfigSetParameter"), typeof(ConfigSetParameter)); + m64pConfigSetParameterStr = (ConfigSetParameterStr)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "ConfigSetParameter"), typeof(ConfigSetParameterStr)); + m64pCoreSaveState = (savestates_save_bkm)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "savestates_save_bkm"), typeof(savestates_save_bkm)); + m64pCoreLoadState = (savestates_load_bkm)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "savestates_load_bkm"), typeof(savestates_load_bkm)); + m64pDebugMemGetPointer = (DebugMemGetPointer)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "DebugMemGetPointer"), typeof(DebugMemGetPointer)); + m64pDebugSetCallbacks = (DebugSetCallbacks)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "DebugSetCallbacks"), typeof(DebugSetCallbacks)); + m64pDebugBreakpointLookup = (DebugBreakpointLookup)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "DebugBreakpointLookup"), typeof(DebugBreakpointLookup)); + m64pDebugBreakpointCommand = ( DebugBreakpointCommand )Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "DebugBreakpointCommand"), typeof(DebugBreakpointCommand)); + m64pDebugGetState = (DebugGetState)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "DebugGetState"), typeof(DebugGetState)); + m64pDebugSetRunState = (DebugSetRunState)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "DebugSetRunState"), typeof(DebugSetRunState)); + m64pDebugStep = (DebugStep)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "DebugStep"), typeof(DebugStep)); + m64pMemGetSize = (MemGetSize)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "MemGetSize"), typeof(MemGetSize)); + m64pinit_saveram = (init_saveram)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "init_saveram"), typeof(init_saveram)); + m64psave_saveram = (save_saveram)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "save_saveram"), typeof(save_saveram)); + m64pload_saveram = (load_saveram)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "load_saveram"), typeof(load_saveram)); - m64pSetTraceCallback = (SetTraceCallback)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "SetTraceCallback"), typeof(SetTraceCallback)); + m64pSetTraceCallback = (SetTraceCallback)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "SetTraceCallback"), typeof(SetTraceCallback)); - m64pGetRegisters = (GetRegisters)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "GetRegisters"), typeof(GetRegisters)); + m64pGetRegisters = (GetRegisters)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "GetRegisters"), typeof(GetRegisters)); - m64p_read_memory_8 = (biz_read_memory)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "biz_read_memory"), typeof(biz_read_memory)); - m64p_write_memory_8 = (biz_write_memory)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "biz_write_memory"), typeof(biz_write_memory)); + m64p_read_memory_8 = (biz_read_memory)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "biz_read_memory"), typeof(biz_read_memory)); + m64p_write_memory_8 = (biz_write_memory)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "biz_write_memory"), typeof(biz_write_memory)); - m64p_decode_op = (biz_r4300_decode_op)Marshal.GetDelegateForFunctionPointer(GetProcAddress(CoreDll, "biz_r4300_decode_op"), typeof(biz_r4300_decode_op)); + m64p_decode_op = (biz_r4300_decode_op)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(CoreDll, "biz_r4300_decode_op"), typeof(biz_r4300_decode_op)); } /// @@ -933,7 +924,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi m64pCoreDoCommandPtr(m64p_command.M64CMD_ROM_CLOSE, 0, IntPtr.Zero); m64pCoreShutdown(); - FreeLibrary(CoreDll); + libLoader.FreePlatformSpecific(CoreDll); disposed = true; } @@ -953,18 +944,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi DetachPlugin(type); AttachedPlugin plugin; - plugin.dllHandle = LoadLibrary(PluginName); - if (plugin.dllHandle == IntPtr.Zero) - throw new InvalidOperationException(string.Format("Failed to load plugin {0}, error code: 0x{1:X}", PluginName, GetLastError())); + plugin.dllHandle = libLoader.LoadPlatformSpecific(PluginName); - plugin.dllStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(GetProcAddress(plugin.dllHandle, "PluginStartup"), typeof(PluginStartup)); - plugin.dllShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(GetProcAddress(plugin.dllHandle, "PluginShutdown"), typeof(PluginShutdown)); + plugin.dllStartup = (PluginStartup)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(plugin.dllHandle, "PluginStartup"), typeof(PluginStartup)); + plugin.dllShutdown = (PluginShutdown)Marshal.GetDelegateForFunctionPointer(libLoader.GetProcAddr(plugin.dllHandle, "PluginShutdown"), typeof(PluginShutdown)); plugin.dllStartup(CoreDll, null, null); m64p_error result = m64pCoreAttachPlugin(type, plugin.dllHandle); if (result != m64p_error.M64ERR_SUCCESS) { - FreeLibrary(plugin.dllHandle); + libLoader.FreePlatformSpecific(plugin.dllHandle); throw new InvalidOperationException(string.Format("Error during attaching plugin {0}", PluginName)); } @@ -980,7 +969,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi plugins.Remove(type); m64pCoreDetachPlugin(type); plugin.dllShutdown(); - FreeLibrary(plugin.dllHandle); + libLoader.FreePlatformSpecific(plugin.dllHandle); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs index 303073dfbc..ae44856892 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs @@ -74,7 +74,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES 4, 7, 14, 30, 60, 88, 118, 148, 188, 236, 354, 472, 708, 944, 1890, 3778 }; - public sealed class PulseUnit { public PulseUnit(APU apu, int unit) { this.unit = unit; this.apu = apu; } @@ -97,35 +96,35 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { ser.BeginSection("Pulse" + unit); - ser.Sync("duty_cnt", ref duty_cnt); - ser.Sync("env_loop", ref env_loop); - ser.Sync("env_constant", ref env_constant); - ser.Sync("env_cnt_value", ref env_cnt_value); - ser.Sync("len_halt", ref len_halt); + ser.Sync(nameof(duty_cnt), ref duty_cnt); + ser.Sync(nameof(env_loop), ref env_loop); + ser.Sync(nameof(env_constant), ref env_constant); + ser.Sync(nameof(env_cnt_value), ref env_cnt_value); + ser.Sync(nameof(len_halt), ref len_halt); - ser.Sync("sweep_en", ref sweep_en); - ser.Sync("sweep_divider_cnt", ref sweep_divider_cnt); - ser.Sync("sweep_negate", ref sweep_negate); - ser.Sync("sweep_shiftcount", ref sweep_shiftcount); - ser.Sync("sweep_reload", ref sweep_reload); + ser.Sync(nameof(sweep_en), ref sweep_en); + ser.Sync(nameof(sweep_divider_cnt), ref sweep_divider_cnt); + ser.Sync(nameof(sweep_negate), ref sweep_negate); + ser.Sync(nameof(sweep_shiftcount), ref sweep_shiftcount); + ser.Sync(nameof(sweep_reload), ref sweep_reload); - ser.Sync("len_cnt", ref len_cnt); - ser.Sync("timer_raw_reload_value", ref timer_raw_reload_value); - ser.Sync("timer_reload_value", ref timer_reload_value); + ser.Sync(nameof(len_cnt), ref len_cnt); + ser.Sync(nameof(timer_raw_reload_value), ref timer_raw_reload_value); + ser.Sync(nameof(timer_reload_value), ref timer_reload_value); - ser.Sync("lenctr_en", ref lenctr_en); + ser.Sync(nameof(lenctr_en), ref lenctr_en); - ser.Sync("swp_divider_counter", ref swp_divider_counter); - ser.Sync("swp_silence", ref swp_silence); - ser.Sync("duty_step", ref duty_step); - ser.Sync("timer_counter", ref timer_counter); - ser.Sync("sample", ref sample); - ser.Sync("duty_value", ref duty_value); + ser.Sync(nameof(swp_divider_counter), ref swp_divider_counter); + ser.Sync(nameof(swp_silence), ref swp_silence); + ser.Sync(nameof(duty_step), ref duty_step); + ser.Sync(nameof(timer_counter), ref timer_counter); + ser.Sync(nameof(sample), ref sample); + ser.Sync(nameof(duty_value), ref duty_value); - ser.Sync("env_start_flag", ref env_start_flag); - ser.Sync("env_divider", ref env_divider); - ser.Sync("env_counter", ref env_counter); - ser.Sync("env_output", ref env_output); + ser.Sync(nameof(env_start_flag), ref env_start_flag); + ser.Sync(nameof(env_divider), ref env_divider); + ser.Sync(nameof(env_counter), ref env_counter); + ser.Sync(nameof(env_output), ref env_output); ser.EndSection(); } @@ -395,25 +394,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { ser.BeginSection("Noise"); - ser.Sync("env_cnt_value", ref env_cnt_value); - ser.Sync("env_loop", ref env_loop); - ser.Sync("env_constant", ref env_constant); - ser.Sync("mode_cnt", ref mode_cnt); - ser.Sync("period_cnt", ref period_cnt); + ser.Sync(nameof(env_cnt_value), ref env_cnt_value); + ser.Sync(nameof(env_loop), ref env_loop); + ser.Sync(nameof(env_constant), ref env_constant); + ser.Sync(nameof(mode_cnt), ref mode_cnt); + ser.Sync(nameof(period_cnt), ref period_cnt); - ser.Sync("len_halt", ref len_halt); - ser.Sync("len_cnt", ref len_cnt); - ser.Sync("lenctr_en", ref lenctr_en); + ser.Sync(nameof(len_halt), ref len_halt); + ser.Sync(nameof(len_cnt), ref len_cnt); + ser.Sync(nameof(lenctr_en), ref lenctr_en); - ser.Sync("shift_register", ref shift_register); - ser.Sync("timer_counter", ref timer_counter); - ser.Sync("sample", ref sample); + ser.Sync(nameof(shift_register), ref shift_register); + ser.Sync(nameof(timer_counter), ref timer_counter); + ser.Sync(nameof(sample), ref sample); - ser.Sync("env_output", ref env_output); - ser.Sync("env_start_flag", ref env_start_flag); - ser.Sync("env_divider", ref env_divider); - ser.Sync("env_counter", ref env_counter); - ser.Sync("noise_bit", ref noise_bit); + ser.Sync(nameof(env_output), ref env_output); + ser.Sync(nameof(env_start_flag), ref env_start_flag); + ser.Sync(nameof(env_divider), ref env_divider); + ser.Sync(nameof(env_counter), ref env_counter); + ser.Sync(nameof(noise_bit), ref noise_bit); ser.EndSection(); } @@ -553,18 +552,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { ser.BeginSection("Triangle"); - ser.Sync("linear_counter_reload", ref linear_counter_reload); - ser.Sync("control_flag", ref control_flag); - ser.Sync("timer_cnt", ref timer_cnt); - ser.Sync("reload_flag", ref reload_flag); - ser.Sync("len_cnt", ref len_cnt); + ser.Sync(nameof(linear_counter_reload), ref linear_counter_reload); + ser.Sync(nameof(control_flag), ref control_flag); + ser.Sync(nameof(timer_cnt), ref timer_cnt); + ser.Sync(nameof(reload_flag), ref reload_flag); + ser.Sync(nameof(len_cnt), ref len_cnt); - ser.Sync("lenctr_en", ref lenctr_en); - ser.Sync("linear_counter", ref linear_counter); - ser.Sync("timer", ref timer); - ser.Sync("timer_cnt_reload", ref timer_cnt_reload); - ser.Sync("seq", ref seq); - ser.Sync("sample", ref sample); + ser.Sync(nameof(lenctr_en), ref lenctr_en); + ser.Sync(nameof(linear_counter), ref linear_counter); + ser.Sync(nameof(timer), ref timer); + ser.Sync(nameof(timer_cnt_reload), ref timer_cnt_reload); + ser.Sync(nameof(seq), ref seq); + ser.Sync(nameof(sample), ref sample); ser.EndSection(); } @@ -704,6 +703,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES sample_buffer_filled = false; out_deltacounter = 64; out_bits_remaining = 0; + user_address = 0x8000; // even though this can't be accessed by writing, it is indeed the power up address + user_length = 1; } bool irq_enabled; @@ -728,23 +729,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { ser.BeginSection("DMC"); - ser.Sync("irq_enabled", ref irq_enabled); - ser.Sync("loop_flag", ref loop_flag); - ser.Sync("timer_reload", ref timer_reload); + ser.Sync(nameof(irq_enabled), ref irq_enabled); + ser.Sync(nameof(loop_flag), ref loop_flag); + ser.Sync(nameof(timer_reload), ref timer_reload); - ser.Sync("timer", ref timer); - ser.Sync("user_address", ref user_address); - ser.Sync("user_length", ref user_length); + ser.Sync(nameof(timer), ref timer); + ser.Sync(nameof(user_address), ref user_address); + ser.Sync(nameof(user_length), ref user_length); - ser.Sync("sample_address", ref sample_address); - ser.Sync("sample_length", ref sample_length); - ser.Sync("sample_buffer", ref sample_buffer); - ser.Sync("sample_buffer_filled", ref sample_buffer_filled); + ser.Sync(nameof(sample_address), ref sample_address); + ser.Sync(nameof(sample_length), ref sample_length); + ser.Sync(nameof(sample_buffer), ref sample_buffer); + ser.Sync(nameof(sample_buffer_filled), ref sample_buffer_filled); - ser.Sync("out_shift", ref out_shift); - ser.Sync("out_bits_remaining", ref out_bits_remaining); - ser.Sync("out_deltacounter", ref out_deltacounter); - ser.Sync("out_silence", ref out_silence); + ser.Sync(nameof(out_shift), ref out_shift); + ser.Sync(nameof(out_bits_remaining), ref out_bits_remaining); + ser.Sync(nameof(out_deltacounter), ref out_deltacounter); + ser.Sync(nameof(out_silence), ref out_silence); ser.Sync("dmc_call_delay", ref delay); @@ -944,27 +945,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("dmc_irq", ref dmc_irq); - ser.Sync("pending_reg", ref pending_reg); - ser.Sync("pending_val", ref pending_val); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(dmc_irq), ref dmc_irq); + ser.Sync(nameof(pending_reg), ref pending_reg); + ser.Sync(nameof(pending_val), ref pending_val); - ser.Sync("sequencer_counter", ref sequencer_counter); - ser.Sync("sequencer_step", ref sequencer_step); - ser.Sync("sequencer_mode", ref sequencer_mode); - ser.Sync("sequencer_irq_inhibit;", ref sequencer_irq_inhibit); - ser.Sync("sequencer_irq", ref sequencer_irq); - ser.Sync("sequence_reset_pending", ref sequence_reset_pending); - ser.Sync("sequencer_irq_clear_pending", ref sequencer_irq_clear_pending); - ser.Sync("sequencer_irq_assert", ref sequencer_irq_assert); + ser.Sync(nameof(sequencer_counter), ref sequencer_counter); + ser.Sync(nameof(sequencer_step), ref sequencer_step); + ser.Sync(nameof(sequencer_mode), ref sequencer_mode); + ser.Sync(nameof(sequencer_irq_inhibit), ref sequencer_irq_inhibit); + ser.Sync(nameof(sequencer_irq), ref sequencer_irq); + ser.Sync(nameof(sequence_reset_pending), ref sequence_reset_pending); + ser.Sync(nameof(sequencer_irq_clear_pending), ref sequencer_irq_clear_pending); + ser.Sync(nameof(sequencer_irq_assert), ref sequencer_irq_assert); - ser.Sync("dmc_dma_countdown", ref dmc_dma_countdown); + ser.Sync(nameof(dmc_dma_countdown), ref dmc_dma_countdown); ser.Sync("sample_length_delay", ref pending_length_change); ser.Sync("dmc_called_from_write", ref call_from_write); ser.Sync("sequencer_tick_delay", ref seq_tick); ser.Sync("seq_val_to_apply", ref seq_val); - ser.Sync("sequencer_irq_flag", ref sequencer_irq_flag); - ser.Sync("len_clock_active", ref len_clock_active); + ser.Sync(nameof(sequencer_irq_flag), ref sequencer_irq_flag); + ser.Sync(nameof(len_clock_active), ref len_clock_active); + + ser.Sync(nameof(oldmix), ref oldmix); + ser.Sync(nameof(cart_sound), ref cart_sound); + ser.Sync(nameof(old_cart_sound), ref old_cart_sound); pulse[0].SyncState(ser); pulse[1].SyncState(ser); @@ -1257,127 +1262,118 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int pending_length_change; - public void RunOne(bool read) + public void RunOneFirst() { - if (read) - { - pulse[0].Run(); - pulse[1].Run(); - triangle.Run(); - noise.Run(); - dmc.Run(); - pulse[0].len_halt = false; - pulse[1].len_halt = false; - noise.len_halt = false; + pulse[0].Run(); + pulse[1].Run(); + triangle.Run(); + noise.Run(); + dmc.Run(); - } - else - { - if (pending_length_change>0) - { - pending_length_change--; - if (pending_length_change==0) - { - dmc.sample_length--; - } - } - - EmitSample(); - - // we need to predict if there will be a length clock here, because the sequencer ticks last, but the - // timer reload shouldn't happen if length clock and write happen simultaneously - // I'm not sure if we can avoid this by simply processing the sequencer first - // but at the moment that would break everything, so this is good enough for now - if (sequencer_counter == (sequencer_lut[0][1] - 1) || - (sequencer_counter == sequencer_lut[0][3] - 2 && sequencer_mode==0) || - (sequencer_counter == sequencer_lut[1][4] - 2 && sequencer_mode == 1)) - { - len_clock_active = true; - } - - // handle writes - // notes: this set up is a bit convoluded at the moment, mainly because APU behaviour is not entirely understood - // in partiuclar, there are several clock pulses affecting the APU, and when new written are latched is not known in detail - // the current code simply matches known behaviour - if (pending_reg != -1) - { - if (pending_reg == 0x4015 || pending_reg == 0x4015 || pending_reg == 0x4003 || pending_reg==0x4007) - { - _WriteReg(pending_reg, pending_val); - pending_reg = -1; - } - else if (dmc.timer%2==0) - { - _WriteReg(pending_reg, pending_val); - pending_reg = -1; - } - } - - len_clock_active = false; - - sequencer_tick(); - sequencer_write_tick(seq_val); - doing_tick_quarter = false; - - if (sequencer_irq_assert>0) { - sequencer_irq_assert--; - if (sequencer_irq_assert==0) - { - sequencer_irq = true; - } - } - - SyncIRQ(); - nes._irq_apu = irq_pending; - - // since the units run concurrently, the APU frame sequencer is ran last because - // it can change the ouput values of the pulse/triangle channels - // we want the changes to affect it on the *next* cycle. - - if (sequencer_irq_flag == false) - sequencer_irq = false; - - if (DebugCallbackDivider != 0) - { - if (DebugCallbackTimer == 0) - { - if (DebugCallback != null) - DebugCallback(); - DebugCallbackTimer = DebugCallbackDivider; - } - else DebugCallbackTimer--; - - } - } + pulse[0].len_halt = false; + pulse[1].len_halt = false; + noise.len_halt = false; } - public struct Delta + public void RunOneLast() { - public uint time; - public int value; - public Delta(uint time, int value) + if (pending_length_change > 0) { - this.time = time; - this.value = value; + pending_length_change--; + if (pending_length_change == 0) + { + dmc.sample_length--; + } + } + + // we need to predict if there will be a length clock here, because the sequencer ticks last, but the + // timer reload shouldn't happen if length clock and write happen simultaneously + // I'm not sure if we can avoid this by simply processing the sequencer first + // but at the moment that would break everything, so this is good enough for now + if (sequencer_counter == (sequencer_lut[0][1] - 1) || + (sequencer_counter == sequencer_lut[0][3] - 2 && sequencer_mode == 0) || + (sequencer_counter == sequencer_lut[1][4] - 2 && sequencer_mode == 1)) + { + len_clock_active = true; + } + + // handle writes + // notes: this set up is a bit convoluded at the moment, mainly because APU behaviour is not entirely understood + // in partiuclar, there are several clock pulses affecting the APU, and when new written are latched is not known in detail + // the current code simply matches known behaviour + if (pending_reg != -1) + { + if (pending_reg == 0x4015 || pending_reg == 0x4015 || pending_reg == 0x4003 || pending_reg == 0x4007) + { + _WriteReg(pending_reg, pending_val); + pending_reg = -1; + } + else if (dmc.timer % 2 == 0) + { + _WriteReg(pending_reg, pending_val); + pending_reg = -1; + } + } + + len_clock_active = false; + + sequencer_tick(); + sequencer_write_tick(seq_val); + doing_tick_quarter = false; + + if (sequencer_irq_assert > 0) + { + sequencer_irq_assert--; + if (sequencer_irq_assert == 0) + { + sequencer_irq = true; + } + } + + SyncIRQ(); + nes._irq_apu = irq_pending; + + // since the units run concurrently, the APU frame sequencer is ran last because + // it can change the ouput values of the pulse/triangle channels + // we want the changes to affect it on the *next* cycle. + + if (sequencer_irq_flag == false) + sequencer_irq = false; + + if (DebugCallbackDivider != 0) + { + if (DebugCallbackTimer == 0) + { + if (DebugCallback != null) + DebugCallback(); + DebugCallbackTimer = DebugCallbackDivider; + } + else DebugCallbackTimer--; + } } - public List dlist = new List(); - /// only call in board.ClockCPU() /// public void ExternalQueue(int value) { - // sampleclock is incremented right before board.ClockCPU() - dlist.Add(new Delta(sampleclock - 1, value)); + cart_sound = value + old_cart_sound; + + if (cart_sound != old_cart_sound) + { + recalculate = true; + old_cart_sound = cart_sound; + } } public uint sampleclock = 0; int oldmix = 0; + int cart_sound = 0; + int old_cart_sound = 0; - void EmitSample() + public int EmitSample() { if (recalculate) { @@ -1389,16 +1385,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int s_noise = noise.sample; int s_dmc = dmc.sample; - // int s_ext = 0; //gamepak - - /* - if (!EnableSquare1) s_pulse0 = 0; - if (!EnableSquare2) s_pulse1 = 0; - if (!EnableTriangle) s_tri = 0; - if (!EnableNoise) s_noise = 0; - if (!EnableDMC) s_dmc = 0; - */ - // more properly correct float pulse_out, tnd_out; if (s_pulse0 == 0 && s_pulse1 == 0) @@ -1410,13 +1396,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES float output = pulse_out + tnd_out; // output = output * 2 - 1; // this needs to leave enough headroom for straying DC bias due to the DMC unit getting stuck outputs. smb3 is bad about that. - int mix = (int)(20000 * output * (1 + m_vol/5)); + int mix = (int)(20000 * output * (1 + m_vol/5)) + cart_sound; - dlist.Add(new Delta(sampleclock, mix - oldmix)); oldmix = mix; + + return mix; } - sampleclock++; + return oldmix; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs index 22aa7188e0..aa796813e2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs @@ -21,8 +21,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr_banks_4k", ref chr_banks_4k); - ser.Sync("prg_bank_32k", ref prg_bank_32k); + ser.Sync(nameof(chr_banks_4k), ref chr_banks_4k); + ser.Sync(nameof(prg_bank_32k), ref prg_bank_32k); } public override bool Configure(NES.EDetectionOrigin origin) @@ -105,9 +105,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr_bank_8k", ref chr_bank_8k); - ser.Sync("prg_bank_32k", ref prg_bank_32k); - ser.Sync("isMapper79", ref isMapper79); + ser.Sync(nameof(chr_bank_8k), ref chr_bank_8k); + ser.Sync(nameof(prg_bank_32k), ref prg_bank_32k); + ser.Sync(nameof(isMapper79), ref isMapper79); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs index 28dd117a49..2fbf1b9aa3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs @@ -87,7 +87,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg",ref prg); + ser.Sync(nameof(prg), ref prg); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs index 6796424108..d8e990dd50 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs @@ -56,11 +56,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_reg_16k", ref prg_reg_16k); - ser.Sync("regs", ref regs); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_enabled", ref irq_enabled); - ser.Sync("irq_latch", ref irq_latch); + ser.Sync(nameof(prg_reg_16k), ref prg_reg_16k); + ser.Sync(nameof(regs), ref regs); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_enabled), ref irq_enabled); + ser.Sync(nameof(irq_latch), ref irq_latch); if (eprom != null) eprom.SyncState(ser); if (reader != null) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_02_74.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_02_74.cs index d6dbc7266a..0763442522 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_02_74.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_02_74.cs @@ -29,8 +29,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr_block", ref chr_block); - ser.Sync("chr_pos", ref chr_pos); + ser.Sync(nameof(chr_block), ref chr_block); + ser.Sync(nameof(chr_pos), ref chr_pos); ser.Sync("prg_bank_mask_16k", ref prg_bank_mask_32k); ser.Sync("prg_bank_16k", ref prg_bank_32k); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_161_32.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_161_32.cs index 3a5a722abb..142344184e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_161_32.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_161_32.cs @@ -43,10 +43,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg_bank_mask_16k", ref prg_bank_mask_16k); - ser.Sync("prg_bank_16k", ref prg_bank_16k); - ser.Sync("prg_banks_16k", ref prg_banks_16k); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg_bank_mask_16k), ref prg_bank_mask_16k); + ser.Sync(nameof(prg_bank_16k), ref prg_bank_16k); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); } void SyncPRG() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BxROM.cs index f1f2ffd275..39fc42c2ab 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BxROM.cs @@ -16,8 +16,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_bank_32k", ref prg_bank_32k); - ser.Sync("chr_bank_8k", ref chr_bank_8k); + ser.Sync(nameof(prg_bank_32k), ref prg_bank_32k); + ser.Sync(nameof(chr_bank_8k), ref chr_bank_8k); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs index 1f70954115..1788cf3574 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs @@ -154,9 +154,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("seicross", ref seicross); - ser.Sync("chr_enabled", ref chr_enabled); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(seicross), ref seicross); + ser.Sync(nameof(chr_enabled), ref chr_enabled); } public override byte ReadPRG(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CPROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CPROM.cs index 0542577863..7045c8c0d1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CPROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CPROM.cs @@ -64,7 +64,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr",ref chr); + ser.Sync(nameof(chr), ref chr); } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs index 3dd2914b9f..4c93fa4e7c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_16k", ref prg_banks_16k); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); } public override bool Configure(NES.EDetectionOrigin origin) @@ -111,9 +111,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_16k", ref prg_banks_16k); - ser.Sync("prg_block", ref prg_block); - ser.Sync("prg_page", ref prg_page); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); + ser.Sync(nameof(prg_block), ref prg_block); + ser.Sync(nameof(prg_page), ref prg_page); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs index b1ac0da1c2..4c9a315d3a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs @@ -51,14 +51,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_regs", ref prg_regs); - ser.Sync("chr_regs", ref chr_regs); - ser.Sync("IRQCount", ref IRQCount); - ser.Sync("IRQa", ref IRQa); - ser.Sync("bank", ref bank); - ser.Sync("mode", ref mode); - ser.Sync("is_2k_bank", ref is_2k_bank); - ser.Sync("is_not_2k_bank", ref is_not_2k_bank); + ser.Sync(nameof(prg_regs), ref prg_regs); + ser.Sync(nameof(chr_regs), ref chr_regs); + ser.Sync(nameof(IRQCount), ref IRQCount); + ser.Sync(nameof(IRQa), ref IRQa); + ser.Sync(nameof(bank), ref bank); + ser.Sync(nameof(mode), ref mode); + ser.Sync(nameof(is_2k_bank), ref is_2k_bank); + ser.Sync(nameof(is_not_2k_bank), ref is_not_2k_bank); } public void Mirroring() @@ -242,14 +242,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_regs", ref prg_regs); - ser.Sync("chr_regs", ref chr_regs); - ser.Sync("IRQCount", ref IRQCount); - ser.Sync("IRQa", ref IRQa); - ser.Sync("bank", ref bank); - ser.Sync("mode", ref mode); - ser.Sync("is_2k_bank", ref is_2k_bank); - ser.Sync("is_not_2k_bank", ref is_not_2k_bank); + ser.Sync(nameof(prg_regs), ref prg_regs); + ser.Sync(nameof(chr_regs), ref chr_regs); + ser.Sync(nameof(IRQCount), ref IRQCount); + ser.Sync(nameof(IRQa), ref IRQa); + ser.Sync(nameof(bank), ref bank); + ser.Sync(nameof(mode), ref mode); + ser.Sync(nameof(is_2k_bank), ref is_2k_bank); + ser.Sync(nameof(is_not_2k_bank), ref is_not_2k_bank); } public void Mirroring() @@ -433,8 +433,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr_regs", ref chr_regs); - ser.Sync("prg_regs", ref prg_regs); + ser.Sync(nameof(chr_regs), ref chr_regs); + ser.Sync(nameof(prg_regs), ref prg_regs); } public override void WritePRG(int addr, byte value) @@ -451,7 +451,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else if (addr == 0x200) { - IRQCount &= 0xFF00; IRQCount |= value; ; + IRQCount &= 0xFF00; IRQCount |= value; IRQSignal = false; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs index 979abfbdd9..8e33a2420a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs @@ -121,7 +121,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("exp", ref exp, false); + ser.Sync(nameof(exp), ref exp, false); } public override void NESSoftReset() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs index de789fb36e..59dddf8770 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs @@ -63,11 +63,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.BeginSection("DatachBarcode"); - ser.Sync("cycles", ref cycles); - ser.Sync("output", ref output); - ser.Sync("stream_idx", ref stream_idx); - ser.Sync("data", ref data, false); + ser.BeginSection(nameof(DatachBarcode)); + ser.Sync(nameof(cycles), ref cycles); + ser.Sync(nameof(output), ref output); + ser.Sync(nameof(stream_idx), ref stream_idx); + ser.Sync(nameof(data), ref data, false); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs index 61a0c5fe7c..16800da327 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs @@ -66,25 +66,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("irq_target", ref irq_target); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_enabled", ref irq_enabled); - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("in_frame", ref in_frame); - ser.Sync("exram_mode", ref exram_mode); - ser.Sync("chr_mode", ref chr_mode); - ser.Sync("prg_mode", ref prg_mode); - ser.Sync("chr_reg_high", ref chr_reg_high); - ser.Sync("ab_mode", ref ab_mode); - ser.Sync("regs_a", ref regs_a); - ser.Sync("regs_b", ref regs_b); - ser.Sync("regs_prg", ref regs_prg); - ser.Sync("nt_modes", ref nt_modes); - ser.Sync("nt_fill_tile", ref nt_fill_tile); - ser.Sync("nt_fill_attrib", ref nt_fill_attrib); - ser.Sync("wram_bank", ref wram_bank); - ser.Sync("last_nt_read", ref last_nt_read); - ser.Sync("EXRAM", ref EXRAM, false); + ser.Sync(nameof(irq_target), ref irq_target); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_enabled), ref irq_enabled); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(in_frame), ref in_frame); + ser.Sync(nameof(exram_mode), ref exram_mode); + ser.Sync(nameof(chr_mode), ref chr_mode); + ser.Sync(nameof(prg_mode), ref prg_mode); + ser.Sync(nameof(chr_reg_high), ref chr_reg_high); + ser.Sync(nameof(ab_mode), ref ab_mode); + ser.Sync(nameof(regs_a), ref regs_a); + ser.Sync(nameof(regs_b), ref regs_b); + ser.Sync(nameof(regs_prg), ref regs_prg); + ser.Sync(nameof(nt_modes), ref nt_modes); + ser.Sync(nameof(nt_fill_tile), ref nt_fill_tile); + ser.Sync(nameof(nt_fill_attrib), ref nt_fill_attrib); + ser.Sync(nameof(wram_bank), ref wram_bank); + ser.Sync(nameof(last_nt_read), ref last_nt_read); + ser.Sync(nameof(EXRAM), ref EXRAM, false); SyncPRGBanks(); SyncCHRBanks(); @@ -244,7 +244,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int bank_1k = addr >> 10; int ofs = addr & ((1 << 10) - 1); - if (exram_mode == 1 && NES.ppu.ppuphase == PPU.PPUPHASE.BG) + if (exram_mode == 1 && NES.ppu.ppuphase == PPU.PPU_PHASE_BG) { int exram_addr = last_nt_read; int bank_4k = EXRAM[exram_addr] & 0x3F; @@ -255,15 +255,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // top 2 bits of address come from chr_reg_high bank_1k += chr_reg_high << 8; ofs = addr & (4 * 1024 - 1); - goto MAPPED; + + bank_1k &= chr_bank_mask_1k; + addr = (bank_1k << 10) | ofs; + return addr; } if (NES.ppu.reg_2000.obj_size_16) { bool isPattern = NES.ppu.PPUON; - if (NES.ppu.ppuphase == PPU.PPUPHASE.OBJ && isPattern) + if (NES.ppu.ppuphase == PPU.PPU_PHASE_OBJ && isPattern) bank_1k = a_banks_1k[bank_1k]; - else if (NES.ppu.ppuphase == PPU.PPUPHASE.BG && isPattern) + else if (NES.ppu.ppuphase == PPU.PPU_PHASE_BG && isPattern) bank_1k = b_banks_1k[bank_1k]; else { @@ -278,7 +281,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank_1k = a_banks_1k[bank_1k]; } - MAPPED: bank_1k &= chr_bank_mask_1k; addr = (bank_1k<<10)|ofs; return addr; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper017.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper017.cs index 5cf8366e46..4606856e21 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper017.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper017.cs @@ -109,12 +109,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); - ser.Sync("prg_regs_8k", ref prg_regs_8k); - ser.Sync("chr_regs_1k", ref chr_regs_1k); + ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); + ser.Sync(nameof(chr_regs_1k), ref chr_regs_1k); - ser.Sync("irq_enable", ref irq_enable); - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("irq_count", ref irq_count); + ser.Sync(nameof(irq_enable), ref irq_enable); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(irq_count), ref irq_count); } public override byte ReadPRG(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs index 72a36b5308..fdb10c00d0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs @@ -56,10 +56,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(BizHawk.Common.Serializer ser) { base.SyncState(ser); - ser.Sync("c", ref c); - ser.Sync("e", ref e); - ser.Sync("prginner", ref prginner); - ser.Sync("prgouter", ref prgouter); + ser.Sync(nameof(c), ref c); + ser.Sync(nameof(e), ref e); + ser.Sync(nameof(prginner), ref prginner); + ser.Sync(nameof(prgouter), ref prgouter); } public override void NESSoftReset() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs index 699abea7c3..1edc25e1f5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs @@ -78,8 +78,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg", ref prg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg), ref prg); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs index 480f4c160b..b3765682d6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs @@ -92,8 +92,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_bank_32k", ref prg_bank_32k); - ser.Sync("chr_bank_8k", ref chr_bank_8k); + ser.Sync(nameof(prg_bank_32k), ref prg_bank_32k); + ser.Sync(nameof(chr_bank_8k), ref chr_bank_8k); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM-74_161_161_21_138.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM-74_161_161_21_138.cs index d62a37d17e..79b01d0590 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM-74_161_161_21_138.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM-74_161_161_21_138.cs @@ -32,8 +32,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg", ref prg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg), ref prg); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM_TAM_S1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM_TAM_S1.cs index 7b51a69e07..42d535df0d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM_TAM_S1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM_TAM_S1.cs @@ -37,9 +37,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_bank_mask_16k", ref prg_bank_mask_16k); - ser.Sync("prg_bank_16k", ref prg_bank_16k); - ser.Sync("prg_banks_16k", ref prg_banks_16k); + ser.Sync(nameof(prg_bank_mask_16k), ref prg_bank_mask_16k); + ser.Sync(nameof(prg_bank_16k), ref prg_bank_16k); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); } void SyncPRG() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_G101.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_G101.cs index 77a2b56ca5..2c90571c13 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_G101.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_G101.cs @@ -28,10 +28,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_regs_8k", ref prg_regs_8k); - ser.Sync("chr_regs_1k", ref chr_regs_1k); - ser.Sync("prg_mode", ref chr_regs_1k); - ser.Sync("mirror_mode", ref chr_regs_1k); + ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); + ser.Sync(nameof(chr_regs_1k), ref chr_regs_1k); + ser.Sync(nameof(prg_mode), ref chr_regs_1k); + ser.Sync(nameof(mirror_mode), ref chr_regs_1k); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_H3001.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_H3001.cs index 3775f47222..3bc0c0ca84 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_H3001.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_H3001.cs @@ -31,13 +31,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_regs_8k", ref prg_regs_8k); - ser.Sync("chr_regs_1k", ref chr_regs_1k); - ser.Sync("irq_counter_enabled", ref irq_counter_enabled); - ser.Sync("irq_asserted", ref irq_asserted); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_reload", ref irq_reload); - ser.Sync("clock_counter", ref clock_counter); + ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); + ser.Sync(nameof(chr_regs_1k), ref chr_regs_1k); + ser.Sync(nameof(irq_counter_enabled), ref irq_counter_enabled); + ser.Sync(nameof(irq_asserted), ref irq_asserted); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_reload), ref irq_reload); + ser.Sync(nameof(clock_counter), ref clock_counter); SyncIRQ(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_05_06_07.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_05_06_07.cs index d32bce9697..9b9b8db7af 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_05_06_07.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_05_06_07.cs @@ -53,7 +53,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); + ser.Sync(nameof(chr), ref chr); } public override void WriteWRAM(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_13.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_13.cs index 0fdc6039db..333ac7f667 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_13.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_13.cs @@ -74,8 +74,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg", ref prg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg), ref prg); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs index e3ccbe97ca..74c64a3c57 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs @@ -66,9 +66,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("latch", ref latch); - ser.Sync("prg_banks_16k", ref prg_banks_16k); - ser.Sync("chr_banks_8k", ref chr_banks_8k); + ser.Sync(nameof(latch), ref latch); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); + ser.Sync(nameof(chr_banks_8k), ref chr_banks_8k); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs index 143525ba20..52191278ea 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs @@ -63,9 +63,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("latch", ref latch); - ser.Sync("prg_banks_16k", ref prg_banks_16k); - ser.Sync("chr_banks_8k", ref chr_banks_8k); + ser.Sync(nameof(latch), ref latch); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); + ser.Sync(nameof(chr_banks_8k), ref chr_banks_8k); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_SS8806.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_SS8806.cs index 4e824669c5..30c09d7496 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_SS8806.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_SS8806.cs @@ -51,13 +51,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_banks_8k", ref prg_banks_8k); - ser.Sync("chr_banks_1k", ref chr_banks_1k); - ser.Sync("ppuclock", ref ppuclock); - ser.Sync("irqclock", ref irqclock); - ser.Sync("irqreload", ref irqreload); - ser.Sync("irqcountwidth", ref irqcountwidth); - ser.Sync("irqcountpaused", ref irqcountpaused); + ser.Sync(nameof(prg_banks_8k), ref prg_banks_8k); + ser.Sync(nameof(chr_banks_1k), ref chr_banks_1k); + ser.Sync(nameof(ppuclock), ref ppuclock); + ser.Sync(nameof(irqclock), ref irqclock); + ser.Sync(nameof(irqreload), ref irqreload); + ser.Sync(nameof(irqcountwidth), ref irqcountwidth); + ser.Sync(nameof(irqcountpaused), ref irqcountpaused); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Jaleco-JF_11_14.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Jaleco-JF_11_14.cs index 4ebee4b4db..aaf436a29a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Jaleco-JF_11_14.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Jaleco-JF_11_14.cs @@ -68,8 +68,8 @@ Other chips used: Sunsoft-1 public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg", ref prg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg), ref prg); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs index 09583ef19c..9dc3bf9ac9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs @@ -122,11 +122,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_reg", ref prg_reg); - ser.Sync("chr_reg", ref chr_reg); - ser.Sync("prg_mode", ref prg_mode); + ser.Sync(nameof(prg_reg), ref prg_reg); + ser.Sync(nameof(chr_reg), ref chr_reg); + ser.Sync(nameof(prg_mode), ref prg_mode); ser.Sync("chip", ref chip_offset); - ser.Sync("eRAM", ref eRAM); + ser.Sync(nameof(eRAM), ref eRAM); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-MAX15.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-MAX15.cs index d772ce9b9d..408d47daa8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-MAX15.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-MAX15.cs @@ -47,12 +47,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("mode", ref mode); - ser.Sync("block_high", ref block_high); - ser.Sync("block_low", ref block_low); - ser.Sync("prg_bank", ref prg_bank); + ser.Sync(nameof(mode), ref mode); + ser.Sync(nameof(block_high), ref block_high); + ser.Sync(nameof(block_low), ref block_low); + ser.Sync(nameof(prg_bank), ref prg_bank); ser.Sync("chr_bank", ref chr_bank_high); - ser.Sync("reg_0_locked", ref reg_0_locked); + ser.Sync(nameof(reg_0_locked), ref reg_0_locked); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs index a2414fa58d..23eb8af17a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs @@ -41,11 +41,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("wram_enabled", ref wram_enabled); - ser.Sync("wram_h_enabled", ref wram_h_enabled); - ser.Sync("wram_l_enabled", ref wram_l_enabled); - ser.Sync("wram_h_enabled_write", ref wram_h_enabled_write); - ser.Sync("wram_l_enabled_write", ref wram_l_enabled_write); + ser.Sync(nameof(wram_enabled), ref wram_enabled); + ser.Sync(nameof(wram_h_enabled), ref wram_h_enabled); + ser.Sync(nameof(wram_l_enabled), ref wram_l_enabled); + ser.Sync(nameof(wram_h_enabled_write), ref wram_h_enabled_write); + ser.Sync(nameof(wram_l_enabled_write), ref wram_l_enabled_write); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs index 999d23605b..cddb957e3d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs @@ -147,21 +147,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public virtual void SyncState(Serializer ser) { - ser.Sync("reg_addr", ref reg_addr); - ser.Sync("chr_mode", ref chr_mode); - ser.Sync("prg_mode", ref prg_mode); - ser.Sync("regs", ref regs); - ser.Sync("mirror", ref mirror); - ser.Sync("a12_old", ref a12_old); - ser.Sync("irq_reload", ref irq_reload); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("irq_enable", ref irq_enable); - ser.Sync("separator_counter", ref separator_counter); - ser.Sync("irq_countdown", ref irq_countdown); - ser.Sync("irq_reload_flag", ref irq_reload_flag); - ser.Sync("wram_enable", ref wram_enable); - ser.Sync("wram_write_protect", ref wram_write_protect); + ser.Sync(nameof(reg_addr), ref reg_addr); + ser.Sync(nameof(chr_mode), ref chr_mode); + ser.Sync(nameof(prg_mode), ref prg_mode); + ser.Sync(nameof(regs), ref regs); + ser.Sync(nameof(mirror), ref mirror); + ser.Sync(nameof(a12_old), ref a12_old); + ser.Sync(nameof(irq_reload), ref irq_reload); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(irq_enable), ref irq_enable); + ser.Sync(nameof(separator_counter), ref separator_counter); + ser.Sync(nameof(irq_countdown), ref irq_countdown); + ser.Sync(nameof(irq_reload_flag), ref irq_reload_flag); + ser.Sync(nameof(wram_enable), ref wram_enable); + ser.Sync(nameof(wram_write_protect), ref wram_write_protect); Sync(); } @@ -346,7 +346,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); mmc3.SyncState(ser); - ser.Sync("extra_vrom", ref extra_vrom); + ser.Sync(nameof(extra_vrom), ref extra_vrom); } protected virtual int Get_CHRBank_1K(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs index 7ad1eacfed..24214c6344 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs @@ -24,8 +24,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("block0", ref block0); - ser.Sync("block1", ref block1); + ser.Sync(nameof(block0), ref block0); + ser.Sync(nameof(block1), ref block1); } int block0, block1; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper037.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper037.cs index 19b96dbac9..1e082ecef3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper037.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper037.cs @@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("exreg", ref exreg); + ser.Sync(nameof(exreg), ref exreg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs index 46747c18ee..dda7224722 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs @@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("block_select", ref block_select); + ser.Sync(nameof(block_select), ref block_select); } int block_select; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs index 26563599a8..59afd1d5d4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs @@ -27,9 +27,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("block", ref block); - ser.Sync("prg", ref prg); - ser.Sync("mode", ref mode); + ser.Sync(nameof(block), ref block); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(mode), ref mode); } int block, prg; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper052.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper052.cs index 1715b9e211..e8aab5b12e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper052.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper052.cs @@ -29,11 +29,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("lock_regs", ref lock_regs); - ser.Sync("prg_block_size", ref prg_block_size); - ser.Sync("chr_block_size", ref chr_block_size); - ser.Sync("prg_or", ref prg_or); - ser.Sync("chr_or", ref chr_or); + ser.Sync(nameof(lock_regs), ref lock_regs); + ser.Sync(nameof(prg_block_size), ref prg_block_size); + ser.Sync(nameof(chr_block_size), ref chr_block_size); + ser.Sync(nameof(prg_or), ref prg_or); + ser.Sync(nameof(chr_or), ref chr_or); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper115.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper115.cs index c78e0d813c..fd46dacfe8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper115.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper115.cs @@ -28,9 +28,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_mode_mapper", ref prg_mode_mapper); - ser.Sync("prg_page", ref prg_page); - ser.Sync("chr_block_or", ref chr_block_or); + ser.Sync(nameof(prg_mode_mapper), ref prg_mode_mapper); + ser.Sync(nameof(prg_page), ref prg_page); + ser.Sync(nameof(chr_block_or), ref chr_block_or); } bool prg_mode_mapper; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs index 2f589102ec..802869ce8b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs @@ -32,7 +32,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("exRegs", ref exRegs); + ser.Sync(nameof(exRegs), ref exRegs); } public override byte ReadEXP(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper134.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper134.cs index e898949ce3..f2e5a13f8d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper134.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper134.cs @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("reg", ref reg); + ser.Sync(nameof(reg), ref reg); } public override void WriteWRAM(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper165.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper165.cs index 0c284c6f2d..ee95bb2214 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper165.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper165.cs @@ -32,8 +32,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("latch0", ref latch0); - ser.Sync("latch1", ref latch1); + ser.Sync(nameof(latch0), ref latch0); + ser.Sync(nameof(latch1), ref latch1); } // same as ReadPPU, but doesn't process latches diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper189.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper189.cs index f176f97dbf..92ef82768a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper189.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper189.cs @@ -41,7 +41,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); + ser.Sync(nameof(prg), ref prg); } public override void WriteEXP(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs index 1a1599ac83..4fdd8ce17c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs @@ -39,9 +39,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.BeginSection("Mapper196"); - ser.Sync("prgmode", ref prgmode); - ser.Sync("prgreg", ref prgreg); + ser.BeginSection(nameof(Mapper196)); + ser.Sync(nameof(prgmode), ref prgmode); + ser.Sync(nameof(prgreg), ref prgreg); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper197.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper197.cs index 1adfda1ca9..dfa7405530 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper197.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper197.cs @@ -59,7 +59,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr_regs_1k_512", ref chr_regs_1k_512); + ser.Sync(nameof(chr_regs_1k_512), ref chr_regs_1k_512); } public override void Dispose() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs index ab619862db..56aaf80215 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs @@ -35,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("exRegs", ref exRegs); + ser.Sync(nameof(exRegs), ref exRegs); } public override byte ReadPPU(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs index 3496146d08..fe37155ab2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs @@ -84,11 +84,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("exRegs", ref exRegs); - ser.Sync("is_mk3", ref is_mk3); - ser.Sync("ptg_regs_8k", ref prg_regs_8k); - ser.Sync("prg_mask", ref prg_mask_8k); - ser.Sync("chr_mask", ref chr_mask_1k); + ser.Sync(nameof(exRegs), ref exRegs); + ser.Sync(nameof(is_mk3), ref is_mk3); + ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); + ser.Sync(nameof(prg_mask), ref prg_mask_8k); + ser.Sync(nameof(chr_mask), ref chr_mask_1k); } public void sync_prg(int i) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs index ed2a41300f..5510b72bf1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs @@ -50,10 +50,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("exRegs", ref exRegs); - ser.Sync("ptg_regs_8k", ref prg_regs_8k); - ser.Sync("prg_mask", ref prg_mask_8k); - ser.Sync("chr_mask", ref chr_mask_1k); + ser.Sync(nameof(exRegs), ref exRegs); + ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); + ser.Sync(nameof(prg_mask), ref prg_mask_8k); + ser.Sync(nameof(chr_mask), ref chr_mask_1k); } public void sync_prg() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs index 13d30b938d..306dc183f3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs @@ -147,11 +147,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("exregs", ref exregs, false); - ser.Sync("prgregs", ref prgregs, false); - ser.Sync("chrregs", ref chrregs, false); - ser.Sync("bits_rev", ref bits_rev); - ser.Sync("reg_value", ref reg_value); + ser.Sync(nameof(exregs), ref exregs, false); + ser.Sync(nameof(prgregs), ref prgregs, false); + ser.Sync(nameof(chrregs), ref chrregs, false); + ser.Sync(nameof(bits_rev), ref bits_rev); + ser.Sync(nameof(reg_value), ref reg_value); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs index d529fc0ced..b51c128d6b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper238.cs @@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("reg", ref reg); + ser.Sync(nameof(reg), ref reg); } public override byte ReadEXP(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs index 5f4de42af4..c139cb7770 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs @@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("chr_mode", ref chr_mode); + ser.Sync(nameof(chr_mode), ref chr_mode); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper249.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper249.cs index eff310aab1..e54d85a944 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper249.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper249.cs @@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("piratecrap", ref piratecrap); + ser.Sync(nameof(piratecrap), ref piratecrap); } public override void WriteEXP(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs index d2baf71db5..ce270c2098 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs @@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("regs", ref regs); + ser.Sync(nameof(regs), ref regs); } public override byte ReadWRAM(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/NES-QJ.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/NES-QJ.cs index 5dd2335ead..49c7326aae 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/NES-QJ.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/NES-QJ.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("block", ref block); + ser.Sync(nameof(block), ref block); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs index e8642c2aec..03f47bafea 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs @@ -50,10 +50,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("exRegs", ref exRegs); - ser.Sync("ptg_regs_8k", ref prg_regs_8k); - ser.Sync("prg_mask", ref prg_mask_8k); - ser.Sync("chr_mask", ref chr_mask_1k); + ser.Sync(nameof(exRegs), ref exRegs); + ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); + ser.Sync(nameof(prg_mask), ref prg_mask_8k); + ser.Sync(nameof(chr_mask), ref chr_mask_1k); } public override void WriteEXP(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs index 6566ed5664..e40334ff5b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs @@ -36,10 +36,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(BizHawk.Common.Serializer ser) { base.SyncState(ser); - ser.Sync("exmode", ref exmode); - ser.Sync("exprg", ref exprg, false); - ser.Sync("exchr", ref exchr, false); - ser.Sync("exnmt", ref exnmt); + ser.Sync(nameof(exmode), ref exmode); + ser.Sync(nameof(exprg), ref exprg, false); + ser.Sync(nameof(exchr), ref exchr, false); + ser.Sync(nameof(exnmt), ref exnmt); } public override byte ReadPRG(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs index 0fe238bfeb..6a665045ec 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs @@ -123,7 +123,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("nametables", ref nametables, false); + ser.Sync(nameof(nametables), ref nametables, false); } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs index e15ac229bf..62aeae6a9b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs @@ -101,7 +101,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_8k", ref prg_banks_8k); + ser.Sync(nameof(prg_banks_8k), ref prg_banks_8k); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper028.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper028.cs index a7f2e43cc3..9fe341ec84 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper028.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper028.cs @@ -186,11 +186,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("reg", ref reg); - ser.Sync("chr", ref chr); - ser.Sync("prg", ref prg); - ser.Sync("mode", ref mode); - ser.Sync("outer", ref outer); + ser.Sync(nameof(reg), ref reg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(mode), ref mode); + ser.Sync(nameof(outer), ref outer); if (!ser.IsWriter) Sync(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs index 69649784f3..a5296db020 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs @@ -55,13 +55,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("chr", ref chr); - ser.Sync("flash_state", ref flash_state); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(flash_state), ref flash_state); int tmp = (int)flash_mode; - ser.Sync("flash_mode", ref tmp); + ser.Sync(nameof(flash_mode), ref tmp); flash_mode = (flashmode)tmp; - ser.Sync("flash_rom", ref flash_rom, true); + ser.Sync(nameof(flash_rom), ref flash_rom, true); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper034.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper034.cs index 34436b66cd..05173bf5a2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper034.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper034.cs @@ -1,7 +1,8 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { @@ -13,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int prg_bank_mask_32k, chr_bank_mask_4k; //state - int[] chr = new int[2]; + ByteBuffer chr = new ByteBuffer(2); int prg; @@ -38,6 +39,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void Dispose() + { + chr.Dispose(); + base.Dispose(); + } + public override byte ReadPPU(int addr) { if (addr < 0x2000) @@ -64,10 +71,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg = value & prg_bank_mask_32k; break; case 0x1ffe: - chr[0] = value & chr_bank_mask_4k; + chr[0] = (byte)(value & chr_bank_mask_4k); break; case 0x1fff: - chr[1] = value & chr_bank_mask_4k; + chr[1] = (byte)(value & chr_bank_mask_4k); break; default: // on NINA, the regs sit on top of WRAM @@ -75,5 +82,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES break; } } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(chr), ref chr); + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper036.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper036.cs index 8c55044f87..7f2a2e7b2c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper036.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper036.cs @@ -94,11 +94,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg", ref prg); - ser.Sync("R", ref R); - ser.Sync("M", ref M); - ser.Sync("P", ref P); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(R), ref R); + ser.Sync(nameof(M), ref M); + ser.Sync(nameof(P), ref P); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper038.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper038.cs index acb94fa21f..53ce1bb7d4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper038.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper038.cs @@ -66,8 +66,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg", ref prg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg), ref prg); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper040.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper040.cs index 38f252b00c..847395cc4b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper040.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper040.cs @@ -72,9 +72,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("irqcnt", ref irqcnt); - ser.Sync("irqactive", ref irqactive); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(irqcnt), ref irqcnt); + ser.Sync(nameof(irqactive), ref irqactive); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper041.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper041.cs index 3fa15a8c9b..28dade5c45 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper041.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper041.cs @@ -62,9 +62,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("chr", ref chr); - ser.Sync("regenable", ref regenable); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(regenable), ref regenable); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper042.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper042.cs index dd950ebc1a..3ae0c2b2e6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper042.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper042.cs @@ -93,10 +93,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("chr", ref chr); - ser.Sync("irqenable", ref irqenable); - ser.Sync("irqcnt", ref irqcnt); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(irqenable), ref irqenable); + ser.Sync(nameof(irqcnt), ref irqcnt); } public override byte ReadPPU(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs index 49e87f21da..eae264daff 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs @@ -129,10 +129,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("irqenable", ref irqenable); - ser.Sync("irqcnt", ref irqcnt); - ser.Sync("swap", ref swap); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(irqenable), ref irqenable); + ser.Sync(nameof(irqcnt), ref irqcnt); + ser.Sync(nameof(swap), ref swap); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper045.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper045.cs index 2a56268faa..78d737bbd3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper045.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper045.cs @@ -38,8 +38,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("regs", ref regs); - ser.Sync("lock_regs", ref lock_regs); + ser.Sync(nameof(regs), ref regs); + ser.Sync(nameof(lock_regs), ref lock_regs); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper046.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper046.cs index 4401ef27b7..14bfd3b6d8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper046.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper046.cs @@ -77,10 +77,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_bank_32k_H", ref prg_bank_32k_H); - ser.Sync("prg_bank_32k_L", ref prg_bank_32k_L); - ser.Sync("chr_bank_8k_H", ref chr_bank_8k_H); - ser.Sync("chr_bank_8k_L", ref chr_bank_8k_L); + ser.Sync(nameof(prg_bank_32k_H), ref prg_bank_32k_H); + ser.Sync(nameof(prg_bank_32k_L), ref prg_bank_32k_L); + ser.Sync(nameof(chr_bank_8k_H), ref chr_bank_8k_H); + ser.Sync(nameof(chr_bank_8k_L), ref chr_bank_8k_L); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper057.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper057.cs index 32416906da..02ef8eb9b6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper057.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper057.cs @@ -33,11 +33,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_reg", ref prg_reg); - ser.Sync("chr_reg", ref chr_reg); - ser.Sync("chr_reg_low_0", ref chr_reg); - ser.Sync("chr_reg_low_1", ref chr_reg); - ser.Sync("prg_mode", ref prg_mode); + ser.Sync(nameof(prg_reg), ref prg_reg); + ser.Sync(nameof(chr_reg), ref chr_reg); + ser.Sync(nameof(chr_reg_low_0), ref chr_reg); + ser.Sync(nameof(chr_reg_low_1), ref chr_reg); + ser.Sync(nameof(prg_mode), ref prg_mode); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs index f9193d10f5..6167a25e02 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs @@ -61,9 +61,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_reg", ref prg_reg); - ser.Sync("chr_reg", ref chr_reg); - ser.Sync("prg_mode", ref prg_mode); + ser.Sync(nameof(prg_reg), ref prg_reg); + ser.Sync(nameof(chr_reg), ref chr_reg); + ser.Sync(nameof(prg_mode), ref prg_mode); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs index c808732674..cd0a062a47 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs @@ -75,11 +75,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg0", ref prg0); - ser.Sync("prg1", ref prg1); - ser.Sync("prg2", ref prg2); - ser.Sync("prg3", ref prg3); - ser.Sync("open_bus", ref open_bus); + ser.Sync(nameof(prg0), ref prg0); + ser.Sync(nameof(prg1), ref prg1); + ser.Sync(nameof(prg2), ref prg2); + ser.Sync(nameof(prg3), ref prg3); + ser.Sync(nameof(open_bus), ref open_bus); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper069.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper069.cs index 35034f8aa1..44fa9ea502 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper069.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper069.cs @@ -73,17 +73,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("addr_reg", ref addr_reg); - ser.Sync("regs", ref regs); - ser.Sync("prg_banks_8k", ref prg_banks_8k); - ser.Sync("wram_bank", ref wram_bank); - ser.Sync("wram_ram_selected", ref wram_ram_selected); - ser.Sync("wram_ram_enabled", ref wram_ram_enabled); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_countdown", ref irq_countdown); - ser.Sync("irq_enabled", ref irq_enabled); - ser.Sync("irq_asserted", ref irq_asserted); - ser.Sync("clock_counter", ref clock_counter); + ser.Sync(nameof(addr_reg), ref addr_reg); + ser.Sync(nameof(regs), ref regs); + ser.Sync(nameof(prg_banks_8k), ref prg_banks_8k); + ser.Sync(nameof(wram_bank), ref wram_bank); + ser.Sync(nameof(wram_ram_selected), ref wram_ram_selected); + ser.Sync(nameof(wram_ram_enabled), ref wram_ram_enabled); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_countdown), ref irq_countdown); + ser.Sync(nameof(irq_enabled), ref irq_enabled); + ser.Sync(nameof(irq_asserted), ref irq_asserted); + ser.Sync(nameof(clock_counter), ref clock_counter); SyncIrq(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper078.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper078.cs index 776279dfe2..79af148e52 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper078.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper078.cs @@ -43,11 +43,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg_bank_mask_16k", ref prg_bank_mask_16k); - ser.Sync("prg_bank_16k", ref prg_bank_16k); - ser.Sync("prg_banks_16k", ref prg_banks_16k); - ser.Sync("holydiver", ref holydiver); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg_bank_mask_16k), ref prg_bank_mask_16k); + ser.Sync(nameof(prg_bank_16k), ref prg_bank_16k); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); + ser.Sync(nameof(holydiver), ref holydiver); } void SyncPRG() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs index 296cf53d6d..1b0246b699 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs @@ -132,54 +132,54 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); - ser.Sync("prg_regs", ref prg_regs); - ser.Sync("chr_regs", ref chr_regs); - ser.Sync("chr_latches", ref chr_latches); - ser.Sync("nt_regs", ref nt_regs); + ser.Sync(nameof(prg_regs), ref prg_regs); + ser.Sync(nameof(chr_regs), ref chr_regs); + ser.Sync(nameof(chr_latches), ref chr_latches); + ser.Sync(nameof(nt_regs), ref nt_regs); - ser.Sync("prg_banks", ref prg_banks); - ser.Sync("chr_banks", ref chr_banks); - ser.Sync("ram_bytes", ref ram_bytes); + ser.Sync(nameof(prg_banks), ref prg_banks); + ser.Sync(nameof(chr_banks), ref chr_banks); + ser.Sync(nameof(ram_bytes), ref ram_bytes); - ser.Sync("dipswitch_0", ref dipswitch_0); - ser.Sync("dipswitch_1", ref dipswitch_1); + ser.Sync(nameof(dipswitch_0), ref dipswitch_0); + ser.Sync(nameof(dipswitch_1), ref dipswitch_1); - ser.Sync("prg_bank_mask_8k", ref prg_bank_mask_8k); - ser.Sync("chr_bank_mask_1k", ref chr_bank_mask_1k); + ser.Sync(nameof(prg_bank_mask_8k), ref prg_bank_mask_8k); + ser.Sync(nameof(chr_bank_mask_1k), ref chr_bank_mask_1k); - ser.Sync("prg_mode_select", ref prg_mode_select); - ser.Sync("chr_mode_select", ref chr_mode_select); - ser.Sync("sram_prg", ref sram_prg); - ser.Sync("ram_bank", ref ram_bank); + ser.Sync(nameof(prg_mode_select), ref prg_mode_select); + ser.Sync(nameof(chr_mode_select), ref chr_mode_select); + ser.Sync(nameof(sram_prg), ref sram_prg); + ser.Sync(nameof(ram_bank), ref ram_bank); - ser.Sync("mapper_035", ref mapper_035); - ser.Sync("mapper_090", ref mapper_090); - ser.Sync("mapper_209", ref mapper_209); - ser.Sync("mapper_211", ref mapper_211); + ser.Sync(nameof(mapper_035), ref mapper_035); + ser.Sync(nameof(mapper_090), ref mapper_090); + ser.Sync(nameof(mapper_209), ref mapper_209); + ser.Sync(nameof(mapper_211), ref mapper_211); - ser.Sync("nt_advanced_control", ref nt_advanced_control); - ser.Sync("nt_ram_disable", ref nt_ram_disable); - ser.Sync("nt_ram_select", ref nt_ram_select); + ser.Sync(nameof(nt_advanced_control), ref nt_advanced_control); + ser.Sync(nameof(nt_ram_disable), ref nt_ram_disable); + ser.Sync(nameof(nt_ram_select), ref nt_ram_select); - ser.Sync("mirror_chr", ref mirror_chr); - ser.Sync("chr_block_mode", ref chr_block_mode); - ser.Sync("chr_block", ref chr_block); - ser.Sync("prg_block", ref prg_block); + ser.Sync(nameof(mirror_chr), ref mirror_chr); + ser.Sync(nameof(chr_block_mode), ref chr_block_mode); + ser.Sync(nameof(chr_block), ref chr_block); + ser.Sync(nameof(prg_block), ref prg_block); - ser.Sync("multiplicator", ref multiplicator); - ser.Sync("multiplicand", ref multiplicand); - ser.Sync("multiplication_result", ref multiplication_result); + ser.Sync(nameof(multiplicator), ref multiplicator); + ser.Sync(nameof(multiplicand), ref multiplicand); + ser.Sync(nameof(multiplication_result), ref multiplication_result); - ser.Sync("irq_enable", ref irq_enable); - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("irq_count_down", ref irq_count_down); - ser.Sync("irq_count_up", ref irq_count_up); - ser.Sync("irq_prescaler_size", ref irq_prescaler_size); - ser.Sync("irq_source", ref irq_source); - ser.Sync("prescaler", ref prescaler); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("xor_reg", ref xor_reg); - ser.Sync("a12_old", ref a12_old); + ser.Sync(nameof(irq_enable), ref irq_enable); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(irq_count_down), ref irq_count_down); + ser.Sync(nameof(irq_count_up), ref irq_count_up); + ser.Sync(nameof(irq_prescaler_size), ref irq_prescaler_size); + ser.Sync(nameof(irq_source), ref irq_source); + ser.Sync(nameof(prescaler), ref prescaler); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(xor_reg), ref xor_reg); + ser.Sync(nameof(a12_old), ref a12_old); Sync(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper101.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper101.cs index 70cb903b1c..d877201589 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper101.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper101.cs @@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr_bank_8k", ref chr_bank_8k); + ser.Sync(nameof(chr_bank_8k), ref chr_bank_8k); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper103.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper103.cs index efad39f3e4..8d7c19f4ba 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper103.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper103.cs @@ -73,8 +73,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("romenable", ref romenable); - ser.Sync("prg", ref prg); + ser.Sync(nameof(romenable), ref romenable); + ser.Sync(nameof(prg), ref prg); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper106.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper106.cs index 5dee9d4a37..90e44ae3d7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper106.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper106.cs @@ -42,9 +42,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("regs", ref regs); - ser.Sync("IRQa", ref IRQa); - ser.Sync("IRQCount", ref IRQCount); + ser.Sync(nameof(regs), ref regs); + ser.Sync(nameof(IRQa), ref IRQa); + ser.Sync(nameof(IRQCount), ref IRQCount); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper107.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper107.cs index 9dbfc85673..acc558c3ac 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper107.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper107.cs @@ -13,8 +13,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_bank_32k", ref prg_bank_32k); - ser.Sync("chr_bank_8k", ref chr_bank_8k); + ser.Sync(nameof(prg_bank_32k), ref prg_bank_32k); + ser.Sync(nameof(chr_bank_8k), ref chr_bank_8k); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper108.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper108.cs index 74c745c285..8a6841a2b1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper108.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper108.cs @@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); + ser.Sync(nameof(prg), ref prg); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper120.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper120.cs index 1c907bdd87..3256092829 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper120.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper120.cs @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_reg", ref prg_reg); + ser.Sync(nameof(prg_reg), ref prg_reg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper125.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper125.cs index 50d5f1b4f4..c3e44c9ad3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper125.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper125.cs @@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); + ser.Sync(nameof(reg), ref reg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs index 05e81b9d21..1062eec3e2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs @@ -117,11 +117,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg", ref prg); - ser.Sync("is172", ref is172); - ser.Sync("is173", ref is173); - ser.Sync("reg", ref reg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(is172), ref is172); + ser.Sync(nameof(is173), ref is173); + ser.Sync(nameof(reg), ref reg); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper150.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper150.cs index 99b153d352..873a70e052 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper150.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper150.cs @@ -36,8 +36,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("latch", ref latch); - ser.Sync("cmd", ref cmd); + ser.Sync(nameof(latch), ref latch); + ser.Sync(nameof(cmd), ref cmd); } public override void WriteEXP(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper156.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper156.cs index 696cba92e6..a49935f9e0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper156.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper156.cs @@ -110,7 +110,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // do not need to serialize mirroring, as that's handled for us for (int i = 0; i < chr.Length; i++) ser.Sync("chr" + i, ref chr[i]); - ser.Sync("prg", ref prg); + ser.Sync(nameof(prg), ref prg); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper168.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper168.cs index 71fbb2ee36..99ec6833db 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper168.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper168.cs @@ -87,9 +87,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("chr", ref chr); - ser.Sync("irqclock", ref irqclock); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(irqclock), ref irqclock); } public override void ClockCPU() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs index 37f90c2a0f..11fd6ee818 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs @@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); + ser.Sync(nameof(reg), ref reg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper175.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper175.cs index 5a2c0b2658..9755c01bd9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper175.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper175.cs @@ -31,15 +31,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("delay", ref delay); + ser.Sync(nameof(delay), ref delay); - ser.Sync("reg", ref reg); - ser.Sync("mirr", ref mirr); + ser.Sync(nameof(reg), ref reg); + ser.Sync(nameof(mirr), ref mirr); - ser.Sync("chrReg", ref chrReg); - ser.Sync("prgReg8", ref prgReg8); - ser.Sync("prgRegC", ref prgRegC); - ser.Sync("prgRegE", ref prgRegE); + ser.Sync(nameof(chrReg), ref chrReg); + ser.Sync(nameof(prgReg8), ref prgReg8); + ser.Sync(nameof(prgRegC), ref prgRegC); + ser.Sync(nameof(prgRegE), ref prgRegE); base.SyncState(ser); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper176.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper176.cs index 7427ae7c47..1b2c828aa4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper176.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper176.cs @@ -124,10 +124,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("mirror", ref mirror); - ser.Sync("prg_banks_8k", ref prg_banks_8k); - ser.Sync("chr_banks_8k", ref chr_banks_8k); - ser.Sync("sbw", ref sbw); + ser.Sync(nameof(mirror), ref mirror); + ser.Sync(nameof(prg_banks_8k), ref prg_banks_8k); + ser.Sync(nameof(chr_banks_8k), ref chr_banks_8k); + ser.Sync(nameof(sbw), ref sbw); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper177.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper177.cs index 5c31161cd3..13ab928420 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper177.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper177.cs @@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); + ser.Sync(nameof(prg), ref prg); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper178.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper178.cs index c3f1610282..dc00dc4de9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper178.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper178.cs @@ -67,8 +67,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_32k", ref prg_banks_32k); - ser.Sync("reg4802", ref reg4802); + ser.Sync(nameof(prg_banks_32k), ref prg_banks_32k); + ser.Sync(nameof(reg4802), ref reg4802); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper180.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper180.cs index 099fa34624..1f6677ad84 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper180.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper180.cs @@ -37,9 +37,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_bank_mask_16k", ref prg_bank_mask_16k); - ser.Sync("prg_bank_16k", ref prg_bank_16k); - ser.Sync("prg_banks_16k", ref prg_banks_16k); + ser.Sync(nameof(prg_bank_mask_16k), ref prg_bank_mask_16k); + ser.Sync(nameof(prg_bank_16k), ref prg_bank_16k); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); } void SyncPRG() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs index acdbb7b7df..cf5551146a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs @@ -44,8 +44,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("chr", ref chr); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(chr), ref chr); } private void SetMirroring(int mirr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs index 51aa6e1286..4f3df52dae 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper186.cs @@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { ser.Sync("SRAM", ref _SRAM); - ser.Sync("regs", ref regs); + ser.Sync(nameof(regs), ref regs); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper188.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper188.cs index dfa03fb586..dd37801bd2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper188.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper188.cs @@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg", ref prg); + ser.Sync(nameof(prg), ref prg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs index fef5c4916b..5e17d8b56c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs @@ -13,8 +13,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_reg", ref prg_reg); - ser.Sync("chr_reg", ref chr_reg, false); + ser.Sync(nameof(prg_reg), ref prg_reg); + ser.Sync(nameof(chr_reg), ref chr_reg, false); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper193.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper193.cs index fe3284e036..e0f4e0de88 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper193.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper193.cs @@ -92,8 +92,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_8k", ref prg_banks_8k); - ser.Sync("chr_banks_2k", ref chr_banks_2k); + ser.Sync(nameof(prg_banks_8k), ref prg_banks_8k); + ser.Sync(nameof(chr_banks_2k), ref chr_banks_2k); } public override void WriteWRAM(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs index 8ad3e871ba..063cac6307 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs @@ -66,8 +66,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_reg_16k", ref prg_reg_16k); - ser.Sync("chr_reg_8k", ref chr_reg_8k); + ser.Sync(nameof(prg_reg_16k), ref prg_reg_16k); + ser.Sync(nameof(chr_reg_8k), ref chr_reg_8k); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper201.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper201.cs index 2ad9dd0ebc..f5594f9bcb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper201.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper201.cs @@ -63,7 +63,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); + ser.Sync(nameof(reg), ref reg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper203.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper203.cs index 857e3d91ea..cb7f07e21a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper203.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper203.cs @@ -64,8 +64,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_reg_16k", ref prg_reg_16k); - ser.Sync("chr_reg_8k", ref chr_reg_8k); + ser.Sync(nameof(prg_reg_16k), ref prg_reg_16k); + ser.Sync(nameof(chr_reg_8k), ref chr_reg_8k); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper212.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper212.cs index 93d286a2be..ea1e0cc422 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper212.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper212.cs @@ -36,7 +36,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("_reg", ref _reg); + ser.Sync(nameof(_reg), ref _reg); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper213.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper213.cs index 4315b308f1..2b1ef978fa 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper213.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper213.cs @@ -29,7 +29,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("_reg", ref _reg); + ser.Sync(nameof(_reg), ref _reg); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper220.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper220.cs index bc8f4c5682..67bae19969 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper220.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper220.cs @@ -32,7 +32,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); + ser.Sync(nameof(reg), ref reg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper221.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper221.cs index 0474c55126..0ed3601e59 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper221.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper221.cs @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("regs", ref regs); + ser.Sync(nameof(regs), ref regs); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper222.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper222.cs index d249370787..8747abf6f4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper222.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper222.cs @@ -66,14 +66,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //Console.WriteLine("IRQ GO: SL {0} val {1}", NES.ppu.ppur.status.sl, value); //break; case 0x1000: SetMirrorType(!value.Bit(0) ? EMirrorType.Vertical : EMirrorType.Horizontal);break; - case 0x3000: chr[0] = value & chr_bank_mask_1k; ; break; - case 0x3002: chr[1] = value & chr_bank_mask_1k; ; break; - case 0x4000: chr[2] = value & chr_bank_mask_1k; ; break; - case 0x4002: chr[3] = value & chr_bank_mask_1k; ; break; - case 0x5000: chr[4] = value & chr_bank_mask_1k; ; break; - case 0x5002: chr[5] = value & chr_bank_mask_1k; ; break; - case 0x6000: chr[6] = value & chr_bank_mask_1k; ; break; - case 0x6002: chr[7] = value & chr_bank_mask_1k; ; break; + case 0x3000: chr[0] = value & chr_bank_mask_1k; break; + case 0x3002: chr[1] = value & chr_bank_mask_1k; break; + case 0x4000: chr[2] = value & chr_bank_mask_1k; break; + case 0x4002: chr[3] = value & chr_bank_mask_1k; break; + case 0x5000: chr[4] = value & chr_bank_mask_1k; break; + case 0x5002: chr[5] = value & chr_bank_mask_1k; break; + case 0x6000: chr[6] = value & chr_bank_mask_1k; break; + case 0x6002: chr[7] = value & chr_bank_mask_1k; break; } @@ -120,10 +120,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg", ref prg, false); - ser.Sync("chr", ref chr, false); - ser.Sync("irq_time", ref irq_time); - ser.Sync("irq_counting", ref irq_counting); + ser.Sync(nameof(prg), ref prg, false); + ser.Sync(nameof(chr), ref chr, false); + ser.Sync(nameof(irq_time), ref irq_time); + ser.Sync(nameof(irq_counting), ref irq_counting); base.SyncState(ser); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper225.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper225.cs index 09c5cc47e5..23b768a9dc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper225.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper225.cs @@ -33,10 +33,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_reg", ref prg_reg); - ser.Sync("chr_reg", ref chr_reg); - ser.Sync("prg_mode", ref prg_mode); - ser.Sync("eRAM", ref eRAM); + ser.Sync(nameof(prg_reg), ref prg_reg); + ser.Sync(nameof(chr_reg), ref chr_reg); + ser.Sync(nameof(prg_mode), ref prg_mode); + ser.Sync(nameof(eRAM), ref eRAM); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper226.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper226.cs index 95d55040d2..5b26257276 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper226.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper226.cs @@ -48,10 +48,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_page", ref prg_page); - ser.Sync("prg_mode", ref prg_mode); - ser.Sync("resetFlag", ref resetFlag); - ser.Sync("resetSwitchMode", ref resetSwitchMode); + ser.Sync(nameof(prg_page), ref prg_page); + ser.Sync(nameof(prg_mode), ref prg_mode); + ser.Sync(nameof(resetFlag), ref resetFlag); + ser.Sync(nameof(resetSwitchMode), ref resetSwitchMode); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs index 464944047e..baaa6995b8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs @@ -120,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); + ser.Sync(nameof(prg), ref prg); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs index 5356d1d130..a271b134fa 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs @@ -91,9 +91,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("contra_mode", ref contra_mode); - ser.Sync("prg_page", ref prg_page); - ser.Sync("prg_mode", ref prg_mode); + ser.Sync(nameof(contra_mode), ref contra_mode); + ser.Sync(nameof(prg_page), ref prg_page); + ser.Sync(nameof(prg_mode), ref prg_mode); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs index fa5d8b6173..3233fe7de9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs @@ -57,7 +57,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_reg", ref prg_reg); + ser.Sync(nameof(prg_reg), ref prg_reg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper233.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper233.cs index 678f7141c2..367526136d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper233.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper233.cs @@ -82,8 +82,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_page", ref prg_page); - ser.Sync("prg_mode", ref prg_mode); + ser.Sync(nameof(prg_page), ref prg_page); + ser.Sync(nameof(prg_mode), ref prg_mode); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper236.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper236.cs index f08add262c..6bbb192846 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper236.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper236.cs @@ -41,11 +41,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("isLargeBanks", ref isLargeBanks); - ser.Sync("large_bank", ref large_bank); - ser.Sync("prg_bank", ref prg_bank); - ser.Sync("chr_bank", ref chr_bank); - ser.Sync("bank_mode", ref bank_mode); + ser.Sync(nameof(isLargeBanks), ref isLargeBanks); + ser.Sync(nameof(large_bank), ref large_bank); + ser.Sync(nameof(prg_bank), ref prg_bank); + ser.Sync(nameof(chr_bank), ref chr_bank); + ser.Sync(nameof(bank_mode), ref bank_mode); ser.Sync("Cart_Switch", ref CartSwitch_70in1); ser.Sync("Cart_Switch", ref CartSwitch_800in1); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper240.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper240.cs index d0218f87f9..ea32eb0e0e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper240.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper240.cs @@ -38,8 +38,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_bank_32k", ref prg_bank_32k); - ser.Sync("chr_bank_8k", ref chr_bank_8k); + ser.Sync(nameof(prg_bank_32k), ref prg_bank_32k); + ser.Sync(nameof(chr_bank_8k), ref chr_bank_8k); } public override byte ReadPPU(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper241.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper241.cs index 7499234655..6296d6ac39 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper241.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper241.cs @@ -58,7 +58,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_32k", ref prg_banks_32k); + ser.Sync(nameof(prg_banks_32k), ref prg_banks_32k); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper242.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper242.cs index 8a45658cda..38989c8956 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper242.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper242.cs @@ -55,7 +55,7 @@ mirroring - both public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); + ser.Sync(nameof(prg), ref prg); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs index 3c92f064c0..647575faf3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs @@ -36,8 +36,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg_addr", ref reg_addr); - ser.Sync("regs", ref regs); + ser.Sync(nameof(reg_addr), ref reg_addr); + ser.Sync(nameof(regs), ref regs); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs index 365c7f9ee6..da6e5b5724 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs @@ -98,8 +98,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_8k", ref prg_banks_8k); - ser.Sync("chr_banks_2k", ref chr_banks_2k); + ser.Sync(nameof(prg_banks_8k), ref prg_banks_8k); + ser.Sync(nameof(chr_banks_2k), ref chr_banks_2k); } public override void WriteWRAM(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs index 52af4d130e..88de5db5fc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs @@ -44,8 +44,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("preg", ref preg); - ser.Sync("creg", ref creg); + ser.Sync(nameof(preg), ref preg); + ser.Sync(nameof(creg), ref creg); } public override void ClockCPU() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs index 89bb8d6dc0..79426e2bf4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs @@ -43,8 +43,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); ser.Sync("preg", ref prg); - ser.Sync("chrlo", ref chrlo); - ser.Sync("chrhi", ref chrhi); + ser.Sync(nameof(chrlo), ref chrlo); + ser.Sync(nameof(chrhi), ref chrhi); } public override void ClockCPU() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper50.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper50.cs index 18cd9bfaad..11794ba28b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper50.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper50.cs @@ -31,11 +31,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("ppu_cyclecount", ref ppu_cyclecount); - ser.Sync("prg_bank", ref prg_bank); - ser.Sync("irq_enable", ref irq_enable); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_ready", ref irq_ready); + ser.Sync(nameof(ppu_cyclecount), ref ppu_cyclecount); + ser.Sync(nameof(prg_bank), ref prg_bank); + ser.Sync(nameof(irq_enable), ref irq_enable); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_ready), ref irq_ready); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs index d9ff278ff9..aac8e1b7a4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs @@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("_reg", ref _reg); + ser.Sync(nameof(_reg), ref _reg); } public override void WritePRG(int addr, byte value) @@ -107,7 +107,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("resetSwitch", ref resetSwitch); + ser.Sync(nameof(resetSwitch), ref resetSwitch); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs index 6f69ce26a2..2fd0a4841c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs @@ -61,8 +61,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_page", ref prg_page); - ser.Sync("prg_mode", ref prg_mode); + ser.Sync(nameof(prg_page), ref prg_page); + ser.Sync(nameof(prg_mode), ref prg_mode); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs index 2c463c41d5..fe6e7ede65 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs @@ -66,9 +66,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("prg_reg", ref prg_reg); - ser.Sync("chr_reg", ref chr_reg); - ser.Sync("prg_mode", ref prg_mode); + ser.Sync(nameof(prg_reg), ref prg_reg); + ser.Sync(nameof(chr_reg), ref chr_reg); + ser.Sync(nameof(prg_mode), ref prg_mode); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs index fb17de069a..c222b0e32b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs @@ -201,17 +201,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES base.SyncState(ser); scnt.SyncState(ser); - ser.Sync("c000_swappable", ref c000_swappable); + ser.Sync(nameof(c000_swappable), ref c000_swappable); ser.Sync("prg_16k_mode", ref prg_32k_mode); - ser.Sync("irq_enable", ref irq_enable); - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("irq_count", ref irq_count); - ser.Sync("prg_a", ref prg_a); - ser.Sync("prg_b", ref prg_b); - ser.Sync("init_sequence", ref init_sequence); - ser.Sync("chip_select", ref chip_select); - ser.Sync("wram_disable", ref wram_disable); - ser.Sync("prg_banks_16k", ref prg_banks_16k); + ser.Sync(nameof(irq_enable), ref irq_enable); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(irq_count), ref irq_count); + ser.Sync(nameof(prg_a), ref prg_a); + ser.Sync(nameof(prg_b), ref prg_b); + ser.Sync(nameof(init_sequence), ref init_sequence); + ser.Sync(nameof(chip_select), ref chip_select); + ser.Sync(nameof(wram_disable), ref wram_disable); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); if (ser.IsReader) Sync(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs index a3bf9dc415..bbc752cd2a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs @@ -84,11 +84,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_4k", ref prg_banks_4k); - ser.Sync("Patch_Vectors", ref Patch_Vectors); - ser.Sync("CurrentSong", ref CurrentSong); - ser.Sync("InitPending", ref InitPending); - ser.Sync("ButtonState", ref ButtonState); + ser.Sync(nameof(prg_banks_4k), ref prg_banks_4k); + ser.Sync(nameof(Patch_Vectors), ref Patch_Vectors); + ser.Sync(nameof(CurrentSong), ref CurrentSong); + ser.Sync(nameof(InitPending), ref InitPending); + ser.Sync(nameof(ButtonState), ref ButtonState); } public void InitNSF(NSFFormat nsf) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs index e6d2ddac41..d9be399703 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs @@ -45,18 +45,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_8k", ref prg_banks_8k); - ser.Sync("chr_banks_1k", ref chr_banks_1k); + ser.Sync(nameof(prg_banks_8k), ref prg_banks_8k); + ser.Sync(nameof(chr_banks_1k), ref chr_banks_1k); for (int i = 0; i < vram_enable.Length; i++) ser.Sync("vram_enable_" + i, ref vram_enable[i]); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_enabled", ref irq_enabled); - ser.Sync("irq_pending", ref irq_pending); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_enabled), ref irq_enabled); + ser.Sync(nameof(irq_pending), ref irq_pending); SyncIRQ(); - ser.Sync("audio_cycles", ref audio_cycles); + ser.Sync(nameof(audio_cycles), ref audio_cycles); audio.SyncState(ser); - ser.Sync("audio_disable", ref audio_disable); - ser.Sync("prgram_write", ref prgram_write); + ser.Sync(nameof(audio_disable), ref audio_disable); + ser.Sync(nameof(prgram_write), ref prgram_write); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs index be3f8ce59d..45f192721b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs @@ -78,9 +78,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg, false); - ser.Sync("chr", ref chr, false); - ser.Sync("wramenable", ref wramenable); + ser.Sync(nameof(prg), ref prg, false); + ser.Sync(nameof(chr), ref chr, false); + ser.Sync(nameof(wramenable), ref wramenable); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs index 7908eef567..89a3f3b548 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs @@ -78,9 +78,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg, false); - ser.Sync("chr", ref chr, false); - ser.Sync("port", ref port); + ser.Sync(nameof(prg), ref prg, false); + ser.Sync(nameof(chr), ref chr, false); + ser.Sync(nameof(port), ref port); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper112.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper112.cs index 913ed0e80a..2e99aa0b5e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper112.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper112.cs @@ -47,9 +47,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("reg_addr", ref reg_addr); - ser.Sync("regs", ref regs); - ser.Sync("chr_outer_Reg", ref chr_outer_reg); + ser.Sync(nameof(reg_addr), ref reg_addr); + ser.Sync(nameof(regs), ref regs); + ser.Sync(nameof(chr_outer_reg), ref chr_outer_reg); Sync(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namco163Audio.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namco163Audio.cs index 6a45136c1f..eea85483c9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namco163Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namco163Audio.cs @@ -101,10 +101,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("ram", ref ram, false); - ser.Sync("addr", ref addr); - ser.Sync("autoincrement", ref autoincrement); - ser.Sync("ch", ref ch); + ser.Sync(nameof(ram), ref ram, false); + ser.Sync(nameof(addr), ref addr); + ser.Sync(nameof(autoincrement), ref autoincrement); + ser.Sync(nameof(ch), ref ch); } Action enqueuer; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs index 6cb98ebfbd..d2fff1a5ac 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs @@ -38,8 +38,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public virtual void SyncState(Serializer ser) { - ser.Sync("reg_addr", ref reg_addr); - ser.Sync("regs", ref regs); + ser.Sync(nameof(reg_addr), ref reg_addr); + ser.Sync(nameof(regs), ref regs); Sync(); } @@ -123,9 +123,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); if (NES._isVS) - ser.Sync("CIRAM_VS", ref CIRAM_VS, false); + ser.Sync(nameof(CIRAM_VS), ref CIRAM_VS, false); - ser.Sync("tko_security", ref tko_security); + ser.Sync(nameof(tko_security), ref tko_security); mapper.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NanJing.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NanJing.cs index 61ff11113b..7229ee1ffe 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NanJing.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NanJing.cs @@ -157,12 +157,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("reg0", ref reg0); - ser.Sync("reg1", ref reg1); - ser.Sync("prg", ref prg); - ser.Sync("security", ref security); - ser.Sync("trigger", ref trigger); - ser.Sync("strobe", ref strobe); + ser.Sync(nameof(reg0), ref reg0); + ser.Sync(nameof(reg1), ref reg1); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(security), ref security); + ser.Sync(nameof(trigger), ref trigger); + ser.Sync(nameof(strobe), ref strobe); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NovelDiamond.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NovelDiamond.cs index 58b62e693e..5f495f9284 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NovelDiamond.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NovelDiamond.cs @@ -45,8 +45,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("chr", ref chr); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(chr), ref chr); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/PxROM_FxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/PxROM_FxROM.cs index 73f567325d..13511e2e34 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/PxROM_FxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/PxROM_FxROM.cs @@ -20,9 +20,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_reg", ref prg_reg); - ser.Sync("chr_banks_4k", ref chr_banks_4k); - ser.Sync("chr_latches", ref chr_latches); + ser.Sync(nameof(prg_reg), ref prg_reg); + ser.Sync(nameof(chr_banks_4k), ref chr_banks_4k); + ser.Sync(nameof(chr_latches), ref chr_latches); if (ser.IsReader) SyncPRG(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SEEPROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SEEPROM.cs index c1eb5895b0..a708bef9e4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SEEPROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SEEPROM.cs @@ -245,17 +245,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.BeginSection("SEEPROM"); - ser.Sync("rom", ref rom, false); - ser.Sync("OutEnable", ref OutEnable); - ser.Sync("SCK", ref SCK); - ser.Sync("SDA", ref SDA); - ser.Sync("PullDown", ref PullDown); - ser.Sync("BitsLeft", ref BitsLeft); - ser.Sync("Data", ref Data); - ser.Sync("Addr", ref Addr); + ser.BeginSection(nameof(SEEPROM)); + ser.Sync(nameof(rom), ref rom, false); + ser.Sync(nameof(OutEnable), ref OutEnable); + ser.Sync(nameof(SCK), ref SCK); + ser.Sync(nameof(SDA), ref SDA); + ser.Sync(nameof(PullDown), ref PullDown); + ser.Sync(nameof(BitsLeft), ref BitsLeft); + ser.Sync(nameof(Data), ref Data); + ser.Sync(nameof(Addr), ref Addr); int tmp = (int)State; - ser.Sync("State", ref tmp); + ser.Sync(nameof(State), ref tmp); State = (EState)tmp; ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs index 37565a1aae..8444e8a7bf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs @@ -158,10 +158,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("port", ref port); - ser.Sync("prg", ref prg); - ser.Sync("chr", ref chr, false); - ser.Sync("simple", ref simple); + ser.Sync(nameof(port), ref port); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(chr), ref chr, false); + ser.Sync(nameof(simple), ref simple); } } @@ -304,9 +304,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("port", ref port); - ser.Sync("prg", ref prg); - ser.Sync("chr", ref chr, false); + ser.Sync(nameof(port), ref port); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(chr), ref chr, false); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs index 7b27880341..1cbfcfe8d9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs @@ -108,8 +108,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg", ref prg); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg), ref prg); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs index 361a5b3d31..6ea2340e68 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs @@ -32,8 +32,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("regs", ref regs); - ser.Sync("is167", ref is167); + ser.Sync(nameof(regs), ref regs); + ser.Sync(nameof(is167), ref is167); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1.cs index ba379f2201..4b10191bb0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1.cs @@ -61,8 +61,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("left_piece", ref left_piece); - ser.Sync("right_piece", ref right_piece); + ser.Sync(nameof(left_piece), ref left_piece); + ser.Sync(nameof(right_piece), ref right_piece); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs index 09b48a0ed2..2a690fb454 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs @@ -46,7 +46,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(BizHawk.Common.Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); + ser.Sync(nameof(prg), ref prg); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m89.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m89.cs index 3d1ab46852..29d921bb43 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m89.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m89.cs @@ -41,10 +41,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg_bank_mask_16k", ref prg_bank_mask_16k); - ser.Sync("prg_bank_16k", ref prg_bank_16k); - ser.Sync("prg_banks_16k", ref prg_banks_16k); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg_bank_mask_16k), ref prg_bank_mask_16k); + ser.Sync(nameof(prg_bank_16k), ref prg_bank_16k); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); } void SyncPRG() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m93.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m93.cs index 08aaa0f9b5..e577b11123 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m93.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m93.cs @@ -42,9 +42,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_bank_mask_16k", ref prg_bank_mask_16k); - ser.Sync("prg_bank_16k", ref prg_bank_16k); - ser.Sync("prg_banks_16k", ref prg_banks_16k); + ser.Sync(nameof(prg_bank_mask_16k), ref prg_bank_mask_16k); + ser.Sync(nameof(prg_bank_16k), ref prg_bank_16k); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); } void SyncPRG() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs index 997440082c..7c22a49f52 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs @@ -27,13 +27,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("toggle", ref toggle); - ser.Sync("prg_banks_16k", ref prg_banks_16k); - ser.Sync("chr_banks_2k", ref chr_banks_2k); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_enable", ref irq_enable); - ser.Sync("irq_asserted", ref irq_asserted); - ser.Sync("clock_counter", ref clock_counter); + ser.Sync(nameof(toggle), ref toggle); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); + ser.Sync(nameof(chr_banks_2k), ref chr_banks_2k); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_enable), ref irq_enable); + ser.Sync(nameof(irq_asserted), ref irq_asserted); + ser.Sync(nameof(clock_counter), ref clock_counter); if (NES.IsVS) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft4.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft4.cs index 12c5699dae..01ec7b9cd4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft4.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft4.cs @@ -29,11 +29,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr_regs_2k", ref chr_regs_2k); - ser.Sync("nt_regs", ref nt_regs); - ser.Sync("prg_regs_16k", ref prg_regs_16k); - ser.Sync("flag_m", ref flag_m); - ser.Sync("flag_r", ref flag_r); + ser.Sync(nameof(chr_regs_2k), ref chr_regs_2k); + ser.Sync(nameof(nt_regs), ref nt_regs); + ser.Sync(nameof(prg_regs_16k), ref prg_regs_16k); + ser.Sync(nameof(flag_m), ref flag_m); + ser.Sync(nameof(flag_r), ref flag_r); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs index 22f90619b4..1eeb61ed64 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs @@ -54,14 +54,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { scnt.SyncState(ser); - ser.Sync("chr_mode", ref chr_mode); - ser.Sync("prg_mode", ref prg_mode); - ser.Sync("prg_slot", ref prg_slot); - ser.Sync("chr_0", ref chr_0); - ser.Sync("chr_1", ref chr_1); - ser.Sync("wram_disable", ref wram_disable); - ser.Sync("prg", ref prg); - ser.SyncEnum("mirror", ref mirror); + ser.Sync(nameof(chr_mode), ref chr_mode); + ser.Sync(nameof(prg_mode), ref prg_mode); + ser.Sync(nameof(prg_slot), ref prg_slot); + ser.Sync(nameof(chr_0), ref chr_0); + ser.Sync(nameof(chr_1), ref chr_1); + ser.Sync(nameof(wram_disable), ref wram_disable); + ser.Sync(nameof(prg), ref prg); + ser.SyncEnum(nameof(mirror), ref mirror); SyncCHR(); SyncPRG(); @@ -103,8 +103,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("shift_count", ref shift_count); - ser.Sync("shift_val", ref shift_val); + ser.Sync(nameof(shift_count), ref shift_count); + ser.Sync(nameof(shift_val), ref shift_val); } public Action Reset; @@ -393,8 +393,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); mmc1.SyncState(ser); - ser.Sync("ppuclock", ref ppuclock); - ser.Sync("chr_wram_enable", ref chr_wram_enable); + ser.Sync(nameof(ppuclock), ref ppuclock); + ser.Sync(nameof(chr_wram_enable), ref chr_wram_enable); if (NES._isVS) ser.Sync("VS_CIRAM", ref CIRAM_VS, false); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TAITO_74_161_161_32.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TAITO_74_161_161_32.cs index dc23872ef8..0e490a241a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TAITO_74_161_161_32.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TAITO_74_161_161_32.cs @@ -40,10 +40,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); - ser.Sync("prg_bank_mask_16k", ref prg_bank_mask_16k); - ser.Sync("prg_bank_16k", ref prg_bank_16k); - ser.Sync("prg_banks_16k", ref prg_banks_16k); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(prg_bank_mask_16k), ref prg_bank_mask_16k); + ser.Sync(nameof(prg_bank_16k), ref prg_bank_16k); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); } void SyncPRG() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs index 9c17d9e76d..9e2123011e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs @@ -41,20 +41,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("regs", ref regs); - ser.Sync("address", ref address); - ser.Sync("chr_1k", ref chr_1k); - ser.Sync("chr_mode", ref chr_mode); - ser.Sync("prg_mode", ref prg_mode); - ser.Sync("irq_countdown", ref irq_countdown); - ser.Sync("a12_old", ref a12_old); - ser.Sync("irq_reload", ref irq_reload); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("irq_enable", ref irq_enable); - ser.Sync("irq_mode", ref irq_mode); - ser.Sync("irq_reload_pending", ref irq_reload_pending); - ser.Sync("separator_counter", ref separator_counter); + ser.Sync(nameof(regs), ref regs); + ser.Sync(nameof(address), ref address); + ser.Sync(nameof(chr_1k), ref chr_1k); + ser.Sync(nameof(chr_mode), ref chr_mode); + ser.Sync(nameof(prg_mode), ref prg_mode); + ser.Sync(nameof(irq_countdown), ref irq_countdown); + ser.Sync(nameof(a12_old), ref a12_old); + ser.Sync(nameof(irq_reload), ref irq_reload); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(irq_enable), ref irq_enable); + ser.Sync(nameof(irq_mode), ref irq_mode); + ser.Sync(nameof(irq_reload_pending), ref irq_reload_pending); + ser.Sync(nameof(separator_counter), ref separator_counter); Sync(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN_800008.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN_800008.cs index 520a53b182..0c9023ec8d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN_800008.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN_800008.cs @@ -54,8 +54,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("chr", ref chr); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(chr), ref chr); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs index c770bef585..e032d56748 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs @@ -34,8 +34,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); ser.BeginSection("mmc3variant"); - ser.Sync("pending", ref pending); - ser.Sync("delay", ref delay); + ser.Sync(nameof(pending), ref pending); + ser.Sync(nameof(delay), ref delay); ser.EndSection(); } @@ -84,9 +84,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); if(mmc3 != null) mmc3.SyncState(ser); - ser.Sync("prg_regs_8k", ref prg_regs_8k); - ser.Sync("chr_regs_1k", ref chr_regs_1k); - ser.Sync("mirror_mode", ref mirror_mode); + ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); + ser.Sync(nameof(chr_regs_1k), ref chr_regs_1k); + ser.Sync(nameof(mirror_mode), ref mirror_mode); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_005.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_005.cs index 0bdaefdd98..9ee071a0e3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_005.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_005.cs @@ -52,9 +52,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr_regs_1k", ref chr_regs_1k); - ser.Sync("prg_regs_8k", ref prg_regs_8k); - ser.Sync("wramenable", ref wramenable); + ser.Sync(nameof(chr_regs_1k), ref chr_regs_1k); + ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); + ser.Sync(nameof(wramenable), ref wramenable); } public override void Dispose() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_017.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_017.cs index 0aacb6be96..74ea6c91bf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_017.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_017.cs @@ -76,9 +76,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_regs_8k", ref prg_regs_8k); - ser.Sync("chr_regs_1k", ref chr_regs_1k); - ser.Sync("ChrMode", ref ChrMode); + ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); + ser.Sync(nameof(chr_regs_1k), ref chr_regs_1k); + ser.Sync(nameof(ChrMode), ref ChrMode); for (int i = 0; i < wramenable.Length; i++) ser.Sync("wramenable_" + i, ref wramenable[i]); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF-DREAMTECH01.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF-DREAMTECH01.cs index bf642a252c..724d140003 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF-DREAMTECH01.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF-DREAMTECH01.cs @@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); + ser.Sync(nameof(reg), ref reg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs index 80e90a5d59..b268323987 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs @@ -23,8 +23,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("regs", ref regs); - ser.Sync("ctrl", ref ctrl); + ser.Sync(nameof(regs), ref regs); + ser.Sync(nameof(ctrl), ref ctrl); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs index 9386a87c91..b7f29f10bd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs @@ -89,7 +89,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("regs", ref regs); + ser.Sync(nameof(regs), ref regs); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-810544-C-A1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-810544-C-A1.cs index 4fb8e19e80..3826ec224c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-810544-C-A1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-810544-C-A1.cs @@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("latche", ref latche); + ser.Sync(nameof(latche), ref latche); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-BS-5.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-BS-5.cs index 88c8db1ecc..104a233727 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-BS-5.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-BS-5.cs @@ -53,9 +53,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("reg_prg", ref reg_prg); - ser.Sync("reg_chr", ref reg_chr); - ser.Sync("BMC_BS_5_DipSwitch", ref BMC_BS_5_DipSwitch); + ser.Sync(nameof(reg_prg), ref reg_prg); + ser.Sync(nameof(reg_chr), ref reg_chr); + ser.Sync(nameof(BMC_BS_5_DipSwitch), ref BMC_BS_5_DipSwitch); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs index b3543e83a9..97462732bf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs @@ -37,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); ser.Sync("reg", ref _reg); - ser.Sync("D1038_Dipswitch", ref D1038_Dipswitch); + ser.Sync(nameof(D1038_Dipswitch), ref D1038_Dipswitch); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2013.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2013.cs index e39ad1cbab..d91261b218 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2013.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2013.cs @@ -43,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); ser.Sync("reg", ref _reg); - ser.Sync("_isRom2", ref _isRom2); + ser.Sync(nameof(_isRom2), ref _isRom2); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs index afef3e003d..cb8a3c6c0e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs @@ -39,10 +39,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); - ser.Sync("bank", ref bank); - ser.Sync("bank", ref Ghostbusters63in1_63set); - ser.Sync("bank", ref Ghostbusters63in1_chip_22_select); + ser.Sync(nameof(reg), ref reg); + ser.Sync(nameof(bank), ref bank); + ser.Sync(nameof(bank), ref Ghostbusters63in1_63set); + ser.Sync(nameof(bank), ref Ghostbusters63in1_chip_22_select); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-NTD-03.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-NTD-03.cs index abc100e521..0463013e8b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-NTD-03.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-NTD-03.cs @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("latche", ref latche); + ser.Sync(nameof(latche), ref latche); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs index 61ec883370..338676941e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs @@ -83,12 +83,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("exRegs", ref exRegs); - ser.Sync("prg_regs_8k", ref prg_regs_8k); - ser.Sync("prg_mask", ref prg_mask_8k); - ser.Sync("chr_mask", ref chr_mask_1k); - ser.Sync("dip_switch", ref dip_switch); - ser.Sync("dip_switch_setting", ref dip_switch_setting); + ser.Sync(nameof(exRegs), ref exRegs); + ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); + ser.Sync(nameof(prg_mask), ref prg_mask_8k); + ser.Sync(nameof(chr_mask), ref chr_mask_1k); + ser.Sync(nameof(dip_switch), ref dip_switch); + ser.Sync(nameof(dip_switch_setting), ref dip_switch_setting); } void UpdateChr() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs index 8bd3ad0fdd..83e14080d2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs @@ -35,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("exRegs", ref exRegs); + ser.Sync(nameof(exRegs), ref exRegs); } public override void WriteEXP(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-43272.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-43272.cs index a12401eb11..424ea572ac 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-43272.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-43272.cs @@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("latche", ref latche); + ser.Sync(nameof(latche), ref latche); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AC08.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AC08.cs index 8d391e2a5d..6c5136a720 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AC08.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AC08.cs @@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); + ser.Sync(nameof(reg), ref reg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AX5705.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AX5705.cs index 2067bf8724..000b579a96 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AX5705.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AX5705.cs @@ -33,8 +33,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_reg", ref prg_reg); - ser.Sync("chr_reg", ref chr_reg); + ser.Sync(nameof(prg_reg), ref prg_reg); + ser.Sync(nameof(chr_reg), ref chr_reg); } public override void WritePRG(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-BB.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-BB.cs index a0573add6f..e058dc781d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-BB.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-BB.cs @@ -26,8 +26,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); - ser.Sync("chr", ref chr); + ser.Sync(nameof(reg), ref reg); + ser.Sync(nameof(chr), ref chr); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7012.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7012.cs index 83278d6cab..7b45f1b690 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7012.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7012.cs @@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); + ser.Sync(nameof(reg), ref reg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7013B.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7013B.cs index 43550ef399..22cff63251 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7013B.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7013B.cs @@ -25,7 +25,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); + ser.Sync(nameof(reg), ref reg); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs index ff6e12e7d4..17fa4b4518 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs @@ -36,8 +36,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { - ser.Sync("reg", ref reg); - ser.Sync("cmd", ref cmd); + ser.Sync(nameof(reg), ref reg); + ser.Sync(nameof(cmd), ref cmd); base.SyncState(ser); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs index aa25648f75..b913b40f78 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs @@ -27,8 +27,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("reg", ref reg); - ser.Sync("RegionAsia", ref RegionAsia); + ser.Sync(nameof(reg), ref reg); + ser.Sync(nameof(RegionAsia), ref RegionAsia); } public override void WriteEXP(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs index 04df29aadc..12765f33e5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs @@ -40,13 +40,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg0", ref prg0); - ser.Sync("prg1", ref prg1); - ser.Sync("swap", ref swap); - ser.Sync("chr", ref chr); - ser.Sync("IRQa", ref IRQa); - ser.Sync("IRQCount", ref IRQCount); - ser.Sync("IRQpre", ref IRQpre); + ser.Sync(nameof(prg0), ref prg0); + ser.Sync(nameof(prg1), ref prg1); + ser.Sync(nameof(swap), ref swap); + ser.Sync(nameof(chr), ref chr); + ser.Sync(nameof(IRQa), ref IRQa); + ser.Sync(nameof(IRQCount), ref IRQCount); + ser.Sync(nameof(IRQpre), ref IRQpre); } public override void WritePRG(int addr, byte value) @@ -80,7 +80,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES case 0xF003: IRQa = value.Bit(1); IRQSignal = false; - if (NES.ppu.ppuphase !=PPU.PPUPHASE.VBL) + if (NES.ppu.ppuphase !=PPU.PPU_PHASE_VBL) IRQCount -= 8; break; } @@ -88,7 +88,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void ClockPPU() { - if ((NES.ppu.ppuphase != PPU.PPUPHASE.VBL))// && IRQa) + if ((NES.ppu.ppuphase != PPU.PPU_PHASE_VBL))// && IRQa) { IRQpre--; if (IRQpre==0) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs index 10aae8f739..951e7305fd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs @@ -56,25 +56,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); - ser.Sync("DripGameDipSwitch", ref DripGameDipSwitch); + ser.Sync(nameof(DripGameDipSwitch), ref DripGameDipSwitch); - ser.Sync("warmupclock", ref warmupclock); - ser.Sync("prg", ref prg, false); - ser.Sync("chr", ref chr, false); + ser.Sync(nameof(warmupclock), ref warmupclock); + ser.Sync(nameof(prg), ref prg, false); + ser.Sync(nameof(chr), ref chr, false); - ser.Sync("exram", ref exram, false); - ser.Sync("nt", ref nt, false); - ser.Sync("exattr", ref exattr); - ser.Sync("sramwrite", ref sramwrite); - ser.Sync("irqbuffer", ref irqbuffer); - ser.Sync("irqvalue", ref irqvalue); + ser.Sync(nameof(exram), ref exram, false); + ser.Sync(nameof(nt), ref nt, false); + ser.Sync(nameof(exattr), ref exattr); + ser.Sync(nameof(sramwrite), ref sramwrite); + ser.Sync(nameof(irqbuffer), ref irqbuffer); + ser.Sync(nameof(irqvalue), ref irqvalue); - ser.Sync("lastntread", ref lastntread); // technically not needed if states are always at frame boundary + ser.Sync(nameof(lastntread), ref lastntread); // technically not needed if states are always at frame boundary - ser.BeginSection("sound0"); + ser.BeginSection(nameof(sound0)); sound0.SyncState(ser); ser.EndSection(); - ser.BeginSection("sound1"); + ser.BeginSection(nameof(sound1)); sound1.SyncState(ser); ser.EndSection(); } @@ -270,18 +270,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("fifo", ref fifo, false); - ser.Sync("active", ref active); - ser.Sync("writecursor", ref writecursor); - ser.Sync("readcursor", ref readcursor); + ser.Sync(nameof(fifo), ref fifo, false); + ser.Sync(nameof(active), ref active); + ser.Sync(nameof(writecursor), ref writecursor); + ser.Sync(nameof(readcursor), ref readcursor); - ser.Sync("timer", ref timer); - ser.Sync("period", ref period); - ser.Sync("volume", ref volume); - ser.Sync("sample", ref sample); - ser.Sync("latched", ref latched); // not needed + ser.Sync(nameof(timer), ref timer); + ser.Sync(nameof(period), ref period); + ser.Sync(nameof(volume), ref volume); + ser.Sync(nameof(sample), ref sample); + ser.Sync(nameof(latched), ref latched); // not needed - ser.Sync("volumeChangePending", ref volumeChangePending); // very not needed + ser.Sync(nameof(volumeChangePending), ref volumeChangePending); // very not needed } // sound data fifo diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs index 41123272c6..2a74e04162 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs @@ -83,10 +83,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); - ser.Sync("irqenable", ref irqenable); - ser.Sync("irqcnt", ref irqcnt); - ser.Sync("swap", ref swap); + ser.Sync(nameof(prg), ref prg); + ser.Sync(nameof(irqenable), ref irqenable); + ser.Sync(nameof(irqcnt), ref irqcnt); + ser.Sync(nameof(swap), ref swap); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs index 5b708c256c..73695b5f46 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs @@ -161,7 +161,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); + ser.Sync(nameof(prg), ref prg); if (NES.IsVS) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs index 8808c0aa42..9ffbafd49d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs @@ -30,8 +30,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_8k", ref prg_banks_8k); - ser.Sync("chr_banks_4k", ref chr_banks_4k); + ser.Sync(nameof(prg_banks_8k), ref prg_banks_8k); + ser.Sync(nameof(chr_banks_4k), ref chr_banks_4k); if (NES.IsVS) { ser.Sync("VS_CIRAM", ref CIRAM_VS, false); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs index 51e4bc3af9..caf0c2e99b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs @@ -97,21 +97,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES base.SyncState(ser); for (int i = 0; i < 2; i++) ser.Sync("prg_bank_reg_8k_" + i, ref prg_bank_reg_8k[i]); for (int i = 0; i < 16; i++) ser.Sync("chr_bank_reg_1k_" + i, ref chr_bank_reg_1k[i]); - ser.Sync("irq_mode", ref irq_mode); - ser.Sync("irq_enabled", ref irq_enabled); - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("irq_autoen", ref irq_autoen); - ser.Sync("irq_reload", ref irq_reload); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_prescaler", ref irq_prescaler); - ser.Sync("extra_vrom", ref extra_vrom); + ser.Sync(nameof(irq_mode), ref irq_mode); + ser.Sync(nameof(irq_enabled), ref irq_enabled); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(irq_autoen), ref irq_autoen); + ser.Sync(nameof(irq_reload), ref irq_reload); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_prescaler), ref irq_prescaler); + ser.Sync(nameof(extra_vrom), ref extra_vrom); if (latch6k_exists) - ser.Sync("latch6k_value", ref latch6k_value); + ser.Sync(nameof(latch6k_value), ref latch6k_value); //SyncPRG(); ser.Sync("prg_banks", ref prg_banks_8k, false); SyncCHR(); SyncIRQ(); - ser.Sync("isPirate", ref isPirate); + ser.Sync(nameof(isPirate), ref isPirate); ser.Sync("isBMC", ref _isBMC); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC3.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC3.cs index 10f74262a9..c93c27bef2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC3.cs @@ -27,14 +27,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg_banks_16k", ref prg_banks_16k); - ser.Sync("irq_mode", ref irq_mode); - ser.Sync("irq_enabled", ref irq_enabled); - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("irq_autoen", ref irq_autoen); - ser.Sync("irq_reload", ref irq_reload); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_cycles", ref irq_cycles); + ser.Sync(nameof(prg_banks_16k), ref prg_banks_16k); + ser.Sync(nameof(irq_mode), ref irq_mode); + ser.Sync(nameof(irq_enabled), ref irq_enabled); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(irq_autoen), ref irq_autoen); + ser.Sync(nameof(irq_reload), ref irq_reload); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_cycles), ref irq_cycles); SyncIRQ(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC6.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC6.cs index ee5479a2bb..03de6c809b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC6.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC6.cs @@ -138,20 +138,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); VRC6Sound.SyncState(ser); - ser.Sync("prg_bank_16k", ref prg_bank_16k); - ser.Sync("prg_bank_8k", ref prg_bank_8k); - ser.Sync("chr_banks_1k", ref chr_banks_1k); - ser.Sync("irq_mode", ref irq_mode); - ser.Sync("irq_enabled", ref irq_enabled); - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("irq_autoen", ref irq_autoen); - ser.Sync("irq_reload", ref irq_reload); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_prescaler", ref irq_prescaler); + ser.Sync(nameof(prg_bank_16k), ref prg_bank_16k); + ser.Sync(nameof(prg_bank_8k), ref prg_bank_8k); + ser.Sync(nameof(chr_banks_1k), ref chr_banks_1k); + ser.Sync(nameof(irq_mode), ref irq_mode); + ser.Sync(nameof(irq_enabled), ref irq_enabled); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(irq_autoen), ref irq_autoen); + ser.Sync(nameof(irq_reload), ref irq_reload); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_prescaler), ref irq_prescaler); - ser.Sync("chrA10replace", ref chrA10replace); - ser.Sync("NTROM", ref NTROM); - ser.Sync("PPUBankingMode", ref PPUBankingMode); + ser.Sync(nameof(chrA10replace), ref chrA10replace); + ser.Sync(nameof(NTROM), ref NTROM); + ser.Sync(nameof(PPUBankingMode), ref PPUBankingMode); SyncPRG(); SyncIRQ(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs index 3804ca06d1..640ac83dfb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs @@ -38,15 +38,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES base.SyncState(ser); if (fm != null) fm.SyncState(ser); - ser.Sync("prg_banks_8k", ref prg_banks_8k); - ser.Sync("chr_banks_1k", ref chr_banks_1k); - ser.Sync("irq_mode", ref irq_mode); - ser.Sync("irq_enabled", ref irq_enabled); - ser.Sync("irq_pending", ref irq_pending); - ser.Sync("irq_autoen", ref irq_autoen); - ser.Sync("irq_reload", ref irq_reload); - ser.Sync("irq_counter", ref irq_counter); - ser.Sync("irq_prescaler", ref irq_prescaler); + ser.Sync(nameof(prg_banks_8k), ref prg_banks_8k); + ser.Sync(nameof(chr_banks_1k), ref chr_banks_1k); + ser.Sync(nameof(irq_mode), ref irq_mode); + ser.Sync(nameof(irq_enabled), ref irq_enabled); + ser.Sync(nameof(irq_pending), ref irq_pending); + ser.Sync(nameof(irq_autoen), ref irq_autoen); + ser.Sync(nameof(irq_reload), ref irq_reload); + ser.Sync(nameof(irq_counter), ref irq_counter); + ser.Sync(nameof(irq_prescaler), ref irq_prescaler); SyncIRQ(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs index 0f96dd3f1f..cf083f4ffa 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs @@ -104,7 +104,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("chr", ref chr); + ser.Sync(nameof(chr), ref chr); ser.Sync("VS_CIRAM", ref CIRAM_VS, false); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs index 6a34c25e5c..a6537bd966 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs @@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg, true); + ser.Sync(nameof(prg), ref prg, true); } public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs index c32715179c..960a93dbc1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs @@ -53,31 +53,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.BeginSection("FDS"); - ser.BeginSection("RamAdapter"); + ser.BeginSection(nameof(FDS)); + ser.BeginSection(nameof(RamAdapter)); diskdrive.SyncState(ser); ser.EndSection(); - ser.BeginSection("audio"); + ser.BeginSection(nameof(audio)); audio.SyncState(ser); ser.EndSection(); { // silly little hack int tmp = currentside != null ? (int)currentside : 1234567; - ser.Sync("currentside", ref tmp); + ser.Sync(nameof(currentside), ref tmp); currentside = tmp == 1234567 ? null : (int?)tmp; } for (int i = 0; i < NumSides; i++) ser.Sync("diskdiffs" + i, ref diskdiffs[i], true); - ser.Sync("_timerirq", ref _timerirq); - ser.Sync("timer_irq_active", ref timer_irq_active); - ser.Sync("timerirq_cd", ref timerirq_cd); - ser.Sync("_diskirq", ref _diskirq); - ser.Sync("diskenable", ref diskenable); - ser.Sync("soundenable", ref soundenable); - ser.Sync("reg4026", ref reg4026); - ser.Sync("timerlatch", ref timerlatch); - ser.Sync("timervalue", ref timervalue); - ser.Sync("timerreg", ref timerreg); + ser.Sync(nameof(_timerirq), ref _timerirq); + ser.Sync(nameof(timer_irq_active), ref timer_irq_active); + ser.Sync(nameof(timerirq_cd), ref timerirq_cd); + ser.Sync(nameof(_diskirq), ref _diskirq); + ser.Sync(nameof(diskenable), ref diskenable); + ser.Sync(nameof(soundenable), ref soundenable); + ser.Sync(nameof(reg4026), ref reg4026); + ser.Sync(nameof(timerlatch), ref timerlatch); + ser.Sync(nameof(timervalue), ref timervalue); + ser.Sync(nameof(timerreg), ref timerreg); ser.EndSection(); SetIRQ(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDSAudio.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDSAudio.cs index 4041027bba..84439ea181 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDSAudio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDSAudio.cs @@ -8,48 +8,48 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { public void SyncState(Serializer ser) { - ser.Sync("waveram", ref waveram, false); - ser.Sync("waverampos", ref waverampos); + ser.Sync(nameof(waveram), ref waveram, false); + ser.Sync(nameof(waverampos), ref waverampos); - ser.Sync("volumespd", ref volumespd); - ser.Sync("r4080_6", ref r4080_6); - ser.Sync("r4080_7", ref r4080_7); + ser.Sync(nameof(volumespd), ref volumespd); + ser.Sync(nameof(r4080_6), ref r4080_6); + ser.Sync(nameof(r4080_7), ref r4080_7); - ser.Sync("frequency", ref frequency); - ser.Sync("r4083_6", ref r4083_6); - ser.Sync("r4083_7", ref r4083_7); + ser.Sync(nameof(frequency), ref frequency); + ser.Sync(nameof(r4083_6), ref r4083_6); + ser.Sync(nameof(r4083_7), ref r4083_7); - ser.Sync("sweepspd", ref sweepspd); - ser.Sync("r4084_6", ref r4084_6); - ser.Sync("r4084_7", ref r4084_7); + ser.Sync(nameof(sweepspd), ref sweepspd); + ser.Sync(nameof(r4084_6), ref r4084_6); + ser.Sync(nameof(r4084_7), ref r4084_7); - ser.Sync("sweepbias", ref sweepbias); + ser.Sync(nameof(sweepbias), ref sweepbias); - ser.Sync("modfreq", ref modfreq); - ser.Sync("r4087_7", ref r4087_7); + ser.Sync(nameof(modfreq), ref modfreq); + ser.Sync(nameof(r4087_7), ref r4087_7); - ser.Sync("modtable", ref modtable, false); - ser.Sync("modtablepos", ref modtablepos); + ser.Sync(nameof(modtable), ref modtable, false); + ser.Sync(nameof(modtablepos), ref modtablepos); - ser.Sync("mastervol_num", ref mastervol_num); - ser.Sync("mastervol_den", ref mastervol_den); - ser.Sync("waveram_writeenable", ref waveram_writeenable); + ser.Sync(nameof(mastervol_num), ref mastervol_num); + ser.Sync(nameof(mastervol_den), ref mastervol_den); + ser.Sync(nameof(waveram_writeenable), ref waveram_writeenable); - ser.Sync("envspeed", ref envspeed); + ser.Sync(nameof(envspeed), ref envspeed); - ser.Sync("volumeclock", ref volumeclock); - ser.Sync("sweepclock", ref sweepclock); - ser.Sync("modclock", ref modclock); - ser.Sync("mainclock", ref mainclock); + ser.Sync(nameof(volumeclock), ref volumeclock); + ser.Sync(nameof(sweepclock), ref sweepclock); + ser.Sync(nameof(modclock), ref modclock); + ser.Sync(nameof(mainclock), ref mainclock); - ser.Sync("modoutput", ref modoutput); + ser.Sync(nameof(modoutput), ref modoutput); - ser.Sync("volumegain", ref volumegain); - ser.Sync("sweepgain", ref sweepgain); + ser.Sync(nameof(volumegain), ref volumegain); + ser.Sync(nameof(sweepgain), ref sweepgain); - ser.Sync("waveramoutput", ref waveramoutput); + ser.Sync(nameof(waveramoutput), ref waveramoutput); - ser.Sync("latchedoutput", ref latchedoutput); + ser.Sync(nameof(latchedoutput), ref latchedoutput); } //4040:407f diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs index 540e471764..77b613a588 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs @@ -130,34 +130,34 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("originaldisk", ref originaldisk, true); - ser.Sync("disk", ref disk, true); - ser.Sync("diskpos", ref diskpos); - ser.Sync("disksize", ref disksize); - ser.Sync("writeprotect", ref writeprotect); + ser.Sync(nameof(originaldisk), ref originaldisk, true); + ser.Sync(nameof(disk), ref disk, true); + ser.Sync(nameof(diskpos), ref diskpos); + ser.Sync(nameof(disksize), ref disksize); + ser.Sync(nameof(writeprotect), ref writeprotect); - ser.Sync("cycleswaiting", ref cycleswaiting); + ser.Sync(nameof(cycleswaiting), ref cycleswaiting); { int tmp = (int)state; - ser.Sync("state", ref tmp); + ser.Sync(nameof(state), ref tmp); state = (RamAdapterState)tmp; } - ser.Sync("cached4025", ref cached4025); - ser.Sync("irq", ref irq); - ser.Sync("transferreset", ref transferreset); + ser.Sync(nameof(cached4025), ref cached4025); + ser.Sync(nameof(irq), ref irq); + ser.Sync(nameof(transferreset), ref transferreset); - ser.Sync("crc", ref crc); - ser.Sync("writecomputecrc", ref writecomputecrc); + ser.Sync(nameof(crc), ref crc); + ser.Sync(nameof(writecomputecrc), ref writecomputecrc); - ser.Sync("readreg", ref readreg); - ser.Sync("writereg", ref writereg); - ser.Sync("readregpos", ref readregpos); - ser.Sync("writeregpos", ref writeregpos); - ser.Sync("readreglatch", ref readreglatch); - ser.Sync("writereglatch", ref writereglatch); + ser.Sync(nameof(readreg), ref readreg); + ser.Sync(nameof(writereg), ref writereg); + ser.Sync(nameof(readregpos), ref readregpos); + ser.Sync(nameof(writeregpos), ref writeregpos); + ser.Sync(nameof(readreglatch), ref readreglatch); + ser.Sync(nameof(writereglatch), ref writereglatch); - ser.Sync("bytetransferflag", ref bytetransferflag); - ser.Sync("lookingforendofgap", ref lookingforendofgap); + ser.Sync(nameof(bytetransferflag), ref bytetransferflag); + ser.Sync(nameof(lookingforendofgap), ref lookingforendofgap); } #region state diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs index d4486394b3..ba665367f7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs @@ -97,10 +97,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public virtual void SyncState(Serializer ser) { - ser.Sync("vram", ref vram, true); - ser.Sync("wram", ref wram, true); + ser.Sync(nameof(vram), ref vram, true); + ser.Sync(nameof(wram), ref wram, true); for (int i = 0; i < 4; i++) ser.Sync("mirroring" + i, ref mirroring[i]); - ser.Sync("irq_signal", ref irq_signal); + ser.Sync(nameof(irq_signal), ref irq_signal); SyncStateFlag = true; } @@ -490,7 +490,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { #if DEBUG if (ret != null) - throw new Exception(string.Format("Boards {0} and {1} both responded to Configure!", ret, type)); + throw new Exception($"Boards {ret} and {type} both responded to {nameof(NESBoardBase.Configure)}!"); else ret = type; #else diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs index feb338ad42..676279ec21 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs @@ -1,3 +1,5 @@ +// NOTE: to match Mesen timings, set idleSynch to true at power on, and set start_up_offset to -3 + using System; using System.Linq; @@ -9,7 +11,7 @@ using BizHawk.Emulation.Cores.Components.M6502; namespace BizHawk.Emulation.Cores.Nintendo.NES { - public partial class NES : IEmulator, ICycleTiming + public partial class NES : IEmulator, ISoundProvider, ICycleTiming { //hardware/state public MOS6502X cpu; @@ -29,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public int cpuclockrate { get; private set; } //user configuration - int[] palette_compiled = new int[64 * 8]; + public int[] palette_compiled = new int[64 * 8]; //variable set when VS system games are running internal bool _isVS = false; @@ -70,92 +72,65 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return Board; } + #region Audio + + BlipBuffer blip = new BlipBuffer(4096); + const int blipbuffsize = 4096; + + public int old_s = 0; + + public bool CanProvideAsync { get { return false; } } + + public void SetSyncMode(SyncSoundMode mode) + { + if (mode != SyncSoundMode.Sync) + { + throw new NotSupportedException("Only sync mode is supported"); + } + } + + public void GetSamplesAsync(short[] samples) + { + throw new NotSupportedException("Async not supported"); + } + + public SyncSoundMode SyncMode + { + get { return SyncSoundMode.Sync; } + } + public void Dispose() { - if (magicSoundProvider != null) - magicSoundProvider.Dispose(); - magicSoundProvider = null; + if (blip != null) + { + blip.Dispose(); + blip = null; + } } - class MagicSoundProvider : ISoundProvider, IDisposable + public void GetSamplesSync(out short[] samples, out int nsamp) { - BlipBuffer blip; - NES nes; + blip.EndFrame(apu.sampleclock); + apu.sampleclock = 0; - const int blipbuffsize = 4096; + nsamp = blip.SamplesAvailable(); + samples = new short[nsamp * 2]; - public MagicSoundProvider(NES nes, uint infreq) - { - this.nes = nes; + blip.ReadSamples(samples, nsamp, true); + // duplicate to stereo + for (int i = 0; i < nsamp * 2; i += 2) + samples[i + 1] = samples[i]; - blip = new BlipBuffer(blipbuffsize); - blip.SetRates(infreq, 44100); - - //var actualMetaspu = new Sound.MetaspuSoundProvider(Sound.ESynchMethod.ESynchMethod_V); - //1.789773mhz NTSC - //resampler = new Sound.Utilities.SpeexResampler(2, infreq, 44100 * APU.DECIMATIONFACTOR, infreq, 44100, actualMetaspu.buffer.enqueue_samples); - //output = new Sound.Utilities.DCFilter(actualMetaspu); - } - - public bool CanProvideAsync - { - get { return false; } - } - - public SyncSoundMode SyncMode - { - get { return SyncSoundMode.Sync; } - } - - public void SetSyncMode(SyncSoundMode mode) - { - if (mode != SyncSoundMode.Sync) - { - throw new NotSupportedException("Only sync mode is supported"); - } - } - - public void GetSamplesAsync(short[] samples) - { - throw new NotSupportedException("Async not supported"); - } - - public void GetSamplesSync(out short[] samples, out int nsamp) - { - //Console.WriteLine("ASync: {0}", nes.apu.dlist.Count); - foreach (var d in nes.apu.dlist) - blip.AddDelta(d.time, d.value); - nes.apu.dlist.Clear(); - blip.EndFrame(nes.apu.sampleclock); - nes.apu.sampleclock = 0; - - nsamp = blip.SamplesAvailable(); - samples = new short[nsamp * 2]; - - blip.ReadSamples(samples, nsamp, true); - // duplicate to stereo - for (int i = 0; i < nsamp * 2; i += 2) - samples[i + 1] = samples[i]; - - nes.Board.ApplyCustomAudio(samples); - } - - public void DiscardSamples() - { - nes.apu.dlist.Clear(); - nes.apu.sampleclock = 0; - } - - public void Dispose() - { - if (blip != null) - { - blip.Dispose(); - blip = null; - } - } + Board.ApplyCustomAudio(samples); } - MagicSoundProvider magicSoundProvider; + + public void DiscardSamples() + { + blip.Clear(); + apu.sampleclock = 0; + } + + #endregion public void HardReset() { @@ -195,6 +170,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } + // Add in the reset timing float control for subneshawk + if (using_reset_timing && (ControllerDefinition.FloatControls.Count() == 0)) + { + ControllerDefinition.FloatControls.Add("Reset Cycle"); + ControllerDefinition.FloatRanges.Add(new ControllerDefinition.FloatRange(0, 0, 500000)); + } + // don't replace the magicSoundProvider on reset, as it's not needed // if (magicSoundProvider != null) magicSoundProvider.Dispose(); @@ -234,8 +216,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES default: throw new Exception("Unknown displaytype!"); } - if (magicSoundProvider == null) - magicSoundProvider = new MagicSoundProvider(this, (uint)cpuclockrate); + + blip.SetRates((uint)cpuclockrate, 44100); BoardSystemHardReset(); @@ -309,7 +291,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bool resetSignal; bool hardResetSignal; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { _controller = controller; @@ -375,12 +357,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else { - ppu.ppu_init_frame(); - - ppu.do_vbl = true; - ppu.do_active_sl = true; - ppu.do_pre_vbl = true; - // do the vbl ticks seperate, that will save us a few checks that don't happen in active region while (ppu.do_vbl) { @@ -413,6 +389,47 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // turn off all cheats // any cheats still active will be re-applied by the buspoke at the start of the next frame num_cheats = 0; + + return true; + } + + // these variables are for subframe input control + public bool controller_was_latched; + public bool frame_is_done; + public bool current_strobe; + public bool new_strobe; + public bool alt_lag; + // variable used with subneshawk to trigger reset at specific cycle after reset + public bool using_reset_timing = false; + // this function will run one step of the ppu + // it will return whether the controller is read or not. + public void do_single_step(IController controller, out bool cont_read, out bool frame_done) + { + _controller = controller; + + controller_was_latched = false; + frame_is_done = false; + + current_strobe = new_strobe; + if (ppu.ppudead > 0) + { + ppu.NewDeadPPU(); + } + else if (ppu.do_vbl) + { + ppu.TickPPU_VBL(); + } + else if (ppu.do_active_sl) + { + ppu.TickPPU_active(); + } + else if (ppu.do_pre_vbl) + { + ppu.TickPPU_preVBL(); + } + + cont_read = controller_was_latched; + frame_done = frame_is_done; } //PAL: @@ -519,7 +536,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ///////////////////////////// // dmc dma end ///////////////////////////// - apu.RunOne(true); + apu.RunOneFirst(); if (cpu.RDY && !IRQ_delay) { @@ -532,7 +549,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } cpu.ExecuteOne(); - apu.RunOne(false); + Board.ClockCPU(); + + int s = apu.EmitSample(); + + if (s != old_s) + { + blip.AddDelta(apu.sampleclock, s - old_s); + old_s = s; + } + apu.sampleclock++; + + apu.RunOneLast(); if (ppu.double_2007_read > 0) ppu.double_2007_read--; @@ -548,8 +576,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES cpu.RDY = true; IRQ_delay = true; } - - Board.ClockCPU(); } public byte ReadReg(int addr) @@ -734,6 +760,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES var si = new StrobeInfo(latched4016, value); ControllerDeck.Strobe(si, _controller); latched4016 = value; + new_strobe = (value & 1) > 0; + if (current_strobe && !new_strobe) + { + controller_was_latched = true; + alt_lag = false; + } } byte read_joyport(int addr) @@ -741,6 +773,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES InputCallbacks.Call(); lagged = false; byte ret = 0; + if (_isVS) { // for whatever reason, in VS left and right controller have swapped regs @@ -750,7 +783,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { ret = addr == 0x4016 ? ControllerDeck.ReadA(_controller) : ControllerDeck.ReadB(_controller); } - + ret &= 0x1f; ret |= (byte)(0xe0 & DB); return ret; @@ -808,7 +841,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public byte DummyReadMemory(ushort addr) { return 0; } - private void ApplySystemBusPoke(int addr, byte value) + public void ApplySystemBusPoke(int addr, byte value) { if (addr < 0x2000) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs index 0997f6e269..30d37f6e20 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { public partial class NES { - private MemoryDomainList _memoryDomains; + public MemoryDomainList _memoryDomains; private bool _memoryDomainsSetup = false; private void SetupMemoryDomains() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IStatable.cs index e2dd212602..67226bae60 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IStatable.cs @@ -49,17 +49,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private void SyncState(Serializer ser) { int version = 4; - ser.BeginSection("NES"); - ser.Sync("version", ref version); + ser.BeginSection(nameof(NES)); + ser.Sync(nameof(version), ref version); ser.Sync("Frame", ref _frame); ser.Sync("Lag", ref _lagcount); ser.Sync("IsLag", ref islag); cpu.SyncState(ser); - ser.Sync("ram", ref ram, false); - ser.Sync("CIRAM", ref CIRAM, false); - ser.Sync("_irq_apu", ref _irq_apu); - ser.Sync("sprdma_countdown", ref sprdma_countdown); - ser.Sync("cpu_deadcounter", ref cpu_deadcounter); + ser.Sync(nameof(ram), ref ram, false); + ser.Sync(nameof(CIRAM), ref CIRAM, false); + ser.Sync(nameof(_irq_apu), ref _irq_apu); + ser.Sync(nameof(sprdma_countdown), ref sprdma_countdown); + ser.Sync(nameof(cpu_deadcounter), ref cpu_deadcounter); + + ser.Sync(nameof(old_s), ref old_s); //oam related ser.Sync("Oam_Dma_Index", ref oam_dma_index); @@ -67,10 +69,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync("Oam_Dma_Addr", ref oam_dma_addr); ser.Sync("Oam_Dma_Byte", ref oam_dma_byte); ser.Sync("Dmc_Dma_Exec", ref dmc_dma_exec); - ser.Sync("dmc_realign", ref dmc_realign); - ser.Sync("IRQ_delay", ref IRQ_delay); - ser.Sync("special_case_delay", ref special_case_delay); - ser.Sync("do_the_reread", ref do_the_reread); + ser.Sync(nameof(dmc_realign), ref dmc_realign); + ser.Sync(nameof(IRQ_delay), ref IRQ_delay); + ser.Sync(nameof(special_case_delay), ref special_case_delay); + ser.Sync(nameof(do_the_reread), ref do_the_reread); //VS related ser.Sync("VS", ref _isVS); @@ -82,29 +84,33 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync("VS_Coin", ref VS_coin_inserted); ser.Sync("VS_ROM_Control", ref VS_ROM_control); - ser.BeginSection("Board"); + // single cycle execution related + ser.Sync(nameof(current_strobe), ref current_strobe); + ser.Sync(nameof(new_strobe), ref new_strobe); + + ser.BeginSection(nameof(Board)); Board.SyncState(ser); if (Board is NESBoardBase && !((NESBoardBase)Board).SyncStateFlag) - throw new InvalidOperationException("the current NES mapper didnt call base.SyncState"); + throw new InvalidOperationException($"the current NES mapper didn't call base.{nameof(INESBoard.SyncState)}"); ser.EndSection(); ppu.SyncState(ser); apu.SyncState(ser); if (version >= 2) { - ser.Sync("DB", ref DB); + ser.Sync(nameof(DB), ref DB); } if (version >= 3) { - ser.Sync("latched4016", ref latched4016); - ser.BeginSection("ControllerDeck"); + ser.Sync(nameof(latched4016), ref latched4016); + ser.BeginSection(nameof(ControllerDeck)); ControllerDeck.SyncState(ser); ser.EndSection(); } if (version >= 4) { - ser.Sync("resetSignal", ref resetSignal); - ser.Sync("hardResetSignal", ref hardResetSignal); + ser.Sync(nameof(resetSignal), ref resetSignal); + ser.Sync(nameof(hardResetSignal), ref hardResetSignal); } ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index 5da37f44c4..aa3eb566ba 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -62,7 +62,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES Tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register(Tracer); ser.Register(videoProvider); - ser.Register(magicSoundProvider); + ser.Register(this); if (Board is BANDAI_FCG_1) { @@ -126,7 +126,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public DisplayType Region { get { return _display_type; } } - class MyVideoProvider : IVideoProvider + public class MyVideoProvider : IVideoProvider { //public int ntsc_top = 8; //public int ntsc_bottom = 231; @@ -246,7 +246,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public int VsyncDenominator => emu.VsyncDen; } - MyVideoProvider videoProvider; + public MyVideoProvider videoProvider; [Obsolete] // with the changes to both nes and quicknes cores, nothing uses this anymore public static readonly ControllerDefinition NESController = diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs index 48adc81990..c612f335d4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs @@ -190,10 +190,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.BeginSection("Left"); + ser.BeginSection(nameof(Left)); Left.SyncState(ser); ser.EndSection(); - ser.BeginSection("Right"); + ser.BeginSection(nameof(Right)); Right.SyncState(ser); ser.EndSection(); } @@ -323,8 +323,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("restting", ref resetting); - ser.Sync("latchedvalue", ref latchedvalue); + ser.Sync(nameof(resetting), ref resetting); + ser.Sync(nameof(latchedvalue), ref latchedvalue); } } @@ -386,8 +386,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("restting", ref resetting); - ser.Sync("latchedvalue", ref latchedvalue); + ser.Sync(nameof(resetting), ref resetting); + ser.Sync(nameof(latchedvalue), ref latchedvalue); } } @@ -439,9 +439,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("shiftidx", ref shiftidx); - ser.Sync("restting", ref resetting); - ser.Sync("latchedvalue", ref latchedvalue); + ser.Sync(nameof(shiftidx), ref shiftidx); + ser.Sync(nameof(resetting), ref resetting); + ser.Sync(nameof(latchedvalue), ref latchedvalue); } } @@ -497,8 +497,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("restting", ref resetting); - ser.Sync("latchedvalue", ref latchedvalue); + ser.Sync(nameof(resetting), ref resetting); + ser.Sync(nameof(latchedvalue), ref latchedvalue); } } @@ -546,9 +546,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("restting", ref resetting); - ser.Sync("latched3", ref latched3); - ser.Sync("latched4", ref latched4); + ser.Sync(nameof(resetting), ref resetting); + ser.Sync(nameof(latched3), ref latched3); + ser.Sync(nameof(latched4), ref latched4); } } @@ -663,8 +663,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("restting", ref resetting); - ser.Sync("latchedvalue", ref latchedvalue); + ser.Sync(nameof(resetting), ref resetting); + ser.Sync(nameof(latchedvalue), ref latchedvalue); } // famicom expansion hookups @@ -805,9 +805,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("shiftidx", ref shiftidx); - ser.Sync("restting", ref resetting); - ser.Sync("latchedvalue", ref latchedvalue); + ser.Sync(nameof(shiftidx), ref shiftidx); + ser.Sync(nameof(resetting), ref resetting); + ser.Sync(nameof(latchedvalue), ref latchedvalue); } } @@ -951,9 +951,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("active", ref active); - ser.Sync("column", ref column); - ser.Sync("row", ref row); + ser.Sync(nameof(active), ref active); + ser.Sync(nameof(column), ref column); + ser.Sync(nameof(row), ref row); } } @@ -1013,9 +1013,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("resetting", ref resetting); - ser.Sync("latchedp1", ref latchedp1); - ser.Sync("latchedp2", ref latchedp2); + ser.Sync(nameof(resetting), ref resetting); + ser.Sync(nameof(latchedp1), ref latchedp1); + ser.Sync(nameof(latchedp2), ref latchedp2); } } @@ -1085,9 +1085,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("resetting", ref resetting); - ser.Sync("shiftidx", ref shiftidx); - ser.Sync("latchedvalue", ref latchedvalue); + ser.Sync(nameof(resetting), ref resetting); + ser.Sync(nameof(shiftidx), ref shiftidx); + ser.Sync(nameof(latchedvalue), ref latchedvalue); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs index 320113d52f..74c2b582d9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.CompilerServices; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES @@ -106,6 +105,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int sum = 0; int ymin = Math.Max(Math.Max(y - radius, ppur.status.sl - 20), 0); + if (ymin > 239) { ymin = 239; } int ymax = Math.Min(y + radius, 239); int xmin = Math.Max(x - radius, 0); int xmax = Math.Min(x + radius, 255); @@ -113,25 +113,42 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int ystop = ppur.status.sl - 2; int xstop = ppur.status.cycle - 20; - for (int j = ymin; j <= ymax; j++) + bool all_stop = false; + + int j = ymin; + int i = xmin; + short s = 0; + short palcolor = 0; + short intensity = 0; + + if (j >= ystop && i >= xstop || j > ystop) { all_stop = true; } + + while (!all_stop) { - for (int i = xmin; i <= xmax; i++) + s = xbuf[j * 256 + i]; + palcolor = (short)(s & 0x3F); + intensity = (short)((s >> 6) & 0x7); + + sum += _currentLuma[palcolor]; + + i++; + if (i > xmax) { - if (j >= ystop && i >= xstop || j > ystop) - goto loopout; + i = xmin; + j++; - short s = xbuf[j * 256 + i]; - - short palcolor = (short)(s & 0x3F); - short intensity = (short)((s >> 6) & 0x7); - sum += _currentLuma[palcolor]; + if (j > ymax) + { + all_stop = true; + } } + + if (j >= ystop && i >= xstop || j > ystop) { all_stop = true; } } - loopout: + return sum >= 2000; } - //when the ppu issues a write it goes through here and into the game board public void ppubus_write(int addr, byte value) { @@ -160,11 +177,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return nes.Board.PeekPPU(addr); } - public enum PPUPHASE - { - VBL, BG, OBJ - }; - public PPUPHASE ppuphase; + public static int PPU_PHASE_VBL = 0; + public static int PPU_PHASE_BG = 1; + public static int PPU_PHASE_OBJ = 2; + + public int ppuphase; private readonly NES nes; public PPU(NES nes) @@ -208,85 +225,87 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("cpu_step", ref cpu_step); - ser.Sync("cpu_stepcounter", ref cpu_stepcounter); - ser.Sync("ppudead", ref ppudead); - ser.Sync("idleSynch", ref idleSynch); - ser.Sync("NMI_PendingInstructions", ref NMI_PendingInstructions); - ser.Sync("PPUGenLatch", ref PPUGenLatch); - ser.Sync("vtoggle", ref vtoggle); - ser.Sync("VRAMBuffer", ref VRAMBuffer); - ser.Sync("ppu_addr_temp", ref ppu_addr_temp); + ser.Sync(nameof(cpu_step), ref cpu_step); + ser.Sync(nameof(cpu_stepcounter), ref cpu_stepcounter); + ser.Sync(nameof(ppudead), ref ppudead); + ser.Sync(nameof(idleSynch), ref idleSynch); + ser.Sync(nameof(NMI_PendingInstructions), ref NMI_PendingInstructions); + ser.Sync(nameof(PPUGenLatch), ref PPUGenLatch); + ser.Sync(nameof(vtoggle), ref vtoggle); + ser.Sync(nameof(VRAMBuffer), ref VRAMBuffer); + ser.Sync(nameof(ppu_addr_temp), ref ppu_addr_temp); - ser.Sync("spr_true_count", ref spr_true_count); - ser.Sync("sprite_eval_write", ref sprite_eval_write); - ser.Sync("Read_Value", ref read_value); + ser.Sync(nameof(spr_true_count), ref spr_true_count); + ser.Sync(nameof(sprite_eval_write), ref sprite_eval_write); + ser.Sync(nameof(read_value), ref read_value); ser.Sync("Prev_soam_index", ref soam_index_prev); ser.Sync("Spr_Zero_Go", ref sprite_zero_go); ser.Sync("Spr_zero_in_Range", ref sprite_zero_in_range); - ser.Sync("Is_even_cycle", ref is_even_cycle); - ser.Sync("soam_index", ref soam_index); - ser.Sync("soam_m_index", ref soam_m_index); - ser.Sync("oam_index", ref oam_index); - ser.Sync("oam_index_aux", ref oam_index_aux); - ser.Sync("soam_index_aux", ref soam_index_aux); - ser.Sync("yp", ref yp); - ser.Sync("target", ref target); - ser.Sync("ppu_was_on", ref ppu_was_on); - ser.Sync("spriteHeight", ref spriteHeight); - ser.Sync("install_2006", ref install_2006); - ser.Sync("race_2006", ref race_2006); - ser.Sync("install_2001", ref install_2001); - ser.Sync("show_bg_new", ref show_bg_new); - ser.Sync("show_obj_new", ref show_obj_new); + ser.Sync(nameof(is_even_cycle), ref is_even_cycle); + ser.Sync(nameof(soam_index), ref soam_index); + ser.Sync(nameof(soam_m_index), ref soam_m_index); + ser.Sync(nameof(oam_index), ref oam_index); + ser.Sync(nameof(oam_index_aux), ref oam_index_aux); + ser.Sync(nameof(soam_index_aux), ref soam_index_aux); + ser.Sync(nameof(yp), ref yp); + ser.Sync(nameof(target), ref target); + ser.Sync(nameof(ppu_was_on), ref ppu_was_on); + ser.Sync(nameof(spriteHeight), ref spriteHeight); + ser.Sync(nameof(install_2006), ref install_2006); + ser.Sync(nameof(race_2006), ref race_2006); + ser.Sync(nameof(race_2006_2), ref race_2006_2); + ser.Sync(nameof(install_2001), ref install_2001); + ser.Sync(nameof(show_bg_new), ref show_bg_new); + ser.Sync(nameof(show_obj_new), ref show_obj_new); - ser.Sync("ppu_open_bus", ref ppu_open_bus); - ser.Sync("double_2007_read", ref double_2007_read); - ser.Sync("ppu_open_bus_decay_timer", ref ppu_open_bus_decay_timer, false); - ser.Sync("glitchy_reads_2003", ref glitchy_reads_2003, false); + ser.Sync(nameof(ppu_open_bus), ref ppu_open_bus); + ser.Sync(nameof(double_2007_read), ref double_2007_read); + ser.Sync(nameof(ppu_open_bus_decay_timer), ref ppu_open_bus_decay_timer, false); + ser.Sync(nameof(glitchy_reads_2003), ref glitchy_reads_2003, false); - ser.Sync("OAM", ref OAM, false); - ser.Sync("soam", ref soam, false); - ser.Sync("PALRAM", ref PALRAM, false); + ser.Sync(nameof(OAM), ref OAM, false); + ser.Sync(nameof(soam), ref soam, false); + ser.Sync(nameof(PALRAM), ref PALRAM, false); + ser.Sync(nameof(ppuphase), ref ppuphase); - ser.Sync("Reg2002_objoverflow", ref Reg2002_objoverflow); - ser.Sync("Reg2002_objhit", ref Reg2002_objhit); - ser.Sync("Reg2002_vblank_active", ref Reg2002_vblank_active); - ser.Sync("Reg2002_vblank_active_pending", ref Reg2002_vblank_active_pending); - ser.Sync("Reg2002_vblank_clear_pending", ref Reg2002_vblank_clear_pending); + ser.Sync(nameof(Reg2002_objoverflow), ref Reg2002_objoverflow); + ser.Sync(nameof(Reg2002_objhit), ref Reg2002_objhit); + ser.Sync(nameof(Reg2002_vblank_active), ref Reg2002_vblank_active); + ser.Sync(nameof(Reg2002_vblank_active_pending), ref Reg2002_vblank_active_pending); + ser.Sync(nameof(Reg2002_vblank_clear_pending), ref Reg2002_vblank_clear_pending); ppur.SyncState(ser); - byte temp8 = reg_2000.Value; ser.Sync("reg_2000.Value", ref temp8); reg_2000.Value = temp8; - temp8 = reg_2001.Value; ser.Sync("reg_2001.Value", ref temp8); reg_2001.Value = temp8; - ser.Sync("reg_2003", ref reg_2003); + byte temp8 = reg_2000.Value; ser.Sync($"{nameof(reg_2000)}.{nameof(reg_2000.Value)}", ref temp8); reg_2000.Value = temp8; + temp8 = reg_2001.Value; ser.Sync($"{nameof(reg_2001)}.{nameof(reg_2001.Value)}", ref temp8); reg_2001.Value = temp8; + ser.Sync(nameof(reg_2003), ref reg_2003); //don't sync framebuffer into binary (rewind) states if(ser.IsText) - ser.Sync("xbuf", ref xbuf, false); + ser.Sync(nameof(xbuf), ref xbuf, false); - ser.Sync("_totalCycles", ref _totalCycles); + ser.Sync(nameof(_totalCycles), ref _totalCycles); - ser.Sync("do_vbl", ref do_vbl); - ser.Sync("do_active_sl", ref do_active_sl); - ser.Sync("do_pre_vbl", ref do_pre_vbl); + ser.Sync(nameof(do_vbl), ref do_vbl); + ser.Sync(nameof(do_active_sl), ref do_active_sl); + ser.Sync(nameof(do_pre_vbl), ref do_pre_vbl); - ser.Sync("nmi_destiny", ref nmi_destiny); - ser.Sync("yp_shift", ref yp_shift); - ser.Sync("sprite_eval_cycle", ref sprite_eval_cycle); - ser.Sync("xt", ref xt); - ser.Sync("xp", ref xp); - ser.Sync("xstart", ref xstart); - ser.Sync("rasterpos", ref rasterpos); - ser.Sync("renderspritenow", ref renderspritenow); - ser.Sync("renderbgnow", ref renderbgnow); - ser.Sync("hit_pending", ref hit_pending); - ser.Sync("s", ref s); - ser.Sync("ppu_aux_index", ref ppu_aux_index); - ser.Sync("junksprite", ref junksprite); - ser.Sync("line", ref line); - ser.Sync("patternNumber", ref patternNumber); - ser.Sync("patternAddress", ref patternAddress); - ser.Sync("temp_addr", ref temp_addr); - ser.Sync("sl_sprites", ref sl_sprites, false); + ser.Sync(nameof(nmi_destiny), ref nmi_destiny); + ser.Sync(nameof(evenOddDestiny), ref evenOddDestiny); + ser.Sync(nameof(NMI_offset), ref NMI_offset); + ser.Sync(nameof(yp_shift), ref yp_shift); + ser.Sync(nameof(sprite_eval_cycle), ref sprite_eval_cycle); + ser.Sync(nameof(xt), ref xt); + ser.Sync(nameof(xp), ref xp); + ser.Sync(nameof(xstart), ref xstart); + ser.Sync(nameof(rasterpos), ref rasterpos); + ser.Sync(nameof(renderspritenow), ref renderspritenow); + ser.Sync(nameof(s), ref s); + ser.Sync(nameof(ppu_aux_index), ref ppu_aux_index); + ser.Sync(nameof(junksprite), ref junksprite); + ser.Sync(nameof(line), ref line); + ser.Sync(nameof(patternNumber), ref patternNumber); + ser.Sync(nameof(patternAddress), ref patternAddress); + ser.Sync(nameof(temp_addr), ref temp_addr); + ser.Sync(nameof(sl_sprites), ref sl_sprites, false); byte bg_byte; for (int i = 0; i < 34; i++) @@ -307,7 +326,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES string str = "oamdata" + i.ToString() + "y"; oam_byte = t_oam[i].oam_y; ser.Sync(str, ref oam_byte); t_oam[i].oam_y = oam_byte; str = "oamdata" + i.ToString() + "ind"; - oam_byte = t_oam[i].oam_ind; ; ser.Sync(str, ref oam_byte); t_oam[i].oam_ind = oam_byte; + oam_byte = t_oam[i].oam_ind; ser.Sync(str, ref oam_byte); t_oam[i].oam_ind = oam_byte; str = "oamdata" + i.ToString() + "attr"; oam_byte = t_oam[i].oam_attr; ser.Sync(str, ref oam_byte); t_oam[i].oam_attr = oam_byte; str = "oamdata" + i.ToString() + "x"; @@ -330,15 +349,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES void runppu() { - //run one ppu cycle at a time so we can interact with the ppu and clockPPU at high granularity - - race_2006 = false; - if (install_2006>0) + //run one ppu cycle at a time so we can interact with the ppu and clockPPU at high granularity + if (install_2006 > 0) { install_2006--; if (install_2006==0) { - ppur.install_latches(); + if (!race_2006) { ppur.install_latches(); } + else { race_2006_2 = true; } //nes.LogLine("addr wrote vt = {0}, ht = {1}", ppur._vt, ppur._ht); //normally the address isnt observed by the board till it gets clocked by a read or write. @@ -347,11 +365,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //ONLY if the ppu is not rendering if (ppur.status.sl >= 241 || !PPUON) nes.Board.AddressPPU(ppur.get_2007access()); - - race_2006 = true; } } + race_2006 = false; + if (install_2001 > 0) { install_2001--; @@ -365,7 +383,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ppur.status.cycle++; is_even_cycle = !is_even_cycle; - if (PPUON && ppur.status.cycle >= 257 && ppur.status.cycle <= 320 && ppur.status.sl <= 240) + if (ppur.status.cycle >= 257 && ppur.status.cycle <= 320 && ppur.status.sl <= 240 && PPUON) { reg_2003 = 0; } @@ -396,18 +414,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - if (Reg2002_vblank_active_pending) - { - Reg2002_vblank_active = 1; - Reg2002_vblank_active_pending = false; - } - - if (Reg2002_vblank_clear_pending) - { - Reg2002_vblank_active = 0; - Reg2002_vblank_clear_pending = false; - } - if (HasClockPPU) { nes.Board.ClockPPU(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs index a0aed3f502..01d0aadf5a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs @@ -9,7 +9,6 @@ using System; using BizHawk.Common; - namespace BizHawk.Emulation.Cores.Nintendo.NES { sealed partial class PPU @@ -78,19 +77,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void SyncState(Serializer ser) { - ser.Sync("fv", ref fv); - ser.Sync("v", ref v); - ser.Sync("h", ref h); - ser.Sync("vt", ref vt); - ser.Sync("ht", ref ht); - ser.Sync("_fv", ref _fv); - ser.Sync("_v", ref _v); - ser.Sync("_h", ref _h); - ser.Sync("_vt", ref _vt); - ser.Sync("_ht", ref _ht); - ser.Sync("fh", ref fh); - ser.Sync("status.cycle", ref status.cycle); - ser.Sync("status.sl", ref status.sl); + ser.Sync(nameof(fv), ref fv); + ser.Sync(nameof(v), ref v); + ser.Sync(nameof(h), ref h); + ser.Sync(nameof(vt), ref vt); + ser.Sync(nameof(ht), ref ht); + ser.Sync(nameof(_fv), ref _fv); + ser.Sync(nameof(_v), ref _v); + ser.Sync(nameof(_h), ref _h); + ser.Sync(nameof(_vt), ref _vt); + ser.Sync(nameof(_ht), ref _ht); + ser.Sync(nameof(fh), ref fh); + ser.Sync($"{nameof(status)}.{nameof(status.cycle)}", ref status.cycle); + ser.Sync($"{nameof(status)}.{nameof(status.sl)}", ref status.sl); } //normal clocked regs. as the game can interfere with these at any time, they need to be savestated @@ -307,6 +306,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public Reg_2000 reg_2000; public Reg_2001 reg_2001; byte reg_2003; + public byte reg_2006_2; void regs_reset() { @@ -450,12 +450,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { OAM[reg_2003] = value; reg_2003++; - } - + } } + byte read_2004() { byte ret; + // Console.WriteLine("read 2004"); // behaviour depends on whether things are being rendered or not if (PPUON) { @@ -526,6 +527,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ppur._v = (value >> 3) & 1; ppur._fv = (value >> 4) & 3; //nes.LogLine("addr wrote fv = {0}", ppur._fv); + reg_2006_2 = value; } else { @@ -534,13 +536,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ppur._ht = value & 31; // testing indicates that this operation is delayed by 3 pixels - // ppur.install_latches(); - + //ppur.install_latches(); install_2006 = 3; } vtoggle ^= true; - } byte read_2006() { return ppu_open_bus; } byte peek_2006() { return ppu_open_bus; } @@ -551,7 +551,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //does this take 4x longer? nestopia indicates so perhaps... int addr = ppur.get_2007access(); - if (ppuphase == PPUPHASE.BG) + if (ppuphase == PPU_PHASE_BG) { if (show_bg_new) { @@ -835,4 +835,4 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //Palette Gaps and Mirrors // 3F04h,3F08h,3F0Ch - Three general purpose 6bit data registers. // 3F10h,3F14h,3F18h,3F1Ch - Mirrors of 3F00h,3F04h,3F08h,3F0Ch. -// 3F20h-3FFFh - Mirrors of 3F00h-3F1Fh. \ No newline at end of file +// 3F20h-3FFFh - Mirrors of 3F00h-3F1Fh. diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs index 63e65192ff..8bc43b817b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs @@ -1,8 +1,8 @@ //TODO - correctly emulate PPU OFF state +using System; using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { @@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // installing vram address is delayed after second write to 2006, set this up here public int install_2006; - public bool race_2006; + public bool race_2006, race_2006_2; public int install_2001; public bool show_bg_new; //Show background public bool show_obj_new; //Show sprites @@ -62,30 +62,29 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // attempt to emulate graphics pipeline behaviour // experimental int pixelcolor_latch_1; - int pixelcolor_latch_2; + void pipeline(int pixelcolor, int row_check) { - if (row_check > 1) + if (row_check > 0) { if (reg_2001.color_disable) - pixelcolor_latch_2 &= 0x30; + pixelcolor_latch_1 &= 0x30; //TODO - check flashing sirens in werewolf //tack on the deemph bits. THESE MAY BE ORDERED WRONG. PLEASE CHECK IN THE PALETTE CODE - xbuf[(target - 2)] = (short)(pixelcolor_latch_2 | reg_2001.intensity_lsl_6); + xbuf[(target - 1)] = (short)(pixelcolor_latch_1 | reg_2001.intensity_lsl_6); } - - pixelcolor_latch_2 = pixelcolor_latch_1; + pixelcolor_latch_1 = pixelcolor; } - void Read_bgdata(int cycle, ref BGDataRecord bgdata) + void Read_bgdata(int cycle, int i) { switch (cycle) { case 0: ppu_addr_temp = ppur.get_ntread(); - bgdata.nt = ppubus_read(ppu_addr_temp, true, true); + bgdata[i].nt = ppubus_read(ppu_addr_temp, true, true); break; case 1: break; @@ -99,20 +98,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if ((ppur.ht & 2) != 0) at >>= 2; at &= 0x03; at <<= 2; - bgdata.at = at; + bgdata[i].at = at; break; } case 3: break; case 4: - ppu_addr_temp = ppur.get_ptread(bgdata.nt); - bgdata.pt_0 = ppubus_read(ppu_addr_temp, true, true); + ppu_addr_temp = ppur.get_ptread(bgdata[i].nt); + bgdata[i].pt_0 = ppubus_read(ppu_addr_temp, true, true); break; case 5: break; case 6: ppu_addr_temp |= 8; - bgdata.pt_1 = ppubus_read(ppu_addr_temp, true, true); + bgdata[i].pt_1 = ppubus_read(ppu_addr_temp, true, true); break; case 7: break; @@ -125,6 +124,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public bool do_pre_vbl; bool nmi_destiny; + bool evenOddDestiny; + static int start_up_offset = 2; + int NMI_offset; int yp_shift; int sprite_eval_cycle; int xt; @@ -132,8 +134,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int xstart; int rasterpos; bool renderspritenow; - bool renderbgnow; - bool hit_pending; int s; int ppu_aux_index; bool junksprite; @@ -148,140 +148,153 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ppur.status.cycle = 0; // These things happen at the start of every frame - - Reg2002_vblank_active_pending = true; - ppuphase = PPUPHASE.VBL; + ppuphase = PPU_PHASE_VBL; bgdata = new BGDataRecord[34]; } public void TickPPU_VBL() { - if (ppur.status.cycle == 3 && ppur.status.sl == 241 + preNMIlines) + if (ppur.status.cycle == 0 && ppur.status.sl == 241 + preNMIlines) { nmi_destiny = reg_2000.vblank_nmi_gen && Reg2002_vblank_active; + if (cpu_stepcounter == 2) { NMI_offset = 1; } + else if (cpu_stepcounter == 1) { NMI_offset = 2; } + else { NMI_offset = 0; } } - else if (ppur.status.cycle == 6 && ppur.status.sl == 241 + preNMIlines) + else if (ppur.status.cycle <= 2 && nmi_destiny) + { + nmi_destiny &= reg_2000.vblank_nmi_gen && Reg2002_vblank_active; + } + else if (ppur.status.cycle == (3 + NMI_offset) && ppur.status.sl == 241 + preNMIlines) { if (nmi_destiny) { nes.cpu.NMI = true; } nes.Board.AtVsyncNMI(); } + if (ppur.status.cycle == 340) + { + if (ppur.status.sl == 241 + preNMIlines + postNMIlines - 1) + { + Reg2002_vblank_clear_pending = true; + idleSynch ^= true; + Reg2002_objhit = Reg2002_objoverflow = 0; + } + } + runppu(); // note cycle ticks inside runppu if (ppur.status.cycle == 341) { + if (Reg2002_vblank_clear_pending) + { + Reg2002_vblank_active = 0; + Reg2002_vblank_clear_pending = false; + } + ppur.status.cycle = 0; ppur.status.sl++; if (ppur.status.sl == 241 + preNMIlines + postNMIlines) { - Reg2002_objhit = Reg2002_objoverflow = 0; - Reg2002_vblank_clear_pending = true; - idleSynch ^= true; - do_vbl = false; ppur.status.sl = 0; + do_active_sl = true; } } } public void TickPPU_active() { - if (ppur.status.cycle == 0) - { - ppur.status.cycle = 0; - - spr_true_count = 0; - soam_index = 0; - soam_m_index = 0; - oam_index_aux = 0; - oam_index = 0; - is_even_cycle = true; - sprite_eval_write = true; - sprite_zero_go = sprite_zero_in_range; - - sprite_zero_in_range = false; - - yp = ppur.status.sl - 1; - ppuphase = PPUPHASE.BG; - - // "If PPUADDR is not less then 8 when rendering starts, the first 8 bytes in OAM are written to from - // the current location of PPUADDR" - if (ppur.status.sl == 0 && PPUON && reg_2003 >= 8 && region == Region.NTSC) - { - for (int i = 0; i < 8; i++) - { - OAM[i] = OAM[(reg_2003 & 0xF8) + i]; - } - } - - if (NTViewCallback != null && yp == NTViewCallback.Scanline) NTViewCallback.Callback(); - if (PPUViewCallback != null && yp == PPUViewCallback.Scanline) PPUViewCallback.Callback(); - - // set up intial values to use later - yp_shift = yp << 8; - xt = 0; - xp = 0; - - sprite_eval_cycle = 0; - - xstart = xt << 3; - target = yp_shift + xstart; - rasterpos = xstart; - - spriteHeight = reg_2000.obj_size_16 ? 16 : 8; - - //check all the conditions that can cause things to render in these 8px - renderspritenow = show_obj_new && (xt > 0 || reg_2001.show_obj_leftmost); - hit_pending = false; - - } - if (ppur.status.cycle < 256) { + if (ppur.status.cycle == 0) + { + ppur.status.cycle = 0; + + spr_true_count = 0; + soam_index = 0; + soam_m_index = 0; + oam_index_aux = 0; + oam_index = 0; + is_even_cycle = true; + sprite_eval_write = true; + sprite_zero_go = sprite_zero_in_range; + + sprite_zero_in_range = false; + + yp = ppur.status.sl - 1; + ppuphase = PPU_PHASE_BG; + + // "If PPUADDR is not less then 8 when rendering starts, the first 8 bytes in OAM are written to from + // the current location of PPUADDR" + if (ppur.status.sl == 0 && PPUON && reg_2003 >= 8 && region == Region.NTSC) + { + for (int i = 0; i < 8; i++) + { + OAM[i] = OAM[(reg_2003 & 0xF8) + i]; + } + } + + if (NTViewCallback != null && yp == NTViewCallback.Scanline) NTViewCallback.Callback(); + if (PPUViewCallback != null && yp == PPUViewCallback.Scanline) PPUViewCallback.Callback(); + + // set up intial values to use later + yp_shift = yp << 8; + xt = 0; + xp = 0; + + sprite_eval_cycle = 0; + + xstart = xt << 3; + target = yp_shift + xstart; + rasterpos = xstart; + + spriteHeight = reg_2000.obj_size_16 ? 16 : 8; + + //check all the conditions that can cause things to render in these 8px + renderspritenow = show_obj_new && (xt > 0 || reg_2001.show_obj_leftmost); + } + if (ppur.status.sl != 0) { ///////////////////////////////////////////// // Sprite Evaluation Start ///////////////////////////////////////////// - - if (sprite_eval_cycle <= 63 && !is_even_cycle) + + if (sprite_eval_cycle < 64) { // the first 64 cycles of each scanline are used to initialize sceondary OAM // the actual effect setting a flag that always returns 0xFF from a OAM read // this is a bit of a shortcut to save some instructions // data is read from OAM as normal but never used - soam[soam_index] = 0xFF; - soam_index++; + if (!is_even_cycle) + { + soam[soam_index] = 0xFF; + soam_index++; + } } - if (sprite_eval_cycle == 64) - { - soam_index = 0; - oam_index = reg_2003; - } - // otherwise, scan through OAM and test if sprites are in range // if they are, they get copied to the secondary OAM - if (sprite_eval_cycle >= 64) + else { + if (sprite_eval_cycle == 64) + { + soam_index = 0; + oam_index = reg_2003; + } + if (oam_index >= 256) { oam_index = 0; sprite_eval_write = false; } - if (is_even_cycle && oam_index < 256) + if (is_even_cycle) { if ((oam_index + soam_m_index) < 256) read_value = OAM[oam_index + soam_m_index]; else read_value = OAM[oam_index + soam_m_index - 256]; } - else if (!sprite_eval_write) - { - // if we don't write sprites anymore, just scan through the oam - read_value = soam[0]; - oam_index += 4; - } else if (sprite_eval_write) { //look for sprites @@ -328,12 +341,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES oam_index += 4; } } - else if (soam_index >= 8) + else { if (yp >= read_value && yp < read_value + spriteHeight && PPUON) { - hit_pending = true; - //Reg2002_objoverflow = true; + Reg2002_objoverflow = true; } if (yp >= read_value && yp < read_value + spriteHeight && spr_true_count == 0) @@ -368,54 +380,28 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES read_value = soam[0]; //writes change to reads } } + else + { + // if we don't write sprites anymore, just scan through the oam + read_value = soam[0]; + oam_index += 4; + } } - + ///////////////////////////////////////////// // Sprite Evaluation End ///////////////////////////////////////////// + int pixel = 0, pixelcolor = PALRAM[pixel]; + //process the current clock's worth of bg data fetching //this needs to be split into 8 pieces or else exact sprite 0 hitting wont work // due to the cpu not running while the sprite renders below - if (PPUON) { Read_bgdata(xp, ref bgdata[xt + 2]); } - - runppu(); - - if (PPUON && xp == 6) - { - ppu_was_on = true; - } - - if (PPUON && xp == 7) - { - if (!race_2006) - ppur.increment_hsc(); - - if (ppur.status.cycle == 256 && !race_2006) - ppur.increment_vs(); - - ppu_was_on = false; - } - - if (hit_pending) - { - hit_pending = false; - Reg2002_objoverflow = true; - } - - renderbgnow = show_bg_new && (xt > 0 || reg_2001.show_bg_leftmost); - //bg pos is different from raster pos due to its offsetability. - //so adjust for that here - int bgpos = rasterpos + ppur.fh; - int bgpx = bgpos & 7; - int bgtile = bgpos >> 3; - - int pixel = 0, pixelcolor = PALRAM[pixel]; - + if (PPUON) { Read_bgdata(xp, xt + 2); } //according to qeed's doc, use palette 0 or $2006's value if it is & 0x3Fxx //at one point I commented this out to fix bottom-left garbage in DW4. but it's needed for full_nes_palette. //solution is to only run when PPU is actually OFF (left-suppression doesnt count) - if (!PPUON) + else { // if there's anything wrong with how we're doing this, someone please chime in int addr = ppur.get_2007access(); @@ -424,15 +410,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES pixel = addr & 0x1F; } pixelcolor = PALRAM[pixel]; - pixelcolor |= 0x8000; //whats this? i think its a flag to indicate a hidden background to be used by the canvas filling logic later + pixelcolor |= 0x8000; } //generate the BG data - if (renderbgnow) + if (show_bg_new && (xt > 0 || reg_2001.show_bg_leftmost)) { + int bgtile = (rasterpos + ppur.fh) >> 3; byte pt_0 = bgdata[bgtile].pt_0; byte pt_1 = bgdata[bgtile].pt_1; - int sel = 7 - bgpx; + int sel = 7 - (rasterpos + ppur.fh) & 7; pixel = ((pt_0 >> sel) & 1) | (((pt_1 >> sel) & 1) << 1); if (pixel != 0) pixel |= bgdata[bgtile].at; @@ -440,7 +427,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } if (!nes.Settings.DispBackground) - pixelcolor = 0x8000; //whats this? i think its a flag to indicate a hidden background to be used by the canvas filling logic later + pixelcolor = 0x8000; //check if the pixel has a sprite in it if (sl_sprites[256 + xt * 8 + xp] != 0 && renderspritenow) @@ -467,14 +454,53 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } //oamcount loop + runppu(); + + if (xp == 6 && PPUON) + { + ppu_was_on = true; + if (ppur.status.cycle == 255) { race_2006 = true; } + } + + if (xp == 7 && PPUON) + { + ppur.increment_hsc(); + + if (ppur.status.cycle == 256) + { + ppur.increment_vs(); + } + + if (race_2006_2) + { + if (ppur.status.cycle == 256) + { + ppur.fv &= ppur._fv; + ppur.v &= ppur._v; + ppur.h &= ppur._h; + ppur.vt &= ppur._vt; + ppur.ht &= ppur._ht; + } + else + { + ppur.fv = ppur._fv; + ppur.v = ppur._v; + ppur.h &= ppur._h; + ppur.vt = ppur._vt; + ppur.ht &= ppur._ht; + } + } + + ppu_was_on = false; + } + + race_2006_2 = false; pipeline(pixelcolor, xt * 8 + xp); target++; // clear out previous sprites from scanline buffer - //sl_sprites[xt * 8 + xp] = 0; sl_sprites[256 + xt * 8 + xp] = 0; - //sl_sprites[512 + xt * 8 + xp] = 0; // end of visible part of the scanline sprite_eval_cycle++; @@ -494,33 +520,56 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //check all the conditions that can cause things to render in these 8px renderspritenow = show_obj_new && (xt > 0 || reg_2001.show_obj_leftmost); - hit_pending = false; - - } + } } else { // if scanline is the pre-render line, we just read BG data - Read_bgdata(xp, ref bgdata[xt + 2]); + Read_bgdata(xp, xt + 2); runppu(); - if (PPUON && xp == 6) + if (xp == 6 && PPUON) { ppu_was_on = true; + if (ppur.status.cycle == 255) { race_2006 = true; } + } - if (PPUON && xp == 7) + if (xp == 7 && PPUON) { - if (!race_2006) - ppur.increment_hsc(); + ppur.increment_hsc(); - if (ppur.status.cycle == 256 && !race_2006) + if (ppur.status.cycle == 256) + { ppur.increment_vs(); + } + + if(race_2006_2) + { + if (ppur.status.cycle == 256) + { + ppur.fv &= ppur._fv; + ppur.v &= ppur._v; + ppur.h &= ppur._h; + ppur.vt &= ppur._vt; + ppur.ht &= ppur._ht; + } + else + { + ppur.fv = ppur._fv; + ppur.v = ppur._v; + ppur.h &= ppur._h; + ppur.vt = ppur._vt; + ppur.ht &= ppur._ht; + } + } ppu_was_on = false; } + race_2006_2 = false; + xp++; if (xp == 8) @@ -566,14 +615,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (soam_index_prev > 8 && !nes.Settings.AllowMoreThanEightSprites) soam_index_prev = 8; - ppuphase = PPUPHASE.OBJ; + ppuphase = PPU_PHASE_OBJ; spriteHeight = reg_2000.obj_size_16 ? 16 : 8; s = 0; ppu_aux_index = 0; - junksprite = (!PPUON); + junksprite = !PPUON; t_oam[s].oam_y = soam[s * 4]; t_oam[s].oam_ind = soam[s * 4 + 1]; @@ -612,7 +661,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES runppu(); break; case 1: - if (PPUON && ppur.status.sl == 0 && ppur.status.cycle == 305) + if (ppur.status.sl == 0 && ppur.status.cycle == 305 && PPUON) { ppur.install_latches(); @@ -620,40 +669,45 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES runppu(); } - else if (PPUON && (ppur.status.sl != 0) && ppur.status.cycle == 257) + else if ((ppur.status.sl != 0) && ppur.status.cycle == 257 && PPUON) { if (target <= 61441 && target > 0 && s == 0) { - pipeline(0, 256); + pipeline(0, 256); // last pipeline call option 1 of 2 target++; } //at 257: 3d world runner is ugly if we do this at 256 - if (PPUON) ppur.install_h_latches(); + if (PPUON/* && !race_2006_2*/) { ppur.install_h_latches(); } + race_2006_2 = false; read_value = t_oam[s].oam_ind; runppu(); + /* if (target <= 61441 && target > 0 && s == 0) { - pipeline(0, 257); // last pipeline call option 1 of 2 + //pipeline(0, 257); } + */ } else { if (target <= 61441 && target > 0 && s == 0) { - pipeline(0, 256); + pipeline(0, 256); // last pipeline call option 2 of 2 target++; } read_value = t_oam[s].oam_ind; runppu(); + /* if (target <= 61441 && target > 0 && s == 0) { - pipeline(0, 257); // last pipeline call option 2 of 2 + //pipeline(0, 257); } + */ } break; @@ -684,15 +738,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } break; case 5: - // if the PPU is off, we don't put anything on the bus - if (junksprite) - { - runppu(); - } - else - { - runppu(); - } + runppu(); break; case 6: // if the PPU is off, we don't put anything on the bus @@ -770,7 +816,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (s < 8) { - junksprite = (!PPUON); + junksprite = !PPUON; t_oam[s].oam_y = soam[s * 4]; t_oam[s].oam_ind = soam[s * 4 + 1]; @@ -870,26 +916,26 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else { - if (ppur.status.cycle == 320) - { - ppuphase = PPUPHASE.BG; - xt = 0; - xp = 0; - } - if (ppur.status.cycle < 336) { + if (ppur.status.cycle == 320) + { + ppuphase = PPU_PHASE_BG; + xt = 0; + xp = 0; + } + // if scanline is the pre-render line, we just read BG data - Read_bgdata(xp, ref bgdata[xt]); + Read_bgdata(xp, xt); runppu(); - if (PPUON && xp == 6) + if (xp == 6 && PPUON) { ppu_was_on = true; } - if (PPUON && xp == 7) + if (xp == 7 && PPUON) { if (!race_2006) ppur.increment_hsc(); @@ -910,12 +956,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else if (ppur.status.cycle < 340) { + if (ppur.status.cycle == 339) + { + evenOddDestiny = PPUON; + } + runppu(); } else { - bool evenOddDestiny = PPUON; - // After memory access 170, the PPU simply rests for 4 cycles (or the // equivelant of half a memory access cycle) before repeating the whole // pixel/scanline rendering process. If the scanline being rendered is the very @@ -935,21 +984,37 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (ppur.status.sl == 241) { do_active_sl = false; + do_pre_vbl = true; } } } public void TickPPU_preVBL() { + if (ppur.status.cycle == 340) + { + Reg2002_vblank_active_pending = true; + } + runppu(); if (ppur.status.cycle == 341) { + if (Reg2002_vblank_active_pending) + { + Reg2002_vblank_active = 1; + Reg2002_vblank_active_pending = false; + } + ppur.status.cycle = 0; ppur.status.sl++; if (ppur.status.sl == 241 + preNMIlines) { do_pre_vbl = false; + do_vbl = true; + + ppu_init_frame(); + nes.frame_is_done = true; } } } @@ -961,11 +1026,28 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //to wait for vblank public void NewDeadPPU() { + if (ppur.status.cycle == 241 * 341 - start_up_offset - 1) + { + Reg2002_vblank_active_pending = true; + } + runppu(); - if (ppur.status.cycle == 241 * 341 - 3) + if (ppur.status.cycle == 241 * 341 - start_up_offset) { + if (Reg2002_vblank_active_pending) + { + Reg2002_vblank_active = 1; + Reg2002_vblank_active_pending = false; + } + ppudead--; + + ppu_init_frame(); + + do_vbl = true; + + nes.frame_is_done = true; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index 899ae0254f..dc60a866f1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -37,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES Context = QN.qn_new(); if (Context == IntPtr.Zero) { - throw new InvalidOperationException("qn_new() returned NULL"); + throw new InvalidOperationException($"{nameof(QN.qn_new)}() returned NULL"); } try @@ -179,7 +179,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES #endregion - public void FrameAdvance(IController controller, bool render, bool rendersound = true) + public bool FrameAdvance(IController controller, bool render, bool rendersound = true) { CheckDisposed(); using (FP.Save()) @@ -211,6 +211,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES if (CB1 != null) CB1(); if (CB2 != null) CB2(); } + + return true; } IntPtr Context; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs index a245fbdbbf..e16511cbaa 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { _controller = controller; @@ -80,6 +80,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { LagCount++; } + + return true; } public int Frame diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/ReadMe.txt b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/ReadMe.txt new file mode 100644 index 0000000000..bc60bf4b01 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/ReadMe.txt @@ -0,0 +1 @@ +TODO: diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IDebuggable.cs new file mode 100644 index 0000000000..fe41918f23 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IDebuggable.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk +{ + public partial class SubNESHawk : IDebuggable + { + public IDictionary GetCpuFlagsAndRegisters() + { + return new Dictionary + { + /* + ["A"] = cpu.A, + ["X"] = cpu.X, + ["Y"] = cpu.Y, + ["S"] = cpu.S, + ["PC"] = cpu.PC, + ["Flag C"] = cpu.FlagC, + ["Flag Z"] = cpu.FlagZ, + ["Flag I"] = cpu.FlagI, + ["Flag D"] = cpu.FlagD, + ["Flag B"] = cpu.FlagB, + ["Flag V"] = cpu.FlagV, + ["Flag N"] = cpu.FlagN, + ["Flag T"] = cpu.FlagT + */ + }; + } + + public void SetCpuRegister(string register, int value) + { + switch (register) + { + default: + throw new InvalidOperationException(); + case "A": + //cpu.A = (byte)value; + break; + case "X": + //cpu.X = (byte)value; + break; + case "Y": + //cpu.Y = (byte)value; + break; + case "S": + //cpu.S = (byte)value; + break; + case "PC": + //cpu.PC = (ushort)value; + break; + case "Flag I": + //cpu.FlagI = value > 0; + break; + } + } + + public bool CanStep(StepType type) + { + return false; + } + + public IMemoryCallbackSystem MemoryCallbacks { get; private set; } + + [FeatureNotImplemented] + public void Step(StepType type) { throw new NotImplementedException(); } + + public long TotalExecutedCycles + { + get { return subnes.cpu.TotalExecutedCycles; } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs new file mode 100644 index 0000000000..ba5b1c0638 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs @@ -0,0 +1,221 @@ +using System; + +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Nintendo.NES; + +namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk +{ + public partial class SubNESHawk : IEmulator + { + public IEmulatorServiceProvider ServiceProvider { get; } + + public ControllerDefinition ControllerDefinition => subnes.ControllerDefinition; + + public bool FrameAdvance(IController controller, bool render, bool rendersound) + { + //Console.WriteLine("-----------------------FRAME-----------------------"); + if (_tracer.Enabled) + { + subnes.cpu.TraceCallback = s => _tracer.Put(s); + } + else + { + subnes.cpu.TraceCallback = null; + } + + _frame++; + + if (controller.IsPressed("Power")) + { + HardReset(); + } + + reset_frame = false; + if (controller.IsPressed("Reset")) + { + reset_frame = true; + } + + reset_cycle = controller.GetFloat("Reset Cycle"); + reset_cycle_int = (int)Math.Floor(reset_cycle); + + _islag = true; + subnes.alt_lag = true; + + InputCallbacks.Call(); + + do_frame(controller); + + bool ret = pass_a_frame; + + if (pass_a_frame) + { + subnes.videoProvider.FillFrameBuffer(); + current_cycle = 0; + subnes.cpu.ext_ppu_cycle = current_cycle; + } + + _islag = subnes.alt_lag; + + if (_islag) + { + _lagcount++; + VBL_CNT++; + } + + reset_frame = false; + return ret; + } + + public bool stop_cur_frame; + public bool pass_new_input; + public bool pass_a_frame; + public bool reset_frame; + public int current_cycle; + public float reset_cycle; + public int reset_cycle_int; + + public void do_frame(IController controller) + { + stop_cur_frame = false; + while (!stop_cur_frame) + { + if (reset_frame && (current_cycle == reset_cycle_int)) + { + SoftReset(); + reset_frame = false; + } + subnes.do_single_step(controller, out pass_new_input, out pass_a_frame); + current_cycle++; + subnes.cpu.ext_ppu_cycle = current_cycle; + stop_cur_frame |= pass_a_frame; + stop_cur_frame |= pass_new_input; + } + } + + public int Frame => _frame; + + public string SystemId => "NES"; + + public bool DeterministicEmulation { get; set; } + + public void ResetCounters() + { + _frame = 0; + _lagcount = 0; + _islag = false; + } + + public CoreComm CoreComm { get; } + + public void Dispose() + { + subnes.Dispose(); + } + /* + #region Video provider + + public int _frameHz = 60; + + public int[] _vidbuffer = new int[160 * 2 * 144]; + public int[] buff_L = new int[160 * 144]; + public int[] buff_R = new int[160 * 144]; + + public int[] GetVideoBuffer() + { + // combine the 2 video buffers from the instances + for (int i = 0; i < 144; i++) + { + for (int j = 0; j < 160; j++) + { + _vidbuffer[i * 320 + j] = buff_L[i * 160 + j]; + _vidbuffer[i * 320 + j + 160] = buff_R[i * 160 + j]; + } + } + + return _vidbuffer; + } + + public int VirtualWidth => 160 * 2; + public int VirtualHeight => 144; + public int BufferWidth => 160 * 2; + public int BufferHeight => 144; + public int BackgroundColor => unchecked((int)0xFF000000); + public int VsyncNumerator => _frameHz; + public int VsyncDenominator => 1; + + public static readonly uint[] color_palette_BW = { 0xFFFFFFFF , 0xFFAAAAAA, 0xFF555555, 0xFF000000 }; + public static readonly uint[] color_palette_Gr = { 0xFFA4C505, 0xFF88A905, 0xFF1D551D, 0xFF052505 }; + + public uint[] color_palette = new uint[4]; + + #endregion + + #region audio + + public bool CanProvideAsync => false; + + public void SetSyncMode(SyncSoundMode mode) + { + if (mode != SyncSoundMode.Sync) + { + throw new InvalidOperationException("Only Sync mode is supported_"); + } + } + + public SyncSoundMode SyncMode => SyncSoundMode.Sync; + + public void GetSamplesSync(out short[] samples, out int nsamp) + { + short[] temp_samp_L; + short[] temp_samp_R; + + int nsamp_L; + int nsamp_R; + + L.audio.GetSamplesSync(out temp_samp_L, out nsamp_L); + R.audio.GetSamplesSync(out temp_samp_R, out nsamp_R); + + if (linkSettings.AudioSet == GBLinkSettings.AudioSrc.Left) + { + samples = temp_samp_L; + nsamp = nsamp_L; + } + else if (linkSettings.AudioSet == GBLinkSettings.AudioSrc.Right) + { + samples = temp_samp_R; + nsamp = nsamp_R; + } + else + { + samples = new short[0]; + nsamp = 0; + } + } + + public void GetSamplesAsync(short[] samples) + { + throw new NotSupportedException("Async is not available"); + } + + public void DiscardSamples() + { + L.audio.DiscardSamples(); + R.audio.DiscardSamples(); + } + + private void GetSamples(short[] samples) + { + + } + + public void DisposeSound() + { + L.audio.DisposeSound(); + R.audio.DisposeSound(); + } + + #endregion + */ + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IInputPollable.cs new file mode 100644 index 0000000000..04c6faea5c --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IInputPollable.cs @@ -0,0 +1,24 @@ +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk +{ + public partial class SubNESHawk : IInputPollable + { + public int LagCount + { + get { return _lagcount; } + set { _lagcount = value; } + } + + public bool IsLagFrame + { + get { return _islag; } + set { _islag = value; } + } + + public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); + + public bool _islag = true; + private int _lagcount; + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IMemoryDomains.cs new file mode 100644 index 0000000000..b1aafedaf7 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IMemoryDomains.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk +{ + public partial class SubNESHawk + { + private MemoryDomainList _memoryDomains; + private bool _memoryDomainsSetup = false; + + private void SetupMemoryDomains() + { + var domains = new List(); + var RAM = new MemoryDomainByteArray("RAM", MemoryDomain.Endian.Little, subnes.ram, true, 1); + var SystemBus = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little, + addr => subnes.PeekMemory((ushort)addr), (addr, value) => subnes.ApplySystemBusPoke((int)addr, value), 1); + var PPUBus = new MemoryDomainDelegate("PPU Bus", 0x4000, MemoryDomain.Endian.Little, + addr => subnes.ppu.ppubus_peek((int)addr), (addr, value) => subnes.ppu.ppubus_write((int)addr, value), 1); + var CIRAMdomain = new MemoryDomainByteArray("CIRAM (nametables)", MemoryDomain.Endian.Little, subnes.CIRAM, true, 1); + var OAMdoman = new MemoryDomainByteArray("OAM", MemoryDomain.Endian.Unknown, subnes.ppu.OAM, true, 1); + + domains.Add(RAM); + domains.Add(SystemBus); + domains.Add(PPUBus); + domains.Add(CIRAMdomain); + domains.Add(OAMdoman); + + if (!(subnes.Board is NES.FDS) && subnes.Board.SaveRam != null) + { + var BatteryRam = new MemoryDomainByteArray("Battery RAM", MemoryDomain.Endian.Little, subnes.Board.SaveRam, true, 1); + domains.Add(BatteryRam); + } + + if (subnes.Board.ROM != null) + { + var PRGROM = new MemoryDomainByteArray("PRG ROM", MemoryDomain.Endian.Little, subnes.Board.ROM, true, 1); + domains.Add(PRGROM); + } + + if (subnes.Board.VROM != null) + { + var CHRROM = new MemoryDomainByteArray("CHR VROM", MemoryDomain.Endian.Little, subnes.Board.VROM, true, 1); + domains.Add(CHRROM); + } + + if (subnes.Board.VRAM != null) + { + var VRAM = new MemoryDomainByteArray("VRAM", MemoryDomain.Endian.Little, subnes.Board.VRAM, true, 1); + domains.Add(VRAM); + } + + if (subnes.Board.WRAM != null) + { + var WRAM = new MemoryDomainByteArray("WRAM", MemoryDomain.Endian.Little, subnes.Board.WRAM, true, 1); + domains.Add(WRAM); + } + + // if there were more boards with special ram sets, we'd want to do something more general + if (subnes.Board is NES.FDS) + { + domains.Add((subnes.Board as NES.FDS).GetDiskPeeker()); + } + else if (subnes.Board is NES.ExROM) + { + domains.Add((subnes.Board as NES.ExROM).GetExRAM()); + } + + if (!_memoryDomainsSetup) + { + _memoryDomains = new MemoryDomainList(domains); + (ServiceProvider as BasicServiceProvider).Register(_memoryDomains); + _memoryDomainsSetup = true; + } + else + { + var src = new MemoryDomainList(domains); + _memoryDomains.MergeList(src); + } + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.ISaveRam.cs new file mode 100644 index 0000000000..1d61877e5b --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.ISaveRam.cs @@ -0,0 +1,42 @@ +using System; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk +{ + public partial class SubNESHawk : ISaveRam + { + public bool SaveRamModified + { + get + { + if (subnes.Board == null) return false; + if (subnes.Board is NES.FDS) return true; + if (subnes.Board.SaveRam == null) return false; + return true; + } + } + + public byte[] CloneSaveRam() + { + if (subnes.Board is NES.FDS) + return (subnes.Board as NES.FDS).ReadSaveRam(); + + if (subnes.Board == null || subnes.Board.SaveRam == null) + return null; + return (byte[])subnes.Board.SaveRam.Clone(); + } + + public void StoreSaveRam(byte[] data) + { + if (subnes.Board is NES.FDS) + { + (subnes.Board as NES.FDS).StoreSaveRam(data); + return; + } + + if (subnes.Board == null || subnes.Board.SaveRam == null) + return; + Array.Copy(data, subnes.Board.SaveRam, data.Length); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs new file mode 100644 index 0000000000..6ded0e50d8 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs @@ -0,0 +1,64 @@ +using System.IO; + +using BizHawk.Common; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Nintendo.NES; + +namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk +{ + public partial class SubNESHawk : IStatable + { + public bool BinarySaveStatesPreferred => true; + + public void SaveStateText(TextWriter writer) + { + subnes.SaveStateText(writer); + SyncState(new Serializer(writer)); + } + + public void LoadStateText(TextReader reader) + { + subnes.LoadStateText(reader); + SyncState(new Serializer(reader)); + } + + public void SaveStateBinary(BinaryWriter bw) + { + subnes.SaveStateBinary(bw); + // other variables + SyncState(new Serializer(bw)); + } + + public void LoadStateBinary(BinaryReader br) + { + subnes.LoadStateBinary(br); + // other variables + SyncState(new Serializer(br)); + } + + public byte[] SaveStateBinary() + { + MemoryStream ms = new MemoryStream(); + BinaryWriter bw = new BinaryWriter(ms); + SaveStateBinary(bw); + bw.Flush(); + return ms.ToArray(); + } + + //private JsonSerializer ser = new JsonSerializer { Formatting = Formatting.Indented }; + + private void SyncState(Serializer ser) + { + ser.Sync("Lag", ref _lagcount); + ser.Sync("Frame", ref _frame); + ser.Sync("IsLag", ref _islag); + ser.Sync(nameof(pass_a_frame), ref pass_a_frame); + ser.Sync(nameof(reset_frame), ref reset_frame); + ser.Sync(nameof(pass_new_input), ref pass_new_input); + ser.Sync(nameof(current_cycle), ref current_cycle); + ser.Sync(nameof(reset_cycle), ref reset_cycle); + ser.Sync(nameof(reset_cycle_int), ref reset_cycle_int); + ser.Sync(nameof(VBL_CNT), ref VBL_CNT); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs new file mode 100644 index 0000000000..6abdd61162 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs @@ -0,0 +1,229 @@ +using System; + +using BizHawk.Emulation.Common; + +using BizHawk.Emulation.Cores.Nintendo.NES; + +namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk +{ + [Core( + "SubNESHawk", + "", + isPorted: false, + isReleased: true)] + [ServiceNotApplicable(typeof(IDriveLight))] + public partial class SubNESHawk : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, + ISettable, INESPPUViewable + { + public NES.NES subnes; + + // needed for movies to accurately calculate timing + public int VBL_CNT; + + [CoreConstructor("NES")] + public SubNESHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) + { + var ser = new BasicServiceProvider(this); + + subnesSettings = (NES.NES.NESSettings)settings ?? new NES.NES.NESSettings(); + subnesSyncSettings = (NES.NES.NESSyncSettings)syncSettings ?? new NES.NES.NESSyncSettings(); + + CoreComm = comm; + + subnes = new NES.NES(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, + game, rom, subnesSettings, subnesSyncSettings); + + ser.Register(subnes.videoProvider); + ser.Register(subnes); + + _tracer = new TraceBuffer { Header = "6502: PC, machine code, mnemonic, operands, registers (A, X, Y, P, SP), flags (NVTBDIZCR), CPU Cycle, PPU Cycle" }; + ser.Register(_tracer); + + ServiceProvider = ser; + + (ServiceProvider as BasicServiceProvider).Register(subnes._memoryDomains); + + subnes.using_reset_timing = true; + HardReset(); + current_cycle = 0; + subnes.cpu.ext_ppu_cycle = current_cycle; + VBL_CNT = 0; + } + + public void HardReset() + { + subnes.HardReset(); + } + + public void SoftReset() + { + subnes.Board.NESSoftReset(); + subnes.cpu.NESSoftReset(); + subnes.apu.NESSoftReset(); + subnes.ppu.NESSoftReset(); + current_cycle = 0; + subnes.cpu.ext_ppu_cycle = current_cycle; + } + + public DisplayType Region => DisplayType.NTSC; + + public int _frame = 0; + + private readonly ITraceable _tracer; + + private void ExecFetch(ushort addr) + { + MemoryCallbacks.CallExecutes(addr, "System Bus"); + } + + #region ISettable + private NES.NES.NESSettings subnesSettings = new NES.NES.NESSettings(); + public NES.NES.NESSyncSettings subnesSyncSettings = new NES.NES.NESSyncSettings(); + + public NES.NES.NESSettings GetSettings() + { + return subnesSettings.Clone(); + } + + public NES.NES.NESSyncSettings GetSyncSettings() + { + return subnesSyncSettings.Clone(); + } + + public bool PutSettings(NES.NES.NESSettings o) + { + subnesSettings = o; + if (subnesSettings.ClipLeftAndRight) + { + subnes.videoProvider.left = 8; + subnes.videoProvider.right = 247; + } + else + { + subnes.videoProvider.left = 0; + subnes.videoProvider.right = 255; + } + + CoreComm.ScreenLogicalOffsetX = subnes.videoProvider.left; + CoreComm.ScreenLogicalOffsetY = Region == DisplayType.NTSC ? subnesSettings.NTSC_TopLine : subnesSettings.PAL_TopLine; + + subnes.SetPalette(subnesSettings.Palette); + + subnes.apu.m_vol = subnesSettings.APU_vol; + + return false; + } + + public bool PutSyncSettings(NES.NES.NESSyncSettings o) + { + bool ret = NES.NES.NESSyncSettings.NeedsReboot(subnesSyncSettings, o); + subnesSyncSettings = o; + return ret; + } + #endregion + + #region PPU Viewable + + public int[] GetPalette() + { + return subnes.palette_compiled; + } + + public bool BGBaseHigh + { + get { return subnes.ppu.reg_2000.bg_pattern_hi; } + } + + public bool SPBaseHigh + { + get { return subnes.ppu.reg_2000.obj_pattern_hi; } + } + + public bool SPTall + { + get { return subnes.ppu.reg_2000.obj_size_16; } + } + + public byte[] GetPPUBus() + { + byte[] ret = new byte[0x3000]; + for (int i = 0; i < 0x3000; i++) + { + ret[i] = subnes.ppu.ppubus_peek(i); + } + return ret; + } + + public byte[] GetPalRam() + { + return subnes.ppu.PALRAM; + } + + public byte[] GetOam() + { + return subnes.ppu.OAM; + } + + public byte PeekPPU(int addr) + { + return subnes.Board.PeekPPU(addr); + } + + public byte[] GetExTiles() + { + if (subnes.Board is ExROM) + { + return subnes.Board.VROM ?? subnes.Board.VRAM; + } + else + { + throw new InvalidOperationException(); + } + } + + public bool ExActive + { + get { return subnes.Board is ExROM && (subnes.Board as ExROM).ExAttrActive; } + } + + public byte[] GetExRam() + { + if (subnes.Board is ExROM) + { + return (subnes.Board as ExROM).GetExRAMArray(); + } + else + { + throw new InvalidOperationException(); + } + } + + public MemoryDomain GetCHRROM() + { + return _memoryDomains["CHR VROM"]; + } + + + public void InstallCallback1(Action cb, int sl) + { + subnes.ppu.NTViewCallback = new PPU.DebugCallback { Callback = cb, Scanline = sl }; + } + + public void InstallCallback2(Action cb, int sl) + { + subnes.ppu.PPUViewCallback = new PPU.DebugCallback { Callback = cb, Scanline = sl }; + } + + public void RemoveCallback1() + { + subnes.ppu.NTViewCallback = null; + } + + public void RemoveCallback2() + { + subnes.ppu.PPUViewCallback = null; + } + + #endregion + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/ADPCM.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/ADPCM.cs index 89472c489b..838f6584b6 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/ADPCM.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/ADPCM.cs @@ -322,27 +322,27 @@ namespace BizHawk.Emulation.Cores.PCEngine public void SyncState(Serializer ser) { - ser.BeginSection("ADPCM"); - ser.Sync("RAM", ref RAM, false); - ser.Sync("IOAddress", ref IOAddress); - ser.Sync("AdpcmLength", ref AdpcmLength); - ser.Sync("ReadAddress", ref ReadAddress); - ser.Sync("ReadTimer", ref ReadTimer); - ser.Sync("ReadPending", ref ReadPending); - ser.Sync("WriteAddress", ref WriteAddress); - ser.Sync("WriteTimer", ref WriteTimer); - ser.Sync("WriteBuffer", ref WriteBuffer); - ser.Sync("WritePending", ref WritePending); + ser.BeginSection(nameof(ADPCM)); + ser.Sync(nameof(RAM), ref RAM, false); + ser.Sync(nameof(IOAddress), ref IOAddress); + ser.Sync(nameof(AdpcmLength), ref AdpcmLength); + ser.Sync(nameof(ReadAddress), ref ReadAddress); + ser.Sync(nameof(ReadTimer), ref ReadTimer); + ser.Sync(nameof(ReadPending), ref ReadPending); + ser.Sync(nameof(WriteAddress), ref WriteAddress); + ser.Sync(nameof(WriteTimer), ref WriteTimer); + ser.Sync(nameof(WriteBuffer), ref WriteBuffer); + ser.Sync(nameof(WritePending), ref WritePending); - ser.Sync("Port180B", ref Port180B); - ser.Sync("Port180D", ref Port180D); - ser.Sync("Port180E", ref port180E); + ser.Sync(nameof(Port180B), ref Port180B); + ser.Sync(nameof(Port180D), ref Port180D); + ser.Sync(nameof(Port180E), ref port180E); - ser.Sync("AdpcmIsPlaying", ref AdpcmIsPlaying); - ser.Sync("HalfReached", ref HalfReached); - ser.Sync("EndReached", ref EndReached); + ser.Sync(nameof(AdpcmIsPlaying), ref AdpcmIsPlaying); + ser.Sync(nameof(HalfReached), ref HalfReached); + ser.Sync(nameof(EndReached), ref EndReached); - ser.Sync("Playback44khzTimer", ref Playback44khzTimer); + ser.Sync(nameof(Playback44khzTimer), ref Playback44khzTimer); ser.Sync("PlayingSample", ref playingSample); ser.Sync("NextSampleTimer", ref nextSampleTimer); ser.Sync("Nibble", ref nibble); diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ArcadeCard.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ArcadeCard.cs index 8d5168efca..33ce5525af 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ArcadeCard.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.ArcadeCard.cs @@ -139,10 +139,10 @@ namespace BizHawk.Emulation.Cores.PCEngine public void ArcadeCardSyncState(Serializer ser) { - ser.BeginSection("ArcadeCard"); - ser.Sync("ShiftRegister", ref ShiftRegister); - ser.Sync("ShiftAmount", ref ShiftAmount); - ser.Sync("RotateAmount", ref RotateAmount); + ser.BeginSection(nameof(ArcadeCard)); + ser.Sync(nameof(ShiftRegister), ref ShiftRegister); + ser.Sync(nameof(ShiftAmount), ref ShiftAmount); + ser.Sync(nameof(RotateAmount), ref RotateAmount); if (ArcadeCardRewindHack == false || ser.IsText) { @@ -153,10 +153,10 @@ namespace BizHawk.Emulation.Cores.PCEngine { ser.BeginSection("Page" + i); - ser.Sync("Control", ref ArcadePage[i].Control); - ser.Sync("Base", ref ArcadePage[i].Base); - ser.Sync("Offset", ref ArcadePage[i].Offset); - ser.Sync("IncrementValue", ref ArcadePage[i].IncrementValue); + ser.Sync(nameof(ArcadeCardPage.Control), ref ArcadePage[i].Control); + ser.Sync(nameof(ArcadeCardPage.Base), ref ArcadePage[i].Base); + ser.Sync(nameof(ArcadeCardPage.Offset), ref ArcadePage[i].Offset); + ser.Sync(nameof(ArcadeCardPage.IncrementValue), ref ArcadePage[i].IncrementValue); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs index 5fa7f01d7e..6b46010327 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.PCEngine public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { _controller = controller; _lagged = true; @@ -39,6 +39,8 @@ namespace BizHawk.Emulation.Cores.PCEngine { _isLag = false; } + + return true; } public int Frame diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IStatable.cs index a390c09de3..67c58347ec 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IStatable.cs @@ -56,7 +56,7 @@ namespace BizHawk.Emulation.Cores.PCEngine private void SyncState(Serializer ser) { - ser.BeginSection("PCEngine"); + ser.BeginSection(nameof(PCEngine)); Cpu.SyncState(ser); VCE.SyncState(ser); VDC1.SyncState(ser, 1); @@ -87,26 +87,26 @@ namespace BizHawk.Emulation.Cores.PCEngine } ser.Sync("RAM", ref Ram, false); - ser.Sync("IOBuffer", ref IOBuffer); - ser.Sync("CdIoPorts", ref CdIoPorts, false); - ser.Sync("BramLocked", ref BramLocked); + ser.Sync(nameof(IOBuffer), ref IOBuffer); + ser.Sync(nameof(CdIoPorts), ref CdIoPorts, false); + ser.Sync(nameof(BramLocked), ref BramLocked); ser.Sync("Frame", ref _frame); ser.Sync("Lag", ref _lagCount); ser.Sync("IsLag", ref _isLag); if (Cpu.ReadMemory21 == ReadMemorySF2) { - ser.Sync("SF2MapperLatch", ref SF2MapperLatch); + ser.Sync(nameof(SF2MapperLatch), ref SF2MapperLatch); } if (PopulousRAM != null) { - ser.Sync("PopulousRAM", ref PopulousRAM, false); + ser.Sync(nameof(PopulousRAM), ref PopulousRAM, false); } if (BRAM != null) { - ser.Sync("BRAM", ref BRAM, false); + ser.Sync(nameof(BRAM), ref BRAM, false); } ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs index 1a8472594f..bf09781625 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/ScsiCDBus.cs @@ -686,19 +686,19 @@ namespace BizHawk.Emulation.Cores.PCEngine ser.Sync("ACK", ref ack); ser.Sync("ATN", ref atn); ser.Sync("RST", ref rst); - ser.Sync("DataBits", ref DataBits); - ser.Sync("Phase", ref Phase); + ser.Sync(nameof(DataBits), ref DataBits); + ser.Sync(nameof(Phase), ref Phase); - ser.Sync("MessageCompleted", ref MessageCompleted); - ser.Sync("StatusCompleted", ref StatusCompleted); - ser.Sync("MessageValue", ref MessageValue); + ser.Sync(nameof(MessageCompleted), ref MessageCompleted); + ser.Sync(nameof(StatusCompleted), ref StatusCompleted); + ser.Sync(nameof(MessageValue), ref MessageValue); - ser.Sync("DataReadWaitTimer", ref DataReadWaitTimer); - ser.Sync("DataReadInProgress", ref DataReadInProgress); - ser.Sync("DataTransferWasDone", ref DataTransferWasDone); - ser.Sync("DataTransferInProgress", ref DataTransferInProgress); - ser.Sync("CurrentReadingSector", ref CurrentReadingSector); - ser.Sync("SectorsLeftToRead", ref SectorsLeftToRead); + ser.Sync(nameof(DataReadWaitTimer), ref DataReadWaitTimer); + ser.Sync(nameof(DataReadInProgress), ref DataReadInProgress); + ser.Sync(nameof(DataTransferWasDone), ref DataTransferWasDone); + ser.Sync(nameof(DataTransferInProgress), ref DataTransferInProgress); + ser.Sync(nameof(CurrentReadingSector), ref CurrentReadingSector); + ser.Sync(nameof(SectorsLeftToRead), ref SectorsLeftToRead); ser.Sync("CommandBuffer", ref CommandBuffer.buffer, false); ser.Sync("CommandBufferPosition", ref CommandBuffer.Position); diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VCE.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VCE.cs index 4473b23c59..4c80c601bf 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VCE.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VCE.cs @@ -72,10 +72,10 @@ namespace BizHawk.Emulation.Cores.PCEngine public void SyncState(Serializer ser) { - ser.BeginSection("VCE"); - ser.Sync("VceAddress", ref VceAddress); - ser.Sync("CR", ref CR); - ser.Sync("VceData", ref VceData, false); + ser.BeginSection(nameof(VCE)); + ser.Sync(nameof(VceAddress), ref VceAddress); + ser.Sync(nameof(CR), ref CR); + ser.Sync(nameof(VceData), ref VceData, false); ser.EndSection(); if (ser.IsReader) diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs index 4dd59e373f..f6aa768715 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs @@ -309,21 +309,21 @@ namespace BizHawk.Emulation.Cores.PCEngine public void SyncState(Serializer ser, int vdcNo) { ser.BeginSection("VDC"+vdcNo); - ser.Sync("VRAM", ref VRAM, false); + ser.Sync(nameof(VRAM), ref VRAM, false); ser.Sync("SAT", ref SpriteAttributeTable, false); - ser.Sync("Registers", ref Registers, false); - ser.Sync("RegisterLatch", ref RegisterLatch); - ser.Sync("ReadBuffer", ref ReadBuffer); - ser.Sync("StatusByte", ref StatusByte); + ser.Sync(nameof(Registers), ref Registers, false); + ser.Sync(nameof(RegisterLatch), ref RegisterLatch); + ser.Sync(nameof(ReadBuffer), ref ReadBuffer); + ser.Sync(nameof(StatusByte), ref StatusByte); - ser.Sync("DmaRequested", ref DmaRequested); - ser.Sync("SatDmaRequested", ref SatDmaRequested); - ser.Sync("SatDmaPerformed", ref SatDmaPerformed); + ser.Sync(nameof(DmaRequested), ref DmaRequested); + ser.Sync(nameof(SatDmaRequested), ref SatDmaRequested); + ser.Sync(nameof(SatDmaPerformed), ref SatDmaPerformed); - ser.Sync("ScanLine", ref ScanLine); - ser.Sync("BackgroundY", ref BackgroundY); - ser.Sync("RCRCounter", ref RCRCounter); - ser.Sync("ActiveLine", ref ActiveLine); + ser.Sync(nameof(ScanLine), ref ScanLine); + ser.Sync(nameof(BackgroundY), ref BackgroundY); + ser.Sync(nameof(RCRCounter), ref RCRCounter); + ser.Sync(nameof(ActiveLine), ref ActiveLine); ser.EndSection(); if (ser.IsReader) diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs index 47fd130afc..0239736e07 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs @@ -81,8 +81,8 @@ namespace BizHawk.Emulation.Cores.PCEngine public void SyncState(Serializer ser) { - ser.BeginSection("VPC"); - ser.Sync("Registers", ref Registers, false); + ser.BeginSection(nameof(VPC)); + ser.Sync(nameof(Registers), ref Registers, false); ser.EndSection(); if (ser.IsReader) diff --git a/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs b/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs index 462b62fbee..ae20720922 100644 --- a/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs @@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK _serviceProvider.Register(_videoProvider); } - public void FrameAdvance(IController controller, bool render, bool rendersound = true) + public bool FrameAdvance(IController controller, bool render, bool rendersound = true) { var t1 = Task.Run(() => { @@ -67,6 +67,8 @@ namespace BizHawk.Emulation.Cores.Consoles.SNK Frame++; _soundProvider.Fetch(); _videoProvider.Fetch(); + + return true; } #region link cable diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ICodeDataLog.cs new file mode 100644 index 0000000000..14bdaaa32d --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ICodeDataLog.cs @@ -0,0 +1,106 @@ +using System; +using System.IO; + +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Sega.MasterSystem; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + public sealed partial class GGHawkLink : ICodeDataLogger + { + public void SetCDL(ICodeDataLog cdl) + { + CDL = cdl; + if (cdl == null) + { + L.Cpu.ReadMemory = L.ReadMemory; + L.Cpu.WriteMemory = L.WriteMemory; + L.Cpu.FetchMemory = L.FetchMemory; + } + else + { + L.Cpu.ReadMemory = ReadMemory_CDL; + L.Cpu.WriteMemory = L.WriteMemory; + L.Cpu.FetchMemory = FetchMemory_CDL; + } + } + + public void NewCDL(ICodeDataLog cdl) + { + cdl["ROM"] = new byte[MemoryDomains["ROM"].Size]; + cdl["Main RAM"] = new byte[MemoryDomains["Main RAM"].Size]; + + if (MemoryDomains.Has("Save RAM")) + { + cdl["Save RAM"] = new byte[MemoryDomains["Save RAM"].Size]; + } + + if (MemoryDomains.Has("Cart (Volatile) RAM")) + { + cdl["Cart (Volatile) RAM"] = new byte[MemoryDomains["Cart (Volatile) RAM"].Size]; + } + + cdl.SubType = "SMS"; + cdl.SubVer = 0; + } + + [FeatureNotImplemented] + public void DisassembleCDL(Stream s, ICodeDataLog cdl) + { + + } + + private enum CDLog_AddrType + { + None, + ROM, + MainRAM, + SaveRAM, + CartRAM, //"Cart (Volatile) RAM" aka ExtRam + } + + [Flags] + private enum CDLog_Flags + { + ExecFirst = 0x01, + ExecOperand = 0x02, + Data = 0x04 + }; + + private ICodeDataLog CDL; + + private void RunCDL(ushort address, CDLog_Flags flags) + { + if (L.MapMemory != null) + { + SMS.CDLog_MapResults results = L.MapMemory(address, false); + switch (results.Type) + { + case SMS.CDLog_AddrType.None: break; + case SMS.CDLog_AddrType.ROM: CDL["ROM"][results.Address] |= (byte)flags; break; + case SMS.CDLog_AddrType.MainRAM: CDL["Main RAM"][results.Address] |= (byte)flags; break; + case SMS.CDLog_AddrType.SaveRAM: CDL["Save RAM"][results.Address] |= (byte)flags; break; + case SMS.CDLog_AddrType.CartRAM: CDL["Cart (Volatile) RAM"][results.Address] |= (byte)flags; break; + } + } + } + + /// + /// A wrapper for FetchMemory which inserts CDL logic + /// + private byte FetchMemory_CDL(ushort address) + { + RunCDL(address, CDLog_Flags.ExecFirst); + return L.ReadMemory(address); + } + + /// + /// A wrapper for ReadMemory which inserts CDL logic + /// + private byte ReadMemory_CDL(ushort address) + { + RunCDL(address, CDLog_Flags.Data); + return L.ReadMemory(address); + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IDebuggable.cs new file mode 100644 index 0000000000..559381bead --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IDebuggable.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + public partial class GGHawkLink : IDebuggable + { + public IDictionary GetCpuFlagsAndRegisters() + { + return new Dictionary + { + ["A"] = L.Cpu.Regs[L.Cpu.A], + ["AF"] = L.Cpu.Regs[L.Cpu.F] + (L.Cpu.Regs[L.Cpu.A] << 8), + ["B"] = L.Cpu.Regs[L.Cpu.B], + ["BC"] = L.Cpu.Regs[L.Cpu.C] + (L.Cpu.Regs[L.Cpu.B] << 8), + ["C"] = L.Cpu.Regs[L.Cpu.C], + ["D"] = L.Cpu.Regs[L.Cpu.D], + ["DE"] = L.Cpu.Regs[L.Cpu.E] + (L.Cpu.Regs[L.Cpu.D] << 8), + ["E"] = L.Cpu.Regs[L.Cpu.E], + ["F"] = L.Cpu.Regs[L.Cpu.F], + ["H"] = L.Cpu.Regs[L.Cpu.H], + ["HL"] = L.Cpu.Regs[L.Cpu.L] + (L.Cpu.Regs[L.Cpu.H] << 8), + ["I"] = L.Cpu.Regs[L.Cpu.I], + ["IX"] = L.Cpu.Regs[L.Cpu.Ixl] + (L.Cpu.Regs[L.Cpu.Ixh] << 8), + ["IY"] = L.Cpu.Regs[L.Cpu.Iyl] + (L.Cpu.Regs[L.Cpu.Iyh] << 8), + ["L"] = L.Cpu.Regs[L.Cpu.L], + ["PC"] = L.Cpu.Regs[L.Cpu.PCl] + (L.Cpu.Regs[L.Cpu.PCh] << 8), + ["R"] = L.Cpu.Regs[L.Cpu.R], + ["Shadow AF"] = L.Cpu.Regs[L.Cpu.F_s] + (L.Cpu.Regs[L.Cpu.A_s] << 8), + ["Shadow BC"] = L.Cpu.Regs[L.Cpu.C_s] + (L.Cpu.Regs[L.Cpu.B_s] << 8), + ["Shadow DE"] = L.Cpu.Regs[L.Cpu.E_s] + (L.Cpu.Regs[L.Cpu.D_s] << 8), + ["Shadow HL"] = L.Cpu.Regs[L.Cpu.L_s] + (L.Cpu.Regs[L.Cpu.H_s] << 8), + ["SP"] = L.Cpu.Regs[L.Cpu.SPl] + (L.Cpu.Regs[L.Cpu.SPh] << 8), + ["Flag C"] = L.Cpu.FlagC, + ["Flag N"] = L.Cpu.FlagN, + ["Flag P/V"] = L.Cpu.FlagP, + ["Flag 3rd"] = L.Cpu.Flag3, + ["Flag H"] = L.Cpu.FlagH, + ["Flag 5th"] = L.Cpu.Flag5, + ["Flag Z"] = L.Cpu.FlagZ, + ["Flag S"] = L.Cpu.FlagS + }; + } + + public void SetCpuRegister(string register, int value) + { + switch (register) + { + default: + throw new InvalidOperationException(); + case "A": + L.Cpu.Regs[L.Cpu.A] = (ushort)value; + break; + case "AF": + L.Cpu.Regs[L.Cpu.F] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.A] = (ushort)(value & 0xFF00); + break; + case "B": + L.Cpu.Regs[L.Cpu.B] = (ushort)value; + break; + case "BC": + L.Cpu.Regs[L.Cpu.C] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.B] = (ushort)(value & 0xFF00); + break; + case "C": + L.Cpu.Regs[L.Cpu.C] = (ushort)value; + break; + case "D": + L.Cpu.Regs[L.Cpu.D] = (ushort)value; + break; + case "DE": + L.Cpu.Regs[L.Cpu.E] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.D] = (ushort)(value & 0xFF00); + break; + case "E": + L.Cpu.Regs[L.Cpu.E] = (ushort)value; + break; + case "F": + L.Cpu.Regs[L.Cpu.F] = (ushort)value; + break; + case "H": + L.Cpu.Regs[L.Cpu.H] = (ushort)value; + break; + case "HL": + L.Cpu.Regs[L.Cpu.L] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.H] = (ushort)(value & 0xFF00); + break; + case "I": + L.Cpu.Regs[L.Cpu.I] = (ushort)value; + break; + case "IX": + L.Cpu.Regs[L.Cpu.Ixl] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.Ixh] = (ushort)(value & 0xFF00); + break; + case "IY": + L.Cpu.Regs[L.Cpu.Iyl] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.Iyh] = (ushort)(value & 0xFF00); + break; + case "L": + L.Cpu.Regs[L.Cpu.L] = (ushort)value; + break; + case "PC": + L.Cpu.Regs[L.Cpu.PCl] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.PCh] = (ushort)(value & 0xFF00); + break; + case "R": + L.Cpu.Regs[L.Cpu.R] = (ushort)value; + break; + case "Shadow AF": + L.Cpu.Regs[L.Cpu.F_s] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.A_s] = (ushort)(value & 0xFF00); + break; + case "Shadow BC": + L.Cpu.Regs[L.Cpu.C_s] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.B_s] = (ushort)(value & 0xFF00); + break; + case "Shadow DE": + L.Cpu.Regs[L.Cpu.E_s] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.D_s] = (ushort)(value & 0xFF00); + break; + case "Shadow HL": + L.Cpu.Regs[L.Cpu.L_s] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.H_s] = (ushort)(value & 0xFF00); + break; + case "SP": + L.Cpu.Regs[L.Cpu.SPl] = (ushort)(value & 0xFF); + L.Cpu.Regs[L.Cpu.SPh] = (ushort)(value & 0xFF00); + break; + } + } + + public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); + + public bool CanStep(StepType type) + { + return false; + } + + [FeatureNotImplemented] + public void Step(StepType type) + { + throw new NotImplementedException(); + } + + public long TotalExecutedCycles + { + get { return (long)L.Cpu.TotalExecutedCycles; } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs new file mode 100644 index 0000000000..54f009a9b3 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs @@ -0,0 +1,291 @@ +using System; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + public partial class GGHawkLink : IEmulator, IVideoProvider, ISoundProvider + { + public IEmulatorServiceProvider ServiceProvider { get; } + + public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; + + public bool FrameAdvance(IController controller, bool render, bool rendersound) + { + //Console.WriteLine("-----------------------FRAME-----------------------"); + if (_tracer.Enabled) + { + L.Cpu.TraceCallback = s => _tracer.Put(s); + } + else + { + L.Cpu.TraceCallback = null; + } + + _frame++; + + if (controller.IsPressed("Power")) + { + HardReset(); + } + + bool cablediscosignalNew = controller.IsPressed("Toggle Cable"); + if (cablediscosignalNew && !_cablediscosignal) + { + _cableconnected ^= true; + Console.WriteLine("Cable connect status to {0}", _cableconnected); + } + + _cablediscosignal = cablediscosignalNew; + + _islag = true; + + GetControllerState(controller); + + do_frame(controller, render, rendersound); + + _islag = L._isLag; + + if (_islag) + { + _lagcount++; + } + + return true; + } + + public void do_frame(IController controller, bool render, bool rendersound) + { + L.start_pressed = controller.IsPressed("P1 Start"); + R.start_pressed = controller.IsPressed("P2 Start"); + + L.FrameAdvancePrep(); + R.FrameAdvancePrep(); + + int scanlinesPerFrame = 262; + + L.Vdp.ScanLine = 0; + R.Vdp.ScanLine = 0; + + for (int S = 0; S < scanlinesPerFrame; S++) + { + L.Vdp.RenderCurrentScanline(render); + R.Vdp.RenderCurrentScanline(render); + + L.Vdp.ProcessFrameInterrupt(); + R.Vdp.ProcessFrameInterrupt(); + + L.Vdp.ProcessLineInterrupt(); + R.Vdp.ProcessLineInterrupt(); + + // 512 cycles per line + for (int j = 0; j < 228; j++) + { + L.Cpu.ExecuteOne(); + R.Cpu.ExecuteOne(); + + /* + * + * Linking code goes here + * + */ + + L.PSG.generate_sound(); + R.PSG.generate_sound(); + + int s_L = L.PSG.current_sample_L; + int s_R = L.PSG.current_sample_R; + + if (s_L != L.old_s_L) + { + L.blip_L.AddDelta(L.sampleclock, s_L - L.old_s_L); + L.old_s_L = s_L; + } + + if (s_R != L.old_s_R) + { + L.blip_R.AddDelta(L.sampleclock, s_R - L.old_s_R); + L.old_s_R = s_R; + } + + L.sampleclock++; + + s_L = R.PSG.current_sample_L; + s_R = R.PSG.current_sample_R; + + if (s_L != R.old_s_L) + { + R.blip_L.AddDelta(R.sampleclock, s_L - R.old_s_L); + R.old_s_L = s_L; + } + + if (s_R != R.old_s_R) + { + R.blip_R.AddDelta(R.sampleclock, s_R - R.old_s_R); + R.old_s_R = s_R; + } + + R.sampleclock++; + } + + if (S == scanlinesPerFrame - 1) + { + L.Vdp.ProcessGGScreen(); + R.Vdp.ProcessGGScreen(); + + L.Vdp.ProcessOverscan(); + R.Vdp.ProcessOverscan(); + } + + L.Vdp.ScanLine++; + R.Vdp.ScanLine++; + } + + L.FrameAdvancePost(); + R.FrameAdvancePost(); + + buff_L = L.Vdp.GetVideoBuffer(); + buff_R = R.Vdp.GetVideoBuffer(); + + FillVideoBuffer(); + } + + public void GetControllerState(IController controller) + { + InputCallbacks.Call(); + L.cntr_rd_0 = (byte)(controller.IsPressed("P1 Start") ? 0x7F : 0xFF); + L.cntr_rd_1 = _controllerDeck.ReadPort1(controller); + L.cntr_rd_2 = 0xFF; + R.cntr_rd_0 = (byte)(controller.IsPressed("P2 Start") ? 0x7F : 0xFF); + R.cntr_rd_1 = _controllerDeck.ReadPort2(controller); + R.cntr_rd_2 = 0xFF; + } + + public int Frame => _frame; + + public string SystemId => "GGL"; + + public bool DeterministicEmulation { get; set; } + + public void ResetCounters() + { + _frame = 0; + _lagcount = 0; + _islag = false; + } + + public CoreComm CoreComm { get; } + + public void Dispose() + { + L.Dispose(); + R.Dispose(); + } + + #region Video provider + + public int _frameHz = 60; + + public int[] _vidbuffer = new int[160 * 2 * 144]; + public int[] buff_L = new int[160 * 144]; + public int[] buff_R = new int[160 * 144]; + + public int[] GetVideoBuffer() + { + return _vidbuffer; + } + + public void FillVideoBuffer() + { + // combine the 2 video buffers from the instances + for (int i = 0; i < 144; i++) + { + for (int j = 0; j < 160; j++) + { + _vidbuffer[i * 320 + j] = buff_L[i * 160 + j]; + _vidbuffer[i * 320 + j + 160] = buff_R[i * 160 + j]; + } + } + } + + public int VirtualWidth => 160 * 2; + public int VirtualHeight => 144; + public int BufferWidth => 160 * 2; + public int BufferHeight => 144; + public int BackgroundColor => unchecked((int)0xFF000000); + public int VsyncNumerator => _frameHz; + public int VsyncDenominator => 1; + + public static readonly uint[] color_palette_BW = { 0xFFFFFFFF , 0xFFAAAAAA, 0xFF555555, 0xFF000000 }; + public static readonly uint[] color_palette_Gr = { 0xFFA4C505, 0xFF88A905, 0xFF1D551D, 0xFF052505 }; + + public uint[] color_palette = new uint[4]; + + #endregion + + #region audio + + public bool CanProvideAsync => false; + + public void SetSyncMode(SyncSoundMode mode) + { + if (mode != SyncSoundMode.Sync) + { + throw new InvalidOperationException("Only Sync mode is supported_"); + } + } + + public SyncSoundMode SyncMode => SyncSoundMode.Sync; + + public void GetSamplesSync(out short[] samples, out int nsamp) + { + short[] temp_samp_L = new short[735 * 2]; + short[] temp_samp_R = new short[735 * 2]; + + int nsamp_L = 735; + int nsamp_R = 735; + + L.GetSamplesSync(out temp_samp_L, out nsamp_L); + R.GetSamplesSync(out temp_samp_R, out nsamp_L); + + if (linkSettings.AudioSet == GGLinkSettings.AudioSrc.Left) + { + samples = temp_samp_L; + nsamp = nsamp_L; + } + else if (linkSettings.AudioSet == GGLinkSettings.AudioSrc.Right) + { + samples = temp_samp_R; + nsamp = nsamp_R; + } + else + { + samples = new short[0]; + nsamp = 0; + } + } + + public void GetSamplesAsync(short[] samples) + { + throw new NotSupportedException("Async is not available"); + } + + public void DiscardSamples() + { + L.DiscardSamples(); + R.DiscardSamples(); + } + + private void GetSamples(short[] samples) + { + + } + + public void DisposeSound() + { + + } + + #endregion + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IInputPollable.cs new file mode 100644 index 0000000000..3a180561c8 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IInputPollable.cs @@ -0,0 +1,24 @@ +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + public partial class GGHawkLink : IInputPollable + { + public int LagCount + { + get { return _lagcount; } + set { _lagcount = value; } + } + + public bool IsLagFrame + { + get { return _islag; } + set { _islag = value; } + } + + public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); + + public bool _islag = true; + private int _lagcount; + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs new file mode 100644 index 0000000000..9c2f9977c8 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs @@ -0,0 +1,114 @@ +using System; + +using System.Collections.Generic; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + public partial class GGHawkLink + { + private IMemoryDomains MemoryDomains; + + public void SetupMemoryDomains() + { + var domains = new List + { + new MemoryDomainDelegate( + "Main RAM L", + L.SystemRam.Length, + MemoryDomain.Endian.Little, + addr => L.SystemRam[addr], + (addr, value) => L.SystemRam[addr] = value, + 1), + new MemoryDomainDelegate( + "Main RAM R", + R.SystemRam.Length, + MemoryDomain.Endian.Little, + addr => R.SystemRam[addr], + (addr, value) => R.SystemRam[addr] = value, + 1), + new MemoryDomainDelegate( + "System Bus L", + 0X10000, + MemoryDomain.Endian.Little, + addr => PeekSystemBusL(addr), + (addr, value) => PokeSystemBusL(addr, value), + 1), + new MemoryDomainDelegate( + "System Bus R", + 0X10000, + MemoryDomain.Endian.Little, + addr => PeekSystemBusR(addr), + (addr, value) => PokeSystemBusR(addr, value), + 1), + new MemoryDomainDelegate( + "ROM L", + L.RomData.Length, + MemoryDomain.Endian.Little, + addr => L.RomData[addr], + (addr, value) => L.RomData[addr] = value, + 1), + new MemoryDomainDelegate( + "ROM R", + R.RomData.Length, + MemoryDomain.Endian.Little, + addr => R.RomData[addr], + (addr, value) => R.RomData[addr] = value, + 1), + new MemoryDomainDelegate( + "VRAM L", + L.Vdp.VRAM.Length, + MemoryDomain.Endian.Little, + addr => L.Vdp.VRAM[addr], + (addr, value) => L.Vdp.VRAM[addr] = value, + 1), + new MemoryDomainDelegate( + "VRAM R", + R.Vdp.VRAM.Length, + MemoryDomain.Endian.Little, + addr => R.Vdp.VRAM[addr], + (addr, value) => R.Vdp.VRAM[addr] = value, + 1) + }; + + if (L.SaveRAM != null) + { + var CartRamL = new MemoryDomainByteArray("Cart RAM L", MemoryDomain.Endian.Little, L.SaveRAM, true, 1); + domains.Add(CartRamL); + } + + if (R.SaveRAM != null) + { + var CartRamR = new MemoryDomainByteArray("Cart RAM R", MemoryDomain.Endian.Little, R.SaveRAM, true, 1); + domains.Add(CartRamR); + } + + MemoryDomains = new MemoryDomainList(domains); + (ServiceProvider as BasicServiceProvider).Register(MemoryDomains); + } + + private byte PeekSystemBusL(long addr) + { + ushort addr2 = (ushort)(addr & 0xFFFF); + return L.ReadMemory(addr2); + } + + private byte PeekSystemBusR(long addr) + { + ushort addr2 = (ushort)(addr & 0xFFFF); + return R.ReadMemory(addr2); + } + + private void PokeSystemBusL(long addr, byte value) + { + ushort addr2 = (ushort)(addr & 0xFFFF); + L.WriteMemory(addr2, value); + } + + private void PokeSystemBusR(long addr, byte value) + { + ushort addr2 = (ushort)(addr & 0xFFFF); + R.WriteMemory(addr2, value); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISaveRam.cs new file mode 100644 index 0000000000..335b273e86 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISaveRam.cs @@ -0,0 +1,81 @@ +using System; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + public partial class GGHawkLink : ISaveRam + { + public byte[] CloneSaveRam() + { + if ((L.SaveRAM != null) || (R.SaveRAM != null)) + { + int Len1 = 0; + int Len2 = 0; + int index = 0; + + if (L.SaveRAM != null) + { + Len1 = L.SaveRAM.Length; + } + + if (R.SaveRAM != null) + { + Len2 = R.SaveRAM.Length; + } + + byte[] temp = new byte[Len1 + Len2]; + + if (L.SaveRAM != null) + { + for (int i = 0; i < L.SaveRAM.Length; i++) + { + temp[index] = L.SaveRAM[i]; + index++; + } + } + + if (R.SaveRAM != null) + { + for (int i = 0; i < L.SaveRAM.Length; i++) + { + temp[index] = R.SaveRAM[i]; + index++; + } + } + + return temp; + } + else + { + return null; + } + } + + public void StoreSaveRam(byte[] data) + { + if ((L.SaveRAM != null) && (R.SaveRAM == null)) + { + Buffer.BlockCopy(data, 0, L.SaveRAM, 0, L.SaveRAM.Length); + } + else if ((R.SaveRAM != null) && (L.SaveRAM == null)) + { + Buffer.BlockCopy(data, 0, R.SaveRAM, 0, R.SaveRAM.Length); + } + else if ((R.SaveRAM != null) && (L.SaveRAM != null)) + { + Buffer.BlockCopy(data, 0, L.SaveRAM, 0, L.SaveRAM.Length); + Buffer.BlockCopy(data, L.SaveRAM.Length, R.SaveRAM, 0, R.SaveRAM.Length); + } + + Console.WriteLine("loading SRAM here"); + } + + public bool SaveRamModified + { + get + { + return linkSyncSettings.Use_SRAM; + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISettable.cs new file mode 100644 index 0000000000..2c5f5d8612 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISettable.cs @@ -0,0 +1,78 @@ +using System; +using System.ComponentModel; + +using Newtonsoft.Json; + +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + public partial class GGHawkLink : IEmulator, IStatable, ISettable + { + public GGLinkSettings GetSettings() + { + return linkSettings.Clone(); + } + + public GGLinkSyncSettings GetSyncSettings() + { + return linkSyncSettings.Clone(); + } + + public bool PutSettings(GGLinkSettings o) + { + linkSettings = o; + return false; + } + + public bool PutSyncSettings(GGLinkSyncSettings o) + { + bool ret = GGLinkSyncSettings.NeedsReboot(linkSyncSettings, o); + linkSyncSettings = o; + return ret; + } + + private GGLinkSettings linkSettings = new GGLinkSettings(); + public GGLinkSyncSettings linkSyncSettings = new GGLinkSyncSettings(); + + public class GGLinkSettings + { + public enum AudioSrc + { + Left, + Right, + Both + } + + [DisplayName("Audio Selection")] + [Description("Choose Audio Source. Both will produce Stereo sound.")] + [DefaultValue(AudioSrc.Left)] + public AudioSrc AudioSet { get; set; } + + public GGLinkSettings Clone() + { + return (GGLinkSettings)MemberwiseClone(); + } + } + + public class GGLinkSyncSettings + { + + [DisplayName("Use Existing SaveRAM")] + [Description("When true, existing SaveRAM will be loaded at boot up")] + [DefaultValue(false)] + public bool Use_SRAM { get; set; } + + public GGLinkSyncSettings Clone() + { + return (GGLinkSyncSettings)MemberwiseClone(); + } + + public static bool NeedsReboot(GGLinkSyncSettings x, GGLinkSyncSettings y) + { + return !DeepEquality.DeepEquals(x, y); + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IStatable.cs new file mode 100644 index 0000000000..5da5d644d7 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IStatable.cs @@ -0,0 +1,65 @@ +using System.IO; +using Newtonsoft.Json; + +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + public partial class GGHawkLink : IStatable + { + public bool BinarySaveStatesPreferred => true; + + public void SaveStateText(TextWriter writer) + { + L.SaveStateText(writer); + R.SaveStateText(writer); + SyncState(new Serializer(writer)); + } + + public void LoadStateText(TextReader reader) + { + L.LoadStateText(reader); + R.LoadStateText(reader); + SyncState(new Serializer(reader)); + } + + public void SaveStateBinary(BinaryWriter bw) + { + L.SaveStateBinary(bw); + R.SaveStateBinary(bw); + // other variables + SyncState(new Serializer(bw)); + } + + public void LoadStateBinary(BinaryReader br) + { + L.LoadStateBinary(br); + R.LoadStateBinary(br); + // other variables + SyncState(new Serializer(br)); + } + + public byte[] SaveStateBinary() + { + MemoryStream ms = new MemoryStream(); + BinaryWriter bw = new BinaryWriter(ms); + SaveStateBinary(bw); + bw.Flush(); + return ms.ToArray(); + } + + //private JsonSerializer ser = new JsonSerializer { Formatting = Formatting.Indented }; + + private void SyncState(Serializer ser) + { + ser.Sync("Lag", ref _lagcount); + ser.Sync("Frame", ref _frame); + ser.Sync("IsLag", ref _islag); + ser.Sync(nameof(_cableconnected), ref _cableconnected); + ser.Sync(nameof(_cablediscosignal), ref _cablediscosignal); + ser.Sync(nameof(do_r_next), ref do_r_next); + _controllerDeck.SyncState(ser); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs new file mode 100644 index 0000000000..1401820939 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.cs @@ -0,0 +1,96 @@ +using System; + +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Components.Z80A; + +using BizHawk.Emulation.Cores.Sega.MasterSystem; +using System.Runtime.InteropServices; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + [Core( + "GGHawkLink", + "", + isPorted: false, + isReleased: false)] + [ServiceNotApplicable(typeof(IDriveLight))] + public partial class GGHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable, + ISettable + { + // we want to create two GG instances that we will run concurrently + public SMS L; + public SMS R; + + // if true, the link cable is currently connected + private bool _cableconnected = true; + + // if true, the link cable toggle signal is currently asserted + private bool _cablediscosignal = false; + + private bool do_r_next = false; + + public GGHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) + { + var ser = new BasicServiceProvider(this); + + linkSettings = (GGLinkSettings)settings ?? new GGLinkSettings(); + linkSyncSettings = (GGLinkSyncSettings)syncSettings ?? new GGLinkSyncSettings(); + _controllerDeck = new GGHawkLinkControllerDeck(GGHawkLinkControllerDeck.DefaultControllerName, GGHawkLinkControllerDeck.DefaultControllerName); + + CoreComm = comm; + + var temp_set_L = new SMS.SMSSettings(); + var temp_set_R = new SMS.SMSSettings(); + + var temp_sync_L = new SMS.SMSSyncSettings(); + var temp_sync_R = new SMS.SMSSyncSettings(); + + L = new SMS(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, + game_L, rom_L, temp_set_L, temp_sync_L); + + R = new SMS(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, + game_R, rom_R, temp_set_R, temp_sync_R); + + ser.Register(this); + ser.Register(this); + + _tracer = new TraceBuffer { Header = L.Cpu.TraceHeader }; + ser.Register(_tracer); + + ServiceProvider = ser; + + SetupMemoryDomains(); + + HardReset(); + + L.stand_alone = false; + R.stand_alone = false; + } + + public void HardReset() + { + L.HardReset(); + R.HardReset(); + } + + public DisplayType Region => DisplayType.NTSC; + + public int _frame = 0; + + private readonly GGHawkLinkControllerDeck _controllerDeck; + + private readonly ITraceable _tracer; + + public bool LinkConnected + { + get { return _cableconnected; } + set { _cableconnected = value; } + } + + private void ExecFetch(ushort addr) + { + MemoryCallbacks.CallExecutes(addr, "System Bus"); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllerDeck.cs new file mode 100644 index 0000000000..82cfed4c06 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllerDeck.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using BizHawk.Common; +using BizHawk.Common.ReflectionExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + public class GGHawkLinkControllerDeck + { + public GGHawkLinkControllerDeck(string controller1Name, string controller2Name) + { + if (!ValidControllerTypes.ContainsKey(controller1Name)) + { + throw new InvalidOperationException("Invalid controller type: " + controller1Name); + } + + if (!ValidControllerTypes.ContainsKey(controller2Name)) + { + throw new InvalidOperationException("Invalid controller type: " + controller2Name); + } + + Port1 = (IPort)Activator.CreateInstance(ValidControllerTypes[controller1Name], 1); + Port2 = (IPort)Activator.CreateInstance(ValidControllerTypes[controller2Name], 2); + + Definition = new ControllerDefinition + { + Name = Port1.Definition.Name, + BoolButtons = Port1.Definition.BoolButtons + .Concat(Port2.Definition.BoolButtons) + .Concat(new[] { "Toggle Cable" } ) + .ToList() + }; + } + + public byte ReadPort1(IController c) + { + return Port1.Read(c); + } + + public byte ReadPort2(IController c) + { + return Port2.Read(c); + } + + public ControllerDefinition Definition { get; } + + public void SyncState(Serializer ser) + { + ser.BeginSection(nameof(Port1)); + Port1.SyncState(ser); + ser.EndSection(); + + ser.BeginSection(nameof(Port2)); + Port2.SyncState(ser); + ser.EndSection(); + } + + private readonly IPort Port1; + private readonly IPort Port2; + + private static Dictionary _controllerTypes; + + public static Dictionary ValidControllerTypes + { + get + { + if (_controllerTypes == null) + { + _controllerTypes = typeof(GGHawkLinkControllerDeck).Assembly + .GetTypes() + .Where(t => typeof(IPort).IsAssignableFrom(t)) + .Where(t => !t.IsAbstract && !t.IsInterface) + .ToDictionary(tkey => tkey.DisplayName()); + } + + return _controllerTypes; + } + } + + public static string DefaultControllerName => typeof(StandardControls).DisplayName(); + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs new file mode 100644 index 0000000000..7c1bc51e16 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs @@ -0,0 +1,85 @@ +using System; +using System.ComponentModel; +using System.Linq; + +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Sega.GGHawkLink +{ + /// + /// Represents a GG add on + /// + public interface IPort + { + byte Read(IController c); + + ControllerDefinition Definition { get; } + + void SyncState(Serializer ser); + + int PortNum { get; } + } + + [DisplayName("Game Gear Controller")] + public class StandardControls : IPort + { + public StandardControls(int portNum) + { + PortNum = portNum; + Definition = new ControllerDefinition + { + Name = "GG Controller", + BoolButtons = BaseDefinition + .Select(b => "P" + PortNum + " " + b) + .ToList() + }; + } + + public int PortNum { get; } + + public ControllerDefinition Definition { get; } + + public byte Read(IController c) + { + byte result = 0xFF; + + if (c.IsPressed(Definition.BoolButtons[0])) + { + result &= 0xFE; + } + if (c.IsPressed(Definition.BoolButtons[1])) + { + result &= 0xFD; + } + if (c.IsPressed(Definition.BoolButtons[2])) + { + result &= 0xFB; + } + if (c.IsPressed(Definition.BoolButtons[3])) + { + result &= 0xF7; + } + if (c.IsPressed(Definition.BoolButtons[4])) + { + result &= 0xEF; + } + if (c.IsPressed(Definition.BoolButtons[5])) + { + result &= 0xDF; + } + + return result; + } + + private static readonly string[] BaseDefinition = + { + "Up", "Down", "Left", "Right", "B1", "B2", "Start" + }; + + public void SyncState(Serializer ser) + { + //nothing + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/ReadMe.txt b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/ReadMe.txt new file mode 100644 index 0000000000..bc60bf4b01 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/ReadMe.txt @@ -0,0 +1 @@ +TODO: diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/EEPROM.93c46.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/EEPROM.93c46.cs index ec0acddec1..6f9281da46 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/EEPROM.93c46.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/EEPROM.93c46.cs @@ -219,14 +219,14 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public void SyncState(Serializer ser) { ser.BeginSection("93c46"); - ser.Sync("Address", ref Address); - ser.Sync("Value", ref Value); - ser.Sync("BitsWritten", ref BitsWritten); - ser.Sync("BitsRead", ref BitsRead); - ser.Sync("WriteEnable", ref WriteEnable); - ser.SyncEnum("WriteMode", ref WriteMode); - ser.SyncEnum("ReadMode", ref ReadMode); - ser.SyncEnum("Flags", ref Flags); + ser.Sync(nameof(Address), ref Address); + ser.Sync(nameof(Value), ref Value); + ser.Sync(nameof(BitsWritten), ref BitsWritten); + ser.Sync(nameof(BitsRead), ref BitsRead); + ser.Sync(nameof(WriteEnable), ref WriteEnable); + ser.SyncEnum(nameof(WriteMode), ref WriteMode); + ser.SyncEnum(nameof(ReadMode), ref ReadMode); + ser.SyncEnum(nameof(Flags), ref Flags); ser.EndSection(); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ICodeDataLogger.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ICodeDataLogger.cs index 199cfef58c..14c9616b4c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ICodeDataLogger.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ICodeDataLogger.cs @@ -4,7 +4,7 @@ using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Sega.MasterSystem { - public sealed partial class SMS : ICodeDataLogger + public partial class SMS : ICodeDataLogger { public void SetCDL(ICodeDataLog cdl) { @@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } - private enum CDLog_AddrType + public enum CDLog_AddrType { None, ROM, @@ -58,24 +58,24 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } [Flags] - private enum CDLog_Flags + public enum CDLog_Flags { ExecFirst = 0x01, ExecOperand = 0x02, Data = 0x04 }; - private struct CDLog_MapResults + public struct CDLog_MapResults { public CDLog_AddrType Type; public int Address; } - private delegate CDLog_MapResults MapMemoryDelegate(ushort addr, bool write); - private MapMemoryDelegate MapMemory; - private ICodeDataLog CDL; + public delegate CDLog_MapResults MapMemoryDelegate(ushort addr, bool write); + public MapMemoryDelegate MapMemory; + public ICodeDataLog CDL; - private void RunCDL(ushort address, CDLog_Flags flags) + public void RunCDL(ushort address, CDLog_Flags flags) { if (MapMemory != null) { @@ -94,19 +94,19 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem /// /// A wrapper for FetchMemory which inserts CDL logic /// - private byte FetchMemory_CDL(ushort address) + public byte FetchMemory_CDL(ushort address) { RunCDL(address, CDLog_Flags.ExecFirst); - return ReadMemory(address); + return FetchMemory(address); } /// /// A wrapper for ReadMemory which inserts CDL logic /// - private byte ReadMemory_CDL(ushort address) + public byte ReadMemory_CDL(ushort address) { RunCDL(address, CDLog_Flags.Data); return ReadMemory(address); } } -} \ No newline at end of file +} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IDebuggable.cs index 2f142e92da..753c9eb7d8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IDebuggable.cs @@ -1,12 +1,11 @@ using System; using System.Collections.Generic; -using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Sega.MasterSystem { - public sealed partial class SMS : IDebuggable + public partial class SMS : IDebuggable { public IDictionary GetCpuFlagsAndRegisters() { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs index 1ac7e86924..e3578436d4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs @@ -1,8 +1,9 @@ using BizHawk.Emulation.Common; +using System; namespace BizHawk.Emulation.Cores.Sega.MasterSystem { - public sealed partial class SMS : IEmulator + public partial class SMS : IEmulator, ISoundProvider { public IEmulatorServiceProvider ServiceProvider { get; } @@ -37,16 +38,18 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } } - public void FrameAdvance(IController controller, bool render, bool rendersound) + // not savestated variables + int s_L, s_R; + + public bool FrameAdvance(IController controller, bool render, bool rendersound) { _controller = controller; _lagged = true; _frame++; - PSG.BeginFrame(Cpu.TotalExecutedCycles); if (!IsGameGear) { - PSG.StereoPanning = Settings.ForceStereoSeparation ? ForceStereoByte : (byte)0xFF; + PSG.Set_Panning(Settings.ForceStereoSeparation ? ForceStereoByte : (byte)0xFF); } if (Tracer.Enabled) @@ -69,14 +72,80 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem if (IsGame3D && Settings.Fix3D) { - Vdp.ExecFrame((Frame & 1) == 0); + render = ((Frame & 1) == 0) & render; + } + + int scanlinesPerFrame = Vdp.DisplayType == DisplayType.NTSC ? 262 : 313; + Vdp.SpriteLimit = Settings.SpriteLimit; + for (int i = 0; i < scanlinesPerFrame; i++) + { + Vdp.ScanLine = i; + + Vdp.RenderCurrentScanline(render); + + Vdp.ProcessFrameInterrupt(); + Vdp.ProcessLineInterrupt(); + ProcessLineControls(); + + for (int j = 0; j < Vdp.IPeriod; j++) + { + Cpu.ExecuteOne(); + + PSG.generate_sound(); + + s_L = PSG.current_sample_L; + s_R = PSG.current_sample_R; + + if (s_L != old_s_L) + { + blip_L.AddDelta(sampleclock, s_L - old_s_L); + old_s_L = s_L; + } + + if (s_R != old_s_R) + { + blip_R.AddDelta(sampleclock, s_R - old_s_R); + old_s_R = s_R; + } + + sampleclock++; + } + + if (Vdp.ScanLine == scanlinesPerFrame - 1) + { + Vdp.ProcessGGScreen(); + Vdp.ProcessOverscan(); + } + } + + if (_lagged) + { + _lagCount++; + _isLag = true; } else { - Vdp.ExecFrame(render); + _isLag = false; } - PSG.EndFrame(Cpu.TotalExecutedCycles); + return true; + } + + // Used for GG linked play + public void FrameAdvancePrep() + { + _lagged = true; + _frame++; + + if (!IsGameGear && IsGameGear_C) + { + Cpu.NonMaskableInterrupt = start_pressed; + } + } + + // Used for GG linked play + public void FrameAdvancePost() + { if (_lagged) { _lagCount++; @@ -88,7 +157,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } } - public int Frame => _frame; + public int Frame => _frame; public string SystemId => "SMS"; @@ -105,6 +174,98 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public void Dispose() { + if (blip_L != null) + { + blip_L.Dispose(); + blip_L = null; + } + + if (blip_R != null) + { + blip_R.Dispose(); + blip_R = null; + } } + + #region Audio + + public BlipBuffer blip_L = new BlipBuffer(4096); + public BlipBuffer blip_R = new BlipBuffer(4096); + const int blipbuffsize = 4096; + + public uint sampleclock; + public int old_s_L = 0; + public int old_s_R = 0; + + public bool CanProvideAsync { get { return false; } } + + public void SetSyncMode(SyncSoundMode mode) + { + if (mode != SyncSoundMode.Sync) + { + throw new NotSupportedException("Only sync mode is supported"); + } + } + + public void GetSamplesAsync(short[] samples) + { + throw new NotSupportedException("Async not supported"); + } + + public SyncSoundMode SyncMode + { + get { return SyncSoundMode.Sync; } + } + + public void GetSamplesSync(out short[] samples, out int nsamp) + { + if (!disablePSG) + { + blip_L.EndFrame(sampleclock); + blip_R.EndFrame(sampleclock); + + nsamp = Math.Max(Math.Max(blip_L.SamplesAvailable(), blip_R.SamplesAvailable()), 1); + samples = new short[nsamp * 2]; + + blip_L.ReadSamplesLeft(samples, nsamp); + blip_R.ReadSamplesRight(samples, nsamp); + + ApplyYMAudio(samples); + } + else + { + nsamp = 735; + samples = new short[nsamp * 2]; + ApplyYMAudio(samples); + } + + sampleclock = 0; + } + + public void DiscardSamples() + { + blip_L.Clear(); + blip_R.Clear(); + sampleclock = 0; + } + + public void ApplyYMAudio(short[] samples) + { + if (HasYM2413) + { + short[] fmsamples = new short[samples.Length]; + YM2413.GetSamples(fmsamples); + //naive mixing. need to study more + int len = samples.Length; + for (int i = 0; i < len; i++) + { + short fmsamp = fmsamples[i]; + samples[i] = (short)(samples[i] + fmsamp); + } + } + } + + #endregion + } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IInputPollable.cs index 82a3e637d8..c5568fa7ea 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IInputPollable.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem { - public sealed partial class SMS : IInputPollable + public partial class SMS : IInputPollable { public int LagCount { @@ -18,8 +18,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public IInputCallbackSystem InputCallbacks { get; private set; } - private int _lagCount = 0; - private bool _lagged = true; - private bool _isLag = false; + public int _lagCount = 0; + public bool _lagged = true; + public bool _isLag = false; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IMemoryDomains.cs index a19dadae35..fd5c606af8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IMemoryDomains.cs @@ -6,7 +6,7 @@ using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Sega.MasterSystem { - public sealed partial class SMS + public partial class SMS { private MemoryDomainList MemoryDomains; private readonly Dictionary _byteArrayDomains = new Dictionary(); @@ -61,7 +61,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem if (ExtRam != null) { - SyncByteArrayDomain("Cart (Volatile) RAM", Vdp.VRAM); + SyncByteArrayDomain("Cart (Volatile) RAM", ExtRam); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISaveRam.cs index 9e88f186c7..be49228c80 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISaveRam.cs @@ -4,7 +4,7 @@ using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Sega.MasterSystem { - public sealed partial class SMS : ISaveRam + public partial class SMS : ISaveRam { public byte[] CloneSaveRam() { @@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public bool SaveRamModified { get; private set; } - private byte[] SaveRAM; + public byte[] SaveRAM; private byte SaveRamBank; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISettable.cs index 4a45ac0e7a..fc24b04854 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISettable.cs @@ -2,7 +2,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem { - public sealed partial class SMS : ISettable + public partial class SMS : ISettable { public SMSSettings GetSettings() { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISoundProvider.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISoundProvider.cs deleted file mode 100644 index fd44ce7fe5..0000000000 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISoundProvider.cs +++ /dev/null @@ -1,12 +0,0 @@ -using BizHawk.Emulation.Cores.Components; - -namespace BizHawk.Emulation.Cores.Sega.MasterSystem -{ - // Sound refactor TODO: Implement ISoundProvider without the need for FakeSyncSound - public sealed partial class SMS - { - private FakeSyncSound _fakeSyncSound; - private IAsyncSoundProvider ActiveSoundProvider; - private SoundMixer SoundMixer; - } -} diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IStatable.cs index f2b241bd3a..ac07eeac62 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IStatable.cs @@ -6,7 +6,7 @@ using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Sega.MasterSystem { - public sealed partial class SMS : IStatable + public partial class SMS : IStatable { public bool BinarySaveStatesPreferred { @@ -53,30 +53,39 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } Cpu.SyncState(ser); - ser.BeginSection("SMS"); + ser.BeginSection(nameof(SMS)); Vdp.SyncState(ser); PSG.SyncState(ser); ser.Sync("RAM", ref SystemRam, false); - ser.Sync("RomBank0", ref RomBank0); - ser.Sync("RomBank1", ref RomBank1); - ser.Sync("RomBank2", ref RomBank2); - ser.Sync("RomBank3", ref RomBank3); - ser.Sync("Bios_bank", ref Bios_bank); - ser.Sync("Port01", ref Port01); - ser.Sync("Port02", ref Port02); - ser.Sync("Port05", ref Port05); - ser.Sync("Port3E", ref Port3E); - ser.Sync("Port3F", ref Port3F); - ser.Sync("Controller1SelectHigh", ref Controller1SelectHigh); - ser.Sync("ControllerSelect2High", ref Controller2SelectHigh); - ser.Sync("LatchLightPhaser", ref LatchLightPhaser); + ser.Sync(nameof(RomBank0), ref RomBank0); + ser.Sync(nameof(RomBank1), ref RomBank1); + ser.Sync(nameof(RomBank2), ref RomBank2); + ser.Sync(nameof(RomBank3), ref RomBank3); + ser.Sync(nameof(Bios_bank), ref Bios_bank); + ser.Sync(nameof(Port01), ref Port01); + ser.Sync(nameof(Port02), ref Port02); + ser.Sync(nameof(Port05), ref Port05); + ser.Sync(nameof(Port3E), ref Port3E); + ser.Sync(nameof(Port3F), ref Port3F); + ser.Sync(nameof(Controller1SelectHigh), ref Controller1SelectHigh); + ser.Sync(nameof(Controller2SelectHigh), ref Controller2SelectHigh); + ser.Sync(nameof(LatchLightPhaser), ref LatchLightPhaser); + ser.Sync(nameof(start_pressed), ref start_pressed); + ser.Sync(nameof(cntr_rd_0), ref cntr_rd_0); + ser.Sync(nameof(cntr_rd_1), ref cntr_rd_1); + ser.Sync(nameof(cntr_rd_2), ref cntr_rd_2); + ser.Sync(nameof(stand_alone), ref stand_alone); + ser.Sync(nameof(disablePSG), ref disablePSG); + ser.Sync(nameof(sampleclock), ref sampleclock); + ser.Sync(nameof(old_s_L), ref old_s_L); + ser.Sync(nameof(old_s_R), ref old_s_R); if (SaveRAM != null) { - ser.Sync("SaveRAM", ref SaveRAM, false); + ser.Sync(nameof(SaveRAM), ref SaveRAM, false); } - ser.Sync("SaveRamBank", ref SaveRamBank); + ser.Sync(nameof(SaveRamBank), ref SaveRamBank); if (ExtRam != null) { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs index 58f1a4683c..45ff29f103 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs @@ -592,6 +592,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem return 0xFF; } + _lagged = false; + byte value = 0xFF; if ((_controller.IsPressed("Pause") && !IsGameGear) || (_controller.IsPressed("P1 Start") && IsGameGear_C)) diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs index bba177d817..ba12a7c4c1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs @@ -5,7 +5,6 @@ using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.Components; using BizHawk.Emulation.Cores.Components; using BizHawk.Emulation.Cores.Components.Z80A; -using BizHawk.Common.BufferExtensions; /***************************************************** TODO: @@ -23,7 +22,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem isPorted: false, isReleased: true)] [ServiceNotApplicable(typeof(IDriveLight))] - public sealed partial class SMS : IEmulator, ISaveRam, IStatable, IInputPollable, IRegionable, + public partial class SMS : IEmulator, ISaveRam, IStatable, IInputPollable, IRegionable, IDebuggable, ISettable, ICodeDataLogger { [CoreConstructor("SMS", "SG", "GG")] @@ -93,7 +92,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem OnExecFetch = OnExecMemory }; - if (game["GG_in_SMS"]) { // skip setting the BIOS because this is a game gear game that puts the system @@ -106,17 +104,18 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem Vdp = new VDP(this, Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, Region); (ServiceProvider as BasicServiceProvider).Register(Vdp); - PSG = new SN76489(); + PSG = new SN76489sms(); YM2413 = new YM2413(); - SoundMixer = new SoundMixer(YM2413, PSG); + //SoundMixer = new SoundMixer(YM2413, PSG); if (HasYM2413 && game["WhenFMDisablePSG"]) { - SoundMixer.DisableSource(PSG); + disablePSG = true; } - ActiveSoundProvider = HasYM2413 ? (IAsyncSoundProvider)SoundMixer : PSG; - _fakeSyncSound = new FakeSyncSound(ActiveSoundProvider, 735); - (ServiceProvider as BasicServiceProvider).Register(_fakeSyncSound); + blip_L.SetRates(3579545, 44100); + blip_R.SetRates(3579545, 44100); + + (ServiceProvider as BasicServiceProvider).Register(this); SystemRam = new byte[0x2000]; @@ -146,7 +145,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem ForceStereoByte = byte.Parse(game.OptionValue("StereoByte")); } - PSG.StereoPanning = ForceStereoByte; + PSG.Set_Panning(ForceStereoByte); } if (SyncSettings.AllowOverlock && game["OverclockSafe"]) @@ -213,27 +212,33 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem Cpu.Regs[Cpu.SPh] = 0xDF; } + public void HardReset() + { + + } + // Constants private const int BankSize = 16384; // ROM - private byte[] RomData; + public byte[] RomData; private byte RomBank0, RomBank1, RomBank2, RomBank3; private byte Bios_bank; private byte RomBanks; private byte[] BiosRom; // Machine resources - private Z80A Cpu; - private byte[] SystemRam; + public Z80A Cpu; + public byte[] SystemRam; public VDP Vdp; - private SN76489 PSG; + public SN76489sms PSG; private YM2413 YM2413; public bool IsGameGear { get; set; } public bool IsGameGear_C { get; set; } public bool IsSG1000 { get; set; } private bool HasYM2413 = false; + private bool disablePSG = false; private bool PortDEEnabled = false; private IController _controller = NullController.Instance; @@ -249,10 +254,16 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem private byte ForceStereoByte = 0xAD; private bool IsGame3D = false; + // Linked Play Only + public bool start_pressed; + public byte cntr_rd_0; + public byte cntr_rd_1; + public byte cntr_rd_2; + public bool stand_alone = true; + public DisplayType Region { get; set; } - - private ITraceable Tracer { get; set; } + private readonly ITraceable Tracer; string DetermineRegion(string gameRegion) { @@ -281,21 +292,21 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem return DisplayType.NTSC; } - private byte ReadMemory(ushort addr) + public byte ReadMemory(ushort addr) { MemoryCallbacks.CallReads(addr, "System Bus"); return ReadMemoryMapper(addr); } - private void WriteMemory(ushort addr, byte value) + public void WriteMemory(ushort addr, byte value) { WriteMemoryMapper(addr, value); MemoryCallbacks.CallWrites(addr, "System Bus"); } - private byte FetchMemory(ushort addr) + public byte FetchMemory(ushort addr) { return ReadMemoryMapper(addr); } @@ -331,7 +342,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem switch (port) { - case 0x00: return ReadPort0(); + case 0x00: if (stand_alone) { return ReadPort0(); } else { _lagged = false; return cntr_rd_0; } case 0x01: return Port01; case 0x02: return Port02; case 0x03: return 0x00; @@ -359,9 +370,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem switch (port) { case 0xC0: - case 0xDC: return ReadControls1(); + case 0xDC: if (stand_alone) { return ReadControls1(); } else { _lagged = false; return cntr_rd_1; } case 0xC1: - case 0xDD: return ReadControls2(); + case 0xDD: if (stand_alone) { return ReadControls2(); } else { _lagged = false; return cntr_rd_2; } case 0xDE: return PortDEEnabled ? PortDE : (byte)0xFF; case 0xF2: return HasYM2413 ? YM2413.DetectionValue : (byte)0xFF; default: return 0xFF; @@ -378,13 +389,13 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem case 0x01: Port01 = value; break; case 0x02: Port02 = value; break; case 0x05: Port05 = value; break; - case 0x06: PSG.StereoPanning = value; break; + case 0x06: PSG.Set_Panning(value); break; case 0x3E: Port3E = value; break; case 0x3F: Port3F = value; break; } } else if (port < 0x80) // PSG - PSG.WritePsgData(value, Cpu.TotalExecutedCycles); + PSG.WriteReg(value); else if (port < 0xC0) // VDP { if ((port & 1) == 0) @@ -398,8 +409,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem else if (port == 0xF2 && HasYM2413) YM2413.DetectionValue = value; } - private string _region; - private string RegionStr + public string _region; + public string RegionStr { get { return _region; } set diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.ModeTMS.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.ModeTMS.cs index 408c9fb2f3..8b302be1c9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.ModeTMS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.ModeTMS.cs @@ -1,5 +1,4 @@ // Contains rendering functions for legacy TMS9918 modes. - using System; namespace BizHawk.Emulation.Cores.Sega.MasterSystem diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs index adccda7fd3..f528652581 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs @@ -1,18 +1,15 @@ using System; -using System.Globalization; -using System.IO; using BizHawk.Common; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components.Z80A; - namespace BizHawk.Emulation.Cores.Sega.MasterSystem { public enum VdpMode { SMS, GameGear } // Emulates the Texas Instruments TMS9918 VDP. - public sealed partial class VDP : IVideoProvider + public partial class VDP : IVideoProvider { // VDP State public byte[] VRAM = new byte[0x4000]; //16kb video RAM @@ -38,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem SMS Sms; VdpMode mode; - DisplayType DisplayType = DisplayType.NTSC; + public DisplayType DisplayType = DisplayType.NTSC; Z80A Cpu; public bool SpriteLimit; @@ -337,7 +334,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } } - void ProcessFrameInterrupt() + public void ProcessFrameInterrupt() { if (ScanLine == FrameHeight + 1) { @@ -352,7 +349,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } - void ProcessLineInterrupt() + public void ProcessLineInterrupt() { if (ScanLine <= FrameHeight) { @@ -371,35 +368,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem lineIntLinesRemaining = Registers[0x0A]; } - public void ExecFrame(bool render) - { - int scanlinesPerFrame = DisplayType == DisplayType.NTSC ? 262 : 313; - SpriteLimit = Sms.Settings.SpriteLimit; - for (ScanLine = 0; ScanLine < scanlinesPerFrame; ScanLine++) - { - RenderCurrentScanline(render); - - ProcessFrameInterrupt(); - ProcessLineInterrupt(); - Sms.ProcessLineControls(); - - //Console.Write(Cpu.cur_instr.Length); - //Console.Write(" "); - //Console.WriteLine(Cpu.instr_pntr); - for (int j = 0; j < IPeriod; j++) - { - Cpu.ExecuteOne(); - } - - - if (ScanLine == scanlinesPerFrame - 1) - { - ProcessGGScreen(); - ProcessOverscan(); - } - } - } - internal void RenderCurrentScanline(bool render) { // only mode 4 supports frameskip. deal with it @@ -429,20 +397,20 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public void SyncState(Serializer ser) { - ser.BeginSection("VDP"); - ser.Sync("StatusByte", ref StatusByte); + ser.BeginSection(nameof(VDP)); + ser.Sync(nameof(StatusByte), ref StatusByte); ser.Sync("WaitingForLatchByte", ref VdpWaitingForLatchByte); ser.Sync("Latch", ref VdpLatch); ser.Sync("ReadBuffer", ref VdpBuffer); - ser.Sync("VdpAddress", ref VdpAddress); + ser.Sync(nameof(VdpAddress), ref VdpAddress); ser.Sync("Command", ref VdpCommand); - ser.Sync("HIntPending", ref HIntPending); - ser.Sync("VIntPending", ref VIntPending); + ser.Sync(nameof(HIntPending), ref HIntPending); + ser.Sync(nameof(VIntPending), ref VIntPending); ser.Sync("LineIntLinesRemaining", ref lineIntLinesRemaining); - ser.Sync("Registers", ref Registers, false); - ser.Sync("CRAM", ref CRAM, false); - ser.Sync("VRAM", ref VRAM, false); - ser.Sync("HCounter", ref HCounter); + ser.Sync(nameof(Registers), ref Registers, false); + ser.Sync(nameof(CRAM), ref CRAM, false); + ser.Sync(nameof(VRAM), ref VRAM, false); + ser.Sync(nameof(HCounter), ref HCounter); ser.EndSection(); if (ser.IsReader) diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/FilePiping.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/FilePiping.cs index 969f7b32df..62b68db8f7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/FilePiping.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/FilePiping.cs @@ -45,7 +45,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn if (e != null) throw new InvalidOperationException("Previous attempt failed!", e); if (!s.CanWrite) - throw new ArgumentException("Stream must be readable!"); + throw new ArgumentException($"{nameof(Stream)} must be readable!"); using (var evt = new ManualResetEventSlim()) { @@ -78,7 +78,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn if (e != null) throw new InvalidOperationException("Previous attempt failed!", e); if (!s.CanRead) - throw new ArgumentException("Stream must be readable!"); + throw new ArgumentException($"{nameof(Stream)} must be readable!"); using (var evt = new ManualResetEventSlim()) { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs index e0a3ac20b1..35caf3331c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs @@ -7,51 +7,51 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { public IEmulatorServiceProvider ServiceProvider { get; private set; } - public ControllerDefinition ControllerDefinition { get; private set; } - - // TODO: use render and rendersound - public void FrameAdvance(IController controller, bool render, bool rendersound = true) + public ControllerDefinition ControllerDefinition { get; private set; } + + // TODO: use render and rendersound + public bool FrameAdvance(IController controller, bool render, bool rendersound = true) { if (controller.IsPressed("Reset")) Core.gpgx_reset(false); if (controller.IsPressed("Power")) - Core.gpgx_reset(true); - if (_cds != null) - { - var prev = controller.IsPressed("Previous Disk"); - var next = controller.IsPressed("Next Disk"); - int newDisk = _discIndex; - if (prev && !_prevDiskPressed) - newDisk--; - if (next && !_nextDiskPressed) - newDisk++; - - _prevDiskPressed = prev; - _nextDiskPressed = next; - - if (newDisk < -1) - newDisk = -1; - if (newDisk >= _cds.Length) - newDisk = _cds.Length - 1; - - if (newDisk != _discIndex) - { - _discIndex = newDisk; - Core.gpgx_swap_disc(_discIndex == -1 ? null : GetCDDataStruct(_cds[_discIndex])); - Console.WriteLine("IMMA CHANGING MAH DISKS"); - } - } - - // this shouldn't be needed, as nothing has changed - // if (!Core.gpgx_get_control(input, inputsize)) - // throw new Exception("gpgx_get_control() failed!"); - + Core.gpgx_reset(true); + if (_cds != null) + { + var prev = controller.IsPressed("Previous Disk"); + var next = controller.IsPressed("Next Disk"); + int newDisk = _discIndex; + if (prev && !_prevDiskPressed) + newDisk--; + if (next && !_nextDiskPressed) + newDisk++; + + _prevDiskPressed = prev; + _nextDiskPressed = next; + + if (newDisk < -1) + newDisk = -1; + if (newDisk >= _cds.Length) + newDisk = _cds.Length - 1; + + if (newDisk != _discIndex) + { + _discIndex = newDisk; + Core.gpgx_swap_disc(_discIndex == -1 ? null : GetCDDataStruct(_cds[_discIndex])); + Console.WriteLine("IMMA CHANGING MAH DISKS"); + } + } + + // this shouldn't be needed, as nothing has changed + // if (!Core.gpgx_get_control(input, inputsize)) + // throw new Exception("gpgx_get_control() failed!"); + ControlConverter.ScreenWidth = vwidth; ControlConverter.ScreenHeight = vheight; ControlConverter.Convert(controller, input); if (!Core.gpgx_put_control(input, inputsize)) - throw new Exception("gpgx_put_control() failed!"); + throw new Exception($"{nameof(Core.gpgx_put_control)}() failed!"); IsLagFrame = true; Frame++; @@ -66,6 +66,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx if (_cds != null) DriveLightOn = _drivelight; + + return true; } public int Frame { get; private set; } @@ -96,7 +98,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx if (_elf != null) _elf.Dispose(); if (_cds != null) - foreach (var cd in _cds) + foreach (var cd in _cds) cd.Dispose(); _disposed = true; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs index b6f867ace4..c8d8dab662 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs @@ -23,12 +23,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { var regs = DebuggableCore.GetCpuFlagsAndRegisters(); uint pc = (uint)regs["M68K PC"].Value; - var length = 0; - var disasm = Disassembler.Disassemble(MemoryDomains.SystemBus, pc, out length); + int length; + var disasm = Disassembler.Disassemble(MemoryDomains.SystemBus, pc & 0xFFFFFF, out length); var traceInfo = new TraceInfo { - Disassembly = string.Format("{0:X6}: {1}", pc, disasm) + Disassembly = string.Format("{0:X6}: {1}", pc, disasm).PadRight(50) }; var sb = new StringBuilder(); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IVideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IVideoProvider.cs index 9eaa69b291..69f2250c13 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IVideoProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IVideoProvider.cs @@ -78,7 +78,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx for (int i = 0; i < xpad; i++) *pdst++ = unchecked((int)0xff000000); for (int i = 0; i < gpwidth; i++) - *pdst++ = *psrc++; ; + *pdst++ = *psrc++; for (int i = 0; i < xpad2; i++) *pdst++ = unchecked((int)0xff000000); psrc += rinc; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs index c28bfe7067..2c507c30ca 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.cs @@ -114,7 +114,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx } if (!Core.gpgx_init(romextension, LoadCallback, _syncSettings.UseSixButton, system_a, system_b, _syncSettings.Region, _syncSettings.GetNativeSettings())) - throw new Exception("gpgx_init() failed"); + throw new Exception($"{nameof(Core.gpgx_init)}() failed"); { int fpsnum = 60; @@ -374,7 +374,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { inputsize = Marshal.SizeOf(typeof(LibGPGX.InputData)); if (!Core.gpgx_get_control(input, inputsize)) - throw new Exception("gpgx_get_control() failed"); + throw new Exception($"{nameof(Core.gpgx_get_control)}() failed"); ControlConverter = new GPGXControlConverter(input, false); // _cds != null); ControllerDefinition = ControlConverter.ControllerDef; diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs index 5c43900826..55157f7abe 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs @@ -131,7 +131,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSP } - public void FrameAdvance(IController controller, bool render, bool rendersound = true) + public bool FrameAdvance(IController controller, bool render, bool rendersound = true) { Frame++; UpdateInput(controller); @@ -147,6 +147,8 @@ namespace BizHawk.Emulation.Cores.Sony.PSP //nsampavail = PPSSPPDll.mixsound(audiobuffer, audiobuffer.Length / 2); LogFlush(); //Console.WriteLine("Audio Service: {0}", nsampavail); + + return true; } public int Frame diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 807558d6b3..0b2931de02 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -743,7 +743,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX private IController _controller; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { _controller = controller; FrameAdvance_PrepDiscState(); @@ -801,7 +801,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX LagCount++; //what happens to sound in this case? - if (render == false) return; + if (render == false) return true; OctoshockDll.ShockFramebufferInfo fb = new OctoshockDll.ShockFramebufferInfo(); @@ -840,9 +840,11 @@ namespace BizHawk.Emulation.Cores.Sony.PSX fixed (short* samples = sbuff) { sbuffcontains = OctoshockDll.shock_GetSamples(psx, null); - if (sbuffcontains * 2 > sbuff.Length) throw new InvalidOperationException("shock_GetSamples returned too many samples: " + sbuffcontains); + if (sbuffcontains * 2 > sbuff.Length) throw new InvalidOperationException($"{nameof(OctoshockDll.shock_GetSamples)} returned too many samples: {sbuffcontains}"); OctoshockDll.shock_GetSamples(psx, samples); } + + return true; } public ControllerDefinition ControllerDefinition { get; private set; } @@ -1074,7 +1076,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX }; int result = OctoshockDll.shock_StateTransaction(psx, ref transaction); if (result != OctoshockDll.SHOCK_OK) - throw new InvalidOperationException("eShockStateTransaction.TextSave returned error!"); + throw new InvalidOperationException($"{nameof(OctoshockDll.eShockStateTransaction)}.{nameof(OctoshockDll.eShockStateTransaction.TextSave)} returned error!"); s.ExtraData.IsLagFrame = IsLagFrame; s.ExtraData.LagCount = LagCount; @@ -1097,7 +1099,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX int result = OctoshockDll.shock_StateTransaction(psx, ref transaction); if (result != OctoshockDll.SHOCK_OK) - throw new InvalidOperationException("eShockStateTransaction.TextLoad returned error!"); + throw new InvalidOperationException($"{nameof(OctoshockDll.eShockStateTransaction)}.{nameof(OctoshockDll.eShockStateTransaction.TextLoad)} returned error!"); IsLagFrame = s.ExtraData.IsLagFrame; LagCount = s.ExtraData.LagCount; @@ -1132,7 +1134,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX int result = OctoshockDll.shock_StateTransaction(psx, ref transaction); if (result != OctoshockDll.SHOCK_OK) - throw new InvalidOperationException("eShockStateTransaction.BinarySave returned error!"); + throw new InvalidOperationException($"{nameof(OctoshockDll.eShockStateTransaction)}.{nameof(OctoshockDll.eShockStateTransaction.BinarySave)} returned error!"); writer.Write(savebuff.Length); writer.Write(savebuff); @@ -1162,7 +1164,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX reader.Read(savebuff, 0, length); int ret = OctoshockDll.shock_StateTransaction(psx, ref transaction); if (ret != OctoshockDll.SHOCK_OK) - throw new InvalidOperationException("eShockStateTransaction.BinaryLoad returned error!"); + throw new InvalidOperationException($"{nameof(OctoshockDll.eShockStateTransaction)}.{nameof(OctoshockDll.eShockStateTransaction.BinaryLoad)} returned error!"); // other variables IsLagFrame = reader.ReadBoolean(); diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISaveRam.cs index 0c83a13649..6ff43e6c6c 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.ISaveRam.cs @@ -20,14 +20,14 @@ namespace BizHawk.Emulation.Cores.WonderSwan public byte[] CloneSaveRam() { if (!BizSwan.bizswan_saveramsave(Core, saverambuff, saverambuff.Length)) - throw new InvalidOperationException("bizswan_saveramsave() returned false!"); + throw new InvalidOperationException($"{nameof(BizSwan.bizswan_saveramsave)}() returned false!"); return (byte[])saverambuff.Clone(); } public void StoreSaveRam(byte[] data) { if (!BizSwan.bizswan_saveramload(Core, data, data.Length)) - throw new InvalidOperationException("bizswan_saveramload() returned false!"); + throw new InvalidOperationException($"{nameof(BizSwan.bizswan_saveramload)}() returned false!"); } public bool SaveRamModified diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs index a228dbb8ae..eb25855adf 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.IStatable.cs @@ -64,7 +64,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan public void SaveStateBinary(BinaryWriter writer) { if (!BizSwan.bizswan_binstatesave(Core, savebuff, savebuff.Length)) - throw new InvalidOperationException("bizswan_binstatesave() returned false!"); + throw new InvalidOperationException($"{nameof(BizSwan.bizswan_binstatesave)}() returned false!"); writer.Write(savebuff.Length); writer.Write(savebuff); @@ -80,7 +80,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan throw new InvalidOperationException("Save buffer size mismatch!"); reader.Read(savebuff, 0, length); if (!BizSwan.bizswan_binstateload(Core, savebuff, savebuff.Length)) - throw new InvalidOperationException("bizswan_binstateload() returned false!"); + throw new InvalidOperationException($"{nameof(BizSwan.bizswan_binstateload)}() returned false!"); var d = BinaryQuickSerializer.Create(reader); LoadTextStateData(d); diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index 49f91a1824..4068514676 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan DeterministicEmulation = deterministic; // when true, remember to force the RTC flag! Core = BizSwan.bizswan_new(); if (Core == IntPtr.Zero) - throw new InvalidOperationException("bizswan_new() returned NULL!"); + throw new InvalidOperationException($"{nameof(BizSwan.bizswan_new)}() returned NULL!"); try { var ss = _SyncSettings.GetNativeSettings(); @@ -32,7 +32,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan bool rotate = false; if (!BizSwan.bizswan_load(Core, file, file.Length, ref ss, ref rotate)) - throw new InvalidOperationException("bizswan_load() returned FALSE!"); + throw new InvalidOperationException($"{nameof(BizSwan.bizswan_load)}() returned FALSE!"); InitISaveRam(); @@ -61,7 +61,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan } } - public void FrameAdvance(IController controller, bool render, bool rendersound = true) + public bool FrameAdvance(IController controller, bool render, bool rendersound = true) { Frame++; IsLagFrame = true; @@ -79,6 +79,8 @@ namespace BizHawk.Emulation.Cores.WonderSwan if (IsLagFrame) LagCount++; + + return true; } public CoreComm CoreComm { get; private set; } diff --git a/BizHawk.Emulation.Cores/CoreInventory.cs b/BizHawk.Emulation.Cores/CoreInventory.cs index 12de472ea6..9f5a5aa905 100644 --- a/BizHawk.Emulation.Cores/CoreInventory.cs +++ b/BizHawk.Emulation.Cores/CoreInventory.cs @@ -178,7 +178,7 @@ namespace BizHawk.Emulation.Cores { var coreattr = typ.GetCustomAttributes(typeof(CoreAttribute), false); if (coreattr.Length != 1) - throw new InvalidOperationException(string.Format("IEmulator {0} without CoreAttributes!", typ)); + throw new InvalidOperationException($"{nameof(IEmulator)} {typ} without {nameof(CoreAttribute)}s!"); var cons = typ.GetConstructors(BindingFlags.Public | BindingFlags.Instance) .Where(c => c.GetCustomAttributes(typeof(CoreConstructorAttribute), false).Length > 0).ToList(); foreach(var con in cons) diff --git a/BizHawk.Emulation.Cores/FileID.cs b/BizHawk.Emulation.Cores/FileID.cs index f026b96e5b..5b343f7360 100644 --- a/BizHawk.Emulation.Cores/FileID.cs +++ b/BizHawk.Emulation.Cores/FileID.cs @@ -573,17 +573,9 @@ namespace BizHawk.Emulation.Cores //first we can check for SMD magic words. //since this extension is ambiguous, we can't be completely sure about it. but it's almost surely accurate if (CheckMagic(job.Stream, SimpleMagics.SEGAGENESIS)) - { - var ret = new FileIDResult(FileIDType.SMD, 95); - ret.ExtraInfo["type"] = "genesis"; - return ret; - } - + return new FileIDResult(FileIDType.SMD, 95) { ExtraInfo = { ["type"] = "genesis" } }; if (CheckMagic(job.Stream, SimpleMagics.SEGAMEGADRIVE)) - { - var ret = new FileIDResult(FileIDType.SMD, 95); - ret.ExtraInfo["type"] = "megadrive"; - } + return new FileIDResult(FileIDType.SMD, 95) { ExtraInfo = { ["type"] = "megadrive" } }; } //well... guess it's a disc. @@ -637,4 +629,4 @@ namespace BizHawk.Emulation.Cores } } -} \ No newline at end of file +} diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs b/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs index f52709963b..3d3fca7bb9 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs @@ -154,11 +154,13 @@ namespace BizHawk.Emulation.Cores.Libretro private IController _controller; - public void FrameAdvance(IController controller, bool render, bool rendersound) + public bool FrameAdvance(IController controller, bool render, bool rendersound) { _controller = controller; api.CMD_Run(); timeFrameCounter++; + + return true; } GCHandle vidBufferHandle; diff --git a/BizHawk.Emulation.Cores/Sound/CDAudio.cs b/BizHawk.Emulation.Cores/Sound/CDAudio.cs index c2016f2ff0..db892d3901 100644 --- a/BizHawk.Emulation.Cores/Sound/CDAudio.cs +++ b/BizHawk.Emulation.Cores/Sound/CDAudio.cs @@ -229,17 +229,17 @@ namespace BizHawk.Emulation.Cores.Components public void SyncState(Serializer ser) { - ser.BeginSection("CDAudio"); - ser.Sync("Mode", ref Mode); - ser.Sync("PlayMode", ref PlayMode); - ser.Sync("LogicalVolume", ref LogicalVolume); - ser.Sync("StartLBA", ref StartLBA); - ser.Sync("EndLBA", ref EndLBA); - ser.Sync("PlayingTrack", ref PlayingTrack); - ser.Sync("CurrentSector", ref CurrentSector); - ser.Sync("SectorOffset", ref SectorOffset); - ser.Sync("FadeOutOverFrames", ref FadeOutOverFrames); - ser.Sync("FadeOutFramesRemaining", ref FadeOutFramesRemaining); + ser.BeginSection(nameof(CDAudio)); + ser.Sync(nameof(Mode), ref Mode); + ser.Sync(nameof(PlayMode), ref PlayMode); + ser.Sync(nameof(LogicalVolume), ref LogicalVolume); + ser.Sync(nameof(StartLBA), ref StartLBA); + ser.Sync(nameof(EndLBA), ref EndLBA); + ser.Sync(nameof(PlayingTrack), ref PlayingTrack); + ser.Sync(nameof(CurrentSector), ref CurrentSector); + ser.Sync(nameof(SectorOffset), ref SectorOffset); + ser.Sync(nameof(FadeOutOverFrames), ref FadeOutOverFrames); + ser.Sync(nameof(FadeOutFramesRemaining), ref FadeOutFramesRemaining); ser.EndSection(); if (ser.IsReader) diff --git a/BizHawk.Emulation.Cores/Sound/HuC6280PSG.cs b/BizHawk.Emulation.Cores/Sound/HuC6280PSG.cs index 0aa5cac72f..4c008a551a 100644 --- a/BizHawk.Emulation.Cores/Sound/HuC6280PSG.cs +++ b/BizHawk.Emulation.Cores/Sound/HuC6280PSG.cs @@ -227,28 +227,28 @@ namespace BizHawk.Emulation.Cores.Components public void SyncState(Serializer ser) { ser.BeginSection("PSG"); - ser.Sync("MainVolumeLeft", ref MainVolumeLeft); - ser.Sync("MainVolumeRight", ref MainVolumeRight); - ser.Sync("VoiceLatch", ref VoiceLatch); - ser.Sync("WaveTableWriteOffset", ref WaveTableWriteOffset); + ser.Sync(nameof(MainVolumeLeft), ref MainVolumeLeft); + ser.Sync(nameof(MainVolumeRight), ref MainVolumeRight); + ser.Sync(nameof(VoiceLatch), ref VoiceLatch); + ser.Sync(nameof(WaveTableWriteOffset), ref WaveTableWriteOffset); for (int i = 0; i < 6; i++) { ser.BeginSection("Channel"+i); - ser.Sync("Frequency", ref Channels[i].Frequency); - ser.Sync("Panning", ref Channels[i].Panning); - ser.Sync("Volume", ref Channels[i].Volume); - ser.Sync("Enabled", ref Channels[i].Enabled); + ser.Sync(nameof(PSGChannel.Frequency), ref Channels[i].Frequency); + ser.Sync(nameof(PSGChannel.Panning), ref Channels[i].Panning); + ser.Sync(nameof(PSGChannel.Volume), ref Channels[i].Volume); + ser.Sync(nameof(PSGChannel.Enabled), ref Channels[i].Enabled); if (i.In(4, 5)) { - ser.Sync("NoiseChannel", ref Channels[i].NoiseChannel); - ser.Sync("NoiseFreq", ref Channels[i].NoiseFreq); + ser.Sync(nameof(PSGChannel.NoiseChannel), ref Channels[i].NoiseChannel); + ser.Sync(nameof(PSGChannel.NoiseFreq), ref Channels[i].NoiseFreq); } - ser.Sync("DDA", ref Channels[i].DDA); - ser.Sync("DDAValue", ref Channels[i].DDAValue); - ser.Sync("SampleOffset", ref Channels[i].SampleOffset); - ser.Sync("Wave", ref Channels[i].Wave, false); + ser.Sync(nameof(PSGChannel.DDA), ref Channels[i].DDA); + ser.Sync(nameof(PSGChannel.DDAValue), ref Channels[i].DDAValue); + ser.Sync(nameof(PSGChannel.SampleOffset), ref Channels[i].SampleOffset); + ser.Sync(nameof(PSGChannel.Wave), ref Channels[i].Wave, false); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Sound/MMC5Audio.cs b/BizHawk.Emulation.Cores/Sound/MMC5Audio.cs index ed81b55961..559ed36672 100644 --- a/BizHawk.Emulation.Cores/Sound/MMC5Audio.cs +++ b/BizHawk.Emulation.Cores/Sound/MMC5Audio.cs @@ -50,20 +50,20 @@ namespace BizHawk.Emulation.Cores.Components public void SyncState(Serializer ser) { - ser.Sync("V", ref V); - ser.Sync("T", ref T); - ser.Sync("L", ref L); - ser.Sync("D", ref D); - ser.Sync("LenCntDisable", ref LenCntDisable); - ser.Sync("ConstantVolume", ref ConstantVolume); - ser.Sync("Enable", ref Enable); - ser.Sync("estart", ref estart); - ser.Sync("etime", ref etime); - ser.Sync("ecount", ref ecount); - ser.Sync("length", ref length); - ser.Sync("sequence", ref sequence); - ser.Sync("clock", ref clock); - ser.Sync("output", ref output); + ser.Sync(nameof(V), ref V); + ser.Sync(nameof(T), ref T); + ser.Sync(nameof(L), ref L); + ser.Sync(nameof(D), ref D); + ser.Sync(nameof(LenCntDisable), ref LenCntDisable); + ser.Sync(nameof(ConstantVolume), ref ConstantVolume); + ser.Sync(nameof(Enable), ref Enable); + ser.Sync(nameof(estart), ref estart); + ser.Sync(nameof(etime), ref etime); + ser.Sync(nameof(ecount), ref ecount); + ser.Sync(nameof(length), ref length); + ser.Sync(nameof(sequence), ref sequence); + ser.Sync(nameof(clock), ref clock); + ser.Sync(nameof(output), ref output); } public void Write0(byte val) @@ -265,19 +265,19 @@ namespace BizHawk.Emulation.Cores.Components public void SyncState(Serializer ser) { - ser.BeginSection("MMC5Audio"); - ser.Sync("frame", ref frame); + ser.BeginSection(nameof(MMC5Audio)); + ser.Sync(nameof(frame), ref frame); ser.BeginSection("Pulse0"); pulse[0].SyncState(ser); ser.EndSection(); ser.BeginSection("Pulse1"); pulse[1].SyncState(ser); ser.EndSection(); - ser.Sync("PCMRead", ref PCMRead); - ser.Sync("PCMEnableIRQ", ref PCMEnableIRQ); - ser.Sync("PCMIRQTriggered", ref PCMIRQTriggered); - ser.Sync("PCMVal", ref PCMVal); - ser.Sync("PCMNextVal", ref PCMNextVal); + ser.Sync(nameof(PCMRead), ref PCMRead); + ser.Sync(nameof(PCMEnableIRQ), ref PCMEnableIRQ); + ser.Sync(nameof(PCMIRQTriggered), ref PCMIRQTriggered); + ser.Sync(nameof(PCMVal), ref PCMVal); + ser.Sync(nameof(PCMNextVal), ref PCMNextVal); ser.EndSection(); if (ser.IsReader) RaiseIRQ(PCMEnableIRQ && PCMIRQTriggered); diff --git a/BizHawk.Emulation.Cores/Sound/SN76489.cs b/BizHawk.Emulation.Cores/Sound/SN76489.cs deleted file mode 100644 index c5e7e113c5..0000000000 --- a/BizHawk.Emulation.Cores/Sound/SN76489.cs +++ /dev/null @@ -1,258 +0,0 @@ -using System.Collections.Generic; - -using BizHawk.Common; -using BizHawk.Emulation.Common; - -namespace BizHawk.Emulation.Cores.Components -{ - public sealed class SN76489 : IMixedSoundProvider - { - public sealed class Channel - { - public ushort Frequency; - public byte Volume; - public short[] Wave; - public bool Noise; - public byte NoiseType; - public float WaveOffset; - public bool Left = true; - public bool Right = true; - - const int SampleRate = 44100; - private static readonly byte[] LogScale = { 0, 10, 13, 16, 20, 26, 32, 40, 51, 64, 81, 102, 128, 161, 203, 255 }; - - public void Mix(short[] samples, long start, long len, int maxVolume) - { - if (Volume == 0) return; - - float adjustedWaveLengthInSamples = SampleRate / (Noise ? (Frequency / (float)Wave.Length) : Frequency); - float moveThroughWaveRate = Wave.Length / adjustedWaveLengthInSamples; - - long end = start + len; - for (long i = start; i < end; ) - { - short value = Wave[(int)WaveOffset]; - - samples[i++] += (short)(Left ? (value / 4 * LogScale[Volume] / 0xFF * maxVolume / short.MaxValue) : 0); - samples[i++] += (short)(Right ? (value / 4 * LogScale[Volume] / 0xFF * maxVolume / short.MaxValue) : 0); - WaveOffset += moveThroughWaveRate; - if (WaveOffset >= Wave.Length) - WaveOffset %= Wave.Length; - } - } - } - - public Channel[] Channels = new Channel[4]; - public byte PsgLatch; - - private readonly Queue commands = new Queue(256); - long frameStartTime, frameStopTime; - - const int PsgBase = 111861; - - public SN76489() - { - MaxVolume = short.MaxValue * 2 / 3; - Waves.InitWaves(); - for (int i = 0; i < 4; i++) - { - Channels[i] = new Channel(); - switch (i) - { - case 0: - case 1: - case 2: - Channels[i].Wave = Waves.ImperfectSquareWave; - break; - case 3: - Channels[i].Wave = Waves.NoiseWave; - Channels[i].Noise = true; - break; - } - } - } - - public void Reset() - { - PsgLatch = 0; - foreach (var channel in Channels) - { - channel.Frequency = 0; - channel.Volume = 0; - channel.NoiseType = 0; - channel.WaveOffset = 0f; - } - } - - public void BeginFrame(long cycles) - { - while (commands.Count > 0) - { - var cmd = commands.Dequeue(); - WritePsgDataImmediate(cmd.Value); - } - frameStartTime = cycles; - } - - public void EndFrame(long cycles) - { - frameStopTime = cycles; - } - - public void WritePsgData(byte value, long cycles) - { - commands.Enqueue(new QueuedCommand { Value = value, Time = cycles - frameStartTime }); - } - - void UpdateNoiseType(int value) - { - Channels[3].NoiseType = (byte)(value & 0x07); - switch (Channels[3].NoiseType & 3) - { - case 0: Channels[3].Frequency = PsgBase / 16; break; - case 1: Channels[3].Frequency = PsgBase / 32; break; - case 2: Channels[3].Frequency = PsgBase / 64; break; - case 3: Channels[3].Frequency = Channels[2].Frequency; break; - } - var newWave = (value & 4) == 0 ? Waves.PeriodicWave16 : Waves.NoiseWave; - if (newWave != Channels[3].Wave) - { - Channels[3].Wave = newWave; - Channels[3].WaveOffset = 0f; - } - } - - void WritePsgDataImmediate(byte value) - { - switch (value & 0xF0) - { - case 0x80: - case 0xA0: - case 0xC0: - PsgLatch = value; - break; - case 0xE0: - PsgLatch = value; - UpdateNoiseType(value); - break; - case 0x90: - Channels[0].Volume = (byte)(~value & 15); - PsgLatch = value; - break; - case 0xB0: - Channels[1].Volume = (byte)(~value & 15); - PsgLatch = value; - break; - case 0xD0: - Channels[2].Volume = (byte)(~value & 15); - PsgLatch = value; - break; - case 0xF0: - Channels[3].Volume = (byte)(~value & 15); - PsgLatch = value; - break; - default: - byte channel = (byte)((PsgLatch & 0x60) >> 5); - if ((PsgLatch & 16) == 0) // Tone latched - { - int f = PsgBase / (((value & 0x03F) * 16) + (PsgLatch & 0x0F) + 1); - if (f > 15000) - f = 0; // upper bound of playable frequency - Channels[channel].Frequency = (ushort)f; - if ((Channels[3].NoiseType & 3) == 3 && channel == 2) - Channels[3].Frequency = (ushort)f; - } - else - { // volume latched - Channels[channel].Volume = (byte)(~value & 15); - } - break; - } - } - - byte stereoPanning = 0xFF; - public byte StereoPanning - { - get - { - byte value = 0; - if (Channels[0].Left) value |= 0x10; - if (Channels[0].Right) value |= 0x01; - if (Channels[1].Left) value |= 0x20; - if (Channels[1].Right) value |= 0x02; - if (Channels[2].Left) value |= 0x40; - if (Channels[2].Right) value |= 0x04; - if (Channels[3].Left) value |= 0x80; - if (Channels[3].Right) value |= 0x08; - return value; - } - set - { - Channels[0].Left = (value & 0x10) != 0; - Channels[0].Right = (value & 0x01) != 0; - Channels[1].Left = (value & 0x20) != 0; - Channels[1].Right = (value & 0x02) != 0; - Channels[2].Left = (value & 0x40) != 0; - Channels[2].Right = (value & 0x04) != 0; - Channels[3].Left = (value & 0x80) != 0; - Channels[3].Right = (value & 0x08) != 0; - stereoPanning = value; - } - } - - public void SyncState(Serializer ser) - { - ser.BeginSection("PSG"); - ser.Sync("Volume0", ref Channels[0].Volume); - ser.Sync("Volume1", ref Channels[1].Volume); - ser.Sync("Volume2", ref Channels[2].Volume); - ser.Sync("Volume3", ref Channels[3].Volume); - ser.Sync("Freq0", ref Channels[0].Frequency); - ser.Sync("Freq1", ref Channels[1].Frequency); - ser.Sync("Freq2", ref Channels[2].Frequency); - ser.Sync("Freq3", ref Channels[3].Frequency); - ser.Sync("NoiseType", ref Channels[3].NoiseType); - ser.Sync("PsgLatch", ref PsgLatch); - ser.Sync("Panning", ref stereoPanning); - ser.EndSection(); - - if (ser.IsReader) - { - StereoPanning = stereoPanning; - UpdateNoiseType(Channels[3].NoiseType); - } - } - - public int MaxVolume { get; set; } - public void DiscardSamples() { commands.Clear(); } - public void GetSamples(short[] samples) - { - long elapsedCycles = frameStopTime - frameStartTime; - if (elapsedCycles == 0) - elapsedCycles = 1; // hey it's better than diving by zero - - long start = 0; - while (commands.Count > 0) - { - var cmd = commands.Dequeue(); - long pos = ((cmd.Time * samples.Length) / elapsedCycles) & ~1; - GetSamplesImmediate(samples, start, pos - start); - start = pos; - WritePsgDataImmediate(cmd.Value); - } - GetSamplesImmediate(samples, start, samples.Length - start); - } - - public void GetSamplesImmediate(short[] samples, long start, long len) - { - for (long i = 0; i < 4; i++) - Channels[i].Mix(samples, start, len, MaxVolume); - } - - class QueuedCommand - { - public byte Value; - public long Time; - } - } -} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Sound/SN76489sms.cs b/BizHawk.Emulation.Cores/Sound/SN76489sms.cs new file mode 100644 index 0000000000..1cc1bc0de7 --- /dev/null +++ b/BizHawk.Emulation.Cores/Sound/SN76489sms.cs @@ -0,0 +1,258 @@ +using System; + +using BizHawk.Common; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Cores.Components +{ + public sealed class SN76489sms + { + public int current_sample_L; + public int current_sample_R; + + public SN76489sms() + { + Reset(); + } + + public byte[] Chan_vol = new byte[4]; + public ushort[] Chan_tone = new ushort[4]; + + public int chan_sel; + public bool vol_tone; + public bool noise_type; + public int noise_rate; + public bool noise_bit; + + public bool A_L, B_L, C_L, noise_L; + public bool A_R, B_R, C_R, noise_R; + + private int psg_clock; + + private int clock_A, clock_B, clock_C; + + private bool A_up, B_up, C_up; + + private int noise_clock; + private int noise; + + public byte stereo_panning; + private static readonly byte[] LogScale = { 255, 203, 161, 128, 102, 86, 64, 51, 40, 32, 26, 20, 16, 13, 10, 0 }; + + public void Reset() + { + clock_A = clock_B = clock_C = 0x1000; + noise_clock = 0x10; + chan_sel = 0; + + // reset the shift register + noise = 0x40000; + + Chan_vol[0] = 0xF; + Chan_vol[1] = 0xF; + Chan_vol[2] = 0xF; + Chan_vol[3] = 0xF; + + Set_Panning(0xFF); + } + + public void Set_Panning(byte value) + { + A_L = (value & 0x10) != 0; + A_R = (value & 0x01) != 0; + B_L = (value & 0x20) != 0; + B_R = (value & 0x02) != 0; + C_L = (value & 0x40) != 0; + C_R = (value & 0x04) != 0; + noise_L = (value & 0x80) != 0; + noise_R = (value & 0x08) != 0; + + stereo_panning = value; + } + + public void SyncState(Serializer ser) + { + ser.BeginSection("SN76489"); + + ser.Sync(nameof(Chan_vol), ref Chan_vol, false); + ser.Sync(nameof(Chan_tone), ref Chan_tone, false); + + ser.Sync(nameof(chan_sel), ref chan_sel); + ser.Sync(nameof(vol_tone), ref vol_tone); + ser.Sync(nameof(noise_type), ref noise_type); + ser.Sync(nameof(noise_rate), ref noise_rate); + + ser.Sync(nameof(clock_A), ref clock_A); + ser.Sync(nameof(clock_B), ref clock_B); + ser.Sync(nameof(clock_C), ref clock_C); + ser.Sync(nameof(noise_clock), ref noise_clock); + ser.Sync(nameof(noise_bit), ref noise_bit); + + ser.Sync(nameof(psg_clock), ref psg_clock); + + ser.Sync(nameof(A_up), ref A_up); + ser.Sync(nameof(B_up), ref B_up); + ser.Sync(nameof(C_up), ref C_up); + ser.Sync(nameof(noise), ref noise); + + ser.Sync(nameof(A_L), ref A_L); + ser.Sync(nameof(B_L), ref B_L); + ser.Sync(nameof(C_L), ref C_L); + ser.Sync(nameof(noise_L), ref noise_L); + ser.Sync(nameof(A_L), ref A_R); + ser.Sync(nameof(B_L), ref B_R); + ser.Sync(nameof(C_L), ref C_R); + ser.Sync(nameof(noise_L), ref noise_R); + + ser.Sync(nameof(current_sample_L), ref current_sample_L); + ser.Sync(nameof(current_sample_R), ref current_sample_R); + ser.Sync(nameof(stereo_panning), ref stereo_panning); + + ser.EndSection(); + } + + public byte ReadReg() + { + // not used, reading not allowed, just return 0xFF + return 0xFF; + } + + public void WriteReg(byte value) + { + // if bit 7 is set, change the latch, otherwise modify the currently latched register + if (value.Bit(7)) + { + chan_sel = (value >> 5) & 3; + vol_tone = value.Bit(4); + + if (vol_tone) + { + Chan_vol[chan_sel] = (byte)(value & 0xF); + } + else + { + if (chan_sel < 3) + { + Chan_tone[chan_sel] &= 0x3F0; + Chan_tone[chan_sel] |= (ushort)(value & 0xF); + } + else + { + noise_type = value.Bit(2); + noise_rate = value & 3; + + // reset the shift register + noise = 0x40000; + } + } + } + else + { + if (vol_tone) + { + Chan_vol[chan_sel] = (byte)(value & 0xF); + } + else + { + if (chan_sel < 3) + { + Chan_tone[chan_sel] &= 0xF; + Chan_tone[chan_sel] |= (ushort)((value & 0x3F) << 4); + } + else + { + noise_type = value.Bit(2); + noise_rate = value & 3; + + // reset the shift register + noise = 0x40000; + } + } + } + } + + public void generate_sound() + { + // there are 16 cpu cycles for every psg cycle + psg_clock++; + + if (psg_clock == 16) + { + psg_clock = 0; + + clock_A--; + clock_B--; + clock_C--; + noise_clock--; + + // clock noise + if (noise_clock == 0) + { + noise_bit = noise.Bit(0); + if (noise_type) + { + noise = (((noise & 1) ^ ((noise >> 1) & 1)) << 14) | (noise >> 1); + } + else + { + noise = ((noise & 1) << 14) | (noise >> 1); + } + + if (noise_rate == 0) + { + noise_clock = 0x10; + } + else if (noise_rate == 1) + { + noise_clock = 0x20; + } + else if (noise_rate == 2) + { + noise_clock = 0x40; + } + else + { + noise_clock = Chan_tone[2] + 1; + } + + noise_clock *= 2; + } + + if (clock_A == 0) + { + A_up = !A_up; + clock_A = Chan_tone[0] + 1; + } + + if (clock_B == 0) + { + B_up = !B_up; + clock_B = Chan_tone[1] + 1; + } + + if (clock_C == 0) + { + C_up = !C_up; + clock_C = Chan_tone[2] + 1; + } + + // now calculate the volume of each channel and add them together + current_sample_L = (A_L ? (A_up ? LogScale[Chan_vol[0]] * 42 : 0) : 0); + + current_sample_L += (B_L ? (B_up ? LogScale[Chan_vol[1]] * 42 : 0) : 0); + + current_sample_L += (C_L ? (C_up ? LogScale[Chan_vol[2]] * 42 : 0) : 0); + + current_sample_L += (noise_L ? (noise_bit ? LogScale[Chan_vol[3]] * 42 : 0) : 0); + + current_sample_R = (A_R ? (A_up ? LogScale[Chan_vol[0]] * 42 : 0) : 0); + + current_sample_R += (B_R ? (B_up ? LogScale[Chan_vol[1]] * 42 : 0) : 0); + + current_sample_R += (C_R ? (C_up ? LogScale[Chan_vol[2]] * 42 : 0) : 0); + + current_sample_R += (noise_R ? (noise_bit ? LogScale[Chan_vol[3]] * 42 : 0) : 0); + } + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Sound/Sunsoft5BAudio.cs b/BizHawk.Emulation.Cores/Sound/Sunsoft5BAudio.cs index 7b06cc59cb..a33fea9559 100644 --- a/BizHawk.Emulation.Cores/Sound/Sunsoft5BAudio.cs +++ b/BizHawk.Emulation.Cores/Sound/Sunsoft5BAudio.cs @@ -26,12 +26,12 @@ namespace BizHawk.Emulation.Cores.Components public void SyncState(Serializer ser) { - ser.Sync("Period", ref Period); - ser.Sync("Disable", ref Disable); - ser.Sync("Volume", ref Volume); - ser.Sync("clock", ref clock); - ser.Sync("sequence", ref sequence); - ser.Sync("output", ref output); + ser.Sync(nameof(Period), ref Period); + ser.Sync(nameof(Disable), ref Disable); + ser.Sync(nameof(Volume), ref Volume); + ser.Sync(nameof(clock), ref clock); + ser.Sync(nameof(sequence), ref sequence); + ser.Sync(nameof(output), ref output); } public Pulse(Action SendDiff) @@ -122,8 +122,8 @@ namespace BizHawk.Emulation.Cores.Components public void SyncState(Serializer ser) { - ser.BeginSection("Sunsoft5BAudio"); - ser.Sync("RegNum", ref RegNum); + ser.BeginSection(nameof(Sunsoft5BAudio)); + ser.Sync(nameof(RegNum), ref RegNum); for (int i = 0; i < pulse.Length; i++) { ser.BeginSection("Pulse" + i); diff --git a/BizHawk.Emulation.Cores/Sound/VRC6Alt.cs b/BizHawk.Emulation.Cores/Sound/VRC6Alt.cs index 57e0cbb980..756982d66b 100644 --- a/BizHawk.Emulation.Cores/Sound/VRC6Alt.cs +++ b/BizHawk.Emulation.Cores/Sound/VRC6Alt.cs @@ -44,8 +44,8 @@ namespace BizHawk.Emulation.Cores.Components public void SyncState(Serializer ser) { - ser.BeginSection("VRC6Alt"); - ser.Sync("masterenable", ref masterenable); + ser.BeginSection(nameof(VRC6Alt)); + ser.Sync(nameof(masterenable), ref masterenable); ser.BeginSection("Pulse1"); pulse1.SyncState(ser); ser.EndSection(); @@ -135,14 +135,14 @@ namespace BizHawk.Emulation.Cores.Components public void SyncState(Serializer ser) { - ser.Sync("A", ref A); - ser.Sync("F", ref F); - ser.Sync("E", ref E); - ser.Sync("RSHIFT", ref RSHIFT); - ser.Sync("count", ref count); - ser.Sync("accum", ref accum); - ser.Sync("acount", ref acount); - ser.Sync("output", ref output); + ser.Sync(nameof(A), ref A); + ser.Sync(nameof(F), ref F); + ser.Sync(nameof(E), ref E); + ser.Sync(nameof(RSHIFT), ref RSHIFT); + ser.Sync(nameof(count), ref count); + ser.Sync(nameof(accum), ref accum); + ser.Sync(nameof(acount), ref acount); + ser.Sync(nameof(output), ref output); } public void Write0(byte value) @@ -247,14 +247,14 @@ namespace BizHawk.Emulation.Cores.Components public void SyncState(Serializer ser) { - ser.Sync("V", ref V); - ser.Sync("D", ref D); - ser.Sync("F", ref F); - ser.Sync("E", ref E); - ser.Sync("RSHIFT", ref RSHIFT); - ser.Sync("count", ref count); - ser.Sync("duty", ref duty); - ser.Sync("output", ref output); + ser.Sync(nameof(V), ref V); + ser.Sync(nameof(D), ref D); + ser.Sync(nameof(F), ref F); + ser.Sync(nameof(E), ref E); + ser.Sync(nameof(RSHIFT), ref RSHIFT); + ser.Sync(nameof(count), ref count); + ser.Sync(nameof(duty), ref duty); + ser.Sync(nameof(output), ref output); } public void Write0(byte value) diff --git a/BizHawk.Emulation.Cores/Sound/YM2413.cs b/BizHawk.Emulation.Cores/Sound/YM2413.cs index f0d961f8f7..91268635e9 100644 --- a/BizHawk.Emulation.Cores/Sound/YM2413.cs +++ b/BizHawk.Emulation.Cores/Sound/YM2413.cs @@ -39,8 +39,8 @@ namespace BizHawk.Emulation.Common.Components public void SyncState(Serializer ser) { - ser.BeginSection("YM2413"); - ser.Sync("RegisterLatch", ref RegisterLatch); + ser.BeginSection(nameof(YM2413)); + ser.Sync(nameof(RegisterLatch), ref RegisterLatch); ser.Sync("Registers", ref opll.reg, false); ser.EndSection(); diff --git a/BizHawk.Emulation.Cores/Waterbox/MapHeap.cs b/BizHawk.Emulation.Cores/Waterbox/MapHeap.cs index 3ae6e57a7c..499988bc35 100644 --- a/BizHawk.Emulation.Cores/Waterbox/MapHeap.cs +++ b/BizHawk.Emulation.Cores/Waterbox/MapHeap.cs @@ -6,8 +6,8 @@ using System.Text; using System.Threading.Tasks; using System.IO; using System.Runtime.InteropServices; -using BizHawk.Common.BizInvoke; - +using BizHawk.Common.BizInvoke; + namespace BizHawk.Emulation.Cores.Waterbox { /// @@ -56,7 +56,7 @@ namespace BizHawk.Emulation.Cores.Waterbox _pages = (MemoryBlock.Protection[])(object)_pagesAsBytes; for (var i = 0; i < _pages.Length; i++) _pages[i] = FREE; - Console.WriteLine("Created mapheap `{1}` at {0:x16}:{2:x16}", start, name, start + size); + Console.WriteLine($"Created {nameof(MapHeap)} `{name}` at {start:x16}:{start + size:x16}"); } // find consecutive unused pages to map @@ -294,14 +294,14 @@ namespace BizHawk.Emulation.Cores.Waterbox { var name = br.ReadString(); if (name != Name) - throw new InvalidOperationException(string.Format("Name did not match for mapheap {0}", Name)); + throw new InvalidOperationException($"Name did not match for {nameof(MapHeap)} {Name}"); var size = br.ReadUInt64(); if (size != Memory.Size) - throw new InvalidOperationException(string.Format("Size did not match for mapheap {0}", Name)); + throw new InvalidOperationException($"Size did not match for {nameof(MapHeap)} {Name}"); var used = br.ReadUInt64(); var hash = br.ReadBytes(Memory.XorHash.Length); if (!hash.SequenceEqual(Memory.XorHash)) - throw new InvalidOperationException(string.Format("Hash did not match for mapheap {0}. Is this the same rom?", Name)); + throw new InvalidOperationException($"Hash did not match for {nameof(MapHeap)} {Name}. Is this the same rom?"); if (br.BaseStream.Read(_pagesAsBytes, 0, _pagesAsBytes.Length) != _pagesAsBytes.Length) throw new InvalidOperationException("Unexpected error reading!"); diff --git a/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs b/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs index fdb242e35a..d81aac84be 100644 --- a/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs +++ b/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs @@ -1217,7 +1217,7 @@ namespace BizHawk.Emulation.Cores.Waterbox { // if a different runtime instance than this one saved the state, // Exvoker imports need to be reconnected - Console.WriteLine("Restoring PeRunner state from a different core..."); + Console.WriteLine($"Restoring {nameof(PeRunner)} state from a different core..."); ConnectAllImports(); _psx.ReloadVtables(); } diff --git a/BizHawk.Emulation.Cores/Waterbox/PeWrapper.cs b/BizHawk.Emulation.Cores/Waterbox/PeWrapper.cs index 8f2e5d3d28..9f4854b8ba 100644 --- a/BizHawk.Emulation.Cores/Waterbox/PeWrapper.cs +++ b/BizHawk.Emulation.Cores/Waterbox/PeWrapper.cs @@ -333,7 +333,7 @@ namespace BizHawk.Emulation.Cores.Waterbox public void SealImportsAndTakeXorSnapshot() { if (_everythingSealed) - throw new InvalidOperationException("PeWrapper already sealed!"); + throw new InvalidOperationException($"{nameof(PeWrapper)} already sealed!"); // save import values, then zero them all (for hash purposes), then take our snapshot, then load them again, // then set the .idata area to read only diff --git a/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs b/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs index 3c717bb65f..f202a6b3dd 100644 --- a/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs +++ b/BizHawk.Emulation.Cores/Waterbox/WaterboxCore.cs @@ -191,7 +191,7 @@ namespace BizHawk.Emulation.Cores.Waterbox protected virtual void FrameAdvancePost() { } - public unsafe void FrameAdvance(IController controller, bool render, bool rendersound = true) + public unsafe bool FrameAdvance(IController controller, bool render, bool rendersound = true) { using (_exe.EnterExit()) { @@ -218,6 +218,8 @@ namespace BizHawk.Emulation.Cores.Waterbox FrameAdvancePost(); } } + + return true; } private bool _disposed = false; diff --git a/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs b/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs index 9340619392..5288b214fb 100644 --- a/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs +++ b/BizHawk.Emulation.DiscSystem/API_MednaDisc.cs @@ -17,11 +17,11 @@ namespace BizHawk.Emulation.DiscSystem public MednaDisc(string pathToDisc) { if (!IsLibraryAvailable) - throw new InvalidOperationException("MednaDisc library is not available!"); + throw new InvalidOperationException($"{nameof(MednaDisc)} library is not available!"); handle = mednadisc_LoadCD(pathToDisc); if (handle == IntPtr.Zero) - throw new InvalidOperationException("Failed to load MednaDisc: " + pathToDisc); + throw new InvalidOperationException($"Failed to load {nameof(MednaDisc)}: {pathToDisc}"); //read the mednafen toc TOCTracks = new MednadiscTOCTrack[101]; diff --git a/BizHawk.Emulation.DiscSystem/CDFS/ISOVolumeDescriptor.cs b/BizHawk.Emulation.DiscSystem/CDFS/ISOVolumeDescriptor.cs index e8b271e10f..4a4a5cc4d1 100644 --- a/BizHawk.Emulation.DiscSystem/CDFS/ISOVolumeDescriptor.cs +++ b/BizHawk.Emulation.DiscSystem/CDFS/ISOVolumeDescriptor.cs @@ -466,7 +466,7 @@ namespace BizHawk.Emulation.DiscSystem public bool GetISO9660(byte[] buffer) { //zero 24-jun-2013 - validate ISO9660 - // "CD001" + 0x01 + // "CD001\x01" if (buffer[1] == 'C' && buffer[2] == 'D' && buffer[3] == '0' && buffer[4] == '0' && buffer[5] == '1' && buffer[6] == 0x01) { ISOFile.Format = ISOFile.ISOFormat.ISO9660; diff --git a/BizHawk.Emulation.DiscSystem/DiscDecoding.cs b/BizHawk.Emulation.DiscSystem/DiscDecoding.cs index 0bb82900e3..490203eba7 100644 --- a/BizHawk.Emulation.DiscSystem/DiscDecoding.cs +++ b/BizHawk.Emulation.DiscSystem/DiscDecoding.cs @@ -19,7 +19,7 @@ namespace BizHawk.Emulation.DiscSystem private static string[] Escape(IEnumerable args) { - return args.Select(s => s.Contains(" ") ? string.Format("\"{0}\"", s) : s).ToArray(); + return args.Select(s => s.Contains(" ") ? $"\"{s}\"" : s).ToArray(); } //note: accepts . or : in the stream stream/substream separator in the stream ID format, since that changed at some point in FFMPEG history @@ -92,10 +92,10 @@ namespace BizHawk.Emulation.DiscSystem { var runResults = Run("-i", path, "-xerror", "-f", "wav", "-ar", "44100", "-ac", "2", "-acodec", "pcm_s16le", "-y", tempfile); if(runResults.ExitCode != 0) - throw new InvalidOperationException("Failure running ffmpeg for audio decode. here was its output:\r\n" + runResults.Text); + throw new InvalidOperationException($"Failure running ffmpeg for audio decode. here was its output:\r\n{runResults.Text}"); byte[] ret = File.ReadAllBytes(tempfile); if (ret.Length == 0) - throw new InvalidOperationException("Failure running ffmpeg for audio decode. here was its output:\r\n" + runResults.Text); + throw new InvalidOperationException($"Failure running ffmpeg for audio decode. here was its output:\r\n{runResults.Text}"); return ret; } finally @@ -163,7 +163,7 @@ namespace BizHawk.Emulation.DiscSystem string path = FindAudio(audioPath); if (path == null) { - throw new AudioDecoder_Exception("Could not find source audio for: " + Path.GetFileName(audioPath)); + throw new AudioDecoder_Exception($"Could not find source audio for: {Path.GetFileName(audioPath)}"); } return new FFMpeg().DecodeAudio(path); } diff --git a/BizHawk.Emulation.DiscSystem/DiscExceptions.cs b/BizHawk.Emulation.DiscSystem/DiscExceptions.cs index 5565f4d510..f3583bccf3 100644 --- a/BizHawk.Emulation.DiscSystem/DiscExceptions.cs +++ b/BizHawk.Emulation.DiscSystem/DiscExceptions.cs @@ -11,11 +11,11 @@ namespace BizHawk.Emulation.DiscSystem public class DiscReferenceException : Exception { public DiscReferenceException(string fname, Exception inner) - : base(string.Format("A disc attempted to reference a file which could not be accessed or loaded: {0}", fname), inner) + : base($"A disc attempted to reference a file which could not be accessed or loaded: {fname}", inner) { } public DiscReferenceException(string fname, string extrainfo) - : base(string.Format("A disc attempted to reference a file which could not be accessed or loaded:\n\n{0}\n\n{1}", fname, extrainfo)) + : base($"A disc attempted to reference a file which could not be accessed or loaded:\n\n{fname}\n\n{extrainfo}") { } } diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/RiffMaster.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/RiffMaster.cs index 7de03852fa..e8f2bd143d 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/RiffMaster.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/Blobs/RiffMaster.cs @@ -42,7 +42,7 @@ namespace BizHawk.Emulation.DiscSystem private static string ReadTag(BinaryReader br) { - return "" + br.ReadChar() + br.ReadChar() + br.ReadChar() + br.ReadChar(); + return $"{br.ReadChar()}{br.ReadChar()}{br.ReadChar()}{br.ReadChar()}"; } protected static void WriteTag(BinaryWriter bw, string tag) diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs index 49d85b95a3..b50d2976da 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs @@ -171,7 +171,7 @@ namespace BizHawk.Emulation.DiscSystem { int ret; if(!TryGetValue(key, out ret)) - throw new CCDParseException("Malformed or unexpected CCD format: missing required [Entry] key: " + key); + throw new CCDParseException($"Malformed or unexpected CCD format: missing required [Entry] key: {key}"); return ret; } } @@ -250,7 +250,7 @@ namespace BizHawk.Emulation.DiscSystem ccdf.DataTracksScrambled = discSection.FetchOrDefault(0, "DATATRACKSSCRAMBLED"); ccdf.CDTextLength = discSection.FetchOrDefault(0, "CDTEXTLENGTH"); - if (ccdf.DataTracksScrambled==1) throw new CCDParseException("Malformed CCD format: DataTracksScrambled=1 not supported. Please report this, so we can understand what it means."); + if (ccdf.DataTracksScrambled==1) throw new CCDParseException($"Malformed CCD format: {nameof(ccdf.DataTracksScrambled)}=1 not supported. Please report this, so we can understand what it means."); for (int i = 2; i < sections.Count; i++) { diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs index 53044c6d87..1eae6cfaf0 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs @@ -28,7 +28,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE public override string ToString() { - return string.Format("I#{0:D2} {1}", Number, FileMSF); + return $"I#{Number:D2} {FileMSF}"; } } @@ -72,7 +72,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE public CompiledCueFileType Type; public override string ToString() { - return string.Format("{0}: {1}", Type, Path.GetFileName(FullPath)); + return $"{Type}: {Path.GetFileName(FullPath)}"; } } @@ -109,11 +109,11 @@ namespace BizHawk.Emulation.DiscSystem.CUE { var idx = Indexes.Find((i) => i.Number == 1); if (idx == null) - return string.Format("T#{0:D2} NO INDEX 1", Number); + return $"T#{Number:D2} NO INDEX 1"; else { var indexlist = string.Join("|", Indexes); - return string.Format("T#{0:D2} {1}:{2} ({3})", Number, BlobIndex, idx.FileMSF, indexlist); + return $"T#{Number:D2} {BlobIndex}:{idx.FileMSF} ({indexlist})"; } } } @@ -223,7 +223,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE string choice = null; if (options.Count == 0) { - Error(string.Format("Couldn't resolve referenced cue file: {0} ; you can commonly repair the cue file yourself, or a file might be missing", f.Path)); + Error($"Couldn't resolve referenced cue file: {f.Path} ; you can commonly repair the cue file yourself, or a file might be missing"); //add a null entry to keep the count from being wrong later (quiets a warning) OUT_CompiledCueFiles.Add(null); return; @@ -232,7 +232,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE { choice = options[0]; if (options.Count > 1) - Warn("Multiple options resolving referenced cue file; choosing: " + Path.GetFileName(choice)); + Warn($"Multiple options resolving referenced cue file; choosing: {Path.GetFileName(choice)}"); } var cfi = new CompiledCueFile(); @@ -275,13 +275,13 @@ namespace BizHawk.Emulation.DiscSystem.CUE cfi.Type = CompiledCueFileType.ECM; if (!Disc.Blob_ECM.IsECM(choice)) { - Error("an ECM file was specified or detected, but it isn't a valid ECM file: " + Path.GetFileName(choice)); + Error($"an ECM file was specified or detected, but it isn't a valid ECM file: {Path.GetFileName(choice)}"); cfi.Type = CompiledCueFileType.Unknown; } } else { - Error("Unknown cue file type. Since it's likely an unsupported compression, this is an error: ", Path.GetFileName(choice)); + Error($"Unknown cue file type. Since it's likely an unsupported compression, this is an error: {Path.GetFileName(choice)}"); cfi.Type = CompiledCueFileType.Unknown; } @@ -497,4 +497,4 @@ namespace BizHawk.Emulation.DiscSystem.CUE } //class CompileCueJob -} //namespace BizHawk.Emulation.DiscSystem \ No newline at end of file +} //namespace BizHawk.Emulation.DiscSystem diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_File.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_File.cs index 7a55fead7b..442c501208 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_File.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_File.cs @@ -12,20 +12,20 @@ namespace BizHawk.Emulation.DiscSystem.CUE public static class Command { //TODO - record line number origin of command? Kind of nice but inessential - public class CATALOG { public string Value; public override string ToString() { return string.Format("CATALOG: {0}", Value); } } - public class CDTEXTFILE { public string Path; public override string ToString() { return string.Format("CDTEXTFILE: {0}", Path); } } - public class FILE { public string Path; public CueFileType Type; public override string ToString() { return string.Format("FILE ({0}): {1}", Type, Path); } } - public class FLAGS { public CueTrackFlags Flags; public override string ToString() { return string.Format("FLAGS {0}", Flags); } } - public class INDEX { public int Number; public Timestamp Timestamp; public override string ToString() { return string.Format("INDEX {0,2} {1}", Number, Timestamp); } } - public class ISRC { public string Value; public override string ToString() { return string.Format("ISRC: {0}", Value); } } - public class PERFORMER { public string Value; public override string ToString() { return string.Format("PERFORMER: {0}", Value); } } - public class POSTGAP { public Timestamp Length; public override string ToString() { return string.Format("POSTGAP: {0}", Length); } } - public class PREGAP { public Timestamp Length; public override string ToString() { return string.Format("PREGAP: {0}", Length); } } - public class REM { public string Value; public override string ToString() { return string.Format("REM: {0}", Value); } } - public class COMMENT { public string Value; public override string ToString() { return string.Format("COMMENT: {0}", Value); } } - public class SONGWRITER { public string Value; public override string ToString() { return string.Format("SONGWRITER: {0}", Value); } } - public class TITLE { public string Value; public override string ToString() { return string.Format("TITLE: {0}", Value); } } - public class TRACK { public int Number; public CueTrackType Type; public override string ToString() { return string.Format("TRACK {0,2} ({1})", Number, Type); } } + public class CATALOG { public string Value; public override string ToString() { return $"CATALOG: {Value}"; } } + public class CDTEXTFILE { public string Path; public override string ToString() { return $"CDTEXTFILE: {Path}"; } } + public class FILE { public string Path; public CueFileType Type; public override string ToString() { return $"FILE ({Type}): {Path}"; } } + public class FLAGS { public CueTrackFlags Flags; public override string ToString() { return $"FLAGS {Flags}"; } } + public class INDEX { public int Number; public Timestamp Timestamp; public override string ToString() { return $"INDEX {Number,2} {Timestamp}"; } } + public class ISRC { public string Value; public override string ToString() { return $"ISRC: {Value}"; } } + public class PERFORMER { public string Value; public override string ToString() { return $"PERFORMER: {Value}"; } } + public class POSTGAP { public Timestamp Length; public override string ToString() { return $"POSTGAP: {Length}"; } } + public class PREGAP { public Timestamp Length; public override string ToString() { return $"PREGAP: {Length}"; } } + public class REM { public string Value; public override string ToString() { return $"REM: {Value}"; } } + public class COMMENT { public string Value; public override string ToString() { return $"COMMENT: {Value}"; } } + public class SONGWRITER { public string Value; public override string ToString() { return $"SONGWRITER: {Value}"; } } + public class TITLE { public string Value; public override string ToString() { return $"TITLE: {Value}"; } } + public class TRACK { public int Number; public CueTrackType Type; public override string ToString() { return $"TRACK {Number,2} ({Type})"; } } } diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs index eb497a1318..f9e345dee7 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs @@ -306,7 +306,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE default: case CueTrackType.Mode2_2336: - throw new InvalidOperationException("Not supported: " + cct.TrackType); + throw new InvalidOperationException($"Not supported: {cct.TrackType}"); } ss.Blob = curr_blobInfo.Blob; diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs index 77eded7043..4ec9b7b19d 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Parse.cs @@ -170,7 +170,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE else switch (key) { default: - job.Warn("Unknown command: " + key); + job.Warn($"Unknown command: {key}"); break; case "CATALOG": @@ -204,7 +204,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE switch (strType) { default: - job.Error("Unknown FILE type: " + strType); + job.Error($"Unknown FILE type: {strType}"); ft = CueFileType.Unspecified; break; case "BINARY": ft = CueFileType.BINARY; break; @@ -229,7 +229,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE { case "DATA": default: - job.Warn("Unknown FLAG: " + flag); + job.Warn($"Unknown FLAG: {flag}"); break; case "DCP": cmd.Flags |= CueTrackFlags.DCP; break; case "4CH": cmd.Flags |= CueTrackFlags._4CH; break; @@ -253,7 +253,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE int indexnum; if (!int.TryParse(strindexnum, out indexnum) || indexnum < 0 || indexnum > 99) { - job.Error("Invalid INDEX number: " + strindexnum); + job.Error($"Invalid INDEX number: {strindexnum}"); break; } string str_timestamp = clp.ReadToken(); @@ -267,7 +267,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE if (!ts.Valid) { if (IN_Strict) - job.Error("Invalid INDEX timestamp: " + str_timestamp); + job.Error($"Invalid INDEX timestamp: {str_timestamp}"); break; } OUT_CueFile.Commands.Add(new CUE_File.Command.INDEX() { Number = indexnum, Timestamp = ts }); @@ -283,7 +283,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE { var isrc = clp.ReadToken(); if (isrc.Length != 12) - job.Warn("Invalid ISRC code ignored: " + isrc); + job.Warn($"Invalid ISRC code ignored: {isrc}"); else { OUT_CueFile.Commands.Add(OUT_CueFile.GlobalDiscInfo.ISRC = new CUE_File.Command.ISRC() { Value = isrc }); @@ -301,7 +301,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE var str_msf = clp.ReadToken(); var msf = new Timestamp(str_msf); if (!msf.Valid) - job.Error("Ignoring {0} with invalid length MSF: " + str_msf, key); + job.Error($"Ignoring {{0}} with invalid length MSF: {str_msf}", key); else { if (key == "POSTGAP") @@ -335,7 +335,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE int tracknum; if (!int.TryParse(str_tracknum, out tracknum) || tracknum < 1 || tracknum > 99) { - job.Error("Invalid TRACK number: " + str_tracknum); + job.Error($"Invalid TRACK number: {str_tracknum}"); break; } @@ -346,7 +346,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE switch (str_trackType.ToUpperInvariant()) { default: - job.Error("Unknown TRACK type: " + str_trackType); + job.Error($"Unknown TRACK type: {str_trackType}"); tt = CueTrackType.Unknown; break; case "AUDIO": tt = CueTrackType.Audio; break; @@ -372,7 +372,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE //add a comment OUT_CueFile.Commands.Add(new CUE_File.Command.COMMENT() { Value = remainder }); } - else job.Warn("Unknown text at end of line after processing command: " + key); + else job.Warn($"Unknown text at end of line after processing command: {key}"); } } //end cue parsing loop diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Synths.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Synths.cs index 558f084827..9eeabac3a2 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Synths.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Synths.cs @@ -127,7 +127,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE case CueTrackType.Mode2_2336: default: - throw new InvalidOperationException("Not supported: " + TrackType); + throw new InvalidOperationException($"Not supported: {TrackType}"); } //audio has no sector header but the others do diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs index 27699da2d1..c8ab3222ce 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs @@ -314,7 +314,7 @@ namespace BizHawk.Emulation.DiscSystem if (aFile.Header.Version[0] > 1) { - throw new MDSParseException("MDS Parse Error: Only MDS version 1.x is supported!\nDetected version: " + aFile.Header.Version[0] + "." + aFile.Header.Version[1]); + throw new MDSParseException($"MDS Parse Error: Only MDS version 1.x is supported!\nDetected version: {aFile.Header.Version[0]}.{aFile.Header.Version[1]}"); } // parse sessions @@ -477,11 +477,11 @@ namespace BizHawk.Emulation.DiscSystem if (f.FilenameOffset == 0 || string.Compare(fileName, "*.mdf", StringComparison.InvariantCultureIgnoreCase) == 0) { - fileName = dir + @"\" + Path.GetFileNameWithoutExtension(aFile.MDSPath) + ".mdf"; + fileName = $@"{dir}\{Path.GetFileNameWithoutExtension(aFile.MDSPath)}.mdf"; } else { - fileName = dir + @"\" + fileName; + fileName = $@"{dir}\{fileName}"; } track.ImageFileNamePaths.Add(fileName); @@ -527,44 +527,33 @@ namespace BizHawk.Emulation.DiscSystem aFile.ParsedSession.Add(session); } - // now build the TOC object - foreach (var se in aFile.ParsedSession) - { - // get the first and last tracks - int sTrack = se.StartTrack; - int eTrack = se.EndTrack; - - // get list of all tracks from aTracks for this session - var tracks = (from a in aTracks.Values - where a.TrackNo >= sTrack || a.TrackNo <= eTrack - orderby a.TrackNo - select a).ToList(); - - // create the TOC entries - foreach (var t in tracks) - { - ATOCEntry toc = new ATOCEntry(t.Point); - toc.ADR_Control = t.ADR_Control; - toc.AFrame = t.AFrame; - toc.AMin = t.AMin; - toc.ASec = t.ASec; - toc.EntryNum = t.TrackNo; - toc.PFrame = t.PFrame; - toc.PLBA = Convert.ToInt32(t.PLBA); - toc.PMin = t.PMin; - toc.Point = t.Point; - toc.PSec = t.PSec; - toc.SectorSize = t.SectorSize; - toc.Zero = t.Zero; - toc.TrackOffset = Convert.ToInt64(t.StartOffset); - toc.Session = se.SessionSequence; - toc.ImageFileNamePaths = t.ImageFileNamePaths; - toc.ExtraBlock = t.ExtraBlock; - toc.BlobIndex = t.BlobIndex; - aFile.TOCEntries.Add(toc); - } - - } + // now build the TOC object + foreach (var se in aFile.ParsedSession) + foreach (var t in aTracks.Values + .Where(a => se.StartTrack <= a.TrackNo && a.TrackNo <= se.EndTrack) + .OrderBy(a => a.TrackNo)) + { + aFile.TOCEntries.Add(new ATOCEntry(t.Point) + { + ADR_Control = t.ADR_Control, + AFrame = t.AFrame, + AMin = t.AMin, + ASec = t.ASec, + BlobIndex = t.BlobIndex, + EntryNum = t.TrackNo, + ExtraBlock = t.ExtraBlock, + ImageFileNamePaths = t.ImageFileNamePaths, + PFrame = t.PFrame, + PLBA = Convert.ToInt32(t.PLBA), + PMin = t.PMin, + Point = t.Point, + PSec = t.PSec, + SectorSize = t.SectorSize, + Session = se.SessionSequence, + TrackOffset = Convert.ToInt64(t.StartOffset), + Zero = t.Zero + }); + } return aFile; } @@ -632,7 +621,7 @@ namespace BizHawk.Emulation.DiscSystem foreach (var file in track.ImageFileNamePaths.Distinct()) { if (!File.Exists(file)) - throw new MDSParseException("Malformed MDS format: nonexistent image file: " + file); + throw new MDSParseException($"Malformed MDS format: nonexistent image file: {file}"); IBlob mdfBlob = null; long mdfLen = -1; @@ -656,7 +645,7 @@ namespace BizHawk.Emulation.DiscSystem { // wrap in zeropadadapter disc.DisposableResources.Add(mdfBlob); - BlobIndex[count] = mdfBlob; + BlobIndex[count++] = mdfBlob; } } } @@ -840,7 +829,7 @@ namespace BizHawk.Emulation.DiscSystem currBlobIndex++; mdfBlob = disc.DisposableResources[currBlobIndex] as Disc.Blob_RawFile; - int userSector = 2048; + //int userSector = 2048; switch (track.SectorSize) { case 2448: @@ -848,7 +837,7 @@ namespace BizHawk.Emulation.DiscSystem { Policy = IN_DiscMountPolicy }; - userSector = 2352; + //userSector = 2352; break; case 2048: default: @@ -856,10 +845,10 @@ namespace BizHawk.Emulation.DiscSystem { Policy = IN_DiscMountPolicy }; - userSector = 2048; + //userSector = 2048; break; - //throw new Exception("Not supported: Sector Size " + track.SectorSize); + //throw new Exception($"Not supported: Sector Size {track.SectorSize}"); } // configure blob diff --git a/BizHawk.Emulation.DiscSystem/DiscMountJob.cs b/BizHawk.Emulation.DiscSystem/DiscMountJob.cs index 7282d00f74..a2597e0d55 100644 --- a/BizHawk.Emulation.DiscSystem/DiscMountJob.cs +++ b/BizHawk.Emulation.DiscSystem/DiscMountJob.cs @@ -52,7 +52,7 @@ namespace BizHawk.Emulation.DiscSystem switch (IN_DiscInterface) { case DiscInterface.LibMirage: - throw new NotSupportedException("LibMirage not supported yet"); + throw new NotSupportedException($"{nameof(DiscInterface.LibMirage)} not supported yet"); case DiscInterface.BizHawk: RunBizHawk(); break; @@ -116,11 +116,10 @@ namespace BizHawk.Emulation.DiscSystem { //make a fake cue file to represent this iso file and rerun it as a cue string filebase = Path.GetFileName(infile); - cue_content = string.Format(@" - FILE ""{0}"" BINARY - TRACK 01 MODE1/2048 - INDEX 01 00:00:00", - filebase); + cue_content = $@" + FILE ""{filebase}"" BINARY + TRACK 01 MODE1/2048 + INDEX 01 00:00:00"; infile = Path.ChangeExtension(infile, ".cue"); goto RERUN; } diff --git a/BizHawk.Emulation.DiscSystem/DiscStream.cs b/BizHawk.Emulation.DiscSystem/DiscStream.cs index c2f8267b3a..fcc2106491 100644 --- a/BizHawk.Emulation.DiscSystem/DiscStream.cs +++ b/BizHawk.Emulation.DiscSystem/DiscStream.cs @@ -80,7 +80,7 @@ namespace BizHawk.Emulation.DiscSystem dsr.Policy.UserData2048Mode = DiscSectorReaderPolicy.EUserData2048Mode.AssumeMode2_Form1; break; default: - throw new NotSupportedException("Unsupported EDiscStreamView"); + throw new NotSupportedException($"Unsupported {nameof(EDiscStreamView)}"); } diff --git a/BizHawk.Emulation.DiscSystem/DiscTypes.cs b/BizHawk.Emulation.DiscSystem/DiscTypes.cs index fdce3047e7..4641a6f42b 100644 --- a/BizHawk.Emulation.DiscSystem/DiscTypes.cs +++ b/BizHawk.Emulation.DiscSystem/DiscTypes.cs @@ -138,7 +138,7 @@ namespace BizHawk.Emulation.DiscSystem get { if (!Valid) return "--:--:--"; - return string.Format("{0}{1:D2}:{2:D2}:{3:D2}", Negative ? '-' : '+', MIN, SEC, FRAC); + return $"{(Negative ? '-' : '+')}{MIN:D2}:{SEC:D2}:{FRAC:D2}"; } } diff --git a/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscStructure_From_DiscTOC_Job.cs b/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscStructure_From_DiscTOC_Job.cs index 6320c32d8f..14accab6d3 100644 --- a/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscStructure_From_DiscTOC_Job.cs +++ b/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscStructure_From_DiscTOC_Job.cs @@ -22,7 +22,7 @@ namespace BizHawk.Emulation.DiscSystem session.Number = 1; if (TOCRaw.FirstRecordedTrackNumber != 1) - throw new InvalidOperationException("Unsupported: FirstRecordedTrackNumber != 1"); + throw new InvalidOperationException($"Unsupported: {nameof(TOCRaw.FirstRecordedTrackNumber)} != 1"); //add a lead-in track session.Tracks.Add(new DiscStructure.Track() diff --git a/BizHawk.sln b/BizHawk.sln index 8e9fe65e66..5c6cd2044b 100644 --- a/BizHawk.sln +++ b/BizHawk.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.28307.136 +VisualStudioVersion = 15.0.27703.2047 MinimumVisualStudioVersion = 12.0.31101.0 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Version", "Version\Version.csproj", "{0CE8B337-08E3-4602-BF10-C4D4C75D2F13}" EndProject @@ -64,189 +64,69 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Debug|x64.ActiveCfg = Debug|Any CPU - {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Debug|x64.Build.0 = Debug|Any CPU - {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Debug|x86.ActiveCfg = Debug|Any CPU - {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Debug|x86.Build.0 = Debug|Any CPU {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Release|Any CPU.ActiveCfg = Release|Any CPU {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Release|Any CPU.Build.0 = Release|Any CPU - {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Release|x64.ActiveCfg = Release|Any CPU - {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Release|x64.Build.0 = Release|Any CPU - {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Release|x86.ActiveCfg = Release|Any CPU - {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}.Release|x86.Build.0 = Release|Any CPU {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Debug|x64.ActiveCfg = Debug|Any CPU - {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Debug|x64.Build.0 = Debug|Any CPU - {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Debug|x86.ActiveCfg = Debug|Any CPU - {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Debug|x86.Build.0 = Debug|Any CPU {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Release|Any CPU.ActiveCfg = Release|Any CPU {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Release|Any CPU.Build.0 = Release|Any CPU - {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Release|x64.ActiveCfg = Release|Any CPU - {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Release|x64.Build.0 = Release|Any CPU - {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Release|x86.ActiveCfg = Release|Any CPU - {24A0AA3C-B25F-4197-B23D-476D6462DBA0}.Release|x86.Build.0 = Release|Any CPU {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Debug|x64.ActiveCfg = Debug|Any CPU - {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Debug|x64.Build.0 = Debug|Any CPU - {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Debug|x86.ActiveCfg = Debug|Any CPU - {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Debug|x86.Build.0 = Debug|Any CPU {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Release|Any CPU.ActiveCfg = Release|Any CPU {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Release|Any CPU.Build.0 = Release|Any CPU - {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Release|x64.ActiveCfg = Release|Any CPU - {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Release|x64.Build.0 = Release|Any CPU - {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Release|x86.ActiveCfg = Release|Any CPU - {866F8D13-0678-4FF9-80A4-A3993FD4D8A3}.Release|x86.Build.0 = Release|Any CPU {DD448B37-BA3F-4544-9754-5406E8094723}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DD448B37-BA3F-4544-9754-5406E8094723}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DD448B37-BA3F-4544-9754-5406E8094723}.Debug|x64.ActiveCfg = Debug|Any CPU - {DD448B37-BA3F-4544-9754-5406E8094723}.Debug|x64.Build.0 = Debug|Any CPU - {DD448B37-BA3F-4544-9754-5406E8094723}.Debug|x86.ActiveCfg = Debug|Any CPU - {DD448B37-BA3F-4544-9754-5406E8094723}.Debug|x86.Build.0 = Debug|Any CPU {DD448B37-BA3F-4544-9754-5406E8094723}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD448B37-BA3F-4544-9754-5406E8094723}.Release|Any CPU.Build.0 = Release|Any CPU - {DD448B37-BA3F-4544-9754-5406E8094723}.Release|x64.ActiveCfg = Release|Any CPU - {DD448B37-BA3F-4544-9754-5406E8094723}.Release|x64.Build.0 = Release|Any CPU - {DD448B37-BA3F-4544-9754-5406E8094723}.Release|x86.ActiveCfg = Release|Any CPU - {DD448B37-BA3F-4544-9754-5406E8094723}.Release|x86.Build.0 = Release|Any CPU {C4366030-6D03-424B-AE53-F4F43BB217C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C4366030-6D03-424B-AE53-F4F43BB217C3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C4366030-6D03-424B-AE53-F4F43BB217C3}.Debug|x64.ActiveCfg = Debug|Any CPU - {C4366030-6D03-424B-AE53-F4F43BB217C3}.Debug|x64.Build.0 = Debug|Any CPU - {C4366030-6D03-424B-AE53-F4F43BB217C3}.Debug|x86.ActiveCfg = Debug|Any CPU - {C4366030-6D03-424B-AE53-F4F43BB217C3}.Debug|x86.Build.0 = Debug|Any CPU {C4366030-6D03-424B-AE53-F4F43BB217C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {C4366030-6D03-424B-AE53-F4F43BB217C3}.Release|Any CPU.Build.0 = Release|Any CPU - {C4366030-6D03-424B-AE53-F4F43BB217C3}.Release|x64.ActiveCfg = Release|Any CPU - {C4366030-6D03-424B-AE53-F4F43BB217C3}.Release|x64.Build.0 = Release|Any CPU - {C4366030-6D03-424B-AE53-F4F43BB217C3}.Release|x86.ActiveCfg = Release|Any CPU - {C4366030-6D03-424B-AE53-F4F43BB217C3}.Release|x86.Build.0 = Release|Any CPU {F51946EA-827F-4D82-B841-1F2F6D060312}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F51946EA-827F-4D82-B841-1F2F6D060312}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F51946EA-827F-4D82-B841-1F2F6D060312}.Debug|x64.ActiveCfg = Debug|Any CPU - {F51946EA-827F-4D82-B841-1F2F6D060312}.Debug|x64.Build.0 = Debug|Any CPU - {F51946EA-827F-4D82-B841-1F2F6D060312}.Debug|x86.ActiveCfg = Debug|Any CPU - {F51946EA-827F-4D82-B841-1F2F6D060312}.Debug|x86.Build.0 = Debug|Any CPU {F51946EA-827F-4D82-B841-1F2F6D060312}.Release|Any CPU.ActiveCfg = Release|Any CPU {F51946EA-827F-4D82-B841-1F2F6D060312}.Release|Any CPU.Build.0 = Release|Any CPU - {F51946EA-827F-4D82-B841-1F2F6D060312}.Release|x64.ActiveCfg = Release|Any CPU - {F51946EA-827F-4D82-B841-1F2F6D060312}.Release|x64.Build.0 = Release|Any CPU - {F51946EA-827F-4D82-B841-1F2F6D060312}.Release|x86.ActiveCfg = Release|Any CPU - {F51946EA-827F-4D82-B841-1F2F6D060312}.Release|x86.Build.0 = Release|Any CPU {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|x64.ActiveCfg = Debug|Any CPU - {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|x64.Build.0 = Debug|Any CPU - {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|x86.ActiveCfg = Debug|Any CPU - {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|x86.Build.0 = Debug|Any CPU {E1A23168-B571-411C-B360-2229E7225E0E}.Release|Any CPU.ActiveCfg = Release|Any CPU {E1A23168-B571-411C-B360-2229E7225E0E}.Release|Any CPU.Build.0 = Release|Any CPU - {E1A23168-B571-411C-B360-2229E7225E0E}.Release|x64.ActiveCfg = Release|Any CPU - {E1A23168-B571-411C-B360-2229E7225E0E}.Release|x64.Build.0 = Release|Any CPU - {E1A23168-B571-411C-B360-2229E7225E0E}.Release|x86.ActiveCfg = Release|Any CPU - {E1A23168-B571-411C-B360-2229E7225E0E}.Release|x86.Build.0 = Release|Any CPU {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Debug|x64.ActiveCfg = Debug|Any CPU - {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Debug|x64.Build.0 = Debug|Any CPU - {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Debug|x86.ActiveCfg = Debug|Any CPU - {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Debug|x86.Build.0 = Debug|Any CPU {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Release|Any CPU.ActiveCfg = Release|Any CPU {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Release|Any CPU.Build.0 = Release|Any CPU - {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Release|x64.ActiveCfg = Release|Any CPU - {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Release|x64.Build.0 = Release|Any CPU - {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Release|x86.ActiveCfg = Release|Any CPU - {197D4314-8A9F-49BA-977D-54ACEFAEB6BA}.Release|x86.Build.0 = Release|Any CPU {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Debug|x64.ActiveCfg = Debug|Any CPU - {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Debug|x64.Build.0 = Debug|Any CPU - {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Debug|x86.ActiveCfg = Debug|Any CPU - {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Debug|x86.Build.0 = Debug|Any CPU {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Release|Any CPU.ActiveCfg = Release|Any CPU {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Release|Any CPU.Build.0 = Release|Any CPU - {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Release|x64.ActiveCfg = Release|Any CPU - {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Release|x64.Build.0 = Release|Any CPU - {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Release|x86.ActiveCfg = Release|Any CPU - {9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Release|x86.Build.0 = Release|Any CPU {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Debug|x64.ActiveCfg = Debug|Any CPU - {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Debug|x64.Build.0 = Debug|Any CPU - {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Debug|x86.ActiveCfg = Debug|Any CPU - {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Debug|x86.Build.0 = Debug|Any CPU {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Release|Any CPU.ActiveCfg = Release|Any CPU {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Release|Any CPU.Build.0 = Release|Any CPU - {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Release|x64.ActiveCfg = Release|Any CPU - {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Release|x64.Build.0 = Release|Any CPU - {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Release|x86.ActiveCfg = Release|Any CPU - {5160CFB1-5389-47C1-B7F6-8A0DC97641EE}.Release|x86.Build.0 = Release|Any CPU {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Debug|x64.ActiveCfg = Debug|Any CPU - {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Debug|x64.Build.0 = Debug|Any CPU - {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Debug|x86.ActiveCfg = Debug|Any CPU - {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Debug|x86.Build.0 = Debug|Any CPU {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Release|Any CPU.Build.0 = Release|Any CPU - {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Release|x64.ActiveCfg = Release|Any CPU - {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Release|x64.Build.0 = Release|Any CPU - {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Release|x86.ActiveCfg = Release|Any CPU - {2D2890A8-C338-4439-AD8B-CB9EE85A94F9}.Release|x86.Build.0 = Release|Any CPU {337CA23E-65E7-44E1-9411-97EE08BB8116}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {337CA23E-65E7-44E1-9411-97EE08BB8116}.Debug|Any CPU.Build.0 = Debug|Any CPU - {337CA23E-65E7-44E1-9411-97EE08BB8116}.Debug|x64.ActiveCfg = Debug|Any CPU - {337CA23E-65E7-44E1-9411-97EE08BB8116}.Debug|x64.Build.0 = Debug|Any CPU - {337CA23E-65E7-44E1-9411-97EE08BB8116}.Debug|x86.ActiveCfg = Debug|Any CPU - {337CA23E-65E7-44E1-9411-97EE08BB8116}.Debug|x86.Build.0 = Debug|Any CPU {337CA23E-65E7-44E1-9411-97EE08BB8116}.Release|Any CPU.ActiveCfg = Release|Any CPU {337CA23E-65E7-44E1-9411-97EE08BB8116}.Release|Any CPU.Build.0 = Release|Any CPU - {337CA23E-65E7-44E1-9411-97EE08BB8116}.Release|x64.ActiveCfg = Release|Any CPU - {337CA23E-65E7-44E1-9411-97EE08BB8116}.Release|x64.Build.0 = Release|Any CPU - {337CA23E-65E7-44E1-9411-97EE08BB8116}.Release|x86.ActiveCfg = Release|Any CPU - {337CA23E-65E7-44E1-9411-97EE08BB8116}.Release|x86.Build.0 = Release|Any CPU {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Debug|x64.ActiveCfg = Debug|Any CPU - {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Debug|x64.Build.0 = Debug|Any CPU - {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Debug|x86.ActiveCfg = Debug|Any CPU - {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Debug|x86.Build.0 = Debug|Any CPU {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Release|Any CPU.ActiveCfg = Release|Any CPU {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Release|Any CPU.Build.0 = Release|Any CPU - {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Release|x64.ActiveCfg = Release|Any CPU - {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Release|x64.Build.0 = Release|Any CPU - {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Release|x86.ActiveCfg = Release|Any CPU - {E6B436B1-A3CD-4C9A-8F76-5D7154726884}.Release|x86.Build.0 = Release|Any CPU {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Debug|x64.ActiveCfg = Debug|Any CPU - {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Debug|x86.ActiveCfg = Debug|Any CPU {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Release|Any CPU.ActiveCfg = Release|Any CPU {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Release|Any CPU.Build.0 = Release|Any CPU - {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Release|x64.ActiveCfg = Release|Any CPU - {B95649F5-A0AE-41EB-B62B-578A2AFF5E18}.Release|x86.ActiveCfg = Release|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|x64.ActiveCfg = Debug|Any CPU - {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|x64.Build.0 = Debug|Any CPU - {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|x86.ActiveCfg = Debug|Any CPU - {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|x86.Build.0 = Debug|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Any CPU.Build.0 = Release|Any CPU - {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|x64.ActiveCfg = Release|Any CPU - {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|x64.Build.0 = Release|Any CPU - {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|x86.ActiveCfg = Release|Any CPU - {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|x86.Build.0 = Release|Any CPU {8E522778-7A2C-4364-BDCE-0BA5623828E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8E522778-7A2C-4364-BDCE-0BA5623828E1}.Debug|Any CPU.Build.0 = Debug|Any CPU {8E522778-7A2C-4364-BDCE-0BA5623828E1}.Debug|x64.ActiveCfg = Debug|Any CPU diff --git a/Bizware/BizHawk.Bizware.BizwareGL.GdiPlus/GdiPlusGuiRenderer.cs b/Bizware/BizHawk.Bizware.BizwareGL.GdiPlus/GdiPlusGuiRenderer.cs index 06ed24b922..9c9f5f6b72 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL.GdiPlus/GdiPlusGuiRenderer.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL.GdiPlus/GdiPlusGuiRenderer.cs @@ -146,7 +146,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus public void End() { if (!IsActive) - throw new InvalidOperationException("GuiRenderer is not active!"); + throw new InvalidOperationException($"{nameof(GuiRenderer)} is not active!"); IsActive = false; if (CurrentImageAttributes != null) { @@ -202,7 +202,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus var tw = tex.Opaque as IGL_GdiPlus.TextureWrapper; //TODO - we can support bicubic for the final presentation.. if ((int)tw.MagFilter != (int)tw.MinFilter) - throw new InvalidOperationException("tw.MagFilter != tw.MinFilter"); + throw new InvalidOperationException($"{nameof(tw)}.{nameof(tw.MagFilter)} != {nameof(tw)}.{nameof(tw.MinFilter)}"); if (tw.MagFilter == TextureMagFilter.Linear) g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear; if (tw.MagFilter == TextureMagFilter.Nearest) @@ -240,7 +240,17 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus g.Transform = new sd.Drawing2D.Matrix(mat.M11, mat.M12, mat.M21, mat.M22, mat.M41, mat.M42); } + unsafe void DrawInternal(Art art, float x, float y, float w, float h) + { + DrawInternal(art.BaseTexture, x, y, w, h, art.u0, art.v0, art.u1, art.v1); + } + unsafe void DrawInternal(Texture2d tex, float x, float y, float w, float h) + { + DrawInternal(tex, x, y, w, h, 0, 0, 1, 1); + } + + unsafe void DrawInternal(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1) { var g = Gdi.GetCurrentGraphics(); PrepDraw(g, tex); @@ -253,9 +263,16 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus new sd.PointF(x,y+h), }; + float sx = tex.Width * u0; + float sy = tex.Height * v0; + float sx2 = tex.Width * u1; + float sy2 = tex.Height * v1; + float sw = sx2 - sx; + float sh = sy2 - sy; + var tw = tex.Opaque as IGL_GdiPlus.TextureWrapper; g.PixelOffsetMode = sd.Drawing2D.PixelOffsetMode.Half; - g.DrawImage(tw.SDBitmap, destPoints, new sd.RectangleF(0, 0, tex.Width, tex.Height), sd.GraphicsUnit.Pixel, CurrentImageAttributes); + g.DrawImage(tw.SDBitmap, destPoints, new sd.RectangleF(sx, sy, sw, sh), sd.GraphicsUnit.Pixel, CurrentImageAttributes); g.Transform = new sd.Drawing2D.Matrix(); //.Reset() doesnt work ? ? } diff --git a/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs b/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs index 349bc67819..9a5eca933a 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs @@ -183,9 +183,9 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK //if the shaders arent available, the pipeline isn't either if (!vertexShader.Available || !fragmentShader.Available) { - string errors = string.Format("Vertex Shader:\r\n {0} \r\n-------\r\nFragment Shader:\r\n{1}", vertexShader.Errors, fragmentShader.Errors); + string errors = $"Vertex Shader:\r\n {vertexShader.Errors} \r\n-------\r\nFragment Shader:\r\n{fragmentShader.Errors}"; if (required) - throw new InvalidOperationException("Couldn't build required GL pipeline:\r\n" + errors); + throw new InvalidOperationException($"Couldn't build required GL pipeline:\r\n{errors}"); var pipeline = new Pipeline(this, null, false, null, null, null); pipeline.Errors = errors; return pipeline; @@ -246,14 +246,14 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK if (errcode != ErrorCode.NoError) if (required) - throw new InvalidOperationException("Error creating pipeline (error returned from glLinkProgram): " + errcode + "\r\n\r\n" + resultLog); + throw new InvalidOperationException($"Error creating pipeline (error returned from glLinkProgram): {errcode}\r\n\r\n{resultLog}"); else success = false; int linkStatus; GL.GetProgram(pid, GetProgramParameterName.LinkStatus, out linkStatus); if (linkStatus == 0) if (required) - throw new InvalidOperationException("Error creating pipeline (link status false returned from glLinkProgram): " + "\r\n\r\n" + resultLog); + throw new InvalidOperationException($"Error creating pipeline (link status false returned from glLinkProgram): \r\n\r\n{resultLog}"); else success = false; //need to work on validation. apparently there are some weird caveats to glValidate which make it complicated and possibly excuses (barely) the intel drivers' dysfunctional operation @@ -271,11 +271,11 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK //errcode = GL.GetError(); //resultLog = GL.GetProgramInfoLog(pid); //if (errcode != ErrorCode.NoError) - // throw new InvalidOperationException("Error creating pipeline (error returned from glValidateProgram): " + errcode + "\r\n\r\n" + resultLog); + // throw new InvalidOperationException($"Error creating pipeline (error returned from glValidateProgram): {errcode}\r\n\r\n{resultLog}"); //int validateStatus; //GL.GetProgram(pid, GetProgramParameterName.ValidateStatus, out validateStatus); //if (validateStatus == 0) - // throw new InvalidOperationException("Error creating pipeline (validateStatus status false returned from glValidateProgram): " + "\r\n\r\n" + resultLog); + // throw new InvalidOperationException($"Error creating pipeline (validateStatus status false returned from glValidateProgram): \r\n\r\n{resultLog}"); //set the program to active, in case we need to set sampler uniforms on it GL.UseProgram(pid); @@ -548,7 +548,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK GL.DrawBuffers(1, buffers); if (GL.Ext.CheckFramebufferStatus(FramebufferTarget.Framebuffer) != FramebufferErrorCode.FramebufferComplete) - throw new InvalidOperationException("Error creating framebuffer (at CheckFramebufferStatus)"); + throw new InvalidOperationException($"Error creating framebuffer (at {nameof(GL.Ext.CheckFramebufferStatus)})"); //since we're done configuring unbind this framebuffer, to return to the default GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, 0); @@ -724,7 +724,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK errcode = GL.GetError(); if (errcode != ErrorCode.NoError) if (required) - throw new InvalidOperationException("Error compiling shader (from previous operation) " + errcode); + throw new InvalidOperationException($"Error compiling shader (from previous operation) {errcode}"); else success = false; GL.ShaderSource(sid, source); @@ -732,7 +732,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK errcode = GL.GetError(); if (errcode != ErrorCode.NoError) if (required) - throw new InvalidOperationException("Error compiling shader (ShaderSource) " + errcode); + throw new InvalidOperationException($"Error compiling shader ({nameof(GL.ShaderSource)}) {errcode}"); else success = false; GL.CompileShader(sid); @@ -742,7 +742,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK if (errcode != ErrorCode.NoError) { - string message = "Error compiling shader (CompileShader) " + errcode + "\r\n\r\n" + resultLog; + string message = $"Error compiling shader ({nameof(GL.CompileShader)}) {errcode}\r\n\r\n{resultLog}"; if (required) throw new InvalidOperationException(message); else @@ -757,7 +757,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK if (n == 0) if (required) - throw new InvalidOperationException("Error compiling shader (CompileShader )" + "\r\n\r\n" + resultLog); + throw new InvalidOperationException($"Error compiling shader ({nameof(GL.GetShader)})\r\n\r\n{resultLog}"); else success = false; return success; diff --git a/Bizware/BizHawk.Bizware.BizwareGL.SlimDX/IGL_SlimDX9.cs b/Bizware/BizHawk.Bizware.BizwareGL.SlimDX/IGL_SlimDX9.cs index e437875303..b8d48b4981 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL.SlimDX/IGL_SlimDX9.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL.SlimDX/IGL_SlimDX9.cs @@ -210,7 +210,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX } catch (Exception ex) { - throw new InvalidOperationException("Error compiling shader: " + errors, ex); + throw new InvalidOperationException($"Error compiling shader: {errors}", ex); } sw.ps = new PixelShader(dev, bytecode); @@ -266,7 +266,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX } catch (Exception ex) { - throw new InvalidOperationException("Error compiling shader: " + errors, ex); + throw new InvalidOperationException($"Error compiling shader: {errors}", ex); } sw.vs = new VertexShader(dev, bytecode); @@ -381,9 +381,9 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX { if (!vertexShader.Available || !fragmentShader.Available) { - string errors = string.Format("Vertex Shader:\r\n {0} \r\n-------\r\nFragment Shader:\r\n{1}", vertexShader.Errors, fragmentShader.Errors); + string errors = $"Vertex Shader:\r\n {vertexShader.Errors} \r\n-------\r\nFragment Shader:\r\n{fragmentShader.Errors}"; if (required) - throw new InvalidOperationException("Couldn't build required GL pipeline:\r\n" + errors); + throw new InvalidOperationException($"Couldn't build required GL pipeline:\r\n{errors}"); var pipeline = new Pipeline(this, null, false, null, null, null); pipeline.Errors = errors; return pipeline; @@ -466,11 +466,11 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX var handle = tuple.Item2; var descr = ct.GetConstantDescription(handle); - //Console.WriteLine("D3D UNIFORM: " + descr.Name); + //Console.WriteLine($"D3D UNIFORM: {descr.Name}"); if (descr.StructMembers != 0) { - string newprefix = prefix + descr.Name + "."; + string newprefix = $"{prefix}{descr.Name}."; for (int j = 0; j < descr.StructMembers; j++) { var subhandle = ct.GetConstant(handle, j); @@ -490,7 +490,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX { string key = name.TrimStart('$'); if (descr.Rows != 1) - key = key + "[0]"; + key += "[0]"; if (fs.MapCodeToNative != null && ct == fsct) if (fs.MapCodeToNative.ContainsKey(key)) name = fs.MapCodeToNative[key]; if (vs.MapCodeToNative != null && ct == vsct) if (vs.MapCodeToNative.ContainsKey(key)) name = vs.MapCodeToNative[key]; } diff --git a/Bizware/BizHawk.Bizware.BizwareGL/Art.cs b/Bizware/BizHawk.Bizware.BizwareGL/Art.cs index 5992872e23..13db7e68a6 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/Art.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/Art.cs @@ -5,6 +5,16 @@ namespace BizHawk.Bizware.BizwareGL /// public class Art { + //bleh, didnt mean to have this here, but I need it now + public Art(Texture2d tex) + { + BaseTexture = tex; + u1 = 1; + v1 = 1; + Width = tex.Width; + Height = tex.Height; + } + internal Art(ArtManager owner) { Owner = owner; diff --git a/Bizware/BizHawk.Bizware.BizwareGL/ArtManager.cs b/Bizware/BizHawk.Bizware.BizwareGL/ArtManager.cs index 0f5e32f5be..768c789a4b 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/ArtManager.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/ArtManager.cs @@ -27,7 +27,7 @@ namespace BizHawk.Bizware.BizwareGL public void Open() { AssertIsOpen(false); - if (IsClosedForever) throw new InvalidOperationException("ArtManager instance has been closed forever!"); + if (IsClosedForever) throw new InvalidOperationException($"{nameof(ArtManager)} instance has been closed forever!"); IsOpened = true; } @@ -140,7 +140,7 @@ namespace BizHawk.Bizware.BizwareGL /// /// Throws an exception if the instance is not open /// - private void AssertIsOpen(bool state) { if (IsOpened != state) throw new InvalidOperationException("ArtManager instance is not open!"); } + private void AssertIsOpen(bool state) { if (IsOpened != state) throw new InvalidOperationException($"{nameof(ArtManager)} instance is not open!"); } public IGL Owner { get; private set; } diff --git a/Bizware/BizHawk.Bizware.BizwareGL/BitmapBuffer.cs b/Bizware/BizHawk.Bizware.BizwareGL/BitmapBuffer.cs index df5fc3591a..725899ac7a 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/BitmapBuffer.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/BitmapBuffer.cs @@ -42,7 +42,7 @@ namespace BizHawk.Bizware.BizwareGL public BitmapData LockBits() //TODO - add read/write semantic, for wraps { if(CurrLock != null) - throw new InvalidOperationException("BitmapBuffer can only be locked once!"); + throw new InvalidOperationException($"{nameof(BitmapBuffer)} can only be locked once!"); if (WrappedBitmap != null) { diff --git a/Bizware/BizHawk.Bizware.BizwareGL/CGC.cs b/Bizware/BizHawk.Bizware.BizwareGL/CGC.cs index 572ed175f8..3b0f0de6df 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/CGC.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/CGC.cs @@ -21,7 +21,7 @@ namespace BizHawk.Bizware.BizwareGL private static string[] Escape(IEnumerable args) { - return args.Select(s => s.Contains(" ") ? string.Format("\"{0}\"", s) : s).ToArray(); + return args.Select(s => s.Contains(" ") ? $"\"{s}\"" : s).ToArray(); } public class Results @@ -105,7 +105,7 @@ namespace BizHawk.Bizware.BizwareGL if (hlslHacks) { - ret.Code = rxHlslSamplerCrashWorkaround.Replace(ret.Code, m => string.Format("({0}uniform sampler2D{1})", m.Groups[1].Value, m.Groups[3].Value)); + ret.Code = rxHlslSamplerCrashWorkaround.Replace(ret.Code, m => $"({m.Groups[1].Value}uniform sampler2D{m.Groups[3].Value})"); } //make variable name map diff --git a/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs b/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs index 9ecf4b5e5d..1d94786675 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/GuiRenderer.cs @@ -180,7 +180,7 @@ namespace BizHawk.Bizware.BizwareGL public void End() { if (!IsActive) - throw new InvalidOperationException("GuiRenderer is not active!"); + throw new InvalidOperationException($"{nameof(GuiRenderer)} is not active!"); IsActive = false; } @@ -224,7 +224,7 @@ namespace BizHawk.Bizware.BizwareGL unsafe void DrawInternal(Texture2d tex, float x, float y, float w, float h) { - Art art = new Art(null); + Art art = new Art((ArtManager)null); art.Width = w; art.Height = h; art.u0 = art.v0 = 0; diff --git a/Bizware/BizHawk.Bizware.BizwareGL/RenderTarget.cs b/Bizware/BizHawk.Bizware.BizwareGL/RenderTarget.cs index a71460c7ff..7eb44d6f5e 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/RenderTarget.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/RenderTarget.cs @@ -15,7 +15,7 @@ namespace BizHawk.Bizware.BizwareGL public override string ToString() { - return string.Format("GL RT: {0}x{1}", Texture2d.Width, Texture2d.Height); + return $"GL RT: {Texture2d.Width}x{Texture2d.Height}"; } public object Opaque { get; private set; } diff --git a/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs b/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs index d221d9f8d8..4b0c14564e 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/RetroShader.cs @@ -26,8 +26,8 @@ namespace BizHawk.Bizware.BizwareGL VertexLayout.Close(); string defines = "#define TEXCOORD TEXCOORD0\r\n"; //maybe not safe.. - string vsSource = "#define VERTEX\r\n" + defines + source; - string psSource = "#define FRAGMENT\r\n" + defines + source; + string vsSource = $"#define VERTEX\r\n{defines}{source}"; + string psSource = $"#define FRAGMENT\r\n{defines}{source}"; var vs = owner.CreateVertexShader(true, vsSource, "main_vertex", debug); var ps = owner.CreateFragmentShader(true, psSource, "main_fragment", debug); Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug, "retro"); diff --git a/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs b/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs index bb91f8b845..2f385ab56f 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL/Texture2d.cs @@ -37,7 +37,7 @@ namespace BizHawk.Bizware.BizwareGL public override string ToString() { - return string.Format("GL Tex: {0}x{1}", Width, Height); + return $"GL Tex: {Width}x{Height}"; } public void LoadFrom(BitmapBuffer buffer) diff --git a/README.md b/README.md index 05d9dd6cda..a28abebc08 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,319 @@ # BizHawk -BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as fullscreen, rewind, and joypad support in addition to rerecording and debugging tools for all system cores. +A multi-system emulator written in C#. As well as quality-of-life features for casual players, it also has recording/playback and debugging tools, making it the first choice for TASers (Tool-Assisted Speedrunners). -[Release Notes](http://tasvideos.org/Bizhawk/ReleaseHistory.html) +[![unique systems emulated | 27](https://img.shields.io/badge/unique_systems_emulated-27-darkgreen.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAFqklEQVR4nO2aa6hVRRTH973XMkvEnmRc6VansvY9+8z6/Svs+UGCMqEHiKRWFPShd0bZA3tQGZplhRVRgb2MIkgyikIp0IroEtGDCOlhaGkvS8tKTa99uPvU8Tj73H2e2wvnD/Npz16zfjOzZ6+ZNUHQVltttdXW0JSkIyTNAR51zp2VtT8tUy6XGwXcK+lvSTtKys1Z+9ZsdQIXS1pbBr5D0g5gM5DL2smmyDl3MtDnAy/rhCVZ+9pQ9fb2jpX0PNA/GHyxmNnpWftdtyTtLek2YFNa8JLymaQ9smaoVR3AFGBVDeCls+DqrEGqliSAFfWAl5T148aN2z9rplSKouggSU9K2tYg+OKC+EjWbBWVy+WGS7pe0oYaITcAi4EXge89z/+RlM+a0ytJkyStrGN0l+Xz+X2L9sIw3BN4wlN3aRAEHRmi7izgGOCNOqf2r8650R7zwyR95FkQz245aLny+fy+wEOStjbg234xqR0zu9VT/8tcLje8lbyl6pJ0OfBTAxe4p5Mak3SD7x0zu6mFzAMCJgCf1DjK/cBzwJnAeEm3lCyW3wRB0OVrU9LrCTY3hmF4cEvA8/n84cDL1YSvng6YWW4XEPBH/PyBIAg6y+AvHcTmwqaCh2E4ErhH0l91TvE1QRAM87UhaUEJ0HvxlL8WWDJYhwPbzey4ZrB3mtlFwHeN+MaBN5IaMrOpg3w2K4D7JL3kGwjgvaCRv0UzOxF4vxHgJU72JbUHzEx4b6uZTS6tG0XRYZK+9tSdVjd4FEXdwLPA9kbCF0fSN1V7enr2kvRFwjv3JnTYeE/91VEU7VMTeHd39whgVnExalYBvov39R1BEATOuR5gWYX645N8TgiT76qWvcPMJkv6ppngnrI2HvWKG6UaOuBPMzs0FbmZFSS93WJwX/kKmO6c63HOHV8W+3tHFFCFTltUETzepj6mgV1V1vBrwjDczwN4R3FEgQmlzyQdAHxcoQM2JbEPA64DftsNwIvOzvA5GobhnpLWx3W2x/HAbODxwfwHfvRN94lKWGkz7oAzk0YrDohqsTmrdLqMU3IcnXkBLk7g75L0Q5X2Nki6NgiCjkDSHsA8YHPWkIN0QJ9vS2tm51dhZxvwRBRFB5WO/P01OvW7pAXAIjX4LK9CWeqcOzIIBo7TzOyytPEIsFwSvu/n1ypHoh9YaGaHlNh4sIUzoR/4A9iSsv4qYEqQFP9Xs9IDPznnTiq3EScrf4zrbJY0HzgPeK5VHePxdZOk27u7u0ckrB3/dcCjVRiem2RHA3vx14tTNNYwDWRpWgneDyzq7e0dWxG8KDM7MO1nACyuYMo7xYAzWgjf55w7ORV4mZMzUjaw3fcJDCY1//e6Nv5Ndg7mi1dxNJU2+Pmg2obM7OwmjfhmSXNzudyomsDLnJyYstG3JB1QjW1gdoPB+yW90vDLEJJeq9Dot5LODao4TooPTRbVczjqKZ82Lf8fRdHRCRHhutI0VBoBVzb40OQX4Kog4bC0YZI03zP6y2uwM61B4FuBh31b4abIOTdau24utpnZsVWa6pD0bp3wS6Mo6m0KaCXJk2AA3kyonvhHAE6tEXylc+6cJuGlUpc8WVZJk4oVcrnccOA6Se8ECZ2ggROZahbAjcCNWSYy/5OZneZxfg1wAXCJds7tX1H+fhiGIyU9kwY8PslZKGlMFqyJ0kB2Jc3I/az/Y4NOM7tQCZcZPeXdZqWr6pZzrkcp83zA55LmSPogJfhqM5sa7E63N3ySdHedK3l5+dPM7qw5M9Nqxd/ymnrB423qC6mTEbuTgOl1wn8o6ZSsOepRZ41Hz+skXRok3OYYUioUCiekzQQDW4B5CTe5hq6Ap1LAv1ooFI7K2temSNIYSRuTfoPAGVn72HTFUWBpHmC9pGs0hK+nV61CoWBmditw1ZC5kd1WW2211dau+hdChUiZwhqSBAAAAABJRU5ErkJggg==&style=popout)](#cores) +[![GitHub latest release](https://img.shields.io/github/release/TASVideos/BizHawk.svg?logo=github&logoColor=333333&style=popout)](https://github.com/TASVideos/BizHawk/releases/latest) +[![dev builds | AppVeyor](https://img.shields.io/badge/dev_builds-AppVeyor-orange.svg?logo=appveyor&logoColor=333333&style=popout)](https://ci.appveyor.com/project/zeromus/bizhawk-udexo/history) +[![Windows prereqs | GitHub](https://img.shields.io/badge/Windows_prereqs-GitHub-darkred.svg?logo=github&logoColor=333333&style=popout)](https://github.com/TASVideos/BizHawk-Prereqs/releases/latest) +[![GitHub open issues counter](https://img.shields.io/github/issues-raw/TASVideos/BizHawk.svg?logo=github&logoColor=333333&style=popout)](https://github.com/TASVideos/BizHawk/issues) -[Here](http://tasvideos.org/Bizhawk/Features.html) is a list of features offered by bizhawk. +*** -## Download Binaries +Click the "release" button above to grab the latest stable version ([changelog at TASVideos](http://tasvideos.org/Bizhawk/ReleaseHistory.html)). -Windows users, don't forget to run the [prereq installer](http://github.com/TASVideos/BizHawk-Prereqs/releases) first! +New user on Windows? Install the prerequisites first, click the "prereqs" button to get that and see [*Installing*](#windows-78110) for info. -Release binaries can be found on [on github](http://github.com/TASVideos/BizHawk/releases) +**Never mix different versions** of BizHawk — Keep each version in its own folder. -[Developer build](https://ci.appveyor.com/project/zeromus/bizhawk-udexo/build/artifacts) of the most recent commit +Jump to: +* Installing + * [Windows 7/8.1/10](#windows-78110) + * [GNU+Linux](#gnulinux) +* Building + * [Windows 7/8.1/10](#windows-78110-1) + * [GNU+Linux](#gnulinux-1) +* [Usage](#usage) + * [TASing](#tasing) + * [Testing](#testing) + * [Cores](#cores) +* [Support and troubleshooting](#support-and-troubleshooting) +* [Contributing](#contributing) +* [Related projects](#related-projects) +* [License](#license) -Never mix different versions of BizHawk. Keep each version in its own folder. +## Features and systems -## Supported Systems +The BizHawk common features (across all cores) are: +* format, region, and integrity detection for game images +* 10 save slots with hotkeys and infinite named savestates +* speed control, including frame stepping and rewinding +* memory view/search/edit in all emulated hardware components +* input recording (making TAS movies) +* screenshotting and recording audio + video to file +* firmware management +* input, framerate, and more in a HUD over the game +* emulated controllers via a comprehensive input mapper +* Lua control over core and frontend (Windows only) +* hotkey bindings to control the UI - * Nintendo Entertainment System / Famicom / Famicom Disk System (NES/FDS) - * Super Nintendo (SNES) - * Nintendo 64 - * Game Boy, Game Boy Color, and Super Game Boy - * Game Boy Advance - * Sony PlayStation - * Sega Master System, Game Gear, and SG-1000 - * Sega Genesis / Sega-CD - * Sega Saturn - * PC-Engine (TurboGrafx-16) / CD-ROM & SuperGrafx - * Atari 2600 - * Atari 7800 - * Atari Lynx - * ColecoVision - * TI-83 Calculator - * Wonderswan and Wonderswan Color - * Apple II - * Commodore 64 - * Sinclair ZX Spectrum +Supported consoles and computers: -## Resources +* Apple II +* Atari + * Video Computer System / 2600 + * 7800 + * Lynx +* Bandai WonderSwan + Color +* CBM Commodore 64 +* Coleco Industries ColecoVision +* Mattel IntelliVision +* NEC + * PC Engine / TurboGrafx-16 + SuperGrafx + CD + * PC-FX +* Neo Geo Pocket + Color +* Nintendo + * Famicom / Nintendo Entertainment System + FDS + * Game Boy + Color + * Game Boy Advance + * Nintendo 64 + * Super Famicom / Super Nintendo Entertainment System + * Virtual Boy +* Sega + * Game Gear + * Genesis + 32X + CD + * Master System + * Pico + * Saturn + * SG-1000 +* Sinclair ZX Spectrum +* Sony Playstation (PSX) +* Texas Instruments TI-83 +* Uzebox +* [More](http://tasvideos.org/Bizhawk/CoreRoadMap.html) coming soon..? -[BizHawk homepage](http://tasvideos.org/Bizhawk.html) +See [*Usage*](#usage) below for info on basic config needed to play games. -[FAQ](http://tasvideos.org/Bizhawk/FAQ.html) - Frequently Asked Questions / Troubleshooting +[to top](#bizhawk) -[Compiling](http://tasvideos.org/Bizhawk/Compiling.html) - What is needed to compile BizHawk src +## Installing -[CompactDiscInfoDump](http://tasvideos.org/Bizhawk/CompactDiscInfoDump.html) - A concise explanation of compact disc CDs, gathered for the first time EVER in one location, and mostly inaccurate +### Windows 7/8.1/10 -[Rerecording](http://tasvideos.org/Bizhawk/Rerecording.html) - (Work in progress) - Documentation of the rerecording implementation of BizHawk - * [TAS movie file format](http://tasvideos.org/Bizhawk/TASFormat.html) - Mnemonic patterns for each platform for .tas (input) files. +Released binaries can be found right here on GitHub: -[Commandline](http://tasvideos.org/Bizhawk/CommandLine.html) - Documentation of the command line options in BizHawk +[![Windows | binaries](https://img.shields.io/badge/Windows-binaries-%230078D6.svg?logo=windows&logoColor=0078D6&style=popout)](https://github.com/TASVideos/BizHawk/releases/latest) + +Click `BizHawk-.zip` to download it. Also note the changelog, the full version of which is [here at TASVideos](http://tasvideos.org/Bizhawk/ReleaseHistory.html). **Don't mix different versions** of BizHawk, keep each version in its own folder. + +Before you start (by running `EmuHawk.exe`), you'll need the following Windows-only prerequisites installed. You can get them all at once with [this program](https://github.com/TASVideos/BizHawk-Prereqs/releases/latest). +* .NET Framework 4.6.1 +* Visual C++ Redists + * 2010 SP1 + * 2012 + * 2015 +* Direct3D 9 + +BizHawk functions like a "portable" program, you may move or rename the folder containing `EmuHawk.exe`, even to another drive — as long as you keep all the files together, and the prerequisites are installed when you go to run it. + +Following [Microsoft's support lifecycle](https://support.microsoft.com/en-us/help/13853/windows-lifecycle-fact-sheet), Win10 is supported from 1709 "Redstone 3", Win8 is supported from 8.1, and Win7 is supported from SP1 (ends Jan 2020, upgrade to Win10 or try [ReactOS](https://reactos.org/joining/faqs)). + +A "backport" release, [1.13.2](https://github.com/TASVideos/BizHawk/releases/tag/1.13.2), is available for users of Windows XP and/or 32-bit Windows. Being in the 1.x series, many bugs remain and features are missing. + +[to top](#bizhawk) + +### GNU+Linux + +*...or, as I’ve recently taken to calling it, Mono+GNU+Linux.* + +**IMPORTANT**: Linux support is a work-in-progress! It is *not* complete, does *not* look very nice, and is *not* ready for anything that needs accuracy. + +You'll need to either build BizHawk yourself (see [*Building*](#gnulinux-1) below), or download a dev build (see [*Testing*](#testing) below). + +The runtime dependencies are Mono (complete) + Mono VB.NET, WINE (just `libwine` if available), `libdl.so` (glibc), NVIDIA's `cgc` utility, and `libblip_buf.so` from the repo's `Assets` folder (copy it to `/usr/lib/libblip_buf.so.1.1.0` or equivalent). LSB release info is optional for automatically setting the library location. + +Run `EmuHawkMono.sh` to give Mono the library and executable paths — you can run it from anywhere, so putting it in a .desktop file is fine. If running the script doesn't start EmuHawk, you may need to edit it (if you use a terminal, it will say so in the output). + +The systems that currently work are: GB + GBC (GBHawk), NES (NesHawk), SMS, Atari 7800, and some classic home computers. See [#1430](https://github.com/TASVideos/BizHawk/issues/1430) for progress. + +[to top](#bizhawk) + +## Building + +### Windows 7/8.1/10 + +If you have WSL, Git BASH, or similar, clone the repo with: +``` +git clone https://github.com/TASVideos/BizHawk.git BizHawk_master +# or ssh: git clone git@github.com:TASVideos/BizHawk.git BizHawk_master +``` +...or use a [Git GUI](https://desktop.github.com). Otherwise, you'll have to download an archive from GitHub. + +Once it's downloaded and extracted, go into the repo's `Dist` folder and run `BuildAndPackage_Release.bat`. BizHawk will be built as a .zip just like any other release. + +For anything more complicated than building, you'll need an IDE like [VS Community 2017](https://visualstudio.microsoft.com/vs/community), currently the best free C# IDE. Open `BizHawk.sln` with VS to start and use the toolbar to choose EmuHawk and build. See [Compiling at TASVideos](http://tasvideos.org/Bizhawk/Compiling.html) (somewhat outdated) for more detailed instructions. + +[to top](#bizhawk) + +### GNU+Linux + +*Compiling* requires MSBuild and *running* requires Mono and WINE, but **BizHawk does not run under WINE** — only the bundled libraries are required. + +If you use GNU+Linux, there might be a `bizhawk-git` package or similar in the same repo as the main package. If it's available, installing it will automate the build process. + +Building is as easy as: +```sh +git clone https://github.com/TASVideos/BizHawk.git BizHawk_master && cd BizHawk_master +# or ssh: git clone git@github.com:TASVideos/BizHawk.git BizHawk_master && cd BizHawk_master +msbuild /p:Configuration=Release BizHawk.sln +``` + +Remove the `/p:...` flag from MSBuild if you want debugging symbols. + +If your distro isn't listed under *Installing* above, `libblip_buf` probably isn't in your package repos. You can easily [build it yourself](https://gitlab.com/TASVideos/libblip_buf/blob/unified/README.md). + +Once built, see [*Installing*](#gnulinux) above, substituting the repo's `output` folder for the download. + +Again, if your distro isn't listed there, you might get an "Unknown distro" warning in the terminal, and BizHawk may not open or may show the missing dependencies dialog. You may need to add your distro to the case statement in the script, setting `libpath` to the location of `d3dx9_43.dll.so` (please do share if you get it working). + +[to top](#bizhawk) + +## Usage + +#### Loading firmware + +Put all your dumped firmware files in the `Firmware` folder and everything will be automatically detected and loaded when you try to load a game (filenames and subfolders aren't enforced, you can just throw them in there). If you're missing required or optional firmware, you will see a "You are missing the needed firmware files [...]" dialog. + +Keep in mind some firmware is optional, and some have multiple versions, only one of which needs to be set. + +If you want to customise firmware (when there are alternative firmwares, for example) go to `Config` > `Firmwares...`, right-click the line of the firmware you want to change, click "Set Customization", and open the file. + +You can change where BizHawk looks for firmware by going to `Config` > `Paths...` and changing "Firmware" in the "Global" tab to the new location. This allows multiple BizHawk releases to use the same folder. + +#### Identifying a good rom + +With a core and game loaded, look in the very left of the status bar (`View` > `Display Status Bar`): +* a green checkmark means you've loaded a "known good" rom; +* a "!" in a red circle means you've loaded a "known bad" rom, created by incorrect dumping methods; and +* something else, usually a ?-block, means you've loaded something that's not in the database. + +#### Rebinding keys and controllers + +There are two keybind windows, `Config` > `Controllers...` and `Config` > `Hotkeys...`. These let you bind your keyboard and controllers to virtual controllers and to frontend functions, respectively. + +Using them is simple, click in a box next to an action and press the button (or bump the axis) you want bound to that action. If the "Auto Tab" checkbox at the bottom of the window is checked, the next box will be selected automatically and whatever button you press will be bound to *that* action, and so on down the list. If "Auto Tab" is unchecked, clicking a filled box will let you bind another button to the same action. Keep in mind there are multiple tabs of actions. + +#### Changing cores + +To change which core is used for NES, SNES, GB, or GBA, go to `Config` > `Cores`. There, you'll also find the `GB in SGB` item, which is a checkbox that makes GB games run with the *Super Game Boy* on an SNES. + +Most cores have their own settings window too, look in the menubar for the system name after `Tools`. Some have multiple windows, like Mupen64Plus which has virtual controller settings and graphics settings. + +#### Running Lua scripts + +(Reminder that this feature is Windows-only for now.) + +Go to `Tools` > `Lua Console`. The opened window has two parts, the loaded script list and the console output. The buttons below the menubar are shortcuts for items in the menus, hover over them to see what they do. Any script you load is added to the list, and will start running immediately. Instead of using "Open script", you can drag-and-drop .lua files onto the console or game windows. + +Running scripts have a "▶️" beside their name, and stopped scripts (manually or due to an error) have a "⏹️" beside them. Using "Pause or Resume", you can temporarily pause scripts, those have a "⏸️". + +"Toggle script" does just that (paused scripts are stopped). "Reload script" stops it and loads changes to the file, running scripts are then started again. "Remove script" stops it and removes it from the list. + +[to top](#bizhawk) + +### TASing + +~~This section refers to BizHawk specifically. For resources on TASing in general, see [Welcome to TASVideos](http://tasvideos.org/WelcomeToTASVideos.html).~~ This section hasn't been written yet. + +For now, the best way to learn how to TAS is to browse pages like [BasicTools](http://tasvideos.org/TasingGuide/BasicTools.html) on TASVideos and watch tutorials like [Sand_Knight and dwangoAC's](https://youtu.be/6tJniMaR2Ps). + +[to top](#bizhawk) + +### Testing + +* [Latest development build](https://ci.appveyor.com/project/zeromus/bizhawk-udexo/build/artifacts) + +Testing bugfixes or new features can be just as helpful as making them! If code's more your thing, see [*Contributing*](#contributing) below. + +Dev builds are automated with AppVeyor, every green checkmark in the [commit history](https://github.com/TASVideos/BizHawk/commits/master) is a successful build. Clicking a checkmark and then "Details" in the box that appears takes you straight to the build page. The full list is [here](https://ci.appveyor.com/project/zeromus/bizhawk-udexo/history), in future use the "dev builds" button at the top of this readme. + +Once you're on the build page, click "Artifacts" and download `BizHawk_Developer--#.zip`. + +[to top](#bizhawk) + +### Cores + +A *core* is what we call the smaller bits of software that emulate just one system or family of systems, e.g. NES/Famicom. For the most part, there's a "best" core for each system, based on accuracy, but there are a few alternative cores which are *faster and less accurate*. + +System | Core | Alt. Core +--:|:--|:-- +Apple II | Virtu | +Atari 2600 | Atari2600Hawk | +Atari 7800 | A7800Hawk | +Atari Lynx | Handy | +Commodore 64 | C64Hawk | +ColecoVision | ColecoHawk | +Game Boy / Color | GBHawk | Gambatte +Game Boy Advance | mGBA | VBA-Next +IntelliVision | IntelliHawk | +N64 | Mupen64Plus | +Neo Geo Pocket / Color | NeoPop | +NES | NesHawk | QuickNes | +PC-FX | T.S.T. | +Playstation (PSX) | Octoshock | +Sega Game Gear | SMSHawk | +Sega Genesis | Genplus-gx | +Sega Master System | SMSHawk | +Sega Saturn | Saturnus | +Sega Pico | PicoDrive | +SNES | BSNES | Snes9x +Super Game Boy | BSNES | SameBoy +TI-83 | TI83Hawk | +TurboGrafx / SuperGrafx | PCEHawk | +Uzebox | Uzem | +Virtual Boy | Virtual Boyee | +WonderSwan / Color | Cygne | +ZX Spectrum | ZXHawk | + +Amstrad CPC, Magnavox Odyssey², and Sony PSP emulation are works-in-progress and there is **no ETA**. Cores for other systems are only conceptual. If you want to help speed up development, ask on IRC (see below). + +[to top](#bizhawk) + +## Support and troubleshooting + +A short [FAQ](http://tasvideos.org/Bizhawk/FAQ.html) is provided on the [BizHawk wiki](http://tasvideos.org/Bizhawk.html). + +If your problem is one of the many not answered there, and you can't find it in the [issue tracker search](https://github.com/TASVideos/BizHawk/issues?q=is%3Aissue+ISSUE_KEYWORDS), check the [BizHawk forum](http://tasvideos.org/forum/viewforum.php?f=64) at TASVideos, or ask on IRC: +* with an IRC client, join channel `#bizhawk` on `chat.freenode.net:6697` +* with a Matrix client, connect to [#freenode_#bizhawk:matrix.org](https://matrix.to/#/#freenode_#bizhawk:matrix.org) (via matrix.org's IRC bridge) +* use freenode's [web-based IRC client](http://webchat.freenode.net/?channels=bizhawk) + +If there's no easy solution, what you've got is a bug. Or maybe a feature request. Either way, [open a new issue](https://github.com/TASVideos/BizHawk/issues/new) (you'll need a GitHub account, signup is very fast). + +[to top](#bizhawk) + +## Contributing + +BizHawk is Open Source Software, so you're free to modify it however you please, and if you do, we invite you to share! Under the permissive *MIT License*, this is optional, just be careful with reusing cores as some have copyleft licenses. + +Not a programmer? Something as simple as reproducing bugs with different software versions is still very helpful! See [*Testing*](#testing) above to learn about dev builds if you'd rather help us get the next release out. + +If you'd like to fix bugs, check the [issue tracker](https://github.com/TASVideos/BizHawk/issues) here on GitHub. + +It's a good idea to check if anyone is already working on an issue by asking on IRC (see [*Support*](#support-and-troubleshooting) above). + +If you'd like to add a feature, first search the issue tracker for it. If it's a new idea, make your own feature request issue before you start coding. + +For the time being, style is not enforced in PRs, only build success is. Please use CRLF, tabs, and [Allman braces](https://en.wikipedia.org/wiki/Indentation_style#Allman_style) in new files. + +Past contrbutors to the frontend and custom-built cores are listed [here](https://github.com/TASVideos/BizHawk/graphs/contributors). See the wiki for core authors. + +[to top](#bizhawk) + +## Related projects + +* [DeSmuME](https://desmume.org) for DS/Lite — cross-platform +* [Dolphin](https://dolphin-emu.org) for GameCube and (original) Wii — cross-platform +* [FCEUX](http://www.fceux.com/web/home.html) for NES/Famicom — TASing is Windows-only, but it should run cross-platform +* [libTAS](https://github.com/clementgallet/libTAS) for Linux ELF — GNU+Linux-only, also emulates other emulators +* [lsnes](http://tasvideos.org/Lsnes.html) for GB and SNES — cross-platform +* [openMSX](https://openmsx.org) for MSX — cross-platform + +Emulators for other systems can be found on the [EmulatorResources page](http://tasvideos.org/EmulatorResources.html) at TASVideos. The [TASVideos GitHub page](https://github.com/TASVideos) also holds copies of other emulators and plugins where development happens sometimes, their upstreams may be of use. + +## License + +From the [full text](https://github.com/TASVideos/BizHawk/blob/master/LICENSE): +> This repository contains original work chiefly in c# by the BizHawk team (which is all provided under the MIT License), embedded submodules from other authors with their own licenses clearly provided, other embedded submodules from other authors WITHOUT their own licenses clearly provided, customizations by the BizHawk team to many of those submodules (which is provided under the MIT license), and compiled binary executable modules from other authors without their licenses OR their origins clearly indicated. + +In short, the frontend is MIT (Expat), beyond that you're on your own. diff --git a/References/OpenTK.GLControl.dll b/References/OpenTK.GLControl.dll index 9cfe53e67f..9d928cfb69 100644 Binary files a/References/OpenTK.GLControl.dll and b/References/OpenTK.GLControl.dll differ diff --git a/References/OpenTK.dll b/References/OpenTK.dll index 4ded127209..52feb21b25 100644 Binary files a/References/OpenTK.dll and b/References/OpenTK.dll differ diff --git a/References/OpenTK.dll.config b/References/OpenTK.dll.config index 975c2be900..7098d39e9c 100644 --- a/References/OpenTK.dll.config +++ b/References/OpenTK.dll.config @@ -1,16 +1,25 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libmupen64plus/GLideN64 b/libmupen64plus/GLideN64 index d6915e13c4..b8d7ad3337 160000 --- a/libmupen64plus/GLideN64 +++ b/libmupen64plus/GLideN64 @@ -1 +1 @@ -Subproject commit d6915e13c4904e38d221bd49f5efe9b16845a367 +Subproject commit b8d7ad33375ab315628c17abb14bc459b2aa3ae4 diff --git a/output/dll/mupen64plus-video-GLideN64.dll b/output/dll/mupen64plus-video-GLideN64.dll index a2cb0a6269..03d5d41d1d 100644 Binary files a/output/dll/mupen64plus-video-GLideN64.dll and b/output/dll/mupen64plus-video-GLideN64.dll differ diff --git a/output/dll/nlua/NLua.dll b/output/dll/nlua/NLua.dll index 5bdc058e66..57e6d07cb9 100644 Binary files a/output/dll/nlua/NLua.dll and b/output/dll/nlua/NLua.dll differ