mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-19 23:29:05 +00:00
42 lines
1.1 KiB
Plaintext
42 lines
1.1 KiB
Plaintext
//
|
|
// TestMachineZ80.m
|
|
// Clock Signal
|
|
//
|
|
// Created by Thomas Harte on 16/05/2017.
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
//
|
|
|
|
#import "TestMachineZ80.h"
|
|
#include "Z80AllRAM.hpp"
|
|
|
|
static CPU::Z80::Register registerForRegister(CSTestMachineZ80Register reg) {
|
|
switch (reg) {
|
|
case CSTestMachineZ80RegisterProgramCounter: return CPU::Z80::Register::ProgramCounter;
|
|
case CSTestMachineZ80RegisterStackPointer: return CPU::Z80::Register::StackPointer;
|
|
}
|
|
}
|
|
|
|
@implementation CSTestMachineZ80 {
|
|
CPU::Z80::AllRAMProcessor _processor;
|
|
}
|
|
|
|
#pragma mark - Accessors
|
|
|
|
- (void)setData:(NSData *)data atAddress:(uint16_t)startAddress {
|
|
_processor.set_data_at_address(startAddress, data.length, (const uint8_t *)data.bytes);
|
|
}
|
|
|
|
- (void)runForNumberOfCycles:(int)cycles {
|
|
_processor.run_for_cycles(cycles);
|
|
}
|
|
|
|
- (void)setValue:(uint16_t)value forRegister:(CSTestMachineZ80Register)reg {
|
|
_processor.set_value_of_register(registerForRegister(reg), value);
|
|
}
|
|
|
|
- (uint16_t)valueForRegister:(CSTestMachineZ80Register)reg {
|
|
return _processor.get_value_of_register(registerForRegister(reg));
|
|
}
|
|
|
|
@end
|