decompiled_code:
void *__fastcall seicross_vh_screenrefresh(__int64 a1)
{
int v1; // ebx
__int64 v2; // r12
__int64 v3; // rcx
__int64 i; // rax
int v5; // er13
__int64 v6; // rbx
int v7; // er12
void *result; // rax
int v9; // er13
__int64 v10; // rbx
int v11; // er12
int v12[42]; // [rsp+0h] [rbp-A8h] BYREF

v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
if ( *(_BYTE *)(dirtybuffer + v2) )
{
*(_BYTE *)(dirtybuffer + v2) = 0;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v2) + ((16 * *(unsigned __int8 *)(colorram + v2)) & 0x100u),
*(_BYTE *)(colorram + v2) & 0xF,
*(_BYTE *)(colorram + v2) & 0x40,
*(_BYTE *)(colorram + v2) & 0x80,
(unsigned int)(8 * (v1 % 32)),
(unsigned int)(8 * (v1 / 32)),
0LL,
0LL,
0LL);
}
--v2;
--v1;
}
while ( v1 >= 0 );
}
v3 = seicross_row_scroll;
for ( i = 0LL; i != 32; ++i )
v12[i] = -*(unsigned __int8 *)(v3 + i);
copyscrollbitmap(a1, tmpbitmap, 0LL, 0LL, 32LL, v12, Machine + 776LL, 0LL, 0LL);
v5 = spriteram_size - 4;
if ( spriteram_size - 4 >= 0 )
{
v6 = v5 + 3LL;
do
{
v7 = *(unsigned __int8 *)(spriteram + v6);
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(*(_BYTE *)(spriteram + v6 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram + v6 - 2)) & 0x40u) + 128,
*(_BYTE *)(spriteram + v6 - 2) & 0xF,
*(_BYTE *)(spriteram + v6 - 3) & 0x40,
*(_BYTE *)(spriteram + v6 - 3) & 0x80,
*(unsigned __int8 *)(spriteram + v6),
240 - (unsigned int)*(unsigned __int8 *)(spriteram + v6 - 1),
Machine + 776LL,
2LL,
0LL);
if ( v7 > 240 )
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(*(_BYTE *)(spriteram + v6 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram + v6 - 2)) & 0x40u) + 128,
*(_BYTE *)(spriteram + v6 - 2) & 0xF,
*(_BYTE *)(spriteram + v6 - 3) & 0x40,
*(_BYTE *)(spriteram + v6 - 3) & 0x80,
(unsigned int)(v7 - 256),
240 - (unsigned int)*(unsigned __int8 *)(spriteram + v6 - 1),
Machine + 776LL,
2LL,
0LL);
v6 -= 4LL;
v5 -= 4;
}
while ( v5 >= 0 );
}
result = &spriteram_2_size;
v9 = spriteram_2_size - 4;
if ( spriteram_2_size - 4 >= 0 )
{
v10 = v9 + 3LL;
do
{
v11 = *(unsigned __int8 *)(spriteram_2 + v10);
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram_2 + v10 - 2)) & 0x40u,
*(_BYTE *)(spriteram_2 + v10 - 2) & 0xF,
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x40,
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x80,
*(unsigned __int8 *)(spriteram_2 + v10),
240 - (unsigned int)*(unsigned __int8 *)(spriteram_2 + v10 - 1),
Machine + 776LL,
2LL,
0LL);
if ( v11 > 240 )
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram_2 + v10 - 2)) & 0x40u,
*(_BYTE *)(spriteram_2 + v10 - 2) & 0xF,
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x40,
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x80,
(unsigned int)(v11 - 256),
240 - (unsigned int)*(unsigned __int8 *)(spriteram_2 + v10 - 1),
Machine + 776LL,
2LL,
0LL);
v10 -= 4LL;
v9 -= 4;
}
while ( v9 >= 0 );
}
return result;
}

canonical_decompiled_code:
void *__fastcall func4(__int64 a1)
{
int v1; // ebx
__int64 v2; // r12
__int64 v3; // rcx
__int64 i; // rax
int v5; // er13
__int64 v6; // rbx
int v7; // er12
void *result; // rax
int v9; // er13
__int64 v10; // rbx
int v11; // er12
int v12[42]; // [rsp+0h] [rbp-A8h] BYREF

v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
if ( *(_BYTE *)(dirtybuffer + v2) )
{
*(_BYTE *)(dirtybuffer + v2) = 0;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v2) + ((16 * *(unsigned __int8 *)(colorram + v2)) & 0x100u),
*(_BYTE *)(colorram + v2) & 0xF,
*(_BYTE *)(colorram + v2) & 0x40,
*(_BYTE *)(colorram + v2) & 0x80,
(unsigned int)(8 * (v1 % 32)),
(unsigned int)(8 * (v1 / 32)),
0LL,
0LL,
0LL);
}
--v2;
--v1;
}
while ( v1 >= 0 );
}
v3 = seicross_row_scroll;
for ( i = 0LL; i != 32; ++i )
v12[i] = -*(unsigned __int8 *)(v3 + i);
copyscrollbitmap(a1, tmpbitmap, 0LL, 0LL, 32LL, v12, Machine + 776LL, 0LL, 0LL);
v5 = spriteram_size - 4;
if ( spriteram_size - 4 >= 0 )
{
v6 = v5 + 3LL;
do
{
v7 = *(unsigned __int8 *)(spriteram + v6);
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(*(_BYTE *)(spriteram + v6 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram + v6 - 2)) & 0x40u) + 128,
*(_BYTE *)(spriteram + v6 - 2) & 0xF,
*(_BYTE *)(spriteram + v6 - 3) & 0x40,
*(_BYTE *)(spriteram + v6 - 3) & 0x80,
*(unsigned __int8 *)(spriteram + v6),
240 - (unsigned int)*(unsigned __int8 *)(spriteram + v6 - 1),
Machine + 776LL,
2LL,
0LL);
if ( v7 > 240 )
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
(*(_BYTE *)(spriteram + v6 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram + v6 - 2)) & 0x40u) + 128,
*(_BYTE *)(spriteram + v6 - 2) & 0xF,
*(_BYTE *)(spriteram + v6 - 3) & 0x40,
*(_BYTE *)(spriteram + v6 - 3) & 0x80,
(unsigned int)(v7 - 256),
240 - (unsigned int)*(unsigned __int8 *)(spriteram + v6 - 1),
Machine + 776LL,
2LL,
0LL);
v6 -= 4LL;
v5 -= 4;
}
while ( v5 >= 0 );
}
result = &spriteram_2_size;
v9 = spriteram_2_size - 4;
if ( spriteram_2_size - 4 >= 0 )
{
v10 = v9 + 3LL;
do
{
v11 = *(unsigned __int8 *)(spriteram_2 + v10);
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram_2 + v10 - 2)) & 0x40u,
*(_BYTE *)(spriteram_2 + v10 - 2) & 0xF,
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x40,
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x80,
*(unsigned __int8 *)(spriteram_2 + v10),
240 - (unsigned int)*(unsigned __int8 *)(spriteram_2 + v10 - 1),
Machine + 776LL,
2LL,
0LL);
if ( v11 > 240 )
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x3F | (4 * *(_BYTE *)(spriteram_2 + v10 - 2)) & 0x40u,
*(_BYTE *)(spriteram_2 + v10 - 2) & 0xF,
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x40,
*(_BYTE *)(spriteram_2 + v10 - 3) & 0x80,
(unsigned int)(v11 - 256),
240 - (unsigned int)*(unsigned __int8 *)(spriteram_2 + v10 - 1),
Machine + 776LL,
2LL,
0LL);
v10 -= 4LL;
v9 -= 4;
}
while ( v9 >= 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: struct osd_bitmap { int width; int depth; void *_private; unsigned char **line; } *

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 func5()
{
__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 *

return_type: void


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;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__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;
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

variable_types:
data
unsigned int


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

canonical_decompiled_code:
__int64 func7()
{
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 func8()
{
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);
}

return_type: unsigned int


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

canonical_decompiled_code:
__int64 __fastcall func2(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);
}


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

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;
}

return_type: int


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)
{
void *result; // rax

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

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

result = (void *)(a2 & 1);
if ( (_DWORD)result != flipscreen )
{
flipscreen = a2 & 1;
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);
 }
}


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; // ebx
__int64 v3; // r12
int v4; // ecx
int v5; // eax
int v6; // edx
int v7; // eax
__int64 i; // rbx
__int64 v9; // rdi
__int64 v10; // r8
__int64 v11; // r9
int v12; // esi
void *result; // rax
int v14; // ebx
__int64 v15; // r12
int v16; // edi
int v17; // eax
char v18; // si
int v19; // edx
int v20; // eax

v2 = videoram_size - 1;
if ( videoram_size - 1 > 0 )
{
v3 = v2;
do
{
if ( *(_BYTE *)(dirtybuffer + v3) )
{
*(_BYTE *)(dirtybuffer + v3) = 0;
v6 = v2 % 32;
v7 = v2 / 32;
if ( v2 <= 63 )
{
v4 = v7 + 34;
v5 = v6 - 2;
}
else if ( v2 <= 959 )
{
v4 = v6 + 2;
v5 = v7 - 2;
}
else
{
v4 = v7 - 30;
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 );
}
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
for ( i = 257LL; i != 385; i += 2LL )
{
v12 = *(unsigned __int8 *)(spriteram + i - 1);
v11 = *(_BYTE *)(spriteram + i - 257) & 0x40;
v10 = *(_BYTE *)(spriteram + i - 257) & 0x80;
if ( flipscreen )
{
v9 = (unsigned int)(v12 - 16);
v10 = (_DWORD)v10 == 0;
v11 = (_DWORD)v11 == 0;
}
else
{
v9 = (unsigned int)(224 - v12);
}
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
((*(_BYTE *)(spriteram + i - 129) & 1) << 6) + (*(_BYTE *)(spriteram + i - 257) & 0x3Fu),
*(_BYTE *)(spriteram + i - 256) & 0x3F,
v10,
v11,
((*(unsigned __int8 *)(spriteram + i - 128) << 8) & 0x100)
+ (unsigned int)*(unsigned __int8 *)(spriteram + i)
- 40,
v9,
Machine + 776LL,
6LL,
31LL);
}
result = &videoram_size;
v14 = videoram_size - 1;
if ( videoram_size - 1 > 0 )
{
v15 = v14;
do
{
result = (void *)colorram;
v18 = *(_BYTE *)(colorram + v15);
if ( v18 < 0 )
{
v19 = v14 % 32;
v20 = v14 / 32;
if ( v14 <= 63 )
{
v16 = v20 + 34;
v17 = v19 - 2;
}
else if ( v14 <= 959 )
{
v16 = v19 + 2;
v17 = v20 - 2;
}
else
{
v16 = v20 - 30;
v17 = v19 - 2;
}
if ( flipscreen )
{
v16 = 35 - v16;
v17 = 27 - v17;
}
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v15),
v18 & 0x3F,
(unsigned int)flipscreen,
(unsigned int)flipscreen,
(unsigned int)(8 * v16),
(unsigned int)(8 * v17),
Machine + 776LL,
0LL,
0LL);
}
--v15;
--v14;
}
while ( v14 );
}
return result;
}

canonical_decompiled_code:
void *__fastcall func7(__int64 a1)
{
int v2; // ebx
__int64 v3; // r12
int v4; // ecx
int v5; // eax
int v6; // edx
int v7; // eax
__int64 i; // rbx
__int64 v9; // rdi
__int64 v10; // r8
__int64 v11; // r9
int v12; // esi
void *result; // rax
int v14; // ebx
__int64 v15; // r12
int v16; // edi
int v17; // eax
char v18; // si
int v19; // edx
int v20; // eax

v2 = videoram_size - 1;
if ( videoram_size - 1 > 0 )
{
v3 = v2;
do
{
if ( *(_BYTE *)(dirtybuffer + v3) )
{
*(_BYTE *)(dirtybuffer + v3) = 0;
v6 = v2 % 32;
v7 = v2 / 32;
if ( v2 <= 63 )
{
v4 = v7 + 34;
v5 = v6 - 2;
}
else if ( v2 <= 959 )
{
v4 = v6 + 2;
v5 = v7 - 2;
}
else
{
v4 = v7 - 30;
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 );
}
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
for ( i = 257LL; i != 385; i += 2LL )
{
v12 = *(unsigned __int8 *)(spriteram + i - 1);
v11 = *(_BYTE *)(spriteram + i - 257) & 0x40;
v10 = *(_BYTE *)(spriteram + i - 257) & 0x80;
if ( flipscreen )
{
v9 = (unsigned int)(v12 - 16);
v10 = (_DWORD)v10 == 0;
v11 = (_DWORD)v11 == 0;
}
else
{
v9 = (unsigned int)(224 - v12);
}
drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
((*(_BYTE *)(spriteram + i - 129) & 1) << 6) + (*(_BYTE *)(spriteram + i - 257) & 0x3Fu),
*(_BYTE *)(spriteram + i - 256) & 0x3F,
v10,
v11,
((*(unsigned __int8 *)(spriteram + i - 128) << 8) & 0x100)
+ (unsigned int)*(unsigned __int8 *)(spriteram + i)
- 40,
v9,
Machine + 776LL,
6LL,
31LL);
}
result = &videoram_size;
v14 = videoram_size - 1;
if ( videoram_size - 1 > 0 )
{
v15 = v14;
do
{
result = (void *)colorram;
v18 = *(_BYTE *)(colorram + v15);
if ( v18 < 0 )
{
v19 = v14 % 32;
v20 = v14 / 32;
if ( v14 <= 63 )
{
v16 = v20 + 34;
v17 = v19 - 2;
}
else if ( v14 <= 959 )
{
v16 = v19 + 2;
v17 = v20 - 2;
}
else
{
v16 = v20 - 30;
v17 = v19 - 2;
}
if ( flipscreen )
{
v16 = 35 - v16;
v17 = 27 - v17;
}
result = (void *)drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
*(unsigned __int8 *)(videoram + v15),
v18 & 0x3F,
(unsigned int)flipscreen,
(unsigned int)flipscreen,
(unsigned int)(8 * v16),
(unsigned int)(8 * v17),
Machine + 776LL,
0LL,
0LL);
}
--v15;
--v14;
}
while ( v14 );
}
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 func9()
{
free(mixer_table);
free(mixer_buffer);
}

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


decompiled_code:
__int64 wiping_sh_start()
{
void *v0; // rax
void *v1; // rbp
unsigned int v2; // ebx
__int64 v3; // rdx
unsigned __int64 v4; // rcx
_DWORD *v5; // rax

stream = stream_init("Wiping", 100LL, 48000LL, 0LL, wiping_update_mono);
v0 = malloc(0x2EE00uLL);
mixer_buffer = v0;
if ( !v0 )
return 1;
v1 = v0;
v2 = make_mixer_table(8, 48);
if ( v2 )
{
free(v1);
v2 = 1;
}
else
{
last_channel = (__int64)&flipscreen;
sound_rom = memory_region(146LL);
v3 = memory_region(147LL);
sound_enable = 1;
v4 = last_channel;
v5 = &channel_list;
if ( last_channel > (unsigned __int64)&channel_list )
{
do
{
*v5 = 0;
v5[3] = 0;
v5[2] = 0;
*((_QWORD *)v5 + 2) = v3;
v5[1] = 0;
v5 += 8;
}
while ( v4 > (unsigned __int64)v5 );
}
}
return v2;
}

canonical_decompiled_code:
__int64 func10()
{
void *v0; // rax
void *v1; // rbp
unsigned int v2; // ebx
__int64 v3; // rdx
unsigned __int64 v4; // rcx
_DWORD *v5; // rax

stream = stream_init("Wiping", 100LL, 48000LL, 0LL, wiping_update_mono);
v0 = malloc(0x2EE00uLL);
mixer_buffer = v0;
if ( !v0 )
return 1;
v1 = v0;
v2 = func8(8, 48);
if ( v2 )
{
free(v1);
v2 = 1;
}
else
{
last_channel = (__int64)&flipscreen;
sound_rom = memory_region(146LL);
v3 = memory_region(147LL);
sound_enable = 1;
v4 = last_channel;
v5 = &channel_list;
if ( last_channel > (unsigned __int64)&channel_list )
{
do
{
*v5 = 0;
v5[3] = 0;
v5[2] = 0;
*((_QWORD *)v5 + 2) = v3;
v5[1] = 0;
v5 += 8;
}
while ( v4 > (unsigned __int64)v5 );
}
}
return v2;
}

original_code:
int wiping_sh_start(const struct MachineSound *msound)
{
 const char *mono_name = "Wiping";
 sound_channel *voice;
 stream = stream_init(mono_name,100 , samplerate, 0, wiping_update_mono);
 if ((mixer_buffer = (short int*)malloc(2 * sizeof(short) * samplerate)) == 0)
  return 1;
 mixer_buffer_2 = mixer_buffer + samplerate;
 if (make_mixer_table(8, defgain))
 {
  free(mixer_buffer);
  return 1;
 }
 num_voices = 8;
 last_channel = channel_list + num_voices;
 sound_rom = memory_region(REGION_SOUND1);
 sound_prom = memory_region(REGION_SOUND2);
 sound_enable = 1;
 for (voice = channel_list; voice < last_channel; voice++)
 {
  voice->frequency = 0;
  voice->volume[0] = voice->volume[1] = 0;
  voice->wave = &sound_prom[0];
  voice->counter = 0;
 }
 return 0;
}

canonical_original_code:
int wiping_sh_start(struct MachineSound *msound)
{
 char *mono_name = "Wiping";
 struct sound_channel *voice;
 stream = stream_init(mono_name,100 , samplerate, 0, wiping_update_mono);
 if ((mixer_buffer = (short *)malloc(2 * sizeof(short) * samplerate)) == 0)
  return 1;
 mixer_buffer_2 = mixer_buffer + samplerate;
 if (make_mixer_table(8, defgain))
 {
  free(mixer_buffer);
  return 1;
 }
 num_voices = 8;
 last_channel = channel_list + num_voices;
 sound_rom = memory_region(REGION_SOUND1);
 sound_prom = memory_region(REGION_SOUND2);
 sound_enable = 1;
 for (voice = channel_list; voice < last_channel; voice++)
 {
  voice->frequency = 0;
  voice->volume[0] = voice->volume[1] = 0;
  voice->wave = &sound_prom[0];
  voice->counter = 0;
 }
 return 0;
}

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

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


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; // edx
int v9; // edx
char *v10; // rbx

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

canonical_decompiled_code:
unsigned __int64 __fastcall func11(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; // edx
int v9; // edx
char *v10; // rbx

stream_update((unsigned int)stream, 0LL);
result = a1;
*(_BYTE *)(*(_QWORD *)&wiping_soundregs + a1) = a2;
if ( a1 > 0x3F )
{
if ( a1 > 0x1FFF )
{
result = 32LL * ((unsigned __int8)(a1 & 0x3F) >> 3);
if ( *(_DWORD *)((char *)&channel_list + result + 24) )
{
v10 = (char *)&channel_list + result;
*((_DWORD *)v10 + 1) = 0;
*((_DWORD *)v10 + 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;
result = (unsigned __int64)&channel_list;
v7 = 8197 - wiping_soundregs;
do
{
v8 = v6[2] & 0xF;
*(_DWORD *)result = v8;
v9 = (v6[1] & 0xF) + 16 * v8;
*(_DWORD *)result = v9;
*(_DWORD *)result = (*v6 & 0xF) + 16 * v9;
*(_DWORD *)(result + 8) = v6[7] & 0xF;
if ( (v6[5] & 0xF) != 0 )
{
*(_QWORD *)(result + 16) = v5 + (((*(_BYTE *)(v4 + v7 + (int)v6) & 0xF) + 16 * (v6[5] & 0xF)) << 7);
*(_DWORD *)(result + 24) = 1;
}
else
{
*(_QWORD *)(result + 16) = v5 + (unsigned __int8)(16 * v6[3]);
*(_DWORD *)(result + 24) = 0;
}
result += 32LL;
v6 += 8;
}
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


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 func12(__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; // ebp
unsigned int i; // ebx

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

canonical_decompiled_code:
__int64 __fastcall func13(char a1)
{
unsigned int v1; // ebp
unsigned int i; // ebx

v1 = 0;
for ( i = 0; i != 8; ++i )
v1 |= (((int)readinputport(i) >> a1) & 1) << i;
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


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

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

original_code:
static data_t shared1_r(offs_t offset)
{
 return sharedram1[offset];
}

canonical_original_code:
static unsigned int shared1_r(unsigned int offset)
{
 return sharedram1[offset];
}


decompiled_code:
__int64 __fastcall nitedrvr_draw_block(__int64 a1, int a2, int a3, int a4, int a5)
{
int v5; // ebp
__int64 result; // rax
int v9; // ebx

v5 = a3;
if ( a3 < a5 )
{
do
{
v9 = a2;
if ( a2 < a4 )
{
do
{
if ( v5 <= 255 && v9 <= 255 )
result = plot_pixel(
a1,
(unsigned int)v9,
(unsigned int)v5,
*(unsigned __int16 *)(*(_QWORD *)(Machine + 792LL) + 2LL));
++v9;
}
while ( a4 != v9 );
}
++v5;
}
while ( a5 != v5 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, int a3, int a4, int a5)
{
int v5; // ebp
__int64 result; // rax
int v9; // ebx

v5 = a3;
if ( a3 < a5 )
{
do
{
v9 = a2;
if ( a2 < a4 )
{
do
{
if ( v5 <= 255 && v9 <= 255 )
result = plot_pixel(
a1,
(unsigned int)v9,
(unsigned int)v5,
*(unsigned __int16 *)(*(_QWORD *)(Machine + 792LL) + 2LL));
++v9;
}
while ( a4 != v9 );
}
++v5;
}
while ( a5 != v5 );
}
return result;
}

original_code:
static void nitedrvr_draw_block(struct osd_bitmap *bitmap, int bx, int by, int ex, int ey)
{
 int x,y;
 for (y=by; y<ey; y++)
 {
  for (x=bx; x<ex; x++)
  {
   if ((y<256) && (x<256))
    plot_pixel(bitmap, x, y, Machine->pens[1]);
  }
 }
 return;
}

canonical_original_code:
static void nitedrvr_draw_block(struct osd_bitmap *bitmap, int bx, int by, int ex, int ey)
{
 int x; int y;
 for (y=by; y<ey; y++)
 {
  for (x=bx; x<ex; x++)
  {
   if ((y<256) && (x<256))
    plot_pixel(bitmap, x, y, Machine->pens[1]);
  }
 }
 return;
}

variable_types: bx int

variable_types: by int

variable_types: ex int

variable_types: ey int

variable_types: x int

variable_types: y int

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


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

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

original_code:
data_t nitedrvr_ram_r(offs_t offset)
{
 return nitedrvr_ram[offset];
}

canonical_original_code:
unsigned int nitedrvr_ram_r(unsigned int offset)
{
 return nitedrvr_ram[offset];
}


decompiled_code:
__int64 nitedrvr_steering_reset_r()
{
nitedrvr_steering_val = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
nitedrvr_steering_val = 0;
return 0LL;
}

original_code:
data_t nitedrvr_steering_reset_r(offs_t offset)
{
 nitedrvr_steering_val=0x00;
 return 0;
}

canonical_original_code:
unsigned int nitedrvr_steering_reset_r(unsigned int offset)
{
 nitedrvr_steering_val=0x00;
 return 0;
}


decompiled_code:
void nitedrvr_steering_reset_w()
{
nitedrvr_steering_val = 0;
}

canonical_decompiled_code:
void func5()
{
nitedrvr_steering_val = 0;
}

original_code:
void nitedrvr_steering_reset_w(offs_t offset,data_t data)
{
 nitedrvr_steering_val=0x00;
}

canonical_original_code:
void nitedrvr_steering_reset_w(unsigned int offset, unsigned int data)
{
 nitedrvr_steering_val=0x00;
}


decompiled_code:
void nitedrvr_out0_w()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void nitedrvr_out0_w(offs_t offset,data_t data)
{
}

canonical_original_code:
void nitedrvr_out0_w(unsigned int offset, unsigned int data)
{
}


decompiled_code:
__int64 __fastcall nitedrvr_vh_screenrefresh(__int64 a1)
{
int v1; // ebx
__int64 v2; // r12
__int64 i; // rbx
__int64 j; // rbx
int k; // ebx
__int64 result; // rax
__int64 v7[2]; // [rsp+0h] [rbp-48h]
__int16 v8; // [rsp+10h] [rbp-38h]
int v9; // [rsp+1Ah] [rbp-2Eh]
__int16 v10; // [rsp+1Eh] [rbp-2Ah]

v9 = 302056711;
v10 = 0;
v7[0] = 0x1805050309160F0ELL;
v7[1] = 0x1000000014120510LL;
v8 = 3858;
v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
if ( *(_BYTE *)(dirtybuffer + v2) )
{
*(_BYTE *)(dirtybuffer + v2) = 0;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(_BYTE *)(videoram + v2) & 0x3F,
0LL,
0LL,
0LL,
(unsigned int)(8 * (v1 % 32)),
(unsigned int)(16 * (v1 / 32)),
Machine + 776LL,
0LL,
0LL);
}
--v2;
--v1;
}
while ( v1 >= 0 );
}
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
for ( i = 0LL; i != 16; ++i )
nitedrvr_draw_block(
a1,
*(unsigned __int8 *)(nitedrvr_hvc + i),
*(unsigned __int8 *)(nitedrvr_hvc + i + 16),
*(unsigned __int8 *)(nitedrvr_hvc + i) + (*(_BYTE *)(nitedrvr_hvc + i + 32) >> 4),
*(unsigned __int8 *)(nitedrvr_hvc + i + 16) - (*(_BYTE *)(nitedrvr_hvc + i + 32) & 0xF) + 16);
nitedrvr_draw_block(a1, 64, 232, 192, 256);
HIBYTE(v10) = nitedrvr_gear + 48;
for ( j = 0LL; j != 6; ++j )
drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
(unsigned int)*((char *)&v9 + j),
0LL,
0LL,
0LL,
(unsigned int)(8 * j),
248LL,
Machine + 776LL,
0LL,
0LL);
for ( k = 0; k != 6; ++k )
result = drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
(unsigned int)*((char *)v7 + 6 * nitedrvr_track + k),
0LL,
0LL,
0LL,
(unsigned int)(8 * k + 208),
248LL,
Machine + 776LL,
0LL,
0LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
int v1; // ebx
__int64 v2; // r12
__int64 i; // rbx
__int64 j; // rbx
int k; // ebx
__int64 result; // rax
__int64 v7[2]; // [rsp+0h] [rbp-48h]
__int16 v8; // [rsp+10h] [rbp-38h]
int v9; // [rsp+1Ah] [rbp-2Eh]
__int16 v10; // [rsp+1Eh] [rbp-2Ah]

v9 = 302056711;
v10 = 0;
v7[0] = 0x1805050309160F0ELL;
v7[1] = 0x1000000014120510LL;
v8 = 3858;
v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
if ( *(_BYTE *)(dirtybuffer + v2) )
{
*(_BYTE *)(dirtybuffer + v2) = 0;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(_BYTE *)(videoram + v2) & 0x3F,
0LL,
0LL,
0LL,
(unsigned int)(8 * (v1 % 32)),
(unsigned int)(16 * (v1 / 32)),
Machine + 776LL,
0LL,
0LL);
}
--v2;
--v1;
}
while ( v1 >= 0 );
}
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
for ( i = 0LL; i != 16; ++i )
func1(
a1,
*(unsigned __int8 *)(nitedrvr_hvc + i),
*(unsigned __int8 *)(nitedrvr_hvc + i + 16),
*(unsigned __int8 *)(nitedrvr_hvc + i) + (*(_BYTE *)(nitedrvr_hvc + i + 32) >> 4),
*(unsigned __int8 *)(nitedrvr_hvc + i + 16) - (*(_BYTE *)(nitedrvr_hvc + i + 32) & 0xF) + 16);
func1(a1, 64, 232, 192, 256);
HIBYTE(v10) = nitedrvr_gear + 48;
for ( j = 0LL; j != 6; ++j )
drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
(unsigned int)*((char *)&v9 + j),
0LL,
0LL,
0LL,
(unsigned int)(8 * j),
248LL,
Machine + 776LL,
0LL,
0LL);
for ( k = 0; k != 6; ++k )
result = drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
(unsigned int)*((char *)v7 + 6 * nitedrvr_track + k),
0LL,
0LL,
0LL,
(unsigned int)(8 * k + 208),
248LL,
Machine + 776LL,
0LL,
0LL);
return result;
}

original_code:
void nitedrvr_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int offs,roadway;
 char gear_buf[] = {0x07,0x05,0x01,0x12,0x00,0x00};
 char track_buf[] = {0x0e,0x0f,0x16,0x09,0x03,0x05,
      0x05,0x18,0x10,0x05,0x12,0x14,
      0x00,0x00,0x00,0x10,0x12,0x0f};
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int charcode;
   int sx,sy;
   dirtybuffer[offs]=0;
   charcode = videoram[offs] & 0x3f;
   sx = 8 * (offs % 32);
   sy = 16 * (offs / 32);
   drawgfx(tmpbitmap,Machine->gfx[0],
     charcode, 0,
     0,0,sx,sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 for (roadway=0; roadway < 16; roadway++)
 {
  int bx, by, ex, ey;
  bx = nitedrvr_hvc[roadway];
  by = nitedrvr_hvc[roadway + 16];
  ex = bx + ((nitedrvr_hvc[roadway + 32] & 0xf0) >> 4);
  ey = by + (16 - (nitedrvr_hvc[roadway + 32] & 0x0f));
  nitedrvr_draw_block(bitmap,bx,by,ex,ey);
 }
 nitedrvr_draw_block(bitmap,64,232,192,256);
 gear_buf[5]=0x30 + nitedrvr_gear;
 for (offs = 0; offs < 6; offs++)
  drawgfx(bitmap,Machine->gfx[0],
    gear_buf[offs],0,
    0,0,(offs)*8,31*8,
    &Machine->visible_area,TRANSPARENCY_NONE,0);
 for (offs = 0; offs < 6; offs++)
  drawgfx(bitmap,Machine->gfx[0],
    track_buf[offs + 6*nitedrvr_track],0,
    0,0,(offs+26)*8,31*8,
    &Machine->visible_area,TRANSPARENCY_NONE,0);
}

canonical_original_code:
void nitedrvr_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int offs; int roadway;
 char gear_buf[] = {0x07,0x05,0x01,0x12,0x00,0x00};
 char track_buf[] = {0x0e,0x0f,0x16,0x09,0x03,0x05,
      0x05,0x18,0x10,0x05,0x12,0x14,
      0x00,0x00,0x00,0x10,0x12,0x0f};
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int charcode;
   int sx; int sy;
   dirtybuffer[offs]=0;
   charcode = videoram[offs] & 0x3f;
   sx = 8 * (offs % 32);
   sy = 16 * (offs / 32);
   drawgfx(tmpbitmap,Machine->gfx[0],
     charcode, 0,
     0,0,sx,sy,
     &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 for (roadway=0; roadway < 16; roadway++)
 {
  int bx; int by; int ex; int ey;
  bx = nitedrvr_hvc[roadway];
  by = nitedrvr_hvc[roadway + 16];
  ex = bx + ((nitedrvr_hvc[roadway + 32] & 0xf0) >> 4);
  ey = by + (16 - (nitedrvr_hvc[roadway + 32] & 0x0f));
  nitedrvr_draw_block(bitmap,bx,by,ex,ey);
 }
 nitedrvr_draw_block(bitmap,64,232,192,256);
 gear_buf[5]=0x30 + nitedrvr_gear;
 for (offs = 0; offs < 6; offs++)
  drawgfx(bitmap,Machine->gfx[0],
    gear_buf[offs],0,
    0,0,(offs)*8,31*8,
    &Machine->visible_area,TRANSPARENCY_NONE,0);
 for (offs = 0; offs < 6; offs++)
  drawgfx(bitmap,Machine->gfx[0],
    track_buf[offs + 6*nitedrvr_track],0,
    0,0,(offs+26)*8,31*8,
    &Machine->visible_area,TRANSPARENCY_NONE,0);
}

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

variable_types: offs int

variable_types: roadway int

variable_types: charcode int

variable_types: sx int


decompiled_code:
__int64 nitedrvr_steering()
{
int v0; // eax
int v1; // edx
int v2; // eax

v0 = input_port_5_r(0LL);
v1 = v0 - last_val_1;
last_val_1 = v0;
if ( v1 <= 128 )
{
if ( v1 < -128 )
v1 += 256;
}
else
{
v1 -= 256;
}
v2 = nitedrvr_steering_buf + v1 / 4;
nitedrvr_steering_buf = v2;
if ( v2 <= 0 )
{
if ( v2 < 0 )
{
nitedrvr_steering_buf = v2 + 1;
nitedrvr_steering_val = 128;
}
else
{
nitedrvr_steering_val = 0;
}
}
else
{
nitedrvr_steering_buf = v2 - 1;
nitedrvr_steering_val = 192;
}
return (unsigned int)nitedrvr_steering_val;
}

canonical_decompiled_code:
__int64 func9()
{
int v0; // eax
int v1; // edx
int v2; // eax

v0 = input_port_5_r(0LL);
v1 = v0 - last_val_1;
last_val_1 = v0;
if ( v1 <= 128 )
{
if ( v1 < -128 )
v1 += 256;
}
else
{
v1 -= 256;
}
v2 = nitedrvr_steering_buf + v1 / 4;
nitedrvr_steering_buf = v2;
if ( v2 <= 0 )
{
if ( v2 < 0 )
{
nitedrvr_steering_buf = v2 + 1;
nitedrvr_steering_val = 128;
}
else
{
nitedrvr_steering_val = 0;
}
}
else
{
nitedrvr_steering_buf = v2 - 1;
nitedrvr_steering_val = 192;
}
return (unsigned int)nitedrvr_steering_val;
}

original_code:
static int nitedrvr_steering(void)
{
 static int last_val=0;
 int this_val;
 int delta;
 this_val=input_port_5_r(0);
 delta=this_val-last_val;
 last_val=this_val;
 if (delta>128) delta-=256;
 else if (delta<-128) delta+=256;
 nitedrvr_steering_buf+=(delta/4);
 if (nitedrvr_steering_buf>0)
 {
  nitedrvr_steering_buf--;
  nitedrvr_steering_val=0xC0;
 }
 else if (nitedrvr_steering_buf<0)
 {
  nitedrvr_steering_buf++;
  nitedrvr_steering_val=0x80;
 }
 else
 {
  nitedrvr_steering_val=0x00;
 }
 return nitedrvr_steering_val;
}

canonical_original_code:
static int nitedrvr_steering()
{
 static int last_val = 0;
 int this_val;
 int delta;
 this_val=input_port_5_r(0);
 delta=this_val-last_val;
 last_val=this_val;
 if (delta>128) delta-=256;
 else if (delta<-128) delta+=256;
 nitedrvr_steering_buf+=(delta/4);
 if (nitedrvr_steering_buf>0)
 {
  nitedrvr_steering_buf--;
  nitedrvr_steering_val=0xC0;
 }
 else if (nitedrvr_steering_buf<0)
 {
  nitedrvr_steering_buf++;
  nitedrvr_steering_val=0x80;
 }
 else
 {
  nitedrvr_steering_val=0x00;
 }
 return nitedrvr_steering_val;
}

variable_types: delta int


decompiled_code:
__int64 __fastcall nitedrvr_in0_r(char a1)
{
char v2; // al
unsigned int v3; // edi
__int64 result; // rax
int v5; // ebx

v2 = input_port_2_r(0LL);
if ( (v2 & 0x10) != 0 )
{
nitedrvr_gear = 1;
v3 = a1 & 3;
if ( (a1 & 3) == 2 )
return 224LL;
goto LABEL_3;
}
if ( (v2 & 0x20) != 0 )
{
nitedrvr_gear = 2;
v3 = a1 & 3;
if ( (a1 & 3) == 2 )
return 208LL;
goto LABEL_3;
}
if ( (v2 & 0x40) != 0 )
{
nitedrvr_gear = 3;
v3 = a1 & 3;
result = 176LL;
if ( (a1 & 3) == 2 )
return result;
goto LABEL_3;
}
if ( v2 < 0 )
{
nitedrvr_gear = 4;
v3 = a1 & 3;
result = 112LL;
if ( (a1 & 3) == 2 )
return result;
goto LABEL_3;
}
v3 = a1 & 3;
if ( (a1 & 3) != 2 )
{
LABEL_3:
if ( v3 > 2 )
{
v5 = input_port_3_r(0LL);
result = v5 | (unsigned int)nitedrvr_steering();
}
else if ( v3 )
{
if ( v3 == 1 )
result = input_port_1_r(0LL);
else
result = 255LL;
}
else
{
result = input_port_0_r(0LL);
}
return result;
}
if ( nitedrvr_gear == 1 )
return 224LL;
if ( nitedrvr_gear == 2 )
return 208LL;
result = 176LL;
if ( nitedrvr_gear != 3 )
result = 112LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(char a1)
{
char v2; // al
unsigned int v3; // edi
__int64 result; // rax
int v5; // ebx

v2 = input_port_2_r(0LL);
if ( (v2 & 0x10) != 0 )
{
nitedrvr_gear = 1;
v3 = a1 & 3;
if ( (a1 & 3) == 2 )
return 224LL;
goto LABEL_3;
}
if ( (v2 & 0x20) != 0 )
{
nitedrvr_gear = 2;
v3 = a1 & 3;
if ( (a1 & 3) == 2 )
return 208LL;
goto LABEL_3;
}
if ( (v2 & 0x40) != 0 )
{
nitedrvr_gear = 3;
v3 = a1 & 3;
result = 176LL;
if ( (a1 & 3) == 2 )
return result;
goto LABEL_3;
}
if ( v2 < 0 )
{
nitedrvr_gear = 4;
v3 = a1 & 3;
result = 112LL;
if ( (a1 & 3) == 2 )
return result;
goto LABEL_3;
}
v3 = a1 & 3;
if ( (a1 & 3) != 2 )
{
LABEL_3:
if ( v3 > 2 )
{
v5 = input_port_3_r(0LL);
result = v5 | (unsigned int)func9();
}
else if ( v3 )
{
if ( v3 == 1 )
result = input_port_1_r(0LL);
else
result = 255LL;
}
else
{
result = input_port_0_r(0LL);
}
return result;
}
if ( nitedrvr_gear == 1 )
return 224LL;
if ( nitedrvr_gear == 2 )
return 208LL;
result = 176LL;
if ( nitedrvr_gear != 3 )
result = 112LL;
return result;
}

original_code:
data_t nitedrvr_in0_r(offs_t offset)
{
 int gear;
 gear=input_port_2_r(0);
 if (gear & 0x10) nitedrvr_gear=1;
 else if (gear & 0x20) nitedrvr_gear=2;
 else if (gear & 0x40) nitedrvr_gear=3;
 else if (gear & 0x80) nitedrvr_gear=4;
 switch (offset & 0x03)
 {
  case 0x00:
   return input_port_0_r(0);
  case 0x01:
   return input_port_1_r(0);
  case 0x02:
   if (nitedrvr_gear==1) return 0xE0;
   else if (nitedrvr_gear==2) return 0xD0;
   else if (nitedrvr_gear==3) return 0xB0;
   else return 0x70;
  case 0x03:
   return (input_port_3_r(0) | nitedrvr_steering());
  default:
   return 0xFF;
 }
}

canonical_original_code:
unsigned int nitedrvr_in0_r(unsigned int offset)
{
 int gear;
 gear=input_port_2_r(0);
 if (gear & 0x10) nitedrvr_gear=1;
 else if (gear & 0x20) nitedrvr_gear=2;
 else if (gear & 0x40) nitedrvr_gear=3;
 else if (gear & 0x80) nitedrvr_gear=4;
 switch (offset & 0x03)
 {
  case 0x00:
   return input_port_0_r(0);
  case 0x01:
   return input_port_1_r(0);
  case 0x02:
   if (nitedrvr_gear==1) return 0xE0;
   else if (nitedrvr_gear==2) return 0xD0;
   else if (nitedrvr_gear==3) return 0xB0;
   else return 0x70;
  case 0x03:
   return (input_port_3_r(0) | nitedrvr_steering());
  default:
   return 0xFF;
 }
}

variable_types:
offset
unsigned int

variable_types: gear int


decompiled_code:
__int64 __fastcall nitedrvr_in1_r(char a1)
{
char v1; // al
__int64 result; // rax

ac_line_0 = (ac_line_0 + 1) % 3;
v1 = input_port_4_r(0LL);
if ( (v1 & 0x10) != 0 )
{
nitedrvr_track = 0;
goto LABEL_3;
}
if ( (v1 & 0x20) != 0 )
{
nitedrvr_track = 1;
}
else if ( (v1 & 0x40) != 0 )
{
nitedrvr_track = 2;
LABEL_3:
switch ( a1 & 7 )
{
case 0:
goto LABEL_9;
case 1:
goto LABEL_10;
case 2:
goto LABEL_11;
case 3:
goto LABEL_12;
case 4:
case 7:
result = 0LL;
break;
case 5:
goto LABEL_14;
case 6:
goto LABEL_15;
}
return result;
}
switch ( a1 & 7 )
{
case 0:
LABEL_9:
result = (unsigned __int8)(v1 << 7);
break;
case 1:
LABEL_10:
result = (unsigned __int8)(v1 << 6) & 0x80;
break;
case 2:
LABEL_11:
result = (unsigned __int8)(32 * v1) & 0x80;
break;
case 3:
LABEL_12:
result = (unsigned __int8)(16 * v1) & 0x80;
break;
case 4:
result = (unsigned __int8)(nitedrvr_track == 1) << 7;
break;
case 5:
LABEL_14:
result = (unsigned __int8)(nitedrvr_track == 0) << 7;
break;
case 6:
LABEL_15:
result = (unsigned __int8)(ac_line_0 == 0) << 7;
break;
case 7:
result = 0LL;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(char a1)
{
char v1; // al
__int64 result; // rax

ac_line_0 = (ac_line_0 + 1) % 3;
v1 = input_port_4_r(0LL);
if ( (v1 & 0x10) != 0 )
{
nitedrvr_track = 0;
goto LABEL_3;
}
if ( (v1 & 0x20) != 0 )
{
nitedrvr_track = 1;
}
else if ( (v1 & 0x40) != 0 )
{
nitedrvr_track = 2;
LABEL_3:
switch ( a1 & 7 )
{
case 0:
goto LABEL_9;
case 1:
goto LABEL_10;
case 2:
goto LABEL_11;
case 3:
goto LABEL_12;
case 4:
case 7:
result = 0LL;
break;
case 5:
goto LABEL_14;
case 6:
goto LABEL_15;
}
return result;
}
switch ( a1 & 7 )
{
case 0:
LABEL_9:
result = (unsigned __int8)(v1 << 7);
break;
case 1:
LABEL_10:
result = (unsigned __int8)(v1 << 6) & 0x80;
break;
case 2:
LABEL_11:
result = (unsigned __int8)(32 * v1) & 0x80;
break;
case 3:
LABEL_12:
result = (unsigned __int8)(16 * v1) & 0x80;
break;
case 4:
result = (unsigned __int8)(nitedrvr_track == 1) << 7;
break;
case 5:
LABEL_14:
result = (unsigned __int8)(nitedrvr_track == 0) << 7;
break;
case 6:
LABEL_15:
result = (unsigned __int8)(ac_line_0 == 0) << 7;
break;
case 7:
result = 0LL;
break;
}
return result;
}

original_code:
data_t nitedrvr_in1_r(offs_t offset)
{
 static int ac_line=0x00;
 int port;
 ac_line=(ac_line+1) % 3;
 port=input_port_4_r(0);
 if (port & 0x10) nitedrvr_track=0;
 else if (port & 0x20) nitedrvr_track=1;
 else if (port & 0x40) nitedrvr_track=2;
 switch (offset & 0x07)
 {
  case 0x00:
   return ((port & 0x01) << 7);
  case 0x01:
   return ((port & 0x02) << 6);
  case 0x02:
   return ((port & 0x04) << 5);
  case 0x03:
   return ((port & 0x08) << 4);
  case 0x04:
   if (nitedrvr_track == 1) return 0x80; else return 0x00;
  case 0x05:
   if (nitedrvr_track == 0) return 0x80; else return 0x00;
  case 0x06:
   if (ac_line==0) return 0x80; else return 0x00;
  case 0x07:
   return 0x00;
  default:
   return 0xFF;
 }
}

canonical_original_code:
unsigned int nitedrvr_in1_r(unsigned int offset)
{
 static int ac_line = 0x00;
 int port;
 ac_line=(ac_line+1) % 3;
 port=input_port_4_r(0);
 if (port & 0x10) nitedrvr_track=0;
 else if (port & 0x20) nitedrvr_track=1;
 else if (port & 0x40) nitedrvr_track=2;
 switch (offset & 0x07)
 {
  case 0x00:
   return ((port & 0x01) << 7);
  case 0x01:
   return ((port & 0x02) << 6);
  case 0x02:
   return ((port & 0x04) << 5);
  case 0x03:
   return ((port & 0x08) << 4);
  case 0x04:
   if (nitedrvr_track == 1) return 0x80; else return 0x00;
  case 0x05:
   if (nitedrvr_track == 0) return 0x80; else return 0x00;
  case 0x06:
   if (ac_line==0) return 0x80; else return 0x00;
  case 0x07:
   return 0x00;
  default:
   return 0xFF;
 }
}

variable_types: port int


decompiled_code:
__int64 __fastcall nitedrvr_out1_w(__int64 a1, unsigned int a2)
{
return osd_led_w(0LL, (a2 >> 4) & 1);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, unsigned int a2)
{
return osd_led_w(0LL, (a2 >> 4) & 1);
}

original_code:
void nitedrvr_out1_w(offs_t offset,data_t data)
{
 osd_led_w(0,(data & 0x10)>>4);
}

canonical_original_code:
void nitedrvr_out1_w(unsigned int offset, unsigned int data)
{
 osd_led_w(0,(data & 0x10)>>4);
}

variable_types:
data
unsigned int


decompiled_code:
void skydiver_width_w()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void skydiver_width_w(offs_t offset,data_t data)
{
 skydiver_width = offset;
}

canonical_original_code:
void skydiver_width_w(unsigned int offset, unsigned int data)
{
 skydiver_width = offset;
}


decompiled_code:
_BOOL8 __fastcall skydiver_sk_lamps_w(unsigned int a1)
{
_BOOL8 result; // rax

if ( a1 == 2 )
{
dword_B84 = 0;
}
else if ( a1 > 2 )
{
if ( a1 == 3 )
dword_B84 = 1;
}
else
{
result = a1 != 0;
skydiver_lamps = a1 != 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(unsigned int a1)
{
_BOOL8 result; // rax

if ( a1 == 2 )
{
dword_B84 = 0;
}
else if ( a1 > 2 )
{
if ( a1 == 3 )
dword_B84 = 1;
}
else
{
result = a1 != 0;
skydiver_lamps = a1 != 0;
}
return result;
}

original_code:
void skydiver_sk_lamps_w(offs_t offset,data_t data)
{
 switch (offset)
 {
  case 0: skydiver_lamps[0] = 0; break;
  case 1: skydiver_lamps[0] = 1; break;
  case 2: skydiver_lamps[1] = 0; break;
  case 3: skydiver_lamps[1] = 1; break;
 }
}

canonical_original_code:
void skydiver_sk_lamps_w(unsigned int offset, unsigned int data)
{
 switch (offset)
 {
  case 0: skydiver_lamps[0] = 0; break;
  case 1: skydiver_lamps[0] = 1; break;
  case 2: skydiver_lamps[1] = 0; break;
  case 3: skydiver_lamps[1] = 1; break;
 }
}


decompiled_code:
_BOOL8 __fastcall skydiver_yd_lamps_w(unsigned int a1)
{
_BOOL8 result; // rax

if ( a1 == 2 )
{
dword_B8C = 0;
}
else if ( a1 > 2 )
{
if ( a1 == 3 )
dword_B8C = 1;
}
else
{
result = a1 != 0;
dword_B88 = a1 != 0;
}
return result;
}

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

if ( a1 == 2 )
{
dword_B8C = 0;
}
else if ( a1 > 2 )
{
if ( a1 == 3 )
dword_B8C = 1;
}
else
{
result = a1 != 0;
dword_B88 = a1 != 0;
}
return result;
}

original_code:
void skydiver_yd_lamps_w(offs_t offset,data_t data)
{
 switch (offset)
 {
  case 0: skydiver_lamps[2] = 0; break;
  case 1: skydiver_lamps[2] = 1; break;
  case 2: skydiver_lamps[3] = 0; break;
  case 3: skydiver_lamps[3] = 1; break;
 }
}

canonical_original_code:
void skydiver_yd_lamps_w(unsigned int offset, unsigned int data)
{
 switch (offset)
 {
  case 0: skydiver_lamps[2] = 0; break;
  case 1: skydiver_lamps[2] = 1; break;
  case 2: skydiver_lamps[3] = 0; break;
  case 3: skydiver_lamps[3] = 1; break;
 }
}


decompiled_code:
void __fastcall skydiver_iver_lamps_w(int a1)
{
switch ( a1 )
{
case 0:
dword_B90 = 0;
break;
case 1:
dword_B90 = 1;
break;
case 2:
dword_B94 = 0;
break;
case 3:
dword_B94 = 1;
break;
case 4:
dword_B98 = 0;
break;
case 5:
dword_B98 = 1;
break;
case 6:
dword_B9C = 0;
break;
case 7:
dword_B9C = 1;
break;
default:
return;
}
}

canonical_decompiled_code:
void __fastcall func3(int a1)
{
switch ( a1 )
{
case 0:
dword_B90 = 0;
break;
case 1:
dword_B90 = 1;
break;
case 2:
dword_B94 = 0;
break;
case 3:
dword_B94 = 1;
break;
case 4:
dword_B98 = 0;
break;
case 5:
dword_B98 = 1;
break;
case 6:
dword_B9C = 0;
break;
case 7:
dword_B9C = 1;
break;
default:
return;
}
}

original_code:
void skydiver_iver_lamps_w(offs_t offset,data_t data)
{
 switch (offset)
 {
  case 0: skydiver_lamps[4] = 0; break;
  case 1: skydiver_lamps[4] = 1; break;
  case 2: skydiver_lamps[5] = 0; break;
  case 3: skydiver_lamps[5] = 1; break;
  case 4: skydiver_lamps[6] = 0; break;
  case 5: skydiver_lamps[6] = 1; break;
  case 6: skydiver_lamps[7] = 0; break;
  case 7: skydiver_lamps[7] = 1; break;
 }
}

canonical_original_code:
void skydiver_iver_lamps_w(unsigned int offset, unsigned int data)
{
 switch (offset)
 {
  case 0: skydiver_lamps[4] = 0; break;
  case 1: skydiver_lamps[4] = 1; break;
  case 2: skydiver_lamps[5] = 0; break;
  case 3: skydiver_lamps[5] = 1; break;
  case 4: skydiver_lamps[6] = 0; break;
  case 5: skydiver_lamps[6] = 1; break;
  case 6: skydiver_lamps[7] = 0; break;
  case 7: skydiver_lamps[7] = 1; break;
 }
}


decompiled_code:
void __fastcall skydiver_nmion_w(int a1)
{
skydiver_nmion = a1;
}

canonical_decompiled_code:
void __fastcall func4(int a1)
{
skydiver_nmion = a1;
}

original_code:
void skydiver_nmion_w(offs_t offset,data_t data)
{
 skydiver_nmion = offset;
}

canonical_original_code:
void skydiver_nmion_w(unsigned int offset, unsigned int data)
{
 skydiver_nmion = offset;
}


decompiled_code:
__int64 __fastcall skydiver_vh_screenrefresh(__int64 a1)
{
int v1; // ebx
__int64 v2; // r12
__int64 i; // rbx
__int64 j; // rbx
unsigned __int8 v5; // dl
int v6; // er8
int v7; // er9
__int64 v8; // rdx
__int64 result; // rax

v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
if ( *(_BYTE *)(dirtybuffer + v2) )
{
*(_BYTE *)(dirtybuffer + v2) = 0;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(_BYTE *)(videoram + v2) & 0x3F,
*(_BYTE *)(videoram + v2) >> 6,
0LL,
0LL,
(unsigned int)(8 * (v1 % 32)),
(unsigned int)(8 * (v1 / 32)),
Machine + 776LL,
0LL,
0LL);
}
--v2;
--v1;
}
while ( v1 >= 0 );
}
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
for ( i = 0LL; i != 8; ++i )
drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
(unsigned int)LC0[i],
(unsigned int)(skydiver_lamps[i] + 4),
0LL,
0LL,
(unsigned int)(8 * i),
224LL,
Machine + 776LL,
0LL,
0LL);
for ( j = 3LL; j != -1; --j )
{
v5 = *(_BYTE *)(spriteram + 2 * j + 9);
v6 = (int)v5 >> 4;
v7 = (int)v5 >> 3;
v8 = ((int)v5 >> 2) & 0x18 | v5 & 7u;
result = drawgfx(
a1,
*(_QWORD *)(Machine + 8LL * (((int)v8 > 15) + 1) + 512),
v8,
j & 1,
v6 & 1,
v7 & 1,
232 - (unsigned int)*(unsigned __int8 *)(spriteram + j),
240 - (unsigned int)*(unsigned __int8 *)(spriteram + 2 * j + 8),
Machine + 776LL,
2LL,
0LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
int v1; // ebx
__int64 v2; // r12
__int64 i; // rbx
__int64 j; // rbx
unsigned __int8 v5; // dl
int v6; // er8
int v7; // er9
__int64 v8; // rdx
__int64 result; // rax

v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
if ( *(_BYTE *)(dirtybuffer + v2) )
{
*(_BYTE *)(dirtybuffer + v2) = 0;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
*(_BYTE *)(videoram + v2) & 0x3F,
*(_BYTE *)(videoram + v2) >> 6,
0LL,
0LL,
(unsigned int)(8 * (v1 % 32)),
(unsigned int)(8 * (v1 / 32)),
Machine + 776LL,
0LL,
0LL);
}
--v2;
--v1;
}
while ( v1 >= 0 );
}
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
for ( i = 0LL; i != 8; ++i )
drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
(unsigned int)LC0[i],
(unsigned int)(skydiver_lamps[i] + 4),
0LL,
0LL,
(unsigned int)(8 * i),
224LL,
Machine + 776LL,
0LL,
0LL);
for ( j = 3LL; j != -1; --j )
{
v5 = *(_BYTE *)(spriteram + 2 * j + 9);
v6 = (int)v5 >> 4;
v7 = (int)v5 >> 3;
v8 = ((int)v5 >> 2) & 0x18 | v5 & 7u;
result = drawgfx(
a1,
*(_QWORD *)(Machine + 8LL * (((int)v8 > 15) + 1) + 512),
v8,
j & 1,
v6 & 1,
v7 & 1,
232 - (unsigned int)*(unsigned __int8 *)(spriteram + j),
240 - (unsigned int)*(unsigned __int8 *)(spriteram + 2 * j + 8),
Machine + 776LL,
2LL,
0LL);
}
return result;
}

original_code:
void skydiver_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 int offs;
 int pic;
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int charcode;
   int color;
   int sx,sy;
   dirtybuffer[offs]=0;
   charcode = videoram[offs] & 0x3F;
   color = (videoram[offs] & 0xc0) >> 6;
   sx = 8 * (offs % 32);
   sy = 8 * (offs / 32);
   drawgfx(tmpbitmap,Machine->gfx[0],
    charcode, color,
    0,0,sx,sy,
    &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 {
  int light;
  for (light = 0; light < 8; light++)
  {
   char *text = "SKYDIVER";
   drawgfx(bitmap,Machine->gfx[0],
    text[light], skydiver_lamps[light] + 4,
    0,0,light*8,28*8,
    &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
 for (pic=3;pic>=0;pic--)
 {
  int sx,sy;
  int charcode;
  int xflip, yflip;
  int color;
  sx = 29*8 - spriteram[pic];
  sy = 30*8 - spriteram[pic*2 + 8];
  charcode = spriteram[pic*2 + 9];
  xflip = (charcode & 0x10) >> 4;
  yflip = (charcode & 0x08) >> 3;
  charcode = (charcode & 0x07) | ((charcode & 0x60) >> 2);
  color = pic & 0x01;
  drawgfx(bitmap,Machine->gfx[1+(charcode >= 0x10)],
   charcode, color,
   xflip,yflip,sx,sy,
   &Machine->visible_area,TRANSPARENCY_PEN,0);
 }
}

canonical_original_code:
void skydiver_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 int offs;
 int pic;
 for (offs = videoram_size - 1;offs >= 0;offs--)
 {
  if (dirtybuffer[offs])
  {
   int charcode;
   int color;
   int sx; int sy;
   dirtybuffer[offs]=0;
   charcode = videoram[offs] & 0x3F;
   color = (videoram[offs] & 0xc0) >> 6;
   sx = 8 * (offs % 32);
   sy = 8 * (offs / 32);
   drawgfx(tmpbitmap,Machine->gfx[0],
    charcode, color,
    0,0,sx,sy,
    &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
 copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->visible_area,TRANSPARENCY_NONE,0);
 {
  int light;
  for (light = 0; light < 8; light++)
  {
   char *text = "SKYDIVER";
   drawgfx(bitmap,Machine->gfx[0],
    text[light], skydiver_lamps[light] + 4,
    0,0,light*8,28*8,
    &Machine->visible_area,TRANSPARENCY_NONE,0);
  }
 }
 for (pic=3;pic>=0;pic--)
 {
  int sx; int sy;
  int charcode;
  int xflip; int yflip;
  int color;
  sx = 29*8 - spriteram[pic];
  sy = 30*8 - spriteram[pic*2 + 8];
  charcode = spriteram[pic*2 + 9];
  xflip = (charcode & 0x10) >> 4;
  yflip = (charcode & 0x08) >> 3;
  charcode = (charcode & 0x07) | ((charcode & 0x60) >> 2);
  color = pic & 0x01;
  drawgfx(bitmap,Machine->gfx[1+(charcode >= 0x10)],
   charcode, color,
   xflip,yflip,sx,sy,
   &Machine->visible_area,TRANSPARENCY_PEN,0);
 }
}

variable_types: pic int

variable_types: color int

variable_types: sy int

variable_types: light int

variable_types:
text
char *

variable_types: xflip int

variable_types: yflip int


decompiled_code:
__int64 __fastcall skydiver_input_0_r(unsigned int a1)
{
unsigned __int8 v1; // al
__int64 result; // rax

v1 = input_port_0_r(0LL);
if ( a1 == 2 )
return (4 * v1) & 0xC0;
if ( a1 > 2 )
{
result = v1 & 0xC0;
if ( a1 != 3 )
result = 0LL;
}
else if ( a1 )
{
result = (unsigned __int8)(16 * v1) & 0xC0;
}
else
{
result = (unsigned __int8)(v1 << 6);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
unsigned __int8 v1; // al
__int64 result; // rax

v1 = input_port_0_r(0LL);
if ( a1 == 2 )
return (4 * v1) & 0xC0;
if ( a1 > 2 )
{
result = v1 & 0xC0;
if ( a1 != 3 )
result = 0LL;
}
else if ( a1 )
{
result = (unsigned __int8)(16 * v1) & 0xC0;
}
else
{
result = (unsigned __int8)(v1 << 6);
}
return result;
}

original_code:
data_t skydiver_input_0_r(offs_t offset)
{
 int data = input_port_0_r(0);
 switch(offset)
 {
  case 0: return ((data & 0x03) << 6);
  case 1: return ((data & 0x0C) << 4);
  case 2: return ((data & 0x30) << 2);
  case 3: return ((data & 0xC0) << 0);
  default: return 0;
 }
}

canonical_original_code:
unsigned int skydiver_input_0_r(unsigned int offset)
{
 int data = input_port_0_r(0);
 switch(offset)
 {
  case 0: return ((data & 0x03) << 6);
  case 1: return ((data & 0x0C) << 4);
  case 2: return ((data & 0x30) << 2);
  case 3: return ((data & 0xC0) << 0);
  default: return 0;
 }
}

variable_types: data int


decompiled_code:
__int64 __fastcall skydiver_input_1_r(unsigned int a1)
{
unsigned __int8 v1; // al
__int64 result; // rax

v1 = input_port_1_r(0LL);
if ( a1 == 2 )
return (4 * v1) & 0xC0;
if ( a1 > 2 )
{
result = v1 & 0xC0;
if ( a1 != 3 )
result = 0LL;
}
else if ( a1 )
{
result = (unsigned __int8)(16 * v1) & 0xC0;
}
else
{
result = (unsigned __int8)(v1 << 6);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1)
{
unsigned __int8 v1; // al
__int64 result; // rax

v1 = input_port_1_r(0LL);
if ( a1 == 2 )
return (4 * v1) & 0xC0;
if ( a1 > 2 )
{
result = v1 & 0xC0;
if ( a1 != 3 )
result = 0LL;
}
else if ( a1 )
{
result = (unsigned __int8)(16 * v1) & 0xC0;
}
else
{
result = (unsigned __int8)(v1 << 6);
}
return result;
}

original_code:
data_t skydiver_input_1_r(offs_t offset)
{
 int data = input_port_1_r(0);
 switch(offset)
 {
  case 0: return ((data & 0x03) << 6);
  case 1: return ((data & 0x0C) << 4);
  case 2: return ((data & 0x30) << 2);
  case 3: return ((data & 0xC0) << 0);
  default: return 0;
 }
}

canonical_original_code:
unsigned int skydiver_input_1_r(unsigned int offset)
{
 int data = input_port_1_r(0);
 switch(offset)
 {
  case 0: return ((data & 0x03) << 6);
  case 1: return ((data & 0x0C) << 4);
  case 2: return ((data & 0x30) << 2);
  case 3: return ((data & 0xC0) << 0);
  default: return 0;
 }
}


decompiled_code:
__int64 __fastcall skydiver_input_2_r(unsigned int a1)
{
unsigned __int8 v1; // al
__int64 result; // rax

v1 = input_port_2_r(0LL);
if ( a1 == 2 )
return (4 * v1) & 0xC0;
if ( a1 > 2 )
{
result = v1 & 0xC0;
if ( a1 != 3 )
result = 0LL;
}
else if ( a1 )
{
result = (unsigned __int8)(16 * v1) & 0xC0;
}
else
{
result = (unsigned __int8)(v1 << 6);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1)
{
unsigned __int8 v1; // al
__int64 result; // rax

v1 = input_port_2_r(0LL);
if ( a1 == 2 )
return (4 * v1) & 0xC0;
if ( a1 > 2 )
{
result = v1 & 0xC0;
if ( a1 != 3 )
result = 0LL;
}
else if ( a1 )
{
result = (unsigned __int8)(16 * v1) & 0xC0;
}
else
{
result = (unsigned __int8)(v1 << 6);
}
return result;
}

original_code:
data_t skydiver_input_2_r(offs_t offset)
{
 int data = input_port_2_r(0);
 switch(offset)
 {
  case 0: return ((data & 0x03) << 6);
  case 1: return ((data & 0x0C) << 4);
  case 2: return ((data & 0x30) << 2);
  case 3: return ((data & 0xC0) << 0);
  default: return 0;
 }
}

canonical_original_code:
unsigned int skydiver_input_2_r(unsigned int offset)
{
 int data = input_port_2_r(0);
 switch(offset)
 {
  case 0: return ((data & 0x03) << 6);
  case 1: return ((data & 0x0C) << 4);
  case 2: return ((data & 0x30) << 2);
  case 3: return ((data & 0xC0) << 0);
  default: return 0;
 }
}


decompiled_code:
__int64 __fastcall skydiver_input_3_r(unsigned int a1)
{
unsigned __int8 v1; // al
__int64 result; // rax

v1 = input_port_3_r(0LL);
if ( a1 == 2 )
return (4 * v1) & 0xC0;
if ( a1 > 2 )
{
result = v1 & 0xC0;
if ( a1 != 3 )
result = 0LL;
}
else if ( a1 )
{
result = (unsigned __int8)(16 * v1) & 0xC0;
}
else
{
result = (unsigned __int8)(v1 << 6);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1)
{
unsigned __int8 v1; // al
__int64 result; // rax

v1 = input_port_3_r(0LL);
if ( a1 == 2 )
return (4 * v1) & 0xC0;
if ( a1 > 2 )
{
result = v1 & 0xC0;
if ( a1 != 3 )
result = 0LL;
}
else if ( a1 )
{
result = (unsigned __int8)(16 * v1) & 0xC0;
}
else
{
result = (unsigned __int8)(v1 << 6);
}
return result;
}

original_code:
data_t skydiver_input_3_r(offs_t offset)
{
 int data = input_port_3_r(0);
 switch(offset)
 {
  case 0: return ((data & 0x03) << 6);
  case 1: return ((data & 0x0C) << 4);
  case 2: return ((data & 0x30) << 2);
  case 3: return ((data & 0xC0) << 0);
  default: return 0;
 }
}

canonical_original_code:
unsigned int skydiver_input_3_r(unsigned int offset)
{
 int data = input_port_3_r(0);
 switch(offset)
 {
  case 0: return ((data & 0x03) << 6);
  case 1: return ((data & 0x0C) << 4);
  case 2: return ((data & 0x30) << 2);
  case 3: return ((data & 0xC0) << 0);
  default: return 0;
 }
}


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

if ( skydiver_nmion )
result = nmi_interrupt();
else
result = ignore_interrupt();
return result;
}

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

if ( skydiver_nmion )
result = nmi_interrupt();
else
result = ignore_interrupt();
return result;
}

original_code:
int skydiver_interrupt(void)
{
 if (skydiver_nmion)
  return nmi_interrupt();
 else
     return ignore_interrupt();
}

canonical_original_code:
int skydiver_interrupt()
{
 if (skydiver_nmion)
  return nmi_interrupt();
 else
     return ignore_interrupt();
}


decompiled_code:
__int64 __fastcall init_palette(__int64 a1, __m128i *a2)
{
__int64 result; // rax

*(_QWORD *)a1 = 0x7F7FFFBFBF000000LL;
*(_BYTE *)(a1 + 8) = -1;
*a2 = _mm_load_si128((const __m128i *)&colortable);
result = qword_490;
a2[1].m128i_i64[0] = qword_490;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __m128i *a2)
{
__int64 result; // rax

*(_QWORD *)a1 = 0x7F7FFFBFBF000000LL;
*(_BYTE *)(a1 + 8) = -1;
*a2 = _mm_load_si128((const __m128i *)&colortable);
result = qword_490;
a2[1].m128i_i64[0] = qword_490;
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));
 memcpy(game_colortable,colortable,sizeof(colortable));
}

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));
 memcpy(game_colortable,colortable,sizeof(colortable));
}


decompiled_code:
void lsasquad_sh_nmi_disable_w()
{
sound_nmi_enable = 0;
}

canonical_decompiled_code:
void func0()
{
sound_nmi_enable = 0;
}

original_code:
void lsasquad_sh_nmi_disable_w(offs_t offset,data_t data)
{
 sound_nmi_enable = 0;
}

canonical_original_code:
void lsasquad_sh_nmi_disable_w(unsigned int offset, unsigned int data)
{
 sound_nmi_enable = 0;
}


decompiled_code:
__int64 lsasquad_sh_sound_command_r()
{
sound_pending &= 0xFFFFFFFE;
return (unsigned int)sound_cmd;
}

canonical_decompiled_code:
__int64 func1()
{
sound_pending &= 0xFFFFFFFE;
return (unsigned int)sound_cmd;
}

original_code:
data_t lsasquad_sh_sound_command_r(offs_t offset)
{
 sound_pending &= ~0x01;
 return sound_cmd;
}

canonical_original_code:
unsigned int lsasquad_sh_sound_command_r(unsigned int offset)
{
 sound_pending &= ~0x01;
 return sound_cmd;
}


decompiled_code:
void __fastcall lsasquad_sh_result_w(__int64 a1, int a2)
{
sound_pending |= 2u;
sound_result = a2;
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, int a2)
{
sound_pending |= 2u;
sound_result = a2;
}

original_code:
void lsasquad_sh_result_w(offs_t offset,data_t data)
{
 sound_pending |= 0x02;
 sound_result = data;
}

canonical_original_code:
void lsasquad_sh_result_w(unsigned int offset, unsigned int data)
{
 sound_pending |= 0x02;
 sound_result = data;
}


decompiled_code:
__int64 lsasquad_sound_result_r()
{
sound_pending &= 0xFFFFFFFD;
return (unsigned int)sound_result;
}

canonical_decompiled_code:
__int64 func3()
{
sound_pending &= 0xFFFFFFFD;
return (unsigned int)sound_result;
}

original_code:
data_t lsasquad_sound_result_r(offs_t offset)
{
 sound_pending &= ~0x02;
 return sound_result;
}

canonical_original_code:
unsigned int lsasquad_sound_result_r(unsigned int offset)
{
 sound_pending &= ~0x02;
 return sound_result;
}


decompiled_code:
__int64 lsasquad_sound_status_r()
{
return (unsigned int)sound_pending;
}

canonical_decompiled_code:
__int64 func4()
{
return (unsigned int)sound_pending;
}

original_code:
data_t lsasquad_sound_status_r(offs_t offset)
{
 return sound_pending;
}

canonical_original_code:
unsigned int lsasquad_sound_status_r(unsigned int offset)
{
 return sound_pending;
}


decompiled_code:
__int64 lsasquad_68705_portA_r()
{
return ~(unsigned __int8)ddrA & (unsigned __int8)portA_in | (unsigned int)(unsigned __int8)(portA_out & ddrA);
}

canonical_decompiled_code:
__int64 func5()
{
return ~(unsigned __int8)ddrA & (unsigned __int8)portA_in | (unsigned int)(unsigned __int8)(portA_out & ddrA);
}

original_code:
data_t lsasquad_68705_portA_r(offs_t offset)
{
 return (portA_out & ddrA) | (portA_in & ~ddrA);
}

canonical_original_code:
unsigned int lsasquad_68705_portA_r(unsigned int offset)
{
 return (portA_out & ddrA) | (portA_in & ~ddrA);
}


decompiled_code:
void __fastcall lsasquad_68705_portA_w(__int64 a1, char a2)
{
portA_out = a2;
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1, char a2)
{
portA_out = a2;
}

original_code:
void lsasquad_68705_portA_w(offs_t offset,data_t data)
{
 portA_out = data;
}

canonical_original_code:
void lsasquad_68705_portA_w(unsigned int offset, unsigned int data)
{
 portA_out = data;
}


decompiled_code:
void __fastcall lsasquad_68705_ddrA_w(__int64 a1, char a2)
{
ddrA = a2;
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, char a2)
{
ddrA = a2;
}

original_code:
void lsasquad_68705_ddrA_w(offs_t offset,data_t data)
{
 ddrA = data;
}

canonical_original_code:
void lsasquad_68705_ddrA_w(unsigned int offset, unsigned int data)
{
 ddrA = data;
}


decompiled_code:
__int64 lsasquad_68705_portB_r()
{
return (unsigned __int8)(ddrB & portB_out);
}

canonical_decompiled_code:
__int64 func8()
{
return (unsigned __int8)(ddrB & portB_out);
}

original_code:
data_t lsasquad_68705_portB_r(offs_t offset)
{
 return (portB_out & ddrB) | (portB_in & ~ddrB);
}

canonical_original_code:
unsigned int lsasquad_68705_portB_r(unsigned int offset)
{
 return (portB_out & ddrB) | (portB_in & ~ddrB);
}


decompiled_code:
void __fastcall lsasquad_68705_ddrB_w(__int64 a1, char a2)
{
ddrB = a2;
}

canonical_decompiled_code:
void __fastcall func9(__int64 a1, char a2)
{
ddrB = a2;
}

original_code:
void lsasquad_68705_ddrB_w(offs_t offset,data_t data)
{
 ddrB = data;
}

canonical_original_code:
void lsasquad_68705_ddrB_w(unsigned int offset, unsigned int data)
{
 ddrB = data;
}


decompiled_code:
__int64 lsasquad_mcu_r()
{
mcu_sent = 0;
return (unsigned __int8)from_mcu;
}

canonical_decompiled_code:
__int64 func10()
{
mcu_sent = 0;
return (unsigned __int8)from_mcu;
}

original_code:
data_t lsasquad_mcu_r(offs_t offset)
{
 mcu_sent = 0;
 return from_mcu;
}

canonical_original_code:
unsigned int lsasquad_mcu_r(unsigned int offset)
{
 mcu_sent = 0;
 return from_mcu;
}


original_code:
void lsasquad_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] >> 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[0x400] >> 0) & 0x01;
  bit1 = (color_prom[0x400] >> 1) & 0x01;
  bit2 = (color_prom[0x400] >> 2) & 0x01;
  bit3 = (color_prom[0x400] >> 3) & 0x01;
  *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  bit0 = (color_prom[2*0x400] >> 0) & 0x01;
  bit1 = (color_prom[2*0x400] >> 1) & 0x01;
  bit2 = (color_prom[2*0x400] >> 2) & 0x01;
  bit3 = (color_prom[2*0x400] >> 3) & 0x01;
  *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  color_prom++;
 }
 for (i = 0;i < Machine->drv->color_table_len;i++)
  colortable[i] = i ^ 0x0f;
}

canonical_original_code:
void lsasquad_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] >> 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[0x400] >> 0) & 0x01;
  bit1 = (color_prom[0x400] >> 1) & 0x01;
  bit2 = (color_prom[0x400] >> 2) & 0x01;
  bit3 = (color_prom[0x400] >> 3) & 0x01;
  *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  bit0 = (color_prom[2*0x400] >> 0) & 0x01;
  bit1 = (color_prom[2*0x400] >> 1) & 0x01;
  bit2 = (color_prom[2*0x400] >> 2) & 0x01;
  bit3 = (color_prom[2*0x400] >> 3) & 0x01;
  *(palette++) = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  color_prom++;
 }
 for (i = 0;i < Machine->drv->color_table_len;i++)
  colortable[i] = i ^ 0x0f;
}

variable_types:
palette
unsigned char *

variable_types:
colortable
unsigned short *

variable_types: i int


unk

decompiled_code:
void unk()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code:
static void unk(offs_t offset,data_t data)
{
}

canonical_original_code:
static void unk(unsigned int offset, unsigned int data)
{
}


decompiled_code:
_DWORD *init_lsasquad()
{
_DWORD *result; // rax

result = &lsasquad_invertcoin;
lsasquad_invertcoin = 0;
return result;
}

canonical_decompiled_code:
_DWORD *func13()
{
_DWORD *result; // rax

result = &lsasquad_invertcoin;
lsasquad_invertcoin = 0;
return result;
}

original_code: static void init_lsasquad(void) { lsasquad_invertcoin = 0x00; }

canonical_original_code: static void init_lsasquad() { lsasquad_invertcoin = 0x00; }


decompiled_code:
_DWORD *init_storming()
{
_DWORD *result; // rax

result = &lsasquad_invertcoin;
lsasquad_invertcoin = 12;
return result;
}

canonical_decompiled_code:
_DWORD *func14()
{
_DWORD *result; // rax

result = &lsasquad_invertcoin;
lsasquad_invertcoin = 12;
return result;
}

original_code: static void init_storming(void) { lsasquad_invertcoin = 0x0c; }

canonical_original_code: static void init_storming() { lsasquad_invertcoin = 0x0c; }


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

sound_nmi_enable = 1;
if ( pending_nmi )
{
result = cpu_cause_interrupt(1LL, 4294967294LL);
pending_nmi = 0;
}
return result;
}

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

sound_nmi_enable = 1;
if ( pending_nmi )
{
result = cpu_cause_interrupt(1LL, 4294967294LL);
pending_nmi = 0;
}
return result;
}

original_code:
void lsasquad_sh_nmi_enable_w(offs_t offset,data_t data)
{
 sound_nmi_enable = 1;
 if (pending_nmi)
 {
  cpu_cause_interrupt(1,-2);
  pending_nmi = 0;
 }
}

canonical_original_code:
void lsasquad_sh_nmi_enable_w(unsigned int offset, unsigned int data)
{
 sound_nmi_enable = 1;
 if (pending_nmi)
 {
  cpu_cause_interrupt(1,-2);
  pending_nmi = 0;
 }
}


decompiled_code:
__int64 __fastcall lsasquad_sound_command_w(__int64 a1, __int64 a2)
{
sound_pending |= 1u;
sound_cmd = a2;
return timer_set(0LL, a2, nmi_callback);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2)
{
sound_pending |= 1u;
sound_cmd = a2;
return timer_set(0LL, a2, nmi_callback);
}

original_code:
void lsasquad_sound_command_w(offs_t offset,data_t data)
{
 sound_pending |= 0x01;
 sound_cmd = data;
 timer_set((0),data,nmi_callback);
}

canonical_original_code:
void lsasquad_sound_command_w(unsigned int offset, unsigned int data)
{
 sound_pending |= 0x01;
 sound_cmd = data;
 timer_set((0),data,nmi_callback);
}


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

if ( (ddrB & 2) != 0 && (a2 & 2) == 0 && (portB_out & 2) != 0 )
{
result = (unsigned __int8)from_main;
portA_in = from_main;
if ( main_sent )
result = cpu_set_irq_line(2LL, 0LL, 0LL);
main_sent = 0;
}
if ( (ddrB & 4) != 0 && (a2 & 4) != 0 && (portB_out & 4) == 0 )
{
result = (unsigned __int8)portA_out;
from_mcu = portA_out;
mcu_sent = 1;
}
portB_out = a2;
return result;
}

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

if ( (ddrB & 2) != 0 && (a2 & 2) == 0 && (portB_out & 2) != 0 )
{
result = (unsigned __int8)from_main;
portA_in = from_main;
if ( main_sent )
result = cpu_set_irq_line(2LL, 0LL, 0LL);
main_sent = 0;
}
if ( (ddrB & 4) != 0 && (a2 & 4) != 0 && (portB_out & 4) == 0 )
{
result = (unsigned __int8)portA_out;
from_mcu = portA_out;
mcu_sent = 1;
}
portB_out = a2;
return result;
}

original_code:
void lsasquad_68705_portB_w(offs_t offset,data_t data)
{
 if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02))
 {
  portA_in = from_main;
  if (main_sent) cpu_set_irq_line(2,0,0);
  main_sent = 0;
 }
 if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04))
 {
  from_mcu = portA_out;
  mcu_sent = 1;
 }
 portB_out = data;
}

canonical_original_code:
void lsasquad_68705_portB_w(unsigned int offset, unsigned int data)
{
 if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02))
 {
  portA_in = from_main;
  if (main_sent) cpu_set_irq_line(2,0,0);
  main_sent = 0;
 }
 if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04))
 {
  from_mcu = portA_out;
  mcu_sent = 1;
 }
 portB_out = data;
}


decompiled_code:
__int64 __fastcall lsasquad_mcu_w(__int64 a1, char a2)
{
from_main = a2;
main_sent = 1;
return cpu_set_irq_line(2LL, 0LL, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, char a2)
{
from_main = a2;
main_sent = 1;
return cpu_set_irq_line(2LL, 0LL, 1LL);
}

original_code:
void lsasquad_mcu_w(offs_t offset,data_t data)
{
 from_main = data;
 main_sent = 1;
 cpu_set_irq_line(2,0,1);
}

canonical_original_code:
void lsasquad_mcu_w(unsigned int offset, unsigned int data)
{
 from_main = data;
 main_sent = 1;
 cpu_set_irq_line(2,0,1);
}


decompiled_code:
__int64 lsasquad_mcu_status_r()
{
unsigned int v0; // eax

v0 = input_port_3_r(0LL);
if ( !main_sent )
v0 |= 1u;
if ( !mcu_sent )
v0 |= 2u;
return lsasquad_invertcoin ^ v0;
}

canonical_decompiled_code:
__int64 func21()
{
unsigned int v0; // eax

v0 = input_port_3_r(0LL);
if ( !main_sent )
v0 |= 1u;
if ( !mcu_sent )
v0 |= 2u;
return lsasquad_invertcoin ^ v0;
}

original_code:
data_t lsasquad_mcu_status_r(offs_t offset)
{
 int res = input_port_3_r(0);
 if (!main_sent) res |= 0x01;
 if (!mcu_sent) res |= 0x02;
 return res ^ lsasquad_invertcoin;
}

canonical_original_code:
unsigned int lsasquad_mcu_status_r(unsigned int offset)
{
 int res = input_port_3_r(0);
 if (!main_sent) res |= 0x01;
 if (!mcu_sent) res |= 0x02;
 return res ^ lsasquad_invertcoin;
}

variable_types: res int


decompiled_code:
__int64 __fastcall lsasquad_vh_screenrefresh(__int64 a1)
{
fillbitmap(a1, *(unsigned __int16 *)(*(_QWORD *)(Machine + 792LL) + 1022LL), Machine + 776LL);
draw_layer(a1, lsasquad_scrollram);
draw_layer(a1, lsasquad_scrollram + 128);
draw_sprites(a1);
return draw_layer(a1, lsasquad_scrollram + 256);
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1)
{
fillbitmap(a1, *(unsigned __int16 *)(*(_QWORD *)(Machine + 792LL) + 1022LL), Machine + 776LL);
func23(a1, lsasquad_scrollram);
func23(a1, lsasquad_scrollram + 128);
func22(a1);
return func23(a1, lsasquad_scrollram + 256);
}

original_code:
void lsasquad_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
{
 fillbitmap(bitmap,Machine->pens[511],&Machine->visible_area);
 draw_layer(bitmap,lsasquad_scrollram + 0x000);
 draw_layer(bitmap,lsasquad_scrollram + 0x080);
 draw_sprites(bitmap);
 draw_layer(bitmap,lsasquad_scrollram + 0x100);
}

canonical_original_code:
void lsasquad_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh)
{
 fillbitmap(bitmap,Machine->pens[511],&Machine->visible_area);
 draw_layer(bitmap,lsasquad_scrollram + 0x000);
 draw_layer(bitmap,lsasquad_scrollram + 0x080);
 draw_sprites(bitmap);
 draw_layer(bitmap,lsasquad_scrollram + 0x100);
}

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


decompiled_code:
__int64 __fastcall lsasquad_bankswitch_w(unsigned int a1, char a2)
{
unsigned int v3; // eax

cpu_bankbase[1] = memory_region(129LL) + (((a2 & 7u) + 8) << 13);
if ( ophw == 1 )
{
ophw = -1;
v3 = cpu_get_pc();
cpu_setOPbase16(v3);
}
return flip_screen_w(a1, a2 & 0x10);
}

canonical_decompiled_code:
__int64 __fastcall func25(unsigned int a1, char a2)
{
unsigned int v3; // eax

cpu_bankbase[1] = memory_region(129LL) + (((a2 & 7u) + 8) << 13);
if ( ophw == 1 )
{
ophw = -1;
v3 = cpu_get_pc();
cpu_setOPbase16(v3);
}
return flip_screen_w(a1, a2 & 0x10);
}

original_code:
void lsasquad_bankswitch_w(offs_t offset,data_t data)
{
 unsigned char *ROM = memory_region(REGION_CPU1);
 { if (1 >= 1 && 1 <= 16) { cpu_bankbase[1] = (UINT8 *)(&ROM[0x10000 + 0x2000 * (data & 7)]); if (ophw == 1) { ophw = 0xff; cpu_setOPbase16(cpu_get_pc()); } } };
 flip_screen_w(offset,data & 0x10);
}

canonical_original_code:
void lsasquad_bankswitch_w(unsigned int offset, unsigned int data)
{
 unsigned char *ROM = memory_region(REGION_CPU1);
 { if (1 >= 1 && 1 <= 16) { cpu_bankbase[1] = (unsigned char *)(&ROM[0x10000 + 0x2000 * (data & 7)]); if (ophw == 1) { ophw = 0xff; cpu_setOPbase16(cpu_get_pc()); } } };
 flip_screen_w(offset,data & 0x10);
}

variable_types:
offset
unsigned int

variable_types:
ROM
unsigned char *


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

if ( sound_nmi_enable )
return cpu_cause_interrupt(1LL, 4294967294LL);
pending_nmi = 1;
return result;
}

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

if ( sound_nmi_enable )
return cpu_cause_interrupt(1LL, 4294967294LL);
pending_nmi = 1;
return result;
}

original_code:
static void nmi_callback(int param)
{
 if (sound_nmi_enable) cpu_cause_interrupt(1,-2);
 else pending_nmi = 1;
}

variable_types: param int


irqhandler

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

canonical_decompiled_code:
__int64 __fastcall func20(int a1)
{
return cpu_set_irq_line(1LL, 0LL, a1 != 0);
}

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

variable_types: irq int