released 0.8.7 (new MMU layout, m5484LITE board working again)

This commit is contained in:
Markus Fröschle
2015-01-24 10:24:33 +00:00
parent f72b551170
commit ce6e8d58fd
284 changed files with 126529 additions and 0 deletions

185
BaS_gcc/video/fbmem.c Normal file
View File

@@ -0,0 +1,185 @@
/*
* fbmem.c
*
* Copyright (C) 1994 Martin Schaller
*
* 2001 - Documented with DocBook
* - Brad Douglas <brad@neruo.com>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*/
#include "bas_types.h"
#include "bas_printf.h"
#include "bas_string.h"
#include "fb.h"
#include "radeonfb.h"
#include "driver_mem.h"
#define DBG_FBMEM
#ifdef DBG_FBMEM
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else
#define dbg(format, arg...) do { ; } while (0)
#endif /* DBG_FBMEM */
long mem_cmp(char *p1, char *p2, long size)
{
while(size--)
{
if (*p1++ != *p2++)
return(1);
}
return(0);
}
/*
* Frame buffer device initialization and setup routines
*/
#define FBPIXMAPSIZE (1024 * 8)
int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
{
int xoffset = var->xoffset;
int yoffset = var->yoffset;
int err;
// DPRINT("fb_pan_display\r\n");
if ((xoffset < 0) || (yoffset < 0)
|| ((xoffset + info->var.xres) > info->var.xres_virtual))
return -1; //-EINVAL;
if ((err = info->fbops->fb_pan_display(var, info)))
return err;
info->var.xoffset = var->xoffset;
info->var.yoffset = var->yoffset;
if (var->vmode & FB_VMODE_YWRAP)
info->var.vmode |= FB_VMODE_YWRAP;
else
info->var.vmode &= ~FB_VMODE_YWRAP;
return 0;
}
int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
{
int err;
// DPRINT("fb_set_var\r\n");
if (var->activate & FB_ACTIVATE_INV_MODE)
/* return 1 if equal */
return(!mem_cmp((char *)&info->var, (char *)var, sizeof(struct fb_var_screeninfo)));
if ((var->activate & FB_ACTIVATE_FORCE)
|| mem_cmp((char *)&info->var, (char *)var, sizeof(struct fb_var_screeninfo)))
{
if ((err = info->fbops->fb_check_var(var, info)))
return err;
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW)
{
memcpy(&info->var, var, sizeof(struct fb_var_screeninfo));
info->fbops->fb_set_par(info);
fb_pan_display(info, &info->var);
}
}
return 0;
}
int fb_blank(struct fb_info *info, int blank)
{
dbg("fb_blank\r\n");
if (blank > FB_BLANK_POWERDOWN)
blank = FB_BLANK_POWERDOWN;
return(info->fbops->fb_blank(blank, info));
}
int fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
{
struct fb_var_screeninfo var;
struct fb_fix_screeninfo fix;
void *argp = (void *) arg;
int i;
switch(cmd)
{
case FBIOGET_VSCREENINFO:
memcpy(argp, &info->var, sizeof(var));
return 0;
case FBIOPUT_VSCREENINFO:
memcpy(&var, argp, sizeof(var));
i = fb_set_var(info, &var);
if (i)
return i;
memcpy(argp, &var, sizeof(var));
return 0;
case FBIOGET_FSCREENINFO:
memcpy(argp, &info->fix, sizeof(fix));
return 0;
case FBIOPAN_DISPLAY:
memcpy(&var, argp, sizeof(var));
i = fb_pan_display(info, &var);
if (i)
return i;
memcpy(argp, &var, sizeof(var));
return 0;
case FBIOBLANK:
i = fb_blank(info, arg);
return i;
case FBIO_ALLOC:
return(offscreen_alloc(info,(long)arg));
case FBIO_FREE:
return(offscreen_free(info,(long)arg));
default:
return(info->fbops->fb_ioctl(cmd, arg, info));
}
}
/**
* framebuffer_alloc - creates a new frame buffer info structure
*
* @size: size of driver private data, can be zero
* @dev: pointer to the device for this fb, this can be NULL
*
* Creates a new frame buffer info structure. Also reserves @size bytes
* for driver private data (info->par). info->par (if any) will be
* aligned to sizeof(long).
*
* Returns the new structure, or NULL if an error occured.
*
*/
struct fb_info *framebuffer_alloc(unsigned long size)
{
struct fb_info *info = driver_mem_alloc(sizeof(struct fb_info));
if (info == NULL)
{
dbg("%s: could not allocate fb_info structure\r\n", __FUNCTION__);
return 0;
}
memset(info, 0, sizeof(struct fb_info));
if (size)
{
char *p = driver_mem_alloc(size);
if (!p)
return NULL;
memset(p, 0, size);
info->par = p;
}
return info;
}
/**
* framebuffer_release - marks the structure available for freeing
*
* @info: frame buffer info structure
*
* Drop the reference count of the class_device embedded in the
* framebuffer info structure.
*
*/
void framebuffer_release(struct fb_info *info)
{
driver_mem_free(info->par);
}

596
BaS_gcc/video/fbmodedb.c Normal file
View File

@@ -0,0 +1,596 @@
/*
* fb_modedb.c -- Standard video mode database management
*
* Copyright (C) 1999 Geert Uytterhoeven
*
* 2001 - Documented with DocBook
* - Brad Douglas <brad@neruo.com>
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*/
#include "fb.h"
#include "bas_types.h"
#include "bas_printf.h"
#include "bas_string.h"
#define DBG_MODES
#ifdef DBG_MODES
#define dbg(format, arg...) do { xprintf("DEBUG: " format, __FUNCTION__, ##arg); } while (0)
#else
#define dbg(format, arg...) do { ; } while (0)
#endif /* DBG_MODES */
#define name_matches(v, s, l) \
((v).name && !strncmp((s), (v).name, (l)) && strlen((v).name) == (l))
#define res_matches(v, x, y) \
((v).xres == (x) && (v).yres == (y))
/*
* Standard video mode definitions (taken from XFree86)
*/
#define DEFAULT_MODEDB_INDEX 0
const struct fb_videomode modedb[] =
{
{
/* 640x400 @ 70 Hz, 31.5 kHz hsync */
70, 640, 400, 39721, 40, 24, 39, 9, 96, 2,
0, FB_VMODE_NONINTERLACED
},
{
/* 640x480 @ 60 Hz, 31.5 kHz hsync */
60, 640, 480, 39721, 40, 24, 32, 11, 96, 2,
0, FB_VMODE_NONINTERLACED
},
{
/* 800x600 @ 56 Hz, 35.15 kHz hsync */
56, 800, 600, 27777, 128, 24, 22, 1, 72, 2,
0, FB_VMODE_NONINTERLACED
},
{
/* 1024x768 @ 87 Hz interlaced, 35.5 kHz hsync */
87, 1024, 768, 22271, 56, 24, 33, 8, 160, 8,
0, FB_VMODE_INTERLACED
},
{
/* 640x400 @ 85 Hz, 37.86 kHz hsync */
85, 640, 400, 31746, 96, 32, 41, 1, 64, 3,
FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 640x480 @ 72 Hz, 36.5 kHz hsync */
72, 640, 480, 31746, 144, 40, 30, 8, 40, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 640x480 @ 75 Hz, 37.50 kHz hsync */
75, 640, 480, 31746, 120, 16, 16, 1, 64, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 800x600 @ 60 Hz, 37.8 kHz hsync */
60, 800, 600, 25000, 88, 40, 23, 1, 128, 4,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 640x480 @ 85 Hz, 43.27 kHz hsync */
85, 640, 480, 27777, 80, 56, 25, 1, 56, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 1152x864 @ 89 Hz interlaced, 44 kHz hsync */
69, 1152, 864, 15384, 96, 16, 110, 1, 216, 10,
0, FB_VMODE_INTERLACED
},
{
/* 800x600 @ 72 Hz, 48.0 kHz hsync */
72, 800, 600, 20000, 64, 56, 23, 37, 120, 6,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 1024x768 @ 60 Hz, 48.4 kHz hsync */
60, 1024, 768, 15384, 168, 8, 29, 3, 144, 6,
0, FB_VMODE_NONINTERLACED
},
{
/* 640x480 @ 100 Hz, 53.01 kHz hsync */
100, 640, 480, 21834, 96, 32, 36, 8, 96, 6,
0, FB_VMODE_NONINTERLACED
},
{
/* 1152x864 @ 60 Hz, 53.5 kHz hsync */
60, 1152, 864, 11123, 208, 64, 16, 4, 256, 8,
0, FB_VMODE_NONINTERLACED
},
{
/* 800x600 @ 85 Hz, 55.84 kHz hsync */
85, 800, 600, 16460, 160, 64, 36, 16, 64, 5,
0, FB_VMODE_NONINTERLACED
},
{
/* 1024x768 @ 70 Hz, 56.5 kHz hsync */
70, 1024, 768, 13333, 144, 24, 29, 3, 136, 6,
0, FB_VMODE_NONINTERLACED
},
{
/* 1280x1024 @ 87 Hz interlaced, 51 kHz hsync */
87, 1280, 1024, 12500, 56, 16, 128, 1, 216, 12,
0, FB_VMODE_INTERLACED
},
{
/* 800x600 @ 100 Hz, 64.02 kHz hsync */
100, 800, 600, 14357, 160, 64, 30, 4, 64, 6,
0, FB_VMODE_NONINTERLACED
},
{
/* 1024x768 @ 76 Hz, 62.5 kHz hsync */
76, 1024, 768, 11764, 208, 8, 36, 16, 120, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 1152x864 @ 70 Hz, 62.4 kHz hsync */
70, 1152, 864, 10869, 106, 56, 20, 1, 160, 10,
0, FB_VMODE_NONINTERLACED
},
{
/* 1280x1024 @ 61 Hz, 64.2 kHz hsync */
61, 1280, 1024, 9090, 200, 48, 26, 1, 184, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 1400x1050 @ 60Hz, 63.9 kHz hsync */
68, 1400, 1050, 9259, 136, 40, 13, 1, 112, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 1400x1050 @ 75,107 Hz, 82,392 kHz +hsync +vsync*/
75, 1400, 1050, 9271, 120, 56, 13, 0, 112, 3,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 1400x1050 @ 60 Hz, ? kHz +hsync +vsync*/
60, 1400, 1050, 9259, 128, 40, 12, 0, 112, 3,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 1024x768 @ 85 Hz, 70.24 kHz hsync */
85, 1024, 768, 10111, 192, 32, 34, 14, 160, 6,
0, FB_VMODE_NONINTERLACED
},
{
/* 1152x864 @ 78 Hz, 70.8 kHz hsync */
78, 1152, 864, 9090, 228, 88, 32, 0, 84, 12,
0, FB_VMODE_NONINTERLACED
},
{
/* 1280x1024 @ 70 Hz, 74.59 kHz hsync */
70, 1280, 1024, 7905, 224, 32, 28, 8, 160, 8,
0, FB_VMODE_NONINTERLACED
},
{
/* 1600x1200 @ 60Hz, 75.00 kHz hsync */
60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 1152x864 @ 84 Hz, 76.0 kHz hsync */
84, 1152, 864, 7407, 184, 312, 32, 0, 128, 12,
0, FB_VMODE_NONINTERLACED
},
{
/* 1280x1024 @ 74 Hz, 78.85 kHz hsync */
74, 1280, 1024, 7407, 256, 32, 34, 3, 144, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 1024x768 @ 100Hz, 80.21 kHz hsync */
100, 1024, 768, 8658, 192, 32, 21, 3, 192, 10,
0, FB_VMODE_NONINTERLACED
},
{
/* 1280x1024 @ 76 Hz, 81.13 kHz hsync */
76, 1280, 1024, 7407, 248, 32, 34, 3, 104, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 1600x1200 @ 70 Hz, 87.50 kHz hsync */
70, 1600, 1200, 5291, 304, 64, 46, 1, 192, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 1152x864 @ 100 Hz, 89.62 kHz hsync */
100, 1152, 864, 7264, 224, 32, 17, 2, 128, 19,
0, FB_VMODE_NONINTERLACED
},
{
/* 1280x1024 @ 85 Hz, 91.15 kHz hsync */
85, 1280, 1024, 6349, 224, 64, 44, 1, 160, 3,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 1600x1200 @ 75 Hz, 93.75 kHz hsync */
75, 1600, 1200, 4938, 304, 64, 46, 1, 192, 3,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 1600x1200 @ 85 Hz, 105.77 kHz hsync */
85, 1600, 1200, 4545, 272, 16, 37, 4, 192, 3,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 1280x1024 @ 100 Hz, 107.16 kHz hsync */
100, 1280, 1024, 5502, 256, 32, 26, 7, 128, 15,
0, FB_VMODE_NONINTERLACED
},
{
/* 1800x1440 @ 64Hz, 96.15 kHz hsync */
64, 1800, 1440, 4347, 304, 96, 46, 1, 192, 3,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 1800x1440 @ 70Hz, 104.52 kHz hsync */
70, 1800, 1440, 4000, 304, 96, 46, 1, 192, 3,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 512x384 @ 78 Hz, 31.50 kHz hsync */
78, 512, 384, 49603, 48, 16, 16, 1, 64, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 512x384 @ 85 Hz, 34.38 kHz hsync */
85, 512, 384, 45454, 48, 16, 16, 1, 64, 3,
0, FB_VMODE_NONINTERLACED
},
{
/* 320x200 @ 70 Hz, 31.5 kHz hsync, 8:5 aspect ratio */
70, 320, 200, 79440, 16, 16, 20, 4, 48, 1,
0, FB_VMODE_DOUBLE
},
{
/* 320x240 @ 60 Hz, 31.5 kHz hsync, 4:3 aspect ratio */
60, 320, 240, 79440, 16, 16, 16, 5, 48, 1,
0, FB_VMODE_DOUBLE
},
{
/* 320x240 @ 72 Hz, 36.5 kHz hsync */
72, 320, 240, 63492, 16, 16, 16, 4, 48, 2,
0, FB_VMODE_DOUBLE
},
{
/* 400x300 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio */
56, 400, 300, 55555, 64, 16, 10, 1, 32, 1,
0, FB_VMODE_DOUBLE
},
{
/* 400x300 @ 60 Hz, 37.8 kHz hsync */
60, 400, 300, 50000, 48, 16, 11, 1, 64, 2,
0, FB_VMODE_DOUBLE
},
{
/* 400x300 @ 72 Hz, 48.0 kHz hsync */
72, 400, 300, 40000, 32, 24, 11, 19, 64, 3,
0, FB_VMODE_DOUBLE
},
{
/* 480x300 @ 56 Hz, 35.2 kHz hsync, 8:5 aspect ratio */
56, 480, 300, 46176, 80, 16, 10, 1, 40, 1,
0, FB_VMODE_DOUBLE
},
{
/* 480x300 @ 60 Hz, 37.8 kHz hsync */
60, 480, 300, 41858, 56, 16, 11, 1, 80, 2,
0, FB_VMODE_DOUBLE
},
{
/* 480x300 @ 63 Hz, 39.6 kHz hsync */
63, 480, 300, 40000, 56, 16, 11, 1, 80, 2,
0, FB_VMODE_DOUBLE
},
{
/* 480x300 @ 72 Hz, 48.0 kHz hsync */
72, 480, 300, 33386, 40, 24, 11, 19, 80, 3,
0, FB_VMODE_DOUBLE
},
{
/* 1920x1200 @ 60 Hz, 74.5 Khz hsync */
60, 1920, 1200, 5177, 128, 336, 1, 38, 208, 3,
FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
FB_VMODE_NONINTERLACED
},
{
/* 1152x768, 60 Hz, PowerBook G4 Titanium I and II */
60, 1152, 768, 14047, 158, 26, 29, 3, 136, 6,
FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
},
{
/* 1920x1080, 60 Hz, 1080pf */
60, 1920, 1080, 6741, 148, 44, 36, 4, 88, 5,
0, FB_VMODE_NONINTERLACED
},
{
/* 1366x768, 60 Hz, 47.403 kHz hsync, WXGA 16:9 aspect ratio */
60, 1366, 768, 13806, 120, 10, 14, 3, 32, 5,
0, FB_VMODE_NONINTERLACED
},
{
/* 1280x800, 60 Hz, 47.403 kHz hsync, WXGA 16:10 aspect ratio */
60, 1280, 800, 12048, 200, 64, 24, 1, 136, 3,
0, FB_VMODE_NONINTERLACED
},
};
long total_modedb = sizeof(modedb) / sizeof(*modedb);
const struct fb_videomode vesa_modes[] =
{
/* 0 640x350-85 VESA */
{ 85, 640, 350, 31746, 96, 32, 60, 32, 64, 3, FB_SYNC_HOR_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA},
/* 1 640x400-85 VESA */
{ 85, 640, 400, 31746, 96, 32, 41, 01, 64, 3, FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 2 720x400-85 VESA */
{ 85, 721, 400, 28169, 108, 36, 42, 01, 72, 3, FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 3 640x480-60 VESA */
{ 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2, 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 4 640x480-72 VESA */
{ 72, 640, 480, 31746, 128, 24, 29, 9, 40, 2, 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 5 640x480-75 VESA */
{ 75, 640, 480, 31746, 120, 16, 16, 01, 64, 3, 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 6 640x480-85 VESA */
{ 85, 640, 480, 27777, 80, 56, 25, 01, 56, 3, 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 7 800x600-56 VESA */
{ 56, 800, 600, 27777, 128, 24, 22, 01, 72, 2, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 8 800x600-60 VESA */
{ 60, 800, 600, 25000, 88, 40, 23, 01, 128, 4, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 9 800x600-72 VESA */
{ 72, 800, 600, 20000, 64, 56, 23, 37, 120, 6, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 10 800x600-75 VESA */
{ 75, 800, 600, 20202, 160, 16, 21, 01, 80, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 11 800x600-85 VESA */
{ 85, 800, 600, 17761, 152, 32, 27, 01, 64, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 12 1024x768i-43 VESA */
{ 53, 1024, 768, 22271, 56, 8, 41, 0, 176, 8, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_INTERLACED, FB_MODE_IS_VESA },
/* 13 1024x768-60 VESA */
{ 60, 1024, 768, 15384, 160, 24, 29, 3, 136, 6, 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 14 1024x768-70 VESA */
{ 70, 1024, 768, 13333, 144, 24, 29, 3, 136, 6, 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 15 1024x768-75 VESA */
{ 75, 1024, 768, 12690, 176, 16, 28, 1, 96, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 16 1024x768-85 VESA */
{ 85, 1024, 768, 10582, 208, 48, 36, 1, 96, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 17 1152x864-75 VESA */
{ 75, 1153, 864, 9259, 256, 64, 32, 1, 128, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 18 1280x960-60 VESA */
{ 60, 1280, 960, 9259, 312, 96, 36, 1, 112, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 19 1280x960-85 VESA */
{ 85, 1280, 960, 6734, 224, 64, 47, 1, 160, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 20 1280x1024-60 VESA */
{ 60, 1280, 1024, 9259, 248, 48, 38, 1, 112, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 21 1280x1024-75 VESA */
{ 75, 1280, 1024, 7407, 248, 16, 38, 1, 144, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 22 1280x1024-85 VESA */
{ 85, 1280, 1024, 6349, 224, 64, 44, 1, 160, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 23 1600x1200-60 VESA */
{ 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 24 1600x1200-65 VESA */
{ 65, 1600, 1200, 5698, 304, 64, 46, 1, 192, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 25 1600x1200-70 VESA */
{ 70, 1600, 1200, 5291, 304, 64, 46, 1, 192, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 26 1600x1200-75 VESA */
{ 75, 1600, 1200, 4938, 304, 64, 46, 1, 192, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 27 1600x1200-85 VESA */
{ 85, 1600, 1200, 4357, 304, 64, 46, 1, 192, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 28 1792x1344-60 VESA */
{ 60, 1792, 1344, 4882, 328, 128, 46, 1, 200, 3, FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 29 1792x1344-75 VESA */
{ 75, 1792, 1344, 3831, 352, 96, 69, 1, 216, 3, FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 30 1856x1392-60 VESA */
{ 60, 1856, 1392, 4580, 352, 96, 43, 1, 224, 3, FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 31 1856x1392-75 VESA */
{ 75, 1856, 1392, 3472, 352, 128, 104, 1, 224, 3, FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 32 1920x1440-60 VESA */
{ 60, 1920, 1440, 4273, 344, 128, 56, 1, 200, 3, FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
/* 33 1920x1440-75 VESA */
{ 60, 1920, 1440, 3367, 352, 144, 56, 1, 224, 3, FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
};
/**
* fb_try_mode - test a video mode
* @var: frame buffer user defined part of display
* @info: frame buffer info structure
* @mode: frame buffer video mode structure
* @bpp: color depth in bits per pixel
*
* Tries a video mode to test it's validity for device @info.
*
* Returns 1 on success.
*
*/
static int fb_try_mode(struct fb_var_screeninfo *var, struct fb_info *info,
const struct fb_videomode *mode, unsigned int bpp)
{
int err = 0;
dbg("Trying mode %d x %d - %d @ %d\r\n", mode->xres, mode->yres, bpp, mode->refresh);
var->xres = mode->xres;
var->yres = mode->yres;
var->xres_virtual = mode->xres;
var->yres_virtual = mode->yres;
var->xoffset = 0;
var->yoffset = 0;
var->bits_per_pixel = bpp;
var->activate |= FB_ACTIVATE_TEST;
var->pixclock = mode->pixclock;
var->left_margin = mode->left_margin;
var->right_margin = mode->right_margin;
var->upper_margin = mode->upper_margin;
var->lower_margin = mode->lower_margin;
var->hsync_len = mode->hsync_len;
var->vsync_len = mode->vsync_len;
var->sync = mode->sync;
var->vmode = mode->vmode;
var->refresh = mode->refresh;
err = info->fbops->fb_check_var(var, info);
var->activate &= ~FB_ACTIVATE_TEST;
return err;
}
/**
* fb_find_mode - finds a valid video mode
* @var: frame buffer user defined part of display
* @info: frame buffer info structure
* @resolution: fVDI structure mode_option
* @db: video mode database
* @dbsize: size of @db
* @default_mode: default video mode to fall back to
* @default_bpp: default color depth in bits per pixel
*
* Finds a suitable video mode, starting with the specified mode
* in @resolution with fallback to @default_mode. If
* @default_mode fails, all modes in the video mode database will
* be tried.
*
* Valid mode specifiers for @resolution:
*
* <xres>x<yres>[-<bpp>][@<refresh>] or
* <name>[-<bpp>][@<refresh>]
*
* with <xres>, <yres>, <bpp> and <refresh> decimal numbers and
* <name> a string.
*
* NOTE: The passed struct @var is _not_ cleared! This allows you
* to supply values for e.g. the grayscale and accel_flags fields.
*
* Returns zero for failure, 1 if using specified @resolution,
* 2 if using specified @resolution with an ignored refresh rate,
* 3 if default mode is used, 4 if fall back to any valid mode.
*
*/
int fb_find_mode(struct fb_var_screeninfo *var,
struct fb_info *info, struct mode_option *resolution ,
const struct fb_videomode *db, unsigned int dbsize,
const struct fb_videomode *default_mode,
unsigned int default_bpp)
{
int i,abs;
int res_specified = 0, bpp_specified = 0, refresh_specified = 0;
unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0;
int yres_specified = 0;
unsigned long best, diff;
dbg("fb_find_mode\r\n");
/* Set up defaults */
if (!db)
{
dbg("fb_find_mode, use default modedb\r\n");
if (resolution->used && (resolution->flags & MODE_VESA_FLAG))
{
db = vesa_modes;
dbsize = sizeof(vesa_modes)/sizeof(*vesa_modes);
}
else
{
db = modedb;
dbsize = sizeof(modedb)/sizeof(*modedb);
}
}
if (!default_mode)
default_mode = &modedb[DEFAULT_MODEDB_INDEX];
if (!default_bpp)
default_bpp = 8;
/* Did the user specify a video mode? */
if (resolution->used) /* fVDI mode */
{
refresh = (unsigned int)resolution->freq;
if (refresh)
refresh_specified = 1;
bpp = (unsigned int)resolution->bpp;
if (resolution->flags & MODE_EMUL_MONO_FLAG)
bpp = 8;
if (bpp)
bpp_specified = 1;
yres = (unsigned int)resolution->height;
if (yres)
yres_specified = 1;
xres = (unsigned int)resolution->width;
if (xres)
res_specified = 1;
}
dbg("Trying specified video mode %d x %d\r\n", xres, yres);
diff = refresh;
best = -1;
for (i = 0; i < dbsize; i++)
{
if (res_specified && res_matches(db[i], xres, yres))
{
if (!fb_try_mode(var, info, &db[i], bpp))
{
if (!refresh_specified || db[i].refresh == refresh)
return 1;
else
{
abs = db[i].refresh - refresh;
if (abs < 0)
abs = -abs;
if (diff > abs)
{
diff = abs;
best = i;
}
}
}
}
}
if (best != -1)
{
fb_try_mode(var, info, &db[best], bpp);
return 2;
}
diff = xres + yres;
dbg("Trying best-fit modes\r\n");
best = -1;
for (i = 0; i < dbsize; i++)
{
if (xres <= db[i].xres && yres <= db[i].yres)
{
dbg("Trying %d x %d\r\n", db[i].xres, db[i].yres);
if (!fb_try_mode(var, info, &db[i], bpp))
{
if (diff > (db[i].xres - xres) + (db[i].yres - yres))
{
diff = (db[i].xres - xres) + (db[i].yres - yres);
best = i;
}
}
}
}
if (best != -1)
{
fb_try_mode(var, info, &db[best], bpp);
return 5;
}
dbg("Trying default video mode\r\n");
if (!fb_try_mode(var, info, default_mode, default_bpp))
return 3;
dbg("Trying all modes\r\n");
for (i = 0; i < dbsize; i++)
{
if (!fb_try_mode(var, info, &db[i], default_bpp))
return 4;
}
dbg("No valid mode found\r\n");
return 0;
}

1303
BaS_gcc/video/fbmon.c Normal file

File diff suppressed because it is too large Load Diff

337
BaS_gcc/video/fnt_st_8x16.c Normal file
View File

@@ -0,0 +1,337 @@
/*
* fnt-8x16.c - 8x16 font for Atari ST encoding
*
* Copyright (C) 2001-2002 The EmuTOS development team
*
* This file is distributed under the GPL, version 2 or at your
* option any later version. See doc/license.txt for details.
*/
#include "bas_types.h"
#include "font.h"
static const uint16_t off_table[] =
{
0x0000, 0x0008, 0x0010, 0x0018, 0x0020, 0x0028, 0x0030, 0x0038,
0x0040, 0x0048, 0x0050, 0x0058, 0x0060, 0x0068, 0x0070, 0x0078,
0x0080, 0x0088, 0x0090, 0x0098, 0x00a0, 0x00a8, 0x00b0, 0x00b8,
0x00c0, 0x00c8, 0x00d0, 0x00d8, 0x00e0, 0x00e8, 0x00f0, 0x00f8,
0x0100, 0x0108, 0x0110, 0x0118, 0x0120, 0x0128, 0x0130, 0x0138,
0x0140, 0x0148, 0x0150, 0x0158, 0x0160, 0x0168, 0x0170, 0x0178,
0x0180, 0x0188, 0x0190, 0x0198, 0x01a0, 0x01a8, 0x01b0, 0x01b8,
0x01c0, 0x01c8, 0x01d0, 0x01d8, 0x01e0, 0x01e8, 0x01f0, 0x01f8,
0x0200, 0x0208, 0x0210, 0x0218, 0x0220, 0x0228, 0x0230, 0x0238,
0x0240, 0x0248, 0x0250, 0x0258, 0x0260, 0x0268, 0x0270, 0x0278,
0x0280, 0x0288, 0x0290, 0x0298, 0x02a0, 0x02a8, 0x02b0, 0x02b8,
0x02c0, 0x02c8, 0x02d0, 0x02d8, 0x02e0, 0x02e8, 0x02f0, 0x02f8,
0x0300, 0x0308, 0x0310, 0x0318, 0x0320, 0x0328, 0x0330, 0x0338,
0x0340, 0x0348, 0x0350, 0x0358, 0x0360, 0x0368, 0x0370, 0x0378,
0x0380, 0x0388, 0x0390, 0x0398, 0x03a0, 0x03a8, 0x03b0, 0x03b8,
0x03c0, 0x03c8, 0x03d0, 0x03d8, 0x03e0, 0x03e8, 0x03f0, 0x03f8,
0x0400, 0x0408, 0x0410, 0x0418, 0x0420, 0x0428, 0x0430, 0x0438,
0x0440, 0x0448, 0x0450, 0x0458, 0x0460, 0x0468, 0x0470, 0x0478,
0x0480, 0x0488, 0x0490, 0x0498, 0x04a0, 0x04a8, 0x04b0, 0x04b8,
0x04c0, 0x04c8, 0x04d0, 0x04d8, 0x04e0, 0x04e8, 0x04f0, 0x04f8,
0x0500, 0x0508, 0x0510, 0x0518, 0x0520, 0x0528, 0x0530, 0x0538,
0x0540, 0x0548, 0x0550, 0x0558, 0x0560, 0x0568, 0x0570, 0x0578,
0x0580, 0x0588, 0x0590, 0x0598, 0x05a0, 0x05a8, 0x05b0, 0x05b8,
0x05c0, 0x05c8, 0x05d0, 0x05d8, 0x05e0, 0x05e8, 0x05f0, 0x05f8,
0x0600, 0x0608, 0x0610, 0x0618, 0x0620, 0x0628, 0x0630, 0x0638,
0x0640, 0x0648, 0x0650, 0x0658, 0x0660, 0x0668, 0x0670, 0x0678,
0x0680, 0x0688, 0x0690, 0x0698, 0x06a0, 0x06a8, 0x06b0, 0x06b8,
0x06c0, 0x06c8, 0x06d0, 0x06d8, 0x06e0, 0x06e8, 0x06f0, 0x06f8,
0x0700, 0x0708, 0x0710, 0x0718, 0x0720, 0x0728, 0x0730, 0x0738,
0x0740, 0x0748, 0x0750, 0x0758, 0x0760, 0x0768, 0x0770, 0x0778,
0x0780, 0x0788, 0x0790, 0x0798, 0x07a0, 0x07a8, 0x07b0, 0x07b8,
0x07c0, 0x07c8, 0x07d0, 0x07d8, 0x07e0, 0x07e8, 0x07f0, 0x07f8,
0x0800,
};
static const uint16_t dat_table[] =
{
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1104,
0x0000, 0x0000, 0x1800, 0x3800, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x4000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x003c,
0x0600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x6032, 0x3200, 0x0000, 0x0000, 0x00f1,
0x00f6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0060, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0018, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x05a0,
0x7c00, 0x7c7c, 0x007c, 0x7c7c, 0x7c7c, 0x0000, 0x0000, 0x0b28,
0x0000, 0x0000, 0x1800, 0x7c00, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1000,
0x6000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x000e, 0x18e0, 0x0000,
0x0000, 0x0618, 0x0060, 0x1c00, 0x1800, 0x6000, 0x1860, 0x6666,
0x0c00, 0x3e18, 0x0060, 0x1860, 0x0066, 0x6600, 0x0e00, 0x0000,
0x0606, 0x0606, 0x3232, 0x0000, 0x0000, 0x0060, 0x6000, 0x0000,
0x3232, 0x0100, 0x0000, 0x307a, 0x7a66, 0x0610, 0x0000, 0x005b,
0x66f6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0060, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x7c00, 0x001e, 0x0e00, 0x0000,
0x0000, 0x0000, 0x0018, 0x0000, 0x3838, 0x0000, 0x0000, 0x00fe,
0x0000, 0x0030, 0x0c7c, 0xfeee, 0x0100, 0x0008, 0x7838, 0x05a0,
0xba02, 0x3a3a, 0x82b8, 0xb8ba, 0xbaba, 0x0078, 0x0000, 0x0dd8,
0x0018, 0x6666, 0x3e66, 0x6c18, 0x0660, 0x6600, 0x0000, 0x0006,
0x3c18, 0x3c7e, 0x0c7e, 0x1c7e, 0x3c3c, 0x0000, 0x0000, 0x003c,
0x3818, 0x7c3c, 0x787e, 0x7e3e, 0x667e, 0x06cc, 0x60c6, 0x663c,
0x7c3c, 0xf83e, 0x7e66, 0x66c6, 0x6666, 0x7e1e, 0x6078, 0x1000,
0x7000, 0x6000, 0x0600, 0x0e00, 0x6018, 0x0cc0, 0x3800, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0018, 0x1830, 0x0000,
0x3c66, 0x0c3c, 0x6630, 0x3600, 0x3c66, 0x3066, 0x3c30, 0x663c,
0x1800, 0x7e3c, 0x6630, 0x3c30, 0x6666, 0x6618, 0x1e66, 0x180e,
0x0c0c, 0x0c0c, 0x7a7a, 0x0000, 0x1800, 0x0020, 0x2000, 0x0000,
0x7a7a, 0x3d00, 0x007e, 0x184c, 0x4c66, 0x0c7c, 0x7a7c, 0x7c5f,
0x6666, 0x667c, 0x1e7e, 0x7e38, 0x1e7e, 0x6e3c, 0x3c7e, 0x6c1c,
0xfe36, 0x7e6e, 0x3e7c, 0xd67e, 0x387e, 0x7e7e, 0x6e1c, 0x0000,
0x0018, 0xfe00, 0xfe00, 0x0000, 0x103c, 0x383e, 0x1e10, 0x3e7c,
0x0000, 0x6006, 0x0e18, 0x0000, 0x6c7c, 0x0000, 0x3030, 0x78fe,
0x0018, 0x3c38, 0x1c38, 0xfec6, 0x013c, 0x000e, 0x4040, 0x05a0,
0xc606, 0x0606, 0xc6c0, 0xc0c6, 0xc6c6, 0x0040, 0x0000, 0x0628,
0x0018, 0x6666, 0x7e66, 0x6c18, 0x0c30, 0x6618, 0x0000, 0x0006,
0x7e18, 0x7e7e, 0x0c7e, 0x3c7e, 0x7e7e, 0x0000, 0x0e00, 0xe07e,
0x7c3c, 0x7e7e, 0x7c7e, 0x7e7e, 0x667e, 0x06cc, 0x60c6, 0x667e,
0x7e7e, 0xfc7e, 0x7e66, 0x66c6, 0x6666, 0x7e1e, 0x6078, 0x3800,
0x3800, 0x6000, 0x0600, 0x1e00, 0x6018, 0x0cc0, 0x3800, 0x0000,
0x0000, 0x0000, 0x1800, 0x0000, 0x0000, 0x0018, 0x1830, 0x0000,
0x7e66, 0x1866, 0x6618, 0x1c00, 0x6666, 0x1866, 0x6618, 0x1818,
0x7e00, 0xf866, 0x6618, 0x6618, 0x6600, 0x0018, 0x3866, 0x3c1e,
0x1818, 0x1818, 0x4c4c, 0x0000, 0x1800, 0x0020, 0x2018, 0x0000,
0x4c4c, 0x7e00, 0x00fe, 0x0000, 0x0000, 0x1810, 0xcac6, 0xc655,
0x0066, 0x767c, 0x1e7e, 0x7e38, 0x1e7e, 0x6e3c, 0x3e7e, 0x6e1c,
0xfe36, 0x7e6e, 0x3e7e, 0xd67e, 0x387e, 0x3e7e, 0x6e36, 0x0000,
0x003c, 0x7e00, 0xfe00, 0x0002, 0x107e, 0x6c20, 0x1010, 0x7efe,
0x0018, 0x700e, 0x1918, 0x1802, 0x447c, 0x0000, 0x7848, 0x1800,
0x003c, 0x242c, 0x34ba, 0xfed6, 0x0366, 0x180f, 0x7040, 0x05a0,
0xc606, 0x0606, 0xc6c0, 0xc0c6, 0xc6c6, 0x0070, 0x0000, 0x07d0,
0x0018, 0x66ff, 0x606c, 0x3818, 0x1c38, 0x3c18, 0x0000, 0x0006,
0x6638, 0x660c, 0x1c60, 0x7006, 0x6666, 0x1818, 0x1c7e, 0x7066,
0xe67e, 0x6666, 0x6e60, 0x6060, 0x6618, 0x06d8, 0x60ee, 0x6666,
0x6666, 0xcc60, 0x1866, 0x66c6, 0x6666, 0x0c18, 0x6018, 0x3800,
0x1c00, 0x6000, 0x0600, 0x1800, 0x6000, 0x00c0, 0x1800, 0x0000,
0x0000, 0x0000, 0x1800, 0x0000, 0x0000, 0x0018, 0x1830, 0x0000,
0x6600, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3c3c,
0x7e00, 0xd800, 0x0000, 0x0000, 0x003c, 0x663c, 0x3066, 0x6618,
0x0000, 0x0000, 0x0000, 0x3c3c, 0x0000, 0x0023, 0x2318, 0x0000,
0x0000, 0x6601, 0x00d8, 0x3c3c, 0x3c00, 0x0010, 0xca82, 0x8251,
0xe666, 0x760c, 0x060c, 0x0618, 0x0466, 0x660c, 0x0606, 0x3e0c,
0xfe36, 0x6666, 0x3e06, 0xd666, 0x1806, 0x3666, 0x6632, 0x0066,
0x6266, 0x6202, 0x601e, 0x007e, 0x7c66, 0xc630, 0x7c7c, 0xe0c6,
0x7e18, 0x381c, 0x1b18, 0x183e, 0x6c7c, 0x0000, 0x4818, 0x3000,
0x0066, 0x24e6, 0x6792, 0xfc92, 0x03c3, 0x3c09, 0x4040, 0x0db0,
0xc606, 0x0606, 0xc6c0, 0xc0c6, 0xc6c6, 0x7c40, 0x0000, 0x2e10,
0x0018, 0x66ff, 0x600c, 0x3818, 0x1818, 0x3c18, 0x0000, 0x000c,
0x6638, 0x660c, 0x1c60, 0x6006, 0x6666, 0x1818, 0x387e, 0x3866,
0xc266, 0x6666, 0x6660, 0x6060, 0x6618, 0x06d8, 0x60ee, 0x7666,
0x6666, 0xcc60, 0x1866, 0x66c6, 0x3c66, 0x0c18, 0x3018, 0x6c00,
0x0c3c, 0x7c3c, 0x3e3c, 0x183e, 0x7c38, 0x0ccc, 0x186c, 0x3c3c,
0x7c3e, 0x7c3e, 0x7e66, 0x66c6, 0x6666, 0x7e18, 0x1830, 0x6218,
0x6666, 0x3c3c, 0x3c3c, 0x3c3c, 0x3c3c, 0x3c38, 0x3838, 0x7e7e,
0x6076, 0xd83c, 0x3c3c, 0x6666, 0x667e, 0x667e, 0x3066, 0x6618,
0x3c38, 0x3c66, 0x3c66, 0x3e7e, 0x1800, 0x0026, 0x2600, 0x0000,
0x3c3c, 0x663d, 0x7ed8, 0x7e7e, 0x7e00, 0x0010, 0xcaba, 0xba00,
0x6666, 0x3e0c, 0x060c, 0x6618, 0x0c66, 0x660c, 0x0606, 0x360c,
0xc636, 0x6636, 0x0606, 0xd666, 0x1806, 0x3666, 0x7618, 0x10f7,
0xf666, 0x607e, 0x3038, 0x66fc, 0xc642, 0xc618, 0xd6d6, 0xc0c6,
0x7e18, 0x1c38, 0x1b18, 0x007c, 0x3838, 0x001f, 0x4830, 0x1800,
0x00c3, 0x2483, 0xc1d6, 0xfcba, 0x0691, 0x3c08, 0x4038, 0x0db0,
0x8202, 0x3a3a, 0xbab8, 0xb882, 0xbaba, 0x7e78, 0x0000, 0x39e0,
0x0018, 0x6666, 0x7c18, 0x7018, 0x1818, 0xff7e, 0x007e, 0x000c,
0x6618, 0x0c18, 0x3c7c, 0x600c, 0x3c7e, 0x1818, 0x7000, 0x1c0c,
0xda66, 0x7e60, 0x667c, 0x7c6e, 0x7e18, 0x06f0, 0x60fe, 0x7666,
0x6666, 0xcc70, 0x1866, 0x66c6, 0x3c3c, 0x1818, 0x3018, 0x6c00,
0x043e, 0x7e7c, 0x7e7e, 0x7e7e, 0x7e38, 0x0cdc, 0x18fe, 0x7e7e,
0x7e7e, 0x7e7e, 0x7e66, 0x66c6, 0x6666, 0x7e38, 0x1838, 0xf218,
0x6066, 0x7e3e, 0x3e3e, 0x3e7c, 0x7e7e, 0x7e38, 0x3838, 0x6666,
0x607f, 0xde7e, 0x7e7e, 0x6666, 0x6666, 0x6666, 0x307e, 0x6618,
0x3e38, 0x7e66, 0x7e66, 0x0666, 0x1800, 0x002c, 0x2c18, 0x1ab0,
0x3e7e, 0x6e7e, 0xffde, 0x6666, 0x6600, 0x0010, 0xcaa2, 0xaa00,
0x6666, 0x3c0c, 0x0e0c, 0x6618, 0x0c66, 0x6600, 0x0606, 0x660c,
0xc636, 0x763e, 0x0606, 0xf666, 0x1806, 0x3676, 0x3e3c, 0x1099,
0xdc66, 0x60fc, 0x186c, 0x6690, 0x8242, 0xc63c, 0x9292, 0xc0c6,
0x007e, 0x0e70, 0x1818, 0x7e40, 0x0000, 0x0010, 0x4860, 0x4800,
0x0081, 0xe783, 0xc1c6, 0xf838, 0x0691, 0x3c08, 0x0000, 0x1db8,
0x0000, 0x7c7c, 0x7c7c, 0x7c00, 0x7c7c, 0x0600, 0x0000, 0x3800,
0x0018, 0x6666, 0x3e18, 0x7018, 0x1818, 0xff7e, 0x007e, 0x0018,
0x6e18, 0x0c18, 0x3c7e, 0x7c0c, 0x3c3e, 0x1818, 0xe000, 0x0e0c,
0xd666, 0x7c60, 0x667c, 0x7c6e, 0x7e18, 0x06f0, 0x60d6, 0x7e66,
0x6666, 0xfc38, 0x1866, 0x66d6, 0x183c, 0x1818, 0x1818, 0xc600,
0x0006, 0x6660, 0x6666, 0x7e66, 0x6618, 0x0cf8, 0x18fe, 0x6666,
0x6666, 0x6660, 0x1866, 0x66d6, 0x3c66, 0x0cf0, 0x181e, 0xbe3c,
0x6066, 0x6606, 0x0606, 0x0660, 0x6666, 0x6618, 0x1818, 0x6666,
0x7c1b, 0xde66, 0x6666, 0x6666, 0x6666, 0x6660, 0x303c, 0x7c7e,
0x0618, 0x6666, 0x6676, 0x3e66, 0x1800, 0x0018, 0x1818, 0x36d8,
0x0666, 0x6e66, 0xdbde, 0x6666, 0x6600, 0x0010, 0xcaa2, 0xb200,
0x6666, 0x3c0c, 0x1e0c, 0x6618, 0x0c66, 0x6600, 0x060e, 0x660c,
0xc636, 0x7618, 0x3606, 0xf666, 0x1806, 0x3676, 0x0e66, 0x3899,
0x887c, 0x60a8, 0x0cc6, 0x6630, 0x827e, 0xc666, 0x9292, 0xfcc6,
0x7e7e, 0x1c38, 0x1818, 0x7e02, 0x0000, 0x00d0, 0x4878, 0x3000,
0x00e7, 0x81e6, 0x67d6, 0xfaba, 0x8c9d, 0x3c78, 0x1e1c, 0x399c,
0x8202, 0xb83a, 0x3a3a, 0xba02, 0xba3a, 0x060e, 0x07f0, 0x0000,
0x0018, 0x00ff, 0x0630, 0xde00, 0x1818, 0x3c18, 0x0000, 0x0018,
0x7618, 0x180c, 0x6c06, 0x7e18, 0x6606, 0x0000, 0x707e, 0x1c18,
0xd67e, 0x6660, 0x6660, 0x6066, 0x6618, 0x06d8, 0x60d6, 0x7e66,
0x7e66, 0xf81c, 0x1866, 0x66d6, 0x1818, 0x3018, 0x1818, 0xc600,
0x003e, 0x6660, 0x6666, 0x1866, 0x6618, 0x0cf0, 0x18d6, 0x6666,
0x6666, 0x6070, 0x1866, 0x66d6, 0x3c66, 0x18f0, 0x181e, 0x9c24,
0x6066, 0x663e, 0x3e3e, 0x3e60, 0x6666, 0x6618, 0x1818, 0x7e7e,
0x7c7b, 0xf866, 0x6666, 0x6666, 0x6666, 0x6660, 0xfe18, 0x6618,
0x3e18, 0x6666, 0x667e, 0x7e66, 0x3000, 0x0030, 0x3218, 0x6c6c,
0x3e66, 0x766e, 0xdbd8, 0x7e7e, 0x6600, 0x0000, 0x7aa2, 0xba00,
0x6666, 0x6e0c, 0x360c, 0x6618, 0x0c66, 0x6600, 0x061c, 0x660c,
0xc636, 0x061c, 0x3606, 0xc666, 0x1806, 0x3606, 0x0666, 0x38ef,
0x8866, 0x6028, 0x0cc6, 0x6630, 0x8242, 0x6c42, 0x9292, 0xfcc6,
0x7e18, 0x381c, 0x1818, 0x003e, 0x0000, 0x00d0, 0x0000, 0x0000,
0x0024, 0xc32c, 0x3492, 0xf292, 0x8c81, 0x3cf8, 0x1012, 0x799e,
0xc606, 0xc006, 0x0606, 0xc606, 0xc606, 0x7e10, 0x0ff8, 0x0000,
0x0018, 0x00ff, 0x0636, 0xde00, 0x1818, 0x3c18, 0x0000, 0x0030,
0x6618, 0x180c, 0x6c06, 0x6618, 0x6606, 0x0000, 0x387e, 0x3818,
0xdc7e, 0x6660, 0x6660, 0x6066, 0x6618, 0x06d8, 0x60c6, 0x6e66,
0x7c66, 0xd80e, 0x1866, 0x66fe, 0x3c18, 0x3018, 0x0c18, 0x0000,
0x007e, 0x6660, 0x667e, 0x1866, 0x6618, 0x0cf8, 0x18d6, 0x6666,
0x6666, 0x603c, 0x1866, 0x66fe, 0x1866, 0x1838, 0x1838, 0x0066,
0x6066, 0x7e7e, 0x7e7e, 0x7e60, 0x7e7e, 0x7e18, 0x1818, 0x7e7e,
0x60ff, 0xf866, 0x6666, 0x6666, 0x6666, 0x6666, 0x307e, 0x6618,
0x7e18, 0x6666, 0x667e, 0x6666, 0x307e, 0x7e6e, 0x6618, 0xd836,
0x7e66, 0x767e, 0xdfd8, 0x7e7e, 0x6600, 0x0000, 0x0aba, 0xaa00,
0x6666, 0x6e0c, 0x360c, 0x6618, 0x0c66, 0x6600, 0x0630, 0x6e0c,
0xc636, 0x7e0e, 0x3606, 0xc666, 0x1806, 0x3606, 0x063c, 0x6c66,
0xdc66, 0x6028, 0x18c6, 0x6630, 0x8242, 0x2842, 0x9292, 0xc0c6,
0x0018, 0x700e, 0x1818, 0x187c, 0x0000, 0x1850, 0x0000, 0x0000,
0x0024, 0x6638, 0x1cba, 0xf6d6, 0xd8c3, 0x7e70, 0x1c1c, 0x718e,
0xc606, 0xc006, 0x0606, 0xc606, 0xc606, 0x660c, 0x1fec, 0x0000,
0x0000, 0x0066, 0x7e66, 0xcc00, 0x1818, 0x6618, 0x1800, 0x1830,
0x6618, 0x3066, 0x7e06, 0x6630, 0x6606, 0x1818, 0x1c00, 0x7018,
0xc066, 0x6666, 0x6660, 0x6066, 0x6618, 0x66cc, 0x60c6, 0x6e66,
0x6066, 0xcc06, 0x1866, 0x3cfe, 0x3c18, 0x6018, 0x0c18, 0x0000,
0x0066, 0x6660, 0x6660, 0x1866, 0x6618, 0x0cd8, 0x18d6, 0x6666,
0x6666, 0x600e, 0x1866, 0x3cfe, 0x3c66, 0x3018, 0x1830, 0x0042,
0x6666, 0x6066, 0x6666, 0x6660, 0x6060, 0x6018, 0x1818, 0x6666,
0x60d8, 0xd866, 0x6666, 0x6666, 0x6666, 0x667e, 0x3018, 0x6618,
0x6618, 0x6666, 0x666e, 0x6666, 0x667e, 0x7ed3, 0xce18, 0x6c6c,
0x6666, 0x6676, 0xd8d8, 0x6666, 0x6600, 0x0000, 0x0a82, 0x8200,
0x6666, 0x667e, 0x360c, 0x6618, 0x0c66, 0x7e00, 0x3e30, 0x6e7c,
0xfe7e, 0x7e7e, 0x3606, 0xfee6, 0x1806, 0x3e06, 0x0618, 0x6c00,
0xf666, 0x6028, 0x30c6, 0x6630, 0xc666, 0xaa66, 0xd6d6, 0xc0c6,
0x7e18, 0x6006, 0x18d8, 0x1840, 0x0000, 0x3c70, 0x0000, 0x0000,
0x0024, 0x3c30, 0x0c38, 0xe6c6, 0x5866, 0xff00, 0x1014, 0x718e,
0xc606, 0xc006, 0x0606, 0xc606, 0xc606, 0x6602, 0x1804, 0x0000,
0x0000, 0x0066, 0x7c66, 0xcc00, 0x1c38, 0x6600, 0x1800, 0x1860,
0x6618, 0x3066, 0x7e66, 0x6630, 0x660e, 0x1818, 0x0e00, 0xe000,
0xe266, 0x6666, 0x6e60, 0x6066, 0x6618, 0x66cc, 0x60c6, 0x6666,
0x606a, 0xcc06, 0x1866, 0x3cee, 0x6618, 0x6018, 0x0618, 0x0000,
0x0066, 0x6660, 0x6660, 0x187e, 0x6618, 0x0ccc, 0x18c6, 0x6666,
0x6666, 0x6006, 0x1866, 0x3cee, 0x3c7e, 0x3018, 0x1830, 0x00c3,
0x6666, 0x6066, 0x6666, 0x6660, 0x6060, 0x6018, 0x1818, 0x6666,
0x60d8, 0xd866, 0x6666, 0x6666, 0x7e66, 0x663c, 0x3018, 0x7c18,
0x6618, 0x6666, 0x6666, 0x7e7e, 0x6660, 0x0606, 0x1a18, 0x36d8,
0x6666, 0x6666, 0xd8d8, 0x6666, 0x6600, 0x0000, 0x0ac6, 0xc600,
0x66f6, 0x627e, 0x360c, 0x6618, 0x0466, 0x7e00, 0x3c30, 0x6e7c,
0x7c7e, 0x7e7e, 0x3606, 0xfee6, 0x1806, 0x3e06, 0x064c, 0xc600,
0x627c, 0x6028, 0x606c, 0x7f20, 0x7c7e, 0xee7e, 0x7c7c, 0xe0c6,
0x7e00, 0x0000, 0x18d8, 0x0000, 0x0000, 0x3c20, 0x0000, 0x0000,
0x003c, 0x1800, 0x007c, 0xeeee, 0x703c, 0x1000, 0x1012, 0x6186,
0xba02, 0xb83a, 0x023a, 0xba02, 0xba3a, 0x7e1c, 0x1804, 0x0000,
0x0018, 0x0000, 0x1800, 0xfe00, 0x0c30, 0x0000, 0x1800, 0x1860,
0x7e7e, 0x7e7e, 0x0c7e, 0x7e30, 0x7e3c, 0x1818, 0x0000, 0x0018,
0x7e66, 0x7e7e, 0x7c7e, 0x607e, 0x667e, 0x7ec6, 0x7ec6, 0x667e,
0x607c, 0xc67e, 0x187e, 0x18c6, 0x6618, 0x7e1e, 0x0678, 0x00fe,
0x007e, 0x7e7e, 0x7e7e, 0x183e, 0x663c, 0x0cce, 0x3cc6, 0x667e,
0x7e7e, 0x607e, 0x1e7e, 0x18c6, 0x663e, 0x7e18, 0x1830, 0x00ff,
0x7e7e, 0x7e7e, 0x7e7e, 0x7e7e, 0x7e7e, 0x7e3c, 0x3c3c, 0x6666,
0x7eff, 0xde7e, 0x7e7e, 0x7e7e, 0x3e7e, 0x7e18, 0x7f18, 0x6c18,
0x7e3c, 0x7e7e, 0x6666, 0x3e3c, 0x7e60, 0x060c, 0x3218, 0x1ab0,
0x7e7e, 0x7e7e, 0xfffe, 0x6666, 0x7e00, 0x0000, 0x0a7c, 0x7c00,
0xf6f6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x3000, 0x0000, 0x1806, 0x0006, 0x066c, 0xc600,
0x006c, 0x6000, 0xfe38, 0x5d00, 0x103c, 0x6c3c, 0x1010, 0x7ec6,
0x007e, 0x7e7e, 0x1898, 0x0000, 0x0000, 0x1800, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x3800, 0x0000, 0x4182,
0x7c00, 0x7c7c, 0x007c, 0x7c00, 0x7c7c, 0x3c00, 0x1004, 0x0000,
0x0018, 0x0000, 0x1800, 0x7600, 0x0660, 0x0000, 0x1800, 0x1860,
0x3c7e, 0x7e3c, 0x0c3c, 0x3c30, 0x3c38, 0x1818, 0x0000, 0x0018,
0x3c66, 0x7c3c, 0x787e, 0x603c, 0x667e, 0x3cc6, 0x7ec6, 0x663c,
0x6036, 0xc67c, 0x183c, 0x1882, 0x6618, 0x7e1e, 0x0678, 0x00fe,
0x003e, 0x7c3e, 0x3e3e, 0x1806, 0x663c, 0x0cc6, 0x3cc6, 0x663c,
0x7c3e, 0x607c, 0x0e3e, 0x1882, 0x6606, 0x7e18, 0x1830, 0x0000,
0x3c3e, 0x3e3e, 0x3e3e, 0x3e3e, 0x3e3e, 0x3e3c, 0x3c3c, 0x6666,
0x7e7f, 0xde3c, 0x3c3c, 0x3e3e, 0x063c, 0x3c18, 0xff18, 0x6070,
0x3e3c, 0x3c3e, 0x6666, 0x0000, 0x3c60, 0x0618, 0x3f18, 0x0000,
0x3e3c, 0xbcbc, 0x7f7e, 0x6666, 0x3c00, 0x0000, 0x0a00, 0x0000,
0x0e0e, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x3000, 0x0000, 0x1806, 0x0006, 0x0638, 0x0000,
0x0060, 0xf000, 0xfe00, 0xc000, 0x1000, 0x0000, 0xf010, 0x3ec6,
0x007e, 0x7e7e, 0x1870, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x2000, 0x1000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1e3c, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0030, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x007e, 0x0000, 0x7c00, 0x0000, 0x0000,
0x6006, 0x0000, 0x0000, 0x0000, 0x007e, 0x000e, 0x18e0, 0x0000,
0x0c00, 0x0000, 0x0000, 0x000c, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x7e00, 0x0000, 0x0000, 0x4060,
0x0000, 0x0000, 0x0000, 0x7e7e, 0x0000, 0x001f, 0x0218, 0x0000,
0x0000, 0x8080, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x3c7c, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x3000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0040, 0x0000, 0x0000, 0x8000, 0x7c00, 0x0000, 0xe000, 0x0000,
0x0000, 0x0000, 0x1800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1754, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x007c, 0x0000, 0x7800, 0x0000, 0x0000,
0x6006, 0x0000, 0x0000, 0x0000, 0x007c, 0x0000, 0x0000, 0x0000,
0x3800, 0x0000, 0x0000, 0x0038, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x7c00, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x3878, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x1800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};
const struct font_head fnt_st_8x16 = {
1, /* WORD font_id */
10, /* WORD point */
"8x16 system font", /* BYTE name[32] */
0, /* WORD first_ade */
255, /* WORD last_ade */
13, /* UWORD top */
11, /* UWORD ascent */
8, /* UWORD half */
2, /* UWORD descent */
2, /* UWORD bottom */
7, /* UWORD max_char_width */
8, /* UWORD max_cell_width */
1, /* UWORD left_offset */
7, /* UWORD right_offset */
1, /* UWORD thicken */
1, /* UWORD ul_size */
0x5555, /* UWORD lighten */
0x5555, /* UWORD skew */
F_STDFORM | F_MONOSPACE | F_DEFAULT, /* UWORD flags */
0, /* UBYTE *hor_table */
off_table, /* UWORD *off_table */
dat_table, /* UWORD *dat_table */
256, /* UWORD form_width */
16, /* UWORD form_height */
0, /* struct font * next_font */
0 /* UWORD next_seg */
};

294
BaS_gcc/video/offscreen.c Normal file
View File

@@ -0,0 +1,294 @@
/*
* offscreen.c
*
* based from Emutos / BDOS
*
* Copyright (c) 2001 Lineo, Inc.
*
* Authors: Karl T. Braun, Martin Doering, Laurent Vogel
*
* This file is distributed under the GPL, version 2 or at your
* option any later version.
*/
#include "bas_types.h"
#include "bas_string.h"
#include "fb.h"
#undef DEBUG
/* MD - Memory Descriptor */
#define MD struct _md_
MD
{
MD *m_link;
long m_start;
long m_length;
void *m_own;
};
/* MPB - Memory Partition Block */
#define MPB struct _mpb
MPB
{
MD *mp_mfl;
MD *mp_mal;
MD *mp_rover;
};
#define MAXMD 256
static MD tab_md[MAXMD];
static MPB pmd;
static long wrap;
static void *xmgetblk(void)
{
int i;
for (i = 0; i < MAXMD; i++)
{
if(tab_md[i].m_own == NULL)
{
tab_md[i].m_own = (void*)1L;
return(&tab_md[i]);
}
}
return(NULL);
}
static void xmfreblk(void *m)
{
int i = (int)(((long)m - (long)tab_md) / sizeof(MD));
if((i > 0) && (i < MAXMD))
tab_md[i].m_own = NULL;
}
static MD *ffit(long amount, MPB *mp)
{
MD *p,*q,*p1; /* free list is composed of MD's */
int maxflg;
long maxval;
if(amount != -1)
{
#if 1
amount += (wrap - 1);
amount /= wrap;
amount *= wrap; /* screen line alignment */
#else
amount += 15; /* 16 bytes alignment */
amount &= 0xFFFFFFF0;
#endif
}
if((q = mp->mp_rover) == 0) /* get rotating pointer */
return(0) ;
maxval = 0;
maxflg = ((amount == -1) ? true : false) ;
p = q->m_link; /* start with next MD */
do /* search the list for an MD with enough space */
{
if(p == NULL)
{
/* at end of list, wrap back to start */
q = (MD *) &mp->mp_mfl; /* q => mfl field */
p = q->m_link; /* p => 1st MD */
}
if((!maxflg) && (p->m_length >= amount))
{
/* big enough */
if(p->m_length == amount)
q->m_link = p->m_link; /* take the whole thing */
else
{
/* break it up - 1st allocate a new
MD to describe the remainder */
p1 = xmgetblk();
if(p1 == NULL)
return(NULL);
/* init new MD */
p1->m_length = p->m_length - amount;
p1->m_start = p->m_start + amount;
p1->m_link = p->m_link;
p->m_length = amount; /* adjust allocated block */
q->m_link = p1;
}
/* link allocate block into allocated list,
mark owner of block, & adjust rover */
p->m_link = mp->mp_mal;
mp->mp_mal = p;
mp->mp_rover = (q == (MD *) &mp->mp_mfl ? q->m_link : q);
return(p); /* got some */
}
else if(p->m_length > maxval)
maxval = p->m_length;
p = ( q=p )->m_link;
}
while(q != mp->mp_rover);
/* return either the max, or 0 (error) */
if(maxflg)
{
maxval -= 15; /* 16 bytes alignment */
if(maxval < 0)
maxval = 0;
else
maxval &= 0xFFFFFFF0;
}
return(maxflg ? (MD *) maxval : 0);
}
static void freeit(MD *m, MPB *mp)
{
MD *p, *q;
q = NULL;
for (p = mp->mp_mfl; p ; p = (q=p) -> m_link)
{
if(m->m_start <= p->m_start)
break;
}
m->m_link = p;
if(q)
q->m_link = m;
else
mp->mp_mfl = m;
if(!mp->mp_rover)
mp->mp_rover = m;
if(p)
{
if(m->m_start + m->m_length == p->m_start)
{ /* join to higher neighbor */
m->m_length += p->m_length;
m->m_link = p->m_link;
if(p == mp->mp_rover)
mp->mp_rover = m;
xmfreblk(p);
}
}
if(q)
{
if(q->m_start + q->m_length == m->m_start)
{ /* join to lower neighbor */
q->m_length += m->m_length;
q->m_link = m->m_link;
if(m == mp->mp_rover)
mp->mp_rover = q;
xmfreblk(m);
}
}
}
long offscreen_free(struct fb_info *info, long addr)
{
MD *p,**q;
MPB *mpb;
#ifdef DEBUG
char buf[10];
Funcs_puts("radeon_offscreen_free(0x");
Funcs_ltoa(buf, addr, 16);
Funcs_puts(buf);
Funcs_puts("\r\n");
#endif
//*vblsem = 0;
mpb = &pmd;
for (p = *(q = &mpb->mp_mal); p; p = *(q = &p->m_link))
{
if(addr == p->m_start)
break;
}
if(!p)
{
// *vblsem = 1;
return -1; //(EFAULT);
}
*q = p->m_link;
freeit(p,mpb);
//*vblsem = 1;
return(0);
}
long offscreen_alloc(struct fb_info *info, long amount)
{
long ret;
MD *m;
#ifdef DEBUG
char buf[10];
Funcs_puts("radeon_offscreen_alloc(0x");
Funcs_ltoa(buf, amount, 16);
Funcs_puts(buf);
Funcs_puts(") = 0x");
#endif
// *vblsem = 0;
if(amount == -1L)
{
ret = (long)ffit(-1L,&pmd);
// *vblsem = 1;
return(ret);
}
if(amount <= 0 )
{
// *vblsem = 1;
return(0);
}
if((amount & 1))
amount++;
m = ffit(amount,&pmd);
if(m == NULL)
{
#ifdef DEBUG
Funcs_puts("0\r\n");
#endif
// *vblsem = 1;
return(0);
}
#ifdef DEBUG
Funcs_ltoa(buf, m->m_start, 16);
Funcs_puts(buf);
Funcs_puts("\r\n");
#endif
ret = (long)m->m_start;
// *vblsem = 1;
return(ret);
}
long offscren_reserved(struct fb_info *info)
{
return((long) info->ram_base + (long) info->ram_size);
}
void offscreen_init(struct fb_info *info)
{
#ifdef DEBUG
char buf[10];
#endif
long size_screen, max_offscreen_size;
wrap = (long) info->var.xres_virtual * (long)(info->var.bits_per_pixel / 8);
size_screen = (long)info->var.yres_virtual * wrap;
if(!size_screen)
size_screen = (long)info->screen_size;
pmd.mp_mfl = pmd.mp_rover = &tab_md[0];
tab_md[0].m_link = (MD *)NULL;
tab_md[0].m_start = (long)((unsigned long)info->ram_base + (unsigned long)size_screen);
tab_md[0].m_length = (long)info->ram_size - size_screen;
tab_md[0].m_own = (void *)1L;
max_offscreen_size = ((long)info->var.xres_virtual * 8192L * (long)(info->var.bits_per_pixel / 8)) - size_screen;
if(max_offscreen_size < 0)
max_offscreen_size = 0;
if(tab_md[0].m_length > max_offscreen_size)
tab_md[0].m_length = max_offscreen_size;
#ifdef DEBUG
Funcs_puts("offscreen_init start 0x");
Funcs_ltoa(buf, tab_md[0].m_start, 16);
Funcs_puts(buf);
Funcs_puts(", length 0x");
Funcs_ltoa(buf, tab_md[0].m_length, 16);
Funcs_puts(buf);
Funcs_puts(", ram_size 0x");
Funcs_ltoa(buf, (long)info->ram_size, 16);
Funcs_puts(buf);
Funcs_puts("\r\n");
#endif
pmd.mp_mal = (MD *)NULL;
}

1112
BaS_gcc/video/vdi_fill.c Normal file

File diff suppressed because it is too large Load Diff

885
BaS_gcc/video/videl.c Normal file
View File

@@ -0,0 +1,885 @@
/*
* videl.c - Falcon VIDEL support
*
* Copyright (c) 2013 The EmuTOS development team
*
* Authors:
* PES Petr Stehlik
* RFB Roger Burrows
*
* This file is distributed under the GPL, version 2 or at your
* option any later version. See doc/license.txt for details.
*/
#define DBG_VIDEL
#ifdef DBG_VIDEL
#define dbg(format, arg...) do { xprintf("DEBUG: %s(): " format, __FUNCTION__, ##arg); } while (0)
#else
#define dbg(format, arg...) do { ; } while (0)
#endif /* DBG_VIDEL */
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "bas_printf.h"
#include "screen.h"
#include "videl.h"
uint16_t *colorptr;
static const int32_t videl_dflt_palette[] = {
FRGB_WHITE, FRGB_RED, FRGB_GREEN, FRGB_YELLOW,
FRGB_BLUE, FRGB_MAGENTA, FRGB_CYAN, FRGB_LTGRAY,
FRGB_GRAY, FRGB_LTRED, FRGB_LTGREEN, FRGB_LTYELLOW,
FRGB_LTBLUE, FRGB_LTMAGENTA, FRGB_LTCYAN, FRGB_BLACK,
0xffff00ff, 0xeded00ed, 0xdddd00dd, 0xcccc00cc,
0xbaba00ba, 0xaaaa00aa, 0x99990099, 0x87870087,
0x77770077, 0x66660066, 0x54540054, 0x44440044,
0x33330033, 0x21210021, 0x11110011, 0x00000000,
0xff000000, 0xff000011, 0xff000021, 0xff000033,
0xff000044, 0xff000054, 0xff000066, 0xff000077,
0xff000087, 0xff000099, 0xff0000aa, 0xff0000ba,
0xff0000cc, 0xff0000dd, 0xff0000ed, 0xff0000ff,
0xed0000ff, 0xdd0000ff, 0xcc0000ff, 0xba0000ff,
0xaa0000ff, 0x990000ff, 0x870000ff, 0x770000ff,
0x660000ff, 0x540000ff, 0x440000ff, 0x330000ff,
0x210000ff, 0x110000ff, 0x000000ff, 0x001100ff,
0x002100ff, 0x003300ff, 0x004400ff, 0x005400ff,
0x006600ff, 0x007700ff, 0x008700ff, 0x009900ff,
0x00aa00ff, 0x00ba00ff, 0x00cc00ff, 0x00dd00ff,
0x00ed00ff, 0x00ff00ff, 0x00ff00ed, 0x00ff00dd,
0x00ff00cc, 0x00ff00ba, 0x00ff00aa, 0x00ff0099,
0x00ff0087, 0x00ff0077, 0x00ff0066, 0x00ff0054,
0x00ff0044, 0x00ff0033, 0x00ff0021, 0x00ff0011,
0x00ff0000, 0x11ff0000, 0x21ff0000, 0x33ff0000,
0x44ff0000, 0x54ff0000, 0x66ff0000, 0x77ff0000,
0x87ff0000, 0x99ff0000, 0xaaff0000, 0xbaff0000,
0xccff0000, 0xddff0000, 0xedff0000, 0xffff0000,
0xffed0000, 0xffdd0000, 0xffcc0000, 0xffba0000,
0xffaa0000, 0xff990000, 0xff870000, 0xff770000,
0xff660000, 0xff540000, 0xff440000, 0xff330000,
0xff210000, 0xff110000, 0xba000000, 0xba000011,
0xba000021, 0xba000033, 0xba000044, 0xba000054,
0xba000066, 0xba000077, 0xba000087, 0xba000099,
0xba0000aa, 0xba0000ba, 0xaa0000ba, 0x990000ba,
0x870000ba, 0x770000ba, 0x660000ba, 0x540000ba,
0x440000ba, 0x330000ba, 0x210000ba, 0x110000ba,
0x000000ba, 0x001100ba, 0x002100ba, 0x003300ba,
0x004400ba, 0x005400ba, 0x006600ba, 0x007700ba,
0x008700ba, 0x009900ba, 0x00aa00ba, 0x00ba00ba,
0x00ba00aa, 0x00ba0099, 0x00ba0087, 0x00ba0077,
0x00ba0066, 0x00ba0054, 0x00ba0044, 0x00ba0033,
0x00ba0021, 0x00ba0011, 0x00ba0000, 0x11ba0000,
0x21ba0000, 0x33ba0000, 0x44ba0000, 0x54ba0000,
0x66ba0000, 0x77ba0000, 0x87ba0000, 0x99ba0000,
0xaaba0000, 0xbaba0000, 0xbaaa0000, 0xba990000,
0xba870000, 0xba770000, 0xba660000, 0xba540000,
0xba440000, 0xba330000, 0xba210000, 0xba110000,
0x77000000, 0x77000011, 0x77000021, 0x77000033,
0x77000044, 0x77000054, 0x77000066, 0x77000077,
0x66000077, 0x54000077, 0x44000077, 0x33000077,
0x21000077, 0x11000077, 0x00000077, 0x00110077,
0x00210077, 0x00330077, 0x00440077, 0x00540077,
0x00660077, 0x00770077, 0x00770066, 0x00770054,
0x00770044, 0x00770033, 0x00770021, 0x00770011,
0x00770000, 0x11770000, 0x21770000, 0x33770000,
0x44770000, 0x54770000, 0x66770000, 0x77770000,
0x77660000, 0x77540000, 0x77440000, 0x77330000,
0x77210000, 0x77110000, 0x44000000, 0x44000011,
0x44000021, 0x44000033, 0x44000044, 0x33000044,
0x21000044, 0x11000044, 0x00000044, 0x00110044,
0x00210044, 0x00330044, 0x00440044, 0x00440033,
0x00440021, 0x00440011, 0x00440000, 0x11440000,
0x21440000, 0x33440000, 0x44440000, 0x44330000,
0x44210000, 0x44110000, FRGB_WHITE, FRGB_BLACK
};
int32_t falcon_shadow_palette[256]; /* real Falcon does this, used by vectors.S */
static int16_t ste_shadow_palette[16];
#define MON_ALL -1 /* code used in VMODE_ENTRY for match on mode only */
/*
* tables that cover all(?) valid Falcon modes
* note:
* . 256-colour and Truecolor modes are not currently supported by the VDI
*/
static const VMODE_ENTRY vga_init_table[] = {
/* the entries in this table are for VGA/NTSC (i.e. VGA 60Hz) and VGA/PAL
* (i.e. VGA 50Hz). in *this* table, each entry applies to four video modes:
* mode, mode|VIDEL_VERTICAL, mode|VIDEL_PAL, mode|VIDEL_VERTICAL|VIDEL_PAL
*/
{ 0x0011, MON_ALL, 0x0017, 0x0012, 0x0001, 0x020a, 0x0009, 0x0011, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0012, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x028a, 0x006b, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0013, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x029a, 0x007b, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0014, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x02ac, 0x0091, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0018, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x0273, 0x0050, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0019, MON_ALL, 0x0017, 0x0012, 0x0001, 0x020e, 0x000d, 0x0011, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x001a, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x02a3, 0x007c, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x001b, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x02ab, 0x0084, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0092, MON_ALL, 0x0017, 0x0012, 0x0001, 0x020e, 0x000d, 0x0011, 0x0419, 0x03af, 0x008f, 0x008f, 0x03af, 0x0415 },
{ 0x0098, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x0273, 0x0050, 0x0096, 0x0419, 0x03af, 0x008f, 0x008f, 0x03af, 0x0415 },
{ 0x0099, MON_ALL, 0x0017, 0x0012, 0x0001, 0x020e, 0x000d, 0x0011, 0x0419, 0x03af, 0x008f, 0x008f, 0x03af, 0x0415 },
{ -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
static const VMODE_ENTRY nonvga_init_table[] = {
/* the remaining entries are for TV+NTSC, TV+PAL, TV+NTSC+overscan, TV+PAL+overscan */
{ 0x0001, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0239, 0x0012, 0x0034, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x0002, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x000c, 0x006d, 0x00d8, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x0003, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x001c, 0x007d, 0x00d8, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x0004, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x002e, 0x008f, 0x00d8, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x0008, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x03f0, 0x009f, 0x01b4, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x0009, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0002, 0x0020, 0x0034, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x000a, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x004d, 0x00fd, 0x01b4, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x000b, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x005d, 0x010d, 0x01b4, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x0021, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0239, 0x0012, 0x0034, 0x0271, 0x0265, 0x002f, 0x007f, 0x020f, 0x026b },
{ 0x0022, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x000c, 0x006d, 0x00d8, 0x0271, 0x0265, 0x002f, 0x007f, 0x020f, 0x026b },
{ 0x0023, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x001c, 0x007d, 0x00d8, 0x0271, 0x0265, 0x002f, 0x007f, 0x020f, 0x026b },
{ 0x0024, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x002e, 0x008f, 0x00d8, 0x0271, 0x0265, 0x002f, 0x007f, 0x020f, 0x026b },
{ 0x0028, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x03ef, 0x00a0, 0x01b2, 0x0271, 0x0265, 0x002f, 0x007f, 0x020f, 0x026b },
{ 0x0029, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0002, 0x0020, 0x0034, 0x0271, 0x0265, 0x002f, 0x007f, 0x020f, 0x026b },
{ 0x002a, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x004d, 0x00fe, 0x01b2, 0x0271, 0x0265, 0x002f, 0x007f, 0x020f, 0x026b },
{ 0x002b, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x005d, 0x010e, 0x01b2, 0x0271, 0x0265, 0x002f, 0x007f, 0x020f, 0x026b },
{ 0x0041, MON_VGA, 0x003e, 0x0030, 0x0008, 0x0239, 0x0012, 0x0034, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0041, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0232, 0x001b, 0x0034, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0042, MON_VGA, 0x00fe, 0x00c9, 0x0027, 0x000c, 0x006d, 0x00d8, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0042, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x02ec, 0x008d, 0x00d8, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0043, MON_VGA, 0x00fe, 0x00c9, 0x0027, 0x001c, 0x007d, 0x00d8, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0043, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x02fc, 0x009d, 0x00d8, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0044, MON_VGA, 0x00fe, 0x00c9, 0x0027, 0x002e, 0x008f, 0x00d8, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0044, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x000e, 0x00af, 0x00d8, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0048, MON_VGA, 0x01ff, 0x0197, 0x0050, 0x03f0, 0x009f, 0x01b4, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0048, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x03b0, 0x00df, 0x01b4, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0049, MON_VGA, 0x003e, 0x0030, 0x0008, 0x023b, 0x001c, 0x0034, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0049, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0237, 0x0020, 0x0034, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x004a, MON_VGA, 0x01ff, 0x0197, 0x0050, 0x004d, 0x00fd, 0x01b4, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x004a, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x000d, 0x013d, 0x01b4, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x004b, MON_VGA, 0x01ff, 0x0197, 0x0050, 0x005d, 0x010d, 0x01b4, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x004b, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x001d, 0x014d, 0x01b4, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x0061, MON_VGA, 0x003e, 0x0030, 0x0008, 0x0239, 0x0012, 0x0034, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0061, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0232, 0x001b, 0x0034, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0062, MON_VGA, 0x00fe, 0x00cb, 0x0027, 0x000c, 0x006d, 0x00d8, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0062, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x02ec, 0x008d, 0x00d8, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0063, MON_VGA, 0x00fe, 0x00cb, 0x0027, 0x001c, 0x007d, 0x00d8, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0063, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x02fc, 0x009d, 0x00d8, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0064, MON_VGA, 0x00fe, 0x00cb, 0x0027, 0x002e, 0x008f, 0x00d8, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0064, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x000e, 0x00af, 0x00d8, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0068, MON_VGA, 0x01fe, 0x0199, 0x0050, 0x03ef, 0x00a0, 0x01b2, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0068, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x03af, 0x00e0, 0x01b2, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0069, MON_VGA, 0x003e, 0x0030, 0x0008, 0x023b, 0x001c, 0x0034, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0069, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0237, 0x0020, 0x0034, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x006a, MON_VGA, 0x01fe, 0x0199, 0x0050, 0x004d, 0x00fe, 0x01b2, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x006a, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x000d, 0x013e, 0x01b2, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x006b, MON_VGA, 0x01fe, 0x0199, 0x0050, 0x005d, 0x010e, 0x01b2, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x006b, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x001d, 0x014e, 0x01b2, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x0082, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x0088, MON_MONO, 0x001a, 0x0000, 0x0000, 0x020f, 0x000c, 0x0014, 0x03e9, 0x0000, 0x0000, 0x0043, 0x0363, 0x03e7 },
{ 0x0088, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x03f0, 0x009f, 0x01b4, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x0089, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x00a2, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x0271, 0x0265, 0x002f, 0x006f, 0x01ff, 0x026b },
{ 0x00a8, MON_MONO, 0x001a, 0x0000, 0x0000, 0x020f, 0x000c, 0x0014, 0x03e9, 0x0000, 0x0000, 0x0043, 0x0363, 0x03e7 },
{ 0x00a8, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x03ef, 0x00a0, 0x01b2, 0x0271, 0x0265, 0x002f, 0x007f, 0x020f, 0x026b },
{ 0x00a9, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x0271, 0x0265, 0x002f, 0x006f, 0x01ff, 0x026b },
{ 0x00c2, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x00c8, MON_MONO, 0x001a, 0x0000, 0x0000, 0x020f, 0x000c, 0x0014, 0x03e9, 0x0000, 0x0000, 0x0043, 0x0363, 0x03e7 },
{ 0x00c8, MON_VGA, 0x01ff, 0x0197, 0x0050, 0x03f0, 0x009f, 0x01b4, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x00c8, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x03b0, 0x00df, 0x01b4, 0x020d, 0x0201, 0x0016, 0x0025, 0x0205, 0x0207 },
{ 0x00c9, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x00e2, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x0271, 0x0265, 0x002f, 0x006f, 0x01ff, 0x026b },
{ 0x00e8, MON_MONO, 0x001a, 0x0000, 0x0000, 0x020f, 0x000c, 0x0014, 0x03e9, 0x0000, 0x0000, 0x0043, 0x0363, 0x03e7 },
{ 0x00e8, MON_VGA, 0x01fe, 0x0199, 0x0050, 0x03ef, 0x00a0, 0x01b2, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x00e8, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x03af, 0x00e0, 0x01b2, 0x0271, 0x0265, 0x002f, 0x0057, 0x0237, 0x026b },
{ 0x00e9, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x0271, 0x0265, 0x002f, 0x006f, 0x01ff, 0x026b },
{ 0x0101, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0239, 0x0012, 0x0034, 0x020c, 0x0201, 0x0016, 0x004c, 0x01dc, 0x0207 },
{ 0x0102, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x000c, 0x006d, 0x00d8, 0x020c, 0x0201, 0x0016, 0x004c, 0x01dc, 0x0207 },
{ 0x0103, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x001c, 0x007d, 0x00d8, 0x020c, 0x0201, 0x0016, 0x004c, 0x01dc, 0x0207 },
{ 0x0104, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x002e, 0x008f, 0x00d8, 0x020c, 0x0201, 0x0016, 0x004c, 0x01dc, 0x0207 },
{ 0x0108, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x03f0, 0x009f, 0x01b4, 0x020c, 0x0201, 0x0016, 0x004c, 0x01dc, 0x0207 },
{ 0x0109, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0002, 0x0020, 0x0034, 0x020c, 0x0201, 0x0016, 0x004c, 0x01dc, 0x0207 },
{ 0x010a, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x004d, 0x00fd, 0x01b4, 0x020c, 0x0201, 0x0016, 0x004c, 0x01dc, 0x0207 },
{ 0x010b, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x005d, 0x010d, 0x01b4, 0x020c, 0x0201, 0x0016, 0x004c, 0x01dc, 0x0207 },
{ 0x0121, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0239, 0x0012, 0x0034, 0x0270, 0x0265, 0x002f, 0x007e, 0x020e, 0x026b },
{ 0x0122, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x000c, 0x006d, 0x00d8, 0x0270, 0x0265, 0x002f, 0x007e, 0x020e, 0x026b },
{ 0x0123, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x001c, 0x007d, 0x00d8, 0x0270, 0x0265, 0x002f, 0x007e, 0x020e, 0x026b },
{ 0x0124, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x002e, 0x008f, 0x00d8, 0x0270, 0x0265, 0x002f, 0x007e, 0x020e, 0x026b },
{ 0x0128, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x03ef, 0x00a0, 0x01b2, 0x0270, 0x0265, 0x002f, 0x007e, 0x020e, 0x026b },
{ 0x0129, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0002, 0x0020, 0x0034, 0x0270, 0x0265, 0x002f, 0x007e, 0x020e, 0x026b },
{ 0x012a, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x004d, 0x00fe, 0x01b2, 0x0270, 0x0265, 0x002f, 0x007e, 0x020e, 0x026b },
{ 0x012b, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x005d, 0x010e, 0x01b2, 0x0270, 0x0265, 0x002f, 0x007e, 0x020e, 0x026b },
{ 0x0141, MON_VGA, 0x003e, 0x0030, 0x0008, 0x0239, 0x0012, 0x0034, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0141, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0232, 0x001b, 0x0034, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0142, MON_VGA, 0x00fe, 0x00c9, 0x0027, 0x000c, 0x006d, 0x00d8, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0142, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x02ec, 0x008d, 0x00d8, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0143, MON_VGA, 0x00fe, 0x00c9, 0x0027, 0x001c, 0x007d, 0x00d8, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0143, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x02fc, 0x009d, 0x00d8, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0144, MON_VGA, 0x00fe, 0x00c9, 0x0027, 0x002e, 0x008f, 0x00d8, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0144, MON_ALL, 0x00fe, 0x00c9, 0x0027, 0x000e, 0x00af, 0x00d8, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0148, MON_VGA, 0x01ff, 0x0197, 0x0050, 0x03f0, 0x009f, 0x01b4, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0148, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x03b0, 0x00df, 0x01b4, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0149, MON_VGA, 0x003e, 0x0030, 0x0008, 0x023b, 0x001c, 0x0034, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0149, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0237, 0x0020, 0x0034, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x014a, MON_VGA, 0x01ff, 0x0197, 0x0050, 0x004d, 0x00fd, 0x01b4, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x014a, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x000d, 0x013d, 0x01b4, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x014b, MON_VGA, 0x01ff, 0x0197, 0x0050, 0x005d, 0x010d, 0x01b4, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x014b, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x001d, 0x014d, 0x01b4, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x0161, MON_VGA, 0x003e, 0x0030, 0x0008, 0x0239, 0x0012, 0x0034, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0161, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0232, 0x001b, 0x0034, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0162, MON_VGA, 0x00fe, 0x00cb, 0x0027, 0x000c, 0x006d, 0x00d8, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0162, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x02ec, 0x008d, 0x00d8, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0163, MON_VGA, 0x00fe, 0x00cb, 0x0027, 0x001c, 0x007d, 0x00d8, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0163, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x02fc, 0x009d, 0x00d8, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0164, MON_VGA, 0x00fe, 0x00cb, 0x0027, 0x002e, 0x008f, 0x00d8, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0164, MON_ALL, 0x00fe, 0x00cb, 0x0027, 0x000e, 0x00af, 0x00d8, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0168, MON_VGA, 0x01fe, 0x0199, 0x0050, 0x03ef, 0x00a0, 0x01b2, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0168, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x03af, 0x00e0, 0x01b2, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0169, MON_VGA, 0x003e, 0x0030, 0x0008, 0x023b, 0x001c, 0x0034, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0169, MON_ALL, 0x003e, 0x0030, 0x0008, 0x0237, 0x0020, 0x0034, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x016a, MON_VGA, 0x01fe, 0x0199, 0x0050, 0x004d, 0x00fe, 0x01b2, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x016a, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x000d, 0x013e, 0x01b2, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x016b, MON_VGA, 0x01fe, 0x0199, 0x0050, 0x005d, 0x010e, 0x01b2, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x016b, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x001d, 0x014e, 0x01b2, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x0182, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x0188, MON_MONO, 0x001a, 0x0000, 0x0000, 0x020f, 0x000c, 0x0014, 0x03e9, 0x0000, 0x0000, 0x0043, 0x0363, 0x03e7 },
{ 0x0188, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x03f0, 0x009f, 0x01b4, 0x020c, 0x0201, 0x0016, 0x004c, 0x01dc, 0x0207 },
{ 0x0189, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x01a2, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x0271, 0x0265, 0x002f, 0x006f, 0x01ff, 0x026b },
{ 0x01a8, MON_MONO, 0x001a, 0x0000, 0x0000, 0x020f, 0x000c, 0x0014, 0x03e9, 0x0000, 0x0000, 0x0043, 0x0363, 0x03e7 },
{ 0x01a8, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x03ef, 0x00a0, 0x01b2, 0x0270, 0x0265, 0x002f, 0x007e, 0x020e, 0x026b },
{ 0x01a9, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x0271, 0x0265, 0x002f, 0x006f, 0x01ff, 0x026b },
{ 0x01c2, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x01c8, MON_MONO, 0x001a, 0x0000, 0x0000, 0x020f, 0x000c, 0x0014, 0x03e9, 0x0000, 0x0000, 0x0043, 0x0363, 0x03e7 },
{ 0x01c8, MON_VGA, 0x01ff, 0x0197, 0x0050, 0x03f0, 0x009f, 0x01b4, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x01c8, MON_ALL, 0x01ff, 0x0197, 0x0050, 0x03b0, 0x00df, 0x01b4, 0x020c, 0x0201, 0x0016, 0x0024, 0x0204, 0x0207 },
{ 0x01c9, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x020d, 0x0201, 0x0016, 0x004d, 0x01dd, 0x0207 },
{ 0x01e2, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x0271, 0x0265, 0x002f, 0x006f, 0x01ff, 0x026b },
{ 0x01e8, MON_MONO, 0x001a, 0x0000, 0x0000, 0x020f, 0x000c, 0x0014, 0x03e9, 0x0000, 0x0000, 0x0043, 0x0363, 0x03e7 },
{ 0x01e8, MON_VGA, 0x01fe, 0x0199, 0x0050, 0x03ef, 0x00a0, 0x01b2, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x01e8, MON_ALL, 0x01fe, 0x0199, 0x0050, 0x03af, 0x00e0, 0x01b2, 0x0270, 0x0265, 0x002f, 0x0056, 0x0236, 0x026b },
{ 0x01e9, MON_ALL, 0x003e, 0x0032, 0x0009, 0x023f, 0x001c, 0x0034, 0x0271, 0x0265, 0x002f, 0x006f, 0x01ff, 0x026b },
{ -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
void set_palette(uint16_t *colorptr)
{
int i;
uint16_t *palette_regs = (uint16_t *) 0xffff9800;
do
{
*palette_regs++ = *colorptr++;
} while (palette_regs < 0xffff9600 + 16 * 2);
}
/*
* functions for VIDEL programming
*/
static uint16_t get_videl_bpp(void)
{
uint16_t f_shift = *(volatile uint16_t *)SPSHIFT;
uint8_t st_shift = *(volatile uint8_t *)ST_SHIFTER;
/* to get bpp, we must examine f_shift and st_shift.
* f_shift is valid if any of bits no. 10, 8 or 4
* is set. Priority in f_shift is: 10 ">" 8 ">" 4, i.e.
* if bit 10 set then bit 8 and bit 4 don't care...
* If all these bits are 0 get display depth from st_shift
* (as for ST and STe)
*/
int bits_per_pixel = 1;
if (f_shift & 0x400) /* 2 colors */
bits_per_pixel = 1;
else if (f_shift & 0x100) /* hicolor */
bits_per_pixel = 16;
else if (f_shift & 0x010) /* 8 bitplanes */
bits_per_pixel = 8;
else if (st_shift == 0)
bits_per_pixel = 4;
else if (st_shift == 0x1)
bits_per_pixel = 2;
else /* if (st_shift == 0x2) */
bits_per_pixel = 1;
return bits_per_pixel;
}
static uint16_t get_videl_width(void)
{
return ( * (volatile uint16_t *) 0xffff8210) * 16 / get_videl_bpp();
}
static uint16_t get_videl_height(void)
{
uint16_t vdb = * (volatile uint16_t *) 0xffff82a8;
uint16_t vde = * (volatile uint16_t *) 0xffff82aa;
uint16_t vmode = * (volatile uint16_t *) 0xffff82c2;
/* visible y resolution:
* Graphics display starts at line VDB and ends at line
* VDE. If interlace mode off unit of VC-registers is
* half lines, else lines.
*/
uint16_t yres = vde - vdb;
if (!(vmode & 0x02)) /* interlace */
yres >>= 1;
if (vmode & 0x01) /* double */
yres >>= 1;
return yres;
}
/*
* lookup videl initialisation data for specified mode/monitor
* returns NULL if mode/monitor combination is invalid
*/
const VMODE_ENTRY *lookup_videl_mode(int16_t mode,int16_t monitor)
{
const VMODE_ENTRY *vmode_init_table, *p;
if (mode&VIDEL_VGA)
{
vmode_init_table = vga_init_table;
/* ignore bits that don't affect initialisation data */
mode &= ~(VIDEL_VERTICAL|VIDEL_PAL);
}
else
{
vmode_init_table = nonvga_init_table;
}
for (p = vmode_init_table; p->vmode >= 0; p++)
if (p->vmode == mode)
if ((p->monitor == MON_ALL) || (p->monitor == monitor))
return p;
return NULL;
}
/*
* determine scanline width based on video mode
*/
static int16_t determine_width(int16_t mode)
{
int16_t linewidth;
linewidth = (mode&VIDEL_80COL) ? 40 : 20;
linewidth <<= (mode & VIDEL_BPPMASK);
if (mode&VIDEL_OVERSCAN)
linewidth = linewidth * 12 / 10; /* multiply by 1.2 */
return linewidth;
}
/*
* determine vctl based on video mode and monitor type
*/
static int16_t determine_vctl(int16_t mode, int16_t monitor)
{
int16_t vctl;
if (mode & VIDEL_VGA)
{
vctl = (mode & VIDEL_80COL) ? 0x08 : 0x04;
if (mode & VIDEL_VERTICAL)
vctl |= 0x01;
}
else
{
vctl = (mode & VIDEL_80COL) ? 0x04 : 0x00;
if (mode & VIDEL_VERTICAL)
vctl |= 0x02;
}
if (!(mode & VIDEL_COMPAT))
return vctl;
switch (mode & VIDEL_BPPMASK)
{
case VIDEL_1BPP:
if (!(mode & VIDEL_VGA) && (monitor == MON_MONO))
vctl = 0x08;
break;
case VIDEL_2BPP:
vctl = (mode & VIDEL_VGA)? 0x09 : 0x04;
break;
case VIDEL_4BPP:
vctl = (mode & VIDEL_VGA)? 0x05 : 0x00;
break;
}
return vctl;
}
/*
* determine regc0 based on video mode & monitor type
*/
static int16_t determine_regc0(int16_t mode,int16_t monitor)
{
if (mode & VIDEL_VGA)
return 0x0186;
if (!(mode & VIDEL_COMPAT))
return (monitor == MON_TV) ? 0x0183 : 0x0181;
/* handle ST-compatible modes */
if ((mode & (VIDEL_80COL | VIDEL_BPPMASK)) == (VIDEL_80COL | VIDEL_1BPP))
{
/* 80-column, 2-colour */
switch(monitor)
{
case MON_MONO:
return 0x0080;
case MON_TV:
return 0x0183;
default:
return 0x0181;
}
}
return (monitor == MON_TV) ? 0x0083 : 0x0081;
}
/*
* this routine can set VIDEL to 1,2,4 or 8 bitplanes mode on VGA
*/
static int set_videl_vga(int16_t mode)
{
volatile char *videlregs = (char *)0xffff8200;
#define videlword(n) (*(volatile uint16_t *)(videlregs+(n)))
const VMODE_ENTRY *p;
int16_t linewidth, monitor, vctl;
monitor = vmontype();
p = lookup_videl_mode(mode,monitor);/* validate mode */
if (!p)
return -1;
videlregs[0x0a] = (mode & VIDEL_PAL) ? 2 : 0; /* video sync to 50Hz if PAL */
// FIXME: vsync() can't work if the screen is initially turned off
//vsync(); /* wait for vbl so we're not interrupted :-) */
videlword(0x82) = p->hht; /* H hold timer */
videlword(0x84) = p->hbb; /* H border begin */
videlword(0x86) = p->hbe; /* H border end */
videlword(0x88) = p->hdb; /* H display begin */
videlword(0x8a) = p->hde; /* H display end */
videlword(0x8c) = p->hss; /* H SS */
videlword(0xa2) = p->vft; /* V freq timer */
videlword(0xa4) = p->vbb; /* V border begin */
videlword(0xa6) = p->vbe; /* V border end */
videlword(0xa8) = p->vdb; /* V display begin */
videlword(0xaa) = p->vde; /* V display end */
videlword(0xac) = p->vss; /* V SS */
videlregs[0x60] = 0x00; /* clear ST shift for safety */
videlword(0x0e) = 0; /* offset */
linewidth = determine_width(mode);
vctl = determine_vctl(mode,monitor);
videlword(0x10) = linewidth; /* scanline width */
videlword(0xc2) = vctl; /* video control */
videlword(0xc0) = determine_regc0(mode,monitor);
videlword(0x66) = 0x0000; /* clear SPSHIFT */
switch(mode & VIDEL_BPPMASK)
{
/* set SPSHIFT / ST shift */
case VIDEL_1BPP: /* 2 colours (mono) */
if (monitor == MON_MONO)
videlregs[0x60] = 0x02;
else videlword(0x66) = 0x0400;
break;
case VIDEL_2BPP: /* 4 colours */
videlregs[0x60] = 0x01;
videlword(0x10) = linewidth; /* writing to the ST shifter has */
videlword(0xc2) = vctl; /* just overwritten these registers */
break;
case VIDEL_4BPP: /* 16 colours */
/* if not ST-compatible, SPSHIFT was already set correctly above */
if (mode & VIDEL_COMPAT)
videlregs[0x60] = 0x00; /* else set ST shifter */
break;
case VIDEL_8BPP: /* 256 colours */
videlword(0x66) = 0x0010;
break;
case VIDEL_TRUECOLOR: /* 65536 colours (Truecolor) */
videlword(0x66) = 0x0100;
break;
}
return 0;
}
/*
* the current Falcon video mode; used by vsetmode() & vfixmode()
*/
int16_t current_video_mode;
/*
* Set Falcon video mode
*/
int16_t vsetmode(int16_t mode)
{
int16_t ret;
if (mode == -1)
return current_video_mode;
#ifdef DBG_VIDEL
xprintf("vsetmode(0x%04x)\n", mode);
#endif
if (set_videl_vga(mode) < 0) /* invalid mode */
return current_video_mode;
ret = current_video_mode;
current_video_mode = mode;
return ret;
}
/*
* Get Videl monitor type
*/
int16_t vmontype(void)
{
return ((*(volatile uint8_t *)0xffff8006) >> 6) & 3;
}
/*
* Set external video sync mode
*/
int16_t vsetsync(int16_t external)
{
uint16_t spshift;
if (external & 0x01) /* external clock wanted? */
*(volatile int8_t *)SYNCMODE |= 0x01;
else *(volatile int8_t *)SYNCMODE &= 0xfe;
spshift = *(volatile uint16_t *)SPSHIFT;
if (external&0x02) /* external vertical sync wanted? */
spshift |= 0x0020;
else spshift &= 0xffdf;
if (external&0x04) /* external horizontal sync wanted? */
spshift |= 0x0040;
else spshift &= 0xffbf;
*(volatile uint16_t *)SPSHIFT = spshift;
return 0; /* OK */
}
/*
* get video ram size according to mode
*/
int32_t vgetsize(int16_t mode)
{
const VMODE_ENTRY *p;
int height;
int16_t vctl, monitor;
monitor = vmontype();
mode &= VIDEL_VALID; /* ignore invalid bits */
if ((mode & VIDEL_BPPMASK) > VIDEL_TRUECOLOR)
{
/* fixup invalid bpp */
mode &= ~VIDEL_BPPMASK;
mode |= VIDEL_TRUECOLOR;
}
p = lookup_videl_mode(mode, monitor);
if (!p)
{
/* invalid mode */
if (mode & VIDEL_COMPAT)
return ST_VRAM_SIZE;
mode &= ~(VIDEL_OVERSCAN|VIDEL_PAL);/* ignore less-important bits */
p = lookup_videl_mode(mode, monitor);/* & try again */
if (!p) /* "can't happen" */
return FALCON_VRAM_SIZE;
}
vctl = determine_vctl(mode, monitor);
height = p->vde - p->vdb;
if (!(vctl & 0x02))
height >>= 1;
if (vctl & 0x01)
height >>= 1;
return (int32_t)determine_width(mode) * 2 * height;
}
/*
* convert from Falcon palette format to STe palette format
*/
#define falc2ste(a) ((((a) >> 1) & 0x08) | (((a) >> 5) & 0x07))
static void convert2ste(int16_t *ste,int32_t *falcon)
{
union
{
int32_t l;
uint8_t b[4];
} u;
int i;
for (i = 0; i < 16; i++)
{
u.l = *falcon++;
*ste++ = (falc2ste(u.b[0]) << 8) | (falc2ste(u.b[1]) << 4) | falc2ste(u.b[3]);
}
}
/*
* determine whether to update STe or Falcon h/w palette registers
* returns true if we need to update the STe h/w palette
*/
static int use_ste_palette(int16_t videomode)
{
if (vmontype() == MON_MONO) /* always for ST mono monitor */
return true;
if ((videomode & VIDEL_BPPMASK) == VIDEL_2BPP) /* always for 4-colour modes */
return true;
if ((videomode & VIDEL_COMPAT) && ((videomode & VIDEL_BPPMASK) == VIDEL_4BPP))
return true; /* and for ST low */
return false;
}
/*
* set palette registers
*
* note that the actual update of the hardware registers is done by the
* VBL interrupt handler, according to the setting of 'colorptr'. since
* the address in colorptr must be even, we use bit 0 as a flag.
*
* colorptr contents VBL interrupt handler action
* ----------------- ----------------------------
* 0 do nothing
* address load STe palette regs from address
* address | 0x01 load first 16 Falcon palette regs from address
* 0 | 0x01 load 256 Falcon palette regs from falcon_shadow_palette[]
*/
int16_t vsetrgb(int16_t index,int16_t count, int32_t *rgb)
{
int32_t *shadow, *source;
union
{
int32_t l;
uint8_t b[4];
} u;
int16_t limit;
if ((index < 0) || (count <= 0))
return -1; /* Generic error */
limit = (get_videl_bpp() <= 4) ? 16 : 256;
if ((index + count) > limit)
return -1; /* Generic error */
/*
* we always update the Falcon shadow palette, since that's
* what we'll return for VgetRGB()
*/
shadow = falcon_shadow_palette + index;
source = rgb;
while (count--) {
u.l = *source++;
u.b[0] = u.b[1]; /* shift R & G */
u.b[1] = u.b[2];
u.b[2] = 0x00;
*shadow++ = u.l;
}
/*
* for ST low or 4-colour modes, we need to convert the
* Falcon shadow registers to STe palette register format, and
* request the VBL interrupt handler to update the STe palette
* registers rather than the Falcon registers
*/
if (use_ste_palette(vsetmode(-1))) {
convert2ste(ste_shadow_palette, falcon_shadow_palette);
colorptr = ste_shadow_palette;
return 0; /* OK */
}
colorptr = (limit == 256) ? (int16_t *) 0x01L : (int16_t *) ((int32_t) falcon_shadow_palette|0x01L);
set_palette(colorptr);
return 0; /* OK */
}
/*
* get palette registers
*/
int16_t vgetrgb(int16_t index,int16_t count,int32_t *rgb)
{
int32_t *shadow;
union
{
int32_t l;
uint8_t b[4];
} u;
int16_t limit;
if ((index < 0) || (count <= 0))
return -1; /* Generic error */
limit = (get_videl_bpp() <= 4) ? 16 : 256;
if ((index + count) > limit)
return -1; /* Generic error */
shadow = falcon_shadow_palette + index;
while (count--)
{
u.l = *shadow++;
u.b[2] = u.b[1]; /* shift R & G right*/
u.b[1] = u.b[0];
u.b[0] = 0x00;
*rgb++ = u.l;
}
return 0; /* OK */
}
/*
* Fix Videl mode
*
* This converts an (assumed legal) input mode into the
* corresponding output mode for the current monitor type
*/
int16_t vfixmode(int16_t mode)
{
int16_t monitor, currentmode;
monitor = vmontype();
if (monitor == MON_MONO)
return FALCON_ST_HIGH;
currentmode = vsetmode(-1);
if (currentmode & VIDEL_PAL) /* set PAL bit per current value */
mode |= VIDEL_PAL;
else mode &= ~VIDEL_PAL;
/* handle VGA monitor */
if (monitor == MON_VGA) {
mode &= ~VIDEL_OVERSCAN; /* turn off overscan (not used with VGA) */
if (!(mode & VIDEL_VGA)) /* if mode doesn't have VGA set, */
mode ^= (VIDEL_VERTICAL | VIDEL_VGA); /* set it & flip vertical */
if (mode & VIDEL_COMPAT) {
if ((mode&VIDEL_BPPMASK) == VIDEL_1BPP)
mode &= ~VIDEL_VERTICAL; /* clear vertical for ST high */
else mode |= VIDEL_VERTICAL; /* set it for ST medium, low */
}
return mode;
}
/* handle RGB or TV */
if (mode & VIDEL_VGA) /* if mode has VGA set, */
mode ^= (VIDEL_VERTICAL | VIDEL_VGA); /* clear it & flip vertical */
if (mode & VIDEL_COMPAT) {
if ((mode & VIDEL_BPPMASK) == VIDEL_1BPP)
mode |= VIDEL_VERTICAL; /* set vertical for ST high */
else mode &= ~VIDEL_VERTICAL; /* clear it for ST medium, low */
}
return mode;
}
int16_t videl_check_moderez(int16_t moderez)
{
int16_t current_mode, return_mode;
if (moderez < 0) /* ignore rez values */
return 0;
current_mode = get_videl_mode();
return_mode = vfixmode(moderez);/* adjust */
return (return_mode == current_mode) ? 0 : return_mode;
}
uint32_t videl_vram_size(void)
{
return get_videl_width() / 8L * get_videl_height() * get_videl_bpp();
}
void videl_get_current_mode_info(uint16_t *planes, uint16_t *hz_rez, uint16_t *vt_rez)
{
*planes = get_videl_bpp();
*hz_rez = get_videl_width();
*vt_rez = get_videl_height();
}
/*
* Initialise Falcon palette
*/
void initialise_falcon_palette(int16_t mode)
{
volatile int16_t *col_regs = (int16_t *) ST_PALETTE_REGS;
volatile int32_t *fcol_regs = (int32_t *) FALCON_PALETTE_REGS;
int i, limit;
/* first, set up Falcon shadow palette and real registers */
for (i = 0; i < 256; i++)
falcon_shadow_palette[i] = videl_dflt_palette[i];
switch(mode&VIDEL_BPPMASK) {
case VIDEL_1BPP: /* 2-colour mode */
falcon_shadow_palette[1] = falcon_shadow_palette[15];
break;
case VIDEL_2BPP: /* 4-colour mode */
falcon_shadow_palette[3] = falcon_shadow_palette[15];
break;
}
/* a 'feature' of the Falcon hardware: if we're in a mode with less
* than 256 colours, and we attempt to set the Falcon hardware
* palette registers for colours 16 & above, it will screw up the
* values in the first 16 hardware palette registers, resulting in
* a messed-up display ...
* NOTE: what happens in the Truecolor case is yet to be determined,
* although it is probably not important since we don't use those
* registers.
*/
limit = ((mode & VIDEL_BPPMASK) == VIDEL_8BPP) ? 256 : 16;
for (i = 0; i < limit; i++)
fcol_regs[i] = falcon_shadow_palette[i];
/*
* if appropriate, set up the STe shadow & real palette registers
*/
if (use_ste_palette(mode)) {
convert2ste(ste_shadow_palette, falcon_shadow_palette);
for (i = 0; i < 16; i++)
col_regs[i] = ste_shadow_palette[i];
}
}
/*
* Get videl mode
* This is the same as vsetmode(-1) except that it returns
* zero when there is no videl. Used by app_save().
*/
int16_t get_videl_mode(void)
{
return vsetmode(-1);
}

358
BaS_gcc/video/video.c Normal file
View File

@@ -0,0 +1,358 @@
#include "video.h"
#include "videl.h"
#include "screen.h"
#include "pci.h"
#include "pci_ids.h"
#include "mod_devicetable.h"
#include "fb.h"
#include "radeonfb.h"
//#define DBG_VIDEO
#ifdef DBG_VIDEO
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else
#define dbg(format, arg...) do { ; } while (0)
#endif /* DBG_VIDEO */
#ifdef _USE_VIDEL_
#define MON_ALL -1 /* code used in VMODE_ENTRY for match on mode only */
/*
* tables that cover all(?) valid Falcon modes
* note:
* . 256-colour and Truecolor modes are not currently supported by the VDI
*/
static const VMODE_ENTRY vga_init_table[] = {
/* the entries in this table are for VGA/NTSC (i.e. VGA 60Hz) and VGA/PAL
* (i.e. VGA 50Hz). in *this* table, each entry applies to four video modes:
* mode, mode|VIDEL_VERTICAL, mode|VIDEL_PAL, mode|VIDEL_VERTICAL|VIDEL_PAL
*/
{ 0x0011, MON_ALL, 0x0017, 0x0012, 0x0001, 0x020a, 0x0009, 0x0011, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0012, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x028a, 0x006b, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0013, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x029a, 0x007b, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0014, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x02ac, 0x0091, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0018, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x0273, 0x0050, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0019, MON_ALL, 0x0017, 0x0012, 0x0001, 0x020e, 0x000d, 0x0011, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x001a, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x02a3, 0x007c, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x001b, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x02ab, 0x0084, 0x0096, 0x0419, 0x03ff, 0x003f, 0x003f, 0x03ff, 0x0415 },
{ 0x0092, MON_ALL, 0x0017, 0x0012, 0x0001, 0x020e, 0x000d, 0x0011, 0x0419, 0x03af, 0x008f, 0x008f, 0x03af, 0x0415 },
{ 0x0098, MON_ALL, 0x00c6, 0x008d, 0x0015, 0x0273, 0x0050, 0x0096, 0x0419, 0x03af, 0x008f, 0x008f, 0x03af, 0x0415 },
{ 0x0099, MON_ALL, 0x0017, 0x0012, 0x0001, 0x020e, 0x000d, 0x0011, 0x0419, 0x03af, 0x008f, 0x008f, 0x03af, 0x0415 },
{ -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
/*
* Initialise palette registers
* This routine is also used by resolution change
*/
void initialise_palette_registers(int16_t rez,int16_t mode)
{
initialise_falcon_palette(mode);
}
/*
* determine regc0 based on video mode & monitor type
*/
static int16_t determine_regc0(int16_t mode, int16_t monitor)
{
if (mode&VIDEL_VGA)
return 0x0186;
if (!(mode&VIDEL_COMPAT))
return (monitor==MON_TV)?0x0183:0x0181;
/* handle ST-compatible modes */
if ((mode&(VIDEL_80COL|VIDEL_BPPMASK)) == (VIDEL_80COL|VIDEL_1BPP)) { /* 80-column, 2-colour */
switch(monitor) {
case MON_MONO:
return 0x0080;
case MON_TV:
return 0x0183;
default:
return 0x0181;
}
}
return (monitor==MON_TV)?0x0083:0x0081;
}
/*
* determine vctl based on video mode and monitor type
*/
static int16_t determine_vctl(int16_t mode,int16_t monitor)
{
int16_t vctl;
if (mode&VIDEL_VGA) {
vctl = (mode&VIDEL_80COL) ? 0x08 : 0x04;
if (mode&VIDEL_VERTICAL)
vctl |= 0x01;
} else {
vctl = (mode&VIDEL_80COL) ? 0x04 : 0x00;
if (mode&VIDEL_VERTICAL)
vctl |= 0x02;
}
if (!(mode&VIDEL_COMPAT))
return vctl;
switch(mode&VIDEL_BPPMASK) {
case VIDEL_1BPP:
if (!(mode&VIDEL_VGA) && (monitor == MON_MONO))
vctl = 0x08;
break;
case VIDEL_2BPP:
vctl = (mode&VIDEL_VGA)? 0x09 : 0x04;
break;
case VIDEL_4BPP:
vctl = (mode&VIDEL_VGA)? 0x05 : 0x00;
break;
}
return vctl;
}
/*
* determine scanline width based on video mode
*/
static int16_t determine_width(int16_t mode)
{
int16_t linewidth;
linewidth = (mode&VIDEL_80COL) ? 40 : 20;
linewidth <<= (mode & VIDEL_BPPMASK);
if (mode&VIDEL_OVERSCAN)
linewidth = linewidth * 12 / 10; /* multiply by 1.2 */
return linewidth;
}
static int set_videl_vga(int16_t mode)
{
volatile char *videlregs = (char *)0xffff8200;
#define videlword(n) (*(volatile uint16_t *)(videlregs+(n)))
const VMODE_ENTRY *p;
int16_t linewidth, monitor, vctl;
monitor = vmontype();
p = lookup_videl_mode(mode,monitor);/* validate mode */
if (!p)
return -1;
videlregs[0x0a] = (mode&VIDEL_PAL) ? 2 : 0; /* video sync to 50Hz if PAL */
// FIXME: vsync() can't work if the screen is initially turned off
//vsync(); /* wait for vbl so we're not interrupted :-) */
videlword(0x82) = p->hht; /* H hold timer */
videlword(0x84) = p->hbb; /* H border begin */
videlword(0x86) = p->hbe; /* H border end */
videlword(0x88) = p->hdb; /* H display begin */
videlword(0x8a) = p->hde; /* H display end */
videlword(0x8c) = p->hss; /* H SS */
videlword(0xa2) = p->vft; /* V freq timer */
videlword(0xa4) = p->vbb; /* V border begin */
videlword(0xa6) = p->vbe; /* V border end */
videlword(0xa8) = p->vdb; /* V display begin */
videlword(0xaa) = p->vde; /* V display end */
videlword(0xac) = p->vss; /* V SS */
videlregs[0x60] = 0x00; /* clear ST shift for safety */
videlword(0x0e) = 0; /* offset */
linewidth = determine_width(mode);
vctl = determine_vctl(mode,monitor);
videlword(0x10) = linewidth; /* scanline width */
videlword(0xc2) = vctl; /* video control */
videlword(0xc0) = determine_regc0(mode,monitor);
videlword(0x66) = 0x0000; /* clear SPSHIFT */
switch(mode&VIDEL_BPPMASK) { /* set SPSHIFT / ST shift */
case VIDEL_1BPP: /* 2 colours (mono) */
if (monitor == MON_MONO)
videlregs[0x60] = 0x02;
else videlword(0x66) = 0x0400;
break;
case VIDEL_2BPP: /* 4 colours */
videlregs[0x60] = 0x01;
videlword(0x10) = linewidth; /* writing to the ST shifter has */
videlword(0xc2) = vctl; /* just overwritten these registers */
break;
case VIDEL_4BPP: /* 16 colours */
/* if not ST-compatible, SPSHIFT was already set correctly above */
if (mode&VIDEL_COMPAT)
videlregs[0x60] = 0x00; /* else set ST shifter */
break;
case VIDEL_8BPP: /* 256 colours */
videlword(0x66) = 0x0010;
break;
case VIDEL_TRUECOLOR: /* 65536 colours (Truecolor) */
videlword(0x66) = 0x0100;
break;
}
return 0;
}
int16_t current_video_mode;
/* Set physical screen address */
static void setphys(int32_t addr,int checkaddr)
{
*(volatile uint8_t *) VIDEOBASE_ADDR_HI = ((uint32_t) addr) >> 16;
*(volatile uint8_t *) VIDEOBASE_ADDR_MID = ((uint32_t) addr) >> 8;
*(volatile uint8_t *) VIDEOBASE_ADDR_LOW = ((uint32_t) addr);
}
/*
* In the original TOS there used to be an early screen init,
* before memory configuration. This is not used here, and all is
* done at the same time from C.
*/
void videl_screen_init(void)
{
uint32_t screen_start;
uint16_t boot_resolution = FALCON_DEFAULT_BOOT;
int16_t monitor_type, sync_mode;
int16_t rez = 0; /* avoid 'may be uninitialized' warning */
/* Initialize the interrupt handlers.
* It is important to do this first because the initialization code below
* may call vsync(), which temporarily enables the interrupts. */
/* TODO: VEC_HBL = int_hbl; */
/* TODO: VEC_VBL = int_vbl; */
/*
* first, see what we're connected to, and set the
* resolution / video mode appropriately
*/
monitor_type = MON_COLOR;
xprintf("monitor_type = %d\r\n", monitor_type);
/* reset VIDEL on boot-up */
/* first set the physbase to a safe memory */
setphys(0xd00000, 0);
if (!lookup_videl_mode(boot_resolution, monitor_type)) { /* mode isn't in table */
xprintf("Invalid video mode 0x%04x changed to 0x%04x\r\n",
boot_resolution, FALCON_DEFAULT_BOOT);
boot_resolution = FALCON_DEFAULT_BOOT; /* so pick one that is */
}
if (!VALID_VDI_BPP(boot_resolution)) { /* mustn't confuse VDI */
xprintf("VDI doesn't support video mode 0x%04x, changed to 0x%04x\r\n",
boot_resolution, FALCON_DEFAULT_BOOT);
boot_resolution = FALCON_DEFAULT_BOOT; /* so use default */
}
vsetmode(boot_resolution);
rez = FALCON_REZ; /* fake value indicates Falcon/Videl */
sync_mode = (boot_resolution & VIDEL_PAL) ? 0x02 : 0x00;
*(volatile uint8_t *) SYNCMODE = sync_mode;
/*
* next, set up the palette(s)
*/
initialise_palette_registers(rez, boot_resolution);
/* FIXME: sshiftmod = rez; */
/* videoram is placed just below the phystop */
screen_start = 0xd00000;
/* correct physical address */
setphys(screen_start, 1);
}
#endif /* _USE_VIDEL_ */
static struct fb_info fb;
struct fb_info *info_fb = &fb;
const char monitor_layout[1024] = "CRT,CRT";
int16_t ignore_edid;
struct mode_option resolution =
{
.used = 0,
.width = 640,
.height = 480,
.bpp = 8,
.freq = 60,
.flags = 0
};
int16_t force_measure_pll;
void install_vbl_timer(void *func, int remove)
{
dbg("%s: not implemented\r\n", __FUNCTION__);
}
/*
* detect and initialise PCI graphics cards
*/
void video_init(void)
{
/*
* detect PCI video card
*/
int index = 0;
int32_t handle;
struct pci_device_id *board;
int32_t id;
bool radeon_found = false;
dbg("%s\r\n", __FUNCTION__);
do
{
/*
* scan PCI bus for graphics cards
*/
handle = pci_find_classcode(PCI_BASE_CLASS_DISPLAY | PCI_FIND_BASE_CLASS, index);
if (handle > 0) /* found a display device */
{
dbg("%s: handle = 0x%x\r\n", __FUNCTION__, handle);
id = swpl(pci_read_config_longword(handle, PCIIDR)); /* get vendor + device id */
dbg("%s: PCIIDR=0x%x\r\n", __FUNCTION__, id);
board = &radeonfb_pci_table[0];
do
{
/* check it against elements of table */
dbg("%s: check %x %x against %08x\r\n", __FUNCTION__, board->device, board->vendor, id);
if ((board->device == (id >> 16)) && (board->vendor == (id & 0xffff)))
{
radeon_found = true;
dbg("%s: matched\r\n", __FUNCTION__);
if (radeonfb_pci_register(handle, board) >= 0)
{
xprintf("RADEON video card found and registered\r\n");
}
else
{
dbg("%s: failed to register RADEON PCI video card\r\n", __FUNCTION__);
}
return;
}
board++;
} while (board->vendor);
}
index++;
} while (handle > 0);
xprintf("%s: RADEON video card %sfound and %sregistered\r\n", __FUNCTION__,
(radeon_found ? "" : "not "), (radeon_found ? "" : "not "));
}