mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-24 12:30:17 +00:00
Made an attempt at hooking up the '2' and '4' keys. A mostly unsuccessful attempt. 2 does nothing, 4 clears the screen.
This commit is contained in:
parent
7a241b5ef5
commit
d7c1f5b18a
@ -22,10 +22,47 @@ enum ROMSlot {
|
|||||||
ROMSlotCharacters,
|
ROMSlotCharacters,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define key(line, mask) (((mask) << 3) | (line))
|
||||||
|
|
||||||
|
enum Key: uint16_t {
|
||||||
|
Key2 = key(7, 0x80), Key4 = key(7, 0x40)
|
||||||
|
};
|
||||||
|
|
||||||
class UserPortVIA: public MOS::MOS6522<UserPortVIA> {
|
class UserPortVIA: public MOS::MOS6522<UserPortVIA> {
|
||||||
};
|
};
|
||||||
|
|
||||||
class KeyboardVIA: public MOS::MOS6522<KeyboardVIA> {
|
class KeyboardVIA: public MOS::MOS6522<KeyboardVIA> {
|
||||||
|
public:
|
||||||
|
void set_key_state(Key key, bool isPressed) {
|
||||||
|
if(isPressed)
|
||||||
|
_columns[key & 0x07] &= ~(key >> 3);
|
||||||
|
else
|
||||||
|
_columns[key & 0x07] |= (key >> 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
// to satisfy MOS::MOS6522
|
||||||
|
uint8_t get_port_input(int port) {
|
||||||
|
if(!port) {
|
||||||
|
uint8_t result = 0xff;
|
||||||
|
for(int c = 0; c < 8; c++)
|
||||||
|
{
|
||||||
|
if(!(_activation_mask&(1 << c))) result &= _columns[c];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_port_output(int port, uint8_t value) {
|
||||||
|
if(port) _activation_mask = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyboardVIA() : _columns{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} {}
|
||||||
|
private:
|
||||||
|
uint8_t _columns[8];
|
||||||
|
uint8_t _activation_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Machine: public CPU6502::Processor<Machine>, public CRTMachine::Machine, public MOS::MOS6522Delegate {
|
class Machine: public CPU6502::Processor<Machine>, public CRTMachine::Machine, public MOS::MOS6522Delegate {
|
||||||
@ -34,6 +71,7 @@ class Machine: public CPU6502::Processor<Machine>, public CRTMachine::Machine, p
|
|||||||
|
|
||||||
void set_rom(ROMSlot slot, size_t length, const uint8_t *data);
|
void set_rom(ROMSlot slot, size_t length, const uint8_t *data);
|
||||||
void add_prg(size_t length, const uint8_t *data);
|
void add_prg(size_t length, const uint8_t *data);
|
||||||
|
void set_key_state(Key key, bool isPressed) { _keyboardVIA->set_key_state(key, isPressed); }
|
||||||
|
|
||||||
// to satisfy CPU6502::Processor
|
// to satisfy CPU6502::Processor
|
||||||
unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value);
|
unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value);
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "CSMachine.h"
|
#import "CSMachine.h"
|
||||||
#import "KeyCodes.h"
|
|
||||||
#import "CSKeyboardMachine.h"
|
#import "CSKeyboardMachine.h"
|
||||||
|
|
||||||
@interface CSElectron : CSMachine <CSKeyboardMachine>
|
@interface CSElectron : CSMachine <CSKeyboardMachine>
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#import "KeyCodes.h"
|
||||||
|
|
||||||
@protocol CSKeyboardMachine <NSObject>
|
@protocol CSKeyboardMachine <NSObject>
|
||||||
|
|
||||||
- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed;
|
- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed;
|
||||||
|
@ -39,6 +39,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed {
|
- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed {
|
||||||
|
@synchronized(self) {
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
case VK_ANSI_2: _vic20.set_key_state(Vic20::Key::Key2, isPressed); break;
|
||||||
|
case VK_ANSI_4: _vic20.set_key_state(Vic20::Key::Key4, isPressed); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)clearAllKeys {
|
- (void)clearAllKeys {
|
||||||
|
Loading…
Reference in New Issue
Block a user