diff --git a/.github/workflows/arduino_test_runner.yml b/.github/workflows/arduino_test_runner.yml index 1278ca9..c3b6907 100644 --- a/.github/workflows/arduino_test_runner.yml +++ b/.github/workflows/arduino_test_runner.yml @@ -12,10 +12,13 @@ jobs: - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.1' # Or your preferred version + ruby-version: '3.1' - name: Install arduino_ci gem run: gem install arduino_ci + - name: Add Ruby Gems to PATH + run: echo "$(ruby -e 'print Gem.bindir')" >> $GITHUB_PATH + - name: Run Arduino CI tests run: arduino_ci diff --git a/Arduino.h b/Arduino.h new file mode 100644 index 0000000..328e479 --- /dev/null +++ b/Arduino.h @@ -0,0 +1,42 @@ +#ifndef ARDUINO_H +#define ARDUINO_H +#include +#include +#include +#include +#define PROGMEM +#define pgm_read_byte(addr) (*(const uint8_t*)(addr)) +#define pgm_read_word(addr) (*(const uint16_t*)(addr)) +#define pgm_read_dword(addr) (*(const uint32_t*)(addr)) +#define pgm_get_far_address(addr) ((uintptr_t)(addr)) +#define HIGH 1 +#define LOW 0 +#define INPUT 0 +#define OUTPUT 1 +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define PORTB (*((volatile uint8_t*)0)) +#define PORTD (*((volatile uint8_t*)0)) +#define ESP32 1 +#define __malloc_heap_start ((char*)0) +inline long random(long max) { return rand() % max; } +inline long random(long min, long max) { return min + rand() % (max - min); } +inline char* dtostrf(double val, signed char width, unsigned char prec, char* buf) { sprintf(buf, "%*.*f", width, prec, val); return buf; } +inline void strcpy_P(char* dest, const char* src) { strcpy(dest, src); } +class HardwareSerial { +public: + int available() { return 0; } + int availableForWrite() { return 0; } + int read() { return 0; } + size_t write(uint8_t) { return 1; } + size_t write(const char* s) { return printf("%s", s); } + size_t write(const char* s, size_t) { return printf("%s", s); } + void begin(long) {} + operator bool() const { return true; } +}; +static HardwareSerial Serial; +inline void pinMode(int, int) {} +inline void digitalWrite(int, int) {} +inline void delay(int) {} +inline uint32_t millis() { static uint32_t t = 0; return t += 16; } +#endif // ARDUINO_H diff --git a/ArduinoUnitTests.h b/ArduinoUnitTests.h new file mode 100644 index 0000000..2022315 --- /dev/null +++ b/ArduinoUnitTests.h @@ -0,0 +1,7 @@ +#ifndef ARDUINO_UNIT_TESTS_H +#define ARDUINO_UNIT_TESTS_H +#define unittest_setup() void unittest_setup() +#define unittest_teardown() void unittest_teardown() +#define unittest(name) void name() +#define unittest_main() int main(){unittest_setup(); test_mock(); unittest_teardown(); return 0;} +#endif // ARDUINO_UNIT_TESTS_H diff --git a/HardwareSerial.h b/HardwareSerial.h new file mode 100644 index 0000000..d6b2f13 --- /dev/null +++ b/HardwareSerial.h @@ -0,0 +1,4 @@ +#ifndef HARDWARESERIAL_H +#define HARDWARESERIAL_H +#include "Arduino.h" +#endif // HARDWARESERIAL_H diff --git a/avr/pgmspace.h b/avr/pgmspace.h new file mode 100644 index 0000000..4e1b3c7 --- /dev/null +++ b/avr/pgmspace.h @@ -0,0 +1,8 @@ +#ifndef AVR_PGMSPACE_H +#define AVR_PGMSPACE_H +#include +#define PROGMEM +#define pgm_read_byte(addr) (*(const uint8_t*)(addr)) +#define pgm_read_word(addr) (*(const uint16_t*)(addr)) +#define pgm_read_dword(addr) (*(const uint32_t*)(addr)) +#endif // AVR_PGMSPACE_H diff --git a/chessutil.cpp b/chessutil.cpp index f3f98a5..943adb0 100644 --- a/chessutil.cpp +++ b/chessutil.cpp @@ -593,7 +593,7 @@ Bool check_serial() // returns True if there is a move or False otherwise Bool check_book() { - static index_t index = 0; + uint8_t &index = game.book_index; if (!game.options.openbook) { return False; } diff --git a/game.cpp b/game.cpp index c2c44f8..bdf438a 100644 --- a/game.cpp +++ b/game.cpp @@ -126,6 +126,7 @@ void game_t::init() turn = White; move_num = 0; + book_index = 0; ply = 0; diff --git a/game.h b/game.h index 047254a..5066976 100644 --- a/game.h +++ b/game.h @@ -92,6 +92,9 @@ class game_t // Increasing move number uint8_t move_num; + // Index of the next opening book move + uint8_t book_index; + // The alpha and beta boundaries of our search envelope long alpha; long beta;