Reference ยท Engine

Quarantine's field staff roll - STFROLL_VOL4

Covers31 in 3 groups
QUA SLUS_205.64:0x001c52e8 event opcode 169 (ending_kanji)QUA gcmn.prg:0x004f0a30 the roll's start0x004f0950 its thread0x004f0aa0 the object's constructor0x004f0d40 Init0x004f1880 main0x004f2f40 the scroll0x004f2fe0 the logo's fade0x004f31b0 the text and logo draw0x004f3370 the states0x004f1cb0 the animations' transparency0x004f2620 the animations' draw0x004f1d80 the generators0x004f2aa0 the phases0x004f1920 the late comets0x004f1ae0 the comets' frame0x004f12a0 a comet's path0x004f3ad0 a comet's step0x004f3d50 the Catmull-Rom point0x004f3990 a comet's generators ended0x004f3710 a line pushed0x004f36b0 a line dropped0x004f3890 the comet's constructor0x004f37f0 a comet's point0x005cee00 the generator rows0x005cf000 the particle rows0x005cf160 0x005cf180 0x005cf1a0 the comets' random ranges0x005cf1c0 the credits0x005cfc20 the last pageQUA SLUS_205.64:0x002095a0 sqDataEvent row 1260x0020a190 eventPlayType

Quarantine's ending (event 314 "Ending") has one staff roll, its own, not the desktop's: block 3 in field 126, Kite hidden, runs ending_kanji (event opcode 169, which only Quarantine's executable has). That starts STFROLL_VOL4, a thread in gcmn.prg with no symbol. It draws the hacking logos, the credits as ccKanji lines, the ending scene's ring and book, and particle comets, over the field's black. The event's last block, back on the desktop, runs staff_roll, but Quarantine's case 147 starts no desktop roll: it grants wallpapers 77-86 and opens the save menu (desktop.md).

The port is in four places:

  • crates/piney-effect/src/stfroll.rs holds the object's rules.
  • piney_data::tables::stfroll holds its tables, generated by piney-gen's stfroll group.
  • AreaFx::ending (crates/piney-game/src/fx.rs) runs and draws it on the field's effect tasks.
  • Wait::EndingKanji (piney-event) and EvHost start and wait for it.

ending_kanji (opcode 169)

QUA main 0x001c52e8 (events.md, the Quarantine disc):

  1. It sets game.pauseFlag (+0x7c) to 1, which keeps ccThMother's pause for a pulled controller off until ccGame::Init (it is never cleared before), as in the port (overview.md, "The pause"). It puts the player (plw+0x20) at (0, 0, 0, 1).
  2. It reads KFED.BIN and KFAED.BIN, which nothing reads, and frees them at the end.
  3. It adds ending.ccs (ccLoadFLAdd(0x00219340)).
  4. gcmn 0x004f0a30 starts the thread 0x004f0950 at priority 66 with a 0x1000 stack. The call then breathes until the thread's tscb +0x14 is set.

The thread runs in this order:

  1. It names itself STFROLL_VOL4.
  2. It makes the 0x150-byte object, clearing the first nine words, and calls the constructor (0x004f0aa0).
  3. It sets the tscb's +0x40 to 0x004f0730 and calls Init(0).
  4. Each frame it breathes once and runs main (0x004f1880), until +0x108 (done) is set.
  5. It then sets the tscb's +0x14 and breathes forever. Main no longer runs, so nothing is drawn.

The object

offsetfield
+0x00, +0x0c, +0x18three vectors: the shown lines (pointers into the credit rows), the comets, freed comets' iterators
+0x24the last comet
+0x28the scroll, -0.55 a frame
+0x2ca logo's hold (240)
+0x30, +0x34the book's wait; the book drawn
+0x38the logo (ccMask)
+0x3c, +0x40layers 100 and 129 (the text's, sysLayer's view)
+0x4417 ccKanji (0xe8 each): Init(3, 16), type 4 (large fixed), sprite colour row 7
+0x48ccAnm[2]: ANM_ring_anm_2 and ANM_book_anm2 of ending
+0x50, +0x60the camera's view and eye (0, -350, 0, 1)
+0x70, +0x80the ring's position (0, -50, 75, 1) and turn
+0xd0, +0xd4the two glow generators
+0x100, +0x108the next row; done
+0x10c, +0x110the line spacing, 20 and 5
+0x114the table's end is in
+0x118, +0x11cthe state (0-3) and the animations' phase (1-5)
+0x120, +0x124the logo's fade a frame (0.025, negated at each turn) and its transparency
+0x128the phase's frame count
+0x12c-+0x134the late comets' timer, count and limit
+0x138, +0x13c, +0x140the ring's clip over; the last logo's wait (180); the tail (480)

A frame

Main calls, in order:

  1. 0x004f2f40 moves the lines up.
  2. 0x004f2fe0 fades the logo.
  3. 0x004f31b0 draws the 17 lines (state 1), or else the logo.
  4. 0x004f3370 runs the states.
  5. 0x004f1cb0 sets the animations' transparency.
  6. 0x004f2620 draws them.
  7. 0x004f1d80 makes the phase's generators and comets.
  8. 0x004f2aa0 ends phases.
  9. 0x004f1920 makes the late comets.
  10. 0x004f1ae0 moves the comets and frees the done ones.

The states:

  • 0: TEX_hackrogo (".hack Quarantine") fades in by 0.025 a frame, holds 240 frames and fades out. Then Init(1) runs: ccBgmPlay(2), state 1, phase 1, the tail 480, and the next logo TEX_hackrogo_2.
  • 1: the credits scroll up 0.55 a frame. A line above -20 leaves the front of the list, and the next row goes on 25 below the last. The table's end row (text NULL) going above 0 runs Init(2): state 2, the last page's first row.
  • 2: the last page shows logo by logo. TEX_hackrogo_2 (Project .hack) fades in, holds and fades out. Then TEX_hack_url shows after a 180-frame wait. With the page's end in, Init(3): state 3.

The animations' phases:

  • 1: the ring, 25 steps a frame, and its comets.
  • 2: once its clip is over and its comets are done, the ring fades out.
  • 3: the glows are killed and the book comes up, with its standing generators and comet.
  • 4-5: once the book is drawn, the last comet.

Phase 5 ends once every comet is done and the tail of 480 frames has run out. ccBgmStop then stops the music and sets done.

The comets are 0x80-byte objects (constructor 0x004f3890). Each follows a Catmull-Rom path (0x004f3d50) through four points, drawn by 0x004f12a0 from the random ranges at 0x005cf160-0x005cf1a0. Their main generator, and some subordinate ones, sync to the comet's +0x70. The generator rows (0x005cee00) and particle rows (0x005cf000) are piney_data::tables::stfroll's gens and ffs.

In the port's run of Quarantine's data:

roll frameevent
1-319the first logo
320ccBgmPlay(2); the credits, the ring and the glows begin
8002the first comet
9657, 9658the ring's clip over; the book
10416, 10417the book's last phases, the last comet
11047the credits out; state 2 (Project .hack, then the URL)
11742ccBgmStop, done

Where it draws

  • The text. The 17 kanji draw on the roll's own layer 129. The layer takes sysLayer's view, ccLayer::Init's SetFrame(0, 0, 512, 384, 256, 192, 1, 1), so it is not centred.

  • The logo. It is a ccMask sprite on sysLayer (priority 0), the whole 512 by 384 frame.

  • The ring and book. They draw through ccAnm::Draw on the layer ccLayer::active names. In the ending that is sysLayer, for this reason:

    1. Each frame WORLD_MAN::SetActiveLayer(0) makes sysLayer active.
    2. ccLattice::Disp's path with nothing to draw (head == tail) stores its caller's stale $s0 back into ccLayer::active.
    3. Kite's ArmsEffect (with a weapon that has no arms effect) would store -1 there. It is skipped for acts 12, 13, 14 and 24, and pc_act 0 6 has put Kite in act 14.

    So the anms draw on sysLayer with the camera the roll asked for (changeCamera(3), eye and view).

  • Lighting. None of ending's 82 models has mtype bit 0, so no light touches them.

  • The pages. ANM_book_anm2 draws MDL_xdhdpag_a0 three times (its own entry and the ExtObj copies OBJ_xdhdpag_d and _e) and MDL_xdhdpag_b0 twice (with _f).

    • Each entry's Obj2 chunk names its own morpher (MPH_xdhdpag_a0, _d, _e, _f), and Decode_ExtObj (INF 0x0014cb80) keeps it on the copy.
    • So ccModel::Draw bends each page by its own weights, and the pages turn one after another.
    • The port once drew one page per model, morphed by every morpher of that model summed. The page went through the book (#75).
    • piney_world::town::object_morph now takes the entry's modifier. Only ending and the field_i towers have two morphers on one base model, on every disc.

The music

ccBgmPlay(2) streams VOICE/BGM.BIN track 2 from the roll's frame 320 to its end, and ccBgmStop ends it.

Field 126 asks ccSndSQLoad(5), the event bank, with row game.field 126. Quarantine's sqDataEvent runs to 127 rows, and row 126 is empty (-1). eventPlayType[126] is 3. So no bank loads and no sequence plays: the roll's music plays alone. sqVolTblEvent has only 126 rows, but an empty row never reads its volumes.

How it was checked

  • The rules, against the game's code. tools/test_stfroll_rs.py runs the game's own constructor, Init and main in eemu over 12000 frames, with ending.ccs loaded and a stand-in genrand. It compares every frame against crates/piney-effect/examples/stfroll_probe.rs: the object's fields, its vectors, the animations, the lines, the comets, the generators, the draw calls (kanji, mask, anm with its matrix) and the music and camera calls. All frames agree.
  • The whole event.
    • session::tests::ending::event_314_plays_through_field_126 plays event 314 from its start under the pilot. The roll runs 11742 frames and the event ends.
    • the_field_staff_roll_plays_alone hears the event through crate::handle. No sequence plays at any frame of the roll, and track 2 streams from frame 320 to 11742.
    • staff_roll_shots (ignored) writes the main beats as PNGs.
  • The music data. piney-audio's field_126_has_no_bank checks the bank row.
  • The active layer. It was found with piney-eemu's ee_run (EE_PRINT prints each call with the active layer) over a save before 314's field part, with EE_THEN starting the roll by a stub task.

Unknown

  • The pixels have not been compared with the game's output: piney-eemu draws nothing.

How this was found out

docs/engine/stfroll.md