diff --git a/.gitignore b/.gitignore index 20ffa86c34..a8f5a6d362 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ svnrev.cs **/ipch/** *.ilk +*.il *.tlog *.obj *.o @@ -74,3 +75,7 @@ libsnes/vs2015/libsnes.VC.db waterbox/**/*.wbx waterbox/**/*.wbx.in /BizHawkTool_template.zip + +mono_crash* + +.idea diff --git a/Assets/EmuHawkMono.sh b/Assets/EmuHawkMono.sh index a42a52a5f6..0e59998135 100755 --- a/Assets/EmuHawkMono.sh +++ b/Assets/EmuHawkMono.sh @@ -8,11 +8,14 @@ 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";; + "Debian"|"LinuxMint") libpath="/usr/lib/x86_64-linux-gnu/wine";; + "Ubuntu") libpath="/usr/lib/x86_64-linux-gnu/wine"; export MONO_WINFORMS_XIM_STYLE=disabled;; # see https://bugzilla.xamarin.com/show_bug.cgi?id=28047#c9 esac +else + printf "Distro does not provide LSB release info API! (You've met with a terrible fate, haven't you?)\n" 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 +LD_LIBRARY_PATH="$libpath" mono ./EmuHawk.exe >EmuHawkMono_laststdout.txt diff --git a/Assets/gamedb/gamedb.txt b/Assets/gamedb/gamedb.txt index 5b6a8ab82b..ba89a10f60 100644 --- a/Assets/gamedb/gamedb.txt +++ b/Assets/gamedb/gamedb.txt @@ -21,11 +21,13 @@ #include gamedb_sega_md.txt #include gamedb_snes.txt #include gamedb_user.txt +#include gamedb_vectrex.txt #include gamedb_ws.txt #include gamedb_wsc.txt #include gamedb_zxspectrum.txt #include gamedb_amstradcpc.txt #include gamedb_ngp.txt +#include gamedb_channelf.txt ; ************ TI-83 ************ diff --git a/Assets/gamedb/gamedb_a2600.txt b/Assets/gamedb/gamedb_a2600.txt index 604912bc87..cac5fb3048 100644 --- a/Assets/gamedb/gamedb_a2600.txt +++ b/Assets/gamedb/gamedb_a2600.txt @@ -50,9 +50,9 @@ sha1:a65f487740069640952803218b70580b2fb724b7 A-Team, The (Atari) (Prototype) ( sha1:821cffe5f5940b2951f280d07d2691e140f54ad2 A-Team, The (Atari) (Prototype) (PAL-60) [!] A26 m=F8;NTSC=true sha1:53413577afe7def1d390e3892c45822405513c07 A-Team, The (Atari) (Prototype) [!] A26 m=F8;NTSC=true sha1:3607f46475f4b1b8989f7327f90ca53a4ac0e9fe A-VCS-tec Challenge (beta 5) (PD) A26 m=F8;NTSC=true -sha1:d7c62df8300a68b21ce672cfaa4d0f2f4b3d0ce1 Acid Drop (1992) (Salu) (PAL) [!] A26 m=F6;PAL=true -sha1:66216ed98295f3fde35a0cc9398b4f2fc79f2375 Acid Drop (1992) (Salu) (PAL) [b1] A26 m=F8;PAL=true -sha1:2ad5e47e360842bb5f9c23bbe2c19866d890f427 Acid Drop (NTSC Conversion) (TJ) A26 m=F8;NTSC=true +sha1:d7c62df8300a68b21ce672cfaa4d0f2f4b3d0ce1 Acid Drop (1992) (Salu) (PAL) [!] A26 SP_RESET=true;m=F6;PAL=true +sha1:66216ed98295f3fde35a0cc9398b4f2fc79f2375 Acid Drop (1992) (Salu) (PAL) [b1] A26 SP_RESET=true;m=F8;PAL=true +sha1:2ad5e47e360842bb5f9c23bbe2c19866d890f427 Acid Drop (NTSC Conversion) (TJ) A26 SP_RESET=true;m=F8;NTSC=true sha1:9e6fb047ee9fa0a454ca23673ed9693430032dc6 Action Force (1983) (Parker Bros) (PAL) [!] A26 m=4K;PAL=true sha1:bfcc35feee3713f5028122844d027c88a84772b6 2 Pak Special Red - Motocross,Boom Bang (1990) (PAL) [!] A26 m=F6;PAL=true sha1:8a503416ca6f2404bc52382e337f31238bba9534 3-D Corridor Demo 2 (29-03-2003) (MP) A26 m=4K;NTSC=true @@ -68,13 +68,13 @@ sha1:317a7b8693af44095c23437253a32cc748824ccf Adventure (Color Scrolling) [h1] sha1:4ffe36c5113305714e27c72d7f3abecc9b08a630 Adventure (New Graphics) [h1] A26 m=4K;NTSC=true sha1:0b0875ad1bd494c9dd8de4ff0a06938e699f60d5 Adventure 34 by Kurt Howe (Adventure Hack) A26 m=4K;NTSC=true sha1:8501444b12f7f9e2103cd2bcf0c8d3f5b7536569 Adventure II (Adventure Hack) A26 m=4K;NTSC=true -sha1:03a495c7bfa0671e24aa4d9460d232731f68cb43 Adventures of Tron (1983) (Mattel) A26 m=4K;NTSC=true +sha1:03a495c7bfa0671e24aa4d9460d232731f68cb43 Adventures of Tron (1983) (Mattel) A26 SP_RESET=true;m=4K;NTSC=true sha1:6e420544bf91f603639188824a2b570738bb7e02 Adventures on GX-12 (Telegames) (PAL) [!] A26 m=4K;PAL=true sha1:3b02e7dacb418c44d0d3dc77d60a9663b90b0fbc Air Raid (Men-A-Vision) A26 m=4K;NTSC=true -sha1:e65a0c6c5a1f9f05ebcfaaa7b2c9ee6625bf2d83 Air Raiders (1982) (Mattel) (PAL) [p1][!] A26 m=4K;PAL=true -sha1:29f5c73d1fe806a4284547274dd73f9972a7ed70 Air Raiders (1982) (Mattel) [!] A26 m=4K;NTSC=true -sha1:a9a51405b521ae0b465f521fa098e8b3aedd018b Air Raiders (1982) (Mattel) [a1][!] A26 m=4K;NTSC=true -sha1:39a98b42f0670dfe6a842645f09f24583ae8ee60 Air Raiders (1982) (Mattel) [h1] A26 m=4K;NTSC=true +sha1:e65a0c6c5a1f9f05ebcfaaa7b2c9ee6625bf2d83 Air Raiders (1982) (Mattel) (PAL) [p1][!] A26 SP_RESET=true;m=4K;PAL=true +sha1:29f5c73d1fe806a4284547274dd73f9972a7ed70 Air Raiders (1982) (Mattel) [!] A26 SP_RESET=true;m=4K;NTSC=true +sha1:a9a51405b521ae0b465f521fa098e8b3aedd018b Air Raiders (1982) (Mattel) [a1][!] A26 SP_RESET=true;m=4K;NTSC=true +sha1:39a98b42f0670dfe6a842645f09f24583ae8ee60 Air Raiders (1982) (Mattel) [h1] A26 SP_RESET=true;m=4K;NTSC=true sha1:b96c7a509bf610f61f82377bfd506db3dba2b423 Air-Sea Battle (1977) (Atari) (PAL) [!] A26 m=2K;PAL=true sha1:a746fdc82b336a9d499bf17f50b41e0193ba595e Air-Sea Battle (1977) (Atari) [!] A26 m=2K;NTSC=true sha1:d3897fc60585e420ae816a2db909400f6cbadd88 Air-Sea Battle (1977) (Atari) [o1] A26 m=2K;NTSC=true @@ -323,9 +323,9 @@ sha1:67387d0d3d48a44800c44860bf15339a81f41aa9 Bugs (1982) (Data Age) [!] A26 m sha1:a8aedea627c67c38032cdde441fb98dad226916a Bugs (1983) (Gameworld) (PAL) [!] A26 m=4K;PAL=true sha1:9c0e13af336a986c271fe828fafdca250afba647 Bugs Bunny (Atari) (Prototype) [!] A26 m=F8;NTSC=true sha1:13534da5c382ed20d070ffe93f35c4c11b36e1bc Bullet Demo (20-12-2002) (CT) A26 m=4K;NTSC=true -sha1:5614c32e76c8b272c38c16720ebbb1818d3d3103 Bump 'N' Jump (1983) (Mattel) [b1] A26 m=F6;NTSC=true -sha1:1819ef408c1216c83dcfeceec28d13f6ea5ca477 Bump 'N' Jump (1983) (Mattel) A26 m=E7;NTSC=true -sha1:35bc4048f58bb170313872a0bce44fb1ca3217cc Bump 'N' Jump (Telegames) (PAL) [!] A26 m=F8;PAL=true +sha1:5614c32e76c8b272c38c16720ebbb1818d3d3103 Bump 'N' Jump (1983) (Mattel) [b1] A26 SP_RESET=true;m=F6;NTSC=true +sha1:1819ef408c1216c83dcfeceec28d13f6ea5ca477 Bump 'N' Jump (1983) (Mattel) A26 SP_RESET=true;m=E7;NTSC=true +sha1:35bc4048f58bb170313872a0bce44fb1ca3217cc Bump 'N' Jump (Telegames) (PAL) [!] A26 SP_RESET=true;m=F8;PAL=true sha1:ad48f4952e867a2b97900d965b69f50fddf8ba2d Bumper Bash (1983) (Spectravideo) (PAL) [!] A26 m=4K;PAL=true sha1:6c199782c79686dc0cbce6d5fe805f276a86a3f5 Bumper Bash (1983) (Spectravideo) A26 m=4K;NTSC=true sha1:49e01b8048ae344cb65838f6b1c1de0e1f416f29 Burgertime (1982) (Mattel) A26 SP_RESET=true;m=E7;NTSC=true @@ -855,8 +855,8 @@ sha1:6b9e591cc53844795725fc66c564f0364d1fbe40 Frogger II - Threedeep! (1983) (P sha1:bce92de22fc8950f0eebb643d96fe9fa5dba2b72 Frogger II - Threedeep! (1984) (Parker Bros) (PAL) [!] A26 m=E0;PAL=true sha1:5215cf9051e833482e115d16ff90fee5f01c3e84 Frogger Preview (1982) (Starpath) [a1] A26 m=AR;NTSC=true sha1:2edb64be1bb6f4215f520ec2f487b19f29724b8d Frogger Preview (1982) (Starpath) A26 m=AR;NTSC=true -sha1:7682b4b6d45865b7eec1244e5d76f0f2efdb17e7 Frogs and Flies (1982) (Mattel) (PAL) [p1][!] A26 m=4K;PAL=true -sha1:f344d5a8dc895c5a2ae0288f3c6cb66650e49167 Frogs and Flies (1982) (Mattel) [!] A26 m=4K;NTSC=true +sha1:7682b4b6d45865b7eec1244e5d76f0f2efdb17e7 Frogs and Flies (1982) (Mattel) (PAL) [p1][!] A26 SP_RESET=true;m=4K;PAL=true +sha1:f344d5a8dc895c5a2ae0288f3c6cb66650e49167 Frogs and Flies (1982) (Mattel) [!] A26 SP_RESET=true;m=4K;NTSC=true sha1:cf32bfcd7f2c3b7d2a6ad2f298aea2dfad8242e7 Front Line (1982) (Coleco) A26 m=F8;NTSC=true sha1:58a6f82434ccf49ca420596809ce9545373845a2 Frostbite (1983) (Activision) (PAL) [!] A26 m=4K;PAL=true sha1:8ad03667bbf73d3c7760cb82f2c4442f8745483c Frostbite (1983) (Activision) (PAL) [p1][!] A26 m=4K;PAL=true @@ -1256,9 +1256,9 @@ sha1:128c3a98d78b043edabe8964cf7998955342fa2d Kiss Meets Pacman (Cody Pittman) sha1:45623a1c8fb5074de98c37f005edd5b1d0937dae Klax (1990) (Atari) (PAL) [!] A26 m=F6SC;PAL=true sha1:3162259c6dbfbb57a2ea41d849155702151ee39b Klax (1990) (Atari) A26 m=F6SC;NTSC=true sha1:759597d1d779cfdfd7aa30fd28a59acc58ca2533 Knight on the Town (1982) (Playaround) A26 m=4K;NTSC=true -sha1:2f550743e237f6dc8c75c389a01b02e9a396fdad Kool Aid Man (1982) (Mattel) A26 m=4K;NTSC=true -sha1:f5c193ed00bf557ddd5ab698d92a7483b89c6519 Kool Aid Man (Fixed) (15-11-2002) (CT) A26 m=4K;NTSC=true -sha1:38f55fc76bec14eb661a7b594301c271aa5f5f3b Kool Aid Man (PAL Conversion) (16-11-2002) (Fabrizio Zavagli) A26 m=4K;NTSC=true +sha1:2f550743e237f6dc8c75c389a01b02e9a396fdad Kool Aid Man (1982) (Mattel) A26 SP_RESET=true;m=4K;NTSC=true +sha1:f5c193ed00bf557ddd5ab698d92a7483b89c6519 Kool Aid Man (Fixed) (15-11-2002) (CT) A26 SP_RESET=true;m=4K;NTSC=true +sha1:38f55fc76bec14eb661a7b594301c271aa5f5f3b Kool Aid Man (PAL Conversion) (16-11-2002) (Fabrizio Zavagli) A26 SP_RESET=true;m=4K;NTSC=true sha1:82e64366795b011c2a2f1755bf899cc2c0617fe8 Krieg Der Sterne (Atlantis-Ariola) (PAL) [!] A26 m=4K;PAL=true sha1:4bdf1cf73316bdb0002606facf11b6ddcb287207 Krull (1983) (Atari) [!] A26 m=F8;NTSC=true sha1:07a1c1b1a2297c4edde0e16f610b5ec23c775217 Krull (CCE) A26 m=F8;NTSC=true @@ -1305,9 +1305,9 @@ sha1:4f3e51f68c10d2fa7c4b9764b0cb81fdded0fde4 Lilly Adventure (Starsoft) (NTSC sha1:63f4776aa4c35d124001918b733cdb4d46dfbe9b Lilly Adventure (Starsoft) (PAL) [!] A26 m=4K;PAL=true sha1:5425578808363ee72dbba6195533549679137777 Lines Demo (Eckhard Stolberg) (PAL) (PD) A26 m=2K;PAL=true sha1:fe208ad775cbf9523e7a99632b9f10f2c9c7aa87 Lochjaw (1982) (Apollo) A26 m=4K;NTSC=true -sha1:119171935ed9ea877de4f2a68aee31cd55bc697d Lock 'N' Chase (1982) (Mattel) (PAL) [p1][!] A26 m=4K;PAL=true -sha1:fc3d75d46d917457aa1701bf47844817d0ba96c3 Lock 'N' Chase (1982) (Mattel) [!] A26 m=4K;NTSC=true -sha1:075ec3678ceabbee46a7d576fdd199a4ab908cc0 Lock 'N' Chase (1982) (Telegames) (PAL) [!] A26 m=4K;PAL=true +sha1:119171935ed9ea877de4f2a68aee31cd55bc697d Lock 'N' Chase (1982) (Mattel) (PAL) [p1][!] A26 SP_RESET=true;m=4K;PAL=true +sha1:fc3d75d46d917457aa1701bf47844817d0ba96c3 Lock 'N' Chase (1982) (Mattel) [!] A26 SP_RESET=true;m=4K;NTSC=true +sha1:075ec3678ceabbee46a7d576fdd199a4ab908cc0 Lock 'N' Chase (1982) (Telegames) (PAL) [!] A26 SP_RESET=true;m=4K;PAL=true sha1:ef02fdb94ac092247bfcd5f556e01a68c06a4832 Lord of The Rings (1983) (Parker Bros) (Prototype) A26 m=E0;NTSC=true sha1:43575ed97f8a585c5bae6fb1a7b2133c87b4d256 Lord of the Rings - Fellowship of the Ring by Adam Thornton (Dark Mage Hack) (PD) [a1] A26 m=4K;NTSC=true sha1:721514e5c31c8f2b30b4a2bf2cda69a810cac75b Lord of the Rings - Fellowship of the Ring by Adam Thornton (Dark Mage Hack) (PD) A26 m=4K;NTSC=true @@ -1359,8 +1359,8 @@ sha1:6ef010513e01520560616994cbe3f10995490996 Max3 (2001) (Maxime Beauvais) (PD sha1:a2b13017d759346174e3d8dd53b6347222d3b85d Maze (AKA Slot Racers) (1978) (Sears) [!] A26 m=2K;NTSC=true sha1:05f8d0e9f9bec192dfe5947965039817c8c390df Maze (AKA Slot Racers) (1978) (Sears) [o1] A26 m=2K;NTSC=true sha1:365a3af336d71f8f80345de9fcebb100f5141182 Maze 003 Demo (PD) A26 m=4K;NTSC=true -sha1:4a255c1d277f9ceb98dfe61ec2c6f7537ca4e7bf Maze Craze (1978) (Atari) (PAL) [!] A26 m=4K;PAL=true -sha1:aba25089d87cd6fee8d206b880baa5d938aae255 Maze Craze (1978) (Atari) A26 m=4K;NTSC=true +sha1:4a255c1d277f9ceb98dfe61ec2c6f7537ca4e7bf Maze Craze (1978) (Atari) (PAL) [!] A26 SP_FRAME=true;m=4K;PAL=true +sha1:aba25089d87cd6fee8d206b880baa5d938aae255 Maze Craze (1978) (Atari) A26 SP_FRAME=true;m=4K;NTSC=true sha1:43c309177fde4adf59c99ba5d3865df2a588a79e Maze Demo 1 (PD) A26 m=4K;NTSC=true sha1:648e91958afdf264e8e6b45521ecb542fb340586 Maze Demo 2 (PD) A26 m=4K;NTSC=true sha1:0103b35b1aef6b10c1c0a44b213ebf30af708df6 McDonald's (1983) (Parker Bros) (Prototype) [!] A26 m=4K;NTSC=true @@ -1559,9 +1559,9 @@ sha1:03eb4a3b3db04c1782e1a91d27ea515163d258fb Oink! (CCE) A26 m=4K;NTSC=true sha1:7feef3965706bc64f0f0a940149b2523e0735ce6 Okie Dokie (4K) (PD) A26 m=4K;NTSC=true sha1:7bd1cbddefcf3bd24da570be015234d0c444a7e5 Okie Dokie (Older) (PD) A26 m=2K;NTSC=true sha1:8a47b1930971f271a935c50d423e152aaea6ac59 Okie Dokie (PD) A26 m=2K;NTSC=true -sha1:ca4f26716120d2e4ba531c2ea50b570b9980756e Omega Race (1983) (CBS Electronics) [o1] A26 m=F6SC;NTSC=true -sha1:dcaab259e7617c7ac7d349893451896a9ca0e292 Omega Race (1983) (CBS Electronics) A26 m=FA;NTSC=true -sha1:c7a9ecad6c1a82048de54d33b231abd89fb08bd8 Omega Race JS (TJ) A26 m=FA;NTSC=true +sha1:ca4f26716120d2e4ba531c2ea50b570b9980756e Omega Race (1983) (CBS Electronics) [o1] A26 SP_RESET=true;m=F6SC;NTSC=true +sha1:dcaab259e7617c7ac7d349893451896a9ca0e292 Omega Race (1983) (CBS Electronics) A26 SP_RESET=true;m=FA;NTSC=true +sha1:c7a9ecad6c1a82048de54d33b231abd89fb08bd8 Omega Race JS (TJ) A26 SP_RESET=true;m=FA;NTSC=true sha1:fbf180f8f35178099244bc1ae341ccff87838907 One Blue Bar Demo (PD) A26 m=4K;NTSC=true sha1:e52ca6e73c931ef71c63e164704fb398086e4308 One On One by Angelino (Basketball Hack) A26 m=2K;NTSC=true sha1:98007f26356b4032a2ae4e9fddea5a38a988eb13 Oscar's Trash Race (1983) (Atari) (PAL) [!] A26 m=F8;PAL=true @@ -2302,8 +2302,8 @@ sha1:7c2a2ddbdef639ed2985ce66ae717b2285a94ae0 Star Raiders (1982) (Atari) (PAL) sha1:e10cce1a438c82bd499e1eb31a3f07d7254198f5 Star Raiders (1982) (Atari) A26 m=F8;NTSC=true sha1:d2b6290afb81bad126321d923d222c26e2de5fa8 Star Ship - Outer Space (1977) [o1] A26 m=2K;NTSC=true sha1:878e78ed46e29c44949d0904a2198826e412ed81 Star Ship - Outer Space (1977) A26 m=2K;NTSC=true -sha1:de05d1ca8ad1e7a85df3faf25b1aa90b159afded Star Strike (1982) (Mattel) A26 m=4K;NTSC=true -sha1:a0e29405a92773bf3baa2845788a8add8f3bc0b1 Star Strike (Telegames) (PAL) [!] A26 m=4K;PAL=true +sha1:de05d1ca8ad1e7a85df3faf25b1aa90b159afded Star Strike (1982) (Mattel) A26 SP_RESET=true;m=4K;NTSC=true +sha1:a0e29405a92773bf3baa2845788a8add8f3bc0b1 Star Strike (Telegames) (PAL) [!] A26 SP_RESET=true;m=4K;PAL=true sha1:667a528e8cf3fd7f533cf67993f48bcc3c100e0d Star Trek - Strategic Operations Simulator (1983) (Sega) (PAL) [!] A26 m=F8;PAL=true sha1:61a3ebbffa0bfb761295c66e189b62915f4818d9 Star Trek - Strategic Operations Simulator (1983) (Sega) A26 m=F8;NTSC=true sha1:417bb89e1117413321ffba48a17e005b2687680b Star Voyager (1982) (CCE) [!] A26 m=4K;NTSC=true @@ -2554,8 +2554,8 @@ sha1:ccf422636180f24becaa8af0cc391f95e599a330 Tunnel Demo (28-03-2003) (AD) A26 sha1:0f6552a0afe40cc1c448313569db8c9a8cda6d21 Tunnel Demo (Cycling Colours 2) (29-03-2003) (AD) A26 m=4K;NTSC=true sha1:8dad50a3918c7462811c2def42f289cd123822af Tunnel Demo (Red Spiral) (30-03-2003) (AD) A26 m=4K;NTSC=true sha1:4df103678f9c88b017e64f1e14e741fc6e15340c Tunnel Demo 2 (27-03-2003) (CT) A26 m=4K;NTSC=true -sha1:fc1a0b58765a7dcbd8e33562e1074ddd9e0ac624 Tunnel Runner (1983) (CBS Electronics) [!] A26 m=FA;NTSC=true -sha1:460094d7689ac0c4435b72e3e390f4b6f2ef112c Tunnel Runner (1983) (CBS Electronics) [a1][!] A26 m=FA;NTSC=true +sha1:fc1a0b58765a7dcbd8e33562e1074ddd9e0ac624 Tunnel Runner (1983) (CBS Electronics) [!] A26 SP_RESET=true;m=FA;NTSC=true +sha1:460094d7689ac0c4435b72e3e390f4b6f2ef112c Tunnel Runner (1983) (CBS Electronics) [a1][!] A26 SP_RESET=true;m=FA;NTSC=true sha1:0921fab66ce4b712701326ce105e1a84ac47b497 Turbo (Coleco) Prototype Fake v0.1 (TJ) A26 m=2K;NTSC=true sha1:b594a9acedd4734070776bf69d0f08abb5c261bf Turbo WIP (TJ) A26 m=F8;NTSC=true sha1:1162fe46977f01b4d25efab813e0d05ec90aeadc Turmoil (1982) (20th Century Fox) [!] A26 m=4K;NTSC=true @@ -2596,7 +2596,7 @@ sha1:082a7bc7d0fdbf307501cd146e18ed3d03b9ec0f Vertical Ship Demo 1 (PD) A26 m= sha1:1d641abfb95e3b4b7abaad42a8760c8c9ce993a6 Vertically Scrolling Playfield (02-02-2003) (Aaron Bergstrom) A26 m=4K;NTSC=true sha1:24c1c6e1a495137bec53818c2cd8bd83c8336d21 Video Checkers (1978) (Atari) (PAL) [!] A26 m=4K;PAL=true sha1:babae88a832b76d8c5af6ea63b8f10a0da5bb992 Video Checkers (1978) (Atari) A26 m=4K;NTSC=true -sha1:043ef523e4fcb9fc2fc2fda21f15671bf8620fc3 Video Chess (1978) (Atari) A26 m=4K;NTSC=true +sha1:043ef523e4fcb9fc2fc2fda21f15671bf8620fc3 Video Chess (1978) (Atari) A26 SP_FRAME=true;m=4K;NTSC=true sha1:3f2ad3666eb713b20484e3677d8e1cac8fbd323e Video Cube (CCE) A26 m=4K;NTSC=true sha1:1554b146d076b64776bf49136cea01f60eeba4c1 Video Jogger (Exus) (PAL) A26 m=4K;PAL=true sha1:19d4f52d399c2ab70e411be51b715341db7a41bf Video Life (CommaVid) [h1] A26 m=CV;NTSC=true @@ -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_channelf.txt b/Assets/gamedb/gamedb_channelf.txt new file mode 100644 index 0000000000..e57abc0c17 --- /dev/null +++ b/Assets/gamedb/gamedb_channelf.txt @@ -0,0 +1,58 @@ +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +;;; Type: NO-INTRO +;;; Source: Fairchild - Channel F - 20120223-000000 +;;; FileGen: 2019-04-16 13:59:49 (UTC) +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +;;; Bad Dumps +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +; +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +;;; Hacks +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +; +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +;;; Over Dumps +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +; +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +;;; Translated +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +; +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +;;; Believed Good +;;;;;;;;;;--------------------------------------------------;;;;;;;;;; +F7BF7D55A7660FFA80D08AD1BA903FF7 Alien Invasion (USA) ChannelF USA +D89B48AE8C906488CAAC2B2AE1D63D88 Backgammon, Acey-Deucey (USA) ChannelF USA +4FA83F734C139963AA02BDBB7A52E500 Baseball (USA) ChannelF USA +25E231E7A464A32B4715BFB47AF89240 Bowling (USA) ChannelF USA +BB7F7BBBE21F142591CDCAFA98D7F6E4 Casino Poker (USA) ChannelF USA +35D61D40EF7EC337CBA092AABAC74DBD Checkers (USA) ChannelF USA +54CF17C48707467295749490D458EAFB Demonstration Cartridge (USA) ChannelF USA +F6916B665893AA8138CDE57C37E50ADA Demonstration Cartridge 2 (USA) ChannelF USA +4F11F13CBCA685CB20E888F87B3B1586 Desert Fox, Shooting Gallery (USA) ChannelF USA +6FFEDAED3C5CD8BA74D98901849CC451 Dodge It (USA) ChannelF USA +F80AF74B09D058B90E719BB7DFBDD50E Drag Race (USA) ChannelF USA +9E0711B140E22729687DB1E1354980AB Galactic Space Wars, Lunar Lander (USA) ChannelF USA +0124CD0B61DF5502AABD59029CCB6D5A Hangman (USA) ChannelF USA +4C10FA5C7316C59EFA241043FC67DFA8 Magic Numbers - Mind Reader + Nim (USA) ChannelF USA +A8E6103FCAE4D0F9E14D9EDCFC3FC493 Math Quiz I - Addition + Subtraction (USA) ChannelF USA +86B77EAFDF7B806E19E01724987E384F Math Quiz II - Multiplication + Division (USA) ChannelF USA +6565DF74539476D66FD78DE1BAC0259C Maze, Jailbreak, Blind-man's-bluff, Trailblazer (USA) ChannelF USA +53E4CC2DA0F2C167E0692B794CB7692C Maze, Jailbreak, Blind-man's-bluff, Trailblazer (USA) (Alt 1) ChannelF USA +2B3CA549E27579E4519A765FD8F52D0F Memory Match 1 & 2 (USA) ChannelF USA +1FBD86DCCA0E4619963B902C48AE77F2 Muehle, Tontauben-Schiessen, Kreatives Malspiel, Videoscope (Germany) ChannelF Germany +C2A44D22D3865B036479E9311C74D3AD Ordtaevling (Sweden) ChannelF Sweden +E90339B7068C6227D54F3C0CA637E017 Pinball Challenge (USA) ChannelF USA +5CBCDA1C44F0DAD02B0DFE209B6325D5 Pinball Challenge (USA) (Alt 1) ChannelF USA +9A894D745356A050F95410983C3BC54A Pro Football (USA) ChannelF USA +913ECBAA30816C6D78DE8651251761FC Rat' Mal (Germany) ChannelF Germany +3783B6AC359E21B99CFA17773AA811C6 Robot War, Torpedo Alley (USA) ChannelF USA +5568205F926333914DEDC8EF8BF16AF2 Schach (Germany) ChannelF Germany +DFB66EE145FAB65062FDEADAFC8DC34C Slot Machine (USA) ChannelF USA +4CB12EDAE37DF23851884B82CA410754 Sonar Search (USA) ChannelF USA +32CCA8FF09041A39251D7AADE21EE22F Space War (USA) ChannelF USA +1B409FE1154584F4D1AB76B344A73D99 Spitfire (USA) ChannelF USA +7E5C26A6D1F9A90C68669A9800BA522D Tic-Tac-Toe, Shooting Gallery, Doodle, Quadra-Doodle (USA) ChannelF USA +B074C867F235FB69CED96C6916673B45 Video Blackjack (USA) ChannelF USA +90A9B3952568F91502A7088BFB0AE07E Video Whizball (USA) ChannelF USA diff --git a/Assets/gamedb/gamedb_vectrex.txt b/Assets/gamedb/gamedb_vectrex.txt new file mode 100644 index 0000000000..f4042d8ead --- /dev/null +++ b/Assets/gamedb/gamedb_vectrex.txt @@ -0,0 +1,3 @@ +SHA1:67F8513958C04E936B135740ED4EC6E6FA1763D5 Clean Sweep VEC +SHA1:38E38B5C60466146D4648F8929B5CE3A08DCBE0D Scramble VEC + diff --git a/BizHawk.Client.ApiHawk/Classes/Api/EmuApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/EmuApi.cs index a3cda9ed76..015bd52093 100644 --- a/BizHawk.Client.ApiHawk/Classes/Api/EmuApi.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/EmuApi.cs @@ -103,7 +103,7 @@ namespace BizHawk.Client.ApiHawk } catch (NotImplementedException) { - Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement disassemble()"); + Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDisassemblable.Disassemble)}()"); return null; } } @@ -124,7 +124,7 @@ namespace BizHawk.Client.ApiHawk } catch (NotImplementedException) { - Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement getregister()"); + Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.GetCpuFlagsAndRegisters)}()"); return null; } } @@ -147,7 +147,7 @@ namespace BizHawk.Client.ApiHawk } catch (NotImplementedException) { - Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement getregisters()"); + Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.GetCpuFlagsAndRegisters)}()"); } return table; @@ -166,7 +166,7 @@ namespace BizHawk.Client.ApiHawk } catch (NotImplementedException) { - Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement setregister()"); + Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.SetCpuRegister)}()"); } } @@ -183,7 +183,7 @@ namespace BizHawk.Client.ApiHawk } catch (NotImplementedException) { - Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement totalexecutedcycles()"); + Console.WriteLine($"Error: {Emulator.Attributes().CoreName} does not yet implement {nameof(IDebuggable.TotalExecutedCycles)}()"); return 0; } @@ -201,7 +201,7 @@ namespace BizHawk.Client.ApiHawk return InputPollableCore.IsLagFrame; } - Console.WriteLine($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); + Console.WriteLine($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); return false; } @@ -213,7 +213,7 @@ namespace BizHawk.Client.ApiHawk } else { - Console.WriteLine($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); + Console.WriteLine($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); } } @@ -224,7 +224,7 @@ namespace BizHawk.Client.ApiHawk return InputPollableCore.LagCount; } - Console.WriteLine($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); + Console.WriteLine($"Can not get lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); return 0; } @@ -236,7 +236,7 @@ namespace BizHawk.Client.ApiHawk } else { - Console.WriteLine($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement IInputPollable"); + Console.WriteLine($"Can not set lag information, {Emulator.Attributes().CoreName} does not implement {nameof(IInputPollable)}"); } } diff --git a/BizHawk.Client.ApiHawk/Classes/Api/JoypadApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/JoypadApi.cs index 0c049ed97c..a1074d5507 100644 --- a/BizHawk.Client.ApiHawk/Classes/Api/JoypadApi.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/JoypadApi.cs @@ -20,9 +20,9 @@ namespace BizHawk.Client.ApiHawk { 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)}"); } } @@ -32,9 +32,9 @@ namespace BizHawk.Client.ApiHawk { 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)}"); } } @@ -81,7 +81,7 @@ namespace BizHawk.Client.ApiHawk } catch (Exception) { - Console.WriteLine("invalid mnemonic string: " + inputLogEntry); + Console.WriteLine($"invalid mnemonic string: {inputLogEntry}"); } } @@ -119,7 +119,7 @@ namespace BizHawk.Client.ApiHawk var toPress = button.ToString(); if (controller.HasValue) { - toPress = "P" + controller + " " + button; + toPress = $"P{controller} {button}"; } if (!invert) @@ -154,7 +154,7 @@ namespace BizHawk.Client.ApiHawk var toPress = button; if (controller.HasValue) { - toPress = "P" + controller + " " + button; + toPress = $"P{controller} {button}"; } if (state.HasValue) Global.LuaAndAdaptor.SetButton(toPress, state.Value); @@ -191,7 +191,7 @@ namespace BizHawk.Client.ApiHawk } else { - Global.StickyXORAdapter.SetFloat("P" + controller + " " + name, theValue); + Global.StickyXORAdapter.SetFloat($"P{controller} {name}", theValue); } } } @@ -210,7 +210,7 @@ namespace BizHawk.Client.ApiHawk } else { - Global.StickyXORAdapter.SetFloat("P" + controller + " " + control, value); + Global.StickyXORAdapter.SetFloat($"P{controller} {control}", value); } } catch diff --git a/BizHawk.Client.ApiHawk/Classes/Api/MemApiBase.cs b/BizHawk.Client.ApiHawk/Classes/Api/MemApiBase.cs index bc5c328d66..dd6a6377a9 100644 --- a/BizHawk.Client.ApiHawk/Classes/Api/MemApiBase.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/MemApiBase.cs @@ -64,7 +64,7 @@ namespace BizHawk.Client.ApiHawk return d.PeekByte(addr); } - Console.WriteLine("Warning: attempted read of " + addr + " outside the memory size of " + d.Size); + Console.WriteLine($"Warning: attempted read of {addr} outside the memory size of {d.Size}"); return 0; } @@ -79,7 +79,7 @@ namespace BizHawk.Client.ApiHawk } else { - Console.WriteLine("Warning: attempted write to " + addr + " outside the memory size of " + d.Size); + Console.WriteLine($"Warning: attempted write to {addr} outside the memory size of {d.Size}"); } } else @@ -165,8 +165,8 @@ namespace BizHawk.Client.ApiHawk { if (addr < d.Size) list.Add(d.PeekByte(addr)); - else { - Console.WriteLine("Warning: Attempted read " + addr + " outside memory domain size of " + d.Size + " in readbyterange()"); + else { + Console.WriteLine($"Warning: Attempted read {addr} outside memory domain size of {d.Size} in {nameof(ReadByteRange)}()"); list.Add(0); } } @@ -187,7 +187,7 @@ namespace BizHawk.Client.ApiHawk } else { - Console.WriteLine("Warning: Attempted write " + addr + " outside memory domain size of " + d.Size + " in writebyterange()"); + Console.WriteLine($"Warning: Attempted write {addr} outside memory domain size of {d.Size} in {nameof(WriteByteRange)}()"); } } } @@ -207,7 +207,7 @@ namespace BizHawk.Client.ApiHawk return BitConverter.ToSingle(bytes, 0); } - Console.WriteLine("Warning: Attempted read " + addr + " outside memory size of " + d.Size); + Console.WriteLine($"Warning: Attempted read {addr} outside memory size of {d.Size}"); return 0; } @@ -226,7 +226,7 @@ namespace BizHawk.Client.ApiHawk } else { - Console.WriteLine("Warning: Attempted write " + addr + " outside memory size of " + d.Size); + Console.WriteLine($"Warning: Attempted write {addr} outside memory size of {d.Size}"); } } else diff --git a/BizHawk.Client.ApiHawk/Classes/Api/MovieApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/MovieApi.cs index 0b74cfd5cc..049cdb4fa3 100644 --- a/BizHawk.Client.ApiHawk/Classes/Api/MovieApi.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/MovieApi.cs @@ -169,7 +169,7 @@ namespace BizHawk.Client.ApiHawk 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.ApiHawk/Classes/Api/SqlApi.cs b/BizHawk.Client.ApiHawk/Classes/Api/SqlApi.cs index 6a18d507af..4b66a827f9 100644 --- a/BizHawk.Client.ApiHawk/Classes/Api/SqlApi.cs +++ b/BizHawk.Client.ApiHawk/Classes/Api/SqlApi.cs @@ -87,7 +87,7 @@ namespace BizHawk.Client.ApiHawk { var table = new Dictionary(); 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; @@ -101,7 +101,7 @@ namespace BizHawk.Client.ApiHawk { 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.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs b/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs index 935df8122f..e05823994b 100644 --- a/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs +++ b/BizHawk.Client.ApiHawk/Classes/BizHawkSystemIdToCoreSystemEnumConverter.cs @@ -93,6 +93,9 @@ namespace BizHawk.Client.ApiHawk case "TI83": return CoreSystem.TI83; + case "VEC": + return CoreSystem.Vectrex; + case "WSWAN": return CoreSystem.WonderSwan; @@ -102,6 +105,12 @@ namespace BizHawk.Client.ApiHawk case "AmstradCPC": return CoreSystem.AmstradCPC; + case "GGL": + return CoreSystem.GGL; + + case "ChannelF": + return CoreSystem.ChannelF; + case "VB": case "NGP": case "DNGP": @@ -112,7 +121,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 +227,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 19d01f9f08..5449083ff1 100644 --- a/BizHawk.Client.ApiHawk/Classes/ClientApi.cs +++ b/BizHawk.Client.ApiHawk/Classes/ClientApi.cs @@ -97,7 +97,9 @@ namespace BizHawk.Client.ApiHawk method = mainFormClass.GetMethod(name, typeList.ToArray()); } else method = mainFormClass.GetMethod(name); - method.Invoke(clientMainFormInstance, paramList); + + if(method != null) + method.Invoke(clientMainFormInstance, paramList); } private static object GetMainFormField(string name) @@ -145,7 +147,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 { @@ -161,7 +163,7 @@ namespace BizHawk.Client.ApiHawk /// Savetate friendly name public static void LoadState(string name) { - InvokeMainFormMethod("LoadState", 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 }); } @@ -250,7 +252,7 @@ namespace BizHawk.Client.ApiHawk /// Savetate friendly name public static void SaveState(string name) { - InvokeMainFormMethod("SaveState", 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 }); } /// @@ -358,7 +360,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 { @@ -376,11 +378,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); } } } @@ -392,8 +394,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); } }*/ } @@ -446,8 +448,8 @@ 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"); } } } @@ -650,7 +652,7 @@ namespace BizHawk.Client.ApiHawk object osd = f.GetValue(null); t = f.GetType(); MethodInfo m = t.GetMethod("AddMessage"); - m.Invoke(osd, new Object[] { "Window size set to " + size + "x" }); + m.Invoke(osd, new Object[] { $"Window size set to {size}x" }); } else { 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/IComm.cs b/BizHawk.Client.ApiHawk/Interfaces/Api/IComm.cs index 9ef8a5e0c0..e3fe09b68a 100644 --- a/BizHawk.Client.ApiHawk/Interfaces/Api/IComm.cs +++ b/BizHawk.Client.ApiHawk/Interfaces/Api/IComm.cs @@ -13,7 +13,7 @@ #region MemoryMappedFiles void MmfSetFilename(string filename); - string MmfSetFilename(); + string MmfGetFilename(); int MmfScreenshot(); int MmfWrite(string mmf_filename, string outputString); string MmfRead(string mmf_filename, int expectedSize); diff --git a/BizHawk.Client.Common/7z/LibraryManager.cs b/BizHawk.Client.Common/7z/LibraryManager.cs index ac0aedd2ee..6f2f375862 100644 --- a/BizHawk.Client.Common/7z/LibraryManager.cs +++ b/BizHawk.Client.Common/7z/LibraryManager.cs @@ -89,7 +89,7 @@ namespace SevenZip // private static string _LibraryVersion; private static bool? _modifyCapabale; - private static readonly PlatformLinkedLibSingleton.PlatformLinkedLibManager libLoader = PlatformLinkedLibSingleton.LinkedLibManager; + private static readonly OSTailoredCode.ILinkedLibManager libLoader = OSTailoredCode.LinkedLibManager; private static void InitUserInFormat(object user, InArchiveFormat format) { diff --git a/BizHawk.Client.Common/Api/CoreSystem.cs b/BizHawk.Client.Common/Api/CoreSystem.cs index d76625b963..05b63c7f96 100644 --- a/BizHawk.Client.Common/Api/CoreSystem.cs +++ b/BizHawk.Client.Common/Api/CoreSystem.cs @@ -29,8 +29,11 @@ WonderSwan, Libretro, VirtualBoy, + Vectrex, NeoGeoPocket, ZXSpectrum, - AmstradCPC + AmstradCPC, + GGL, + ChannelF } } 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/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 c233e7a7ec..c8ef120a66 100644 --- a/BizHawk.Client.Common/Global.cs +++ b/BizHawk.Client.Common/Global.cs @@ -154,6 +154,8 @@ namespace BizHawk.Client.Common return SystemInfo.ZXSpectrum; case "AmstradCPC": return SystemInfo.AmstradCPC; + case "ChannelF": + return SystemInfo.ChannelF; } } } diff --git a/BizHawk.Client.Common/OpenAdvanced.cs b/BizHawk.Client.Common/OpenAdvanced.cs index b26bff967e..251d49d89e 100644 --- a/BizHawk.Client.Common/OpenAdvanced.cs +++ b/BizHawk.Client.Common/OpenAdvanced.cs @@ -60,7 +60,7 @@ namespace BizHawk.Client.Common 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; } @@ -87,7 +87,7 @@ namespace BizHawk.Client.Common 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) diff --git a/BizHawk.Client.Common/PathManager.cs b/BizHawk.Client.Common/PathManager.cs index 465dacb381..14af64ccbb 100644 --- a/BizHawk.Client.Common/PathManager.cs +++ b/BizHawk.Client.Common/PathManager.cs @@ -34,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() @@ -262,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) @@ -289,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"] ?? @@ -337,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 f06cf75020..0c3ff35062 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -17,6 +17,7 @@ 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; @@ -27,6 +28,8 @@ using GPGX64 = BizHawk.Emulation.Cores.Consoles.Sega.gpgx; using BizHawk.Emulation.Cores.Consoles.Sega.Saturn; using BizHawk.Emulation.Cores.Consoles.NEC.PCFX; using BizHawk.Emulation.Cores.Computers.AmstradCPC; +using BizHawk.Emulation.Cores.Consoles.Vectrex; +using BizHawk.Emulation.Cores.Consoles.ChannelF; namespace BizHawk.Client.Common { @@ -218,7 +221,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) @@ -427,7 +430,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) @@ -495,7 +498,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; @@ -728,7 +731,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) @@ -805,6 +808,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; } @@ -1061,6 +1080,9 @@ namespace BizHawk.Client.Common Deterministic); nextEmulator = zx; break; + case "ChannelF": + nextEmulator = new ChannelF(nextComm, game, rom.FileData, GetCoreSettings(), GetCoreSyncSettings()); + break; case "AmstradCPC": var cpc = new AmstradCPC(nextComm, Enumerable.Repeat(rom.RomData, 1), Enumerable.Repeat(rom.GameInfo, 1).ToList(), GetCoreSettings(), GetCoreSyncSettings()); nextEmulator = cpc; @@ -1154,12 +1176,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..6b631d0851 100644 --- a/BizHawk.Client.Common/SystemInfo.cs +++ b/BizHawk.Client.Common/SystemInfo.cs @@ -183,6 +183,11 @@ namespace BizHawk.Client.Common /// public static SystemInfo VirtualBoy { get; } = new SystemInfo("Virtual Boy", CoreSystem.VirtualBoy, 1); + /// + /// Gets the instance for Vectrex + /// + public static SystemInfo Vectrex { get; } = new SystemInfo("Vextrex", CoreSystem.Vectrex, 2); + /// /// Gets the instance for TI-83 /// @@ -198,14 +203,24 @@ namespace BizHawk.Client.Common /// public static SystemInfo AmstradCPC { get; } = new SystemInfo("Amstrad CPC", CoreSystem.AmstradCPC, 2); - #endregion Get SystemInfo + /// + /// Gets the instance for GGL + /// + 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) + /// + /// Gets the instance for ChannelF + /// + public static SystemInfo ChannelF { get; } = new SystemInfo("Channel F", CoreSystem.ChannelF, 2); + + #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 2ff5988861..c0bf196702 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Drawing; +using BizHawk.Common; using BizHawk.Emulation.Common; // ReSharper disable FieldCanBeMadeReadOnly.Global @@ -341,8 +342,13 @@ namespace BizHawk.Client.Common public int DispPrescale = 1; - // warning: we dont even want to deal with changing this at runtime. but we want it changed here for config purposes. so dont check this variable. check in GlobalWin or something like that. - public EDispMethod DispMethod = EDispMethod.SlimDX9; + /// + /// warning: we dont even want to deal with changing this at runtime. but we want it changed here for config purposes. so dont check this variable. check in GlobalWin or something like that. + /// force DX for Windows and GDI+ for Unix when a new config is generated + /// + public EDispMethod DispMethod = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows + ? EDispMethod.SlimDX9 + : EDispMethod.GdiPlus; public int DispChrome_FrameWindowed = 2; public bool DispChrome_StatusBarWindowed = true; @@ -370,11 +376,9 @@ namespace BizHawk.Client.Common public int DispCropBottom = 0; // Sound options -#if WINDOWS - public ESoundOutputMethod SoundOutputMethod = ESoundOutputMethod.DirectSound; -#else - public ESoundOutputMethod SoundOutputMethod = ESoundOutputMethod.OpenAL; -#endif + public ESoundOutputMethod SoundOutputMethod = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows + ? ESoundOutputMethod.DirectSound + : ESoundOutputMethod.OpenAL; // force OpenAL for Unix when config is generated public bool SoundEnabled = true; public bool SoundEnabledNormal = true; public bool SoundEnabledRWFF = true; diff --git a/BizHawk.Client.Common/config/PathEntry.cs b/BizHawk.Client.Common/config/PathEntry.cs index 9b6b710212..7df0046165 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[] { @@ -382,6 +382,12 @@ namespace BizHawk.Client.Common new PathEntry { System = "PCFX", SystemDisplayName = "PCFX", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, new PathEntry { System = "PCFX", SystemDisplayName = "PCFX", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, new PathEntry { System = "PCFX", SystemDisplayName = "PCFX", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, + + new PathEntry { System = "ChannelF", SystemDisplayName = "Fairchild Channel F", Type = "Base", Path = Path.Combine(".", "ZXSpectrum"), Ordinal = 0 }, + new PathEntry { System = "ChannelF", SystemDisplayName = "Fairchild Channel F", Type = "ROM", Path = ".", Ordinal = 1 }, + new PathEntry { System = "ChannelF", SystemDisplayName = "Fairchild Channel F", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 }, + new PathEntry { System = "ChannelF", SystemDisplayName = "Fairchild Channel F", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, + new PathEntry { System = "ChannelF", SystemDisplayName = "Fairchild Channel F", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, }; } } 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 594ae78d2e..1ec246820e 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.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 5cbc8d2df2..ac03a3c9d4 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.SQL.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.SQL.cs @@ -105,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; @@ -119,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 2fa7471105..8b6b40737e 100644 --- a/BizHawk.Client.Common/lua/LuaDocumentation.cs +++ b/BizHawk.Client.Common/lua/LuaDocumentation.cs @@ -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..ab1ebdd9e3 100644 --- a/BizHawk.Client.Common/lua/LuaSandbox.cs +++ b/BizHawk.Client.Common/lua/LuaSandbox.cs @@ -1,5 +1,8 @@ using System; using System.Runtime.InteropServices; + +using BizHawk.Common; + using NLua; // TODO - evaluate for re-entrancy problems @@ -18,16 +21,14 @@ namespace BizHawk.Client.Common private string _currentDirectory; - #if WINDOWS [DllImport("kernel32.dll", SetLastError = true)] static extern bool SetCurrentDirectoryW(byte* lpPathName); [DllImport("kernel32.dll", SetLastError=true)] static extern uint GetCurrentDirectoryW(uint nBufferLength, byte* pBuffer); - #endif 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 @@ -42,40 +43,43 @@ namespace BizHawk.Client.Common return true; } - // 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]) + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) + { + // WARNING: setting the current directory is SLOW!!! security checks for some reason. + // so we're bypassing it with windows hacks + 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 - { - Environment.CurrentDirectory = CurrentDirectory; // thats right, you can't set a directory as current that doesnt exist because .net's got to do SENSELESS SLOW-ASS SECURITY CHECKS on it and it can't do that on a NONEXISTENT DIRECTORY - return true; - } - else - { - return false; - } - #endif + } + else + { + if (System.IO.Directory.Exists(_currentDirectory)) // race condition for great justice + { + Environment.CurrentDirectory = _currentDirectory; // thats right, you can't set a directory as current that doesnt exist because .net's got to do SENSELESS SLOW-ASS SECURITY CHECKS on it and it can't do that on a NONEXISTENT DIRECTORY + return true; + } + else + { + return false; + } + } } private string CoolGetCurrentDirectory() { - // GUESS WHAT! - // .NET DOES A SECURITY CHECK ON THE DIRECTORY WE JUST RETRIEVED - // AS IF ASKING FOR THE CURRENT DIRECTORY IS EQUIVALENT TO TRYING TO ACCESS IT - // SCREW YOU - #if WINDOWS + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) + { + // GUESS WHAT! + // .NET DOES A SECURITY CHECK ON THE DIRECTORY WE JUST RETRIEVED + // AS IF ASKING FOR THE CURRENT DIRECTORY IS EQUIVALENT TO TRYING TO ACCESS IT + // SCREW YOU var buf = new byte[32768]; - fixed(byte* pBuf = &buf[0]) - { - uint ret = GetCurrentDirectoryW(32767, pBuf); - return System.Text.Encoding.Unicode.GetString(buf, 0, (int)ret*2); - } - #else + fixed (byte* pBuf = &buf[0]) + return System.Text.Encoding.Unicode.GetString(buf, 0, 2 * (int) GetCurrentDirectoryW(32767, pBuf)); + } + else + { return Environment.CurrentDirectory; - #endif + } } private void Sandbox(Action callback, Action exceptionCallback) diff --git a/BizHawk.Client.Common/lua/NamedLuaFunction.cs b/BizHawk.Client.Common/lua/NamedLuaFunction.cs index 9737d77a93..bb602e8f62 100644 --- a/BizHawk.Client.Common/lua/NamedLuaFunction.cs +++ b/BizHawk.Client.Common/lua/NamedLuaFunction.cs @@ -25,11 +25,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.HeaderApi.cs b/BizHawk.Client.Common/movie/bk2/Bk2Movie.HeaderApi.cs index e042e1bd39..41ca3d7015 100644 --- a/BizHawk.Client.Common/movie/bk2/Bk2Movie.HeaderApi.cs +++ b/BizHawk.Client.Common/movie/bk2/Bk2Movie.HeaderApi.cs @@ -93,11 +93,17 @@ namespace BizHawk.Client.Common { if (value) { - Header.Add(HeaderKeys.STARTSFROMSAVERAM, "True"); + if (!Header.ContainsKey(HeaderKeys.STARTSFROMSAVERAM)) + { + Header.Add(HeaderKeys.STARTSFROMSAVERAM, "True"); + } } else { - Header.Remove(HeaderKeys.STARTSFROMSAVERAM); + if (Header.ContainsKey(HeaderKeys.STARTSFROMSAVERAM)) + { + Header.Remove(HeaderKeys.STARTSFROMSAVERAM); + } } } } 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 99716f7617..ac88cba786 100644 --- a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs +++ b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs @@ -16,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)) { @@ -26,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 @@ -131,11 +131,11 @@ namespace BizHawk.Client.Common.MovieConversionExtensions if (old.Filename.Contains("tasproj")) { newFilename = newFilename.Remove(newFilename.Length - 7, 7); - newFilename = newFilename + "nfn." + TasMovie.Extension; + newFilename = $"{newFilename}nfn.{TasMovie.Extension}"; } else { - newFilename = old.Filename + "." + TasMovie.Extension; + newFilename = $"{old.Filename}.{TasMovie.Extension}"; } if (File.Exists(newFilename)) @@ -146,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 @@ -216,11 +216,11 @@ namespace BizHawk.Client.Common.MovieConversionExtensions if (old.Filename.Contains("tasproj")) { newFilename = newFilename.Remove(newFilename.Length - 7, 7); - newFilename = newFilename + "nfsr." + TasMovie.Extension; + newFilename = $"{newFilename}nfsr.{TasMovie.Extension}"; } else { - newFilename = old.Filename + "." + TasMovie.Extension; + newFilename = $"{old.Filename}.{TasMovie.Extension}"; } if (File.Exists(newFilename)) @@ -231,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 @@ -323,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)) { 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/StateManagerDecay.cs b/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs index 4d551f86e6..f7b3130881 100644 --- a/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs +++ b/BizHawk.Client.Common/movie/tasproj/StateManagerDecay.cs @@ -156,6 +156,8 @@ namespace BizHawk.Client.Common backwardFrame = currentFrame; } } + + int decayStatesLast = decayStates; if (forwardFrame > -1 && backwardFrame > -1) { @@ -192,10 +194,11 @@ namespace BizHawk.Client.Common decayStates--; } } - else - { + // we're very sorry about failing to find states to remove, but we can't go beyond capacity, so remove at least something // this shouldn't happen, but if we don't do it here, nothing good will happen either + if (decayStatesLast == decayStates) + { if (_tsm.RemoveState(_tsm.GetStateFrameByIndex(1))) { // decrementing this if no state was removed is BAD 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 a226d2d17f..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); @@ -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); 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 79a9ef03aa..360966dac0 100644 --- a/BizHawk.Client.Common/tools/Watch/DWordWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/DWordWatch.cs @@ -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.DBMan/DATTools/DATParserBase.cs b/BizHawk.Client.DBMan/DATTools/DATParserBase.cs index f13196463c..7034724261 100644 --- a/BizHawk.Client.DBMan/DATTools/DATParserBase.cs +++ b/BizHawk.Client.DBMan/DATTools/DATParserBase.cs @@ -218,6 +218,7 @@ namespace BizHawk.Client.DBMan Lynx, VB, UZE, - NGP + NGP, + ChannelF } } 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..ccb9f64379 100644 --- a/BizHawk.Client.EmuHawk/AVOut/FFmpegWriter.cs +++ b/BizHawk.Client.EmuHawk/AVOut/FFmpegWriter.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Common; using BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk @@ -85,14 +86,10 @@ namespace BizHawk.Client.EmuHawk try { _ffmpeg = new Process(); -#if WINDOWS - _ffmpeg.StartInfo.FileName = Path.Combine(PathManager.GetDllDirectory(), "ffmpeg.exe"); -#else - 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.FileName = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows + ? Path.Combine(PathManager.GetDllDirectory(), "ffmpeg.exe") + : "ffmpeg"; + _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 +97,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 +129,7 @@ namespace BizHawk.Client.EmuHawk _stderr.Dequeue(); } - _stderr.Enqueue(line.Data + "\n"); + _stderr.Enqueue($"{line.Data}\n"); } } @@ -193,7 +190,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 +200,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 +221,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 +271,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 +286,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 004c288d58..510ca56392 100644 --- a/BizHawk.Client.EmuHawk/AVOut/FFmpegWriterForm.cs +++ b/BizHawk.Client.EmuHawk/AVOut/FFmpegWriterForm.cs @@ -61,7 +61,7 @@ namespace BizHawk.Client.EmuHawk new FormatPreset("MP4", "AVC video and AAC audio in an MP4 container.", "-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.", @@ -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..cf4643b863 100644 --- a/BizHawk.Client.EmuHawk/AboutBox.cs +++ b/BizHawk.Client.EmuHawk/AboutBox.cs @@ -163,24 +163,16 @@ 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.Month == 12) + { if (DateTime.Now.Day > 17 && DateTime.Now.Day <= 25) { pictureBox1.Image = Properties.Resources.alt_about_image; } - - if (DateTime.Now.Month == 2) - { - if (DateTime.Now.Day >= 7 && DateTime.Now.Day <= 14) - { - pictureBox1.Image = Properties.Resources.HawkInLove; - pictureBox1.Location = new Point(pictureBox1.Location.X - 40, pictureBox1.Location.Y); - pictureBox1.Width = pictureBox1.Width + 80; - } } } diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/CommApi.cs b/BizHawk.Client.EmuHawk/Api/Libraries/CommApi.cs index 152658c639..e66cd0304b 100644 --- a/BizHawk.Client.EmuHawk/Api/Libraries/CommApi.cs +++ b/BizHawk.Client.EmuHawk/Api/Libraries/CommApi.cs @@ -33,7 +33,7 @@ namespace BizHawk.Client.EmuHawk public string SocketServerSend(string SendString) { - return "Sent : " + GlobalWin.socketServer.SendString(SendString).ToString() + " bytes"; + return $"Sent : {GlobalWin.socketServer.SendString(SendString)} bytes"; } public string SocketServerResponse() { @@ -48,14 +48,41 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.socketServer.SetTimeout(timeout); } + + public void SocketServerSetIp(string ip) + { + GlobalWin.socketServer.Ip = ip; + } + + public void SetSocketServerPort(int port) + { + GlobalWin.socketServer.Port = port; + } + + public string SocketServerGetIp() + { + return GlobalWin.socketServer.Ip; + } + + public int SocketServerGetPort() + { + return GlobalWin.socketServer.Port; + } + + public string SocketServerGetInfo() + { + return GlobalWin.socketServer.GetInfo(); + } + // All MemoryMappedFile related methods public void MmfSetFilename(string filename) { - GlobalWin.memoryMappedFiles.SetFilename(filename); + GlobalWin.memoryMappedFiles.Filename = filename; } - public string MmfSetFilename() + + public string MmfGetFilename() { - return GlobalWin.memoryMappedFiles.GetFilename(); + return GlobalWin.memoryMappedFiles.Filename; } public int MmfScreenshot() @@ -67,10 +94,13 @@ namespace BizHawk.Client.EmuHawk { 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() { @@ -103,19 +133,19 @@ namespace BizHawk.Client.EmuHawk } public void HttpSetPostUrl(string url) { - GlobalWin.httpCommunication.SetPostUrl(url); + GlobalWin.httpCommunication.PostUrl = url; } public void HttpSetGetUrl(string url) { - GlobalWin.httpCommunication.SetGetUrl(url); + GlobalWin.httpCommunication.GetUrl = url; } public string HttpGetPostUrl() { - return GlobalWin.httpCommunication.GetPostUrl(); + return GlobalWin.httpCommunication.PostUrl; } public string HttpGetGetUrl() { - return GlobalWin.httpCommunication.GetGetUrl(); + return GlobalWin.httpCommunication.GetUrl; } } } diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs b/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs index 5270a6eece..6f16a229b1 100644 --- a/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs +++ b/BizHawk.Client.EmuHawk/Api/Libraries/GuiApi.cs @@ -303,7 +303,7 @@ namespace BizHawk.Client.EmuHawk { if (!File.Exists(path)) { - AddMessage("File not found: " + path); + AddMessage($"File not found: {path}"); return; } @@ -331,7 +331,7 @@ namespace BizHawk.Client.EmuHawk { if (!File.Exists(path)) { - Console.WriteLine("File not found: " + path); + Console.WriteLine($"File not found: {path}"); return; } @@ -371,7 +371,7 @@ namespace BizHawk.Client.EmuHawk { if (!File.Exists(path)) { - Console.WriteLine("File not found: " + path); + Console.WriteLine($"File not found: {path}"); return; } diff --git a/BizHawk.Client.EmuHawk/Api/Libraries/SaveStateAPI.cs b/BizHawk.Client.EmuHawk/Api/Libraries/SaveStateAPI.cs index df75742920..d4b1cdbe2f 100644 --- a/BizHawk.Client.EmuHawk/Api/Libraries/SaveStateAPI.cs +++ b/BizHawk.Client.EmuHawk/Api/Libraries/SaveStateAPI.cs @@ -27,7 +27,7 @@ namespace BizHawk.Client.EmuHawk { if (slotNum >= 0 && slotNum <= 9) { - GlobalWin.MainForm.LoadQuickSave("QuickSave" + slotNum, true); + GlobalWin.MainForm.LoadQuickSave($"QuickSave{slotNum}", true); } } @@ -40,7 +40,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/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 6c4823af50..6d053c97aa 100644 --- a/BizHawk.Client.EmuHawk/ArgParser.cs +++ b/BizHawk.Client.EmuHawk/ArgParser.cs @@ -2,14 +2,15 @@ using System.Collections.Generic; using System.Linq; using System.IO; +using System.Windows.Forms; namespace BizHawk.Client.EmuHawk { - class ArgParser - //parses command line arguments and adds the values to a class attribute - //default values are null for strings and false for boolean - //the last value will overwrite previously set values - //unrecognized parameters are simply ignored or in the worst case assumed to be a ROM name [cmdRom] + class ArgParser + //parses command line arguments and adds the values to a class attribute + //default values are null for strings and false for boolean + //the last value will overwrite previously set values + //unrecognized parameters are simply ignored or in the worst case assumed to be a ROM name [cmdRom] { public string cmdRom = null; public string cmdLoadSlot = null; @@ -21,28 +22,28 @@ namespace BizHawk.Client.EmuHawk public string cmdDumpName = null; public HashSet _currAviWriterFrameList; public int _autoDumpLength; - public bool _autoCloseOnDump = false; - // chrome is never shown, even in windowed mode + public bool _autoCloseOnDump = false; + // chrome is never shown, even in windowed mode public bool _chromeless = false; public bool startFullscreen = false; public string luaScript = null; public bool luaConsole = false; - public int socket_port = 9999; + public int socket_port = 0; public string socket_ip = null; public string mmf_filename = null; public string URL_get = null; public string URL_post = null; + public bool? audiosync = null; public void ParseArguments(string[] args) - { for (int i = 0; i < args.Length; i++) - { - // For some reason sometimes visual studio will pass this to us on the commandline. it makes no sense. + { + // For some reason sometimes visual studio will pass this to us on the commandline. it makes no sense. if (args[i] == ">") { i++; - var stdout = args[i]; + var stdout = args[i]; Console.SetOut(new StreamWriter(stdout)); continue; } @@ -77,9 +78,9 @@ namespace BizHawk.Client.EmuHawk foreach (string item in items) { _currAviWriterFrameList.Add(int.Parse(item)); - } - - // automatically set dump length to maximum frame + } + + // automatically set dump length to maximum frame _autoDumpLength = _currAviWriterFrameList.OrderBy(x => x).Last(); } else if (arg.StartsWith("--dump-name=")) @@ -131,43 +132,63 @@ namespace BizHawk.Client.EmuHawk { URL_post = args[i].Substring(args[i].IndexOf('=') + 1); } + else if (arg.StartsWith("--audiosync=")) + { + audiosync = arg.Substring(arg.IndexOf('=') + 1) == "true"; + } else { cmdRom = args[i]; } - } - ////initialize HTTP communication + } + + //initialize HTTP communication if (URL_get != null || URL_post != null) { + GlobalWin.httpCommunication = new Communication.HttpCommunication(); if (URL_get != null) { - GlobalWin.httpCommunication.initialized = true; - GlobalWin.httpCommunication.SetGetUrl(URL_get); + GlobalWin.httpCommunication.GetUrl = URL_get; } if (URL_post != null) { - GlobalWin.httpCommunication.initialized = true; - GlobalWin.httpCommunication.SetPostUrl(URL_post); + GlobalWin.httpCommunication.PostUrl = URL_post; } - } - //inititalize socket server - if (socket_ip != null && socket_port > -1) - { - GlobalWin.socketServer.initialized = true; + } + + //inititalize socket server + if (socket_ip != null && socket_port > 0) + { + GlobalWin.socketServer = new Communication.SocketServer(); GlobalWin.socketServer.SetIp(socket_ip, socket_port); } - else if (socket_ip != null) + else if (socket_ip == null ^ socket_port == 0) { - GlobalWin.socketServer.initialized = true; - GlobalWin.socketServer.SetIp(socket_ip); - } - - //initialize mapped memory files + throw new ArgParserException("Socket server needs both --socket_ip and --socket_port. Socket server was not started"); + } + + //initialize mapped memory files if (mmf_filename != null) { - GlobalWin.memoryMappedFiles.initialized = true; - GlobalWin.memoryMappedFiles.SetFilename(mmf_filename); + GlobalWin.memoryMappedFiles = new Communication.MemoryMappedFiles(); + GlobalWin.memoryMappedFiles.Filename = mmf_filename; } } + + public static string GetCmdConfigFile(string[] args) + { + return args.FirstOrDefault(arg => arg.StartsWith("--config=", StringComparison.InvariantCultureIgnoreCase))?.Substring(9); + } + } + + class ArgParserException : Exception + { + public ArgParserException() + { + } + + public ArgParserException(string message) : base(message) + { + } } -} +} \ No newline at end of file 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 53c12c988e..f8710bbc42 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -113,8 +113,8 @@ - - PlatformLinkedLibSingleton.cs + + OSTailoredCode.cs svnrev.cs @@ -1216,7 +1216,7 @@ TraceLogger.cs - + Component @@ -1252,6 +1252,7 @@ + @@ -2282,4 +2283,4 @@ - \ No newline at end of file + diff --git a/BizHawk.Client.EmuHawk/Communication.cs b/BizHawk.Client.EmuHawk/Communication.cs index ba61cd1671..ca6bd4b421 100644 --- a/BizHawk.Client.EmuHawk/Communication.cs +++ b/BizHawk.Client.EmuHawk/Communication.cs @@ -12,7 +12,6 @@ using BizHawk.Emulation.Common; using BizHawk.Client.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; using System.Windows.Forms; -using System.IO; namespace BizHawk.Client.EmuHawk { @@ -23,16 +22,14 @@ namespace BizHawk.Client.EmuHawk public class HttpCommunication { private static HttpClient client = new HttpClient(); - private string PostUrl = "http://localhost:9876/post/"; - private string GetUrl = "http://localhost:9876/index"; - public bool initialized = false; + public string PostUrl { get; set; } = null; + public string GetUrl { get; set; } = null; private ScreenShot screenShot = new ScreenShot(); public int timeout = 0; public int default_timeout = 500; public void SetTimeout(int _timeout) { - //timeout = _timeout.TotalMilliseconds; if (timeout == 0 && _timeout == 0) { timeout = default_timeout; @@ -41,32 +38,15 @@ namespace BizHawk.Client.EmuHawk { client.Timeout = new TimeSpan(0, 0, 0, _timeout / 1000, _timeout % 1000); timeout = _timeout; - } - - } - public void SetPostUrl(string url) - { - PostUrl = url; - } - public void SetGetUrl(string url) - { - GetUrl = url; - } - - public string GetGetUrl() - { - return GetUrl; - } - public string GetPostUrl() - { - return PostUrl; + } } public async Task Get(string url) { client.DefaultRequestHeaders.ConnectionClose = false; HttpResponseMessage response = await client.GetAsync(url).ConfigureAwait(false); - if (response.IsSuccessStatusCode) { + if (response.IsSuccessStatusCode) + { return await response.Content.ReadAsStringAsync(); } else @@ -82,11 +62,9 @@ namespace BizHawk.Client.EmuHawk try { response = await client.PostAsync(url, content).ConfigureAwait(false); - } catch (Exception e) { - MessageBox.Show(e.ToString()); return e.ToString(); } @@ -161,19 +139,40 @@ namespace BizHawk.Client.EmuHawk return Post(PostUrl, content).Result; } } + public class SocketServer { + string ip = null; + public string Ip + { + get { return ip; } + set + { + ip = value; + ipAdd = System.Net.IPAddress.Parse(ip); + Connect(); + } + } - public string ip = "192.168.178.21"; - public int port = 9999; - public Decoder decoder = Encoding.UTF8.GetDecoder(); - public Socket soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - public IPAddress ipAdd; - public IPEndPoint remoteEP; - public IVideoProvider currentVideoProvider = null; + int port = 0; + public int Port + { + get { return port; } + set + { + port = value; + Connect(); + } + } + + Decoder decoder = Encoding.UTF8.GetDecoder(); + Socket soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + IPAddress ipAdd; + IPEndPoint remoteEP; + IVideoProvider currentVideoProvider = null; public bool connected = false; public bool initialized = false; - public int retries = 10; + public int Retries { get; set; } = 10; public bool success = false; //indicates whether the last command was executed succesfully public void Initialize(IVideoProvider _currentVideoProvider) @@ -181,8 +180,8 @@ namespace BizHawk.Client.EmuHawk currentVideoProvider = _currentVideoProvider; SetIp(ip, port); initialized = true; - } + public void Connect() { if (!initialized) @@ -194,42 +193,40 @@ namespace BizHawk.Client.EmuHawk soc.Connect(remoteEP); connected = true; soc.ReceiveTimeout = 5; - - } - public void SetIp(string ip_) - { - ip = ip_; - ipAdd = System.Net.IPAddress.Parse(ip); - remoteEP = new IPEndPoint(ipAdd, port); } + public void SetIp(string ip_, int port_) { ip = ip_; port = port_; ipAdd = System.Net.IPAddress.Parse(ip); remoteEP = new IPEndPoint(ipAdd, port); - } + + public string GetInfo() + { + return $"{ip}:{port}"; + } + public void SetTimeout(int timeout) { soc.ReceiveTimeout = timeout; } + public void SocketConnected() { bool part1 = soc.Poll(1000, SelectMode.SelectRead); bool part2 = (soc.Available == 0); - if (part1 && part2) - connected = false; - else - connected = true; + connected = !(part1 && part2); } + public int SendString(string SendString) { - int sentBytes = SendBytes(Encoding.ASCII.GetBytes(SendString)); success = sentBytes > 0; return sentBytes; } + public int SendBytes(byte[] SendBytes) { int sentBytes = 0; @@ -248,6 +245,7 @@ namespace BizHawk.Client.EmuHawk { return SendScreenshot(0); } + public string SendScreenshot(int waitingTime) { if (!connected) @@ -262,7 +260,7 @@ namespace BizHawk.Client.EmuHawk byte[] bmpBytes = screenShot.ImageToByte(img); int sentBytes = 0; int tries = 0; - while (sentBytes <= 0 && tries < retries) + while (sentBytes <= 0 && tries < Retries) { try { @@ -279,7 +277,7 @@ namespace BizHawk.Client.EmuHawk Connect(); } } - success = (tries < retries); + success = (tries < Retries); } } String resp = ""; @@ -294,7 +292,7 @@ namespace BizHawk.Client.EmuHawk { return resp; } - resp = ""; + resp = ReceiveMessage(); if (resp == "") { @@ -302,6 +300,7 @@ namespace BizHawk.Client.EmuHawk } return resp; } + public string ReceiveMessage() { if (!connected) @@ -318,14 +317,15 @@ namespace BizHawk.Client.EmuHawk { receivedLength = soc.Receive(receivedBytes, receivedBytes.Length, 0); resp += Encoding.ASCII.GetString(receivedBytes); - } catch + } + catch { receivedLength = 0; } } - return resp; } + public bool Successful() { return success; @@ -334,29 +334,19 @@ namespace BizHawk.Client.EmuHawk public class MemoryMappedFiles { - public string filename_main = "BizhawkTemp_main"; + public string Filename { get; set; } = "BizhawkTemp_main"; public Dictionary mmf_files = new Dictionary(); public int index = 0; - public bool initialized = false; public int main_size = 10 ^ 5; ScreenShot screenShot = new ScreenShot(); - public void SetFilename(string filename) - { - filename_main = filename; - } - public string GetFilename() - { - return filename_main; - } - public int ScreenShotToFile() { ScreenShot screenShot = new ScreenShot(); var bb = screenShot.MakeScreenShotImage(); var img = bb.ToSysdrawingBitmap(); byte[] bmpBytes = screenShot.ImageToByte(img); - return WriteToFile(@filename_main, bmpBytes); + return WriteToFile(@Filename, bmpBytes); } public int WriteToFile(string filename, byte[] outputBytes) @@ -384,7 +374,6 @@ namespace BizHawk.Client.EmuHawk } catch (Exception) { - } mmf_file = MemoryMappedFile.CreateOrOpen(filename, outputBytes.Length); @@ -417,6 +406,7 @@ namespace BizHawk.Client.EmuHawk { private IVideoProvider currentVideoProvider = null; private ImageConverter converter = new ImageConverter(); + public BitmapBuffer MakeScreenShotImage() { if (currentVideoProvider == null) @@ -425,14 +415,17 @@ namespace BizHawk.Client.EmuHawk } return GlobalWin.DisplayManager.RenderVideoProvider(currentVideoProvider); } + public byte[] ImageToByte(Image img) { return (byte[])converter.ConvertTo(img, typeof(byte[])); } + public string ImageToString(Image img) { return Convert.ToBase64String(ImageToByte(img)); } + public string GetScreenShotAsString() { BitmapBuffer bb = MakeScreenShotImage(); @@ -440,6 +433,18 @@ namespace BizHawk.Client.EmuHawk return Convert.ToBase64String(imgBytes); } } + + class CommunicationSocketServerException : Exception + { + public CommunicationSocketServerException() + { + } + + public CommunicationSocketServerException(string message) : base(message) + { + } + } } } + 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..3cd63c326b 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs @@ -1196,7 +1196,7 @@ namespace BizHawk.Client.EmuHawk if (AllowRightClickSelecton && e.Button == MouseButtons.Right) { - if (!IsHoveringOnColumnCell) + if (!IsHoveringOnColumnCell && CurrentCell != null) { _currentX = e.X; _currentY = e.Y; @@ -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 377edac627..cf8783c48d 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs @@ -306,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; } @@ -491,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(); @@ -915,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)) @@ -939,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 06a2bbaab5..fa26cc5d71 100644 --- a/BizHawk.Client.EmuHawk/GlobalWin.cs +++ b/BizHawk.Client.EmuHawk/GlobalWin.cs @@ -26,8 +26,8 @@ namespace BizHawk.Client.EmuHawk public static GLManager GLManager; public static int ExitCode; - public static Communication.HttpCommunication httpCommunication = new Communication.HttpCommunication(); - public static Communication.SocketServer socketServer = new Communication.SocketServer(); - public static Communication.MemoryMappedFiles memoryMappedFiles = new Communication.MemoryMappedFiles(); + public static Communication.HttpCommunication httpCommunication = null; + public static Communication.SocketServer socketServer = null; + public static Communication.MemoryMappedFiles memoryMappedFiles = null; } } 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 0727baeffe..a890029682 100644 --- a/BizHawk.Client.EmuHawk/Input/Input.cs +++ b/BizHawk.Client.EmuHawk/Input/Input.cs @@ -123,24 +123,24 @@ namespace BizHawk.Client.EmuHawk public static void Initialize() { - if (PlatformLinkedLibSingleton.RunningOnUnix) - { - OTK_Keyboard.Initialize(); -// OTK_Gamepad.Initialize(); - } - else + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) { KeyInput.Initialize(); IPCKeyInput.Initialize(); GamePad.Initialize(); GamePad360.Initialize(); } + else + { + OTK_Keyboard.Initialize(); +// OTK_Gamepad.Initialize(); + } Instance = new Input(); } public static void Cleanup() { - if (!PlatformLinkedLibSingleton.RunningOnUnix) + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) { KeyInput.Cleanup(); GamePad.Cleanup(); @@ -198,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()}"; } } @@ -234,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,18 +331,18 @@ namespace BizHawk.Client.EmuHawk { while (true) { - var keyEvents = PlatformLinkedLibSingleton.RunningOnUnix - ? OTK_Keyboard.Update() - : KeyInput.Update().Concat(IPCKeyInput.Update()); - if (PlatformLinkedLibSingleton.RunningOnUnix) - { - //TODO - } - else + var keyEvents = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows + ? KeyInput.Update().Concat(IPCKeyInput.Update()) + : OTK_Keyboard.Update(); + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) { GamePad.UpdateAll(); GamePad360.UpdateAll(); } + else + { + //TODO + } //this block is going to massively modify data structures that the binding method uses, so we have to lock it all lock (this) @@ -360,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()) @@ -376,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()) @@ -513,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/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 b7df5e2f76..930017ff83 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -354,6 +354,8 @@ this.DGBsettingsToolStripMenuItem = 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(); @@ -507,6 +509,7 @@ this.SaturnSubMenu, this.DGBSubMenu, this.DGBHawkSubMenu, + this.GGLSubMenu, this.GenesisSubMenu, this.wonderSwanToolStripMenuItem, this.AppleSubMenu, @@ -3205,6 +3208,21 @@ 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[] { @@ -3847,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); @@ -4533,6 +4552,8 @@ 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; diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 1475a7e2dd..4ece99a72f 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -25,6 +25,7 @@ using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Client.EmuHawk.ToolExtensions; using BizHawk.Emulation.Cores.Computers.AppleII; using BizHawk.Client.ApiHawk; +using BizHawk.Common; using BizHawk.Emulation.Cores.Computers.Commodore64; using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Computers.SinclairSpectrum; @@ -443,12 +444,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) @@ -683,7 +684,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 { @@ -1364,7 +1365,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) @@ -1383,7 +1384,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}"); } } @@ -1469,7 +1470,14 @@ namespace BizHawk.Client.EmuHawk private void RamSearchMenuItem_Click(object sender, EventArgs e) { - GlobalWin.Tools.Load(); + var ramSearch = GlobalWin.Tools.Load(); + if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows) + { + // this is apparently needed for weird mono-forms-on-different-thread issues + // dont do .Show() within Load() for RamSearch - instead put an instance of it here on MainForm, then show here + // the mono winforms implementation is.... weird and buggy + ramSearch.Show(); + } } private void LuaConsoleMenuItem_Click(object sender, EventArgs e) @@ -1601,10 +1609,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."); } } } @@ -2377,6 +2385,15 @@ namespace BizHawk.Client.EmuHawk #endregion + #region GGL + + private void GGLSettingsMenuItem_Click(object sender, EventArgs e) + { + GenericCoreConfig.DoDialog(this, "Game Gear Settings"); + } + + #endregion + #region GEN private void GenVdpViewerMenuItem_Click(object sender, EventArgs e) @@ -2431,8 +2448,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 }; @@ -2470,8 +2487,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 }; @@ -2572,8 +2589,8 @@ namespace BizHawk.Client.EmuHawk var menuItem = new ToolStripMenuItem { - Name = i + "_" + name, - Text = i + ": " + name, + Name = $"{i}_{name}", + Text = $"{i}: {name}", Checked = currSel == i }; @@ -2607,8 +2624,8 @@ namespace BizHawk.Client.EmuHawk var menuItem = new ToolStripMenuItem { - Name = i + "_" + name, - Text = i + ": " + name, + Name = $"{i}_{name}", + Text = $"{i}: {name}", Checked = currSel == i }; @@ -2696,8 +2713,8 @@ namespace BizHawk.Client.EmuHawk var menuItem = new ToolStripMenuItem { - Name = i + "_" + name, - Text = i + ": " + name, + Name = $"{i}_{name}", + Text = $"{i}: {name}", Checked = currSel == i }; @@ -2731,8 +2748,8 @@ namespace BizHawk.Client.EmuHawk var menuItem = new ToolStripMenuItem { - Name = i + "_" + name, - Text = i + ": " + name, + Name = $"{i}_{name}", + Text = $"{i}: {name}", Checked = currSel == i }; @@ -2870,23 +2887,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; } } @@ -3016,13 +3029,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) @@ -3069,12 +3078,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}"); } } @@ -3115,11 +3124,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(); @@ -3254,7 +3273,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.Movie.cs b/BizHawk.Client.EmuHawk/MainForm.Movie.cs index e8838d9d46..b9bc4db335 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Movie.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Movie.cs @@ -104,6 +104,11 @@ namespace BizHawk.Client.EmuHawk GlobalWin.OSD.AddMessage("Warning: Movie hash does not match the ROM"); } + if (Emulator is NullEmulator) + { + return false; + } + return true; } diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index ff80757b3d..6ec93e6d70 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -25,6 +25,7 @@ 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,13 +155,22 @@ namespace BizHawk.Client.EmuHawk .ReadAllBytes(); } }; - - argParser.ParseArguments(args); + try + { + argParser.ParseArguments(args); + } + catch (ArgParserException e) + { + MessageBox.Show(e.Message); + } + Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt")); // TODO GL - a lot of disorganized wiring-up here - CGC.CGCBinPath = Path.Combine(PathManager.GetDllDirectory(), "cgc.exe"); + CGC.CGCBinPath = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows + ? Path.Combine(PathManager.GetDllDirectory(), "cgc.exe") + : "cgc"; // installed separately (via package manager or from https://developer.nvidia.com/cg-toolkit-download), look in $PATH PresentationPanel = new PresentationPanel(); PresentationPanel.GraphicsControl.MainWindow = true; GlobalWin.DisplayManager = new DisplayManager(PresentationPanel); @@ -278,7 +288,7 @@ namespace BizHawk.Client.EmuHawk LoadRom(argParser.cmdRom, new LoadRomArgs { OpenAdvanced = ioa }); if (Global.Game == null) { - MessageBox.Show("Failed to load " + argParser.cmdRom + " specified on commandline"); + MessageBox.Show($"Failed to load {argParser.cmdRom} specified on commandline"); } } else if (Global.Config.RecentRoms.AutoLoad && !Global.Config.RecentRoms.Empty) @@ -286,6 +296,11 @@ namespace BizHawk.Client.EmuHawk LoadRomFromRecent(Global.Config.RecentRoms.MostRecent); } + if (argParser.audiosync.HasValue) + { + Global.Config.VideoWriterAudioSync = argParser.audiosync.Value; + } + if (argParser.cmdMovie != null) { _supressSyncSettingsWarning = true; // We dont' want to be nagged if we are attempting to automate @@ -369,11 +384,11 @@ namespace BizHawk.Client.EmuHawk } else if (argParser.cmdLoadSlot != null) { - LoadQuickSave("QuickSave" + argParser.cmdLoadSlot); + LoadQuickSave($"QuickSave{argParser.cmdLoadSlot}"); } else if (Global.Config.AutoLoadLastSaveSlot) { - LoadQuickSave("QuickSave" + Global.Config.SaveSlot); + LoadQuickSave($"QuickSave{Global.Config.SaveSlot}"); } } @@ -917,34 +932,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); } @@ -966,10 +969,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() @@ -995,7 +998,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); @@ -1063,7 +1066,7 @@ namespace BizHawk.Client.EmuHawk if (!_inFullscreen) { SuspendLayout(); -#if WINDOWS + // Work around an AMD driver bug in >= vista: // It seems windows will activate opengl fullscreen mode when a GL control is occupying the exact space of a screen (0,0 and dimensions=screensize) // AMD cards manifest a problem under these circumstances, flickering other monitors. @@ -1071,7 +1074,9 @@ namespace BizHawk.Client.EmuHawk // (this could be determined with more work; other side affects of the fullscreen mode include: corrupted taskbar, no modal boxes on top of GL control, no screenshots) // At any rate, we can solve this by adding a 1px black border around the GL control // Please note: It is important to do this before resizing things, otherwise momentarily a GL control without WS_BORDER will be at the magic dimensions and cause the flakeout - if (Global.Config.DispFullscreenHacks && Global.Config.DispMethod == Config.EDispMethod.OpenGL) + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows + && Global.Config.DispFullscreenHacks + && Global.Config.DispMethod == Config.EDispMethod.OpenGL) { //ATTENTION: this causes the statusbar to not work well, since the backcolor is now set to black instead of SystemColors.Control. //It seems that some statusbar elements composite with the backcolor. @@ -1082,7 +1087,6 @@ namespace BizHawk.Client.EmuHawk // FUTURE WORK: // re-add this padding back into the display manager (so the image will get cut off a little but, but a few more resolutions will fully fit into the screen) } -#endif _windowedLocation = Location; @@ -1099,13 +1103,15 @@ namespace BizHawk.Client.EmuHawk WindowState = FormWindowState.Normal; -#if WINDOWS - // do this even if DispFullscreenHacks arent enabled, to restore it in case it changed underneath us or something - Padding = new Padding(0); - // it's important that we set the form color back to this, because the statusbar icons blend onto the mainform, not onto the statusbar-- - // so we need the statusbar and mainform backdrop color to match - BackColor = SystemColors.Control; -#endif + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) + { + // do this even if DispFullscreenHacks arent enabled, to restore it in case it changed underneath us or something + Padding = new Padding(0); + + // it's important that we set the form color back to this, because the statusbar icons blend onto the mainform, not onto the statusbar-- + // so we need the statusbar and mainform backdrop color to match + BackColor = SystemColors.Control; + } _inFullscreen = false; @@ -1175,7 +1181,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() @@ -1252,7 +1258,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) @@ -1288,7 +1294,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) { @@ -1310,7 +1316,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")}"); } } @@ -1399,6 +1405,7 @@ namespace BizHawk.Client.EmuHawk private int _lastOpenRomFilter; private ArgParser argParser = new ArgParser(); + // Resources private Bitmap _statusBarDiskLightOnImage; private Bitmap _statusBarDiskLightOffImage; @@ -1447,7 +1454,7 @@ namespace BizHawk.Client.EmuHawk if (!string.IsNullOrEmpty(VersionInfo.CustomBuildString)) { - str += VersionInfo.CustomBuildString + " "; + str += $"{VersionInfo.CustomBuildString} "; } str += Emulator.IsNull() ? "BizHawk" : Global.SystemInfo.DisplayName; @@ -1459,11 +1466,11 @@ 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)}"; } } @@ -1634,9 +1641,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) { @@ -1646,7 +1653,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; } } @@ -1722,6 +1729,7 @@ namespace BizHawk.Client.EmuHawk SaturnSubMenu.Visible = false; DGBSubMenu.Visible = false; DGBHawkSubMenu.Visible = false; + GGLSubMenu.Visible = false; GenesisSubMenu.Visible = false; wonderSwanToolStripMenuItem.Visible = false; AppleSubMenu.Visible = false; @@ -1845,6 +1853,9 @@ namespace BizHawk.Client.EmuHawk case "AmstradCPC": amstradCPCToolStripMenuItem.Visible = true; break; + case "GGL": + GGLSubMenu.Visible = true; + break; } } @@ -1904,13 +1915,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) { @@ -1962,14 +1973,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() @@ -2073,7 +2084,22 @@ namespace BizHawk.Client.EmuHawk // sends an alt+mnemonic combination private void SendAltKeyChar(char c) { - typeof(ToolStrip).InvokeMember("ProcessMnemonicInternal", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, null, MainformMenu, new object[] { c }); + switch (OSTailoredCode.CurrentOS) + { + case OSTailoredCode.DistinctOS.Linux: + case OSTailoredCode.DistinctOS.macOS: + // no mnemonics for you + break; + case OSTailoredCode.DistinctOS.Windows: + //HACK + var _ = typeof(ToolStrip).InvokeMember( + "ProcessMnemonicInternal", + System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, + null, + MainformMenu, + new object[] { c }); + break; + } } public static string FormatFilter(params string[] args) @@ -2323,7 +2349,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() @@ -2334,7 +2360,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() @@ -2433,7 +2459,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(); } @@ -2460,7 +2486,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(); } @@ -2619,7 +2645,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."); } } @@ -2659,9 +2685,7 @@ namespace BizHawk.Client.EmuHawk ? _linkCableOn : _linkCableOff; - LinkConnectStatusBarButton.ToolTipText = Emulator.AsLinkable().LinkConnected - ? "Link connection is currently enabled" - : "Link connection is currently disabled"; + LinkConnectStatusBarButton.ToolTipText = $"Link connection is currently {(Emulator.AsLinkable().LinkConnected ? "enabled" : "disabled")}"; } else { @@ -2696,21 +2720,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) @@ -3271,7 +3292,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 @@ -3460,7 +3481,7 @@ namespace BizHawk.Client.EmuHawk } catch (Exception e) { - MessageBox.Show("Video dumping died:\n\n" + e); + MessageBox.Show($"Video dumping died:\n\n{e}"); AbortAv(); } @@ -3526,7 +3547,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); @@ -3654,7 +3675,9 @@ namespace BizHawk.Client.EmuHawk if (ioa is OpenAdvanced_OpenRom) { var ioa_openrom = (OpenAdvanced_OpenRom)ioa; - path = ioa_openrom.Path; + // path already has the right value, while ioa.Path is null (interestingly, these are swapped below) + // I doubt null is meant to be assigned here, and it just prevents gameload + //path = ioa_openrom.Path; } CoreFileProvider.SyncCoreCommInputSignals(nextComm); @@ -3677,7 +3700,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); @@ -3709,8 +3732,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(); } } @@ -3824,7 +3847,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) @@ -3966,7 +3989,7 @@ namespace BizHawk.Client.EmuHawk GlobalWin.Tools.Restart(); ApiManager.Restart(Emulator.ServiceProvider); RewireSound(); - Text = "BizHawk" + (VersionInfo.DeveloperBuild ? " (interim) " : ""); + Text = $"BizHawk{(VersionInfo.DeveloperBuild ? " (interim) " : "")}"; HandlePlatformMenus(); _stateSlots.Clear(); UpdateDumpIcon(); @@ -3994,7 +4017,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() @@ -4074,7 +4097,7 @@ namespace BizHawk.Client.EmuHawk if (!supressOSD) { - GlobalWin.OSD.AddMessage("Loaded state: " + userFriendlyStateName); + GlobalWin.OSD.AddMessage($"Loaded state: {userFriendlyStateName}"); } } else @@ -4105,10 +4128,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; } @@ -4135,11 +4158,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) @@ -4169,7 +4192,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) @@ -4180,7 +4203,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); @@ -4225,7 +4248,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/PresentationPanel.cs b/BizHawk.Client.EmuHawk/PresentationPanel.cs index a20b656ac8..b647f2ce01 100644 --- a/BizHawk.Client.EmuHawk/PresentationPanel.cs +++ b/BizHawk.Client.EmuHawk/PresentationPanel.cs @@ -6,9 +6,6 @@ using sysdrawing2d=System.Drawing.Drawing2D; using System.IO; using System.Threading; using System.Windows.Forms; -#if WINDOWS -using SlimDX; -#endif using BizHawk.Client.Common; using BizHawk.Bizware.BizwareGL; diff --git a/BizHawk.Client.EmuHawk/Program.cs b/BizHawk.Client.EmuHawk/Program.cs index 0ed765e047..4458f2ac75 100644 --- a/BizHawk.Client.EmuHawk/Program.cs +++ b/BizHawk.Client.EmuHawk/Program.cs @@ -1,21 +1,19 @@ using System; -using System.Linq; using System.Diagnostics; using System.IO; using System.Collections.Generic; using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; -#if WINDOWS + using Microsoft.VisualBasic.ApplicationServices; -#endif using BizHawk.Common; using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { - static class Program + internal static class Program { static Program() { @@ -23,56 +21,52 @@ namespace BizHawk.Client.EmuHawk Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - 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 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; - fail |= vc2010 == IntPtr.Zero; - fail |= vc2012 == IntPtr.Zero; - fail |= vc2010p == IntPtr.Zero; - if (fail || warn) + if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows) { - var sw = new System.IO.StringWriter(); - sw.WriteLine("[ OK ] .Net 4.6.1 (You couldn't even get here without it)"); - sw.WriteLine("[{0}] Direct3d 9", d3dx9 == IntPtr.Zero ? "FAIL" : " OK "); - sw.WriteLine("[{0}] Visual C++ 2010 SP1 Runtime", (vc2010 == IntPtr.Zero || vc2010p == IntPtr.Zero) ? "FAIL" : " OK "); - sw.WriteLine("[{0}] Visual C++ 2012 Runtime", (vc2012 == IntPtr.Zero) ? "FAIL" : " OK "); - sw.WriteLine("[{0}] Visual C++ 2015 Runtime", (vc2015 == IntPtr.Zero) ? "FAIL" : " OK "); - var str = sw.ToString(); - var box = new BizHawk.Client.EmuHawk.CustomControls.PrereqsAlert(!fail); - box.textBox1.Text = str; - box.ShowDialog(); - if (!fail) { } - else - System.Diagnostics.Process.GetCurrentProcess().Kill(); - } + var libLoader = EXE_PROJECT.OSTailoredCode.LinkedLibManager; - libLoader.FreePlatformSpecific(d3dx9); - libLoader.FreePlatformSpecific(vc2015); - libLoader.FreePlatformSpecific(vc2012); - libLoader.FreePlatformSpecific(vc2010); - libLoader.FreePlatformSpecific(vc2010p); + //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 fail = vc2015 == IntPtr.Zero || vc2010 == IntPtr.Zero || vc2012 == IntPtr.Zero || vc2010p == IntPtr.Zero; + var warn = d3dx9 == IntPtr.Zero; + if (fail || warn) + { + var alertLines = new[] + { + "[ OK ] .NET CLR (You wouldn't even get here without it)", + $"[{(d3dx9 == IntPtr.Zero ? "WARN" : " OK ")}] Direct3d 9", + $"[{(vc2010 == IntPtr.Zero || vc2010p == IntPtr.Zero ? "FAIL" : " OK ")}] Visual C++ 2010 SP1 Runtime", + $"[{(vc2012 == IntPtr.Zero ? "FAIL" : " OK ")}] Visual C++ 2012 Runtime", + $"[{(vc2015 == IntPtr.Zero ? "FAIL" : " OK ")}] Visual C++ 2015 Runtime" + }; + var box = new BizHawk.Client.EmuHawk.CustomControls.PrereqsAlert(!fail) + { + textBox1 = { Text = string.Concat("\n", alertLines) } + }; + box.ShowDialog(); + if (fail) System.Diagnostics.Process.GetCurrentProcess().Kill(); + } + + libLoader.FreePlatformSpecific(d3dx9); + libLoader.FreePlatformSpecific(vc2015); + libLoader.FreePlatformSpecific(vc2012); + libLoader.FreePlatformSpecific(vc2010); + libLoader.FreePlatformSpecific(vc2010p); - 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"); + var dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); SetDllDirectory(dllDir); //in case assembly resolution fails, such as if we moved them into the dll subdiretory, this event handler can reroute to them - AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); + AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; //but before we even try doing that, whack the MOTW from everything in that directory (thats a dll) //otherwise, some people will have crashes at boot-up due to .net security disliking MOTW. @@ -84,129 +78,20 @@ namespace BizHawk.Client.EmuHawk } [STAThread] - static int Main(string[] args) + private static int Main(string[] args) { - return SubMain(args); - } - - private interface PlatformSpecificMainLoopCrashHandler - { - void TryCatchFinally(string[] args); - } - private class Win32MainLoopCrashHandler : PlatformSpecificMainLoopCrashHandler - { - public void TryCatchFinally(string[] args) + var exitCode = SubMain(args); + if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Linux) { - try - { - if (Global.Config.SingleInstanceMode) - { - try - { - new SingleInstanceController(args).Run(args); - } - catch (ObjectDisposedException) - { - // Eat it, MainForm disposed itself and Run attempts to dispose of itself. Eventually we would want to figure out a way to prevent that, but in the meantime it is harmless, so just eat the error - } - } - else - { - using (var mf = new MainForm(args)) - { - var title = mf.Text; - mf.Show(); - mf.Text = title; - try - { - GlobalWin.ExitCode = mf.ProgramRunLoop(); - } - catch (Exception e) when (!Debugger.IsAttached && !VersionInfo.DeveloperBuild && Global.MovieSession.Movie.IsActive) - { - 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, - MessageBoxButtons.YesNo, - MessageBoxIcon.Exclamation - ); - if (result == DialogResult.Yes) - { - Global.MovieSession.Movie.Save(); - } - } - } - } - } - catch (Exception e) when (!Debugger.IsAttached) - { - new ExceptionBox(e).ShowDialog(); - } - finally - { - if (GlobalWin.Sound != null) - { - GlobalWin.Sound.Dispose(); - GlobalWin.Sound = null; - } - GlobalWin.GL.Dispose(); - Input.Cleanup(); - } + Console.WriteLine("BizHawk has completed its shutdown routines, killing process..."); + Process.GetCurrentProcess().Kill(); } + return exitCode; } - private class UnixMonoMainLoopCrashHandler : PlatformSpecificMainLoopCrashHandler - { - // Identical to the implementation in Win32MainLoopCrashHandler sans the single-instance check. - public void TryCatchFinally(string[] args) - { - try - { - using (var mf = new MainForm(args)) - { - var title = mf.Text; - mf.Show(); - mf.Text = title; - try - { - GlobalWin.ExitCode = mf.ProgramRunLoop(); - } - catch (Exception e) when (!Debugger.IsAttached && !VersionInfo.DeveloperBuild && Global.MovieSession.Movie.IsActive) - { - 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, - MessageBoxButtons.YesNo, - MessageBoxIcon.Exclamation - ); - if (result == DialogResult.Yes) - { - Global.MovieSession.Movie.Save(); - } - } - } - } - catch (Exception e) when (!Debugger.IsAttached) - { - new ExceptionBox(e).ShowDialog(); - } - finally - { - if (GlobalWin.Sound != null) - { - GlobalWin.Sound.Dispose(); - GlobalWin.Sound = null; - } - GlobalWin.GL.Dispose(); - Input.Cleanup(); - } - } - } - private static PlatformSpecificMainLoopCrashHandler mainLoopCrashHandler = EXE_PROJECT.PlatformLinkedLibSingleton.RunningOnUnix - ? (PlatformSpecificMainLoopCrashHandler) new UnixMonoMainLoopCrashHandler() - : (PlatformSpecificMainLoopCrashHandler) new Win32MainLoopCrashHandler(); //NoInlining should keep this code from getting jammed into Main() which would create dependencies on types which havent been setup by the resolver yet... or something like that [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] - static int SubMain(string[] args) + private static int SubMain(string[] args) { // this check has to be done VERY early. i stepped through a debug build with wrong .dll versions purposely used, // and there was a TypeLoadException before the first line of SubMain was reached (some static ColorType init?) @@ -228,9 +113,8 @@ namespace BizHawk.Client.EmuHawk HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler(); - ArgParser argParser = new ArgParser(); - argParser.ParseArguments(args); - if (argParser.cmdConfigFile != null) PathManager.SetDefaultIniPath(argParser.cmdConfigFile); + string cmdConfigFile = ArgParser.GetCmdConfigFile(args); + if (cmdConfigFile != null) PathManager.SetDefaultIniPath(cmdConfigFile); try { @@ -248,13 +132,9 @@ namespace BizHawk.Client.EmuHawk BizHawk.Client.Common.StringLogUtil.DefaultToAWE = Global.Config.MoviesInAWE; // super hacky! this needs to be done first. still not worth the trouble to make this system fully proper - for (int i = 0; i < args.Length; i++) + if (Array.Exists(args, arg => arg.StartsWith("--gdi", StringComparison.InvariantCultureIgnoreCase))) { - var arg = args[i].ToLower(); - if (arg.StartsWith("--gdi")) - { - Global.Config.DispMethod = Config.EDispMethod.GdiPlus; - } + Global.Config.DispMethod = Config.EDispMethod.GdiPlus; } // create IGL context. we do this whether or not the user has selected OpenGL, so that we can run opengl-based emulator cores @@ -265,8 +145,10 @@ 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 (EXE_PROJECT.PlatformLinkedLibSingleton.RunningOnUnix) Global.Config.DispMethod = Config.EDispMethod.GdiPlus; - REDO_DISPMETHOD: + if (EXE_PROJECT.OSTailoredCode.CurrentOS != EXE_PROJECT.OSTailoredCode.DistinctOS.Windows) + Global.Config.DispMethod = Config.EDispMethod.GdiPlus; + +REDO_DISPMETHOD: if (Global.Config.DispMethod == Config.EDispMethod.GdiPlus) GlobalWin.GL = new Bizware.BizwareGL.Drivers.GdiPlus.IGL_GdiPlus(); else if (Global.Config.DispMethod == Config.EDispMethod.SlimDX9) @@ -277,8 +159,7 @@ namespace BizHawk.Client.EmuHawk } catch(Exception ex) { - var e2 = new Exception("Initialization of Direct3d 9 Display Method failed; falling back to GDI+", ex); - new ExceptionBox(e2).ShowDialog(); + new ExceptionBox(new Exception("Initialization of Direct3d 9 Display Method failed; falling back to GDI+", ex)).ShowDialog(); // fallback Global.Config.DispMethod = Config.EDispMethod.GdiPlus; @@ -290,8 +171,7 @@ namespace BizHawk.Client.EmuHawk GlobalWin.GL = GlobalWin.IGL_GL; // check the opengl version and dont even try to boot this crap up if its too old - int version = GlobalWin.IGL_GL.Version; - if (version < 200) + if (GlobalWin.IGL_GL.Version < 200) { // fallback Global.Config.DispMethod = Config.EDispMethod.GdiPlus; @@ -306,26 +186,75 @@ namespace BizHawk.Client.EmuHawk } catch(Exception ex) { - var e2 = new Exception("Initialization of Display Method failed; falling back to GDI+", ex); - new ExceptionBox(e2).ShowDialog(); + new ExceptionBox(new Exception("Initialization of Display Method failed; falling back to GDI+", ex)).ShowDialog(); + //fallback Global.Config.DispMethod = Config.EDispMethod.GdiPlus; goto REDO_DISPMETHOD; } - if (!EXE_PROJECT.PlatformLinkedLibSingleton.RunningOnUnix) + if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows) { //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". //It isn't clear whether we need the earlier SetDllDirectory(), but I think we do. //note: this is pasted instead of being put in a static method due to this initialization code being sensitive to things like that, and not wanting to cause it to break //pasting should be safe (not affecting the jit order of things) - string dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); + var dllDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); SetDllDirectory(dllDir); } - // Using a simple conditional to skip the single-instancing step caused crashes on GNU+Linux, even though the single-instancing step wasn't being executed. Something about the way instantiation works in C# means this workaround is possible. - mainLoopCrashHandler.TryCatchFinally(args); + try + { + if (Global.Config.SingleInstanceMode) + { + try + { + new SingleInstanceController(args).Run(); + } + catch (ObjectDisposedException) + { + // Eat it, MainForm disposed itself and Run attempts to dispose of itself. Eventually we would want to figure out a way to prevent that, but in the meantime it is harmless, so just eat the error + } + } + else + { + using (var mf = new MainForm(args)) + { + var title = mf.Text; + mf.Show(); + mf.Text = title; + try + { + GlobalWin.ExitCode = mf.ProgramRunLoop(); + } + catch (Exception e) when (Global.MovieSession.Movie.IsActive && !(Debugger.IsAttached || VersionInfo.DeveloperBuild)) + { + 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}", + MessageBoxButtons.YesNo, + MessageBoxIcon.Exclamation + ); + if (result == DialogResult.Yes) + { + Global.MovieSession.Movie.Save(); + } + } + } + } + } + catch (Exception e) when (!Debugger.IsAttached) + { + new ExceptionBox(e).ShowDialog(); + } + finally + { + GlobalWin.Sound?.Dispose(); + GlobalWin.Sound = null; + GlobalWin.GL.Dispose(); + Input.Cleanup(); + } //cleanup: //cleanup IGL stuff so we can get better refcounts when exiting process, for debugging @@ -341,19 +270,19 @@ namespace BizHawk.Client.EmuHawk } //SubMain //declared here instead of a more usual place to avoid dependencies on the more usual place -#if WINDOWS + [DllImport("kernel32.dll", SetLastError = true)] - static extern uint SetDllDirectory(string lpPathName); + private static extern uint SetDllDirectory(string lpPathName); [DllImport("kernel32.dll", EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] - static extern bool DeleteFileW([MarshalAs(UnmanagedType.LPWStr)]string lpFileName); + private static extern bool DeleteFileW([MarshalAs(UnmanagedType.LPWStr)]string lpFileName); - public static void RemoveMOTW(string path) + private static void RemoveMOTW(string path) { - DeleteFileW(path + ":Zone.Identifier"); + DeleteFileW($"{path}:Zone.Identifier"); } - static void WhackAllMOTW(string dllDir) + private static void WhackAllMOTW(string dllDir) { var todo = new Queue(new[] { new DirectoryInfo(dllDir) }); while (todo.Count > 0) @@ -365,14 +294,11 @@ namespace BizHawk.Client.EmuHawk foreach (var fi in di.GetFiles("*.exe")) RemoveMOTW(fi.FullName); } - } -#endif - - static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) + private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { - string requested = args.Name; + var requested = args.Name; //mutate filename depending on selection of lua core. here's how it works //1. we build NLua to the output/dll/lua directory. that brings KopiLua with it @@ -380,52 +306,43 @@ namespace BizHawk.Client.EmuHawk //3. When NLua assembly attempts to load, it can't find it //I. if LuaInterface is selected by the user, we switch to requesting that. // (those DLLs are built into the output/DLL directory) - //II. if NLua is selected by the user, we skip over this part; + //II. if NLua is selected by the user, we skip over this part; // later, we look for NLua or KopiLua assembly names and redirect them to files located in the output/DLL/nlua directory if (new AssemblyName(requested).Name == "NLua") { //this method referencing Global.Config makes assemblies get loaded, which isnt smart from the assembly resolver. //so.. we're going to resort to something really bad. //avert your eyes. - bool UseNLua = true; - string configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini"); - if (File.Exists(configPath)) + var configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini"); + if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows // LuaInterface is not currently working on Mono + && File.Exists(configPath) + && (Array.Find(File.ReadAllLines(configPath), line => line.Contains(" \"UseNLua\": ")) ?? string.Empty) + .Contains("false")) { - var cfg = File.ReadAllLines(configPath); - var usenlua_key = cfg.FirstOrDefault(line=>line.Contains(" \"UseNLua\": ")); - if (usenlua_key != null) - if (usenlua_key.Contains("false")) - UseNLua = false; + requested = "LuaInterface"; } - - if (UseNLua) { } - else requested = "LuaInterface"; } lock (AppDomain.CurrentDomain) { - var asms = AppDomain.CurrentDomain.GetAssemblies(); - foreach (var asm in asms) - if (asm.FullName == requested) - return asm; + var firstAsm = Array.Find(AppDomain.CurrentDomain.GetAssemblies(), asm => asm.FullName == requested); + if (firstAsm != null) return firstAsm; //load missing assemblies by trying to find them in the dll directory - string dllname = new AssemblyName(requested).Name + ".dll"; - string directory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); - string simpleName = new AssemblyName(requested).Name; + var dllname = $"{new AssemblyName(requested).Name}.dll"; + var directory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dll"); + var simpleName = new AssemblyName(requested).Name; if (simpleName == "NLua" || simpleName == "KopiLua") directory = Path.Combine(directory, "nlua"); - string fname = Path.Combine(directory, dllname); - if (!File.Exists(fname)) return null; - - //it is important that we use LoadFile here and not load from a byte array; otherwise mixed (managed/unamanged) assemblies can't load - return Assembly.LoadFile(fname); + var fname = Path.Combine(directory, dllname); + //it is important that we use LoadFile here and not load from a byte array; otherwise mixed (managed/unmanaged) assemblies can't load + return File.Exists(fname) ? Assembly.LoadFile(fname) : null; } } -#if WINDOWS - public class SingleInstanceController : WindowsFormsApplicationBase + private class SingleInstanceController : WindowsFormsApplicationBase { - readonly string[] cmdArgs; + private readonly string[] cmdArgs; + public SingleInstanceController(string[] args) { cmdArgs = args; @@ -433,10 +350,12 @@ namespace BizHawk.Client.EmuHawk StartupNextInstance += this_StartupNextInstance; } - void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e) + public void Run() => Run(cmdArgs); + + private void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e) { if (e.CommandLine.Count >= 1) - (MainForm as MainForm).LoadRom(e.CommandLine[0], new MainForm.LoadRomArgs() { OpenAdvanced = new OpenAdvanced_OpenRom() }); + ((MainForm)MainForm).LoadRom(e.CommandLine[0], new MainForm.LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom() }); } protected override void OnCreateMainForm() @@ -445,11 +364,8 @@ namespace BizHawk.Client.EmuHawk var title = MainForm.Text; MainForm.Show(); MainForm.Text = title; - GlobalWin.ExitCode = (MainForm as MainForm).ProgramRunLoop(); + GlobalWin.ExitCode = ((MainForm)MainForm).ProgramRunLoop(); } } - - -#endif } } diff --git a/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs b/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs index 8cb04e3e15..d9e97b6eff 100644 --- a/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs +++ b/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -690,16 +690,6 @@ namespace BizHawk.Client.EmuHawk.Properties { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap HawkInLove { - get { - object obj = ResourceManager.GetObject("HawkInLove", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/BizHawk.Client.EmuHawk/Properties/Resources.resx b/BizHawk.Client.EmuHawk/Properties/Resources.resx index 301536707a..1876bfb3b7 100644 --- a/BizHawk.Client.EmuHawk/Properties/Resources.resx +++ b/BizHawk.Client.EmuHawk/Properties/Resources.resx @@ -1455,9 +1455,6 @@ ..\images\tastudio\ts_h_piano_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\images\HawkInLove.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\images\tastudio\ts_h_piano_00_blue.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/BizHawk.Client.EmuHawk/ScreenSaver.cs b/BizHawk.Client.EmuHawk/ScreenSaver.cs index d362b4b2c2..5b40fe8af3 100644 --- a/BizHawk.Client.EmuHawk/ScreenSaver.cs +++ b/BizHawk.Client.EmuHawk/ScreenSaver.cs @@ -1,80 +1,66 @@ -using System; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; -using BizHawk.Client.Common; using BizHawk.Common; namespace BizHawk.Client.EmuHawk { - // Derived from http://www.codeproject.com/KB/cs/ScreenSaverControl.aspx + /// Derived from http://www.codeproject.com/KB/cs/ScreenSaverControl.aspx public static class ScreenSaver { - private interface PlatformSpecificScreenBlankInterface + private interface IScreenBlankTimer { - Int32 Get(); - void Set(Int32 v); + /// + /// The screen saver timeout setting, in seconds + /// + int Duration { get; set; } } - private class WinScreenBlankInterface : PlatformSpecificScreenBlankInterface + + private class Win32ScreenBlankTimer : IScreenBlankTimer { [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern bool SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int flags); - public Int32 Get() - { - Int32 value = 0; - SystemParametersInfo(SPI_GETSCREENSAVERTIMEOUT, 0, ref value, 0); - return value; - } - public void Set(Int32 v) - { - int nullVar = 0; - SystemParametersInfo(SPI_SETSCREENSAVERTIMEOUT, v, ref nullVar, SPIF_SENDWININICHANGE); - } - } - private class MiscUnixScreenBlankInterface : PlatformSpecificScreenBlankInterface - { - public Int32 Get() - { - return 0; //TODO implement - } - public void Set(Int32 v) - { - //TODO implement - } - } - private static PlatformSpecificScreenBlankInterface screenBlankInterface = PlatformLinkedLibSingleton.RunningOnUnix - ? (PlatformSpecificScreenBlankInterface) new MiscUnixScreenBlankInterface() - : (PlatformSpecificScreenBlankInterface) new WinScreenBlankInterface(); - private const int SPI_GETSCREENSAVERTIMEOUT = 14; - private const int SPI_SETSCREENSAVERTIMEOUT = 15; - private const int SPIF_SENDWININICHANGE = 2; + private const int SPI_GETSCREENSAVERTIMEOUT = 14; + private const int SPI_SETSCREENSAVERTIMEOUT = 15; + private const int SPIF_SENDWININICHANGE = 2; + + public int Duration + { + get + { + var value = 0; + SystemParametersInfo(SPI_GETSCREENSAVERTIMEOUT, 0, ref value, 0); + return value; + } + set + { + var nullVar = 0; + SystemParametersInfo(SPI_SETSCREENSAVERTIMEOUT, value, ref nullVar, SPIF_SENDWININICHANGE); + } + } + } + + private class UnixScreenBlankTimer : IScreenBlankTimer + { + public int Duration { get; set; } = 0; //TODO implementation + } + + private static readonly IScreenBlankTimer _screenBlankTimer = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows + ? (IScreenBlankTimer) new Win32ScreenBlankTimer() + : new UnixScreenBlankTimer(); + + private static int ctr; public static void ResetTimerImmediate() { - SetScreenSaverTimeout(GetScreenSaverTimeout()); + _screenBlankTimer.Duration = _screenBlankTimer.Duration; } - private static int ctr; public static void ResetTimerPeriodically() { - ctr++; - if (ctr == 120) - { - SetScreenSaverTimeout(GetScreenSaverTimeout()); - ctr = 0; - } - } - - // Returns the screen saver timeout setting, in seconds - private static Int32 GetScreenSaverTimeout() - { - return screenBlankInterface.Get(); - } - - // Pass in the number of seconds to set the screen saver timeout value. - private static void SetScreenSaverTimeout(Int32 Value) - { - screenBlankInterface.Set(Value); + if (++ctr < 120) return; + ctr = 0; + ResetTimerImmediate(); } } -} +} \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs b/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs index df362aa7aa..21ca8bd90f 100644 --- a/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs +++ b/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs @@ -1,5 +1,4 @@ -#if WINDOWS -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -164,4 +163,3 @@ namespace BizHawk.Client.EmuHawk } } } -#endif diff --git a/BizHawk.Client.EmuHawk/Sound/Output/XAudio2SoundOutput.cs b/BizHawk.Client.EmuHawk/Sound/Output/XAudio2SoundOutput.cs index 913fb91c94..e5bf4f8dc0 100644 --- a/BizHawk.Client.EmuHawk/Sound/Output/XAudio2SoundOutput.cs +++ b/BizHawk.Client.EmuHawk/Sound/Output/XAudio2SoundOutput.cs @@ -1,5 +1,4 @@ -#if WINDOWS -using System; +using System; using System.Collections.Generic; using System.Linq; @@ -185,4 +184,3 @@ namespace BizHawk.Client.EmuHawk } } } -#endif diff --git a/BizHawk.Client.EmuHawk/Sound/Sound.cs b/BizHawk.Client.EmuHawk/Sound/Sound.cs index 1edaaae699..85aaa2502d 100644 --- a/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -25,15 +25,17 @@ namespace BizHawk.Client.EmuHawk public Sound(IntPtr mainWindowHandle) { - if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL) - _outputDevice = new OpenALSoundOutput(this); - if (!PlatformLinkedLibSingleton.RunningOnUnix) + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) { + if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL) + _outputDevice = new OpenALSoundOutput(this); if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound) _outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle); if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2) _outputDevice = new XAudio2SoundOutput(this); } + else _outputDevice = new OpenALSoundOutput(this); // at the moment unix/mono can only support OpenAL (so ignore whatever is set in the config) + if (_outputDevice == null) _outputDevice = new DummySoundOutput(this); } 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 5eb8fcba22..d25af833ca 100644 --- a/BizHawk.Client.EmuHawk/Throttle.cs +++ b/BizHawk.Client.EmuHawk/Throttle.cs @@ -35,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; @@ -153,14 +153,16 @@ namespace BizHawk.Client.EmuHawk } private class UnixMonoSysTimer : PlatformSpecificSysTimer { - [DllImport("winmm.dll.so", EntryPoint = "timeBeginPeriod")] - private static extern uint timeBeginPeriod(uint uMilliseconds); public uint TimeBeginPeriod(uint ms) { - return timeBeginPeriod(ms); + // we are not going to bother trying to set a minimum resolution for periodic timers + // (on linux I don't think you can set this in user code) + return ms; } } - static PlatformSpecificSysTimer sysTimer = PlatformLinkedLibSingleton.RunningOnUnix ? (PlatformSpecificSysTimer) new UnixMonoSysTimer() : (PlatformSpecificSysTimer) new WinSysTimer(); + static PlatformSpecificSysTimer sysTimer = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows + ? (PlatformSpecificSysTimer) new WinSysTimer() + : new UnixMonoSysTimer(); static uint TimeBeginPeriod(uint ms) { return sysTimer.TimeBeginPeriod(ms); @@ -198,12 +200,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(); } @@ -362,18 +364,23 @@ namespace BizHawk.Client.EmuHawk int sleepTime = (int)((timePerFrame - elapsedTime) * 1000 / afsfreq); if (sleepTime >= 2 || paused) { -#if WINDOWS - // Assuming a timer period of 1 ms (i.e. TimeBeginPeriod(1)): The actual sleep time - // on Windows XP is generally within a half millisecond either way of the requested - // time. The actual sleep time on Windows 8 is generally between the requested time - // and up to a millisecond over. So we'll subtract 1 ms from the time to avoid - // sleeping longer than desired. - sleepTime -= 1; -#else - // The actual sleep time on OS X with Mono is generally between the request time - // and up to 25% over. So we'll scale the sleep time back to account for that. - sleepTime = sleepTime * 4 / 5; -#endif + switch (OSTailoredCode.CurrentOS) + { + case OSTailoredCode.DistinctOS.Linux: //TODO repro + case OSTailoredCode.DistinctOS.macOS: + // The actual sleep time on OS X with Mono is generally between the request time + // and up to 25% over. So we'll scale the sleep time back to account for that. + sleepTime = sleepTime * 4 / 5; + break; + case OSTailoredCode.DistinctOS.Windows: + // Assuming a timer period of 1 ms (i.e. TimeBeginPeriod(1)): The actual sleep time + // on Windows XP is generally within a half millisecond either way of the requested + // time. The actual sleep time on Windows 8 is generally between the requested time + // and up to a millisecond over. So we'll subtract 1 ms from the time to avoid + // sleeping longer than desired. + sleepTime -= 1; + break; + } Thread.Sleep(Math.Max(sleepTime, 1)); } 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/app.config b/BizHawk.Client.EmuHawk/app.config index d405098352..9b69721c46 100644 --- a/BizHawk.Client.EmuHawk/app.config +++ b/BizHawk.Client.EmuHawk/app.config @@ -1,3 +1,9 @@ - + + + + + + + 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 303f054169..25b246d55f 100644 --- a/BizHawk.Client.EmuHawk/config/ControllerConfig.cs +++ b/BizHawk.Client.EmuHawk/config/ControllerConfig.cs @@ -126,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; } @@ -162,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++; @@ -176,7 +176,7 @@ namespace BizHawk.Client.EmuHawk tt.TabPages[pageidx].Controls.Add(createpanel(settings, cat.Value, tt.Size)); // zxhawk hack - it uses multiple categoryLabels - if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC") + if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC" || Global.Emulator.SystemId == "ChannelF") pageidx++; } @@ -184,7 +184,7 @@ namespace BizHawk.Client.EmuHawk if (buckets[0].Count > 0) { // ZXHawk needs to skip this bit - if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC") + if (Global.Emulator.SystemId == "ZXSpectrum" || Global.Emulator.SystemId == "AmstradCPC" || Global.Emulator.SystemId == "ChannelF") return; string tabname = (Global.Emulator.SystemId == "C64") ? "Keyboard" : "Console"; // hack @@ -275,6 +275,11 @@ namespace BizHawk.Client.EmuHawk tableLayoutPanel1.ColumnStyles[1].Width = Properties.Resources.ZXSpectrumKeyboards.Width; } + if (controlName == "ChannelF Controller") + { + + } + if (controlName == "AmstradCPC Controller") { /* @@ -362,7 +367,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.cs b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs index a2cd975168..cb4f4f7515 100644 --- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs +++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs @@ -3,6 +3,7 @@ using System.IO; using System.Windows.Forms; using BizHawk.Emulation.Common; using BizHawk.Client.Common; +using BizHawk.Common; namespace BizHawk.Client.EmuHawk { @@ -91,6 +92,16 @@ namespace BizHawk.Client.EmuHawk txtCropBottom.Text = Global.Config.DispCropBottom.ToString(); RefreshAspectRatioOptions(); + + if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows) + { + // Disable SlimDX on Unix + rbD3D9.Enabled = false; + rbD3D9.AutoCheck = false; + cbAlternateVsync.Enabled = false; + label13.Enabled = false; + label8.Enabled = false; + } } private void btnOk_Click(object sender, EventArgs e) @@ -270,7 +281,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/FirmwaresConfig.cs b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs index d7a062cc1e..69a302c097 100644 --- a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs +++ b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs @@ -53,7 +53,8 @@ namespace BizHawk.Client.EmuHawk { "PCFX", "PC-FX" }, { "32X", "32X" }, { "ZXSpectrum", "ZX Spectrum" }, - { "AmstradCPC", "Amstrad CPC" } + { "AmstradCPC", "Amstrad CPC" }, + { "ChannelF", "Channel F" } }; public string TargetSystem = null; @@ -109,7 +110,7 @@ namespace BizHawk.Client.EmuHawk } else { - tbbCloseReload.ToolTipText = "Close Firmware Manager and reload " + reloadRomPath; + tbbCloseReload.ToolTipText = $"Close Firmware Manager and reload {reloadRomPath}"; } } @@ -313,7 +314,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 = ""; } } @@ -357,6 +358,8 @@ namespace BizHawk.Client.EmuHawk private void tbbOpenFolder_Click(object sender, EventArgs e) { var frmWares = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null); + if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows && !Directory.Exists(frmWares)) + Directory.CreateDirectory(frmWares); System.Diagnostics.Process.Start(frmWares); } @@ -443,7 +446,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 +459,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 +529,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 +651,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 79167ea11f..7026051674 100644 --- a/BizHawk.Client.EmuHawk/config/InputWidget.cs +++ b/BizHawk.Client.EmuHawk/config/InputWidget.cs @@ -71,7 +71,7 @@ namespace BizHawk.Client.EmuHawk protected override void OnMouseClick(MouseEventArgs e) { - if (!PlatformLinkedLibSingleton.RunningOnUnix) HideCaret(Handle); + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) HideCaret(Handle); base.OnMouseClick(e); } @@ -264,7 +264,7 @@ namespace BizHawk.Client.EmuHawk protected override void OnGotFocus(EventArgs e) { - if (!PlatformLinkedLibSingleton.RunningOnUnix) HideCaret(Handle); + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) 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 0bcbccdbfd..ae8dc93b28 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs +++ b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs @@ -405,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) @@ -532,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) @@ -604,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; @@ -776,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; @@ -852,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 64b371ddc6..2c3a963428 100644 --- a/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs +++ b/BizHawk.Client.EmuHawk/config/NES/NESGraphicsConfig.cs @@ -113,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; 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/SoundConfig.cs b/BizHawk.Client.EmuHawk/config/SoundConfig.cs index 782ae648aa..97faed7762 100644 --- a/BizHawk.Client.EmuHawk/config/SoundConfig.cs +++ b/BizHawk.Client.EmuHawk/config/SoundConfig.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Common; namespace BizHawk.Client.EmuHawk { @@ -24,10 +25,14 @@ namespace BizHawk.Client.EmuHawk cbEnableNormal.Checked = Global.Config.SoundEnabledNormal; cbEnableRWFF.Checked = Global.Config.SoundEnabledRWFF; cbMuteFrameAdvance.Checked = Global.Config.MuteFrameAdvance; -#if !WINDOWS - rbOutputMethodDirectSound.Enabled = false; - rbOutputMethodXAudio2.Enabled = false; -#endif + + if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows) + { + // Disable DirectSound and XAudio2 on Mono + rbOutputMethodDirectSound.Enabled = false; + rbOutputMethodXAudio2.Enabled = false; + } + rbOutputMethodDirectSound.Checked = Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound; rbOutputMethodXAudio2.Checked = Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2; rbOutputMethodOpenAL.Checked = Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL; @@ -83,11 +88,13 @@ namespace BizHawk.Client.EmuHawk private void PopulateDeviceList() { IEnumerable deviceNames = Enumerable.Empty(); -#if WINDOWS - if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames(); - if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames(); -#endif + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) + { + if (rbOutputMethodDirectSound.Checked) deviceNames = DirectSoundSoundOutput.GetDeviceNames(); + if (rbOutputMethodXAudio2.Checked) deviceNames = XAudio2SoundOutput.GetDeviceNames(); + } if (rbOutputMethodOpenAL.Checked) deviceNames = OpenALSoundOutput.GetDeviceNames(); + listBoxSoundDevices.Items.Clear(); listBoxSoundDevices.Items.Add(""); listBoxSoundDevices.SelectedIndex = 0; 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/images/HawkInLove.png b/BizHawk.Client.EmuHawk/images/HawkInLove.png deleted file mode 100644 index e29af04f0e..0000000000 Binary files a/BizHawk.Client.EmuHawk/images/HawkInLove.png and /dev/null differ 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..92fee7a5c5 100644 --- a/BizHawk.Client.EmuHawk/tools/CDL.cs +++ b/BizHawk.Client.EmuHawk/tools/CDL.cs @@ -7,6 +7,7 @@ using BizHawk.Emulation.Common; using BizHawk.Client.Common; using BizHawk.Client.EmuHawk.ToolExtensions; +using BizHawk.Common; //TODO - select which memorydomains go out to the CDL file. will this cause a problem when re-importing it? //perhaps missing domains shouldnt fail a check @@ -38,7 +39,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] @@ -98,7 +99,16 @@ namespace BizHawk.Client.EmuHawk if (_cdl == null) { lvCDL.BeginUpdate(); - lvCDL.Items.Clear(); + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) + { + lvCDL.Items.Clear(); + } + else + { + // this is a winforms implementation problem for mono + // see https://github.com/mono/mono/issues/11070 + // until this is resolved in mono we should just skip this call + } lvCDL.EndUpdate(); return; } @@ -147,29 +157,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 +508,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.Designer.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs index e0d3f9b754..ff6dc13a11 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs @@ -261,6 +261,7 @@ this.DisassemblerView.Scroll += new System.Windows.Forms.ScrollEventHandler(this.DisassemblerView_Scroll); this.DisassemblerView.SizeChanged += new System.EventHandler(this.DisassemblerView_SizeChanged); this.DisassemblerView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DisassemblerView_KeyDown); + this.DisassemblerView.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.DisassemblerView_Wheel); // // Address // diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs index 133341652f..cefc2830e9 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,41 @@ namespace BizHawk.Client.EmuHawk { if (e.Type == ScrollEventType.SmallIncrement) { - IncrementCurrentAddress(); - Disassemble(); - DisassemblerView.Refresh(); + SmallIncrement(); } if (e.Type == ScrollEventType.SmallDecrement) { - DecrementCurrentAddress(); - Disassemble(); - DisassemblerView.Refresh(); + SmallDecrement(); + } + } + + private void DisassemblerView_Wheel(object sender, MouseEventArgs e) + { + if (e.Delta > 0) + { + SmallDecrement(); + } + if (e.Delta > 120) + { + SmallDecrement(); + } + if (e.Delta > 240) + { + SmallDecrement(); + } + + if (e.Delta < 0) + { + SmallIncrement(); + } + if (e.Delta < -120) + { + SmallIncrement(); + } + if (e.Delta < -240) + { + SmallIncrement(); } } @@ -166,12 +191,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 +235,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..3f8774e932 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs @@ -7,6 +7,8 @@ using NLua; using BizHawk.Common; using BizHawk.Emulation.Common; using BizHawk.Client.Common; +using System.Threading; +using System.Diagnostics; // ReSharper disable StringLiteralTypo // ReSharper disable UnusedMember.Global @@ -145,6 +147,8 @@ namespace BizHawk.Client.EmuHawk public static void SetSoundOn(bool enable) { Global.Config.SoundEnabled = enable; + GlobalWin.Sound.StopSound(); + GlobalWin.Sound.StartSound(); } [LuaMethodExample("if ( client.GetSoundOn( ) ) then\r\n\tconsole.log( \"Gets the state of the Sound On toggle\" );\r\nend;")] @@ -320,7 +324,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 { @@ -472,5 +476,30 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.MainForm.FlushSaveRAM(); } + + [LuaMethodExample("client.sleep( 50 );")] + [LuaMethod("sleep", "sleeps for n milliseconds")] + public void Sleep(int millis) + { + Thread.Sleep(millis); + } + + [LuaMethodExample("client.exactsleep( 50 );")] + [LuaMethod("exactsleep", "sleeps exactly for n milliseconds")] + public void ExactSleep(int millis) + { + Stopwatch stopwatch = Stopwatch.StartNew(); + while (millis - stopwatch.ElapsedMilliseconds > 100) + { + Thread.Sleep(50); + } + while (true) + { + if (stopwatch.ElapsedMilliseconds >= millis) + { + break; + } + } + } } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Communication.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Communication.cs index fdae9f132d..4776698360 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Communication.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Communication.cs @@ -4,10 +4,6 @@ using NLua; using BizHawk.Emulation.Common; using BizHawk.Client.Common; using System.Text; -using System.Collections.Generic; -using System.Net.Http; -using System.Windows.Forms; - namespace BizHawk.Client.EmuHawk { @@ -37,70 +33,146 @@ namespace BizHawk.Client.EmuHawk { list.AppendLine(function.ToString()); } - return list.ToString(); } [LuaMethod("socketServerScreenShot", "sends a screenshot to the Socket server")] public string SocketServerScreenShot() { - return GlobalWin.socketServer.SendScreenshot(); + CheckSocketServer(); + return GlobalWin.socketServer?.SendScreenshot(); } + [LuaMethod("socketServerScreenShotResponse", "sends a screenshot to the Socket server and retrieves the response")] public string SocketServerScreenShotResponse() { - return GlobalWin.socketServer.SendScreenshot(1000).ToString(); + CheckSocketServer(); + return GlobalWin.socketServer?.SendScreenshot(1000).ToString(); } [LuaMethod("socketServerSend", "sends a string to the Socket server")] - public string SocketServerSend(string SendString) + public int SocketServerSend(string SendString) { - return "Sent : " + GlobalWin.socketServer.SendString(SendString).ToString() + " bytes"; + if (!CheckSocketServer()) + { + return -1; + } + return GlobalWin.socketServer.SendString(SendString); } + [LuaMethod("socketServerResponse", "receives a message from the Socket server")] public string SocketServerResponse() { - return GlobalWin.socketServer.ReceiveMessage(); + CheckSocketServer(); + return GlobalWin.socketServer?.ReceiveMessage(); } [LuaMethod("socketServerSuccessful", "returns the status of the last Socket server action")] public bool SocketServerSuccessful() { + if (!CheckSocketServer()) + { + return false; + } return GlobalWin.socketServer.Successful(); } + [LuaMethod("socketServerSetTimeout", "sets the timeout in milliseconds for receiving messages")] public void SocketServerSetTimeout(int timeout) { - GlobalWin.socketServer.SetTimeout(timeout); + CheckSocketServer(); + GlobalWin.socketServer?.SetTimeout(timeout); } + + [LuaMethod("socketServerSetIp", "sets the IP address of the Lua socket server")] + public void SocketServerSetIp(string ip) + { + CheckSocketServer(); + GlobalWin.socketServer.Ip = ip; + } + + [LuaMethod("socketServerSetPort", "sets the port of the Lua socket server")] + public void SocketServerSetPort(int port) + { + CheckSocketServer(); + GlobalWin.socketServer.Port = port; + } + + [LuaMethod("socketServerGetIp", "returns the IP address of the Lua socket server")] + public string SocketServerGetIp() + { + return GlobalWin.socketServer?.Ip; + } + + [LuaMethod("socketServerGetPort", "returns the port of the Lua socket server")] + public int? SocketServerGetPort() + { + return GlobalWin.socketServer?.Port; + } + + [LuaMethod("socketServerGetInfo", "returns the IP and port of the Lua socket server")] + public string SocketServerGetInfo() + { + if (!CheckSocketServer()) + { + return ""; + } + return GlobalWin.socketServer.GetInfo(); + } + + private bool CheckSocketServer() + { + if (GlobalWin.socketServer == null) + { + Log("Socket server was not initialized, please initialize it via the command line"); + return false; + } + return true; + } + // All MemoryMappedFile related methods [LuaMethod("mmfSetFilename", "Sets the filename for the screenshots")] public void MmfSetFilename(string filename) { - GlobalWin.memoryMappedFiles.SetFilename(filename); + CheckMmf(); + GlobalWin.memoryMappedFiles.Filename = filename; } + [LuaMethod("mmfGetFilename", "Gets the filename for the screenshots")] - public string MmfSetFilename() + public string MmfGetFilename() { - return GlobalWin.memoryMappedFiles.GetFilename(); + CheckMmf(); + return GlobalWin.memoryMappedFiles?.Filename; } [LuaMethod("mmfScreenshot", "Saves screenshot to memory mapped file")] public int MmfScreenshot() { + CheckMmf(); return GlobalWin.memoryMappedFiles.ScreenShotToFile(); } [LuaMethod("mmfWrite", "Writes a string to a memory mapped file")] public int MmfWrite(string mmf_filename, string outputString) { + CheckMmf(); return GlobalWin.memoryMappedFiles.WriteToFile(mmf_filename, Encoding.ASCII.GetBytes(outputString)); } [LuaMethod("mmfRead", "Reads a string from a memory mapped file")] public string MmfRead(string mmf_filename, int expectedSize) { - return GlobalWin.memoryMappedFiles.ReadFromFile(mmf_filename, expectedSize).ToString(); + CheckMmf(); + return GlobalWin.memoryMappedFiles?.ReadFromFile(mmf_filename, expectedSize).ToString(); } + + private void CheckMmf() + { + if (GlobalWin.memoryMappedFiles == null) + { + Log("Memory mapped file was not initialized, please initialize it via the command line"); + } + } + // All HTTP related methods [LuaMethod("httpTest", "tests HTTP connections")] public string HttpTest() @@ -111,51 +183,76 @@ namespace BizHawk.Client.EmuHawk list.AppendLine("done testing"); return list.ToString(); } + [LuaMethod("httpTestGet", "tests the HTTP GET connection")] public string HttpTestGet() { - return GlobalWin.httpCommunication.TestGet(); + CheckHttp(); + return GlobalWin.httpCommunication?.TestGet(); } + [LuaMethod("httpGet", "makes a HTTP GET request")] public string HttpGet(string url) { - return GlobalWin.httpCommunication.ExecGet(url); + CheckHttp(); + return GlobalWin.httpCommunication?.ExecGet(url); } [LuaMethod("httpPost", "makes a HTTP POST request")] public string HttpPost(string url, string payload) { - return GlobalWin.httpCommunication.ExecPost(url, payload); + CheckHttp(); + return GlobalWin.httpCommunication?.ExecPost(url, payload); } + [LuaMethod("httpPostScreenshot", "HTTP POST screenshot")] public string HttpPostScreenshot() { - return GlobalWin.httpCommunication.SendScreenshot(); + CheckHttp(); + return GlobalWin.httpCommunication?.SendScreenshot(); } + [LuaMethod("httpSetTimeout", "Sets HTTP timeout in milliseconds")] public void HttpSetTimeout(int timeout) { - GlobalWin.httpCommunication.SetTimeout(timeout); + CheckHttp(); + GlobalWin.httpCommunication?.SetTimeout(timeout); } + [LuaMethod("httpSetPostUrl", "Sets HTTP POST URL")] public void HttpSetPostUrl(string url) { - GlobalWin.httpCommunication.SetPostUrl(url); + CheckHttp(); + GlobalWin.httpCommunication.PostUrl = url; } + [LuaMethod("httpSetGetUrl", "Sets HTTP GET URL")] public void HttpSetGetUrl(string url) { - GlobalWin.httpCommunication.SetGetUrl(url); + CheckHttp(); + GlobalWin.httpCommunication.GetUrl = url; } + [LuaMethod("httpGetPostUrl", "Gets HTTP POST URL")] public string HttpGetPostUrl() { - return GlobalWin.httpCommunication.GetPostUrl(); + CheckHttp(); + return GlobalWin.httpCommunication?.PostUrl; } + [LuaMethod("httpGetGetUrl", "Gets HTTP GET URL")] public string HttpGetGetUrl() { - return GlobalWin.httpCommunication.GetGetUrl(); + CheckHttp(); + return GlobalWin.httpCommunication?.GetUrl; + } + + private void CheckHttp() + { + if (GlobalWin.httpCommunication == null) + { + Log("HTTP was not initialized, please initialize it via the command line"); + } } } -} +} \ No newline at end of file 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 9775b41c28..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; } 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/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 c84ad96923..01e632f799 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -60,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(); } @@ -173,15 +186,15 @@ namespace BizHawk.Client.EmuHawk } var currentScripts = LuaImp?.ScriptList; // Temp fix for now - LuaImp = PlatformLinkedLibSingleton.RunningOnUnix - ? (PlatformEmuLuaLibrary) new NotReallyLuaLibrary() - : (PlatformEmuLuaLibrary) new EmuLuaLibrary(Emulator.ServiceProvider); + LuaImp = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows + ? (PlatformEmuLuaLibrary) new EmuLuaLibrary(Emulator.ServiceProvider) + : (PlatformEmuLuaLibrary) new NotReallyLuaLibrary(); 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) { @@ -241,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); @@ -438,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; @@ -623,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."; } } @@ -756,7 +769,7 @@ namespace BizHawk.Client.EmuHawk SaveSessionAs(); } - OutputMessages.Text = Path.GetFileName(LuaImp.ScriptList.Filename) + " saved."; + OutputMessages.Text = $"{Path.GetFileName(LuaImp.ScriptList.Filename)} saved."; } } @@ -898,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) { @@ -960,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 (*.*)|*.*" }; 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/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 f64cace517..a163f97c2e 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -226,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}"); } } @@ -244,7 +244,7 @@ namespace BizHawk.Client.EmuHawk { Branch(); CallSavedCallback(Movie.BranchCount - 1); - GlobalWin.OSD.AddMessage("Added branch " + Movie.CurrentBranch.ToString()); + GlobalWin.OSD.AddMessage($"Added branch {Movie.CurrentBranch}"); } private void AddBranchWithTexToolStripMenuItem_Click(object sender, EventArgs e) @@ -252,7 +252,7 @@ namespace BizHawk.Client.EmuHawk Branch(); EditBranchTextPopUp(Movie.CurrentBranch); CallSavedCallback(Movie.BranchCount - 1); - GlobalWin.OSD.AddMessage("Added branch " + Movie.CurrentBranch.ToString()); + GlobalWin.OSD.AddMessage($"Added branch {Movie.CurrentBranch}"); } private void LoadBranchToolStripMenuItem_Click(object sender, EventArgs e) @@ -292,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}"); } } @@ -312,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}"); } } } @@ -358,7 +358,7 @@ namespace BizHawk.Client.EmuHawk CallRemovedCallback(index); Tastudio.RefreshDialog(); - GlobalWin.OSD.AddMessage("Removed branch " + index.ToString()); + GlobalWin.OSD.AddMessage($"Removed branch {index}"); } } @@ -578,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..627f28e352 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) { @@ -185,7 +185,7 @@ namespace BizHawk.Client.EmuHawk index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(SelectedButton); if (SelectedButton == "Default bool Auto-Fire") { - index = _tastudio.BoolPatterns.Length + 1; + index = _tastudio.BoolPatterns.Length - 1; } if (index != -1) @@ -198,7 +198,7 @@ namespace BizHawk.Client.EmuHawk { if (SelectedButton == "Default float Auto-Fire") { - index = _tastudio.FloatPatterns.Length + 1; + index = _tastudio.FloatPatterns.Length - 1; } else { @@ -224,7 +224,7 @@ namespace BizHawk.Client.EmuHawk int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(SelectedButton); if (SelectedButton == "Default bool Auto-Fire") { - index = _tastudio.BoolPatterns.Length + 1; + index = _tastudio.BoolPatterns.Length - 1; } if (index != -1) @@ -244,7 +244,7 @@ namespace BizHawk.Client.EmuHawk { if (SelectedButton == "Default float Auto-Fire") { - index = _tastudio.FloatPatterns.Length + 1; + index = _tastudio.FloatPatterns.Length - 1; } else { @@ -263,15 +263,19 @@ namespace BizHawk.Client.EmuHawk _tastudio.FloatPatterns[index] = new AutoPatternFloat(p.ToArray(), LagBox.Checked, 0, _loopAt); } - _tastudio.UpdateAutoFire(SelectedButton, null); + if ((SelectedButton != "Default float Auto-Fire") && (SelectedButton != "Default bool Auto-Fire")) + { + _tastudio.UpdateAutoFire(SelectedButton, null); + } } private void GetPattern() { int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(SelectedButton); + if (SelectedButton == "Default bool Auto-Fire") { - index = _tastudio.BoolPatterns.Length + 1; + index = _tastudio.BoolPatterns.Length - 1; } if (index != -1) @@ -296,13 +300,13 @@ namespace BizHawk.Client.EmuHawk } } - _loopAt = _tastudio.BoolPatterns[index].Loop; + _loopAt = _tastudio.BoolPatterns[index].Loop; } else { if (SelectedButton == "Default float Auto-Fire") { - index = _tastudio.FloatPatterns.Length + 1; + index = _tastudio.FloatPatterns.Length - 1; } else { 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 61ec0e85bb..672ec1656f 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; } @@ -624,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); @@ -819,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; } @@ -862,7 +862,16 @@ namespace BizHawk.Client.EmuHawk DialogResult result = prompt.ShowDialog(); if (result == DialogResult.OK) { - int val = int.Parse(prompt.PromptText); + int val = 0; + try + { + val = int.Parse(prompt.PromptText); + } + catch + { + MessageBox.Show("Invalid Entry.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + if (val > 0) { CurrentTasMovie.ChangeLog.MaxSteps = val; @@ -1261,14 +1270,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 @@ -1312,9 +1321,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]); } @@ -1368,7 +1375,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 diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 1462a28b47..c9a866b822 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -416,6 +416,12 @@ namespace BizHawk.Client.EmuHawk StartNewTasMovie(); } + if (Global.Emulator is NullEmulator) + { + DisengageTastudio(); + return false; + } + EngageTastudio(); return true; } @@ -607,7 +613,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(); } @@ -648,8 +654,11 @@ namespace BizHawk.Client.EmuHawk CurrentTasMovie.PopulateWithDefaultHeaderValues(); SetTasMovieCallbacks(); CurrentTasMovie.ClearChanges(); // Don't ask to save changes here. - HandleMovieLoadStuff(); - CurrentTasMovie.TasStateManager.Capture(); // Capture frame 0 always. + + if (HandleMovieLoadStuff()) + { + CurrentTasMovie.TasStateManager.Capture(); // Capture frame 0 always. + } // clear all selections TasView.DeselectAll(); @@ -686,7 +695,7 @@ namespace BizHawk.Client.EmuHawk CurrentTasMovie.ClearChanges(); SetTextProperty(); - MessageStatusLabel.Text = Path.GetFileName(CurrentTasMovie.Filename) + " loaded."; + MessageStatusLabel.Text = $"{Path.GetFileName(CurrentTasMovie.Filename)} loaded."; return true; } @@ -699,7 +708,7 @@ namespace BizHawk.Client.EmuHawk { movie = CurrentTasMovie; } - + SetTasMovieCallbacks(movie as TasMovie); bool result = Mainform.StartNewMovie(movie, record); @@ -788,7 +797,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 +807,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 +815,7 @@ namespace BizHawk.Client.EmuHawk var text = "TAStudio"; if (CurrentTasMovie != null) { - text += " - " + CurrentTasMovie.Name + (CurrentTasMovie.Changes ? "*" : ""); + text += $" - {CurrentTasMovie.Name}{(CurrentTasMovie.Changes ? "*" : "")}"; } if (InvokeRequired) @@ -986,13 +995,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() + - (_tasClipboard.Any() - ? ", Clipboard: " + _tasClipboard.Count + " frame" + (_tasClipboard.Count == 1 ? "" : "s") - : ""); + 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() @@ -1099,7 +1104,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) @@ -1138,7 +1143,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; @@ -1151,7 +1156,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 67aefdfd0f..23c3a8df8c 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolBox.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolBox.cs @@ -7,6 +7,7 @@ using System.Windows.Forms; using BizHawk.Emulation.Common; using BizHawk.Client.ApiHawk; +using BizHawk.Common; namespace BizHawk.Client.EmuHawk { @@ -68,6 +69,8 @@ namespace BizHawk.Client.EmuHawk continue; // if (!ApiInjector.IsAvailable(, t)) // continue; + if (t == typeof(HexView) && OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows) + continue; // Skip this tool on Unix. It isn't finished and only causes exceptions 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 05128567ec..27d1ed70e8 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -47,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 @@ -159,7 +159,15 @@ namespace BizHawk.Client.EmuHawk } newTool.Restart(); - newTool.Show(); + if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows + && newTool is RamSearch) + { + // the mono winforms implementation is buggy, skip to the return statement and call Show in MainForm instead + } + else + { + newTool.Show(); + } return (T)newTool; } @@ -236,7 +244,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; @@ -631,7 +639,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; } } @@ -740,7 +748,7 @@ namespace BizHawk.Client.EmuHawk return false; } - if (t == typeof(LuaConsole) && PlatformLinkedLibSingleton.RunningOnUnix) return false; + if (t == typeof(LuaConsole) && OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows) return false; var tool = Assembly .GetExecutingAssembly() @@ -1023,7 +1031,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.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/controls/VirtualPadAnalogStick.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs index 98f4e0fa53..fa62c0fc08 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.cs @@ -264,10 +264,7 @@ namespace BizHawk.Client.EmuHawk private void SetAnalogMaxFromNumerics() { if (!_programmaticallyUpdatingNumerics) - { - //blehh,... this damn feature - AnalogStick.SetUserRange((float)MaxXNumeric.Value, (float)MaxYNumeric.Value); - } + AnalogStick.SetUserRange((sbyte)MaxXNumeric.Value, (sbyte)MaxYNumeric.Value); } } } diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs new file mode 100644 index 0000000000..928cbb1fed --- /dev/null +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogStickPanel.cs @@ -0,0 +1,302 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +using BizHawk.Client.Common; +using BizHawk.Common; +using BizHawk.Common.NumberExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Client.EmuHawk +{ + public sealed class AnalogStickPanel : Panel + { + private int _x; + private int _y; + + public int X + { + get + { + return _x; + } + set + { + _x = RangeX.Constrain(value); + SetAnalog(); + } + } + + public int Y + { + get + { + return _y; + } + set + { + _y = RangeY.Constrain(value); + SetAnalog(); + } + } + + public bool HasValue; + public bool ReadOnly { private get; set; } + + public string XName = string.Empty; + public string YName = string.Empty; + + private IController _previous; + + private sbyte UserRangePercentageX = 100; + private sbyte UserRangePercentageY = 100; + + public void SetUserRange(sbyte rx, sbyte ry) + { + UserRangePercentageX = rx; + UserRangePercentageY = ry; + Rerange(); + Refresh(); + } + + public void SetRangeX(float[] range) + { + ActualRangeX.Min = (int) range[0]; + ActualRangeX.Max = (int) range[2]; + Rerange(); + } + + public void SetRangeY(float[] range) + { + ActualRangeY.Min = (int) range[0]; + ActualRangeY.Max = (int) range[2]; + Rerange(); + } + + private readonly MutableIntRange RangeX = new MutableIntRange(-128, 127); + private readonly MutableIntRange RangeY = new MutableIntRange(-128, 127); + private readonly MutableIntRange ActualRangeX = new MutableIntRange(-128, 127); + private readonly MutableIntRange ActualRangeY = new MutableIntRange(-128, 127); + + private bool ReverseX; + private bool ReverseY; + + private void Rerange() + { + ReverseX = UserRangePercentageX < 0; + ReverseY = UserRangePercentageY < 0; + + var midX = (ActualRangeX.Min + ActualRangeX.Max) / 2; + var halfRangeX = (ReverseX ? -1 : 1) * (ActualRangeX.Max - ActualRangeX.Min) * UserRangePercentageX / 200.0; + RangeX.Min = (int) (midX - halfRangeX); + RangeX.Max = (int) (midX + halfRangeX); + + var midY = (ActualRangeY.Min + ActualRangeY.Max) / 2; + var halfRangeY = (ReverseY ? -1 : 1) * (ActualRangeY.Max - ActualRangeY.Min) * UserRangePercentageY / 200.0; + RangeY.Min = (int) (midY - halfRangeY); + RangeY.Max = (int) (midY + halfRangeY); + + // re-constrain after changing ranges + X = X; + Y = Y; + } + + /// + /// never tested, assuming it works --zeromus + /// + private const float ScaleX = 0.60f; + /// + private const float ScaleY = 0.60f; + + /// + /// min + (max - i) == max - (i - min) == min + max - i + /// + private int MaybeReversedInX(int i) => ReverseX ? RangeX.Min + RangeX.Max - i : i; + /// + private int MaybeReversedInY(int i) => ReverseY ? RangeY.Min + RangeY.Max - i : i; + + private int PixelSizeX => (int)(RangeX.GetCount() * ScaleX); + private int PixelSizeY => (int)(RangeY.GetCount() * ScaleY); + private int PixelMinX => (Size.Width - PixelSizeX) / 2; + private int PixelMinY => (Size.Height - PixelSizeY) / 2; + private int PixelMidX => PixelMinX + PixelSizeX / 2; + private int PixelMidY => PixelMinY + PixelSizeY / 2; + private int PixelMaxX => PixelMinX + PixelSizeX - 1; + private int PixelMaxY => PixelMinY + PixelSizeY - 1; + + private int RealToGfxX(int val) => + PixelMinX + ((MaybeReversedInX(RangeX.Constrain(val)) - RangeX.Min) * ScaleX).RoundToInt(); + + private int RealToGfxY(int val) => + PixelMinY + ((MaybeReversedInY(RangeY.Constrain(val)) - RangeY.Min) * ScaleY).RoundToInt(); + + private int GfxToRealX(int val) => + MaybeReversedInX(RangeX.Constrain(RangeX.Min + ((val - PixelMinX) / ScaleX).RoundToInt())); + + private int GfxToRealY(int val) => + MaybeReversedInY(RangeY.Constrain(RangeY.Min + ((val - PixelMinY) / ScaleY).RoundToInt())); + + private readonly Pen BlackPen = new Pen(Brushes.Black); + private readonly Pen BluePen = new Pen(Brushes.Blue, 2); + private readonly Pen GrayPen = new Pen(Brushes.Gray, 2); + + private readonly Bitmap Dot = new Bitmap(7, 7); + private readonly Bitmap GrayDot = new Bitmap(7, 7); + + public Action ClearCallback { private get; set; } + + private void DoClearCallback() + { + ClearCallback?.Invoke(); + } + + public AnalogStickPanel() + { + Size = new Size(PixelSizeX + 1, PixelSizeY + 1); + SetStyle(ControlStyles.AllPaintingInWmPaint, true); + SetStyle(ControlStyles.UserPaint, true); + SetStyle(ControlStyles.OptimizedDoubleBuffer, true); + SetStyle(ControlStyles.SupportsTransparentBackColor, true); + SetStyle(ControlStyles.Opaque, true); + BackColor = Color.Gray; + Paint += AnalogControlPanel_Paint; + BorderStyle = BorderStyle.Fixed3D; + + // Draw the dot into a bitmap + using (var g = Graphics.FromImage(Dot)) + { + g.Clear(Color.Transparent); + var redBrush = Brushes.Red; + g.FillRectangle(redBrush, 2, 0, 3, 7); + g.FillRectangle(redBrush, 1, 1, 5, 5); + g.FillRectangle(redBrush, 0, 2, 7, 3); + } + + using (var gg = Graphics.FromImage(GrayDot)) + { + gg.Clear(Color.Transparent); + gg.FillRectangle(Brushes.Gray, 2, 0, 3, 7); + gg.FillRectangle(Brushes.Gray, 1, 1, 5, 5); + gg.FillRectangle(Brushes.Gray, 0, 2, 7, 3); + } + } + + private void SetAnalog() + { + Global.StickyXORAdapter.SetFloat(XName, HasValue ? X : (int?)null); + Global.StickyXORAdapter.SetFloat(YName, HasValue ? Y : (int?)null); + Refresh(); + } + + private void AnalogControlPanel_Paint(object sender, PaintEventArgs e) + { + unchecked + { + // Background + e.Graphics.Clear(Color.LightGray); + + e.Graphics.FillRectangle(Brushes.LightGray, PixelMinX, PixelMinY, PixelMaxX - PixelMinX, PixelMaxY - PixelMinY); + e.Graphics.FillEllipse(ReadOnly ? Brushes.Beige : Brushes.White, PixelMinX, PixelMinY, PixelMaxX - PixelMinX - 2, PixelMaxY - PixelMinY - 3); + e.Graphics.DrawEllipse(BlackPen, PixelMinX, PixelMinY, PixelMaxX - PixelMinX - 2, PixelMaxY - PixelMinY - 3); + e.Graphics.DrawLine(BlackPen, PixelMidX, 0, PixelMidX, PixelMaxY); + e.Graphics.DrawLine(BlackPen, 0, PixelMidY, PixelMaxX, PixelMidY); + + // Previous frame + if (_previous != null) + { + var pX = (int)_previous.GetFloat(XName); + var pY = (int)_previous.GetFloat(YName); + e.Graphics.DrawLine(GrayPen, PixelMidX, PixelMidY, RealToGfxX(pX), RealToGfxY(pY)); + e.Graphics.DrawImage(GrayDot, RealToGfxX(pX) - 3, RealToGfxY(RangeY.Max) - RealToGfxY(pY) - 3); + } + + // Line + if (HasValue) + { + e.Graphics.DrawLine(BluePen, PixelMidX, PixelMidY, RealToGfxX(X), RealToGfxY(Y)); + e.Graphics.DrawImage(ReadOnly ? GrayDot : Dot, RealToGfxX(X) - 3, RealToGfxY(Y) - 3); + } + } + } + + protected override void OnMouseMove(MouseEventArgs e) + { + if (ReadOnly) return; + if (e.Button == MouseButtons.Left) + { + X = GfxToRealX(e.X); + Y = GfxToRealY(e.Y); + HasValue = true; + SetAnalog(); + } + else if (e.Button == MouseButtons.Right) + { + Clear(); + } + Refresh(); + base.OnMouseMove(e); + } + + protected override void OnMouseUp(MouseEventArgs e) + { + base.OnMouseUp(e); + Capture = false; + } + + protected override void WndProc(ref Message m) + { + if (m.Msg == 0x007B) // WM_CONTEXTMENU + { + // Don't let parent controls get this. We handle the right mouse button ourselves + return; + } + + base.WndProc(ref m); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (ReadOnly) return; + if (e.Button == MouseButtons.Left) + { + X = GfxToRealX(e.X); + Y = GfxToRealY(e.Y); + HasValue = true; + } + if (e.Button == MouseButtons.Right) + { + Clear(); + } + Refresh(); + } + + public void Clear() + { + if (!HasValue && X == 0 && Y == 0) return; + X = Y = 0; + HasValue = false; + DoClearCallback(); + Refresh(); + } + + public void Set(IController controller) + { + var newX = (int) controller.GetFloat(XName); + var newY = (int) controller.GetFloat(YName); + if (newX != X || newY != Y) SetPosition(newX, newY); + } + + public void SetPrevious(IController previous) + { + _previous = previous; + } + + private void SetPosition(int xval, int yval) + { + X = xval; + Y = yval; + HasValue = true; + Refresh(); + } + } +} diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogSticklPanel.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogSticklPanel.cs deleted file mode 100644 index 38dc7833c8..0000000000 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/components/AnalogSticklPanel.cs +++ /dev/null @@ -1,403 +0,0 @@ -using System; -using System.Drawing; -using System.Windows.Forms; - -using BizHawk.Client.Common; -using BizHawk.Emulation.Common; - -//Just because this code was mostly rewritten, dont think it isnt still awful - -namespace BizHawk.Client.EmuHawk -{ - public sealed class AnalogStickPanel : Panel - { - private int _x = 0; - private int _y = 0; - - public int X - { - get - { - return _x; - } - - set - { - if (value < MinX) { _x = MinX; } - else if (value > MaxX) { _x = MaxX; } - else { _x = value; } - SetAnalog(); - } - } - - public int Y - { - get - { - return _y; - } - - set - { - if (value < MinY) { _y = MinY; } - else if (value > MaxY) { _y = MaxY; } - else { _y = value; } - SetAnalog(); - } - } - - public bool HasValue = false; - public bool ReadOnly { get; set; } - - public string XName = ""; - public string YName = ""; - - private IController _previous = null; - - float UserRangePercentageX = 100, UserRangePercentageY = 100; - - public void SetUserRange(float rx, float ry) - { - UserRangePercentageX = rx; - UserRangePercentageY = ry; - Rerange(); - Refresh(); - } - - public void SetRangeX(float[] range) - { - for (int i = 0; i < 3; i++) ActualRangeX[i] = range[i]; - Rerange(); - } - - public void SetRangeY(float[] range) - { - for (int i = 0; i < 3; i++) ActualRangeY[i] = range[i]; - Rerange(); - } - - public float[] RangeX = new float[] { -128f, 0.0f, 127f }; - public float[] RangeY = new float[] { -128f, 0.0f, 127f }; - public float[] ActualRangeX = new float[] { -128f, 0.0f, 127f }; - public float[] ActualRangeY = new float[] { -128f, 0.0f, 127f }; - - float flipx = 1, flipy = 1; - - void Rerange() - { - //baseline: - //Array.Copy(ActualRangeX, RangeX, 3); - //Array.Copy(ActualRangeY, RangeY, 3); - - float rx = ActualRangeX[2] - ActualRangeX[0]; - float ry = ActualRangeY[2] - ActualRangeY[0]; - float midx = rx / 2 + ActualRangeX[0]; - float midy = ry / 2 + ActualRangeY[0]; - rx *= UserRangePercentageX / 100; - ry *= UserRangePercentageY / 100; - float minx = midx - rx / 2; - float maxx = minx + rx; - float miny = midy - ry / 2; - float maxy = miny + ry; - - if (minx > maxx) - { - float temp = minx; - minx = maxx; - maxx = temp; - flipx = -1; - } - - if (miny > maxy) - { - float temp = miny; - miny = maxy; - maxy = temp; - flipy = -1; - } - - //Range?[1] isn't really used - RangeX[0] = minx; - RangeX[2] = maxx; - RangeY[0] = miny; - RangeY[2] = maxy; - - Clamp(); - } - - //dont count on this working. it's never been tested. - //but it kind of must be, or else nothing here would work... - public float ScaleX = 0.60f; - public float ScaleY = 0.60f; - - int MinX { get { return (int)(RangeX[0]); } } - int MinY { get { return (int)(RangeY[0]); } } - int MaxX { get { return (int)(RangeX[2]); } } - int MaxY { get { return (int)(RangeY[2]); } } - int RangeSizeX { get { return (int)(MaxX - MinX + 1); } } - int RangeSizeY { get { return (int)(MaxY - MinY + 1); } } - - int PixelSizeX { get { return (int)(RangeSizeX * ScaleX); } } - int PixelSizeY { get { return (int)(RangeSizeY * ScaleY); } } - int PixelMinX { get { return (Size.Width - PixelSizeX) / 2; } } - int PixelMinY { get { return (Size.Height - PixelSizeY) / 2; } } - int PixelMidX { get { return PixelMinX + PixelSizeX / 2; } } - int PixelMidY { get { return PixelMinY + PixelSizeY / 2; } } - int PixelMaxX { get { return PixelMinX + PixelSizeX - 1; } } - int PixelMaxY { get { return PixelMinY + PixelSizeY - 1; } } - - private int RealToGfxX(int val) - { - int v = val; - if (flipx == -1) - v = (MaxX - val) + MinX; - v = (int)(((float)v - MinX) * ScaleX); - v += PixelMinX; - return v; - } - - private int RealToGfxY(int val) - { - int v = val; - if (flipy == -1) - v = (MaxY - val) + MinY; - v = (int)(((float)v - MinY) * ScaleY); - v += PixelMinY; - return v; - } - - private int GfxToRealX(int val) - { - val -= PixelMinX; - float v = ((float)val / ScaleX + MinX); - if (v < MinX) v = MinX; - if (v > MaxX) v = MaxX; - if (flipx == -1) - v = (MaxX - v) + MinX; - return (int)v; - } - - private int GfxToRealY(int val) - { - val -= PixelMinY; - float v; - v = ((float)val / ScaleY + MinY); - if (v < MinX) v = MinX; - if (v > MaxX) v = MaxX; - if(flipy == -1) - v = (MaxY - v) + MinY; - return (int)v; - } - - private readonly Brush WhiteBrush = Brushes.White; - private readonly Brush GrayBrush = Brushes.LightGray; - private readonly Brush RedBrush = Brushes.Red; - private readonly Brush OffWhiteBrush = Brushes.Beige; - - private readonly Pen BlackPen = new Pen(Brushes.Black); - private readonly Pen BluePen = new Pen(Brushes.Blue, 2); - private readonly Pen GrayPen = new Pen(Brushes.Gray, 2); - - private readonly Bitmap Dot = new Bitmap(7, 7); - private readonly Bitmap GrayDot = new Bitmap(7, 7); - - public Action ClearCallback { get; set; } - - private void DoClearCallback() - { - if (ClearCallback != null) - { - ClearCallback(); - } - } - - public AnalogStickPanel() - { - Size = new Size(PixelSizeX + 1, PixelSizeY + 1); - SetStyle(ControlStyles.AllPaintingInWmPaint, true); - SetStyle(ControlStyles.UserPaint, true); - SetStyle(ControlStyles.OptimizedDoubleBuffer, true); - SetStyle(ControlStyles.SupportsTransparentBackColor, true); - SetStyle(ControlStyles.Opaque, true); - BackColor = Color.Gray; - Paint += AnalogControlPanel_Paint; - BorderStyle = BorderStyle.Fixed3D; - - // Draw the dot into a bitmap - using (var g = Graphics.FromImage(Dot)) - { - g.Clear(Color.Transparent); - g.FillRectangle(RedBrush, 2, 0, 3, 7); - g.FillRectangle(RedBrush, 1, 1, 5, 5); - g.FillRectangle(RedBrush, 0, 2, 7, 3); - } - - using (var gg = Graphics.FromImage(GrayDot)) - { - gg.Clear(Color.Transparent); - gg.FillRectangle(Brushes.Gray, 2, 0, 3, 7); - gg.FillRectangle(Brushes.Gray, 1, 1, 5, 5); - gg.FillRectangle(Brushes.Gray, 0, 2, 7, 3); - } - } - - private void SetAnalog() - { - var xn = HasValue ? X : (int?)null; - var yn = HasValue ? Y : (int?)null; - Global.StickyXORAdapter.SetFloat(XName, xn); - Global.StickyXORAdapter.SetFloat(YName, yn); - - Refresh(); - } - - private void AnalogControlPanel_Paint(object sender, PaintEventArgs e) - { - unchecked - { - // Background - e.Graphics.Clear(Color.LightGray); - - e.Graphics.FillRectangle(GrayBrush, PixelMinX, PixelMinY, PixelMaxX - PixelMinX, PixelMaxY- PixelMinY); - e.Graphics.FillEllipse(ReadOnly ? OffWhiteBrush : WhiteBrush, PixelMinX, PixelMinY, PixelMaxX - PixelMinX - 2, PixelMaxY - PixelMinY - 3); - e.Graphics.DrawEllipse(BlackPen, PixelMinX, PixelMinY, PixelMaxX - PixelMinX - 2, PixelMaxY - PixelMinY - 3); - e.Graphics.DrawLine(BlackPen, PixelMidX, 0, PixelMidX, PixelMaxY); - e.Graphics.DrawLine(BlackPen, 0, PixelMidY, PixelMaxX, PixelMidY); - - // Previous frame - if (_previous != null) - { - var pX = (int)_previous.GetFloat(XName); - var pY = (int)_previous.GetFloat(YName); - e.Graphics.DrawLine(GrayPen, PixelMidX, PixelMidY, RealToGfxX(pX), RealToGfxY(pY)); - e.Graphics.DrawImage(GrayDot, RealToGfxX(pX) - 3, RealToGfxY(MaxY) - RealToGfxY(pY) - 3); - } - - // Line - if (HasValue) - { - e.Graphics.DrawLine(BluePen, PixelMidX, PixelMidY, RealToGfxX(X), RealToGfxY(Y)); - e.Graphics.DrawImage(ReadOnly ? GrayDot : Dot, RealToGfxX(X) - 3, RealToGfxY(Y) - 3); - } - } - } - - protected override void OnMouseMove(MouseEventArgs e) - { - if (!ReadOnly) - { - if (e.Button == MouseButtons.Left) - { - X = GfxToRealX(e.X); - Y = GfxToRealY(e.Y); - Clamp(); - HasValue = true; - SetAnalog(); - } - else if (e.Button == MouseButtons.Right) - { - Clear(); - } - - Refresh(); - base.OnMouseMove(e); - } - } - - protected override void OnMouseUp(MouseEventArgs e) - { - base.OnMouseUp(e); - Capture = false; - } - - protected override void WndProc(ref Message m) - { - if (m.Msg == 0x007B) // WM_CONTEXTMENU - { - // Don't let parent controls get this. We handle the right mouse button ourselves - return; - } - - base.WndProc(ref m); - } - - protected override void OnMouseDown(MouseEventArgs e) - { - if (!ReadOnly) - { - if (e.Button == MouseButtons.Left) - { - X = GfxToRealX(e.X); - Y = GfxToRealY(e.Y); - Clamp(); - HasValue = true; - } - if (e.Button == MouseButtons.Right) - { - Clear(); - } - - Refresh(); - } - } - - - public void Clear() - { - if (X != 0 || Y != 0 || HasValue) - { - X = Y = 0; - HasValue = false; - DoClearCallback(); - Refresh(); - } - } - - public void Set(IController controller) - { - var newX = (int)controller.GetFloat(XName); - var newY = (int)controller.GetFloat(YName); - var changed = newX != X || newY != Y; - if (changed) - { - SetPosition(newX, newY); - } - } - - public void SetPrevious(IController previous) - { - _previous = previous; - } - - public void SetPosition(int xval, int yval) - { - X = xval; - Y = yval; - Clamp(); - HasValue = true; - - Refresh(); - } - - private void Clamp() - { - if (X > MaxX) - { - X = MaxX; - } - else if (X < MinX) - { - X = MinX; - } - - if (Y > MaxY) - { - Y = MaxY; - } - else if (Y < MinY) - { - Y = MinY; - } - } - } -} diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A26Schema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A26Schema.cs index c915c4015d..c15d0f3095 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A26Schema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/A26Schema.cs @@ -39,6 +39,8 @@ namespace BizHawk.Client.EmuHawk return StandardController(controller); case Atari2600ControllerTypes.Paddle: return PaddleController(controller); + case Atari2600ControllerTypes.BoostGrip: + return BoostGripController(controller); case Atari2600ControllerTypes.Driving: return DrivingController(controller); } @@ -48,7 +50,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 +58,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 +66,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 +74,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 +82,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 +90,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 +103,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 +111,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 +135,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, @@ -145,11 +147,78 @@ namespace BizHawk.Client.EmuHawk }; } + private static PadSchema BoostGripController(int controller) + { + return new PadSchema + { + DisplayName = $"Player {controller}", + IsConsole = false, + DefaultSize = new Size(174, 74), + MaxSize = new Size(174, 74), + Buttons = new[] + { + new PadSchema.ButtonSchema + { + Name = $"P{controller} Up", + DisplayName = "", + Icon = Properties.Resources.BlueUp, + Location = new Point(23, 15), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Down", + DisplayName = "", + Icon = Properties.Resources.BlueDown, + Location = new Point(23, 36), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Left", + DisplayName = "", + Icon = Properties.Resources.Back, + Location = new Point(2, 24), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Right", + DisplayName = "", + Icon = Properties.Resources.Forward, + Location = new Point(44, 24), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Button", + DisplayName = "B", + Location = new Point(132, 24), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Button 1", + DisplayName = "B1", + Location = new Point(68, 36), + Type = PadSchema.PadInputType.Boolean + }, + new PadSchema.ButtonSchema + { + Name = $"P{controller} Button 2", + DisplayName = "B2", + Location = new Point(100, 36), + Type = PadSchema.PadInputType.Boolean + } + } + }; + } + private static PadSchema DrivingController(int controller) { return new PadSchema { - DisplayName = "Player " + controller, + DisplayName = $"Player {controller}", IsConsole = false, DefaultSize = new Size(334, 94), MaxSize = new Size(334, 94), @@ -157,14 +226,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 +243,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 eeaf72f352..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 + " Button", + 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..11adfdccb6 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(); @@ -927,23 +927,31 @@ namespace BizHawk.Client.EmuHawk Message = "Enter a hexadecimal value" }; - var result = prompt.ShowHawkDialog(); - - if (result == DialogResult.OK) + while (prompt.ShowHawkDialog() == DialogResult.OK) { - if (prompt.PromptText.IsHex()) + try { var addr = int.Parse(prompt.PromptText, NumberStyles.HexNumber); - for (int index = 0; index < _searches.Count; index++) { - if (addr == _searches[index].Address) + if (_searches[index].Address == addr) { WatchListView.SelectItem(index, true); WatchListView.ensureVisible(); - break; + return; // Don't re-show dialog on success } } + //TODO add error text to dialog? + // Re-show dialog if the address isn't found + } + catch (FormatException e) + { + // Re-show dialog if given invalid text (shouldn't happen) + } + catch (OverflowException e) + { + //TODO add error text to dialog? + // Re-show dialog if the address isn't valid } } } @@ -1015,7 +1023,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 +1032,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 +1050,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 +1115,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 +1254,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 +1267,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 876c145ad2..57821a4430 100644 --- a/BizHawk.Common/BizHawk.Common.csproj +++ b/BizHawk.Common/BizHawk.Common.csproj @@ -83,8 +83,9 @@ + - + 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 842eedb9b5..e71a78fbef 100644 --- a/BizHawk.Common/BizInvoke/DynamicLibraryImportResolver.cs +++ b/BizHawk.Common/BizInvoke/DynamicLibraryImportResolver.cs @@ -8,12 +8,12 @@ namespace BizHawk.Common.BizInvoke public class DynamicLibraryImportResolver : IImportResolver, IDisposable { private IntPtr _p; - private readonly PlatformLinkedLibSingleton.PlatformLinkedLibManager libLoader = PlatformLinkedLibSingleton.LinkedLibManager; + private readonly OSTailoredCode.ILinkedLibManager libLoader = OSTailoredCode.LinkedLibManager; public DynamicLibraryImportResolver(string dllName) { _p = libLoader.LoadPlatformSpecific(dllName); - if (_p == IntPtr.Zero) throw new InvalidOperationException("null pointer returned by LoadPlatformSpecific"); + if (_p == IntPtr.Zero) throw new InvalidOperationException($"null pointer returned by {nameof(libLoader.LoadPlatformSpecific)}"); } public IntPtr Resolve(string entryPoint) diff --git a/BizHawk.Common/BizInvoke/MemoryBlock.cs b/BizHawk.Common/BizInvoke/MemoryBlock.cs index 9c9a147533..7bbdf04f36 100644 --- a/BizHawk.Common/BizInvoke/MemoryBlock.cs +++ b/BizHawk.Common/BizInvoke/MemoryBlock.cs @@ -79,6 +79,9 @@ namespace BizHawk.Common.BizInvoke /// public MemoryBlock(ulong start, ulong size) { + if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows) + throw new InvalidOperationException("MemoryBlock ctor called on Unix"); + if (!WaterboxUtils.Aligned(start)) throw new ArgumentOutOfRangeException(); if (size == 0) @@ -89,7 +92,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 +109,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 +123,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 +178,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 +200,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 +235,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 +264,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 +305,7 @@ namespace BizHawk.Common.BizInvoke private void EnsureNotDisposed() { if (_owner.Start == 0) - throw new ObjectDisposedException("MemoryBlock"); + throw new ObjectDisposedException(nameof(MemoryBlock)); } private MemoryBlock _owner; 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..cd0ee12369 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) @@ -130,5 +130,7 @@ namespace BizHawk.Common.NumberExtensions return val; } + + public static int RoundToInt(this float f) => (int) Math.Round(f); } } 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/MutableIntRange.cs b/BizHawk.Common/MutableIntRange.cs new file mode 100644 index 0000000000..8309e6ffd0 --- /dev/null +++ b/BizHawk.Common/MutableIntRange.cs @@ -0,0 +1,55 @@ +using System; + +namespace BizHawk.Common +{ + public class MutableIntRange + { + private int _min; + private int _max; + + public int Min + { + get + { + return _min; + } + set + { + if (_max < value) throw new ArgumentException(); + _min = value; + } + } + + public int Max + { + get + { + return _max; + } + set + { + if (value < _min) throw new ArgumentException(); + _max = value; + } + } + + public MutableIntRange(int min, int max) + { + _min = min; + Max = max; // setter may throw ArgumentException + } + + public int Constrain(int i) => i < _min ? _min : i > _max ? _max : i; + + /// true if i is in the inclusive range .., false otherwise + public bool Covers(int i) => _min <= i && i <= _max; + + public uint GetCount() => (uint) ((long) _max - _min + 1); + + /// true if i is in the exclusive range .., false otherwise + /// + /// You probably want + /// + public bool StrictContains(int i) => _min < i && i < _max; + } +} \ No newline at end of file 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/OSTailoredCode.cs similarity index 59% rename from BizHawk.Common/PlatformLinkedLibSingleton.cs rename to BizHawk.Common/OSTailoredCode.cs index 14ed9c29e6..fa7c882556 100644 --- a/BizHawk.Common/PlatformLinkedLibSingleton.cs +++ b/BizHawk.Common/OSTailoredCode.cs @@ -1,44 +1,73 @@ 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 +using System.Diagnostics; +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 sealed class OSTailoredCode { - public static readonly bool RunningOnUnix = Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX; + /// macOS doesn't use PlatformID.MacOSX + public static readonly DistinctOS CurrentOS = Environment.OSVersion.Platform == PlatformID.Unix + ? currentIsMacOS() ? DistinctOS.macOS : DistinctOS.Linux + : DistinctOS.Windows; - private static readonly Lazy lazy = new Lazy(() => RunningOnUnix - ? (PlatformLinkedLibManager) new UnixMonoLinkedLibManager() - : (PlatformLinkedLibManager) new Win32LinkedLibManager()); + private static readonly Lazy lazy = new Lazy(() => + { + switch (CurrentOS) + { + case DistinctOS.Linux: + case DistinctOS.macOS: + return new UnixMonoLLManager(); + case DistinctOS.Windows: + return new WindowsLLManager(); + default: + throw new ArgumentOutOfRangeException(); + } + }); - public static PlatformLinkedLibManager LinkedLibManager { get { return lazy.Value; } } + public static ILinkedLibManager LinkedLibManager => lazy.Value; - private PlatformLinkedLibSingleton() {} + private static bool currentIsMacOS() + { + var proc = new Process { + StartInfo = new ProcessStartInfo { + Arguments = "-s", + CreateNoWindow = true, + FileName = "uname", + RedirectStandardOutput = true, + UseShellExecute = false + } + }; + proc.Start(); + if (proc.StandardOutput.EndOfStream) throw new Exception("Can't determine OS (uname wrote nothing to stdout)!"); + return proc.StandardOutput.ReadLine() == "Darwin"; + } - public interface PlatformLinkedLibManager + private OSTailoredCode() {} + + public interface ILinkedLibManager { 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. + private class UnixMonoLLManager : ILinkedLibManager { - // This class is copied from a tutorial, so don't git blame and then email me expecting insight. - const int RTLD_NOW = 2; + private const int RTLD_NOW = 2; [DllImport("libdl.so.2")] - private static extern IntPtr dlopen(String fileName, int flags); + 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); + 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) @@ -59,10 +88,10 @@ public sealed class PlatformLinkedLibSingleton } } - public class Win32LinkedLibManager : PlatformLinkedLibManager + private class WindowsLLManager : ILinkedLibManager { [DllImport("kernel32.dll")] - private static extern UInt32 GetLastError(); + private static extern uint 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")] @@ -89,5 +118,12 @@ public sealed class PlatformLinkedLibSingleton return FreeLibrary(hModule) ? 1 : 0; } } + + public enum DistinctOS : byte + { + Linux, + macOS, + Windows + } } -} +} \ No newline at end of file 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..ae0a3df4c0 100644 --- a/BizHawk.Common/Serializer.cs +++ b/BizHawk.Common/Serializer.cs @@ -440,6 +440,90 @@ namespace BizHawk.Common } } + public void Sync(string name, ref float[] val, bool useNull) + { + if (IsText) + { + SyncText(name, ref val, useNull); + } + else if (IsReader) + { + val = Util.ByteBufferToFloatBuffer(Util.ReadByteBuffer(_br, false)); + if (val == null && !useNull) + { + val = new float[0]; + } + } + else + { + Util.WriteByteBuffer(_bw, Util.FloatBufferToByteBuffer(val)); + } + } + + public void SyncText(string name, ref float[] val, bool useNull) + { + if (IsReader) + { + if (Present(name)) + { + var bytes = Util.HexStringToBytes(Item(name)); + val = Util.ByteBufferToFloatBuffer(bytes); + } + + if (val != null && val.Length == 0 && useNull) + { + val = null; + } + } + else + { + var temp = val ?? new float[0]; + _tw.WriteLine("{0} {1}", name, Util.FloatBufferToByteBuffer(temp).BytesToHexString()); + } + } + + public void Sync(string name, ref double[] val, bool useNull) + { + if (IsText) + { + SyncText(name, ref val, useNull); + } + else if (IsReader) + { + val = Util.ByteBufferToDoubleBuffer(Util.ReadByteBuffer(_br, false)); + if (val == null && !useNull) + { + val = new double[0]; + } + } + else + { + Util.WriteByteBuffer(_bw, Util.DoubleBufferToByteBuffer(val)); + } + } + + public void SyncText(string name, ref double[] val, bool useNull) + { + if (IsReader) + { + if (Present(name)) + { + var bytes = Util.HexStringToBytes(Item(name)); + val = Util.ByteBufferToDoubleBuffer(bytes); + } + + if (val != null && val.Length == 0 && useNull) + { + val = null; + } + } + else + { + var temp = val ?? new double[0]; + _tw.WriteLine("{0} {1}", name, Util.DoubleBufferToByteBuffer(temp).BytesToHexString()); + } + } + public void Sync(string name, ref Bit val) { if (IsText) @@ -612,6 +696,22 @@ namespace BizHawk.Common } } + public void Sync(string name, ref double val) + { + if (IsText) + { + SyncText(name, ref val); + } + else if (IsReader) + { + Read(ref val); + } + else + { + Write(ref val); + } + } + public void Sync(string name, ref bool val) { if (IsText) @@ -658,7 +758,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 +840,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 +863,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!"); } } } @@ -907,6 +1007,18 @@ namespace BizHawk.Common } } + private void SyncText(string name, ref double val) + { + if (IsReader) + { + ReadText(name, ref val); + } + else + { + WriteText(name, ref val); + } + } + private void SyncText(string name, ref bool val) { if (IsReader) @@ -1135,6 +1247,16 @@ namespace BizHawk.Common _bw.Write(val); } + private void Read(ref double val) + { + val = _br.ReadDouble(); + } + + private void Write(ref double val) + { + _bw.Write(val); + } + private void ReadText(string name, ref float val) { if (Present(name)) @@ -1148,6 +1270,19 @@ namespace BizHawk.Common _tw.WriteLine("{0} {1}", name, val); } + private void ReadText(string name, ref double val) + { + if (Present(name)) + { + val = double.Parse(Item(name)); + } + } + + private void WriteText(string name, ref double val) + { + _tw.WriteLine("{0} {1}", name, val); + } + private void Read(ref bool val) { val = _br.ReadBoolean(); 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..88d5b628cc 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); } @@ -59,10 +59,8 @@ namespace BizHawk.Common } } - #if WINDOWS [DllImport("kernel32.dll", EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] static extern bool DeleteFileW([MarshalAs(UnmanagedType.LPWStr)]string lpFileName); - #endif static void ThreadProc() { @@ -94,12 +92,10 @@ namespace BizHawk.Common { try { - // SHUT. UP. THE. EXCEPTIONS. - #if WINDOWS - DeleteFileW(fi.FullName); - #else - fi.Delete(); - #endif + if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) + DeleteFileW(fi.FullName); // SHUT. UP. THE. EXCEPTIONS. + else + fi.Delete(); } catch { diff --git a/BizHawk.Common/Util.cs b/BizHawk.Common/Util.cs index 9869e60e93..17c8a90722 100644 --- a/BizHawk.Common/Util.cs +++ b/BizHawk.Common/Util.cs @@ -299,6 +299,38 @@ namespace BizHawk.Common return ret; } + public static float[] ByteBufferToFloatBuffer(byte[] buf) + { + int num = buf.Length / sizeof(float); + var ret = new float[num]; + Buffer.BlockCopy(buf, 0, ret, 0, num); + return ret; + } + + public static byte[] FloatBufferToByteBuffer(float[] buf) + { + int num = buf.Length; + var ret = new byte[num * sizeof(float)]; + Buffer.BlockCopy(buf, 0, ret, 0, ret.Length); + return ret; + } + + public static double[] ByteBufferToDoubleBuffer(byte[] buf) + { + int num = buf.Length; + var ret = new double[num / sizeof(double)]; + Buffer.BlockCopy(buf, 0, ret, 0, num); + return ret; + } + + public static byte[] DoubleBufferToByteBuffer(double[] buf) + { + int num = buf.Length; + var ret = new byte[num * sizeof(double)]; + Buffer.BlockCopy(buf, 0, ret, 0, ret.Length); + return ret; + } + public static byte[] ReadByteBuffer(BinaryReader br, bool returnNull) { int len = br.ReadInt32(); @@ -389,7 +421,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 +542,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 +553,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 da0d6dd1fc..97cb1f1e7d 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/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/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/Database/FirmwareDatabase.cs b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs index 32ba4651e5..713ad82bb6 100644 --- a/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs +++ b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs @@ -30,6 +30,7 @@ namespace BizHawk.Emulation.Common FirmwareAndOption("5A140136A16D1D83E4FF32A19409CA376A8DF874", 16384, "A78", "Bios_PAL", "7800PALBIOS.bin", "PAL Bios"); FirmwareAndOption("A3AF676991391A6DD716C79022D4947206B78164", 4096, "A78", "Bios_HSC", "7800highscore.bin", "Highscore Bios"); FirmwareAndOption("45BEDC4CBDEAC66C7DF59E9E599195C778D86A92", 8192, "Coleco", "Bios", "ColecoBios.bin", "Bios"); + FirmwareAndOption("B9BBF5BB0EAC52D039A4A993A2D8064B862C9E28", 4096, "Vectrex", "Bios", "VectrexBios.bin", "Bios"); var gbaNormal = File("300C20DF6731A33952DED8C436F7F186D25D3492", 16384, "gbabios.rom", "Bios (World)"); var gbaJDebug = File("AA98A2AD32B86106340665D1222D7D973A1361C7", 16384, "gbabios.rom", "Bios (J Debug)"); @@ -60,6 +61,10 @@ namespace BizHawk.Emulation.Common FirmwareAndOption("A584272F21DC82C14B7D4F1ED440E23A976E71F0", 32768, "ZXSpectrum", "PentagonROM", "pentagon.rom", "Russian Pentagon Clone ROM"); FirmwareAndOption("282EB7BC819AAD2A12FD954E76F7838A4E1A7929", 16384, "ZXSpectrum", "TRDOSROM", "trdos.rom", "TRDOS ROM"); + // Channel F + FirmwareAndOption("81193965A374D77B99B4743D317824B53C3E3C78", 1024, "ChannelF", "ChannelF_sl131253", "ChannelF-SL31253.rom", "Channel F Rom0"); + FirmwareAndOption("8F70D1B74483BA3A37E86CF16C849D601A8C3D2C", 1024, "ChannelF", "ChannelF_sl131254", "ChannelF-SL31254.rom", "Channel F Rom1"); + // for saturn, we think any bios region can pretty much run any iso // so, we're going to lay this out carefully so that we choose things in a sensible order, but prefer the correct region var ss_100_j = File("2B8CB4F87580683EB4D760E4ED210813D667F0A2", 524288, "saturn-1.00-(J).bin", "Bios v1.00 (J)"); 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/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/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/SystemLookup.cs b/BizHawk.Emulation.Common/SystemLookup.cs index 0e4cc90d06..88f7fe8e6c 100644 --- a/BizHawk.Emulation.Common/SystemLookup.cs +++ b/BizHawk.Emulation.Common/SystemLookup.cs @@ -34,7 +34,8 @@ namespace BizHawk.Emulation.Common new SystemInfo { SystemId = "AppleII", FullName = "Apple II" }, new SystemInfo { SystemId = "INTV", FullName = "Intellivision" }, new SystemInfo { SystemId = "ZXSpectrum", FullName = "Sinclair ZX Spectrum" }, - new SystemInfo { SystemId = "AmstradCPC", FullName = "Amstrad CPC" } + new SystemInfo { SystemId = "AmstradCPC", FullName = "Amstrad CPC" }, + new SystemInfo { SystemId = "ChannelF", FullName = "Fairchild Channel F"}, }; public SystemInfo this[string systemId] diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index f6bf415a2a..ef1d8c3a49 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -319,7 +319,6 @@ - @@ -371,7 +370,6 @@ - @@ -597,6 +595,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + VectrexHawk.cs + + + VectrexHawk.cs + + + VectrexHawk.cs + + + VectrexHawk.cs + + + VectrexHawk.cs + + + VectrexHawk.cs + + + VectrexHawk.cs + + + + + + + + + ColecoVision.cs @@ -1336,6 +1386,31 @@ + + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GGHawkLink.cs + + + GPGX.cs @@ -1412,9 +1487,6 @@ SMS.cs - - SMS.cs - SMS.cs @@ -1471,6 +1543,14 @@ + + + + + + + + @@ -1520,6 +1600,9 @@ + + + @@ -1551,7 +1634,6 @@ - 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 a8f7d659f3..fd4ccf623d 100644 --- a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs +++ b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs @@ -60,21 +60,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 3d6904c695..406e3730d7 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 063b41ee5c..a4e26f5a7c 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs @@ -591,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/MC6809/Disassembler.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/Disassembler.cs new file mode 100644 index 0000000000..94cf5b9ece --- /dev/null +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/Disassembler.cs @@ -0,0 +1,1033 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BizHawk.Emulation.Common.Components.MC6809 +{ + public sealed partial class MC6809 + { + static string[] table = + { + "NEG DP+i8", // 00 + "???", // 01 + "???", // 02 + "COM DP+i8", // 03 + "LSR DP+i8", // 04 + "???", // 05 + "ROR DP+i8", // 06 + "ASR DP+i8", // 07 + "ASL DP+i8", // 08 + "ROL DP+i8", // 09 + "DEC DP+i8", // 0a + "???", // 0b + "INC DP+i8", // 0c + "TST DP+i8", // 0d + "JMP DP+i8", // 0e + "CLR DP+i8", // 0f + "PAGE 2", // 10 + "PAGE 3", // 11 + "NOP", // 12 + "SYNC", // 13 + "???", // 14 + "???", // 15 + "LBRA i16", // 16 + "LBSR i16", // 17 + "???", // 18 + "DAA", // 19 + "ORCC i8", // 1a + "???", // 1b + "ANDCC i8", // 1c + "SEX", // 1d + "EXG i8", // 1e + "TFR i8", // 1f + "BRA i8", // 20 + "BRN i8", // 21 + "BHI i8", // 22 + "BLS i8", // 23 + "BHS i8", // 24 + "BLO i8", // 25 + "BNE i8", // 26 + "BEQ i8", // 27 + "BVC i8", // 28 + "BVS i8", // 29 + "BPL i8", // 2a + "BMI i8", // 2b + "BGE i8", // 2c + "BLT i8", // 2d + "BGT i8", // 2e + "BLE i8", // 2f + "LEAX ix16", // 30 + "LEAY ix16", // 31 + "LEAS ix16", // 32 + "LEAU ix16", // 33 + "PSHS i8", // 34 + "PULS i8", // 35 + "PSHU i8", // 36 + "PULU i8", // 37 + "???", // 38 + "RTS", // 39 + "ABX", // 3a + "RTI", // 3b + "CWAI", // 3c + "MUL", // 3d + "???", // 3e + "SWI1", // 3f + "NEG A", // 40 + "???", // 41 + "???", // 42 + "COM A", // 43 + "LSR A", // 44 + "???", // 45 + "ROR A", // 46 + "ASR A", // 47 + "ASL A", // 48 + "ROL A", // 49 + "DEC A", // 4a + "???", // 4b + "INC A", // 4c + "TST A", // 4d + "???", // 4e + "CLR A", // 4f + "NEG B", // 50 + "???", // 51 + "???", // 52 + "COM B", // 53 + "LSR B", // 54 + "???", // 55 + "ROR B", // 56 + "ASR B", // 57 + "ASL B", // 58 + "ROL B", // 59 + "DEC B", // 5a + "???", // 5b + "INC B", // 5c + "TST B", // 5d + "???", // 5e + "CLR B", // 5f + "NEG ix16", // 60 + "???", // 61 + "???", // 62 + "COM ix16", // 63 + "LSR ix16", // 64 + "???", // 65 + "ROR ix16", // 66 + "ASR ix16", // 67 + "ASL ix16", // 68 + "ROL ix16", // 69 + "DEC ix16", // 6a + "???", // 6b + "INC ix16", // 6c + "TST ix16", // 6d + "JMP ix16", // 6e + "CLR ix16", // 6f + "NEG ex16", // 70 + "???", // 71 + "???", // 72 + "COM ex16", // 73 + "LSR ex16", // 74 + "???", // 75 + "ROR ex16", // 76 + "ASR ex16", // 77 + "ASL ex16", // 78 + "ROL ex16", // 79 + "DEC ex16", // 7a + "???", // 7b + "INC ex16", // 7c + "TST ex16", // 7d + "JMP ex16", // 7e + "CLR ex16", // 7f + "SUB A,i8", // 80 + "CMP A,i8", // 81 + "SBC A,i8", // 82 + "SUB D,i16", // 83 + "AND A,i8", // 84 + "BIT A,i8", // 85 + "LD A,i8", // 86 + "???", // 87 + "EOR A,i8", // 88 + "ADC A,i8", // 89 + "OR A,i8", // 8a + "ADD A,i8", // 8b + "CMP X,i16", // 8c + "BSR i8", // 8d + "LD X,i16", // 8e + "???", // 8f + "SUB A,DP+i8", // 90 + "CMP A,DP+i8", // 91 + "SBC A,DP+i8", // 92 + "SUB D,DP+i8", // 93 + "AND A,DP+i8", // 94 + "BIT A,DP+i8", // 95 + "LD A,DP+i8", // 96 + "ST A,DP+i8", // 97 + "EOR A,DP+i8", // 98 + "ADC A,DP+i8", // 99 + "OR A,DP+i8", // 9a + "ADD A,DP+i8", // 9b + "CMP X,DP+i8", // 9c + "JSR DP+i8", // 9d + "LD X,ix16", // 9e + "ST X,ix16", // 9f + "SUB A,ix16", // a0 + "CMP A,ix16", // a1 + "SBC A,ix16", // a2 + "SUB D,ix16", // a3 + "AND A,ix16", // a4 + "BIT A,ix16", // a5 + "LD A,ix16", // a6 + "ST A,ix16", // a7 + "EOR A,ix16", // a8 + "ADC A,ix16", // a9 + "OR A,ix16", // aa + "ADD A,ix16", // ab + "CMP X,ix16", // ac + "JSR ix16", // ad + "LD X,ex16", // ae + "ST X,ex16", // af + "SUB A,ex16", // b0 + "CMP A,ex16", // b1 + "SBC A,ex16", // b2 + "SUB D,ex16", // b3 + "AND A,ex16", // b4 + "BIT A,ex16", // b5 + "LD A,ex16", // b6 + "ST A,ex16", // b7 + "EOR A,ex16", // b8 + "ADC A,ex16", // b9 + "OR A,ex16", // ba + "ADD A,ex16", // bb + "CMP X,ex16", // bc + "JSR ex16", // bd + "LD X,ex16", // be + "ST X,ex16", // bf + "SUB B,i8", // c0 + "CMP B,i8", // c1 + "SBC B,i8", // c2 + "ADD D,i16", // c3 + "AND B,i8", // c4 + "BIT B,i8", // c5 + "LD B,i8", // c6 + "???", // c7 + "EOR B,i8", // c8 + "ADC B,i8", // c9 + "OR B,i8", // ca + "ADD B,i8", // cb + "LD D,i16", // cc + "???", // cd + "LD U,i16", // ce + "???", // cf + "SUB B,DP+i8", // d0 + "CMP B,DP+i8", // d1 + "SBC B,DP+i8", // d2 + "ADD D,DP+i8", // d3 + "AND B,DP+i8", // d4 + "BIT B,DP+i8", // d5 + "LD B,DP+i8", // d6 + "ST B,DP+i8", // d7 + "EOR B,DP+i8", // d8 + "ADC B,DP+i8", // d9 + "OR B,DP+i8", // da + "ADD B,DP+i8", // db + "LD D,DP+i8", // dc + "ST D,DP+i8", // dd + "LD U,DP+i8", // de + "ST U,DP+i8", // df + "SUB B,ix16", // e0 + "CMP B,ix16", // e1 + "SBC B,ix16", // e2 + "ADD D,ix16", // e3 + "AND B,ix16", // e4 + "BIT B,ix16", // e5 + "LD B,ix16", // e6 + "ST B,ix16", // e7 + "EOR B,ix16", // e8 + "ADC B,ix16", // e9 + "OR B,ix16", // ea + "ADD B,ix16", // eb + "LD D,ix16", // ec + "ST D,ix16", // ed + "LD U,ix16", // ee + "ST U,ix16", // ef + "SUB B,ex16", // f0 + "CMP B,ex16", // f1 + "SBC B,ex16", // f2 + "ADD D,ex16", // f3 + "AND B,ex16", // f4 + "BIT B,ex16", // f5 + "LD B,ex16", // f6 + "ST B,ex16", // f7 + "EOR B,ex16", // f8 + "ADC B,ex16", // f9 + "OR B,ex16", // fa + "ADD B,ex16", // fb + "LD D,ex16", // fc + "ST D,ex16", // fd + "LD U,ex16", // fe + "ST U,ex16", // ff + }; + + static string[] table2 = + { + "???", // 00 + "???", // 01 + "???", // 02 + "???", // 03 + "???", // 04 + "???", // 05 + "???", // 06 + "???", // 07 + "???", // 08 + "???", // 09 + "???", // 0a + "???", // 0b + "???", // 0c + "???", // 0d + "???", // 0e + "???", // 0f + "???", // 10 + "???", // 11 + "???", // 12 + "???", // 13 + "???", // 14 + "???", // 15 + "???", // 16 + "???", // 17 + "???", // 18 + "???", // 19 + "???", // 1a + "???", // 1b + "???", // 1c + "???", // 1d + "???", // 1e + "???", // 1f + "???", // 20 + "LBRN i16", // 21 + "LBHI i16", // 22 + "LBLS i16", // 23 + "LBHS i16", // 24 + "LBLO i16", // 25 + "LBNE i16", // 26 + "LBEQ i16", // 27 + "LBVC i16", // 28 + "LBVS i16", // 29 + "LBPL i16", // 2a + "LBMI i16", // 2b + "LBGE i16", // 2c + "LBLT i16", // 2d + "LBGT i16", // 2e + "LBLE i16", // 2f + "???", // 30 + "???", // 31 + "???", // 32 + "???", // 33 + "???", // 34 + "???", // 35 + "???", // 36 + "???", // 37 + "???", // 38 + "???", // 39 + "???", // 3a + "???", // 3b + "???", // 3c + "???", // 3d + "???", // 3e + "SWI2", // 3f + "???", // 40 + "???", // 41 + "???", // 42 + "???", // 43 + "???", // 44 + "???", // 45 + "???", // 46 + "???", // 47 + "???", // 48 + "???", // 49 + "???", // 4a + "???", // 4b + "???", // 4c + "???", // 4d + "???", // 4e + "???", // 4f + "???", // 50 + "???", // 51 + "???", // 52 + "???", // 53 + "???", // 54 + "???", // 55 + "???", // 56 + "???", // 57 + "???", // 58 + "???", // 59 + "???", // 5a + "???", // 5b + "???", // 5c + "???", // 5d + "???", // 5e + "???", // 5f + "???", // 60 + "???", // 61 + "???", // 62 + "???", // 63 + "???", // 64 + "???", // 65 + "???", // 66 + "???", // 67 + "???", // 68 + "???", // 69 + "???", // 6a + "???", // 6b + "???", // 6c + "???", // 6d + "???", // 6e + "???", // 6f + "???", // 70 + "???", // 71 + "???", // 72 + "???", // 73 + "???", // 74 + "???", // 75 + "???", // 76 + "???", // 77 + "???", // 78 + "???", // 79 + "???", // 7a + "???", // 7b + "???", // 7c + "???", // 7d + "???", // 7e + "???", // 7f + "???", // 80 + "???", // 81 + "???", // 82 + "CMP D,(i16)", // 83 + "???", // 84 + "???", // 85 + "???", // 86 + "???", // 87 + "???", // 88 + "???", // 89 + "???", // 8a + "???", // 8b + "CMP Y,(i16)", // 8c + "???", // 8d + "LD Y,(i16)", // 8e + "???", // 8f + "???", // 90 + "???", // 91 + "???", // 92 + "CMP D,(DP+i8)", // 93 + "???", // 94 + "???", // 95 + "???", // 96 + "???", // 97 + "???", // 98 + "???", // 99 + "???", // 9a + "???", // 9b + "CMP Y,(DP+i8)", // 9c + "???", // 9d + "LD Y,(DP+i8)", // 9e + "ST Y,(DP+i8)", // 9f + "???", // a0 + "???", // a1 + "???", // a2 + "CMP D,ix16", // a3 + "???", // a4 + "???", // a5 + "???", // a6 + "???", // a7 + "???", // a8 + "???", // a9 + "???", // aa + "???", // ab + "CMP Y,ix16", // ac + "???", // ad + "LD Y,ix16", // ae + "ST Y,ix16", // af + "???", // b0 + "???", // b1 + "???", // b2 + "CMP D,ex16", // b3 + "???", // b4 + "???", // b5 + "???", // b6 + "???", // b7 + "???", // b8 + "???", // b9 + "???", // ba + "???", // bb + "CMP Y,ex16", // bc + "???", // bd + "LD Y,ex16", // be + "ST Y,ex16", // bf + "???", // c0 + "???", // c1 + "???", // c2 + "???", // c3 + "???", // c4 + "???", // c5 + "???", // c6 + "???", // c7 + "???", // c8 + "???", // c9 + "???", // ca + "???", // cb + "???", // cc + "???", // cd + "LD SP,i16", // ce + "???", // cf + "???", // d0 + "???", // d1 + "???", // d2 + "???", // d3 + "???", // d4 + "???", // d5 + "???", // d6 + "???", // d7 + "???", // d8 + "???", // d9 + "???", // da + "???", // db + "???", // dc + "???", // dd + "LD SP,DP+i8", // de + "ST SP,DP+i8", // df + "???", // e0 + "???", // e1 + "???", // e2 + "???", // e3 + "???", // e4 + "???", // e5 + "???", // e6 + "???", // e7 + "???", // e8 + "???", // e9 + "???", // ea + "???", // eb + "???", // ec + "???", // ed + "LD SP,ix16", // ee + "ST SP,ix16", // ef + "???", // f0 + "???", // f1 + "???", // f2 + "???", // f3 + "???", // f4 + "???", // f5 + "???", // f6 + "???", // f7 + "???", // f8 + "???", // f9 + "???", // fa + "???", // fb + "???", // fc + "???", // fd + "LD SP,ex16", // fe + "ST SP,ex16", // ff + }; + + static string[] table3 = + { + "???", // 00 + "???", // 01 + "???", // 02 + "???", // 03 + "???", // 04 + "???", // 05 + "???", // 06 + "???", // 07 + "???", // 08 + "???", // 09 + "???", // 0a + "???", // 0b + "???", // 0c + "???", // 0d + "???", // 0e + "???", // 0f + "???", // 10 + "???", // 11 + "???", // 12 + "???", // 13 + "???", // 14 + "???", // 15 + "???", // 16 + "???", // 17 + "???", // 18 + "???", // 19 + "???", // 1a + "???", // 1b + "???", // 1c + "???", // 1d + "???", // 1e + "???", // 1f + "???", // 20 + "???", // 21 + "???", // 22 + "???", // 23 + "???", // 24 + "???", // 25 + "???", // 26 + "???", // 27 + "???", // 28 + "???", // 29 + "???", // 2a + "???", // 2b + "???", // 2c + "???", // 2d + "???", // 2e + "???", // 2f + "???", // 30 + "???", // 31 + "???", // 32 + "???", // 33 + "???", // 34 + "???", // 35 + "???", // 36 + "???", // 37 + "???", // 38 + "???", // 39 + "???", // 3a + "???", // 3b + "???", // 3c + "???", // 3d + "???", // 3e + "SWI3", // 3f + "???", // 40 + "???", // 41 + "???", // 42 + "???", // 43 + "???", // 44 + "???", // 45 + "???", // 46 + "???", // 47 + "???", // 48 + "???", // 49 + "???", // 4a + "???", // 4b + "???", // 4c + "???", // 4d + "???", // 4e + "???", // 4f + "???", // 50 + "???", // 51 + "???", // 52 + "???", // 53 + "???", // 54 + "???", // 55 + "???", // 56 + "???", // 57 + "???", // 58 + "???", // 59 + "???", // 5a + "???", // 5b + "???", // 5c + "???", // 5d + "???", // 5e + "???", // 5f + "???", // 60 + "???", // 61 + "???", // 62 + "???", // 63 + "???", // 64 + "???", // 65 + "???", // 66 + "???", // 67 + "???", // 68 + "???", // 69 + "???", // 6a + "???", // 6b + "???", // 6c + "???", // 6d + "???", // 6e + "???", // 6f + "???", // 70 + "???", // 71 + "???", // 72 + "???", // 73 + "???", // 74 + "???", // 75 + "???", // 76 + "???", // 77 + "???", // 78 + "???", // 79 + "???", // 7a + "???", // 7b + "???", // 7c + "???", // 7d + "???", // 7e + "???", // 7f + "???", // 80 + "???", // 81 + "???", // 82 + "CMP US,(i16)", // 83 + "???", // 84 + "???", // 85 + "???", // 86 + "???", // 87 + "???", // 88 + "???", // 89 + "???", // 8a + "???", // 8b + "CMP SP,(i16)", // 8c + "???", // 8d + "???", // 8e + "???", // 8f + "???", // 90 + "???", // 91 + "???", // 92 + "CMP US,(DP+i8)", // 93 + "???", // 94 + "???", // 95 + "???", // 96 + "???", // 97 + "???", // 98 + "???", // 99 + "???", // 9a + "???", // 9b + "CMP SP,(DP+i8)", // 9c + "???", // 9d + "???", // 9e + "???", // 9f + "???", // a0 + "???", // a1 + "???", // a2 + "CMP US,ix16", // a3 + "???", // a4 + "???", // a5 + "???", // a6 + "???", // a7 + "???", // a8 + "???", // a9 + "???", // aa + "???", // ab + "CMP SP,ix16", // ac + "???", // ad + "???", // ae + "???", // af + "???", // b0 + "???", // b1 + "???", // b2 + "CMP US,ex16", // b3 + "???", // b4 + "???", // b5 + "???", // b6 + "???", // b7 + "???", // b8 + "???", // b9 + "???", // ba + "???", // bb + "CMP SP,ex16", // bc + "???", // bd + "???", // be + "???", // bf + "???", // c0 + "???", // c1 + "???", // c2 + "???", // c3 + "???", // c4 + "???", // c5 + "???", // c6 + "???", // c7 + "???", // c8 + "???", // c9 + "???", // ca + "???", // cb + "???", // cc + "???", // cd + "???", // ce + "???", // cf + "???", // d0 + "???", // d1 + "???", // d2 + "???", // d3 + "???", // d4 + "???", // d5 + "???", // d6 + "???", // d7 + "???", // d8 + "???", // d9 + "???", // da + "???", // db + "???", // dc + "???", // dd + "???", // de + "???", // df + "???", // e0 + "???", // e1 + "???", // e2 + "???", // e3 + "???", // e4 + "???", // e5 + "???", // e6 + "???", // e7 + "???", // e8 + "???", // e9 + "???", // ea + "???", // eb + "???", // ec + "???", // ed + "???", // ee + "???", // ef + "???", // f0 + "???", // f1 + "???", // f2 + "???", // f3 + "???", // f4 + "???", // f5 + "???", // f6 + "???", // f7 + "???", // f8 + "???", // f9 + "???", // fa + "???", // fb + "???", // fc + "???", // fd + "???", // fe + "???", // ff + }; + + public static string Disassemble(ushort addr, Func reader, out ushort size) + { + ushort origaddr = addr; + List bytes = new List(); + bytes.Add(reader(addr++)); + + string result = table[bytes[0]]; + if (bytes[0] == 0x10) + { + bytes.Add(reader(addr++)); + result = table2[bytes[1]]; + } + + if (bytes[0] == 0x11) + { + bytes.Add(reader(addr++)); + result = table3[bytes[1]]; + } + + if (result.Contains("i8")) + { + byte d = reader(addr++); + bytes.Add(d); + result = result.Replace("i8", string.Format("#{0:X2}h", d)); + } + else if (result.Contains("i16")) + { + byte dhi = reader(addr++); + byte dlo = reader(addr++); + bytes.Add(dhi); + bytes.Add(dlo); + result = result.Replace("i16", string.Format("#{0:X2}{1:X2}h", dhi, dlo)); + } + else if (result.Contains("ex16")) + { + byte dhi = reader(addr++); + byte dlo = reader(addr++); + bytes.Add(dhi); + bytes.Add(dlo); + result = result.Replace("ex16", "(" + string.Format("#{0:X2}{1:X2}h", dhi, dlo) + ")"); + } + else if (result.Contains("ix16")) + { + byte d = reader(addr++); + bytes.Add(d); + + string temp_reg = ""; + + switch ((d >> 5) & 3) + { + case 0: temp_reg = "X"; break; + case 1: temp_reg = "Y"; break; + case 2: temp_reg = "US"; break; + case 3: temp_reg = "SP"; break; + } + + if ((d & 0x80) == 0) + { + short tempdis = (short)(d & 0x1F); + if (tempdis >= 16) + tempdis -= 32; + + result = result.Replace("ix16", temp_reg + " + ea"); + result = result.Replace("ea", string.Format("{0:N}h", tempdis)); + } + else + { + if ((d & 0x10) == 0x10) + { + switch (d & 0xF) + { + case 0x0: + result = result.Replace("ix16", "???"); + break; + case 0x1: + result = result.Replace("ix16","(" + temp_reg + ")++"); + break; + case 0x2: + result = result.Replace("ix16", "???"); + break; + case 0x3: + result = result.Replace("ix16", "--(" + temp_reg + ")"); + break; + case 0x4: + result = result.Replace("ix16", "(" + temp_reg + ")"); + break; + case 0x5: + result = result.Replace("ix16", "(" + temp_reg + " + B)"); + break; + case 0x6: + result = result.Replace("ix16", "(" + temp_reg + " + A)"); + break; + case 0x7: + result = result.Replace("ix16", "???"); + break; + case 0x8: + byte e = reader(addr++); + bytes.Add(e); + result = result.Replace("ix16", "(" + temp_reg + " + ea)"); + result = result.Replace("ea", string.Format("{0:X2}h", e)); + break; + case 0x9: + byte f = reader(addr++); + bytes.Add(f); + byte g = reader(addr++); + bytes.Add(g); + result = result.Replace("ix16", "(" + temp_reg + " + ea)"); + result = result.Replace("ea", string.Format("{0:X2}{1:X2}h", f, g)); + break; + case 0xA: + result = result.Replace("ix16", "???"); + break; + case 0xB: + result = result.Replace("ix16", "(" + temp_reg + " + D)"); + break; + case 0xC: + temp_reg = "PC"; + byte h = reader(addr++); + bytes.Add(h); + result = result.Replace("ix16", "(" + temp_reg + " + ea)"); + result = result.Replace("ea", string.Format("{0:X2}h", h)); + break; + case 0xD: + temp_reg = "PC"; + byte i = reader(addr++); + bytes.Add(i); + byte j = reader(addr++); + bytes.Add(j); + result = result.Replace("ix16", "(" + temp_reg + " + ea)"); + result = result.Replace("ea", string.Format("{0:X2}{1:X2}h", i, j)); + break; + case 0xE: + result = result.Replace("ix16", "???"); + break; + case 0xF: + if (((d >> 5) & 3) == 0) + { + byte k = reader(addr++); + bytes.Add(k); + byte l = reader(addr++); + bytes.Add(l); + result = result.Replace("ix16", "(" + string.Format("{0:X2}{1:X2}h", k, l) + ")"); + } + else + { + result = result.Replace("ix16", "???"); + } + break; + } + } + else + { + switch (d & 0xF) + { + case 0x0: + result = result.Replace("ix16", temp_reg + "+"); + break; + case 0x1: + result = result.Replace("ix16", temp_reg + "++"); + break; + case 0x2: + result = result.Replace("ix16", "-" + temp_reg); + break; + case 0x3: + result = result.Replace("ix16", "--" + temp_reg); + break; + case 0x4: + result = result.Replace("ix16", temp_reg); + break; + case 0x5: + result = result.Replace("ix16", temp_reg + " + B"); + break; + case 0x6: + result = result.Replace("ix16", temp_reg + " + A"); + break; + case 0x7: + result = result.Replace("ix16", "???"); + break; + case 0x8: + byte e = reader(addr++); + bytes.Add(e); + result = result.Replace("ix16", temp_reg + " + ea"); + result = result.Replace("ea", string.Format("{0:X2}h", e)); + break; + case 0x9: + byte f = reader(addr++); + bytes.Add(f); + byte g = reader(addr++); + bytes.Add(g); + result = result.Replace("ix16", temp_reg + " + ea"); + result = result.Replace("ea", string.Format("{0:X2}{1:X2}h", f, g)); + break; + case 0xA: + result = result.Replace("ix16", "???"); + break; + case 0xB: + result = result.Replace("ix16", temp_reg + " + D"); + break; + case 0xC: + temp_reg = "PC"; + byte h = reader(addr++); + bytes.Add(h); + result = result.Replace("ix16", temp_reg + " + ea"); + result = result.Replace("ea", string.Format("{0:X2}h", h)); + break; + case 0xD: + temp_reg = "PC"; + byte i = reader(addr++); + bytes.Add(i); + byte j = reader(addr++); + bytes.Add(j); + result = result.Replace("ix16", temp_reg + " + ea"); + result = result.Replace("ea", string.Format("{0:X2}{1:X2}h", i, j)); + break; + case 0xE: + result = result.Replace("ix16", "???"); + break; + case 0xF: + result = result.Replace("ix16", "???"); + break; + } + } + } + } + else if (result.Contains("r8")) + { + byte d = reader(addr++); + bytes.Add(d); + int offs = d; + if (offs >= 128) + offs -= 256; + result = result.Replace("r8", string.Format("{0:X4}h", (ushort)(addr + offs))); + } + StringBuilder ret = new StringBuilder(); + ret.Append(string.Format("{0:X4}: ", origaddr)); + foreach (var b in bytes) + ret.Append(string.Format("{0:X2} ", b)); + while (ret.Length < 22) + ret.Append(' '); + ret.Append(result); + size = (ushort)(addr - origaddr); + return ret.ToString(); + } + } +} diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/Execute.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/Execute.cs new file mode 100644 index 0000000000..df96726c14 --- /dev/null +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/Execute.cs @@ -0,0 +1,352 @@ +using System; + +namespace BizHawk.Emulation.Common.Components.MC6809 +{ + public partial class MC6809 + { + public ulong TotalExecutedCycles; + + // variables for executing instructions + public int instr_pntr = 0; + public ushort[] cur_instr = new ushort[60]; + public int opcode_see; + + public int IRQS; + public int irq_pntr; + + ushort reg_d_ad; + ushort reg_h_ad; + ushort reg_l_ad; + + public void FetchInstruction(byte opcode) + { + opcode_see = opcode; + switch (opcode) + { + case 0x00: DIRECT_MEM(NEG); break; // NEG (Direct) + case 0x01: ILLEGAL(); break; // ILLEGAL + case 0x02: ILLEGAL(); break; // ILLEGAL + case 0x03: DIRECT_MEM(COM); break; // COM (Direct) + case 0x04: DIRECT_MEM(LSR); break; // LSR (Direct) + case 0x05: ILLEGAL(); break; // ILLEGAL + case 0x06: DIRECT_MEM(ROR); break; // ROR (Direct) + case 0x07: DIRECT_MEM(ASR); break; // ASR (Direct) + case 0x08: DIRECT_MEM(ASL); break; // ASL , LSL (Direct) + case 0x09: DIRECT_MEM(ROL); break; // ROL (Direct) + case 0x0A: DIRECT_MEM(DEC8); break; // DEC (Direct) + case 0x0B: ILLEGAL(); break; // ILLEGAL + case 0x0C: DIRECT_MEM(INC8); break; // INC (Direct) + case 0x0D: DIRECT_MEM(TST); break; // TST (Direct) + case 0x0E: JMP_DIR_(); break; // JMP (Direct) + case 0x0F: DIRECT_MEM(CLR); break; // CLR (Direct) + case 0x10: PAGE_2(); break; // Page 2 + case 0x11: PAGE_3(); break; // Page 3 + case 0x12: NOP_(); break; // NOP (Inherent) + case 0x13: SYNC_(); break; // SYNC (Inherent) + case 0x14: ILLEGAL(); break; // ILLEGAL + case 0x15: ILLEGAL(); break; // ILLEGAL + case 0x16: LBR_(true); break; // LBRA (Relative) + case 0x17: LBSR_(); break; // LBSR (Relative) + case 0x18: ILLEGAL(); break; // ILLEGAL + case 0x19: REG_OP(DA, A); break; // DAA (Inherent) + case 0x1A: REG_OP_IMD_CC(OR8); break; // ORCC (Immediate) + case 0x1B: ILLEGAL(); break; // ILLEGAL + case 0x1C: REG_OP_IMD_CC(AND8); break; // ANDCC (Immediate) + case 0x1D: REG_OP(SEX, A); break; // SEX (Inherent) + case 0x1E: EXG_(); break; // EXG (Immediate) + case 0x1F: TFR_(); break; // TFR (Immediate) + case 0x20: BR_(true); break; // BRA (Relative) + case 0x21: BR_(false); break; // BRN (Relative) + case 0x22: BR_(!(FlagC | FlagZ)); break; // BHI (Relative) + case 0x23: BR_(FlagC | FlagZ); break; // BLS (Relative) + case 0x24: BR_(!FlagC); break; // BHS , BCC (Relative) + case 0x25: BR_(FlagC); break; // BLO , BCS (Relative) + case 0x26: BR_(!FlagZ); break; // BNE (Relative) + case 0x27: BR_(FlagZ); break; // BEQ (Relative) + case 0x28: BR_(!FlagV); break; // BVC (Relative) + case 0x29: BR_(FlagV); break; // BVS (Relative) + case 0x2A: BR_(!FlagN); break; // BPL (Relative) + case 0x2B: BR_(FlagN); break; // BMI (Relative) + case 0x2C: BR_(FlagN == FlagV); break; // BGE (Relative) + case 0x2D: BR_(FlagN ^ FlagV); break; // BLT (Relative) + case 0x2E: BR_((!FlagZ) & (FlagN == FlagV)); break; // BGT (Relative) + case 0x2F: BR_(FlagZ | (FlagN ^ FlagV)); break; // BLE (Relative) + case 0x30: INDEX_OP(LEAX); break; // LEAX (Indexed) + case 0x31: INDEX_OP(LEAY); break; // LEAY (Indexed) + case 0x32: INDEX_OP(LEAS); break; // LEAS (Indexed) + case 0x33: INDEX_OP(LEAU); break; // LEAU (Indexed) + case 0x34: PSH(SP); break; // PSHS (Immediate) + case 0x35: PUL(SP); break; // PULS (Immediate) + case 0x36: PSH(US); break; // PSHU (Immediate) + case 0x37: PUL(US); break; // PULU (Immediate) + case 0x38: ILLEGAL(); break; // ILLEGAL + case 0x39: RTS(); break; // RTS (Inherent) + case 0x3A: ABX_(); break; // ABX (Inherent) + case 0x3B: RTI(); break; // RTI (Inherent) + case 0x3C: CWAI_(); break; // CWAI (Inherent) + case 0x3D: MUL_(); break; // MUL (Inherent) + case 0x3E: ILLEGAL(); break; // ILLEGAL + case 0x3F: SWI1(); break; // SWI (Inherent) + case 0x40: REG_OP(NEG, A); break; // NEGA (Inherent) + case 0x41: ILLEGAL(); break; // ILLEGAL + case 0x42: ILLEGAL(); break; // ILLEGAL + case 0x43: REG_OP(COM, A); break; // COMA (Inherent) + case 0x44: REG_OP(LSR, A); break; // LSRA (Inherent) + case 0x45: ILLEGAL(); break; // ILLEGAL + case 0x46: REG_OP(ROR, A); break; // RORA (Inherent) + case 0x47: REG_OP(ASR, A); break; // ASRA (Inherent) + case 0x48: REG_OP(ASL, A); break; // ASLA , LSLA (Inherent) + case 0x49: REG_OP(ROL, A); break; // ROLA (Inherent) + case 0x4A: REG_OP(DEC8, A); break; // DECA (Inherent) + case 0x4B: ILLEGAL(); break; // ILLEGAL + case 0x4C: REG_OP(INC8, A); break; // INCA (Inherent) + case 0x4D: REG_OP(TST, A); break; // TSTA (Inherent) + case 0x4E: ILLEGAL(); break; // ILLEGAL + case 0x4F: REG_OP(CLR, A); break; // CLRA (Inherent) + case 0x50: REG_OP(NEG, B); break; // NEGB (Inherent) + case 0x51: ILLEGAL(); break; // ILLEGAL + case 0x52: ILLEGAL(); break; // ILLEGAL + case 0x53: REG_OP(COM, B); break; // COMB (Inherent) + case 0x54: REG_OP(LSR, B); break; // LSRB (Inherent) + case 0x55: ILLEGAL(); break; // ILLEGAL + case 0x56: REG_OP(ROR, B); break; // RORB (Inherent) + case 0x57: REG_OP(ASR, B); break; // ASRB (Inherent) + case 0x58: REG_OP(ASL, B); break; // ASLB , LSLB (Inherent) + case 0x59: REG_OP(ROL, B); break; // ROLB (Inherent) + case 0x5A: REG_OP(DEC8, B); break; // DECB (Inherent) + case 0x5B: ILLEGAL(); break; // ILLEGAL + case 0x5C: REG_OP(INC8, B); break; // INCB (Inherent) + case 0x5D: REG_OP(TST, B); break; // TSTB (Inherent) + case 0x5E: ILLEGAL(); break; // ILLEGAL + case 0x5F: REG_OP(CLR, B); break; // CLRB (Inherent) + case 0x60: INDEX_OP(I_NEG); break; // NEG (Indexed) + case 0x61: ILLEGAL(); break; // ILLEGAL + case 0x62: ILLEGAL(); break; // ILLEGAL + case 0x63: INDEX_OP(I_COM); break; // COM (Indexed) + case 0x64: INDEX_OP(I_LSR); break; // LSR (Indexed) + case 0x65: ILLEGAL(); break; // ILLEGAL + case 0x66: INDEX_OP(I_ROR); break; // ROR (Indexed) + case 0x67: INDEX_OP(I_ASR); break; // ASR (Indexed) + case 0x68: INDEX_OP(I_ASL); break; // ASL , LSL (Indexed) + case 0x69: INDEX_OP(I_ROL); break; // ROL (Indexed) + case 0x6A: INDEX_OP(I_DEC); break; // DEC (Indexed) + case 0x6B: ILLEGAL(); break; // ILLEGAL + case 0x6C: INDEX_OP(I_INC); break; // INC (Indexed) + case 0x6D: INDEX_OP(I_TST); break; // TST (Indexed) + case 0x6E: INDEX_OP(I_JMP); break; // JMP (Indexed) + case 0x6F: INDEX_OP(I_CLR); break; // CLR (Indexed) + case 0x70: EXT_MEM(NEG); break; // NEG (Extended) + case 0x71: ILLEGAL(); break; // ILLEGAL + case 0x72: ILLEGAL(); break; // ILLEGAL + case 0x73: EXT_MEM(COM); break; // COM (Extended) + case 0x74: EXT_MEM(LSR); break; // LSR (Extended) + case 0x75: ILLEGAL(); break; // ILLEGAL + case 0x76: EXT_MEM(ROR); break; // ROR (Extended) + case 0x77: EXT_MEM(ASR); break; // ASR (Extended) + case 0x78: EXT_MEM(ASL); break; // ASL , LSL (Extended) + case 0x79: EXT_MEM(ROL); break; // ROL (Extended) + case 0x7A: EXT_MEM(DEC8); break; // DEC (Extended) + case 0x7B: ILLEGAL(); break; // ILLEGAL + case 0x7C: EXT_MEM(INC8); break; // INC (Extended) + case 0x7D: EXT_MEM(TST); break; // TST (Extended) + case 0x7E: JMP_EXT_(); break; // JMP (Extended) + case 0x7F: EXT_MEM(CLR); break; // CLR (Extended) + case 0x80: REG_OP_IMD(SUB8, A); break; // SUBA (Immediate) + case 0x81: REG_OP_IMD(CMP8, A); break; // CMPA (Immediate) + case 0x82: REG_OP_IMD(SBC8, A); break; // SBCA (Immediate) + case 0x83: IMD_OP_D(SUB16, D); break; // SUBD (Immediate) + case 0x84: REG_OP_IMD(AND8, A); break; // ANDA (Immediate) + case 0x85: REG_OP_IMD(BIT, A); break; // BITA (Immediate) + case 0x86: REG_OP_IMD(LD_8, A); break; // LDA (Immediate) + case 0x87: ILLEGAL(); break; // ILLEGAL + case 0x88: REG_OP_IMD(XOR8, A); break; // EORA (Immediate) + case 0x89: REG_OP_IMD(ADC8, A); break; // ADCA (Immediate) + case 0x8A: REG_OP_IMD(OR8, A); break; // ORA (Immediate) + case 0x8B: REG_OP_IMD(ADD8, A); break; // ADDA (Immediate) + case 0x8C: IMD_CMP_16(CMP16, X); break; // CMPX (Immediate) + case 0x8D: BSR_(); break; // BSR (Relative) + case 0x8E: REG_OP_LD_16(X); break; // LDX (Immediate) + case 0x8F: ILLEGAL(); break; // ILLEGAL + case 0x90: DIRECT_MEM_4(SUB8, A); break; // SUBA (Direct) + case 0x91: DIRECT_MEM_4(CMP8, A); break; // CMPA (Direct) + case 0x92: DIRECT_MEM_4(SBC8, A); break; // SBCA (Direct) + case 0x93: DIR_OP_D(SUB16, D); break; // SUBD (Direct) + case 0x94: DIRECT_MEM_4(AND8, A); break; // ANDA (Direct) + case 0x95: DIRECT_MEM_4(BIT, A); break; // BITA (Direct) + case 0x96: DIRECT_MEM_4(LD_8, A); break; // LDA (Direct) + case 0x97: DIRECT_ST_4(A); break; // STA (Direct) + case 0x98: DIRECT_MEM_4(XOR8, A); break; // EORA (Direct) + case 0x99: DIRECT_MEM_4(ADC8, A); break; // ADCA (Direct) + case 0x9A: DIRECT_MEM_4(OR8, A); break; // ORA (Direct) + case 0x9B: DIRECT_MEM_4(ADD8, A); break; // ADDA (Direct) + case 0x9C: DIR_CMP_16(CMP16, X); break; // CMPX (Direct) + case 0x9D: REG_OP(ADC8, A); break; // JSR (Direct) + case 0x9E: DIR_OP_LD_16(X); break; // LDX (Direct) + case 0x9F: DIR_OP_ST_16(X); break; // STX (Direct) + case 0xA0: INDEX_OP_REG(I_SUB, A); break; // SUBA (Indexed) + case 0xA1: INDEX_OP_REG(I_CMP, A); break; // CMPA (Indexed) + case 0xA2: INDEX_OP_REG(I_SBC, A); break; // SBCA (Indexed) + case 0xA3: INDEX_OP_REG(I_SUBD, D); break; // SUBD (Indexed) + case 0xA4: INDEX_OP_REG(I_AND, A); break; // ANDA (Indexed) + case 0xA5: INDEX_OP_REG(I_BIT, A); break; // BITA (Indexed) + case 0xA6: INDEX_OP_REG(I_LD, A); break; // LDA (Indexed) + case 0xA7: INDEX_OP_REG(I_ST, A); break; // STA (Indexed) + case 0xA8: INDEX_OP_REG(I_XOR, A); break; // EORA (Indexed) + case 0xA9: INDEX_OP_REG(I_ADC, A); break; // ADCA (Indexed) + case 0xAA: INDEX_OP_REG(I_OR, A); break; // ORA (Indexed) + case 0xAB: INDEX_OP_REG(I_ADD, A); break; // ADDA (Indexed) + case 0xAC: INDEX_OP_REG(I_CMP16, X); break; // CMPX (Indexed) + case 0xAD: INDEX_OP(I_JSR); break; // JSR (Indexed) + case 0xAE: INDEX_OP_REG(I_LD16, X); break; // LDX (Indexed) + case 0xAF: INDEX_OP_REG(I_ST16, X); break; // STX (Indexed) + case 0xB0: EXT_REG(SUB8, A); break; // SUBA (Extended) + case 0xB1: EXT_REG(CMP8, A); break; // CMPA (Extended) + case 0xB2: EXT_REG(SBC8, A); break; // SBCA (Extended) + case 0xB3: EXT_OP_D(SUB16, D); break; // SUBD (Extended) + case 0xB4: EXT_REG(AND8, A); break; // ANDA (Extended) + case 0xB5: EXT_REG(BIT, A); break; // BITA (Extended) + case 0xB6: EXT_REG(LD_8, A); break; // LDA (Extended) + case 0xB7: EXT_ST(A); break; // STA (Extended) + case 0xB8: EXT_REG(XOR8, A); break; // EORA (Extended) + case 0xB9: EXT_REG(ADC8, A); break; // ADCA (Extended) + case 0xBA: EXT_REG(OR8, A); break; // ORA (Extended) + case 0xBB: EXT_REG(ADD8, A); break; // ADDA (Extended) + case 0xBC: EXT_CMP_16(CMP16, X); break; // CMPX (Extended) + case 0xBD: JSR_EXT(); break; // JSR (Extended) + case 0xBE: EXT_OP_LD_16(X); break; // LDX (Extended) + case 0xBF: EXT_OP_ST_16(X); break; // STX (Extended) + case 0xC0: REG_OP_IMD(SUB8, B); break; // SUBB (Immediate) + case 0xC1: REG_OP_IMD(CMP8, B); break; // CMPB (Immediate) + case 0xC2: REG_OP_IMD(SBC8, B); break; // SBCB (Immediate) + case 0xC3: IMD_OP_D(ADD16, D); break; // ADDD (Immediate) + case 0xC4: REG_OP_IMD(AND8, B); break; // ANDB (Immediate) + case 0xC5: REG_OP_IMD(BIT, B); break; // BITB (Immediate) + case 0xC6: REG_OP_IMD(LD_8, B); break; // LDB (Immediate) + case 0xC7: ILLEGAL(); break; // ILLEGAL + case 0xC8: REG_OP_IMD(XOR8, B); break; // EORB (Immediate) + case 0xC9: REG_OP_IMD(ADC8, B); break; // ADCB (Immediate) + case 0xCA: REG_OP_IMD(OR8, B); break; // ORB (Immediate) + case 0xCB: REG_OP_IMD(ADD8, B); break; // ADDB (Immediate) + case 0xCC: REG_OP_LD_16D(); break; // LDD (Immediate) + case 0xCD: ILLEGAL(); break; // ILLEGAL + case 0xCE: REG_OP_LD_16(US); break; // LDU (Immediate) + case 0xCF: ILLEGAL(); break; // ILLEGAL + case 0xD0: DIRECT_MEM_4(SUB8, B); break; // SUBB (Direct) + case 0xD1: DIRECT_MEM_4(CMP8, B); break; // CMPB (Direct) + case 0xD2: DIRECT_MEM_4(SBC8, B); break; // SBCB (Direct) + case 0xD3: DIR_OP_D(ADD16, D); break; // ADDD (Direct) + case 0xD4: DIRECT_MEM_4(AND8, B); break; // ANDB (Direct) + case 0xD5: DIRECT_MEM_4(BIT, B); break; // BITB (Direct) + case 0xD6: DIRECT_MEM_4(LD_8, B); break; // LDB (Direct) + case 0xD7: DIRECT_ST_4(B); break; // STB (Direct) + case 0xD8: DIRECT_MEM_4(XOR8, B); break; // EORB (Direct) + case 0xD9: DIRECT_MEM_4(ADC8, B); break; // ADCB (Direct) + case 0xDA: DIRECT_MEM_4(OR8, B); break; // ORB (Direct) + case 0xDB: DIRECT_MEM_4(ADD8, B); break; // ADDB (Direct) + case 0xDC: DIR_OP_LD_16D(); break; // LDD (Direct) + case 0xDD: DIR_OP_ST_16D(); break; // STD (Direct) + case 0xDE: DIR_OP_LD_16(US); break; // LDU (Direct) + case 0xDF: DIR_OP_ST_16(US); break; // STU (Direct) + case 0xE0: INDEX_OP_REG(I_SUB, B); break; // SUBB (Indexed) + case 0xE1: INDEX_OP_REG(I_CMP, B); break; // CMPB (Indexed) + case 0xE2: INDEX_OP_REG(I_SBC, B); break; // SBCB (Indexed) + case 0xE3: INDEX_OP_REG(I_ADDD, D); break; // ADDD (Indexed) + case 0xE4: INDEX_OP_REG(I_AND, B); break; // ANDB (Indexed) + case 0xE5: INDEX_OP_REG(I_BIT, B); break; // BITB (Indexed) + case 0xE6: INDEX_OP_REG(I_LD, B); break; // LDB (Indexed) + case 0xE7: INDEX_OP_REG(I_ST, B); break; // STB (Indexed) + case 0xE8: INDEX_OP_REG(I_XOR, B); break; // EORB (Indexed) + case 0xE9: INDEX_OP_REG(I_ADC, B); break; // ADCB (Indexed) + case 0xEA: INDEX_OP_REG(I_OR, B); break; // ORB (Indexed) + case 0xEB: INDEX_OP_REG(I_ADD, B); break; // ADDB (Indexed) + case 0xEC: INDEX_OP_REG(I_LD16D, D); break; // LDD (Indexed) + case 0xED: INDEX_OP_REG(I_ST16D, D); break; // STD (Indexed) + case 0xEE: INDEX_OP_REG(I_LD16, US); break; // LDU (Indexed) + case 0xEF: INDEX_OP_REG(I_ST16, US); break; // STU (Indexed) + case 0xF0: EXT_REG(SUB8, B); break; // SUBB (Extended) + case 0xF1: EXT_REG(CMP8, B); break; // CMPB (Extended) + case 0xF2: EXT_REG(SBC8, B); break; // SBCB (Extended) + case 0xF3: EXT_OP_D(ADD16, D); break; // ADDD (Extended) + case 0xF4: EXT_REG(AND8, B); break; // ANDB (Extended) + case 0xF5: EXT_REG(BIT, B); break; // BITB (Extended) + case 0xF6: EXT_REG(LD_8, B); break; // LDB (Extended) + case 0xF7: EXT_ST(B); break; // STB (Extended) + case 0xF8: EXT_REG(XOR8, B); break; // EORB (Extended) + case 0xF9: EXT_REG(ADC8, B); break; // ADCB (Extended) + case 0xFA: EXT_REG(OR8, B); break; // ORB (Extended) + case 0xFB: EXT_REG(ADD8, B); break; // ADDB (Extended) + case 0xFC: EXT_OP_LD_16D(); break; // LDD (Extended) + case 0xFD: EXT_OP_ST_16D(); break; // STD (Extended) + case 0xFE: EXT_OP_LD_16(US); break; // LDU (Extended) + case 0xFF: EXT_OP_ST_16(US); break; // STU (Extended) + } + } + + public void FetchInstruction2(byte opcode) + { + opcode_see = opcode; + switch (opcode) + { + case 0x21: LBR_(false); break; // BRN (Relative) + case 0x22: LBR_(!(FlagC | FlagZ)); break; // BHI (Relative) + case 0x23: LBR_(FlagC | FlagZ); break; // BLS (Relative) + case 0x24: LBR_(!FlagC); break; // BHS , BCC (Relative) + case 0x25: LBR_(FlagC); break; // BLO , BCS (Relative) + case 0x26: LBR_(!FlagZ); break; // BNE (Relative) + case 0x27: LBR_(FlagZ); break; // BEQ (Relative) + case 0x28: LBR_(!FlagV); break; // BVC (Relative) + case 0x29: LBR_(FlagV); break; // BVS (Relative) + case 0x2A: LBR_(!FlagN); break; // BPL (Relative) + case 0x2B: LBR_(FlagN); break; // BMI (Relative) + case 0x2C: LBR_(FlagN == FlagV); break; // BGE (Relative) + case 0x2D: LBR_(FlagN ^ FlagV); break; // BLT (Relative) + case 0x2E: LBR_((!FlagZ) & (FlagN == FlagV)); break; // BGT (Relative) + case 0x2F: LBR_(FlagZ | (FlagN ^ FlagV)); break; // BLE (Relative) + case 0x3F: SWI2_3(2); break; // SWI2 (Inherent) + case 0x83: IMD_OP_D(CMP16D, D); break; // CMPD (Immediate) + case 0x8C: IMD_CMP_16(CMP16, Y); break; // CMPY (Immediate) + case 0x8E: REG_OP_LD_16(Y); break; // LDY (Immediate) + case 0x93: DIR_OP_D(CMP16D, D); break; // CMPD (Direct) + case 0x9C: DIR_CMP_16(CMP16, Y); break; // CMPY (Direct) + case 0x9E: DIR_OP_LD_16(Y); break; // LDY (Direct) + case 0x9F: DIR_OP_ST_16(Y); break; // STY (Direct) + case 0xA3: INDEX_OP_REG(I_CMP16D, D); break; // CMPD (Indexed) + case 0xAC: INDEX_OP_REG(I_CMP16, Y); break; // CMPY (Indexed) + case 0xAE: INDEX_OP_REG(I_LD16, Y); break; // LDY (Indexed) + case 0xAF: INDEX_OP_REG(I_ST16, Y); break; // STY (Indexed) + case 0xB3: EXT_OP_D(CMP16D, D); break; // CMPD (Extended) + case 0xBC: EXT_CMP_16(CMP16, Y); break; // CMPY (Extended) + case 0xBE: EXT_OP_LD_16(Y); break; // LDY (Extended) + case 0xBF: EXT_OP_ST_16(Y); break; // STY (Extended) + case 0xCE: REG_OP_LD_16(SP); break; // LDS (Immediate) + case 0xDE: DIR_OP_LD_16(SP); break; // LDS (Direct) + case 0xDF: DIR_OP_ST_16(SP); break; // STS (Direct) + case 0xEE: INDEX_OP_REG(I_LD16, SP); break; // LDS (Indexed) + case 0xEF: INDEX_OP_REG(I_ST16, SP); break; // STS (Indexed) + case 0xFE: EXT_OP_LD_16(SP); break; // LDS (Extended) + case 0xFF: EXT_OP_ST_16(SP); break; // STS (Extended) + + default: ILLEGAL(); break; + } + } + + public void FetchInstruction3(byte opcode) + { + opcode_see = opcode; + switch (opcode) + { + case 0x3F: SWI2_3(3); break; // SWI3 (Inherent) + case 0x83: IMD_CMP_16(CMP16, US); break; // CMPU (Immediate) + case 0x8C: IMD_CMP_16(CMP16, SP); break; // CMPS (Immediate) + case 0x93: DIR_CMP_16(CMP16, US); break; // CMPU (Direct) + case 0x9C: DIR_CMP_16(CMP16, SP); break; // CMPS (Direct) + case 0xA3: INDEX_OP_REG(I_CMP16, US); break; // CMPU (Indexed) + case 0xAC: INDEX_OP_REG(I_CMP16, SP); break; // CMPS (Indexed) + case 0xB3: EXT_CMP_16(CMP16, US); break; // CMPU (Extended) + case 0xBC: EXT_CMP_16(CMP16, SP); break; // CMPS (Extended) + + default: ILLEGAL(); break; + } + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/Indexed_Modes.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/Indexed_Modes.cs new file mode 100644 index 0000000000..89e4e87c8f --- /dev/null +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/Indexed_Modes.cs @@ -0,0 +1,454 @@ +using System; + +namespace BizHawk.Emulation.Common.Components.MC6809 +{ + public partial class MC6809 + { + public const ushort LEAX = 0; + public const ushort LEAY = 1; + public const ushort LEAS = 2; + public const ushort LEAU = 3; + public const ushort I_NEG = 4; + public const ushort I_COM = 5; + public const ushort I_LSR = 6; + public const ushort I_ROR = 7; + public const ushort I_ASR = 8; + public const ushort I_ASL = 9; + public const ushort I_ROL = 10; + public const ushort I_DEC = 11; + public const ushort I_INC = 12; + public const ushort I_TST = 13; + public const ushort I_JMP = 14; + public const ushort I_CLR = 15; + public const ushort I_SUB = 16; + public const ushort I_CMP = 17; + public const ushort I_SBC = 18; + public const ushort I_AND = 19; + public const ushort I_BIT = 20; + public const ushort I_LD = 21; + public const ushort I_ST = 22; + public const ushort I_XOR = 23; + public const ushort I_ADC = 24; + public const ushort I_OR = 25; + public const ushort I_ADD = 26; + public const ushort I_SUBD = 27; + public const ushort I_ADDD = 28; + public const ushort I_CMP16 = 29; + public const ushort I_JSR = 30; + public const ushort I_LD16 = 31; + public const ushort I_ST16 = 32; + public const ushort I_LD16D = 33; + public const ushort I_ST16D = 34; + public const ushort I_CMP16D = 35; + + public ushort indexed_op; + public ushort indexed_reg; + public ushort indexed_op_reg; + + public ushort temp; + + private void INDEX_OP(ushort oper) + { + indexed_op = oper; + + PopulateCURINSTR(RD_INC_OP, ALU, PC, IDX_DCDE); + + IRQS = -1; + } + + private void INDEX_OP_REG(ushort oper, ushort src) + { + indexed_op = oper; + indexed_op_reg = src; + + PopulateCURINSTR(RD_INC_OP, ALU, PC, IDX_DCDE); + + IRQS = -1; + } + + private void INDEX_OP_JMP() + { + PopulateCURINSTR(TR, PC, IDX_EA); + + IRQS = 1; + } + + private void INDEX_OP_JSR() + { + PopulateCURINSTR(TR, ADDR, PC, + DEC16, SP, + TR, PC, IDX_EA, + WR_DEC_LO, SP, ADDR, + WR_HI, SP, ADDR); + + IRQS = 5; + } + + private void INDEX_OP_LEA(ushort dest) + { + PopulateCURINSTR(LEA, dest, IDX_EA, + IDLE); + + IRQS = 2; + } + + private void INDEX_OP_LD() + { + PopulateCURINSTR(IDLE, + RD_INC, ALU, IDX_EA, + RD_INC_OP, ALU2, IDX_EA, LD_16, indexed_op_reg, ALU, ALU2); + + IRQS = 3; + } + + private void INDEX_OP_ST() + { + PopulateCURINSTR(IDLE, + WR_HI_INC, IDX_EA, indexed_op_reg, + WR_DEC_LO, IDX_EA, indexed_op_reg); + + IRQS = 3; + } + + private void INDEX_OP_LDD() + { + PopulateCURINSTR(IDLE, + RD_INC, A, IDX_EA, + RD_INC_OP, B, IDX_EA, LD_16, ADDR, A, B); + + IRQS = 3; + } + + private void INDEX_OP_STD() + { + PopulateCURINSTR(SET_ADDR, ADDR, A, A, + WR_HI_INC, IDX_EA, ADDR, + WR_DEC_LO, IDX_EA, B); + + IRQS = 3; + } + + private void INDEX_OP_EX4(ushort oper) + { + PopulateCURINSTR(IDLE, + RD_INC_OP, ALU, IDX_EA, oper, indexed_op_reg, ALU); + + IRQS = 2; + } + + private void INDEX_OP_EX4_ST() + { + PopulateCURINSTR(IDLE, + WR, ALU, IDX_EA, indexed_op_reg); + + IRQS = 2; + } + + private void INDEX_OP_EX6(ushort oper) + { + PopulateCURINSTR(IDLE, + RD, ALU, IDX_EA, + oper, ALU, + WR, IDX_EA, ALU); + + IRQS = 4; + } + + private void INDEX_OP_EX6D(ushort oper) + { + PopulateCURINSTR(IDLE, + RD_INC, ALU, IDX_EA, + RD_INC_OP, ALU2, IDX_EA, SET_ADDR, ADDR, ALU, ALU2, + oper, ADDR); + + IRQS = 4; + } + + private void INDEX_CMP_EX6(ushort oper) + { + PopulateCURINSTR(IDLE, + RD_INC, ALU, IDX_EA, + RD_INC_OP, ALU2, IDX_EA, SET_ADDR, ADDR, ALU, ALU2, + oper, indexed_op_reg, ADDR); + + IRQS = 4; + } + + // ALU holds the post byte + public void Index_decode() + { + switch ((Regs[ALU] >> 5) & 3) + { + case 0: indexed_reg = X; break; + case 1: indexed_reg = Y; break; + case 2: indexed_reg = US; break; + case 3: indexed_reg = SP; break; + } + + if ((Regs[ALU] & 0x80) == 0) + { + temp = (ushort)(Regs[ALU] & 0x1F); + if ((Regs[ALU] & 0x10) == 0x10) + { + temp |= 0xFFE0; + } + + Regs[IDX_EA] = (ushort)(Regs[indexed_reg] + temp); + + PopulateCURINSTR(IDX_OP_BLD); + } + else + { + if ((Regs[ALU] & 0x10) == 0x10) + { + switch (Regs[ALU] & 0xF) + { + case 0x0: + // Illegal + break; + case 0x1: + Regs[ADDR] = Regs[indexed_reg]; + PopulateCURINSTR(INC16, indexed_reg, + INC16, indexed_reg, + RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + break; + case 0x2: + // Illegal + break; + case 0x3: + Regs[ADDR] = (ushort)(Regs[indexed_reg] - 2); + PopulateCURINSTR(DEC16, indexed_reg, + DEC16, indexed_reg, + RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + break; + case 0x4: + Regs[ADDR] = Regs[indexed_reg]; + PopulateCURINSTR(RD_INC, ALU, ADDR, + RD_INC_OP, ALU2, ADDR, SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + break; + case 0x5: + Regs[ADDR] = (ushort)(Regs[indexed_reg] + (((Regs[B] & 0x80) == 0x80) ? (Regs[B] | 0xFF00) : Regs[B])); + PopulateCURINSTR(RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + break; + case 0x6: + Regs[ADDR] = (ushort)(Regs[indexed_reg] + (((Regs[A] & 0x80) == 0x80) ? (Regs[A] | 0xFF00) : Regs[A])); + PopulateCURINSTR(RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + break; + case 0x7: + // Illegal + break; + case 0x8: + Regs[ADDR] = Regs[indexed_reg]; + PopulateCURINSTR(RD_INC_OP, ALU2, PC, ADD8BR, ADDR, ALU2, + RD_INC, ALU, ADDR, + RD_INC_OP, ALU2, ADDR, SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + break; + case 0x9: + Regs[ADDR] = Regs[indexed_reg]; + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC, ALU2, PC, + SET_ADDR, IDX_EA, ALU, ALU2, + ADD16BR, ADDR, IDX_EA, + RD_INC, ALU, ADDR, + RD_INC_OP, ALU2, ADDR, SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + break; + case 0xA: + // Illegal + break; + case 0xB: + Regs[ADDR] = Regs[indexed_reg]; + PopulateCURINSTR(IDLE, + IDLE, + SET_ADDR, IDX_EA, A, B, + ADD16BR, ADDR, IDX_EA, + RD_INC, ALU, ADDR, + RD_INC_OP, ALU2, ADDR, SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + break; + case 0xC: + indexed_reg = PC; + Regs[ADDR] = Regs[indexed_reg]; + PopulateCURINSTR(RD_INC_OP, ALU2, PC, ADD8BR, ADDR, ALU2, + RD_INC, ALU, ADDR, + RD_INC_OP, ALU2, ADDR, SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + break; + case 0xD: + indexed_reg = PC; + Regs[ADDR] = Regs[indexed_reg]; + PopulateCURINSTR(IDLE, + RD_INC, ALU, PC, + RD_INC, ALU2, PC, + SET_ADDR, IDX_EA, ALU, ALU2, + ADD16BR, ADDR, IDX_EA, + RD_INC, ALU, ADDR, + RD_INC_OP, ALU2, ADDR, SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + break; + case 0xE: + // Illegal + break; + case 0xF: + if (((Regs[ALU] >> 5) & 3) == 0) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + RD_INC, ALU, ADDR, + RD_INC_OP, ALU2, ADDR, SET_ADDR, IDX_EA, ALU, ALU2, + IDX_OP_BLD); + } + else + { + // illegal + } + break; + } + } + else + { + switch (Regs[ALU] & 0xF) + { + case 0x0: + Regs[IDX_EA] = Regs[indexed_reg]; + PopulateCURINSTR(INC16, indexed_reg, + IDX_OP_BLD); + break; + case 0x1: + Regs[IDX_EA] = Regs[indexed_reg]; + PopulateCURINSTR(INC16, indexed_reg, + INC16, indexed_reg, + IDX_OP_BLD); + break; + case 0x2: + Regs[IDX_EA] = (ushort)(Regs[indexed_reg] - 1); + PopulateCURINSTR(DEC16, indexed_reg, + IDX_OP_BLD); + break; + case 0x3: + Regs[IDX_EA] = (ushort)(Regs[indexed_reg] - 2); + PopulateCURINSTR(DEC16, indexed_reg, + DEC16, indexed_reg, + IDX_OP_BLD); + break; + case 0x4: + Regs[IDX_EA] = Regs[indexed_reg]; + Index_Op_Builder(); + return; // need to return here or else we run into the code below invalidating irq_pntr + break; + case 0x5: + Regs[IDX_EA] = (ushort)(Regs[indexed_reg] + (((Regs[B] & 0x80) == 0x80) ? (Regs[B] | 0xFF00) : Regs[B])); + PopulateCURINSTR(IDX_OP_BLD); + break; + case 0x6: + Regs[IDX_EA] = (ushort)(Regs[indexed_reg] + (((Regs[A] & 0x80) == 0x80) ? (Regs[A] | 0xFF00) : Regs[A])); + PopulateCURINSTR(IDX_OP_BLD); + break; + case 0x7: + // Illegal + break; + case 0x8: + PopulateCURINSTR(RD_INC_OP, ALU2, PC, EA_8); + break; + case 0x9: + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC, ALU2, PC, + SET_ADDR, ADDR, ALU, ALU2, + EA_16); + break; + case 0xA: + // Illegal + break; + case 0xB: + PopulateCURINSTR(IDLE, + IDLE, + SET_ADDR, ADDR, A, B, + EA_16); + break; + case 0xC: + indexed_reg = PC; + PopulateCURINSTR(RD_INC_OP, ALU2, PC, EA_8); + break; + case 0xD: + indexed_reg = PC; + PopulateCURINSTR(IDLE, + RD_INC, ALU, PC, + RD_INC, ALU2, PC, + SET_ADDR, ADDR, ALU, ALU2, + EA_16); + break; + case 0xE: + // Illegal + break; + case 0xF: + // Illegal + break; + } + } + } + + instr_pntr = 0; + irq_pntr = 100; + } + + public void Index_Op_Builder() + { + switch(indexed_op) + { + case LEAX: INDEX_OP_LEA(X); break; // LEAX + case LEAY: INDEX_OP_LEA(Y); break; // LEAY + case LEAS: INDEX_OP_LEA(SP); break; // LEAS + case LEAU: INDEX_OP_LEA(US); break; // LEAU + case I_NEG: INDEX_OP_EX6(NEG); break; // NEG + case I_COM: INDEX_OP_EX6(COM); break; // COM + case I_LSR: INDEX_OP_EX6(LSR); break; // LSR + case I_ROR: INDEX_OP_EX6(ROR); break; // ROR + case I_ASR: INDEX_OP_EX6(ASR); break; // ASR + case I_ASL: INDEX_OP_EX6(ASL); break; // ASL + case I_ROL: INDEX_OP_EX6(ROL); break; // ROL + case I_DEC: INDEX_OP_EX6(DEC8); break; // DEC + case I_INC: INDEX_OP_EX6(INC8); break; // INC + case I_TST: INDEX_OP_EX6(TST); break; // TST + case I_JMP: INDEX_OP_JMP(); break; // JMP + case I_CLR: INDEX_OP_EX6(CLR); break; // CLR + case I_SUB: INDEX_OP_EX4(SUB8); break; // SUB A,B + case I_CMP: INDEX_OP_EX4(CMP8); break; // CMP A,B + case I_SBC: INDEX_OP_EX4(SBC8); break; // SBC A,B + case I_AND: INDEX_OP_EX4(AND8); break; // AND A,B + case I_BIT: INDEX_OP_EX4(BIT); break; // BIT A,B + case I_LD: INDEX_OP_EX4(LD_8); break; // LD A,B + case I_ST: INDEX_OP_EX4_ST(); break; // ST A,B + case I_XOR: INDEX_OP_EX4(XOR8); break; // XOR A,B + case I_ADC: INDEX_OP_EX4(ADC8); break; // ADC A,B + case I_OR: INDEX_OP_EX4(OR8); break; // OR A,B + case I_ADD: INDEX_OP_EX4(ADD8); break; // ADD A,B + case I_SUBD: INDEX_OP_EX6D(SUB16); break; // SUB D + case I_ADDD: INDEX_OP_EX6D(ADD16); break; // ADD D + case I_CMP16: INDEX_CMP_EX6(CMP16); break; // CMP X, Y, SP, US + case I_JSR: INDEX_OP_JSR(); break; // JSR + case I_LD16: INDEX_OP_LD(); break; // LD X, Y, SP, US + case I_ST16: INDEX_OP_ST(); break; // ST X, Y, SP, US + case I_LD16D: INDEX_OP_LDD(); break; // LD D + case I_ST16D: INDEX_OP_STD(); break; // ST D + case I_CMP16D: INDEX_OP_EX6D(CMP16D); break; // CMP D + } + + instr_pntr = 0; + irq_pntr = -1; + } + } +} diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/Interrupts.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/Interrupts.cs new file mode 100644 index 0000000000..d443e83065 --- /dev/null +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/Interrupts.cs @@ -0,0 +1,90 @@ +using System; + +namespace BizHawk.Emulation.Common.Components.MC6809 +{ + public partial class MC6809 + { + private void IRQ_() + { + Regs[ADDR] = 0xFFF8; + PopulateCURINSTR(IDLE, + IDLE, + DEC16, SP, + WR_DEC_LO, SP, PC, + WR_DEC_HI, SP, PC, + WR_DEC_LO, SP, US, + WR_DEC_HI, SP, US, + WR_DEC_LO, SP, Y, + WR_DEC_HI, SP, Y, + WR_DEC_LO, SP, X, + WR_DEC_HI, SP, X, + WR_DEC_LO, SP, DP, + WR_DEC_LO, SP, B, + WR_DEC_LO, SP, A, + WR, SP, CC, + SET_F_I, + RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, PC, ALU, ALU2); + + IRQS = 19; + } + + private void FIRQ_() + { + Regs[ADDR] = 0xFFF6; + PopulateCURINSTR(IDLE, + IDLE, + DEC16, SP, + WR_DEC_LO, SP, PC, + WR_DEC_HI, SP, PC, + WR, SP, CC, + SET_F_I, + RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, PC, ALU, ALU2); + + IRQS = 10; + } + + private void NMI_() + { + Regs[ADDR] = 0xFFFC; + PopulateCURINSTR(IDLE, + IDLE, + DEC16, SP, + WR_DEC_LO, SP, PC, + WR_DEC_HI, SP, PC, + WR_DEC_LO, SP, US, + WR_DEC_HI, SP, US, + WR_DEC_LO, SP, Y, + WR_DEC_HI, SP, Y, + WR_DEC_LO, SP, X, + WR_DEC_HI, SP, X, + WR_DEC_LO, SP, DP, + WR_DEC_LO, SP, B, + WR_DEC_LO, SP, A, + WR, SP, CC, + SET_F_I, + RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, PC, ALU, ALU2); + + IRQS = 19; + } + + public bool NMIPending; + public bool FIRQPending; + public bool IRQPending; + public bool IN_SYNC; + + public Action IRQCallback = delegate () { }; + public Action FIRQCallback = delegate () { }; + public Action NMICallback = delegate () { }; + + private void ResetInterrupts() + { + IN_SYNC = false; + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs new file mode 100644 index 0000000000..db47fef582 --- /dev/null +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs @@ -0,0 +1,681 @@ +using System; + +using BizHawk.Common; + +// Motorola Corp 6809 +namespace BizHawk.Emulation.Common.Components.MC6809 +{ + public sealed partial class MC6809 + { + // operations that can take place in an instruction + public const ushort IDLE = 0; + public const ushort OP = 1; + public const ushort RD = 2; + public const ushort WR = 3; + public const ushort TR = 4; + public const ushort ADD16BR = 5; + public const ushort ADD8 = 6; + public const ushort SUB8 = 7; + public const ushort ADC8 = 8; + public const ushort SBC8 = 9; + public const ushort INC16 = 10; + public const ushort INC8 = 11; + public const ushort DEC16 = 12; + public const ushort DEC8 = 13; + public const ushort ROL = 14; + public const ushort ROR = 15; + public const ushort COM = 16; + public const ushort DA = 17; + public const ushort AND8 = 18; + public const ushort XOR8 = 19; + public const ushort OR8 = 20; + public const ushort CP8 = 21; + public const ushort ASL = 22; + public const ushort ASR = 23; + public const ushort LSR = 24; + public const ushort BIT = 25; + public const ushort CWAI = 26; + public const ushort SYNC = 27; + public const ushort INT_GET = 28; + public const ushort HALT_CHK = 29; + public const ushort RD_INC = 30; + public const ushort SET_ADDR = 31; + public const ushort NEG = 32; + public const ushort TST = 33; + public const ushort CLR = 34; + public const ushort OP_PG_2 = 35; + public const ushort OP_PG_3 = 36; + public const ushort SEX = 37; + public const ushort RD_INC_OP = 38; + public const ushort EXG = 39; + public const ushort TFR = 40; + public const ushort WR_DEC_LO = 41; + public const ushort WR_DEC_HI = 42; + public const ushort WR_HI = 43; + public const ushort ADD8BR = 44; + public const ushort ABX = 45; + public const ushort MUL = 46; + public const ushort JPE = 47; + public const ushort IDX_DCDE = 48; + public const ushort IDX_OP_BLD = 49; + public const ushort EA_8 = 50; + public const ushort EA_16 = 51; + public const ushort PSH_n = 52; + public const ushort PUL_n = 53; + public const ushort WR_DEC_LO_OP = 54; + public const ushort WR_DEC_HI_OP = 55; + public const ushort SET_ADDR_PUL = 56; + public const ushort SET_F_I = 57; + public const ushort SET_E = 58; + public const ushort ANDCC = 59; + public const ushort CMP8 = 60; + public const ushort SUB16 = 61; + public const ushort ADD16 = 62; + public const ushort CMP16 = 63; + public const ushort CMP16D = 64; + public const ushort WR_HI_INC = 65; + public const ushort LD_8 = 66; + public const ushort LD_16 = 67; + public const ushort LEA = 68; + + public MC6809() + { + Reset(); + } + + public void Reset() + { + ResetRegisters(); + ResetInterrupts(); + TotalExecutedCycles = 0; + Regs[PC] = 0xFFFE; + PopulateCURINSTR(IDLE, + IDLE, + IDLE, + RD_INC, ALU, PC, + RD_INC, ALU2, PC, + SET_ADDR, PC, ALU, ALU2); + + IRQS = 6; + instr_pntr = irq_pntr = 0; + } + + // Memory Access + + public Func ReadMemory; + public Action WriteMemory; + public Func PeekMemory; + public Func DummyReadMemory; + + // Special Function for Speed switching executed on a STOP + public Func SpeedFunc; + + //this only calls when the first byte of an instruction is fetched. + public Action OnExecFetch; + + public void UnregisterMemoryMapper() + { + ReadMemory = null; + ReadMemory = null; + PeekMemory = null; + DummyReadMemory = null; + } + + public void SetCallbacks + ( + Func ReadMemory, + Func DummyReadMemory, + Func PeekMemory, + Action WriteMemory + ) + { + this.ReadMemory = ReadMemory; + this.DummyReadMemory = DummyReadMemory; + this.PeekMemory = PeekMemory; + this.WriteMemory = WriteMemory; + } + + //a little CDL related stuff + public delegate void DoCDLCallbackType(ushort addr, MC6809.eCDLogMemFlags flags); + + public DoCDLCallbackType CDLCallback; + + public enum eCDLogMemFlags + { + FetchFirst = 1, + FetchOperand = 2, + Data = 4, + Write = 8 + }; + + // Execute instructions + public void ExecuteOne() + { + //Console.Write(opcode_see + " "); + //Console.WriteLine(Regs[PC] + " "); + switch (cur_instr[instr_pntr++]) + { + case IDLE: + // do nothing + break; + case OP: + // Read the opcode of the next instruction + if (OnExecFetch != null) OnExecFetch(PC); + if (TraceCallback != null) TraceCallback(State()); + if (CDLCallback != null) CDLCallback(PC, eCDLogMemFlags.FetchFirst); + FetchInstruction(ReadMemory(Regs[PC]++)); + instr_pntr = 0; + irq_pntr = -1; + break; + case OP_PG_2: + FetchInstruction2(ReadMemory(Regs[PC]++)); + instr_pntr = 0; + irq_pntr = -1; + break; + case OP_PG_3: + FetchInstruction3(ReadMemory(Regs[PC]++)); + instr_pntr = 0; + irq_pntr = -1; + break; + case RD: + Read_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case RD_INC: + Read_Inc_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case RD_INC_OP: + Read_Inc_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + switch (cur_instr[instr_pntr++]) + { + case AND8: + AND8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case ADD8: + ADD8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case ADC8: + ADC8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case OR8: + OR8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case XOR8: + XOR8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case BIT: + BIT_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case SUB8: + SUB8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case SBC8: + SBC8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case CMP8: + CMP8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case DEC16: + DEC16_Func(cur_instr[instr_pntr++]); + break; + case ADD8BR: + ADD8BR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case TR: + TR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case SET_ADDR: + reg_d_ad = cur_instr[instr_pntr++]; + reg_h_ad = cur_instr[instr_pntr++]; + reg_l_ad = cur_instr[instr_pntr++]; + + Regs[reg_d_ad] = (ushort)((Regs[reg_h_ad] << 8) | Regs[reg_l_ad]); + break; + case JPE: + if (!FlagE) { instr_pntr = 45; }; + break; + case IDX_DCDE: + Index_decode(); + break; + case IDX_OP_BLD: + Index_Op_Builder(); + break; + case EA_8: + Regs[IDX_EA] = (ushort)(Regs[indexed_reg] + (((Regs[ALU2] & 0x80) == 0x80) ? (Regs[ALU2] | 0xFF00) : Regs[ALU2])); + Index_Op_Builder(); + break; + case PUL_n: + PUL_n_BLD(cur_instr[instr_pntr++]); + break; + case SET_ADDR_PUL: + Regs[cur_instr[instr_pntr++]] = (ushort)((Regs[ALU2] << 8) + Regs[ADDR]); + PUL_n_BLD(cur_instr[instr_pntr++]); + break; + case LD_8: + LD_8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case LD_16: + LD_16_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case LEA: + LEA_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + } + break; + case WR: + Write_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case WR_DEC_LO: + Write_Dec_Lo_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case WR_DEC_HI: + Write_Dec_HI_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case WR_DEC_LO_OP: + Write_Dec_Lo_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + switch (cur_instr[instr_pntr++]) + { + case PSH_n: + PSH_n_BLD(cur_instr[instr_pntr++]); + break; + } + break; + case WR_DEC_HI_OP: + Write_Dec_HI_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + switch (cur_instr[instr_pntr++]) + { + case PSH_n: + PSH_n_BLD(cur_instr[instr_pntr++]); + break; + } + break; + case WR_HI: + Write_Hi_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case WR_HI_INC: + Write_Hi_Inc_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case TR: + TR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case LD_8: + LD_8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case LD_16: + LD_16_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case LEA: + LEA_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case EXG: + EXG_Func(cur_instr[instr_pntr++]); + break; + case IDX_OP_BLD: + Index_Op_Builder(); + break; + case EA_16: + Regs[IDX_EA] = (ushort)(Regs[indexed_reg] + Regs[ADDR]); + Index_Op_Builder(); + break; + case TFR: + TFR_Func(cur_instr[instr_pntr++]); + break; + case SET_ADDR: + reg_d_ad = cur_instr[instr_pntr++]; + reg_h_ad = cur_instr[instr_pntr++]; + reg_l_ad = cur_instr[instr_pntr++]; + + // Console.WriteLine(reg_d_ad + " " + reg_h_ad + " " + reg_l_ad); + // Console.WriteLine(Regs[reg_d_ad] + " " + Regs[reg_h_ad] + " " + Regs[reg_l_ad]); + + Regs[reg_d_ad] = (ushort)((Regs[reg_h_ad] << 8) | Regs[reg_l_ad]); + break; + case NEG: + NEG_8_Func(cur_instr[instr_pntr++]); + break; + case TST: + TST_Func(cur_instr[instr_pntr++]); + break; + case CLR: + CLR_Func(cur_instr[instr_pntr++]); + break; + case SEX: + SEX_Func(cur_instr[instr_pntr++]); + break; + case ABX: + Regs[X] += Regs[B]; + break; + case MUL: + Mul_Func(); + break; + case SET_F_I: + FlagI = true; FlagF = true; + break; + case SET_E: + FlagE = true; + break; + case ANDCC: + Regs[CC] &= Regs[instr_pntr++]; + break; + case PSH_n: + PSH_n_BLD(cur_instr[instr_pntr++]); + break; + case PUL_n: + PUL_n_BLD(cur_instr[instr_pntr++]); + break; + case ADD16BR: + ADD16BR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case ADD8BR: + ADD8BR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case ADD8: + ADD8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case SUB8: + SUB8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case ADC8: + ADC8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case SBC8: + SBC8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case CMP8: + CMP8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case INC16: + INC16_Func(cur_instr[instr_pntr++]); + break; + case INC8: + INC8_Func(cur_instr[instr_pntr++]); + break; + case DEC16: + DEC16_Func(cur_instr[instr_pntr++]); + break; + case SUB16: + SUB16_Func(cur_instr[instr_pntr++]); + break; + case ADD16: + ADD16_Func(cur_instr[instr_pntr++]); + break; + case CMP16: + CMP16_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case CMP16D: + CMP16D_Func(cur_instr[instr_pntr++]); + break; + case DEC8: + DEC8_Func(cur_instr[instr_pntr++]); + break; + case ROL: + ROL_Func(cur_instr[instr_pntr++]); + break; + case ROR: + ROR_Func(cur_instr[instr_pntr++]); + break; + case COM: + COM_Func(cur_instr[instr_pntr++]); + break; + case DA: + DA_Func(cur_instr[instr_pntr++]); + break; + case AND8: + AND8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case XOR8: + XOR8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case OR8: + OR8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case CP8: + CP8_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case ASL: + ASL_Func(cur_instr[instr_pntr++]); + break; + case ASR: + ASR_Func(cur_instr[instr_pntr++]); + break; + case LSR: + LSR_Func(cur_instr[instr_pntr++]); + break; + case BIT: + BIT_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + case CWAI: + if (NMIPending) + { + Regs[ADDR] = 0xFFFC; + PopulateCURINSTR(RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, PC, ALU, ALU2); + irq_pntr = -1; + IRQS = 3; + + if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====CWAI NMI====", RegisterInfo = "" }); } + } + else if (FIRQPending && !FlagF) + { + Regs[ADDR] = 0xFFF6; + PopulateCURINSTR(RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, PC, ALU, ALU2); + irq_pntr = -1; + IRQS = 3; + + if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====CWAI FIRQ====", RegisterInfo = "" }); } + } + else if (IRQPending && !FlagI) + { + Regs[ADDR] = 0xFFF8; + PopulateCURINSTR(RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, PC, ALU, ALU2); + irq_pntr = -1; + IRQS = 3; + + if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====CWAI IRQ====", RegisterInfo = "" }); } + } + else + { + PopulateCURINSTR(CWAI); + irq_pntr = 0; + IRQS = -1; + } + instr_pntr = 0; + break; + case SYNC: + IN_SYNC = true; + IRQS = 1; + instr_pntr = irq_pntr = 0; + PopulateCURINSTR(SYNC); + break; + case INT_GET: + + break; + case HALT_CHK: + + break; + } + + if (++irq_pntr == IRQS) + { + // NMI has priority + if (NMIPending) + { + NMIPending = false; + + if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====NMI====", RegisterInfo = "" }); } + + IN_SYNC = false; + NMI_(); + NMICallback(); + instr_pntr = irq_pntr = 0; + } + // fast IRQ has next priority + else if (FIRQPending) + { + if (!FlagF) + { + FIRQPending = false; + + if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====FIRQ====", RegisterInfo = "" }); } + + IN_SYNC = false; + FIRQ_(); + FIRQCallback(); + instr_pntr = irq_pntr = 0; + } + else if (IN_SYNC) + { + FIRQPending = false; + + if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====SYNC====", RegisterInfo = "" }); } + + IN_SYNC = false; + IRQS = 1; + instr_pntr = irq_pntr = 0; + PopulateCURINSTR(IDLE); + } + } + // then regular IRQ + else if (IRQPending && !FlagI) + { + if (!FlagI) + { + IRQPending = false; + + if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); } + + IN_SYNC = false; + IRQ_(); + IRQCallback(); + instr_pntr = irq_pntr = 0; + } + else if (IN_SYNC) + { + IRQPending = false; + + if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====SYNC====", RegisterInfo = "" }); } + + IN_SYNC = false; + IRQS = 1; + instr_pntr = irq_pntr = 0; + PopulateCURINSTR(IDLE); + } + } + // otherwise start the next instruction + else + { + PopulateCURINSTR(OP); + instr_pntr = irq_pntr = 0; + IRQS = -1; + } + } + + TotalExecutedCycles++; + } + + // tracer stuff + + public Action TraceCallback; + + public string TraceHeader + { + get { return "MC6809: PC, machine code, mnemonic, operands, registers (A, B, X, Y, US, SP, DP, CC), Cy, flags (EFHINZVC)"; } + } + + public TraceInfo State(bool disassemble = true) + { + ushort notused; + + return new TraceInfo + { + Disassembly = string.Format( + "{0} ", + disassemble ? Disassemble(Regs[PC], ReadMemory, out notused) : "---").PadRight(50), + RegisterInfo = string.Format( + "A:{0:X2} B:{1:X2} X:{2:X4} Y:{3:X4} US:{4:X4} SP:{5:X4} DP:{6:X2} CC:{7:X2} Cy:{8} {9}{10}{11}{12}{13}{14}{15}{16}", + Regs[A], + Regs[B], + Regs[X], + Regs[Y], + Regs[US], + Regs[SP], + Regs[DP], + Regs[CC], + TotalExecutedCycles, + FlagE ? "E" : "e", + FlagF ? "F" : "f", + FlagH ? "H" : "h", + FlagI ? "I" : "i", + FlagN ? "N" : "n", + FlagZ ? "Z" : "z", + FlagV ? "V" : "v", + FlagC ? "C" : "c" + ) + }; + } + + /// + /// 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, ushort d38 = 0, + ushort d39 = 0, ushort d40 = 0, ushort d41 = 0, ushort d42 = 0, ushort d43 = 0, ushort d44 = 0, ushort d45 = 0, ushort d46 = 0, ushort d47 = 0, ushort d48 = 0, + ushort d49 = 0, ushort d50 = 0, ushort d51 = 0, ushort d52 = 0, ushort d53 = 0, ushort d54 = 0, ushort d55 = 0, ushort d56 = 0, ushort d57 = 0, ushort d58 = 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; cur_instr[38] = d38; + cur_instr[39] = d39; cur_instr[40] = d40; cur_instr[41] = d41; + cur_instr[42] = d42; cur_instr[43] = d43; cur_instr[44] = d44; + cur_instr[45] = d45; cur_instr[46] = d46; cur_instr[47] = d47; + cur_instr[48] = d48; cur_instr[49] = d49; cur_instr[50] = d50; + cur_instr[51] = d51; cur_instr[52] = d52; cur_instr[53] = d53; + cur_instr[54] = d54; cur_instr[55] = d55; cur_instr[56] = d56; + cur_instr[57] = d57; cur_instr[58] = d58; + } + + // State Save/Load + public void SyncState(Serializer ser) + { + ser.BeginSection("MC6809"); + + ser.Sync(nameof(IN_SYNC), ref IN_SYNC); + ser.Sync(nameof(NMIPending), ref NMIPending); + ser.Sync(nameof(FIRQPending), ref FIRQPending); + ser.Sync(nameof(IRQPending), ref IRQPending); + + ser.Sync(nameof(indexed_op), ref indexed_op); + ser.Sync(nameof(indexed_reg), ref indexed_reg); + ser.Sync(nameof(indexed_op_reg), ref indexed_op_reg); + ser.Sync(nameof(temp), ref temp); + + ser.Sync(nameof(instr_pntr), ref instr_pntr); + ser.Sync(nameof(cur_instr), ref cur_instr, false); + ser.Sync(nameof(opcode_see), ref opcode_see); + ser.Sync(nameof(IRQS), ref IRQS); + ser.Sync(nameof(irq_pntr), ref irq_pntr); + + ser.Sync(nameof(Regs), ref Regs, false); + ser.Sync(nameof(TotalExecutedCycles), ref TotalExecutedCycles); + + ser.EndSection(); + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/OP_Tables.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/OP_Tables.cs new file mode 100644 index 0000000000..2a867db8df --- /dev/null +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/OP_Tables.cs @@ -0,0 +1,721 @@ +using System; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Common.Components.MC6809 +{ + public partial class MC6809 + { + // this contains the vectors of instrcution operations + // NOTE: This list is NOT confirmed accurate for each individual cycle + + private void NOP_() + { + PopulateCURINSTR(IDLE); + + IRQS = 1; + } + + private void ILLEGAL() + { + //throw new Exception("Encountered illegal instruction"); + PopulateCURINSTR(IDLE); + + IRQS = 1; + } + + private void SYNC_() + { + PopulateCURINSTR(IDLE, + SYNC); + + IRQS = -1; + } + + private void REG_OP(ushort oper, ushort src) + { + PopulateCURINSTR(oper, src); + + IRQS = 1; + } + + private void DIRECT_MEM(ushort oper) + { + PopulateCURINSTR(RD_INC, ALU, PC, + SET_ADDR, ADDR, DP, ALU, + RD, ALU, ADDR, + oper, ALU, + WR, ADDR, ALU); + + IRQS = 5; + } + + private void DIRECT_ST_4(ushort dest) + { + PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, + IDLE, + WR, ADDR, dest); + + IRQS = 3; + } + + private void DIRECT_MEM_4(ushort oper, ushort dest) + { + PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, + IDLE, + RD_INC_OP, ALU, ADDR, oper, dest, ALU); + + IRQS = 3; + } + + private void EXT_MEM(ushort oper) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC, ALU2, PC, + SET_ADDR, ADDR, ALU, ALU2, + RD, ALU, ADDR, + oper, ALU, + WR, ADDR, ALU); + + IRQS = 6; + } + + private void EXT_REG(ushort oper, ushort dest) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + RD, ALU, ADDR, + oper, dest, ALU); + + IRQS = 4; + } + + private void EXT_ST(ushort dest) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + IDLE, + WR, ADDR, dest); + + IRQS = 4; + } + + private void REG_OP_IMD_CC(ushort oper) + { + Regs[ALU2] = Regs[CC]; + PopulateCURINSTR(RD_INC_OP, ALU, PC, oper, ALU2, ALU, + TR, CC, ALU2); + + IRQS = 2; + } + + private void REG_OP_IMD(ushort oper, ushort dest) + { + PopulateCURINSTR(RD_INC_OP, ALU, PC, oper, dest, ALU); + + IRQS = 1; + } + + private void IMD_OP_D(ushort oper, ushort dest) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + oper, ADDR); + + IRQS = 3; + } + + private void DIR_OP_D(ushort oper, ushort dest) + { + PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, + RD_INC, ALU, ADDR, + RD, ALU2, ADDR, + SET_ADDR, ADDR, ALU, ALU2, + oper, ADDR); + + IRQS = 5; + } + + private void EXT_OP_D(ushort oper, ushort dest) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + RD_INC, ALU, ADDR, + RD, ALU2, ADDR, + SET_ADDR, ADDR, ALU, ALU2, + oper, ADDR); + + IRQS = 6; + } + + private void REG_OP_LD_16D() + { + PopulateCURINSTR(RD_INC, A, PC, + RD_INC_OP, B, PC, LD_16, ADDR, A, B); + + IRQS = 2; + } + + private void DIR_OP_LD_16D() + { + PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, + IDLE, + RD_INC, A, ADDR, + RD_INC_OP, B, ADDR, LD_16, ADDR, A, B); + + IRQS = 4; + } + + private void DIR_OP_ST_16D() + { + PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, + SET_ADDR, ALU, A, A, + WR_HI_INC, ADDR, ALU, + WR, ADDR, B); + + IRQS = 4; + } + + private void DIR_CMP_16(ushort oper, ushort dest) + { + PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, + RD_INC, ALU, ADDR, + RD, ALU2, ADDR, + SET_ADDR, ADDR, ALU, ALU2, + oper, dest, ADDR); + + IRQS = 5; + } + + private void IMD_CMP_16(ushort oper, ushort dest) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + oper, dest, ADDR); + + IRQS = 3; + } + + private void REG_OP_LD_16(ushort dest) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, LD_16, dest, ALU, ALU2); + + IRQS = 2; + } + + private void DIR_OP_LD_16(ushort dest) + { + PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, + IDLE, + RD_INC, ALU, ADDR, + RD_INC_OP, ALU2, ADDR, LD_16, dest, ALU, ALU2); + + IRQS = 4; + } + + private void DIR_OP_ST_16(ushort src) + { + PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, + IDLE, + WR_HI_INC, ADDR, src, + WR_DEC_LO, ADDR, src); + + IRQS = 4; + } + + private void EXT_OP_LD_16(ushort dest) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + IDLE, + RD_INC, ALU, ADDR, + RD_INC_OP, ALU2, ADDR, LD_16, dest, ALU, ALU2); + + IRQS = 5; + } + + private void EXT_OP_ST_16(ushort src) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + IDLE, + WR_HI_INC, ADDR, src, + WR_DEC_LO, ADDR, src); + + IRQS = 5; + } + + private void EXT_OP_LD_16D() + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + IDLE, + RD_INC, A, ADDR, + RD_INC_OP, B, ADDR, LD_16, ADDR, A, B); + + IRQS = 5; + } + + private void EXT_OP_ST_16D() + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + SET_ADDR, ALU, A, A, + WR_HI_INC, ADDR, ALU, + WR, ADDR, B); + + IRQS = 5; + } + + private void EXT_CMP_16(ushort oper, ushort dest) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + RD_INC, ALU, ADDR, + RD, ALU2, ADDR, + SET_ADDR, ADDR, ALU, ALU2, + oper, dest, ADDR); + + IRQS = 6; + } + + private void EXG_() + { + PopulateCURINSTR(RD_INC, ALU, PC, + EXG, ALU, + IDLE, + IDLE, + IDLE, + IDLE, + IDLE); + + IRQS = 7; + } + + private void TFR_() + { + PopulateCURINSTR(RD_INC, ALU, PC, + TFR, ALU, + IDLE, + IDLE, + IDLE); + + IRQS = 5; + } + + private void JMP_DIR_() + { + PopulateCURINSTR(RD_INC, ALU, PC, + SET_ADDR, PC, DP, ALU); + + IRQS = 2; + } + + private void JMP_EXT_() + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC, ALU2, PC, + SET_ADDR, PC, ALU, ALU2); + + IRQS = 3; + } + + private void JSR_() + { + PopulateCURINSTR(RD_INC, ALU, PC, + SET_ADDR, ADDR, DP, ALU, + DEC16, SP, + TR, PC, ADDR, + WR_DEC_LO, SP, ADDR, + WR_HI, SP, ADDR); + + IRQS = 6; + } + + private void JSR_EXT() + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, + TR, ALU, PC, + DEC16, SP, + TR, PC, ADDR, + WR_DEC_LO, SP, ALU, + WR_HI, SP, ALU); + + IRQS = 7; + } + + private void LBR_(bool cond) + { + if (cond) + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC, ALU2, PC, + SET_ADDR, ADDR, ALU, ALU2, + ADD16BR, PC, ADDR); + + IRQS = 4; + } + else + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC, ALU2, PC, + SET_ADDR, PC, ALU, ALU2); + + IRQS = 3; + } + } + + private void BR_(bool cond) + { + if (cond) + { + PopulateCURINSTR(RD_INC, ALU, PC, + ADD8BR, PC, ALU); + + IRQS = 2; + } + else + { + PopulateCURINSTR(RD_INC, ALU, PC, + IDLE); + + IRQS = 2; + } + } + + private void BSR_() + { + PopulateCURINSTR(RD_INC, ALU, PC, + TR, ADDR, PC, + ADD8BR, PC, ALU, + DEC16, SP, + WR_DEC_LO, SP, ADDR, + WR_HI, SP, ADDR); + + IRQS = 6; + } + + private void LBSR_() + { + PopulateCURINSTR(RD_INC, ALU, PC, + RD_INC, ALU2, PC, + SET_ADDR, ADDR, ALU, ALU2, + TR, ALU, PC, + ADD16BR, PC, ADDR, + DEC16, SP, + WR_DEC_LO, SP, ALU, + WR_HI, SP, ALU); + + IRQS = 8; + } + + private void PAGE_2() + { + PopulateCURINSTR(OP_PG_2); + + IRQS = -1; + } + + private void PAGE_3() + { + PopulateCURINSTR(OP_PG_3); + + IRQS = -1; + } + + private void ABX_() + { + PopulateCURINSTR(ABX, + IDLE); + + IRQS = 2; + } + + private void MUL_() + { + PopulateCURINSTR(MUL, + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + IDLE); + + IRQS = 10; + } + + private void RTS() + { + PopulateCURINSTR(IDLE, + RD_INC, ALU, SP, + RD_INC, ALU2, SP, + SET_ADDR, PC, ALU, ALU2); + + IRQS = 4; + } + + private void RTI() + { + PopulateCURINSTR(IDLE, + RD_INC_OP, CC, SP, JPE, + RD_INC, A, SP, + RD_INC, B, SP, + RD_INC, DP, SP, + RD_INC, ALU, SP, + RD_INC_OP, ALU2, SP, SET_ADDR, X, ALU, ALU2, + RD_INC, ALU, SP, + RD_INC_OP, ALU2, SP, SET_ADDR, Y, ALU, ALU2, + RD_INC, ALU, SP, + RD_INC_OP, ALU2, SP, SET_ADDR, US, ALU, ALU2, + RD_INC, ALU, SP, + RD_INC_OP, ALU2, SP, + SET_ADDR, PC, ALU, ALU2); + + IRQS = 14; + } + + private void PSH(ushort src) + { + PopulateCURINSTR(RD_INC, ALU, PC, + IDLE, + DEC16, SP, + PSH_n, src); + + IRQS = -1; + } + + // Post byte info is in ALU + // mask out bits until the end + private void PSH_n_BLD(ushort src) + { + if (Regs[ALU].Bit(7)) + { + PopulateCURINSTR(WR_DEC_LO, src, PC, + WR_DEC_HI_OP, src, PC, PSH_n, src); + + Regs[ALU] &= 0x7F; + } + else if (Regs[ALU].Bit(6)) + { + if (src == US) + { + PopulateCURINSTR(WR_DEC_LO, src, SP, + WR_DEC_HI_OP, src, SP, PSH_n, src); + } + else + { + PopulateCURINSTR(WR_DEC_LO, src, US, + WR_DEC_HI_OP, src, US, PSH_n, src); + } + + Regs[ALU] &= 0x3F; + } + else if (Regs[ALU].Bit(5)) + { + PopulateCURINSTR(WR_DEC_LO, src, Y, + WR_DEC_HI_OP, src, Y, PSH_n, src); + + Regs[ALU] &= 0x1F; + } + else if (Regs[ALU].Bit(4)) + { + PopulateCURINSTR(WR_DEC_LO, src, X, + WR_DEC_HI_OP, src, X, PSH_n, src); + + Regs[ALU] &= 0xF; + } + else if (Regs[ALU].Bit(3)) + { + PopulateCURINSTR(WR_DEC_LO_OP, src, DP, PSH_n, src); + + Regs[ALU] &= 0x7; + } + else if (Regs[ALU].Bit(2)) + { + PopulateCURINSTR(WR_DEC_LO_OP, src, B, PSH_n, src); + + Regs[ALU] &= 0x3; + } + else if (Regs[ALU].Bit(1)) + { + PopulateCURINSTR(WR_DEC_LO_OP, src, A, PSH_n, src); + + Regs[ALU] &= 0x1; + } + else if (Regs[ALU].Bit(0)) + { + PopulateCURINSTR(WR_DEC_LO_OP, src, CC, PSH_n, src); + + Regs[ALU] = 0; + } + else + { + Regs[src] += 1; // we decremented an extra time overall, regardless of what was run + + IRQS = irq_pntr + 1; + } + + instr_pntr = 0; + } + + private void PUL(ushort src) + { + PopulateCURINSTR(RD_INC, ALU, PC, + IDLE, + PUL_n, src); + + IRQS = -1; + } + + // Post byte info is in ALU + // mask out bits until the end + private void PUL_n_BLD(ushort src) + { + if (Regs[ALU].Bit(0)) + { + PopulateCURINSTR(RD_INC_OP, CC, src, PUL_n, src); + + Regs[ALU] &= 0xFE; + } + else if (Regs[ALU].Bit(1)) + { + PopulateCURINSTR(RD_INC_OP, A, src, PUL_n, src); + + Regs[ALU] &= 0xFC; + } + else if (Regs[ALU].Bit(2)) + { + PopulateCURINSTR(RD_INC_OP, B, src, PUL_n, src); + + Regs[ALU] &= 0xF8; + } + else if (Regs[ALU].Bit(3)) + { + PopulateCURINSTR(RD_INC_OP, DP, src, PUL_n, src); + + Regs[ALU] &= 0xF0; + } + else if (Regs[ALU].Bit(4)) + { + PopulateCURINSTR(RD_INC, ALU2, src, + RD_INC_OP, ADDR, src, SET_ADDR_PUL, X, src); + + Regs[ALU] &= 0xE0; + } + else if (Regs[ALU].Bit(5)) + { + PopulateCURINSTR(RD_INC, ALU2, src, + RD_INC_OP, ADDR, src, SET_ADDR_PUL, Y, src); + + Regs[ALU] &= 0xC0; + } + else if (Regs[ALU].Bit(6)) + { + if (src == US) + { + PopulateCURINSTR(RD_INC, ALU2, src, + RD_INC_OP, ADDR, src, SET_ADDR_PUL, SP, src); + } + else + { + PopulateCURINSTR(RD_INC, ALU2, src, + RD_INC_OP, ADDR, src, SET_ADDR_PUL, US, src); + } + + Regs[ALU] &= 0x80; + } + else if (Regs[ALU].Bit(7)) + { + PopulateCURINSTR(RD_INC, ALU2, src, + RD_INC_OP, ADDR, src, SET_ADDR_PUL, PC, src); + + Regs[ALU] = 0; + } + else + { + // extra end cycle + PopulateCURINSTR(IDLE); + + IRQS = irq_pntr + 2; + } + + instr_pntr = 0; + } + + private void SWI1() + { + Regs[ADDR] = 0xFFFA; + PopulateCURINSTR(SET_E, + DEC16, SP, + WR_DEC_LO, SP, PC, + WR_DEC_HI, SP, PC, + WR_DEC_LO, SP, US, + WR_DEC_HI, SP, US, + WR_DEC_LO, SP, Y, + WR_DEC_HI, SP, Y, + WR_DEC_LO, SP, X, + WR_DEC_HI, SP, X, + WR_DEC_LO, SP, DP, + WR_DEC_LO, SP, B, + WR_DEC_LO, SP, A, + WR, SP, CC, + SET_F_I, + RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, PC, ALU, ALU2); + + IRQS = 18; + } + + private void SWI2_3(ushort pick) + { + Regs[ADDR] = (ushort)((pick == 3) ? 0xFFF2 : 0xFFF4); + PopulateCURINSTR(SET_E, + DEC16, SP, + WR_DEC_LO, SP, PC, + WR_DEC_HI, SP, PC, + WR_DEC_LO, SP, US, + WR_DEC_HI, SP, US, + WR_DEC_LO, SP, Y, + WR_DEC_HI, SP, Y, + WR_DEC_LO, SP, X, + WR_DEC_HI, SP, X, + WR_DEC_LO, SP, DP, + WR_DEC_LO, SP, B, + WR_DEC_LO, SP, A, + WR, SP, CC, + IDLE, + RD_INC, ALU, ADDR, + RD_INC, ALU2, ADDR, + SET_ADDR, PC, ALU, ALU2); + + IRQS = 18; + } + + private void CWAI_() + { + PopulateCURINSTR(RD_INC_OP, ALU, PC, ANDCC, ALU, + SET_E, + DEC16, SP, + WR_DEC_LO, SP, PC, + WR_DEC_HI, SP, PC, + WR_DEC_LO, SP, US, + WR_DEC_HI, SP, US, + WR_DEC_LO, SP, Y, + WR_DEC_HI, SP, Y, + WR_DEC_LO, SP, X, + WR_DEC_HI, SP, X, + WR_DEC_LO, SP, DP, + WR_DEC_LO, SP, B, + WR_DEC_LO, SP, A, + WR, SP, CC, + CWAI); + + IRQS = 16; + } + } +} diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/Operations.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/Operations.cs new file mode 100644 index 0000000000..6ce7fb9836 --- /dev/null +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/Operations.cs @@ -0,0 +1,736 @@ +using System; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Common.Components.MC6809 +{ + public partial class MC6809 + { + public void Read_Func(ushort dest, ushort src) + { + if (CDLCallback != null) + { + if (src == PC) CDLCallback(Regs[src], eCDLogMemFlags.FetchOperand); + else CDLCallback(Regs[src], eCDLogMemFlags.Data); + } + Regs[dest] = ReadMemory(Regs[src]); + } + + public void Read_Inc_Func(ushort dest, ushort src) + { + if (CDLCallback != null) + { + if (src == PC) CDLCallback(Regs[src], eCDLogMemFlags.FetchOperand); + else CDLCallback(Regs[src], eCDLogMemFlags.Data); + } + //Console.WriteLine(dest + " " + src + " " + opcode_see); + + Regs[dest] = ReadMemory(Regs[src]); + + Regs[src]++; + } + + public void Write_Func(ushort dest, ushort src) + { + if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + WriteMemory(Regs[dest], (byte)Regs[src]); + } + + public void Write_Dec_Lo_Func(ushort dest, ushort src) + { + if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + WriteMemory(Regs[dest], (byte)Regs[src]); + Regs[dest] -= 1; + } + + public void Write_Dec_HI_Func(ushort dest, ushort src) + { + if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + WriteMemory(Regs[dest], (byte)(Regs[src] >> 8)); + Regs[dest] -= 1; + } + + public void Write_Hi_Func(ushort dest, ushort src) + { + if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + WriteMemory(Regs[dest], (byte)(Regs[src] >> 8)); + } + + public void Write_Hi_Inc_Func(ushort dest, ushort src) + { + if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + WriteMemory(Regs[dest], (byte)(Regs[src] >> 8)); + Regs[dest]++; + } + + public void NEG_8_Func(ushort src) + { + int Reg16_d = 0; + Reg16_d -= Regs[src]; + + FlagC = Regs[src] != 0x0; + FlagZ = (Reg16_d & 0xFF) == 0; + FlagV = Regs[src] == 0x80; + FlagN = (Reg16_d & 0xFF) > 127; + + ushort ans = (ushort)(Reg16_d & 0xFF); + // redo for half carry flag + Reg16_d = 0; + Reg16_d -= (Regs[src] & 0xF); + FlagH = Reg16_d.Bit(4); + Regs[src] = ans; + } + + public void TR_Func(ushort dest, ushort src) + { + Regs[dest] = Regs[src]; + } + + public void LD_8_Func(ushort dest, ushort src) + { + Regs[dest] = Regs[src]; + + FlagZ = (Regs[dest] & 0xFF) == 0; + FlagV = false; + FlagN = (Regs[dest] & 0xFF) > 127; + } + + public void LD_16_Func(ushort dest, ushort src_h, ushort src_l) + { + Regs[dest] = (ushort)(Regs[src_h] << 8 | Regs[src_l]); + + FlagZ = Regs[dest] == 0; + FlagV = false; + FlagN = Regs[dest] > 0x7FFF; + } + + // for LEAX/Y, zero flag can be effected, but not for U/S + public void LEA_Func(ushort dest, ushort src) + { + Regs[dest] = Regs[src]; + + if ((dest == X) || (dest == Y)) + { + FlagZ = Regs[dest] == 0; + } + } + + public void TST_Func(ushort src) + { + FlagZ = Regs[src] == 0; + FlagV = false; + FlagN = (Regs[src] & 0xFF) > 127; + } + + public void CLR_Func(ushort src) + { + Regs[src] = 0; + + FlagZ = true; + FlagV = false; + FlagC = false; + FlagN = false; + } + + // source is considered a 16 bit signed value, used for long relative branch + // no flags used + public void ADD16BR_Func(ushort dest, ushort src) + { + Regs[dest] = (ushort)(Regs[dest] + (short)Regs[src]); + } + + public void ADD8BR_Func(ushort dest, ushort src) + { + if (Regs[src] > 127) { Regs[src] |= 0xFF00; } + Regs[dest] = (ushort)(Regs[dest] + (short)Regs[src]); + } + + public void Mul_Func() + { + Regs[ALU] = (ushort)(Regs[A] * Regs[B]); + D = Regs[ALU]; + FlagC = Regs[A] > 127; + FlagZ = D == 0; + } + + public void ADD8_Func(ushort dest, ushort src) + { + int Reg16_d = Regs[dest]; + Reg16_d += Regs[src]; + + FlagC = Reg16_d.Bit(8); + FlagZ = (Reg16_d & 0xFF) == 0; + + ushort ans = (ushort)(Reg16_d & 0xFF); + + // redo for half carry flag + Reg16_d = Regs[dest] & 0xF; + Reg16_d += (Regs[src] & 0xF); + + FlagH = Reg16_d.Bit(4); + FlagV = (Regs[dest].Bit(7) != Regs[src].Bit(7)) && (Regs[dest].Bit(7) != ans.Bit(7)); + FlagN = false; + + Regs[dest] = ans; + } + + public void SUB8_Func(ushort dest, ushort src) + { + int Reg16_d = Regs[dest]; + Reg16_d -= Regs[src]; + + FlagC = Reg16_d.Bit(8); + FlagZ = (Reg16_d & 0xFF) == 0; + + ushort ans = (ushort)(Reg16_d & 0xFF); + + // redo for half carry flag + Reg16_d = Regs[dest] & 0xF; + Reg16_d -= (Regs[src] & 0xF); + + FlagH = Reg16_d.Bit(4); + FlagN = ans > 127; + FlagV = (Regs[dest].Bit(7) != Regs[src].Bit(7)) && (Regs[dest].Bit(7) != ans.Bit(7)); + + Regs[dest] = ans; + } + + // same as SUB8 but result not stored + public void CMP8_Func(ushort dest, ushort src) + { + int Reg16_d = Regs[dest]; + Reg16_d -= Regs[src]; + + FlagC = Reg16_d.Bit(8); + FlagZ = (Reg16_d & 0xFF) == 0; + + ushort ans = (ushort)(Reg16_d & 0xFF); + + // redo for half carry flag + Reg16_d = Regs[dest] & 0xF; + Reg16_d -= (Regs[src] & 0xF); + + FlagH = Reg16_d.Bit(4); + FlagN = ans > 127; + FlagV = (Regs[dest].Bit(7) != Regs[src].Bit(7)) && (Regs[dest].Bit(7) != ans.Bit(7)); + } + + public void BIT_Func(ushort dest, ushort src) + { + ushort ans = (ushort)(Regs[dest] & Regs[src]); + + FlagZ = ans == 0; + FlagV = false; + FlagN = ans > 127; + } + + public void ASL_Func(ushort src) + { + FlagC = Regs[src].Bit(7); + FlagV = Regs[src].Bit(7) ^ Regs[src].Bit(6); + + Regs[src] = (ushort)((Regs[src] << 1) & 0xFF); + + FlagZ = Regs[src] == 0; + FlagH = false; + FlagN = (Regs[src] & 0xFF) > 127; + + } + + public void ASR_Func(ushort src) + { + FlagC = Regs[src].Bit(0); + + ushort temp = (ushort)(Regs[src] & 0x80); // MSB doesn't change in this operation + + Regs[src] = (ushort)((Regs[src] >> 1) | temp); + + FlagZ = Regs[src] == 0; + FlagH = false; + FlagN = (Regs[src] & 0xFF) > 127; + } + + public void LSR_Func(ushort src) + { + FlagC = Regs[src].Bit(0); + + Regs[src] = (ushort)(Regs[src] >> 1); + + FlagZ = Regs[src] == 0; + FlagN = false; + } + + public void COM_Func(ushort src) + { + Regs[src] = (ushort)((~Regs[src]) & 0xFF); + + FlagC = true; + FlagZ = Regs[src] == 0; + FlagV = false; + FlagN = (Regs[src] & 0xFF) > 127; + } + + public void SEX_Func(ushort src) + { + if (Regs[B] > 127) + { + Regs[A] = 0xFF; + } + else + { + Regs[A] = 0; + } + + FlagZ = D == 0; + FlagN = Regs[A] > 127; + } + + public void AND8_Func(ushort dest, ushort src) + { + Regs[dest] = (ushort)(Regs[dest] & Regs[src]); + + FlagZ = Regs[dest] == 0; + FlagV = false; + FlagN = Regs[dest] > 127; + } + + public void OR8_Func(ushort dest, ushort src) + { + Regs[dest] = (ushort)(Regs[dest] | Regs[src]); + + FlagZ = Regs[dest] == 0; + FlagV = false; + FlagN = Regs[dest] > 127; + } + + public void XOR8_Func(ushort dest, ushort src) + { + Regs[dest] = (ushort)(Regs[dest] ^ Regs[src]); + + FlagZ = Regs[dest] == 0; + FlagV = false; + FlagN = Regs[dest] > 127; + } + + public void CP8_Func(ushort dest, ushort src) + { + int Reg16_d = Regs[dest]; + Reg16_d -= Regs[src]; + + FlagC = Reg16_d.Bit(8); + FlagZ = (Reg16_d & 0xFF) == 0; + + // redo for half carry flag + Reg16_d = Regs[dest] & 0xF; + Reg16_d -= (Regs[src] & 0xF); + + FlagH = Reg16_d.Bit(4); + + FlagN = true; + } + + public void ROR_Func(ushort src) + { + ushort c = (ushort)(FlagC ? 0x80 : 0); + + FlagC = Regs[src].Bit(0); + + Regs[src] = (ushort)(c | (Regs[src] >> 1)); + + FlagZ = Regs[src] == 0; + FlagN = (Regs[src] & 0xFF) > 127; + } + + public void ROL_Func(ushort src) + { + ushort c = (ushort)(FlagC ? 1 : 0); + FlagC = Regs[src].Bit(7); + FlagV = Regs[src].Bit(7) ^ Regs[src].Bit(6); + + + Regs[src] = (ushort)(((Regs[src] << 1) & 0xFF) | c); + + FlagZ = Regs[src] == 0; + FlagN = (Regs[src] & 0xFF) > 127; + } + + public void INC8_Func(ushort src) + { + FlagV = Regs[src] == 0x7F; + + Regs[src] = (ushort)((Regs[src] + 1) & 0xFF); + + FlagZ = Regs[src] == 0; + FlagN = (Regs[src] & 0xFF) > 127; + } + + public void DEC8_Func(ushort src) + { + FlagV = Regs[src] == 0x80; + + Regs[src] = (ushort)((Regs[src] - 1) & 0xFF); + + FlagZ = Regs[src] == 0; + FlagN = (Regs[src] & 0xFF) > 127; + } + + public void INC16_Func(ushort src) + { + Regs[src] += 1; + } + + public void DEC16_Func(ushort src) + { + Regs[src] -= 1; + } + + public void ADC8_Func(ushort dest, ushort src) + { + int Reg16_d = Regs[dest]; + int c = FlagC ? 1 : 0; + + Reg16_d += (Regs[src] + c); + + FlagC = Reg16_d.Bit(8); + FlagZ = (Reg16_d & 0xFF) == 0; + + ushort ans = (ushort)(Reg16_d & 0xFF); + + // redo for half carry flag + Reg16_d = Regs[dest] & 0xF; + Reg16_d += ((Regs[src] & 0xF) + c); + + FlagH = Reg16_d.Bit(4); + FlagV = (Regs[dest].Bit(7) != Regs[src].Bit(7)) && (Regs[dest].Bit(7) != ans.Bit(7)); + FlagN = false; + + Regs[dest] = ans; + } + + public void SBC8_Func(ushort dest, ushort src) + { + int Reg16_d = Regs[dest]; + int c = FlagC ? 1 : 0; + + Reg16_d -= (Regs[src] + c); + + FlagC = Reg16_d.Bit(8); + FlagZ = (Reg16_d & 0xFF) == 0; + + ushort ans = (ushort)(Reg16_d & 0xFF); + + // redo for half carry flag + Reg16_d = Regs[dest] & 0xF; + Reg16_d -= ((Regs[src] & 0xF) + c); + + FlagH = Reg16_d.Bit(4); + FlagN = ans > 127; + FlagV = (Regs[dest].Bit(7) != Regs[src].Bit(7)) && (Regs[dest].Bit(7) != ans.Bit(7)); + + Regs[dest] = ans; + } + + // DA code courtesy of AWJ: http://forums.nesdev.com/viewtopic.php?f=20&t=15944 + public void DA_Func(ushort src) + { + byte a = (byte)Regs[src]; + + if (!FlagN) + { // after an addition, adjust if (half-)carry occurred or if result is out of bounds + if (FlagC || a > 0x99) { a += 0x60; FlagC = true; } + if (FlagH || (a & 0x0f) > 0x09) { a += 0x6; } + } + else + { // after a subtraction, only adjust if (half-)carry occurred + if (FlagC) { a -= 0x60; } + if (FlagH) { a -= 0x6; } + } + + a &= 0xFF; + + Regs[src] = a; + + FlagZ = a == 0; + FlagH = false; + } + + // used for signed operations + public void ADDS_Func(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) + { + int Reg16_d = Regs[dest_l]; + int Reg16_s = Regs[src_l]; + + Reg16_d += Reg16_s; + + ushort temp = 0; + + // since this is signed addition, calculate the high byte carry appropriately + if (Reg16_s.Bit(7)) + { + if (((Reg16_d & 0xFF) >= Regs[dest_l])) + { + temp = 0xFF; + } + else + { + temp = 0; + } + } + else + { + temp = (ushort)(Reg16_d.Bit(8) ? 1 : 0); + } + + ushort ans_l = (ushort)(Reg16_d & 0xFF); + + // JR operations do not effect flags + if (dest_l != PC) + { + FlagC = Reg16_d.Bit(8); + + // redo for half carry flag + Reg16_d = Regs[dest_l] & 0xF; + Reg16_d += Regs[src_l] & 0xF; + + FlagH = Reg16_d.Bit(4); + FlagN = false; + FlagZ = false; + } + + Regs[dest_l] = ans_l; + Regs[dest_h] += temp; + Regs[dest_h] &= 0xFF; + + } + + // D register implied + public void SUB16_Func(ushort src) + { + int Reg16_d = D; + int Reg16_s = Regs[src]; + + Reg16_d -= Reg16_s; + + FlagC = Reg16_d.Bit(16); + FlagZ = (Reg16_d & 0xFFFF) == 0; + + ushort ans = (ushort)(Reg16_d & 0xFFFF); + + FlagN = ans > 0x7FFF; + FlagV = (D.Bit(15) != Regs[src].Bit(15)) && (D.Bit(15) != ans.Bit(15)); + + D = ans; + } + + // D register implied + public void ADD16_Func(ushort src) + { + int Reg16_d = D; + int Reg16_s = Regs[src]; + + Reg16_d += Reg16_s; + + FlagC = Reg16_d.Bit(16); + FlagZ = (Reg16_d & 0xFFFF) == 0; + + ushort ans = (ushort)(Reg16_d & 0xFFFF); + + FlagN = ans > 0x7FFF; + FlagV = (D.Bit(15) != Regs[src].Bit(15)) && (D.Bit(15) != ans.Bit(15)); + + D = ans; + } + + // D register implied + public void CMP16D_Func(ushort src) + { + int Reg16_d = D; + int Reg16_s = Regs[src]; + + Reg16_d -= Reg16_s; + + FlagC = Reg16_d.Bit(16); + FlagZ = (Reg16_d & 0xFFFF) == 0; + + ushort ans = (ushort)(Reg16_d & 0xFFFF); + + FlagN = ans > 0x7FFF; + FlagV = (D.Bit(15) != Regs[src].Bit(15)) && (D.Bit(15) != ans.Bit(15)); + } + + public void CMP16_Func(ushort dest, ushort src) + { + int Reg16_d = Regs[dest]; + int Reg16_s = Regs[src]; + + Reg16_d -= Reg16_s; + + FlagC = Reg16_d.Bit(16); + FlagZ = (Reg16_d & 0xFFFF) == 0; + + ushort ans = (ushort)(Reg16_d & 0xFFFF); + + FlagN = ans > 0x7FFF; + FlagV = (Regs[dest].Bit(15) != Regs[src].Bit(15)) && (Regs[dest].Bit(15) != ans.Bit(15)); + } + + public void EXG_Func(ushort sel) + { + ushort src = 0; + ushort dest = 0; + ushort temp = 0; + if ((Regs[sel] & 0x8) == 0) + { + switch (Regs[sel] & 0xF) + { + case 0: src = Dr; break; + case 1: src = X; break; + case 2: src = Y; break; + case 3: src = US; break; + case 4: src = SP; break; + case 5: src = PC; break; + case 6: src = 0xFF; break; + case 7: src = 0xFF; break; + } + + switch ((Regs[sel] >> 4) & 0xF) + { + case 0: dest = Dr; break; + case 1: dest = X; break; + case 2: dest = Y; break; + case 3: dest = US; break; + case 4: dest = SP; break; + case 5: dest = PC; break; + case 6: dest = 0xFF; break; + case 7: dest = 0xFF; break; + default: dest = 0xFF; break; + } + } + else + { + switch (Regs[sel] & 0xF) + { + case 8: src = A; break; + case 9: src = B; break; + case 10: src = CC; break; + case 11: src = DP; break; + case 12: src = 0xFF; break; + case 13: src = 0xFF; break; + case 14: src = 0xFF; break; + case 15: src = 0xFF; break; + } + + switch ((Regs[sel] >> 4) & 0xF) + { + case 8: dest = A; break; + case 9: dest = B; break; + case 10: dest = CC; break; + case 11: dest = DP; break; + case 12: dest = 0xFF; break; + case 13: dest = 0xFF; break; + case 14: dest = 0xFF; break; + case 15: dest = 0xFF; break; + default: dest = 0xFF; break; + } + } + + if ((src != 0xFF) && (dest != 0xFF)) + { + if (src == Dr) + { + temp = D; + D = Regs[dest]; + Regs[dest] = temp; + } + else if (dest == Dr) + { + temp = D; + D = Regs[src]; + Regs[src] = temp; + } + else + { + temp = Regs[src]; + Regs[src] = Regs[dest]; + Regs[dest] = temp; + } + } + } + + public void TFR_Func(ushort sel) + { + ushort src = 0; + ushort dest = 0; + + if ((Regs[sel] & 0x8) == 0) + { + switch (Regs[sel] & 0xF) + { + case 0: dest = Dr; break; + case 1: dest = X; break; + case 2: dest = Y; break; + case 3: dest = US; break; + case 4: dest = SP; break; + case 5: dest = PC; break; + case 6: dest = 0xFF; break; + case 7: dest = 0xFF; break; + } + + switch ((Regs[sel] >> 4) & 0xF) + { + case 0: src = Dr; break; + case 1: src = X; break; + case 2: src = Y; break; + case 3: src = US; break; + case 4: src = SP; break; + case 5: src = PC; break; + case 6: src = 0xFF; break; + case 7: src = 0xFF; break; + default: src = 0xFF; break; + } + } + else + { + switch (Regs[sel] & 0xF) + { + case 8: dest = A; break; + case 9: dest = B; break; + case 10: dest = CC; break; + case 11: dest = DP; break; + case 12: dest = 0xFF; break; + case 13: dest = 0xFF; break; + case 14: dest = 0xFF; break; + case 15: dest = 0xFF; break; + } + + switch ((Regs[sel] >> 4) & 0xF) + { + case 8: src = A; break; + case 9: src = B; break; + case 10: src = CC; break; + case 11: src = DP; break; + case 12: src = 0xFF; break; + case 13: src = 0xFF; break; + case 14: src = 0xFF; break; + case 15: src = 0xFF; break; + default: src = 0xFF; break; + } + } + + if ((src != 0xFF) && (dest != 0xFF)) + { + if (src == Dr) + { + Regs[dest] = D; + } + else if (dest == Dr) + { + D = Regs[src]; + } + else + { + Regs[dest] = Regs[src]; + } + } + } + } +} diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/ReadMe.txt b/BizHawk.Emulation.Cores/CPUs/MC6809/ReadMe.txt new file mode 100644 index 0000000000..115b568cb8 --- /dev/null +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/ReadMe.txt @@ -0,0 +1 @@ +TODO: STOP for second byte nonzero diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/Registers.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/Registers.cs new file mode 100644 index 0000000000..78a30cb2f1 --- /dev/null +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/Registers.cs @@ -0,0 +1,87 @@ +using System; + +namespace BizHawk.Emulation.Common.Components.MC6809 +{ + public partial class MC6809 + { + // registers + public ushort[] Regs = new ushort[14]; + + public const ushort PC = 0; + public const ushort US = 1; + public const ushort SP = 2; + public const ushort X = 3; + public const ushort Y = 4; + public const ushort A = 5; + public const ushort B = 6; + public const ushort ADDR = 7; // internal + public const ushort ALU = 8; // internal + public const ushort ALU2 = 9; // internal + public const ushort DP = 10; + public const ushort CC = 11; + public const ushort Dr = 12; + public const ushort IDX_EA = 13; + + public ushort D + { + get { return (ushort)(Regs[B] | (Regs[A] << 8)); } + set { Regs[B] = (ushort)(value & 0xFF); Regs[A] = (ushort)((value >> 8) & 0xFF); } + } + + public bool FlagC + { + get { return (Regs[CC] & 0x01) != 0; } + set { Regs[CC] = (byte)((Regs[CC] & ~0x01) | (value ? 0x01 : 0x00)); } + } + + public bool FlagV + { + get { return (Regs[CC] & 0x02) != 0; } + set { Regs[CC] = (byte)((Regs[CC] & ~0x02) | (value ? 0x02 : 0x00)); } + } + + public bool FlagZ + { + get { return (Regs[CC] & 0x04) != 0; } + set { Regs[CC] = (byte)((Regs[CC] & ~0x04) | (value ? 0x04 : 0x00)); } + } + + public bool FlagN + { + get { return (Regs[CC] & 0x08) != 0; } + set { Regs[CC] = (byte)((Regs[CC] & ~0x08) | (value ? 0x08 : 0x00)); } + } + + public bool FlagI + { + get { return (Regs[CC] & 0x10) != 0; } + set { Regs[CC] = (byte)((Regs[CC] & ~0x10) | (value ? 0x10 : 0x00)); } + } + + public bool FlagH + { + get { return (Regs[CC] & 0x20) != 0; } + set { Regs[CC] = (byte)((Regs[CC] & ~0x20) | (value ? 0x20 : 0x00)); } + } + + public bool FlagF + { + get { return (Regs[CC] & 0x40) != 0; } + set { Regs[CC] = (byte)((Regs[CC] & ~0x40) | (value ? 0x40 : 0x00)); } + } + + public bool FlagE + { + get { return (Regs[CC] & 0x80) != 0; } + set { Regs[CC] = (byte)((Regs[CC] & ~0x80) | (value ? 0x80 : 0x00)); } + } + + private void ResetRegisters() + { + for (int i = 0; i < 14; i++) + { + Regs[i] = 0; + } + } + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs index 2b0965e0ed..5fc328f146 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs @@ -126,28 +126,28 @@ namespace BizHawk.Emulation.Cores.Components.M6502 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.Sync("ext_ppu_cycle", ref ext_ppu_cycle); + 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/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/Z80A.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs index 6de41ae296..8560300319 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs @@ -839,38 +839,38 @@ namespace BizHawk.Emulation.Cores.Components.Z80A // 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); - 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.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.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.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/AppleII/AppleII.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs index 45eca4f1b9..938e521207 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs @@ -115,8 +115,8 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII } private static readonly List RealButtons = new List(Keyboard.GetKeyNames() - .Where(k => k != "White Apple") // Hack because these buttons aren't wired up yet - .Where(k => k != "Black Apple") + //.Where(k => k != "White Apple") // Hack because these buttons aren't wired up yet + //.Where(k => k != "Black Apple") .Where(k => k != "Reset")); private static readonly List ExtraButtons = new List 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 3ae4eafd72..e18c3ae68e 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using BizHawk.Emulation.Cores.Sound; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -16,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum private SpectrumBase _machine { get; set; } private Z80A _cpu { get; set; } - private IBeeperDevice _buzzer { get; set; } + private OneBitBeeper _buzzer { get; set; } /// /// Default constructor @@ -983,19 +984,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 77cb18d38c..36a55e3d29 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/StandardKeyboard.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Input/StandardKeyboard.cs @@ -278,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 deleted file mode 100644 index a3f5dec9c4..0000000000 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/SoundOuput/Beeper.cs +++ /dev/null @@ -1,216 +0,0 @@ -using BizHawk.Common; -using BizHawk.Emulation.Common; -using System; - -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) - /// - public class Beeper : ISoundProvider, IBeeperDevice - { - #region Fields and Properties - - /// - /// Sample Rate - /// This usually has to be 44100 for ISoundProvider - /// - private int _sampleRate; - public int SampleRate - { - get { return _sampleRate; } - set { _sampleRate = value; } - } - - /// - /// Buzzer volume - /// Accepts an int 0-100 value - /// - private int _volume; - public int Volume - { - get - { - return VolumeConverterOut(_volume); - } - set - { - var newVol = VolumeConverterIn(value); - if (newVol != _volume) - blip.Clear(); - _volume = VolumeConverterIn(value); - } - } - - /// - /// The last used volume (used to modify blipbuffer delta values) - /// - private int lastVolume; - - /// - /// The number of cpu cycles per frame - /// - private long _tStatesPerFrame; - - /// - /// The parent emulated machine - /// - private SpectrumBase _machine; - - /// - /// The last pulse - /// - private bool LastPulse; - - /// - /// The last T-State (cpu cycle) that the last pulse was received - /// - private long LastPulseTState; - - /// - /// Device blipbuffer - /// - private readonly BlipBuffer blip = new BlipBuffer(882); - - #endregion - - #region Private Methods - - /// - /// Takes an int 0-100 and returns the relevant short volume to output - /// - /// - /// - private int VolumeConverterIn(int vol) - { - int maxLimit = short.MaxValue / 3; - int increment = maxLimit / 100; - - return vol * increment; - } - - /// - /// Takes an short volume and returns the relevant int value 0-100 - /// - /// - /// - private int VolumeConverterOut(int shortvol) - { - int maxLimit = short.MaxValue / 3; - int increment = maxLimit / 100; - - if (shortvol > maxLimit) - shortvol = maxLimit; - - return shortvol / increment; - } - - #endregion - - #region Construction & Initialisation - - public Beeper(SpectrumBase machine) - { - _machine = machine; - } - - /// - /// Initialises the beeper - /// - public void Init(int sampleRate, int tStatesPerFrame) - { - blip.SetRates((tStatesPerFrame * 50), sampleRate); - _sampleRate = sampleRate; - _tStatesPerFrame = tStatesPerFrame; - } - - #endregion - - #region IBeeperDevice - - /// - /// Processes an incoming pulse value and adds it to the blipbuffer - /// - /// - public void ProcessPulseValue(bool pulse) - { - if (!_machine._renderSound) - return; - - if (LastPulse == pulse) - { - // no change - blip.AddDelta((uint)_machine.CurrentFrameCycle, 0); - } - - else - { - if (pulse) - blip.AddDelta((uint)_machine.CurrentFrameCycle, (short)(_volume)); - else - blip.AddDelta((uint)_machine.CurrentFrameCycle, -(short)(_volume)); - - lastVolume = _volume; - } - - LastPulse = pulse; - } - - #endregion - - #region ISoundProvider - - public bool CanProvideAsync => false; - - public SyncSoundMode SyncMode => SyncSoundMode.Sync; - - public void SetSyncMode(SyncSoundMode mode) - { - if (mode != SyncSoundMode.Sync) - throw new InvalidOperationException("Only Sync mode is supported."); - } - - public void GetSamplesAsync(short[] samples) - { - throw new NotSupportedException("Async is not available"); - } - - public void DiscardSamples() - { - blip.Clear(); - } - - public void GetSamplesSync(out short[] samples, out int nsamp) - { - blip.EndFrame((uint)_tStatesPerFrame); - nsamp = blip.SamplesAvailable(); - samples = new short[nsamp * 2]; - blip.ReadSamples(samples, nsamp, true); - for (int i = 0; i < nsamp * 2; i += 2) - { - samples[i + 1] = samples[i]; - } - } - - #endregion - - #region State Serialization - - 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.EndSection(); - } - - #endregion - } -} diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/CPUMonitor.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/CPUMonitor.cs index e163d88682..b18ad12a2c 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/CPUMonitor.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/CPUMonitor.cs @@ -97,7 +97,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } } - _cpu.ExecuteOne(); + _cpu.ExecuteOne(); } /// @@ -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/Pentagon128K/Pentagon128.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.Port.cs index 033ca1f29d..d4507749ff 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.Port.cs @@ -162,9 +162,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ULADevice.BorderColor = value & BORDER_BIT; } - // Buzzer - BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0); - TapeDevice.WritePort(port, value); + // Buzzer + BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0, _renderSound); + TapeDevice.WritePort(port, value); // Tape //TapeDevice.ProcessMicBit((value & MIC_BIT) != 0); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.cs index ea76f7a511..c46e265ccf 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BizHawk.Emulation.Cores.Components.Z80A; +using BizHawk.Emulation.Cores.Sound; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -30,11 +31,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ULADevice = new ScreenPentagon128(this); - BuzzerDevice = new Beeper(this); - BuzzerDevice.Init(44100, ULADevice.FrameLength); + BuzzerDevice = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "SystemBuzzer"); - TapeBuzzer = new Beeper(this); - TapeBuzzer.Init(44100, ULADevice.FrameLength); + TapeBuzzer = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "TapeBuzzer"); AYDevice = new AY38912(this); AYDevice.Init(44100, ULADevice.FrameLength); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs index a03e22ed25..56db60c5b0 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs @@ -1,5 +1,6 @@ using BizHawk.Common; using BizHawk.Emulation.Cores.Components.Z80A; +using BizHawk.Emulation.Cores.Sound; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -40,12 +41,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// The spectrum buzzer/beeper /// - public IBeeperDevice BuzzerDevice { get; set; } + public OneBitBeeper BuzzerDevice { get; set; } /// /// A second beeper for the tape /// - public IBeeperDevice TapeBuzzer { get; set; } + public OneBitBeeper TapeBuzzer { get; set; } /// /// Device representing the AY-3-8912 chip found in the 128k and up spectrums @@ -164,8 +165,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // run the CPU Monitor cycle CPUMon.ExecuteCycle(); - // cycle the tape device - if (UPDDiskDevice == null || !UPDDiskDevice.FDD_IsDiskLoaded) + // clock the beepers + TapeBuzzer.SetClock((int)CurrentFrameCycle); + BuzzerDevice.SetClock((int)CurrentFrameCycle); + + // cycle the tape device + if (UPDDiskDevice == null || !UPDDiskDevice.FDD_IsDiskLoaded) TapeDevice.TapeCycle(); // has frame end been reached? @@ -321,34 +326,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); @@ -362,7 +367,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; @@ -373,7 +378,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 5951326a93..6ab1341a93 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULA.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULA.cs @@ -940,7 +940,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum return croppedBuffer; case ZXSpectrum.BorderType.None: - // all border sizes now 24 + // all border sizes now 0 var lR__ = BorderLeftWidth; var rR__ = BorderRightWidth; var tR__ = BorderTopHeight; @@ -1035,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/ZXSpectrum128K/ZX128.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs index 1ec92a69f6..c1839dcaf3 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.Port.cs @@ -157,9 +157,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ULADevice.BorderColor = value & BORDER_BIT; } - // Buzzer - BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0); - TapeDevice.WritePort(port, value); + // Buzzer + BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0, _renderSound); + TapeDevice.WritePort(port, value); // Tape //TapeDevice.ProcessMicBit((value & MIC_BIT) != 0); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs index 009c882d38..2a3884c9b2 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using BizHawk.Emulation.Cores.Components.Z80A; +using BizHawk.Emulation.Cores.Sound; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -30,13 +31,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ULADevice = new Screen128(this); - BuzzerDevice = new Beeper(this); - BuzzerDevice.Init(44100, ULADevice.FrameLength); + BuzzerDevice = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "SystemBuzzer"); - TapeBuzzer = new Beeper(this); - TapeBuzzer.Init(44100, ULADevice.FrameLength); + TapeBuzzer = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "TapeBuzzer"); - AYDevice = new AY38912(this); + AYDevice = new AY38912(this); AYDevice.Init(44100, ULADevice.FrameLength); KeyboardDevice = new StandardKeyboard(this); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Port.cs index 7d6a6a53a4..1e3af11048 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Port.cs @@ -157,11 +157,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ULADevice.BorderColor = value & BORDER_BIT; } - // Buzzer - BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0); + // Buzzer + BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0, _renderSound); - // Tape - TapeDevice.WritePort(port, value); + // Tape + TapeDevice.WritePort(port, value); // Tape //TapeDevice.ProcessMicBit((value & MIC_BIT) != 0); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.cs index b38ba2ef0a..ffde2726f7 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.cs @@ -1,5 +1,6 @@ using BizHawk.Emulation.Cores.Components.Z80A; using System.Collections.Generic; +using BizHawk.Emulation.Cores.Sound; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -30,13 +31,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ULADevice = new Screen128Plus2a(this); - BuzzerDevice = new Beeper(this); - BuzzerDevice.Init(44100, ULADevice.FrameLength); + BuzzerDevice = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "SystemBuzzer"); - TapeBuzzer = new Beeper(this); - TapeBuzzer.Init(44100, ULADevice.FrameLength); + TapeBuzzer = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "TapeBuzzer"); - AYDevice = new AY38912(this); + AYDevice = new AY38912(this); AYDevice.Init(44100, ULADevice.FrameLength); KeyboardDevice = new StandardKeyboard(this); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Port.cs index ac662665d3..eb87580a99 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Port.cs @@ -164,11 +164,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ULADevice.BorderColor = value & BORDER_BIT; } - // Buzzer - BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0); + // Buzzer + BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0, _renderSound); - // Tape - TapeDevice.WritePort(port, value); + // Tape + TapeDevice.WritePort(port, value); // Tape //TapeDevice.ProcessMicBit((value & MIC_BIT) != 0); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs index f681ec3bd0..98576ab5a4 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs @@ -1,5 +1,6 @@ using BizHawk.Emulation.Cores.Components.Z80A; using System.Collections.Generic; +using BizHawk.Emulation.Cores.Sound; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -30,13 +31,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ULADevice = new Screen128Plus2a(this); - BuzzerDevice = new Beeper(this); - BuzzerDevice.Init(44100, ULADevice.FrameLength); + BuzzerDevice = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "SystemBuzzer"); - TapeBuzzer = new Beeper(this); - TapeBuzzer.Init(44100, ULADevice.FrameLength); + TapeBuzzer = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "TapeBuzzer"); - AYDevice = new AY38912(this); + AYDevice = new AY38912(this); AYDevice.Init(44100, ULADevice.FrameLength); KeyboardDevice = new StandardKeyboard(this); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs index b6d175028b..75aa48425b 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Port.cs @@ -91,7 +91,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } // Buzzer - BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0); + BuzzerDevice.ProcessPulseValue((value & EAR_BIT) != 0, _renderSound); // Tape TapeDevice.WritePort(port, value); diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.cs index 3291f5c20a..caf5ee440f 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.cs @@ -1,6 +1,7 @@ using BizHawk.Emulation.Cores.Components.Z80A; using System; using System.Collections.Generic; +using BizHawk.Emulation.Cores.Sound; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -24,13 +25,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum CPUMon = new CPUMonitor(this); ULADevice = new Screen48(this); - BuzzerDevice = new Beeper(this); - BuzzerDevice.Init(44100, ULADevice.FrameLength); + BuzzerDevice = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "SystemBuzzer"); - TapeBuzzer = new Beeper(this); - TapeBuzzer.Init(44100, ULADevice.FrameLength); + TapeBuzzer = new OneBitBeeper(44100, ULADevice.FrameLength, 50, "TapeBuzzer"); - KeyboardDevice = new StandardKeyboard(this); + KeyboardDevice = new StandardKeyboard(this); InitJoysticks(joysticks); 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/SoundProviderMixer.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/SoundProviderMixer.cs deleted file mode 100644 index 55df2265f9..0000000000 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/SoundProviderMixer.cs +++ /dev/null @@ -1,213 +0,0 @@ -using BizHawk.Emulation.Common; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum -{ - /// - /// My attempt at mixing multiple ISoundProvider sources together and outputting another ISoundProvider - /// Currently only supports SyncSoundMode.Sync - /// Attached ISoundProvider sources must already be stereo 44.1khz and ideally sound buffers should be the same length (882) - /// (if not, only 882 samples of their buffer will be used) - /// - internal sealed class SoundProviderMixer : ISoundProvider - { - private class Provider - { - public ISoundProvider SoundProvider { get; set; } - public string ProviderDescription { get; set; } - public int MaxVolume { get; set; } - public short[] Buffer { get; set; } - public int NSamp { get; set; } - } - - private bool _stereo = true; - public bool Stereo - { - get { return _stereo; } - set { _stereo = value; } - } - - private readonly List SoundProviders; - - public SoundProviderMixer(params ISoundProvider[] soundProviders) - { - SoundProviders = new List(); - - foreach (var s in soundProviders) - { - SoundProviders.Add(new Provider - { - SoundProvider = s, - MaxVolume = short.MaxValue, - }); - } - - EqualizeVolumes(); - } - - public SoundProviderMixer(short maxVolume, string description, params ISoundProvider[] soundProviders) - { - SoundProviders = new List(); - - foreach (var s in soundProviders) - { - SoundProviders.Add(new Provider - { - SoundProvider = s, - MaxVolume = maxVolume, - ProviderDescription = description - }); - } - - EqualizeVolumes(); - } - - public void AddSource(ISoundProvider source, string description) - { - SoundProviders.Add(new Provider - { - SoundProvider = source, - MaxVolume = short.MaxValue, - ProviderDescription = description - }); - - EqualizeVolumes(); - } - - public void AddSource(ISoundProvider source, short maxVolume, string description) - { - SoundProviders.Add(new Provider - { - SoundProvider = source, - MaxVolume = maxVolume, - ProviderDescription = description - }); - - EqualizeVolumes(); - } - - public void DisableSource(ISoundProvider source) - { - var sp = SoundProviders.Where(a => a.SoundProvider == source); - if (sp.Count() == 1) - SoundProviders.Remove(sp.First()); - else if (sp.Count() > 1) - foreach (var s in sp) - SoundProviders.Remove(s); - - EqualizeVolumes(); - } - - public void EqualizeVolumes() - { - if (SoundProviders.Count < 1) - return; - - int eachVolume = short.MaxValue / SoundProviders.Count; - foreach (var source in SoundProviders) - { - source.MaxVolume = eachVolume; - } - } - - #region ISoundProvider - - public bool CanProvideAsync => false; - public SyncSoundMode SyncMode => SyncSoundMode.Sync; - - public void SetSyncMode(SyncSoundMode mode) - { - if (mode != SyncSoundMode.Sync) - throw new InvalidOperationException("Only Sync mode is supported."); - } - - public void GetSamplesAsync(short[] samples) - { - throw new NotSupportedException("Async is not available"); - } - - public void DiscardSamples() - { - foreach (var soundSource in SoundProviders) - { - soundSource.SoundProvider.DiscardSamples(); - } - } - - public void GetSamplesSync(out short[] samples, out int nsamp) - { - samples = null; - nsamp = 0; - - // get samples from all the providers - foreach (var sp in SoundProviders) - { - int sampCount; - short[] samp; - sp.SoundProvider.GetSamplesSync(out samp, out sampCount); - sp.NSamp = sampCount; - sp.Buffer = samp; - } - - // are all the sample lengths the same? - var firstEntry = SoundProviders.First(); - bool sameCount = SoundProviders.All(s => s.NSamp == firstEntry.NSamp); - - if (!sameCount) - { - // this is a bit hacky, really all ISoundProviders should be supplying 44100 with 882 samples per frame. - // we will make sure this happens (no matter how it sounds) - if (SoundProviders.Count > 1) - { - for (int i = 0; i < SoundProviders.Count; i++) - { - int ns = SoundProviders[i].NSamp; - short[] buff = new short[882 * 2]; - - for (int b = 0; b < 882 * 2; b++) - { - if (b == SoundProviders[i].Buffer.Length - 1) - { - // end of source buffer - break; - } - - buff[b] = SoundProviders[i].Buffer[b]; - } - - // save back to the soundprovider - SoundProviders[i].NSamp = 882; - SoundProviders[i].Buffer = buff; - } - } - else - { - // just process what we have as-is - } - } - - // mix the soundproviders together - nsamp = 882; - samples = new short[nsamp * 2]; - - for (int i = 0; i < samples.Length; i++) - { - short sectorVal = 0; - foreach (var sp in SoundProviders) - { - if (sp.Buffer[i] > sp.MaxVolume) - sectorVal += (short)sp.MaxVolume; - else - sectorVal += sp.Buffer[i]; - } - - samples[i] = sectorVal; - } - } - - #endregion - - } -} diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs index 1e8e491ca6..e03bbc5258 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; +using BizHawk.Emulation.Cores.Sound; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -36,11 +37,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } if (_machine != null && _machine.BuzzerDevice != null) { - ((Beeper)_machine.BuzzerDevice as Beeper).Volume = o.EarVolume; + ((OneBitBeeper)_machine.BuzzerDevice as OneBitBeeper).Volume = o.EarVolume; } if (_machine != null && _machine.TapeBuzzer != null) { - ((Beeper)_machine.TapeBuzzer as Beeper).Volume = o.TapeVolume; + ((OneBitBeeper)_machine.TapeBuzzer as OneBitBeeper).Volume = o.TapeVolume; } Settings = o; @@ -390,7 +391,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 = ""; 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.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs index 4807ffbc37..1c51cbbc10 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs @@ -6,6 +6,8 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using BizHawk.Emulation.Cores.Components; +using BizHawk.Emulation.Cores.Sound; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -46,11 +48,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum PutSettings((ZXSpectrumSettings)settings ?? new ZXSpectrumSettings()); List joysticks = new List(); - joysticks.Add(((ZXSpectrumSyncSettings)syncSettings as ZXSpectrumSyncSettings).JoystickType1); - joysticks.Add(((ZXSpectrumSyncSettings)syncSettings as ZXSpectrumSyncSettings).JoystickType2); - joysticks.Add(((ZXSpectrumSyncSettings)syncSettings as ZXSpectrumSyncSettings).JoystickType3); + joysticks.Add(((ZXSpectrumSyncSettings)syncSettings).JoystickType1); + joysticks.Add(((ZXSpectrumSyncSettings)syncSettings).JoystickType2); + joysticks.Add(((ZXSpectrumSyncSettings)syncSettings).JoystickType3); - deterministicEmulation = ((ZXSpectrumSyncSettings)syncSettings as ZXSpectrumSyncSettings).DeterministicEmulation; + deterministicEmulation = ((ZXSpectrumSyncSettings)syncSettings).DeterministicEmulation; if (deterministic != null && deterministic == true) { @@ -116,26 +118,29 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ser.Register(_machine.ULADevice); // initialize sound mixer and attach the various ISoundProvider devices - SoundMixer = new SoundProviderMixer((int)(32767 / 10), "System Beeper", (ISoundProvider)_machine.BuzzerDevice); - SoundMixer.AddSource((ISoundProvider)_machine.TapeBuzzer, "Tape Audio"); - if (_machine.AYDevice != null) - SoundMixer.AddSource(_machine.AYDevice, "AY-3-3912"); + SoundMixer = new SyncSoundMixer(targetSampleCount: 882); + SoundMixer.PinSource(_machine.BuzzerDevice, "System Beeper", (int)(32767 / 10)); + SoundMixer.PinSource(_machine.TapeBuzzer, "Tape Audio", (int)(32767 / 10)); + if (_machine.AYDevice != null) + { + SoundMixer.PinSource(_machine.AYDevice, "AY-3-3912"); + } // set audio device settings if (_machine.AYDevice != null && _machine.AYDevice.GetType() == typeof(AY38912)) { - ((AY38912)_machine.AYDevice as AY38912).PanningConfiguration = ((ZXSpectrumSettings)settings as ZXSpectrumSettings).AYPanConfig; - _machine.AYDevice.Volume = ((ZXSpectrumSettings)settings as ZXSpectrumSettings).AYVolume; + ((AY38912)_machine.AYDevice).PanningConfiguration = ((ZXSpectrumSettings)settings).AYPanConfig; + _machine.AYDevice.Volume = ((ZXSpectrumSettings)settings).AYVolume; } if (_machine.BuzzerDevice != null) { - ((Beeper)_machine.BuzzerDevice as Beeper).Volume = ((ZXSpectrumSettings)settings as ZXSpectrumSettings).EarVolume; + _machine.BuzzerDevice.Volume = ((ZXSpectrumSettings)settings).EarVolume; } if (_machine.TapeBuzzer != null) { - ((Beeper)_machine.TapeBuzzer as Beeper).Volume = ((ZXSpectrumSettings)settings as ZXSpectrumSettings).TapeVolume; + _machine.TapeBuzzer.Volume = ((ZXSpectrumSettings)settings).TapeVolume; } DCFilter dc = new DCFilter(SoundMixer, 512); @@ -159,7 +164,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public List _tapeInfo = new List(); public List _diskInfo = new List(); - private SoundProviderMixer SoundMixer; + private SyncSoundMixer SoundMixer; private readonly List _files; 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..baa68e39ec 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600ControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600ControllerDeck.cs @@ -15,6 +15,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 typeof(UnpluggedController), // Order must match Atari2600ControllerTypes enum values typeof(StandardController), typeof(PaddleController), + typeof(BoostGripController), typeof(DrivingController) }; @@ -66,11 +67,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/Atari2600Controllers.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600Controllers.cs index bbe1d0333e..1b44676c6d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600Controllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600Controllers.cs @@ -12,6 +12,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 Unplugged, Joystick, Paddle, + BoostGrip, Driving } @@ -161,6 +162,70 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } + public class BoostGripController : IPort + { + public BoostGripController(int portNum) + { + PortNum = portNum; + Definition = new ControllerDefinition + { + BoolButtons = BaseDefinition + .Select(b => $"P{PortNum} " + b) + .ToList() + }; + } + + public int PortNum { get; } + + public void SyncState(Serializer ser) + { + // Nothing todo, I think + } + + public ControllerDefinition Definition { get; } + + private static readonly string[] BaseDefinition = + { + "Up", "Down", "Left", "Right", "Button", + "Button 1", + "Button 2" + }; + + public byte Read(IController c) + { + byte result = 0xFF; + + if (c.IsPressed($"P{PortNum} Up")) { result &= 0xEF; } + if (c.IsPressed($"P{PortNum} Down")) { result &= 0xDF; } + if (c.IsPressed($"P{PortNum} Left")) { result &= 0xBF; } + if (c.IsPressed($"P{PortNum} Right")) { result &= 0x7F; } + if (c.IsPressed($"P{PortNum} Button")) { result &= 0xF7; } + + return result; + } + + public int Read_Pot(IController c, int pot) + { + bool is_pressed = false; + + if (pot == 0) + { + is_pressed = c.IsPressed($"P{PortNum} Button 1"); + } + else + { + is_pressed = c.IsPressed($"P{PortNum} Button 2"); + } + + if (is_pressed) + { + return 10; + } + + return 65535; + } + } + public class DrivingController : IPort { public DrivingController(int portNum) 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..d7b2901d1e 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; @@ -119,10 +126,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private HMoveData _hmove; private BallData _ball; - private readonly Audio[] AUD = { new Audio(), new Audio() }; + private readonly Audio AUD =new Audio(); // current audio register state used to sample correct positions in the scanline (clrclk 0 and 114) - ////public byte[] current_audio_register = new byte[6]; public readonly short[] LocalAudioCycles = new short[2000]; private static int ReverseBits(int value, int bits) @@ -208,6 +214,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 +350,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 +401,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 +656,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _hmove.HMoveCnt++; _hmove.HMoveCnt %= 4; - if (_p0Stuff && _hsyncCnt % 4 == 0) + if (_p0Stuff) { _p0Stuff = false; @@ -636,7 +678,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } - if (_p1Stuff && _hsyncCnt % 4 == 0) + if (_p1Stuff) { _p1Stuff = false; @@ -658,7 +700,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } - if (_m0Stuff && _hsyncCnt % 4 == 0) + if (_m0Stuff) { _m0Stuff = false; @@ -680,7 +722,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } - if (_m1Stuff && _hsyncCnt % 4 == 0) + if (_m1Stuff) { _m1Stuff = false; @@ -702,7 +744,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } - if (_bStuff && _hsyncCnt % 4 == 0) + if (_bStuff) { _bStuff = false; @@ -725,15 +767,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; @@ -766,8 +808,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { if (AudioClocks < 2000) { - LocalAudioCycles[AudioClocks] += (short)(AUD[0].Cycle() / 2); - LocalAudioCycles[AudioClocks] += (short)(AUD[1].Cycle() / 2); + LocalAudioCycles[AudioClocks] += (short)(AUD.Cycle_L() / 2); + LocalAudioCycles[AudioClocks] += (short)(AUD.Cycle_R() / 2); AudioClocks++; } } @@ -865,7 +907,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 // 6105 roughly centers the paddle in Breakout if (maskedAddr == 0x08) // INPT0 { - if (_core.ReadPot1(0)>0 && _capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= _core.ReadPot1(0)) + if (_core.ReadPot1(0) > 0 && _capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= _core.ReadPot1(0)) { coll = 0x80; } @@ -879,7 +921,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 if (maskedAddr == 0x09) // INPT1 { - if (_core.ReadPot1(1) > 0 && _capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= _core.ReadPot1(1)) + if (_core.ReadPot1(1) > 0 && _capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= _core.ReadPot1(1)) { coll = 0x80; } @@ -1215,27 +1257,27 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } else if (maskedAddr == 0x15) // AUDC0 { - AUD[0].AUDC = (byte)(value & 15); + AUD.AUDC_L = (byte)(value & 15); } else if (maskedAddr == 0x16) // AUDC1 { - AUD[1].AUDC = (byte)(value & 15); + AUD.AUDC_R = (byte)(value & 15); } else if (maskedAddr == 0x17) // AUDF0 { - AUD[0].AUDF = (byte)((value & 31) + 1); + AUD.AUDF_L = (byte)((value & 31) + 1); } else if (maskedAddr == 0x18) // AUDF1 { - AUD[1].AUDF = (byte)((value & 31) + 1); + AUD.AUDF_R = (byte)((value & 31) + 1); } else if (maskedAddr == 0x19) // AUDV0 { - AUD[0].AUDV = (byte)(value & 15); + AUD.AUDV_L = (byte)(value & 15); } else if (maskedAddr == 0x1A) // AUDV1 { - AUD[1].AUDV = (byte)(value & 15); + AUD.AUDV_R = (byte)(value & 15); } else if (maskedAddr == 0x1B) // GRP0 { @@ -1274,15 +1316,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 +1352,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..fa95102db1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs @@ -8,88 +8,98 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public class Audio { // noise/division control - public byte AUDC = 0; + public byte AUDC_L = 0; + public byte AUDC_R = 0; // frequency divider - public byte AUDF = 1; + public byte AUDF_L = 1; + public byte AUDF_R = 1; // volume - public byte AUDV = 0; + public byte AUDV_L = 0; + public byte AUDV_R = 0; // 2 state counter - private bool sr1 = true; + private bool sr1_L = true; + private bool sr1_R = true; // 4 bit shift register - private int sr4 = 0x0f; + private int sr4_L = 0x0f; + private int sr4_R = 0x0f; // 5 bit shift register - private int sr5 = 0x1f; + private int sr5_L = 0x1f; + private int sr5_R = 0x1f; // 9 bit shift register - private int sr9 = 0x1ff; + private int sr9_L = 0x1ff; + private int sr9_R = 0x1ff; // 3 state counter - private int sr3 = 2; + private int sr3_L = 2; + private int sr3_R = 2; // counter based off AUDF - private byte freqcnt; + private byte freqcnt_L; + private byte freqcnt_R; // latched audio value - private bool on = true; + private bool on_L = true; + private bool on_R = true; - private bool Run3() + private bool Run3_L() { - sr3++; - if (sr3 == 3) + sr3_L++; + if (sr3_L == 3) { - sr3 = 0; + sr3_L = 0; return true; } return false; } - private bool Run4() + private bool Run4_L() { - bool ret = (sr4 & 1) != 0; - bool c = ((sr4 & 1) != 0) ^ ((sr4 & 2) != 0); - sr4 = (sr4 >> 1) | (c ? 8 : 0); + bool ret = (sr4_L & 1) != 0; + bool c = ((sr4_L & 1) != 0) ^ ((sr4_L & 2) != 0); + sr4_L = (sr4_L >> 1) | (c ? 8 : 0); return ret; } - private bool Run5() + private bool Run5_L() { - bool ret = (sr5 & 1) != 0; - bool c = ((sr5 & 1) != 0) ^ ((sr5 & 4) != 0); - sr5 = (sr5 >> 1) | (c ? 16 : 0); + bool ret = (sr5_L & 1) != 0; + bool c = ((sr5_L & 1) != 0) ^ ((sr5_L & 4) != 0); + sr5_L = (sr5_L >> 1) | (c ? 16 : 0); return ret; } - private bool One4() + private bool One4_L() { - bool ret = (sr4 & 1) != 0; - sr4 = (sr4 >> 1) | 8; + bool ret = (sr4_L & 1) != 0; + sr4_L = (sr4_L >> 1) | 8; return ret; } - private bool One5() + private bool One5_L() { - bool ret = (sr5 & 1) != 0; - sr5 = (sr5 >> 1) | 16; + bool ret = (sr5_L & 1) != 0; + sr5_L = (sr5_L >> 1) | 16; return ret; } - private bool Run1() + private bool Run1_L() { - sr1 = !sr1; - return !sr1; + sr1_L = !sr1_L; + return !sr1_L; } - private bool Run9() + private bool Run9_L() { - bool ret = (sr9 & 1) != 0; - bool c = ((sr9 & 1) != 0) ^ ((sr9 & 16) != 0); - sr9 = (sr9 >> 1) | (c ? 256 : 0); + bool ret = (sr9_L & 1) != 0; + bool c = ((sr9_L & 1) != 0) ^ ((sr9_L & 16) != 0); + sr9_L = (sr9_L >> 1) | (c ? 256 : 0); return ret; } @@ -97,92 +107,92 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 /// call me approx 31k times a second /// /// 16 bit audio sample - public short Cycle() + public short Cycle_L() { - if (++freqcnt >= AUDF) + if (++freqcnt_L >= AUDF_L) { - freqcnt = 0; - switch (AUDC) + freqcnt_L = 0; + switch (AUDC_L) { case 0x00: case 0x0b: // Both have a 1 s - One5(); - on = One4(); + One5_L(); + on_L = One4_L(); break; case 0x01: // Both run, but the 5 bit is ignored - on = Run4(); + on_L = Run4_L(); //Run5(); break; case 0x02: - if ((sr5 & 0x0f) == 0 || (sr5 & 0x0f) == 0x0f) + if ((sr5_L & 0x0f) == 0 || (sr5_L & 0x0f) == 0x0f) { - on = Run4(); + on_L = Run4_L(); } - Run5(); + Run5_L(); break; case 0x03: - if (Run5()) + if (Run5_L()) { - on = Run4(); + on_L = Run4_L(); } break; case 0x04: - Run5(); - One4(); - on = Run1(); + Run5_L(); + One4_L(); + on_L = Run1_L(); break; case 0x05: - One5(); - Run4(); - on = Run1(); + One5_L(); + Run4_L(); + on_L = Run1_L(); break; case 0x06: case 0x0a: - Run5(); - if ((sr5 & 0x0f) == 0) + Run5_L(); + if ((sr5_L & 0x0f) == 0) { - on = false; + on_L = false; } - else if ((sr5 & 0x0f) == 0x0f) + else if ((sr5_L & 0x0f) == 0x0f) { - on = true; + on_L = true; } break; case 0x07: case 0x09: - on = Run5(); + on_L = Run5_L(); break; case 0x08: - on = Run9(); + on_L = Run9_L(); break; case 0x0c: case 0x0d: - if (Run3()) + if (Run3_L()) { - on = Run1(); + on_L = Run1_L(); } break; case 0x0e: - if (Run3()) + if (Run3_L()) { goto case 0x06; } break; case 0x0f: - if (Run3()) + if (Run3_L()) { goto case 0x07; } @@ -191,21 +201,189 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } - return (short)(on ? AUDV * 1092 : 0); + return (short)(on_L ? AUDV_L * 1092 : 0); + } + + private bool Run3_R() + { + sr3_R++; + if (sr3_R == 3) + { + sr3_R = 0; + return true; + } + + return false; + } + + private bool Run4_R() + { + bool ret = (sr4_R & 1) != 0; + bool c = ((sr4_R & 1) != 0) ^ ((sr4_R & 2) != 0); + sr4_R = (sr4_R >> 1) | (c ? 8 : 0); + return ret; + } + + private bool Run5_R() + { + bool ret = (sr5_R & 1) != 0; + bool c = ((sr5_R & 1) != 0) ^ ((sr5_R & 4) != 0); + sr5_R = (sr5_R >> 1) | (c ? 16 : 0); + return ret; + } + + private bool One4_R() + { + bool ret = (sr4_R & 1) != 0; + sr4_R = (sr4_R >> 1) | 8; + return ret; + } + + private bool One5_R() + { + bool ret = (sr5_R & 1) != 0; + sr5_R = (sr5_R >> 1) | 16; + return ret; + } + + private bool Run1_R() + { + sr1_R = !sr1_R; + return !sr1_R; + } + + private bool Run9_R() + { + bool ret = (sr9_R & 1) != 0; + bool c = ((sr9_R & 1) != 0) ^ ((sr9_R & 16) != 0); + sr9_R = (sr9_R >> 1) | (c ? 256 : 0); + return ret; + } + + /// + /// call me approx 31k times a second + /// + /// 16 bit audio sample + public short Cycle_R() + { + if (++freqcnt_R >= AUDF_R) + { + freqcnt_R = 0; + switch (AUDC_R) + { + case 0x00: + case 0x0b: + // Both have a 1 s + One5_R(); + on_R = One4_R(); + break; + + case 0x01: + // Both run, but the 5 bit is ignored + on_R = Run4_R(); + //Run5(); + break; + case 0x02: + if ((sr5_R & 0x0f) == 0 || (sr5_R & 0x0f) == 0x0f) + { + on_R = Run4_R(); + } + + Run5_R(); + break; + case 0x03: + if (Run5_R()) + { + on_R = Run4_R(); + } + + break; + + case 0x04: + Run5_R(); + One4_R(); + on_R = Run1_R(); + break; + + case 0x05: + One5_R(); + Run4_R(); + on_R = Run1_R(); + break; + + case 0x06: + case 0x0a: + Run5_R(); + if ((sr5_R & 0x0f) == 0) + { + on_R = false; + } + else if ((sr5_R & 0x0f) == 0x0f) + { + on_R = true; + } + + break; + + case 0x07: + case 0x09: + on_R = Run5_R(); + break; + + case 0x08: + on_R = Run9_R(); + break; + case 0x0c: + case 0x0d: + if (Run3_R()) + { + on_R = Run1_R(); + } + + break; + case 0x0e: + if (Run3_R()) + { + goto case 0x06; + } + + break; + case 0x0f: + if (Run3_R()) + { + goto case 0x07; + } + + break; + } + } + + return (short)(on_R ? AUDV_R * 1092 : 0); } 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_L), ref AUDC_L); + ser.Sync(nameof(AUDF_L), ref AUDF_L); + ser.Sync(nameof(AUDV_L), ref AUDV_L); + ser.Sync(nameof(sr1_L), ref sr1_L); + ser.Sync(nameof(sr3_L), ref sr3_L); + ser.Sync(nameof(sr4_L), ref sr4_L); + ser.Sync(nameof(sr5_L), ref sr5_L); + ser.Sync(nameof(sr9_L), ref sr9_L); + ser.Sync(nameof(freqcnt_L), ref freqcnt_L); + ser.Sync(nameof(on_L), ref on_L); + + ser.Sync(nameof(AUDC_R), ref AUDC_R); + ser.Sync(nameof(AUDF_R), ref AUDF_R); + ser.Sync(nameof(AUDV_R), ref AUDV_R); + ser.Sync(nameof(sr1_R), ref sr1_R); + ser.Sync(nameof(sr3_R), ref sr3_R); + ser.Sync(nameof(sr4_R), ref sr4_R); + ser.Sync(nameof(sr5_R), ref sr5_R); + ser.Sync(nameof(sr9_R), ref sr9_R); + ser.Sync(nameof(freqcnt_R), ref freqcnt_R); + ser.Sync(nameof(on_R), ref on_R); } } } 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..252f74e644 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,12 @@ 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("Audio"); + AUD.SyncState(ser); + ser.EndSection(); ser.BeginSection("Player0"); _player0.SyncState(ser); 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 9d792e3d31..bf70777b4a 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/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/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.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/Fairchild/ChannelF/Audio.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Audio.cs new file mode 100644 index 0000000000..6390adea4a --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Audio.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + /// + /// Audio related functions + /// + public partial class ChannelF : ISoundProvider + { + private double SampleRate = 44100; + private int SamplesPerFrame; + private double Period; + private double CyclesPerSample; + + + private int tone = 0; + + private double[] tone_freqs = new double[] { 0, 1000, 500, 120 }; + private double amplitude = 0; + private double decay = 0.998; + private double time = 0; + private double cycles = 0; + private int samplePos = 0; + private int lastCycle = 0; + + private BlipBuffer _blip; + + private short[] SampleBuffer; + + private void SetupAudio() + { + Period = (double)1 / SampleRate; + SamplesPerFrame = (int)(SampleRate / refreshRate); + CyclesPerSample = (double)ClockPerFrame / (double)SamplesPerFrame; + SampleBuffer = new short[SamplesPerFrame]; + _blip = new BlipBuffer(SamplesPerFrame); + _blip.SetRates(ClockPerFrame * refreshRate, SampleRate); + } + + private void AudioChange() + { + if (tone == 0) + { + // silence + } + else + { + int SamplesPerWave = (int)(SampleRate / tone_freqs[tone]); + double RadPerSample = (Math.PI * 2) / (double) SamplesPerWave; + double SinVal = 0; + + int NumSamples = (int)(((double)FrameClock - (double)lastCycle) / CyclesPerSample); + + int startPos = lastCycle; + + for (int i = 0; i < NumSamples; i++) + { + SinVal = Math.Sin(RadPerSample * (double) (i * SamplesPerWave)); + _blip.AddDelta((uint)startPos, (int) (Math.Floor(SinVal * 127) + 128) * 1024); + startPos += (int)CyclesPerSample; + } + } + } + + public bool CanProvideAsync => false; + + public SyncSoundMode SyncMode => SyncSoundMode.Sync; + + public void SetSyncMode(SyncSoundMode mode) + { + if (mode != SyncSoundMode.Sync) + throw new InvalidOperationException("Only Sync mode is supported."); + } + + public void GetSamplesAsync(short[] samples) + { + throw new NotSupportedException("Async is not available"); + } + + public void DiscardSamples() + { + SampleBuffer = new short[SamplesPerFrame]; + samplePos = 0; + lastCycle = 0; + } + + public void GetSamplesSync(out short[] samples, out int nsamp) + { + AudioChange(); + + _blip.EndFrame((uint)ClockPerFrame); + nsamp = _blip.SamplesAvailable(); + samples = new short[nsamp * 2]; + _blip.ReadSamples(samples, nsamp, true); + + for (int i = 0; i < nsamp * 2; i += 2) + { + samples[i + 1] = samples[i]; + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart.cs new file mode 100644 index 0000000000..d2d52dda5b --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + /// + /// Cartridge and related functions + /// + public partial class ChannelF + { + public byte[] Rom = new byte[4096]; + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs new file mode 100644 index 0000000000..80a2ae7931 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs @@ -0,0 +1,177 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using BizHawk.Common.BufferExtensions; +using BizHawk.Common.NumberExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + public partial class ChannelF + { + public bool[] StateConsole = new bool[4]; + public string[] ButtonsConsole = new string[] + { + "TIME", "MODE", "HOLD", "START" + }; + public byte DataConsole + { + get + { + int w = 0; + for (int i = 0; i < 4; i++) + { + byte mask = (byte) (1 << i); + w = StateConsole[i] ? w | mask : w & ~mask; + } + + return (byte)(w & 0xFF); + } + } + + public bool[] StateRight = new bool[8]; + public string[] ButtonsRight = new string[] + { + "Right", "Left", "Back", "Forward", "CCW", "CW", "Pull", "Push" + }; + public byte DataRight + { + get + { + int w = 0; + for (int i = 0; i < 8; i++) + { + byte mask = (byte)(1 << i); + w = StateRight[i] ? w | mask : w & ~mask; + } + + return (byte)(w & 0xFF); + } + } + + public bool[] StateLeft = new bool[8]; + public string[] ButtonsLeft = new string[] + { + "Right", "Left", "Back", "Forward", "CCW", "CW", "Pull", "Push" + }; + public byte DataLeft + { + get + { + int w = 0; + for (int i = 0; i < 8; i++) + { + byte mask = (byte)(1 << i); + w = StateLeft[i] ? w | mask : w & ~mask; + } + + return (byte)(w & 0xFF); + } + } + + + /// + /// Cycles through all the input callbacks + /// This should be done once per frame + /// + public bool PollInput() + { + bool noInput = true; + + InputCallbacks.Call(); + + lock (this) + { + for (int i = 0; i < ButtonsConsole.Length; i++) + { + var key = ButtonsConsole[i]; + bool prevState = StateConsole[i]; // CTRLConsole.Bit(i); + bool currState = _controller.IsPressed(key); + if (currState != prevState) + { + StateConsole[i] = currState; + noInput = false; + } + } + + for (int i = 0; i < ButtonsRight.Length; i++) + { + var key = "P1 " + ButtonsRight[i]; + bool prevState = StateRight[i]; + bool currState = _controller.IsPressed(key); + if (currState != prevState) + { + StateRight[i] = currState; + noInput = false; + } + } + + for (int i = 0; i < ButtonsLeft.Length; i++) + { + var key = "P2 " + ButtonsLeft[i]; + bool prevState = StateLeft[i]; + bool currState = _controller.IsPressed(key); + if (currState != prevState) + { + StateLeft[i] = currState; + noInput = false; + } + } + } + + return noInput; + } + + public ControllerDefinition ChannelFControllerDefinition + { + get + { + ControllerDefinition definition = new ControllerDefinition(); + definition.Name = "ChannelF Controller"; + + string pre = "P1 "; + + // sticks + List stickR = new List + { + // P1 (right) stick + pre + "Forward", pre + "Back", pre + "Left", pre + "Right", pre + "CCW", pre + "CW", pre + "Pull", pre + "Push" + }; + + foreach (var s in stickR) + { + definition.BoolButtons.Add(s); + definition.CategoryLabels[s] = "Right Controller"; + } + + pre = "P2 "; + + List stickL = new List + { + // P2 (left) stick + pre + "Forward", pre + "Back", pre + "Left", pre + "Right", pre + "CCW", pre + "CW", pre + "Pull", pre + "Push" + }; + + foreach (var s in stickL) + { + definition.BoolButtons.Add(s); + definition.CategoryLabels[s] = "Left Controller"; + } + + // console + List consoleButtons = new List + { + "RESET", "START", "HOLD", "MODE", "TIME" + }; + + foreach (var s in consoleButtons) + { + definition.BoolButtons.Add(s); + definition.CategoryLabels[s] = "Console"; + } + + return definition; + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs new file mode 100644 index 0000000000..ee961bcf67 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + public partial class ChannelF : IDebuggable + { + public IDictionary GetCpuFlagsAndRegisters() + { + var res = new Dictionary + { + ["A"] = CPU.Regs[CPU.A], + ["W"] = CPU.Regs[CPU.W], + ["ISAR"] = CPU.Regs[CPU.ISAR], + ["PC0"] = CPU.RegPC0, + ["PC1"] = CPU.RegPC1, + ["DC0"] = CPU.RegDC0, + ["DB"] = CPU.Regs[CPU.DB], + ["IO"] = CPU.Regs[CPU.IO], + ["J"] = CPU.Regs[CPU.J], + ["H"] = CPU.Regs[CPU.Hl] + (CPU.Regs[CPU.Hh] << 8), + ["K"] = CPU.Regs[CPU.Kl] + (CPU.Regs[CPU.Kh] << 8), + ["Q"] = CPU.Regs[CPU.Ql] + (CPU.Regs[CPU.Qh] << 8), + ["Flag C"] = CPU.FlagC, + ["Flag O"] = CPU.FlagO, + ["Flag Z"] = CPU.FlagZ, + ["Flag S"] = CPU.FlagS, + ["Flag I"] = CPU.FlagICB + }; + + for (int i = 0; i < 64; i++) + { + res.Add("SPR" + i, CPU.Regs[i]); + } + + return res; + } + + public void SetCpuRegister(string register, int value) + { + if (register.StartsWith("SPR")) + { + var reg = Convert.ToInt32(register.Replace("SPR", "")); + + if (reg > 63) + throw new InvalidOperationException(); + + CPU.Regs[reg] = (byte) value; + } + else + { + switch (register) + { + default: + throw new InvalidOperationException(); + case "A": + CPU.Regs[CPU.A] = (byte)value; + break; + case "W": + CPU.Regs[CPU.W] = (byte)value; + break; + case "ISAR": + CPU.Regs[CPU.ISAR] = (byte)(value & 0x3F); + break; + case "PC0": + CPU.RegPC0 = (ushort)value; + break; + case "PC1": + CPU.RegPC1 = (ushort)value; + break; + case "DC0": + CPU.RegDC0 = (ushort)value; + break; + case "DB": + CPU.Regs[CPU.DB] = (byte)value; + break; + case "IO": + CPU.Regs[CPU.IO] = (byte)value; + break; + case "J": + CPU.Regs[CPU.J] = (byte)value; + break; + case "H": + CPU.Regs[CPU.Hl] = (byte)(value & 0xFF); + CPU.Regs[CPU.Hh] = (byte)(value & 0xFF00); + break; + case "K": + CPU.Regs[CPU.Kl] = (byte)(value & 0xFF); + CPU.Regs[CPU.Kh] = (byte)(value & 0xFF00); + break; + case "Q": + CPU.Regs[CPU.Ql] = (byte)(value & 0xFF); + CPU.Regs[CPU.Qh] = (byte)(value & 0xFF00); + break; + } + } + } + + public IMemoryCallbackSystem MemoryCallbacks { get; } + + public bool CanStep(StepType type) => false; + + [FeatureNotImplemented] + public void Step(StepType type) + { + throw new NotImplementedException(); + } + + public long TotalExecutedCycles => CPU.TotalExecutedCycles; + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs new file mode 100644 index 0000000000..fa44fd2e45 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs @@ -0,0 +1,77 @@ +using System; +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + public partial class ChannelF : IEmulator + { + public IEmulatorServiceProvider ServiceProvider { get; } + + public ControllerDefinition ControllerDefinition { get; set; } + + public string SystemId => "ChannelF"; + + public bool DeterministicEmulation { get; set; } + + private static double cpuFreq = 1.7897725; + private static double refreshRate = 60; + + public int ClockPerFrame; + public int FrameClock = 0; + + private void CalcClock() + { + var c = ((cpuFreq * 1000000) / refreshRate); + ClockPerFrame = (int) c; + + SetupAudio(); + } + + public bool FrameAdvance(IController controller, bool render, bool renderSound) + { + _controller = controller; + _isLag = false; + + if (_tracer.Enabled) + { + CPU.TraceCallback = s => _tracer.Put(s); + } + else + { + CPU.TraceCallback = null; + } + + _isLag = PollInput(); + + while (FrameClock++ < ClockPerFrame) + { + CPU.ExecuteOne(); + } + + FrameClock = 0; + _frame++; + return true; + } + + private int _frame; + private int _lagcount; + private bool _islag; + + public void ResetCounters() + { + _frame = 0; + _lagcount = 0; + _islag = false; + } + + public int Frame => _frame; + + public CoreComm CoreComm { get; } + + public void Dispose() + { + + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs new file mode 100644 index 0000000000..d23b8b87b1 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs @@ -0,0 +1,79 @@ +using System; +using System.ComponentModel; +using BizHawk.Common; +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Nintendo.NES; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + public partial class ChannelF : ISettable + { + internal ChannelFSettings Settings = new ChannelFSettings(); + internal ChannelFSyncSettings SyncSettings = new ChannelFSyncSettings(); + + public ChannelFSettings GetSettings() + { + return Settings.Clone(); + } + + public ChannelFSyncSettings GetSyncSettings() + { + return SyncSettings.Clone(); + } + + public bool PutSettings(ChannelFSettings o) + { + Settings = o; + return false; + } + + public bool PutSyncSettings(ChannelFSyncSettings o) + { + bool ret = ChannelFSyncSettings.NeedsReboot(SyncSettings, o); + SyncSettings = o; + return ret; + } + + public class ChannelFSettings + { + [DisplayName("Default Background Color")] + [Description("The default BG color")] + [DefaultValue(0)] + public int BackgroundColor { get; set; } + + public ChannelFSettings Clone() + { + return (ChannelFSettings)MemberwiseClone(); + } + + public ChannelFSettings() + { + SettingsUtil.SetDefaultValues(this); + } + } + + public class ChannelFSyncSettings + { + [DisplayName("Deterministic Emulation")] + [Description("If true, the core agrees to behave in a completely deterministic manner")] + [DefaultValue(true)] + public bool DeterministicEmulation { get; set; } + + public ChannelFSyncSettings Clone() + { + return (ChannelFSyncSettings) MemberwiseClone(); + } + + public ChannelFSyncSettings() + { + SettingsUtil.SetDefaultValues(this); + } + + public static bool NeedsReboot(ChannelFSyncSettings x, ChannelFSyncSettings y) + { + return !DeepEquality.DeepEquals(x, y); + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IStatable.cs new file mode 100644 index 0000000000..101f1fd378 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IStatable.cs @@ -0,0 +1,107 @@ +using System; +using System.IO; +using BizHawk.Common; +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + public partial class ChannelF : IStatable + { + public bool BinarySaveStatesPreferred => true; + + public void SaveStateText(TextWriter writer) + { + SyncState(new Serializer(writer)); + } + + public void LoadStateText(TextReader reader) + { + SyncState(new Serializer(reader)); + } + + public void SaveStateBinary(BinaryWriter bw) + { + SyncState(new Serializer(bw)); + } + + public void LoadStateBinary(BinaryReader br) + { + SyncState(new Serializer(br)); + } + + public byte[] SaveStateBinary() + { + MemoryStream ms = new MemoryStream(); + BinaryWriter bw = new BinaryWriter(ms); + SaveStateBinary(bw); + bw.Flush(); + return ms.ToArray(); + } + + private void SyncState(Serializer ser) + { + ser.BeginSection("ChannelF"); + ser.Sync(nameof(VRAM), ref VRAM, false); + ser.Sync(nameof(_colour), ref _colour); + ser.Sync(nameof(_x), ref _x); + ser.Sync(nameof(_y), ref _y); + ser.Sync(nameof(_arm), ref _arm); + ser.Sync(nameof(ControllersEnabled), ref ControllersEnabled); + CPU.SyncState(ser); + ser.EndSection(); + /* + + byte[] core = null; + if (ser.IsWriter) + { + var ms = new MemoryStream(); + ms.Close(); + core = ms.ToArray(); + } + + if (ser.IsWriter) + { + ser.SyncEnum(nameof(_machineType), ref _machineType); + + _cpu.SyncState(ser); + ser.BeginSection(nameof(ZXSpectrum)); + _machine.SyncState(ser); + ser.Sync("Frame", ref _machine.FrameCount); + ser.Sync("LagCount", ref _lagCount); + ser.Sync("IsLag", ref _isLag); + ser.EndSection(); + } + + if (ser.IsReader) + { + var tmpM = _machineType; + ser.SyncEnum(nameof(_machineType), ref _machineType); + if (tmpM != _machineType && _machineType.ToString() != "72") + { + string msg = "SAVESTATE FAILED TO LOAD!!\n\n"; + msg += "Current Configuration: " + tmpM.ToString(); + msg += "\n"; + msg += "Saved Configuration: " + _machineType.ToString(); + msg += "\n\n"; + msg += "If you wish to load this SaveState ensure that you have the correct machine configuration selected, reboot the core, then try again."; + CoreComm.ShowMessage(msg); + _machineType = tmpM; + } + else + { + _cpu.SyncState(ser); + ser.BeginSection(nameof(ZXSpectrum)); + _machine.SyncState(ser); + ser.Sync("Frame", ref _machine.FrameCount); + ser.Sync("LagCount", ref _lagCount); + ser.Sync("IsLag", ref _isLag); + ser.EndSection(); + + SyncAllByteArrayDomains(); + } + } + */ + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs new file mode 100644 index 0000000000..5393e91dcf --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs @@ -0,0 +1,63 @@ +using System; +using BizHawk.Common; +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + public partial class ChannelF : IVideoProvider, IRegionable + { + public int _frameHz = 60; + + public int[] CroppedBuffer = new int[102 * 58]; + + #region IVideoProvider + + public int VirtualWidth => BufferWidth * 2; + public int VirtualHeight => (int)((double)BufferHeight * 1.3) * 2; + public int BufferWidth => 102; //128 + public int BufferHeight => 58; //64 + public int BackgroundColor => Colors.ARGB(0x00, 0x00, 0x00); + public int VsyncNumerator => _frameHz; + public int VsyncDenominator => 1; + + public int[] GetVideoBuffer() + { + BuildFrame(); + + var lBorderWidth = 4; + var rBorderWidth = 128 - 102 - lBorderWidth; + var tBorderHeight = 4; + var bBorderHeight = 64 - 58 - tBorderHeight; + var startP = 128 * tBorderHeight; + var endP = 128 * bBorderHeight; + + int index = 0; + + for (int i = startP; i < frameBuffer.Length - endP; i += 128) + { + for (int p = lBorderWidth; p < 128 - rBorderWidth; p++) + { + if (index == CroppedBuffer.Length) + break; + + CroppedBuffer[index++] = FPalette[frameBuffer[i + p]]; + } + } + + return CroppedBuffer; + + //return frameBuffer; + + + } + + #endregion + + #region IRegionable + + public DisplayType Region => DisplayType.NTSC; + + #endregion + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs new file mode 100644 index 0000000000..1112bf1b21 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs @@ -0,0 +1,26 @@ +using System; +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + public partial class ChannelF : IInputPollable + { + public int LagCount + { + get { return _lagCount; } + set { _lagCount = value; } + } + + public bool IsLagFrame + { + get { return _isLag; } + set { _isLag = value; } + } + + public IInputCallbackSystem InputCallbacks { get; } + + private int _lagCount = 0; + private bool _isLag = false; + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs new file mode 100644 index 0000000000..0f62cab512 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + public partial class ChannelF + { + internal IMemoryDomains memoryDomains; + private readonly Dictionary _byteArrayDomains = new Dictionary(); + private bool _memoryDomainsInit = false; + + private void SetupMemoryDomains() + { + var domains = new List + { + new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Big, + (addr) => + { + if (addr < 0 || addr >= 65536) + { + throw new ArgumentOutOfRangeException(); + } + return ReadBus((ushort)addr); + }, + (addr, value) => + { + if (addr < 0 || addr >= 65536) + { + throw new ArgumentOutOfRangeException(); + } + + WriteBus((ushort)addr, value); + }, 1) + }; + + SyncAllByteArrayDomains(); + + memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList()); + (ServiceProvider as BasicServiceProvider)?.Register(memoryDomains); + + _memoryDomainsInit = true; + } + + private void SyncAllByteArrayDomains() + { + SyncByteArrayDomain("BIOS1", BIOS01); + SyncByteArrayDomain("BIOS2", BIOS02); + SyncByteArrayDomain("ROM", Rom); + SyncByteArrayDomain("VRAM", VRAM); + } + + private void SyncByteArrayDomain(string name, byte[] data) + { + if (_memoryDomainsInit || _byteArrayDomains.ContainsKey(name)) + { + var m = _byteArrayDomains[name]; + m.Data = data; + } + else + { + var m = new MemoryDomainByteArray(name, MemoryDomain.Endian.Big, data, false, 1); + _byteArrayDomains.Add(name, m); + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs new file mode 100644 index 0000000000..78a54ecc79 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs @@ -0,0 +1,59 @@ +using System; +using BizHawk.Common; +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + [Core( + "ChannelFHawk", + "Asnivor", + isPorted: false, + isReleased: false)] + [ServiceNotApplicable(typeof(IDriveLight))] + public partial class ChannelF + { + public ChannelF(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) + { + var ser = new BasicServiceProvider(this); + ServiceProvider = ser; + CoreComm = comm; + InputCallbacks = new InputCallbackSystem(); + MemoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); + + ControllerDefinition = ChannelFControllerDefinition; + + CPU = new F3850 + { + ReadMemory = ReadBus, + WriteMemory = WriteBus, + ReadHardware = ReadPort, + WriteHardware = WritePort, + DummyReadMemory = ReadBus + }; + + _tracer = new TraceBuffer { Header = CPU.TraceHeader }; + + byte[] bios01 = comm.CoreFileProvider.GetFirmware("ChannelF", "ChannelF_sl131253", true); + byte[] bios02 = comm.CoreFileProvider.GetFirmware("ChannelF", "ChannelF_sl131254", true); + + BIOS01 = bios01; + BIOS02 = bios02; + + Array.Copy(rom, 0, Rom, 0, rom.Length); + + CalcClock(); + + ser.Register(this); + ser.Register(_tracer); + ser.Register(CPU); + ser.Register(this); + + SetupMemoryDomains(); + } + + public F3850 CPU; + private readonly TraceBuffer _tracer; + public IController _controller; + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Disassembler.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Disassembler.cs new file mode 100644 index 0000000000..f3e4510f89 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Disassembler.cs @@ -0,0 +1,347 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + /// + /// Disassembler + /// + public sealed partial class F3850 : IDisassemblable + { + static string Result(string format, Func read, ref ushort addr) + { + //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) + { + format = format.Replace("nn", read(addr++) + .ToString("X2") + read(addr++) + .ToString("X2") + "h"); // MSB 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) + { + var b = unchecked((sbyte)read(addr++)); + format = format.Replace("d", $"{(b < 0 ? '-' : '+')}{(b < 0 ? -b : b):X2}h"); + } + + return format; + } + + + readonly static string[] mnemonics = new string[] + { + "LR A, KU", // 0x00 + "LR A, KL", // 0x01 + "LR A, QU", // 0x02 + "LR A, QL", // 0x03 + "LR KU, A", // 0x04 + "LR KL, A", // 0x05 + "LR QU, A", // 0x06 + "LR QL, A", // 0x07 + "LR K, P", // 0x08 + "LR P, K", // 0x09 + "LR A, IS", // 0x0A + "LR IS, A", // 0x0B + "PK", // 0x0C + "LR P0, Q", // 0x0D + "LR Q, DC", // 0x0E + "LR DC, Q", // 0x0F + "LR DC, H", // 0x10 + "LR H, DC", // 0x11 + "SR 1", // 0x12 + "SL 1", // 0x13 + "SR 4", // 0x14 + "SL 4", // 0x15 + "LM", // 0x16 + "ST", // 0x17 + "COM", // 0x18 + "LNK", // 0x19 + "DI", // 0x1A + "EI", // 0x1B + "POP", // 0x1C + "LR W, J", // 0x1D + "LR J, W", // 0x1E + "INC", // 0x1F + "LI n", // 0x20 + "NI n", // 0x21 + "OI n", // 0x22 + "XI n", // 0x23 + "AI n", // 0x24 + "CI n", // 0x25 + "IN n", // 0x26 + "OUT n", // 0x27 + "PI nn", // 0x28 + "JMP nn", // 0x29 + "DCI nn", // 0x2A + "NOP", // 0x2B + "XDC", // 0x2C + "ILLEGAL", // 0x2D + "ILLEGAL", // 0x2E + "ILLEGAL", // 0x2F + "DS r00", // 0x30 + "DS r01", // 0x31 + "DS r02", // 0x32 + "DS r03", // 0x33 + "DS r04", // 0x34 + "DS r05", // 0x35 + "DS r06", // 0x36 + "DS r07", // 0x37 + "DS r08", // 0x38 + "DS r09", // 0x39 + "DS r10", // 0x3A + "DS r11", // 0x3B + "DS ISAR", // 0x3C + "DS ISAR INC", // 0x3D + "DS ISAR DEC", // 0x3E + "ILLEGAL", // 0x3F + "LR A, r00", // 0x40 + "LR A, r01", // 0x41 + "LR A, r02", // 0x42 + "LR A, r03", // 0x43 + "LR A, r04", // 0x44 + "LR A, r05", // 0x45 + "LR A, r06", // 0x46 + "LR A, r07", // 0x47 + "LR A, r08", // 0x48 + "LR A, r09", // 0x49 + "LR A, r10", // 0x4A + "LR A, r11", // 0x4B + "LR A, (ISAR)", // 0x4C + "LR A, (ISAR) INC", // 0x4D + "LR A, (ISAR) DEC", // 0x4E + "ILLEGAL", // 0x4F + "LR r00, A", // 0x50 + "LR r01, A", // 0x51 + "LR r02, A", // 0x52 + "LR r03, A", // 0x53 + "LR r04, A", // 0x54 + "LR r05, A", // 0x55 + "LR r06, A", // 0x56 + "LR r07, A", // 0x57 + "LR r08, A", // 0x58 + "LR r09, A", // 0x59 + "LR r10, A", // 0x5A + "LR r11, A", // 0x5B + "LR ((ISAR)), A", // 0x5C + "LR (ISAR), A INC", // 0x5D + "LR (ISAR), A DEC", // 0x5E + "ILLEGAL", // 0x5F + "LISU 0", // 0x60 + "LISU 1", // 0x61 + "LISU 2", // 0x62 + "LISU 3", // 0x63 + "LISU 4", // 0x64 + "LISU 5", // 0x65 + "LISU 6", // 0x66 + "LISU 7", // 0x67 + "LISL 0", // 0x68 + "LISL 1", // 0x69 + "LISL 2", // 0x6A + "LISL 3", // 0x6B + "LISL 4", // 0x6C + "LISL 5", // 0x6D + "LISL 6", // 0x6E + "LISL 7", // 0x6F + "LIS 0", // 0x70 + "LIS 1", // 0x71 + "LIS 2", // 0x72 + "LIS 3", // 0x73 + "LIS 4", // 0x74 + "LIS 5", // 0x75 + "LIS 6", // 0x76 + "LIS 7", // 0x77 + "LIS 8", // 0x78 + "LIS 9", // 0x79 + "LIS A", // 0x7A + "LIS B", // 0x7B + "LIS C", // 0x7C + "LIS D", // 0x7D + "LIS E", // 0x7E + "LIS F", // 0x7F + "BT NOBRANCH", // 0x80 + "BP d", // 0x81 + "BC d", // 0x82 + "BP or C d", // 0x83 + "BZ d", // 0x84 + "BP d", // 0x85 + "BZ or C d", // 0x86 + "BP or C d", // 0x87 + "AM", // 0x88 + "AMD", // 0x89 + "NM", // 0x8A + "OM", // 0x8B + "XM", // 0x8C + "CM", // 0x8D + "ADC", // 0x8E + "BR7 n", // 0x8F + "BF UNCON d", // 0x90 + "BN d", // 0x91 + "BNC d", // 0x92 + "BNC & deg d", // 0x93 + "BNZ d", // 0x94 + "BN d", // 0x95 + "BNC & dZ d", // 0x96 + "BNC & deg d", // 0x97 + "BNO d", // 0x98 + "BN & dO d", // 0x99 + "BNO & dC d", // 0x9A + "BNO & dC & deg d", // 0x9B + "BNO & dZ d", // 0x9C + "BN & dO d", // 0x9D + "BNO & dC & dZ d", // 0x9E + "BNO & dC & deg d", // 0x9F + "INS 0", // 0xA0 + "INS 1", // 0xA1 + "ILLEGAL", // 0xA2 + "ILLEGAL", // 0xA3 + "INS 4", // 0xA4 + "INS 5", // 0xA5 + "INS 6", // 0xA6 + "INS 7", // 0xA7 + "INS 8", // 0xA8 + "INS 9", // 0xA9 + "INS 10", // 0xAA + "INS 11", // 0xAB + "INS 12", // 0xAC + "INS 13", // 0xAD + "INS 14", // 0xAE + "INS 16", // 0xAF + "OUTS 0", // 0xB0 + "OUTS 1", // 0xB1 + "ILLEGAL", // 0xB2 + "ILLEGAL", // 0xB3 + "OUTS 4", // 0xB4 + "OUTS 5", // 0xB5 + "OUTS 6", // 0xB6 + "OUTS 7", // 0xB7 + "OUTS 8", // 0xB8 + "OUTS 9", // 0xB9 + "OUTS 10", // 0xBA + "OUTS 11", // 0xBB + "OUTS 12", // 0xBC + "OUTS 13", // 0xBD + "OUTS 14", // 0xBE + "OUTS 15", // 0xBF + "AS r00", // 0xC0 + "AS r01", // 0xC1 + "AS r02", // 0xC2 + "AS r03", // 0xC3 + "AS r04", // 0xC4 + "AS r05", // 0xC5 + "AS r06", // 0xC6 + "AS r07", // 0xC7 + "AS r08", // 0xC8 + "AS r09", // 0xC9 + "AS r10", // 0xCA + "AS r11", // 0xCB + "AS ISAR", // 0xCC + "AS ISAR INC", // 0xCD + "AS ISAR DEC", // 0xCE + "ILLEGAL", // 0xCF + "ASD r00", // 0xD0 + "ASD r01", // 0xD1 + "ASD r02", // 0xD2 + "ASD r03", // 0xD3 + "ASD r04", // 0xD4 + "ASD r05", // 0xD5 + "ASD r06", // 0xD6 + "ASD r07", // 0xD7 + "ASD r08", // 0xD8 + "ASD r09", // 0xD9 + "ASD r10", // 0xDA + "ASD r11", // 0xDB + "ASD ISAR", // 0xDC + "ASD ISAR INC", // 0xDD + "ASD ISAR DEC", // 0xDE + "ILLEGAL", // 0xDF + "XS r00", // 0xE0 + "XS r01", // 0xE1 + "XS r02", // 0xE2 + "XS r03", // 0xE3 + "XS r04", // 0xE4 + "XS r05", // 0xE5 + "XS r06", // 0xE6 + "XS r07", // 0xE7 + "XS r08", // 0xE8 + "XS r09", // 0xE9 + "XS r10", // 0xEA + "XS r11", // 0xEB + "XS ISAR", // 0xEC + "XS ISAR INC", // 0xED + "XS ISAR DEC", // 0xEE + "ILLEGAL", // 0xEF + "NS r00", // 0xF0 + "NS r01", // 0xF1 + "NS r02", // 0xF2 + "NS r03", // 0xF3 + "NS r04", // 0xF4 + "NS r05", // 0xF5 + "NS r06", // 0xF6 + "NS r07", // 0xF7 + "NS r08", // 0xF8 + "NS r09", // 0xF9 + "NS r10", // 0xFA + "NS r11", // 0xFB + "NS ISAR", // 0xFC + "NS ISAR INC", // 0xFD + "NS ISAR DEC", // 0xFE + "ILLEGAL", // 0xFF + }; + + public string Disassemble(ushort addr, Func read, out int size) + { + ushort start_addr = addr; + ushort extra_inc = 0; + byte A = read(addr++); + string format; + format = mnemonics[A]; + + string temp = Result(format, read, ref addr); + size = addr - start_addr; + + if (addr < start_addr) + { + size = (0x10000 + addr) - start_addr; + } + + return temp; + } + + #region IDisassemblable + + #endregion + + public string Cpu + { + get { return "F3850"; } + set { } + } + + public string PCRegisterName + { + get { return "PC"; } + } + + public IEnumerable AvailableCpus + { + get { yield return "F3850"; } + } + + public string Disassemble(MemoryDomain m, uint addr, out int length) + { + string ret = Disassemble((ushort)addr, a => m.PeekByte(a), out length); + return ret; + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Execute.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Execute.cs new file mode 100644 index 0000000000..7c5ae0e707 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Execute.cs @@ -0,0 +1,287 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + public sealed partial class F3850 + { + public const int MaxInstructionLength = 40; + + public long TotalExecutedCycles; + + public int instr_pntr = 0; + public byte[] cur_instr = new byte[MaxInstructionLength]; // fixed size - do not change at runtime + public byte[] cur_romc = new byte[MaxInstructionLength]; // fixed size - do not change at runtime + public byte opcode; + + public void FetchInstruction() + { + switch (opcode) + { + case 0x00: LR_A_KU(); break; // LR A, (KU) + case 0x01: LR_A_KL(); break; // LR A, (KL) + case 0x02: LR_A_QU(); break; // LR A, (QU) + case 0x03: LR_A_QL(); break; // LR A, (QL) + case 0x04: LR_KU_A(); break; // LR KU, (A) + case 0x05: LR_KL_A(); break; // LR KL, (A) + case 0x06: LR_QU_A(); break; // LR QU, (A) + case 0x07: LR_QL_A(); break; // LR QL, (A) + case 0x08: LR_K_P(); break; // LR K, (P) + case 0x09: LR_P_K(); break; // LR P, (K) + case 0x0A: LR_A_IS(); break; // LR A, (ISAR) + case 0x0B: LR_IS_A(); break; // LR ISAR, (A) + case 0x0C: PK(); break; // LR PC1, (PC0); LR PC0l <- (r13); LR PC0h, (r12) + case 0x0D: LR_P0_Q(); break; // LR PC0l, (r15); LR PC0h <- (r14) + case 0x0E: LR_Q_DC(); break; // LR r14, (DC0h); r15 <- (DC0l) + case 0x0F: LR_DC_Q(); break; // LR DC0h, (r14); DC0l <- (r15) + case 0x10: LR_DC_H(); break; // LR DC0h, (r10); DC0l <- (r11) + case 0x11: LR_H_DC(); break; // LR r10, (DC0h); r11 <- (DC0l) + case 0x12: SHIFT_R(1); break; // Shift (A) right one bit position (zero fill) + case 0x13: SHIFT_L(1); break; // Shift (A) left one bit position (zero fill) + case 0x14: SHIFT_R(4); break; // Shift (A) right four bit positions (zero fill) + case 0x15: SHIFT_L(4); break; // Shift (A) left four bit positions (zero fill) + case 0x16: LM(); break; // A <- ((DC0)) + case 0x17: ST(); break; // (DC) <- (A) + case 0x18: COM(); break; // A <- A XOR 255 (complement A) + case 0x19: LNK(); break; // A <- (A) + (C) + case 0x1A: DI(); break; // Clear ICB + case 0x1B: EI(); break; // Set ICB + case 0x1C: POP(); break; // PC0 <- PC1 + case 0x1D: LR_W_J(); break; // W <- (r9) + case 0x1E: LR_J_W(); break; // r9 <- (W) + case 0x1F: INC(); break; // A <- (A) + 1 + case 0x20: LI(); break; // A <- H'aa' + case 0x21: NI(); break; // A <- (A) AND H'aa' + case 0x22: OI(); break; // A <- (A) OR H'aa' + case 0x23: XI(); break; // A <- (A) XOR H'aa' + case 0x24: AI(); break; // A <- (A) + H'aa' + case 0x25: CI(); break; // H'aa' + (A) + 1 (modify flags without saving result) + case 0x26: IN(); break; // DB <- PP; A <- (I/O Port PP) + case 0x27: OUT(); break; // DB <- PP; I/O Port PP <- (A) + case 0x28: PI(); break; // A <- H'ii'; PC1 <- (PC0) + 1; PC0l <- H'jj'; PC0h <- (A) + case 0x29: JMP(); break; // A <- H'ii'; PC0l <- H'jj'; PC0h <- (A) + case 0x2A: DCI(); break; // DC0h <- ii; increment PC0; DC0l <- jj; increment PC0 + case 0x2B: NOP(); break; // No operation (4 cycles - fetch next opcode) + case 0x2C: XDC(); break; // DC0 <-> DC1 + + + + case 0x30: DS(0); break; // SR <- (SR) + H'FF' + case 0x31: DS(1); break; // SR <- (SR) + H'FF' + case 0x32: DS(2); break; // SR <- (SR) + H'FF' + case 0x33: DS(3); break; // SR <- (SR) + H'FF' + case 0x34: DS(4); break; // SR <- (SR) + H'FF' + case 0x35: DS(5); break; // SR <- (SR) + H'FF' + case 0x36: DS(6); break; // SR <- (SR) + H'FF' + case 0x37: DS(7); break; // SR <- (SR) + H'FF' + case 0x38: DS(8); break; // SR <- (SR) + H'FF' + case 0x39: DS(9); break; // SR <- (SR) + H'FF' + case 0x3A: DS(10); break; // SR <- (SR) + H'FF' + case 0x3B: DS(11); break; // SR <- (SR) + H'FF' + case 0x3C: DS_ISAR(); break; // SR <- (SR) + H'FF' (SR pointed to by the ISAR) + case 0x3D: DS_ISAR_INC(); break; // SR <- (SR) + H'FF' (SR pointed to by the ISAR); ISAR incremented + case 0x3E: DS_ISAR_DEC(); break; // SR <- (SR) + H'FF' (SR pointed to by the ISAR); ISAR decremented + + case 0x40: LR_A_R(0); break; // A <- (SR) + case 0x41: LR_A_R(1); break; // A <- (SR) + case 0x42: LR_A_R(2); break; // A <- (SR) + case 0x43: LR_A_R(3); break; // A <- (SR) + case 0x44: LR_A_R(4); break; // A <- (SR) + case 0x45: LR_A_R(5); break; // A <- (SR) + case 0x46: LR_A_R(6); break; // A <- (SR) + case 0x47: LR_A_R(7); break; // A <- (SR) + case 0x48: LR_A_R(8); break; // A <- (SR) + case 0x49: LR_A_R(9); break; // A <- (SR) + case 0x4A: LR_A_R(10); break; // A <- (SR) + case 0x4B: LR_A_R(11); break; // A <- (SR) + case 0x4C: LR_A_ISAR(); break; // A <- (SR) (SR pointed to by the ISAR) + case 0x4D: LR_A_ISAR_INC(); break; // A <- (SR) (SR pointed to by the ISAR); ISAR incremented + case 0x4E: LR_A_ISAR_DEC(); break; // A <- (SR) (SR pointed to by the ISAR); ISAR decremented + + case 0x50: LR_R_A(0); break; // SR <- (A) + case 0x51: LR_R_A(1); break; // SR <- (A) + case 0x52: LR_R_A(2); break; // SR <- (A) + case 0x53: LR_R_A(3); break; // SR <- (A) + case 0x54: LR_R_A(4); break; // SR <- (A) + case 0x55: LR_R_A(5); break; // SR <- (A) + case 0x56: LR_R_A(6); break; // SR <- (A) + case 0x57: LR_R_A(7); break; // SR <- (A) + case 0x58: LR_R_A(8); break; // SR <- (A) + case 0x59: LR_R_A(9); break; // SR <- (A) + case 0x5A: LR_R_A(10); break; // SR <- (A) + case 0x5B: LR_R_A(11); break; // SR <- (A) + case 0x5C: LR_ISAR_A(); break; // SR <- (A) (SR pointed to by the ISAR) + case 0x5D: LR_ISAR_A_INC(); break; // SR <- (A) (SR pointed to by the ISAR); ISAR incremented + case 0x5E: LR_ISAR_A_DEC(); break; // SR <- (A) (SR pointed to by the ISAR); ISAR decremented + + case 0x60: LISU(0); break; // ISARU <- 0'e' (octal) + case 0x61: LISU(1); break; // ISARU <- 0'e' (octal) + case 0x62: LISU(2); break; // ISARU <- 0'e' (octal) + case 0x63: LISU(3); break; // ISARU <- 0'e' (octal) + case 0x64: LISU(4); break; // ISARU <- 0'e' (octal) + case 0x65: LISU(5); break; // ISARU <- 0'e' (octal) + case 0x66: LISU(6); break; // ISARU <- 0'e' (octal) + case 0x67: LISU(7); break; // ISARU <- 0'e' (octal) + case 0x68: LISL(0); break; // ISARL <- 0'e' (octal) + case 0x69: LISL(1); break; // ISARL <- 0'e' (octal) + case 0x6A: LISL(2); break; // ISARL <- 0'e' (octal) + case 0x6B: LISL(3); break; // ISARL <- 0'e' (octal) + case 0x6C: LISL(4); break; // ISARL <- 0'e' (octal) + case 0x6D: LISL(5); break; // ISARL <- 0'e' (octal) + case 0x6E: LISL(6); break; // ISARL <- 0'e' (octal) + case 0x6F: LISL(7); break; // ISARL <- 0'e' (octal) + + case 0x70: LIS(0); break; // A <- H'0a' + case 0x71: LIS(1); break; // A <- H'0a' + case 0x72: LIS(2); break; // A <- H'0a' + case 0x73: LIS(3); break; // A <- H'0a' + case 0x74: LIS(4); break; // A <- H'0a' + case 0x75: LIS(5); break; // A <- H'0a' + case 0x76: LIS(6); break; // A <- H'0a' + case 0x77: LIS(7); break; // A <- H'0a' + case 0x78: LIS(8); break; // A <- H'0a' + case 0x79: LIS(9); break; // A <- H'0a' + case 0x7a: LIS(10); break; // A <- H'0a' + case 0x7b: LIS(11); break; // A <- H'0a' + case 0x7c: LIS(12); break; // A <- H'0a' + case 0x7d: LIS(13); break; // A <- H'0a' + case 0x7e: LIS(14); break; // A <- H'0a' + case 0x7f: LIS(15); break; // A <- H'0a' + case 0x80: BT(0); break; // Branch on true - test operand against W register + case 0x81: BT(1); break; // Branch if positive (sign bit is set) + case 0x82: BT(2); break; // Branch on carry (carry bit is set) + case 0x83: BT(3); break; // Branch on true - test operand against W register + case 0x84: BT(4); break; // Branch on zero (zero bit is set) + case 0x85: BT(5); break; // Branch on true - test operand against W register + case 0x86: BT(6); break; // Branch on true - test operand against W register + case 0x87: BT(7); break; // Branch on true - test operand against W register + case 0x88: AM(); break; // A <- (A) + ((DC0))Binary; DC0 <- (DC0) + 1 + case 0x89: AMD(); break; // A <- (A) + ((DC0))Decimal; DC0 <- (DC0) + 1 + case 0x8A: NM(); break; // A <- (A) AND ((DC0)); DC0 <- (DC0) + 1 + case 0x8B: OM(); break; // A <- (A) OR ((DC0)); DC0 <- (DC0) + 1 + case 0x8C: XM(); break; // A <- (A) XOR ((DC0)); DC0 <- (DC0) + 1 + case 0x8D: CM(); break; // Set status flags on basis of: ((DC)) + (A) + 1; DC0 <- (DC0) + 1; DC <- (DC) + (A) + case 0x8E: ADC(); break; // DC <- (DC) + (A) + case 0x8F: BR7(); break; // Branch on ISAR (any of the low 3 bits of ISAR are reset) + case 0x90: BF(0); break; // Unconditional branch (always) + case 0x91: BF(1); break; // Branch if negative (sign bit is reset) + case 0x92: BF(2); break; // Branch if no carry (carry bit is reset) + case 0x93: BF(3); break; // Branch on false - test operand against W register + case 0x94: BF(4); break; // Branch on not zero (zero bit is reset) + case 0x95: BF(5); break; // Branch on false - test operand against W register + case 0x96: BF(6); break; // Branch on false - test operand against W register + case 0x97: BF(7); break; // Branch on false - test operand against W register + case 0x98: BF(8); break; // Branch if no overflow (OVF bit is reset) + case 0x99: BF(9); break; // Branch on false - test operand against W register + case 0x9A: BF(10); break; // Branch on false - test operand against W register + case 0x9B: BF(11); break; // Branch on false - test operand against W register + case 0x9C: BF(12); break; // Branch on false - test operand against W register + case 0x9D: BF(13); break; // Branch on false - test operand against W register + case 0x9E: BF(14); break; // Branch on false - test operand against W register + case 0x9F: BF(15); break; // Branch on false - test operand against W register + case 0xA0: INS_0(0); break; // A <- (I/O Port 0 or 1) + case 0xA1: INS_0(1); break; // A <- (I/O Port 0 or 1) + + + case 0xA4: INS_1(4); break; // DB <- Port Address (4 thru 15) + case 0xA5: INS_1(5); break; // DB <- Port Address (4 thru 15) + case 0xA6: INS_1(6); break; // DB <- Port Address (4 thru 15) + case 0xA7: INS_1(7); break; // DB <- Port Address (4 thru 15) + case 0xA8: INS_1(8); break; // DB <- Port Address (4 thru 15) + case 0xA9: INS_1(9); break; // DB <- Port Address (4 thru 15) + case 0xAA: INS_1(10); break; // DB <- Port Address (4 thru 15) + case 0xAB: INS_1(11); break; // DB <- Port Address (4 thru 15) + case 0xAC: INS_1(12); break; // DB <- Port Address (4 thru 15) + case 0xAD: INS_1(13); break; // DB <- Port Address (4 thru 15) + case 0xAE: INS_1(14); break; // DB <- Port Address (4 thru 15) + case 0xAF: INS_1(15); break; // DB <- Port Address (4 thru 15) + case 0xB0: OUTS_0(0); break; // I/O Port 0 or 1 <- (A) + case 0xB1: OUTS_0(1); break; // I/O Port 0 or 1 <- (A) + + + case 0xB4: OUTS_1(4); break; // DB <- Port Address (4 thru 15) + case 0xB5: OUTS_1(5); break; // DB <- Port Address (4 thru 15) + case 0xB6: OUTS_1(6); break; // DB <- Port Address (4 thru 15) + case 0xB7: OUTS_1(7); break; // DB <- Port Address (4 thru 15) + case 0xB8: OUTS_1(8); break; // DB <- Port Address (4 thru 15) + case 0xB9: OUTS_1(9); break; // DB <- Port Address (4 thru 15) + case 0xBA: OUTS_1(10); break; // DB <- Port Address (4 thru 15) + case 0xBB: OUTS_1(11); break; // DB <- Port Address (4 thru 15) + case 0xBC: OUTS_1(12); break; // DB <- Port Address (4 thru 15) + case 0xBD: OUTS_1(13); break; // DB <- Port Address (4 thru 15) + case 0xBE: OUTS_1(14); break; // DB <- Port Address (4 thru 15) + case 0xBF: OUTS_1(15); break; // DB <- Port Address (4 thru 15) + case 0xC0: AS(0); break; // A <- (A) + (r) Binary + case 0xC1: AS(1); break; // A <- (A) + (r) Binary + case 0xC2: AS(2); break; // A <- (A) + (r) Binary + case 0xC3: AS(3); break; // A <- (A) + (r) Binary + case 0xC4: AS(4); break; // A <- (A) + (r) Binary + case 0xC5: AS(5); break; // A <- (A) + (r) Binary + case 0xC6: AS(6); break; // A <- (A) + (r) Binary + case 0xC7: AS(7); break; // A <- (A) + (r) Binary + case 0xC8: AS(8); break; // A <- (A) + (r) Binary + case 0xC9: AS(9); break; // A <- (A) + (r) Binary + case 0xCA: AS(10); break; // A <- (A) + (r) Binary + case 0xCB: AS(11); break; // A <- (A) + (r) Binary + case 0xCC: AS_IS(); break; // A <- (A) + (r addressed via ISAR) Binary + case 0xCD: AS_IS_INC(); break; // A <- (A) + (r addressed via ISAR) Binary; Increment ISAR + case 0xCE: AS_IS_DEC(); break; // A <- (A) + (r addressed via ISAR) Binary; Decrement ISAR + + case 0xD0: ASD(0); break; // A <- (A) + (r) Decimal + case 0xD1: ASD(1); break; // A <- (A) + (r) Decimal + case 0xD2: ASD(2); break; // A <- (A) + (r) Decimal + case 0xD3: ASD(3); break; // A <- (A) + (r) Decimal + case 0xD4: ASD(4); break; // A <- (A) + (r) Decimal + case 0xD5: ASD(5); break; // A <- (A) + (r) Decimal + case 0xD6: ASD(6); break; // A <- (A) + (r) Decimal + case 0xD7: ASD(7); break; // A <- (A) + (r) Decimal + case 0xD8: ASD(8); break; // A <- (A) + (r) Decimal + case 0xD9: ASD(9); break; // A <- (A) + (r) Decimal + case 0xDA: ASD(10); break; // A <- (A) + (r) Decimal + case 0xDB: ASD(11); break; // A <- (A) + (r) Decimal + case 0xDC: ASD_IS(); break; // A <- (A) + (r addressed via ISAR) Decimal + case 0xDD: ASD_IS_INC(); break; // A <- (A) + (r addressed via ISAR) Decimal; Increment ISAR + case 0xDE: ASD_IS_DEC(); break; // A <- (A) + (r addressed via ISAR) Decimal; Decrement ISAR + + case 0xE0: XS(0); break; // A <- (A) XOR (r) + case 0xE1: XS(1); break; // A <- (A) XOR (r) + case 0xE2: XS(2); break; // A <- (A) XOR (r) + case 0xE3: XS(3); break; // A <- (A) XOR (r) + case 0xE4: XS(4); break; // A <- (A) XOR (r) + case 0xE5: XS(5); break; // A <- (A) XOR (r) + case 0xE6: XS(6); break; // A <- (A) XOR (r) + case 0xE7: XS(7); break; // A <- (A) XOR (r) + case 0xE8: XS(8); break; // A <- (A) XOR (r) + case 0xE9: XS(9); break; // A <- (A) XOR (r) + case 0xEA: XS(10); break; // A <- (A) XOR (r) + case 0xEB: XS(11); break; // A <- (A) XOR (r) + case 0xEC: XS_IS(); break; // A <- (A) XOR (r addressed via ISAR) + case 0xED: XS_IS_INC(); break; // A <- (A) XOR (r addressed via ISAR); Increment ISAR + case 0xEE: XS_IS_DEC(); break; // A <- (A) XOR (r addressed via ISAR); Decrement ISAR + + case 0xF0: NS(0); break; // A <- (A) XOR (r) + case 0xF1: NS(1); break; // A <- (A) XOR (r) + case 0xF2: NS(2); break; // A <- (A) XOR (r) + case 0xF3: NS(3); break; // A <- (A) XOR (r) + case 0xF4: NS(4); break; // A <- (A) XOR (r) + case 0xF5: NS(5); break; // A <- (A) XOR (r) + case 0xF6: NS(6); break; // A <- (A) XOR (r) + case 0xF7: NS(7); break; // A <- (A) XOR (r) + case 0xF8: NS(8); break; // A <- (A) XOR (r) + case 0xF9: NS(9); break; // A <- (A) XOR (r) + case 0xFA: NS(10); break; // A <- (A) XOR (r) + case 0xFB: NS(11); break; // A <- (A) XOR (r) + case 0xFC: NS_IS(); break; // A <- (A) XOR (r addressed via ISAR) + case 0xFD: NS_IS_INC(); break; // A <- (A) XOR (r addressed via ISAR); Increment ISAR + case 0xFE: NS_IS_DEC(); break; // A <- (A) XOR (r addressed via ISAR); Decrement ISAR + + default: ILLEGAL(); break; // Illegal Opcode + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Operations.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Operations.cs new file mode 100644 index 0000000000..648f3120d3 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Operations.cs @@ -0,0 +1,299 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + /// + /// ALU Operations + /// + public sealed partial class F3850 + { + public void Read_Func(byte dest, byte src_l, byte src_h) + { + Regs[dest] = ReadMemory((ushort)(Regs[src_l] | (Regs[src_h]) << 8)); + } + + public void Write_Func(byte dest_l, byte dest_h, byte src) + { + WriteMemory((ushort)(Regs[dest_l] | (Regs[dest_h] << 8)), Regs[src]); + } + + public void IN_Func(byte dest, byte src) + { + Regs[dest] = ReadHardware(Regs[src]); + } + + public void LR_A_IO_Func(byte dest, byte src) + { + // helper method that simulates transferring DB to accumulator (as part of an IN operation) + // this sets flags accordingly + // dest should always == A and src should always == DB for this function + + // overflow and carry unconditionally reset + FlagO = false; + FlagC = false; + + Regs[dest] = Regs[src]; + + FlagZ = Regs[dest] == 0; + + // Sign SET if MSB == 0 (positive signed number) + FlagS = Regs[dest].Bit(7) == false; + + // ICB flag not affected + } + + public void ClearFlags_Func() + { + FlagC = false; + FlagO = false; + FlagS = false; + FlagZ = false; + } + + public void LR_Func(byte dest, byte src) + { + if (dest == DB) + { + // byte storage + Regs[dest] = (byte)(Regs[src] & 0xFF); + } + else if (dest == W) + { + // mask for status register + Regs[dest] = (byte)(Regs[src] & 0x1F); + } + else if (dest == ISAR) + { + // mask for ISAR register + Regs[dest] = (byte)(Regs[src] & 0x3F); + } + else + { + Regs[dest] = Regs[src]; + } + } + + /// + /// Right shift 'src' 'shift' positions (zero fill) + /// + /// + /// + public void SR_Func(byte src, byte shift) + { + // overflow and carry unconditionally reset + FlagO = false; + FlagC = false; + + Regs[src] = (byte)((Regs[src] >> shift) & 0xFF); + + FlagZ = Regs[src] == 0; + + // Sign SET if MSB == 0 (positive signed number) + FlagS = Regs[src].Bit(7) == false; + + // ICB flag not affected + } + + /// + /// Left shit 'src' 'shift' positions (zero fill) + /// + /// + /// + public void SL_Func(byte src, byte shift) + { + // overflow and carry unconditionally reset + FlagO = false; + FlagC = false; + + Regs[src] = (byte)((Regs[src] << shift) & 0xFF); + + FlagZ = Regs[src] == 0; + + // Sign SET if MSB == 0 (positive signed number) + FlagS = Regs[src].Bit(7) == false; + + // ICB flag not affected + } + + public void ADD_Func_(byte dest, byte src) + { + // addition of 2 signed bytes + ushort dest16 = Regs[dest]; + + dest16 += Regs[src]; + + FlagC = dest16.Bit(8); + FlagZ = (dest16 & 0xFF) == 0; + + ushort ans = (ushort)(dest16 & 0xFF); + + // Sign SET if MSB == 0 (positive signed number) + FlagS = ans.Bit(7) == false; + + // overflow based on carry out of bit6 XOR carry out of bit7 + var b6c = dest16 >> 7; + var b7c = dest16 >> 8; + FlagO = (b6c ^ b7c) != 0; + + Regs[dest] = (byte)ans; + } + + public void ADD_Func(byte dest, byte src) + { + // addition of 2 signed bytes + var sD = Regs[dest] & 0x80; + var sS = Regs[src] & 0x80; + var res = Regs[dest] + Regs[src]; + var sR = res & 0x80; + + FlagS = !((res & 0x80) > 0); + FlagZ = (res & 0xff) == 0; + FlagO = (sD == sS && sD != sR); + FlagC = (res & 0x100) > 0; + + Regs[dest] = (byte) (res & 0xff); + } + + public void SUB_Func(byte dest, byte src) + { + Regs[ALU0] = (byte)((Regs[src] ^ 0xff) + 1); + ADD_Func(dest, ALU0); + } + + public void ADDD_Func(byte dest, byte src) + { + var d = Regs[dest]; + var s = Regs[src]; + var bcdRes = d + s; + + var carryIntermediate = ((d & 0x0F) + (s & 0x0F)) > 0x0F; + var carryUpper = bcdRes >= 0x100; + + // temporary storage and set flags + Regs[ALU0] = Regs[dest]; + Regs[ALU1] = Regs[src]; + ADD_Func(ALU0, ALU1); + + if (!carryIntermediate) + { + bcdRes = (bcdRes & 0xF0) | ((bcdRes + 0x0A) & 0x0F); + } + + if (!carryUpper) + { + bcdRes = (bcdRes + 0xA0); + } + + Regs[dest] = (byte)(bcdRes & 0xFF); + } + + public void CI_Func() + { + // compare immediate + // we need to achieve DB - A + 1 + // flags set - results not stored + var comp = ((Regs[A] ^ 0xFF) + 1); + Regs[ALU0] = (byte)comp; + Regs[ALU1] = Regs[DB]; + ADD_Func(ALU1, ALU0); + } + /* + public void ADDD_Func_(ushort dest, ushort src) + { + // from MAME f8.cpp (BSD-3) + // https://github.com/mamedev/mame/blob/97b67170277437131adf6ed4d60139c172529e4f/src/devices/cpu/f8/f8.cpp#L264 + byte d = (byte)Regs[dest]; + byte s = (byte)Regs[src]; + byte tmp = (byte)(d + s); + + byte c = 0; // high order carry + byte ic = 0; // low order carry + + if (((d + s) & 0xFF0) > 0xF0) + { + c = 1; + } + + if ((d & 0x0F) + (s & 0x0F) > 0x0F) + { + ic = 1; + } + + //ALU_ClearFlags(); + ALU_ADD8_FLAGSONLY_Func(dest, src); + Regs[ALU0] = tmp; + //ALU_SetFlags_SZ(ALU0); + + if (c == 0 && ic == 0) + { + tmp = (byte)(((tmp + 0xa0) & 0xf0) + ((tmp + 0x0a) & 0x0f)); + } + + if (c == 0 && ic == 1) + { + tmp = (byte)(((tmp + 0xa0) & 0xf0) + (tmp & 0x0f)); + } + + if (c == 1 && ic == 0) + { + tmp = (byte)((tmp & 0xf0) + ((tmp + 0x0a) & 0x0f)); + } + + Regs[dest] = tmp; + } + */ + + public void AND_Func(byte dest, byte src) + { + // overflow and carry unconditionally reset + FlagO = false; + FlagC = false; + + Regs[dest] = (byte)(Regs[dest] & Regs[src]); + + FlagZ = Regs[src] == 0; + + // Sign SET if MSB == 0 (positive signed number) + FlagS = Regs[src].Bit(7) == false; + + // ICB flag not affected + } + + public void OR_Func(byte dest, byte src) + { + // overflow and carry unconditionally reset + FlagO = false; + FlagC = false; + + Regs[dest] = (byte)(Regs[dest] | Regs[src]); + + FlagZ = Regs[src] == 0; + + // Sign SET if MSB == 0 (positive signed number) + FlagS = Regs[src].Bit(7) == false; + + // ICB flag not affected + } + + public void XOR_Func(byte dest, byte src) + { + // overflow and carry unconditionally reset + FlagO = false; + FlagC = false; + + Regs[dest] = (byte)(Regs[dest] ^ Regs[src]); + + FlagZ = Regs[src] == 0; + + // Sign SET if MSB == 0 (positive signed number) + FlagS = Regs[src].Bit(7) == false; + + // ICB flag not affected + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Registers.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Registers.cs new file mode 100644 index 0000000000..c084cc402f --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Registers.cs @@ -0,0 +1,198 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms.VisualStyles; +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + /// + /// Internal Registers + /// + public sealed partial class F3850 + { + /// + /// Registers (counters and scratchpad) + /// + public byte[] Regs = new byte[100]; + + // scratchpad registers live in Regs 0-64 + public byte J = 9; + public byte Hh = 10; + public byte Hl = 11; + public byte Kh = 12; + public byte Kl = 13; + public byte Qh = 14; + public byte Ql = 15; + + // Internal CPU counters kept after the scratchpad for ease of implementation + /// + /// Accumulator + /// + public byte A = 65; + /// + /// Status Register + /// + public byte W = 66; + /// + /// Indirect Scratchpad Address Register + /// (6bit) + /// + public byte ISAR = 67; + /// + /// Primary Program Counter (high byte) + /// + public byte PC0h = 68; + /// + /// Primary Program Counter (low byte) + /// + public byte PC0l = 69; + /// + /// Backup Program Counter (high byte) + /// + public byte PC1h = 70; + /// + /// Backup Program Counter (low byte) + /// + public byte PC1l = 71; + /// + /// Data counter (high byte) + /// + public byte DC0h = 72; + /// + /// Data Counter (low byte) + /// + public byte DC0l = 73; + /// + /// Temporary Arithmetic Storage + /// + public byte ALU0 = 74; + /// + /// Temporary Arithmetic Storage + /// + public byte ALU1 = 75; + /// + /// Data Bus + /// + public byte DB = 76; + /// + /// IO Bus/Latch + /// + public byte IO = 77; + /// + /// 0x00 value for arithmetic ops + /// + public byte ZERO = 78; + /// + /// 0x01 value for arithmetic ops + /// + public byte ONE = 79; + /// + /// 0xFF value for arithmetic ops + /// + public byte BYTE = 80; + + + /// + /// Status Register - Sign Flag + /// + public bool FlagS + { + get { return (Regs[W] & 0x01) != 0; } + set { Regs[W] = (byte)((Regs[W] & ~0x01) | (value ? 0x01 : 0x00)); } + } + + /// + /// Status Register - Carry Flag + /// + public bool FlagC + { + get { return (Regs[W] & 0x02) != 0; } + set { Regs[W] = (byte)((Regs[W] & ~0x02) | (value ? 0x02 : 0x00)); } + } + + /// + /// Status Register - Zero Flag + /// + public bool FlagZ + { + get { return (Regs[W] & 0x04) != 0; } + set { Regs[W] = (byte)((Regs[W] & ~0x04) | (value ? 0x04 : 0x00)); } + } + + /// + /// Status Register - Overflow Flag + /// + public bool FlagO + { + get { return (Regs[W] & 0x08) != 0; } + set { Regs[W] = (byte)((Regs[W] & ~0x08) | (value ? 0x08 : 0x00)); } + } + + /// + /// Status Register - Interrupt Master Enable Flag + /// + public bool FlagICB + { + get { return (Regs[W] & 0x10) != 0; } + set { Regs[W] = (byte)((Regs[W] & ~0x10) | (value ? 0x10 : 0x00)); } + } + + /// + /// Access to the full 16-bit Primary Program Counter + /// + public ushort RegPC0 + { + get { return (ushort)(Regs[PC0l] | (Regs[PC0h] << 8)); } + set + { + Regs[PC0l] = (byte)(value & 0xFF); + Regs[PC0h] = (byte)((value >> 8) & 0xFF); + } + } + + /// + /// Access to the full 16-bit Backup Program Counter + /// + public ushort RegPC1 + { + get { return (ushort)(Regs[PC1l] | (Regs[PC1h] << 8)); } + set + { + Regs[PC1l] = (byte)(value & 0xFF); + Regs[PC1h] = (byte)((value >> 8) & 0xFF); + } + } + + /// + /// Access to the full 16-bit Data Counter + /// + public ushort RegDC0 + { + get { return (ushort)(Regs[DC0l] | (Regs[DC0h] << 8)); } + set + { + Regs[DC0l] = (byte)(value & 0xFF); + Regs[DC0h] = (byte)((value >> 8) & 0xFF); + } + } + + private void ResetRegisters() + { + for (var i = 0; i < Regs.Length; i++) + { + Regs[i] = 0; + } + + Regs[ONE] = 1; + Regs[BYTE] = 0xFF; + + // testing only - fill scratchpad with 0xff + for (int i = 0; i < 64; i++) + Regs[i] = 0xff; + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Tables.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Tables.cs new file mode 100644 index 0000000000..8273969482 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Tables.cs @@ -0,0 +1,1376 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BizHawk.Common; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Components; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + /// + /// Vectors of Instruction Operations + /// + public sealed partial class F3850 + { + private void LR_A_KU() + { + PopulateCURINSTR( + // S + OP_LR8, A, Kh, // A <- (r12) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_A_KL() + { + PopulateCURINSTR( + // S + OP_LR8, A, Kl, // A <- (r13) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_A_QU() + { + PopulateCURINSTR( + // S + OP_LR8, A, Qh, // A <- (r14) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_A_QL() + { + PopulateCURINSTR( + // S + OP_LR8, A, Ql, // A <- (r15) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_KU_A() + { + PopulateCURINSTR( + // S + OP_LR8, Kh, A, // r12 <- (A) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_KL_A() + { + PopulateCURINSTR( + // S + OP_LR8, Kl, A, // r13 <- (A) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_QU_A() + { + PopulateCURINSTR( + // S + OP_LR8, Qh, A, // r14 <- (A) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_QL_A() + { + PopulateCURINSTR( + // S + OP_LR8, Ql, A, // r15 <- (A) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_K_P() + { + PopulateCURINSTR( + // L + ROMC_07, // DB <- (PC1h) + IDLE, + IDLE, + OP_LR8, Kh, DB, // r12 <- (DB) + IDLE, + IDLE, + // L + ROMC_0B, // DB <- (PC1l) + IDLE, + IDLE, + OP_LR8, Kl, DB, // r13 <- (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void LR_P_K() + { + PopulateCURINSTR( + // L + OP_LR8, DB, Kh, // DB <- (r12) + IDLE, + IDLE, + ROMC_15, // PC1h <- (DB) + IDLE, + IDLE, + // L + OP_LR8, DB, Kl, // DB <- (r13) + IDLE, + IDLE, + ROMC_18, // PC1l <- (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void LR_A_IS() + { + PopulateCURINSTR( + // S + OP_LR8, A, ISAR, // A <- (ISAR) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_IS_A() + { + PopulateCURINSTR( + // S + OP_LR8, ISAR, A, // ISAR <- (A) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void PK() + { + PopulateCURINSTR( + // L + OP_LR8, DB, Kl, // DB <- (r13) + IDLE, + IDLE, + ROMC_12, // PC1 <- (PC0); PC0l <- (DB) + IDLE, + IDLE, + // L + OP_LR8, DB, Kh, // DB <- (r12) + IDLE, + IDLE, + ROMC_14, // PC0h <- (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void LR_P0_Q() + { + PopulateCURINSTR( + // L + OP_LR8, DB, Ql, // DB <- (r15) + OP_EI, // Set ICB Flag + IDLE, + ROMC_17, // PC0l <- (DB) + IDLE, + IDLE, + // L + OP_LR8, DB, Qh, // DB <- (r14) + IDLE, + IDLE, + ROMC_14, // PC0h <- DB + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void LR_Q_DC() + { + PopulateCURINSTR( + // L + ROMC_06, // DB <- (DC0h) + IDLE, + IDLE, + OP_LR8, Qh, DB, // r14 <- (DB) + IDLE, + IDLE, + // L + ROMC_09, // DB <- (DC0l) + IDLE, + IDLE, + OP_LR8, Ql, DB, // r15 <- (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void LR_DC_Q() + { + PopulateCURINSTR( + // L + OP_LR8, DB, Qh, // DB <- (r14) + IDLE, + IDLE, + ROMC_16, // DC0h <- (DB) + IDLE, + IDLE, + // L + OP_LR8, DB, Ql, // DB <- (r15) + IDLE, + IDLE, + ROMC_19, // DC0l <- (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void LR_DC_H() + { + PopulateCURINSTR( + // L + OP_LR8, DB, Hh, // DB <- (r10) + IDLE, + IDLE, + ROMC_16, // DC0h <- (DB) + IDLE, + IDLE, + // L + OP_LR8, DB, Hl, // DB <- (r11) + IDLE, + IDLE, + ROMC_19, // DC0l <- (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void LR_H_DC() + { + PopulateCURINSTR( + // L + ROMC_06, // DB <- (DC0h) + IDLE, + IDLE, + OP_LR8, Hh, DB, // r10 <- (DB) + IDLE, + IDLE, + // L + ROMC_09, // DB <- (DC0l) + IDLE, + IDLE, + OP_LR8, Hl, DB, // r11 <- (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void SHIFT_R(byte index) + { + PopulateCURINSTR( + // S + OP_SHFT_R, A, index, // A >> (index) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void SHIFT_L(byte index) + { + PopulateCURINSTR( + // S + OP_SHFT_L, A, index, // A << (index) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LM() + { + PopulateCURINSTR( + // L + ROMC_02, // DB <- ((DC0)); DC0++ + IDLE, + IDLE, + OP_LR8, A, DB, // A <- (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void ST() + { + PopulateCURINSTR( + // L + OP_LR8, DB, A, // DB <- (A) + IDLE, + IDLE, + ROMC_05, // ((DC0)) <- (DB); DC0++ + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void COM() + { + PopulateCURINSTR( + // S + OP_XOR8, A, BYTE, // A <- A XOR 0xFF (compliment accumulator) + //OP_COM, // A <- A XOR 0xFF (compliment accumulator) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LNK() + { + PopulateCURINSTR( + // S + OP_LNK, // A <- A + FlagC + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void DI() + { + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + OP_DI, // Clear ICB + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void EI() + { + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + OP_EI, // Set ICB + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void POP() + { + PopulateCURINSTR( + // S + ROMC_04, // PC0 <- (PC1) + IDLE, + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + OP_EI, // Set ICB Flag + IDLE, + END); + } + + private void LR_W_J() + { + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + IDLE, + OP_LR8, W, J, // W <- (r9) + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + OP_EI, // Set ICB Flag + IDLE, + END); + } + + private void LR_J_W() + { + PopulateCURINSTR( + // S + OP_LR8, J, W, // r9 <- (W) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void INC() + { + PopulateCURINSTR( + // S + OP_INC8, A, ONE, // A <- A + 1 + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LI() + { + PopulateCURINSTR( + // L + ROMC_03_L, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, //OP_CLEAR_FLAGS, + OP_LR8, A, DB, // A <- (DB) + IDLE, //OP_SET_FLAGS_SZ, A, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void NI() + { + PopulateCURINSTR( + // L + ROMC_03_L, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + OP_AND8, A, DB, // A <- (A) AND (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void OI() + { + PopulateCURINSTR( + // L + ROMC_03_L, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + OP_OR8, A, DB, // A <- (A) OR (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void XI() + { + PopulateCURINSTR( + // L + ROMC_03_L, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + OP_XOR8, A, DB, // A <- (A) XOR (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void AI() + { + PopulateCURINSTR( + // L + ROMC_03_L, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + OP_ADD8, A, DB, // A <- (A) + (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void CI() + { + PopulateCURINSTR( + // L + ROMC_03_L, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + OP_CI, // Set flags for A <- (DB) + (-A) + 1 (do not store result in A) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + + private void ILLEGAL() + { + PopulateCURINSTR( + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void IN() + { + PopulateCURINSTR( + // L + ROMC_03_L, // DB/IO <- ((PC0)); PC0++ + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + // L + ROMC_1B, // DB <- ((IO)); + IDLE, + IDLE, + OP_LR_A_DB_IO, A, DB, // A <- (DB) - flags set as result of IN or INS operation + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void OUT() + { + PopulateCURINSTR( + // L + ROMC_03_L, // DB/IO <- ((PC0)); PC0++ + IDLE, + IDLE, + OP_LR8, DB, A, // DB <- (A) + IDLE, + IDLE, + // L + ROMC_1A, // ((IO)) <- DB + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + OP_EI, // Set ICB Flag + IDLE, + END); + } + + private void PI() + { + PopulateCURINSTR( + // L + ROMC_03_L, // DB/IO <- ((PC0)); PC0++ + IDLE, + IDLE, + OP_LR8, A, DB, // A <- (DB) + IDLE, + IDLE, + // S + ROMC_0D, // PC1 <- PC0 + 1 + IDLE, + IDLE, + IDLE, + // L + ROMC_0C, // DB <- ((PC0)); PC0l <- (DB) + IDLE, + IDLE, + OP_LR8, DB, A, // DB <- (A) + IDLE, + IDLE, + // L + ROMC_14, // PC0h <- (DB) + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + OP_EI, // Set ICB Flag + IDLE, + END); + } + + private void JMP() + { + PopulateCURINSTR( + // L + ROMC_03_L, // DB/IO <- ((PC0)); PC0++ + IDLE, + IDLE, + OP_LR8, A, DB, // A <- (DB) + IDLE, + IDLE, + // L + ROMC_0C, // DB <- ((PC0)); PC0l <- DB + IDLE, + IDLE, + OP_LR8, DB, A, // DB <- (A) + IDLE, + IDLE, + // L + ROMC_14, // PC0h <- (DB) + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + OP_EI, // Set ICB Flag + IDLE, + END); + } + + private void DCI() + { + PopulateCURINSTR( + // L + ROMC_11, // DB <- ((PC0)); DC0h <- DB + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + // S + ROMC_03_S, // DB/IO <- ((PC0)); PC0++ + IDLE, + IDLE, + IDLE, + // L + ROMC_0E, // DB <- ((PC0)); DC0l <- (DB) + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + // S + ROMC_03_S, // DB/IO <- ((PC0)); PC0++ + IDLE, + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void NOP() + { + PopulateCURINSTR( + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void XDC() + { + PopulateCURINSTR( + // S + ROMC_1D, // DC0 <-> DC1 + IDLE, + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void DS(byte rIndex) + { + // only scratch registers 0-16 + rIndex = (byte)(rIndex & 0x0F); + + PopulateCURINSTR( + // L + IDLE, + OP_SUB8, rIndex, ONE, + //OP_ADD8, rIndex, BYTE, + IDLE, + ROMC_00_L, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + private void DS_ISAR() + { + PopulateCURINSTR( + // L + IDLE, + OP_SUB8, Regs[ISAR], ONE, // r[ISAR] = r[ISAR] + 0xff + IDLE, + ROMC_00_L, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void DS_ISAR_INC() + { + PopulateCURINSTR( + // L + IDLE, + OP_SUB8, Regs[ISAR], ONE, // r[ISAR] = r[ISAR] + 0xff + IDLE, + OP_IS_INC, // Inc ISAR + ROMC_00_L, // DB <- ((PC0)); PC0++ + END); + } + + private void DS_ISAR_DEC() + { + PopulateCURINSTR( + // L + IDLE, + OP_SUB8, Regs[ISAR], ONE, // r[ISAR] = r[ISAR] + 0xff + IDLE, + OP_IS_DEC, // Dec ISAR + ROMC_00_L, // DB <- ((PC0)); PC0++ + END); + } + + private void LR_A_R(byte rIndex) + { + // only scratch registers 0-16 + rIndex = (byte)(rIndex & 0x0F); + + PopulateCURINSTR( + // S + OP_LR8, A, rIndex, // A <- (rIndex) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_A_ISAR() + { + PopulateCURINSTR( + // S + OP_LR8, A, Regs[ISAR], // A <- ((ISAR)) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_A_ISAR_INC() + { + PopulateCURINSTR( + // S + OP_LR8, A, Regs[ISAR], // A <- ((ISAR)) + OP_IS_INC, // Inc ISAR + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void LR_A_ISAR_DEC() + { + PopulateCURINSTR( + // S + OP_LR8, A, Regs[ISAR], // A <- ((ISAR)) + OP_IS_DEC, // Dec ISAR + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void LR_R_A(byte rIndex) + { + // only scratch registers 0-16 + rIndex = (byte)(rIndex & 0x0F); + + PopulateCURINSTR( + // S + OP_LR8, rIndex, A, // rIndex <- (A) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_ISAR_A() + { + PopulateCURINSTR( + // S + OP_LR8, Regs[ISAR], A, // rIndex <- (A) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LR_ISAR_A_INC() + { + PopulateCURINSTR( + // S + OP_LR8, Regs[ISAR], A, // rIndex <- (A) + OP_IS_INC, // Inc ISAR + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void LR_ISAR_A_DEC() + { + PopulateCURINSTR( + // S + OP_LR8, Regs[ISAR], A, // rIndex <- (A) + OP_IS_DEC, // Dec ISAR + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void LISU(byte octal) + { + PopulateCURINSTR( + // S + OP_LISU, octal, // set the upper octal ISAR bits (b3,b4,b5) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LISL(byte octal) + { + PopulateCURINSTR( + // S + OP_LISL, octal, // set the lower octal ISAR bits (b0,b1,b2) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void LIS(byte index) + { + PopulateCURINSTR( + // S + OP_LIS, index, // A <- index + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void BT(byte index) + { + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + IDLE, + IDLE, + OP_BT, index); // no END as there is branching logic within OP_BT + } + + private void AM() + { + PopulateCURINSTR( + // L + ROMC_02, // DB <- ((DC0)); DC0++ + IDLE, + IDLE, + OP_ADD8, A, DB, // A <- (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void AMD() + { + PopulateCURINSTR( + // L + ROMC_02, // DB <- ((DC0)); DC0++ + IDLE, + IDLE, + OP_ADD8D, A, DB, // A <- (A) + (DB) decimal + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void NM() + { + PopulateCURINSTR( + // L + ROMC_02, // DB <- ((DC0)); DC0++ + IDLE, + IDLE, + OP_AND8, A, DB, // A <- (A) AND (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void OM() + { + PopulateCURINSTR( + // L + ROMC_02, // DB <- ((DC0)); DC0++ + IDLE, + IDLE, + OP_OR8, A, DB, // A <- (A) OR (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void XM() + { + PopulateCURINSTR( + // L + ROMC_02, // DB <- ((DC0)); DC0++ + IDLE, + IDLE, + OP_XOR8, A, DB, // A <- (A) XOR (DB) + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void CM() + { + PopulateCURINSTR( + // L + ROMC_02, // DB <- ((DC0)); DC0++ + IDLE, + IDLE, + OP_CI, A, + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void ADC() + { + PopulateCURINSTR( + // L + OP_LR8, DB, A, // DB <- (A) + IDLE, + IDLE, + ROMC_0A, + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void BR7() + { + PopulateCURINSTR( + OP_BR7); // no END as there is branching logic within OP_BR7 + } + + private void BF(byte index) + { + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + IDLE, + IDLE, + OP_BF, index); // no END as there is branching logic within OP_BF + } + + private void INS_0(byte index) + { + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + IDLE, + OP_IN, A, index, // A <- ((Port index - 0/1)) + OP_LR_A_DB_IO, A, A, // A <- (A) - flags set as result of IN or INS operation + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void INS_1(byte index) + { + Regs[IO] = index; // latch port index early + + PopulateCURINSTR( + // L + ROMC_1C_L, // Idle + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + // L + ROMC_1B, // DB <- ((IO)) + IDLE, + IDLE, + OP_LR_A_DB_IO, A, DB, // A <- (DB) - flags set as result of IN or INS operation + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void OUTS_0(byte index) + { + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + IDLE, + OP_OUT, index, A, // Port <- (A) + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void OUTS_1(byte index) + { + Regs[IO] = index; // latch port index early + + PopulateCURINSTR( + // L + ROMC_1C_L, // Idle + IDLE, + IDLE, + OP_LR8, DB, A, // DB <- (A) + IDLE, + IDLE, + // L + ROMC_1A, // ((IO)) <- (DB) + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + OP_EI, // Set ICB Flag + IDLE, + END); + } + + private void AS(byte rIndex) + { + // only scratch registers 0-15 + rIndex = (byte) (rIndex & 0x0F); + + PopulateCURINSTR( + // S + OP_ADD8, A, rIndex, // A <- (A) + (rIndex) + IDLE, + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void AS_IS() + { + PopulateCURINSTR( + // S + IDLE, + OP_ADD8, A, Regs[ISAR], // A <- (A) + ((ISAR)); + IDLE, + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void AS_IS_INC() + { + PopulateCURINSTR( + // S + IDLE, + OP_ADD8, A, Regs[ISAR], // A <- (A) + ((ISAR)); + OP_IS_INC, // Inc ISAR + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void AS_IS_DEC() + { + PopulateCURINSTR( + // S + IDLE, + OP_ADD8, A, Regs[ISAR], // A <- (A) + ((ISAR)); + OP_IS_DEC, // Dec ISAR + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void ASD(byte rIndex) + { + // only scratch registers 0-15 + rIndex = (byte)(rIndex & 0x0F); + + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + IDLE, + OP_ADD8D, A, rIndex, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void ASD_IS() + { + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + IDLE, + OP_ADD8D, A, Regs[ISAR], + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void ASD_IS_INC() + { + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + IDLE, + OP_ADD8D, A, Regs[ISAR], + OP_IS_INC, // Inc ISAR + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void ASD_IS_DEC() + { + PopulateCURINSTR( + // S + ROMC_1C_S, // Idle + IDLE, + OP_ADD8D, A, Regs[ISAR], + OP_IS_DEC, // Dec ISAR + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void XS(byte rIndex) + { + // only scratch registers 0-15 + rIndex = (byte)(rIndex & 0x0F); + + PopulateCURINSTR( + // S + IDLE, + OP_XOR8, A, rIndex, // A <- (A) XOR (reg) + IDLE, + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void XS_IS() + { + PopulateCURINSTR( + // S + OP_XOR8, A, Regs[ISAR], // A <- (A) XOR ((ISAR)) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void XS_IS_INC() + { + PopulateCURINSTR( + // S + OP_XOR8, A, Regs[ISAR], // A <- (A) XOR ((ISAR)) + OP_IS_INC, // Inc ISAR + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void XS_IS_DEC() + { + PopulateCURINSTR( + // S + OP_XOR8, A, Regs[ISAR], // A <- (A) XOR ((ISAR)) + OP_IS_DEC, // Dec ISAR + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void NS(byte rIndex) + { + // only scratch registers 0-15 + rIndex = (byte)(rIndex & 0x0F); + + PopulateCURINSTR( + // S + OP_AND8, A, rIndex, // A <- (A) AND (reg) + IDLE, + ROMC_00_S, // DB <- ((PC0)); PC0++ + END); + } + + private void NS_IS() + { + PopulateCURINSTR( + // S + OP_AND8, A, Regs[ISAR], // A <- (A) AND ((ISAR)) + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void NS_IS_INC() + { + PopulateCURINSTR( + // S + OP_AND8, A, Regs[ISAR], // A <- (A) AND ((ISAR)) + OP_IS_INC, // Inc ISAR + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + private void NS_IS_DEC() + { + PopulateCURINSTR( + // S + OP_AND8, A, Regs[ISAR], // A <- (A) AND ((ISAR)) + OP_IS_DEC, // Dec ISAR + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + END); + } + + + private void DO_BRANCH() + { + PopulateCURINSTR( + // L + IDLE, + ROMC_01, // forward or backward displacement + IDLE, + IDLE, + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + + private void DONT_BRANCH() + { + PopulateCURINSTR( + // S + IDLE, + ROMC_03_S, // immediate operand fetch + IDLE, + IDLE, + // S + ROMC_00_S, // DB <- ((PC0)); PC0++ + IDLE, + IDLE, + END); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs new file mode 100644 index 0000000000..1532d09ba0 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs @@ -0,0 +1,809 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using BizHawk.Common; +using BizHawk.Common.NumberExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + /// + /// Fairchild F3850 (F8) CPU (Channel F-specific implementation) + /// + /// The F8 microprocessor is made up of separate interchangeable devices + /// The Channel F has: + /// * x1 F3850 CPU (central processing unit) + /// * x2 F3851 PSU (program storage unit) + /// The CPU does not have its own data counters or program counters, rather each F8 component connected to the CPU + /// holds their own PCs and SPs and are all connected to the ROMC (ROM control) pins that are serviced by the CPU. + /// Every device must respond to changes in the CPU ROMC pins output and they each update their PCs and DCs in the same way. + /// e.g. SPs and PCs should always be identical + /// Each device has a factory ROM mask applied and with every ROMC change observed is able to know whether it should respond (via the shared data bus) + /// or not based on the value within its counters. + /// + /// For this reason we will hold the PCs and SPs within the F3850 implementation. + /// + /// We are currently also *not* using a separate F3851 implementation. In reality the F3851 chip has/does: + /// * 1024 byte masked ROM + /// * x2 16-bit program counters + /// * x1 16-bit data counter + /// * Programmable timer + /// * Interrupt logic + /// + /// However, the Channel F does not use the timer or interrupt logic at all (as far as I can see) so we can hopefully just + /// maintain the PC and DC here in the CPU and move the ROMs into the core. + /// + public sealed partial class F3850 + { + // operations that can take place in an instruction + public const byte ROMC_01 = 1; + public const byte ROMC_02 = 2; + public const byte ROMC_03_S = 3; + public const byte ROMC_04 = 4; + public const byte ROMC_05 = 5; + public const byte ROMC_06 = 6; + public const byte ROMC_07 = 7; + public const byte ROMC_08 = 8; + public const byte ROMC_09 = 9; + public const byte ROMC_0A = 10; + public const byte ROMC_0B = 11; + public const byte ROMC_0C = 12; + public const byte ROMC_0D = 13; + public const byte ROMC_0E = 14; + public const byte ROMC_0F = 15; + public const byte ROMC_10 = 16; + public const byte ROMC_11 = 17; + public const byte ROMC_12 = 18; + public const byte ROMC_13 = 19; + public const byte ROMC_14 = 20; + public const byte ROMC_15 = 21; + public const byte ROMC_16 = 22; + public const byte ROMC_17 = 23; + public const byte ROMC_18 = 24; + public const byte ROMC_19 = 25; + public const byte ROMC_1A = 26; + public const byte ROMC_1B = 27; + public const byte ROMC_1C_S = 28; + public const byte ROMC_1D = 29; + public const byte ROMC_1E = 30; + public const byte ROMC_1F = 31; + public const byte ROMC_00_S = 32; + public const byte ROMC_00_L = 33; + public const byte ROMC_03_L = 34; + public const byte ROMC_1C_L = 35; + + public const byte IDLE = 0; + public const byte END = 51; + + public const byte OP_LR8 = 100; + public const byte OP_SHFT_R = 101; + public const byte OP_SHFT_L = 102; + public const byte OP_LNK = 103; + public const byte OP_DI = 104; + public const byte OP_EI = 105; + public const byte OP_INC8 = 106; + public const byte OP_AND8 = 107; + public const byte OP_OR8 = 108; + public const byte OP_XOR8 = 109; + //public const byte OP_COM = 110; + public const byte OP_SUB8 = 110; + public const byte OP_ADD8 = 111; + public const byte OP_CI = 112; + public const byte OP_IS_INC = 113; + public const byte OP_IS_DEC = 114; + public const byte OP_LISU = 115; + public const byte OP_LISL = 116; + public const byte OP_BT = 117; + public const byte OP_ADD8D = 118; + public const byte OP_BR7 = 119; + public const byte OP_BF = 120; + public const byte OP_IN = 121; + public const byte OP_OUT = 122; + //public const byte OP_AS_IS = 123; + //public const byte OP_XS_IS = 124; + //public const byte OP_NS_IS = 125; + public const byte OP_LR_A_DB_IO = 126; + public const byte OP_DS = 127; + //public const byte OP_CLEAR_FLAGS = 126; + //public const byte OP_SET_FLAGS_SZ = 127; + public const byte OP_LIS = 128; + + + public F3850() + { + Reset(); + } + + public void Reset() + { + ResetRegisters(); + TotalExecutedCycles = 0; + instr_pntr = 0; + + PopulateCURINSTR( + ROMC_1C_S, // S + IDLE, + IDLE, + IDLE, + ROMC_08, // L + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + ROMC_00_S, // S + IDLE, + IDLE, + END); + + ClearFlags_Func(); + FlagICB = false; + } + + public IMemoryCallbackSystem MemoryCallbacks { get; set; } + + // Memory Access + public Func ReadMemory; + public Action WriteMemory; + public Func PeekMemory; + public Func DummyReadMemory; + + // Hardware I/O Port Access + public Func ReadHardware; + public Action WriteHardware; + + public Action OnExecFetch; + + public void SetCallbacks + ( + Func ReadMemory, + Func DummyReadMemory, + Func PeekMemory, + Action WriteMemory, + Func ReadHardware, + Action WriteHardware + ) + { + this.ReadMemory = ReadMemory; + this.DummyReadMemory = DummyReadMemory; + this.PeekMemory = PeekMemory; + this.WriteMemory = WriteMemory; + this.ReadHardware = ReadHardware; + this.WriteHardware = WriteHardware; + } + + /// + /// Runs a single CPU clock cycle + /// + public void ExecuteOne() + { + switch (cur_instr[instr_pntr++]) + { + // always the last tick within an opcode instruction cycle + case END: + OnExecFetch?.Invoke(RegPC0); + TraceCallback?.Invoke(State()); + opcode = (byte)Regs[DB]; + instr_pntr = 0; + FetchInstruction(); + break; + + // used as timing 'padding' + case IDLE: + break; + + // load one register into another (or databus) + case OP_LR8: + LR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // load DB into A (as a part of an IN or INS instruction) + case OP_LR_A_DB_IO: + LR_A_IO_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // loads supplied index value into register + case OP_LIS: + Regs[ALU1] = (byte)(cur_instr[instr_pntr++] & 0x0F); + LR_Func(A, ALU1); + break; + + // Shift register n bit positions to the right (zero fill) + case OP_SHFT_R: + SR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // Shift register n bit positions to the left (zero fill) + case OP_SHFT_L: + SL_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // x <- (x) ADD y + case OP_ADD8: + ADD_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // x <- (x) MINUS y + case OP_SUB8: + SUB_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // x <- (x) ADD y (decimal) + case OP_ADD8D: + ADDD_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // A <- (A) + (C) + case OP_LNK: + Regs[ALU0] = (byte)(FlagC ? 1 : 0); + ADD_Func(A, ALU0); + break; + + // Clear ICB status bit + case OP_DI: + FlagICB = false; + break; + + // Set ICB status bit + case OP_EI: + FlagICB = true; + break; + + // x <- (y) XOR DB + case OP_XOR8: + XOR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // x <- (x) + 1 + case OP_INC8: + ADD_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // x <- (y) & DB + case OP_AND8: + AND_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // x <- (y) | DB + case OP_OR8: + OR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); + break; + + // DB + (x) + 1 (modify flags without saving result) + case OP_CI: + CI_Func(); + break; + + // ISAR is incremented + case OP_IS_INC: + Regs[ISAR] = (byte)((Regs[ISAR]& 0x38) | ((Regs[ISAR] + 1) & 0x07)); + break; + + // ISAR is decremented + case OP_IS_DEC: + Regs[ISAR] = (byte)((Regs[ISAR] & 0x38) | ((Regs[ISAR] - 1) & 0x07)); + break; + + // set the upper octal ISAR bits (b3,b4,b5) + case OP_LISU: + Regs[ISAR] = (byte)((((Regs[ISAR] & 0x07) | (cur_instr[instr_pntr++] & 0x07) << 3)) & 0x3F); + break; + + // set the lower octal ISAR bits (b0,b1,b2) + case OP_LISL: + Regs[ISAR] = (byte) (((Regs[ISAR] & 0x38) | (cur_instr[instr_pntr++] & 0x07)) & 0x3F); + break; + + // decrement scratchpad byte + //case OP_DS: + //SUB_Func(cur_instr[instr_pntr++], ONE); + //break; + + // Branch on TRUE + case OP_BT: + bool branchBT = false; + switch (cur_instr[instr_pntr++]) + { + case 0: + // do not branch + break; + + case 1: + // branch if positive (sign bit is set) + if (FlagS) branchBT = true; + break; + + case 2: + // branch on carry (carry bit is set) + if (FlagC) branchBT = true; + break; + + case 3: + // branch if positive or on carry + if (FlagS || FlagC) branchBT = true; + break; + + case 4: + // branch if zero (zero bit is set) + if (FlagZ) branchBT = true; + break; + + case 5: + // branch if positive and zero + if (FlagS || FlagZ) branchBT = true; + break; + + case 6: + // branch if zero or on carry + if (FlagZ || FlagC) branchBT = true; + break; + case 7: + // branch if positive or on carry or zero + if (FlagS || FlagC || FlagZ) branchBT = true; + break; + } + + instr_pntr = 0; + if (branchBT) DO_BRANCH(); + else DONT_BRANCH(); + break; + + // Branch on ISARL + case OP_BR7: + instr_pntr = 1; // lose a cycle + if (Regs[ISAR].Bit(0) && Regs[ISAR].Bit(1) && Regs[ISAR].Bit(2)) + { + DONT_BRANCH(); + } + else + { + DO_BRANCH(); + } + break; + + // Branch on FALSE + case OP_BF: + bool branchBF = false; + switch (cur_instr[instr_pntr++]) + { + case 0: + // unconditional branch relative + branchBF = true; + break; + + case 1: + // branch on negative (sign bit is reset) + if (!FlagS) branchBF = true; + break; + + case 2: + // branch if no carry (carry bit is reset) + if (!FlagC) branchBF = true; + break; + + case 3: + // branch if no carry and negative + if (!FlagC && !FlagS) branchBF = true; + break; + + case 4: + // branch if not zero (zero bit is reset) + if (!FlagZ) branchBF = true; + break; + + case 5: + // branch if not zero and negative + if (!FlagS && !FlagZ) branchBF = true; + break; + + case 6: + // branch if no carry and result is no zero + if (!FlagC && !FlagZ) branchBF = true; + break; + + case 7: + // branch if not zero, carry and sign + if (!FlagS && !FlagC && !FlagZ) branchBF = true; + break; + + case 8: + // branch if there is no overflow (OVF bit is reset) + if (!FlagO) branchBF = true; + break; + + case 9: + // branch if negative and no overflow + if (!FlagS && !FlagO) branchBF = true; + break; + + case 0xA: + // branch if no overflow and no carry + if (!FlagO && !FlagC) branchBF = true; + break; + + case 0xB: + // branch if no overflow, no carry & negative + if (!FlagO && !FlagC && !FlagS) branchBF = true; + break; + + case 0xC: + // branch if no overflow and not zero + if (!FlagO && !FlagZ) branchBF = true; + break; + + case 0xD: + // branch if no overflow, not zero and neg + if (!FlagS && !FlagO && !FlagZ) branchBF = true; + break; + + case 0xE: + // branch if no overflow, no carry & not zero + if (!FlagO && !FlagC && !FlagZ) branchBF = true; + break; + + case 0xF: + // all neg + if (!FlagO && !FlagC && !FlagS && FlagZ) branchBF = true; + break; + } + + instr_pntr = 0; + if (branchBF) DO_BRANCH(); + else DONT_BRANCH(); + break; + + // A <- (I/O Port 0 or 1) + case OP_IN: + instr_pntr++; // dest == A + Regs[ALU0] = cur_instr[instr_pntr++]; // src + IN_Func(A, ALU0); + break; + + // I/O Port 0 or 1 <- (A) + case OP_OUT: + WriteHardware(cur_instr[instr_pntr++], (byte)Regs[cur_instr[instr_pntr++]]); + break; + + // instruction fetch + // The device whose address space includes the contents of the PC0 register must place on the data bus the op code addressed by PC0; + // then all devices increments the content of PC0. + // CYCLE LENGTH: S + case ROMC_00_S: + Read_Func(DB, PC0l, PC0h); + RegPC0++; + break; + + // instruction fetch + // The device whose address space includes the contents of the PC0 register must place on the data bus the op code addressed by PC0; + // then all devices increments the content of PC0. + // CYCLE LENGTH: L + case ROMC_00_L: + Read_Func(DB, PC0l, PC0h); + RegPC0++; + break; + + // The device whose address space includes the contents of the PC0 register must place on the data bus the contents of the memory location + // addressed by by PC0; then all devices add the 8-bit value on the data bus, as a signed binary number, to PC0 + // CYCLE LENGTH: L + case ROMC_01: + Read_Func(DB, PC0l, PC0h); + RegPC0 += (ushort)((SByte) Regs[DB]); + break; + + // The device whose DC0 address addresses a memory word within the address space of that device must place on the data bus the contents + // of the memory location addressed by DC0; then all devices increment DC0 + // CYCLE LENGTH: L + case ROMC_02: + Read_Func(DB, DC0l, DC0h); + RegDC0++; + break; + + // Similar to 0x00, except that it is used for Immediate Operand fetches (using PC0) instead of instruction fetches + // CYCLE LENGTH: S + case ROMC_03_S: + Read_Func(DB, PC0l, PC0h); + RegPC0++; + Regs[IO] = Regs[DB]; + break; + + // Similar to 0x00, except that it is used for Immediate Operand fetches (using PC0) instead of instruction fetches + // CYCLE LENGTH: L + case ROMC_03_L: + Read_Func(DB, PC0l, PC0h); + RegPC0++; + Regs[IO] = Regs[DB]; + break; + + // Copy the contents of PC1 into PC0 + // CYCLE LENGTH: S + case ROMC_04: + RegPC0 = RegPC1; + break; + + // Store the data bus contents into the memory location pointed to by DC0; increment DC0 + // CYCLE LENGTH: L + case ROMC_05: + Write_Func(DC0l, DC0h, DB); + break; + + // Place the high order byte of DC0 on the data bus + // CYCLE LENGTH: L + case ROMC_06: + Regs[DB] = (byte)Regs[DC0h]; + break; + + // Place the high order byte of PC1 on the data bus + // CYCLE LENGTH: L + case ROMC_07: + Regs[DB] = (byte)Regs[PC1h]; + break; + + // All devices copy the contents of PC0 into PC1. The CPU outputs zero on the data bus in this ROMC state. + // Load the data bus into both halves of PC0, this clearing the register. + // CYCLE LENGTH: L + case ROMC_08: + RegPC1 = RegPC0; + Regs[DB] = 0; + Regs[PC0h] = 0; + Regs[PC0l] = 0; + break; + + // The device whose address space includes the contents of the DC0 register must place the low order byte of DC0 onto the data bus + // CYCLE LENGTH: L + case ROMC_09: + Regs[DB] = (byte)Regs[DC0l]; + break; + + // All devices add the 8-bit value on the data bus, treated as a signed binary number, to the data counter + // CYCLE LENGTH: L + case ROMC_0A: + RegDC0 += (ushort) ((sbyte) Regs[DB]); + break; + + // The device whose address space includes the value in PC1 must place the low order byte of PC1 on the data bus + // CYCLE LENGTH: L + case ROMC_0B: + Regs[DB] = (byte)Regs[PC1l]; + break; + + // The device whose address space includes the contents of the PC0 register must place the contents of the memory word addressed by PC0 + // onto the data bus; then all devices move the value that has just been placed on the data bus into the low order byte of PC0 + // CYCLE LENGTH: L + case ROMC_0C: + Read_Func(DB, PC0l, PC0h); + Regs[PC0l] = Regs[DB]; + break; + + // All devices store in PC1 the current contents of PC0, incremented by 1; PC0 is unaltered + // CYCLE LENGTH: S + case ROMC_0D: + RegPC1 = (ushort)(RegPC0 + 1); + break; + + // The device whose address space includes the contents of PC0 must place the contents of the word addressed by PC0 onto the data bus. + // The value on the data bus is then moved to the low order byte of DC0 by all devices + // CYCLE LENGTH: L + case ROMC_0E: + Read_Func(DB, PC0l, PC0h); + Regs[DC0l] = Regs[DB]; + break; + + // The interrupting device with the highest priority must place the low order byte of the interrupt vector on the data bus. + // All devices must copy the contents of PC0 into PC1. All devices must move the contents of the data bus into the low order byte of PC0 + // CYCLE LENGTH: L + case ROMC_0F: + throw new NotImplementedException("ROMC 0x0F not implemented"); + + // Inhibit any modification to the interrupt priority logic + // CYCLE LENGTH: L + case ROMC_10: + throw new NotImplementedException("ROMC 0x10 not implemented"); + + // The device whose memory space includes the contents of PC0 must place the contents of the addressed memory word on the data bus. + // All devices must then move the contents of the data bus to the upper byte of DC0 + // CYCLE LENGTH: L + case ROMC_11: + Read_Func(DB, PC0l, PC0h); + Regs[DC0h] = Regs[DB]; + break; + + // All devices copy the contents of PC0 into PC1. All devices then move the contents of the data bus into the low order byte of PC0 + // CYCLE LENGTH: L + case ROMC_12: + RegPC1 = RegPC0; + Regs[PC0l] = Regs[DB]; + break; + + // The interrupting device with the highest priority must move the high order half of the interrupt vector onto the data bus. + // All devices must move the conetnts of the data bus into the high order byte of of PC0. The interrupting device resets its + // interrupt circuitry (so that it is no longer requesting CPU servicing and can respond to another interrupt) + // CYCLE LENGTH: L + case ROMC_13: + throw new NotImplementedException("ROMC 0x13 not implemented"); + + // All devices move the contents of the data bus into the high order byte of PC0 + // CYCLE LENGTH: L + case ROMC_14: + Regs[PC0h] = Regs[DB]; + break; + + // All devices move the contents of the data bus into the high order byte of PC1 + // CYCLE LENGTH: L + case ROMC_15: + Regs[PC1h] = Regs[DB]; + break; + + // All devices move the contents of the data bus into the high order byte of DC0 + // CYCLE LENGTH: L + case ROMC_16: + Regs[DC0h] = Regs[DB]; + break; + + // All devices move the contents of the data bus into the low order byte of PC0 + // CYCLE LENGTH: L + case ROMC_17: + Regs[PC0l] = Regs[DB]; + break; + + // All devices move the contents of the data bus into the low order byte of PC1 + // CYCLE LENGTH: L + case ROMC_18: + Regs[PC1l] = Regs[DB]; + break; + + // All devices move the contents of the data bus into the low order byte of DC0 + // CYCLE LENGTH: L + case ROMC_19: + Regs[DC0l] = Regs[DB]; + break; + + // During the prior cycle, an I/O port timer or interrupt control register was addressed; the device containing the addressed + // port must move the current contents of the data bus into the addressed port + // CYCLE LENGTH: L + case ROMC_1A: + WriteHardware(Regs[IO], (byte)Regs[DB]); + break; + + // During the prior cycle, the data bus specified the address of an I/O port. The device containing the addressed I/O port + // must place the contents of the I/O port on the data bus. (Note that the contents of the timer and interrupt control + // registers cannot be read back onto the data bus) + // CYCLE LENGTH: L + case ROMC_1B: + IN_Func(DB, IO); + //Regs[DB] = ReadHardware(Regs[IO]); + break; + + // None + // CYCLE LENGTH: S + case ROMC_1C_S: + break; + + // None + // CYCLE LENGTH: L + case ROMC_1C_L: + break; + + // Devices with DC0 and DC1 registers must switch registers. Devices without a DC1 register perform no operation + // CYCLE LENGTH: S + case ROMC_1D: + // we have no DC1 in this implementation + break; + + // The device whose address space includes the contents of PC0 must place the low order byte of PC0 onto the data bus + // CYCLE LENGTH: L + case ROMC_1E: + Regs[DB] = (byte)Regs[PC0l]; + break; + + // The device whose address space includes the contents of PC0 must place the high order byte of PC0 onto the data bus + // CYCLE LENGTH: L + case ROMC_1F: + Regs[DB] = (byte)Regs[PC0h]; + break; + } + + TotalExecutedCycles++; + } + + public Action TraceCallback; + + public string TraceHeader => "F3850: PC, machine code, mnemonic, operands, flags (IOZCS), registers (PC1, DC0, A, ISAR, DB, IO, J, H, K, Q, R00-R63), Cycles"; + + public TraceInfo State(bool disassemble = true) + { + int bytes_read = 0; + ushort pc = (ushort)(RegPC0 - 1); + string disasm = disassemble ? Disassemble(pc, ReadMemory, out bytes_read) : "---"; + string byte_code = null; + + for (ushort i = 0; i < bytes_read; i++) + { + byte_code += ReadMemory((ushort)(pc + i)).ToHexString(2); + if (i < (bytes_read - 1)) + { + byte_code += " "; + } + } + + return new TraceInfo + { + Disassembly = string.Format( + "{0:X4}: {1} {2}", + pc, + byte_code.PadRight(12), + disasm.PadRight(26)), + RegisterInfo = string.Format( + "Flags:{75}{76}{77}{78}{79} " + + "PC1:{0:X4} DC0:{1:X4} A:{2:X2} ISAR:{3:X2} DB:{4:X2} IO:{5:X2} J:{6:X2} H:{7:X4} K:{8:X4} Q:{9:X4} " + + "R0:{10:X2} R1:{11:X2} R2:{12:X2} R3:{13:X2} R4:{14:X2} R5:{15:X2} R6:{16:X2} R7:{17:X2} R8:{18:X2} R9:{19:X2} " + + "R10:{20:X2} R11:{21:X2} R12:{22:X2} R13:{23:X2} R14:{24:X2} R15:{25:X2} R16:{26:X2} R17:{27:X2} R18:{28:X2} R19:{29:X2} " + + "R20:{30:X2} R21:{31:X2} R22:{32:X2} R23:{33:X2} R24:{34:X2} R25:{35:X2} R26:{36:X2} R27:{37:X2} R28:{38:X2} R29:{39:X2} " + + "R30:{40:X2} R31:{41:X2} R32:{42:X2} R33:{43:X2} R34:{44:X2} R35:{45:X2} R36:{46:X2} R37:{47:X2} R38:{48:X2} R39:{49:X2} " + + "R40:{50:X2} R41:{51:X2} R42:{52:X2} R43:{53:X2} R44:{54:X2} R45:{55:X2} R46:{56:X2} R47:{57:X2} R48:{58:X2} R49:{59:X2} " + + "R50:{60:X2} R51:{61:X2} R52:{62:X2} R53:{63:X2} R54:{64:X2} R55:{65:X2} R56:{66:X2} R57:{67:X2} R58:{68:X2} R59:{69:X2} " + + "R60:{70:X2} R61:{71:X2} R62:{72:X2} R63:{73:X2} " + + "Cy:{74}", + RegPC1, + RegDC0, + Regs[A], + Regs[ISAR], + Regs[DB], + Regs[IO], + Regs[J], + (ushort)(Regs[Hl] | (Regs[Hh] << 8)), + (ushort)(Regs[Kl] | (Regs[Kh] << 8)), + (ushort)(Regs[Ql] | (Regs[Qh] << 8)), + Regs[0], Regs[1], Regs[2], Regs[3], Regs[4], Regs[5], Regs[6], Regs[7], Regs[8], Regs[9], + Regs[10], Regs[11], Regs[12], Regs[13], Regs[14], Regs[15], Regs[16], Regs[17], Regs[18], Regs[19], + Regs[20], Regs[21], Regs[22], Regs[23], Regs[24], Regs[25], Regs[26], Regs[27], Regs[28], Regs[29], + Regs[30], Regs[31], Regs[32], Regs[33], Regs[34], Regs[35], Regs[36], Regs[37], Regs[38], Regs[39], + Regs[40], Regs[41], Regs[42], Regs[43], Regs[44], Regs[45], Regs[46], Regs[47], Regs[48], Regs[49], + Regs[50], Regs[51], Regs[52], Regs[53], Regs[54], Regs[55], Regs[56], Regs[57], Regs[58], Regs[59], + Regs[60], Regs[61], Regs[62], Regs[63], + TotalExecutedCycles, + FlagICB ? "I" : "i", + FlagO ? "O" : "o", + FlagZ ? "Z" : "z", + FlagC ? "C" : "c", + FlagS ? "S" : "s"), + + }; + } + + /// + /// Optimization method to set cur_instr + /// + private void PopulateCURINSTR(byte d0 = 0, byte d1 = 0, byte d2 = 0, byte d3 = 0, byte d4 = 0, byte d5 = 0, byte d6 = 0, byte d7 = 0, byte d8 = 0, + byte d9 = 0, byte d10 = 0, byte d11 = 0, byte d12 = 0, byte d13 = 0, byte d14 = 0, byte d15 = 0, byte d16 = 0, byte d17 = 0, byte d18 = 0, + byte d19 = 0, byte d20 = 0, byte d21 = 0, byte d22 = 0, byte d23 = 0, byte d24 = 0, byte d25 = 0, byte d26 = 0, byte d27 = 0, byte d28 = 0, + byte d29 = 0, byte d30 = 0, byte d31 = 0, byte d32 = 0, byte d33 = 0, byte d34 = 0, byte d35 = 0, byte d36 = 0, byte 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; + } + + public void SyncState(Serializer ser) + { + ser.BeginSection(nameof(F3850)); + ser.Sync(nameof(Regs), ref Regs, false); + ser.Sync(nameof(cur_instr), ref cur_instr, false); + ser.Sync(nameof(instr_pntr), ref instr_pntr); + ser.EndSection(); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Memory.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Memory.cs new file mode 100644 index 0000000000..41fbd55593 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Memory.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + /// + /// Memory and related functions + /// + public partial class ChannelF + { + public byte[] BIOS01 = new byte[1024]; + public byte[] BIOS02 = new byte[1024]; + + /// + /// Simulates reading a byte of data from the address space + /// + /// + /// + public byte ReadBus(ushort addr) + { + if (addr < 0x400) + { + // Rom0 + return BIOS01[addr]; + } + else if (addr < 0x800) + { + // Rom1 + return BIOS02[addr - 0x400]; + } + else if (addr < 0x2000) + { + // Cart + //return 0; + return Rom[addr - 0x800]; + } + + return 0xFF; + } + + /// + /// Simulates writing a byte of data to the address space (in its default configuration, there is no writeable RAM in the + /// Channel F addressable through the address space) + /// + /// + /// + public void WriteBus(ushort addr, byte value) + { + + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs new file mode 100644 index 0000000000..acf9373e9e --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Remoting.Messaging; +using System.Text; +using System.Threading.Tasks; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + /// + /// Ports and related functions + /// + public partial class ChannelF + { + /// + /// The Channel F has 4 8-bit IO ports connected. + /// CPU - ports 0 and 1 + /// PSU - ports 4 and 5 + /// (the second PSU has no IO ports wired up) + /// + public byte[] PortLatch = new byte[4]; + + public bool ControllersEnabled; + + public const int PORT0 = 0; + public const int PORT1 = 1; + public const int PORT4 = 2; + public const int PORT5 = 3; + + /// + /// CPU attempts to read data byte from the requested port + /// + /// + /// + public byte ReadPort(ushort addr) + { + switch (addr) + { + // Console buttons + // b0: TIME + // b1: MODE + // b2: HOLD + // b3: START + case 0: + return (byte)((DataConsole ^ 0xff) | PortLatch[PORT0]); + + // Right controller + // b0: RIGHT + // b1: LEFT + // b2: BACK + // b3: FORWARD + // b4: CCW + // b5: CW + // b6: PULL + // b7: PUSH + case 1: + byte ed1; + if ((PortLatch[PORT0] & 0x40) == 0) + { + ed1 = DataRight; + } + else + { + ed1 = (byte) (0xC0 | DataRight); + } + return (byte) ((ed1 ^ 0xff) | PortLatch[PORT1]); + + // Left controller + // b0: RIGHT + // b1: LEFT + // b2: BACK + // b3: FORWARD + // b4: CCW + // b5: CW + // b6: PULL + // b7: PUSH + case 4: + byte ed4; + if ((PortLatch[PORT0] & 0x40) == 0) + { + ed4 = DataLeft; + } + else + { + ed4 = 0xff; + } + return (byte)((ed4 ^ 0xff) | PortLatch[PORT4]); + + case 5: + return (byte) (0 | PortLatch[PORT5]); + + default: + return 0; + } + } + + /// + /// CPU attempts to write data to the requested port (latch) + /// + /// + /// + public void WritePort(ushort addr, byte value) + { + switch (addr) + { + case 0: + PortLatch[PORT0] = value; + if ((value & 0x20) != 0) + { + var offset = _x + (_y * 128); + VRAM[offset] = (byte)(_colour); + } + break; + + case 1: + + PortLatch[PORT1] = value; + + // Write Data0 - indicates that valid data is present for both VRAM ODD0 and EVEN0 + bool data0 = value.Bit(6); + // Write Data1 - indicates that valid data is present for both VRAM ODD1 and EVEN1 + bool data1 = value.Bit(7); + + //_colour = ((value) >> 6) & 3; + _colour = ((value ^ 0xff) >> 6) & 0x3; + break; + + case 4: + PortLatch[PORT4] = value; + _x = (value ^ 0xff) & 0x7f; + //_x = (value | 0x80) ^ 0xFF; + /* + + // video horizontal position + // 0 - video select + // 1-6 - horiz A-F + + + + */ + + break; + + + case 5: + + PortLatch[PORT5] = value; + //_y = (value & 31); // ^ 0xff; + //_y = (value | 0xC0) ^ 0xff; + + //_y = (value ^ 0xff) & 0x1f; + + // video vertical position and sound + // 0-5 - Vertical A-F + // 6 - Tone AN, 7 - Tone BN + + _y = (value ^ 0xff) & 0x3f; + + // audio + var aVal = ((value >> 6) & 0x03); // (value & 0xc0) >> 6; + if (aVal != tone) + { + tone = aVal; + time = 0; + amplitude = 1; + AudioChange(); + } + break; + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Video.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Video.cs new file mode 100644 index 0000000000..9c26fec92f --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Video.cs @@ -0,0 +1,80 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Consoles.ChannelF +{ + /// + /// Video related functions + /// + public partial class ChannelF + { + /// + /// 128x64 pixels - 8192x2bits (2 KB) + /// For the purposes of this core we will use 8192 bytes and just & 0x03 + /// + public byte[] VRAM = new byte[(128 * 64)]; + + public static readonly int[] FPalette = + { + /* + 0x101010, 0xFDFDFD, 0x5331FF, 0x5DCC02, 0xF33F4B, 0xE0E0E0, 0xA6FF91, 0xD0CEFF + */ + + Colors.ARGB(0x10, 0x10, 0x10), // Black + Colors.ARGB(0xFD, 0xFD, 0xFD), // White + Colors.ARGB(0xFF, 0x31, 0x53), // Red + Colors.ARGB(0x02, 0xCC, 0x5D), // Green + Colors.ARGB(0x4B, 0x3F, 0xF3), // Blue + Colors.ARGB(0xE0, 0xE0, 0xE0), // Gray + Colors.ARGB(0x91, 0xFF, 0xA6), // BGreen + Colors.ARGB(0xCE, 0xD0, 0xFF), // BBlue + + }; + + public static readonly int[] CMap = + { + 0, 1, 1, 1, + 7, 4, 2, 3, + 5, 4, 2, 3, + 6, 4, 2, 3, + }; + + private int _colour = 2; + private int _x; + private int _y; + private int _arm; + + private int[] frameBuffer = new int[128 * 64]; + + private void BuildFrame() + { + // rows + int counter = 0; + for (int row = 0; row < 64; row++) + { + // columns 125 and 126 hold the palette index modifier for the entire row + var rIndex = 128 * row; + var c125 = (VRAM[rIndex + 125] & 0x03); + var c126 = (VRAM[rIndex + 126] & 0x03); + var pModifier = (((c126 & 0x02) | c125 >> 1) << 2); + + pModifier = ((VRAM[(row << 7) + 125] & 2) >> 1) | (VRAM[(row << 7) + 126] & 3); + pModifier = (pModifier << 2) & 0xc; + + // columns + for (int col = 0; col < 128; col++, counter++) + { + int cl = (VRAM[(row << 7) + col]) & 0x3; + frameBuffer[(row << 7) + col] = CMap[pModifier | cl] & 0x7; + //var nCol = pModifier + (VRAM[col | (row << 7)] & 0x03); + //frameBuffer[counter] = FPalette[CMap[nCol]]; + } + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Audio.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Audio.cs new file mode 100644 index 0000000000..725db7cd61 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Audio.cs @@ -0,0 +1,378 @@ +using System; + +using BizHawk.Common; +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; +using BizHawk.Common.NumberExtensions; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + // An AY_3_8912 + public class Audio : ISoundProvider + { + public VectrexHawk Core { get; set; } + + private BlipBuffer _blip_L = new BlipBuffer(15000); + private BlipBuffer _blip_R = new BlipBuffer(15000); + + public uint master_audio_clock; + + private short current_sample; + + public byte[] Register = new byte[16]; + + public byte port_sel; + + public short Sample() + { + return current_sample; + } + + private static readonly int[] VolumeTable = + { + 0x0000, 0x0055, 0x0079, 0x00AB, 0x00F1, 0x0155, 0x01E3, 0x02AA, + 0x03C5, 0x0555, 0x078B, 0x0AAB, 0x0F16, 0x1555, 0x1E2B, 0x2AAA + }; + + private int psg_clock; + private int sq_per_A, sq_per_B, sq_per_C; + private int clock_A, clock_B, clock_C; + private int vol_A, vol_B, vol_C; + private bool A_on, B_on, C_on; + private bool A_up, B_up, C_up; + private bool A_noise, B_noise, C_noise; + + private int env_per; + private int env_clock; + private int env_shape; + private int env_E; + private int E_up_down; + private int env_vol_A, env_vol_B, env_vol_C; + + private int noise_clock; + private int noise_per; + private int noise = 0x1; + + public void SyncState(Serializer ser) + { + ser.BeginSection("PSG"); + + ser.Sync(nameof(Register), ref Register, false); + + 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(); + + ser.EndSection(); + } + + public byte ReadReg(int addr) + { + return Register[port_sel]; + } + + private void sync_psg_state() + { + sq_per_A = (Register[0] & 0xFF) | (((Register[1] & 0xF) << 8)); + if (sq_per_A == 0) + { + sq_per_A = 0x1000; + } + + sq_per_B = (Register[2] & 0xFF) | (((Register[3] & 0xF) << 8)); + if (sq_per_B == 0) + { + sq_per_B = 0x1000; + } + + sq_per_C = (Register[4] & 0xFF) | (((Register[5] & 0xF) << 8)); + if (sq_per_C == 0) + { + sq_per_C = 0x1000; + } + + env_per = (Register[11] & 0xFF) | (((Register[12] & 0xFF) << 8)); + if (env_per == 0) + { + env_per = 0x10000; + } + + env_per *= 2; + + A_on = Register[7].Bit(0); + B_on = Register[7].Bit(1); + C_on = Register[7].Bit(2); + A_noise = Register[7].Bit(3); + B_noise = Register[7].Bit(4); + C_noise = Register[7].Bit(5); + + noise_per = Register[6] & 0x1F; + if (noise_per == 0) + { + noise_per = 0x20; + } + + var shape_select = Register[13] & 0xF; + + if (shape_select < 4) + env_shape = 0; + else if (shape_select < 8) + env_shape = 1; + else + env_shape = 2 + (shape_select - 8); + + vol_A = Register[8] & 0xF; + env_vol_A = (Register[8] >> 4) & 0x1; + + vol_B = Register[9] & 0xF; + env_vol_B = (Register[9] >> 4) & 0x1; + + vol_C = Register[10] & 0xF; + env_vol_C = (Register[10] >> 4) & 0x1; + } + + public void WriteReg(int addr, byte value) + { + value &= 0xFF; + + Register[port_sel] = value; + + sync_psg_state(); + + if (port_sel == 13) + { + env_clock = env_per; + + if (env_shape == 0 || env_shape == 2 || env_shape == 3 || env_shape == 4 || env_shape == 5) + { + env_E = 15; + E_up_down = -1; + } + else + { + env_E = 0; + E_up_down = 1; + } + } + } + + public void tick() + { + // there are 8 cpu cycles for every psg cycle + bool sound_out_A; + bool sound_out_B; + bool sound_out_C; + + psg_clock++; + + if (psg_clock == 8) + { + psg_clock = 0; + + clock_A--; + clock_B--; + clock_C--; + + noise_clock--; + env_clock--; + + // clock noise + if (noise_clock == 0) + { + noise = (noise >> 1) ^ (noise.Bit(0) ? 0x10004 : 0); + noise_clock = noise_per; + } + + if (env_clock == 0) + { + env_clock = env_per; + + env_E += E_up_down; + + if (env_E == 16 || env_E == -1) + { + + // we just completed a period of the envelope, determine what to do now based on the envelope shape + if (env_shape == 0 || env_shape == 1 || env_shape == 3 || env_shape == 9) + { + E_up_down = 0; + env_E = 0; + } + else if (env_shape == 5 || env_shape == 7) + { + E_up_down = 0; + env_E = 15; + } + else if (env_shape == 4 || env_shape == 8) + { + if (env_E == 16) + { + env_E = 15; + E_up_down = -1; + } + else + { + env_E = 0; + E_up_down = 1; + } + } + else if (env_shape == 2) + { + env_E = 15; + } + else + { + env_E = 0; + } + } + } + + if (clock_A == 0) + { + A_up = !A_up; + clock_A = sq_per_A; + } + + if (clock_B == 0) + { + B_up = !B_up; + clock_B = sq_per_B; + } + + if (clock_C == 0) + { + C_up = !C_up; + clock_C = sq_per_C; + } + + + sound_out_A = (noise.Bit(0) | A_noise) & (A_on | A_up); + sound_out_B = (noise.Bit(0) | B_noise) & (B_on | B_up); + sound_out_C = (noise.Bit(0) | C_noise) & (C_on | C_up); + + // now calculate the volume of each channel and add them together + int v; + + if (env_vol_A == 0) + { + v = (short)(sound_out_A ? VolumeTable[vol_A] : 0); + } + else + { + v = (short)(sound_out_A ? VolumeTable[vol_A] : 0); + } + + if (env_vol_B == 0) + { + v += (short)(sound_out_B ? VolumeTable[vol_B] : 0); + + } + else + { + v += (short)(sound_out_B ? VolumeTable[env_E] : 0); + } + + if (env_vol_C == 0) + { + v += (short)(sound_out_C ? VolumeTable[vol_C] : 0); + } + else + { + v += (short)(sound_out_C ? VolumeTable[env_E] : 0); + } + + current_sample = (short)v; + } + } + + public void Reset() + { + clock_A = clock_B = clock_C = 0x1000; + noise_clock = 0x20; + port_sel = 0; + + for (int i = 0; i < 16; i++) + { + Register[i] = 0x0000; + } + sync_psg_state(); + + _blip_L.SetRates(4194304, 44100); + _blip_R.SetRates(4194304, 44100); + } + + #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) + { + _blip_L.EndFrame(master_audio_clock); + _blip_R.EndFrame(master_audio_clock); + + nsamp = _blip_L.SamplesAvailable(); + + // only for running without errors, remove this line once you get audio + nsamp = 1; + + samples = new short[nsamp * 2]; + + // uncomment these once you have audio to play + //_blip_L.ReadSamplesLeft(samples, nsamp); + //_blip_R.ReadSamplesRight(samples, nsamp); + + master_audio_clock = 0; + } + + public void GetSamplesAsync(short[] samples) + { + throw new NotSupportedException("Async is not available"); + } + + public void DiscardSamples() + { + _blip_L.Clear(); + _blip_R.Clear(); + master_audio_clock = 0; + } + + private void GetSamples(short[] samples) + { + + } + + public void DisposeSound() + { + _blip_L.Clear(); + _blip_R.Clear(); + _blip_L.Dispose(); + _blip_R.Dispose(); + _blip_L = null; + _blip_R = null; + } + + #endregion + } +} \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs new file mode 100644 index 0000000000..49b52c5906 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/HW_Registers.cs @@ -0,0 +1,299 @@ +using System; +using BizHawk.Emulation.Common; +using BizHawk.Common.NumberExtensions; +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + // MOS6522 Interface + + /* Port B writes to both the PSG and the DAC simultaneously + * The trick here is that bits 3 and 4 both zero represent PSG disabled + * So it's easy to not interfere with the PSG + * However, the DAC will always receive some input, controlled by the multiplexer and selector bits + * BIOS functions keep everything in order + */ + + public partial class VectrexHawk + { + public byte dir_dac, dir_ctrl; + public byte reg_A, reg_B; + + public byte portB_ret, portA_ret; + + public byte t1_low, t1_high; + public int t1_counter, t1_ctrl; + public bool t1_shot_go; + + public byte t2_low, t2_high; + public int t2_counter, t2_ctrl; + public bool t2_shot_go; + + public bool PB7, PB6; + public bool PB7_prev, PB6_prev; + + public byte int_en, int_fl, aux_ctrl; + + public byte Read_Registers(int addr) + { + byte ret = 0; + + switch (addr) + { + case 0x0: + ret = portB_ret; + + int_fl &= 0xE7; + update_int_fl(); + break; + case 0x1: + ret = portA_ret; + + int_fl &= 0xFC; + update_int_fl(); + break; + case 0x2: + ret = dir_ctrl; + break; + case 0x3: + ret = dir_dac; + break; + case 0x4: + ret = (byte)(t1_counter & 0xFF); + + int_fl &= 0xBF; + update_int_fl(); + break; + case 0x5: + ret = (byte)((t1_counter >> 8) & 0xFF); + break; + case 0x6: + ret = t1_low; + break; + case 0x7: + ret = t1_high; + break; + case 0x8: + ret = (byte)(t2_counter & 0xFF); + + int_fl &= 0xDF; + update_int_fl(); + break; + case 0x9: + ret = (byte)((t2_counter >> 8) & 0xFF); + break; + case 0xA: + int_fl &= 0xFB; + update_int_fl(); + break; + case 0xB: + ret = aux_ctrl; + break; + case 0xC: + break; + case 0xD: + ret = int_fl; + break; + case 0xE: + ret = int_en; + break; + case 0xF: + break; + } + return ret; + } + + public void Write_Registers(int addr, byte value) + { + byte wrt_val = 0; + + switch (addr) + { + case 0x0: + wrt_val = (byte)(value & dir_ctrl); + + portB_ret = (byte)(wrt_val | (reg_B & ~(dir_ctrl))); + + int_fl &= 0xE7; + update_int_fl(); + break; + case 0x1: + wrt_val = (byte)(value & dir_dac); + + portA_ret = (byte)(wrt_val | (reg_A & ~(dir_dac))); + + int_fl &= 0xFC; + update_int_fl(); + break; + case 0x2: + dir_ctrl = value; + Console.WriteLine("dir_ctrl: " + value); + break; + case 0x3: + dir_dac = value; + Console.WriteLine("dir_dac: " + value); + break; + case 0x4: + t1_low = value; + break; + case 0x5: + t1_high = value; + + t1_counter = (t1_high << 8) | t1_low; + t1_shot_go = true; + if (aux_ctrl.Bit(7)) { PB7 = true; } + t1_ctrl = aux_ctrl; + + int_fl &= 0xBF; + update_int_fl(); + break; + case 0x6: + t1_low = value; + break; + case 0x7: + t1_high = value; + + int_fl &= 0xBF; + update_int_fl(); + break; + case 0x8: + t2_low = value; + break; + case 0x9: + t2_high = value; + + t2_counter = (t2_high << 8) | t2_low; + t2_shot_go = true; + t2_ctrl = aux_ctrl; + + int_fl &= 0xDF; + update_int_fl(); + break; + case 0xA: + int_fl &= 0xFB; + update_int_fl(); + break; + case 0xB: + aux_ctrl = value; + break; + case 0xC: + break; + case 0xD: + // writing to flags does not clear bit 7 directly + int_fl &= (byte)~(value & 0x7F); + + update_int_fl(); + break; + case 0xE: + // bit 7 is always 0 + if (value.Bit(7)) + { + int_en |= (byte)(value & 0x7F); + } + else + { + int_en &= (byte)((~value) & 0x7F); + } + update_int_fl(); + break; + case 0xF: + break; + } + } + + public void timer_1_tick() + { + t1_counter--; + + if (t1_counter < 0) + { + if (t1_ctrl.Bit(6)) + { + t1_counter = (t1_high << 8) | t1_low; + + int_fl |= 0x40; + update_int_fl(); + //if (int_en.Bit(6)) { cpu.IRQPending = true; } + + if (t1_ctrl.Bit(7)) { PB7 = !PB7; } + } + else + { + t1_counter = 0xFFFF; + + if (t1_shot_go) + { + int_fl |= 0x40; + update_int_fl(); + //if (int_en.Bit(6)) { cpu.IRQPending = true; } + if (t1_ctrl.Bit(7)) { PB7 = false; } + + t1_shot_go = false; + } + } + } + } + + public void timer_2_tick() + { + t2_counter--; + + if (t2_counter < 0) + { + if (t2_ctrl.Bit(5)) + { + t2_counter = (t2_high << 8) | t2_low; + + int_fl |= 0x20; + update_int_fl(); + //if (int_en.Bit(6)) { cpu.IRQPending = true; } + } + else + { + t2_counter = 0xFFFF; + + if (t2_shot_go) + { + int_fl |= 0x20; + update_int_fl(); + //if (int_en.Bit(6)) { cpu.IRQPending = true; } + + t2_shot_go = false; + } + } + } + } + + public void update_int_fl() + { + // bit 7 is (IF.bit(X) & IE.bit(X)) OR'ed together for each bit + bool test = false; + + for (int i = 0; i < 7; i++) + { + test |= int_en.Bit(i) & int_fl.Bit(i); + } + + int_fl |= (byte)(test ? 0x80 : 0); + } + + public void Register_Reset() + { + dir_dac = dir_ctrl = 0; + + portB_ret = portA_ret = 0; + + t1_low = t1_high = 0; + t1_counter = t1_ctrl = 0; + t1_shot_go = false; + PB7 = PB7_prev = false; + + t2_low = t2_high = 0; + t2_counter = t2_ctrl = 0; + t2_shot_go = false; + PB6 = PB7_prev = false; + + int_en = int_fl = aux_ctrl = 0; + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs new file mode 100644 index 0000000000..0dbbe85dc8 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs @@ -0,0 +1,54 @@ +using BizHawk.Common; +using System; + +using BizHawk.Emulation.Common.Components.MC6809; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public class MapperBase + { + public VectrexHawk Core { get; set; } + + public virtual byte ReadMemory(ushort addr) + { + return 0; + } + + public virtual byte PeekMemory(ushort addr) + { + return 0; + } + + public virtual void WriteMemory(ushort addr, byte value) + { + } + + public virtual void PokeMemory(ushort addr, byte value) + { + } + + public virtual void SyncState(Serializer ser) + { + } + + public virtual void Dispose() + { + } + + public virtual void Initialize() + { + } + + public virtual void Mapper_Tick() + { + } + + public virtual void RTC_Get(byte value, int index) + { + } + + public virtual void MapCDL(ushort addr, MC6809.eCDLogMemFlags flags) + { + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/Mapper_Default.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/Mapper_Default.cs new file mode 100644 index 0000000000..9d1afc0418 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/Mapper_Default.cs @@ -0,0 +1,38 @@ +using BizHawk.Common; +using BizHawk.Common.NumberExtensions; +using System; + +using BizHawk.Emulation.Common.Components.MC6809; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + // Default mapper with no bank switching + // make sure peekmemory and poke memory don't effect the rest of the system! + public class MapperDefault : MapperBase + { + public override void Initialize() + { + // nothing to initialize + } + + public override byte ReadMemory(ushort addr) + { + return Core._rom[addr]; + } + + public override byte PeekMemory(ushort addr) + { + return ReadMemory(addr); + } + + public override void WriteMemory(ushort addr, byte value) + { + + } + + public override void PokeMemory(ushort addr, byte value) + { + WriteMemory(addr, value); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/ReadMe.txt b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/ReadMe.txt new file mode 100644 index 0000000000..0c94c8272c --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/ReadMe.txt @@ -0,0 +1,3 @@ +TODO: +Official Mappers +Unofficial Mappers diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/MemoryMap.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/MemoryMap.cs new file mode 100644 index 0000000000..dc94847b60 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/MemoryMap.cs @@ -0,0 +1,121 @@ +using System; + +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; + + +/* + 0x0000 - 0x7FFF ROM + 0x8000 - 0xC7FF Unmapped + 0xC800 - 0xCFFF RAM (and shadows) + 0xD000 - 0XD7FF 6522 (and shadows) + 0xD800 - 0xDFFF 6522 + RAM + 0xE000 - 0xEFFF Minestorm + 0xF000 - 0xFFFF BIOS +*/ + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public partial class VectrexHawk + { + public byte ReadMemory(ushort addr) + { + MemoryCallbacks.CallReads(addr, "System Bus"); + + if (addr < 0x8000) + { + return mapper.ReadMemory(addr); + } + else if (addr < 0xC800) + { + return 0xFF; + } + else if (addr < 0xD000) + { + return RAM[(addr-0xC800) & 0x3FF]; + } + else if (addr < 0xD800) + { + return Read_Registers(addr & 0xF); + } + else if (addr < 0xE000) + { + return 0xFF; + } + else if (addr < 0xF000) + { + return 0xFF; + } + else + { + return _bios[addr - 0xF000]; + } + } + + public void WriteMemory(ushort addr, byte value) + { + MemoryCallbacks.CallWrites(addr, "System Bus"); + + if (addr < 0x8000) + { + + } + else if (addr < 0xC800) + { + + } + else if (addr < 0xD000) + { + RAM[(addr - 0xC800) & 0x3FF] = value; + } + else if (addr < 0xD800) + { + Write_Registers(addr & 0xF, value); + } + else if (addr < 0xE000) + { + + } + else if (addr < 0xF000) + { + + } + else + { + + } + } + + public byte PeekMemory(ushort addr) + { + if (addr < 0x8000) + { + return 0xFF; + } + else if (addr < 0xC800) + { + return 0xFF; + } + else if (addr < 0xD000) + { + return RAM[(addr - 0xC800) & 0x3FF]; + } + else if (addr < 0xD800) + { + return Read_Registers(addr & 0xF); + } + else if (addr < 0xE000) + { + return 0xFF; + } + else if (addr < 0xF000) + { + return 0xFF; + } + else + { + return _bios[addr - 0xF000]; + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/PPU.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/PPU.cs new file mode 100644 index 0000000000..2d2118bc80 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/PPU.cs @@ -0,0 +1,45 @@ +using System; +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public class PPU + { + public VectrexHawk Core { get; set; } + + public byte ReadReg(int addr) + { + return 0; + } + + public void WriteReg(int addr, byte value) + { + + } + + public void tick() + { + + } + + public virtual void latch_delay() + { + + } + + public void render(int render_cycle) + { + + } + + public void Reset() + { + + } + + public void SyncState(Serializer ser) + { + + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/ReadMe.txt b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/ReadMe.txt new file mode 100644 index 0000000000..bc60bf4b01 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/ReadMe.txt @@ -0,0 +1 @@ +TODO: diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs new file mode 100644 index 0000000000..1212ce8a24 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs @@ -0,0 +1,37 @@ +using System; +using BizHawk.Emulation.Common; +using BizHawk.Common.NumberExtensions; +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public class SerialPort + { + public VectrexHawk Core { get; set; } + + public byte ReadReg(int addr) + { + return 0xFF; + } + + public void WriteReg(int addr, byte value) + { + + } + + public void serial_transfer_tick() + { + + } + + public void Reset() + { + + } + + public void SyncState(Serializer ser) + { + + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ICodeDataLog.cs new file mode 100644 index 0000000000..0e73346e43 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ICodeDataLog.cs @@ -0,0 +1,104 @@ +using System; +using System.IO; +using System.Collections.Generic; + +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Components.M6502; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public sealed partial class VectrexHawk : ICodeDataLogger + { + public void SetCDL(ICodeDataLog cdl) + { + CDL = cdl; + } + + public void NewCDL(ICodeDataLog cdl) + { + cdl["RAM"] = new byte[MemoryDomains["RAM"].Size]; + + if (MemoryDomains.Has("Save RAM")) + { + cdl["Save RAM"] = new byte[MemoryDomains["Save RAM"].Size]; + } + + if (MemoryDomains.Has("Battery RAM")) + { + cdl["Battery RAM"] = new byte[MemoryDomains["Battery RAM"].Size]; + } + + if (MemoryDomains.Has("Battery RAM")) + { + cdl["Battery RAM"] = new byte[MemoryDomains["Battery RAM"].Size]; + } + + cdl.SubType = "VIC20"; + cdl.SubVer = 0; + } + + [FeatureNotImplemented] + public void DisassembleCDL(Stream s, ICodeDataLog cdl) + { + + } + + private enum CDLog_AddrType + { + None, + ROM, + MainRAM, + SaveRAM, + } + + [Flags] + private enum CDLog_Flags + { + ExecFirst = 0x01, + ExecOperand = 0x02, + Data = 0x04 + }; + + private 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; + + private void RunCDL(ushort address, CDLog_Flags flags) + { + if (MapMemory != null) + { + CDLog_MapResults results = MapMemory(address, false); + switch (results.Type) + { + case CDLog_AddrType.None: break; + case CDLog_AddrType.MainRAM: CDL["Main RAM"][results.Address] |= (byte)flags; break; + case CDLog_AddrType.SaveRAM: CDL["Save 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 PeekMemory(address); + } + + /// + /// A wrapper for ReadMemory which inserts CDL logic + /// + private 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/GCE/Vectrex/VectrexHawk.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IDebuggable.cs new file mode 100644 index 0000000000..c703f77cbc --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IDebuggable.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public partial class VectrexHawk : 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)cpu.TotalExecutedCycles; } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs new file mode 100644 index 0000000000..e0ea80cf29 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IEmulator.cs @@ -0,0 +1,101 @@ +using BizHawk.Common.NumberExtensions; +using BizHawk.Emulation.Common; +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public partial class VectrexHawk : IEmulator, IVideoProvider + { + public IEmulatorServiceProvider ServiceProvider { get; } + + public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; + + public bool FrameAdvance(IController controller, bool render, bool rendersound) + { + if (_tracer.Enabled) + { + cpu.TraceCallback = s => _tracer.Put(s); + } + else + { + cpu.TraceCallback = null; + } + + _frame++; + + if (controller.IsPressed("Power")) + { + HardReset(); + } + + _islag = true; + + do_frame(); + + if (_islag) + { + _lagcount++; + } + + return true; + } + + public void do_frame() + { + for (int i = 0; i < 45000; i++) + { + timer_1_tick(); + timer_2_tick(); + cpu.ExecuteOne(); + } + } + + public int Frame => _frame; + + public string SystemId => "VEC"; + + public bool DeterministicEmulation { get; set; } + + public void ResetCounters() + { + _frame = 0; + _lagcount = 0; + _islag = false; + } + + public CoreComm CoreComm { get; } + + public void Dispose() + { + audio.DisposeSound(); + } + + #region Video provider + + public int _frameHz = 60; + + public int[] _vidbuffer; + + public int[] GetVideoBuffer() + { + return _vidbuffer; + } + + public int VirtualWidth => 160; + public int VirtualHeight => 144; + public int BufferWidth => 160; + 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 + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IInputPollable.cs new file mode 100644 index 0000000000..66a0ccf891 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IInputPollable.cs @@ -0,0 +1,24 @@ +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public partial class VectrexHawk : 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/GCE/Vectrex/VectrexHawk.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IMemoryDomains.cs new file mode 100644 index 0000000000..bfc65dec78 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IMemoryDomains.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public partial class VectrexHawk + { + private IMemoryDomains MemoryDomains; + + public void SetupMemoryDomains() + { + var domains = new List + { + new MemoryDomainDelegate( + "Main RAM", + RAM.Length, + MemoryDomain.Endian.Little, + addr => RAM[addr], + (addr, value) => RAM[addr] = value, + 1), + new MemoryDomainDelegate( + "System Bus", + 0X10000, + MemoryDomain.Endian.Little, + addr => PeekSystemBus(addr), + (addr, value) => PokeSystemBus(addr, value), + 1), + new MemoryDomainDelegate( + "ROM", + _rom.Length, + MemoryDomain.Endian.Little, + addr => _rom[addr], + (addr, value) => _rom[addr] = value, + 1), + }; + + if (cart_RAM != null) + { + var CartRam = new MemoryDomainByteArray("Cart RAM", MemoryDomain.Endian.Little, cart_RAM, true, 1); + domains.Add(CartRam); + } + + MemoryDomains = new MemoryDomainList(domains); + (ServiceProvider as BasicServiceProvider).Register(MemoryDomains); + } + + private byte PeekSystemBus(long addr) + { + ushort addr2 = (ushort)(addr & 0xFFFF); + return PeekMemory(addr2); + } + + private void PokeSystemBus(long addr, byte value) + { + ushort addr2 = (ushort)(addr & 0xFFFF); + WriteMemory(addr2, value); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISaveRam.cs new file mode 100644 index 0000000000..051fe9d6f5 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISaveRam.cs @@ -0,0 +1,34 @@ +using System; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public partial class VectrexHawk : ISaveRam + { + public byte[] CloneSaveRam() + { + if (cart_RAM != null) + { + return (byte[])cart_RAM.Clone(); + } + else + { + return null; + } + } + + public void StoreSaveRam(byte[] data) + { + Buffer.BlockCopy(data, 0, cart_RAM, 0, data.Length); + Console.WriteLine("loading SRAM here"); + } + + public bool SaveRamModified + { + get + { + return has_bat & _syncSettings.Use_SRAM; + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISettable.cs new file mode 100644 index 0000000000..53b8c11013 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISettable.cs @@ -0,0 +1,92 @@ +using System; +using System.ComponentModel; + +using Newtonsoft.Json; + +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public partial class VectrexHawk : IEmulator, IStatable, ISettable + { + public VectrexSettings GetSettings() + { + return _settings.Clone(); + } + + public VectrexSyncSettings GetSyncSettings() + { + return _syncSettings.Clone(); + } + + public bool PutSettings(VectrexSettings o) + { + _settings = o; + return false; + } + + public bool PutSyncSettings(VectrexSyncSettings o) + { + bool ret = VectrexSyncSettings.NeedsReboot(_syncSettings, o); + _syncSettings = o; + return ret; + } + + private VectrexSettings _settings = new VectrexSettings(); + public VectrexSyncSettings _syncSettings = new VectrexSyncSettings(); + + public class VectrexSettings + { + + public VectrexSettings Clone() + { + return (VectrexSettings)MemberwiseClone(); + } + } + + public class VectrexSyncSettings + { + [JsonIgnore] + public string Port1 = VectrexHawkControllerDeck.DefaultControllerName; + + public enum ControllerType + { + Default, + } + + [JsonIgnore] + private ControllerType _VectrexController; + + [DisplayName("Controller")] + [Description("Select Controller Type")] + [DefaultValue(ControllerType.Default)] + public ControllerType VectrexController + { + get { return _VectrexController; } + set + { + if (value == ControllerType.Default) { Port1 = VectrexHawkControllerDeck.DefaultControllerName; } + else { Port1 = VectrexHawkControllerDeck.DefaultControllerName; } + + _VectrexController = value; + } + } + + [DisplayName("Use Existing SaveRAM")] + [Description("When true, existing SaveRAM will be loaded at boot up")] + [DefaultValue(false)] + public bool Use_SRAM { get; set; } + + public VectrexSyncSettings Clone() + { + return (VectrexSyncSettings)MemberwiseClone(); + } + + public static bool NeedsReboot(VectrexSyncSettings x, VectrexSyncSettings y) + { + return !DeepEquality.DeepEquals(x, y); + } + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IStatable.cs new file mode 100644 index 0000000000..203a98841d --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IStatable.cs @@ -0,0 +1,97 @@ +using System.IO; + +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public partial class VectrexHawk : IStatable + { + public bool BinarySaveStatesPreferred => true; + + public void SaveStateText(TextWriter writer) + { + SyncState(new Serializer(writer)); + } + + public void LoadStateText(TextReader reader) + { + SyncState(new Serializer(reader)); + } + + public void SaveStateBinary(BinaryWriter bw) + { + SyncState(new Serializer(bw)); + } + + public void LoadStateBinary(BinaryReader br) + { + SyncState(new Serializer(br)); + } + + public byte[] SaveStateBinary() + { + MemoryStream ms = new MemoryStream(); + BinaryWriter bw = new BinaryWriter(ms); + SaveStateBinary(bw); + bw.Flush(); + return ms.ToArray(); + } + + private void SyncState(Serializer ser) + { + byte[] core = null; + if (ser.IsWriter) + { + var ms = new MemoryStream(); + ms.Close(); + core = ms.ToArray(); + } + cpu.SyncState(ser); + mapper.SyncState(ser); + ppu.SyncState(ser); + serialport.SyncState(ser); + audio.SyncState(ser); + + ser.BeginSection("VECTREX"); + + ser.Sync(nameof(RAM), ref RAM, false); + + ser.Sync(nameof(dir_dac), ref dir_dac); + ser.Sync(nameof(dir_ctrl), ref dir_ctrl); + + ser.Sync(nameof(portB_ret), ref portB_ret); + ser.Sync(nameof(portA_ret), ref portA_ret); + + ser.Sync(nameof(t1_low), ref t1_low); + ser.Sync(nameof(t1_high), ref t1_high); + ser.Sync(nameof(t1_counter), ref t1_counter); + ser.Sync(nameof(t1_shot_go), ref t1_shot_go); + ser.Sync(nameof(PB7), ref PB7); + ser.Sync(nameof(PB7_prev), ref PB7_prev); + + ser.Sync(nameof(t2_low), ref t2_low); + ser.Sync(nameof(t2_high), ref t2_high); + ser.Sync(nameof(t2_counter), ref t2_counter); + ser.Sync(nameof(t2_shot_go), ref t2_shot_go); + ser.Sync(nameof(PB6), ref PB6); + ser.Sync(nameof(PB6_prev), ref PB6_prev); + + ser.Sync(nameof(int_en), ref int_en); + ser.Sync(nameof(int_fl), ref int_fl); + ser.Sync(nameof(aux_ctrl), ref aux_ctrl); + + ser.Sync(nameof(_frame), ref _frame); + ser.Sync(nameof(_lagcount), ref _lagcount); + ser.Sync(nameof(_islag), ref _islag); + + // probably a better way to do this + if (cart_RAM != null) + { + ser.Sync(nameof(cart_RAM), ref cart_RAM, false); + } + + ser.EndSection(); + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs new file mode 100644 index 0000000000..442924488f --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.cs @@ -0,0 +1,135 @@ +using System; + +using BizHawk.Common.BufferExtensions; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common.Components.MC6809; + +using System.Runtime.InteropServices; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + [Core( + "VectrexHawk", + "", + isPorted: false, + isReleased: true)] + [ServiceNotApplicable(typeof(IDriveLight))] + public partial class VectrexHawk : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, + ISettable + { + public byte[] RAM = new byte[0x400]; + + + public byte[] _bios; + public readonly byte[] _rom; + + public byte[] cart_RAM; + public bool has_bat; + + private int _frame = 0; + + public MapperBase mapper; + + private readonly ITraceable _tracer; + + public MC6809 cpu; + public PPU ppu; + public Audio audio; + public SerialPort serialport; + + [CoreConstructor("VEC")] + public VectrexHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) + { + var ser = new BasicServiceProvider(this); + + cpu = new MC6809 + { + ReadMemory = ReadMemory, + WriteMemory = WriteMemory, + PeekMemory = PeekMemory, + DummyReadMemory = ReadMemory, + OnExecFetch = ExecFetch, + }; + + audio = new Audio(); + ppu = new PPU(); + serialport = new SerialPort(); + + CoreComm = comm; + + _settings = (VectrexSettings)settings ?? new VectrexSettings(); + _syncSettings = (VectrexSyncSettings)syncSettings ?? new VectrexSyncSettings(); + _controllerDeck = new VectrexHawkControllerDeck(_syncSettings.Port1); + + byte[] Bios = null; + Bios = comm.CoreFileProvider.GetFirmware("Vectrex", "Bios", true, "BIOS Not Found, Cannot Load"); + _bios = Bios; + + Console.WriteLine("SHA1:" + rom.HashSHA1(0, rom.Length)); + + _rom = rom; + + // mirror games that are too small + if (_rom.Length < 0x8000) + { + _rom = new byte[0x8000]; + + for (int i = 0; i < 0x8000 / rom.Length; i++) + { + for (int j = 0; j < rom.Length; j++) + { + _rom[j + i * rom.Length] = rom[j]; + } + } + } + + Setup_Mapper(); + + _frameHz = 60; + + audio.Core = this; + ppu.Core = this; + serialport.Core = this; + + ser.Register(this); + ser.Register(audio); + ServiceProvider = ser; + + _settings = (VectrexSettings)settings ?? new VectrexSettings(); + _syncSettings = (VectrexSyncSettings)syncSettings ?? new VectrexSyncSettings(); + + _tracer = new TraceBuffer { Header = cpu.TraceHeader }; + ser.Register(_tracer); + + SetupMemoryDomains(); + HardReset(); + + cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory); + } + + public DisplayType Region => DisplayType.NTSC; + + private readonly VectrexHawkControllerDeck _controllerDeck; + + public void HardReset() + { + Register_Reset(); + ppu.Reset(); + audio.Reset(); + serialport.Reset(); + + _vidbuffer = new int[VirtualWidth * VirtualHeight]; + } + + private void ExecFetch(ushort addr) + { + MemoryCallbacks.CallExecutes(addr, "System Bus"); + } + + private void Setup_Mapper() + { + mapper = new MapperDefault(); + mapper.Core = this; + } + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllerDeck.cs new file mode 100644 index 0000000000..39ca11d579 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllerDeck.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using BizHawk.Common; +using BizHawk.Common.ReflectionExtensions; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + public class VectrexHawkControllerDeck + { + public VectrexHawkControllerDeck(string controller1Name) + { + if (!ValidControllerTypes.ContainsKey(controller1Name)) + { + throw new InvalidOperationException("Invalid controller type: " + controller1Name); + } + + Port1 = (IPort)Activator.CreateInstance(ValidControllerTypes[controller1Name], 1); + + Definition = new ControllerDefinition + { + Name = Port1.Definition.Name, + BoolButtons = Port1.Definition.BoolButtons + .ToList() + }; + + Definition.FloatControls.AddRange(Port1.Definition.FloatControls); + + Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges); + } + + public byte ReadPort1(IController c) + { + return Port1.Read(c); + } + + public ControllerDefinition Definition { get; } + + public void SyncState(Serializer ser) + { + ser.BeginSection("Port1"); + Port1.SyncState(ser); + ser.EndSection(); + } + + private readonly IPort Port1; + + private static Dictionary _controllerTypes; + + public static Dictionary ValidControllerTypes + { + get + { + if (_controllerTypes == null) + { + _controllerTypes = typeof(VectrexHawkControllerDeck).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/GCE/Vectrex/VectrexHawkControllers.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs new file mode 100644 index 0000000000..08ae1262d4 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Consoles.Vectrex +{ + /// + /// Represents a Vectrex add on + /// + public interface IPort + { + byte Read(IController c); + + ControllerDefinition Definition { get; } + + void SyncState(Serializer ser); + + int PortNum { get; } + } + + [DisplayName("Vectrex Controller")] + public class StandardControls : IPort + { + public StandardControls(int portNum) + { + PortNum = portNum; + Definition = new ControllerDefinition + { + Name = "Vectrex 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; + + return result; + } + + private static readonly string[] BaseDefinition = + { + + }; + + public void SyncState(Serializer ser) + { + //nothing + } + } +} \ No newline at end of file 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.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 264d658e98..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 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 33fc348968..843377bcc7 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() { 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 27775f026b..c1d420be36 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs @@ -1532,34 +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("LYC_t", ref LYC_t); - ser.Sync("LYC_cd", ref LYC_cd); + 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 ca42c1472e..8b22b682ee 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs @@ -161,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 > 42134400) { throw new Exception("ERROR: Unable to Resolve Frame"); } in_vblank_old = in_vblank; REG_FF0F_OLD = REG_FF0F; 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 5091c6ceb8..74cd3fa611 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IStatable.cs @@ -55,56 +55,56 @@ 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("undoc_6C", ref undoc_6C); - ser.Sync("undoc_72", ref undoc_72); - ser.Sync("undoc_73", ref undoc_73); - ser.Sync("undoc_74", ref undoc_74); - ser.Sync("undoc_75", ref undoc_75); - ser.Sync("undoc_76", ref undoc_76); - ser.Sync("undoc_77", ref undoc_77); + 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("Use_MT", ref Use_MT); - ser.Sync("addr_access", ref addr_access); + 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(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs index 9d9242bf7b..5a7d688cd9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.cs @@ -158,10 +158,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk Buffer.BlockCopy(rom, 0x100, header, 0, 0x50); - string hash_md5 = null; - hash_md5 = "md5:" + rom.HashMD5(0, rom.Length); - Console.WriteLine(hash_md5); - + Console.WriteLine("MD5: " + rom.HashMD5(0, rom.Length)); + Console.WriteLine("SHA1: " + rom.HashSHA1(0, rom.Length)); _rom = rom; Setup_Mapper(); 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/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 88029763c2..5347487ed4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC3.cs @@ -284,20 +284,20 @@ 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("control", ref control); - ser.Sync("chip_read", ref chip_read); - ser.Sync("timer_read", ref timer_read); - ser.Sync("time_val_shift", ref time_val_shift); - ser.Sync("time", ref time); - ser.Sync("RTC_timer", ref RTC_timer); - ser.Sync("RTC_low_clock", ref RTC_low_clock); - ser.Sync("RTC_seconds", ref RTC_seconds); + 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 520db111e1..340b61fc2b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs @@ -161,97 +161,97 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public virtual void SyncState(Serializer ser) { - 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(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("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(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("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("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(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("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(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("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(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("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 f5e0150c61..c4fb5218e9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs @@ -166,15 +166,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk 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("going_out", ref going_out); - ser.Sync("coming_in", ref coming_in); + 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 index cfc841d321..6ce439f161 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ICodeDataLog.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ICodeDataLog.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Collections.Generic; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.Components.LR35902; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs index 5187308752..e272ccc7ad 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs @@ -1,9 +1,6 @@ -using BizHawk.Common.NumberExtensions; -using BizHawk.Emulation.Common; -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; +using System; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.GBHawk; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink @@ -69,7 +66,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink { _cableconnected ^= true; Console.WriteLine("Cable connect status to {0}", _cableconnected); - LinkConnected = _cableconnected; } _cablediscosignal = cablediscosignalNew; @@ -104,7 +100,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink // 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 (LinkConnected) + if (_cableconnected) { L.serialport.send_external_bit((byte)(L.serialport.serial_data & 0x80)); @@ -122,7 +118,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink { do_r_next = false; - if (LinkConnected) + if (_cableconnected) { R.serialport.send_external_bit((byte)(R.serialport.serial_data & 0x80)); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs index d28fdaba55..baa6162919 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs index 75cea814bc..79ab75ecc1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs @@ -129,8 +129,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink private int _RTCInitialTime_L; private int _RTCInitialTime_R; [JsonIgnore] - public ushort _DivInitialTime_L; - public ushort _DivInitialTime_R; + public ushort _DivInitialTime_L = 8; + public ushort _DivInitialTime_R = 8; public GBLinkSyncSettings Clone() { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs index 7b3049f1e2..9481bfc597 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs @@ -57,12 +57,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink ser.Sync("Lag", ref _lagcount); ser.Sync("Frame", ref _frame); ser.Sync("IsLag", ref _islag); - ser.Sync("_cableconnected", ref _cableconnected); - ser.Sync("_cablediscosignal", ref _cablediscosignal); - ser.Sync("do_r_next", ref do_r_next); + 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); - - LinkConnected = _cableconnected; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs index 4ef7f815e0..4192c9bece 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs @@ -1,12 +1,8 @@ using System; -using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Common.Components.LR35902; -using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Nintendo.GBHawk; -using System.Runtime.InteropServices; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink { @@ -14,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink "GBHawkLink", "", isPorted: false, - isReleased: false)] + isReleased: true)] [ServiceNotApplicable(typeof(IDriveLight))] public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable, ISettable @@ -39,7 +35,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink linkSettings = (GBLinkSettings)settings ?? new GBLinkSettings(); linkSyncSettings = (GBLinkSyncSettings)syncSettings ?? new GBLinkSyncSettings(); - _controllerDeck = new GBHawkLinkControllerDeck(GBHawkControllerDeck.DefaultControllerName, GBHawkControllerDeck.DefaultControllerName); + _controllerDeck = new GBHawkLinkControllerDeck(GBHawkLinkControllerDeck.DefaultControllerName, GBHawkLinkControllerDeck.DefaultControllerName); CoreComm = comm; @@ -74,8 +70,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink SetupMemoryDomains(); HardReset(); - - LinkConnected = _cableconnected; } public void HardReset() @@ -92,7 +86,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink private readonly ITraceable _tracer; - public bool LinkConnected { get; private set; } + public bool LinkConnected + { + get { return _cableconnected; } + set { _cableconnected = value; } + } private void ExecFetch(ushort addr) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs index 9bc1143bb4..7f789b0059 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllerDeck.cs @@ -49,11 +49,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink 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/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.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISaveRam.cs index 3776eb00f7..218d2bf3ec 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISaveRam.cs @@ -41,31 +41,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy break; default: throw new ArgumentException("Size of saveram data does not match expected!"); - case 44: - data = FixRTC(data, 44); - break; - case 40: - data = FixRTC(data, 40); - break; } LibGambatte.gambatte_loadsavedata(GambatteState, data); } - - private byte[] FixRTC(byte[] data, int offset) - { - // length - offset is the start of the VBA-only data; so - // length - offset - 4 is the start of the RTC block - int idx = data.Length - offset - 4; - - byte[] ret = new byte[idx + 4]; - Buffer.BlockCopy(data, 0, ret, 0, idx); - data[idx] = (byte)zerotime; - data[idx + 1] = (byte)(zerotime >> 8); - data[idx + 2] = (byte)(zerotime >> 16); - data[idx + 3] = (byte)(zerotime >> 24); - - return ret; - } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs index 297b029f11..70a2aef2fe 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs @@ -116,17 +116,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy [DefaultValue(false)] public bool RealTimeRTC { get; set; } - [DisplayName("RTC Initial Time")] - [Description("Set the initial RTC time in terms of elapsed seconds. Only used when RealTimeRTC is false.")] + [DisplayName("RTC Divisor Offset")] + [Description("CPU clock frequency relative to real time clock. Base value is 2^22 Hz. Used in cycle-based RTC to sync on real hardware to account for RTC imperfections.")] [DefaultValue(0)] - public int RTCInitialTime - { - get { return _RTCInitialTime; } - set { _RTCInitialTime = Math.Max(0, Math.Min(1024 * 24 * 60 * 60, value)); } - } - - [JsonIgnore] - private int _RTCInitialTime; + public int RTCDivisorOffset { get; set; } [DisplayName("Equal Length Frames")] [Description("When false, emulation frames sync to vblank. Only useful for high level TASing.")] @@ -141,11 +134,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy [DeepEqualsIgnore] private bool _equalLengthFrames; - [DisplayName("Initial DIV offset")] - [Description("Internal. Probably doesn't work. Leave this set to 0. Accepts values from 0 to 65532 in steps of 4")] - [DefaultValue(0)] - public int InitialDiv { get; set; } - public GambatteSyncSettings() { SettingsUtil.SetDefaultValues(this); @@ -160,11 +148,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { return !DeepEquality.DeepEquals(x, y); } - - public uint GetInitialDivInternal() - { - return (uint)(InitialDiv & 0xfffc); - } } } } 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..0de16d0723 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); @@ -58,13 +58,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { _syncSettings = (GambatteSyncSettings)syncSettings ?? new GambatteSyncSettings(); - // copy over non-loadflag syncsettings now; they won't take effect if changed later - zerotime = (uint)_syncSettings.RTCInitialTime; - - real_rtc_time = !DeterministicEmulation && _syncSettings.RealTimeRTC; - - DivInternal = _syncSettings.GetInitialDivInternal(); - LibGambatte.LoadFlags flags = 0; switch (_syncSettings.ConsoleMode) @@ -90,33 +83,26 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy flags |= LibGambatte.LoadFlags.MULTICART_COMPAT; } - if (LibGambatte.gambatte_load(GambatteState, file, (uint)file.Length, GetCurrentTime(), flags, DivInternal) != 0) + if (LibGambatte.gambatte_load(GambatteState, file, (uint)file.Length, flags) != 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?)"); } + byte[] Bios; if ((flags & LibGambatte.LoadFlags.FORCE_DMG) == LibGambatte.LoadFlags.FORCE_DMG) { - byte[] Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load"); - + Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load"); IsCgb = false; - - if (LibGambatte.gambatte_loaddmgbios(GambatteState, Bios) != 0) - { - throw new InvalidOperationException("gambatte_loaddmgbios() returned non-zero (bios error)"); - } } else { - byte[] Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load"); - + Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load"); IsCgb = true; - - if (LibGambatte.gambatte_loadgbcbios(GambatteState, Bios) != 0) - { - throw new InvalidOperationException("gambatte_loadgbcbios() returned non-zero (bios error)"); - } } + if (LibGambatte.gambatte_loadbios(GambatteState, Bios, (uint)Bios.Length) != 0) + { + throw new InvalidOperationException($"{nameof(LibGambatte.gambatte_loadbios)}() returned non-zero (bios error)"); + } // set real default colors (before anyone mucks with them at all) PutSettings((GambatteSettings)settings ?? new GambatteSettings()); @@ -140,8 +126,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy string romname = System.Text.Encoding.ASCII.GetString(buff); Console.WriteLine("Core reported rom name: {0}", romname); - TimeCallback = new LibGambatte.RTCCallback(GetCurrentTime); - LibGambatte.gambatte_setrtccallback(GambatteState, TimeCallback); + if (!DeterministicEmulation && _syncSettings.RealTimeRTC) + { + LibGambatte.gambatte_settimemode(GambatteState, false); + } + LibGambatte.gambatte_setrtcdivisoroffset(GambatteState, _syncSettings.RTCDivisorOffset); _cdCallback = new LibGambatte.CDCallback(CDCallbackProc); @@ -174,59 +163,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy /// private LibGambatte.Buttons CurrentButtons = 0; - private uint DivInternal = 0; - - #region RTC - - /// - /// RTC time when emulation begins. - /// - private readonly uint zerotime = 0; - - /// - /// if true, RTC will run off of real elapsed time - /// - private bool real_rtc_time = false; - - private LibGambatte.RTCCallback TimeCallback; - - private static long GetUnixNow() - { - // because internally the RTC works off of relative time, we don't need to base - // this off of any particular canonical epoch. - return DateTime.UtcNow.Ticks / 10000000L - 60000000000L; - } - - private uint GetCurrentTime() - { - if (real_rtc_time) - { - return (uint)GetUnixNow(); - } - - ulong fn = (ulong)Frame; - - // as we're exactly tracking cpu cycles, this can be pretty accurate - fn *= 4389; - fn /= 262144; - fn += zerotime; - return (uint)fn; - } - - private uint GetInitialTime() - { - if (real_rtc_time) - { - return (uint)GetUnixNow(); - } - - // setting the initial boot time to 0 will cause our zerotime - // to function as an initial offset, which is what we want - return 0; - } - - #endregion - #region ALL SAVESTATEABLE STATE GOES HERE /// @@ -327,7 +263,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy if (controller.IsPressed("Power")) { - LibGambatte.gambatte_reset(GambatteState, GetCurrentTime(), DivInternal); + LibGambatte.gambatte_reset(GambatteState); } if (Tracer.Enabled) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs index c10f340eae..1458fd746e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs @@ -34,7 +34,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { _cableconnected ^= true; Console.WriteLine("Cable connect status to {0}", _cableconnected); - LinkConnected = _cableconnected; } _cablediscosignal = cablediscosignalNew; 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/Gameboy/LibGambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs index 1a05daea20..d156afdb63 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs @@ -53,29 +53,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy /// opaque state pointer /// the rom data, can be disposed of once this function returns /// length of romdata in bytes - /// RTC time when the rom is loaded /// ORed combination of LoadFlags. /// 0 on success, negative value on failure. [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern int gambatte_load(IntPtr core, byte[] romdata, uint length, long now, LoadFlags flags, uint div); + public static extern int gambatte_load(IntPtr core, byte[] romdata, uint length, LoadFlags flags); /// - /// Load GB BIOS image. + /// Load GB(C) BIOS image. /// /// opaque state pointer /// the bios data, can be disposed of once this function returns + /// length of romdata in bytes /// 0 on success, negative value on failure. [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern int gambatte_loaddmgbios(IntPtr core, byte[] biosdata); - - /// - /// Load GBC BIOS image. - /// - /// opaque state pointer - /// the bios data, can be disposed of once this function returns - /// 0 on success, negative value on failure. - [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern int gambatte_loadgbcbios(IntPtr core, byte[] biosdata); + public static extern int gambatte_loadbios(IntPtr core, byte[] biosdata, uint length); /// /// Emulates until at least 'samples' stereo sound samples are produced in the supplied buffer, @@ -122,9 +113,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy /// Equivalent to reloading a ROM image, or turning a Game Boy Color off and on again. /// /// opaque state pointer - /// RTC time when the reset occurs [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern void gambatte_reset(IntPtr core, long now, uint div); + public static extern void gambatte_reset(IntPtr core); /// /// palette type for gambatte_setdmgpalettecolor @@ -267,21 +257,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy /// 0-153 inclusive [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void gambatte_setscanlinecallback(IntPtr core, ScanlineCallback callback, int sl); - - /// - /// type of the RTC callback - /// - /// what time is it, unixy - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate uint RTCCallback(); - - /// - /// sets RTC callback. probably mandatory. - /// - /// opaque state pointer - /// the callback - [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern void gambatte_setrtccallback(IntPtr core, RTCCallback callback); /// /// type of the link data sent callback @@ -297,6 +272,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void gambatte_setlinkcallback(IntPtr core, LinkCallback callback); + /// + /// Changes between cycle-based and real-time RTC. Defaults to cycle-based. + /// + /// opaque state pointer + /// use cycle-based RTC + [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void gambatte_settimemode(IntPtr core, bool useCycles); + + /// + /// Adjusts the CPU clock frequency relative to real time. Base value is 2^22 Hz. + /// This is used to account for drift in the RTC when syncing cycle-based RTC to real hardware. + /// RTCs in carts are not perfectly accurate, and the value will differ from cart to cart. + /// + /// opaque state pointer + /// CPU frequency adjustment + [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void gambatte_setrtcdivisoroffset(IntPtr core, int rtcDivisorOffset); + /// /// Returns true if the currently loaded ROM image is treated as having CGB support. /// 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 6d56b3e7da..f1cba049bc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs @@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi bool event_frameend = false; bool event_breakpoint = false; - private static readonly PlatformLinkedLibSingleton.PlatformLinkedLibManager libLoader = PlatformLinkedLibSingleton.LinkedLibManager; + private static readonly OSTailoredCode.ILinkedLibManager libLoader = OSTailoredCode.LinkedLibManager; public enum m64p_error { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs index d39606def4..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(); } @@ -730,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); @@ -946,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); @@ -1259,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) { @@ -1391,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) @@ -1412,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 ce0e72510f..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(); @@ -255,7 +255,10 @@ 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) @@ -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 472f229a4d..05173bf5a2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper034.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper034.cs @@ -86,8 +86,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/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 c8df6cac0d..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) 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 2642787ef7..3fc666b556 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs @@ -11,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; @@ -72,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; + } } - public 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); } - public MagicSoundProvider magicSoundProvider; + + public void DiscardSamples() + { + blip.Clear(); + apu.sampleclock = 0; + } + + #endregion public void HardReset() { @@ -243,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(); @@ -563,7 +536,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ///////////////////////////// // dmc dma end ///////////////////////////// - apu.RunOne(true); + apu.RunOneFirst(); if (cpu.RDY && !IRQ_delay) { @@ -576,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--; @@ -592,8 +576,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES cpu.RDY = true; IRQ_delay = true; } - - Board.ClockCPU(); } public byte ReadReg(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IStatable.cs index eeda0a5fd7..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); @@ -83,32 +85,32 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync("VS_ROM_Control", ref VS_ROM_control); // single cycle execution related - ser.Sync("current_strobe", ref current_strobe); - ser.Sync("new_strobe", ref new_strobe); + ser.Sync(nameof(current_strobe), ref current_strobe); + ser.Sync(nameof(new_strobe), ref new_strobe); - ser.BeginSection("Board"); + 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 62d534f935..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) { 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 b04744f5f8..74c2b582d9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs @@ -105,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); @@ -112,21 +113,39 @@ 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; } @@ -206,88 +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("race_2006_2", ref race_2006_2); - 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("ppuphase", ref ppuphase); + 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("evenOddDestiny", ref evenOddDestiny); - ser.Sync("NMI_offset", ref NMI_offset); - 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("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++) @@ -308,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"; @@ -331,10 +349,8 @@ 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 - - - 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) @@ -367,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; } @@ -398,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 739338840a..01d0aadf5a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs @@ -77,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 diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs index ead5ce61b5..8bc43b817b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs @@ -78,13 +78,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES 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; @@ -98,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; @@ -134,7 +134,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int xstart; int rasterpos; bool renderspritenow; - bool renderbgnow; int s; int ppu_aux_index; bool junksprite; @@ -149,8 +148,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ppur.status.cycle = 0; // These things happen at the start of every frame - //Reg2002_vblank_active = true; - //Reg2002_vblank_active_pending = true; ppuphase = PPU_PHASE_VBL; bgdata = new BGDataRecord[34]; } @@ -188,6 +185,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES 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) @@ -201,100 +204,97 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES 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 = 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.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 @@ -341,7 +341,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES oam_index += 4; } } - else if (soam_index >= 8) + else { if (yp >= read_value && yp < read_value + spriteHeight && PPUON) { @@ -380,30 +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]); } - - 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(); @@ -412,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; @@ -428,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) @@ -457,13 +456,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES 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) { ppur.increment_hsc(); @@ -526,18 +525,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES 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) { ppur.increment_hsc(); @@ -623,7 +622,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES 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]; @@ -662,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(); @@ -670,7 +669,7 @@ 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) @@ -739,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 @@ -825,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]; @@ -925,26 +916,26 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else { - if (ppur.status.cycle == 320) - { - ppuphase = PPU_PHASE_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(); @@ -1009,6 +1000,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES 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) @@ -1038,6 +1035,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES 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(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index aad8579a37..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 diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs index 110e5274b0..6ded0e50d8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IStatable.cs @@ -52,13 +52,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk ser.Sync("Lag", ref _lagcount); ser.Sync("Frame", ref _frame); ser.Sync("IsLag", ref _islag); - ser.Sync("pass_a_frame", ref pass_a_frame); - ser.Sync("reset_frame", ref reset_frame); - ser.Sync("pass_new_input", ref pass_new_input); - ser.Sync("current_cycle", ref current_cycle); - ser.Sync("reset_cycle", ref reset_cycle); - ser.Sync("reset_cycle_int", ref reset_cycle_int); - ser.Sync("VBL_CNT", ref VBL_CNT); + 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 index 0487bd3f2a..a6de84103b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs @@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk "SubNESHawk", "", isPorted: false, - isReleased: false)] + isReleased: true)] [ServiceNotApplicable(typeof(IDriveLight))] public partial class SubNESHawk : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ISettable, INESPPUViewable @@ -34,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk game, rom, subnesSettings, subnesSyncSettings); ser.Register(subnes.videoProvider); - ser.Register(subnes.magicSoundProvider); + 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); 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.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..040c62f328 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) @@ -357,15 +357,15 @@ namespace BizHawk.Emulation.Cores.PCEngine // clear inter-sprite priority buffer Array.Clear(InterSpritePriorityBuffer, 0, FrameWidth); + var testRange = new MutableIntRange(0, vdc.ActiveLine + 1); for (int i = 0; i < 64; i++) { int y = (vdc.SpriteAttributeTable[(i * 4) + 0] & 1023) - 64; int x = (vdc.SpriteAttributeTable[(i * 4) + 1] & 1023) - 32; ushort flags = vdc.SpriteAttributeTable[(i * 4) + 3]; - int height = heightTable[(flags >> 12) & 3]; - - if (y + height <= vdc.ActiveLine || y > vdc.ActiveLine) - continue; + byte height = heightTable[(flags >> 12) & 3]; + testRange.Min = vdc.ActiveLine - height; + if (!testRange.StrictContains(y)) continue; int patternNo = (((vdc.SpriteAttributeTable[(i * 4) + 2]) >> 1) & 0x1FF); int paletteBase = 256 + ((flags & 15) * 16); 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..19c04a4312 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IEmulator.cs @@ -0,0 +1,401 @@ +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 int L_NMI_CD, R_NMI_CD; + + 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(); + + if (!_cableconnected) + { + if ((L.Port05 & 0x38) == 0x38) + { + L.Port05 |= 4; + L.Cpu.NonMaskableInterrupt = true; + } + + if ((R.Port05 & 0x38) == 0x38) + { + R.Port05 |= 4; + R.Cpu.NonMaskableInterrupt = true; + } + } + else + { + if ((L.Port05 & 0x38) == 0x38) + { + L.Port05 &= 0xFB; + } + + if ((R.Port05 & 0x38) == 0x38) + { + R.Port05 &= 0xFB; + } + } + + 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 + if (L.p3_write) + { + L.p3_write = false; + + if (((L.Port05 & 0x38) == 0x38) && _cableconnected) + { + L.Port05 |= 1; + + if ((R.Port05 & 0x38) == 0x38) + { + R.Port05 |= 2; + R.Port04 = L.Port03; + R_NMI_CD = 256; + //R.Cpu.NonMaskableInterrupt = true; + } + } + } + + if (L.p4_read) + { + L.p4_read = false; + L.Cpu.NonMaskableInterrupt = false; + + if (((L.Port05 & 0x38) == 0x38) && _cableconnected) + { + L.Port05 &= 0xFD; + + if ((R.Port05 & 0x38) == 0x38) + { + R.Port05 &= 0xFE; + } + } + } + + if (R.p3_write) + { + R.p3_write = false; + + if (((R.Port05 & 0x38) == 0x38) && _cableconnected) + { + R.Port05 |= 1; + + if ((L.Port05 & 0x38) == 0x38) + { + L.Port05 |= 2; + L.Port04 = R.Port03; + L_NMI_CD = 256; + //L.Cpu.NonMaskableInterrupt = true; + } + } + } + + if (R.p4_read) + { + R.p4_read = false; + R.Cpu.NonMaskableInterrupt = false; + + if (((R.Port05 & 0x38) == 0x38) && _cableconnected) + { + R.Port05 &= 0xFD; + + if ((L.Port05 & 0x38) == 0x38) + { + L.Port05 &= 0xFE; + } + } + } + + if (L_NMI_CD > 0) + { + L_NMI_CD--; + if (L_NMI_CD == 0) + { + L.Cpu.NonMaskableInterrupt = true; + } + } + + if (R_NMI_CD > 0) + { + R_NMI_CD--; + if (R_NMI_CD == 0) + { + R.Cpu.NonMaskableInterrupt = true; + } + } + + 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..920fa985f6 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IStatable.cs @@ -0,0 +1,67 @@ +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); + ser.Sync(nameof(L_NMI_CD), ref L_NMI_CD); + ser.Sync(nameof(L_NMI_CD), ref R_NMI_CD); + _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 d3fbefd440..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 } } + // 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,52 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem if (IsGame3D && Settings.Fix3D) { - Vdp.ExecFrame((Frame & 1) == 0); - } - else - { - Vdp.ExecFrame(render); + 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(); + } } - PSG.EndFrame(Cpu.TotalExecutedCycles); if (_lagged) { _lagCount++; @@ -90,7 +131,33 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem return true; } - public int Frame => _frame; + // 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++; + _isLag = true; + } + else + { + _isLag = false; + } + } + + public int Frame => _frame; public string SystemId => "SMS"; @@ -107,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..1ba1712d05 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,43 @@ 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(Port03), ref Port03); + ser.Sync(nameof(Port04), ref Port04); + 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(p3_write), ref p3_write); + ser.Sync(nameof(p4_read), ref p4_read); + 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 9872272391..941851b72d 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,35 +212,43 @@ 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; private int _frame = 0; private byte Port01 = 0xFF; - private byte Port02 = 0xFF; - private byte Port05 = 0x00; + public byte Port02 = 0xFF; + public byte Port03 = 0x00; + public byte Port04 = 0xFF; + public byte Port05 = 0x00; private byte Port3E = 0xAF; private byte Port3F = 0xFF; private byte PortDE = 0x00; @@ -249,10 +256,18 @@ 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 bool p3_write; + public bool p4_read; + public DisplayType Region { get; set; } - - private ITraceable Tracer { get; set; } + private readonly ITraceable Tracer; string DetermineRegion(string gameRegion) { @@ -281,7 +296,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem return DisplayType.NTSC; } - private byte ReadMemory(ushort addr) + public byte ReadMemory(ushort addr) { uint flags = (uint)(MemoryCallbackFlags.AccessRead); MemoryCallbacks.CallMemoryCallbacks(addr, 0, flags, "System Bus"); @@ -289,7 +304,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem return ReadMemoryMapper(addr); } - private void WriteMemory(ushort addr, byte value) + public void WriteMemory(ushort addr, byte value) { WriteMemoryMapper(addr, value); @@ -297,7 +312,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem MemoryCallbacks.CallMemoryCallbacks(addr, value, flags, "System Bus"); } - private byte FetchMemory(ushort addr) + public byte FetchMemory(ushort addr) { return ReadMemoryMapper(addr); } @@ -334,11 +349,11 @@ 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; - case 0x04: return 0xFF; + case 0x03: return Port03; + case 0x04: p4_read = true; return Port04; case 0x05: return Port05; case 0x06: return 0xFF; case 0x3E: return Port3E; @@ -362,9 +377,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; @@ -380,14 +395,16 @@ 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 0x03: p3_write = true; Port03 = value; break; + case 0x04: /*Port04 = value*/; break; // receive port, not sure what writing does + case 0x05: Port05 = (byte)(value & 0xF8); 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) @@ -401,8 +418,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 475d1562fc..35caf3331c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs @@ -51,7 +51,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx 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++; 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/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 6e7041d8c7..30f3bd3cac 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -840,7 +840,7 @@ 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); } @@ -1078,7 +1078,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; @@ -1101,7 +1101,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; @@ -1136,7 +1136,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); @@ -1166,7 +1166,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 b64d3bc70f..8ef12ba934 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(); 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/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/OneBitBeeper.cs b/BizHawk.Emulation.Cores/Sound/OneBitBeeper.cs new file mode 100644 index 0000000000..9ab9e3e05b --- /dev/null +++ b/BizHawk.Emulation.Cores/Sound/OneBitBeeper.cs @@ -0,0 +1,194 @@ +using System; +using BizHawk.Common; +using BizHawk.Emulation.Common; + +namespace BizHawk.Emulation.Cores.Sound +{ + /// + /// A simple 1-bit (mono) beeper/buzzer implementation using blipbuffer + /// Simulating the piezzo-electric buzzer found in many old computers (such as the ZX Spectrum or Amstrad CPC) + /// Sound is generated by toggling the single input line ON and OFF rapidly + /// + public sealed class OneBitBeeper : ISoundProvider + { + private int _sampleRate; + private int _clocksPerFrame; + private int _framesPerSecond; + private BlipBuffer _blip; + private readonly string _beeperId; + + /// + /// Constructor + /// + /// The sample rate to pass to blipbuffer (this should be 44100 for ISoundProvider) + /// The number of (usually CPU) clocked cycles in one frame + /// The number of frames per second (usually either 60 or 50) + /// Unique name for this instance (needed for serialization as some cores have more than one active instance of the beeper) + public OneBitBeeper(int blipSampleRate, int clocksPerFrame, int framesPerSecond, string beeperId) + { + _beeperId = beeperId; + _sampleRate = blipSampleRate; + _clocksPerFrame = clocksPerFrame; + _framesPerSecond = framesPerSecond; + _blip = new BlipBuffer(blipSampleRate / framesPerSecond); + _blip.SetRates(clocksPerFrame * 50, blipSampleRate); + } + + private int clockCounter; + + /// + /// Option to clock the beeper every CPU clock + /// + public void Clock(int clocksToAdd = 1) + { + clockCounter += clocksToAdd; + } + + /// + /// Option to directly set the current clock position within the frame + /// + public void SetClock(int currentFrameClock) + { + clockCounter = currentFrameClock; + } + + private bool lastPulse; + + /// + /// Processes an incoming pulse value + /// + /// + public void ProcessPulseValue(bool pulse, bool renderSound = true) + { + if (!renderSound) + return; + + if (lastPulse == pulse) + { + // no change + _blip.AddDelta((uint)clockCounter, 0); + } + + else + { + if (pulse) + _blip.AddDelta((uint)clockCounter, (short)(_volume)); + else + _blip.AddDelta((uint)clockCounter, -(short)(_volume)); + + lastVolume = _volume; + } + + lastPulse = pulse; + } + + #region Volume Handling + + /// + /// Beeper volume + /// Accepts an int 0-100 value + /// + public int Volume + { + get { return VolumeConverterOut(_volume); } + set + { + var newVol = VolumeConverterIn(value); + if (newVol != _volume) + _blip.Clear(); + _volume = VolumeConverterIn(value); + } + } + private int _volume; + + /// + /// The last used volume (used to modify blipbuffer delta values) + /// + private int lastVolume; + + + /// + /// Takes an int 0-100 and returns the relevant short volume to output + /// + /// + /// + private int VolumeConverterIn(int vol) + { + int maxLimit = short.MaxValue / 3; + int increment = maxLimit / 100; + + return vol * increment; + } + + /// + /// Takes an short volume and returns the relevant int value 0-100 + /// + /// + /// + private int VolumeConverterOut(int shortvol) + { + int maxLimit = short.MaxValue / 3; + int increment = maxLimit / 100; + + if (shortvol > maxLimit) + shortvol = maxLimit; + + return shortvol / increment; + } + + #endregion + + #region ISoundProvider + + public bool CanProvideAsync => false; + + public SyncSoundMode SyncMode => SyncSoundMode.Sync; + + public void SetSyncMode(SyncSoundMode mode) + { + if (mode != SyncSoundMode.Sync) + throw new InvalidOperationException("Only Sync mode is supported."); + } + + public void GetSamplesAsync(short[] samples) + { + throw new NotSupportedException("Async is not available"); + } + + public void DiscardSamples() + { + _blip.Clear(); + } + + public void GetSamplesSync(out short[] samples, out int nsamp) + { + _blip.EndFrame((uint)_clocksPerFrame); + nsamp = _blip.SamplesAvailable(); + samples = new short[nsamp * 2]; + _blip.ReadSamples(samples, nsamp, true); + for (int i = 0; i < nsamp * 2; i += 2) + { + samples[i + 1] = samples[i]; + } + + clockCounter = 0; + } + + #endregion + + #region State Serialization + + public void SyncState(Serializer ser) + { + ser.BeginSection("Beeper_" + _beeperId); + ser.Sync(nameof(_sampleRate), ref _sampleRate); + ser.Sync(nameof(_clocksPerFrame), ref _clocksPerFrame); + ser.Sync(nameof(_framesPerSecond), ref _framesPerSecond); + ser.Sync(nameof(clockCounter), ref clockCounter); + ser.Sync(nameof(lastPulse), ref lastPulse); + ser.EndSection(); + } + + #endregion + } +} 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/SyncSoundMixer.cs b/BizHawk.Emulation.Cores/Sound/SyncSoundMixer.cs new file mode 100644 index 0000000000..2052546040 --- /dev/null +++ b/BizHawk.Emulation.Cores/Sound/SyncSoundMixer.cs @@ -0,0 +1,340 @@ +using BizHawk.Emulation.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using BizHawk.Common; + +namespace BizHawk.Emulation.Cores.Components +{ + /// + /// ISoundProvider mixer that generates a single ISoundProvider output from multiple ISoundProvider sources + /// Currently only supports sync (not async) + /// + /// Bizhawk expects ISoundProviders to output at 44100KHz, so this is what SyncSoundMixer does. Therefore, try to make + /// sure that your child ISoundProviders also do this I guess. + /// + /// This is currently used in the ZX Spectrum and CPC cores but others may find it useful in future + /// + public sealed class SyncSoundMixer : ISoundProvider + { + /// + /// Currently attached ChildProviders + /// + private readonly List _soundProviders = new List(); + + /// + /// The final output max volume + /// + public short FinalMaxVolume + { + get { return _finalMaxVolume; } + set + { + _finalMaxVolume = value; + EqualizeVolumes(); + } + } + private short _finalMaxVolume; + + /// + /// How the sound sources are balanced against each other + /// + public SoundMixBalance MixBalanceMethod + { + get { return _mixBalanceMethod; } + set + { + _mixBalanceMethod = value; + EqualizeVolumes(); + } + } + private SoundMixBalance _mixBalanceMethod; + + /// + /// If specified the output buffer of the SyncSoundMixer will always contain this many samples + /// You should probably nearly always specify a value for this and get your ISoundProvider sources + /// to get as close to this nsamp value as possible. Otherwise the number of samples will + /// be based on the highest nsamp out of all the child providers for that specific frame + /// Useful examples: + /// 882 - 44100KHz - 50Hz + /// 735 - 44100Khz - 60Hz + /// + private int? _targetSampleCount; + + /// + /// Constructor + /// + /// Whether each providers MaxVolume is reduced to an equal share of the final max volume value + /// The final 'master' max volume + /// + /// If specified the output buffer of the SyncSoundMixer will always contain this many samples + /// If left null the output buffer will contain the highest number of samples out of each of the providers every frame + /// + public SyncSoundMixer(SoundMixBalance mixBalanceMethod = SoundMixBalance.Equalize, short maxVolume = short.MaxValue, int? targetSampleCount = null) + { + _mixBalanceMethod = mixBalanceMethod; + _finalMaxVolume = maxVolume; + _targetSampleCount = targetSampleCount; + } + + /// + /// Adds an ISoundProvider to the SyncSoundMixer + /// + /// The source ISoundProvider + /// An ident string for the ISoundProvider (useful when debugging) + /// If this is true then only half the samples should be present + public void PinSource(ISoundProvider source, string sourceDescription) + { + PinSource(source, sourceDescription, FinalMaxVolume); + } + + /// + /// Adds an ISoundProvider to the SyncSoundMixer + /// + /// The source ISoundProvider + /// An ident string for the ISoundProvider (useful when debugging) + /// The MaxVolume level for this particular ISoundProvider + /// If this is true then only half the samples should be present + public void PinSource(ISoundProvider source, string sourceDescription, short sourceMaxVolume) + { + _soundProviders.Add(new ChildProvider + { + SoundProvider = source, + ProviderDescription = sourceDescription, + MaxVolume = sourceMaxVolume + }); + + EqualizeVolumes(); + } + + /// + /// Removes an existing ISoundProvider from the SyncSoundMixer + /// + /// + public void UnPinSource(ISoundProvider source) + { + var sp = _soundProviders.Where(a => a.SoundProvider == source); + + if (sp.Count() == 1) + { + _soundProviders.Remove(sp.First()); + } + else if (sp.Count() > 1) + { + foreach (var s in sp) + { + _soundProviders.Remove(s); + } + } + + EqualizeVolumes(); + } + + /// + /// Sets each pinned sound provider's MaxVolume based on the MixBalanceMethod + /// + public void EqualizeVolumes() + { + if (_soundProviders.Count < 1) + return; + + switch (MixBalanceMethod) + { + case SoundMixBalance.Equalize: + var eachVolume = FinalMaxVolume / _soundProviders.Count; + foreach (var source in _soundProviders) + { + source.MaxVolume = eachVolume; + } + break; + case SoundMixBalance.MasterHardLimit: + foreach (var source in _soundProviders) + { + if (source.MaxVolume > FinalMaxVolume) + { + source.MaxVolume = FinalMaxVolume; + } + } + break; + } + } + + /// + /// Returns the value of the highest nsamp in the SoundProviders collection + /// + /// + private int GetHigestSampleCount() + { + var lookup = _soundProviders.OrderByDescending(x => x.InputNSamp) + .FirstOrDefault(); + + if (lookup == null) + { + return 0; + } + + return lookup.InputNSamp; + } + + #region ISoundProvider + + public bool CanProvideAsync => false; + public SyncSoundMode SyncMode => SyncSoundMode.Sync; + + public void SetSyncMode(SyncSoundMode mode) + { + if (mode != SyncSoundMode.Sync) + throw new InvalidOperationException("Only Sync mode is supported."); + } + + public void GetSamplesAsync(short[] samples) + { + throw new NotSupportedException("Async is not available"); + } + + public void DiscardSamples() + { + foreach (var soundSource in _soundProviders) + { + soundSource.SoundProvider.DiscardSamples(); + } + } + + public void GetSamplesSync(out short[] samples, out int nsamp) + { + // fetch samples from all the providers + foreach (var sp in _soundProviders) + { + sp.GetSamples(); + } + + nsamp = _targetSampleCount ?? GetHigestSampleCount(); + samples = new short[nsamp * 2]; + + // process the output buffers + foreach (var sp in _soundProviders) + { + sp.PrepareOutput(nsamp); + } + + // mix the child providers together + for (int i = 0; i < samples.Length; i++) + { + int sampleVal = 0; + foreach (var sp in _soundProviders) + { + if (sp.OutputBuffer[i] > sp.MaxVolume) + { + sampleVal += (short)sp.MaxVolume; + } + else + { + sampleVal += sp.OutputBuffer[i]; + } + } + + // final hard limit + if (sampleVal > (int)FinalMaxVolume) + { + sampleVal = (int)FinalMaxVolume; + } + + samples[i] = (short)sampleVal; + } + } + + #endregion + + /// + /// Instantiated for every ISoundProvider source that is added to the mixer + /// + private class ChildProvider + { + /// + /// The Child ISoundProvider + /// + public ISoundProvider SoundProvider; + + /// + /// Identification string + /// + public string ProviderDescription; + + /// + /// The max volume for this provider + /// + public int MaxVolume; + + /// + /// Stores the incoming samples + /// + public short[] InputBuffer; + + /// + /// The incoming number of samples + /// + public int InputNSamp; + + /// + /// Stores the processed samples ready for mixing + /// + public short[] OutputBuffer; + + /// + /// The output number of samples + /// + public int OutputNSamp; + + /// + /// Fetches sample data from the child ISoundProvider + /// + public void GetSamples() + { + SoundProvider.GetSamplesSync(out InputBuffer, out InputNSamp); + } + + /// + /// Ensures the output buffer is ready for mixing based on the supplied nsamp value + /// Overflow samples will be omitted and underflow samples will be empty air + /// + /// + public void PrepareOutput(int nsamp) + { + OutputNSamp = nsamp; + var outputBuffSize = OutputNSamp * 2; + + if (OutputNSamp != InputNSamp || InputBuffer.Length != outputBuffSize) + { + OutputBuffer = new short[outputBuffSize]; + + var i = 0; + while (i < InputBuffer.Length && i < outputBuffSize) + { + OutputBuffer[i] = InputBuffer[i]; + i++; + } + } + else + { + // buffer needs no modification + OutputBuffer = InputBuffer; + } + } + } + } + + /// + /// Defines how mixed sound sources should be balanced + /// + public enum SoundMixBalance + { + /// + /// Each sound source's max volume will be set to MaxVolume / nSources + /// + Equalize, + /// + /// Each sound source's individual max volume will be respected but the final MaxVolume will be limited to MaxVolume + /// + MasterHardLimit + } +} 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..2698714e69 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(); @@ -139,23 +139,23 @@ namespace BizHawk.Emulation.Common.Components */ new byte[] { - // http://forums.nesdev.com/viewtopic.php?f=6&t=9141 + // March 15, 2019 dumped by Nuke.YKT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x21, 0x05, 0x06, 0xB8, 0x82, 0x42, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x13, 0x41, 0x13, 0x0D, 0xD8, 0xD6, 0x23, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x31, 0x11, 0x08, 0x08, 0xFA, 0x9A, 0x22, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x31, 0x61, 0x18, 0x07, 0x78, 0x64, 0x30, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x22, 0x21, 0x1E, 0x06, 0xF0, 0x76, 0x08, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x01, 0x06, 0x00, 0xF0, 0xF2, 0x03, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x21, 0x61, 0x1D, 0x07, 0x82, 0x81, 0x16, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x23, 0x21, 0x1A, 0x17, 0xCF, 0x72, 0x25, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x15, 0x11, 0x25, 0x00, 0x4F, 0x71, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x85, 0x01, 0x12, 0x0F, 0x99, 0xA2, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x07, 0xC1, 0x69, 0x07, 0xF3, 0xF5, 0xA7, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x71, 0x23, 0x0D, 0x06, 0x66, 0x75, 0x23, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x02, 0xD3, 0x05, 0xA3, 0x92, 0xF7, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x61, 0x63, 0x0C, 0x00, 0x94, 0xAF, 0x34, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x21, 0x62, 0x0D, 0x00, 0xB1, 0xA0, 0x54, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x21, 0x05, 0x06, 0xE8, 0x81, 0x42, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x13, 0x41, 0x14, 0x0D, 0xD8, 0xF6, 0x23, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x11, 0x08, 0x08, 0xFA, 0xB2, 0x20, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x31, 0x61, 0x0C, 0x07, 0xA8, 0x64, 0x61, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x32, 0x21, 0x1E, 0x06, 0xE1, 0x76, 0x01, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x01, 0x06, 0x00, 0xA3, 0xE2, 0xF4, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x21, 0x61, 0x1D, 0x07, 0x82, 0x81, 0x11, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x21, 0x22, 0x17, 0xA2, 0x72, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x35, 0x11, 0x25, 0x00, 0x40, 0x73, 0x72, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xB5, 0x01, 0x0F, 0x0F, 0xA8, 0xA5, 0x51, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x17, 0xC1, 0x24, 0x07, 0xF8, 0xF8, 0x22, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x71, 0x23, 0x11, 0x06, 0x65, 0x74, 0x18, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x02, 0xD3, 0x05, 0xC9, 0x95, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x61, 0x63, 0x0C, 0x00, 0x94, 0xC0, 0x33, 0xF6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x21, 0x72, 0x0D, 0x00, 0xC1, 0xD5, 0x56, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 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.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 2b1a0659ef..53559fc6dc 100644 --- a/BizHawk.sln +++ b/BizHawk.sln @@ -145,7 +145,7 @@ Global {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA} = {B51F1139-3D2C-41BE-A762-EF1F9B41EACA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1A77376C-2741-489C-90E1-03E415910B65} + SolutionGuid = {9B9E4316-9185-412E-B951-A63355ACA956} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = BizHawk.Client.EmuHawk\BizHawk.Client.EmuHawk.csproj diff --git a/Bizware/BizHawk.Bizware.BizwareGL.GdiPlus/GdiPlusGuiRenderer.cs b/Bizware/BizHawk.Bizware.BizwareGL.GdiPlus/GdiPlusGuiRenderer.cs index c1ee8d0644..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) diff --git a/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs b/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs index 7a8f02bc9d..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; @@ -860,7 +860,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK _rsBlendNormal = new CacheBlendState( true, BlendingFactorSrc.SrcAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.OneMinusSrcAlpha, - BlendingFactorSrc.One, BlendEquationMode.Max, BlendingFactorDest.One); + BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero); } CacheBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal; diff --git a/Bizware/BizHawk.Bizware.BizwareGL.SlimDX/IGL_SlimDX9.cs b/Bizware/BizHawk.Bizware.BizwareGL.SlimDX/IGL_SlimDX9.cs index 5d97323759..912d9ba634 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); @@ -368,7 +368,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX _rsBlendNormal = new CacheBlendState( true, gl.BlendingFactorSrc.SrcAlpha, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.OneMinusSrcAlpha, - gl.BlendingFactorSrc.One, gl.BlendEquationMode.Max, gl.BlendingFactorDest.One); + gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero); } CacheBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal; @@ -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]; } @@ -520,6 +520,10 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX { var pw = pipeline.Opaque as PipelineWrapper; + //unavailable pipelines will have no opaque + if (pw == null) + return; + pw.VertexDeclaration.Dispose(); pw.FragmentShader.IGLShader.Release(); pw.VertexShader.IGLShader.Release(); 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 6bfb577f7b..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) { @@ -287,7 +287,7 @@ namespace BizHawk.Bizware.BizwareGL /// public void DiscardAlpha() { - //HasAlpha = false; + HasAlpha = false; } void LoadInternal(Stream stream, sd.Bitmap bitmap, BitmapLoadOptions options) 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 d4b25aac90..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; } 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/Dist/BuildDebug.sh b/Dist/BuildDebug.sh new file mode 100755 index 0000000000..388cc5536d --- /dev/null +++ b/Dist/BuildDebug.sh @@ -0,0 +1,2 @@ +#!/bin/sh +cd "$(dirname "$0")/.." && msbuild /p:Configuration=Debug BizHawk.sln diff --git a/Dist/BuildRelease.sh b/Dist/BuildRelease.sh new file mode 100755 index 0000000000..203546a22c --- /dev/null +++ b/Dist/BuildRelease.sh @@ -0,0 +1,2 @@ +#!/bin/sh +cd "$(dirname "$0")/.." && msbuild /p:Configuration=Release BizHawk.sln diff --git a/Dist/HelloWorld_BizHawkTool.dll b/Dist/HelloWorld_BizHawkTool.dll index 9aea3925c6..0f48d06611 100644 Binary files a/Dist/HelloWorld_BizHawkTool.dll and b/Dist/HelloWorld_BizHawkTool.dll differ diff --git a/Dist/HelloWorld_BizHawkTool.zip b/Dist/HelloWorld_BizHawkTool.zip new file mode 100644 index 0000000000..0332bfd973 Binary files /dev/null and b/Dist/HelloWorld_BizHawkTool.zip differ diff --git a/ExternalCoreProjects/Virtu/.vs/Virtu/v15/Server/sqlite3/db.lock b/ExternalCoreProjects/Virtu/.vs/Virtu/v15/Server/sqlite3/db.lock new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ExternalCoreProjects/Virtu/.vs/Virtu/v15/Server/sqlite3/storage.ide b/ExternalCoreProjects/Virtu/.vs/Virtu/v15/Server/sqlite3/storage.ide new file mode 100644 index 0000000000..9f73c3360a Binary files /dev/null and b/ExternalCoreProjects/Virtu/.vs/Virtu/v15/Server/sqlite3/storage.ide differ diff --git a/ExternalCoreProjects/Virtu/.vs/Virtu/v15/Server/sqlite3/storage.ide-shm b/ExternalCoreProjects/Virtu/.vs/Virtu/v15/Server/sqlite3/storage.ide-shm new file mode 100644 index 0000000000..fe9ac2845e Binary files /dev/null and b/ExternalCoreProjects/Virtu/.vs/Virtu/v15/Server/sqlite3/storage.ide-shm differ diff --git a/ExternalCoreProjects/Virtu/.vs/Virtu/v15/Server/sqlite3/storage.ide-wal b/ExternalCoreProjects/Virtu/.vs/Virtu/v15/Server/sqlite3/storage.ide-wal new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ExternalCoreProjects/Virtu/GamePort.cs b/ExternalCoreProjects/Virtu/GamePort.cs index a562f35da7..0f78c4d50d 100644 --- a/ExternalCoreProjects/Virtu/GamePort.cs +++ b/ExternalCoreProjects/Virtu/GamePort.cs @@ -9,8 +9,8 @@ namespace Jellyfish.Virtu public sealed class GamePort : MachineComponent { // TODO: ressurect this - public bool ReadButton0() { return false; } - public bool ReadButton1() { return false; } + public bool ReadButton0() { return Keyboard.WhiteAppleDown; } + public bool ReadButton1() { return Keyboard.BlackAppleDown; } public bool ReadButton2() { return false; } public bool Paddle0Strobe { get { return false; } } diff --git a/ExternalCoreProjects/Virtu/Keyboard.cs b/ExternalCoreProjects/Virtu/Keyboard.cs index 650eb14aff..e598b881a7 100644 --- a/ExternalCoreProjects/Virtu/Keyboard.cs +++ b/ExternalCoreProjects/Virtu/Keyboard.cs @@ -264,6 +264,9 @@ namespace Jellyfish.Virtu { } + public static bool WhiteAppleDown; + public static bool BlackAppleDown; + /// /// Call this at 60hz with all of the currently pressed keys /// @@ -272,8 +275,15 @@ namespace Jellyfish.Virtu { Keys keys = FromStrings(keynames); - if (keys.HasFlag(Keys.WhiteApple)) { } // TODO: set GAME1 - if (keys.HasFlag(Keys.BlackApple)) { } // TODO: set GAME2 + if (keys.HasFlag(Keys.WhiteApple)) + WhiteAppleDown = true; + else + WhiteAppleDown = false; + + if (keys.HasFlag(Keys.BlackApple)) + BlackAppleDown = true; + else + BlackAppleDown = false; if (keys.HasFlag(Keys.Reset) && keys.HasFlag(Keys.Control)) { } // TODO: reset console diff --git a/ExternalCoreProjects/Virtu/Virtu.csproj b/ExternalCoreProjects/Virtu/Virtu.csproj index ad68f03108..e3e9fc67b1 100644 --- a/ExternalCoreProjects/Virtu/Virtu.csproj +++ b/ExternalCoreProjects/Virtu/Virtu.csproj @@ -74,7 +74,7 @@ - copy /y $(TargetDir)$(TargetFileName) $(ProjectDir)..\..\references\$(TargetFileName) + copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\references\$(TargetFileName)"