[comp.os.cpm] CP/M & MBASIC question

kwgst@unix.cis.pitt.edu (Filip Gieszczykiewicz) (01/10/91)

	Greetings I have a Kaypro 10 and am starting to experiment
	with CP/M. (My first z80 machine)

	I have several questions:

	1) Is there a command in Miscrosoft BASIC (M-80) that will
	clear the screen and home the cursor? I have all docs but they
	say nothing.

	2) I have a simple CLS.COM program that is about 15 bytes long
	that clears the screen. Now, I DUMPed it and converted the
	hex to decimal and poked those values from within BASIC.
	When I CALL it, it clears the screen and does a "Warm Boot"
	[bummer]. Anyways, I got rid of the JMP 0000h (for the
	warm boot) but now in hangs. [bummer^2] Arghh... Good lord,
	even my Apple ][+ has a HOME command! ;-)

	3) How do I load a binary file so I can use it with the
	USR# function? I have an assembler (RMAC), a linker, a
	BASICLIB.REL (what is that <--- ?), and MBASIC. Is this
	all I need? Oh, yeah, I have a hard disk so space in not
	a problem.

	(I have the source for SAFETY.COM, which also clears the screen,
	but even that does not work when POKEed from BASIC. Can I use
	&HD000? I have no idea where empty space is in BASIC.)

	Anyone?

	I also don't have a text editor (WS died) so I wrote my own
	in basic.... can't use the "," with INPUT... it gives a
	"Redo from start" (or something similar).

	4) Anyone know how to read a text file using random-access?
	I tried every possible combination. I can create but I can't
	read it. (Remember, you can't read a file that contains ","s
	with the INPUT# statement)

	Maybe I should stick to assembly..... [grin]
	(Yeah, but you need an editor for that - Catch 22???)

	Take care.

	P.S. Please e-mail. I will archive everything. Before sending
	a "send everything to me", give me a few days to organize :-)
-- 
------------------------------------------------------------------------------
Name: Karol Gieszczykiewicz Address: kwgst@unix.cis.pitt.edu
This message posted for: Filip Gieszczykiewicz (fmgst@unix.cis.pitt.edu)

slsw2@cc.usu.edu (01/12/91)

In article <77348@unix.cis.pitt.edu>, kwgst@unix.cis.pitt.edu (Filip Gieszczykiewicz) writes:
> 	Greetings I have a Kaypro 10 and am starting to experiment
> 	with CP/M. (My first z80 machine)
>
> 	1) Is there a command in Miscrosoft BASIC (M-80) that will
> 	clear the screen and home the cursor? I have all docs but they
> 	say nothing.

Try this:

PRINT CHR$(26) : REM Clear screen
PRINT CHR$(27);"=";CHR$(X+31);CHR$(Y+31) : REM move cursor

CP/M machines work the way God intended (they have terminals instead of
standard hardware that everyone has to know about), so it was not possible
for Microsoft to put those commands in.

I might have the coordinate order backwards, and +31 means that the upper
left hand corner is (1,1). If you want it to be (0,0), add 32 instead.

> 	2) I have a simple CLS.COM program that is about 15 bytes long
> 	that clears the screen. Now, I DUMPed it and converted the
> 	hex to decimal and poked those values from within BASIC.
> 	When I CALL it, it clears the screen and does a "Warm Boot"
> 	[bummer]. Anyways, I got rid of the JMP 0000h (for the
> 	warm boot) but now in hangs. [bummer^2] Arghh... Good lord,
> 	even my Apple ][+ has a HOME command! ;-)

If you have the manuals, you should look up how to call a machine language
routine; it's been long enough since I played with BASIC at that level (I've
discovered the magic of assemblers now) that I don't remember. At the very
least you have to replace the JMP 0000h with a RET (opcode C9H). If you just
delete the JMP, you'll wind up wandering through memory; I usually trash a
disk when that happens, so I tend to be careful.

> 	3) How do I load a binary file so I can use it with the
> 	USR# function? I have an assembler (RMAC), a linker, a
> 	BASICLIB.REL (what is that <--- ?), and MBASIC. Is this
> 	all I need? Oh, yeah, I have a hard disk so space in not
> 	a problem.

I used to hand poke them, but I have done things like read a binary image
into a string and use that to construct a source statement on disk. Getting
machine code into BASIC is not easy.

BASICLIB.REL is the run-time library for a BASIC compiler, e.g., BASCOM,
which compiles Microsoft BASIC. I seem to recall that its library was called
BASLIB, though.

> 	(I have the source for SAFETY.COM, which also clears the screen,
> 	but even that does not work when POKEed from BASIC. Can I use
> 	&HD000? I have no idea where empty space is in BASIC.)

The traditional way to do this is store the code in a string variable and 
use VARPTR to find the address of the variable; if you've got manuals you
can figure out how to do that. I seem to recall that VARPTR( A$ ) is the
length of A$ and then VARPTR( A$ ) + 1 contains the low-order byte of the
data area and VARPTR( A$ ) + 2 contains the high-order byte. But it's been
a while.

> 	I also don't have a text editor (WS died) so I wrote my own
> 	in basic.... can't use the "," with INPUT... it gives a
> 	"Redo from start" (or something similar).

Try using LINE INPUT.

> 	4) Anyone know how to read a text file using random-access?
> 	I tried every possible combination. I can create but I can't
> 	read it. (Remember, you can't read a file that contains ","s
> 	with the INPUT# statement)

Try using LINE INPUT#.

-- 
===============================================================================
Roger Ivie

35 S 300 W
Logan, Ut.  84321
(801) 752-8633
===============================================================================

roadhog@austex (Lindsay Haisley) (01/16/91)

kwgst@unix.cis.pitt.edu (Filip Gieszczykiewicz) writes:

> 	1) Is there a command in Miscrosoft BASIC (M-80) that will
> 	clear the screen and home the cursor? I have all docs but they
> 	say nothing.

The clear screen command for the Kaypro 10 is ^Z, aka 1b hex, aka CHR$(26)
in Basic, I think.  Any way you can send this to the screen will work.

> 	2) I have a simple CLS.COM program that is about 15 bytes long
> 	that clears the screen. Now, I DUMPed it and converted the
> 	hex to decimal and poked those values from within BASIC.
> 	When I CALL it, it clears the screen and does a "Warm Boot"
> 	[bummer]. Anyways, I got rid of the JMP 0000h (for the
> 	warm boot) but now in hangs. [bummer^2] Arghh... Good lord,
> 	even my Apple ][+ has a HOME command! ;-)

You have to change the JMP 0 to a RET (C9 hex).  This will return 
program control to the CCP rather than to the BIOS warm boot.


"Everything works if you let it!"
 ---  Travis J. Redfish
 +++++++++++++++++++++++++++
uucp: austex!roadhog@emx.utexas.edu  OR  roadhog%austex.uucp@emx.utexas.edu
 BBS: (512) 259-1261 (Z-Node 77 - aka - Kaypro Club of Austin)