/*
 This file generated from ../gtk/pixmaps.c with xstatusbar.pl
*/

#define __ 0x0,
#define AA 0x0520,
#define AB 0x0520,
#define AC 0x0340,
#define AD 0x0340,
#define AE 0x06e0,
#define AF 0x07c0,

#define PIXMAP_DISK_ACTIVE_OFF 99
#define PIXMAP_DISK_ACTIVE_W 15
#define PIXMAP_DISK_ACTIVE_H 20
static libspectrum_word pixmap_disk_active[] = {
   AA AA AB AA AB AB AB AB AB AA AA AB AB AB AB
   AB AB AB AB AB AA AB AC AA AB AA AB AA AB AA
   AB AB AB AA AB AA AA AC AA AA AB AA AB AA AB
   AB AB AA AB AB AB AB AC AB AA AB AB AA AA AB
   AA AA AA AB AB AA AA AD AB AB AB AA AA AB AA
   AB AB AA AB AB AB AA AC AB AB AA AB AA AB AA
   AB AA AB AB AA AB AA AD AA AB AB AB AA AB AB
   AB AA AA AA AA AA AA AB AA AA AA AA AB AB AB
   AB AA AB AB AA AA AB AA AA AB AA AB AB AB AB
   AA AB AB AA AB AB AE AF AE AB AA AB AA AB AA
   AA AB AA AB AB AA AF AF AF AB AA AA AB AB AA
   AA AA AB AA AA AA AE AF AE AA AA AB AB AB AA
   AB AA AA AB AA AA AB AB AB AB AB AB AB AA AA
   AB AB AA AA AB AA AA AA AB AB AA AB AA AA AA
   AB AB AB AA AB AB AA AB AB AA AA AA AA AA AA
   AA AA AC AD AC AC AD AD AD AC AD AC AD AB AB
   AB AB AC AD AC AC AC AC AC AC AD AD AC AA AA
   AB AA AC AD AC AD AC AC AC AD AD AC AC AA AB
   AB AB AC AC AC AC AC AC AC AD AC AC AD AA AA
   AA AA AD AD AC AD AC AC AC AC AD AC AD AA AB
};

#undef __
#undef AA
#undef AB
#undef AC
#undef AD
#undef AE
#undef AF

#define __ 0x0,
#define AA 0xa534,
#define AB 0xa534,
#define AC 0x6b4d,
#define AD 0x6b4d,
#define AE 0xdefb,
#define AF 0xffdf,

#define PIXMAP_DISK_INACTIVE_OFF 84
#define PIXMAP_DISK_INACTIVE_W 15
#define PIXMAP_DISK_INACTIVE_H 20
static libspectrum_word pixmap_disk_inactive[] = {
   AA AA AB AA AB AB AB AB AB AA AA AB AB AB AB
   AB AB AB AB AB AA AB AC AA AB AA AB AA AB AA
   AB AB AB AA AB AA AA AC AA AA AB AA AB AA AB
   AB AB AA AB AB AB AB AC AB AA AB AB AA AA AB
   AA AA AA AB AB AA AA AD AB AB AB AA AA AB AA
   AB AB AA AB AB AB AA AC AB AB AA AB AA AB AA
   AB AA AB AB AA AB AA AD AA AB AB AB AA AB AB
   AB AA AA AA AA AA AA AB AA AA AA AA AB AB AB
   AB AA AB AB AA AA AB AA AA AB AA AB AB AB AB
   AA AB AB AA AB AB AE AF AE AB AA AB AA AB AA
   AA AB AA AB AB AA AF AF AF AB AA AA AB AB AA
   AA AA AB AA AA AA AE AF AE AA AA AB AB AB AA
   AB AA AA AB AA AA AB AB AB AB AB AB AB AA AA
   AB AB AA AA AB AA AA AA AB AB AA AB AA AA AA
   AB AB AB AA AB AB AA AB AB AA AA AA AA AA AA
   AA AA AC AD AC AC AD AD AD AC AD AC AD AB AB
   AB AB AC AD AC AC AC AC AC AC AD AD AC AA AA
   AB AA AC AD AC AD AC AC AC AD AD AC AC AA AB
   AB AB AC AC AC AC AC AC AC AD AC AC AD AA AA
   AA AA AD AD AC AD AC AC AC AC AD AC AD AA AB
};

#undef __
#undef AA
#undef AB
#undef AC
#undef AD
#undef AE
#undef AF

#define __ 0x0,
#define AA 0x0000,
#define AB 0x6b4d,
#define AC 0x0440,
#define AD 0x0560,
#define AE 0x06c0,

#define PIXMAP_MDR_ACTIVE_OFF 69
#define PIXMAP_MDR_ACTIVE_W 15
#define PIXMAP_MDR_ACTIVE_H 20
static libspectrum_word pixmap_mdr_active[] = {
   AD AD AB AE AE AE AE AE AE AE AE AD AD AD AD
   AD AD AD AB AB AB AA AA AB AB AB AD AD AD AD
   AB AD AD AB AB AB AB AB AB AB AB AD AD AD AD
   AE AB AD AD AB AB AB AB AB AB AB AD AD AD AD
   AE AB AD AD AD AD AD AD AD AD AD AD AD AD AD
   AE AB AC AD AD AC AC AC AC AC AD AD AC AC AD
   AE AB AD AD AD AD AD AD AD AD AD AD AD AD AC
   AB AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AD AC AC AC AD AD AD AD AD AD AD AC AC AC AD
   AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD
   AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD
   AB AB AB AB AB AB AB AB AB AB AB AB AB AB AB
   AB AB AB AB AB AB AB AB AB AB AB AB AB AB AB
   AB AB AB AB AB AB AB AB AB AB AB AB AB AB AB
};

#undef __
#undef AA
#undef AB
#undef AC
#undef AD
#undef AE

#define __ 0x0,
#define AA 0x0000,
#define AB 0x6b4d,
#define AC 0x8c51,
#define AD 0xad75,
#define AE 0xdedb,

#define PIXMAP_MDR_INACTIVE_OFF 54
#define PIXMAP_MDR_INACTIVE_W 15
#define PIXMAP_MDR_INACTIVE_H 20
static libspectrum_word pixmap_mdr_inactive[] = {
   AD AD AB AE AE AE AE AE AE AE AE AD AD AD AD
   AD AD AD AB AB AB AA AA AB AB AB AD AD AD AD
   AB AD AD AB AB AB AB AB AB AB AB AD AD AD AD
   AE AB AD AD AB AB AB AB AB AB AB AD AD AD AD
   AE AB AD AD AD AD AD AD AD AD AD AD AD AD AD
   AE AB AC AD AD AC AC AC AC AC AD AD AC AC AD
   AE AB AD AD AD AD AD AD AD AD AD AD AD AD AC
   AB AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AC AD AD AD AD AD AD AD AD AD AD AD AD AD AC
   AD AC AC AC AD AD AD AD AD AD AD AC AC AC AD
   AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD
   AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD
   AB AB AB AB AB AB AB AB AB AB AB AB AB AB AB
   AB AB AB AB AB AB AB AB AB AB AB AB AB AB AB
   AB AB AB AB AB AB AB AB AB AB AB AB AB AB AB
};

#undef __
#undef AA
#undef AB
#undef AC
#undef AD
#undef AE

#define __ 0x0,
#define AA 0x06a0,
#define AB 0x03e0,
#define AC 0x0520,
#define AD 0x03e0,
#define AE 0x04a0,
#define AF 0x06e0,
#define AG 0x07c0,
#define AH 0x0300,
#define AI 0x07c0,
#define AJ 0x0300,
#define AK 0x0300,
#define AL 0x0340,

#define PIXMAP_TAPE_ACTIVE_OFF 27
#define PIXMAP_TAPE_ACTIVE_W 27
#define PIXMAP_TAPE_ACTIVE_H 17
static libspectrum_word pixmap_tape_active[] = {
   AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
   AA AB AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AB AA
   AA AA AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AA AA
   AA AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AA
   AA AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AA
   AA AC AC AC AC AC AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AC AC AC AC AC AA
   AA AC AC AC AC AE AD AF AG AF AC AH AH AH AH AH AC AF AG AF AD AE AC AC AC AC AA
   AA AC AC AC AC AD AC AG AG AI AC AJ AH AH AH AH AC AG AG AI AC AD AC AC AC AC AA
   AA AC AC AC AC AE AD AF AI AF AC AH AK AH AH AH AC AF AI AF AD AE AC AC AC AC AA
   AA AC AC AC AC AC AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AC AC AC AC AC AA
   AA AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AA
   AA AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AA
   AA AA AA AA AA AL AL AL AL AL AL AL AL AL AL AL AL AL AL AL AL AL AA AA AA AA AA
   AA AA AA AA AE AL AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AL AE AA AA AA AA
   AA AA AA AA AL AE AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AE AL AA AA AA AA
   AA AB AA AA AL AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AL AA AA AB AA
   AA AA AA AA AL AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AL AA AA AA AA
};

#undef __
#undef AA
#undef AB
#undef AC
#undef AD
#undef AE
#undef AF
#undef AG
#undef AH
#undef AI
#undef AJ
#undef AK
#undef AL

#define __ 0x0,
#define AA 0xd6ba,
#define AB 0x7bef,
#define AC 0xa534,
#define AD 0x7bef,
#define AE 0x94b2,
#define AF 0xdefb,
#define AG 0xffdf,
#define AH 0x630c,
#define AI 0xffdf,
#define AJ 0x630c,
#define AK 0x630c,
#define AL 0x6b4d,

#define PIXMAP_TAPE_INACTIVE_OFF 0
#define PIXMAP_TAPE_INACTIVE_W 27
#define PIXMAP_TAPE_INACTIVE_H 17
static libspectrum_word pixmap_tape_inactive[] = {
   AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
   AA AB AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AB AA
   AA AA AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AA AA
   AA AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AA
   AA AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AA
   AA AC AC AC AC AC AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AC AC AC AC AC AA
   AA AC AC AC AC AE AD AF AG AF AC AH AH AH AH AH AC AF AG AF AD AE AC AC AC AC AA
   AA AC AC AC AC AD AC AG AG AI AC AJ AH AH AH AH AC AG AG AI AC AD AC AC AC AC AA
   AA AC AC AC AC AE AD AF AI AF AC AH AK AH AH AH AC AF AI AF AD AE AC AC AC AC AA
   AA AC AC AC AC AC AD AD AD AD AD AD AD AD AD AD AD AD AD AD AD AC AC AC AC AC AA
   AA AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AA
   AA AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AC AA
   AA AA AA AA AA AL AL AL AL AL AL AL AL AL AL AL AL AL AL AL AL AL AA AA AA AA AA
   AA AA AA AA AE AL AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AL AE AA AA AA AA
   AA AA AA AA AL AE AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AE AL AA AA AA AA
   AA AB AA AA AL AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AL AA AA AB AA
   AA AA AA AA AL AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AL AA AA AA AA
};

#undef __
#undef AA
#undef AB
#undef AC
#undef AD
#undef AE
#undef AF
#undef AG
#undef AH
#undef AI
#undef AJ
#undef AK
#undef AL

#define PIXMAPS_W 
#define PIXMAPS_H 20

static ui_statusbar_state pixmap_mdr_state, pixmap_tape_state, pixmap_disk_state;
static int status_updated;
static int icon_size = 0;

static void
xstatusbar_add_pixmap(int x, int pw, int h, libspectrum_word *colors)
{
  int y = 3 * DISPLAY_SCREEN_HEIGHT;
  x *= icon_size;
  for( ; h > 0; h-- ) {
    int w = pw;
    for( ; w > 0; w-- ) {
      int i;
      for( i = icon_size; i > 0; i-- ) {
        xdisplay_putpixel( x, y, colors);
        if( icon_size > 1 )
          xdisplay_putpixel( x, y + 1, colors);
        if( icon_size > 2 )
          xdisplay_putpixel( x, y + 2, colors);
        x++;
      }
      colors++;
    }
    x -= pw * icon_size; y += icon_size;
  }
}
/* put status icons to X(Shm)Image extra area */
void
xstatusbar_init( int size )
{
  if( icon_size == size )
    return;
  icon_size = size;

  xstatusbar_add_pixmap( PIXMAP_TAPE_INACTIVE_OFF, PIXMAP_TAPE_INACTIVE_W, PIXMAP_TAPE_INACTIVE_H, pixmap_tape_inactive);
  xstatusbar_add_pixmap( PIXMAP_TAPE_ACTIVE_OFF, PIXMAP_TAPE_ACTIVE_W, PIXMAP_TAPE_ACTIVE_H, pixmap_tape_active);
  xstatusbar_add_pixmap( PIXMAP_MDR_INACTIVE_OFF, PIXMAP_MDR_INACTIVE_W, PIXMAP_MDR_INACTIVE_H, pixmap_mdr_inactive);
  xstatusbar_add_pixmap( PIXMAP_MDR_ACTIVE_OFF, PIXMAP_MDR_ACTIVE_W, PIXMAP_MDR_ACTIVE_H, pixmap_mdr_active);
  xstatusbar_add_pixmap( PIXMAP_DISK_INACTIVE_OFF, PIXMAP_DISK_INACTIVE_W, PIXMAP_DISK_INACTIVE_H, pixmap_disk_inactive);
  xstatusbar_add_pixmap( PIXMAP_DISK_ACTIVE_OFF, PIXMAP_DISK_ACTIVE_W, PIXMAP_DISK_ACTIVE_H, pixmap_disk_active);
}

static void
xstatusbar_put_icon( int x, int w, int h )
{
  static int dx = 0;
  static int dy = 0;
  w *= icon_size; x *= icon_size; h *= icon_size;
  if( x < 0 || dx == 0 ) {
    dx = ( DISPLAY_ASPECT_WIDTH - 2 ) * xdisplay_current_size;
    dy = ( DISPLAY_SCREEN_HEIGHT - 2 ) * xdisplay_current_size - PIXMAPS_H * icon_size;
    return;
  }
  dx -= w;
  if( shm_used ) {
#ifdef X_USE_SHM
    /* FIXME: should wait for an ShmCompletion event here */
    XShmPutImage( display, xui_mainWindow, gc, image, x, 3 * DISPLAY_SCREEN_HEIGHT, dx, dy, w, h, True );
#endif				/* #ifdef X_USE_SHM */
  } else {
    XPutImage( display, xui_mainWindow, gc, image, x, 3 * DISPLAY_SCREEN_HEIGHT, dx, dy, w, h );
  }
  dx -= 4; /* 4px space */
}

void
xstatusbar_overlay( void )
{
  int x = 0, w = 0, h;
  xstatusbar_put_icon( -1, 0, 0 );


  switch( pixmap_tape_state ) {
  case UI_STATUSBAR_STATE_ACTIVE:
    x = PIXMAP_TAPE_ACTIVE_OFF; w = PIXMAP_TAPE_ACTIVE_W; h = PIXMAP_TAPE_ACTIVE_H;
    break;
  case UI_STATUSBAR_STATE_INACTIVE:
    x = PIXMAP_TAPE_INACTIVE_OFF; w = PIXMAP_TAPE_INACTIVE_W; h = PIXMAP_TAPE_INACTIVE_H;
    break;
  case UI_STATUSBAR_STATE_NOT_AVAILABLE:
    w = 0;
    break;
  }
  if( w ) xstatusbar_put_icon( x, w, h );

  switch( pixmap_mdr_state ) {
  case UI_STATUSBAR_STATE_ACTIVE:
    x = PIXMAP_MDR_ACTIVE_OFF; w = PIXMAP_MDR_ACTIVE_W; h = PIXMAP_MDR_ACTIVE_H;
    break;
  case UI_STATUSBAR_STATE_INACTIVE:
    x = PIXMAP_MDR_INACTIVE_OFF; w = PIXMAP_MDR_INACTIVE_W; h = PIXMAP_MDR_INACTIVE_H;
    break;
  case UI_STATUSBAR_STATE_NOT_AVAILABLE:
    w = 0;
    break;
  }
  if( w ) xstatusbar_put_icon( x, w, h );

  switch( pixmap_disk_state ) {
  case UI_STATUSBAR_STATE_ACTIVE:
    x = PIXMAP_DISK_ACTIVE_OFF; w = PIXMAP_DISK_ACTIVE_W; h = PIXMAP_DISK_ACTIVE_H;
    break;
  case UI_STATUSBAR_STATE_INACTIVE:
    x = PIXMAP_DISK_INACTIVE_OFF; w = PIXMAP_DISK_INACTIVE_W; h = PIXMAP_DISK_INACTIVE_H;
    break;
  case UI_STATUSBAR_STATE_NOT_AVAILABLE:
    w = 0;
    break;
  }
  if( w ) xstatusbar_put_icon( x, w, h );

  status_updated = 0;
}

