Skip to content

Commit 24facb1

Browse files
committed
Fix #2
1 parent 461d006 commit 24facb1

File tree

7 files changed

+42
-41
lines changed

7 files changed

+42
-41
lines changed

CMakeLists.txt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ if (NGAGESDK)
1616
else()
1717
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXPORT_DIR})
1818
include(get_SDL3)
19+
include(get_zlib)
1920
get_SDL3("3.2.16")
21+
get_zlib("1.3.1")
2022
endif()
2123

2224
# Game source files.
@@ -34,7 +36,7 @@ set(kagekero_sources
3436
src/utils.c
3537
)
3638

37-
add_executable(kagekero WIN32 ${kagekero_sources})
39+
add_executable(kagekero ${kagekero_sources})
3840
target_compile_definitions(kagekero PRIVATE
3941
$<$<CONFIG:Debug>:DEBUG>
4042
)
@@ -126,19 +128,21 @@ if(PACK_ASSETS)
126128
endif()
127129
endif()
128130

129-
if(NGAGESDK)
130-
set(MAP_PREFIX ".gz")
131-
function(compress_maps asset_dir)
132-
add_custom_target(001.tmj.gz ALL
133-
WORKING_DIRECTORY ${asset_dir}
134-
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/gzip -k -f *.tmj
135-
)
136-
endfunction()
137-
endif()
131+
function(compress_maps asset_dir)
132+
find_program(GZIP_EXECUTABLE gzip PATHS ${CMAKE_CURRENT_SOURCE_DIR}/tools NO_DEFAULT_PATH)
133+
if(NOT GZIP_EXECUTABLE)
134+
find_program(GZIP_EXECUTABLE gzip)
135+
endif()
136+
137+
add_custom_target(001.tmj.gz ALL
138+
WORKING_DIRECTORY ${asset_dir}
139+
COMMAND ${GZIP_EXECUTABLE} -k -f *.tmj
140+
)
141+
endfunction()
138142

139143
set(BASE_ASSETS
140-
001.tmj${MAP_PREFIX}
141-
002.tmj${MAP_PREFIX}
144+
001.tmj.gz
145+
002.tmj.gz
142146
font.png
143147
frame.png
144148
frame_400x240.png
@@ -151,25 +155,21 @@ if(PACK_ASSETS)
151155
if(BUILD_FULL_VERSION)
152156
set(ASSET_DIR "${CMAKE_CURRENT_SOURCE_DIR}/full-assets")
153157

154-
if(NGAGESDK)
155-
compress_maps("${ASSET_DIR}")
156-
endif()
158+
compress_maps("${ASSET_DIR}")
157159

158160
set(ASSET_LIST
159161
"${BASE_ASSETS}"
160-
003.tmj${MAP_PREFIX}
161-
004.tmj${MAP_PREFIX}
162-
005.tmj${MAP_PREFIX}
163-
006.tmj${MAP_PREFIX}
164-
007.tmj${MAP_PREFIX}
162+
003.tmj.gz
163+
004.tmj.gz
164+
005.tmj.gz
165+
006.tmj.gz
166+
007.tmj.gz
165167
)
166168
else()
167169

168170
set(ASSET_DIR "${CMAKE_CURRENT_SOURCE_DIR}/assets")
169171

170-
if(NGAGESDK)
171-
compress_maps("${ASSET_DIR}")
172-
endif()
172+
compress_maps("${ASSET_DIR}")
173173

174174
set(ASSET_LIST ${BASE_ASSETS})
175175
endif()
@@ -187,7 +187,7 @@ if(PACK_ASSETS)
187187
endif()
188188

189189
if(UNIX)
190-
target_link_libraries(kagekero PRIVATE ${SDL3_LIBRARIES} m)
190+
target_link_libraries(kagekero PRIVATE ${SDL3_LIBRARIES} ${ZLIB_LIBRARIES} m)
191191

192192
if(PACK_ASSETS)
193193
add_executable(packer tools/packer.cpp)
@@ -196,7 +196,7 @@ if(UNIX)
196196
)
197197
endif()
198198
else()
199-
target_link_libraries(kagekero PRIVATE ${SDL3_LIBRARIES})
199+
target_link_libraries(kagekero PRIVATE ${SDL3_LIBRARIES} ${ZLIB_LIBRARIES})
200200
endif()
201201

202202
# Dreamcast-specific setup.

cmake/get_zlib.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
macro(get_zlib version)
2+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
3+
cmake_policy(SET CMP0135 NEW)
4+
endif()
5+
include(FetchContent)
6+
FetchContent_Declare(
7+
zlib
8+
URL https://zlib.net/zlib-${version}.tar.gz
9+
URL_HASH
10+
SHA256=9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23
11+
)
12+
FetchContent_MakeAvailable(zlib)
13+
14+
set(ZLIB_LIBRARIES zlib)
15+
endmacro(get_zlib)

export/data.pfs

-1.29 MB
Binary file not shown.

src/config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#if defined DEBUG
3232
// Default configuration.
3333
#elif defined __SYMBIAN32__
34-
#define MAP_PREFIX ".gz"
3534
#define WINDOW_W 176
3635
#define WINDOW_H 208
3736
#define SCREEN_OFFSET_X 0
@@ -84,10 +83,6 @@
8483
#define FRAME_OFFSET_Y 0
8584
#endif
8685

87-
#ifndef MAP_PREFIX
88-
#define MAP_PREFIX ""
89-
#endif
90-
9186
#ifndef SCALE
9287
#define SCALE 1
9388
#endif

src/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ bool init(core_t **nc)
9797
init_file_reader();
9898

9999
char first_map[11] = { 0 };
100-
SDL_snprintf(first_map, 11, "%03d.tmj%s", FIRST_LEVEL, MAP_PREFIX);
100+
SDL_snprintf(first_map, 11, "%03d.tmj.gz", FIRST_LEVEL);
101101
if (!load_map(first_map, &(*nc)->map, (*nc)->renderer))
102102
{
103103
return false;

src/kero.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static void handle_interaction(kero_t *kero, map_t *map, unsigned int *btn, SDL_
115115
char next_map[11] = { 0 };
116116
kero->level += 1;
117117

118-
SDL_snprintf(next_map, 11, "%03d.tmj%s", kero->level, MAP_PREFIX);
118+
SDL_snprintf(next_map, 11, "%03d.tmj.gz", kero->level);
119119
if (!load_map(next_map, &map, renderer))
120120
{
121121
SDL_Log("Failed to load next map: %s", next_map);

src/map.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
#include "pfs.h"
1616
#include "utils.h"
1717

18-
#if defined __SYMBIAN32__
1918
#include "zlib.h"
20-
#endif
2119

2220
#if defined __SYMBIAN32__
2321
#define CUTE_TILED_SNPRINTF(ARGS...) (void)(ARGS)
@@ -52,7 +50,6 @@ static void destroy_tiled_map(map_t *map)
5250
map->handle = NULL;
5351
}
5452

55-
#if defined __SYMBIAN32__
5653
static bool decompress_gz_buffer(Uint8 *compressed_data, size_t compressed_size, Uint8 **out_decompressed_data, uLongf *out_decompressed_size)
5754
{
5855
const size_t CHUNK_SIZE = 16384;
@@ -109,7 +106,6 @@ static bool decompress_gz_buffer(Uint8 *compressed_data, size_t compressed_size,
109106

110107
return true;
111108
}
112-
#endif
113109

114110
static bool load_tiled_map(const char *file_name, map_t *map)
115111
{
@@ -128,13 +124,11 @@ static bool load_tiled_map(const char *file_name, map_t *map)
128124
}
129125

130126
int buffer_size = 0;
131-
#if defined __SYMBIAN32__
132127
Uint8 *decompressed_data = NULL;
133128
uLongf decompressed_size = 0;
134129

135130
if (decompress_gz_buffer(buffer, size_of_file(file_name), &decompressed_data, &decompressed_size))
136131
{
137-
// Success � `decompressed_data` contains result, size in `decompressed_size`
138132
SDL_Log("Decompressed to %lu bytes", decompressed_size);
139133
SDL_free(buffer); // free original .gz buffer
140134
buffer = decompressed_data;
@@ -144,9 +138,6 @@ static bool load_tiled_map(const char *file_name, map_t *map)
144138
{
145139
SDL_Log("Decompression failed");
146140
}
147-
#else
148-
buffer_size = size_of_file(file_name);
149-
#endif
150141

151142
map->handle = cute_tiled_load_map_from_memory((const void *)buffer, buffer_size, NULL);
152143
if (!map->handle)

0 commit comments

Comments
 (0)