decompiled_code:
__int64 xmame_sound_start()
{
void *v0; // rax

if ( verbose_proc )
printf("Starting sound server: .....");
if ( (unsigned int)sound_start() )
{
if ( verbose_proc )
puts("...FAILED, Can't use sound");
}
else
{
v0 = &xmame_func_sound;
if ( !use_sound )
v0 = &xmame_func_nosound;
xmame_func = v0;
if ( verbose_proc )
puts("...OK");
sound_reset();
}
return 1LL;
}

canonical_decompiled_code:
__int64 func4()
{
void *v0; // rax

if ( verbose_proc )
printf("Starting sound server: .....");
if ( (unsigned int)sound_start() )
{
if ( verbose_proc )
puts("...FAILED, Can't use sound");
}
else
{
v0 = &xmame_func_sound;
if ( !use_sound )
v0 = &xmame_func_nosound;
xmame_func = v0;
if ( verbose_proc )
puts("...OK");
sound_reset();
}
return 1LL;
}

original_code:
int xmame_sound_start( void )
{
  if(verbose_proc) printf("Starting sound server: .....");
  if( sound_start()==0 ){
    do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
    if(verbose_proc) printf("...OK\n");
    sound_reset();
  }else{
    if(verbose_proc) printf("...FAILED, Can't use sound\n");
  }
  return 1;
}

canonical_original_code:
int xmame_sound_start()
{
  if(verbose_proc) printf("Starting sound server: .....");
  if( sound_start()==0 ){
    do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
    if(verbose_proc) printf("...OK\n");
    sound_reset();
  }else{
    if(verbose_proc) printf("...FAILED, Can't use sound\n");
  }
  return 1;
}


decompiled_code:
__int64 xmame_sound_update()
{
return sound_update();
}

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

original_code:
void xmame_sound_update( void )
{
  sound_update();
}

canonical_original_code:
void xmame_sound_update()
{
  sound_update();
}

return_type: void


decompiled_code:
__int64 xmame_sound_stop()
{
return sound_stop();
}

canonical_decompiled_code:
__int64 func6()
{
return sound_stop();
}

original_code:
void xmame_sound_stop( void )
{
  sound_stop();
}

canonical_original_code:
void xmame_sound_stop()
{
  sound_stop();
}


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

if ( close_device )
result = osd_sound_enable(0LL);
return result;
}

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

if ( close_device )
result = osd_sound_enable(0LL);
return result;
}

original_code:
void xmame_sound_suspend( void )
{
  if( close_device )
    osd_sound_enable(0);
}

canonical_original_code:
void xmame_sound_suspend()
{
  if( close_device )
    osd_sound_enable(0);
}


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

if ( close_device )
result = osd_sound_enable(1LL);
return result;
}

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

if ( close_device )
result = osd_sound_enable(1LL);
return result;
}

original_code:
void xmame_sound_resume( void )
{
  if( close_device )
    osd_sound_enable(1);
}

canonical_original_code:
void xmame_sound_resume()
{
  if( close_device )
    osd_sound_enable(1);
}


decompiled_code:
__int64 xmame_sound_reset()
{
return sound_reset();
}

canonical_decompiled_code:
__int64 func9()
{
return sound_reset();
}

original_code:
void xmame_sound_reset( void )
{
  sound_reset();
}

canonical_original_code:
void xmame_sound_reset()
{
  sound_reset();
}


decompiled_code:
_BOOL8 xmame_sound_is_enable()
{
return sound_stream != 0;
}

canonical_decompiled_code:
_BOOL8 func10()
{
return sound_stream != 0;
}

original_code:
int xmame_sound_is_enable( void )
{
  if( sound_stream ) return (1);
  else return (0);
}

canonical_original_code:
int xmame_sound_is_enable()
{
  if( sound_stream ) return (1);
  else return (0);
}

return_type: int


decompiled_code:
_BOOL8 xmame_volume_is_variable()
{
return (unsigned int)osd_has_sound_mixer() != 0;
}

canonical_decompiled_code:
_BOOL8 func11()
{
return (unsigned int)osd_has_sound_mixer() != 0;
}

original_code:
int xmame_volume_is_variable( void )
{
  if( osd_has_sound_mixer() ) return (1);
  else return (0);
}

canonical_original_code:
int xmame_volume_is_variable()
{
  if( osd_has_sound_mixer() ) return (1);
  else return (0);
}


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

if ( sound_stream )
{
if ( use_sound )
result = sound_stream_update();
}
return result;
}

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

if ( sound_stream )
{
if ( use_sound )
result = sound_stream_update();
}
return result;
}

original_code:
void xmame_update_video_and_audio( void )
{
   if (sound_stream && use_sound)
      sound_stream_update(sound_stream);
}

canonical_original_code:
void xmame_update_video_and_audio()
{
   if (sound_stream && use_sound)
      sound_stream_update(sound_stream);
}


decompiled_code:
__int64 xmame_sound_in_data()
{
__int64 (__fastcall *v0)(_QWORD); // rax
__int64 result; // rax

v0 = (__int64 (__fastcall *)(_QWORD))*((_QWORD *)xmame_func + 1);
if ( v0 )
result = v0(0LL);
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 (__fastcall *v0)(_QWORD); // rax
__int64 result; // rax

v0 = (__int64 (__fastcall *)(_QWORD))*((_QWORD *)xmame_func + 1);
if ( v0 )
result = v0(0LL);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
byte xmame_sound_in_data( void )
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound_in_data)(0);
  else return 0xff;
}

canonical_original_code:
unsigned char xmame_sound_in_data()
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound_in_data)(0);
  else return 0xff;
}

return_type: unsigned char


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

result = 0LL;
if ( *((_QWORD *)xmame_func + 1) )
result = (*((__int64 (__fastcall **)(_QWORD))xmame_func + 2))(0LL);
return result;
}

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

result = 0LL;
if ( *((_QWORD *)xmame_func + 1) )
result = (*((__int64 (__fastcall **)(_QWORD))xmame_func + 2))(0LL);
return result;
}

original_code:
byte xmame_sound_in_status( void )
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound_in_status)(0);
  else return 0;
}

canonical_original_code:
unsigned char xmame_sound_in_status()
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound_in_status)(0);
  else return 0;
}


decompiled_code:
void *__fastcall xmame_sound_out_reg(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 3))(0LL, a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func15(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 3))(0LL, a1);
return result;
}

original_code:
void xmame_sound_out_reg( byte data )
{
  if( xmame_func->sound_in_data ) (xmame_func->sound_out_reg)(0,data);
}

canonical_original_code:
void xmame_sound_out_reg(unsigned char data)
{
  if( xmame_func->sound_in_data ) (xmame_func->sound_out_reg)(0,data);
}

variable_types:
data
unsigned char


decompiled_code:
void *__fastcall xmame_sound_out_data(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 4))(0LL, a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func16(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 4))(0LL, a1);
return result;
}

original_code:
void xmame_sound_out_data( byte data )
{
  if( xmame_func->sound_in_data ) (xmame_func->sound_out_data)(0,data);
}

canonical_original_code:
void xmame_sound_out_data(unsigned char data)
{
  if( xmame_func->sound_in_data ) (xmame_func->sound_out_data)(0,data);
}


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

result = 0xFFFFFFFFLL;
if ( use_sound )
{
LOBYTE(result) = sound_board == 0;
result = (unsigned int)-(int)result;
}
return result;
}

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

result = 0xFFFFFFFFLL;
if ( use_sound )
{
LOBYTE(result) = sound_board == 0;
result = (unsigned int)-(int)result;
}
return result;
}

original_code:
byte xmame_sound2_in_data( void )
{
  if( !use_sound ) return 0xff;
  else{
    if( sound_board==SOUND_I ) return 0xff;
    else return 0;
  }
}

canonical_original_code:
unsigned char xmame_sound2_in_data()
{
  if( !use_sound ) return 0xff;
  else{
    if( sound_board==SOUND_I ) return 0xff;
    else return 0;
  }
}


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

if ( *((_QWORD *)xmame_func + 1) )
result = (*((__int64 (__fastcall **)(_QWORD))xmame_func + 6))(0LL);
else
result = 0xFFFFFFFFLL;
return result;
}

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

if ( *((_QWORD *)xmame_func + 1) )
result = (*((__int64 (__fastcall **)(_QWORD))xmame_func + 6))(0LL);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
byte xmame_sound2_in_status( void )
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound2_in_status)(0);
  else return 0xff;
}

canonical_original_code:
unsigned char xmame_sound2_in_status()
{
  if( xmame_func->sound_in_data ) return (xmame_func->sound2_in_status)(0);
  else return 0xff;
}


decompiled_code:
void *__fastcall xmame_sound2_out_reg(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 7))(0LL, a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func19(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 7))(0LL, a1);
return result;
}

original_code:
void xmame_sound2_out_reg( byte data )
{
  if( xmame_func->sound_in_data ) (xmame_func->sound2_out_reg)(0,data);
}

canonical_original_code:
void xmame_sound2_out_reg(unsigned char data)
{
  if( xmame_func->sound_in_data ) (xmame_func->sound2_out_reg)(0,data);
}


decompiled_code:
void *__fastcall xmame_sound2_out_data(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 8))(0LL, a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func20(unsigned __int8 a1)
{
void *result; // rax

result = xmame_func;
if ( *((_QWORD *)xmame_func + 1) )
result = (void *)(*((__int64 (__fastcall **)(_QWORD, _QWORD))xmame_func + 8))(0LL, a1);
return result;
}

original_code:
void xmame_sound2_out_data( byte data )
{
  if( xmame_func->sound_in_data ) (xmame_func->sound2_out_data)(0,data);
}

canonical_original_code:
void xmame_sound2_out_data(unsigned char data)
{
  if( xmame_func->sound_in_data ) (xmame_func->sound2_out_data)(0,data);
}


decompiled_code:
__int64 xmame_get_sound_volume()
{
return osd_get_mastervolume();
}

canonical_decompiled_code:
__int64 func21()
{
return osd_get_mastervolume();
}

original_code:
int xmame_get_sound_volume( void )
{
  return osd_get_mastervolume();
}

canonical_original_code:
int xmame_get_sound_volume()
{
  return osd_get_mastervolume();
}


decompiled_code:
__int64 __fastcall xmame_set_sound_volume(__int64 a1)
{
if ( (int)a1 < -32 )
a1 = 4294967264LL;
if ( (int)a1 > 0 )
a1 = 0LL;
return osd_set_mastervolume(a1);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1)
{
if ( (int)a1 < -32 )
a1 = 4294967264LL;
if ( (int)a1 > 0 )
a1 = 0LL;
return osd_set_mastervolume(a1);
}

original_code:
void xmame_set_sound_volume( int vol )
{
    if( vol > (0) ) vol = (0);
    if( vol < (-32) ) vol = (-32);
    osd_set_mastervolume( vol );
}

canonical_original_code:
void xmame_set_sound_volume(int vol)
{
    if( vol > (0) ) vol = (0);
    if( vol < (-32) ) vol = (-32);
    osd_set_mastervolume( vol );
}

variable_types: vol int


decompiled_code:
__int64 __fastcall xmame_get_mixer_volume(__int64 a1)
{
__int64 result; // rax

if ( use_fmgen )
{
if ( (_DWORD)a1 == 2 )
return mixer_get_mixing_level(a1);
result = 0LL;
if ( (_DWORD)a1 == 5 )
{
a1 = 0LL;
return mixer_get_mixing_level(a1);
}
}
else
{
result = sound_board;
if ( !sound_board )
{
if ( (_DWORD)a1 == 1 )
{
a1 = 3LL;
}
else if ( (_DWORD)a1 == 2 )
{
a1 = 4LL;
}
else if ( (_DWORD)a1 )
{
return result;
}
return mixer_get_mixing_level(a1);
}
switch ( (int)a1 )
{
case 0:
return mixer_get_mixing_level(a1);
case 1:
a1 = 3LL;
return mixer_get_mixing_level(a1);
case 2:
a1 = 5LL;
return mixer_get_mixing_level(a1);
case 3:
result = rhythmvol;
break;
case 4:
result = adpcmvol;
break;
default:
result = use_fmgen;
break;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1)
{
__int64 result; // rax

if ( use_fmgen )
{
if ( (_DWORD)a1 == 2 )
return mixer_get_mixing_level(a1);
result = 0LL;
if ( (_DWORD)a1 == 5 )
{
a1 = 0LL;
return mixer_get_mixing_level(a1);
}
}
else
{
result = sound_board;
if ( !sound_board )
{
if ( (_DWORD)a1 == 1 )
{
a1 = 3LL;
}
else if ( (_DWORD)a1 == 2 )
{
a1 = 4LL;
}
else if ( (_DWORD)a1 )
{
return result;
}
return mixer_get_mixing_level(a1);
}
switch ( (int)a1 )
{
case 0:
return mixer_get_mixing_level(a1);
case 1:
a1 = 3LL;
return mixer_get_mixing_level(a1);
case 2:
a1 = 5LL;
return mixer_get_mixing_level(a1);
case 3:
result = rhythmvol;
break;
case 4:
result = adpcmvol;
break;
default:
result = use_fmgen;
break;
}
}
return result;
}

original_code:
int xmame_get_mixer_volume( int ch )
{
  if( use_fmgen==0 ){
    if( sound_board==SOUND_I ){
      switch( ch ){
      case XMAME_MIXER_PSG: ch = 0; break;
      case XMAME_MIXER_FM: ch = 3; break;
      case XMAME_MIXER_BEEP: ch = 4; break;
      case XMAME_MIXER_RHYTHM: return 0;
      case XMAME_MIXER_ADPCM: return 0;
      default: return 0;
      }
    }else{
      switch( ch ){
      case XMAME_MIXER_PSG: ch = 0; break;
      case XMAME_MIXER_FM: ch = 3; break;
      case XMAME_MIXER_BEEP: ch = 5; break;
      case XMAME_MIXER_RHYTHM: return rhythmvol;
      case XMAME_MIXER_ADPCM: return adpcmvol;
      default: return 0;
      }
    }
  }else{
    switch( ch ){
    case XMAME_MIXER_FMPSG: ch = 0; break;
    case XMAME_MIXER_BEEP: ch = 2; break;
    default: return 0;
    }
  }
  return mixer_get_mixing_level( ch );
}

canonical_original_code:
int xmame_get_mixer_volume(int ch)
{
  if( use_fmgen==0 ){
    if( sound_board==SOUND_I ){
      switch( ch ){
      case XMAME_MIXER_PSG: ch = 0; break;
      case XMAME_MIXER_FM: ch = 3; break;
      case XMAME_MIXER_BEEP: ch = 4; break;
      case XMAME_MIXER_RHYTHM: return 0;
      case XMAME_MIXER_ADPCM: return 0;
      default: return 0;
      }
    }else{
      switch( ch ){
      case XMAME_MIXER_PSG: ch = 0; break;
      case XMAME_MIXER_FM: ch = 3; break;
      case XMAME_MIXER_BEEP: ch = 5; break;
      case XMAME_MIXER_RHYTHM: return rhythmvol;
      case XMAME_MIXER_ADPCM: return adpcmvol;
      default: return 0;
      }
    }
  }else{
    switch( ch ){
    case XMAME_MIXER_FMPSG: ch = 0; break;
    case XMAME_MIXER_BEEP: ch = 2; break;
    default: return 0;
    }
  }
  return mixer_get_mixing_level( ch );
}

variable_types: ch int


decompiled_code:
void __fastcall xmame_set_mixer_volume(int a1, __int64 a2)
{
unsigned int v2; // ebx
unsigned int v3; // ebx
unsigned int i; // ebx
unsigned int v5; // eax
const char *v6; // rbp
unsigned int v7; // ebx
unsigned int v8; // ebx
const char *v9; // rbp
unsigned int v10; // eax

v2 = use_fmgen;
if ( use_fmgen )
{
if ( a1 == 2 )
{
if ( (int)a2 > 100 )
a2 = 100LL;
if ( (int)a2 < 0 )
a2 = 0LL;
mixer_set_mixing_level(2LL, a2);
}
else if ( a1 == 5 )
{
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
v3 = 0;
if ( (int)a2 >= 0 )
v3 = a2;
mixer_set_mixing_level(0LL, v3);
mixer_set_mixing_level(1LL, v3);
}
else
{
for ( i = 0; i != 16; ++i )
{
v6 = (const char *)mixer_get_name(i);
if ( v6 )
{
v5 = mixer_get_mixing_level(i);
printf("%d[ch] %s\t:%d\n", i, v6, v5);
}
}
}
}
else
{
switch ( a1 )
{
case 0:
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
v7 = 0;
if ( (int)a2 >= 0 )
v7 = a2;
mixer_set_mixing_level(0LL, v7);
mixer_set_mixing_level(1LL, v7);
mixer_set_mixing_level(2LL, v7);
break;
case 1:
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
v8 = 0;
if ( (int)a2 >= 0 )
v8 = a2;
if ( sound_board )
{
mixer_set_mixing_level(3LL, v8);
mixer_set_mixing_level(4LL, v8);
}
else
{
mixer_set_mixing_level(3LL, v8);
}
break;
case 2:
if ( (int)a2 > 100 )
a2 = 100LL;
if ( (int)a2 < 0 )
a2 = 0LL;
if ( sound_board )
mixer_set_mixing_level(5LL, a2);
else
mixer_set_mixing_level(4LL, a2);
break;
case 3:
if ( sound_board == 1 )
{
if ( (int)a2 > 200 )
LODWORD(a2) = 200;
if ( (int)a2 < 0 )
LODWORD(a2) = 0;
rhythmvol = a2;
}
break;
case 4:
if ( sound_board == 1 )
{
if ( (int)a2 > 200 )
LODWORD(a2) = 200;
if ( (int)a2 < 0 )
LODWORD(a2) = 0;
adpcmvol = a2;
}
break;
default:
do
{
v9 = (const char *)mixer_get_name(v2);
if ( v9 )
{
v10 = mixer_get_mixing_level(v2);
printf("%d[ch] %s\t:%d\n", v2, v9, v10);
}
++v2;
}
while ( v2 != 16 );
break;
}
}
}

canonical_decompiled_code:
void __fastcall func24(int a1, __int64 a2)
{
unsigned int v2; // ebx
unsigned int v3; // ebx
unsigned int i; // ebx
unsigned int v5; // eax
const char *v6; // rbp
unsigned int v7; // ebx
unsigned int v8; // ebx
const char *v9; // rbp
unsigned int v10; // eax

v2 = use_fmgen;
if ( use_fmgen )
{
if ( a1 == 2 )
{
if ( (int)a2 > 100 )
a2 = 100LL;
if ( (int)a2 < 0 )
a2 = 0LL;
mixer_set_mixing_level(2LL, a2);
}
else if ( a1 == 5 )
{
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
v3 = 0;
if ( (int)a2 >= 0 )
v3 = a2;
mixer_set_mixing_level(0LL, v3);
mixer_set_mixing_level(1LL, v3);
}
else
{
for ( i = 0; i != 16; ++i )
{
v6 = (const char *)mixer_get_name(i);
if ( v6 )
{
v5 = mixer_get_mixing_level(i);
printf("%d[ch] %s\t:%d\n", i, v6, v5);
}
}
}
}
else
{
switch ( a1 )
{
case 0:
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
v7 = 0;
if ( (int)a2 >= 0 )
v7 = a2;
mixer_set_mixing_level(0LL, v7);
mixer_set_mixing_level(1LL, v7);
mixer_set_mixing_level(2LL, v7);
break;
case 1:
if ( (int)a2 > 100 )
LODWORD(a2) = 100;
v8 = 0;
if ( (int)a2 >= 0 )
v8 = a2;
if ( sound_board )
{
mixer_set_mixing_level(3LL, v8);
mixer_set_mixing_level(4LL, v8);
}
else
{
mixer_set_mixing_level(3LL, v8);
}
break;
case 2:
if ( (int)a2 > 100 )
a2 = 100LL;
if ( (int)a2 < 0 )
a2 = 0LL;
if ( sound_board )
mixer_set_mixing_level(5LL, a2);
else
mixer_set_mixing_level(4LL, a2);
break;
case 3:
if ( sound_board == 1 )
{
if ( (int)a2 > 200 )
LODWORD(a2) = 200;
if ( (int)a2 < 0 )
LODWORD(a2) = 0;
rhythmvol = a2;
}
break;
case 4:
if ( sound_board == 1 )
{
if ( (int)a2 > 200 )
LODWORD(a2) = 200;
if ( (int)a2 < 0 )
LODWORD(a2) = 0;
adpcmvol = a2;
}
break;
default:
do
{
v9 = (const char *)mixer_get_name(v2);
if ( v9 )
{
v10 = mixer_get_mixing_level(v2);
printf("%d[ch] %s\t:%d\n", v2, v9, v10);
}
++v2;
}
while ( v2 != 16 );
break;
}
}
}

original_code:
void xmame_set_mixer_volume( int ch, int level )
{
  if( use_fmgen ){
  switch( ch ){
  case XMAME_MIXER_FMPSG:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 0, level );
    mixer_set_mixing_level( 1, level );
    break;
  case XMAME_MIXER_BEEP:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 2, level );
    break;
  default:
    for( ch=0; ch<16 ; ch++ ){
      const char *name = mixer_get_name(ch);
      if(name) printf( "%d[ch] %s\t:%d\n", ch,name,mixer_get_mixing_level(ch));
    }
    break;
  }
  return;
  }
  switch( ch ){
  case XMAME_MIXER_PSG:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 0, level );
    mixer_set_mixing_level( 1, level );
    mixer_set_mixing_level( 2, level );
    break;
  case XMAME_MIXER_FM:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    if( sound_board==SOUND_I ){
      mixer_set_mixing_level( 3, level );
    }else{
      mixer_set_mixing_level( 3, level );
      mixer_set_mixing_level( 4, level );
    }
    break;
  case XMAME_MIXER_BEEP:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    if( sound_board==SOUND_I ){
      mixer_set_mixing_level( 4, level );
    }else{
      mixer_set_mixing_level( 5, level );
    }
    break;
  case XMAME_MIXER_RHYTHM:
    if( level < (0) ) level = (0);
    if( level > (200) ) level = (200);
    if( sound_board==SOUND_II ){
      rhythmvol = level;
    }
    break;
  case XMAME_MIXER_ADPCM:
    if( level < (0) ) level = (0);
    if( level > (200) ) level = (200);
    if( sound_board==SOUND_II ){
      adpcmvol = level;
    }
    break;
  default:
    for( ch=0; ch<16 ; ch++ ){
      const char *name = mixer_get_name(ch);
      if(name) printf( "%d[ch] %s\t:%d\n", ch,name,mixer_get_mixing_level(ch));
    }
    break;
  }
}

canonical_original_code:
void xmame_set_mixer_volume(int ch, int level)
{
  if( use_fmgen ){
  switch( ch ){
  case XMAME_MIXER_FMPSG:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 0, level );
    mixer_set_mixing_level( 1, level );
    break;
  case XMAME_MIXER_BEEP:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 2, level );
    break;
  default:
    for( ch=0; ch<16 ; ch++ ){
      char *name = mixer_get_name(ch);
      if(name) printf( "%d[ch] %s\t:%d\n", ch,name,mixer_get_mixing_level(ch));
    }
    break;
  }
  return;
  }
  switch( ch ){
  case XMAME_MIXER_PSG:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    mixer_set_mixing_level( 0, level );
    mixer_set_mixing_level( 1, level );
    mixer_set_mixing_level( 2, level );
    break;
  case XMAME_MIXER_FM:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    if( sound_board==SOUND_I ){
      mixer_set_mixing_level( 3, level );
    }else{
      mixer_set_mixing_level( 3, level );
      mixer_set_mixing_level( 4, level );
    }
    break;
  case XMAME_MIXER_BEEP:
    if( level < (0) ) level = (0);
    if( level > (100) ) level = (100);
    if( sound_board==SOUND_I ){
      mixer_set_mixing_level( 4, level );
    }else{
      mixer_set_mixing_level( 5, level );
    }
    break;
  case XMAME_MIXER_RHYTHM:
    if( level < (0) ) level = (0);
    if( level > (200) ) level = (200);
    if( sound_board==SOUND_II ){
      rhythmvol = level;
    }
    break;
  case XMAME_MIXER_ADPCM:
    if( level < (0) ) level = (0);
    if( level > (200) ) level = (200);
    if( sound_board==SOUND_II ){
      adpcmvol = level;
    }
    break;
  default:
    for( ch=0; ch<16 ; ch++ ){
      char *name = mixer_get_name(ch);
      if(name) printf( "%d[ch] %s\t:%d\n", ch,name,mixer_get_mixing_level(ch));
    }
    break;
  }
}

variable_types: level int

variable_types:
name
char *


decompiled_code:
__int64 __fastcall YM2203UpdateRequest(int a1)
{
return stream_update((unsigned int)stream[a1], 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
return stream_update((unsigned int)stream[a1], 0LL);
}

original_code:
void YM2203UpdateRequest(int chip)
{
 stream_update(stream[chip],0);
}

variable_types: chip int


decompiled_code:
_BOOL8 __fastcall YM2203_sh_start(__int64 a1)
{
int v2; // edx
_BOOL8 result; // rax
unsigned int *v4; // rax
__int64 v5; // rdi
__int64 v6; // rbx
const char *v7; // rax
char v8[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = AY8910_sh_start_ym();
result = 1LL;
if ( !v2 )
{
v4 = *(unsigned int **)(a1 + 8);
intf = (__int64)v4;
v5 = *v4;
if ( (int)v5 > 0 )
{
v6 = 0LL;
do
{
v7 = (const char *)sound_name(a1);
sprintf(v8, "%s #%d FM", v7, (unsigned int)v6);
stream[v6] = stream_init(
v8,
(unsigned int)*(__int16 *)(intf + 4LL * (int)v6 + 10),
sample_rate,
(unsigned int)v6,
&YM2203UpdateOne);
v4 = (unsigned int *)intf;
v5 = *(unsigned int *)intf;
++v6;
}
while ( (int)v5 > (int)v6 );
}
result = (unsigned int)YM2203Init(v5, v4[1], sample_rate, 0LL, 0LL) != 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
int v2; // edx
_BOOL8 result; // rax
unsigned int *v4; // rax
__int64 v5; // rdi
__int64 v6; // rbx
const char *v7; // rax
char v8[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = AY8910_sh_start_ym();
result = 1LL;
if ( !v2 )
{
v4 = *(unsigned int **)(a1 + 8);
intf = (__int64)v4;
v5 = *v4;
if ( (int)v5 > 0 )
{
v6 = 0LL;
do
{
v7 = (const char *)sound_name(a1);
sprintf(v8, "%s #%d FM", v7, (unsigned int)v6);
stream[v6] = stream_init(
v8,
(unsigned int)*(__int16 *)(intf + 4LL * (int)v6 + 10),
sample_rate,
(unsigned int)v6,
&YM2203UpdateOne);
v4 = (unsigned int *)intf;
v5 = *(unsigned int *)intf;
++v6;
}
while ( (int)v5 > (int)v6 );
}
result = (unsigned int)YM2203Init(v5, v4[1], sample_rate, 0LL, 0LL) != 0;
}
return result;
}

original_code:
int YM2203_sh_start(const struct MachineSound *msound)
{
 int i;
 if (AY8910_sh_start_ym(msound)) return 1;
 intf = msound->sound_interface;
 FMTimerInit();
 for (i = 0;i < intf->num;i++)
 {
  int volume;
  char name[20];
  sprintf(name,"%s #%d FM",sound_name(msound),i);
  volume = intf->mixing_level[i]>>16;
  stream[i] = stream_init(name,volume,sample_rate,i,YM2203UpdateOne );
 }
 if (YM2203Init(intf->num,intf->baseclock,sample_rate,0,0) == 0)
 {
  return 0;
 }
 return 1;
}

canonical_original_code:
int YM2203_sh_start(struct MachineSound *msound)
{
 int i;
 if (AY8910_sh_start_ym(msound)) return 1;
 intf = msound->sound_interface;
 FMTimerInit();
 for (i = 0;i < intf->num;i++)
 {
  int volume;
  char name[20];
  sprintf(name,"%s #%d FM",sound_name(msound),i);
  volume = intf->mixing_level[i]>>16;
  stream[i] = stream_init(name,volume,sample_rate,i,YM2203UpdateOne );
 }
 if (YM2203Init(intf->num,intf->baseclock,sample_rate,0,0) == 0)
 {
  return 0;
 }
 return 1;
}

variable_types: struct MachineSound { int sound_type; void *sound_interface; char *tag; } *

variable_types: i int

variable_types: volume int

variable_types:
name
char [20]


decompiled_code:
__int64 YM2203_sh_stop()
{
YM2203Shutdown();
return AY8910_sh_stop_ym();
}

canonical_decompiled_code:
__int64 func3()
{
YM2203Shutdown();
return AY8910_sh_stop_ym();
}

original_code:
void YM2203_sh_stop(void)
{
 YM2203Shutdown();
 AY8910_sh_stop_ym();
}

canonical_original_code:
void YM2203_sh_stop()
{
 YM2203Shutdown();
 AY8910_sh_stop_ym();
}


decompiled_code:
__int64 YM2203_sh_reset()
{
__int64 result; // rax
unsigned int v1; // ebx

result = intf;
if ( *(int *)intf > 0 )
{
v1 = 0;
do
{
YM2203ResetChip(v1++);
result = intf;
}
while ( *(_DWORD *)intf > (signed int)v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax
unsigned int v1; // ebx

result = intf;
if ( *(int *)intf > 0 )
{
v1 = 0;
do
{
YM2203ResetChip(v1++);
result = intf;
}
while ( *(_DWORD *)intf > (signed int)v1 );
}
return result;
}

original_code:
void YM2203_sh_reset(void)
{
 int i;
 for (i = 0;i < intf->num;i++)
  YM2203ResetChip(i);
}

canonical_original_code:
void YM2203_sh_reset()
{
 int i;
 for (i = 0;i < intf->num;i++)
  YM2203ResetChip(i);
}


decompiled_code:
__int64 YM2203_status_port_0_r()
{
return YM2203Read(0LL, 0LL);
}

canonical_decompiled_code:
__int64 func5()
{
return YM2203Read(0LL, 0LL);
}

original_code: data8_t YM2203_status_port_0_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(0,0); }

canonical_original_code: unsigned char YM2203_status_port_0_r(unsigned int offset) { return YM2203Read(0,0); }

variable_types:
offset
unsigned int


decompiled_code:
__int64 YM2203_status_port_1_r()
{
return YM2203Read(1LL, 0LL);
}

canonical_decompiled_code:
__int64 func6()
{
return YM2203Read(1LL, 0LL);
}

original_code: data8_t YM2203_status_port_1_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(1,0); }

canonical_original_code: unsigned char YM2203_status_port_1_r(unsigned int offset) { return YM2203Read(1,0); }


decompiled_code:
__int64 YM2203_status_port_2_r()
{
return YM2203Read(2LL, 0LL);
}

canonical_decompiled_code:
__int64 func7()
{
return YM2203Read(2LL, 0LL);
}

original_code: data8_t YM2203_status_port_2_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(2,0); }

canonical_original_code: unsigned char YM2203_status_port_2_r(unsigned int offset) { return YM2203Read(2,0); }


decompiled_code:
__int64 YM2203_status_port_3_r()
{
return YM2203Read(3LL, 0LL);
}

canonical_decompiled_code:
__int64 func8()
{
return YM2203Read(3LL, 0LL);
}

original_code: data8_t YM2203_status_port_3_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(3,0); }

canonical_original_code: unsigned char YM2203_status_port_3_r(unsigned int offset) { return YM2203Read(3,0); }


decompiled_code:
__int64 YM2203_status_port_4_r()
{
return YM2203Read(4LL, 0LL);
}

canonical_decompiled_code:
__int64 func9()
{
return YM2203Read(4LL, 0LL);
}

original_code: data8_t YM2203_status_port_4_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(4,0); }

canonical_original_code: unsigned char YM2203_status_port_4_r(unsigned int offset) { return YM2203Read(4,0); }


decompiled_code:
__int64 YM2203_read_port_0_r()
{
return YM2203Read(0LL, 1LL);
}

canonical_decompiled_code:
__int64 func10()
{
return YM2203Read(0LL, 1LL);
}

original_code: data8_t YM2203_read_port_0_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(0,1); }

canonical_original_code: unsigned char YM2203_read_port_0_r(unsigned int offset) { return YM2203Read(0,1); }


decompiled_code:
__int64 YM2203_read_port_1_r()
{
return YM2203Read(1LL, 1LL);
}

canonical_decompiled_code:
__int64 func11()
{
return YM2203Read(1LL, 1LL);
}

original_code: data8_t YM2203_read_port_1_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(1,1); }

canonical_original_code: unsigned char YM2203_read_port_1_r(unsigned int offset) { return YM2203Read(1,1); }


decompiled_code:
__int64 YM2203_read_port_2_r()
{
return YM2203Read(2LL, 1LL);
}

canonical_decompiled_code:
__int64 func12()
{
return YM2203Read(2LL, 1LL);
}

original_code: data8_t YM2203_read_port_2_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(2,1); }

canonical_original_code: unsigned char YM2203_read_port_2_r(unsigned int offset) { return YM2203Read(2,1); }


decompiled_code:
__int64 YM2203_read_port_3_r()
{
return YM2203Read(3LL, 1LL);
}

canonical_decompiled_code:
__int64 func13()
{
return YM2203Read(3LL, 1LL);
}

original_code: data8_t YM2203_read_port_3_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(3,1); }

canonical_original_code: unsigned char YM2203_read_port_3_r(unsigned int offset) { return YM2203Read(3,1); }


decompiled_code:
__int64 YM2203_read_port_4_r()
{
return YM2203Read(4LL, 1LL);
}

canonical_decompiled_code:
__int64 func14()
{
return YM2203Read(4LL, 1LL);
}

original_code: data8_t YM2203_read_port_4_r(__attribute__((__unused__)) offs_t offset) { return YM2203Read(4,1); }

canonical_original_code: unsigned char YM2203_read_port_4_r(unsigned int offset) { return YM2203Read(4,1); }


decompiled_code:
__int64 __fastcall YM2203_control_port_0_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(0LL, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(0LL, 0LL, a2);
}

original_code:
void YM2203_control_port_0_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(0,0,data);
}

canonical_original_code:
void YM2203_control_port_0_w(unsigned int offset, unsigned char data)
{
 YM2203Write(0,0,data);
}


decompiled_code:
__int64 __fastcall YM2203_control_port_1_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(1LL, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(1LL, 0LL, a2);
}

original_code:
void YM2203_control_port_1_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(1,0,data);
}

canonical_original_code:
void YM2203_control_port_1_w(unsigned int offset, unsigned char data)
{
 YM2203Write(1,0,data);
}


decompiled_code:
__int64 __fastcall YM2203_control_port_2_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(2LL, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(2LL, 0LL, a2);
}

original_code:
void YM2203_control_port_2_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(2,0,data);
}

canonical_original_code:
void YM2203_control_port_2_w(unsigned int offset, unsigned char data)
{
 YM2203Write(2,0,data);
}


decompiled_code:
__int64 __fastcall YM2203_control_port_3_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(3LL, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(3LL, 0LL, a2);
}

original_code:
void YM2203_control_port_3_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(3,0,data);
}

canonical_original_code:
void YM2203_control_port_3_w(unsigned int offset, unsigned char data)
{
 YM2203Write(3,0,data);
}


decompiled_code:
__int64 __fastcall YM2203_control_port_4_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(4LL, 0LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(4LL, 0LL, a2);
}

original_code:
void YM2203_control_port_4_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(4,0,data);
}

canonical_original_code:
void YM2203_control_port_4_w(unsigned int offset, unsigned char data)
{
 YM2203Write(4,0,data);
}


decompiled_code:
__int64 __fastcall YM2203_write_port_0_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(0LL, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(0LL, 1LL, a2);
}

original_code:
void YM2203_write_port_0_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(0,1,data);
}

canonical_original_code:
void YM2203_write_port_0_w(unsigned int offset, unsigned char data)
{
 YM2203Write(0,1,data);
}


decompiled_code:
__int64 __fastcall YM2203_write_port_1_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(1LL, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(1LL, 1LL, a2);
}

original_code:
void YM2203_write_port_1_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(1,1,data);
}

canonical_original_code:
void YM2203_write_port_1_w(unsigned int offset, unsigned char data)
{
 YM2203Write(1,1,data);
}


decompiled_code:
__int64 __fastcall YM2203_write_port_2_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(2LL, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(2LL, 1LL, a2);
}

original_code:
void YM2203_write_port_2_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(2,1,data);
}

canonical_original_code:
void YM2203_write_port_2_w(unsigned int offset, unsigned char data)
{
 YM2203Write(2,1,data);
}


decompiled_code:
__int64 __fastcall YM2203_write_port_3_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(3LL, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(3LL, 1LL, a2);
}

original_code:
void YM2203_write_port_3_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(3,1,data);
}

canonical_original_code:
void YM2203_write_port_3_w(unsigned int offset, unsigned char data)
{
 YM2203Write(3,1,data);
}


decompiled_code:
__int64 __fastcall YM2203_write_port_4_w(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(4LL, 1LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1, unsigned __int8 a2)
{
return YM2203Write(4LL, 1LL, a2);
}

original_code:
void YM2203_write_port_4_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 YM2203Write(4,1,data);
}

canonical_original_code:
void YM2203_write_port_4_w(unsigned int offset, unsigned char data)
{
 YM2203Write(4,1,data);
}


decompiled_code:
__int64 __fastcall YM2203_word_0_w(int a1, unsigned __int8 a2)
{
__int64 result; // rax

if ( a1 )
result = YM2203_write_port_0_w(0LL, a2);
else
result = YM2203_control_port_0_w(0LL, a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func25(int a1, unsigned __int8 a2)
{
__int64 result; // rax

if ( a1 )
result = func20(0LL, a2);
else
result = func15(0LL, a2);
return result;
}

original_code:
void YM2203_word_0_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 if (offset)
  YM2203_write_port_0_w(0,data);
 else
  YM2203_control_port_0_w(0,data);
}

canonical_original_code:
void YM2203_word_0_w(unsigned int offset, unsigned char data)
{
 if (offset)
  YM2203_write_port_0_w(0,data);
 else
  YM2203_control_port_0_w(0,data);
}


decompiled_code:
__int64 __fastcall YM2203_word_1_w(int a1, unsigned __int8 a2)
{
__int64 result; // rax

if ( a1 )
result = YM2203_write_port_1_w(0LL, a2);
else
result = YM2203_control_port_1_w(0LL, a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func26(int a1, unsigned __int8 a2)
{
__int64 result; // rax

if ( a1 )
result = func21(0LL, a2);
else
result = func16(0LL, a2);
return result;
}

original_code:
void YM2203_word_1_w(__attribute__((__unused__)) offs_t offset, __attribute__((__unused__)) data8_t data)
{
 if (offset)
  YM2203_write_port_1_w(0,data);
 else
  YM2203_control_port_1_w(0,data);
}

canonical_original_code:
void YM2203_word_1_w(unsigned int offset, unsigned char data)
{
 if (offset)
  YM2203_write_port_1_w(0,data);
 else
  YM2203_control_port_1_w(0,data);
}


decompiled_code:
__int64 pause_init()
{
status_message(0LL, 0LL, " PAUSE ");
status_message(1LL, 0LL, "<ESC> key to return");
status_message(2LL, 0LL, 0LL);
return draw_screen_force();
}

canonical_decompiled_code:
__int64 func0()
{
status_message(0LL, 0LL, " PAUSE ");
status_message(1LL, 0LL, "<ESC> key to return");
status_message(2LL, 0LL, 0LL);
return draw_screen_force();
}

original_code:
static void pause_init( void )
{
  status_message( 0, 0, " PAUSE " );
  status_message( 1, 0, "<ESC> key to return" );
  status_message( 2, 0, ((void *)0) );
  draw_screen_force();
}

canonical_original_code:
static void pause_init()
{
  status_message( 0, 0, " PAUSE " );
  status_message( 1, 0, "<ESC> key to return" );
  status_message( 2, 0, ((void *)0) );
  draw_screen_force();
}


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

if ( need_focus )
{
pause_by_focus_out = 1;
result = set_emu_mode(7LL);
}
return result;
}

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

if ( need_focus )
{
pause_by_focus_out = 1;
result = set_emu_mode(7LL);
}
return result;
}

original_code:
void pause_event_focus_out_when_exec( void )
{
  if( need_focus ){
    pause_by_focus_out = (1);
    set_emu_mode( PAUSE );
  }
}

canonical_original_code:
void pause_event_focus_out_when_exec()
{
  if( need_focus ){
    pause_by_focus_out = (1);
    set_emu_mode( PAUSE );
  }
}


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

if ( pause_by_focus_out )
result = set_emu_mode(1LL);
return result;
}

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

if ( pause_by_focus_out )
result = set_emu_mode(1LL);
return result;
}

original_code:
void pause_event_focus_in_when_pause( void )
{
  if( pause_by_focus_out ){
    set_emu_mode( GO );
  }
}

canonical_original_code:
void pause_event_focus_in_when_pause()
{
  if( pause_by_focus_out ){
    set_emu_mode( GO );
  }
}


decompiled_code:
__int64 pause_event_key_on_esc()
{
return set_emu_mode(1LL);
}

canonical_decompiled_code:
__int64 func3()
{
return set_emu_mode(1LL);
}

original_code:
void pause_event_key_on_esc( void )
{
  set_emu_mode( GO );
}

canonical_original_code:
void pause_event_key_on_esc()
{
  set_emu_mode( GO );
}


decompiled_code:
__int64 pause_event_key_on_menu()
{
return set_emu_mode(6LL);
}

canonical_decompiled_code:
__int64 func4()
{
return set_emu_mode(6LL);
}

original_code:
void pause_event_key_on_menu( void )
{
  set_emu_mode( MENU );
}

canonical_original_code:
void pause_event_key_on_menu()
{
  set_emu_mode( MENU );
}


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

pause_init();
while ( 1 )
{
result = next_emu_mode();
if ( (_DWORD)result != 7 )
break;
event_handle();
wait_menu();
}
pause_by_focus_out = 0;
return result;
}

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

func0();
while ( 1 )
{
result = next_emu_mode();
if ( (_DWORD)result != 7 )
break;
event_handle();
wait_menu();
}
pause_by_focus_out = 0;
return result;
}

original_code:
void pause_main( void )
{
  pause_init();
  while( next_emu_mode() == PAUSE ){
    event_handle();
    wait_menu();
  }
  pause_by_focus_out = (0);
}

canonical_original_code:
void pause_main()
{
  pause_init();
  while( next_emu_mode() == PAUSE ){
    event_handle();
    wait_menu();
  }
  pause_by_focus_out = (0);
}


decompiled_code:
int joystick_init()
{
int result; // eax

if ( use_joydevice && verbose_proc )
{
result = puts("\nJoystick not supported");
enable_joystick = 0;
}
else
{
enable_joystick = 0;
}
return result;
}

canonical_decompiled_code:
int func0()
{
int result; // eax

if ( use_joydevice && verbose_proc )
{
result = puts("\nJoystick not supported");
enable_joystick = 0;
}
else
{
enable_joystick = 0;
}
return result;
}

original_code:
void joystick_init( void )
{
  if( use_joydevice ){
    if( verbose_proc ) printf( "\nJoystick not supported\n" );
  }
  enable_joystick = (0);
}

canonical_original_code:
void joystick_init()
{
  if( use_joydevice ){
    if( verbose_proc ) printf( "\nJoystick not supported\n" );
  }
  enable_joystick = (0);
}


decompiled_code:
void joystick_term()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void joystick_term( void )
{
}

canonical_original_code:
void joystick_term()
{
}


decompiled_code:
void joystick_event()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void joystick_event( void )
{
}

canonical_original_code:
void joystick_event()
{
}


decompiled_code:
_BOOL8 check_break_point_PC()
{
__int64 i; // rax
int v1; // ecx
__int64 j; // rax
int v3; // edx

for ( i = 0LL; i != 10; ++i )
{
v1 = i;
if ( break_point[2 * i] == 1 )
break;
v1 = i + 1;
}
for ( j = 0LL; j != 10; ++j )
{
v3 = j;
if ( break_point[2 * j + 20] == 1 )
break;
v3 = j + 1;
}
return v3 != 10 || v1 != 10;
}

original_code:
static __inline__ int check_break_point_PC( void )
{
  int i, j;
  for( i=0; i<(10); i++ ) if( break_point[BP_MAIN][i].type == BP_PC ) break;
  for( j=0; j<(10); j++ ) if( break_point[BP_SUB][j].type == BP_PC ) break;
  if( i==(10) && j==(10) ) return (0);
  else return (1);
}

canonical_original_code:
static __inline__ int check_break_point_PC()
{
  int i; int j;
  for( i=0; i<(10); i++ ) if( break_point[BP_MAIN][i].type == BP_PC ) break;
  for( j=0; j<(10); j++ ) if( break_point[BP_SUB][j].type == BP_PC ) break;
  if( i==(10) && j==(10) ) return (0);
  else return (1);
}

variable_types: j int


decompiled_code:
__int64 emu_init()
{
status_message(0LL, 0xFFFFFFFFLL, 0LL);
status_message(1LL, 0xFFFFFFFFLL, 0LL);
status_message(2LL, 0xFFFFFFFFLL, 0LL);
return draw_screen_force();
}

canonical_decompiled_code:
__int64 func1()
{
status_message(0LL, 0xFFFFFFFFLL, 0LL);
status_message(1LL, 0xFFFFFFFFLL, 0LL);
status_message(2LL, 0xFFFFFFFFLL, 0LL);
return draw_screen_force();
}

original_code:
static void emu_init( void )
{
  status_message( 0, -1, ((void *)0) );
  status_message( 1, -1, ((void *)0) );
  status_message( 2, -1, ((void *)0) );
  draw_screen_force();
}

canonical_original_code:
static void emu_init()
{
  status_message( 0, -1, ((void *)0) );
  status_message( 1, -1, ((void *)0) );
  status_message( 2, -1, ((void *)0) );
  draw_screen_force();
}


decompiled_code:
__int64 __fastcall set_emu_mode(int a1)
{
__int64 result; // rax

if ( !a1 )
{
a1 = 1;
goto LABEL_5;
}
result = (unsigned int)(a1 - 1);
if ( (unsigned int)result <= 3 )
{
LABEL_5:
emu_mode_next = 0;
emu_mode_execute = a1;
goto LABEL_6;
}
emu_mode_next = a1;
emu_rest_step = 1;
LABEL_6:
z80_state_intchk = 0;
z80_state_goal = 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 result; // rax

if ( !a1 )
{
a1 = 1;
goto LABEL_5;
}
result = (unsigned int)(a1 - 1);
if ( (unsigned int)result <= 3 )
{
LABEL_5:
emu_mode_next = 0;
emu_mode_execute = a1;
goto LABEL_6;
}
emu_mode_next = a1;
emu_rest_step = 1;
LABEL_6:
z80_state_intchk = 0;
z80_state_goal = 1;
return result;
}

original_code:
void set_emu_mode( int mode )
{
  if( mode == EXEC ) mode = GO;
  if( mode == GO ||
      mode == STEP ||
      mode == TRACE ||
      mode == TRACE_CHANGE ){
    emu_mode_next = EXEC;
    emu_mode_execute = mode;
  }else{
    emu_mode_next = mode;
    emu_rest_step = 1;
  }
  do{ z80_state_intchk = 0; z80_state_goal = 1; }while(0);
}

canonical_original_code:
void set_emu_mode(int mode)
{
  if( mode == EXEC ) mode = GO;
  if( mode == GO ||
      mode == STEP ||
      mode == TRACE ||
      mode == TRACE_CHANGE ){
    emu_mode_next = EXEC;
    emu_mode_execute = mode;
  }else{
    emu_mode_next = mode;
    emu_rest_step = 1;
  }
  do{ z80_state_intchk = 0; z80_state_goal = 1; }while(0);
}

variable_types: mode int


decompiled_code:
__int64 emu_main()
{
__int64 (__fastcall *v0)(); // rbx
__int64 result; // rax
int v2; // er14
unsigned int v3; // ebp
int v4; // er13
__int64 v5; // rsi
int v6; // eax
__int64 v7; // rsi
int v8; // eax
int v9; // eax
int v10; // ebp

v0 = z80_emu_with_breakpoint;
if ( !check_break_point_PC() )
v0 = (__int64 (__fastcall *)())&z80_emu;
result = (unsigned int)emu_mode_execute;
if ( emu_mode_execute == 3 )
{
v2 = 1;
LABEL_59:
emu_rest_step = v2;
v3 = 1;
goto LABEL_60;
}
if ( emu_mode_execute == 4 )
{
emu_rest_step = 0;
v10 = select_main_cpu;
if ( cpu_timing > 0 )
{
puts("command 'trace change' can use when -cpu 0");
return set_emu_mode(5);
}
while ( 1 )
{
LODWORD(result) = select_main_cpu;
if ( select_main_cpu != v10 )
break;
if ( select_main_cpu )
((void (__fastcall *)(void *, __int64))v0)(&z80main_cpu, 1LL);
else
((void (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, 1LL);
v9 = emu_rest_step;
if ( emu_rest_step )
{
--emu_rest_step;
if ( v9 - 1 <= 0 )
{
result = (unsigned int)select_main_cpu;
if ( select_main_cpu == v10 )
return result;
break;
}
}
}
if ( !(_DWORD)result )
{
LABEL_19:
z80_debug(&z80sub_cpu, "[SUB CPU]\n");
return set_emu_mode(5);
}
LABEL_55:
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
return set_emu_mode(5);
}
v2 = trace_counter;
if ( emu_mode_execute == 2 )
goto LABEL_59;
emu_rest_step = 0;
if ( emu_mode_execute <= 3 && emu_mode_execute > 0 )
{
v3 = 0;
v2 = 0;
LABEL_60:
v4 = cpu_timing;
if ( cpu_timing == 1 )
{
v4 = 0;
while ( 1 )
{
if ( dual_cpu_count )
{
((void (__fastcall *)(void *, __int64))v0)(&z80main_cpu, 1LL);
((void (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, 1LL);
--dual_cpu_count;
}
else
{
((void (__fastcall *)(void *, _QWORD))v0)(&z80main_cpu, v3);
}
if ( emu_rest_step )
{
++v4;
result = (unsigned int)(emu_rest_step - 1);
emu_rest_step = result;
if ( (int)result <= 0 )
break;
}
}
LABEL_15:
if ( emu_mode_execute == 1 || v4 < v2 )
return result;
if ( cpu_timing == 1 )
{
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
if ( !dual_cpu_count )
return set_emu_mode(5);
goto LABEL_19;
}
if ( cpu_timing == 2 )
{
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
z80_debug(&z80sub_cpu, "[SUB CPU]\n");
return set_emu_mode(5);
}
if ( cpu_timing )
return set_emu_mode(5);
if ( !select_main_cpu )
goto LABEL_19;
goto LABEL_55;
}
if ( cpu_timing != 2 )
{
if ( cpu_timing )
{
if ( emu_mode_execute == 1 || v2 > 0 )
return result;
return set_emu_mode(5);
}
while ( 1 )
{
if ( select_main_cpu )
((void (__fastcall *)(void *, _QWORD))v0)(&z80main_cpu, v3);
else
((void (__fastcall *)(void *, _QWORD))v0)(&z80sub_cpu, v3);
if ( emu_rest_step )
{
++v4;
result = (unsigned int)(emu_rest_step - 1);
emu_rest_step = result;
if ( (int)result <= 0 )
break;
}
}
goto LABEL_15;
}
v4 = 0;
while ( 1 )
{
v8 = main_state;
if ( main_state > 255 )
goto LABEL_28;
if ( sub_state > 255 )
{
v6 = sub_state;
LABEL_32:
v7 = v3;
if ( !v3 )
v7 = (unsigned int)(v6 / 256);
sub_state -= ((unsigned int (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, v7) << 8;
goto LABEL_35;
}
v8 = (int)((double)cpu_slice_us * cpu_clock_mhz * 256.0 + (double)main_state);
main_state = v8;
sub_state = (int)((double)cpu_slice_us * 3.9936 * 256.0 + (double)sub_state);
if ( v8 > 255 )
{
LABEL_28:
v5 = v3;
if ( !v3 )
v5 = (unsigned int)(v8 / 256);
main_state -= ((unsigned int (__fastcall *)(void *, __int64))v0)(&z80main_cpu, v5) << 8;
}
v6 = sub_state;
if ( sub_state > 255 )
goto LABEL_32;
LABEL_35:
if ( emu_rest_step )
{
++v4;
result = (unsigned int)(emu_rest_step - 1);
emu_rest_step = result;
if ( (int)result <= 0 )
goto LABEL_15;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 (__fastcall *v0)(); // rbx
__int64 result; // rax
int v2; // er14
unsigned int v3; // ebp
int v4; // er13
__int64 v5; // rsi
int v6; // eax
__int64 v7; // rsi
int v8; // eax
int v9; // eax
int v10; // ebp

v0 = z80_emu_with_breakpoint;
if ( !func0() )
v0 = (__int64 (__fastcall *)())&z80_emu;
result = (unsigned int)emu_mode_execute;
if ( emu_mode_execute == 3 )
{
v2 = 1;
LABEL_59:
emu_rest_step = v2;
v3 = 1;
goto LABEL_60;
}
if ( emu_mode_execute == 4 )
{
emu_rest_step = 0;
v10 = select_main_cpu;
if ( cpu_timing > 0 )
{
puts("command 'trace change' can use when -cpu 0");
return func2(5);
}
while ( 1 )
{
LODWORD(result) = select_main_cpu;
if ( select_main_cpu != v10 )
break;
if ( select_main_cpu )
((void (__fastcall *)(void *, __int64))v0)(&z80main_cpu, 1LL);
else
((void (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, 1LL);
v9 = emu_rest_step;
if ( emu_rest_step )
{
--emu_rest_step;
if ( v9 - 1 <= 0 )
{
result = (unsigned int)select_main_cpu;
if ( select_main_cpu == v10 )
return result;
break;
}
}
}
if ( !(_DWORD)result )
{
LABEL_19:
z80_debug(&z80sub_cpu, "[SUB CPU]\n");
return func2(5);
}
LABEL_55:
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
return func2(5);
}
v2 = trace_counter;
if ( emu_mode_execute == 2 )
goto LABEL_59;
emu_rest_step = 0;
if ( emu_mode_execute <= 3 && emu_mode_execute > 0 )
{
v3 = 0;
v2 = 0;
LABEL_60:
v4 = cpu_timing;
if ( cpu_timing == 1 )
{
v4 = 0;
while ( 1 )
{
if ( dual_cpu_count )
{
((void (__fastcall *)(void *, __int64))v0)(&z80main_cpu, 1LL);
((void (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, 1LL);
--dual_cpu_count;
}
else
{
((void (__fastcall *)(void *, _QWORD))v0)(&z80main_cpu, v3);
}
if ( emu_rest_step )
{
++v4;
result = (unsigned int)(emu_rest_step - 1);
emu_rest_step = result;
if ( (int)result <= 0 )
break;
}
}
LABEL_15:
if ( emu_mode_execute == 1 || v4 < v2 )
return result;
if ( cpu_timing == 1 )
{
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
if ( !dual_cpu_count )
return func2(5);
goto LABEL_19;
}
if ( cpu_timing == 2 )
{
z80_debug(&z80main_cpu, "[MAIN CPU]\n");
z80_debug(&z80sub_cpu, "[SUB CPU]\n");
return func2(5);
}
if ( cpu_timing )
return func2(5);
if ( !select_main_cpu )
goto LABEL_19;
goto LABEL_55;
}
if ( cpu_timing != 2 )
{
if ( cpu_timing )
{
if ( emu_mode_execute == 1 || v2 > 0 )
return result;
return func2(5);
}
while ( 1 )
{
if ( select_main_cpu )
((void (__fastcall *)(void *, _QWORD))v0)(&z80main_cpu, v3);
else
((void (__fastcall *)(void *, _QWORD))v0)(&z80sub_cpu, v3);
if ( emu_rest_step )
{
++v4;
result = (unsigned int)(emu_rest_step - 1);
emu_rest_step = result;
if ( (int)result <= 0 )
break;
}
}
goto LABEL_15;
}
v4 = 0;
while ( 1 )
{
v8 = main_state;
if ( main_state > 255 )
goto LABEL_28;
if ( sub_state > 255 )
{
v6 = sub_state;
LABEL_32:
v7 = v3;
if ( !v3 )
v7 = (unsigned int)(v6 / 256);
sub_state -= ((unsigned int (__fastcall *)(void *, __int64))v0)(&z80sub_cpu, v7) << 8;
goto LABEL_35;
}
v8 = (int)((double)cpu_slice_us * cpu_clock_mhz * 256.0 + (double)main_state);
main_state = v8;
sub_state = (int)((double)cpu_slice_us * 3.9936 * 256.0 + (double)sub_state);
if ( v8 > 255 )
{
LABEL_28:
v5 = v3;
if ( !v3 )
v5 = (unsigned int)(v8 / 256);
main_state -= ((unsigned int (__fastcall *)(void *, __int64))v0)(&z80main_cpu, v5) << 8;
}
v6 = sub_state;
if ( sub_state > 255 )
goto LABEL_32;
LABEL_35:
if ( emu_rest_step )
{
++v4;
result = (unsigned int)(emu_rest_step - 1);
emu_rest_step = result;
if ( (int)result <= 0 )
goto LABEL_15;
}
}
}
return result;
}

original_code:
static void emu_main( void )
{
  int passed_step;
  int target_step;
  int infinity, only_1step;
  int wk;
  int (*z80_exec)( z80arch *, int );
  if( check_break_point_PC() ) z80_exec = z80_emu_with_breakpoint;
  else z80_exec = z80_emu;
  passed_step = 0;
  switch( emu_mode_execute ){
  default:
  case GO:
    target_step = 0;
    infinity = (0);
    only_1step = (1);
    break;
  case TRACE:
    target_step = trace_counter;
    infinity = (1);
    only_1step = (1);
    break;
  case STEP:
    target_step = 1;
    infinity = (1);
    only_1step = (1);
    break;
  case TRACE_CHANGE:
    target_step = 0;
    infinity = (1);
    only_1step = (1);
    break;
  }
  emu_rest_step = target_step;
  switch( emu_mode_execute ){
  case GO:
  case TRACE:
  case STEP:
    switch( cpu_timing ){
    case 0:
      for(;;){
 if( select_main_cpu ) (z80_exec)( &z80main_cpu, infinity );
 else (z80_exec)( &z80sub_cpu, infinity );
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    case 1:
      for(;;){
 if( dual_cpu_count==0 ) (z80_exec)( &z80main_cpu, infinity );
 else{
   (z80_exec)( &z80main_cpu, only_1step );
   (z80_exec)( &z80sub_cpu, only_1step );
   dual_cpu_count --;
 }
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    case 2:
      for(;;){
 if( main_state < 1*(256) && sub_state < 1*(256) ){
   main_state += (cpu_clock_mhz * cpu_slice_us) * (256);
   sub_state += (3.9936 * cpu_slice_us) * (256);
 }
 if( main_state >= 1*(256) ){
   wk = (infinity==(0)) ? main_state/(256) : (1);
   main_state -= (z80_exec( &z80main_cpu, wk ) ) * (256);
 }
 if( sub_state >= 1*(256) ){
   wk = (infinity==(0)) ? sub_state/(256) : (1);
   sub_state -= (z80_exec( &z80sub_cpu, wk ) ) * (256);
 }
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    }
    if( emu_mode_execute != GO ){
      if( passed_step >= target_step ){
 switch( cpu_timing ){
 case 0:
   if( select_main_cpu ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 case 1:
                        z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   if( dual_cpu_count ) z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 case 2:
   z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 }
 set_emu_mode( MONITOR );
      }
    }
    break;
    case TRACE_CHANGE:
      if( cpu_timing >= 1 ){
 printf( "command 'trace change' can use when -cpu 0\n");
 set_emu_mode( MONITOR );
 break;
      }
      wk = select_main_cpu;
      while( wk==select_main_cpu ){
 if( select_main_cpu ) (z80_exec)( &z80main_cpu, infinity );
 else (z80_exec)( &z80sub_cpu, infinity );
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      if( wk != select_main_cpu ){
 if( select_main_cpu ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
 else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
 set_emu_mode( MONITOR );
      }
      break;
  }
}

canonical_original_code:
static void emu_main()
{
  int passed_step;
  int target_step;
  int infinity; int only_1step;
  int wk;
  int (*z80_exec)(struct z80arch *, int);
  if( check_break_point_PC() ) z80_exec = z80_emu_with_breakpoint;
  else z80_exec = z80_emu;
  passed_step = 0;
  switch( emu_mode_execute ){
  default:
  case GO:
    target_step = 0;
    infinity = (0);
    only_1step = (1);
    break;
  case TRACE:
    target_step = trace_counter;
    infinity = (1);
    only_1step = (1);
    break;
  case STEP:
    target_step = 1;
    infinity = (1);
    only_1step = (1);
    break;
  case TRACE_CHANGE:
    target_step = 0;
    infinity = (1);
    only_1step = (1);
    break;
  }
  emu_rest_step = target_step;
  switch( emu_mode_execute ){
  case GO:
  case TRACE:
  case STEP:
    switch( cpu_timing ){
    case 0:
      for(;;){
 if( select_main_cpu ) (z80_exec)( &z80main_cpu, infinity );
 else (z80_exec)( &z80sub_cpu, infinity );
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    case 1:
      for(;;){
 if( dual_cpu_count==0 ) (z80_exec)( &z80main_cpu, infinity );
 else{
   (z80_exec)( &z80main_cpu, only_1step );
   (z80_exec)( &z80sub_cpu, only_1step );
   dual_cpu_count --;
 }
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    case 2:
      for(;;){
 if( main_state < 1*(256) && sub_state < 1*(256) ){
   main_state += (cpu_clock_mhz * cpu_slice_us) * (256);
   sub_state += (3.9936 * cpu_slice_us) * (256);
 }
 if( main_state >= 1*(256) ){
   wk = (infinity==(0)) ? main_state/(256) : (1);
   main_state -= (z80_exec( &z80main_cpu, wk ) ) * (256);
 }
 if( sub_state >= 1*(256) ){
   wk = (infinity==(0)) ? sub_state/(256) : (1);
   sub_state -= (z80_exec( &z80sub_cpu, wk ) ) * (256);
 }
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      break;
    }
    if( emu_mode_execute != GO ){
      if( passed_step >= target_step ){
 switch( cpu_timing ){
 case 0:
   if( select_main_cpu ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 case 1:
                        z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   if( dual_cpu_count ) z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 case 2:
   z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
   z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
   break;
 }
 set_emu_mode( MONITOR );
      }
    }
    break;
    case TRACE_CHANGE:
      if( cpu_timing >= 1 ){
 printf( "command 'trace change' can use when -cpu 0\n");
 set_emu_mode( MONITOR );
 break;
      }
      wk = select_main_cpu;
      while( wk==select_main_cpu ){
 if( select_main_cpu ) (z80_exec)( &z80main_cpu, infinity );
 else (z80_exec)( &z80sub_cpu, infinity );
 if( emu_rest_step ){
   passed_step ++;
   if( -- emu_rest_step <= 0 ) break;
 }
      }
      if( wk != select_main_cpu ){
 if( select_main_cpu ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
 else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
 set_emu_mode( MONITOR );
      }
      break;
  }
}

variable_types: infinity int

variable_types: wk int

variable_types: int (*)(struct z80arch { union pair { struct { unsigned char l; } B; unsigned short W; } AF; union pair IX; union pair AF1; unsigned char I; unsigned char R_saved; unsigned char IFF; unsigned char IM; unsigned char HALT; int INT_active; int icount; int state0; int skip_intr_chk; unsigned char log; unsigned char break_if_halt; unsigned char (*fetch)(unsigned short); unsigned char (*mem_read)(unsigned short); void (*mem_write)(unsigned short, unsigned char); unsigned char (*io_read)(unsigned char); void (*io_write)(unsigned char, unsigned char); void (*intr_update)(); int (*intr_ack)(); union pair PC_prev; } *, int)

user_defined_types: struct z80arch { union pair AF; union pair IX; union pair AF1; unsigned char I; unsigned char R_saved; unsigned char IFF; unsigned char IM; unsigned char HALT; int INT_active; int icount; int state0; int skip_intr_chk; unsigned char log; unsigned char break_if_halt; unsigned char (*fetch)(unsigned short); unsigned char (*mem_read)(unsigned short); void (*mem_write)(unsigned short, unsigned char); unsigned char (*io_read)(unsigned char); void (*io_write)(unsigned char, unsigned char); void (*intr_update)(); int (*intr_ack)(); union pair PC_prev; }


decompiled_code:
__int64 __fastcall z80_emu_with_breakpoint(unsigned __int16 *a1)
{
unsigned int v1; // er13
__int64 v2; // rbp
__int64 i; // rbx
__int64 v4; // rcx

v1 = z80_emu(a1, 1LL);
v2 = 20LL * (a1 != z80main_cpu);
for ( i = 0LL; i != 10; ++i )
{
if ( break_point[2 * i + v2] == 1 && break_point[2 * i + 1 + v2] == a1[6] )
{
if ( (_DWORD)i == 9 )
break_point[20 * (a1 != z80main_cpu) + 18] = 0;
v4 = (unsigned int)(i + 1);
if ( a1 == z80main_cpu )
{
printf("*** Break at %04x *** ( %s[#%d] : PC )\n", z80main_cpu[6], "MAIN", v4);
z80_debug(z80main_cpu, "[MAIN CPU]\n");
}
else
{
printf("*** Break at %04x *** ( %s[#%d] : PC )\n", a1[6], "SUB", v4);
z80_debug(&z80sub_cpu, "[SUB CPU]\n");
}
set_emu_mode(5);
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int16 *a1)
{
unsigned int v1; // er13
__int64 v2; // rbp
__int64 i; // rbx
__int64 v4; // rcx

v1 = z80_emu(a1, 1LL);
v2 = 20LL * (a1 != z80main_cpu);
for ( i = 0LL; i != 10; ++i )
{
if ( break_point[2 * i + v2] == 1 && break_point[2 * i + 1 + v2] == a1[6] )
{
if ( (_DWORD)i == 9 )
break_point[20 * (a1 != z80main_cpu) + 18] = 0;
v4 = (unsigned int)(i + 1);
if ( a1 == z80main_cpu )
{
printf("*** Break at %04x *** ( %s[#%d] : PC )\n", z80main_cpu[6], "MAIN", v4);
z80_debug(z80main_cpu, "[MAIN CPU]\n");
}
else
{
printf("*** Break at %04x *** ( %s[#%d] : PC )\n", a1[6], "SUB", v4);
z80_debug(&z80sub_cpu, "[SUB CPU]\n");
}
func2(5);
}
}
return v1;
}

original_code:
static int z80_emu_with_breakpoint( z80arch *z80, int unused )
{
  int i, cpu, states;
  states = z80_emu( z80, 1 );
  if( z80==&z80main_cpu ) cpu = BP_MAIN;
  else cpu = BP_SUB;
  for( i=0; i<(10); i++ ){
    if( break_point[cpu][i].type == BP_PC &&
 break_point[cpu][i].addr == z80->PC.W ){
      if( i==(9) ){
 break_point[cpu][i].type = BP_NONE;
      }
      printf( "*** Break at %04x *** ( %s[#%d] : PC )\n",
       z80->PC.W, (cpu==BP_MAIN)?"MAIN":"SUB", i+1 );
      if( cpu==BP_MAIN ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
      else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
      set_emu_mode( MONITOR );
    }
  }
  return states;
}

canonical_original_code:
static int z80_emu_with_breakpoint(struct z80arch *z80, int unused)
{
  int i; int cpu; int states;
  states = z80_emu( z80, 1 );
  if( z80==&z80main_cpu ) cpu = BP_MAIN;
  else cpu = BP_SUB;
  for( i=0; i<(10); i++ ){
    if( break_point[cpu][i].type == BP_PC &&
 break_point[cpu][i].addr == z80->PC.W ){
      if( i==(9) ){
 break_point[cpu][i].type = BP_NONE;
      }
      printf( "*** Break at %04x *** ( %s[#%d] : PC )\n",
       z80->PC.W, (cpu==BP_MAIN)?"MAIN":"SUB", i+1 );
      if( cpu==BP_MAIN ) z80_debug( &z80main_cpu, "[MAIN CPU]\n" );
      else z80_debug( &z80sub_cpu, "[SUB CPU]\n" );
      set_emu_mode( MONITOR );
    }
  }
  return states;
}

variable_types: struct z80arch { union pair { struct { unsigned char l; } B; unsigned short W; } AF; union pair IX; union pair AF1; unsigned char I; unsigned char R_saved; unsigned char IFF; unsigned char IM; unsigned char HALT; int INT_active; int icount; int state0; int skip_intr_chk; unsigned char log; unsigned char break_if_halt; unsigned char (*fetch)(unsigned short); unsigned char (*mem_read)(unsigned short); void (*mem_write)(unsigned short, unsigned char); unsigned char (*io_read)(unsigned char); void (*io_write)(unsigned char, unsigned char); void (*intr_update)(); int (*intr_ack)(); union pair PC_prev; } *

variable_types: unused int

variable_types: cpu int

variable_types: states int


decompiled_code:
__int64 get_emu_mode()
{
return (unsigned int)emu_mode;
}

canonical_decompiled_code:
__int64 func5()
{
return (unsigned int)emu_mode;
}

original_code:
int get_emu_mode( void )
{
  return emu_mode;
}

canonical_original_code:
int get_emu_mode()
{
  return emu_mode;
}


decompiled_code:
__int64 next_emu_mode()
{
return (unsigned int)emu_mode_next;
}

canonical_decompiled_code:
__int64 func6()
{
return (unsigned int)emu_mode_next;
}

original_code:
int next_emu_mode( void )
{
  return emu_mode_next;
}

canonical_original_code:
int next_emu_mode()
{
  return emu_mode_next;
}


decompiled_code:
void emu_reset()
{
select_main_cpu = 1;
dual_cpu_count = 0;
main_state = 0;
sub_state = 0;
}

canonical_decompiled_code:
void func7()
{
select_main_cpu = 1;
dual_cpu_count = 0;
main_state = 0;
sub_state = 0;
}

original_code:
void emu_reset( void )
{
  select_main_cpu = (1);
  dual_cpu_count = 0;
  main_state = 0;
  sub_state = 0;
}

canonical_original_code:
void emu_reset()
{
  select_main_cpu = (1);
  dual_cpu_count = 0;
  main_state = 0;
  sub_state = 0;
}


emu

decompiled_code:
__int64 emu()
{
__int16 *v0; // rax
unsigned __int64 v1; // rax
_WORD *v2; // rax
__int64 result; // rax

v0 = break_point;
do
{
*v0 = 0;
v0 += 2;
}
while ( v0 != (__int16 *)(unsigned int)((_DWORD)break_point + 40) );
v1 = (unsigned int)((_DWORD)break_point + 40);
do
{
*(_WORD *)v1 = 0;
v1 += 4LL;
}
while ( v1 != (_DWORD)break_point + 80 );
v2 = &break_point_fdc;
do
{
*v2 = 0;
v2 += 4;
}
while ( (_WORD *)(unsigned int)((_DWORD)&break_point_fdc + 80) != v2 );
while ( 1 )
{
if ( emu_mode != emu_mode_next )
{
emu_mode = emu_mode_next;
if ( !emu_mode_next )
emu_init();
}
wait_vsync_reset();
result = (unsigned int)emu_mode;
switch ( emu_mode )
{
case 0:
set_window_title("QUASI88 ver 0.6.3");
xmame_sound_resume();
event_init();
keyboard_start();
emu_main();
break;
case 5:
set_emu_mode(7);
break;
case 6:
set_window_title("QUASI88 ver 0.6.3");
xmame_sound_suspend();
event_init();
keyboard_stop();
menu_main();
break;
case 7:
set_window_title("QUASI88 (PAUSE)");
xmame_sound_suspend();
event_init();
keyboard_stop();
pause_main();
break;
case 8:
return result;
default:
continue;
}
}
}

canonical_decompiled_code:
__int64 func8()
{
__int16 *v0; // rax
unsigned __int64 v1; // rax
_WORD *v2; // rax
__int64 result; // rax

v0 = break_point;
do
{
*v0 = 0;
v0 += 2;
}
while ( v0 != (__int16 *)(unsigned int)((_DWORD)break_point + 40) );
v1 = (unsigned int)((_DWORD)break_point + 40);
do
{
*(_WORD *)v1 = 0;
v1 += 4LL;
}
while ( v1 != (_DWORD)break_point + 80 );
v2 = &break_point_fdc;
do
{
*v2 = 0;
v2 += 4;
}
while ( (_WORD *)(unsigned int)((_DWORD)&break_point_fdc + 80) != v2 );
while ( 1 )
{
if ( emu_mode != emu_mode_next )
{
emu_mode = emu_mode_next;
if ( !emu_mode_next )
func1();
}
wait_vsync_reset();
result = (unsigned int)emu_mode;
switch ( emu_mode )
{
case 0:
set_window_title("QUASI88 ver 0.6.3");
xmame_sound_resume();
event_init();
keyboard_start();
func3();
break;
case 5:
func2(7);
break;
case 6:
set_window_title("QUASI88 ver 0.6.3");
xmame_sound_suspend();
event_init();
keyboard_stop();
menu_main();
break;
case 7:
set_window_title("QUASI88 (PAUSE)");
xmame_sound_suspend();
event_init();
keyboard_stop();
pause_main();
break;
case 8:
return result;
default:
continue;
}
}
}

original_code:
void emu( void )
{
  int i, j;
  for( j=0; j<2; j++ )
    for( i=0; i<(10); i++ )
      break_point[j][i].type = BP_NONE;
  for( i=0; i<(10); i++ )
    break_point_fdc[i].type = BP_NONE;
  for( ;; ){
    if( emu_mode != emu_mode_next ){
      emu_mode = emu_mode_next;
      if( emu_mode == EXEC ){
 emu_init();
      }
    }
    wait_vsync_reset();
    switch( emu_mode ){
    case EXEC:
      set_window_title( "QUASI88" " ver " "0.6.3" );
      xmame_sound_resume();
      event_init();
      keyboard_start();
      emu_main();
      break;
    case MONITOR:
      set_emu_mode( PAUSE );
      break;
    case MENU:
      set_window_title( "QUASI88" " ver " "0.6.3" );
      xmame_sound_suspend();
      event_init();
      keyboard_stop();
      menu_main();
      break;
    case PAUSE:
      set_window_title( "QUASI88" " (PAUSE)" );
      xmame_sound_suspend();
      event_init();
      keyboard_stop();
      pause_main();
      break;
    case QUIT:
      return;
    }
  }
}

canonical_original_code:
void emu()
{
  int i; int j;
  for( j=0; j<2; j++ )
    for( i=0; i<(10); i++ )
      break_point[j][i].type = BP_NONE;
  for( i=0; i<(10); i++ )
    break_point_fdc[i].type = BP_NONE;
  for( ;; ){
    if( emu_mode != emu_mode_next ){
      emu_mode = emu_mode_next;
      if( emu_mode == EXEC ){
 emu_init();
      }
    }
    wait_vsync_reset();
    switch( emu_mode ){
    case EXEC:
      set_window_title( "QUASI88" " ver " "0.6.3" );
      xmame_sound_resume();
      event_init();
      keyboard_start();
      emu_main();
      break;
    case MONITOR:
      set_emu_mode( PAUSE );
      break;
    case MENU:
      set_window_title( "QUASI88" " ver " "0.6.3" );
      xmame_sound_suspend();
      event_init();
      keyboard_stop();
      menu_main();
      break;
    case PAUSE:
      set_window_title( "QUASI88" " (PAUSE)" );
      xmame_sound_suspend();
      event_init();
      keyboard_stop();
      pause_main();
      break;
    case QUIT:
      return;
    }
  }
}


decompiled_code:
_BOOL8 statesave_emu()
{
return (unsigned int)statesave_table("EMU ", &suspend_emu_work) == 0;
}

canonical_decompiled_code:
_BOOL8 func9()
{
return (unsigned int)statesave_table("EMU ", &suspend_emu_work) == 0;
}

original_code:
int statesave_emu( void )
{
  if( statesave_table( "EMU ", suspend_emu_work ) == (0) ) return (1);
  else return (0);
}

canonical_original_code:
int statesave_emu()
{
  if( statesave_table( "EMU ", suspend_emu_work ) == (0) ) return (1);
  else return (0);
}


decompiled_code:
_BOOL8 stateload_emu()
{
return (unsigned int)stateload_table("EMU ", &suspend_emu_work) == 0;
}

canonical_decompiled_code:
_BOOL8 func10()
{
return (unsigned int)stateload_table("EMU ", &suspend_emu_work) == 0;
}

original_code:
int stateload_emu( void )
{
  if( stateload_table( "EMU ", suspend_emu_work ) == (0) ) return (1);
  else return (0);
  set_emu_mode( EXEC );
}

canonical_original_code:
int stateload_emu()
{
  if( stateload_table( "EMU ", suspend_emu_work ) == (0) ) return (1);
  else return (0);
  set_emu_mode( EXEC );
}


decompiled_code:
__int64 __fastcall sound_set_options(__int64 a1, __int64 a2, int a3)
{
if ( use_sound )
sample_rate = sound_samplerate;
else
sample_rate = sound_fake != 0 ? 0x1F40 : 0;
*(_DWORD *)(a1 + 64) = a3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
if ( use_sound )
sample_rate = sound_samplerate;
else
sample_rate = sound_fake != 0 ? 0x1F40 : 0;
*(_DWORD *)(a1 + 64) = a3;
return 0LL;
}

original_code:
static int sound_set_options(struct rc_option *option, const char *arg,
   int priority)
{
  if(use_sound)
  {
     sample_rate = sound_samplerate;
  }
  else if(sound_fake)
  {
     sample_rate = 8000;
  }
  else
     sample_rate = 0;
  option->priority = priority;
  return 0;
}

canonical_original_code:
static int sound_set_options(struct rc_option *option, char *arg, int priority)
{
  if(use_sound)
  {
     sample_rate = sound_samplerate;
  }
  else if(sound_fake)
  {
     sample_rate = 8000;
  }
  else
     sample_rate = 0;
  option->priority = priority;
  return 0;
}

variable_types: struct rc_option { char *name; char *shortname; int type; void *dest; char *deflt; float min; float max; int (*func)(struct rc_option *option, char *arg, int priority); char *help; int priority; } *

variable_types:
arg
char *

variable_types: priority int


decompiled_code:
_BOOL8 osd_has_sound_mixer()
{
return sound_mixer != 0;
}

canonical_decompiled_code:
_BOOL8 func1()
{
return sound_mixer != 0;
}

original_code: int osd_has_sound_mixer(void){ return (sound_mixer) ? 1 : 0; }

canonical_original_code: int osd_has_sound_mixer(){ return (sound_mixer) ? 1 : 0; }


decompiled_code:
__int64 __fastcall osd_set_mastervolume(int a1)
{
__int64 result; // rax
float v2; // xmm0_4

result = sound_mixer;
if ( sound_mixer )
{
v2 = (float)((float)((float)((float)a1 + 32.0) * 100.0) * 0.03125) + 0.5;
result = sysdep_mixer_set(sound_mixer, 1LL, (unsigned int)(int)v2, (unsigned int)(int)v2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 result; // rax
float v2; // xmm0_4

result = sound_mixer;
if ( sound_mixer )
{
v2 = (float)((float)((float)((float)a1 + 32.0) * 100.0) * 0.03125) + 0.5;
result = sysdep_mixer_set(sound_mixer, 1LL, (unsigned int)(int)v2, (unsigned int)(int)v2);
}
return result;
}

original_code:
void osd_set_mastervolume (int attenuation)
{
   float f = attenuation;
   if(!sound_mixer)
      return;
   f += 32.0;
   f *= 100.0;
   f /= 32.0;
   f += 0.50;
   sysdep_mixer_set(sound_mixer, 1, f, f);
}

canonical_original_code:
void osd_set_mastervolume(int attenuation)
{
   float f = attenuation;
   if(!sound_mixer)
      return;
   f += 32.0;
   f *= 100.0;
   f /= 32.0;
   f += 0.50;
   sysdep_mixer_set(sound_mixer, 1, f, f);
}

variable_types: attenuation int

variable_types: f float


decompiled_code:
__int64 osd_get_mastervolume()
{
char v1[4]; // [rsp+0h] [rbp-10h] BYREF
int v2[3]; // [rsp+4h] [rbp-Ch] BYREF

if ( !sound_mixer )
return 4294967264LL;
if ( (unsigned int)sysdep_mixer_get(sound_mixer, 1LL, v2, v1) )
return 4294967264LL;
return (unsigned int)(int)(float)((float)((float)((float)v2[0] * 32.0) / 100.0) - 32.5);
}

canonical_decompiled_code:
__int64 func3()
{
char v1[4]; // [rsp+0h] [rbp-10h] BYREF
int v2[3]; // [rsp+4h] [rbp-Ch] BYREF

if ( !sound_mixer )
return 4294967264LL;
if ( (unsigned int)sysdep_mixer_get(sound_mixer, 1LL, v2, v1) )
return 4294967264LL;
return (unsigned int)(int)(float)((float)((float)((float)v2[0] * 32.0) / 100.0) - 32.5);
}

original_code:
int osd_get_mastervolume (void)
{
   int left, right;
   float f;
   if(!sound_mixer)
      return -32;
   if(sysdep_mixer_get(sound_mixer, 1, &left, &right))
      return -32;
   f = left;
   f *= 32.0;
   f /= 100.0;
   f -= 32.5;
   return f;
}

canonical_original_code:
int osd_get_mastervolume()
{
   int left; int right;
   float f;
   if(!sound_mixer)
      return -32;
   if(sysdep_mixer_get(sound_mixer, 1, &left, &right))
      return -32;
   f = left;
   f *= 32.0;
   f /= 100.0;
   f -= 32.5;
   return f;
}

variable_types: left int

variable_types: right int


decompiled_code:
__int64 __fastcall osd_update_audio_stream(__int64 a1)
{
if ( use_sound )
sound_stream_write(sound_stream, a1, (unsigned int)sound_samples_per_frame);
return (unsigned int)sound_samples_per_frame;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
if ( use_sound )
sound_stream_write(sound_stream, a1, (unsigned int)sound_samples_per_frame);
return (unsigned int)sound_samples_per_frame;
}

original_code:
int osd_update_audio_stream(INT16 *buffer)
{
   if (use_sound)
      sound_stream_write(sound_stream, (unsigned char *)buffer,
         sound_samples_per_frame);
   return sound_samples_per_frame;
}

canonical_original_code:
int osd_update_audio_stream(short *buffer)
{
   if (use_sound)
      sound_stream_write(sound_stream, (unsigned char *)buffer,
         sound_samples_per_frame);
   return sound_samples_per_frame;
}

variable_types:
buffer
short *


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

if ( sound_stream )
result = sound_stream_destroy();
if ( sound_dsp )
result = sysdep_dsp_destroy();
if ( sound_mixer )
result = sysdep_mixer_destroy();
return result;
}

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

if ( sound_stream )
result = sound_stream_destroy();
if ( sound_dsp )
result = sysdep_dsp_destroy();
if ( sound_mixer )
result = sysdep_mixer_destroy();
return result;
}

original_code:
void osd_stop_audio_stream(void)
{
   if(sound_stream)
      sound_stream_destroy(sound_stream);
   if(sound_dsp)
      sysdep_dsp_destroy(sound_dsp);
   if(sound_mixer)
      sysdep_mixer_destroy(sound_mixer);
}

canonical_original_code:
void osd_stop_audio_stream()
{
   if(sound_stream)
      sound_stream_destroy(sound_stream);
   if(sound_dsp)
      sysdep_dsp_destroy(sound_dsp);
   if(sound_mixer)
      sysdep_mixer_destroy(sound_mixer);
}


decompiled_code:
void __fastcall osd_sound_enable(int a1)
{
float v1; // xmm1_4

if ( sound_stream && a1 )
{
use_sound = 1;
xmame_func = &xmame_func_sound;
if ( !sound_dsp )
{
v1 = vsync_freq_hz;
sound_dsp = sysdep_dsp_create(
0LL,
sound_dsp_device,
&sample_rate,
&type,
5LL,
(float)(1.0 / v1) * *(float *)&sound_bufsize);
if ( sound_dsp )
{
sound_stream_destroy(sound_stream);
sound_stream = sound_stream_create(sound_dsp, (unsigned int)type, (unsigned int)sound_samples_per_frame, 3LL);
if ( !sound_stream )
{
osd_stop_audio_stream();
use_sound = 0;
xmame_func = &xmame_func_nosound;
}
}
else
{
use_sound = 0;
xmame_func = &xmame_func_nosound;
}
}
}
else
{
if ( sound_dsp )
{
sysdep_dsp_destroy();
sound_dsp = 0LL;
}
use_sound = 0;
xmame_func = &xmame_func_nosound;
}
}

canonical_decompiled_code:
void __fastcall func6(int a1)
{
float v1; // xmm1_4

if ( sound_stream && a1 )
{
use_sound = 1;
xmame_func = &xmame_func_sound;
if ( !sound_dsp )
{
v1 = vsync_freq_hz;
sound_dsp = sysdep_dsp_create(
0LL,
sound_dsp_device,
&sample_rate,
&type,
5LL,
(float)(1.0 / v1) * *(float *)&sound_bufsize);
if ( sound_dsp )
{
sound_stream_destroy(sound_stream);
sound_stream = sound_stream_create(sound_dsp, (unsigned int)type, (unsigned int)sound_samples_per_frame, 3LL);
if ( !sound_stream )
{
func5();
use_sound = 0;
xmame_func = &xmame_func_nosound;
}
}
else
{
use_sound = 0;
xmame_func = &xmame_func_nosound;
}
}
}
else
{
if ( sound_dsp )
{
sysdep_dsp_destroy();
sound_dsp = 0LL;
}
use_sound = 0;
xmame_func = &xmame_func_nosound;
}
}

original_code:
void osd_sound_enable (int enable_it)
{
   if (sound_stream && enable_it)
   {
      use_sound = 1;
      do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
      if (!sound_dsp)
      {
  if (!(sound_dsp = sysdep_dsp_create(((void *)0),
     sound_dsp_device,
     &sample_rate,
     &type,
     sound_bufsize * (1 / ((float)(vsync_freq_hz))),
     0x01 | 0x04)))
  {
     use_sound = 0;
     do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
  }
  else
  {
     sound_stream_destroy(sound_stream);
     if (!(sound_stream = sound_stream_create(sound_dsp, type,
        sound_samples_per_frame, 3)))
     {
        osd_stop_audio_stream();
        use_sound = 0;
        do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
     }
  }
      }
   }
   else
   {
      if (sound_dsp)
      {
  sysdep_dsp_destroy(sound_dsp);
  sound_dsp = ((void *)0);
      }
      use_sound = 0;
      do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
   }
}

canonical_original_code:
void osd_sound_enable(int enable_it)
{
   if (sound_stream && enable_it)
   {
      use_sound = 1;
      do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
      if (!sound_dsp)
      {
  if (!(sound_dsp = sysdep_dsp_create(((void *)0),
     sound_dsp_device,
     &sample_rate,
     &type,
     sound_bufsize * (1 / ((float)(vsync_freq_hz))),
     0x01 | 0x04)))
  {
     use_sound = 0;
     do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
  }
  else
  {
     sound_stream_destroy(sound_stream);
     if (!(sound_stream = sound_stream_create(sound_dsp, type,
        sound_samples_per_frame, 3)))
     {
        osd_stop_audio_stream();
        use_sound = 0;
        do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
     }
  }
      }
   }
   else
   {
      if (sound_dsp)
      {
  sysdep_dsp_destroy(sound_dsp);
  sound_dsp = ((void *)0);
      }
      use_sound = 0;
      do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
   }
}


decompiled_code:
__int64 __fastcall osd_start_audio_stream(int a1)
{
int v1; // eax
float v2; // xmm1_4
float v3; // xmm0_4
__int64 result; // rax
float v5; // xmm1_4
__int64 v6; // rdi
float v7; // xmm1_4

type = a1 == 0 ? 1 : 3;
sound_stream = 0LL;
if ( !use_sound )
{
LABEL_2:
v1 = sound_fake;
if ( sound_fake )
v1 = 8000;
sample_rate = v1;
v2 = vsync_freq_hz;
v3 = (float)v1 / v2;
result = (unsigned int)(int)v3;
sound_samples_per_frame = (int)v3;
return result;
}
v5 = vsync_freq_hz;
v6 = sysdep_dsp_create(0LL, sound_dsp_device, &sample_rate, &type, 5LL, (float)(1.0 / v5) * *(float *)&sound_bufsize);
sound_dsp = v6;
if ( !v6 )
goto LABEL_13;
if ( !use_sound )
goto LABEL_2;
v7 = vsync_freq_hz;
sound_samples_per_frame = (int)(float)((float)sample_rate / v7);
sound_stream = sound_stream_create(v6, (unsigned int)type, (unsigned int)sound_samples_per_frame, 3LL);
if ( !sound_stream )
{
LABEL_13:
osd_stop_audio_stream();
use_sound = 0;
xmame_func = &xmame_func_nosound;
goto LABEL_2;
}
if ( !use_sound )
goto LABEL_2;
sound_mixer = sysdep_mixer_create(0LL, sound_mixer_device, 1LL);
if ( sound_mixer && (unsigned int)rc_get_priority2(&sound_opts, "volume") )
osd_set_mastervolume(sound_attenuation);
return (unsigned int)sound_samples_per_frame;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
int v1; // eax
float v2; // xmm1_4
float v3; // xmm0_4
__int64 result; // rax
float v5; // xmm1_4
__int64 v6; // rdi
float v7; // xmm1_4

type = a1 == 0 ? 1 : 3;
sound_stream = 0LL;
if ( !use_sound )
{
LABEL_2:
v1 = sound_fake;
if ( sound_fake )
v1 = 8000;
sample_rate = v1;
v2 = vsync_freq_hz;
v3 = (float)v1 / v2;
result = (unsigned int)(int)v3;
sound_samples_per_frame = (int)v3;
return result;
}
v5 = vsync_freq_hz;
v6 = sysdep_dsp_create(0LL, sound_dsp_device, &sample_rate, &type, 5LL, (float)(1.0 / v5) * *(float *)&sound_bufsize);
sound_dsp = v6;
if ( !v6 )
goto LABEL_13;
if ( !use_sound )
goto LABEL_2;
v7 = vsync_freq_hz;
sound_samples_per_frame = (int)(float)((float)sample_rate / v7);
sound_stream = sound_stream_create(v6, (unsigned int)type, (unsigned int)sound_samples_per_frame, 3LL);
if ( !sound_stream )
{
LABEL_13:
func5();
use_sound = 0;
xmame_func = &xmame_func_nosound;
goto LABEL_2;
}
if ( !use_sound )
goto LABEL_2;
sound_mixer = sysdep_mixer_create(0LL, sound_mixer_device, 1LL);
if ( sound_mixer && (unsigned int)rc_get_priority2(&sound_opts, "volume") )
func2(sound_attenuation);
return (unsigned int)sound_samples_per_frame;
}

original_code:
int osd_start_audio_stream(int stereo)
{
   type = 0x01 | (stereo? 0x02:0x00);
   sound_stream = ((void *)0);
   if(use_sound)
   {
      if(!(sound_dsp = sysdep_dsp_create(((void *)0),
         sound_dsp_device,
         &sample_rate,
         &type,
         sound_bufsize * (1 / ((float)(vsync_freq_hz))),
         0x01 | 0x04)))
      {
         osd_stop_audio_stream();
         use_sound = 0;
  do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
      }
   }
   if(use_sound)
   {
      sound_samples_per_frame = sample_rate /
         ((float)(vsync_freq_hz));
      if(!(sound_stream = sound_stream_create(sound_dsp, type,
         sound_samples_per_frame, 3)))
      {
         osd_stop_audio_stream();
         use_sound = 0;
  do{ if( use_sound ) xmame_func = &xmame_func_sound; else xmame_func = &xmame_func_nosound; }while(0);
      }
   }
   if(!use_sound)
   {
      if(sound_fake)
         sample_rate = 8000;
      else
         sample_rate = 0;
      sound_samples_per_frame = sample_rate /
         ((float)(vsync_freq_hz));
      return sound_samples_per_frame;
   }
   sound_mixer = sysdep_mixer_create(((void *)0), sound_mixer_device,
      0x01);
   if(sound_mixer && rc_get_priority2(sound_opts, "volume"))
      osd_set_mastervolume(sound_attenuation);
   return sound_samples_per_frame;
}

variable_types: stereo int


original_code:
static void status_puts( int type, const unsigned char *str )
{
  int i, j, k, c, w, h16;
  const byte *p;
  byte mask;
  byte *dst = status_info[ type ].pixmap;
  if( str ){
    w = (((strlen((char *)str) * 8)<((48*8)))?(strlen((char *)str) * 8):((48*8)));
    for( i=0; i<w; i+=8 ){
      c = *str ++;
      if( c=='\0' ) break;
      if( c < 0xe0 ){
 if( has_kanji_rom &&
     (( 0x20 <= c && c <= 0x7f ) ||
      ( 0xa0 <= c && c <= 0xdf ) ) ){
   p = &kanji_rom[0][ c*8 ][0];
   h16 = (1);
 }else{
   p = &font_mem[ c*8 ];
   h16 = (0);
 }
 for( j=0; j<16; j++ ){
   for( mask=0x80, k=0; k<8; k++, mask>>=1 ){
     if( *p & mask ) dst[ j*w +i +k ] = STATUS_FG;
     else dst[ j*w +i +k ] = STATUS_BG;
   }
   if( h16 || j&1 ) p++;
 }
      }else{
 p = &status_font[ (c-0xe0) ][0];
 for( j=0; j<16; j++ ){
   for( k=0; k<8; k++ ){
     dst[ j*w +i +k ] = *p;
     p++;
   }
 }
      }
    }
    status_info[ type ].w = i;
  }else{
    status_info[ type ].w = 0;
  }
}

canonical_original_code:
static void status_puts(int type, unsigned char *str)
{
  int i; int j; int k; int c; int w; int h16;
  unsigned char *p;
  unsigned char mask;
  unsigned char *dst = status_info[ type ].pixmap;
  if( str ){
    w = (((strlen((char *)str) * 8)<((48*8)))?(strlen((char *)str) * 8):((48*8)));
    for( i=0; i<w; i+=8 ){
      c = *str ++;
      if( c=='\0' ) break;
      if( c < 0xe0 ){
 if( has_kanji_rom &&
     (( 0x20 <= c && c <= 0x7f ) ||
      ( 0xa0 <= c && c <= 0xdf ) ) ){
   p = &kanji_rom[0][ c*8 ][0];
   h16 = (1);
 }else{
   p = &font_mem[ c*8 ];
   h16 = (0);
 }
 for( j=0; j<16; j++ ){
   for( mask=0x80, k=0; k<8; k++, mask>>=1 ){
     if( *p & mask ) dst[ j*w +i +k ] = STATUS_FG;
     else dst[ j*w +i +k ] = STATUS_BG;
   }
   if( h16 || j&1 ) p++;
 }
      }else{
 p = &status_font[ (c-0xe0) ][0];
 for( j=0; j<16; j++ ){
   for( k=0; k<8; k++ ){
     dst[ j*w +i +k ] = *p;
     p++;
   }
 }
      }
    }
    status_info[ type ].w = i;
  }else{
    status_info[ type ].w = 0;
  }
}

variable_types: type int

variable_types:
str
unsigned char *

variable_types: i int

variable_types: j int

variable_types: k int

variable_types: c int

variable_types: w int

variable_types:
p
unsigned char *

variable_types:
mask
unsigned char

variable_types:
dst
unsigned char *


decompiled_code:
__int64 status_mode()
{
int v0; // ebx
__int64 result; // rax
char v2[11]; // [rsp+0h] [rbp-18h] BYREF
char v3; // [rsp+Bh] [rbp-Dh]
char v4; // [rsp+Ch] [rbp-Ch]
char v5; // [rsp+Dh] [rbp-Bh]
char v6; // [rsp+Eh] [rbp-Ah]

v0 = boot_basic;
if ( boot_basic != 2 && boot_basic != 3 )
v0 = boot_basic == 1;
if ( !boot_clock_4mhz )
v0 += 4;
if ( key_scan[10] >= 0 )
v0 += 8;
if ( (key_scan[8] & 0x20) == 0 )
v0 += 16;
result = (unsigned int)(v0 + 32);
if ( numlock_emu )
v0 += 32;
if ( stat_var != v0 )
{
stat_var = v0;
strcpy(v2, (&mode_str_0)[v0 & 7]);
if ( (v0 & 8) != 0 )
{
v2[9] = -11;
v2[10] = -10;
}
if ( (v0 & 0x10) != 0 )
{
if ( romaji_input_mode )
{
v3 = -7;
v4 = -6;
}
else
{
v3 = -9;
v4 = -8;
}
}
if ( (v0 & 0x20) != 0 )
{
v5 = -5;
v6 = -4;
}
result = status_puts(0, v2);
stat_draw = 1;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // ebx
__int64 result; // rax
char v2[11]; // [rsp+0h] [rbp-18h] BYREF
char v3; // [rsp+Bh] [rbp-Dh]
char v4; // [rsp+Ch] [rbp-Ch]
char v5; // [rsp+Dh] [rbp-Bh]
char v6; // [rsp+Eh] [rbp-Ah]

v0 = boot_basic;
if ( boot_basic != 2 && boot_basic != 3 )
v0 = boot_basic == 1;
if ( !boot_clock_4mhz )
v0 += 4;
if ( key_scan[10] >= 0 )
v0 += 8;
if ( (key_scan[8] & 0x20) == 0 )
v0 += 16;
result = (unsigned int)(v0 + 32);
if ( numlock_emu )
v0 += 32;
if ( stat_var != v0 )
{
stat_var = v0;
strcpy(v2, (&mode_str_0)[v0 & 7]);
if ( (v0 & 8) != 0 )
{
v2[9] = -11;
v2[10] = -10;
}
if ( (v0 & 0x10) != 0 )
{
if ( romaji_input_mode )
{
v3 = -7;
v4 = -6;
}
else
{
v3 = -9;
v4 = -8;
}
}
if ( (v0 & 0x20) != 0 )
{
v5 = -5;
v6 = -4;
}
result = func0(0, v2);
stat_draw = 1;
}
return result;
}

original_code:
static __inline__ void status_mode( void )
{
  int mode = 0;
  byte buf[16];
  static const char *mode_str[] = {
    "N   4MHz       ", "V1S 4MHz       ", "V1H 4MHz       ", "V2  4MHz       ",
    "N   8MHz       ", "V1S 8MHz       ", "V1H 8MHz       ", "V2  8MHz       ",
  };
  switch( boot_basic ){
  case BASIC_N: mode = 0; break;
  case BASIC_V1S: mode = 1; break;
  case BASIC_V1H: mode = 2; break;
  case BASIC_V2: mode = 3; break;
  }
  if( boot_clock_4mhz == (0) ) mode += 4;
  if( (key_scan[0x0a] & 0x80) == 0 ) mode += 8;
  if( (key_scan[0x08] & 0x20) == 0 ) mode += 16;
  if( numlock_emu ) mode += 32;
  if( stat_var[0] != mode ){
    stat_var[0] = mode;
    strcpy( (char *)buf, mode_str[ mode & 0x7 ] );
    if( mode & 8 ){
      buf[ 9] = FNT_CAP_1;
      buf[10] = FNT_CAP_2;
    }
    if( mode & 16 ){
      if( romaji_input_mode ){
 buf[11] = FNT_RMJ_1;
 buf[12] = FNT_RMJ_2;
      }else{
 buf[11] = FNT_KAN_1;
 buf[12] = FNT_KAN_2;
      }
    }
    if( mode & 32 ){
 buf[13] = FNT_NUM_1;
 buf[14] = FNT_NUM_2;
    }
    status_puts( 0, (const unsigned char *)buf );
    stat_draw[ 0 ] = (1);
  }
}

canonical_original_code:
static __inline__ void status_mode()
{
  int mode = 0;
  unsigned char buf[16];
  static char *mode_str[] = {
    "N   4MHz       ", "V1S 4MHz       ", "V1H 4MHz       ", "V2  4MHz       ",
    "N   8MHz       ", "V1S 8MHz       ", "V1H 8MHz       ", "V2  8MHz       ",
  };
  switch( boot_basic ){
  case BASIC_N: mode = 0; break;
  case BASIC_V1S: mode = 1; break;
  case BASIC_V1H: mode = 2; break;
  case BASIC_V2: mode = 3; break;
  }
  if( boot_clock_4mhz == (0) ) mode += 4;
  if( (key_scan[0x0a] & 0x80) == 0 ) mode += 8;
  if( (key_scan[0x08] & 0x20) == 0 ) mode += 16;
  if( numlock_emu ) mode += 32;
  if( stat_var[0] != mode ){
    stat_var[0] = mode;
    strcpy( (char *)buf, mode_str[ mode & 0x7 ] );
    if( mode & 8 ){
      buf[ 9] = FNT_CAP_1;
      buf[10] = FNT_CAP_2;
    }
    if( mode & 16 ){
      if( romaji_input_mode ){
 buf[11] = FNT_RMJ_1;
 buf[12] = FNT_RMJ_2;
      }else{
 buf[11] = FNT_KAN_1;
 buf[12] = FNT_KAN_2;
      }
    }
    if( mode & 32 ){
 buf[13] = FNT_NUM_1;
 buf[14] = FNT_NUM_2;
    }
    status_puts( 0, (unsigned char *)buf );
    stat_draw[ 0 ] = (1);
  }
}

variable_types: mode int

variable_types:
buf
unsigned char [16]


variable_types: fdd int


decompiled_code:
unsigned __int64 status_init()
{
char *v0; // rdx
unsigned __int64 result; // rax

v0 = (char *)&pixmap;
for ( result = 0LL; result != 6; result += 2LL )
{
stat_draw[result / 2] = 1;
stat_msg_exist[result / 2] = 0;
stat_var[result / 2] = -1;
status_info[result] = (__int64)v0;
LODWORD(status_info[result + 1]) = 0;
HIDWORD(status_info[result + 1]) = 16;
v0 += 6144;
}
return result * 2;
}

canonical_decompiled_code:
unsigned __int64 func3()
{
char *v0; // rdx
unsigned __int64 result; // rax

v0 = (char *)&pixmap;
for ( result = 0LL; result != 6; result += 2LL )
{
stat_draw[result / 2] = 1;
stat_msg_exist[result / 2] = 0;
stat_var[result / 2] = -1;
status_info[result] = (__int64)v0;
LODWORD(status_info[result + 1]) = 0;
HIDWORD(status_info[result + 1]) = 16;
v0 += 6144;
}
return result * 2;
}

original_code:
void status_init( void )
{
  int i;
  for( i=0; i<3; i++ ){
    stat_draw[i] = (1);
    stat_msg_exist[i] = (0);
    stat_var[i] = -1;
    status_info[i].pixmap = &pixmap[i][0];
    status_info[i].w = 0;
    status_info[i].h = (16);
  }
}

canonical_original_code:
void status_init()
{
  int i;
  for( i=0; i<3; i++ ){
    stat_draw[i] = (1);
    stat_msg_exist[i] = (0);
    stat_var[i] = -1;
    status_info[i].pixmap = &pixmap[i][0];
    status_info[i].w = 0;
    status_info[i].h = (16);
  }
}


decompiled_code:
void __fastcall status_reset(int a1)
{
if ( a1 )
{
dword_4EC8 = 1;
dword_4EC4 = 1;
stat_draw[0] = 1;
}
else
{
dword_640 = -1;
dword_63C = -1;
stat_var[0] = -1;
}
}

canonical_decompiled_code:
void __fastcall func4(int a1)
{
if ( a1 )
{
dword_4EC8 = 1;
dword_4EC4 = 1;
stat_draw[0] = 1;
}
else
{
dword_640 = -1;
dword_63C = -1;
stat_var[0] = -1;
}
}

original_code:
void status_reset( int show )
{
  if( show ){
    stat_draw[0] = stat_draw[1] = stat_draw[2] = (1);
  }else{
    stat_var[0] = stat_var[1] = stat_var[2] = -1;
  }
}

canonical_original_code:
void status_reset(int show)
{
  if( show ){
    stat_draw[0] = stat_draw[1] = stat_draw[2] = (1);
  }else{
    stat_var[0] = stat_var[1] = stat_var[2] = -1;
  }
}

variable_types: show int


decompiled_code:
__int64 __fastcall status_message(int a1, int a2, const char *a3)
{
__int64 result; // rax

status_puts(a1, a3);
result = a1;
if ( a2 < 0 )
{
stat_msg_exist[a1] = 0;
stat_var[a1] = -1;
}
else
{
stat_msg_exist[a1] = 1;
}
stat_msg_timer[a1] = a2;
stat_draw[a1] = 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, int a2, const char *a3)
{
__int64 result; // rax

func0(a1, a3);
result = a1;
if ( a2 < 0 )
{
stat_msg_exist[a1] = 0;
stat_var[a1] = -1;
}
else
{
stat_msg_exist[a1] = 1;
}
stat_msg_timer[a1] = a2;
stat_draw[a1] = 1;
return result;
}

original_code:
void status_message( int kind, int frames, const char *msg )
{
  status_puts( kind, (const unsigned char *)msg );
  if( frames >= 0 ){ stat_msg_exist[ kind ] = (1); }
  else { stat_msg_exist[ kind ] = (0); stat_var[ kind ] = -1; }
  stat_msg_timer[ kind ] = frames;
  stat_draw[ kind ] = (1);
}

canonical_original_code:
void status_message(int kind, int frames, char *msg)
{
  status_puts( kind, (unsigned char *)msg );
  if( frames >= 0 ){ stat_msg_exist[ kind ] = (1); }
  else { stat_msg_exist[ kind ] = (0); stat_var[ kind ] = -1; }
  stat_msg_timer[ kind ] = frames;
  stat_draw[ kind ] = (1);
}

variable_types: kind int

variable_types: frames int

variable_types:
msg
char *


decompiled_code:
__int64 __fastcall status_update(int a1)
{
int v1; // ebp
__int64 i; // rbx
int v3; // eax
int v4; // eax
__int64 result; // rax
__int64 v6; // rcx

v1 = 1;
for ( i = 0LL; ; ++i )
{
if ( !stat_msg_exist[i]
|| (v3 = stat_msg_timer[i]) != 0
&& (v4 = v3 - 1, (stat_msg_timer[i] = v4) == 0)
&& (status_message(i, -1, 0LL), stat_var[i] = -1, !stat_msg_exist[i]) )
{
if ( !(_DWORD)i )
{
status_mode(0LL);
goto LABEL_5;
}
if ( (_DWORD)i == 2 )
break;
}
if ( v1 > 2 )
goto LABEL_13;
LABEL_5:
++v1;
}
status_fdd(2LL);
LABEL_13:
result = now_status;
if ( now_status )
{
v6 = 0LL;
result = 0LL;
do
{
if ( stat_draw[v6] | a1 )
{
stat_draw[v6] = 0;
result = (1 << v6) | (unsigned int)result;
}
++v6;
}
while ( v6 != 3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
int v1; // ebp
__int64 i; // rbx
int v3; // eax
int v4; // eax
__int64 result; // rax
__int64 v6; // rcx

v1 = 1;
for ( i = 0LL; ; ++i )
{
if ( !stat_msg_exist[i]
|| (v3 = stat_msg_timer[i]) != 0
&& (v4 = v3 - 1, (stat_msg_timer[i] = v4) == 0)
&& (func5(i, -1, 0LL), stat_var[i] = -1, !stat_msg_exist[i]) )
{
if ( !(_DWORD)i )
{
func1(0LL);
goto LABEL_5;
}
if ( (_DWORD)i == 2 )
break;
}
if ( v1 > 2 )
goto LABEL_13;
LABEL_5:
++v1;
}
func2(2LL);
LABEL_13:
result = now_status;
if ( now_status )
{
v6 = 0LL;
result = 0LL;
do
{
if ( stat_draw[v6] | a1 )
{
stat_draw[v6] = 0;
result = (1 << v6) | (unsigned int)result;
}
++v6;
}
while ( v6 != 3 );
}
return result;
}

original_code:
int status_update( int force )
{
  int i, ret = 0;
  for( i=0; i<3; i++ ){
    if( stat_msg_exist[i] ){
      if( stat_msg_timer[i] ){
 if( -- stat_msg_timer[i]==0 ){
   status_message( i, -1, ((void *)0) );
   stat_var[i] = -1;
 }
      }
    }
    if( stat_msg_exist[i] == (0) ){
      if ( i==0 ){ status_mode(); }
      else if( i==2 ){ status_fdd(); }
    }
  }
  if( now_status ){
    for( i=0; i<3; i++ ){
      if( stat_draw[i] || force ){
 stat_draw[i] = (0);
 ret |= 1<<i;
      }
    }
  }
  return ret;
}

canonical_original_code:
int status_update(int force)
{
  int i; int ret = 0;
  for( i=0; i<3; i++ ){
    if( stat_msg_exist[i] ){
      if( stat_msg_timer[i] ){
 if( -- stat_msg_timer[i]==0 ){
   status_message( i, -1, ((void *)0) );
   stat_var[i] = -1;
 }
      }
    }
    if( stat_msg_exist[i] == (0) ){
      if ( i==0 ){ status_mode(); }
      else if( i==2 ){ status_fdd(); }
    }
  }
  if( now_status ){
    for( i=0; i<3; i++ ){
      if( stat_draw[i] || force ){
 stat_draw[i] = (0);
 ret |= 1<<i;
      }
    }
  }
  return ret;
}

variable_types: force int

variable_types: ret int


decompiled_code:
const char *indicate_bootup_logo()
{
const char *result; // rax
char v1[40]; // [rsp+0h] [rbp-28h] BYREF

result = (const char *)get_keysym_menu();
if ( result )
{
sprintf(v1, "<%.8s> key to MENU", result);
status_message(0, 240, "QUASI88 0.6.3");
result = (const char *)status_message(1, 0, v1);
}
return result;
}

canonical_decompiled_code:
const char *func7()
{
const char *result; // rax
char v1[40]; // [rsp+0h] [rbp-28h] BYREF

result = (const char *)get_keysym_menu();
if ( result )
{
sprintf(v1, "<%.8s> key to MENU", result);
func5(0, 240, "QUASI88 0.6.3");
result = (const char *)func5(1, 0, v1);
}
return result;
}

original_code:
void indicate_bootup_logo( void )
{
  char menu_msg[24];
  const char *keysym = get_keysym_menu();
  if( keysym ){
    sprintf( menu_msg, "<%.8s> key to MENU", keysym );
    status_message( 0, 60*4, "QUASI88" " " "0.6.3" );
    status_message( 1, 0, menu_msg );
  }
}

canonical_original_code:
void indicate_bootup_logo()
{
  char menu_msg[24];
  char *keysym = get_keysym_menu();
  if( keysym ){
    sprintf( menu_msg, "<%.8s> key to MENU", keysym );
    status_message( 0, 60*4, "QUASI88" " " "0.6.3" );
    status_message( 1, 0, menu_msg );
  }
}

variable_types:
keysym
char *


decompiled_code:
__int64 indicate_stateload_logo()
{
status_message(0, 240, "QUASI88 0.6.3");
return status_message(1, 240, "State Load Successful !");
}

canonical_decompiled_code:
__int64 func8()
{
func5(0, 240, "QUASI88 0.6.3");
return func5(1, 240, "State Load Successful !");
}

original_code:
void indicate_stateload_logo( void )
{
  status_message( 0, 60*4, "QUASI88" " " "0.6.3" );
  status_message( 1, 60*4, "State Load Successful !" );
}

canonical_original_code:
void indicate_stateload_logo()
{
  status_message( 0, 60*4, "QUASI88" " " "0.6.3" );
  status_message( 1, 60*4, "State Load Successful !" );
}