• One From The Vault: PETSCII-to-PRG Converter (1K)

    From Cameron Kaiser@21:1/5 to All on Fri Feb 12 18:40:01 2021
    ******************************************************************
    *** ***
    *** comp.binaries.cbm is a moderated binaries- ***
    *** only newsgroup (no discussion or ***
    *** crossposting allowed) for Commodore 8-bits ***
    *** ***
    *** For information on comp.binaries.cbm visit ***
    *** http://www.floodgap.com/comp.binaries.cbm/ ***
    *** ***
    *** This file is available via mailing list at ***
    *** http://lists.trikaliotis.net/listinfo/comp-binaries-cbm/ ***
    *** to list subscribers ***
    *** Allow time for submission to be received ***
    *** ***
    ******************************************************************

    * One from the Vault is a collection of frequently requested, useful or just
    plain interesting past posts sent to comp.binaries.cbm, as archived by the
    moderators. If you have a request, please send it to the address in the
    headers. In addition to being selected and reposted by moderation staff,
    some of these postings are regularly posted on Mondays and Fridays on a
    rotating schedule.

    Take care when replying to these messages, as many were posted years ago.


    From: Cameron Kaiser <cdkaiser@delete.these.four.words.concentric.net> >Reply-to: Cameron Kaiser <cdkaiser@delete.these.four.words.concentric.net> >X-Original-Posting-Date:

    In the comp.sys.cbm (now largely outdated: Jim, where are you?) FAQ, Jim
    Brain mentions a tip for converting a PETSCII text file into a program file
    as if you had typed it in yourself. It works, but it involves some typing,
    and you must close the file yourself. It's also a little ugly. :-) Hernan Vergara suggested I write a new one, so I did.

    The following program, which is very small and public domain, reads in
    a PETSCII program file on the disk that you created (like this:

    open1,device,2,"filename,s,w":cmd1:list
    [cursor comes back]
    print#1:close1

    where device is 8-11 and filename is the name of the text file), and enters
    it into memory for you.

    There *must* be a READY. as the last line of that text file, which the code above does as a side effect.

    To use this program, LOAD it into memory ,8,1 and type NEW to clear
    pointers. Then:

    sys49152,"filename",device

    The program will flash the border as it loads the text file into memory and enters it. It will then say "FINISHED!" and close the file when done, giving you a READY. prompt. (If you type a wrong filename or device number in by mistake, hit RUN/STOP-RESTORE to recover.)

    If there is a program in memory, it will have the lines appended to it
    (unless line numbers conflict, in which case the new lines will overwrite
    the old ones). To execute this merge, LOAD this program first, type NEW,
    LOAD the first program, and then do the command above.

    Since $c000-$cfff is a common area for machine language routines, the source code in xa crossassembler format is below. It requires 121 bytes of free RAM.

    -- Cameron Kaiser

    .word $c000
    *=$c000

    /* tokenise a basic program from disk, by cameron kaiser, in xa format */

    jsr $aefd /* skip comma */
    jsr 57812 /* grab filename and device */
    lda #1
    ldx $ba
    ldy #2
    jsr $ffba /* setlfs */
    jsr 65472 /* open */
    lda 768
    sta esto
    lda 769
    sta estp
    lda #<ehand
    ldx #>ehand
    sta 768
    stx 769 /* move basic ierror vector to our handler */
    ldx #1
    lda 812
    sta iclsav /* save iclall vector */
    lda #73
    sta 812 /* iclall */
    jmp 65478 /* chkin and exit */

    /* error handler -- works on the principle that the last line will make a
    syntax error */

    ehand inc $d020
    pha /* save accumulator just in case */
    cpx #11 /* is it a syntax error? if so, we're done! */
    beq *+5
    pla
    jmp (esto) /* nope, use default handler and fergeddaboudit */
    lda #1
    jsr $ffc3 /* close */
    jsr $ffcc /* clrchn */
    lda #<mes
    ldy #>mes
    jsr $ab1e /* strut our stuff */
    ldx #255 /* throw error message away */
    ejump lda esto
    sta 768
    lda estp
    sta 769 /* restore ierror vector */
    lda iclsav /* restore iclall vector */
    sta 812
    pla
    jmp (esto) /* bye */
    esto .byte 00
    estp .byte 00
    iclsav .byte 00
    mes .asc "FINISHED!",$0d,00

    begin 644 seqbas49152.bin M`,`@_:X@U.&I`::ZH`(@NO\@P/^M``.-:\"M`0.-;,"I.*+`C0`#C@$#H@&M M+`.-;<"I28TL`TS&_^X@T$C@"_`$:&QKP*D!(,/_(,S_J6Z@P"`>JZ+_K6O` AC0`#K6S`C0$#K6W`C2P#:&QKP````$9)3DE32$5$(0T`
    `
    end
    --
    Cameron Kaiser * ckaiser@floodgap.com * posting with a Commodore 128
    Floodgap Systems: http://www.floodgap.com/
    personal page: http://www.cameronkaiser.com/

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