client/tests/browser_resolution.c (34335B)
1 #include "recomp_types.h" 2 #include <assert.h> 3 4 void browser_request_resize(unsigned width, unsigned height); 5 void browser_creation_finish(const char *name); 6 void browser_chat_viewport(unsigned bottom); 7 void browser_orbit(int x, int y, int active); 8 void browser_camera_wheel(int x, int y); 9 void browser_zoom(int amount); 10 void browser_hud_insets(unsigned right, unsigned top); 11 void browser_chat_scroll(int pixels); 12 void browser_resize_frame(void); 13 void browser_touch_frame(unsigned request); 14 void browser_touch_frame_complete(void); 15 static unsigned touch_frame_reply; 16 void ao_touch_frame(unsigned request) { touch_frame_reply = request; } 17 static unsigned calls, width, height, resize_calls; 18 static int graphics_ready = 1, request_during_resize; 19 static unsigned freed_images, rebuilt_panels; 20 static unsigned logo_scales, logo_centers; 21 static float logo_scale_x, logo_scale_y; 22 static float backdrop_scale_x, backdrop_scale_y; 23 static unsigned backdrop_positions; 24 static int caption_x, caption_y; 25 static int chat_bounds[10]; 26 static unsigned chat_updates; 27 static unsigned chat_moves; 28 static unsigned chat_resizes; 29 static unsigned ui_redraws; 30 static unsigned toolbar_changes; 31 static int touch_regions[10]; 32 static unsigned touch_count, touch_updates; 33 static int touch_width, touch_height, touch_item_menu; 34 static int creation_bounds[7]; 35 static char creation_name[256]; 36 static unsigned creation_updates; 37 static unsigned creation_edits; 38 static unsigned creation_finishes; 39 static unsigned orbit_updates, orbit_stops; 40 static float orbit_x, orbit_y; 41 static unsigned camera_repositions, camera_syncs; 42 static int chat_scrolled; 43 static unsigned chat_background_width, chat_background_height; 44 45 static void resize_chat_detector(void) 46 { 47 assert(g_ecx == 0x50004b00); 48 uint32_t size = MEM32(g_esp + 4); 49 MEM32(g_ecx + 0x34) = MEM32(g_ecx + 0x2c) + MEM32(size); 50 MEM32(g_ecx + 0x38) = MEM32(g_ecx + 0x30) + MEM32(size + 4); 51 g_esp += 8; 52 } 53 54 static void scale_chat_background(void) 55 { 56 assert(g_ecx == 0x50004900); 57 chat_background_width = *(float *)ADDR(MEM32(g_esp + 4)) * 16; 58 chat_background_height = *(float *)ADDR(MEM32(g_esp + 8)) * 16; 59 g_esp += 12; 60 } 61 62 static void scroll_chat(void) 63 { 64 assert(g_ecx == 0x50003300); 65 chat_scrolled += (int32_t)MEM32(g_esp + 4); 66 g_esp += 8; 67 } 68 69 static void move_camera(void) 70 { 71 assert(g_ecx == 0x50003f00); 72 orbit_x = *(float *)ADDR(g_esp + 4); 73 orbit_y = *(float *)ADDR(g_esp + 8); 74 ++orbit_updates; 75 g_eax = 999; 76 g_st[0] = -1; 77 g_flag_cf = 0; 78 g_esp += 12; 79 } 80 81 static void stop_camera(void) 82 { 83 assert(g_ecx == 0x50003f00); 84 ++orbit_stops; 85 g_esp += 4; 86 } 87 88 static void get_camera_target(void) 89 { 90 assert(g_ecx == 0x50005200); 91 uint32_t target = MEM32(g_esp + 4); 92 memcpy((void *)ADDR(target), (float[]){10, 20, 30}, 12); 93 g_esp += 8; 94 } 95 96 static void set_camera_position(void) 97 { 98 assert(g_ecx == 0x50005200); 99 memcpy((void *)ADDR(g_ecx + 0x54), (void *)ADDR(MEM32(g_esp + 4)), 12); 100 ++camera_repositions; 101 g_esp += 8; 102 } 103 104 static void synchronize_camera(void) 105 { 106 assert(g_ecx == 0x50005200 && MEM32(g_esp + 4) == 1); 107 float x = *(float *)ADDR(g_ecx + 0x54) - 10; 108 float y = *(float *)ADDR(g_ecx + 0x58) - 20; 109 float z = *(float *)ADDR(g_ecx + 0x5c) - 30; 110 *(float *)ADDR(g_ecx + 0x174) = sqrtf(x * x + y * y + z * z); 111 ++camera_syncs; 112 g_esp += 8; 113 } 114 115 static void invalidate_ui(void) 116 { 117 assert(g_ecx == 0 && MEM32(0x27048be4) == 0x50003800); 118 ++ui_redraws; 119 g_esp += 4; 120 } 121 122 void ao_touch_regions(const int *regions, unsigned count, int screen_width, int screen_height, int item_menu) 123 { 124 assert(count <= 2); 125 memcpy(touch_regions, regions, count * 5 * sizeof(int)); 126 touch_count = count; 127 touch_width = screen_width; 128 touch_height = screen_height; 129 touch_item_menu = item_menu; 130 ++touch_updates; 131 } 132 133 void ao_creation_state(const int *bounds, const char *name) 134 { 135 memcpy(creation_bounds, bounds, sizeof(creation_bounds)); 136 snprintf(creation_name, sizeof(creation_name), "%s", name); 137 ++creation_updates; 138 } 139 140 static void set_creation_name(void) 141 { 142 assert(g_ecx == 0x50005900); 143 strcpy((char *)ADDR(0x50005b00), (const char *)ADDR(MEM32(g_esp + 4))); 144 ++creation_edits; 145 g_eax = 999; 146 g_st[0] = -1; 147 g_flag_cf = 0; 148 g_esp += 8; 149 } 150 151 static void start_server_creation(void) 152 { 153 assert(g_ecx == 0x50005500 && creation_edits == 1); 154 assert(!strcmp((const char *)ADDR(0x50005b00), "Phonehero")); 155 ++creation_finishes; 156 g_esp += 4; 157 } 158 159 static void creator_name_tracks_native_field_and_random_replies(void) 160 { 161 MEM32(0x27048be8) = 1024; 162 MEM32(0x27048bec) = 768; 163 MEM32(0x2b0ee7d0) = MEM32(0x2b0ee7e0) = 0x50005500; 164 MEM32(0x50005588) = 0x50005600; 165 MEM32(0x50005600) = 0x50005700; 166 MEM32(0x50005604) = 0x50005800; 167 MEM32(0x50005608) = 0x50005900; 168 MEM8(0x50005808) = 1; 169 MEM32(0x50005950) = 0x50005a00; 170 MEM32(0x50005a04) = 0x50005b00; 171 memcpy((void *)ADDR(0x5000572c), (int[]){358, 123, 310, 16}, 16); 172 strcpy((char *)ADDR(0x50005b00), "Nativehero"); 173 174 browser_resize_frame(); 175 unsigned published = creation_updates; 176 browser_resize_frame(); 177 178 assert(!memcmp(creation_bounds, (int[]){1, 358, 123, 310, 16, 1024, 768}, sizeof(creation_bounds))); 179 assert(!strcmp(creation_name, "Nativehero")); 180 assert(creation_updates == published); 181 182 strcpy((char *)ADDR(0x50005b00), "Randomhero"); 183 browser_resize_frame(); 184 185 assert(!strcmp(creation_name, "Randomhero") && creation_updates == published + 1); 186 187 char replacement[] = "Phonehero"; 188 uint32_t stack = g_esp; 189 browser_creation_finish("Phonebad"); 190 browser_creation_finish(replacement); 191 replacement[0] = 'X'; 192 MEM32(0x2b0e42a8) = 1004; 193 194 browser_resize_frame(); 195 196 assert(creation_edits == 0 && creation_finishes == 0); 197 MEM32(0x2b0e42a8) = 0; 198 MEM32(0x500055a4) = 0x1008; 199 200 browser_resize_frame(); 201 202 assert(creation_edits == 0 && creation_finishes == 0); 203 MEM32(0x500055a4) = 0; 204 MEM8(0x50005808) = 0; 205 206 browser_resize_frame(); 207 208 assert(creation_edits == 0 && creation_finishes == 0); 209 MEM8(0x50005808) = 1; 210 211 browser_resize_frame(); 212 browser_resize_frame(); 213 214 assert(!strcmp(creation_name, "Phonehero") && creation_edits == 1 && creation_finishes == 1); 215 assert(g_esp == stack && g_eax == 101 && g_st[0] == 123.5 && g_flag_cf == 112); 216 217 MEM8(0x50005808) = 0; 218 browser_creation_finish("Hidden"); 219 browser_resize_frame(); 220 221 assert(creation_bounds[0] == 1 && creation_bounds[3] == 0 && !creation_name[0]); 222 assert(creation_edits == 1); 223 224 MEM32(0x2b0ee7d0) = 0; 225 MEM32(0x2b0ee7e4) = 0x50005c00; 226 browser_resize_frame(); 227 228 assert(creation_bounds[0] == 1 && creation_bounds[3] == 0); 229 assert(creation_finishes == 1); 230 231 MEM32(0x2b0ee7e0) = MEM32(0x2b0ee7e4) = 0; 232 browser_resize_frame(); 233 234 assert(creation_bounds[0] == 0 && creation_bounds[3] == 0 && !creation_name[0]); 235 assert(creation_edits == 1); 236 } 237 238 static void toggle_toolbar(void) 239 { 240 assert(g_ecx == 0x50003600); 241 MEM8(g_ecx + 4) = MEM32(g_esp + 4); 242 ++toolbar_changes; 243 g_esp += 8; 244 } 245 246 void ao_chat_bounds(int x, int y, int width, int height, int screen_width, int screen_height, 247 int output_x, int output_y, int output_width, int output_height) 248 { 249 int bounds[] = {x, y, width, height, screen_width, screen_height, 250 output_x, output_y, output_width, output_height}; 251 memcpy(chat_bounds, bounds, sizeof(bounds)); 252 ++chat_updates; 253 } 254 255 static void reposition_chat(void) 256 { 257 assert(g_ecx == 0x50003100 || g_ecx == 0x50003300); 258 uint32_t window = g_ecx == 0x50003100 ? MEM32(g_ecx) : MEM32(g_ecx + 0x14); 259 uint32_t point = MEM32(g_esp + 4); 260 MEM32(window + 0x2c) = MEM32(point); 261 MEM32(window + 0x30) = MEM32(point + 4); 262 ++chat_moves; 263 g_eax = 1; 264 g_st[0] = -7; 265 g_flag_cf = 0; 266 g_esp += 8; 267 } 268 269 static void resize_chat(void) 270 { 271 assert(g_ecx == 0x50003400 || g_ecx == 0x50003500); 272 uint32_t size = MEM32(g_esp + 4); 273 MEM32(g_ecx + 0x34) = MEM32(size); 274 MEM32(g_ecx + 0x38) = MEM32(size + 4); 275 ++chat_resizes; 276 g_esp += 8; 277 } 278 279 static void reposition_backdrop(void) 280 { 281 if (g_ecx == 0x50004100 || g_ecx == 0x50004200) { 282 *(float *)ADDR(g_ecx + 0x18) = MEM32(MEM32(g_esp + 4)); 283 *(float *)ADDR(g_ecx + 0x1c) = MEM32(MEM32(g_esp + 4) + 4); 284 g_esp += 8; 285 return; 286 } 287 assert(g_ecx == 0x50002100); 288 assert(backdrop_scale_x > 0 && backdrop_scale_y > 0); 289 assert(MEM32(MEM32(g_esp + 4)) == 0); 290 assert(MEM32(MEM32(g_esp + 4) + 4) == 0); 291 ++backdrop_positions; 292 g_esp += 8; 293 } 294 295 static void scale_backdrop(void) 296 { 297 assert(g_ecx == 0x50002100); 298 backdrop_scale_x = *(float *)ADDR(MEM32(g_esp + 4)); 299 backdrop_scale_y = *(float *)ADDR(MEM32(g_esp + 8)); 300 g_esp += 12; 301 } 302 303 static void scale_logo(void) 304 { 305 assert(g_ecx == 0x50002000); 306 logo_scale_x = *(float *)ADDR(MEM32(g_esp + 4)); 307 logo_scale_y = *(float *)ADDR(MEM32(g_esp + 8)); 308 ++logo_scales; 309 g_esp += 12; 310 } 311 312 static void center_logo(void) 313 { 314 assert(g_ecx == 0x50002000 && logo_scales == logo_centers + 1); 315 assert(*(float *)ADDR(g_esp + 4) == 0.5f); 316 assert(*(float *)ADDR(g_esp + 8) == 0.5f); 317 ++logo_centers; 318 g_esp += 12; 319 } 320 321 void guest_free(uint32_t address) 322 { 323 assert(address == (freed_images ? 0x50001300 : 0x50001400)); 324 ++freed_images; 325 } 326 327 static void rebuild_panel(void) 328 { 329 assert(g_ecx == 0x50001100); 330 assert(MEM32(g_ecx + 0x28) == 0); 331 MEM32(g_ecx + 0x28) = 0x50001300; 332 MEM32(g_ecx + 0xc) = 12; 333 MEM32(0x50001300) = 0x50001500; 334 MEM32(0x50001308) = 768; 335 MEM32(0x5000130c) = 192; 336 g_esp += 16; 337 ++rebuilt_panels; 338 } 339 340 static void clear_panel(void) 341 { 342 assert(g_ecx == 0x50001200); 343 assert(MEM32(g_ecx) == 0x50001500); 344 assert(freed_images == 2); 345 g_esp += 16; 346 } 347 348 static void panel_no_arguments(void) { g_esp += 4; } 349 static void panel_one_argument(void) 350 { 351 if (g_ecx == 0x50002200) { 352 caption_x = MEM32(MEM32(g_esp + 4)); 353 caption_y = MEM32(MEM32(g_esp + 4) + 4); 354 } 355 if (g_ecx == 0x50004300 || g_ecx == 0x50004400) { 356 MEM32(g_ecx + 0x2c) = MEM32(MEM32(g_esp + 4)); 357 MEM32(g_ecx + 0x30) = MEM32(MEM32(g_esp + 4) + 4); 358 } 359 g_esp += 8; 360 } 361 static void panel_eight_arguments(void) { g_esp += 36; } 362 363 int linux_graphics_resize(unsigned new_width, unsigned new_height, uint32_t drawing_surface) 364 { 365 assert(drawing_surface == 0x50000780); 366 if (!graphics_ready) return 0; 367 width = new_width; 368 height = new_height; 369 ++resize_calls; 370 if (request_during_resize) browser_request_resize(913, 617); 371 return 1; 372 } 373 374 static void resize_buffers(void) 375 { 376 assert(calls++ == 0); 377 assert(g_ecx == 0x50000200); 378 assert(MEM32(g_esp + 4) == width && MEM32(g_esp + 8) == height); 379 assert(MEM32(0x50000100) == width && MEM32(0x50000104) == height); 380 g_esp += 12; 381 g_eax = 1; g_ecx = 2; g_edx = 3; g_ebx = 4; g_esi = 5; g_edi = 6; g_ebp = 7; 382 g_cur_func = 8; g_flag_k = 9; g_flag_a = 10; g_flag_b = 11; g_flag_cf = 12; 383 g_st[0] = -1; g_st_i64[0] = -2; g_fp_top = 3; g_fpu_cw = 4; 384 } 385 386 static void reposition_viewport(void) 387 { 388 assert(calls++ == 2); 389 assert(g_ecx == 0x50000000); 390 assert(MEM32(g_esp + 4) == 0 && MEM32(g_esp + 8) == 0); 391 g_esp += 12; 392 } 393 394 static void resize_viewport(void) 395 { 396 assert(calls++ == 1); 397 assert(g_ecx == 0x50000000); 398 assert(MEM32(g_esp + 4) == (width > 197 ? width - 197 : 1)); 399 assert(MEM32(g_esp + 8) == (height > 20 ? height - 20 : 1)); 400 assert(MEM32(0x27048be8) == width && MEM32(0x27048bec) == height); 401 assert(MEM32(0x27048bc4) == 0 && MEM32(0x27048bd0) == 0); 402 g_esp += 12; 403 } 404 405 static void reposition_detector(void) 406 { 407 assert(calls++ == 3); 408 assert(g_ecx == 0x50000400 && MEM32(g_esp + 4) == 0x50000300); 409 g_esp += 8; 410 } 411 412 static void resize_detector(void) 413 { 414 assert(calls++ == 4); 415 assert(g_ecx == 0x50000400 && MEM32(g_esp + 4) == 0x50000308); 416 g_esp += 8; 417 } 418 419 static void notify_layout(void) 420 { 421 assert(calls++ == 5); 422 assert(g_ecx == 0x50000600); 423 assert(MEM32(g_esp + 4) == 0x12 && MEM32(g_esp + 8) == 0x6e); 424 g_esp += 12; 425 } 426 427 recomp_func_t recomp_lookup(uint32_t address) 428 { 429 switch (address) { 430 case 0x250d6010: return resize_buffers; 431 case 0x250a5ff0: return reposition_viewport; 432 case 0x250a5f40: return resize_viewport; 433 case 1: return reposition_detector; 434 case 2: return resize_detector; 435 case 0x20003630: return notify_layout; 436 case 0x270181e0: return rebuild_panel; 437 case 0x250af340: return clear_panel; 438 case 0x27018620: return panel_one_argument; 439 case 5: return panel_one_argument; 440 case 0x2b03b110: case 0x27018890: case 0x27026160: case 0x270262c0: 441 return panel_no_arguments; 442 case 0x27025ec0: return panel_eight_arguments; 443 case 0x27018ac0: return scale_logo; 444 case 0x27018b20: return center_logo; 445 case 3: return scale_backdrop; 446 case 0x250ae720: return reposition_backdrop; 447 case 0x27015910: case 0x2b004560: return reposition_chat; 448 case 0x27018720: return resize_chat; 449 case 0x2b005220: return scroll_chat; 450 case 7: return scale_chat_background; 451 case 6: return resize_chat_detector; 452 case 0x2701d270: return invalidate_ui; 453 case 0x2b0775b0: return toggle_toolbar; 454 case 0x36020440: return move_camera; 455 case 0x36020470: return stop_camera; 456 case 0x38001f50: return get_camera_target; 457 case 8: return set_camera_position; 458 case 0x38004290: return synchronize_camera; 459 case 0x2701f310: return set_creation_name; 460 case 0x2b033cb0: return start_server_creation; 461 default: abort(); 462 } 463 } 464 465 static void wheel_camera_consumes_a_burst_once(void) 466 { 467 orbit_updates = orbit_stops = 0; 468 469 browser_camera_wheel(64, -32); 470 browser_camera_wheel(64, -32); 471 browser_resize_frame(); 472 473 assert(orbit_updates == 1 && orbit_stops == 0); 474 assert(orbit_x == 0.0009765625f && orbit_y == -0.00048828125f); 475 browser_resize_frame(); 476 browser_resize_frame(); 477 assert(orbit_updates == 1 && orbit_stops == 1); 478 } 479 480 static void stopping_camera_cancels_pending_wheels(void) 481 { 482 orbit_updates = orbit_stops = 0; 483 browser_camera_wheel(128, -64); 484 485 browser_orbit(0, 0, 0); 486 browser_resize_frame(); 487 488 assert(orbit_updates == 0 && orbit_stops == 0); 489 } 490 491 static void wheel_camera_preserves_an_active_touch_orbit(void) 492 { 493 orbit_updates = orbit_stops = 0; 494 browser_orbit(64, -32, 1); 495 496 browser_camera_wheel(64, -32); 497 browser_resize_frame(); 498 499 assert(orbit_updates == 1 && orbit_stops == 0); 500 assert(orbit_x == 0.0009765625f && orbit_y == -0.00048828125f); 501 browser_resize_frame(); 502 assert(orbit_updates == 2 && orbit_stops == 0); 503 assert(orbit_x == 0 && orbit_y == 0); 504 browser_orbit(0, 0, 0); 505 browser_resize_frame(); 506 assert(orbit_stops == 1); 507 } 508 509 static void inventory_touch_regions_follow_native_item_state(void) 510 { 511 MEM8(0x50004608) = 1; 512 MEM32(0x50004600) = 0x27034278; 513 MEM32(0x50004654) = 104; 514 MEM32(0x50004658) = 48; 515 MEM32(0x27048b6c) = 0x50006000; 516 517 browser_resize_frame(); 518 519 assert(touch_count == 2 && touch_regions[4] == 3); 520 assert(!touch_item_menu); 521 522 MEM8(0x50004670) = 1; 523 browser_resize_frame(); 524 assert(touch_regions[4] == 0); 525 MEM8(0x50004670) = 0; 526 MEM32(0x50006020) = 0x50004600; 527 browser_resize_frame(); 528 assert(touch_regions[4] == 0); 529 MEM32(0x50006020) = 0; 530 MEM32(0x50004658) = 6; 531 browser_resize_frame(); 532 assert(touch_regions[4] == 0); 533 MEM32(0x2b0eea14) = 0x50006200; 534 MEM32(0x5000621c) = 0x50004600; 535 browser_resize_frame(); 536 assert(touch_regions[4] == 4); 537 538 MEM32(0x27048b98) = 0x50006100; 539 browser_resize_frame(); 540 assert(touch_item_menu); 541 MEM32(0x27048b98) = 0; 542 MEM8(0x50004608) = 0; 543 MEM32(0x27048b6c) = 0; 544 MEM32(0x2b0eea14) = 0; 545 } 546 547 static void touch_frame_acknowledges_consumed_pointer_motion(void) 548 { 549 browser_touch_frame(1); 550 551 browser_touch_frame_complete(); 552 assert(touch_frame_reply == 0); 553 browser_touch_frame_complete(); 554 555 assert(touch_frame_reply == 1); 556 browser_touch_frame(2); 557 browser_touch_frame(3); 558 browser_touch_frame_complete(); 559 assert(touch_frame_reply == 1); 560 browser_touch_frame_complete(); 561 assert(touch_frame_reply == 3); 562 } 563 564 int main(void) 565 { 566 assert(guest_map("display globals", 0x25230000, 0x10000)); 567 assert(guest_map("sprite globals", 0x27040000, 0x10000)); 568 assert(guest_map("sprite imports", 0x27020000, 0x10000)); 569 assert(guest_map("action globals", 0x2b0e0000, 0x10000)); 570 assert(guest_map("chat imports", 0x2b0b0000, 0x10000)); 571 MEM32(0x2b0b5658) = 7; 572 assert(guest_map("message globals", 0x20010000, 0x10000)); 573 assert(guest_map("resize objects", 0x50000000, 0x10000)); 574 MEM32(0x25238568) = 0x50000000; 575 MEM32(0x50000008) = 0x50000100; 576 MEM32(0x50000020) = 0x50000800; 577 MEM32(0x50000804) = 1; 578 MEM32(0x50000824) = 0x50000900; 579 MEM32(0x50000900) = 0x50000a00; 580 MEM32(0x50000a04) = 0x50000b00; 581 MEM32(0x50000a08) = 0x50000b10; 582 MEM32(0x50000034) = 0x50000200; 583 MEM32(0x50000038) = 0x50000280; 584 MEM32(0x500000d4) = 0x50000700; 585 MEM32(0x50000700) = 0x50000780; 586 MEM32(0x2b0ee640) = 0x50000300; 587 MEM32(0x50000310) = 0x50000400; 588 MEM32(0x50000400) = 0x50000500; 589 MEM32(0x50000514) = 1; 590 MEM32(0x50000518) = 2; 591 MEM32(0x20015cd4) = 0x50000600; 592 MEM32(0x27048bc4) = MEM32(0x27048bd0) = 3; 593 g_esp = 0x5000ff00; 594 g_eax = 101; g_ecx = 102; g_edx = 103; g_ebx = 104; g_esi = 105; g_edi = 106; g_ebp = 107; 595 g_cur_func = 108; g_flag_k = 109; g_flag_a = 110; g_flag_b = 111; g_flag_cf = 112; 596 g_st[0] = 123.5; g_st_i64[0] = 456; g_fp_top = 7; g_fpu_cw = 0x37f; 597 598 browser_request_resize(1600, 900); 599 browser_request_resize(1001, 733); 600 browser_resize_frame(); 601 602 assert(calls == 6 && resize_calls == 1 && width == 1001 && height == 733); 603 assert(MEM32(0x50000308) == 804 && MEM32(0x5000030c) == 713); 604 assert(MEM32(0x5000080c) == 733 && MEM32(0x50000810) == 1001); 605 assert(MEM32(0x50000a08) == 0x50000b00); 606 assert(g_esp == 0x5000ff00); 607 assert(g_eax == 101 && g_ecx == 102 && g_edx == 103 && g_ebx == 104); 608 assert(g_esi == 105 && g_edi == 106 && g_ebp == 107 && g_cur_func == 108); 609 assert(g_flag_k == 109 && g_flag_a == 110 && g_flag_b == 111 && g_flag_cf == 112); 610 assert(g_st[0] == 123.5 && g_st_i64[0] == 456 && g_fp_top == 7 && g_fpu_cw == 0x37f); 611 612 calls = 0; 613 graphics_ready = 0; 614 browser_request_resize(801, 599); 615 616 browser_resize_frame(); 617 assert(!calls && resize_calls == 1); 618 graphics_ready = 1; 619 request_during_resize = 1; 620 browser_resize_frame(); 621 calls = 0; 622 request_during_resize = 0; 623 browser_resize_frame(); 624 625 assert(calls == 6 && resize_calls == 3 && width == 913 && height == 617); 626 browser_resize_frame(); 627 browser_request_resize(913, 617); 628 browser_resize_frame(); 629 browser_request_resize(0, 0); 630 browser_resize_frame(); 631 assert(calls == 6 && resize_calls == 3); 632 633 calls = 0; 634 browser_request_resize(1, 1); 635 browser_resize_frame(); 636 637 assert(calls == 6 && resize_calls == 4); 638 assert(MEM32(0x50000308) == 1 && MEM32(0x5000030c) == 1); 639 640 calls = 0; 641 MEM32(0x2b0ee9b8) = 0x50001000; 642 MEM32(0x2b0ee9dc) = 0x50001100; 643 MEM32(0x50001128) = 0x50001200; 644 MEM32(0x50001200) = 0x50001400; 645 MEM32(0x50001070) = 0x50001600; 646 MEM32(0x50001600) = 0x50001700; 647 MEM32(0x50001054) = 0x50001800; 648 MEM32(0x50001800) = MEM32(0x50001804) = 0x50001900; 649 MEM32(0x50001914) = 0x50001a00; 650 MEM32(0x50001a08) = 4; 651 uint32_t text_destination = MEM32(0x50001128); 652 653 browser_request_resize(1001, 733); 654 browser_resize_frame(); 655 656 assert(rebuilt_panels == 1 && freed_images == 2); 657 assert(MEM32(0x50001128) == text_destination); 658 assert(MEM32(text_destination) == 0x50001500); 659 assert(MEM32(text_destination + 8) == 768 && MEM32(text_destination + 12) == 192); 660 assert(g_esp == 0x5000ff00); 661 MEM32(0x2b0ee9b8) = 0; 662 MEM32(0x2b0ee968) = 0x50002000; 663 MEM32(0x2b0ee958) = 0x50002100; 664 MEM32(0x2b0ee960) = 0x50002200; 665 MEM32(0x50002234) = 224; 666 MEM32(0x27029218) = 3; 667 const struct { 668 unsigned width, height; 669 float scale, backdrop_x, backdrop_y; 670 int text_x, text_y; 671 } logo_sizes[] = { 672 {1024, 768, 1.0f, 64, 48, 400, 718}, 673 {1600, 900, 1.171875f, 100, 56.25f, 688, 850}, 674 {768, 1024, 0.75f, 48, 64, 272, 974}, 675 {320, 800, 0.3125f, 20, 50, 48, 750}, 676 {3840, 2160, 2.8125f, 240, 135, 1808, 2110} 677 }; 678 for (unsigned i = 0; i < sizeof(logo_sizes) / sizeof(logo_sizes[0]); ++i) { 679 calls = 0; 680 681 browser_request_resize(logo_sizes[i].width, logo_sizes[i].height); 682 browser_resize_frame(); 683 684 assert(logo_scale_x == logo_sizes[i].scale && logo_scale_y == logo_sizes[i].scale); 685 assert(logo_scales == i + 1 && logo_centers == i + 1); 686 assert(backdrop_scale_x == logo_sizes[i].backdrop_x && backdrop_scale_y == logo_sizes[i].backdrop_y); 687 assert(backdrop_positions == i + 1); 688 assert(caption_x == logo_sizes[i].text_x && caption_y == logo_sizes[i].text_y); 689 assert(g_esp == 0x5000ff00); 690 } 691 MEM32(0x2b0ee6a4) = 0x50003000; 692 MEM32(0x50003008) = 0x50003100; 693 MEM32(0x5000300c) = 0x50003300; 694 MEM32(0x50003314) = 0x50003400; 695 MEM32(0x50003100) = 0x50003200; 696 MEM32(0x5000322c) = 10; 697 MEM32(0x50003230) = 690; 698 MEM32(0x50003234) = 322; 699 MEM32(0x50003238) = 16; 700 MEM32(0x27048be8) = 1024; 701 MEM32(0x27048bec) = 768; 702 703 browser_resize_frame(); 704 browser_resize_frame(); 705 706 assert(chat_updates == 1); 707 assert(chat_bounds[0] == 11 && chat_bounds[1] == 691); 708 assert(chat_bounds[2] == 320 && chat_bounds[3] == 14); 709 assert(chat_bounds[4] == 1024 && chat_bounds[5] == 768); 710 711 MEM32(0x50003230) = 390; 712 MEM32(0x27048bec) = 468; 713 browser_resize_frame(); 714 715 assert(chat_updates == 2 && chat_bounds[1] == 391 && chat_bounds[5] == 468); 716 717 MEM32(0x50003338) = 15; 718 MEM32(0x50003318) = 0x50004b00; 719 MEM32(0x50004b00) = 0x50004a00; 720 MEM32(0x50004a18) = 6; 721 MEM32(0x50003320) = 0x50004900; 722 MEM32(0x50003348) = 322; 723 MEM32(0x5000333c) = 10; 724 MEM32(0x5000334c) = 150; 725 MEM32(0x5000332c) = 30; 726 MEM32(0x50003358) = 20; 727 MEM8(0x50003360) = 1; 728 MEM32(0x5000336c) = 0x50003500; 729 MEM32(0x5000342c) = 10; 730 MEM32(0x50003430) = 540; 731 MEM32(0x50003438) = 150; 732 MEM32(0x50003434) = 322; 733 MEM32(0x50003534) = 11; 734 MEM32(0x50003538) = 150; 735 MEM32(0x50003230) = 690; 736 MEM32(0x27048bec) = 768; 737 MEM32(0x2b0ef034) = 0x50003600; 738 MEM32(0x50003638) = 0x50003900; 739 MEM32(0x5000392c) = 500; 740 MEM32(0x50003930) = 300; 741 MEM32(0x50003934) = 64; 742 MEM32(0x50003938) = 64; 743 MEM32(0x5000365c) = 0x50003700; 744 MEM32(0x5000372c) = 20; 745 MEM32(0x50003730) = 50; 746 MEM32(0x50003734) = 220; 747 MEM32(0x50003738) = 100; 748 MEM32(0x27048be4) = 0x50003800; 749 750 browser_chat_viewport(200); 751 browser_resize_frame(); 752 browser_resize_frame(); 753 754 assert(MEM32(0x50003230) == 184 && MEM32(0x50003430) == 34); 755 assert(MEM32(0x5000322c) == 20 && MEM32(0x5000342c) == 20); 756 assert(chat_bounds[0] == 21); 757 assert(chat_bounds[1] == 185 && chat_bounds[5] == 768); 758 assert(chat_moves == 2 && resize_calls == 10); 759 assert(MEM32(0x50003238) == 16 && MEM32(0x50003438) == 150); 760 assert(g_eax == 101 && g_st[0] == 123.5 && g_flag_cf == 112); 761 assert(g_esp == 0x5000ff00); 762 assert(MEM8(0x50003604) == 1 && toolbar_changes == 1); 763 assert(ui_redraws == 1); 764 765 browser_chat_viewport(120); 766 browser_resize_frame(); 767 768 assert(MEM32(0x50003230) == 104 && MEM32(0x50003430) == 14); 769 assert(MEM32(0x5000322c) == 20 && MEM32(0x5000342c) == 20); 770 assert(MEM32(0x50003438) == 90 && MEM32(0x50003538) == 90); 771 assert(MEM32(0x5000333c) == 6 && MEM32(0x5000334c) == 90); 772 assert(MEM32(0x50003358) == 24 && MEM8(0x50003309) == 1); 773 assert(chat_resizes == 2); 774 assert(MEM8(0x50003604) == 1 && toolbar_changes == 1); 775 assert(chat_moves == 4 && resize_calls == 10); 776 assert(ui_redraws == 2); 777 778 browser_chat_viewport(0); 779 browser_resize_frame(); 780 browser_resize_frame(); 781 782 assert(MEM32(0x50003230) == 690 && MEM32(0x50003430) == 540); 783 assert(MEM32(0x5000322c) == 10 && MEM32(0x5000342c) == 10); 784 assert(chat_bounds[0] == 11); 785 assert(chat_bounds[1] == 691 && chat_moves == 6 && resize_calls == 10); 786 assert(MEM32(0x50003438) == 150 && MEM32(0x50003538) == 150); 787 assert(MEM32(0x5000333c) == 10 && MEM32(0x5000334c) == 150); 788 assert(MEM32(0x50003358) == 20 && chat_resizes == 4); 789 assert(MEM8(0x50003604) == 0 && toolbar_changes == 2); 790 assert(ui_redraws == 3); 791 792 MEM32(0x50003730) = 174; 793 MEM32(0x50003738) = 224; 794 795 browser_chat_viewport(200); 796 browser_resize_frame(); 797 798 assert(MEM8(0x50003604) == 0 && toolbar_changes == 2); 799 800 MEM32(0x50003730) = 173; 801 MEM32(0x50003738) = 223; 802 browser_resize_frame(); 803 804 assert(MEM8(0x50003604) == 1 && toolbar_changes == 3); 805 806 MEM32(0x5000372c) = 400; 807 MEM32(0x50003734) = 600; 808 browser_resize_frame(); 809 810 assert(MEM8(0x50003604) == 0 && toolbar_changes == 4); 811 812 MEM32(0x5000372c) = 20; 813 MEM32(0x50003734) = 220; 814 MEM8(0x50003604) = 1; 815 816 browser_resize_frame(); 817 browser_chat_viewport(0); 818 browser_resize_frame(); 819 820 assert(MEM8(0x50003604) == 1 && toolbar_changes == 4); 821 822 MEM32(0x5000322c) = 40; 823 MEM32(0x5000342c) = 60; 824 825 browser_chat_viewport(200); 826 browser_resize_frame(); 827 assert(MEM32(0x5000322c) == 40 && MEM32(0x5000342c) == 60); 828 browser_chat_viewport(0); 829 browser_resize_frame(); 830 831 assert(MEM32(0x5000322c) == 40 && MEM32(0x5000342c) == 60); 832 833 MEM32(0x27048b7c) = 0x50004000; 834 MEM32(0x50004000) = 0x50004100; 835 MEM8(0x50004004) = 1; 836 MEM32(0x50004104) = 0x50004200; 837 MEM32(0x50004200) = 0x50004300; 838 MEM32(0x50004300) = 0x50004400; 839 MEM32(0x50004308) = 0x50004600; 840 MEM32(0x50004400) = 0x50004500; 841 MEM32(0x50004408) = 0x50004700; 842 MEM32(0x50004500) = 0x50004200; 843 MEM32(0x50004508) = 0x50004800; 844 MEM8(0x50004608) = MEM8(0x50004708) = 1; 845 MEM32(0x5000462c) = 20; 846 MEM32(0x50004630) = 30; 847 MEM32(0x50004634) = 200; 848 MEM32(0x50004638) = 300; 849 MEM32(0x50004734) = 1024; 850 MEM32(0x50004738) = 768; 851 MEM32(MEM32(0x2b0ee640) + 0x10) = 0x50004700; 852 MEM32(0x50003318) = 0x50004600; 853 854 browser_resize_frame(); 855 unsigned published = touch_updates; 856 browser_resize_frame(); 857 858 int expected[] = {20, 30, 200, 300, 2, 0, 0, 1024, 768, 1}; 859 assert(touch_count == 2 && touch_width == 1024 && touch_height == 768); 860 assert(!memcmp(touch_regions, expected, sizeof(expected))); 861 assert(touch_updates == published); 862 assert(g_eax == 101 && g_st[0] == 123.5 && g_flag_cf == 112); 863 864 MEM8(0x50004608) = 0; 865 MEM32(0x50003318) = 0x50004b00; 866 browser_resize_frame(); 867 868 assert(touch_count == 1 && touch_regions[4] == 1); 869 assert(touch_updates == published + 1); 870 inventory_touch_regions_follow_native_item_state(); 871 assert(guest_map("camera interface", 0x2d010000, 0x10000)); 872 MEM32(0x2d01752c) = 0x50003f00; 873 uint32_t stack = g_esp; 874 875 browser_orbit(64, -32, 1); 876 browser_orbit(64, -32, 1); 877 browser_resize_frame(); 878 879 assert(orbit_updates == 1 && orbit_stops == 0); 880 assert(orbit_x == 0.0009765625f && orbit_y == -0.00048828125f); 881 assert(g_esp == stack && g_eax == 101 && g_st[0] == 123.5 && g_flag_cf == 112); 882 883 browser_resize_frame(); 884 browser_orbit(0, 0, 0); 885 browser_resize_frame(); 886 browser_resize_frame(); 887 888 assert(orbit_updates == 2 && orbit_x == 0 && orbit_y == 0); 889 assert(orbit_stops == 1); 890 assert(g_esp == stack && g_eax == 101 && g_st[0] == 123.5 && g_flag_cf == 112); 891 892 browser_orbit(100, 100, 1); 893 browser_orbit(0, 0, 0); 894 browser_orbit(0, 0, 1); 895 browser_resize_frame(); 896 browser_orbit(0, 0, 0); 897 browser_resize_frame(); 898 899 assert(orbit_updates == 3 && orbit_x == 0 && orbit_y == 0); 900 assert(orbit_stops == 2); 901 902 MEM32(0x2b0eea5c) = 0x50004000; 903 MEM32(0x500040dc) = 0x50004100; 904 MEM32(0x500040e0) = 0x50004200; 905 MEM32(0x500040e8) = 0x50004300; 906 MEM32(0x500040e4) = 0x50004400; 907 MEM32(0x50004300) = MEM32(0x50004400) = 0x50004500; 908 MEM32(0x50004514) = 5; 909 *(float *)ADDR(0x5000421c) = 144; 910 MEM32(0x50004430) = 144; 911 912 browser_hud_insets(24, 24); 913 browser_resize_frame(); 914 915 assert(*(float *)ADDR(0x5000411c) == 24 && *(float *)ADDR(0x5000421c) == 168); 916 assert(MEM32(0x50004330) == 24 && MEM32(0x50004430) == 168); 917 assert(g_esp == stack && g_eax == 101 && g_st[0] == 123.5 && g_flag_cf == 112); 918 919 browser_hud_insets(24, 0); 920 browser_resize_frame(); 921 922 assert(*(float *)ADDR(0x5000411c) == 0 && *(float *)ADDR(0x5000421c) == 144); 923 assert(MEM32(0x50004330) == 0 && MEM32(0x50004430) == 144); 924 925 browser_hud_insets(0, 0); 926 browser_resize_frame(); 927 *(float *)ADDR(0x5000411c) = 7; 928 browser_resize_frame(); 929 930 assert(*(float *)ADDR(0x5000411c) == 7); 931 932 MEM32(0x5000322c) = MEM32(0x5000342c) = 0; 933 MEM32(0x50003230) = 690; 934 MEM32(0x50003430) = 540; 935 936 browser_hud_insets(24, 0); 937 browser_resize_frame(); 938 unsigned moves = chat_moves; 939 browser_resize_frame(); 940 941 assert(MEM32(0x5000322c) == 12 && MEM32(0x5000342c) == 12); 942 assert(MEM32(0x50003230) == 690 && MEM32(0x50003430) == 540); 943 assert(chat_moves == moves); 944 945 browser_chat_viewport(200); 946 browser_resize_frame(); 947 948 assert(MEM32(0x5000322c) == 20 && MEM32(0x5000342c) == 20); 949 assert(MEM32(0x50003230) == 184 && MEM32(0x50003430) == 34); 950 951 browser_chat_viewport(0); 952 browser_resize_frame(); 953 browser_hud_insets(48, 0); 954 browser_resize_frame(); 955 956 assert(MEM32(0x5000322c) == 24 && MEM32(0x5000342c) == 24); 957 assert(MEM32(0x50003230) == 690 && MEM32(0x50003430) == 540); 958 959 MEM32(0x5000342c) = 80; 960 961 browser_resize_frame(); 962 browser_hud_insets(0, 0); 963 browser_resize_frame(); 964 965 assert(MEM32(0x5000342c) == 80); 966 967 MEM32(0x5000322c) = MEM32(0x5000342c) = 0; 968 969 browser_resize_frame(); 970 971 assert(MEM32(0x5000322c) == 0 && MEM32(0x5000342c) == 0); 972 973 MEM32(0x27048be8) = 320; 974 975 browser_hud_insets(24, 0); 976 browser_resize_frame(); 977 978 assert(MEM32(0x5000342c) == 12 && MEM32(0x50003434) == 285); 979 assert(MEM32(0x50003350) == 285 && MEM32(0x50003348) == 285); 980 assert(chat_bounds[6] == 12 && chat_bounds[8] == 285); 981 assert(chat_background_width == 285 && chat_background_height == 150); 982 assert(MEM32(0x50004b34) - MEM32(0x50004b2c) == 285); 983 assert(MEM32(0x5000342c) + MEM32(0x50003434) + 11 == 308); 984 985 MEM32(0x27048be8) = 844; 986 browser_resize_frame(); 987 browser_chat_scroll(8); 988 browser_resize_frame(); 989 browser_chat_scroll(22); 990 browser_resize_frame(); 991 992 assert(MEM32(0x50003434) == 322 && MEM32(0x50003350) == 322); 993 assert(chat_scrolled == -2); 994 995 browser_chat_scroll(-15); 996 browser_resize_frame(); 997 browser_hud_insets(0, 0); 998 browser_chat_scroll(60); 999 browser_resize_frame(); 1000 1001 assert(chat_scrolled == -1); 1002 1003 MEM32(0x50003f80) = 0x50005000; 1004 MEM32(0x5000519c) = 1; 1005 MEM32(0x50005060) = 0x50005200; 1006 MEM32(0x50005200) = 0x50005400; 1007 MEM32(0x50005488) = 0x38004290; 1008 assert(guest_map("camera imports", 0x38040000, 0x10000)); 1009 MEM32(0x3804e6f4) = 8; 1010 *(float *)ADDR(0x50005374) = 10; 1011 memcpy((void *)ADDR(0x50005254), (float[]){4, 12, 30}, 12); 1012 1013 browser_zoom(-32768); 1014 browser_zoom(-32768); 1015 browser_resize_frame(); 1016 1017 assert(fabsf(*(float *)ADDR(0x50005374) - 3.6787944f) < 0.00001f); 1018 assert(fabsf(*(float *)ADDR(0x50005254) - 7.792723f) < 0.00001f); 1019 assert(fabsf(*(float *)ADDR(0x50005258) - 17.056965f) < 0.00001f); 1020 assert(*(float *)ADDR(0x5000525c) == 30); 1021 assert(camera_repositions == 1 && camera_syncs == 1); 1022 assert(g_esp == stack && g_eax == 101 && g_st[0] == 123.5 && g_flag_cf == 112); 1023 1024 browser_resize_frame(); 1025 1026 assert(fabsf(*(float *)ADDR(0x50005374) - 3.6787944f) < 0.00001f); 1027 assert(camera_repositions == 1 && camera_syncs == 1); 1028 1029 browser_zoom(65536); 1030 browser_resize_frame(); 1031 1032 assert(fabsf(*(float *)ADDR(0x50005374) - 10) < 0.00001f); 1033 assert(fabsf(*(float *)ADDR(0x50005254) - 4) < 0.00001f); 1034 assert(fabsf(*(float *)ADDR(0x50005258) - 12) < 0.00001f); 1035 assert(*(float *)ADDR(0x5000525c) == 30); 1036 1037 /* Touch pinch uses the same zoom path while an orbit is held. */ 1038 browser_orbit(0, 0, 1); 1039 1040 browser_zoom(655360); 1041 browser_resize_frame(); 1042 1043 assert(fabsf(*(float *)ADDR(0x50005374) - 150) < 0.0001f); 1044 assert(fabsf(*(float *)ADDR(0x50005254) + 80) < 0.0001f); 1045 assert(fabsf(*(float *)ADDR(0x50005258) + 100) < 0.0001f); 1046 1047 browser_zoom(-655360); 1048 browser_resize_frame(); 1049 1050 assert(fabsf(*(float *)ADDR(0x50005374) - 0.7f) < 0.00001f); 1051 assert(fabsf(*(float *)ADDR(0x50005254) - 9.58f) < 0.00001f); 1052 assert(fabsf(*(float *)ADDR(0x50005258) - 19.44f) < 0.00001f); 1053 1054 MEM32(0x5000519c) = 0; 1055 1056 browser_zoom(65536); 1057 browser_resize_frame(); 1058 1059 assert(fabsf(*(float *)ADDR(0x50005374) - 0.7f) < 0.00001f); 1060 1061 MEM32(0x5000519c) = 1; 1062 1063 browser_zoom(65536); 1064 browser_orbit(0, 0, 0); 1065 browser_orbit(0, 0, 1); 1066 browser_resize_frame(); 1067 browser_orbit(0, 0, 0); 1068 browser_resize_frame(); 1069 1070 assert(fabsf(*(float *)ADDR(0x50005374) - 0.7f) < 0.00001f); 1071 assert(camera_repositions == 4 && camera_syncs == 4); 1072 1073 browser_orbit(0, 0, 1); 1074 for (unsigned i = 0; i < 8; ++i) { 1075 browser_zoom(i % 2 ? -256 : 256); 1076 browser_resize_frame(); 1077 assert(*(float *)ADDR(0x50005254) < 10 && *(float *)ADDR(0x50005258) < 20); 1078 } 1079 browser_orbit(0, 0, 0); 1080 browser_resize_frame(); 1081 1082 assert(fabsf(*(float *)ADDR(0x50005374) - 0.7f) < 0.00001f); 1083 assert(*(float *)ADDR(0x5000525c) == 30); 1084 wheel_camera_consumes_a_burst_once(); 1085 stopping_camera_cancels_pending_wheels(); 1086 wheel_camera_preserves_an_active_touch_orbit(); 1087 creator_name_tracks_native_field_and_random_replies(); 1088 touch_frame_acknowledges_consumed_pointer_motion(); 1089 puts("Browser resize, guest state, mobile chat, camera orbit, wheel and pinch zoom checks passed"); 1090 return 0; 1091 }