mirror of https://github.com/JorjBauer/aiie
importing old mouse work to new teensy 4.1
parent
dee3baed60
commit
fe46c4ab52
@ -0,0 +1,86 @@
|
||||
#include "mouse.h"
|
||||
#include <string.h>
|
||||
#include "mouse-rom.h"
|
||||
|
||||
Mouse::Mouse()
|
||||
{
|
||||
}
|
||||
|
||||
Mouse::~Mouse()
|
||||
{
|
||||
}
|
||||
|
||||
bool Mouse::Serialize(int8_t fd)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Mouse::Deserialize(int8_t fd)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Mouse::Reset()
|
||||
{
|
||||
}
|
||||
|
||||
uint8_t Mouse::readSwitches(uint8_t s)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
void Mouse::writeSwitches(uint8_t s, uint8_t v)
|
||||
{
|
||||
printf("unknown switch 0x%X\n", s);
|
||||
}
|
||||
|
||||
void Mouse::loadROM(uint8_t *toWhere)
|
||||
{
|
||||
uint8_t rom[256] = { 0x2c, 0x58, 0xff, 0x70, 0x1B, 0x38, 0x90, 0x18,
|
||||
0xb8, 0x50, 0x15, 0x01, 0x20, 0xae, 0xae, 0xae,
|
||||
0xae, 0x00, 0x6d, 0x75, 0x8e, 0x9f, 0xa4, 0x86,
|
||||
0xa9, 0x97, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae,
|
||||
0x48, 0x98, 0x48, 0x8a, 0x48, 0x08, 0x78, 0x20,
|
||||
0x58, 0xFF, 0xBA, 0xBD, 0x00, 0x01, 0xAA, 0x0A,
|
||||
0x0A, 0x0A, 0x0A, 0xA8, 0x28, 0x50, 0x0F, 0xA5,
|
||||
0x38, 0xd0, 0x0d, 0x8a, 0x45, 0x39, 0xd0, 0x08,
|
||||
0xa9, 0x05, 0x85, 0x38, 0xd0, 0x0b, 0xb0, 0x09,
|
||||
0x68, 0xaa, 0x68, 0xea, 0x68, 0x99, 0x80, 0xc0,
|
||||
0x60, 0x99, 0x81, 0xc0, 0x68, 0xbd, 0x38, 0x06,
|
||||
0xaa, 0x68, 0xa8, 0x68, 0xbd, 0x00, 0x02, 0x60,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xc9, 0x10, 0xb0,
|
||||
0x3f, 0x99, 0x82, 0xc0, 0x60, 0x48, 0x18, 0x90,
|
||||
0x39, 0x99, 0x83, 0xc0, 0xbd, 0xb8, 0x06, 0x29,
|
||||
|
||||
0x0E, 0xD0, 0x01, 0x38, 0x68, 0x60, 0xc9, 0x02,
|
||||
0xb0, 0x26, 0x99, 0x83, 0xc0, 0x60, 0xa9, 0x04,
|
||||
0x99, 0x83, 0xc0, 0x18, 0xea, 0xea, 0x60, 0xea,
|
||||
0xa9, 0x02, 0x99, 0x83, 0xc0, 0x18, 0x60, 0xea,
|
||||
0xa9, 0x05, 0xd0, 0xf6, 0xea, 0xa9, 0x06, 0xd0,
|
||||
0xf1, 0xea, 0xa9, 0x07, 0xd0, 0xec, 0xa2, 0x03,
|
||||
0x38, 0x60, 0x08, 0xa5, 0x00, 0x48, 0xa9, 0x60,
|
||||
0x85, 0x00, 0x78, 0x20, 0x00, 0x00, 0xba, 0x68,
|
||||
0x85, 0x00, 0xbd, 0x00, 0x01, 0x28, 0xaa, 0x0a,
|
||||
0x0a, 0x0a, 0x0a, 0xa8, 0xa9, 0x03, 0x18, 0x90,
|
||||
0xa8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xd6, 0xff, 0xff, 0xff, 0x01 };
|
||||
memcpy(toWhere, rom, 256);
|
||||
}
|
||||
|
||||
bool Mouse::hasExtendedRom()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Mouse::loadExtendedRom(uint8_t *toWhere, uint16_t byteOffset)
|
||||
{
|
||||
printf("loading extended rom for the mouse\n");
|
||||
for (int i=0; i<256; i++) {
|
||||
toWhere[i] = romData[i + byteOffset];
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
#ifndef __APPLEMOUSE_H
|
||||
#define __APPLEMOUSE_H
|
||||
|
||||
#ifdef TEENSYDUINO
|
||||
#include <Arduino.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "applemmu.h"
|
||||
#include "slot.h"
|
||||
|
||||
class Mouse : public Slot {
|
||||
public:
|
||||
Mouse();
|
||||
virtual ~Mouse();
|
||||
|
||||
virtual bool Serialize(int8_t fd);
|
||||
virtual bool Deserialize(int8_t fd);
|
||||
|
||||
virtual void Reset(); // used by BIOS cold-boot
|
||||
virtual uint8_t readSwitches(uint8_t s);
|
||||
virtual void writeSwitches(uint8_t s, uint8_t v);
|
||||
virtual void loadROM(uint8_t *toWhere);
|
||||
|
||||
virtual bool hasExtendedRom();
|
||||
virtual void loadExtendedRom(uint8_t *toWhere, uint16_t byteOffset);
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,43 @@
|
||||
#include "pia6821.h"
|
||||
|
||||
PIA6821::PIA6821()
|
||||
{
|
||||
}
|
||||
|
||||
PIA6821::~PIA6821()
|
||||
{
|
||||
}
|
||||
|
||||
uint8_t PIA6821::read(uint8_t addr)
|
||||
{
|
||||
uint8_t rv;
|
||||
|
||||
switch (addr) {
|
||||
case DDRA:
|
||||
if (cra & 0x04) { // DDR or Peripherial Interface access control
|
||||
// peripheral
|
||||
// rv = readPeripheralA();
|
||||
// FIXME continue here
|
||||
} else {
|
||||
rv = ddra;
|
||||
}
|
||||
break;
|
||||
case CTLA:
|
||||
rv = cra;
|
||||
break;
|
||||
case DDRB:
|
||||
if (crb & 0x04) {
|
||||
// rv = readPeripheralB();
|
||||
// FIXME continue here
|
||||
} else {
|
||||
rv = ddrb;
|
||||
}
|
||||
break;
|
||||
case CTLB:
|
||||
rv = crb;
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
#ifndef _PIA6821_H
|
||||
#define _PIA6821_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// http://webpages.charter.net/coinopcauldron/piaarticle.html
|
||||
|
||||
#define DDRA 0
|
||||
#define CTLA 1
|
||||
#define DDRB 2
|
||||
#define CTLB 3
|
||||
|
||||
class PIA6821 {
|
||||
public:
|
||||
PIA6821();
|
||||
~PIA6821();
|
||||
|
||||
uint8_t read(uint8_t addr);
|
||||
|
||||
|
||||
private:
|
||||
uint8_t porta, portb;
|
||||
uint8_t ddra, ddrb;
|
||||
uint8_t cra, crb; // control registers
|
||||
/*
|
||||
2 ports - porta, portb
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue