diff --git a/remap2db.py b/contrib/remap2db.py similarity index 98% rename from remap2db.py rename to contrib/remap2db.py index 135ac12..8620bdc 100755 --- a/remap2db.py +++ b/contrib/remap2db.py @@ -85,7 +85,7 @@ #include #include "database.h" -// no-cpc-intro CRC database +// clean-cpc-db CRC database t_file_entry database[] = { """ FOOTER = """ @@ -173,7 +173,7 @@ def file_get_entry(l_File): if command: command = command.upper() \ .replace('[ENTER]', '\\n') \ - .replace('[QUOTE]', '"') \ + .replace('[QUOTE]', '\\"') \ .replace('[WAIT]', '~') if not command in commands: commands.append(command) @@ -202,6 +202,7 @@ def file_get_entry(l_File): tmp = line.split('=') retro_key[tmp[1].replace(',', '').strip()] = tmp[0].strip() + # build final file text = HEADER for (key, entry) in db.items(): diff --git a/contrib/remaps/Abbey.rmp b/contrib/remaps/Abbey.rmp index dd7df10..775af79 100644 --- a/contrib/remaps/Abbey.rmp +++ b/contrib/remaps/Abbey.rmp @@ -27,7 +27,7 @@ input_player1_key_y_name = "answer yes" # [enter] => \n # [quote] => " # [wait] => wait 5 seconds -entry_command = "RUN[quote]GAME.BIN" +entry_command = "|CPM" # game hashes entry_hash_1 = "0xbf188ce3" # comment here @@ -36,4 +36,4 @@ entry_hash_2 = "0x6e5f98ff" # map type (clean/keep) # keep: use joystick as base and add/changes inputs given above # clean: clear all default binds and only uses the given above -entry_map_type = "clean" \ No newline at end of file +entry_map_type = "clean" diff --git a/contrib/remaps/Ikari Warriors.rmp b/contrib/remaps/Ikari Warriors.rmp new file mode 100644 index 0000000..192f0be --- /dev/null +++ b/contrib/remaps/Ikari Warriors.rmp @@ -0,0 +1,21 @@ +input_player1_key_start = "49" +input_player1_key_start_name = "Start One Player" +input_player1_key_b = "116" +input_player1_key_b_name = "Toggle" +input_player1_key_x = "51" +input_player1_key_x_name = "Joystick 2 Select" +input_player1_key_select = "50" +input_player1_key_select_name = "Joystick 1 Select" + +entry_map_type = "keep" # default + +entry_hash_1 = 36d943ea +entry_hash_2 = e7df0e60 + +# game load command +# special commands: +# [enter] => \n +# [quote] => " +# [wait] => wait 5 seconds +entry_command = "RUN[quote]ELITE" + diff --git a/contrib/remaps/Manic Miner.rmp b/contrib/remaps/Manic Miner.rmp new file mode 100644 index 0000000..9bdd2e6 --- /dev/null +++ b/contrib/remaps/Manic Miner.rmp @@ -0,0 +1,4 @@ +input_player1_key_start = "13" +input_player1_key_b = "13" + +entry_hash_1 = 0xcd9dbf9c \ No newline at end of file diff --git a/libretro/db/database.c b/libretro/db/database.c index 9b73897..e771870 100644 --- a/libretro/db/database.c +++ b/libretro/db/database.c @@ -3,6 +3,8 @@ #include "entries.h" +// #define DEBUG_DATABASE + extern t_button_cfg btnPAD[MAX_PADCFG]; unsigned char get_keybind (unsigned int key, unsigned char position) @@ -10,16 +12,50 @@ unsigned char get_keybind (unsigned int key, unsigned char position) switch (key) { case DB_CLEAN: + #ifdef DEBUG_DATABASE + printf("[keybind-clean] k:%u p:%u = %u\n", key, position, btnPAD[0].buttons[position]); + #endif return 0xff; case DB_KEEP: + #ifdef DEBUG_DATABASE + printf("[keybind-keep] k:%u p:%u = %u\n", key, position, btnPAD[0].buttons[position]); + #endif return btnPAD[0].buttons[position]; default: + #ifdef DEBUG_DATABASE + printf("[keybind-cfg] k:%u p:%u = %u\n", key, position, get_cpckey(key)); + #endif return get_cpckey(key); } } +const char * string_find(const char * data, size_t data_leng, unsigned int position) +{ + for(size_t n = 0; n < (data_leng - 1); n++) + { + if (!position) + return &data[n]; + + if (data[n] == '\0') + position --; + } + + return NULL; +} + +void command_add(unsigned int command_position) +{ + const char * command = string_find(commands, sizeof(commands), command_position); + + if (!command || strlen(command) > LOADER_MAX_SIZE) + return; + + strcpy(game_configuration.loader_command, command); + game_configuration.has_command = true; +} + void database_entry(t_file_entry * entry) { if (entry->btn_map[0]) @@ -31,10 +67,9 @@ void database_entry(t_file_entry * entry) game_configuration.has_btn = true; } - if (entry->loader_command[0]) + if (entry->loader_command != COMMAND_EMPTY) { - strncpy(game_configuration.loader_command, entry->loader_command, LOADER_MAX_SIZE); - game_configuration.has_command = true; + command_add(entry->loader_command); } } @@ -52,6 +87,5 @@ bool get_database(const uint32_t hash) } } } - return false; } diff --git a/libretro/db/database.h b/libretro/db/database.h index 81af89e..a3e6984 100644 --- a/libretro/db/database.h +++ b/libretro/db/database.h @@ -3,6 +3,7 @@ #define DB_CLEAN 0xfff #define DB_KEEP 0xffff +#define COMMAND_EMPTY -1 typedef struct { uint32_t hash_list[16]; diff --git a/libretro/db/entries.h b/libretro/db/entries.h index dedf1b4..31e3e52 100644 --- a/libretro/db/entries.h +++ b/libretro/db/entries.h @@ -38,7 +38,7 @@ #include #include "database.h" -// no-cpc-intro CRC database +// clean-cpc-db CRC database t_file_entry database[] = { { // Abadia.rmp {0xd37cf8e7, 0xaa05ed4a}, @@ -46,20 +46,31 @@ t_file_entry database[] = { {0, 1, -1, 2, -1, -1, 3, 4, 5, 6, -1, -1, -1, -1}, 0, }, + { // Manic Miner.rmp + {0xcd9dbf9c}, + {RETROK_RETURN, DB_KEEP, DB_KEEP, RETROK_RETURN, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP}, + {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, + -1, + }, + { // Ikari Warriors.rmp + {0x36d943ea, 0xe7df0e60}, + {RETROK_t, DB_KEEP, RETROK_2, RETROK_1, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP, RETROK_3, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP}, + {7, -1, 8, 9, -1, -1, -1, -1, -1, 10, -1, -1, -1, -1}, + 1, + }, { // Abbey.rmp {0xbf188ce3, 0x6e5f98ff}, - {RETROK_z, RETROK_y, DB_KEEP, RETROK_SPACE, DB_KEEP, DB_KEEP, RETROK_k, RETROK_l, RETROK_a, RETROK_n, DB_KEEP, DB_KEEP, DB_KEEP, DB_KEEP}, - {7, 8, -1, 9, -1, -1, 10, 11, 12, 13, -1, -1, -1, -1}, - -1, + {RETROK_z, RETROK_y, DB_CLEAN, RETROK_SPACE, DB_CLEAN, DB_CLEAN, RETROK_k, RETROK_l, RETROK_a, RETROK_n, DB_CLEAN, DB_CLEAN, DB_CLEAN, DB_CLEAN}, + {11, 12, -1, 13, -1, -1, 14, 15, 16, 17, -1, -1, -1, -1}, + 0, }, }; -// dictionary commands char commands[] = { - "|CPM\0" "" + "|CPM\0" + "RUN\"ELITE\0" }; -// dictionary names char input_names[] = { "Mover Adso\0" "Decir Si\0" @@ -68,6 +79,10 @@ char input_names[] = { "Girar Derecha\0" "Avanzar\0" "Decir No\0" + "Toggle\0" + "Joystick 1 Select\0" + "Start One Player\0" + "Joystick 2 Select\0" "Send Adso Forward\0" "Answer Yes\0" "Start / Drop Object\0" @@ -78,5 +93,5 @@ char input_names[] = { }; -// gen hash: 1648674136.6454308 +// gen hash: 1649930269.6167448 diff --git a/libretro/libretro-core.c b/libretro/libretro-core.c index 33d92d7..9093487 100644 --- a/libretro/libretro-core.c +++ b/libretro/libretro-core.c @@ -997,7 +997,7 @@ void computer_set_model(int model) if (CPC.model == model) return; - printf("[computer_set_model] model [%i => %i]\n", CPC.model, model); + LOGI("[computer_set_model] model [%i => %i]\n", CPC.model, model); CPC.model = model; retro_computer_cfg.model = model; @@ -1009,8 +1009,6 @@ void computer_set_model(int model) void check_flags(const char *filename, unsigned int size) { - LOGI("model %i %s %i %i \n", CPC.model, filename, file_check_flag(filename, size, FLAG_BIOS_664, 5), file_check_flag(filename, size, FLAG_BIOS_B10, 10)); - if (file_check_flag(filename, size, FLAG_BIOS_664, 5)) { computer_set_model(1);