🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: eunet.micro.acorn
1 messages
1 total messages Started by Gerben 'P' Vos Mon, 28 Jan 1991 15:51
UU{De,En}code+Arc/Xarc, part 1/5: Decode_Bas
#204
Author: Gerben 'P' Vos
Date: Mon, 28 Jan 1991 15:51
117 lines
4737 bytes
This is the first in a series of five articles, containing UU{De,En}code and
Arc/Xarc programs for the BBC Microcomputer, Acorn Electron, Master and Master
Compact.


This article contains the plain text of an UUDecoding program in BASIC. You'll
need it to decode the other four articles.

Article 2 contains the (uuencoded) file Xarc, which you'll need to extract the
archives in the fourth and fifth articles. It's a Sideways RAM image.

Article 3 contains the file DoXarc. Electron users need this to be able to use
Xarc, which can run on the BBC in the memory-saving mode 7. DoXarc is an
*EXEC-able file.

Article 4 contains Encode_Arc, an archive containing the files DecodeSrc,
EncodeSrc and Encode_Bas. DecodeSrc and EncodeSrc can be run to produce the
machine code utilities UUDecode and UUEncode. Encode_Bas is included for
completeness, and may be used as an UUEncoding program on e.g. an Archimedes,
if nothing else is available.

Lastly, article 5 contains Arc_Arc, an archive containing the files Arc (a
Sideways RAM image), ArcDoc (a text file) and DoArc (an *EXEC-able file for the
Electron). You can use Arc to compress and archive files yourself.


I propose the following standard for submitting files for Acorn 6502-based
machines: put them together using *Arc, then encode them using *UUEncode.
If there are files whose load- and execution addresses must be restored to the
original addresses (Arc doesn't do this), include a file "ExecMe" in the
archive, which sets them.

Decoding can be done with *UUDecode and *Xarc, and *EXEC ExecMe if necessary.


Please note that Arc has a bug, which manifests itself in some large files.
This bug causes some bytes at the end of the file to be lost when Xarc-ed,
typically between 10 and 20. A temporary solution is to put some redundant
extra bytes at the end of the file which gets truncated, before Arc-ing it.

                                        Gerben Vos, gpvos@cs.vu.nl


---cut here---
   10REM Decode_Bas
   20REM Create the specified file, decoding as you go - used with UUEncode
   30REM
   40REM Written by Mark Horton, ported by Gerben Vos - Public Domain
   50REM BBC BASIC-II version for BBC Microcomputer, Acorn Electron and Master
   60 
   70DIMbuf% 80
   80 
   90REPEAT
  100INPUT"UUDecode - input file: "in$
  110in%=OPENINin$:IFin%=0 PRINT"Input file does not exist!"
  120UNTILin%
  130 
  140REPEAT
  150IFFNfgets(buf%,80,in%)<=0 PRINT"No begin line.":CLOSE#in%:END
  160UNTILLEFT$($buf%,6)="begin "
  170p%=INSTR($buf%," ",7):dest$=$(buf%+p%)
  180PRINT"Output file is "dest$
  190 
  200out%=OPENINdest$:IFout% PRINT"Output file already exists!":CLOSE#out%:CLOSE#in%:END
  210 
  220REM create output file
  230out%=OPENOUTdest$
  240PRINT"UUDecoding..."
  250PROCdecode(in%,out%)
  260IFFNfgets(buf%,80,in%)<=0 OR$buf%<>"end" PRINT"No end line." ELSEPRINT"Finished."
  270 
  280CLOSE#out%
  290CLOSE#in%
  300END
  310 
  320REM copy from in to out, decoding as you go along.
  330DEFPROCdecode(in%,out%)
  340LOCALbp%,m%,n%
  350REPEAT
  360REM for each input line
  370IFFNfgets(buf%,80,in%)<=0 PRINT"Short file.":CLOSE#out%:CLOSE#in%:END
  380m%=FNdec(?buf%)
  390IFm%<=0 GOTO450
  400n%=m%:bp%=buf%+1
  410REPEAT
  420PROCoutdec(bp%,out%,n%)
  430bp%=bp%+4:n%=n%-3
  440UNTILn%<=0
  450UNTILm%<=0
  460ENDPROC
  470 
  480REM output a group of 3 bytes (4 input characters).
  490REM the input chars are pointed to by p, they are to
  500REM be output to file f.  n is used to tell us not to
  510REM output all of them at the end of the file.
  520DEFPROCoutdec(p%,f%,n%)
  530LOCALc1%,c2%,c3%
  540c1%=(FNdec(?p%)*4)OR(FNdec(p%?1)DIV16)
  550c2%=(FNdec(p%?1)*16)OR(FNdec(p%?2)DIV4)
  560c3%=(FNdec(p%?2)*64)OR(FNdec(p%?3))
  570IFn%>=1 BPUT#out%,c1%
  580IFn%>=2 BPUT#out%,c2%
  590IFn%>=3 BPUT#out%,c3%
  600ENDPROC
  610 
  620DEFFNfgets(buf%,max%,in%)
  630LOCALn%
  640n%=0
  650REPEAT
  660IFNOT(EOF#in% ORn%=max%) buf%?n%=BGET#in%:n%=n%+1
  670UNTILEOF#in% ORn%=max% ORbuf%?(n%-1)=10
  680IFn%>0 buf%?(n%-1)=13
  690=n%
  700 
  710REM single character decode
  720DEFFNdec(c%)=(c%-32)AND&3F
---cut here, too---
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads