[A89] Re: 8/24k size limit
[Prev][Next][Index][Thread]
[A89] Re: 8/24k size limit
Sorry, here's the function that I think is causing the problem:
---------------------------------------------------------------
CALLBACK void ExitFunc(void) {
float avspare = 0.0;
if (homequit == 1) goto exitquick;
GrayOff();
clrscr();
SetIntVec (AUTO_INT_5, OldInt5);
//This restores the timer interrupt back to normal for a HW2 calc. If you
know a more elegant or effective way, please email me
pokeIO (0x600017, 204);
//Next two lines are just something I made out of curiosity, uncomment the
second one and recompile to see what they do
avspare = spare / cycles;
//printf ("Average spare: %f\n", avspare);
cfgfile = NULL;
cfgfile = fopen ("bnibcfg", "r+b");
if (cfgfile != NULL) {
fwrite (&fps, 1, 1, cfgfile);
fclose (cfgfile);
}
//Handle high scores, most of the function names are self-explanatory
cfgfile = NULL;
cfgfile = fopen ("bnibcfg", "rb");
if (cfgfile != NULL) {
fseek (cfgfile, 1, SEEK_CUR);
fread (&hscore, 2, 1,cfgfile);
fclose (cfgfile);
}
cfgfile = NULL;
if (score > hscore) {
cfgfile = fopen ("bnibcfg", "r+b");
if (cfgfile != NULL) {
fseek (cfgfile, 1, SEEK_CUR);
fwrite (&score, 2, 1, cfgfile);
fclose (cfgfile);
printf("New high score!\n\n");
printf("The old high score was %d\n", hscore);
}
}
else //printf("High score: %d", hscore);
GKeyFlush(); //Clear the keyboard queue
//Wait about a second, in case the player hit a key just as they died.
OSFreeTimer(6);
OSRegisterTimer (6, 20);
while (!OSTimerExpired(6)) {}
ngetchx();
exitquick:
//Free the screen buffers, point arrays, and rotated sprites
free (lbuffer);
free (dbuffer);
free (ptx);
free (pty);
free (headrightl);
free (headrightd);
free (headdownl);
free (headdownd);
free (headleftl);
free (headleftd);
free (tailrightl);
free (tailrightd);
free (taildownl);
free (taildownd);
free (tailleftl);
free (tailleftd);
free (bodyhorzl);
free (bodyhorzd);
free (uprightl);
free (uprightd);
free (downrightl);
free (downrightd);
free (downleftl);
free (downleftd);
}
----------------------------------------------------------------------------
--------
CALLBACK is to silence a compiler warning from when I register that function
as an exit function with atexit(), my Dad helped me with that.
The variables in the free commands are all valid variables allocated with
malloc. For the complete source code, download
http://h00a0cce677a7.ne.client2.attbi.com/bnibbles_source_only.zip. It
doesn't crash every time I try to exit the program, and it crashes more
often on my real calc(ams 2.05 HW2) than vti.
Brett
----- Original Message -----
From: "John David Ratliff" <jdratlif@indiana.edu>
To: <assembly-89@lists.ticalc.org>
Sent: Sunday, August 25, 2002 5:40 PM
Subject: [A89] Re: 8/24k size limit
>
> It would be much easier to help you if you would post your source code.
>
> John David Ratliff
> jdratlif@cs.indiana.edu
>
>
> -----Original Message-----
> From: assembly-89-bounce@lists.ticalc.org
> [mailto:assembly-89-bounce@lists.ticalc.org] On Behalf Of Brett Simmers
> Sent: Sunday, August 25, 2002 2:30 AM
> To: assembly-89@lists.ticalc.org
> Subject: [A89] Re: 8/24k size limit
>
>
> Thanks for the info, now I just have to find out what's making my game
> crash... ugh. It generally crashes right before it's about to exit, and
> I
> have 24 free() commands right around there. Could that cause the calc
> to
> crash? They are freeing space allocated for temporary spirtes, and it
> seemed to work better (crash less) before I added the feature that needs
> those allocated variables.
>
> Brett
>
>
> ----- Original Message -----
> From: "Patrick Davidson" <pad@OCF.Berkeley.EDU>
> To: <assembly-89@lists.ticalc.org>
> Sent: Sunday, August 25, 2002 3:00 AM
> Subject: [A89] Re: 8/24k size limit
>
>
> >
> >
> >
> > On Sun, 25 Aug 2002, Brett Simmers wrote:
> >
> > >
> > > I think one of my programs has bumped up against some part of the
> 8/24k
> > > size limit, but I'm not sure. The file is 8.7k, but instead of not
> > > running at all, it will run but crash often when it is trying to
> exit.
> > > I've never really understood all the technical details of this size
> > > limit, so I don't know whether the crashing is from the size limit
> or
> > > just my code. Could someone explain the parts of the limit, and
> what
> > > happens when a prog hits it?
> >
> > There are two parts of the limit, the "software" and "hardware"
> limits.
> > The limit is 8K on AMS 2.03, 24K on AMS 2.04 and above, and doesn't
> exist
> > at all on 1.x.
> >
> > The "software" limit is a "feature" of the AMS which checks the size
> of
> > the program when you try to run it, and displays "ASAP or exec screen
> too
> > long" or something like that instead of running it if the program
> exceeds
> > the limit. This can be easily beaten by software (a "kernel" will
> turn it
> > off when installed, and it is not hard to make a launcher that goes
> around
> > it either).
> >
> > The "hardware" limit is a "feature" of hardware version 2 that is
> enabled
> > by the AMS versions that have the size limit. This detects whenever
> the
> > PC is outside the approved range and will crash. This is harder to
> beat,
> > but it can be done. HW2Patch disables it, and you can also go around
> it
> > using a launcher like TTStart (which PPG laucnhers are built around)
> and
> > there is also a simple launcher to circumvent it in the TIGCC library
> > documentation.
> >
> > Your problem doesn't seem related to this, however. If your program
> were
> > over the size limit, and the size limit had not been disabled, it
> would
> > have just shown an error instead of running. The size limit should
> only
> > crash if you tried to circumvent and got around the AMS check but
> didn't
> > turn off the hardware restriction, or if you tried to move some code
> to
> > another region of memory since the new location would probably be
> outside
> > the permitted area.
> >
> >
> >
>
>
>
>
>
Follow-Ups:
References: