3

A common annoyance when programming in BASIC on the Apple II is that 6K of BASIC storage area falls before the start of the first hires screen, with another big chunk of storage falling after it. On a 32K machine (the smallest that could use DOS and hires graphics), the memory layout would be:

$0800-$1FFF : 6K usable by BASIC
$2000-$3FFF : Hires page 1
$4000-$55FF : 5.5K usable by BASIC
$5600-$7FFF : 10.5K used by DOS

on a 48K machine, depending upon whether a program used one or two hires screens, it would be either:

$0800-$1FFF : 6K usable by BASIC
$2000-$3FFF : Hires page 1
$4000-$95FF : 21.5K Usable by BASIC
$9600-$BFFF : 10.5K used by DOS

or

$0800-$1FFF : 6K usable by BASIC
$2000-$3FFF : Hires page 1
$4000-$5FFF : Hires page 1
$6000-$95FF : 13.5K Usable by BASIC
$9600-$BFFF : 10.5K used by DOS

Having DOS place its default 1K of buffers and/or easily-regenerated tables at $0800-$0BFF and 5K of itself from $0C00-$1FFF would seem like it would have been an easy way of consolidating the 6K in the lower chunk of memory to the upper chunk, thus eliminating the need to split BASIC RAM into two discontinuous chunks. Additionally, having 5K of DOS be located at a fixed address range that was independent of system memory size would reduce the number of address relocation fixups required to handle different memory sizes.

The resulting memory layout would be either (32K machine)

$0800-$1FFF : 6K used by DOS
$2000-$6DFF : Hires page 1
$4000-$6DFF:  11.5K for BASIC
$6E00-$7FFF : 4.5K used by DOS

or (64K machine)

$0800-$1FFF : 6K used by DOS
$2000-$5FFF : Hires pages 1 and 2
$6000-$ADFF : 19.5K Usable by BASIC
$AE00-$BFFF : 4.5K used by DOS

BASIC programs that didn't need both hires screens could use something like MAXFILES to increase available storage by 8K or 16K, but in other cases the risks of collisions between hires screen and BASIC RAM would be eliminated. Additionally, if the first 1K of RAM was used to hold the first two file buffers and the nybble translation tables, a command similar to MAXFILES could relocate those somewhere else in case code wanted to use text/lores page 2. As a final benefit, the boot loader could be constructed to leave undisturbed the RAM between $2000 and the start of the DOS high area.

Would there have been any difficulty putting 6K of DOS and its buffers lower in memory? Programs that need to have more than three files open at once might need to accommodate having some buffers in the low area and others above the top of BASIC RAM, but that wouldn't seem difficult. Were there ever any patched variants of DOS 3.3 which moved the start-of-BASIC pointer higher so they could place a significant portion of themselves at the bottom of memory?

6
  • I don't remember any DOS variant using that layout. Moreover, there were at least some games etc. that required BASIC at $0800, because they added some binary stuff. Plus there were binary games that required loading at a start address before HIRES (because they had a loading screen that was just loaded into HIRES after turning it on). So while BASIC was relocatable in theory, I don't remember anything actually doing that, and DOS before HIRES would definitely cause some incompabilities.
    – dirkt
    Commented Nov 27, 2023 at 6:22
  • I vaguely remembering there being a third party tool that could rearrange your program for this to work. Commented Nov 27, 2023 at 7:42
  • @dirkt: I do indeed remember such games, such as Taipan, from back in the day. They would have been incompatible with such a DOS unless they checked for its presence, disconnected it (since the games didn't require any disk I/O anyhow), and then copied themselves down to $0800--something that would not have been overly difficult if authors foresaw the need.
    – supercat
    Commented Nov 27, 2023 at 16:24
  • @dirkt: If the game started with something like CALL PEEK(105)+256*PEEK(106), relocatable code at that address could disconnect DOS or other special handlers, copy itself to $0300 [using LDA ($71),Y to fetch itself], check whether those addresses were as expected, and copy everything above those addresses to memory starting at $08xx it wasn't already there. That would allow loading such a game after another such game had already been loaded.
    – supercat
    Commented Nov 27, 2023 at 16:30
  • 1
    @supercat You can't expect games to follow your conventions. Games do what they do, and if they don't work, nobody is going to use your DOS variant.
    – dirkt
    Commented Nov 27, 2023 at 19:06

0

You must log in to answer this question.

Browse other questions tagged .