http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SVGALIB and memory offsets



Hi,

I've only recently started using SVGALIB under Linux, and so far so good, but I only have one little problem. I'm writing a game, I started out under Dos, but I decided to write both Dos and Linux at the same time, since it's mostly only graphics that's different, and I'm using #define's to select Dos/Linux. But anyways, this is my problem:

I'm using the following loop to write an image to the screen (under Dos, imagepos is unsigned int):

	for (imagepos = 0; imagepos < 64000; imagepos++) {
		imageread = fgetc(filehandle);
		asm {
			mov ax, 0a000h
			mov es, ax
			mov ax, imagepos
			mov di, ax
			mov ax, imagepos
			mov [es:di], ax
		}
	}

This works fine under Dos, but when I try to re-write it for Linux, I get the problem: The Asm routine uses memory offsets, but vga_drawpixel() uses x/y locations. How do I convert them? I know how to calculate an offset from x/y, but how do I do the opposite? I tried working something out, but it looks like I'm just too stupid :-). Can somebody please tell me what to do?

This is what it looks like so far:

	for (imagepos = 0; imagepos < 64000; imagepos++) {
		imageread = fgetc(filehandle);
		vga_setcolor(imageread);
		vga_drawpixel(?, ?);
	}

Does this look okay? I'm quite a newbie (especially to SVGALIB), so it might be all wrong! I've also been thinking about using something like:

	vga_drawpixel(offset, 0);

If I'm correct, when SVGALIB calculates the offset, it would do:

	offset = 320 * 0 + offset;

Is this correct? Would it work? Or wouldn't the funcion accept an X value higher than that of the screen resolution? Or not above 32k? Since it is an int.

Kind regards,

Lionel Pinkhard

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html