gt:                 bank = 0;	/* text bank */
context: /*
   * ported to v0.37b7
   * using automatic conversion tool v0.01
   */
  package vidhrdw;
  
  import static arcadeflex.fucPtr.*;
  import static arcadeflex.libc_v2.*;
  import static mame.common.bitmap_alloc;
  import static mame.common.flip_screen_w;
  import static mame.common.schedule_full_refresh;
  import static mame.common.set_vh_global_attribute;
  import static mame.commonH.REGION_GFX4;
  import static mame.commonH.flip_screen;
  import static old.mame.drawgfx.*;
  import static old.mame.drawgfxH.TRANSPARENCY_NONE;
  import static old.mame.drawgfxH.TRANSPARENCY_PEN;
  import static mame.mame.Machine;
  import static mame.osdependH.osd_bitmap;
  import static old.arcadeflex.osdepend.logerror;
  import static old.arcadeflex.video.osd_free_bitmap;
  import static old.mame.common.memory_region;
  import old.mame.drawgfxH.rectangle;
  import static old.mame.inptport.readinputport;
  import static old.mame.palette.palette_init_used_colors;
  import static old.mame.palette.palette_recalc;
  import static old.mame.palette.palette_transparent_pen;
  import static old.mame.palette.palette_used_colors;
  import static old.mame.paletteH.PALETTE_COLOR_TRANSPARENT;
  import static old.mame.paletteH.PALETTE_COLOR_USED;
  import static old.vidhrdw.generic.*;
  import static arcadeflex.libc.memset.*;
  import static mame.commonH.REGION_CPU1;
  import static mame.tilemapC.*;
  import static mame.tilemapH.*;
  import static mame.sndintrf.*;
  import static old.mame.cpuintrf.*;
  import static old.mame.inptport.*;
  import static mame.memoryH.*;
  import old.mame.drawgfxH.GfxElement;
  import static vidhrdw.konamiic.*;
  import static arcadeflex.libc.memcpy.*;
  
  public class combatsc {
  
      static struct_tilemap[] tilemap = new struct_tilemap[2];
      static struct_tilemap textlayer;
      static UBytePtr[] private_spriteram = new UBytePtr[2];
      static int priority;
  
      static UBytePtr combasc_io_ram;
      static int combasc_vreg;
      public static UBytePtr banked_area = new UBytePtr();
  
      static int combasc_bank_select;
      /* 0x00..0x1f */
      static int combasc_video_circuit;
      /* 0 or 1 */
      static UBytePtr combasc_page[] = new UBytePtr[2];
      static /*unsigned*/ char[] combasc_scrollram0 = new char[0x40];
      static /*unsigned*/ char[] combasc_scrollram1 = new char[0x40];
      static UBytePtr combasc_scrollram = new UBytePtr();
  
      public static VhConvertColorPromPtr combasc_convert_color_prom = new VhConvertColorPromPtr() {
          public void handler(char[] palette, char[] colortable, UBytePtr color_prom) {
              int i, pal, clut = 0;
              int c_ptr = 0;
              for (pal = 0; pal < 8; pal++) {
                  switch (pal) {
                      case 0:
                      /* other sprites */
                      case 2:
                          /* other sprites(alt) */
                          clut = 1;
                          /* 0 is wrong for Firing Range III targets */
                          break;
  
                      case 4:
                      /* player sprites */
                      case 6:
                          /* player sprites(alt) */
                          clut = 2;
                          break;
  
                      case 1:
                      /* background */
                      case 3:
                          /* background(alt) */
                          clut = 1;
                          break;
  
                      case 5:
                      /* foreground tiles */
                      case 7:
                          /* foreground tiles(alt) */
                          clut = 3;
                          break;
                  }
                  
                  for (i = 0; i < 256; i++) {
                      if ((pal & 1) == 0) /* sprites */ {
                          if (color_prom.read(256 * clut + i) == 0) {
                              colortable[c_ptr++] = 0;
                          } else {
                              colortable[c_ptr++] = (char) (16 * pal + color_prom.read(256 * clut + i));
                          }
                      } else /* chars */ {
                          colortable[c_ptr++] = (char) (16 * pal + color_prom.read(256 * clut + i));
                      }
                  }
              }
          }
      };
      public static VhConvertColorPromPtr combascb_convert_color_prom = new VhConvertColorPromPtr() {
          public void handler(char[] palette, char[] colortable, UBytePtr color_prom) {
              int i, pal;
              int c_ptr = 0;
              for (pal = 0; pal < 8; pal++) {
                  for (i = 0; i < 256; i++) {
                      if ((pal & 1) == 0) /* sprites */ {
                          colortable[c_ptr++] = (char) (16 * pal + (color_prom.read(i) ^ 0x0f));
                      } else /* chars */ {
                          colortable[c_ptr++] = (char) (16 * pal + (i & 0x0f));	/* no lookup? */
                      }
                  }
              }
          }
      };
  
      /**
       * *************************************************************************
       *
       * Callbacks for the TileMap code
       *
       **************************************************************************
       */
      public static GetTileInfoPtr get_tile_info0 = new GetTileInfoPtr() {
          public void handler(int tile_index) {
              /*unsigned*/ char attributes = combasc_page[0].read(tile_index);
              int bank = 4 * ((combasc_vreg & 0x0f) - 1);
              int number, color;
  
              if (bank < 0) {
                  bank = 0;
              }
              if ((attributes & 0xb0) == 0) {
                  bank = 0;	/* text bank */
              }
  
              if ((attributes & 0x80) != 0) {
                  bank += 1;
              }
              if ((attributes & 0x10) != 0) {
                  bank += 2;
              }
              if ((attributes & 0x20) != 0) {
                  bank += 4;
              }
  
              color = ((K007121_ctrlram[0][6] & 0x10) * 2 + 16) + (attributes & 0x0f);
  
              number = combasc_page[0].read(tile_index + 0x400) + 256 * bank;
  
              SET_TILE_INFO(0, number, color);
              tile_info.u32_priority = (attributes & 0x40) >> 6;
          }
      };
  
      public static GetTileInfoPtr get_tile_info1 = new GetTileInfoPtr() {
          public void handler(int tile_index) {
              /*unsigned*/ char attributes = combasc_page[1].read(tile_index);
              int bank = 4 * ((combasc_vreg >> 4) - 1);
              int number, color;
  
              if (bank < 0) {
                  bank = 0;
              }
              if ((attributes & 0xb0) == 0) {
                  bank = 0;	/* text bank */
              }
  
              if ((attributes & 0x80) != 0) {
                  bank += 1;
              }
              if ((attributes & 0x10) != 0) {
                  bank += 2;
              }
              if ((attributes & 0x20) != 0) {
                  bank += 4;
              }
  
              color = ((K007121_ctrlram[1][6] & 0x10) * 2 + 16 + 4 * 16) + (attributes & 0x0f);
  
              number = combasc_page[1].read(tile_index + 0x400) + 256 * bank;
  
              SET_TILE_INFO(1, number, color);
              tile_info.u32_priority = (attributes & 0x40) >> 6;
          }
      };
  
      public static GetTileInfoPtr get_text_info = new GetTileInfoPtr() {
          public void handler(int tile_index) {
              /*unsigned*/ char attributes = combasc_page[0].read(tile_index + 0x800);
              int number = combasc_page[0].read(tile_index + 0xc00);
              int color = 16 + (attributes & 0x0f);
  
              SET_TILE_INFO(0, number, color);
  
              /* the following hack is needed because the TileMap system doesn't support TRANSPARENCY_COLOR */
              tile_info.u32_flags = 0;
              if ((attributes & 0x0f) == 0x01 || (attributes & 0x0f) == 0x0e) {
                  tile_info.u32_flags = TILE_IGNORE_TRANSPARENCY;
              }
          }
      };
  
      public static GetTileInfoPtr get_tile_info0_bootleg = new GetTileInfoPtr() {
          public void handler(int tile_index) {
              /*unsigned*/ char attributes = combasc_page[0].read(tile_index);
              int bank = 4 * ((combasc_vreg & 0x0f) - 1);
              int number, pal, color;
  
              if (bank < 0) {
                  bank = 0;
              }
              if ((attributes & 0xb0) == 0) {
                  bank = 0;	/* text bank */
              }
  
              if ((attributes & 0x80) != 0) {
                  bank += 1;
              }
              if ((attributes & 0x10) != 0) {
                  bank += 2;
              }
              if ((attributes & 0x20) != 0) {
                  bank += 4;
              }
  
              pal = (bank == 0 || bank >= 0x1c || (attributes & 0x40) != 0) ? 1 : 3;
              color = pal * 16;// + (attributes & 0x0f);
              number = combasc_page[0].read(tile_index + 0x400) + 256 * bank;
  
              SET_TILE_INFO(0, number, color);
          }
      };
  
      public static GetTileInfoPtr get_tile_info1_bootleg = new GetTileInfoPtr() {
          public void handler(int tile_index) {
              /*unsigned*/ char attributes = combasc_page[1].read(tile_index);
              int bank = 4 * ((combasc_vreg >> 4) - 1);
              int number, pal, color;
  
              if (bank < 0) {
                  bank = 0;
              }
              if ((attributes & 0xb0) == 0) {
  