aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: f0ee3acc52b8f07b5237bcf8845b45b89cfe3ad8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# `jancity`

## Overview

`jancity` is a cross-platform, tile-based sandbox video game.

![Screenshot](jancity.png)

Mostly written during the Global Game Jam 2024 event, reusing its engine
from [`rts`](https://gitea.privatedns.org/xavi/rts).

## Platforms

The following platforms are either supported or support is expected in
the future:

- Sony® PlayStation® 1, using a forked version of
[PSXSDK](https://git.disroot.org/xavi92/psxsdk).
- Microsoft® Win9x, using a `i386-mingw32` cross-toolchain and SDL-1.2.
A `i386-mingw32` cross-toolchain must be already available on the
system.
- POSIX-compliant operating systems such as GNU/Linux® or *BSD, using
SDL-1.2 (if available).
- Possibly, modern Microsoft® Windows® versions, too (currently
untested).

## Design goals

- Keep source code as simple and clean as possible.
- Keep platform-specific code separated so common code can be shared
between platforms without modifications.
- Use C99 features for better portability.
- Use modern CMake features for a simplified build process and
availability of the `compile_commands.json` database.
- Implement any multiplayer capabilities provided by the platform.
- Support a wide range of screen resolutions, even portrait resolutions
typically used by mobile platforms.
- And, above all, provide a fun game that can run even on low-end
hardware.

## Building from source

### Native build

A native version of `jancity` can be built using the typical CMake build
process:

```sh
cmake -B build
cmake --build build
```

#### Dependencies

##### Ubuntu

```sh
apt install libsdl-gfx1.2-dev libsdl-mixer1.2-dev libsdl1.2-dev libenet-dev
```

### Cross-compilation

[`CMAKE_TOOLCHAIN_FILE`](https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html)
can be used to set up the cross-toolchain. Files labeled as
`cmake/*-toolchain.cmake` can be used as values.

#### Sony® PlayStation® 1

For example, the Sony® PlayStation® 1 version can be built using:

```sh
cmake -B build \
    -DCMAKE_TOOLCHAIN_FILE=cmake/ps1-toolchain.cmake \
    -DVIDEO_MODE=VMODE_PAL # VMODE_NTSC can be otherwise used
cmake --build build
```

This will generate a `.bin`/`.cue` file pair in `build` that can be
played on an emulator or burnt into a CD-r in order to play the game
on real hardware.

A custom version of [PSXSDK](https://git.disroot.org/xavi92/psxsdk) is
required. Once built, the installation prefix must be stored into an
environment variable called `PSXSDK_PATH`.

#### Microsoft® Win9x

```sh
SDLDIR=<sdl-prefix> \
    SDLMIXERDIR=<sdl_mixer-prefix> \
    SDLGFXDIR=<sdl_gfx-prefix> \
    ENETDIR=<enet-prefix> \
    cmake -B build -DCMAKE_TOOLCHAIN_FILE=cmake/win9x-toolchain.cmake
cmake --build build
```

Where:

- `SDLDIR` is the path to the cross-compiled version for `SDL-1.2`, which
would correspond to `./configure --prefix=$SDLDIR` used when building
`SDL-1.2`.
- `SDLMIXERDIR` is the path to the cross-compiled version for `SDL_mixer`,
which would correspond to `./configure --prefix=$SDLMIXERDIR` used in
building `SDL_mixer`.
- `SDLGFXDIR` is the path to the cross-compiled version for `SDL_gfx`,
which would correspond to `./configure --prefix=$SDLGFXDIR` used in
building `SDL_gfx`.
- `ENETDIR` is the path to the cross-compiled version for `enet`,
which would correspond to `./configure --prefix=$ENETDIR` used in
building `enet`.

A stripped version of the executable, as well as game assets, will be
located in `build/cdimg`.

#### Dependencies

A cross-compiled `i386-mingw32` version of all required dependencies
is needed before building `jancity`.

Note upstream CMake does not provide `FindSDL_gfx.cmake` as of the time
of this writing, so it is provisionally provided on
[this repository](cmake/FindSDL_gfx.cmake).

[Ongoing upstream PR](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7475)

Read [the documentation](doc/BUILD-win9x.md) for further reference on
how to build the dependencies from source.

## License

Unless stated otherwise, **jancity** follows the license described by the
`LICENSE` file, which currently is the GNU General Public License v3
or later. Original versions of other works under various licenses are
also distributed in this project, that are located inside the
`res/orig` directory. This directory also contains a `LICENSE`
describing the source and license of each individual file.

Derivative works have been also created from these files for this
project, that are located inside the `res` directory. A `LICENSE`
file is also provided to describe the relationship between the
original and derived works.

## Copyright notice

Microsoft®, Linux®, Sony® and PlayStation® are registered trademarks of
their respective owners.