From Newsgroup: comp.sys.cbm
enzo <
enzo@fusionchat.net> writes:
Firstly in Basic, when saving a file, how do you overwrite a file that >already exists? I seem to get a flashing red light and nothing saved
when I try...
There is a Save-and-Replace command, but I wouldn't use it (at least one demonstrated bug exists).
Instead, scratch first, save second:
open15,8,15,"s0:program":close15:save"program",8:end
I usually make this a line in my program, and then RUN that line so I don't have to type it all the time.
When I start basic, it reports 38911 bytes free, does that mean there
are other areas of memory I can use for machine code without affecting
the basic program in memory, if so, where are they?
Sure. There is a large tract of RAM from $c000-$cfff, although a lot of
machine language utilities like this area also. There is also RAM under
the BASIC and Kernal ROMs, and under the I/O space, although these take
a little more work to get at and are hard to manipulate from BASIC without help.
How do I load/save an area of memory from Basic? (like SAVE "somedata"
CODE 49152,8192 or whatever on the spectrum)
Most people use a utility cartridge for this, and it's just handy to
have. Epyx FastLoad, Final Cartridge, SuperSnapshot and Action Replay
all have this functionality. You can find FastLoad cartridges very
cheaply (I got a box of 5 for $5 at a flea market).
If you want an actual BSAVE subroutine, ask and I'll give you a few
one-liners you can play with.
In assembler, how do I read from Basic variables? as in, if I called a >routine with say PA=1 PB=2 PC$="FOO" how would I read those? I realise
I could just poke (at least the numbers) to the relevent place but
that doesn't seem like a great solution...
It would be easier to pass the variables instead. Here is an idiom I use frequently:
jsr $aefd ; check and throw away comma
jsr $ad9e ; BASIC prmeval
jsr $b7f7 ; convert to int, store in $14-$15
So, if you were to assemble this to 49152, and did sys49152,w+3 the result
of w+3 would be stored in integer 16-bit form with low byte at $14 and
high byte at $15.
The screen display seems to be from 1024 onwards, where are the
attributes stored?
Colour memory is at $d800 (55296). Only the bottom nybble is significant.
It would be to your advantage to try and find either an electronic or
paper copy of one or both of the Programmers' Reference Guide, or Mapping
the 64. Both of these have comprehensive memory maps and intricate
instructions for manipulating the 64's more advanced features. Project64
I believe has them both in e-text form, but getting a book version is
much more convenient. I keep several copies of each, just because I'd be
lost without them if a copy disappeared.
--
Cameron Kaiser *
ckaiser@floodgap.com * posting with a Commodore 128
personal page:
http://www.armory.com/%7Espectre/
** Computer Workshops: games, productivity software and more for C64/128! **
**
http://www.armory.com/%7Espectre/cwi/ **
--- Synchronet 3.18b-Win32 NewsLink 1.113