Skip to content

Commit b55a175

Browse files
committed
Merge remote-tracking branch 'refs/remotes/TASVideos/master' into NewrRelease
Conflicts: Version/VersionInfo.cs
2 parents 8f12352 + 1ee56ea commit b55a175

30 files changed

+679
-216
lines changed

BizHawk.Client.Common/RomLoader.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ public bool LoadRom(string path, CoreComm nextComm, bool forceAccurateCore = fal
672672
nextEmulator = new Atari7800(nextComm, game, rom.RomData, gamedbpath);
673673
break;
674674
case "C64":
675-
var c64 = new C64(nextComm, game, rom.RomData, rom.Extension);
675+
var c64 = new C64(nextComm, game, rom.RomData, rom.Extension, GetCoreSettings<C64>(), GetCoreSyncSettings<C64>());
676676
nextEmulator = c64;
677677
break;
678678
case "GBA":

BizHawk.Client.Common/movie/PlatformFrameRates.cs

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ public class PlatformFrameRates
88
// these are political numbers, designed to be in accord with tasvideos.org tradition. theyre not necessarily mathematical factualities (although they may be in some cases)
99
// it would be nice if we could turn this into a rational expression natively, and also, to write some comments about the derivation and ideal valees (since this seems to be where theyre all collected)
1010
// are we collecting them anywhere else? for avi-writing code perhaps?
11+
12+
// just some constants, according to specs
13+
private static readonly double PAL_CARRIER = 15625 * 283.75 + 25; // 4.43361875 MHz
14+
private static readonly double NTSC_CARRIER = 4500000 * 227.5 / 286; // 3.579545454... MHz
15+
private static readonly double PAL_N_CARRIER = 15625 * 229.25 + 25; // 3.58205625 MHz
16+
1117
private static readonly Dictionary<string, double> _rates = new Dictionary<string, double>
1218
{
1319
{ "NES", 60.098813897440515532 }, // discussion here: http://forums.nesdev.com/viewtopic.php?t=492 ; a rational expression would be (19687500 / 11) / ((341*262-0.529780.5)/3) -> (118125000 / 1965513) -> 60.098813897440515529533511098629 (so our chosen number is very close)
@@ -48,6 +54,11 @@ public class PlatformFrameRates
4854
{"PSX", 44100.0*768*11/7/263/3413}, //59.292862562
4955
{"PSX_PAL", 44100.0*768*11/7/314/3406}, //49.7645593576
5056

57+
{"C64_PAL", PAL_CARRIER*2/9/312/63},
58+
{"C64_NTSC", NTSC_CARRIER*2/7/263/65},
59+
{"C64_NTSC_OLD", NTSC_CARRIER*2/7/262/64},
60+
{"C64_DREAN", PAL_N_CARRIER*2/7/312/65},
61+
5162
//according to ryphecha, using
5263
//clocks[2] = { 53.693182e06, 53.203425e06 }; //ntsc console, pal console
5364
//lpf[2][2] = { { 263, 262.5 }, { 314, 312.5 } }; //ntsc,pal; noninterlaced, interlaced

BizHawk.Client.EmuHawk/MainForm.Designer.cs

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BizHawk.Client.EmuHawk/MainForm.Events.cs

+9
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,15 @@ private void AppleDisksSubMenu_DropDownOpened(object sender, EventArgs e)
20632063

20642064
#endregion
20652065

2066+
#region C64
2067+
2068+
private void C64SettingsMenuItem_Click(object sender, EventArgs e)
2069+
{
2070+
GenericCoreConfig.DoDialog(this, "C64 Settings");
2071+
}
2072+
2073+
#endregion
2074+
20662075
#region Help
20672076

20682077
private void OnlineHelpMenuItem_Click(object sender, EventArgs e)

BizHawk.Client.EmuHawk/MainForm.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,7 @@ private void HandlePlatformMenus()
15951595
GenesisSubMenu.Visible = false;
15961596
wonderSwanToolStripMenuItem.Visible = false;
15971597
AppleSubMenu.Visible = false;
1598+
C64SubMenu.Visible = false;
15981599

15991600
switch (system)
16001601
{
@@ -1675,6 +1676,9 @@ private void HandlePlatformMenus()
16751676
case "AppleII":
16761677
AppleSubMenu.Visible = true;
16771678
break;
1679+
case "C64":
1680+
C64SubMenu.Visible = true;
1681+
break;
16781682
}
16791683
}
16801684

@@ -1965,7 +1969,7 @@ public static string RomFilter
19651969
if (VersionInfo.DeveloperBuild)
19661970
{
19671971
return FormatFilter(
1968-
"Rom Files", "*.nes;*.fds;*unf;*.sms;*.gg;*.sg;*.pce;*.sgx;*.bin;*.smd;*.rom;*.a26;*.a78;*.lnx;*.m3u;*.cue;*.ccd;*.exe;*.gb;*.gbc;*.gba;*.gen;*.md;*.col;.int;*.smc;*.sfc;*.prg;*.d64;*.g64;*.crt;*.sgb;*.xml;*.z64;*.v64;*.n64;*.ws;*.wsc;*.dsk;*.do;*.po;*.psf;*.minipsf;*.nsf;%ARCH%",
1972+
"Rom Files", "*.nes;*.fds;*unf;*.sms;*.gg;*.sg;*.pce;*.sgx;*.bin;*.smd;*.rom;*.a26;*.a78;*.lnx;*.m3u;*.cue;*.ccd;*.exe;*.gb;*.gbc;*.gba;*.gen;*.md;*.col;.int;*.smc;*.sfc;*.prg;*.d64;*.g64;*.crt;*.tap;*.sgb;*.xml;*.z64;*.v64;*.n64;*.ws;*.wsc;*.dsk;*.do;*.po;*.psf;*.minipsf;*.nsf;%ARCH%",
19691973
"Music Files", "*.psf;*.minipsf;*.sid;*.nsf",
19701974
"Disc Images", "*.cue;*.ccd;*.m3u",
19711975
"NES", "*.nes;*.fds;*.unf;*.nsf;%ARCH%",
@@ -1986,7 +1990,7 @@ public static string RomFilter
19861990
"PlayStation", "*.cue;*.ccd;*.m3u",
19871991
"PSX Executables (experimental)", "*.exe",
19881992
"PSF Playstation Sound File", "*.psf;*.minipsf",
1989-
"Commodore 64 (experimental)", "*.prg; *.d64, *.g64; *.crt;%ARCH%",
1993+
"Commodore 64 (experimental)", "*.prg; *.d64, *.g64; *.crt; *.tap;%ARCH%",
19901994
"SID Commodore 64 Music File", "*.sid;%ARCH%",
19911995
"Nintendo 64", "*.z64;*.v64;*.n64",
19921996
"WonderSwan", "*.ws;*.wsc;%ARCH%",

BizHawk.Client.EmuHawk/config/GenericCoreConfig.Designer.cs

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ private void SaveMenuItem_Click(object sender, EventArgs e)
10241024
if (result)
10251025
{
10261026
MessageLabel.Text = Path.GetFileName(_currentFileName) + " saved";
1027-
Global.Config.RecentWatches.Add(watches.CurrentFileName);
1027+
Settings.RecentSearches.Add(watches.CurrentFileName);
10281028
}
10291029
}
10301030
}

BizHawk.Emulation.Common/Database/Database.cs

+1
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ public static GameInfo GetGameInfo(byte[] romData, string fileName)
315315
case ".T64":
316316
case ".G64":
317317
case ".CRT":
318+
case ".TAP":
318319
game.System = "C64";
319320
break;
320321

BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj

+6-2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
<Compile Include="Computers\Commodore64\C64.IDebuggable.cs">
152152
<DependentUpon>C64.cs</DependentUpon>
153153
</Compile>
154+
<Compile Include="Computers\Commodore64\C64.IDisassemblable.cs" />
154155
<Compile Include="Computers\Commodore64\C64.IDriveLight.cs">
155156
<DependentUpon>C64.cs</DependentUpon>
156157
</Compile>
@@ -160,6 +161,7 @@
160161
<Compile Include="Computers\Commodore64\C64.IMemoryDomains.cs">
161162
<DependentUpon>C64.cs</DependentUpon>
162163
</Compile>
164+
<Compile Include="Computers\Commodore64\C64.ISettable.cs" />
163165
<Compile Include="Computers\Commodore64\C64.IStatable.cs">
164166
<DependentUpon>C64.cs</DependentUpon>
165167
</Compile>
@@ -176,14 +178,15 @@
176178
<Compile Include="Computers\Commodore64\Cartridge\Mapper0013.cs" />
177179
<Compile Include="Computers\Commodore64\Cartridge\Mapper0020.cs" />
178180
<Compile Include="Computers\Commodore64\CassettePort\CassettePortDevice.cs" />
181+
<Compile Include="Computers\Commodore64\CassettePort\Tape.cs" />
179182
<Compile Include="Computers\Commodore64\InputFileInfo.cs" />
180183
<Compile Include="Computers\Commodore64\Media\PRG.cs" />
181184
<Compile Include="Computers\Commodore64\Cartridge\Cart.cs" />
182185
<Compile Include="Computers\Commodore64\MOS\CartridgePort.cs" />
183-
<Compile Include="Computers\Commodore64\MOS\CassettePort.cs" />
184186
<Compile Include="Computers\Commodore64\MOS\Chip2114.cs" />
185187
<Compile Include="Computers\Commodore64\MOS\Chip23XX.cs" />
186188
<Compile Include="Computers\Commodore64\MOS\Chip4864.cs" />
189+
<Compile Include="Computers\Commodore64\MOS\MOS6567R56A.cs" />
187190
<Compile Include="Computers\Commodore64\MOS\MOS6510.cs" />
188191
<Compile Include="Computers\Commodore64\MOS\MOS6522.cs" />
189192
<Compile Include="Computers\Commodore64\Media\D64.cs" />
@@ -193,7 +196,8 @@
193196
<Compile Include="Computers\Commodore64\MOS\MOS6526-2.Interface.cs" />
194197
<Compile Include="Computers\Commodore64\MOS\MOS6526-2.PortIO.cs" />
195198
<Compile Include="Computers\Commodore64\MOS\MOS6526.cs" />
196-
<Compile Include="Computers\Commodore64\MOS\MOS6567.cs" />
199+
<Compile Include="Computers\Commodore64\MOS\MOS6567R8.cs" />
200+
<Compile Include="Computers\Commodore64\MOS\MOS6572.cs" />
197201
<Compile Include="Computers\Commodore64\MOS\MOS6581.cs" />
198202
<Compile Include="Computers\Commodore64\MOS\MOS6569.cs" />
199203
<Compile Include="Computers\Commodore64\MOS\MOSPLA.cs" />

BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs

+5
Original file line numberDiff line numberDiff line change
@@ -2931,5 +2931,10 @@ public void ExecuteOne()
29312931
if (!rdy_freeze)
29322932
mi++;
29332933
} //ExecuteOne
2934+
2935+
public bool AtInstructionStart()
2936+
{
2937+
return Microcode[opcode][mi] >= Uop.End;
2938+
}
29342939
}
29352940
}

BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs

+101-6
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,110 @@ public void SetCpuRegister(string register, int value)
5151
}
5252
}
5353

54-
public IMemoryCallbackSystem MemoryCallbacks
54+
public bool CanStep(StepType type)
5555
{
56-
[FeatureNotImplemented]
57-
get { throw new NotImplementedException(); }
56+
switch (type)
57+
{
58+
case StepType.Into:
59+
case StepType.Over:
60+
case StepType.Out:
61+
return true;
62+
default:
63+
return false;
64+
}
65+
}
66+
67+
68+
public void Step(StepType type)
69+
{
70+
switch (type)
71+
{
72+
case StepType.Into:
73+
StepInto();
74+
break;
75+
case StepType.Out:
76+
StepOut();
77+
break;
78+
case StepType.Over:
79+
StepOver();
80+
break;
81+
}
82+
}
83+
84+
private void StepInto()
85+
{
86+
while (board.cpu.AtInstructionStart())
87+
{
88+
DoCycle();
89+
}
90+
while (!board.cpu.AtInstructionStart())
91+
{
92+
DoCycle();
93+
}
5894
}
5995

60-
[FeatureNotImplemented]
61-
public void Step(StepType type) { throw new NotImplementedException(); }
96+
private void StepOver()
97+
{
98+
var instruction = board.cpu.Peek(board.cpu.PC);
99+
100+
if (instruction == JSR)
101+
{
102+
var destination = board.cpu.PC + JSRSize;
103+
while (board.cpu.PC != destination)
104+
{
105+
StepInto();
106+
}
107+
}
108+
else
109+
{
110+
StepInto();
111+
}
112+
}
113+
114+
private void StepOut()
115+
{
116+
var instr = board.cpu.Peek(board.cpu.PC);
117+
118+
JSRCount = instr == JSR ? 1 : 0;
119+
120+
var bailOutFrame = Frame + 1;
121+
122+
while (true)
123+
{
124+
StepInto();
125+
instr = board.cpu.Peek(board.cpu.PC);
126+
if (instr == JSR)
127+
{
128+
JSRCount++;
129+
}
130+
else if ((instr == RTS || instr == RTI) && JSRCount <= 0)
131+
{
132+
StepInto();
133+
JSRCount = 0;
134+
break;
135+
}
136+
else if (instr == RTS || instr == RTI)
137+
{
138+
JSRCount--;
139+
}
140+
else //Emergency Bailout Logic
141+
{
142+
if (Frame == bailOutFrame)
143+
{
144+
break;
145+
}
146+
}
147+
}
148+
}
149+
150+
private int JSRCount = 0;
151+
152+
private const byte JSR = 0x20;
153+
private const byte RTI = 0x40;
154+
private const byte RTS = 0x60;
155+
156+
private const byte JSRSize = 3;
62157

63-
public bool CanStep(StepType type) { return false; }
158+
public IMemoryCallbackSystem MemoryCallbacks { get; private set; }
64159
}
65160
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using BizHawk.Emulation.Common;
5+
6+
namespace BizHawk.Emulation.Cores.Computers.Commodore64
7+
{
8+
public partial class C64 : IDisassemblable
9+
{
10+
public string Cpu
11+
{
12+
get { return "6510"; } set { }
13+
}
14+
15+
public string PCRegisterName
16+
{
17+
get { return "PC"; }
18+
}
19+
20+
public IEnumerable<string> AvailableCpus
21+
{
22+
get { yield return "6510"; }
23+
}
24+
25+
public string Disassemble(MemoryDomain m, uint addr, out int length)
26+
{
27+
return Components.M6502.MOS6502X.Disassemble((ushort)addr, out length, (a) => m.PeekByte(a));
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)