Skip to content

Commit

Permalink
Polishing docview menus
Browse files Browse the repository at this point in the history
  • Loading branch information
ifilot committed Sep 15, 2024
1 parent cb12927 commit 026ce49
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 67 deletions.
20 changes: 10 additions & 10 deletions src/ABOUT.TXT
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
|=====================|
| ABOUT: CX-16 KAKURO |
| VERSION: 0.2.0 |
|=====================|
ABOUT: CX-16 KAKURO

VERSION: 0.3.0

Kakuro for the Commander X16 is developed by Ivo Filot. The source code for this
game can be found on its Github page: https://github.com/ifilot/cx16-kakuro/.
Kakuro for the Commander X16 is developed by Ivo Filot. The source code for
this game can be found on its Github page:
https://github.com/ifilot/cx16-kakuro/.

The source code is available under the GNU General Public License version 3.
The source code is available under the GNU General Public License version 3.

---------------------------------
PRESS ESCAPE TO LEAVE THIS SCREEN
---------------------------------
---------------------------------
PRESS ESCAPE TO LEAVE THIS SCREEN
---------------------------------
95 changes: 48 additions & 47 deletions src/HELP.TXT
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
======
KAKURO
======
KAKURO

Introduction
------------
Kakuro is a logic-based number puzzle game, often described as a cross
between a crossword and Sudoku. In this game, players fill a grid with
digits from 1 to 9, with the objective of matching the sum of numbers in
each row or column to a given target. However, no number can be repeated
within a single sum. Each clue is represented as a small number in a black
cell, dictating the sum of the digits to be placed in the adjacent white
cells.

Introduction
------------
Kakuro is a logic-based number puzzle game, often described as a cross between a
crossword and Sudoku. In this game, players fill a grid with digits from 1 to 9,
with the objective of matching the sum of numbers in each row or column to a
given target. However, no number can be repeated within a single sum. Each clue
is represented as a small number in a black cell, dictating the sum of the
digits to be placed in the adjacent white cells.
Rules
-----
* Kakuro is played on a grid of blank and black cells, where the goal is to
fill in the blank cells with numbers. Some black cells have "clues" (a
small number in the corner) indicating the sum of the numbers that must
appear in the consecutive blank cells in that row or column.
* Only the numbers 1 through 9 can be used to fill the blank cells.
* Within a "run" (a sequence of consecutive blank cells either in a row or a
column), the numbers cannot repeat. Each number within a run must be
unique.
* The numbers in a run must add up to the sum indicated by the clue in the
black cell.
* Each valid combination of numbers (in a run) must be used only once in the
entire puzzle. This means that no two different runs with the same number
of blank cells can have identical number combinations that sum to the same
value.

Rules
-----
* Kakuro is played on a grid of blank and black cells, where the goal is to fill
in the blank cells with numbers. Some black cells have "clues" (a small number
in the corner) indicating the sum of the numbers that must appear in the
consecutive blank cells in that row or column.
* Only the numbers 1 through 9 can be used to fill the blank cells.
* Within a "run" (a sequence of consecutive blank cells either in a row or a
column), the numbers cannot repeat. Each number within a run must be unique.
* The numbers in a run must add up to the sum indicated by the clue in the black
cell.
* Each valid combination of numbers (in a run) must be used only once in the
entire puzzle. This means that no two different runs with the same number of
blank cells can have identical number combinations that sum to the same value.
Puzzles
-------
* The game contains (currently) 96 puzzles of various sizes and difficulty
levels. The size and difficulty are indicated by the number (6-10) in the
menu screen and the number of stars, respectively.
* If a puzzle has been opened before, but not completed, it is colored in a
light green color. Completed puzzles are colored in a dark green shade.
The game will remember which puzzles have been completed before. You can
always choose to play a completed game again.

Puzzles
-------
* The game contains (currently) 96 puzzles of various sizes and difficulty
levels. The size and difficulty are indicated by the number (6-10) in the
menu screen and the number of stars, respectively.
* If a puzzle has been opened before, but not completed, it is colored in a
light green color. Completed puzzles are colored in a dark green shade. The
game will remember which puzzles have been completed before. You can always
choose to play a completed game again.
Gameplay
--------
* Move your mouse cursor over the cell you want to fill and press a digit
(1-9) on your keyboard to enter a number.
* Once all the cells are correctly filled, the game will notify you
automatically.
* If you'd like to validate your progress during the game, click the
green/red button at the top-right corner of the screen.
* To exit the game, click the 'X' button or press the <ESCAPE> key.

Gameplay
--------
* Move your mouse cursor over the cell you want to fill and press a digit (1-9) on
your keyboard to enter a number.
* Once all the cells are correctly filled, the game will notify you
automatically.
* If you'd like to validate your progress during the game, click the green/red
button at the top-right corner of the screen.
* To exit the game, click the 'X' button or press the <ESCAPE> key.

---------------------------------
PRESS ESCAPE TO LEAVE THIS SCREEN
---------------------------------
---------------------------------
PRESS ESCAPE TO LEAVE THIS SCREEN
---------------------------------
20 changes: 17 additions & 3 deletions src/docview.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,22 @@ void docview_init_screen() {
*
*/
void docview_clear_screen() {
fill_layer(TILE_BACKGROUND, LAYER0, PALETTEBYTE, 64, 64);
fill_layer(0x20, LAYER1, 0x00, 64, 128);
uint8_t i;

fill_layer(TILE_BACKGROUND, LAYER1, PALETTEBYTE, 64, 128);

// window background
for(i=2; i<=27; i++) {
set_tile(i, 1, 0x04, 0x00, LAYER0);
fill_line(0x06, LAYER0, 0x00, i, 2, 64, 36);
set_tile(i, 38, 0x04, MIRROR_X, LAYER0);
}

// window title
set_tile(1, 1, 0x0B, 0x00, LAYER0);
fill_line(0x03, LAYER0, 0x00, 1, 2, 64, 36);
fill_line(0x05, LAYER0, 0x00, 28, 2, 64, 36);
set_tile(1, 38, 0x02, MIRROR_X, LAYER0);
}

/**
Expand Down Expand Up @@ -113,7 +127,7 @@ void docview_load_file(const char* filename) {
*/
void docview_show_file() {
uint8_t x = 0;
uint8_t y = 0;
uint8_t y = 4;
uint8_t *s = (uint8_t*)(BANKED_RAM);
uint32_t map_base_addr = MAPBASE1 + (y << 7 + x) * 2;

Expand Down
10 changes: 3 additions & 7 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,14 @@ void menu_init() {
// window background
for(i=2; i<=27; i++) {
set_tile(i, 1, 0x04, 0x00, LAYER0);
for(j=2; j<=37; j++) {
set_tile(i, j, 0x06, 0x00, LAYER0);
}
fill_line(0x06, LAYER0, 0x00, i, 2, 64, 36);
set_tile(i, 38, 0x04, MIRROR_X, LAYER0);
}

// window title
set_tile(1, 1, 0x0B, 0x00, LAYER0);
for(j=2; j<=37; j++) {
set_tile(1, j, 0x03, 0x00, LAYER0);
set_tile(28, j, 0x05, 0x00, LAYER0);
}
fill_line(0x03, LAYER0, 0x00, 1, 2, 64, 36);
fill_line(0x05, LAYER0, 0x00, 28, 2, 64, 36);
set_tile(1, 38, 0x02, MIRROR_X, LAYER0);

if((menu_page+1) < MAX_PAGES) {
Expand Down
28 changes: 28 additions & 0 deletions src/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,34 @@ void fill_layer(uint8_t tile_id, uint8_t layer, uint8_t b2, uint8_t height, uint
}
}

/**
* @brief Fill line with tiles of the same type
*
* @param tile_id background tile index
* @param layer which layer to fill
* @param b2 which tile info to use
* @param height height of the map
* @param width width of the map
* @param nrtiles number of tiles
*/
void fill_line(uint8_t tile_id, uint8_t layer, uint8_t b2,
uint8_t y, uint8_t x, uint8_t width, uint8_t nrtiles) {
uint8_t i;
uint32_t map_base_addr;

// set background tiles
map_base_addr = (layer == 0 ? MAPBASE0 : MAPBASE1);
map_base_addr += (y * width + x) << 1;
VERA.address = map_base_addr;
VERA.address_hi = map_base_addr >> 16;
VERA.address_hi |= 0b10000;

for (i=0; i<nrtiles; i++) {
VERA.data0 = tile_id; // background tile
VERA.data0 = b2; // palette offset data
}
}

/**
* @brief Set a tile on LAYER1
*
Expand Down
13 changes: 13 additions & 0 deletions src/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ void clear_screen();
*/
void fill_layer(uint8_t tile_id, uint8_t layer, uint8_t b2, uint8_t height, uint8_t width);

/**
* @brief Fill line with tiles of the same type
*
* @param tile_id background tile index
* @param layer which layer to fill
* @param b2 which tile info to use
* @param height height of the map
* @param width width of the map
* @param nrtiles number of tiles
*/
void fill_line(uint8_t tile_id, uint8_t layer, uint8_t b2,
uint8_t y, uint8_t x, uint8_t width, uint8_t nrtiles);

/**
* @brief Set a tile on LAYER1
*
Expand Down

0 comments on commit 026ce49

Please sign in to comment.