1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-29 15:29:36 +00:00

Continued in my effort to wire up a keyboard. Will need further to continue.

This commit is contained in:
Thomas Harte 2016-10-14 21:35:15 -04:00
parent d8e4c488c2
commit 138eabcff4
4 changed files with 58 additions and 10 deletions

View File

@ -21,3 +21,18 @@ void AY38910::get_samples(unsigned int number_of_samples, int16_t *target)
void AY38910::skip_samples(unsigned int number_of_samples)
{
}
void AY38910::select_register(uint8_t r)
{
printf("sel %d\n", r);
}
void AY38910::set_register_value(uint8_t value)
{
printf("val %d\n", value);
}
uint8_t AY38910::get_register_value()
{
return 0;
}

View File

@ -15,6 +15,7 @@ Machine::Machine() : _cycles_since_video_update(0)
set_clock_rate(1000000);
_via.set_interrupt_delegate(this);
_keyboard.reset(new Keyboard);
_via.keyboard = _keyboard;
clear_all_keys();
}

View File

@ -95,23 +95,56 @@ class Machine:
public:
using MOS6522IRQDelegate::set_interrupt_status;
void set_port_output(Port port, uint8_t value, uint8_t direction_mask) {
port_outputs[port] = value;
if(port)
set_control_line_input(port, Line::One, (value << 1)&value&128);
void set_control_line_output(Port port, Line line, bool value)
{
if(line)
{
if(port) _ay_bdir = value; else _ay_bc1 = value;
update_ay();
}
}
void set_port_output(Port port, uint8_t value, uint8_t direction_mask) {
if(port)
{
keyboard->row = value;
}
else
{
_port_a = value;
update_ay();
}
}
uint8_t get_port_input(Port port) {
if(port)
{
return port_outputs[0];
return (keyboard->rows[keyboard->row & 7] & keyboard->column) ? 0x08 : 0x00;
}
else
return (uint8_t)((port_outputs[port] >> 4) | (port_outputs[port] << 4));
{
return _port_a;
}
}
uint8_t port_outputs[2];
std::unique_ptr<GI::AY38910> ay8910;
std::shared_ptr<Keyboard> keyboard;
private:
void update_ay()
{
if(_ay_bdir)
{
if(_ay_bc1) ay8910->select_register(_port_a);
else ay8910->set_register_value(_port_a);
}
else
{
if(_ay_bc1) _port_a = ay8910->get_register_value();
}
}
uint8_t _port_a;
bool _ay_bdir, _ay_bc1;
};
VIA _via;
std::shared_ptr<Keyboard> _keyboard;

View File

@ -25,7 +25,7 @@
self = [super init];
if(self)
{
NSData *rom = [self rom:@"test108j"];
NSData *rom = [self rom:@"basic11"]; // test108j
if(rom) _oric.set_rom(rom.stdVector8);
}
return self;
@ -48,7 +48,7 @@
@synchronized(self) {
switch(key)
{
/* case VK_ANSI_0: _oric.set_key_state(Oric::Key::Key0, isPressed); break;
case VK_ANSI_0: _oric.set_key_state(Oric::Key::Key0, isPressed); break;
case VK_ANSI_1: _oric.set_key_state(Oric::Key::Key1, isPressed); break;
case VK_ANSI_2: _oric.set_key_state(Oric::Key::Key2, isPressed); break;
case VK_ANSI_3: _oric.set_key_state(Oric::Key::Key3, isPressed); break;
@ -107,7 +107,6 @@
case VK_Shift: _oric.set_key_state(Oric::Key::KeyLeftShift, isPressed); break;
case VK_RightShift: _oric.set_key_state(Oric::Key::KeyRightShift, isPressed); break;
case VK_Control: _oric.set_key_state(Oric::Key::KeyControl, isPressed); break;
case VK_Command:*/
case VK_ANSI_Grave:
case VK_F12: _oric.set_key_state(Oric::Key::KeyNMI, isPressed); break;