mirror of
https://github.com/mist-devel/mist-firmware.git
synced 2026-04-27 20:58:59 +00:00
Custom processors for Chroma81 COL and CHR files
This commit is contained in:
4
main.c
4
main.c
@@ -52,6 +52,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "user_io.h"
|
||||
#include "data_io.h"
|
||||
#include "c64files.h"
|
||||
#include "snes.h"
|
||||
#include "zx_col.h"
|
||||
#include "arc_file.h"
|
||||
#include "font.h"
|
||||
#include "tos.h"
|
||||
@@ -144,6 +146,8 @@ int main(void)
|
||||
|
||||
data_io_init();
|
||||
c64files_init();
|
||||
snes_init();
|
||||
zx_init();
|
||||
Timer_Init();
|
||||
|
||||
USART_Init(115200);
|
||||
|
||||
41
menu-8bit.c
41
menu-8bit.c
@@ -29,8 +29,6 @@
|
||||
#include "hdd.h"
|
||||
#include "fat_compat.h"
|
||||
#include "cue_parser.h"
|
||||
#include "snes.h"
|
||||
#include "zx_col.h"
|
||||
|
||||
extern char s[FF_LFN_BUF + 1];
|
||||
|
||||
@@ -43,7 +41,7 @@ extern hardfileTYPE hardfiles[4];
|
||||
//////////////////////////
|
||||
/////// 8-bit menu ///////
|
||||
//////////////////////////
|
||||
typedef enum _RomType {ROM_NORMAL, ROM_SNES, ROM_ZXCOL, ROM_ZXCHR, ROM_PROCESSED} RomType;
|
||||
typedef enum _RomType {ROM_NORMAL, ROM_PROCESSED} RomType;
|
||||
|
||||
static unsigned char selected_drive_slot;
|
||||
static RomType romtype;
|
||||
@@ -129,30 +127,12 @@ static char RomFileSelected(uint8_t idx, const char *SelectedName) {
|
||||
iprintf("RomFileSelected romType=%d\n", romtype);
|
||||
// this assumes that further file entries only exist if the first one also exists
|
||||
if (f_open(&file, SelectedName, FA_READ) == FR_OK) {
|
||||
if (romtype == ROM_ZXCOL || romtype == ROM_ZXCHR) {
|
||||
if (romtype == ROM_ZXCOL && !zx_col_load(&file, sector_buffer)) {
|
||||
ErrorMessage("\n Error parsing COL file!\n", 0);
|
||||
f_close(&file);
|
||||
return 0;
|
||||
} else if (romtype == ROM_ZXCHR && !zx_chr_load(&file, sector_buffer)) {
|
||||
ErrorMessage("\n Error parsing CHR file!\n", 0);
|
||||
f_close(&file);
|
||||
return 0;
|
||||
} else {
|
||||
data_io_file_tx_prepare(&file, ext_idx << 6 | selected_drive_slot, GetExtension(SelectedName));
|
||||
EnableFpga();
|
||||
SPI(DIO_FILE_TX_DAT);
|
||||
spi_write(sector_buffer, 1024+(romtype == ROM_ZXCOL ? 1 : 0));
|
||||
DisableFpga();
|
||||
data_io_file_tx_done();
|
||||
}
|
||||
} else if (romtype == ROM_PROCESSED) {
|
||||
if (romtype == ROM_PROCESSED) {
|
||||
data_io_file_tx_processor(&file, ext_idx << 6 | selected_drive_slot, GetExtension(SelectedName), SelectedName, data_processor_id);
|
||||
} else {
|
||||
if (romtype == ROM_SNES) ext_idx = snes_getromtype(&file);
|
||||
data_io_file_tx(&file, ext_idx << 6 | selected_drive_slot, GetExtension(SelectedName));
|
||||
f_close(&file);
|
||||
}
|
||||
if (romtype != ROM_PROCESSED) f_close(&file);
|
||||
}
|
||||
// close menu afterwards (but allow custom processor to have its own menu)
|
||||
if (romtype != ROM_PROCESSED) CloseMenu();
|
||||
@@ -301,9 +281,18 @@ static char GetMenuItem_8bit(uint8_t idx, char action, menu_item_t *item) {
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
if (p[1] && p[1] != ',' && p[2] && p[2] != ',' && !strncmp(&p[2], "SNES", 4)) romtype = ROM_SNES; // F1SNES
|
||||
if (p[1] && p[1] != ',' && p[2] && p[2] != ',' && !strncmp(&p[2], "ZXCOL", 5)) romtype = ROM_ZXCOL; // F2ZXCOL
|
||||
if (p[1] && p[1] != ',' && p[2] && p[2] != ',' && !strncmp(&p[2], "ZXCHR", 5)) romtype = ROM_ZXCHR; // F3ZXCHR
|
||||
if (p[1] && p[1] != ',' && p[2] && p[2] != ',' && !strncmp(&p[2], "SNES", 4)) {
|
||||
romtype = ROM_PROCESSED; // handle legacy F1SNES notation as a custom data processor
|
||||
strcpy(data_processor_id, "SFC");
|
||||
}
|
||||
if (p[1] && p[1] != ',' && p[2] && p[2] != ',' && !strncmp(&p[2], "ZXCOL", 5)) {
|
||||
romtype = ROM_PROCESSED; // F2ZXCOL
|
||||
strcpy(data_processor_id, "COL");
|
||||
}
|
||||
if (p[1] && p[1] != ',' && p[2] && p[2] != ',' && !strncmp(&p[2], "ZXCHR", 5)) {
|
||||
romtype = ROM_PROCESSED; // F3ZXCHR
|
||||
strcpy(data_processor_id, "CHR");
|
||||
}
|
||||
substrcpy(ext, p, 1);
|
||||
while(strlen(ext) < 3) strcat(ext, " ");
|
||||
SelectFileNG(ext, SCAN_DIR | SCAN_LFN, (p[0] == 'F')?RomFileSelected:iscue?CueFileSelected:ImageFileSelected, 1);
|
||||
|
||||
22
snes.c
22
snes.c
@@ -19,6 +19,8 @@
|
||||
#include <stdio.h>
|
||||
#include "snes.h"
|
||||
#include "fat_compat.h"
|
||||
#include "data_io.h"
|
||||
#include "menu.h"
|
||||
#include "debug.h"
|
||||
|
||||
enum HeaderField {
|
||||
@@ -136,7 +138,7 @@ static uint32_t score_header(FIL *file, uint32_t offset, uint32_t addr)
|
||||
return score;
|
||||
}
|
||||
|
||||
char snes_getromtype(FIL *file)
|
||||
static char snes_getromtype(FIL *file)
|
||||
{
|
||||
uint32_t score_lo, score_hi, score_ex;
|
||||
UINT br;
|
||||
@@ -164,3 +166,21 @@ char snes_getromtype(FIL *file)
|
||||
iprintf("No clue about ROM type\n");
|
||||
return 0; // no idea, fall back to LoROM
|
||||
}
|
||||
|
||||
static void snes_handlerom(FIL *file, int index, const char *name, const char *ext)
|
||||
{
|
||||
iprintf("SNES: open %s\n", name);
|
||||
|
||||
char ext_idx = snes_getromtype(file);
|
||||
data_io_file_tx(file, ext_idx << 6 | (index & 0x3f), ext);
|
||||
f_close(file);
|
||||
CloseMenu();
|
||||
}
|
||||
|
||||
static data_io_processor_t snes_romfile = {"SFC", &snes_handlerom};
|
||||
|
||||
|
||||
void snes_init()
|
||||
{
|
||||
data_io_add_processor(&snes_romfile);
|
||||
}
|
||||
|
||||
4
snes.h
4
snes.h
@@ -18,8 +18,6 @@
|
||||
#ifndef SNES_H
|
||||
#define SNES_H
|
||||
|
||||
#include "FatFs/ff.h"
|
||||
|
||||
char snes_getromtype(FIL *file);
|
||||
void snes_init();
|
||||
|
||||
#endif // SNES_H
|
||||
|
||||
50
zx_col.c
50
zx_col.c
@@ -19,6 +19,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "sxmlc/sxmlc.h"
|
||||
#include "fat_compat.h"
|
||||
#include "data_io.h"
|
||||
#include "menu.h"
|
||||
|
||||
static unsigned char *zx_col_table;
|
||||
//static char *col_state_s[] = {"None", "Border", "Entry", "Line", "Paper", "Ink"};
|
||||
@@ -268,7 +271,7 @@ int main() {
|
||||
fclose(f);
|
||||
}
|
||||
#else
|
||||
int zx_col_load(FIL *fil, unsigned char *buf)
|
||||
static int zx_col_load(FIL *fil, unsigned char *buf)
|
||||
{
|
||||
zx_col_table = buf;
|
||||
memset(zx_col_table, 0xf0, 128*8+1);
|
||||
@@ -314,7 +317,7 @@ static const unsigned char zx81_charset[512] = {
|
||||
0x00, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x00, 0x00, 0x7E, 0x04, 0x08, 0x10, 0x20, 0x7E, 0x00
|
||||
};
|
||||
|
||||
int zx_chr_load(FIL *fil, unsigned char *buf)
|
||||
static int zx_chr_load(FIL *fil, unsigned char *buf)
|
||||
{
|
||||
#ifdef HAVE_XML
|
||||
zx_col_table = buf;
|
||||
@@ -328,3 +331,46 @@ int zx_chr_load(FIL *fil, unsigned char *buf)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void zx_sendfile(FIL *file, int index, const char *ext, int len)
|
||||
{
|
||||
data_io_file_tx_prepare(file, index, ext);
|
||||
EnableFpga();
|
||||
SPI(DIO_FILE_TX_DAT);
|
||||
spi_write(sector_buffer, len);
|
||||
DisableFpga();
|
||||
data_io_file_tx_done();
|
||||
}
|
||||
|
||||
static void zx_handlecol(FIL *file, int index, const char *name, const char *ext)
|
||||
{
|
||||
if (!zx_col_load(file, sector_buffer)) {
|
||||
ErrorMessage("\n Error parsing CHR file!\n", 0);
|
||||
f_close(file);
|
||||
} else {
|
||||
zx_sendfile(file, index, ext, 1025);
|
||||
f_close(file);
|
||||
CloseMenu();
|
||||
}
|
||||
}
|
||||
|
||||
static void zx_handlechr(FIL *file, int index, const char *name, const char *ext)
|
||||
{
|
||||
if (!zx_chr_load(file, sector_buffer)) {
|
||||
ErrorMessage("\n Error parsing CHR file!\n", 0);
|
||||
f_close(file);
|
||||
} else {
|
||||
zx_sendfile(file, index, ext, 1024);
|
||||
f_close(file);
|
||||
CloseMenu();
|
||||
}
|
||||
}
|
||||
|
||||
static data_io_processor_t zx_colfile = {"COL", &zx_handlecol};
|
||||
static data_io_processor_t zx_chrfile = {"CHR", &zx_handlechr};
|
||||
|
||||
void zx_init()
|
||||
{
|
||||
data_io_add_processor(&zx_colfile);
|
||||
data_io_add_processor(&zx_chrfile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user