Integrate keyboard.

This commit is contained in:
Lawrence Kesteloot 2016-11-06 14:37:20 -08:00
parent 21a5e8f112
commit cd7dd66e5e
2 changed files with 14 additions and 6 deletions

View File

@ -5,12 +5,13 @@
using namespace std; using namespace std;
#include "emulator.h" #include "emulator.h"
#include "keyboard.h"
const unsigned int DEBUG_RW = 0x01; const unsigned int DEBUG_RW = 0x01;
const unsigned int DEBUG_DECODE = 0x02; const unsigned int DEBUG_DECODE = 0x02;
const unsigned int DEBUG_STATE = 0x04; const unsigned int DEBUG_STATE = 0x04;
const unsigned int DEBUG_ERROR = 0x08; const unsigned int DEBUG_ERROR = 0x08;
unsigned int debug = DEBUG_ERROR | DEBUG_DECODE | DEBUG_STATE; unsigned int debug = DEBUG_ERROR ; // | DEBUG_DECODE | DEBUG_STATE;
struct SoftSwitch struct SoftSwitch
{ {
@ -111,6 +112,11 @@ struct MAINboard : board_base
memcpy(rom_bytes, rom + rom_base - 0x8000 , sizeof(rom_bytes)); memcpy(rom_bytes, rom + rom_base - 0x8000 , sizeof(rom_bytes));
memcpy(irom_bytes, rom + irom_base - 0x8000 , sizeof(irom_bytes)); memcpy(irom_bytes, rom + irom_base - 0x8000 , sizeof(irom_bytes));
memset(ram_bytes, 0x00, sizeof(ram_bytes)); memset(ram_bytes, 0x00, sizeof(ram_bytes));
start_keyboard();
}
virtual ~MAINboard()
{
stop_keyboard();
} }
virtual bool read(int addr, unsigned char &data) virtual bool read(int addr, unsigned char &data)
{ {
@ -140,8 +146,8 @@ struct MAINboard : board_base
return true; return true;
} }
if(addr == 0xC000) { if(addr == 0xC000) {
if(debug & DEBUG_RW) printf("read KBD, force 0x00\n"); data = get_keyboard_data_and_strobe();
data = 0x00; if(debug & DEBUG_RW) printf("read KBD, return 0x%02X\n", data);
return true; return true;
} }
if(addr == 0xC030) { if(addr == 0xC030) {
@ -151,9 +157,9 @@ struct MAINboard : board_base
return true; return true;
} }
if(addr == 0xC010) { if(addr == 0xC010) {
if(debug & DEBUG_RW) printf("read KBDSTRB, force 0x00\n");
// reset keyboard latch // reset keyboard latch
data = 0x00; data = get_any_key_down_and_clear_strobe();
if(debug & DEBUG_RW) printf("read KBDSTRB, return 0x%02X\n", data);
return true; return true;
} }
printf("unhandled MMIO Read at %04X\n", addr); printf("unhandled MMIO Read at %04X\n", addr);
@ -204,6 +210,7 @@ struct MAINboard : board_base
if(addr == 0xC010) { if(addr == 0xC010) {
if(debug & DEBUG_RW) printf("write KBDSTRB\n"); if(debug & DEBUG_RW) printf("write KBDSTRB\n");
// reset keyboard latch // reset keyboard latch
get_any_key_down_and_clear_strobe();
return true; return true;
} }
if(addr == 0xC030) { if(addr == 0xC030) {
@ -1146,6 +1153,7 @@ int main(int argc, char **argv)
CPU6502 cpu; CPU6502 cpu;
while(1) { while(1) {
poll_keyboard();
cpu.cycle(bus); cpu.cycle(bus);
// printf("> "); // printf("> ");
// char line[512]; // char line[512];

View File

@ -68,7 +68,7 @@ static int ttyraw(int fd)
newtermios.c_cflag |= CS8; newtermios.c_cflag |= CS8;
/* Set 8 bits per character. */ /* Set 8 bits per character. */
newtermios.c_oflag &= ~(OPOST); // newtermios.c_oflag &= ~(OPOST);
/* This includes things like expanding tabs to spaces. */ /* This includes things like expanding tabs to spaces. */
newtermios.c_cc[VMIN] = 1; newtermios.c_cc[VMIN] = 1;