Page 1 of 1

VIdeo Programming.

Posted: Wed Sep 26, 2007 6:37 pm
by OctalMage
I want to do something that sounds like it should be simple.

All I want to do, is write directly to the video memory, without writing my own os or my own drivers.

There has to be a way, using assembly I would assume, to change the pixels different colors. Like turn pixel, 5,5, blue.

Anyway, I hope I provided enough information.

Im in linux, but I have windows and dos.

Thanks in advance,
OctalMage

Posted: Wed Sep 26, 2007 6:46 pm
by JackScott
Using 16 bit assembly, you can use BIOS functions (not sure which ones) to switch to your preferred video mode and then write directly to 0xb8000. If you use MS-DOS (which has a distinct lack of memory protection), you'll be able to do this with no special code or permissions.

In 32 bits, such as Windows or Linux, it's a bit harder due to the kernel's memory protection. In this case, the simplest thing to do is to request permission to write to a frame buffer from the operating system, and then write to that.

How to write the pixel depends on the video mode, but it will usually just involve writing RGB codes (of the right size, eg 8/16/24/32 bits) to an offset in that framebuffer.

Posted: Wed Sep 26, 2007 6:51 pm
by OctalMage
Thanks for your quick reply, It was suggested to me to use dos, so Im installing FreeDos on a virtual harddrive right now.

Lets say I'm going to take that route, does anyone have any tutorials?

Thanks,
OctalMage

Posted: Wed Sep 26, 2007 6:53 pm
by jerryleecooper
I was writing a plasma effect in visual c++ clr, and because of a bug in my program, it happened that I wrote dirrectly on the screen, it was not pretty, all those lines on the screen. So writing directly on the screen with WIndows XP home edition is possible, just make sure to lock your bitmap, and

Code: Select all

ch = (char*)bm->Scan0.ToPointer();
and you get it.
In linux there's th framebuffer, in dos, the bios.

Posted: Wed Sep 26, 2007 7:05 pm
by OctalMage
Right now my goal is to do it with out using any libraries, because of the possibility that I might develop my own os.

So in dos, I should be able to write directly to the video memory. Does anyone know of a tutorial on how to do this, all of the ones that I have see went into how to develop your own os too.

Thanks,
OctalMage

Posted: Wed Sep 26, 2007 7:10 pm
by JackScott
Google is your friend:
http://www.brackeen.com/vga/ is one I use. Has info on VGA and mode 0x13, right through to drawing lines, circles, and filling in rectangles.

Posted: Wed Sep 26, 2007 10:18 pm
by Dex
I written a small demo for someone for dos, that may help, see zip file.
Also off the top of my head try

Code: Select all

  ; c:\fasm Demo.asm Demo.com        ;
	org   100h
	use16
start:
	mov	ax,0013h		   ; set video mode13h
	int	10h
	push	0A000h
	pop	es
	mov     di,320*5+5                 ; XY
	mov     al,9                       ; color
	stosb

	mov	ah,00h			   ; wait for key press.
	int	16h
LetsGo:
	mov	ax,0003h		   ; change to text mode
	int	10h
	ret				   ; return to dos