mirror of
https://github.com/mist-devel/mist-firmware.git
synced 2026-04-18 16:37:20 +00:00
Introduce UIO_SET_MOD and ARC files
ARC files has a simple ini format: [ARC] RBF=RBFNAME MOD=core variant number (0-127) CONF=...one config string line... CONF=...one more config string line...
This commit is contained in:
2
Makefile
2
Makefile
@@ -10,7 +10,7 @@ DUMP = $(BASE)-objdump
|
||||
TODAY = `date +"%m/%d/%y"`
|
||||
|
||||
PRJ = firmware
|
||||
SRC = Cstartup_SAM7.c fat.c fdd.c firmware.c fpga.c hardware.c spi.c hdd.c main.c menu.c mmc.c osd.c state.c syscalls.c user_io.c data_io.c boot.c rafile.c idxfile.c config.c tos.c ikbd.c xmodem.c ini_parser.c mist_cfg.c archie.c
|
||||
SRC = Cstartup_SAM7.c fat.c fdd.c firmware.c fpga.c hardware.c spi.c hdd.c main.c menu.c mmc.c osd.c state.c syscalls.c user_io.c data_io.c boot.c rafile.c idxfile.c config.c tos.c ikbd.c xmodem.c ini_parser.c mist_cfg.c archie.c arc_file.c
|
||||
SRC += usb/max3421e.c usb/usb.c usb/hub.c usb/hid.c usb/hidparser.c usb/timer.c usb/asix.c usb/pl2303.c usb/usbrtc.c usb/joymapping.c
|
||||
# SRC += usb/storage.c
|
||||
SRC += cdc_enumerate.c cdc_control.c
|
||||
|
||||
71
arc_file.c
Normal file
71
arc_file.c
Normal file
@@ -0,0 +1,71 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ini_parser.h"
|
||||
#include "arc_file.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define MAX_CONF_SIZE 256
|
||||
|
||||
static char mod;
|
||||
static char rbfname[9];
|
||||
static char conf[MAX_CONF_SIZE];
|
||||
static int conf_ptr;
|
||||
|
||||
void arc_set_rbf();
|
||||
void arc_set_conf();
|
||||
|
||||
// arc ini sections
|
||||
const ini_section_t arc_ini_sections[] = {
|
||||
{1, "ARC"}
|
||||
};
|
||||
|
||||
// arc ini vars
|
||||
const ini_var_t arc_ini_vars[] = {
|
||||
{"MOD", (void*)(&mod), UINT8, 0, 127, 1},
|
||||
{"RBF", (void*)rbfname, STRING, 1, 8, 1},
|
||||
{"CONF", (void*)arc_set_conf, CUSTOM_HANDLER, 0, 0, 1},
|
||||
};
|
||||
|
||||
|
||||
extern unsigned long iCurrentDirectory; // cluster number of current directory, 0 for root
|
||||
|
||||
void arc_set_conf(char *c)
|
||||
{
|
||||
if ((conf_ptr+strlen(c))<MAX_CONF_SIZE-1) {
|
||||
strcpy(&conf[conf_ptr], c);
|
||||
strcat(conf, ";");
|
||||
conf_ptr += strlen(c) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
char arc_open(char *fname)
|
||||
{
|
||||
ini_cfg_t arc_ini_cfg;
|
||||
|
||||
arc_ini_cfg.filename = fname;
|
||||
arc_ini_cfg.dir = iCurrentDirectory;
|
||||
arc_ini_cfg.sections = arc_ini_sections;
|
||||
arc_ini_cfg.vars = arc_ini_vars;
|
||||
arc_ini_cfg.nsections = (int)(sizeof(arc_ini_sections) / sizeof(ini_section_t));
|
||||
arc_ini_cfg.nvars = (int)(sizeof(arc_ini_vars) / sizeof(ini_var_t));
|
||||
|
||||
rbfname[8] = 0;
|
||||
conf[0] = 0;
|
||||
conf_ptr = 0;
|
||||
mod = -1;
|
||||
ini_parse(&arc_ini_cfg, 0);
|
||||
iprintf("arc conf=%s\n",conf);
|
||||
return mod;
|
||||
}
|
||||
|
||||
char *arc_get_rbfname()
|
||||
{
|
||||
return rbfname;
|
||||
}
|
||||
|
||||
char *arc_get_conf()
|
||||
{
|
||||
return conf;
|
||||
}
|
||||
14
arc_file.h
Normal file
14
arc_file.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* arc_file.h
|
||||
* Open/parse .arc (Arcade) files
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ARC_FILE_H
|
||||
#define ARC_FILE_H
|
||||
|
||||
char arc_open(char *fname);
|
||||
char *arc_get_rbfname();
|
||||
char *arc_get_conf();
|
||||
|
||||
#endif // DATA_IO_H
|
||||
@@ -286,7 +286,7 @@ void ini_parse(const ini_cfg_t* cfg, const char *alter_section)
|
||||
if ((ini_fp = fopen(cfg->filename, "rb")) == NULL) {
|
||||
#else
|
||||
memset(&ini_file, 0, sizeof(ini_file));
|
||||
if (!FileOpen(&ini_file, cfg->filename)) {
|
||||
if (!FileOpenDir(&ini_file, cfg->filename, cfg->dir)) {
|
||||
#endif
|
||||
ini_parser_debugf("Can't open file %s !", cfg->filename);
|
||||
return;
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
const char* filename;
|
||||
unsigned long dir;
|
||||
const ini_section_t* sections;
|
||||
const ini_var_t* vars;
|
||||
int nsections;
|
||||
|
||||
22
menu.c
22
menu.c
@@ -48,6 +48,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "debug.h"
|
||||
#include "boot.h"
|
||||
#include "archie.h"
|
||||
#include "arc_file.h"
|
||||
#include "usb/joymapping.h"
|
||||
|
||||
// test features (not used right now)
|
||||
@@ -171,8 +172,7 @@ void SelectFile(char* pFileExt, unsigned char Options, unsigned char MenuSelect,
|
||||
|
||||
iprintf("pFileExt = %3s\n", pFileExt);
|
||||
strcpy(fs_pFileExt, pFileExt);
|
||||
fs_ShowExt = (strlen(fs_pFileExt)>3 || strchr(fs_pFileExt, '*') || strchr(fs_pFileExt, '?'));
|
||||
// fs_pFileExt = pFileExt;
|
||||
fs_ShowExt = ((strlen(fs_pFileExt)>3 && strncmp(fs_pFileExt, "RBFARC", 6)) || strchr(fs_pFileExt, '*') || strchr(fs_pFileExt, '?'));
|
||||
fs_Options = Options;
|
||||
fs_MenuSelect = MenuSelect;
|
||||
fs_MenuCancel = MenuCancel;
|
||||
@@ -597,7 +597,7 @@ void HandleUI(void)
|
||||
else {
|
||||
// the "menu" core is special in jumps directly to the core selection menu
|
||||
if(!strcmp(user_io_get_core_name(), "MENU"))
|
||||
SelectFile("RBF", SCAN_LFN | SCAN_SYSDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_FIRMWARE1, 0);
|
||||
SelectFile("RBFARC", SCAN_LFN | SCAN_SYSDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_FIRMWARE1, 0);
|
||||
else
|
||||
menustate = MENU_8BIT_MAIN1;
|
||||
}
|
||||
@@ -3242,7 +3242,7 @@ void HandleUI(void)
|
||||
OsdClear();
|
||||
}
|
||||
else if (menusub == fat_uses_mmc()?1:0) {
|
||||
SelectFile("RBF", SCAN_LFN | SCAN_SYSDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_FIRMWARE1, 0);
|
||||
SelectFile("RBFARC", SCAN_LFN | SCAN_SYSDIR, MENU_FIRMWARE_CORE_FILE_SELECTED, MENU_FIRMWARE1, 0);
|
||||
}
|
||||
else if (menusub == fat_uses_mmc()?2:1) {
|
||||
switch(user_io_core_type()) {
|
||||
@@ -3277,6 +3277,20 @@ void HandleUI(void)
|
||||
else
|
||||
OsdCoreNameSet(file.name);
|
||||
|
||||
char mod = 0;
|
||||
|
||||
if (!strncasecmp(&file.name[8],"ARC",3)) {
|
||||
mod = arc_open(file.name);
|
||||
if(mod < 0) { // error
|
||||
menustate = MENU_NONE1;
|
||||
break;
|
||||
}
|
||||
strncpy(file.name, arc_get_rbfname(), 8);
|
||||
strncpy(&file.name[8], "RBF", 3);
|
||||
}
|
||||
|
||||
user_io_set_core_mod(mod);
|
||||
|
||||
// reset fpga with core
|
||||
fpga_init(file.name);
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ const ini_cfg_t mist_ini_cfg = {
|
||||
#else
|
||||
"MIST INI",
|
||||
#endif
|
||||
0,
|
||||
mist_ini_sections,
|
||||
mist_ini_vars,
|
||||
(int)(sizeof(mist_ini_sections) / sizeof(ini_section_t)),
|
||||
|
||||
54
user_io.c
54
user_io.c
@@ -21,7 +21,7 @@
|
||||
#include "mmc.h"
|
||||
#include "tos.h"
|
||||
#include "errors.h"
|
||||
#include "ini_parser.h"
|
||||
#include "arc_file.h"
|
||||
|
||||
// up to 16 key can be remapped
|
||||
#define MAX_REMAP 16
|
||||
@@ -50,6 +50,9 @@ static char core_type_8bit_with_config_string = 0;
|
||||
// core supports direct ROM upload via SS4
|
||||
extern char rom_direct_upload;
|
||||
|
||||
// core variant (mostly for arcades)
|
||||
static char core_mod = 0;
|
||||
|
||||
// permanent state of adc inputs used for dip switches
|
||||
static unsigned char adc_state = 0;
|
||||
AT91PS_ADC a_pADC = AT91C_BASE_ADC;
|
||||
@@ -213,6 +216,15 @@ static void user_io_read_core_name() {
|
||||
iprintf("Core name is \"%s\"\n", core_name);
|
||||
}
|
||||
|
||||
void user_io_set_core_mod(char mod) {
|
||||
core_mod = mod;
|
||||
}
|
||||
|
||||
void user_io_send_core_mod() {
|
||||
iprintf("Sending core mod = %d\n", core_mod);
|
||||
spi_uio_cmd8(UIO_SET_MOD, core_mod);
|
||||
}
|
||||
|
||||
void user_io_detect_core_type() {
|
||||
core_name[0] = 0;
|
||||
|
||||
@@ -270,6 +282,9 @@ void user_io_detect_core_type() {
|
||||
case CORE_TYPE_8BIT: {
|
||||
puts("Identified 8BIT core");
|
||||
|
||||
// send core variant first to allow the FPGA choosing the config string
|
||||
user_io_send_core_mod();
|
||||
|
||||
// forward SD card config to core in case it uses the local
|
||||
// SD card implementation
|
||||
user_io_sd_set_config();
|
||||
@@ -316,6 +331,7 @@ void user_io_detect_core_type() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned short usb2amiga( unsigned char k ) {
|
||||
// replace MENU key by RGUI to allow using Right Amiga on reduced keyboards
|
||||
// (it also disables the use of Menu for OSD)
|
||||
@@ -616,7 +632,9 @@ void user_io_file_mount(fileTYPE *file, unsigned char index) {
|
||||
// 8 bit cores have a config string telling the firmware how
|
||||
// to treat it
|
||||
char *user_io_8bit_get_string(char index) {
|
||||
unsigned char i, lidx = 0, j = 0;
|
||||
unsigned char i, lidx = 0, j = 0, d = 0, arc = 0;
|
||||
int arc_ptr = 0;
|
||||
char dip[3];
|
||||
static char buffer[128+1]; // max 128 bytes per config item
|
||||
|
||||
// clear buffer
|
||||
@@ -635,17 +653,35 @@ char *user_io_8bit_get_string(char index) {
|
||||
|
||||
while ((i != 0) && (i!=0xff) && (j<sizeof(buffer))) {
|
||||
if(i == ';') {
|
||||
if(lidx == index) buffer[j++] = 0;
|
||||
lidx++;
|
||||
if(!arc && d==3 && !strncmp(dip, "DIP", 3)) {
|
||||
// found "DIP", continue with config snippet from ARC
|
||||
if(lidx == index) {
|
||||
// skip the DIP line
|
||||
j = 0;
|
||||
buffer[0] = 0;
|
||||
}
|
||||
arc = 1;
|
||||
} else {
|
||||
if(lidx == index) buffer[j++] = 0;
|
||||
lidx++;
|
||||
}
|
||||
d = 0;
|
||||
} else {
|
||||
if(lidx == index)
|
||||
buffer[j++] = i;
|
||||
buffer[j++] = i;
|
||||
if (d<3)
|
||||
dip[d++] = i;
|
||||
}
|
||||
|
||||
// iprintf("%c", i);
|
||||
i = spi_in();
|
||||
//iprintf("%c", i);
|
||||
if (arc) {
|
||||
i = arc_get_conf()[arc_ptr++];
|
||||
if (!i) arc = 0;
|
||||
}
|
||||
if (!arc)
|
||||
i = spi_in();
|
||||
}
|
||||
|
||||
|
||||
DisableIO();
|
||||
// iprintf("\n");
|
||||
|
||||
@@ -659,7 +695,7 @@ char *user_io_8bit_get_string(char index) {
|
||||
return NULL;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long user_io_8bit_set_status(unsigned long new_status, unsigned long mask) {
|
||||
static unsigned long status = 0;
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#define UIO_SET_STATUS2 0x1e // 32bit status
|
||||
#define UIO_GET_KBD_LED 0x1f // keyboard LEDs control
|
||||
#define UIO_SIO_OUT 0x20 // serial out
|
||||
#define UIO_SET_MOD 0x21 // send core variant from metadata (ARC) file
|
||||
|
||||
// extended joystick control (32 bit value)
|
||||
#define UIO_JOYSTICK0_EXT 0x60
|
||||
@@ -170,6 +171,7 @@ char user_io_dip_switch1(void);
|
||||
char user_io_serial_status(serial_status_t *, uint8_t);
|
||||
void user_io_file_mount(fileTYPE *, unsigned char);
|
||||
char *user_io_get_core_name();
|
||||
void user_io_set_core_mod(char);
|
||||
|
||||
// io controllers interface for FPGA ethernet emulation using usb ethernet
|
||||
// devices attached to the io controller (ethernec emulation)
|
||||
|
||||
Reference in New Issue
Block a user