From 8949e0539e324fd31319b095554223dbbfb4d5af Mon Sep 17 00:00:00 2001 From: jean-marcharvengt Date: Mon, 5 Jul 2021 23:59:29 +0200 Subject: [PATCH] fix hangup when up/right or down/right pressed --- MCUME_pico/bin/PICOMPUTER/mcume_pico64.uf2 | Bin 440832 -> 440832 bytes MCUME_pico/bin/PICOMPUTER/mcume_pico800.uf2 | Bin 297472 -> 297472 bytes MCUME_pico/bin/PICOMPUTER/mcume_pico81.uf2 | Bin 249856 -> 249856 bytes MCUME_pico/bin/PICOMPUTER/mcume_picocolem.uf2 | Bin 234496 -> 234496 bytes MCUME_pico/bin/PICOMPUTER/mcume_picoo2em.uf2 | Bin 187392 -> 187392 bytes .../bin/PICOMPUTER/mcume_picospeccy.uf2 | Bin 274944 -> 274944 bytes MCUME_pico/bin/PICOMPUTER/mcume_picovcs.uf2 | Bin 215552 -> 215552 bytes MCUME_pico/pico5200/emuapi.cpp | 111 +++------- MCUME_pico/pico64/emuapi.cpp | 113 +++------- MCUME_pico/pico800/emuapi.cpp | 115 +++------- MCUME_pico/pico81/emuapi.cpp | 114 +++------- MCUME_pico/picocolem/emuapi.cpp | 136 +++--------- MCUME_pico/piconofrendo/emuapi.cpp | 145 +++---------- MCUME_pico/picoo2em/emuapi.cpp | 138 +++--------- MCUME_pico/picosnd/emuapi.cpp | 200 +++++++----------- MCUME_pico/picospeccy/emuapi.cpp | 140 +++--------- MCUME_pico/picovcs/emuapi.cpp | 135 +++--------- 17 files changed, 310 insertions(+), 1037 deletions(-) diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_pico64.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_pico64.uf2 index 83e730fe0e4421b587ca3c13a58490c503396d0f..f7c143b0c74c89b94433364c5572841f276772e8 100644 GIT binary patch delta 235 zcmZqpBGmvyTNpDQa7!|H$xU<=^Aaq0HNE%&W3iRNR_O``ZN-Zsz9QZX3bF|z-qINi z+7h>gy@Wkwn3NpO#E3XA*~Fy7f8oCl;|(U|InE5qd|u2C7>%bZRu>ajpn2c1k*)IroEOh#DF`6MF+F&oI@15ri3csEoaBH`D#0bPp zK+FupEZc1!u})mTXuADe6I+x#FY8YRjcXSe6y7{%`0#$a=_0n*%t}-F83h=(FnP4N XG44rlXV}l{hRXlQyWMFS+dg3ch0IaS delta 235 zcmZqpBGmvyTNpDQa7!>a%5^x3d2$p?nqK^XvDivrt8@i}w&Fz*9}#Z`1(^g9Z|MvM zZHe2$o>EML4nkg+Vz`_qZDP{mzwlp6;HH8W*98VeK5r&tCgbUf6|8qA|6vr=|HvS~ zz{tSxk%56BmYIPe?0@%@8FCCAjD{1OeqQusNRd$J5ZKGY78gD<>#1eE7fJbP?NYW~Gn3i~@{Xm^@nC X822Q&GwkPeL*-B9-|n=GZJ#gzv+hv; diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_pico800.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_pico800.uf2 index 3bd9995f7cdc06d4e8753fd4da20eed8a2f33497..1344231cda3551ff792a625917fbb3402e770e57 100644 GIT binary patch delta 182 zcmV;n07?IVloEiH5`eS;OqL5707@Q_K^968aO#&=mH~5CFtr*tptdIa2)`~eY%4VVFk4VVJA4VVMiwgEG@=1v3#9swV> k?Q8^70Rjd2w?b|N_5%Y&AOV*&9nnw0Ri{7 oEw%&e0tjLL01yGR0!Wu3!~@)u`~eY{4Y~sx0!_=eD!K#K6(x>8YXATM delta 186 zcmV;r07d_Rpbvnc4}i1*)L07`06`vzK^92}aFVy*SOIeZRuHutcmOLQ(G*M+O8_7o zU=&LmXaFl1+Y?C|0uewGO43{kLz1!rDi6^ADiGNqDhkj5Ar4CdGXgW19sq~|F_1#} z(MbSg7$Arcy$MX*=K>>|L+j^E|11I60wbJ503!}c z1K7G01yGR0!V~L0lZ*G0KfUUx59n{J{6)SKf(Y2 delta 191 zcmV;w06_nMs1AUr4uG@)5H}DQ06`vzK^92}aFPZD)k;Q}A&3Lqll%b@mkl@pfmRT; z8+ZUKA<+~}6iWag9AFen8)yJ47~2y`8UhhO5=zos3PX~z0xA#C|0)pKASw#b03i-b z0y6?Lm>vL#0Wpw5`O!%LWEdcb5WNXZ+~)!#nnUa7hvYZ`hvYZ{x8yhjc_RTcw_aQW t1|9(?mt}ebUjgs8#d-tl0}}bU01yGR0!V~L0lZ*G0KX0Gx59n{J{9N{J@o(p diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_picoo2em.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_picoo2em.uf2 index 15f5c5b86678212923ef7f163b85093bfb2361c6..f2f2dcf03bf38bb752b1e181c26a33c7e421ad4e 100644 GIT binary patch delta 149 zcmV;G0BZk$xC?-|3$Q@S3mE`P9+5#7N)d4ClS|5TVlcHEcmOLQ(G*P-O8_7pU=&Lm zXaFl1+Y?F?NgM(qK+IeeL!`0-EDzBCECJX8Bb-A3BMwRf-~lrNG9)Vp&=H8CLio{J z09acvy$Ma+=Kvu3=fFlUI{+Z)N&yhS6#yWUApzTy`vDSz4a~O<%mKLA0X4VAqyjoO DAtW+_ delta 149 zcmV;G0BZk$xC?-|3$Q@S3m5=F9*98}NeFO~lS|5TVi2_(cmOLQ(G*M+O8_7oU=&Lm zXaFl1+Y?C|0uewGO43{kLz1!rDi6^ADiGNqDhkj5Ar4CdGXgW19sq~|F_1#}(MbSg z7$Arcy$MX*=K>>|L+j@+I{+Z)N&yhS6#yWUApzTy`vDSz4a~O<%mKLA0W-J8qyjoO Dk6AFa diff --git a/MCUME_pico/bin/PICOMPUTER/mcume_picospeccy.uf2 b/MCUME_pico/bin/PICOMPUTER/mcume_picospeccy.uf2 index e99101dd6eac429a2e9dffea0f91df9c4e55349f..4e730db315ce9fca27973a65d21dfdc81238cd3e 100644 GIT binary patch delta 227 zcmZp8BG3RtTNraZxFs39CLNG?S8+QqvUwM{$S9!c7Z|R&2xqi|F>_IV0q1~wDBN=0OJ-Wj}|w^Jqhj% S`!m0x@#t$0zyN5q>!K_)@OTRMY5 zTjI8`rxcT*gOJyy7%t~Yo0zotFZ|aMxT&DUb%8;V&wIL}3d^0ze;5Ugmof-2FfuSK zWnf^CWMW_l```V9$(YG_h8#l&qu~UnpBFtDQX~{Q1om?J+Mj&R| z?%>7DyMfVoyWcP7C^=r%p9~t;E-)y(dCu_R{r0UAEU%fBLJu>|L+j^tkK2rby 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();