2016-06-05 01:43:50 +00:00
|
|
|
//
|
|
|
|
// Vic20.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 04/06/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Vic20.hpp"
|
2016-06-05 02:00:50 +00:00
|
|
|
|
2016-06-05 14:51:07 +00:00
|
|
|
#include <algorithm>
|
2016-08-15 23:44:41 +00:00
|
|
|
#include "../../../Storage/Tape/Formats/TapePRG.hpp"
|
2016-06-05 14:51:07 +00:00
|
|
|
|
2016-07-05 17:28:27 +00:00
|
|
|
using namespace Commodore::Vic20;
|
2016-06-05 02:00:50 +00:00
|
|
|
|
2016-06-09 02:15:24 +00:00
|
|
|
Machine::Machine() :
|
2016-06-11 18:00:12 +00:00
|
|
|
_rom(nullptr)
|
2016-06-05 15:44:29 +00:00
|
|
|
{
|
2016-07-05 18:55:20 +00:00
|
|
|
// create 6522s, serial port and bus
|
2016-07-05 14:55:47 +00:00
|
|
|
_userPortVIA.reset(new UserPortVIA);
|
|
|
|
_keyboardVIA.reset(new KeyboardVIA);
|
|
|
|
_serialPort.reset(new SerialPort);
|
2016-07-05 18:55:20 +00:00
|
|
|
_serialBus.reset(new ::Commodore::Serial::Bus);
|
2016-07-05 14:55:47 +00:00
|
|
|
|
2016-07-05 18:55:20 +00:00
|
|
|
// wire up the serial bus and serial port
|
2016-07-10 11:46:20 +00:00
|
|
|
Commodore::Serial::AttachPortAndBus(_serialPort, _serialBus);
|
2016-07-05 18:55:20 +00:00
|
|
|
|
|
|
|
// wire up 6522s and serial port
|
2016-07-05 14:55:47 +00:00
|
|
|
_userPortVIA->set_serial_port(_serialPort);
|
|
|
|
_keyboardVIA->set_serial_port(_serialPort);
|
2016-07-05 20:10:54 +00:00
|
|
|
_serialPort->set_user_port_via(_userPortVIA);
|
2016-07-05 14:55:47 +00:00
|
|
|
|
2016-07-05 18:55:20 +00:00
|
|
|
// wire up the 6522s, tape and machine
|
2016-08-01 08:25:11 +00:00
|
|
|
_userPortVIA->set_interrupt_delegate(this);
|
|
|
|
_keyboardVIA->set_interrupt_delegate(this);
|
2016-06-26 23:43:09 +00:00
|
|
|
_tape.set_delegate(this);
|
2016-07-01 23:01:22 +00:00
|
|
|
|
2016-07-05 18:55:20 +00:00
|
|
|
// establish the memory maps
|
2016-08-13 21:21:25 +00:00
|
|
|
set_memory_size(MemorySize::Default);
|
|
|
|
|
2016-08-14 17:33:20 +00:00
|
|
|
// set the NTSC clock rate
|
|
|
|
set_region(NTSC);
|
2016-08-13 21:21:25 +00:00
|
|
|
// _debugPort.reset(new ::Commodore::Serial::DebugPort);
|
|
|
|
// _debugPort->set_serial_bus(_serialBus);
|
|
|
|
// _serialBus->add_port(_debugPort);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Machine::set_memory_size(MemorySize size)
|
|
|
|
{
|
2016-07-01 23:01:22 +00:00
|
|
|
memset(_processorReadMemoryMap, 0, sizeof(_processorReadMemoryMap));
|
|
|
|
memset(_processorWriteMemoryMap, 0, sizeof(_processorWriteMemoryMap));
|
|
|
|
|
2016-08-13 21:21:25 +00:00
|
|
|
switch(size)
|
|
|
|
{
|
|
|
|
default: break;
|
|
|
|
case ThreeKB:
|
|
|
|
write_to_map(_processorReadMemoryMap, _expansionRAM, 0x0000, 0x1000);
|
|
|
|
write_to_map(_processorWriteMemoryMap, _expansionRAM, 0x0000, 0x1000);
|
|
|
|
break;
|
|
|
|
case ThirtyTwoKB:
|
|
|
|
write_to_map(_processorReadMemoryMap, _expansionRAM, 0x0000, 0x8000);
|
|
|
|
write_to_map(_processorWriteMemoryMap, _expansionRAM, 0x0000, 0x8000);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-08-15 23:56:01 +00:00
|
|
|
// install the system ROMs and VIC-visible memory
|
2016-07-01 23:01:22 +00:00
|
|
|
write_to_map(_processorReadMemoryMap, _userBASICMemory, 0x0000, sizeof(_userBASICMemory));
|
|
|
|
write_to_map(_processorReadMemoryMap, _screenMemory, 0x1000, sizeof(_screenMemory));
|
|
|
|
write_to_map(_processorReadMemoryMap, _colorMemory, 0x9400, sizeof(_colorMemory));
|
|
|
|
write_to_map(_processorReadMemoryMap, _characterROM, 0x8000, sizeof(_characterROM));
|
|
|
|
write_to_map(_processorReadMemoryMap, _basicROM, 0xc000, sizeof(_basicROM));
|
|
|
|
write_to_map(_processorReadMemoryMap, _kernelROM, 0xe000, sizeof(_kernelROM));
|
|
|
|
|
|
|
|
write_to_map(_processorWriteMemoryMap, _userBASICMemory, 0x0000, sizeof(_userBASICMemory));
|
|
|
|
write_to_map(_processorWriteMemoryMap, _screenMemory, 0x1000, sizeof(_screenMemory));
|
|
|
|
write_to_map(_processorWriteMemoryMap, _colorMemory, 0x9400, sizeof(_colorMemory));
|
2016-08-15 23:56:01 +00:00
|
|
|
|
|
|
|
// install the inserted ROM if there is one
|
|
|
|
if(_rom)
|
|
|
|
{
|
|
|
|
write_to_map(_processorReadMemoryMap, _rom, _rom_address, _rom_length);
|
|
|
|
}
|
2016-06-05 15:44:29 +00:00
|
|
|
}
|
2016-06-05 14:51:07 +00:00
|
|
|
|
2016-07-01 23:01:22 +00:00
|
|
|
void Machine::write_to_map(uint8_t **map, uint8_t *area, uint16_t address, uint16_t length)
|
|
|
|
{
|
|
|
|
address >>= 10;
|
|
|
|
length >>= 10;
|
|
|
|
while(length--)
|
|
|
|
{
|
|
|
|
map[address] = area;
|
|
|
|
area += 0x400;
|
|
|
|
address++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-11 18:00:12 +00:00
|
|
|
Machine::~Machine()
|
|
|
|
{
|
|
|
|
delete[] _rom;
|
|
|
|
}
|
|
|
|
|
2016-06-05 02:00:50 +00:00
|
|
|
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
|
|
|
|
{
|
2016-07-10 02:29:11 +00:00
|
|
|
// static int logCount = 0;
|
2016-08-16 23:46:53 +00:00
|
|
|
// if(operation == CPU6502::BusOperation::ReadOpcode && address == 0xf957) logCount = 500;
|
2016-07-10 02:29:11 +00:00
|
|
|
// if(operation == CPU6502::BusOperation::ReadOpcode && logCount) {
|
|
|
|
// logCount--;
|
|
|
|
// printf("%04x\n", address);
|
|
|
|
// }
|
2016-07-10 00:03:38 +00:00
|
|
|
|
2016-06-05 16:11:12 +00:00
|
|
|
// run the phase-1 part of this cycle, in which the VIC accesses memory
|
2016-08-10 00:41:05 +00:00
|
|
|
_mos6560->run_for_cycles(1);
|
2016-06-05 16:11:12 +00:00
|
|
|
|
|
|
|
// run the phase-2 part of the cycle, which is whatever the 6502 said it should be
|
2016-06-05 15:44:29 +00:00
|
|
|
if(isReadOperation(operation))
|
|
|
|
{
|
2016-07-01 23:01:22 +00:00
|
|
|
uint8_t result = _processorReadMemoryMap[address >> 10] ? _processorReadMemoryMap[address >> 10][address & 0x3ff] : 0xff;
|
|
|
|
if((address&0xfc00) == 0x9000)
|
2016-06-07 00:29:39 +00:00
|
|
|
{
|
2016-07-01 23:01:22 +00:00
|
|
|
if((address&0xff00) == 0x9000) result &= _mos6560->get_register(address);
|
2016-07-05 14:55:47 +00:00
|
|
|
if((address&0xfc10) == 0x9010) result &= _userPortVIA->get_register(address);
|
|
|
|
if((address&0xfc20) == 0x9020) result &= _keyboardVIA->get_register(address);
|
2016-06-07 00:29:39 +00:00
|
|
|
}
|
2016-07-01 23:01:22 +00:00
|
|
|
*value = result;
|
|
|
|
|
|
|
|
// test for PC at F92F
|
2016-07-07 02:17:32 +00:00
|
|
|
if(_use_fast_tape_hack && _tape.has_tape() && address == 0xf92f && operation == CPU6502::BusOperation::ReadOpcode)
|
2016-06-07 23:15:18 +00:00
|
|
|
{
|
2016-07-01 23:01:22 +00:00
|
|
|
// advance time on the tape and the VIAs until an interrupt is signalled
|
2016-07-05 14:55:47 +00:00
|
|
|
while(!_userPortVIA->get_interrupt_line() && !_keyboardVIA->get_interrupt_line())
|
2016-07-01 23:01:22 +00:00
|
|
|
{
|
2016-07-05 14:55:47 +00:00
|
|
|
_userPortVIA->run_for_half_cycles(2);
|
|
|
|
_keyboardVIA->run_for_half_cycles(2);
|
2016-07-01 23:01:22 +00:00
|
|
|
_tape.run_for_cycles(1);
|
|
|
|
}
|
2016-06-07 23:15:18 +00:00
|
|
|
}
|
2016-06-05 15:44:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-01 23:01:22 +00:00
|
|
|
uint8_t *ram = _processorWriteMemoryMap[address >> 10];
|
|
|
|
if(ram) ram[address & 0x3ff] = *value;
|
|
|
|
if((address&0xfc00) == 0x9000)
|
2016-06-07 23:15:18 +00:00
|
|
|
{
|
2016-07-01 23:01:22 +00:00
|
|
|
if((address&0xff00) == 0x9000) _mos6560->set_register(address, *value);
|
2016-07-05 14:55:47 +00:00
|
|
|
if((address&0xfc10) == 0x9010) _userPortVIA->set_register(address, *value);
|
|
|
|
if((address&0xfc20) == 0x9020) _keyboardVIA->set_register(address, *value);
|
2016-06-07 23:15:18 +00:00
|
|
|
}
|
2016-06-05 15:44:29 +00:00
|
|
|
}
|
|
|
|
|
2016-07-05 14:55:47 +00:00
|
|
|
_userPortVIA->run_for_half_cycles(2);
|
|
|
|
_keyboardVIA->run_for_half_cycles(2);
|
2016-08-06 18:33:24 +00:00
|
|
|
if(_typer && operation == CPU6502::BusOperation::ReadOpcode && address == 0xEB1E)
|
|
|
|
{
|
|
|
|
if(!_typer->type_next_character())
|
|
|
|
_typer.reset();
|
|
|
|
}
|
2016-06-26 23:43:09 +00:00
|
|
|
_tape.run_for_cycles(1);
|
2016-07-05 20:39:18 +00:00
|
|
|
if(_c1540) _c1540->run_for_cycles(1);
|
2016-06-05 02:00:50 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2016-06-05 13:06:59 +00:00
|
|
|
|
2016-06-10 02:37:59 +00:00
|
|
|
#pragma mark - 6522 delegate
|
|
|
|
|
|
|
|
void Machine::mos6522_did_change_interrupt_status(void *mos6522)
|
|
|
|
{
|
2016-07-05 14:55:47 +00:00
|
|
|
set_nmi_line(_userPortVIA->get_interrupt_line());
|
|
|
|
set_irq_line(_keyboardVIA->get_interrupt_line());
|
2016-06-10 02:37:59 +00:00
|
|
|
}
|
|
|
|
|
2016-06-05 15:20:05 +00:00
|
|
|
#pragma mark - Setup
|
|
|
|
|
2016-08-14 17:33:20 +00:00
|
|
|
void Machine::set_region(Commodore::Vic20::Region region)
|
|
|
|
{
|
|
|
|
_region = region;
|
|
|
|
switch(region)
|
|
|
|
{
|
|
|
|
case PAL:
|
|
|
|
set_clock_rate(1108404);
|
|
|
|
if(_mos6560) _mos6560->set_output_mode(MOS::MOS6560<Commodore::Vic20::Vic6560>::OutputMode::PAL);
|
|
|
|
break;
|
|
|
|
case NTSC:
|
|
|
|
set_clock_rate(1022727);
|
|
|
|
if(_mos6560) _mos6560->set_output_mode(MOS::MOS6560<Commodore::Vic20::Vic6560>::OutputMode::NTSC);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-05 14:51:07 +00:00
|
|
|
void Machine::setup_output(float aspect_ratio)
|
|
|
|
{
|
2016-08-06 18:33:24 +00:00
|
|
|
_mos6560.reset(new Vic6560());
|
2016-08-14 17:33:20 +00:00
|
|
|
set_region(_region);
|
2016-08-10 00:41:05 +00:00
|
|
|
|
|
|
|
memset(_mos6560->_videoMemoryMap, 0, sizeof(_mos6560->_videoMemoryMap));
|
|
|
|
write_to_map(_mos6560->_videoMemoryMap, _characterROM, 0x0000, sizeof(_characterROM));
|
|
|
|
write_to_map(_mos6560->_videoMemoryMap, _userBASICMemory, 0x2000, sizeof(_userBASICMemory));
|
|
|
|
write_to_map(_mos6560->_videoMemoryMap, _screenMemory, 0x3000, sizeof(_screenMemory));
|
|
|
|
_mos6560->_colorMemory = _colorMemory;
|
2016-06-05 14:51:07 +00:00
|
|
|
}
|
|
|
|
|
2016-07-05 00:34:11 +00:00
|
|
|
void Machine::close_output()
|
|
|
|
{
|
|
|
|
_mos6560 = nullptr;
|
|
|
|
}
|
|
|
|
|
2016-06-05 13:06:59 +00:00
|
|
|
void Machine::set_rom(ROMSlot slot, size_t length, const uint8_t *data)
|
|
|
|
{
|
2016-06-05 14:51:07 +00:00
|
|
|
uint8_t *target = nullptr;
|
2016-06-05 15:20:05 +00:00
|
|
|
size_t max_length = 0x2000;
|
2016-06-05 14:51:07 +00:00
|
|
|
switch(slot)
|
|
|
|
{
|
2016-07-05 20:39:18 +00:00
|
|
|
case Kernel: target = _kernelROM; break;
|
|
|
|
case Characters: target = _characterROM; max_length = 0x1000; break;
|
|
|
|
case BASIC: target = _basicROM; break;
|
|
|
|
case Drive:
|
2016-08-06 18:33:24 +00:00
|
|
|
_driveROM.reset(new uint8_t[length]);
|
|
|
|
memcpy(_driveROM.get(), data, length);
|
|
|
|
install_disk_rom();
|
2016-07-05 20:39:18 +00:00
|
|
|
return;
|
2016-06-05 14:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(target)
|
|
|
|
{
|
2016-06-05 15:20:05 +00:00
|
|
|
size_t length_to_copy = std::min(max_length, length);
|
2016-06-05 14:51:07 +00:00
|
|
|
memcpy(target, data, length_to_copy);
|
|
|
|
}
|
2016-06-05 13:06:59 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 23:44:41 +00:00
|
|
|
void Machine::set_prg(const char *file_name, size_t length, const uint8_t *data)
|
2016-06-05 13:06:59 +00:00
|
|
|
{
|
2016-06-11 18:00:12 +00:00
|
|
|
if(length > 2)
|
|
|
|
{
|
|
|
|
_rom_address = (uint16_t)(data[0] | (data[1] << 8));
|
|
|
|
_rom_length = (uint16_t)(length - 2);
|
2016-06-19 17:46:53 +00:00
|
|
|
|
2016-08-15 23:56:01 +00:00
|
|
|
// install in the ROM area if this looks like a ROM; otherwise put on tape and throw into that mechanism
|
|
|
|
if(_rom_address == 0xa000 && _rom_length == 0x1000)
|
2016-08-14 20:36:42 +00:00
|
|
|
{
|
|
|
|
_rom = new uint8_t[length - 2];
|
|
|
|
memcpy(_rom, &data[2], length - 2);
|
|
|
|
write_to_map(_processorReadMemoryMap, _rom, _rom_address, _rom_length);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-15 23:44:41 +00:00
|
|
|
set_tape(std::shared_ptr<Storage::Tape>(new Storage::TapePRG(file_name)));
|
2016-08-14 20:36:42 +00:00
|
|
|
}
|
2016-06-11 18:00:12 +00:00
|
|
|
}
|
2016-06-05 13:06:59 +00:00
|
|
|
}
|
2016-06-19 17:10:52 +00:00
|
|
|
|
2016-06-25 20:24:52 +00:00
|
|
|
#pragma mar - Tape
|
|
|
|
|
|
|
|
void Machine::set_tape(std::shared_ptr<Storage::Tape> tape)
|
|
|
|
{
|
2016-06-26 23:43:09 +00:00
|
|
|
_tape.set_tape(tape);
|
2016-08-06 21:39:27 +00:00
|
|
|
if(_should_automatically_load_media) set_typer_for_string("LOAD\nRUN\n");
|
2016-06-26 23:43:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Machine::tape_did_change_input(Tape *tape)
|
|
|
|
{
|
2016-07-05 14:55:47 +00:00
|
|
|
_keyboardVIA->set_control_line_input(KeyboardVIA::Port::A, KeyboardVIA::Line::One, tape->get_input());
|
2016-06-25 20:24:52 +00:00
|
|
|
}
|
|
|
|
|
2016-07-10 16:57:17 +00:00
|
|
|
#pragma mark - Disc
|
|
|
|
|
|
|
|
void Machine::set_disk(std::shared_ptr<Storage::Disk> disk)
|
|
|
|
{
|
|
|
|
// construct the 1540
|
|
|
|
_c1540.reset(new ::Commodore::C1540::Machine);
|
|
|
|
|
|
|
|
// attach it to the serial bus
|
|
|
|
_c1540->set_serial_bus(_serialBus);
|
|
|
|
|
2016-07-10 20:24:46 +00:00
|
|
|
// hand it the disk
|
|
|
|
_c1540->set_disk(disk);
|
2016-07-31 23:33:18 +00:00
|
|
|
|
|
|
|
// install the ROM if it was previously set
|
2016-08-06 18:33:24 +00:00
|
|
|
install_disk_rom();
|
|
|
|
|
2016-08-06 21:39:27 +00:00
|
|
|
if(_should_automatically_load_media) set_typer_for_string("LOAD\"*\",8,1\nRUN\n");
|
2016-08-06 18:33:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Machine::install_disk_rom()
|
|
|
|
{
|
|
|
|
if(_driveROM && _c1540)
|
2016-07-31 23:33:18 +00:00
|
|
|
{
|
|
|
|
_c1540->set_rom(_driveROM.get());
|
2016-08-06 18:33:24 +00:00
|
|
|
_c1540->run_for_cycles(2000000);
|
2016-07-31 23:33:18 +00:00
|
|
|
_driveROM.reset();
|
|
|
|
}
|
2016-07-10 16:57:17 +00:00
|
|
|
}
|
|
|
|
|
2016-06-19 17:10:52 +00:00
|
|
|
#pragma mark - Typer
|
|
|
|
|
|
|
|
int Machine::get_typer_delay()
|
|
|
|
{
|
2016-08-01 14:32:32 +00:00
|
|
|
return get_is_resetting() ? 1*263*60*65 : 0; // wait a second if resetting
|
2016-06-19 17:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Machine::get_typer_frequency()
|
|
|
|
{
|
|
|
|
return 2*263*65; // accept a new character every two fields
|
|
|
|
}
|
|
|
|
|
2016-06-19 17:46:53 +00:00
|
|
|
bool Machine::typer_set_next_character(::Utility::Typer *typer, char character, int phase)
|
2016-06-19 17:10:52 +00:00
|
|
|
{
|
2016-06-19 17:46:53 +00:00
|
|
|
// If there's a 'ROM' installed that can never be accessed, assume that this typing was scheduled because
|
|
|
|
// it should be in RAM. So copy it there.
|
|
|
|
if(_rom && _rom_address >= 0x1000 && _rom_address+_rom_length < 0x2000)
|
2016-06-19 17:10:52 +00:00
|
|
|
{
|
2016-06-19 17:46:53 +00:00
|
|
|
memcpy(&_screenMemory[_rom_address - 0x1000], _rom, _rom_length);
|
|
|
|
delete[] _rom;
|
|
|
|
_rom = nullptr;
|
2016-06-19 17:10:52 +00:00
|
|
|
}
|
2016-06-19 17:46:53 +00:00
|
|
|
|
|
|
|
if(!phase) clear_all_keys();
|
|
|
|
|
|
|
|
// The following table is arranged in ASCII order
|
|
|
|
Key key_sequences[][3] = {
|
|
|
|
{NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped},
|
|
|
|
{KeyDelete, TerminateSequence},
|
|
|
|
{NotMapped},
|
|
|
|
{KeyReturn, TerminateSequence},
|
|
|
|
{NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped},
|
|
|
|
{NotMapped}, {NotMapped}, {NotMapped}, {NotMapped},
|
|
|
|
{NotMapped}, {NotMapped}, {NotMapped}, {NotMapped},
|
|
|
|
{NotMapped}, {NotMapped}, {NotMapped}, {NotMapped},
|
|
|
|
{NotMapped}, {NotMapped}, {NotMapped}, {NotMapped},
|
|
|
|
|
|
|
|
{KeySpace, TerminateSequence}, // space
|
|
|
|
|
2016-06-19 20:35:04 +00:00
|
|
|
{KeyLShift, Key1, TerminateSequence}, {KeyLShift, Key2, TerminateSequence}, // !, "
|
|
|
|
{KeyLShift, Key3, TerminateSequence}, {KeyLShift, Key4, TerminateSequence}, // #, $
|
|
|
|
{KeyLShift, Key5, TerminateSequence}, {KeyLShift, Key6, TerminateSequence}, // %, &
|
|
|
|
{KeyLShift, Key7, TerminateSequence}, {KeyLShift, Key8, TerminateSequence}, // ', (
|
|
|
|
{KeyLShift, Key9, TerminateSequence}, {KeyAsterisk, TerminateSequence}, // ), *
|
|
|
|
{KeyPlus, TerminateSequence}, {KeyComma, TerminateSequence}, // +, ,
|
|
|
|
{KeyDash, TerminateSequence}, {KeyFullStop, TerminateSequence}, // -, .
|
|
|
|
{KeySlash, TerminateSequence}, // /
|
|
|
|
|
|
|
|
{Key0, TerminateSequence}, {Key1, TerminateSequence}, // 0, 1
|
|
|
|
{Key2, TerminateSequence}, {Key3, TerminateSequence}, // 2, 3
|
|
|
|
{Key4, TerminateSequence}, {Key5, TerminateSequence}, // 4, 5
|
|
|
|
{Key6, TerminateSequence}, {Key7, TerminateSequence}, // 6, 7
|
|
|
|
{Key8, TerminateSequence}, {Key9, TerminateSequence}, // 8, 9
|
|
|
|
|
|
|
|
{KeyColon, TerminateSequence}, {KeySemicolon, TerminateSequence}, // :, ;
|
|
|
|
{KeyLShift, KeyComma, TerminateSequence}, {KeyEquals, TerminateSequence}, // <, =
|
|
|
|
{KeyLShift, KeyFullStop, TerminateSequence}, {KeyLShift, KeySlash, TerminateSequence}, // >, ?
|
2016-06-19 17:46:53 +00:00
|
|
|
{KeyAt, TerminateSequence}, // @
|
|
|
|
|
2016-06-19 20:35:04 +00:00
|
|
|
{KeyA, TerminateSequence}, {KeyB, TerminateSequence}, {KeyC, TerminateSequence}, {KeyD, TerminateSequence}, // A, B, C, D
|
|
|
|
{KeyE, TerminateSequence}, {KeyF, TerminateSequence}, {KeyG, TerminateSequence}, {KeyH, TerminateSequence}, // E, F, G, H
|
|
|
|
{KeyI, TerminateSequence}, {KeyJ, TerminateSequence}, {KeyK, TerminateSequence}, {KeyL, TerminateSequence}, // I, J, K L
|
|
|
|
{KeyM, TerminateSequence}, {KeyN, TerminateSequence}, {KeyO, TerminateSequence}, {KeyP, TerminateSequence}, // M, N, O, P
|
|
|
|
{KeyQ, TerminateSequence}, {KeyR, TerminateSequence}, {KeyS, TerminateSequence}, {KeyT, TerminateSequence}, // Q, R, S, T
|
|
|
|
{KeyU, TerminateSequence}, {KeyV, TerminateSequence}, {KeyW, TerminateSequence}, {KeyX, TerminateSequence}, // U, V, W X
|
|
|
|
{KeyY, TerminateSequence}, {KeyZ, TerminateSequence}, // Y, Z
|
|
|
|
|
|
|
|
{KeyLShift, KeyColon, TerminateSequence}, {NotMapped}, // [, '\'
|
|
|
|
{KeyLShift, KeyFullStop, TerminateSequence}, {NotMapped}, // ], ^
|
|
|
|
{NotMapped}, {NotMapped}, // _, `
|
|
|
|
|
|
|
|
{KeyA, TerminateSequence}, {KeyB, TerminateSequence}, {KeyC, TerminateSequence}, {KeyD, TerminateSequence}, // A, B, C, D
|
|
|
|
{KeyE, TerminateSequence}, {KeyF, TerminateSequence}, {KeyG, TerminateSequence}, {KeyH, TerminateSequence}, // E, F, G, H
|
|
|
|
{KeyI, TerminateSequence}, {KeyJ, TerminateSequence}, {KeyK, TerminateSequence}, {KeyL, TerminateSequence}, // I, J, K L
|
|
|
|
{KeyM, TerminateSequence}, {KeyN, TerminateSequence}, {KeyO, TerminateSequence}, {KeyP, TerminateSequence}, // M, N, O, P
|
|
|
|
{KeyQ, TerminateSequence}, {KeyR, TerminateSequence}, {KeyS, TerminateSequence}, {KeyT, TerminateSequence}, // Q, R, S, T
|
|
|
|
{KeyU, TerminateSequence}, {KeyV, TerminateSequence}, {KeyW, TerminateSequence}, {KeyX, TerminateSequence}, // U, V, W X
|
|
|
|
{KeyY, TerminateSequence}, {KeyZ, TerminateSequence}, // Y, Z
|
|
|
|
// {KeyLShift, KeyA, TerminateSequence}, {KeyLShift, KeyB, TerminateSequence}, // a, b
|
|
|
|
// {KeyLShift, KeyC, TerminateSequence}, {KeyLShift, KeyD, TerminateSequence}, // c, d
|
|
|
|
// {KeyLShift, KeyE, TerminateSequence}, {KeyLShift, KeyF, TerminateSequence}, // e, f
|
|
|
|
// {KeyLShift, KeyG, TerminateSequence}, {KeyLShift, KeyH, TerminateSequence}, // g, h
|
|
|
|
// {KeyLShift, KeyI, TerminateSequence}, {KeyLShift, KeyJ, TerminateSequence}, // i, j
|
|
|
|
// {KeyLShift, KeyK, TerminateSequence}, {KeyLShift, KeyL, TerminateSequence}, // k, l
|
|
|
|
// {KeyLShift, KeyM, TerminateSequence}, {KeyLShift, KeyN, TerminateSequence}, // m, n
|
|
|
|
// {KeyLShift, KeyO, TerminateSequence}, {KeyLShift, KeyP, TerminateSequence}, // o, p
|
|
|
|
// {KeyLShift, KeyQ, TerminateSequence}, {KeyLShift, KeyR, TerminateSequence}, // q, r
|
|
|
|
// {KeyLShift, KeyS, TerminateSequence}, {KeyLShift, KeyT, TerminateSequence}, // s, t
|
|
|
|
// {KeyLShift, KeyU, TerminateSequence}, {KeyLShift, KeyV, TerminateSequence}, // u, v
|
|
|
|
// {KeyLShift, KeyW, TerminateSequence}, {KeyLShift, KeyX, TerminateSequence}, // w, x
|
|
|
|
// {KeyLShift, KeyY, TerminateSequence}, {KeyLShift, KeyZ, TerminateSequence}, // y, z
|
2016-06-19 17:46:53 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
Key *key_sequence = nullptr;
|
|
|
|
|
|
|
|
character &= 0x7f;
|
|
|
|
if(character < sizeof(key_sequences) / sizeof(*key_sequences))
|
|
|
|
{
|
|
|
|
key_sequence = key_sequences[character];
|
|
|
|
|
2016-06-19 20:35:04 +00:00
|
|
|
if(key_sequence[0] != NotMapped)
|
|
|
|
{
|
|
|
|
if(phase > 0)
|
|
|
|
{
|
|
|
|
set_key_state(key_sequence[phase-1], true);
|
|
|
|
return key_sequence[phase] == TerminateSequence;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2016-06-19 17:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2016-06-19 17:10:52 +00:00
|
|
|
}
|
2016-06-26 23:43:09 +00:00
|
|
|
|
|
|
|
#pragma mark - Tape
|
|
|
|
|
|
|
|
Tape::Tape() : TapePlayer(1022727) {}
|
|
|
|
|
|
|
|
void Tape::set_motor_control(bool enabled) {}
|
|
|
|
void Tape::set_tape_output(bool set) {}
|
|
|
|
|
|
|
|
void Tape::process_input_pulse(Storage::Tape::Pulse pulse)
|
|
|
|
{
|
|
|
|
bool new_input_level = pulse.type == Storage::Tape::Pulse::Low;
|
|
|
|
if(_input_level != new_input_level)
|
|
|
|
{
|
|
|
|
_input_level = new_input_level;
|
|
|
|
if(_delegate) _delegate->tape_did_change_input(this);
|
|
|
|
}
|
|
|
|
}
|
2016-07-05 20:39:18 +00:00
|
|
|
|