For graphics modes, store pixel width/height instead of text
width/height. Add explicit char width field. Where needed, calculate
text width/height from pixel width/height by dividing pixel count by
character size.
Rename some fields and change field sizes to match cirrus/bochs
definitions.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
#define SEG_MTEXT 0xB000
struct vgamode_s {
#define SEG_MTEXT 0xB000
struct vgamode_s {
- u8 svgamode;
- u8 memmodel; /* CTEXT,MTEXT,CGA,PL1,PL2,PL4,P8,P15,P16,P24,P32 */
- u8 twidth;
- u8 theight;
+ u16 mode;
+ u8 memmodel;
+ u16 width;
+ u16 height;
+ u8 depth;
+ u8 cwidth;
modeswitch_set_bda(int mode, int flags, struct vgamode_s *vmode_g)
{
// Set the BIOS mem
modeswitch_set_bda(int mode, int flags, struct vgamode_s *vmode_g)
{
// Set the BIOS mem
- u16 cheight = GET_GLOBAL(vmode_g->cheight);
+ int width = GET_GLOBAL(vmode_g->width);
+ int height = GET_GLOBAL(vmode_g->height);
+ int cheight = GET_GLOBAL(vmode_g->cheight);
SET_BDA(video_mode, mode);
SET_BDA(video_mode, mode);
- SET_BDA(video_cols, GET_GLOBAL(vmode_g->twidth));
+ if (GET_GLOBAL(vmode_g->memmodel) == MM_TEXT) {
+ SET_BDA(video_cols, width);
+ SET_BDA(video_rows, height-1);
+ SET_BDA(cursor_type, 0x0607);
+ } else {
+ int cwidth = GET_GLOBAL(vmode_g->cwidth);
+ SET_BDA(video_cols, width / cwidth);
+ SET_BDA(video_rows, (height / cheight) - 1);
+ SET_BDA(cursor_type, 0x0000);
+ }
SET_BDA(video_pagesize, GET_GLOBAL(vmode_g->slength));
SET_BDA(crtc_address, stdvga_get_crtc());
SET_BDA(video_pagesize, GET_GLOBAL(vmode_g->slength));
SET_BDA(crtc_address, stdvga_get_crtc());
- SET_BDA(video_rows, GET_GLOBAL(vmode_g->theight)-1);
SET_BDA(char_height, cheight);
SET_BDA(video_ctl, 0x60 | (flags & MF_NOCLEARMEM ? 0x80 : 0x00));
SET_BDA(video_switches, 0xF9);
SET_BDA(modeset_ctl, GET_BDA(modeset_ctl) & 0x7f);
SET_BDA(char_height, cheight);
SET_BDA(video_ctl, 0x60 | (flags & MF_NOCLEARMEM ? 0x80 : 0x00));
SET_BDA(video_switches, 0xF9);
SET_BDA(modeset_ctl, GET_BDA(modeset_ctl) & 0x7f);
- SET_BDA(cursor_type
- , GET_GLOBAL(vmode_g->memmodel) == MM_TEXT ? 0x0607 : 0x0000);
int i;
for (i=0; i<8; i++)
SET_BDA(cursor_pos[i], 0x0000);
int i;
for (i=0; i<8; i++)
SET_BDA(cursor_pos[i], 0x0000);
, struct cursorpos ul, struct cursorpos lr)
{
int cheight = GET_GLOBAL(vmode_g->cheight) / 2;
, struct cursorpos ul, struct cursorpos lr)
{
int cheight = GET_GLOBAL(vmode_g->cheight) / 2;
- int cwidth = GET_GLOBAL(vmode_g->pixbits);
+ int cwidth = GET_GLOBAL(vmode_g->depth);
int stride = GET_BDA(video_cols) * cwidth;
void *src_far, *dest_far;
if (nblines >= 0) {
int stride = GET_BDA(video_cols) * cwidth;
void *src_far, *dest_far;
if (nblines >= 0) {
return;
u8 *fdata_g = vgafont8;
return;
u8 *fdata_g = vgafont8;
- u8 bpp = GET_GLOBAL(vmode_g->pixbits);
+ u8 bpp = GET_GLOBAL(vmode_g->depth);
u16 addr = (cp.x * bpp) + cp.y * 320;
u16 src = ca.car * 8;
u8 i;
u16 addr = (cp.x * bpp) + cp.y * 320;
u16 src = ca.car * 8;
u8 i;
stdvga_grdc_write(0x03, 0x00);
break;
case MM_CGA:
stdvga_grdc_write(0x03, 0x00);
break;
case MM_CGA:
- if (GET_GLOBAL(vmode_g->pixbits) == 2)
+ if (GET_GLOBAL(vmode_g->depth) == 2)
addr_far = (void*)((x >> 2) + (y >> 1) * 80);
else
addr_far = (void*)((x >> 3) + (y >> 1) * 80);
if (y & 1)
addr_far += 0x2000;
data = GET_FARVAR(SEG_CTEXT, *addr_far);
addr_far = (void*)((x >> 2) + (y >> 1) * 80);
else
addr_far = (void*)((x >> 3) + (y >> 1) * 80);
if (y & 1)
addr_far += 0x2000;
data = GET_FARVAR(SEG_CTEXT, *addr_far);
- if (GET_GLOBAL(vmode_g->pixbits) == 2) {
+ if (GET_GLOBAL(vmode_g->depth) == 2) {
attr = (color & 0x03) << ((3 - (x & 0x03)) * 2);
mask = 0x03 << ((3 - (x & 0x03)) * 2);
} else {
attr = (color & 0x03) << ((3 - (x & 0x03)) * 2);
mask = 0x03 << ((3 - (x & 0x03)) * 2);
} else {
if (y & 1)
addr_far += 0x2000;
data = GET_FARVAR(SEG_CTEXT, *addr_far);
if (y & 1)
addr_far += 0x2000;
data = GET_FARVAR(SEG_CTEXT, *addr_far);
- if (GET_GLOBAL(vmode_g->pixbits) == 2)
+ if (GET_GLOBAL(vmode_g->depth) == 2)
attr = (data >> ((3 - (x & 0x03)) * 2)) & 0x03;
else
attr = (data >> (7 - (x & 0x07))) & 0x01;
attr = (data >> ((3 - (x & 0x03)) * 2)) & 0x03;
else
attr = (data >> (7 - (x & 0x07))) & 0x01;
int i;
for (i=0; i<ARRAY_SIZE(parammodes); i++) {
int i;
for (i=0; i<ARRAY_SIZE(parammodes); i++) {
- u8 mode = GET_GLOBAL(parammodes[i]);
+ int mode = GET_GLOBAL(parammodes[i]);
if (! mode)
continue;
struct VideoParam_s *vparam_g = &video_param_table[i];
struct vgamode_s *vmode_g = find_vga_entry(mode);
if (!vmode_g)
continue;
if (! mode)
continue;
struct VideoParam_s *vparam_g = &video_param_table[i];
struct vgamode_s *vmode_g = find_vga_entry(mode);
if (!vmode_g)
continue;
- SET_VGA(vparam_g->twidth, GET_GLOBAL(vmode_g->twidth));
- SET_VGA(vparam_g->theightm1, GET_GLOBAL(vmode_g->theight)-1);
- SET_VGA(vparam_g->cheight, GET_GLOBAL(vmode_g->cheight));
+ int width = GET_GLOBAL(vmode_g->width);
+ int height = GET_GLOBAL(vmode_g->height);
+ int cheight = GET_GLOBAL(vmode_g->cheight);
+ if (GET_GLOBAL(vmode_g->memmodel) == MM_TEXT) {
+ SET_VGA(vparam_g->twidth, width);
+ SET_VGA(vparam_g->theightm1, height-1);
+ } else {
+ int cwidth = GET_GLOBAL(vmode_g->cwidth);
+ SET_VGA(vparam_g->twidth, width / cwidth);
+ SET_VGA(vparam_g->theightm1, (height / cheight) - 1);
+ }
+ SET_VGA(vparam_g->cheight, cheight);
SET_VGA(vparam_g->slength, GET_GLOBAL(vmode_g->slength));
memcpy_far(get_global_seg(), vparam_g->sequ_regs
, get_global_seg(), GET_GLOBAL(vmode_g->sequ_regs)
SET_VGA(vparam_g->slength, GET_GLOBAL(vmode_g->slength));
memcpy_far(get_global_seg(), vparam_g->sequ_regs
, get_global_seg(), GET_GLOBAL(vmode_g->sequ_regs)
#define VPARAM(x) &video_param_table[x]
static struct vgamode_s vga_modes[] VAR16 = {
#define VPARAM(x) &video_param_table[x]
static struct vgamode_s vga_modes[] VAR16 = {
- //mode model tx ty bpp cw ch sstart slength
+ //mode model tx ty bpp cw ch sstart slength
// pelm dac sequ misc crtc actl grdc
// pelm dac sequ misc crtc actl grdc
- {0x00, MM_TEXT, 40, 25, 4, 9, 16, SEG_CTEXT, 0x0800
+ {0x00, MM_TEXT, 40, 25, 4, 9, 16, SEG_CTEXT, 0x0800
, 0xFF, PAL(palette2), sequ_01, 0x67, crtc_01, actl_01, grdc_01},
, 0xFF, PAL(palette2), sequ_01, 0x67, crtc_01, actl_01, grdc_01},
- {0x01, MM_TEXT, 40, 25, 4, 9, 16, SEG_CTEXT, 0x0800
+ {0x01, MM_TEXT, 40, 25, 4, 9, 16, SEG_CTEXT, 0x0800
, 0xFF, PAL(palette2), sequ_01, 0x67, crtc_01, actl_01, grdc_01},
, 0xFF, PAL(palette2), sequ_01, 0x67, crtc_01, actl_01, grdc_01},
- {0x02, MM_TEXT, 80, 25, 4, 9, 16, SEG_CTEXT, 0x1000
+ {0x02, MM_TEXT, 80, 25, 4, 9, 16, SEG_CTEXT, 0x1000
, 0xFF, PAL(palette2), sequ_03, 0x67, crtc_03, actl_01, grdc_01},
, 0xFF, PAL(palette2), sequ_03, 0x67, crtc_03, actl_01, grdc_01},
- {0x03, MM_TEXT, 80, 25, 4, 9, 16, SEG_CTEXT, 0x1000
+ {0x03, MM_TEXT, 80, 25, 4, 9, 16, SEG_CTEXT, 0x1000
, 0xFF, PAL(palette2), sequ_03, 0x67, crtc_03, actl_01, grdc_01},
, 0xFF, PAL(palette2), sequ_03, 0x67, crtc_03, actl_01, grdc_01},
- {0x04, MM_CGA, 40, 25, 2, 8, 8, SEG_CTEXT, 0x0800
+ {0x04, MM_CGA, 320, 200, 2, 8, 8, SEG_CTEXT, 0x0800
, 0xFF, PAL(palette1), sequ_04, 0x63, crtc_04, actl_04, grdc_04},
, 0xFF, PAL(palette1), sequ_04, 0x63, crtc_04, actl_04, grdc_04},
- {0x05, MM_CGA, 40, 25, 2, 8, 8, SEG_CTEXT, 0x0800
+ {0x05, MM_CGA, 320, 200, 2, 8, 8, SEG_CTEXT, 0x0800
, 0xFF, PAL(palette1), sequ_04, 0x63, crtc_04, actl_04, grdc_04},
, 0xFF, PAL(palette1), sequ_04, 0x63, crtc_04, actl_04, grdc_04},
- {0x06, MM_CGA, 80, 25, 1, 8, 8, SEG_CTEXT, 0x1000
+ {0x06, MM_CGA, 640, 200, 1, 8, 8, SEG_CTEXT, 0x1000
, 0xFF, PAL(palette1), sequ_06, 0x63, crtc_06, actl_06, grdc_06},
, 0xFF, PAL(palette1), sequ_06, 0x63, crtc_06, actl_06, grdc_06},
- {0x07, MM_TEXT, 80, 25, 4, 9, 16, SEG_MTEXT, 0x1000
+ {0x07, MM_TEXT, 80, 25, 4, 9, 16, SEG_MTEXT, 0x1000
, 0xFF, PAL(palette0), sequ_03, 0x66, crtc_07, actl_07, grdc_07},
, 0xFF, PAL(palette0), sequ_03, 0x66, crtc_07, actl_07, grdc_07},
- {0x0D, MM_PLANAR, 40, 25, 4, 8, 8, SEG_GRAPH, 0x2000
+ {0x0D, MM_PLANAR, 320, 200, 4, 8, 8, SEG_GRAPH, 0x2000
, 0xFF, PAL(palette1), sequ_0d, 0x63, crtc_0d, actl_0d, grdc_0d},
, 0xFF, PAL(palette1), sequ_0d, 0x63, crtc_0d, actl_0d, grdc_0d},
- {0x0E, MM_PLANAR, 80, 25, 4, 8, 8, SEG_GRAPH, 0x4000
+ {0x0E, MM_PLANAR, 640, 200, 4, 8, 8, SEG_GRAPH, 0x4000
, 0xFF, PAL(palette1), sequ_0e, 0x63, crtc_0e, actl_0d, grdc_0d},
, 0xFF, PAL(palette1), sequ_0e, 0x63, crtc_0e, actl_0d, grdc_0d},
- {0x0F, MM_PLANAR, 80, 25, 1, 8, 14, SEG_GRAPH, 0x8000
+ {0x0F, MM_PLANAR, 640, 350, 1, 8, 14, SEG_GRAPH, 0x8000
, 0xFF, PAL(palette0), sequ_0e, 0xa3, crtc_0f, actl_0f, grdc_0d},
, 0xFF, PAL(palette0), sequ_0e, 0xa3, crtc_0f, actl_0f, grdc_0d},
- {0x10, MM_PLANAR, 80, 25, 4, 8, 14, SEG_GRAPH, 0x8000
+ {0x10, MM_PLANAR, 640, 350, 4, 8, 14, SEG_GRAPH, 0x8000
, 0xFF, PAL(palette2), sequ_0e, 0xa3, crtc_0f, actl_10, grdc_0d},
, 0xFF, PAL(palette2), sequ_0e, 0xa3, crtc_0f, actl_10, grdc_0d},
- {0x11, MM_PLANAR, 80, 30, 1, 8, 16, SEG_GRAPH, 0x0000
+ {0x11, MM_PLANAR, 640, 480, 1, 8, 16, SEG_GRAPH, 0x0000
, 0xFF, PAL(palette2), sequ_0e, 0xe3, crtc_11, actl_11, grdc_0d},
, 0xFF, PAL(palette2), sequ_0e, 0xe3, crtc_11, actl_11, grdc_0d},
- {0x12, MM_PLANAR, 80, 30, 4, 8, 16, SEG_GRAPH, 0x0000
+ {0x12, MM_PLANAR, 640, 480, 4, 8, 16, SEG_GRAPH, 0x0000
, 0xFF, PAL(palette2), sequ_0e, 0xe3, crtc_11, actl_10, grdc_0d},
, 0xFF, PAL(palette2), sequ_0e, 0xe3, crtc_11, actl_10, grdc_0d},
- {0x13, MM_PACKED, 40, 25, 8, 8, 8, SEG_GRAPH, 0x0000
+ {0x13, MM_PACKED, 320, 200, 8, 8, 8, SEG_GRAPH, 0x0000
, 0xFF, PAL(palette3), sequ_13, 0x63, crtc_13, actl_13, grdc_13},
, 0xFF, PAL(palette3), sequ_13, 0x63, crtc_13, actl_13, grdc_13},
- {0x6A, MM_PLANAR, 100, 37, 4, 8, 16, SEG_GRAPH, 0x0000
+ {0x6A, MM_PLANAR, 800, 600, 4, 8, 16, SEG_GRAPH, 0x0000
, 0xFF, PAL(palette2), sequ_0e, 0xe3, crtc_6A, actl_10, grdc_0d},
};
, 0xFF, PAL(palette2), sequ_0e, 0xe3, crtc_6A, actl_10, grdc_0d},
};
int i;
for (i = 0; i < ARRAY_SIZE(vga_modes); i++) {
struct vgamode_s *vmode_g = &vga_modes[i];
int i;
for (i = 0; i < ARRAY_SIZE(vga_modes); i++) {
struct vgamode_s *vmode_g = &vga_modes[i];
- if (GET_GLOBAL(vmode_g->svgamode) == mode)
+ if (GET_GLOBAL(vmode_g->mode) == mode)
return vmode_g;
}
return NULL;
return vmode_g;
}
return NULL;