generated from github/codespaces-blank
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a8961ec
Showing
25 changed files
with
454 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Build files | ||
/build-fx | ||
/build-cg | ||
/build-cg-push | ||
# /*.g1a | ||
# /*.g3a | ||
|
||
# Python bytecode | ||
__pycache__/ | ||
|
||
# Common IDE files | ||
*.sublime-project | ||
*.sublime-workspace | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Configure with [fxsdk build-fx] or [fxsdk build-cg], which provide the | ||
# toolchain file and module path of the fxSDK | ||
|
||
cmake_minimum_required(VERSION 3.15) | ||
project(Mines) | ||
|
||
include(GenerateG1A) | ||
include(GenerateG3A) | ||
include(Fxconv) | ||
find_package(Gint 2.9 REQUIRED) | ||
|
||
set(SOURCES | ||
src/main.c | ||
src/mines.c | ||
src/display.c | ||
# ... | ||
) | ||
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets | ||
set(ASSETS | ||
# ... | ||
) | ||
set(ASSETS_fx | ||
assets-fx/icons.png | ||
assets-fx/tiles.png | ||
assets-fx/title.png | ||
assets-fx/logo.png | ||
assets-fx/font3x5.png | ||
# ... | ||
) | ||
set(ASSETS_cg | ||
assets-cg/example.png | ||
# ... | ||
) | ||
|
||
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA) | ||
|
||
add_executable(mines ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}}) | ||
target_compile_options(mines PRIVATE -Wall -Wextra -Os) | ||
target_link_libraries(mines Gint::Gint) | ||
|
||
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) | ||
generate_g1a(TARGET mines OUTPUT "Mines.g1a" | ||
NAME "Mines" ICON assets-fx/icon.png) | ||
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50) | ||
generate_g3a(TARGET mines OUTPUT "MyAddin.g3a" | ||
NAME "MyAddin" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 asherhe | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<div align="center"> | ||
<img width="25%" src="assets-fx/splash.png" alt="fx-mines logo" /> | ||
</div> | ||
|
||
<h1 align="center">fx-mines</h1> | ||
|
||
A basic minesweeper clone for CASIO fx-9860G series calculators. | ||
|
||
This software was tested on a fx-9750GIII calculator, but it should ideally work on any fx-9860G series calculator. At present there is no support for color graphing calculators as I do not own one for development. | ||
|
||
## How to Play | ||
|
||
Press any key to exit the splash screen | ||
|
||
- Arrow keys to move the cursor. | ||
- `EXE` to clear a cell | ||
- `1` to flag/unflag a cell | ||
|
||
Uncovered cells will indicate the number of neighboring mines. The goal is to determine the positions of the mines and uncover all other cells. | ||
|
||
Upon winning/losing, press any key to play again. `MENU` can be used to return to main menu. | ||
|
||
## Building | ||
|
||
To build fx-Mines for yourself, first install [fxSDK](https://gitea.planet-casio.com/Lephenixnoir/fxsdk#installing), a versatile development kit for add-ins for both fx-9860G and CG50 series calculators. | ||
|
||
Afterwards, simply clone this repository and run | ||
|
||
``` | ||
$ fxsdk build-fx | ||
``` | ||
|
||
to build a G1A file for fx-9860G calculators. Executing this add-in is simply a matter of copying this file into the root directory of your calculator. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
icons.png: | ||
type: bopti-image | ||
name: img_icons | ||
|
||
tiles.png: | ||
type: bopti-image | ||
name: img_tiles | ||
|
||
title.png: | ||
type: bopti-image | ||
name: img_title | ||
|
||
logo.png: | ||
type: bopti-image | ||
name: img_title_logo | ||
|
||
font3x5.png: | ||
type: font | ||
name: font_3x5 | ||
charset: print | ||
grid.size: 4x6 | ||
grid.padding: 1 | ||
proportional: true |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef CONFIG_H | ||
#define CONFIG_H | ||
|
||
#define MINES_GRID_WIDTH 14 | ||
#define MINES_GRID_HEIGHT 9 | ||
|
||
#define MINES_TILE_WIDTH 6 | ||
#define MINES_TILE_HEIGHT 6 | ||
|
||
#define MINES_NUM_MINES 20 | ||
|
||
#endif // CONFIG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "display.h" | ||
|
||
#include <gint/display.h> | ||
#include "config.h" | ||
#include "mines.h" | ||
|
||
void render(struct MINES_Game *game) | ||
{ | ||
extern bopti_image_t img_icons, img_tiles; | ||
|
||
dclear(C_WHITE); | ||
|
||
drect(1, 1, 126, 62, C_BLACK); | ||
drect(3, 3, 92, 60, C_WHITE); // playfield | ||
drect(95, 3, 124, 60, C_WHITE); // sidebar | ||
|
||
// cursor | ||
dsubimage(5 + game->cursorX * MINES_TILE_WIDTH, 5 + game->cursorY * MINES_TILE_HEIGHT, | ||
&img_tiles, | ||
0, 0, | ||
MINES_TILE_WIDTH, MINES_TILE_HEIGHT, DIMAGE_NONE); | ||
|
||
// draw tiles | ||
for (int i = 0; i < MINES_GRID_WIDTH; ++i) | ||
for (int j = 0; j < MINES_GRID_HEIGHT; ++j) | ||
{ | ||
struct MINES_Tile *tile = &game->field[i][j]; | ||
unsigned int x = 5 + i * MINES_TILE_WIDTH, y = 5 + j * MINES_TILE_HEIGHT; | ||
if (game->over && tile->isMine) | ||
dsubimage(x, y, | ||
&img_tiles, | ||
game->win ? 4 * MINES_TILE_WIDTH : 3 * MINES_TILE_WIDTH, 0, | ||
MINES_TILE_WIDTH, MINES_TILE_HEIGHT, DIMAGE_NONE); | ||
else if (tile->isFlagged) | ||
dsubimage(x, y, | ||
&img_tiles, | ||
2 * MINES_TILE_WIDTH, 0, | ||
MINES_TILE_WIDTH, MINES_TILE_HEIGHT, DIMAGE_NONE); | ||
else if (tile->isCovered) | ||
dsubimage(x, y, | ||
&img_tiles, | ||
MINES_TILE_WIDTH, 0, | ||
MINES_TILE_WIDTH, MINES_TILE_HEIGHT, DIMAGE_NONE); | ||
else if (tile->neighbors) | ||
dsubimage(x, y, | ||
&img_tiles, | ||
(tile->neighbors - 1) * MINES_TILE_WIDTH, MINES_TILE_HEIGHT, | ||
MINES_TILE_WIDTH, MINES_TILE_HEIGHT, DIMAGE_NONE); | ||
} | ||
|
||
// write info | ||
dsubimage(97, 5, &img_icons, 1, 1, 5, 5, DIMAGE_NONE); | ||
dtext(103, 5, C_BLACK, "MINES"); | ||
|
||
dsubimage(97, 23, &img_icons, 1, 1, 5, 5, DIMAGE_NONE); | ||
dprint(105, 23, C_BLACK, "%d", game->mines); | ||
dsubimage(97, 33, &img_icons, 8, 1, 5, 5, DIMAGE_NONE); | ||
dprint(105, 33, C_BLACK, "%d", game->flags); | ||
|
||
dupdate(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef DISPLAY_H | ||
#define DISPLAY_H | ||
|
||
#include "mines.h" | ||
|
||
void render(struct MINES_Game *game); | ||
|
||
#endif // DISPLAY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <gint/display.h> | ||
#include <gint/keyboard.h> | ||
#include <gint/drivers/keydev.h> | ||
#include <stdlib.h> | ||
#include <time.h> | ||
#include "mines.h" | ||
#include "display.h" | ||
|
||
int main(void) | ||
{ | ||
extern bopti_image_t img_title, img_title_logo; | ||
extern font_t font_3x5; | ||
|
||
srand(clock()); | ||
dfont(&font_3x5); | ||
|
||
struct MINES_Game game; | ||
|
||
dimage(47, 5, &img_title_logo); | ||
dimage(25, 38, &img_title); | ||
dupdate(); | ||
getkey(); | ||
|
||
while (true) | ||
{ | ||
MINES_InitGame(&game); | ||
render(&game); | ||
|
||
while (!game.over) | ||
{ | ||
int key = getkey().key; | ||
enum MINES_Input input = NONE; | ||
switch (key) | ||
{ | ||
case KEY_UP: | ||
input = CURSOR_UP; | ||
break; | ||
case KEY_DOWN: | ||
input = CURSOR_DOWN; | ||
break; | ||
case KEY_LEFT: | ||
input = CURSOR_LEFT; | ||
break; | ||
case KEY_RIGHT: | ||
input = CURSOR_RIGHT; | ||
break; | ||
case KEY_EXE: | ||
input = CLEAR_CELL; | ||
break; | ||
case KEY_1: | ||
input = TOGGLE_FLAG; | ||
break; | ||
default: | ||
break; | ||
} | ||
if (input != NONE) | ||
{ | ||
MINES_InputGame(&game, input); | ||
render(&game); | ||
} | ||
} | ||
getkey(); | ||
} | ||
|
||
return 1; | ||
} |
Oops, something went wrong.