1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-23 20:29:42 +00:00

Implements the C010 read value.

This commit is contained in:
Thomas Harte 2018-08-04 17:57:02 -04:00
parent 558b96bc05
commit 3aeb4213fe

View File

@ -85,6 +85,7 @@ template <bool is_iie> class ConcreteMachine:
std::vector<uint8_t> rom_;
std::vector<uint8_t> character_rom_;
uint8_t keyboard_input_ = 0x00;
bool key_is_down_ = false;
Concurrency::DeferringAsyncTaskQueue audio_queue_;
Audio::Toggle audio_toggle_;
@ -149,17 +150,12 @@ template <bool is_iie> class ConcreteMachine:
2000 to 4000 : the graphics screen, which can be configured to write to auxiliary RAM
c100 to d000 : can be used to page an additional 3.75kb of ROM, replacing the IO area
c300 to c400 : can contain the same 256-byte segment of the ROM as if the whole IO area were switched, but while leaving cards visible in the rest
c800 to d000 : can contain ROM separately from the region below c800
If dealt with as individual blocks in the inner loop, that would therefore imply mapping
an address to one of 12 potential pageable zones. So I've gone reductive and surrendered
an address to one of 13 potential pageable zones. So I've gone reductive and surrendered
to paging every 6502 page of memory independently. It makes the paging events more expensive,
but hopefully is clear.
Those 12 block, for the record:
0000 to 0200; 0200 to 0400; 0400 to 0800; 0800 to 2000;
2000 to 4000; 4000 to c000; c000 to c100; c100 to c300;
c300 to c400; c400 to d000; d000 to e000; e000+
but hopefully more clear.
*/
uint8_t *read_pages_[256]; // each is a pointer to the 256-block of memory the CPU should read when accessing that page of memory
uint8_t *write_pages_[256]; // as per read_pages_, but this is where the CPU should write. If a pointer is nullptr, don't write.
@ -614,8 +610,7 @@ template <bool is_iie> class ConcreteMachine:
// On the IIe, reading C010 returns additional key info.
if(is_iie && isReadOperation(operation)) {
// TODO!
*value = 0;
*value = (key_is_down_ ? 0x80 : 0x00) | (keyboard_input_ & 0x7f);
}
break;
@ -732,20 +727,26 @@ template <bool is_iie> class ConcreteMachine:
return;
}
if(is_pressed) {
// If no ASCII value is supplied, look for a few special cases.
if(!value) {
switch(key) {
case Key::Left: value = 0x08; break;
case Key::Right: value = 0x15; break;
case Key::Down: value = 0x0a; break;
case Key::Up: value = 0x0b; break;
case Key::BackSpace: value = 0x7f; break;
default: break;
}
// If no ASCII value is supplied, look for a few special cases.
if(!value) {
switch(key) {
case Key::Left: value = 0x08; break;
case Key::Right: value = 0x15; break;
case Key::Down: value = 0x0a; break;
case Key::Up: value = 0x0b; break;
case Key::BackSpace: value = 0x7f; break;
default: return;
}
}
keyboard_input_ = static_cast<uint8_t>(toupper(value) | 0x80);
value = static_cast<char>(toupper(value));
if(is_pressed) {
keyboard_input_ = static_cast<uint8_t>(value | 0x80);
key_is_down_ = true;
} else {
if((keyboard_input_ & 0x7f) == value) {
key_is_down_ = false;
}
}
}