Mail Archives: djgpp/1997/03/02/17:13:29
From: | aho450s AT nic DOT smsu DOT edu (Tony O'Bryan)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Allegro and SB05_DJ2 problem
|
Date: | Sun, 02 Mar 1997 21:14:50 GMT
|
Organization: | Southwest Missouri State University
|
Lines: | 96
|
Message-ID: | <3319eaa3.7656395@ursa.smsu.edu>
|
NNTP-Posting-Host: | forseti.i175.smsu.edu
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I'm using the Sound Blaster Library by Joel H. Hunter, and have run into a
problem when using Allegro's graphics functions with it. The MOD player built
into the Sound Blaster Library stops at random places within the MOD or starts
playing an extremely mangled version of the actual music. It appears to be
caused by something Allegro does, since it works fine if I remove all the
Allegro calls. I am using DJGPP 2.01, Allegro 2.2 and version 0.5 of the Sound
Blaster Library. If anyone has experienced this problem, please let me know.
Here is my offending code from a file called "credits.cc":
#include <conio.h>
#include <allegro.h>
#include <credits.h>
#include <data1.h>
#include <dialogue.h>
#include <main.h>
#include <sb_lib.h>
#include "keyb.h"
#define NUM_CREDITS 4
void RollTheCredits(void)
{
DATAFILE * GrabberFile;
BITMAP * Bitmaps[NUM_CREDITS];
BITMAP * WorkScreen;
int Coords[][2] = { {0,500},
{0,700},
{0,900},
{0,1100},
};
int NumVerticalPixels;
int Count;
int ScreenWidth = 640;
int ScreenHeight = 480;
sb_mod_file * Music;
allegro_init();
if ( (GrabberFile = load_datafile("data1.dat")) == NULL)
ExitWithError("Can't load credits data file");
Bitmaps[0] = (BITMAP *)GrabberFile[TITLE].dat;
Bitmaps[1] = (BITMAP *)GrabberFile[COPYRIGHT].dat;
Bitmaps[2] = (BITMAP *)GrabberFile[DESIGNER].dat,
Bitmaps[3] = (BITMAP *)GrabberFile[ALLEGRO_CREDIT].dat;
WorkScreen = create_bitmap(640,480);
set_gfx_mode(GFX_AUTODETECT,640,480,0,0);
set_pallete((RGB *)GrabberFile[CREDITS_COLORS].dat);
if (sb_install_driver(8000) != SB_SUCCESS)
ExitWithError("Can't install MOD player");
if ( (Music = sb_load_mod_file("alienrad.mod")) == NULL)
ExitWithError("Can't load MOD file");
for (Count = 0;Count < NUM_CREDITS;Count++)
Coords[Count][0] = (ScreenWidth - (*Bitmaps[Count]).w) / 2;
sb_mod_play(Music);
while (1)
{
if (!sb_mod_active)
{
sb_uninstall_driver();
unload_datafile(GrabberFile);
destroy_bitmap(WorkScreen);
allegro_exit();
return;
}
NumVerticalPixels = 0;
while (Coords[NUM_CREDITS - 1][1] > -300)
{
clear(WorkScreen);
for (Count = 0;Count < NUM_CREDITS;Count++)
{
blit(Bitmaps[Count],WorkScreen,0,0,Coords[Count][0],Coords[Count][1],(*Bitmaps[Count]).w,(*Bitmaps[Count]).h);
Coords[Count][1] -= 2;
}
NumVerticalPixels += 2;
blit(WorkScreen,screen,0,0,0,0,ScreenWidth,ScreenHeight);
if (kbhit() != 0)
{
if (getch() == ESCAPE)
{
sb_uninstall_driver();
unload_datafile(GrabberFile);
destroy_bitmap(WorkScreen);
allegro_exit();
return;
}
}
}
for (Count = 0;Count < NUM_CREDITS;Count++)
Coords[Count][1] += NumVerticalPixels;
}
}
- Raw text -