Skip to content

Commit

Permalink
[core] new database based on clean-cpc-db #112
Browse files Browse the repository at this point in the history
first RMP files added.
  • Loading branch information
David Skywalker committed Apr 14, 2022
1 parent bb2d96c commit 6a4ef66
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 19 deletions.
5 changes: 3 additions & 2 deletions remap2db.py → contrib/remap2db.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
#include <libretro.h>
#include "database.h"
// no-cpc-intro CRC database
// clean-cpc-db CRC database
t_file_entry database[] = {
"""
FOOTER = """
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions contrib/remaps/Abbey.rmp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
entry_map_type = "clean"
21 changes: 21 additions & 0 deletions contrib/remaps/Ikari Warriors.rmp
Original file line number Diff line number Diff line change
@@ -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"

4 changes: 4 additions & 0 deletions contrib/remaps/Manic Miner.rmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
input_player1_key_start = "13"
input_player1_key_b = "13"

entry_hash_1 = 0xcd9dbf9c
42 changes: 38 additions & 4 deletions libretro/db/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,59 @@

#include "entries.h"

// #define DEBUG_DATABASE

extern t_button_cfg btnPAD[MAX_PADCFG];

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])
Expand All @@ -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);
}
}

Expand All @@ -52,6 +87,5 @@ bool get_database(const uint32_t hash)
}
}
}

return false;
}
1 change: 1 addition & 0 deletions libretro/db/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#define DB_CLEAN 0xfff
#define DB_KEEP 0xffff
#define COMMAND_EMPTY -1

typedef struct {
uint32_t hash_list[16];
Expand Down
31 changes: 23 additions & 8 deletions libretro/db/entries.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,39 @@
#include <libretro.h>
#include "database.h"

// no-cpc-intro CRC database
// clean-cpc-db CRC database
t_file_entry database[] = {
{ // Abadia.rmp
{0xd37cf8e7, 0xaa05ed4a},
{RETROK_z, RETROK_s, DB_CLEAN, RETROK_SPACE, DB_CLEAN, DB_CLEAN, RETROK_k, RETROK_l, RETROK_a, RETROK_n, DB_CLEAN, DB_CLEAN, DB_CLEAN, DB_CLEAN},
{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"
Expand All @@ -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"
Expand All @@ -78,5 +93,5 @@ char input_names[] = {
};


// gen hash: 1648674136.6454308
// gen hash: 1649930269.6167448

4 changes: 1 addition & 3 deletions libretro/libretro-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 6a4ef66

Please sign in to comment.