AKB Forums

Go Back   AKB Forums > Technical sections > Algorithms
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Algorithms The source of algorithms for your project

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Nov 9, 2002, 21:56   #1
Студент
 
Join Date: Mar 2002
Location: [ Surrealistical World ]
Posts: 312
Rep Power: 7
Reputation: 10
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.
__________________
::Against the crowd.
Rust is offline   Reply With Quote Quote selected
Old Nov 10, 2002, 01:28   #2
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
Post

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

нужны детали..если можешь постни весь код.
__________________
[x]-=-[ ]-=-[x]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Nov 10, 2002, 05:27   #3
Студент
 
Join Date: Mar 2002
Location: [ Surrealistical World ]
Posts: 312
Rep Power: 7
Reputation: 10
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.
Rust is offline   Reply With Quote Quote selected
Old Nov 10, 2002, 06:13   #4
Студент
 
Join Date: Mar 2002
Location: [ Surrealistical World ]
Posts: 312
Rep Power: 7
Reputation: 10
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.
__________________
::Against the crowd.
Rust is offline   Reply With Quote Quote selected
Old Nov 10, 2002, 16:51   #5
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
Post

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

     a:=trunc(getmaxx/6);

     setvisualpage(0);
     setactivepage(0);
перед самым первым сетактивпэйдж(0) разве не должен стоять сетвижуалпэйдж(1) ?
__________________
[x]-=-[ ]-=-[x]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Nov 10, 2002, 17:17   #6
Студент
 
Join Date: Mar 2002
Location: [ Surrealistical World ]
Posts: 312
Rep Power: 7
Reputation: 10
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');
   ...
__________________
::Against the crowd.
Rust is offline   Reply With Quote Quote selected
Old Nov 10, 2002, 18:26   #7
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
Post

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

а что это за драйвер
__________________
[x]-=-[ ]-=-[x]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Nov 11, 2002, 06:48   #8
Студент
 
Join Date: Mar 2002
Location: [ Surrealistical World ]
Posts: 312
Rep Power: 7
Reputation: 10
Post

A eto driver dlya 320x200x256.
__________________
::Against the crowd.
Rust is offline   Reply With Quote Quote selected
Old Nov 11, 2002, 14:56   #9
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
Post

>>pm
__________________
[x]-=-[ ]-=-[x]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Nov 11, 2002, 16:16   #10
Студент
 
Join Date: Mar 2002
Location: [ Surrealistical World ]
Posts: 312
Rep Power: 7
Reputation: 10
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.
__________________
::Against the crowd.
Rust is offline   Reply With Quote Quote selected
Old Nov 11, 2002, 19:00   #11
Guru Apprentice
 
Join Date: Feb 2002
Location: /dev/null
Posts: 520
Rep Power: 7
Reputation: 10
Send a message via ICQ to Ektich Send a message via Yahoo to Ektich
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...
Ektich is offline   Reply With Quote Quote selected
Old Nov 12, 2002, 01:39   #12
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
Post

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

2Silver: Try Ektich's code. Let us know what happens.
__________________
[x]-=-[ ]-=-[x]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Nov 12, 2002, 03:08   #13
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
Post

And if it is possible send me that bgi driver.
abyss-------freenet-------am
__________________
[x]-=-[ ]-=-[x]

Last edited by Dark Abyss of Yerevan : Apr 27, 2005 at 19:48.
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Old Nov 12, 2002, 06:29   #14
Студент
 
Join Date: Mar 2002
Location: [ Surrealistical World ]
Posts: 312
Rep Power: 7
Reputation: 10
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.
__________________
::Against the crowd.
Rust is offline   Reply With Quote Quote selected
Old Nov 12, 2002, 14:39   #15
Дошкольник
 
Dark Abyss of Yerevan's Avatar
 
Join Date: Jan 2002
Location: hell
Posts: 124
Rep Power: 7
Reputation: 10
Send a message via ICQ to Dark Abyss of Yerevan
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]
Dark Abyss of Yerevan is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 00:52.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link