Mail Archives: djgpp/1998/12/20/18:05:34
From: | jsc AT lds DOT co DOT uk
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Gaps between my banks (vesa prog question)
|
Date: | Sun, 20 Dec 1998 22:54:51 GMT
|
Organization: | Deja News - The Leader in Internet Discussion
|
Lines: | 121
|
Message-ID: | <75jv7q$qc0$1@nnrp1.dejanews.com>
|
NNTP-Posting-Host: | 194.73.88.152
|
X-Article-Creation-Date: | Sun Dec 20 22:54:51 1998 GMT
|
X-Http-User-Agent: | Mozilla/2.0 (compatible; MSIE 3.0; Windows 95)
|
X-Http-Proxy: | 1.0 x10.dejanews.com:80 (Squid/1.1.22) for client 194.73.88.152
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hello all! This is really baffling me - I'm hoping that some kind soul can
help me out here. This is really basic vesa (1.something-or-other) pixel
plotting code using bank switching. Now, I worked out most of it on my own.
Indeed, for the most part it works, but you'll notice if you run it, that
there's a horrible black hole at the end of each bank - the first pixel of
each bank (except bank 0) jumps forward a few hundred pixels. I can't see why
or how to stop it. I tried adding "if (my_bank>0) {offset -=100 (or, the
number of places it is jumping)} but that didn't work - it simply won't write
anything in those spaces. Please help, someone - It's really bugging me and I
genuinely can't think of where to go next. Code follows below BTW I know that
my win granularity = 64 and my banks are labelled 0,1,2,3... So I left those
bits out of the code (for simplicity eg 64/win gran ==1) Thanks and Merry
Christmas! Christopher Anthony jsc AT lds DOT co DOT uk
#include <stdio.h>
#include <dos.h>
#include <bios.h>
#include <sys/farptr.h>
#include <go32.h>
#include <dpmi.h>
#define far
void ExitGraphics(void)
{
union REGS regs;
regs.x.ax = 0x3;
int86(0x10, ®s,®s);
}
int set_mode (int mode)
{
union REGS regs;
regs.x.ax = 0x4F02;
regs.x.bx = mode;
int86(0x10, ®s, ®s);
return regs.x.ax; // zero if successful, non-zero otherwise
}
int bank_switch(int bank_no)
{
union REGS regs;
regs.x.ax = 0x4F05;
regs.x.bx = 0; ///check this line - is it relevant?
regs.x.dx = bank_no;
int86(0x10, ®s, ®s);
return regs.x.ax; // zero if successful, non-zero otherwise
}
void plot_pixel (long x, long y, int colour, int rgba)
{
long offset;
int my_bank;
// remember not y*640 as there's 4 times
// more bytes in each line
offset = (long)y*2560 + ((long)x * 4) + rgba;
my_bank=(int)(offset/64000);
bank_switch(my_bank);
offset=offset - (64000*(int)my_bank);
_farpokeb(_dos_ds, 0xa0000 + (long)offset, colour);
//rgba is either 1, 2, 3 or 4 and represents whether you are setting
//the b, g, r or alpha.
//It's really easy to work out why its x*4 + rgba - just draw a diagram.
}
int main(void)
{
int a, b;
long index;
set_mode(0x112);
for(b=0; b<480; b++)
{
for(a=0; a<640; a++)
{
plot_pixel(a, b, 255, 0);
plot_pixel(a, b, 255, 1);
plot_pixel(a, b, 255, 2);
}
}
/*
for(b=0; b<26; b++)
{
plot_pixel(0, b, 255, 0);
plot_pixel(0, b, 255, 1);
plot_pixel(0, b, 255, 2);
}
plot_pixel(0, 25, 255, 0);
plot_pixel(0, 25, 255, 1);
plot_pixel(0, 25, 255, 2);
plot_pixel(639, 10, 255, 0);
plot_pixel(639, 10, 255, 1);
plot_pixel(639, 10, 255, 2);
plot_pixel(639, 300, 255, 0);
plot_pixel(639, 300, 255, 1);
plot_pixel(639, 300, 255, 2);
plot_pixel(639, 400, 255, 0);
plot_pixel(639, 400, 255, 1);
plot_pixel(639, 400, 255, 2);
*/
getch();
ExitGraphics();
return 0;
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
- Raw text -