www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/03/18:30:40

From: "23yrold3yrold" <cbarry AT pangea DOT ca>
Newsgroups: comp.os.msdos.djgpp
References: <395e61e0_2 AT spamkiller DOT newsfeeds DOT com>
Subject: Re: Using (page-flipping) to speed up a program
Date: Sun, 2 Jul 2000 10:53:54 -0500
Lines: 76
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
NNTP-Posting-Host: 64.4.88.210
Message-ID: <395fcb12_1@spamkiller.newsfeeds.com>
X-Trace: 2 Jul 2000 18:06:58 -0500, 64.4.88.210
X-Comments: This message was posted through Newsfeeds.com
X-Comments2: IMPORTANT: Newsfeeds.com does not condone, nor support, spam or any illegal or copyrighted postings.
X-Comments3: IMPORTANT: Under NO circumstances will postings containing illegal or copyrighted material through this service be tolerated!!
X-Report: Please report illegal or inappropriate use to <abuse AT newsfeeds DOT com> You may also use our online abuse reporting from: http://www.newsfeeds.com/abuseform.htm
X-Abuse-Info: Please be sure to forward a copy of ALL headers, INCLUDING the body (DO NOT SEND ATTACHMENTS)
Organization: Newsfeeds.com http://www.newsfeeds.com 73,000+ UNCENSORED Newsgroups.
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

First of all, thanks to everyone who helped me with understanding the timer
issue; due to those responses, I've decided to put the timer bit on the back
burner (the program needs no help slowing down) and figure out
page-flipping. However, here I have also run into a snag.

I found the original program refused to page flip, simply because 640 x 960
seems too big for it to handle. So I triedshrinking it to Mode-X 320 x 240
to see if I could get that to work (I want it in 640 x 480 ultimately, but I
tried this to see if it would help). No prob compiling, big prob running.
Since a few people suggested the page-flipping I hope for some help in
figuring out why/where the following program is flawed. Thank you for your
time.

#include <stdlib.h>
#include <stdio.h>
#include <allegro.h>

short int   sx = 0, sy = 0;
PALETTE     pal;
BITMAP     *page1,
           *page2,
           *active_page;
RLE_SPRITE *ship;

int main()
{

allegro_init();
install_keyboard();
install_timer();
set_color_depth(16);

set_gfx_mode(GFX_MODEX, 320, 240, 320, 480);

page1 = create_sub_bitmap(screen, 0, 0, SCREEN_W, SCREEN_H);
page2 = create_sub_bitmap(screen, 0, SCREEN_H, SCREEN_W, SCREEN_H);
active_page = page2;

ship = get_rle_sprite(load_bitmap("Ship.bmp",  pal));

do
{

   draw_rle_sprite(active_page, ship, sx, sy);

      if (active_page == page1) {
  scroll_screen(0, 0);
  active_page = page2;
      }
      else {
  scroll_screen(0, SCREEN_H);
  active_page = page1;
      }

  // Move the sprite according to the controls
  if(key[KEY_LEFT])
    {if(sx > 0)   {sx = sx - 5;} else {sx = 0;};};
  if(key[KEY_RIGHT])
    {if(sx < 595) {sx = sx + 5;} else {sx = 595;};};
  if(key[KEY_UP])
    {if(sy > 0)   {sy = sy - 5;} else {sy = 0;};};
  if(key[KEY_DOWN])
    {if(sy < 425) {sy = sy + 5;} else {sy = 425;};};

} while(!key[KEY_ESC]);

   set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
   destroy_rle_sprite(ship);
   destroy_bitmap(page1);
   destroy_bitmap(page2);

   return 0;
}



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019