VIdeo Programming.

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
OctalMage
Posts: 3
Joined: Wed Sep 26, 2007 6:31 pm

VIdeo Programming.

Post 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
User avatar
JackScott
Member
Member
Posts: 1036
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Mastodon: https://aus.social/@jackscottau
Matrix: @JackScottAU:matrix.org
GitHub: https://github.com/JackScottAU
Contact:

Post 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.
OctalMage
Posts: 3
Joined: Wed Sep 26, 2007 6:31 pm

Post 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
User avatar
jerryleecooper
Member
Member
Posts: 233
Joined: Mon Aug 06, 2007 6:32 pm
Location: Canada

Post 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.
OctalMage
Posts: 3
Joined: Wed Sep 26, 2007 6:31 pm

Post 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
User avatar
JackScott
Member
Member
Posts: 1036
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Mastodon: https://aus.social/@jackscottau
Matrix: @JackScottAU:matrix.org
GitHub: https://github.com/JackScottAU
Contact:

Post 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.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post 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
Attachments
bmp.zip
(13.21 KiB) Downloaded 22 times
Post Reply