Rev 14 | Rev 20 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 14 | Rev 18 | ||
|---|---|---|---|
| Line 162... | Line 162... | ||
| 162 | harness_game_config.enable_diagnostics = 0; |
162 | harness_game_config.enable_diagnostics = 0; |
| 163 | // no volume multiplier |
163 | // no volume multiplier |
| 164 | harness_game_config.volume_multiplier = 1.0f; |
164 | harness_game_config.volume_multiplier = 1.0f; |
| 165 | // start window in windowed mode |
165 | // start window in windowed mode |
| 166 | harness_game_config.start_full_screen = 0; |
166 | harness_game_config.start_full_screen = 0; |
| 167 | // |
167 | // Disable gore check emulation |
| 168 | harness_game_config.gore_check = 0; |
168 | harness_game_config.gore_check = 0; |
| 169 | // Enable Sound Options menu |
169 | // Enable Sound Options menu |
| 170 | harness_game_config.sound_options = 1; // Pierre-Marie Baty -- invert option default value |
170 | harness_game_config.sound_options = 1; // Pierre-Marie Baty -- invert option default value |
| 171 | // Skip binding socket to allow local network testing |
171 | // Skip binding socket to allow local network testing |
| 172 | harness_game_config.no_bind = 0; |
172 | harness_game_config.no_bind = 0; |
| - | 173 | // Disable verbose logging |
|
| - | 174 | harness_game_config.verbose = 0; |
|
| 173 | 175 | ||
| 174 | // install signal handler by default |
176 | // install signal handler by default |
| 175 | harness_game_config.install_signalhandler = 1; |
177 | harness_game_config.install_signalhandler = 1; |
| 176 | 178 | ||
| 177 | Harness_ProcessCommandLine(argc, argv); |
179 | Harness_ProcessCommandLine(argc, argv); |
| Line 215... | Line 217... | ||
| 215 | } |
217 | } |
| 216 | #endif /* __APPLE__ */ |
218 | #endif /* __APPLE__ */ |
| 217 | if (root_dir[0] == 0) |
219 | if (root_dir[0] == 0) |
| 218 | strcpy(root_dir, "."); // Pierre-Marie Baty -- consistency check |
220 | strcpy(root_dir, "."); // Pierre-Marie Baty -- consistency check |
| 219 | } |
221 | } |
| 220 | printf("Using root directory: %s\n", root_dir); |
222 | printf("Using root directory: %s\n", root_dir); |
| 221 | result = chdir(root_dir); |
223 | result = chdir(root_dir); |
| 222 | if (result != 0) { |
224 | if (result != 0) { |
| 223 | LOG_PANIC("Failed to chdir. Error is %s", strerror(errno)); |
225 | LOG_PANIC("Failed to chdir. Error is %s", strerror(errno)); |
| 224 | } |
226 | } |
| 225 | 227 | ||
| 226 | if (harness_game_info.mode == eGame_none) { |
228 | if (harness_game_info.mode == eGame_none) { |
| 227 | Harness_DetectGameMode(); |
229 | Harness_DetectGameMode(); |
| 228 | } |
230 | } |
| Line 251... | Line 253... | ||
| 251 | harness_debug_level = atoi(s + 1); |
253 | harness_debug_level = atoi(s + 1); |
| 252 | LOG_INFO("debug level set to %d", harness_debug_level); |
254 | LOG_INFO("debug level set to %d", harness_debug_level); |
| 253 | handled = 1; |
255 | handled = 1; |
| 254 | } else if (strstr(argv[i], "--physics-step-time=") != NULL) { |
256 | } else if (strstr(argv[i], "--physics-step-time=") != NULL) { |
| 255 | char* s = strstr(argv[i], "="); |
257 | char* s = strstr(argv[i], "="); |
| 256 | harness_game_config.physics_step_time = |
258 | harness_game_config.physics_step_time = atoi(s + 1); |
| 257 | LOG_INFO("Physics step time set to |
259 | LOG_INFO("Physics step time set to %d", harness_game_config.physics_step_time); |
| 258 | handled = 1; |
260 | handled = 1; |
| 259 | } else if (strstr(argv[i], "--fps=") != NULL) { |
261 | } else if (strstr(argv[i], "--fps=") != NULL) { |
| 260 | char* s = strstr(argv[i], "="); |
262 | char* s = strstr(argv[i], "="); |
| 261 | harness_game_config.fps = atoi(s + 1); |
263 | harness_game_config.fps = atoi(s + 1); |
| 262 | LOG_INFO("FPS limiter set to %f", harness_game_config.fps); |
264 | LOG_INFO("FPS limiter set to %f", harness_game_config.fps); |
| Line 308... | Line 310... | ||
| 308 | i--; |
310 | i--; |
| 309 | } |
311 | } |
| 310 | } |
312 | } |
| 311 | 313 | ||
| 312 | return 0; |
314 | return 0; |
| 313 | } |
- | |
| 314 | - | ||
| 315 | // Render 2d back buffer |
- | |
| 316 | void Harness_RenderScreen(br_pixelmap* dst, br_pixelmap* src) { |
- | |
| 317 | gHarness_platform.Renderer_FullScreenQuad((uint8_t*)src->pixels); |
- | |
| 318 | - | ||
| 319 | last_dst = dst; |
- | |
| 320 | last_src = src; |
- | |
| 321 | } |
- | |
| 322 | - | ||
| 323 | void Harness_Hook_BrV1dbRendererBegin(br_v1db_state* v1db) { |
- | |
| 324 | renderer_state = NewHarnessBrRenderer(); |
- | |
| 325 | v1db->renderer = (br_renderer*)renderer_state; |
- | |
| 326 | } |
- | |
| 327 | - | ||
| 328 | static int Harness_CalculateFrameDelay(void) { |
- | |
| 329 | if (harness_game_config.fps == 0) { |
- | |
| 330 | return 0; |
- | |
| 331 | } |
- | |
| 332 | - | ||
| 333 | unsigned int now = GetTotalTime(); |
- | |
| 334 | - | ||
| 335 | if (last_frame_time != 0) { |
- | |
| 336 | unsigned int frame_time = now - last_frame_time; |
- | |
| 337 | last_frame_time = now; |
- | |
| 338 | if (frame_time < 100) { |
- | |
| 339 | int sleep_time = (1000 / harness_game_config.fps) - frame_time; |
- | |
| 340 | if (sleep_time > 5) { |
- | |
| 341 | return sleep_time; |
- | |
| 342 | } |
- | |
| 343 | } |
- | |
| 344 | } |
- | |
| 345 | return 0; |
- | |
| 346 | } |
- | |
| 347 | - | ||
| 348 | void Harness_Hook_renderActor(br_actor* actor, br_model* model, br_material* material, br_token type) { |
- | |
| 349 | gHarness_platform.Renderer_Model(actor, model, material, type, renderer_state->state.matrix.model_to_view); |
- | |
| 350 | } |
- | |
| 351 | - | ||
| 352 | // Called by game to swap buffers at end of frame rendering |
- | |
| 353 | void Harness_Hook_BrPixelmapDoubleBuffer(br_pixelmap* dst, br_pixelmap* src) { |
- | |
| 354 | - | ||
| 355 | // draw the current colour_buffer (2d screen) contents |
- | |
| 356 | Harness_RenderScreen(dst, src); |
- | |
| 357 | - | ||
| 358 | int delay_ms = Harness_CalculateFrameDelay(); |
- | |
| 359 | gHarness_platform.SwapWindow(); |
- | |
| 360 | if (delay_ms > 0) { |
- | |
| 361 | gHarness_platform.Sleep(delay_ms); |
- | |
| 362 | } |
- | |
| 363 | - | ||
| 364 | gHarness_platform.Renderer_ClearBuffers(); |
- | |
| 365 | last_frame_time = GetTotalTime(); |
- | |
| 366 | } |
- | |
| 367 | - | ||
| 368 | void Harness_RenderLastScreen(void) { |
- | |
| 369 | if (last_dst) { |
- | |
| 370 | Harness_RenderScreen(last_dst, last_src); |
- | |
| 371 | gHarness_platform.SwapWindow(); |
- | |
| 372 | } |
- | |
| 373 | } |
315 | } |
| 374 | 316 | ||
| 375 | // Filesystem hooks |
317 | // Filesystem hooks |
| 376 | FILE* Harness_Hook_fopen(const char* pathname, const char* mode) { |
318 | FILE* Harness_Hook_fopen(const char* pathname, const char* mode) { |
| 377 | return OS_fopen(pathname, mode); |
319 | return OS_fopen(pathname, mode); |