commit d80b03bdf0c553e6eef53c158325c6074178affb Author: A.M. Rowsell Date: Wed Jul 30 21:48:16 2025 -0400 Initial commit of MPLABX version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da897e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +# Created by https://www.toptal.com/developers/gitignore/api/mplabx +# Edit at https://www.toptal.com/developers/gitignore?templates=mplabx + +### MPLabX ### +#Ignore List for Microchip's MPLAB X IDE +#It's a form of NetBeans with vendor specific changes +#Taken from zeha on GIST https://gist.github.com/zeha/5999375 +#Updated by Cristian Cristea (https://github.com/cristiancristea00) + +*.d +*.pre +*.p1 +*.lst +*.sym +*.obj +*.o +*.sdb +*.obj.dmp +*.mk +*.map +*.properties +*.production +*.debug +html/ +nbproject/private/ +nbproject/Package-*.bash +build/ +nbbuild/ +dist/ +nbdist/ +nbactions.xml +nb-configuration.xml +funclist +nbproject/Makefile-* +disassembly/ +.generated_files/ + +# End of https://www.toptal.com/developers/gitignore/api/mplabx + diff --git a/Board.cpp b/Board.cpp new file mode 100644 index 0000000..c29a421 --- /dev/null +++ b/Board.cpp @@ -0,0 +1,25 @@ +/* + * File: Board.cpp + * Author: amr + * + * Created on July 30, 2025, 9:20 PM + */ + +#include "Board.hpp" + +Board::Board() { +} + +Board::~Board() { +} + +void Board::setupInitialPosition() { + return; +} +void Board::movePiece(int fromX, int fromY, int toX, int toY) { + return; +} + +void Board::deserializeBoard(uint64_t incomingBoard) { + return; +} \ No newline at end of file diff --git a/Board.hpp b/Board.hpp new file mode 100644 index 0000000..613117a --- /dev/null +++ b/Board.hpp @@ -0,0 +1,31 @@ +/* + * File: Board.hpp + * Author: amr + * + * Created on July 30, 2025, 9:20 PM + */ + +#ifndef BOARD_HPP +#define BOARD_HPP + +#include +#include +#include "Piece.hpp" +class Piece; +class Board { +private: + std::vector> boardGrid; + +public: + Board(); + ~Board(); + void setupInitialPosition(); + Piece *getPieceAt(int x, int y) const; + void movePiece(int fromX, int fromY, int toX, int toY); + bool isInBounds(int x, int y) const; + uint64_t serialBoard = 0xFFFF00000000FFFF; // opening position + void deserializeBoard(uint64_t incomingBoard); +}; + +#endif // BOARD_HPP + diff --git a/Game.cpp b/Game.cpp new file mode 100644 index 0000000..924b1da --- /dev/null +++ b/Game.cpp @@ -0,0 +1,13 @@ +/* + * File: Game.cpp + * Author: amr + * + * Created on July 30, 2025, 9:22 PM + */ + +#include "Game.hpp" + +Game::Game() { +} + + diff --git a/Game.hpp b/Game.hpp new file mode 100644 index 0000000..3716a55 --- /dev/null +++ b/Game.hpp @@ -0,0 +1,29 @@ +/* + * File: Game.hpp + * Author: amr + * + * Created on July 30, 2025, 9:22 PM + */ + +#ifndef GAME_HPP +#define GAME_HPP + +#include +#include "Piece.hpp" +class Piece; + +enum Players { PL_WHITE, PL_BLACK }; + +class Game { +public: + Game(); + void resetGame(void); // reset the board to a fresh state + uint8_t makeMove(Piece piece, Square start, Square end); + +private: + Players currentTurn = PL_WHITE; // start with white +}; + +#endif // GAME_HPP + + diff --git a/NeoPixel.cpp b/NeoPixel.cpp new file mode 100644 index 0000000..695eefb --- /dev/null +++ b/NeoPixel.cpp @@ -0,0 +1,13 @@ +/* + * File: NeoPixel.cpp + * Author: amr + * + * Created on July 30, 2025, 9:35 PM + */ + +#include "NeoPixel.hpp" + +uint8_t setNeoPixel(uint8_t index, uint8_t red, uint8_t green, uint8_t blue) { + + return 0; +} diff --git a/NeoPixel.hpp b/NeoPixel.hpp new file mode 100644 index 0000000..94a84a8 --- /dev/null +++ b/NeoPixel.hpp @@ -0,0 +1,25 @@ +/* + * File: NeoPixel.hpp + * Author: amr + * + * Created on July 30, 2025, 9:35 PM + */ + +#ifndef NEOPIXEL_HPP +#define NEOPIXEL_HPP +#include + +class NeoPixel { +public: + NeoPixel(uint8_t stringLength) : length(stringLength) {}; + uint8_t setNeoPixel(uint8_t index, uint8_t red, uint8_t green, uint8_t blue); + void allPixelsOff(void); + +private: + uint8_t sendPixelData(uint8_t count, uint8_t *data); + uint8_t PixelArray[64][3] = {{0}}; + uint8_t length; +}; + +#endif // NEOPIXEL_HPP + diff --git a/Piece.cpp b/Piece.cpp new file mode 100644 index 0000000..d6fc084 --- /dev/null +++ b/Piece.cpp @@ -0,0 +1,15 @@ +/* + * File: Piece.cpp + * Author: amr + * + * Created on July 30, 2025, 9:21 PM + */ + +#include "Piece.hpp" + +std::vector> King::getLegalMoves(int x, int y, const Board& board) const { + std::vector> moveList; + + // calculate legal moves somehow + return moveList; +} diff --git a/Piece.hpp b/Piece.hpp new file mode 100644 index 0000000..9a6d494 --- /dev/null +++ b/Piece.hpp @@ -0,0 +1,45 @@ +/* + * File: Piece.hpp + * Author: amr + * + * Created on July 30, 2025, 9:21 PM + */ + +#ifndef PIECE_HPP +#define PIECE_HPP +#pragma once + +#include +#include +#include +#include "Board.hpp" +class Board; + +enum PieceType { PAWN, BISHOP, KNIGHT, ROOK, QUEEN, KING, EMPTY }; +enum PieceColour { PIECE_WHITE, PIECE_BLACK, PIECE_EMPTY }; +enum Rank { R1 = 1, R2 = 2, R3 = 3, R4 = 4, R5 = 5, R6 = 6, R7 = 7, R8 = 8 }; +enum File { A, B, C, D, E, F, G, H }; +struct Square { + Rank rank; + File file; +}; + +class Piece { +protected: + PieceColour colour; + +public: + // methods + Piece(PieceColour pColour) : colour(pColour) {} + virtual ~Piece() {} + virtual std::vector> getLegalMoves(int x, int y, const Board &board) const; + PieceColour getColour() const { return colour; } +}; + +class King : public Piece { +public: + King(PieceColour colour) : Piece(colour) {} + std::vector> getLegalMoves(int x, int y, const Board &board) const override; +}; +#endif // PIECE_HPP + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..3bb4e7d --- /dev/null +++ b/main.cpp @@ -0,0 +1,16 @@ +// FrznChess MCU code +// © 2025 A.M. Rowsell + +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. +// This Source Code Form is "Incompatible With Secondary Licenses", as +// defined by the Mozilla Public License, v. 2.0. + +#include + +extern "C" int main(void) { + + while(1) { + } +}