PDA

View Full Version : Again page buffering...


Rust
Nov 9, 2002, 22:56
Hi there

Another mstic problem here..
Look at the code:

...
setactivepage(0);
setvisualpage(0);
textout('Loading...');

setactivepage(1);
DoLoad****(); {very slow bmp loading function}
setvisualpage(1);
...vopros:: pochemu on ne dojidaetsya polnogo load-a bmp, a pokazyvaet kak ono loadaetsya??
thx a lot.

Dark Abyss of Yerevan
Nov 10, 2002, 02:28
так трудно сказать.. одно ясно - загружается картинка в видимую страницу. Ты в каком графическом режиме работаешь? Не исключено что в этом твоем режиме всего то одна страница видеопамяти..

нужны детали..если можешь постни весь код.

Rust
Nov 10, 2002, 06:27
I'm using 320x200x256 mode.

Here is the complete code in Pascal [I have no other selection :( ]:

program poneslas_muzhiki;
uses crt,graph;

var P1,P2,M,CS: pointer;
size: word;
x,y,a,c: integer;
gd,gm:integer;
bp,bv:integer;


procedure loadbgbmp(ff:string);
var
f: file of byte;
cc: byte;
x,y: integer;
begin
assign(f,ff);

reset(f);
seek(f,filesize(f)-(320*200));

for y:=200 downto 1 do begin
for x:=1 to 320 do begin
read(f,cc);
putpixel(x-1,y-1,cc);
end;
end;

end;


begin
{initgraph}
gd:=installuserdriver('silverff',nil); {install the 320x200x256 BGI driver}
gm:=0; {320x200x256 mode}
initgraph(gd,gm,' ');

{draw object}
setfillstyle(1,255);
for x:=0 to 20 do begin
for y:=0 to 40 do begin
c:=random(255)+1;
putpixel(x,y,c);
end;
end;

setfillstyle(1,0);
bar(5,5,15,35);
for x:=0 to 20 do begin
for y:=0 to 40 do begin
c:=random(255)+1;
putpixel(x,y+40,c);
end;
end;
bar(5,45,15,75);
readln;
setfillstyle(1,255);
bar(20,0,39,40);
setfillstyle(1,0);
bar(25,5,35,35);
{
setcolor(255);
ellipse(10,20,0,360,10,20);
floodfill(10,20,255);
}

{transparency mask}

{
ellipse(30,20,0,360,10,20);
setfillstyle(1,255);
floodfill(30,20,255);
}
readln;

size:=imagesize(0,0,19,40);

{set pointer addresses}
getmem(P1,size);
getmem(P2,size);
getmem(M,size);
getmem(CS,size);

{take object and mask}
getimage(0,0,19,40,P1^);
getimage(20,0,40,40,M^);
getimage(0,40,19,80,P2^);
cleardevice;

{draw the background on 0 buffer}
setactivepage(0);
loadbgbmp('pablo\home.bmp');

a:=trunc(getmaxx/6);

setvisualpage(0);
setactivepage(0);
{
putimage(30,100,M^,orput);
putimage(30,100,P^,xorput);
}
readln;

y:=0;
for x:=0 to a do begin
y:=x;
if (odd(x)) then begin
bp:=1;
end
else begin
bp:=0;
end;

setactivepage(bp);
getimage(x*2,y,x*2+19,y+40,CS^);
putimage(x*2,y,M^,orput);
if bp=1 then putimage(x*2,y,P1^,xorput) else putimage(x*2,y,P2^,xorput);
setvisualpage(bp);
delay(2000);
putimage(x*2,y,CS^,normalput);
end;
readln;
end.I'm very sorry, I didn't edit my program at all so there may be concerns about remarks... just ignore them.
What this program does is loading a BMP file as a background and moving a transparent sprite on it.

thanks a lot.

Rust
Nov 10, 2002, 07:13
By the way...
FYI [not to make you lost in the source]: there are two sprites loaded - one in P1, and second in P2, so animation sequentially shows P1 and P2 sprites. It's just test purposes, in the future it'll become a guy who will walk. thanks.

Dark Abyss of Yerevan
Nov 10, 2002, 17:51
Постой, может я чего то не так понял, но ведь у тебя же там бмп загружается в видимую страницу:
setactivepage(0);
loadbgbmp('pablo\home.bmp');

a:=trunc(getmaxx/6);

setvisualpage(0);
setactivepage(0);перед самым первым сетактивпэйдж(0) разве не должен стоять сетвижуалпэйдж(1) ?

Rust
Nov 10, 2002, 18:17
I'm very sorry, I wrote I've forgotten to edit the source.

What about this? [revised]:

...
{draw the background on 0 buffer}
setactivepage(1);
setcolor(15);
outtext('loading');
setvisualpage(1);
setactivepage(0);
loadbgbmp('pablo\home.bmp');
...

Dark Abyss of Yerevan
Nov 10, 2002, 19:26
gd:=installuserdriver('silverff',nil);

а что это за драйвер

Rust
Nov 11, 2002, 07:48
A eto driver dlya 320x200x256.

Dark Abyss of Yerevan
Nov 11, 2002, 15:56
>>pm

Rust
Nov 11, 2002, 17:16
Hi there.

Sorry for non-informative answer - I had really no time to answer then :)
here we go.

silverff is a BGI driver for 320200256 mode as you already know.
It's not written by me... It was a .PAS file converted to BGI by me using a 3rd party converter.
It is a 3rd party driver, and the source code isn't available coz I had downloaded it long ago, and I dont remember the site from which I have downloaded it.

If you can provide your own driver, or if you can help with finding another - better one, please respond.

I'm sure that there IS a page flipping support in that mode, maybe not in that BGI driver, but there for sure IS.

That's it I'm waiting for your quick reply.

Thanks a lot for assitance,
Silver.

Ektich
Nov 11, 2002, 20:00
Silly question, but did you check with some other plotting subroutinse that there are two pages in the driver you're using?
Just try something like
setvisualpage(0);
setactivepage(1);
plot(); {or what was the command in PASCAL?? maybe driver you're using doesn't have pages?
I never investigated too deep how exactly this pages stuff works. I suppose it's nothing to do with PASCAL, Agregat was saying something about asm, so I think it's shomething to do with BIOS int 10 (or Agregat was suggesting to write in video memory directly? That's not very compatible, AFAIK).

Actually, you can call interupts from PASCAL without any asm things invovled. I've done this once, switched to 320x200x256 mode by calling int 10, then - draw a line using the same int... But wouldn't remember how exactly I've done this ;)

And, some BGI drivers worth look at (IMHO)
http://pascal.sources.ru/graph/svga256.zip

Dark Abyss of Yerevan
Nov 12, 2002, 02:39
2Ektich: Exactly. I suspect that there's just one page in that mode.

2Silver: Try Ektich's code. Let us know what happens.

Dark Abyss of Yerevan
Nov 12, 2002, 04:08
And if it is possible send me that bgi driver.
abyss-------freenet-------am

Rust
Nov 12, 2002, 07:29
Hello dear people.

I don't anymore care for those ****ing BGI files, I was so nervous today about them that I removed all 'uses graph;'s from my codes and wrote a completely new graphics library on Assembly. So I may say that although my brain f***ing hurts, my graphics go CRAZILY FAST!! :)
All stuff about page flipping, etc, I've realized myself.
The only two functions left to write are GetImage/PutImage... I'm sure I'll write them soon, but if anyone has ideas on how to write them in the most optimal way, please reply...

Thanks a lot for all your help.

Again I'm assuring myself that 3rd party sux.

ABYSS:: You still need that .bgi? If so, no probs - I can send it to you.

EKTICH:: Drivers on that link ain't work about flipping either.

Regards,
Silver.

Dark Abyss of Yerevan
Nov 12, 2002, 15:39
Yes, that's the best way to make things work ;)
As to the getimage/putimage, there are actually 2 ways of doing it.
First, getimage will just copy the rectangle from the video memory to other place, and putimage will blit from mem to videomem. This is done very easily with a set of rep/movsb[w] s.
And second, if you need transparent images, you can write some functions for blitting RLE encoded sprites.
I used to do this kind of things in C long time ago, so the lib is still http://users.freenet.am/~abyss/moz/GLIB.ZIP
There are a lot of good functions there that you can easily translate to Pascal.
P.S. Have you tried the ModeX library for Pascal? ModeX was actually what most of the game developers used in the DOS Epoch, before the protected mode dos extenders(dos4gw) appeaared on the scene.