+void pollux_video_flip()
+{
+ gpsp_gp2x_memregl[0x406C>>2] = fb_paddr[fb_work_buf];
+ gpsp_gp2x_memregl[0x4058>>2] |= 0x10;
+ fb_work_buf++;
+ if (fb_work_buf >= fb_buf_use)
+ fb_work_buf = 0;
+ gpsp_gp2x_screen = fb_vaddr[fb_work_buf];
+}
+
+void fb_use_buffers(int count)
+{
+ if (count < 1)
+ count = 1;
+ else if (count > fb_buf_count)
+ count = fb_buf_count;
+ fb_buf_use = count;
+ memset(fb_vaddr[0], 0, 320*240*2*count);
+}
+
+void wiz_lcd_set_portrait(int y)
+{
+ static int old_y = -1;
+ int cmd[2] = { 0, 0 };
+
+ if (old_y == y)
+ return;
+ cmd[0] = y ? 6 : 5;
+ ioctl(fbdev, _IOW('D', 90, int[2]), cmd);
+ gpsp_gp2x_memregl[0x4004>>2] = y ? 0x013f00ef : 0x00ef013f;
+ gpsp_gp2x_memregl[0x4000>>2] |= 1 << 3;
+ old_y = y;
+
+ /* the above ioctl resets LCD timings, so set them here */
+ pollux_dpc_set(gpsp_gp2x_memregs, getenv("pollux_dpc_set"));
+}
+
+static void fb_video_exit()
+{
+ /* switch to default fb mem, turn portrait off */
+ gpsp_gp2x_memregl[0x406C>>2] = fb_paddr[0];
+ gpsp_gp2x_memregl[0x4058>>2] |= 0x10;
+ wiz_lcd_set_portrait(0);
+ close(fbdev);
+}
+
+static int wiz_gamepak_fd = -1;
+static u32 wiz_gamepak_size;
+
+static void wiz_gamepak_cleanup()
+{
+ if (wiz_gamepak_size)
+ munmap(gamepak_rom, wiz_gamepak_size);
+ if (wiz_gamepak_fd >= 0)
+ close(wiz_gamepak_fd);
+ gamepak_rom = NULL;
+ wiz_gamepak_size = 0;
+ wiz_gamepak_fd = -1;
+}