Re: [cc65] Atari __RESERVED_MEMORY__

From: Daniel Serpell <daniel.serpell1gmail.com>
Date: 2009-10-27 01:44:00
Hi!

On Mon, Oct 26, 2009 at 7:12 PM, Fatih Aygün <cyco130@yahoo.com> wrote:
> Hi,
>
> I remember that this linker symbol was added a couple of years ago after a discussion
> about atari tgi drivers, which were non-existant at the time.
>
> The problem is that the docs list some values to be used with some graphics modes.
> Some of the values are just 1. They work. But the rest are one less than what is actually
> needed. This is caused by an OS bug, which probably does some strict > comparison
> instead of a >=. This is the same reason of the modes that need 1 byte of memory exist.
>
> My problem is that, in atari, in order to tgi drivers to be used, the user must specify the
> reserved memory size for the mode he needs. Forgetting to do so will, quite probably,
> be the #1 source of user errors. The bad things is that, when the driver tries to initialize
> the graphics modes, and fails because of insufficient memory, the screen will go black.
> It won't be able to go back to the text mode, because OS will think that it is 1 byte short
> of memory. Result: the user won't even see an error message, just a black screen. I think
> the same scenario is valid for the native _graphics().
>
> Ofcourse I can add a pre-test to see if there is enough memory before switching. But
> I think this alternative is more elegant:
>
> Atari startup code consume all available memory minus reserved memory. Everything
> would be much simpler if it consumed just one byte less. The docs (and every atari
> document about that matter on the web) would be giving the correct values, with the
> unnecessary 1's gone and the graphics functions could return to text mode in case of
> failure.
>

There is another solution: the graphics function wrapper could reserve
the memory
needed from the heap, adjusting RAMTOP (ZP $6A) to just bellow the stack
and APPMHI to the current top of the heap.

It's a little trickier because you now have a fixed stack size and the memory of
the default graphics mode (text mode) is unused in graphics mode, but has the
advantage of simply working.

Of course, a better alternative still is using a malloced buffer and setting the
graphics mode in the TGI code. This allows keeping the text mode screen
unchanged when in graphics mode, all the conio functions would work to this
"virtual" screen, but then all the graphics function should set and restore
SAVMSC before calling ROM functions.

    Daniel.
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Oct 27 01:44:10 2009

This archive was generated by hypermail 2.1.8 : 2009-10-27 01:44:13 CET