From d79f111260b25efd6d451d4512e63e60aded2b11 Mon Sep 17 00:00:00 2001 From: karllurman Date: Wed, 31 Oct 2018 15:05:11 +1100 Subject: [PATCH 1/7] Make file points to the appropriate toolchain GCC and G++ bins in /opt/linaro --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 79b1bd0..fb87d2b 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ SHELL = /bin/bash -o pipefail # using gcc version 5.4.1 20161213 (Linaro GCC 5.4-2017.01-rc2) -BASE = arm-linux-gnueabihf +BASE = /opt/linaro/bin/arm-linux-gnueabihf CC = $(BASE)-gcc LD = $(CC) From 7614950f67b677a660b2a4e0ca8d221300412712 Mon Sep 17 00:00:00 2001 From: karllurman Date: Wed, 31 Oct 2018 15:05:33 +1100 Subject: [PATCH 2/7] Added a readme --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..fe47695 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Main_MiSTer + +Goal of this is to sort out container building for + +# Development Setup: Boot2Docker, Windows 7 + +- Download and install Docker - you won't be able to do Docker for Windows unless you are on a newer version of the OS. +- Once installed and tested, ssh into your boot2docker guest machine +- Issue this command to pull down a working linaro toolchain: +``` +docker pull wsbu/toolchain-linaro +``` +- Issue this command to run a bash on the linaro container and mount the repo root folder inside the container at /source: +``` +docker run -ti -v :/source wsbu/toolchain-linaro bash +``` +- Go into the /source folder +``` +cd /source +``` +- Make MiSTer +``` +root@d6f7eba5be6f:/source# make +sxmlc.c +ini_parser.cpp +minimig_hdd.cpp +cfg.cpp +spi.cpp +user_io.cpp +archie.cpp +st_ikbd.cpp +tzx2wav.cpp +x86.cpp +battery.cpp +hardware.cpp +st_tos.cpp +input.cpp +minimig_boot.cpp +brightness.cpp +DiskImage.cpp +file_io.cpp +fpga_io.cpp +minimig_config.cpp +sharpmz.cpp +minimig_fdd.cpp +menu.cpp +osd.cpp +main.cpp +MiSTer +``` From 94e560fa586149d2f19ff95fde5bd99d983fc285 Mon Sep 17 00:00:00 2001 From: karllurman Date: Wed, 31 Oct 2018 23:11:07 +1100 Subject: [PATCH 3/7] Created a support folder and move core ARM support code for minimig into it. Updated menu, osd, and user_io. Makefile also updated to account for new support folder --- Makefile | 14 +- menu.cpp | 87 ++- osd.cpp | 3 +- support.h | 4 + .../minimig/minimig_boot.cpp | 10 +- .../minimig/minimig_boot.h | 0 .../minimig/minimig_config.cpp | 114 ++-- .../minimig/minimig_config.h | 4 +- .../minimig/minimig_fdd.cpp | 90 +-- .../minimig/minimig_fdd.h | 6 +- .../minimig/minimig_hdd.cpp | 66 +-- .../minimig/minimig_hdd.h | 0 .../minimig/minimig_hdd_internal.h | 0 user_io.cpp | 531 +++++++++--------- 14 files changed, 467 insertions(+), 462 deletions(-) create mode 100644 support.h rename minimig_boot.cpp => support/minimig/minimig_boot.cpp (99%) rename minimig_boot.h => support/minimig/minimig_boot.h (100%) rename minimig_config.cpp => support/minimig/minimig_config.cpp (98%) rename minimig_config.h => support/minimig/minimig_config.h (97%) rename minimig_fdd.cpp => support/minimig/minimig_fdd.cpp (99%) rename minimig_fdd.h => support/minimig/minimig_fdd.h (96%) rename minimig_hdd.cpp => support/minimig/minimig_hdd.cpp (99%) rename minimig_hdd.h => support/minimig/minimig_hdd.h (100%) rename minimig_hdd_internal.h => support/minimig/minimig_hdd_internal.h (100%) diff --git a/Makefile b/Makefile index fb87d2b..3ba3869 100644 --- a/Makefile +++ b/Makefile @@ -9,15 +9,21 @@ CC = $(BASE)-gcc LD = $(CC) STRIP = $(BASE)-strip +INCLUDE = -I./ +INCLUDE = -I./support/minimig + PRJ = MiSTer SRC = $(wildcard *.c) SRC2 = $(wildcard *.cpp) +MINIMIG_SRC = $(wildcard ./support/minimig/*.cpp) -OBJ = $(SRC:.c=.o) $(SRC2:.cpp=.o) -DEP = $(SRC:.c=.d) $(SRC2:.cpp=.d) +VPATH = ./:./support/minimig -CFLAGS = $(DFLAGS) -c -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DVDATE=\"`date +"%y%m%d"`\" -LFLAGS = -lc -lstdc++ -lrt +OBJ = $(SRC:.c=.o) $(SRC2:.cpp=.o) $(MINIMIG_SRC:.cpp=.o) +DEP = $(SRC:.c=.d) $(SRC2:.cpp=.d) $(MINIMIG_SRC:.cpp=.d) + +CFLAGS = $(DFLAGS) -c -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DVDATE=\"`date +"%y%m%d"`\" +LFLAGS = -lc -lstdc++ -lrt $(PRJ): $(OBJ) @$(info $@) diff --git a/menu.cpp b/menu.cpp index 6066859..6d68c16 100644 --- a/menu.cpp +++ b/menu.cpp @@ -38,17 +38,14 @@ along with this program. If not, see . #include "string.h" #include "file_io.h" #include "osd.h" -#include "minimig_fdd.h" -#include "minimig_hdd.h" #include "hardware.h" -#include "minimig_config.h" #include "menu.h" #include "user_io.h" #include "st_tos.h" #include "debug.h" -#include "minimig_boot.h" +#include "support.h" #include "archie.h" -#include "sharpmz.h" +#include "sharpmz.h" #include "fpga_io.h" #include #include "cfg.h" @@ -655,7 +652,7 @@ void HandleUI(void) case CORE_TYPE_MIST: case CORE_TYPE_MINIMIG2: case CORE_TYPE_8BIT: - case CORE_TYPE_SHARPMZ: + case CORE_TYPE_SHARPMZ: case CORE_TYPE_ARCHIE: break; @@ -807,12 +804,12 @@ void HandleUI(void) } - // SHARPMZ Series Menu - This has been located within the sharpmz.cpp code base in order to keep updates to common code - // base to a minimum and shrink its size. The UI is called with the basic state data and it handles everything internally, - // only updating values in this function as necessary. - // - if (user_io_core_type() == CORE_TYPE_SHARPMZ) - sharpmz_ui(MENU_NONE1, MENU_NONE2, MENU_8BIT_SYSTEM1, MENU_FILE_SELECT1, &parentstate, &menustate, &menusub, &menusub_last, &menumask, SelectedPath, &helptext, helptext_custom, &fs_ExtLen, &fs_Options, &fs_MenuSelect, &fs_MenuCancel, fs_pFileExt, menu, select, up, down, left, right, plus, minus); + // SHARPMZ Series Menu - This has been located within the sharpmz.cpp code base in order to keep updates to common code + // base to a minimum and shrink its size. The UI is called with the basic state data and it handles everything internally, + // only updating values in this function as necessary. + // + if (user_io_core_type() == CORE_TYPE_SHARPMZ) + sharpmz_ui(MENU_NONE1, MENU_NONE2, MENU_8BIT_SYSTEM1, MENU_FILE_SELECT1, &parentstate, &menustate, &menusub, &menusub_last, &menumask, SelectedPath, &helptext, helptext_custom, &fs_ExtLen, &fs_Options, &fs_MenuSelect, &fs_MenuCancel, fs_pFileExt, menu, select, up, down, left, right, plus, minus); // Switch to current menu screen switch (menustate) @@ -1313,19 +1310,19 @@ void HandleUI(void) break; case MENU_8BIT_SYSTEM2: - if (menu) - { - switch (user_io_core_type()) - { - case CORE_TYPE_SHARPMZ: - menusub = menusub_last; - menustate = sharpmz_default_ui_state(); - break; - default: - menustate = MENU_NONE1; - break; - }; - } + if (menu) + { + switch (user_io_core_type()) + { + case CORE_TYPE_SHARPMZ: + menusub = menusub_last; + menustate = sharpmz_default_ui_state(); + break; + default: + menustate = MENU_NONE1; + break; + }; + } if (select) { @@ -1378,11 +1375,11 @@ void HandleUI(void) menustate = MENU_RESET1; menusub = 1; } - else if (user_io_core_type() == CORE_TYPE_SHARPMZ) - { - menustate = sharpmz_reset_config(1); - menusub = 0; - } + else if (user_io_core_type() == CORE_TYPE_SHARPMZ) + { + menustate = sharpmz_reset_config(1); + menusub = 0; + } break; case 5: // Save settings @@ -1394,10 +1391,10 @@ void HandleUI(void) archie_save_config(); menustate = MENU_ARCHIE_MAIN1; } - else if (user_io_core_type() == CORE_TYPE_SHARPMZ) - { - menustate = sharpmz_save_config(); - } + else if (user_io_core_type() == CORE_TYPE_SHARPMZ) + { + menustate = sharpmz_save_config(); + } else { char *filename = user_io_create_config_name(); @@ -1445,10 +1442,10 @@ void HandleUI(void) menusub = 0; menustate = MENU_8BIT_MAIN1; break; - case CORE_TYPE_SHARPMZ: - menusub = menusub_last; - menustate = sharpmz_default_ui_state(); - break; + case CORE_TYPE_SHARPMZ: + menusub = menusub_last; + menustate = sharpmz_default_ui_state(); + break; } } @@ -2444,7 +2441,7 @@ void HandleUI(void) case MENU_RESET2: m = 0; if (user_io_core_type() == CORE_TYPE_MINIMIG2) m = 1; - if (user_io_core_type() == CORE_TYPE_SHARPMZ) m = 2; + if (user_io_core_type() == CORE_TYPE_SHARPMZ) m = 2; if (select && menusub == 0) { @@ -2453,11 +2450,11 @@ void HandleUI(void) menustate = MENU_NONE1; MinimigReset(); } - else if(m == 2) - { - menustate = MENU_8BIT_SYSTEM1; - sharpmz_reset_config(1); - } + else if(m == 2) + { + menustate = MENU_8BIT_SYSTEM1; + sharpmz_reset_config(1); + } else { char *filename = user_io_create_config_name(); @@ -2736,7 +2733,7 @@ void HandleUI(void) break; case MENU_ROMFILE_SELECTED: - SetKickstart(SelectedPath); + SetKickstart(SelectedPath); menustate = MENU_SETTINGS_MEMORY1; break; diff --git a/osd.cpp b/osd.cpp index 8a99ad3..86c5597 100644 --- a/osd.cpp +++ b/osd.cpp @@ -45,7 +45,8 @@ as rotated copies of the first 128 entries. -- AMR #include "logo.h" #include "user_io.h" #include "hardware.h" -#include "minimig_config.h" + +#include "support.h" static int osd_size = 8; diff --git a/support.h b/support.h new file mode 100644 index 0000000..21f78ae --- /dev/null +++ b/support.h @@ -0,0 +1,4 @@ +#include "support/minimig/minimig_config.h" +#include "support/minimig/minimig_boot.h" +#include "support/minimig/minimig_fdd.h" +#include "support/minimig/minimig_hdd.h" diff --git a/minimig_boot.cpp b/support/minimig/minimig_boot.cpp similarity index 99% rename from minimig_boot.cpp rename to support/minimig/minimig_boot.cpp index 9c1cd73..5b7f3fb 100644 --- a/minimig_boot.cpp +++ b/support/minimig/minimig_boot.cpp @@ -6,13 +6,13 @@ #include "string.h" #include "stdio.h" #include "minimig_boot.h" -#include "hardware.h" -#include "osd.h" -#include "spi.h" -#include "file_io.h" +#include "../../hardware.h" +#include "../../osd.h" +#include "../../spi.h" +#include "../../file_io.h" #include "minimig_config.h" #include "minimig_fdd.h" -#include "cfg.h" +#include "../../cfg.h" static uint8_t buffer[1024]; diff --git a/minimig_boot.h b/support/minimig/minimig_boot.h similarity index 100% rename from minimig_boot.h rename to support/minimig/minimig_boot.h diff --git a/minimig_config.cpp b/support/minimig/minimig_config.cpp similarity index 98% rename from minimig_config.cpp rename to support/minimig/minimig_config.cpp index d6ac839..8751b1a 100644 --- a/minimig_config.cpp +++ b/support/minimig/minimig_config.cpp @@ -3,19 +3,19 @@ #include #include #include -#include -#include +#include +#include -#include "hardware.h" +#include "../../hardware.h" #include "minimig_boot.h" -#include "file_io.h" -#include "osd.h" +#include "../../file_io.h" +#include "../../osd.h" #include "minimig_fdd.h" #include "minimig_hdd.h" -#include "menu.h" +#include "../../menu.h" #include "minimig_config.h" -#include "user_io.h" -#include "input.h" +#include "../../user_io.h" +#include "../../input.h" typedef struct { @@ -237,30 +237,30 @@ static char UploadActionReplay() static char* GetConfigurationName(int num) { static char path[128]; - sprintf(path, "%s/%s", getRootDir(), CONFIG_DIR); + sprintf(path, "%s/%s", getRootDir(), CONFIG_DIR); - DIR *d; - struct dirent *dir; - d = opendir(path); - if (d) - { - if(num) sprintf(path, "minimig%d", num); - else sprintf(path, "minimig.cfg", num); - - while ((dir = readdir(d)) != NULL) - { - int len = strlen(dir->d_name); - if (len>10 && !strncasecmp(dir->d_name, path, strlen(path)) && !strcasecmp(dir->d_name+len-4, ".cfg")) - { - closedir(d); - strcpy(path, dir->d_name); - return path; - } - } - closedir(d); - } - - return NULL; + DIR *d; + struct dirent *dir; + d = opendir(path); + if (d) + { + if(num) sprintf(path, "minimig%d", num); + else sprintf(path, "minimig.cfg", num); + + while ((dir = readdir(d)) != NULL) + { + int len = strlen(dir->d_name); + if (len>10 && !strncasecmp(dir->d_name, path, strlen(path)) && !strcasecmp(dir->d_name+len-4, ".cfg")) + { + closedir(d); + strcpy(path, dir->d_name); + return path; + } + } + closedir(d); + } + + return NULL; } unsigned char SaveConfiguration(int num) @@ -324,8 +324,8 @@ static void ApplyConfiguration(char reloadkickstart) printf("Secondary Slave HDD is %s.\n", config.hardfile[3].enabled ? "enabled" : "disabled"); } - rstval = SPI_CPU_HLT; - spi_osd_cmd8(OSD_CMD_RST, rstval); + rstval = SPI_CPU_HLT; + spi_osd_cmd8(OSD_CMD_RST, rstval); spi_osd_cmd8(OSD_CMD_HDD, (config.enable_ide ? 1 : 0) | (OpenHardfile(0) ? 2 : 0) | (OpenHardfile(1) ? 4 : 0) | (OpenHardfile(2) ? 8 : 0) | (OpenHardfile(3) ? 16 : 0)); ConfigMemory(config.memory); @@ -340,7 +340,7 @@ static void ApplyConfiguration(char reloadkickstart) { printf("Reloading kickstart ...\n"); rstval |= (SPI_RST_CPU | SPI_CPU_HLT); - spi_osd_cmd8(OSD_CMD_RST, rstval); + spi_osd_cmd8(OSD_CMD_RST, rstval); if (!UploadKickstart(config.kickstart)) { strcpy(config.kickstart, "Amiga/KICK.ROM"); @@ -356,21 +356,21 @@ static void ApplyConfiguration(char reloadkickstart) } } rstval |= (SPI_RST_USR | SPI_RST_CPU); - spi_osd_cmd8(OSD_CMD_RST, rstval); + spi_osd_cmd8(OSD_CMD_RST, rstval); } else { printf("Resetting ...\n"); rstval |= (SPI_RST_USR | SPI_RST_CPU); - spi_osd_cmd8(OSD_CMD_RST, rstval); + spi_osd_cmd8(OSD_CMD_RST, rstval); } - rstval = 0; - spi_osd_cmd8(OSD_CMD_RST, rstval); + rstval = 0; + spi_osd_cmd8(OSD_CMD_RST, rstval); ConfigVideo(config.filter.hires, config.filter.lores, config.scanlines); ConfigAudio(config.audio); - ConfigAutofire(config.autofire, 0xC); + ConfigAutofire(config.autofire, 0xC); } unsigned char LoadConfiguration(int num) @@ -461,12 +461,12 @@ unsigned char LoadConfiguration(int num) updatekickstart = true; BootPrintEx(">>> No config found. Using defaults. <<<"); } - - for (int i = 0; i < 4; i++) - { - df[i].status = 0; - FileClose(&df[i].file); - } + + for (int i = 0; i < 4; i++) + { + df[i].status = 0; + FileClose(&df[i].file); + } // print config to boot screen char cfg_str[256]; @@ -494,17 +494,17 @@ unsigned char LoadConfiguration(int num) return(result); } -void MinimigReset() -{ - ApplyConfiguration(0); - user_io_rtc_reset(); -} - -void SetKickstart(char *name) -{ +void MinimigReset() +{ + ApplyConfiguration(0); + user_io_rtc_reset(); +} + +void SetKickstart(char *name) +{ int len = strlen(name); if (len > (sizeof(config.kickstart) - 1)) len = sizeof(config.kickstart) - 1; - memcpy(config.kickstart, name, len); - config.kickstart[len] = 0; - force_reload_kickstart = 1; -} + memcpy(config.kickstart, name, len); + config.kickstart[len] = 0; + force_reload_kickstart = 1; +} diff --git a/minimig_config.h b/support/minimig/minimig_config.h similarity index 97% rename from minimig_config.h rename to support/minimig/minimig_config.h index b94d187..d71d504 100644 --- a/minimig_config.h +++ b/support/minimig/minimig_config.h @@ -2,7 +2,7 @@ #ifndef __MINIMIG_CONFIG_H__ #define __MINIMIG_CONFIG_H__ -#include "file_io.h" +#include "../../file_io.h" typedef struct { @@ -48,6 +48,6 @@ unsigned char SaveConfiguration(int num); const char* GetConfigDisplayName(int num); void MinimigReset(); -void SetKickstart(char *name); +void SetKickstart(char *name); #endif diff --git a/minimig_fdd.cpp b/support/minimig/minimig_fdd.cpp similarity index 99% rename from minimig_fdd.cpp rename to support/minimig/minimig_fdd.cpp index 65a4298..22f0f08 100644 --- a/minimig_fdd.cpp +++ b/support/minimig/minimig_fdd.cpp @@ -25,13 +25,13 @@ along with this program. If not, see . #include #include -#include "hardware.h" -#include "file_io.h" +#include "../../hardware.h" +#include "../../file_io.h" #include "minimig_fdd.h" #include "minimig_config.h" -#include "debug.h" -#include "fpga_io.h" -#include "menu.h" +#include "../../debug.h" +#include "../../fpga_io.h" +#include "../../menu.h" unsigned char drives = 0; // number of active drives reported by FPGA (may change only during reset) adfTYPE *pdfx; // drive select pointer @@ -39,7 +39,7 @@ adfTYPE df[4] = { 0 }; // drive information structure static uint8_t sector_buffer[512]; -unsigned char Error; +unsigned char Error; #define TRACK_SIZE 12668 #define HEADER_SIZE 0x40 @@ -631,42 +631,42 @@ void HandleFDD(unsigned char c1, unsigned char c2) } } -// insert floppy image pointed to to by global into -void InsertFloppy(adfTYPE *drive, char* path) -{ - int writable = FileCanWrite(path); - - if (!FileOpenEx(&drive->file, path, writable ? O_RDWR | O_SYNC : O_RDONLY)) - { - return; - } - - unsigned char i, j; - unsigned long tracks; - - // calculate number of tracks in the ADF image file - tracks = drive->file.size / (512 * 11); - if (tracks > MAX_TRACKS) - { - menu_debugf("UNSUPPORTED ADF SIZE!!! Too many tracks: %lu\n", tracks); - tracks = MAX_TRACKS; - } - drive->tracks = (unsigned char)tracks; - - strcpy(drive->name, path); - - // initialize the rest of drive struct - drive->status = DSK_INSERTED; - if (writable) // read-only attribute - drive->status |= DSK_WRITABLE; - - drive->sector_offset = 0; - drive->track = 0; - drive->track_prev = -1; - - menu_debugf("Inserting floppy: \"%s\"\n", path); - menu_debugf("file writable: %d\n", writable); - menu_debugf("file size: %lu (%lu KB)\n", drive->file.size, drive->file.size >> 10); - menu_debugf("drive tracks: %u\n", drive->tracks); - menu_debugf("drive status: 0x%02X\n", drive->status); -} +// insert floppy image pointed to to by global into +void InsertFloppy(adfTYPE *drive, char* path) +{ + int writable = FileCanWrite(path); + + if (!FileOpenEx(&drive->file, path, writable ? O_RDWR | O_SYNC : O_RDONLY)) + { + return; + } + + unsigned char i, j; + unsigned long tracks; + + // calculate number of tracks in the ADF image file + tracks = drive->file.size / (512 * 11); + if (tracks > MAX_TRACKS) + { + menu_debugf("UNSUPPORTED ADF SIZE!!! Too many tracks: %lu\n", tracks); + tracks = MAX_TRACKS; + } + drive->tracks = (unsigned char)tracks; + + strcpy(drive->name, path); + + // initialize the rest of drive struct + drive->status = DSK_INSERTED; + if (writable) // read-only attribute + drive->status |= DSK_WRITABLE; + + drive->sector_offset = 0; + drive->track = 0; + drive->track_prev = -1; + + menu_debugf("Inserting floppy: \"%s\"\n", path); + menu_debugf("file writable: %d\n", writable); + menu_debugf("file size: %lu (%lu KB)\n", drive->file.size, drive->file.size >> 10); + menu_debugf("drive tracks: %u\n", drive->tracks); + menu_debugf("drive status: 0x%02X\n", drive->status); +} diff --git a/minimig_fdd.h b/support/minimig/minimig_fdd.h similarity index 96% rename from minimig_fdd.h rename to support/minimig/minimig_fdd.h index da9883b..1adce51 100644 --- a/minimig_fdd.h +++ b/support/minimig/minimig_fdd.h @@ -1,7 +1,7 @@ #ifndef __MINIMIG_FDD_H__ #define __MINIMIG_FDD_H__ -#include "file_io.h" +#include "../../file_io.h" // floppy disk interface defs #define CMD_RDTRK 0x01 @@ -24,8 +24,8 @@ typedef struct char name[1024]; /*floppy name*/ } adfTYPE; -extern unsigned char drives; -extern adfTYPE df[4]; +extern unsigned char drives; +extern adfTYPE df[4]; void UpdateDriveStatus(void); void HandleFDD(unsigned char c1, unsigned char c2); diff --git a/minimig_hdd.cpp b/support/minimig/minimig_hdd.cpp similarity index 99% rename from minimig_hdd.cpp rename to support/minimig/minimig_hdd.cpp index d6ca154..004dfdd 100644 --- a/minimig_hdd.cpp +++ b/support/minimig/minimig_hdd.cpp @@ -25,13 +25,13 @@ along with this program. If not, see . #include #include -#include "hardware.h" -#include "file_io.h" +#include "../../hardware.h" +#include "../../file_io.h" #include "minimig_hdd.h" -#include "menu.h" +#include "../../menu.h" #include "minimig_config.h" -#include "debug.h" -#include "fpga_io.h" +#include "../../debug.h" +#include "../../fpga_io.h" #define CMD_IDECMD 0x04 #define CMD_IDEDAT 0x08 @@ -86,32 +86,32 @@ static uint8_t sector_buffer[512]; static void CalcGeometry(hdfTYPE *hdf) { - uint32_t head, cyl, spt; - uint32_t sptt[] = { 63, 127, 255, 0 }; - uint32_t total = hdf->file.size / 512; - for (int i = 0; sptt[i] != 0; i++) - { - spt = sptt[i]; - for (head = 4; head <= 16; head++) - { - cyl = total / (head * spt); - if (total <= 1024 * 1024) - { - if (cyl <= 1023) break; - } - else - { - if (cyl < 16383) break; - if (cyl < 32767 && head >= 5) break; - if (cyl <= 65536) break; - } - } - if (head <= 16) break; - } - - hdf->cylinders = cyl; - hdf->heads = (uint16_t)head; - hdf->sectors = (uint16_t)spt; + uint32_t head, cyl, spt; + uint32_t sptt[] = { 63, 127, 255, 0 }; + uint32_t total = hdf->file.size / 512; + for (int i = 0; sptt[i] != 0; i++) + { + spt = sptt[i]; + for (head = 4; head <= 16; head++) + { + cyl = total / (head * spt); + if (total <= 1024 * 1024) + { + if (cyl <= 1023) break; + } + else + { + if (cyl < 16383) break; + if (cyl < 32767 && head >= 5) break; + if (cyl <= 65536) break; + } + } + if (head <= 16) break; + } + + hdf->cylinders = cyl; + hdf->heads = (uint16_t)head; + hdf->sectors = (uint16_t)spt; } static void GetRDBGeometry(hdfTYPE *hdf) @@ -133,7 +133,7 @@ static void GetRDBGeometry(hdfTYPE *hdf) printf(" DANGEROUS: Cannot translate to legal CHS values. Re-calculate the CHS.\n"); CalcGeometry(hdf); - } + } } static void SetHardfileGeometry(hdfTYPE *hdf, int isHDF) @@ -765,4 +765,4 @@ int checkHDF(const char* name, struct RigidDiskBlock **rdb) return 1; // non-HDF file } return 0; -} +} \ No newline at end of file diff --git a/minimig_hdd.h b/support/minimig/minimig_hdd.h similarity index 100% rename from minimig_hdd.h rename to support/minimig/minimig_hdd.h diff --git a/minimig_hdd_internal.h b/support/minimig/minimig_hdd_internal.h similarity index 100% rename from minimig_hdd_internal.h rename to support/minimig/minimig_hdd_internal.h diff --git a/user_io.cpp b/user_io.cpp index d176410..b3da3c0 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -21,14 +21,11 @@ #include "input.h" #include "fpga_io.h" #include "file_io.h" -#include "minimig_config.h" #include "menu.h" #include "x86.h" #include "tzx2wav.h" #include "DiskImage.h" -#include "minimig_boot.h" -#include "minimig_fdd.h" -#include "minimig_hdd.h" +#include "support.h" #include "brightness.h" #include "sxmlc.h" @@ -917,265 +914,265 @@ int user_io_file_mount(char *name, unsigned char index) return ret ? 1 : 0; } -static unsigned char col_attr[1025]; -static int col_parse(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, const int n, SAX_Data* sd) -{ - static int in_border = 0; - static int in_color = 0; - static int in_bright = 0; - static int in_entry = 0; - static int in_line = 0; - static int in_paper = 0; - static int in_ink = 0; - static int end = 0; - static int start = 0; - static int line = 0; - - static char tmp[8]; - - switch (evt) - { - case XML_EVENT_START_NODE: - if (!strcasecmp(node->tag, "colourisation")) - { - in_border = 0; - in_color = 0; - in_bright = 0; - in_entry = 0; - in_line = 0; - in_paper = 0; - in_ink = 0; - } - - if (!strcasecmp(node->tag, "border")) in_border = 1; - if (!strcasecmp(node->tag, "colour")) in_color = 1; - if (!strcasecmp(node->tag, "bright")) in_bright = 1; - - if (!strcasecmp(node->tag, "entry")) - { - int ncode = -1; - int ncnt = -1; - for (int i = 0; i < node->n_attributes; i++) - { - if (!strcasecmp(node->attributes[i].name, "code")) ncode = atoi(node->attributes[i].value); - if (!strcasecmp(node->attributes[i].name, "quantity")) ncnt = atoi(node->attributes[i].value); - } - - in_entry = 0; - if (ncode >= 0 && ncode <= 127) - { - start = ncode; - if (ncnt < 1) ncnt = 1; - end = start + ncnt; - if (end > 128) end = 128; - memset(tmp, 0, sizeof(tmp)); - in_entry = 1; - } - } - - if (!strcasecmp(node->tag, "line")) - { - int nline = -1; - for (int i = 0; i < node->n_attributes; i++) - { - if (!strcasecmp(node->attributes[i].name, "index")) nline = atoi(node->attributes[i].value); - } - - in_line = 0; - if (nline >= 0 && nline <= 7) - { - line = nline; - if (in_entry) tmp[line] = 0; - in_line = 1; - } - } - - if (!strcasecmp(node->tag, "paper")) in_paper = 1; - if (!strcasecmp(node->tag, "ink")) in_ink = 1; - break; - - case XML_EVENT_END_NODE: - if (!strcasecmp(node->tag, "border")) in_border = 0; - if (!strcasecmp(node->tag, "colour")) in_color = 0; - if (!strcasecmp(node->tag, "bright")) in_bright = 0; - if (!strcasecmp(node->tag, "line")) in_line = 0; - if (!strcasecmp(node->tag, "paper")) in_paper = 0; - if (!strcasecmp(node->tag, "ink")) in_ink = 0; - if (!strcasecmp(node->tag, "entry")) - { - if (in_entry) - { - for (int i = start; i < end; i++) memcpy(&col_attr[i * 8], tmp, 8); - } - in_entry = 0; - } - break; - - case XML_EVENT_TEXT: - if (in_border && in_color) col_attr[1024] = (char)((col_attr[1024] & 8) | (atoi(text) & 7)); - if (in_border && in_bright) col_attr[1024] = (char)((col_attr[1024] & 7) | ((atoi(text) & 1) << 3)); - - if (in_entry && in_line && in_ink && in_color) tmp[line] = (char)((tmp[line] & 0xF8) | (atoi(text) & 7)); - if (in_entry && in_line && in_ink && in_bright) tmp[line] = (char)((tmp[line] & 0xF7) | ((atoi(text) & 1) << 3)); - if (in_entry && in_line && in_paper && in_color) tmp[line] = (char)((tmp[line] & 0x8F) | ((atoi(text) & 7) << 4)); - if (in_entry && in_line && in_paper && in_bright) tmp[line] = (char)((tmp[line] & 0x7F) | ((atoi(text) & 1) << 7)); - break; - - case XML_EVENT_ERROR: - printf("XML parse: %s: ERROR %d\n", text, n); - break; - default: - break; - } - - return true; -} +static unsigned char col_attr[1025]; +static int col_parse(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, const int n, SAX_Data* sd) +{ + static int in_border = 0; + static int in_color = 0; + static int in_bright = 0; + static int in_entry = 0; + static int in_line = 0; + static int in_paper = 0; + static int in_ink = 0; + static int end = 0; + static int start = 0; + static int line = 0; + + static char tmp[8]; + + switch (evt) + { + case XML_EVENT_START_NODE: + if (!strcasecmp(node->tag, "colourisation")) + { + in_border = 0; + in_color = 0; + in_bright = 0; + in_entry = 0; + in_line = 0; + in_paper = 0; + in_ink = 0; + } + + if (!strcasecmp(node->tag, "border")) in_border = 1; + if (!strcasecmp(node->tag, "colour")) in_color = 1; + if (!strcasecmp(node->tag, "bright")) in_bright = 1; + + if (!strcasecmp(node->tag, "entry")) + { + int ncode = -1; + int ncnt = -1; + for (int i = 0; i < node->n_attributes; i++) + { + if (!strcasecmp(node->attributes[i].name, "code")) ncode = atoi(node->attributes[i].value); + if (!strcasecmp(node->attributes[i].name, "quantity")) ncnt = atoi(node->attributes[i].value); + } + + in_entry = 0; + if (ncode >= 0 && ncode <= 127) + { + start = ncode; + if (ncnt < 1) ncnt = 1; + end = start + ncnt; + if (end > 128) end = 128; + memset(tmp, 0, sizeof(tmp)); + in_entry = 1; + } + } + + if (!strcasecmp(node->tag, "line")) + { + int nline = -1; + for (int i = 0; i < node->n_attributes; i++) + { + if (!strcasecmp(node->attributes[i].name, "index")) nline = atoi(node->attributes[i].value); + } + + in_line = 0; + if (nline >= 0 && nline <= 7) + { + line = nline; + if (in_entry) tmp[line] = 0; + in_line = 1; + } + } + + if (!strcasecmp(node->tag, "paper")) in_paper = 1; + if (!strcasecmp(node->tag, "ink")) in_ink = 1; + break; + + case XML_EVENT_END_NODE: + if (!strcasecmp(node->tag, "border")) in_border = 0; + if (!strcasecmp(node->tag, "colour")) in_color = 0; + if (!strcasecmp(node->tag, "bright")) in_bright = 0; + if (!strcasecmp(node->tag, "line")) in_line = 0; + if (!strcasecmp(node->tag, "paper")) in_paper = 0; + if (!strcasecmp(node->tag, "ink")) in_ink = 0; + if (!strcasecmp(node->tag, "entry")) + { + if (in_entry) + { + for (int i = start; i < end; i++) memcpy(&col_attr[i * 8], tmp, 8); + } + in_entry = 0; + } + break; + + case XML_EVENT_TEXT: + if (in_border && in_color) col_attr[1024] = (char)((col_attr[1024] & 8) | (atoi(text) & 7)); + if (in_border && in_bright) col_attr[1024] = (char)((col_attr[1024] & 7) | ((atoi(text) & 1) << 3)); + + if (in_entry && in_line && in_ink && in_color) tmp[line] = (char)((tmp[line] & 0xF8) | (atoi(text) & 7)); + if (in_entry && in_line && in_ink && in_bright) tmp[line] = (char)((tmp[line] & 0xF7) | ((atoi(text) & 1) << 3)); + if (in_entry && in_line && in_paper && in_color) tmp[line] = (char)((tmp[line] & 0x8F) | ((atoi(text) & 7) << 4)); + if (in_entry && in_line && in_paper && in_bright) tmp[line] = (char)((tmp[line] & 0x7F) | ((atoi(text) & 1) << 7)); + break; + + case XML_EVENT_ERROR: + printf("XML parse: %s: ERROR %d\n", text, n); + break; + default: + break; + } + + return true; +} static const unsigned char defchars[512] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, - 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, - 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, - 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x55, 0xAA, 0x55, - 0xAA, 0x55, 0xAA, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x1C, 0x22, 0x78, 0x20, 0x20, 0x7E, 0x00, 0x00, 0x08, 0x3E, 0x28, 0x3E, 0x0A, 0x3E, 0x08, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x3C, 0x42, 0x04, 0x08, 0x00, 0x08, 0x00, - 0x00, 0x04, 0x08, 0x08, 0x08, 0x08, 0x04, 0x00, 0x00, 0x20, 0x10, 0x10, 0x10, 0x10, 0x20, 0x00, - 0x00, 0x00, 0x10, 0x08, 0x04, 0x08, 0x10, 0x00, 0x00, 0x00, 0x04, 0x08, 0x10, 0x08, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14, 0x00, - 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, - 0x00, 0x3C, 0x46, 0x4A, 0x52, 0x62, 0x3C, 0x00, 0x00, 0x18, 0x28, 0x08, 0x08, 0x08, 0x3E, 0x00, - 0x00, 0x3C, 0x42, 0x02, 0x3C, 0x40, 0x7E, 0x00, 0x00, 0x3C, 0x42, 0x0C, 0x02, 0x42, 0x3C, 0x00, - 0x00, 0x08, 0x18, 0x28, 0x48, 0x7E, 0x08, 0x00, 0x00, 0x7E, 0x40, 0x7C, 0x02, 0x42, 0x3C, 0x00, - 0x00, 0x3C, 0x40, 0x7C, 0x42, 0x42, 0x3C, 0x00, 0x00, 0x7E, 0x02, 0x04, 0x08, 0x10, 0x10, 0x00, - 0x00, 0x3C, 0x42, 0x3C, 0x42, 0x42, 0x3C, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x3E, 0x02, 0x3C, 0x00, - 0x00, 0x3C, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x00, 0x00, 0x7C, 0x42, 0x7C, 0x42, 0x42, 0x7C, 0x00, - 0x00, 0x3C, 0x42, 0x40, 0x40, 0x42, 0x3C, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x44, 0x78, 0x00, - 0x00, 0x7E, 0x40, 0x7C, 0x40, 0x40, 0x7E, 0x00, 0x00, 0x7E, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x00, - 0x00, 0x3C, 0x42, 0x40, 0x4E, 0x42, 0x3C, 0x00, 0x00, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00, - 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00, 0x02, 0x02, 0x02, 0x42, 0x42, 0x3C, 0x00, - 0x00, 0x44, 0x48, 0x70, 0x48, 0x44, 0x42, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00, - 0x00, 0x42, 0x66, 0x5A, 0x42, 0x42, 0x42, 0x00, 0x00, 0x42, 0x62, 0x52, 0x4A, 0x46, 0x42, 0x00, - 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x7C, 0x40, 0x40, 0x00, - 0x00, 0x3C, 0x42, 0x42, 0x52, 0x4A, 0x3C, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x7C, 0x44, 0x42, 0x00, - 0x00, 0x3C, 0x40, 0x3C, 0x02, 0x42, 0x3C, 0x00, 0x00, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, - 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, - 0x00, 0x42, 0x42, 0x42, 0x42, 0x5A, 0x24, 0x00, 0x00, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x00, - 0x00, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x00, 0x00, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x00 -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, + 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, + 0x0F, 0x0F, 0x0F, 0x0F, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, + 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x55, 0xAA, 0x55, + 0xAA, 0x55, 0xAA, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x1C, 0x22, 0x78, 0x20, 0x20, 0x7E, 0x00, 0x00, 0x08, 0x3E, 0x28, 0x3E, 0x0A, 0x3E, 0x08, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x3C, 0x42, 0x04, 0x08, 0x00, 0x08, 0x00, + 0x00, 0x04, 0x08, 0x08, 0x08, 0x08, 0x04, 0x00, 0x00, 0x20, 0x10, 0x10, 0x10, 0x10, 0x20, 0x00, + 0x00, 0x00, 0x10, 0x08, 0x04, 0x08, 0x10, 0x00, 0x00, 0x00, 0x04, 0x08, 0x10, 0x08, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x3E, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14, 0x00, + 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x3C, 0x46, 0x4A, 0x52, 0x62, 0x3C, 0x00, 0x00, 0x18, 0x28, 0x08, 0x08, 0x08, 0x3E, 0x00, + 0x00, 0x3C, 0x42, 0x02, 0x3C, 0x40, 0x7E, 0x00, 0x00, 0x3C, 0x42, 0x0C, 0x02, 0x42, 0x3C, 0x00, + 0x00, 0x08, 0x18, 0x28, 0x48, 0x7E, 0x08, 0x00, 0x00, 0x7E, 0x40, 0x7C, 0x02, 0x42, 0x3C, 0x00, + 0x00, 0x3C, 0x40, 0x7C, 0x42, 0x42, 0x3C, 0x00, 0x00, 0x7E, 0x02, 0x04, 0x08, 0x10, 0x10, 0x00, + 0x00, 0x3C, 0x42, 0x3C, 0x42, 0x42, 0x3C, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x3E, 0x02, 0x3C, 0x00, + 0x00, 0x3C, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x00, 0x00, 0x7C, 0x42, 0x7C, 0x42, 0x42, 0x7C, 0x00, + 0x00, 0x3C, 0x42, 0x40, 0x40, 0x42, 0x3C, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x44, 0x78, 0x00, + 0x00, 0x7E, 0x40, 0x7C, 0x40, 0x40, 0x7E, 0x00, 0x00, 0x7E, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x00, + 0x00, 0x3C, 0x42, 0x40, 0x4E, 0x42, 0x3C, 0x00, 0x00, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00, + 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00, 0x02, 0x02, 0x02, 0x42, 0x42, 0x3C, 0x00, + 0x00, 0x44, 0x48, 0x70, 0x48, 0x44, 0x42, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00, + 0x00, 0x42, 0x66, 0x5A, 0x42, 0x42, 0x42, 0x00, 0x00, 0x42, 0x62, 0x52, 0x4A, 0x46, 0x42, 0x00, + 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x7C, 0x40, 0x40, 0x00, + 0x00, 0x3C, 0x42, 0x42, 0x52, 0x4A, 0x3C, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x7C, 0x44, 0x42, 0x00, + 0x00, 0x3C, 0x40, 0x3C, 0x02, 0x42, 0x3C, 0x00, 0x00, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, + 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, + 0x00, 0x42, 0x42, 0x42, 0x42, 0x5A, 0x24, 0x00, 0x00, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x00, + 0x00, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x00, 0x00, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x00 +}; -static int chr_parse(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, const int n, SAX_Data* sd) -{ - static int in_entry = 0; - static int in_line = 0; - static int code = 0; - static int line = 0; - - switch (evt) - { - case XML_EVENT_START_NODE: - if (!strcasecmp(node->tag, "definition")) - { - in_entry = 0; - in_line = 0; - code = 0; - line = 0; - } - - if (!strcasecmp(node->tag, "entry")) - { - int ncode = -1; - for (int i = 0; i < node->n_attributes; i++) - { - if (!strcasecmp(node->attributes[i].name, "code")) ncode = atoi(node->attributes[i].value); - } - - in_entry = 0; - if (ncode >= 0 && ncode <= 63) - { - code = ncode; - in_entry = 1; - } - - if (ncode >= 128 && ncode <= 191) - { - code = ncode - 64; - in_entry = 1; - } - } - - if (!strcasecmp(node->tag, "line")) - { - int nline = -1; - for (int i = 0; i < node->n_attributes; i++) - { - if (!strcasecmp(node->attributes[i].name, "index")) nline = atoi(node->attributes[i].value); - } - - in_line = 0; - if (nline >= 0 && nline <= 7) - { - line = nline; - in_line = 1; - } - } - break; - - case XML_EVENT_END_NODE: - if (!strcasecmp(node->tag, "line")) in_line = 0; - if (!strcasecmp(node->tag, "entry")) in_entry = 0; - break; - - case XML_EVENT_TEXT: - if (in_entry && in_line) - { - unsigned char tmp = 0; - if (strlen(text) >= 8) - { - for (int i = 0; i < 8; i++) tmp = (tmp << 1) | ((text[i] == '1') ? 1 : 0); - if (code >= 64) tmp = ~tmp; - } - col_attr[code * 8 + line] = tmp; - in_line = 0; - } - break; - - case XML_EVENT_ERROR: - printf("XML parse: %s: ERROR %d\n", text, n); - break; - default: - break; - } - - return true; +static int chr_parse(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, const int n, SAX_Data* sd) +{ + static int in_entry = 0; + static int in_line = 0; + static int code = 0; + static int line = 0; + + switch (evt) + { + case XML_EVENT_START_NODE: + if (!strcasecmp(node->tag, "definition")) + { + in_entry = 0; + in_line = 0; + code = 0; + line = 0; + } + + if (!strcasecmp(node->tag, "entry")) + { + int ncode = -1; + for (int i = 0; i < node->n_attributes; i++) + { + if (!strcasecmp(node->attributes[i].name, "code")) ncode = atoi(node->attributes[i].value); + } + + in_entry = 0; + if (ncode >= 0 && ncode <= 63) + { + code = ncode; + in_entry = 1; + } + + if (ncode >= 128 && ncode <= 191) + { + code = ncode - 64; + in_entry = 1; + } + } + + if (!strcasecmp(node->tag, "line")) + { + int nline = -1; + for (int i = 0; i < node->n_attributes; i++) + { + if (!strcasecmp(node->attributes[i].name, "index")) nline = atoi(node->attributes[i].value); + } + + in_line = 0; + if (nline >= 0 && nline <= 7) + { + line = nline; + in_line = 1; + } + } + break; + + case XML_EVENT_END_NODE: + if (!strcasecmp(node->tag, "line")) in_line = 0; + if (!strcasecmp(node->tag, "entry")) in_entry = 0; + break; + + case XML_EVENT_TEXT: + if (in_entry && in_line) + { + unsigned char tmp = 0; + if (strlen(text) >= 8) + { + for (int i = 0; i < 8; i++) tmp = (tmp << 1) | ((text[i] == '1') ? 1 : 0); + if (code >= 64) tmp = ~tmp; + } + col_attr[code * 8 + line] = tmp; + in_line = 0; + } + break; + + case XML_EVENT_ERROR: + printf("XML parse: %s: ERROR %d\n", text, n); + break; + default: + break; + } + + return true; } static void send_pcolchr(const char* name, unsigned char index, int type) { static char full_path[1024]; - - sprintf(full_path, "%s/%s", getRootDir(), name); + + sprintf(full_path, "%s/%s", getRootDir(), name); char *p = strrchr(full_path, '.'); if (!p) p = full_path + strlen(full_path); strcpy(p, type ? ".chr" : ".col"); - - if (type) - { - memcpy(col_attr, defchars, sizeof(defchars)); - memcpy(col_attr+sizeof(defchars), defchars, sizeof(defchars)); - } - else memset(col_attr, 0, sizeof(col_attr)); + + if (type) + { + memcpy(col_attr, defchars, sizeof(defchars)); + memcpy(col_attr+sizeof(defchars), defchars, sizeof(defchars)); + } + else memset(col_attr, 0, sizeof(col_attr)); - SAX_Callbacks sax; - SAX_Callbacks_init(&sax); - sax.all_event = type ? chr_parse : col_parse; - if (XMLDoc_parse_file_SAX(full_path, &sax, 0)) - { - printf("Send additional file %s\n", full_path); + SAX_Callbacks sax; + SAX_Callbacks_init(&sax); + sax.all_event = type ? chr_parse : col_parse; + if (XMLDoc_parse_file_SAX(full_path, &sax, 0)) + { + printf("Send additional file %s\n", full_path); //hexdump(col_attr, sizeof(col_attr)); @@ -1196,7 +1193,7 @@ static void send_pcolchr(const char* name, unsigned char index, int type) spi8(UIO_FILE_TX); spi8(0x00); DisableFpga(); - } + } } int user_io_file_tx(const char* name, unsigned char index, char opensave, char mute, char composite) @@ -1211,12 +1208,12 @@ int user_io_file_tx(const char* name, unsigned char index, char opensave, char m if (composite) { if (!FileReadSec(&f, buf)) return 0; - if (memcmp(buf, "MiSTer", 6)) return 0; - - uint32_t off = 16 + *(uint32_t*)(((uint8_t*)buf) + 12); - bytes2send -= off; - - FileSeek(&f, off, SEEK_SET); + if (memcmp(buf, "MiSTer", 6)) return 0; + + uint32_t off = 16 + *(uint32_t*)(((uint8_t*)buf) + 12); + bytes2send -= off; + + FileSeek(&f, off, SEEK_SET); } /* transmit the entire file using one transfer */ @@ -1587,19 +1584,19 @@ void user_io_poll() */ static u_int8_t last_status_change = 0; - char stchg = spi_uio_cmd_cont(UIO_GET_STATUS); - if ((stchg & 0xF0) == 0xA0 && last_status_change != (stchg & 0xF)) - { - last_status_change = (stchg & 0xF); - uint32_t st = spi32w(0); - DisableIO(); + char stchg = spi_uio_cmd_cont(UIO_GET_STATUS); + if ((stchg & 0xF0) == 0xA0 && last_status_change != (stchg & 0xF)) + { + last_status_change = (stchg & 0xF); + uint32_t st = spi32w(0); + DisableIO(); user_io_8bit_set_status(st, ~UIO_STATUS_RESET); //printf("** new status from core: %08X\n", st); - } - else - { - DisableIO(); - } + } + else + { + DisableIO(); + } // sd card emulation if (is_x86_core()) From decd9a7e0154e8ab327c243bff36ad29d6328d55 Mon Sep 17 00:00:00 2001 From: karllurman Date: Thu, 1 Nov 2018 08:28:55 +1100 Subject: [PATCH 4/7] Move sharpmz into support too --- menu.cpp | 1 - support.h | 4 + sharpmz.cpp => support/sharpmz/sharpmz.cpp | 14 +- support/sharpmz/sharpmz.h | 469 +++++++++++++++++++++ user_io.cpp | 2 +- 5 files changed, 481 insertions(+), 9 deletions(-) rename sharpmz.cpp => support/sharpmz/sharpmz.cpp (99%) create mode 100644 support/sharpmz/sharpmz.h diff --git a/menu.cpp b/menu.cpp index 6d68c16..8ae44e9 100644 --- a/menu.cpp +++ b/menu.cpp @@ -45,7 +45,6 @@ along with this program. If not, see . #include "debug.h" #include "support.h" #include "archie.h" -#include "sharpmz.h" #include "fpga_io.h" #include #include "cfg.h" diff --git a/support.h b/support.h index 21f78ae..9e521da 100644 --- a/support.h +++ b/support.h @@ -1,4 +1,8 @@ +// Minimig support #include "support/minimig/minimig_config.h" #include "support/minimig/minimig_boot.h" #include "support/minimig/minimig_fdd.h" #include "support/minimig/minimig_hdd.h" + +// SharpMz support +#include "support/sharpmz/sharpmz.h" diff --git a/sharpmz.cpp b/support/sharpmz/sharpmz.cpp similarity index 99% rename from sharpmz.cpp rename to support/sharpmz/sharpmz.cpp index 6930b31..965044f 100644 --- a/sharpmz.cpp +++ b/support/sharpmz/sharpmz.cpp @@ -33,13 +33,13 @@ #include "malloc.h" #include #include -#include "hardware.h" -#include "fpga_io.h" -#include "sharpmz.h" -#include "osd.h" -#include "menu.h" -#include "debug.h" -#include "user_io.h" +#include "../../hardware.h" +#include "../../fpga_io.h" +#include "../../sharpmz.h" +#include "../../osd.h" +#include "../../menu.h" +#include "../../debug.h" +#include "../../user_io.h" #define sharpmz_debugf(a, ...) //#define sharpmz_debugf(a, ...) printf("\033[1;31mSHARPMZ: " a "\033[0m\n", ##__VA_ARGS__) diff --git a/support/sharpmz/sharpmz.h b/support/sharpmz/sharpmz.h new file mode 100644 index 0000000..b7e1cf1 --- /dev/null +++ b/support/sharpmz/sharpmz.h @@ -0,0 +1,469 @@ +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Name: sharpmz.h +// Created: July 2018 +// Author(s): Philip Smart +// Description: Sharp MZ series MiSTer Menu Add-On. +// This module is an extension to the MiSTer control program. It adds extensions to +// the menu system and additional I/O control specific to the Sharp MZ series +// emulation. +// +// Credits: +// Copyright: (c) 2018 Philip Smart +// +// History: July 2018 - Initial module written. +// Sept 2018 - Synchronised with main MiSTer codebase. +// +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// This source file 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 source file 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 . +///////////////////////////////////////////////////////////////////////////////////////////////////////// +#ifndef SHARPMZ_H +#define SHARPMZ_H + +#include "../../file_io.h" + +// Defaults. +// +#define MZ_TAPE_HEADER_STACK_ADDR 0x10f0 +#define MZ_TAPE_HEADER_SIZE 128 +#define MEMORY_DUMP_FILE "cmp/lastload" +#define MAX_FILENAME_SIZE 1024 + +// HPS commands to fpga block. +// +#define SHARPMZ_EOF 0x00 +#define SHARPMZ_SOF 0x01 +#define SHARPMZ_FILE_TX 0x53 +#define SHARPMZ_FILE_TX_DAT 0x54 +#define SHARPMZ_FILE_INDEX 0x55 +#define SHARPMZ_FILE_INFO 0x56 +#define SHARPMZ_FILE_ADDR 0x57 +#define SHARPMZ_FILE_ADDR_TX 0x58 +#define SHARPMZ_FILE_ADDR_RX 0x59 +#define SHARPMZ_CONFIG_RX 0x5A +#define SHARPMZ_CONFIG_TX 0x5B + +// Memory blocks within the Emulator. +// +#define SHARPMZ_MEMBANK_ALL 0xff +#define SHARPMZ_MEMBANK_SYSROM 0x00 +#define SHARPMZ_MEMBANK_SYSRAM 0x02 +#define SHARPMZ_MEMBANK_KEYMAP 0x03 +#define SHARPMZ_MEMBANK_VRAM 0x04 +#define SHARPMZ_MEMBANK_CMT_HDR 0x05 +#define SHARPMZ_MEMBANK_CMT_DATA 0x06 +#define SHARPMZ_MEMBANK_CGROM 0x07 +#define SHARPMZ_MEMBANK_CGRAM 0x08 +#define SHARPMZ_MEMBANK_MAXBANKS 9 + +// Name of the configuration file. +// +#define SHARPMZ_CONFIG_FILENAME "SHARPMZ.CFG" + +// Name of the core. +// +#define SHARPMZ_CORE_NAME "SharpMZ" + +// Maximum number of machines currently supported by the emulation. +// +#define MAX_MZMACHINES 8 + +// Maximum number of sub-roms per machine. +// +#define MAX_MROMOPTIONS 2 + +// Numeric index of each machine. +// +#define MZ80K_IDX 0 // 000 +#define MZ80C_IDX 1 // 001 +#define MZ1200_IDX 2 // 010 +#define MZ80A_IDX 3 // 011 +#define MZ700_IDX 4 // 100 +#define MZ800_IDX 5 // 101 +#define MZ80B_IDX 6 // 110 +#define MZ2000_IDX 7 // 111 + +// Maximum number of images which can be loaded. +// +#define MAX_IMAGE_TYPES 6 + +// Numeric index of each main rom image category. +// +#define MROM_IDX 0 +#define MROM_80C_IDX 1 +#define CGROM_IDX 2 +#define KEYMAP_IDX 3 +#define USERROM_IDX 4 +#define FDCROM_IDX 5 + +// Numeric index of monitor rom subtypes. +// +#define MONITOR 0 +#define MONITOR_80C 1 + +// Numeric index of Option rom subtypes. +// +#define USERROM 0 +#define FDCROM 1 + +// Tape(CMT) Data types. +// +#define SHARPMZ_CMT_MC 1 // machine code program. +#define SHARPMZ_CMT_BASIC 2 // MZ-80 Basic program. +#define SHARPMZ_CMT_DATA 3 // MZ-80 data file. +#define SHARPMZ_CMT_700DATA 4 // MZ-700 data file. +#define SHARPMZ_CMT_700BASIC 5 // MZ700 Basic program. + +// Numeric id of system registers. +// +#define REGISTER_MODEL 0 +#define REGISTER_DISPLAY 1 +#define REGISTER_CPU 2 +#define REGISTER_AUDIO 3 +#define REGISTER_CMT 4 +#define REGISTER_CMT2 5 +#define REGISTER_USERROM 6 +#define REGISTER_FDCROM 7 +#define REGISTER_8 8 +#define REGISTER_9 9 +#define REGISTER_10 10 +#define REGISTER_11 11 +#define REGISTER_12 12 +#define REGISTER_13 13 +#define REGISTER_DEBUG 14 +#define REGISTER_DEBUG2 15 +#define MAX_REGISTERS 16 + +// Numeric id of bit for a given CMT register flag. +// +#define CMT_PLAY_READY 0 // Tape play back buffer, 0 = empty, 1 = full. +#define CMT_PLAYING 1 // Tape playback, 0 = stopped, 1 = in progress. +#define CMT_RECORD_READY 2 // Tape record buffer full. +#define CMT_RECORDING 3 // Tape recording, 0 = stopped, 1 = in progress. +#define CMT_ACTIVE 4 // Tape transfer in progress, 0 = no activity, 1 = activity. +#define CMT_SENSE 5 // Tape state Sense out. +#define CMT_WRITEBIT 6 // Write bit to MZ. +#define CMT_READBIT 7 // Receive bit from MZ. +#define CMT_MOTOR 8 // Motor on/off. + +// Names of the supported machines. +// +static const char *MZMACHINES[MAX_MZMACHINES] = { "MZ80K", "MZ80C", "MZ1200", "MZ80A", "MZ700", "MZ800", "MZ80B", "MZ2000" }; + +// Default load addresses of roms. +// +static const unsigned int MZLOADADDR[MAX_IMAGE_TYPES][MAX_MZMACHINES] = + { + { 0x00000, 0x03800, 0x07000, 0x0A800, 0x0E000, 0x11800, 0x15000, 0x17800 }, // MROM + { 0x01000, 0x04800, 0x08000, 0x0B800, 0x0F000, 0x12800, 0x15800, 0x18000 }, // MROM 80C + { 0x70000, 0x71000, 0x72000, 0x73000, 0x74000, 0x75000, 0x76000, 0x77000 }, // CGROM + { 0x30000, 0x30100, 0x30200, 0x30300, 0x30400, 0x30500, 0x30600, 0x30700 }, // KEYMAP + { 0x02000, 0x05800, 0x09000, 0x0C800, 0x10000, 0x13800, 0x16000, 0x18800 }, // USERROM + { 0x02800, 0x06000, 0x09800, 0x0D000, 0x10800, 0x14000, 0x16800, 0x19000 } // FDCROM + }; + +// Default size of roms. +// +static const unsigned int MZLOADSIZE[MAX_IMAGE_TYPES][MAX_MZMACHINES] = + { + { 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800 }, // MROM + { 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800 }, // MROM 80C + { 0x0800, 0x0800, 0x0800, 0x0800, 0x1000, 0x0800, 0x0800, 0x0800 }, // CGROM + { 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100 }, // KEYMAP + { 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800 }, // USERROM + { 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000 } // FDCROM + }; + +static const unsigned int MZBANKSIZE[SHARPMZ_MEMBANK_MAXBANKS] = { 0x20000, 0x0000, 0x10000, 0x00800, 0x04000, 0x00080, 0x10000, 0x08000, 0x08000 }; + +#if !defined(MENU_H) && !defined(USER_IO_H) +// Lookup tables for menu entries. +// +const char *SHARPMZ_FAST_TAPE[] = { "Off", "2x", "4x", "8x", "16x", "32x", "Off", "Off", + "Off", "2x", "4x", "8x", "16x", "32x", "Off", "Off", + "Off", "2x", "4x", "8x", "16x", "Off", "Off", "Off" + }; +const char *SHARPMZ_CPU_SPEED[] = { "2MHz", "4MHz", "8MHz", "16MHz", "32MHz", "64MHz", "2MHz", "2MHz", + "3.5MHz", "7MHz", "14MHz", "28MHz", "56MHz", "112MHz", "3.5MHz", "3.5MHz", + "4MHz", "8MHz", "16MHz", "32MHz", "64MHz", "4MHz", "4MHz", "4MHz" + }; +const char *SHARPMZ_TAPE_BUTTONS[] = { "Off", "Play", "Record", "Auto" }; +const char *SHARPMZ_AUDIO_SOURCE[] = { "Sound", "Tape" }; +const char *SHARPMZ_AUDIO_VOLUME[] = { "Max", "14", "13", "12", "11", "10", "9", "8", "7", "6", "5", "4", "3", "2", "1", "Min" }; +const char *SHARPMZ_AUDIO_MUTE[] = { "Off", "Mute" }; +const char *SHARPMZ_USERROM_ENABLED[] = { "Disabled", "Enabled" }; +const char *SHARPMZ_FDCROM_ENABLED[] = { "Disabled", "Enabled" }; +const char *SHARPMZ_ROM_ENABLED[] = { "Disabled", "Enabled" }; +const char *SHARPMZ_AUTO_SAVE_ENABLED[] = { "No", "Yes" }; +const char *SHARPMZ_DISPLAY_TYPE[] = { "Mono 40x25", "Mono 80x25 ", "Colour 40x25", "Colour 80x25", "tbd3", "tbd4", "tbd5", "tbd6" }; +const char *SHARPMZ_ASPECT_RATIO[] = { "4:3", "16:9" }; +const char *SHARPMZ_SCANDOUBLER_FX[] = { "None", "HQ2x", "CRT 25%", "CRT 50%", "CRT 75%", "tbd1", "tbd2", "tbd3" }; +const char *SHARPMZ_VRAMWAIT_MODE[] = { "Off", "On" }; +const char *SHARPMZ_VRAMDISABLE_MODE[] = { "Enabled", "Disabled" }; +const char *SHARPMZ_GRAMDISABLE_MODE[] = { "Enabled", "Disabled" }; +const char *SHARPMZ_PCG_MODE[] = { "ROM", "RAM" }; +const char *SHARPMZ_MACHINE_MODEL[] = { "MZ80K", "MZ80C", "MZ1200", "MZ80A", "MZ700", "MZ800", "MZ80B", "MZ2000" }; +const char *SHARPMZ_DEBUG_ENABLE[] = { "Off", "On" }; +const char *SHARPMZ_DEBUG_LEDS[] = { "Off", "On" }; +const char *SHARPMZ_DEBUG_LEDS_BANK[] = { "T80", "I/O", "IOCTL", "Config", "MZ80C I", "MZ80C II", "MZ80B I", "MZ80B II" }; +const char *SHARPMZ_DEBUG_LEDS_SUBBANK[] = { "Auto", "A7-0", "A15-8", "DI", "Signals", "", "", "", + "Auto", "Video", "PS2Key", "Signals", "", "", "", "", + "Auto", "A23-16", "A15-8", "A7-0", "Signals", "", "", "", + "Auto", "Config 1", "Config 2", "Config 3", "Config 4", "Config 5", "", "", + "Auto", "CS 1", "CS 2", "CS 3", "INT/RE", "Clk", "", "", + "Auto", "CMT 1", "CMT 2", "CMT 3", "", "", "", "", + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + }; +const char *SHARPMZ_DEBUG_CPUFREQ[] = { "CPU/CMT", "1MHz", "100KHz", "10KHz", "5KHz", "1KHz", "500Hz", "100Hz", "50Hz", "10Hz", "5Hz", "2Hz", "1Hz", "0.5Hz", "0.2Hz", "0.1Hz" }; +const char *SHARPMZ_DEBUG_LEDS_SMPFREQ[] = { "CPU/CMT", "1MHz", "100KHz", "10KHz", "5KHz", "1KHz", "500Hz", "100Hz", "50Hz", "10Hz", "5Hz", "2Hz", "1Hz", "0.5Hz", "0.2Hz", "0.1Hz" }; +const char *SHARPMZ_MEMORY_BANK[] = { "SysROM", "SysRAM", "KeyMap", "VRAM", "CMTHDR", "CMTDATA", "CGROM", "CGRAM", "All" }; +const char *SHARPMZ_MEMORY_BANK_FILE[] = { "sysrom.dump", "sysram.dump", "keymap.dump", "vram.dump", "cmt_hdr.dump", "cmt_data.dump", "cgrom.dump", "cgram.dump", "all_memory.dump" }; +const char *SHARPMZ_TAPE_TYPE[] = { "N/A", "M/code", "MZ80 Basic", "MZ80 Data", "MZ700 Data", "MZ700 Basic", "N/A" }; +const char *SHARPMZ_HELPTEXT[] = { "Welcome to the Sharp MZ Series! Use the cursor keys to navigate the menus. Use space bar or enter to select an item. Press Esc or F12 to exit the menus. ", + 0 + }; +#else +// External definitions. +extern const char *SHARPMZ_FAST_TAPE[]; +extern const char *SHARPMZ_TAPE_BUTTONS[]; +extern const char *SHARPMZ_AUDIO_SOURCE[]; +extern const char *SHARPMZ_AUDIO_VOLUME[]; +extern const char *SHARPMZ_AUDIO_MUTE[]; +extern const char *SHARPMZ_USERROM_ENABLED[]; +extern const char *SHARPMZ_FDCROM_ENABLED[]; +extern const char *SHARPMZ_ROM_ENABLED[]; +extern const char *SHARPMZ_AUTO_SAVE_ENABLED[]; +extern const char *SHARPMZ_DISPLAY_TYPE[]; +extern const char *SHARPMZ_ASPECT_RATIO[]; +extern const char *SHARPMZ_SCANDOUBLER_FX[]; +extern const char *SHARPMZ_VRAMWAIT_MODE[]; +extern const char *SHARPMZ_VRAMDISABLE_MODE[]; +extern const char *SHARPMZ_GRAMDISABLE_MODE[]; +extern const char *SHARPMZ_PCG_MODE[]; +extern const char *SHARPMZ_MACHINE_MODEL[]; +extern const char *SHARPMZ_CPU_SPEED[]; +extern const char *SHARPMZ_DEBUG_ENABLE[]; +extern const char *SHARPMZ_DEBUG_LEDS[]; +extern const char *SHARPMZ_DEBUG_LEDS_BANK[]; +extern const char *SHARPMZ_DEBUG_CPUFREQ[]; +extern const char *SHARPMZ_DEBUG_LEDS_SMPFREQ[]; +extern const char *SHARPMZ_TAPE_TYPE[]; +extern const char *SHARPMZ_MEMORY_BANK[]; +extern const char *SHARPMZ_MEMORY_BANK_FILE[]; +extern const char *SHARPMZ_HELPTEXT[]; +#endif + +// Structure to store the name, load address and the size of a given rom. +// +typedef struct +{ + char romFileName[MAX_FILENAME_SIZE]; + short romEnabled; + unsigned int loadAddr; + unsigned int loadSize; +} romData_t; + +// Structure to store the configuration data of the emulator. +// +typedef struct +{ + unsigned long system_ctrl; // Original MiSTer system control register. + unsigned char system_reg[MAX_REGISTERS]; // Emulator control register bank. + unsigned char autoSave; // Automatically save tape file if RECORD_READY becomes active. Use filename in header. + unsigned char volume; // Volume setting, using the MiSTer DAC level control. BIt 0-3 = Attenuation, bit 4 = Mute. + romData_t romMonitor[MAX_MZMACHINES][MAX_MROMOPTIONS]; // Details of rom monitor images to upload. + romData_t romCG[MAX_MZMACHINES]; // Details of rom character generator images to upload. + romData_t romKeyMap[MAX_MZMACHINES]; // Details of rom Key mapping images to upload. + romData_t romUser[MAX_MZMACHINES]; // Details of User ROM images to upload. + romData_t romFDC[MAX_MZMACHINES]; // Details of FDC ROM images to upload. +} sharpmz_config_t; + +// Structures to store the tape file queue. +// +typedef struct tape_queue_node tape_queue_node_t; +struct tape_queue_node +{ + char fileName[MAX_FILENAME_SIZE]; + tape_queue_node_t *next; +}; +// +typedef struct +{ + struct tape_queue_node *top; + struct tape_queue_node *bottom; + unsigned short elements; +} tape_queue_t; + +// MZ Series Tape header structure - 128 bytes. +// +typedef struct +{ + unsigned char dataType; // 01 = machine code program. + // 02 MZ-80 Basic program. + // 03 MZ-80 data file. + // 04 MZ-700 data file. + // 05 MZ-700 Basic program. + char fileName[17]; // File name. + unsigned short fileSize; // Size of data partition. + unsigned short loadAddress; // Load address of the program/data. + unsigned short execAddress; // Execution address of program. + unsigned char comment[104]; // Free text or code area. +} sharpmz_tape_header_t; + +// UI state machine states, extension set to the main menu.cpp MENU enum. Values are set above the original enum so that they +// are detected and handle within this sharpmz code base. +// +enum SHARPMZ_MENU +{ + // Sharp MZ menu entries + MENU_SHARPMZ_MAIN1 = 0xa0, + MENU_SHARPMZ_MAIN2 = 0xa1, + MENU_SHARPMZ_TAPE_STORAGE1 = 0xa2, + MENU_SHARPMZ_TAPE_STORAGE2 = 0xa3, + MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM = 0xa4, + MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM2 = 0xa5, + MENU_SHARPMZ_TAPE_STORAGE_QUEUE_TAPE_TO_CMT = 0xa6, + MENU_SHARPMZ_TAPE_STORAGE_QUEUE_TAPE_TO_CMT2 = 0xa7, + MENU_SHARPMZ_TAPE_STORAGE_SAVE_TAPE_FROM_CMT = 0xa8, + MENU_SHARPMZ_TAPE_STORAGE_SAVE_TAPE_FROM_CMT2 = 0xa9, + MENU_SHARPMZ_FLOPPY_STORAGE1 = 0xaa, + MENU_SHARPMZ_FLOPPY_STORAGE2 = 0xab, + MENU_SHARPMZ_DISPLAY1 = 0xb0, + MENU_SHARPMZ_DISPLAY2 = 0xb1, + MENU_SHARPMZ_MACHINE1 = 0xb2, + MENU_SHARPMZ_MACHINE2 = 0xb3, + MENU_SHARPMZ_ROMS1 = 0xb4, + MENU_SHARPMZ_ROMS2 = 0xb5, + MENU_SHARPMZ_ROM_FILE_SELECTED = 0xb6, + MENU_SHARPMZ_DEBUG1 = 0xb7, + MENU_SHARPMZ_DEBUG2 = 0xb8 +}; + +// Prototypes. +// +void sharpmz_reset(unsigned long, unsigned long); +short sharpmz_read_ram(char *, short); +void sharpmz_init(void); +void sharpmz_poll(void); +short sharpmz_read_ram(char *, short); +const char *sharpmz_get_rom_name(void); +void sharpmz_set_config_register(short addr, unsigned char value); +unsigned char sharpmz_read_config_register(short addr); +void sharpmz_send_file(romData_t &, char *); +void sharpmz_set_rom(romData_t *); +int sharpmz_FileRead(fileTYPE *file, void *pBuffer, int nSize); +short sharpmz_get_machine_group(void); +unsigned char sharpmz_get_auto_save_enabled(void); +int sharpmz_get_fasttape(void); +int sharpmz_get_display_type(void); +int sharpmz_get_aspect_ratio(void); +int sharpmz_get_scandoubler_fx(void); +int sharpmz_get_vram_wait_mode(void); +int sharpmz_get_vram_disable_mode(void); +int sharpmz_get_gram_disable_mode(void); +int sharpmz_get_pcg_mode(void); +int sharpmz_get_machine_model(void); +int sharpmz_get_cpu_speed(void); +int sharpmz_get_audio_source(void); +int sharpmz_get_audio_volume(void); +int sharpmz_get_audio_mute(void); +int sharpmz_get_debug_enable(void); +int sharpmz_get_debug_leds(void); +int sharpmz_get_tape_buttons(void); +short sharpmz_get_next_memory_bank(void); +short sharpmz_get_next_debug_leds_bank(void); +short sharpmz_get_next_debug_leds_subbank(unsigned char); +short sharpmz_get_next_debug_cpufreq(void); +short sharpmz_get_next_debug_leds_smpfreq(void); +void sharpmz_set_auto_save_enabled(unsigned char); +void sharpmz_set_fasttape(short, short); +void sharpmz_set_display_type(short, short); +void sharpmz_set_aspect_ratio(short, short); +void sharpmz_set_scandoubler_fx(short, short); +void sharpmz_set_vram_wait_mode(short, short); +void sharpmz_set_vram_disable_mode(short, short); +void sharpmz_set_gram_disable_mode(short, short); +void sharpmz_set_pcg_mode(short, short); +void sharpmz_set_machine_model(short, short); +void sharpmz_set_cpu_speed(short, short); +void sharpmz_set_audio_source(short, short); +void sharpmz_set_audio_volume(short, short); +void sharpmz_set_audio_mute(short, short); +void sharpmz_set_debug_enable(short, short); +void sharpmz_set_debug_leds(short, short); +void sharpmz_set_debug_leds_bank(short, short); +void sharpmz_set_debug_leds_subbank(short, short); +void sharpmz_set_debug_cpufreq(short, short); +void sharpmz_set_debug_leds_smpfreq(short, short); +void sharpmz_set_tape_buttons(short, short); +int sharpmz_save_config(void); +int sharpmz_reset_config(short); +int sharpmz_reload_config(short); +short sharpmz_get_next_machine_model(void); +short sharpmz_get_user_rom_enabled(short); +void sharpmz_set_user_rom_enabled(short, short, short); +short sharpmz_get_fdc_rom_enabled(short); +void sharpmz_set_fdc_rom_enabled(short, short, short); +short sharpmz_get_custom_rom_enabled(short, short); +void sharpmz_set_custom_rom_enabled(short, short, short); +char *sharpmz_get_rom_file(short, short); +void sharpmz_set_rom_file(short, short, char *); +short sharpmz_read_tape_header(const char *); +short sharpmz_load_tape_to_ram(const char *, unsigned char); +short sharpmz_save_tape_from_cmt(const char *); +sharpmz_tape_header_t *sharpmz_get_tape_header(void); +const char *sharpmz_get_auto_save_enabled_string(void); +const char *sharpmz_get_fasttape_string(void); +const char *sharpmz_get_display_type_string(void); +const char *sharpmz_get_aspect_ratio_string(void); +const char *sharpmz_get_scandoubler_fx_string(void); +const char *sharpmz_get_vram_wait_mode_string(void); +const char *sharpmz_get_vram_disable_mode_string(void); +const char *sharpmz_get_gram_disable_mode_string(void); +const char *sharpmz_get_pcg_mode_string(void); +const char *sharpmz_get_machine_model_string(void); +const char *sharpmz_get_cpu_speed_string(void); +const char *sharpmz_get_audio_source_string(void); +const char *sharpmz_get_audio_volume_string(void); +const char *sharpmz_get_audio_mute_string(void); +const char *sharpmz_get_debug_enable_string(void); +const char *sharpmz_get_debug_leds_string(void); +const char *sharpmz_get_debug_leds_bank_string(void); +const char *sharpmz_get_debug_leds_subbank_string(void); +const char *sharpmz_get_debug_cpufreq_string(void); +const char *sharpmz_get_debug_leds_smpfreq_string(void); +const char *sharpmz_get_machine_model_string(short machineModel); +const char *sharpmz_get_machine_model_string(void); +const char *sharpmz_get_user_rom_enabled_string(short); +const char *sharpmz_get_fdc_rom_enabled_string(short); +const char *sharpmz_get_custom_rom_enabled_string(short romEnabled); +const char *sharpmz_get_tape_type_string(void); +const char *sharpmz_get_tape_buttons_string(void); +const char *sharpmz_get_memory_bank_string(short); +const char *sharpmz_get_memory_bank_file(short); +void sharpmz_push_filename(char *); +char *sharpmz_pop_filename(void); +char *sharpmz_get_next_filename(char); +void sharpmz_clear_filelist(void); +void sharpmz_select_file(const char*, unsigned char, char *, char, char *); +int sharpmz_default_ui_state(void); +int sharpmz_ui(int, int, int, int, + unsigned char *, unsigned char *, unsigned char *, unsigned char *, + unsigned int *, char *, const char **, char *, + unsigned char *, unsigned char *, unsigned char *, unsigned char *, + char *, + unsigned char, unsigned char, unsigned char, unsigned char, + unsigned char, unsigned char, unsigned char, unsigned char); +#endif // SHARPMZ_H diff --git a/user_io.cpp b/user_io.cpp index b3da3c0..1485fb9 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -12,7 +12,7 @@ #include "osd.h" #include "user_io.h" #include "archie.h" -#include "sharpmz.h" + #include "debug.h" #include "st_ikbd.h" #include "spi.h" From 3fccd05165add90a43326ba2224b9e1e587d98d4 Mon Sep 17 00:00:00 2001 From: karllurman Date: Thu, 1 Nov 2018 09:32:26 +1100 Subject: [PATCH 5/7] Makefile was wrong and sharpmz wasnt being built. Archie is now in support too --- Makefile | 8 +- menu.cpp | 1 - sharpmz.h | 469 ------------------------ support.h | 3 + archie.cpp => support/archie/archie.cpp | 14 +- archie.h => support/archie/archie.h | 2 +- support/sharpmz/sharpmz.cpp | 2 +- user_io.cpp | 1 - 8 files changed, 17 insertions(+), 483 deletions(-) delete mode 100644 sharpmz.h rename archie.cpp => support/archie/archie.cpp (99%) rename archie.h => support/archie/archie.h (95%) diff --git a/Makefile b/Makefile index 3ba3869..8b50f45 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,13 @@ PRJ = MiSTer SRC = $(wildcard *.c) SRC2 = $(wildcard *.cpp) MINIMIG_SRC = $(wildcard ./support/minimig/*.cpp) +SHARPMZ_SRC = $(wildcard ./support/sharpmz/*.cpp) +ARCHIE_SRC = $(wildcard ./support/archie/*.cpp) -VPATH = ./:./support/minimig +VPATH = ./:./support/minimig:./support/sharpmz:./support/archie -OBJ = $(SRC:.c=.o) $(SRC2:.cpp=.o) $(MINIMIG_SRC:.cpp=.o) -DEP = $(SRC:.c=.d) $(SRC2:.cpp=.d) $(MINIMIG_SRC:.cpp=.d) +OBJ = $(SRC:.c=.o) $(SRC2:.cpp=.o) $(MINIMIG_SRC:.cpp=.o) $(SHARPMZ_SRC:.cpp=.o) $(ARCHIE_SRC:.cpp=.o) +DEP = $(SRC:.c=.d) $(SRC2:.cpp=.d) $(MINIMIG_SRC:.cpp=.d) $(SHARPMZ_SRC:.cpp=.d) $(ARCHIE_SRC:.cpp=.d) CFLAGS = $(DFLAGS) -c -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DVDATE=\"`date +"%y%m%d"`\" LFLAGS = -lc -lstdc++ -lrt diff --git a/menu.cpp b/menu.cpp index 8ae44e9..5b53d05 100644 --- a/menu.cpp +++ b/menu.cpp @@ -44,7 +44,6 @@ along with this program. If not, see . #include "st_tos.h" #include "debug.h" #include "support.h" -#include "archie.h" #include "fpga_io.h" #include #include "cfg.h" diff --git a/sharpmz.h b/sharpmz.h deleted file mode 100644 index 21dfa66..0000000 --- a/sharpmz.h +++ /dev/null @@ -1,469 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Name: sharpmz.h -// Created: July 2018 -// Author(s): Philip Smart -// Description: Sharp MZ series MiSTer Menu Add-On. -// This module is an extension to the MiSTer control program. It adds extensions to -// the menu system and additional I/O control specific to the Sharp MZ series -// emulation. -// -// Credits: -// Copyright: (c) 2018 Philip Smart -// -// History: July 2018 - Initial module written. -// Sept 2018 - Synchronised with main MiSTer codebase. -// -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// This source file 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 source file 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 . -///////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef SHARPMZ_H -#define SHARPMZ_H - -#include "file_io.h" - -// Defaults. -// -#define MZ_TAPE_HEADER_STACK_ADDR 0x10f0 -#define MZ_TAPE_HEADER_SIZE 128 -#define MEMORY_DUMP_FILE "cmp/lastload" -#define MAX_FILENAME_SIZE 1024 - -// HPS commands to fpga block. -// -#define SHARPMZ_EOF 0x00 -#define SHARPMZ_SOF 0x01 -#define SHARPMZ_FILE_TX 0x53 -#define SHARPMZ_FILE_TX_DAT 0x54 -#define SHARPMZ_FILE_INDEX 0x55 -#define SHARPMZ_FILE_INFO 0x56 -#define SHARPMZ_FILE_ADDR 0x57 -#define SHARPMZ_FILE_ADDR_TX 0x58 -#define SHARPMZ_FILE_ADDR_RX 0x59 -#define SHARPMZ_CONFIG_RX 0x5A -#define SHARPMZ_CONFIG_TX 0x5B - -// Memory blocks within the Emulator. -// -#define SHARPMZ_MEMBANK_ALL 0xff -#define SHARPMZ_MEMBANK_SYSROM 0x00 -#define SHARPMZ_MEMBANK_SYSRAM 0x02 -#define SHARPMZ_MEMBANK_KEYMAP 0x03 -#define SHARPMZ_MEMBANK_VRAM 0x04 -#define SHARPMZ_MEMBANK_CMT_HDR 0x05 -#define SHARPMZ_MEMBANK_CMT_DATA 0x06 -#define SHARPMZ_MEMBANK_CGROM 0x07 -#define SHARPMZ_MEMBANK_CGRAM 0x08 -#define SHARPMZ_MEMBANK_MAXBANKS 9 - -// Name of the configuration file. -// -#define SHARPMZ_CONFIG_FILENAME "SHARPMZ.CFG" - -// Name of the core. -// -#define SHARPMZ_CORE_NAME "SharpMZ" - -// Maximum number of machines currently supported by the emulation. -// -#define MAX_MZMACHINES 8 - -// Maximum number of sub-roms per machine. -// -#define MAX_MROMOPTIONS 2 - -// Numeric index of each machine. -// -#define MZ80K_IDX 0 // 000 -#define MZ80C_IDX 1 // 001 -#define MZ1200_IDX 2 // 010 -#define MZ80A_IDX 3 // 011 -#define MZ700_IDX 4 // 100 -#define MZ800_IDX 5 // 101 -#define MZ80B_IDX 6 // 110 -#define MZ2000_IDX 7 // 111 - -// Maximum number of images which can be loaded. -// -#define MAX_IMAGE_TYPES 6 - -// Numeric index of each main rom image category. -// -#define MROM_IDX 0 -#define MROM_80C_IDX 1 -#define CGROM_IDX 2 -#define KEYMAP_IDX 3 -#define USERROM_IDX 4 -#define FDCROM_IDX 5 - -// Numeric index of monitor rom subtypes. -// -#define MONITOR 0 -#define MONITOR_80C 1 - -// Numeric index of Option rom subtypes. -// -#define USERROM 0 -#define FDCROM 1 - -// Tape(CMT) Data types. -// -#define SHARPMZ_CMT_MC 1 // machine code program. -#define SHARPMZ_CMT_BASIC 2 // MZ-80 Basic program. -#define SHARPMZ_CMT_DATA 3 // MZ-80 data file. -#define SHARPMZ_CMT_700DATA 4 // MZ-700 data file. -#define SHARPMZ_CMT_700BASIC 5 // MZ700 Basic program. - -// Numeric id of system registers. -// -#define REGISTER_MODEL 0 -#define REGISTER_DISPLAY 1 -#define REGISTER_CPU 2 -#define REGISTER_AUDIO 3 -#define REGISTER_CMT 4 -#define REGISTER_CMT2 5 -#define REGISTER_USERROM 6 -#define REGISTER_FDCROM 7 -#define REGISTER_8 8 -#define REGISTER_9 9 -#define REGISTER_10 10 -#define REGISTER_11 11 -#define REGISTER_12 12 -#define REGISTER_13 13 -#define REGISTER_DEBUG 14 -#define REGISTER_DEBUG2 15 -#define MAX_REGISTERS 16 - -// Numeric id of bit for a given CMT register flag. -// -#define CMT_PLAY_READY 0 // Tape play back buffer, 0 = empty, 1 = full. -#define CMT_PLAYING 1 // Tape playback, 0 = stopped, 1 = in progress. -#define CMT_RECORD_READY 2 // Tape record buffer full. -#define CMT_RECORDING 3 // Tape recording, 0 = stopped, 1 = in progress. -#define CMT_ACTIVE 4 // Tape transfer in progress, 0 = no activity, 1 = activity. -#define CMT_SENSE 5 // Tape state Sense out. -#define CMT_WRITEBIT 6 // Write bit to MZ. -#define CMT_READBIT 7 // Receive bit from MZ. -#define CMT_MOTOR 8 // Motor on/off. - -// Names of the supported machines. -// -static const char *MZMACHINES[MAX_MZMACHINES] = { "MZ80K", "MZ80C", "MZ1200", "MZ80A", "MZ700", "MZ800", "MZ80B", "MZ2000" }; - -// Default load addresses of roms. -// -static const unsigned int MZLOADADDR[MAX_IMAGE_TYPES][MAX_MZMACHINES] = - { - { 0x00000, 0x03800, 0x07000, 0x0A800, 0x0E000, 0x11800, 0x15000, 0x17800 }, // MROM - { 0x01000, 0x04800, 0x08000, 0x0B800, 0x0F000, 0x12800, 0x15800, 0x18000 }, // MROM 80C - { 0x70000, 0x71000, 0x72000, 0x73000, 0x74000, 0x75000, 0x76000, 0x77000 }, // CGROM - { 0x30000, 0x30100, 0x30200, 0x30300, 0x30400, 0x30500, 0x30600, 0x30700 }, // KEYMAP - { 0x02000, 0x05800, 0x09000, 0x0C800, 0x10000, 0x13800, 0x16000, 0x18800 }, // USERROM - { 0x02800, 0x06000, 0x09800, 0x0D000, 0x10800, 0x14000, 0x16800, 0x19000 } // FDCROM - }; - -// Default size of roms. -// -static const unsigned int MZLOADSIZE[MAX_IMAGE_TYPES][MAX_MZMACHINES] = - { - { 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800 }, // MROM - { 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800 }, // MROM 80C - { 0x0800, 0x0800, 0x0800, 0x0800, 0x1000, 0x0800, 0x0800, 0x0800 }, // CGROM - { 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100 }, // KEYMAP - { 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800 }, // USERROM - { 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000 } // FDCROM - }; - -static const unsigned int MZBANKSIZE[SHARPMZ_MEMBANK_MAXBANKS] = { 0x20000, 0x0000, 0x10000, 0x00800, 0x04000, 0x00080, 0x10000, 0x08000, 0x08000 }; - -#if !defined(MENU_H) && !defined(USER_IO_H) -// Lookup tables for menu entries. -// -const char *SHARPMZ_FAST_TAPE[] = { "Off", "2x", "4x", "8x", "16x", "32x", "Off", "Off", - "Off", "2x", "4x", "8x", "16x", "32x", "Off", "Off", - "Off", "2x", "4x", "8x", "16x", "Off", "Off", "Off" - }; -const char *SHARPMZ_CPU_SPEED[] = { "2MHz", "4MHz", "8MHz", "16MHz", "32MHz", "64MHz", "2MHz", "2MHz", - "3.5MHz", "7MHz", "14MHz", "28MHz", "56MHz", "112MHz", "3.5MHz", "3.5MHz", - "4MHz", "8MHz", "16MHz", "32MHz", "64MHz", "4MHz", "4MHz", "4MHz" - }; -const char *SHARPMZ_TAPE_BUTTONS[] = { "Off", "Play", "Record", "Auto" }; -const char *SHARPMZ_AUDIO_SOURCE[] = { "Sound", "Tape" }; -const char *SHARPMZ_AUDIO_VOLUME[] = { "Max", "14", "13", "12", "11", "10", "9", "8", "7", "6", "5", "4", "3", "2", "1", "Min" }; -const char *SHARPMZ_AUDIO_MUTE[] = { "Off", "Mute" }; -const char *SHARPMZ_USERROM_ENABLED[] = { "Disabled", "Enabled" }; -const char *SHARPMZ_FDCROM_ENABLED[] = { "Disabled", "Enabled" }; -const char *SHARPMZ_ROM_ENABLED[] = { "Disabled", "Enabled" }; -const char *SHARPMZ_AUTO_SAVE_ENABLED[] = { "No", "Yes" }; -const char *SHARPMZ_DISPLAY_TYPE[] = { "Mono 40x25", "Mono 80x25 ", "Colour 40x25", "Colour 80x25", "tbd3", "tbd4", "tbd5", "tbd6" }; -const char *SHARPMZ_ASPECT_RATIO[] = { "4:3", "16:9" }; -const char *SHARPMZ_SCANDOUBLER_FX[] = { "None", "HQ2x", "CRT 25%", "CRT 50%", "CRT 75%", "tbd1", "tbd2", "tbd3" }; -const char *SHARPMZ_VRAMWAIT_MODE[] = { "Off", "On" }; -const char *SHARPMZ_VRAMDISABLE_MODE[] = { "Enabled", "Disabled" }; -const char *SHARPMZ_GRAMDISABLE_MODE[] = { "Enabled", "Disabled" }; -const char *SHARPMZ_PCG_MODE[] = { "ROM", "RAM" }; -const char *SHARPMZ_MACHINE_MODEL[] = { "MZ80K", "MZ80C", "MZ1200", "MZ80A", "MZ700", "MZ800", "MZ80B", "MZ2000" }; -const char *SHARPMZ_DEBUG_ENABLE[] = { "Off", "On" }; -const char *SHARPMZ_DEBUG_LEDS[] = { "Off", "On" }; -const char *SHARPMZ_DEBUG_LEDS_BANK[] = { "T80", "I/O", "IOCTL", "Config", "MZ80C I", "MZ80C II", "MZ80B I", "MZ80B II" }; -const char *SHARPMZ_DEBUG_LEDS_SUBBANK[] = { "Auto", "A7-0", "A15-8", "DI", "Signals", "", "", "", - "Auto", "Video", "PS2Key", "Signals", "", "", "", "", - "Auto", "A23-16", "A15-8", "A7-0", "Signals", "", "", "", - "Auto", "Config 1", "Config 2", "Config 3", "Config 4", "Config 5", "", "", - "Auto", "CS 1", "CS 2", "CS 3", "INT/RE", "Clk", "", "", - "Auto", "CMT 1", "CMT 2", "CMT 3", "", "", "", "", - "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", - }; -const char *SHARPMZ_DEBUG_CPUFREQ[] = { "CPU/CMT", "1MHz", "100KHz", "10KHz", "5KHz", "1KHz", "500Hz", "100Hz", "50Hz", "10Hz", "5Hz", "2Hz", "1Hz", "0.5Hz", "0.2Hz", "0.1Hz" }; -const char *SHARPMZ_DEBUG_LEDS_SMPFREQ[] = { "CPU/CMT", "1MHz", "100KHz", "10KHz", "5KHz", "1KHz", "500Hz", "100Hz", "50Hz", "10Hz", "5Hz", "2Hz", "1Hz", "0.5Hz", "0.2Hz", "0.1Hz" }; -const char *SHARPMZ_MEMORY_BANK[] = { "SysROM", "SysRAM", "KeyMap", "VRAM", "CMTHDR", "CMTDATA", "CGROM", "CGRAM", "All" }; -const char *SHARPMZ_MEMORY_BANK_FILE[] = { "sysrom.dump", "sysram.dump", "keymap.dump", "vram.dump", "cmt_hdr.dump", "cmt_data.dump", "cgrom.dump", "cgram.dump", "all_memory.dump" }; -const char *SHARPMZ_TAPE_TYPE[] = { "N/A", "M/code", "MZ80 Basic", "MZ80 Data", "MZ700 Data", "MZ700 Basic", "N/A" }; -const char *SHARPMZ_HELPTEXT[] = { "Welcome to the Sharp MZ Series! Use the cursor keys to navigate the menus. Use space bar or enter to select an item. Press Esc or F12 to exit the menus. ", - 0 - }; -#else -// External definitions. -extern const char *SHARPMZ_FAST_TAPE[]; -extern const char *SHARPMZ_TAPE_BUTTONS[]; -extern const char *SHARPMZ_AUDIO_SOURCE[]; -extern const char *SHARPMZ_AUDIO_VOLUME[]; -extern const char *SHARPMZ_AUDIO_MUTE[]; -extern const char *SHARPMZ_USERROM_ENABLED[]; -extern const char *SHARPMZ_FDCROM_ENABLED[]; -extern const char *SHARPMZ_ROM_ENABLED[]; -extern const char *SHARPMZ_AUTO_SAVE_ENABLED[]; -extern const char *SHARPMZ_DISPLAY_TYPE[]; -extern const char *SHARPMZ_ASPECT_RATIO[]; -extern const char *SHARPMZ_SCANDOUBLER_FX[]; -extern const char *SHARPMZ_VRAMWAIT_MODE[]; -extern const char *SHARPMZ_VRAMDISABLE_MODE[]; -extern const char *SHARPMZ_GRAMDISABLE_MODE[]; -extern const char *SHARPMZ_PCG_MODE[]; -extern const char *SHARPMZ_MACHINE_MODEL[]; -extern const char *SHARPMZ_CPU_SPEED[]; -extern const char *SHARPMZ_DEBUG_ENABLE[]; -extern const char *SHARPMZ_DEBUG_LEDS[]; -extern const char *SHARPMZ_DEBUG_LEDS_BANK[]; -extern const char *SHARPMZ_DEBUG_CPUFREQ[]; -extern const char *SHARPMZ_DEBUG_LEDS_SMPFREQ[]; -extern const char *SHARPMZ_TAPE_TYPE[]; -extern const char *SHARPMZ_MEMORY_BANK[]; -extern const char *SHARPMZ_MEMORY_BANK_FILE[]; -extern const char *SHARPMZ_HELPTEXT[]; -#endif - -// Structure to store the name, load address and the size of a given rom. -// -typedef struct -{ - char romFileName[MAX_FILENAME_SIZE]; - short romEnabled; - unsigned int loadAddr; - unsigned int loadSize; -} romData_t; - -// Structure to store the configuration data of the emulator. -// -typedef struct -{ - unsigned long system_ctrl; // Original MiSTer system control register. - unsigned char system_reg[MAX_REGISTERS]; // Emulator control register bank. - unsigned char autoSave; // Automatically save tape file if RECORD_READY becomes active. Use filename in header. - unsigned char volume; // Volume setting, using the MiSTer DAC level control. BIt 0-3 = Attenuation, bit 4 = Mute. - romData_t romMonitor[MAX_MZMACHINES][MAX_MROMOPTIONS]; // Details of rom monitor images to upload. - romData_t romCG[MAX_MZMACHINES]; // Details of rom character generator images to upload. - romData_t romKeyMap[MAX_MZMACHINES]; // Details of rom Key mapping images to upload. - romData_t romUser[MAX_MZMACHINES]; // Details of User ROM images to upload. - romData_t romFDC[MAX_MZMACHINES]; // Details of FDC ROM images to upload. -} sharpmz_config_t; - -// Structures to store the tape file queue. -// -typedef struct tape_queue_node tape_queue_node_t; -struct tape_queue_node -{ - char fileName[MAX_FILENAME_SIZE]; - tape_queue_node_t *next; -}; -// -typedef struct -{ - struct tape_queue_node *top; - struct tape_queue_node *bottom; - unsigned short elements; -} tape_queue_t; - -// MZ Series Tape header structure - 128 bytes. -// -typedef struct -{ - unsigned char dataType; // 01 = machine code program. - // 02 MZ-80 Basic program. - // 03 MZ-80 data file. - // 04 MZ-700 data file. - // 05 MZ-700 Basic program. - char fileName[17]; // File name. - unsigned short fileSize; // Size of data partition. - unsigned short loadAddress; // Load address of the program/data. - unsigned short execAddress; // Execution address of program. - unsigned char comment[104]; // Free text or code area. -} sharpmz_tape_header_t; - -// UI state machine states, extension set to the main menu.cpp MENU enum. Values are set above the original enum so that they -// are detected and handle within this sharpmz code base. -// -enum SHARPMZ_MENU -{ - // Sharp MZ menu entries - MENU_SHARPMZ_MAIN1 = 0xa0, - MENU_SHARPMZ_MAIN2 = 0xa1, - MENU_SHARPMZ_TAPE_STORAGE1 = 0xa2, - MENU_SHARPMZ_TAPE_STORAGE2 = 0xa3, - MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM = 0xa4, - MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM2 = 0xa5, - MENU_SHARPMZ_TAPE_STORAGE_QUEUE_TAPE_TO_CMT = 0xa6, - MENU_SHARPMZ_TAPE_STORAGE_QUEUE_TAPE_TO_CMT2 = 0xa7, - MENU_SHARPMZ_TAPE_STORAGE_SAVE_TAPE_FROM_CMT = 0xa8, - MENU_SHARPMZ_TAPE_STORAGE_SAVE_TAPE_FROM_CMT2 = 0xa9, - MENU_SHARPMZ_FLOPPY_STORAGE1 = 0xaa, - MENU_SHARPMZ_FLOPPY_STORAGE2 = 0xab, - MENU_SHARPMZ_DISPLAY1 = 0xb0, - MENU_SHARPMZ_DISPLAY2 = 0xb1, - MENU_SHARPMZ_MACHINE1 = 0xb2, - MENU_SHARPMZ_MACHINE2 = 0xb3, - MENU_SHARPMZ_ROMS1 = 0xb4, - MENU_SHARPMZ_ROMS2 = 0xb5, - MENU_SHARPMZ_ROM_FILE_SELECTED = 0xb6, - MENU_SHARPMZ_DEBUG1 = 0xb7, - MENU_SHARPMZ_DEBUG2 = 0xb8 -}; - -// Prototypes. -// -void sharpmz_reset(unsigned long, unsigned long); -short sharpmz_read_ram(char *, short); -void sharpmz_init(void); -void sharpmz_poll(void); -short sharpmz_read_ram(char *, short); -const char *sharpmz_get_rom_name(void); -void sharpmz_set_config_register(short addr, unsigned char value); -unsigned char sharpmz_read_config_register(short addr); -void sharpmz_send_file(romData_t &, char *); -void sharpmz_set_rom(romData_t *); -int sharpmz_FileRead(fileTYPE *file, void *pBuffer, int nSize); -short sharpmz_get_machine_group(void); -unsigned char sharpmz_get_auto_save_enabled(void); -int sharpmz_get_fasttape(void); -int sharpmz_get_display_type(void); -int sharpmz_get_aspect_ratio(void); -int sharpmz_get_scandoubler_fx(void); -int sharpmz_get_vram_wait_mode(void); -int sharpmz_get_vram_disable_mode(void); -int sharpmz_get_gram_disable_mode(void); -int sharpmz_get_pcg_mode(void); -int sharpmz_get_machine_model(void); -int sharpmz_get_cpu_speed(void); -int sharpmz_get_audio_source(void); -int sharpmz_get_audio_volume(void); -int sharpmz_get_audio_mute(void); -int sharpmz_get_debug_enable(void); -int sharpmz_get_debug_leds(void); -int sharpmz_get_tape_buttons(void); -short sharpmz_get_next_memory_bank(void); -short sharpmz_get_next_debug_leds_bank(void); -short sharpmz_get_next_debug_leds_subbank(unsigned char); -short sharpmz_get_next_debug_cpufreq(void); -short sharpmz_get_next_debug_leds_smpfreq(void); -void sharpmz_set_auto_save_enabled(unsigned char); -void sharpmz_set_fasttape(short, short); -void sharpmz_set_display_type(short, short); -void sharpmz_set_aspect_ratio(short, short); -void sharpmz_set_scandoubler_fx(short, short); -void sharpmz_set_vram_wait_mode(short, short); -void sharpmz_set_vram_disable_mode(short, short); -void sharpmz_set_gram_disable_mode(short, short); -void sharpmz_set_pcg_mode(short, short); -void sharpmz_set_machine_model(short, short); -void sharpmz_set_cpu_speed(short, short); -void sharpmz_set_audio_source(short, short); -void sharpmz_set_audio_volume(short, short); -void sharpmz_set_audio_mute(short, short); -void sharpmz_set_debug_enable(short, short); -void sharpmz_set_debug_leds(short, short); -void sharpmz_set_debug_leds_bank(short, short); -void sharpmz_set_debug_leds_subbank(short, short); -void sharpmz_set_debug_cpufreq(short, short); -void sharpmz_set_debug_leds_smpfreq(short, short); -void sharpmz_set_tape_buttons(short, short); -int sharpmz_save_config(void); -int sharpmz_reset_config(short); -int sharpmz_reload_config(short); -short sharpmz_get_next_machine_model(void); -short sharpmz_get_user_rom_enabled(short); -void sharpmz_set_user_rom_enabled(short, short, short); -short sharpmz_get_fdc_rom_enabled(short); -void sharpmz_set_fdc_rom_enabled(short, short, short); -short sharpmz_get_custom_rom_enabled(short, short); -void sharpmz_set_custom_rom_enabled(short, short, short); -char *sharpmz_get_rom_file(short, short); -void sharpmz_set_rom_file(short, short, char *); -short sharpmz_read_tape_header(const char *); -short sharpmz_load_tape_to_ram(const char *, unsigned char); -short sharpmz_save_tape_from_cmt(const char *); -sharpmz_tape_header_t *sharpmz_get_tape_header(void); -const char *sharpmz_get_auto_save_enabled_string(void); -const char *sharpmz_get_fasttape_string(void); -const char *sharpmz_get_display_type_string(void); -const char *sharpmz_get_aspect_ratio_string(void); -const char *sharpmz_get_scandoubler_fx_string(void); -const char *sharpmz_get_vram_wait_mode_string(void); -const char *sharpmz_get_vram_disable_mode_string(void); -const char *sharpmz_get_gram_disable_mode_string(void); -const char *sharpmz_get_pcg_mode_string(void); -const char *sharpmz_get_machine_model_string(void); -const char *sharpmz_get_cpu_speed_string(void); -const char *sharpmz_get_audio_source_string(void); -const char *sharpmz_get_audio_volume_string(void); -const char *sharpmz_get_audio_mute_string(void); -const char *sharpmz_get_debug_enable_string(void); -const char *sharpmz_get_debug_leds_string(void); -const char *sharpmz_get_debug_leds_bank_string(void); -const char *sharpmz_get_debug_leds_subbank_string(void); -const char *sharpmz_get_debug_cpufreq_string(void); -const char *sharpmz_get_debug_leds_smpfreq_string(void); -const char *sharpmz_get_machine_model_string(short machineModel); -const char *sharpmz_get_machine_model_string(void); -const char *sharpmz_get_user_rom_enabled_string(short); -const char *sharpmz_get_fdc_rom_enabled_string(short); -const char *sharpmz_get_custom_rom_enabled_string(short romEnabled); -const char *sharpmz_get_tape_type_string(void); -const char *sharpmz_get_tape_buttons_string(void); -const char *sharpmz_get_memory_bank_string(short); -const char *sharpmz_get_memory_bank_file(short); -void sharpmz_push_filename(char *); -char *sharpmz_pop_filename(void); -char *sharpmz_get_next_filename(char); -void sharpmz_clear_filelist(void); -void sharpmz_select_file(const char*, unsigned char, char *, char, char *); -int sharpmz_default_ui_state(void); -int sharpmz_ui(int, int, int, int, - unsigned char *, unsigned char *, unsigned char *, unsigned char *, - unsigned int *, char *, const char **, char *, - unsigned char *, unsigned char *, unsigned char *, unsigned char *, - char *, - unsigned char, unsigned char, unsigned char, unsigned char, - unsigned char, unsigned char, unsigned char, unsigned char); -#endif // SHARPMZ_H diff --git a/support.h b/support.h index 9e521da..034eee9 100644 --- a/support.h +++ b/support.h @@ -6,3 +6,6 @@ // SharpMz support #include "support/sharpmz/sharpmz.h" + +// Archie support +#include "support/archie/archie.h" diff --git a/archie.cpp b/support/archie/archie.cpp similarity index 99% rename from archie.cpp rename to support/archie/archie.cpp index bf206d2..3da5c6e 100644 --- a/archie.cpp +++ b/support/archie/archie.cpp @@ -1,11 +1,11 @@ #include "stdio.h" #include "string.h" -#include "hardware.h" -#include "fpga_io.h" -#include "menu.h" +#include "../../hardware.h" +#include "../../fpga_io.h" +#include "../../menu.h" #include "archie.h" -#include "debug.h" -#include "user_io.h" +#include "../../debug.h" +#include "../../user_io.h" #define MAX_FLOPPY 4 @@ -97,7 +97,7 @@ void archie_set_ar(char i) { if (i) config.system_ctrl |= 1; else config.system_ctrl &= ~1; - user_io_8bit_set_status((i ? -1 : 0), 2); + user_io_8bit_set_status((i ? -1 : 0), 2); } char archie_get_ar() @@ -108,7 +108,7 @@ char archie_get_ar() void archie_set_amix(char i) { config.system_ctrl = (config.system_ctrl & ~0b110) | ((i & 3)<<1); - user_io_8bit_set_status(config.system_ctrl << 1, 0b1100); + user_io_8bit_set_status(config.system_ctrl << 1, 0b1100); } char archie_get_amix() diff --git a/archie.h b/support/archie/archie.h similarity index 95% rename from archie.h rename to support/archie/archie.h index 72fd748..ef599fb 100644 --- a/archie.h +++ b/support/archie/archie.h @@ -1,7 +1,7 @@ #ifndef ARCHIE_H #define ARCHIE_H -#include "file_io.h" +#include "../../file_io.h" void archie_init(void); void archie_poll(void); diff --git a/support/sharpmz/sharpmz.cpp b/support/sharpmz/sharpmz.cpp index 965044f..c6bd362 100644 --- a/support/sharpmz/sharpmz.cpp +++ b/support/sharpmz/sharpmz.cpp @@ -35,7 +35,7 @@ #include #include "../../hardware.h" #include "../../fpga_io.h" -#include "../../sharpmz.h" +#include "sharpmz.h" #include "../../osd.h" #include "../../menu.h" #include "../../debug.h" diff --git a/user_io.cpp b/user_io.cpp index 1485fb9..6da7a7c 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -11,7 +11,6 @@ #include "hardware.h" #include "osd.h" #include "user_io.h" -#include "archie.h" #include "debug.h" #include "st_ikbd.h" From 62058bfa32dfbd60bb82abffc832d40d4af2f849 Mon Sep 17 00:00:00 2001 From: karllurman Date: Thu, 1 Nov 2018 11:15:58 +1100 Subject: [PATCH 6/7] St and X86 moved to support --- Makefile | 15 ++- menu.cpp | 8 +- support.h | 7 ++ st_ikbd.cpp => support/st/st_ikbd.cpp | 6 +- st_ikbd.h => support/st/st_ikbd.h | 0 st_tos.cpp => support/st/st_tos.cpp | 12 +- st_tos.h => support/st/st_tos.h | 2 +- x86.cpp => support/x86/x86.cpp | 166 +++++++++++++------------- x86.h => support/x86/x86.h | 0 user_io.cpp | 9 +- 10 files changed, 119 insertions(+), 106 deletions(-) rename st_ikbd.cpp => support/st/st_ikbd.cpp (99%) rename st_ikbd.h => support/st/st_ikbd.h (100%) rename st_tos.cpp => support/st/st_tos.cpp (95%) rename st_tos.h => support/st/st_tos.h (99%) rename x86.cpp => support/x86/x86.cpp (99%) rename x86.h => support/x86/x86.h (100%) diff --git a/Makefile b/Makefile index 8b50f45..778735a 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ SHELL = /bin/bash -o pipefail # using gcc version 5.4.1 20161213 (Linaro GCC 5.4-2017.01-rc2) +# This is the location of the linaro compiler in the wsbu/toolchain-linaro docker container BASE = /opt/linaro/bin/arm-linux-gnueabihf CC = $(BASE)-gcc @@ -18,11 +19,13 @@ SRC2 = $(wildcard *.cpp) MINIMIG_SRC = $(wildcard ./support/minimig/*.cpp) SHARPMZ_SRC = $(wildcard ./support/sharpmz/*.cpp) ARCHIE_SRC = $(wildcard ./support/archie/*.cpp) +ST_SRC = $(wildcard ./support/st/*.cpp) +X86_SRC = $(wildcard ./support/x86/*.cpp) -VPATH = ./:./support/minimig:./support/sharpmz:./support/archie +VPATH = ./:./support/minimig:./support/sharpmz:./support/archie:./support/st:./support/x86 -OBJ = $(SRC:.c=.o) $(SRC2:.cpp=.o) $(MINIMIG_SRC:.cpp=.o) $(SHARPMZ_SRC:.cpp=.o) $(ARCHIE_SRC:.cpp=.o) -DEP = $(SRC:.c=.d) $(SRC2:.cpp=.d) $(MINIMIG_SRC:.cpp=.d) $(SHARPMZ_SRC:.cpp=.d) $(ARCHIE_SRC:.cpp=.d) +OBJ = $(SRC:.c=.o) $(SRC2:.cpp=.o) $(MINIMIG_SRC:.cpp=.o) $(SHARPMZ_SRC:.cpp=.o) $(ARCHIE_SRC:.cpp=.o) $(ST_SRC:.cpp=.o) $(X86_SRC:.cpp=.o) +DEP = $(SRC:.c=.d) $(SRC2:.cpp=.d) $(MINIMIG_SRC:.cpp=.d) $(SHARPMZ_SRC:.cpp=.d) $(ARCHIE_SRC:.cpp=.d) $(ST_SRC:.cpp=.d) $(X86_SRC:.cpp=.d) CFLAGS = $(DFLAGS) -c -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -DVDATE=\"`date +"%y%m%d"`\" LFLAGS = -lc -lstdc++ -lrt @@ -37,6 +40,12 @@ clean: rm -f *.d *.o *.elf *.map *.lst *.bak *.rej *.org *.user *~ $(PRJ) rm -rf obj .vs DTAR* x64 +cleanall: + rm -rf *.d *.o *.elf *.map *.lst *.bak *.rej *.org *.user *~ $(PRJ) + rm -rf obj .vs DTAR* x64 + find . -name '*.o' -delete + find . -name '*.d' -delete + %.o: %.c @$(info $<) @$(CC) $(CFLAGS) -std=gnu99 -o $@ -c $< 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g' diff --git a/menu.cpp b/menu.cpp index 5b53d05..38104fc 100644 --- a/menu.cpp +++ b/menu.cpp @@ -34,23 +34,23 @@ along with this program. If not, see . #include #include #include +#include #include "stdio.h" #include "string.h" + #include "file_io.h" #include "osd.h" #include "hardware.h" #include "menu.h" #include "user_io.h" -#include "st_tos.h" #include "debug.h" -#include "support.h" #include "fpga_io.h" -#include #include "cfg.h" #include "input.h" -#include "x86.h" #include "battery.h" +#include "support.h" + /*menu states*/ enum MENU { diff --git a/support.h b/support.h index 034eee9..a0373ad 100644 --- a/support.h +++ b/support.h @@ -9,3 +9,10 @@ // Archie support #include "support/archie/archie.h" + +// ST (Atari) support +#include "support/st/st_ikbd.h" +#include "support/st/st_tos.h" + +// X86 support +#include "support/x86/x86.h" \ No newline at end of file diff --git a/st_ikbd.cpp b/support/st/st_ikbd.cpp similarity index 99% rename from st_ikbd.cpp rename to support/st/st_ikbd.cpp index ab44543..2ad1f68 100644 --- a/st_ikbd.cpp +++ b/support/st/st_ikbd.cpp @@ -27,10 +27,10 @@ M1 tank platoon/A_385 fixed #include #include -#include "user_io.h" -#include "spi.h" +#include "../../user_io.h" +#include "../../spi.h" #include "st_ikbd.h" -#include "debug.h" +#include "../../debug.h" #define IKBD_AUTO_MS 20 diff --git a/st_ikbd.h b/support/st/st_ikbd.h similarity index 100% rename from st_ikbd.h rename to support/st/st_ikbd.h diff --git a/st_tos.cpp b/support/st/st_tos.cpp similarity index 95% rename from st_tos.cpp rename to support/st/st_tos.cpp index d8c9206..c0c5ea4 100644 --- a/st_tos.cpp +++ b/support/st/st_tos.cpp @@ -2,14 +2,14 @@ #include #include -#include "hardware.h" -#include "menu.h" +#include "../../hardware.h" +#include "../../menu.h" #include "st_tos.h" -#include "file_io.h" -#include "debug.h" -#include "user_io.h" +#include "../../file_io.h" +#include "../../debug.h" +#include "../../user_io.h" #include "st_ikbd.h" -#include "fpga_io.h" +#include "../../fpga_io.h" #define CONFIG_FILENAME "MIST.CFG" diff --git a/st_tos.h b/support/st/st_tos.h similarity index 99% rename from st_tos.h rename to support/st/st_tos.h index 21691b2..58b0323 100644 --- a/st_tos.h +++ b/support/st/st_tos.h @@ -1,7 +1,7 @@ #ifndef __ST_TOS_H__ #define __ST_TOS_H__ -#include "file_io.h" +#include "../../file_io.h" // FPGA spi cmommands #define MIST_INVALID 0x00 diff --git a/x86.cpp b/support/x86/x86.cpp similarity index 99% rename from x86.cpp rename to support/x86/x86.cpp index afbd7dd..aabb4a3 100644 --- a/x86.cpp +++ b/support/x86/x86.cpp @@ -24,18 +24,18 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include "spi.h" -#include "user_io.h" -#include "file_io.h" -#include "fpga_io.h" +#include "../../spi.h" +#include "../../user_io.h" +#include "../../file_io.h" +#include "../../fpga_io.h" #define ALT_CPU_CPU_FREQ 90000000u @@ -62,52 +62,52 @@ typedef struct static x86_config config; -static uint8_t dma_sdio(int status) -{ - uint8_t res; - EnableFpga(); - spi8(UIO_DMA_SDIO); - res = spi_w((uint16_t)status); - DisableFpga(); - return res; -} - -static uint32_t dma_get(uint32_t address) -{ - EnableFpga(); - spi8(UIO_DMA_READ); - spi32w(address); - uint32_t res = spi32w(0); - DisableFpga(); - return res; -} - -static void dma_set(uint32_t address, uint32_t data) -{ - EnableFpga(); - spi8(UIO_DMA_WRITE); - spi32w(address); - spi32w(data); - DisableFpga(); -} - -static void dma_sendbuf(uint32_t address, uint32_t length, uint32_t *data) -{ - EnableFpga(); - spi8(UIO_DMA_WRITE); - spi32w(address); - while (length--) spi32w(*data++); - DisableFpga(); -} +static uint8_t dma_sdio(int status) +{ + uint8_t res; + EnableFpga(); + spi8(UIO_DMA_SDIO); + res = spi_w((uint16_t)status); + DisableFpga(); + return res; +} -static void dma_rcvbuf(uint32_t address, uint32_t length, uint32_t *data) -{ - EnableFpga(); - spi8(UIO_DMA_READ); - spi32w(address); - while (length--) *data++ = spi32w(0); - DisableFpga(); -} +static uint32_t dma_get(uint32_t address) +{ + EnableFpga(); + spi8(UIO_DMA_READ); + spi32w(address); + uint32_t res = spi32w(0); + DisableFpga(); + return res; +} + +static void dma_set(uint32_t address, uint32_t data) +{ + EnableFpga(); + spi8(UIO_DMA_WRITE); + spi32w(address); + spi32w(data); + DisableFpga(); +} + +static void dma_sendbuf(uint32_t address, uint32_t length, uint32_t *data) +{ + EnableFpga(); + spi8(UIO_DMA_WRITE); + spi32w(address); + while (length--) spi32w(*data++); + DisableFpga(); +} + +static void dma_rcvbuf(uint32_t address, uint32_t length, uint32_t *data) +{ + EnableFpga(); + spi8(UIO_DMA_READ); + spi32w(address); + while (length--) *data++ = spi32w(0); + DisableFpga(); +} static int load_bios(const char* name, uint8_t index) { @@ -178,30 +178,30 @@ static __inline fileTYPE *get_image(uint32_t type) return &fdd_image1; } -static int img_mount(uint32_t type, char *name) -{ - FileClose(get_image(type)); - - int writable = FileCanWrite(name); - int ret = FileOpenEx(get_image(type), name, writable ? (O_RDWR | O_SYNC) : O_RDONLY); - if (!ret) - { - get_image(type)->size = 0; - printf("Failed to open file %s\n", name); - return 0; - } - - printf("Mount %s as %s\n", name, writable ? "read-write" : "read-only"); - return 1; -} +static int img_mount(uint32_t type, char *name) +{ + FileClose(get_image(type)); -static int img_read(uint32_t type, uint32_t lba, void *buf, uint32_t len) + int writable = FileCanWrite(name); + int ret = FileOpenEx(get_image(type), name, writable ? (O_RDWR | O_SYNC) : O_RDONLY); + if (!ret) + { + get_image(type)->size = 0; + printf("Failed to open file %s\n", name); + return 0; + } + + printf("Mount %s as %s\n", name, writable ? "read-write" : "read-only"); + return 1; +} + +static int img_read(uint32_t type, uint32_t lba, void *buf, uint32_t len) { if (!FileSeekLBA(get_image(type), lba)) return 0; return FileReadAdv(get_image(type), buf, len); } -static int img_write(uint32_t type, uint32_t lba, void *buf, uint32_t len) +static int img_write(uint32_t type, uint32_t lba, void *buf, uint32_t len) { if (!FileSeekLBA(get_image(type), lba)) return 0; return FileWriteAdv(get_image(type), buf, len); @@ -488,14 +488,14 @@ static int hdd_set(uint32_t num) return hdd[num].present; } -static uint8_t bin2bcd(unsigned val) -{ - return ((val / 10) << 4) + (val % 10); +static uint8_t bin2bcd(unsigned val) +{ + return ((val / 10) << 4) + (val % 10); } void x86_init() { - user_io_8bit_set_status(UIO_STATUS_RESET, UIO_STATUS_RESET); + user_io_8bit_set_status(UIO_STATUS_RESET, UIO_STATUS_RESET); load_bios("ao486/boot0.rom", 0); load_bios("ao486/boot1.rom", 1); @@ -532,7 +532,7 @@ void x86_init() //-------------------------------------------------------------------------- floppy fdd_set(config.fdd_name); - + //-------------------------------------------------------------------------- hdd hdd_set(0); @@ -551,8 +551,8 @@ void x86_init() unsigned char translate_mode = 1; //LBA translate_mode = (translate_mode << 6) | (translate_mode << 4) | (translate_mode << 2) | translate_mode; - time_t t = time(NULL); - struct tm tm = *localtime(&t); + time_t t = time(NULL); + struct tm tm = *localtime(&t); //rtc contents 0-127 uint32_t tmp[128] = { @@ -650,8 +650,8 @@ void x86_init() cmos[0x2F] = sum & 0xFF; for(unsigned int i=0; i Date: Thu, 1 Nov 2018 15:48:03 +1100 Subject: [PATCH 7/7] Moving the docker specific stuff out into another repo --- Makefile | 3 +-- README.md | 50 -------------------------------------------------- 2 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 README.md diff --git a/Makefile b/Makefile index 778735a..08baa96 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,7 @@ SHELL = /bin/bash -o pipefail # using gcc version 5.4.1 20161213 (Linaro GCC 5.4-2017.01-rc2) -# This is the location of the linaro compiler in the wsbu/toolchain-linaro docker container -BASE = /opt/linaro/bin/arm-linux-gnueabihf +BASE = arm-linux-gnueabihf CC = $(BASE)-gcc LD = $(CC) diff --git a/README.md b/README.md deleted file mode 100644 index fe47695..0000000 --- a/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# Main_MiSTer - -Goal of this is to sort out container building for - -# Development Setup: Boot2Docker, Windows 7 - -- Download and install Docker - you won't be able to do Docker for Windows unless you are on a newer version of the OS. -- Once installed and tested, ssh into your boot2docker guest machine -- Issue this command to pull down a working linaro toolchain: -``` -docker pull wsbu/toolchain-linaro -``` -- Issue this command to run a bash on the linaro container and mount the repo root folder inside the container at /source: -``` -docker run -ti -v :/source wsbu/toolchain-linaro bash -``` -- Go into the /source folder -``` -cd /source -``` -- Make MiSTer -``` -root@d6f7eba5be6f:/source# make -sxmlc.c -ini_parser.cpp -minimig_hdd.cpp -cfg.cpp -spi.cpp -user_io.cpp -archie.cpp -st_ikbd.cpp -tzx2wav.cpp -x86.cpp -battery.cpp -hardware.cpp -st_tos.cpp -input.cpp -minimig_boot.cpp -brightness.cpp -DiskImage.cpp -file_io.cpp -fpga_io.cpp -minimig_config.cpp -sharpmz.cpp -minimig_fdd.cpp -menu.cpp -osd.cpp -main.cpp -MiSTer -```