aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 589d0c85621ff33edf19e4c06ffd5967d33c8b37
parent 568389f2022e866e434db0e051fd1667dc5bc505
Author: anon <anon@example.com>
Date:   Sun, 18 Oct 2026 19:51:01 +0000

Preserve loading artwork proportions across viewport changes

Diffstat:
Msrc/game/ddr.dll/lifted-0014.c | 16++++++++++++----
Msrc/runtime/browser_resolution.c | 19+++++++++++++++++++
Msrc/tests/browser_resolution.c | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 116 insertions(+), 6 deletions(-)

diff --git a/src/game/ddr.dll/lifted-0014.c b/src/game/ddr.dll/lifted-0014.c @@ -983,10 +983,18 @@ L_2B039BC0: ecx = MEM32(0x2B0EE968); /* 0x2B039BF2: mov ecx, dword ptr [0x2b0ee968] */ RECOMP_ICALL(MEM32(0x2B0B5BDC)); /* 0x2B039BF8: call dword ptr [0x2b0b5bdc] */ RECOMP_FLAGS_IN(); - ecx = MEM32(0x2B0EE968); /* 0x2B039BFE: mov ecx, dword ptr [0x2b0ee968] */ - PUSH32(esp, 0x44400000u); /* 0x2B039C04: push 0x44400000 */ - PUSH32(esp, 0x44800000u); /* 0x2B039C09: push 0x44800000 */ - RECOMP_ICALL(MEM32(0x2B0B5B18)); /* 0x2B039C0E: call dword ptr [0x2b0b5b18] */ + /* Fit the loading artwork uniformly inside its 1024x768 reference area. */ + ecx = MEM32(0x2B0EE968); + esp -= 4; + *(float *)ADDR(esp) = fminf((float)MEM32(ebp - 0x18) / 1024.0f, + (float)MEM32(ebp - 0x14) / 768.0f); + { + uint32_t scale = esp; + PUSH32(esp, scale); + PUSH32(esp, scale); + RECOMP_ICALL(0x27018AC0u); /* RenderWindow_t::SetScale */ + } + esp += 4; RECOMP_FLAGS_IN(); ecx = MEM32(0x2B0EE968); /* 0x2B039C14: mov ecx, dword ptr [0x2b0ee968] */ PUSH32(esp, 1); /* 0x2B039C1A: push 1 */ diff --git a/src/runtime/browser_resolution.c b/src/runtime/browser_resolution.c @@ -236,6 +236,25 @@ void browser_resize_frame(void) } else { call_method(0x250a5f40, display, 2, (uint32_t[]){width, height}); } + /* Keep the loading logo centered and undistorted across viewport changes. */ + if (MEM32(0x2b0ee968)) { + g_esp -= 4; + *(float *)ADDR(g_esp) = fminf(width / 1024.0f, height / 768.0f); + call_method(0x27018ac0, MEM32(0x2b0ee968), 2, (uint32_t[]){g_esp, g_esp}); + g_esp += 4; + call_method(0x27018b20, MEM32(0x2b0ee968), 2, (uint32_t[]){0x3f000000, 0x3f000000}); + + /* Stretch the black 16x16 backdrop and reposition the loading caption. */ + g_esp -= 8; + *(float *)ADDR(g_esp) = width / 16.0f; + *(float *)ADDR(g_esp + 4) = height / 16.0f; + call_method(MEM32(0x27029218), MEM32(0x2b0ee958), 2, (uint32_t[]){g_esp, g_esp + 4}); + g_esp += 8; + move_point(0x250ae720, MEM32(0x2b0ee958), 0, 0); + if (MEM32(0x2b0ee960)) + move_point(0x27018620, MEM32(0x2b0ee960), + ((int)width - (int)MEM32(MEM32(0x2b0ee960) + 0x34)) / 2, (int)height - 50); + } resize_status_bar(width, height); resize_side_panel(width, height); resize_windows(width, height_change); diff --git a/src/tests/browser_resolution.c b/src/tests/browser_resolution.c @@ -6,6 +6,47 @@ void browser_resize_frame(void); static unsigned calls, width, height, resize_calls; static int graphics_ready = 1, request_during_resize; static unsigned freed_images, rebuilt_panels; +static unsigned logo_scales, logo_centers; +static float logo_scale_x, logo_scale_y; +static float backdrop_scale_x, backdrop_scale_y; +static unsigned backdrop_positions; +static int caption_x, caption_y; + +static void reposition_backdrop(void) +{ + assert(g_ecx == 0x50002100); + assert(backdrop_scale_x > 0 && backdrop_scale_y > 0); + assert(MEM32(MEM32(g_esp + 4)) == 0); + assert(MEM32(MEM32(g_esp + 4) + 4) == 0); + ++backdrop_positions; + g_esp += 8; +} + +static void scale_backdrop(void) +{ + assert(g_ecx == 0x50002100); + backdrop_scale_x = *(float *)ADDR(MEM32(g_esp + 4)); + backdrop_scale_y = *(float *)ADDR(MEM32(g_esp + 8)); + g_esp += 12; +} + +static void scale_logo(void) +{ + assert(g_ecx == 0x50002000); + logo_scale_x = *(float *)ADDR(MEM32(g_esp + 4)); + logo_scale_y = *(float *)ADDR(MEM32(g_esp + 8)); + ++logo_scales; + g_esp += 12; +} + +static void center_logo(void) +{ + assert(g_ecx == 0x50002000 && logo_scales == logo_centers + 1); + assert(*(float *)ADDR(g_esp + 4) == 0.5f); + assert(*(float *)ADDR(g_esp + 8) == 0.5f); + ++logo_centers; + g_esp += 12; +} void guest_free(uint32_t address) { @@ -35,7 +76,14 @@ static void clear_panel(void) } static void panel_no_arguments(void) { g_esp += 4; } -static void panel_one_argument(void) { g_esp += 8; } +static void panel_one_argument(void) +{ + if (g_ecx == 0x50002200) { + caption_x = MEM32(MEM32(g_esp + 4)); + caption_y = MEM32(MEM32(g_esp + 4) + 4); + } + g_esp += 8; +} static void panel_eight_arguments(void) { g_esp += 36; } int linux_graphics_resize(unsigned new_width, unsigned new_height, uint32_t drawing_surface) @@ -117,6 +165,10 @@ recomp_func_t recomp_lookup(uint32_t address) case 0x2b03b110: case 0x27018890: case 0x27026160: case 0x270262c0: return panel_no_arguments; case 0x27025ec0: return panel_eight_arguments; + case 0x27018ac0: return scale_logo; + case 0x27018b20: return center_logo; + case 3: return scale_backdrop; + case 0x250ae720: return reposition_backdrop; default: abort(); } } @@ -125,6 +177,7 @@ int main(void) { assert(guest_map("display globals", 0x25230000, 0x10000)); assert(guest_map("sprite globals", 0x27040000, 0x10000)); + assert(guest_map("sprite imports", 0x27020000, 0x10000)); assert(guest_map("action globals", 0x2b0e0000, 0x10000)); assert(guest_map("message globals", 0x20010000, 0x10000)); assert(guest_map("resize objects", 0x50000000, 0x10000)); @@ -215,6 +268,36 @@ int main(void) assert(MEM32(text_destination) == 0x50001500); assert(MEM32(text_destination + 8) == 768 && MEM32(text_destination + 12) == 192); assert(g_esp == 0x5000ff00); - puts("Browser resize request, frame boundary, and guest state checks passed"); + MEM32(0x2b0ee9b8) = 0; + MEM32(0x2b0ee968) = 0x50002000; + MEM32(0x2b0ee958) = 0x50002100; + MEM32(0x2b0ee960) = 0x50002200; + MEM32(0x50002234) = 224; + MEM32(0x27029218) = 3; + const struct { + unsigned width, height; + float scale, backdrop_x, backdrop_y; + int text_x, text_y; + } logo_sizes[] = { + {1024, 768, 1.0f, 64, 48, 400, 718}, + {1600, 900, 1.171875f, 100, 56.25f, 688, 850}, + {768, 1024, 0.75f, 48, 64, 272, 974}, + {320, 800, 0.3125f, 20, 50, 48, 750}, + {3840, 2160, 2.8125f, 240, 135, 1808, 2110} + }; + for (unsigned i = 0; i < sizeof(logo_sizes) / sizeof(logo_sizes[0]); ++i) { + calls = 0; + + browser_request_resize(logo_sizes[i].width, logo_sizes[i].height); + browser_resize_frame(); + + assert(logo_scale_x == logo_sizes[i].scale && logo_scale_y == logo_sizes[i].scale); + assert(logo_scales == i + 1 && logo_centers == i + 1); + assert(backdrop_scale_x == logo_sizes[i].backdrop_x && backdrop_scale_y == logo_sizes[i].backdrop_y); + assert(backdrop_positions == i + 1); + assert(caption_x == logo_sizes[i].text_x && caption_y == logo_sizes[i].text_y); + assert(g_esp == 0x5000ff00); + } + puts("Browser resize request, frame boundary, loading logo, and guest state checks passed"); return 0; }