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
This commit is contained in:
14
Makefile
14
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 $@)
|
||||
|
||||
87
menu.cpp
87
menu.cpp
@@ -38,17 +38,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#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 <stdbool.h>
|
||||
#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;
|
||||
|
||||
|
||||
3
osd.cpp
3
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;
|
||||
|
||||
|
||||
4
support.h
Normal file
4
support.h
Normal file
@@ -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"
|
||||
@@ -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];
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -25,13 +25,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#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 <file> into <drive>
|
||||
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 <file> into <drive>
|
||||
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);
|
||||
}
|
||||
@@ -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);
|
||||
@@ -25,13 +25,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#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;
|
||||
}
|
||||
}
|
||||
531
user_io.cpp
531
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())
|
||||
|
||||
Reference in New Issue
Block a user