lsShowOneObject

decompiled_code:
__int64 __fastcall lsShowOneObject(__int64 a1, unsigned __int16 a2, unsigned __int16 a3, char a4)
{
unsigned __int16 v5; // r12
__int64 v8; // rax
__int64 v9; // r14
void *v11; // rdi

v5 = a2;
v8 = dbGetObject(*(unsigned int *)(a1 + 20));
if ( *(_DWORD *)(a1 + 20) == 9261 )
return 0LL;
v9 = v8;
if ( (a4 & 0x20) == 0
&& ((a4 & 1) == 0 || !(unsigned __int8)lsIsObjectAWall(a1))
&& ((a4 & 0x40) == 0 || !(unsigned __int8)lsIsObjectADoor(a1) || *(_BYTE *)(a1 + 11) != 1)
&& (a4 >= 0 || !(unsigned __int8)lsIsObjectSpecial(a1) || *(_BYTE *)(a1 + 11) != 1)
&& ((a4 & 2) == 0 || !(unsigned __int8)lsIsObjectAStdObj(a1) || *(_BYTE *)(a1 + 11) != 1)
&& ((a4 & 4) == 0 || !(unsigned __int8)lsIsObjectAnAddOn(a1) || *(_BYTE *)(a1 + 11) != 1) )
{
return 0LL;
}
v11 = lsPrepareFromMem_isra_0(*(_BYTE *)(a1 + 10));
if ( a2 == 0x8AD0 )
v5 = *(_WORD *)(a1 + 2);
if ( a3 == 0x8AD0 )
a3 = *(_WORD *)(a1 + 4);
lsBlitOneObject((__int64)v11, *(_WORD *)(v9 + 4) + (*(_WORD *)(a1 + 16) & 3), v5, a3, *(unsigned __int8 *)(v9 + 22));
lsSetAlarmPict(a1);
return 1LL;
}

original_code:
S32 lsShowOneObject(LSObject lso, word destx, word desty, U32 ul_Mode)
{
    Item item = dbGetObject(lso->Type);
    S32 show = 0;
    uword offsetFact;
    switch (lso->Type) {
    case 9261U:
 break;
    default:
 if (ul_Mode & 32)
     show = 1;
 if ((!show) && (ul_Mode & 1))
     if (lsIsObjectAWall(lso))
  show = 1;
 if ((!show) && (ul_Mode & 64))
     if (lsIsObjectADoor(lso) && lso->uch_Visible == ((ubyte) 1))
  show = 1;
 if ((!show) && (ul_Mode & 128))
     if (lsIsObjectSpecial(lso) && lso->uch_Visible == ((ubyte) 1))
  show = 1;
 if ((!show) && (ul_Mode & 2))
     if (lsIsObjectAStdObj(lso) && lso->uch_Visible == ((ubyte) 1))
  show = 1;
 if ((!show) && (ul_Mode & 4))
     if (lsIsObjectAnAddOn(lso) && lso->uch_Visible == ((ubyte) 1))
  show = 1;
 if (show) {
            MemRastPort *rp;
            rp = lsPrepareFromMem(lso);
     offsetFact = item->OffsetFact + (lso->ul_Status & 3);
     if (destx == -30000)
  destx = lso->us_DestX;
     if (desty == -30000)
  desty = lso->us_DestY;
     lsBlitOneObject(rp, offsetFact, destx, desty, item->Size);
 }
 break;
    }
    if (show)
 lsSetAlarmPict(lso);
    return show;
}

canonical_original_code:
int lsShowOneObject(struct _LSObject *lso, short destx, short desty, unsigned int ul_Mode)
{
    struct _Item *item = dbGetObject(lso->Type);
    int show = 0;
    unsigned short offsetFact;
    switch (lso->Type) {
    case 9261U:
 break;
    default:
 if (ul_Mode & 32)
     show = 1;
 if ((!show) && (ul_Mode & 1))
     if (lsIsObjectAWall(lso))
  show = 1;
 if ((!show) && (ul_Mode & 64))
     if (lsIsObjectADoor(lso) && lso->uch_Visible == ((unsigned char) 1))
  show = 1;
 if ((!show) && (ul_Mode & 128))
     if (lsIsObjectSpecial(lso) && lso->uch_Visible == ((unsigned char) 1))
  show = 1;
 if ((!show) && (ul_Mode & 2))
     if (lsIsObjectAStdObj(lso) && lso->uch_Visible == ((unsigned char) 1))
  show = 1;
 if ((!show) && (ul_Mode & 4))
     if (lsIsObjectAnAddOn(lso) && lso->uch_Visible == ((unsigned char) 1))
  show = 1;
 if (show) {
            struct _MemRastPort *rp;
            rp = lsPrepareFromMem(lso);
     offsetFact = item->OffsetFact + (lso->ul_Status & 3);
     if (destx == -30000)
  destx = lso->us_DestX;
     if (desty == -30000)
  desty = lso->us_DestY;
     lsBlitOneObject(rp, offsetFact, destx, desty, item->Size);
 }
 break;
    }
    if (show)
 lsSetAlarmPict(lso);
    return show;
}

variable_types: destx short

variable_types: desty short

variable_types: struct _Item { enum ItemE { Holztuer=0, Stahltuer=1, Ausstellungskasten=2, Kasse=3, Kasten=4, Schreibtisch=5, Nachtkaestchen=6, Wertschrank=7, Stahlschrank=8, Panzerschrank=9, Tresorraum=10, Mauer=11, Mauerecke=12, Steinmauer=13, Mauertor=14, Zaun=15, Zauntor=16, Saeule=17, Fenster=18, Alarmanlage_Z3=19, Alarmanlage_X3=20, Alarmanlage_Top=21, Mikrophon=22, Stechuhr=23, Scheinwerfer=24, Lichtschranke=25, Steuerkasten=26, Grab=27, Grabhuegel=28, Kreuz=29, Kranz=30, Gruft=31, Treppe=32, Sockel=33, WC=34, Sessel=35, Pult=36, Statue=37, Beutesack=38, Bett=39, Billardtisch=40, Sofa=41, Spiegel=42, Tisch=43, Kamin=44, Badewanne=45, Tresen=46, Gemaelde=47, Klavier=48, Buecherregal=49, Skelett=50, Dinosaurier=51, Elch=52, Kanone=53, Beefeater=54, Busch=55, Strauch=56, Gebuesch=57, Laubbaum=58, Nadelbaum=59, Hecke=60, Hantel=61, Regal=62, Flugzeugheck=63, linker_Flugzeugfluegel=64, rechter_Flugzeugfluegel=65, Bild=66, Vase=67, Kuehlschrank=68, Wache=69, Beichtstuhl=70, Kirchenbank=71, Altar=72, Kroehnungsstuhl=73, Opferkassa=74, Schrein=75, Kerzen=76, Weihwasserbecken=77, Heiligenstatue=78, Kerzenstaender=79, Kirchenkreuz=80, Gelaender=81, verzierte_Saeule=82, Regal_mit_Chemikalien=83, Versuchstisch=84, Kiste=85, Fasz=86, leere_Palette=87, Palette_mit_Schachteln=88, Absperrung=89, Hottentotten_Figur=90, Batman_Figur=91, Dicker_Man=92, Unbekannter=93, Jack_the_Ripper_Figur=94, Koenigs_Figur=95, Wache_Figur=96, Miss_World_1952=97, groszer_Koffer=98, Sitzbank=99, Speisetisch=100, Holzkiste=101, Palette_mit_Kisten=102, Postsack=103, Leiter=104, Zuggelaender=105, Lokomotive_vorne_rechts=106, Lokomotive_vorne_links=107, Lokomotive_oben=108, Lokomotive_seitlich=109, Lokomotive_Kabine=110, Lokomotive_Tuer=111 } Type; unsigned short OffsetFact; unsigned short HExactXOffset; unsigned short HExactYOffset; unsigned short HExactWidth; unsigned short HExactHeight; unsigned short VExactXOffset; unsigned short VExactYOffset; unsigned short VExactWidth; unsigned short VExactHeight; unsigned char Size; unsigned char ColorNr; } *

variable_types: show int

user_defined_types: struct _Item { enum ItemE Type; unsigned short OffsetFact; unsigned short HExactXOffset; unsigned short HExactYOffset; unsigned short HExactWidth; unsigned short HExactHeight; unsigned short VExactXOffset; unsigned short VExactYOffset; unsigned short VExactWidth; unsigned short VExactHeight; unsigned char Size; unsigned char ColorNr; }


lsRefreshClosedDoors

repo: vcosta/derclou

decompiled_code:
__int64 __fastcall lsRefreshClosedDoors(unsigned __int16 a1, unsigned __int16 a2, unsigned __int16 a3, unsigned __int16 a4)
{
__int64 result; // rax
_QWORD *v5; // r8
_QWORD *v6; // rbx
unsigned int v7; // er15
unsigned int v8; // er14
__int64 v9; // rbp

result = ls;
v5 = *(_QWORD **)(ls + 336LL);
*(_BYTE *)(ls + 407LL) = 64;
v6 = (_QWORD *)*v5;
if ( *(_QWORD *)*v5 )
{
v7 = a4;
v8 = a3;
do
{
while ( 1 )
{
v9 = v6[5];
if ( (unsigned __int8)lsIsInside(v9, a1, a2, v8, v7) )
{
if ( (unsigned __int8)lsIsObjectADoor(v9) && *(_BYTE *)(v9 + 11) == 1 )
break;
}
v6 = (_QWORD *)*v6;
if ( !*v6 )
goto LABEL_8;
}
lsShowOneObject(v9, 0x8AD0u, 0x8AD0u, 64);
v6 = (_QWORD *)*v6;
}
while ( *v6 );
LABEL_8:
result = ls;
}
*(_BYTE *)(result + 407) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int16 a1, unsigned __int16 a2, unsigned __int16 a3, unsigned __int16 a4)
{
__int64 result; // rax
_QWORD *v5; // r8
_QWORD *v6; // rbx
unsigned int v7; // er15
unsigned int v8; // er14
__int64 v9; // rbp

result = ls;
v5 = *(_QWORD **)(ls + 336LL);
*(_BYTE *)(ls + 407LL) = 64;
v6 = (_QWORD *)*v5;
if ( *(_QWORD *)*v5 )
{
v7 = a4;
v8 = a3;
do
{
while ( 1 )
{
v9 = v6[5];
if ( (unsigned __int8)lsIsInside(v9, a1, a2, v8, v7) )
{
if ( (unsigned __int8)lsIsObjectADoor(v9) && *(_BYTE *)(v9 + 11) == 1 )
break;
}
v6 = (_QWORD *)*v6;
if ( !*v6 )
goto LABEL_8;
}
func6(v9, 0x8AD0u, 0x8AD0u, 64);
v6 = (_QWORD *)*v6;
}
while ( *v6 );
LABEL_8:
result = ls;
}
*(_BYTE *)(result + 407) = 0;
return result;
}

original_code:
static void lsRefreshClosedDoors(uword us_X0, uword us_Y0,
                                 uword us_X1, uword us_Y1)
{
    NODE *node;
    ls->uch_ShowObjectMask = 0x40;
    for (node = (NODE *) ((((NODE *)((&((ls->p_ObjectRetrieval))->Head)))->Succ)); (((NODE *)(node))->Succ);
  node = (NODE *) (((NODE *)(node))->Succ)) {
 LSObject lso = (((struct ObjectNode *)node)->data);
 if (lsIsInside(lso, us_X0, us_Y0, us_X1, us_Y1))
     if (lsIsObjectADoor(lso))
  if (lso->uch_Visible == ((ubyte) 1))
      lsShowOneObject(lso, -30000, -30000,
        64);
    }
    ls->uch_ShowObjectMask = 0x0;
}

canonical_original_code:
static void lsRefreshClosedDoors(unsigned short us_X0, unsigned short us_Y0, unsigned short us_X1, unsigned short us_Y1)
{
    struct Node *node;
    ls->uch_ShowObjectMask = 0x40;
    for (node = (struct Node *) ((((struct Node *)((&((ls->p_ObjectRetrieval))->Head)))->Succ)); (((struct Node *)(node))->Succ);
  node = (struct Node *) (((struct Node *)(node))->Succ)) {
 struct _LSObject *lso = (((struct ObjectNode *)node)->data);
 if (lsIsInside(lso, us_X0, us_Y0, us_X1, us_Y1))
     if (lsIsObjectADoor(lso))
  if (lso->uch_Visible == ((unsigned char) 1))
      lsShowOneObject(lso, -30000, -30000,
        64);
    }
    ls->uch_ShowObjectMask = 0x0;
}

variable_types: struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } *

variable_types: struct _LSObject { unsigned short us_OffsetFact; unsigned short us_DestX; unsigned short us_DestY; unsigned char uch_ExactX; unsigned char uch_ExactY; unsigned char uch_ExactX1; unsigned char uch_ExactY1; unsigned char uch_Size; unsigned char uch_Visible; unsigned char uch_Chained; unsigned int ul_Status; unsigned int Type; } *

return_type: void


lsBlitFloor

decompiled_code:
__int64 __fastcall lsBlitFloor(unsigned __int16 a1, unsigned __int16 a2, unsigned __int16 a3)
{
return gfxLSPut(
&LSFloorRPInMem,
(32 * *(unsigned __int8 *)(*(_QWORD *)(ls + 288LL) + a1)) & 0x1E0,
0LL,
a2,
a3,
32LL,
32LL);
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned __int16 a1, unsigned __int16 a2, unsigned __int16 a3)
{
return gfxLSPut(
&LSFloorRPInMem,
(32 * *(unsigned __int8 *)(*(_QWORD *)(ls + 288LL) + a1)) & 0x1E0,
0LL,
a2,
a3,
32LL,
32LL);
}

original_code:
void lsBlitFloor(uword floorIndex, uword destx, uword desty)
{
    MemRastPort *rp = &LSFloorRPInMem;
    uword srcX;
    srcX =
 ((ls->p_CurrFloor[floorIndex].uch_FloorType) & 0xf) * 32;
    gfxLSPut(rp, srcX, 0, destx, desty, 32, 32);
}

canonical_original_code:
void lsBlitFloor(unsigned short floorIndex, unsigned short destx, unsigned short desty)
{
    struct _MemRastPort *rp = &LSFloorRPInMem;
    unsigned short srcX;
    srcX =
 ((ls->p_CurrFloor[floorIndex].uch_FloorType) & 0xf) * 32;
    gfxLSPut(rp, srcX, 0, destx, desty, 32, 32);
}

variable_types:
floorIndex
unsigned short

variable_types:
destx
unsigned short

variable_types:
desty
unsigned short

variable_types: struct _MemRastPort { unsigned short w; unsigned short h; unsigned char palette[768]; unsigned char *pixels; unsigned short collId; } *

variable_types:
srcX
unsigned short


lsSetViewPort

decompiled_code:
__int64 __fastcall lsSetViewPort(unsigned __int16 a1, unsigned __int16 a2)
{
return gfxNCH4SetViewPort(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned __int16 a1, unsigned __int16 a2)
{
return gfxNCH4SetViewPort(a1, a2);
}

original_code:
void lsSetViewPort(uword x, uword y)
{
    gfxNCH4SetViewPort(x, y);
}

canonical_original_code:
void lsSetViewPort(unsigned short x, unsigned short y)
{
    gfxNCH4SetViewPort(x, y);
}

variable_types:
x
unsigned short

variable_types:
y
unsigned short


lsInitGfx

decompiled_code:
__int64 lsInitGfx()
{
gfxSetVideoMode(2LL);
lsSetViewPort(0, 0);
return gfxNCH4SetSplit(256LL);
}

canonical_decompiled_code:
__int64 func11()
{
gfxSetVideoMode(2LL);
func10(0, 0);
return gfxNCH4SetSplit(256LL);
}

original_code:
void lsInitGfx(void)
{
    gfxSetVideoMode(2);
    lsSetViewPort(0, 0);
    gfxNCH4SetSplit(256);
}

canonical_original_code:
void lsInitGfx()
{
    gfxSetVideoMode(2);
    lsSetViewPort(0, 0);
    gfxNCH4SetSplit(256);
}


lsCloseGfx

decompiled_code:
__int64 lsCloseGfx()
{
gfxSetVideoMode(1LL);
tcSetPermanentColors();
return inpMousePtrOn();
}

canonical_decompiled_code:
__int64 func12()
{
gfxSetVideoMode(1LL);
tcSetPermanentColors();
return inpMousePtrOn();
}

original_code:
void lsCloseGfx(void)
{
    gfxSetVideoMode(1);
    tcSetPermanentColors();
    inpMousePtrOn();
}

canonical_original_code:
void lsCloseGfx()
{
    gfxSetVideoMode(1);
    tcSetPermanentColors();
    inpMousePtrOn();
}


lsScrollCorrectData

decompiled_code:
__int64 __fastcall lsScrollCorrectData(__int16 a1, __int16 a2)
{
_WORD *v2; // rax
__int16 v5; // di
__int16 v6; // si
unsigned __int16 v7; // di
unsigned __int16 v8; // si

v2 = (_WORD *)ls;
v5 = *(_WORD *)(ls + 14LL);
v6 = *(_WORD *)(ls + 16LL);
*(_WORD *)(ls + 396LL) = a1;
v2[199] = a2;
v7 = a1 + v5;
v8 = a2 + v6;
v2[7] = v7;
v2[8] = v8;
return livSetVisLScape(v7, v8);
}

original_code:
void lsScrollCorrectData(S32 dx, S32 dy)
{
    ls->us_WindowXPos += dx;
    ls->us_WindowYPos += dy;
    ls->us_RasInfoScrollX = (word) dx;
    ls->us_RasInfoScrollY = (word) dy;
    livSetVisLScape(ls->us_WindowXPos, ls->us_WindowYPos);
}

canonical_original_code:
void lsScrollCorrectData(int dx, int dy)
{
    ls->us_WindowXPos += dx;
    ls->us_WindowYPos += dy;
    ls->us_RasInfoScrollX = (short) dx;
    ls->us_RasInfoScrollY = (short) dy;
    livSetVisLScape(ls->us_WindowXPos, ls->us_WindowYPos);
}

variable_types: dx int

variable_types: dy int


lsDoScroll

decompiled_code:
__int64 lsDoScroll()
{
__int64 result; // rax

result = gfxNCH4Scroll((unsigned int)*(__int16 *)(ls + 396LL), (unsigned int)*(__int16 *)(ls + 398LL));
*(_DWORD *)(ls + 396LL) = 0;
return result;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 result; // rax

result = gfxNCH4Scroll((unsigned int)*(__int16 *)(ls + 396LL), (unsigned int)*(__int16 *)(ls + 398LL));
*(_DWORD *)(ls + 396LL) = 0;
return result;
}

original_code:
void lsDoScroll(void)
{
    gfxNCH4Scroll(ls->us_RasInfoScrollX, ls->us_RasInfoScrollY);
    ls->us_RasInfoScrollX = 0;
    ls->us_RasInfoScrollY = 0;
}

canonical_original_code:
void lsDoScroll()
{
    gfxNCH4Scroll(ls->us_RasInfoScrollX, ls->us_RasInfoScrollY);
    ls->us_RasInfoScrollX = 0;
    ls->us_RasInfoScrollY = 0;
}


DoneTaxi

decompiled_code:
__int64 DoneTaxi()
{
__int64 v0; // r12
__int64 v1; // r13
__int64 v2; // rax
__int64 v3; // rax
__int64 **i; // rbp
__int64 v5; // rsi
__int64 v6; // rax
__int64 v7; // rax
unsigned int v8; // er13
int v9; // eax
char v10; // si
__int64 v11; // rbp
__int64 v12; // rax
char v14[256]; // [rsp+0h] [rbp-228h] BYREF
char v15[296]; // [rsp+100h] [rbp-128h] BYREF

v0 = CreateList();
v1 = dbGetObject(9821LL);
v2 = dbGetObject(9801LL);
SetP(v2, 5LL, v1, 0xFFFFFFFFLL);
SetObjectListAttr(0LL, 9903LL);
v3 = dbGetObject(9801LL);
AskAll(v3, 16LL, &BuildObjectList);
for ( i = (__int64 **)*ObjectList; *i; *(_DWORD *)(v7 + 32) = v5 + 1 )
{
v5 = *(unsigned int *)i[5];
v6 = GetNthNode(*(_QWORD *)(film + 24LL), v5);
sprintf(v14, "*%s", *(const char **)(v6 + 16));
v7 = CreateNode(v0, 48LL, v14);
i = (__int64 **)*i;
}
v8 = (unsigned __int8)i_0;
v9 = GetNrOfNodes(v0);
v10 = i_0;
if ( v8 >= v9 - 1 )
v10 = GetNrOfNodes(v0) - 1;
i_0 = v10;
txtGetNthString(2LL, "NO_CHOICE", 0LL, v15);
ExpandObjectList(v0, v15);
v11 = (unsigned __int8)Bubble(v0, (unsigned __int8)i_0, 0LL, 0LL);
if ( (unsigned __int8)ChoiceOk(v11, 255LL, v0) )
{
i_0 = v11;
v12 = GetNthNode(v0, (unsigned int)v11);
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)GetLocScene((unsigned int)(*(_DWORD *)(v12 + 32) - 1));
}
else
{
Say(2LL, 0LL, 7LL, "LOVELY_TAXI");
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)GetLocScene(*(unsigned int *)(film + 56LL));
}
*((_BYTE *)&SceneArgs + 8) = 1;
SceneArgs = 0;
RemoveList(v0);
return gfxChangeColors(l_gc, 2LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // r12
__int64 v1; // r13
__int64 v2; // rax
__int64 v3; // rax
__int64 **i; // rbp
__int64 v5; // rsi
__int64 v6; // rax
__int64 v7; // rax
unsigned int v8; // er13
int v9; // eax
char v10; // si
__int64 v11; // rbp
__int64 v12; // rax
char v14[256]; // [rsp+0h] [rbp-228h] BYREF
char v15[296]; // [rsp+100h] [rbp-128h] BYREF

v0 = CreateList();
v1 = dbGetObject(9821LL);
v2 = dbGetObject(9801LL);
SetP(v2, 5LL, v1, 0xFFFFFFFFLL);
SetObjectListAttr(0LL, 9903LL);
v3 = dbGetObject(9801LL);
AskAll(v3, 16LL, &BuildObjectList);
for ( i = (__int64 **)*ObjectList; *i; *(_DWORD *)(v7 + 32) = v5 + 1 )
{
v5 = *(unsigned int *)i[5];
v6 = GetNthNode(*(_QWORD *)(film + 24LL), v5);
sprintf(v14, "*%s", *(const char **)(v6 + 16));
v7 = CreateNode(v0, 48LL, v14);
i = (__int64 **)*i;
}
v8 = (unsigned __int8)i_0;
v9 = GetNrOfNodes(v0);
v10 = i_0;
if ( v8 >= v9 - 1 )
v10 = GetNrOfNodes(v0) - 1;
i_0 = v10;
txtGetNthString(2LL, "NO_CHOICE", 0LL, v15);
ExpandObjectList(v0, v15);
v11 = (unsigned __int8)Bubble(v0, (unsigned __int8)i_0, 0LL, 0LL);
if ( (unsigned __int8)ChoiceOk(v11, 255LL, v0) )
{
i_0 = v11;
v12 = GetNthNode(v0, (unsigned int)v11);
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)GetLocScene((unsigned int)(*(_DWORD *)(v12 + 32) - 1));
}
else
{
Say(2LL, 0LL, 7LL, "LOVELY_TAXI");
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)GetLocScene(*(unsigned int *)(film + 56LL));
}
*((_BYTE *)&SceneArgs + 8) = 1;
SceneArgs = 0;
RemoveList(v0);
return gfxChangeColors(l_gc, 2LL, 4LL, 0LL);
}

original_code:
void DoneTaxi(void)
{
    static ubyte i = 0;
    ubyte j;
    char name[256], exp[256];
    LIST *locs = CreateList();
    struct ObjectNode *n, *new;
    U32 locNr;
    Location loc;
    SetP (dbGetObject (9801U), 5, dbGetObject (9821U), (4294967295U));
    { SetObjectListAttr ((0),9903L); AskAll (dbGetObject (9801U), 16, BuildObjectList); };
    for (n = (struct ObjectNode *) ((((NODE *)((&((ObjectList))->Head)))->Succ)); (((NODE *)(n))->Succ);
  n = (struct ObjectNode *) (((NODE *)(n))->Succ)) {
 loc = (((struct ObjectNode *)n)->data);
 locNr = ((Location) loc)->LocationNr;
 sprintf(name, "*%s", (((NODE *)(GetNthNode(film->loc_names, locNr)))->Name));
 new = (struct ObjectNode *) CreateNode(locs, sizeof(struct ObjectNode), name);
 new->nr = locNr + 1;
    }
    i = ((i) < (GetNrOfNodes(locs) - 1) ? (i) : (GetNrOfNodes(locs) - 1));
    (txtGetNthString(2U, "NO_CHOICE", 0, exp));
    ExpandObjectList(locs, exp);
    if (ChoiceOk(j = Bubble(locs, i, 0L, 0L), ((U8)-1), locs)) {
 i = j;
 locNr = (((struct ObjectNode *)GetNthNode(locs, i))->nr) - 1;
 SceneArgs.ReturnValue = (U32)GetLocScene(locNr)->EventNr;
    } else {
 Say(2U, 0, 7, "LOVELY_TAXI");
 SceneArgs.ReturnValue = (U32)GetLocScene((film->alter_Ort))->EventNr;
    }
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.Moeglichkeiten = 0L;
    RemoveList(locs);
    gfxChangeColors(l_gc, 2L, 4, 0L);
}

canonical_original_code:
void DoneTaxi()
{
    static unsigned char i = 0;
    unsigned char j;
    char name[256]; char exp[256];
    struct List *locs = CreateList();
    struct ObjectNode *n; struct ObjectNode *new;
    unsigned int locNr;
    struct _Location *loc;
    SetP (dbGetObject (9801U), 5, dbGetObject (9821U), (4294967295U));
    { SetObjectListAttr ((0),9903L); AskAll (dbGetObject (9801U), 16, BuildObjectList); };
    for (n = (struct ObjectNode *) ((((struct Node *)((&((ObjectList))->Head)))->Succ)); (((struct Node *)(n))->Succ);
  n = (struct ObjectNode *) (((struct Node *)(n))->Succ)) {
 loc = (((struct ObjectNode *)n)->data);
 locNr = ((struct _Location *) loc)->LocationNr;
 sprintf(name, "*%s", (((struct Node *)(GetNthNode(film->loc_names, locNr)))->Name));
 new = (struct ObjectNode *) CreateNode(locs, sizeof(struct ObjectNode), name);
 new->nr = locNr + 1;
    }
    i = ((i) < (GetNrOfNodes(locs) - 1) ? (i) : (GetNrOfNodes(locs) - 1));
    (txtGetNthString(2U, "NO_CHOICE", 0, exp));
    ExpandObjectList(locs, exp);
    if (ChoiceOk(j = Bubble(locs, i, 0L, 0L), ((U8)-1), locs)) {
 i = j;
 locNr = (((struct ObjectNode *)GetNthNode(locs, i))->nr) - 1;
 SceneArgs.ReturnValue = (unsigned int)GetLocScene(locNr)->EventNr;
    } else {
 Say(2U, 0, 7, "LOVELY_TAXI");
 SceneArgs.ReturnValue = (unsigned int)GetLocScene((film->alter_Ort))->EventNr;
    }
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.Moeglichkeiten = 0L;
    RemoveList(locs);
    gfxChangeColors(l_gc, 2L, 4, 0L);
}

variable_types:
i
unsigned char

variable_types:
j
unsigned char

variable_types:
name
char [256]

variable_types:
exp
char [256]

variable_types: struct List { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Head; struct Node Tail; } *

variable_types: struct ObjectNode { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Link; unsigned int nr; unsigned int type; void *data; } *

variable_types:
locNr
unsigned int

variable_types: struct _Location { unsigned int LocationNr; unsigned short OpenFromMinute; unsigned short OpenToMinute; } *

user_defined_types: struct ObjectNode { struct Node Link; unsigned int nr; unsigned int type; void *data; }

user_defined_types: struct List { struct Node Head; struct Node Tail; }


DoneInsideHouse

decompiled_code:
__int64 DoneInsideHouse()
{
__int64 v0; // rax
__int64 v1; // r13
unsigned int v2; // er12
__int64 v3; // rax
__int64 *i; // rbx
unsigned int v5; // ebp
unsigned __int8 v6; // bl
__int64 v7; // rax
unsigned int v8; // ebp
__int64 v9; // r14
int j; // edi
int v11; // er8
int v12; // eax
__int64 v13; // rdi
__int64 **k; // r12
unsigned int v16; // eax

v0 = txtGoKey(0LL, "Mainmenu");
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v1 = v0;
ShowMenuBackground();
v2 = GetObjNrOfBuilding((unsigned int)(*(_DWORD *)(film + 52LL) + 1));
SetObjectListAttr(0LL, 509992LL);
v3 = dbGetObject(v2);
AskAll(v3, 500002LL, &BuildObjectList);
for ( i = (__int64 *)*ObjectList; *i; i = (__int64 *)*i )
{
v5 = *((_DWORD *)i + 8);
lsInitRelations(v5);
lsInitObjectDB(v2, v5);
}
v6 = 0;
SetObjectListAttr(0LL, 509992LL);
v7 = dbGetObject(v2);
AskAll(v7, 500001LL, &BuildObjectList);
v8 = *(_DWORD *)(*ObjectList + 32LL);
lsLoadGlobalData(v2, v8);
lsSetRelations(v8);
v9 = *(unsigned __int8 *)(dbGetObject(v2) + 8);
lsShowRaster(v8, v9);
gfxShow(154LL, 6LL, 5LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
LABEL_4:
for ( j = *((_DWORD *)&SceneArgs + 1); ; j = *((_DWORD *)&SceneArgs + 1) )
{
v11 = SceneArgs;
if ( j )
break;
while ( 1 )
{
while ( !v11 )
;
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v6 = Menu(v1, SceneArgs, v6, 0LL, 0LL);
inpTurnFunctionKey(1LL);
inpTurnESC(1LL);
if ( !v6 )
break;
if ( v6 == 3 )
{
tcInsideOfHouse(v2, v8, (unsigned int)v9);
ShowMenuBackground();
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
AddVTime(19LL);
ShowTime(0LL);
j = *((_DWORD *)&SceneArgs + 1);
goto LABEL_4;
}
v12 = StdHandle((unsigned int)(1 << v6));
v11 = SceneArgs;
*((_DWORD *)&SceneArgs + 1) = v12;
if ( v12 )
goto LABEL_9;
}
v16 = tcGoInsideOfHouse(v2);
v8 = v16;
if ( v16 )
{
lsSetRelations(v16);
lsShowRaster(v8, (unsigned int)v9);
}
else
{
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)(**(_QWORD **)(GetCurrentScene() + 32) + 32LL);
}
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
}
LABEL_9:
SetObjectListAttr(0LL, 509992LL);
v13 = dbGetObject(v2);
AskAll(v13, 500002LL, &BuildObjectList);
for ( k = (__int64 **)*ObjectList; *k; k = (__int64 **)*k )
lsDoneObjectDB(*((unsigned int *)k + 8));
StopAnim();
gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
return RemoveList(v1);
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rax
__int64 v1; // r13
unsigned int v2; // er12
__int64 v3; // rax
__int64 *i; // rbx
unsigned int v5; // ebp
unsigned __int8 v6; // bl
__int64 v7; // rax
unsigned int v8; // ebp
__int64 v9; // r14
int j; // edi
int v11; // er8
int v12; // eax
__int64 v13; // rdi
__int64 **k; // r12
unsigned int v16; // eax

v0 = txtGoKey(0LL, "Mainmenu");
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v1 = v0;
ShowMenuBackground();
v2 = GetObjNrOfBuilding((unsigned int)(*(_DWORD *)(film + 52LL) + 1));
SetObjectListAttr(0LL, 509992LL);
v3 = dbGetObject(v2);
AskAll(v3, 500002LL, &BuildObjectList);
for ( i = (__int64 *)*ObjectList; *i; i = (__int64 *)*i )
{
v5 = *((_DWORD *)i + 8);
lsInitRelations(v5);
lsInitObjectDB(v2, v5);
}
v6 = 0;
SetObjectListAttr(0LL, 509992LL);
v7 = dbGetObject(v2);
AskAll(v7, 500001LL, &BuildObjectList);
v8 = *(_DWORD *)(*ObjectList + 32LL);
lsLoadGlobalData(v2, v8);
lsSetRelations(v8);
v9 = *(unsigned __int8 *)(dbGetObject(v2) + 8);
lsShowRaster(v8, v9);
gfxShow(154LL, 6LL, 5LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
LABEL_4:
for ( j = *((_DWORD *)&SceneArgs + 1); ; j = *((_DWORD *)&SceneArgs + 1) )
{
v11 = SceneArgs;
if ( j )
break;
while ( 1 )
{
while ( !v11 )
;
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v6 = Menu(v1, SceneArgs, v6, 0LL, 0LL);
inpTurnFunctionKey(1LL);
inpTurnESC(1LL);
if ( !v6 )
break;
if ( v6 == 3 )
{
tcInsideOfHouse(v2, v8, (unsigned int)v9);
ShowMenuBackground();
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
AddVTime(19LL);
ShowTime(0LL);
j = *((_DWORD *)&SceneArgs + 1);
goto LABEL_4;
}
v12 = StdHandle((unsigned int)(1 << v6));
v11 = SceneArgs;
*((_DWORD *)&SceneArgs + 1) = v12;
if ( v12 )
goto LABEL_9;
}
v16 = tcGoInsideOfHouse(v2);
v8 = v16;
if ( v16 )
{
lsSetRelations(v16);
lsShowRaster(v8, (unsigned int)v9);
}
else
{
*((_DWORD *)&SceneArgs + 1) = *(_DWORD *)(**(_QWORD **)(GetCurrentScene() + 32) + 32LL);
}
tcRefreshLocationInTitle(*(unsigned int *)(film + 52LL));
}
LABEL_9:
SetObjectListAttr(0LL, 509992LL);
v13 = dbGetObject(v2);
AskAll(v13, 500002LL, &BuildObjectList);
for ( k = (__int64 **)*ObjectList; *k; k = (__int64 **)*k )
lsDoneObjectDB(*((unsigned int *)k + 8));
StopAnim();
gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
return RemoveList(v1);
}

original_code:
void DoneInsideHouse(void)
{
    LIST *menu = txtGoKey(0U, "Mainmenu");
    U32 choice, buildingID, areaID;
    ubyte activ = 0, perc;
    NODE *node;
    SceneArgs.ReturnValue = 0;
    SceneArgs.Ueberschrieben = 1;
    ShowMenuBackground();
    buildingID = GetObjNrOfBuilding((film->akt_Ort) + 1);
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500002, BuildObjectList); };
    for (node = (NODE *) ((((NODE *)((&((ObjectList))->Head)))->Succ)); (((NODE *)(node))->Succ);
  node = (NODE *) (((NODE *)(node))->Succ)) {
 areaID = (((struct ObjectNode *)node)->nr);
 lsInitRelations(areaID);
 lsInitObjectDB(buildingID, areaID);
    }
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500001, BuildObjectList); };
    areaID = (((struct ObjectNode *)((((NODE *)((&((ObjectList))->Head)))->Succ)))->nr);
    lsLoadGlobalData(buildingID, areaID);
    lsSetRelations(areaID);
    perc = ((Building) dbGetObject(buildingID))->Exactlyness;
    lsShowRaster(areaID, perc);
    gfxShow(154, 4 | 2, 5, -1, -1);
    tcRefreshLocationInTitle((film->akt_Ort));
    while (!SceneArgs.ReturnValue) {
 if (SceneArgs.Moeglichkeiten) {
     inpTurnFunctionKey(0);
     inpTurnESC(0);
     activ =
  Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
     inpTurnFunctionKey(1);
     inpTurnESC(1);
     choice = (U32) 1L << activ;
     switch (choice) {
     case (1<<3):
  tcInsideOfHouse(buildingID, areaID, perc);
  ShowMenuBackground();
  tcRefreshLocationInTitle((film->akt_Ort));
  AddVTime(19);
  ShowTime(0);
  break;
     case (1):
  if (!(areaID = tcGoInsideOfHouse(buildingID)))
      SceneArgs.ReturnValue =
   (U32) (((struct TCEventNode
     *) (((((NODE *)((&(((GetCurrentScene()-> std_succ)))->Head)))->Succ))))->EventNr);
  else {
      lsSetRelations(areaID);
      lsShowRaster(areaID, perc);
  }
  tcRefreshLocationInTitle((film->akt_Ort));
  break;
     default:
  SceneArgs.ReturnValue = StdHandle(choice);
  break;
     }
 }
    }
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500002, BuildObjectList); };
    for (node = (NODE *) ((((NODE *)((&((ObjectList))->Head)))->Succ)); (((NODE *)(node))->Succ);
  node = (NODE *) (((NODE *)(node))->Succ))
 lsDoneObjectDB((((struct ObjectNode *)node)->nr));
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
    RemoveList(menu);
}

canonical_original_code:
void DoneInsideHouse()
{
    struct List *menu = txtGoKey(0U, "Mainmenu");
    unsigned int choice; unsigned int buildingID; unsigned int areaID;
    unsigned char activ = 0; unsigned char perc;
    struct Node *node;
    SceneArgs.ReturnValue = 0;
    SceneArgs.Ueberschrieben = 1;
    ShowMenuBackground();
    buildingID = GetObjNrOfBuilding((film->akt_Ort) + 1);
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500002, BuildObjectList); };
    for (node = (struct Node *) ((((struct Node *)((&((ObjectList))->Head)))->Succ)); (((struct Node *)(node))->Succ);
  node = (struct Node *) (((struct Node *)(node))->Succ)) {
 areaID = (((struct ObjectNode *)node)->nr);
 lsInitRelations(areaID);
 lsInitObjectDB(buildingID, areaID);
    }
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500001, BuildObjectList); };
    areaID = (((struct ObjectNode *)((((struct Node *)((&((ObjectList))->Head)))->Succ)))->nr);
    lsLoadGlobalData(buildingID, areaID);
    lsSetRelations(areaID);
    perc = ((struct _Building *) dbGetObject(buildingID))->Exactlyness;
    lsShowRaster(areaID, perc);
    gfxShow(154, 4 | 2, 5, -1, -1);
    tcRefreshLocationInTitle((film->akt_Ort));
    while (!SceneArgs.ReturnValue) {
 if (SceneArgs.Moeglichkeiten) {
     inpTurnFunctionKey(0);
     inpTurnESC(0);
     activ =
  Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
     inpTurnFunctionKey(1);
     inpTurnESC(1);
     choice = (unsigned int) 1L << activ;
     switch (choice) {
     case (1<<3):
  tcInsideOfHouse(buildingID, areaID, perc);
  ShowMenuBackground();
  tcRefreshLocationInTitle((film->akt_Ort));
  AddVTime(19);
  ShowTime(0);
  break;
     case (1):
  if (!(areaID = tcGoInsideOfHouse(buildingID)))
      SceneArgs.ReturnValue =
   (U32) (((struct TCEventNode *) (((((struct Node *)((&(((GetCurrentScene()-> std_succ)))->Head)))->Succ))))->EventNr);
  else {
      lsSetRelations(areaID);
      lsShowRaster(areaID, perc);
  }
  tcRefreshLocationInTitle((film->akt_Ort));
  break;
     default:
  SceneArgs.ReturnValue = StdHandle(choice);
  break;
     }
 }
    }
    { SetObjectListAttr ((0),509992L); AskAll (dbGetObject (buildingID), 500002, BuildObjectList); };
    for (node = (struct Node *) ((((struct Node *)((&((ObjectList))->Head)))->Succ)); (((struct Node *)(node))->Succ);
  node = (struct Node *) (((struct Node *)(node))->Succ))
 lsDoneObjectDB((((struct ObjectNode *)node)->nr));
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
    RemoveList(menu);
}

variable_types:
choice
unsigned int

variable_types:
buildingID
unsigned int

variable_types:
areaID
unsigned int

variable_types:
activ
unsigned char

variable_types:
perc
unsigned char

variable_types: struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } *

user_defined_types: struct _Building { unsigned int LocationNr; unsigned short PoliceTime; unsigned short GTime; unsigned char Exactlyness; unsigned char GRate; unsigned char Strike; unsigned int Values; enum RouteE EscapeRoute; unsigned char EscapeRouteLength; unsigned char RadioGuarding; unsigned char MaxVolume; unsigned char GuardStrength; unsigned short CarXPos; unsigned short CarYPos; unsigned char DiskId; }

user_defined_types: struct TCEventNode { struct Node Node; unsigned int EventNr; }

user_defined_types: enum RouteE { Innenstadt=0, Stadt=1, Landstrasse=2, Autobahn=3 }


DoneTools

decompiled_code:
__int64 DoneTools()
{
unsigned __int8 v0; // bl
__int64 v1; // rax
__int64 v2; // rbp
unsigned int v3; // eax
__int64 v4; // r12
unsigned int v5; // eax
__int64 v6; // rax
int v7; // eax
__int64 v8; // r12
unsigned int v9; // eax
__int64 v10; // rax

v0 = 0;
v1 = txtGoKey(0LL, "Mainmenu");
*((_BYTE *)&SceneArgs + 8) = 1;
v2 = v1;
v3 = getKey(11LL);
tcMoveAPerson(9824LL, v3);
v4 = dbGetObject(9824LL);
v5 = getKey(2LL);
v6 = dbGetObject(v5);
UnSet(v6, 10LL, v4);
while ( !*((_DWORD *)&SceneArgs + 1) )
{
while ( 1 )
{
tcPersonIsHere();
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v0 = Menu(v2, SceneArgs, v0, 0LL, 0LL);
inpTurnESC(1LL);
if ( v0 == 2 )
break;
v7 = StdHandle((unsigned int)(1 << v0));
*((_DWORD *)&SceneArgs + 1) = v7;
if ( v7 )
goto LABEL_6;
}
tcToolsShop();
AddVTime(9LL);
ShowTime(0LL);
}
LABEL_6:
inpTurnFunctionKey(1LL);
v8 = dbGetObject(9824LL);
v9 = getKey(2LL);
v10 = dbGetObject(v9);
SetP(v10, 10LL, v8, 0xFFFFFFFFLL);
RemoveList(v2);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func2()
{
unsigned __int8 v0; // bl
__int64 v1; // rax
__int64 v2; // rbp
unsigned int v3; // eax
__int64 v4; // r12
unsigned int v5; // eax
__int64 v6; // rax
int v7; // eax
__int64 v8; // r12
unsigned int v9; // eax
__int64 v10; // rax

v0 = 0;
v1 = txtGoKey(0LL, "Mainmenu");
*((_BYTE *)&SceneArgs + 8) = 1;
v2 = v1;
v3 = getKey(11LL);
tcMoveAPerson(9824LL, v3);
v4 = dbGetObject(9824LL);
v5 = getKey(2LL);
v6 = dbGetObject(v5);
UnSet(v6, 10LL, v4);
while ( !*((_DWORD *)&SceneArgs + 1) )
{
while ( 1 )
{
tcPersonIsHere();
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v0 = Menu(v2, SceneArgs, v0, 0LL, 0LL);
inpTurnESC(1LL);
if ( v0 == 2 )
break;
v7 = StdHandle((unsigned int)(1 << v0));
*((_DWORD *)&SceneArgs + 1) = v7;
if ( v7 )
goto LABEL_6;
}
tcToolsShop();
AddVTime(9LL);
ShowTime(0LL);
}
LABEL_6:
inpTurnFunctionKey(1LL);
v8 = dbGetObject(9824LL);
v9 = getKey(2LL);
v10 = dbGetObject(v9);
SetP(v10, 10LL, v8, 0xFFFFFFFFLL);
RemoveList(v2);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

original_code:
void DoneTools(void)
{
    ubyte activ = 0;
    U32 choice = 0;
    LIST *menu = txtGoKey(0U, "Mainmenu");
    SceneArgs.Ueberschrieben = 1;
    tcMoveAPerson(9824U, getKey(_Location_Tools_Shop));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9824U));
    while (!SceneArgs.ReturnValue) {
 tcPersonIsHere();
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
 inpTurnESC(1);
 choice = (U32) 1L << (activ);
 if (choice == (1<<2)) {
     tcToolsShop();
     AddVTime(9);
     ShowTime(0);
 } else
     SceneArgs.ReturnValue = StdHandle(choice);
    }
    inpTurnFunctionKey(1);
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9824U), (4294967295U));
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

canonical_original_code:
void DoneTools()
{
    unsigned char activ = 0;
    unsigned int choice = 0;
    struct List *menu = txtGoKey(0U, "Mainmenu");
    SceneArgs.Ueberschrieben = 1;
    tcMoveAPerson(9824U, getKey(_Location_Tools_Shop));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9824U));
    while (!SceneArgs.ReturnValue) {
 tcPersonIsHere();
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
 inpTurnESC(1);
 choice = (unsigned int) 1L << (activ);
 if (choice == (1<<2)) {
     tcToolsShop();
     AddVTime(9);
     ShowTime(0);
 } else
     SceneArgs.ReturnValue = StdHandle(choice);
    }
    inpTurnFunctionKey(1);
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9824U), (4294967295U));
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

user_defined_types: struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; }


DoneDealer

decompiled_code:
__int64 DoneDealer()
{
__int64 v0; // rax
__int64 v1; // rbp
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
__int64 v5; // r12
unsigned int v6; // eax
__int64 v7; // rax
__int64 v8; // rbx
unsigned int v9; // eax
__int64 v10; // rax
__int64 v11; // rdx
unsigned __int8 v12; // bl
__int64 v13; // r12
unsigned int v14; // eax
__int64 v15; // rax
int v16; // eax
__int64 v17; // r12
unsigned int v18; // eax
__int64 v19; // rax
__int64 v20; // rbx
unsigned int v21; // eax
__int64 v22; // rax
__int64 v23; // r12
unsigned int v24; // eax
__int64 v25; // rax

v0 = txtGoKey(0LL, "Mainmenu");
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v1 = v0;
v2 = getKey(17LL);
tcMoveAPerson(9814LL, v2);
v3 = getKey(18LL);
tcMoveAPerson(9825LL, v3);
v4 = getKey(16LL);
tcMoveAPerson(9820LL, v4);
v5 = dbGetObject(9814LL);
v6 = getKey(2LL);
v7 = dbGetObject(v6);
UnSet(v7, 10LL, v5);
v8 = dbGetObject(9825LL);
v9 = getKey(2LL);
v10 = dbGetObject(v9);
v11 = v8;
v12 = 0;
UnSet(v10, 10LL, v11);
v13 = dbGetObject(9820LL);
v14 = getKey(2LL);
v15 = dbGetObject(v14);
UnSet(v15, 10LL, v13);
while ( !*((_DWORD *)&SceneArgs + 1) )
{
while ( 1 )
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v12 = Menu(v1, SceneArgs, v12, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v12 == 2 )
break;
v16 = StdHandle((unsigned int)(1 << v12));
*((_DWORD *)&SceneArgs + 1) = v16;
if ( v16 )
goto LABEL_6;
}
tcDealerDlg();
}
LABEL_6:
v17 = dbGetObject(9814LL);
v18 = getKey(2LL);
v19 = dbGetObject(v18);
SetP(v19, 10LL, v17, 0xFFFFFFFFLL);
v20 = dbGetObject(9825LL);
v21 = getKey(2LL);
v22 = dbGetObject(v21);
SetP(v22, 10LL, v20, 0xFFFFFFFFLL);
v23 = dbGetObject(9820LL);
v24 = getKey(2LL);
v25 = dbGetObject(v24);
SetP(v25, 10LL, v23, 0xFFFFFFFFLL);
RemoveList(v1);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
__int64 v1; // rbp
unsigned int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax
__int64 v5; // r12
unsigned int v6; // eax
__int64 v7; // rax
__int64 v8; // rbx
unsigned int v9; // eax
__int64 v10; // rax
__int64 v11; // rdx
unsigned __int8 v12; // bl
__int64 v13; // r12
unsigned int v14; // eax
__int64 v15; // rax
int v16; // eax
__int64 v17; // r12
unsigned int v18; // eax
__int64 v19; // rax
__int64 v20; // rbx
unsigned int v21; // eax
__int64 v22; // rax
__int64 v23; // r12
unsigned int v24; // eax
__int64 v25; // rax

v0 = txtGoKey(0LL, "Mainmenu");
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v1 = v0;
v2 = getKey(17LL);
tcMoveAPerson(9814LL, v2);
v3 = getKey(18LL);
tcMoveAPerson(9825LL, v3);
v4 = getKey(16LL);
tcMoveAPerson(9820LL, v4);
v5 = dbGetObject(9814LL);
v6 = getKey(2LL);
v7 = dbGetObject(v6);
UnSet(v7, 10LL, v5);
v8 = dbGetObject(9825LL);
v9 = getKey(2LL);
v10 = dbGetObject(v9);
v11 = v8;
v12 = 0;
UnSet(v10, 10LL, v11);
v13 = dbGetObject(9820LL);
v14 = getKey(2LL);
v15 = dbGetObject(v14);
UnSet(v15, 10LL, v13);
while ( !*((_DWORD *)&SceneArgs + 1) )
{
while ( 1 )
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v12 = Menu(v1, SceneArgs, v12, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v12 == 2 )
break;
v16 = StdHandle((unsigned int)(1 << v12));
*((_DWORD *)&SceneArgs + 1) = v16;
if ( v16 )
goto LABEL_6;
}
tcDealerDlg();
}
LABEL_6:
v17 = dbGetObject(9814LL);
v18 = getKey(2LL);
v19 = dbGetObject(v18);
SetP(v19, 10LL, v17, 0xFFFFFFFFLL);
v20 = dbGetObject(9825LL);
v21 = getKey(2LL);
v22 = dbGetObject(v21);
SetP(v22, 10LL, v20, 0xFFFFFFFFLL);
v23 = dbGetObject(9820LL);
v24 = getKey(2LL);
v25 = dbGetObject(v24);
SetP(v25, 10LL, v23, 0xFFFFFFFFLL);
RemoveList(v1);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

original_code:
void DoneDealer(void)
{
    ubyte activ = 0;
    U32 choice = 0;
    LIST *menu = txtGoKey(0U, "Mainmenu");
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0L;
    tcMoveAPerson(9814U, getKey(_Location_Maloya));
    tcMoveAPerson(9825U, getKey(_Location_Pooly));
    tcMoveAPerson(9820U, getKey(_Location_Parker));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9814U));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9825U));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9820U));
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 choice = (U32) 1L << (activ);
 if (choice == (1<<2))
     tcDealerDlg();
 else
     SceneArgs.ReturnValue = StdHandle(choice);
    }
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9814U), (4294967295U));
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9825U), (4294967295U));
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9820U), (4294967295U));
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

canonical_original_code:
void DoneDealer()
{
    unsigned char activ = 0;
    unsigned int choice = 0;
    struct List *menu = txtGoKey(0U, "Mainmenu");
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0L;
    tcMoveAPerson(9814U, getKey(_Location_Maloya));
    tcMoveAPerson(9825U, getKey(_Location_Pooly));
    tcMoveAPerson(9820U, getKey(_Location_Parker));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9814U));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9825U));
    UnSet (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9820U));
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0L);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 choice = (unsigned int) 1L << (activ);
 if (choice == (1<<2))
     tcDealerDlg();
 else
     SceneArgs.ReturnValue = StdHandle(choice);
    }
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9814U), (4294967295U));
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9825U), (4294967295U));
    SetP (dbGetObject (getKey(_London_London_1)), 10, dbGetObject (9820U), (4294967295U));
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}


DoneParking

decompiled_code:
__int64 DoneParking()
{
unsigned __int8 v0; // bl
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rax
unsigned __int16 *v4; // r14
char v5; // al
unsigned int v6; // eax

v0 = 0;
v1 = txtGoKey(2LL, "PARKING");
v2 = txtGoKey(0LL, "Mainmenu");
v3 = dbGetObject(9832LL);
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v4 = (unsigned __int16 *)v3;
do
{
while ( 1 )
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v0 = Menu(v2, SceneArgs, v0, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v0 == 2 )
break;
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle(1LL << v0);
inpTurnESC(1LL);
if ( *((_DWORD *)&SceneArgs + 1) )
goto LABEL_10;
}
while ( 1 )
{
v5 = Bubble(v1, 0LL, 0LL, 0LL);
if ( !v5 )
{
tcBuyCar();
AddVTime(9LL);
goto LABEL_9;
}
if ( v5 != 1 )
goto LABEL_9;
v6 = tcChooseCar(27LL);
if ( !v6 )
break;
tcSellCar(v6);
AddVTime(11LL);
}
Say(2LL, 0LL, *v4, "SELL_HERE");
LABEL_9:
ShowTime(0LL);
}
while ( !*((_DWORD *)&SceneArgs + 1) );
LABEL_10:
RemoveList(v1);
RemoveList(v2);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func4()
{
unsigned __int8 v0; // bl
__int64 v1; // r12
__int64 v2; // rbp
__int64 v3; // rax
unsigned __int16 *v4; // r14
char v5; // al
unsigned int v6; // eax

v0 = 0;
v1 = txtGoKey(2LL, "PARKING");
v2 = txtGoKey(0LL, "Mainmenu");
v3 = dbGetObject(9832LL);
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v4 = (unsigned __int16 *)v3;
do
{
while ( 1 )
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v0 = Menu(v2, SceneArgs, v0, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v0 == 2 )
break;
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle(1LL << v0);
inpTurnESC(1LL);
if ( *((_DWORD *)&SceneArgs + 1) )
goto LABEL_10;
}
while ( 1 )
{
v5 = Bubble(v1, 0LL, 0LL, 0LL);
if ( !v5 )
{
tcBuyCar();
AddVTime(9LL);
goto LABEL_9;
}
if ( v5 != 1 )
goto LABEL_9;
v6 = tcChooseCar(27LL);
if ( !v6 )
break;
tcSellCar(v6);
AddVTime(11LL);
}
Say(2LL, 0LL, *v4, "SELL_HERE");
LABEL_9:
ShowTime(0LL);
}
while ( !*((_DWORD *)&SceneArgs + 1) );
LABEL_10:
RemoveList(v1);
RemoveList(v2);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

original_code:
void DoneParking(void)
{
    LIST *bubble = txtGoKey(2U, "PARKING");
    LIST *menu = txtGoKey(0U, "Mainmenu");
    ubyte activ = 0, choice = 0;
    U32 carID;
    Person marc = dbGetObject(9832U);
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0;
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), 0L, 0L);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 if ((1L << activ) == (1<<2)) {
     choice = 0;
     while (choice != 2) {
  choice = Bubble(bubble, 0, 0L, 0L);
  switch (choice) {
  case 0:
      tcBuyCar();
      AddVTime(9);
      choice = 2;
      break;
  case 1:
      if ((carID = tcChooseCar(27))) {
   tcSellCar(carID);
   AddVTime(11);
      } else {
   Say(2U, 0, marc->PictID, "SELL_HERE");
   choice = 2;
      }
      break;
  default:
      choice = 2;
      break;
  }
     }
     ShowTime(0);
 } else {
     inpTurnESC(0);
     SceneArgs.ReturnValue = StdHandle(1L << activ);
     inpTurnESC(1);
 }
    }
    RemoveList(bubble);
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

canonical_original_code:
void DoneParking()
{
    struct List *bubble = txtGoKey(2U, "PARKING");
    struct List *menu = txtGoKey(0U, "Mainmenu");
    unsigned char activ = 0; unsigned char choice = 0;
    unsigned int carID;
    struct _Person *marc = dbGetObject(9832U);
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0;
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), 0L, 0L);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 if ((1L << activ) == (1<<2)) {
     choice = 0;
     while (choice != 2) {
  choice = Bubble(bubble, 0, 0L, 0L);
  switch (choice) {
  case 0:
      tcBuyCar();
      AddVTime(9);
      choice = 2;
      break;
  case 1:
      if ((carID = tcChooseCar(27))) {
   tcSellCar(carID);
   AddVTime(11);
      } else {
   Say(2U, 0, marc->PictID, "SELL_HERE");
   choice = 2;
      }
      break;
  default:
      choice = 2;
      break;
  }
     }
     ShowTime(0);
 } else {
     inpTurnESC(0);
     SceneArgs.ReturnValue = StdHandle(1L << activ);
     inpTurnESC(1);
 }
    }
    RemoveList(bubble);
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

variable_types:
choice
unsigned char

variable_types:
carID
unsigned int

variable_types: struct _Person { unsigned short PictID; enum JobE { Detektiv=0, Sprengmeister=1, Schlosser=2, Hehler=3, Haendler=4, Taxifahrer=5, Mechaniker=6, Elektriker=7, Sekretaerin=8, Anwalt=9, Unbekannt=10, Profiboxer=11, Angestellte=12, Soldat=13, Student=14, Literat=15, Professor=16, Hausfrau=17, Politiker=18, Abenteurer=19, Agent=20, Musiker=21, Pilot=22, Kellner=23, Rezeptionist=24, Polizeichef=25, Polizist=26, Moench=27, Inspektor=28, Pizzafahrer=29, Kellner_und_Student=30, Arbeiter=31, Butler=32, Krankenschwester=33 } Job; enum SexE { Maennlich=0, Weiblich=1 } Sex; char Age; unsigned char Health; unsigned char Mood; unsigned char Intelligence; unsigned char Strength; unsigned char Stamina; unsigned char Loyality; unsigned char Skill; unsigned char Known; unsigned char Popularity; unsigned char Avarice; unsigned char Panic; unsigned char KnownToPolice; unsigned int TalkBits; unsigned char TalkFileID; unsigned char OldHealth; } *

user_defined_types: struct _Person { unsigned short PictID; enum JobE Job; enum SexE Sex; char Age; unsigned char Health; unsigned char Mood; unsigned char Intelligence; unsigned char Strength; unsigned char Stamina; unsigned char Loyality; unsigned char Skill; unsigned char Known; unsigned char Popularity; unsigned char Avarice; unsigned char Panic; unsigned char KnownToPolice; unsigned int TalkBits; unsigned char TalkFileID; unsigned char OldHealth; }


DoneGarage

decompiled_code:
__int64 DoneGarage()
{
unsigned __int8 v0; // bl
__int64 v1; // rbp
__int64 v2; // rax
unsigned __int16 *v3; // r12
unsigned int v4; // eax

v0 = 0;
v1 = txtGoKey(0LL, "Mainmenu");
v2 = dbGetObject(9832LL);
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v3 = (unsigned __int16 *)v2;
do
{
while ( 1 )
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v0 = Menu(v1, SceneArgs, v0, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v0 == 2 )
break;
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle((unsigned int)(1 << v0));
inpTurnESC(1LL);
LABEL_3:
if ( *((_DWORD *)&SceneArgs + 1) )
goto LABEL_7;
}
v4 = tcChooseCar(26LL);
if ( !v4 )
{
Say(2LL, 0LL, *v3, "REPAIR_HERE");
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle(1LL);
inpTurnESC(1LL);
goto LABEL_3;
}
tcCarInGarage(v4);
AddVTime(9LL);
ShowTime(0LL);
}
while ( !*((_DWORD *)&SceneArgs + 1) );
LABEL_7:
RemoveList(v1);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func5()
{
unsigned __int8 v0; // bl
__int64 v1; // rbp
__int64 v2; // rax
unsigned __int16 *v3; // r12
unsigned int v4; // eax

v0 = 0;
v1 = txtGoKey(0LL, "Mainmenu");
v2 = dbGetObject(9832LL);
*((_BYTE *)&SceneArgs + 8) = 1;
*((_DWORD *)&SceneArgs + 1) = 0;
v3 = (unsigned __int16 *)v2;
do
{
while ( 1 )
{
inpTurnFunctionKey(0LL);
inpTurnESC(0LL);
v0 = Menu(v1, SceneArgs, v0, 0LL, 0LL);
inpTurnESC(1LL);
inpTurnFunctionKey(1LL);
if ( v0 == 2 )
break;
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle((unsigned int)(1 << v0));
inpTurnESC(1LL);
LABEL_3:
if ( *((_DWORD *)&SceneArgs + 1) )
goto LABEL_7;
}
v4 = tcChooseCar(26LL);
if ( !v4 )
{
Say(2LL, 0LL, *v3, "REPAIR_HERE");
inpTurnESC(0LL);
*((_DWORD *)&SceneArgs + 1) = StdHandle(1LL);
inpTurnESC(1LL);
goto LABEL_3;
}
tcCarInGarage(v4);
AddVTime(9LL);
ShowTime(0LL);
}
while ( !*((_DWORD *)&SceneArgs + 1) );
LABEL_7:
RemoveList(v1);
StopAnim();
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

original_code:
void DoneGarage(void)
{
    LIST *menu = txtGoKey(0U, "Mainmenu");
    ubyte activ = 0;
    U32 choice, carID;
    Person marc = dbGetObject(9832U);
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0;
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 choice = (U32) 1L << (activ);
 if (choice == (1<<2)) {
     if ((carID = tcChooseCar(26))) {
  tcCarInGarage(carID);
  AddVTime(9);
  ShowTime(0);
     } else {
  Say(2U, 0, marc->PictID, "REPAIR_HERE");
  inpTurnESC(0);
  SceneArgs.ReturnValue = StdHandle((1));
  inpTurnESC(1);
     }
 } else {
     inpTurnESC(0);
     SceneArgs.ReturnValue = StdHandle(choice);
     inpTurnESC(1);
 }
    }
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

canonical_original_code:
void DoneGarage()
{
    struct List *menu = txtGoKey(0U, "Mainmenu");
    unsigned char activ = 0;
    unsigned int choice; unsigned int carID;
    struct _Person *marc = dbGetObject(9832U);
    SceneArgs.Ueberschrieben = 1;
    SceneArgs.ReturnValue = 0;
    while (!SceneArgs.ReturnValue) {
 inpTurnFunctionKey(0);
 inpTurnESC(0);
 activ = Menu(menu, SceneArgs.Moeglichkeiten, (ubyte) (activ), ((void *)0), 0);
 inpTurnESC(1);
 inpTurnFunctionKey(1);
 choice = (unsigned int) 1L << (activ);
 if (choice == (1<<2)) {
     if ((carID = tcChooseCar(26))) {
  tcCarInGarage(carID);
  AddVTime(9);
  ShowTime(0);
     } else {
  Say(2U, 0, marc->PictID, "REPAIR_HERE");
  inpTurnESC(0);
  SceneArgs.ReturnValue = StdHandle((1));
  inpTurnESC(1);
     }
 } else {
     inpTurnESC(0);
     SceneArgs.ReturnValue = StdHandle(choice);
     inpTurnESC(1);
 }
    }
    RemoveList(menu);
    StopAnim();
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

user_defined_types: enum JobE { Detektiv=0, Sprengmeister=1, Schlosser=2, Hehler=3, Haendler=4, Taxifahrer=5, Mechaniker=6, Elektriker=7, Sekretaerin=8, Anwalt=9, Unbekannt=10, Profiboxer=11, Angestellte=12, Soldat=13, Student=14, Literat=15, Professor=16, Hausfrau=17, Politiker=18, Abenteurer=19, Agent=20, Musiker=21, Pilot=22, Kellner=23, Rezeptionist=24, Polizeichef=25, Polizist=26, Moench=27, Inspektor=28, Pizzafahrer=29, Kellner_und_Student=30, Arbeiter=31, Butler=32, Krankenschwester=33 }


tcInitFahndung

decompiled_code:
__int64 tcInitFahndung()
{
unsigned int v0; // eax
__int64 v1; // rbx
__int64 result; // rax

v0 = getKey(1LL);
v1 = dbGetObject(v0);
result = tcMattGoesTo(59LL);
++*(_BYTE *)(v1 + 12);
return result;
}

canonical_decompiled_code:
__int64 func6()
{
unsigned int v0; // eax
__int64 v1; // rbx
__int64 result; // rax

v0 = getKey(1LL);
v1 = dbGetObject(v0);
result = tcMattGoesTo(59LL);
++*(_BYTE *)(v1 + 12);
return result;
}

original_code:
void tcInitFahndung(void)
{
    Player player = dbGetObject(getKey(_Player_Player_1));
    tcMattGoesTo(59);
    player->NrOfBurglaries++;
}

canonical_original_code:
void tcInitFahndung()
{
    struct _Player *player = dbGetObject(getKey(_Player_Player_1));
    tcMattGoesTo(59);
    player->NrOfBurglaries++;
}

variable_types: struct _Player { unsigned int Money; unsigned int StolenMoney; unsigned int MyStolenMoney; unsigned char NrOfBurglaries; unsigned char JobOfferCount; unsigned char MattsPart; unsigned int CurrScene; unsigned int CurrDay; unsigned int CurrMinute; unsigned int CurrLocation; } *


tcDoneFahndung

decompiled_code:
__int64 tcDoneFahndung()
{
__int64 v1; // rdi

if ( (unsigned int)tcStartEvidence() )
{
tcDonePrison();
*((_DWORD *)&SceneArgs + 1) = 45350912;
}
else
{
v1 = (unsigned int)getKey(1LL);
if ( *(_BYTE *)(dbGetObject(v1) + 12) == 3 )
*((_DWORD *)&SceneArgs + 1) = 21495808;
else
*((_DWORD *)&SceneArgs + 1) = 0x200000;
}
if ( (unsigned int)tcIsDeadlock() )
*((_DWORD *)&SceneArgs + 1) = 45350912;
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v1; // rdi

if ( (unsigned int)tcStartEvidence() )
{
tcDonePrison();
*((_DWORD *)&SceneArgs + 1) = 45350912;
}
else
{
v1 = (unsigned int)getKey(1LL);
if ( *(_BYTE *)(dbGetObject(v1) + 12) == 3 )
*((_DWORD *)&SceneArgs + 1) = 21495808;
else
*((_DWORD *)&SceneArgs + 1) = 0x200000;
}
if ( (unsigned int)tcIsDeadlock() )
*((_DWORD *)&SceneArgs + 1) = 45350912;
return gfxChangeColors(l_gc, 5LL, 4LL, 0LL);
}

original_code:
void tcDoneFahndung(void)
{
    if (tcStartEvidence()) {
 tcDonePrison();
 SceneArgs.ReturnValue = 45350912L;
    } else {
 switch (((Player) (dbGetObject(getKey(_Player_Player_1))))->NrOfBurglaries) {
 case 3:
     SceneArgs.ReturnValue = 21495808L;
     break;
 default:
     SceneArgs.ReturnValue = 2097152L;
     break;
 }
    }
    if (tcIsDeadlock())
 SceneArgs.ReturnValue = 45350912L;
    gfxChangeColors(l_gc, 5L, 4, 0L);
}

canonical_original_code:
void tcDoneFahndung()
{
    if (tcStartEvidence()) {
 tcDonePrison();
 SceneArgs.ReturnValue = 45350912L;
    } else {
 switch (((Player) (dbGetObject(getKey(_Player_Player_1))))->NrOfBurglaries) {
 case 3:
     SceneArgs.ReturnValue = 21495808L;
     break;
 default:
     SceneArgs.ReturnValue = 2097152L;
     break;
 }
    }
    if (tcIsDeadlock())
 SceneArgs.ReturnValue = 45350912L;
    gfxChangeColors(l_gc, 5L, 4, 0L);
}


DoneHotelRoom

decompiled_code:
__int64 DoneHotelRoom()
{
tcCheckForBones();
if ( setup[1] )
tcCheckForDowning();
return StdDone();
}

canonical_decompiled_code:
__int64 func8()
{
tcCheckForBones();
if ( setup[1] )
tcCheckForDowning();
return StdDone();
}

original_code:
void DoneHotelRoom(void)
{
    tcCheckForBones();
    if (setup.Profidisk) {
        tcCheckForDowning();
    }
    StdDone();
}

canonical_original_code:
void DoneHotelRoom()
{
    tcCheckForBones();
    if (setup.Profidisk) {
        tcCheckForDowning();
    }
    StdDone();
}


sndInit

decompiled_code:
__int64 sndInit()
{
currSoundName = 0;
return hscInit();
}

canonical_decompiled_code:
__int64 func0()
{
currSoundName = 0;
return hscInit();
}

original_code:
void sndInit(void)
{
    currSoundName[0] = '\0';
    hscInit();
}

canonical_original_code:
void sndInit()
{
    currSoundName[0] = '\0';
    hscInit();
}


sndDone

decompiled_code:
__int64 sndDone()
{
SDL_LockAudio();
hscDone();
return SDL_UnlockAudio();
}

canonical_decompiled_code:
__int64 func1()
{
SDL_LockAudio();
hscDone();
return SDL_UnlockAudio();
}

original_code:
void sndDone(void)
{
    SDL_LockAudio();
    hscDone();
    SDL_UnlockAudio();
}

canonical_original_code:
void sndDone()
{
    SDL_LockAudio();
    hscDone();
    SDL_UnlockAudio();
}


sndPlaySound

decompiled_code:
int __fastcall sndPlaySound(char *src)
{
int result; // eax
_BYTE v2[520]; // [rsp+0h] [rbp-208h] BYREF

result = strcmp(&currSoundName, src);
if ( result )
{
result = (unsigned int)strcpy(&currSoundName, src);
if ( FXBase )
{
dskBuildPathName(0LL, "sounds", src, v2);
SDL_LockAudio();
hscLoad(v2);
result = SDL_UnlockAudio();
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(char *src)
{
int result; // eax
_BYTE v2[520]; // [rsp+0h] [rbp-208h] BYREF

result = strcmp(&currSoundName, src);
if ( result )
{
result = (unsigned int)strcpy(&currSoundName, src);
if ( FXBase )
{
dskBuildPathName(0LL, "sounds", src, v2);
SDL_LockAudio();
hscLoad(v2);
result = SDL_UnlockAudio();
}
}
return result;
}

original_code:
void sndPlaySound(char *name, U32 mode)
{
    char path[512];
    if (strcmp(currSoundName, name) != 0) {
 strcpy(currSoundName, name);
 if (FXBase.us_AudioOk) {
     dskBuildPathName(DISK_CHECK_FILE, "sounds", name, path);
            SDL_LockAudio();
     hscLoad(path);
            SDL_UnlockAudio();
 }
    }
}

canonical_original_code:
void sndPlaySound(char *name, unsigned int mode)
{
    char path[512];
    if (strcmp(currSoundName, name) != 0) {
 strcpy(currSoundName, name);
 if (FXBase.us_AudioOk) {
     dskBuildPathName(DISK_CHECK_FILE, "sounds", name, path);
            SDL_LockAudio();
     hscLoad(path);
            SDL_UnlockAudio();
 }
    }
}

variable_types:
name
char *

variable_types:
mode
unsigned int

variable_types:
path
char [512]


sndGetCurrSoundName

decompiled_code:
char *sndGetCurrSoundName()
{
return &currSoundName;
}

canonical_decompiled_code:
char *func3()
{
return &currSoundName;
}

original_code:
char *sndGetCurrSoundName(void)
{
    return currSoundName;
}

canonical_original_code:
char *sndGetCurrSoundName()
{
    return currSoundName;
}

return_type: char *


sndFading

decompiled_code:
void sndFading()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void sndFading(short int targetVol)
{
    if (FXBase.us_AudioOk) {
    }
}

canonical_original_code:
void sndFading(short targetVol)
{
    if (FXBase.us_AudioOk) {
    }
}

variable_types: targetVol short


sndStopSound

decompiled_code:
__int64 sndStopSound()
{
__int64 result; // rax

if ( FXBase )
{
SDL_LockAudio();
hscReset();
result = SDL_UnlockAudio();
}
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax

if ( FXBase )
{
SDL_LockAudio();
hscReset();
result = SDL_UnlockAudio();
}
return result;
}

original_code:
void sndStopSound(U8 dummy)
{
    if (FXBase.us_AudioOk) {
        SDL_LockAudio();
        hscReset();
        SDL_UnlockAudio();
    }
}

canonical_original_code:
void sndStopSound(unsigned char dummy)
{
    if (FXBase.us_AudioOk) {
        SDL_LockAudio();
        hscReset();
        SDL_UnlockAudio();
    }
}

variable_types:
dummy
unsigned char


sndCallBack

decompiled_code:
__int64 __fastcall sndCallBack(__int64 a1, _WORD *a2, unsigned int a3)
{
unsigned __int64 v3; // rbx
__int64 result; // rax
unsigned __int64 v5; // rbx
__int64 v6; // rax
_WORD *v7; // rbp
__int64 v8; // rbx
_WORD *v9; // rbp
int v10; // er10
int v11; // er11
float v12; // [rsp+0h] [rbp-30h]
float v13; // [rsp+4h] [rbp-2Ch]
__int16 v14; // [rsp+14h] [rbp-1Ch] BYREF
__int16 v15[13]; // [rsp+16h] [rbp-1Ah] BYREF

v3 = (int)a3;
v12 = (float)setup[1] / 255.0;
v13 = (float)setup[2] / 255.0;
hscMusicPlayer(a3);
result = SDL_memset(a2, 0LL, v3);
v5 = v3 >> 1;
if ( (int)v5 > 0 )
{
v6 = (unsigned int)(v5 - 1);
v7 = a2;
v8 = (__int64)&a2[v6 + 1];
if ( (v6 & 1) != 0 )
goto LABEL_14;
v15[0] = 0;
v14 = 0;
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v14, 2LL);
result = sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v15, 2LL);
*a2 = (int)(float)((float)((float)((float)v14 * v12) + (float)((float)v15[0] * v13)) + 0.5);
v7 = a2 + 1;
if ( a2 + 1 != (_WORD *)v8 )
{
LABEL_14:
do
{
v15[0] = 0;
v14 = 0;
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v14, 2LL);
v9 = v7 + 1;
sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v15, 2LL);
v10 = v14;
v11 = v15[0];
v15[0] = 0;
v14 = 0;
*(v9 - 1) = (int)(float)((float)((float)((float)v10 * v12) + (float)((float)v11 * v13)) + 0.5);
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v14, 2LL);
v7 = v9 + 1;
result = sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v15, 2LL);
*(v7 - 1) = (int)(float)((float)((float)((float)v14 * v12) + (float)((float)v15[0] * v13)) + 0.5);
}
while ( v7 != (_WORD *)v8 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _WORD *a2, unsigned int a3)
{
unsigned __int64 v3; // rbx
__int64 result; // rax
unsigned __int64 v5; // rbx
__int64 v6; // rax
_WORD *v7; // rbp
__int64 v8; // rbx
_WORD *v9; // rbp
int v10; // er10
int v11; // er11
float v12; // [rsp+0h] [rbp-30h]
float v13; // [rsp+4h] [rbp-2Ch]
__int16 v14; // [rsp+14h] [rbp-1Ch] BYREF
__int16 v15[13]; // [rsp+16h] [rbp-1Ah] BYREF

v3 = (int)a3;
v12 = (float)setup[1] / 255.0;
v13 = (float)setup[2] / 255.0;
hscMusicPlayer(a3);
result = SDL_memset(a2, 0LL, v3);
v5 = v3 >> 1;
if ( (int)v5 > 0 )
{
v6 = (unsigned int)(v5 - 1);
v7 = a2;
v8 = (__int64)&a2[v6 + 1];
if ( (v6 & 1) != 0 )
goto LABEL_14;
v15[0] = 0;
v14 = 0;
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v14, 2LL);
result = sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v15, 2LL);
*a2 = (int)(float)((float)((float)((float)v14 * v12) + (float)((float)v15[0] * v13)) + 0.5);
v7 = a2 + 1;
if ( a2 + 1 != (_WORD *)v8 )
{
LABEL_14:
do
{
v15[0] = 0;
v14 = 0;
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v14, 2LL);
v9 = v7 + 1;
sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v15, 2LL);
v10 = v14;
v11 = v15[0];
v15[0] = 0;
v14 = 0;
*(v9 - 1) = (int)(float)((float)((float)((float)v10 * v12) + (float)((float)v11 * v13)) + 0.5);
if ( SfxChannelOn )
sndRemoveBuffer(*((_QWORD *)&FXBase + 1), &v14, 2LL);
v7 = v9 + 1;
result = sndRemoveBuffer(*((_QWORD *)&FXBase + 2), v15, 2LL);
*(v7 - 1) = (int)(float)((float)((float)((float)v14 * v12) + (float)((float)v15[0] * v13)) + 0.5);
}
while ( v7 != (_WORD *)v8 );
}
}
return result;
}

original_code:
static void sndCallBack(void *udata, Uint8 *stream, int len)
{
    S16 *MixStream = (S16 *) stream;
    const float sfxFactor = ((float)setup.SfxVolume) / 255,
     musicFactor = ((float)setup.MusicVolume) / 255;
    int sizeStream, i;
    if (MusicChannelOn) {
 hscMusicPlayer(len);
    }
    SDL_memset(stream, 0, len);
    sizeStream = len / sizeof(S16);
    for (i = 0; i < sizeStream; i++) {
 S16 Sfx, Music;
 Sfx = Music = 0;
 if (SfxChannelOn) {
     sndRemoveBuffer(FXBase.pSfxBuffer, &Sfx, sizeof(Sfx));
 }
 if (MusicChannelOn) {
     sndRemoveBuffer(FXBase.pMusicBuffer, &Music, sizeof(Music));
 }
 MixStream[i] = sfxFactor*Sfx + musicFactor*Music + 0.5f;
    }
}

canonical_original_code:
static void sndCallBack(void *udata, unsigned char *stream, int len)
{
    short *MixStream = (S16 *) stream;
    float sfxFactor = ((float)setup.SfxVolume) / 255; float musicFactor = ((float)setup.MusicVolume) / 255;
    int sizeStream; int i;
    if (MusicChannelOn) {
 hscMusicPlayer(len);
    }
    SDL_memset(stream, 0, len);
    sizeStream = len / sizeof(S16);
    for (i = 0; i < sizeStream; i++) {
 short Sfx; short Music;
 Sfx = Music = 0;
 if (SfxChannelOn) {
     sndRemoveBuffer(FXBase.pSfxBuffer, &Sfx, sizeof(Sfx));
 }
 if (MusicChannelOn) {
     sndRemoveBuffer(FXBase.pMusicBuffer, &Music, sizeof(Music));
 }
 MixStream[i] = sfxFactor*Sfx + musicFactor*Music + 0.5f;
    }
}

variable_types:
udata
void *

variable_types:
stream
unsigned char *

variable_types: len int

variable_types:
MixStream
short *

variable_types: sfxFactor float

variable_types: musicFactor float

variable_types: sizeStream int

variable_types: i int

variable_types: Sfx short

variable_types: Music short


LoadVOC

decompiled_code:
void __fastcall LoadVOC(const char *a1)
{
__int64 v1; // rax
unsigned __int16 *v2; // rbp
__int64 v3; // rbx
__int64 v4; // rcx
int v5; // er14
int v6; // er13
unsigned int v7; // er15
__int64 v8; // r12
char *v9; // rbx
__m128 v10; // xmm0
int v11; // er15
float v12; // xmm12_4
_WORD *v13; // r13
__int64 v14; // r8
__int64 v15; // r14
__m128 v16; // xmm7
float v17; // xmm10_4
__m128 v18; // xmm11
unsigned int v19; // er10
float v20; // xmm7_4
__m128 v21; // xmm6
__int64 v22; // rdi
__int64 v23; // r14
float v24; // xmm8_4
__m128 v25; // xmm10
unsigned int v26; // er10
float v27; // xmm6_4
__int64 v28; // rdi
__m128 v29; // xmm6
__m128 v30; // xmm9
__m128 v31; // xmm8
float v32; // xmm10_4
unsigned int v33; // er14
float v34; // xmm8_4
__int64 v35; // r10
__int64 v36; // r11
__m128 v37; // xmm1

v1 = dskLoad();
if ( !v1 )
return;
v2 = (unsigned __int16 *)v1;
if ( *(_QWORD *)v1 ^ 0x6576697461657243LL | *(_QWORD *)(v1 + 8) ^ 0x46206563696F5620LL
|| *(_DWORD *)(v1 + 16) != 442854505 )
{
DebugMsg(0LL, 13LL, "Not a VOC file: %s", a1);
v3 = v2[10];
v4 = *((unsigned __int8 *)v2 + v3);
if ( (_DWORD)v4 != 1 )
{
LABEL_26:
DebugMsg(0LL, 13LL, "Unknown VOC block-type: %d", v4);
goto LABEL_4;
}
}
else
{
v3 = *(unsigned __int16 *)(v1 + 20);
v4 = *(unsigned __int8 *)(v1 + v3);
if ( (_DWORD)v4 != 1 )
goto LABEL_26;
}
LABEL_4:
v5 = (*((unsigned __int8 *)v2 + (unsigned int)(v3 + 2)) << 8) | (*((unsigned __int8 *)v2 + (unsigned int)(v3 + 3)) << 16) | *((unsigned __int8 *)v2 + (unsigned int)(v3 + 1));
v6 = v5 - 2;
DebugMsg(2LL, 13LL, "block-offset: %d, num-samples: %d", (unsigned int)v3, (unsigned int)(v5 - 2));
v7 = *((unsigned __int8 *)v2 + (unsigned int)(v3 + 5));
v8 = 1000000 / (256LL - *((unsigned __int8 *)v2 + (unsigned int)(v3 + 4)));
DebugMsg(
2LL,
13LL,
"sample-rate: %d Hz, compression-type: %d",
(unsigned int)v8,
*((unsigned __int8 *)v2 + (unsigned int)(v3 + 5)));
if ( v7 )
DebugMsg(0LL, 13LL, "Unknown VOC compression-type: %d", v7);
v10 = (__m128)(unsigned int)LC7;
v9 = (char *)v2 + (unsigned int)(v3 + 6);
v10.m128_f32[0] = (float)(22050.0 / (float)(int)v8) * (float)v6;
if ( COERCE_FLOAT(v10.m128_i32[0] & LC9) < 8388608.0 )
{
v29.m128_f32[0] = (float)(22050.0 / (float)(int)v8) * (float)v6;
v30.m128_f32[0] = (float)(int)v10.m128_f32[0];
v10.m128_i32[0] = COERCE_UNSIGNED_INT(v30.m128_f32[0] + COERCE_FLOAT(_mm_cmpgt_ss(v29, v30).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v10).m128_u32[0];
}
v11 = (int)v10.m128_f32[0];
v12 = (float)(int)v8 / (float)((float)(v10.m128_f32[0] * (float)(int)v8) / (float)v6);
v13 = malloc((unsigned int)(2 * (int)v10.m128_f32[0]));
if ( (int)v10.m128_f32[0] )
{
v14 = (unsigned int)(v5 - 3);
v15 = 0LL;
if ( (v11 & 1) == 0 )
goto LABEL_37;
v31 = 0LL;
v31.m128_f32[0] = (float)0 * v12;
v32 = v31.m128_f32[0];
if ( COERCE_FLOAT(v31.m128_i32[0] & LC9) < 8388608.0 )
{
v37.m128_f32[0] = (float)(int)v31.m128_f32[0];
LODWORD(v32) = COERCE_UNSIGNED_INT(v37.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v37, v31).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v31).m128_u32[0];
}
v33 = (int)v32;
v34 = v31.m128_f32[0] - v32;
if ( (int)v32 > (unsigned int)v14 )
v33 = v14;
v35 = v33 + 1;
v36 = v33;
v15 = 1LL;
if ( (unsigned int)v35 > (unsigned int)v14 )
v35 = v14;
*v13 = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v35]
- (float)(unsigned __int8)v9[v36])
* v34)
+ (float)(unsigned __int8)v9[v36])
* 255.0)
- 32768.0)
+ 0.5);
if ( v11 != 1LL )
{
LABEL_37:
do
{
v16 = 0LL;
v16.m128_f32[0] = (float)(int)v15 * v12;
v17 = v16.m128_f32[0];
if ( COERCE_FLOAT(v16.m128_i32[0] & LC9) < 8388608.0 )
{
v18.m128_f32[0] = (float)(int)v16.m128_f32[0];
LODWORD(v17) = COERCE_UNSIGNED_INT(v18.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v18, v16).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v16).m128_u32[0];
}
v19 = (int)v17;
v20 = v16.m128_f32[0] - v17;
v21 = 0LL;
if ( (int)v17 > (unsigned int)v14 )
v19 = v14;
v22 = v19 + 1;
if ( (unsigned int)v22 > (unsigned int)v14 )
v22 = v14;
v13[v15] = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v22]
- (float)(unsigned __int8)v9[v19])
* v20)
+ (float)(unsigned __int8)v9[v19])
* 255.0)
- 32768.0)
+ 0.5);
v23 = v15 + 1;
v21.m128_f32[0] = (float)(int)v23 * v12;
v24 = v21.m128_f32[0];
if ( COERCE_FLOAT(v21.m128_i32[0] & LC9) < 8388608.0 )
{
v25.m128_f32[0] = (float)(int)v21.m128_f32[0];
LODWORD(v24) = COERCE_UNSIGNED_INT(v25.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v25, v21).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v21).m128_u32[0];
}
v26 = (int)v24;
v27 = v21.m128_f32[0] - v24;
if ( (int)v24 > (unsigned int)v14 )
v26 = v14;
v28 = v26 + 1;
if ( (unsigned int)v28 > (unsigned int)v14 )
v28 = v14;
v13[v23] = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v28]
- (float)(unsigned __int8)v9[v26])
* v27)
+ (float)(unsigned __int8)v9[v26])
* 255.0)
- 32768.0)
+ 0.5);
v15 = v23 + 1;
}
while ( v15 != v11 );
}
}
sndResetBuffer(*((_QWORD *)&FXBase + 1));
sndInsertBuffer(*((_QWORD *)&FXBase + 1), v13, (unsigned int)(2 * (int)v10.m128_f32[0]));
free(v13);
free(v2);
}

canonical_decompiled_code:
void __fastcall func1(const char *a1)
{
__int64 v1; // rax
unsigned __int16 *v2; // rbp
__int64 v3; // rbx
__int64 v4; // rcx
int v5; // er14
int v6; // er13
unsigned int v7; // er15
__int64 v8; // r12
char *v9; // rbx
__m128 v10; // xmm0
int v11; // er15
float v12; // xmm12_4
_WORD *v13; // r13
__int64 v14; // r8
__int64 v15; // r14
__m128 v16; // xmm7
float v17; // xmm10_4
__m128 v18; // xmm11
unsigned int v19; // er10
float v20; // xmm7_4
__m128 v21; // xmm6
__int64 v22; // rdi
__int64 v23; // r14
float v24; // xmm8_4
__m128 v25; // xmm10
unsigned int v26; // er10
float v27; // xmm6_4
__int64 v28; // rdi
__m128 v29; // xmm6
__m128 v30; // xmm9
__m128 v31; // xmm8
float v32; // xmm10_4
unsigned int v33; // er14
float v34; // xmm8_4
__int64 v35; // r10
__int64 v36; // r11
__m128 v37; // xmm1

v1 = dskLoad();
if ( !v1 )
return;
v2 = (unsigned __int16 *)v1;
if ( *(_QWORD *)v1 ^ 0x6576697461657243LL | *(_QWORD *)(v1 + 8) ^ 0x46206563696F5620LL
|| *(_DWORD *)(v1 + 16) != 442854505 )
{
DebugMsg(0LL, 13LL, "Not a VOC file: %s", a1);
v3 = v2[10];
v4 = *((unsigned __int8 *)v2 + v3);
if ( (_DWORD)v4 != 1 )
{
LABEL_26:
DebugMsg(0LL, 13LL, "Unknown VOC block-type: %d", v4);
goto LABEL_4;
}
}
else
{
v3 = *(unsigned __int16 *)(v1 + 20);
v4 = *(unsigned __int8 *)(v1 + v3);
if ( (_DWORD)v4 != 1 )
goto LABEL_26;
}
LABEL_4:
v5 = (*((unsigned __int8 *)v2 + (unsigned int)(v3 + 2)) << 8) | (*((unsigned __int8 *)v2 + (unsigned int)(v3 + 3)) << 16) | *((unsigned __int8 *)v2 + (unsigned int)(v3 + 1));
v6 = v5 - 2;
DebugMsg(2LL, 13LL, "block-offset: %d, num-samples: %d", (unsigned int)v3, (unsigned int)(v5 - 2));
v7 = *((unsigned __int8 *)v2 + (unsigned int)(v3 + 5));
v8 = 1000000 / (256LL - *((unsigned __int8 *)v2 + (unsigned int)(v3 + 4)));
DebugMsg(
2LL,
13LL,
"sample-rate: %d Hz, compression-type: %d",
(unsigned int)v8,
*((unsigned __int8 *)v2 + (unsigned int)(v3 + 5)));
if ( v7 )
DebugMsg(0LL, 13LL, "Unknown VOC compression-type: %d", v7);
v10 = (__m128)(unsigned int)LC7;
v9 = (char *)v2 + (unsigned int)(v3 + 6);
v10.m128_f32[0] = (float)(22050.0 / (float)(int)v8) * (float)v6;
if ( COERCE_FLOAT(v10.m128_i32[0] & LC9) < 8388608.0 )
{
v29.m128_f32[0] = (float)(22050.0 / (float)(int)v8) * (float)v6;
v30.m128_f32[0] = (float)(int)v10.m128_f32[0];
v10.m128_i32[0] = COERCE_UNSIGNED_INT(v30.m128_f32[0] + COERCE_FLOAT(_mm_cmpgt_ss(v29, v30).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v10).m128_u32[0];
}
v11 = (int)v10.m128_f32[0];
v12 = (float)(int)v8 / (float)((float)(v10.m128_f32[0] * (float)(int)v8) / (float)v6);
v13 = malloc((unsigned int)(2 * (int)v10.m128_f32[0]));
if ( (int)v10.m128_f32[0] )
{
v14 = (unsigned int)(v5 - 3);
v15 = 0LL;
if ( (v11 & 1) == 0 )
goto LABEL_37;
v31 = 0LL;
v31.m128_f32[0] = (float)0 * v12;
v32 = v31.m128_f32[0];
if ( COERCE_FLOAT(v31.m128_i32[0] & LC9) < 8388608.0 )
{
v37.m128_f32[0] = (float)(int)v31.m128_f32[0];
LODWORD(v32) = COERCE_UNSIGNED_INT(v37.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v37, v31).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v31).m128_u32[0];
}
v33 = (int)v32;
v34 = v31.m128_f32[0] - v32;
if ( (int)v32 > (unsigned int)v14 )
v33 = v14;
v35 = v33 + 1;
v36 = v33;
v15 = 1LL;
if ( (unsigned int)v35 > (unsigned int)v14 )
v35 = v14;
*v13 = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v35]
- (float)(unsigned __int8)v9[v36])
* v34)
+ (float)(unsigned __int8)v9[v36])
* 255.0)
- 32768.0)
+ 0.5);
if ( v11 != 1LL )
{
LABEL_37:
do
{
v16 = 0LL;
v16.m128_f32[0] = (float)(int)v15 * v12;
v17 = v16.m128_f32[0];
if ( COERCE_FLOAT(v16.m128_i32[0] & LC9) < 8388608.0 )
{
v18.m128_f32[0] = (float)(int)v16.m128_f32[0];
LODWORD(v17) = COERCE_UNSIGNED_INT(v18.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v18, v16).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v16).m128_u32[0];
}
v19 = (int)v17;
v20 = v16.m128_f32[0] - v17;
v21 = 0LL;
if ( (int)v17 > (unsigned int)v14 )
v19 = v14;
v22 = v19 + 1;
if ( (unsigned int)v22 > (unsigned int)v14 )
v22 = v14;
v13[v15] = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v22]
- (float)(unsigned __int8)v9[v19])
* v20)
+ (float)(unsigned __int8)v9[v19])
* 255.0)
- 32768.0)
+ 0.5);
v23 = v15 + 1;
v21.m128_f32[0] = (float)(int)v23 * v12;
v24 = v21.m128_f32[0];
if ( COERCE_FLOAT(v21.m128_i32[0] & LC9) < 8388608.0 )
{
v25.m128_f32[0] = (float)(int)v21.m128_f32[0];
LODWORD(v24) = COERCE_UNSIGNED_INT(v25.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v25, v21).m128_u32[0] & LC10)) | _mm_andnot_ps((__m128)(unsigned int)LC9, v21).m128_u32[0];
}
v26 = (int)v24;
v27 = v21.m128_f32[0] - v24;
if ( (int)v24 > (unsigned int)v14 )
v26 = v14;
v28 = v26 + 1;
if ( (unsigned int)v28 > (unsigned int)v14 )
v28 = v14;
v13[v23] = (int)(float)((float)((float)((float)((float)((float)((float)(unsigned __int8)v9[v28]
- (float)(unsigned __int8)v9[v26])
* v27)
+ (float)(unsigned __int8)v9[v26])
* 255.0)
- 32768.0)
+ 0.5);
v15 = v23 + 1;
}
while ( v15 != v11 );
}
}
sndResetBuffer(*((_QWORD *)&FXBase + 1));
sndInsertBuffer(*((_QWORD *)&FXBase + 1), v13, (unsigned int)(2 * (int)v10.m128_f32[0]));
free(v13);
free(v2);
}

original_code:
static void LoadVOC(const char *fileName)
{
    U8 *pSoundFile, *pRawSound;
    S16 *pResampledSound;
    unsigned blockOffset, blockType, numSamples;
    U8 SR;
    unsigned sampleRate, compressionType;
    if (!(pSoundFile = dskLoad(fileName))) {
 return;
    }
    if (memcmp(pSoundFile, magicString, strlen(magicString)) != 0) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND, "Not a VOC file: %s",
   fileName);
    }
    blockOffset = (pSoundFile[0x14])
  | (pSoundFile[0x15] << 8);
    if ((blockType = pSoundFile[blockOffset]) != 1) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND,
   "Unknown VOC block-type: %d",
   blockType);
    }
    numSamples = (pSoundFile[blockOffset + 0x3] << 16)
        | (pSoundFile[blockOffset + 0x2] << 8)
        | (pSoundFile[blockOffset + 0x1]);
    numSamples -= 2;
    DebugMsg(ERR_DEBUG, ERROR_MODULE_SOUND,
      "block-offset: %d, num-samples: %d",
      blockOffset, numSamples);
    SR = pSoundFile[blockOffset + 0x4];
    sampleRate = 1000000L / (256L - SR);
    compressionType = pSoundFile[blockOffset + 0x5];
    DebugMsg(ERR_DEBUG, ERROR_MODULE_SOUND,
      "sample-rate: %d Hz, compression-type: %d",
      sampleRate, compressionType);
    if (compressionType != 0) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND,
   "Unknown VOC compression-type: %d",
   compressionType);
    }
    pRawSound = &pSoundFile[blockOffset + 0x6];
    {
 float resampleRate, resampleRatio, numResamples;
 unsigned i, nResamples, sizeResamples;
 resampleRate = 22050;
 resampleRatio = resampleRate / sampleRate;
 numResamples = ceil(resampleRatio * numSamples);
 nResamples = numResamples;
 resampleRate = numResamples * sampleRate / numSamples;
 resampleRatio = (float) sampleRate / resampleRate;
 sizeResamples = nResamples * sizeof(*pResampledSound);
 pResampledSound = malloc(sizeResamples);
 for (i = 0; i < nResamples; i++) {
     float middleT, leftT;
     float middleS, leftS, rightS;
     unsigned left, right;
     middleT = resampleRatio * i;
     leftT = floor(middleT);
     left = leftT;
     left = ((left) < (0) ? (0) : (left) > (numSamples - 1) ? (numSamples - 1) : (left));
     right = left + 1;
     right = ((right) < (0) ? (0) : (right) > (numSamples - 1) ? (numSamples - 1) : (right));
     leftS = pRawSound[left];
     rightS = pRawSound[right];
     middleS = (rightS - leftS) * (middleT - leftT) + leftS;
     middleS = middleS * 255.0f - 32768.0f;
     pResampledSound[i] = (middleS + 0.5f);
 }
 sndResetBuffer(FXBase.pSfxBuffer);
 sndInsertBuffer(FXBase.pSfxBuffer, pResampledSound, sizeResamples);
 free(pResampledSound);
    }
    free(pSoundFile);
}

canonical_original_code:
static void LoadVOC(char *fileName)
{
    unsigned char *pSoundFile; unsigned char *pRawSound;
    short *pResampledSound;
    unsigned int blockOffset; unsigned int blockType; unsigned int numSamples;
    unsigned char SR;
    unsigned int sampleRate; unsigned int compressionType;
    if (!(pSoundFile = dskLoad(fileName))) {
 return;
    }
    if (memcmp(pSoundFile, magicString, strlen(magicString)) != 0) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND, "Not a VOC file: %s",
   fileName);
    }
    blockOffset = (pSoundFile[0x14])
  | (pSoundFile[0x15] << 8);
    if ((blockType = pSoundFile[blockOffset]) != 1) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND,
   "Unknown VOC block-type: %d",
   blockType);
    }
    numSamples = (pSoundFile[blockOffset + 0x3] << 16)
        | (pSoundFile[blockOffset + 0x2] << 8)
        | (pSoundFile[blockOffset + 0x1]);
    numSamples -= 2;
    DebugMsg(ERR_DEBUG, ERROR_MODULE_SOUND,
      "block-offset: %d, num-samples: %d",
      blockOffset, numSamples);
    SR = pSoundFile[blockOffset + 0x4];
    sampleRate = 1000000L / (256L - SR);
    compressionType = pSoundFile[blockOffset + 0x5];
    DebugMsg(ERR_DEBUG, ERROR_MODULE_SOUND,
      "sample-rate: %d Hz, compression-type: %d",
      sampleRate, compressionType);
    if (compressionType != 0) {
 DebugMsg(ERR_ERROR, ERROR_MODULE_SOUND,
   "Unknown VOC compression-type: %d",
   compressionType);
    }
    pRawSound = &pSoundFile[blockOffset + 0x6];
    {
 float resampleRate; float resampleRatio; float numResamples;
 unsigned int i; unsigned int nResamples; unsigned int sizeResamples;
 resampleRate = 22050;
 resampleRatio = resampleRate / sampleRate;
 numResamples = ceil(resampleRatio * numSamples);
 nResamples = numResamples;
 resampleRate = numResamples * sampleRate / numSamples;
 resampleRatio = (float) sampleRate / resampleRate;
 sizeResamples = nResamples * sizeof(*pResampledSound);
 pResampledSound = malloc(sizeResamples);
 for (i = 0; i < nResamples; i++) {
     float middleT; float leftT;
     float middleS; float leftS; float rightS;
     unsigned int left; unsigned int right;
     middleT = resampleRatio * i;
     leftT = floor(middleT);
     left = leftT;
     left = ((left) < (0) ? (0) : (left) > (numSamples - 1) ? (numSamples - 1) : (left));
     right = left + 1;
     right = ((right) < (0) ? (0) : (right) > (numSamples - 1) ? (numSamples - 1) : (right));
     leftS = pRawSound[left];
     rightS = pRawSound[right];
     middleS = (rightS - leftS) * (middleT - leftT) + leftS;
     middleS = middleS * 255.0f - 32768.0f;
     pResampledSound[i] = (middleS + 0.5f);
 }
 sndResetBuffer(FXBase.pSfxBuffer);
 sndInsertBuffer(FXBase.pSfxBuffer, pResampledSound, sizeResamples);
 free(pResampledSound);
    }
    free(pSoundFile);
}

variable_types:
fileName
char *

variable_types:
pSoundFile
unsigned char *

variable_types:
pRawSound
unsigned char *

variable_types:
pResampledSound
short *

variable_types:
blockOffset
unsigned int

variable_types:
blockType
unsigned int

variable_types:
numSamples
unsigned int

variable_types:
SR
unsigned char

variable_types:
sampleRate
unsigned int

variable_types:
compressionType
unsigned int

variable_types: resampleRate float

variable_types: resampleRatio float

variable_types: numResamples float

variable_types:
i
unsigned int

variable_types:
nResamples
unsigned int

variable_types:
sizeResamples
unsigned int

variable_types: middleT float

variable_types: leftT float

variable_types: middleS float

variable_types: leftS float

variable_types: rightS float

variable_types:
left
unsigned int

variable_types:
right
unsigned int


InitAudio

decompiled_code:
__int64 InitAudio()
{
__int64 result; // rax
__int64 v1; // rax
__int64 v2; // rax
int v3; // [rsp+0h] [rbp-28h] BYREF
__int16 v4; // [rsp+4h] [rbp-24h]
char v5; // [rsp+6h] [rbp-22h]
__int16 v6; // [rsp+8h] [rbp-20h]
__int64 (__fastcall *v7)(__int64, _WORD *, unsigned int); // [rsp+10h] [rbp-18h]
__int64 v8; // [rsp+18h] [rbp-10h]

if ( (unsigned int)SDL_InitSubSystem(16LL) )
{
v2 = SDL_GetError();
DebugMsg(1LL, 13LL, "SDL_InitSubSystem: %s", v2);
}
else
{
v6 = 1024;
FXBase = 1;
v3 = 22050;
v4 = -32752;
v5 = 1;
v7 = sndCallBack;
v8 = 0LL;
if ( !(unsigned int)SDL_OpenAudio(&v3, 0LL) )
{
*((_QWORD *)&FXBase + 1) = sndCreateBuffer(0x10000LL);
*((_QWORD *)&FXBase + 2) = sndCreateBuffer(0x10000LL);
return SDL_PauseAudio(0LL);
}
v1 = SDL_GetError();
DebugMsg(1LL, 13LL, "SDL_OpenAudio: %s", v1);
}
result = 0LL;
FXBase = 0;
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
__int64 v1; // rax
__int64 v2; // rax
int v3; // [rsp+0h] [rbp-28h] BYREF
__int16 v4; // [rsp+4h] [rbp-24h]
char v5; // [rsp+6h] [rbp-22h]
__int16 v6; // [rsp+8h] [rbp-20h]
__int64 (__fastcall *v7)(__int64, _WORD *, unsigned int); // [rsp+10h] [rbp-18h]
__int64 v8; // [rsp+18h] [rbp-10h]

if ( (unsigned int)SDL_InitSubSystem(16LL) )
{
v2 = SDL_GetError();
DebugMsg(1LL, 13LL, "SDL_InitSubSystem: %s", v2);
}
else
{
v6 = 1024;
FXBase = 1;
v3 = 22050;
v4 = -32752;
v5 = 1;
v7 = sndCallBack;
v8 = 0LL;
if ( !(unsigned int)SDL_OpenAudio(&v3, 0LL) )
{
*((_QWORD *)&FXBase + 1) = sndCreateBuffer(0x10000LL);
*((_QWORD *)&FXBase + 2) = sndCreateBuffer(0x10000LL);
return SDL_PauseAudio(0LL);
}
v1 = SDL_GetError();
DebugMsg(1LL, 13LL, "SDL_OpenAudio: %s", v1);
}
result = 0LL;
FXBase = 0;
return result;
}

original_code:
void InitAudio(void)
{
    SDL_AudioSpec spec;
    if (SDL_InitSubSystem(0x00000010u) == 0) {
 FXBase.us_AudioOk = 1;
    } else {
 DebugMsg(ERR_WARNING, ERROR_MODULE_SOUND,
                 "SDL_InitSubSystem: %s", SDL_GetError());
 FXBase.us_AudioOk = 0;
 return;
    }
    spec.freq = 22050;
    spec.format = 0x8010;
    spec.channels = 1;
    spec.samples = 1024;
    spec.callback = sndCallBack;
    spec.userdata = ((void *)0);
    if (SDL_OpenAudio(&spec, ((void *)0))) {
        DebugMsg(ERR_WARNING, ERROR_MODULE_SOUND,
                 "SDL_OpenAudio: %s", SDL_GetError());
        FXBase.us_AudioOk = 0;
 return;
    }
    FXBase.pSfxBuffer = sndCreateBuffer(65536);
    FXBase.pMusicBuffer = sndCreateBuffer(65536);
    SDL_PauseAudio(0);
}

canonical_original_code:
void InitAudio()
{
    struct SDL_AudioSpec spec;
    if (SDL_InitSubSystem(0x00000010u) == 0) {
 FXBase.us_AudioOk = 1;
    } else {
 DebugMsg(ERR_WARNING, ERROR_MODULE_SOUND,
                 "SDL_InitSubSystem: %s", SDL_GetError());
 FXBase.us_AudioOk = 0;
 return;
    }
    spec.freq = 22050;
    spec.format = 0x8010;
    spec.channels = 1;
    spec.samples = 1024;
    spec.callback = sndCallBack;
    spec.userdata = ((void *)0);
    if (SDL_OpenAudio(&spec, ((void *)0))) {
        DebugMsg(ERR_WARNING, ERROR_MODULE_SOUND,
                 "SDL_OpenAudio: %s", SDL_GetError());
        FXBase.us_AudioOk = 0;
 return;
    }
    FXBase.pSfxBuffer = sndCreateBuffer(65536);
    FXBase.pMusicBuffer = sndCreateBuffer(65536);
    SDL_PauseAudio(0);
}

variable_types: struct SDL_AudioSpec { int freq; unsigned short format; unsigned char channels; unsigned char silence; unsigned short samples; unsigned short padding; unsigned int size; void (*callback)(void *userdata, unsigned char *stream, int len); void *userdata; }


RemoveAudio

decompiled_code:
__int64 RemoveAudio()
{
__int64 result; // rax

SDL_CloseAudio();
if ( (unsigned int)SDL_WasInit(16LL) )
SDL_QuitSubSystem(16LL);
result = 0LL;
FXBase = 0;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax

SDL_CloseAudio();
if ( (unsigned int)SDL_WasInit(16LL) )
SDL_QuitSubSystem(16LL);
result = 0LL;
FXBase = 0;
return result;
}

original_code:
void RemoveAudio(void)
{
    SDL_CloseAudio();
    if (SDL_WasInit(0x00000010u) != 0) {
        SDL_QuitSubSystem(0x00000010u);
    }
    FXBase.us_AudioOk = 0;
}

canonical_original_code:
void RemoveAudio()
{
    SDL_CloseAudio();
    if (SDL_WasInit(0x00000010u) != 0) {
        SDL_QuitSubSystem(0x00000010u);
    }
    FXBase.us_AudioOk = 0;
}


sndInitFX

decompiled_code:
__int64 sndInitFX()
{
SDL_LockAudio();
SfxChannelOn = 0;
return SDL_UnlockAudio();
}

canonical_decompiled_code:
__int64 func4()
{
SDL_LockAudio();
SfxChannelOn = 0;
return SDL_UnlockAudio();
}

original_code:
void sndInitFX(void)
{
    SDL_LockAudio();
    SfxChannelOn = 0;
    SDL_UnlockAudio();
}

canonical_original_code:
void sndInitFX()
{
    SDL_LockAudio();
    SfxChannelOn = 0;
    SDL_UnlockAudio();
}


sndDoneFX

decompiled_code:
// attributes: thunk
__int64 sndDoneFX()
{
return sndInitFX();
}

canonical_decompiled_code:
__int64 func5()
{
return func4();
}

original_code:
void sndDoneFX(void)
{
    SDL_LockAudio();
    SfxChannelOn = 0;
    SDL_UnlockAudio();
}

canonical_original_code:
void sndDoneFX()
{
    SDL_LockAudio();
    SfxChannelOn = 0;
    SDL_UnlockAudio();
}


sndPrepareFX

decompiled_code:
void __fastcall sndPrepareFX(__int64 a1)
{
char v1[520]; // [rsp+0h] [rbp-208h] BYREF

sndInitFX();
if ( FXBase )
{
dskBuildPathName(0LL, "samples", a1, v1);
LoadVOC(v1);
}
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
char v1[520]; // [rsp+0h] [rbp-208h] BYREF

func4();
if ( FXBase )
{
dskBuildPathName(0LL, "samples", a1, v1);
func1(v1);
}
}

original_code:
void sndPrepareFX(const char *name)
{
    sndDoneFX();
    if (FXBase.us_AudioOk) {
        char fileName[512];
        dskBuildPathName(DISK_CHECK_FILE, "samples", name, fileName);
        LoadVOC(fileName);
    }
}

canonical_original_code:
void sndPrepareFX(char *name)
{
    sndDoneFX();
    if (FXBase.us_AudioOk) {
        char fileName[512];
        dskBuildPathName(DISK_CHECK_FILE, "samples", name, fileName);
        LoadVOC(fileName);
    }
}

variable_types:
name
char *

variable_types:
fileName
char [512]


sndPlayFX

decompiled_code:
__int64 sndPlayFX()
{
SDL_LockAudio();
SfxChannelOn = 1;
return SDL_UnlockAudio();
}

canonical_decompiled_code:
__int64 func7()
{
SDL_LockAudio();
SfxChannelOn = 1;
return SDL_UnlockAudio();
}

original_code:
void sndPlayFX(void)
{
    SDL_LockAudio();
    SfxChannelOn = 1;
    SDL_UnlockAudio();
}

canonical_original_code:
void sndPlayFX()
{
    SDL_LockAudio();
    SfxChannelOn = 1;
    SDL_UnlockAudio();
}


InitAnimHandler

decompiled_code:
void InitAnimHandler()
{
Handler = &RunningAnimLine;
RunningAnimLine = 0;
}

canonical_decompiled_code:
void func0()
{
Handler = &RunningAnimLine;
RunningAnimLine = 0;
}

original_code:
void InitAnimHandler(void)
{
    Handler.RunningAnimID = RunningAnimLine;
    Handler.RunningAnimID[0] = '\0';
}

canonical_original_code:
void InitAnimHandler()
{
    Handler.RunningAnimID = RunningAnimLine;
    Handler.RunningAnimID[0] = '\0';
}


SuspendAnim

decompiled_code:
void SuspendAnim()
{
byte_66D |= 1u;
}

canonical_decompiled_code:
void func1()
{
byte_66D |= 1u;
}

original_code:
void SuspendAnim(void)
{
    Handler.AnimatorState |= (1<<0);
}

canonical_original_code:
void SuspendAnim()
{
    Handler.AnimatorState |= (1<<0);
}


ContinueAnim

decompiled_code:
void ContinueAnim()
{
byte_66D &= 0xFEu;
}

canonical_decompiled_code:
void func2()
{
byte_66D &= 0xFEu;
}

original_code:
void ContinueAnim(void)
{
    Handler.AnimatorState &= (0xff - (1<<0));
}

canonical_original_code:
void ContinueAnim()
{
    Handler.AnimatorState &= (0xff - (1<<0));
}


GetAnim

decompiled_code:
__int64 __fastcall GetAnim(char *src, __int64 a2)
{
char v2; // dl
char *v3; // rax
char v5[264]; // [rsp+0h] [rbp-108h] BYREF

strcpy(v5, src);
v2 = v5[0];
if ( v5[0] )
{
v3 = v5;
do
{
if ( v2 == 44 )
*v3 = 95;
v2 = *++v3;
}
while ( v2 );
}
return txtGetNthString(8LL, v5, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(char *src, __int64 a2)
{
char v2; // dl
char *v3; // rax
char v5[264]; // [rsp+0h] [rbp-108h] BYREF

strcpy(v5, src);
v2 = v5[0];
if ( v5[0] )
{
v3 = v5;
do
{
if ( v2 == 44 )
*v3 = 95;
v2 = *++v3;
}
while ( v2 );
}
return txtGetNthString(8LL, v5, 0LL, a2);
}

original_code:
void GetAnim(char *AnimID, char *Dest)
{
    int i;
    char ID[256];
    strcpy(ID, AnimID);
    for (i = 0; ID[i] != '\0'; i++)
 if (ID[i] == ',')
     ID[i] = '_';
    txtGetNthString(8U, ID, 0, Dest);
}

variable_types:
AnimID
char *

variable_types:
Dest
char *

variable_types: i int

variable_types:
ID
char [256]


PrepareAnim

decompiled_code:
__int64 __fastcall PrepareAnim(char *a1)
{
__int64 result; // rax
unsigned __int16 v2; // ax
__int64 v3; // rbx
int v4; // ecx
__int64 v5; // rdi
int v6; // eax
__int64 v7; // rdx
_BYTE v8[264]; // [rsp+0h] [rbp-108h] BYREF

GetAnim(a1, (__int64)v8);
result = txtCountKey(v8);
if ( (unsigned int)result > 3 )
{
v2 = txtGetKeyAsULONG(4LL, v8);
v3 = gfxGetCollection(v2);
word_652 = txtGetKeyAsULONG(5LL, v8);
word_64C = txtGetKeyAsULONG(6LL, v8);
word_64E = txtGetKeyAsULONG(7LL, v8);
word_650 = txtGetKeyAsULONG(8LL, v8);
word_648 = txtGetKeyAsULONG(9LL, v8);
word_64A = txtGetKeyAsULONG(10LL, v8);
v4 = (unsigned __int16)word_650 + (unsigned __int16)word_64C;
v5 = *(unsigned __int16 *)(v3 + 32);
v6 = (unsigned __int16)word_650 + *(unsigned __int16 *)(v3 + 64);
v7 = (unsigned int)(v6 >> 31);
word_656 = *(_WORD *)(v3 + 64);
LODWORD(v7) = v6 % v4;
word_660 = v5;
word_654 = v6 / v4;
result = gfxCollToMem(v5, &AnimRPInMem, v7);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
__int64 result; // rax
unsigned __int16 v2; // ax
__int64 v3; // rbx
int v4; // ecx
__int64 v5; // rdi
int v6; // eax
__int64 v7; // rdx
_BYTE v8[264]; // [rsp+0h] [rbp-108h] BYREF

func3(a1, (__int64)v8);
result = txtCountKey(v8);
if ( (unsigned int)result > 3 )
{
v2 = txtGetKeyAsULONG(4LL, v8);
v3 = gfxGetCollection(v2);
word_652 = txtGetKeyAsULONG(5LL, v8);
word_64C = txtGetKeyAsULONG(6LL, v8);
word_64E = txtGetKeyAsULONG(7LL, v8);
word_650 = txtGetKeyAsULONG(8LL, v8);
word_648 = txtGetKeyAsULONG(9LL, v8);
word_64A = txtGetKeyAsULONG(10LL, v8);
v4 = (unsigned __int16)word_650 + (unsigned __int16)word_64C;
v5 = *(unsigned __int16 *)(v3 + 32);
v6 = (unsigned __int16)word_650 + *(unsigned __int16 *)(v3 + 64);
v7 = (unsigned int)(v6 >> 31);
word_656 = *(_WORD *)(v3 + 64);
LODWORD(v7) = v6 % v4;
word_660 = v5;
word_654 = v6 / v4;
result = gfxCollToMem(v5, &AnimRPInMem, v7);
}
return result;
}

original_code:
static void PrepareAnim(char *AnimID)
{
    char pict_list[256];
    struct Collection *coll;
    GetAnim(AnimID, pict_list);
    if ((U32) (txtCountKey(pict_list)) > 3) {
 coll =
     gfxGetCollection(txtGetKeyAsULONG(4, pict_list));
 Handler.frameCount = txtGetKeyAsULONG(5, pict_list);
 Handler.width =
     (U16) txtGetKeyAsULONG(6, pict_list);
 Handler.height =
     (U16) txtGetKeyAsULONG(7, pict_list);
 Handler.offset =
     (U16) txtGetKeyAsULONG(8, pict_list);
 Handler.destX =
     (U16) txtGetKeyAsULONG(9, pict_list);
 Handler.destY =
     (U16) txtGetKeyAsULONG(10, pict_list);
 Handler.pictsPerRow =
     (coll->us_TotalWidth + Handler.offset) / (Handler.width +
            Handler.offset);
 Handler.totalWidth = coll->us_TotalWidth;
 Handler.AnimCollection = coll->us_CollId;
 gfxCollToMem(coll->us_CollId, &AnimRPInMem);
    }
}

canonical_original_code:
static void PrepareAnim(char *AnimID)
{
    char pict_list[256];
    struct Collection *coll;
    GetAnim(AnimID, pict_list);
    if ((U32) (txtCountKey(pict_list)) > 3) {
 coll =
     gfxGetCollection(txtGetKeyAsULONG(4, pict_list));
 Handler.frameCount = txtGetKeyAsULONG(5, pict_list);
 Handler.width =
     (unsigned short) txtGetKeyAsULONG(6, pict_list);
 Handler.height =
     (unsigned short) txtGetKeyAsULONG(7, pict_list);
 Handler.offset =
     (unsigned short) txtGetKeyAsULONG(8, pict_list);
 Handler.destX =
     (unsigned short) txtGetKeyAsULONG(9, pict_list);
 Handler.destY =
     (unsigned short) txtGetKeyAsULONG(10, pict_list);
 Handler.pictsPerRow =
     (coll->us_TotalWidth + Handler.offset) / (Handler.width +
            Handler.offset);
 Handler.totalWidth = coll->us_TotalWidth;
 Handler.AnimCollection = coll->us_CollId;
 gfxCollToMem(coll->us_CollId, &AnimRPInMem);
    }
}

variable_types: struct Collection { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Link; unsigned short us_CollId; char *puch_Filename; struct _MemRastPort { unsigned short w; unsigned short h; unsigned char palette[768]; unsigned char *pixels; unsigned short collId; } *prepared; void *p_ColorTable; unsigned short us_TotalWidth; unsigned short us_TotalHeight; unsigned char uch_ColorRangeStart; unsigned char uch_ColorRangeEnd; } *

user_defined_types: struct Collection { struct Node Link; unsigned short us_CollId; char *puch_Filename; struct _MemRastPort *prepared; void *p_ColorTable; unsigned short us_TotalWidth; unsigned short us_TotalHeight; unsigned char uch_ColorRangeStart; unsigned char uch_ColorRangeEnd; }


StopAnim

decompiled_code:
void StopAnim()
{
unsigned __int16 v0; // ax
__int64 v1; // rax
unsigned __int16 v2; // ax
_BYTE v3[264]; // [rsp-108h] [rbp-108h] BYREF

if ( Handler && *Handler )
{
GetAnim(Handler, (__int64)v3);
v0 = txtGetKeyAsULONG(3LL, v3);
v1 = gfxGetPicture(v0);
if ( v1 )
gfxUnPrepareColl(*(unsigned __int16 *)(v1 + 34));
if ( (unsigned int)txtCountKey(v3) > 3 )
{
v2 = txtGetKeyAsULONG(4LL, v3);
gfxUnPrepareColl(v2);
}
*Handler = 0;
}
}

canonical_decompiled_code:
void func5()
{
unsigned __int16 v0; // ax
__int64 v1; // rax
unsigned __int16 v2; // ax
_BYTE v3[264]; // [rsp-108h] [rbp-108h] BYREF

if ( Handler && *Handler )
{
func3(Handler, (__int64)v3);
v0 = txtGetKeyAsULONG(3LL, v3);
v1 = gfxGetPicture(v0);
if ( v1 )
gfxUnPrepareColl(*(unsigned __int16 *)(v1 + 34));
if ( (unsigned int)txtCountKey(v3) > 3 )
{
v2 = txtGetKeyAsULONG(4LL, v3);
gfxUnPrepareColl(v2);
}
*Handler = 0;
}
}

original_code:
void StopAnim(void)
{
    char pict_list[256];
    struct Picture *pict;
    if (Handler.RunningAnimID) {
 if (Handler.RunningAnimID[0] != '\0') {
     GetAnim(Handler.RunningAnimID, pict_list);
     pict =
  gfxGetPicture((U16)
         txtGetKeyAsULONG((U16) 3,
            pict_list));
     if (pict)
  gfxUnPrepareColl((U16) pict->us_CollId);
     if (txtCountKey(pict_list) > 3)
  gfxUnPrepareColl((U16)
     txtGetKeyAsULONG((U16) 4,
        pict_list));
     Handler.RunningAnimID[0] = '\0';
 }
    }
}

canonical_original_code:
void StopAnim()
{
    char pict_list[256];
    struct Picture *pict;
    if (Handler.RunningAnimID) {
 if (Handler.RunningAnimID[0] != '\0') {
     GetAnim(Handler.RunningAnimID, pict_list);
     pict =
  gfxGetPicture((unsigned short)
         txtGetKeyAsULONG((unsigned short) 3,
            pict_list));
     if (pict)
  gfxUnPrepareColl((unsigned short) pict->us_CollId);
     if (txtCountKey(pict_list) > 3)
  gfxUnPrepareColl((unsigned short)
     txtGetKeyAsULONG((unsigned short) 4,
        pict_list));
     Handler.RunningAnimID[0] = '\0';
 }
    }
}

variable_types: struct Picture { struct Node { struct Node *Succ; struct Node *Pred; char *Name; unsigned long Size; } Link; unsigned short us_PictId; unsigned short us_CollId; unsigned short us_XOffset; unsigned short us_YOffset; unsigned short us_Width; unsigned short us_Height; unsigned short us_DestX; unsigned short us_DestY; } *

user_defined_types: struct Picture { struct Node Link; unsigned short us_PictId; unsigned short us_CollId; unsigned short us_XOffset; unsigned short us_YOffset; unsigned short us_Width; unsigned short us_Height; unsigned short us_DestX; unsigned short us_DestY; }


CloseAnimHandler

decompiled_code:
// attributes: thunk
void CloseAnimHandler()
{
StopAnim();
}

canonical_decompiled_code:
void func6()
{
func5();
}

original_code:
void CloseAnimHandler(void)
{
    StopAnim();
}

canonical_original_code:
void CloseAnimHandler()
{
    StopAnim();
}


PlayAnim

decompiled_code:
void __fastcall PlayAnim(char *src, __int16 a2, unsigned int a3)
{
unsigned __int16 v4; // ax
__int16 v5; // ax
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

GetAnim(src, (__int64)v6);
if ( v6[0] )
{
StopAnim();
PrepareAnim(src);
if ( (a3 & 0x40) == 0 )
{
if ( !a3 )
a3 = txtGetKeyAsULONG(1LL, v6);
v4 = txtGetKeyAsULONG(3LL, v6);
if ( v4 )
gfxShow(v4, a3, 2LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
}
if ( (unsigned int)txtCountKey(v6) > 3 )
{
v5 = txtGetKeyAsULONG(2LL, v6);
word_65C = a2;
word_65A = v5;
word_65E = 0;
qword_664 = 0x1000000000001LL;
byte_66C = 1;
strcpy(Handler, src);
ContinueAnim();
}
else
{
*Handler = 0;
}
}
else
{
gfxClearArea(l_gc);
}
}

canonical_decompiled_code:
void __fastcall func7(char *src, __int16 a2, unsigned int a3)
{
unsigned __int16 v4; // ax
__int16 v5; // ax
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

func3(src, (__int64)v6);
if ( v6[0] )
{
func5();
func4(src);
if ( (a3 & 0x40) == 0 )
{
if ( !a3 )
a3 = txtGetKeyAsULONG(1LL, v6);
v4 = txtGetKeyAsULONG(3LL, v6);
if ( v4 )
gfxShow(v4, a3, 2LL, 0xFFFFFFFFLL, 0xFFFFFFFFLL);
}
if ( (unsigned int)txtCountKey(v6) > 3 )
{
v5 = txtGetKeyAsULONG(2LL, v6);
word_65C = a2;
word_65A = v5;
word_65E = 0;
qword_664 = 0x1000000000001LL;
byte_66C = 1;
strcpy(Handler, src);
func2();
}
else
{
*Handler = 0;
}
}
else
{
gfxClearArea(l_gc);
}
}

original_code:
void PlayAnim(char *AnimID, U16 how_often, U32 mode)
{
    char pict_list[256];
    U16 pict_id = 0, rate;
    GetAnim(AnimID, pict_list);
    if (pict_list[0] == '\0')
 gfxClearArea(l_gc);
    else {
 StopAnim();
 PrepareAnim(AnimID);
 if (!(mode & 64)) {
     if (!mode)
  mode = (U32) txtGetKeyAsULONG((U16) 1, pict_list);
     pict_id = (U16) txtGetKeyAsULONG((U16) 3, pict_list);
 }
 if (pict_id)
     gfxShow(pict_id, mode, 2, -1L, -1L);
 if ((U32) (txtCountKey(pict_list)) > 3) {
     rate = (U16) txtGetKeyAsULONG((U16) 2, pict_list);
     Handler.PlayMode = 1;
     Handler.PictureRate = rate;
     Handler.Repeatation = how_often;
     Handler.CurrPictNr = 0;
     Handler.Direction = 1;
     Handler.RepeatationCount = 0;
     Handler.WaitCounter = 1;
     strcpy(Handler.RunningAnimID, AnimID);
     ContinueAnim();
 } else
     Handler.RunningAnimID[0] = '\0';
    }
}

canonical_original_code:
void PlayAnim(char *AnimID, unsigned short how_often, unsigned int mode)
{
    char pict_list[256];
    unsigned short pict_id = 0; unsigned short rate;
    GetAnim(AnimID, pict_list);
    if (pict_list[0] == '\0')
 gfxClearArea(l_gc);
    else {
 StopAnim();
 PrepareAnim(AnimID);
 if (!(mode & 64)) {
     if (!mode)
  mode = (unsigned int) txtGetKeyAsULONG((unsigned short) 1, pict_list);
     pict_id = (unsigned short) txtGetKeyAsULONG((unsigned short) 3, pict_list);
 }
 if (pict_id)
     gfxShow(pict_id, mode, 2, -1L, -1L);
 if ((U32) (txtCountKey(pict_list)) > 3) {
     rate = (unsigned short) txtGetKeyAsULONG((unsigned short) 2, pict_list);
     Handler.PlayMode = 1;
     Handler.PictureRate = rate;
     Handler.Repeatation = how_often;
     Handler.CurrPictNr = 0;
     Handler.Direction = 1;
     Handler.RepeatationCount = 0;
     Handler.WaitCounter = 1;
     strcpy(Handler.RunningAnimID, AnimID);
     ContinueAnim();
 } else
     Handler.RunningAnimID[0] = '\0';
    }
}

variable_types:
mode
unsigned int

variable_types:
rate
unsigned short