Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/apple-silicon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Fresh Apple Silicon installer build
on:
workflow_dispatch:
push:
paths: ['port/macos/**', 'port/linux/**', 'source/**', 'tools/**', 'validation/**', '.github/workflows/apple-silicon.yml']
pull_request:
paths: ['port/macos/**', 'port/linux/**', 'source/**', 'tools/**', 'validation/**', '.github/workflows/apple-silicon.yml']
permissions:
contents: read
jobs:
build:
runs-on: macos-15
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Confirm ARM64 and create synthetic disc fixture
env:
FIXTURE_ISO: ${{ runner.temp }}/synthetic-halo.iso
run: |
test "$(uname -m)" = arm64
python3 - <<'PY'
import importlib.util, os
from pathlib import Path
spec = importlib.util.spec_from_file_location('fixture', 'port/macos/tooling/tests/test_xbox_assets.py')
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
module.fixture(Path(os.environ['FIXTURE_ISO']))
PY
- name: Run installer without game downloads or game launches
env:
HALO_WORK_DIR: ${{ runner.temp }}/fresh-build
HALO_APP_OUTPUT: ${{ runner.temp }}/Halo Fixture Build.app
run: ./port/macos/setup.sh "$RUNNER_TEMP/synthetic-halo.iso" --jobs 2
- name: Static native bundle check
run: '"$RUNNER_TEMP/Halo Fixture Build.app/Contents/MacOS/Halo Combat Evolved" --check'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Each platform has its own instructions:
| Linux (32-bit x86 executable, OpenGL 4.5, SDL3) | [port/linux/README.md](port/linux/README.md) |
| Windows (32-bit x86 executable, OpenGL 4.5, SDL3) | [port/windows/README.md](port/windows/README.md) |
| Android (arm64 app, OpenGL ES 3, SDL3) | [port/android/README.md](port/android/README.md) |
| macOS (Apple Silicon, experimental source build) | [port/macos/BUILD.md](port/macos/BUILD.md) |

The Linux README also gives the controls, the settings and the multiplayer
functions. These are almost the same on all platforms.
Expand Down
19 changes: 19 additions & 0 deletions port/android/guest/runtime/guest_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ void host_memory_watch_initialize(void);
void host_memory_watch_protect(unsigned int address, unsigned int size);
unsigned int host_memory_watch_generation(unsigned int address, unsigned int size);
unsigned int host_memory_watch_serial(void);
#ifdef HALO_MACOS
int host_memory_fingerprint_page(unsigned int address, unsigned long long *hashes);
int host_memory_fingerprint_range(unsigned int address, unsigned int pages,
void *entries, volatile unsigned long *counter, unsigned long *newest);
unsigned int host_bink_open(const char *path, void *info, int audio_enabled);
int host_bink_decode(unsigned int token);
int host_bink_next(unsigned int token, void *info);
int host_bink_wait(unsigned int token);
int host_bink_copy(unsigned int token, void *destination, int pitch,
unsigned int height, unsigned int x, unsigned int y, unsigned int flags);
void host_bink_close(unsigned int token);
#endif
void host_memory_watch_prepare_write(unsigned int address, unsigned int size);
void host_memory_watch_forget(unsigned int address, unsigned int size);

Expand All @@ -59,6 +71,13 @@ long long host_sdl_ticks(void);
long long host_sdl_thread_id(void);
unsigned int host_sdl_create_window(const char *title, int width, int height, long long flags);
void host_sdl_window_size_in_pixels(unsigned int window, int *width, int *height);
#ifdef HALO_MACOS
int host_sdl_window_size(unsigned int window, int *width, int *height);
long long host_sdl_window_flags(unsigned int window);
int host_sdl_set_window_fullscreen(unsigned int window, int enabled);
int host_sdl_set_window_size(unsigned int window, int width, int height);
int host_sdl_warp_mouse(unsigned int window, float x, float y);
#endif
int host_sdl_set_relative_mouse(unsigned int window, int enabled);
int host_sdl_gl_set_attribute(int attribute, int value);
unsigned int host_sdl_gl_create_context(unsigned int window);
Expand Down
31 changes: 31 additions & 0 deletions port/android/guest/runtime/guest_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,37 @@ bool SDL_SetWindowRelativeMouseMode(SDL_Window *window, bool enabled)
return host_sdl_set_relative_mouse((unsigned int)window, enabled) != 0;
}

#ifdef HALO_MACOS
bool SDL_GetWindowSize(SDL_Window *window, int *width, int *height)
{
int w = 0, h = 0;
int result = host_sdl_window_size((unsigned int)window, &w, &h);
if (width) *width = w;
if (height) *height = h;
return result != 0;
}

SDL_WindowFlags SDL_GetWindowFlags(SDL_Window *window)
{
return (SDL_WindowFlags)host_sdl_window_flags((unsigned int)window);
}

bool SDL_SetWindowSize(SDL_Window *window, int width, int height)
{
return host_sdl_set_window_size((unsigned int)window, width, height) != 0;
}

bool SDL_SetWindowFullscreen(SDL_Window *window, bool fullscreen)
{
return host_sdl_set_window_fullscreen((unsigned int)window, fullscreen) != 0;
}

void SDL_WarpMouseInWindow(SDL_Window *window, float x, float y)
{
(void)host_sdl_warp_mouse((unsigned int)window, x, y);
}
#endif

bool SDL_GL_SetAttribute(SDL_GLAttr attribute, int value)
{
return host_sdl_gl_set_attribute((int)attribute, value) != 0;
Expand Down
26 changes: 26 additions & 0 deletions port/linux/game/network_distributed.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,19 @@ static void distributed_client_send_predictions(

/* (the host) a client's own players: the latest of each, taken at the next
tick */
#ifdef HALO_MACOS
/* Fixed-size counters and opt-in output; disabled in ordinary human play. */
static void distributed_trace(short stage, long machine, long type, long tick, long count)
{
static long enabled = -1, counters[10];
if (enabled < 0) enabled = getenv("HALO_NETWORK_TRACE") && strcmp(getenv("HALO_NETWORK_TRACE"), "1") == 0;
if (enabled && stage >= 0 && stage < 10 && (++counters[stage] <= 16 || counters[stage] % 300 == 0))
fprintf(stderr, "[mp-decoder] stage=%d n=%ld machine=%ld type=%ld tick=%ld count=%ld\n", (int)stage, counters[stage], machine, type, tick, count);
}
#else
#define distributed_trace(stage,machine,type,tick,count) ((void)0)
#endif

static void distributed_handle_predictions(
long machine_index,
struct distributed_unit_state const *states,
Expand All @@ -813,8 +826,10 @@ static void distributed_handle_predictions(
if (state->player_index >= MAXIMUM_TRACKED_PLAYERS ||
!distributed_machine_has_player(machine_index, state->player_index))
{
distributed_trace(5, machine_index, state->player_index, state->unit_index, count);
continue;
}
distributed_trace(6, machine_index, state->player_index, state->unit_index, count);
distributed_predictions[state->player_index].valid = TRUE;
distributed_predictions[state->player_index].state = *state;
}
Expand Down Expand Up @@ -843,6 +858,7 @@ static void distributed_apply_predictions(
real dy = state->position.y - object->object.position.y;
real dz = state->position.z - object->object.position.z;

distributed_trace(7, player_index, unit_index, (long)((dx * dx + dy * dy + dz * dz) * 1000.0f), game_time_get());
if (dx * dx + dy * dy + dz * dz <= HOST_ACCEPT_TOLERANCE * HOST_ACCEPT_TOLERANCE)
distributed_apply_state(unit_index, state, 0.0f, HOST_BLEND_DISTANCE);
}
Expand Down Expand Up @@ -1016,11 +1032,13 @@ static void distributed_handle_inputs(
if (input->player_index >= MAXIMUM_TRACKED_PLAYERS ||
!distributed_machine_has_player(machine_index, input->player_index))
{
distributed_trace(8, machine_index, input->player_index, input->tick, count);
continue;
}
player = distributed_player(input->player_index);
if (!player)
continue;
distributed_trace(9, machine_index, input->player_index, input->tick, input->control_flags);
update_server_handle_distributed_input(DATUM_INDEX_NEW(input->player_index, player->identifier), input->tick,
&input->action, input->control_flags, DISTRIBUTED_INPUT_HISTORY);
if (input->host_time != NONE && machine_index >= 0 && machine_index < HALO_PORT_MAXIMUM_NETWORK_MACHINES)
Expand Down Expand Up @@ -1681,6 +1699,7 @@ void network_distributed_handle_message(
if (size < sizeof(header) || !network_game_distributed() || !game_in_progress())
return;
csmemcpy(&header, message, sizeof(header));
distributed_trace(0, machine_index, header.type, header.game_time, header.count);
/* a tick's messages in one: each as if it came alone */
if (header.type == _distributed_message_batch)
{
Expand Down Expand Up @@ -1738,7 +1757,10 @@ void network_distributed_handle_message(
case _distributed_message_vehicle_prediction:
case _distributed_message_player_inputs:
if (machine_index == NONE || game_connection() != _game_connection_network_server)
{
distributed_trace(1, machine_index, header.type, header.game_time, header.count);
return;
}
break;
default:
if (game_connection() != _game_connection_network_client)
Expand All @@ -1750,7 +1772,11 @@ void network_distributed_handle_message(
break;
}
if (distributed_message_stale(machine_index, &header))
{
distributed_trace(2, machine_index, header.type, header.game_time, header.count);
return;
}
distributed_trace(3, machine_index, header.type, header.game_time, header.count);

switch (header.type)
{
Expand Down
11 changes: 10 additions & 1 deletion port/linux/game/network_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Called from the main loop every frame (main.c).
*/

#include "cseries.h"
#include "bink/bink_playback.h"
#include "main/main.h"
#include "interface/player_ui.h"
#include "interface/ui_widget.h"
Expand Down Expand Up @@ -437,6 +438,14 @@ static void network_test_pickup(
}
}

/* main_menu_scenario_loaded can already be true while the intro owns the
* texture-cache scratch pool. Host setup precaches its map using that same
* pool, so wait for normal movie disposal before starting the menu timer. */
static boolean network_test_frontend_ready(boolean main_menu_loaded)
{
return main_menu_loaded && !bink_playback_active();
}

void network_test_update(
boolean main_menu_loaded,
real seconds)
Expand Down Expand Up @@ -545,7 +554,7 @@ void network_test_update(
}
}

if (!main_menu_loaded)
if (!network_test_frontend_ready(main_menu_loaded))
return;
network_test.menu_seconds += seconds;
/* (the main menu settling first) */
Expand Down
8 changes: 7 additions & 1 deletion port/linux/include/StdDef.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
/* the game includes <StdDef.h>; Linux file names are case sensitive */
/* The game includes <StdDef.h>; Linux file names are case sensitive. On
* case-insensitive macOS filesystems this lowercase shim aliases StdDef.h
* itself, so skip this include directory to reach the target C library. */
#if defined(HALO_MACOS)
#include_next <stddef.h>
#else
#include <stddef.h>
#endif
2 changes: 1 addition & 1 deletion port/linux/include/halo_linux_prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ emitting them so the redefinition above cannot reach them. */

/* ---------- __declspec(selectany) data (XDK D3DCONST tables) */

#define DECLSPEC_SELECTANY __attribute__((weak))
#define DECLSPEC_SELECTANY __attribute__((__weak__))

/* ---------- MSVC intrinsics

Expand Down
70 changes: 69 additions & 1 deletion port/linux/src/bink_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,24 @@ RADEXPLINK is __stdcall.
*/

#include "platform.h"
#ifdef HALO_MACOS
#include "guest_host.h"
#include "port_config.h"
#include <string.h>
#endif

typedef void *(__stdcall *rad_memory_allocate_proc)(unsigned long size);
typedef void (__stdcall *rad_memory_free_proc)(void *memory);
typedef void *(__stdcall *bink_sound_system_open_proc)(unsigned long param);
typedef struct BINK *HBINK;
#ifdef HALO_MACOS
struct BINK
{
unsigned long Width, Height, Frames, FrameNum, LastFrameNum;
unsigned int native_token;
};
typedef char bink_wire_size_must_be_24[sizeof(struct BINK) == 24 ? 1 : -1];
#endif

void __stdcall RADSetMemory(rad_memory_allocate_proc allocate, rad_memory_free_proc release)
{
Expand All @@ -25,15 +38,24 @@ void __stdcall RADSetMemory(rad_memory_allocate_proc allocate, rad_memory_free_p

void *__stdcall BinkOpenDirectSound(unsigned long param)
{
#ifdef HALO_MACOS
return (void *)param;
#else
(void)param;
return NULL;
#endif
}

long __stdcall BinkSetSoundSystem(bink_sound_system_open_proc open, unsigned long param)
{
(void)open;
(void)param;
return 0;
return
#ifdef HALO_MACOS
1;
#else
0;
#endif
}

void __stdcall BinkSetIOSize(unsigned long io_size)
Expand All @@ -44,10 +66,55 @@ void __stdcall BinkSetIOSize(unsigned long io_size)
HBINK __stdcall BinkOpen(const char *name, unsigned long flags)
{
(void)flags;
#ifdef HALO_MACOS
char path[1024];
HBINK movie = calloc(1, sizeof(*movie));
if (!movie) return NULL;
platform_translate_path(name, path, sizeof(path));
movie->native_token = host_bink_open(path, movie, config_boolean("audio.enabled"));
if (!movie->native_token) { free(movie); platform_log("native Bink cannot open %s", path); return NULL; }
return movie;
#else
platform_log("Bink video is not supported; skipping \"%s\"", name ? name : "");
return NULL;
#endif
}

/* The native adapter owns codec/audio objects; the guest owns only this
* wire record. Closing/skipping releases both sides immediately. */
#ifdef HALO_MACOS
void __stdcall BinkClose(HBINK movie) { if (movie) { host_bink_close(movie->native_token); free(movie); } }
long __stdcall BinkDoFrame(HBINK movie)
{
if (!movie || !host_bink_decode(movie->native_token)) host_abort("native Bink video decode failed");
return 0;
}
void __stdcall BinkNextFrame(HBINK movie)
{
if (!movie || !host_bink_next(movie->native_token, movie)) host_abort("native Bink frame state failed");
}
long __stdcall BinkWait(HBINK movie) { return movie ? host_bink_wait(movie->native_token) : 0; }
long __stdcall BinkCopyToBuffer(HBINK movie, void *destination, long pitch,
unsigned long height, unsigned long x, unsigned long y, unsigned long flags)
{
if (!movie || !host_bink_copy(movie->native_token, destination, pitch, height, x, y, flags))
host_abort("native Bink destination span or format invalid");
return 0;
}
void __stdcall BinkGetSummary(HBINK movie, void *summary)
{
unsigned long *words = summary;
memset(summary, 0, 31 * sizeof(unsigned long));
if (movie) { words[0] = movie->Width; words[1] = movie->Height; words[8] = movie->Frames; words[9] = movie->FrameNum; }
}
void __stdcall BinkGetRealtime(HBINK movie, void *realtime, unsigned long frame_count)
{
unsigned long *words = realtime;
(void)frame_count;
memset(realtime, 0, 14 * sizeof(unsigned long));
if (movie) { words[0] = movie->FrameNum; words[3] = movie->FrameNum ? movie->FrameNum : 1; }
}
#else
/* never reached without an open movie */

void __stdcall BinkClose(HBINK bink) { (void)bink; }
Expand All @@ -66,3 +133,4 @@ long __stdcall BinkCopyToBuffer(HBINK bink, void *destination, long destination_

void __stdcall BinkGetSummary(HBINK bink, void *summary) { (void)bink; (void)summary; }
void __stdcall BinkGetRealtime(HBINK bink, void *realtime, unsigned long frame_count) { (void)bink; (void)realtime; (void)frame_count; }
#endif
Loading