Initial commit of MPLABX version

This commit is contained in:
A.M. Rowsell 2025-07-30 21:48:16 -04:00
commit d80b03bdf0
Signed by untrusted user who does not match committer: amr
GPG key ID: E0879EDBDB0CA7B1
10 changed files with 251 additions and 0 deletions

39
.gitignore vendored Normal file
View file

@ -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

25
Board.cpp Normal file
View file

@ -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;
}

31
Board.hpp Normal file
View file

@ -0,0 +1,31 @@
/*
* File: Board.hpp
* Author: amr
*
* Created on July 30, 2025, 9:20 PM
*/
#ifndef BOARD_HPP
#define BOARD_HPP
#include <vector>
#include <cstdint>
#include "Piece.hpp"
class Piece;
class Board {
private:
std::vector<std::vector<Piece *>> 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

13
Game.cpp Normal file
View file

@ -0,0 +1,13 @@
/*
* File: Game.cpp
* Author: amr
*
* Created on July 30, 2025, 9:22 PM
*/
#include "Game.hpp"
Game::Game() {
}

29
Game.hpp Normal file
View file

@ -0,0 +1,29 @@
/*
* File: Game.hpp
* Author: amr
*
* Created on July 30, 2025, 9:22 PM
*/
#ifndef GAME_HPP
#define GAME_HPP
#include <stdint.h>
#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

13
NeoPixel.cpp Normal file
View file

@ -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;
}

25
NeoPixel.hpp Normal file
View file

@ -0,0 +1,25 @@
/*
* File: NeoPixel.hpp
* Author: amr
*
* Created on July 30, 2025, 9:35 PM
*/
#ifndef NEOPIXEL_HPP
#define NEOPIXEL_HPP
#include <stdint.h>
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

15
Piece.cpp Normal file
View file

@ -0,0 +1,15 @@
/*
* File: Piece.cpp
* Author: amr
*
* Created on July 30, 2025, 9:21 PM
*/
#include "Piece.hpp"
std::vector<std::pair<int, int>> King::getLegalMoves(int x, int y, const Board& board) const {
std::vector<std::pair<int, int>> moveList;
// calculate legal moves somehow
return moveList;
}

45
Piece.hpp Normal file
View file

@ -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 <stdint.h>
#include <utility>
#include <vector>
#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<std::pair<int, int>> 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<std::pair<int, int>> getLegalMoves(int x, int y, const Board &board) const override;
};
#endif // PIECE_HPP

16
main.cpp Normal file
View file

@ -0,0 +1,16 @@
// FrznChess MCU code
// © 2025 A.M. Rowsell <amr@frzn.dev>
// 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 <xc.h>
extern "C" int main(void) {
while(1) {
}
}