diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index e14eb5f1..c01b2398 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -192,9 +192,22 @@ d/lyt/d_window.cpp: .data start:0x80510820 end:0x805108B0 .sdata2 start:0x805797F0 end:0x805797F8 -d/d_text_writer.cpp: +d/d_textunk.cpp: + .text start:0x800B1890 end:0x800B20DC + .ctors start:0x804DB6D0 end:0x804DB6D4 + .data start:0x805108C8 end:0x805108D8 + .sdata start:0x805722D8 end:0x805722E0 + .sbss start:0x805753B0 end:0x805753B8 + .sdata2 start:0x805797F8 end:0x80579848 + .bss start:0x805A6F70 end:0x805A7730 + +d/d_tag_processor.cpp: .text start:0x800B35C0 end:0x800B9274 .ctors start:0x804DB6D4 end:0x804DB6D8 + .rodata start:0x804E4C34 end:0x804E4C50 + .data start:0x805108E8 end:0x805109A0 + .sdata2 start:0x8057986C end:0x805798D0 + .bss start:0x805A7730 end:0x805A78B8 toBeSorted/time_area_mgr.cpp: .text start:0x800B9280 end:0x800BB2A0 @@ -347,8 +360,11 @@ d/lyt/d_lyt_msg_window_select_btn.cpp: .text start:0x8011C8D0 end:0x80120988 .ctors start:0x804DB73C end:0x804DB740 +d/lyt/d_lyt_msg_window_base.cpp: + .text start:0x80120A20 end:0x80120A98 + d/lyt/d_lyt_msg_window_talk.cpp: - .text start:0x80120A20 end:0x801223C8 + .text start:0x80120AA0 end:0x801223C8 .ctors start:0x804DB740 end:0x804DB744 d/lyt/d_lyt_msg_window_link.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 9d424c41..3338776c 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -3783,7 +3783,7 @@ syncAnmFrame__Q23d2d14AnmGroupBase_cFv = .text:0x800AC910; // type:function size setForward__Q23d2d14AnmGroupBase_cFv = .text:0x800AC920; // type:function size:0x14 setBackward__Q23d2d14AnmGroupBase_cFv = .text:0x800AC940; // type:function size:0x14 fn_800AC960 = .text:0x800AC960; // type:function size:0x4C -init__Q23d2d9AnmGroupsFPQ23d2d10AnmGroup_cPQ23d2d15LytBrlanMappingUlPQ23m2d10ResAccIf_cPQ23d2d8Layout_c = .text:0x800AC9B0; // type:function size:0x80 +init__Q23d2d9AnmGroupsFPQ23d2d10AnmGroup_cPCQ23d2d15LytBrlanMappingUlPQ23m2d10ResAccIf_cPQ23d2d8Layout_c = .text:0x800AC9B0; // type:function size:0x80 remove__Q23d2d9AnmGroupsFv = .text:0x800ACA30; // type:function size:0x64 draw__Q23d2d9LytBase_cFv = .text:0x800ACAA0; // type:function size:0x18 fn_800ACAC0 = .text:0x800ACAC0; // type:function size:0x5C @@ -3868,25 +3868,25 @@ UpdateSize__9dWindow_cFP10dTextBox_cf = .text:0x800B1670; // type:function size: GetRuntimeTypeInfo__Q34nw4r3lyt6WindowCFv = .text:0x800B17B0; // type:function size:0x8 scope:weak __dt__9dWindow_cFv = .text:0x800B17C0; // type:function size:0x58 __dt__Q34nw4r3lyt19ArcResourceAccessorFv = .text:0x800B1820; // type:function size:0x6C scope:weak -fn_800B1890 = .text:0x800B1890; // type:function size:0x40 -fn_800B18D0 = .text:0x800B18D0; // type:function size:0x4D4 -fn_800B1DB0 = .text:0x800B1DB0; // type:function size:0x15C -fn_800B1F10 = .text:0x800B1F10; // type:function size:0x34 -fn_800B1F50 = .text:0x800B1F50; // type:function size:0x8 -fn_800B1F60 = .text:0x800B1F60; // type:function size:0x4 -fn_800B1F70 = .text:0x800B1F70; // type:function size:0x4C -fn_800B1FC0 = .text:0x800B1FC0; // type:function size:0x8 -fn_800B1FD0 = .text:0x800B1FD0; // type:function size:0x8 -fn_800B1FE0 = .text:0x800B1FE0; // type:function size:0x8 -fn_800B1FF0 = .text:0x800B1FF0; // type:function size:0x8 -fn_800B2000 = .text:0x800B2000; // type:function size:0x8 -fn_800B2010 = .text:0x800B2010; // type:function size:0x8 -fn_800B2020 = .text:0x800B2020; // type:function size:0x8 -fn_800B2030 = .text:0x800B2030; // type:function size:0x8 -fn_800B2040 = .text:0x800B2040; // type:function size:0x8 -fn_800B2050 = .text:0x800B2050; // type:function size:0x40 -fn_800B2090 = .text:0x800B2090; // type:function size:0x40 -fn_800B20D0 = .text:0x800B20D0; // type:function size:0xC +__dt__12UnkTextThingFv = .text:0x800B1890; // type:function size:0x40 +__ct__12UnkTextThingFv = .text:0x800B18D0; // type:function size:0x4D4 +destroy__12UnkTextThingFv = .text:0x800B1DB0; // type:function size:0x15C +fn_800B1F10__12UnkTextThingFv = .text:0x800B1F10; // type:function size:0x34 +allocUnk__12UnkTextThingFUli = .text:0x800B1F50; // type:function size:0x8 +destroyUnk__12UnkTextThingFPv = .text:0x800B1F60; // type:function size:0x4 +fn_800B1F70__12UnkTextThingFv = .text:0x800B1F70; // type:function size:0x4C +fn_800B1FC0__12UnkTextThingFv = .text:0x800B1FC0; // type:function size:0x8 +fn_800B1FD0__12UnkTextThingFv = .text:0x800B1FD0; // type:function size:0x8 +fn_800B1FE0__12UnkTextThingFv = .text:0x800B1FE0; // type:function size:0x8 +fn_800B1FF0__12UnkTextThingFv = .text:0x800B1FF0; // type:function size:0x8 +fn_800B2000__12UnkTextThingFv = .text:0x800B2000; // type:function size:0x8 +fn_800B2010__12UnkTextThingFv = .text:0x800B2010; // type:function size:0x8 +fn_800B2020__12UnkTextThingFv = .text:0x800B2020; // type:function size:0x8 +fn_800B2030__12UnkTextThingFv = .text:0x800B2030; // type:function size:0x8 +fn_800B2040__12UnkTextThingFv = .text:0x800B2040; // type:function size:0x8 +destroyMsg__12UnkTextThingFP8MsbtInfo = .text:0x800B2050; // type:function size:0x40 +destroyFlow__12UnkTextThingFP8MsbfInfo = .text:0x800B2090; // type:function size:0x40 +__sinit_\d_textunk_cpp = .text:0x800B20D0; // type:function size:0xC scope:local LytMsgWindowUnk__ctor = .text:0x800B20E0; // type:function size:0x48 fn_800B2130 = .text:0x800B2130; // type:function size:0x370 textAdvancingRelated = .text:0x800B24A0; // type:function size:0x5FC @@ -3900,69 +3900,69 @@ fn_800B32E0 = .text:0x800B32E0; // type:function size:0x84 drawTextBlur = .text:0x800B3370; // type:function size:0x138 fn_800B34B0 = .text:0x800B34B0; // type:function size:0x40 fn_800B34F0 = .text:0x800B34F0; // type:function size:0xD0 -TextManager__ctor = .text:0x800B35C0; // type:function size:0x260 -fn_800B3820 = .text:0x800B3820; // type:function size:0x58 +__ct__15dTagProcessor_cFv = .text:0x800B35C0; // type:function size:0x260 +__dt__15dTagProcessor_cFv = .text:0x800B3820; // type:function size:0x58 fn_800B3880 = .text:0x800B3880; // type:function size:0x8C -eventFlowTextProcessingRelated = .text:0x800B3910; // type:function size:0x980 +eventFlowTextProcessingRelated__15dTagProcessor_cFP10dTextBox_cPCwPwUlPUl = .text:0x800B3910; // type:function size:0x980 fn_800B4290 = .text:0x800B4290; // type:function size:0x5AC -TextManager__Process = .text:0x800B4840; // type:function size:0x10 -TextManager__CalcRect = .text:0x800B4850; // type:function size:0x4 -TextManager__ProcessTags = .text:0x800B4860; // type:function size:0x78C -fn_800B4FF0 = .text:0x800B4FF0; // type:function size:0x274 -TextManager__setColor = .text:0x800B5270; // type:function size:0x214 -TextManager__setScale = .text:0x800B5490; // type:function size:0x5C -TextManager__setFramesLeftOnPause = .text:0x800B54F0; // type:function size:0xC -fn_800B5500 = .text:0x800B5500; // type:function size:0x18 -fn_800B5520 = .text:0x800B5520; // type:function size:0x14 -fn_800B5540 = .text:0x800B5540; // type:function size:0x28 -fn_800B5570 = .text:0x800B5570; // type:function size:0x110 -fn_800B5680 = .text:0x800B5680; // type:function size:0x1DC -fn_800B5860 = .text:0x800B5860; // type:function size:0x1C0 -fn_800B5A20 = .text:0x800B5A20; // type:function size:0x3AC -fn_800B5DD0 = .text:0x800B5DD0; // type:function size:0x1FC -fn_800B5FD0 = .text:0x800B5FD0; // type:function size:0x10C -fn_800B60E0 = .text:0x800B60E0; // type:function size:0x24 -fn_800B6110 = .text:0x800B6110; // type:function size:0x24 -fn_800B6140 = .text:0x800B6140; // type:function size:0x14 -fn_800B6160 = .text:0x800B6160; // type:function size:0x8 -fn_800B6170 = .text:0x800B6170; // type:function size:0x14 -fn_800B6190 = .text:0x800B6190; // type:function size:0x1C -fn_800B61B0 = .text:0x800B61B0; // type:function size:0x18 -fn_800B61D0 = .text:0x800B61D0; // type:function size:0x64 -TextManager__changeScale = .text:0x800B6240; // type:function size:0xDC -fn_800B6320 = .text:0x800B6320; // type:function size:0x12C -fn_800B6450 = .text:0x800B6450; // type:function size:0x340 +Process__15dTagProcessor_cFUsPQ34nw4r2ut15PrintContext = .text:0x800B4840; // type:function size:0x10 +CalcRect__15dTagProcessor_cFPQ34nw4r2ut4RectUsPQ34nw4r2ut15PrintContext = .text:0x800B4850; // type:function size:0x4 +ProcessTags__15dTagProcessor_cFPQ34nw4r2ut4RectUsPQ34nw4r2ut15PrintContext = .text:0x800B4860; // type:function size:0x78C +fn_800B4FF0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = .text:0x800B4FF0; // type:function size:0x274 +setColor__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = .text:0x800B5270; // type:function size:0x214 +setScale__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = .text:0x800B5490; // type:function size:0x5C +setFramesLeftOnPause__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = .text:0x800B54F0; // type:function size:0xC +fn_800B5500__15dTagProcessor_cFUcPw = .text:0x800B5500; // type:function size:0x18 +fn_800B5520__15dTagProcessor_cFPw = .text:0x800B5520; // type:function size:0x14 +fn_800B5540__15dTagProcessor_cFPw = .text:0x800B5540; // type:function size:0x28 +writeHeroname__15dTagProcessor_cFPwPll = .text:0x800B5570; // type:function size:0x110 +writeItem__15dTagProcessor_cFPwPwPll = .text:0x800B5680; // type:function size:0x1DC +writeStringArg__15dTagProcessor_cFPwPwPll = .text:0x800B5860; // type:function size:0x1C0 +writeNumericArg__15dTagProcessor_cFPwPwPll = .text:0x800B5A20; // type:function size:0x3AC +fn_800B5DD0__15dTagProcessor_cFPwPwPll = .text:0x800B5DD0; // type:function size:0x1FC +fn_800B5FD0__15dTagProcessor_cFUlPwPl = .text:0x800B5FD0; // type:function size:0x10C +fn_800B60E0__15dTagProcessor_cFUcPw = .text:0x800B60E0; // type:function size:0x24 +fn_800B6110__15dTagProcessor_cFUcPw = .text:0x800B6110; // type:function size:0x24 +fn_800B6140__15dTagProcessor_cFUcPw = .text:0x800B6140; // type:function size:0x14 +playSound__15dTagProcessor_cFUcPw = .text:0x800B6160; // type:function size:0x8 +fn_800B6170__15dTagProcessor_cFUcPw = .text:0x800B6170; // type:function size:0x14 +fn_800B6190__15dTagProcessor_cFUcPw = .text:0x800B6190; // type:function size:0x1C +fn_800B61B0__15dTagProcessor_cFUcPw = .text:0x800B61B0; // type:function size:0x18 +fn_800B61D0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = .text:0x800B61D0; // type:function size:0x64 +changeScale__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextb = .text:0x800B6240; // type:function size:0xDC +writeIcon__15dTagProcessor_cFP10dTextBox_cPwf = .text:0x800B6320; // type:function size:0x12C +fn_800B6450__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = .text:0x800B6450; // type:function size:0x340 fn_800B6790 = .text:0x800B6790; // type:function size:0x750 -fn_800B6EE0 = .text:0x800B6EE0; // type:function size:0x1E8 +makeSpaceForIconMaybe__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextPw = .text:0x800B6EE0; // type:function size:0x1E8 fn_800B70D0 = .text:0x800B70D0; // type:function size:0x3A4 somethingWithScrapperAndMusic = .text:0x800B7480; // type:function size:0xB8 -fn_800B7540 = .text:0x800B7540; // type:function size:0x250 -fn_800B7790 = .text:0x800B7790; // type:function size:0xD8 -symbolToFontIdx = .text:0x800B7870; // type:function size:0x10 +restoreColor__15dTagProcessor_cFPQ34nw4r2ut15PrintContextUc = .text:0x800B7540; // type:function size:0x250 +writeTextNormal__15dTagProcessor_cFPCwPwPlUcl = .text:0x800B7790; // type:function size:0xD8 +symbolToFontIdx__15dTagProcessor_cFl = .text:0x800B7870; // type:function size:0x10 fn_800B7880 = .text:0x800B7880; // type:function size:0x210 fn_800B7A90 = .text:0x800B7A90; // type:function size:0x9C fn_800B7B30 = .text:0x800B7B30; // type:function size:0x46C -TextManager__setStringArg = .text:0x800B7FA0; // type:function size:0xA0 -fn_800B8040 = .text:0x800B8040; // type:function size:0x1F0 +setStringArg__15dTagProcessor_cFPCwl = .text:0x800B7FA0; // type:function size:0xA0 +fn_800B8040__15dTagProcessor_cFScUl = .text:0x800B8040; // type:function size:0x1F0 fn_800B8230 = .text:0x800B8230; // type:function size:0x10C fn_800B8340 = .text:0x800B8340; // type:function size:0x18C fn_800B84D0 = .text:0x800B84D0; // type:function size:0x8C fn_800B8560 = .text:0x800B8560; // type:function size:0x54 fn_800B85C0 = .text:0x800B85C0; // type:function size:0x290 -fn_800B8850 = .text:0x800B8850; // type:function size:0x38 -TextManager__getTextCommands = .text:0x800B8890; // type:function size:0x38 -TextManager__process0xFCommand = .text:0x800B88D0; // type:function size:0xC -fn_800B88E0 = .text:0x800B88E0; // type:function size:0x30 -fn_800B8910 = .text:0x800B8910; // type:function size:0x1C -fn_800B8930 = .text:0x800B8930; // type:function size:0x30 -fn_800B8960 = .text:0x800B8960; // type:function size:0xD8 -fn_800B8A40 = .text:0x800B8A40; // type:function size:0x10 -TextManager__setNumericArg0 = .text:0x800B8A50; // type:function size:0xC -TextManager__setNumericArgs = .text:0x800B8A60; // type:function size:0xDC +getNumLines__15dTagProcessor_cFl = .text:0x800B8850; // type:function size:0x38 +getTextCommand__15dTagProcessor_cFwPCwPUcPlPPw = .text:0x800B8890; // type:function size:0x38 +process0xFCommand__15dTagProcessor_cFwPCwPl = .text:0x800B88D0; // type:function size:0xC +tick0x830__15dTagProcessor_cFv = .text:0x800B88E0; // type:function size:0x30 +resetSomething__15dTagProcessor_cFv = .text:0x800B8910; // type:function size:0x1C +tickPauseFrame__15dTagProcessor_cFv = .text:0x800B8930; // type:function size:0x30 +resetSomeFloats__15dTagProcessor_cFv = .text:0x800B8960; // type:function size:0xD8 +getFloat__15dTagProcessor_cFl = .text:0x800B8A40; // type:function size:0x10 +setNumericArg0__15dTagProcessor_cFl = .text:0x800B8A50; // type:function size:0xC +setNumericArgs__15dTagProcessor_cFPCll = .text:0x800B8A60; // type:function size:0xDC fn_800B8B40 = .text:0x800B8B40; // type:function size:0x4C fn_800B8B90 = .text:0x800B8B90; // type:function size:0x4C fn_800B8BE0 = .text:0x800B8BE0; // type:function size:0x34 -TextManager__sinit = .text:0x800B8C20; // type:function size:0x654 +__sinit_\d_tag_processor_cpp = .text:0x800B8C20; // type:function size:0x654 scope:local __ct__14dTimeAreaMgr_cFv = .text:0x800B9280; // type:function size:0xF0 __dt__19dTimeAreaMgrProcA_cFv = .text:0x800B9370; // type:function size:0x58 __dt__19dTimeAreaMgrProcB_cFv = .text:0x800B93D0; // type:function size:0x58 @@ -30989,12 +30989,12 @@ lbl_8051078C = .data:0x8051078C; // type:object size:0xC lbl_80510798 = .data:0x80510798; // type:object size:0x88 __vt__9dWindow_c = .data:0x80510820; // type:object size:0x8C __vt__Q23d2d10ResAccIf_c = .data:0x805108B0; // type:object size:0x18 -lbl_805108C8 = .data:0x805108C8; // type:object size:0x10 +__vt__12UnkTextThing = .data:0x805108C8; // type:object size:0xC lbl_805108D8 = .data:0x805108D8; // type:object size:0x10 lbl_805108E8 = .data:0x805108E8; // type:object size:0x10 lbl_805108F8 = .data:0x805108F8; // type:object size:0x14 data:string jumptable_8051090C = .data:0x8051090C; // type:object size:0x80 scope:local -lbl_8051098C = .data:0x8051098C; // type:object size:0x14 +__vt__15dTagProcessor_c = .data:0x8051098C; // type:object size:0x14 lbl_805109A0 = .data:0x805109A0; // type:object size:0x20 lbl_805109C0 = .data:0x805109C0; // type:object size:0x20 lbl_805109E0 = .data:0x805109E0; // type:object size:0x88 @@ -37965,7 +37965,7 @@ lbl_805722BC = .sdata:0x805722BC; // type:object size:0x4 lbl_805722C0 = .sdata:0x805722C0; // type:object size:0x4 data:wstring lbl_805722C4 = .sdata:0x805722C4; // type:object size:0x8 lbl_805722CC = .sdata:0x805722CC; // type:object size:0xC -lbl_805722D8 = .sdata:0x805722D8; // type:object size:0x8 +lbl_805722D8 = .sdata:0x805722D8; // type:object size:0x1 lbl_805722E0 = .sdata:0x805722E0; // type:object size:0x8 lbl_805722E8 = .sdata:0x805722E8; // type:object size:0x8 lbl_805722F0 = .sdata:0x805722F0; // type:object size:0x4 data:4byte @@ -39932,7 +39932,7 @@ lbl_80575398 = .sbss:0x80575398; // type:object size:0x8 data:byte SCRAPPER_PICKUP_TARGET = .sbss:0x805753A0; // type:object size:0x8 data:4byte lbl_805753A8 = .sbss:0x805753A8; // type:object size:0x1 data:byte lbl_805753AC = .sbss:0x805753AC; // type:object size:0x4 data:4byte -lbl_805753B0 = .sbss:0x805753B0; // type:object size:0x8 data:4byte +sInstance__12UnkTextThing = .sbss:0x805753B0; // type:object size:0x4 data:4byte lbl_805753B8 = .sbss:0x805753B8; // type:object size:0x1 data:byte lbl_805753BC = .sbss:0x805753BC; // type:object size:0x4 data:4byte sInstance__14dTimeAreaMgr_c = .sbss:0x805753C0; // type:object size:0x4 data:4byte @@ -48338,7 +48338,7 @@ lbl_805A6340 = .bss:0x805A6340; // type:object size:0x30 data:4byte eventFlowTextStringMaybe1 = .bss:0x805A6370; // type:object size:0x400 eventFlowTextStringMaybe2 = .bss:0x805A6770; // type:object size:0x400 eventFlowTextStringMaybe3 = .bss:0x805A6B70; // type:object size:0x400 -eventFlowTextStringMaybe4 = .bss:0x805A6F70; // type:object size:0x7C0 +textThing = .bss:0x805A6F70; // type:object size:0x7C0 FontColors1 = .bss:0x805A7730; // type:object size:0xC4 data:byte FontColors2 = .bss:0x805A77F4; // type:object size:0xC4 data:byte lbl_805A78B8 = .bss:0x805A78B8; // type:object size:0xC diff --git a/configure.py b/configure.py index 1a158930..8d264269 100644 --- a/configure.py +++ b/configure.py @@ -365,6 +365,8 @@ config.libs = [ Object(NonMatching, "d/lyt/d2d.cpp"), Object(NonMatching, "d/lyt/d_textbox.cpp"), Object(Matching, "d/lyt/d_window.cpp"), + Object(Matching, "d/d_textunk.cpp"), + Object(NonMatching, "d/d_tag_processor.cpp"), Object(NonMatching, "d/lyt/meter/d_lyt_meter.cpp"), Object(NonMatching, "d/lyt/meter/d_lyt_meter_unk.cpp"), Object(NonMatching, "d/lyt/meter/d_lyt_meter_a_btn.cpp"), diff --git a/include/d/d_tag_processor.h b/include/d/d_tag_processor.h new file mode 100644 index 00000000..c68ad2f1 --- /dev/null +++ b/include/d/d_tag_processor.h @@ -0,0 +1,148 @@ +#ifndef D_TAG_PROCESSOR_H +#define D_TAG_PROCESSOR_H + +#include "d/lyt/d_textbox.h" +#include "nw4r/ut/ut_TagProcessorBase.h" +#include "nw4r/ut/ut_TextWriterBase.h" + +// inofficial name +// size: 0xEF4 +class dTagProcessor_c : public nw4r::ut::TagProcessorBase { +public: + dTagProcessor_c(); + virtual ~dTagProcessor_c(); + + void + eventFlowTextProcessingRelated(dTextBox_c *textBox, const wchar_t *src, wchar_t *dest, u32 destLen, u32 *pOutLen); + + virtual nw4r::ut::Operation Process(u16 ch, nw4r::ut::PrintContext *ctx) override; + virtual nw4r::ut::Operation CalcRect(nw4r::ut::Rect *rect, u16 ch, nw4r::ut::PrintContext *ctx) override; + + nw4r::ut::Operation ProcessTags(nw4r::ut::Rect *rect, u16 ch, nw4r::ut::PrintContext *ctx); + + void changeScale(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, bool); + wchar_t *writeItem(wchar_t *dest, wchar_t *src, s32 *, s32); + wchar_t *writeStringArg(wchar_t *dest, wchar_t *src, s32 *, s32); + wchar_t *writeNumericArg(wchar_t *dest, wchar_t *src, s32 *, s32); + void fn_800B4FF0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *ptr); + void fn_800B6450(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *ptr); + void makeSpaceForIconMaybe(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, wchar_t *ptr); + void fn_800B61D0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *ptr); + void setFramesLeftOnPause(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *ptr); + void fn_800B5500(u8 cmdLen, wchar_t *ptr); + void fn_800B5540(wchar_t *ptr); + void fn_800B60E0(u8 cmdLen, wchar_t *ptr); + void fn_800B6110(u8 cmdLen, wchar_t *ptr); + void fn_800B6140(u8 cmdLen, wchar_t *ptr); + void playSound(u8 cmdLen, wchar_t *ptr); + void fn_800B6170(u8 cmdLen, wchar_t *ptr); + void fn_800B6190(u8 cmdLen, wchar_t *ptr); + void fn_800B61B0(u8 cmdLen, wchar_t *ptr); + void setColor(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *ptr); + void restoreColor(nw4r::ut::PrintContext *ctx, u8 windowType); + void setScale(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *ptr); + + u8 symbolToFontIdx(s32 s); + void setStringArg(const wchar_t *arg, s32 index); + + static s32 getNumLines(s32 arg); + + static void getTextCommand(wchar_t _0xe, const wchar_t *src, u8 *outCmdLen, s32 *outCmd, wchar_t **outEndPtr); + static void process0xFCommand(wchar_t _0xf, const wchar_t *src, s32 *outCmd); + + static f32 fn_800B8040(s8, u32); + wchar_t *fn_800B5FD0(u32, wchar_t *, s32 *); + wchar_t *writeTextNormal(const wchar_t *src, wchar_t *dest, s32 *, u8 cmdLen, s32); + wchar_t *writeHeroname(wchar_t *dest, s32 *, s32); + wchar_t *fn_800B5DD0(wchar_t *dest, wchar_t *src, s32 *, s32); + void fn_800B5520(wchar_t *src); + void writeIcon(dTextBox_c *textBox, wchar_t *cmd, f32); + char fn_800B7880(u32); + void fn_800B70D0(nw4r::ut::TextWriterBase *, nw4r::ut::PrintContext *ctx, u16 c, s32); + + void resetSomething(); + void resetSomeFloats(); + void setNumericArg0(s32 arg); + void setNumericArgs(const s32 *args, s32 numArgs); + f32 getFloat(s32 i); + s32 tickPauseFrame(); + s32 tick0x830(); + +private: + /* 0x004 */ dTextBox_c *field_0x004; + /* 0x008 */ wchar_t field_0x008[4][256]; + /* 0x808 */ wchar_t field_0x808[4]; + /* 0x810 */ f32 field_0x810; + /* 0x814 */ f32 field_0x814; + /* 0x818 */ f32 field_0x818; + /* 0x81C */ s32 field_0x81C; + /* 0x820 */ s32 field_0x820; + /* 0x824 */ s32 field_0x824; + /* 0x828 */ s32 field_0x828; + /* 0x82C */ s32 field_0x82C; + /* 0x830 */ s32 field_0x830; + /* 0x834 */ s32 mPauseFramesLeft; + /* 0x838 */ s32 field_0x838; + /* 0x83C */ s32 field_0x83C; + /* 0x840 */ s32 field_0x840; + /* 0x844 */ s32 field_0x844; + /* 0x848 */ s32 field_0x848; + /* 0x84C */ s32 field_0x84C; + /* 0x850 */ s32 field_0x850; + /* 0x854 */ s32 field_0x854; + /* 0x858 */ s32 field_0x858; + /* 0x85C */ s32 field_0x85C; + /* 0x860 */ s32 field_0x860; + /* 0x864 */ s32 field_0x864; + /* 0x868 */ s32 field_0x868; + /* 0x86C */ s32 field_0x86C; + /* 0x870 */ s32 field_0x870; + /* 0x874 */ s32 field_0x874; + /* 0x878 */ s32 field_0x878; + /* 0x87C */ s32 field_0x87C; + /* 0x880 */ s32 field_0x880; + /* 0x884 */ s32 field_0x884; + /* 0x888 */ s32 field_0x888; + /* 0x88C */ s32 field_0x88C; + /* 0x890 */ s32 field_0x890; + /* 0x894 */ s32 field_0x894; + /* 0x898 */ s32 field_0x898; + /* 0x89C */ s32 mNumericArgs[10]; + /* 0x8C4 */ s32 mNumericArgsCopy[10]; + /* 0x8EC */ s32 field_0x8EC; + /* 0x8EC */ s32 field_0x8F0; + /* 0x8F4 */ s32 field_0x8F4; + /* 0x8F8 */ s32 field_0x8F8; + /* 0x8FC */ s32 field_0x8FC; + /* 0x900 */ s32 field_0x900; + /* 0x904 */ f32 field_0x904; + /* 0x908 */ f32 field_0x908; + /* 0x90C */ u8 field_0x90C; + /* 0x90D */ u8 field_0x90D; + /* 0x90E */ u8 field_0x90E; + /* 0x90F */ u8 field_0x90F[4]; + /* 0x914 */ f32 field_0x914[0x32]; + /* 0x9DC */ s32 mCommandInsert; + /* 0x9E0 */ wchar_t mStringArgs[8][64]; + /* 0xDE0 */ u8 field_0xDE0[0xEE0 - 0xDE0]; + /* 0xEE0 */ u8 field_0xEE0; + /* 0xEE1 */ u8 field_0xEE1; + /* 0xEE2 */ u8 field_0xEE2; + /* 0xEE3 */ u8 field_0xEE3; + /* 0xEE4 */ u8 field_0xEE4; + /* 0xEE5 */ u8 field_0xEE5; + /* 0xEE6 */ u8 field_0xEE6; + /* 0xEE7 */ u8 field_0xEE7; + /* 0xEE8 */ u8 field_0xEE8; + /* 0xEE9 */ u8 field_0xEE9; + /* 0xEEA */ u8 field_0xEEA; + /* 0xEEB */ u8 field_0xEEB; + /* 0xEEC */ u8 field_0xEEC; + /* 0xEED */ u8 field_0xEED; + /* 0xEEE */ u8 field_0xEEE; + /* 0xEEF */ u8 field_0xEEF; + /* 0xEF0 */ u8 field_0xEF0; + /* 0xEF1 */ u8 field_0xEF1; +}; + +#endif diff --git a/include/d/d_textunk.h b/include/d/d_textunk.h new file mode 100644 index 00000000..3860c81b --- /dev/null +++ b/include/d/d_textunk.h @@ -0,0 +1,118 @@ +#ifndef D_TEXTUNK_H +#define D_TEXTUNK_H + +#include "common.h" +#include "libms/flowfile.h" +#include "libms/msgfile.h" +#include "nw4r/ut/ut_Color.h" +#include "sized_string.h" + +class UnkTextThing { +public: + UnkTextThing(); + virtual ~UnkTextThing() {} + + void destroy(); + + inline static f32 getField0x758() { + if (sInstance != nullptr) { + return sInstance->field_0x758; + } + return 0.0f; + } + + inline static f32 getField0x768() { + if (sInstance != nullptr) { + return sInstance->field_0x768; + } + return 0.0f; + } + + inline static f32 getField0x76C() { + if (sInstance != nullptr) { + return sInstance->field_0x76C; + } + return 0.0f; + } + + inline static f32 getFn800B1F70() { + if (sInstance != nullptr) { + return sInstance->fn_800B1F70(); + } + return 1.0f; + } + + inline static f32 getFn800B1F10() { + return sInstance->fn_800B1F10(); + } + +private: + static UnkTextThing *sInstance; + + void *allocUnk(size_t size, int align); + void destroyUnk(void *thing); + void destroyFlow(MsbfInfo *flow); + void destroyMsg(MsbtInfo *msg); + + f32 fn_800B1F10(); + f32 fn_800B1F70(); + f32 fn_800B1FC0(); + f32 fn_800B1FD0(); + f32 fn_800B1FE0(); + f32 fn_800B1FF0(); + f32 fn_800B2000(); + f32 fn_800B2010(); + f32 fn_800B2020(); + f32 fn_800B2030(); + f32 fn_800B2040(); + + /* 0x004 */ SizedString<0x80> field_0x004; + /* 0x084 */ SizedString<0x80> field_0x084; + /* 0x104 */ SizedString<0x80> field_0x104; + /* 0x184 */ void *field_buf0[82]; + /* 0x2CC */ void *field_buf4[23]; + /* 0x328 */ void *field_buf1[80]; + /* 0x468 */ MsbtInfo *field_buf2[82]; + /* 0x5B0 */ MsbtInfo *field_buf5[23]; + /* 0x60C */ MsbfInfo *field_buf3[80]; + /* 0x74C */ void *field_0x74C; + /* 0x750 */ void *field_0x750; + /* 0x754 */ f32 field_0x754; + /* 0x758 */ f32 field_0x758; + /* 0x75C */ f32 field_0x75C; + /* 0x760 */ f32 field_0x760; + /* 0x764 */ f32 field_0x764; + /* 0x768 */ f32 field_0x768; + /* 0x76C */ f32 field_0x76C; + /* 0x770 */ f32 field_0x770; + /* 0x774 */ f32 field_0x774; + /* 0x778 */ f32 field_0x778; + /* 0x77C */ f32 field_0x77C; + /* 0x780 */ f32 field_0x780; + /* 0x784 */ f32 field_0x784; + /* 0x788 */ f32 field_0x788; + /* 0x78C */ f32 field_0x78C; + /* 0x790 */ f32 field_0x790; + /* 0x794 */ s16 field_0x794; + /* 0x796 */ s16 field_0x796; + /* 0x798 */ UNKWORD field_0x798; + /* 0x79C */ UNKWORD field_0x79C; + /* 0x7A0 */ UNKWORD field_0x7A0; + /* 0x7A4 */ s16 field_0x7A4; + /* 0x7A6 */ s16 field_0x7A6; + /* 0x7A8 */ s16 field_0x7A8; + /* 0x7AA */ s16 field_0x7AA; + /* 0x7AC */ s16 field_0x7AC; + /* 0x7AE */ s16 field_0x7AE; + /* 0x7B0 */ s16 field_0x7B0; + /* 0x7B2 */ bool field_0x7B2; + /* 0x7B3 */ bool field_0x7B3; + /* 0x7B4 */ bool field_0x7B4; + /* 0x7B5 */ bool field_0x7B5; + /* 0x7B6 */ bool field_0x7B6; + /* 0x7B6 */ bool field_0x7B7; + /* 0x7B8 */ nw4r::ut::Color field_0x7B8; + /* 0x7BC */ nw4r::ut::Color field_0x7BC; +}; + +#endif diff --git a/include/d/lyt/d_textbox.h b/include/d/lyt/d_textbox.h index 768cd1ed..653aafb3 100644 --- a/include/d/lyt/d_textbox.h +++ b/include/d/lyt/d_textbox.h @@ -27,6 +27,14 @@ public: nw4r::lyt::TextBox::SetScale(value); } + void set0x1F8(u8 val) { + field_0x1F8 = val; + } + + f32 getMyScale() const { + return mScale; + } + static inline f32 GetTranslateX1() { if (lbl_805753B0 != nullptr) { return GetTranslateX1_(); @@ -46,11 +54,13 @@ public: private: void MySetScale(const nw4r::math::VEC2 &value); - d2d::LytBase_c *mpLytBase; - u8 field_0x108[0x118 - 0x108]; + /* 0x104 */ d2d::LytBase_c *mpLytBase; + /* 0x108 */ u8 field_0x108[0x118 - 0x108]; /* 0x118 */ nw4r::math::VEC2 mTextScale; /* 0x120 */ f32 mScale; - u8 field_0x124[0x204 - 0x124]; + /* 0x124 */ u8 field_0x124[0x1F8 - 0x124]; + /* 0x1F8 */ u8 field_0x1F8; + /* 0x1F9 */ u8 field_0x1F9[0x204 - 0x1F9]; }; #endif diff --git a/include/libms/commonlib.h b/include/libms/commonlib.h index b99702b6..13e8bcc1 100644 --- a/include/libms/commonlib.h +++ b/include/libms/commonlib.h @@ -1,3 +1,6 @@ +#ifndef LIBMS_COMMONLIB_H +#define LIBMS_COMMONLIB_H + #include "common.h" #ifdef __cplusplus @@ -49,3 +52,5 @@ int LMSi_GetHashTableIndexFromLabel(const char *label, int tableSize); #ifdef __cplusplus } #endif + +#endif diff --git a/include/libms/flowfile.h b/include/libms/flowfile.h index a017cf1d..9bc47790 100644 --- a/include/libms/flowfile.h +++ b/include/libms/flowfile.h @@ -1,3 +1,6 @@ +#ifndef LIBMS_FLOWFILE_H +#define LIBMS_FLOWFILE_H + #include "common.h" #ifdef __cplusplus @@ -28,3 +31,5 @@ const unsigned short *LMS_GetBranchPoints(struct MsbfInfo *info, int index); #ifdef __cplusplus } #endif + +#endif diff --git a/include/libms/libms.h b/include/libms/libms.h index a83faed3..86345e16 100644 --- a/include/libms/libms.h +++ b/include/libms/libms.h @@ -1,3 +1,6 @@ +#ifndef LIBMS_LIBMS_H +#define LIBMS_LIBMS_H + #include "common.h" #ifdef __cplusplus @@ -15,3 +18,5 @@ void LMSi_MemCopy(char *p1, const char *p2, int n); #ifdef __cplusplus } #endif + +#endif diff --git a/include/libms/msgfile.h b/include/libms/msgfile.h index c866e0f7..50121699 100644 --- a/include/libms/msgfile.h +++ b/include/libms/msgfile.h @@ -1,3 +1,6 @@ +#ifndef LIBMS_MSGFILE_H +#define LIBMS_MSGFILE_H + #include "common.h" #ifdef __cplusplus @@ -22,3 +25,5 @@ struct MsbtAttrInfo *LMS_GetAttribute(struct MsbtInfo *info, int index); #ifdef __cplusplus } #endif + +#endif diff --git a/include/nw4r/lyt/lyt_pane.h b/include/nw4r/lyt/lyt_pane.h index a711b1b0..2e1d63ae 100644 --- a/include/nw4r/lyt/lyt_pane.h +++ b/include/nw4r/lyt/lyt_pane.h @@ -84,6 +84,10 @@ public: mAlpha = value; } + u8 GetGlobalAlpha() const { + return mGlbAlpha; + } + const Size &GetSize() const { return mSize; } diff --git a/src/d/d_tag_processor.cpp b/src/d/d_tag_processor.cpp new file mode 100644 index 00000000..eccf7481 --- /dev/null +++ b/src/d/d_tag_processor.cpp @@ -0,0 +1,1061 @@ +#include "d/d_tag_processor.h" + +#include "common.h" +#include "d/d_font_manager.h" +#include "d/d_textunk.h" +#include "nw4r/lyt/lyt_types.h" +#include "nw4r/ut/ut_CharWriter.h" +#include "nw4r/ut/ut_Color.h" +#include "nw4r/ut/ut_Font.h" +#include "nw4r/ut/ut_Rect.h" +#include "nw4r/ut/ut_TagProcessorBase.h" +#include "nw4r/ut/ut_TextWriterBase.h" +#include "sized_string.h" +#include "toBeSorted/file_manager.h" + +#include + +nw4r::ut::Color FontColors1[] = { + nw4r::ut::Color(0xff, 0x4b, 0x32, 0xff), + nw4r::ut::Color(0xff, 0x4b, 0x32, 0xff), + nw4r::ut::Color(0xfa, 0xaf, 0x05, 0xff), + nw4r::ut::Color(0xdc, 0xf5, 0xfa, 0xff), + nw4r::ut::Color(0x91, 0xff, 0x6e, 0xff), + nw4r::ut::Color(0xff, 0xbe, 0x1e, 0xff), + nw4r::ut::Color(0xeb, 0xc8, 0xff, 0xff), + nw4r::ut::Color(0x14, 0xd7, 0x46, 0xff), + nw4r::ut::Color(0x19, 0xa5, 0xeb, 0xff), + nw4r::ut::Color(0xf0, 0x3c, 0x1e, 0xff), + nw4r::ut::Color(0xc8, 0xc8, 0xc8, 0xff), + nw4r::ut::Color(0xfa, 0xaf, 0x05, 0xff), + nw4r::ut::Color(0x32, 0x23, 0x46, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(0xed, 0xe2, 0xd0, 0xff), + nw4r::ut::Color(0xf6, 0xf6, 0xde, 0xff), + nw4r::ut::Color(0xe6, 0xe6, 0xa0, 0xff), + nw4r::ut::Color(0xe8, 0xad, 0x55, 0xff), + nw4r::ut::Color(0xff, 0xfa, 0xe6, 0xff), + nw4r::ut::Color(0xf5, 0xf2, 0xeb, 0xff), + nw4r::ut::Color(0x64, 0x5f, 0x69, 0xff), + nw4r::ut::Color(0x5e, 0x51, 0x46, 0xff), + nw4r::ut::Color(0xed, 0xe2, 0xd0, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(0xfa, 0xf6, 0xe7, 0xff), + nw4r::ut::Color(0xff, 0xff, 0xff, 0xff), + nw4r::ut::Color(0x4c, 0x32, 0x0f, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(), + nw4r::ut::Color(), + nw4r::ut::Color(0xed, 0xe2, 0xd0, 0xff), + nw4r::ut::Color(0xed, 0xe2, 0xd0, 0xff), + nw4r::ut::Color(0xed, 0xe2, 0xd0, 0xff), + nw4r::ut::Color(0xed, 0xe2, 0xd0, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(0xf6, 0xf2, 0xea, 0xff), + nw4r::ut::Color(0xed, 0xe2, 0xd0, 0xff), + nw4r::ut::Color(0xed, 0xe2, 0xd0, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(), + nw4r::ut::Color(0xff, 0xff, 0xff, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(0xed, 0xe2, 0xd0, 0xff), + nw4r::ut::Color(0x20, 0x20, 0x20, 0xff), + nw4r::ut::Color(0x74, 0x6d, 0x5c, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(), + nw4r::ut::Color(), + nw4r::ut::Color(), +}; + +nw4r::ut::Color FontColors2[] = { + nw4r::ut::Color(0xff, 0x4b, 0x32, 0xff), + nw4r::ut::Color(0xcd, 0x4b, 0x32, 0xff), + nw4r::ut::Color(0xff, 0xe6, 0x8c, 0xff), + nw4r::ut::Color(0x7d, 0xc3, 0xff, 0xff), + nw4r::ut::Color(0x64, 0xc8, 0x41, 0xff), + nw4r::ut::Color(0xff, 0xbe, 0x1e, 0xff), + nw4r::ut::Color(0x91, 0x5f, 0xff, 0xff), + nw4r::ut::Color(0xaf, 0xe6, 0x2d, 0xff), + nw4r::ut::Color(0xb4, 0xe6, 0xff, 0xff), + nw4r::ut::Color(0xff, 0x91, 0x78, 0xff), + nw4r::ut::Color(0xe6, 0xe6, 0xc8, 0xff), + nw4r::ut::Color(0xff, 0xe6, 0x8c, 0xff), + nw4r::ut::Color(0x50, 0x4b, 0x5f, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(0xca, 0xaf, 0x81, 0xff), + nw4r::ut::Color(0xe7, 0xd7, 0xed, 0xff), + nw4r::ut::Color(0xa5, 0x96, 0x6e, 0xff), + nw4r::ut::Color(0xb5, 0x52, 0x2e, 0xff), + nw4r::ut::Color(0xff, 0xfa, 0xe6, 0xff), + nw4r::ut::Color(0xe1, 0xc8, 0x9b, 0xff), + nw4r::ut::Color(0x55, 0x50, 0x5a, 0xff), + nw4r::ut::Color(0x35, 0x2d, 0x27, 0xff), + nw4r::ut::Color(0xca, 0xaf, 0x81, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(0xe3, 0xcc, 0x8f, 0xff), + nw4r::ut::Color(0xff, 0xff, 0xff, 0xff), + nw4r::ut::Color(0x3a, 0x25, 0x09, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(), + nw4r::ut::Color(), + nw4r::ut::Color(0xca, 0xaf, 0x81, 0xff), + nw4r::ut::Color(0xca, 0xaf, 0x81, 0xff), + nw4r::ut::Color(0xca, 0xaf, 0x81, 0xff), + nw4r::ut::Color(0xca, 0xaf, 0x81, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(0xe1, 0xc7, 0x9b, 0xff), + nw4r::ut::Color(0xca, 0xaf, 0x81, 0xff), + nw4r::ut::Color(0xca, 0xaf, 0x81, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(), + nw4r::ut::Color(0xff, 0xff, 0xff, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(0xca, 0xaf, 0x81, 0xff), + nw4r::ut::Color(0x20, 0x20, 0x20, 0xff), + nw4r::ut::Color(0x4b, 0x47, 0x3f, 0xff), + nw4r::ut::Color(), + nw4r::ut::Color(), + nw4r::ut::Color(), + nw4r::ut::Color(), +}; + +dTagProcessor_c::dTagProcessor_c() { + field_0x82C = -1; + field_0x828 = -1; + field_0x90E = 0; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 256; j++) { + field_0x008[i][j] = 0; + } + field_0x808[i] = 0; + field_0x90F[i] = 0; + } + + field_0x904 = 0.0f; + field_0x908 = 0.0f; + resetSomething(); + field_0x830 = -1; + mPauseFramesLeft = 0; + field_0x838 = 0; + field_0x83C = 0; + field_0x840 = 0; + field_0x844 = 0; + field_0x848 = 0; + field_0x84C = 0; + field_0x850 = 0; + field_0x87C = 0; + field_0x854 = 0; + field_0x858 = 0; + field_0x85C = 0; + field_0x860 = 0; + field_0x880 = 0; + field_0x864 = 0; + field_0x868 = 0; + field_0x884 = 0; + field_0x86C = 0; + field_0x870 = 0; + field_0x894 = 0; + field_0x874 = 0; + field_0x878 = 0xffffffff; + field_0x898 = 0; + field_0x888 = 0; + field_0x88C = 0; + field_0x824 = 0; + field_0x890 = 0; + field_0x8FC = -1; + field_0x900 = -1; + resetSomeFloats(); + field_0x81C = 0; + field_0x820 = 0; + setNumericArg0(0); + mNumericArgsCopy[1] = 0; + mNumericArgsCopy[2] = 0; + mNumericArgsCopy[0] = 0; + mNumericArgsCopy[3] = 0; + mNumericArgsCopy[4] = 0; + mNumericArgsCopy[5] = 0; + mNumericArgsCopy[6] = 0; + mNumericArgsCopy[7] = 0; + mNumericArgsCopy[8] = 0; + mNumericArgsCopy[9] = 0; + field_0x8EC = 0; + field_0x8F0 = 0; + field_0x8F4 = 0; + field_0x8F8 = 0; + + field_0xEE5 = 0; + field_0xEE6 = 0; + field_0xEE7 = 0; + field_0xEE8 = 0; + field_0xEE9 = 0; + field_0xEEA = 0; + field_0xEEB = 0; + field_0xEEC = 0; + field_0xEED = 0; + field_0xEEE = 0; + field_0xEEF = 0; + field_0xEE0 = 0; + field_0xEE1 = 0; + field_0xEE2 = 0; + field_0xEE3 = 0; + field_0xEE4 = 0; + field_0x004 = nullptr; + field_0x90C = 0x24; + field_0x90D = 4; + field_0xEF0 = 0; + field_0xEF1 = 0; +} + +dTagProcessor_c::~dTagProcessor_c() {} + +struct StackThing { + wchar_t us[4]; +}; + +void dTagProcessor_c::eventFlowTextProcessingRelated( + dTextBox_c *textBox, const wchar_t *src, wchar_t *dest, u32 destLen, u32 *pOutLen +) { + s32 state3 = 0; + s32 state4 = 0; + + s32 state1 = -1; + s32 state2 = -1; + + // FPR regswap between float1 and float2 + f32 float1, float2; + float2 = float1 = fn_800B8040(0, field_0x90C); + + if (textBox != nullptr) { + float1 *= textBox->getMyScale(); + resetSomeFloats(); + textBox->set0x1F8(0); + } + + s32 local_b4 = 0; + + StackThing x = {0x000E, 0x0F0F, 0x0F0F, 0x0002}; + wchar_t *writePtr = dest; + if (textBox != nullptr) { + writePtr += 5; + dest[0] = x.us[0]; + dest[1] = x.us[1]; + dest[2] = x.us[2]; + dest[3] = x.us[3]; + dest[4] = mCommandInsert; + } + + StackThing yTmp; + StackThing y = {0x000E, 0x0F0F, 0x0F0E, 0x0001}; + + do { + wchar_t c = *src; + if (c == nullptr) { + if (textBox != nullptr) { + mCommandInsert++; + } + *writePtr = '\0'; + goto end; + } + + if (c == 0xE) { + u8 cmdLen = 0; + s32 cmd = 0; + wchar_t *endPtr = nullptr; + getTextCommand(c, src + 1, &cmdLen, &cmd, &endPtr); + bool bVar3 = false; + switch (cmd) { + case 0x0F0F0F0F: + if (state4 != 0 && field_0x90E != 0) { + const wchar_t *t = src; + u32 len = (cmdLen / 2) + 1; + for (int i = 0; i < len; i++) { + field_0x008[field_0x90E - 1][local_b4] = *(t++); + if (field_0x90E - 1 < 4) { + field_0x808[field_0x90E - 1]++; + } + local_b4++; + } + } else { + const wchar_t *t = src; + u32 len = (cmdLen / 2) + 1; + for (int i = 0; i < len; i++) { + *(writePtr++) = *(t++); + } + } + break; + case 0x10000: { + const u8 *endPtrU8 = (const u8 *)endPtr; + u8 a = endPtrU8[0]; + u8 b = endPtrU8[1]; + switch (a) { + case 0: state2 = 0; break; + case 1: state1 = 0; break; + } + field_0x90F[0] = b; + yTmp = y; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 256; j++) { + if (j < 4) { + field_0x008[i][j] = yTmp.us[j]; + } else { + field_0x008[i][j] = 0; + } + } + field_0x808[i] = 4; + } + state3 = 1; + bVar3 = true; + } break; + case 0x10001: { + const u8 *endPtrU8 = (const u8 *)endPtr; + u8 a = endPtrU8[0]; + u8 b = endPtrU8[1]; + switch (a) { + case 0: state2 = 1; break; + case 1: state1 = 1; break; + } + field_0x90F[1] = b; + state3 = 2; + bVar3 = true; + } break; + case 0x10002: { + const u8 *endPtrU8 = (const u8 *)endPtr; + u8 a = endPtrU8[0]; + u8 b = endPtrU8[1]; + switch (a) { + case 0: state2 = 2; break; + case 1: state1 = 2; break; + } + field_0x90F[2] = b; + state3 = 3; + bVar3 = true; + } break; + case 0x10003: { + const u8 *endPtrU8 = (const u8 *)endPtr; + u8 a = endPtrU8[0]; + u8 b = endPtrU8[1]; + switch (a) { + case 0: state2 = 3; break; + case 1: state1 = 3; break; + } + field_0x90F[3] = b; + state3 = 4; + bVar3 = true; + } break; + case 0x10008: + if (textBox != nullptr) { + float1 = fn_800B8040(((u8 *)endPtr)[0], field_0x90C); + float1 *= textBox->getMyScale(); + } + writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4); + break; + case 0x30000: { + if (textBox != nullptr) { + float2 = float1; + float1 *= UnkTextThing::getField0x768(); + float1 *= textBox->getMyScale(); + } + writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4); + } break; + case 0x10010: fn_800B5520(endPtr); break; + case 0x20004: + if (textBox != nullptr) { + writeIcon(textBox, endPtr, float1); + } + writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4); + break; + case 0x20000: writePtr = writeHeroname(writePtr, &local_b4, state4); break; + case 0x20001: writePtr = writeItem(writePtr, endPtr, &local_b4, state4); break; + case 0x20002: writePtr = writeStringArg(writePtr, endPtr, &local_b4, state4); break; + case 0x20003: writePtr = writeNumericArg(writePtr, endPtr, &local_b4, state4); break; + + case 0x30004: writePtr = fn_800B5DD0(writePtr, endPtr, &local_b4, state4); break; + case 0x30001: + field_0xEF1 = 1; + writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4); + break; + + default: writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4); break; + } + + if (bVar3) { + field_0x82C = state1; + state4 = 1; + field_0x828 = state2; + field_0x90E = state3; + local_b4 = field_0x808[state3 - 1]; + } + src += (cmdLen / 2) + 1; + } else if (c == 0xF) { + s32 tmp = 0; + process0xFCommand(c, src + 1, &tmp); + if (tmp == 0x30000) { + float1 = float2; + } + writePtr[0] = src[0]; + writePtr[1] = src[1]; + writePtr[2] = src[2]; + writePtr += 3; + src += 3; + } else if (state4 != 0 && field_0x90E != 0) { + // Note: Return ignored here + fn_800B5FD0(c, &field_0x008[field_0x90E - 1][local_b4], &local_b4); + src++; + // This looks like an inline tbh + if (field_0x90E - 1 < 4) { + field_0x808[field_0x90E - 1]++; + } + } else { + if (textBox != nullptr) { + if (c == 10) { + *writePtr = c; + src++; + writePtr++; + mCommandInsert++; + s32 i10 = getNumLines(field_0x90C); + if (mCommandInsert % i10 == 0) { + float1 = fn_800B8040(0, field_0x90C); + float1 *= textBox->getMyScale(); + } + if (textBox != nullptr) { + wchar_t *buf = (wchar_t *)&x; + writePtr[0] = buf[0]; + writePtr[1] = buf[1]; + writePtr[2] = buf[2]; + writePtr[3] = buf[3]; + writePtr[4] = mCommandInsert; + writePtr += 5; + } + } else { + const nw4r::ut::Font *fnt = textBox->GetFont(); + field_0x914[mCommandInsert] += float1 * fnt->GetCharWidth(*src) + textBox->GetCharSpace(); + writePtr = fn_800B5FD0(*src, writePtr, nullptr); + src++; + } + + } else { + writePtr = fn_800B5FD0(c, writePtr, nullptr); + src++; + } + } + + } while (destLen > writePtr - dest); + + dest[destLen - 1] = 0; +end: + if (pOutLen != nullptr) { + *pOutLen = writePtr - dest; + } +} + +nw4r::ut::Operation dTagProcessor_c::Process(u16 ch, nw4r::ut::PrintContext *ctx) { + return ProcessTags(nullptr, ch, ctx); +} + +nw4r::ut::Operation dTagProcessor_c::CalcRect(nw4r::ut::Rect *rect, u16 ch, nw4r::ut::PrintContext *ctx) { + return ProcessTags(rect, ch, ctx); +} + +nw4r::ut::Operation dTagProcessor_c::ProcessTags(nw4r::ut::Rect *rect, u16 ch, nw4r::ut::PrintContext *ctx) { + if (ch != 0x0E) { + if (ch != 0x0F) { + if (rect != nullptr) { + return nw4r::ut::TagProcessorBase::CalcRect(rect, ch, ctx); + } else { + return nw4r::ut::TagProcessorBase::Process(ch, ctx); + } + } else { + s32 cmd = 0; + process0xFCommand(ch, ctx->str, &cmd); + if (cmd == 0x30000) { + changeScale(rect, ctx, true); + } + ctx->str += 2; + return nw4r::ut::OPERATION_DEFAULT; + } + } + + u8 cmdLen = 0; + s32 cmd = 0; + wchar_t *endPtr = nullptr; + getTextCommand(ch, ctx->str, &cmdLen, &cmd, &endPtr); + switch (cmd) { + case 0x10000: + ctx->str += cmdLen / 2; + ctx->str += field_0x808[0]; + return nw4r::ut::OPERATION_DEFAULT; + case 0x10001: + ctx->str += cmdLen / 2; + ctx->str += field_0x808[1]; + return nw4r::ut::OPERATION_DEFAULT; + case 0x10002: + ctx->str += cmdLen / 2; + ctx->str += field_0x808[2]; + return nw4r::ut::OPERATION_DEFAULT; + case 0x10003: + ctx->str += cmdLen / 2; + ctx->str += field_0x808[3]; + return nw4r::ut::OPERATION_DEFAULT; + case 0x0F0F0F0F: fn_800B4FF0(rect, ctx, cmdLen, endPtr); break; + case 0x0F0F0F0E: field_0xEE2 = 1; break; + case 0x3: + if (field_0xEE1 == 0) { + setColor(rect, ctx, cmdLen, endPtr); + } + break; + case 0x2: setScale(rect, ctx, cmdLen, endPtr); break; + case 0x10004: + // Pause + if (rect == nullptr && field_0xEE1 == 0) { + if (field_0xEED == 0 && field_0x8F0 == field_0x838) { + setFramesLeftOnPause(rect, ctx, cmdLen, endPtr); + field_0xEED = 1; + field_0x838++; + } + field_0x8F0++; + } + break; + case 0x10005: + if (rect == nullptr && field_0xEE1 == 0) { + if (field_0xEEE == 0 && field_0x8F4 == field_0x83C) { + fn_800B5500(cmdLen, endPtr); + field_0xEEE = 1; + field_0x83C++; + } + field_0x8F4++; + } + break; + case 0x10007: + if (rect == nullptr && field_0xEE1 == 0) { + if (field_0xEE5 == 0 && mNumericArgsCopy[3] == field_0x87C) { + fn_800B60E0(cmdLen, endPtr); + field_0xEE5 = 1; + field_0x87C++; + } + mNumericArgsCopy[3]++; + } + break; + case 0x10008: fn_800B61D0(rect, ctx, cmdLen, endPtr); break; + case 0x30000: changeScale(rect, ctx, false); break; + case 0x10009: + if (rect == nullptr && field_0xEE1 == 0) { + if (field_0xEE6 == 0 && mNumericArgsCopy[4] == field_0x880) { + fn_800B6110(cmdLen, endPtr); + field_0xEE6 = 1; + field_0x880++; + } + mNumericArgsCopy[4]++; + } + break; + case 0x1000A: + if (rect == nullptr && field_0xEE1 == 0) { + if (field_0xEE7 == 0 && mNumericArgsCopy[5] == field_0x884) { + fn_800B6140(cmdLen, endPtr); + field_0xEE7 = 1; + field_0x884++; + } + mNumericArgsCopy[5]++; + } + break; + case 0x1000B: + // Sound + if (rect == nullptr && field_0xEE1 == 0) { + if (field_0xEE8 == 0 && mNumericArgsCopy[6] == field_0x888) { + playSound(cmdLen, endPtr); + field_0xEE8 = 1; + field_0x888++; + } + mNumericArgsCopy[6]++; + } + break; + case 0x1000C: + // "entrypoint" + if (rect == nullptr && field_0xEE1 == 0) { + if (field_0xEEA == 0 && mNumericArgsCopy[8] == field_0x890) { + fn_800B6170(cmdLen, endPtr); + field_0xEEA = 1; + field_0x890++; + } + mNumericArgsCopy[8]++; + } + break; + case 0x1000D: + if (rect == nullptr && field_0xEE1 == 0) { + if (field_0xEEB == 0 && mNumericArgsCopy[9] == field_0x894) { + fn_800B6190(cmdLen, endPtr); + field_0xEEB = 1; + field_0x894++; + } + mNumericArgsCopy[9]++; + } + break; + case 0x1000E: + if (rect == nullptr && field_0xEE1 == 0) { + if (field_0xEEC == 0 && field_0x8EC == field_0x898) { + fn_800B61B0(cmdLen, endPtr); + field_0xEEC = 1; + field_0x898++; + } + field_0x8EC++; + } + break; + case 0x20004: + if (field_0xEE3 != 0) { + if (rect == nullptr) { + fn_800B6450(rect, ctx, cmdLen, endPtr); + } else { + makeSpaceForIconMaybe(rect, ctx, endPtr); + } + } + break; + case 0x10011: + if (rect == nullptr && field_0xEE1 == 0) { + if (field_0xEEF == 0 && field_0x8F8 == field_0x840) { + fn_800B5540(endPtr); + field_0xEEF = 1; + field_0x840++; + } + field_0x8F8++; + } + break; + } + ctx->str += cmdLen / 2; + return nw4r::ut::OPERATION_DEFAULT; +} + +void dTagProcessor_c::fn_800B4FF0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *ptr) { + if (field_0x90C != 22 && field_0x90C != 30 && field_0xEE0 != 0) { + int arg = ptr[0]; + nw4r::lyt::Size textBoxSize = field_0x004->GetSize(); + nw4r::lyt::Size fontSize = field_0x004->GetFontSize(); + int i1 = getNumLines(field_0x90C); + if (arg % i1 == 0 && field_0x90C != 31 && field_0x90C != 8) { + int u = 0; + int v = 0; + for (int i = arg; i < arg + getNumLines(field_0x90C) && i < 0x32; i++) { + f32 f6 = getFloat(i); + if (f6 > 0.0f) { + v++; + if (u != 0) { + v += u; + u = 0; + } + } else { + u++; + } + } + + // Unfortunately, the code then proceeds to access + // some global text stuff at 0x805753b0, which is + // completely hidden in the Ghidra decompiler, apparently + // because the results aren't used? + + if (u < getNumLines(field_0x90C)) { + f32 w1 = fontSize.width * 0.5f; + f32 h1 = fontSize.height * 0.5f; + if (!(w1 < UnkTextThing::getField0x758())) { + w1 = UnkTextThing::getField0x758(); + } + if (!(h1 < UnkTextThing::getField0x758())) { + h1 = UnkTextThing::getField0x758(); + } + + f32 f7 = (fontSize.height + field_0x004->GetLineSpace()) * 0.5f * (getNumLines(field_0x90C) - v); + field_0x814 = ctx->writer->GetCursorY(); + field_0x818 = ctx->y; + field_0xEE4 = 1; + if (f7 > 0.0f) { + ctx->writer->SetCursorY(ctx->writer->GetCursorY() + f7); + field_0x810 = f7; + } + } + } + + f32 f7 = getFloat(arg); + f32 f8 = (textBoxSize.width - f7) * 0.5f; + if ((field_0x90C < 6 || field_0x90C >= 9) && field_0x90C != 30) { + f8 = 0.0f; + } + if (f8 > 0.0f) { + ctx->writer->SetCursorX(ctx->writer->GetCursorX() + f8); + } + } +} + +void dTagProcessor_c::setColor(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *buf) { + u16 cmd = buf[0]; + if (cmd == 0xFFFF) { + restoreColor(ctx, field_0x90C); + return; + } + nw4r::ut::Color c1 = FontColors1[cmd & 0xFFFF]; + nw4r::ut::Color c2 = FontColors2[cmd & 0xFFFF]; + if (cmd == 0) { + if (field_0x90C == 2) { + c1.r = 0xFF; + c1.g = 0x6E; + c1.b = 0x64; + c2.r = 0xFF; + c2.g = 0x6E; + c2.b = 0x64; + } else if (field_0x90C == 7) { + c1.r = 0xE6; + c1.g = 0x4B; + c1.b = 0x32; + c2.r = 0xE6; + c2.g = 0x4B; + c2.b = 0x32; + } + } else if (cmd == 1) { + if (field_0x90C == 2) { + c1.r = 0xF5; + c1.g = 0x64; + c1.b = 0x5A; + c2.r = 0xC8; + c2.g = 0x64; + c2.b = 0x5A; + } else if (field_0x90C == 7) { + c1.r = 0xB4; + c1.g = 0x50; + c1.b = 0x50; + c2.r = 0x8C; + c2.g = 0x40; + c2.b = 0x40; + } + } else if (cmd == 3 && field_0x90C >= 2 && field_0x90C < 5) { + c1.r = 0x50; + c1.g = 0xE6; + c1.b = 0xFA; + c2.r = 0xC8; + c2.g = 0xE6; + c2.b = 0xF5; + } + + u8 u5 = 0xFF; + if (field_0x004 != nullptr) { + u5 = field_0x004->GetGlobalAlpha(); + } + + c2.a = u5; + c1.a = u5; + ctx->writer->SetGradationMode(nw4r::ut::CharWriter::GRADMODE_V); + ctx->writer->SetTextColor(c1, c2); +} + +void dTagProcessor_c::setScale(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *buf) { + u16 scale = buf[0]; + if (scale == 0) { + scale = 50; + } + f32 x = scale / 100.0f; + f32 y = scale / 100.0f; + ctx->writer->SetScale(x, y); +} + +void dTagProcessor_c::setFramesLeftOnPause( + nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *ptr +) { + mPauseFramesLeft = ptr[0]; +} + +void dTagProcessor_c::fn_800B5500(u8 cmdLen, wchar_t *ptr) { + u16 val = ptr[0]; + if (field_0x830 == -1) { + field_0x830 = val; + } +} + +void dTagProcessor_c::fn_800B5520(wchar_t *src) { + field_0x81C = ((u32 *)src)[0]; + field_0x820 = ((u32 *)src)[1]; +} + +wchar_t *dTagProcessor_c::writeHeroname(wchar_t *dest, s32 *outArg, s32 arg) { + if (FileManager::sInstance->getHeroname()[0] != '\0') { + for (int i = 0; FileManager::sInstance->getHeroname()[i] != '\0'; i++) { + if (arg != 0 && field_0x90E != 0) { + wchar_t c = FileManager::sInstance->getHeroname()[i]; + fn_800B5FD0(c, &field_0x008[field_0x90E - 1][*outArg], outArg); + if (field_0x90E - 1 < 4) { + field_0x808[field_0x90E - 1]++; + } + } else { + dest = fn_800B5FD0(FileManager::sInstance->getHeroname()[i], dest, nullptr); + } + } + } + return dest; +} + +void dTagProcessorDataStuff() { + SizedString<32> s; + s.sprintf("NAME_ITEM_%03d"); + s.sprintf("lang:word:%03d:%02d"); +} + +void dTagProcessor_c::fn_800B60E0(u8 cmdLen, wchar_t *ptr) { + field_0x844 = *((u8 *)ptr); + field_0x848 = *((u8 *)ptr + 1); + field_0x84C = *((u8 *)ptr + 2); + field_0x850 = *((u8 *)ptr + 3); +} +void dTagProcessor_c::fn_800B6110(u8 cmdLen, wchar_t *ptr) { + field_0x854 = *((u8 *)ptr); + field_0x858 = *((u8 *)ptr + 1); + field_0x85C = *((u8 *)ptr + 2); + field_0x860 = *((u8 *)ptr + 3); +} +void dTagProcessor_c::fn_800B6140(u8 cmdLen, wchar_t *ptr) { + field_0x864 = ptr[0]; + field_0x868 = ptr[1]; +} +void dTagProcessor_c::playSound(u8 cmdLen, wchar_t *ptr) {} +void dTagProcessor_c::fn_800B6170(u8 cmdLen, wchar_t *ptr) { + field_0x8FC = ptr[0]; + field_0x900 = ptr[1]; +} +void dTagProcessor_c::fn_800B6190(u8 cmdLen, wchar_t *ptr) { + field_0x86C = *((char *)ptr); + field_0x870 = *((char *)ptr + 1); +} +void dTagProcessor_c::fn_800B61B0(u8 cmdLen, wchar_t *ptr) { + field_0x874 = *((char *)ptr); + field_0x878 = *((s16 *)((char *)ptr + 1)); +} + +void dTagProcessor_c::fn_800B61D0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, u8 cmdLen, wchar_t *ptr) { + f32 scale = fn_800B8040(*(char *)ptr, field_0x90C); + if (field_0x004 != nullptr) { + scale *= field_0x004->getMyScale(); + } + ctx->writer->SetScale(scale, scale); +} + +void dTagProcessor_c::changeScale(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, bool direct) { + f32 scale; + f32 posY; + + if (direct) { + scale = field_0x904; + posY = field_0x908; + } else { + field_0x904 = ctx->writer->GetScaleV(); + field_0x908 = ctx->writer->GetCursorY(); + scale = field_0x904 * UnkTextThing::getField0x768(); + posY = field_0x908 - ctx->writer->GetFontAscent() * UnkTextThing::getField0x76C(); + } + + ctx->writer->SetCursorY(posY); + ctx->writer->SetScale(scale, scale); +} + +void dTagProcessor_c::makeSpaceForIconMaybe(nw4r::ut::Rect *rect, nw4r::ut::PrintContext *ctx, wchar_t *ptr) { + nw4r::ut::Font *f = dFontMng_c::getFont(4); + u32 c3 = fn_800B7880(*(u8 *)ptr); + nw4r::ut::TextWriterBase copy = *ctx->writer; + f32 charWidth = f->GetCharWidth(c3); + fn_800B70D0(©, ctx, c3, 0xFF); + ctx->writer->MoveCursorX(charWidth * copy.GetScaleH()); + + f32 cursorX = ctx->writer->GetCursorX(); + rect->left = rect->left > cursorX ? cursorX : rect->left; + rect->right = rect->right < cursorX ? cursorX : rect->right; +} + +void dTagProcessor_c::restoreColor(nw4r::ut::PrintContext *ctx, u8 windowType) { + if (field_0xEE2 != 0) { + windowType = 1; + } + int colorIndex; + switch (windowType) { + case 2: colorIndex = 15; break; + case 3: colorIndex = 16; break; + case 4: colorIndex = 17; break; + case 5: colorIndex = 19; break; + case 6: colorIndex = 20; break; + case 7: colorIndex = 21; break; + case 8: colorIndex = 22; break; + case 9: colorIndex = 24; break; + case 11: colorIndex = 25; break; + case 12: colorIndex = 26; break; + case 13: colorIndex = 30; break; + case 17: colorIndex = 31; break; + case 18: colorIndex = 32; break; + case 19: colorIndex = 43; break; + case 20: colorIndex = 33; break; + case 22: colorIndex = 35; break; + case 23: colorIndex = 36; break; + case 24: colorIndex = 37; break; + case 27: colorIndex = 40; break; + case 29: colorIndex = 42; break; + case 30: colorIndex = 44; break; + case 31: colorIndex = 18; break; + default: colorIndex = 14; break; + } + + nw4r::ut::Color c1 = FontColors1[colorIndex & 0xFFFF]; + nw4r::ut::Color c2 = FontColors2[colorIndex & 0xFFFF]; + + if (windowType == 7) { + c2.a = 0xC8; + } else if (windowType == 12) { + c2.a = 0xFF; + } else if (windowType == 13) { + c2.a = 0xC8; + } + + u8 u5 = 0xFF; + if (field_0x004 != nullptr) { + u5 = field_0x004->GetGlobalAlpha(); + } + + c1.a = c1.a * u5 / 255.0f; + c2.a = c2.a * u5 / 255.0f; + ctx->writer->SetGradationMode(nw4r::ut::CharWriter::GRADMODE_V); + ctx->writer->SetTextColor(c1, c2); +} + +wchar_t *dTagProcessor_c::writeTextNormal(const wchar_t *src, wchar_t *dest, s32 *pArg, u8 cmdLen, s32 arg) { + if (arg != 0 && field_0x90E != 0) { + for (u32 i = 0; i < (cmdLen / 2 + 1); i++) { + field_0x008[field_0x90E - 1][*pArg] = *(src++); + if (field_0x90E - 1 < 4) { + field_0x808[field_0x90E - 1]++; + } + (*pArg)++; + } + } else { + memcpy(dest, src, cmdLen + 2); + dest += (cmdLen / 2 + 1); + } + + return dest; +} + +u8 dTagProcessor_c::symbolToFontIdx(s32 s) { + static const u8 alphabet[] = " !\"#$%&\'()*+,)+-/0123456789"; + return alphabet[s]; +} + +void dTagProcessor_c::setStringArg(const wchar_t *arg, s32 index) { + for (int i = 0; i < 0x40; i++) { + mStringArgs[index][i] = arg[i]; + } +} + +f32 dTagProcessor_c::fn_800B8040(s8 factor, u32 windowType) { + // Fun little recursion here + f32 f1 = UnkTextThing::getFn800B1F70(); + if (windowType == 6) { + f32 f2 = fn_800B8040(0, 0); + f32 f3 = fn_800B8040(factor, 0); + return f1 * ((f3 / f2) * 0.93f); + } else if (windowType == 7) { + f32 f2 = fn_800B8040(0, 0); + f32 f3 = fn_800B8040(factor, 0); + return f1 * ((f3 / f2) * 0.9f); + } else if (windowType == 9) { + f32 f2 = fn_800B8040(0, 0); + f32 f3 = fn_800B8040(factor, 0); + return f1 * ((f3 / f2) * 0.68f); + } else if (windowType == 30) { + f32 f2 = fn_800B8040(0, 0); + f32 f3 = fn_800B8040(factor, 0); + return f1 * ((f3 / f2) * 0.9f); + } else if (windowType == 34) { + f32 f2 = fn_800B8040(0, 0); + f32 f3 = fn_800B8040(factor, 0); + return f1 * ((f3 / f2) * 0.86f); + } else { + f32 x; + switch (factor) { + case -2: x = 0.55f; break; + case -1: x = 0.68f; break; + case -0: x = 0.8f; break; + case 1: x = 0.95f; break; + case 2: + x = 1.1f; + break; + // @bug: No default, so uninitialized is possible + } + x *= UnkTextThing::getFn800B1F10(); + return x * f1; + } +} + +s32 dTagProcessor_c::getNumLines(s32 arg) { + if (arg >= 6 && arg < 8) { + return 4; + } else if (arg == 9) { + return 2; + } else if (arg == 30) { + return 2; + } + return 4; +} + +void dTagProcessor_c::getTextCommand( + wchar_t _0xe, const wchar_t *src, u8 *outCmdLen, s32 *outCmd, wchar_t **outEndPtr +) { + *outCmdLen = src[2] + 6; + *outCmd = *(s32 *)src; + if (*outCmdLen > 6) { + *outEndPtr = (wchar_t *)src + 3; + } else { + *outEndPtr = nullptr; + } +} + +void dTagProcessor_c::process0xFCommand(wchar_t _0xf, const wchar_t *src, s32 *outCmd) { + *outCmd = *(s32 *)src; +} + +s32 dTagProcessor_c::tick0x830() { + if (field_0x830 >= 0) { + field_0x830--; + } + if (field_0x830 < -1) { + field_0x830 = -1; + } + return field_0x830; +} + +void dTagProcessor_c::resetSomething() { + field_0x810 = 0.0f; + field_0x818 = 0.0f; + field_0x814 = 0.0f; + field_0xEE4 = 0; +} + +s32 dTagProcessor_c::tickPauseFrame() { + if (mPauseFramesLeft > 0) { + mPauseFramesLeft--; + } + if (mPauseFramesLeft < 0) { + mPauseFramesLeft = 0; + } + return mPauseFramesLeft; +} + +void dTagProcessor_c::resetSomeFloats() { + for (int i = 0; i < 0x32; i++) { + field_0x914[i] = 0.0f; + } + mCommandInsert = 0; +} + +f32 dTagProcessor_c::getFloat(s32 i) { + return field_0x914[i]; +} + +void dTagProcessor_c::setNumericArg0(s32 arg) { + mNumericArgs[0] = arg; + mNumericArgsCopy[0] = arg; +} + +void dTagProcessor_c::setNumericArgs(const s32 *args, s32 numArgs) { + // Holy unrolling, Batman! + for (int i = 0; i < numArgs; i++) { + mNumericArgs[i] = args[i]; + } +} diff --git a/src/d/d_textunk.cpp b/src/d/d_textunk.cpp new file mode 100644 index 00000000..49cbc58f --- /dev/null +++ b/src/d/d_textunk.cpp @@ -0,0 +1,188 @@ +#include "d/d_textunk.h" + +#include "common.h" +#include "nw4r/ut/ut_Color.h" + +UnkTextThing textThing; +UnkTextThing *UnkTextThing::sInstance; + +// UnkTextThing::~UnkTextThing() {} +UnkTextThing::UnkTextThing() { + sInstance = this; + + field_0x754 = 0.0f; + field_0x758 = 12.0f; + field_0x75C = 0.04f; + field_0x760 = 0.22f; + field_0x764 = 42.0f; + field_0x768 = 0.8f; + field_0x76C = 0.3f; + + field_0x7B3 = false; + field_0x798 = 0; + field_0x79C = 0; + field_0x7A0 = 0; + + field_0x770 = 80.0f; + field_0x774 = 30.0f; + field_0x796 = 3; + field_0x778 = 10.0f; + field_0x780 = 8.0f; + field_0x77C = 8.0f; + field_0x784 = 6.0f; + + field_0x7A4 = 0xB6; + field_0x7A6 = 0x16C; + + for (int i = 0; i < 82; i++) { + field_buf0[i] = 0; + field_buf2[i] = 0; + } + + for (int i = 0; i < 23; i++) { + field_buf4[i] = 0; + field_buf5[i] = 0; + } + + for (int i = 0; i < 80; i++) { + field_buf1[i] = 0; + field_buf3[i] = 0; + } + + field_0x74C = 0; + field_0x750 = 0; + + field_0x7B4 = false; + field_0x7B5 = false; + + field_0x004 = ""; + field_0x084 = ""; + field_0x104 = ""; + + field_0x7B6 = 0; + + field_0x7A8 = 0; + field_0x788 = 0.45; + field_0x78C = -5.0f; + field_0x7AE = 4; + field_0x7B7 = 0; + field_0x7AA = 5; + field_0x7AC = 15; + field_0x7B0 = 0; + field_0x7B2 = false; + + // Weird init order + field_0x7B8.a = 0; + field_0x7B8.b = 0; + field_0x7B8.g = 0; + field_0x7B8.r = 0; + field_0x7BC.a = 0; + field_0x7BC.b = 0; + field_0x7BC.g = 0; + field_0x7BC.r = 0; + + field_0x790 = -1.0f; + field_0x794 = 100.0f; +} + +void UnkTextThing::destroy() { + for (int i = 0; i < 82; i++) { + if (field_buf0[i] != nullptr) { + destroyUnk(field_buf0[i]); + field_buf0[i] = nullptr; + } + + if (field_buf2[i] != nullptr) { + destroyMsg(field_buf2[i]); + field_buf2[i] = nullptr; + } + } + + for (int i = 0; i < 23; i++) { + if (field_buf4[i] != nullptr) { + destroyUnk(field_buf4[i]); + field_buf4[i] = nullptr; + } + + if (field_buf5[i] != nullptr) { + destroyMsg(field_buf5[i]); + field_buf5[i] = nullptr; + } + } + + for (int i = 0; i < 80; i++) { + if (field_buf1[i] != nullptr) { + destroyUnk(field_buf1[i]); + field_buf1[i] = nullptr; + } + + if (field_buf3[i] != nullptr) { + destroyFlow(field_buf3[i]); + field_buf3[i] = nullptr; + } + } + + if (field_0x74C != nullptr) { + destroyUnk(field_0x74C); + field_0x74C = nullptr; + } + + if (field_0x750 != nullptr) { + destroyUnk(field_0x750); + field_0x750 = nullptr; + } +} + +f32 UnkTextThing::fn_800B1F10() { + return field_0x794 / 100.0f; +} + +void *UnkTextThing::allocUnk(size_t size, int align) { + return nullptr; +} +void UnkTextThing::destroyUnk(void *_thing) {} + +f32 UnkTextThing::fn_800B1F70() { + f32 v = fn_800B1FC0(); + v *= fn_800B1FE0(); + return v; +} +f32 UnkTextThing::fn_800B1FC0() { + return 1.0f; +} +f32 UnkTextThing::fn_800B1FD0() { + return 0.9f; +} +f32 UnkTextThing::fn_800B1FE0() { + return 1.0f; +} +f32 UnkTextThing::fn_800B1FF0() { + return 0.0f; +} +f32 UnkTextThing::fn_800B2000() { + return 0.0f; +} +f32 UnkTextThing::fn_800B2010() { + return -1.0f; +} +f32 UnkTextThing::fn_800B2020() { + return 0.0f; +} +f32 UnkTextThing::fn_800B2030() { + return 0.0f; +} +f32 UnkTextThing::fn_800B2040() { + return 0.0f; +} + +void UnkTextThing::destroyMsg(MsbtInfo *msg) { + field_0x7B6 = true; + LMS_CloseMessage(msg); + field_0x7B6 = false; +} + +void UnkTextThing::destroyFlow(MsbfInfo *flow) { + field_0x7B6 = true; + LMS_CloseFlow(flow); + field_0x7B6 = false; +}