Skip to content

Commit

Permalink
v0.81.5 | 2024/05/13 14:12 | Deprecated the u8, i32, etc types. In th…
Browse files Browse the repository at this point in the history
…e future, I want to see if I can port Super-Sweeper to Enscripten or something so it can be run through a web browswer.
  • Loading branch information
ZERICO2005 committed May 13, 2024
1 parent 688a896 commit e87b767
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 71 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ set(LIB_PATH "${TOOLCHAIN_PATH}/lib")

set(SRC_DIR "./src")
set(SRC_LCD_DIR "./src-lcd")
set(IMGUI_DIR "./imgui")
# set(IMGUI_DIR "./imgui")

set(PROJECT_NAME "Super-Sweeper-Windows")
project(${PROJECT_NAME})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "./bin")

# Compiler
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)

# Set C and C++ standards
set(CMAKE_C_STANDARD 23)
Expand All @@ -26,7 +26,8 @@ set(CMAKE_CXX_STANDARD 17)
find_package(SDL2 REQUIRED)

file(GLOB SRC_FILES "${SRC_DIR}/*.c" "${SRC_LCD_DIR}/*.c")
file(GLOB IMGUI_FILES "${IMGUI_DIR}/*.c" "${IMGUI_DIR}/*.cpp")
# file(GLOB IMGUI_FILES "${IMGUI_DIR}/*.c" "${IMGUI_DIR}/*.cpp")

# Create an executable
add_executable(${PROJECT_NAME} ${SRC_FILES} ${IMGUI_FILES})

Expand Down
16 changes: 4 additions & 12 deletions src-lcd/x86_Common_Def.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,13 @@
#define PLATFORM_WINDOWS
//#define PLATFORM_LINUX

// #ifdef __EMSCRIPTEN__
// #include <emscripten.h>
// #endif

typedef signed _BitInt(24) int24_t;
typedef unsigned _BitInt(24) uint24_t;

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint24_t u24;
typedef uint32_t u32;
typedef uint64_t u64;

typedef int8_t i8;
typedef int16_t i16;
typedef int24_t i24;
typedef int32_t i32;
typedef int64_t i64;

typedef float fp32;
typedef double fp64;

Expand Down
24 changes: 6 additions & 18 deletions src/Common_Def.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

#define PROGRAM_V_MAJOR 0
#define PROGRAM_V_MINOR 81
#define PROGRAM_V_PATCH 4
#define PROGRAM_V_PATCH 5

#define PLATFORM_TI84CE
//#define PLATFORM_X86
//#define PLATFORM_TI84CE
#define PLATFORM_X86

//#define DEBUG_FRAMERATE_COUNTER // Shows FPS and Frame-Time
//#define DEBUG_FRAME_SHIFT // Use the numberpad to move the screen around
Expand Down Expand Up @@ -92,21 +92,9 @@
#include "x86_Common_Def.h"
#include "x86_ti84ce.h"
#include "x86_Render.h"
#endif

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;

typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;

#ifdef PLATFORM_TI84CE
typedef uint24_t u24;
typedef int24_t i24;
// #ifdef __EMSCRIPTEN__
// #include <emscripten.h>
// #endif
#endif


Expand Down
38 changes: 19 additions & 19 deletions src/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ int24_t flags = 54; //S16
uint24_t cleared = 0; //U16
uint8_t win = 1;
uint24_t flagColor = 1;
u8 cheater = 0;
u8 autoLoss = 0;
uint8_t cheater = 0;
uint8_t autoLoss = 0;

int24_t score = 0;

Expand Down Expand Up @@ -60,25 +60,25 @@ uint8_t fontSize = 7;
/* Graphical Backend */

/* Settings */
u8 swapAlphaSecondBind = 0;
uint8_t swapAlphaSecondBind = 0;
//Game Settings
u8 safeGuess = 2; //off,on,extra
u8 chording = 1; //off,on
u8 autoSolver = 0; //off,manual,automatic
uint8_t safeGuess = 2; //off,on,extra
uint8_t chording = 1; //off,on
uint8_t autoSolver = 0; //off,manual,automatic

//Video Settings
uint24_t displayMode = 0; //Originally videoMode
u8 accessMode = 0; //Increases Readability, Disables Quake
u8 fadeEffect = 1; //off,static,dynamic //Refactor to bgEffects
u8 fpsCounter = 1; //Debug thing
u8 cursorGraphic = 0;
u8 movieIntro = 1;
uint8_t accessMode = 0; //Increases Readability, Disables Quake
uint8_t fadeEffect = 1; //off,static,dynamic //Refactor to bgEffects
uint8_t fpsCounter = 1; //Debug thing
uint8_t cursorGraphic = 0;
uint8_t movieIntro = 1;

uint32_t FPS = (32768 / 960); //Set to 0 for unlimited
uint32_t fpsT = 120; //temp value

//Data Settings
u8 autoSaveMax = 0;
uint8_t autoSaveMax = 0;

/* Settings */

Expand Down Expand Up @@ -112,7 +112,7 @@ const uint8_t hiddenText[43] = { //SuperSweeper V:X.XX.X ZERICO2005 YYYY/MM/DD
(PROGRAM_V_MAJOR),34,((PROGRAM_V_MINOR) / 10),((PROGRAM_V_MINOR) % 10),34,PROGRAM_V_PATCH, /* Version */
32,89,68,81,72,66,78,2,0,0,5,32, /* Text */
2,0,2,4,36, /* Year */
0,2,36,1,4, /* Month Day */
0,5,36,1,3, /* Month Day */
};
const uint8_t hiddenTextLength = 43;

Expand Down Expand Up @@ -252,15 +252,15 @@ uint8_t findColor1555(uint16_t c) {
g += (c & 0x8000) ? 1 : 0;
i8 b = (c & 0x001F);
u8 best = 0x00;
u16 low = 0xFFFF;
for (u8 i = 0; i < 0xF0; i++) { //Avoids temp color zone
u16 col = paletteRAM[i];
uint8_t best = 0x00;
uint16_t low = 0xFFFF;
for (uint8_t i = 0; i < 0xF0; i++) { //Avoids temp color zone
uint16_t col = paletteRAM[i];
i8 r0 = (col & 0x7C00) >> 10;
i8 g0 = (col & 0x03E0) >> 4;
g0 += (c & 0x8000) ? 1 : 0;
i8 b0 = (col & 0x001F);
u16 dif = (abs(r - r0) * abs(r - r0)) + (abs(g - g0) * abs(g - g0)) + (abs(b - b0) * abs(b - b0));
uint16_t dif = (abs(r - r0) * abs(r - r0)) + (abs(g - g0) * abs(g - g0)) + (abs(b - b0) * abs(b - b0));
if (dif < low) {
low = dif;
best = i;
Expand All @@ -269,7 +269,7 @@ uint8_t findColor1555(uint16_t c) {
return best;
}
uint8_t findColor888(uint8_t r, uint8_t g, uint8_t b) {
u8 i = (g & 0x04) >> 2;
uint8_t i = (g & 0x04) >> 2;
r >>= 3;
g >>= 2;
b >>= 3;
Expand Down
24 changes: 12 additions & 12 deletions src/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ extern int24_t flags; //S16
extern uint24_t cleared; //U16
extern uint8_t win;
extern uint24_t flagColor;
extern u8 cheater;
extern u8 autoLoss;
extern uint8_t cheater;
extern uint8_t autoLoss;

extern int24_t score;

Expand Down Expand Up @@ -65,25 +65,25 @@ extern uint8_t fontSize;
/* Graphical Backend */

/* Settings */
extern u8 swapAlphaSecondBind;
extern uint8_t swapAlphaSecondBind;
//Game Settings
extern u8 safeGuess; //off,on,extra
extern u8 chording; //off,on
extern u8 autoSolver; //off,manual,automatic
extern uint8_t safeGuess; //off,on,extra
extern uint8_t chording; //off,on
extern uint8_t autoSolver; //off,manual,automatic

//Video Settings
extern uint24_t displayMode; //Originally videoMode
extern u8 accessMode; //Increases Readability, Disables Quake
extern u8 fadeEffect; //off,static,dynamic //Refactor to bgEffects
extern u8 fpsCounter; //Debug thing
extern u8 cursorGraphic;
extern u8 movieIntro;
extern uint8_t accessMode; //Increases Readability, Disables Quake
extern uint8_t fadeEffect; //off,static,dynamic //Refactor to bgEffects
extern uint8_t fpsCounter; //Debug thing
extern uint8_t cursorGraphic;
extern uint8_t movieIntro;

extern uint32_t FPS; //Set to 0 for unlimited
extern uint32_t fpsT; //temp value

//Data Settings
extern u8 autoSaveMax;
extern uint8_t autoSaveMax;

#ifdef PLATFORM_TI84CE
extern uint8_t darkMode;
Expand Down
6 changes: 3 additions & 3 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ void fadeColor() {
}
/* Fade Effect */

u16 getNumber(u16 index) {
uint16_t getNumber(uint16_t index) {
if (boxMax[index] < 255) {
return *(uint8_t*)boxPointer[index];
} else {
return *(uint16_t*)boxPointer[index];
}
};
void setNumber(u16 index, u16 value) {
void setNumber(uint16_t index, uint16_t value) {
if (boxMax[index] < 255) {
*(uint8_t*)boxPointer[index] = (uint8_t)value;
} else {
Expand Down Expand Up @@ -272,7 +272,7 @@ void slideHL() {
void dial(uint16_t boxOffset, uint8_t boxRow) { //uint8_t src, uint8_t des
uint16_t box = boxOffset + boxRow;
uint24_t yCord = 20 + (24 * row);
u16 value = getNumber(box);
uint16_t value = getNumber(box);
if ((kb_Data[7] & kb_Right)) { //Right
if (value == boxMax[box]) {
value = boxMin[box];
Expand Down
4 changes: 2 additions & 2 deletions src/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ void fadeSet();
void fadeColor();
/* Fade Effect */

u16 getNumber(u16 index);
uint16_t getNumber(uint16_t index);

void setNumber(u16 index, u16 value);
void setNumber(uint16_t index, uint16_t value);

void buildMenu();

Expand Down
2 changes: 1 addition & 1 deletion src/mineSweeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void buildSeg7(
void quake();

enum expressionCode { eHAPPY = 0, eSAD = 1, eNULL = 2, eCHORD = 3, eNORMAL = 4, eSHADES = 5, eXX = 6, eSLEEP = 7 };
void expression(unsigned char e); //Updates the smiley face
void expression(uint8_t e); //Updates the smiley face

void flash(); //uint8_t x

Expand Down

0 comments on commit e87b767

Please sign in to comment.