From f302fe21f6fc4450cd38d70a34f73d4f420ec832 Mon Sep 17 00:00:00 2001 From: Udo Munk Date: Tue, 14 May 2024 08:46:02 +0200 Subject: [PATCH] cleanup everything --- arduino_8080.ino | 6 ++---- iosim.h | 9 +++++---- memsim.h | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/arduino_8080.ino b/arduino_8080.ino index ba3ba19..65e09f6 100644 --- a/arduino_8080.ino +++ b/arduino_8080.ino @@ -7,7 +7,7 @@ // 04-MAY-2024 Release 1.0 implements a very basic 8080 system // 06-MAY-2024 Release 1.1 add support for a ROM in flash // 07-MAY-2024 Release 1.2 move 8080 memory into a FRAM -// 13-MAY-2024 Release 1.2.1 can run MITS Alatir BASIC +// 13-MAY-2024 Release 1.2.1 can run MITS Altair BASIC // //#define DEBUG // enables some debug messages @@ -19,8 +19,6 @@ #define UAP 7 // chip select pin for FRAM (default) #define FRAM_CS 10 -// FRAM address size, this is for the 512 KB module -#define FRAM_ADDR_SIZE 3 // data types for the 8080 CPU typedef unsigned char BYTE; @@ -2796,7 +2794,7 @@ void setup() ; // Wait for serial port to connect. Needed for native USB randomSeed(analogRead(UAP)); SPI.setClockDivider(SPI_CLOCK_DIV2); - if (!fram.begin(FRAM_ADDR_SIZE)) { + if (!fram.begin()) { Serial.println(F("No FRAM found")); exit(1); } diff --git a/iosim.h b/iosim.h index 856b985..5797e7a 100644 --- a/iosim.h +++ b/iosim.h @@ -9,6 +9,7 @@ // static BYTE sio_last; // last byte read from the UART + BYTE fp_value; // the value for port 255 read // I/O function port 0 read: // read status of the Arduino UART and return: @@ -31,10 +32,10 @@ static BYTE p000_in(void) static BYTE p001_in(void) { if (!Serial.available()) // someone reading without checking first - return sio_last; + return (sio_last); else { sio_last = Serial.read(); - return sio_last; + return (sio_last); } } @@ -55,7 +56,7 @@ BYTE io_in(BYTE addrl, BYTE addrh) if ((addrl <= 4) && (*port_in[addrl] != 0)) // for now we use 0-4 return ((*port_in[addrl]) ()); else if (addrl == 255) // and 255, frontpanel port - return 0; + return (fp_value); else return (0xff); // all other return 0xff } @@ -88,7 +89,7 @@ const static void (*port_out[5]) (BYTE) = { 0 // port 4 }; -// write a byte to 8080 CPU I/O +// Write a byte to 8080 CPU I/O void io_out(BYTE addrl, BYTE addrh, BYTE data) { if ((addrl <= 4) && (*port_out[addrl] != 0)) // for now we use 0-4 diff --git a/memsim.h b/memsim.h index b46dbd0..25d32a7 100644 --- a/memsim.h +++ b/memsim.h @@ -21,7 +21,7 @@ Adafruit_FRAM_SPI fram = Adafruit_FRAM_SPI(FRAM_CS, 40000000); // setup FRAM void init_memory(void) { - long i; + uint32_t i; // copy our 8080 code from flash into FRAM for (i = 0; i < code_length; i++) @@ -35,12 +35,12 @@ void init_memory(void) // read a byte from 8080 CPU memory address addr static inline BYTE memrdr(WORD addr) { - return fram.read8(addr); + return fram.read8((uint32_t) addr); } // write a byte data into 8080 CPU RAM at address addr static inline void memwrt(WORD addr, BYTE data) { if (addr < 0xff00) // top memory page write protected for MITS BASIC - fram.write8(addr, data); + fram.write8((uint32_t) addr, data); }