/* ----- BLOCK A: insert immediately BEFORE the comment line "widget source for the six PAGE_OPTIONS buttons" -----
 * PS3 1.19: BUTTON_OPTIONS_EULA 0x7ce251cd (text MENU_TITLE_EULA 0x54b6e963) -> PAGE_EULA 0xda1f28d9; EULA_PICTURES 0x2485c6f, type 0x27,
 * source f_33c1c8 (PS3 enum 0x59 = PS4 0x58, 0x761a60, op 4 image and op 9 input stripped). PS3 builds a URL from net table 0x75e3b9a9 and downloads JPEGs
 * (f_941404); here they are local vtex files eula/p1..p7 (BCES English = 7 pages). PS4 class 0x167a610 draws op 4 and the op 6/7 arrows. */
#define EU_TAG 0x4c414850u
#define EU_PAGES 7
static int32_t eu_cur EXT_BSS;
static void *eu_tex EXT_BSS;
static uint8_t *eu_row EXT_BSS;
EXT static int eu_source(uintptr_t base,int32_t *event,ProfileState *s){
 uint8_t *source=*(uint8_t**)((uint8_t*)event+0x98);if(!source||*(uint32_t*)(source+0x1c)!=EU_TAG)return 0;
 if(!base)return 1;
 switch(event[0]){
  case 4:{void *(*vtex)(uintptr_t,const char*)=(void*(*)(uintptr_t,const char*))s->natives[NATIVE_VTEX_FIND];
   char nm[8]={'e','u','l','a','/','p',(char)('1'+eu_cur),0};void *t=vtex?vtex(base+0x1b31128,nm):0;eu_tex=t;
   for(int k=3;k<=12;k++)event[k]=0;event[9]=-1;event[11]=-1;
   if(t){event[2]=2;*(void**)(event+4)=t;event[12]=0x3f800000;}else{event[2]=0x10;event[12]=0x3f800000;}
   break;}
  case 5:event[1]=eu_cur;break;
  case 6:event[1]=EU_PAGES-1;break;
  case 7:event[1]=0;break;
  case 10:{int32_t v=event[1];eu_cur=v<0?0:v>=EU_PAGES?EU_PAGES-1:v;break;}
  case 23:if(event[14])eu_cur=0;break;
  case 9:{uint8_t *m=*(uint8_t**)(base+0x16e3188);
   /* 0x66e570 op 3 blocks Back in MP unless profile +0x778 == entry +0xc (PS3 f_28b110, profile +1328) */
   uint8_t *pr=*(uint8_t**)(base+0x17dd610);uint8_t *en=((uint8_t*(*)(void))(base+0x6a8010u))();
   if(pr&&en&&*(uint32_t*)(pr+0x778)!=*(uint32_t*)(en+0xc))*(uint32_t*)(pr+0x778)=*(uint32_t*)(en+0xc);
   uint8_t *pend=m?*(uint8_t**)(m+0x898):0;
   if(m&&eu_tex&&(!pend||!*(uint32_t*)(pend+0x10))&&mp_code_is(base,0x658050u,"53488d0d38ca15018b997c08")){
    int r=((int(*)(uint8_t*,int,int))(base+0x658050u))(m,1,0);   /* PS3 f_2656e8: 3 previous, 4 next */
    if(r==3&&eu_cur>0)eu_cur--;else if(r==4&&eu_cur<EU_PAGES-1)eu_cur++;}
   break;}
 }
 return 1;}
/* ----- BLOCK B: in rpm_source replaces the hide lines ----- */
 int eu=k==5&&base&&*(volatile uint8_t*)(base+0x17d5c61u)!=0&&!(X.ec[1]&0x4000u);
 if(k==5&&eu_row)*(uint32_t*)(eu_row+0x50)=eu?0xda1f28d9u:0x163921b2u;   /* PAGE_EULA in MP, PAGE_CREDITS otherwise */
 if(op==8)event[1]=1;
 else if(op==1)set_text(event,text(base,s,eu?0x54b6e963u:*(uint32_t*)(source+8)));
/* ----- BLOCK C: in h21_retag, before the PAGE_OPTIONS id test ----- */
 if(*(uint32_t*)(page+8)==0xda1f28d9u){uint8_t *c1=*(uint8_t**)(page+0x48);uint8_t *i1=c1?*(uint8_t**)(c1+8):0;if(i1&&*(uint32_t*)c1==1&&*(uint32_t*)(i1+0x34)==0x58){*(uint32_t*)(i1+0x34)=0xcf;*(uint32_t*)(i1+0x40)=EU_TAG;}return;}
/* ----- BLOCK E: in the kind 2 dispatch, before the rpm_source call ----- */
  if(eu_source(base,event,s))return 1;
