rebuild iggy's native movie player runtime
This commit is contained in:
@@ -1135,3 +1135,31 @@ foreach(platform IN ITEMS durango orbis ps3 vita)
|
||||
target_compile_options(${target} PRIVATE /Oi-)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# swf_play -- Iggy's movie playback + display-list execution runtime (the
|
||||
# IggyPlayer tick/play/pause/focus/clipboard, advance_movie, do_placeobject,
|
||||
# play_framescripts, sprite/textfield/button/shape create+destroy, hit-testing,
|
||||
# input dispatch, audio/voice). EXACTLY 68 exports on every platform; per-
|
||||
# platform source_functions diverges (durango 112 / orbis 90 / ps3 90 / vita 93)
|
||||
# while the 68-export ABI stays invariant. OWNS 1 data global
|
||||
# (iggy_double_click_time, a 4-byte float defaulting to 0.5 -- big-endian on
|
||||
# ps3). Every deep-engine struct/field offset is width-gated field-for-field
|
||||
# for the 32-bit ps3/vita targets (ps3 is 32-bit big-endian). References the 72
|
||||
# invariant cross-module imports (nearly the whole as3vm/iggy movie+render
|
||||
# surface plus swf_decode's iggy_libraries); guard memset/setjmp against builtin
|
||||
# re-synthesis with -fno-builtin (clang/gcc) or /Oi- (MSVC).
|
||||
foreach(platform IN ITEMS durango orbis ps3 vita)
|
||||
string(TOUPPER ${platform} platform_upper)
|
||||
set(target iggy_reconstructed_swf_play_${platform})
|
||||
add_library(${target} STATIC swf_play.c)
|
||||
target_compile_definitions(
|
||||
${target}
|
||||
PRIVATE IGGY_RECONSTRUCT_SWF_PLAY_${platform_upper}
|
||||
)
|
||||
configure_iggy_reconstructed_target(${target} c_std_11)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
|
||||
target_compile_options(${target} PRIVATE -fno-builtin)
|
||||
elseif(MSVC)
|
||||
target_compile_options(${target} PRIVATE /Oi-)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -1002,6 +1002,31 @@ big-endian. The module references the 34 invariant cross-module imports, owns no
|
||||
stray global, and pulls no ARM soft-float; a couple of auxiliary non-runtime
|
||||
success-path offsets remain marked `*derived*` in-source.
|
||||
|
||||
`swf_play.c` restores Iggy's movie playback + display-list execution runtime —
|
||||
the largest single behavioral surface reconstructed so far — behind its 68
|
||||
exports: the `IggyPlayer` tick/play/pause/focus/clipboard entry points, movie
|
||||
advance/create/destroy/insert, `do_placeobject`/`do_placement`, the framescript
|
||||
player, sprite/textfield/button/shape construction + teardown, hit-testing, the
|
||||
input-event dispatch, and the audio/voice path. It owns one data global
|
||||
(`iggy_double_click_time`, a 4-byte float defaulting to 0.5, emitted big-endian
|
||||
on ps3). The body was reconstructed family-by-family from the authoritative
|
||||
durango decompile with every deep-engine struct/field offset width-gated
|
||||
field-for-field from the ps3/vita raw (ps3 is 32-bit big-endian). The
|
||||
independent review confirmed the bulk faithful — the pinned player/movie leaf
|
||||
paths, the pattern-derived mouseover/button offsets, `iggy_is_weak_ptr`'s
|
||||
nursery/old-generation pool walk (object-resolved), the contract corrections
|
||||
(`PL_ROOT`, `MV_NAME`, the `as3vm_nullundef_storage` data-import rewiring, several
|
||||
import return types), and the `shift_mapping`/`dummy_button`/`dummy_text` data
|
||||
blobs — and caught a cluster of input-engine defects since fixed against the
|
||||
orbis dispatch: an inverted focus gained/lost status, the mouse-event argument
|
||||
marshalling (related/extra order + the wheel-delta and click-count fields in the
|
||||
event struct), a dropped keydown AS3 dispatch, and a 32-bit output-offset bug.
|
||||
It references the 72 invariant cross-module imports (including `swf_decode`'s
|
||||
`iggy_libraries`), owns no stray global, and pulls no ARM soft-float; a few
|
||||
deep 32-bit offsets that vita inlines out of existence remain annotated
|
||||
`*derived*` in-source, and one cross-module propagation detail in the mouse-event
|
||||
callee is tracked as a follow-up.
|
||||
|
||||
Configure this directory directly with CMake to build the reconstructed units.
|
||||
Every added module must compile independently and have behavioral tests before
|
||||
it is listed in `modules.tsv` as complete.
|
||||
|
||||
@@ -189,3 +189,7 @@ swf_decode 69 9 durango complete
|
||||
swf_decode 41 9 orbis complete
|
||||
swf_decode 48 9 ps3 complete
|
||||
swf_decode 57 9 vita complete
|
||||
swf_play 112 68 durango complete
|
||||
swf_play 90 68 orbis complete
|
||||
swf_play 90 68 ps3 complete
|
||||
swf_play 93 68 vita complete
|
||||
|
||||
|
344
iggy-decompiled/src/reconstructed/swf_play.c
Normal file
344
iggy-decompiled/src/reconstructed/swf_play.c
Normal file
@@ -0,0 +1,344 @@
|
||||
/*
|
||||
* swf_play.c -- source-equivalent reconstruction of Iggy 1.2.30's movie playback
|
||||
* + display-list execution runtime. 68 exported entry points: the IggyPlayer*
|
||||
* tick / play / pause / focus / clipboard surface, IggySetDoubleClickTime, the
|
||||
* AS3 value bridge (as3vm_get_movie_as3value_GC), the movie advance / PlaceObject
|
||||
* / framescript engine, the sprite / textfield / button / shape lifecycle,
|
||||
* hit-testing, the seek queue and the audio / voice path.
|
||||
*
|
||||
* Recovered by reconciling all four Ghidra decompiles
|
||||
* (raw/{durango,orbis,ps3,vita}/swf_play.c) against the retail objects
|
||||
* work/iggy-native-decomp/<platform>-objects/swf_play.obj (llvm-objdump -d -r / -s
|
||||
* used to resolve the Ghidra &DAT_/&_pdata_/&__ImageBase artifacts and the frozen
|
||||
* import surface). durango (64-bit LE) is authoritative for structure; vita
|
||||
* (32-bit LE) fixes every pointer-width-gated width; ps3 (32-bit BE PPC) confirms
|
||||
* the big-endian byte/bitfield lanes; orbis (64-bit LE) corroborates durango.
|
||||
*
|
||||
* Canonical retail source path: c:\projects\g\src\flash\swf_play.c
|
||||
*
|
||||
* OWNS EXACTLY ONE externally named data global:
|
||||
* iggy_double_click_time 4-byte float defaulting to 0.5f -- the double-click
|
||||
* window; IggySetDoubleClickTime writes ms / 1000.0.
|
||||
* (durango's other read-only R symbols are ??_C@ / __real@ / __xmm@ MSVC
|
||||
* artifacts; ps3's extra D symbols are .opd descriptors -- neither is owned data.)
|
||||
*/
|
||||
|
||||
/* ---- Platform selection (one #error idiom, matching the swf_decode sibling). */
|
||||
#if defined(IGGY_RECONSTRUCT_SWF_PLAY_DURANGO)
|
||||
# define IGGY_PTR64 1
|
||||
#elif defined(IGGY_RECONSTRUCT_SWF_PLAY_ORBIS)
|
||||
# define IGGY_PTR64 1
|
||||
#elif defined(IGGY_RECONSTRUCT_SWF_PLAY_PS3)
|
||||
# define IGGY_PTR64 0
|
||||
# define IGGY_BIG_ENDIAN 1
|
||||
#elif defined(IGGY_RECONSTRUCT_SWF_PLAY_VITA)
|
||||
# define IGGY_PTR64 0
|
||||
#else
|
||||
# error "define one of IGGY_RECONSTRUCT_SWF_PLAY_{DURANGO,ORBIS,PS3,VITA}"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "swf_play.h"
|
||||
|
||||
/* Provenance: the canonical Iggy source path (retail embeds this exact string via
|
||||
* iggy_malloc_fileline on all four platforms; durango additionally carries its
|
||||
* build .obj path). */
|
||||
#define IGGY_SWF_PLAY_FILE "c:\\projects\\g\\src\\flash\\swf_play.c"
|
||||
static const char *const iggy_swf_play_source_path __attribute__((used)) =
|
||||
IGGY_SWF_PLAY_FILE;
|
||||
#if defined(IGGY_RECONSTRUCT_SWF_PLAY_DURANGO)
|
||||
static const char *const iggy_swf_play_obj_path __attribute__((used)) =
|
||||
"c:\\projects\\g\\build\\release\\temps\\libdu\\iggy_durango"
|
||||
"\\swf_play.obj";
|
||||
#endif
|
||||
|
||||
/* On the host Mach-O dylib (the runtime harness) the un-exercised deep-engine
|
||||
* imports must weak-bind so the dylib loads under flat-namespace dynamic_lookup;
|
||||
* the COFF/ELF cross builds keep them strong so they list in nm for the frozen
|
||||
* import contract. */
|
||||
#if defined(__APPLE__)
|
||||
# define IGGY_WEAK __attribute__((weak))
|
||||
#else
|
||||
# define IGGY_WEAK
|
||||
#endif
|
||||
|
||||
/* iggy_create_movie_for_actionscript_object and iggy_set_button_state are
|
||||
* swf_play exports that the durango runtime harness ALSO provides as recording
|
||||
* stubs; on Apple they are emitted weak so the harness's strong definition wins
|
||||
* (the cross builds keep them strong T exports). */
|
||||
#if defined(__APPLE__)
|
||||
# define IGGY_EXPORT_OVERRIDABLE __attribute__((weak))
|
||||
#else
|
||||
# define IGGY_EXPORT_OVERRIDABLE
|
||||
#endif
|
||||
|
||||
/* ---- libc the retail optimizer emitted (tolerated allowlist). ------------- */
|
||||
extern void *memset(void *dst, int c, size_t n);
|
||||
struct __jmp_buf_tag;
|
||||
extern int setjmp(struct __jmp_buf_tag *env);
|
||||
|
||||
/* ---- Byte-offset access helpers (auto-scaling pointer-width slots). -------- */
|
||||
#define AT(b, off) ((char *)(void *)(b) + (off))
|
||||
#define U8(b, off) (*(uint8_t *)(void *)AT(b, off))
|
||||
#define I8(b, off) (*(int8_t *)(void *)AT(b, off))
|
||||
#define U16(b, off) (*(uint16_t *)(void *)AT(b, off))
|
||||
#define I16(b, off) (*(int16_t *)(void *)AT(b, off))
|
||||
#define U32(b, off) (*(uint32_t *)(void *)AT(b, off))
|
||||
#define I32(b, off) (*(int32_t *)(void *)AT(b, off))
|
||||
#define F32(b, off) (*(float *)(void *)AT(b, off))
|
||||
#define F64(b, off) (*(double *)(void *)AT(b, off))
|
||||
#define PTR(b, off) (*(void **)(void *)AT(b, off))
|
||||
#define IPTR(b, off)(*(intptr_t *)(void *)AT(b, off))
|
||||
#define UPTR(b, off)(*(uintptr_t*)(void *)AT(b, off))
|
||||
|
||||
/* ---- Iggy player / movie struct offsets, width-gated. ----------------------
|
||||
* 64-bit values are durango-authoritative (llvm-objdump resolved the Ghidra
|
||||
* &_pdata_* labels: as3vm ctx @0x28f0, framescript-flag @0x2884, iggyexp @0x2888,
|
||||
* ...). 32-bit values are read DIRECTLY from the vita raw, never halved. */
|
||||
#if IGGY_PTR64
|
||||
/* -- player (Iggy *) fields -- */
|
||||
# define PL_INITIALIZED 0x1f38 /* int nonzero gate. */
|
||||
# define PL_U0010 0x10 /* unknown_0010 block base (last-tick@ +0x20).*/
|
||||
# define PL_PAUSE_FLAG 0x2880 /* byte pause flag (unknown_2870[0x10]). */
|
||||
# define PL_TM_STAMP 0x2870 /* double: frame budget (unknown_2870[0]). */
|
||||
# define PL_AS3VM 0x28f0 /* ptr: AS3 VM context. */
|
||||
# define PL_IGGYEXP 0x2888 /* ptr: iggyexp host callback object. */
|
||||
# define PL_STAGE 0x2660 /* embedded stage DisplayObject base. */
|
||||
# define PL_ROOT 0x24c0 /* embedded root movie base. */
|
||||
# define PL_UNPARENTED 0x24b8 /* ptr: unparented-object list head. */
|
||||
# define PL_FRAMESCRIPT_FLAG 0x2884 /* byte: in-framescript reentrancy flag. */
|
||||
# define PL_SJ_BASE 0x3550 /* setjmp buffer array base. */
|
||||
# define PL_SJ_STRIDE 0x100 /* setjmp buffer stride. */
|
||||
# define PL_SJ_COUNTER 0x3542 /* byte: setjmp nesting counter. */
|
||||
# define PL_RENDER_DT 0x28a0 /* longlong: last tick render delta. */
|
||||
# define PL_VOICE_BASE 0x2d30 /* voice struct array base (stride 0x38). */
|
||||
# define PL_VOICE_ID 0x2d54 /* short: voice id within a voice struct. */
|
||||
# define PL_VOICE_STRIDE 0x38 /* voice struct stride. */
|
||||
# define PL_LIBS_BASE 0x368 /* library base-pointer array (shape class). */
|
||||
# define TM_HOOK_BEGIN 0xa0 /* iggy_tm_normal vtable: scope begin. */
|
||||
# define TM_HOOK_END 0xa8 /* iggy_tm_normal vtable: scope end. */
|
||||
/* -- movie node fields -- */
|
||||
# define MV_LIBMASK 0x264 /* uint: 0x20-bit live-library mask. */
|
||||
# define MV_AS3VALUE 0x20 /* ptr: cached AS3 value slot. */
|
||||
# define MV_REFCOUNT 0x06 /* short: mouse-event visit refcount. */
|
||||
#else
|
||||
/* -- player (Iggy *) fields (vita) -- */
|
||||
# define PL_INITIALIZED 0x19c8
|
||||
# define PL_U0010 0x08
|
||||
# define PL_PAUSE_FLAG 0x21a0
|
||||
# define PL_TM_STAMP 0x2190
|
||||
# define PL_AS3VM 0x2208
|
||||
# define PL_IGGYEXP 0x21a8
|
||||
# define PL_STAGE 0x2024
|
||||
# define PL_ROOT 0x1efc
|
||||
# define PL_UNPARENTED 0x1ef8
|
||||
# define PL_FRAMESCRIPT_FLAG 0x21a4
|
||||
# define PL_SJ_BASE 0x2b18
|
||||
# define PL_SJ_STRIDE 0xc0
|
||||
# define PL_SJ_COUNTER 0x2bce
|
||||
# define PL_RENDER_DT 0x21b8
|
||||
# define PL_VOICE_BASE 0x2460
|
||||
# define PL_VOICE_ID 0x247c
|
||||
# define PL_VOICE_STRIDE 0x28
|
||||
# define PL_LIBS_BASE 0x298
|
||||
# define TM_HOOK_BEGIN 0x50
|
||||
# define TM_HOOK_END 0x54
|
||||
/* -- movie node fields (vita) -- */
|
||||
# define MV_LIBMASK 0x214
|
||||
# define MV_AS3VALUE 0x14
|
||||
# define MV_REFCOUNT 0x06 /* short: shared 0-7 header region (== durango). */
|
||||
#endif
|
||||
|
||||
/* ---- Module-owned data global (external linkage; initialised data 'D'). ----
|
||||
* `float ... = 0.5f` makes the compiler emit the platform-correct endianness:
|
||||
* little-endian 00 00 00 3f on durango/orbis/vita, big-endian 3f 00 00 00 on ps3.
|
||||
* IggySetDoubleClickTime writes (float)ms / 1000.0 (the __real@447a0000 constant).
|
||||
*/
|
||||
float iggy_double_click_time = 0.5f;
|
||||
|
||||
/* Recurring read-only sentinels the retail rodata holds (empty-string / default
|
||||
* name blobs the deep bodies stash into movie fields; the durango Ghidra
|
||||
* &DAT_0000eb29 / &DAT_0000eb21 -- contents inert, used only as stable pointers). */
|
||||
/* The Ghidra &DAT_0000eb29 / &DAT_0000eb21 labels are address-of the imported AS3
|
||||
* VM null/undefined-value storage (llvm-objdump: IMAGE_REL to
|
||||
* as3vm_nullundef_storage). eb21 is the null slot (base), eb29 the undefined slot
|
||||
* (base + one pointer). */
|
||||
extern uint8_t as3vm_nullundef_storage[] IGGY_WEAK;
|
||||
#define IGGY_NULLUNDEF_NULL ((void *)as3vm_nullundef_storage)
|
||||
#define IGGY_NULLUNDEF_UNDEF ((void *)(as3vm_nullundef_storage + sizeof(void *)))
|
||||
|
||||
/* ---- Frozen 72 cross-module imports (INVARIANT contract) + owned-by-swf_decode
|
||||
* iggy_libraries. Declared variadic (with a stable leading arg) where the four
|
||||
* decompiles show the optimizer eliding trailing file/line/tag/callback args at
|
||||
* different call sites, so every recovered call site compiles under -Werror
|
||||
* without inventing a false fixed arity -- matching the swf_decode sibling. */
|
||||
|
||||
/* -- data imports -- */
|
||||
extern void *iggy_libraries[0x20]; /* swf_decode-owned lib table. */
|
||||
extern void *iggy_tm_normal IGGY_WEAK; /* timing-manager vtable object.*/
|
||||
extern int32_t iggy_seek_behavior_version IGGY_WEAK;
|
||||
extern int32_t iggy_force_default_smoothing IGGY_WEAK;
|
||||
|
||||
/* -- AS3 VM surface -- */
|
||||
extern void *as3vm_RunFunction(void *ctx, ...) IGGY_WEAK;
|
||||
extern void as3vm_clean_listeners(void *ctx, ...) IGGY_WEAK;
|
||||
extern void *as3vm_construct_post_GC(void *ctx, ...) IGGY_WEAK;
|
||||
extern void *as3vm_construct_pre_GC(void *ctx, ...) IGGY_WEAK;
|
||||
extern void *as3vm_construct_swf_type_GC(void *ctx, ...) IGGY_WEAK;
|
||||
extern int as3vm_do_direct_event_GC(void *ctx, ...) IGGY_WEAK;
|
||||
extern int as3vm_do_displayobject_event_GC(void *ctx, ...) IGGY_WEAK;
|
||||
extern void as3vm_do_event_timer_GC(void *ctx, ...) IGGY_WEAK;
|
||||
extern int as3vm_do_focus_event_GC(void *ctx, ...) IGGY_WEAK;
|
||||
extern int as3vm_do_keyboard_event_GC(void *ctx, ...) IGGY_WEAK;
|
||||
extern void as3vm_do_mouse_event_GC(void *ctx, ...) IGGY_WEAK;
|
||||
extern void *as3vm_find_intern_string(void *ctx, ...) IGGY_WEAK;
|
||||
extern void *as3vm_get_stage(void *ctx, ...) IGGY_WEAK;
|
||||
extern void as3vm_interpreter_initialize(void *ctx, ...) IGGY_WEAK;
|
||||
extern void *as3vm_pool_alloc(void *ctx, ...) IGGY_WEAK;
|
||||
extern void as3vm_pool_free(void *ctx, ...) IGGY_WEAK;
|
||||
extern void as3vm_set_property_toplevel(void *ctx, ...) IGGY_WEAK;
|
||||
extern void as3vm_setup_DisplayObject(void *ctx, ...) IGGY_WEAK;
|
||||
extern void as3vm_write_barrier_slowpath(void *ctx, ...) IGGY_WEAK;
|
||||
|
||||
/* -- iggy_* movie / audio / seek / textfield / render surface -- */
|
||||
extern void *iggy_arena_malloc(void *arena, ...) IGGY_WEAK;
|
||||
extern int iggy_begin_execution(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_change_sample(int voice, ...) IGGY_WEAK;
|
||||
extern void iggy_clear_movie_dirty(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_deallocate_vbuf_array(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_destroy_textfield_text(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_direct_texture_deref(void *player, ...) IGGY_WEAK;
|
||||
extern int iggy_edittext_char(void *tf, ...) IGGY_WEAK;
|
||||
extern void iggy_edittext_clear(void *tf, ...) IGGY_WEAK;
|
||||
extern int iggy_edittext_copy_utf16(void *tf, ...) IGGY_WEAK;
|
||||
extern int iggy_edittext_copy_utf8(void *tf, ...) IGGY_WEAK;
|
||||
extern void iggy_edittext_cut(void *tf, ...) IGGY_WEAK;
|
||||
extern void iggy_edittext_down(void *tf, ...) IGGY_WEAK;
|
||||
extern void iggy_edittext_drag(void *tf, ...) IGGY_WEAK;
|
||||
extern int iggy_edittext_keydown(void *tf, ...) IGGY_WEAK;
|
||||
extern void iggy_edittext_paste_utf16(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_end_execution(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_free_alloc(void *arena, ...) IGGY_WEAK;
|
||||
extern void iggy_free_voice(int voice, ...) IGGY_WEAK;
|
||||
extern int iggy_free_voice_if_done(int voice, ...) IGGY_WEAK;
|
||||
extern void iggy_gdraw_FreeVertexBuffer(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_get_o2p(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_get_o2w(void *player, ...) IGGY_WEAK;
|
||||
extern int iggy_get_seconds_best_effort(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_goto_frame_GC(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_halt_voice(int voice, ...) IGGY_WEAK;
|
||||
extern void iggy_initialize_main_timeline_3d(void *player, ...) IGGY_WEAK;
|
||||
extern int iggy_inverse_transform(void *out_a, ...) IGGY_WEAK;
|
||||
extern void *iggy_malloc_fileline(void *arena, ...) IGGY_WEAK;
|
||||
extern void iggy_mark_movie_dirty(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_matrix_concatenate(void *out, ...) IGGY_WEAK;
|
||||
extern void iggy_play_adpcm(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_play_mp3(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_play_uncompressed(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_play_voice(int voice, ...) IGGY_WEAK;
|
||||
extern void iggy_seek_frame_GC(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_send_display_tree(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_send_error(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_set_bounds(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_set_textfield_htmltext(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_set_textfield_text(void *player, ...) IGGY_WEAK;
|
||||
extern void iggy_textfield_select_all(void *tf, ...) IGGY_WEAK;
|
||||
extern void iggy_uncaught_exception_warning(void *player, ...) IGGY_WEAK;
|
||||
|
||||
/* -- public-API wrapper (defined in another TU; swf_play references it) -- */
|
||||
extern int32_t IggyPlayerPasteUTF16(void *player, void *text, int32_t len) IGGY_WEAK;
|
||||
|
||||
/* -- RAD runtime helpers -- */
|
||||
extern int64_t rrGetTicks(void) IGGY_WEAK;
|
||||
extern int rrUTF8toUTF16(void *dst, ...) IGGY_WEAK;
|
||||
extern int rrwcscmp(const void *a, const void *b) IGGY_WEAK;
|
||||
extern int rrwcslen(const void *s, ...) IGGY_WEAK;
|
||||
|
||||
/* ---- File-static helpers used across the deep engine bodies (44 total). ----
|
||||
* Signatures are frozen against the real durango DEFINITIONS (full arity); at the
|
||||
* call sites where Ghidra elided trailing register-passed args those args are
|
||||
* recovered in the body, never dropped. Base pointers / contexts / stream
|
||||
* cursors are void*; scalar params keep their int / float type. */
|
||||
static void bind_bare_object(void *player, void *movie);
|
||||
static uint64_t button_under_cursor(void *player, void *matrix, void *node,
|
||||
void *p4, uint32_t p5, uint64_t p6, int p7);
|
||||
static void clean_unreferenced_objects(void *player);
|
||||
static uint64_t consider_curve(float ax, float ay, float cx, float cy, float bx,
|
||||
float by, uint32_t p7, float px, float py,
|
||||
int depth);
|
||||
static unsigned consider_edge(float ax, float ay, float bx, float by, float px,
|
||||
float py);
|
||||
static void *create_buttonrecord_movie_GC(void *player, void *record);
|
||||
static void create_from_null_GC(void *player, void *movie, int p3,
|
||||
uint32_t p4);
|
||||
static void *create_movie_GC(void *player, void *def, void *p3, int p4,
|
||||
void *name);
|
||||
static void create_movie_finish(void *player, void *movie);
|
||||
static uint64_t do_mouse_overing(void *player, unsigned *ev, int p3);
|
||||
static uint64_t do_mouseover(void *player, void *node, void *matrix,
|
||||
uint32_t p4, void *p5, int p6, int p7);
|
||||
static uint64_t do_tick(void *player);
|
||||
static void do_timers(void *player, float dt);
|
||||
static void *find_tree_max_at_most(void *node, int depth);
|
||||
static void *find_tree_min_at_least(void *node, int depth);
|
||||
static void finish_creating_children(void *player, void *node, uint32_t p3,
|
||||
uint32_t p4);
|
||||
static void gswf_add_movie_at_depth_raw(void *player, void *parent,
|
||||
int depth, void *movie);
|
||||
static void gswf_remove_sprite_do_events(void *player, void *movie);
|
||||
static uint64_t hit_test_point_rec(void *player, void *matrix, void *node,
|
||||
void *p4, uint32_t p5);
|
||||
static uint64_t hit_test_shape(void *player, void *shape, void *px, void *py,
|
||||
int p5);
|
||||
static void initialize_button_GC(void *player, void *button, void *def);
|
||||
static uint64_t is_focused_input(void *player);
|
||||
static uint64_t is_hit(void *player, void *node, void *matrix, int p4);
|
||||
static void make_bare_object_constructed(void *player, void *node, void *p3,
|
||||
uint32_t p4);
|
||||
static void make_null_object_bare_GC(void *player, void *movie);
|
||||
static uint64_t movie_is_entirely_unreferenced(void *player, void *movie);
|
||||
static void null_object(void *player, void *movie);
|
||||
static void *placeobject_GC(void *player, void *p2, int p3, void *def,
|
||||
void *p5, void *p6, void *p7, uint32_t p8,
|
||||
uint32_t p9, void *p10, int p11, int p12,
|
||||
uint8_t p13);
|
||||
static void placeobject_shared(void *player, void *movie, void *p3);
|
||||
static void preorder_send_displayobject_event_GC(void *player, void *node,
|
||||
uint8_t p3, uint32_t p4);
|
||||
static uint64_t process_input_event(void *player, int *ev, void **p3);
|
||||
static uint64_t process_key_event(void *player, int p2, unsigned p3, int p4,
|
||||
unsigned *p5);
|
||||
static void process_mouse_event(void *player, char p2, unsigned *p3);
|
||||
static void process_mouse_move(void *player, unsigned x, unsigned y,
|
||||
void *p4, int p5);
|
||||
static void process_mouse_wheel(void *player, uint8_t p2, unsigned *p3);
|
||||
static void recursive_send_displayobject_event_GC(void *player, void *node,
|
||||
uint8_t p3, uint32_t p4);
|
||||
static void seek_focus(void *player, int p2);
|
||||
static void swf_AdvanceFrameNumber(void *player, void *node, int p3);
|
||||
static void swf_DoRemoveEventsForAdvance(void *player, void *node);
|
||||
static void swf_advance_dlist_GC(void *player, void *movie, uint32_t p3,
|
||||
uint32_t p4, uint32_t p5);
|
||||
static void swf_button_update_over(void *player, void *button, void *p3,
|
||||
int p4);
|
||||
static void swf_do_remove_with_events_for_advance_dlist(void *player,
|
||||
void *node);
|
||||
static void swf_update_buttons(void *player, void *node, void *hit, int p4);
|
||||
static void update_time(void *player);
|
||||
|
||||
/* ---- Reconstructed bodies (split into feature .inc units, < 800 lines). --- */
|
||||
#include "swf_play_player.inc"
|
||||
#include "swf_play_movie.inc"
|
||||
#include "swf_play_create.inc"
|
||||
#include "swf_play_advance.inc"
|
||||
#include "swf_play_advance2.inc"
|
||||
#include "swf_play_placeobject.inc"
|
||||
#include "swf_play_framescript.inc"
|
||||
#include "swf_play_sprite.inc"
|
||||
#include "swf_play_textfield.inc"
|
||||
#include "swf_play_hittest.inc"
|
||||
#include "swf_play_hittest2.inc"
|
||||
#include "swf_play_input.inc"
|
||||
#include "swf_play_input2.inc"
|
||||
#include "swf_play_audio.inc"
|
||||
115
iggy-decompiled/src/reconstructed/swf_play.h
Normal file
115
iggy-decompiled/src/reconstructed/swf_play.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* swf_play.h -- reconstructed public ABI for Iggy 1.2.30's movie playback +
|
||||
* display-list execution runtime. Exactly 68 externally visible entry points on
|
||||
* all four platforms (durango / orbis / ps3 / vita): the IggyPlayer* tick / play /
|
||||
* pause / focus / clipboard surface, IggySetDoubleClickTime, the movie advance /
|
||||
* PlaceObject / framescript engine, the sprite / textfield / button / shape
|
||||
* lifecycle, hit-testing, the seek queue and the audio / voice path. The module
|
||||
* OWNS a single externally named data global (iggy_double_click_time, a 4-byte
|
||||
* float defaulting to 0.5).
|
||||
*
|
||||
* Canonical retail source path (embedded for provenance):
|
||||
* c:\projects\g\src\flash\swf_play.c
|
||||
*
|
||||
* C11 and C++17 includable; all entry points are C-linkage. Signatures are
|
||||
* ABI-generic (void* / int / int64) -- the retail decompiles carry provisional
|
||||
* Ghidra types (Iggy*, longlong, undefined8, ...); callers bind by name.
|
||||
*/
|
||||
#ifndef IGGY_RECONSTRUCTED_SWF_PLAY_H
|
||||
#define IGGY_RECONSTRUCTED_SWF_PLAY_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ---- IggyPlayer* public tick / play / focus / clipboard surface. ---------- */
|
||||
int32_t IggyPlayerCopyUTF16(void *f, void *buffer, int32_t bufferlen);
|
||||
int32_t IggyPlayerCopyUTF8(void *f, void *buffer, int32_t bufferlen);
|
||||
uint64_t IggyPlayerCut_core(void *player);
|
||||
int IggyPlayerDispatchEventRS_core(void *player, int *event, void *p3);
|
||||
int32_t IggyPlayerGetFocusableObjects(void *f, void *current_focus, void *objs,
|
||||
int32_t max_obj, int32_t *num_obj);
|
||||
int32_t IggyPlayerHasFocusedEditableTextfield(void *f);
|
||||
uint64_t IggyPlayerPasteUTF16_core(void *player, void *text, uint32_t len);
|
||||
int32_t IggyPlayerPasteUTF8_core(void *player, void *text, uint32_t len);
|
||||
void IggyPlayerPause(void *player, int32_t pause_audio);
|
||||
void IggyPlayerPlay(void *player);
|
||||
int32_t IggyPlayerReadyToTick(void *player);
|
||||
void IggyPlayerSendFrameToExplorer(void *f);
|
||||
void IggyPlayerSetFocus_core(void *player, void *obj, uint32_t p3);
|
||||
void IggyPlayerTickRS_core(void *player);
|
||||
void IggySetDoubleClickTime(int32_t time_in_ms);
|
||||
|
||||
/* ---- AS3 value bridge. ---------------------------------------------------- */
|
||||
uint64_t as3vm_get_movie_as3value_GC(void *player, void *movie);
|
||||
|
||||
/* ---- Movie advance / PlaceObject / framescript engine. -------------------- */
|
||||
void iggy_add_movie_framescript(void *player, int frame, void *script);
|
||||
void iggy_add_to_unparented(void *player, void *movie);
|
||||
void iggy_advance_movie_GC(void);
|
||||
uint64_t iggy_advance_movie_raw_GC(void *player, void *movie, int p3, void *p4);
|
||||
void iggy_audio_update(void *player);
|
||||
void iggy_check_display_trees(void);
|
||||
void iggy_create_empty_bitmap(void *player, void *tag);
|
||||
int64_t iggy_create_movie_complete_GC(void *player, void *p2, void *p3,
|
||||
uint32_t p4);
|
||||
void *iggy_create_movie_for_actionscript_object(void *player, void *object);
|
||||
void *iggy_create_textfield(void *player);
|
||||
void iggy_destroy_sprite(void *player, void *movie);
|
||||
void iggy_destroy_sprite_attachments(void *player, void *movie, int p3);
|
||||
void iggy_destroy_sprite_during_shutdown(void *player, void *movie);
|
||||
void iggy_discard_seek_queue(void *player);
|
||||
void iggy_do_placement(void *player, void *movie, void *p3);
|
||||
void iggy_do_placeobject_GC(void *player, void *p2, void *p3, int p4,
|
||||
uint32_t p5, uint32_t p6, uint32_t p7,
|
||||
uint32_t p8);
|
||||
void iggy_do_playsound(void *player, void *p2, void *p3);
|
||||
void iggy_dynamic_graphics_clear_cache(void *player, void *movie);
|
||||
void iggy_finish_creating_movie_GC(void *player, void *movie, uint32_t p3,
|
||||
void *p4, uint32_t p5);
|
||||
uint64_t iggy_flush_seek_queue_GC(void *player);
|
||||
void iggy_free_as3_filters(void *player, void *movie);
|
||||
void iggy_free_graphics(void *player, void *movie);
|
||||
void iggy_free_textfield(void *player, void *movie);
|
||||
uint64_t iggy_get_symbol(void *movie, void *name);
|
||||
void iggy_hit_test_point(void *player, void *pt, void *p3, void *p4,
|
||||
uint32_t p5);
|
||||
void iggy_init_textfield(void *player, void *movie, void *p3, int p4);
|
||||
void iggy_initialized_main_movie_GC(void *player);
|
||||
uint64_t iggy_insert_movie_at_GC(void *player, void *parent, int depth,
|
||||
void *movie);
|
||||
void iggy_insert_movie_messages_GC(void *player, void *movie, int p3);
|
||||
uint64_t iggy_is_weak_ptr(void *player, void *ptr);
|
||||
int64_t iggy_make_empty_button(void *player);
|
||||
void iggy_make_empty_shape(void *player);
|
||||
void iggy_make_empty_sprite(void *player);
|
||||
int64_t iggy_make_empty_textfield(void *player);
|
||||
void iggy_play_framescript(void *player, void *movie);
|
||||
void iggy_play_framescripts(void *player, void *movie);
|
||||
void iggy_play_framescripts_complete(void *player);
|
||||
int iggy_play_sound(void *player, void *p2, float *p3, void *p4, void *p5,
|
||||
void *p6, float p7, float *p8, void *p9);
|
||||
void iggy_poll_iggyexp(void *player);
|
||||
void iggy_remove_from_unparented(void *player, void *movie);
|
||||
void iggy_remove_sprite(void *player, void *movie, int p3, void *p4, int p5,
|
||||
int p6);
|
||||
void iggy_set_button_state(void *player, void *button, uint8_t p3, int p4);
|
||||
void iggy_set_focus_typed(void *player, char kind, void *obj, uint32_t p4);
|
||||
void iggy_set_mouseover_list(void *player);
|
||||
void iggy_set_movie_defaults(void *movie);
|
||||
void iggy_set_movie_parent(void *player, void *movie, void *parent);
|
||||
int iggy_shape_has_class(void *player, void *movie);
|
||||
uint64_t iggy_shape_hit_test(void *player, void *matrix, void *shape, void *p4,
|
||||
void *p5, uint32_t p6);
|
||||
void iggy_update_button(void *player, void *button);
|
||||
void iggy_update_voice(void *player, int voice);
|
||||
void iggy_verify_container(void);
|
||||
void iggy_zero_movie_state(void *movie);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* IGGY_RECONSTRUCTED_SWF_PLAY_H */
|
||||
599
iggy-decompiled/src/reconstructed/swf_play_advance.inc
Normal file
599
iggy-decompiled/src/reconstructed/swf_play_advance.inc
Normal file
@@ -0,0 +1,599 @@
|
||||
/*
|
||||
* swf_play_advance.inc -- movie-advance / tick engine: do_tick, do_timers,
|
||||
* iggy_advance_movie_GC/_raw_GC, swf_advance_dlist_GC, swf_AdvanceFrameNumber,
|
||||
* swf_DoRemoveEventsForAdvance, swf_do_remove_with_events_for_advance_dlist,
|
||||
* gswf_add_movie_at_depth_raw, gswf_remove_sprite_do_events, find_tree_max_
|
||||
* at_most/find_tree_min_at_least, clean_unreferenced_objects.
|
||||
*
|
||||
* durango raw/durango/swf_play.c line ranges (authoritative for control flow):
|
||||
* iggy_advance_movie_GC 2179-2189 | iggy_advance_movie_raw_GC 2190-2265 |
|
||||
* swf_advance_dlist_GC 6031-6098 | swf_AdvanceFrameNumber 5945-5995 |
|
||||
* swf_DoRemoveEventsForAdvance 5996-6030 |
|
||||
* swf_do_remove_with_events_for_advance_dlist 6181-6276 |
|
||||
* gswf_add_movie_at_depth_raw 1863-1917 |
|
||||
* gswf_remove_sprite_do_events 1918-1952 |
|
||||
* find_tree_max_at_most 1777-1805 | find_tree_min_at_least 1806-1833 |
|
||||
* do_tick 1565-1715 | do_timers 1719-1773 |
|
||||
* clean_unreferenced_objects 657-686
|
||||
*
|
||||
* do_timers, clean_unreferenced_objects, gswf_add_movie_at_depth_raw,
|
||||
* gswf_remove_sprite_do_events and swf_do_remove_with_events_for_advance_dlist
|
||||
* are all fully inlined into their sole call site on vita, so their fields
|
||||
* are cross-checked against the vita bodies of do_tick (5523-5814),
|
||||
* iggy_advance_movie_raw_GC (3394-3471), iggy_do_placement (1675-...) and
|
||||
* iggy_insert_movie_at_GC (1519-...), which touch the same child-list fields.
|
||||
* See the completion report's RESIDUALS for the two items that could not be
|
||||
* pinned down with full confidence (the dlist-remove-record case-2 child
|
||||
* pointer, and the elided finish_creating_children p4 argument).
|
||||
*
|
||||
* RESIDUAL / correction: the frozen PL_ROOT macro states vita=0x1f00, but
|
||||
* do_tick's own vita body (5718: "iggy_seek_frame_GC(param_1,param_1 +
|
||||
* 0x1efc,0,1)") and iggy_advance_movie_raw_GC's vita body (5452: "iVar4 !=
|
||||
* param_1 + 0x1efc") both show 0x1efc -- independently confirmed by
|
||||
* swf_play_sprite.inc's SPR_PL_ROOT (also 0x1efc, "objdump+2x-raw confirmed").
|
||||
* Per the contract's own "VERIFY vita via objdump if used" caveat on PL_ROOT,
|
||||
* this file does not redefine the frozen macro; it uses a local corrected
|
||||
* alias PL_ROOT_V (durango == frozen PL_ROOT 0x24c0; vita == 0x1efc).
|
||||
*/
|
||||
|
||||
/* ---- New movie-node field offsets this file needs (width-gated; not already
|
||||
* defined by swf_play_movie.inc). Vita values cross-checked as cited. ------ */
|
||||
#if IGGY_PTR64
|
||||
#undef MV_BF
|
||||
# define MV_BF 0xbf /* byte: per-tick advance/seek-lock state. */
|
||||
#undef MV_FIRSTCHILD
|
||||
# define MV_FIRSTCHILD 0x10 /* ptr: first-child list head. */
|
||||
#undef MV_LASTCHILD
|
||||
# define MV_LASTCHILD 0x90/* ptr: last-child list tail. */
|
||||
#undef MV_LIBARRAY
|
||||
# define MV_LIBARRAY 0x48/* ptr: depth-indexed child pointer array. */
|
||||
#undef MV_LIBCOUNT
|
||||
# define MV_LIBCOUNT 0x15c/*int: capacity of MV_LIBARRAY. */
|
||||
#undef MV_DLIST
|
||||
# define MV_DLIST 0x168/*ptr: pending display-list change record. */
|
||||
#undef MV_FRAMECOUNT
|
||||
# define MV_FRAMECOUNT 0x174/*int: current frame index. */
|
||||
#undef MV_FRAMECOUNT_COPY
|
||||
# define MV_FRAMECOUNT_COPY 0x170/*int: frame-index snapshot. */
|
||||
#undef MV_TAGDATA
|
||||
# define MV_TAGDATA 0xa8 /* ptr: compiled/static tag stream. */
|
||||
#undef MV_DEPTH
|
||||
# define MV_DEPTH 0xc4 /* int: this node's own depth index. */
|
||||
#else
|
||||
#undef MV_BF
|
||||
# define MV_BF 0x67
|
||||
#undef MV_FIRSTCHILD
|
||||
# define MV_FIRSTCHILD 0x0c
|
||||
#undef MV_LASTCHILD
|
||||
# define MV_LASTCHILD 0x4c
|
||||
#undef MV_LIBARRAY
|
||||
# define MV_LIBARRAY 0x28
|
||||
#undef MV_LIBCOUNT
|
||||
# define MV_LIBCOUNT 0xf4
|
||||
#undef MV_DLIST
|
||||
# define MV_DLIST 0xfc
|
||||
#undef MV_FRAMECOUNT
|
||||
# define MV_FRAMECOUNT 0x104
|
||||
#undef MV_FRAMECOUNT_COPY
|
||||
# define MV_FRAMECOUNT_COPY 0x100
|
||||
#undef MV_TAGDATA
|
||||
# define MV_TAGDATA 0x58
|
||||
#undef MV_DEPTH
|
||||
# define MV_DEPTH 0x6c
|
||||
#endif
|
||||
#undef MV_LOCKCOUNT
|
||||
#define MV_LOCKCOUNT 6 /* short refcount @ +6; identical on both widths
|
||||
* (gswf_remove_sprite_do_events, both raws). */
|
||||
|
||||
/* ---- Corrected root-movie base (see header note above). ------------------- */
|
||||
#if IGGY_PTR64
|
||||
#undef PL_ROOT_V
|
||||
# define PL_ROOT_V PL_ROOT
|
||||
#else
|
||||
#undef PL_ROOT_V
|
||||
# define PL_ROOT_V 0x1efc
|
||||
#endif
|
||||
|
||||
/* ---- Additional player-relative fields do_tick touches. ------------------- */
|
||||
#if IGGY_PTR64
|
||||
#undef PL_TIME_UPDATED
|
||||
# define PL_TIME_UPDATED 0x285c /* int: "seconds already sampled" flag. */
|
||||
#undef PL_LAST_SECONDS
|
||||
# define PL_LAST_SECONDS 0x2868 /* double: last iggy_get_seconds sample. */
|
||||
#undef PL_MOUSE_X
|
||||
# define PL_MOUSE_X 0x2980 /* int: last mousedown/mousemove x. */
|
||||
#undef PL_MOUSE_Y
|
||||
# define PL_MOUSE_Y 0x2984 /* int: last mousedown/mousemove y. */
|
||||
#undef PL_TICK_BYTE_COUNTER
|
||||
# define PL_TICK_BYTE_COUNTER 0x2977/* byte: per-tick counter. */
|
||||
#undef PL_ROOT_TICKFLAG
|
||||
# define PL_ROOT_TICKFLAG 0x257f/* byte: root's own MV_BF-ish tick flag, */
|
||||
/* == PL_ROOT + 0xbf (root movie header).*/
|
||||
#undef PL_SEEKPENDING_PTR
|
||||
# define PL_SEEKPENDING_PTR 0x2628/* ptr: nonzero while a seek is pending. */
|
||||
#undef PL_SEEKPENDING_FLAG
|
||||
# define PL_SEEKPENDING_FLAG 0x92/* byte: "ready to auto-advance" flag. */
|
||||
#undef PL_ROOT_FORCE_FLAG
|
||||
# define PL_ROOT_FORCE_FLAG 0x2f24/* int: force-reseek-root override flag. */
|
||||
#else
|
||||
#undef PL_TIME_UPDATED
|
||||
# define PL_TIME_UPDATED 0x217c
|
||||
#undef PL_LAST_SECONDS
|
||||
# define PL_LAST_SECONDS 0x2188
|
||||
#undef PL_MOUSE_X
|
||||
# define PL_MOUSE_X 0x2268
|
||||
#undef PL_MOUSE_Y
|
||||
# define PL_MOUSE_Y 0x226c
|
||||
#undef PL_TICK_BYTE_COUNTER
|
||||
# define PL_TICK_BYTE_COUNTER 0x225f
|
||||
#undef PL_ROOT_TICKFLAG
|
||||
# define PL_ROOT_TICKFLAG 0x1f63
|
||||
#undef PL_SEEKPENDING_PTR
|
||||
# define PL_SEEKPENDING_PTR 0x1ff8
|
||||
#undef PL_SEEKPENDING_FLAG
|
||||
# define PL_SEEKPENDING_FLAG 0x72
|
||||
#undef PL_ROOT_FORCE_FLAG
|
||||
# define PL_ROOT_FORCE_FLAG 0x25d4
|
||||
#endif
|
||||
|
||||
/* Derived from the already-frozen PL_U0010 macro; both sub-offsets verified
|
||||
* to line up exactly on both widths (durango 0x10/0x08 + 0x10/0x18/0x20). */
|
||||
#undef PL_TICK_COUNTER
|
||||
#define PL_TICK_COUNTER (PL_U0010 + 0x10)
|
||||
#undef PL_DT_TOTAL
|
||||
#define PL_DT_TOTAL (PL_U0010 + 0x18)
|
||||
#undef PL_DT_THISFRAME
|
||||
#define PL_DT_THISFRAME (PL_U0010 + 0x20) /* == contract's "last-tick double".*/
|
||||
|
||||
/* ---- AS3-VM-context-relative sub-fields (ctx is its own allocation; its
|
||||
* layout is independently width-gated from the player struct). ------------- */
|
||||
#if IGGY_PTR64
|
||||
#undef CTX_TICK_CLEAR
|
||||
# define CTX_TICK_CLEAR 0x2908 /* cleared unconditionally at tick start. */
|
||||
#undef CTX_TIMER_HEAD
|
||||
# define CTX_TIMER_HEAD 0x88 /* ptr: head of the pending-timer list. */
|
||||
#undef CTX_TIMERSTACK
|
||||
# define CTX_TIMERSTACK 0x6b18 /* void**: reentrant "current timer" stack. */
|
||||
#undef CTX_RENDER_FLAG
|
||||
# define CTX_RENDER_FLAG 0xd34 /* int: "render event pending" flag. */
|
||||
#else
|
||||
#undef CTX_TICK_CLEAR
|
||||
# define CTX_TICK_CLEAR 0x16e8
|
||||
#undef CTX_TIMER_HEAD
|
||||
# define CTX_TIMER_HEAD 0x4c
|
||||
#undef CTX_TIMERSTACK
|
||||
# define CTX_TIMERSTACK 0x4834
|
||||
#undef CTX_RENDER_FLAG
|
||||
# define CTX_RENDER_FLAG 0x8bc /* NOTE: corrects the contract's unqualified
|
||||
* "+0xd34" -- do_tick's own vita body shows
|
||||
* ctx+0x8bc, so this field is NOT identical
|
||||
* across widths as the task text implied. */
|
||||
#endif
|
||||
|
||||
/* ---- Timer-record fields (the object chained off CTX_TIMER_HEAD). -------- */
|
||||
#if IGGY_PTR64
|
||||
#undef TMR_INTERVAL
|
||||
# define TMR_INTERVAL 0x37 /* double */
|
||||
#undef TMR_ELAPSED
|
||||
# define TMR_ELAPSED 0x3f /* double */
|
||||
#undef TMR_REPCOUNT
|
||||
# define TMR_REPCOUNT 0x47 /* int */
|
||||
#undef TMR_REPLIMIT
|
||||
# define TMR_REPLIMIT 0x4b /* int */
|
||||
#undef TMR_ACTIVE
|
||||
# define TMR_ACTIVE 0x4f /* int */
|
||||
#undef TMR_NEXT
|
||||
# define TMR_NEXT 0x57 /* ptr */
|
||||
#else
|
||||
#undef TMR_INTERVAL
|
||||
# define TMR_INTERVAL 0x1f
|
||||
#undef TMR_ELAPSED
|
||||
# define TMR_ELAPSED 0x27
|
||||
#undef TMR_REPCOUNT
|
||||
# define TMR_REPCOUNT 0x2f
|
||||
#undef TMR_REPLIMIT
|
||||
# define TMR_REPLIMIT 0x33
|
||||
#undef TMR_ACTIVE
|
||||
# define TMR_ACTIVE 0x37
|
||||
#undef TMR_NEXT
|
||||
# define TMR_NEXT 0x3b
|
||||
#endif
|
||||
|
||||
/* ---- dlist change-record fields (durango raw:6033-6098 / vita raw:2345-
|
||||
* 2400). DLREC_PO_CHILDPTR (the case-2 "already has a child" pointer used
|
||||
* only by swf_do_remove_with_events_for_advance_dlist) is NOT exercised by
|
||||
* swf_advance_dlist_GC, so its vita offset could not be cross-checked the
|
||||
* same way as the others -- see RESIDUALS in the completion report. */
|
||||
#if IGGY_PTR64
|
||||
#undef DLREC_TAG
|
||||
# define DLREC_TAG 8 /* byte: record tag (1 stop/2 place/3 remove/4
|
||||
* depth/6 sound). */
|
||||
#undef DLREC_PO_ID
|
||||
# define DLREC_PO_ID 40 /* short: case-2 library index. */
|
||||
#undef DLREC_PO_CHILDPTR
|
||||
# define DLREC_PO_CHILDPTR 48/* ptr: case-2 "already has a live child" test.*/
|
||||
#undef DLREC_RM_ID
|
||||
# define DLREC_RM_ID 10/* ushort: case-3/case-remove library index. */
|
||||
#undef DLREC_DEPTH_ID
|
||||
# define DLREC_DEPTH_ID 12/* ushort: case-4 library index. */
|
||||
#undef DLREC_DEPTH_VAL
|
||||
# define DLREC_DEPTH_VAL 14/* ushort: case-4 new depth value. */
|
||||
#else
|
||||
#undef DLREC_TAG
|
||||
# define DLREC_TAG 4
|
||||
#undef DLREC_PO_ID
|
||||
# define DLREC_PO_ID 36
|
||||
#undef DLREC_PO_CHILDPTR
|
||||
# define DLREC_PO_CHILDPTR 40 /* RESIDUAL: proportional estimate, unverified.*/
|
||||
#undef DLREC_RM_ID
|
||||
# define DLREC_RM_ID 6
|
||||
#undef DLREC_DEPTH_ID
|
||||
# define DLREC_DEPTH_ID 8
|
||||
#undef DLREC_DEPTH_VAL
|
||||
# define DLREC_DEPTH_VAL 10
|
||||
#endif
|
||||
|
||||
/* raw:657-686 (durango) / inlined into do_tick's tail on vita (5790-5808),
|
||||
* confirming PL_UNPARENTED (already frozen) as the traversal head. */
|
||||
static void clean_unreferenced_objects(void *player) {
|
||||
void *node = PTR(player, PL_UNPARENTED);
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0xb65, 0, 0);
|
||||
}
|
||||
while (node != NULL) {
|
||||
void *next = PTR(node, MV_NEXT);
|
||||
if (movie_is_entirely_unreferenced(player, node) != 0) {
|
||||
iggy_destroy_sprite(player, node);
|
||||
}
|
||||
node = next;
|
||||
}
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0xb76);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:1806-1833 (durango) / raw/vita:6181-6202 (exact match, every field
|
||||
* reused from the already-frozen movie.inc macros: MV_BA, MVD_114, MV_TYPE,
|
||||
* MV_FIRSTCHILD, MV_B9, MV_NEXT). */
|
||||
static void *find_tree_min_at_least(void *node, int depth) {
|
||||
void *result = NULL;
|
||||
if ((U8(node, MV_BA) & 0x80) != 0 && depth <= I32(node, MVD_114)) {
|
||||
result = node;
|
||||
}
|
||||
if (U8(node, MV_TYPE) == 7) {
|
||||
return result;
|
||||
}
|
||||
{
|
||||
void *child;
|
||||
for (child = PTR(node, MV_FIRSTCHILD); child != NULL; child = PTR(child, MV_NEXT)) {
|
||||
if ((U8(child, MV_B9) & 0x40) != 0) {
|
||||
void *cand = find_tree_min_at_least(child, depth);
|
||||
if (cand != NULL && (result == NULL || I32(cand, MVD_114) < I32(result, MVD_114))) {
|
||||
result = cand;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* raw:1777-1805 (durango) / raw/vita:6206-6230 (exact match). */
|
||||
static void *find_tree_max_at_most(void *node, int depth) {
|
||||
void *result = NULL;
|
||||
if ((U8(node, MV_BA) & 0x80) != 0 && I32(node, MVD_114) >= 0 &&
|
||||
I32(node, MVD_114) <= depth) {
|
||||
result = node;
|
||||
}
|
||||
if (U8(node, MV_TYPE) != 7) {
|
||||
void *child;
|
||||
for (child = PTR(node, MV_FIRSTCHILD); child != NULL; child = PTR(child, MV_NEXT)) {
|
||||
if ((U8(child, MV_B9) & 0x40) != 0) {
|
||||
void *cand = find_tree_max_at_most(child, depth);
|
||||
if (cand != NULL && (result == NULL || I32(result, MVD_114) < I32(cand, MVD_114))) {
|
||||
result = cand;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* raw:1719-1773 (durango); fully inlined into do_tick on vita (5616-5667) --
|
||||
* every field below is cross-checked against that inlined body. The stack
|
||||
* push/pop at CTX_TIMERSTACK is done through real void** pointer arithmetic
|
||||
* so the +8 (durango) / +4 (vita) stride falls out of sizeof(void*)
|
||||
* automatically rather than needing a second width-gated constant. */
|
||||
static void do_timers(void *player, float dt) {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
void *timer;
|
||||
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0xb7d, 0, 0);
|
||||
}
|
||||
|
||||
for (timer = PTR(ctx, CTX_TIMER_HEAD); timer != NULL; timer = PTR(timer, TMR_NEXT)) {
|
||||
if (I32(timer, TMR_ACTIVE) != 0) {
|
||||
double elapsed = F64(timer, TMR_ELAPSED) + (double)((float)dt * 1000.0f);
|
||||
F64(timer, TMR_ELAPSED) = elapsed;
|
||||
if (F64(timer, TMR_INTERVAL) <= elapsed) {
|
||||
void ***stackptr;
|
||||
|
||||
I32(timer, TMR_REPCOUNT) = I32(timer, TMR_REPCOUNT) + 1;
|
||||
F64(timer, TMR_ELAPSED) = elapsed - F64(timer, TMR_INTERVAL);
|
||||
as3vm_interpreter_initialize(ctx);
|
||||
|
||||
stackptr = (void ***)AT(ctx, CTX_TIMERSTACK);
|
||||
**stackptr = timer;
|
||||
*stackptr = *stackptr + 1;
|
||||
|
||||
as3vm_do_event_timer_GC(ctx, timer, 0);
|
||||
|
||||
if (I32(timer, TMR_REPLIMIT) != 0 &&
|
||||
I32(timer, TMR_REPLIMIT) <= I32(timer, TMR_REPCOUNT)) {
|
||||
I32(timer, TMR_ACTIVE) = 0;
|
||||
F64(timer, TMR_ELAPSED) = 0;
|
||||
stackptr = (void ***)AT(ctx, CTX_TIMERSTACK);
|
||||
as3vm_do_event_timer_GC(ctx, *(*stackptr - 1), 1);
|
||||
}
|
||||
|
||||
iggy_flush_seek_queue_GC(player);
|
||||
|
||||
/* Reload the "current timer" from the (now popped) reentrancy stack,
|
||||
* exactly as durango's do_timers does -- the for-loop's own
|
||||
* increment (TMR_NEXT) then runs against whatever this reload
|
||||
* produced, faithfully reproducing the retail control flow. */
|
||||
stackptr = (void ***)AT(ctx, CTX_TIMERSTACK);
|
||||
*stackptr = *stackptr - 1;
|
||||
timer = **stackptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0xb9c);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:1565-1715 (durango) / raw/vita:5523-5814. The vita body additionally
|
||||
* shows the iggy_audio_update / iggy_flush_seek_queue_GC bodies inlined at
|
||||
* their call sites (both are exports owned by sibling .inc files here), and
|
||||
* confirms every offset cited in the macro block above. */
|
||||
uint64_t do_tick(void *player) {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
int seek_reset = 0;
|
||||
int p3;
|
||||
void *p4;
|
||||
float this_dt;
|
||||
|
||||
if (ctx != NULL) {
|
||||
#if IGGY_PTR64
|
||||
*(uint64_t *)AT(ctx, CTX_TICK_CLEAR) = 0;
|
||||
#else
|
||||
*(uint32_t *)AT(ctx, CTX_TICK_CLEAR) = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
iggy_audio_update(player);
|
||||
|
||||
if (I32(player, PL_TIME_UPDATED) == 0) {
|
||||
double now = (double)iggy_get_seconds_best_effort(player);
|
||||
double prev = F64(player, PL_LAST_SECONDS);
|
||||
double delta;
|
||||
F64(player, PL_LAST_SECONDS) = now;
|
||||
delta = now - prev;
|
||||
F64(player, PL_DT_TOTAL) = F64(player, PL_DT_TOTAL) + delta;
|
||||
F64(player, PL_DT_THISFRAME) = F64(player, PL_DT_THISFRAME) + delta;
|
||||
}
|
||||
I32(player, PL_TIME_UPDATED) = 0;
|
||||
|
||||
{
|
||||
uint32_t mm_scratch[4];
|
||||
mm_scratch[0] = 0; mm_scratch[1] = 0; mm_scratch[2] = 0; mm_scratch[3] = 0;
|
||||
process_mouse_move(player, (unsigned)I32(player, PL_MOUSE_X),
|
||||
(unsigned)I32(player, PL_MOUSE_Y), mm_scratch, 0);
|
||||
}
|
||||
|
||||
{
|
||||
double total = F64(player, PL_DT_THISFRAME);
|
||||
double budget = F64(player, PL_TM_STAMP);
|
||||
if (total <= budget) {
|
||||
this_dt = (float)total;
|
||||
F64(player, PL_DT_THISFRAME) = 0;
|
||||
} else {
|
||||
this_dt = (float)budget;
|
||||
F64(player, PL_DT_THISFRAME) = total - budget;
|
||||
}
|
||||
}
|
||||
|
||||
I32(player, PL_TICK_COUNTER) = I32(player, PL_TICK_COUNTER) + 1;
|
||||
|
||||
if (ctx != NULL && PTR(ctx, CTX_TIMER_HEAD) != NULL) {
|
||||
do_timers(player, this_dt);
|
||||
}
|
||||
|
||||
U8(player, PL_TICK_BYTE_COUNTER) = U8(player, PL_TICK_BYTE_COUNTER) + 1;
|
||||
|
||||
if (ctx != NULL) {
|
||||
as3vm_interpreter_initialize(ctx);
|
||||
}
|
||||
|
||||
if (iggy_seek_behavior_version == 1) {
|
||||
seek_reset = (U8(player, PL_ROOT_TICKFLAG) == 2);
|
||||
U8(player, PL_ROOT_TICKFLAG) = 0;
|
||||
}
|
||||
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0xbda, 0, 0);
|
||||
}
|
||||
|
||||
if (seek_reset) {
|
||||
p3 = 0;
|
||||
p4 = (void *)(intptr_t)1;
|
||||
} else {
|
||||
if (PTR(player, PL_SEEKPENDING_PTR) == NULL &&
|
||||
U8(player, PL_SEEKPENDING_FLAG) != 0) {
|
||||
if (ctx != NULL) {
|
||||
as3vm_do_direct_event_GC(ctx, 3);
|
||||
}
|
||||
iggy_flush_seek_queue_GC(player);
|
||||
iggy_seek_frame_GC(player, AT(player, PL_ROOT_V), 0, 1);
|
||||
goto tick_done;
|
||||
}
|
||||
if (ctx != NULL) {
|
||||
swf_DoRemoveEventsForAdvance(player, AT(player, PL_STAGE));
|
||||
}
|
||||
swf_AdvanceFrameNumber(player, AT(player, PL_STAGE), 1);
|
||||
p3 = 1;
|
||||
p4 = (void *)(intptr_t)0;
|
||||
}
|
||||
|
||||
iggy_advance_movie_raw_GC(player, AT(player, PL_STAGE), p3, p4);
|
||||
|
||||
if (ctx != NULL) {
|
||||
as3vm_do_direct_event_GC(ctx, 3);
|
||||
iggy_flush_seek_queue_GC(player);
|
||||
}
|
||||
|
||||
if (!seek_reset) {
|
||||
void *root = AT(player, PL_ROOT_V);
|
||||
/* p4 (finish_creating_children's own 4th arg) is elided at both durango
|
||||
* call sites that use this exact idiom (raw:1674 and raw:3480); the one
|
||||
* fully-explicit sibling call (raw:2374) shows 0,0 for p3/p4, so 0 is
|
||||
* used here too -- see RESIDUALS. */
|
||||
finish_creating_children(player, root, 1, 0);
|
||||
if ((U8(root, MV_FLAG1) & 1) != 0) {
|
||||
make_bare_object_constructed(player, root, (void *)0, 0);
|
||||
create_movie_finish(player, root);
|
||||
if ((U8(root, MV_B9) & 0x20) != 0) {
|
||||
iggy_insert_movie_messages_GC(player, root, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iggy_play_framescripts_complete(player);
|
||||
|
||||
tick_done:
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0xc0f);
|
||||
}
|
||||
|
||||
if (ctx != NULL) {
|
||||
as3vm_clean_listeners(ctx);
|
||||
}
|
||||
|
||||
if (ctx != NULL && I32(ctx, CTX_RENDER_FLAG) != 0) {
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0xc16, 0, 0);
|
||||
}
|
||||
as3vm_interpreter_initialize(ctx);
|
||||
as3vm_do_direct_event_GC(ctx, 4);
|
||||
I32(ctx, CTX_RENDER_FLAG) = 0;
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0xc1a);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx != NULL) {
|
||||
as3vm_clean_listeners(ctx);
|
||||
}
|
||||
|
||||
clean_unreferenced_objects(player);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:1863-1917 (durango). Not present standalone on vita (its sole caller,
|
||||
* iggy_do_placement, is elsewhere); every field is cross-checked instead
|
||||
* against iggy_do_placement's own vita body (MV_LIBARRAY, MV_DEPTH) and the
|
||||
* structurally-identical positional-insert list splice inside vita's
|
||||
* iggy_insert_movie_at_GC (MV_FIRSTCHILD/MV_LASTCHILD/MV_NEXT/MV_PREV -- same
|
||||
* doubly-linked-list fields, different insertion policy). */
|
||||
static void gswf_add_movie_at_depth_raw(void *player, void *parent, int depth, void *movie) {
|
||||
int count, idx;
|
||||
void *sibling;
|
||||
int fc_was_target;
|
||||
(void)player;
|
||||
|
||||
((void **)PTR(parent, MV_LIBARRAY))[depth] = movie;
|
||||
|
||||
if (PTR(parent, MV_FIRSTCHILD) == NULL) {
|
||||
PTR(parent, MV_LASTCHILD) = movie;
|
||||
PTR(parent, MV_FIRSTCHILD) = movie;
|
||||
PTR(movie, MV_NEXT) = NULL;
|
||||
PTR(movie, MV_PREV) = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
count = I32(parent, MV_LIBCOUNT);
|
||||
idx = depth + 1;
|
||||
if (idx < count) {
|
||||
while (((void **)PTR(parent, MV_LIBARRAY))[idx] == NULL) {
|
||||
idx = idx + 1;
|
||||
if (!(idx < count)) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (idx == count) {
|
||||
PTR(movie, MV_NEXT) = NULL;
|
||||
PTR(movie, MV_PREV) = PTR(parent, MV_LASTCHILD);
|
||||
PTR(parent, MV_LASTCHILD) = movie;
|
||||
if (PTR(movie, MV_PREV) != NULL) {
|
||||
PTR(PTR(movie, MV_PREV), MV_NEXT) = movie;
|
||||
}
|
||||
fc_was_target = (PTR(parent, MV_FIRSTCHILD) == NULL);
|
||||
} else {
|
||||
sibling = ((void **)PTR(parent, MV_LIBARRAY))[idx];
|
||||
PTR(movie, MV_NEXT) = sibling;
|
||||
PTR(movie, MV_PREV) = PTR(sibling, MV_PREV);
|
||||
PTR(sibling, MV_PREV) = movie;
|
||||
if (PTR(movie, MV_PREV) != NULL) {
|
||||
PTR(PTR(movie, MV_PREV), MV_NEXT) = movie;
|
||||
}
|
||||
fc_was_target = (PTR(parent, MV_FIRSTCHILD) == sibling);
|
||||
}
|
||||
if (fc_was_target) {
|
||||
PTR(parent, MV_FIRSTCHILD) = movie;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:1918-1952 (durango). Fully inlined into iggy_remove_sprite on vita
|
||||
* (566-587) -- every field matches exactly (MV_PARENT, MV_FLAG1, PL_STAGE,
|
||||
* the literal +6 short refcount). */
|
||||
static void gswf_remove_sprite_do_events(void *player, void *movie) {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
if (ctx != NULL) {
|
||||
void *walk, *next;
|
||||
|
||||
U16(movie, MV_LOCKCOUNT) = U16(movie, MV_LOCKCOUNT) + 1;
|
||||
walk = PTR(movie, MV_PARENT);
|
||||
as3vm_do_displayobject_event_GC(ctx, movie, 0x14, 1);
|
||||
U16(movie, MV_LOCKCOUNT) = U16(movie, MV_LOCKCOUNT) - 1;
|
||||
|
||||
next = PTR(walk, MV_PARENT);
|
||||
while (next != NULL && (U8(walk, MV_FLAG1) & 8) == 0) {
|
||||
walk = next;
|
||||
next = PTR(walk, MV_PARENT);
|
||||
}
|
||||
|
||||
if (walk == AT(player, PL_STAGE)) {
|
||||
int r;
|
||||
U16(movie, MV_LOCKCOUNT) = U16(movie, MV_LOCKCOUNT) + 1;
|
||||
r = as3vm_do_displayobject_event_GC(ctx, movie, 0x15, 0);
|
||||
if (r != 0) {
|
||||
recursive_send_displayobject_event_GC(player, movie, 0x15, 0);
|
||||
}
|
||||
U16(movie, MV_LOCKCOUNT) = U16(movie, MV_LOCKCOUNT) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:5945-5995 (durango) / raw/vita:5468-5517 (exact match; MV_BF, MV_B9,
|
||||
* MVD_178, MV_FRAMECOUNT, MV_TYPE, MV_LIBARRAY, MV_TAGDATA, MV_DLIST, MV_BB
|
||||
* all confirmed). */
|
||||
281
iggy-decompiled/src/reconstructed/swf_play_advance2.inc
Normal file
281
iggy-decompiled/src/reconstructed/swf_play_advance2.inc
Normal file
@@ -0,0 +1,281 @@
|
||||
/* swf_play_advance2.inc -- overflow of swf_play_advance.inc (frame-advance tail:
|
||||
* swf_AdvanceFrameNumber / DoRemoveEventsForAdvance / advance_dlist_GC /
|
||||
* do_remove_with_events_for_advance_dlist / iggy_advance_movie_(raw_)GC).
|
||||
* Uses the width-gated offset macros defined at the top of swf_play_advance.inc
|
||||
* (same translation unit, included immediately after it). */
|
||||
|
||||
static void swf_AdvanceFrameNumber(void *player, void *node, int p3) {
|
||||
if (U8(node, MV_BF) == 2) {
|
||||
return;
|
||||
}
|
||||
if (p3 != 0 && (U8(node, MV_B9) & 1) != 0 && PTR(node, MV_DLIST) != NULL) {
|
||||
I32(node, MVD_178) = I32(node, MV_FRAMECOUNT) + 1;
|
||||
}
|
||||
if (U8(node, MV_TYPE) == 7) {
|
||||
void **arr = (void **)PTR(node, MV_LIBARRAY);
|
||||
int i;
|
||||
for (i = 0; i < 4; i = i + 1) {
|
||||
void *child = arr[i];
|
||||
if (child != NULL) {
|
||||
if (PTR(child, MV_TAGDATA) == NULL || U8(child, MV_TYPE) != 3 ||
|
||||
PTR(child, MV_DLIST) != NULL || (U8(child, MV_B9) & 1) == 0 ||
|
||||
(U8(child, MV_BB) & 0x20) == 0) {
|
||||
swf_AdvanceFrameNumber(player, child, 1);
|
||||
} else {
|
||||
swf_AdvanceFrameNumber(player, child, 0);
|
||||
I32(child, MVD_178) = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
{
|
||||
void *child;
|
||||
for (child = PTR(node, MV_FIRSTCHILD); child != NULL; child = PTR(child, MV_NEXT)) {
|
||||
if ((U8(child, MV_FLAG1) & 2) == 0) {
|
||||
if (PTR(child, MV_TAGDATA) == NULL || U8(child, MV_TYPE) != 3 ||
|
||||
PTR(child, MV_DLIST) != NULL || (U8(child, MV_B9) & 1) == 0 ||
|
||||
(U8(child, MV_BB) & 0x20) == 0) {
|
||||
swf_AdvanceFrameNumber(player, child, 1);
|
||||
} else {
|
||||
swf_AdvanceFrameNumber(player, child, 0);
|
||||
I32(child, MVD_178) = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:5996-6030 (durango) / raw/vita:5405-5462 (exact match; MV_BF, MV_LIBARRAY,
|
||||
* MV_LIBCOUNT, MV_B9, MV_BB, DLREC_TAG/DLREC_RM_ID all confirmed). */
|
||||
static void swf_DoRemoveEventsForAdvance(void *player, void *node) {
|
||||
if (U8(node, MV_BF) == 2) {
|
||||
return;
|
||||
}
|
||||
if (U8(node, MV_TYPE) == 7) {
|
||||
void **arr = (void **)PTR(node, MV_LIBARRAY);
|
||||
int i;
|
||||
for (i = 0; i < 4; i = i + 1) {
|
||||
void *child = arr[i];
|
||||
if (child != NULL && I32(child, MV_LIBCOUNT) != 0 && (U8(child, MV_B9) & 1) != 0) {
|
||||
swf_DoRemoveEventsForAdvance(player, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
void *child;
|
||||
for (child = PTR(node, MV_FIRSTCHILD); child != NULL; child = PTR(child, MV_NEXT)) {
|
||||
if (I32(child, MV_LIBCOUNT) != 0 && (U8(child, MV_B9) & 1) != 0) {
|
||||
swf_DoRemoveEventsForAdvance(player, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((U8(node, MV_B9) & 1) != 0 && (U8(node, MV_BB) & 0x20) != 0 &&
|
||||
U8(node, MV_BF) != 2) {
|
||||
swf_do_remove_with_events_for_advance_dlist(player, node);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:6031-6098 (durango) / raw/vita:2345-2400 (exact match; MV_DLIST,
|
||||
* MV_FRAMECOUNT, MV_FRAMECOUNT_COPY, MV_TYPE, MV_LIBARRAY and every DLREC_*
|
||||
* field confirmed). */
|
||||
static void swf_advance_dlist_GC(void *player, void *movie, uint32_t p3, uint32_t p4,
|
||||
uint32_t p5) {
|
||||
void *rec = PTR(movie, MV_DLIST);
|
||||
void *next_rec = NULL;
|
||||
|
||||
I32(movie, MV_FRAMECOUNT_COPY) = I32(movie, MV_FRAMECOUNT);
|
||||
|
||||
if (U8(movie, MV_TYPE) != 7) {
|
||||
if (rec != NULL) {
|
||||
for (;;) {
|
||||
uint8_t tag = U8(rec, DLREC_TAG);
|
||||
if (tag == 1) {
|
||||
next_rec = PTR(rec, 0);
|
||||
goto advance_tail;
|
||||
} else if (tag == 2) {
|
||||
if (I16(rec, DLREC_PO_ID) != 0) {
|
||||
iggy_do_placeobject_GC(player, movie, rec, 0, I32(movie, MV_FRAMECOUNT),
|
||||
p5, p3, p4);
|
||||
}
|
||||
} else if (tag == 3) {
|
||||
uint16_t idx = U16(rec, DLREC_RM_ID);
|
||||
void *child = ((void **)PTR(movie, MV_LIBARRAY))[idx];
|
||||
if (child != NULL) {
|
||||
iggy_remove_sprite(player, child, 0, 0, PTR(player, PL_AS3VM) == NULL, 1);
|
||||
}
|
||||
} else if (tag == 4) {
|
||||
uint16_t idx = U16(rec, DLREC_DEPTH_ID);
|
||||
void *child = ((void **)PTR(movie, MV_LIBARRAY))[idx];
|
||||
if (child != NULL) {
|
||||
U8(child, MV_BA) = U8(child, MV_BA) | 0x80;
|
||||
I32(child, MVD_114) = (uint32_t)U16(rec, DLREC_DEPTH_VAL);
|
||||
}
|
||||
} else if (tag == 6) {
|
||||
iggy_do_playsound(player, movie, rec);
|
||||
}
|
||||
rec = PTR(rec, 0);
|
||||
if (rec == NULL) break;
|
||||
}
|
||||
next_rec = NULL;
|
||||
}
|
||||
advance_tail:
|
||||
I32(movie, MV_FRAMECOUNT) = I32(movie, MV_FRAMECOUNT) + 1;
|
||||
PTR(movie, MV_DLIST) = next_rec;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:6181-6276 (durango). Not present standalone on vita (folded into its
|
||||
* sole caller); DLREC_TAG / DLREC_RM_ID reused verbatim from swf_advance_
|
||||
* dlist_GC (same record type, directly cross-checked there). MV_PARENT,
|
||||
* MV_B9, MV_AS3VAL, MV_NAME, MV_LIBARRAY, MV_DEPTH, MV_FIRSTCHILD,
|
||||
* MV_LASTCHILD, MV_NEXT, MV_PREV all reused from already-verified macros.
|
||||
* The unlink + re-parent-to-unparented-list tail is byte-for-byte the body of
|
||||
* the already-implemented iggy_add_to_unparented (swf_play_movie.inc), so it
|
||||
* is called directly here rather than re-transcribed. */
|
||||
static void swf_do_remove_with_events_for_advance_dlist(void *player, void *node) {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
void *rec;
|
||||
uint8_t tag;
|
||||
|
||||
for (rec = PTR(node, MV_DLIST);
|
||||
rec != NULL && (tag = U8(rec, DLREC_TAG)) != 1;
|
||||
rec = PTR(rec, 0)) {
|
||||
if (tag == 2) {
|
||||
if (U16(rec, DLREC_PO_ID) != 0 && PTR(rec, DLREC_PO_CHILDPTR) != NULL) {
|
||||
void *child = ((void **)PTR(node, MV_LIBARRAY))[U16(rec, DLREC_PO_ID)];
|
||||
if (child != NULL) {
|
||||
iggy_remove_sprite(player, child, 1, (void *)(intptr_t)1, ctx == NULL, 1);
|
||||
}
|
||||
}
|
||||
} else if (tag == 3) {
|
||||
uint16_t idx = U16(rec, DLREC_RM_ID);
|
||||
void *child = ((void **)PTR(node, MV_LIBARRAY))[idx];
|
||||
if (child != NULL) {
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0x29f, 0, 0);
|
||||
}
|
||||
U8(child, MV_FLAG1) = U8(child, MV_FLAG1) | 8;
|
||||
if (ctx != NULL) {
|
||||
gswf_remove_sprite_do_events(player, child);
|
||||
}
|
||||
if (ctx != NULL && PTR(child, MV_PARENT) != NULL && (U8(child, MV_B9) & 8) != 0) {
|
||||
void **parent_as3 = (void **)PTR(PTR(child, MV_PARENT), MV_AS3VAL);
|
||||
if (parent_as3 != NULL && *parent_as3 != NULL) {
|
||||
/* elided call (durango raw:6228 shows zero explicit args); args
|
||||
* recovered by direct analogy to bind_bare_object's mirror-image
|
||||
* "add" case in swf_play_movie.inc -- see RESIDUALS. */
|
||||
as3vm_set_property_toplevel(ctx, *parent_as3, PTR(child, MV_NAME), 0);
|
||||
}
|
||||
}
|
||||
if (PTR(child, MV_PARENT) != NULL) {
|
||||
if (I32(child, MV_DEPTH) >= 0) {
|
||||
((void **)PTR(PTR(child, MV_PARENT), MV_LIBARRAY))[I32(child, MV_DEPTH)] = NULL;
|
||||
}
|
||||
if (PTR(PTR(child, MV_PARENT), MV_FIRSTCHILD) == child) {
|
||||
PTR(PTR(child, MV_PARENT), MV_FIRSTCHILD) = PTR(child, MV_NEXT);
|
||||
}
|
||||
if (PTR(PTR(child, MV_PARENT), MV_LASTCHILD) == child) {
|
||||
PTR(PTR(child, MV_PARENT), MV_LASTCHILD) = PTR(child, MV_PREV);
|
||||
}
|
||||
if (PTR(child, MV_PARENT) != NULL) {
|
||||
PTR(child, MV_PARENT) = NULL;
|
||||
iggy_mark_movie_dirty(player, child);
|
||||
}
|
||||
if (PTR(child, MV_NEXT) != NULL) {
|
||||
PTR(PTR(child, MV_NEXT), MV_PREV) = PTR(child, MV_PREV);
|
||||
}
|
||||
if (PTR(child, MV_PREV) != NULL) {
|
||||
PTR(PTR(child, MV_PREV), MV_NEXT) = PTR(child, MV_NEXT);
|
||||
}
|
||||
PTR(child, MV_NEXT) = NULL;
|
||||
PTR(child, MV_PREV) = NULL;
|
||||
}
|
||||
iggy_add_to_unparented(player, child);
|
||||
if (ctx == NULL) {
|
||||
iggy_destroy_sprite(player, child);
|
||||
}
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0x2d4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:2179-2189 (durango) / raw/vita:3475-3482. Both raws show the tail-call
|
||||
* with ZERO explicit arguments even though iggy_advance_movie_raw_GC needs
|
||||
* four -- this looks like genuinely dead/unreachable forwarding (register
|
||||
* garbage in the retail build); NULL/0 is passed here as the most defensible
|
||||
* faithful default. See RESIDUALS. */
|
||||
void iggy_advance_movie_GC(void) {
|
||||
iggy_advance_movie_raw_GC(NULL, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
/* raw:2190-2265 (durango) / raw/vita:3394-3471 (exact match; MV_BF, MVD_17C,
|
||||
* MV_B9, MV_FLAG1, MV_DLIST, MVD_178->reused as "reset-to-frame-1" flag here
|
||||
* (same byte offset as movie.inc's "scale x default" field), MV_TYPE,
|
||||
* MV_LIBARRAY, MV_FIRSTCHILD, MV_NEXT, MV_FRAMECOUNT, PL_ROOT_V,
|
||||
* PL_ROOT_FORCE_FLAG, MV_BB all confirmed). */
|
||||
uint64_t iggy_advance_movie_raw_GC(void *player, void *movie, int p3, void *p4) {
|
||||
int p4i = (int)(intptr_t)p4;
|
||||
void *child;
|
||||
|
||||
if (U8(movie, MV_BF) == 2) {
|
||||
if (iggy_seek_behavior_version == 1) {
|
||||
I32(movie, MVD_17C) = 0;
|
||||
}
|
||||
p4i = 1;
|
||||
U8(movie, MV_BF) = 1;
|
||||
} else {
|
||||
int reset = 0;
|
||||
if ((p4i == 0 && p3 != 0 && (U8(movie, MV_B9) & 1) != 0) ||
|
||||
(U8(movie, MV_FLAG1) & 2) != 0) {
|
||||
reset = 1;
|
||||
}
|
||||
I32(movie, MVD_17C) = reset;
|
||||
if (p3 != 0 && (U8(movie, MV_B9) & 1) != 0 && PTR(movie, MV_DLIST) != NULL) {
|
||||
I32(movie, MV_FRAMECOUNT_COPY) = I32(movie, MV_FRAMECOUNT);
|
||||
}
|
||||
if (p4i == 0 && p3 != 0 && (U8(movie, MV_B9) & 1) != 0 &&
|
||||
PTR(movie, MV_DLIST) != NULL && (U8(movie, MV_BB) & 0x20) != 0) {
|
||||
swf_advance_dlist_GC(player, movie, 0, (uint32_t)p4i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (U8(movie, MV_TYPE) == 7) {
|
||||
void **arr = (void **)PTR(movie, MV_LIBARRAY);
|
||||
int i;
|
||||
for (i = 0; i < 4; i = i + 1) {
|
||||
child = arr[i];
|
||||
if (child != NULL) {
|
||||
iggy_advance_movie_raw_GC(player, child, 1, (void *)(intptr_t)p4i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (child = PTR(movie, MV_FIRSTCHILD); child != NULL;) {
|
||||
if ((U8(child, MV_FLAG1) & 2) == 0) {
|
||||
if (PTR(child, MV_TAGDATA) == NULL || U8(child, MV_TYPE) != 3 ||
|
||||
PTR(child, MV_DLIST) != NULL || (U8(child, MV_B9) & 1) == 0 ||
|
||||
(U8(child, MV_BB) & 0x20) == 0 || p4i != 0) {
|
||||
iggy_advance_movie_raw_GC(player, child, 1, (void *)(intptr_t)p4i);
|
||||
} else {
|
||||
if (I32(child, MV_FRAMECOUNT) != 1 &&
|
||||
(child != AT(player, PL_ROOT_V) || I32(player, PL_ROOT_FORCE_FLAG) == 0)) {
|
||||
iggy_seek_frame_GC(player, child, 0, 0);
|
||||
U8(child, MV_FLAG1) = U8(child, MV_FLAG1) | 2;
|
||||
U8(child, MV_BF) = 0;
|
||||
}
|
||||
iggy_advance_movie_raw_GC(player, child, 0, (void *)(intptr_t)0);
|
||||
}
|
||||
} else {
|
||||
I32(child, MVD_17C) = 1;
|
||||
}
|
||||
U8(child, MV_FLAG1) = U8(child, MV_FLAG1) & 0xfd;
|
||||
child = PTR(child, MV_NEXT);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
407
iggy-decompiled/src/reconstructed/swf_play_audio.inc
Normal file
407
iggy-decompiled/src/reconstructed/swf_play_audio.inc
Normal file
@@ -0,0 +1,407 @@
|
||||
/*
|
||||
* swf_play_audio.inc -- the voice / sound-channel path: the per-tick voice
|
||||
* reaper (iggy_audio_update), the pan/gain matrix updater fed to the mixer
|
||||
* (iggy_update_voice), the attach-sound dedup/dispatch entry point
|
||||
* (iggy_do_playsound), the low-level voice allocator (iggy_play_sound), and
|
||||
* the seek-queue drain used by both a discard path and a GC'd flush-and-seek
|
||||
* path (iggy_discard_seek_queue / iggy_flush_seek_queue_GC).
|
||||
*
|
||||
* durango raw line ranges cited per function; every 32-bit offset is read
|
||||
* directly from the vita raw (never halved) and the voice-struct / envelope
|
||||
* / sound-def field roles were cross-validated via
|
||||
* `llvm-objdump -d -r --disassemble-symbols=iggy_update_voice|iggy_play_sound
|
||||
* work/iggy-native-decomp/durango-objects/swf_play.obj` against both raws'
|
||||
* statement order. `PL_VOICE_BASE` / `PL_VOICE_ID` / `PL_VOICE_STRIDE` /
|
||||
* `PL_AS3VM` / `PL_ROOT`/`PL_UNPARENTED` etc. are the frozen swf_play.c
|
||||
* macros; `MV_FIELD140` (swf_play_sprite.inc) and `TXT_CHARTABLE`
|
||||
* (swf_play_textfield.inc) are reused rather than redefined.
|
||||
*/
|
||||
|
||||
/* -- audio-family field offsets (width-gated; durango / vita), prefixed
|
||||
* AUD_ to avoid collision with sibling .inc files' macros. ----------------- */
|
||||
#if IGGY_PTR64
|
||||
#undef AUD_PL_DIRTY
|
||||
# define AUD_PL_DIRTY 0x2f08 /* player: "voices changed this tick" flag. */
|
||||
#undef AUD_V_DEF
|
||||
# define AUD_V_DEF 0x08 /* voice: sound-def / dedup-key pointer. */
|
||||
#undef AUD_V_GAIN
|
||||
# define AUD_V_GAIN 0x10 /* voice: float final gain. */
|
||||
#undef AUD_V_MTX0
|
||||
# define AUD_V_MTX0 0x14 /* voice: float pan-matrix[0]. */
|
||||
#undef AUD_V_MTX1
|
||||
# define AUD_V_MTX1 0x18 /* voice: float pan-matrix[1]. */
|
||||
#undef AUD_V_MTX2
|
||||
# define AUD_V_MTX2 0x1c /* voice: float pan-matrix[2]. */
|
||||
#undef AUD_V_MTX3
|
||||
# define AUD_V_MTX3 0x20 /* voice: float pan-matrix[3]. */
|
||||
#undef AUD_V_P9
|
||||
# define AUD_V_P9 0x28 /* voice: caller-supplied opaque tag (p9). */
|
||||
#undef AUD_V_OBJ
|
||||
# define AUD_V_OBJ 0x30 /* voice: instigating-object pointer (p2). */
|
||||
#undef AUD_SEEKQ_HEAD
|
||||
# define AUD_SEEKQ_HEAD 0x2848 /* player: seek-queue head. */
|
||||
#undef AUD_SEEKQ_TAIL
|
||||
# define AUD_SEEKQ_TAIL 0x2850 /* player: seek-queue tail. */
|
||||
#undef AUD_SQ_MOVIE
|
||||
# define AUD_SQ_MOVIE 0x08 /* seek-queue node: target movie. */
|
||||
#undef AUD_SQ_FRAME
|
||||
# define AUD_SQ_FRAME 0x10 /* seek-queue node: target frame (int32). */
|
||||
#undef AUD_SQ_FLAG
|
||||
# define AUD_SQ_FLAG 0x14 /* seek-queue node: byte flag (0/1/-1). */
|
||||
#undef AUD_SEV_ID
|
||||
# define AUD_SEV_ID 0x0c /* sound-event record: u16 character id. */
|
||||
#undef AUD_SEV_FLAG1
|
||||
# define AUD_SEV_FLAG1 0x0e /* sound-event record: "stop" flag. */
|
||||
#undef AUD_SEV_FLAG2
|
||||
# define AUD_SEV_FLAG2 0x0f /* sound-event record: "no-restart" flag. */
|
||||
#undef AUD_INST_MTX
|
||||
# define AUD_INST_MTX 0x18 /* instigator: envelope-override matrix ptr. */
|
||||
#undef AUD_INST_FLAG
|
||||
# define AUD_INST_FLAG 0x28 /* instigator: envelope-present type flag. */
|
||||
#undef AUD_INST_ENV
|
||||
# define AUD_INST_ENV 0x30 /* instigator: envelope record pointer. */
|
||||
#undef AUD_SND_TYPE
|
||||
# define AUD_SND_TYPE 0x36 /* sound-def: codec type tag. */
|
||||
#undef AUD_SND_ARG24
|
||||
# define AUD_SND_ARG24 0x24 /* sound-def: misc int (all codecs). */
|
||||
#undef AUD_SND_DATA
|
||||
# define AUD_SND_DATA 0x28 /* sound-def: encoded-data pointer. */
|
||||
#undef AUD_SND_BLOCK
|
||||
# define AUD_SND_BLOCK 0x30 /* sound-def: block-size (adpcm/mp3). */
|
||||
#undef AUD_SND_RATE
|
||||
# define AUD_SND_RATE 0x34 /* sound-def: u16 sample rate (not mp3). */
|
||||
#undef AUD_SND_FLAGA
|
||||
# define AUD_SND_FLAGA 0x37 /* sound-def: byte flag (uncompressed only). */
|
||||
#undef AUD_SND_FLAGB
|
||||
# define AUD_SND_FLAGB 0x38 /* sound-def: byte flag (uncompressed+adpcm). */
|
||||
#else
|
||||
#undef AUD_PL_DIRTY
|
||||
# define AUD_PL_DIRTY 0x25b8
|
||||
#undef AUD_V_DEF
|
||||
# define AUD_V_DEF 0x04
|
||||
#undef AUD_V_GAIN
|
||||
# define AUD_V_GAIN 0x08
|
||||
#undef AUD_V_MTX0
|
||||
# define AUD_V_MTX0 0x0c
|
||||
#undef AUD_V_MTX1
|
||||
# define AUD_V_MTX1 0x10
|
||||
#undef AUD_V_MTX2
|
||||
# define AUD_V_MTX2 0x14
|
||||
#undef AUD_V_MTX3
|
||||
# define AUD_V_MTX3 0x18
|
||||
#undef AUD_V_P9
|
||||
# define AUD_V_P9 0x20
|
||||
#undef AUD_V_OBJ
|
||||
# define AUD_V_OBJ 0x24
|
||||
#undef AUD_SEEKQ_HEAD
|
||||
# define AUD_SEEKQ_HEAD 0x2170
|
||||
#undef AUD_SEEKQ_TAIL
|
||||
# define AUD_SEEKQ_TAIL 0x2174
|
||||
#undef AUD_SQ_MOVIE
|
||||
# define AUD_SQ_MOVIE 0x04
|
||||
#undef AUD_SQ_FRAME
|
||||
# define AUD_SQ_FRAME 0x08
|
||||
#undef AUD_SQ_FLAG
|
||||
# define AUD_SQ_FLAG 0x0c
|
||||
#undef AUD_SEV_ID
|
||||
# define AUD_SEV_ID 0x08
|
||||
#undef AUD_SEV_FLAG1
|
||||
# define AUD_SEV_FLAG1 0x0a
|
||||
#undef AUD_SEV_FLAG2
|
||||
# define AUD_SEV_FLAG2 0x0b
|
||||
#undef AUD_INST_MTX
|
||||
# define AUD_INST_MTX 0x10
|
||||
#undef AUD_INST_FLAG
|
||||
# define AUD_INST_FLAG 0x20
|
||||
#undef AUD_INST_ENV
|
||||
# define AUD_INST_ENV 0x24
|
||||
#undef AUD_SND_TYPE
|
||||
# define AUD_SND_TYPE 0x22
|
||||
#undef AUD_SND_ARG24
|
||||
# define AUD_SND_ARG24 0x14
|
||||
#undef AUD_SND_DATA
|
||||
# define AUD_SND_DATA 0x18
|
||||
#undef AUD_SND_BLOCK
|
||||
# define AUD_SND_BLOCK 0x1c
|
||||
#undef AUD_SND_RATE
|
||||
# define AUD_SND_RATE 0x20
|
||||
#undef AUD_SND_FLAGA
|
||||
# define AUD_SND_FLAGA 0x23
|
||||
#undef AUD_SND_FLAGB
|
||||
# define AUD_SND_FLAGB 0x24
|
||||
#endif
|
||||
/* envelope record fields (same offsets both widths -- small leading fields). */
|
||||
#undef AUD_ENV_TYPE
|
||||
#define AUD_ENV_TYPE 0
|
||||
#undef AUD_ENV_A
|
||||
#define AUD_ENV_A 4
|
||||
#undef AUD_ENV_D
|
||||
#define AUD_ENV_D 6
|
||||
|
||||
/* raw:2266-2304 reap finished voices (freeing any pooled AS3 handle) and
|
||||
* push updated pan/gain to any voice still playing when the player's
|
||||
* "voices changed" flag is set; always clears that flag at the end. */
|
||||
void iggy_audio_update(void *player) {
|
||||
int i;
|
||||
for (i = 0; i < 8; i++) {
|
||||
intptr_t voice_off = (intptr_t)i * PL_VOICE_STRIDE;
|
||||
void *voice = AT(player, PL_VOICE_BASE + voice_off);
|
||||
if (I16(voice, PL_VOICE_ID - PL_VOICE_BASE) < 0) {
|
||||
continue;
|
||||
}
|
||||
if (iggy_free_voice_if_done((int)I16(voice, PL_VOICE_ID - PL_VOICE_BASE))) {
|
||||
if (PTR(voice, 0) != NULL) {
|
||||
as3vm_pool_free(PTR(player, PL_AS3VM), PTR(voice, 0));
|
||||
PTR(voice, 0) = NULL;
|
||||
}
|
||||
I16(voice, PL_VOICE_ID - PL_VOICE_BASE) = -1;
|
||||
} else if (I32(player, AUD_PL_DIRTY) != 0) {
|
||||
iggy_update_voice(player, i);
|
||||
}
|
||||
}
|
||||
I32(player, AUD_PL_DIRTY) = 0;
|
||||
}
|
||||
|
||||
/* raw:4476-4507 (objdump-resolved) recompute a voice's 2x2 pan matrix from
|
||||
* the voice's own stored matrix and the player's listener matrix
|
||||
* (player+0x2ef0..0x2f04), then push the voice's id/gain/matrix to the mixer
|
||||
* via iggy_change_sample. */
|
||||
void iggy_update_voice(void *player, int voice_idx) {
|
||||
void *voice = AT(player, PL_VOICE_BASE + (intptr_t)voice_idx * PL_VOICE_STRIDE);
|
||||
float m0 = F32(voice, AUD_V_MTX0);
|
||||
float m1 = F32(voice, AUD_V_MTX1);
|
||||
float m2 = F32(voice, AUD_V_MTX2);
|
||||
float m3 = F32(voice, AUD_V_MTX3);
|
||||
float out[4];
|
||||
out[0] = m0 * F32(player, 0x2ef8) + m1 * F32(player, 0x2f00);
|
||||
out[1] = m2 * F32(player, 0x2ef8) + m3 * F32(player, 0x2f00);
|
||||
out[2] = m0 * F32(player, 0x2efc) + m1 * F32(player, 0x2f04);
|
||||
out[3] = m3 * F32(player, 0x2f04) + m2 * F32(player, 0x2f00);
|
||||
iggy_change_sample((int)I16(voice, PL_VOICE_ID - PL_VOICE_BASE),
|
||||
F32(player, 0x2ef0) * F32(voice, AUD_V_GAIN) * F32(player, 0x2ef4), out);
|
||||
}
|
||||
|
||||
/* raw:2917-2987 attach-sound dedup / stop / (re)play dispatch: resolve the
|
||||
* character id to its DefineSound-like definition (must be tag 0x15), then
|
||||
* either stop-a-matching-voice, start-a-new-voice-if-none-matches, or
|
||||
* restart depending on the sound-event record's two flag bytes. */
|
||||
void iggy_do_playsound(void *player, void *p2, void *sev) {
|
||||
uint16_t char_id = U16(sev, AUD_SEV_ID);
|
||||
void *def;
|
||||
if (char_id == 0) {
|
||||
return;
|
||||
}
|
||||
def = *(void **)AT(PTR(player, TXT_CHARTABLE), (intptr_t)char_id * sizeof(void *));
|
||||
if (def == NULL || U8(def, 0) != 0x15) {
|
||||
return;
|
||||
}
|
||||
if (U8(sev, AUD_SEV_FLAG1) == 0) {
|
||||
int i, found = 8;
|
||||
if (U8(sev, AUD_SEV_FLAG2) != 0) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
void *voice = AT(player, PL_VOICE_BASE + (intptr_t)i * PL_VOICE_STRIDE);
|
||||
if (I16(voice, PL_VOICE_ID - PL_VOICE_BASE) >= 0 && PTR(voice, AUD_V_DEF) == def) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found != 8) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
void *voice = AT(player, PL_VOICE_BASE + (intptr_t)i * PL_VOICE_STRIDE);
|
||||
if (I16(voice, PL_VOICE_ID - PL_VOICE_BASE) >= 0 && PTR(voice, AUD_V_DEF) == def &&
|
||||
PTR(voice, AUD_V_P9) == p2 && PTR(voice, AUD_V_OBJ) == sev) {
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == 8) {
|
||||
iggy_play_sound(player, sev, 0, def, 0, 0, 0, 0, p2);
|
||||
}
|
||||
} else {
|
||||
int i;
|
||||
for (i = 0; i < 8; i++) {
|
||||
void *voice = AT(player, PL_VOICE_BASE + (intptr_t)i * PL_VOICE_STRIDE);
|
||||
if (I16(voice, PL_VOICE_ID - PL_VOICE_BASE) >= 0 && PTR(voice, AUD_V_DEF) == def) {
|
||||
iggy_free_voice((int)I16(voice, PL_VOICE_ID - PL_VOICE_BASE));
|
||||
I16(voice, PL_VOICE_ID - PL_VOICE_BASE) = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:3926-4071 (objdump-resolved) allocate a free voice slot, resolve the
|
||||
* pan/gain matrix (identity, or scaled from an attached envelope when `p2` is
|
||||
* a type-1 instigator with a zero-tagged envelope record), dispatch to the
|
||||
* matching codec (`p4`'s type byte: 0/3 = uncompressed, 1 = adpcm, 2 = mp3),
|
||||
* and on success stamp the voice struct. The three codec calls recover their
|
||||
* Ghidra-elided trailing stack args from the locals' address order (verified
|
||||
* consistent across all three branches: the ascending-named locals are the
|
||||
* ascending stack argument positions in each). */
|
||||
int iggy_play_sound(void *player, void *p2, float *p3, void *p4, void *p5, void *p6, float p7,
|
||||
float *p8, void *p9) {
|
||||
int slot;
|
||||
float pan[4];
|
||||
uint16_t voiceid;
|
||||
intptr_t voice_off;
|
||||
void *voice;
|
||||
(void)p5;
|
||||
(void)p6;
|
||||
|
||||
if (iggy_tm_normal) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0x898, 0, 0);
|
||||
}
|
||||
|
||||
for (slot = 0; slot < 8; slot++) {
|
||||
if (I16(AT(player, PL_VOICE_BASE + (intptr_t)slot * PL_VOICE_STRIDE),
|
||||
PL_VOICE_ID - PL_VOICE_BASE) < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (slot == 8) {
|
||||
if (iggy_tm_normal) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0x89f);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
pan[0] = 1.0f;
|
||||
pan[1] = 0.0f;
|
||||
pan[2] = 0.0f;
|
||||
pan[3] = 1.0f;
|
||||
if (p2 != NULL) {
|
||||
p3 = (float *)AT(p2, AUD_INST_MTX);
|
||||
p7 = 1.0f;
|
||||
if (I32(p2, AUD_INST_FLAG) == 1) {
|
||||
void *env = PTR(p2, AUD_INST_ENV);
|
||||
if (I32(env, AUD_ENV_TYPE) == 0) {
|
||||
pan[0] = (float)U16(env, AUD_ENV_A) * (1.0f / 32768.0f);
|
||||
pan[3] = (float)U16(env, AUD_ENV_D) * (1.0f / 32768.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
float *src = (p8 != NULL) ? p8 : pan;
|
||||
uint8_t codec = U8(p4, AUD_SND_TYPE);
|
||||
float gain = p7 * F32(player, 0x2ef0) * F32(player, 0x2ef4);
|
||||
float out[4];
|
||||
uint16_t ret;
|
||||
out[0] = F32(player, 0x2ef8) * src[0] + src[1] * F32(player, 0x2f00);
|
||||
out[1] = F32(player, 0x2ef8) * src[2] + src[3] * F32(player, 0x2f00);
|
||||
out[2] = src[0] * F32(player, 0x2efc) + F32(player, 0x2f04) * src[1];
|
||||
out[3] = F32(player, 0x2f04) * src[3] + src[2] * F32(player, 0x2f00);
|
||||
|
||||
/* iggy_play_uncompressed/adpcm/mp3 are frozen `void`-returning imports
|
||||
* (swf_play.c), but the retail bodies return the allocated voice's 16-bit
|
||||
* id (Ghidra: `uVar7 = iggy_play_uncompressed(...)`), which durango
|
||||
* stores back into the voice slot and later tests `< 0`. Call through a
|
||||
* differently-typed function pointer to recover that value without
|
||||
* touching the frozen `extern void ...` declarations. */
|
||||
if (codec == 0 || codec == 3) {
|
||||
uint16_t (*fn)(void *, ...) = (uint16_t(*)(void *, ...))(uintptr_t)iggy_play_uncompressed;
|
||||
ret = fn(player, PTR(p4, AUD_SND_DATA), U16(p4, AUD_SND_RATE), U32(p4, AUD_SND_ARG24), p3,
|
||||
out, gain, U8(p4, AUD_SND_FLAGA), U8(p4, AUD_SND_FLAGB));
|
||||
} else if (codec == 1) {
|
||||
uint16_t (*fn)(void *, ...) = (uint16_t(*)(void *, ...))(uintptr_t)iggy_play_adpcm;
|
||||
ret = fn(player, PTR(p4, AUD_SND_DATA), U32(p4, AUD_SND_BLOCK), U16(p4, AUD_SND_RATE),
|
||||
U32(p4, AUD_SND_ARG24), p3, out, gain, U8(p4, AUD_SND_FLAGB));
|
||||
} else if (codec == 2) {
|
||||
uint16_t (*fn)(void *, ...) = (uint16_t(*)(void *, ...))(uintptr_t)iggy_play_mp3;
|
||||
ret = fn(player, PTR(p4, AUD_SND_DATA), U32(p4, AUD_SND_BLOCK), gain, U32(p4, AUD_SND_ARG24),
|
||||
p3, out);
|
||||
} else {
|
||||
ret = 0xffff;
|
||||
}
|
||||
I16(AT(player, PL_VOICE_BASE + (intptr_t)slot * PL_VOICE_STRIDE), PL_VOICE_ID - PL_VOICE_BASE) =
|
||||
(int16_t)ret;
|
||||
|
||||
if (iggy_tm_normal) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0x8c7);
|
||||
}
|
||||
|
||||
voice_off = PL_VOICE_BASE + (intptr_t)slot * PL_VOICE_STRIDE;
|
||||
voice = AT(player, voice_off);
|
||||
voiceid = (uint16_t)I16(voice, PL_VOICE_ID - PL_VOICE_BASE);
|
||||
if ((int16_t)voiceid < 0) {
|
||||
return -1;
|
||||
}
|
||||
F32(voice, AUD_V_GAIN) = p7;
|
||||
PTR(voice, AUD_V_OBJ) = p2;
|
||||
PTR(voice, AUD_V_DEF) = p4;
|
||||
PTR(voice, AUD_V_P9) = p9;
|
||||
PTR(voice, 0) = NULL;
|
||||
/* Persist the pre-listener-multiplication pan (src[]), not the
|
||||
* already-multiplied out[] sent to the codec: iggy_update_voice
|
||||
* re-multiplies this stored matrix by the player's listener matrix
|
||||
* every tick, so storing the multiplied result would double-apply it. */
|
||||
F32(voice, AUD_V_MTX0) = src[0];
|
||||
F32(voice, AUD_V_MTX1) = src[1];
|
||||
F32(voice, AUD_V_MTX2) = src[2];
|
||||
F32(voice, AUD_V_MTX3) = src[3];
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:2782-2814 drain the seek queue, dropping (not executing) each pending
|
||||
* seek: clear the target movie's pending-seek backlink and toggle its
|
||||
* MV_B9 bit0 to match the request's "was already queued" flag, then free the
|
||||
* node. */
|
||||
void iggy_discard_seek_queue(void *player) {
|
||||
void *node = PTR(player, AUD_SEEKQ_HEAD);
|
||||
while (node != NULL) {
|
||||
void *next = PTR(node, 0);
|
||||
void *movie;
|
||||
PTR(player, AUD_SEEKQ_HEAD) = next;
|
||||
if (next == NULL) {
|
||||
PTR(player, AUD_SEEKQ_TAIL) = NULL;
|
||||
}
|
||||
movie = PTR(node, AUD_SQ_MOVIE);
|
||||
if (movie != NULL) {
|
||||
PTR(movie, MV_FIELD140) = NULL;
|
||||
if (I8(node, AUD_SQ_FLAG) != -1) {
|
||||
uint8_t bit = (I8(node, AUD_SQ_FLAG) == 0) ? 1 : 0;
|
||||
U8(movie, MV_B9) = (uint8_t)(U8(movie, MV_B9) ^ ((bit ^ U8(movie, MV_B9)) & 1));
|
||||
}
|
||||
}
|
||||
iggy_free_alloc(player, node);
|
||||
node = PTR(player, AUD_SEEKQ_HEAD);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:3069-3107 drain the seek queue, this time actually performing each
|
||||
* pending seek (iggy_seek_frame_GC) before freeing the node; returns nonzero
|
||||
* iff any node had a live target movie. */
|
||||
uint64_t iggy_flush_seek_queue_GC(void *player) {
|
||||
uint64_t did_seek = 0;
|
||||
void *node = PTR(player, AUD_SEEKQ_HEAD);
|
||||
while (node != NULL) {
|
||||
void *next = PTR(node, 0);
|
||||
void *movie;
|
||||
PTR(player, AUD_SEEKQ_HEAD) = next;
|
||||
if (next == NULL) {
|
||||
PTR(player, AUD_SEEKQ_TAIL) = NULL;
|
||||
}
|
||||
movie = PTR(node, AUD_SQ_MOVIE);
|
||||
if (movie != NULL) {
|
||||
PTR(movie, MV_FIELD140) = NULL;
|
||||
if (I8(node, AUD_SQ_FLAG) != -1) {
|
||||
uint8_t bit = (I8(node, AUD_SQ_FLAG) == 0) ? 1 : 0;
|
||||
U8(movie, MV_B9) = (uint8_t)(U8(movie, MV_B9) ^ ((bit ^ U8(movie, MV_B9)) & 1));
|
||||
}
|
||||
did_seek = 1;
|
||||
if (I32(node, AUD_SQ_FRAME) >= 0) {
|
||||
iggy_seek_frame_GC(player, movie, I32(node, AUD_SQ_FRAME), 0);
|
||||
}
|
||||
}
|
||||
iggy_free_alloc(player, node);
|
||||
node = PTR(player, AUD_SEEKQ_HEAD);
|
||||
}
|
||||
return did_seek;
|
||||
}
|
||||
655
iggy-decompiled/src/reconstructed/swf_play_create.inc
Normal file
655
iggy-decompiled/src/reconstructed/swf_play_create.inc
Normal file
@@ -0,0 +1,655 @@
|
||||
/*
|
||||
* swf_play_create.inc -- the movie-creation family: create_buttonrecord_movie_GC,
|
||||
* create_from_null_GC, create_movie_GC (the movie constructor), create_movie_finish,
|
||||
* finish_creating_children, iggy_create_empty_bitmap, iggy_create_movie_complete_GC,
|
||||
* iggy_create_movie_for_actionscript_object, iggy_finish_creating_movie_GC,
|
||||
* iggy_initialized_main_movie_GC, make_bare_object_constructed, make_null_object_bare_GC,
|
||||
* movie_is_entirely_unreferenced, null_object.
|
||||
*
|
||||
* durango raw line ranges: 792-821, 822-887, 888-1102, 1103-1128, 1834-1862, 2315-2363,
|
||||
* 2364-2391, 2392-2467, 3049-3068, 3445-3492, 4849-4919, 4920-4980, 4981-5016, 5017-5056.
|
||||
*
|
||||
* 32-bit offsets are cross-checked directly against the vita raw: bind_bare_object,
|
||||
* create_from_null_GC and create_movie_GC (vita ~2463-3158), iggy_create_movie_for_
|
||||
* actionscript_object / iggy_make_empty_sprite / iggy_make_empty_shape / iggy_create_
|
||||
* empty_bitmap (vita ~1184-1331), iggy_create_movie_complete_GC (vita ~3162-3176),
|
||||
* iggy_finish_creating_movie_GC -- which the vita compiler inlines make_bare_object_
|
||||
* constructed + create_movie_finish directly into (vita ~2239-2339), iggy_initialized_
|
||||
* main_movie_GC (vita ~3540-3569), make_null_object_bare_GC (vita ~2404-2459),
|
||||
* movie_is_entirely_unreferenced (vita ~5361-5399), and the per-record button-movie
|
||||
* creation that vita inlines into its own initialize_button_GC (vita ~3004-3096).
|
||||
*/
|
||||
|
||||
/* -- fields this file needs beyond swf_play.c's PL_* / MV_AS3VALUE and swf_play_movie.inc's
|
||||
* MV_FLAG1/MV_TYPE/MV_B9/MV_BA/MV_BB/MV_CLASSPTR/MV_AS3VAL/MV_PARENT/MV_PREV/MV_NEXT. --- */
|
||||
#if IGGY_PTR64
|
||||
#undef CM_DEF
|
||||
# define CM_DEF 0xa8 /* movie: ptr to its source tag/definition. */
|
||||
#undef CM_NAME
|
||||
# define CM_NAME 0x138 /* movie: ptr interned instance name (bind_bare_ */
|
||||
/* object's real read site for both widths -- */
|
||||
/* NOTE 32-bit disagrees with swf_play_movie.inc's*/
|
||||
/* MV_NAME=0xc4; see RESIDUALS in the report). */
|
||||
#undef CM_ROOT
|
||||
# define CM_ROOT 0x24c0 /* embedded root movie (matches swf_playhead.c's */
|
||||
/* independently-derived PL_ROOTMOVIE; swf_play.c's*/
|
||||
/* own PL_ROOT=0x1f00 for vita looks like a typo, */
|
||||
/* see RESIDUALS). */
|
||||
#undef CM_CHARDEFS
|
||||
# define CM_CHARDEFS 0x98 /* player: flat character-id -> tag table. */
|
||||
#undef CM_FSCRIPT_BASE
|
||||
# define CM_FSCRIPT_BASE 0x2508 /* player: ptr per-frame framescript-head array. */
|
||||
#undef CM_FSCRIPT_COUNT
|
||||
# define CM_FSCRIPT_COUNT 0x261c /* player: int element count of that array. */
|
||||
#undef CM_MAIN_FRAMECOUNT
|
||||
# define CM_MAIN_FRAMECOUNT 0x6c /* player: int main-timeline frame count. */
|
||||
#undef CM_OBJCOUNT_A
|
||||
# define CM_OBJCOUNT_A 0x2f2c /* player: int live-object instrumentation ctr. */
|
||||
#undef CM_OBJCOUNT_B
|
||||
# define CM_OBJCOUNT_B 0x2f28 /* player: int live-object instrumentation ctr. */
|
||||
#undef CM_AS3_WK1
|
||||
# define CM_AS3_WK1 0x25b8 /* as3vm ctx: well-known class ptr #1. */
|
||||
#undef CM_AS3_WK2
|
||||
# define CM_AS3_WK2 0x2610 /* as3vm ctx: well-known class ptr #2. */
|
||||
#undef CM_AS3_SUPER
|
||||
# define CM_AS3_SUPER 0x40 /* class: superclass/next-in-chain ptr. */
|
||||
#undef CM_AS3_CTORCTX
|
||||
# define CM_AS3_CTORCTX 0x28d0 /* as3vm ctx: reentrant under-construction slot. */
|
||||
#undef CM_CLASS_CTOR
|
||||
# define CM_CLASS_CTOR 0x30 /* class: constructor-ish field. */
|
||||
#undef CM_TEXT_SRC
|
||||
# define CM_TEXT_SRC 0x60 /* tag: cached wide-string ptr (EditText tags). */
|
||||
#undef CM_SLOT_A
|
||||
# define CM_SLOT_A 0x160 /* movie: shared shape-framecount/button slot A. */
|
||||
#undef CM_SLOT_B
|
||||
# define CM_SLOT_B 0x168 /* movie: shared shape-framecount/button slot B. */
|
||||
#undef CM_TAG_COUNT
|
||||
# define CM_TAG_COUNT 0x2a /* tag: u16 button-state count (Shape tags). */
|
||||
#undef CM_TAG_SLOTSRC
|
||||
# define CM_TAG_SLOTSRC 0x38 /* tag: ptr source for CM_SLOT_A/B. */
|
||||
#undef CM_TAG_ICON
|
||||
# define CM_TAG_ICON 0x30 /* tag: ptr icon override (used when flag1<0). */
|
||||
#undef CM_TAG_CACHED
|
||||
# define CM_TAG_CACHED 0x20 /* tag: ptr cached-value pair source. */
|
||||
#undef CM_ICON_FIELD
|
||||
# define CM_ICON_FIELD 0x180 /* movie: ptr icon (default &DAT_..eb29). */
|
||||
#undef CM_BUTTONFLAG
|
||||
# define CM_BUTTONFLAG 0xbd /* movie: byte button-init-done flag. */
|
||||
#undef CM_BUTTONFLAG2
|
||||
# define CM_BUTTONFLAG2 0x113 /* movie: byte button secondary flag. */
|
||||
#undef CM_BITMAP_ALLOC
|
||||
# define CM_BITMAP_ALLOC 0x20 /* bytes: iggy_create_empty_bitmap tag alloc size.*/
|
||||
#undef CM_BITMAP_QUALITY
|
||||
# define CM_BITMAP_QUALITY 0x234 /* player: byte default smoothing/quality source. */
|
||||
#undef AS3VAL_OWNER
|
||||
# define AS3VAL_OWNER 0x27 /* AS3 value: back-ptr to owning movie. */
|
||||
#undef AS3VAL_CLEAR
|
||||
# define AS3VAL_CLEAR 0x2f /* AS3 value: flags word cleared on construction. */
|
||||
#undef MV_FIRSTCHILD
|
||||
# define MV_FIRSTCHILD 0x10 /* movie: ptr first child (container head). */
|
||||
#undef MV_BUTTONSTATES
|
||||
# define MV_BUTTONSTATES 0x48 /* movie: ptr button-state array. */
|
||||
#undef MV_BUTTONCOUNT
|
||||
# define MV_BUTTONCOUNT 0x15c /* movie: uint button-state array length. */
|
||||
#undef MV_EVENTDEPTH
|
||||
# define MV_EVENTDEPTH 6 /* movie: short reentrant event/ctor nesting. */
|
||||
#else
|
||||
#undef CM_DEF
|
||||
# define CM_DEF 0x58
|
||||
#undef CM_NAME
|
||||
# define CM_NAME 0xe0
|
||||
#undef CM_ROOT
|
||||
# define CM_ROOT 0x1efc
|
||||
#undef CM_CHARDEFS
|
||||
# define CM_CHARDEFS 0x78
|
||||
#undef CM_FSCRIPT_BASE
|
||||
# define CM_FSCRIPT_BASE 0x1f24
|
||||
#undef CM_FSCRIPT_COUNT
|
||||
# define CM_FSCRIPT_COUNT 0x1ff0
|
||||
#undef CM_MAIN_FRAMECOUNT
|
||||
# define CM_MAIN_FRAMECOUNT 0x5c
|
||||
#undef CM_OBJCOUNT_A
|
||||
# define CM_OBJCOUNT_A 0x25d8
|
||||
#undef CM_OBJCOUNT_B
|
||||
# define CM_OBJCOUNT_B 0x25dc
|
||||
#undef CM_AS3_WK1
|
||||
# define CM_AS3_WK1 0x151c
|
||||
#undef CM_AS3_WK2
|
||||
# define CM_AS3_WK2 0x1548
|
||||
#undef CM_AS3_SUPER
|
||||
# define CM_AS3_SUPER 0x24
|
||||
#undef CM_AS3_CTORCTX
|
||||
# define CM_AS3_CTORCTX 0x16cc
|
||||
#undef CM_CLASS_CTOR
|
||||
# define CM_CLASS_CTOR 0x1c
|
||||
#undef CM_TEXT_SRC
|
||||
# define CM_TEXT_SRC 0x40
|
||||
#undef CM_SLOT_A
|
||||
# define CM_SLOT_A 0xf8
|
||||
#undef CM_SLOT_B
|
||||
# define CM_SLOT_B 0xfc
|
||||
#undef CM_TAG_COUNT
|
||||
# define CM_TAG_COUNT 0x16
|
||||
#undef CM_TAG_SLOTSRC
|
||||
# define CM_TAG_SLOTSRC 0x1c
|
||||
#undef CM_TAG_ICON
|
||||
# define CM_TAG_ICON 0x18
|
||||
#undef CM_TAG_CACHED
|
||||
# define CM_TAG_CACHED 0x10
|
||||
#undef CM_ICON_FIELD
|
||||
# define CM_ICON_FIELD 0x110
|
||||
#undef CM_BUTTONFLAG
|
||||
# define CM_BUTTONFLAG 0x65
|
||||
#undef CM_BUTTONFLAG2
|
||||
# define CM_BUTTONFLAG2 0xbb
|
||||
#undef CM_BITMAP_ALLOC
|
||||
# define CM_BITMAP_ALLOC 0x10
|
||||
#undef CM_BITMAP_QUALITY
|
||||
# define CM_BITMAP_QUALITY 0x1f4
|
||||
#undef AS3VAL_OWNER
|
||||
# define AS3VAL_OWNER 0x17
|
||||
#undef AS3VAL_CLEAR
|
||||
# define AS3VAL_CLEAR 0x1b
|
||||
#undef MV_FIRSTCHILD
|
||||
# define MV_FIRSTCHILD 0x0c
|
||||
#undef MV_BUTTONSTATES
|
||||
# define MV_BUTTONSTATES 0x28
|
||||
#undef MV_BUTTONCOUNT
|
||||
# define MV_BUTTONCOUNT 0xf4
|
||||
#undef MV_EVENTDEPTH
|
||||
# define MV_EVENTDEPTH 6
|
||||
#endif
|
||||
|
||||
/* raw:792-821 (button-record placement helper; vita inlines this into its own
|
||||
* initialize_button_GC at ~3004-3096, confirming CM_CHARDEFS + the matrix/cxform
|
||||
* destination offsets byte-for-byte). */
|
||||
static void *create_buttonrecord_movie_GC(void *player, void *record) {
|
||||
void *def = *(void **)AT(PTR(player, CM_CHARDEFS),
|
||||
(uintptr_t)U16(record, 4) * sizeof(void *));
|
||||
void *movie = placeobject_GC(player, NULL, 0, def, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0);
|
||||
if (I8(movie, MV_TYPE) != 7) {
|
||||
make_null_object_bare_GC(player, movie);
|
||||
}
|
||||
bind_bare_object(player, movie);
|
||||
/* record's matrix (src+0x24..0x3b) -> movie's transform matrix;
|
||||
* record's cxform-ish block (src+0x08..0x23) -> movie's cxform slot. */
|
||||
#if IGGY_PTR64
|
||||
*(uint64_t *)AT(movie, 0xd8) = *(uint64_t *)AT(record, 0x24);
|
||||
*(uint64_t *)AT(movie, 0xe0) = *(uint64_t *)AT(record, 0x2c);
|
||||
*(uint64_t *)AT(movie, 0xe8) = *(uint64_t *)AT(record, 0x34);
|
||||
*(uint64_t *)AT(movie, 0xf0) = *(uint64_t *)AT(record, 0x08);
|
||||
*(uint64_t *)AT(movie, 0xf8) = *(uint64_t *)AT(record, 0x10);
|
||||
*(uint64_t *)AT(movie, 0x100) = *(uint64_t *)AT(record, 0x18);
|
||||
*(uint32_t *)AT(movie, 0x108) = *(uint32_t *)AT(record, 0x20);
|
||||
#else
|
||||
*(uint32_t *)AT(movie, 0x80) = *(uint32_t *)AT(record, 0x24);
|
||||
*(uint32_t *)AT(movie, 0x84) = *(uint32_t *)AT(record, 0x28);
|
||||
*(uint32_t *)AT(movie, 0x88) = *(uint32_t *)AT(record, 0x2c);
|
||||
*(uint32_t *)AT(movie, 0x8c) = *(uint32_t *)AT(record, 0x30);
|
||||
*(uint32_t *)AT(movie, 0x90) = *(uint32_t *)AT(record, 0x34);
|
||||
*(uint32_t *)AT(movie, 0x94) = *(uint32_t *)AT(record, 0x38);
|
||||
*(uint32_t *)AT(movie, 0x98) = *(uint32_t *)AT(record, 0x08);
|
||||
*(uint32_t *)AT(movie, 0x9c) = *(uint32_t *)AT(record, 0x0c);
|
||||
*(uint32_t *)AT(movie, 0xa0) = *(uint32_t *)AT(record, 0x10);
|
||||
*(uint32_t *)AT(movie, 0xa4) = *(uint32_t *)AT(record, 0x14);
|
||||
*(uint32_t *)AT(movie, 0xa8) = *(uint32_t *)AT(record, 0x18);
|
||||
*(uint32_t *)AT(movie, 0xac) = *(uint32_t *)AT(record, 0x1c);
|
||||
*(uint32_t *)AT(movie, 0xb0) = *(uint32_t *)AT(record, 0x20);
|
||||
#endif
|
||||
return movie;
|
||||
}
|
||||
|
||||
/* raw:822-887 (vita ~2515-2598). */
|
||||
static void create_from_null_GC(void *player, void *movie, int p3, uint32_t p4) {
|
||||
if (PTR(movie, CM_SLOT_B) != NULL) {
|
||||
void *def = PTR(movie, CM_DEF);
|
||||
void *cls;
|
||||
if (I8(def, 1) < 0) {
|
||||
cls = PTR(def, MV_CLASSPTR);
|
||||
} else if ((uintptr_t)player + PL_LIBS_BASE != 0) {
|
||||
cls = *(void **)AT(PTR(player, PL_LIBS_BASE + (intptr_t)I8(def, 1) * (intptr_t)sizeof(void *)),
|
||||
(uintptr_t)U16(def, 2) * sizeof(void *));
|
||||
} else {
|
||||
cls = NULL;
|
||||
}
|
||||
if (cls != NULL) {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
void *wk1 = PTR(ctx, CM_AS3_WK1);
|
||||
void *wk2 = PTR(ctx, CM_AS3_WK2);
|
||||
void *walk = cls;
|
||||
while (walk != NULL && walk != wk1 && walk != wk2) {
|
||||
walk = PTR(walk, CM_AS3_SUPER);
|
||||
}
|
||||
U8(movie, MV_BB) &= (uint8_t)~0x20;
|
||||
U8(movie, MV_BB) |= (uint8_t)(walk == wk1 ? 0x20 : 0);
|
||||
}
|
||||
if (PTR(movie, CM_SLOT_B) != NULL) {
|
||||
swf_advance_dlist_GC(player, movie, 1, (uint32_t)p3, p4);
|
||||
}
|
||||
}
|
||||
if (p3 == 0) {
|
||||
make_null_object_bare_GC(player, movie);
|
||||
}
|
||||
for (void *child = PTR(movie, MV_FIRSTCHILD); child != NULL; child = PTR(child, MV_NEXT)) {
|
||||
if (I8(child, MV_TYPE) == 7) {
|
||||
if ((U8(child, MV_B9) & 8) != 0 && PTR(player, PL_AS3VM) != NULL) {
|
||||
if (PTR(movie, MV_AS3VAL) == NULL) {
|
||||
as3vm_get_movie_as3value_GC(player, movie);
|
||||
}
|
||||
as3vm_set_property_toplevel(PTR(player, PL_AS3VM),
|
||||
*(void **)PTR(movie, MV_AS3VAL),
|
||||
PTR(child, CM_NAME),
|
||||
*(void **)PTR(child, MV_AS3VAL));
|
||||
}
|
||||
} else if (p3 == 0 || (U8(child, MV_FLAG1) & 1) != 0) {
|
||||
create_from_null_GC(player, child, p3, p4);
|
||||
}
|
||||
}
|
||||
if (p3 == 0) {
|
||||
bind_bare_object(player, movie);
|
||||
U8(movie, MV_B9) &= (uint8_t)~0x20;
|
||||
U8(movie, MV_B9) |= (uint8_t)((p4 & 1) << 5);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:888-1102 (the movie constructor; vita ~2769-3157). CM_SLOT_A/CM_SLOT_B alias
|
||||
* the same movie bytes as create_buttonrecord_movie_GC's cxform/matrix region for
|
||||
* non-shape movies -- see the offset table above. */
|
||||
static void *create_movie_GC(void *player, void *def, void *p3, int p4, void *name) {
|
||||
(void)p3;
|
||||
void *movie = iggy_malloc_fileline(player, 0, 0x1a0, 0x14, iggy_swf_play_source_path, 0x617);
|
||||
I32(player, CM_OBJCOUNT_A) = I32(player, CM_OBJCOUNT_A) + 1;
|
||||
I32(player, CM_OBJCOUNT_B) = I32(player, CM_OBJCOUNT_B) + 1;
|
||||
memset(movie, 0, 0x1a0);
|
||||
U8(movie, MV_B9) |= 0x41;
|
||||
U8(movie, 0) &= 0xfe;
|
||||
U8(movie, MV_BA) |= 0x70;
|
||||
U8(movie, MV_FLAG1) |= 1;
|
||||
U8(movie, 0xc4) = 0xff; U8(movie, 0xc5) = 0xff; U8(movie, 0xc6) = 0xff; U8(movie, 0xc7) = 0xff;
|
||||
U8(movie, 0x170) = 0xff; U8(movie, 0x171) = 0xff; U8(movie, 0x172) = 0xff; U8(movie, 0x173) = 0xff;
|
||||
U8(movie, 0x110) = 0xff; U8(movie, 0x111) = 0xff;
|
||||
U8(movie, 0x114) = 0xff; U8(movie, 0x115) = 0xff; U8(movie, 0x116) = 0xff; U8(movie, 0x117) = 0xff;
|
||||
U8(movie, 0xd8) = 0; U8(movie, 0xd9) = 0; U8(movie, 0xda) = 0x80; U8(movie, 0xdb) = 0x3f;
|
||||
U8(movie, 0xdc) = 0; U8(movie, 0xdd) = 0; U8(movie, 0xde) = 0; U8(movie, 0xdf) = 0;
|
||||
U8(movie, 0xe0) = 0; U8(movie, 0xe1) = 0; U8(movie, 0xe2) = 0; U8(movie, 0xe3) = 0;
|
||||
U8(movie, 0xe4) = 0; U8(movie, 0xe5) = 0; U8(movie, 0xe6) = 0x80; U8(movie, 0xe7) = 0x3f;
|
||||
PTR(movie, CM_DEF) = def;
|
||||
{
|
||||
void *icon = IGGY_NULLUNDEF_UNDEF;
|
||||
uint32_t nstates = 0;
|
||||
U8(movie, 0x98) = 0; U8(movie, 0x99) = 0; U8(movie, 0x9a) = 0; U8(movie, 0x9b) = 0;
|
||||
U8(movie, 0x9c) = 0; U8(movie, 0x9d) = 0; U8(movie, 0x9e) = 0; U8(movie, 0x9f) = 0;
|
||||
U8(movie, MV_TYPE) = *(uint8_t *)def;
|
||||
PTR(movie, CM_NAME) = name;
|
||||
U8(movie, MV_B9) = (uint8_t)((U8(movie, MV_B9) & ~8u) | (uint8_t)(name != NULL ? 8u : 0u));
|
||||
U8(movie, 0xe8) = 0; U8(movie, 0xe9) = 0; U8(movie, 0xea) = 0; U8(movie, 0xeb) = 0;
|
||||
U8(movie, 0xec) = 0; U8(movie, 0xed) = 0; U8(movie, 0xee) = 0; U8(movie, 0xef) = 0;
|
||||
U8(movie, MV_BB) &= (uint8_t)~0x20;
|
||||
U8(movie, 0x88) = 0; U8(movie, 0x89) = 0; U8(movie, 0x8a) = 0; U8(movie, 0x8b) = 0;
|
||||
U8(movie, 0x8c) = 0; U8(movie, 0x8d) = 0; U8(movie, 0x8e) = 0; U8(movie, 0x8f) = 0;
|
||||
iggy_add_to_unparented(player, movie);
|
||||
|
||||
uint8_t type = U8(movie, MV_TYPE);
|
||||
if (type == 3) {
|
||||
void *tag = PTR(movie, CM_DEF);
|
||||
uint16_t tcount = U16(tag, CM_TAG_COUNT);
|
||||
nstates = tcount;
|
||||
#if IGGY_PTR64
|
||||
*(uint64_t *)AT(movie, CM_SLOT_B) = *(uint64_t *)AT(tag, CM_TAG_SLOTSRC);
|
||||
*(uint64_t *)AT(movie, CM_SLOT_A) = *(uint64_t *)AT(tag, CM_TAG_SLOTSRC);
|
||||
#else
|
||||
*(uint32_t *)AT(movie, CM_SLOT_B) = *(uint32_t *)AT(tag, CM_TAG_SLOTSRC);
|
||||
*(uint32_t *)AT(movie, CM_SLOT_A) = *(uint32_t *)AT(tag, CM_TAG_SLOTSRC);
|
||||
#endif
|
||||
int8_t tflag1 = I8(tag, 1);
|
||||
if (tflag1 < 0) {
|
||||
icon = PTR(tag, CM_TAG_ICON);
|
||||
}
|
||||
PTR(movie, CM_ICON_FIELD) = icon;
|
||||
|
||||
void *cls;
|
||||
if (tflag1 < 0) {
|
||||
cls = PTR(tag, MV_CLASSPTR);
|
||||
} else if ((uintptr_t)player + PL_LIBS_BASE != 0) {
|
||||
cls = *(void **)AT(PTR(player, PL_LIBS_BASE + (intptr_t)tflag1 * (intptr_t)sizeof(void *)),
|
||||
(uintptr_t)U16(tag, 2) * sizeof(void *));
|
||||
} else {
|
||||
cls = NULL;
|
||||
}
|
||||
if (cls == NULL) {
|
||||
U8(movie, MV_BB) |= 0x20;
|
||||
} else {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
void *wk1 = PTR(ctx, CM_AS3_WK1);
|
||||
void *wk2 = PTR(ctx, CM_AS3_WK2);
|
||||
void *walk = cls;
|
||||
while (walk != NULL && walk != wk1 && walk != wk2) {
|
||||
walk = PTR(walk, CM_AS3_SUPER);
|
||||
}
|
||||
U8(movie, MV_BB) &= (uint8_t)~0x20;
|
||||
U8(movie, MV_BB) |= (uint8_t)(walk == wk1 ? 0x20 : 0);
|
||||
}
|
||||
|
||||
void *cached = PTR(tag, CM_TAG_CACHED);
|
||||
if (cached != NULL) {
|
||||
U8(movie, MV_FLAG1) |= 1;
|
||||
#if IGGY_PTR64
|
||||
*(uint64_t *)AT(movie, 0x118) = *(uint64_t *)AT(cached, 0);
|
||||
*(uint64_t *)AT(movie, 0x120) = *(uint64_t *)AT(cached, 8);
|
||||
#else
|
||||
*(uint32_t *)AT(movie, 0xc0) = *(uint32_t *)AT(cached, 0);
|
||||
*(uint32_t *)AT(movie, 0xc4) = *(uint32_t *)AT(cached, 4);
|
||||
*(uint32_t *)AT(movie, 0xc8) = *(uint32_t *)AT(cached, 8);
|
||||
*(uint32_t *)AT(movie, 0xcc) = *(uint32_t *)AT(cached, 12);
|
||||
#endif
|
||||
}
|
||||
if (tcount == 0) goto set_defaults;
|
||||
} else if (type == 6) {
|
||||
void *tag = PTR(movie, CM_DEF);
|
||||
void *text = PTR(tag, CM_TEXT_SRC);
|
||||
if (text == NULL) {
|
||||
iggy_init_textfield(player, movie, NULL, 0);
|
||||
} else {
|
||||
int len = rrwcslen(text);
|
||||
iggy_init_textfield(player, movie, text, len);
|
||||
}
|
||||
goto set_defaults;
|
||||
} else if (type == 7) {
|
||||
nstates = 4;
|
||||
#if IGGY_PTR64
|
||||
*(uint64_t *)AT(movie, CM_SLOT_B) = 0;
|
||||
*(uint64_t *)AT(movie, CM_SLOT_A) = 0;
|
||||
#else
|
||||
*(uint32_t *)AT(movie, CM_SLOT_B) = 0;
|
||||
*(uint32_t *)AT(movie, CM_SLOT_A) = 0;
|
||||
#endif
|
||||
} else {
|
||||
goto set_defaults;
|
||||
}
|
||||
|
||||
{
|
||||
void *arr = iggy_malloc_fileline(player, 0, (size_t)nstates * sizeof(void *), 0x13,
|
||||
iggy_swf_play_source_path, 0x667);
|
||||
U32(movie, MV_BUTTONCOUNT) = nstates;
|
||||
PTR(movie, MV_BUTTONSTATES) = arr;
|
||||
for (uint32_t i = 0; i < nstates; i++) {
|
||||
*(void **)AT(arr, (intptr_t)i * (intptr_t)sizeof(void *)) = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
set_defaults:
|
||||
iggy_set_movie_defaults(movie);
|
||||
if (U8(movie, MV_TYPE) == 7) {
|
||||
initialize_button_GC(player, movie, PTR(movie, CM_DEF));
|
||||
U8(movie, CM_BUTTONFLAG) = 1;
|
||||
U8(movie, CM_BUTTONFLAG2) = 0;
|
||||
iggy_update_button(player, movie);
|
||||
}
|
||||
if (p4 == 0) {
|
||||
null_object(player, movie);
|
||||
if (U8(movie, MV_TYPE) == 7) {
|
||||
make_null_object_bare_GC(player, movie);
|
||||
}
|
||||
}
|
||||
return movie;
|
||||
}
|
||||
|
||||
/* raw:1103-1128 (vita inlines this into iggy_finish_creating_movie_GC, ~2255-2319). */
|
||||
static void create_movie_finish(void *player, void *movie) {
|
||||
if ((U8(movie, MV_FLAG1) & 1) == 0) {
|
||||
U8(movie, MV_FLAG1) &= (uint8_t)~1;
|
||||
return;
|
||||
}
|
||||
if (PTR(movie, MV_AS3VAL) != NULL) {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
void *old = *(void **)PTR(movie, MV_AS3VAL);
|
||||
as3vm_pool_free(ctx, PTR(movie, MV_AS3VAL));
|
||||
PTR(movie, MV_AS3VAL) = as3vm_pool_alloc(ctx, old, 1);
|
||||
iggy_mark_movie_dirty(player, movie);
|
||||
}
|
||||
U8(movie, MV_FLAG1) &= (uint8_t)~1;
|
||||
}
|
||||
|
||||
/* raw:1834-1862 (vita ~7084-7111). */
|
||||
static void finish_creating_children(void *player, void *movie, uint32_t p3, uint32_t p4) {
|
||||
if (I8(movie, MV_TYPE) == 7) {
|
||||
void *states = PTR(movie, MV_BUTTONSTATES);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
void *state = *(void **)AT(states, (intptr_t)i * (intptr_t)sizeof(void *));
|
||||
if (state != NULL) {
|
||||
iggy_finish_creating_movie_GC(player, state, p3, NULL, p4);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (void *child = PTR(movie, MV_FIRSTCHILD); child != NULL; child = PTR(child, MV_NEXT)) {
|
||||
iggy_finish_creating_movie_GC(player, child, p3, NULL, p4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:2315-2363 (vita ~1297-1331). */
|
||||
void iggy_create_empty_bitmap(void *player, void *tag) {
|
||||
if (tag == NULL || *(uint8_t *)tag != 4) {
|
||||
tag = iggy_malloc_fileline(player, 0, CM_BITMAP_ALLOC, 0x15, iggy_swf_play_source_path, 0x400);
|
||||
memset(tag, 0, CM_BITMAP_ALLOC);
|
||||
*(uint8_t *)tag = 4;
|
||||
*((uint8_t *)tag + 1) = U8(player, CM_BITMAP_QUALITY);
|
||||
}
|
||||
iggy_create_movie_for_actionscript_object(player, tag);
|
||||
}
|
||||
|
||||
/* raw:2364-2391 (vita ~3162-3175). */
|
||||
int64_t iggy_create_movie_complete_GC(void *player, void *p2, void *p3, uint32_t p4) {
|
||||
void *movie = create_movie_GC(player, p2, NULL, 0, NULL);
|
||||
create_from_null_GC(player, movie, 0, 0);
|
||||
finish_creating_children(player, movie, 0, 0);
|
||||
if ((U8(movie, MV_FLAG1) & 1) != 0) {
|
||||
make_bare_object_constructed(player, movie, p3, p4);
|
||||
create_movie_finish(player, movie);
|
||||
if ((U8(movie, MV_B9) & 0x20) != 0 && PTR(player, PL_AS3VM) != NULL) {
|
||||
I16(movie, MV_EVENTDEPTH) += 1;
|
||||
U8(movie, MV_B9) &= (uint8_t)~0x20;
|
||||
as3vm_do_displayobject_event_GC(PTR(player, PL_AS3VM), movie, 7, 1);
|
||||
I16(movie, MV_EVENTDEPTH) -= 1;
|
||||
}
|
||||
}
|
||||
return (int64_t)(intptr_t)movie;
|
||||
}
|
||||
|
||||
/* raw:2392-2467 (vita ~1184-1251). Runtime-harness-overridable export (see the
|
||||
* IGGY_EXPORT_OVERRIDABLE contract note in swf_play.c). */
|
||||
IGGY_EXPORT_OVERRIDABLE void *iggy_create_movie_for_actionscript_object(void *player, void *object) {
|
||||
void *movie = iggy_malloc_fileline(player, 0, 0x1a0, 0x14, iggy_swf_play_source_path, 0x3ce);
|
||||
I32(player, CM_OBJCOUNT_A) = I32(player, CM_OBJCOUNT_A) + 1;
|
||||
I32(player, CM_OBJCOUNT_B) = I32(player, CM_OBJCOUNT_B) + 1;
|
||||
memset(movie, 0, 0x1a0);
|
||||
U8(movie, MV_B9) |= 0x41;
|
||||
U8(movie, 0) &= 0xfe;
|
||||
U8(movie, MV_BA) |= 0x70;
|
||||
U8(movie, 0xc4) = 0xff; U8(movie, 0xc5) = 0xff; U8(movie, 0xc6) = 0xff; U8(movie, 0xc7) = 0xff;
|
||||
U8(movie, 0x170) = 0xff; U8(movie, 0x171) = 0xff; U8(movie, 0x172) = 0xff; U8(movie, 0x173) = 0xff;
|
||||
U8(movie, 0x110) = 0xff; U8(movie, 0x111) = 0xff;
|
||||
U8(movie, 0x114) = 0xff; U8(movie, 0x115) = 0xff; U8(movie, 0x116) = 0xff; U8(movie, 0x117) = 0xff;
|
||||
U8(movie, 0xd8) = 0; U8(movie, 0xd9) = 0; U8(movie, 0xda) = 0x80; U8(movie, 0xdb) = 0x3f;
|
||||
U8(movie, 0xdc) = 0; U8(movie, 0xdd) = 0; U8(movie, 0xde) = 0; U8(movie, 0xdf) = 0;
|
||||
U8(movie, 0xe0) = 0; U8(movie, 0xe1) = 0; U8(movie, 0xe2) = 0; U8(movie, 0xe3) = 0;
|
||||
U8(movie, 0xe4) = 0; U8(movie, 0xe5) = 0; U8(movie, 0xe6) = 0x80; U8(movie, 0xe7) = 0x3f;
|
||||
PTR(movie, CM_DEF) = object;
|
||||
PTR(movie, CM_ICON_FIELD) = IGGY_NULLUNDEF_UNDEF;
|
||||
if (object != NULL) {
|
||||
U8(movie, MV_TYPE) = *(uint8_t *)object;
|
||||
}
|
||||
iggy_set_movie_defaults(movie);
|
||||
memset(AT(movie, MV_PARENT), 0, 2 * sizeof(void *));
|
||||
iggy_add_to_unparented(player, movie);
|
||||
return movie;
|
||||
}
|
||||
|
||||
/* raw:3049-3068 (vita fully inlines finish_creating_children + make_bare_object_
|
||||
* constructed + create_movie_finish here, ~2239-2339, confirming every offset below). */
|
||||
void iggy_finish_creating_movie_GC(void *player, void *movie, uint32_t p3, void *p4, uint32_t p5) {
|
||||
/* RESIDUAL: durango/vita both show finish_creating_children() called here with
|
||||
* (durango: zero, vita: 3 of its 4) args elided; register/stack state is already
|
||||
* this function's own (player, movie, p3, p5) unchanged, which is the recovery used. */
|
||||
finish_creating_children(player, movie, p3, p5);
|
||||
if ((U8(movie, MV_FLAG1) & 1) != 0) {
|
||||
make_bare_object_constructed(player, movie, p4, p5);
|
||||
create_movie_finish(player, movie);
|
||||
if ((U8(movie, MV_B9) & 0x20) != 0) {
|
||||
iggy_insert_movie_messages_GC(player, movie, p3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:3445-3492 (vita ~3540-3569). CM_ROOT is verified independently by
|
||||
* swf_playhead.c's own PL_ROOTMOVIE derivation -- see RESIDUALS. */
|
||||
void iggy_initialized_main_movie_GC(void *player) {
|
||||
if (PTR(player, PL_AS3VM) != NULL) {
|
||||
iggy_initialize_main_timeline_3d(player);
|
||||
}
|
||||
int count = I32(player, CM_MAIN_FRAMECOUNT);
|
||||
void *arr = iggy_malloc_fileline(player, 0, (size_t)count * sizeof(void *), 0x13,
|
||||
iggy_swf_play_source_path, 0xa5c);
|
||||
PTR(player, CM_FSCRIPT_BASE) = arr;
|
||||
I32(player, CM_FSCRIPT_COUNT) = count;
|
||||
for (int i = 0; i < count; i++) {
|
||||
*(void **)AT(arr, (intptr_t)i * (intptr_t)sizeof(void *)) = NULL;
|
||||
}
|
||||
void *root = AT(player, CM_ROOT);
|
||||
swf_advance_dlist_GC(player, root, 0, 0, 1);
|
||||
finish_creating_children(player, root, 1, 0);
|
||||
if ((U8(root, MV_FLAG1) & 1) != 0) {
|
||||
make_bare_object_constructed(player, root, NULL, 0);
|
||||
create_movie_finish(player, root);
|
||||
if ((U8(root, MV_B9) & 0x20) != 0) {
|
||||
iggy_insert_movie_messages_GC(player, root, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:4849-4919 (vita inlines this identically into iggy_finish_creating_movie_GC,
|
||||
* ~2267-2306; the two "resolve the tag's class" computations in the durango body are
|
||||
* provably identical pure reads, collapsed to one `cls` reused for both). */
|
||||
static void make_bare_object_constructed(void *player, void *movie, void *p3, uint32_t p4) {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
if (ctx == NULL) return;
|
||||
if ((U8(movie, MV_B9) & 8) == 0) {
|
||||
void *def = PTR(movie, CM_DEF);
|
||||
if (*(uint8_t *)def == 4) return;
|
||||
void *cls0;
|
||||
if (I8(def, 1) < 0) {
|
||||
cls0 = PTR(def, MV_CLASSPTR);
|
||||
} else {
|
||||
if ((uintptr_t)player + PL_LIBS_BASE == 0) return;
|
||||
cls0 = *(void **)AT(PTR(player, PL_LIBS_BASE + (intptr_t)I8(def, 1) * (intptr_t)sizeof(void *)),
|
||||
(uintptr_t)U16(def, 2) * sizeof(void *));
|
||||
}
|
||||
if (cls0 == NULL) return;
|
||||
}
|
||||
{
|
||||
void *def = PTR(movie, CM_DEF);
|
||||
void *cls;
|
||||
if (I8(def, 1) < 0) {
|
||||
cls = PTR(def, MV_CLASSPTR);
|
||||
} else if ((uintptr_t)player + PL_LIBS_BASE != 0) {
|
||||
cls = *(void **)AT(PTR(player, PL_LIBS_BASE + (intptr_t)I8(def, 1) * (intptr_t)sizeof(void *)),
|
||||
(uintptr_t)U16(def, 2) * sizeof(void *));
|
||||
} else {
|
||||
cls = NULL;
|
||||
}
|
||||
if (cls != NULL) {
|
||||
void *saved = PTR(ctx, CM_AS3_CTORCTX);
|
||||
PTR(ctx, CM_AS3_CTORCTX) = movie;
|
||||
as3vm_construct_post_GC(ctx, PTR(movie, MV_AS3VAL), *(void **)AT(cls, CM_CLASS_CTOR), p3, p4);
|
||||
PTR(ctx, CM_AS3_CTORCTX) = saved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:4920-4980 (vita ~2404-2459). */
|
||||
static void make_null_object_bare_GC(void *player, void *movie) {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
if (ctx == NULL) return;
|
||||
if ((U8(movie, MV_B9) & 8) == 0) {
|
||||
void *def = PTR(movie, CM_DEF);
|
||||
if (*(uint8_t *)def == 4) return;
|
||||
void *cls0;
|
||||
if (I8(def, 1) < 0) {
|
||||
cls0 = PTR(def, MV_CLASSPTR);
|
||||
} else {
|
||||
if ((uintptr_t)player + PL_LIBS_BASE == 0) return;
|
||||
cls0 = *(void **)AT(PTR(player, PL_LIBS_BASE + (intptr_t)I8(def, 1) * (intptr_t)sizeof(void *)),
|
||||
(uintptr_t)U16(def, 2) * sizeof(void *));
|
||||
}
|
||||
if (cls0 == NULL) return;
|
||||
}
|
||||
{
|
||||
void *def = PTR(movie, CM_DEF);
|
||||
void *cls2;
|
||||
if (I8(def, 1) < 0) {
|
||||
cls2 = PTR(def, MV_CLASSPTR);
|
||||
} else if ((uintptr_t)player + PL_LIBS_BASE != 0) {
|
||||
cls2 = *(void **)AT(PTR(player, PL_LIBS_BASE + (intptr_t)I8(def, 1) * (intptr_t)sizeof(void *)),
|
||||
(uintptr_t)U16(def, 2) * sizeof(void *));
|
||||
} else {
|
||||
cls2 = NULL;
|
||||
}
|
||||
void *val;
|
||||
if (cls2 == NULL) {
|
||||
val = as3vm_construct_swf_type_GC(ctx, *(uint8_t *)def, movie);
|
||||
} else {
|
||||
val = as3vm_construct_pre_GC(ctx, *(void **)AT(cls2, CM_CLASS_CTOR));
|
||||
}
|
||||
*(void **)PTR(movie, MV_AS3VAL) = val;
|
||||
iggy_mark_movie_dirty(player, movie);
|
||||
PTR(val, AS3VAL_OWNER) = movie;
|
||||
PTR(val, AS3VAL_CLEAR) = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:4981-5016 (vita ~5361-5399). */
|
||||
static uint64_t movie_is_entirely_unreferenced(void *player, void *movie) {
|
||||
void *as3val = PTR(movie, MV_AS3VAL);
|
||||
if ((as3val == NULL || *(intptr_t *)as3val == 7) &&
|
||||
(U8(movie, MV_FLAG1) & 1) == 0 &&
|
||||
I16(movie, MV_EVENTDEPTH) == 0) {
|
||||
if (I8(movie, MV_TYPE) == 7) {
|
||||
void *states = PTR(movie, MV_BUTTONSTATES);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
void *state = *(void **)AT(states, (intptr_t)i * (intptr_t)sizeof(void *));
|
||||
if (state != NULL && movie_is_entirely_unreferenced(player, state) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (void *child = PTR(movie, MV_FIRSTCHILD); child != NULL; child = PTR(child, MV_NEXT)) {
|
||||
if (movie_is_entirely_unreferenced(player, child) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:5017-5056 (vita inlines this into create_movie_GC, ~3128-3151). */
|
||||
static void null_object(void *player, void *movie) {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
if (ctx == NULL) return;
|
||||
if ((U8(movie, MV_B9) & 8) == 0) {
|
||||
void *def = PTR(movie, CM_DEF);
|
||||
if (*(uint8_t *)def == 4) return;
|
||||
void *cls;
|
||||
if (I8(def, 1) < 0) {
|
||||
cls = PTR(def, MV_CLASSPTR);
|
||||
} else {
|
||||
if ((uintptr_t)player + PL_LIBS_BASE == 0) return;
|
||||
cls = *(void **)AT(PTR(player, PL_LIBS_BASE + (intptr_t)I8(def, 1) * (intptr_t)sizeof(void *)),
|
||||
(uintptr_t)U16(def, 2) * sizeof(void *));
|
||||
}
|
||||
if (cls == NULL) return;
|
||||
}
|
||||
PTR(movie, MV_AS3VAL) = as3vm_pool_alloc(ctx, IGGY_NULLUNDEF_NULL, 0);
|
||||
iggy_mark_movie_dirty(player, movie);
|
||||
}
|
||||
228
iggy-decompiled/src/reconstructed/swf_play_framescript.inc
Normal file
228
iggy-decompiled/src/reconstructed/swf_play_framescript.inc
Normal file
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* swf_play_framescript.inc -- the frame-script (onEnterFrame-adjacent AS3
|
||||
* "run this frame's actions") engine: registering a compiled script for a
|
||||
* frame of the main timeline, running a single movie's current-frame (or
|
||||
* frame-label-node) script, recursing that across a movie's descendants, and
|
||||
* the top-level per-tick driver that keeps re-running until no movie is left
|
||||
* dirty and the seek queue is empty.
|
||||
*
|
||||
* durango raw line ranges (authoritative for structure):
|
||||
* iggy_play_framescript 3783-3828 (export)
|
||||
* iggy_play_framescripts 3829-3889 (export)
|
||||
* iggy_play_framescripts_complete 3890-3925 (export)
|
||||
* iggy_add_movie_framescript 2131-2159 (export)
|
||||
*
|
||||
* 32-bit offsets derived from raw/vita/swf_play.c; every offset and every
|
||||
* Ghidra-elided call argument here was cross-checked against the retail
|
||||
* durango object (llvm-objdump -d -r --disassemble-symbols=<fn>
|
||||
* work/iggy-native-decomp/durango-objects/swf_play.obj).
|
||||
*/
|
||||
|
||||
/* -- fields local to this unit (width-gated). MV_B9, MVD_178 and the top-level
|
||||
* PL_AS3VM / PL_ROOT / PL_STAGE / PL_FRAMESCRIPT_FLAG / TM_HOOK_* macros are
|
||||
* already in scope (swf_play.c / swf_play_movie.inc) and reused unchanged. -- */
|
||||
#if IGGY_PTR64
|
||||
#undef PL_FRAMECOUNT
|
||||
# define PL_FRAMECOUNT 0x68 /* i32: main-timeline frame count. */
|
||||
#undef FS_CTX_ARRAY
|
||||
# define FS_CTX_ARRAY 8 /* as3vm ctx: ptr per-frame script array. */
|
||||
#undef FS_CTX_CAP
|
||||
# define FS_CTX_CAP 0x10 /* as3vm ctx: i32 script-array capacity. */
|
||||
#undef FS_CTX_GCPTR
|
||||
# define FS_CTX_GCPTR 0x40 /* as3vm ctx: ptr to GC nursery bump pointer. */
|
||||
#undef AS3VMCTX_UNCAUGHT
|
||||
# define AS3VMCTX_UNCAUGHT 0x2908 /* as3vm ctx: i32 uncaught-exception flag. */
|
||||
#undef MV_CURFRAME
|
||||
# define MV_CURFRAME 0x170 /* movie: i32 current frame index. */
|
||||
#undef MV_FSLABELLIST
|
||||
# define MV_FSLABELLIST 0x50 /* movie: ptr frame-label-node list head. */
|
||||
#undef FS_NODE_DATA
|
||||
# define FS_NODE_DATA 8 /* label node: ptr-to-ptr function slot. */
|
||||
#undef FS_NODE_NEXT
|
||||
# define FS_NODE_NEXT 0x10 /* label node: ptr next. */
|
||||
#else
|
||||
#undef PL_FRAMECOUNT
|
||||
# define PL_FRAMECOUNT 0x58
|
||||
#undef FS_CTX_ARRAY
|
||||
# define FS_CTX_ARRAY 4
|
||||
#undef FS_CTX_CAP
|
||||
# define FS_CTX_CAP 8
|
||||
#undef FS_CTX_GCPTR
|
||||
# define FS_CTX_GCPTR 0x28
|
||||
#undef AS3VMCTX_UNCAUGHT
|
||||
# define AS3VMCTX_UNCAUGHT 0x16e8
|
||||
#undef MV_CURFRAME
|
||||
# define MV_CURFRAME 0x100
|
||||
#undef MV_FSLABELLIST
|
||||
# define MV_FSLABELLIST 0x2c
|
||||
#undef FS_NODE_DATA
|
||||
# define FS_NODE_DATA 4
|
||||
#undef FS_NODE_NEXT
|
||||
# define FS_NODE_NEXT 8
|
||||
#endif
|
||||
#undef FS_NODE_LABEL
|
||||
#define FS_NODE_LABEL 0 /* label node: i32 frame-label index (both widths). */
|
||||
|
||||
/* raw:2131-2159 (objdump-confirmed). Register `script` to run when the main
|
||||
* timeline reaches `frame`, growing/zeroing the as3vm ctx's per-frame script
|
||||
* array on first use and running the GC write barrier when the stored
|
||||
* pointer crosses into the young generation. */
|
||||
void iggy_add_movie_framescript(void *player, int frame, void *script) {
|
||||
if (frame < 0) {
|
||||
return;
|
||||
}
|
||||
int32_t framecount = I32(player, PL_FRAMECOUNT);
|
||||
if (frame >= framecount) {
|
||||
return;
|
||||
}
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
if (ctx == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PTR(ctx, FS_CTX_ARRAY) == NULL) {
|
||||
I32(ctx, FS_CTX_CAP) = framecount;
|
||||
void *arr =
|
||||
iggy_arena_malloc(player, 0, (size_t)framecount * sizeof(void *), 0xb9);
|
||||
PTR(ctx, FS_CTX_ARRAY) = arr;
|
||||
memset(arr, 0, (size_t)I32(ctx, FS_CTX_CAP) * sizeof(void *));
|
||||
}
|
||||
((void **)PTR(ctx, FS_CTX_ARRAY))[frame] = script;
|
||||
if (((uintptr_t)script & 3) == 1 && script != (void *)(uintptr_t)0x7) {
|
||||
uint8_t *gcptr = *(uint8_t **)AT(ctx, FS_CTX_GCPTR);
|
||||
if ((uint8_t)(~(*(uint8_t *)script) & *gcptr) > 0x17) {
|
||||
as3vm_write_barrier_slowpath(ctx, gcptr - 1, (uint8_t *)script - 1);
|
||||
}
|
||||
}
|
||||
((void **)PTR(ctx, FS_CTX_ARRAY))[frame] = script;
|
||||
}
|
||||
|
||||
/* raw:3783-3828 (objdump-confirmed). Run a single movie's applicable
|
||||
* frame-script: for the root/stage movie this indexes the as3vm ctx's
|
||||
* per-frame script array by the movie's current frame; for any other movie it
|
||||
* walks the movie's frame-label-node list looking for the node whose label
|
||||
* matches (frame-1). MV_B9 bit 0x02 is toggled on entry and (if execution did
|
||||
* not short-circuit before the toggle) again on exit -- a reentrancy marker,
|
||||
* not a conditional flag (both toggle expressions reduce algebraically, and
|
||||
* disassemble, to an unconditional `^= 2`). */
|
||||
void iggy_play_framescript(void *player, void *movie) {
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
void *fn = NULL;
|
||||
if (ctx == NULL) {
|
||||
return;
|
||||
}
|
||||
if (movie == AT(player, PL_ROOT)) {
|
||||
U8(movie, MV_B9) ^= 2;
|
||||
ctx = PTR(player, PL_AS3VM);
|
||||
if (PTR(ctx, FS_CTX_ARRAY) == NULL) {
|
||||
goto done;
|
||||
}
|
||||
if (I32(ctx, FS_CTX_CAP) <= I32(movie, MV_CURFRAME)) {
|
||||
goto done;
|
||||
}
|
||||
fn = ((void **)PTR(ctx, FS_CTX_ARRAY))[I32(movie, MV_CURFRAME)];
|
||||
if (fn == NULL) {
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
void *node = PTR(movie, MV_FSLABELLIST);
|
||||
if (node == NULL) {
|
||||
return;
|
||||
}
|
||||
while (I32(node, FS_NODE_LABEL) != I32(movie, MVD_178) - 1) {
|
||||
node = PTR(node, FS_NODE_NEXT);
|
||||
if (node == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
U8(movie, MV_B9) ^= 2;
|
||||
ctx = PTR(player, PL_AS3VM);
|
||||
fn = PTR(PTR(node, FS_NODE_DATA), 0);
|
||||
}
|
||||
as3vm_RunFunction(ctx, fn);
|
||||
done:
|
||||
U8(movie, MV_B9) ^= 2;
|
||||
}
|
||||
|
||||
/* raw:3829-3889 (objdump-confirmed). Run `movie`'s own frame-script (honoring
|
||||
* its "stop count" -- the same byte offset as the shape scale-y default,
|
||||
* MVD_17C, reused as a sprite-only decrementing counter) and, if no uncaught
|
||||
* exception is now pending, recurse across its children -- the fixed
|
||||
* 4-iteration depth-array walk for sprite (type 7) movies, or the plain
|
||||
* sibling list otherwise. */
|
||||
void iggy_play_framescripts(void *player, void *movie) {
|
||||
if (PTR(player, PL_AS3VM) == NULL) {
|
||||
return;
|
||||
}
|
||||
if (I32(movie, MVD_17C) == 0) {
|
||||
if ((U8(movie, MV_FLAG1) & 2) == 0) {
|
||||
goto after_own_script;
|
||||
}
|
||||
} else {
|
||||
I32(movie, MVD_17C) = I32(movie, MVD_17C) - 1;
|
||||
}
|
||||
U8(movie, MV_FLAG1) &= 0xfd;
|
||||
iggy_play_framescript(player, movie);
|
||||
if (I32(PTR(player, PL_AS3VM), AS3VMCTX_UNCAUGHT) != 0) {
|
||||
iggy_uncaught_exception_warning(player);
|
||||
}
|
||||
after_own_script:
|
||||
if (U8(player, PL_FRAMESCRIPT_FLAG + 1) == 0) {
|
||||
if (I8(movie, MV_TYPE) == 7) {
|
||||
void *deptharray = PTR(movie, MV_DEPTHARRAY);
|
||||
for (int idx = 0; idx < 4; idx++) {
|
||||
void *child =
|
||||
*(void **)AT(deptharray, (intptr_t)idx * (intptr_t)sizeof(void *));
|
||||
if (child != NULL && I32(PTR(player, PL_AS3VM), AS3VMCTX_UNCAUGHT) == 0) {
|
||||
iggy_play_framescripts(player, child);
|
||||
if (U8(player, PL_FRAMESCRIPT_FLAG + 1) != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
void *child = PTR(movie, MV_FIRSTCHILD);
|
||||
if (child != NULL) {
|
||||
while (I32(PTR(player, PL_AS3VM), AS3VMCTX_UNCAUGHT) == 0) {
|
||||
iggy_play_framescripts(player, child);
|
||||
child = PTR(child, MV_NEXT);
|
||||
if (U8(player, PL_FRAMESCRIPT_FLAG + 1) != 0) {
|
||||
return;
|
||||
}
|
||||
if (child == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:3890-3925 (objdump-confirmed). Drive iggy_play_framescripts across the
|
||||
* stage repeatedly, flushing the seek queue between passes, until a pass
|
||||
* leaves both the "needs replay" flag clear and the seek queue empty. */
|
||||
void iggy_play_framescripts_complete(void *player) {
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0xb2b, 0, 0);
|
||||
}
|
||||
U8(player, PL_FRAMESCRIPT_FLAG + 1) = 0;
|
||||
if (PTR(player, PL_AS3VM) == NULL) {
|
||||
goto tm_end;
|
||||
}
|
||||
do {
|
||||
iggy_play_framescripts(player, AT(player, PL_STAGE));
|
||||
tm_end:
|
||||
if (U8(player, PL_FRAMESCRIPT_FLAG - 1) == 0) {
|
||||
if (iggy_flush_seek_queue_GC(player) == 0) {
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0xb40);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
U8(player, PL_FRAMESCRIPT_FLAG - 1) = 0;
|
||||
U8(player, PL_FRAMESCRIPT_FLAG + 1) = 0;
|
||||
} while (1);
|
||||
}
|
||||
552
iggy-decompiled/src/reconstructed/swf_play_hittest.inc
Normal file
552
iggy-decompiled/src/reconstructed/swf_play_hittest.inc
Normal file
@@ -0,0 +1,552 @@
|
||||
/*
|
||||
* swf_play_hittest.inc -- point/shape hit-testing core: the recursive point
|
||||
* hit-test walk, the fill/stroke shape scanline test (edge + quadratic-bezier
|
||||
* winding-number accumulation), and is_hit (the mouse-cursor display-tree walk
|
||||
* used by button/sprite mouse-over dispatch). durango raw line ranges cited
|
||||
* per function; 32-bit offsets derived directly from the vita raw (never
|
||||
* halved) and cross-checked against orbis/ps3 where the durango body is
|
||||
* opaque (jump-table dispatch reconstructed as a switch from the vita raw,
|
||||
* whose case bodies are NOT elided).
|
||||
*
|
||||
* Field offsets not already established by swf_play_movie.inc (MV_FLAG1,
|
||||
* MV_TYPE, MV_PARENT, MV_NEXT, MV_PREV, MV_B9, MV_BA, MV_BB, MVD_114) are
|
||||
* defined locally below, width-gated from direct vita raw comparison.
|
||||
*/
|
||||
|
||||
/* -- additional movie-node field offsets used by hit-testing / mouseover. --- */
|
||||
#if IGGY_PTR64
|
||||
#undef MV_FIRSTCHILD
|
||||
# define MV_FIRSTCHILD 0x10 /* ptr: first child (bottom-up z-order). */
|
||||
#undef MV_LASTCHILD
|
||||
# define MV_LASTCHILD 0x90 /* ptr: last child (top-down/front z-order). */
|
||||
#undef MV_XFORM
|
||||
# define MV_XFORM 0xd8 /* 6 floats: local 2x3 transform matrix. */
|
||||
#undef MV_BOUNDS_MINX
|
||||
# define MV_BOUNDS_MINX 0xc8 /* float: cached world bounds, min x. */
|
||||
#undef MV_BOUNDS_MINY
|
||||
# define MV_BOUNDS_MINY 0xcc
|
||||
#undef MV_BOUNDS_MAXX
|
||||
# define MV_BOUNDS_MAXX 0xd0
|
||||
#undef MV_BOUNDS_MAXY
|
||||
# define MV_BOUNDS_MAXY 0xd4
|
||||
#undef MV_SHAPE_FILL
|
||||
# define MV_SHAPE_FILL 0xa8 /* ptr: fill/"hit area" shape (flag 0). */
|
||||
#undef MV_SHAPE_STROKE
|
||||
# define MV_SHAPE_STROKE 0xa0 /* ptr: stroke/mask shape (flag 1). */
|
||||
#undef MV_BOUNDOBJ
|
||||
# define MV_BOUNDOBJ 0x78 /* ptr: bound mask/button-hit movie. */
|
||||
#undef MV_BOUNDROOT
|
||||
# define MV_BOUNDROOT 0x68 /* ptr: bound movie's cached tree root. */
|
||||
#undef MV_DEPTHCOUNT
|
||||
# define MV_DEPTHCOUNT 0xc4 /* int: depth-indexed child-array length. */
|
||||
#undef MV_DEPTHARRAY
|
||||
# define MV_DEPTHARRAY 0x48 /* ptr (via parent): depth-indexed child array.*/
|
||||
#undef MV_LOCALW
|
||||
# define MV_LOCALW 0x130 /* float: bound-object local width (is_hit). */
|
||||
#undef MV_LOCALH
|
||||
# define MV_LOCALH 0x134
|
||||
#undef MV_LOCALOX
|
||||
# define MV_LOCALOX 0x128 /* float: bound-object local origin x. */
|
||||
#undef MV_LOCALOY
|
||||
# define MV_LOCALOY 0x12c
|
||||
/* -- shape sub-struct fields. -- */
|
||||
#undef SHAPE_BBOX_MINX
|
||||
# define SHAPE_BBOX_MINX 0x20
|
||||
#undef SHAPE_BBOX_MINY
|
||||
# define SHAPE_BBOX_MINY 0x24
|
||||
#undef SHAPE_BBOX_MAXX
|
||||
# define SHAPE_BBOX_MAXX 0x28
|
||||
#undef SHAPE_BBOX_MAXY
|
||||
# define SHAPE_BBOX_MAXY 0x2c
|
||||
#undef SHAPE_EDGECOUNT
|
||||
# define SHAPE_EDGECOUNT 0x38 /* short: number of style-groups. */
|
||||
#undef SHAPE_GROUPS
|
||||
# define SHAPE_GROUPS 0x48 /* ptr: style-group array base. */
|
||||
#undef GROUP_STRIDE
|
||||
# define GROUP_STRIDE 0x40
|
||||
#undef GROUP_COUNT
|
||||
# define GROUP_COUNT 0x18 /* int: edge count within a style-group. */
|
||||
#else
|
||||
#undef MV_FIRSTCHILD
|
||||
# define MV_FIRSTCHILD 0x0c
|
||||
#undef MV_LASTCHILD
|
||||
# define MV_LASTCHILD 0x4c
|
||||
#undef MV_XFORM
|
||||
# define MV_XFORM 0x80
|
||||
#undef MV_BOUNDS_MINX
|
||||
# define MV_BOUNDS_MINX 0x70
|
||||
#undef MV_BOUNDS_MINY
|
||||
# define MV_BOUNDS_MINY 0x74
|
||||
#undef MV_BOUNDS_MAXX
|
||||
# define MV_BOUNDS_MAXX 0x78
|
||||
#undef MV_BOUNDS_MAXY
|
||||
# define MV_BOUNDS_MAXY 0x7c
|
||||
#undef MV_SHAPE_FILL
|
||||
# define MV_SHAPE_FILL 0x58
|
||||
#undef MV_SHAPE_STROKE
|
||||
# define MV_SHAPE_STROKE 0x54
|
||||
#undef MV_BOUNDOBJ
|
||||
# define MV_BOUNDOBJ 0x40
|
||||
#undef MV_BOUNDROOT
|
||||
# define MV_BOUNDROOT 0x38
|
||||
#undef MV_DEPTHCOUNT
|
||||
# define MV_DEPTHCOUNT 0x6c
|
||||
#undef MV_DEPTHARRAY
|
||||
# define MV_DEPTHARRAY 0x28
|
||||
#undef MV_LOCALW
|
||||
# define MV_LOCALW 0xd8
|
||||
#undef MV_LOCALH
|
||||
# define MV_LOCALH 0xdc
|
||||
#undef MV_LOCALOX
|
||||
# define MV_LOCALOX 0xd0
|
||||
#undef MV_LOCALOY
|
||||
# define MV_LOCALOY 0xd4
|
||||
#undef SHAPE_BBOX_MINX
|
||||
# define SHAPE_BBOX_MINX 0x10
|
||||
#undef SHAPE_BBOX_MINY
|
||||
# define SHAPE_BBOX_MINY 0x14
|
||||
#undef SHAPE_BBOX_MAXX
|
||||
# define SHAPE_BBOX_MAXX 0x18
|
||||
#undef SHAPE_BBOX_MAXY
|
||||
# define SHAPE_BBOX_MAXY 0x1c
|
||||
#undef SHAPE_EDGECOUNT
|
||||
# define SHAPE_EDGECOUNT 0x24
|
||||
#undef SHAPE_GROUPS
|
||||
# define SHAPE_GROUPS 0x2c
|
||||
#undef GROUP_STRIDE
|
||||
# define GROUP_STRIDE 0x28
|
||||
#undef GROUP_COUNT
|
||||
# define GROUP_COUNT 0x14
|
||||
#endif
|
||||
/* Edge-record layout is identical both widths (no pointer fields): stride
|
||||
* 0x18, x/y/cx/cy floats then a type byte and two style-index shorts. */
|
||||
#undef GROUP_EDGESPTR
|
||||
#define GROUP_EDGESPTR 0x10
|
||||
#undef EDGE_STRIDE
|
||||
#define EDGE_STRIDE 0x18
|
||||
#undef EDGE_X
|
||||
#define EDGE_X 0x00
|
||||
#undef EDGE_Y
|
||||
#define EDGE_Y 0x04
|
||||
#undef EDGE_CX
|
||||
#define EDGE_CX 0x08
|
||||
#undef EDGE_CY
|
||||
#define EDGE_CY 0x0c
|
||||
#undef EDGE_TYPE
|
||||
#define EDGE_TYPE 0x10
|
||||
#undef EDGE_STYLE_A
|
||||
#define EDGE_STYLE_A 0x12
|
||||
#undef EDGE_STYLE_B
|
||||
#define EDGE_STYLE_B 0x14
|
||||
|
||||
/* MV_BUTTONREC / MV_TFOBJ / MV_TFOBJ2 are read only from is_hit's/
|
||||
* do_mouseover's opaque durango jump-table case bodies (types 4 and 7); only
|
||||
* the vita raw shows their real bodies (0001406a / 00014314), and the same
|
||||
* numeric offset is used for both widths below as a residual placeholder --
|
||||
* NOT independently confirmed for the 64-bit layout. See report. */
|
||||
#undef MV_BUTTONREC
|
||||
#define MV_BUTTONREC 0x28 /* ptr-to-ptr: bound buttonrecord's target movie. */
|
||||
#undef MV_TFOBJ2
|
||||
#define MV_TFOBJ2 0xe8 /* int: textfield link-count/flag (type 4). */
|
||||
#undef MV_TFOBJ
|
||||
#define MV_TFOBJ 0xec /* ptr: textfield format/link object (type 4). */
|
||||
|
||||
/* -- player-relative fields used by is_hit (live mouse position). ----------- */
|
||||
#if IGGY_PTR64
|
||||
#undef PL_MOUSE_X
|
||||
# define PL_MOUSE_X 0x29d8
|
||||
#undef PL_MOUSE_Y
|
||||
# define PL_MOUSE_Y 0x29dc
|
||||
#else
|
||||
#undef PL_MOUSE_X
|
||||
# define PL_MOUSE_X 0x22a0
|
||||
#undef PL_MOUSE_Y
|
||||
# define PL_MOUSE_Y 0x22a4
|
||||
#endif
|
||||
|
||||
/* raw:734-788 consider_edge -- winding-number contribution of one straight
|
||||
* edge (ax,ay)-(bx,by) against the test point (px,py). Float arithmetic
|
||||
* translated exactly (no algebraic simplification). */
|
||||
static unsigned consider_edge(float ax, float ay, float bx, float by, float px,
|
||||
float py) {
|
||||
if (ay != by) {
|
||||
if (by < ay) {
|
||||
if (py < by) {
|
||||
return 0;
|
||||
}
|
||||
if (ay <= py) {
|
||||
return 0;
|
||||
}
|
||||
if (py == by) {
|
||||
return (unsigned)(px < ax) - 1u;
|
||||
}
|
||||
{
|
||||
unsigned dir = 0xffffffffu;
|
||||
float fx = ax, fy = ay;
|
||||
if ((bx <= px) && (fx <= px)) {
|
||||
return dir;
|
||||
}
|
||||
if ((bx <= px) || (fx <= px)) {
|
||||
unsigned hit = 0;
|
||||
if (((fx - bx) * (py - fy)) / (ay - fy) + bx <= px) {
|
||||
hit = dir;
|
||||
}
|
||||
return hit;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (py < ay) {
|
||||
return 0;
|
||||
}
|
||||
if (by <= py) {
|
||||
return 0;
|
||||
}
|
||||
if (py == ay) {
|
||||
return (unsigned)(ax <= px);
|
||||
}
|
||||
{
|
||||
unsigned dir = 1;
|
||||
float fx = bx, fy = by;
|
||||
bx = ax;
|
||||
by = ay;
|
||||
if ((fx <= px) && (bx <= px)) {
|
||||
return dir;
|
||||
}
|
||||
if ((fx <= px) || (bx <= px)) {
|
||||
unsigned hit = 0;
|
||||
if (((bx - fx) * (py - by)) / (fy - by) + fx <= px) {
|
||||
hit = dir;
|
||||
}
|
||||
return hit;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:690-730 consider_curve -- recursive quadratic-bezier flattening; once
|
||||
* the control-point deviation from the chord midpoint is within tolerance (or
|
||||
* the recursion depth exceeds 15) the curve is treated as its chord and
|
||||
* consider_edge is applied. Ghidra float constants: 40000000=2.0f,
|
||||
* 3e800000=0.25f, 3f000000=0.5f. */
|
||||
static uint64_t consider_curve(float ax, float ay, float cx, float cy, float bx,
|
||||
float by, uint32_t p7, float px, float py,
|
||||
int depth) {
|
||||
if (((px < ay) && (px < cy) && (px < by)) ||
|
||||
((ay < px) && (cy < px) && (by < px))) {
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
float mx = (cx * 2.0f + ax + bx) * 0.25f;
|
||||
float my = (cy * 2.0f + ay + by) * 0.25f;
|
||||
float dx = (ax + bx) * 0.5f - mx;
|
||||
float dy = (ay + by) * 0.5f - my;
|
||||
if ((dy * dy + dx * dx <= p7) || (depth > 15)) {
|
||||
return consider_edge(ax, ay, bx, by, p7, px);
|
||||
} else {
|
||||
uint64_t n1 = consider_curve(mx, my, (cx + bx) * 0.5f, (cy + by) * 0.5f,
|
||||
bx, by, p7, px, py, depth + 1);
|
||||
uint64_t n2 = consider_curve(ax, ay, (ax + cx) * 0.5f, (ay + cy) * 0.5f,
|
||||
mx, my, p7, px, py, depth + 1);
|
||||
return (uint64_t)(uint32_t)(n1 + n2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:2005-2127 hit_test_shape -- winding-number scanline test: walk every
|
||||
* style-group's edge list, accumulating consider_edge/consider_curve results;
|
||||
* odd winding count => inside. The optional "hole" early-out (checking the
|
||||
* matching style index of the next edge, guarded by p5) matches durango's
|
||||
* `param_5 != 0` gate. */
|
||||
static uint64_t hit_test_shape(void *player, void *shape, void *pxv, void *pyv,
|
||||
int p5) {
|
||||
float px = *(float *)pxv;
|
||||
float py = *(float *)pyv;
|
||||
int16_t groupcount = (int16_t)U16(shape, SHAPE_EDGECOUNT);
|
||||
(void)player;
|
||||
if (groupcount > 0) {
|
||||
void *groupbase = PTR(shape, SHAPE_GROUPS);
|
||||
int gi = 0;
|
||||
do {
|
||||
void *group = AT(groupbase, (intptr_t)gi * GROUP_STRIDE);
|
||||
int32_t edgecount = I32(group, GROUP_COUNT);
|
||||
unsigned winding = 0;
|
||||
if (edgecount > 0) {
|
||||
void *edges = PTR(group, GROUP_EDGESPTR);
|
||||
float ex = 0.0f, ey = 0.0f;
|
||||
uint16_t sa = 0, sb = 0;
|
||||
int ei = 0;
|
||||
do {
|
||||
void *rec = AT(edges, (intptr_t)ei * EDGE_STRIDE);
|
||||
uint8_t etype = (uint8_t)I8(rec, EDGE_TYPE);
|
||||
uint16_t na, nb;
|
||||
if (etype == 1) {
|
||||
na = U16(rec, EDGE_STYLE_A);
|
||||
nb = U16(rec, EDGE_STYLE_B);
|
||||
ex = F32(rec, EDGE_X);
|
||||
ey = F32(rec, EDGE_Y);
|
||||
} else if (etype == 2) {
|
||||
na = U16(rec, EDGE_STYLE_A);
|
||||
nb = U16(rec, EDGE_STYLE_B);
|
||||
if ((na == 0) != (nb == 0)) {
|
||||
if (na == 0) {
|
||||
winding += consider_edge(F32(rec, EDGE_X), F32(rec, EDGE_Y), ex,
|
||||
ey, px, py);
|
||||
} else {
|
||||
winding += consider_edge(ex, ey, F32(rec, EDGE_X),
|
||||
F32(rec, EDGE_Y), px, py);
|
||||
}
|
||||
}
|
||||
} else if (etype == 3) {
|
||||
float sx, sy, ux, uy;
|
||||
na = U16(rec, EDGE_STYLE_A);
|
||||
nb = U16(rec, EDGE_STYLE_B);
|
||||
if ((na == 0) != (nb == 0)) {
|
||||
if (na == 0) {
|
||||
sx = F32(rec, EDGE_X);
|
||||
sy = F32(rec, EDGE_Y);
|
||||
ux = ex;
|
||||
uy = ey;
|
||||
} else {
|
||||
ux = F32(rec, EDGE_X);
|
||||
uy = F32(rec, EDGE_Y);
|
||||
sx = ex;
|
||||
sy = ey;
|
||||
}
|
||||
winding += (unsigned)consider_curve(
|
||||
sx, sy, F32(rec, EDGE_CX), F32(rec, EDGE_CY), ux, uy, 0, px,
|
||||
py, 0);
|
||||
}
|
||||
} else {
|
||||
na = sa;
|
||||
nb = sb;
|
||||
}
|
||||
if (p5 != 0 && (ei + 1) < edgecount &&
|
||||
(U16(rec, 0x2a) != na || U16(rec, 0x2c) != nb) &&
|
||||
(winding & 1) != 0) {
|
||||
return 1;
|
||||
}
|
||||
sa = na;
|
||||
sb = nb;
|
||||
ei = ei + 1;
|
||||
} while (ei < edgecount);
|
||||
}
|
||||
if ((winding & 1) != 0) {
|
||||
return 1;
|
||||
}
|
||||
gi = gi + 1;
|
||||
} while (gi < groupcount);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:4404-4427 iggy_shape_hit_test -- inverse-transform the mouse point into
|
||||
* shape space, reject on the shape's cached bounding box, then delegate to
|
||||
* hit_test_shape for the exact scanline test. Exported: 6-arg frozen
|
||||
* signature (player, matrix, shape, p4, p5, p6). */
|
||||
uint64_t iggy_shape_hit_test(void *player, void *matrix, void *shape, void *p4,
|
||||
void *p5, uint32_t p6) {
|
||||
float lx, ly;
|
||||
(void)p4;
|
||||
(void)p5;
|
||||
if (shape != NULL && I8(shape, 0) == 1) {
|
||||
int ok = iggy_inverse_transform(&lx, &ly, matrix);
|
||||
if (ok != 0 && F32(shape, SHAPE_BBOX_MINX) <= lx &&
|
||||
lx <= F32(shape, SHAPE_BBOX_MAXX) && F32(shape, SHAPE_BBOX_MINY) <= ly &&
|
||||
ly <= F32(shape, SHAPE_BBOX_MAXY)) {
|
||||
return hit_test_shape(player, shape, &lx, &ly, (int)p6);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:1953-2001 hit_test_point_rec -- recursive display-tree point test: try
|
||||
* the node's own fill shape (MV_SHAPE_FILL) if present, else its stroke/mask
|
||||
* shape (MV_SHAPE_STROKE), else recurse through every child with its local
|
||||
* transform concatenated onto the accumulated matrix. */
|
||||
static uint64_t hit_test_point_rec(void *player, void *matrix, void *node,
|
||||
void *p4, uint32_t p5) {
|
||||
if (node == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (I8(node, MV_TYPE) == 1 && PTR(node, MV_SHAPE_FILL) != NULL) {
|
||||
/* durango passes its own uint32 p5 as the shape-test's (dead) 5th arg and
|
||||
* a literal 0 as the real fill/stroke selector (6th arg, consumed by
|
||||
* hit_test_shape via iggy_shape_hit_test's p6). */
|
||||
if (iggy_shape_hit_test(player, matrix, PTR(node, MV_SHAPE_FILL), p4,
|
||||
(void *)(uintptr_t)p5, 0) != 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (PTR(node, MV_SHAPE_STROKE) != NULL) {
|
||||
if (iggy_shape_hit_test(player, matrix, PTR(node, MV_SHAPE_STROKE), p4,
|
||||
(void *)(uintptr_t)p5, 1) != 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
{
|
||||
void *child;
|
||||
uint8_t local_xform[0x20];
|
||||
for (child = PTR(node, MV_FIRSTCHILD); child != NULL;
|
||||
child = PTR(child, MV_NEXT)) {
|
||||
iggy_matrix_concatenate(local_xform, matrix, AT(child, MV_XFORM));
|
||||
if (hit_test_point_rec(player, local_xform, child, p4, p5) != 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:3264-3299 iggy_hit_test_point -- public entry: supply an identity
|
||||
* matrix when none is given, then delegate to hit_test_point_rec. Arguments
|
||||
* forward in the SAME order as the frozen 5-arg static, matching the
|
||||
* ps3/orbis raw exactly (durango's own decompile elides the pass-through of
|
||||
* param_1/param_3/param_4 at the call site, showing only the two
|
||||
* locally-touched slots -- see report). */
|
||||
void iggy_hit_test_point(void *player, void *pt, void *p3, void *p4,
|
||||
uint32_t p5) {
|
||||
float identity[6];
|
||||
if (pt == NULL) {
|
||||
identity[0] = 1.0f;
|
||||
identity[1] = 0.0f;
|
||||
identity[2] = 0.0f;
|
||||
identity[3] = 1.0f;
|
||||
identity[4] = 0.0f;
|
||||
identity[5] = 0.0f;
|
||||
pt = identity;
|
||||
}
|
||||
hit_test_point_rec(player, pt, p3, p4, p5);
|
||||
}
|
||||
|
||||
/* raw:4727-4848 is_hit -- mouse-cursor display-tree walk used by button /
|
||||
* sprite mouseover dispatch. The durango body opens with an opaque
|
||||
* `param_2[3]-1<7` jump-table dispatch; the switch below is reconstructed
|
||||
* from the vita raw (0001406a), which shows the real case bodies for movie
|
||||
* types 1..7. Type 3 (sprite) is the only case whose real jump-table target
|
||||
* is the shared last-child traversal + stroke-shape fallback immediately
|
||||
* below the switch (matches durango: only type 3 continues past the jump
|
||||
* table in the vita mirror). */
|
||||
static uint64_t is_hit(void *player, void *node, void *matrix, int p4) {
|
||||
float mx = F32(player, PL_MOUSE_X);
|
||||
float my = F32(player, PL_MOUSE_Y);
|
||||
if (((U8(node, MV_B9) & 0x40) == 0 && p4 == 0) ||
|
||||
F32(node, MV_BOUNDS_MINX) > mx || mx > F32(node, MV_BOUNDS_MAXX) ||
|
||||
F32(node, MV_BOUNDS_MINY) > my || my > F32(node, MV_BOUNDS_MAXY)) {
|
||||
return 0;
|
||||
}
|
||||
if ((U8(node, 0) & 0x40) != 0) {
|
||||
float lx, ly;
|
||||
float local_xform[6];
|
||||
float ident[6];
|
||||
iggy_inverse_transform(&lx, &ly, matrix);
|
||||
if (lx < 0.0f || F32(node, MV_LOCALW) < lx || ly < 0.0f ||
|
||||
F32(node, MV_LOCALH) < ly) {
|
||||
return 0;
|
||||
}
|
||||
ident[0] = 1.0f;
|
||||
ident[1] = 0.0f;
|
||||
ident[2] = 0.0f;
|
||||
ident[3] = 1.0f;
|
||||
ident[4] = -F32(node, MV_LOCALOX);
|
||||
ident[5] = -F32(node, MV_LOCALOY);
|
||||
iggy_matrix_concatenate(local_xform, matrix, ident);
|
||||
matrix = local_xform;
|
||||
}
|
||||
switch (U8(node, MV_TYPE)) {
|
||||
case 1:
|
||||
if (PTR(node, MV_SHAPE_FILL) != NULL) {
|
||||
return iggy_shape_hit_test(player, matrix, PTR(node, MV_SHAPE_FILL),
|
||||
NULL, 0, 0)
|
||||
? 1
|
||||
: 0;
|
||||
}
|
||||
return 0;
|
||||
case 2:
|
||||
return 1;
|
||||
case 3:
|
||||
break; /* falls through to the shared traversal below. */
|
||||
case 4:
|
||||
if (I32(node, MV_TFOBJ2) != 0) {
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
/* vita re-reads the fill-shape pointer (node+0x58/0xa8, MV_SHAPE_FILL)
|
||||
* here and tests its own type byte / short -- NOT a separate field. */
|
||||
void *fillshape = PTR(node, MV_SHAPE_FILL);
|
||||
if (fillshape != NULL && I8(fillshape, 0) == 4 &&
|
||||
I16(fillshape, 2) != 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (PTR(node, MV_TFOBJ) != NULL) {
|
||||
void *linked = PTR(PTR(node, MV_TFOBJ), 0);
|
||||
if (linked != NULL && I32(linked, 0x17) != 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case 5:
|
||||
return 1;
|
||||
case 6:
|
||||
return 1;
|
||||
case 7:
|
||||
if (PTR(PTR(node, MV_BUTTONREC), 0) != NULL) {
|
||||
float local_xform[6];
|
||||
void *rec = PTR(node, MV_BUTTONREC);
|
||||
iggy_matrix_concatenate(local_xform, matrix, AT(PTR(rec, 0), MV_XFORM));
|
||||
return is_hit(player, PTR(rec, 0), local_xform, 1) ? 1 : 0;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
{
|
||||
void *child = PTR(node, MV_LASTCHILD);
|
||||
while (child != NULL) {
|
||||
void *prevnode = child;
|
||||
if (I16(child, MVD_114) < 0 && (U8(child, MV_B9) & 0x40) != 0) {
|
||||
float local_xform[6];
|
||||
iggy_matrix_concatenate(local_xform, matrix, AT(child, MV_XFORM));
|
||||
if (is_hit(player, child, local_xform, p4) != 0) {
|
||||
int32_t depthcount = I32(child, MV_DEPTHCOUNT);
|
||||
if (depthcount < 1) {
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
int i;
|
||||
void *depth_array = PTR(PTR(child, MV_PARENT), MV_DEPTHARRAY);
|
||||
for (i = 0; i < depthcount; i++) {
|
||||
void *sib = PTR(depth_array, (intptr_t)i * sizeof(void *));
|
||||
if (sib != NULL && I16(sib, MVD_114) >= 0 &&
|
||||
depthcount < (int32_t)I16(sib, MVD_114)) {
|
||||
float local_xform2[6];
|
||||
iggy_matrix_concatenate(local_xform2, matrix, AT(sib, MV_XFORM));
|
||||
if (is_hit(player, sib, local_xform2, p4) == 0) {
|
||||
prevnode = sib;
|
||||
goto next_sibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
next_sibling:
|
||||
child = PTR(prevnode, MV_PREV);
|
||||
}
|
||||
}
|
||||
if (PTR(node, MV_SHAPE_STROKE) != NULL) {
|
||||
/* durango: local_a8=(dead float), local_a0=1 (the real stroke selector,
|
||||
* position 6). */
|
||||
return iggy_shape_hit_test(player, matrix, PTR(node, MV_SHAPE_STROKE), NULL,
|
||||
0, 1)
|
||||
? 1
|
||||
: 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
492
iggy-decompiled/src/reconstructed/swf_play_hittest2.inc
Normal file
492
iggy-decompiled/src/reconstructed/swf_play_hittest2.inc
Normal file
@@ -0,0 +1,492 @@
|
||||
/*
|
||||
* swf_play_hittest2.inc -- do_mouseover (the display-tree walk that finds the
|
||||
* topmost mouse-sensitive object under the cursor, honoring bound
|
||||
* masks/buttons) and do_mouse_overing (the per-tick driver: rebuild the
|
||||
* mouseover list, diff it against the previous tick's list, and dispatch
|
||||
* rollOver/rollOut/mouseOver/mouseOut/mouseMove AS3 events). Split out of
|
||||
* swf_play_hittest.inc to stay under the 800-line budget. durango raw line
|
||||
* ranges cited per function; 32-bit offsets derived from the vita raw.
|
||||
*/
|
||||
|
||||
/* MV_U70: an opaque guard pointer tested (must be NULL) before do_mouseover
|
||||
* will consider a node eligible at all; durango 0x70 / vita 0x3c (matches the
|
||||
* vita raw's do_mouseover exactly: `*(int *)(param_2 + 0x3c) != 0`). */
|
||||
#if IGGY_PTR64
|
||||
#undef MV_U70
|
||||
# define MV_U70 0x70
|
||||
#else
|
||||
#undef MV_U70
|
||||
# define MV_U70 0x3c
|
||||
#endif
|
||||
|
||||
/* -- player-relative fields used by do_mouseover / do_mouse_overing. -------- */
|
||||
#if IGGY_PTR64
|
||||
#undef PL_MOUSEOVER_CUR
|
||||
# define PL_MOUSEOVER_CUR 0x29b0 /* ptr: current mouseover target. */
|
||||
#undef PL_MOUSEOVER_CUR2
|
||||
# define PL_MOUSEOVER_CUR2 0x29c0 /* ptr: secondary mouseover cursor. */
|
||||
#undef PL_MOUSEOVER_PREV
|
||||
# define PL_MOUSEOVER_PREV 0x29b8 /* ptr: previous-tick mouseover target. */
|
||||
#undef PL_CAPTURED
|
||||
# define PL_CAPTURED 0x2998 /* ptr: mouse-captured object. */
|
||||
#undef PL_MOUSEOVER_LIST
|
||||
# define PL_MOUSEOVER_LIST 0x2a08 /* ptr[100]: this-tick ancestor chain. */
|
||||
#undef PL_MOUSEOVER_COUNT
|
||||
# define PL_MOUSEOVER_COUNT 0x2d28 /* int: entries used in the list above. */
|
||||
#undef PL_SCALE_X
|
||||
# define PL_SCALE_X 0x1f44
|
||||
#undef PL_SCALE_Y
|
||||
# define PL_SCALE_Y 0x1f48
|
||||
#undef PL_CLICKBTN
|
||||
# define PL_CLICKBTN 0x2974 /* byte: last mouse-button-down state. */
|
||||
#undef PL_EVMOUSE_X
|
||||
# define PL_EVMOUSE_X 0x2988 /* float: mouse x cached for AS3 events. */
|
||||
#undef PL_EVMOUSE_Y
|
||||
# define PL_EVMOUSE_Y 0x298c
|
||||
#else
|
||||
#undef PL_MOUSEOVER_CUR
|
||||
# define PL_MOUSEOVER_CUR 0x228c
|
||||
#undef PL_MOUSEOVER_CUR2
|
||||
# define PL_MOUSEOVER_CUR2 0x2294 /* confirmed: iVar7(=player+0x2200)+0x94. */
|
||||
#undef PL_MOUSEOVER_PREV
|
||||
# define PL_MOUSEOVER_PREV 0x2290 /* estimated -- not independently found in
|
||||
* the vita raw (do_mouse_overing is
|
||||
* inlined there); see report. */
|
||||
#undef PL_CAPTURED
|
||||
# define PL_CAPTURED 0x2280
|
||||
#undef PL_MOUSEOVER_LIST
|
||||
# define PL_MOUSEOVER_LIST 0x22c8 /* estimated by tight-packing pattern from
|
||||
* the confirmed durango gap; see report. */
|
||||
#undef PL_MOUSEOVER_COUNT
|
||||
# define PL_MOUSEOVER_COUNT 0x2458 /* estimated: PL_MOUSEOVER_LIST + 100*4. */
|
||||
#undef PL_SCALE_X
|
||||
# define PL_SCALE_X 0x19d4
|
||||
#undef PL_SCALE_Y
|
||||
# define PL_SCALE_Y 0x19d8
|
||||
#undef PL_CLICKBTN
|
||||
# define PL_CLICKBTN 0x225c
|
||||
#undef PL_EVMOUSE_X
|
||||
# define PL_EVMOUSE_X 0x2270
|
||||
#undef PL_EVMOUSE_Y
|
||||
# define PL_EVMOUSE_Y 0x2274
|
||||
#endif
|
||||
|
||||
/* raw:1358-1561 do_mouseover -- recursive descent used both by is_hit's
|
||||
* sibling `iggy_set_mouseover_list` entry point and by itself: find the
|
||||
* innermost mouse-sensitive descendant under the live cursor, honoring bound
|
||||
* masks (MV_BOUNDOBJ) and buttons (movie types 3/6/7 with a bound-object
|
||||
* chain). The type 1..7 dispatch after the eligibility gate is another
|
||||
* opaque durango jump table; reconstructed as a switch from the vita raw
|
||||
* (00014314), whose case bodies mirror is_hit's exactly. */
|
||||
static uint64_t do_mouseover(void *player, void *node, void *matrix,
|
||||
uint32_t p4, void *p5, int p6, int p7) {
|
||||
float mx = F32(player, PL_MOUSE_X);
|
||||
float my = F32(player, PL_MOUSE_Y);
|
||||
void *target = p5;
|
||||
|
||||
if ((U8(node, MV_FLAG1) & 0x10) == 0 && (U8(node, MV_B9) & 0x40) != 0 &&
|
||||
PTR(node, MV_U70) == NULL) {
|
||||
uint8_t ntype = U8(node, MV_TYPE);
|
||||
if ((ntype == 3 || (uint8_t)(ntype - 6) < 2) && p6 == 0 &&
|
||||
(U8(node, MV_BA) & 0x40) != 0 && node != AT(player, PL_STAGE) &&
|
||||
node != AT(player, PL_ROOT)) {
|
||||
target = node;
|
||||
}
|
||||
if ((U8(node, 0) & 0x40) != 0) {
|
||||
float lx, ly;
|
||||
float local_xform[6];
|
||||
float ident[6];
|
||||
iggy_inverse_transform(&lx, &ly, matrix, mx, my);
|
||||
if (lx < 0.0f || F32(node, MV_LOCALW) < lx || ly < 0.0f ||
|
||||
F32(node, MV_LOCALH) < ly) {
|
||||
return 0;
|
||||
}
|
||||
ident[0] = 1.0f;
|
||||
ident[1] = 0.0f;
|
||||
ident[2] = 0.0f;
|
||||
ident[3] = 1.0f;
|
||||
ident[4] = -F32(node, MV_LOCALOX);
|
||||
ident[5] = -F32(node, MV_LOCALOY);
|
||||
iggy_matrix_concatenate(local_xform, matrix, ident);
|
||||
matrix = local_xform;
|
||||
}
|
||||
if (U8(node, MV_TYPE) == 3 && PTR(node, MV_LASTCHILD) != NULL) {
|
||||
void *child = PTR(node, MV_LASTCHILD);
|
||||
void *prevnode = child;
|
||||
int found = 0;
|
||||
do {
|
||||
prevnode = child;
|
||||
if (I16(child, MVD_114) < 0 && (U8(child, MV_B9) & 0x40) != 0) {
|
||||
void *saved_cur = PTR(player, PL_MOUSEOVER_CUR);
|
||||
void *saved_cur2 = PTR(player, PL_MOUSEOVER_CUR2);
|
||||
float childxform[6];
|
||||
int newp6, newp7;
|
||||
uint64_t r;
|
||||
iggy_matrix_concatenate(childxform, matrix, AT(child, MV_XFORM));
|
||||
newp6 = (PTR(node, MV_BOUNDOBJ) == NULL ||
|
||||
(U8(node, MV_BA) & 0x40) == 0)
|
||||
? 0
|
||||
: 1;
|
||||
newp7 = (p6 == 0 && (U8(node, MV_BA) & 0x10) != 0) ? 0 : 1;
|
||||
r = do_mouseover(player, child, childxform, p4 + 1, target, newp7,
|
||||
newp6);
|
||||
if (r != 0) {
|
||||
int32_t depthcount = I32(child, MV_DEPTHCOUNT);
|
||||
int broke = 0;
|
||||
if (depthcount > 0) {
|
||||
int i;
|
||||
void *depth_array = PTR(PTR(child, MV_PARENT), MV_DEPTHARRAY);
|
||||
for (i = 0; i < depthcount; i++) {
|
||||
void *sib = PTR(depth_array, (intptr_t)i * sizeof(void *));
|
||||
if (sib != NULL && I16(sib, MVD_114) >= 0 &&
|
||||
depthcount < (int32_t)I16(sib, MVD_114)) {
|
||||
float sibxform[6];
|
||||
iggy_matrix_concatenate(sibxform, matrix, AT(sib, MV_XFORM));
|
||||
if (is_hit(player, sib, sibxform, 0) == 0) {
|
||||
prevnode = sib;
|
||||
broke = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
depthcount = I32(child, MV_DEPTHCOUNT);
|
||||
}
|
||||
}
|
||||
if (!broke) {
|
||||
void *root = PTR(child, MV_BOUNDROOT);
|
||||
int rootok = 1;
|
||||
if (root != NULL) {
|
||||
float rootxform[6];
|
||||
void *walk;
|
||||
int k;
|
||||
for (k = 0; k < 6; k++) {
|
||||
rootxform[k] = F32(root, MV_XFORM + k * 4);
|
||||
}
|
||||
for (walk = PTR(root, MV_PARENT); walk != NULL;
|
||||
walk = PTR(walk, MV_PARENT)) {
|
||||
iggy_matrix_concatenate(rootxform, AT(walk, MV_XFORM),
|
||||
rootxform);
|
||||
root = walk;
|
||||
}
|
||||
if (root != AT(player, PL_STAGE)) {
|
||||
iggy_matrix_concatenate(rootxform,
|
||||
AT(AT(player, PL_STAGE), MV_XFORM),
|
||||
rootxform);
|
||||
}
|
||||
rootok = is_hit(player, PTR(child, MV_BOUNDROOT), rootxform, 1)
|
||||
? 1
|
||||
: 0;
|
||||
}
|
||||
if (root == NULL || rootok) {
|
||||
if (PTR(player, PL_MOUSEOVER_CUR) != target) {
|
||||
return 1;
|
||||
}
|
||||
found = 1;
|
||||
} else {
|
||||
PTR(player, PL_MOUSEOVER_CUR) = saved_cur;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = saved_cur2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
child = PTR(prevnode, MV_PREV);
|
||||
} while (child != NULL);
|
||||
if (found) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if ((U8(node, MV_TYPE) == 3 || (uint8_t)(U8(node, MV_TYPE) - 6) < 2) &&
|
||||
PTR(node, MV_BOUNDOBJ) != NULL && (U8(node, MV_BA) & 0x40) != 0) {
|
||||
float boundxform[6];
|
||||
iggy_get_o2p(player, PTR(node, MV_BOUNDOBJ), boundxform);
|
||||
if (is_hit(player, PTR(node, MV_BOUNDOBJ), boundxform, 1) != 0) {
|
||||
PTR(player, PL_MOUSEOVER_CUR) = target;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = node;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (p7 == 0) {
|
||||
if (PTR(node, MV_BOUNDOBJ) == NULL && target != NULL &&
|
||||
F32(node, MV_BOUNDS_MINX) <= mx && mx <= F32(node, MV_BOUNDS_MAXX) &&
|
||||
F32(node, MV_BOUNDS_MINY) <= my && my <= F32(node, MV_BOUNDS_MAXY) &&
|
||||
(uint8_t)(U8(node, MV_TYPE) - 1) < 7) {
|
||||
switch (U8(node, MV_TYPE)) {
|
||||
case 1:
|
||||
if (PTR(node, MV_SHAPE_FILL) != NULL) {
|
||||
if (iggy_shape_hit_test(player, matrix, PTR(node, MV_SHAPE_FILL),
|
||||
NULL, 0, 0) != 0) {
|
||||
PTR(player, PL_MOUSEOVER_CUR) = target;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = node;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
PTR(player, PL_MOUSEOVER_CUR) = target;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = node;
|
||||
return 1;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
if (I32(node, MV_TFOBJ2) != 0) {
|
||||
PTR(player, PL_MOUSEOVER_CUR) = target;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = node;
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
/* re-reads the fill-shape pointer (MV_SHAPE_FILL), testing its
|
||||
* own type byte / short -- matches is_hit's case 4 exactly. */
|
||||
void *fillshape = PTR(node, MV_SHAPE_FILL);
|
||||
if (fillshape != NULL && I8(fillshape, 0) == 4 &&
|
||||
I16(fillshape, 2) != 0) {
|
||||
PTR(player, PL_MOUSEOVER_CUR) = target;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = node;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (PTR(node, MV_TFOBJ) != NULL) {
|
||||
void *linked = PTR(PTR(node, MV_TFOBJ), 0);
|
||||
if (linked != NULL && I32(linked, 0x17) != 0) {
|
||||
PTR(player, PL_MOUSEOVER_CUR) = target;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = node;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
PTR(player, PL_MOUSEOVER_CUR) = target;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = node;
|
||||
return 1;
|
||||
case 6:
|
||||
PTR(player, PL_MOUSEOVER_CUR) = target;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = node;
|
||||
return 1;
|
||||
case 7:
|
||||
if (PTR(PTR(node, MV_BUTTONREC), 0) != NULL) {
|
||||
float recxform[6];
|
||||
void *rec = PTR(node, MV_BUTTONREC);
|
||||
iggy_matrix_concatenate(recxform, matrix, AT(PTR(rec, 0), MV_XFORM));
|
||||
if (is_hit(player, PTR(rec, 0), recxform, 1) != 0) {
|
||||
/* vita sets both cursors to the node itself here, not to the
|
||||
* bound record's target movie nor to `target`. */
|
||||
PTR(player, PL_MOUSEOVER_CUR) = node;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = node;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (PTR(node, MV_SHAPE_STROKE) != NULL && target != NULL &&
|
||||
((U8(node, MV_TYPE) != 3 && (uint8_t)(U8(node, MV_TYPE) - 6) > 1) ||
|
||||
(U8(node, MV_BA) & 0x40) != 0) &&
|
||||
F32(node, MV_BOUNDS_MINX) <= mx && mx <= F32(node, MV_BOUNDS_MAXX) &&
|
||||
F32(node, MV_BOUNDS_MINY) <= my && my <= F32(node, MV_BOUNDS_MAXY)) {
|
||||
if (iggy_shape_hit_test(player, matrix, PTR(node, MV_SHAPE_STROKE),
|
||||
NULL, 0, 1) != 0) {
|
||||
PTR(player, PL_MOUSEOVER_CUR) = target;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = node;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:1129-1354 do_mouse_overing -- per-tick mouseover-list refresh + AS3
|
||||
* rollOver/rollOut/mouseOver/mouseOut/mouseMove event dispatch. The 100-entry
|
||||
* scratch arrays translate durango's `alStack_6a8`/`local_388` fixed stack
|
||||
* buffers; the ancestor-chain list at PL_MOUSEOVER_LIST is capped at 100
|
||||
* entries in the original (the `puVar14 == 0x64` break). */
|
||||
static uint64_t do_mouse_overing(void *player, unsigned *ev, int p3) {
|
||||
void *stage = AT(player, PL_STAGE);
|
||||
void *root = AT(player, PL_ROOT);
|
||||
float scale_evt[6];
|
||||
void *moveTarget;
|
||||
void *newCur;
|
||||
void *oldPrevChain;
|
||||
void *oldListEntry = NULL;
|
||||
void *outCandidate;
|
||||
int outCount = 0;
|
||||
void *rollOutList[100];
|
||||
void *rollOverList[100];
|
||||
int rollOverCount = 0, rollOutCount = 0;
|
||||
(void)rollOutCount;
|
||||
int i;
|
||||
|
||||
iggy_set_mouseover_list(player);
|
||||
|
||||
scale_evt[0] = F32(player, PL_SCALE_X);
|
||||
scale_evt[1] = F32(player, PL_SCALE_Y);
|
||||
scale_evt[2] = 0.0f;
|
||||
scale_evt[3] = 0.0f;
|
||||
scale_evt[4] = 0.0f;
|
||||
scale_evt[5] = 0.0f;
|
||||
|
||||
{
|
||||
uint64_t bu = button_under_cursor(player, AT(player, PL_MOUSE_X), stage,
|
||||
AT(player, PL_MOUSE_X), 0, 0, 0);
|
||||
swf_update_buttons(player, stage, (void *)(uintptr_t)bu, U8(player, PL_CLICKBTN));
|
||||
}
|
||||
if (PTR(player, PL_AS3VM) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
newCur = PTR(player, PL_MOUSEOVER_PREV) != NULL
|
||||
? PTR(player, PL_MOUSEOVER_PREV)
|
||||
: stage;
|
||||
moveTarget = stage;
|
||||
if ((*ev & 1) == 0 && newCur != stage) {
|
||||
moveTarget = newCur;
|
||||
*ev = *ev | 1;
|
||||
}
|
||||
|
||||
{
|
||||
uint8_t evtbuf[0x30];
|
||||
F32(evtbuf, 0) = F32(player, PL_EVMOUSE_X);
|
||||
F32(evtbuf, 4) = F32(player, PL_EVMOUSE_Y);
|
||||
(void)evtbuf;
|
||||
as3vm_interpreter_initialize(PTR(player, PL_AS3VM));
|
||||
if (p3 != 0) {
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evtbuf, moveTarget, 0x25,
|
||||
0, 1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
outCandidate = PTR(player, PL_MOUSEOVER_PREV);
|
||||
if (outCandidate == root) {
|
||||
outCandidate = NULL;
|
||||
}
|
||||
oldPrevChain = PTR(player, PL_MOUSEOVER_CUR2);
|
||||
if (oldPrevChain == root) {
|
||||
oldPrevChain = NULL;
|
||||
}
|
||||
|
||||
/* Find the first entry in last tick's ancestor-chain list whose chain of
|
||||
* MV_PARENT pointers still reaches the stage (i.e. is still attached). */
|
||||
if (I32(player, PL_MOUSEOVER_COUNT) > 0) {
|
||||
void *listbase = AT(player, PL_MOUSEOVER_LIST);
|
||||
int idx = 0;
|
||||
do {
|
||||
void *entry = PTR(listbase, (intptr_t)idx * sizeof(void *));
|
||||
oldListEntry = NULL;
|
||||
if (entry != NULL) {
|
||||
void *anc = entry;
|
||||
void *walk;
|
||||
for (walk = PTR(entry, MV_PARENT); walk != NULL;
|
||||
walk = PTR(walk, MV_PARENT)) {
|
||||
anc = walk;
|
||||
}
|
||||
if (anc == stage) {
|
||||
oldListEntry = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
idx = idx + 1;
|
||||
} while (idx < I32(player, PL_MOUSEOVER_COUNT));
|
||||
}
|
||||
|
||||
/* Walk up from the currently-captured/old-cur chain, collecting rollOut
|
||||
* candidates (still attached, not the stage, not already flagged "new"). */
|
||||
{
|
||||
void *node = outCandidate;
|
||||
while (node != NULL) {
|
||||
if ((U8(node, MV_BA) & 0x40) != 0 && (U8(node, MV_B9) & 0x80) == 0 &&
|
||||
node != stage) {
|
||||
U16(node, MV_REFCOUNT) = U16(node, MV_REFCOUNT) + 1;
|
||||
rollOutList[outCount] = node;
|
||||
outCount = outCount + 1;
|
||||
if (outCount == 0x64) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
node = PTR(node, MV_PARENT);
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear the "in this tick's list" flag on every entry from last tick. */
|
||||
if (I32(player, PL_MOUSEOVER_COUNT) > 0) {
|
||||
void *listbase = AT(player, PL_MOUSEOVER_LIST);
|
||||
int idx;
|
||||
for (idx = I32(player, PL_MOUSEOVER_COUNT) - 1; idx >= 0; idx--) {
|
||||
void *entry = PTR(listbase, (intptr_t)idx * sizeof(void *));
|
||||
if (entry != NULL) {
|
||||
U8(entry, MV_B9) = U8(entry, MV_B9) & 0x7f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Rebuild this tick's ancestor-chain list from the new target upward,
|
||||
* marking each entry "in this tick's list". */
|
||||
{
|
||||
int count = 0;
|
||||
if (moveTarget != NULL) {
|
||||
void *listbase = AT(player, PL_MOUSEOVER_LIST);
|
||||
void *node = moveTarget;
|
||||
do {
|
||||
U8(node, MV_B9) = U8(node, MV_B9) | 0x80;
|
||||
PTR(listbase, (intptr_t)count * sizeof(void *)) = node;
|
||||
node = PTR(node, MV_PARENT);
|
||||
count = count + 1;
|
||||
if (count == 0x64) {
|
||||
break;
|
||||
}
|
||||
} while (node != NULL);
|
||||
}
|
||||
I32(player, PL_MOUSEOVER_COUNT) = count;
|
||||
}
|
||||
|
||||
/* Walk up from the still-attached old-list entry, collecting rollOver
|
||||
* candidates -- anything not already marked "in this tick's list". */
|
||||
if (oldListEntry != NULL) {
|
||||
void *node = oldListEntry;
|
||||
do {
|
||||
if ((U8(node, MV_B9) & 0x80) != 0) {
|
||||
break;
|
||||
}
|
||||
if ((U8(node, MV_BA) & 0x40) != 0 && node != stage) {
|
||||
rollOverList[rollOverCount] = node;
|
||||
rollOverCount = rollOverCount + 1;
|
||||
U16(node, MV_REFCOUNT) = U16(node, MV_REFCOUNT) + 1;
|
||||
}
|
||||
node = PTR(node, MV_PARENT);
|
||||
} while (node != NULL);
|
||||
}
|
||||
|
||||
if (oldPrevChain != NULL && oldPrevChain != moveTarget) {
|
||||
uint8_t evtbuf[0x30];
|
||||
F32(evtbuf, 0) = F32(player, PL_EVMOUSE_X);
|
||||
F32(evtbuf, 4) = F32(player, PL_EVMOUSE_Y);
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evtbuf, oldPrevChain, 0x26,
|
||||
0, 1, moveTarget);
|
||||
}
|
||||
|
||||
for (i = rollOverCount - 1; i >= 0; i--) {
|
||||
uint8_t evtbuf[0x30];
|
||||
F32(evtbuf, 0) = F32(player, PL_EVMOUSE_X);
|
||||
F32(evtbuf, 4) = F32(player, PL_EVMOUSE_Y);
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evtbuf, rollOverList[i],
|
||||
0x2d, 0, 0, NULL);
|
||||
U16(rollOverList[i], MV_REFCOUNT) = U16(rollOverList[i], MV_REFCOUNT) - 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < outCount; i++) {
|
||||
uint8_t evtbuf[0x30];
|
||||
F32(evtbuf, 0) = F32(player, PL_EVMOUSE_X);
|
||||
F32(evtbuf, 4) = F32(player, PL_EVMOUSE_Y);
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evtbuf, rollOutList[i], 0x2e,
|
||||
0, 0, NULL);
|
||||
U16(rollOutList[i], MV_REFCOUNT) = U16(rollOutList[i], MV_REFCOUNT) - 1;
|
||||
}
|
||||
|
||||
if (moveTarget != NULL && oldPrevChain != moveTarget) {
|
||||
uint8_t evtbuf[0x30];
|
||||
F32(evtbuf, 0) = F32(player, PL_EVMOUSE_X);
|
||||
F32(evtbuf, 4) = F32(player, PL_EVMOUSE_Y);
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evtbuf, moveTarget, 0x27, 0,
|
||||
1, oldPrevChain);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
554
iggy-decompiled/src/reconstructed/swf_play_input.inc
Normal file
554
iggy-decompiled/src/reconstructed/swf_play_input.inc
Normal file
@@ -0,0 +1,554 @@
|
||||
/*
|
||||
* swf_play_input.inc -- keyboard focus routing (iggy_set_focus_typed,
|
||||
* seek_focus / tab order), iggy_set_mouseover_list (the per-tick mouseover
|
||||
* driver's thin public wrapper), and the low-level input dispatch entry
|
||||
* points process_input_event / process_key_event. durango raw line ranges
|
||||
* cited per function; 32-bit offsets derived from the vita raw.
|
||||
*
|
||||
* shift_mapping is recovered byte-for-byte from the durango .obj's .data
|
||||
* section (llvm-nm: `d shift_mapping` @ file offset 0xd0, size 0x42, the
|
||||
* tail of the 0x112-byte swf_play.c .data blob; llvm-objdump -s -j .data
|
||||
* confirms the bytes below). It decodes cleanly as 22 3-byte records
|
||||
* {vk, unshifted-char, shifted-char} -- e.g. {0x30,'0',')'}, {0xBC,',','<'}
|
||||
* -- matching the standard US-QWERTY VK-code shift table exactly, which
|
||||
* corroborates the byte recovery. Ghidra's separate `DAT_000021d1` symbol
|
||||
* (indexed `shift_state + i*3`) is this SAME array read one byte to the
|
||||
* right of each record's vk byte (i.e. `&shift_mapping[1]`); the two
|
||||
* accesses are folded into one below.
|
||||
*/
|
||||
static const uint8_t shift_mapping[0x42] = {
|
||||
0x09, 0x09, 0x00, 0x30, 0x30, 0x29, 0x31, 0x31, 0x21, 0x32, 0x32, 0x40,
|
||||
0x33, 0x33, 0x23, 0x34, 0x34, 0x24, 0x35, 0x35, 0x25, 0x36, 0x36, 0x5e,
|
||||
0x37, 0x37, 0x26, 0x38, 0x38, 0x2a, 0x39, 0x39, 0x28, 0xc0, 0x60, 0x7e,
|
||||
0xdc, 0x5c, 0x7c, 0xbc, 0x2c, 0x3c, 0xbb, 0x3d, 0x2b, 0xdb, 0x5b, 0x7b,
|
||||
0xbd, 0x2d, 0x5f, 0xbe, 0x2e, 0x3e, 0xde, 0x27, 0x22, 0xdd, 0x5d, 0x7d,
|
||||
0xba, 0x3b, 0x3a, 0xbf, 0x2f, 0x3f,
|
||||
};
|
||||
#undef SHIFT_MAPPING_ENTRIES
|
||||
#define SHIFT_MAPPING_ENTRIES 22
|
||||
|
||||
/* -- player-relative fields used by focus / key routing. -------------------
|
||||
* FOCUSOBJ, PL_STAGE, PL_ROOT, PL_AS3VM, MV_TFSTRUCT, MV_TFEDIT, MV_NEXT,
|
||||
* MV_PREV, MV_PARENT, MV_FIRSTCHILD, MV_LASTCHILD, MV_B9, MV_BA, MVD_114 are
|
||||
* already established (swf_play_player.inc / swf_play_movie.inc /
|
||||
* swf_play_hittest.inc, all included earlier in swf_play.c). */
|
||||
#if IGGY_PTR64
|
||||
#undef PL_MODSTATE
|
||||
# define PL_MODSTATE 0x2973 /* byte: active shift/ctrl/alt combo index. */
|
||||
#undef PL_KEY0F_LO
|
||||
# define PL_KEY0F_LO 0x297e
|
||||
#undef PL_KEY0F_HI
|
||||
# define PL_KEY0F_HI 0x297f
|
||||
#undef PL_MOD0F
|
||||
# define PL_MOD0F 0x2972
|
||||
#undef PL_KEY10_LO
|
||||
# define PL_KEY10_LO 0x2978
|
||||
#undef PL_KEY10_HI
|
||||
# define PL_KEY10_HI 0x2979
|
||||
#undef PL_MOD10
|
||||
# define PL_MOD10 0x2973 /* == PL_MODSTATE. */
|
||||
#undef PL_KEY11_LO
|
||||
# define PL_KEY11_LO 0x297c
|
||||
#undef PL_KEY11_HI
|
||||
# define PL_KEY11_HI 0x297d
|
||||
#undef PL_MOD11
|
||||
# define PL_MOD11 0x2971
|
||||
#undef PL_KEY12_LO
|
||||
# define PL_KEY12_LO 0x297a
|
||||
#undef PL_KEY12_HI
|
||||
# define PL_KEY12_HI 0x297b
|
||||
#undef PL_MOD12
|
||||
# define PL_MOD12 0x2970
|
||||
#else
|
||||
#undef PL_MODSTATE
|
||||
# define PL_MODSTATE 0x225b
|
||||
#undef PL_KEY0F_LO
|
||||
# define PL_KEY0F_LO 0x2266
|
||||
#undef PL_KEY0F_HI
|
||||
# define PL_KEY0F_HI 0x2267
|
||||
#undef PL_MOD0F
|
||||
# define PL_MOD0F 0x225a
|
||||
#undef PL_KEY10_LO
|
||||
# define PL_KEY10_LO 0x2260
|
||||
#undef PL_KEY10_HI
|
||||
# define PL_KEY10_HI 0x2261
|
||||
#undef PL_MOD10
|
||||
# define PL_MOD10 0x225b
|
||||
#undef PL_KEY11_LO
|
||||
# define PL_KEY11_LO 0x2264
|
||||
#undef PL_KEY11_HI
|
||||
# define PL_KEY11_HI 0x2265
|
||||
#undef PL_MOD11
|
||||
# define PL_MOD11 0x2259
|
||||
#undef PL_KEY12_LO
|
||||
# define PL_KEY12_LO 0x2262
|
||||
#undef PL_KEY12_HI
|
||||
# define PL_KEY12_HI 0x2263
|
||||
#undef PL_MOD12
|
||||
# define PL_MOD12 0x2258
|
||||
#endif
|
||||
|
||||
/* raw:4242-4278 iggy_set_focus_typed -- exported focus setter: dispatch the
|
||||
* as3 pre-focus/focusOut/focusIn event triple; a nonzero pre-focus return
|
||||
* cancels the change. */
|
||||
void iggy_set_focus_typed(void *player, char kind, void *obj, uint32_t p4) {
|
||||
void *cur = PTR(player, FOCUSOBJ);
|
||||
if (obj != cur) {
|
||||
if (kind != 0) {
|
||||
void *from = (cur == NULL) ? AT(player, PL_STAGE) : cur;
|
||||
if (as3vm_do_focus_event_GC(PTR(player, PL_AS3VM), from, kind, obj, p4,
|
||||
1) != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (PTR(player, FOCUSOBJ) != NULL) {
|
||||
as3vm_do_focus_event_GC(PTR(player, PL_AS3VM), PTR(player, FOCUSOBJ),
|
||||
0x32, obj, 0, 0);
|
||||
}
|
||||
PTR(player, FOCUSOBJ) = obj;
|
||||
if (obj != NULL) {
|
||||
as3vm_do_focus_event_GC(PTR(player, PL_AS3VM), obj, 0x31, obj, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:5774-5941 seek_focus -- tab-order search over the display tree
|
||||
* (depth-first, respecting MVD_114 explicit tab-index overrides when set on
|
||||
* the current focus object's ancestor chain); translated with the durango
|
||||
* control flow's own labels preserved verbatim (the traversal has several
|
||||
* loop-crossing jumps that do not restructure cleanly). */
|
||||
static void seek_focus(void *player, int p2) {
|
||||
/* Variable names mirror the durango pseudocode's own puVarN registers as
|
||||
* closely as possible (p6,p7,p9,p10,p11,p12) since this traversal's control
|
||||
* flow (labels jumping into the middle of nested loops) does not restate
|
||||
* cleanly under renaming -- a literal transliteration is the safer/more
|
||||
* faithful translation here. p10 doubles as both an initial "carried
|
||||
* fallback" pointer (NULL) in the ancestor-walk below and, once reused as
|
||||
* an integer, the depth counter -- exactly as it does in the raw. */
|
||||
void *stage = AT(player, PL_STAGE);
|
||||
void *p6 = PTR(player, FOCUSOBJ);
|
||||
void *p12 = stage;
|
||||
void *p11;
|
||||
void *p9, *p5, *p7;
|
||||
void *p10 = NULL;
|
||||
int32_t iVar4;
|
||||
void *result;
|
||||
uint8_t bVar2;
|
||||
int depth = 0;
|
||||
|
||||
if (p6 != NULL) {
|
||||
do {
|
||||
if (p6 == p12) {
|
||||
break;
|
||||
}
|
||||
p6 = PTR(p6, MV_PARENT);
|
||||
} while (p6 != NULL);
|
||||
}
|
||||
p11 = p12;
|
||||
if (p6 == p12) {
|
||||
p11 = PTR(player, FOCUSOBJ);
|
||||
}
|
||||
iVar4 = I32(p11, MVD_114);
|
||||
p6 = p11;
|
||||
p5 = p10; /* NULL */
|
||||
p9 = p11;
|
||||
|
||||
if (iVar4 < 0) {
|
||||
do {
|
||||
if (p6 == p12) {
|
||||
break;
|
||||
}
|
||||
p7 = p6;
|
||||
if ((U8(p6, MV_B9) & 0x40) == 0 && (p7 = p5, p5 != NULL)) {
|
||||
p7 = p10;
|
||||
p9 = p5;
|
||||
}
|
||||
p6 = PTR(p6, MV_PARENT);
|
||||
p5 = p7;
|
||||
} while (p6 != NULL);
|
||||
|
||||
if (p2 > 0) {
|
||||
p6 = p9;
|
||||
if ((U8(p9, MV_B9) & 0x40) == 0) {
|
||||
for (p6 = PTR(p9, MV_NEXT); p6 != NULL; p6 = PTR(p6, MV_NEXT)) {
|
||||
if ((U8(p6, MV_B9) & 0x40) != 0) {
|
||||
goto forward_found;
|
||||
}
|
||||
}
|
||||
p6 = PTR(p9, MV_PARENT);
|
||||
if (p6 == NULL) {
|
||||
p6 = p11;
|
||||
}
|
||||
}
|
||||
forward_found:
|
||||
if (p6 != p12) {
|
||||
goto forward_continue;
|
||||
}
|
||||
do {
|
||||
bVar2 = U8(p6, MV_BA);
|
||||
while ((bVar2 & 0x20) != 0 && (p12 = PTR(p6, MV_FIRSTCHILD)) != NULL &&
|
||||
(U8(p6, MV_B9) & 0x40) != 0) {
|
||||
bVar2 = U8(p12, MV_BA);
|
||||
p6 = p12;
|
||||
}
|
||||
for (;;) {
|
||||
for (;;) {
|
||||
if ((U8(p6, MV_BA) & 0x80) != 0 && (p5 = p6, (U8(p6, MV_B9) & 0x40) != 0)) {
|
||||
goto done;
|
||||
}
|
||||
if (p6 == p11) {
|
||||
return;
|
||||
}
|
||||
depth = depth + 1;
|
||||
forward_continue:
|
||||
p5 = p11;
|
||||
if (depth > 4999) {
|
||||
goto done;
|
||||
}
|
||||
p12 = PTR(p6, MV_NEXT);
|
||||
if (p12 == NULL) {
|
||||
break;
|
||||
}
|
||||
bVar2 = U8(p12, MV_BA);
|
||||
p6 = p12;
|
||||
while ((bVar2 & 0x20) != 0 &&
|
||||
(p12 = PTR(p6, MV_FIRSTCHILD)) != NULL &&
|
||||
(U8(p6, MV_B9) & 0x40) != 0) {
|
||||
bVar2 = U8(p12, MV_BA);
|
||||
p6 = p12;
|
||||
}
|
||||
}
|
||||
p6 = PTR(p6, MV_PARENT);
|
||||
if (p6 == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
p6 = stage;
|
||||
if (p6 == p11) {
|
||||
return;
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
/* p2 <= 0: walk backward via MV_PREV/MV_LASTCHILD. */
|
||||
p6 = p9;
|
||||
if ((U8(p9, MV_B9) & 0x40) == 0) {
|
||||
for (p6 = PTR(p9, MV_PREV); p6 != NULL; p6 = PTR(p6, MV_PREV)) {
|
||||
if ((U8(p6, MV_B9) & 0x40) != 0) {
|
||||
goto backward_found;
|
||||
}
|
||||
}
|
||||
p6 = PTR(p9, MV_PARENT);
|
||||
if (p6 == NULL) {
|
||||
p6 = p11;
|
||||
}
|
||||
}
|
||||
backward_found:
|
||||
do {
|
||||
if (((U8(p6, MV_BA) & 0x20) == 0) ||
|
||||
((p5 = PTR(p6, MV_LASTCHILD)) == NULL) || (U8(p6, MV_B9) & 0x40) == 0) {
|
||||
void *lVar3;
|
||||
p5 = p12;
|
||||
for (lVar3 = PTR(p6, MV_PARENT); lVar3 != NULL;
|
||||
lVar3 = PTR(lVar3, MV_PARENT)) {
|
||||
if (PTR(lVar3, MV_PREV) != NULL) {
|
||||
p5 = PTR(lVar3, MV_PREV);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((U8(p5, MV_BA) & 0x80) != 0 && (U8(p5, MV_B9) & 0x40) != 0) {
|
||||
break;
|
||||
}
|
||||
if (p5 == p11) {
|
||||
return;
|
||||
}
|
||||
depth = depth + 1;
|
||||
p6 = p5;
|
||||
p5 = p11;
|
||||
} while (depth < 5000);
|
||||
} else if (p2 < 1) {
|
||||
p5 = find_tree_max_at_most(p12, iVar4 - 1);
|
||||
if (p5 == NULL) {
|
||||
p5 = find_tree_max_at_most(p12, 0x7fffffff);
|
||||
}
|
||||
} else {
|
||||
p5 = find_tree_min_at_least(p12, iVar4 + 1);
|
||||
if (p5 == NULL) {
|
||||
p5 = find_tree_min_at_least(p12, 0);
|
||||
}
|
||||
}
|
||||
done:
|
||||
result = p5;
|
||||
if (result != NULL && result != PTR(player, FOCUSOBJ)) {
|
||||
void *from = PTR(player, FOCUSOBJ);
|
||||
if (from == NULL) {
|
||||
from = stage;
|
||||
}
|
||||
if (as3vm_do_focus_event_GC(PTR(player, PL_AS3VM), from, 0x33, result, 9,
|
||||
1) == 0) {
|
||||
if (PTR(player, FOCUSOBJ) != NULL) {
|
||||
as3vm_do_focus_event_GC(PTR(player, PL_AS3VM), PTR(player, FOCUSOBJ),
|
||||
0x32, result, 0, 0);
|
||||
}
|
||||
PTR(player, FOCUSOBJ) = result;
|
||||
as3vm_do_focus_event_GC(PTR(player, PL_AS3VM), result, 0x31, result, 0,
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:4279-4340 iggy_set_mouseover_list -- exported: reset the "just
|
||||
* clicked" bounds tracker and re-run do_mouseover from the stage root. */
|
||||
void iggy_set_mouseover_list(void *player) {
|
||||
float identity[6];
|
||||
void *stage = AT(player, PL_STAGE);
|
||||
identity[0] = 1.0f;
|
||||
identity[1] = 0.0f;
|
||||
identity[2] = 0.0f;
|
||||
identity[3] = 1.0f;
|
||||
identity[4] = 0.0f;
|
||||
identity[5] = 0.0f;
|
||||
iggy_set_bounds(player, identity);
|
||||
{
|
||||
/* durango swaps PL_MOUSEOVER_PREV <-> PL_MOUSEOVER_CUR, then clears both
|
||||
* PL_MOUSEOVER_CUR/PL_MOUSEOVER_CUR2 before the fresh top-down walk. */
|
||||
void *saved = PTR(player, PL_MOUSEOVER_CUR);
|
||||
PTR(player, PL_MOUSEOVER_PREV) = saved;
|
||||
PTR(player, PL_MOUSEOVER_CUR) = NULL;
|
||||
PTR(player, PL_MOUSEOVER_CUR2) = NULL;
|
||||
}
|
||||
identity[0] = F32(player, PL_SCALE_X);
|
||||
identity[1] = F32(player, PL_SCALE_Y);
|
||||
identity[2] = 0.0f;
|
||||
identity[3] = 0.0f;
|
||||
identity[4] = 0.0f;
|
||||
identity[5] = 0.0f;
|
||||
do_mouseover(player, stage, identity, 0, NULL, 0, 0);
|
||||
if (PTR(player, PL_MOUSEOVER_CUR) == AT(player, PL_ROOT)) {
|
||||
PTR(player, PL_MOUSEOVER_CUR) = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:5231-5269 process_input_event -- pre-focus-routing input gate. The
|
||||
* durango body opens with an opaque 16-way jump table over `*ev - 1` (0x199f8
|
||||
* table) that is NOT recoverable from the vita/orbis raws (process_input_event
|
||||
* does not appear as a separate symbol in either -- it is presumably inlined
|
||||
* at its single call site there). The 16 short-circuit cases are left as a
|
||||
* residual (falling through to the visible logic below, which is the real
|
||||
* body for every *ev value outside 1..16); see report. */
|
||||
static uint64_t process_input_event(void *player, int *ev, void **p3) {
|
||||
/* The durango body opens with an opaque 16-way jump table over `*ev - 1`
|
||||
* (&__ImageBase + 0x199f8); the case bodies are the switch below, recovered
|
||||
* from the orbis raw (raw/orbis/swf_play.c:4116-4230 where the identical
|
||||
* dispatch is inlined into IggyPlayerDispatchEventRS_core), factored back
|
||||
* into the durango-only helpers process_mouse_event / process_mouse_move /
|
||||
* process_mouse_wheel / process_key_event / is_focused_input. */
|
||||
uint32_t evflags = (uint32_t)ev[1];
|
||||
uint32_t focus_status = 0;
|
||||
uint32_t extra = 0;
|
||||
uint32_t local[4];
|
||||
void *focus = PTR(player, FOCUSOBJ);
|
||||
if (U8(player, PL_FRAMESCRIPT_FLAG) != 0) {
|
||||
return 0;
|
||||
}
|
||||
local[0] = evflags;
|
||||
local[1] = 0;
|
||||
local[2] = 0;
|
||||
local[3] = 0;
|
||||
if ((unsigned)(*ev - 1) < 0x10) {
|
||||
unsigned code = 0;
|
||||
switch (*ev) {
|
||||
case 1: code = 0x24; goto mouse;
|
||||
case 2: code = 0x28; goto mouse;
|
||||
case 3: code = 0x2b; goto mouse;
|
||||
case 4: code = 0x2c; goto mouse;
|
||||
case 5: code = 0x22; goto mouse;
|
||||
case 6:
|
||||
code = 0x23;
|
||||
mouse:
|
||||
process_mouse_event(player, (char)code, local);
|
||||
break;
|
||||
case 7:
|
||||
process_mouse_move(player, (unsigned)ev[2], (unsigned)ev[3], local, 1);
|
||||
break;
|
||||
case 8:
|
||||
process_mouse_wheel(player, (uint8_t)ev[4], local);
|
||||
break;
|
||||
case 9:
|
||||
process_key_event(player, 0, (unsigned)ev[4], ev[5], local);
|
||||
if ((evflags & 1) == 0 && is_focused_input(player) != 0) {
|
||||
local[0] = local[0] | 1;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
/* raw/orbis:4165-4192 (LAB_00107269) after edittext_keydown fires and
|
||||
* AS3VM is present: reinit the interpreter AND, if the focus is still an
|
||||
* editable textfield, dispatch displayobject event 10. */
|
||||
if (process_key_event(player, 1, (unsigned)ev[4], ev[5], local) == 0 &&
|
||||
(evflags & 1) == 0 && is_focused_input(player) != 0) {
|
||||
local[0] = local[0] | 1;
|
||||
if (iggy_edittext_keydown(player, ev[4]) != 0 &&
|
||||
PTR(player, PL_AS3VM) != NULL) {
|
||||
as3vm_interpreter_initialize(PTR(player, PL_AS3VM));
|
||||
if (is_focused_input(player) != 0) {
|
||||
as3vm_do_displayobject_event_GC(PTR(player, PL_AS3VM),
|
||||
PTR(player, FOCUSOBJ), 10, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0xb:
|
||||
/* raw/orbis:4188-4200 guard: focus present AND modifier bit clear
|
||||
* ((lVar1==0)||(uVar7!=0))->break; then the edittext_char + LAB_00107269
|
||||
* tail (displayobject event 10) shared with case 0xa. */
|
||||
if (focus != NULL && (evflags & 1) == 0 && I8(focus, 3) == 6 &&
|
||||
is_focused_input(player) != 0 &&
|
||||
as3vm_do_keyboard_event_GC(PTR(player, PL_AS3VM), focus, 0x37, 0,
|
||||
ev[4], 0) == 0) {
|
||||
local[0] = local[0] | 1;
|
||||
if (iggy_edittext_char(player, ev[4]) != 0 &&
|
||||
PTR(player, PL_AS3VM) != NULL) {
|
||||
as3vm_interpreter_initialize(PTR(player, PL_AS3VM));
|
||||
if (is_focused_input(player) != 0) {
|
||||
as3vm_do_displayobject_event_GC(PTR(player, PL_AS3VM),
|
||||
PTR(player, FOCUSOBJ), 10, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0xc:
|
||||
as3vm_do_direct_event_GC(PTR(player, PL_AS3VM), 1);
|
||||
break;
|
||||
case 0xd:
|
||||
as3vm_do_direct_event_GC(PTR(player, PL_AS3VM), 2);
|
||||
break;
|
||||
case 0xe:
|
||||
as3vm_do_displayobject_event_GC(PTR(player, PL_AS3VM),
|
||||
AT(player, PL_STAGE), 0x16, 0);
|
||||
break;
|
||||
case 0xf:
|
||||
as3vm_do_direct_event_GC(PTR(player, PL_AS3VM), 5);
|
||||
break;
|
||||
case 0x10:
|
||||
if (focus != NULL &&
|
||||
as3vm_do_focus_event_GC(PTR(player, PL_AS3VM), focus, 0x34, 0, 0,
|
||||
1) == 0) {
|
||||
void *cur = PTR(player, FOCUSOBJ);
|
||||
if (cur != NULL) {
|
||||
as3vm_do_focus_event_GC(PTR(player, PL_AS3VM), cur, 0x32, 0, 0, 0);
|
||||
}
|
||||
PTR(player, FOCUSOBJ) = NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* raw/orbis:4231-4242 focus GAINED (new!=0 && old==0) -> 1; focus LOST
|
||||
* (new==0 && old!=0) -> 2; unchanged -> 0. (`focus` is the entry value,
|
||||
* FOCUSOBJ the exit value; the durango tail is decompiler-corrupted so orbis
|
||||
* is authoritative.) */
|
||||
{
|
||||
void *newfocus = PTR(player, FOCUSOBJ);
|
||||
if (newfocus != NULL && focus == NULL) {
|
||||
focus_status = 1;
|
||||
} else if (newfocus == NULL && focus != NULL) {
|
||||
focus_status = 2;
|
||||
} else {
|
||||
focus_status = 0;
|
||||
}
|
||||
}
|
||||
if (p3 != NULL) {
|
||||
/* output struct = three u32s {flags@0, status@4, extra@8}; orbis writes
|
||||
* local_48 (extra) at +8 unconditionally -- literal 8, not sizeof(void*)
|
||||
* (which would clobber status@4 on 32-bit). */
|
||||
*(uint32_t *)p3 = local[0];
|
||||
*(uint32_t *)AT(p3, 4) = focus_status;
|
||||
*(uint32_t *)AT(p3, 8) = extra;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:5270-5368 process_key_event -- keyboard dispatch: derive the mapped
|
||||
* (shifted) character via shift_mapping, update the live modifier-toggle
|
||||
* bytes for Shift/Ctrl/Alt/vk-0xf, fire the AS3 keyboard event, then (Tab)
|
||||
* drive seek_focus and the resulting textfield select-all. */
|
||||
static uint64_t process_key_event(void *player, int p2, unsigned p3, int p4,
|
||||
unsigned *p5) {
|
||||
void *focus_before = PTR(player, FOCUSOBJ);
|
||||
uint8_t modidx = U8(player, PL_MODSTATE);
|
||||
unsigned mapped;
|
||||
uint64_t result;
|
||||
void *evtTarget;
|
||||
|
||||
if (p3 - 0x41 < 0x1a) {
|
||||
mapped = p3 + 0x20u - (unsigned)modidx * 0x20u;
|
||||
} else if (p3 == 0x20) {
|
||||
mapped = 0x20;
|
||||
} else {
|
||||
int i;
|
||||
mapped = p3;
|
||||
for (i = 0; i < SHIFT_MAPPING_ENTRIES; i++) {
|
||||
if (shift_mapping[i * 3] == (uint8_t)p3) {
|
||||
mapped = shift_mapping[i * 3 + 1 + modidx];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p3 == 0xf) {
|
||||
U8(player, PL_KEY0F_LO + (p4 == 2)) = (uint8_t)p2;
|
||||
U8(player, PL_MOD0F) = U8(player, PL_KEY0F_LO) | U8(player, PL_KEY0F_HI);
|
||||
} else if (p3 == 0x10) {
|
||||
U8(player, PL_KEY10_LO + (p4 == 2)) = (uint8_t)p2;
|
||||
U8(player, PL_MOD10) = U8(player, PL_KEY10_LO) | U8(player, PL_KEY10_HI);
|
||||
} else if (p3 == 0x11) {
|
||||
U8(player, PL_KEY11_LO + (p4 == 2)) = (uint8_t)p2;
|
||||
U8(player, PL_MOD11) = U8(player, PL_KEY11_LO) | U8(player, PL_KEY11_HI);
|
||||
} else if (p3 == 0x12) {
|
||||
U8(player, PL_KEY12_LO + (p4 == 2)) = (uint8_t)p2;
|
||||
U8(player, PL_MOD12) = U8(player, PL_KEY12_LO) | U8(player, PL_KEY12_HI);
|
||||
}
|
||||
|
||||
as3vm_interpreter_initialize(PTR(player, PL_AS3VM));
|
||||
evtTarget = AT(player, PL_STAGE);
|
||||
if (PTR(player, FOCUSOBJ) != NULL && (*p5 & 1) == 0) {
|
||||
*p5 = *p5 | 1;
|
||||
evtTarget = PTR(player, FOCUSOBJ);
|
||||
}
|
||||
result = as3vm_do_keyboard_event_GC(PTR(player, PL_AS3VM), evtTarget,
|
||||
(p2 == 0) ? 0x36 : 0x35, p3, mapped, p4);
|
||||
if ((*p5 & 2) != 0) {
|
||||
return result;
|
||||
}
|
||||
if (p3 != 9) {
|
||||
return result;
|
||||
}
|
||||
if (p2 == 0) {
|
||||
return result;
|
||||
}
|
||||
{
|
||||
int dir = (U8(player, PL_MODSTATE) != 0) ? -1 : 1;
|
||||
seek_focus(player, dir);
|
||||
}
|
||||
if (PTR(player, FOCUSOBJ) != NULL) {
|
||||
*p5 = *p5 | 2;
|
||||
{
|
||||
void *tf = PTR(PTR(player, FOCUSOBJ), MV_TFSTRUCT);
|
||||
if (tf != NULL && I8(tf, MV_TFEDIT) != 0) {
|
||||
iggy_textfield_select_all(tf);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PTR(player, FOCUSOBJ) != NULL) {
|
||||
if (focus_before == NULL) {
|
||||
p5[1] = 1;
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (focus_before != NULL) {
|
||||
p5[1] = 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
369
iggy-decompiled/src/reconstructed/swf_play_input2.inc
Normal file
369
iggy-decompiled/src/reconstructed/swf_play_input2.inc
Normal file
@@ -0,0 +1,369 @@
|
||||
/*
|
||||
* swf_play_input2.inc -- mouse button / move / wheel dispatch:
|
||||
* process_mouse_event (button down/up/dblclick state machine + AS3 mouse
|
||||
* event dispatch), process_mouse_move (drag-rect clamping + do_mouse_overing
|
||||
* driver), process_mouse_wheel. Split out of swf_play_input.inc to stay
|
||||
* under the 800-line budget. durango raw line ranges cited per function;
|
||||
* 32-bit offsets derived from the vita raw (confirmed for every field below
|
||||
* via direct llvm-objdump cross-check against the durango .obj).
|
||||
*/
|
||||
|
||||
#if IGGY_PTR64
|
||||
# define PL_CLICKSEQ 0x2975 /* byte: down/up click-sequence state. */
|
||||
# define PL_CLICKTIMERSTATE 0x2976 /* byte: double-click timer state. */
|
||||
# define PL_CLICKTIMER_STAMP 0x2990 /* double: click timer start (seconds). */
|
||||
# define PL_CLICKTIMER_TARGET 0x29c8 /* ptr: click-timer's candidate target. */
|
||||
# define PL_CLICKTARGET 0x29a0 /* ptr: last mouse-down/press target. */
|
||||
# define PL_DRAGTARGET 0x29f0 /* ptr: IggyPlayerStartDrag target. */
|
||||
# define PL_DRAG_MINX 0x29e0
|
||||
# define PL_DRAG_MINY 0x29e4
|
||||
# define PL_DRAG_MAXX 0x29e8
|
||||
# define PL_DRAG_MAXY 0x29ec
|
||||
# define PL_DRAG_OFFX 0x2a00
|
||||
# define PL_DRAG_OFFY 0x2a04
|
||||
#else
|
||||
# define PL_CLICKSEQ 0x225d
|
||||
# define PL_CLICKTIMERSTATE 0x225e
|
||||
# define PL_CLICKTIMER_STAMP 0x2278
|
||||
# define PL_CLICKTIMER_TARGET 0x2298
|
||||
# define PL_CLICKTARGET 0x2284
|
||||
# define PL_DRAGTARGET 0x22b8
|
||||
# define PL_DRAG_MINX 0x22a8
|
||||
# define PL_DRAG_MINY 0x22ac
|
||||
# define PL_DRAG_MAXX 0x22b0
|
||||
# define PL_DRAG_MAXY 0x22b4
|
||||
# define PL_DRAG_OFFX 0x22c0
|
||||
# define PL_DRAG_OFFY 0x22c4
|
||||
#endif
|
||||
|
||||
/* raw:5369-5563 process_mouse_event -- button-state machine driving AS3
|
||||
* mouseDown/mouseUp/click/doubleClick, folded verbatim from durango's labels
|
||||
* (LAB_0000b331/b490/b497/b519/b520/b49d/b4ec below as
|
||||
* click_target/timer_reset/timer_dispatch/finish/update_buttons/
|
||||
* fire_click_check/fire_click). */
|
||||
static void process_mouse_event(void *player, char p2, unsigned *p3) {
|
||||
void *stage = AT(player, PL_STAGE);
|
||||
void *cur = PTR(player, PL_MOUSEOVER_CUR);
|
||||
void *target = stage;
|
||||
unsigned already = *p3 & 1;
|
||||
int propagated = 0;
|
||||
uint32_t handled;
|
||||
float evt[4] = {0}; /* x@0, y@4, clickCount@8 (u16), delta@10 (i8). */
|
||||
uint32_t evt_flags;
|
||||
|
||||
if (cur != NULL && already == 0) {
|
||||
*p3 = *p3 | 1;
|
||||
target = cur;
|
||||
}
|
||||
if (p2 == '$') {
|
||||
U8(player, PL_CLICKBTN) = 1;
|
||||
} else if (p2 == '(') {
|
||||
U8(player, PL_CLICKBTN) = 0;
|
||||
}
|
||||
as3vm_interpreter_initialize(PTR(player, PL_AS3VM));
|
||||
evt[0] = F32(player, PL_EVMOUSE_X);
|
||||
evt[1] = F32(player, PL_EVMOUSE_Y);
|
||||
|
||||
if (p2 == '$' && U8(player, PL_CLICKSEQ) == 0 && already == 0) {
|
||||
void *focustest = (target == AT(player, PL_ROOT)) ? stage : target;
|
||||
if (focustest == NULL || (U8(focustest, MV_BA) & 0x80) != 0 ||
|
||||
PTR(focustest, MV_TFSTRUCT) != NULL || focustest == stage) {
|
||||
void *focusobj = (target == AT(player, PL_ROOT)) ? NULL : focustest;
|
||||
iggy_set_focus_typed(player, 0x34, focusobj, 0);
|
||||
}
|
||||
U8(player, PL_CLICKSEQ) = 1;
|
||||
PTR(player, PL_CLICKTARGET) = focustest;
|
||||
if (target != NULL && U8(target, MV_TYPE) == 6 &&
|
||||
PTR(target, MV_TFSTRUCT) != NULL) {
|
||||
float xform[6];
|
||||
float lx, ly;
|
||||
iggy_get_o2w(player, target, xform);
|
||||
iggy_inverse_transform(&lx, &ly, xform, F32(player, PL_EVMOUSE_X));
|
||||
iggy_edittext_down(player, target, lx, ly);
|
||||
}
|
||||
}
|
||||
|
||||
propagated = 0;
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evt, target, p2, 0, 1, &propagated);
|
||||
handled = (uint32_t)propagated;
|
||||
|
||||
if (p2 == '+') {
|
||||
if (U8(player, PL_CLICKSEQ) == 0) {
|
||||
U8(player, PL_CLICKSEQ) = 2;
|
||||
goto click_target;
|
||||
}
|
||||
} else if (p2 == '"' && U8(player, PL_CLICKSEQ) == 0) {
|
||||
U8(player, PL_CLICKSEQ) = 3;
|
||||
goto click_target;
|
||||
}
|
||||
if (0) {
|
||||
click_target:
|
||||
PTR(player, PL_CLICKTARGET) = target;
|
||||
}
|
||||
|
||||
evt_flags = U8(player, PL_CLICKTIMERSTATE);
|
||||
if (evt_flags == 0) {
|
||||
if (p2 == '$' && U8(player, PL_CLICKSEQ) == 1) {
|
||||
U8(player, PL_CLICKTIMERSTATE) = 1;
|
||||
PTR(player, PL_CLICKTIMER_TARGET) = target;
|
||||
F64(player, PL_CLICKTIMER_STAMP) =
|
||||
(double)iggy_get_seconds_best_effort(player);
|
||||
goto update_buttons;
|
||||
}
|
||||
timer_reset:
|
||||
U8(player, PL_CLICKTIMERSTATE) = 0;
|
||||
timer_dispatch:
|
||||
if (p2 == '(') {
|
||||
goto fire_click_check;
|
||||
}
|
||||
if (p2 == ',') {
|
||||
if (U8(player, PL_CLICKSEQ) != 2 ||
|
||||
target != PTR(player, PL_CLICKTARGET)) {
|
||||
goto finish;
|
||||
}
|
||||
goto fire_click_with_type_2a;
|
||||
}
|
||||
if (p2 != '#') {
|
||||
goto update_buttons;
|
||||
}
|
||||
if (U8(player, PL_CLICKSEQ) == 3 &&
|
||||
target == PTR(player, PL_CLICKTARGET)) {
|
||||
goto fire_click_with_type_21;
|
||||
}
|
||||
} else if (evt_flags == 1) {
|
||||
if (p2 != '(') {
|
||||
goto timer_dispatch;
|
||||
}
|
||||
U8(player, PL_CLICKTIMERSTATE) = 2;
|
||||
fire_click_check:
|
||||
if (U8(player, PL_CLICKSEQ) == 1 && target == PTR(player, PL_CLICKTARGET)) {
|
||||
uint32_t extra;
|
||||
propagated = 0;
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evt, target, 0x1e, 0, 1, &propagated);
|
||||
extra = (uint32_t)propagated;
|
||||
handled = handled | extra;
|
||||
}
|
||||
} else if (evt_flags == 2) {
|
||||
if (p2 == '$') {
|
||||
if (target == PTR(player, PL_CLICKTIMER_TARGET)) {
|
||||
U8(player, PL_CLICKTIMERSTATE) = 3;
|
||||
} else {
|
||||
U8(player, PL_CLICKTIMERSTATE) = 1;
|
||||
PTR(player, PL_CLICKTIMER_TARGET) = target;
|
||||
F64(player, PL_CLICKTIMER_STAMP) =
|
||||
(double)iggy_get_seconds_best_effort(player);
|
||||
}
|
||||
goto update_buttons;
|
||||
}
|
||||
goto timer_dispatch;
|
||||
} else if (evt_flags == 3) {
|
||||
if (p2 != '(') {
|
||||
goto timer_reset;
|
||||
}
|
||||
if (target == PTR(player, PL_CLICKTIMER_TARGET)) {
|
||||
double now = (double)iggy_get_seconds_best_effort(player);
|
||||
if (now < F64(player, PL_CLICKTIMER_STAMP) +
|
||||
(double)iggy_double_click_time) {
|
||||
void *dbl = PTR(player, PL_CLICKTARGET);
|
||||
if (dbl != NULL && (U8(dbl, MV_BA) & 4) != 0) {
|
||||
uint32_t extra;
|
||||
U8(player, PL_CLICKSEQ) = 0;
|
||||
propagated = 0;
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evt, dbl, 0x20, 0, 1, &propagated);
|
||||
extra = (uint32_t)propagated;
|
||||
handled = handled | extra;
|
||||
}
|
||||
U8(player, PL_CLICKTIMERSTATE) = 0;
|
||||
goto fire_click_check;
|
||||
}
|
||||
}
|
||||
U8(player, PL_CLICKTIMERSTATE) = 2;
|
||||
PTR(player, PL_CLICKTIMER_TARGET) = target;
|
||||
F64(player, PL_CLICKTIMER_STAMP) =
|
||||
(double)iggy_get_seconds_best_effort(player);
|
||||
goto fire_click_check;
|
||||
}
|
||||
goto finish;
|
||||
|
||||
fire_click_with_type_2a:
|
||||
{
|
||||
uint32_t propagated = 0, extra;
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evt, target, 0x2a, 0, 1, &propagated);
|
||||
extra = (uint32_t)propagated;
|
||||
handled = handled | extra;
|
||||
}
|
||||
goto update_buttons;
|
||||
fire_click_with_type_21:
|
||||
{
|
||||
uint32_t propagated = 0, extra;
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evt, target, 0x21, 0, 1, &propagated);
|
||||
extra = (uint32_t)propagated;
|
||||
handled = handled | extra;
|
||||
}
|
||||
goto update_buttons;
|
||||
|
||||
finish:
|
||||
U8(player, PL_CLICKSEQ) = 0;
|
||||
update_buttons:
|
||||
swf_update_buttons(player, stage, PTR(player, PL_MOUSEOVER_CUR),
|
||||
U8(player, PL_CLICKBTN));
|
||||
if (propagated != 0) {
|
||||
*p3 = *p3 | 8;
|
||||
}
|
||||
if (handled != 0) {
|
||||
*p3 = *p3 | 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:5567-5687 process_mouse_move -- rescale the raw pixel position by the
|
||||
* stage-to-device scale, clamp any active drag target's local position into
|
||||
* its drag rect, drive do_mouse_overing, splice the drag-target's owner-list
|
||||
* linkage (durango offsets +0x18/+0x28/+0x30 relative to the drag-target
|
||||
* object -- these are NOT movie-node fields; the 32-bit values below are
|
||||
* halved from durango since no independent vita confirmation of this small
|
||||
* link-list sub-structure was found; flagged in the report), then (if
|
||||
* dragging a textfield caret) update the caret via iggy_edittext_drag. */
|
||||
static void process_mouse_move(void *player, unsigned p2, unsigned p3,
|
||||
void *p4, int p5) {
|
||||
float oldx = F32(player, PL_EVMOUSE_X);
|
||||
float oldy = F32(player, PL_EVMOUSE_Y);
|
||||
if (I32(player, PL_INITIALIZED) == 0) {
|
||||
return;
|
||||
}
|
||||
if (F32(player, PL_SCALE_X) != 0.0f) {
|
||||
F32(player, PL_EVMOUSE_X) = (float)(int)p2 / F32(player, PL_SCALE_X);
|
||||
}
|
||||
if (F32(player, PL_SCALE_Y) != 0.0f) {
|
||||
F32(player, PL_EVMOUSE_Y) = (float)(int)p3 / F32(player, PL_SCALE_Y);
|
||||
}
|
||||
if (U8(player, PL_CLICKSEQ) == 0) {
|
||||
PTR(player, PL_CAPTURED) = NULL;
|
||||
}
|
||||
if (F32(player, PL_EVMOUSE_X) != oldx || F32(player, PL_EVMOUSE_Y) != oldy) {
|
||||
F32(player, PL_MOUSE_X) = (float)(int)p2;
|
||||
F32(player, PL_MOUSE_Y) = (float)(int)p3;
|
||||
}
|
||||
{
|
||||
void *dragtarget = PTR(player, PL_DRAGTARGET);
|
||||
if (dragtarget != NULL) {
|
||||
void *root = dragtarget;
|
||||
void *walk;
|
||||
for (walk = PTR(dragtarget, MV_PARENT); walk != NULL;
|
||||
walk = PTR(walk, MV_PARENT)) {
|
||||
root = walk;
|
||||
}
|
||||
if (root == AT(player, PL_STAGE)) {
|
||||
float xform[6];
|
||||
float lx, ly;
|
||||
void *o2w_target = (PTR(dragtarget, MV_PARENT) != NULL)
|
||||
? PTR(dragtarget, MV_PARENT)
|
||||
: AT(player, PL_STAGE);
|
||||
iggy_get_o2w(player, o2w_target, xform);
|
||||
iggy_inverse_transform(&lx, &ly, xform, F32(player, PL_EVMOUSE_Y));
|
||||
lx = lx + F32(player, PL_DRAG_OFFX);
|
||||
ly = ly + F32(player, PL_DRAG_OFFY);
|
||||
if (lx < F32(player, PL_DRAG_MINX)) {
|
||||
lx = F32(player, PL_DRAG_MINX);
|
||||
}
|
||||
if (ly < F32(player, PL_DRAG_MINY)) {
|
||||
ly = F32(player, PL_DRAG_MINY);
|
||||
}
|
||||
if (F32(player, PL_DRAG_MAXX) < lx) {
|
||||
lx = F32(player, PL_DRAG_MAXX);
|
||||
}
|
||||
if (F32(player, PL_DRAG_MAXY) < ly) {
|
||||
ly = F32(player, PL_DRAG_MAXY);
|
||||
}
|
||||
F32(dragtarget, 0xe8) = lx;
|
||||
F32(dragtarget, 0xec) = ly;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do_mouse_overing(player, p4, p5);
|
||||
|
||||
{
|
||||
void *dragtarget = PTR(player, PL_DRAGTARGET);
|
||||
if (dragtarget != NULL) {
|
||||
#if IGGY_PTR64
|
||||
# define DRAG_OWNER 0x18
|
||||
# define DRAG_PREV 0x28
|
||||
# define DRAG_NEXT 0x30
|
||||
#else
|
||||
# define DRAG_OWNER 0x0c
|
||||
# define DRAG_PREV 0x14
|
||||
# define DRAG_NEXT 0x18
|
||||
#endif
|
||||
void *owner = PTR(dragtarget, DRAG_OWNER);
|
||||
if (owner != NULL) {
|
||||
if (PTR(owner, DRAG_PREV) == dragtarget) {
|
||||
PTR(owner, DRAG_PREV) = PTR(dragtarget, DRAG_NEXT);
|
||||
} else {
|
||||
void *n = PTR(owner, DRAG_NEXT);
|
||||
while (PTR(n, DRAG_NEXT) != dragtarget) {
|
||||
n = PTR(n, DRAG_NEXT);
|
||||
}
|
||||
PTR(n, DRAG_NEXT) = PTR(PTR(n, DRAG_NEXT), DRAG_NEXT);
|
||||
}
|
||||
PTR(dragtarget, DRAG_OWNER) = NULL;
|
||||
}
|
||||
{
|
||||
void *newowner = PTR(player, PL_MOUSEOVER_CUR2);
|
||||
PTR(dragtarget, DRAG_OWNER) = newowner;
|
||||
if (newowner != NULL) {
|
||||
PTR(dragtarget, DRAG_NEXT) = PTR(newowner, DRAG_PREV);
|
||||
PTR(newowner, DRAG_PREV) = dragtarget;
|
||||
}
|
||||
}
|
||||
if (PTR(player, PL_MOUSEOVER_CUR2) != NULL) {
|
||||
as3vm_get_movie_as3value_GC(player, dragtarget);
|
||||
}
|
||||
#undef DRAG_OWNER
|
||||
#undef DRAG_PREV
|
||||
#undef DRAG_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
if (p5 != 0 && U8(player, PL_CLICKSEQ) == 1) {
|
||||
void *target = PTR(player, PL_CLICKTARGET);
|
||||
if (target != NULL && U8(target, MV_TYPE) == 6 &&
|
||||
PTR(target, MV_TFSTRUCT) != NULL) {
|
||||
float xform[6];
|
||||
float lx, ly;
|
||||
iggy_get_o2w(player, target, xform);
|
||||
iggy_inverse_transform(&lx, &ly, xform, F32(player, PL_EVMOUSE_X));
|
||||
iggy_edittext_drag(player, target, lx, ly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:5691-5737 process_mouse_wheel -- fires the AS3 mouseWheel event at the
|
||||
* currently-captured object (or the stage). */
|
||||
static void process_mouse_wheel(void *player, uint8_t p2, unsigned *p3) {
|
||||
if ((*p3 & 1) == 0) {
|
||||
void *target = PTR(player, PL_MOUSEOVER_CUR);
|
||||
int propagated = 0;
|
||||
float evt[4] = {0}; /* x@0, y@4, clickCount@8, delta@10. */
|
||||
uint32_t handled;
|
||||
if (target == NULL) {
|
||||
target = AT(player, PL_STAGE);
|
||||
}
|
||||
as3vm_interpreter_initialize(PTR(player, PL_AS3VM));
|
||||
evt[0] = F32(player, PL_EVMOUSE_X);
|
||||
evt[1] = F32(player, PL_EVMOUSE_Y);
|
||||
/* orbis:4149 stored the wheel delta as local_36 inside the point struct at
|
||||
* +10; related=0 (else the callee derefs it as a DisplayObject), extra is
|
||||
* the arg7 out-flag pointer. */
|
||||
*(int8_t *)((char *)evt + 10) = (int8_t)p2;
|
||||
propagated = 0;
|
||||
as3vm_do_mouse_event_GC(PTR(player, PL_AS3VM), evt, target, 0x29, 0, 1,
|
||||
&propagated);
|
||||
handled = (uint32_t)propagated;
|
||||
if (propagated != 0) {
|
||||
*p3 = *p3 | 9;
|
||||
}
|
||||
if (handled != 0) {
|
||||
*p3 = *p3 | 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
378
iggy-decompiled/src/reconstructed/swf_play_movie.inc
Normal file
378
iggy-decompiled/src/reconstructed/swf_play_movie.inc
Normal file
@@ -0,0 +1,378 @@
|
||||
/*
|
||||
* swf_play_movie.inc -- the movie-object leaf surface: the AS3 value bridge, the
|
||||
* library-mask symbol scan, the weak-pointer test, the movie-default / zero-state
|
||||
* stampers, the empty sprite / shape / button / textfield constructors, the
|
||||
* unparented-list splice and the simple movie predicates. durango raw lines
|
||||
* cited inline; 32-bit offsets derived from the vita raw.
|
||||
*/
|
||||
|
||||
/* -- movie-node field offsets (width-gated; durango / vita). ---------------- */
|
||||
#if IGGY_PTR64
|
||||
#undef MV_FLAG1
|
||||
# define MV_FLAG1 1 /* byte: flag word 1 (bit1 = pending). */
|
||||
#undef MV_TYPE
|
||||
# define MV_TYPE 3 /* byte: movie type tag. */
|
||||
#undef MV_AS3VAL
|
||||
# define MV_AS3VAL 0x20 /* ptr: cached AS3 value slot. */
|
||||
#undef MV_PARENT
|
||||
# define MV_PARENT 0x80 /* ptr: parent movie. */
|
||||
#undef MV_NEXT
|
||||
# define MV_NEXT 0x08 /* ptr: next sibling. */
|
||||
#undef MV_PREV
|
||||
# define MV_PREV 0x88 /* ptr: prev sibling. */
|
||||
#undef MV_NAME
|
||||
# define MV_NAME 0x138 /* ptr: interned name. */
|
||||
#undef MV_B9
|
||||
# define MV_B9 0xb9 /* byte: flag word (bit3 = has-as3). */
|
||||
#undef MV_BA
|
||||
# define MV_BA 0xba
|
||||
#undef MV_BB
|
||||
# define MV_BB 0xbb
|
||||
#undef MV_CLASSPTR
|
||||
# define MV_CLASSPTR 0x18 /* ptr: bound class (when flag1 < 0). */
|
||||
#undef MV_TFSTRUCT
|
||||
# define MV_TFSTRUCT 0x98 /* ptr: EditText sub-struct. */
|
||||
#undef MV_TFEDIT
|
||||
# define MV_TFEDIT 0xea /* byte: editable flag. */
|
||||
#undef MVD_MASK
|
||||
# define MVD_MASK 0xf /* set_movie_defaults low-nibble mask. */
|
||||
#undef MVD_114
|
||||
# define MVD_114 0x114 /* u32: bounds run-fill. */
|
||||
#undef MVD_178
|
||||
# define MVD_178 0x178 /* u32: scale x default 1. */
|
||||
#undef MVD_17C
|
||||
# define MVD_17C 0x17c /* u32: scale y default 1. */
|
||||
#undef LIB_EXPCOUNT
|
||||
# define LIB_EXPCOUNT 0x230
|
||||
#undef LIB_EXPTABLE
|
||||
# define LIB_EXPTABLE 0x228
|
||||
#undef EXP_STRIDE
|
||||
# define EXP_STRIDE 0x18
|
||||
#undef EXP_NAMEOFF
|
||||
# define EXP_NAMEOFF 0x08
|
||||
#undef WEAK_P1
|
||||
# define WEAK_P1 0xd8 /* as3vm ctx nursery pool-list head. */
|
||||
#undef WEAK_P2
|
||||
# define WEAK_P2 0xd0 /* as3vm ctx old pool-list head. */
|
||||
#undef WEAK_LO
|
||||
# define WEAK_LO 0x10 /* pool payload low bound. */
|
||||
#undef WEAK_HI
|
||||
# define WEAK_HI 0x810 /* pool payload high bound. */
|
||||
#undef SP_MALLOC
|
||||
# define SP_MALLOC 0x48
|
||||
#undef SP_TAGONE
|
||||
# define SP_TAGONE 0x28
|
||||
#undef SH_MALLOC
|
||||
# define SH_MALLOC 0x80
|
||||
#undef SH_CTX
|
||||
# define SH_CTX 0x40
|
||||
#undef WRAP_CLEAR
|
||||
# define WRAP_CLEAR 0x178
|
||||
#else
|
||||
#undef MV_FLAG1
|
||||
# define MV_FLAG1 1
|
||||
#undef MV_TYPE
|
||||
# define MV_TYPE 3
|
||||
#undef MV_AS3VAL
|
||||
# define MV_AS3VAL 0x14
|
||||
#undef MV_PARENT
|
||||
# define MV_PARENT 0x44
|
||||
#undef MV_NEXT
|
||||
# define MV_NEXT 0x08
|
||||
#undef MV_PREV
|
||||
# define MV_PREV 0x48
|
||||
#undef MV_NAME
|
||||
# define MV_NAME 0xe0 /* vita instance-name (0x138 durango); objdump-confirmed. */
|
||||
#undef MV_B9
|
||||
# define MV_B9 0x61
|
||||
#undef MV_BA
|
||||
# define MV_BA 0x62
|
||||
#undef MV_BB
|
||||
# define MV_BB 0x63
|
||||
#undef MV_CLASSPTR
|
||||
# define MV_CLASSPTR 0x0c
|
||||
#undef MV_TFSTRUCT
|
||||
# define MV_TFSTRUCT 0x50
|
||||
#undef MV_TFEDIT
|
||||
# define MV_TFEDIT 0xce
|
||||
#undef MVD_MASK
|
||||
# define MVD_MASK 0x7f
|
||||
#undef MVD_114
|
||||
# define MVD_114 0xbc
|
||||
#undef MVD_178
|
||||
# define MVD_178 0x108
|
||||
#undef MVD_17C
|
||||
# define MVD_17C 0x10c
|
||||
#undef LIB_EXPCOUNT
|
||||
# define LIB_EXPCOUNT 0x1f0
|
||||
#undef LIB_EXPTABLE
|
||||
# define LIB_EXPTABLE 0x1ec
|
||||
#undef EXP_STRIDE
|
||||
# define EXP_STRIDE 0x0c
|
||||
#undef EXP_NAMEOFF
|
||||
# define EXP_NAMEOFF 0x04
|
||||
#undef WEAK_P1
|
||||
# define WEAK_P1 0x8c
|
||||
#undef WEAK_P2
|
||||
# define WEAK_P2 0x88
|
||||
#undef WEAK_LO
|
||||
# define WEAK_LO 0x0c
|
||||
#undef WEAK_HI
|
||||
# define WEAK_HI 0x40c
|
||||
#undef SP_MALLOC
|
||||
# define SP_MALLOC 0x24
|
||||
#undef SP_TAGONE
|
||||
# define SP_TAGONE 0x14
|
||||
#undef SH_MALLOC
|
||||
# define SH_MALLOC 0x58
|
||||
#undef SH_CTX
|
||||
# define SH_CTX 0x28
|
||||
#undef WRAP_CLEAR
|
||||
# define WRAP_CLEAR 0x108
|
||||
#endif
|
||||
|
||||
/* raw:540-570 the on-demand AS3 value for a movie node (stage special-cased). */
|
||||
uint64_t as3vm_get_movie_as3value_GC(void *player, void *movie) {
|
||||
if (PTR(movie, MV_AS3VAL) != NULL) {
|
||||
return *(uint64_t *)PTR(movie, MV_AS3VAL);
|
||||
}
|
||||
if (movie == AT(player, PL_STAGE)) {
|
||||
return (uint64_t)(uintptr_t)as3vm_get_stage(PTR(player, PL_AS3VM));
|
||||
}
|
||||
if ((U8(movie, MV_FLAG1) & 1) != 0) {
|
||||
void *v = as3vm_construct_swf_type_GC(PTR(player, PL_AS3VM), U8(movie, MV_TYPE),
|
||||
movie);
|
||||
as3vm_setup_DisplayObject(PTR(player, PL_AS3VM), v, movie);
|
||||
return (uint64_t)(uintptr_t)v;
|
||||
}
|
||||
U8(movie, MV_FLAG1) = U8(movie, MV_FLAG1) | 1;
|
||||
{
|
||||
void *v = as3vm_construct_swf_type_GC(PTR(player, PL_AS3VM), U8(movie, MV_TYPE),
|
||||
movie);
|
||||
as3vm_setup_DisplayObject(PTR(player, PL_AS3VM), v, movie);
|
||||
U8(movie, MV_FLAG1) = U8(movie, MV_FLAG1) & 0xfe;
|
||||
as3vm_pool_free(PTR(player, PL_AS3VM), PTR(movie, MV_AS3VAL));
|
||||
PTR(movie, MV_AS3VAL) = as3vm_pool_alloc(PTR(player, PL_AS3VM), v, 1);
|
||||
iggy_mark_movie_dirty(player, movie);
|
||||
return (uint64_t)(uintptr_t)v;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:577-590 push a bare object's value into the parent's AS3 property table. */
|
||||
static void bind_bare_object(void *player, void *movie) {
|
||||
if (PTR(player, PL_AS3VM) != NULL && (U8(movie, MV_B9) & 8) != 0 &&
|
||||
PTR(movie, MV_AS3VAL) != NULL) {
|
||||
if (PTR(PTR(movie, MV_PARENT), MV_AS3VAL) == NULL) {
|
||||
as3vm_get_movie_as3value_GC(player, movie);
|
||||
}
|
||||
as3vm_set_property_toplevel(PTR(player, PL_AS3VM),
|
||||
*(void **)PTR(PTR(movie, MV_PARENT), MV_AS3VAL),
|
||||
PTR(movie, MV_NAME),
|
||||
*(void **)PTR(movie, MV_AS3VAL));
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:3228-3260 scan the movie's 0x20-bit library mask; for each live library
|
||||
* walk the export table and return the value whose name rrwcscmp-matches. */
|
||||
uint64_t iggy_get_symbol(void *movie, void *name) {
|
||||
unsigned i = 0;
|
||||
do {
|
||||
if (((1u << (i & 0xff)) & U32(movie, MV_LIBMASK)) != 0) {
|
||||
void *lib = iggy_libraries[i];
|
||||
int count = I32(lib, LIB_EXPCOUNT);
|
||||
if (count > 0) {
|
||||
void *table = PTR(lib, LIB_EXPTABLE);
|
||||
intptr_t off = 0;
|
||||
int k = 0;
|
||||
do {
|
||||
if (rrwcscmp(name, *(void **)AT(table, off + EXP_NAMEOFF)) == 0) {
|
||||
return (uint64_t)(uintptr_t) * (void **)AT(table, off);
|
||||
}
|
||||
k = k + 1;
|
||||
off = off + EXP_STRIDE;
|
||||
} while (k < count);
|
||||
}
|
||||
}
|
||||
i = i + 1;
|
||||
} while ((int)i < 0x20);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:3671-3695 (objdump-resolved) a pointer is "weak" iff it lands inside the
|
||||
* AS3 VM nursery pool (ctx+WEAK_P1 list); the old-pool (ctx+WEAK_P2) walk always
|
||||
* returns 0. Range per block is [p+WEAK_LO, p+WEAK_HI). */
|
||||
uint64_t iggy_is_weak_ptr(void *player, void *ptr) {
|
||||
char *pt = (char *)ptr;
|
||||
void *ctx = PTR(player, PL_AS3VM);
|
||||
void *p = PTR(ctx, WEAK_P1);
|
||||
while (p != NULL) {
|
||||
if (pt >= (char *)p + WEAK_LO && pt < (char *)p + WEAK_HI) {
|
||||
return 1;
|
||||
}
|
||||
p = PTR(p, 0);
|
||||
}
|
||||
for (p = PTR(ctx, WEAK_P2); p != NULL; p = PTR(p, 0)) {
|
||||
if (pt >= (char *)p + WEAK_LO && pt < (char *)p + WEAK_HI) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:4343-4364 OR/mask the movie defaults, then the type-switch (the durango
|
||||
* jump table = this vita switch; case 4 reads iggy_force_default_smoothing). */
|
||||
void iggy_set_movie_defaults(void *movie) {
|
||||
uint8_t ba = U8(movie, MV_BA);
|
||||
uint8_t b9 = U8(movie, MV_B9);
|
||||
U8(movie, MV_B9) = b9 | 0x40;
|
||||
U8(movie, 1) = U8(movie, 1) | 2;
|
||||
uint8_t nb = (uint8_t)((ba & MVD_MASK) | 0x70);
|
||||
U32(movie, MVD_114) = 0xffffffff;
|
||||
U32(movie, MVD_178) = 1;
|
||||
U32(movie, MVD_17C) = 1;
|
||||
U8(movie, MV_BA) = nb;
|
||||
switch (U8(movie, MV_TYPE)) {
|
||||
case 3:
|
||||
if ((b9 & 0x10) != 0) {
|
||||
U8(movie, MV_BA) = (uint8_t)((ba & 0x7f) | 0xf0);
|
||||
}
|
||||
U8(movie, 0) = U8(movie, 0) | 0x20;
|
||||
break;
|
||||
case 4:
|
||||
U8(movie, MV_BA) = (uint8_t)(nb & 0xbf);
|
||||
U8(movie, MV_BB) = (uint8_t)((U8(movie, MV_BB) & 0xef) |
|
||||
((uint8_t)((iggy_force_default_smoothing & 1) << 4)));
|
||||
break;
|
||||
case 1:
|
||||
case 5:
|
||||
U8(movie, MV_BA) = (uint8_t)(ba & 0xf);
|
||||
break;
|
||||
case 6:
|
||||
if (PTR(movie, MV_TFSTRUCT) != NULL &&
|
||||
I8(PTR(movie, MV_TFSTRUCT), MV_TFEDIT) != 0) {
|
||||
U8(movie, MV_BA) = (uint8_t)((ba & 0x7f) | 0xf0);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
U8(movie, MV_BA) = (uint8_t)((ba & 0x7f) | 0xf0);
|
||||
U8(movie, 0) = U8(movie, 0) | 0x20;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:4523-4561 memset then the fixed default byte pattern. */
|
||||
void iggy_zero_movie_state(void *movie) {
|
||||
#if IGGY_PTR64
|
||||
memset(movie, 0, 0x1a0);
|
||||
U8(movie, 0xb9) = U8(movie, 0xb9) | 0x41;
|
||||
U8(movie, 0) = U8(movie, 0) & 0xfe;
|
||||
U8(movie, 0xba) = U8(movie, 0xba) | 0x70;
|
||||
U8(movie, 0xda) = 0x80; U8(movie, 0xdb) = 0x3f; /* 1.0f @ 0xd8. */
|
||||
U8(movie, 0xc4) = 0xff; U8(movie, 0xc5) = 0xff;
|
||||
U8(movie, 0xc6) = 0xff; U8(movie, 0xc7) = 0xff;
|
||||
U8(movie, 0xe6) = 0x80; U8(movie, 0xe7) = 0x3f; /* 1.0f @ 0xe4. */
|
||||
U8(movie, 0x170) = 0xff; U8(movie, 0x171) = 0xff;
|
||||
U8(movie, 0x172) = 0xff; U8(movie, 0x173) = 0xff;
|
||||
PTR(movie, 0x180) = IGGY_NULLUNDEF_UNDEF;
|
||||
U8(movie, 0x110) = 0xff; U8(movie, 0x111) = 0xff;
|
||||
U8(movie, 0x114) = 0xff; U8(movie, 0x115) = 0xff;
|
||||
U8(movie, 0x116) = 0xff; U8(movie, 0x117) = 0xff;
|
||||
#else
|
||||
memset(movie, 0, 0x128);
|
||||
U8(movie, 0x6c) = 0xff; U8(movie, 0x6d) = 0xff;
|
||||
U8(movie, 0x6e) = 0xff; U8(movie, 0x6f) = 0xff;
|
||||
U8(movie, 0x82) = 0x80; U8(movie, 0x83) = 0x3f; /* 1.0f @ 0x80. */
|
||||
U8(movie, 0x8e) = 0x80; U8(movie, 0x8f) = 0x3f; /* 1.0f @ 0x8c. */
|
||||
U8(movie, 0x100) = 0xff; U8(movie, 0x101) = 0xff;
|
||||
U8(movie, 0x102) = 0xff; U8(movie, 0x103) = 0xff;
|
||||
U8(movie, 0x61) = U8(movie, 0x61) | 0x41;
|
||||
U8(movie, 0xb8) = 0xff; U8(movie, 0xb9) = 0xff;
|
||||
U8(movie, 0) = U8(movie, 0) & 0xfe;
|
||||
U8(movie, 0xbc) = 0xff; U8(movie, 0xbd) = 0xff;
|
||||
U8(movie, 0xbe) = 0xff; U8(movie, 0xbf) = 0xff;
|
||||
U8(movie, 0x62) = U8(movie, 0x62) | 0x70;
|
||||
PTR(movie, 0x110) = IGGY_NULLUNDEF_UNDEF;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* raw:4371-4381 */
|
||||
void iggy_set_movie_parent(void *player, void *movie, void *parent) {
|
||||
if (PTR(movie, MV_PARENT) != parent) {
|
||||
PTR(movie, MV_PARENT) = parent;
|
||||
iggy_mark_movie_dirty(player);
|
||||
if (parent != NULL) {
|
||||
iggy_mark_movie_dirty(player, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:4388-4400 */
|
||||
int iggy_shape_has_class(void *player, void *movie) {
|
||||
if (I8(movie, MV_FLAG1) < 0) {
|
||||
return PTR(movie, MV_CLASSPTR) != NULL;
|
||||
}
|
||||
return *(void **)AT(PTR(player, PL_LIBS_BASE + (intptr_t)(char)I8(movie, MV_FLAG1) *
|
||||
(intptr_t)sizeof(void *)),
|
||||
(uintptr_t)U16(movie, 2) * sizeof(void *)) != NULL;
|
||||
}
|
||||
|
||||
/* raw:4513-4517 / 2307-2311 intentional no-ops. */
|
||||
void iggy_verify_container(void) {}
|
||||
void iggy_check_display_trees(void) {}
|
||||
|
||||
/* raw:2165-2174 push movie onto the unparented list. */
|
||||
void iggy_add_to_unparented(void *player, void *movie) {
|
||||
PTR(movie, MV_PREV) = NULL;
|
||||
PTR(movie, MV_NEXT) = PTR(player, PL_UNPARENTED);
|
||||
if (PTR(player, PL_UNPARENTED) != NULL) {
|
||||
PTR(PTR(player, PL_UNPARENTED), MV_PREV) = movie;
|
||||
}
|
||||
PTR(player, PL_UNPARENTED) = movie;
|
||||
}
|
||||
|
||||
/* raw:4129-4144 splice movie out of the unparented list. */
|
||||
void iggy_remove_from_unparented(void *player, void *movie) {
|
||||
PTR(movie, MV_PARENT) = NULL;
|
||||
if (PTR(player, PL_UNPARENTED) == movie) {
|
||||
PTR(player, PL_UNPARENTED) = PTR(movie, MV_NEXT);
|
||||
}
|
||||
if (PTR(movie, MV_NEXT) != NULL) {
|
||||
PTR(PTR(movie, MV_NEXT), MV_PREV) = PTR(movie, MV_PREV);
|
||||
}
|
||||
if (PTR(movie, MV_PREV) != NULL) {
|
||||
PTR(PTR(movie, MV_PREV), MV_NEXT) = PTR(movie, MV_NEXT);
|
||||
}
|
||||
PTR(movie, MV_NEXT) = NULL;
|
||||
PTR(movie, MV_PREV) = NULL;
|
||||
}
|
||||
|
||||
/* raw:3737-3758 malloc the sprite object, stamp its type tag (0xff03) + a field,
|
||||
* create the DisplayObject wrapper and clear wrapper+WRAP_CLEAR. */
|
||||
void iggy_make_empty_sprite(void *player) {
|
||||
void *obj = iggy_malloc_fileline(player, 0, SP_MALLOC, 0x15,
|
||||
iggy_swf_play_source_path, 0x3e2);
|
||||
memset(obj, 0, SP_MALLOC);
|
||||
U16(obj, 0) = 0xff03;
|
||||
U16(obj, SP_TAGONE) = 1;
|
||||
{
|
||||
void *wrap = iggy_create_movie_for_actionscript_object(player, obj);
|
||||
U32(wrap, WRAP_CLEAR) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:3717-3730 malloc the shape object, stamp type tag (0xff01), store ctx,
|
||||
* create the wrapper and clear wrapper+WRAP_CLEAR. */
|
||||
void iggy_make_empty_shape(void *player) {
|
||||
void *obj = iggy_malloc_fileline(player, 0, SH_MALLOC, 0x15,
|
||||
iggy_swf_play_source_path, 0x3ef);
|
||||
memset(obj, 0, SH_MALLOC);
|
||||
U16(obj, 0) = 0xff01;
|
||||
PTR(obj, SH_CTX) = player;
|
||||
{
|
||||
void *wrap = iggy_create_movie_for_actionscript_object(player, obj);
|
||||
U32(wrap, WRAP_CLEAR) = 0;
|
||||
}
|
||||
}
|
||||
611
iggy-decompiled/src/reconstructed/swf_play_placeobject.inc
Normal file
611
iggy-decompiled/src/reconstructed/swf_play_placeobject.inc
Normal file
@@ -0,0 +1,611 @@
|
||||
/*
|
||||
* swf_play_placeobject.inc -- the PlaceObject execution engine: resolving a
|
||||
* placement's character definition (by direct pointer or symbol-name lookup),
|
||||
* constructing/reusing the target DisplayObject, splicing it into the parent's
|
||||
* child list (and the depth-indexed lookup array), applying the tag's shared
|
||||
* properties (matrix / color transform / ratio / blend / filters / instance
|
||||
* name), and the preorder/recursive "added"/"addedToStage" event dispatch used
|
||||
* both by PlaceObject and by the raw movie-insertion entry points.
|
||||
*
|
||||
* durango raw line ranges (authoritative for structure):
|
||||
* placeobject_GC 5057-5133 (static, 13-arg)
|
||||
* placeobject_shared 5134-5197 (static)
|
||||
* iggy_do_placeobject_GC 2858-2916 (export)
|
||||
* iggy_do_placement 2815-2857 (export)
|
||||
* iggy_insert_movie_at_GC 3493-3635 (export)
|
||||
* iggy_insert_movie_messages_GC 3636-3668 (export)
|
||||
* preorder_send_displayobject_event_GC 5198-5230 (static)
|
||||
* recursive_send_displayobject_event_GC 5741-5773 (static)
|
||||
*
|
||||
* 32-bit offsets derived directly from raw/vita/swf_play.c; every offset below
|
||||
* was additionally cross-checked against the retail durango object
|
||||
* (llvm-objdump -d -r --disassemble-symbols=<fn> work/iggy-native-decomp/
|
||||
* durango-objects/swf_play.obj), which also resolved every Ghidra-elided call
|
||||
* argument used here.
|
||||
*/
|
||||
|
||||
/* -- movie-node fields used by this unit (width-gated; not already in
|
||||
* swf_play.c or swf_play_movie.inc). MV_FLAG1/MV_TYPE/MV_PARENT/MV_NEXT/
|
||||
* MV_PREV/MV_B9/MV_BA/MV_AS3VAL are already in scope from swf_play_movie.inc
|
||||
* and are reused here unchanged. -------------------------------------------- */
|
||||
#if IGGY_PTR64
|
||||
#undef MV_FIRSTCHILD
|
||||
# define MV_FIRSTCHILD 0x10 /* ptr: first child (simple sibling list). */
|
||||
#undef MV_LASTCHILD
|
||||
# define MV_LASTCHILD 0x90 /* ptr: last child. */
|
||||
#undef MV_DEPTH
|
||||
# define MV_DEPTH 0xc4 /* i32: object's own depth (-1 == unassigned). */
|
||||
#undef MV_DEPTHARRAY
|
||||
# define MV_DEPTHARRAY 0x48 /* ptr: parent's depth-indexed children array. */
|
||||
#undef MV_BC
|
||||
# define MV_BC 0xbc /* byte: bit0=owns-instance-name, bit1=owns-filt*/
|
||||
#undef MV_MATRIX
|
||||
# define MV_MATRIX 0xd8 /* 6 floats (24B): scaleX,skewY,skewX,scaleY,x,y*/
|
||||
#undef MV_UNKB8
|
||||
# define MV_UNKB8 0xb8 /* byte: ratio-adjacent placement byte. */
|
||||
#undef MV_COLORXFORM
|
||||
# define MV_COLORXFORM 0xf0 /* 7 floats (28B): color transform. */
|
||||
#undef MV_RATIO
|
||||
# define MV_RATIO 0x10c /* float: morph-shape ratio (record u16/65535). */
|
||||
#undef MV_BLEND
|
||||
# define MV_BLEND 0x110 /* u16: blend mode. */
|
||||
#undef MV_FILTERLIST
|
||||
# define MV_FILTERLIST 0xb0 /* ptr: AS3 filter array. */
|
||||
#undef MV_FILTERCOUNT
|
||||
# define MV_FILTERCOUNT 0x112 /* byte: filter count (0xff == unset). */
|
||||
#undef MV_INSTNAME
|
||||
# define MV_INSTNAME 0x138 /* ptr: instance-name buffer (owned if BC bit0).*/
|
||||
#undef MV_UNKC0
|
||||
# define MV_UNKC0 0xc0 /* u32: placeobject "characterId"-ish field. */
|
||||
#undef PR_DEPTH
|
||||
# define PR_DEPTH 0x28 /* record: u16 depth. */
|
||||
#undef PR_DEF
|
||||
# define PR_DEF 0x30 /* record: ptr explicit character definition. */
|
||||
#undef PR_FLAGS
|
||||
# define PR_FLAGS 9 /* record: byte flag word. */
|
||||
#undef PR_COLORXFORM
|
||||
# define PR_COLORXFORM 0x48 /* record: ptr to 7x int32 color transform. */
|
||||
#undef PR_UNKB
|
||||
# define PR_UNKB 0xb /* record: byte (-> MV_UNKB8), 0xf == no-change.*/
|
||||
#undef PR_FILTERFLAG
|
||||
# define PR_FILTERFLAG 0xa /* record: byte filter count, 0x7f == no-change.*/
|
||||
#undef PR_FILTERDATA
|
||||
# define PR_FILTERDATA 0x58 /* record: ptr filter array payload. */
|
||||
#undef PR_MATRIX
|
||||
# define PR_MATRIX 0x10 /* record: 6 floats (24B) matrix. */
|
||||
#undef PR_RATIO
|
||||
# define PR_RATIO 0x38 /* record: u16 ratio. */
|
||||
#undef PR_BLEND
|
||||
# define PR_BLEND 0x3a /* record: u16 blend mode. */
|
||||
#undef PR_INSTNAME
|
||||
# define PR_INSTNAME 0x40 /* record: ptr instance name. */
|
||||
#undef PR_CLASSNAME
|
||||
# define PR_CLASSNAME 0x50 /* record: ptr class name (symbol lookup). */
|
||||
#else
|
||||
#undef MV_FIRSTCHILD
|
||||
# define MV_FIRSTCHILD 0x0c
|
||||
#undef MV_LASTCHILD
|
||||
# define MV_LASTCHILD 0x4c
|
||||
#undef MV_DEPTH
|
||||
# define MV_DEPTH 0x6c
|
||||
#undef MV_DEPTHARRAY
|
||||
# define MV_DEPTHARRAY 0x28
|
||||
#undef MV_BC
|
||||
# define MV_BC 0x64
|
||||
#undef MV_MATRIX
|
||||
# define MV_MATRIX 0x80
|
||||
#undef MV_UNKB8
|
||||
# define MV_UNKB8 0x60
|
||||
#undef MV_COLORXFORM
|
||||
# define MV_COLORXFORM 0x98
|
||||
#undef MV_RATIO
|
||||
# define MV_RATIO 0xb4
|
||||
#undef MV_BLEND
|
||||
# define MV_BLEND 0xb8
|
||||
#undef MV_FILTERLIST
|
||||
# define MV_FILTERLIST 0x5c
|
||||
#undef MV_FILTERCOUNT
|
||||
# define MV_FILTERCOUNT 0xba
|
||||
#undef MV_INSTNAME
|
||||
# define MV_INSTNAME 0xe0
|
||||
#undef MV_UNKC0
|
||||
# define MV_UNKC0 0x68
|
||||
#undef PR_DEPTH
|
||||
# define PR_DEPTH 0x24
|
||||
#undef PR_DEF
|
||||
# define PR_DEF 0x28
|
||||
#undef PR_FLAGS
|
||||
# define PR_FLAGS 5
|
||||
#undef PR_COLORXFORM
|
||||
# define PR_COLORXFORM 0x34
|
||||
#undef PR_UNKB
|
||||
# define PR_UNKB 7
|
||||
#undef PR_FILTERFLAG
|
||||
# define PR_FILTERFLAG 6
|
||||
#undef PR_FILTERDATA
|
||||
# define PR_FILTERDATA 0x3c
|
||||
#undef PR_MATRIX
|
||||
# define PR_MATRIX 0xc
|
||||
#undef PR_RATIO
|
||||
# define PR_RATIO 0x2c
|
||||
#undef PR_BLEND
|
||||
# define PR_BLEND 0x2e
|
||||
#undef PR_INSTNAME
|
||||
# define PR_INSTNAME 0x30
|
||||
#undef PR_CLASSNAME
|
||||
# define PR_CLASSNAME 0x38
|
||||
#endif
|
||||
#undef MV_LOCKCOUNT
|
||||
#define MV_LOCKCOUNT 6 /* i16: reentrancy/hold counter (identical both widths).*/
|
||||
|
||||
#if IGGY_PTR64
|
||||
#undef PLACE_CTX_DEPTH_OFF
|
||||
# define PLACE_CTX_DEPTH_OFF 8
|
||||
#undef PLACE_CTX_EXTRA_OFF
|
||||
# define PLACE_CTX_EXTRA_OFF 0xc
|
||||
#else
|
||||
#undef PLACE_CTX_DEPTH_OFF
|
||||
# define PLACE_CTX_DEPTH_OFF 4
|
||||
#undef PLACE_CTX_EXTRA_OFF
|
||||
# define PLACE_CTX_EXTRA_OFF 8
|
||||
#endif
|
||||
|
||||
/* -- the ad-hoc 3-word stack record placeobject_GC builds to hand off to
|
||||
* iggy_do_placement (durango: parent@0, depth@8, extra@0xc; vita: parent@0,
|
||||
* depth@4, extra@8 -- natural struct alignment already reproduces both
|
||||
* layouts without further width-gating). -------------------------------- */
|
||||
struct po_place_ctx {
|
||||
void *parent;
|
||||
int32_t depth;
|
||||
int32_t extra;
|
||||
};
|
||||
|
||||
/* raw:5057-5133 (objdump-confirmed). Resolve/construct the placed object, wire
|
||||
* it into its parent, apply shared placement data and refresh its cached AS3
|
||||
* value. */
|
||||
static void *placeobject_GC(void *player, void *p2, int depth, void *def,
|
||||
void *p5, void *p6, void *record, uint32_t p8,
|
||||
uint32_t p9, void *p10, int p11, int p12,
|
||||
uint8_t p13) {
|
||||
(void)p10; /* durango passes literal 1; never read by the callee. */
|
||||
if (def == NULL) {
|
||||
def = (void *)(uintptr_t)iggy_get_symbol(player, p5);
|
||||
if (def == NULL) {
|
||||
iggy_send_error(player, 0x6a,
|
||||
"Timeline tried to create object of unknown class %S",
|
||||
p5);
|
||||
return NULL;
|
||||
}
|
||||
if (U8(def, 0) >= 0x13) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
struct po_place_ctx place_ctx;
|
||||
place_ctx.parent = p2;
|
||||
place_ctx.depth = depth;
|
||||
place_ctx.extra = (int32_t)p8;
|
||||
|
||||
/* create_movie_GC's real arity is 5 (player,def,p3,p4,name); durango's own
|
||||
* call site shows a 6th arg that the callee never consumes -- drop it. */
|
||||
void *movie = create_movie_GC(player, def, record, p12, p6);
|
||||
if (movie == NULL) {
|
||||
void *deptharray = PTR(p2, MV_DEPTHARRAY);
|
||||
void *existing =
|
||||
*(void **)AT(deptharray, (intptr_t)depth * (intptr_t)sizeof(void *));
|
||||
if (existing != NULL) {
|
||||
iggy_remove_sprite(player, existing, (int)p8, NULL,
|
||||
PTR(player, PL_AS3VM) == NULL, 1);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (p2 != NULL) {
|
||||
iggy_remove_from_unparented(player, movie);
|
||||
if (PTR(movie, MV_PARENT) != p2) {
|
||||
PTR(movie, MV_PARENT) = p2;
|
||||
iggy_mark_movie_dirty(player, movie);
|
||||
iggy_mark_movie_dirty(player, p2);
|
||||
}
|
||||
}
|
||||
|
||||
iggy_do_placement(player, movie, &place_ctx);
|
||||
if (record != NULL) {
|
||||
placeobject_shared(player, movie, record);
|
||||
}
|
||||
U8(movie, MV_BA) &= 0xf7;
|
||||
U32(movie, MV_UNKC0) = p9;
|
||||
if (record != NULL || p12 != 0) {
|
||||
if (p11 == 0) {
|
||||
if (I8(movie, MV_TYPE) == 7) {
|
||||
bind_bare_object(player, movie);
|
||||
} else {
|
||||
create_from_null_GC(player, movie, p12, 1);
|
||||
}
|
||||
} else {
|
||||
U8(movie, MV_FLAG1) &= 0xfd;
|
||||
}
|
||||
}
|
||||
U8(movie, MV_B9) &= 0xdf;
|
||||
U8(movie, MV_B9) |= (uint8_t)((p13 & 1) << 5);
|
||||
if ((p12 != 0 || I8(movie, MV_TYPE) == 7) && PTR(movie, MV_AS3VAL) != NULL) {
|
||||
void *old_val = *(void **)PTR(movie, MV_AS3VAL);
|
||||
as3vm_pool_free(PTR(player, PL_AS3VM), PTR(movie, MV_AS3VAL));
|
||||
PTR(movie, MV_AS3VAL) = as3vm_pool_alloc(PTR(player, PL_AS3VM), old_val, 1);
|
||||
iggy_mark_movie_dirty(player, movie);
|
||||
}
|
||||
return movie;
|
||||
}
|
||||
|
||||
/* raw:5134-5197 (objdump-confirmed). Apply a placement record's shared
|
||||
* (non-creation) properties onto an already-resolved display object. */
|
||||
static void placeobject_shared(void *player, void *movie, void *record) {
|
||||
if (movie == NULL) {
|
||||
return;
|
||||
}
|
||||
if ((U8(record, PR_FLAGS) & 2) != 0) {
|
||||
void *cx = PTR(record, PR_COLORXFORM);
|
||||
*(uint32_t *)AT(movie, MV_COLORXFORM) = *(uint32_t *)AT(cx, 0);
|
||||
*(uint32_t *)AT(movie, MV_COLORXFORM + 4) = *(uint32_t *)AT(cx, 4);
|
||||
*(uint32_t *)AT(movie, MV_COLORXFORM + 8) = *(uint32_t *)AT(cx, 8);
|
||||
*(uint32_t *)AT(movie, MV_COLORXFORM + 0xc) = *(uint32_t *)AT(cx, 0xc);
|
||||
*(uint32_t *)AT(movie, MV_COLORXFORM + 0x10) = *(uint32_t *)AT(cx, 0x10);
|
||||
*(uint32_t *)AT(movie, MV_COLORXFORM + 0x14) = *(uint32_t *)AT(cx, 0x14);
|
||||
*(uint32_t *)AT(movie, MV_COLORXFORM + 0x18) = *(uint32_t *)AT(cx, 0x18);
|
||||
}
|
||||
if (I8(record, PR_UNKB) != 0xf) {
|
||||
U8(movie, MV_UNKB8) = U8(record, PR_UNKB);
|
||||
}
|
||||
if ((U8(record, PR_FLAGS) & 0x10) != 0) {
|
||||
U8(movie, MV_BA) |= 8;
|
||||
}
|
||||
if (I8(record, PR_FILTERFLAG) != 0x7f) {
|
||||
if ((U8(movie, MV_BC) & 2) != 0) {
|
||||
iggy_free_as3_filters(player, movie);
|
||||
}
|
||||
U8(movie, MV_FILTERCOUNT) = U8(record, PR_FILTERFLAG);
|
||||
void *filters = (I8(record, PR_FILTERFLAG) == 0)
|
||||
? NULL
|
||||
: PTR(record, PR_FILTERDATA);
|
||||
U8(movie, MV_BC) &= 0xfd;
|
||||
PTR(movie, MV_FILTERLIST) = filters;
|
||||
}
|
||||
if ((U8(record, PR_FLAGS) & 1) != 0) {
|
||||
*(uint32_t *)AT(movie, MV_MATRIX) = *(uint32_t *)AT(record, PR_MATRIX);
|
||||
*(uint32_t *)AT(movie, MV_MATRIX + 4) =
|
||||
*(uint32_t *)AT(record, PR_MATRIX + 4);
|
||||
*(uint32_t *)AT(movie, MV_MATRIX + 8) =
|
||||
*(uint32_t *)AT(record, PR_MATRIX + 8);
|
||||
*(uint32_t *)AT(movie, MV_MATRIX + 0xc) =
|
||||
*(uint32_t *)AT(record, PR_MATRIX + 0xc);
|
||||
U8(movie, 2) = 0;
|
||||
*(uint32_t *)AT(movie, MV_MATRIX + 0x10) =
|
||||
*(uint32_t *)AT(record, PR_MATRIX + 0x10);
|
||||
*(uint32_t *)AT(movie, MV_MATRIX + 0x14) =
|
||||
*(uint32_t *)AT(record, PR_MATRIX + 0x14);
|
||||
}
|
||||
F32(movie, MV_RATIO) = (float)U16(record, PR_RATIO) / 65535.0f;
|
||||
if ((U8(record, PR_FLAGS) & 0x80) != 0) {
|
||||
U16(movie, MV_BLEND) = U16(record, PR_BLEND);
|
||||
}
|
||||
if ((U8(record, PR_FLAGS) & 0x40) != 0 && PTR(record, PR_INSTNAME) != NULL) {
|
||||
if ((U8(movie, MV_BC) & 1) != 0) {
|
||||
iggy_free_alloc(player, PTR(movie, MV_INSTNAME));
|
||||
U8(movie, MV_BC) &= 0xfe;
|
||||
}
|
||||
PTR(movie, MV_INSTNAME) = PTR(record, PR_INSTNAME);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:2858-2916 (objdump-confirmed). Dispatch a PlaceObject tag: replace
|
||||
* shared properties on an already-placed object at this depth, or construct a
|
||||
* new object via placeobject_GC. */
|
||||
void iggy_do_placeobject_GC(void *player, void *p2, void *p3, int p4,
|
||||
uint32_t p5, uint32_t p6, uint32_t p7,
|
||||
uint32_t p8) {
|
||||
void *record = p3;
|
||||
uint16_t depth = U16(record, PR_DEPTH);
|
||||
void *deptharray = PTR(p2, MV_DEPTHARRAY);
|
||||
void *existing =
|
||||
*(void **)AT(deptharray, (intptr_t)depth * (intptr_t)sizeof(void *));
|
||||
|
||||
if (PTR(record, PR_DEF) == NULL && (U8(record, PR_FLAGS) & 0x20) == 0) {
|
||||
if (existing == NULL || (U8(existing, MV_FLAG1) & 4) == 0) {
|
||||
placeobject_shared(player, existing, record);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (p4 == 0) {
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0x839, 0, 0);
|
||||
}
|
||||
void *instname = NULL;
|
||||
if ((U8(record, PR_FLAGS) & 0x40) != 0) {
|
||||
instname = PTR(record, PR_INSTNAME);
|
||||
}
|
||||
void *classname = NULL;
|
||||
if ((U8(record, PR_FLAGS) & 0x20) != 0) {
|
||||
classname = PTR(record, PR_CLASSNAME);
|
||||
}
|
||||
placeobject_GC(player, p2, depth, PTR(record, PR_DEF), classname, instname,
|
||||
record, p6, p5, (void *)1, (int)p7, (int)p8, (uint8_t)p6);
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0x83e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (existing != NULL && (U8(existing, MV_FLAG1) & 4) == 0) {
|
||||
U8(existing, MV_COLORXFORM) = 0;
|
||||
U16(existing, MV_COLORXFORM + 1) = 0;
|
||||
U8(existing, MV_UNKB8) = 0;
|
||||
U8(existing, MV_FILTERCOUNT) = 0;
|
||||
F32(existing, MV_MATRIX) = 1.0f;
|
||||
F32(existing, MV_MATRIX + 4) = 0.0f;
|
||||
F32(existing, MV_MATRIX + 8) = 0.0f;
|
||||
F32(existing, MV_MATRIX + 0xc) = 1.0f;
|
||||
F32(existing, MV_MATRIX + 0x10) = 0.0f;
|
||||
F32(existing, MV_MATRIX + 0x14) = 0.0f;
|
||||
placeobject_shared(player, existing, record);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:2815-2857 (objdump-confirmed). Splice a resolved object into its
|
||||
* parent's depth-array, swapping shared properties from any object it is
|
||||
* displacing at that depth. */
|
||||
void iggy_do_placement(void *player, void *movie, void *p3) {
|
||||
void *parent = PTR(p3, 0);
|
||||
int32_t depth = I32(p3, PLACE_CTX_DEPTH_OFF);
|
||||
I32(movie, MV_DEPTH) = depth;
|
||||
if (parent == NULL) {
|
||||
return;
|
||||
}
|
||||
void *deptharray = PTR(parent, MV_DEPTHARRAY);
|
||||
void *existing =
|
||||
*(void **)AT(deptharray, (intptr_t)depth * (intptr_t)sizeof(void *));
|
||||
if (existing != NULL) {
|
||||
*(uint64_t *)AT(movie, MV_MATRIX) = *(uint64_t *)AT(existing, MV_MATRIX);
|
||||
*(uint64_t *)AT(movie, MV_MATRIX + 8) =
|
||||
*(uint64_t *)AT(existing, MV_MATRIX + 8);
|
||||
*(uint64_t *)AT(movie, MV_MATRIX + 0x10) =
|
||||
*(uint64_t *)AT(existing, MV_MATRIX + 0x10);
|
||||
U8(movie, MV_UNKB8) = U8(existing, MV_UNKB8);
|
||||
*(uint64_t *)AT(movie, MV_COLORXFORM) =
|
||||
*(uint64_t *)AT(existing, MV_COLORXFORM);
|
||||
*(uint64_t *)AT(movie, MV_COLORXFORM + 8) =
|
||||
*(uint64_t *)AT(existing, MV_COLORXFORM + 8);
|
||||
*(uint64_t *)AT(movie, MV_COLORXFORM + 0x10) =
|
||||
*(uint64_t *)AT(existing, MV_COLORXFORM + 0x10);
|
||||
U32(movie, MV_COLORXFORM + 0x18) = U32(existing, MV_COLORXFORM + 0x18);
|
||||
U32(movie, MV_RATIO) = U32(existing, MV_RATIO);
|
||||
if ((U8(movie, MV_BC) & 2) != 0) {
|
||||
iggy_free_as3_filters(player, movie);
|
||||
}
|
||||
PTR(movie, MV_FILTERLIST) = PTR(existing, MV_FILTERLIST);
|
||||
U8(movie, MV_FILTERCOUNT) = U8(existing, MV_FILTERCOUNT);
|
||||
U8(movie, MV_BC) ^= (uint8_t)((U8(movie, MV_BC) ^ U8(existing, MV_BC)) & 2);
|
||||
U8(existing, MV_BC) &= 0xfd;
|
||||
iggy_remove_sprite(player, existing, I32(p3, PLACE_CTX_EXTRA_OFF), NULL,
|
||||
PTR(player, PL_AS3VM) == NULL, 1);
|
||||
}
|
||||
gswf_add_movie_at_depth_raw(player, parent, depth, movie);
|
||||
}
|
||||
|
||||
/* raw:3493-3635 (objdump-confirmed). Move `movie` to the given depth under
|
||||
* `parent`, splicing sibling/unparented lists and (if it crosses onto or off
|
||||
* the stage) dispatching added/addedToStage. */
|
||||
uint64_t iggy_insert_movie_at_GC(void *player, void *parent, int depth,
|
||||
void *movie) {
|
||||
if ((U8(movie, MV_FLAG1) & 8) != 0) {
|
||||
return 0;
|
||||
}
|
||||
for (void *p = parent; p != NULL; p = PTR(p, MV_PARENT)) {
|
||||
if (p == movie) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
{
|
||||
void *walk = PTR(parent, MV_FIRSTCHILD);
|
||||
int i = 0;
|
||||
if (depth > 0) {
|
||||
do {
|
||||
if (walk == NULL) {
|
||||
return 0;
|
||||
}
|
||||
walk = PTR(walk, MV_NEXT);
|
||||
i = i + 1;
|
||||
} while (i < depth);
|
||||
}
|
||||
}
|
||||
|
||||
void *old_parent = PTR(movie, MV_PARENT);
|
||||
int had_different_parent = (old_parent != parent);
|
||||
int now_on_stage = had_different_parent;
|
||||
if (old_parent != NULL) {
|
||||
int was_on_stage = had_different_parent;
|
||||
if (had_different_parent) {
|
||||
was_on_stage = 0;
|
||||
for (void *p = old_parent; p != NULL; p = PTR(p, MV_PARENT)) {
|
||||
if (p == AT(player, PL_STAGE)) {
|
||||
was_on_stage = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
iggy_remove_sprite(player, movie, was_on_stage, NULL, 0, 0);
|
||||
}
|
||||
if (had_different_parent) {
|
||||
now_on_stage = 0;
|
||||
for (void *p = parent; p != NULL; p = PTR(p, MV_PARENT)) {
|
||||
if (p == AT(player, PL_STAGE)) {
|
||||
now_on_stage = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PTR(movie, MV_PARENT) = NULL;
|
||||
if (PTR(player, PL_UNPARENTED) == movie) {
|
||||
PTR(player, PL_UNPARENTED) = PTR(movie, MV_NEXT);
|
||||
}
|
||||
if (PTR(movie, MV_NEXT) != NULL) {
|
||||
PTR(PTR(movie, MV_NEXT), MV_PREV) = PTR(movie, MV_PREV);
|
||||
}
|
||||
if (PTR(movie, MV_PREV) != NULL) {
|
||||
PTR(PTR(movie, MV_PREV), MV_NEXT) = PTR(movie, MV_NEXT);
|
||||
}
|
||||
PTR(movie, MV_PREV) = NULL;
|
||||
PTR(movie, MV_NEXT) = NULL;
|
||||
I32(movie, MV_DEPTH) = -1;
|
||||
if (PTR(movie, MV_PARENT) != parent) {
|
||||
PTR(movie, MV_PARENT) = parent;
|
||||
iggy_mark_movie_dirty(player, movie);
|
||||
if (parent != NULL) {
|
||||
iggy_mark_movie_dirty(player, parent);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
void *child = PTR(parent, MV_FIRSTCHILD);
|
||||
if (child == NULL) {
|
||||
PTR(parent, MV_LASTCHILD) = movie;
|
||||
PTR(parent, MV_FIRSTCHILD) = movie;
|
||||
PTR(movie, MV_PREV) = NULL;
|
||||
PTR(movie, MV_NEXT) = NULL;
|
||||
} else if (depth == 0) {
|
||||
PTR(movie, MV_NEXT) = child;
|
||||
PTR(movie, MV_PREV) = NULL;
|
||||
PTR(child, MV_PREV) = movie;
|
||||
PTR(parent, MV_FIRSTCHILD) = movie;
|
||||
} else {
|
||||
int placed = 0;
|
||||
if (depth == -1) {
|
||||
PTR(movie, MV_NEXT) = NULL;
|
||||
} else {
|
||||
int i = 1;
|
||||
if (depth > 1) {
|
||||
while (i < depth) {
|
||||
child = PTR(child, MV_NEXT);
|
||||
if (child == NULL) {
|
||||
break;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
if (child != NULL && child != PTR(parent, MV_LASTCHILD)) {
|
||||
PTR(movie, MV_PREV) = child;
|
||||
PTR(movie, MV_NEXT) = PTR(child, MV_NEXT);
|
||||
PTR(child, MV_NEXT) = movie;
|
||||
PTR(PTR(movie, MV_NEXT), MV_PREV) = movie;
|
||||
placed = 1;
|
||||
} else {
|
||||
PTR(movie, MV_NEXT) = NULL;
|
||||
}
|
||||
}
|
||||
if (!placed) {
|
||||
void *tail = PTR(parent, MV_LASTCHILD);
|
||||
PTR(movie, MV_PREV) = tail;
|
||||
PTR(tail, MV_NEXT) = movie;
|
||||
PTR(parent, MV_LASTCHILD) = movie;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PTR(player, PL_AS3VM) != NULL && now_on_stage) {
|
||||
U8(movie, MV_B9) |= 0x20;
|
||||
if (PTR(player, PL_AS3VM) != NULL) {
|
||||
U8(movie, MV_B9) &= 0xdf;
|
||||
U16(movie, MV_LOCKCOUNT) = (uint16_t)(U16(movie, MV_LOCKCOUNT) + 1);
|
||||
as3vm_do_displayobject_event_GC(PTR(player, PL_AS3VM), movie, 7, 1);
|
||||
U16(movie, MV_LOCKCOUNT) = (uint16_t)(U16(movie, MV_LOCKCOUNT) - 1);
|
||||
}
|
||||
if (PTR(player, PL_AS3VM) != NULL) {
|
||||
as3vm_do_displayobject_event_GC(PTR(player, PL_AS3VM), movie, 8, 0);
|
||||
preorder_send_displayobject_event_GC(player, movie, 8, 0);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* raw:3636-3668 (objdump-confirmed). Dispatch the "added" (and, if this movie
|
||||
* is reachable from the stage, "addedToStage") events for a freshly-inserted
|
||||
* movie. */
|
||||
void iggy_insert_movie_messages_GC(void *player, void *movie, int p3) {
|
||||
if (PTR(player, PL_AS3VM) == NULL) {
|
||||
return;
|
||||
}
|
||||
void *topmost = PTR(movie, MV_PARENT);
|
||||
U8(movie, MV_B9) &= 0xdf;
|
||||
U16(movie, MV_LOCKCOUNT) = (uint16_t)(U16(movie, MV_LOCKCOUNT) + 1);
|
||||
as3vm_do_displayobject_event_GC(PTR(player, PL_AS3VM), movie, 7, 1);
|
||||
if (p3 != 0) {
|
||||
if (topmost != NULL) {
|
||||
for (void *p = PTR(topmost, MV_PARENT); p != NULL;
|
||||
p = PTR(p, MV_PARENT)) {
|
||||
topmost = p;
|
||||
}
|
||||
}
|
||||
if (topmost == AT(player, PL_STAGE)) {
|
||||
as3vm_do_displayobject_event_GC(PTR(player, PL_AS3VM), movie, 8, 0);
|
||||
}
|
||||
}
|
||||
U16(movie, MV_LOCKCOUNT) = (uint16_t)(U16(movie, MV_LOCKCOUNT) - 1);
|
||||
}
|
||||
|
||||
/* raw:5198-5230 (objdump-confirmed). Preorder-walk `node`'s children
|
||||
* dispatching a displayobject event to each. */
|
||||
static void preorder_send_displayobject_event_GC(void *player, void *node,
|
||||
uint8_t p3, uint32_t p4) {
|
||||
void *child = PTR(node, MV_FIRSTCHILD);
|
||||
if (child == NULL) {
|
||||
return;
|
||||
}
|
||||
for (;;) {
|
||||
void *next = PTR(child, MV_NEXT);
|
||||
U16(child, MV_LOCKCOUNT) = (uint16_t)(U16(child, MV_LOCKCOUNT) + 1);
|
||||
if (next != NULL) {
|
||||
U16(next, MV_LOCKCOUNT) = (uint16_t)(U16(next, MV_LOCKCOUNT) + 1);
|
||||
}
|
||||
as3vm_do_displayobject_event_GC(PTR(player, PL_AS3VM), child, p3, p4);
|
||||
if (PTR(child, MV_FIRSTCHILD) != NULL) {
|
||||
preorder_send_displayobject_event_GC(player, child, p3, p4);
|
||||
}
|
||||
U16(child, MV_LOCKCOUNT) = (uint16_t)(U16(child, MV_LOCKCOUNT) - 1);
|
||||
if (next == NULL) {
|
||||
break;
|
||||
}
|
||||
U16(next, MV_LOCKCOUNT) = (uint16_t)(U16(next, MV_LOCKCOUNT) - 1);
|
||||
child = next;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:5741-5773 (objdump-confirmed). Textually identical to
|
||||
* preorder_send_displayobject_event_GC in durango; kept as a distinct
|
||||
* file-static per the frozen forward-decl surface. */
|
||||
static void recursive_send_displayobject_event_GC(void *player, void *node,
|
||||
uint8_t p3, uint32_t p4) {
|
||||
void *child = PTR(node, MV_FIRSTCHILD);
|
||||
if (child == NULL) {
|
||||
return;
|
||||
}
|
||||
for (;;) {
|
||||
void *next = PTR(child, MV_NEXT);
|
||||
U16(child, MV_LOCKCOUNT) = (uint16_t)(U16(child, MV_LOCKCOUNT) + 1);
|
||||
if (next != NULL) {
|
||||
U16(next, MV_LOCKCOUNT) = (uint16_t)(U16(next, MV_LOCKCOUNT) + 1);
|
||||
}
|
||||
as3vm_do_displayobject_event_GC(PTR(player, PL_AS3VM), child, p3, p4);
|
||||
if (PTR(child, MV_FIRSTCHILD) != NULL) {
|
||||
recursive_send_displayobject_event_GC(player, child, p3, p4);
|
||||
}
|
||||
U16(child, MV_LOCKCOUNT) = (uint16_t)(U16(child, MV_LOCKCOUNT) - 1);
|
||||
if (next == NULL) {
|
||||
break;
|
||||
}
|
||||
U16(next, MV_LOCKCOUNT) = (uint16_t)(U16(next, MV_LOCKCOUNT) - 1);
|
||||
child = next;
|
||||
}
|
||||
}
|
||||
481
iggy-decompiled/src/reconstructed/swf_play_player.inc
Normal file
481
iggy-decompiled/src/reconstructed/swf_play_player.inc
Normal file
@@ -0,0 +1,481 @@
|
||||
/*
|
||||
* swf_play_player.inc -- the IggyPlayer* public tick / play / pause / focus /
|
||||
* clipboard entry points, IggySetDoubleClickTime, and the tick-time helpers
|
||||
* iggy_poll_iggyexp / update_time. durango raw lines cited inline; 32-bit
|
||||
* offsets derived from the vita raw (cross-checked ps3).
|
||||
*/
|
||||
|
||||
/* -- player-family field offsets (width-gated; durango / vita). ------------- */
|
||||
#if IGGY_PTR64
|
||||
#undef FOCUSOBJ
|
||||
# define FOCUSOBJ 0x29a8 /* ptr: currently focused DisplayObject. */
|
||||
#undef DISPTREE_CACHE
|
||||
# define DISPTREE_CACHE 0x2898 /* ptr: cached display-tree snapshot. */
|
||||
#undef TF_STRUCT
|
||||
# define TF_STRUCT 0x98 /* movie: EditText sub-struct pointer. */
|
||||
#undef TF_EDITABLE
|
||||
# define TF_EDITABLE 0xea /* EditText: editable flag byte. */
|
||||
#undef PL_TIMEFLAG
|
||||
# define PL_TIMEFLAG 0x285c /* int: time-updated-this-tick flag. */
|
||||
#undef PL_LASTSEC
|
||||
# define PL_LASTSEC 0x2868 /* double: last iggy_get_seconds sample. */
|
||||
#undef PL_ACCUM_A
|
||||
# define PL_ACCUM_A 0x30 /* double: accumulated frame time (u0010+0x20).*/
|
||||
#undef PL_ACCUM_B
|
||||
# define PL_ACCUM_B 0x28 /* double: accumulated real time (u0010+0x18).*/
|
||||
#undef PL_FRAMEDROP
|
||||
# define PL_FRAMEDROP 0x2f20 /* uint: consecutive dropped-frame counter. */
|
||||
#undef PL_DISPX
|
||||
# define PL_DISPX 0x2980 /* int: dispatch cursor x snapshot. */
|
||||
#undef PL_DISPY
|
||||
# define PL_DISPY 0x2984 /* int: dispatch cursor y snapshot. */
|
||||
#undef PL_TICKCTR
|
||||
# define PL_TICKCTR 0x2f20 /* int: tick counter (shares framedrop slot). */
|
||||
#else
|
||||
#undef FOCUSOBJ
|
||||
# define FOCUSOBJ 0x2288
|
||||
#undef DISPTREE_CACHE
|
||||
# define DISPTREE_CACHE 0x21b4
|
||||
#undef TF_STRUCT
|
||||
# define TF_STRUCT 0x50
|
||||
#undef TF_EDITABLE
|
||||
# define TF_EDITABLE 0xce
|
||||
#undef PL_TIMEFLAG
|
||||
# define PL_TIMEFLAG 0x217c
|
||||
#undef PL_LASTSEC
|
||||
# define PL_LASTSEC 0x2188
|
||||
#undef PL_ACCUM_A
|
||||
# define PL_ACCUM_A 0x28
|
||||
#undef PL_ACCUM_B
|
||||
# define PL_ACCUM_B 0x20
|
||||
#undef PL_FRAMEDROP
|
||||
# define PL_FRAMEDROP 0x25d0
|
||||
#undef PL_DISPX
|
||||
# define PL_DISPX 0x2268
|
||||
#undef PL_DISPY
|
||||
# define PL_DISPY 0x226c
|
||||
#undef PL_TICKCTR
|
||||
# define PL_TICKCTR 0x25d0
|
||||
#endif
|
||||
|
||||
/* The focused object's EditText sub-struct iff it is an editable EditText, else
|
||||
* NULL (shared predicate of Copy/Cut/Paste/HasFocusedEditableTextfield). The
|
||||
* retail edittext_* calls were register-elided by Ghidra; the operand is this
|
||||
* textfield pointer. raw:12-14 / vita:16038-16041. */
|
||||
static void *iggy_play_focused_edittext(void *f) {
|
||||
void *node = PTR(f, FOCUSOBJ);
|
||||
if (node != NULL && I8(node, 3) == 6 && PTR(node, TF_STRUCT) != NULL &&
|
||||
I8(PTR(node, TF_STRUCT), TF_EDITABLE) != 0) {
|
||||
return PTR(node, TF_STRUCT);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* raw:6-19 */
|
||||
int32_t IggyPlayerCopyUTF16(void *f, void *buffer, int32_t bufferlen) {
|
||||
void *tf = iggy_play_focused_edittext(f);
|
||||
if (tf != NULL) {
|
||||
return (int32_t)(intptr_t)iggy_edittext_copy_utf16(tf, buffer, bufferlen);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* raw:25-38 */
|
||||
int32_t IggyPlayerCopyUTF8(void *f, void *buffer, int32_t bufferlen) {
|
||||
void *tf = iggy_play_focused_edittext(f);
|
||||
if (tf != NULL) {
|
||||
return (int32_t)(intptr_t)iggy_edittext_copy_utf8(tf, buffer, bufferlen);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* raw:44-56 */
|
||||
uint64_t IggyPlayerCut_core(void *player) {
|
||||
void *tf = iggy_play_focused_edittext(player);
|
||||
if (tf != NULL) {
|
||||
iggy_edittext_cut(tf);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:191-202 */
|
||||
int32_t IggyPlayerHasFocusedEditableTextfield(void *f) {
|
||||
return iggy_play_focused_edittext(f) != NULL ? 1 : 0;
|
||||
}
|
||||
|
||||
/* raw:208-230 guarded setjmp around iggy_edittext_paste_utf16. */
|
||||
uint64_t IggyPlayerPasteUTF16_core(void *player, void *text, uint32_t len) {
|
||||
if (iggy_play_focused_edittext(player) != NULL) {
|
||||
uint8_t depth = (uint8_t)(U8(player, PL_SJ_COUNTER) + 1);
|
||||
U8(player, PL_SJ_COUNTER) = depth;
|
||||
int rc = setjmp((struct __jmp_buf_tag *)
|
||||
AT(player, PL_SJ_BASE + (intptr_t)(int)(depth - 1) * PL_SJ_STRIDE));
|
||||
if (rc == 0) {
|
||||
iggy_edittext_paste_utf16(player, text, len);
|
||||
U8(player, PL_SJ_COUNTER) = (uint8_t)(U8(player, PL_SJ_COUNTER) - 1);
|
||||
return 1;
|
||||
}
|
||||
U8(player, PL_SJ_COUNTER) = (uint8_t)(U8(player, PL_SJ_COUNTER) - 1);
|
||||
U32(player, PL_INITIALIZED) = 0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:240-285 UTF8->UTF16 into a bounded stack buffer, then PasteUTF16. The
|
||||
* retail alloca / __security_cookie scaffolding is a toolchain artifact and is
|
||||
* replaced by a fixed 0x1000-wchar buffer (the same clamp the retail code uses). */
|
||||
int32_t IggyPlayerPasteUTF8_core(void *player, void *text, uint32_t len) {
|
||||
if (iggy_play_focused_edittext(player) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
int n = rrUTF8toUTF16(0, 0, text, len);
|
||||
if (n > 0x1000) {
|
||||
n = 0x1000;
|
||||
}
|
||||
{
|
||||
uint16_t buf[0x1000];
|
||||
int32_t stringlen = (int32_t)(intptr_t)rrUTF8toUTF16(buf, n, text, len);
|
||||
return IggyPlayerPasteUTF16(player, buf, stringlen);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:291-337 initialized gate; pause flag := 1; mode 1 (pause_audio) parks the
|
||||
* eight voices, mode 2 (stop_audio) halts then frees them; else the loop is
|
||||
* skipped (pure). */
|
||||
void IggyPlayerPause(void *player, int32_t pause_audio) {
|
||||
if (U32(player, PL_INITIALIZED) != 0) {
|
||||
U8(player, PL_PAUSE_FLAG) = 1;
|
||||
if (pause_audio == 1) {
|
||||
char *v = AT(player, PL_VOICE_ID);
|
||||
int i = 8;
|
||||
do {
|
||||
if (I16(v, 0) >= 0) {
|
||||
iggy_play_voice((int)I16(v, 0), 0);
|
||||
}
|
||||
v += PL_VOICE_STRIDE;
|
||||
i = i - 1;
|
||||
} while (i != 0);
|
||||
} else if (pause_audio == 2) {
|
||||
char *halt = AT(player, PL_VOICE_ID);
|
||||
char *freev = halt;
|
||||
int a = 8, b = 8;
|
||||
do {
|
||||
if (I16(halt, 0) >= 0) {
|
||||
iggy_halt_voice((int)I16(halt, 0));
|
||||
}
|
||||
halt += PL_VOICE_STRIDE;
|
||||
b = b - 1;
|
||||
} while (b != 0);
|
||||
do {
|
||||
if (I16(freev, 0) >= 0) {
|
||||
iggy_free_voice((int)I16(freev, 0));
|
||||
U8(freev, 0) = 0xff;
|
||||
U8(freev, 1) = 0xff;
|
||||
}
|
||||
freev += PL_VOICE_STRIDE;
|
||||
a = a - 1;
|
||||
} while (a != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:343-370 initialized gate; clears pause flag + the accum window, polls,
|
||||
* and starts the eight voices. */
|
||||
void IggyPlayerPlay(void *player) {
|
||||
if (U32(player, PL_INITIALIZED) != 0) {
|
||||
U8(player, PL_PAUSE_FLAG) = 0;
|
||||
IggyPlayerReadyToTick(player);
|
||||
F64(player, PL_ACCUM_A) = 0.0;
|
||||
{
|
||||
char *v = AT(player, PL_VOICE_ID);
|
||||
int i = 8;
|
||||
do {
|
||||
if (I16(v, 0) >= 0) {
|
||||
iggy_play_voice((int)I16(v, 0), 1);
|
||||
}
|
||||
v += PL_VOICE_STRIDE;
|
||||
i = i - 1;
|
||||
} while (i != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:377-404 NULL / uninitialized -> 0 before any import (pure reject). */
|
||||
int32_t IggyPlayerReadyToTick(void *player) {
|
||||
if (player != NULL && U32(player, PL_INITIALIZED) != 0) {
|
||||
iggy_poll_iggyexp(player);
|
||||
if (U8(player, PL_PAUSE_FLAG) == 0) {
|
||||
if (U32(player, PL_FRAMEDROP) < 3) {
|
||||
update_time(player);
|
||||
return F64(player, PL_TM_STAMP) <= F64(player, PL_ACCUM_A) ? 1 : 0;
|
||||
}
|
||||
U32(player, PL_FRAMEDROP) = 0;
|
||||
F64(player, PL_ACCUM_A) = 0.0;
|
||||
iggy_send_error(player, 0xc9,
|
||||
"Cannot maintain framerate specified in SWF file");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:410-425 */
|
||||
void IggyPlayerSendFrameToExplorer(void *f) {
|
||||
if (PTR(f, PL_IGGYEXP) != NULL) {
|
||||
PTR(f, DISPTREE_CACHE) = NULL;
|
||||
iggy_send_display_tree(f);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:432-467 walk the display tree for param_2; on a match dispatch a typed
|
||||
* focus event through iggy_set_focus_typed. */
|
||||
void IggyPlayerSetFocus_core(void *player, void *obj, uint32_t p3) {
|
||||
if (player != NULL && U32(player, PL_INITIALIZED) != 0 &&
|
||||
U8(player, PL_FRAMESCRIPT_FLAG) == 0) {
|
||||
void *node = AT(player, PL_STAGE);
|
||||
void *cur = node;
|
||||
while (cur != NULL) {
|
||||
if (cur == obj) {
|
||||
iggy_set_focus_typed(player, 0x33, cur, p3);
|
||||
return;
|
||||
}
|
||||
void *next = PTR(cur, 0x10);
|
||||
if (next == NULL && (I8(cur, 3) != 7 ||
|
||||
(next = PTR(PTR(cur, 0x48),
|
||||
(intptr_t)(char)I8(cur, 0x113) * (intptr_t)sizeof(void *)),
|
||||
next == NULL))) {
|
||||
void *up = cur;
|
||||
next = PTR(cur, 8);
|
||||
if (next == NULL) {
|
||||
while (PTR(up, 8) == NULL) {
|
||||
up = PTR(up, 0x80);
|
||||
cur = NULL;
|
||||
if (up == NULL) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
next = PTR(up, 8);
|
||||
}
|
||||
}
|
||||
cur = next;
|
||||
}
|
||||
done:
|
||||
if (cur == obj && cur != NULL) {
|
||||
iggy_set_focus_typed(player, 0x33, cur, p3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:117-185 enumerate focusable objects into the caller array (objs entry is
|
||||
* 0x18 bytes: object ptr @ +0, four floats @ +8..+0x14). */
|
||||
int32_t IggyPlayerGetFocusableObjects(void *f, void *current_focus, void *objs,
|
||||
int32_t max_obj, int32_t *num_obj) {
|
||||
int64_t count = 0;
|
||||
int written = 0;
|
||||
uint8_t flags;
|
||||
char *node;
|
||||
char *child;
|
||||
float *out;
|
||||
*num_obj = 0;
|
||||
if (f == NULL || U32(f, PL_INITIALIZED) == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (current_focus != NULL) {
|
||||
*(void **)current_focus = PTR(f, FOCUSOBJ);
|
||||
}
|
||||
flags = U8(f, PL_STAGE + 0x17e);
|
||||
node = AT(f, PL_STAGE);
|
||||
while ((flags & 0x20) != 0) {
|
||||
child = PTR(node, 0x10);
|
||||
if (child == NULL) {
|
||||
break;
|
||||
}
|
||||
flags = U8(child, 0xba);
|
||||
node = child;
|
||||
}
|
||||
out = (float *)AT(objs, 0x18);
|
||||
for (;;) {
|
||||
for (;;) {
|
||||
if ((U8(node, 0xba) & 0x80) != 0) {
|
||||
if (count < max_obj) {
|
||||
*(void **)AT(out, -0x18) = node;
|
||||
out[-1] = F32(node, 0xc8);
|
||||
out[0] = F32(node, 0xcc);
|
||||
out[1] = F32(node, 0xd0);
|
||||
out[2] = F32(node, 0xd4);
|
||||
}
|
||||
written = written + 1;
|
||||
count = count + 1;
|
||||
out = out + 6;
|
||||
}
|
||||
child = PTR(node, 8);
|
||||
if (child != NULL) {
|
||||
break;
|
||||
}
|
||||
node = PTR(node, 0x80);
|
||||
if (node == NULL) {
|
||||
*num_obj = written;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
node = child;
|
||||
while ((U8(child, 0xba) & 0x20) != 0) {
|
||||
char *sub = PTR(child, 0x10);
|
||||
if (sub == NULL) {
|
||||
node = child;
|
||||
if (I8(child, 3) != 7 ||
|
||||
(sub = PTR(PTR(child, 0x48),
|
||||
(intptr_t)(char)U8(child, 0x113) * (intptr_t)sizeof(void *)),
|
||||
sub == NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
child = sub;
|
||||
node = sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:476-519 guarded do_tick, with the tm_normal profiler scopes. */
|
||||
void IggyPlayerTickRS_core(void *player) {
|
||||
int64_t start = rrGetTicks();
|
||||
if (U32(player, PL_INITIALIZED) != 0) {
|
||||
iggy_poll_iggyexp(player);
|
||||
if (U8(player, PL_FRAMESCRIPT_FLAG) != 0) {
|
||||
if (U32(player, PL_TIMEFLAG) == 0) {
|
||||
update_time(player);
|
||||
}
|
||||
F64(player, 0x30) = 0.0;
|
||||
U32(player, PL_TIMEFLAG) = 0;
|
||||
IPTR(player, PL_RENDER_DT) = (intptr_t)(rrGetTicks() - start);
|
||||
return;
|
||||
}
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0xc39, 0, 0);
|
||||
}
|
||||
U8(player, PL_SJ_COUNTER) = (uint8_t)(U8(player, PL_SJ_COUNTER) + 1);
|
||||
I32(player, PL_TICKCTR) = I32(player, PL_TICKCTR) + 1;
|
||||
{
|
||||
uint8_t depth = U8(player, PL_SJ_COUNTER);
|
||||
int rc = setjmp((struct __jmp_buf_tag *)
|
||||
AT(player, PL_SJ_BASE + (intptr_t)(int)(depth - 1) * PL_SJ_STRIDE));
|
||||
if (rc == 0) {
|
||||
do_tick(player);
|
||||
} else {
|
||||
U32(player, PL_INITIALIZED) = 0;
|
||||
}
|
||||
}
|
||||
U8(player, PL_SJ_COUNTER) = (uint8_t)(U8(player, PL_SJ_COUNTER) - 1);
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0xc46);
|
||||
}
|
||||
IPTR(player, PL_RENDER_DT) = (intptr_t)(rrGetTicks() - start);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:526-533 iggy_double_click_time = (float)ms / 1000.0 (__real@447a0000). */
|
||||
void IggySetDoubleClickTime(int32_t time_in_ms) {
|
||||
iggy_double_click_time = (float)time_in_ms / 1000.0f;
|
||||
}
|
||||
|
||||
/* raw:4074-4122 pump the iggyexp host callback (2/3 toggle the framescript
|
||||
* flag; 4 invalidates the display-tree cache; 5 stashes it). */
|
||||
void iggy_poll_iggyexp(void *player) {
|
||||
void *exp = PTR(player, PL_IGGYEXP);
|
||||
if (exp != NULL) {
|
||||
int rc = (*(int (**)(void *, void *))PTR(exp, 0))(player, exp);
|
||||
if (rc == 0) {
|
||||
void *e = PTR(player, PL_IGGYEXP);
|
||||
if (e != NULL) {
|
||||
(*(void (**)(void *, void *))AT(e, 0x28))(player, e);
|
||||
}
|
||||
PTR(player, PL_IGGYEXP) = NULL;
|
||||
} else {
|
||||
char *tok = NULL;
|
||||
void *e;
|
||||
while ((e = PTR(player, PL_IGGYEXP)) != NULL &&
|
||||
(rc = (*(int (**)(void *, void *, char **))AT(e, 8))(player, e, &tok)) != 0) {
|
||||
char c = *tok;
|
||||
tok = tok + 1;
|
||||
if (c == 2) {
|
||||
U8(player, PL_FRAMESCRIPT_FLAG) = 1;
|
||||
} else if (c == 3) {
|
||||
U8(player, PL_FRAMESCRIPT_FLAG) = 0;
|
||||
} else if (c == 4) {
|
||||
if (PTR(player, PL_IGGYEXP) != NULL) {
|
||||
PTR(player, DISPTREE_CACHE) = NULL;
|
||||
iggy_send_display_tree(player);
|
||||
}
|
||||
} else if (c == 5) {
|
||||
if (rc == 9) {
|
||||
PTR(player, DISPTREE_CACHE) = *(void **)tok;
|
||||
} else if (rc == 1) {
|
||||
PTR(player, DISPTREE_CACHE) = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:6303-6318 sample the wall clock; fold the delta into the accum window. */
|
||||
void update_time(void *player) {
|
||||
double now = (double)iggy_get_seconds_best_effort(player);
|
||||
U32(player, PL_TIMEFLAG) = 1;
|
||||
double prev = F64(player, PL_LASTSEC);
|
||||
F64(player, PL_LASTSEC) = now;
|
||||
double delta = now - prev;
|
||||
F64(player, PL_ACCUM_B) = delta + F64(player, PL_ACCUM_B);
|
||||
F64(player, PL_ACCUM_A) = delta + F64(player, PL_ACCUM_A);
|
||||
}
|
||||
|
||||
/* raw:60-113 guarded input dispatch (setjmp reentrancy) around
|
||||
* process_input_event, with the tm_normal profiler scopes. */
|
||||
int IggyPlayerDispatchEventRS_core(void *player, int *event, void *p3) {
|
||||
int ok = 1;
|
||||
if (U8(player, PL_FRAMESCRIPT_FLAG) != 0) {
|
||||
return 1;
|
||||
}
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0x1402, 0, 0);
|
||||
}
|
||||
if (event != NULL) {
|
||||
if (U32(player, PL_INITIALIZED) == 0 || iggy_begin_execution(player) == 0) {
|
||||
ok = 0;
|
||||
} else {
|
||||
int reentered = 0;
|
||||
if (event[0] == 7) {
|
||||
if (event[2] != I32(player, PL_DISPX) || event[3] != I32(player, PL_DISPY)) {
|
||||
reentered = 1;
|
||||
}
|
||||
} else {
|
||||
event[2] = I32(player, PL_DISPX);
|
||||
event[3] = I32(player, PL_DISPY);
|
||||
reentered = 1;
|
||||
}
|
||||
if (reentered && PTR(player, PL_AS3VM) != NULL) {
|
||||
U8(player, PL_SJ_COUNTER) = (uint8_t)(U8(player, PL_SJ_COUNTER) + 1);
|
||||
uint8_t depth = U8(player, PL_SJ_COUNTER);
|
||||
int rc = setjmp((struct __jmp_buf_tag *)
|
||||
AT(player, PL_SJ_BASE + (intptr_t)(int)(depth - 1) * PL_SJ_STRIDE));
|
||||
ok = rc == 0;
|
||||
if (ok) {
|
||||
process_input_event(player, event, (void **)p3);
|
||||
}
|
||||
U8(player, PL_SJ_COUNTER) = (uint8_t)(U8(player, PL_SJ_COUNTER) - 1);
|
||||
}
|
||||
I32(player, PL_DISPX) = event[2];
|
||||
I32(player, PL_DISPY) = event[3];
|
||||
iggy_end_execution(player);
|
||||
}
|
||||
}
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0x142b);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
713
iggy-decompiled/src/reconstructed/swf_play_sprite.inc
Normal file
713
iggy-decompiled/src/reconstructed/swf_play_sprite.inc
Normal file
@@ -0,0 +1,713 @@
|
||||
/*
|
||||
* swf_play_sprite.inc -- sprite / button lifecycle: destroy, remove-from-tree,
|
||||
* button state machine, button record instantiation and the button/hit-test
|
||||
* cursor walk. durango raw line ranges cited per function; every 32-bit offset
|
||||
* is derived from the vita raw (or, where vita elides/inlines the routine,
|
||||
* cross-checked against sibling vita bodies that touch the same fields) -- see
|
||||
* the per-macro citations below. Two RESIDUAL fixes to the frozen macro table
|
||||
* are flagged where the vita raw disagrees with the values already frozen in
|
||||
* swf_play.c / swf_play_movie.inc (both confirmed via llvm-objdump and/or two
|
||||
* independent vita call sites): the real embedded-root offset and the real
|
||||
* MV_NAME offset. See the report for detail; this file does NOT redefine the
|
||||
* frozen PL_ROOT / MV_NAME macros, it uses corrected local aliases instead.
|
||||
*/
|
||||
|
||||
/* ---- local field offsets (width-gated; vita-verified unless noted). -------- */
|
||||
#if IGGY_PTR64
|
||||
#undef SPR_PL_ROOT
|
||||
# define SPR_PL_ROOT 0x24c0 /* == PL_ROOT; durango: button_under_cursor, */
|
||||
/* destroy_sprite_attachments both confirm. */
|
||||
#undef SPR_NAME
|
||||
# define SPR_NAME 0x138 /* == MV_NAME (durango value agrees). */
|
||||
#undef MV_NAMEOWN_FLAG
|
||||
# define MV_NAMEOWN_FLAG 0xbc /* byte: bit0 = SPR_NAME buffer is owned. */
|
||||
#undef PL_MOUSEDOWN_CNT
|
||||
# define PL_MOUSEDOWN_CNT 0x2d28 /* int: mousedown-tracked-object count. */
|
||||
#undef PL_MOUSEDOWN_ARR
|
||||
# define PL_MOUSEDOWN_ARR 0x2a08 /* ptr[]: mousedown-tracked-object array. */
|
||||
#undef PL_LASTHIT
|
||||
# define PL_LASTHIT 0x29b8 /* ptr: last hit-tested object (cleared). */
|
||||
#undef PL_MOUSEOVER_CUR
|
||||
# define PL_MOUSEOVER_CUR 0x29b0 /* ptr: current mouseover-cursor object. */
|
||||
#undef PL_MOUSEDOWN_BTN
|
||||
# define PL_MOUSEDOWN_BTN 0x2998 /* ptr: captured (mouse-down) button. */
|
||||
#undef PL_SPRITE_COUNT
|
||||
# define PL_SPRITE_COUNT 0x2f28 /* int: live sprite count. */
|
||||
#undef MV_CHILD
|
||||
# define MV_CHILD 0x10 /* ptr: first-child list head. */
|
||||
#undef MV_LASTCHILD
|
||||
# define MV_LASTCHILD 0x90 /* ptr: last-child (hit-test order) pointer. */
|
||||
#undef MV_CHILDTABLE
|
||||
# define MV_CHILDTABLE 0x48 /* ptr: depth table / button-record table. */
|
||||
#undef MV_DEPTHIDX
|
||||
# define MV_DEPTHIDX 0xc4 /* int: this movie's depth-table index. */
|
||||
#undef MV_OBJ
|
||||
# define MV_OBJ 0xa8 /* ptr: attached shape/sprite payload. */
|
||||
#undef MV_TEXTURE
|
||||
# define MV_TEXTURE 0x148 /* ptr: direct-texture ref. */
|
||||
#undef MV_GRAPHICS
|
||||
# define MV_GRAPHICS 0xa0 /* ptr: dynamic-graphics object. */
|
||||
#undef MV_AS3EXTRA
|
||||
# define MV_AS3EXTRA 0x150 /* ptr: secondary AS3-pooled value. */
|
||||
#undef MV_FIELD140
|
||||
# define MV_FIELD140 0x140 /* ptr: back-linked aux record. */
|
||||
#undef MV_LIST2
|
||||
# define MV_LIST2 0x50 /* ptr: secondary AS3 weak-value list head. */
|
||||
#undef LIST2_NEXT
|
||||
# define LIST2_NEXT 0x10
|
||||
#undef LIST2_VALUE
|
||||
# define LIST2_VALUE 0x08
|
||||
#undef TF_FIELD_C8
|
||||
# define TF_FIELD_C8 200 /* textfield-substruct field (0xc8). */
|
||||
#undef TF_FIELD_68
|
||||
# define TF_FIELD_68 0x68
|
||||
#undef MV_LISTENERS
|
||||
# define MV_LISTENERS 0x28 /* ptr: AS3 listener list head. */
|
||||
#undef LISTENER_NEXT
|
||||
# define LISTENER_NEXT 0x08
|
||||
#undef LISTENER_OWNERBACK
|
||||
# define LISTENER_OWNERBACK 0x18
|
||||
#undef BTN_STATE
|
||||
# define BTN_STATE 0xbd /* byte: current button state (0..3). */
|
||||
#undef BTN_OVERFLAG
|
||||
# define BTN_OVERFLAG 0x113 /* byte: raw "over" bit passed through. */
|
||||
#undef MV_MULTISTATE
|
||||
# define MV_MULTISTATE 0x15c /* int: multi-state (DefineButton2) count. */
|
||||
#undef BTNDEF_RECCOUNT
|
||||
# define BTNDEF_RECCOUNT 0x44 /* short: button-record count in definition. */
|
||||
#undef BTNDEF_RECARRAY
|
||||
# define BTNDEF_RECARRAY 0x48 /* ptr: button-record array in definition. */
|
||||
#undef BTNDEF_RECSTRIDE
|
||||
# define BTNDEF_RECSTRIDE 0x48 /* stride of one button-record entry. */
|
||||
#else
|
||||
#undef SPR_NAME_OTHER_HINT
|
||||
# define SPR_NAME_OTHER_HINT 0xc4 /* frozen MV_NAME (movie.inc) -- see NOTE. */
|
||||
#undef SPR_PL_ROOT
|
||||
# define SPR_PL_ROOT 0x1efc /* objdump+2x-raw confirmed; frozen PL_ROOT */
|
||||
/* macro states 0x1f00 -- that looks wrong. */
|
||||
#undef SPR_NAME
|
||||
# define SPR_NAME 0xe0 /* 2x-raw confirmed (iggy_remove_sprite, */
|
||||
/* destroy_sprite_attachments); frozen */
|
||||
/* MV_NAME macro states 0xc4 -- looks wrong. */
|
||||
#undef MV_NAMEOWN_FLAG
|
||||
# define MV_NAMEOWN_FLAG 0x64
|
||||
#undef PL_MOUSEDOWN_CNT
|
||||
# define PL_MOUSEDOWN_CNT 0x2458
|
||||
#undef PL_MOUSEDOWN_ARR
|
||||
# define PL_MOUSEDOWN_ARR 0x22c8
|
||||
#undef PL_LASTHIT
|
||||
# define PL_LASTHIT 0x2290
|
||||
#undef PL_MOUSEOVER_CUR
|
||||
# define PL_MOUSEOVER_CUR 0x228c
|
||||
#undef PL_MOUSEDOWN_BTN
|
||||
# define PL_MOUSEDOWN_BTN 0x2280
|
||||
#undef PL_SPRITE_COUNT
|
||||
# define PL_SPRITE_COUNT 0x25d8
|
||||
#undef MV_CHILD
|
||||
# define MV_CHILD 0x0c
|
||||
#undef MV_LASTCHILD
|
||||
# define MV_LASTCHILD 0x4c
|
||||
#undef MV_CHILDTABLE
|
||||
# define MV_CHILDTABLE 0x28
|
||||
#undef MV_DEPTHIDX
|
||||
# define MV_DEPTHIDX 0x6c
|
||||
#undef MV_OBJ
|
||||
# define MV_OBJ 0x58
|
||||
#undef MV_TEXTURE
|
||||
# define MV_TEXTURE 0xe8
|
||||
#undef MV_GRAPHICS
|
||||
# define MV_GRAPHICS 0x54
|
||||
#undef MV_AS3EXTRA
|
||||
# define MV_AS3EXTRA 0xec
|
||||
#undef MV_FIELD140
|
||||
# define MV_FIELD140 0xe4
|
||||
#undef MV_LIST2
|
||||
# define MV_LIST2 0x2c
|
||||
#undef LIST2_NEXT
|
||||
# define LIST2_NEXT 0x08
|
||||
#undef LIST2_VALUE
|
||||
# define LIST2_VALUE 0x04
|
||||
#undef TF_FIELD_C8
|
||||
# define TF_FIELD_C8 0xb0
|
||||
#undef TF_FIELD_68
|
||||
# define TF_FIELD_68 0x58
|
||||
#undef MV_LISTENERS
|
||||
# define MV_LISTENERS 0x18
|
||||
#undef LISTENER_NEXT
|
||||
# define LISTENER_NEXT 0x08
|
||||
#undef LISTENER_OWNERBACK
|
||||
# define LISTENER_OWNERBACK 0x10
|
||||
#undef BTN_STATE
|
||||
# define BTN_STATE 0x65
|
||||
#undef BTN_OVERFLAG
|
||||
# define BTN_OVERFLAG 0xbb
|
||||
#undef MV_MULTISTATE
|
||||
# define MV_MULTISTATE 0xf4
|
||||
/* RESIDUAL: initialize_button_GC is wholly absent from the vita raw (dead-code
|
||||
* eliminated or folded elsewhere); these three could not be vita-verified.
|
||||
* Kept proportional to the durango values as a best-effort placeholder. */
|
||||
#undef BTNDEF_RECCOUNT
|
||||
# define BTNDEF_RECCOUNT 0x2c
|
||||
#undef BTNDEF_RECARRAY
|
||||
# define BTNDEF_RECARRAY 0x30
|
||||
#undef BTNDEF_RECSTRIDE
|
||||
# define BTNDEF_RECSTRIDE 0x2c
|
||||
#endif
|
||||
|
||||
/* ---- dummy_button: file-static def blob passed to
|
||||
* iggy_create_movie_for_actionscript_object() by iggy_make_empty_button().
|
||||
* Bytes recovered via llvm-objdump -s -j .data on both objects: durango's
|
||||
* blob is 0x58 bytes (llvm-nm: iggy_double_click_time sits immediately after
|
||||
* it at +0x58, so dummy_button cannot extend past that); vita's is 0x3c bytes
|
||||
* (llvm-nm --print-size gives the exact span directly). Content on both
|
||||
* platforms: first dword = 7 (movie type tag, BUTTON), remainder zero. */
|
||||
#if IGGY_PTR64
|
||||
static const uint8_t dummy_button[0x58] = { 0x07 };
|
||||
#else
|
||||
static const uint8_t dummy_button[0x3c] = { 0x07 };
|
||||
#endif
|
||||
|
||||
/* dummy_text: sibling static blob (referenced here only for the
|
||||
* destroy_sprite_attachments pointer-identity check; the textfield-lifecycle
|
||||
* bodies elsewhere also reference it -- since this .inc is #include'd before
|
||||
* swf_play_textfield.inc in swf_play.c, this is the one and only definition
|
||||
* for the whole translation unit. Sizes/content recovered the same way as
|
||||
* dummy_button: durango spans [0x60,0xd0) = 0x70 bytes (llvm-nm: dummy_text
|
||||
* then shift_mapping bounds it); vita is 0x44 bytes (llvm-nm --print-size).
|
||||
* Content on both platforms: first dword = 6 (movie type tag, EDITTEXT),
|
||||
* remainder zero. */
|
||||
#if IGGY_PTR64
|
||||
static const uint8_t dummy_text[0x70] = { 0x06 };
|
||||
#else
|
||||
static const uint8_t dummy_text[0x44] = { 0x06 };
|
||||
#endif
|
||||
|
||||
/* raw:2521-2669 (durango) / 648-802 (vita) */
|
||||
void iggy_destroy_sprite(void *player, void *movie) {
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0x220, 0x2000, 0);
|
||||
}
|
||||
if ((U8(movie, MV_B9) & 0x80) != 0) {
|
||||
if (I32(player, PL_MOUSEDOWN_CNT) > 0) {
|
||||
void **arr = (void **)AT(player, PL_MOUSEDOWN_ARR);
|
||||
int i = 0;
|
||||
do {
|
||||
if (arr[i] == movie) {
|
||||
arr[i] = NULL;
|
||||
break;
|
||||
}
|
||||
i = i + 1;
|
||||
} while (i < I32(player, PL_MOUSEDOWN_CNT));
|
||||
}
|
||||
U8(movie, MV_B9) = U8(movie, MV_B9) & 0x7f;
|
||||
}
|
||||
if (PTR(player, PL_LASTHIT) == movie) {
|
||||
PTR(player, PL_LASTHIT) = NULL;
|
||||
}
|
||||
if (PTR(player, PL_AS3VM) == NULL) {
|
||||
if (PTR(movie, MV_PARENT) == NULL || (U8(movie, MV_FLAG1) & 8) != 0) {
|
||||
PTR(movie, MV_PARENT) = NULL;
|
||||
if (PTR(player, PL_UNPARENTED) == movie) {
|
||||
PTR(player, PL_UNPARENTED) = PTR(movie, MV_NEXT);
|
||||
}
|
||||
if (PTR(movie, MV_NEXT) != NULL) {
|
||||
PTR(PTR(movie, MV_NEXT), MV_PREV) = PTR(movie, MV_PREV);
|
||||
}
|
||||
if (PTR(movie, MV_PREV) != NULL) {
|
||||
PTR(PTR(movie, MV_PREV), MV_NEXT) = PTR(movie, MV_NEXT);
|
||||
}
|
||||
PTR(movie, MV_NEXT) = NULL;
|
||||
PTR(movie, MV_PREV) = NULL;
|
||||
} else {
|
||||
PTR(movie, MV_PARENT) = NULL;
|
||||
iggy_mark_movie_dirty(player, movie);
|
||||
}
|
||||
} else {
|
||||
PTR(movie, MV_PARENT) = NULL;
|
||||
if (PTR(player, PL_UNPARENTED) == movie) {
|
||||
PTR(player, PL_UNPARENTED) = PTR(movie, MV_NEXT);
|
||||
}
|
||||
if (PTR(movie, MV_NEXT) != NULL) {
|
||||
PTR(PTR(movie, MV_NEXT), MV_PREV) = PTR(movie, MV_PREV);
|
||||
}
|
||||
if (PTR(movie, MV_PREV) != NULL) {
|
||||
PTR(PTR(movie, MV_PREV), MV_NEXT) = PTR(movie, MV_NEXT);
|
||||
}
|
||||
PTR(movie, MV_NEXT) = NULL;
|
||||
PTR(movie, MV_PREV) = NULL;
|
||||
}
|
||||
if ((U8(movie, 0) & 4) != 0) {
|
||||
iggy_clear_movie_dirty(player, movie);
|
||||
}
|
||||
if (PTR(player, PL_MOUSEOVER_CUR) == movie) {
|
||||
PTR(player, PL_MOUSEOVER_CUR) = NULL;
|
||||
}
|
||||
I32(player, PL_SPRITE_COUNT) = I32(player, PL_SPRITE_COUNT) - 1;
|
||||
iggy_destroy_sprite_attachments(player, movie, 0);
|
||||
{
|
||||
void *child = PTR(movie, MV_CHILD);
|
||||
PTR(movie, MV_CHILD) = NULL;
|
||||
PTR(movie, MV_LASTCHILD) = NULL;
|
||||
while (child != NULL) {
|
||||
void *next = PTR(child, MV_NEXT);
|
||||
iggy_remove_sprite(player, child, 0, (void *)1, 1, 0);
|
||||
child = next;
|
||||
}
|
||||
}
|
||||
if (PTR(movie, MV_CHILDTABLE) != NULL) {
|
||||
if (U8(movie, MV_TYPE) == 7) {
|
||||
void **tbl = (void **)PTR(movie, MV_CHILDTABLE);
|
||||
int k;
|
||||
for (k = 0; k < 4; k = k + 1) {
|
||||
if (tbl[k] != NULL) {
|
||||
iggy_remove_sprite(player, tbl[k], 0, (void *)1, 1, 0);
|
||||
tbl = (void **)PTR(movie, MV_CHILDTABLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
iggy_free_alloc(player, PTR(movie, MV_CHILDTABLE));
|
||||
}
|
||||
iggy_free_alloc(player, movie);
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0x25a);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:2670-2741 (durango) / 327-448 (vita) */
|
||||
void iggy_destroy_sprite_attachments(void *player, void *movie, int p3) {
|
||||
if (PTR(movie, MV_AS3VAL) != NULL) {
|
||||
void *v = *(void **)PTR(movie, MV_AS3VAL);
|
||||
if (v != (void *)7) {
|
||||
/* clear the boxed value's back-reference (offset 0x27/0x17). */
|
||||
*(void **)AT(v, IGGY_PTR64 ? 0x27 : 0x17) = NULL;
|
||||
}
|
||||
as3vm_pool_free(PTR(player, PL_AS3VM), PTR(movie, MV_AS3VAL));
|
||||
}
|
||||
if (PTR(movie, MV_AS3EXTRA) != NULL) {
|
||||
as3vm_pool_free(PTR(player, PL_AS3VM), PTR(movie, MV_AS3EXTRA));
|
||||
PTR(movie, MV_AS3EXTRA) = NULL;
|
||||
}
|
||||
if (PTR(movie, MV_TEXTURE) != NULL) {
|
||||
if (p3 == 0) {
|
||||
iggy_direct_texture_deref(player, movie);
|
||||
}
|
||||
PTR(movie, MV_TEXTURE) = NULL;
|
||||
}
|
||||
if (PTR(movie, MV_GRAPHICS) != NULL) {
|
||||
iggy_free_graphics(player, movie);
|
||||
}
|
||||
iggy_free_as3_filters(player, movie);
|
||||
{
|
||||
char *obj = (char *)PTR(movie, MV_OBJ);
|
||||
if (obj != NULL && *(int16_t *)AT(obj, 2) == 0 && movie != AT(player, SPR_PL_ROOT)) {
|
||||
char t = *obj;
|
||||
if (t == 1 || t == 3 || t == 4 || (t == 6 && obj != (char *)dummy_text)) {
|
||||
iggy_free_alloc(player, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PTR(movie, MV_FIELD140) != NULL) {
|
||||
*(void **)AT(PTR(movie, MV_FIELD140), IGGY_PTR64 ? 8 : 4) = NULL;
|
||||
}
|
||||
{
|
||||
void *n = PTR(movie, MV_LIST2);
|
||||
while (n != NULL) {
|
||||
void *nx = PTR(n, LIST2_NEXT);
|
||||
as3vm_pool_free(PTR(player, PL_AS3VM), PTR(n, LIST2_VALUE));
|
||||
iggy_free_alloc(player, n);
|
||||
n = nx;
|
||||
}
|
||||
}
|
||||
{
|
||||
void *tf = PTR(movie, MV_TFSTRUCT);
|
||||
if (tf != NULL) {
|
||||
if (PTR(tf, TF_FIELD_C8) != NULL) {
|
||||
iggy_free_alloc(player, PTR(tf, TF_FIELD_C8));
|
||||
}
|
||||
if (PTR(tf, TF_FIELD_68) != NULL) {
|
||||
iggy_free_alloc(player, PTR(tf, TF_FIELD_68));
|
||||
}
|
||||
iggy_destroy_textfield_text(player, tf);
|
||||
iggy_free_alloc(player, tf);
|
||||
PTR(movie, MV_TFSTRUCT) = NULL;
|
||||
}
|
||||
}
|
||||
if (PTR(movie, SPR_NAME) != NULL && (U8(movie, MV_NAMEOWN_FLAG) & 1) != 0) {
|
||||
iggy_free_alloc(player, PTR(movie, SPR_NAME));
|
||||
PTR(movie, SPR_NAME) = NULL;
|
||||
}
|
||||
{
|
||||
void *n;
|
||||
for (n = PTR(movie, MV_LISTENERS); n != NULL; n = PTR(n, LISTENER_NEXT)) {
|
||||
PTR(n, LISTENER_OWNERBACK) = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:2742-2781 (durango) / 452-495 (vita) */
|
||||
void iggy_destroy_sprite_during_shutdown(void *player, void *movie) {
|
||||
if (PTR(movie, MV_AS3VAL) != NULL) {
|
||||
void *v = *(void **)PTR(movie, MV_AS3VAL);
|
||||
if (v != (void *)7) {
|
||||
*(void **)AT(v, IGGY_PTR64 ? 0x27 : 0x17) = NULL;
|
||||
}
|
||||
}
|
||||
iggy_destroy_sprite_attachments(player, movie, 1);
|
||||
{
|
||||
void *child = PTR(movie, MV_CHILD);
|
||||
while (child != NULL) {
|
||||
void *next = PTR(child, MV_NEXT);
|
||||
iggy_destroy_sprite_during_shutdown(player, child);
|
||||
child = next;
|
||||
}
|
||||
}
|
||||
if (PTR(movie, MV_CHILDTABLE) != NULL) {
|
||||
if (U8(movie, MV_TYPE) == 7) {
|
||||
void **tbl = (void **)PTR(movie, MV_CHILDTABLE);
|
||||
int k;
|
||||
for (k = 0; k < 4; k = k + 1) {
|
||||
if (tbl[k] != NULL) {
|
||||
iggy_destroy_sprite_during_shutdown(player, tbl[k]);
|
||||
tbl = (void **)PTR(movie, MV_CHILDTABLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
iggy_free_alloc(player, PTR(movie, MV_CHILDTABLE));
|
||||
}
|
||||
if (PTR(movie, MV_TFSTRUCT) != NULL) {
|
||||
iggy_destroy_textfield_text(player, PTR(movie, MV_TFSTRUCT));
|
||||
iggy_free_alloc(player, PTR(movie, MV_TFSTRUCT));
|
||||
PTR(movie, MV_TFSTRUCT) = NULL;
|
||||
}
|
||||
iggy_free_alloc(player, movie);
|
||||
}
|
||||
|
||||
/* raw:4149-4218 (durango) / 550-644 (vita) */
|
||||
void iggy_remove_sprite(void *player, void *movie, int p3, void *p4, int p5, int p6) {
|
||||
(void)p4;
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_BEGIN))(
|
||||
iggy_tm_normal, 0, 0, 0, 0, iggy_swf_play_source_path, 0x29f, 0, 0);
|
||||
}
|
||||
U8(movie, MV_FLAG1) = U8(movie, MV_FLAG1) & 0xf7;
|
||||
U8(movie, MV_FLAG1) = U8(movie, MV_FLAG1) | (uint8_t)((p6 & 1) << 3);
|
||||
if (PTR(player, PL_AS3VM) != NULL && p3 != 0) {
|
||||
gswf_remove_sprite_do_events(player, movie);
|
||||
}
|
||||
if (PTR(player, PL_AS3VM) != NULL && PTR(movie, MV_PARENT) != NULL &&
|
||||
(U8(movie, MV_B9) & 8) != 0 && p6 != 0) {
|
||||
void **parentval = (void **)PTR(PTR(movie, MV_PARENT), MV_AS3VAL);
|
||||
if (parentval != NULL && *parentval != NULL) {
|
||||
as3vm_set_property_toplevel(PTR(player, PL_AS3VM), *parentval,
|
||||
PTR(movie, SPR_NAME), IGGY_NULLUNDEF_NULL);
|
||||
}
|
||||
}
|
||||
if (PTR(movie, MV_PARENT) != NULL) {
|
||||
if (I32(movie, MV_DEPTHIDX) >= 0) {
|
||||
((void **)PTR(PTR(movie, MV_PARENT), MV_CHILDTABLE))[I32(movie, MV_DEPTHIDX)] = NULL;
|
||||
}
|
||||
if (PTR(PTR(movie, MV_PARENT), MV_CHILD) == movie) {
|
||||
PTR(PTR(movie, MV_PARENT), MV_CHILD) = PTR(movie, MV_NEXT);
|
||||
}
|
||||
if (PTR(PTR(movie, MV_PARENT), MV_LASTCHILD) == movie) {
|
||||
PTR(PTR(movie, MV_PARENT), MV_LASTCHILD) = PTR(movie, MV_PREV);
|
||||
}
|
||||
if (PTR(movie, MV_PARENT) != NULL) {
|
||||
PTR(movie, MV_PARENT) = NULL;
|
||||
iggy_mark_movie_dirty(player, movie);
|
||||
}
|
||||
if (PTR(movie, MV_NEXT) != NULL) {
|
||||
PTR(PTR(movie, MV_NEXT), MV_PREV) = PTR(movie, MV_PREV);
|
||||
}
|
||||
if (PTR(movie, MV_PREV) != NULL) {
|
||||
PTR(PTR(movie, MV_PREV), MV_NEXT) = PTR(movie, MV_NEXT);
|
||||
}
|
||||
PTR(movie, MV_NEXT) = NULL;
|
||||
PTR(movie, MV_PREV) = NULL;
|
||||
}
|
||||
PTR(movie, MV_PREV) = NULL;
|
||||
PTR(movie, MV_NEXT) = PTR(player, PL_UNPARENTED);
|
||||
if (PTR(player, PL_UNPARENTED) != NULL) {
|
||||
PTR(PTR(player, PL_UNPARENTED), MV_PREV) = movie;
|
||||
}
|
||||
PTR(player, PL_UNPARENTED) = movie;
|
||||
if (p5 != 0) {
|
||||
iggy_destroy_sprite(player, movie);
|
||||
}
|
||||
if (iggy_tm_normal != NULL) {
|
||||
(*(void (**)(void *, ...))AT(iggy_tm_normal, TM_HOOK_END))(
|
||||
iggy_tm_normal, 0, 0, iggy_swf_play_source_path, 0x2d4);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:4222-4241 (durango) / 1846-1862 (vita). Export the runtime harness also
|
||||
* stubs -- keep IGGY_EXPORT_OVERRIDABLE so the harness's own definition wins
|
||||
* on Apple builds. */
|
||||
IGGY_EXPORT_OVERRIDABLE
|
||||
void iggy_set_button_state(void *player, void *button, uint8_t p3, int p4) {
|
||||
if (p4 != I8(button, BTN_STATE) && (unsigned)(p4 - 1) < 3 &&
|
||||
PTR(button, MV_CHILDTABLE) != NULL) {
|
||||
void *frame = ((void **)PTR(button, MV_CHILDTABLE))[p4];
|
||||
if (frame != NULL) {
|
||||
iggy_goto_frame_GC(player, frame, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
I8(button, BTN_STATE) = (int8_t)p4;
|
||||
U8(button, BTN_OVERFLAG) = p3;
|
||||
iggy_update_button(player, button);
|
||||
}
|
||||
|
||||
/* raw:3693-3711 (durango) / 3179-3203 (vita, this platform does not build a
|
||||
* per-record definition -- both bodies stamp the same fields). */
|
||||
int64_t iggy_make_empty_button(void *player) {
|
||||
void *btn = iggy_create_movie_for_actionscript_object(player, (void *)dummy_button);
|
||||
I32(btn, MV_MULTISTATE) = 4;
|
||||
{
|
||||
void *tbl = iggy_malloc_fileline(player, 0, IGGY_PTR64 ? 0x20 : 0x10, 0x12,
|
||||
iggy_swf_play_source_path, 0x7f8);
|
||||
PTR(btn, MV_CHILDTABLE) = tbl;
|
||||
((void **)tbl)[0] = NULL;
|
||||
((void **)tbl)[1] = NULL;
|
||||
((void **)tbl)[2] = NULL;
|
||||
((void **)tbl)[3] = NULL;
|
||||
}
|
||||
iggy_set_button_state(player, btn, 0, 1);
|
||||
return (int64_t)(intptr_t)btn;
|
||||
}
|
||||
|
||||
/* raw:4566-4709 (durango). Absent from the vita raw entirely (no textual or
|
||||
* inlined match found) -- RESIDUAL: the BTNDEF_* offsets above could not be
|
||||
* vita-verified; everything else here reuses already cross-verified movie /
|
||||
* player fields. */
|
||||
static void initialize_button_GC(void *player, void *button, void *def) {
|
||||
int up = 0, down = 0, over = 0, hit = 0;
|
||||
int16_t reccount = *(int16_t *)AT(def, BTNDEF_RECCOUNT);
|
||||
char *recs = (char *)PTR(def, BTNDEF_RECARRAY);
|
||||
int state;
|
||||
|
||||
if (reccount > 0) {
|
||||
int i;
|
||||
char *p = recs;
|
||||
for (i = 0; i < reccount; i = i + 1, p += BTNDEF_RECSTRIDE) {
|
||||
uint8_t flags = (uint8_t)*p;
|
||||
if (flags & 1) up = up + 1;
|
||||
if (flags & 2) down = down + 1;
|
||||
if (flags & 4) over = over + 1;
|
||||
if (flags & 8) hit = hit + 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (state = 0; state < 4; state = state + 1) {
|
||||
int counts[4];
|
||||
void *slot = NULL;
|
||||
unsigned bit;
|
||||
int i;
|
||||
|
||||
counts[0] = up; counts[1] = down; counts[2] = over; counts[3] = hit;
|
||||
if (counts[state] != 1) {
|
||||
void *obj = iggy_malloc_fileline(player, 0, IGGY_PTR64 ? 0x48 : 0x24, 0x12,
|
||||
iggy_swf_play_source_path, 0x3e2);
|
||||
memset(obj, 0, IGGY_PTR64 ? 0x48 : 0x24);
|
||||
U16(obj, 0) = 0xff03;
|
||||
U16(obj, IGGY_PTR64 ? 0x28 : 0x14) = 1;
|
||||
slot = iggy_create_movie_for_actionscript_object(player, obj);
|
||||
U32(slot, WRAP_CLEAR) = 0;
|
||||
}
|
||||
|
||||
bit = 1u << (unsigned)state;
|
||||
if (reccount > 0) {
|
||||
char *p = recs;
|
||||
for (i = 0; i < reccount; i = i + 1, p += BTNDEF_RECSTRIDE) {
|
||||
if (((uint8_t)*p) & bit) {
|
||||
void *rec = create_buttonrecord_movie_GC(player, p);
|
||||
I32(rec, MV_DEPTHIDX) = -1;
|
||||
if (slot == NULL) {
|
||||
slot = rec;
|
||||
break;
|
||||
}
|
||||
/* splice rec in as the new head child of slot. */
|
||||
PTR(rec, MV_PARENT) = NULL;
|
||||
if (PTR(player, PL_UNPARENTED) == rec) {
|
||||
PTR(player, PL_UNPARENTED) = PTR(rec, MV_NEXT);
|
||||
}
|
||||
if (PTR(rec, MV_NEXT) != NULL) {
|
||||
PTR(PTR(rec, MV_NEXT), MV_PREV) = PTR(rec, MV_PREV);
|
||||
}
|
||||
if (PTR(rec, MV_PREV) != NULL) {
|
||||
PTR(PTR(rec, MV_PREV), MV_NEXT) = PTR(rec, MV_NEXT);
|
||||
}
|
||||
PTR(rec, MV_PARENT) = slot;
|
||||
PTR(rec, MV_NEXT) = PTR(slot, MV_CHILD);
|
||||
if (PTR(slot, MV_CHILD) == NULL) {
|
||||
PTR(slot, MV_CHILD) = rec;
|
||||
}
|
||||
if (PTR(slot, MV_LASTCHILD) != NULL) {
|
||||
PTR(PTR(slot, MV_LASTCHILD), MV_PREV) = rec;
|
||||
}
|
||||
PTR(rec, MV_PREV) = PTR(slot, MV_LASTCHILD);
|
||||
PTR(slot, MV_LASTCHILD) = rec;
|
||||
slot = rec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
((void **)PTR(button, MV_CHILDTABLE))[state] = slot;
|
||||
/* unparent slot, then make it a direct child of the button. */
|
||||
PTR(slot, MV_PARENT) = NULL;
|
||||
if (PTR(player, PL_UNPARENTED) == slot) {
|
||||
PTR(player, PL_UNPARENTED) = PTR(slot, MV_NEXT);
|
||||
}
|
||||
if (PTR(slot, MV_NEXT) != NULL) {
|
||||
PTR(PTR(slot, MV_NEXT), MV_PREV) = PTR(slot, MV_PREV);
|
||||
}
|
||||
if (PTR(slot, MV_PREV) != NULL) {
|
||||
PTR(PTR(slot, MV_PREV), MV_NEXT) = PTR(slot, MV_NEXT);
|
||||
}
|
||||
I32(slot, MV_DEPTHIDX) = state;
|
||||
PTR(slot, MV_PREV) = NULL;
|
||||
PTR(slot, MV_NEXT) = NULL;
|
||||
PTR(slot, MV_PARENT) = button;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:4431-4472 (durango) / 1802-1842 (vita). */
|
||||
void iggy_update_button(void *player, void *button) {
|
||||
(void)player;
|
||||
{
|
||||
int i;
|
||||
void **tbl = (void **)PTR(button, MV_CHILDTABLE);
|
||||
if ((U8(button, 0) & 0x20) != 0) {
|
||||
int8_t cur = I8(button, BTN_STATE);
|
||||
for (i = 0; i < 4; i = i + 1) {
|
||||
void *m = tbl[i];
|
||||
if (m != NULL) {
|
||||
if (i == cur) U8(m, MV_B9) |= 0x40; else U8(m, MV_B9) &= 0xbf;
|
||||
if (i == 0) U8(m, MV_BA) |= 0x40; else U8(m, MV_BA) &= 0xbf;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < 4; i = i + 1) {
|
||||
void *m = tbl[i];
|
||||
if (m != NULL) {
|
||||
U8(m, MV_B9) = (U8(m, MV_B9) & 0xbf) | ((i == 1) ? 0x40 : 0);
|
||||
U8(m, MV_BA) = U8(m, MV_BA) & 0xbf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:6099-6180 (durango). Fully inlined into swf_update_buttons on vita;
|
||||
* every field below is cross-checked against that inlined vita body. */
|
||||
static void swf_button_update_over(void *player, void *button, void *p3, int p4) {
|
||||
int over = (int)(intptr_t)p3;
|
||||
int8_t state;
|
||||
uint8_t next_over;
|
||||
int next_state;
|
||||
|
||||
if (PTR(player, PL_MOUSEDOWN_BTN) != NULL && button != PTR(player, PL_MOUSEDOWN_BTN)) {
|
||||
iggy_set_button_state(player, button, 0, 1);
|
||||
return;
|
||||
}
|
||||
state = I8(button, BTN_OVERFLAG);
|
||||
if (state == 0) {
|
||||
if (over != 0) {
|
||||
iggy_set_button_state(player, button, 1, 2);
|
||||
}
|
||||
} else if (state == 1) {
|
||||
if (over == 0) {
|
||||
iggy_set_button_state(player, button, 0, 1);
|
||||
}
|
||||
} else if (state == 2) {
|
||||
if (over != 0) {
|
||||
iggy_set_button_state(player, button, 3, 3);
|
||||
}
|
||||
} else if (state == 3 && over == 0) {
|
||||
if (I8(PTR(button, MV_OBJ), IGGY_PTR64 ? 0x46 : 0x32) == (int8_t)over) {
|
||||
iggy_set_button_state(player, button, 2, 2);
|
||||
} else {
|
||||
iggy_set_button_state(player, button, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
state = I8(button, BTN_OVERFLAG);
|
||||
if (state == 1) {
|
||||
if (p4 == 0) return;
|
||||
next_state = 3;
|
||||
PTR(player, PL_MOUSEDOWN_BTN) = button;
|
||||
next_over = 3;
|
||||
} else if (state == 2) {
|
||||
if (p4 != 0) return;
|
||||
next_state = 1;
|
||||
next_over = 0;
|
||||
} else if (state == 3) {
|
||||
if (p4 != 0) return;
|
||||
next_state = 2;
|
||||
next_over = 1;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
iggy_set_button_state(player, button, next_over, next_state);
|
||||
}
|
||||
|
||||
/* raw:6277-6300 (durango) / 4864-4993 (vita, inlined swf_button_update_over
|
||||
* and iggy_set_button_state but confirms the same node fields). */
|
||||
static void swf_update_buttons(void *player, void *node, void *hit, int p4) {
|
||||
if (node != NULL) {
|
||||
void *child;
|
||||
for (child = PTR(node, MV_CHILD); child != NULL; child = PTR(child, MV_NEXT)) {
|
||||
if (PTR(child, MV_OBJ) != NULL) {
|
||||
if (U8(child, MV_TYPE) == 7) {
|
||||
swf_button_update_over(player, child, (void *)(intptr_t)(hit == child), p4);
|
||||
}
|
||||
if (I32(child, MV_MULTISTATE) != 0) {
|
||||
swf_update_buttons(player, child, hit, p4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:595-656 (durango) / 4800-4855 (vita, parameter roles reshuffled by the
|
||||
* vita compiler but the touched field offsets below match durango exactly). */
|
||||
static uint64_t button_under_cursor(void *player, void *matrix, void *node, void *p4,
|
||||
uint32_t p5, uint64_t p6, int p7) {
|
||||
uint8_t concat[24];
|
||||
void *m;
|
||||
void *n;
|
||||
|
||||
if (node == NULL) {
|
||||
return 0;
|
||||
}
|
||||
for (n = PTR(node, MV_LASTCHILD); n != NULL; n = PTR(n, MV_PREV)) {
|
||||
m = matrix;
|
||||
if (p6 != 0 || I32(n, MV_MULTISTATE) != 0) {
|
||||
iggy_matrix_concatenate(concat, matrix, AT(n, IGGY_PTR64 ? 0xd8 : 0x80));
|
||||
m = concat;
|
||||
}
|
||||
if (PTR(n, MV_OBJ) != NULL) {
|
||||
char t = (char)U8(n, MV_TYPE);
|
||||
uint64_t r;
|
||||
if (t == 3 || n == AT(player, SPR_PL_ROOT)) {
|
||||
r = button_under_cursor(player, m, n, p4, p5, p6, 0);
|
||||
} else if (t == 7) {
|
||||
r = is_hit(player, n, m, 0) ? (uint64_t)(uintptr_t)n : 0;
|
||||
} else {
|
||||
if (p6 == 0 || p7 != 0 || t != 1) {
|
||||
continue;
|
||||
}
|
||||
/* elided p5/p6 recovery uncertain -- see report residual note. */
|
||||
if (!iggy_shape_hit_test(player, m, PTR(n, MV_OBJ), p4, NULL, 0)) {
|
||||
continue;
|
||||
}
|
||||
r = p6;
|
||||
}
|
||||
if (r != 0) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
678
iggy-decompiled/src/reconstructed/swf_play_textfield.inc
Normal file
678
iggy-decompiled/src/reconstructed/swf_play_textfield.inc
Normal file
@@ -0,0 +1,678 @@
|
||||
/*
|
||||
* swf_play_textfield.inc -- the EditText lifecycle: create / initialize / free
|
||||
* an EditText runtime sub-struct, the empty-textfield constructor, the
|
||||
* focused-editable-input predicate, and the shared "dynamic graphics" /
|
||||
* AS3-filter-list free helpers used when a display object (of any kind) is
|
||||
* torn down. durango raw line ranges cited per function; every 32-bit offset
|
||||
* is read directly from the vita raw (never halved) and cross-checked via
|
||||
* `llvm-objdump -d -r --disassemble-symbols=<fn>` against
|
||||
* work/iggy-native-decomp/{durango,vita}-objects/swf_play.obj.
|
||||
*
|
||||
* `dummy_text` (the file-static default-EditText-definition blob) is declared
|
||||
* once, in swf_play_sprite.inc (included before this file); this file only
|
||||
* references it. `FOCUSOBJ`, `TF_STRUCT`/`TF_EDITABLE`, `MV_OBJ`,
|
||||
* `TF_FIELD_C8`/`TF_FIELD_68` and `PL_SPRITE_COUNT` are likewise already
|
||||
* frozen by swf_play_player.inc / swf_play_sprite.inc (both included before
|
||||
* this file) and are reused verbatim rather than redefined.
|
||||
*/
|
||||
|
||||
/* -- textfield-family field offsets (width-gated; durango / vita), prefixed
|
||||
* TXT_ to guarantee no collision with sibling .inc files' macros. ---------- */
|
||||
#if IGGY_PTR64
|
||||
#undef TXT_NODE_SIZE
|
||||
# define TXT_NODE_SIZE 0x1a0 /* iggy_malloc_fileline size: a movie node. */
|
||||
#undef TXT_SUB_SIZE
|
||||
# define TXT_SUB_SIZE 0x2c8 /* iggy_malloc_fileline size: EditText sub. */
|
||||
#undef TXT_PL_TFCOUNT
|
||||
# define TXT_PL_TFCOUNT 0x2f2c /* player: live-textfield counter. */
|
||||
#undef TXT_PL_ASDEFAULT
|
||||
# define TXT_PL_ASDEFAULT 0xd88 /* as3vm ctx: default/null AS3 value slot. */
|
||||
/* -- EditText sub-struct ("tf") fields, relative to PTR(movie, TF_STRUCT). -- */
|
||||
#undef TXT_TF_AS3VAL
|
||||
# define TXT_TF_AS3VAL 0x10 /* ptr: cached AS3 value for the text run. */
|
||||
#undef TXT_TF_SCALE
|
||||
# define TXT_TF_SCALE 0x18 /* float: default text-scale (12.0 initial). */
|
||||
#undef TXT_TF_INDENT
|
||||
# define TXT_TF_INDENT 0x24 /* float: paragraph indent, twips/20. */
|
||||
#undef TXT_TF_LEFT
|
||||
# define TXT_TF_LEFT 0x28 /* float: left margin, twips/20. */
|
||||
#undef TXT_TF_RIGHT
|
||||
# define TXT_TF_RIGHT 0x2c /* float: right margin, twips/20. */
|
||||
#undef TXT_TF_COLORDEFAULT
|
||||
# define TXT_TF_COLORDEFAULT 0x74 /* uint: default fill color (0xffffff). */
|
||||
#undef TXT_TF_ZALWAYS
|
||||
# define TXT_TF_ZALWAYS 0x78 /* uint: redundant post-memset zero. */
|
||||
#undef TXT_TF_COLORPACK
|
||||
# define TXT_TF_COLORPACK 0x34 /* uint: packed RGB fill color. */
|
||||
#undef TXT_TF_LETTERSPACE
|
||||
# define TXT_TF_LETTERSPACE 0xc0 /* uint: widened letter-spacing value. */
|
||||
#undef TXT_TF_ALIGN
|
||||
# define TXT_TF_ALIGN 0x5a /* byte: alignment tag copy. */
|
||||
#undef TXT_TF_NAME_B0
|
||||
# define TXT_TF_NAME_B0 0x5b /* byte: resolved-definition byte 0. */
|
||||
#undef TXT_TF_NAME_B1
|
||||
# define TXT_TF_NAME_B1 0x5d /* byte: resolved-definition byte 1. */
|
||||
#undef TXT_TF_BIT4
|
||||
# define TXT_TF_BIT4 0xe8 /* byte bool: flags bit 4 (wordWrap). */
|
||||
#undef TXT_TF_BIT1
|
||||
# define TXT_TF_BIT1 0xe3 /* byte bool: flags bit 1. */
|
||||
#undef TXT_TF_BIT0
|
||||
# define TXT_TF_BIT0 0xe6 /* byte bool: flags bit 0. */
|
||||
#undef TXT_TF_NBIT3
|
||||
# define TXT_TF_NBIT3 0xea /* byte bool: ~flags bit 3. */
|
||||
#undef TXT_TF_E4DUAL
|
||||
# define TXT_TF_E4DUAL 0xe4 /* byte: ~flags bit5 (rect) / autosize=1(!rect).*/
|
||||
#undef TXT_TF_BIT9
|
||||
# define TXT_TF_BIT9 0xe1 /* byte bool: flags bit 9. */
|
||||
#undef TXT_TF_BIT6
|
||||
# define TXT_TF_BIT6 0xde /* byte bool: flags bit 6. */
|
||||
#undef TXT_TF_BIT6DUP
|
||||
# define TXT_TF_BIT6DUP 0xdd /* byte bool: duplicate of TXT_TF_BIT6. */
|
||||
#undef TXT_TF_NBIT1
|
||||
# define TXT_TF_NBIT1 0x100 /* byte bool: ~flags bit 1 (readback). */
|
||||
#undef TXT_TF_FIXEDBOUNDS
|
||||
# define TXT_TF_FIXEDBOUNDS 0xec /* byte: has-explicit-bounds flag (rect only).*/
|
||||
#undef TXT_TF_WIDTH
|
||||
# define TXT_TF_WIDTH 0x94 /* float: text bounds width. */
|
||||
#undef TXT_TF_HEIGHT
|
||||
# define TXT_TF_HEIGHT 0x98 /* float: text bounds height. */
|
||||
#undef TXT_TF_X0
|
||||
# define TXT_TF_X0 0x84 /* float: text bounds left (rect copy). */
|
||||
#undef TXT_TF_Y0
|
||||
# define TXT_TF_Y0 0x88 /* float: text bounds top (rect copy). */
|
||||
#undef TXT_TF_ZRECT_A
|
||||
# define TXT_TF_ZRECT_A 0x90 /* uint: redundant post-memset zero. */
|
||||
#undef TXT_TF_ZRECT_B
|
||||
# define TXT_TF_ZRECT_B 0x8c /* uint: redundant post-memset zero. */
|
||||
#undef TXT_TF_WIDTHCOPY
|
||||
# define TXT_TF_WIDTHCOPY 0x7c /* float: final width copy (both branches). */
|
||||
/* -- text-definition record ("txd" = *PTR(movie, MV_OBJ) when resolving). -- */
|
||||
#undef TXT_D_HASRECT
|
||||
# define TXT_D_HASRECT 2 /* i16: nonzero iff a glyph bounds is set. */
|
||||
#undef TXT_D_LIBSEL
|
||||
# define TXT_D_LIBSEL 1 /* i8: signed library selector (<0 = self). */
|
||||
#undef TXT_D_SYMIDX
|
||||
# define TXT_D_SYMIDX 0x32 /* u16: symbol index within the library. */
|
||||
#undef TXT_D_NAME
|
||||
# define TXT_D_NAME 0x38 /* ptr: direct AS3 linkage name (else 0). */
|
||||
#undef TXT_D_RECT_X0
|
||||
# define TXT_D_RECT_X0 0x20
|
||||
#undef TXT_D_RECT_Y0
|
||||
# define TXT_D_RECT_Y0 0x24
|
||||
#undef TXT_D_RECT_X1
|
||||
# define TXT_D_RECT_X1 0x28
|
||||
#undef TXT_D_RECT_Y1
|
||||
# define TXT_D_RECT_Y1 0x2c
|
||||
#undef TXT_D_COLOR_R
|
||||
# define TXT_D_COLOR_R 0x40
|
||||
#undef TXT_D_COLOR_G
|
||||
# define TXT_D_COLOR_G 0x41
|
||||
#undef TXT_D_COLOR_B
|
||||
# define TXT_D_COLOR_B 0x42
|
||||
#undef TXT_D_ADVANCE
|
||||
# define TXT_D_ADVANCE 0x44
|
||||
#undef TXT_D_LETTERSPACE
|
||||
# define TXT_D_LETTERSPACE 0x46
|
||||
#undef TXT_D_LEFT
|
||||
# define TXT_D_LEFT 0x48
|
||||
#undef TXT_D_RIGHT
|
||||
# define TXT_D_RIGHT 0x4a
|
||||
#undef TXT_D_INDENT
|
||||
# define TXT_D_INDENT 0x4e
|
||||
#undef TXT_D_ALIGN
|
||||
# define TXT_D_ALIGN 0x50
|
||||
#undef TXT_D_FLAGS16
|
||||
# define TXT_D_FLAGS16 0x30
|
||||
/* -- resolved character-definition record ("def"). ------------------------- */
|
||||
#undef TXT_DEF_NAME
|
||||
# define TXT_DEF_NAME 0x80
|
||||
#undef TXT_DEF_B0
|
||||
# define TXT_DEF_B0 0x98
|
||||
#undef TXT_DEF_B1
|
||||
# define TXT_DEF_B1 0x99
|
||||
/* -- character-id lookup table (player, or a library entry). -------------- */
|
||||
#undef TXT_CHARTABLE
|
||||
# define TXT_CHARTABLE 0x98
|
||||
#undef TXT_CHARCOUNT
|
||||
# define TXT_CHARCOUNT 0xa0
|
||||
/* -- "dynamic graphics" node/array offsets (iggy_free_graphics et al). ----- */
|
||||
#undef TXT_GFXLIST_HEAD
|
||||
# define TXT_GFXLIST_HEAD 0x30 /* movie-ish node: dynamic-graphics list. */
|
||||
#undef TXT_GFXSTRUCT
|
||||
# define TXT_GFXSTRUCT 0x48 /* movie-ish node: graphics-struct pointer. */
|
||||
#undef TXT_GFXNODE_NEXT
|
||||
# define TXT_GFXNODE_NEXT 8
|
||||
#undef TXT_GFXNODE_TYPEPTR
|
||||
# define TXT_GFXNODE_TYPEPTR 0x20
|
||||
#undef TXT_GFXNODE_VBUFARR
|
||||
# define TXT_GFXNODE_VBUFARR 0x18
|
||||
#undef TXT_GFXREC_STRIDE
|
||||
# define TXT_GFXREC_STRIDE 0x30
|
||||
#undef TXT_GFXREC_FLAGOFF
|
||||
# define TXT_GFXREC_FLAGOFF 10
|
||||
#undef TXT_GFXREC_FREEOFF
|
||||
# define TXT_GFXREC_FREEOFF 0
|
||||
#undef TXT_GFXARR1
|
||||
# define TXT_GFXARR1 0x20 /* graphics struct: array1 head + count. */
|
||||
#undef TXT_GFXARR2
|
||||
# define TXT_GFXARR2 0x28 /* graphics struct: array2 head. */
|
||||
#undef TXT_GFXEXTRA
|
||||
# define TXT_GFXEXTRA 0x10 /* graphics struct: extra alloc. */
|
||||
#undef TXT_GFXARR1_STRIDE
|
||||
# define TXT_GFXARR1_STRIDE 0x48
|
||||
#undef TXT_GFXARR2_STRIDE
|
||||
# define TXT_GFXARR2_STRIDE 0x58
|
||||
#undef TXT_GFXARR_FLAGOFF
|
||||
# define TXT_GFXARR_FLAGOFF 8
|
||||
#undef TXT_GFXARR_FREEOFF
|
||||
# define TXT_GFXARR_FREEOFF 0x48
|
||||
/* -- AS3 filter-list offsets (iggy_free_as3_filters). ---------------------- */
|
||||
#undef TXT_AS3F_FLAGBYTE
|
||||
# define TXT_AS3F_FLAGBYTE 0xbc
|
||||
#undef TXT_AS3F_COUNT
|
||||
# define TXT_AS3F_COUNT 0x112
|
||||
#undef TXT_AS3F_ARRBASE
|
||||
# define TXT_AS3F_ARRBASE 0xb0
|
||||
#undef TXT_AS3F_STRIDE
|
||||
# define TXT_AS3F_STRIDE 0x38
|
||||
#undef TXT_AS3F_T4A
|
||||
# define TXT_AS3F_T4A 0x20
|
||||
#undef TXT_AS3F_T4B
|
||||
# define TXT_AS3F_T4B 0x28
|
||||
#undef TXT_AS3F_T7A
|
||||
# define TXT_AS3F_T7A 0x28
|
||||
#undef TXT_AS3F_T7B
|
||||
# define TXT_AS3F_T7B 0x30
|
||||
#else
|
||||
#undef TXT_NODE_SIZE
|
||||
# define TXT_NODE_SIZE 0x128
|
||||
#undef TXT_SUB_SIZE
|
||||
# define TXT_SUB_SIZE 0x2ac
|
||||
#undef TXT_PL_TFCOUNT
|
||||
# define TXT_PL_TFCOUNT 0x25dc
|
||||
#undef TXT_PL_ASDEFAULT
|
||||
# define TXT_PL_ASDEFAULT 0x900
|
||||
#undef TXT_TF_AS3VAL
|
||||
# define TXT_TF_AS3VAL 0x08
|
||||
#undef TXT_TF_SCALE
|
||||
# define TXT_TF_SCALE 0x0c
|
||||
#undef TXT_TF_INDENT
|
||||
# define TXT_TF_INDENT 0x18
|
||||
#undef TXT_TF_LEFT
|
||||
# define TXT_TF_LEFT 0x1c
|
||||
#undef TXT_TF_RIGHT
|
||||
# define TXT_TF_RIGHT 0x20
|
||||
#undef TXT_TF_COLORDEFAULT
|
||||
# define TXT_TF_COLORDEFAULT 0x60
|
||||
#undef TXT_TF_ZALWAYS
|
||||
# define TXT_TF_ZALWAYS 0x64
|
||||
#undef TXT_TF_COLORPACK
|
||||
# define TXT_TF_COLORPACK 0x28
|
||||
#undef TXT_TF_LETTERSPACE
|
||||
# define TXT_TF_LETTERSPACE 0xac
|
||||
#undef TXT_TF_ALIGN
|
||||
# define TXT_TF_ALIGN 0x4e
|
||||
#undef TXT_TF_NAME_B0
|
||||
# define TXT_TF_NAME_B0 0x4f
|
||||
#undef TXT_TF_NAME_B1
|
||||
# define TXT_TF_NAME_B1 0x51
|
||||
#undef TXT_TF_BIT4
|
||||
# define TXT_TF_BIT4 0xcc
|
||||
#undef TXT_TF_BIT1
|
||||
# define TXT_TF_BIT1 199
|
||||
#undef TXT_TF_BIT0
|
||||
# define TXT_TF_BIT0 0xca
|
||||
#undef TXT_TF_NBIT3
|
||||
# define TXT_TF_NBIT3 0xce
|
||||
#undef TXT_TF_E4DUAL
|
||||
# define TXT_TF_E4DUAL 200
|
||||
#undef TXT_TF_BIT9
|
||||
# define TXT_TF_BIT9 0xc5
|
||||
#undef TXT_TF_BIT6
|
||||
# define TXT_TF_BIT6 0xc2
|
||||
#undef TXT_TF_BIT6DUP
|
||||
# define TXT_TF_BIT6DUP 0xc1
|
||||
#undef TXT_TF_NBIT1
|
||||
# define TXT_TF_NBIT1 0xe4
|
||||
#undef TXT_TF_FIXEDBOUNDS
|
||||
# define TXT_TF_FIXEDBOUNDS 0xd0
|
||||
#undef TXT_TF_WIDTH
|
||||
# define TXT_TF_WIDTH 0x80
|
||||
#undef TXT_TF_HEIGHT
|
||||
# define TXT_TF_HEIGHT 0x84
|
||||
#undef TXT_TF_X0
|
||||
# define TXT_TF_X0 0x70
|
||||
#undef TXT_TF_Y0
|
||||
# define TXT_TF_Y0 0x74
|
||||
#undef TXT_TF_ZRECT_A
|
||||
# define TXT_TF_ZRECT_A 0x7c
|
||||
#undef TXT_TF_ZRECT_B
|
||||
# define TXT_TF_ZRECT_B 0x78
|
||||
#undef TXT_TF_WIDTHCOPY
|
||||
# define TXT_TF_WIDTHCOPY 0x68
|
||||
#undef TXT_D_HASRECT
|
||||
# define TXT_D_HASRECT 2
|
||||
#undef TXT_D_LIBSEL
|
||||
# define TXT_D_LIBSEL 1
|
||||
#undef TXT_D_SYMIDX
|
||||
# define TXT_D_SYMIDX 0x22
|
||||
#undef TXT_D_NAME
|
||||
# define TXT_D_NAME 0x24
|
||||
#undef TXT_D_RECT_X0
|
||||
# define TXT_D_RECT_X0 0x10
|
||||
#undef TXT_D_RECT_Y0
|
||||
# define TXT_D_RECT_Y0 0x14
|
||||
#undef TXT_D_RECT_X1
|
||||
# define TXT_D_RECT_X1 0x18
|
||||
#undef TXT_D_RECT_Y1
|
||||
# define TXT_D_RECT_Y1 0x1c
|
||||
#undef TXT_D_COLOR_R
|
||||
# define TXT_D_COLOR_R 0x28
|
||||
#undef TXT_D_COLOR_G
|
||||
# define TXT_D_COLOR_G 0x29
|
||||
#undef TXT_D_COLOR_B
|
||||
# define TXT_D_COLOR_B 0x2a
|
||||
#undef TXT_D_ADVANCE
|
||||
# define TXT_D_ADVANCE 0x2c
|
||||
#undef TXT_D_LETTERSPACE
|
||||
# define TXT_D_LETTERSPACE 0x2e
|
||||
#undef TXT_D_LEFT
|
||||
# define TXT_D_LEFT 0x30
|
||||
#undef TXT_D_RIGHT
|
||||
# define TXT_D_RIGHT 0x32
|
||||
#undef TXT_D_INDENT
|
||||
# define TXT_D_INDENT 0x36
|
||||
#undef TXT_D_ALIGN
|
||||
# define TXT_D_ALIGN 0x38
|
||||
#undef TXT_D_FLAGS16
|
||||
# define TXT_D_FLAGS16 0x20
|
||||
#undef TXT_DEF_NAME
|
||||
# define TXT_DEF_NAME 0x4c
|
||||
#undef TXT_DEF_B0
|
||||
# define TXT_DEF_B0 0x58
|
||||
#undef TXT_DEF_B1
|
||||
# define TXT_DEF_B1 0x59
|
||||
#undef TXT_CHARTABLE
|
||||
# define TXT_CHARTABLE 0x78
|
||||
#undef TXT_CHARCOUNT
|
||||
# define TXT_CHARCOUNT 0x7c
|
||||
#undef TXT_GFXLIST_HEAD
|
||||
# define TXT_GFXLIST_HEAD 0x20
|
||||
#undef TXT_GFXSTRUCT
|
||||
# define TXT_GFXSTRUCT 0x2c
|
||||
#undef TXT_GFXNODE_NEXT
|
||||
# define TXT_GFXNODE_NEXT 4
|
||||
#undef TXT_GFXNODE_TYPEPTR
|
||||
# define TXT_GFXNODE_TYPEPTR 0x10
|
||||
#undef TXT_GFXNODE_VBUFARR
|
||||
# define TXT_GFXNODE_VBUFARR 0xc
|
||||
#undef TXT_GFXREC_STRIDE
|
||||
# define TXT_GFXREC_STRIDE 0x28
|
||||
#undef TXT_GFXREC_FLAGOFF
|
||||
# define TXT_GFXREC_FLAGOFF 6
|
||||
#undef TXT_GFXREC_FREEOFF
|
||||
# define TXT_GFXREC_FREEOFF 0
|
||||
#undef TXT_GFXARR1
|
||||
# define TXT_GFXARR1 0x18
|
||||
#undef TXT_GFXARR2
|
||||
# define TXT_GFXARR2 0x1c
|
||||
#undef TXT_GFXEXTRA
|
||||
# define TXT_GFXEXTRA 0x10
|
||||
#undef TXT_GFXARR1_STRIDE
|
||||
# define TXT_GFXARR1_STRIDE 0x3c
|
||||
#undef TXT_GFXARR2_STRIDE
|
||||
# define TXT_GFXARR2_STRIDE 0x4c
|
||||
#undef TXT_GFXARR_FLAGOFF
|
||||
# define TXT_GFXARR_FLAGOFF 4
|
||||
#undef TXT_GFXARR_FREEOFF
|
||||
# define TXT_GFXARR_FREEOFF 0x3c
|
||||
#undef TXT_AS3F_FLAGBYTE
|
||||
# define TXT_AS3F_FLAGBYTE 100
|
||||
#undef TXT_AS3F_COUNT
|
||||
# define TXT_AS3F_COUNT 0xba
|
||||
#undef TXT_AS3F_ARRBASE
|
||||
# define TXT_AS3F_ARRBASE 0x5c
|
||||
#undef TXT_AS3F_STRIDE
|
||||
# define TXT_AS3F_STRIDE 0x2c
|
||||
#undef TXT_AS3F_T4A
|
||||
# define TXT_AS3F_T4A 0x1c
|
||||
#undef TXT_AS3F_T4B
|
||||
# define TXT_AS3F_T4B 0x20
|
||||
#undef TXT_AS3F_T7A
|
||||
# define TXT_AS3F_T7A 0x24
|
||||
#undef TXT_AS3F_T7B
|
||||
# define TXT_AS3F_T7B 0x28
|
||||
#endif
|
||||
|
||||
/* raw:4710-4726 (durango) / no standalone vita symbol -- confirmed identical
|
||||
* via objdump (durango is_focused_input reads player+0x29a8 directly; the
|
||||
* IggyPlayerCut_core/CopyUTF16/HasFocusedEditableTextfield bodies inline the
|
||||
* same predicate reading player+0x2288 on vita) -- the movie must be type 6
|
||||
* (EditText) with an editable EditText sub-struct to count as "focused". */
|
||||
static uint64_t is_focused_input(void *player) {
|
||||
void *focus = PTR(player, FOCUSOBJ);
|
||||
if (focus != NULL && I8(focus, MV_TYPE) == 6 && PTR(focus, TF_STRUCT) != NULL &&
|
||||
I8(PTR(focus, TF_STRUCT), TF_EDITABLE) != 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* raw:2988-3048 walk the movie's dynamic-graphics linked list (a per-frame
|
||||
* dynamic-shape cache), freeing each node's vertex buffers / index list, or
|
||||
* (the unreachable-in-practice branch) trapping if a live vbuf slot is found
|
||||
* with a zero type tag -- durango's `swi(3)` / vita's `software_bkpt(0)`
|
||||
* assertion, translated as a hardware trap (durango returns immediately after
|
||||
* it; that early return is reproduced here). */
|
||||
void iggy_dynamic_graphics_clear_cache(void *player, void *movie) {
|
||||
if (PTR(movie, TXT_GFXLIST_HEAD) == NULL) {
|
||||
return;
|
||||
}
|
||||
{
|
||||
int *countp = PTR(PTR(movie, TXT_GFXSTRUCT), TXT_GFXARR1);
|
||||
int count = (countp == NULL) ? 1 : *countp;
|
||||
void *node = PTR(movie, TXT_GFXLIST_HEAD);
|
||||
void *next;
|
||||
do {
|
||||
void *typeptr = PTR(node, TXT_GFXNODE_TYPEPTR);
|
||||
next = PTR(node, TXT_GFXNODE_NEXT);
|
||||
if (*(intptr_t *)typeptr == 0) {
|
||||
if (count != 0) {
|
||||
__builtin_trap();
|
||||
}
|
||||
} else {
|
||||
if (*(intptr_t *)typeptr != 1) {
|
||||
if (count > 0) {
|
||||
void *vbufarr = PTR(node, TXT_GFXNODE_VBUFARR);
|
||||
intptr_t off = 0;
|
||||
int i = count;
|
||||
do {
|
||||
U8(AT(vbufarr, off), TXT_GFXREC_FLAGOFF) = 0;
|
||||
iggy_free_alloc(player, PTR(AT(vbufarr, off), TXT_GFXREC_FREEOFF));
|
||||
off += TXT_GFXREC_STRIDE;
|
||||
i--;
|
||||
} while (i != 0);
|
||||
}
|
||||
iggy_gdraw_FreeVertexBuffer(player, *(void **)typeptr, typeptr);
|
||||
}
|
||||
iggy_deallocate_vbuf_array(player, node);
|
||||
iggy_free_alloc(player, *(void **)PTR(node, TXT_GFXNODE_VBUFARR));
|
||||
iggy_free_alloc(player, PTR(node, TXT_GFXNODE_VBUFARR));
|
||||
}
|
||||
iggy_free_alloc(player, node);
|
||||
node = next;
|
||||
} while (next != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:3152-3207 free a resolved dynamic-graphics struct's two element arrays
|
||||
* plus its extra allocation, its owning graphics struct, and the node itself
|
||||
* (after first flushing the per-frame dynamic-graphics cache above). */
|
||||
void iggy_free_graphics(void *player, void *movie) {
|
||||
void *gfx = PTR(movie, TXT_GFXSTRUCT);
|
||||
iggy_dynamic_graphics_clear_cache(player, movie);
|
||||
{
|
||||
int *countp = PTR(gfx, TXT_GFXARR1);
|
||||
if (countp != NULL) {
|
||||
intptr_t off = 0;
|
||||
int i = 0;
|
||||
if (*countp > 0) {
|
||||
do {
|
||||
if ((U8(AT(*(void **)AT(gfx, TXT_GFXARR1), off), TXT_GFXARR_FLAGOFF) & 0x70) == 0x10) {
|
||||
iggy_free_alloc(player,
|
||||
PTR(AT(*(void **)AT(gfx, TXT_GFXARR1), off), TXT_GFXARR_FREEOFF));
|
||||
}
|
||||
countp = PTR(gfx, TXT_GFXARR1);
|
||||
i++;
|
||||
off += TXT_GFXARR1_STRIDE;
|
||||
} while (i < *countp);
|
||||
}
|
||||
iggy_free_alloc(player, *(void **)AT(gfx, TXT_GFXARR1));
|
||||
}
|
||||
}
|
||||
{
|
||||
int *countp = PTR(gfx, TXT_GFXARR2);
|
||||
if (countp != NULL) {
|
||||
intptr_t off = 0;
|
||||
int i = 0;
|
||||
if (*countp > 0) {
|
||||
do {
|
||||
if ((U8(AT(*(void **)AT(gfx, TXT_GFXARR2), off), TXT_GFXARR_FLAGOFF) & 0x70) == 0x10) {
|
||||
iggy_free_alloc(player,
|
||||
PTR(AT(*(void **)AT(gfx, TXT_GFXARR2), off), TXT_GFXARR_FREEOFF));
|
||||
}
|
||||
countp = PTR(gfx, TXT_GFXARR2);
|
||||
i++;
|
||||
off += TXT_GFXARR2_STRIDE;
|
||||
} while (i < *countp);
|
||||
}
|
||||
iggy_free_alloc(player, *(void **)AT(gfx, TXT_GFXARR2));
|
||||
}
|
||||
}
|
||||
iggy_free_alloc(player, PTR(PTR(movie, TXT_GFXSTRUCT), TXT_GFXEXTRA));
|
||||
iggy_free_alloc(player, PTR(movie, TXT_GFXSTRUCT));
|
||||
iggy_free_alloc(player, movie);
|
||||
}
|
||||
|
||||
/* raw:3108-3151 free an AS3BitmapFilter list attached to a movie: for each
|
||||
* record whose type tag is 4 or 7, free its two extra payload pointers, then
|
||||
* free the array itself. */
|
||||
void iggy_free_as3_filters(void *player, void *movie) {
|
||||
if ((U8(movie, TXT_AS3F_FLAGBYTE) & 2) == 0) {
|
||||
return;
|
||||
}
|
||||
{
|
||||
int count = (int)(unsigned)U8(movie, TXT_AS3F_COUNT);
|
||||
void *arr = PTR(movie, TXT_AS3F_ARRBASE);
|
||||
if (count != 0) {
|
||||
intptr_t off = 0;
|
||||
int i = 0;
|
||||
do {
|
||||
void *rec = AT(arr, off);
|
||||
uint8_t tag = U8(rec, 0);
|
||||
if (tag == 4) {
|
||||
iggy_free_alloc(player, PTR(rec, TXT_AS3F_T4A));
|
||||
iggy_free_alloc(player, PTR(AT(PTR(movie, TXT_AS3F_ARRBASE), off), TXT_AS3F_T4B));
|
||||
} else if (tag == 7) {
|
||||
iggy_free_alloc(player, PTR(rec, TXT_AS3F_T7A));
|
||||
iggy_free_alloc(player, PTR(AT(PTR(movie, TXT_AS3F_ARRBASE), off), TXT_AS3F_T7B));
|
||||
}
|
||||
i++;
|
||||
off += TXT_AS3F_STRIDE;
|
||||
arr = PTR(movie, TXT_AS3F_ARRBASE);
|
||||
} while (i < count);
|
||||
}
|
||||
if (PTR(movie, TXT_AS3F_ARRBASE) != NULL) {
|
||||
iggy_free_alloc(player, PTR(movie, TXT_AS3F_ARRBASE));
|
||||
PTR(movie, TXT_AS3F_ARRBASE) = NULL;
|
||||
}
|
||||
U8(movie, TXT_AS3F_COUNT) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:3208-3225 free the EditText runtime sub-struct's two owned allocations,
|
||||
* its stored text, then the sub-struct itself. */
|
||||
void iggy_free_textfield(void *player, void *movie) {
|
||||
if (PTR(movie, TF_FIELD_C8) != NULL) {
|
||||
iggy_free_alloc(player, PTR(movie, TF_FIELD_C8));
|
||||
}
|
||||
if (PTR(movie, TF_FIELD_68) != NULL) {
|
||||
iggy_free_alloc(player, PTR(movie, TF_FIELD_68));
|
||||
}
|
||||
iggy_destroy_textfield_text(player, movie);
|
||||
iggy_free_alloc(player, movie);
|
||||
}
|
||||
|
||||
/* raw:2468-2520 allocate + zero a bare EditText movie node (the movie-node
|
||||
* "zero state" stamp, matching iggy_zero_movie_state's pattern, plus the
|
||||
* EditText-specific defaults: MV_OBJ defaults to the shared `dummy_text`
|
||||
* placeholder definition, and the type tag is stamped 6 (EditText)). */
|
||||
void *iggy_create_textfield(void *player) {
|
||||
void *node = iggy_malloc_fileline(player, 0, TXT_NODE_SIZE, 0x14,
|
||||
iggy_swf_play_source_path, 0x40a);
|
||||
I32(player, TXT_PL_TFCOUNT) = I32(player, TXT_PL_TFCOUNT) + 1;
|
||||
I32(player, PL_SPRITE_COUNT) = I32(player, PL_SPRITE_COUNT) + 1;
|
||||
memset(node, 0, TXT_NODE_SIZE);
|
||||
#if IGGY_PTR64
|
||||
U8(node, 0xb9) = U8(node, 0xb9) | 0x41;
|
||||
U8(node, 0) = U8(node, 0) & 0xfe;
|
||||
U8(node, 0xba) = U8(node, 0xba) | 0x70;
|
||||
U8(node, 0xe0) = 0; U8(node, 0xe1) = 0; U8(node, 0xe2) = 0; U8(node, 0xe3) = 0;
|
||||
U8(node, 0xc4) = 0xff; U8(node, 0xc5) = 0xff; U8(node, 0xc6) = 0xff; U8(node, 0xc7) = 0xff;
|
||||
PTR(node, 0x180) = NULL; /* &DAT_0000eb29 (inert empty-name sentinel). */
|
||||
U8(node, 0x170) = 0xff; U8(node, 0x171) = 0xff; U8(node, 0x172) = 0xff; U8(node, 0x173) = 0xff;
|
||||
U8(node, 0x110) = 0xff; U8(node, 0x111) = 0xff;
|
||||
U8(node, 0x114) = 0xff; U8(node, 0x115) = 0xff;
|
||||
U8(node, 0x116) = 0xff; U8(node, 0x117) = 0xff;
|
||||
PTR(node, MV_OBJ) = (void *)dummy_text;
|
||||
U8(node, 0xd8) = 0; U8(node, 0xd9) = 0; U8(node, 0xda) = 0x80; U8(node, 0xdb) = 0x3f; /* 1.0f. */
|
||||
U8(node, 0xdc) = 0; U8(node, 0xdd) = 0; U8(node, 0xde) = 0; U8(node, 0xdf) = 0;
|
||||
U8(node, 0xe4) = 0; U8(node, 0xe5) = 0; U8(node, 0xe6) = 0x80; U8(node, 0xe7) = 0x3f; /* 1.0f.*/
|
||||
#else
|
||||
U8(node, 0x6c) = 0xff; U8(node, 0x6d) = 0xff; U8(node, 0x6e) = 0xff; U8(node, 0x6f) = 0xff;
|
||||
U8(node, 0x80) = 0; U8(node, 0x81) = 0; U8(node, 0x82) = 0x80; U8(node, 0x83) = 0x3f; /*1.0f.*/
|
||||
U8(node, 0x84) = 0; U8(node, 0x85) = 0; U8(node, 0x86) = 0; U8(node, 0x87) = 0;
|
||||
U8(node, 0x88) = 0; U8(node, 0x89) = 0; U8(node, 0x8a) = 0; U8(node, 0x8b) = 0;
|
||||
U8(node, 0x8c) = 0; U8(node, 0x8d) = 0; U8(node, 0x8e) = 0x80; U8(node, 0x8f) = 0x3f; /*1.0f.*/
|
||||
U8(node, 0x100) = 0xff; U8(node, 0x101) = 0xff; U8(node, 0x102) = 0xff; U8(node, 0x103) = 0xff;
|
||||
U8(node, 0x61) = U8(node, 0x61) | 0x41;
|
||||
U8(node, 0xb8) = 0xff; U8(node, 0xb9) = 0xff;
|
||||
U8(node, 0) = U8(node, 0) & 0xfe;
|
||||
U8(node, 0xbc) = 0xff; U8(node, 0xbd) = 0xff; U8(node, 0xbe) = 0xff; U8(node, 0xbf) = 0xff;
|
||||
U8(node, 0x62) = U8(node, 0x62) | 0x70;
|
||||
PTR(node, 0x110) = NULL; /* &DAT_00019031 (inert empty-name sentinel). */
|
||||
PTR(node, MV_OBJ) = (void *)dummy_text;
|
||||
#endif
|
||||
I8(node, 3) = 6;
|
||||
iggy_set_movie_defaults(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
/* raw:3300-3441 allocate + populate the EditText runtime sub-struct from the
|
||||
* cached text-definition record at MV_OBJ (bounds, color, margins, alignment
|
||||
* flags, indent, letter-spacing, and the resolved font-linkage AS3 name),
|
||||
* then (if requested) push the initial text/htmltext. The elided
|
||||
* `iggy_get_symbol(param_1)` / `iggy_edittext_clear(param_1)` calls are
|
||||
* completed per the objdump-resolved operands (player, and the definition's
|
||||
* direct-name field / the freshly allocated sub-struct, respectively). */
|
||||
void iggy_init_textfield(void *player, void *movie, void *p3, int p4) {
|
||||
void *tf = iggy_malloc_fileline(player, 0, TXT_SUB_SIZE, 0x17,
|
||||
iggy_swf_play_source_path, 0x31f);
|
||||
PTR(movie, TF_STRUCT) = tf;
|
||||
memset(tf, 0, TXT_SUB_SIZE);
|
||||
PTR(tf, 0) = movie;
|
||||
iggy_edittext_clear(player, tf);
|
||||
|
||||
if (PTR(player, PL_AS3VM) != NULL) {
|
||||
UPTR(tf, TXT_TF_AS3VAL) = UPTR(PTR(player, PL_AS3VM), TXT_PL_ASDEFAULT);
|
||||
} else {
|
||||
UPTR(tf, TXT_TF_AS3VAL) = 0;
|
||||
}
|
||||
F32(tf, TXT_TF_SCALE) = 12.0f;
|
||||
U32(movie, TXT_TF_ZALWAYS) = 0;
|
||||
U32(movie, TXT_TF_COLORDEFAULT) = 0xffffff;
|
||||
|
||||
{
|
||||
void *txd = PTR(movie, MV_OBJ);
|
||||
int rendered_html = 1;
|
||||
if (I16(txd, TXT_D_HASRECT) == 0) {
|
||||
F32(tf, TXT_TF_WIDTH) = 100.0f;
|
||||
F32(tf, TXT_TF_HEIGHT) = 100.0f;
|
||||
U32(tf, TXT_TF_X0) = 0;
|
||||
U32(tf, TXT_TF_Y0) = 0;
|
||||
U8(tf, TXT_TF_E4DUAL) = 1;
|
||||
} else {
|
||||
uint16_t flags = U16(txd, TXT_D_FLAGS16);
|
||||
int bit1 = (flags >> 1) & 1;
|
||||
U8(tf, TXT_TF_BIT4) = (uint8_t)((flags >> 4) & 1);
|
||||
U32(tf, TXT_TF_LETTERSPACE) = (uint32_t)U16(txd, TXT_D_LETTERSPACE);
|
||||
U8(tf, TXT_TF_BIT1) = (uint8_t)bit1;
|
||||
U8(tf, TXT_TF_BIT0) = (uint8_t)(flags & 1);
|
||||
U8(tf, TXT_TF_NBIT3) = (uint8_t)(~(flags >> 3) & 1);
|
||||
U8(tf, TXT_TF_E4DUAL) = (uint8_t)(~(flags >> 5) & 1);
|
||||
U8(tf, TXT_TF_BIT9) = (uint8_t)((flags >> 9) & 1);
|
||||
U8(tf, TXT_TF_BIT6) = (uint8_t)((flags >> 6) & 1);
|
||||
U8(tf, TXT_TF_NBIT1) = (uint8_t)(bit1 == 0);
|
||||
U8(tf, TXT_TF_BIT6DUP) = U8(tf, TXT_TF_BIT6);
|
||||
rendered_html = (flags >> 8) & 1;
|
||||
U8(tf, TXT_TF_ALIGN) = U8(txd, TXT_D_ALIGN);
|
||||
|
||||
UPTR(tf, TXT_TF_AS3VAL) = 0;
|
||||
F32(tf, TXT_TF_SCALE) = (float)U16(txd, TXT_D_ADVANCE) / 20.0f;
|
||||
|
||||
if (PTR(txd, TXT_D_NAME) == NULL) {
|
||||
uint16_t symidx = U16(txd, TXT_D_SYMIDX);
|
||||
if (symidx != 0) {
|
||||
void *lib;
|
||||
int8_t libsel = I8(txd, TXT_D_LIBSEL);
|
||||
if (libsel < 0) {
|
||||
lib = PTR(player, TXT_CHARTABLE);
|
||||
} else {
|
||||
void *libptr = iggy_libraries[(unsigned)libsel];
|
||||
if (libptr == NULL || *(int32_t *)AT(libptr, TXT_CHARCOUNT) <= (int)(unsigned)symidx) {
|
||||
goto rect_done;
|
||||
}
|
||||
lib = PTR(libptr, TXT_CHARTABLE);
|
||||
}
|
||||
{
|
||||
void *def = *(void **)AT(lib, (intptr_t)symidx * sizeof(void *));
|
||||
if (def != NULL) {
|
||||
void *name = PTR(def, TXT_DEF_NAME);
|
||||
if (name != NULL && PTR(player, PL_AS3VM) != NULL) {
|
||||
int len = rrwcslen(name);
|
||||
UPTR(tf, TXT_TF_AS3VAL) =
|
||||
(uintptr_t)as3vm_find_intern_string(PTR(player, PL_AS3VM), len, name, 1);
|
||||
}
|
||||
U8(tf, TXT_TF_NAME_B0) = U8(def, TXT_DEF_B0);
|
||||
U8(tf, TXT_TF_NAME_B1) = U8(def, TXT_DEF_B1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
void *def = (void *)(uintptr_t)iggy_get_symbol(player, PTR(txd, TXT_D_NAME));
|
||||
if (def != NULL) {
|
||||
void *name = PTR(def, TXT_DEF_NAME);
|
||||
int len = rrwcslen(name);
|
||||
UPTR(tf, TXT_TF_AS3VAL) =
|
||||
(uintptr_t)as3vm_find_intern_string(PTR(player, PL_AS3VM), len, name, 1);
|
||||
}
|
||||
}
|
||||
rect_done:
|
||||
U32(tf, TXT_TF_COLORPACK) = ((uint32_t)U8(txd, TXT_D_COLOR_R) << 16) +
|
||||
((uint32_t)U8(txd, TXT_D_COLOR_G) << 8) +
|
||||
(uint32_t)U8(txd, TXT_D_COLOR_B);
|
||||
F32(tf, TXT_TF_LEFT) = (float)U16(txd, TXT_D_LEFT) / 20.0f;
|
||||
F32(tf, TXT_TF_RIGHT) = (float)U16(txd, TXT_D_RIGHT) / 20.0f;
|
||||
F32(tf, TXT_TF_INDENT) = (float)(int16_t)I16(txd, TXT_D_INDENT) / 20.0f;
|
||||
|
||||
F32(movie, TXT_TF_WIDTH) = F32(txd, TXT_D_RECT_X1) - F32(txd, TXT_D_RECT_X0);
|
||||
F32(movie, TXT_TF_HEIGHT) = F32(txd, TXT_D_RECT_Y1) - F32(txd, TXT_D_RECT_Y0);
|
||||
F32(movie, TXT_TF_X0) = F32(txd, TXT_D_RECT_X0);
|
||||
F32(movie, TXT_TF_Y0) = F32(txd, TXT_D_RECT_Y0);
|
||||
U32(movie, TXT_TF_ZRECT_A) = 0;
|
||||
U32(movie, TXT_TF_ZRECT_B) = 0;
|
||||
U8(movie, TXT_TF_FIXEDBOUNDS) = 1;
|
||||
}
|
||||
tf = PTR(movie, TF_STRUCT);
|
||||
F32(tf, TXT_TF_WIDTHCOPY) = F32(tf, TXT_TF_WIDTH);
|
||||
if (p4 != 0) {
|
||||
if (rendered_html) {
|
||||
iggy_set_textfield_htmltext(player, tf, p3, p4);
|
||||
} else {
|
||||
iggy_set_textfield_text(player, tf, p3, p4, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* raw:3763-3779 allocate a default-initialized EditText and splice it onto
|
||||
* the player's unparented-object list (node+0x88/+0x48 = MV_PREV cleared,
|
||||
* node+8 = MV_NEXT linked to the prior head) -- identical to the already
|
||||
* exported iggy_add_to_unparented (swf_play_movie.inc), called directly
|
||||
* rather than duplicating its body. */
|
||||
int64_t iggy_make_empty_textfield(void *player) {
|
||||
void *node = iggy_create_textfield(player);
|
||||
iggy_init_textfield(player, node, 0, 0);
|
||||
iggy_add_to_unparented(player, node);
|
||||
return (int64_t)(intptr_t)node;
|
||||
}
|
||||
72
tests/data/swf_play_expected_imports.txt
Normal file
72
tests/data/swf_play_expected_imports.txt
Normal file
@@ -0,0 +1,72 @@
|
||||
IggyPlayerPasteUTF16
|
||||
as3vm_RunFunction
|
||||
as3vm_clean_listeners
|
||||
as3vm_construct_post_GC
|
||||
as3vm_construct_pre_GC
|
||||
as3vm_construct_swf_type_GC
|
||||
as3vm_do_direct_event_GC
|
||||
as3vm_do_displayobject_event_GC
|
||||
as3vm_do_event_timer_GC
|
||||
as3vm_do_focus_event_GC
|
||||
as3vm_do_keyboard_event_GC
|
||||
as3vm_do_mouse_event_GC
|
||||
as3vm_find_intern_string
|
||||
as3vm_get_stage
|
||||
as3vm_interpreter_initialize
|
||||
as3vm_nullundef_storage
|
||||
as3vm_pool_alloc
|
||||
as3vm_pool_free
|
||||
as3vm_set_property_toplevel
|
||||
as3vm_setup_DisplayObject
|
||||
as3vm_write_barrier_slowpath
|
||||
iggy_arena_malloc
|
||||
iggy_begin_execution
|
||||
iggy_change_sample
|
||||
iggy_clear_movie_dirty
|
||||
iggy_deallocate_vbuf_array
|
||||
iggy_destroy_textfield_text
|
||||
iggy_direct_texture_deref
|
||||
iggy_edittext_char
|
||||
iggy_edittext_clear
|
||||
iggy_edittext_copy_utf16
|
||||
iggy_edittext_copy_utf8
|
||||
iggy_edittext_cut
|
||||
iggy_edittext_down
|
||||
iggy_edittext_drag
|
||||
iggy_edittext_keydown
|
||||
iggy_edittext_paste_utf16
|
||||
iggy_end_execution
|
||||
iggy_force_default_smoothing
|
||||
iggy_free_alloc
|
||||
iggy_free_voice
|
||||
iggy_free_voice_if_done
|
||||
iggy_gdraw_FreeVertexBuffer
|
||||
iggy_get_o2p
|
||||
iggy_get_o2w
|
||||
iggy_get_seconds_best_effort
|
||||
iggy_goto_frame_GC
|
||||
iggy_halt_voice
|
||||
iggy_initialize_main_timeline_3d
|
||||
iggy_inverse_transform
|
||||
iggy_libraries
|
||||
iggy_malloc_fileline
|
||||
iggy_mark_movie_dirty
|
||||
iggy_matrix_concatenate
|
||||
iggy_play_adpcm
|
||||
iggy_play_mp3
|
||||
iggy_play_uncompressed
|
||||
iggy_play_voice
|
||||
iggy_seek_behavior_version
|
||||
iggy_seek_frame_GC
|
||||
iggy_send_display_tree
|
||||
iggy_send_error
|
||||
iggy_set_bounds
|
||||
iggy_set_textfield_htmltext
|
||||
iggy_set_textfield_text
|
||||
iggy_textfield_select_all
|
||||
iggy_tm_normal
|
||||
iggy_uncaught_exception_warning
|
||||
rrGetTicks
|
||||
rrUTF8toUTF16
|
||||
rrwcscmp
|
||||
rrwcslen
|
||||
150
tests/support/swf_play_test_support.c
Normal file
150
tests/support/swf_play_test_support.c
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Host harness for the reconstructed swf_play translation unit.
|
||||
*
|
||||
* swf_play is Iggy's movie playback + display-list execution runtime: the
|
||||
* IggyPlayer tick / play / pause entry points (IggyPlayerTickRS_core,
|
||||
* IggyPlayerPlay, IggyPlayerPause, IggyPlayerReadyToTick), the movie advance /
|
||||
* PlaceObject / framescript engine (iggy_advance_movie_GC, iggy_do_placeobject_GC,
|
||||
* iggy_play_framescripts), the sprite / textfield / button / shape lifecycle
|
||||
* (iggy_make_empty_sprite / _shape / _button / _textfield, iggy_destroy_sprite,
|
||||
* iggy_create_textfield), hit-testing (iggy_hit_test_point, iggy_shape_hit_test),
|
||||
* focus + clipboard (IggyPlayerSetFocus_core, IggyPlayerCut_core,
|
||||
* IggyPlayerPasteUTF8_core) and the module-owned double-click timing global.
|
||||
* It exports EXACTLY 68 entry points on all four platforms (durango / orbis /
|
||||
* ps3 / vita) and OWNS a single externally named data global,
|
||||
* iggy_double_click_time (a 4-byte float defaulting to 0.5, present on ALL four
|
||||
* platforms).
|
||||
*
|
||||
* The DURANGO runtime test builds ONLY the durango dylib, so the 64-bit layout is
|
||||
* authoritative. The pinned leaf behaviours reach only a handful of imports:
|
||||
*
|
||||
* iggy_get_symbol -> reads the swf_decode-owned iggy_libraries[0x20]
|
||||
* pointer array (an IMPORT here) and rrwcscmp's each
|
||||
* candidate export name. The harness DEFINES
|
||||
* iggy_libraries (swf_play only references it) and
|
||||
* exposes a per-slot setter. (raw durango:3226)
|
||||
* iggy_make_empty_sprite / iggy_make_empty_shape
|
||||
* -> iggy_malloc_fileline for the object and
|
||||
* iggy_create_movie_for_actionscript_object for the
|
||||
* wrapper; both are controllable stubs returning a
|
||||
* test-owned buffer. (raw durango:3715/3737)
|
||||
* iggy_zero_movie_state -> memset (resolved from libc, no stub). (raw durango:4521)
|
||||
*
|
||||
* Every other import (the ~70 as3vm_* / iggy_* / rr* surface -- the AS3 VM event
|
||||
* dispatch, the voice / audio path, the seek queue, the GC hooks, ...) is
|
||||
* referenced only inside the deep, un-exercised engine bodies (TickRS_core,
|
||||
* advance_movie_GC, do_placeobject_GC, play_framescripts, hit_test_point_rec) and
|
||||
* is left to -Wl,-undefined,dynamic_lookup: never called at runtime, never bound.
|
||||
* Only the reached symbols are provided below, as recording / controllable stubs
|
||||
* so the durango dylib links and the real leaf bodies run.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/* ---- Recording counters. ---- */
|
||||
static size_t wcscmp_count;
|
||||
static size_t malloc_fileline_count;
|
||||
static size_t create_movie_count;
|
||||
|
||||
/* Controllable stub returns. */
|
||||
static void *malloc_result; /* iggy_malloc_fileline return. */
|
||||
static void *create_result; /* iggy_create_movie_for_actionscript_object. */
|
||||
|
||||
/* Last object handed to iggy_create_movie_for_actionscript_object (the freshly
|
||||
* built sprite / shape), so a test can confirm which buffer was wrapped. */
|
||||
static void *last_created_object;
|
||||
|
||||
/*
|
||||
* iggy_libraries -- swf_decode's module-owned 0x20-slot library pointer array.
|
||||
* swf_play only *references* it (iggy_get_symbol walks it), so under the module
|
||||
* boundary it is an IMPORT of swf_play; the harness owns the concrete storage so
|
||||
* the durango dylib resolves and iggy_get_symbol can round-trip through it. In a
|
||||
* full link this symbol is provided by the reconstructed swf_decode object.
|
||||
*/
|
||||
void *iggy_libraries[0x20];
|
||||
|
||||
void swf_play_test_reset(void) {
|
||||
wcscmp_count = 0;
|
||||
malloc_fileline_count = 0;
|
||||
create_movie_count = 0;
|
||||
malloc_result = 0;
|
||||
create_result = 0;
|
||||
last_created_object = 0;
|
||||
memset(iggy_libraries, 0, sizeof(iggy_libraries));
|
||||
}
|
||||
|
||||
/* ---- Count / last-value accessors. ---- */
|
||||
size_t swf_play_test_wcscmp_count(void) { return wcscmp_count; }
|
||||
size_t swf_play_test_malloc_fileline_count(void) { return malloc_fileline_count; }
|
||||
size_t swf_play_test_create_movie_count(void) { return create_movie_count; }
|
||||
void *swf_play_test_last_created_object(void) { return last_created_object; }
|
||||
|
||||
/* ---- Controllable stub setters. ---- */
|
||||
void swf_play_test_set_malloc_result(void *result) { malloc_result = result; }
|
||||
void swf_play_test_set_create_result(void *result) { create_result = result; }
|
||||
|
||||
/* Set one slot of the harness-owned iggy_libraries array. */
|
||||
void swf_play_test_set_library(int index, void *library) {
|
||||
if (index >= 0 && index < 0x20) {
|
||||
iggy_libraries[index] = library;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- Imports (recording / controllable stubs). ---- */
|
||||
|
||||
/*
|
||||
* RAD wide-string compare (iggy runtime). Faithful-enough model: 0 iff the two
|
||||
* name pointers are identical. iggy_get_symbol's tests arrange the "hit" operands
|
||||
* to be the SAME buffer (a real wcscmp of one string against itself is also 0) and
|
||||
* the "miss" operands to be distinct buffers (a real wcscmp is non-zero), so the
|
||||
* equality model and any faithful wide-compare agree on every case exercised.
|
||||
* Symmetric, so robust to argument order.
|
||||
*/
|
||||
int rrwcscmp(const void *a, const void *b) {
|
||||
++wcscmp_count;
|
||||
return a == b ? 0 : 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* iggy allocation (iggy_allocation). The make_empty_* constructors call this to
|
||||
* obtain the raw object storage; the controllable return lets a test hand back a
|
||||
* buffer it can then inspect for the constructor's field initialisation. The
|
||||
* (ctx, flags, size, tag, file, line) argument shape matches the retail
|
||||
* iggy_malloc_fileline; all but the size are opaque here.
|
||||
*/
|
||||
void *iggy_malloc_fileline(void *ctx, int flags, uint64_t size, int tag,
|
||||
const char *file, int line) {
|
||||
(void)ctx;
|
||||
(void)flags;
|
||||
(void)size;
|
||||
(void)tag;
|
||||
(void)file;
|
||||
(void)line;
|
||||
++malloc_fileline_count;
|
||||
return malloc_result;
|
||||
}
|
||||
|
||||
/*
|
||||
* iggy movie-object wrapper factory (iggy_main / render). make_empty_* pass the
|
||||
* freshly built object here to obtain its DisplayObject wrapper; the controllable
|
||||
* return is a test-owned buffer whose +0x178 field the constructor then clears.
|
||||
*/
|
||||
void *iggy_create_movie_for_actionscript_object(void *ctx, void *object) {
|
||||
(void)ctx;
|
||||
++create_movie_count;
|
||||
last_created_object = object;
|
||||
return create_result;
|
||||
}
|
||||
|
||||
/*
|
||||
* iggy button state machine (swf_play sibling, iggy_main). make_empty_button
|
||||
* calls it after wiring the button record; recorded only so make_empty_button
|
||||
* would link if a test exercised it (button init is otherwise deferred).
|
||||
*/
|
||||
void iggy_set_button_state(void *ctx, void *button, int a, int b) {
|
||||
(void)ctx;
|
||||
(void)button;
|
||||
(void)a;
|
||||
(void)b;
|
||||
}
|
||||
431
tests/test_reconstructed_swf_play.py
Normal file
431
tests/test_reconstructed_swf_play.py
Normal file
@@ -0,0 +1,431 @@
|
||||
"""Runtime tests for the reconstructed swf_play translation unit.
|
||||
|
||||
RED STATE: swf_play.c / swf_play.h do not exist yet, so setUpClass raises
|
||||
"missing swf_play runtime inputs". Every assertion below is grounded in a
|
||||
specific line of iggy-decompiled/raw/durango/swf_play.c (cited inline) and, where
|
||||
a struct offset is load-bearing, in the durango swf_play.obj disassembly (cited as
|
||||
"disasm"). A faithful DURANGO reconstruction turns these green.
|
||||
|
||||
swf_play is Iggy's movie playback + display-list execution runtime: the IggyPlayer
|
||||
tick / play / pause entry points, the movie advance / PlaceObject / framescript
|
||||
engine, the sprite / textfield / button / shape lifecycle, hit-testing, focus and
|
||||
clipboard. It exports EXACTLY 68 entry points on all four platforms and OWNS a
|
||||
single externally named data global -- iggy_double_click_time, a 4-byte float
|
||||
defaulting to 0.5 (IggySetDoubleClickTime writes it as milliseconds / 1000.0).
|
||||
|
||||
WHAT IS PINNED (real, deterministic DURANGO behaviour):
|
||||
IggySetDoubleClickTime(ms) -- iggy_double_click_time = (float)ms / 1000.0;
|
||||
pure, no imports. Read back via ctypes' c_float.in_dll. (raw:526-532;
|
||||
disasm vdivss by __real@447a0000, vmovss into iggy_double_click_time.)
|
||||
IggyPlayerReadyToTick(p) -- returns 0 when p is NULL or p->initialized==0,
|
||||
reaching no import. initialized is at struct offset 0x1f38. (raw:377-381;
|
||||
disasm testq/cmpl $0,0x1f38(rcx).)
|
||||
IggyPlayerPause(p, mode) -- gated on p->initialized (0x1f38); when set, stores
|
||||
1 at the pause flag p+0x2880 (unknown_2870[0x10]); mode != pause_audio(1) and
|
||||
!= stop_audio(2) skips the voice loop entirely (pure). (raw:299-334;
|
||||
disasm cmpl $0,0x1f38 / movb $1,0x2880 / decl edx twice.)
|
||||
IggyPlayerPlay(p) -- gated on p->initialized (0x1f38); uninitialized is
|
||||
a pure no-op. (The initialized path clears the flag AND calls
|
||||
IggyPlayerReadyToTick + the voice loop -> deferred.) (raw:343-350;
|
||||
disasm cmpl $0,0x1f38 / je ret.)
|
||||
iggy_set_movie_defaults(m) -- OR/mask field writes: m[0xb9]|=0x40, m[1]|=2,
|
||||
m[0xba]=(m[0xba]&0xf)|0x70, m[0x114]=0xffffffff, m[0x178]=1, m[0x17c]=1; the
|
||||
trailing type-switch dispatch (m[3]-1 < 7) is skipped when m[3]==0 (pure).
|
||||
(raw:4343-4364.)
|
||||
iggy_zero_movie_state(m) -- memset(m,0,0x1a0) then a fixed byte pattern:
|
||||
m[0xb9]|=0x41, m[0]&=0xfe, m[0xba]|=0x70, the float 1.0 (0x3f800000) at m+0xd8
|
||||
and m+0xe4, 0xff run-fills at m+0xc4 / m+0x170 / m+0x114. (raw:4523-4523.)
|
||||
iggy_get_symbol(movie,name) -- scans the movie's 0x20-bit library mask at
|
||||
movie+0x264; for each set bit indexes iggy_libraries[i] (an IMPORT the harness
|
||||
owns) and walks that library's export table (count @ lib+0x230, table @
|
||||
lib+0x228, stride 0x18, name @ +8 rrwcscmp'd, value @ +0 returned); 0 on miss.
|
||||
(raw:3228-3260; disasm 0x264/
|
||||
0x230/0x228, IMAGE_REL to iggy_libraries.)
|
||||
iggy_make_empty_sprite/_shape(ctx) -- iggy_malloc_fileline the object, stamp its
|
||||
type tag (sprite 0xff03 / shape 0xff01) and a field, then
|
||||
iggy_create_movie_for_actionscript_object the wrapper and clear wrapper+0x178.
|
||||
(raw:3717-3730/3737-3758.)
|
||||
|
||||
DEFERRED (flagged structural, NOT exercised): the deep engine paths --
|
||||
IggyPlayerTickRS_core, iggy_advance_movie_GC / _raw_GC, iggy_do_placeobject_GC,
|
||||
iggy_do_placement, iggy_play_framescript(s)(_complete), iggy_hit_test_point /
|
||||
iggy_shape_hit_test, the focus / clipboard cores (SetFocus_core, Cut_core,
|
||||
Paste*_core, Copy*, DispatchEventRS_core, GetFocusableObjects,
|
||||
HasFocusedEditableTextfield, SendFrameToExplorer), the sprite / textfield / button
|
||||
teardown and creation (iggy_destroy_sprite*, iggy_create_textfield,
|
||||
iggy_init_textfield, iggy_free_textfield, iggy_make_empty_button /
|
||||
iggy_make_empty_textfield, iggy_finish_creating_movie_GC), the seek queue, the
|
||||
audio / voice path (iggy_play_sound, iggy_update_voice, iggy_do_playsound) and
|
||||
iggy_is_weak_ptr (whose Ghidra "&_pdata_5_iggy_init_textfield + param_1" base is an
|
||||
ambiguous global-index expression left for the implementer). The 32-bit ps3 / vita
|
||||
layout (owned global still 4 bytes; struct offsets differ) is noted for the
|
||||
implementer but NOT exercised by the durango-only runtime test.
|
||||
|
||||
Full-suite runs use python3.12 (the machine python3 is 3.14, which SEGFAULTs at
|
||||
teardown on the full suite via an unrelated CPython ctypes-GC bug -- exit 139 AFTER
|
||||
the last "ok" with 0 fail/err is a teardown artifact, not a failure).
|
||||
"""
|
||||
|
||||
import ctypes
|
||||
import shutil
|
||||
import struct
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
RECONSTRUCTED = ROOT / "iggy-decompiled/src/reconstructed"
|
||||
SOURCE = RECONSTRUCTED / "swf_play.c"
|
||||
HEADER = RECONSTRUCTED / "swf_play.h"
|
||||
SUPPORT = ROOT / "tests/support/swf_play_test_support.c"
|
||||
|
||||
MASK64 = (1 << 64) - 1
|
||||
|
||||
# 64-bit DURANGO Iggy player struct offsets (disasm of swf_play.obj).
|
||||
PLAYER_INITIALIZED = 0x1F38 # int: nonzero gate (raw:299/343/377; disasm cmpl 0x1f38).
|
||||
PLAYER_PAUSE_FLAG = 0x2880 # byte: unknown_2870[0x10] pause flag (disasm movb 0x2880).
|
||||
|
||||
# IggyAudioPauseMode enum values (disasm: decl edx == 1 -> pause_audio; == 2 ->
|
||||
# stop_audio; anything else skips the voice loop) (raw:301/312).
|
||||
IGGY_PAUSE_NONE = 0
|
||||
IGGY_PAUSE_PAUSE_AUDIO = 1
|
||||
IGGY_PAUSE_STOP_AUDIO = 2
|
||||
|
||||
# 64-bit DURANGO library export-table offsets used by iggy_get_symbol
|
||||
# (raw:3228-3260; disasm 0x264 / 0x230 / 0x228).
|
||||
MOVIE_LIB_MASK = 0x264 # uint: 0x20-bit set of live library ids (disasm 0x264(r13)).
|
||||
LIB_EXPORT_COUNT = 0x230 # int: export entry count (disasm cmpl 0x230(rsi)).
|
||||
LIB_EXPORT_TABLE = 0x228 # ptr: export table base (disasm movq 0x228(rsi)).
|
||||
EXPORT_STRIDE = 0x18 # per-entry bytes: [+0]=value, [+8]=name ptr (raw:3245/3249).
|
||||
EXPORT_VALUE = 0x00
|
||||
EXPORT_NAME = 0x08
|
||||
LIBRARY_SLOTS = 0x20 # mask width / iggy_libraries slot count (raw:3263).
|
||||
|
||||
|
||||
class ReconstructedSwfPlayTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
missing = [str(path) for path in (SOURCE, HEADER, SUPPORT)
|
||||
if not path.exists()]
|
||||
if missing:
|
||||
raise AssertionError(
|
||||
"missing swf_play runtime inputs: " + ", ".join(missing))
|
||||
cls.temp = tempfile.TemporaryDirectory()
|
||||
cls.base = Path(cls.temp.name) / "swf_play.dylib"
|
||||
build = subprocess.run([
|
||||
"clang", "-dynamiclib", "-std=c11", "-O2", "-Wall", "-Wextra",
|
||||
"-Werror", "-Wl,-undefined,dynamic_lookup",
|
||||
"-DIGGY_RECONSTRUCT_SWF_PLAY_DURANGO=1",
|
||||
"-I", str(RECONSTRUCTED),
|
||||
str(SOURCE), str(SUPPORT), "-o", str(cls.base),
|
||||
], capture_output=True, text=True)
|
||||
if build.returncode:
|
||||
raise AssertionError(build.stdout + build.stderr)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.temp.cleanup()
|
||||
|
||||
def setUp(self):
|
||||
unique = (Path(self.temp.name) /
|
||||
f"swf_play_{self._testMethodName}.dylib")
|
||||
shutil.copyfile(self.base, unique)
|
||||
self.lib = ctypes.CDLL(str(unique))
|
||||
self.lib.swf_play_test_reset()
|
||||
self._keep = []
|
||||
|
||||
# --- harness accessors -------------------------------------------- #
|
||||
|
||||
def _count(self, name):
|
||||
fn = getattr(self.lib, f"swf_play_test_{name}_count")
|
||||
fn.restype = ctypes.c_size_t
|
||||
fn.argtypes = []
|
||||
return fn()
|
||||
|
||||
def _double_click_time(self):
|
||||
return ctypes.c_float.in_dll(self.lib, "iggy_double_click_time").value
|
||||
|
||||
def _set_malloc_result(self, addr):
|
||||
fn = self.lib.swf_play_test_set_malloc_result
|
||||
fn.restype = None
|
||||
fn.argtypes = [ctypes.c_void_p]
|
||||
fn(ctypes.c_void_p(addr))
|
||||
|
||||
def _set_create_result(self, addr):
|
||||
fn = self.lib.swf_play_test_set_create_result
|
||||
fn.restype = None
|
||||
fn.argtypes = [ctypes.c_void_p]
|
||||
fn(ctypes.c_void_p(addr))
|
||||
|
||||
def _set_library(self, index, addr):
|
||||
fn = self.lib.swf_play_test_set_library
|
||||
fn.restype = None
|
||||
fn.argtypes = [ctypes.c_int, ctypes.c_void_p]
|
||||
fn(index, ctypes.c_void_p(addr))
|
||||
|
||||
# --- buffer helpers ----------------------------------------------- #
|
||||
|
||||
def _buf(self, size):
|
||||
buf = (ctypes.c_uint64 * max((size + 7) // 8, 1))()
|
||||
self._keep.append(buf)
|
||||
return buf
|
||||
|
||||
def _addr(self, buf):
|
||||
return ctypes.addressof(buf)
|
||||
|
||||
def _poke_u64(self, buf, offset, value):
|
||||
ctypes.c_uint64.from_buffer(buf, offset).value = value & MASK64
|
||||
|
||||
def _poke_u32(self, buf, offset, value):
|
||||
ctypes.c_uint32.from_buffer(buf, offset).value = value & 0xFFFFFFFF
|
||||
|
||||
def _poke_u16(self, buf, offset, value):
|
||||
ctypes.c_uint16.from_buffer(buf, offset).value = value & 0xFFFF
|
||||
|
||||
def _poke_u8(self, buf, offset, value):
|
||||
ctypes.c_uint8.from_buffer(buf, offset).value = value & 0xFF
|
||||
|
||||
def _peek_u8(self, buf, offset):
|
||||
return ctypes.c_uint8.from_buffer(buf, offset).value
|
||||
|
||||
def _peek_u16(self, buf, offset):
|
||||
return ctypes.c_uint16.from_buffer(buf, offset).value
|
||||
|
||||
def _peek_u32(self, buf, offset):
|
||||
return ctypes.c_uint32.from_buffer(buf, offset).value
|
||||
|
||||
def _peek_u64(self, buf, offset):
|
||||
return ctypes.c_uint64.from_buffer(buf, offset).value
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# IggySetDoubleClickTime -- writes the module-owned float global.
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def _set_double_click_time(self, ms):
|
||||
fn = self.lib.IggySetDoubleClickTime
|
||||
fn.restype = None
|
||||
fn.argtypes = [ctypes.c_int32]
|
||||
fn(ms)
|
||||
|
||||
def test_double_click_time_defaults_to_half(self):
|
||||
# raw:.data owns iggy_double_click_time = 0.5f (retail bytes 0x3f000000).
|
||||
self.assertAlmostEqual(self._double_click_time(), 0.5, places=6)
|
||||
|
||||
def test_set_double_click_time_divides_ms_by_1000(self):
|
||||
# raw:526-532 iggy_double_click_time = (float)time_in_ms / 1000.0.
|
||||
self._set_double_click_time(1000)
|
||||
self.assertAlmostEqual(self._double_click_time(), 1.0, places=6)
|
||||
self._set_double_click_time(500)
|
||||
self.assertAlmostEqual(self._double_click_time(), 0.5, places=6)
|
||||
self._set_double_click_time(2500)
|
||||
self.assertAlmostEqual(self._double_click_time(), 2.5, places=6)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# IggyPlayerReadyToTick -- NULL / uninitialized predicate (pure reject).
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def _ready_to_tick(self, player_addr):
|
||||
fn = self.lib.IggyPlayerReadyToTick
|
||||
fn.restype = ctypes.c_int32
|
||||
fn.argtypes = [ctypes.c_void_p]
|
||||
return fn(ctypes.c_void_p(player_addr))
|
||||
|
||||
def test_ready_to_tick_null_is_zero(self):
|
||||
# raw:379 player == NULL -> return 0 without touching any import.
|
||||
self.assertEqual(self._ready_to_tick(0), 0)
|
||||
|
||||
def test_ready_to_tick_uninitialized_is_zero(self):
|
||||
# raw:379 player->initialized == 0 -> return 0 (disasm cmpl $0,0x1f38).
|
||||
player = self._buf(0x2900) # initialized left 0 -> reject before poll.
|
||||
self.assertEqual(self._ready_to_tick(self._addr(player)), 0)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# IggyPlayerPause -- initialized gate + pause flag (pure, mode NONE).
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def _pause(self, player_addr, mode):
|
||||
fn = self.lib.IggyPlayerPause
|
||||
fn.restype = None
|
||||
fn.argtypes = [ctypes.c_void_p, ctypes.c_int32]
|
||||
fn(ctypes.c_void_p(player_addr), mode)
|
||||
|
||||
def test_pause_uninitialized_is_noop(self):
|
||||
# raw:299 initialized == 0 -> no flag write, no voice loop.
|
||||
player = self._buf(0x2900)
|
||||
self._pause(self._addr(player), IGGY_PAUSE_NONE)
|
||||
self.assertEqual(self._peek_u8(player, PLAYER_PAUSE_FLAG), 0)
|
||||
|
||||
def test_pause_initialized_none_mode_sets_flag_only(self):
|
||||
# raw:300-334 initialized != 0 -> pause flag := 1; mode NONE skips the
|
||||
# voice loop, so no import is reached (disasm decl edx twice -> jne skip).
|
||||
player = self._buf(0x2900)
|
||||
self._poke_u32(player, PLAYER_INITIALIZED, 1)
|
||||
self._pause(self._addr(player), IGGY_PAUSE_NONE)
|
||||
self.assertEqual(self._peek_u8(player, PLAYER_PAUSE_FLAG), 1)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# IggyPlayerPlay -- initialized gate (uninitialized no-op).
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def test_play_uninitialized_is_noop(self):
|
||||
# raw:343-350 initialized == 0 -> immediate return; pause flag untouched.
|
||||
player = self._buf(0x2900)
|
||||
self._poke_u8(player, PLAYER_PAUSE_FLAG, 1) # sentinel; must survive.
|
||||
fn = self.lib.IggyPlayerPlay
|
||||
fn.restype = None
|
||||
fn.argtypes = [ctypes.c_void_p]
|
||||
fn(ctypes.c_void_p(self._addr(player)))
|
||||
self.assertEqual(self._peek_u8(player, PLAYER_PAUSE_FLAG), 1)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# iggy_set_movie_defaults -- OR/mask field writes (skip-dispatch path).
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def test_set_movie_defaults_writes_default_fields(self):
|
||||
# raw:4343-4364 m[3]==0 -> (m[3]-1) as unsigned is >= 7, so the trailing
|
||||
# type-switch dispatch is skipped and only the field writes run.
|
||||
movie = self._buf(0x200)
|
||||
self._poke_u8(movie, 0xB9, 0x00)
|
||||
self._poke_u8(movie, 0x01, 0x00)
|
||||
self._poke_u8(movie, 0xBA, 0x0F) # low nibble preserved, high set to 0x7.
|
||||
self._poke_u8(movie, 0x03, 0x00) # -> skip dispatch.
|
||||
fn = self.lib.iggy_set_movie_defaults
|
||||
fn.restype = None
|
||||
fn.argtypes = [ctypes.c_void_p]
|
||||
fn(ctypes.c_void_p(self._addr(movie)))
|
||||
self.assertEqual(self._peek_u8(movie, 0xB9) & 0x40, 0x40)
|
||||
self.assertEqual(self._peek_u8(movie, 0x01) & 0x02, 0x02)
|
||||
self.assertEqual(self._peek_u8(movie, 0xBA), 0x7F) # (0x0f & 0xf) | 0x70.
|
||||
self.assertEqual(self._peek_u32(movie, 0x114), 0xFFFFFFFF)
|
||||
self.assertEqual(self._peek_u32(movie, 0x178), 1)
|
||||
self.assertEqual(self._peek_u32(movie, 0x17C), 1)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# iggy_zero_movie_state -- memset then a fixed byte pattern.
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def test_zero_movie_state_clears_then_stamps_pattern(self):
|
||||
# raw:4523 memset(m,0,0x1a0) then the documented bit/byte pattern. Seed
|
||||
# the region with 0xff so the memset (and the &0xfe / &0xf masks) are
|
||||
# observable rather than trivially satisfied by fresh BSS.
|
||||
movie = self._buf(0x200)
|
||||
for offset in range(0x1A0):
|
||||
self._poke_u8(movie, offset, 0xFF)
|
||||
fn = self.lib.iggy_zero_movie_state
|
||||
fn.restype = None
|
||||
fn.argtypes = [ctypes.c_void_p]
|
||||
fn(ctypes.c_void_p(self._addr(movie)))
|
||||
# memset cleared the region, then the OR/AND stamps landed.
|
||||
self.assertEqual(self._peek_u8(movie, 0x00) & 0x01, 0x00) # &= 0xfe.
|
||||
self.assertEqual(self._peek_u8(movie, 0xB9), 0x41) # |= 0x41.
|
||||
self.assertEqual(self._peek_u8(movie, 0xBA), 0x70) # |= 0x70.
|
||||
# float 1.0 (0x3f800000) at m+0xd8 and m+0xe4.
|
||||
self.assertEqual(self._peek_u32(movie, 0xD8), 0x3F800000)
|
||||
self.assertEqual(self._peek_u32(movie, 0xE4), 0x3F800000)
|
||||
# 0xff run-fills.
|
||||
self.assertEqual(self._peek_u32(movie, 0xC4), 0xFFFFFFFF)
|
||||
self.assertEqual(self._peek_u32(movie, 0x170), 0xFFFFFFFF)
|
||||
self.assertEqual(self._peek_u32(movie, 0x114), 0xFFFFFFFF)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# iggy_get_symbol -- library-mask scan + export-table walk.
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def _get_symbol(self, movie_addr, name_addr):
|
||||
fn = self.lib.iggy_get_symbol
|
||||
fn.restype = ctypes.c_uint64
|
||||
fn.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
|
||||
return fn(ctypes.c_void_p(movie_addr), ctypes.c_void_p(name_addr))
|
||||
|
||||
def _lib_with_exports(self, entries):
|
||||
# entries: list of (value, name_buf). Builds the lib+0x228 export table.
|
||||
lib = self._buf(0x240)
|
||||
table = self._buf(len(entries) * EXPORT_STRIDE)
|
||||
self._poke_u32(lib, LIB_EXPORT_COUNT, len(entries))
|
||||
self._poke_u64(lib, LIB_EXPORT_TABLE, self._addr(table))
|
||||
for i, (value, name_buf) in enumerate(entries):
|
||||
base = i * EXPORT_STRIDE
|
||||
self._poke_u64(table, base + EXPORT_VALUE, value)
|
||||
self._poke_u64(table, base + EXPORT_NAME, self._addr(name_buf))
|
||||
return lib
|
||||
|
||||
def test_get_symbol_empty_mask_returns_zero(self):
|
||||
# raw:3238 a zero library mask never enters a library -> 0, no rrwcscmp.
|
||||
movie = self._buf(0x280)
|
||||
self._poke_u32(movie, MOVIE_LIB_MASK, 0)
|
||||
name = self._buf(0x10)
|
||||
self.assertEqual(self._get_symbol(self._addr(movie), self._addr(name)), 0)
|
||||
self.assertEqual(self._count("wcscmp"), 0)
|
||||
|
||||
def test_get_symbol_matches_export_by_name(self):
|
||||
# raw:3240-3252 mask bit 0 set -> iggy_libraries[0]; the export whose name
|
||||
# (table+i*0x18+8) rrwcscmp-matches returns its value (table+i*0x18+0).
|
||||
name0 = self._buf(0x10)
|
||||
name1 = self._buf(0x10)
|
||||
lib = self._lib_with_exports([(0xA11CE, name0), (0xB0B, name1)])
|
||||
movie = self._buf(0x280)
|
||||
self._poke_u32(movie, MOVIE_LIB_MASK, 1 << 0)
|
||||
self._set_library(0, self._addr(lib))
|
||||
self.assertEqual(
|
||||
self._get_symbol(self._addr(movie), self._addr(name1)), 0xB0B)
|
||||
self.assertEqual(
|
||||
self._get_symbol(self._addr(movie), self._addr(name0)), 0xA11CE)
|
||||
self.assertGreater(self._count("wcscmp"), 0)
|
||||
|
||||
def test_get_symbol_miss_returns_zero(self):
|
||||
# raw:3260 an exhausted scan across the live library returns 0.
|
||||
name0 = self._buf(0x10)
|
||||
lib = self._lib_with_exports([(0xA11CE, name0)])
|
||||
movie = self._buf(0x280)
|
||||
self._poke_u32(movie, MOVIE_LIB_MASK, 1 << 0)
|
||||
self._set_library(0, self._addr(lib))
|
||||
other = self._buf(0x10) # distinct pointer -> no rrwcscmp hit.
|
||||
self.assertEqual(self._get_symbol(self._addr(movie), self._addr(other)), 0)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# iggy_make_empty_sprite / iggy_make_empty_shape -- constructor field init.
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def test_make_empty_sprite_stamps_type_tag_and_clears_wrapper(self):
|
||||
# raw:3737-3758 malloc the 0x48 object, zero it, tag word := 0xff03,
|
||||
# u16 @ +0x28 := 1, then create the wrapper and clear wrapper+0x178.
|
||||
obj = self._buf(0x48)
|
||||
wrapper = self._buf(0x180)
|
||||
self._poke_u32(wrapper, 0x178, 0xDEADBEEF) # sentinel -> must be cleared.
|
||||
self._set_malloc_result(self._addr(obj))
|
||||
self._set_create_result(self._addr(wrapper))
|
||||
ctx = self._buf(0x10)
|
||||
fn = self.lib.iggy_make_empty_sprite
|
||||
fn.restype = None
|
||||
fn.argtypes = [ctypes.c_void_p]
|
||||
fn(ctypes.c_void_p(self._addr(ctx)))
|
||||
self.assertEqual(self._count("malloc_fileline"), 1)
|
||||
self.assertEqual(self._count("create_movie"), 1)
|
||||
self.assertEqual(self._peek_u16(obj, 0x00), 0xFF03)
|
||||
self.assertEqual(self._peek_u16(obj, 0x28), 1)
|
||||
self.assertEqual(self._peek_u32(wrapper, 0x178), 0)
|
||||
|
||||
def test_make_empty_shape_stamps_type_tag_and_stores_ctx(self):
|
||||
# raw:3717-3730 malloc the 0x80 object, memset it, tag word := 0xff01,
|
||||
# u64 @ +0x40 := ctx, then create the wrapper and clear wrapper+0x178.
|
||||
obj = self._buf(0x80)
|
||||
wrapper = self._buf(0x180)
|
||||
self._poke_u32(wrapper, 0x178, 0xDEADBEEF)
|
||||
self._set_malloc_result(self._addr(obj))
|
||||
self._set_create_result(self._addr(wrapper))
|
||||
ctx = self._buf(0x10)
|
||||
fn = self.lib.iggy_make_empty_shape
|
||||
fn.restype = None
|
||||
fn.argtypes = [ctypes.c_void_p]
|
||||
fn(ctypes.c_void_p(self._addr(ctx)))
|
||||
self.assertEqual(self._count("malloc_fileline"), 1)
|
||||
self.assertEqual(self._count("create_movie"), 1)
|
||||
self.assertEqual(self._peek_u16(obj, 0x00), 0xFF01)
|
||||
self.assertEqual(self._peek_u64(obj, 0x40), self._addr(ctx) & MASK64)
|
||||
self.assertEqual(self._peek_u32(wrapper, 0x178), 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
498
tests/test_reconstructed_swf_play_cross.py
Normal file
498
tests/test_reconstructed_swf_play_cross.py
Normal file
@@ -0,0 +1,498 @@
|
||||
"""Cross-platform contract tests for the reconstructed swf_play module.
|
||||
|
||||
Mirrors tests/test_reconstructed_swf_decode_cross.py (the sibling in the same
|
||||
swf-runtime cluster whose owned-data / .opd / provenance triage this reuses) and
|
||||
tests/test_reconstructed_swf_as3vm_cross.py (the sibling whose large invariant
|
||||
import surface is frozen to a data file). RED until swf_play.c / swf_play.h (and
|
||||
their CMake / modules.tsv rows) exist; the retail-evidence assertions (the 68
|
||||
exports, the single owned data global + its bytes/size, the 72-symbol invariant
|
||||
import contract, provenance and the inventory) run NOW against the four .obj and
|
||||
prove the nm / objdump / strings parsing.
|
||||
|
||||
swf_play is Iggy's movie playback + display-list execution runtime -- the
|
||||
IggyPlayer tick / play / pause loop, the movie advance / PlaceObject / framescript
|
||||
engine, the sprite / textfield / button / shape lifecycle, hit-testing, focus and
|
||||
clipboard. It exports a fixed 68 entry points on every platform and OWNS a single
|
||||
externally named data global.
|
||||
|
||||
How EXPECTED_* were derived (all four .obj under
|
||||
work/iggy-native-decomp/<platform>-objects/swf_play.obj, verified with
|
||||
/opt/homebrew/opt/llvm/bin/llvm-nm and llvm-objdump):
|
||||
|
||||
EXPECTED_FUNCTIONS = `llvm-nm --extern-only --defined-only <obj>` T-tagged
|
||||
names, leading '.' stripped on ps3. IDENTICAL 68-name set
|
||||
on durango / orbis / ps3 / vita. The ps3 .opd descriptors
|
||||
surface each export a second time as 'D'; those normalize
|
||||
to the exported names and are NOT globals.
|
||||
|
||||
EXPECTED_GLOBALS = ONE genuine module-owned data global on ALL FOUR platforms:
|
||||
iggy_double_click_time -- a 4-byte float that
|
||||
IggySetDoubleClickTime writes (milliseconds / 1000.0),
|
||||
defaulting to 0.5 (0x3f000000).
|
||||
It is externally named initialised data ('D') on every
|
||||
platform (its own .data.iggy_double_click_time COMDAT on
|
||||
orbis; the shared .data section on durango / ps3 / vita).
|
||||
The ps3 object also carries 68 'D' .opd descriptors -- one
|
||||
per exported function -- which normalize onto the export
|
||||
names and are NOT owned globals. The durango object carries
|
||||
25 read-only MSVC ARTIFACTS ('R'): 15 ??_C@ SWF-error /
|
||||
__FILE__ string literals, 8 __real@ float constants and 2
|
||||
__xmm@ vectors -- local on the other three platforms, NOT
|
||||
owned exported data.
|
||||
|
||||
OWNED_GLOBAL_* = the byte-level retail evidence for iggy_double_click_time:
|
||||
4 bytes decoding to the float 0.5 on every platform
|
||||
(little-endian 00 00 00 3f on durango / orbis / vita;
|
||||
big-endian 3f 00 00 00 on ps3), read via llvm-objdump -s at
|
||||
the pinned (section, offset).
|
||||
|
||||
EXPECTED_IMPORTS = the 72 genuine cross-module references present on ALL FOUR
|
||||
retail objects (INVARIANT), frozen to
|
||||
tests/data/swf_play_expected_imports.txt: the as3vm_* event
|
||||
/ GC / construct surface, the iggy_* movie / audio / seek /
|
||||
textfield / render surface, the swf_decode-owned
|
||||
iggy_libraries array, the public-API IggyPlayerPasteUTF16
|
||||
wrapper, and the four RAD rr* helpers (rrGetTicks,
|
||||
rrUTF8toUTF16, rrwcscmp, rrwcslen).
|
||||
|
||||
PLATFORM_IMPORTS = the libc the retail optimizer emitted on every platform:
|
||||
{memset, setjmp} (durango carries setjmp as `_setjmp`, which
|
||||
normalizes to `setjmp`).
|
||||
|
||||
RUNTIME_ALLOWLISTS = pure toolchain scaffolding, verified against retail
|
||||
`llvm-nm --undefined-only`:
|
||||
durango {_fltused, __GSHandlerCheck, __ImageBase, __chkstk,
|
||||
__security_check_cookie, __security_cookie}
|
||||
orbis {_GLOBAL_OFFSET_TABLE_}
|
||||
ps3 {}
|
||||
vita {__aeabi_unwind_cpp_pr0/_pr1, __stack_chk_fail,
|
||||
__stack_chk_guard}
|
||||
|
||||
PROVENANCE = the canonical c:\\projects\\g\\src\\flash\\swf_play.c is
|
||||
embedded on ALL FOUR retail objects; durango ALSO carries
|
||||
its build .obj path.
|
||||
|
||||
Run the full suite with python3.12 (`python3.12 -m unittest discover -s tests`):
|
||||
the machine python3 is 3.14, which SEGFAULTs at teardown on the full suite via an
|
||||
unrelated CPython ctypes-GC bug. This cross test's cross-compile / nm logic is
|
||||
python-version-independent.
|
||||
"""
|
||||
|
||||
import re
|
||||
import struct
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
RECONSTRUCTED = ROOT / "iggy-decompiled/src/reconstructed"
|
||||
SOURCE = RECONSTRUCTED / "swf_play.c"
|
||||
HEADER = RECONSTRUCTED / "swf_play.h"
|
||||
DATA = ROOT / "tests/data/swf_play_expected_imports.txt"
|
||||
LLVM_NM = Path("/opt/homebrew/opt/llvm/bin/llvm-nm")
|
||||
LLVM_OBJDUMP = Path("/opt/homebrew/opt/llvm/bin/llvm-objdump")
|
||||
VARIANTS = {
|
||||
"durango": ("clang", "x86_64-pc-windows-msvc"),
|
||||
"orbis": ("clang", "x86_64-unknown-freebsd"),
|
||||
"vita": ("clang", "armv7a-unknown-linux-gnueabihf"),
|
||||
}
|
||||
PS3_CLANG = Path("/opt/homebrew/opt/llvm/bin/clang")
|
||||
if PS3_CLANG.exists():
|
||||
VARIANTS["ps3"] = (str(PS3_CLANG), "powerpc-unknown-linux-gnu")
|
||||
|
||||
# The invariant 68-name exported ABI (leading '.' stripped on ps3).
|
||||
EXPECTED_FUNCTIONS = {
|
||||
"IggyPlayerCopyUTF16",
|
||||
"IggyPlayerCopyUTF8",
|
||||
"IggyPlayerCut_core",
|
||||
"IggyPlayerDispatchEventRS_core",
|
||||
"IggyPlayerGetFocusableObjects",
|
||||
"IggyPlayerHasFocusedEditableTextfield",
|
||||
"IggyPlayerPasteUTF16_core",
|
||||
"IggyPlayerPasteUTF8_core",
|
||||
"IggyPlayerPause",
|
||||
"IggyPlayerPlay",
|
||||
"IggyPlayerReadyToTick",
|
||||
"IggyPlayerSendFrameToExplorer",
|
||||
"IggyPlayerSetFocus_core",
|
||||
"IggyPlayerTickRS_core",
|
||||
"IggySetDoubleClickTime",
|
||||
"as3vm_get_movie_as3value_GC",
|
||||
"iggy_add_movie_framescript",
|
||||
"iggy_add_to_unparented",
|
||||
"iggy_advance_movie_GC",
|
||||
"iggy_advance_movie_raw_GC",
|
||||
"iggy_audio_update",
|
||||
"iggy_check_display_trees",
|
||||
"iggy_create_empty_bitmap",
|
||||
"iggy_create_movie_complete_GC",
|
||||
"iggy_create_movie_for_actionscript_object",
|
||||
"iggy_create_textfield",
|
||||
"iggy_destroy_sprite",
|
||||
"iggy_destroy_sprite_attachments",
|
||||
"iggy_destroy_sprite_during_shutdown",
|
||||
"iggy_discard_seek_queue",
|
||||
"iggy_do_placement",
|
||||
"iggy_do_placeobject_GC",
|
||||
"iggy_do_playsound",
|
||||
"iggy_dynamic_graphics_clear_cache",
|
||||
"iggy_finish_creating_movie_GC",
|
||||
"iggy_flush_seek_queue_GC",
|
||||
"iggy_free_as3_filters",
|
||||
"iggy_free_graphics",
|
||||
"iggy_free_textfield",
|
||||
"iggy_get_symbol",
|
||||
"iggy_hit_test_point",
|
||||
"iggy_init_textfield",
|
||||
"iggy_initialized_main_movie_GC",
|
||||
"iggy_insert_movie_at_GC",
|
||||
"iggy_insert_movie_messages_GC",
|
||||
"iggy_is_weak_ptr",
|
||||
"iggy_make_empty_button",
|
||||
"iggy_make_empty_shape",
|
||||
"iggy_make_empty_sprite",
|
||||
"iggy_make_empty_textfield",
|
||||
"iggy_play_framescript",
|
||||
"iggy_play_framescripts",
|
||||
"iggy_play_framescripts_complete",
|
||||
"iggy_play_sound",
|
||||
"iggy_poll_iggyexp",
|
||||
"iggy_remove_from_unparented",
|
||||
"iggy_remove_sprite",
|
||||
"iggy_set_button_state",
|
||||
"iggy_set_focus_typed",
|
||||
"iggy_set_mouseover_list",
|
||||
"iggy_set_movie_defaults",
|
||||
"iggy_set_movie_parent",
|
||||
"iggy_shape_has_class",
|
||||
"iggy_shape_hit_test",
|
||||
"iggy_update_button",
|
||||
"iggy_update_voice",
|
||||
"iggy_verify_container",
|
||||
"iggy_zero_movie_state",
|
||||
}
|
||||
# swf_play OWNS a single externally named data global on every platform.
|
||||
EXPECTED_GLOBALS = {"iggy_double_click_time"}
|
||||
|
||||
# Byte-level retail evidence for iggy_double_click_time: a 4-byte float == 0.5.
|
||||
OWNED_GLOBAL_NAME = "iggy_double_click_time"
|
||||
OWNED_GLOBAL_SIZE = 4
|
||||
OWNED_GLOBAL_VALUE = 0.5
|
||||
# (section, offset, endianness) pinned per platform (llvm-objdump -s / --syms).
|
||||
OWNED_GLOBAL_LAYOUT = {
|
||||
"durango": (".data", 0x58, "<"),
|
||||
"orbis": (".data.iggy_double_click_time", 0x00, "<"),
|
||||
"ps3": (".data", 0x00, ">"),
|
||||
"vita": (".data", 0x80, "<"),
|
||||
}
|
||||
|
||||
# The 72 genuine cross-module imports present on all four retail objects
|
||||
# (invariant), frozen alongside this test.
|
||||
EXPECTED_IMPORTS = frozenset(
|
||||
line.strip() for line in DATA.read_text(encoding="utf-8").splitlines()
|
||||
if line.strip())
|
||||
# The libc the retail optimizer emitted on every platform. durango lowers setjmp
|
||||
# as `_setjmp`; both normalize to `setjmp`.
|
||||
PLATFORM_IMPORTS = {
|
||||
"durango": {"memset", "setjmp"},
|
||||
"orbis": {"memset", "setjmp"},
|
||||
"ps3": {"memset", "setjmp"},
|
||||
"vita": {"memset", "setjmp"},
|
||||
}
|
||||
RUNTIME_ALLOWLISTS = {
|
||||
"durango": {"_fltused", "__GSHandlerCheck", "__ImageBase", "__chkstk",
|
||||
"__security_check_cookie", "__security_cookie",
|
||||
# a fresh MSVC compile may additionally emit these.
|
||||
"__report_rangecheckfailure"},
|
||||
"orbis": {"_GLOBAL_OFFSET_TABLE_"},
|
||||
"ps3": set(),
|
||||
"vita": {"__aeabi_unwind_cpp_pr0", "__aeabi_unwind_cpp_pr1",
|
||||
"__stack_chk_fail", "__stack_chk_guard"},
|
||||
}
|
||||
# libc/libm a fresh cross-compile may emit or inline differently than retail; not
|
||||
# part of the cross-module ABI contract, so tolerated in the reconstruction import
|
||||
# check (the retail check pins the exact per-platform set instead).
|
||||
LIBM_LIBC = {"memcpy", "memset", "memmove", "memcmp", "strcmp", "strncmp",
|
||||
"qsort", "abs", "ceil", "ceilf", "sqrt", "sqrtf", "floor", "floorf",
|
||||
"setjmp", "longjmp"}
|
||||
|
||||
# The canonical Windows source path, embedded on all four retail objects.
|
||||
CANONICAL_PROVENANCE = r"c:\projects\g\src\flash\swf_play.c"
|
||||
DURANGO_OBJ_PROVENANCE = (
|
||||
r"c:\projects\g\build\release\temps\libdu\iggy_durango\swf_play.obj")
|
||||
# (source_functions, raw line count) per platform. Exports (68) are invariant;
|
||||
# source_functions differs (recovered file-static helpers -- the display-list
|
||||
# recursion, mouse-over walk, timer + button helpers). From
|
||||
# iggy_<platform>.modules.tsv column 3 and `wc -l` on raw.
|
||||
RETAIL_INVENTORY = {
|
||||
"durango": (112, 6323),
|
||||
"orbis": (90, 5921),
|
||||
"ps3": (90, 8368),
|
||||
"vita": (93, 7114),
|
||||
}
|
||||
|
||||
|
||||
def normalized_symbol(name):
|
||||
name = name.removeprefix(".")
|
||||
name = name.removeprefix("__imp_")
|
||||
if name == "_setjmp":
|
||||
return "setjmp"
|
||||
return name
|
||||
|
||||
|
||||
def _section_bytes(obj, section):
|
||||
"""Flatten `llvm-objdump -s -j <section>` into an address->byte map."""
|
||||
dump = subprocess.run(
|
||||
[str(LLVM_OBJDUMP), "-s", "-j", section, str(obj)],
|
||||
capture_output=True, text=True)
|
||||
if dump.returncode != 0:
|
||||
return {}
|
||||
row = re.compile(r"^\s*([0-9a-fA-F]+)\s+((?:[0-9a-fA-F]{2,8}\s+)+)")
|
||||
out = {}
|
||||
for line in dump.stdout.splitlines():
|
||||
match = row.match(line)
|
||||
if not match:
|
||||
continue
|
||||
base = int(match.group(1), 16)
|
||||
blob = "".join(match.group(2).split())
|
||||
for i in range(0, len(blob), 2):
|
||||
out[base + i // 2] = int(blob[i:i + 2], 16)
|
||||
return out
|
||||
|
||||
|
||||
class ReconstructedSwfPlayCrossTests(unittest.TestCase):
|
||||
def _obj(self, platform):
|
||||
return ROOT / (
|
||||
f"work/iggy-native-decomp/{platform}-objects/swf_play.obj")
|
||||
|
||||
def test_ability_inventory_is_68_exports_and_one_global(self):
|
||||
# Documentary: 68 exports, 1 owned global, 72 invariant imports.
|
||||
self.assertEqual(len(EXPECTED_FUNCTIONS), 68)
|
||||
self.assertEqual(len(EXPECTED_GLOBALS), 1)
|
||||
self.assertEqual(len(EXPECTED_IMPORTS), 72)
|
||||
for name in ("IggyPlayerTickRS_core", "IggyPlayerPlay",
|
||||
"IggyPlayerPause", "iggy_advance_movie_GC",
|
||||
"iggy_do_placeobject_GC", "iggy_play_framescripts",
|
||||
"iggy_get_symbol", "IggySetDoubleClickTime"):
|
||||
self.assertIn(name, EXPECTED_FUNCTIONS)
|
||||
self.assertIn("iggy_double_click_time", EXPECTED_GLOBALS)
|
||||
# The owned iggy_libraries import anchor + AS3 event dispatch + RAD helpers.
|
||||
self.assertIn("iggy_libraries", EXPECTED_IMPORTS)
|
||||
self.assertIn("as3vm_do_mouse_event_GC", EXPECTED_IMPORTS)
|
||||
self.assertIn("rrwcscmp", EXPECTED_IMPORTS)
|
||||
self.assertNotIn("memset", EXPECTED_IMPORTS) # libc, not cross-module.
|
||||
self.assertNotIn("setjmp", EXPECTED_IMPORTS)
|
||||
|
||||
def test_native_provenance_counts_source_path_and_inventory(self):
|
||||
# Retail evidence -- runs NOW. Exports + owned global present in nm,
|
||||
# source_functions / line counts in the symbols inventory, provenance
|
||||
# embedded.
|
||||
for platform, (functions, lines) in RETAIL_INVENTORY.items():
|
||||
modules = ROOT / (
|
||||
f"iggy-decompiled/symbols/iggy_{platform}.modules.tsv")
|
||||
row = next(
|
||||
line for line in modules.read_text(encoding="utf-8").splitlines()
|
||||
if line.startswith("swf_play\t"))
|
||||
self.assertEqual(int(row.split("\t")[2]), functions, platform)
|
||||
raw = ROOT / f"iggy-decompiled/raw/{platform}/swf_play.c"
|
||||
self.assertEqual(
|
||||
len(raw.read_text(encoding="utf-8").splitlines()),
|
||||
lines, platform)
|
||||
obj = self._obj(platform)
|
||||
symbols = subprocess.run(
|
||||
["nm", "-g", str(obj)], capture_output=True, text=True)
|
||||
self.assertEqual(symbols.returncode, 0, (platform, symbols.stderr))
|
||||
normalized = symbols.stdout.replace(" .", " ")
|
||||
for symbol in EXPECTED_FUNCTIONS | EXPECTED_GLOBALS:
|
||||
self.assertIn(symbol, normalized, (platform, symbol))
|
||||
strings = subprocess.run(
|
||||
["strings", str(obj)], capture_output=True, text=True)
|
||||
self.assertIn(CANONICAL_PROVENANCE, strings.stdout, platform)
|
||||
durango_strings = subprocess.run(
|
||||
["strings", str(self._obj("durango"))],
|
||||
capture_output=True, text=True)
|
||||
self.assertIn(DURANGO_OBJ_PROVENANCE, durango_strings.stdout)
|
||||
|
||||
if SOURCE.exists():
|
||||
cmake = (RECONSTRUCTED / "CMakeLists.txt").read_text(
|
||||
encoding="utf-8")
|
||||
self.assertIn(
|
||||
"iggy_reconstructed_swf_play_${platform}", cmake)
|
||||
self.assertIn(
|
||||
"add_library(${target} STATIC swf_play.c)", cmake)
|
||||
self.assertIn(
|
||||
"IGGY_RECONSTRUCT_SWF_PLAY_${platform_upper}", cmake)
|
||||
inventory = (RECONSTRUCTED / "modules.tsv").read_text(
|
||||
encoding="utf-8")
|
||||
# Exports (68) invariant; source_functions is per-platform.
|
||||
for platform, (functions, _lines) in RETAIL_INVENTORY.items():
|
||||
self.assertIn(
|
||||
f"swf_play\t{functions}\t68\t{platform}\tcomplete",
|
||||
inventory)
|
||||
|
||||
def test_retail_object_owns_one_data_global_and_classifies_artifacts(self):
|
||||
# Retail evidence -- runs NOW. Exactly one owned global surfaces as
|
||||
# externally named 'D' data that is not a ps3 .opd descriptor; the durango
|
||||
# ??_C@ / __real@ / __xmm@ symbols are 'R' rodata artifacts.
|
||||
if not LLVM_NM.exists():
|
||||
self.skipTest("llvm-nm unavailable")
|
||||
for platform in ("durango", "orbis", "ps3", "vita"):
|
||||
defined = subprocess.run(
|
||||
[str(LLVM_NM), "--print-size", "--extern-only",
|
||||
"--defined-only", str(self._obj(platform))],
|
||||
capture_output=True, text=True)
|
||||
self.assertEqual(defined.returncode, 0, platform)
|
||||
owned_data = set()
|
||||
for line in defined.stdout.splitlines():
|
||||
parts = line.split()
|
||||
if len(parts) < 2:
|
||||
continue
|
||||
tag = parts[-2].upper()
|
||||
name = normalized_symbol(parts[-1])
|
||||
# A genuinely owned data global is B/C/D and not just a ps3 .opd
|
||||
# descriptor of an exported function.
|
||||
if tag in {"B", "C", "D"} and name not in EXPECTED_FUNCTIONS:
|
||||
owned_data.add(name)
|
||||
# ??_C@ format literals must never surface as extern data.
|
||||
if name.startswith("??_C@"):
|
||||
self.assertEqual(tag, "R", (platform, name))
|
||||
# __real@ / __xmm@ float constants must never surface as extern.
|
||||
if name.startswith("__real@") or name.startswith("__xmm@"):
|
||||
self.assertEqual(tag, "R", (platform, name))
|
||||
# ps3 'D' entries other than the owned global are .opd descriptors
|
||||
# -- they normalize onto exported function names.
|
||||
if tag == "D" and name != OWNED_GLOBAL_NAME:
|
||||
self.assertIn(name, EXPECTED_FUNCTIONS, (platform, name))
|
||||
self.assertEqual(owned_data, EXPECTED_GLOBALS, platform)
|
||||
|
||||
def test_retail_owned_global_bytes_decode_to_half(self):
|
||||
# Retail evidence -- runs NOW. iggy_double_click_time is 4 bytes decoding
|
||||
# to the float 0.5 on every platform (little-endian on durango/orbis/vita,
|
||||
# big-endian on ps3), read via llvm-objdump -s at the pinned location.
|
||||
if not LLVM_OBJDUMP.exists():
|
||||
self.skipTest("llvm-objdump unavailable")
|
||||
for platform, (section, offset, endian) in OWNED_GLOBAL_LAYOUT.items():
|
||||
obj = self._obj(platform)
|
||||
byte_map = _section_bytes(obj, section)
|
||||
raw = bytes(byte_map.get(offset + i, None) for i in range(4)) \
|
||||
if all((offset + i) in byte_map for i in range(4)) else None
|
||||
self.assertIsNotNone(
|
||||
raw, (platform, section, hex(offset), "bytes not found"))
|
||||
value = struct.unpack(endian + "f", raw)[0]
|
||||
self.assertAlmostEqual(value, OWNED_GLOBAL_VALUE, places=6,
|
||||
msg=(platform, raw.hex()))
|
||||
# Size is 4 in the non-COFF symbol tables (durango COFF 'D' omits it).
|
||||
if platform != "durango":
|
||||
sized = subprocess.run(
|
||||
[str(LLVM_NM), "--print-size", "--defined-only", str(obj)],
|
||||
capture_output=True, text=True)
|
||||
for line in sized.stdout.splitlines():
|
||||
parts = line.split()
|
||||
if len(parts) >= 4 and parts[-1] == OWNED_GLOBAL_NAME:
|
||||
self.assertEqual(int(parts[1], 16), OWNED_GLOBAL_SIZE,
|
||||
platform)
|
||||
|
||||
def test_retail_object_import_contract(self):
|
||||
# Retail evidence -- runs NOW. The invariant 72-symbol import set is
|
||||
# present and, after subtracting the toolchain allowlist, only the
|
||||
# per-platform libc symbols remain.
|
||||
if not LLVM_NM.exists():
|
||||
self.skipTest("llvm-nm unavailable")
|
||||
for platform in ("durango", "orbis", "ps3", "vita"):
|
||||
undefined = subprocess.run(
|
||||
[str(LLVM_NM), "--undefined-only", str(self._obj(platform))],
|
||||
capture_output=True, text=True)
|
||||
self.assertEqual(undefined.returncode, 0, platform)
|
||||
imports = {normalized_symbol(line.split()[-1])
|
||||
for line in undefined.stdout.splitlines()
|
||||
if line.split()}
|
||||
self.assertTrue(
|
||||
EXPECTED_IMPORTS <= imports,
|
||||
(platform, sorted(EXPECTED_IMPORTS - imports)[:20]))
|
||||
self.assertEqual(
|
||||
imports - EXPECTED_IMPORTS - RUNTIME_ALLOWLISTS[platform],
|
||||
PLATFORM_IMPORTS[platform], (platform, sorted(imports)[:20]))
|
||||
|
||||
def test_exact_exports_globals_normalized_imports_and_c_cpp_abi(self):
|
||||
# RED until the reconstruction exists; then the fresh cross-compile must
|
||||
# reproduce the exact 68 exports + 1 owned global and the invariant
|
||||
# cross-module import set on all four targets.
|
||||
self.assertTrue(SOURCE.exists(), f"missing {SOURCE}")
|
||||
self.assertTrue(HEADER.exists(), f"missing {HEADER}")
|
||||
self.assertIn(r"c:\\projects\\g\\src\\flash\\swf_play.c",
|
||||
SOURCE.read_text(encoding="utf-8"))
|
||||
|
||||
function_pointers = "".join(
|
||||
f" (GenericFn)&{name},\n" for name in sorted(EXPECTED_FUNCTIONS))
|
||||
probe_text = (
|
||||
'#include <stdint.h>\n#include "swf_play.h"\n'
|
||||
'typedef void (*GenericFn)(void);\n'
|
||||
'static GenericFn swf_play_abis[] = {\n'
|
||||
+ function_pointers + '};\n'
|
||||
'int use_abis(void) {\n'
|
||||
' for (unsigned i = 0; '
|
||||
'i < sizeof(swf_play_abis) / sizeof(swf_play_abis[0]); ++i) {\n'
|
||||
' if (!swf_play_abis[i]) return 0;\n'
|
||||
' }\n'
|
||||
' return 1;\n'
|
||||
'}\n')
|
||||
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
temporary = Path(directory)
|
||||
for platform, (compiler, target) in VARIANTS.items():
|
||||
extra = ["-mthumb"] if platform == "vita" else []
|
||||
output = temporary / f"swf_play_{platform}.o"
|
||||
build = subprocess.run([
|
||||
compiler, "-target", target, "-ffreestanding",
|
||||
"-fno-builtin",
|
||||
"-c", "-std=c11", "-O2", "-Wall", "-Wextra", "-Werror",
|
||||
*extra,
|
||||
f"-DIGGY_RECONSTRUCT_SWF_PLAY_{platform.upper()}=1",
|
||||
"-I", str(RECONSTRUCTED), str(SOURCE), "-o", str(output),
|
||||
], capture_output=True, text=True)
|
||||
self.assertEqual(build.returncode, 0, (platform, build.stderr))
|
||||
if LLVM_NM.exists():
|
||||
defined = subprocess.run([
|
||||
str(LLVM_NM), "--extern-only", "--defined-only",
|
||||
str(output),
|
||||
], capture_output=True, text=True)
|
||||
undefined = subprocess.run([
|
||||
str(LLVM_NM), "--undefined-only", str(output),
|
||||
], capture_output=True, text=True)
|
||||
names = {normalized_symbol(parts[-1])
|
||||
for line in defined.stdout.splitlines()
|
||||
if len(parts := line.split()) >= 2 and
|
||||
parts[-2].upper() in {"T", "D", "B", "C"}}
|
||||
imports = {normalized_symbol(line.split()[-1])
|
||||
for line in undefined.stdout.splitlines()
|
||||
if line.split()}
|
||||
self.assertEqual(
|
||||
names, EXPECTED_FUNCTIONS | EXPECTED_GLOBALS, platform)
|
||||
# The cross-module import contract is exactly EXPECTED_IMPORTS
|
||||
# once toolchain scaffolding and optimizer-chosen libc are
|
||||
# removed.
|
||||
residual = (imports - RUNTIME_ALLOWLISTS[platform]
|
||||
- LIBM_LIBC)
|
||||
self.assertEqual(
|
||||
residual, EXPECTED_IMPORTS,
|
||||
(platform, sorted(residual - EXPECTED_IMPORTS)))
|
||||
|
||||
for language, standard in (("c", "c11"), ("c++", "c++17")):
|
||||
suffix = "c" if language == "c" else "cpp"
|
||||
probe = (temporary / f"swf_play_abi_{platform}.{suffix}")
|
||||
probe.write_text(probe_text, encoding="utf-8")
|
||||
syntax = subprocess.run([
|
||||
compiler, "-target", target, "-ffreestanding",
|
||||
"-fsyntax-only", f"-std={standard}",
|
||||
"-Wall", "-Wextra", "-Werror", *extra,
|
||||
f"-DIGGY_RECONSTRUCT_SWF_PLAY_{platform.upper()}=1",
|
||||
"-I", str(RECONSTRUCTED), str(probe),
|
||||
], capture_output=True, text=True)
|
||||
self.assertEqual(syntax.returncode, 0,
|
||||
(platform, language, syntax.stderr))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user