decompiled_code:
__int64 __fastcall circus_vh_screenrefresh(__int64 a1, int a2)
{
int v2; // ebx
__int64 v3; // rbp
__int64 v4; // rdx
char v5; // al
int v6; // er10
unsigned int v7; // edi
__int64 result; // rax
int v9; // er11
int v10; // edx
__int64 v11; // [rsp-28h] [rbp-50h]

if ( palette_recalc() || a2 )
{
memset(dirtybuffer, 1, videoram_size);
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_8;
}
else
{
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_8;
}
v3 = v2;
do
{
while ( !*((_BYTE *)dirtybuffer + v3) )
{
--v2;
--v3;
if ( v2 == -1 )
goto LABEL_8;
}
*((_BYTE *)dirtybuffer + v3) = 0;
v4 = *(unsigned __int8 *)(videoram + v3--);
v11 = (unsigned int)(8 * (v2 >> 5));
v5 = v2--;
drawgfx(a1, *(_QWORD *)(Machine + 512LL), v4, 0LL, 0LL, 0LL, 8 * (v5 & 0x1Fu), v11, Machine + 776LL, 0LL, 0LL);
}
while ( v2 != -1 );
LABEL_8:
draw_line(a1, 0, 18, 255, 0x12u, 0);
draw_line(a1, 0, 249, 255, 0xF9u, 1);
draw_line(a1, 0, 18, 0, 0xF8u, 0);
draw_line(a1, 247, 18, 247, 0xF8u, 0);
draw_line(a1, 0, 137, 17, 0x89u, 0);
draw_line(a1, 231, 137, 248, 0x89u, 0);
draw_line(a1, 0, 193, 17, 0xC1u, 0);
draw_line(a1, 231, 193, 248, 0xC1u, 0);
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(unsigned int)clown_z,
0LL,
0LL,
0LL,
(unsigned int)clown_y,
(unsigned int)clown_x,
Machine + 776LL,
2LL,
0LL);
v6 = clown_y >> 3;
v7 = clown_x >> 3;
result = clown_x & 0xF;
v9 = (clown_x >> 3) - (((_DWORD)result == 0) - 3);
v10 = (clown_y >> 3) + 2 - (((clown_y & 0xF) == 0) - 1);
if ( clown_x >> 3 < v9 )
{
do
{
if ( v6 < v10 )
{
LODWORD(result) = v6;
do
{
if ( (unsigned int)result <= 0x1F && v7 <= 0x1F )
*((_BYTE *)dirtybuffer + (int)(result + 32 * v7)) = 1;
result = (unsigned int)(result + 1);
}
while ( (_DWORD)result != v10 );
}
++v7;
}
while ( v7 != v9 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
int v2; // ebx
__int64 v3; // rbp
__int64 v4; // rdx
char v5; // al
int v6; // er10
unsigned int v7; // edi
__int64 result; // rax
int v9; // er11
int v10; // edx
__int64 v11; // [rsp-28h] [rbp-50h]

if ( palette_recalc() || a2 )
{
memset(dirtybuffer, 1, videoram_size);
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_8;
}
else
{
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_8;
}
v3 = v2;
do
{
while ( !*((_BYTE *)dirtybuffer + v3) )
{
--v2;
--v3;
if ( v2 == -1 )
goto LABEL_8;
}
*((_BYTE *)dirtybuffer + v3) = 0;
v4 = *(unsigned __int8 *)(videoram + v3--);
v11 = (unsigned int)(8 * (v2 >> 5));
v5 = v2--;
drawgfx(a1, *(_QWORD *)(Machine + 512LL), v4, 0LL, 0LL, 0LL, 8 * (v5 & 0x1Fu), v11, Machine + 776LL, 0LL, 0LL);
}
while ( v2 != -1 );
LABEL_8:
func2(a1, 0, 18, 255, 0x12u, 0);
func2(a1, 0, 249, 255, 0xF9u, 1);
func2(a1, 0, 18, 0, 0xF8u, 0);
func2(a1, 247, 18, 247, 0xF8u, 0);
func2(a1, 0, 137, 17, 0x89u, 0);
func2(a1, 231, 137, 248, 0x89u, 0);
func2(a1, 0, 193, 17, 0xC1u, 0);
func2(a1, 231, 193, 248, 0xC1u, 0);
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(unsigned int)clown_z,
0LL,
0LL,
0LL,
(unsigned int)clown_y,
(unsigned int)clown_x,
Machine + 776LL,
2LL,
0LL);
v6 = clown_y >> 3;
v7 = clown_x >> 3;
result = clown_x & 0xF;
v9 = (clown_x >> 3) - (((_DWORD)result == 0) - 3);
v10 = (clown_y >> 3) + 2 - (((clown_y & 0xF) == 0) - 1);
if ( clown_x >> 3 < v9 )
{
do
{
if ( v6 < v10 )
{
LODWORD(result) = v6;
do
{
if ( (unsigned int)result <= 0x1F && v7 <= 0x1F )
*((_BYTE *)dirtybuffer + (int)(result + 32 * v7)) = 1;
result = (unsigned int)(result + 1);
}
while ( (_DWORD)result != v10 );
}
++v7;
}
while ( v7 != v9 );
}
return result;
}

original_code:
void circus_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int offs;
 int sx,sy;
 if (palette_recalc() || full_refresh)
 {
  memset(dirtybuffer,1,videoram_size);
 }
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   dirtybuffer[offs] = 0;
   sy = offs / 32;
   sx = offs % 32;
   drawgfx(bitmap,Machine->gfx[0],
     videoram[offs],
     0,
     0,0,
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
    draw_line (bitmap,0,18,255,18,0);
    draw_line (bitmap,0,249,255,249,1);
    draw_line (bitmap,0,18,0,248,0);
    draw_line (bitmap,247,18,247,248,0);
    draw_line (bitmap,0,137,17,137,0);
    draw_line (bitmap,231,137,248,137,0);
    draw_line (bitmap,0,193,17,193,0);
    draw_line (bitmap,231,193,248,193,0);
 drawgfx(bitmap,Machine->gfx[1],
   clown_z,
   0,
   0,0,
   clown_y,clown_x,
   &Machine->visible_area,TRANSPARENCY_PEN,0);
 sx = clown_y >> 3;
 sy = clown_x >> 3;
 {
  int max_x = 2;
  int max_y = 2;
  int x2, y2;
  if (clown_y & 0x0f) max_x ++;
  if (clown_x & 0x0f) max_y ++;
  for (y2 = sy; y2 < sy + max_y; y2 ++)
  {
   for (x2 = sx; x2 < sx + max_x; x2 ++)
   {
    if ((x2 < 32) && (y2 < 32) && (x2 >= 0) && (y2 >= 0))
     dirtybuffer[x2 + 32*y2] = 1;
   }
  }
 }
}

canonical_original_code:
void circus_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int offs;
 int sx; int sy;
 if (palette_recalc() || full_refresh)
 {
  memset(dirtybuffer,1,videoram_size);
 }
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   dirtybuffer[offs] = 0;
   sy = offs / 32;
   sx = offs % 32;
   drawgfx(bitmap,Machine->gfx[0],
     videoram[offs],
     0,
     0,0,
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
    draw_line (bitmap,0,18,255,18,0);
    draw_line (bitmap,0,249,255,249,1);
    draw_line (bitmap,0,18,0,248,0);
    draw_line (bitmap,247,18,247,248,0);
    draw_line (bitmap,0,137,17,137,0);
    draw_line (bitmap,231,137,248,137,0);
    draw_line (bitmap,0,193,17,193,0);
    draw_line (bitmap,231,193,248,193,0);
 drawgfx(bitmap,Machine->gfx[1],
   clown_z,
   0,
   0,0,
   clown_y,clown_x,
   &Machine->visible_area,TRANSPARENCY_PEN,0);
 sx = clown_y >> 3;
 sy = clown_x >> 3;
 {
  int max_x = 2;
  int max_y = 2;
  int x2; int y2;
  if (clown_y & 0x0f) max_x ++;
  if (clown_x & 0x0f) max_y ++;
  for (y2 = sy; y2 < sy + max_y; y2 ++)
  {
   for (x2 = sx; x2 < sx + max_x; x2 ++)
   {
    if ((x2 < 32) && (y2 < 32) && (x2 >= 0) && (y2 >= 0))
     dirtybuffer[x2 + 32*y2] = 1;
   }
  }
 }
}

variable_types: offs int

variable_types: sx int

variable_types: sy int

user_defined_types: struct osd_bitmap { int width; int depth; void *_private; unsigned char **line; }


decompiled_code:
__int64 __fastcall robotbowl_vh_screenrefresh(__int64 a1, int a2)
{
int v2; // ebx
__int64 v3; // r12
__int64 v4; // rdx
char v5; // al
signed int v6; // ebx
signed int v7; // er12
signed int v8; // esi
unsigned int v9; // edi
int v10; // er10
__int64 result; // rax
int v12; // er11
int v13; // edx
__int64 v14; // [rsp-28h] [rbp-50h]

if ( a2 )
{
memset(dirtybuffer, 1, videoram_size);
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_7;
}
else
{
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_7;
}
v3 = v2;
do
{
while ( !*((_BYTE *)dirtybuffer + v3) )
{
--v2;
--v3;
if ( v2 == -1 )
goto LABEL_7;
}
*((_BYTE *)dirtybuffer + v3) = 0;
v4 = *(unsigned __int8 *)(videoram + v3--);
v14 = (unsigned int)(8 * (v2 >> 5));
v5 = v2--;
drawgfx(a1, *(_QWORD *)(Machine + 512LL), v4, 0LL, 0LL, 0LL, 8 * (v5 & 0x1Fu), v14, Machine + 776LL, 0LL, 0LL);
}
while ( v2 != -1 );
LABEL_7:
v6 = 15;
do
{
draw_robot_box(a1, v6, 0x1Fu);
draw_robot_box(a1, v6, 0x3Fu);
draw_robot_box(a1, v6, 0x5Fu);
v7 = v6 + 152;
v8 = v6 + 152;
v6 += 24;
draw_robot_box(a1, v8, 0x1Fu);
draw_robot_box(a1, v7, 0x3Fu);
draw_robot_box(a1, v7, 0x5Fu);
}
while ( v6 != 87 );
draw_robot_box(a1, 39, 0x7Fu);
draw_line(a1, 39, 137, 47, 0x89u, 0);
draw_robot_box(a1, 191, 0x7Fu);
draw_line(a1, 191, 137, 199, 0x89u, 0);
draw_line(a1, 103, 17, 103, 0xCDu, 0);
draw_line(a1, 111, 17, 111, 0xCBu, 1);
draw_line(a1, 152, 17, 152, 0xCDu, 0);
draw_line(a1, 144, 17, 144, 0xCBu, 1);
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(unsigned int)clown_z,
0LL,
0LL,
0LL,
(unsigned int)(clown_y + 8),
(unsigned int)(clown_x + 8),
Machine + 776LL,
2LL,
0LL);
v9 = clown_x >> 3;
v10 = clown_y >> 3;
result = clown_x & 0xF;
v12 = (clown_x >> 3) - (((_DWORD)result == 0) - 3);
if ( v12 > clown_x >> 3 )
{
v13 = v10 + 2 - (((clown_y & 0xF) == 0) - 1);
do
{
if ( v10 < v13 )
{
LODWORD(result) = v10;
do
{
if ( (unsigned int)result <= 0x1F && v9 <= 0x1F )
*((_BYTE *)dirtybuffer + (int)(result + 32 * v9)) = 1;
result = (unsigned int)(result + 1);
}
while ( (_DWORD)result != v13 );
}
++v9;
}
while ( v12 != v9 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2)
{
int v2; // ebx
__int64 v3; // r12
__int64 v4; // rdx
char v5; // al
signed int v6; // ebx
signed int v7; // er12
signed int v8; // esi
unsigned int v9; // edi
int v10; // er10
__int64 result; // rax
int v12; // er11
int v13; // edx
__int64 v14; // [rsp-28h] [rbp-50h]

if ( a2 )
{
memset(dirtybuffer, 1, videoram_size);
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_7;
}
else
{
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_7;
}
v3 = v2;
do
{
while ( !*((_BYTE *)dirtybuffer + v3) )
{
--v2;
--v3;
if ( v2 == -1 )
goto LABEL_7;
}
*((_BYTE *)dirtybuffer + v3) = 0;
v4 = *(unsigned __int8 *)(videoram + v3--);
v14 = (unsigned int)(8 * (v2 >> 5));
v5 = v2--;
drawgfx(a1, *(_QWORD *)(Machine + 512LL), v4, 0LL, 0LL, 0LL, 8 * (v5 & 0x1Fu), v14, Machine + 776LL, 0LL, 0LL);
}
while ( v2 != -1 );
LABEL_7:
v6 = 15;
do
{
func3(a1, v6, 0x1Fu);
func3(a1, v6, 0x3Fu);
func3(a1, v6, 0x5Fu);
v7 = v6 + 152;
v8 = v6 + 152;
v6 += 24;
func3(a1, v8, 0x1Fu);
func3(a1, v7, 0x3Fu);
func3(a1, v7, 0x5Fu);
}
while ( v6 != 87 );
func3(a1, 39, 0x7Fu);
func2(a1, 39, 137, 47, 0x89u, 0);
func3(a1, 191, 0x7Fu);
func2(a1, 191, 137, 199, 0x89u, 0);
func2(a1, 103, 17, 103, 0xCDu, 0);
func2(a1, 111, 17, 111, 0xCBu, 1);
func2(a1, 152, 17, 152, 0xCDu, 0);
func2(a1, 144, 17, 144, 0xCBu, 1);
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(unsigned int)clown_z,
0LL,
0LL,
0LL,
(unsigned int)(clown_y + 8),
(unsigned int)(clown_x + 8),
Machine + 776LL,
2LL,
0LL);
v9 = clown_x >> 3;
v10 = clown_y >> 3;
result = clown_x & 0xF;
v12 = (clown_x >> 3) - (((_DWORD)result == 0) - 3);
if ( v12 > clown_x >> 3 )
{
v13 = v10 + 2 - (((clown_y & 0xF) == 0) - 1);
do
{
if ( v10 < v13 )
{
LODWORD(result) = v10;
do
{
if ( (unsigned int)result <= 0x1F && v9 <= 0x1F )
*((_BYTE *)dirtybuffer + (int)(result + 32 * v9)) = 1;
result = (unsigned int)(result + 1);
}
while ( (_DWORD)result != v13 );
}
++v9;
}
while ( v12 != v9 );
}
return result;
}

original_code:
void robotbowl_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int offs;
 int sx,sy;
 if (full_refresh)
 {
  memset(dirtybuffer, 1, videoram_size);
 }
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   drawgfx(bitmap,Machine->gfx[0],
     videoram[offs],
     0,
     0,0,
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
    for(offs=15;offs<=63;offs+=24)
    {
        draw_robot_box(bitmap, offs, 31);
        draw_robot_box(bitmap, offs, 63);
        draw_robot_box(bitmap, offs, 95);
        draw_robot_box(bitmap, offs+152, 31);
        draw_robot_box(bitmap, offs+152, 63);
        draw_robot_box(bitmap, offs+152, 95);
    }
    draw_robot_box(bitmap, 39, 127);
    draw_line(bitmap, 39,137,47,137,0);
    draw_robot_box(bitmap, 39+152, 127);
    draw_line(bitmap, 39+152,137,47+152,137,0);
    draw_line(bitmap, 103,17,103,205,0);
    draw_line(bitmap, 111,17,111,203,1);
    draw_line(bitmap, 152,17,152,205,0);
    draw_line(bitmap, 144,17,144,203,1);
 drawgfx(bitmap,Machine->gfx[1],
   clown_z,
   0,
   0,0,
   clown_y+8,clown_x+8,
   &Machine->visible_area,TRANSPARENCY_PEN,0);
 sx = clown_y >> 3;
 sy = clown_x >> 3;
 {
  int max_x = 2;
  int max_y = 2;
  int x2, y2;
  if (clown_y & 0x0f) max_x ++;
  if (clown_x & 0x0f) max_y ++;
  for (y2 = sy; y2 < sy + max_y; y2 ++)
  {
   for (x2 = sx; x2 < sx + max_x; x2 ++)
   {
    if ((x2 < 32) && (y2 < 32) && (x2 >= 0) && (y2 >= 0))
     dirtybuffer[x2 + 32*y2] = 1;
   }
  }
 }
}

canonical_original_code:
void robotbowl_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int offs;
 int sx; int sy;
 if (full_refresh)
 {
  memset(dirtybuffer, 1, videoram_size);
 }
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   drawgfx(bitmap,Machine->gfx[0],
     videoram[offs],
     0,
     0,0,
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
    for(offs=15;offs<=63;offs+=24)
    {
        draw_robot_box(bitmap, offs, 31);
        draw_robot_box(bitmap, offs, 63);
        draw_robot_box(bitmap, offs, 95);
        draw_robot_box(bitmap, offs+152, 31);
        draw_robot_box(bitmap, offs+152, 63);
        draw_robot_box(bitmap, offs+152, 95);
    }
    draw_robot_box(bitmap, 39, 127);
    draw_line(bitmap, 39,137,47,137,0);
    draw_robot_box(bitmap, 39+152, 127);
    draw_line(bitmap, 39+152,137,47+152,137,0);
    draw_line(bitmap, 103,17,103,205,0);
    draw_line(bitmap, 111,17,111,203,1);
    draw_line(bitmap, 152,17,152,205,0);
    draw_line(bitmap, 144,17,144,203,1);
 drawgfx(bitmap,Machine->gfx[1],
   clown_z,
   0,
   0,0,
   clown_y+8,clown_x+8,
   &Machine->visible_area,TRANSPARENCY_PEN,0);
 sx = clown_y >> 3;
 sy = clown_x >> 3;
 {
  int max_x = 2;
  int max_y = 2;
  int x2; int y2;
  if (clown_y & 0x0f) max_x ++;
  if (clown_x & 0x0f) max_y ++;
  for (y2 = sy; y2 < sy + max_y; y2 ++)
  {
   for (x2 = sx; x2 < sx + max_x; x2 ++)
   {
    if ((x2 < 32) && (y2 < 32) && (x2 >= 0) && (y2 >= 0))
     dirtybuffer[x2 + 32*y2] = 1;
   }
  }
 }
}

variable_types: struct osd_bitmap { int width; int depth; void *_private; unsigned char **line; } *

return_type: void


decompiled_code:
__int64 __fastcall crash_vh_screenrefresh(__int64 a1, int a2)
{
int v2; // ebx
__int64 v3; // rbp
__int64 v4; // rdx
char v5; // al
int v6; // er10
unsigned int v7; // edi
__int64 result; // rax
int v9; // er11
int v10; // edx
__int64 v11; // [rsp-28h] [rbp-50h]

if ( a2 )
{
memset(dirtybuffer, 1, videoram_size);
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_7;
}
else
{
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_7;
}
v3 = v2;
do
{
while ( !*((_BYTE *)dirtybuffer + v3) )
{
--v2;
--v3;
if ( v2 == -1 )
goto LABEL_7;
}
*((_BYTE *)dirtybuffer + v3) = 0;
v4 = *(unsigned __int8 *)(videoram + v3--);
v11 = (unsigned int)(8 * (v2 >> 5));
v5 = v2--;
drawgfx(a1, *(_QWORD *)(Machine + 512LL), v4, 0LL, 0LL, 0LL, 8 * (v5 & 0x1Fu), v11, Machine + 776LL, 0LL, 0LL);
}
while ( v2 != -1 );
LABEL_7:
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(unsigned int)clown_z,
0LL,
0LL,
0LL,
(unsigned int)clown_y,
(unsigned int)clown_x,
Machine + 776LL,
2LL,
0LL);
v6 = clown_y >> 3;
v7 = clown_x >> 3;
result = clown_x & 0xF;
v9 = (clown_x >> 3) - (((_DWORD)result == 0) - 3);
v10 = (clown_y >> 3) + 2 - (((clown_y & 0xF) == 0) - 1);
if ( clown_x >> 3 < v9 )
{
do
{
if ( v6 < v10 )
{
LODWORD(result) = v6;
do
{
if ( (unsigned int)result <= 0x1F && v7 <= 0x1F )
*((_BYTE *)dirtybuffer + (int)(result + 32 * v7)) = 1;
result = (unsigned int)(result + 1);
}
while ( (_DWORD)result != v10 );
}
++v7;
}
while ( v7 != v9 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
int v2; // ebx
__int64 v3; // rbp
__int64 v4; // rdx
char v5; // al
int v6; // er10
unsigned int v7; // edi
__int64 result; // rax
int v9; // er11
int v10; // edx
__int64 v11; // [rsp-28h] [rbp-50h]

if ( a2 )
{
memset(dirtybuffer, 1, videoram_size);
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_7;
}
else
{
v2 = videoram_size - 1;
if ( (int)videoram_size - 1 < 0 )
goto LABEL_7;
}
v3 = v2;
do
{
while ( !*((_BYTE *)dirtybuffer + v3) )
{
--v2;
--v3;
if ( v2 == -1 )
goto LABEL_7;
}
*((_BYTE *)dirtybuffer + v3) = 0;
v4 = *(unsigned __int8 *)(videoram + v3--);
v11 = (unsigned int)(8 * (v2 >> 5));
v5 = v2--;
drawgfx(a1, *(_QWORD *)(Machine + 512LL), v4, 0LL, 0LL, 0LL, 8 * (v5 & 0x1Fu), v11, Machine + 776LL, 0LL, 0LL);
}
while ( v2 != -1 );
LABEL_7:
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(unsigned int)clown_z,
0LL,
0LL,
0LL,
(unsigned int)clown_y,
(unsigned int)clown_x,
Machine + 776LL,
2LL,
0LL);
v6 = clown_y >> 3;
v7 = clown_x >> 3;
result = clown_x & 0xF;
v9 = (clown_x >> 3) - (((_DWORD)result == 0) - 3);
v10 = (clown_y >> 3) + 2 - (((clown_y & 0xF) == 0) - 1);
if ( clown_x >> 3 < v9 )
{
do
{
if ( v6 < v10 )
{
LODWORD(result) = v6;
do
{
if ( (unsigned int)result <= 0x1F && v7 <= 0x1F )
*((_BYTE *)dirtybuffer + (int)(result + 32 * v7)) = 1;
result = (unsigned int)(result + 1);
}
while ( (_DWORD)result != v10 );
}
++v7;
}
while ( v7 != v9 );
}
return result;
}

original_code:
void crash_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int offs;
 int sx,sy;
 if (full_refresh)
 {
  memset(dirtybuffer, 1, videoram_size);
 }
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   drawgfx(bitmap,Machine->gfx[0],
     videoram[offs],
     0,
     0,0,
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
    drawgfx(bitmap,Machine->gfx[1],
   clown_z,
   0,
   0,0,
   clown_y,clown_x,
   &Machine->visible_area,TRANSPARENCY_PEN,0);
 sx = clown_y >> 3;
 sy = clown_x >> 3;
 {
  int max_x = 2;
  int max_y = 2;
  int x2, y2;
  if (clown_y & 0x0f) max_x ++;
  if (clown_x & 0x0f) max_y ++;
  for (y2 = sy; y2 < sy + max_y; y2 ++)
  {
   for (x2 = sx; x2 < sx + max_x; x2 ++)
   {
    if ((x2 < 32) && (y2 < 32) && (x2 >= 0) && (y2 >= 0))
     dirtybuffer[x2 + 32*y2] = 1;
   }
  }
 }
}

canonical_original_code:
void crash_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int offs;
 int sx; int sy;
 if (full_refresh)
 {
  memset(dirtybuffer, 1, videoram_size);
 }
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   drawgfx(bitmap,Machine->gfx[0],
     videoram[offs],
     0,
     0,0,
     8*sx,8*sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
    drawgfx(bitmap,Machine->gfx[1],
   clown_z,
   0,
   0,0,
   clown_y,clown_x,
   &Machine->visible_area,TRANSPARENCY_PEN,0);
 sx = clown_y >> 3;
 sy = clown_x >> 3;
 {
  int max_x = 2;
  int max_y = 2;
  int x2; int y2;
  if (clown_y & 0x0f) max_x ++;
  if (clown_x & 0x0f) max_y ++;
  for (y2 = sy; y2 < sy + max_y; y2 ++)
  {
   for (x2 = sx; x2 < sx + max_x; x2 ++)
   {
    if ((x2 < 32) && (y2 < 32) && (x2 >= 0) && (y2 >= 0))
     dirtybuffer[x2 + 32*y2] = 1;
   }
  }
 }
}


decompiled_code:
__int64 ripcord_IN2_r()
{
++circus_interrupt;
return readinputport(2LL);
}

canonical_decompiled_code:
__int64 func10()
{
++circus_interrupt;
return readinputport(2LL);
}

original_code:
static data_t ripcord_IN2_r(offs_t offset)
{
 circus_interrupt ++;
 return readinputport (2);
}

canonical_original_code:
static unsigned int ripcord_IN2_r(unsigned int offset)
{
 circus_interrupt ++;
 return readinputport (2);
}

variable_types:
offset
unsigned int

return_type: unsigned int


decompiled_code:
__int64 init_robotbwl()
{
__int64 i; // rbx
__int64 v1; // rax
__int64 result; // rax

for ( i = 0LL; ; ++i )
{
result = memory_region_length(138LL);
if ( (int)result <= (int)i )
break;
v1 = memory_region(138LL);
*(_BYTE *)(v1 + i) = ~*(_BYTE *)(v1 + i);
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
__int64 i; // rbx
__int64 v1; // rax
__int64 result; // rax

for ( i = 0LL; ; ++i )
{
result = memory_region_length(138LL);
if ( (int)result <= (int)i )
break;
v1 = memory_region(138LL);
*(_BYTE *)(v1 + i) = ~*(_BYTE *)(v1 + i);
}
return result;
}

original_code:
static void init_robotbwl(void)
{
 int i;
 for (i = 0;i < memory_region_length(REGION_GFX2);i++)
  memory_region(REGION_GFX2)[i] ^= 0xFF;
}

canonical_original_code:
static void init_robotbwl()
{
 int i;
 for (i = 0;i < memory_region_length(REGION_GFX2);i++)
  memory_region(REGION_GFX2)[i] ^= 0xFF;
}

variable_types: i int


decompiled_code:
__int64 ripcord_interrupt()
{
circus_interrupt = 0;
return ignore_interrupt();
}

canonical_decompiled_code:
__int64 func12()
{
circus_interrupt = 0;
return ignore_interrupt();
}

original_code:
static int ripcord_interrupt (void)
{
 circus_interrupt = 0;
 if (1)
  return ignore_interrupt();
 else
  return interrupt();
}

canonical_original_code:
static int ripcord_interrupt()
{
 circus_interrupt = 0;
 if (1)
  return ignore_interrupt();
 else
  return interrupt();
}

return_type: int


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

result = 0xFFFFFFFFLL;
*(_DWORD *)a1 = -16777216;
*(_WORD *)(a1 + 4) = -1;
return result;
}

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

result = 0xFFFFFFFFLL;
*(_DWORD *)a1 = -16777216;
*(_WORD *)(a1 + 4) = -1;
return result;
}

original_code:
static void init_palette(unsigned char *game_palette, unsigned short *game_colortable,const unsigned char *color_prom)
{
 memcpy(game_palette,palette,sizeof(palette));
}

canonical_original_code:
static void init_palette(unsigned char *game_palette, unsigned short *game_colortable, unsigned char *color_prom)
{
 memcpy(game_palette,palette,sizeof(palette));
}


original_code:
void sidepckt_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0,bit1,bit2,bit3;
  bit0 = (color_prom[0] >> 4) & 0x01;
  bit1 = (color_prom[0] >> 5) & 0x01;
  bit2 = (color_prom[0] >> 6) & 0x01;
  bit3 = (color_prom[0] >> 7) & 0x01;
  *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  bit0 = (color_prom[0] >> 0) & 0x01;
  bit1 = (color_prom[0] >> 1) & 0x01;
  bit2 = (color_prom[0] >> 2) & 0x01;
  bit3 = (color_prom[0] >> 3) & 0x01;
  *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  bit0 = (color_prom[Machine->drv->total_colors] >> 0) & 0x01;
  bit1 = (color_prom[Machine->drv->total_colors] >> 1) & 0x01;
  bit2 = (color_prom[Machine->drv->total_colors] >> 2) & 0x01;
  bit3 = (color_prom[Machine->drv->total_colors] >> 3) & 0x01;
  *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  color_prom++;
 }
}

canonical_original_code:
void sidepckt_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable, unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0; int bit1; int bit2; int bit3;
  bit0 = (color_prom[0] >> 4) & 0x01;
  bit1 = (color_prom[0] >> 5) & 0x01;
  bit2 = (color_prom[0] >> 6) & 0x01;
  bit3 = (color_prom[0] >> 7) & 0x01;
  *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  bit0 = (color_prom[0] >> 0) & 0x01;
  bit1 = (color_prom[0] >> 1) & 0x01;
  bit2 = (color_prom[0] >> 2) & 0x01;
  bit3 = (color_prom[0] >> 3) & 0x01;
  *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  bit0 = (color_prom[Machine->drv->total_colors] >> 0) & 0x01;
  bit1 = (color_prom[Machine->drv->total_colors] >> 1) & 0x01;
  bit2 = (color_prom[Machine->drv->total_colors] >> 2) & 0x01;
  bit3 = (color_prom[Machine->drv->total_colors] >> 3) & 0x01;
  *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  color_prom++;
 }
}

variable_types:
palette
unsigned char *

variable_types:
colortable
unsigned short *


decompiled_code:
__int64 sidepckt_i8751_r()
{
return (unsigned int)i8751_return;
}

canonical_decompiled_code:
__int64 func2()
{
return (unsigned int)i8751_return;
}

original_code:
static data_t sidepckt_i8751_r(offs_t offset)
{
 return i8751_return;
}

canonical_original_code:
static unsigned int sidepckt_i8751_r(unsigned int offset)
{
 return i8751_return;
}


decompiled_code:
__int64 sidepckt_vh_start()
{
__int64 v0; // rax
unsigned int v1; // er8

v0 = tilemap_create(get_tile_info, &tilemap_scan_rows, 2LL, 8LL, 8LL, 32LL, 32LL);
v1 = 1;
bg_tilemap = v0;
if ( v0 )
{
*(_QWORD *)(v0 + 136) = 0x1000000FFLL;
tilemap_set_flip(0LL, 1LL);
v1 = 0;
}
return v1;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
unsigned int v1; // er8

v0 = tilemap_create(get_tile_info, &tilemap_scan_rows, 2LL, 8LL, 8LL, 32LL, 32LL);
v1 = 1;
bg_tilemap = v0;
if ( v0 )
{
*(_QWORD *)(v0 + 136) = 0x1000000FFLL;
tilemap_set_flip(0LL, 1LL);
v1 = 0;
}
return v1;
}

original_code:
int sidepckt_vh_start(void)
{
 bg_tilemap = tilemap_create(get_tile_info,tilemap_scan_rows,0x02,8,8,32,32);
 if (!bg_tilemap)
  return 1;
 bg_tilemap->transmask[0] = 0xff;
 bg_tilemap->transmask[1] = 0x01;
 tilemap_set_flip(0,0x1);
 return 0;
}

canonical_original_code:
int sidepckt_vh_start()
{
 bg_tilemap = tilemap_create(get_tile_info,tilemap_scan_rows,0x02,8,8,32,32);
 if (!bg_tilemap)
  return 1;
 bg_tilemap->transmask[0] = 0xff;
 bg_tilemap->transmask[1] = 0x01;
 tilemap_set_flip(0,0x1);
 return 0;
}


decompiled_code:
__int64 __fastcall sidepckt_flipscreen_w(__int64 a1, int a2)
{
return tilemap_set_flip(0LL, 1 - ((unsigned int)(a2 == 0) - 1));
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
return tilemap_set_flip(0LL, 1 - ((unsigned int)(a2 == 0) - 1));
}

original_code:
void sidepckt_flipscreen_w(offs_t offset,data_t data)
{
 flipscreen = data;
 tilemap_set_flip(0,flipscreen ? 0x2 : 0x1);
}

canonical_original_code:
void sidepckt_flipscreen_w(unsigned int offset, unsigned int data)
{
 flipscreen = data;
 tilemap_set_flip(0,flipscreen ? 0x2 : 0x1);
}

variable_types:
data
unsigned int


decompiled_code:
__int64 __fastcall sidepckt_vh_screenrefresh(__int64 a1)
{
tilemap_update(0LL);
tilemap_render(0LL);
tilemap_draw(a1, bg_tilemap, 32LL);
draw_sprites(a1);
return tilemap_draw(a1, bg_tilemap, 64LL);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
tilemap_update(0LL);
tilemap_render(0LL);
tilemap_draw(a1, bg_tilemap, 32LL);
draw_sprites(a1);
return tilemap_draw(a1, bg_tilemap, 64LL);
}

original_code:
void sidepckt_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 tilemap_update(0);
 tilemap_render(0);
 tilemap_draw(bitmap,bg_tilemap,0x20);
 draw_sprites(bitmap);
 tilemap_draw(bitmap,bg_tilemap,0x40);
}

canonical_original_code:
void sidepckt_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 tilemap_update(0);
 tilemap_render(0);
 tilemap_draw(bitmap,bg_tilemap,0x20);
 draw_sprites(bitmap);
 tilemap_draw(bitmap,bg_tilemap,0x40);
}


decompiled_code:
__int64 __fastcall sidepckt_i8751_w(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // [rsp+4h] [rbp-94h]
int v4; // [rsp+Ch] [rbp-8Ch]
__int64 v5[8]; // [rsp+10h] [rbp-88h]
__int64 v6[9]; // [rsp+50h] [rbp-48h]

v3 = 0x300000005LL;
v5[0] = 0x420000008ELL;
v5[1] = 0x58000000ADLL;
v5[2] = 0x85000000ECLL;
v5[3] = 0x4C000000DDLL;
v5[4] = 0x9F000000ADLL;
v5[5] = 0x4C00000000LL;
v5[6] = 0x420000007ELL;
v5[7] = 0xFF000000A2LL;
v6[0] = 0x73000000BDLL;
v6[3] = 0x73000000BDLL;
v6[4] = 0x7E000000E0LL;
v6[2] = 0xA700000073LL;
v6[5] = 0x5600000072LL;
v6[6] = 0xFF000000FFLL;
v6[7] = 0xFF000000FFLL;
v4 = 2;
v6[1] = 0xBD00000080LL;
cpu_cause_interrupt(0LL, 2LL);
result = (unsigned int)in_math_7;
if ( in_math_7 == 1 )
{
math_param_6 = a2;
i8751_return = a2;
in_math_7 = 2;
}
else if ( in_math_7 == 2 )
{
in_math_7 = 0;
result = math_param_6 / a2;
i8751_return = math_param_6 / a2;
}
else
{
switch ( a2 )
{
case 1u:
current_table_5 = 1;
current_ptr_4 = 1;
i8751_return = 5;
break;
case 2u:
current_table_5 = 2;
current_ptr_4 = 1;
i8751_return = 142;
break;
case 3u:
current_table_5 = 3;
current_ptr_4 = 1;
i8751_return = 189;
break;
case 4u:
in_math_7 = 1;
i8751_return = 4;
break;
case 6u:
result = (unsigned int)current_table_5;
switch ( current_table_5 )
{
case 1:
result = *((unsigned int *)&v3 + current_ptr_4++);
i8751_return = result;
break;
case 2:
result = *((unsigned int *)v5 + current_ptr_4++);
i8751_return = result;
break;
case 3:
result = *((unsigned int *)v6 + current_ptr_4++);
i8751_return = result;
break;
}
break;
default:
return result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // [rsp+4h] [rbp-94h]
int v4; // [rsp+Ch] [rbp-8Ch]
__int64 v5[8]; // [rsp+10h] [rbp-88h]
__int64 v6[9]; // [rsp+50h] [rbp-48h]

v3 = 0x300000005LL;
v5[0] = 0x420000008ELL;
v5[1] = 0x58000000ADLL;
v5[2] = 0x85000000ECLL;
v5[3] = 0x4C000000DDLL;
v5[4] = 0x9F000000ADLL;
v5[5] = 0x4C00000000LL;
v5[6] = 0x420000007ELL;
v5[7] = 0xFF000000A2LL;
v6[0] = 0x73000000BDLL;
v6[3] = 0x73000000BDLL;
v6[4] = 0x7E000000E0LL;
v6[2] = 0xA700000073LL;
v6[5] = 0x5600000072LL;
v6[6] = 0xFF000000FFLL;
v6[7] = 0xFF000000FFLL;
v4 = 2;
v6[1] = 0xBD00000080LL;
cpu_cause_interrupt(0LL, 2LL);
result = (unsigned int)in_math_7;
if ( in_math_7 == 1 )
{
math_param_6 = a2;
i8751_return = a2;
in_math_7 = 2;
}
else if ( in_math_7 == 2 )
{
in_math_7 = 0;
result = math_param_6 / a2;
i8751_return = math_param_6 / a2;
}
else
{
switch ( a2 )
{
case 1u:
current_table_5 = 1;
current_ptr_4 = 1;
i8751_return = 5;
break;
case 2u:
current_table_5 = 2;
current_ptr_4 = 1;
i8751_return = 142;
break;
case 3u:
current_table_5 = 3;
current_ptr_4 = 1;
i8751_return = 189;
break;
case 4u:
in_math_7 = 1;
i8751_return = 4;
break;
case 6u:
result = (unsigned int)current_table_5;
switch ( current_table_5 )
{
case 1:
result = *((unsigned int *)&v3 + current_ptr_4++);
i8751_return = result;
break;
case 2:
result = *((unsigned int *)v5 + current_ptr_4++);
i8751_return = result;
break;
case 3:
result = *((unsigned int *)v6 + current_ptr_4++);
i8751_return = result;
break;
}
break;
default:
return result;
}
}
return result;
}

original_code:
static void sidepckt_i8751_w(offs_t offset,data_t data)
{
 int table_1[]={5,3,2};
 int table_2[]={0x8e,0x42,0xad,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa2,0xff};
 int table_3[]={0xbd,0x73,0x80,0xbd,0x73,0xa7,0xbd,0x73,0xe0,0x7e,0x72,0x56,0xff,0xff,0xff,0xff};
 static int current_ptr=0,current_table=0,in_math=0,math_param;
 cpu_cause_interrupt(0,2);
 if (in_math==1) {
  in_math=2;
  i8751_return=math_param=data;
 }
 else if (in_math==2) {
  in_math=0;
  i8751_return=math_param/data;
 }
 else switch (data) {
  case 1:
   current_table=1; current_ptr=0; i8751_return=table_1[current_ptr++]; break;
  case 2:
   current_table=2; current_ptr=0; i8751_return=table_2[current_ptr++]; break;
  case 3:
   current_table=3; current_ptr=0; i8751_return=table_3[current_ptr++]; break;
  case 4:
   in_math=1;
   i8751_return=4;
   break;
  case 6:
   if (current_table==1) i8751_return=table_1[current_ptr++];
   if (current_table==2) i8751_return=table_2[current_ptr++];
   if (current_table==3) i8751_return=table_3[current_ptr++];
   break;
 }
}

canonical_original_code:
static void sidepckt_i8751_w(unsigned int offset, unsigned int data)
{
 int table_1[] = {5,3,2};
 int table_2[] = {0x8e,0x42,0xad,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa2,0xff};
 int table_3[] = {0xbd,0x73,0x80,0xbd,0x73,0xa7,0xbd,0x73,0xe0,0x7e,0x72,0x56,0xff,0xff,0xff,0xff};
 static int current_ptr = 0; static int current_table = 0; static int in_math = 0; static int math_param;
 cpu_cause_interrupt(0,2);
 if (in_math==1) {
  in_math=2;
  i8751_return=math_param=data;
 }
 else if (in_math==2) {
  in_math=0;
  i8751_return=math_param/data;
 }
 else switch (data) {
  case 1:
   current_table=1; current_ptr=0; i8751_return=table_1[current_ptr++]; break;
  case 2:
   current_table=2; current_ptr=0; i8751_return=table_2[current_ptr++]; break;
  case 3:
   current_table=3; current_ptr=0; i8751_return=table_3[current_ptr++]; break;
  case 4:
   in_math=1;
   i8751_return=4;
   break;
  case 6:
   if (current_table==1) i8751_return=table_1[current_ptr++];
   if (current_table==2) i8751_return=table_2[current_ptr++];
   if (current_table==3) i8751_return=table_3[current_ptr++];
   break;
 }
}


decompiled_code:
__int64 __fastcall sidepctj_i8751_w(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // [rsp+4h] [rbp-94h]
int v4; // [rsp+Ch] [rbp-8Ch]
__int64 v5[8]; // [rsp+10h] [rbp-88h]
__int64 v6[9]; // [rsp+50h] [rbp-48h]

v3 = 0x300000005LL;
v5[0] = 0x420000008ELL;
v5[1] = 0x58000000B2LL;
v5[2] = 0x85000000ECLL;
v5[3] = 0x4C000000DDLL;
v5[4] = 0x9F000000ADLL;
v5[5] = 0x4C00000000LL;
v5[6] = 0x420000007ELL;
v5[7] = 0xFF000000A7LL;
v6[0] = 0x71000000BDLL;
v6[1] = 0xBD000000C8LL;
v6[2] = 0xEF00000071LL;
v6[3] = 0x72000000BDLL;
v6[4] = 0x7E00000028LL;
v6[5] = 0x9E00000070LL;
v6[6] = 0xFF000000FFLL;
v6[7] = 0xFF000000FFLL;
v4 = 0;
cpu_cause_interrupt(0LL, 2LL);
result = (unsigned int)in_math_3;
if ( in_math_3 == 1 )
{
math_param_2 = a2;
i8751_return = a2;
in_math_3 = 2;
}
else if ( in_math_3 == 2 )
{
in_math_3 = 0;
result = math_param_2 / a2;
i8751_return = math_param_2 / a2;
}
else
{
switch ( a2 )
{
case 1u:
current_table_1 = 1;
current_ptr_0 = 1;
i8751_return = 5;
break;
case 2u:
current_table_1 = 2;
current_ptr_0 = 1;
i8751_return = 142;
break;
case 3u:
current_table_1 = 3;
current_ptr_0 = 1;
i8751_return = 189;
break;
case 4u:
in_math_3 = 1;
i8751_return = 4;
break;
case 6u:
result = (unsigned int)current_table_1;
switch ( current_table_1 )
{
case 1:
result = *((unsigned int *)&v3 + current_ptr_0++);
i8751_return = result;
break;
case 2:
result = *((unsigned int *)v5 + current_ptr_0++);
i8751_return = result;
break;
case 3:
result = *((unsigned int *)v6 + current_ptr_0++);
i8751_return = result;
break;
}
break;
default:
return result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned int a2)
{
__int64 result; // rax
__int64 v3; // [rsp+4h] [rbp-94h]
int v4; // [rsp+Ch] [rbp-8Ch]
__int64 v5[8]; // [rsp+10h] [rbp-88h]
__int64 v6[9]; // [rsp+50h] [rbp-48h]

v3 = 0x300000005LL;
v5[0] = 0x420000008ELL;
v5[1] = 0x58000000B2LL;
v5[2] = 0x85000000ECLL;
v5[3] = 0x4C000000DDLL;
v5[4] = 0x9F000000ADLL;
v5[5] = 0x4C00000000LL;
v5[6] = 0x420000007ELL;
v5[7] = 0xFF000000A7LL;
v6[0] = 0x71000000BDLL;
v6[1] = 0xBD000000C8LL;
v6[2] = 0xEF00000071LL;
v6[3] = 0x72000000BDLL;
v6[4] = 0x7E00000028LL;
v6[5] = 0x9E00000070LL;
v6[6] = 0xFF000000FFLL;
v6[7] = 0xFF000000FFLL;
v4 = 0;
cpu_cause_interrupt(0LL, 2LL);
result = (unsigned int)in_math_3;
if ( in_math_3 == 1 )
{
math_param_2 = a2;
i8751_return = a2;
in_math_3 = 2;
}
else if ( in_math_3 == 2 )
{
in_math_3 = 0;
result = math_param_2 / a2;
i8751_return = math_param_2 / a2;
}
else
{
switch ( a2 )
{
case 1u:
current_table_1 = 1;
current_ptr_0 = 1;
i8751_return = 5;
break;
case 2u:
current_table_1 = 2;
current_ptr_0 = 1;
i8751_return = 142;
break;
case 3u:
current_table_1 = 3;
current_ptr_0 = 1;
i8751_return = 189;
break;
case 4u:
in_math_3 = 1;
i8751_return = 4;
break;
case 6u:
result = (unsigned int)current_table_1;
switch ( current_table_1 )
{
case 1:
result = *((unsigned int *)&v3 + current_ptr_0++);
i8751_return = result;
break;
case 2:
result = *((unsigned int *)v5 + current_ptr_0++);
i8751_return = result;
break;
case 3:
result = *((unsigned int *)v6 + current_ptr_0++);
i8751_return = result;
break;
}
break;
default:
return result;
}
}
return result;
}

original_code:
static void sidepctj_i8751_w(offs_t offset,data_t data)
{
 int table_1[]={5,3,0};
 int table_2[]={0x8e,0x42,0xb2,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa7,0xff};
 int table_3[]={0xbd,0x71,0xc8,0xbd,0x71,0xef,0xbd,0x72,0x28,0x7e,0x70,0x9e,0xff,0xff,0xff,0xff};
 static int current_ptr=0,current_table=0,in_math,math_param;
 cpu_cause_interrupt(0,2);
 if (in_math==1) {
  in_math=2;
  i8751_return=math_param=data;
 }
 else if (in_math==2) {
  in_math=0;
  i8751_return=math_param/data;
 }
 else switch (data) {
  case 1:
   current_table=1; current_ptr=0; i8751_return=table_1[current_ptr++]; break;
  case 2:
   current_table=2; current_ptr=0; i8751_return=table_2[current_ptr++]; break;
  case 3:
   current_table=3; current_ptr=0; i8751_return=table_3[current_ptr++]; break;
  case 4:
   in_math=1;
   i8751_return=4;
   break;
  case 6:
   if (current_table==1) i8751_return=table_1[current_ptr++];
   if (current_table==2) i8751_return=table_2[current_ptr++];
   if (current_table==3) i8751_return=table_3[current_ptr++];
   break;
 }
}

canonical_original_code:
static void sidepctj_i8751_w(unsigned int offset, unsigned int data)
{
 int table_1[] = {5,3,0};
 int table_2[] = {0x8e,0x42,0xb2,0x58,0xec,0x85,0xdd,0x4c,0xad,0x9f,0x00,0x4c,0x7e,0x42,0xa7,0xff};
 int table_3[] = {0xbd,0x71,0xc8,0xbd,0x71,0xef,0xbd,0x72,0x28,0x7e,0x70,0x9e,0xff,0xff,0xff,0xff};
 static int current_ptr = 0; static int current_table = 0; static int in_math; static int math_param;
 cpu_cause_interrupt(0,2);
 if (in_math==1) {
  in_math=2;
  i8751_return=math_param=data;
 }
 else if (in_math==2) {
  in_math=0;
  i8751_return=math_param/data;
 }
 else switch (data) {
  case 1:
   current_table=1; current_ptr=0; i8751_return=table_1[current_ptr++]; break;
  case 2:
   current_table=2; current_ptr=0; i8751_return=table_2[current_ptr++]; break;
  case 3:
   current_table=3; current_ptr=0; i8751_return=table_3[current_ptr++]; break;
  case 4:
   in_math=1;
   i8751_return=4;
   break;
  case 6:
   if (current_table==1) i8751_return=table_1[current_ptr++];
   if (current_table==2) i8751_return=table_2[current_ptr++];
   if (current_table==3) i8751_return=table_3[current_ptr++];
   break;
 }
}


decompiled_code:
__int64 __fastcall get_tile_info(int a1)
{
int v1; // ecx
__int64 v2; // rsi
unsigned int v3; // edx
int v4; // eax
__int64 v5; // rdi
__int64 v6; // rsi
__int64 result; // rax

v1 = *(unsigned __int8 *)(colorram + a1);
v2 = *(_QWORD *)(Machine + 512LL);
v3 = (*(unsigned __int8 *)(videoram + a1) + ((*(unsigned __int8 *)(colorram + a1) << 8) & 0x700u))
% *(_DWORD *)(v2 + 8);
tile_info = *(_QWORD *)(v2 + 40) + (int)(v3 * *(_DWORD *)(v2 + 52));
v4 = *(_DWORD *)(v2 + 12) * ((v1 >> 5) & 1 | (v1 >> 3) & 2);
v5 = *(_QWORD *)(v2 + 16);
v6 = *(_QWORD *)(v2 + 32);
*((_QWORD *)&tile_info + 1) = v5 + 2LL * v4;
result = 0LL;
if ( v6 )
result = *(unsigned int *)(v6 + 4LL * v3);
*((_DWORD *)&tile_info + 4) = result;
*((_DWORD *)&tile_info + 5) = 4 * ((unsigned __int8)v1 >> 7) + 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
int v1; // ecx
__int64 v2; // rsi
unsigned int v3; // edx
int v4; // eax
__int64 v5; // rdi
__int64 v6; // rsi
__int64 result; // rax

v1 = *(unsigned __int8 *)(colorram + a1);
v2 = *(_QWORD *)(Machine + 512LL);
v3 = (*(unsigned __int8 *)(videoram + a1) + ((*(unsigned __int8 *)(colorram + a1) << 8) & 0x700u))
% *(_DWORD *)(v2 + 8);
tile_info = *(_QWORD *)(v2 + 40) + (int)(v3 * *(_DWORD *)(v2 + 52));
v4 = *(_DWORD *)(v2 + 12) * ((v1 >> 5) & 1 | (v1 >> 3) & 2);
v5 = *(_QWORD *)(v2 + 16);
v6 = *(_QWORD *)(v2 + 32);
*((_QWORD *)&tile_info + 1) = v5 + 2LL * v4;
result = 0LL;
if ( v6 )
result = *(unsigned int *)(v6 + 4LL * v3);
*((_DWORD *)&tile_info + 4) = result;
*((_DWORD *)&tile_info + 5) = 4 * ((unsigned __int8)v1 >> 7) + 1;
return result;
}

original_code:
static void get_tile_info(int tile_index)
{
 unsigned char attr = colorram[tile_index];
 { const struct GfxElement *gfx = Machine->gfx[(0)]; int _code = (videoram[tile_index] + ((attr & 0x07) << 8)) % gfx->total_elements; tile_info.pen_data = gfx->gfxdata + _code*gfx->char_modulo; tile_info.pal_data = &gfx->colortable[gfx->color_granularity * (((attr & 0x10) >> 3) | ((attr & 0x20) >> 5))]; tile_info.pen_usage = gfx->pen_usage?gfx->pen_usage[_code]:0; }
 tile_info.flags = 0x01 | (((attr & 0x80) >> 7)<<2);
}

canonical_original_code:
static void get_tile_info(int tile_index)
{
 unsigned char attr = colorram[tile_index];
 { struct GfxElement *gfx = Machine->gfx[(0)]; int _code = (videoram[tile_index] + ((attr & 0x07) << 8)) % gfx->total_elements; tile_info.pen_data = gfx->gfxdata + _code*gfx->char_modulo; tile_info.pal_data = &gfx->colortable[gfx->color_granularity * (((attr & 0x10) >> 3) | ((attr & 0x20) >> 5))]; tile_info.pen_usage = gfx->pen_usage?gfx->pen_usage[_code]:0; }
 tile_info.flags = 0x01 | (((attr & 0x80) >> 7)<<2);
}

variable_types:
attr
unsigned char

variable_types: struct GfxElement { int width; unsigned int total_elements; int color_granularity; unsigned short *colortable; int total_colors; unsigned int *pen_usage; unsigned char *gfxdata; int line_modulo; int char_modulo; } *


irqhandler

decompiled_code:
__int64 __fastcall irqhandler(unsigned int a1)
{
return cpu_set_irq_line(1LL, 0LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
return cpu_set_irq_line(1LL, 0LL, a1);
}

original_code:
static void irqhandler(int linestate)
{
 cpu_set_irq_line(1,0,linestate);
}

variable_types: linestate int


decompiled_code:
__int64 sound_cpu_command_w()
{
soundlatch_w();
return cpu_cause_interrupt(1LL, 2LL);
}

canonical_decompiled_code:
__int64 func9()
{
soundlatch_w();
return cpu_cause_interrupt(1LL, 2LL);
}

original_code:
static void sound_cpu_command_w(offs_t offset,data_t data)
{
    soundlatch_w(offset,data);
    cpu_cause_interrupt(1,2);
}

canonical_original_code:
static void sound_cpu_command_w(unsigned int offset, unsigned int data)
{
    soundlatch_w(offset,data);
    cpu_cause_interrupt(1,2);
}


decompiled_code:
_QWORD *rollerg_init_machine()
{
_QWORD *result; // rax

result = &konami_cpu_setlines_callback;
readzoomroms = 0;
konami_cpu_setlines_callback = rollerg_banking;
return result;
}

canonical_decompiled_code:
_QWORD *func3()
{
_QWORD *result; // rax

result = &konami_cpu_setlines_callback;
readzoomroms = 0;
konami_cpu_setlines_callback = rollerg_banking;
return result;
}

original_code:
static void rollerg_init_machine( void )
{
 konami_cpu_setlines_callback = rollerg_banking;
 readzoomroms = 0;
}

canonical_original_code:
static void rollerg_init_machine()
{
 konami_cpu_setlines_callback = rollerg_banking;
 readzoomroms = 0;
}


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

bg_colorbase = 16;
sprite_colorbase = 16;
zoom_colorbase = 0;
if ( (unsigned int)K053245_vh_start(137LL, 0LL, 1LL, 2LL, 3LL, sprite_callback) )
return 1LL;
if ( (unsigned int)K051316_vh_start_0(138LL, 4LL, zoom_callback) )
{
K053245_vh_stop();
result = 1LL;
}
else
{
K051316_set_offset(0LL, 22LL, 1LL);
result = 0LL;
}
return result;
}

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

bg_colorbase = 16;
sprite_colorbase = 16;
zoom_colorbase = 0;
if ( (unsigned int)K053245_vh_start(137LL, 0LL, 1LL, 2LL, 3LL, sprite_callback) )
return 1LL;
if ( (unsigned int)K051316_vh_start_0(138LL, 4LL, zoom_callback) )
{
K053245_vh_stop();
result = 1LL;
}
else
{
K051316_set_offset(0LL, 22LL, 1LL);
result = 0LL;
}
return result;
}

original_code:
int rollerg_vh_start(void)
{
 bg_colorbase = 16;
 sprite_colorbase = 16;
 zoom_colorbase = 0;
 if (K053245_vh_start(REGION_GFX1,0,1,2,3,sprite_callback))
  return 1;
 if (K051316_vh_start_0(REGION_GFX2,4,zoom_callback))
 {
  K053245_vh_stop();
  return 1;
 }
 K051316_set_offset(0, 22, 1);
 return 0;
}

canonical_original_code:
int rollerg_vh_start()
{
 bg_colorbase = 16;
 sprite_colorbase = 16;
 zoom_colorbase = 0;
 if (K053245_vh_start(REGION_GFX1,0,1,2,3,sprite_callback))
  return 1;
 if (K051316_vh_start_0(REGION_GFX2,4,zoom_callback))
 {
  K053245_vh_stop();
  return 1;
 }
 K051316_set_offset(0, 22, 1);
 return 0;
}


decompiled_code:
__int64 rollerg_vh_stop()
{
K053245_vh_stop();
return K051316_vh_stop_0();
}

original_code:
void rollerg_vh_stop(void)
{
 K053245_vh_stop();
 K051316_vh_stop_0();
}

canonical_original_code:
void rollerg_vh_stop()
{
 K053245_vh_stop();
 K051316_vh_stop_0();
}


decompiled_code:
__int64 __fastcall rollerg_vh_screenrefresh(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rsi

K051316_tilemap_update_0();
palette_init_used_colors();
K053245_mark_sprites_colors();
v1 = 16 * zoom_colorbase;
v2 = v1 + 256;
do
{
*(_BYTE *)(palette_used_colors + v1) = 7;
v1 += 16LL;
}
while ( v1 != v2 );
*(_BYTE *)(palette_used_colors + 16 * bg_colorbase) |= 1u;
if ( palette_recalc() )
tilemap_mark_all_pixels_dirty(0LL);
tilemap_render(0LL);
fillbitmap(priority_bitmap, 0LL, 0LL);
fillbitmap(a1, *(unsigned __int16 *)(*(_QWORD *)(Machine + 792LL) + 32LL * bg_colorbase), Machine + 776LL);
K051316_zoom_draw_0(a1, 1LL);
return K053245_sprites_draw(a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rsi

K051316_tilemap_update_0();
palette_init_used_colors();
K053245_mark_sprites_colors();
v1 = 16 * zoom_colorbase;
v2 = v1 + 256;
do
{
*(_BYTE *)(palette_used_colors + v1) = 7;
v1 += 16LL;
}
while ( v1 != v2 );
*(_BYTE *)(palette_used_colors + 16 * bg_colorbase) |= 1u;
if ( palette_recalc() )
tilemap_mark_all_pixels_dirty(0LL);
tilemap_render(0LL);
fillbitmap(priority_bitmap, 0LL, 0LL);
fillbitmap(a1, *(unsigned __int16 *)(*(_QWORD *)(Machine + 792LL) + 32LL * bg_colorbase), Machine + 776LL);
K051316_zoom_draw_0(a1, 1LL);
return K053245_sprites_draw(a1);
}

original_code:
void rollerg_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int i;
 K051316_tilemap_update_0();
 palette_init_used_colors();
 K053245_mark_sprites_colors();
 for (i = 0;i < 16;i++)
  palette_used_colors[(zoom_colorbase + i) * 16] = (4|(1|2));
 palette_used_colors[16 * bg_colorbase] |= 1;
 if (palette_recalc())
  tilemap_mark_all_pixels_dirty(0);
 tilemap_render(0);
 fillbitmap(priority_bitmap,0,((void *)0));
 fillbitmap(bitmap,Machine->pens[16 * bg_colorbase],&Machine->visible_area);
 K051316_zoom_draw_0(bitmap,1);
 K053245_sprites_draw(bitmap);
}

canonical_original_code:
void rollerg_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int i;
 K051316_tilemap_update_0();
 palette_init_used_colors();
 K053245_mark_sprites_colors();
 for (i = 0;i < 16;i++)
  palette_used_colors[(zoom_colorbase + i) * 16] = (4|(1|2));
 palette_used_colors[16 * bg_colorbase] |= 1;
 if (palette_recalc())
  tilemap_mark_all_pixels_dirty(0);
 tilemap_render(0);
 fillbitmap(priority_bitmap,0,((void *)0));
 fillbitmap(bitmap,Machine->pens[16 * bg_colorbase],&Machine->visible_area);
 K051316_zoom_draw_0(bitmap,1);
 K053245_sprites_draw(bitmap);
}


decompiled_code:
__int64 init_rollerg()
{
return konami_rom_deinterleave_2(137LL);
}

canonical_decompiled_code:
__int64 func7()
{
return konami_rom_deinterleave_2(137LL);
}

original_code:
static void init_rollerg(void)
{
 konami_rom_deinterleave_2(REGION_GFX1);
}

canonical_original_code:
static void init_rollerg()
{
 konami_rom_deinterleave_2(REGION_GFX1);
}


decompiled_code:
void *__fastcall rollerg_banking(char a1)
{
__int64 v1; // rax
int v2; // edi
void *result; // rax
unsigned int v4; // eax

v1 = memory_region(129LL);
v2 = ((a1 & 7) + 4) << 14;
if ( v2 > 163839 )
v2 -= 0x20000;
cpu_bankbase[1] = v1 + v2;
result = &ophw;
if ( ophw == 1 )
{
ophw = -1;
v4 = cpu_get_pc();
result = (void *)cpu_setOPbase16(v4);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func8(char a1)
{
__int64 v1; // rax
int v2; // edi
void *result; // rax
unsigned int v4; // eax

v1 = memory_region(129LL);
v2 = ((a1 & 7) + 4) << 14;
if ( v2 > 163839 )
v2 -= 0x20000;
cpu_bankbase[1] = v1 + v2;
result = &ophw;
if ( ophw == 1 )
{
ophw = -1;
v4 = cpu_get_pc();
result = (void *)cpu_setOPbase16(v4);
}
return result;
}

original_code:
static void rollerg_banking( int lines )
{
 unsigned char *RAM = memory_region(REGION_CPU1);
 int offs = 0;
 offs = 0x10000 + ((lines & 0x07) * 0x4000);
 if (offs >= 0x28000) offs -= 0x20000;
 { if (1 >= 1 && 1 <= 16) { cpu_bankbase[1] = (UINT8 *)(&RAM[offs]); if (ophw == 1) { ophw = 0xff; cpu_setOPbase16(cpu_get_pc()); } } };
}

canonical_original_code:
static void rollerg_banking(int lines)
{
 unsigned char *RAM = memory_region(REGION_CPU1);
 int offs = 0;
 offs = 0x10000 + ((lines & 0x07) * 0x4000);
 if (offs >= 0x28000) offs -= 0x20000;
 { if (1 >= 1 && 1 <= 16) { cpu_bankbase[1] = (unsigned char *)(&RAM[offs]); if (ophw == 1) { ophw = 0xff; cpu_setOPbase16(cpu_get_pc()); } } };
}

variable_types: lines int

variable_types:
RAM
unsigned char *


decompiled_code:
__int64 sound_arm_nmi_w()
{
cpu_set_nmi_line(1LL, 0LL);
return timer_set(53687LL, 0LL, nmi_callback);
}

canonical_decompiled_code:
__int64 func10()
{
cpu_set_nmi_line(1LL, 0LL);
return timer_set(53687LL, 0LL, nmi_callback);
}

original_code:
static void sound_arm_nmi_w(offs_t offset,data_t data)
{
 cpu_set_nmi_line(1,0);
 timer_set(((timer_tm)(((float)(50)*(float)((1<<30)))/(float)1000000)),0,nmi_callback);
}

canonical_original_code:
static void sound_arm_nmi_w(unsigned int offset, unsigned int data)
{
 cpu_set_nmi_line(1,0);
 timer_set(((timer_tm)(((float)(50)*(float)((1<<30)))/(float)1000000)),0,nmi_callback);
}


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

if ( *(_DWORD *)(Machine + 836LL) )
result = K053260_r((unsigned int)(a1 + 2));
else
result = 0LL;
return result;
}

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

if ( *(_DWORD *)(Machine + 836LL) )
result = K053260_r((unsigned int)(a1 + 2));
else
result = 0LL;
return result;
}

original_code:
static data_t rollerg_sound_r(offs_t offset)
{
 if (Machine->sample_rate != 0) return K053260_r(2 + offset);
 else return 0x00;
}

canonical_original_code:
static unsigned int rollerg_sound_r(unsigned int offset)
{
 if (Machine->sample_rate != 0) return K053260_r(2 + offset);
 else return 0x00;
}


decompiled_code:
__int64 soundirq_w()
{
return cpu_cause_interrupt(1LL, 255LL);
}

canonical_decompiled_code:
__int64 func12()
{
return cpu_cause_interrupt(1LL, 255LL);
}

original_code:
static void soundirq_w(offs_t offset,data_t data)
{
 cpu_cause_interrupt(1,0xff);
}

canonical_original_code:
static void soundirq_w(unsigned int offset, unsigned int data)
{
 cpu_cause_interrupt(1,0xff);
}


decompiled_code:
__int64 __fastcall rollerg_0010_w(__int64 a1, char a2)
{
coin_counter_w(0LL, a2 & 1);
coin_counter_w(1LL, a2 & 2);
readzoomroms = a2 & 4;
return K051316_wraparound_enable(0LL, a2 & 0x20);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, char a2)
{
coin_counter_w(0LL, a2 & 1);
coin_counter_w(1LL, a2 & 2);
readzoomroms = a2 & 4;
return K051316_wraparound_enable(0LL, a2 & 0x20);
}

original_code:
static void rollerg_0010_w(offs_t offset,data_t data)
{
 coin_counter_w(0,data & 0x01);
 coin_counter_w(1,data & 0x02);
 readzoomroms = data & 0x04;
 K051316_wraparound_enable(0, data & 0x20);
}

canonical_original_code:
static void rollerg_0010_w(unsigned int offset, unsigned int data)
{
 coin_counter_w(0,data & 0x01);
 coin_counter_w(1,data & 0x02);
 readzoomroms = data & 0x04;
 K051316_wraparound_enable(0, data & 0x20);
}


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

if ( readzoomroms )
result = K051316_rom_0_r();
else
result = K051316_0_r();
return result;
}

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

if ( readzoomroms )
result = K051316_rom_0_r();
else
result = K051316_0_r();
return result;
}

original_code:
static data_t rollerg_K051316_r(offs_t offset)
{
 if (readzoomroms) return K051316_rom_0_r(offset);
 else return K051316_0_r(offset);
}

canonical_original_code:
static unsigned int rollerg_K051316_r(unsigned int offset)
{
 if (readzoomroms) return K051316_rom_0_r(offset);
 else return K051316_0_r(offset);
}


decompiled_code:
__int64 __fastcall zoom_callback(_DWORD *a1, int *a2)
{
__int64 result; // rax

tile_info[5] = (*a2 >> 6) & 3;
*a1 |= ((unsigned __int16)*a2 << 8) & 0xF00;
result = zoom_colorbase + ((*a2 >> 4) & 3u);
*a2 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1, int *a2)
{
__int64 result; // rax

tile_info[5] = (*a2 >> 6) & 3;
*a1 |= ((unsigned __int16)*a2 << 8) & 0xF00;
result = zoom_colorbase + ((*a2 >> 4) & 3u);
*a2 = result;
return result;
}

original_code:
static void zoom_callback(int *code,int *color)
{
 tile_info.flags = ((*color & 0xc0) >> 6);
 *code |= ((*color & 0x0f) << 8);
 *color = zoom_colorbase + ((*color & 0x30) >> 4);
}

canonical_original_code:
static void zoom_callback(int *code, int *color)
{
 tile_info.flags = ((*color & 0xc0) >> 6);
 *code |= ((*color & 0x0f) << 8);
 *color = zoom_colorbase + ((*color & 0x30) >> 4);
}

variable_types:
code
int *

variable_types:
color
int *


decompiled_code:
__int64 pip_r()
{
return 127LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 127LL;
}

original_code:
static data_t pip_r(offs_t offset)
{
 return 0x7f;
}

canonical_original_code:
static unsigned int pip_r(unsigned int offset)
{
 return 0x7f;
}


original_code:
void seicross_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0,bit1,bit2;
  bit0 = (*color_prom >> 0) & 0x01;
  bit1 = (*color_prom >> 1) & 0x01;
  bit2 = (*color_prom >> 2) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = (*color_prom >> 3) & 0x01;
  bit1 = (*color_prom >> 4) & 0x01;
  bit2 = (*color_prom >> 5) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = 0;
  bit1 = (*color_prom >> 6) & 0x01;
  bit2 = (*color_prom >> 7) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  color_prom++;
 }
}

canonical_original_code:
void seicross_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable, unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0; int bit1; int bit2;
  bit0 = (*color_prom >> 0) & 0x01;
  bit1 = (*color_prom >> 1) & 0x01;
  bit2 = (*color_prom >> 2) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = (*color_prom >> 3) & 0x01;
  bit1 = (*color_prom >> 4) & 0x01;
  bit2 = (*color_prom >> 5) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = 0;
  bit1 = (*color_prom >> 6) & 0x01;
  bit2 = (*color_prom >> 7) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  color_prom++;
 }
}


decompiled_code:
void *__fastcall seicross_vh_screenrefresh(__int64 a1)
{
int v1; // er13
__int64 v2; // r14
__int16 v3; // r8
__int64 v4; // rcx
__int64 v5; // r9
int v6; // eax
__int64 v7; // rdx
__int64 v8; // rcx
__int64 i; // rax
int v10; // er12
__int64 v11; // r15
int v12; // er13
char v13; // al
char v14; // r8
void *result; // rax
int v16; // er12
__int64 v17; // r15
int v18; // er13
char v19; // al
__int64 v20; // rdx
unsigned __int8 v21; // r9
__int64 v22; // rcx
__int64 v23; // rax
__int64 v24; // [rsp-28h] [rbp-E0h]
__int64 v25; // [rsp-28h] [rbp-E0h]
_DWORD v26[46]; // [rsp+0h] [rbp-B8h] BYREF

v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
while ( !*(_BYTE *)(v2 + dirtybuffer) )
{
--v1;
--v2;
if ( v1 == -1 )
goto LABEL_6;
}
*(_BYTE *)(v2 + dirtybuffer) = 0;
v3 = *(unsigned __int8 *)(colorram + v2);
v4 = *(_BYTE *)(colorram + v2) & 0xF;
v5 = *(_BYTE *)(colorram + v2) & 0x80;
v6 = *(unsigned __int8 *)(videoram + v2--);
v7 = v6 + ((16 * v3) & 0x100u);
v24 = (unsigned int)(8 * (v1 >> 5));
LOBYTE(v6) = v1--;
drawgfx(tmpbitmap, *(_QWORD *)(Machine + 512LL), v7, v4, v3 & 0x40, v5, 8 * (v6 & 0x1Fu), v24, 0LL, 0LL, 0LL);
}
while ( v1 != -1 );
}
LABEL_6:
v8 = seicross_row_scroll;
for ( i = 0LL; i != 32; ++i )
v26[i] = -*(unsigned __int8 *)(v8 + i);
copyscrollbitmap(a1, tmpbitmap, 0LL, 0LL, 32LL, v26, Machine + 776LL, 0LL, 0LL);
v10 = spriteram_size - 4;
if ( spriteram_size - 4 >= 0 )
{
v11 = v10 + 3LL;
do
{
while ( 1 )
{
v12 = *(unsigned __int8 *)(spriteram + v11);
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(*(_BYTE *)(spriteram + v11 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram + v11 - 2)) & 0x40u) + 128,
*(_BYTE *)(spriteram + v11 - 2) & 0xF,
*(_BYTE *)(spriteram + v11 - 3) & 0x40,
*(_BYTE *)(spriteram + v11 - 3) & 0x80,
*(unsigned __int8 *)(spriteram + v11),
240 - (unsigned int)*(unsigned __int8 *)(spriteram + v11 - 1),
Machine + 776LL,
2LL,
0LL);
if ( v12 > 240 )
break;
v11 -= 4LL;
v10 -= 4;
if ( v10 < 0 )
goto LABEL_13;
}
v13 = *(_BYTE *)(spriteram + v11 - 2);
v14 = *(_BYTE *)(spriteram + v11 - 3);
v25 = 240 - (unsigned int)*(unsigned __int8 *)(spriteram + v11 - 1);
v11 -= 4LL;
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(v14 & 0x3F | (4 * v13) & 0x40u) + 128,
v13 & 0xF,
v14 & 0x40,
v14 & 0x80,
(unsigned int)(v12 - 256),
v25,
Machine + 776LL,
2LL,
0LL);
v10 -= 4;
}
while ( v10 >= 0 );
}
LABEL_13:
result = &spriteram_2_size;
v16 = spriteram_2_size - 4;
if ( spriteram_2_size - 4 >= 0 )
{
v17 = v16 + 3LL;
do
{
while ( 1 )
{
v18 = *(unsigned __int8 *)(spriteram_2 + v17);
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
*(_BYTE *)(spriteram_2 + v17 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram_2 + v17 - 2)) & 0x40u,
*(_BYTE *)(spriteram_2 + v17 - 2) & 0xF,
*(_BYTE *)(spriteram_2 + v17 - 3) & 0x40,
*(_BYTE *)(spriteram_2 + v17 - 3) & 0x80,
*(unsigned __int8 *)(spriteram_2 + v17),
240 - (unsigned int)*(unsigned __int8 *)(spriteram_2 + v17 - 1),
Machine + 776LL,
2LL,
0LL);
if ( v18 > 240 )
break;
v17 -= 4LL;
v16 -= 4;
if ( v16 < 0 )
return result;
}
v19 = *(_BYTE *)(spriteram_2 + v17 - 2);
v20 = *(_BYTE *)(spriteram_2 + v17 - 3) & 0x3F | (4 * v19) & 0x40u;
v21 = *(_BYTE *)(spriteram_2 + v17 - 3);
v22 = v19 & 0xF;
v23 = 240 - (unsigned int)*(unsigned __int8 *)(spriteram_2 + v17 - 1);
v17 -= 4LL;
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
v20,
v22,
v21 & 0x40,
v21 & 0x80,
(unsigned int)(v18 - 256),
v23,
Machine + 776LL,
2LL,
0LL);
v16 -= 4;
}
while ( v16 >= 0 );
}
return result;
}

canonical_decompiled_code:
void *__fastcall func3(__int64 a1)
{
int v1; // er13
__int64 v2; // r14
__int16 v3; // r8
__int64 v4; // rcx
__int64 v5; // r9
int v6; // eax
__int64 v7; // rdx
__int64 v8; // rcx
__int64 i; // rax
int v10; // er12
__int64 v11; // r15
int v12; // er13
char v13; // al
char v14; // r8
void *result; // rax
int v16; // er12
__int64 v17; // r15
int v18; // er13
char v19; // al
__int64 v20; // rdx
unsigned __int8 v21; // r9
__int64 v22; // rcx
__int64 v23; // rax
__int64 v24; // [rsp-28h] [rbp-E0h]
__int64 v25; // [rsp-28h] [rbp-E0h]
_DWORD v26[46]; // [rsp+0h] [rbp-B8h] BYREF

v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
while ( !*(_BYTE *)(v2 + dirtybuffer) )
{
--v1;
--v2;
if ( v1 == -1 )
goto LABEL_6;
}
*(_BYTE *)(v2 + dirtybuffer) = 0;
v3 = *(unsigned __int8 *)(colorram + v2);
v4 = *(_BYTE *)(colorram + v2) & 0xF;
v5 = *(_BYTE *)(colorram + v2) & 0x80;
v6 = *(unsigned __int8 *)(videoram + v2--);
v7 = v6 + ((16 * v3) & 0x100u);
v24 = (unsigned int)(8 * (v1 >> 5));
LOBYTE(v6) = v1--;
drawgfx(tmpbitmap, *(_QWORD *)(Machine + 512LL), v7, v4, v3 & 0x40, v5, 8 * (v6 & 0x1Fu), v24, 0LL, 0LL, 0LL);
}
while ( v1 != -1 );
}
LABEL_6:
v8 = seicross_row_scroll;
for ( i = 0LL; i != 32; ++i )
v26[i] = -*(unsigned __int8 *)(v8 + i);
copyscrollbitmap(a1, tmpbitmap, 0LL, 0LL, 32LL, v26, Machine + 776LL, 0LL, 0LL);
v10 = spriteram_size - 4;
if ( spriteram_size - 4 >= 0 )
{
v11 = v10 + 3LL;
do
{
while ( 1 )
{
v12 = *(unsigned __int8 *)(spriteram + v11);
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(*(_BYTE *)(spriteram + v11 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram + v11 - 2)) & 0x40u) + 128,
*(_BYTE *)(spriteram + v11 - 2) & 0xF,
*(_BYTE *)(spriteram + v11 - 3) & 0x40,
*(_BYTE *)(spriteram + v11 - 3) & 0x80,
*(unsigned __int8 *)(spriteram + v11),
240 - (unsigned int)*(unsigned __int8 *)(spriteram + v11 - 1),
Machine + 776LL,
2LL,
0LL);
if ( v12 > 240 )
break;
v11 -= 4LL;
v10 -= 4;
if ( v10 < 0 )
goto LABEL_13;
}
v13 = *(_BYTE *)(spriteram + v11 - 2);
v14 = *(_BYTE *)(spriteram + v11 - 3);
v25 = 240 - (unsigned int)*(unsigned __int8 *)(spriteram + v11 - 1);
v11 -= 4LL;
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(v14 & 0x3F | (4 * v13) & 0x40u) + 128,
v13 & 0xF,
v14 & 0x40,
v14 & 0x80,
(unsigned int)(v12 - 256),
v25,
Machine + 776LL,
2LL,
0LL);
v10 -= 4;
}
while ( v10 >= 0 );
}
LABEL_13:
result = &spriteram_2_size;
v16 = spriteram_2_size - 4;
if ( spriteram_2_size - 4 >= 0 )
{
v17 = v16 + 3LL;
do
{
while ( 1 )
{
v18 = *(unsigned __int8 *)(spriteram_2 + v17);
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
*(_BYTE *)(spriteram_2 + v17 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram_2 + v17 - 2)) & 0x40u,
*(_BYTE *)(spriteram_2 + v17 - 2) & 0xF,
*(_BYTE *)(spriteram_2 + v17 - 3) & 0x40,
*(_BYTE *)(spriteram_2 + v17 - 3) & 0x80,
*(unsigned __int8 *)(spriteram_2 + v17),
240 - (unsigned int)*(unsigned __int8 *)(spriteram_2 + v17 - 1),
Machine + 776LL,
2LL,
0LL);
if ( v18 > 240 )
break;
v17 -= 4LL;
v16 -= 4;
if ( v16 < 0 )
return result;
}
v19 = *(_BYTE *)(spriteram_2 + v17 - 2);
v20 = *(_BYTE *)(spriteram_2 + v17 - 3) & 0x3F | (4 * v19) & 0x40u;
v21 = *(_BYTE *)(spriteram_2 + v17 - 3);
v22 = v19 & 0xF;
v23 = 240 - (unsigned int)*(unsigned __int8 *)(spriteram_2 + v17 - 1);
v17 -= 4LL;
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
v20,
v22,
v21 & 0x40,
v21 & 0x80,
(unsigned int)(v18 - 256),
v23,
Machine + 776LL,
2LL,
0LL);
v16 -= 4;
}
while ( v16 >= 0 );
}
return result;
}

original_code:
void seicross_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int offs,x;
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int sx,sy;
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   drawgfx(tmpbitmap,Machine->gfx[0],
     videoram[offs] + ((colorram[offs] & 0x10) << 4),
     colorram[offs] & 0x0f,
     colorram[offs] & 0x40,colorram[offs] & 0x80,
     8*sx,8*sy,
     0,TRANSPARENCY_NONE,0);
  }
 }
 {
  int scroll[32];
  for (offs = 0;offs < 32;offs++)
   scroll[offs] = -seicross_row_scroll[offs];
  copyscrollbitmap(bitmap,tmpbitmap,0,0,32,scroll,&Machine->visible_area,TRANSPARENCY_NONE,0);
 }
 for (offs = spriteram_size - 4;offs >= 0;offs -= 4)
 {
  x=spriteram[offs + 3];
  drawgfx(bitmap,Machine->gfx[1],
    (spriteram[offs] & 0x3f) + ((spriteram[offs + 1] & 0x10) << 2) + 128,
    spriteram[offs + 1] & 0x0f,
    spriteram[offs] & 0x40,spriteram[offs] & 0x80,
    x,240-spriteram[offs + 2],
    &Machine->visible_area,TRANSPARENCY_PEN,0);
  if(x>0xf0)
   drawgfx(bitmap,Machine->gfx[1],
     (spriteram[offs] & 0x3f) + ((spriteram[offs + 1] & 0x10) << 2) + 128,
     spriteram[offs + 1] & 0x0f,
     spriteram[offs] & 0x40,spriteram[offs] & 0x80,
     x-256,240-spriteram[offs + 2],
     &Machine->visible_area,TRANSPARENCY_PEN,0);
 }
 for (offs = spriteram_2_size - 4;offs >= 0;offs -= 4)
 {
  x=spriteram_2[offs + 3];
  drawgfx(bitmap,Machine->gfx[1],
    (spriteram_2[offs] & 0x3f) + ((spriteram_2[offs + 1] & 0x10) << 2),
    spriteram_2[offs + 1] & 0x0f,
    spriteram_2[offs] & 0x40,spriteram_2[offs] & 0x80,
    x,240-spriteram_2[offs + 2],
    &Machine->visible_area,TRANSPARENCY_PEN,0);
  if(x>0xf0)
   drawgfx(bitmap,Machine->gfx[1],
     (spriteram_2[offs] & 0x3f) + ((spriteram_2[offs + 1] & 0x10) << 2),
     spriteram_2[offs + 1] & 0x0f,
     spriteram_2[offs] & 0x40,spriteram_2[offs] & 0x80,
     x-256,240-spriteram_2[offs + 2],
     &Machine->visible_area,TRANSPARENCY_PEN,0);
 }
}

canonical_original_code:
void seicross_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int offs; int x;
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int sx; int sy;
   dirtybuffer[offs] = 0;
   sx = offs % 32;
   sy = offs / 32;
   drawgfx(tmpbitmap,Machine->gfx[0],
     videoram[offs] + ((colorram[offs] & 0x10) << 4),
     colorram[offs] & 0x0f,
     colorram[offs] & 0x40,colorram[offs] & 0x80,
     8*sx,8*sy,
     0,TRANSPARENCY_NONE,0);
  }
 }
 {
  int scroll[32];
  for (offs = 0;offs < 32;offs++)
   scroll[offs] = -seicross_row_scroll[offs];
  copyscrollbitmap(bitmap,tmpbitmap,0,0,32,scroll,&Machine->visible_area,TRANSPARENCY_NONE,0);
 }
 for (offs = spriteram_size - 4;offs >= 0;offs -= 4)
 {
  x=spriteram[offs + 3];
  drawgfx(bitmap,Machine->gfx[1],
    (spriteram[offs] & 0x3f) + ((spriteram[offs + 1] & 0x10) << 2) + 128,
    spriteram[offs + 1] & 0x0f,
    spriteram[offs] & 0x40,spriteram[offs] & 0x80,
    x,240-spriteram[offs + 2],
    &Machine->visible_area,TRANSPARENCY_PEN,0);
  if(x>0xf0)
   drawgfx(bitmap,Machine->gfx[1],
     (spriteram[offs] & 0x3f) + ((spriteram[offs + 1] & 0x10) << 2) + 128,
     spriteram[offs + 1] & 0x0f,
     spriteram[offs] & 0x40,spriteram[offs] & 0x80,
     x-256,240-spriteram[offs + 2],
     &Machine->visible_area,TRANSPARENCY_PEN,0);
 }
 for (offs = spriteram_2_size - 4;offs >= 0;offs -= 4)
 {
  x=spriteram_2[offs + 3];
  drawgfx(bitmap,Machine->gfx[1],
    (spriteram_2[offs] & 0x3f) + ((spriteram_2[offs + 1] & 0x10) << 2),
    spriteram_2[offs + 1] & 0x0f,
    spriteram_2[offs] & 0x40,spriteram_2[offs] & 0x80,
    x,240-spriteram_2[offs + 2],
    &Machine->visible_area,TRANSPARENCY_PEN,0);
  if(x>0xf0)
   drawgfx(bitmap,Machine->gfx[1],
     (spriteram_2[offs] & 0x3f) + ((spriteram_2[offs + 1] & 0x10) << 2),
     spriteram_2[offs + 1] & 0x0f,
     spriteram_2[offs] & 0x40,spriteram_2[offs] & 0x80,
     x-256,240-spriteram_2[offs + 2],
     &Machine->visible_area,TRANSPARENCY_PEN,0);
 }
}

variable_types: x int

variable_types:
scroll
int [32]


decompiled_code:
__int64 init_friskyt()
{
__int64 v0; // rbx
__int64 v1; // rcx
__int64 result; // rax

v0 = memory_region(129LL);
v1 = memory_region(130LL);
for ( result = 0LL; result != 0x8000; ++result )
*(_BYTE *)(v1 + result + 0x8000) = *(_BYTE *)(v0 + result);
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rbx
__int64 v1; // rcx
__int64 result; // rax

v0 = memory_region(129LL);
v1 = memory_region(130LL);
for ( result = 0LL; result != 0x8000; ++result )
*(_BYTE *)(v1 + result + 0x8000) = *(_BYTE *)(v0 + result);
return result;
}

original_code:
static void init_friskyt(void)
{
 int A;
 unsigned char *src,*dest;
 src = memory_region(REGION_CPU1);
 dest = memory_region(REGION_CPU2);
 for (A = 0;A < 0x8000;A++)
   dest[A + 0x8000] = src[A];
}

canonical_original_code:
static void init_friskyt()
{
 int A;
 unsigned char *src; unsigned char *dest;
 src = memory_region(REGION_CPU1);
 dest = memory_region(REGION_CPU2);
 for (A = 0;A < 0x8000;A++)
   dest[A + 0x8000] = src[A];
}

variable_types: A int

variable_types:
src
unsigned char *

variable_types:
dest
unsigned char *


decompiled_code:
__int64 __fastcall friskyt_portB_w(__int64 a1, int a2)
{
__int64 result; // rax

result = interrupt_enable_w(0LL, a2 & 1);
if ( (portb & 4) == 0 && (a2 & 4) != 0 )
{
cpu_set_reset_line(1LL, 3LL);
result = cpu_set_halt_line(1LL, 0LL);
portb = a2;
}
else
{
portb = a2;
}
return result;
}

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

result = interrupt_enable_w(0LL, a2 & 1);
if ( (portb & 4) == 0 && (a2 & 4) != 0 )
{
cpu_set_reset_line(1LL, 3LL);
result = cpu_set_halt_line(1LL, 0LL);
portb = a2;
}
else
{
portb = a2;
}
return result;
}

original_code:
static void friskyt_portB_w(offs_t offset,data_t data)
{
 interrupt_enable_w(0,data & 1);
 if (((portb & 4) == 0) && (data & 4))
 {
  cpu_set_reset_line(1, 3);
  cpu_set_halt_line(1, 0);
 }
 portb = data;
}

canonical_original_code:
static void friskyt_portB_w(unsigned int offset, unsigned int data)
{
 interrupt_enable_w(0,data & 1);
 if (((portb & 4) == 0) && (data & 4))
 {
  cpu_set_reset_line(1, 3);
  cpu_set_halt_line(1, 0);
 }
 portb = data;
}

variable_types:
offset
unsigned int


decompiled_code:
__int64 friskyt_init_machine()
{
return cpu_set_halt_line(1LL, 1LL);
}

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

original_code:
static void friskyt_init_machine(void)
{
 cpu_set_halt_line(1, 1);
}

canonical_original_code:
static void friskyt_init_machine()
{
 cpu_set_halt_line(1, 1);
}


decompiled_code:
__int64 friskyt_portB_r()
{
int v0; // ebx

v0 = portb & 0x9F;
return v0 | (unsigned int)(readinputport(6LL) & 0x60);
}

canonical_decompiled_code:
__int64 func7()
{
int v0; // ebx

v0 = portb & 0x9F;
return v0 | (unsigned int)(readinputport(6LL) & 0x60);
}

original_code:
static data_t friskyt_portB_r(offs_t offset)
{
 return (portb & 0x9f) | (readinputport(6) & 0x60);
}

canonical_original_code:
static unsigned int friskyt_portB_r(unsigned int offset)
{
 return (portb & 0x9f) | (readinputport(6) & 0x60);
}


decompiled_code:
__int64 __fastcall sharedram_r(unsigned int a1)
{
return *(unsigned __int8 *)(sharedram + a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
return *(unsigned __int8 *)(sharedram + a1);
}

original_code:
static data_t sharedram_r(offs_t offset)
{
 return sharedram[offset];
}

canonical_original_code:
static unsigned int sharedram_r(unsigned int offset)
{
 return sharedram[offset];
}


decompiled_code:
void pit8254_init()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void pit8254_init (pit8254_interface *intf)
{
}

canonical_original_code:
void pit8254_init(struct pit8254_interface *intf)
{
}

variable_types: struct pit8254_interface { int num; int baseclock1[2]; int baseclock2[2]; int baseclock3[2]; void (*out[2])(int which); } *


canonical_decompiled_code:
void func3()
{
func1();
}

original_code:
void pit8254_0_w(offs_t offset,data_t data)
{
 pit8254_w(0, offset, data);
}

canonical_original_code:
void pit8254_0_w(unsigned int offset, unsigned int data)
{
 pit8254_w(0, offset, data);
}


canonical_decompiled_code:
void func4()
{
func1();
}

original_code:
void pit8254_0_counter1_w(offs_t offset,data_t data)
{
 pit8254_w(0, 0, data);
}

canonical_original_code:
void pit8254_0_counter1_w(unsigned int offset, unsigned int data)
{
 pit8254_w(0, 0, data);
}


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

original_code:
void pit8254_0_counter2_w(offs_t offset,data_t data)
{
 pit8254_w(0, 1, data);
}

canonical_original_code:
void pit8254_0_counter2_w(unsigned int offset, unsigned int data)
{
 pit8254_w(0, 1, data);
}


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

original_code:
void pit8254_0_counter3_w(offs_t offset,data_t data)
{
 pit8254_w(0, 2, data);
}

canonical_original_code:
void pit8254_0_counter3_w(unsigned int offset, unsigned int data)
{
 pit8254_w(0, 2, data);
}


canonical_decompiled_code:
void func7()
{
func1();
}

original_code:
void pit8254_0_control_w(offs_t offset,data_t data)
{
 pit8254_w(0, 3, data);
}

canonical_original_code:
void pit8254_0_control_w(unsigned int offset, unsigned int data)
{
 pit8254_w(0, 3, data);
}


decompiled_code:
// attributes: thunk
void pit8254_1_counter1_w()
{
pit8254_1_w_localalias();
}

canonical_decompiled_code:
void func9()
{
func8();
}

original_code:
void pit8254_1_counter1_w(offs_t offset,data_t data)
{
 pit8254_w(1, 0, data);
}

canonical_original_code:
void pit8254_1_counter1_w(unsigned int offset, unsigned int data)
{
 pit8254_w(1, 0, data);
}


canonical_decompiled_code:
void func10()
{
func1();
}

original_code:
void pit8254_1_counter2_w(offs_t offset,data_t data)
{
 pit8254_w(1, 1, data);
}

canonical_original_code:
void pit8254_1_counter2_w(unsigned int offset, unsigned int data)
{
 pit8254_w(1, 1, data);
}


canonical_decompiled_code:
void func11()
{
func1();
}

original_code:
void pit8254_1_counter3_w(offs_t offset,data_t data)
{
 pit8254_w(1, 2, data);
}

canonical_original_code:
void pit8254_1_counter3_w(unsigned int offset, unsigned int data)
{
 pit8254_w(1, 2, data);
}


canonical_decompiled_code:
void func12()
{
func1();
}

original_code:
void pit8254_1_control_w(offs_t offset,data_t data)
{
 pit8254_w(1, 3, data);
}

canonical_original_code:
void pit8254_1_control_w(unsigned int offset, unsigned int data)
{
 pit8254_w(1, 3, data);
}


decompiled_code:
__int64 __fastcall pit8254_0_r(unsigned int a1)
{
return pit8254_r(0LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned int a1)
{
return func2(0LL, a1);
}

original_code:
data_t pit8254_0_r(offs_t offset)
{
 return pit8254_r(0, offset);
}

canonical_original_code:
unsigned int pit8254_0_r(unsigned int offset)
{
 return pit8254_r(0, offset);
}


decompiled_code:
__int64 pit8254_0_counter1_r()
{
return pit8254_r(0LL, 0LL);
}

canonical_decompiled_code:
__int64 func14()
{
return func2(0LL, 0LL);
}

original_code:
data_t pit8254_0_counter1_r(offs_t offset)
{
 return pit8254_r(0, 0);
}

canonical_original_code:
unsigned int pit8254_0_counter1_r(unsigned int offset)
{
 return pit8254_r(0, 0);
}


decompiled_code:
__int64 pit8254_0_counter2_r()
{
return pit8254_r(0LL, 1LL);
}

canonical_decompiled_code:
__int64 func15()
{
return func2(0LL, 1LL);
}

original_code:
data_t pit8254_0_counter2_r(offs_t offset)
{
 return pit8254_r(0, 1);
}

canonical_original_code:
unsigned int pit8254_0_counter2_r(unsigned int offset)
{
 return pit8254_r(0, 1);
}


decompiled_code:
__int64 pit8254_0_counter3_r()
{
return pit8254_r(0LL, 2LL);
}

canonical_decompiled_code:
__int64 func16()
{
return func2(0LL, 2LL);
}

original_code:
data_t pit8254_0_counter3_r(offs_t offset)
{
 return pit8254_r(0, 2);
}

canonical_original_code:
unsigned int pit8254_0_counter3_r(unsigned int offset)
{
 return pit8254_r(0, 2);
}


decompiled_code:
__int64 pit8254_0_control_r()
{
return pit8254_r(0LL, 3LL);
}

canonical_decompiled_code:
__int64 func17()
{
return func2(0LL, 3LL);
}

original_code:
data_t pit8254_0_control_r(offs_t offset)
{
 return pit8254_r(0, 3);
}

canonical_original_code:
unsigned int pit8254_0_control_r(unsigned int offset)
{
 return pit8254_r(0, 3);
}


decompiled_code:
__int64 __fastcall pit8254_1_r(unsigned int a1)
{
return pit8254_r(1LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func18(unsigned int a1)
{
return func2(1LL, a1);
}

original_code:
data_t pit8254_1_r(offs_t offset)
{
 return pit8254_r(1, offset);
}

canonical_original_code:
unsigned int pit8254_1_r(unsigned int offset)
{
 return pit8254_r(1, offset);
}


decompiled_code:
__int64 pit8254_1_counter1_r()
{
return pit8254_r(1LL, 0LL);
}

canonical_decompiled_code:
__int64 func19()
{
return func2(1LL, 0LL);
}

original_code:
data_t pit8254_1_counter1_r(offs_t offset)
{
 return pit8254_r(1, 0);
}

canonical_original_code:
unsigned int pit8254_1_counter1_r(unsigned int offset)
{
 return pit8254_r(1, 0);
}


decompiled_code:
__int64 pit8254_1_counter2_r()
{
return pit8254_r(1LL, 1LL);
}

canonical_decompiled_code:
__int64 func20()
{
return func2(1LL, 1LL);
}

original_code:
data_t pit8254_1_counter2_r(offs_t offset)
{
 return pit8254_r(1, 1);
}

canonical_original_code:
unsigned int pit8254_1_counter2_r(unsigned int offset)
{
 return pit8254_r(1, 1);
}


decompiled_code:
__int64 pit8254_1_counter3_r()
{
return pit8254_r(1LL, 2LL);
}

canonical_decompiled_code:
__int64 func21()
{
return func2(1LL, 2LL);
}

original_code:
data_t pit8254_1_counter3_r(offs_t offset)
{
 return pit8254_r(1, 2);
}

canonical_original_code:
unsigned int pit8254_1_counter3_r(unsigned int offset)
{
 return pit8254_r(1, 2);
}


decompiled_code:
__int64 pit8254_1_control_r()
{
return pit8254_r(1LL, 3LL);
}

canonical_decompiled_code:
__int64 func22()
{
return func2(1LL, 3LL);
}

original_code:
data_t pit8254_1_control_r(offs_t offset)
{
 return pit8254_r(1, 3);
}

canonical_original_code:
unsigned int pit8254_1_control_r(unsigned int offset)
{
 return pit8254_r(1, 3);
}


canonical_decompiled_code:
void func1()
{
;
}

original_code:
void pit8254_w (int which, int offset, int data)
{
}

canonical_original_code:
void pit8254_w(int which, int offset, int data)
{
}

variable_types: which int

variable_types: offset int

variable_types: data int


decompiled_code:
__int64 pit8254_r()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 0LL;
}

original_code:
int pit8254_r (int which, int offset)
{
 return 0;
}

canonical_original_code:
int pit8254_r(int which, int offset)
{
 return 0;
}


original_code:
void wiping_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0,bit1,bit2;
  bit0 = (*color_prom >> 0) & 0x01;
  bit1 = (*color_prom >> 1) & 0x01;
  bit2 = (*color_prom >> 2) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = (*color_prom >> 3) & 0x01;
  bit1 = (*color_prom >> 4) & 0x01;
  bit2 = (*color_prom >> 5) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = 0;
  bit1 = (*color_prom >> 6) & 0x01;
  bit2 = (*color_prom >> 7) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  color_prom++;
 }
 for (i = 0;i < (Machine->gfx[0]->total_colors * Machine->gfx[0]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[0].color_codes_start + (i ^ 3)]) = *(color_prom++) & 0x0f;
 for (i = 0;i < (Machine->gfx[1]->total_colors * Machine->gfx[1]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[1].color_codes_start + (i ^ 3)]) = (*(color_prom++) & 0x0f) + 0x10;
}

canonical_original_code:
void wiping_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable, unsigned char *color_prom)
{
 int i;
 for (i = 0;i < Machine->drv->total_colors;i++)
 {
  int bit0; int bit1; int bit2;
  bit0 = (*color_prom >> 0) & 0x01;
  bit1 = (*color_prom >> 1) & 0x01;
  bit2 = (*color_prom >> 2) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = (*color_prom >> 3) & 0x01;
  bit1 = (*color_prom >> 4) & 0x01;
  bit2 = (*color_prom >> 5) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  bit0 = 0;
  bit1 = (*color_prom >> 6) & 0x01;
  bit2 = (*color_prom >> 7) & 0x01;
  *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  color_prom++;
 }
 for (i = 0;i < (Machine->gfx[0]->total_colors * Machine->gfx[0]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[0].color_codes_start + (i ^ 3)]) = *(color_prom++) & 0x0f;
 for (i = 0;i < (Machine->gfx[1]->total_colors * Machine->gfx[1]->color_granularity);i++)
  (colortable[Machine->drv->gfxdecodeinfo[1].color_codes_start + (i ^ 3)]) = (*(color_prom++) & 0x0f) + 0x10;
}

variable_types:
palette
unsigned char *

variable_types:
colortable
unsigned short *

variable_types: i int


decompiled_code:
__int64 __fastcall shared2_r(unsigned int a1)
{
return *(unsigned __int8 *)(sharedram2 + a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return *(unsigned __int8 *)(sharedram2 + a1);
}

original_code:
static data_t shared2_r(offs_t offset)
{
 return sharedram2[offset];
}

canonical_original_code:
static unsigned int shared2_r(unsigned int offset)
{
 return sharedram2[offset];
}


decompiled_code:
void *__fastcall wiping_flipscreen_w(__int64 a1, char a2)
{
int v2; // esi
void *result; // rax

v2 = a2 & 1;
if ( v2 != flipscreen )
{
flipscreen = v2;
result = memset(dirtybuffer, 1, videoram_size);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func5(__int64 a1, char a2)
{
int v2; // esi
void *result; // rax

v2 = a2 & 1;
if ( v2 != flipscreen )
{
flipscreen = v2;
result = memset(dirtybuffer, 1, videoram_size);
}
return result;
}

original_code:
void wiping_flipscreen_w(offs_t offset,data_t data)
{
 if (flipscreen != (data & 1))
 {
  flipscreen = (data & 1);
  memset(dirtybuffer,1,videoram_size);
 }
}

canonical_original_code:
void wiping_flipscreen_w(unsigned int offset, unsigned int data)
{
 if (flipscreen != (data & 1))
 {
  flipscreen = (data & 1);
  memset(dirtybuffer,1,videoram_size);
 }
}

variable_types:
data
unsigned int


original_code:
static void wiping_update_mono(int ch, INT16 *buffer, int length)
{
 sound_channel *voice;
 short *mix;
 int i;
 if (sound_enable == 0)
 {
  memset(buffer, 0, length * 2);
  return;
 }
 memset(mixer_buffer, 0, length * sizeof(short));
 for (voice = channel_list; voice < last_channel; voice++)
 {
  int f = 16*voice->frequency;
  int v = voice->volume[0];
  if (v && f)
  {
   const unsigned char *w = voice->wave;
   int c = voice->counter;
   mix = mixer_buffer;
   for (i = 0; i < length; i++)
   {
    int offs;
    c += f;
    if (voice->oneshot)
    {
     if (voice->oneshotplaying)
     {
      offs = (c >> 15);
      if (w[offs>>1] == 0xff)
      {
       voice->oneshotplaying = 0;
      }
      if (voice->oneshotplaying)
      {
       if (offs & 1)
        *mix++ += ((w[offs>>1] & 0x0f) - 8) * v;
       else
        *mix++ += (((w[offs>>1]>>4) & 0x0f) - 8) * v;
      }
     }
    }
    else
    {
     offs = (c >> 15) & 0x1f;
     if (offs & 1)
      *mix++ += ((w[offs>>1] & 0x0f) - 8) * v;
     else
      *mix++ += (((w[offs>>1]>>4) & 0x0f) - 8) * v;
    }
   }
   voice->counter = c;
  }
 }
 mix = mixer_buffer;
 for (i = 0; i < length; i++)
  *buffer++ = mixer_lookup[*mix++];
}

canonical_original_code:
static void wiping_update_mono(int ch, short *buffer, int length)
{
 struct sound_channel *voice;
 short *mix;
 int i;
 if (sound_enable == 0)
 {
  memset(buffer, 0, length * 2);
  return;
 }
 memset(mixer_buffer, 0, length * sizeof(short));
 for (voice = channel_list; voice < last_channel; voice++)
 {
  int f = 16*voice->frequency;
  int v = voice->volume[0];
  if (v && f)
  {
   unsigned char *w = voice->wave;
   int c = voice->counter;
   mix = mixer_buffer;
   for (i = 0; i < length; i++)
   {
    int offs;
    c += f;
    if (voice->oneshot)
    {
     if (voice->oneshotplaying)
     {
      offs = (c >> 15);
      if (w[offs>>1] == 0xff)
      {
       voice->oneshotplaying = 0;
      }
      if (voice->oneshotplaying)
      {
       if (offs & 1)
        *mix++ += ((w[offs>>1] & 0x0f) - 8) * v;
       else
        *mix++ += (((w[offs>>1]>>4) & 0x0f) - 8) * v;
      }
     }
    }
    else
    {
     offs = (c >> 15) & 0x1f;
     if (offs & 1)
      *mix++ += ((w[offs>>1] & 0x0f) - 8) * v;
     else
      *mix++ += (((w[offs>>1]>>4) & 0x0f) - 8) * v;
    }
   }
   voice->counter = c;
  }
 }
 mix = mixer_buffer;
 for (i = 0; i < length; i++)
  *buffer++ = mixer_lookup[*mix++];
}

variable_types: ch int

variable_types:
buffer
short *

variable_types: length int

variable_types: struct sound_channel { int frequency; int counter; int volume[2]; unsigned char *wave; int oneshot; int oneshotplaying; } *

variable_types:
mix
short *

variable_types: f int

variable_types: v int

variable_types:
w
unsigned char *

variable_types: c int

variable_types: offs int


decompiled_code:
void *__fastcall wiping_vh_screenrefresh(__int64 a1)
{
int v2; // er12
__int64 v3; // r14
int v4; // esi
int v5; // edx
int v6; // edx
int v7; // ecx
__int64 v8; // r12
__int64 v9; // r11
char v10; // r10
int v11; // esi
__int64 v12; // rdi
int v13; // ecx
unsigned __int8 v14; // dl
__int64 v15; // r9
__int64 v16; // r8
void *result; // rax
int v18; // er12
__int64 v19; // r13
char v20; // cl
int v21; // eax
int v22; // edx
int v23; // edi
int v24; // eax
unsigned int v25; // er11

v2 = videoram_size - 1;
if ( videoram_size - 1 > 0 )
{
v3 = v2;
do
{
if ( *(_BYTE *)(v3 + dirtybuffer) )
{
*(_BYTE *)(v3 + dirtybuffer) = 0;
v6 = v2 & 0x1F;
v7 = v2 >> 5;
if ( v2 > 63 )
{
if ( v2 <= 959 )
{
v4 = v6 + 2;
v5 = v7 - 2;
}
else
{
v4 = v7 - 30;
v5 = v6 - 2;
}
}
else
{
v4 = v7 + 34;
v5 = v6 - 2;
}
if ( flipscreen )
{
v4 = 35 - v4;
v5 = 27 - v5;
}
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v3),
*(_BYTE *)(colorram + v3) & 0x3F,
(unsigned int)flipscreen,
(unsigned int)flipscreen,
(unsigned int)(8 * v4),
(unsigned int)(8 * v5),
Machine + 776LL,
0LL,
0LL);
}
--v3;
--v2;
}
while ( v2 );
}
v8 = 257LL;
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
do
{
v11 = *(_BYTE *)(spriteram + v8 - 129) & 1;
v12 = ((*(unsigned __int8 *)(spriteram + v8 - 128) << 8) & 0x100)
+ (unsigned int)*(unsigned __int8 *)(spriteram + v8)
- 40;
v13 = *(unsigned __int8 *)(spriteram + v8 - 1);
v14 = *(_BYTE *)(spriteram + v8 - 257);
v15 = v14 & 0x40;
v16 = v14 & 0x80;
if ( flipscreen )
{
v9 = (unsigned int)(v13 - 16);
v16 = (_DWORD)v16 == 0;
v15 = (_DWORD)v15 == 0;
}
else
{
v9 = (unsigned int)(224 - v13);
}
v10 = *(_BYTE *)(spriteram + v8 - 256);
v8 += 2LL;
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(v11 << 6) + (v14 & 0x3Fu),
v10 & 0x3F,
v16,
v15,
v12,
v9,
Machine + 776LL,
6LL,
31LL);
}
while ( v8 != 385 );
result = &videoram_size;
v18 = videoram_size - 1;
if ( videoram_size - 1 > 0 )
{
v19 = v18;
do
{
while ( 1 )
{
result = (void *)colorram;
v20 = *(_BYTE *)(colorram + v19);
if ( v20 < 0 )
break;
--v19;
if ( !--v18 )
return result;
}
v21 = v18 & 0x1F;
v22 = v18 >> 5;
if ( v18 <= 63 )
{
v23 = v22 + 34;
v24 = v21 - 2;
}
else if ( v18 <= 959 )
{
v23 = v21 + 2;
v24 = v22 - 2;
}
else
{
v23 = v22 - 30;
v24 = v21 - 2;
}
if ( flipscreen )
{
v23 = 35 - v23;
v24 = 27 - v24;
}
v25 = *(unsigned __int8 *)(videoram + v19--);
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
v25,
v20 & 0x3F,
(unsigned int)flipscreen,
(unsigned int)flipscreen,
(unsigned int)(8 * v23),
(unsigned int)(8 * v24),
Machine + 776LL,
0LL,
0LL);
--v18;
}
while ( v18 );
}
return result;
}

canonical_decompiled_code:
void *__fastcall func7(__int64 a1)
{
int v2; // er12
__int64 v3; // r14
int v4; // esi
int v5; // edx
int v6; // edx
int v7; // ecx
__int64 v8; // r12
__int64 v9; // r11
char v10; // r10
int v11; // esi
__int64 v12; // rdi
int v13; // ecx
unsigned __int8 v14; // dl
__int64 v15; // r9
__int64 v16; // r8
void *result; // rax
int v18; // er12
__int64 v19; // r13
char v20; // cl
int v21; // eax
int v22; // edx
int v23; // edi
int v24; // eax
unsigned int v25; // er11

v2 = videoram_size - 1;
if ( videoram_size - 1 > 0 )
{
v3 = v2;
do
{
if ( *(_BYTE *)(v3 + dirtybuffer) )
{
*(_BYTE *)(v3 + dirtybuffer) = 0;
v6 = v2 & 0x1F;
v7 = v2 >> 5;
if ( v2 > 63 )
{
if ( v2 <= 959 )
{
v4 = v6 + 2;
v5 = v7 - 2;
}
else
{
v4 = v7 - 30;
v5 = v6 - 2;
}
}
else
{
v4 = v7 + 34;
v5 = v6 - 2;
}
if ( flipscreen )
{
v4 = 35 - v4;
v5 = 27 - v5;
}
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v3),
*(_BYTE *)(colorram + v3) & 0x3F,
(unsigned int)flipscreen,
(unsigned int)flipscreen,
(unsigned int)(8 * v4),
(unsigned int)(8 * v5),
Machine + 776LL,
0LL,
0LL);
}
--v3;
--v2;
}
while ( v2 );
}
v8 = 257LL;
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
do
{
v11 = *(_BYTE *)(spriteram + v8 - 129) & 1;
v12 = ((*(unsigned __int8 *)(spriteram + v8 - 128) << 8) & 0x100)
+ (unsigned int)*(unsigned __int8 *)(spriteram + v8)
- 40;
v13 = *(unsigned __int8 *)(spriteram + v8 - 1);
v14 = *(_BYTE *)(spriteram + v8 - 257);
v15 = v14 & 0x40;
v16 = v14 & 0x80;
if ( flipscreen )
{
v9 = (unsigned int)(v13 - 16);
v16 = (_DWORD)v16 == 0;
v15 = (_DWORD)v15 == 0;
}
else
{
v9 = (unsigned int)(224 - v13);
}
v10 = *(_BYTE *)(spriteram + v8 - 256);
v8 += 2LL;
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(v11 << 6) + (v14 & 0x3Fu),
v10 & 0x3F,
v16,
v15,
v12,
v9,
Machine + 776LL,
6LL,
31LL);
}
while ( v8 != 385 );
result = &videoram_size;
v18 = videoram_size - 1;
if ( videoram_size - 1 > 0 )
{
v19 = v18;
do
{
while ( 1 )
{
result = (void *)colorram;
v20 = *(_BYTE *)(colorram + v19);
if ( v20 < 0 )
break;
--v19;
if ( !--v18 )
return result;
}
v21 = v18 & 0x1F;
v22 = v18 >> 5;
if ( v18 <= 63 )
{
v23 = v22 + 34;
v24 = v21 - 2;
}
else if ( v18 <= 959 )
{
v23 = v21 + 2;
v24 = v22 - 2;
}
else
{
v23 = v22 - 30;
v24 = v21 - 2;
}
if ( flipscreen )
{
v23 = 35 - v23;
v24 = 27 - v24;
}
v25 = *(unsigned __int8 *)(videoram + v19--);
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
v25,
v20 & 0x3F,
(unsigned int)flipscreen,
(unsigned int)flipscreen,
(unsigned int)(8 * v23),
(unsigned int)(8 * v24),
Machine + 776LL,
0LL,
0LL);
--v18;
}
while ( v18 );
}
return result;
}

original_code:
void wiping_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int offs;
 for (offs = videoram_size - 1; offs > 0; offs--)
 {
  if (dirtybuffer[offs])
  {
   int mx,my,sx,sy;
   dirtybuffer[offs] = 0;
         mx = offs % 32;
   my = offs / 32;
   if (my < 2)
   {
    sx = my + 34;
    sy = mx - 2;
   }
   else if (my >= 30)
   {
    sx = my - 30;
    sy = mx - 2;
   }
   else
   {
    sx = mx + 2;
    sy = my - 2;
   }
   if (flipscreen)
   {
    sx = 35 - sx;
    sy = 27 - sy;
   }
   drawgfx(tmpbitmap,Machine->gfx[0],
     videoram[offs],
     colorram[offs] & 0x3f,
     flipscreen,flipscreen,
     sx*8,sy*8,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
         }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 for (offs = 0x0; offs < 128; offs += 2) {
  int sx,sy,flipx,flipy,otherbank;
  sx = spriteram[offs+0x100+1] + ((spriteram[offs+0x81] & 0x01) << 8) - 40;
  sy = 224 - spriteram[offs+0x100];
  otherbank = spriteram[offs+0x80] & 0x01;
  flipy = spriteram[offs] & 0x40;
  flipx = spriteram[offs] & 0x80;
  if (flipscreen)
  {
   sy = 208 - sy;
   flipx = !flipx;
   flipy = !flipy;
  }
  drawgfx(bitmap,Machine->gfx[1],
   (spriteram[offs] & 0x3f) + 64 * otherbank,
   spriteram[offs+1] & 0x3f,
   flipx,flipy,
   sx,sy,
   &Machine->visible_area,TRANSPARENCY_COLOR,0x1f);
 }
 for (offs = videoram_size - 1; offs > 0; offs--)
 {
  if (colorram[offs] & 0x80)
  {
   int mx,my,sx,sy;
         mx = offs % 32;
   my = offs / 32;
   if (my < 2)
   {
    sx = my + 34;
    sy = mx - 2;
   }
   else if (my >= 30)
   {
    sx = my - 30;
    sy = mx - 2;
   }
   else
   {
    sx = mx + 2;
    sy = my - 2;
   }
   if (flipscreen)
   {
    sx = 35 - sx;
    sy = 27 - sy;
   }
   drawgfx(bitmap,Machine->gfx[0],
     videoram[offs],
     colorram[offs] & 0x3f,
     flipscreen,flipscreen,
     sx*8,sy*8,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
         }
 }
}

canonical_original_code:
void wiping_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int offs;
 for (offs = videoram_size - 1; offs > 0; offs--)
 {
  if (dirtybuffer[offs])
  {
   int mx; int my; int sx; int sy;
   dirtybuffer[offs] = 0;
         mx = offs % 32;
   my = offs / 32;
   if (my < 2)
   {
    sx = my + 34;
    sy = mx - 2;
   }
   else if (my >= 30)
   {
    sx = my - 30;
    sy = mx - 2;
   }
   else
   {
    sx = mx + 2;
    sy = my - 2;
   }
   if (flipscreen)
   {
    sx = 35 - sx;
    sy = 27 - sy;
   }
   drawgfx(tmpbitmap,Machine->gfx[0],
     videoram[offs],
     colorram[offs] & 0x3f,
     flipscreen,flipscreen,
     sx*8,sy*8,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
         }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 for (offs = 0x0; offs < 128; offs += 2) {
  int sx; int sy; int flipx; int flipy; int otherbank;
  sx = spriteram[offs+0x100+1] + ((spriteram[offs+0x81] & 0x01) << 8) - 40;
  sy = 224 - spriteram[offs+0x100];
  otherbank = spriteram[offs+0x80] & 0x01;
  flipy = spriteram[offs] & 0x40;
  flipx = spriteram[offs] & 0x80;
  if (flipscreen)
  {
   sy = 208 - sy;
   flipx = !flipx;
   flipy = !flipy;
  }
  drawgfx(bitmap,Machine->gfx[1],
   (spriteram[offs] & 0x3f) + 64 * otherbank,
   spriteram[offs+1] & 0x3f,
   flipx,flipy,
   sx,sy,
   &Machine->visible_area,TRANSPARENCY_COLOR,0x1f);
 }
 for (offs = videoram_size - 1; offs > 0; offs--)
 {
  if (colorram[offs] & 0x80)
  {
   int mx; int my; int sx; int sy;
         mx = offs % 32;
   my = offs / 32;
   if (my < 2)
   {
    sx = my + 34;
    sy = mx - 2;
   }
   else if (my >= 30)
   {
    sx = my - 30;
    sy = mx - 2;
   }
   else
   {
    sx = mx + 2;
    sy = my - 2;
   }
   if (flipscreen)
   {
    sx = 35 - sx;
    sy = 27 - sy;
   }
   drawgfx(bitmap,Machine->gfx[0],
     videoram[offs],
     colorram[offs] & 0x3f,
     flipscreen,flipscreen,
     sx*8,sy*8,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
         }
 }
}

variable_types: struct osd_bitmap { int width; int depth; void *_private; unsigned char **line; } *

variable_types: mx int

variable_types: my int

variable_types: sx int

variable_types: sy int

variable_types: flipx int

variable_types: flipy int

variable_types: otherbank int


decompiled_code:
void wiping_sh_stop()
{
free(mixer_table);
free(mixer_buffer);
}

canonical_decompiled_code:
void func8()
{
free(mixer_table);
free(mixer_buffer);
}

original_code:
void wiping_sh_stop(void)
{
 free(mixer_table);
 free(mixer_buffer);
}


decompiled_code:
unsigned __int64 __fastcall wiping_sound_w(unsigned int a1, char a2)
{
unsigned __int64 result; // rax
unsigned __int64 v3; // rdi
__int64 v4; // r10
__int64 v5; // r8
_BYTE *v6; // rsi
int v7; // er9
int v8; // ecx
int v9; // edx
int v10; // edx
unsigned __int8 v11; // dl
char v12; // dl
_DWORD *v13; // rbx

stream_update((unsigned int)stream, 0LL);
result = a1;
*(_BYTE *)(*(_QWORD *)&wiping_soundregs + a1) = a2;
if ( a1 > 0x3F )
{
if ( a1 > 0x1FFF )
{
v13 = (_DWORD *)((char *)&channel_list + 32 * ((a1 >> 3) & 7));
result = (unsigned int)v13[6];
if ( (_DWORD)result )
{
v13[1] = 0;
v13[7] = 1;
}
}
}
else
{
v3 = last_channel;
result = (unsigned __int64)&channel_list;
if ( last_channel > (unsigned __int64)&channel_list )
{
v4 = *(_QWORD *)&wiping_soundregs;
v5 = sound_rom;
v6 = *(_BYTE **)&wiping_soundregs;
v7 = 8197 - wiping_soundregs;
do
{
while ( 1 )
{
v9 = v6[2] & 0xF;
*(_DWORD *)result = v9;
v10 = (v6[1] & 0xF) + 16 * v9;
*(_DWORD *)result = v10;
*(_DWORD *)result = (*v6 & 0xF) + 16 * v10;
*(_DWORD *)(result + 8) = v6[7] & 0xF;
v11 = v6[5] & 0xF;
if ( !v11 )
break;
v8 = v7 + (_DWORD)v6;
result += 32LL;
v6 += 8;
LOBYTE(v8) = *(_BYTE *)(v4 + v8);
*(_DWORD *)(result - 8) = 1;
*(_QWORD *)(result - 16) = v5 + (((v8 & 0xF) + 16 * v11) << 7);
if ( result >= v3 )
return result;
}
v12 = v6[3];
result += 32LL;
*(_DWORD *)(result - 8) = 0;
v6 += 8;
*(_QWORD *)(result - 16) = v5 + (unsigned __int8)(16 * v12);
}
while ( result < v3 );
}
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func9(unsigned int a1, char a2)
{
unsigned __int64 result; // rax
unsigned __int64 v3; // rdi
__int64 v4; // r10
__int64 v5; // r8
_BYTE *v6; // rsi
int v7; // er9
int v8; // ecx
int v9; // edx
int v10; // edx
unsigned __int8 v11; // dl
char v12; // dl
_DWORD *v13; // rbx

stream_update((unsigned int)stream, 0LL);
result = a1;
*(_BYTE *)(*(_QWORD *)&wiping_soundregs + a1) = a2;
if ( a1 > 0x3F )
{
if ( a1 > 0x1FFF )
{
v13 = (_DWORD *)((char *)&channel_list + 32 * ((a1 >> 3) & 7));
result = (unsigned int)v13[6];
if ( (_DWORD)result )
{
v13[1] = 0;
v13[7] = 1;
}
}
}
else
{
v3 = last_channel;
result = (unsigned __int64)&channel_list;
if ( last_channel > (unsigned __int64)&channel_list )
{
v4 = *(_QWORD *)&wiping_soundregs;
v5 = sound_rom;
v6 = *(_BYTE **)&wiping_soundregs;
v7 = 8197 - wiping_soundregs;
do
{
while ( 1 )
{
v9 = v6[2] & 0xF;
*(_DWORD *)result = v9;
v10 = (v6[1] & 0xF) + 16 * v9;
*(_DWORD *)result = v10;
*(_DWORD *)result = (*v6 & 0xF) + 16 * v10;
*(_DWORD *)(result + 8) = v6[7] & 0xF;
v11 = v6[5] & 0xF;
if ( !v11 )
break;
v8 = v7 + (_DWORD)v6;
result += 32LL;
v6 += 8;
LOBYTE(v8) = *(_BYTE *)(v4 + v8);
*(_DWORD *)(result - 8) = 1;
*(_QWORD *)(result - 16) = v5 + (((v8 & 0xF) + 16 * v11) << 7);
if ( result >= v3 )
return result;
}
v12 = v6[3];
result += 32LL;
*(_DWORD *)(result - 8) = 0;
v6 += 8;
*(_QWORD *)(result - 16) = v5 + (unsigned __int8)(16 * v12);
}
while ( result < v3 );
}
}
return result;
}

original_code:
void wiping_sound_w(offs_t offset,data_t data)
{
 sound_channel *voice;
 int base;
 stream_update(stream, 0);
 wiping_soundregs[offset] = data;
 if (offset <= 0x3f)
 {
  for (base = 0, voice = channel_list; voice < last_channel; voice++, base += 8)
  {
   voice->frequency = wiping_soundregs[0x02 + base] & 0x0f;
   voice->frequency = voice->frequency * 16 + ((wiping_soundregs[0x01 + base]) & 0x0f);
   voice->frequency = voice->frequency * 16 + ((wiping_soundregs[0x00 + base]) & 0x0f);
   voice->volume[0] = wiping_soundregs[0x07 + base] & 0x0f;
   if (wiping_soundregs[0x5 + base] & 0x0f)
   {
    voice->wave = &sound_rom[128 * (16 * (wiping_soundregs[0x5 + base] & 0x0f)
      + (wiping_soundregs[0x2005 + base] & 0x0f))];
    voice->oneshot = 1;
   }
   else
   {
    voice->wave = &sound_rom[16 * (wiping_soundregs[0x3 + base] & 0x0f)];
    voice->oneshot = 0;
   }
  }
 }
 else if (offset >= 0x2000)
 {
  voice = &channel_list[(offset & 0x3f)/8];
  if (voice->oneshot)
  {
   voice->counter = 0;
   voice->oneshotplaying = 1;
  }
 }
}

canonical_original_code:
void wiping_sound_w(unsigned int offset, unsigned int data)
{
 struct sound_channel *voice;
 int base;
 stream_update(stream, 0);
 wiping_soundregs[offset] = data;
 if (offset <= 0x3f)
 {
  for (base = 0, voice = channel_list; voice < last_channel; voice++, base += 8)
  {
   voice->frequency = wiping_soundregs[0x02 + base] & 0x0f;
   voice->frequency = voice->frequency * 16 + ((wiping_soundregs[0x01 + base]) & 0x0f);
   voice->frequency = voice->frequency * 16 + ((wiping_soundregs[0x00 + base]) & 0x0f);
   voice->volume[0] = wiping_soundregs[0x07 + base] & 0x0f;
   if (wiping_soundregs[0x5 + base] & 0x0f)
   {
    voice->wave = &sound_rom[128 * (16 * (wiping_soundregs[0x5 + base] & 0x0f)
      + (wiping_soundregs[0x2005 + base] & 0x0f))];
    voice->oneshot = 1;
   }
   else
   {
    voice->wave = &sound_rom[16 * (wiping_soundregs[0x3 + base] & 0x0f)];
    voice->oneshot = 0;
   }
  }
 }
 else if (offset >= 0x2000)
 {
  voice = &channel_list[(offset & 0x3f)/8];
  if (voice->oneshot)
  {
   voice->counter = 0;
   voice->oneshotplaying = 1;
  }
 }
}

variable_types:
offset
unsigned int

variable_types:
data
unsigned int

variable_types: base int

user_defined_types: struct sound_channel { int frequency; int counter; int volume[2]; unsigned char *wave; int oneshot; int oneshotplaying; }


decompiled_code:
__int64 __fastcall subcpu_reset_w(__int64 a1, char a2)
{
__int64 result; // rax

if ( (a2 & 1) != 0 )
result = cpu_set_reset_line(1LL, 0LL);
else
result = cpu_set_reset_line(1LL, 1LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, char a2)
{
__int64 result; // rax

if ( (a2 & 1) != 0 )
result = cpu_set_reset_line(1LL, 0LL);
else
result = cpu_set_reset_line(1LL, 1LL);
return result;
}

original_code:
static void subcpu_reset_w(offs_t offset,data_t data)
{
 if (data & 1)
  cpu_set_reset_line(1,0);
 else
  cpu_set_reset_line(1,1);
}

canonical_original_code:
static void subcpu_reset_w(unsigned int offset, unsigned int data)
{
 if (data & 1)
  cpu_set_reset_line(1,0);
 else
  cpu_set_reset_line(1,1);
}


decompiled_code:
__int64 __fastcall ports_r(char a1)
{
unsigned int v1; // er13
unsigned int i; // er12
int v3; // eax
char v4; // cl

v1 = 0;
for ( i = 0; i != 8; ++i )
{
v3 = readinputport(i);
v4 = i;
v1 |= ((v3 >> a1) & 1) << v4;
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func11(char a1)
{
unsigned int v1; // er13
unsigned int i; // er12
int v3; // eax
char v4; // cl

v1 = 0;
for ( i = 0; i != 8; ++i )
{
v3 = readinputport(i);
v4 = i;
v1 |= ((v3 >> a1) & 1) << v4;
}
return v1;
}

original_code:
static data_t ports_r(offs_t offset)
{
 int i,res;
 res = 0;
 for (i = 0;i < 8;i++)
  res |= ((readinputport(i) >> offset) & 1) << i;
 return res;
}

canonical_original_code:
static unsigned int ports_r(unsigned int offset)
{
 int i; int res;
 res = 0;
 for (i = 0;i < 8;i++)
  res |= ((readinputport(i) >> offset) & 1) << i;
 return res;
}

variable_types: i int

variable_types: res int