mirror of https://github.com/smartykit/apple1.git
Remove old drivers
This commit is contained in:
parent
4081ce1833
commit
3be3b3ec7c
|
@ -1,110 +0,0 @@
|
||||||
/* SmartyKit Apple I replica - keyboard driver
|
|
||||||
* http://apple1.smartykit.org/
|
|
||||||
* Copyright (C) 2019, Sergey Panarin <contact@smartykit.org>
|
|
||||||
*
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include "PS2Keyboard.h"
|
|
||||||
|
|
||||||
const int DataPin = 3;
|
|
||||||
const int IRQpin = 2;
|
|
||||||
|
|
||||||
|
|
||||||
const int pinKBDCR = 12; //
|
|
||||||
|
|
||||||
int DataBus[8] = {4, 5, 6, 7, 8, 9, 10, 11};
|
|
||||||
|
|
||||||
PS2Keyboard keyboard;
|
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
for (int count = 1; count <= 8; count++) {
|
|
||||||
pinMode(DataBus[count-1], OUTPUT);
|
|
||||||
};
|
|
||||||
pinMode(pinKBDCR, OUTPUT);
|
|
||||||
KBDCR_Disable();
|
|
||||||
|
|
||||||
delay(1000);
|
|
||||||
keyboard.begin(DataPin, IRQpin);
|
|
||||||
Serial.begin(9600);
|
|
||||||
Serial.println("Keyboard:");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void KBDCR_Enable()
|
|
||||||
{
|
|
||||||
digitalWrite(pinKBDCR, HIGH);
|
|
||||||
}
|
|
||||||
void KBDCR_Disable()
|
|
||||||
{
|
|
||||||
digitalWrite(pinKBDCR, LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
KBDCR_Disable();
|
|
||||||
|
|
||||||
if (keyboard.available()) {
|
|
||||||
|
|
||||||
// read the next key
|
|
||||||
char c = keyboard.read();
|
|
||||||
/*
|
|
||||||
// check for some of the special keys
|
|
||||||
if (c == PS2_ENTER) {
|
|
||||||
Serial.println();
|
|
||||||
} else if (c == PS2_TAB) {
|
|
||||||
Serial.print("[Tab]");
|
|
||||||
} else if (c == PS2_ESC) {
|
|
||||||
Serial.print("[ESC]");
|
|
||||||
} else if (c == PS2_PAGEDOWN) {
|
|
||||||
Serial.print("[PgDn]");
|
|
||||||
} else if (c == PS2_PAGEUP) {
|
|
||||||
Serial.print("[PgUp]");
|
|
||||||
} else if (c == PS2_LEFTARROW) {
|
|
||||||
Serial.print("[Left]");
|
|
||||||
} else if (c == PS2_RIGHTARROW) {
|
|
||||||
Serial.print("[Right]");
|
|
||||||
} else if (c == PS2_UPARROW) {
|
|
||||||
Serial.print("[Up]");
|
|
||||||
} else if (c == PS2_DOWNARROW) {
|
|
||||||
Serial.print("[Down]");
|
|
||||||
} else if (c == PS2_DELETE) {
|
|
||||||
Serial.print("[Del]");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// otherwise, just print all normal characters
|
|
||||||
Serial.print(c);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//process Backspace, Left Arrow, Delete as Apple I backspace '_'
|
|
||||||
if (c == PS2_BACKSPACE) {
|
|
||||||
c = '_';
|
|
||||||
} else if (c == PS2_LEFTARROW) {
|
|
||||||
c = '_';
|
|
||||||
} else if (c == PS2_DELETE) {
|
|
||||||
c = '_';
|
|
||||||
}
|
|
||||||
|
|
||||||
//print c to register
|
|
||||||
for (int count = 1; count <= 8 ; count++)
|
|
||||||
{
|
|
||||||
if ((int)c & (1 << (count-1)))
|
|
||||||
digitalWrite(DataBus[count-1], HIGH);
|
|
||||||
else
|
|
||||||
digitalWrite(DataBus[count-1], LOW);
|
|
||||||
}
|
|
||||||
digitalWrite(DataBus[7], HIGH);
|
|
||||||
KBDCR_Enable();
|
|
||||||
delay(4);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
/* SmartyKit Apple I replica - video driver
|
|
||||||
* http://apple1.smartykit.org/
|
|
||||||
* Copyright (C) 2019, Sergey Panarin <contact@smartykit.org>
|
|
||||||
*
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <TVout.h>
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
const int IRQpin = 2; // write to display
|
|
||||||
|
|
||||||
const int pinDA = 12; // read
|
|
||||||
|
|
||||||
//int DataBus[8] = {4, 5, 6, 7, 8, 9, 10, 11};
|
|
||||||
//TV uses pin 7 and pin 9
|
|
||||||
int DataBus[8] = {4, 5, 6, 3, 8, 13, 10, 11};
|
|
||||||
|
|
||||||
|
|
||||||
int bitDA = 0;
|
|
||||||
|
|
||||||
byte scan_code=0;
|
|
||||||
|
|
||||||
TVout TV;
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
TV.begin(PAL, 128, 96);
|
|
||||||
TV.selectFont(font6x8);
|
|
||||||
TV.println("Hello!\r\nI am SmartyKit Apple I replica\n");
|
|
||||||
|
|
||||||
delay(1000);
|
|
||||||
for (int count = 1; count <= 8; count++) {
|
|
||||||
pinMode(DataBus[count-1], INPUT);
|
|
||||||
};
|
|
||||||
pinMode(IRQpin, INPUT);
|
|
||||||
pinMode(pinDA, OUTPUT);
|
|
||||||
|
|
||||||
//attaching an IRQ to IRQpin
|
|
||||||
attachInterrupt(0, videoCharInterrupt, RISING);
|
|
||||||
Serial.begin(9600);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
delay(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//interruption service routine (ISR)
|
|
||||||
void videoCharInterrupt(void) {
|
|
||||||
|
|
||||||
scan_code = 0;
|
|
||||||
for (int count = 1; count <= 8 ; count++) {
|
|
||||||
int pinValue = digitalRead(DataBus[count-1]);
|
|
||||||
scan_code |= pinValue << (count-1);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (scan_code == 0x7F)
|
|
||||||
return; //skip initial setup value
|
|
||||||
|
|
||||||
bitDA = 1;
|
|
||||||
digitalWrite(pinDA, HIGH);
|
|
||||||
|
|
||||||
if (scan_code != 127)
|
|
||||||
scan_code -= 128;
|
|
||||||
|
|
||||||
if (scan_code == 0xD)
|
|
||||||
{
|
|
||||||
Serial.println();
|
|
||||||
TV.println("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Serial.print((char)scan_code);
|
|
||||||
TV.print((char)scan_code);
|
|
||||||
}
|
|
||||||
|
|
||||||
bitDA = 0;
|
|
||||||
digitalWrite(pinDA, LOW);
|
|
||||||
}
|
|
|
@ -1,123 +0,0 @@
|
||||||
/* SmartyKit Apple I replica - video driver
|
|
||||||
* http://apple1.smartykit.org/
|
|
||||||
* Copyright (C) 2019, Sergey Panarin <contact@smartykit.org>
|
|
||||||
*
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <TVout.h>
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
const int IRQpin = 2; // write to display
|
|
||||||
|
|
||||||
const int pinDA = 12; // read
|
|
||||||
|
|
||||||
//int DataBus[8] = {4, 5, 6, 7, 8, 9, 10, 11};
|
|
||||||
//TV uses pin 7 and pin 9
|
|
||||||
int DataBus[8] = {4, 5, 6, 3, 8, 13, 10, 11};
|
|
||||||
|
|
||||||
|
|
||||||
int bitDA = 0;
|
|
||||||
|
|
||||||
byte scan_code=0;
|
|
||||||
|
|
||||||
int color = WHITE;
|
|
||||||
const int CHAR_BUFFER = 32 * 16; //32 columns and 16 rows
|
|
||||||
char videoBuffer[CHAR_BUFFER];
|
|
||||||
int bufferLen = 0;
|
|
||||||
|
|
||||||
TVout TV;
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
pinMode(pinDA, OUTPUT);
|
|
||||||
digitalWrite(pinDA, HIGH); //wait until video setup is ready
|
|
||||||
|
|
||||||
|
|
||||||
TV.begin(NTSC, 128, 96);
|
|
||||||
TV.selectFont(font4x6);
|
|
||||||
TV.println("Hello!\r\nI am SmartyKit Apple I replica\n");
|
|
||||||
|
|
||||||
delay(1000);
|
|
||||||
for (int count = 1; count <= 8; count++) {
|
|
||||||
pinMode(DataBus[count-1], INPUT);
|
|
||||||
};
|
|
||||||
pinMode(IRQpin, INPUT);
|
|
||||||
|
|
||||||
//attaching an IRQ to IRQpin
|
|
||||||
attachInterrupt(0, videoCharInterrupt, RISING);
|
|
||||||
Serial.begin(9600);
|
|
||||||
digitalWrite(pinDA, LOW); //default state after restart = 0 (ready to print)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
|
|
||||||
|
|
||||||
//TV.printChar(TV._cursorX, TV._cursorY, "@");
|
|
||||||
TV.drawLine(TV._cursorX, TV._cursorY + pgm_read_byte(TV.font + 1) - 1, TV._cursorX + pgm_read_byte(TV.font), TV._cursorY + pgm_read_byte(TV.font + 1) - 1, (char)color);
|
|
||||||
if (color == WHITE)
|
|
||||||
color = BLACK;
|
|
||||||
else
|
|
||||||
color = WHITE;
|
|
||||||
|
|
||||||
delay(500);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//interruption service routine (ISR)
|
|
||||||
void videoCharInterrupt(void) {
|
|
||||||
bitDA = 1;
|
|
||||||
digitalWrite(pinDA, HIGH);
|
|
||||||
|
|
||||||
scan_code = 0;
|
|
||||||
for (int count = 1; count <= 8 ; count++) {
|
|
||||||
int pinValue = digitalRead(DataBus[count-1]);
|
|
||||||
scan_code |= pinValue << (count-1);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (scan_code == 0x7F)
|
|
||||||
return; //skip initial setup value
|
|
||||||
|
|
||||||
scan_code = scan_code & 0x7F; //clear bit 7
|
|
||||||
|
|
||||||
// if (scan_code != 127)
|
|
||||||
// scan_code -= 128;
|
|
||||||
|
|
||||||
if (scan_code == 0xD)
|
|
||||||
{
|
|
||||||
Serial.println();
|
|
||||||
TV.println("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//make all symbols uppercase
|
|
||||||
if (scan_code >= 0x60)
|
|
||||||
scan_code -= 0x20;
|
|
||||||
|
|
||||||
//print only visible chars, starting from blanc
|
|
||||||
if (scan_code >= 0x20)
|
|
||||||
{
|
|
||||||
Serial.print((char)scan_code);
|
|
||||||
TV.print((char)scan_code);
|
|
||||||
}
|
|
||||||
//backspace
|
|
||||||
if (scan_code == 0x8)
|
|
||||||
TV.print((char)scan_code);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bitDA = 0;
|
|
||||||
digitalWrite(pinDA, LOW);
|
|
||||||
}
|
|
53
index.css
53
index.css
|
@ -1,53 +0,0 @@
|
||||||
#m-line {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
#hexLabels {
|
|
||||||
margin-left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#open {
|
|
||||||
margin-left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#addFrame {
|
|
||||||
margin-left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#anim {
|
|
||||||
word-wrap: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.cell {
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
border: 1px solid black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cell-active {
|
|
||||||
background-color: orange;
|
|
||||||
}
|
|
||||||
|
|
||||||
.row {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.binLabel {
|
|
||||||
height: 40px;
|
|
||||||
border: 1px solid black;
|
|
||||||
width: 85px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hexLabel {
|
|
||||||
height: 40px;
|
|
||||||
border: 1px solid black;
|
|
||||||
width: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.label-p {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 0;
|
|
||||||
text-align: center;
|
|
||||||
padding-top: 11px;
|
|
||||||
}
|
|
119
index.js
119
index.js
|
@ -1,119 +0,0 @@
|
||||||
|
|
||||||
let matrix = [];
|
|
||||||
let anim = "";
|
|
||||||
let hexOut = "";
|
|
||||||
|
|
||||||
function main() {
|
|
||||||
for (let i = 0; i < 8; i++) {
|
|
||||||
matrix[i] = [];
|
|
||||||
for (let j = 0; j < 8; j++) {
|
|
||||||
matrix[i][j] = 0;
|
|
||||||
document.getElementById(`cell_${i}-${j}`).onclick = cellOnClick;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById("file").onchange = handleFileSelect;
|
|
||||||
document.getElementById("addFrame").onclick = handleFrameAdd;
|
|
||||||
document.getElementById("open").onclick = (e) => {
|
|
||||||
document.getElementById("file").click();
|
|
||||||
e.preventDefault();
|
|
||||||
};
|
|
||||||
|
|
||||||
updateOut();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleFileSelect(e) {
|
|
||||||
let file = e.target.files[0]; // FileList object
|
|
||||||
|
|
||||||
let reader = new FileReader();
|
|
||||||
reader.onload = (e) => {
|
|
||||||
processOpenedFile(e.target.result);
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsText(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleFrameAdd(e) {
|
|
||||||
anim += hexOut;
|
|
||||||
document.getElementById("anim").innerText = anim;
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
function processOpenedFile(data) {
|
|
||||||
let pairs = [];
|
|
||||||
for(let i = 0; i < data.length; i += 2) {
|
|
||||||
pairs[pairs.length] = data.substr(i, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < 8; i++) {
|
|
||||||
let bits = "";
|
|
||||||
let n = parseInt(pairs[i], 16);
|
|
||||||
|
|
||||||
for (let i = 128; i >= 1; i /= 2) {
|
|
||||||
bits += n & i ? '1' : '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let z = 0; z < 8; z++) {
|
|
||||||
matrix[i][z] = parseInt(bits.charAt(z), 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateOut(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function cellOnClick(e) {
|
|
||||||
let id = e.srcElement.id;
|
|
||||||
let cord = id.split("_")[1].split("-");
|
|
||||||
let x = cord[0];
|
|
||||||
let y = cord[1];
|
|
||||||
|
|
||||||
if (matrix[x][y] === 0) {
|
|
||||||
e.srcElement.classList.add("cell-active");
|
|
||||||
matrix[x][y] = 1;
|
|
||||||
} else {
|
|
||||||
e.srcElement.classList.remove("cell-active");
|
|
||||||
matrix[x][y] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateOut();
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateOut(redraw) {
|
|
||||||
let hexString = "";
|
|
||||||
hexOut = "";
|
|
||||||
|
|
||||||
for (let i = 0; i < 8; i++) {
|
|
||||||
let binString = "";
|
|
||||||
|
|
||||||
for (let j = 0; j < 8; j++) { //for (let j = 7; j >= 0; j--) {
|
|
||||||
binString += matrix[i][j];
|
|
||||||
|
|
||||||
if (redraw) {
|
|
||||||
let elem = document.getElementById(`cell_${i}-${j}`);
|
|
||||||
if (matrix[i][j] === 0) {
|
|
||||||
elem.classList.remove("cell-active");
|
|
||||||
} else {
|
|
||||||
elem.classList.add("cell-active");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let n = parseInt(binString, 2).toString(16).toUpperCase();
|
|
||||||
if (n.length === 1)
|
|
||||||
n = "0" + n;
|
|
||||||
|
|
||||||
document.getElementById(`hexLabel-${i}`).innerHTML = n;
|
|
||||||
document.getElementById(`binLabel-${i}`).innerHTML = binString;
|
|
||||||
hexString += n;
|
|
||||||
hexOut += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById("download").href = `data:text/plain;charset=utf-8,%EF%BB%BF${encodeURIComponent(hexOut)}`;
|
|
||||||
document.getElementById("out").innerText = hexString;
|
|
||||||
|
|
||||||
}
|
|
||||||
function startDrawing()
|
|
||||||
{
|
|
||||||
alert("Start drawing");
|
|
||||||
}
|
|
Loading…
Reference in New Issue