• Load binary file using Assembler

    From Rodrigo Vale@21:1/5 to All on Thu Dec 30 20:58:31 2021
    Hi folks,

    I am having a lot of fun studying Apple II assembler but got stuck with a simple task: how to load a binary file into memory from an assembler application? Basically I am trying to load game levels (no surprises =).

    I was able to find a high level description that it is possible to run BASIC commands from an assembler application by adding the BLOAD FILENAME, A$MEMORY command in a buffer and calling an address memory to execute it, but the same information didn't
    provide any detail about how to do it. Does anyone know how to do it?

    I also found some assembler code teaching how to avoid DOS/PRODOS and write an assembler code to read from scratch, but I think that for my level I would prefer to go with the DOS/PRODOS command approach. (Avoiding DOS/PRODOS at this moment seems to add
    a lot of complexity on how to store, execute and test my code)

    Thank you in advance!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fadden@21:1/5 to [email protected] on Fri Dec 31 09:08:40 2021
    On Thursday, December 30, 2021 at 8:58:32 PM UTC-8, [email protected] wrote:
    I was able to find a high level description that it is possible to run BASIC commands from an assembler application by adding the BLOAD FILENAME, A$MEMORY command in a buffer and calling an address memory to execute it, but the same information didn't
    provide any detail about how to do it. Does anyone know how to do it?

    In DOS you can just output the commands prefixed by Ctrl+M Ctrl+D, assuming you haven't redirected character I/O. For example, the Scott Adams adventure games used this to load and save games from disk. See https://6502disassembly.com/a2-scott-adams/
    GoldenVoyage.html#SymSaveGame (look for "dos_save_cmd"). (As examples go it's a bit convoluted... just write the characters to COUT like you would any other text.)

    For ProDOS you can use a sequence of MLI commands (OPEN / READ / CLOSE). These work whether or not BASIC.System is active. See e.g. _Beneath Apple ProDOS_.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Oliver Schmidt@21:1/5 to All on Fri Dec 31 20:04:56 2021
    Hi,

    For ProDOS you can use a sequence of MLI commands (OPEN / READ / CLOSE).

    A pretty straight forward example of doing just that: https://github.com/oliverschmidt/contiki/blob/master/platform/apple2enh/lib/pfs.S

    Regards,
    Oliver

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Antoine Vignau@21:1/5 to All on Mon Jan 3 13:14:56 2022
    Happy New Year,

    DOS is not ProDOS.
    DOS contains the BASIC file interpreter (eg. BLOAD) when ProDOS does not. It is included in the Basic Interpreter. When one wants to load files in the ProDOS file system, they use the MLI (Machine Language Interface) which is really simple and powerful
    to use.

    If you want something common between the two environments, follow the advice of Andy.

    Cheers,
    Antoine

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Oliver Schmidt@21:1/5 to All on Wed Jan 5 08:39:45 2022
    Hi,

    [...] the MLI (Machine Language Interface) which is really simple and powerful to use.

    Full ACK - maybe except for this:

    The MLI doesn't really have a notion of drives. The "usual", "expected" behavior of allowing to save some file to (the root directory of) some
    drive like S6,D1 (like e.g. BASIC.SYSTEM does) requires you to explicitly
    get the volume name of the disk in that drive and build an absolute
    pathname like

    /<volume name>/<file name>

    (Yes, I know about the prefix, but it doesn't apply in this scenario.)

    If you (again like BASIC.SYSTEM) want to do this without specifying a
    drive, then it gets even (somewhat) more complicated, because you need to
    first get the last used drive and then do the above.

    Many MLI newcomers expect this logic to be built into the PRODOS core
    instead of being a BASIC.SYSTEM feature (which therefore needs to be reimplemented by every MLI user).

    Regards,
    Oliver

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)