# port/input/pad-boot.txt: power-on -> boot signs -> title -> New Game
#
# Format: port/input/pad_script.h. <tick> = Main tick from 0 (25 per second
# in PAL: frame step systemStatus[1] = 2, common/src/main.c). Buttons are
# the game's logical word, active high: CROSS 0040, START 0800, LEFT 8000.
#
# The boot timings below are worked out from the code; the measured ones
# are marked ("Measured"). Each step's tick depends on load and memory-card latency,
# so the script does not try to hit each screen at a known tick. It repeats
# a cycle in which every press either advances the screen that is up or does
# nothing there (checked for each screen below). Every press lasts 3 ticks;
# the game acts on the press edge only (pad[0].flags is iosPadRead's trg,
# fumi/ios/pad.c iosPadRead, sugipon/src/keyInput.c:46), so holding never repeats.
#
# frame_count: exec_layout_texture clears pad[0].flags whenever frame_count -
# selectFrame is 0 or 1 (common/src/layout_texture.c:619-621), and it runs
# every tick in a loaded stage (common/src/icoMisc.c:275-279), before
# kanbanExec and the actors. frame_count advances only in GsBase.c
# (seki/src/GsBase.c:981, gsb_UpdateGSSystem, once per frame step). The
# headless build compiles the real GsBase.c (cmake/IcoSources.cmake), so it
# does advance; a build that stubs gsb_UpdateGSSystem would eat every press.
#
# Pad: the host pad reports a DualShock that reaches pad.c's stable analog
# state on tick 6 and is first read on tick 7 (port/input/pad_host.c); the
# first press is at tick 8.
#
# Screens in order, what accepts input, and how this script answers.
# Confidence is for the logic; no step's timing is known.
#
#  1. Stage 1 load, memory-card check. kanbanBootMcCheck checks ports 0 and
#     1, ten tries (common/src/kanbanBoot.c:66-117); the host card layer
#     (port/save/mc_host.c) answers per its folder, port 1 empty. No input. Confidence: high.
#  2. Language sign (kanban 0, kanbanBoot.c:153-174), cursor on English
#     (item 26 for sceScfGetLanguage 1, kanbanBoot.c:157-158;
#     port/config/sysconf.c; English = 1). CROSS confirms (kanban.c:138-141
#     -> key 1, kanbanBoot.c:177). A sign takes input from its first tick,
#     fading in or not (kanban.c:394). LEFT: item 26 has no left link
#     (texProperty[26]), so it does nothing. Confidence: high.
#  3. 50/60 Hz sign (kanban 1, kanbanBoot.c:223-246), default item 33 = 50 Hz
#     (texLayout[1].defaultItem; kanbanBoot.c:230-231 keeps systemStatus[0]
#     = 1). CROSS confirms 50 Hz; LEFT on 33 does nothing (34's left goes to
#     33). Confidence: high.
#  4. No memory card (kanban 5 with the "no card" sign 3, kanbanBoot.c:
#     255-285; after the second card check, kanbanBoot.c:248-249, 108-117).
#     The cursor starts on item 42 (texLayout[5].defaultItem), which is
#     "check again"; only item 41 continues (kanbanBoot.c:276-280). LEFT
#     moves 42 -> 41 (texProperty[42].leftItem), then CROSS continues. A
#     CROSS on 42 just retries the card check and the sign comes back
#     (kanbanBoot.c:282-284), so a cycle that lands badly costs one cycle.
#     Confidence: high (logic), medium (no run).
#  5. "Please wait" sign for 5 s = 125 ticks (kanbanBoot.c:318-330), then
#     kanbanBootEnd (kanbanBoot.c:346). No input. Confidence: high.
#  6. Opening demo (script/src/op.c:126-178, layout 55 la_game_demo,
#     common/src/layout_action.c:612-621). START (0800) skips to the title
#     (op.c:169-172) once the demo's ADPCM stream handle is set and 30 ticks
#     have passed (op.c:161-164). CROSS and LEFT do nothing here; START on
#     layout 55 also needs gflag 388 (layout_action.c:2562), which nothing in
#     the C sets. If no START lands, the demo runs out and puts up the title
#     itself (op.c:474), which phase 2 handles. Confidence: medium: the
#     handle comes from an ADPCM open through the cdvd background reader
#     (script/src/script.c:931-942, fumi/sound/adpcm_init.c:399-414); if that
#     never completes, the boot stops here whatever is pressed.
#  7. Title, "Continue / New Game" (layout 12, layout_action.c:711-769). With
#     no card _la_set_current_port_2 returns -1 (layout_action.c:309-311,
#     458-470) and the title switches itself to layout 13 (layout_action.c:
#     763-766) once it has faded in (1.5 s, layout_texture.c:587). No input
#     needed; CROSS/START do nothing while continueDecided is 0. Confidence:
#     medium-high.
#  8. Title, "New Game" only (layout 13, layout_action.c:773-821). The card
#     check sets newGameDecided (layout_action.c:807-809); after the 1.5 s
#     fade-in, CROSS or START (mask 0840) starts a new game (796-803 ->
#     layout 9). Presses during the fades are ignored (the proc runs only in
#     fade states 1-2 and accepts only in 2, layout_texture.c:575,587). The
#     title's 10 s idle timer (op.c:92-101, 197) only runs before a choice.
#     Confidence: high (logic).
#  9. Vibration on/off (layout 9 la_vibe_select, layout_action.c:652-684),
#     cursor on 44 = on. CROSS or START after its 0.5 s fade-in: gflagInit,
#     gflagOn(382) (layout_action.c:668-671). TRIANGLE would go back to the
#     title, so it is never pressed. Confidence: high.
# 10. gflag 382 -> actSt26aConte01_1_newgame: gflagOn(2), RequestStageChange
#     (op.c:484-499); stgmgrForceSwitchWithFadeColor sets graphics_ready = 1
#     (common/src/StageManager.c:502) in that same tick, so the layout procs
#     stop and a later press cannot confirm screen 9 twice (a second confirm
#     would gflagInit again). The next stage starts on layout 54 or a
#     cutscene's 55 (layout_texture.c:767-768). Confidence: medium.
#
# Phases:
#   phase 1 (ticks 8..1599): LEFT, CROSS, START every 40 ticks. Covers
#     screens 2-9 if the title is reached by about tick 1500. Estimate (no
#     run): load + card checks a few hundred ticks, the four signs and the
#     wait about 300-400, demo to START about 100, title to New Game about
#     150: roughly 800-1100 ticks.
#   phase 2 (ticks 1608..5999): LEFT and CROSS only, for a slower boot or a
#     demo that runs to the end (screens 2-5 and 7-9 accept CROSS).
# Stray presses after the new game: START pauses the game on layout 54
#   (layout_action.c:2523-2537); CROSS (item 295 is the default) or START
#   resumes (layout_action.c:2588); LEFT does nothing in the pause menu.
#   CROSS in play is a game action. Once a trace shows the tick where
#   gf11 bit 30 (0x40000000, flag 382) sets, delete every line after it.
#
# Host devices on the way: every disc read finishes at the next vsync; the sound driver is the SNDN2DRV host over
# the emulated SPU2, so streams advance as the IOP's would;
# the memory card is port/save/mc_host.c: port 0 is the saves folder (a
# formatted card, empty on a first run), port 1 has no card. Screens 4 and
# 7 below were written when both ports reported no card (the earlier null
# card) and describe that path, not the one a card in port 0 takes.
#
# Measured:
# flag 382 sets at Main tick 661 (stage 1); the stages then run 41 (tick
# 663), 42, 43, 45, 40 and 3 (tick 1036).

# ---- phase 1: ticks 8..1599, every 40 ticks: LEFT, CROSS, START ----
8 8000    # LEFT
11 0000
21 0040    # CROSS
24 0000
34 0800    # START
37 0000
48 8000    # LEFT
51 0000
61 0040    # CROSS
64 0000
74 0800    # START
77 0000
88 8000    # LEFT
91 0000
101 0040    # CROSS
104 0000
114 0800    # START
117 0000
128 8000    # LEFT
131 0000
141 0040    # CROSS
144 0000
154 0800    # START
157 0000
168 8000    # LEFT
171 0000
181 0040    # CROSS
184 0000
194 0800    # START
197 0000
208 8000    # LEFT
211 0000
221 0040    # CROSS
224 0000
234 0800    # START
237 0000
248 8000    # LEFT
251 0000
261 0040    # CROSS
264 0000
274 0800    # START
277 0000
288 8000    # LEFT
291 0000
301 0040    # CROSS
304 0000
314 0800    # START
317 0000
328 8000    # LEFT
331 0000
341 0040    # CROSS
344 0000
354 0800    # START
357 0000
368 8000    # LEFT
371 0000
381 0040    # CROSS
384 0000
394 0800    # START
397 0000
408 8000    # LEFT
411 0000
421 0040    # CROSS
424 0000
434 0800    # START
437 0000
448 8000    # LEFT
451 0000
461 0040    # CROSS
464 0000
474 0800    # START
477 0000
488 8000    # LEFT
491 0000
501 0040    # CROSS
504 0000
514 0800    # START
517 0000
528 8000    # LEFT
531 0000
541 0040    # CROSS
544 0000
554 0800    # START
557 0000
568 8000    # LEFT
571 0000
581 0040    # CROSS
584 0000
594 0800    # START
597 0000
608 8000    # LEFT
611 0000
621 0040    # CROSS
624 0000
634 0800    # START
637 0000
648 8000    # LEFT
651 0000
661 0040    # CROSS
664 0000
674 0800    # START
677 0000
688 8000    # LEFT
691 0000
701 0040    # CROSS
704 0000
714 0800    # START
717 0000
728 8000    # LEFT
731 0000
741 0040    # CROSS
744 0000
754 0800    # START
757 0000
768 8000    # LEFT
771 0000
781 0040    # CROSS
784 0000
794 0800    # START
797 0000
808 8000    # LEFT
811 0000
821 0040    # CROSS
824 0000
834 0800    # START
837 0000
848 8000    # LEFT
851 0000
861 0040    # CROSS
864 0000
874 0800    # START
877 0000
888 8000    # LEFT
891 0000
901 0040    # CROSS
904 0000
914 0800    # START
917 0000
928 8000    # LEFT
931 0000
941 0040    # CROSS
944 0000
954 0800    # START
957 0000
968 8000    # LEFT
971 0000
981 0040    # CROSS
984 0000
994 0800    # START
997 0000
1008 8000    # LEFT
1011 0000
1021 0040    # CROSS
1024 0000
1034 0800    # START
1037 0000
1048 8000    # LEFT
1051 0000
1061 0040    # CROSS
1064 0000
1074 0800    # START
1077 0000
1088 8000    # LEFT
1091 0000
1101 0040    # CROSS
1104 0000
1114 0800    # START
1117 0000
1128 8000    # LEFT
1131 0000
1141 0040    # CROSS
1144 0000
1154 0800    # START
1157 0000
1168 8000    # LEFT
1171 0000
1181 0040    # CROSS
1184 0000
1194 0800    # START
1197 0000
1208 8000    # LEFT
1211 0000
1221 0040    # CROSS
1224 0000
1234 0800    # START
1237 0000
1248 8000    # LEFT
1251 0000
1261 0040    # CROSS
1264 0000
1274 0800    # START
1277 0000
1288 8000    # LEFT
1291 0000
1301 0040    # CROSS
1304 0000
1314 0800    # START
1317 0000
1328 8000    # LEFT
1331 0000
1341 0040    # CROSS
1344 0000
1354 0800    # START
1357 0000
1368 8000    # LEFT
1371 0000
1381 0040    # CROSS
1384 0000
1394 0800    # START
1397 0000
1408 8000    # LEFT
1411 0000
1421 0040    # CROSS
1424 0000
1434 0800    # START
1437 0000
1448 8000    # LEFT
1451 0000
1461 0040    # CROSS
1464 0000
1474 0800    # START
1477 0000
1488 8000    # LEFT
1491 0000
1501 0040    # CROSS
1504 0000
1514 0800    # START
1517 0000
1528 8000    # LEFT
1531 0000
1541 0040    # CROSS
1544 0000
1554 0800    # START
1557 0000
1568 8000    # LEFT
1571 0000
1581 0040    # CROSS
1584 0000
1594 0800    # START
1597 0000

# ---- phase 2: ticks 1608..5999, every 40 ticks: LEFT, CROSS (no START) ----
1608 8000    # LEFT
1611 0000
1621 0040    # CROSS
1624 0000
1648 8000    # LEFT
1651 0000
1661 0040    # CROSS
1664 0000
1688 8000    # LEFT
1691 0000
1701 0040    # CROSS
1704 0000
1728 8000    # LEFT
1731 0000
1741 0040    # CROSS
1744 0000
1768 8000    # LEFT
1771 0000
1781 0040    # CROSS
1784 0000
1808 8000    # LEFT
1811 0000
1821 0040    # CROSS
1824 0000
1848 8000    # LEFT
1851 0000
1861 0040    # CROSS
1864 0000
1888 8000    # LEFT
1891 0000
1901 0040    # CROSS
1904 0000
1928 8000    # LEFT
1931 0000
1941 0040    # CROSS
1944 0000
1968 8000    # LEFT
1971 0000
1981 0040    # CROSS
1984 0000
2008 8000    # LEFT
2011 0000
2021 0040    # CROSS
2024 0000
2048 8000    # LEFT
2051 0000
2061 0040    # CROSS
2064 0000
2088 8000    # LEFT
2091 0000
2101 0040    # CROSS
2104 0000
2128 8000    # LEFT
2131 0000
2141 0040    # CROSS
2144 0000
2168 8000    # LEFT
2171 0000
2181 0040    # CROSS
2184 0000
2208 8000    # LEFT
2211 0000
2221 0040    # CROSS
2224 0000
2248 8000    # LEFT
2251 0000
2261 0040    # CROSS
2264 0000
2288 8000    # LEFT
2291 0000
2301 0040    # CROSS
2304 0000
2328 8000    # LEFT
2331 0000
2341 0040    # CROSS
2344 0000
2368 8000    # LEFT
2371 0000
2381 0040    # CROSS
2384 0000
2408 8000    # LEFT
2411 0000
2421 0040    # CROSS
2424 0000
2448 8000    # LEFT
2451 0000
2461 0040    # CROSS
2464 0000
2488 8000    # LEFT
2491 0000
2501 0040    # CROSS
2504 0000
2528 8000    # LEFT
2531 0000
2541 0040    # CROSS
2544 0000
2568 8000    # LEFT
2571 0000
2581 0040    # CROSS
2584 0000
2608 8000    # LEFT
2611 0000
2621 0040    # CROSS
2624 0000
2648 8000    # LEFT
2651 0000
2661 0040    # CROSS
2664 0000
2688 8000    # LEFT
2691 0000
2701 0040    # CROSS
2704 0000
2728 8000    # LEFT
2731 0000
2741 0040    # CROSS
2744 0000
2768 8000    # LEFT
2771 0000
2781 0040    # CROSS
2784 0000
2808 8000    # LEFT
2811 0000
2821 0040    # CROSS
2824 0000
2848 8000    # LEFT
2851 0000
2861 0040    # CROSS
2864 0000
2888 8000    # LEFT
2891 0000
2901 0040    # CROSS
2904 0000
2928 8000    # LEFT
2931 0000
2941 0040    # CROSS
2944 0000
2968 8000    # LEFT
2971 0000
2981 0040    # CROSS
2984 0000
3008 8000    # LEFT
3011 0000
3021 0040    # CROSS
3024 0000
3048 8000    # LEFT
3051 0000
3061 0040    # CROSS
3064 0000
3088 8000    # LEFT
3091 0000
3101 0040    # CROSS
3104 0000
3128 8000    # LEFT
3131 0000
3141 0040    # CROSS
3144 0000
3168 8000    # LEFT
3171 0000
3181 0040    # CROSS
3184 0000
3208 8000    # LEFT
3211 0000
3221 0040    # CROSS
3224 0000
3248 8000    # LEFT
3251 0000
3261 0040    # CROSS
3264 0000
3288 8000    # LEFT
3291 0000
3301 0040    # CROSS
3304 0000
3328 8000    # LEFT
3331 0000
3341 0040    # CROSS
3344 0000
3368 8000    # LEFT
3371 0000
3381 0040    # CROSS
3384 0000
3408 8000    # LEFT
3411 0000
3421 0040    # CROSS
3424 0000
3448 8000    # LEFT
3451 0000
3461 0040    # CROSS
3464 0000
3488 8000    # LEFT
3491 0000
3501 0040    # CROSS
3504 0000
3528 8000    # LEFT
3531 0000
3541 0040    # CROSS
3544 0000
3568 8000    # LEFT
3571 0000
3581 0040    # CROSS
3584 0000
3608 8000    # LEFT
3611 0000
3621 0040    # CROSS
3624 0000
3648 8000    # LEFT
3651 0000
3661 0040    # CROSS
3664 0000
3688 8000    # LEFT
3691 0000
3701 0040    # CROSS
3704 0000
3728 8000    # LEFT
3731 0000
3741 0040    # CROSS
3744 0000
3768 8000    # LEFT
3771 0000
3781 0040    # CROSS
3784 0000
3808 8000    # LEFT
3811 0000
3821 0040    # CROSS
3824 0000
3848 8000    # LEFT
3851 0000
3861 0040    # CROSS
3864 0000
3888 8000    # LEFT
3891 0000
3901 0040    # CROSS
3904 0000
3928 8000    # LEFT
3931 0000
3941 0040    # CROSS
3944 0000
3968 8000    # LEFT
3971 0000
3981 0040    # CROSS
3984 0000
4008 8000    # LEFT
4011 0000
4021 0040    # CROSS
4024 0000
4048 8000    # LEFT
4051 0000
4061 0040    # CROSS
4064 0000
4088 8000    # LEFT
4091 0000
4101 0040    # CROSS
4104 0000
4128 8000    # LEFT
4131 0000
4141 0040    # CROSS
4144 0000
4168 8000    # LEFT
4171 0000
4181 0040    # CROSS
4184 0000
4208 8000    # LEFT
4211 0000
4221 0040    # CROSS
4224 0000
4248 8000    # LEFT
4251 0000
4261 0040    # CROSS
4264 0000
4288 8000    # LEFT
4291 0000
4301 0040    # CROSS
4304 0000
4328 8000    # LEFT
4331 0000
4341 0040    # CROSS
4344 0000
4368 8000    # LEFT
4371 0000
4381 0040    # CROSS
4384 0000
4408 8000    # LEFT
4411 0000
4421 0040    # CROSS
4424 0000
4448 8000    # LEFT
4451 0000
4461 0040    # CROSS
4464 0000
4488 8000    # LEFT
4491 0000
4501 0040    # CROSS
4504 0000
4528 8000    # LEFT
4531 0000
4541 0040    # CROSS
4544 0000
4568 8000    # LEFT
4571 0000
4581 0040    # CROSS
4584 0000
4608 8000    # LEFT
4611 0000
4621 0040    # CROSS
4624 0000
4648 8000    # LEFT
4651 0000
4661 0040    # CROSS
4664 0000
4688 8000    # LEFT
4691 0000
4701 0040    # CROSS
4704 0000
4728 8000    # LEFT
4731 0000
4741 0040    # CROSS
4744 0000
4768 8000    # LEFT
4771 0000
4781 0040    # CROSS
4784 0000
4808 8000    # LEFT
4811 0000
4821 0040    # CROSS
4824 0000
4848 8000    # LEFT
4851 0000
4861 0040    # CROSS
4864 0000
4888 8000    # LEFT
4891 0000
4901 0040    # CROSS
4904 0000
4928 8000    # LEFT
4931 0000
4941 0040    # CROSS
4944 0000
4968 8000    # LEFT
4971 0000
4981 0040    # CROSS
4984 0000
5008 8000    # LEFT
5011 0000
5021 0040    # CROSS
5024 0000
5048 8000    # LEFT
5051 0000
5061 0040    # CROSS
5064 0000
5088 8000    # LEFT
5091 0000
5101 0040    # CROSS
5104 0000
5128 8000    # LEFT
5131 0000
5141 0040    # CROSS
5144 0000
5168 8000    # LEFT
5171 0000
5181 0040    # CROSS
5184 0000
5208 8000    # LEFT
5211 0000
5221 0040    # CROSS
5224 0000
5248 8000    # LEFT
5251 0000
5261 0040    # CROSS
5264 0000
5288 8000    # LEFT
5291 0000
5301 0040    # CROSS
5304 0000
5328 8000    # LEFT
5331 0000
5341 0040    # CROSS
5344 0000
5368 8000    # LEFT
5371 0000
5381 0040    # CROSS
5384 0000
5408 8000    # LEFT
5411 0000
5421 0040    # CROSS
5424 0000
5448 8000    # LEFT
5451 0000
5461 0040    # CROSS
5464 0000
5488 8000    # LEFT
5491 0000
5501 0040    # CROSS
5504 0000
5528 8000    # LEFT
5531 0000
5541 0040    # CROSS
5544 0000
5568 8000    # LEFT
5571 0000
5581 0040    # CROSS
5584 0000
5608 8000    # LEFT
5611 0000
5621 0040    # CROSS
5624 0000
5648 8000    # LEFT
5651 0000
5661 0040    # CROSS
5664 0000
5688 8000    # LEFT
5691 0000
5701 0040    # CROSS
5704 0000
5728 8000    # LEFT
5731 0000
5741 0040    # CROSS
5744 0000
5768 8000    # LEFT
5771 0000
5781 0040    # CROSS
5784 0000
5808 8000    # LEFT
5811 0000
5821 0040    # CROSS
5824 0000
5848 8000    # LEFT
5851 0000
5861 0040    # CROSS
5864 0000
5888 8000    # LEFT
5891 0000
5901 0040    # CROSS
5904 0000
5928 8000    # LEFT
5931 0000
5941 0040    # CROSS
5944 0000
5968 8000    # LEFT
5971 0000
5981 0040    # CROSS
5984 0000

# ---- end: released from here on ----
