mirror of
https://github.com/Luigi30/FruitMachine-Swift.git
synced 2025-01-02 19:29:22 +00:00
adding read and write override handlers i guess?
This commit is contained in:
parent
fb950c6cec
commit
2903eac409
@ -17,6 +17,9 @@
|
||||
2AD458E31F20661300F05121 /* CPUInstructions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AD458E21F20661300F05121 /* CPUInstructions.swift */; };
|
||||
2AD458E51F2070DF00F05121 /* Opcodes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AD458E41F2070DF00F05121 /* Opcodes.swift */; };
|
||||
2AD6D5841F26E6BF008F3CF5 /* DebuggerCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AD6D5831F26E6BF008F3CF5 /* DebuggerCommands.swift */; };
|
||||
2AE42E081F2850F400C4900E /* ReadOverride.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AE42E071F2850F400C4900E /* ReadOverride.swift */; };
|
||||
2AE42E0A1F28521E00C4900E /* WriteOverride.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AE42E091F28521E00C4900E /* WriteOverride.swift */; };
|
||||
2AE42E0C1F28522D00C4900E /* MemoryOverride.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AE42E0B1F28522D00C4900E /* MemoryOverride.swift */; };
|
||||
2AE5BA041F23DE4400FAA343 /* Disassembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AE5BA031F23DE4400FAA343 /* Disassembly.swift */; };
|
||||
2AE5BA061F2469EB00FAA343 /* AddressConversions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AE5BA051F2469EB00FAA343 /* AddressConversions.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
@ -35,6 +38,9 @@
|
||||
2AD458E21F20661300F05121 /* CPUInstructions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPUInstructions.swift; sourceTree = "<group>"; };
|
||||
2AD458E41F2070DF00F05121 /* Opcodes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Opcodes.swift; sourceTree = "<group>"; };
|
||||
2AD6D5831F26E6BF008F3CF5 /* DebuggerCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebuggerCommands.swift; sourceTree = "<group>"; };
|
||||
2AE42E071F2850F400C4900E /* ReadOverride.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadOverride.swift; sourceTree = "<group>"; };
|
||||
2AE42E091F28521E00C4900E /* WriteOverride.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WriteOverride.swift; sourceTree = "<group>"; };
|
||||
2AE42E0B1F28522D00C4900E /* MemoryOverride.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoryOverride.swift; sourceTree = "<group>"; };
|
||||
2AE5BA031F23DE4400FAA343 /* Disassembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Disassembly.swift; sourceTree = "<group>"; };
|
||||
2AE5BA051F2469EB00FAA343 /* AddressConversions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressConversions.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
@ -84,17 +90,28 @@
|
||||
2AD458DD1F205F0D00F05121 /* M6502 */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2AE42E061F2850E100C4900E /* Memory */,
|
||||
2AD458DE1F205F4500F05121 /* CPU.swift */,
|
||||
2AD458E21F20661300F05121 /* CPUInstructions.swift */,
|
||||
2AE5BA031F23DE4400FAA343 /* Disassembly.swift */,
|
||||
2AD458E41F2070DF00F05121 /* Opcodes.swift */,
|
||||
2AE5BA051F2469EB00FAA343 /* AddressConversions.swift */,
|
||||
2AD458E01F2064CB00F05121 /* MemoryInterface.swift */,
|
||||
2A22EBFA1F21A7A700A36A61 /* IntegerExtensions.swift */,
|
||||
);
|
||||
path = M6502;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
2AE42E061F2850E100C4900E /* Memory */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2AD458E01F2064CB00F05121 /* MemoryInterface.swift */,
|
||||
2AE42E071F2850F400C4900E /* ReadOverride.swift */,
|
||||
2AE42E091F28521E00C4900E /* WriteOverride.swift */,
|
||||
2AE42E0B1F28522D00C4900E /* MemoryOverride.swift */,
|
||||
);
|
||||
path = Memory;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@ -168,11 +185,14 @@
|
||||
2AD458E31F20661300F05121 /* CPUInstructions.swift in Sources */,
|
||||
2AD458D01F205EB700F05121 /* DebuggerViewController.swift in Sources */,
|
||||
2AD458CE1F205EB700F05121 /* AppDelegate.swift in Sources */,
|
||||
2AE42E0C1F28522D00C4900E /* MemoryOverride.swift in Sources */,
|
||||
2A22EBFB1F21A7A700A36A61 /* IntegerExtensions.swift in Sources */,
|
||||
2AD6D5841F26E6BF008F3CF5 /* DebuggerCommands.swift in Sources */,
|
||||
2AE5BA041F23DE4400FAA343 /* Disassembly.swift in Sources */,
|
||||
2AD458E51F2070DF00F05121 /* Opcodes.swift in Sources */,
|
||||
2AE42E081F2850F400C4900E /* ReadOverride.swift in Sources */,
|
||||
2AE5BA061F2469EB00FAA343 /* AddressConversions.swift in Sources */,
|
||||
2AE42E0A1F28521E00C4900E /* WriteOverride.swift in Sources */,
|
||||
2AD458E11F2064CB00F05121 /* MemoryInterface.swift in Sources */,
|
||||
2AD458DF1F205F4500F05121 /* CPU.swift in Sources */,
|
||||
);
|
||||
|
@ -46,7 +46,7 @@ class DebuggerViewController: NSViewController {
|
||||
text_CPU_SR.stringValue = String(format:"%02X", cpuInstance.stack_pointer)
|
||||
text_CPU_Flags.stringValue = String(cpuInstance.status_register.asString())
|
||||
|
||||
disassembly = cpuInstance.disassemble(fromAddress: 0, length: 40000)
|
||||
disassembly = cpuInstance.disassemble(fromAddress: 0, length: 65535)
|
||||
highlightCurrentInstruction()
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class DebuggerViewController: NSViewController {
|
||||
cpuInstance.performReset()
|
||||
cpuInstance.program_counter = 0x400 //entry point for the test program
|
||||
updateCPUStatusFields()
|
||||
disassembly = cpuInstance.disassemble(fromAddress: 0, length: 65000)
|
||||
disassembly = cpuInstance.disassemble(fromAddress: 0, length: 65535)
|
||||
debuggerTableView.reloadData()
|
||||
|
||||
cpuInstance.breakpoints.append(0x34E8) //failing at $34FD SBC test
|
||||
|
@ -156,8 +156,7 @@ class CPU: NSObject {
|
||||
//Branches incur a 1-cycle penalty if taken plus the page boundary penalty if necessary.
|
||||
branch_was_taken = false
|
||||
|
||||
breakpoints = [UInt16]()
|
||||
|
||||
breakpoints = [UInt16]()
|
||||
}
|
||||
|
||||
func getOperandByte() -> UInt8 {
|
||||
|
@ -12,15 +12,33 @@ class MemoryInterface: NSObject {
|
||||
|
||||
fileprivate var memory: [UInt8]
|
||||
|
||||
var read_overrides: [ReadOverride]
|
||||
var write_overrides: [WriteOverride]
|
||||
|
||||
override init() {
|
||||
memory = [UInt8](repeating: 0x00, count: 65536)
|
||||
read_overrides = [ReadOverride]()
|
||||
write_overrides = [WriteOverride]()
|
||||
}
|
||||
|
||||
func readByte(offset: UInt16) -> UInt8 {
|
||||
for override in read_overrides {
|
||||
if case override.rangeStart ... override.rangeEnd = offset {
|
||||
override.action(CPU.sharedInstance, nil)
|
||||
}
|
||||
}
|
||||
|
||||
//No match.
|
||||
return memory[Int(offset)]
|
||||
}
|
||||
|
||||
func writeByte(offset: UInt16, value: UInt8) {
|
||||
for override in read_overrides {
|
||||
if case override.rangeStart ... override.rangeEnd = offset {
|
||||
override.action(CPU.sharedInstance, value)
|
||||
}
|
||||
}
|
||||
|
||||
memory[Int(offset)] = value
|
||||
}
|
||||
|
23
FruitMachine/M6502/Memory/MemoryOverride.swift
Normal file
23
FruitMachine/M6502/Memory/MemoryOverride.swift
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// MemoryOverride.swift
|
||||
// FruitMachine
|
||||
//
|
||||
// Created by Christopher Rohl on 7/26/17.
|
||||
// Copyright © 2017 Christopher Rohl. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class MemoryOverride: NSObject {
|
||||
let rangeStart: UInt16
|
||||
let rangeEnd: UInt16
|
||||
|
||||
let action: (CPU, UInt8?) -> Void
|
||||
|
||||
init(start: UInt16, end: UInt16, action: @escaping (CPU, UInt8?) -> Void) {
|
||||
rangeStart = start
|
||||
rangeEnd = end
|
||||
|
||||
self.action = action
|
||||
}
|
||||
}
|
16
FruitMachine/M6502/Memory/ReadOverride.swift
Normal file
16
FruitMachine/M6502/Memory/ReadOverride.swift
Normal file
@ -0,0 +1,16 @@
|
||||
//
|
||||
// ReadOverride.swift
|
||||
// FruitMachine
|
||||
//
|
||||
// Created by Christopher Rohl on 7/26/17.
|
||||
// Copyright © 2017 Christopher Rohl. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
/* A ReadOverride is special behavior that occurs when a memory address is read.
|
||||
Memory-mapped registers, peripherals, etc. */
|
||||
|
||||
class ReadOverride: MemoryOverride {
|
||||
|
||||
}
|
16
FruitMachine/M6502/Memory/WriteOverride.swift
Normal file
16
FruitMachine/M6502/Memory/WriteOverride.swift
Normal file
@ -0,0 +1,16 @@
|
||||
//
|
||||
// WriteOverride.swift
|
||||
// FruitMachine
|
||||
//
|
||||
// Created by Christopher Rohl on 7/26/17.
|
||||
// Copyright © 2017 Christopher Rohl. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
/* A ReadOverride is special behavior that occurs when a memory address is written.
|
||||
Memory-mapped registers, peripherals, etc. */
|
||||
|
||||
class WriteOverride: MemoryOverride {
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user