MBimport 5
Descripción del contenido de la página
Quinta variante de MBimport, programa escrito en MasterBASIC para importar en el emulador SimCoupe código fuente en MasterBASIC escrito en ficheros de texto creados en el sistema operativo anfitrión.
Etiquetas:
Código fuente
// mbimport_5.mbim
rem MBimport 5 (version A-02-201212081830):\
(C) 2012 Marcos Cruz (programandala.net):\
License programandala.net/license
/*
See <http://programandala.net/en.program.mbim> for details.
This program is written in MasterBASIC (with MBim format)
for the SAM Coupé.
History
2012-11-18. First version.
2012-11-20. Rewritten in MBim format.
2012-12-05. Instructions. Some changes to improve the speed. Final KEYIN command.
2012-12-06. Fixed: name clash with the importer: 'top' label changed to 'MBimport5Top',
'r' and 's' changed to 'r5' and 's5'.
2012-12-08. Version A-02: The disk is read by tracks instead of sectors.
Clearer instructions (and moved to a serial file, created by the program 'mkusage5').
'nextTrack' and 'loadTrack' are combined into one proc. Deleted a call to the missing
proc 'wipeBuffer'. Much more compacted, seven lines only!
*/
#firstline 0 // no line numbers; MBimport 4 will be used to import the code
mode 3:\
cls #:\
move "usage5" to #2
defproc import drive:\
// Import a MasterBASIC program, written in text format in the host OS, whose
// original file was packed as a fake MGT disk image (simply using char 13 as
// end of line char, then growing the file with zeros until its size is 820
// KiB, and finally compressing it).
default drive=2:\
// [no need for local:]
# local \
# buffer,\
# bufferEnd,\
# cr$,\
# crPos,\
# endOfSource,\
# l$,\
# lastTrack,\
# sectorLen,\
# sectorsPerTrack,\
# sliceStart,\
# track,\
# trackLen:\
let \
cr$=CHR$ 13,\ // char that ends every source line
endOfSource=0,\ // flag
sectorLen=512,\
sectorsPerTrack=10,\
trackLen=sectorsPerTrack*sectorLen,\
track=127,\ // fake value that changes to 0 when feedBuffer is executed the first time
crPos=0,\
lastTrack=79 bor 128,\
buffer=ramtop,\
bufferEnd=buffer+trackLen-1,\
lineN=1:\ // counter
mode 2:\ // mode 2 is a bit faster for printing
cls #:\
feedBuffer
do:\
exit if not peek (sliceStart):\
let l$="":\
do:\
let crPos=locn(sliceStart,bufferEnd,cr$,abs ):\
if crPos:\
let l$=l$+mem$(sliceStart to crPos-1):\
if crPos=bufferEnd:\
feedBuffer:\
else \
let sliceStart=crPos+1:\
endif:\
else \
let l$=l$+mem$(sliceStart to bufferEnd):\
feedBuffer:\
endif:\
loop until crPos:\
print at 0,0;lineN:\
keyin l$:\
let lineN=lineN+1:\
loop:\
keyin "delete to MBimport5Top:renum line 1 step 1:cls#:print ""Done!"":scroll restore:list:stop":\ // final command
endproc
defproc feedBuffer:\
// Load a new track into the buffer
if track=lastTrack:\
let endOfSource=1:\
else: \ // [colon is needed here to avoid "else if"]
// Calculate the next track number:
if track<80:\ // side 0?
// change to side 1
let track=track bor 128:\ // ['bor' is a bit faster than '+']
else \ // change to side 0
let track=track-127:\
endif:\
// Load the track:
read at drive,track,1,buffer,10:\
let sliceStart=buffer:\
endif:\
endproc
defproc s5:\
delete MBimport5Top+1 to:renum line 1 step 1:save over "MBimport5" line 1:\
endproc
label MBimport5Top
mkusage5
Este programa es un accesorio que crea un fichero en disquete con las instrucciones de uso de MBimport 5. Esto permite que MBimport 5 sea más compacto.
// mkusage5.mbim
rem mkusage5 (version A-00-20121208):\
(C) 2012 Marcos Cruz (programandala.net):\
"License: http://programandala.net/license"
/*
This program creates a disk file with the usage instructions of MBimport 5.
See <http://programandala.net/en.program.mbim.mbimport>.
History
2012-12-08. First version. Texts taken from MBimport 5.
*/
#firstline 0 // no line numbers; MBimport 4 will be used to import the code
// Config
mode 3:\
cls#
let file=4,file$="usage5" // destination file
// About
print "mkusage5"
print "(C) 2012 Marcos Cruz (programandala.net)"
print '"This program creates a disk file with the usage instructions of MBimport 5."
print '"See <http://programandala.net/en.program.mbim> for more details."
print '"Type 'go' to run"
defproc go
// Create the usage file.
if fstat(file$,1) then erase file$
close#file
open#file;file$ out
type "MBimport 5"
type "Copyright (C) 2012 Marcos Cruz (programandala.net)"
type ""
type "Usage:"
type "1) Make sure there's enough memory for your program."
type " Use 'OPEN n' to add more 16 KiB pages to BASIC, and 'CLEAR x' to set the RAMTOP."
type " Example: PRINT FREE: REM free memory available for BASIC"
type " PRINT FPAGES: REM unused 16 KiB memory pages"
type " OPEN 3: REM reserve 3 more pages for BASIC"
type " CLEAR RAMTOP+3*16384: REM move the RAMTOP accordingly"
type "2) Introduce your '*.mbim.mb.mgt.gz' or '*.mbim.mb.mgt.zip' file into drive 2."
type "3) Use 'IMPORT' to import the source from drive 2."
type ""
type "If the program stops with the error 'Not understood', you can examine the latest"
type "imported line with 'PRINT l$'. If it's wrong, you can fix it with 'EDIT l$' and"
type "'CONTINUE'. If it's right, the problem is some bug in 'KEYIN', but 'CONTINUE'"
type "works and the line is added to the program."
type ""
type "See <http://programandala.net/en.program.mbim> for more details."
close#file
cls#
print "Done!"
print "Type 'show' to see the result."
endproc
defproc type line$
// Create a line of the usage file.
print #file;line$
rem print line$
endproc
defproc show
// Show the usage file.
cls#
close#file
open#file;file$ in
do until eof file
input#file; line l$
print l$
loop
close#file
endproc
defproc s:\
renum:\
save over "mkusage5" line 10:\
endproc
Descargas
MBimport 5 y el resto de variantes están disponibles en la sección de descarga en la página principal de MBimport.