decompiled_code:
__int64 wiping_sh_start()
{
void *v0; // rax
void *v1; // rbp
unsigned int v2; // er12
__int64 v3; // rax
unsigned __int64 v4; // rcx
__int64 v5; // rdx
_DWORD *v6; // 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_constprop_0();
if ( !v2 )
{
last_channel = (__int64)&flipscreen;
sound_rom = memory_region(146LL);
v3 = memory_region(147LL);
v4 = last_channel;
sound_enable = 1;
v5 = v3;
v6 = &channel_list;
if ( last_channel > (unsigned __int64)&channel_list )
{
do
{
*v6 = 0;
v6 += 8;
*(v6 - 5) = 0;
*(v6 - 6) = 0;
*((_QWORD *)v6 - 2) = v5;
*(v6 - 7) = 0;
}
while ( v4 > (unsigned __int64)v6 );
}
return v2;
}
free(v1);
return 1LL;
}

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

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

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

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


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

variable_types:
offset
unsigned int

return_type: unsigned int


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

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

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

if ( a3 < a5 )
{
v5 = a3;
do
{
v7 = a2;
if ( a2 < a4 )
{
do
{
if ( v7 <= 255 && v5 <= 255 )
result = plot_pixel(
a1,
(unsigned int)v7,
(unsigned int)v5,
*(unsigned __int16 *)(*(_QWORD *)(Machine + 792LL) + 2LL));
++v7;
}
while ( a4 != v7 );
}
++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: struct osd_bitmap { int width; int depth; void *_private; unsigned char **line; } *

variable_types: bx int

variable_types: by int

variable_types: ex int

variable_types: ey int

variable_types: x int

variable_types: y int

return_type: void


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

variable_types:
data
unsigned int


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; // ebp
__int64 v2; // r12
char v3; // dl
char v4; // al
__int64 v5; // r14
unsigned __int8 v6; // cl
int v7; // esi
int v8; // edx
__int64 v9; // rbp
__int64 v10; // rdx
__int64 v11; // rax
int i; // ebp
__int64 v13; // rdx
__int64 v14; // rax
__int64 result; // rax
__int64 v16; // [rsp-28h] [rbp-90h]
int v17; // [rsp+Ah] [rbp-5Eh]
__int16 v18; // [rsp+Eh] [rbp-5Ah]
__m128i v19; // [rsp+10h] [rbp-58h]
__int16 v20; // [rsp+20h] [rbp-48h]

v18 = 0;
v17 = 302056711;
v20 = 3858;
v19 = _mm_load_si128((const __m128i *)&LC0);
v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
while ( !*(_BYTE *)(v2 + dirtybuffer) )
{
--v1;
--v2;
if ( v1 == -1 )
goto LABEL_6;
}
*(_BYTE *)(v2 + dirtybuffer) = 0;
v3 = *(_BYTE *)(videoram + v2--);
v16 = (unsigned int)(16 * (v1 >> 5));
v4 = v1--;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
v3 & 0x3F,
0LL,
0LL,
0LL,
8 * (v4 & 0x1Fu),
v16,
Machine + 776LL,
0LL,
0LL);
}
while ( v1 != -1 );
}
LABEL_6:
v5 = 0LL;
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
do
{
v6 = *(_BYTE *)(nitedrvr_hvc + v5 + 32);
v7 = *(unsigned __int8 *)(nitedrvr_hvc + v5);
v8 = *(unsigned __int8 *)(nitedrvr_hvc + v5++ + 16);
nitedrvr_draw_block(a1, v7, v8, v7 + (v6 >> 4), 16 - (v6 & 0xF) + v8);
}
while ( v5 != 16 );
v9 = 0LL;
nitedrvr_draw_block(a1, 64, 232, 192, 256);
v10 = 7LL;
HIBYTE(v18) = nitedrvr_gear + 48;
while ( 1 )
{
v11 = (unsigned int)(8 * v9++);
drawgfx(a1, *(_QWORD *)(Machine + 512LL), v10, 0LL, 0LL, 0LL, v11, 248LL, Machine + 776LL, 0LL, 0LL);
if ( v9 == 6 )
break;
v10 = (unsigned int)*((char *)&v17 + v9);
}
for ( i = 0; i != 6; ++i )
{
v13 = (unsigned int)v19.m128i_i8[6 * nitedrvr_track + i];
v14 = (unsigned int)(8 * i + 208);
result = drawgfx(a1, *(_QWORD *)(Machine + 512LL), v13, 0LL, 0LL, 0LL, v14, 248LL, Machine + 776LL, 0LL, 0LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
int v1; // ebp
__int64 v2; // r12
char v3; // dl
char v4; // al
__int64 v5; // r14
unsigned __int8 v6; // cl
int v7; // esi
int v8; // edx
__int64 v9; // rbp
__int64 v10; // rdx
__int64 v11; // rax
int i; // ebp
__int64 v13; // rdx
__int64 v14; // rax
__int64 result; // rax
__int64 v16; // [rsp-28h] [rbp-90h]
int v17; // [rsp+Ah] [rbp-5Eh]
__int16 v18; // [rsp+Eh] [rbp-5Ah]
__m128i v19; // [rsp+10h] [rbp-58h]
__int16 v20; // [rsp+20h] [rbp-48h]

v18 = 0;
v17 = 302056711;
v20 = 3858;
v19 = _mm_load_si128((const __m128i *)&LC0);
v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
while ( !*(_BYTE *)(v2 + dirtybuffer) )
{
--v1;
--v2;
if ( v1 == -1 )
goto LABEL_6;
}
*(_BYTE *)(v2 + dirtybuffer) = 0;
v3 = *(_BYTE *)(videoram + v2--);
v16 = (unsigned int)(16 * (v1 >> 5));
v4 = v1--;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
v3 & 0x3F,
0LL,
0LL,
0LL,
8 * (v4 & 0x1Fu),
v16,
Machine + 776LL,
0LL,
0LL);
}
while ( v1 != -1 );
}
LABEL_6:
v5 = 0LL;
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
do
{
v6 = *(_BYTE *)(nitedrvr_hvc + v5 + 32);
v7 = *(unsigned __int8 *)(nitedrvr_hvc + v5);
v8 = *(unsigned __int8 *)(nitedrvr_hvc + v5++ + 16);
func1(a1, v7, v8, v7 + (v6 >> 4), 16 - (v6 & 0xF) + v8);
}
while ( v5 != 16 );
v9 = 0LL;
func1(a1, 64, 232, 192, 256);
v10 = 7LL;
HIBYTE(v18) = nitedrvr_gear + 48;
while ( 1 )
{
v11 = (unsigned int)(8 * v9++);
drawgfx(a1, *(_QWORD *)(Machine + 512LL), v10, 0LL, 0LL, 0LL, v11, 248LL, Machine + 776LL, 0LL, 0LL);
if ( v9 == 6 )
break;
v10 = (unsigned int)*((char *)&v17 + v9);
}
for ( i = 0; i != 6; ++i )
{
v13 = (unsigned int)v19.m128i_i8[6 * nitedrvr_track + i];
v14 = (unsigned int)(8 * i + 208);
result = drawgfx(a1, *(_QWORD *)(Machine + 512LL), v13, 0LL, 0LL, 0LL, v14, 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: offs int

variable_types: roadway int

variable_types: charcode int

variable_types: sx int

variable_types: sy int

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


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

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;
}
result = (unsigned int)(nitedrvr_steering_buf + v1 / 4);
nitedrvr_steering_buf = result;
if ( (int)result <= 0 )
{
if ( (_DWORD)result )
{
nitedrvr_steering_val = 128;
nitedrvr_steering_buf = result + 1;
result = 128LL;
}
else
{
nitedrvr_steering_val = 0;
}
}
else
{
nitedrvr_steering_val = 192;
nitedrvr_steering_buf = result - 1;
result = 192LL;
}
return result;
}

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

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;
}
result = (unsigned int)(nitedrvr_steering_buf + v1 / 4);
nitedrvr_steering_buf = result;
if ( (int)result <= 0 )
{
if ( (_DWORD)result )
{
nitedrvr_steering_val = 128;
nitedrvr_steering_buf = result + 1;
result = 128LL;
}
else
{
nitedrvr_steering_val = 0;
}
}
else
{
nitedrvr_steering_val = 192;
nitedrvr_steering_buf = result - 1;
result = 192LL;
}
return result;
}

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

return_type: int


decompiled_code:
__int64 __fastcall nitedrvr_in0_r(char a1)
{
int v1; // ebx
char v2; // al
__int64 result; // rax
int v4; // ebx

v1 = a1 & 3;
v2 = input_port_2_r(0LL);
if ( (v2 & 0x10) != 0 )
{
nitedrvr_gear = 1;
if ( v1 != 2 )
goto LABEL_3;
return 224LL;
}
if ( (v2 & 0x20) != 0 )
{
nitedrvr_gear = 2;
if ( v1 == 2 )
return 208LL;
LABEL_3:
if ( v1 != 3 )
{
if ( v1 != 1 )
return input_port_0_r(0LL);
return input_port_1_r(0LL);
}
LABEL_16:
v4 = input_port_3_r(0LL);
return v4 | (unsigned int)nitedrvr_steering();
}
if ( (v2 & 0x40) != 0 )
{
nitedrvr_gear = 3;
if ( v1 == 2 )
return 176LL;
goto LABEL_3;
}
if ( v2 < 0 )
{
nitedrvr_gear = 4;
if ( v1 == 2 )
return 112LL;
LABEL_13:
if ( v1 != 3 )
{
if ( v1 != 1 )
return input_port_0_r(0LL);
return input_port_1_r(0LL);
}
goto LABEL_16;
}
if ( v1 != 2 )
goto LABEL_13;
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)
{
int v1; // ebx
char v2; // al
__int64 result; // rax
int v4; // ebx

v1 = a1 & 3;
v2 = input_port_2_r(0LL);
if ( (v2 & 0x10) != 0 )
{
nitedrvr_gear = 1;
if ( v1 != 2 )
goto LABEL_3;
return 224LL;
}
if ( (v2 & 0x20) != 0 )
{
nitedrvr_gear = 2;
if ( v1 == 2 )
return 208LL;
LABEL_3:
if ( v1 != 3 )
{
if ( v1 != 1 )
return input_port_0_r(0LL);
return input_port_1_r(0LL);
}
LABEL_16:
v4 = input_port_3_r(0LL);
return v4 | (unsigned int)func9();
}
if ( (v2 & 0x40) != 0 )
{
nitedrvr_gear = 3;
if ( v1 == 2 )
return 176LL;
goto LABEL_3;
}
if ( v2 < 0 )
{
nitedrvr_gear = 4;
if ( v1 == 2 )
return 112LL;
LABEL_13:
if ( v1 != 3 )
{
if ( v1 != 1 )
return input_port_0_r(0LL);
return input_port_1_r(0LL);
}
goto LABEL_16;
}
if ( v1 != 2 )
goto LABEL_13;
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: 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;
LABEL_3:
switch ( a1 & 7 )
{
case 0:
goto LABEL_15;
case 1:
goto LABEL_10;
case 2:
goto LABEL_11;
case 3:
goto LABEL_12;
case 4:
case 7:
goto LABEL_9;
case 5:
goto LABEL_13;
case 6:
goto LABEL_14;
}
}
if ( (v1 & 0x20) != 0 )
{
nitedrvr_track = 1;
}
else if ( (v1 & 0x40) != 0 )
{
nitedrvr_track = 2;
goto LABEL_3;
}
switch ( a1 & 7 )
{
case 0:
LABEL_15:
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_13:
result = (unsigned __int8)(nitedrvr_track == 0) << 7;
break;
case 6:
LABEL_14:
result = (unsigned __int8)(ac_line_0 == 0) << 7;
break;
case 7:
LABEL_9:
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;
LABEL_3:
switch ( a1 & 7 )
{
case 0:
goto LABEL_15;
case 1:
goto LABEL_10;
case 2:
goto LABEL_11;
case 3:
goto LABEL_12;
case 4:
case 7:
goto LABEL_9;
case 5:
goto LABEL_13;
case 6:
goto LABEL_14;
}
}
if ( (v1 & 0x20) != 0 )
{
nitedrvr_track = 1;
}
else if ( (v1 & 0x40) != 0 )
{
nitedrvr_track = 2;
goto LABEL_3;
}
switch ( a1 & 7 )
{
case 0:
LABEL_15:
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_13:
result = (unsigned __int8)(nitedrvr_track == 0) << 7;
break;
case 6:
LABEL_14:
result = (unsigned __int8)(ac_line_0 == 0) << 7;
break;
case 7:
LABEL_9:
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:
offset
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_C24 = 0;
}
else if ( a1 > 2 )
{
if ( a1 == 3 )
dword_C24 = 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_C24 = 0;
}
else if ( a1 > 2 )
{
if ( a1 == 3 )
dword_C24 = 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_C2C = 0;
}
else if ( a1 > 2 )
{
if ( a1 == 3 )
dword_C2C = 1;
}
else
{
result = a1 != 0;
dword_C28 = a1 != 0;
}
return result;
}

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

if ( a1 == 2 )
{
dword_C2C = 0;
}
else if ( a1 > 2 )
{
if ( a1 == 3 )
dword_C2C = 1;
}
else
{
result = a1 != 0;
dword_C28 = 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_C30 = 0;
break;
case 1:
dword_C30 = 1;
break;
case 2:
dword_C34 = 0;
break;
case 3:
dword_C34 = 1;
break;
case 4:
dword_C38 = 0;
break;
case 5:
dword_C38 = 1;
break;
case 6:
dword_C3C = 0;
break;
case 7:
dword_C3C = 1;
break;
default:
return;
}
}

canonical_decompiled_code:
void __fastcall func3(int a1)
{
switch ( a1 )
{
case 0:
dword_C30 = 0;
break;
case 1:
dword_C30 = 1;
break;
case 2:
dword_C34 = 0;
break;
case 3:
dword_C34 = 1;
break;
case 4:
dword_C38 = 0;
break;
case 5:
dword_C38 = 1;
break;
case 6:
dword_C3C = 0;
break;
case 7:
dword_C3C = 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; // r13
unsigned __int8 v3; // dl
char v4; // al
__int64 v5; // rbx
__int64 i; // rdx
__int64 v7; // rcx
__int64 v8; // rax
__int64 j; // r14
unsigned int v10; // er11
__int64 v11; // rsi
__int64 v12; // rcx
int v13; // er9
__int64 v14; // rdx
__int64 result; // rax
__int64 v16; // [rsp-28h] [rbp-60h]

v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
while ( !*(_BYTE *)(v2 + dirtybuffer) )
{
--v1;
--v2;
if ( v1 == -1 )
goto LABEL_6;
}
*(_BYTE *)(v2 + dirtybuffer) = 0;
v3 = *(_BYTE *)(videoram + v2--);
v16 = (unsigned int)(8 * (v1 >> 5));
v4 = v1--;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
v3 & 0x3F,
v3 >> 6,
0LL,
0LL,
8 * (v4 & 0x1Fu),
v16,
Machine + 776LL,
0LL,
0LL);
}
while ( v1 != -1 );
}
LABEL_6:
v5 = 0LL;
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
for ( i = 83LL; ; i = (unsigned int)LC0[v5] )
{
v7 = (unsigned int)(skydiver_lamps[v5] + 4);
v8 = (unsigned int)(8 * v5++);
drawgfx(a1, *(_QWORD *)(Machine + 512LL), i, v7, 0LL, 0LL, v8, 224LL, Machine + 776LL, 0LL, 0LL);
if ( v5 == 8 )
break;
}
for ( j = 3LL; j != -1; --j )
{
v10 = j & 1;
v11 = 232 - (unsigned int)*(unsigned __int8 *)(spriteram + j);
v12 = 240 - (unsigned int)*(unsigned __int8 *)(spriteram + 2 * j + 8);
v13 = *(unsigned __int8 *)(spriteram + 2 * j + 9);
v14 = (v13 >> 2) & 0x18 | *(_BYTE *)(spriteram + 2 * j + 9) & 7u;
result = drawgfx(
a1,
*(_QWORD *)(Machine + 8LL * ((int)v14 > 15) + 520),
v14,
v10,
(v13 >> 4) & 1,
(v13 >> 3) & 1,
v11,
v12,
Machine + 776LL,
2LL,
0LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
int v1; // ebx
__int64 v2; // r13
unsigned __int8 v3; // dl
char v4; // al
__int64 v5; // rbx
__int64 i; // rdx
__int64 v7; // rcx
__int64 v8; // rax
__int64 j; // r14
unsigned int v10; // er11
__int64 v11; // rsi
__int64 v12; // rcx
int v13; // er9
__int64 v14; // rdx
__int64 result; // rax
__int64 v16; // [rsp-28h] [rbp-60h]

v1 = videoram_size - 1;
if ( videoram_size - 1 >= 0 )
{
v2 = v1;
do
{
while ( !*(_BYTE *)(v2 + dirtybuffer) )
{
--v1;
--v2;
if ( v1 == -1 )
goto LABEL_6;
}
*(_BYTE *)(v2 + dirtybuffer) = 0;
v3 = *(_BYTE *)(videoram + v2--);
v16 = (unsigned int)(8 * (v1 >> 5));
v4 = v1--;
drawgfx(
tmpbitmap,
*(_QWORD *)(Machine + 512LL),
v3 & 0x3F,
v3 >> 6,
0LL,
0LL,
8 * (v4 & 0x1Fu),
v16,
Machine + 776LL,
0LL,
0LL);
}
while ( v1 != -1 );
}
LABEL_6:
v5 = 0LL;
copybitmap(a1, tmpbitmap, 0LL, 0LL, 0LL, 0LL, Machine + 776LL, 0LL, 0LL);
for ( i = 83LL; ; i = (unsigned int)LC0[v5] )
{
v7 = (unsigned int)(skydiver_lamps[v5] + 4);
v8 = (unsigned int)(8 * v5++);
drawgfx(a1, *(_QWORD *)(Machine + 512LL), i, v7, 0LL, 0LL, v8, 224LL, Machine + 776LL, 0LL, 0LL);
if ( v5 == 8 )
break;
}
for ( j = 3LL; j != -1; --j )
{
v10 = j & 1;
v11 = 232 - (unsigned int)*(unsigned __int8 *)(spriteram + j);
v12 = 240 - (unsigned int)*(unsigned __int8 *)(spriteram + 2 * j + 8);
v13 = *(unsigned __int8 *)(spriteram + 2 * j + 9);
v14 = (v13 >> 2) & 0x18 | *(_BYTE *)(spriteram + 2 * j + 9) & 7u;
result = drawgfx(
a1,
*(_QWORD *)(Machine + 8LL * ((int)v14 > 15) + 520),
v14,
v10,
(v13 >> 4) & 1,
(v13 >> 3) & 1,
v11,
v12,
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: struct osd_bitmap { int width; int depth; void *_private; unsigned char **line; } *

variable_types: pic int

variable_types: color 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

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

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

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

variable_types:
data
unsigned int


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;
result = (unsigned int)pending_nmi;
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;
result = (unsigned int)pending_nmi;
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

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

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

result = (unsigned __int8)ddrB;
if ( (ddrB & 2) != 0 && (a2 & 2) == 0 && (portB_out & 2) != 0 )
{
portA_in = from_main;
if ( main_sent )
{
cpu_set_irq_line(2LL, 0LL, 0LL);
result = (unsigned __int8)ddrB;
}
main_sent = 0;
}
if ( (result & 4) != 0 && (a2 & 4) != 0 && (portB_out & 4) == 0 )
{
result = (unsigned __int8)portA_out;
mcu_sent = 1;
from_mcu = portA_out;
}
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);
}


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:
ROM
unsigned char *


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

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

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

result = (unsigned int)sound_nmi_enable;
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


decompiled_code:
__int64 __fastcall draw_sprites(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbp
__int64 v3; // r14
__int16 v4; // bx
__int64 v5; // r12
__int64 v6; // r8
__int64 v7; // rdx
unsigned int v8; // ebx
unsigned __int8 v9; // cl
unsigned int v10; // [rsp+0h] [rbp-48h]
unsigned int v11; // [rsp+4h] [rbp-44h]
unsigned int v12; // [rsp+8h] [rbp-40h]
int v13; // [rsp+Ch] [rbp-3Ch]

result = (unsigned int)(lsasquad_spriteram_size - 4);
v13 = lsasquad_spriteram_size - 4;
if ( lsasquad_spriteram_size - 4 >= 0 )
{
v2 = (int)result + 3LL;
do
{
v4 = *(unsigned __int8 *)(lsasquad_spriteram + v2 - 2);
v5 = *(unsigned __int8 *)(lsasquad_spriteram + v2);
v3 = *(unsigned __int8 *)(lsasquad_spriteram + v2 - 3);
v6 = *(_BYTE *)(lsasquad_spriteram + v2 - 2) & 0x40;
v7 = *(unsigned __int8 *)(lsasquad_spriteram + v2 - 1) + ((16 * v4) & 0x300u);
v8 = v4 & 0x80;
v9 = *(_BYTE *)(lsasquad_spriteram + v2 - 2) & 0xF;
if ( flip_screen_x )
{
v5 = (unsigned int)(240 - v5);
v6 = (_DWORD)v6 == 0;
v8 = v8 == 0;
}
else
{
v3 = (unsigned int)(240 - v3);
}
v2 -= 4LL;
v12 = v6;
v11 = v9;
v10 = v7;
drawgfx(a1, *(_QWORD *)(Machine + 520LL), v7, v9, v6, v8, v5, v3, Machine + 776LL, 2LL, 0LL);
result = drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
v10,
v11,
v12,
v8,
(unsigned int)(v5 - 256),
v3,
Machine + 776LL,
2LL,
0LL);
v13 -= 4;
}
while ( v13 >= 0 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbp
__int64 v3; // r14
__int16 v4; // bx
__int64 v5; // r12
__int64 v6; // r8
__int64 v7; // rdx
unsigned int v8; // ebx
unsigned __int8 v9; // cl
unsigned int v10; // [rsp+0h] [rbp-48h]
unsigned int v11; // [rsp+4h] [rbp-44h]
unsigned int v12; // [rsp+8h] [rbp-40h]
int v13; // [rsp+Ch] [rbp-3Ch]

result = (unsigned int)(lsasquad_spriteram_size - 4);
v13 = lsasquad_spriteram_size - 4;
if ( lsasquad_spriteram_size - 4 >= 0 )
{
v2 = (int)result + 3LL;
do
{
v4 = *(unsigned __int8 *)(lsasquad_spriteram + v2 - 2);
v5 = *(unsigned __int8 *)(lsasquad_spriteram + v2);
v3 = *(unsigned __int8 *)(lsasquad_spriteram + v2 - 3);
v6 = *(_BYTE *)(lsasquad_spriteram + v2 - 2) & 0x40;
v7 = *(unsigned __int8 *)(lsasquad_spriteram + v2 - 1) + ((16 * v4) & 0x300u);
v8 = v4 & 0x80;
v9 = *(_BYTE *)(lsasquad_spriteram + v2 - 2) & 0xF;
if ( flip_screen_x )
{
v5 = (unsigned int)(240 - v5);
v6 = (_DWORD)v6 == 0;
v8 = v8 == 0;
}
else
{
v3 = (unsigned int)(240 - v3);
}
v2 -= 4LL;
v12 = v6;
v11 = v9;
v10 = v7;
drawgfx(a1, *(_QWORD *)(Machine + 520LL), v7, v9, v6, v8, v5, v3, Machine + 776LL, 2LL, 0LL);
result = drawgfx(
a1,
*(_QWORD *)(Machine + 520LL),
v10,
v11,
v12,
v8,
(unsigned int)(v5 - 256),
v3,
Machine + 776LL,
2LL,
0LL);
v13 -= 4;
}
while ( v13 >= 0 );
}
return result;
}

original_code:
static void draw_sprites(struct osd_bitmap *bitmap)
{
 int offs;
 for (offs = lsasquad_spriteram_size-4;offs >= 0;offs -= 4)
 {
  int sx,sy,attr,code,color,flipx,flipy;
  sx = lsasquad_spriteram[offs+3];
  sy = 240 - lsasquad_spriteram[offs];
  attr = lsasquad_spriteram[offs+1];
  code = lsasquad_spriteram[offs+2] + ((attr & 0x30) << 4);
  color = attr & 0x0f;
  flipx = attr & 0x40;
  flipy = attr & 0x80;
  if (flip_screen_x)
  {
   sx = 240 - sx;
   sy = 240 - sy;
   flipx = !flipx;
   flipy = !flipy;
  }
  drawgfx(bitmap,Machine->gfx[1],
    code,
    color,
    flipx,flipy,
    sx,sy,
    &Machine->visible_area,TRANSPARENCY_PEN,0);
  drawgfx(bitmap,Machine->gfx[1],
    code,
    color,
    flipx,flipy,
    sx-256,sy,
    &Machine->visible_area,TRANSPARENCY_PEN,0);
 }
}

canonical_original_code:
static void draw_sprites(struct osd_bitmap *bitmap)
{
 int offs;
 for (offs = lsasquad_spriteram_size-4;offs >= 0;offs -= 4)
 {
  int sx; int sy; int attr; int code; int color; int flipx; int flipy;
  sx = lsasquad_spriteram[offs+3];
  sy = 240 - lsasquad_spriteram[offs];
  attr = lsasquad_spriteram[offs+1];
  code = lsasquad_spriteram[offs+2] + ((attr & 0x30) << 4);
  color = attr & 0x0f;
  flipx = attr & 0x40;
  flipy = attr & 0x80;
  if (flip_screen_x)
  {
   sx = 240 - sx;
   sy = 240 - sy;
   flipx = !flipx;
   flipy = !flipy;
  }
  drawgfx(bitmap,Machine->gfx[1],
    code,
    color,
    flipx,flipy,
    sx,sy,
    &Machine->visible_area,TRANSPARENCY_PEN,0);
  drawgfx(bitmap,Machine->gfx[1],
    code,
    color,
    flipx,flipy,
    sx-256,sy,
    &Machine->visible_area,TRANSPARENCY_PEN,0);
 }
}

variable_types: offs int

variable_types: sx int

variable_types: sy int

variable_types: attr int

variable_types: code int

variable_types: flipx int

variable_types: flipy int


decompiled_code:
__int64 __fastcall draw_layer(__int64 a1, unsigned __int8 *a2)
{
__int64 v2; // rbp
int v3; // edx
__int64 v4; // r8
__int64 v5; // r14
int v6; // ebx
unsigned __int8 v7; // r13
__int64 result; // rax
unsigned int v9; // [rsp+8h] [rbp-60h]
int v10; // [rsp+Ch] [rbp-5Ch]
__int64 v11; // [rsp+10h] [rbp-58h]
__int64 v12; // [rsp+18h] [rbp-50h]
int v13; // [rsp+28h] [rbp-40h]
int v14; // [rsp+2Ch] [rbp-3Ch]

v13 = a2[3];
v12 = 0LL;
v14 = *a2;
do
{
LODWORD(v2) = v13 + 8 * ((int)v12 >> 2);
v3 = a2[v12 + 1] << 6;
v4 = flip_screen_x;
if ( flip_screen_x )
LOBYTE(v2) = -8 - v2;
v2 = (unsigned __int8)v2;
v5 = v3 + 1;
v6 = v14 + 248;
v11 = v3 + 65;
while ( 1 )
{
v7 = -8 - v6;
if ( (_DWORD)v4 )
v7 = v6;
v10 = (int)*(unsigned __int8 *)(lsasquad_videoram + v5) >> 4;
v9 = *(unsigned __int8 *)(lsasquad_videoram + v5 - 1)
+ ((*(unsigned __int8 *)(lsasquad_videoram + v5) << 8) & 0xF00);
drawgfx(a1, *(_QWORD *)(Machine + 512LL), v9, v10, v4, (unsigned int)v4, v2, v7, Machine + 776LL, 2LL, 0LL);
if ( (int)v2 > 248 )
break;
v6 -= 8;
v5 += 2LL;
if ( v11 == v5 )
goto LABEL_11;
LABEL_6:
v4 = flip_screen_x;
}
v6 -= 8;
v5 += 2LL;
drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
v9,
(unsigned int)v10,
flip_screen_x,
flip_screen_x,
(unsigned int)(v2 - 256),
v7,
Machine + 776LL,
2LL,
0LL);
if ( v11 != v5 )
goto LABEL_6;
LABEL_11:
v12 += 4LL;
result = v12;
}
while ( v12 != 128 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1, unsigned __int8 *a2)
{
__int64 v2; // rbp
int v3; // edx
__int64 v4; // r8
__int64 v5; // r14
int v6; // ebx
unsigned __int8 v7; // r13
__int64 result; // rax
unsigned int v9; // [rsp+8h] [rbp-60h]
int v10; // [rsp+Ch] [rbp-5Ch]
__int64 v11; // [rsp+10h] [rbp-58h]
__int64 v12; // [rsp+18h] [rbp-50h]
int v13; // [rsp+28h] [rbp-40h]
int v14; // [rsp+2Ch] [rbp-3Ch]

v13 = a2[3];
v12 = 0LL;
v14 = *a2;
do
{
LODWORD(v2) = v13 + 8 * ((int)v12 >> 2);
v3 = a2[v12 + 1] << 6;
v4 = flip_screen_x;
if ( flip_screen_x )
LOBYTE(v2) = -8 - v2;
v2 = (unsigned __int8)v2;
v5 = v3 + 1;
v6 = v14 + 248;
v11 = v3 + 65;
while ( 1 )
{
v7 = -8 - v6;
if ( (_DWORD)v4 )
v7 = v6;
v10 = (int)*(unsigned __int8 *)(lsasquad_videoram + v5) >> 4;
v9 = *(unsigned __int8 *)(lsasquad_videoram + v5 - 1)
+ ((*(unsigned __int8 *)(lsasquad_videoram + v5) << 8) & 0xF00);
drawgfx(a1, *(_QWORD *)(Machine + 512LL), v9, v10, v4, (unsigned int)v4, v2, v7, Machine + 776LL, 2LL, 0LL);
if ( (int)v2 > 248 )
break;
v6 -= 8;
v5 += 2LL;
if ( v11 == v5 )
goto LABEL_11;
LABEL_6:
v4 = flip_screen_x;
}
v6 -= 8;
v5 += 2LL;
drawgfx(
a1,
*(_QWORD *)(Machine + 512LL),
v9,
(unsigned int)v10,
flip_screen_x,
flip_screen_x,
(unsigned int)(v2 - 256),
v7,
Machine + 776LL,
2LL,
0LL);
if ( v11 != v5 )
goto LABEL_6;
LABEL_11:
v12 += 4LL;
result = v12;
}
while ( v12 != 128 );
return result;
}

original_code:
static void draw_layer(struct osd_bitmap *bitmap,unsigned char *scrollram)
{
 int offs,scrollx,scrolly;
 scrollx = scrollram[3];
 scrolly = -scrollram[0];
 for (offs = 0;offs < 0x080;offs += 4)
 {
  int base,y,sx,sy,code,color;
  base = 64 * scrollram[offs+1];
  sx = 8*(offs/4) + scrollx;
  if (flip_screen_x) sx = 248 - sx;
  sx &= 0xff;
  for (y = 0;y < 32;y++)
  {
   int attr;
   sy = 8*y + scrolly;
   if (flip_screen_x) sy = 248 - sy;
   sy &= 0xff;
   attr = lsasquad_videoram[base + 2*y + 1];
   code = lsasquad_videoram[base + 2*y] + ((attr & 0x0f) << 8);
   color = attr >> 4;
   drawgfx(bitmap,Machine->gfx[0],
     code,
     color,
     flip_screen_x,flip_screen_x,
     sx,sy,
     &Machine->visible_area,TRANSPARENCY_PEN,0);
   if (sx > 248)
    drawgfx(bitmap,Machine->gfx[0],
      code,
      color,
      flip_screen_x,flip_screen_x,
      sx-256,sy,
      &Machine->visible_area,TRANSPARENCY_PEN,0);
  }
 }
}

canonical_original_code:
static void draw_layer(struct osd_bitmap *bitmap, unsigned char *scrollram)
{
 int offs; int scrollx; int scrolly;
 scrollx = scrollram[3];
 scrolly = -scrollram[0];
 for (offs = 0;offs < 0x080;offs += 4)
 {
  int base; int y; int sx; int sy; int code; int color;
  base = 64 * scrollram[offs+1];
  sx = 8*(offs/4) + scrollx;
  if (flip_screen_x) sx = 248 - sx;
  sx &= 0xff;
  for (y = 0;y < 32;y++)
  {
   int attr;
   sy = 8*y + scrolly;
   if (flip_screen_x) sy = 248 - sy;
   sy &= 0xff;
   attr = lsasquad_videoram[base + 2*y + 1];
   code = lsasquad_videoram[base + 2*y] + ((attr & 0x0f) << 8);
   color = attr >> 4;
   drawgfx(bitmap,Machine->gfx[0],
     code,
     color,
     flip_screen_x,flip_screen_x,
     sx,sy,
     &Machine->visible_area,TRANSPARENCY_PEN,0);
   if (sx > 248)
    drawgfx(bitmap,Machine->gfx[0],
      code,
      color,
      flip_screen_x,flip_screen_x,
      sx-256,sy,
      &Machine->visible_area,TRANSPARENCY_PEN,0);
  }
 }
}

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

variable_types:
scrollram
unsigned char *

variable_types: scrollx int

variable_types: scrolly int

variable_types: base int

variable_types: y int

variable_types: color int