On 07.03.2017 12:17, Anssi Saari wrote:
> rridge@csclub.uwaterloo.ca (Ross Ridge) writes:
>
>> So presumably copy57.5K switches to the memory map where everything is
>> RAM and does the copy using the remaining 6.5K of RAM to store the code
>> that does the copying.
>
> Yes, presumably. But it's just a little bit hard to do I/O if you switch
> I/O out of your memory space so that's not the thing to do, exactly. One
> could use RAM to RAM copy to fill the RAM under I/O. But I wonder,
> Pekka's routine was just 40 bytes using ROM routines so 6.5K (or 5.5K
> since the program was actually copy 58.5k) RAM seems excessive. The
> whole operating system is just 8K. So maybe the program skipped the I/O
> area?
>
> The other question is, what all do you need to take care of if you're
> going to get rid of the kernal and still be able to load stuff into RAM
> below and also get the kernal back later? But with a quick look it looks
> like disabling interrupts is enough.
>
> BTW, I think I found the program, it was COPY 58.5K and it's on a disk
> image at
>
http://www.commodoreserver.com/PublicDiskDetails.asp?DID=BABE16C933E24BE9A89B87
43E4F56D2C
>
> Maybe I'm going to try and figure out exactly how it works. Looks like
> it's 11 blocks so 2.75K but it might be compressed.
>
The load and save routines in stock kernal are not able to switch off
roms. But if you want to use whole memory, then you are able to open the
file as normal sequential file. When you need to get under ROMS, you
switch them off temporarily, read the byte and then switch them back on.
Only thing to remember is that when you switch ROMS off, the interrupt
vectors has to be taken account (especially NMI). On c64, if cpu writes
onto area of ROM, it writes the byte into underneath RAM. So you can
program the RAM memory beforehand using write-through method. When
reading, just turn ROMS off, read byte and then turn them back on. For
example:
; Copy 256 bytes from under Kernal Rom
; we copy the string to 60000, that is under KERNAL ROM.
; We output the string to screen using kernal routines. Same method can
; be used when outputting to disk - just open the file and select it.
; Without a string copied to 60000, this program copies whatever garble
; there is.
ldx #00 ;pointer
.loop sei
ldy #53 ;turn ROMS off
sta $1
lda 60000,x
ldy #55 ;turn ROMS on
sta $1
cli ;enable interrupts
;now we have the read byte from under Kernal in accu
jsr CHROUT ;chrout is label for Kernal chrout routine
inx
bne .loop
My program uses simplest possible method to save memory. It turns off
the BASIC interpreter, so it wont interfere with data in ram of its
area. The program is suitable for almost any pirated game program
copying, since if you load over 53247, you WILL have problems with your
video chip (since it garbles). That is why this tiny program is so
handy- it is small enough to be in memory, and it turns the basic
interpreter off. The basic interpreter is not needed when Kernal
routines are used, so you can safely turn it off. This tiny program
returns the basic interpreter after it has done its duties, so that you
have the shell control of the computer.
If you want to save using sequential file method, here is the pseudocode:
open file,P,W to disk drive
output start address LO,HI (f. ex 01, 08) mode
output data
close file
I have made a datagenerator, that made a basic program to disk. It was
able to load a m/l program, and then create basic for - read- poke- next
loop and data lines for it. It made tokenized code, and calculated all
needed line links and everything. It output the program using sequential
file mode, and the resulted file was normally loadable on c64. The
program itself was written in Basic, and it output basic program :D
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|