Commit Graph

174 Commits

Author SHA1 Message Date
Xavier Del Campo Romero 4d4b92c2b6 font: implement font_dim 2022-06-29 00:27:33 +02:00
Xavier Del Campo Romero c538eb1b90 Deprecate memset(3) for zero-init 2022-06-27 21:56:43 +02:00
Xavier Del Campo Romero d28a748521 human_player_gui.c: fix segfault when selecting one unit
Checking against `sel` is just plain wrong, since it always expected to
be non-NULL, since `h->sel` is an array defined in `struct
human_player`. Instead, `sel->d.i` is the pointer that should be
checked.
2022-06-27 21:43:32 +02:00
Xavier Del Campo Romero bac711c5b3 human_player: deprecate memset(3) for zero-init 2022-06-26 23:42:48 +02:00
Xavier Del Campo Romero 88713427f7 human_player.c: reset deselected instances 2022-06-26 23:42:48 +02:00
Xavier Del Campo Romero 272fd53810 Fix hp bar not being displayed when carrying 2022-06-26 23:42:34 +02:00
Xavier Del Campo Romero 231bc704ff ps1/heap.c: bump heap size 2022-06-26 21:51:51 +02:00
Xavier Del Campo Romero 19d9a571af Implement main menu 2022-06-26 21:51:47 +02:00
Xavier Del Campo Romero c0887a44fb terrain: fix wrong rendering
The older implementation would leave empty areas on the right side of
the screen.
2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero 50b362db39 font: deprecate font_printf
This function is no longer needed since `gui` was revamped.
2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero aea50395c5 Revamp gui component
`gui` was tighly coupled to game logic, and could not be extended for
other purposes. Therefore, a generic GUI implementation, loosely
inspired by well-known GUI frameworks such as GTK, is now provided, with
the following properties:

- Does not depend on dynamic or static memory allocation, only automatic
(i.e., stack) memory allocation required.
- Portable among existing implementations.
- Simple to extend.
- Tiny memory footprint.

`gui` is now composed by GUI elements that can be chained to form a tree
structure. This is useful e.g.: to calculate X/Y coordinates for a given
GUI element given its parent(s).

This commit also refactors the older implementation, moving
game-specific logic into `player` and making use of the new component.
2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero aa047f3b95 font: add font_puts 2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero fe7e006a31 peripheral.c: initialize common members only
Other members will be initialized according to peripheral configuration.
2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero b53db6f005 Deprecate memset(3) over C99 compound literals for zero-init
Using memset(3) does not ensure pointers are assigned to NULL for all
platforms.
2022-06-26 20:00:27 +02:00
Xavier Del Campo Romero cbe7ca6fca player: limit data sizes for resources and population
- All platforms should allow for the same resources.
- Population is not expected to exceed UCHAR_MAX on any platform.
2022-06-26 19:58:46 +02:00
Xavier Del Campo Romero 0b94264a7e camera: implement fixed cursor movement
On platforms with PERIPHERAL_TYPE_PAD, navigating through menus and
options can be cumbersome if moving the cursor freely around the
screen.

Therefore, this commit instead defines a list of (X, Y) coordinates that
the cursor can jump to. The implementation also attempts to guess which
direction the cursor should jump to for the previous/next point, and
hence determine which button should be pressed by the user.
2022-06-24 17:45:50 +02:00
Xavier Del Campo Romero 904d9e933e camera.c: refactor cursor_init
So that uninitialized members are set to 0.
2022-06-24 17:45:14 +02:00
Xavier Del Campo Romero 56107cb516 peripheral: provide common actions
Whereas some actions are context-specific (e.g.: selecting a player),
some are context-independent and can be executed for all screens
(e.g.: exiting the game).
2022-06-24 17:28:38 +02:00
Xavier Del Campo Romero 435629f40b README.md: add copyright notice 2022-06-24 17:20:05 +02:00
Xavier Del Campo Romero 67c3d99446 README.md: update according to current status 2022-06-24 17:19:27 +02:00
Xavier Del Campo Romero 2a9290514f cmake/ps1.cmake: use add_library for libpsx.a 2022-06-19 03:51:36 +02:00
Xavier Del Campo Romero 1133af2f9a Deprecate <TARGET>_BUILD in favor of CMAKE_TOOLCHAIN_FILE 2022-06-19 03:09:28 +02:00
Xavier Del Campo Romero 08c26de540 camera: remove dependency against terrain
This will allow using camera for purposes other than showing the game
map.
2022-06-12 23:19:03 +02:00
Xavier Del Campo Romero 5226dc4663 Split peripheral-related logic into its own component
This has several advantages:

- `camera` no longer needs to define public functions for each
peripheral type.
- Peripheral-related is now no longer tighly coupled to human_player,
so peripheral logic can be reused elsewhere e.g.: on menus.
- Makes camera_update_touch consistent compared to equivalent functions,
since now `pan` has now been moved to `camera` (as it should be).
2022-06-12 23:18:57 +02:00
Xavier Del Campo Romero b2af4c6bcc CMakeLists.txt: limit libraries linked to by ${PROJECT_NAME}
Old behaviour was linking to all components, but main.c currently only
needs a few of them.
2022-06-12 00:00:56 +02:00
Xavier Del Campo Romero 324ac3b807 sdl-1.2/sound.c: use SDL_WasInit 2022-06-11 23:42:30 +02:00
Xavier Del Campo Romero 48428c2e43 sdl-1.2: return to original dimensions on fullscreen exit 2022-06-11 23:42:30 +02:00
Xavier Del Campo Romero 6f74cbd20b Implement button component 2022-06-11 23:42:27 +02:00
Xavier Del Campo Romero 46fec13fcb res: add btn_{left,mid,right} 2022-06-11 23:41:56 +02:00
Xavier Del Campo Romero 5eb4b2e213 res/CMakeLists.txt: do not use transparency for sel_mid_v 2022-06-11 23:11:49 +02:00
Xavier Del Campo Romero 13f6bd0043 README.md: reflect current status 2022-06-08 01:00:32 +02:00
Xavier Del Campo Romero db5f21e3b4 win9x.cmake: remove unneeded dependencies 2022-06-08 00:36:26 +02:00
Xavier Del Campo Romero c607077c22 win9x.cmake: use target commands for SDL and SDL_mixer
Since libSDL.a and libSDL_mixer.a are compiled separately from this
project, some hacks had been used to get the build running. However,
this approach did not make proper use of target-level properties, which
are encouraged according to modern CMake standards over global-level
commands such as include_directories() or link_libraries().

OTOH, Win32 dependencies were being imported using link_libraries(), but
they in fact are SDL dependencies, so target_link_libraries() can be
used instead.
2022-06-08 00:36:26 +02:00
Xavier Del Campo Romero 7a92eb3eb6 pad/CMakeLists.txt: add missing call to target_link_libraries() 2022-06-08 00:36:23 +02:00
Xavier Del Campo Romero 0167e527cd CMakeLists.txt: assume native build by default
This has been decided to make the de-facto standard CMake build process
(shown below) possible.

$ mkdir build
$ cd build/
$ cmake ..
2022-06-08 00:25:17 +02:00
Xavier Del Campo Romero bf3ad3f9e4 CMakeLists.txt: build host tools as ExternalProject 2022-06-08 00:21:18 +02:00
Xavier Del Campo Romero 6712c8ef22 CMakeLists.txt: move target-specific logic away 2022-06-07 23:32:32 +02:00
Xavier Del Campo Romero 7b8c0725f0 Split CMakeLists.txt into platform-specific *.cmake 2022-05-24 22:20:04 +02:00
Xavier Del Campo Romero d07b682c9b Make gfx_draw return int 2022-05-24 22:20:04 +02:00
Xavier Del Campo Romero f34113de51 Use realloc(3) directly
It is simply not true realloc(3) cannot be used with NULL pointers.
2022-05-24 22:20:04 +02:00
Xavier Del Campo Romero 0bcea86763 font.c: avoid several va_list in favor of large buffer 2022-05-24 22:20:04 +02:00
Xavier Del Campo Romero 951a310989 Allow systems without sound support 2022-05-24 22:20:02 +02:00
Xavier Del Campo Romero 3d77d3a8aa Remove unused minor stuff 2022-03-31 07:30:14 +02:00
Xavier Del Campo Romero adfa26d1f9 resource.c: decouple collbox from sprite dimensions 2022-03-31 07:29:16 +02:00
Xavier Del Campo Romero 71a2714fe6 Fix exit condition 2022-03-31 07:27:22 +02:00
Xavier Del Campo Romero ce8b1c43ca Implement touch controls 2022-03-31 06:50:33 +02:00
Xavier Del Campo Romero 1950fe7b06 Implement sub-tile collboxes
These will be later used by the pathfinding algorithm.
2022-03-30 08:28:47 +02:00
Xavier Del Campo Romero 06056a9b5e Rename MAP_{X|Y} to MAP_{W|H} 2022-03-30 08:23:15 +02:00
Xavier Del Campo Romero cbb2dc1a0a camera: implement mouse support 2022-03-30 08:20:21 +02:00
Xavier Del Campo Romero eccba7c2af Move CURSOR_{WIDTH|HEIGHT} to library scope 2022-03-30 08:20:21 +02:00