Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters > Algorithms
Register

Reply
 
LinkBack Thread Tools
Old 09.11.2002, 22:56   #1
Студент
 
Join Date: 03 2002
Location: [ Surrealistical World ]
Posts: 312
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post Again page buffering...

Hi there

Another mstic problem here..
Look at the code:

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.
Reply With Quote
Old 10.11.2002, 02:28   #2
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

так трудно сказать.. одно ясно - загружается картинка в видимую страницу. Ты в каком графическом режиме работаешь? Не исключено что в этом твоем режиме всего то одна страница видеопамяти..

нужны детали..если можешь постни весь код.
Reply With Quote
Old 10.11.2002, 06:27   #3
Студент
 
Join Date: 03 2002
Location: [ Surrealistical World ]
Posts: 312
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

I'm using 320x200x256 mode.

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

Code:
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.
__________________
::Against the crowd.
Reply With Quote
Old 10.11.2002, 07:13   #4
Студент
 
Join Date: 03 2002
Location: [ Surrealistical World ]
Posts: 312
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

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.
Reply With Quote
Old 10.11.2002, 17:51   #5
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

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

     a:=trunc(getmaxx/6);

     setvisualpage(0);
     setactivepage(0);
перед самым первым сетактивпэйдж(0) разве не должен стоять сетвижуалпэйдж(1) ?
Reply With Quote
Old 10.11.2002, 18:17   #6
Студент
 
Join Date: 03 2002
Location: [ Surrealistical World ]
Posts: 312
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

I'm very sorry, I wrote I've forgotten to edit the source.

What about this? [revised]:

Code:
   ...
     {draw the background on 0 buffer}
     setactivepage(1);
     setcolor(15);
     outtext('loading');
     setvisualpage(1);
     setactivepage(0);
     loadbgbmp('pablo\home.bmp');
   ...
Reply With Quote
Old 10.11.2002, 19:26   #7
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

gd:=installuserdriver('silverff',nil);

а что это за драйвер
Reply With Quote
Old 11.11.2002, 07:48   #8
Студент
 
Join Date: 03 2002
Location: [ Surrealistical World ]
Posts: 312
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

A eto driver dlya 320x200x256.
Reply With Quote
Old 11.11.2002, 15:56   #9
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

>>pm
Reply With Quote
Old 11.11.2002, 17:16   #10
Студент
 
Join Date: 03 2002
Location: [ Surrealistical World ]
Posts: 312
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

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.
Reply With Quote
Old 11.11.2002, 20:00   #11
Guru Apprentice
 
Join Date: 02 2002
Location: /dev/null
Age: 41
Posts: 524
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Question

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
Code:
 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
__________________
\/\/h47'5 1n 4 n4m3? 7h47 wh1(h w3 (4|| 4 r053,
8y 4ny 07h3r n4m3 w0u|d 5m3|| 45 5w337...
Reply With Quote
Old 12.11.2002, 02:39   #12
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

2Ektich: Exactly. I suspect that there's just one page in that mode.

2Silver: Try Ektich's code. Let us know what happens.
Reply With Quote
Old 12.11.2002, 04:08   #13
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

And if it is possible send me that bgi driver.
abyss-------freenet-------am

Last edited by Dark Abyss of Yerevan; 27.04.2005 at 20:48.
Reply With Quote
Old 12.11.2002, 07:29   #14
Студент
 
Join Date: 03 2002
Location: [ Surrealistical World ]
Posts: 312
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

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.
Reply With Quote
Old 12.11.2002, 15:39   #15
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: 01 2002
Location: hell
Posts: 124
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

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.
__________________
[x]-=-[ ]-=-[x]
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 23:31.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.