Pārlūkot izejas kodu

Add instructions for macOS

Add compatibility for macOS and *NIX files

TODO: inspect building of dependencies
master
TheoryOfNekomata pirms 1 gada
vecāks
revīzija
25c7c83370
12 mainītis faili ar 45 papildinājumiem un 31 dzēšanām
  1. +1
    -0
      .gitignore
  2. +1
    -0
      CMakeLists.txt
  3. +20
    -13
      README.md
  4. +4
    -1
      dependencies.txt
  5. +3
    -3
      src/packages/config/IZ_config.c
  6. +1
    -1
      src/packages/game/IZ_app.c
  7. +2
    -2
      src/packages/game/IZ_app_config.c
  8. +2
    -2
      src/packages/game/input/IZ_joystick.c
  9. +2
    -2
      src/packages/game/input/IZ_keyboard.c
  10. +3
    -3
      src/packages/game/input/IZ_midi.c
  11. +4
    -2
      src/packages/game/util/IZ_midi.c
  12. +2
    -2
      src/packages/net/IZ_net_client.c

+ 1
- 0
.gitignore Parādīt failu

@@ -62,3 +62,4 @@ cmake-build-debug/
dependencies/
assets_wip/
Backup_*.cdr
.DS_Store

+ 1
- 0
CMakeLists.txt Parādīt failu

@@ -27,6 +27,7 @@ endif()

include_directories(
"${PROJECT_SOURCE_DIR}/dependencies/SDL2/include"
"${PROJECT_SOURCE_DIR}/dependencies/SDL2_image"
"${PROJECT_SOURCE_DIR}/dependencies/SDL2_image/include"
"${PROJECT_SOURCE_DIR}/dependencies/SDL2_ttf/include"
"${PROJECT_SOURCE_DIR}/dependencies/minIni/dev"


+ 20
- 13
README.md Parādīt failu

@@ -1,20 +1,27 @@
# sdl2-hello-world
# izanagi

A beginner template for SDL2 powered by CMake.
A run-and-gun shooter inspired by Metal Slug.

## Setup

> **Note:** CMake and OpenSSL are required.

### Windows

1. Clone this repo.
2. Download the **SDL2 Development Libraries** from the [official download page](https://www.libsdl.org/download-2.0.php).
- For Windows
1. Unpack the **MSVC** archive under `dependencies` folder in this project's root.
2. Rename the directory as `SDL2`.
- For macOS
`TODO`
_Alternatively, on Windows, you can link the external libraries via symlink._
3. Build the following dependencies first:
2. Clone the repositories under `dependencies.txt` except for SDL2.
3. Unpack the **MSVC** archive under `dependencies` folder in this project's root. Rename the directory as `SDL2`.
4. Build the following dependencies first:
- `portmidi`
- `libwebsockets` (follow the [instructions on building LWS](https://libwebsockets.org/lws-api-doc-master/html/md_README_8build.html))
4. Build via CMake.
5. Build via CMake.

### macOS/*NIX

1. Clone this repo.
2. Clone the repositories under `dependencies.txt`, including SDL2.
3. Build the SDL2 dependency using the [build instructions for macOS](https://wiki.libsdl.org/SDL2/Installation#macos).
4. Build the following dependencies first:
- `portmidi`
- `libwebsockets` (follow the [instructions on building LWS](https://libwebsockets.org/lws-api-doc-master/html/md_README_8build.html))
5. Build via CMake.

+ 4
- 1
dependencies.txt Parādīt failu

@@ -1,7 +1,10 @@
https://github.com/libsdl-org/SDL
https://github.com/libsdl-org/SDL_image
https://github.com/compuphase/minIni
https://github.com/grassator/bdd-for-c
https://github.com/PortMidi/portmidi
https://github.com/EsotericSoftware/spine-runtimes
https://github.com/Chunde/getopt-for-windows
https://libwebsockets.org/repo/libwebsockets
https://www.sqlite.org/download.html (use SQLite amalgamated source code)
https://github.com/openssl/openssl
https://www.sqlite.org/download.html (use SQLite amalgamated source code, unpack into `sqlite` directory)

+ 3
- 3
src/packages/config/IZ_config.c Parādīt failu

@@ -123,13 +123,13 @@ void IZ_ConfigEnsureValidString(IZ_ConfigItem* item, const char* buffer) {
if (item->validator) {
IZ_ConfigLoadParamsStringValidator* validator = item->validator;
if (validator(buffer)) {
memcpy_s(item->dest, item->dest_size, buffer, item->dest_size);
memcpy(item->dest, buffer, item->dest_size);
return;
}
memcpy_s(item->dest, item->dest_size, item->default_value, item->dest_size);
memcpy(item->dest, item->default_value, item->dest_size);
return;
}
memcpy_s(item->dest, item->dest_size, buffer, item->dest_size);
memcpy(item->dest, buffer, item->dest_size);
}

void IZ_ConfigLoadString(IZ_ConfigItem* item, const char* config_path) {


+ 1
- 1
src/packages/game/IZ_app.c Parādīt failu

@@ -32,7 +32,7 @@ IZ_AppInitializeResult IZ_AppInitialize(struct IZ_App* app, u8 argc, const char*
char config_path[128];
// TODO abstract command line args parsing
if ((cmdline_buffer = IZ_ConfigGetCommandlineOption(argc, argv, "-c"))) {
memcpy_s(config_path, 128, cmdline_buffer, 128);
memcpy(config_path, cmdline_buffer, 128);
} else {
IZ_ConfigGetDefaultPath(config_path, 128);
}


+ 2
- 2
src/packages/game/IZ_app_config.c Parādīt failu

@@ -7,6 +7,6 @@ void IZ_ConfigGetDefaultPath(const char* config_path, size_t string_size) {
const char* config_path_dir = SDL_GetPrefPath("Modal Studios", IZ_APP_NAME);
#endif

memcpy_s(config_path, string_size, config_path_dir, 128);
strcat_s(config_path, string_size, "config-game.ini");
memcpy(config_path, config_path_dir, string_size);
strcat(config_path, "config-game.ini");
}

+ 2
- 2
src/packages/game/input/IZ_joystick.c Parādīt failu

@@ -157,7 +157,7 @@ void IZ_JoystickInitializeConfigItems(IZ_ConfigItem config_items[]) {
char* control_mapping_section_name;
for (player_index = 0; player_index < IZ_PLAYERS; player_index += 1) {
main_section_name = SDL_malloc(sizeof(char) * 64);
sprintf_s(main_section_name, 64, "Joystick.%d", player_index);
sprintf(main_section_name, "Joystick.%d", player_index);
u8 base_index = (player_index * (IZ_CONTROLS - 4 + 2));
config_items[base_index] = (IZ_ConfigItem) {
IZ_CONFIG_TYPE_I32,
@@ -182,7 +182,7 @@ void IZ_JoystickInitializeConfigItems(IZ_ConfigItem config_items[]) {
};

control_mapping_section_name = SDL_malloc(sizeof(char) * 64);
sprintf_s(control_mapping_section_name, 64, "Joystick.%d.ControlMapping", player_index);
sprintf(control_mapping_section_name, "Joystick.%d.ControlMapping", player_index);
for (control_index = 4; control_index < IZ_CONTROLS; control_index += 1) {
config_items[base_index + 2 + (control_index - 4)] = (IZ_ConfigItem) {
IZ_CONFIG_TYPE_U8,


+ 2
- 2
src/packages/game/input/IZ_keyboard.c Parādīt failu

@@ -4,7 +4,7 @@ static IZ_ConfigItem keyboard_config_items[IZ_PLAYERS * IZ_CONTROLS + 1];

void IZ_KeyboardSerializeControl(i32 value, char control[128]) {
const char* serialized = SDL_GetKeyName(value);
memcpy_s(control, 128, serialized, 128);
memcpy(control, serialized, 128);
}

i32 IZ_KeyboardDeserializeControl(const char* control) {
@@ -55,7 +55,7 @@ void IZ_KeyboardInitializeConfigItems(IZ_ConfigItem config_items[]) {
char* control_mapping_section_name;
for (player_index = 0; player_index < IZ_PLAYERS; player_index += 1) {
control_mapping_section_name = SDL_malloc(sizeof(char) * 64);
sprintf_s(control_mapping_section_name, 64, "Keyboard.%d.ControlMapping", player_index);
sprintf(control_mapping_section_name, "Keyboard.%d.ControlMapping", player_index);
for (control_index = 0; control_index < IZ_CONTROLS; control_index += 1) {
config_items[player_index * IZ_CONTROLS + control_index] = (IZ_ConfigItem) {
IZ_CONFIG_TYPE_I32,


+ 3
- 3
src/packages/game/input/IZ_midi.c Parādīt failu

@@ -8,7 +8,7 @@ bool IZ_MIDIInputIsValidChannel(u8 value) {

void IZ_MIDIInputSerializeControl(i32 value, char* control[128]) {
const char* serialized = IZ_MIDIGetNoteName(value);
memcpy_s(control, 128, serialized, 128);
memcpy(control, serialized, 128);
}

i32 IZ_MIDIInputDeserializeControl(const char* control) {
@@ -77,7 +77,7 @@ void IZ_MIDIInputInitializeConfigItems(IZ_ConfigItem config_items[]) {
char* control_mapping_section_name;
for (player_index = 0; player_index < IZ_PLAYERS; player_index += 1) {
main_section_name = SDL_malloc(sizeof(char) * 64);
sprintf_s(main_section_name, 64, "MIDIInput.%d", player_index);
sprintf(main_section_name, "MIDIInput.%d", player_index);

u16 base_index = (player_index * (IZ_CONTROLS + 2));
config_items[base_index] = (IZ_ConfigItem) {
@@ -111,7 +111,7 @@ void IZ_MIDIInputInitializeConfigItems(IZ_ConfigItem config_items[]) {
};

control_mapping_section_name = SDL_malloc(sizeof(char) * 64);
sprintf_s(control_mapping_section_name, 64, "MIDIInput.%d.ControlMapping", player_index);
sprintf(control_mapping_section_name, "MIDIInput.%d.ControlMapping", player_index);
for (control_index = 0; control_index < IZ_CONTROLS; control_index += 1) {
config_items[base_index + 2 + control_index] = (IZ_ConfigItem) {
IZ_CONFIG_TYPE_U8,


+ 4
- 2
src/packages/game/util/IZ_midi.c Parādīt failu

@@ -19,14 +19,16 @@ char* IZ_MIDIGetNoteName(u8 midi_note) {
const u8 pitch_class = midi_note % 12;
const u8 octave = midi_note / 12;
static char note_name[8];
sprintf_s(note_name, 8, "%s%u", pitch_names[pitch_class], octave);
sprintf(note_name, "%s%u", pitch_names[pitch_class], octave);
return note_name;
}

u8 IZ_MIDIGetNoteFromName(const char* name) {
char name_copy[8];
memcpy_s(name_copy, 8, name, 8);
memcpy(name_copy, name, 8);
#ifdef WIN32
_strlwr_s(name_copy, 8);
#endif

u8 octave;
const char base_pitch_name[] = "c d ef g a b";


+ 2
- 2
src/packages/net/IZ_net_client.c Parādīt failu

@@ -50,7 +50,7 @@ void IZ_NetClientInitializeConfigItems(IZ_ConfigItem config_items[]) {
char* main_section_name;
for (player_index = 0; player_index < IZ_PLAYERS; player_index += 1) {
main_section_name = malloc(sizeof(char) * 64);
sprintf_s(main_section_name, 64, "Network.%d", player_index);
sprintf(main_section_name, "Network.%d", player_index);
config_items[3 + player_index] = (IZ_ConfigItem) {
IZ_CONFIG_TYPE_STRING,
32,
@@ -106,7 +106,7 @@ IZ_ProcedureResult IZ_NetClientInitialize(
if (!user_data) {
return -1;
}
memcpy_s(state, sizeof(IZ_NetClientState), &IZ_NET_CLIENT_DEFAULT_STATE, sizeof(IZ_NetClientState));
memcpy(state, &IZ_NET_CLIENT_DEFAULT_STATE, sizeof(IZ_NetClientState));
if (IZ_NetClientInitializeConfig(state, config_path, argc, argv) < 0) {
return -2;
}


Notiek ielāde…
Atcelt
Saglabāt