diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_pico64.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_pico64.uf2 index 83e730f..f7c143b 100644 Binary files a/MCUME_pico/bin/PICOMPUTER/mcume_pico64.uf2 and b/MCUME_pico/bin/PICOMPUTER/mcume_pico64.uf2 differ diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_pico800.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_pico800.uf2 index 3bd9995..1344231 100644 Binary files a/MCUME_pico/bin/PICOMPUTER/mcume_pico800.uf2 and b/MCUME_pico/bin/PICOMPUTER/mcume_pico800.uf2 differ diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_pico81.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_pico81.uf2 index 3613fc4..e20ca47 100644 Binary files a/MCUME_pico/bin/PICOMPUTER/mcume_pico81.uf2 and b/MCUME_pico/bin/PICOMPUTER/mcume_pico81.uf2 differ diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_picocolem.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_picocolem.uf2 index 1df23d2..5a2c50b 100644 Binary files a/MCUME_pico/bin/PICOMPUTER/mcume_picocolem.uf2 and b/MCUME_pico/bin/PICOMPUTER/mcume_picocolem.uf2 differ diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_picoo2em.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_picoo2em.uf2 index 15f5c5b..f2f2dcf 100644 Binary files a/MCUME_pico/bin/PICOMPUTER/mcume_picoo2em.uf2 and b/MCUME_pico/bin/PICOMPUTER/mcume_picoo2em.uf2 differ diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_picospeccy.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_picospeccy.uf2 index e99101d..4e730db 100644 Binary files a/MCUME_pico/bin/PICOMPUTER/mcume_picospeccy.uf2 and b/MCUME_pico/bin/PICOMPUTER/mcume_picospeccy.uf2 differ diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_picovcs.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_picovcs.uf2 index 1204956..fd46e65 100644 Binary files a/MCUME_pico/bin/PICOMPUTER/mcume_picovcs.uf2 and b/MCUME_pico/bin/PICOMPUTER/mcume_picovcs.uf2 differ diff --git a/MCUME_pico/pico5200/emuapi.cpp b/MCUME_pico/pico5200/emuapi.cpp index 62bc59e..a9122c4 100644 --- a/MCUME_pico/pico5200/emuapi.cpp +++ b/MCUME_pico/pico5200/emuapi.cpp @@ -49,13 +49,13 @@ static char selection[MAX_FILENAME_SIZE+1]=""; static char files[MAX_FILES][MAX_FILENAME_SIZE]; static bool menuRedraw=true; -static int keyMap; #ifdef PICOMPUTER -static unsigned short * keys; +static const unsigned short * keys; static unsigned char keymatrix[6]; static int keymatrix_hitrow=-1; static bool key_fn=false; #endif +static int keyMap; static bool joySwapped = false; static uint16_t bLastState; @@ -67,7 +67,9 @@ static bool menuOn=true; - +/******************************** + * Generic output and malloc +********************************/ void emu_printf(char * text) { printf("%s\n",text); @@ -137,8 +139,9 @@ void emu_Free(void * pt) - - +/******************************** + * Input and keyboard +********************************/ int emu_ReadAnalogJoyX(int min, int max) { adc_select_input(0); @@ -319,7 +322,7 @@ int emu_ReadKeys(void) key_fn = false; } - if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN; + if ( row & 0x10) retval |= MASK_JOY2_BTN; if ( key_fn ) retval |= MASK_KEY_USER2; if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1; #endif @@ -347,19 +350,18 @@ int emu_ReadI2CKeyboard(void) { int retval=0; #ifdef PICOMPUTER if (key_fn) { - keys = (unsigned short *)key_map2; + keys = (const unsigned short *)key_map2; } else { - keys = (unsigned short *)key_map1; + keys = (const unsigned short *)key_map1; } if (keymatrix_hitrow >=0 ) { unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow]; if ( (match == 0x002 ) ) return 0; // shift or fn if (match < 0x100 ) match = match & ~0x002; // ignore shift key - for (int i=0; i= filesize) { - int retval=0; + unsigned int retval=0; if( (f_read (&file, buf, filesize, &retval)) ) { emu_printf("File read failed"); } } f_close(&file); } -#else - if ((file = SD.open(filepath, O_READ))) - { - filesize = file.size(); - emu_printf(filesize); - - if (size >= filesize) - { - if (emu_FileRead(buf, filesize) != filesize) - { - emu_printf("File read failed"); - } - } - file.close(); - } -#endif - + return(filesize); } -int emu_LoadFileSeek(char * filename, char * buf, int size, int seek) -{ - int filesize = 0; - - char filepath[80]; - strcpy(filepath, romspath); - strcat(filepath, "/"); - strcat(filepath, filename); - emu_printf("LoadFileSeek..."); - emu_printf(filepath); -#ifdef USE_SDFS - if( !(f_open(&file, filepath, FA_READ)) ) { - f_lseek(&file, seek); - emu_printf(size); - if (size >= filesize) - { - int retval=0; - if( (!f_read (&file, buf, size, &retval)) ) - if (retval != size) - { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - file.seek(seek); - emu_printf(size); - if (file.read(buf, size) != size) { - emu_printf("File read failed"); - } - file.close(); - } -#endif - - return(filesize); -} -#endif +/******************************** + * Initialization +********************************/ void emu_init(void) { sd_init_driver(); @@ -905,6 +842,6 @@ void emu_init(void) void emu_start(void) { usbnavpad = 0; - + keyMap = 0; } diff --git a/MCUME_pico/pico64/emuapi.cpp b/MCUME_pico/pico64/emuapi.cpp index a2e039a..a9122c4 100644 --- a/MCUME_pico/pico64/emuapi.cpp +++ b/MCUME_pico/pico64/emuapi.cpp @@ -49,13 +49,13 @@ static char selection[MAX_FILENAME_SIZE+1]=""; static char files[MAX_FILES][MAX_FILENAME_SIZE]; static bool menuRedraw=true; -static int keyMap; #ifdef PICOMPUTER -static unsigned short * keys; +static const unsigned short * keys; static unsigned char keymatrix[6]; static int keymatrix_hitrow=-1; static bool key_fn=false; #endif +static int keyMap; static bool joySwapped = false; static uint16_t bLastState; @@ -67,7 +67,9 @@ static bool menuOn=true; - +/******************************** + * Generic output and malloc +********************************/ void emu_printf(char * text) { printf("%s\n",text); @@ -137,6 +139,9 @@ void emu_Free(void * pt) +/******************************** + * Input and keyboard +********************************/ int emu_ReadAnalogJoyX(int min, int max) { adc_select_input(0); @@ -317,7 +322,7 @@ int emu_ReadKeys(void) key_fn = false; } - if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN; + if ( row & 0x10) retval |= MASK_JOY2_BTN; if ( key_fn ) retval |= MASK_KEY_USER2; if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1; #endif @@ -345,19 +350,18 @@ int emu_ReadI2CKeyboard(void) { int retval=0; #ifdef PICOMPUTER if (key_fn) { - keys = (unsigned short *)key_map2; + keys = (const unsigned short *)key_map2; } else { - keys = (unsigned short *)key_map1; + keys = (const unsigned short *)key_map1; } if (keymatrix_hitrow >=0 ) { unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow]; if ( (match == 0x002 ) ) return 0; // shift or fn if (match < 0x100 ) match = match & ~0x002; // ignore shift key - for (int i=0; i= filesize) { - int retval=0; + unsigned int retval=0; if( (f_read (&file, buf, filesize, &retval)) ) { emu_printf("File read failed"); } } f_close(&file); } -#else - if ((file = SD.open(filepath, O_READ))) - { - filesize = file.size(); - emu_printf(filesize); - - if (size >= filesize) - { - if (emu_FileRead(buf, filesize) != filesize) - { - emu_printf("File read failed"); - } - } - file.close(); - } -#endif - + return(filesize); } -int emu_LoadFileSeek(char * filename, char * buf, int size, int seek) -{ - int filesize = 0; - - char filepath[80]; - strcpy(filepath, romspath); - strcat(filepath, "/"); - strcat(filepath, filename); - emu_printf("LoadFileSeek..."); - emu_printf(filepath); -#ifdef USE_SDFS - if( !(f_open(&file, filepath, FA_READ)) ) { - f_lseek(&file, seek); - emu_printf(size); - if (size >= filesize) - { - int retval=0; - if( (!f_read (&file, buf, size, &retval)) ) - if (retval != size) - { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - file.seek(seek); - emu_printf(size); - if (file.read(buf, size) != size) { - emu_printf("File read failed"); - } - file.close(); - } -#endif - - return(filesize); -} -#endif +/******************************** + * Initialization +********************************/ void emu_init(void) { sd_init_driver(); @@ -907,6 +842,6 @@ void emu_init(void) void emu_start(void) { usbnavpad = 0; - + keyMap = 0; } diff --git a/MCUME_pico/pico800/emuapi.cpp b/MCUME_pico/pico800/emuapi.cpp index c3c8d13..a9122c4 100644 --- a/MCUME_pico/pico800/emuapi.cpp +++ b/MCUME_pico/pico800/emuapi.cpp @@ -49,14 +49,14 @@ static char selection[MAX_FILENAME_SIZE+1]=""; static char files[MAX_FILES][MAX_FILENAME_SIZE]; static bool menuRedraw=true; -static int keyMap; #ifdef PICOMPUTER -static unsigned short * keys; +static const unsigned short * keys; static unsigned char keymatrix[6]; static int keymatrix_hitrow=-1; static bool key_fn=false; #endif - +static int keyMap; + static bool joySwapped = false; static uint16_t bLastState; static int xRef; @@ -67,7 +67,9 @@ static bool menuOn=true; - +/******************************** + * Generic output and malloc +********************************/ void emu_printf(char * text) { printf("%s\n",text); @@ -137,6 +139,9 @@ void emu_Free(void * pt) +/******************************** + * Input and keyboard +********************************/ int emu_ReadAnalogJoyX(int min, int max) { adc_select_input(0); @@ -317,7 +322,7 @@ int emu_ReadKeys(void) key_fn = false; } - if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN; + if ( row & 0x10) retval |= MASK_JOY2_BTN; if ( key_fn ) retval |= MASK_KEY_USER2; if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1; #endif @@ -345,19 +350,18 @@ int emu_ReadI2CKeyboard(void) { int retval=0; #ifdef PICOMPUTER if (key_fn) { - keys = (unsigned short *)key_map2; + keys = (const unsigned short *)key_map2; } else { - keys = (unsigned short *)key_map1; + keys = (const unsigned short *)key_map1; } if (keymatrix_hitrow >=0 ) { unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow]; if ( (match == 0x002 ) ) return 0; // shift or fn if (match < 0x100 ) match = match & ~0x002; // ignore shift key - for (int i=0; i= filesize) { - int retval=0; + unsigned int retval=0; if( (f_read (&file, buf, filesize, &retval)) ) { emu_printf("File read failed"); } } f_close(&file); } -#else - if ((file = SD.open(filepath, O_READ))) - { - filesize = file.size(); - emu_printf(filesize); - - if (size >= filesize) - { - if (emu_FileRead(buf, filesize) != filesize) - { - emu_printf("File read failed"); - } - } - file.close(); - } -#endif - + return(filesize); } -int emu_LoadFileSeek(char * filename, char * buf, int size, int seek) -{ - int filesize = 0; - - char filepath[80]; - strcpy(filepath, romspath); - strcat(filepath, "/"); - strcat(filepath, filename); - emu_printf("LoadFileSeek..."); - emu_printf(filepath); -#ifdef USE_SDFS - if( !(f_open(&file, filepath, FA_READ)) ) { - f_lseek(&file, seek); - emu_printf(size); - if (size >= filesize) - { - int retval=0; - if( (!f_read (&file, buf, size, &retval)) ) - if (retval != size) - { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - file.seek(seek); - emu_printf(size); - if (file.read(buf, size) != size) { - emu_printf("File read failed"); - } - file.close(); - } -#endif - - return(filesize); -} -#endif +/******************************** + * Initialization +********************************/ void emu_init(void) { sd_init_driver(); @@ -905,6 +842,6 @@ void emu_init(void) void emu_start(void) { usbnavpad = 0; - + keyMap = 0; } diff --git a/MCUME_pico/pico81/emuapi.cpp b/MCUME_pico/pico81/emuapi.cpp index 453a265..a9122c4 100644 --- a/MCUME_pico/pico81/emuapi.cpp +++ b/MCUME_pico/pico81/emuapi.cpp @@ -49,14 +49,14 @@ static char selection[MAX_FILENAME_SIZE+1]=""; static char files[MAX_FILES][MAX_FILENAME_SIZE]; static bool menuRedraw=true; -static int keyMap; #ifdef PICOMPUTER -static unsigned short * keys; +static const unsigned short * keys; static unsigned char keymatrix[6]; static int keymatrix_hitrow=-1; static bool key_fn=false; #endif - +static int keyMap; + static bool joySwapped = false; static uint16_t bLastState; static int xRef; @@ -67,7 +67,9 @@ static bool menuOn=true; - +/******************************** + * Generic output and malloc +********************************/ void emu_printf(char * text) { printf("%s\n",text); @@ -136,6 +138,10 @@ void emu_Free(void * pt) } + +/******************************** + * Input and keyboard +********************************/ int emu_ReadAnalogJoyX(int min, int max) { adc_select_input(0); @@ -316,7 +322,7 @@ int emu_ReadKeys(void) key_fn = false; } - if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN; + if ( row & 0x10) retval |= MASK_JOY2_BTN; if ( key_fn ) retval |= MASK_KEY_USER2; if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1; #endif @@ -344,19 +350,18 @@ int emu_ReadI2CKeyboard(void) { int retval=0; #ifdef PICOMPUTER if (key_fn) { - keys = (unsigned short *)key_map2; + keys = (const unsigned short *)key_map2; } else { - keys = (unsigned short *)key_map1; + keys = (const unsigned short *)key_map1; } if (keymatrix_hitrow >=0 ) { unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow]; if ( (match == 0x002 ) ) return 0; // shift or fn if (match < 0x100 ) match = match & ~0x002; // ignore shift key - for (int i=0; i= filesize) { - int retval=0; + unsigned int retval=0; if( (f_read (&file, buf, filesize, &retval)) ) { emu_printf("File read failed"); } } f_close(&file); } -#else - if ((file = SD.open(filepath, O_READ))) - { - filesize = file.size(); - emu_printf(filesize); - - if (size >= filesize) - { - if (emu_FileRead(buf, filesize) != filesize) - { - emu_printf("File read failed"); - } - } - file.close(); - } -#endif - + return(filesize); } -int emu_LoadFileSeek(char * filename, char * buf, int size, int seek) -{ - int filesize = 0; - - char filepath[80]; - strcpy(filepath, romspath); - strcat(filepath, "/"); - strcat(filepath, filename); - emu_printf("LoadFileSeek..."); - emu_printf(filepath); -#ifdef USE_SDFS - if( !(f_open(&file, filepath, FA_READ)) ) { - f_lseek(&file, seek); - emu_printf(size); - if (size >= filesize) - { - int retval=0; - if( (!f_read (&file, buf, size, &retval)) ) - if (retval != size) - { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - file.seek(seek); - emu_printf(size); - if (file.read(buf, size) != size) { - emu_printf("File read failed"); - } - file.close(); - } -#endif - - return(filesize); -} -#endif +/******************************** + * Initialization +********************************/ void emu_init(void) { sd_init_driver(); diff --git a/MCUME_pico/picocolem/emuapi.cpp b/MCUME_pico/picocolem/emuapi.cpp index 72048f1..a9122c4 100644 --- a/MCUME_pico/picocolem/emuapi.cpp +++ b/MCUME_pico/picocolem/emuapi.cpp @@ -50,7 +50,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE]; static bool menuRedraw=true; #ifdef PICOMPUTER -static unsigned short * keys; +static const unsigned short * keys; static unsigned char keymatrix[6]; static int keymatrix_hitrow=-1; static bool key_fn=false; @@ -67,7 +67,9 @@ static bool menuOn=true; - +/******************************** + * Generic output and malloc +********************************/ void emu_printf(char * text) { printf("%s\n",text); @@ -137,6 +139,9 @@ void emu_Free(void * pt) +/******************************** + * Input and keyboard +********************************/ int emu_ReadAnalogJoyX(int min, int max) { adc_select_input(0); @@ -317,7 +322,7 @@ int emu_ReadKeys(void) key_fn = false; } - if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN; + if ( row & 0x10) retval |= MASK_JOY2_BTN; if ( key_fn ) retval |= MASK_KEY_USER2; if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1; #endif @@ -345,19 +350,18 @@ int emu_ReadI2CKeyboard(void) { int retval=0; #ifdef PICOMPUTER if (key_fn) { - keys = (unsigned short *)key_map2; + keys = (const unsigned short *)key_map2; } else { - keys = (unsigned short *)key_map1; + keys = (const unsigned short *)key_map1; } if (keymatrix_hitrow >=0 ) { unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow]; if ( (match == 0x002 ) ) return 0; // shift or fn if (match < 0x100 ) match = match & ~0x002; // ignore shift key - for (int i=0; i= filesize) - { - int retval=0; - if( (f_read (&file, buf, filesize, &retval)) ) { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - filesize = file.size(); - emu_printf(filesize); - - if (size >= filesize) - { - if (emu_FileRead(buf, filesize) != filesize) - { - emu_printf("File read failed"); - } - } - file.close(); - } -#endif - - return(filesize); -} - -int emu_LoadFileSeek(char * filename, char * buf, int size, int seek) -{ - int filesize = 0; - - char filepath[80]; - strcpy(filepath, romspath); - strcat(filepath, "/"); - strcat(filepath, filename); - emu_printf("LoadFileSeek..."); - emu_printf(filepath); -#ifdef USE_SDFS - if( !(f_open(&file, filepath, FA_READ)) ) { - f_lseek(&file, seek); - emu_printf(size); - if (size >= filesize) - { - int retval=0; - if( (!f_read (&file, buf, size, &retval)) ) - if (retval != size) - { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - file.seek(seek); - emu_printf(size); - if (file.read(buf, size) != size) { - emu_printf("File read failed"); - } - file.close(); - } -#endif - - return(filesize); -} -#endif +/******************************** + * Initialization +********************************/ void emu_init(void) { sd_init_driver(); diff --git a/MCUME_pico/piconofrendo/emuapi.cpp b/MCUME_pico/piconofrendo/emuapi.cpp index f620519..a9122c4 100644 --- a/MCUME_pico/piconofrendo/emuapi.cpp +++ b/MCUME_pico/piconofrendo/emuapi.cpp @@ -19,10 +19,6 @@ extern "C" { #include "tft_t_dma.h" #endif -const uint16_t deflogo[] = { - 0,0 -}; -static const uint16_t * logo = deflogo; #define MAX_FILES 64 #define MAX_FILENAME_SIZE 24 @@ -53,13 +49,13 @@ static char selection[MAX_FILENAME_SIZE+1]=""; static char files[MAX_FILES][MAX_FILENAME_SIZE]; static bool menuRedraw=true; -static int keyMap; #ifdef PICOMPUTER -static unsigned short * keys; +static const unsigned short * keys; static unsigned char keymatrix[6]; static int keymatrix_hitrow=-1; static bool key_fn=false; #endif +static int keyMap; static bool joySwapped = false; static uint16_t bLastState; @@ -71,7 +67,9 @@ static bool menuOn=true; - +/******************************** + * Generic output and malloc +********************************/ void emu_printf(char * text) { printf("%s\n",text); @@ -141,6 +139,9 @@ void emu_Free(void * pt) +/******************************** + * Input and keyboard +********************************/ int emu_ReadAnalogJoyX(int min, int max) { adc_select_input(0); @@ -321,7 +322,7 @@ int emu_ReadKeys(void) key_fn = false; } - if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN; + if ( row & 0x10) retval |= MASK_JOY2_BTN; if ( key_fn ) retval |= MASK_KEY_USER2; if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1; #endif @@ -349,19 +350,18 @@ int emu_ReadI2CKeyboard(void) { int retval=0; #ifdef PICOMPUTER if (key_fn) { - keys = (unsigned short *)key_map2; + keys = (const unsigned short *)key_map2; } else { - keys = (unsigned short *)key_map1; + keys = (const unsigned short *)key_map1; } if (keymatrix_hitrow >=0 ) { unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow]; if ( (match == 0x002 ) ) return 0; // shift or fn if (match < 0x100 ) match = match & ~0x002; // ignore shift key - for (int i=0; i= filesize) - { - int retval=0; - if( (f_read (&file, buf, filesize, &retval)) ) { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - filesize = file.size(); - emu_printf(filesize); - - if (size >= filesize) - { - if (emu_FileRead(buf, filesize) != filesize) - { - emu_printf("File read failed"); - } - } - file.close(); - } -#endif - - return(filesize); -} - -int emu_LoadFileSeek(char * filename, char * buf, int size, int seek) -{ - int filesize = 0; - - char filepath[80]; - strcpy(filepath, romspath); - strcat(filepath, "/"); - strcat(filepath, filename); - emu_printf("LoadFileSeek..."); - emu_printf(filepath); -#ifdef USE_SDFS - if( !(f_open(&file, filepath, FA_READ)) ) { - f_lseek(&file, seek); - emu_printf(size); - if (size >= filesize) - { - int retval=0; - if( (!f_read (&file, buf, size, &retval)) ) - if (retval != size) - { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - file.seek(seek); - emu_printf(size); - if (file.read(buf, size) != size) { - emu_printf("File read failed"); - } - file.close(); - } -#endif - - return(filesize); -} -#endif +/******************************** + * Initialization +********************************/ void emu_init(void) { sd_init_driver(); @@ -932,7 +842,6 @@ void emu_init(void) void emu_start(void) { usbnavpad = 0; - - keys = (unsigned short *)key_map1; + keyMap = 0; } diff --git a/MCUME_pico/picoo2em/emuapi.cpp b/MCUME_pico/picoo2em/emuapi.cpp index e24292d..a9122c4 100644 --- a/MCUME_pico/picoo2em/emuapi.cpp +++ b/MCUME_pico/picoo2em/emuapi.cpp @@ -19,6 +19,7 @@ extern "C" { #include "tft_t_dma.h" #endif + #define MAX_FILES 64 #define MAX_FILENAME_SIZE 24 #define MAX_MENULINES 9 @@ -49,7 +50,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE]; static bool menuRedraw=true; #ifdef PICOMPUTER -static unsigned short * keys; +static const unsigned short * keys; static unsigned char keymatrix[6]; static int keymatrix_hitrow=-1; static bool key_fn=false; @@ -66,7 +67,9 @@ static bool menuOn=true; - +/******************************** + * Generic output and malloc +********************************/ void emu_printf(char * text) { printf("%s\n",text); @@ -135,6 +138,10 @@ void emu_Free(void * pt) } + +/******************************** + * Input and keyboard +********************************/ int emu_ReadAnalogJoyX(int min, int max) { adc_select_input(0); @@ -315,7 +322,7 @@ int emu_ReadKeys(void) key_fn = false; } - if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN; + if ( row & 0x10) retval |= MASK_JOY2_BTN; if ( key_fn ) retval |= MASK_KEY_USER2; if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1; #endif @@ -343,19 +350,18 @@ int emu_ReadI2CKeyboard(void) { int retval=0; #ifdef PICOMPUTER if (key_fn) { - keys = (unsigned short *)key_map2; + keys = (const unsigned short *)key_map2; } else { - keys = (unsigned short *)key_map1; + keys = (const unsigned short *)key_map1; } if (keymatrix_hitrow >=0 ) { unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow]; if ( (match == 0x002 ) ) return 0; // shift or fn if (match < 0x100 ) match = match & ~0x002; // ignore shift key - for (int i=0; i= filesize) - { - int retval=0; - if( (f_read (&file, buf, filesize, &retval)) ) { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - filesize = file.size(); - emu_printf(filesize); - - if (size >= filesize) - { - if (emu_FileRead(buf, filesize) != filesize) - { - emu_printf("File read failed"); - } - } - file.close(); - } -#endif - - return(filesize); -} - -int emu_LoadFileSeek(char * filename, char * buf, int size, int seek) -{ - int filesize = 0; - - char filepath[80]; - strcpy(filepath, romspath); - strcat(filepath, "/"); - strcat(filepath, filename); - emu_printf("LoadFileSeek..."); - emu_printf(filepath); -#ifdef USE_SDFS - if( !(f_open(&file, filepath, FA_READ)) ) { - f_lseek(&file, seek); - emu_printf(size); - if (size >= filesize) - { - int retval=0; - if( (!f_read (&file, buf, size, &retval)) ) - if (retval != size) - { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - file.seek(seek); - emu_printf(size); - if (file.read(buf, size) != size) { - emu_printf("File read failed"); - } - file.close(); - } -#endif - - return(filesize); -} -#endif +/******************************** + * Initialization +********************************/ void emu_init(void) { sd_init_driver(); diff --git a/MCUME_pico/picosnd/emuapi.cpp b/MCUME_pico/picosnd/emuapi.cpp index 0540680..a9122c4 100644 --- a/MCUME_pico/picosnd/emuapi.cpp +++ b/MCUME_pico/picosnd/emuapi.cpp @@ -50,14 +50,13 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE]; static bool menuRedraw=true; #ifdef PICOMPUTER -static unsigned short * keys; +static const unsigned short * keys; static unsigned char keymatrix[6]; static int keymatrix_hitrow=-1; static bool key_fn=false; #endif static int keyMap; - -static int keypadval=0; + static bool joySwapped = false; static uint16_t bLastState; static int xRef; @@ -68,7 +67,9 @@ static bool menuOn=true; - +/******************************** + * Generic output and malloc +********************************/ void emu_printf(char * text) { printf("%s\n",text); @@ -138,6 +139,9 @@ void emu_Free(void * pt) +/******************************** + * Input and keyboard +********************************/ int emu_ReadAnalogJoyX(int min, int max) { adc_select_input(0); @@ -203,7 +207,7 @@ int emu_SwapJoysticks(int statusOnly) { int emu_GetPad(void) { - return(keypadval/*|((joySwapped?1:0)<<7)*/); + return(bLastState/*|((joySwapped?1:0)<<7)*/); } int emu_ReadKeys(void) @@ -276,10 +280,9 @@ int emu_ReadKeys(void) unsigned char row; unsigned short cols[6]={1,2,3,4,5,14}; for (int i=0;i<6;i++){ - +// gpio_set_dir(cols[i], GPIO_OUT); gpio_put(cols[i], 0); - row=0; - + row=0; row |= (gpio_get(9) ? 0 : 0x01); row |= (gpio_get(9) ? 0 : 0x01); row |= (gpio_get(9) ? 0 : 0x01); @@ -289,20 +292,11 @@ int emu_ReadKeys(void) row |= (gpio_get(15) ? 0 : 0x08); row |= (gpio_get(7) ? 0 : 0x10); row |= (gpio_get(22) ? 0 : 0x20); - /* - if ( !gpio_get(9) ) row |= 0x01; - if ( !gpio_get(9) ) row |= 0x01; - if ( !gpio_get(9) ) row |= 0x01; - if ( !gpio_get(9) ) row |= 0x01; - if ( !gpio_get(8) ) row |= 0x02; - if ( !gpio_get(6) ) row |= 0x04; - if ( !gpio_get(15) ) row |= 0x08; - if ( !gpio_get(7) ) row |= 0x10; - if ( !gpio_get(22) ) row |= 0x20; - */ + gpio_put(cols[i], 1); +// gpio_set_dir(cols[i], GPIO_IN); + keymatrix[i]=row; if (row) keymatrix_hitrow=i; - gpio_put(cols[i], 1); } //6,9,15,8,7,22 @@ -320,8 +314,17 @@ int emu_ReadKeys(void) if ( row & 0x4 ) retval |= MASK_JOY2_DOWN; if ( row & 0x8 ) retval |= MASK_JOY2_UP; #endif - if ( row & 0x10 ) retval |= MASK_JOY2_BTN; - if ( row & 0x20 ) retval |= MASK_KEY_USER1; + + if ( keymatrix[0] & 0x02 ) { + key_fn = true; + } + else { + key_fn = false; + } + + if ( row & 0x10) retval |= MASK_JOY2_BTN; + if ( key_fn ) retval |= MASK_KEY_USER2; + if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1; #endif //Serial.println(retval,HEX); @@ -346,20 +349,18 @@ unsigned short emu_DebounceLocalKeys(void) int emu_ReadI2CKeyboard(void) { int retval=0; #ifdef PICOMPUTER - if ( keymatrix[0] & 0x02 ) { - key_fn = true; - } if (key_fn) { - keys = (unsigned short *)key_map2; + keys = (const unsigned short *)key_map2; } else { - keys = (unsigned short *)key_map1; + keys = (const unsigned short *)key_map1; } if (keymatrix_hitrow >=0 ) { unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow]; - for (int i=0; i= filesize) { - int retval=0; + unsigned int retval=0; if( (f_read (&file, buf, filesize, &retval)) ) { emu_printf("File read failed"); } } f_close(&file); } -#else - if ((file = SD.open(filepath, O_READ))) - { - filesize = file.size(); - emu_printf(filesize); - - if (size >= filesize) - { - if (emu_FileRead(buf, filesize) != filesize) - { - emu_printf("File read failed"); - } - } - file.close(); - } -#endif - + return(filesize); } -int emu_LoadFileSeek(char * filename, char * buf, int size, int seek) -{ - int filesize = 0; - - char filepath[80]; - strcpy(filepath, romspath); - strcat(filepath, "/"); - strcat(filepath, filename); - emu_printf("LoadFileSeek..."); - emu_printf(filepath); -#ifdef USE_SDFS - if( !(f_open(&file, filepath, FA_READ)) ) { - f_lseek(&file, seek); - emu_printf(size); - if (size >= filesize) - { - int retval=0; - if( (!f_read (&file, buf, size, &retval)) ) - if (retval != size) - { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - file.seek(seek); - emu_printf(size); - if (file.read(buf, size) != size) { - emu_printf("File read failed"); - } - file.close(); - } -#endif - - return(filesize); -} -#endif +/******************************** + * Initialization +********************************/ void emu_init(void) { sd_init_driver(); diff --git a/MCUME_pico/picospeccy/emuapi.cpp b/MCUME_pico/picospeccy/emuapi.cpp index f4840d7..a9122c4 100644 --- a/MCUME_pico/picospeccy/emuapi.cpp +++ b/MCUME_pico/picospeccy/emuapi.cpp @@ -49,14 +49,14 @@ static char selection[MAX_FILENAME_SIZE+1]=""; static char files[MAX_FILES][MAX_FILENAME_SIZE]; static bool menuRedraw=true; -static int keyMap; #ifdef PICOMPUTER -static unsigned short * keys; +static const unsigned short * keys; static unsigned char keymatrix[6]; static int keymatrix_hitrow=-1; static bool key_fn=false; #endif - +static int keyMap; + static bool joySwapped = false; static uint16_t bLastState; static int xRef; @@ -67,7 +67,9 @@ static bool menuOn=true; - +/******************************** + * Generic output and malloc +********************************/ void emu_printf(char * text) { printf("%s\n",text); @@ -137,6 +139,9 @@ void emu_Free(void * pt) +/******************************** + * Input and keyboard +********************************/ int emu_ReadAnalogJoyX(int min, int max) { adc_select_input(0); @@ -317,7 +322,7 @@ int emu_ReadKeys(void) key_fn = false; } - if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN; + if ( row & 0x10) retval |= MASK_JOY2_BTN; if ( key_fn ) retval |= MASK_KEY_USER2; if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1; #endif @@ -345,19 +350,18 @@ int emu_ReadI2CKeyboard(void) { int retval=0; #ifdef PICOMPUTER if (key_fn) { - keys = (unsigned short *)key_map2; + keys = (const unsigned short *)key_map2; } else { - keys = (unsigned short *)key_map1; + keys = (const unsigned short *)key_map1; } if (keymatrix_hitrow >=0 ) { unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow]; if ( (match == 0x002 ) ) return 0; // shift or fn if (match < 0x100 ) match = match & ~0x002; // ignore shift key - for (int i=0; i= filesize) - { - int retval=0; - if( (f_read (&file, buf, filesize, &retval)) ) { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - filesize = file.size(); - emu_printf(filesize); - - if (size >= filesize) - { - if (emu_FileRead(buf, filesize) != filesize) - { - emu_printf("File read failed"); - } - } - file.close(); - } -#endif - - return(filesize); -} - -int emu_LoadFileSeek(char * filename, char * buf, int size, int seek) -{ - int filesize = 0; - - char filepath[80]; - strcpy(filepath, romspath); - strcat(filepath, "/"); - strcat(filepath, filename); - emu_printf("LoadFileSeek..."); - emu_printf(filepath); -#ifdef USE_SDFS - if( !(f_open(&file, filepath, FA_READ)) ) { - f_lseek(&file, seek); - emu_printf(size); - if (size >= filesize) - { - int retval=0; - if( (!f_read (&file, buf, size, &retval)) ) - if (retval != size) - { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - file.seek(seek); - emu_printf(size); - if (file.read(buf, size) != size) { - emu_printf("File read failed"); - } - file.close(); - } -#endif - - return(filesize); -} -#endif +/******************************** + * Initialization +********************************/ void emu_init(void) { sd_init_driver(); diff --git a/MCUME_pico/picovcs/emuapi.cpp b/MCUME_pico/picovcs/emuapi.cpp index 68cd1f8..a9122c4 100644 --- a/MCUME_pico/picovcs/emuapi.cpp +++ b/MCUME_pico/picovcs/emuapi.cpp @@ -50,7 +50,7 @@ static char files[MAX_FILES][MAX_FILENAME_SIZE]; static bool menuRedraw=true; #ifdef PICOMPUTER -static unsigned short * keys; +static const unsigned short * keys; static unsigned char keymatrix[6]; static int keymatrix_hitrow=-1; static bool key_fn=false; @@ -67,7 +67,9 @@ static bool menuOn=true; - +/******************************** + * Generic output and malloc +********************************/ void emu_printf(char * text) { printf("%s\n",text); @@ -137,6 +139,9 @@ void emu_Free(void * pt) +/******************************** + * Input and keyboard +********************************/ int emu_ReadAnalogJoyX(int min, int max) { adc_select_input(0); @@ -317,7 +322,7 @@ int emu_ReadKeys(void) key_fn = false; } - if ( keymatrix[0] & 0x20) retval |= MASK_JOY2_BTN; + if ( row & 0x10) retval |= MASK_JOY2_BTN; if ( key_fn ) retval |= MASK_KEY_USER2; if ( ( key_fn ) && (row == 0x20 )) retval |= MASK_KEY_USER1; #endif @@ -345,19 +350,18 @@ int emu_ReadI2CKeyboard(void) { int retval=0; #ifdef PICOMPUTER if (key_fn) { - keys = (unsigned short *)key_map2; + keys = (const unsigned short *)key_map2; } else { - keys = (unsigned short *)key_map1; + keys = (const unsigned short *)key_map1; } if (keymatrix_hitrow >=0 ) { unsigned short match = ((unsigned short)keymatrix_hitrow<<8) | keymatrix[keymatrix_hitrow]; if ( (match == 0x002 ) ) return 0; // shift or fn if (match < 0x100 ) match = match & ~0x002; // ignore shift key - for (int i=0; i= filesize) - { - int retval=0; - if( (f_read (&file, buf, filesize, &retval)) ) { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - filesize = file.size(); - emu_printf(filesize); - - if (size >= filesize) - { - if (emu_FileRead(buf, filesize) != filesize) - { - emu_printf("File read failed"); - } - } - file.close(); - } -#endif - - return(filesize); -} - -int emu_LoadFileSeek(char * filename, char * buf, int size, int seek) -{ - int filesize = 0; - - char filepath[80]; - strcpy(filepath, romspath); - strcat(filepath, "/"); - strcat(filepath, filename); - emu_printf("LoadFileSeek..."); - emu_printf(filepath); -#ifdef USE_SDFS - if( !(f_open(&file, filepath, FA_READ)) ) { - f_lseek(&file, seek); - emu_printf(size); - if (size >= filesize) - { - int retval=0; - if( (!f_read (&file, buf, size, &retval)) ) - if (retval != size) - { - emu_printf("File read failed"); - } - } - f_close(&file); - } -#else - if ((file = SD.open(filepath, O_READ))) - { - file.seek(seek); - emu_printf(size); - if (file.read(buf, size) != size) { - emu_printf("File read failed"); - } - file.close(); - } -#endif - - return(filesize); -} -#endif +/******************************** + * Initialization +********************************/ void emu_init(void) { sd_init_driver();