Mail Archives: djgpp/1998/03/22/14:01:17
Excerpts from netnews.comp.os.msdos.djgpp: 22-Mar-98 Re: ?Win95 crash
from Alleg.. by Shawn Hargreaves AT talula.
> >void main(void)
> >{
> >//640 x 480 mode
> > set_gfx_mode(0,640,480,1024,1024);
> > allegro_init();
>
> I'm not sure why this would crash, but it is grossly incorrect to call
> any other Allegro functions before using allegro_init(). Trying to set a
> video mode before initialising the lib is just asking for trouble...
>
> Also, why are you passing zero as the first param to set_gfx_mode()?
> Using the GFX_* defines would make your code more readable, and prevent
> it from breaking if I ever change what the actual numbers are.
>
This is my fault with the two errors. I spent many many hours isolating
the code(ITS WAY frustrating when the computer has to reboot each time
you find an error), but I rapidly slapped it together once I found the
errors...
It turns out that I copied the initialization functions out of a
function to make things more readable, and I had a setup program pass
values to set_gfx_mods via file, so to make it more readable, I slapped
a 0 instead of the actual value that should have been there.
With all that said, the code still malfunctions due to the setpallete
command. This is very disheartening. If anyone has solution, I'd be in
your debt, but if not, I'd like to find others who have difficulty
running this code to possibly track down the problem which I'm guessing
has to do with how windows configures a driver...
Again the problem is that this code will run under dos, but
not win95 or win98
The nicer code:
#include "allegro.h"
void main(void)
{
BITMAP *BUTCR;
PALLETE stndpal;
allegro_init();
install_mouse();
install_timer();
set_gfx_mode(GFX_AUTODETECT,640,480,1024,1024);
BUTCR=load_pcx("butup.pcx",stndpal);
/* Problem arises due to the set_pallete statement,
* though execution continues until the while loop
*/ at which time the computer freezes up.
set_pallete(stndpal);
show_mouse(screen);
while (true)
{
}
}
Any help or even wild guesses would be of use :)
Once again, sorry for posting horrible code earlier.
- Raw text -