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
VIdeo Programming.
- JackScott
- 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:
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.
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.
- jerryleecooper
- Member
- Posts: 233
- Joined: Mon Aug 06, 2007 6:32 pm
- Location: Canada
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 and you get it.
In linux there's th framebuffer, in dos, the bios.
Code: Select all
ch = (char*)bm->Scan0.ToPointer();
In linux there's th framebuffer, in dos, the bios.
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
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
- JackScott
- 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:
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.
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.
I written a small demo for someone for dos, that may help, see zip file.
Also off the top of my head try
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