mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-25 02:29:08 +00:00
Added a deliberately failing data direction test.
This commit is contained in:
parent
2282b59768
commit
eea850cd12
@ -16,6 +16,8 @@ class MOS6522Tests: XCTestCase {
|
|||||||
action(bridge)
|
action(bridge)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Timer tests
|
||||||
|
|
||||||
func testTimerCount() {
|
func testTimerCount() {
|
||||||
with6522 {
|
with6522 {
|
||||||
// set timer 1 to a value of $000a
|
// set timer 1 to a value of $000a
|
||||||
@ -90,4 +92,22 @@ class MOS6522Tests: XCTestCase {
|
|||||||
XCTAssert($0.valueForRegister(5) == 0x00, "High order byte should be 0x00; was \($0.valueForRegister(5))")
|
XCTAssert($0.valueForRegister(5) == 0x00, "High order byte should be 0x00; was \($0.valueForRegister(5))")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MARK: Data direction tests
|
||||||
|
func testDataDirection() {
|
||||||
|
with6522 {
|
||||||
|
// set low four bits of register B as output, the top four as input
|
||||||
|
$0.setValue(0x0f, forRegister: 2)
|
||||||
|
|
||||||
|
// ask to output 0x8c
|
||||||
|
$0.setValue(0x8c, forRegister: 0)
|
||||||
|
|
||||||
|
// set current input as 0xda
|
||||||
|
$0.portBInput = 0xda
|
||||||
|
|
||||||
|
// test that the result of reading register B is therefore 0x8a
|
||||||
|
XCTAssert($0.valueForRegister(0) == 0x8a, "Data direction register should mix input and output; got \($0.valueForRegister(0))")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
@interface MOS6522Bridge : NSObject
|
@interface MOS6522Bridge : NSObject
|
||||||
|
|
||||||
@property (nonatomic, readonly) BOOL irqLine;
|
@property (nonatomic, readonly) BOOL irqLine;
|
||||||
|
@property (nonatomic) uint8_t portBInput;
|
||||||
|
@property (nonatomic) uint8_t portAInput;
|
||||||
|
|
||||||
- (void)setValue:(uint8_t)value forRegister:(NSUInteger)registerNumber;
|
- (void)setValue:(uint8_t)value forRegister:(NSUInteger)registerNumber;
|
||||||
- (uint8_t)valueForRegister:(NSUInteger)registerNumber;
|
- (uint8_t)valueForRegister:(NSUInteger)registerNumber;
|
||||||
|
@ -15,11 +15,18 @@ class VanillaVIA: public MOS::MOS6522<VanillaVIA> {
|
|||||||
public:
|
public:
|
||||||
MOS6522Bridge *bridge;
|
MOS6522Bridge *bridge;
|
||||||
bool irq_line;
|
bool irq_line;
|
||||||
|
uint8_t port_a_value;
|
||||||
|
uint8_t port_b_value;
|
||||||
|
|
||||||
void set_interrupt_status(bool new_status)
|
void set_interrupt_status(bool new_status)
|
||||||
{
|
{
|
||||||
irq_line = new_status;
|
irq_line = new_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t get_port_input(int port)
|
||||||
|
{
|
||||||
|
return port ? port_b_value : port_a_value;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@implementation MOS6522Bridge
|
@implementation MOS6522Bridge
|
||||||
@ -57,4 +64,24 @@ class VanillaVIA: public MOS::MOS6522<VanillaVIA> {
|
|||||||
return _via.irq_line;
|
return _via.irq_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setPortAInput:(uint8_t)portAInput
|
||||||
|
{
|
||||||
|
_via.port_a_value = portAInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (uint8_t)portAInput
|
||||||
|
{
|
||||||
|
return _via.port_a_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setPortBInput:(uint8_t)portBInput
|
||||||
|
{
|
||||||
|
_via.port_b_value = portBInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (uint8_t)portBInput
|
||||||
|
{
|
||||||
|
return _via.port_b_value;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user