move UCI_COMMANDS fully to PROGMEM
This commit is contained in:
parent
ce19f8793a
commit
9184324a7f
36
Uci.h
36
Uci.h
|
|
@ -23,17 +23,28 @@ uci_return uci_unknown() {
|
||||||
Serial.println(F("Not an UCI command"));
|
Serial.println(F("Not an UCI command"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const uci_cmd UCI_COMMANDS[] = {
|
const char UCI_COMMAND_uci[] PROGMEM = "uci";
|
||||||
{PS2("uci"), &uci_hello},
|
const char UCI_COMMAND_debug[] PROGMEM = "debug";
|
||||||
{PS2("debug"), &uci_unimpl},
|
const char UCI_COMMAND_isready[] PROGMEM = "isready";
|
||||||
{PS2("isready"), &uci_unimpl},
|
const char UCI_COMMAND_setoption[] PROGMEM = "setoption";
|
||||||
{PS2("setoption"), &uci_unimpl},
|
const char UCI_COMMAND_ucinewgame[] PROGMEM = "ucinewgame";
|
||||||
{PS2("ucinewgame"), &uci_unimpl},
|
const char UCI_COMMAND_position[] PROGMEM = "position";
|
||||||
{PS2("position"), &uci_unimpl},
|
const char UCI_COMMAND_go[] PROGMEM = "go";
|
||||||
{PS2("go"), &uci_unimpl},
|
const char UCI_COMMAND_stop[] PROGMEM = "stop";
|
||||||
{PS2("stop"), &uci_unimpl},
|
const char UCI_COMMAND_ponderhit[] PROGMEM = "ponderhit";
|
||||||
{PS2("ponderhit"), &uci_unimpl},
|
const char UCI_COMMAND_quit[] PROGMEM = "quit";
|
||||||
{PS2("quit"), &uci_unimpl},
|
|
||||||
|
const uci_cmd UCI_COMMANDS[] PROGMEM = {
|
||||||
|
{UCI_COMMAND_uci, &uci_hello},
|
||||||
|
{UCI_COMMAND_debug, &uci_unimpl},
|
||||||
|
{UCI_COMMAND_isready, &uci_unimpl},
|
||||||
|
{UCI_COMMAND_setoption, &uci_unimpl},
|
||||||
|
{UCI_COMMAND_ucinewgame, &uci_unimpl},
|
||||||
|
{UCI_COMMAND_position, &uci_unimpl},
|
||||||
|
{UCI_COMMAND_go, &uci_unimpl},
|
||||||
|
{UCI_COMMAND_stop, &uci_unimpl},
|
||||||
|
{UCI_COMMAND_ponderhit, &uci_unimpl},
|
||||||
|
{UCI_COMMAND_quit, &uci_unimpl},
|
||||||
};
|
};
|
||||||
|
|
||||||
const uci_cmd UCI_INVALID = {PS2(""), &uci_unknown};
|
const uci_cmd UCI_INVALID = {PS2(""), &uci_unknown};
|
||||||
|
|
@ -42,7 +53,8 @@ uci_cmd get_uci_command(const char* command) {
|
||||||
size_t command_num = sizeof(UCI_COMMANDS) / sizeof(uci_cmd);
|
size_t command_num = sizeof(UCI_COMMANDS) / sizeof(uci_cmd);
|
||||||
for(size_t i = 0; i < command_num; i++) {
|
for(size_t i = 0; i < command_num; i++) {
|
||||||
size_t ci = 0;
|
size_t ci = 0;
|
||||||
uci_cmd to_try = UCI_COMMANDS[i];
|
uci_cmd to_try;
|
||||||
|
memcpy_P(&to_try, &UCI_COMMANDS[i], sizeof(uci_cmd));
|
||||||
while(true) {
|
while(true) {
|
||||||
char reference = pgm_read_byte_near(to_try.command + ci);
|
char reference = pgm_read_byte_near(to_try.command + ci);
|
||||||
if(reference != command[ci]) {
|
if(reference != command[ci]) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue