Plotting desktop
Plotting desktop
I want to see if I can develop a GUI in 16-bit real mode (don't ask why...), but I'm stuck at the very start. I'm trying to draw the desktop, wich sounds like an easy enough task, but I can't get it quite right. I have cleared the screen and set VGA mode 12h. Now I just need a routine to plot a colored box that covers the whole 640x480 screen.
Can anyone give some code or snippets for this simple task? Thanks in advance!
(P.S. I know that graphics in real mode are slow, but I just want to give it a try.)
Can anyone give some code or snippets for this simple task? Thanks in advance!
(P.S. I know that graphics in real mode are slow, but I just want to give it a try.)
Re:Plotting desktop
Hi
First no one will give you code,as this will not help you,second if you have cleared your 640x480x16 screen,
then by puting the right color in the reg, will do what you want.
You would also be best useing 13 mode,to start with as it will be easyer for you.
Also you should tell people what language you use.
Here alink that may help you make a gui in real mode(get "obmaker.zip")
http://www.tomaskovic.com/other.html
PS. real mode graphics are not slow.
ASHLEY4.
First no one will give you code,as this will not help you,second if you have cleared your 640x480x16 screen,
then by puting the right color in the reg, will do what you want.
You would also be best useing 13 mode,to start with as it will be easyer for you.
Also you should tell people what language you use.
Here alink that may help you make a gui in real mode(get "obmaker.zip")
http://www.tomaskovic.com/other.html
PS. real mode graphics are not slow.
ASHLEY4.
Re:Plotting desktop
Thanks for the reply
1. I'm sorry for not saying what language I use: I was going to say that it could be in C or asm, but I thought you'd assume that.
2. That obmaker thing didn't export any useful code, mainly just jibberish.
3. Could you possibly provide an example for clearing the screen and filling it with a color? Thanks!
1. I'm sorry for not saying what language I use: I was going to say that it could be in C or asm, but I thought you'd assume that.
2. That obmaker thing didn't export any useful code, mainly just jibberish.
3. Could you possibly provide an example for clearing the screen and filling it with a color? Thanks!
Re:Plotting desktop
Some links:
Mouse in mode 12h:
http://www.programmersheaven.com/zone5/cat710/1423.htm
how does it work:
http://www.programmersheaven.com/search/download.asp?FileID=6376
Mouse in mode 12h:
http://www.programmersheaven.com/zone5/cat710/1423.htm
how does it work:
http://www.programmersheaven.com/search/download.asp?FileID=6376
Code: Select all
mov ax, 0xA000
mov es, ax
mov di, 0
mov dx, 0x03C4 ; Enable write to all bitplanes
mov ax, 0x0F02
out dx, ax
mov cx, 0x8000
mov ax, 0x0000 ; color = 0 = black
rep stosw
Re:Plotting desktop
Bubach,
Thanks for the links, those should prove useful later in my GUI development. As for the code: what video mode is it intended for? I changed the color to 0x9. It works on 12h and 13h, but on both modes the screen is striped blue and black, instead of solid blue! Is this supposed to happen or is it a mode problem?
Thanks again!
Thanks for the links, those should prove useful later in my GUI development. As for the code: what video mode is it intended for? I changed the color to 0x9. It works on 12h and 13h, but on both modes the screen is striped blue and black, instead of solid blue! Is this supposed to happen or is it a mode problem?
Thanks again!
Re:Plotting desktop
Try it like this:
Also try this to get 640x480x256
ASHLEY4.
Code: Select all
mov ax, 0xA000
mov es, ax
mov di, 0
mov dx, 0x03C4 ; Enable write to all bitplanes
mov ax, 0x0F02
out dx, ax
mov cx, 0x8000
mov ax, 0x0909 ;<TRY THIS color = 0 = black
rep stosw
Also try this to get 640x480x256
Code: Select all
; uses vesa (1
; assembles in NASM
mov ax,4f02h ;set vesa 1.0 screen mode
mov bx,101h ;640*480*256
int 10h
mov dx,0xa000
mov ds,dx ;sets up registers
call window
rain:
xor dx,dx ;(pages-1)
mouse:
push dx
call window
xor bx,bx
mov al, 0cch
call dog
pop dx
cmp dx,4
je rain
inc dx
mov ah,01h
int 16h
jz mouse
mov ax,0003h
int 10h
mov ax,4c00h ; This is just
int 21h ; for test ,take it out in your OS
window:
mov ax,4f05h ;vesa 1 window select
mov bx,0
int 10h ;dx is the reqired window
xor bx,bx
ret
dog: ;(4*2^16)+45056 pixels
mov [bx],al
inc bx
cmp bx,$00000
jne dog
ret
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Plotting desktop
in mode 12, you have four planes of bits. Each bit is one of the color's bits, so if you want to draw something in dark-ceylan (0011), you need to write a '1' at that pixel's bit in plane #0, a '1' in plane #1, a '0' in plane #2 and a '0' in plane #3.
This means that your drawing function will require a lot of optimization (they always do, anyway to be efficient: the approach
should be restricted to single-pixel plotting. Drawing boxes, lines, bitmaps, etc. should take the advantage they're accessing several bits from the same character in video[] (reducing VRAM read and writes), and could benefit of 'operating mode = AND/OR/XOR' setting on the VGA card (so that you just write X and the video memory become new_content = old_content & X in a single memory cycle).
I strongly suggest you consider using 256 colors approach instead. And if you can afford it, turn in unreal mode and use the LinearFrameBuffer to forget about banking, etc. and unleash the power of your VESA card with 1024x768x16M
This means that your drawing function will require a lot of optimization (they always do, anyway to be efficient: the approach
Code: Select all
virtual_offset = x+y*640;
for (i=0;i<4;i++, color=color/2) {
switch_plane(i)
video[virtual_offset/8]=((video[virtual_offset/8]& ~(1<<i)) | color)
}
I strongly suggest you consider using 256 colors approach instead. And if you can afford it, turn in unreal mode and use the LinearFrameBuffer to forget about banking, etc. and unleash the power of your VESA card with 1024x768x16M
Re:Plotting desktop
The color's called cyanPype.Clicker wrote: in mode 12, you have four planes of bits. Each bit is one of the color's bits, so if you want to draw something in dark-ceylan (0011), you need to write a '1' at that pixel's bit in plane #0, a '1' in plane #1, a '0' in plane #2 and a '0' in plane #3.
FYI, the colors are coded with LSB = blue, bit 1 = green, bit 2 = rood, MSB = bright. So 0001 is dark blue and 1010 is bright green.
Re:Plotting desktop
The color's called "red". ;DCandy wrote: FYI, the colors are coded with LSB = blue, bit 1 = green, bit 2 = rood...
Every good solution is obvious once you've found it.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Plotting desktop
*rofl*Candy wrote: The color's called cyan
The color's called red ;D
damn't where did i lost that that blleue pill again
Re:Plotting desktop
thanks, missed thatSolar wrote:The color's called "red". ;DCandy wrote: FYI, the colors are coded with LSB = blue, bit 1 = green, bit 2 = rood...
*roflmao irl*
So, the second bit is red
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Plotting desktop
and it's actually the *third* one as bit 0 is the first one ;DCandy wrote: So, the second bit is red
btw, that's somehow fun ... but aren't we hitchhiking the forum from it's initial intent (somehow).
Re:Plotting desktop
Fast 16-color graphics code = large, hard-to-understand code (this is also true for banked framebuffer code). But here ya go:
http://my.execpc.com/~geezer/osd/graphics/grdemo.c
Should work with 16-bit Turbo C. For filled rectangles, the functions you want are fill_rect4p(), fill_plane(), and set_plane()
If you don't understand fill_rect4p() and fill_plane(), there is also a write_pixel4p() in there, but it's much slower (four plane-switches for each pixel!)
http://my.execpc.com/~geezer/osd/graphics/grdemo.c
Should work with 16-bit Turbo C. For filled rectangles, the functions you want are fill_rect4p(), fill_plane(), and set_plane()
If you don't understand fill_rect4p() and fill_plane(), there is also a write_pixel4p() in there, but it's much slower (four plane-switches for each pixel!)