2016-06-20 00:12:47 +00:00
|
|
|
//
|
|
|
|
// MOS6532Bridge.m
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 19/06/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MOS6532Bridge.h"
|
|
|
|
#include "6532.hpp"
|
|
|
|
|
|
|
|
class VanillaRIOT: public MOS::MOS6532<VanillaRIOT> {
|
2016-06-21 01:07:01 +00:00
|
|
|
public:
|
2017-07-25 01:57:24 +00:00
|
|
|
uint8_t get_port_input(int port) {
|
2016-06-21 01:07:01 +00:00
|
|
|
return input[port];
|
|
|
|
}
|
|
|
|
uint8_t input[2];
|
2016-06-20 00:12:47 +00:00
|
|
|
};
|
|
|
|
|
2017-07-25 01:57:24 +00:00
|
|
|
@implementation MOS6532Bridge {
|
2016-06-20 00:12:47 +00:00
|
|
|
VanillaRIOT _riot;
|
|
|
|
}
|
|
|
|
|
2017-07-25 01:57:24 +00:00
|
|
|
- (void)setValue:(uint8_t)value forRegister:(NSUInteger)registerNumber {
|
2016-06-20 00:12:47 +00:00
|
|
|
_riot.set_register((int)registerNumber, value);
|
|
|
|
}
|
|
|
|
|
2017-07-25 01:57:24 +00:00
|
|
|
- (uint8_t)valueForRegister:(NSUInteger)registerNumber {
|
2016-06-20 00:12:47 +00:00
|
|
|
return _riot.get_register((int)registerNumber);
|
|
|
|
}
|
|
|
|
|
2017-07-25 01:57:24 +00:00
|
|
|
- (void)runForCycles:(NSUInteger)numberOfCycles {
|
|
|
|
_riot.run_for(Cycles((int)numberOfCycles));
|
2016-06-20 00:12:47 +00:00
|
|
|
}
|
|
|
|
|
2017-07-25 01:57:24 +00:00
|
|
|
- (BOOL)irqLine {
|
2016-06-21 01:02:42 +00:00
|
|
|
return _riot.get_inerrupt_line();
|
|
|
|
}
|
|
|
|
|
2017-07-25 01:57:24 +00:00
|
|
|
- (void)setPortAInput:(uint8_t)portAInput {
|
2016-06-21 01:07:01 +00:00
|
|
|
_riot.input[0] = _portAInput = portAInput;
|
|
|
|
}
|
|
|
|
|
2017-07-25 01:57:24 +00:00
|
|
|
- (void)setPortBInput:(uint8_t)portBInput {
|
2016-06-21 01:07:01 +00:00
|
|
|
_riot.input[1] = _portBInput = portBInput;
|
|
|
|
}
|
|
|
|
|
2016-06-20 00:12:47 +00:00
|
|
|
@end
|