add AUTORUN feature and write capabilities to AtariST floppy

pull/9/head
jean-marcharvengt 2022-02-09 20:49:23 +01:00
rodzic 25e0f243fc
commit d3d956371d
15 zmienionych plików z 1008 dodań i 455 usunięć

Wyświetl plik

@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
MouseController mouse1(myusb);
MIDIDevice midi1(myusb);
#endif
static bool emu_writeConfig(void);
static bool emu_readConfig(void);
static bool emu_eraseConfig(void);
static bool mouseDetected = false;
static bool keyboardDetected = false;
static uint8_t usbnavpad=0;
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
static File file;
#define MAX_FILES 64
#define AUTORUN_FILENAME "autorun.txt"
#define MAX_FILENAME_SIZE 24
#define MAX_MENULINES 9
#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 second_selected_filename[MAX_FILENAME_SIZE]="";
static bool menuRedraw=true;
static bool autorun=false;
static const unsigned short * keys;
#ifdef TEECOMPUTER
@ -972,8 +980,11 @@ void backgroundMenu(void) {
int handleMenu(uint16_t bClick)
{
if (autorun) {
return (ACTION_RUN1);
}
int action = ACTION_NONE;
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
char newpath[MAX_FILENAME_PATH];
strcpy(newpath, selection);
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
nbFiles = readNbFiles();
}
else {
action = ACTION_RUN1;
action = ACTION_RUN1;
#ifdef TEECOMPUTER
if (key_extmode) {
emu_writeConfig();
}
#endif
}
menuRedraw=true;
}
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
int handler = getFreeFileHandler();
if (handler >= 0) {
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
emu_printi(handler+1);
// emu_printi(handler+1);
retval = handler+1;
}
else {
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
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
********************************/
@ -1646,8 +1706,20 @@ void emu_init(void)
#ifdef TEECOMPUTER
#ifndef HAS_T4_VGA
tft.flipscreen(false);
#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);
}

Wyświetl plik

@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
MouseController mouse1(myusb);
MIDIDevice midi1(myusb);
#endif
static bool emu_writeConfig(void);
static bool emu_readConfig(void);
static bool emu_eraseConfig(void);
static bool mouseDetected = false;
static bool keyboardDetected = false;
static uint8_t usbnavpad=0;
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
static File file;
#define MAX_FILES 64
#define AUTORUN_FILENAME "autorun.txt"
#define MAX_FILENAME_SIZE 24
#define MAX_MENULINES 9
#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 second_selected_filename[MAX_FILENAME_SIZE]="";
static bool menuRedraw=true;
static bool autorun=false;
static const unsigned short * keys;
#ifdef TEECOMPUTER
@ -972,8 +980,11 @@ void backgroundMenu(void) {
int handleMenu(uint16_t bClick)
{
if (autorun) {
return (ACTION_RUN1);
}
int action = ACTION_NONE;
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
char newpath[MAX_FILENAME_PATH];
strcpy(newpath, selection);
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
nbFiles = readNbFiles();
}
else {
action = ACTION_RUN1;
action = ACTION_RUN1;
#ifdef TEECOMPUTER
if (key_extmode) {
emu_writeConfig();
}
#endif
}
menuRedraw=true;
}
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
int handler = getFreeFileHandler();
if (handler >= 0) {
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
emu_printi(handler+1);
// emu_printi(handler+1);
retval = handler+1;
}
else {
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
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
********************************/
@ -1646,8 +1706,20 @@ void emu_init(void)
#ifdef TEECOMPUTER
#ifndef HAS_T4_VGA
tft.flipscreen(false);
#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);
}

Wyświetl plik

@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
MouseController mouse1(myusb);
MIDIDevice midi1(myusb);
#endif
static bool emu_writeConfig(void);
static bool emu_readConfig(void);
static bool emu_eraseConfig(void);
static bool mouseDetected = false;
static bool keyboardDetected = false;
static uint8_t usbnavpad=0;
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
static File file;
#define MAX_FILES 64
#define AUTORUN_FILENAME "autorun.txt"
#define MAX_FILENAME_SIZE 24
#define MAX_MENULINES 9
#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 second_selected_filename[MAX_FILENAME_SIZE]="";
static bool menuRedraw=true;
static bool autorun=false;
static const unsigned short * keys;
#ifdef TEECOMPUTER
@ -972,8 +980,11 @@ void backgroundMenu(void) {
int handleMenu(uint16_t bClick)
{
if (autorun) {
return (ACTION_RUN1);
}
int action = ACTION_NONE;
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
char newpath[MAX_FILENAME_PATH];
strcpy(newpath, selection);
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
nbFiles = readNbFiles();
}
else {
action = ACTION_RUN1;
action = ACTION_RUN1;
#ifdef TEECOMPUTER
if (key_extmode) {
emu_writeConfig();
}
#endif
}
menuRedraw=true;
}
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
int handler = getFreeFileHandler();
if (handler >= 0) {
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
emu_printi(handler+1);
// emu_printi(handler+1);
retval = handler+1;
}
else {
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
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
********************************/
@ -1646,8 +1706,20 @@ void emu_init(void)
#ifdef TEECOMPUTER
#ifndef HAS_T4_VGA
tft.flipscreen(false);
#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);
}

Wyświetl plik

@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
MouseController mouse1(myusb);
MIDIDevice midi1(myusb);
#endif
static bool emu_writeConfig(void);
static bool emu_readConfig(void);
static bool emu_eraseConfig(void);
static bool mouseDetected = false;
static bool keyboardDetected = false;
static uint8_t usbnavpad=0;
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
static File file;
#define MAX_FILES 64
#define AUTORUN_FILENAME "autorun.txt"
#define MAX_FILENAME_SIZE 24
#define MAX_MENULINES 9
#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 second_selected_filename[MAX_FILENAME_SIZE]="";
static bool menuRedraw=true;
static bool autorun=false;
static const unsigned short * keys;
#ifdef TEECOMPUTER
@ -972,8 +980,11 @@ void backgroundMenu(void) {
int handleMenu(uint16_t bClick)
{
if (autorun) {
return (ACTION_RUN1);
}
int action = ACTION_NONE;
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
char newpath[MAX_FILENAME_PATH];
strcpy(newpath, selection);
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
nbFiles = readNbFiles();
}
else {
action = ACTION_RUN1;
action = ACTION_RUN1;
#ifdef TEECOMPUTER
if (key_extmode) {
emu_writeConfig();
}
#endif
}
menuRedraw=true;
}
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
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
********************************/
@ -1646,8 +1706,20 @@ void emu_init(void)
#ifdef TEECOMPUTER
#ifndef HAS_T4_VGA
tft.flipscreen(false);
#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);
}

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -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

Wyświetl plik

@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
MouseController mouse1(myusb);
MIDIDevice midi1(myusb);
#endif
static bool emu_writeConfig(void);
static bool emu_readConfig(void);
static bool emu_eraseConfig(void);
static bool mouseDetected = false;
static bool keyboardDetected = false;
static uint8_t usbnavpad=0;
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
static File file;
#define MAX_FILES 64
#define AUTORUN_FILENAME "autorun.txt"
#define MAX_FILENAME_SIZE 24
#define MAX_MENULINES 9
#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 second_selected_filename[MAX_FILENAME_SIZE]="";
static bool menuRedraw=true;
static bool autorun=false;
static const unsigned short * keys;
#ifdef TEECOMPUTER
@ -972,8 +980,11 @@ void backgroundMenu(void) {
int handleMenu(uint16_t bClick)
{
if (autorun) {
return (ACTION_RUN1);
}
int action = ACTION_NONE;
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
char newpath[MAX_FILENAME_PATH];
strcpy(newpath, selection);
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
nbFiles = readNbFiles();
}
else {
action = ACTION_RUN1;
action = ACTION_RUN1;
#ifdef TEECOMPUTER
if (key_extmode) {
emu_writeConfig();
}
#endif
}
menuRedraw=true;
}
@ -1002,8 +1018,8 @@ int handleMenu(uint16_t bClick)
}
else if ( bClick & MASK_KEY_USER2 ) {
menuRedraw=true;
action = ACTION_RUN3;
//emu_SwapJoysticks(0);
//action = ACTION_RUN3;
emu_SwapJoysticks(0);
}
else if ( (bClick & MASK_JOY2_UP) || (bClick & MASK_JOY1_UP) ) {
if (curFile!=0) {
@ -1281,7 +1297,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
// emu_printf(filepath);
#ifdef HCFH
int retval = 0;
if ((file = SD.open(filepath, O_READ))) {
if ((file = SD.open(filepath, O_READ | O_WRITE))) {
retval = 1;
}
else {
@ -1292,8 +1308,8 @@ int emu_FileOpen(const char * filepath, const char * mode)
int retval = 0;
int handler = getFreeFileHandler();
if (handler >= 0) {
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
emu_printi(handler+1);
if ((file_handlers[handler] = SD.open(filepath, O_READ | O_WRITE))) {
// emu_printi(handler+1);
retval = handler+1;
}
else {
@ -1316,6 +1332,17 @@ int emu_FileRead(void * buf, int size, int handler)
#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) {
// emu_printf("FileGetc");
// emu_printi(handler);
@ -1429,6 +1456,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
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
********************************/
@ -1646,8 +1717,20 @@ void emu_init(void)
#ifdef TEECOMPUTER
#ifndef HAS_T4_VGA
tft.flipscreen(false);
#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);
}

Wyświetl plik

@ -177,6 +177,7 @@ extern void emu_Free(void * pt);
extern int emu_FileOpen(const char * filepath, const char * mode);
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_FileSeek(int handler, int seek, int origin);
extern int emu_FileTell(int handler);

Wyświetl plik

@ -11,7 +11,7 @@
* 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)
*/
static char sccsid[] = "$Id: fdc.c,v 1.2 2002/06/08 23:31:58 jhoenig Exp $";
#include <Arduino.h>
#include <stdio.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 "emuapi.h"
#include "diskapi.h"
#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"
int fdc_commands_executed=0;
/*
* FDC Registers
*/
unsigned char fdc_data, fdc_track, fdc_sector, fdc_status, fdc_command, fdc_motor;
unsigned char fdc_int = 0;
char fdcdir=1;
unsigned char disk_ejected[2]={0,1};
unsigned char disk_changed[2];
struct Disk disk[2] = {
unsigned char fdc_data, fdc_track, fdc_sector, fdc_status, fdc_command, fdc_motor;
unsigned char fdc_int = 0;
static char fdcdir=1;
static int fdc_commands_executed=0;
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 },
};
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) {
address &= MEMADDRMASK;
WriteB(address + membase, value);
address &= MEMADDRMASK;
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;
LOG("disc read: ",len);
uint8 buf[256];
int i;
int totlen = len;
unsigned char buf[256];
while (totlen>=256) {
//fread(buf,1,256,disk[discn].file);
disk_Read(buf,256, disk[discn].file);
LOG("b read: ",buf[0]);
emu_FileRead(buf,256, disk[discn].file);
totlen -= 256;
for (i=0; i<256; i++) {
SetMemBBB(address, buf[i]);
@ -104,118 +78,117 @@ PROGMEM int discread(unsigned long address,int a,int len,int discn)
}
}
if (totlen) {
//fread(buf,1,totlen,disk[discn].file);
disk_Read(buf,totlen, disk[discn].file);
LOG("b: ",buf[0]);
emu_FileRead(buf,totlen, disk[discn].file);
for (i=0; i<totlen; i++) {
SetMemBBB(address, buf[i]);
address++;
}
}
discpos[discn]=discpos[discn]+i;
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;
}
PROGMEM int discwrite(unsigned char *buf,int a,int len,int discn)
PROGMEM int discwrite(unsigned long address, int len,int discn)
{
int i;
uint8 val1,val2,*dbuf;
dbuf=buf;
#ifdef BYTES_SWAP
for (i=0; i<len; i+=2) {
val1 = disc[discn][discpos[discn]+i];
val2 = disc[discn][discpos[discn]+i+1];
disc[discn][discpos[discn]+i] = val2;
disc[discn][discpos[discn]+i+1] =val1;
}
#endif
discpos[discn]=discpos[discn]+i;
int i;
int totlen = len;
unsigned char buf[256];
while (totlen>=256) {
for (i=0; i<256; i++) {
buf[i] = GetMemBBB(address);
address++;
}
emu_FileWrite(buf,256, disk[discn].file);
totlen -= 256;
}
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;
}
int discseek(int discn,int pos,int a)
int discseek(int discn,int pos)
{
if (pos>(1050*1024)){
return -1;
}
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;
}
PROGMEM int FDCInit(int i)
{
unsigned char *buf;
emu_printf("FDCInit");
memset((void *)&disc[i][0],0,256);
int len,len2,calcsides,calcsectors,calctracks,badbootsector;
discpos[i]=0;
int len2,calcsides,calcsectors,calctracks,badbootsector;
//if (NULL != (disk[i].file = fopen (disk[i].name, "rb"))) {
//buf=&disc[i][0];
//disk[i].file=fopen (disk[i].name, "rb");
//fseek(disk[i].file,0,SEEK_END);
//len=ftell(disk[i].file);
//disk[i].disksize = len;
//fseek(disk[i].file,0,SEEK_SET);
len = disk_Size(disk[i].name);
disk[i].file = disk_Open(disk[i].name);
buf=&disc[i][0];
disk[i].disksize = len;
if (disk[i].file) {
//fread(buf,1,256,disk[i].file);
//fseek(disk[i].file,0,SEEK_SET);
disk_Read(buf, 256, disk[i].file);
disk_Seek(0,disk[i].file);
}
disk[i].head = 0;
disk[i].sides = (int) *(buf + 26);
disk[i].sectors = (int) *(buf + 24);
disk[i].secsize = 512; //(int) ((*(buf + 12) << 8) | *(buf + 11));
if (disk[i].sectors * disk[i].sides)
disk[i].tracks = (int) ((*(buf + 20) << 8) | *(buf + 19)) /
(disk[i].sectors * disk[i].sides);
// Second Check more precise
if (len> (500*1024)) calcsides = 2;
else calcsides = 1;
if (!(((len/calcsides)/512)%9)&&(((len/calcsides)/512)/9)<86) calcsectors=9;
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;
//}
discpos[i]=0;
int len = emu_FileSize(disk[i].name);
disk[i].file = emu_FileOpen(disk[i].name,"a+rw");
disk[i].disksize = len;
unsigned char buf[256];
if (disk[i].file) {
emu_FileRead(buf, 256, disk[i].file);
emu_FileSeek(disk[i].file,0,SEEK_SET);
}
disk[i].head = 0;
disk[i].sides = (int) *(buf + 26);
disk[i].sectors = (int) *(buf + 24);
disk[i].secsize = 512; //(int) ((*(buf + 12) << 8) | *(buf + 11));
if (disk[i].sectors * disk[i].sides) {
disk[i].tracks = (int) ((*(buf + 20) << 8) | *(buf + 19)) / (disk[i].sectors * disk[i].sides);
}
// Second Check more precise
if (len> (500*1024)) calcsides = 2;
else calcsides = 1;
if (!(((len/calcsides)/512)%9)&&(((len/calcsides)/512)/9)<86) calcsectors=9;
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;
//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){
@ -239,255 +212,283 @@ PROGMEM void FDCeject(int num){
PROGMEM void FDCCommand(void)
{
static char motor = 1;
int sides, drives;
long address; /* dma target/source address */
long offset; /* offset in disk file */
unsigned long count; /* number of byte to transfer */
char *buffer;
int n;
static char motor = 1;
int sides, drives;
long address; /* dma target/source address */
long offset; /* offset in disk file */
unsigned long count; /* number of byte to transfer */
int n;
if (fdc_commands_executed<64)
fdc_commands_executed++;
/* DMA target/source address */
address = (dma_adrh << 16) + (dma_adrm << 8) + dma_adrl;
/* if (address>MEMSIZE){
#ifdef DISASS
StartDisass();
exit(1);
#endif
fdc_status |= 0x10;
return;
}
if (fdc_commands_executed<64)
fdc_commands_executed++;
/* DMA target/source address */
address = (dma_adrh << 16) + (dma_adrm << 8) + dma_adrl;
/*
if (address>MEMSIZE) {
fdc_status |= 0x10;
return;
}
*/
buffer = (char *)(membase + address);
/* status of side select and drive select lines */
sides = (~psg[14]) & 0x1;
drives = (~psg[14]) & 0x6;
if (disk_ejected[drives>>2]==1) drives=2;
switch (drives) {
/* status of side select and drive select lines */
sides = (~psg[14]) & 0x1;
drives = (~psg[14]) & 0x6;
if (disk_ejected[drives>>2]==1) drives=2;
switch (drives)
{
case 2: /* Drive A */
drives = 0;
break;
drives = 0;
break;
case 4: /* Drive B */
drives = 1;
break;
drives = 1;
break;
case 6: /* both, error */
case 0: /* no drive selected */
drives = -1;
break;
}
fdc_status = 0; /* clear fdc status */
drives = -1;
break;
}
if (fdc_command < 0x80) { /* TYPE-I fdc commands */
if (drives >= 0) { /* drive selected */
switch (fdc_command & 0xf0) {
case 0x00: /* RESTORE */
disk[drives].head = 0;
fdc_track = 0;
break;
case 0x10: /* SEEK */
disk[drives].head += (fdc_data - fdc_track);
fdc_track = fdc_data;
if (disk[drives].head < 0
|| disk[drives].head >= disk[drives].tracks)
disk[drives].head = 0;
break;
case 0x30: /* STEP */
fdc_track += fdcdir;
case 0x20:
disk[drives].head += fdcdir;
break;
case 0x50: /* STEP-IN */
fdc_track++;
case 0x40:
if (disk[drives].head < disk[drives].tracks)
disk[drives].head++;
fdcdir = 1;
break;
case 0x70: /* STEP-OUT */
fdc_track--;
case 0x60:
if (disk[drives].head > 0)
disk[drives].head--;
fdcdir = -1;
break;
}
if (disk[drives].head == 0) {
fdc_status |= 0x4;
}
if (disk[drives].head != fdc_track && fdc_command & 0x4) { /* Verify? */
fdc_status |= 0x10;
}
if (motor) {
fdc_status |= 0x20; /* spin-up flag */
}
} 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 */
}
fdc_status = 0; /* clear fdc status */
if (fdc_command < 0x80) { /* TYPE-I fdc commands */
if (drives >= 0) { /* drive selected */
switch (fdc_command & 0xf0) {
case 0x00: /* RESTORE */
disk[drives].head = 0;
fdc_track = 0;
break;
case 0x10: /* SEEK */
disk[drives].head += (fdc_data - fdc_track);
fdc_track = fdc_data;
if (disk[drives].head < 0 || disk[drives].head >= disk[drives].tracks)
disk[drives].head = 0;
break;
case 0x30: /* STEP */
fdc_track += fdcdir;
case 0x20:
disk[drives].head += fdcdir;
break;
case 0x50: /* STEP-IN */
fdc_track++;
case 0x40:
if (disk[drives].head < disk[drives].tracks)
disk[drives].head++;
fdcdir = 1;
break;
case 0x70: /* STEP-OUT */
fdc_track--;
case 0x60:
if (disk[drives].head > 0)
disk[drives].head--;
fdcdir = -1;
break;
}
if (disk[drives].head == 0) {
fdc_status |= 0x4;
}
if (disk[drives].head != fdc_track && fdc_command & 0x4) { /* Verify? */
fdc_status |= 0x10;
}
if (motor) {
fdc_status |= 0x20; /* spin-up flag */
}
}
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))
{
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) {
fdc_status |= 0x80; /* motor on flag */
fdc_motor=1;
}
if (!(fdc_status & 0x01)) { /* not busy */
mfp_iprb |= (0x80 & mfp_ierb); /* Request Interrupt */
mfp_gpip &= ~0x20;
}
if (motor)
{
fdc_status |= 0x80; /* motor on flag */
fdc_motor=1;
}
if (!(fdc_status & 0x01))
{ /* not busy */
mfp_iprb |= (0x80 & mfp_ierb); /* Request Interrupt */
mfp_gpip &= ~0x20;
}
}

Wyświetl plik

@ -6,10 +6,10 @@
#ifdef TEECOMPUTER
//#define ILI9341 1
#define ST7789 1
#define TFTSPI1 1
//#define HAS_T4_VGA 1
//#define HIRES 1
//#define ST7789 1
//#define TFTSPI1 1
#define HAS_T4_VGA 1
#define HIRES 1
#define HAS_SND 1
#define HAS_USBKEY 1

Wyświetl plik

@ -174,10 +174,6 @@ void Redraw16_hi ( int row, int vid_adr )
#endif
static uint8 disk0[256];
static uint8 disk1[256];
void ast_Init(void)
{
emu_printf("Allocating RAM");
@ -188,10 +184,6 @@ void ast_Init(void)
rombase = (int8*)&tos[0]-ROMBASE;
(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;
@ -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)
{
if (mode) display_mode = MONO;
emu_printf("init started");
strncpy (disk[0].name, floppy1, sizeof(disk[0].name));
strncpy (disk[1].name, floppy2, sizeof(disk[1].name));
strncpy (disk[0].name, floppy1, strlen(floppy1));
strncpy (disk[1].name, floppy2, strlen(floppy2));
initialize_memmap();
FDCInit(0);

Wyświetl plik

@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
MouseController mouse1(myusb);
MIDIDevice midi1(myusb);
#endif
static bool emu_writeConfig(void);
static bool emu_readConfig(void);
static bool emu_eraseConfig(void);
static bool mouseDetected = false;
static bool keyboardDetected = false;
static uint8_t usbnavpad=0;
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
static File file;
#define MAX_FILES 64
#define AUTORUN_FILENAME "autorun.txt"
#define MAX_FILENAME_SIZE 24
#define MAX_MENULINES 9
#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 second_selected_filename[MAX_FILENAME_SIZE]="";
static bool menuRedraw=true;
static bool autorun=false;
static const unsigned short * keys;
#ifdef TEECOMPUTER
@ -972,8 +980,11 @@ void backgroundMenu(void) {
int handleMenu(uint16_t bClick)
{
if (autorun) {
return (ACTION_RUN1);
}
int action = ACTION_NONE;
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
char newpath[MAX_FILENAME_PATH];
strcpy(newpath, selection);
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
nbFiles = readNbFiles();
}
else {
action = ACTION_RUN1;
action = ACTION_RUN1;
#ifdef TEECOMPUTER
if (key_extmode) {
emu_writeConfig();
}
#endif
}
menuRedraw=true;
}
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
int handler = getFreeFileHandler();
if (handler >= 0) {
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
emu_printi(handler+1);
// emu_printi(handler+1);
retval = handler+1;
}
else {
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
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
********************************/
@ -1646,8 +1706,20 @@ void emu_init(void)
#ifdef TEECOMPUTER
#ifndef HAS_T4_VGA
tft.flipscreen(false);
#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);
}

Wyświetl plik

@ -5,9 +5,9 @@
#ifdef TEECOMPUTER
//#define ILI9341 1
#define ST7789 1
#define TFTSPI1 1
//#define HAS_T4_VGA 1
//#define ST7789 1
//#define TFTSPI1 1
#define HAS_T4_VGA 1
//#define HIRES 1
//#define HAS_SND 1
#define HAS_USBKEY 1

Wyświetl plik

@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
MouseController mouse1(myusb);
MIDIDevice midi1(myusb);
#endif
static bool emu_writeConfig(void);
static bool emu_readConfig(void);
static bool emu_eraseConfig(void);
static bool mouseDetected = false;
static bool keyboardDetected = false;
static uint8_t usbnavpad=0;
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
static File file;
#define MAX_FILES 64
#define AUTORUN_FILENAME "autorun.txt"
#define MAX_FILENAME_SIZE 24
#define MAX_MENULINES 9
#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 second_selected_filename[MAX_FILENAME_SIZE]="";
static bool menuRedraw=true;
static bool autorun=false;
static const unsigned short * keys;
#ifdef TEECOMPUTER
@ -972,8 +980,11 @@ void backgroundMenu(void) {
int handleMenu(uint16_t bClick)
{
if (autorun) {
return (ACTION_RUN1);
}
int action = ACTION_NONE;
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
char newpath[MAX_FILENAME_PATH];
strcpy(newpath, selection);
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
nbFiles = readNbFiles();
}
else {
action = ACTION_RUN1;
action = ACTION_RUN1;
#ifdef TEECOMPUTER
if (key_extmode) {
emu_writeConfig();
}
#endif
}
menuRedraw=true;
}
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
int handler = getFreeFileHandler();
if (handler >= 0) {
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
emu_printi(handler+1);
// emu_printi(handler+1);
retval = handler+1;
}
else {
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
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
********************************/
@ -1646,8 +1706,20 @@ void emu_init(void)
#ifdef TEECOMPUTER
#ifndef HAS_T4_VGA
tft.flipscreen(false);
#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);
}

Wyświetl plik

@ -20,6 +20,11 @@ USBHIDParser hid1(myusb);
MouseController mouse1(myusb);
MIDIDevice midi1(myusb);
#endif
static bool emu_writeConfig(void);
static bool emu_readConfig(void);
static bool emu_eraseConfig(void);
static bool mouseDetected = false;
static bool keyboardDetected = false;
static uint8_t usbnavpad=0;
@ -28,6 +33,8 @@ static uint8_t usbnavpad=0;
static File file;
#define MAX_FILES 64
#define AUTORUN_FILENAME "autorun.txt"
#define MAX_FILENAME_SIZE 24
#define MAX_MENULINES 9
#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 second_selected_filename[MAX_FILENAME_SIZE]="";
static bool menuRedraw=true;
static bool autorun=false;
static const unsigned short * keys;
#ifdef TEECOMPUTER
@ -972,8 +980,11 @@ void backgroundMenu(void) {
int handleMenu(uint16_t bClick)
{
if (autorun) {
return (ACTION_RUN1);
}
int action = ACTION_NONE;
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_JOY1_BTN) ) {
char newpath[MAX_FILENAME_PATH];
strcpy(newpath, selection);
@ -988,7 +999,12 @@ int handleMenu(uint16_t bClick)
nbFiles = readNbFiles();
}
else {
action = ACTION_RUN1;
action = ACTION_RUN1;
#ifdef TEECOMPUTER
if (key_extmode) {
emu_writeConfig();
}
#endif
}
menuRedraw=true;
}
@ -1293,7 +1309,7 @@ int emu_FileOpen(const char * filepath, const char * mode)
int handler = getFreeFileHandler();
if (handler >= 0) {
if ((file_handlers[handler] = SD.open(filepath, O_READ))) {
emu_printi(handler+1);
// emu_printi(handler+1);
retval = handler+1;
}
else {
@ -1429,6 +1445,50 @@ unsigned int emu_LoadFileSeek(const char * filepath, void * buf, int size, int s
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
********************************/
@ -1646,8 +1706,20 @@ void emu_init(void)
#ifdef TEECOMPUTER
#ifndef HAS_T4_VGA
tft.flipscreen(false);
#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);
}