Ejemplo n.º 1
0
void gfx_set_picasso_state (int on)
{
  printf("gfx_set_picasso_state %d\n", on);
  
  if (on == screen_is_picasso)
    return;
    
  viewport_shutdown();
  screen_is_picasso = on;
  if (on) {
    bm_format = pixel_p96_to_glgfx(picasso_vidinfo.rgbformat);
    bm_width  = picasso_vidinfo.width;
    bm_height = picasso_vidinfo.height;
    viewport_setup();
  } else {
    bm_format = glgfx_pixel_format_a4r4g4b4;
    bm_format = glgfx_pixel_format_a8b8g8r8;
    bm_width  = gfxvidinfo.width;
    bm_height = gfxvidinfo.height;
    viewport_setup();
    reset_drawing();
  }

  if (on) {
    DX_SetPalette(0, 256);
  }
}
Ejemplo n.º 2
0
void doflashscreen (void)
{
#if 0
	flashscreen = 10;
	init_colors ();
	picasso_refresh ();
	reset_drawing ();
	flush_screen (gfxvidinfo.outbuffer, 0, 0);
#endif
}
Ejemplo n.º 3
0
MainWindow::MainWindow()
{
    drawingarea = new DrawingArea();
    QPalette p;
    p.setColor(QPalette::Background, Qt::white);
    drawingarea -> setPalette(p);
    drawingarea -> setBackgroundRole(QPalette::Base);
    p.setColor(QPalette::Background, Qt::white);
    drawingarea -> setPalette(p);
    drawingarea -> setAutoFillBackground(true);
    drawingarea -> setMouseTracking(1);
    drawingarea -> setCursor(Qt::CrossCursor);
    drawingarea -> on_mouse = false;
    drawingarea -> setMouseTracking(1);
    drawingarea -> setWindowFlags(Qt::Window);
    drawingarea -> aviable_complete_polygon = false;

    buttonReset = new QPushButton;
    buttonReset ->setText("Reset");
    buttonComplete = new QPushButton;
    buttonComplete ->setText("Complete");
    statusBar = new QLabel("status");
    this ->setUpdatesEnabled(true);

    QGridLayout *mainLayout = new QGridLayout;

    mainLayout->setColumnStretch(0, 1);
    mainLayout->setColumnStretch(3, 1);
    mainLayout->addWidget( drawingarea,  0, 0, 1, 4);
    mainLayout->addWidget(statusBar,     1, 0, 1, 3);
    mainLayout->addWidget(buttonComplete,1, 1, 1, 1);
    mainLayout->addWidget(buttonReset,   1, 2, 1, 1);
    setLayout(mainLayout);
    int width = drawingarea->width();
    s = QString::number(width);
    buttonReset->setEnabled(false);
    buttonComplete->setEnabled(false);
    connect(this -> drawingarea, SIGNAL(releaseMouse()), this, SLOT(grabMouse()),Qt::DirectConnection);
    connect(this -> drawingarea, SIGNAL(have_points(int)), this, SLOT(setPointsnumber(int)),Qt::DirectConnection);
    connect(this->buttonReset, SIGNAL(clicked()), this ->drawingarea, SLOT(reset_drawing()), Qt::DirectConnection );
    connect(this->buttonReset, SIGNAL(clicked()), this, SLOT(reseting()));
    connect(this->buttonComplete, SIGNAL(clicked()), this ->drawingarea, SLOT(complete_drawing()), Qt::DirectConnection);
    connect(this ->drawingarea, SIGNAL(have_been_reseting(QString)),this->statusBar, SLOT(setText(QString)),Qt::AutoConnection);
    connect(this->drawingarea, SIGNAL(send_polygon_size(QString)), this->statusBar, SLOT(setText(QString )),Qt::DirectConnection);
    connect(this->drawingarea,SIGNAL(update_status_finish(QString)),this->statusBar,SLOT(update()),Qt::DirectConnection);
    connect(this->drawingarea,SIGNAL(update_status_finish(QString)),this->statusBar,SLOT(setText(QString)),Qt::DirectConnection);
    connect(this->drawingarea,SIGNAL(update_status(QString)),this->statusBar,SLOT(setText(QString)),Qt::DirectConnection);
    connect(this->drawingarea,SIGNAL(enableCompleteDrawing(bool)),this->buttonComplete,SLOT(setEnabled(bool)),Qt::DirectConnection);
    connect(this->drawingarea, SIGNAL(leaveEvent(QMouseEvent)),this,SLOT(showNormal()),Qt::DirectConnection );
    connect(this,SIGNAL(grabMouse()),this->drawingarea,SLOT(changeOnMouse()),Qt::DirectConnection);
    connect(this->drawingarea, SIGNAL(HoverLeave(QPoint&,QPoint)), this -> drawingarea, SLOT(changeOnMouse()), Qt::DirectConnection);
    connect(this,SIGNAL(enterEvent_()),this->drawingarea, SLOT(changeOnMouse()),Qt::DirectConnection);
    connect(this -> drawingarea, SIGNAL(fail_to_add_peak(QString)), this->statusBar, SLOT(setText(QString)),Qt::DirectConnection);
}
Ejemplo n.º 4
0
void hsyncstuff (void)
	//only generate Interrupts when
	//writebuffer is complete flushed
	//check state of lwin rwin
{
	//static int keycheck = 0;

#if 0 // DISABLED -- OLD AHI VERSION?
#ifdef AHI
	{ //begin ahi_sound
		static int count;
		if (ahi_on) {
			count++;
			//15625/count freebuffer check
			if(count > ahi_pollrate) {
				ahi_updatesound (1);
				count = 0;
			}
		}
	} //end ahi_sound
#endif
#endif

#if 0 // DISABLED FOR NOW
#ifdef PARALLEL_PORT
	keycheck++;
	if(keycheck >= 1000)
	{
		if (prtopen)
			flushprtbuf ();
		{
			if (flashscreen > 0) {
				flashscreen--;
				if (flashscreen == 0) {
					init_colors ();
					reset_drawing ();
					picasso_refresh ();
					flush_screen (gfxvidinfo.outbuffer, 0, 0);
				}
			}
		}
		keycheck = 0;
	}
	if (currprefs.parallel_autoflush_time && !currprefs.parallel_postscript_detection) {
		parflush++;
		if (parflush / ((currprefs.ntscmode ? MAXVPOS_NTSC : MAXVPOS_PAL) * MAXHPOS_PAL / maxhpos) >= currprefs.parallel_autoflush_time * 50) {
			flushprinter ();
			parflush = 0;
		}
	}
#endif
#endif
}
Ejemplo n.º 5
0
/* A key thing here is to populate the struct gfxvidinfo; most of it is done
 * in the subinit functions.
 *
 * We try hardware accelerated graphics via Graphics3D, If Chrome doesn't
 * support it on the given adapter/driver/OS combination, we fall back to
 * Graphics2D, which is generally speaking slower.
 */
int32_t graphics_init(void) {
    /* Set up the common parts of the gfxvidinfo struct here. The subinit
     * functions for 2D and 3D initialize the remaining values appropriately.
     */
    /* TODO(cstefansen): Generalize resolution. For now we force 720x568. */
    gfxvidinfo.width = currprefs.gfx_size_fs.width = 720;
    gfxvidinfo.height = currprefs.gfx_size_fs.height = 568;
    gfxvidinfo.emergmem = 0;
    gfxvidinfo.linemem = 0;
    gfxvidinfo.maxblocklines = MAXBLOCKLINES_MAX;
    gfxvidinfo.lockscr = pepper_lockscr;
    gfxvidinfo.unlockscr = pepper_unlockscr;
    gfxvidinfo.flush_line = pepper_flush_line;
    gfxvidinfo.flush_block = pepper_flush_block;
    gfxvidinfo.flush_clear_screen = pepper_flush_clear_screen;

    /* Try 3D graphics. */
    using_3d = 1;
    if (!graphics_3d_subinit(&Rmask, &Gmask, &Bmask, &Amask)) {
        DEBUG_LOG("Could not initialize hardware accelerated graphics "
                  "(Graphics3D).\n");
        using_3d = 0;
        /* Try 2D graphics. */
        if (!graphics_2d_subinit(&Rmask, &Gmask, &Bmask, &Amask)) {
            DEBUG_LOG("Could not initialize 2D graphics (Graphics2D).\n");
            return 0;
        }
    }

    reset_drawing();
    init_colors();

    DEBUG_LOG("Screen height    : %d\n", gfxvidinfo.height);
    DEBUG_LOG("Screen width     : %d\n", gfxvidinfo.width);
    DEBUG_LOG("Using Graphics3D?: %d\n", using_3d);
    DEBUG_LOG("Bytes per pixel  : %d\n", gfxvidinfo.pixbytes);
    DEBUG_LOG("Bytes per line   : %d\n", gfxvidinfo.rowbytes);
    DEBUG_LOG("Buffer address   : %p\n", gfxvidinfo.bufmem);

    return 1;
}
Ejemplo n.º 6
0
void Screen_SetFullUpdate(void)
{
   reset_drawing();
}
Ejemplo n.º 7
0
static void graphics_subinit (void)
{
    XSetWindowAttributes wattr;
    XClassHint classhint;
    XWMHints *hints;
    unsigned long valuemask;

    dgamode = screen_is_picasso ? currprefs.gfx_pfullscreen : currprefs.gfx_afullscreen;
    dgamode = dgamode && dgaavail;

    wattr.background_pixel = /*black.pixel*/0;
    wattr.backing_store = Always;
    wattr.backing_planes = bitdepth;
    wattr.border_pixmap = None;
    wattr.border_pixel = /*black.pixel*/0;
    wattr.colormap = cmap;
    valuemask = (CWEventMask | CWBackPixel | CWBorderPixel
		 | CWBackingStore | CWBackingPlanes | CWColormap);

    if (dgamode) {
	wattr.event_mask = DGA_EVENTMASK;
	wattr.override_redirect = 1;
	valuemask |= CWOverrideRedirect;
    } else
	wattr.event_mask = EVENTMASK;

    XSync (display, 0);

    delete_win = XInternAtom(display, "WM_DELETE_WINDOW", False);
    mywin = XCreateWindow (display, rootwin, 0, 0, current_width, current_height,
			   0, bitdepth, InputOutput, vis, valuemask, &wattr);
    XSetWMProtocols (display, mywin, &delete_win, 1);
    XSync (display, 0);
    XStoreName (display, mywin, PACKAGE_NAME);
    XSetIconName (display, mywin, PACKAGE_NAME);

    /* set class hint */
    classhint.res_name  = (char *)"UAE";
    classhint.res_class = (char *)"UAEScreen";
    XSetClassHint(display, mywin, &classhint);

    hints = XAllocWMHints();
    /* Set window group leader to self to become an application
     * that can be hidden by e.g. WindowMaker.
     * Would be more useful if we could find out what the
     * (optional) GTK+ window ID is :-/ */
    hints->window_group = mywin;
    hints->flags = WindowGroupHint;
    XSetWMHints(display, mywin, hints);

    XMapRaised (display, mywin);
    XSync (display, 0);
    mygc = XCreateGC (display, mywin, 0, 0);

    if (dgamode) {
#ifdef USE_DGA_EXTENSION
	enter_dga_mode ();
	/*setuid(getuid());*/
	picasso_vidinfo.rowbytes = fb_width * picasso_vidinfo.pixbytes;
#endif
    } else {
	get_image (current_width, current_height, &ami_dinfo);
	if (screen_is_picasso) {
	    get_image (current_width, current_height, &pic_dinfo);
	    picasso_vidinfo.rowbytes = pic_dinfo.ximg->bytes_per_line;
	}
    }

    picasso_vidinfo.extra_mem = 1;

    gfxvidinfo.flush_screen = x11_flush_screen;
    gfxvidinfo.lockscr      = x11_lock;
    gfxvidinfo.unlockscr    = x11_unlock;
    

    if (need_dither) {
	gfxvidinfo.maxblocklines = 0;
	gfxvidinfo.rowbytes = gfxvidinfo.pixbytes * currprefs.gfx_width_win;
	gfxvidinfo.linemem = malloc (gfxvidinfo.rowbytes);
        gfxvidinfo.flush_line  = x11_flush_line_dither;
    } else if (! dgamode) {
	gfxvidinfo.emergmem = 0;
	gfxvidinfo.linemem = 0;
	gfxvidinfo.bufmem = (uae_u8 *)ami_dinfo.image_mem;
	gfxvidinfo.rowbytes = ami_dinfo.ximg->bytes_per_line;
	if (currprefs.x11_use_low_bandwidth) {
	    write_log ("Doing low-bandwidth output.\n");
	    gfxvidinfo.maxblocklines = 0;
	    gfxvidinfo.rowbytes = ami_dinfo.ximg->bytes_per_line;
	    gfxvidinfo.linemem = malloc (gfxvidinfo.rowbytes);

	    if (shmavail && currprefs.x11_use_mitshm) {
		switch (gfxvidinfo.pixbytes) {
		    case 4  : gfxvidinfo.flush_line = x11_flush_line_lbw_32bit_mitshm; break;
		    case 2  : gfxvidinfo.flush_line = x11_flush_line_lbw_16bit_mitshm; break;
		    default : gfxvidinfo.flush_line = x11_flush_line_lbw_8bit_mitshm;  break;
		}
	    } else {
		switch (gfxvidinfo.pixbytes) {
		    case 4  : gfxvidinfo.flush_line = x11_flush_line_lbw_32bit; break;
		    case 2  : gfxvidinfo.flush_line = x11_flush_line_lbw_16bit; break;
		    default : gfxvidinfo.flush_line = x11_flush_line_lbw_8bit;	break;
		}
	    }
	} else {
	    gfxvidinfo.maxblocklines = MAXBLOCKLINES_MAX;

	    if (shmavail && currprefs.x11_use_mitshm)
		gfxvidinfo.flush_block  = x11_flush_block_mitshm;
	    else
		gfxvidinfo.flush_block  = x11_flush_block;
	}
    }

    if (visualInfo.VI_CLASS != TrueColor && ! screen_is_picasso) {
	int i;
	for (i = 0; i < 256; i++)
	    XStoreColor (display, cmap, parsed_xcolors + i);
    }

#ifdef USE_DGA_EXTENSION
    if (dgamode) {
	dga_colormap_installed = 0;
	XF86DGAInstallColormap (display, screen, cmap2);
	XF86DGAInstallColormap (display, screen, cmap);
    }
#endif

    if (! dgamode) {
	if (!currprefs.hide_cursor)
	    XDefineCursor (display, mywin, xhairCursor);
	else
	    XDefineCursor (display, mywin, blankCursor);
	cursorOn = 1;
    }

    mousehack = !dgamode;

    if (screen_is_picasso) {
	picasso_has_invalid_lines = 0;
	picasso_invalid_start = picasso_vidinfo.height + 1;
	picasso_invalid_stop = -1;
	memset (picasso_invalid_lines, 0, sizeof picasso_invalid_lines);
    } else
	reset_drawing ();

    inwindow = 0;
    inputdevice_release_all_keys ();
    reset_hotkeys ();
}
Ejemplo n.º 8
0
static int viewport_setup(void) {
  intptr_t width, height, format, rowbytes, pixbytes;
  intptr_t rb = 0, gb = 0, bb = 0, ab = 0;
  intptr_t rs = 0, gs = 0, bs = 0, as = 0;

  printf("creating bitmap\n");

  bitmap = glgfx_bitmap_create(glgfx_bitmap_attr_width,  bm_width,
			       glgfx_bitmap_attr_height, bm_height,
			       glgfx_bitmap_attr_format, bm_format,
			       glgfx_tag_end);

  if (bitmap == NULL) {
    return 0;
  }

  printf("created bitmap %d %d format %08lx\n", bm_width, bm_height, bm_format);

  uint32_t* buffer;
  
  if ((buffer = glgfx_bitmap_lock(bitmap, false, true, glgfx_tag_end)) != NULL) {
    int x, y;

    for (y = 0; y < bm_height; y += 1) {
      for (x = 0; x < bm_width; x += 1) {
	buffer[x+y*bm_width] = glgfx_pixel_create_a8b8g8r8(y*255/bm_height, 0, x*255/bm_width, 128);
      }
    }

    if (glgfx_bitmap_unlock(bitmap, glgfx_tag_end)) {
      printf("updated bitmap\n");
    }
  }


  glgfx_bitmap_getattr(bitmap, glgfx_bitmap_attr_width,       &width);
  glgfx_bitmap_getattr(bitmap, glgfx_bitmap_attr_height,      &height);
  glgfx_bitmap_getattr(bitmap, glgfx_bitmap_attr_format,      &format);
  glgfx_bitmap_getattr(bitmap, glgfx_bitmap_attr_bytesperrow, &rowbytes);

  glgfx_pixel_getattr(format, glgfx_pixel_attr_bytesperpixel, &pixbytes);
  
  glgfx_pixel_getattr(format, glgfx_pixel_attr_redbits,       &rb);
  glgfx_pixel_getattr(format, glgfx_pixel_attr_greenbits,     &gb);
  glgfx_pixel_getattr(format, glgfx_pixel_attr_bluebits,      &bb);
  glgfx_pixel_getattr(format, glgfx_pixel_attr_alphabits,     &ab);
  glgfx_pixel_getattr(format, glgfx_pixel_attr_redshift,      &rs);
  glgfx_pixel_getattr(format, glgfx_pixel_attr_greenshift,    &gs);
  glgfx_pixel_getattr(format, glgfx_pixel_attr_blueshift,     &bs);
  glgfx_pixel_getattr(format, glgfx_pixel_attr_alphashift,    &as);
  
  alloc_colors64k(rb, gb, bb, rs, gs, bs, ab, as, ((1 << ab) - 1), 0 /* byte swap? */ );

  // Set up callback functions
  gfxvidinfo.flush_line         = _flush_line;
  gfxvidinfo.flush_block        = _flush_block;
  gfxvidinfo.flush_screen       = _flush_screen;
  gfxvidinfo.flush_clear_screen = _flush_clear_screen;
  gfxvidinfo.lockscr            = _lockscr;
  gfxvidinfo.unlockscr          = _unlockscr;

#ifdef PICASSO96
  if (!screen_is_picasso) {
#endif
    gfxvidinfo.width         = width;
    gfxvidinfo.height        = height;
    gfxvidinfo.pixbytes      = pixbytes;
    gfxvidinfo.rowbytes      = rowbytes;

    gfxvidinfo.bufmem        = NULL;
    gfxvidinfo.emergmem      = malloc(rowbytes);
    gfxvidinfo.maxblocklines = height;
//    gfxvidinfo.maxblocklines = 0;
    gfxvidinfo.linemem       = NULL;

    reset_drawing ();
    
#ifdef PICASSO96
  }
  else {
    picasso_has_invalid_lines	= 0;
    picasso_invalid_start	= height + 1;
    picasso_invalid_stop	= -1;
    
    picasso_vidinfo.width       = width;
    picasso_vidinfo.height      = height;
    picasso_vidinfo.depth       = rb + gb + bb + ab;
    picasso_vidinfo.pixbytes    = pixbytes;
    picasso_vidinfo.rowbytes    = rowbytes;
    picasso_vidinfo.extra_mem	= 1;

    p96_buffer = malloc(width*height*pixbytes);
    p96_bytes_per_row = width*pixbytes;
    
    memset (picasso_invalid_lines, 0, sizeof picasso_invalid_lines);
  }
#endif

  if (fullscreen) {
    rasinfo = glgfx_viewport_addbitmap(viewport, bitmap, 
				       glgfx_rasinfo_attr_x,      0,
				       glgfx_rasinfo_attr_y,      0,
				       glgfx_rasinfo_attr_width,  real_width, 
				       glgfx_rasinfo_attr_height, real_height, 
				       glgfx_tag_end);
  }
  else {
    rasinfo = glgfx_viewport_addbitmap(viewport, bitmap, 
				       glgfx_rasinfo_attr_x,      (real_width - bm_width) / 2,
				       glgfx_rasinfo_attr_y,      (real_height - bm_height) / 2,
				       glgfx_rasinfo_attr_width,  width,
				       glgfx_rasinfo_attr_height, height,
				       glgfx_tag_end);
  }

  if (rasinfo == NULL) {
    return 0;
  }
  
  inputdevice_release_all_keys();
  reset_hotkeys();

  printf("viewport_setup -> 1\n");
  return 1;
}
Ejemplo n.º 9
0
Archivo: main.c Proyecto: bernds/UAE
void real_main (int argc, char **argv)
{
    FILE *hf;

#ifdef USE_SDL
    SDL_Init (SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE);
#endif

    default_prefs (&currprefs);

#ifdef SYSTEM_CFGDIR
    scan_configs (SYSTEM_CFGDIR);
#endif

    /* Can be overriden in graphics_setup, although there's not much of a
       point.  Fullscreen modes are filled in by graphics_setup.  */
    gfx_windowed_modes = default_windowed_modes;
    n_windowed_modes = sizeof default_windowed_modes / sizeof *default_windowed_modes;

    if (! graphics_setup ()) {
	exit (1);
    }

    rtarea_init ();
    hardfile_install ();
    scsidev_install ();

    parse_cmdline_and_init_file (argc, argv);

    machdep_init ();
    init_gtod ();

    if (! setup_sound ()) {
	write_log ("Sound driver unavailable: Sound output disabled\n");
	currprefs.produce_sound = 0;
    }
    inputdevice_init ();

    changed_prefs = currprefs;
    no_gui = ! currprefs.start_gui;
    if (! no_gui) {
	int err = gui_init (1);
	currprefs = changed_prefs;
	if (err == -1) {
	    write_log ("Failed to initialize the GUI\n");
	} else if (err == -2) {
	    exit (0);
	}
    }
    if (sound_available && currprefs.produce_sound > 1 && ! init_audio ()) {
	write_log ("Sound driver unavailable: Sound output disabled\n");
	currprefs.produce_sound = 0;
    }

    fixup_prefs (&currprefs);
    changed_prefs = currprefs;

#ifdef SYSTEM_ROMDIR
    scan_roms (SYSTEM_ROMDIR, ROMLOC_SYSTEM);
#endif
    scan_roms (currprefs.path_rom, ROMLOC_USER);
    /* Install resident module to get 8MB chipmem, if requested */
    rtarea_setup ();

    keybuf_init (); /* Must come after init_joystick */

    expansion_init ();
    memory_init ();

    filesys_install ();
    bsdlib_install ();
    emulib_install ();
    uaeexe_install ();
    native2amiga_install ();

    custom_init (); /* Must come after memory_init */
    serial_init ();
    DISK_init ();

    reset_frame_rate_hack ();
    init_m68k(); /* must come after reset_frame_rate_hack (); */

    gui_update ();

    if (graphics_init ()) {
	reset_drawing ();
	setup_brkhandler ();
	if (currprefs.start_debugger && debuggable ())
	    activate_debugger ();

	start_program ();
    }
    leave_program ();
}
Ejemplo n.º 10
0
int graphics_init(bool mousecapture)
{
    write_log("graphics_init\n");

    // FIXME: perhaps modify so custom_limits defaults to -1, -1, -1, -1
    set_custom_limits (-1, -1, -1, -1);

    if (g_amiga_video_format == AMIGA_VIDEO_FORMAT_R5G6B5) {
        g_red_bits    = uae_bits_in_mask(R5G6B5_MASK_R);
        g_red_shift   = uae_mask_shift(R5G6B5_MASK_R);
        g_green_bits  = uae_bits_in_mask(R5G6B5_MASK_G);
        g_green_shift = uae_mask_shift(R5G6B5_MASK_G);
        g_blue_bits   = uae_bits_in_mask(R5G6B5_MASK_B);
        g_blue_shift  = uae_mask_shift(R5G6B5_MASK_B);
        g_alpha_bits   = 0;
        g_alpha_shift  = 0;
    }
    else if (g_amiga_video_format == AMIGA_VIDEO_FORMAT_R5G5B5A1) {
        g_red_bits    = uae_bits_in_mask(R5G5B5A1_MASK_R);
        g_red_shift   = uae_mask_shift(R5G5B5A1_MASK_R);
        g_green_bits  = uae_bits_in_mask(R5G5B5A1_MASK_G);
        g_green_shift = uae_mask_shift(R5G5B5A1_MASK_G);
        g_blue_bits   = uae_bits_in_mask(R5G5B5A1_MASK_B);
        g_blue_shift  = uae_mask_shift(R5G5B5A1_MASK_B);
        g_alpha_bits   = uae_bits_in_mask(R5G5B5A1_MASK_A);
        g_alpha_shift  = uae_mask_shift(R5G5B5A1_MASK_A);
    }
    else { // RGBA or BGRA
        if (g_amiga_video_format == AMIGA_VIDEO_FORMAT_RGBA) {
            g_red_bits    = uae_bits_in_mask(RGBA_MASK_R);
            g_red_shift   = uae_mask_shift(RGBA_MASK_R);
            g_blue_bits   = uae_bits_in_mask(RGBA_MASK_B);
            g_blue_shift  = uae_mask_shift(RGBA_MASK_B);
        }
        else { // BGRA
            g_red_bits   = uae_bits_in_mask(RGBA_MASK_B);
            g_red_shift  = uae_mask_shift(RGBA_MASK_B);
            g_blue_bits    = uae_bits_in_mask(RGBA_MASK_R);
            g_blue_shift   = uae_mask_shift(RGBA_MASK_R);
        }
        g_green_bits  = uae_bits_in_mask(RGBA_MASK_G);
        g_green_shift = uae_mask_shift(RGBA_MASK_G);
        g_alpha_bits   = uae_bits_in_mask(RGBA_MASK_A);
        g_alpha_shift  = uae_mask_shift(RGBA_MASK_A);
    }

    //g_renderdata.pixels = (unsigned char*) malloc(AMIGA_WIDTH*AMIGA_HEIGHT*4);

    memset(g_renderdata.line, 0, AMIGA_MAX_LINES);
    gfxvidinfo.maxblocklines = 0;
#ifdef USE_BUFMEM
    g_bufmem = (unsigned char*) malloc(AMIGA_WIDTH * AMIGA_HEIGHT * g_amiga_video_bpp);
    gfxvidinfo.drawbuffer.bufmem = g_bufmem;
    memset(g_bufmem, 0, AMIGA_WIDTH * AMIGA_HEIGHT * g_amiga_video_bpp);
    gfxvidinfo.maxblocklines = MAXBLOCKLINES_MAX;
#endif

#ifdef USE_LINEMEM
    gfxvidinfo.drawbuffer.emergmem = 0;
    gfxvidinfo.drawbuffer.linemem = g_linemem;
#else
    gfxvidinfo.drawbuffer.emergmem = 0; //g_linemem;
    gfxvidinfo.drawbuffer.linemem = 0;
#endif
    gfxvidinfo.drawbuffer.pixbytes = g_amiga_video_bpp;
    gfxvidinfo.drawbuffer.rowbytes = AMIGA_WIDTH * g_amiga_video_bpp;
    gfxvidinfo.drawbuffer.height_allocated = AMIGA_HEIGHT;
    gfxvidinfo.drawbuffer.inheight = AMIGA_HEIGHT;
    gfxvidinfo.drawbuffer.outheight = AMIGA_HEIGHT;
    gfxvidinfo.drawbuffer.width_allocated = AMIGA_WIDTH;
    gfxvidinfo.drawbuffer.inwidth = AMIGA_WIDTH;
    gfxvidinfo.drawbuffer.outwidth = AMIGA_WIDTH;

    //gfxvidinfo.flush_block = libamiga_flush_block;
    //gfxvidinfo.flush_screen = libamiga_flush_screen;
    //SDL_SetColors (display, arSDLColors, 0, 256);
    write_log("calling reset_drawing\n");
    reset_drawing ();
    init_colors ();

//#ifdef USE_BUFMEM
//    init_row_map();
//#endif

    //write_log("FIXME: NOT USING VSYNC TRICK\n");
    // Trick UAE into sending believing we are in vsync / fullscreen
    // so a flush command is sent for each frame update in do_flush_screen.

    if (currprefs.m68k_speed == -1) {
        write_log("currprefs.m68k_speed is -1, not allowing full sync\n");
    }
    else {
        //currprefs.gfx_apmode[0].gfx_fullscreen = GFX_FULLSCREEN;
        currprefs.gfx_apmode[0].gfx_vsync = 1;
    }

    //currprefs.gfx_apmode[0].gfx_fullscreen = GFX_FULLSCREEN;
    //currprefs.gfx_apmode[0].gfx_vsync = 1;

    //currprefs.gfx_apmode[0].gfx_vsyncmode = 1;
    //currprefs.gfx_apmode[1].gfx_fullscreen = GFX_FULLSCREEN;
    //currprefs.gfx_apmode[1].gfx_vsync = 1;

    //amiga_set_option("gfx_vsync", "true");
    //amiga_set_option("gfx_vsyncmode", "busywait");

    return 1;
}