Skip to content

Commit

Permalink
#12 Added TotalIllegalInstructions count
Browse files Browse the repository at this point in the history
  • Loading branch information
hagronnestad committed Mar 24, 2020
1 parent 4317c77 commit f081205
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
12 changes: 11 additions & 1 deletion ComputerSystems/Commodore64/FormC64Screen.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions ComputerSystems/Commodore64/FormC64Screen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public FormC64Screen(C64 c64) {

lblCycles.Text = $"{c64.Cpu.TotalCycles:N0} cycles";
lblInstructions.Text = $"{c64.Cpu.TotalInstructions:N0} instructions";
lblIllegalInstructions.Text = $"{c64.Cpu.TotalIllegalInstructions:N0} illegal instructions";
lblKeyboardDisabled.Visible = !c64.KeyboardActivated;

lblFps.Text = $"{((int)_fpsActual):D3} fps";
Expand Down Expand Up @@ -106,12 +107,17 @@ private void InvalidateScreen() {
}

public void ApplyCrtFilter() {
for (int i = 0; i < _bC64ScreenOutputBuffer.Width; i += (int)(_penScanLine2.Width * 2)) {
_gC64ScreenOutputBuffer.DrawLine(_penScanLine2, i, 0, i, _bC64ScreenOutputBuffer.Height);
var width = _bC64ScreenOutputBuffer.Width;
var height = _bC64ScreenOutputBuffer.Height;
var penWidth = (int)(_penScanLine.Width * 2);
var penWidth2 = (int)(_penScanLine2.Width * 2);

for (int i = 0; i < width; i += penWidth2) {
_gC64ScreenOutputBuffer.DrawLine(_penScanLine2, i, 0, i, height);
}

for (int i = 0; i < _bC64ScreenOutputBuffer.Height; i += (int)(_penScanLine.Width * 2)) {
_gC64ScreenOutputBuffer.DrawLine(_penScanLine, 0, i, _bC64ScreenOutputBuffer.Width, i);
for (int i = 0; i < height; i += penWidth) {
_gC64ScreenOutputBuffer.DrawLine(_penScanLine, 0, i, width, i);
}
}

Expand Down
16 changes: 8 additions & 8 deletions ComputerSystems/Commodore64/FormC64Screen.resx
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@
<data name="btnReset.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGeSURBVDhPvVI5TgNBENwHkNpr+ZJve7278n3L9qYg8QVy
XkCAjBAJAe9AIMFLOERG5gAQSAQYAkAIvBqqxmPA4COjpJHXNd3VNd2t/StCodCm+pyNQCCwFovFjtTf
CbRaLZHJZG50XTcV9Y1IJNKrVCrPjuMw6ETRE6jX626j0RDlcvn9S8Tj8SzlcrlXJo5PNBrdkZe/gCQL
sQ8QEqZpXila2naazaY7FvD5fIa6+gMlMqxWqwI92ZYk7G9QwLbtO7zTleQcxOPxAwqkUqlzzev16p1O
R3S7XcFLqK7LqDmAw2UKpNPpR9mDdrstBSimYuaCcWi4KBaLI7fo6gtd+P3+VUksAB1QAE8YSMKyrEu6
SCaTx5JYAPRsH0VFIpE4lQQWZ48CmLEbDAZtSc4A54+CH6VSSSC2p2jp4pabVigUBhyVoifAZCzZPZPx
21f0CEzK5/NDjFOgwy7sHeKtK2wY30zbKDKkdezB29RdYQXswjU3jadWq1FMHjaNlQ3D6E9N/olwOLyL
GV9ks9knVHQ5bzT4DG/eUiEKmvYJzFSJpc41lUwAAAAASUVORK5CYII=
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGdSURBVDhPvVLJTgJBFJwP8ApD2MIOw8xA2LcAc9XEX/Du
F3gwGOPFg99hNNEvcYk3bxzUaOJB9KDGKJO2qmlUlOVmJR2G6vfqVb/3tH9FKBTaVJ+zEQgE1mKx2JH6
O4FWqyUymcyNruumor4RiUR6lUrl2XEcBp0oegL1et1tNBqiXC6/f4l4PJ6lXC73ysTxiUajO/LyF5Bk
5fP5BwgJ0zSvFC1tO81m0x0L+Hw+Q139AUVQcFitVgV6si1J2N+ggG3bd3inK8k5iMfjBxRIpVLnmtfr
1Tudjuh2u4KXUF2XUXMAh8sUSKfTj7IH7XZbClBMxcwF49BwUSwWR27R1Re68Pv9q5JYADqgQDKZHEjC
sqxLugBxLIkFQM/2UVQkEolTSWBx9iiAGbvBYNCW5Axw/sBHqVQSiO0pWrq45aYVCoUBR6XoCTAZS3bP
ZPz2FT2CWpIhxinQYRf2DvHWFTaMb6ZtVB7SOuLepu4KK2AXrrlpPLVajWLysGmsbBhGf2ryT4TD4V3M
+CKbzT6host5o8FnePOWClHQtE+v3YmTOGTF5AAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnPause.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down
6 changes: 6 additions & 0 deletions MicroProcessor/Cpu6502/Cpu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public class Cpu {
/// </summary>
public long TotalInstructions { get; private set; }

/// <summary>
/// The total number of executed illegal instructions.
/// </summary>
public long TotalIllegalInstructions { get; set; }

/// <summary>
/// The total number of times the CPU has been cycled.
/// </summary>
Expand Down Expand Up @@ -228,6 +233,7 @@ public void Step(bool ignoreCycles = false) {
OpCode.Run();

TotalInstructions += 1;
if (OpCode.IsIllegal) TotalIllegalInstructions++;

// Count total cycles
// This doesn't account for extra cycles caused by memory operations crossing pages
Expand Down

0 comments on commit f081205

Please sign in to comment.