Graphics mode switching

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
gtsphere

Graphics mode switching

Post by gtsphere »

I have a general question that requires a lot of depth, heh.

I was wondering how, in C, i could switch from normal text mode, to graphics mode like 320x200 ?

in example, f1 = text f12 = graphics mode?

is that even possible to switch from one to the other while the kernel is running? i'm sure it is because of windows, etc, so any ideas on how to load grahpics mode in C?

thanks alot in advance!
Slasher

Re:Graphics mode switching

Post by Slasher »

hi,
if your kernel is in protected mode, you have 2 options
1. switch to real mode,execute int 10h then switch back to protected mode
2. program a v86 monitor to enable you call bios from protected mode.

option 1 is easier than option 2 but its slower. also in option 1, you have to make sure that you do not use areas of memory below 1mb that is also used by BIOS. I also think (i haven't tried this yet ) that is you reprogram the timer in protected mode that it should be set back to the 18.2hz when you switch to real mode. ( correct me anyone that has done any of this :) )

on your second question, to change to graphics mode you have to use BIOS call 10h sub function 00h
ie
ah = 0h
al = mode number
for 320 * 200 256 color, mode number is 13h (19 decimal)
for 25 * 80 text, mode number is 03h (3 decimal)

in asm (NASM)

global _set_mode

_set_mode:
push bp
mov bp,sp
push ax
mov ah,0h
mov al, byte [bp+4]
int 10h
pop ax
mov sp,bp
pop bp
ret
complie the asm file with
nasm -faout xxxx.asm -o xxxx.o

then include it in the list of object files when linking the kernel,
DON'T CALL THIS FUNCTION IN PROTECTED MODE!!!!!!! :o
this is the function protoype for c

void set_mode(int mode);
in c code to set 320*200*256

set_mode(0x13);

hope this helps ;D
K.J.

Re:Graphics mode switching

Post by K.J. »

There is a 3rd option, directly program the VGA registers(this can be done totally in PMode). The Tauron VGA utilities has code for directly programming the VGA registers:
http://www.newkingstreet.com/zip02/TAURON30.ZIP

K.J.
Berserk

Re:Graphics mode switching

Post by Berserk »

Ok,

But how do i switch to Real Mode?? (from my Kernel)

& also, i might make a vm86 monitor, i searched google, I JUST CAN'T find ANY tutorials on vm86, do if you could explain it a bit, how i would make it & all that, & maybe you know some good tutorials?

But i'd actually want an example (if possible)

So, Please...HEELLPPP!!!

ciao 8)
Mr_Spam

Re:Graphics mode switching

Post by Mr_Spam »

the IA-32 programmers manual volume 3 describes how to switch modes and has detail on vm86.
Berserk

Re:Graphics mode switching

Post by Berserk »

unfortunately, i do not have the manual, so, if somebody could please help me find a walkthrough or explain it themselves.

Thank you in advance 8)

ciao ;)
Tom

Re:Graphics mode switching

Post by Tom »

Berserk....DO NOT try v86 mode now!

I am telling you...it is TOO much to learn right now. For me, v86 is very hard.

I'm not saying just very hard, you need a IDT, a GDT, a LDT, a v86 monitor....more....more....
(I think)
Berserk

Re:Graphics mode switching

Post by Berserk »

good advice, i am not going to.

(i came up with another idea) i just need some answers to questions, read the other thread.

Please...I really need these questions answered.

(if you know how)

ciao 8)
Post Reply