
    3Kj#E                    R   d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZmZmZmZmZmZmZ ddlmZ  ee      j-                         j.                  d   Zed	z  Zed
z  Zedz  ZdZi dededddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/ed0Zd1d2d3d4e
d5Zd6d7d8d9d:d7d;d9d<d=d>d9d?d=d@d9dAdBdCd9dDdBdEd9dFdBdGd9dHdBdId9dJdBdKd9dLdMdNd9dO
ZdYdPZ dZdQZ!d[dRZ"	 	 	 	 	 	 	 	 d\dSZ#	 	 	 	 	 	 	 	 d\dTZ$d]dUZ%d^dVZ&d_dWZ'e(dXk(  r e) e'             y)`a  Classify the HUD menu mode/state dispatcher layer.

The previous opener/frontier passes proved two negative facts:

* The exact #6/#3/#4 top-menu object construction sequence is grounded, but
  does not directly appear in an input consumer.
* Selected-root and global 0x62 descriptor-add scans do not promote a
  normal-field ESC/X opener.

This pass records the next layer down: functions that are clearly menu
state/cursor/selector machinery after the HUD menu object already exists.  The
goal is not to claim the opener; it is to prevent future analysis from treating
cursor movement, confirm/cancel handling, or selector-table production as the
normal-field opener.
    )annotationsN)Path)Any)	ADD_DESCRIPTOR_ROUTINE_VAEDGE_ACTION_MASK_VATOP_MENU_OBJECT_SEQUENCE_VA
call_sitesfind_functionfunction_rangeshxrefs_in_function	text_refs)read_sections   zHwanse2.exeoutwebiY zinput.currentActionMaskzinput.edgeActionMaskzruntime.enabledTableAi`Y zruntime.enabledTableBipY zruntime.menuCategoryi@Y zruntime.menuCursoriJY zruntime.currentDescriptorIndexi>Y zruntime.activeComparisonGroupiDY zmenu.dispatchLatchi(U zmenu.dispatchStopFlagiU zmenu.cursorMaxiXY zmenu.cursorModeiZY zmenu.cursorSourceOffseti[Y zmenu.cursorYBasei\Y zmenu.cursorYi^Y zmenu.soundHandleilY zdescriptor.activeOrderivE iPwE iDwE ivE )zdescriptor.rowTablezdescriptor.persistFlagzdescriptor.statusBasetopMenu.objectSequencepA A isB iA )zcall.menuCursorApplyzcall.menuCursorMotionzcall.soundCuezcall.availabilityBuildercall.addDescriptorzmenu-internal input dispatcher"confirmed-menu-internal-not-openeru1  edge mask를 읽고 이미 존재하는 menu object의 cursor/confirm/cancel 상태를 처리한다. 0x55b128 latch, 0x59db58..0x59db5e cursor globals, 0x59dd6c sound handle, 0x4106ba cursor motion helper, 0x42af73 sound cue를 함께 쓰지만 top-menu object sequence나 descriptor-add 호출은 없다.)label	promotiondecisionz+directional input dispatch to cursor helperu   input edge 방향 bit를 해석해 0x410570 cursor helper로 넘기는 방향키 처리층이다. descriptor/materializer 근거가 없어 opener가 아니다.zcursor apply/helperzconfirmed-helperuF   cursor movement helper로, 선택 buffer/object state를 갱신한다.zcursor motion/sound helperuQ   0x59db5a/5b/5c/5e cursor globals를 소비하는 menu cursor motion 계층이다.zavailability table builderzconfirmed-selector-state-layeruR   0x59e360/0x59e370 enabled table을 준비하는 selector availability producer다.zavailability branch consumeruD   object+0xa8 selector와 enabled table 값을 비교해 분기한다.znext enabled row produceruR   enabled table에서 다음 선택 가능 row를 찾고 object+0xa8 slot에 쓴다.z'active descriptor row selector produceruV   active descriptor row의 +0x48/+0x4a 값을 비교해 menu selector slot을 만든다.z)persistent menu category/cursor load-saveu   active descriptor row와 0x59e340/0x59e34a 사이에 menu category/cursor 상태를 load/save하는 persistent state handler다.zdisplay VM selector base binderz confirmed-base-binder-not-openeru]   display/object VM의 base pointer를 고르는 binder다. opener 증거로 쓰면 안 된다.)
A i;@ r   r   i@ i@ i_@ i@ iR@ iA c                V    t        j                  | dd      S t        |       d      S )N T)quote)htmlescapestr)values    4tools/build_hud_menu_mode_state_dispatcher_review.pyhr$      s%    ;;U]r$GGE
$GG    c                    |j                         D ci c]5  \  }}t        | |      r$|t        | |      D cg c]  }t        |       c}7 c}}}S c c}w c c}}}w Nitemsr   r   )rowrefs_by_namenamerefsrefs        r#   refs_for_functionr/      s_     ',,. D$C& 	"23"=>3r#w>> >   #AA
AAc                    |j                         D ci c]5  \  }}t        | |      r$|t        | |      D cg c]  }t        |       c}7 c}}}S c c}w c c}}}w r'   r(   )r*   calls_by_namer,   r-   r.   s        r#   calls_for_functionr3      s_     (--/ D$C& 	"23"=>3r#w>> >r0   c                   g }t        t        j                               D ]  \  }}t        | |      }|s&|j	                  |t        |      |d   ddi i d       :t        |d         }|j	                  |t        |      t        |      t        t        |d               t        |d         |d   |d   |d	   t        ||      t        ||      d

        |S )Nr   zmissing-function-rangez3function prologue range not found by static scanner)
functionVafunctionVaHexr   r   r   refHitscallHitsstartVaendVasizer   r   )
r5   r6   requestedVaHexendVaHexr;   r   r   r   r7   r8   )	sortedDISPATCHER_FUNCTIONSr)   r
   appendr   intr/   r3   )	functionsr+   r2   rowsvametafunctionstart_vas           r#   classify_known_functionsrH      s    
 "$D/5578 
D B/KK"$%'V!']!9 U! "
 x	*+&!#H"$R&s8G#456HV,-g!+. ,,X|D.xG	
!
< Kr%   c                d   i }|j                         D ])  }|D ]"  }t        | |      }|s||t        |d         <   $ + |j                         D ])  }|D ]"  }t        | |      }|s||t        |d         <   $ + g }	t        |j                         d       D ]  }t	        ||      }
t        ||      }t        d |
D              }t        d |
D              }d|
v }d|v }|sJ|s|s|sQ|	j                  t        t        |d               t        t        |d               |||||
|d	        |	S )
Nr9   c                    t        | d         S )Nr9   )rA   )items    r#   <lambda>z(discover_intersections.<locals>.<lambda>   s    c$y/>R r%   )keyc              3  >   K   | ]  }|j                  d         yw)zinput.N
startswith.0r,   s     r#   	<genexpr>z)discover_intersections.<locals>.<genexpr>   s     Gd1G   c              3  >   K   | ]  }|j                  d         yw))zruntime.zmenu.zdescriptor.NrO   rQ   s     r#   rS   z)discover_intersections.<locals>.<genexpr>   s"      
 OO@A
rT   r   r   r:   )r6   r=   inputHitmenuStateHit
topMenuHitdescriptorAddCallHitr7   r8   )	valuesr
   rA   r>   r/   r3   anyr@   r   )rB   r+   r2   touchedr-   r.   rF   callscallrC   ref_hits	call_hits	input_hitmenu_state_hittop_hitadd_hits                   r#   discover_intersectionsre      sp   
 *,G##% = 	=C$Y4H4<HY/01	==
 %%' = 	=D$Y5H4<HY/01	== "$D7>>+1RS $X|<&x?	GhGG	 
 
 
 +h6&)3.GwKK%'HY,?(@%A "3x'8#9 : )$2"),3' )	. Kr%   c                    t         j                         } t        |       }t        | |      }t        j                         D ci c]  \  }}|t        | ||       }}}t        j                         D ci c]  \  }}|t        | ||       }}}t        |||      }t        |||      }|D 	cg c]&  }	|	j                  d      s|	j                  d      r|	( }
}	|D 	cg c].  }	t        |	j                  dd            j                  d      r|	0 }}	t        |      t        |      t        |      t        |
      t        d |D              ddd	}d
dd||||
|j                         D ci c]  \  }}||D cg c]  }t!        |       c}! c}}}|j                         D ci c]  \  }}||D cg c]  }t!        |       c}! c}}}g dg ddS c c}}w c c}}w c c}	w c c}	w c c}w c c}}}w c c}w c c}}}w )NrX   rY   r   r   	confirmedc              3  R   K   | ]  }|d    t        d      k(  xr |d   dk(   ! yw)r6   r   r   r   N)r   rR   r*   s     r#   rS   zbuild_report.<locals>.<genexpr>  sB      ,
   BzN2 IK $HHI,
s   %'Fu\  0x0041d61b 및 0x0040b49e..0x0040b752 계열은 메뉴가 이미 열린 뒤의 cursor/selector/mode-state dispatcher로 분류된다. 이 층은 입력, cursor globals, selector table을 강하게 참조하지만 top-menu object sequence 생성이나 descriptor-add 호출과 연결되지 않으므로 normal-field ESC/X opener 증거가 아니다.)knownDispatcherRowsconfirmedInternalRowsinputMenuStateIntersectionCount,inputTopMenuOrAddDescriptorIntersectionCountmenuInternalDispatcherProvennormalFieldEscOpenerProvenr   z,hwanse-hud-menu-mode-state-dispatcher-reviewz4tools/build_hud_menu_mode_state_dispatcher_review.pyz0menu-internal-dispatcher-grounded-opener-pending)zy0x0041d61b reads input edge mask and menu cursor globals, but does not reference 0x004ddc6c and does not call 0x00431fe8.z0x0040b49e..0x0040b752 selector handlers prepare/consume enabled tables and persistent cursor state, not menu object construction.zzThe exact top-menu #6/#3/#4 construction sequence remains data-grounded at 0x004ddc84 with no input-consumer intersection.)zTrace the higher-level field mode/state transition that creates or attaches the top-menu descriptor before 0x0041d61b starts consuming cursor input.zySearch for producers of descriptor stack materialization or selected-root switch, not for cursor/confirm/cancel handlers.zPromote only if a candidate connects input/state transition to the exact 0x004ddc6c top-menu object sequence or its descriptor attachment path.)kindsourcestatussummarydispatcherRowsinputMenuStateIntersectionsopenerLikeIntersections
refsByNamecallsByNamenegativeEvidencenextFrontier)EXE
read_bytesr   r   MENU_STATE_GLOBALSr)   r   CALL_TARGETSr	   rH   re   getr!   rP   lenr[   r   )exesectionsrB   r,   rD   r+   r2   dispatcher_rowsintersectionsr*   opener_likeconfirmed_internalrs   r-   r.   r]   r^   s                    r#   build_reportr      s'   
..
CS!HX.I +002D" 	iXr**L  %**,D" 	jh++M  /y,VO*9lMRM$77< CGG,B$C 	K 
 'sww{B'(33K@ 	   #?3!$%7!8+.}+=8;K8H(+ ,
 ',
 )

 ',aG& ?HD)'4#.IUI[I[I]^^:4t6#bg66^N[NaNaNcdd{tUE:Dr$x::d


 K> 7^:dsH   G5G .+G&3G+-G5:G0G5)H6G< H0G5<Hc                   | d   }d| d   fd|d   fd|d   fd|d   fd	|d
   fd|d   fg}dj                  d |D              }dj                  d | d   D              }dj                  d | d   D              }dj                  d | d   D              }dj                  d | d   D              }t        j                  | d      }dt        |d          d| d| d|xs d d| d | d!| d"S )#Nrs   rr   zdispatcher rowsrj   zconfirmed internalrk   zinput/menu intersectionsrl   zopener-like intersectionsrm   zopener provenro   r   c              3  X   K   | ]"  \  }}d t        |       dt        |       d $ yw)z<div class='card'><b>z
</b><span>z</span></div>Nr$   )rR   kvs      r#   rS   zrender_html.<locals>.<genexpr>@  s/     fX\XY[\/!vZ!v]Sfs   (*c              3  ^  K   | ]  }d t        |d          dt        |d          dt        |d          dt        |d          dt        t        j                  |j                  d	i       d
             dt        t        j                  |j                  di       d
             d  yw)<tr><td><code>r6   z</code><br>r   	</td><td>r   z<br><span class='note'>r   z</span></td><td>r7   Fensure_asciir8   
</td></tr>N)r$   jsondumpsr   ri   s     r#   rS   zrender_html.<locals>.<genexpr>A  s       	s?+,-[3w<8I J[!"##:1S_;M:N OCGGIr2GHI JCGGJ3%HIJ K		s   B+B-rt   c              3     K   | ]^  }d t        |d          dt        t        j                  |d   d             dt        t        j                  |d   d             d ` y	w)
r   r6   z</code></td><td>r7   Fr   r   r8   r   N)r$   r   r   ri   s     r#   rS   zrender_html.<locals>.<genexpr>J  st       	s?+,- .C	N?@A BC
O%@AB C	s   A$A&ru   c              3  :   K   | ]  }d t        |       d  ywz<li>z</li>Nr   rR   rK   s     r#   rS   zrender_html.<locals>.<genexpr>R  s     U$$qwiu-U   ry   c              3  :   K   | ]  }d t        |       d  ywr   r   r   s     r#   rS   zrender_html.<locals>.<genexpr>S  s     PagYe,Pr   rz   Fr   a)  <!doctype html>
<html lang="ko">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>HUD Menu Mode/State Dispatcher Review</title>
  <style>
    body { margin:0; background:#101318; color:#edf1f7; font-family:system-ui,sans-serif; }
    main { max-width:1280px; margin:0 auto; padding:24px; }
    a { color:#8ecbff; }
    .nav { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; }
    .chip { border:1px solid #334155; border-radius:999px; padding:6px 10px; text-decoration:none; background:#161b22; }
    .summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:12px; margin:16px 0; }
    .card { border:1px solid #2b3544; border-radius:8px; padding:12px; background:#161b22; }
    .card b { display:block; color:#9fb1c9; font-size:12px; text-transform:uppercase; }
    .card span { display:block; margin-top:8px; font-size:18px; overflow-wrap:anywhere; }
    section { border:1px solid #273244; border-radius:10px; padding:16px; margin:16px 0; background:#141922; overflow:auto; }
    table { border-collapse:collapse; width:100%; min-width:1080px; font-size:13px; }
    th,td { border-bottom:1px solid #283342; padding:8px; text-align:left; vertical-align:top; }
    th { color:#b9c7dc; background:#111722; }
    code { color:#dbeafe; overflow-wrap:anywhere; }
    .note { display:block; margin-top:6px; color:#9fb1c9; line-height:1.35; }
    pre { white-space:pre-wrap; background:#0b0f14; border:1px solid #253044; border-radius:8px; padding:12px; max-height:420px; overflow:auto; }
  </style>
</head>
<body>
<main>
  <div class="nav">
    <a class="chip" href="index.html">index</a>
    <a class="chip" href="hud_menu_opener_frontier_review.html">opener frontier</a>
    <a class="chip" href="hud_menu_selected_root_frontier_review.html">selected-root frontier</a>
    <a class="chip" href="hud_menu_preview.html">HUD menu preview</a>
    <a class="chip" href="../out/hud_menu_mode_state_dispatcher_review.json">JSON</a>
  </div>
  <h1>HUD Menu Mode/State Dispatcher Review</h1>
  <p>r   z</p>
  <div class="summary">z</div>
  <section>
    <h2>Confirmed Dispatcher/Selector Layer</h2>
    <table>
      <thead><tr><th>function</th><th>classification</th><th>refs</th><th>calls</th></tr></thead>
      <tbody>z</tbody>
    </table>
  </section>
  <section>
    <h2>Input + Menu-State Intersections</h2>
    <table>
      <thead><tr><th>function</th><th>refs</th><th>calls</th></tr></thead>
      <tbody>z@<tr><td colspan='3'>No input/menu-state intersections.</td></tr>zV</tbody>
    </table>
  </section>
  <section>
    <h2>Negative Evidence</h2>
    <ul>zB</ul>
  </section>
  <section>
    <h2>Next Frontier</h2>
    <ul>z</ul>
  </section>
  <section>
    <h2>Raw JSON</h2>
    <pre id="json"></pre>
  </section>
</main>
<script>
window.HWANSE_HUD_MENU_MODE_STATE_DISPATCHER_REVIEW = z;
document.getElementById('json').textContent = JSON.stringify(window.HWANSE_HUD_MENU_MODE_STATE_DISPATCHER_REVIEW, null, 2);
</script>
</body>
</html>
)joinr   r   r$   )	reportrs   cards	card_htmlrC   
inter_rows	negativesfrontierpayloads	            r#   render_htmlr   6  s   YG	6(#$	G$9:;	w'>?@	#W-N%OP	$g.\&]^	'">?@E f`effI77  *+ D   78 J U&AS:TUUIwwP9OPPHjje4G#F 
 !{ #
 V  ^^_ `	
 
 	 

 7 8?i @CF Fr%   c                 2   t               } t        j                  d       t        j                  d       t        dz  j	                  t        j                  | dd      dz   d	       t        d
z  j	                  t        |       d	       t        d       y)NT)exist_okz*hud_menu_mode_state_dispatcher_review.jsonF   )r   indent
zutf-8)encodingz*hud_menu_mode_state_dispatcher_review.htmlz(hud_menu_mode_state_dispatcher_review okr   )	r   OUTmkdirWEB
write_textr   r   r   print)r   s    r#   mainr     s    ^FIItIIItI77CC

6a84? D  	77CCKPVDWbiCj	
45r%   __main__)r"   r   returnr!   )r*   dict[str, Any]r+   dict[str, list[int]]r   dict[str, list[str]])r*   r   r2   r   r   r   )rB   list[dict[str, Any]]r+   r   r2   r   r   r   )r   r   )r   r   r   r!   )r   rA   )*__doc__
__future__r   r   r   pathlibr   typingr   %build_hud_menu_opener_frontier_reviewr   r   r   r	   r
   r   r   r   r   probe_exe_scene_tablesr   __file__resolveparentsROOTr{   r   r   CURRENT_ACTION_MASK_VAr}   r~   r?   r$   r/   r3   rH   re   r   r   r   __name__
SystemExit r%   r#   <module>r      s   #    
 
 
 1 H~''*
]
Ul
Ul# 5/ Z Z	
 J * %j $Z * Z j z z 
 J  
!" j#$ &('9+ 2 '' *3 29K		 ?9L	 ''\ .'g .5h 05Z -5h ;5l =5;	 37ss> BH$#$&$ ($ 	$N)#)&) () 	)X>BeP
 z
TV
 r%   