From aab45329c675069d56c6411f7d3125f62733ccec Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Sat, 20 Feb 2021 09:13:46 +0000 Subject: [PATCH] fix memory config --- apple1.ino => Apple1.ino | 15 ++++++++++++--- Makefile | 13 +++++++------ README.md | 2 +- config.h | 21 ++++++++++++++------- 4 files changed, 34 insertions(+), 17 deletions(-) rename apple1.ino => Apple1.ino (83%) diff --git a/apple1.ino b/Apple1.ino similarity index 83% rename from apple1.ino rename to Apple1.ino index f238cec..4d6339c 100644 --- a/apple1.ino +++ b/Apple1.ino @@ -18,7 +18,7 @@ prom b(basic, sizeof(basic)); prom m(monitor, sizeof(monitor)); #endif -ram pages[RAM_SIZE / 1024]; +ram pages[RAM_PAGES]; //socket_filer files("apple1"); flash_filer files(PROGRAMS); io io(files); @@ -45,16 +45,25 @@ void reset() { void setup() { #if defined(DEBUGGING) || defined(CPU_DEBUG) Serial.begin(TERMINAL_SPEED); + Serial.println(); + Serial.printf("RAM: %dkB at 0x0000", RAM_PAGES); + Serial.println(); +#if defined(USE_SPIRAM) + Serial.printf("SpiRAM: %dkB at 0x%04x", SPIRAM_EXTENT * Memory::page_size / 1024, SPIRAM_BASE); + Serial.println(); +#endif #endif hardware_init(cpu); - for (unsigned i = 0; i < RAM_SIZE; i += 1024) - memory.put(pages[i / 1024], i); + for (unsigned i = 0; i < RAM_PAGES; i++) + memory.put(pages[i], i * ram::page_size); #if defined(USE_SPIRAM) memory.put(sram, SPIRAM_BASE, SPIRAM_EXTENT); #endif + memory.put(io, 0xd000); + #if defined(KRUSADER) memory.put(k, 0xe000); #else diff --git a/Makefile b/Makefile index e38d341..7f33847 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,22 @@ t ?= esp32 +TERMINAL_SPEED := 115200 + ifeq ($t, esp8266) BOARD := d1_mini UPLOAD_SPEED := 921600 -TERMINAL_SPEED := 115200 FS_DIR := programs FLASH_SIZE := 4M1M F_CPU := 80 CPPFLAGS = -DUSER_SETUP_LOADED -DILI9341_DRIVER -DTFT_CS=PIN_D8 -DTFT_DC=PIN_D1 \ -DTFT_RST=-1 -DSPI_FREQUENCY=40000000 -DLOAD_GLCD \ - -DHARDWARE_H=\"hw/esp8266-pwm-fs.h\" -DTERMINAL_SPEED=$(TERMINAL_SPEED) -LIBRARIES := TFT_eSPI + -DHARDWARE_H=\"hw/esp8266-pwm-fs-23k256.h\" -DTERMINAL_SPEED=$(TERMINAL_SPEED) -DDEBUGGING=1 +LIBRARIES := TFT_eSPI SpiRAM endif ifeq ($t, tivac) BOARD := EK-LM4F120XL -CPPFLAGS := -DDEBUGGING -DHARDWARE_H=\"hw/lm4f-utft-sd.h\" +CPPFLAGS := -DDEBUGGING -DHARDWARE_H=\"hw/lm4f-utft-sd.h\" -DTERMINAL_SPEED=$(TERMINAL_SPEED) LIBRARIES := UTFT SD SpiRAM endif @@ -25,8 +26,8 @@ UPLOAD_SPEED := 921600 FS_DIR := programs CPPFLAGS = -DDEBUGGING -DCPU_DEBUG \ -DUSER_SETUP_LOADED -DILI9341_DRIVER -DTFT_CS=5 -DTFT_DC=2 \ - -DTFT_RST=-1 -DTFT_WIDTH=240 -DTFT_HEIGHT=320 \ - -DSPI_FREQUENCY=40000000 -DLOAD_GLCD + -DTFT_RST=-1 -DSPI_FREQUENCY=40000000 -DLOAD_GLCD \ + -DHARDWARE_H=\"hw/esp32-espi.h\" -DTERMINAL_SPEED=$(TERMINAL_SPEED) LIBRARIES = TFT_eSPI FS SPIFFS endif diff --git a/README.md b/README.md index e2be0f6..5af3f07 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Apple-1 Emulator ================ -- Emulates an Apple-1 with 32k of RAM +- Emulates an Apple-1 with up to 52k of RAM - See [napple1](https://github.com/nobuh/napple1), [krusader](http://school.anhb.uwa.edu.au/personalpages/kwessen/apple1/Krusader.htm) and more [software](http://www.willegal.net/appleii/apple1-software.htm) diff --git a/config.h b/config.h index a28ea63..c66f632 100644 --- a/config.h +++ b/config.h @@ -1,12 +1,19 @@ -#ifndef _CONFIG_H -#define _CONFIG_H +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + +#define RAM_TOP 0xd000u + +#if (RAM_SIZE >= RAM_TOP) +#define RAM_PAGES (RAM_TOP / ram::page_size) + +#elif defined(USE_SPIRAM) +#define RAM_PAGES (RAM_SIZE / ram::page_size) +#define SPIRAM_BASE RAM_SIZE +#define SPIRAM_EXTENT min(RAM_TOP - SPIRAM_BASE, SPIRAM_SIZE) / Memory::page_size -#if defined(USE_SPIRAM) -#define RAM_SIZE 0x3000 -#define SPIRAM_BASE 0x3000 -#define SPIRAM_EXTENT (20 * 1024 / 256) #else -#define RAM_SIZE 0x8000 +#define RAM_PAGES (RAM_SIZE / ram::page_size) + #endif #define CPU_INSTRUCTIONS 1000