|
959 | 959 | i = 0;
|
960 | 960 | offset = ROM.favorite?40:35;
|
961 | 961 | int option = SAVED ? 3 : 1;
|
| 962 | + draw_mask(x,y-1,80,9); |
962 | 963 | for(int r = 0; r < 5; r++){for(int c = 0; c < 5; c++) {
|
963 | 964 | buffer[i] = icons[r+offset][c] == WHITE ? OPTION == option ? WHITE : GUI.fg : GUI.bg;i++;
|
964 |
| - }} |
| 965 | + }} |
965 | 966 | ili9341_write_frame_rectangleLE(x, y, w, h, buffer);
|
966 | 967 | draw_text(x+10,y,ROM.favorite?"Unfavorite":"Favorite",false,OPTION == option?true:false, false);
|
967 | 968 | }
|
|
1249 | 1250 | f = fopen(file, "rb");
|
1250 | 1251 | if(f == NULL) {
|
1251 | 1252 | f = fopen(file, "w+");
|
1252 |
| - printf("\nCREATING: %s", file); |
1253 |
| - /* |
1254 |
| - Castlevania Adventure, The (U).gb |
1255 |
| - Legend of Zelda, The - Oracle of Seasons (USA).gbc |
1256 |
| - Mega Man 2 (USA).nes |
1257 |
| - */ |
| 1253 | + printf("\nCREATING: %s", file); |
1258 | 1254 | } else {
|
1259 | 1255 | read_favorites();
|
1260 | 1256 | }
|
|
1300 | 1296 |
|
1301 | 1297 | void delete_favorite(char *favorite) {
|
1302 | 1298 | printf("\n----- %s START -----", __func__);
|
| 1299 | + |
| 1300 | + int n = 0; |
| 1301 | + int count = 0; |
| 1302 | + |
| 1303 | + free(FAVORITES); |
| 1304 | + FAVORITES = (char**)malloc(50 * sizeof(void*)); |
| 1305 | + |
| 1306 | + char file[256] = "/sd/odroid/data"; |
| 1307 | + sprintf(file, "%s/%s", file, FAVFILE); |
| 1308 | + |
| 1309 | + FILE *f; |
| 1310 | + f = fopen(file, "rb"); |
| 1311 | + if(f) { |
| 1312 | + printf("\nCHECKING: %s\n", favorite); |
| 1313 | + char line[256]; |
| 1314 | + while (fgets(line, sizeof(line), f)) { |
| 1315 | + char *ep = &line[strlen(line)-1]; |
| 1316 | + while (*ep == '\n' || *ep == '\r'){*ep-- = '\0';} |
| 1317 | + if(strcmp(favorite, line) != 0) { |
| 1318 | + size_t len = strlen(line); |
| 1319 | + FAVORITES[n] = (char*)malloc(len + 1); |
| 1320 | + strcpy(FAVORITES[n], line); |
| 1321 | + n++; |
| 1322 | + count++; |
| 1323 | + } |
| 1324 | + } |
| 1325 | + } |
| 1326 | + fclose(f); |
| 1327 | + struct stat st; |
| 1328 | + if (stat(file, &st) == 0) { |
| 1329 | + unlink(file); |
| 1330 | + create_favorites(); |
| 1331 | + for(n = 0; n < count; n++) { |
| 1332 | + size_t len = strlen(FAVORITES[n]); |
| 1333 | + if(len > 0) { |
| 1334 | + add_favorite(FAVORITES[n]); |
| 1335 | + printf("\n%s - %d" , FAVORITES[n], len); |
| 1336 | + } |
| 1337 | + } |
| 1338 | + } else { |
| 1339 | + printf("\nUNABLE TO UNLINK\n"); |
| 1340 | + } |
| 1341 | + |
1303 | 1342 | printf("\n----- %s END -----\n", __func__);
|
1304 | 1343 | }
|
1305 | 1344 |
|
|
1319 | 1358 | while (fgets(line, sizeof(line), f)) {
|
1320 | 1359 | char *ep = &line[strlen(line)-1];
|
1321 | 1360 | while (*ep == '\n' || *ep == '\r'){*ep-- = '\0';}
|
1322 |
| - printf("\nfavorite:%s line:%s match:%d", favorite, line, strcmp(favorite, line)); |
1323 | 1361 | if(strcmp(favorite, line) == 0) {
|
1324 | 1362 | ROM.favorite = true;
|
1325 | 1363 | }
|
|
1948 | 1986 | SAVED ? rom_resume() : rom_run(false);
|
1949 | 1987 | break;
|
1950 | 1988 | case 1:
|
1951 |
| - SAVED ? rom_run(true) : add_favorite(ROM.name); |
| 1989 | + SAVED ? rom_run(true) : ROM.favorite ? delete_favorite(ROM.name) : add_favorite(ROM.name); |
1952 | 1990 | if(!SAVED) {draw_launcher_options();}
|
1953 | 1991 | break;
|
1954 | 1992 | case 2:
|
1955 | 1993 | rom_delete_save();
|
1956 | 1994 | break;
|
1957 | 1995 | case 3:
|
1958 |
| - add_favorite(ROM.name); |
| 1996 | + ROM.favorite ? delete_favorite(ROM.name) : add_favorite(ROM.name); |
1959 | 1997 | draw_launcher_options();
|
1960 | 1998 | break;
|
1961 | 1999 | }
|
|
0 commit comments