About 640*480 resolution
-
- Posts: 20
- Joined: Wed Jun 21, 2006 7:55 am
- Location: China
About 640*480 resolution
I want to work under 640*480 resolution with int 10's 12h, but i have no idea, someone who have that information can help me?
-
- Posts: 20
- Joined: Wed Jun 21, 2006 7:55 am
- Location: China
You want to use the BIOS for it? If not, heres some code on how to switch VGA-mode in 32-bit.
http://bos.asmhackers.net/docs/vga_with ... _2/modes.c
http://bos.asmhackers.net/docs/vga_with ... /MODES.CPP
or you can just look around in my folder:
http://bos.asmhackers.net/docs/vga_without_bios/
And here is some code for putpixel etc in mode 12h (640*480*16):
http://www.snippets.org/pipermail/c/200 ... 00588.html
http://www.snippets.org/pipermail/c/200 ... 00589.html
http://www.snippets.org/pipermail/c/200 ... 00590.html
http://www.snippets.org/pipermail/c/200 ... 00591.html
http://www.snippets.org/pipermail/c/200 ... 00592.html
http://bos.asmhackers.net/docs/vga_with ... _2/modes.c
http://bos.asmhackers.net/docs/vga_with ... /MODES.CPP
or you can just look around in my folder:
http://bos.asmhackers.net/docs/vga_without_bios/
And here is some code for putpixel etc in mode 12h (640*480*16):
http://www.snippets.org/pipermail/c/200 ... 00588.html
http://www.snippets.org/pipermail/c/200 ... 00589.html
http://www.snippets.org/pipermail/c/200 ... 00590.html
http://www.snippets.org/pipermail/c/200 ... 00591.html
http://www.snippets.org/pipermail/c/200 ... 00592.html
this is what I used in my OS: http://my.execpc.com/~geezer/osd/graphics/modes.c
very good piece of code imo
only thing is you have to do a tad bit of 16-to-32bit address conversion but nothing too hard
this is the actual code that I converted it to in my OS:
very good piece of code imo
only thing is you have to do a tad bit of 16-to-32bit address conversion but nothing too hard
this is the actual code that I converted it to in my OS:
Code: Select all
/*insert those video register arrays here*/
void set_plane(unsigned p)
{
unsigned char pmask;
p &= 3;
pmask = 1 << p;
/* set read plane */
outportb(VGA_GC_INDEX, 4);
outportb(VGA_GC_DATA, p);
/* set write plane */
outportb(VGA_SEQ_INDEX, 2);
outportb(VGA_SEQ_DATA, pmask);
}
void write_regs(unsigned char *regs)
{
unsigned i;
/* write MISCELLANEOUS reg */
outportb(VGA_MISC_WRITE, *regs);
regs++;
/* write SEQUENCER regs */
for(i = 0; i < VGA_NUM_SEQ_REGS; i++)
{
outportb(VGA_SEQ_INDEX, i);
outportb(VGA_SEQ_DATA, *regs);
regs++;
}
/* unlock CRTC registers */
outportb(VGA_CRTC_INDEX, 0x03);
outportb(VGA_CRTC_DATA, inportb(VGA_CRTC_DATA) | 0x80);
outportb(VGA_CRTC_INDEX, 0x11);
outportb(VGA_CRTC_DATA, inportb(VGA_CRTC_DATA) & ~0x80);
/* make sure they remain unlocked */
regs[0x03] |= 0x80;
regs[0x11] &= ~0x80;
/* write CRTC regs */
for(i = 0; i < VGA_NUM_CRTC_REGS; i++)
{
outportb(VGA_CRTC_INDEX, i);
outportb(VGA_CRTC_DATA, *regs);
regs++;
}
/* write GRAPHICS CONTROLLER regs */
for(i = 0; i < VGA_NUM_GC_REGS; i++)
{
outportb(VGA_GC_INDEX, i);
outportb(VGA_GC_DATA, *regs);
regs++;
}
/* write ATTRIBUTE CONTROLLER regs */
for(i = 0; i < VGA_NUM_AC_REGS; i++)
{
(void)inportb(VGA_INSTAT_READ);
outportb(VGA_AC_INDEX, i);
outportb(VGA_AC_WRITE, *regs);
regs++;
}
/* lock 16-color palette and unblank display */
(void)inportb(VGA_INSTAT_READ);
outportb(VGA_AC_INDEX, 0x20);
}
static void vmemwr(unsigned dst_off, unsigned char *src, unsigned count)
{
memcpy(dst_off|0xB8000, src, count);
}
void write_font(unsigned char *buf, unsigned font_height)
{
unsigned char seq2, seq4, gc4, gc5, gc6;
unsigned i;
/* save registers
set_plane() modifies GC 4 and SEQ 2, so save them as well */
outportb(VGA_SEQ_INDEX, 2);
seq2 = inportb(VGA_SEQ_DATA);
outportb(VGA_SEQ_INDEX, 4);
seq4 = inportb(VGA_SEQ_DATA);
/* turn off even-odd addressing (set flat addressing)
assume: chain-4 addressing already off */
outportb(VGA_SEQ_DATA, seq4 | 0x04);
outportb(VGA_GC_INDEX, 4);
gc4 = inportb(VGA_GC_DATA);
outportb(VGA_GC_INDEX, 5);
gc5 = inportb(VGA_GC_DATA);
/* turn off even-odd addressing */
outportb(VGA_GC_DATA, gc5 & ~0x10);
outportb(VGA_GC_INDEX, 6);
gc6 = inportb(VGA_GC_DATA);
/* turn off even-odd addressing */
outportb(VGA_GC_DATA, gc6 & ~0x02);
/* write font to plane P4 */
set_plane(2);
/* write font 0 */
for(i = 0; i < 256; i++)
{
vmemwr(16384u * 0 + i * 32, buf, font_height);
buf += font_height;
}
#if 0
/* write font 1 */
for(i = 0; i < 256; i++)
{
vmemwr(16384u * 1 + i * 32, buf, font_height);
buf += font_height;
}
#endif
/* restore registers */
outportb(VGA_SEQ_INDEX, 2);
outportb(VGA_SEQ_DATA, seq2);
outportb(VGA_SEQ_INDEX, 4);
outportb(VGA_SEQ_DATA, seq4);
outportb(VGA_GC_INDEX, 4);
outportb(VGA_GC_DATA, gc4);
outportb(VGA_GC_INDEX, 5);
outportb(VGA_GC_DATA, gc5);
outportb(VGA_GC_INDEX, 6);
outportb(VGA_GC_DATA, gc6);
}
/*insert those other arrays here*/