• Re: Modify DOS 3.3 to load Integer Basic from Extended 80 ColumnCard?

    From Jayson Smith@jaybird.qxz@bluegrasspals.qxz.com.qxz to comp.sys.apple2 on Friday, April 09, 2021 02:45:16
    From Newsgroup: comp.sys.apple2

    Hi,

    The good news is that, as I said in my first message, someone else
    already did the relocatable Integer Basic probably back in the 80's. I
    have no idea about the history of this version, but it was on tons of
    talking disks with a mix of Applesoft and Integer programs. Right now
    when I want to run an Integer program, I just BRUN INTEGER, then run the program. My intended use case for this hack would be, for example, a
    menu containing all the programs on a disk, wherein Applesoft and
    Integer programs can be run willy nilly, without regard to which
    language is currently loaded. Were Textalker not an issue, I'd just load INTBASIC into the language card and be done with it, but I can't do that
    with Textalker in the mix.

    I'm pretty sure the relocatable Integer Basic I have starts at $8000. It
    loads at $0800, then moves most of itself to $8000, then does a JSR
    $9000, presumably to initialize something, then modifies several
    locations within DOS, then does a JMP $8003, presumably to start the
    Integer interpreter. My version can be found at: http://www.bluegrasspals.com/disks/talking/egames.dsk

    To the person who made a ProDOS version of Integer Basic, where can your
    disk image be found?

    Thanks,

    Jayson

    On 4/8/2021 11:43 AM, Michael 'AppleWin Debugger Dev' wrote:
    Hello Jason

    Sorry to hear about your condition.

    If you don't know 6502 assembly language along with understanding DOS 3.3 internal implementation then this task will seem impossible. It is indeed doable but will require a lot of code patching and zero-page fixups.

    There are two solutions:

    * Relocate Integer Basic (IB) to run from a different address
    * Relocate Echo II to run from from a different address

    The bad news is that both of these are non-trivial.
    The good news is that both of these are indeed doable -- with a lot of elbow grease.

    IB is normally located from $E000 - $F7FF.

    Relocating IB is probably the easier of the two since there are disassembly listings. Also, there was a relocatable version of Integer Basic+ but I'm not aware if this on Asimov. (FTR I also haven't looked.) I would first try to track this down.

    There are two problems:

    1. Fixing IB to run from a different address
    2. Fixing IB HIMEM ($4C,4D) to use "safe" memory so as to not over-write IB and/or DOS 3.3
    3. You also might need to fixup LOMEM / Integer Program Start ($CA, $CB)

    The Extended 80 Column Card is AUXMEM. Instead of trying to get IB to run from AUXMEM I would first get it running from main RAM but at a lower address.

    Making IB "relocatable" is not easy. But also not impossible. It requires manually patching up all the absolute addresses uses. (See note at end.)

    It might be convenient to load IB into main RAM at $7000. Unfortunately this leaves almost a 4K (!) gap from $8800 .. $9600.
    i.e. Wastes $E00 bytes.

    It is tempting to use $8000 for the start of IB. This is doable but requires telling DOS to use less memory for its file buffers via MAXFILES 2.

    Why MAXFILES 2?

    IB located at $8000 uses $8000 .. $97FF. This unfortunately overlap's one of DOS 3.3's file buffers by 512 bytes. DOH!

    DOS 3.3 file buffers "start" at $9600 because MAXFILE defaults to 3. Each file buffer requires 595 bytes. Here is a table of the lowest address DOS uses for each of the MAXFILES settings:

    MAXFILES 3, HIMEM = $9600
    MAXFILES 2, HIMEM = $9853
    MAXFILES 1, HIMEM = $9AA6

    You could change MAXFILES to 2 to move the top of DOS 3.3 file buffers up to leave enough room for IB. You would then need to manually fixup Applesoft and IB zero-page pointers to $8000 so a program's variables don't overwrite the IB code.

    NOTE: I say "start" at $9600 but technically DOS 3.3 files buffers start at high RAM and work down.
    NOTE: Applesoft HIMEM is zero-page $73, $74. Integer Basic HIMEM is zero-page $4C, $4D, IB SOP is $CA, $CB.

    Snippet of BLDFTAB - Build File Tables

    283B:68 095 PLA
    283C:85 74 096 STA ASHM1+1
    283E:85 70 097 STA ASHM2+1
    2840:68 098 PLA
    2841:85 73 099 STA ASHM1
    2843:85 6F 100 STA ASHM2
    2845:60 101 RTS
    102 ;
    103 BFTIB EQU *
    2846:68 104 PLA ; SET IB
    2847:85 4D 105 STA IBHMEM+1 ; UPPER MEM LIMITS 2849:85 CB 106 STA IBSOP+1
    284B:68 107 PLA
    284C:85 4C 108 STA IBHMEM
    284E:85 CA 109 STA IBSOP
    2850:60 110 RTS

    Another solution is to relocate the start DOS 3.3 file buffers down. This leaves a gap between the file buffers and the start of DOS 3.3 code at $9D00. You'll probably want to read the comment on the MAXFILES Command Handler. Again this is non-trivial but doable.
    http://www.textfiles.com/apple/ANATOMY/cmdmxfil.txt

    You'll also want to take a look at this SO question: https://retrocomputing.stackexchange.com/questions/13137/using-integer-basic-on-apple-ii-plus-without-a-language-card

    I would follow-up researching the answer to this interesting answer:

    It was, in fact possible to load Integer BASIC into RAM without the Language Card, and without purchasing a modified variant. Back in the day there was a magazine article (Creative Computing, Byte, Nibble come to mind as likely candidates) detailing how to perform the relocation patch. From then on you were good to go.

    TL:DR;

    0. Find relocatable version of IB. Use this. Done.

    OR:

    1. Load Integer Basic at $7000
    2. Fixup Integer Basic so it runs at this address
    3. Fixup zero-page address for both Applesoft and IB
    $4C, $4D = $7000
    $6F, $70 = $7000
    $73, $74 = $7000
    $CA, $CB = $7000
    There maybe others?
    4. [Optionally] Once that is working, MAXFILES, 2, relocate to IB $8000, perform zero-page fix ups.
    5. Move IB to AUXMEM, patch up INT command and FP so they work.

    Good luck!

    Michael



    --
    Remove all qxz from my Email address to reply privately.
    --- Synchronet 3.18b-Win32 NewsLink 1.113