Store UCI strings in progmem
This commit is contained in:
parent
ec306fe6ad
commit
ce19f8793a
26
Uci.h
26
Uci.h
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef __UCI_H_INC
|
||||
#define __UCI_H_INC
|
||||
|
||||
#define PS2(s) ([]{ static const char c[] PROGMEM = (s); return &c[0]; }())
|
||||
|
||||
typedef void uci_return;
|
||||
typedef uci_return (*uci_handler)();
|
||||
|
||||
|
|
@ -22,19 +24,19 @@ uci_return uci_unknown() {
|
|||
}
|
||||
|
||||
const uci_cmd UCI_COMMANDS[] = {
|
||||
{"uci", &uci_hello},
|
||||
{"debug", &uci_unimpl},
|
||||
{"isready", &uci_unimpl},
|
||||
{"setoption", &uci_unimpl},
|
||||
{"ucinewgame", &uci_unimpl},
|
||||
{"position", &uci_unimpl},
|
||||
{"go", &uci_unimpl},
|
||||
{"stop", &uci_unimpl},
|
||||
{"ponderhit", &uci_unimpl},
|
||||
{"quit", &uci_unimpl},
|
||||
{PS2("uci"), &uci_hello},
|
||||
{PS2("debug"), &uci_unimpl},
|
||||
{PS2("isready"), &uci_unimpl},
|
||||
{PS2("setoption"), &uci_unimpl},
|
||||
{PS2("ucinewgame"), &uci_unimpl},
|
||||
{PS2("position"), &uci_unimpl},
|
||||
{PS2("go"), &uci_unimpl},
|
||||
{PS2("stop"), &uci_unimpl},
|
||||
{PS2("ponderhit"), &uci_unimpl},
|
||||
{PS2("quit"), &uci_unimpl},
|
||||
};
|
||||
|
||||
const uci_cmd UCI_INVALID = {"", &uci_unknown};
|
||||
const uci_cmd UCI_INVALID = {PS2(""), &uci_unknown};
|
||||
|
||||
uci_cmd get_uci_command(const char* command) {
|
||||
size_t command_num = sizeof(UCI_COMMANDS) / sizeof(uci_cmd);
|
||||
|
|
@ -42,7 +44,7 @@ uci_cmd get_uci_command(const char* command) {
|
|||
size_t ci = 0;
|
||||
uci_cmd to_try = UCI_COMMANDS[i];
|
||||
while(true) {
|
||||
char reference = to_try.command[ci];
|
||||
char reference = pgm_read_byte_near(to_try.command + ci);
|
||||
if(reference != command[ci]) {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue