kopia lustrzana https://github.com/Jean-MarcHarvengt/MCUME
add AUTORUN feature and write capabilities to AtariST floppy
rodzic
25e0f243fc
commit
d3d956371d
|
@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
|
||||||
MouseController mouse1(myusb);
|
MouseController mouse1(myusb);
|
||||||
MIDIDevice midi1(myusb);
|
MIDIDevice midi1(myusb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void);
|
||||||
|
static bool emu_readConfig(void);
|
||||||
|
static bool emu_eraseConfig(void);
|
||||||
|
|
||||||
static bool mouseDetected = false;
|
static bool mouseDetected = false;
|
||||||
static bool keyboardDetected = false;
|
static bool keyboardDetected = false;
|
||||||
static uint8_t usbnavpad=0;
|
static uint8_t usbnavpad=0;
|
||||||
|
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
|
||||||
static File file;
|
static File file;
|
||||||
|
|
||||||
#define MAX_FILES 64
|
#define MAX_FILES 64
|
||||||
|
#define AUTORUN_FILENAME "autorun.txt"
|
||||||
|
|
||||||
#define MAX_FILENAME_SIZE 24
|
#define MAX_FILENAME_SIZE 24
|
||||||
#define MAX_MENULINES 9
|
#define MAX_MENULINES 9
|
||||||
#define TEXT_HEIGHT 16
|
#define TEXT_HEIGHT 16
|
||||||
|
@ -57,6 +64,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||||
static char selected_filename[MAX_FILENAME_SIZE]="";
|
static char selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static bool menuRedraw=true;
|
static bool menuRedraw=true;
|
||||||
|
static bool autorun=false;
|
||||||
|
|
||||||
static const unsigned short * keys;
|
static const unsigned short * keys;
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
|
@ -972,8 +980,11 @@ void backgroundMenu(void) {
|
||||||
|
|
||||||
int handleMenu(uint16_t bClick)
|
int handleMenu(uint16_t bClick)
|
||||||
{
|
{
|
||||||
|
if (autorun) {
|
||||||
|
return (ACTION_RUN1);
|
||||||
|
}
|
||||||
|
|
||||||
int action = ACTION_NONE;
|
int action = ACTION_NONE;
|
||||||
|
|
||||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
||||||
char newpath[MAX_FILENAME_PATH];
|
char newpath[MAX_FILENAME_PATH];
|
||||||
strcpy(newpath, selection);
|
strcpy(newpath, selection);
|
||||||
|
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
|
||||||
nbFiles = readNbFiles();
|
nbFiles = readNbFiles();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = ACTION_RUN1;
|
action = ACTION_RUN1;
|
||||||
|
#ifdef TEECOMPUTER
|
||||||
|
if (key_extmode) {
|
||||||
|
emu_writeConfig();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
menuRedraw=true;
|
menuRedraw=true;
|
||||||
}
|
}
|
||||||
|
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
|
||||||
int handler = getFreeFileHandler();
|
int handler = getFreeFileHandler();
|
||||||
if (handler >= 0) {
|
if (handler >= 0) {
|
||||||
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
||||||
emu_printi(handler+1);
|
// emu_printi(handler+1);
|
||||||
retval = handler+1;
|
retval = handler+1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
|
||||||
return(filesize);
|
return(filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_CREAT | O_WRITE)))
|
||||||
|
{
|
||||||
|
if (lofile.write(selection, strlen(selection)) != strlen(selection)) {
|
||||||
|
emu_printf("Config write failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_readConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_READ)))
|
||||||
|
{
|
||||||
|
unsigned int filesize = lofile.size();
|
||||||
|
unsigned int sizeread = lofile.read(selection, filesize);
|
||||||
|
if (sizeread != filesize) {
|
||||||
|
emu_printf("Config read failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (sizeread == filesize)
|
||||||
|
{
|
||||||
|
selection[filesize]=0;
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_eraseConfig(void)
|
||||||
|
{
|
||||||
|
SD.remove (ROMSDIR "/" AUTORUN_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* File IO compatibility
|
* File IO compatibility
|
||||||
********************************/
|
********************************/
|
||||||
|
@ -1646,8 +1706,20 @@ void emu_init(void)
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
#ifndef HAS_T4_VGA
|
#ifndef HAS_T4_VGA
|
||||||
tft.flipscreen(false);
|
tft.flipscreen(false);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
int keypressed = emu_ReadKeys();
|
||||||
|
if (keypressed & MASK_JOY2_DOWN) {
|
||||||
|
tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) );
|
||||||
|
tft.drawTextNoDma(64,48, (char*)" AUTURUN file erased", RGBVAL16(0xff,0xff,0x00), RGBVAL16(0xff,0x00,0x00), true);
|
||||||
|
emu_eraseConfig();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (emu_readConfig()) {
|
||||||
|
autorun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleMenu(true);
|
toggleMenu(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
|
||||||
MouseController mouse1(myusb);
|
MouseController mouse1(myusb);
|
||||||
MIDIDevice midi1(myusb);
|
MIDIDevice midi1(myusb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void);
|
||||||
|
static bool emu_readConfig(void);
|
||||||
|
static bool emu_eraseConfig(void);
|
||||||
|
|
||||||
static bool mouseDetected = false;
|
static bool mouseDetected = false;
|
||||||
static bool keyboardDetected = false;
|
static bool keyboardDetected = false;
|
||||||
static uint8_t usbnavpad=0;
|
static uint8_t usbnavpad=0;
|
||||||
|
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
|
||||||
static File file;
|
static File file;
|
||||||
|
|
||||||
#define MAX_FILES 64
|
#define MAX_FILES 64
|
||||||
|
#define AUTORUN_FILENAME "autorun.txt"
|
||||||
|
|
||||||
#define MAX_FILENAME_SIZE 24
|
#define MAX_FILENAME_SIZE 24
|
||||||
#define MAX_MENULINES 9
|
#define MAX_MENULINES 9
|
||||||
#define TEXT_HEIGHT 16
|
#define TEXT_HEIGHT 16
|
||||||
|
@ -57,6 +64,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||||
static char selected_filename[MAX_FILENAME_SIZE]="";
|
static char selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static bool menuRedraw=true;
|
static bool menuRedraw=true;
|
||||||
|
static bool autorun=false;
|
||||||
|
|
||||||
static const unsigned short * keys;
|
static const unsigned short * keys;
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
|
@ -972,8 +980,11 @@ void backgroundMenu(void) {
|
||||||
|
|
||||||
int handleMenu(uint16_t bClick)
|
int handleMenu(uint16_t bClick)
|
||||||
{
|
{
|
||||||
|
if (autorun) {
|
||||||
|
return (ACTION_RUN1);
|
||||||
|
}
|
||||||
|
|
||||||
int action = ACTION_NONE;
|
int action = ACTION_NONE;
|
||||||
|
|
||||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
||||||
char newpath[MAX_FILENAME_PATH];
|
char newpath[MAX_FILENAME_PATH];
|
||||||
strcpy(newpath, selection);
|
strcpy(newpath, selection);
|
||||||
|
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
|
||||||
nbFiles = readNbFiles();
|
nbFiles = readNbFiles();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = ACTION_RUN1;
|
action = ACTION_RUN1;
|
||||||
|
#ifdef TEECOMPUTER
|
||||||
|
if (key_extmode) {
|
||||||
|
emu_writeConfig();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
menuRedraw=true;
|
menuRedraw=true;
|
||||||
}
|
}
|
||||||
|
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
|
||||||
int handler = getFreeFileHandler();
|
int handler = getFreeFileHandler();
|
||||||
if (handler >= 0) {
|
if (handler >= 0) {
|
||||||
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
||||||
emu_printi(handler+1);
|
// emu_printi(handler+1);
|
||||||
retval = handler+1;
|
retval = handler+1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
|
||||||
return(filesize);
|
return(filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_CREAT | O_WRITE)))
|
||||||
|
{
|
||||||
|
if (lofile.write(selection, strlen(selection)) != strlen(selection)) {
|
||||||
|
emu_printf("Config write failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_readConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_READ)))
|
||||||
|
{
|
||||||
|
unsigned int filesize = lofile.size();
|
||||||
|
unsigned int sizeread = lofile.read(selection, filesize);
|
||||||
|
if (sizeread != filesize) {
|
||||||
|
emu_printf("Config read failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (sizeread == filesize)
|
||||||
|
{
|
||||||
|
selection[filesize]=0;
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_eraseConfig(void)
|
||||||
|
{
|
||||||
|
SD.remove (ROMSDIR "/" AUTORUN_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* File IO compatibility
|
* File IO compatibility
|
||||||
********************************/
|
********************************/
|
||||||
|
@ -1646,8 +1706,20 @@ void emu_init(void)
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
#ifndef HAS_T4_VGA
|
#ifndef HAS_T4_VGA
|
||||||
tft.flipscreen(false);
|
tft.flipscreen(false);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
int keypressed = emu_ReadKeys();
|
||||||
|
if (keypressed & MASK_JOY2_DOWN) {
|
||||||
|
tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) );
|
||||||
|
tft.drawTextNoDma(64,48, (char*)" AUTURUN file erased", RGBVAL16(0xff,0xff,0x00), RGBVAL16(0xff,0x00,0x00), true);
|
||||||
|
emu_eraseConfig();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (emu_readConfig()) {
|
||||||
|
autorun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleMenu(true);
|
toggleMenu(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
|
||||||
MouseController mouse1(myusb);
|
MouseController mouse1(myusb);
|
||||||
MIDIDevice midi1(myusb);
|
MIDIDevice midi1(myusb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void);
|
||||||
|
static bool emu_readConfig(void);
|
||||||
|
static bool emu_eraseConfig(void);
|
||||||
|
|
||||||
static bool mouseDetected = false;
|
static bool mouseDetected = false;
|
||||||
static bool keyboardDetected = false;
|
static bool keyboardDetected = false;
|
||||||
static uint8_t usbnavpad=0;
|
static uint8_t usbnavpad=0;
|
||||||
|
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
|
||||||
static File file;
|
static File file;
|
||||||
|
|
||||||
#define MAX_FILES 64
|
#define MAX_FILES 64
|
||||||
|
#define AUTORUN_FILENAME "autorun.txt"
|
||||||
|
|
||||||
#define MAX_FILENAME_SIZE 24
|
#define MAX_FILENAME_SIZE 24
|
||||||
#define MAX_MENULINES 9
|
#define MAX_MENULINES 9
|
||||||
#define TEXT_HEIGHT 16
|
#define TEXT_HEIGHT 16
|
||||||
|
@ -57,6 +64,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||||
static char selected_filename[MAX_FILENAME_SIZE]="";
|
static char selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static bool menuRedraw=true;
|
static bool menuRedraw=true;
|
||||||
|
static bool autorun=false;
|
||||||
|
|
||||||
static const unsigned short * keys;
|
static const unsigned short * keys;
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
|
@ -972,8 +980,11 @@ void backgroundMenu(void) {
|
||||||
|
|
||||||
int handleMenu(uint16_t bClick)
|
int handleMenu(uint16_t bClick)
|
||||||
{
|
{
|
||||||
|
if (autorun) {
|
||||||
|
return (ACTION_RUN1);
|
||||||
|
}
|
||||||
|
|
||||||
int action = ACTION_NONE;
|
int action = ACTION_NONE;
|
||||||
|
|
||||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
||||||
char newpath[MAX_FILENAME_PATH];
|
char newpath[MAX_FILENAME_PATH];
|
||||||
strcpy(newpath, selection);
|
strcpy(newpath, selection);
|
||||||
|
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
|
||||||
nbFiles = readNbFiles();
|
nbFiles = readNbFiles();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = ACTION_RUN1;
|
action = ACTION_RUN1;
|
||||||
|
#ifdef TEECOMPUTER
|
||||||
|
if (key_extmode) {
|
||||||
|
emu_writeConfig();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
menuRedraw=true;
|
menuRedraw=true;
|
||||||
}
|
}
|
||||||
|
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
|
||||||
int handler = getFreeFileHandler();
|
int handler = getFreeFileHandler();
|
||||||
if (handler >= 0) {
|
if (handler >= 0) {
|
||||||
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
||||||
emu_printi(handler+1);
|
// emu_printi(handler+1);
|
||||||
retval = handler+1;
|
retval = handler+1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
|
||||||
return(filesize);
|
return(filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_CREAT | O_WRITE)))
|
||||||
|
{
|
||||||
|
if (lofile.write(selection, strlen(selection)) != strlen(selection)) {
|
||||||
|
emu_printf("Config write failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_readConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_READ)))
|
||||||
|
{
|
||||||
|
unsigned int filesize = lofile.size();
|
||||||
|
unsigned int sizeread = lofile.read(selection, filesize);
|
||||||
|
if (sizeread != filesize) {
|
||||||
|
emu_printf("Config read failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (sizeread == filesize)
|
||||||
|
{
|
||||||
|
selection[filesize]=0;
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_eraseConfig(void)
|
||||||
|
{
|
||||||
|
SD.remove (ROMSDIR "/" AUTORUN_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* File IO compatibility
|
* File IO compatibility
|
||||||
********************************/
|
********************************/
|
||||||
|
@ -1646,8 +1706,20 @@ void emu_init(void)
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
#ifndef HAS_T4_VGA
|
#ifndef HAS_T4_VGA
|
||||||
tft.flipscreen(false);
|
tft.flipscreen(false);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
int keypressed = emu_ReadKeys();
|
||||||
|
if (keypressed & MASK_JOY2_DOWN) {
|
||||||
|
tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) );
|
||||||
|
tft.drawTextNoDma(64,48, (char*)" AUTURUN file erased", RGBVAL16(0xff,0xff,0x00), RGBVAL16(0xff,0x00,0x00), true);
|
||||||
|
emu_eraseConfig();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (emu_readConfig()) {
|
||||||
|
autorun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleMenu(true);
|
toggleMenu(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
|
||||||
MouseController mouse1(myusb);
|
MouseController mouse1(myusb);
|
||||||
MIDIDevice midi1(myusb);
|
MIDIDevice midi1(myusb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void);
|
||||||
|
static bool emu_readConfig(void);
|
||||||
|
static bool emu_eraseConfig(void);
|
||||||
|
|
||||||
static bool mouseDetected = false;
|
static bool mouseDetected = false;
|
||||||
static bool keyboardDetected = false;
|
static bool keyboardDetected = false;
|
||||||
static uint8_t usbnavpad=0;
|
static uint8_t usbnavpad=0;
|
||||||
|
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
|
||||||
static File file;
|
static File file;
|
||||||
|
|
||||||
#define MAX_FILES 64
|
#define MAX_FILES 64
|
||||||
|
#define AUTORUN_FILENAME "autorun.txt"
|
||||||
|
|
||||||
#define MAX_FILENAME_SIZE 24
|
#define MAX_FILENAME_SIZE 24
|
||||||
#define MAX_MENULINES 9
|
#define MAX_MENULINES 9
|
||||||
#define TEXT_HEIGHT 16
|
#define TEXT_HEIGHT 16
|
||||||
|
@ -57,6 +64,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||||
static char selected_filename[MAX_FILENAME_SIZE]="";
|
static char selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static bool menuRedraw=true;
|
static bool menuRedraw=true;
|
||||||
|
static bool autorun=false;
|
||||||
|
|
||||||
static const unsigned short * keys;
|
static const unsigned short * keys;
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
|
@ -972,8 +980,11 @@ void backgroundMenu(void) {
|
||||||
|
|
||||||
int handleMenu(uint16_t bClick)
|
int handleMenu(uint16_t bClick)
|
||||||
{
|
{
|
||||||
|
if (autorun) {
|
||||||
|
return (ACTION_RUN1);
|
||||||
|
}
|
||||||
|
|
||||||
int action = ACTION_NONE;
|
int action = ACTION_NONE;
|
||||||
|
|
||||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
||||||
char newpath[MAX_FILENAME_PATH];
|
char newpath[MAX_FILENAME_PATH];
|
||||||
strcpy(newpath, selection);
|
strcpy(newpath, selection);
|
||||||
|
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
|
||||||
nbFiles = readNbFiles();
|
nbFiles = readNbFiles();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = ACTION_RUN1;
|
action = ACTION_RUN1;
|
||||||
|
#ifdef TEECOMPUTER
|
||||||
|
if (key_extmode) {
|
||||||
|
emu_writeConfig();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
menuRedraw=true;
|
menuRedraw=true;
|
||||||
}
|
}
|
||||||
|
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
|
||||||
return(filesize);
|
return(filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_CREAT | O_WRITE)))
|
||||||
|
{
|
||||||
|
if (lofile.write(selection, strlen(selection)) != strlen(selection)) {
|
||||||
|
emu_printf("Config write failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_readConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_READ)))
|
||||||
|
{
|
||||||
|
unsigned int filesize = lofile.size();
|
||||||
|
unsigned int sizeread = lofile.read(selection, filesize);
|
||||||
|
if (sizeread != filesize) {
|
||||||
|
emu_printf("Config read failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (sizeread == filesize)
|
||||||
|
{
|
||||||
|
selection[filesize]=0;
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_eraseConfig(void)
|
||||||
|
{
|
||||||
|
SD.remove (ROMSDIR "/" AUTORUN_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* File IO compatibility
|
* File IO compatibility
|
||||||
********************************/
|
********************************/
|
||||||
|
@ -1646,8 +1706,20 @@ void emu_init(void)
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
#ifndef HAS_T4_VGA
|
#ifndef HAS_T4_VGA
|
||||||
tft.flipscreen(false);
|
tft.flipscreen(false);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
int keypressed = emu_ReadKeys();
|
||||||
|
if (keypressed & MASK_JOY2_DOWN) {
|
||||||
|
tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) );
|
||||||
|
tft.drawTextNoDma(64,48, (char*)" AUTURUN file erased", RGBVAL16(0xff,0xff,0x00), RGBVAL16(0xff,0x00,0x00), true);
|
||||||
|
emu_eraseConfig();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (emu_readConfig()) {
|
||||||
|
autorun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleMenu(true);
|
toggleMenu(true);
|
||||||
}
|
}
|
||||||
|
|
Plik binarny nie jest wyświetlany.
|
@ -1,9 +0,0 @@
|
||||||
#ifndef DISKAPI_H
|
|
||||||
#define DISKAPI_H
|
|
||||||
|
|
||||||
int disk_Size(char * filename);
|
|
||||||
int disk_Open(char * filename);
|
|
||||||
int disk_Read(char * buf, int size, int handler);
|
|
||||||
int disk_Seek(int seek, int handler);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
|
||||||
MouseController mouse1(myusb);
|
MouseController mouse1(myusb);
|
||||||
MIDIDevice midi1(myusb);
|
MIDIDevice midi1(myusb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void);
|
||||||
|
static bool emu_readConfig(void);
|
||||||
|
static bool emu_eraseConfig(void);
|
||||||
|
|
||||||
static bool mouseDetected = false;
|
static bool mouseDetected = false;
|
||||||
static bool keyboardDetected = false;
|
static bool keyboardDetected = false;
|
||||||
static uint8_t usbnavpad=0;
|
static uint8_t usbnavpad=0;
|
||||||
|
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
|
||||||
static File file;
|
static File file;
|
||||||
|
|
||||||
#define MAX_FILES 64
|
#define MAX_FILES 64
|
||||||
|
#define AUTORUN_FILENAME "autorun.txt"
|
||||||
|
|
||||||
#define MAX_FILENAME_SIZE 24
|
#define MAX_FILENAME_SIZE 24
|
||||||
#define MAX_MENULINES 9
|
#define MAX_MENULINES 9
|
||||||
#define TEXT_HEIGHT 16
|
#define TEXT_HEIGHT 16
|
||||||
|
@ -57,6 +64,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||||
static char selected_filename[MAX_FILENAME_SIZE]="";
|
static char selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static bool menuRedraw=true;
|
static bool menuRedraw=true;
|
||||||
|
static bool autorun=false;
|
||||||
|
|
||||||
static const unsigned short * keys;
|
static const unsigned short * keys;
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
|
@ -972,8 +980,11 @@ void backgroundMenu(void) {
|
||||||
|
|
||||||
int handleMenu(uint16_t bClick)
|
int handleMenu(uint16_t bClick)
|
||||||
{
|
{
|
||||||
|
if (autorun) {
|
||||||
|
return (ACTION_RUN1);
|
||||||
|
}
|
||||||
|
|
||||||
int action = ACTION_NONE;
|
int action = ACTION_NONE;
|
||||||
|
|
||||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
||||||
char newpath[MAX_FILENAME_PATH];
|
char newpath[MAX_FILENAME_PATH];
|
||||||
strcpy(newpath, selection);
|
strcpy(newpath, selection);
|
||||||
|
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
|
||||||
nbFiles = readNbFiles();
|
nbFiles = readNbFiles();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = ACTION_RUN1;
|
action = ACTION_RUN1;
|
||||||
|
#ifdef TEECOMPUTER
|
||||||
|
if (key_extmode) {
|
||||||
|
emu_writeConfig();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
menuRedraw=true;
|
menuRedraw=true;
|
||||||
}
|
}
|
||||||
|
@ -1002,8 +1018,8 @@ int handleMenu(uint16_t bClick)
|
||||||
}
|
}
|
||||||
else if ( bClick & MASK_KEY_USER2 ) {
|
else if ( bClick & MASK_KEY_USER2 ) {
|
||||||
menuRedraw=true;
|
menuRedraw=true;
|
||||||
action = ACTION_RUN3;
|
//action = ACTION_RUN3;
|
||||||
//emu_SwapJoysticks(0);
|
emu_SwapJoysticks(0);
|
||||||
}
|
}
|
||||||
else if ( (bClick & MASK_JOY2_UP) || (bClick & MASK_JOY1_UP) ) {
|
else if ( (bClick & MASK_JOY2_UP) || (bClick & MASK_JOY1_UP) ) {
|
||||||
if (curFile!=0) {
|
if (curFile!=0) {
|
||||||
|
@ -1281,7 +1297,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
|
||||||
// emu_printf(filepath);
|
// emu_printf(filepath);
|
||||||
#ifdef HCFH
|
#ifdef HCFH
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
if ((file = SD.open(filepath, O_READ))) {
|
if ((file = SD.open(filepath, O_READ | O_WRITE))) {
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1292,8 +1308,8 @@ int emu_FileOpen(const char * filepath, const char * mode)
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
int handler = getFreeFileHandler();
|
int handler = getFreeFileHandler();
|
||||||
if (handler >= 0) {
|
if (handler >= 0) {
|
||||||
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
if ((file_handlers[handler] = SD.open(filepath, O_READ | O_WRITE))) {
|
||||||
emu_printi(handler+1);
|
// emu_printi(handler+1);
|
||||||
retval = handler+1;
|
retval = handler+1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1316,6 +1332,17 @@ int emu_FileRead(void * buf, int size, int handler)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int emu_FileWrite(void * buf, int size, int handler)
|
||||||
|
{
|
||||||
|
// emu_printf("emu_FileWrite");
|
||||||
|
// emu_printi(handler);
|
||||||
|
#ifdef HCFH
|
||||||
|
return (file.write(buf, size));
|
||||||
|
#else
|
||||||
|
return (getFileHandler(handler).write(buf, size));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int emu_FileGetc(int handler) {
|
int emu_FileGetc(int handler) {
|
||||||
// emu_printf("FileGetc");
|
// emu_printf("FileGetc");
|
||||||
// emu_printi(handler);
|
// emu_printi(handler);
|
||||||
|
@ -1429,6 +1456,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
|
||||||
return(filesize);
|
return(filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_CREAT | O_WRITE)))
|
||||||
|
{
|
||||||
|
if (lofile.write(selection, strlen(selection)) != strlen(selection)) {
|
||||||
|
emu_printf("Config write failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_readConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_READ)))
|
||||||
|
{
|
||||||
|
unsigned int filesize = lofile.size();
|
||||||
|
unsigned int sizeread = lofile.read(selection, filesize);
|
||||||
|
if (sizeread != filesize) {
|
||||||
|
emu_printf("Config read failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (sizeread == filesize)
|
||||||
|
{
|
||||||
|
selection[filesize]=0;
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_eraseConfig(void)
|
||||||
|
{
|
||||||
|
SD.remove (ROMSDIR "/" AUTORUN_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* File IO compatibility
|
* File IO compatibility
|
||||||
********************************/
|
********************************/
|
||||||
|
@ -1646,8 +1717,20 @@ void emu_init(void)
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
#ifndef HAS_T4_VGA
|
#ifndef HAS_T4_VGA
|
||||||
tft.flipscreen(false);
|
tft.flipscreen(false);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
int keypressed = emu_ReadKeys();
|
||||||
|
if (keypressed & MASK_JOY2_DOWN) {
|
||||||
|
tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) );
|
||||||
|
tft.drawTextNoDma(64,48, (char*)" AUTURUN file erased", RGBVAL16(0xff,0xff,0x00), RGBVAL16(0xff,0x00,0x00), true);
|
||||||
|
emu_eraseConfig();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (emu_readConfig()) {
|
||||||
|
autorun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleMenu(true);
|
toggleMenu(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,7 @@ extern void emu_Free(void * pt);
|
||||||
|
|
||||||
extern int emu_FileOpen(const char * filepath, const char * mode);
|
extern int emu_FileOpen(const char * filepath, const char * mode);
|
||||||
extern int emu_FileRead(void * buf, int size, int handler);
|
extern int emu_FileRead(void * buf, int size, int handler);
|
||||||
|
extern int emu_FileWrite(void * buf, int size, int handler);
|
||||||
extern int emu_FileGetc(int handler);
|
extern int emu_FileGetc(int handler);
|
||||||
extern int emu_FileSeek(int handler, int seek, int origin);
|
extern int emu_FileSeek(int handler, int seek, int origin);
|
||||||
extern int emu_FileTell(int handler);
|
extern int emu_FileTell(int handler);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
* 23.05.2002 0.02.00 JH FAST1.0.1 code import: KR -> ANSI, restructuring
|
* 23.05.2002 0.02.00 JH FAST1.0.1 code import: KR -> ANSI, restructuring
|
||||||
* 09.06.2002 0.02.00 JH Renamed io.c to st.c again (io.h conflicts with system headers)
|
* 09.06.2002 0.02.00 JH Renamed io.c to st.c again (io.h conflicts with system headers)
|
||||||
*/
|
*/
|
||||||
static char sccsid[] = "$Id: fdc.c,v 1.2 2002/06/08 23:31:58 jhoenig Exp $";
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -22,7 +22,6 @@ static char sccsid[] = "$Id: fdc.c,v 1.2 2002/06/08 23:31:58 jhoenig Exp $";
|
||||||
#include "m68k_intrf.h"
|
#include "m68k_intrf.h"
|
||||||
|
|
||||||
#include "emuapi.h"
|
#include "emuapi.h"
|
||||||
#include "diskapi.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define DISKNULL \
|
#define DISKNULL \
|
||||||
|
@ -35,68 +34,43 @@ static char sccsid[] = "$Id: fdc.c,v 1.2 2002/06/08 23:31:58 jhoenig Exp $";
|
||||||
"\0\0\0\0\0\0\0\0\0\0" \
|
"\0\0\0\0\0\0\0\0\0\0" \
|
||||||
"\0\0\0\0\0\0\0\0\0"
|
"\0\0\0\0\0\0\0\0\0"
|
||||||
|
|
||||||
int fdc_commands_executed=0;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FDC Registers
|
* FDC Registers
|
||||||
*/
|
*/
|
||||||
unsigned char fdc_data, fdc_track, fdc_sector, fdc_status, fdc_command, fdc_motor;
|
unsigned char fdc_data, fdc_track, fdc_sector, fdc_status, fdc_command, fdc_motor;
|
||||||
unsigned char fdc_int = 0;
|
unsigned char fdc_int = 0;
|
||||||
char fdcdir=1;
|
|
||||||
unsigned char disk_ejected[2]={0,1};
|
static char fdcdir=1;
|
||||||
unsigned char disk_changed[2];
|
static int fdc_commands_executed=0;
|
||||||
struct Disk disk[2] = {
|
static unsigned char disk_ejected[2]={0,1};
|
||||||
|
static unsigned char disk_changed[2];
|
||||||
|
static int discpos[2];
|
||||||
|
|
||||||
|
struct Disk disk[2] = {
|
||||||
{ NULL, DISKNULL, 0, SIDES, TRACKS, SECTORS, SECSIZE },
|
{ NULL, DISKNULL, 0, SIDES, TRACKS, SECTORS, SECSIZE },
|
||||||
{ NULL, DISKNULL, 0, SIDES, TRACKS, SECTORS, SECSIZE },
|
{ NULL, DISKNULL, 0, SIDES, TRACKS, SECTORS, SECSIZE },
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16 ID; // Word ID marker, should be $0E0F
|
|
||||||
uint16 SectorsPerTrack; // Word Sectors per track
|
|
||||||
uint16 Sides; // Word Sides (0 or 1; add 1 to this to get correct number of sides)
|
|
||||||
uint16 StartingTrack; // Word Starting track (0-based)
|
|
||||||
uint16 EndingTrack; // Word Ending track (0-based)
|
|
||||||
} MSAHEADERSTRUCT;
|
|
||||||
#define STMemory_Swap68000Int(val) ((val<<8)|(val>>8))
|
|
||||||
|
|
||||||
|
|
||||||
unsigned char * disc[2];
|
|
||||||
|
|
||||||
int discpos[2];
|
|
||||||
|
|
||||||
//#define LOGGING 1
|
|
||||||
|
|
||||||
#ifdef LOGGING
|
|
||||||
//static FILE * log=NULL;
|
|
||||||
//#define LOG(format,val) if (!log) { \
|
|
||||||
// log = fopen("log2.txt","wb"); \
|
|
||||||
// } \
|
|
||||||
// fprintf(log, "%s %d\n", format, val);
|
|
||||||
#define LOG(format,val) Serial.print(format); \
|
|
||||||
Serial.println(val);
|
|
||||||
#else
|
|
||||||
#define LOG(format,va)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PROGMEM static void SetMemBBB (unsigned long address, unsigned char value) {
|
PROGMEM static void SetMemBBB (unsigned long address, unsigned char value) {
|
||||||
address &= MEMADDRMASK;
|
address &= MEMADDRMASK;
|
||||||
WriteB(address + membase, value);
|
WriteB(address + membase, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PROGMEM static unsigned char GetMemBBB (unsigned long address) {
|
||||||
|
address &= MEMADDRMASK;
|
||||||
|
return (ReadB(address + membase));
|
||||||
|
}
|
||||||
|
|
||||||
PROGMEM int discread(unsigned long address,int a,int len,int discn)
|
PROGMEM int discread(unsigned long address,int len,int discn)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
LOG("disc read: ",len);
|
|
||||||
uint8 buf[256];
|
|
||||||
int totlen = len;
|
int totlen = len;
|
||||||
|
unsigned char buf[256];
|
||||||
while (totlen>=256) {
|
while (totlen>=256) {
|
||||||
//fread(buf,1,256,disk[discn].file);
|
emu_FileRead(buf,256, disk[discn].file);
|
||||||
disk_Read(buf,256, disk[discn].file);
|
|
||||||
|
|
||||||
LOG("b read: ",buf[0]);
|
|
||||||
totlen -= 256;
|
totlen -= 256;
|
||||||
for (i=0; i<256; i++) {
|
for (i=0; i<256; i++) {
|
||||||
SetMemBBB(address, buf[i]);
|
SetMemBBB(address, buf[i]);
|
||||||
|
@ -104,118 +78,117 @@ PROGMEM int discread(unsigned long address,int a,int len,int discn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (totlen) {
|
if (totlen) {
|
||||||
//fread(buf,1,totlen,disk[discn].file);
|
emu_FileRead(buf,totlen, disk[discn].file);
|
||||||
disk_Read(buf,totlen, disk[discn].file);
|
|
||||||
LOG("b: ",buf[0]);
|
|
||||||
for (i=0; i<totlen; i++) {
|
for (i=0; i<totlen; i++) {
|
||||||
SetMemBBB(address, buf[i]);
|
SetMemBBB(address, buf[i]);
|
||||||
address++;
|
address++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
discpos[discn]=discpos[discn]+len;
|
||||||
discpos[discn]=discpos[discn]+i;
|
|
||||||
|
emu_FileClose(disk[discn].file);
|
||||||
|
disk[discn].file = emu_FileOpen(disk[discn].name,"a+rw");
|
||||||
|
emu_FileSeek(disk[discn].file,discpos[discn],SEEK_SET);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
PROGMEM int discwrite(unsigned char *buf,int a,int len,int discn)
|
PROGMEM int discwrite(unsigned long address, int len,int discn)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint8 val1,val2,*dbuf;
|
int totlen = len;
|
||||||
dbuf=buf;
|
unsigned char buf[256];
|
||||||
#ifdef BYTES_SWAP
|
|
||||||
for (i=0; i<len; i+=2) {
|
while (totlen>=256) {
|
||||||
val1 = disc[discn][discpos[discn]+i];
|
for (i=0; i<256; i++) {
|
||||||
val2 = disc[discn][discpos[discn]+i+1];
|
buf[i] = GetMemBBB(address);
|
||||||
disc[discn][discpos[discn]+i] = val2;
|
address++;
|
||||||
disc[discn][discpos[discn]+i+1] =val1;
|
}
|
||||||
}
|
emu_FileWrite(buf,256, disk[discn].file);
|
||||||
#endif
|
totlen -= 256;
|
||||||
discpos[discn]=discpos[discn]+i;
|
}
|
||||||
|
if (totlen) {
|
||||||
|
for (i=0; i<totlen; i++) {
|
||||||
|
buf[i] = GetMemBBB(address);
|
||||||
|
address++;
|
||||||
|
}
|
||||||
|
emu_FileWrite(buf,totlen, disk[discn].file);
|
||||||
|
}
|
||||||
|
discpos[discn]=discpos[discn]+len;
|
||||||
|
|
||||||
|
emu_FileClose(disk[discn].file);
|
||||||
|
disk[discn].file = emu_FileOpen(disk[discn].name,"a+rw");
|
||||||
|
emu_FileSeek(disk[discn].file,discpos[discn],SEEK_SET);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int discseek(int discn,int pos,int a)
|
int discseek(int discn,int pos)
|
||||||
{
|
{
|
||||||
if (pos>(1050*1024)){
|
if (pos>(1050*1024)){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
discpos[discn]=pos;
|
discpos[discn]=pos;
|
||||||
if (disk[discn].file) disk_Seek(pos, disk[discn].file); //fseek(disk[discn].file,pos,SEEK_SET);
|
if (disk[discn].file) emu_FileSeek(disk[discn].file,pos,SEEK_SET);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PROGMEM int FDCInit(int i)
|
PROGMEM int FDCInit(int i)
|
||||||
{
|
{
|
||||||
unsigned char *buf;
|
int len2,calcsides,calcsectors,calctracks,badbootsector;
|
||||||
emu_printf("FDCInit");
|
|
||||||
memset((void *)&disc[i][0],0,256);
|
|
||||||
int len,len2,calcsides,calcsectors,calctracks,badbootsector;
|
|
||||||
discpos[i]=0;
|
|
||||||
|
|
||||||
//if (NULL != (disk[i].file = fopen (disk[i].name, "rb"))) {
|
discpos[i]=0;
|
||||||
//buf=&disc[i][0];
|
|
||||||
//disk[i].file=fopen (disk[i].name, "rb");
|
int len = emu_FileSize(disk[i].name);
|
||||||
//fseek(disk[i].file,0,SEEK_END);
|
|
||||||
//len=ftell(disk[i].file);
|
disk[i].file = emu_FileOpen(disk[i].name,"a+rw");
|
||||||
//disk[i].disksize = len;
|
disk[i].disksize = len;
|
||||||
//fseek(disk[i].file,0,SEEK_SET);
|
|
||||||
len = disk_Size(disk[i].name);
|
unsigned char buf[256];
|
||||||
disk[i].file = disk_Open(disk[i].name);
|
if (disk[i].file) {
|
||||||
buf=&disc[i][0];
|
emu_FileRead(buf, 256, disk[i].file);
|
||||||
disk[i].disksize = len;
|
emu_FileSeek(disk[i].file,0,SEEK_SET);
|
||||||
|
}
|
||||||
if (disk[i].file) {
|
|
||||||
//fread(buf,1,256,disk[i].file);
|
disk[i].head = 0;
|
||||||
//fseek(disk[i].file,0,SEEK_SET);
|
disk[i].sides = (int) *(buf + 26);
|
||||||
disk_Read(buf, 256, disk[i].file);
|
disk[i].sectors = (int) *(buf + 24);
|
||||||
disk_Seek(0,disk[i].file);
|
disk[i].secsize = 512; //(int) ((*(buf + 12) << 8) | *(buf + 11));
|
||||||
}
|
|
||||||
|
if (disk[i].sectors * disk[i].sides) {
|
||||||
disk[i].head = 0;
|
disk[i].tracks = (int) ((*(buf + 20) << 8) | *(buf + 19)) / (disk[i].sectors * disk[i].sides);
|
||||||
disk[i].sides = (int) *(buf + 26);
|
}
|
||||||
disk[i].sectors = (int) *(buf + 24);
|
|
||||||
disk[i].secsize = 512; //(int) ((*(buf + 12) << 8) | *(buf + 11));
|
// Second Check more precise
|
||||||
if (disk[i].sectors * disk[i].sides)
|
if (len> (500*1024)) calcsides = 2;
|
||||||
disk[i].tracks = (int) ((*(buf + 20) << 8) | *(buf + 19)) /
|
else calcsides = 1;
|
||||||
(disk[i].sectors * disk[i].sides);
|
|
||||||
|
if (!(((len/calcsides)/512)%9)&&(((len/calcsides)/512)/9)<86) calcsectors=9;
|
||||||
// Second Check more precise
|
else if (!(((len/calcsides)/512)%10)&&(((len/calcsides)/512)/10)<86) calcsectors=10;
|
||||||
if (len> (500*1024)) calcsides = 2;
|
else if (!(((len/calcsides)/512)%11)&&(((len/calcsides)/512)/11)<86) calcsectors=11;
|
||||||
else calcsides = 1;
|
else if (!(((len/calcsides)/512)%12)) calcsectors=12;
|
||||||
if (!(((len/calcsides)/512)%9)&&(((len/calcsides)/512)/9)<86) calcsectors=9;
|
calctracks =((len/calcsides)/512)/calcsectors;
|
||||||
else if (!(((len/calcsides)/512)%10)&&(((len/calcsides)/512)/10)<86) calcsectors=10;
|
|
||||||
else if (!(((len/calcsides)/512)%11)&&(((len/calcsides)/512)/11)<86) calcsectors=11;
|
|
||||||
else if (!(((len/calcsides)/512)%12)) calcsectors=12;
|
|
||||||
calctracks =((len/calcsides)/512)/calcsectors;
|
|
||||||
|
|
||||||
if (disk[i].sides!=calcsides||disk[i].sectors!=calcsectors||disk[i].tracks!=calctracks){
|
|
||||||
if (disk[i].sides==calcsides&&disk[i].sectors==calcsectors){
|
|
||||||
disk[i].tracks=calctracks;
|
|
||||||
badbootsector=0;
|
|
||||||
}else{
|
|
||||||
disk[i].sides=calcsides;
|
|
||||||
disk[i].tracks=calctracks;
|
|
||||||
disk[i].sectors=calcsectors;
|
|
||||||
badbootsector=(i<<24)|(calcsides<<16)|(calctracks<<8)|(calcsectors);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
badbootsector=0;
|
|
||||||
}
|
|
||||||
disk_ejected[i]=0;
|
|
||||||
disk_changed[i]=1;
|
|
||||||
fdc_status |= 0x40;
|
|
||||||
disk[i].head = 0;
|
|
||||||
fdc_track = 0;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//dcastaway_disc_initsave(i);
|
if (disk[i].sides!=calcsides||disk[i].sectors!=calcsectors||disk[i].tracks!=calctracks){
|
||||||
|
if (disk[i].sides==calcsides&&disk[i].sectors==calcsectors){
|
||||||
|
disk[i].tracks=calctracks;
|
||||||
|
badbootsector=0;
|
||||||
|
}else{
|
||||||
|
disk[i].sides=calcsides;
|
||||||
|
disk[i].tracks=calctracks;
|
||||||
|
disk[i].sectors=calcsectors;
|
||||||
|
badbootsector=(i<<24)|(calcsides<<16)|(calctracks<<8)|(calcsectors);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
badbootsector=0;
|
||||||
|
}
|
||||||
|
disk_ejected[i]=0;
|
||||||
|
disk_changed[i]=1;
|
||||||
|
fdc_status |= 0x40;
|
||||||
|
disk[i].head = 0;
|
||||||
|
fdc_track = 0;
|
||||||
|
|
||||||
return badbootsector;
|
return badbootsector;
|
||||||
}
|
}
|
||||||
|
|
||||||
PROGMEM void FDCchange(int i){
|
PROGMEM void FDCchange(int i){
|
||||||
|
@ -239,255 +212,283 @@ PROGMEM void FDCeject(int num){
|
||||||
|
|
||||||
PROGMEM void FDCCommand(void)
|
PROGMEM void FDCCommand(void)
|
||||||
{
|
{
|
||||||
static char motor = 1;
|
static char motor = 1;
|
||||||
int sides, drives;
|
int sides, drives;
|
||||||
long address; /* dma target/source address */
|
long address; /* dma target/source address */
|
||||||
long offset; /* offset in disk file */
|
long offset; /* offset in disk file */
|
||||||
unsigned long count; /* number of byte to transfer */
|
unsigned long count; /* number of byte to transfer */
|
||||||
char *buffer;
|
int n;
|
||||||
int n;
|
|
||||||
|
|
||||||
if (fdc_commands_executed<64)
|
if (fdc_commands_executed<64)
|
||||||
fdc_commands_executed++;
|
fdc_commands_executed++;
|
||||||
/* DMA target/source address */
|
/* DMA target/source address */
|
||||||
address = (dma_adrh << 16) + (dma_adrm << 8) + dma_adrl;
|
address = (dma_adrh << 16) + (dma_adrm << 8) + dma_adrl;
|
||||||
/* if (address>MEMSIZE){
|
/*
|
||||||
#ifdef DISASS
|
if (address>MEMSIZE) {
|
||||||
StartDisass();
|
fdc_status |= 0x10;
|
||||||
exit(1);
|
return;
|
||||||
#endif
|
}
|
||||||
fdc_status |= 0x10;
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
buffer = (char *)(membase + address);
|
|
||||||
/* status of side select and drive select lines */
|
/* status of side select and drive select lines */
|
||||||
sides = (~psg[14]) & 0x1;
|
sides = (~psg[14]) & 0x1;
|
||||||
drives = (~psg[14]) & 0x6;
|
drives = (~psg[14]) & 0x6;
|
||||||
if (disk_ejected[drives>>2]==1) drives=2;
|
if (disk_ejected[drives>>2]==1) drives=2;
|
||||||
switch (drives) {
|
|
||||||
|
switch (drives)
|
||||||
|
{
|
||||||
case 2: /* Drive A */
|
case 2: /* Drive A */
|
||||||
drives = 0;
|
drives = 0;
|
||||||
break;
|
break;
|
||||||
case 4: /* Drive B */
|
case 4: /* Drive B */
|
||||||
drives = 1;
|
drives = 1;
|
||||||
break;
|
break;
|
||||||
case 6: /* both, error */
|
case 6: /* both, error */
|
||||||
case 0: /* no drive selected */
|
case 0: /* no drive selected */
|
||||||
drives = -1;
|
drives = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fdc_status = 0; /* clear fdc status */
|
|
||||||
|
|
||||||
|
fdc_status = 0; /* clear fdc status */
|
||||||
if (fdc_command < 0x80) { /* TYPE-I fdc commands */
|
if (fdc_command < 0x80) { /* TYPE-I fdc commands */
|
||||||
if (drives >= 0) { /* drive selected */
|
if (drives >= 0) { /* drive selected */
|
||||||
switch (fdc_command & 0xf0) {
|
switch (fdc_command & 0xf0) {
|
||||||
case 0x00: /* RESTORE */
|
case 0x00: /* RESTORE */
|
||||||
disk[drives].head = 0;
|
disk[drives].head = 0;
|
||||||
fdc_track = 0;
|
fdc_track = 0;
|
||||||
break;
|
break;
|
||||||
case 0x10: /* SEEK */
|
case 0x10: /* SEEK */
|
||||||
disk[drives].head += (fdc_data - fdc_track);
|
disk[drives].head += (fdc_data - fdc_track);
|
||||||
fdc_track = fdc_data;
|
fdc_track = fdc_data;
|
||||||
if (disk[drives].head < 0
|
if (disk[drives].head < 0 || disk[drives].head >= disk[drives].tracks)
|
||||||
|| disk[drives].head >= disk[drives].tracks)
|
disk[drives].head = 0;
|
||||||
disk[drives].head = 0;
|
break;
|
||||||
break;
|
case 0x30: /* STEP */
|
||||||
case 0x30: /* STEP */
|
fdc_track += fdcdir;
|
||||||
fdc_track += fdcdir;
|
case 0x20:
|
||||||
case 0x20:
|
disk[drives].head += fdcdir;
|
||||||
disk[drives].head += fdcdir;
|
break;
|
||||||
break;
|
case 0x50: /* STEP-IN */
|
||||||
case 0x50: /* STEP-IN */
|
fdc_track++;
|
||||||
fdc_track++;
|
case 0x40:
|
||||||
case 0x40:
|
if (disk[drives].head < disk[drives].tracks)
|
||||||
if (disk[drives].head < disk[drives].tracks)
|
disk[drives].head++;
|
||||||
disk[drives].head++;
|
fdcdir = 1;
|
||||||
fdcdir = 1;
|
break;
|
||||||
break;
|
case 0x70: /* STEP-OUT */
|
||||||
case 0x70: /* STEP-OUT */
|
fdc_track--;
|
||||||
fdc_track--;
|
case 0x60:
|
||||||
case 0x60:
|
if (disk[drives].head > 0)
|
||||||
if (disk[drives].head > 0)
|
disk[drives].head--;
|
||||||
disk[drives].head--;
|
fdcdir = -1;
|
||||||
fdcdir = -1;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
if (disk[drives].head == 0) {
|
if (disk[drives].head == 0) {
|
||||||
fdc_status |= 0x4;
|
fdc_status |= 0x4;
|
||||||
}
|
}
|
||||||
if (disk[drives].head != fdc_track && fdc_command & 0x4) { /* Verify? */
|
if (disk[drives].head != fdc_track && fdc_command & 0x4) { /* Verify? */
|
||||||
fdc_status |= 0x10;
|
fdc_status |= 0x10;
|
||||||
}
|
}
|
||||||
if (motor) {
|
if (motor) {
|
||||||
fdc_status |= 0x20; /* spin-up flag */
|
fdc_status |= 0x20; /* spin-up flag */
|
||||||
}
|
}
|
||||||
} else { /* no drive selected */
|
}
|
||||||
fdc_status |= 0x10;
|
else { /* no drive selected */
|
||||||
}
|
fdc_status |= 0x10;
|
||||||
} else if ((fdc_command & 0xf0) == 0xd0) { /* FORCE INTERRUPT */
|
|
||||||
if (fdc_command == 0xd8) {
|
|
||||||
fdc_int = 1;
|
|
||||||
} else if (fdc_command == 0xd0) {
|
|
||||||
fdc_int = 0;
|
|
||||||
}
|
|
||||||
} else { /* OTHERS */
|
|
||||||
if (drives >= 0) { /* drive selected */
|
|
||||||
/* offset within floppy-file */
|
|
||||||
offset = disk[drives].secsize *
|
|
||||||
(((disk[drives].sectors * disk[drives].sides * disk[drives].head))
|
|
||||||
+ (disk[drives].sectors * sides) + (fdc_sector - 1));
|
|
||||||
switch (fdc_command & 0xf0) {
|
|
||||||
case 0x80: /* READ SECTOR */
|
|
||||||
count = 512;
|
|
||||||
if (!discseek (drives, offset, 0)) {
|
|
||||||
if (address<MEMSIZE){
|
|
||||||
if (count == discread (address, 1, count, drives)) {
|
|
||||||
address += count;
|
|
||||||
dma_adrl = address & 0xff;
|
|
||||||
dma_adrm = (address >> 8) & 0xff;
|
|
||||||
dma_adrh = (address >> 16) & 0xff;
|
|
||||||
dma_scr = 0;
|
|
||||||
dma_sr = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
address += count;
|
|
||||||
dma_adrl = address & 0xff;
|
|
||||||
dma_adrm = (address >> 8) & 0xff;
|
|
||||||
dma_adrh = (address >> 16) & 0xff;
|
|
||||||
dma_scr = 0;
|
|
||||||
dma_sr = 1;
|
|
||||||
mfp_gpip |= 0x20;
|
|
||||||
fdc_status |= 0x1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fdc_status |= 0x10;
|
|
||||||
dma_sr = 1;
|
|
||||||
break;
|
|
||||||
case 0x90: /* READ SECTOR multiple */
|
|
||||||
count = dma_scr * 512;
|
|
||||||
if (count+(fdc_sector-1)*512>disk[drives].sectors*512) count=disk[drives].sectors*512-(fdc_sector-1)*512;
|
|
||||||
if (!discseek (drives, offset, 0)) {
|
|
||||||
if (address<MEMSIZE){
|
|
||||||
if (count == discread (address, 1, count, drives)) {
|
|
||||||
address += count;
|
|
||||||
dma_adrl = address & 0xff;
|
|
||||||
dma_adrm = (address >> 8) & 0xff;
|
|
||||||
dma_adrh = (address >> 16) & 0xff;
|
|
||||||
dma_scr = 0;
|
|
||||||
dma_sr = 1;
|
|
||||||
fdc_sector += count/disk[drives].secsize;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
address += count;
|
|
||||||
dma_adrl = address & 0xff;
|
|
||||||
dma_adrm = (address >> 8) & 0xff;
|
|
||||||
dma_adrh = (address >> 16) & 0xff;
|
|
||||||
dma_scr = 0;
|
|
||||||
dma_sr = 1;
|
|
||||||
mfp_gpip |= 0x20;
|
|
||||||
fdc_status |= 0x1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fdc_status |= 0x10;
|
|
||||||
dma_sr = 1;
|
|
||||||
break;
|
|
||||||
case 0xa0: /* WRITE SECTOR */
|
|
||||||
count = dma_scr * 512;
|
|
||||||
if (!discseek (drives, offset, 0)) {
|
|
||||||
if (count == discwrite ((unsigned char *)buffer, 1, count, drives)) {
|
|
||||||
address += count;
|
|
||||||
dma_adrl = address & 0xff;
|
|
||||||
dma_adrm = (address >> 8) & 0xff;
|
|
||||||
dma_adrh = (address >> 16) & 0xff;
|
|
||||||
dma_scr = 0;
|
|
||||||
dma_sr = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fdc_status |= 0x10;
|
|
||||||
dma_sr = 1;
|
|
||||||
break;
|
|
||||||
case 0xb0: /* WRITE SECTOR multiple */
|
|
||||||
count = dma_scr * 512;
|
|
||||||
if (!discseek (drives, offset, 0)) {
|
|
||||||
if (count == discwrite ((unsigned char *)buffer, 1, count, drives)) {
|
|
||||||
address += count;
|
|
||||||
dma_adrl = address & 0xff;
|
|
||||||
dma_adrm = (address >> 8) & 0xff;
|
|
||||||
dma_adrh = (address >> 16) & 0xff;
|
|
||||||
dma_scr = 0;
|
|
||||||
dma_sr = 1;
|
|
||||||
fdc_sector += dma_scr * (512 / disk[drives].secsize);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fdc_status |= 0x10;
|
|
||||||
dma_sr = 1;
|
|
||||||
break;
|
|
||||||
case 0xc0: /* READ ADDRESS */
|
|
||||||
fdc_status |= 0x10;
|
|
||||||
break;
|
|
||||||
case 0xe0: /* READ TRACK */
|
|
||||||
count = disk[drives].sectors * 512;
|
|
||||||
offset = disk[drives].secsize *
|
|
||||||
(((disk[drives].sectors * disk[drives].sides * disk[drives].head))
|
|
||||||
+ (disk[drives].sectors * sides));
|
|
||||||
if (!discseek (drives, offset, 0)) {
|
|
||||||
if (address<MEMSIZE){
|
|
||||||
if (dma_scr==0x1f){
|
|
||||||
count=0;
|
|
||||||
address += 302;
|
|
||||||
}
|
|
||||||
if (count == discread (address, 1, count, drives)) {
|
|
||||||
dma_adrl = address & 0xff;
|
|
||||||
dma_adrm = (address >> 8) & 0xff;
|
|
||||||
dma_adrh = (address >> 16) & 0xff;
|
|
||||||
dma_scr = 0;
|
|
||||||
dma_sr = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
address += 302;
|
|
||||||
dma_adrl = address & 0xff;
|
|
||||||
dma_adrm = (address >> 8) & 0xff;
|
|
||||||
dma_adrh = (address >> 16) & 0xff;
|
|
||||||
dma_scr = 0;
|
|
||||||
dma_sr = 1;
|
|
||||||
mfp_gpip |= 0x20;
|
|
||||||
fdc_status |= 0x1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fdc_status |= 0x10;
|
|
||||||
dma_sr = 1;
|
|
||||||
break;
|
|
||||||
case 0xf0: /* WRITE TRACK */
|
|
||||||
fdc_status |= 0x10;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (disk[drives].head != fdc_track) {
|
|
||||||
fdc_status |= 0x10;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fdc_status |= 0x10; /* no drive selected */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ((fdc_command & 0xf0) == 0xd0) { /* FORCE INTERRUPT */
|
||||||
|
if (fdc_command == 0xd8)
|
||||||
|
{
|
||||||
|
fdc_int = 1;
|
||||||
|
} else if (fdc_command == 0xd0)
|
||||||
|
{
|
||||||
|
fdc_int = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else { /* OTHERS */
|
||||||
|
if (drives >= 0) { /* drive selected */
|
||||||
|
/* offset within floppy-file */
|
||||||
|
offset = disk[drives].secsize * (((disk[drives].sectors * disk[drives].sides * disk[drives].head)) + (disk[drives].sectors * sides) + (fdc_sector - 1));
|
||||||
|
switch (fdc_command & 0xf0)
|
||||||
|
{
|
||||||
|
case 0x80: /* READ SECTOR */
|
||||||
|
count = 512;
|
||||||
|
if (!discseek (drives, offset))
|
||||||
|
{
|
||||||
|
if (address<MEMSIZE)
|
||||||
|
{
|
||||||
|
if (count == discread (address, count, drives))
|
||||||
|
{
|
||||||
|
address += count;
|
||||||
|
dma_adrl = address & 0xff;
|
||||||
|
dma_adrm = (address >> 8) & 0xff;
|
||||||
|
dma_adrh = (address >> 16) & 0xff;
|
||||||
|
dma_scr = 0;
|
||||||
|
dma_sr = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
address += count;
|
||||||
|
dma_adrl = address & 0xff;
|
||||||
|
dma_adrm = (address >> 8) & 0xff;
|
||||||
|
dma_adrh = (address >> 16) & 0xff;
|
||||||
|
dma_scr = 0;
|
||||||
|
dma_sr = 1;
|
||||||
|
mfp_gpip |= 0x20;
|
||||||
|
fdc_status |= 0x1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fdc_status |= 0x10;
|
||||||
|
dma_sr = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x90: /* READ SECTOR multiple */
|
||||||
|
count = dma_scr * 512;
|
||||||
|
if (count+(fdc_sector-1)*512>disk[drives].sectors*512) count=disk[drives].sectors*512-(fdc_sector-1)*512;
|
||||||
|
if (!discseek (drives, offset))
|
||||||
|
{
|
||||||
|
if (address<MEMSIZE)
|
||||||
|
{
|
||||||
|
if (count == discread (address, count, drives))
|
||||||
|
{
|
||||||
|
address += count;
|
||||||
|
dma_adrl = address & 0xff;
|
||||||
|
dma_adrm = (address >> 8) & 0xff;
|
||||||
|
dma_adrh = (address >> 16) & 0xff;
|
||||||
|
dma_scr = 0;
|
||||||
|
dma_sr = 1;
|
||||||
|
fdc_sector += count/disk[drives].secsize;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
address += count;
|
||||||
|
dma_adrl = address & 0xff;
|
||||||
|
dma_adrm = (address >> 8) & 0xff;
|
||||||
|
dma_adrh = (address >> 16) & 0xff;
|
||||||
|
dma_scr = 0;
|
||||||
|
dma_sr = 1;
|
||||||
|
mfp_gpip |= 0x20;
|
||||||
|
fdc_status |= 0x1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fdc_status |= 0x10;
|
||||||
|
dma_sr = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xa0: /* WRITE SECTOR */
|
||||||
|
count = dma_scr * 512;
|
||||||
|
if (!discseek (drives, offset)) {
|
||||||
|
if (count == discwrite (address, count, drives))
|
||||||
|
{
|
||||||
|
address += count;
|
||||||
|
dma_adrl = address & 0xff;
|
||||||
|
dma_adrm = (address >> 8) & 0xff;
|
||||||
|
dma_adrh = (address >> 16) & 0xff;
|
||||||
|
dma_scr = 0;
|
||||||
|
dma_sr = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fdc_status |= 0x10;
|
||||||
|
dma_sr = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xb0: /* WRITE SECTOR multiple */
|
||||||
|
count = dma_scr * 512;
|
||||||
|
if (!discseek (drives, offset))
|
||||||
|
{
|
||||||
|
if (count == discwrite (address, count, drives)) {
|
||||||
|
address += count;
|
||||||
|
dma_adrl = address & 0xff;
|
||||||
|
dma_adrm = (address >> 8) & 0xff;
|
||||||
|
dma_adrh = (address >> 16) & 0xff;
|
||||||
|
dma_scr = 0;
|
||||||
|
dma_sr = 1;
|
||||||
|
fdc_sector += dma_scr * (512 / disk[drives].secsize);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fdc_status |= 0x10;
|
||||||
|
dma_sr = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xc0: /* READ ADDRESS */
|
||||||
|
fdc_status |= 0x10;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xe0: /* READ TRACK */
|
||||||
|
count = disk[drives].sectors * 512;
|
||||||
|
offset = disk[drives].secsize * (((disk[drives].sectors * disk[drives].sides * disk[drives].head)) + (disk[drives].sectors * sides));
|
||||||
|
if (!discseek (drives, offset))
|
||||||
|
{
|
||||||
|
if (address<MEMSIZE)
|
||||||
|
{
|
||||||
|
if (dma_scr==0x1f)
|
||||||
|
{
|
||||||
|
count=0;
|
||||||
|
address += 302;
|
||||||
|
}
|
||||||
|
if (count == discread (address, count, drives))
|
||||||
|
{
|
||||||
|
dma_adrl = address & 0xff;
|
||||||
|
dma_adrm = (address >> 8) & 0xff;
|
||||||
|
dma_adrh = (address >> 16) & 0xff;
|
||||||
|
dma_scr = 0;
|
||||||
|
dma_sr = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
address += 302;
|
||||||
|
dma_adrl = address & 0xff;
|
||||||
|
dma_adrm = (address >> 8) & 0xff;
|
||||||
|
dma_adrh = (address >> 16) & 0xff;
|
||||||
|
dma_scr = 0;
|
||||||
|
dma_sr = 1;
|
||||||
|
mfp_gpip |= 0x20;
|
||||||
|
fdc_status |= 0x1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fdc_status |= 0x10;
|
||||||
|
dma_sr = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xf0: /* WRITE TRACK */
|
||||||
|
fdc_status |= 0x10;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disk[drives].head != fdc_track)
|
||||||
|
{
|
||||||
|
fdc_status |= 0x10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fdc_status |= 0x10; /* no drive selected */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (motor) {
|
if (motor)
|
||||||
fdc_status |= 0x80; /* motor on flag */
|
{
|
||||||
fdc_motor=1;
|
fdc_status |= 0x80; /* motor on flag */
|
||||||
}
|
fdc_motor=1;
|
||||||
if (!(fdc_status & 0x01)) { /* not busy */
|
}
|
||||||
mfp_iprb |= (0x80 & mfp_ierb); /* Request Interrupt */
|
if (!(fdc_status & 0x01))
|
||||||
mfp_gpip &= ~0x20;
|
{ /* not busy */
|
||||||
}
|
mfp_iprb |= (0x80 & mfp_ierb); /* Request Interrupt */
|
||||||
|
mfp_gpip &= ~0x20;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
|
|
||||||
//#define ILI9341 1
|
//#define ILI9341 1
|
||||||
#define ST7789 1
|
//#define ST7789 1
|
||||||
#define TFTSPI1 1
|
//#define TFTSPI1 1
|
||||||
//#define HAS_T4_VGA 1
|
#define HAS_T4_VGA 1
|
||||||
//#define HIRES 1
|
#define HIRES 1
|
||||||
#define HAS_SND 1
|
#define HAS_SND 1
|
||||||
#define HAS_USBKEY 1
|
#define HAS_USBKEY 1
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,6 @@ void Redraw16_hi ( int row, int vid_adr )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static uint8 disk0[256];
|
|
||||||
static uint8 disk1[256];
|
|
||||||
|
|
||||||
|
|
||||||
void ast_Init(void)
|
void ast_Init(void)
|
||||||
{
|
{
|
||||||
emu_printf("Allocating RAM");
|
emu_printf("Allocating RAM");
|
||||||
|
@ -188,10 +184,6 @@ void ast_Init(void)
|
||||||
|
|
||||||
rombase = (int8*)&tos[0]-ROMBASE;
|
rombase = (int8*)&tos[0]-ROMBASE;
|
||||||
(void) memcpy (membase, &tos[0], 8);
|
(void) memcpy (membase, &tos[0], 8);
|
||||||
|
|
||||||
extern unsigned char * disc[2];
|
|
||||||
disc [ 0 ] = (uint8*) &disk0[0];
|
|
||||||
disc [ 1 ] = (uint8*) &disk1[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mouse_x = XRES/2;
|
static int mouse_x = XRES/2;
|
||||||
|
@ -1005,32 +997,13 @@ void ast_Step(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// disk IO mapped to File
|
|
||||||
|
|
||||||
int disk_Size(char * filename) {
|
|
||||||
return emu_FileSize(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
int disk_Open(char * filename) {
|
|
||||||
return emu_FileOpen(filename,"a+r");
|
|
||||||
}
|
|
||||||
|
|
||||||
int disk_Read(char * buf, int size, int handler) {
|
|
||||||
return emu_FileRead(buf, size, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
int disk_Seek(int seek, int handler) {
|
|
||||||
return emu_FileSeek(handler, seek, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ast_Start(char * floppy1, char * floppy2, int mode)
|
void ast_Start(char * floppy1, char * floppy2, int mode)
|
||||||
{
|
{
|
||||||
if (mode) display_mode = MONO;
|
if (mode) display_mode = MONO;
|
||||||
|
|
||||||
emu_printf("init started");
|
emu_printf("init started");
|
||||||
strncpy (disk[0].name, floppy1, sizeof(disk[0].name));
|
strncpy (disk[0].name, floppy1, strlen(floppy1));
|
||||||
strncpy (disk[1].name, floppy2, sizeof(disk[1].name));
|
strncpy (disk[1].name, floppy2, strlen(floppy2));
|
||||||
|
|
||||||
initialize_memmap();
|
initialize_memmap();
|
||||||
FDCInit(0);
|
FDCInit(0);
|
||||||
|
|
|
@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
|
||||||
MouseController mouse1(myusb);
|
MouseController mouse1(myusb);
|
||||||
MIDIDevice midi1(myusb);
|
MIDIDevice midi1(myusb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void);
|
||||||
|
static bool emu_readConfig(void);
|
||||||
|
static bool emu_eraseConfig(void);
|
||||||
|
|
||||||
static bool mouseDetected = false;
|
static bool mouseDetected = false;
|
||||||
static bool keyboardDetected = false;
|
static bool keyboardDetected = false;
|
||||||
static uint8_t usbnavpad=0;
|
static uint8_t usbnavpad=0;
|
||||||
|
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
|
||||||
static File file;
|
static File file;
|
||||||
|
|
||||||
#define MAX_FILES 64
|
#define MAX_FILES 64
|
||||||
|
#define AUTORUN_FILENAME "autorun.txt"
|
||||||
|
|
||||||
#define MAX_FILENAME_SIZE 24
|
#define MAX_FILENAME_SIZE 24
|
||||||
#define MAX_MENULINES 9
|
#define MAX_MENULINES 9
|
||||||
#define TEXT_HEIGHT 16
|
#define TEXT_HEIGHT 16
|
||||||
|
@ -57,6 +64,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||||
static char selected_filename[MAX_FILENAME_SIZE]="";
|
static char selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static bool menuRedraw=true;
|
static bool menuRedraw=true;
|
||||||
|
static bool autorun=false;
|
||||||
|
|
||||||
static const unsigned short * keys;
|
static const unsigned short * keys;
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
|
@ -972,8 +980,11 @@ void backgroundMenu(void) {
|
||||||
|
|
||||||
int handleMenu(uint16_t bClick)
|
int handleMenu(uint16_t bClick)
|
||||||
{
|
{
|
||||||
|
if (autorun) {
|
||||||
|
return (ACTION_RUN1);
|
||||||
|
}
|
||||||
|
|
||||||
int action = ACTION_NONE;
|
int action = ACTION_NONE;
|
||||||
|
|
||||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
||||||
char newpath[MAX_FILENAME_PATH];
|
char newpath[MAX_FILENAME_PATH];
|
||||||
strcpy(newpath, selection);
|
strcpy(newpath, selection);
|
||||||
|
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
|
||||||
nbFiles = readNbFiles();
|
nbFiles = readNbFiles();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = ACTION_RUN1;
|
action = ACTION_RUN1;
|
||||||
|
#ifdef TEECOMPUTER
|
||||||
|
if (key_extmode) {
|
||||||
|
emu_writeConfig();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
menuRedraw=true;
|
menuRedraw=true;
|
||||||
}
|
}
|
||||||
|
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
|
||||||
int handler = getFreeFileHandler();
|
int handler = getFreeFileHandler();
|
||||||
if (handler >= 0) {
|
if (handler >= 0) {
|
||||||
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
||||||
emu_printi(handler+1);
|
// emu_printi(handler+1);
|
||||||
retval = handler+1;
|
retval = handler+1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
|
||||||
return(filesize);
|
return(filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_CREAT | O_WRITE)))
|
||||||
|
{
|
||||||
|
if (lofile.write(selection, strlen(selection)) != strlen(selection)) {
|
||||||
|
emu_printf("Config write failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_readConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_READ)))
|
||||||
|
{
|
||||||
|
unsigned int filesize = lofile.size();
|
||||||
|
unsigned int sizeread = lofile.read(selection, filesize);
|
||||||
|
if (sizeread != filesize) {
|
||||||
|
emu_printf("Config read failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (sizeread == filesize)
|
||||||
|
{
|
||||||
|
selection[filesize]=0;
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_eraseConfig(void)
|
||||||
|
{
|
||||||
|
SD.remove (ROMSDIR "/" AUTORUN_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* File IO compatibility
|
* File IO compatibility
|
||||||
********************************/
|
********************************/
|
||||||
|
@ -1646,8 +1706,20 @@ void emu_init(void)
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
#ifndef HAS_T4_VGA
|
#ifndef HAS_T4_VGA
|
||||||
tft.flipscreen(false);
|
tft.flipscreen(false);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
int keypressed = emu_ReadKeys();
|
||||||
|
if (keypressed & MASK_JOY2_DOWN) {
|
||||||
|
tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) );
|
||||||
|
tft.drawTextNoDma(64,48, (char*)" AUTURUN file erased", RGBVAL16(0xff,0xff,0x00), RGBVAL16(0xff,0x00,0x00), true);
|
||||||
|
emu_eraseConfig();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (emu_readConfig()) {
|
||||||
|
autorun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleMenu(true);
|
toggleMenu(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
//#define ILI9341 1
|
//#define ILI9341 1
|
||||||
#define ST7789 1
|
//#define ST7789 1
|
||||||
#define TFTSPI1 1
|
//#define TFTSPI1 1
|
||||||
//#define HAS_T4_VGA 1
|
#define HAS_T4_VGA 1
|
||||||
//#define HIRES 1
|
//#define HIRES 1
|
||||||
//#define HAS_SND 1
|
//#define HAS_SND 1
|
||||||
#define HAS_USBKEY 1
|
#define HAS_USBKEY 1
|
||||||
|
|
|
@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
|
||||||
MouseController mouse1(myusb);
|
MouseController mouse1(myusb);
|
||||||
MIDIDevice midi1(myusb);
|
MIDIDevice midi1(myusb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void);
|
||||||
|
static bool emu_readConfig(void);
|
||||||
|
static bool emu_eraseConfig(void);
|
||||||
|
|
||||||
static bool mouseDetected = false;
|
static bool mouseDetected = false;
|
||||||
static bool keyboardDetected = false;
|
static bool keyboardDetected = false;
|
||||||
static uint8_t usbnavpad=0;
|
static uint8_t usbnavpad=0;
|
||||||
|
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
|
||||||
static File file;
|
static File file;
|
||||||
|
|
||||||
#define MAX_FILES 64
|
#define MAX_FILES 64
|
||||||
|
#define AUTORUN_FILENAME "autorun.txt"
|
||||||
|
|
||||||
#define MAX_FILENAME_SIZE 24
|
#define MAX_FILENAME_SIZE 24
|
||||||
#define MAX_MENULINES 9
|
#define MAX_MENULINES 9
|
||||||
#define TEXT_HEIGHT 16
|
#define TEXT_HEIGHT 16
|
||||||
|
@ -57,6 +64,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||||
static char selected_filename[MAX_FILENAME_SIZE]="";
|
static char selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static bool menuRedraw=true;
|
static bool menuRedraw=true;
|
||||||
|
static bool autorun=false;
|
||||||
|
|
||||||
static const unsigned short * keys;
|
static const unsigned short * keys;
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
|
@ -972,8 +980,11 @@ void backgroundMenu(void) {
|
||||||
|
|
||||||
int handleMenu(uint16_t bClick)
|
int handleMenu(uint16_t bClick)
|
||||||
{
|
{
|
||||||
|
if (autorun) {
|
||||||
|
return (ACTION_RUN1);
|
||||||
|
}
|
||||||
|
|
||||||
int action = ACTION_NONE;
|
int action = ACTION_NONE;
|
||||||
|
|
||||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
||||||
char newpath[MAX_FILENAME_PATH];
|
char newpath[MAX_FILENAME_PATH];
|
||||||
strcpy(newpath, selection);
|
strcpy(newpath, selection);
|
||||||
|
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
|
||||||
nbFiles = readNbFiles();
|
nbFiles = readNbFiles();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = ACTION_RUN1;
|
action = ACTION_RUN1;
|
||||||
|
#ifdef TEECOMPUTER
|
||||||
|
if (key_extmode) {
|
||||||
|
emu_writeConfig();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
menuRedraw=true;
|
menuRedraw=true;
|
||||||
}
|
}
|
||||||
|
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
|
||||||
int handler = getFreeFileHandler();
|
int handler = getFreeFileHandler();
|
||||||
if (handler >= 0) {
|
if (handler >= 0) {
|
||||||
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
||||||
emu_printi(handler+1);
|
// emu_printi(handler+1);
|
||||||
retval = handler+1;
|
retval = handler+1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
|
||||||
return(filesize);
|
return(filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_CREAT | O_WRITE)))
|
||||||
|
{
|
||||||
|
if (lofile.write(selection, strlen(selection)) != strlen(selection)) {
|
||||||
|
emu_printf("Config write failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_readConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_READ)))
|
||||||
|
{
|
||||||
|
unsigned int filesize = lofile.size();
|
||||||
|
unsigned int sizeread = lofile.read(selection, filesize);
|
||||||
|
if (sizeread != filesize) {
|
||||||
|
emu_printf("Config read failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (sizeread == filesize)
|
||||||
|
{
|
||||||
|
selection[filesize]=0;
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_eraseConfig(void)
|
||||||
|
{
|
||||||
|
SD.remove (ROMSDIR "/" AUTORUN_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* File IO compatibility
|
* File IO compatibility
|
||||||
********************************/
|
********************************/
|
||||||
|
@ -1646,8 +1706,20 @@ void emu_init(void)
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
#ifndef HAS_T4_VGA
|
#ifndef HAS_T4_VGA
|
||||||
tft.flipscreen(false);
|
tft.flipscreen(false);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
int keypressed = emu_ReadKeys();
|
||||||
|
if (keypressed & MASK_JOY2_DOWN) {
|
||||||
|
tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) );
|
||||||
|
tft.drawTextNoDma(64,48, (char*)" AUTURUN file erased", RGBVAL16(0xff,0xff,0x00), RGBVAL16(0xff,0x00,0x00), true);
|
||||||
|
emu_eraseConfig();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (emu_readConfig()) {
|
||||||
|
autorun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleMenu(true);
|
toggleMenu(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
|
||||||
MouseController mouse1(myusb);
|
MouseController mouse1(myusb);
|
||||||
MIDIDevice midi1(myusb);
|
MIDIDevice midi1(myusb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void);
|
||||||
|
static bool emu_readConfig(void);
|
||||||
|
static bool emu_eraseConfig(void);
|
||||||
|
|
||||||
static bool mouseDetected = false;
|
static bool mouseDetected = false;
|
||||||
static bool keyboardDetected = false;
|
static bool keyboardDetected = false;
|
||||||
static uint8_t usbnavpad=0;
|
static uint8_t usbnavpad=0;
|
||||||
|
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
|
||||||
static File file;
|
static File file;
|
||||||
|
|
||||||
#define MAX_FILES 64
|
#define MAX_FILES 64
|
||||||
|
#define AUTORUN_FILENAME "autorun.txt"
|
||||||
|
|
||||||
#define MAX_FILENAME_SIZE 24
|
#define MAX_FILENAME_SIZE 24
|
||||||
#define MAX_MENULINES 9
|
#define MAX_MENULINES 9
|
||||||
#define TEXT_HEIGHT 16
|
#define TEXT_HEIGHT 16
|
||||||
|
@ -57,6 +64,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE];
|
||||||
static char selected_filename[MAX_FILENAME_SIZE]="";
|
static char selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
static char second_selected_filename[MAX_FILENAME_SIZE]="";
|
||||||
static bool menuRedraw=true;
|
static bool menuRedraw=true;
|
||||||
|
static bool autorun=false;
|
||||||
|
|
||||||
static const unsigned short * keys;
|
static const unsigned short * keys;
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
|
@ -972,8 +980,11 @@ void backgroundMenu(void) {
|
||||||
|
|
||||||
int handleMenu(uint16_t bClick)
|
int handleMenu(uint16_t bClick)
|
||||||
{
|
{
|
||||||
|
if (autorun) {
|
||||||
|
return (ACTION_RUN1);
|
||||||
|
}
|
||||||
|
|
||||||
int action = ACTION_NONE;
|
int action = ACTION_NONE;
|
||||||
|
|
||||||
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
|
||||||
char newpath[MAX_FILENAME_PATH];
|
char newpath[MAX_FILENAME_PATH];
|
||||||
strcpy(newpath, selection);
|
strcpy(newpath, selection);
|
||||||
|
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
|
||||||
nbFiles = readNbFiles();
|
nbFiles = readNbFiles();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = ACTION_RUN1;
|
action = ACTION_RUN1;
|
||||||
|
#ifdef TEECOMPUTER
|
||||||
|
if (key_extmode) {
|
||||||
|
emu_writeConfig();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
menuRedraw=true;
|
menuRedraw=true;
|
||||||
}
|
}
|
||||||
|
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
|
||||||
int handler = getFreeFileHandler();
|
int handler = getFreeFileHandler();
|
||||||
if (handler >= 0) {
|
if (handler >= 0) {
|
||||||
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
|
||||||
emu_printi(handler+1);
|
// emu_printi(handler+1);
|
||||||
retval = handler+1;
|
retval = handler+1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
|
||||||
return(filesize);
|
return(filesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool emu_writeConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_CREAT | O_WRITE)))
|
||||||
|
{
|
||||||
|
if (lofile.write(selection, strlen(selection)) != strlen(selection)) {
|
||||||
|
emu_printf("Config write failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_readConfig(void)
|
||||||
|
{
|
||||||
|
bool retval = false;
|
||||||
|
|
||||||
|
if ((lofile = SD.open(ROMSDIR "/" AUTORUN_FILENAME, O_READ)))
|
||||||
|
{
|
||||||
|
unsigned int filesize = lofile.size();
|
||||||
|
unsigned int sizeread = lofile.read(selection, filesize);
|
||||||
|
if (sizeread != filesize) {
|
||||||
|
emu_printf("Config read failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (sizeread == filesize)
|
||||||
|
{
|
||||||
|
selection[filesize]=0;
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lofile.close();
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool emu_eraseConfig(void)
|
||||||
|
{
|
||||||
|
SD.remove (ROMSDIR "/" AUTORUN_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* File IO compatibility
|
* File IO compatibility
|
||||||
********************************/
|
********************************/
|
||||||
|
@ -1646,8 +1706,20 @@ void emu_init(void)
|
||||||
#ifdef TEECOMPUTER
|
#ifdef TEECOMPUTER
|
||||||
#ifndef HAS_T4_VGA
|
#ifndef HAS_T4_VGA
|
||||||
tft.flipscreen(false);
|
tft.flipscreen(false);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
int keypressed = emu_ReadKeys();
|
||||||
|
if (keypressed & MASK_JOY2_DOWN) {
|
||||||
|
tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) );
|
||||||
|
tft.drawTextNoDma(64,48, (char*)" AUTURUN file erased", RGBVAL16(0xff,0xff,0x00), RGBVAL16(0xff,0x00,0x00), true);
|
||||||
|
emu_eraseConfig();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (emu_readConfig()) {
|
||||||
|
autorun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleMenu(true);
|
toggleMenu(true);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue