fix mouse button

This commit is contained in:
jean-marcharvengt 2020-11-11 15:42:38 +01:00
parent abcc2e7468
commit 923be56795
15 changed files with 12742 additions and 12475 deletions

View file

@ -2,8 +2,8 @@
#define DISKAPI_H #define DISKAPI_H
int disk_Size(char * filename); int disk_Size(char * filename);
int disk_Open(char * filename); int disk_Open(char * filename, int disk);
int disk_Read(char * buf, int size); int disk_Read(char * buf, int size, int disk);
int disk_Seek(int seek); int disk_Seek(int seek, int disk);
#endif #endif

View file

@ -31,10 +31,11 @@ static const uint16_t * logo = deflogo;
#ifdef HAS_USBKEY #ifdef HAS_USBKEY
#include "USBHost_t36.h" // Read this header first for key info #include "USBHost_t36.h" // Read this header first for key info
USBHost myusb; USBHost myusb;
//USBHub hub1(myusb); USBHub hub1(myusb);
KeyboardController keyboard1(myusb); KeyboardController keyboard1(myusb);
USBHIDParser hid1(myusb); USBHIDParser hid1(myusb);
MouseController mouse1(myusb); MouseController mouse1(myusb);
MIDIDevice midi1(myusb);
#endif #endif
static bool mouseDetected = false; static bool mouseDetected = false;
static bool keyboardDetected = false; static bool keyboardDetected = false;
@ -131,6 +132,7 @@ static int nbFiles=0;
static int curFile=0; static int curFile=0;
static int topFile=0; static int topFile=0;
static char selection[MAX_FILENAME_SIZE+1]=""; static char selection[MAX_FILENAME_SIZE+1]="";
static char shown_selection[MAX_FILENAME_SIZE+1]="";
static char files[MAX_FILES][MAX_FILENAME_SIZE]; static char files[MAX_FILES][MAX_FILENAME_SIZE];
static bool menuRedraw=true; static bool menuRedraw=true;
@ -421,6 +423,8 @@ int emu_ReadKeys(void)
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT; if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT; if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN; if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
if (usbnavpad & MASK_KEY_USER1) retval |= MASK_KEY_USER1;
if (usbnavpad & MASK_KEY_USER2) retval |= MASK_KEY_USER2;
#ifdef PIN_KEY_USER1 #ifdef PIN_KEY_USER1
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1; if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
@ -822,14 +826,20 @@ int handleMenu(uint16_t bClick)
nbFiles = readNbFiles(); nbFiles = readNbFiles();
} }
else { else {
action = ACTION_RUNTFT; action = ACTION_RUN1;
} }
menuRedraw=true; menuRedraw=true;
} }
else if ( (bClick & MASK_KEY_USER1) || (c == MKEY_VGA) ) { else if ( (bClick & MASK_KEY_USER1) || (c == MKEY_VGA) ) {
menuRedraw=true; menuRedraw=true;
action = ACTION_RUNVGA; strcpy(shown_selection,selection);
action = ACTION_RUN2;
} }
else if ( (bClick & MASK_KEY_USER2) || (c == MKEY_JOY) ) {
menuRedraw=true;
action = ACTION_RUN3;
//emu_SwapJoysticks(0);
}
else if ( (c >= MKEY_L1) && (c <= MKEY_L9) ) { else if ( (c >= MKEY_L1) && (c <= MKEY_L9) ) {
if ( (topFile+(int)c-1) <= (nbFiles-1) ) if ( (topFile+(int)c-1) <= (nbFiles-1) )
{ {
@ -869,10 +879,6 @@ int handleMenu(uint16_t bClick)
menuRedraw=true; menuRedraw=true;
} }
} }
else if ( (bClick & MASK_KEY_USER2) || (c == MKEY_JOY) ) {
emu_SwapJoysticks(0);
menuRedraw=true;
}
if (menuRedraw && nbFiles) { if (menuRedraw && nbFiles) {
int fileIndex = 0; int fileIndex = 0;
@ -912,7 +918,10 @@ int handleMenu(uint16_t bClick)
#ifndef HAS_T4_VGA #ifndef HAS_T4_VGA
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy); tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
#endif #endif
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false); // tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, "FLOPPY2:", RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
tft.drawRectNoDma(120,MENU_JOYS_YOFFSET+8, MENU_FILE_W, 8, RGBVAL16(0x00,0x00,0x00));
tft.drawTextNoDma(120,MENU_JOYS_YOFFSET+8, shown_selection, RGBVAL16(0xff,0xff,0xff), RGBVAL16(0x00,0x00,0x00), false);
menuRedraw=false; menuRedraw=false;
} }
@ -1007,12 +1016,18 @@ void OnPress(auto key)
case 10: case 10:
usbnavpad |= MASK_JOY2_BTN; usbnavpad |= MASK_JOY2_BTN;
break; break;
case 32:
usbnavpad |= MASK_KEY_USER1;
break;
case 9:
usbnavpad |= MASK_KEY_USER2;
break;
} }
} }
else else
{ {
emu_KeyboardOnDown(keymodifier, key); emu_KeyboardOnDown(keymodifier, key);
} }
} }
void OnRelease(int key) void OnRelease(int key)
@ -1068,6 +1083,12 @@ void OnRelease(int key)
case 10: case 10:
usbnavpad &= ~MASK_JOY2_BTN; usbnavpad &= ~MASK_JOY2_BTN;
break; break;
case 32:
usbnavpad &= ~MASK_KEY_USER1;
break;
case 9:
usbnavpad &= ~MASK_KEY_USER2;
break;
} }
} }
else else
@ -1085,7 +1106,122 @@ int emu_KeyboardDetected(void) {
return (keyboardDetected?1:0); return (keyboardDetected?1:0);
} }
#ifdef HAS_USBKEY
static unsigned char midiBuffer[16];
static int midiDataCnt=0;
static int midiLastCmd=0;
static int midiCmdNbParam=0;
#endif
void emu_MidiOnDataReceived(unsigned char value) {
#ifdef HAS_USBKEY
//10000000 = 128 = note off
//10010000 = 144 = note on
//10100000 = 160 = aftertouch
//10110000 = 176 = continuous controller
//11000000 = 192 = patch change
//11010000 = 208 = channel pressure
//11100000 = 224 = pitch bend
//11110000 = 240 = non-musical commands
if (value >= 128) {
midiDataCnt = 0;
midiLastCmd = value;
switch (value & 0xF0) {
case 128:
midiCmdNbParam = 2;
Serial.print("note off: ");
Serial.println(value&0xf);
break;
case 144:
midiCmdNbParam = 2;
Serial.print("note on: ");
Serial.println(value&0xf);
break;
case 160:
midiCmdNbParam = 2;
Serial.print("aftertouch: ");
Serial.println(value&0xf);
break;
case 176:
midiCmdNbParam = 2;
Serial.print("continuous controller: ");
Serial.println(value&0xf);
break;
case 192:
midiCmdNbParam = 1;
Serial.print("patch change: ");
Serial.println(value&0xf);
break;
case 208:
midiCmdNbParam = 1;
Serial.print("channel pressure: ");
Serial.println(value&0xf);
break;
case 224:
midiCmdNbParam = 2;
Serial.print("pitch bend: ");
Serial.println(value&0xf);
break;
case 240:
Serial.print("non-musical commands: ");
Serial.println(value&0xf);
break;
default:
Serial.print("??: ");
Serial.println(value&0xf);
break;
}
}
else {
if (midiDataCnt<16) midiBuffer[midiDataCnt++] = value ;
Serial.print("DATA ");
Serial.println(value);
if (midiDataCnt == midiCmdNbParam) {
switch (midiLastCmd & 0xF0) {
case 128:
midiCmdNbParam = 2;
midi1.sendNoteOff(midiBuffer[0], midiBuffer[1], midiLastCmd&0xf);
break;
case 144:
midiCmdNbParam = 2;
midi1.sendNoteOn(midiBuffer[0], midiBuffer[1], midiLastCmd&0xf);
break;
case 160:
midiCmdNbParam = 2;
midi1.sendAfterTouchPoly(midiBuffer[0], midiBuffer[1], midiLastCmd&0xf);
//Serial.print("aftertouch: ");
break;
case 176:
midiCmdNbParam = 2;
//Serial.print("continuous controller: ");
midi1.sendControlChange(midiBuffer[0], midiBuffer[1], midiLastCmd&0xf);
break;
case 192:
midiCmdNbParam = 1;
//Serial.print("patch change: ");
midi1.sendProgramChange(midiBuffer[0], midiLastCmd&0xf);
break;
case 208:
midiCmdNbParam = 1;
//Serial.print("channel pressure: ");
midi1.sendProgramChange(midiBuffer[0], midiLastCmd&0xf);
break;
case 224:
midiCmdNbParam = 2;
//Serial.print("pitch bend: ");
midi1.sendProgramChange(midiBuffer[1]<<7+midiBuffer[0], midiLastCmd&0xf);
break;
case 240:
Serial.print("non-musical commands: ");
break;
default:
Serial.print("??: ");
break;
}
}
}
#endif
}
static void callibrationInit(void) static void callibrationInit(void)
{ {
@ -1248,6 +1384,88 @@ int handleCallibration(uint16_t bClick) {
static File filehandlers[3];
int emu_FileOpenBis(char * filename, int handler)
{
int retval = 0;
char filepath[80];
strcpy(filepath, romspath);
strcat(filepath, "/");
strcat(filepath, filename);
emu_printf("FileOpen...");
emu_printf(filepath);
#ifdef USE_SDFS
if( !(f_open(&file, filepath, FA_READ)) ) {
#else
if ((filehandlers[handler] = SD.open(filepath, O_READ))) {
#endif
retval = handler;
}
else {
emu_printf("FileOpen failed");
}
return (retval);
}
int emu_FileReadBis(char * buf, int size, int handler)
{
unsigned char buffer[256];
int remaining = size;
int byteread = 0;
int retval=0;
if (size < 256) {
#ifdef USE_SDFS
if( !(f_read (&file, buffer, size, &retval)) )
#else
retval = filehandlers[handler].read(buffer, size);
#endif
if (retval>0) {
memcpy(buf,buffer,retval);
byteread += retval;
}
}
else {
while (remaining>0) {
#ifdef USE_SDFS
if( !(f_read (&file, buffer, 256, &retval)) )
//f_read (&file, buffer, 256, &retval);
#else
retval = filehandlers[handler].read(buffer, 256);
#endif
if (retval>0) {
//emu_printi(retval);
memcpy(buf,buffer,retval);
buf += retval;
byteread += retval;
remaining -= retval;
}
else {
break;
}
}
}
return byteread;
}
int emu_FileSeekBis(int seek, int handler)
{
#ifdef USE_SDFS
f_lseek(&file, seek);
#else
filehandlers[handler].seek(seek);
#endif
return (seek);
}
int emu_FileOpen(char * filename) int emu_FileOpen(char * filename)
{ {
@ -1314,6 +1532,26 @@ int emu_FileRead(char * buf, int size)
return byteread; return byteread;
} }
int emu_FileSeek(int seek)
{
#ifdef USE_SDFS
f_lseek(&file, seek);
#else
file.seek(seek);
#endif
return (seek);
}
int emu_FileTell(void)
{
#ifdef USE_SDFS
return (f_tell(&file));
#else
return (50);
#endif
}
unsigned char emu_FileGetc(void) { unsigned char emu_FileGetc(void) {
unsigned char c; unsigned char c;
#ifdef USE_SDFS #ifdef USE_SDFS
@ -1364,25 +1602,6 @@ int emu_FileSize(char * filename)
return(filesize); return(filesize);
} }
int emu_FileSeek(int seek)
{
#ifdef USE_SDFS
f_lseek(&file, seek);
#else
file.seek(seek);
#endif
return (seek);
}
int emu_FileTell(void)
{
#ifdef USE_SDFS
return (f_tell(&file));
#else
return (50);
#endif
}
int emu_LoadFile(char * filename, char * buf, int size) int emu_LoadFile(char * filename, char * buf, int size)
{ {

View file

@ -12,7 +12,7 @@
#define TITLE " AtariST Emulator " #define TITLE " AtariST Emulator "
#define ROMSDIR "/st" #define ROMSDIR "/st"
#define emu_Init(ROM,MODE) {ast_Init(); ast_Start(ROM,MODE);} #define emu_Init(FLOPPY1, FLOPPY2, MODE) {ast_Init(); ast_Start(FLOPPY1, FLOPPY2, MODE);}
#define emu_Step(x) {ast_Step();} #define emu_Step(x) {ast_Step();}
#define emu_Input(x) {ast_Input(x);} #define emu_Input(x) {ast_Input(x);}
@ -28,8 +28,9 @@
#define ACTION_NONE 0 #define ACTION_NONE 0
#define ACTION_MAXKBDVAL 16 #define ACTION_MAXKBDVAL 16
#define ACTION_EXITKBD 128 #define ACTION_EXITKBD 128
#define ACTION_RUNTFT 129 #define ACTION_RUN1 129
#define ACTION_RUNVGA 130 #define ACTION_RUN2 130
#define ACTION_RUN3 131
#ifdef KEYMAP_PRESENT #ifdef KEYMAP_PRESENT
@ -117,6 +118,10 @@ extern void emu_printi(int val);
extern void * emu_Malloc(int size); extern void * emu_Malloc(int size);
extern void emu_Free(void * pt); extern void emu_Free(void * pt);
extern int emu_FileOpenBis(char * filename, int handler);
extern int emu_FileReadBis(char * buf, int size, int handler);
extern int emu_FileSeekBis(int seek, int handler);
extern int emu_FileOpen(char * filename); extern int emu_FileOpen(char * filename);
extern int emu_FileRead(char * buf, int size); extern int emu_FileRead(char * buf, int size);
extern unsigned char emu_FileGetc(void); extern unsigned char emu_FileGetc(void);
@ -153,6 +158,7 @@ extern int emu_ReadAnalogJoyY(int min, int max);
extern int emu_ReadI2CKeyboard(void); extern int emu_ReadI2CKeyboard(void);
extern void emu_KeyboardOnUp(int keymodifer, int key); extern void emu_KeyboardOnUp(int keymodifer, int key);
extern void emu_KeyboardOnDown(int keymodifer, int key); extern void emu_KeyboardOnDown(int keymodifer, int key);
extern void emu_MidiOnDataReceived(unsigned char data);
extern void emu_sndPlaySound(int chan, int volume, int freq); extern void emu_sndPlaySound(int chan, int volume, int freq);
extern void emu_sndPlayBuzz(int size, int val); extern void emu_sndPlayBuzz(int size, int val);

View file

@ -25,9 +25,6 @@ static char sccsid[] = "$Id: fdc.c,v 1.2 2002/06/08 23:31:58 jhoenig Exp $";
#include "diskapi.h" #include "diskapi.h"
//#define MEMDISC 1
#define DISK 1
#define DISKNULL \ #define DISKNULL \
"\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\0\0" \
@ -93,28 +90,12 @@ PROGMEM int discread(unsigned long address,int a,int len,int discn)
{ {
int i; int i;
#ifdef MEMDISC
uint8 val1,val2,*dbuf;
uint8 *buf = (uint8 *)(membase + address);
dbuf=buf;
for (i=0;i<len;i++) *buf++=disc[discn][discpos[discn]+i];
#ifdef BYTES_SWAP
for (i=0; i<len; i+=2) {
val1 = dbuf[i];
val2 = dbuf[i+1];
dbuf[i] = val2;
dbuf[i+1] =val1;
}
#endif
#else
LOG("disc read: ",len); LOG("disc read: ",len);
uint8 buf[256]; uint8 buf[256];
int totlen = len; int totlen = len;
while (totlen>=256) { while (totlen>=256) {
//fread(buf,1,256,disk[discn].file); //fread(buf,1,256,disk[discn].file);
disk_Read(buf,256); disk_Read(buf,256, disk[discn].file);
LOG("b read: ",buf[0]); LOG("b read: ",buf[0]);
totlen -= 256; totlen -= 256;
@ -125,14 +106,13 @@ PROGMEM int discread(unsigned long address,int a,int len,int discn)
} }
if (totlen) { if (totlen) {
//fread(buf,1,totlen,disk[discn].file); //fread(buf,1,totlen,disk[discn].file);
disk_Read(buf,totlen); disk_Read(buf,totlen, disk[discn].file);
LOG("b: ",buf[0]); 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++;
} }
} }
#endif
discpos[discn]=discpos[discn]+i; discpos[discn]=discpos[discn]+i;
readdsk |= ( discn + 1 ); readdsk |= ( discn + 1 );
@ -143,11 +123,7 @@ PROGMEM int discwrite(unsigned char *buf,int a,int len,int discn)
{ {
int i; int i;
uint8 val1,val2,*dbuf; uint8 val1,val2,*dbuf;
dbuf=buf; dbuf=buf;
#ifdef MEMDISC
//for (i=0;i<len;i++) disc[discn][discpos[discn]+i]=*buf++;
#else
#endif
#ifdef BYTES_SWAP #ifdef BYTES_SWAP
for (i=0; i<len; i+=2) { for (i=0; i<len; i+=2) {
val1 = disc[discn][discpos[discn]+i]; val1 = disc[discn][discpos[discn]+i];
@ -166,10 +142,7 @@ int discseek(int discn,int pos,int a)
return -1; return -1;
} }
discpos[discn]=pos; discpos[discn]=pos;
#ifdef MEMDISC if (disk[discn].file) disk_Seek(pos, disk[discn].file); //fseek(disk[discn].file,pos,SEEK_SET);
#else
if (disk[discn].file) disk_Seek(pos); //fseek(disk[discn].file,pos,SEEK_SET);
#endif
return 0; return 0;
} }
@ -181,11 +154,7 @@ PROGMEM int FDCInit(int i)
{ {
unsigned char *buf; unsigned char *buf;
emu_printf("FDCInit"); emu_printf("FDCInit");
#ifdef MEMDISC
memset((void *)&disc[i][0],0,MAX_DISC_SIZE);
#else
memset((void *)&disc[i][0],0,256); memset((void *)&disc[i][0],0,256);
#endif
int len,len2,calcsides,calcsectors,calctracks,badbootsector; int len,len2,calcsides,calcsectors,calctracks,badbootsector;
discpos[i]=0; discpos[i]=0;
@ -197,21 +166,17 @@ PROGMEM int FDCInit(int i)
//disk[i].disksize = len; //disk[i].disksize = len;
//fseek(disk[i].file,0,SEEK_SET); //fseek(disk[i].file,0,SEEK_SET);
len = disk_Size(disk[i].name); len = disk_Size(disk[i].name);
disk[i].file = disk_Open(disk[i].name); disk[i].file = disk_Open(disk[i].name, i);
buf=&disc[i][0]; buf=&disc[i][0];
disk[i].disksize = len; disk[i].disksize = len;
#ifdef MEMDISC
//fread(buf,1,len,disk[i].file);
//fclose(disk[i].file);
#else
if (disk[i].file) { if (disk[i].file) {
//fread(buf,1,256,disk[i].file); //fread(buf,1,256,disk[i].file);
//fseek(disk[i].file,0,SEEK_SET); //fseek(disk[i].file,0,SEEK_SET);
disk_Read(buf, 256); disk_Read(buf, 256, disk[i].file);
disk_Seek(0); disk_Seek(0,disk[i].file);
} }
#endif
disk[i].head = 0; disk[i].head = 0;
disk[i].sides = (int) *(buf + 26); disk[i].sides = (int) *(buf + 26);
disk[i].sectors = (int) *(buf + 24); disk[i].sectors = (int) *(buf + 24);
@ -263,10 +228,7 @@ PROGMEM void FDCchange(int i){
PROGMEM void FDCeject(int num){ PROGMEM void FDCeject(int num){
int i; int i;
#ifdef MEMDISC
for (i=0;i<1050*1024;i++) disc[num][i]=0;
#endif
disk[num].file = NULL; disk[num].file = NULL;
sprintf(disk[num].name,"disk%01d",num); sprintf(disk[num].name,"disk%01d",num);
disk[num].sides = SIDES; disk[num].sides = SIDES;
@ -322,7 +284,6 @@ PROGMEM void FDCCommand(void)
} }
fdc_status = 0; /* clear fdc status */ fdc_status = 0; /* clear fdc status */
#if DISK
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 */
@ -522,7 +483,7 @@ PROGMEM void FDCCommand(void)
fdc_status |= 0x10; /* no drive selected */ fdc_status |= 0x10; /* no drive selected */
} }
} }
#endif
if (motor) { if (motor) {
fdc_status |= 0x80; /* motor on flag */ fdc_status |= 0x80; /* motor on flag */
fdc_motor=1; fdc_motor=1;

View file

@ -31,6 +31,7 @@ static char sccsid[] = "$Id: st.c,v 1.14 2002/10/10 19:41:27 jhoenig Exp $";
#ifndef NO_SOUND #ifndef NO_SOUND
#include "sound.h" #include "sound.h"
#endif #endif
#include "emuapi.h"
#ifdef DEBUG #ifdef DEBUG
@ -375,18 +376,21 @@ PROGMEM void DoIOWB(uint32 address, uint8 value)
switch(address) { switch(address) {
case ACIA1_SR&0x7fff: case ACIA1_SR&0x7fff:
//Serial.println(value);
waitstate+=8; waitstate+=8;
acia1_cr = value; acia1_cr = value;
break; break;
case ACIA1_DR&0x7fff: case ACIA1_DR&0x7fff:
//Serial.println(value);
waitstate+=8; waitstate+=8;
IkbdRecv (value); IkbdRecv (value);
break; break;
case ACIA2_SR&0x7fff: case ACIA2_SR&0x7fff:
waitstate+=8; waitstate+=8;
acia2_cr = value; acia2_cr = value;
break; break;
case ACIA2_DR&0x7fff: case ACIA2_DR&0x7fff:
emu_MidiOnDataReceived(value);
waitstate+=8; waitstate+=8;
break; break;
} }

View file

@ -244,23 +244,27 @@ void setup() {
void loop(void) void loop(void)
{ {
static char floppy2[64]="";
if (menuActive()) { if (menuActive()) {
uint16_t bClick = emu_DebounceLocalKeys(); uint16_t bClick = emu_DebounceLocalKeys();
int action = handleMenu(bClick); int action = handleMenu(bClick);
char * filename = menuSelection(); char * floppy1 = menuSelection();
if (action == ACTION_RUNTFT) { if (action == ACTION_RUN1) {
toggleMenu(false); toggleMenu(false);
vgaMode = false; vgaMode = false;
emu_start(); emu_start();
emu_Init(filename,0); emu_Init(floppy1,floppy2,0);
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) ); tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
tft.startDMA(); tft.startDMA();
} }
else if (action == ACTION_RUNVGA) { else if (action == ACTION_RUN2) {
strcpy(floppy2,menuSelection());
}
else if (action == ACTION_RUN3) {
toggleMenu(false); toggleMenu(false);
vgaMode = false; vgaMode = false;
emu_start(); emu_start();
emu_Init(filename,1); emu_Init(floppy1,floppy2,1);
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) ); tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
tft.startDMA(); tft.startDMA();
} }

View file

@ -16,7 +16,7 @@
#include "sound.h" #include "sound.h"
#endif #endif
#include "tossw12.h" #include "tossw14.h"
int8 *membase; int8 *membase;
int8 *rombase; int8 *rombase;
@ -216,7 +216,8 @@ static int prev_mouse_y = 100;
static int prev_key = 0; static int prev_key = 0;
static int prev_j = 0; static int prev_j = 0;
static int prev_mouseb = 0; static int prev_mouseb1 = 0;
static int prev_mouseb2 = 0;
static bool isMouse = true; static bool isMouse = true;
static int joynum = 1; static int joynum = 1;
static int hk = 0; static int hk = 0;
@ -267,16 +268,16 @@ const int16_t keyboardAsciiConv[] = // QWERTY Keyboard
/* 0x23 */ INV_KEY, /* 0x23 */ INV_KEY,
/* 0x24 */ INV_KEY, /* 0x24 */ INV_KEY,
/* 0x25 */ INV_KEY, /* 0x25 */ INV_KEY,
/* 0x26 */ INV_KEY, /* 0x26 */ 43, // ampercent (backslash)
/* 0x27 */ INV_KEY, /* 0x27 */ 40, // single quote
/* 0x28 */ INV_KEY, /* 0x28 */ 26, // bracket left
/* 0x29 */ INV_KEY, /* 0x29 */ 27, // bracket right
/* 0x2A */ INV_KEY, // mult /* 0x2A */ INV_KEY, // mult *
/* 0x2B */ INV_KEY, /* 0x2B */ INV_KEY,
/* 0x2C */ INV_KEY, // comma /* 0x2C */ 51, // comma ,
/* 0x2D */ INV_KEY, /* 0x2D */ 12, // minus -
/* 0x2E */ INV_KEY, /* 0x2E */ 52, // period .
/* 0x2F */ INV_KEY, /* 0x2F */ 53, // slash /
/* 0x30 */ 0x0B, // 0 /* 0x30 */ 0x0B, // 0
/* 0x31 */ 0x02, /* 0x31 */ 0x02,
/* 0x32 */ 0x03, /* 0x32 */ 0x03,
@ -287,10 +288,10 @@ const int16_t keyboardAsciiConv[] = // QWERTY Keyboard
/* 0x37 */ 0x08, /* 0x37 */ 0x08,
/* 0x38 */ 0x09, /* 0x38 */ 0x09,
/* 0x39 */ 0x0A, // 9 /* 0x39 */ 0x0A, // 9
/* 0x3A */ INV_KEY, /* 0x3A */ INV_KEY, // colon :
/* 0x3B */ INV_KEY, // semi colon /* 0x3B */ 39, // semi colon ;
/* 0x3C */ INV_KEY, /* 0x3C */ INV_KEY,
/* 0x3D */ INV_KEY, /* 0x3D */ 13, // equal =
/* 0x3E */ INV_KEY, /* 0x3E */ INV_KEY,
/* 0x3F */ INV_KEY, /* 0x3F */ INV_KEY,
/* 0x40 */ INV_KEY, /* 0x40 */ INV_KEY,
@ -326,7 +327,7 @@ const int16_t keyboardAsciiConv[] = // QWERTY Keyboard
/* 0x5E */ INV_KEY, /* 0x5E */ INV_KEY,
/* 0x5F */ INV_KEY, /* 0x5F */ INV_KEY,
/* 0x60 */ INV_KEY, /* 0x60 */ INV_KEY,
/* 0x61 */ 0x1E, //0x10, // A /* 0x61 */ 0x1E, // A
/* 0x62 */ 0x30, // B /* 0x62 */ 0x30, // B
/* 0x63 */ 0x2E, // C /* 0x63 */ 0x2E, // C
/* 0x64 */ 0x20, // D /* 0x64 */ 0x20, // D
@ -338,20 +339,20 @@ const int16_t keyboardAsciiConv[] = // QWERTY Keyboard
/* 0x6A */ 0x24, // J /* 0x6A */ 0x24, // J
/* 0x6B */ 0x25, // K /* 0x6B */ 0x25, // K
/* 0x6C */ 0x26, // L /* 0x6C */ 0x26, // L
/* 0x6D */ 0x32, //0x27, // M /* 0x6D */ 0x32, // M
/* 0x6E */ 0x31, // N /* 0x6E */ 0x31, // N
/* 0x6F */ 0x18, // O /* 0x6F */ 0x18, // O
/* 0x70 */ 0x19, // P /* 0x70 */ 0x19, // P
/* 0x71 */ 0x10, //0x1E, // Q /* 0x71 */ 0x10, // Q
/* 0x72 */ 0x13, // R /* 0x72 */ 0x13, // R
/* 0x73 */ 0x1F, // S /* 0x73 */ 0x1F, // S
/* 0x74 */ 0x14, // T /* 0x74 */ 0x14, // T
/* 0x75 */ 0x16, // U /* 0x75 */ 0x16, // U
/* 0x76 */ 0x2F, // V /* 0x76 */ 0x2F, // V
/* 0x77 */ 0x11, //0x2C, // W /* 0x77 */ 0x11, // W
/* 0x78 */ 0x2D, // X /* 0x78 */ 0x2D, // X
/* 0x79 */ 0x2C, //0x15, // Y /* 0x79 */ 0x15, // Y
/* 0x7A */ 0x15, //0x2C, //0x11, // Z /* 0x7A */ 0x2C, // Z
/* 0x7B */ INV_KEY, /* 0x7B */ INV_KEY,
/* 0x7C */ INV_KEY, /* 0x7C */ INV_KEY,
/* 0x7D */ INV_KEY, /* 0x7D */ INV_KEY,
@ -396,7 +397,10 @@ const int16_t keyboardSpecialConv[] = // Functions and other keys
/* 0xDF */ INV_KEY /* 0xDF */ INV_KEY
}; };
void emu_KeyboardOnDown(int keymodifer, int key) { void emu_KeyboardOnDown(int keymodifer, int key) {
//emu_printi(key);
int keyCode = INV_KEY; int keyCode = INV_KEY;
if ((key >=0xc0) && (key <=0xdf)) { if ((key >=0xc0) && (key <=0xdf)) {
keyCode = keyboardSpecialConv[(key-0xc0) & 0x1f]; keyCode = keyboardSpecialConv[(key-0xc0) & 0x1f];
@ -404,6 +408,8 @@ void emu_KeyboardOnDown(int keymodifer, int key) {
else { else {
keyCode = keyboardAsciiConv[key & 0x7f]; keyCode = keyboardAsciiConv[key & 0x7f];
} }
//emu_printi(keyCode);
IkbdKeyPress ( keyCode ); IkbdKeyPress ( keyCode );
} }
@ -414,8 +420,8 @@ void emu_KeyboardOnUp(int keymodifer, int key) {
} }
else { else {
keyCode = keyboardAsciiConv[key & 0x7f]; keyCode = keyboardAsciiConv[key & 0x7f];
} }
IkbdKeyRelease ( keyCode | 0x80 ); IkbdKeyRelease ( keyCode );
} }
@ -428,19 +434,18 @@ static void do_events(void)
{ {
int bClick = k & ~prev_k; int bClick = k & ~prev_k;
prev_k = k; prev_k = k;
int mouseb=0; int mouseb1 = prev_mouseb1;
int mouseb2 = prev_mouseb2;
// Toggle mouse/joystick // Toggle keymap + mouse/joystick
if (bClick & MASK_KEY_USER1) { if (bClick & MASK_KEY_USER2) {
if (isMouse) isMouse = false; if (isMouse) isMouse = false;
else isMouse = true; else isMouse = true;
}
// Toggle keymap
if (bClick & MASK_KEY_USER2) {
#ifndef HAS_T4_VGA #ifndef HAS_T4_VGA
emu_setKeymap(0); emu_setKeymap(0);
#endif #endif
} }
// force joystick mode if mouse detected // force joystick mode if mouse detected
if (emu_MouseDetected() ) isMouse = false; if (emu_MouseDetected() ) isMouse = false;
@ -482,10 +487,21 @@ static void do_events(void)
else if ( mouse_y < 0 ) { else if ( mouse_y < 0 ) {
mouse_y = 0; mouse_y = 0;
} }
if (buts & 0x1) mouseb=1;;
if (buts & 0x1) {
mouseb1 |=1;
}
else {
mouseb1 &=~1;
}
if (buts & 0x2) {
mouseb2 |=1;
}
else {
mouseb2 &=~1;
}
} }
if (!isMouse) if (!isMouse)
{ {
int j = 0; int j = 0;
@ -544,8 +560,17 @@ static void do_events(void)
} }
if (( k & MASK_JOY1_BTN) || ( k & MASK_JOY2_BTN)) { if (( k & MASK_JOY1_BTN) || ( k & MASK_JOY2_BTN)) {
mouseb=1; mouseb1 |= 1;
} }
else {
mouseb1 &=~1;
}
if (( k & MASK_KEY_USER1)) {
mouseb2 |= 1;
}
else {
mouseb2 &=~1;
}
} }
if ( (prev_mouse_x != mouse_x) | (prev_mouse_y != mouse_y) ) { if ( (prev_mouse_x != mouse_x) | (prev_mouse_y != mouse_y) ) {
@ -554,11 +579,31 @@ static void do_events(void)
prev_mouse_x = mouse_x; prev_mouse_x = mouse_x;
prev_mouse_y = mouse_y; prev_mouse_y = mouse_y;
} }
if ( (mouseb != prev_mouseb) ){
if (mouseb) IkbdMousePress(2);
else IkbdMouseRelease(2); if ( (mouseb1 != prev_mouseb1) ){
if (mouseb1) {
IkbdMousePress(2);
//emu_printf("b1p");
}
else {
IkbdMouseRelease(2);
//emu_printf("b1r");
}
IkbdLoop(); IkbdLoop();
prev_mouseb = mouseb; prev_mouseb1 = mouseb1;
}
if ( (mouseb2 != prev_mouseb2) ){
if (mouseb2) {
IkbdMousePress(1);
//emu_printf("b2p");
}
else {
IkbdMouseRelease(1);
//emu_printf("b2r");
}
IkbdLoop();
prev_mouseb2 = mouseb2;
} }
} }
@ -881,12 +926,12 @@ void ast_Step(void)
{ {
#ifdef DOUBLE_BUFFERING #ifdef DOUBLE_BUFFERING
if (vid_shiftmode==MONO) { if (vid_shiftmode==MONO) {
emu_DrawWaitLine(325); emu_DrawWaitLine(400);
} }
else if (vid_shiftmode==COL2) { else if (vid_shiftmode==COL2) {
emu_DrawWaitLine(360); emu_DrawWaitLine(400);
} else { } else {
emu_DrawWaitLine(360); emu_DrawWaitLine(400);
} }
renderScreen(); renderScreen();
#else #else
@ -969,34 +1014,40 @@ int disk_Size(char * filename) {
return emu_FileSize(filename); return emu_FileSize(filename);
} }
int disk_Open(char * filename) { int disk_Open(char * filename, int disk) {
//emu_printf("disk reset pt"); //emu_printf("disk open");
return emu_FileOpen(filename); //emu_printi(disk);
return emu_FileOpenBis(filename, disk+1);
} }
int disk_Read(char * buf, int size) { int disk_Read(char * buf, int size, int disk) {
//emu_printf("disk read"); //emu_printf("disk read");
//emu_printi(size); //emu_printi(size);
return emu_FileRead(buf, size); //emu_printi(disk);
return emu_FileReadBis(buf, size, disk);
} }
int disk_Seek(int seek) { int disk_Seek(int seek, int disk) {
//emu_printf("disk seek"); //emu_printf("disk seek");
//emu_printi(seek); //emu_printi(seek);
return emu_FileSeek(seek); //emu_printi(disk);
return emu_FileSeekBis(seek, disk);
} }
void ast_Start(char * filename, 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, filename, sizeof(disk[0].name)); strncpy (disk[0].name, floppy1, sizeof(disk[0].name));
strncpy (disk[1].name, floppy2, sizeof(disk[1].name));
initialize_memmap(); initialize_memmap();
FDCInit(0); FDCInit(0);
FDCInit(1);
//FDCeject(0); //FDCeject(0);
FDCeject(1); //FDCeject(1);
IkbdReset(); IkbdReset();
IOInit(); IOInit();
#ifdef HAS_SND #ifdef HAS_SND

View file

@ -1,4 +1,4 @@
extern void ast_Init(void); extern void ast_Init(void);
extern void ast_Step(void); extern void ast_Step(void);
extern void ast_Start(char * filename, int mode); extern void ast_Start(char * floppy1, char * floppy2, int mode);
extern void ast_Input(int click); extern void ast_Input(int click);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -39,4 +39,3 @@ typedef ULONG uaecptr;
#define HAS_FILESYS 1 #define HAS_FILESYS 1
#endif /* _DTYPES_H_ */ #endif /* _DTYPES_H_ */

View file

@ -34,7 +34,7 @@ static const uint16_t * logo = deflogo;
#ifdef HAS_USBKEY #ifdef HAS_USBKEY
#include "USBHost_t36.h" // Read this header first for key info #include "USBHost_t36.h" // Read this header first for key info
USBHost myusb; USBHost myusb;
//USBHub hub1(myusb); USBHub hub1(myusb);
KeyboardController keyboard1(myusb); KeyboardController keyboard1(myusb);
USBHIDParser hid1(myusb); USBHIDParser hid1(myusb);
MouseController mouse1(myusb); MouseController mouse1(myusb);
@ -134,6 +134,7 @@ static int nbFiles=0;
static int curFile=0; static int curFile=0;
static int topFile=0; static int topFile=0;
static char selection[MAX_FILENAME_SIZE+1]=""; static char selection[MAX_FILENAME_SIZE+1]="";
static char shown_selection[MAX_FILENAME_SIZE+1]="";
static char files[MAX_FILES][MAX_FILENAME_SIZE]; static char files[MAX_FILES][MAX_FILENAME_SIZE];
static bool menuRedraw=true; static bool menuRedraw=true;
@ -424,6 +425,8 @@ int emu_ReadKeys(void)
if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT; if (usbnavpad & MASK_JOY2_LEFT) retval |= MASK_JOY2_LEFT;
if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT; if (usbnavpad & MASK_JOY2_RIGHT) retval |= MASK_JOY2_RIGHT;
if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN; if (usbnavpad & MASK_JOY2_BTN) retval |= MASK_JOY2_BTN;
if (usbnavpad & MASK_KEY_USER1) retval |= MASK_KEY_USER1;
if (usbnavpad & MASK_KEY_USER2) retval |= MASK_KEY_USER2;
#ifdef PIN_KEY_USER1 #ifdef PIN_KEY_USER1
if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1; if ( digitalRead(PIN_KEY_USER1) == LOW ) retval |= MASK_KEY_USER1;
@ -812,14 +815,20 @@ int handleMenu(uint16_t bClick)
nbFiles = readNbFiles(); nbFiles = readNbFiles();
} }
else { else {
action = ACTION_RUNTFT; action = ACTION_RUN1;
} }
menuRedraw=true; menuRedraw=true;
} }
else if ( (bClick & MASK_KEY_USER1) || (c == MKEY_VGA) ) { else if ( (bClick & MASK_KEY_USER1) || (c == MKEY_VGA) ) {
menuRedraw=true; menuRedraw=true;
action = ACTION_RUNVGA; strcpy(shown_selection,selection);
action = ACTION_RUN2;
} }
else if ( (bClick & MASK_KEY_USER2) || (c == MKEY_JOY) ) {
menuRedraw=true;
action = ACTION_RUN3;
//emu_SwapJoysticks(0);
}
else if ( (c >= MKEY_L1) && (c <= MKEY_L9) ) { else if ( (c >= MKEY_L1) && (c <= MKEY_L9) ) {
if ( (topFile+(int)c-1) <= (nbFiles-1) ) if ( (topFile+(int)c-1) <= (nbFiles-1) )
{ {
@ -858,11 +867,7 @@ int handleMenu(uint16_t bClick)
curFile++; curFile++;
menuRedraw=true; menuRedraw=true;
} }
} }
else if ( (bClick & MASK_KEY_USER2) || (c == MKEY_JOY) ) {
emu_SwapJoysticks(0);
menuRedraw=true;
}
if (menuRedraw && nbFiles) { if (menuRedraw && nbFiles) {
int fileIndex = 0; int fileIndex = 0;
@ -902,7 +907,10 @@ int handleMenu(uint16_t bClick)
#ifndef HAS_T4_VGA #ifndef HAS_T4_VGA
tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy); tft.drawSpriteNoDma(0,MENU_JOYS_YOFFSET,(uint16_t*)bmpjoy);
#endif #endif
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false); // tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, (emu_SwapJoysticks(1)?(char*)"SWAP=1":(char*)"SWAP=0"), RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
tft.drawTextNoDma(48,MENU_JOYS_YOFFSET+8, "FLOPPY2:", RGBVAL16(0x00,0xff,0xff), RGBVAL16(0x00,0x00,0xff), false);
tft.drawRectNoDma(120,MENU_JOYS_YOFFSET+8, MENU_FILE_W, 8, RGBVAL16(0x00,0x00,0x00));
tft.drawTextNoDma(120,MENU_JOYS_YOFFSET+8, shown_selection, RGBVAL16(0xff,0xff,0xff), RGBVAL16(0x00,0x00,0x00), false);
menuRedraw=false; menuRedraw=false;
} }
@ -1000,6 +1008,12 @@ void OnPress(auto key)
case 10: case 10:
usbnavpad |= MASK_JOY2_BTN; usbnavpad |= MASK_JOY2_BTN;
break; break;
case 32:
usbnavpad |= MASK_KEY_USER1;
break;
case 9:
usbnavpad |= MASK_KEY_USER2;
break;
} }
} }
else else
@ -1061,6 +1075,12 @@ void OnRelease(int key)
case 10: case 10:
usbnavpad &= ~MASK_JOY2_BTN; usbnavpad &= ~MASK_JOY2_BTN;
break; break;
case 32:
usbnavpad &= ~MASK_KEY_USER1;
break;
case 9:
usbnavpad &= ~MASK_KEY_USER2;
break;
} }
} }
else else

View file

@ -29,8 +29,9 @@
#define ACTION_NONE 0 #define ACTION_NONE 0
#define ACTION_MAXKBDVAL 16 #define ACTION_MAXKBDVAL 16
#define ACTION_EXITKBD 128 #define ACTION_EXITKBD 128
#define ACTION_RUNTFT 129 #define ACTION_RUN1 129
#define ACTION_RUNVGA 130 #define ACTION_RUN2 130
#define ACTION_RUN3 131
#ifdef KEYMAP_PRESENT #ifdef KEYMAP_PRESENT

View file

@ -228,7 +228,7 @@ void loop(void)
uint16_t bClick = emu_DebounceLocalKeys(); uint16_t bClick = emu_DebounceLocalKeys();
int action = handleMenu(bClick); int action = handleMenu(bClick);
char * floppy1 = menuSelection(); char * floppy1 = menuSelection();
if (action == ACTION_RUNTFT) { if (action == ACTION_RUN1) {
toggleMenu(false); toggleMenu(false);
vgaMode = false; vgaMode = false;
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) ); tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
@ -237,25 +237,8 @@ void loop(void)
tft.startDMA(); tft.startDMA();
emu_Init2(); emu_Init2();
} }
else if (action == ACTION_RUNVGA) { else if (action == ACTION_RUN2) {
strcpy(floppy2,menuSelection()); strcpy(floppy2,menuSelection());
#ifdef HAS_VGA
toggleMenu(false);
vgaMode = true;
VGA_frame_buffer = (uint8_t *)malloc((UVGA_YRES*(UVGA_XRES+UVGA_XRES_EXTRA))*sizeof(uint8_t));
uvga.set_static_framebuffer(VGA_frame_buffer);
emu_start();
emu_Init(filename);
int retvga = uvga.begin(&modeline);
Serial.println(retvga);
Serial.print("VGA init: ");
Serial.println(retvga);
uvga.clear(0x00);
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
// In VGA mode, we show the keyboard on TFT
toggleVirtualkeyboard(true); // keepOn
Serial.println("Starting");
#endif
} }
delay(20); delay(20);
} }

View file

@ -293,8 +293,8 @@ const int i2ckeyConv[] =
void uae_Input(int bClick) { void uae_Input(int bClick) {
buttonstate[0] = 0; // buttonstate[0] = 0;
buttonstate[2] = 0; // buttonstate[2] = 0;
hk = emu_ReadI2CKeyboard(); hk = emu_ReadI2CKeyboard();
k = emu_ReadKeys(); k = emu_ReadKeys();
@ -328,8 +328,18 @@ void uae_Input(int bClick) {
else if ( lastmy < 0 ) { else if ( lastmy < 0 ) {
lastmy = 0; lastmy = 0;
} }
if (buts & 0x1) buttonstate[0] = 1; if (buts & 0x1) {
if (buts & 0x2) buttonstate[2] = 1; buttonstate[0] |=1;
}
else {
buttonstate[0] &=~1;
}
if (buts & 0x2) {
buttonstate[2] |=1;
}
else {
buttonstate[2] &=~1;
}
} }
// Diskswap in joystick mode // Diskswap in joystick mode
@ -377,9 +387,18 @@ void uae_Input(int bClick) {
newmousecounters = 1; newmousecounters = 1;
} }
} }
if (( k & MASK_JOY1_BTN) || ( k & MASK_JOY2_BTN)) {
if ( (k & MASK_JOY1_BTN)|| ( k & MASK_JOY2_BTN)) buttonstate[0] = 1; buttonstate[0] |= 1;
if (k & MASK_KEY_USER1) buttonstate[2] = 1; }
else {
buttonstate[0] &=~1;
}
if (( k & MASK_KEY_USER1)) {
buttonstate[2] |= 1;
}
else {
buttonstate[2] &=~1;
}
} }
} }