Created
December 20, 2019 05:48
-
-
Save Pinacolada64/eec620b76e8c64ed4b266d6b0be56f77 to your computer and use it in GitHub Desktop.
Dump arrays (?) to disk or screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{step:2} | |
{crunch:on} | |
{alpha:alt} | |
{number:3000} | |
rem "+.test dumpm" | |
rem output arrays to disk/screen | |
' sa=save .a, sx=save .x, sy=save .y | |
&"Array Output to Device{f6}":sa=780:sx=781:sy=782 | |
{:device} | |
&"Q=Quit, [S=Screen], 1-6=Image drive{f6}" | |
w$="S":p$="Output Device":&,1,32:if an$<>"" then an$=w$ | |
' ex.: W$=NA$:P$="Handle":&,1,32:IF AN$<>"" THEN NA$=AN$ | |
' op=output device | |
on -(an$="Q") goto {:quit}:if an$="S" then op=3:goto {:limit} | |
op=abs(int(val(an$))):dr=.:if op>. or op<7 then dr=op | |
poke sx,op:if dr=. then {:limit} | |
{:file_prompt} | |
w$="arrays":p$="Output Filename":&,1,32:if an$<>"" then an$=w$ | |
f$=an$ | |
{:file_open} | |
a$=dr$+f$:gosub 1011:if e%<>63 then {:limit} | |
{:file_exists} | |
' option to choose filename, overwrite/append | |
&"{f5}{pound}$f{f5} exists. [O]verwrite/[A]ppend?: {pound}i1" | |
' this works with C64List: | |
o=-(an$="O")-2*(an$="A"):on a goto {:file_overwrite}, {:file_append}:goto {:file_exists} | |
' FIXME: this is "Image BASIC", not all labels are resolved: | |
' on -(an$="O")-2*(an$="A") goto {:file_overwrite}, {:file_append}:goto {:file_exists} | |
{:file_overwrite} | |
&"Scratching {f5}{pound}$f{f5}...":a$=f$:gosub 1023:if e%=1 then:&" OK{f6}":goto {:limit} | |
&:goto {:file_prompt} | |
{:file_append} | |
&"Appending...":a$=f$+",s,a":gosub 1011:if e% then close 2:&"{f6}"+a$:goto {:file_prompt} | |
{:limit} | |
w$="100":p$="Output # Elements (1-255)":&,1,32:if an$<>"" then an$=w$ | |
lm=abs(int(val(an$))) | |
if lm>255 then:&"(Limiting to 255.){f6}":lm=255 | |
poke sy,lm | |
{:dump} | |
sys{sym:dump} | |
{:show_file} | |
l%=.:on dr+1 goto {:quit}:close 2:a$=dr$+f$+",s,r":goto 1011:if e% then:&:goto {:show_close} | |
{:show_file_loop} | |
&,2,2:er=64 or st:&"{lt green}{pound}#3{pound}%l{cyan}: {pound}$a{f6}" | |
if er=. then l%=l%+1:goto {:show_file_loop} | |
{:show_close} | |
close 2 | |
' save as "++ dumpm" @ $c000? | |
' poke 56,144:poke 52,144:clr | |
' for pass=1 to 3:org $9000,-(pass=3) | |
' next pass:close 8 | |
{:quit} | |
&"Quitting.{f6}":goto 1811 | |
{asm} | |
usetbl1=$cd03 | |
chrout =$ffd2 | |
clrchn =$ffcc | |
chkout =$ffc9 | |
var=$61 | |
dump: | |
stx dump3+1 ; output device # | |
sty dump7+1 ; # of arrays to output | |
lda #1 | |
sta dump1+1 | |
lda #0 | |
sta dump2+1 | |
jsr chkout | |
dump1: | |
lda #1 | |
pha | |
tax | |
jsr getarr | |
inc dump1+1 | |
dump2: | |
lda #0 | |
sec | |
adc var | |
cmp #79 | |
bcc dump4 | |
jsr clrchn | |
lda #0 | |
sta dump2+1 | |
dump3: | |
ldx #2 | |
jsr chkout | |
dump4: | |
ldy #0 | |
dump5: | |
cpy var | |
beq dump6 | |
lda (var+1),y | |
jsr chrout | |
inc dump2+1 | |
iny | |
bne dump5 | |
dump6: | |
lda #13 | |
jsr chrout | |
inc dump2+1 | |
pla | |
dump7: | |
cmp #100 | |
bcc dump1 | |
jmp clrchn | |
getarr: | |
lda #33 ; &,33: getarr | |
jmp usetbl1 | |
{endasm} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment