mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +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)
|
||||
}
|
||||
|
||||
// MARK: Timer tests
|
||||
|
||||
func testTimerCount() {
|
||||
with6522 {
|
||||
// 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))")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
@property (nonatomic, readonly) BOOL irqLine;
|
||||
@property (nonatomic) uint8_t portBInput;
|
||||
@property (nonatomic) uint8_t portAInput;
|
||||
|
||||
- (void)setValue:(uint8_t)value forRegister:(NSUInteger)registerNumber;
|
||||
- (uint8_t)valueForRegister:(NSUInteger)registerNumber;
|
||||
|
@ -15,11 +15,18 @@ class VanillaVIA: public MOS::MOS6522<VanillaVIA> {
|
||||
public:
|
||||
MOS6522Bridge *bridge;
|
||||
bool irq_line;
|
||||
uint8_t port_a_value;
|
||||
uint8_t port_b_value;
|
||||
|
||||
void set_interrupt_status(bool new_status)
|
||||
{
|
||||
irq_line = new_status;
|
||||
}
|
||||
|
||||
uint8_t get_port_input(int port)
|
||||
{
|
||||
return port ? port_b_value : port_a_value;
|
||||
}
|
||||
};
|
||||
|
||||
@implementation MOS6522Bridge
|
||||
@ -57,4 +64,24 @@ class VanillaVIA: public MOS::MOS6522<VanillaVIA> {
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user