Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > KERNAL IO and the safe memory regions
2020-03-16 13:39
oziphantom

Registered: Oct 2014
Posts: 478
KERNAL IO and the safe memory regions

Does anybody have a handy dandy list of "places that need to be saved" for KERNAL drive IO on
C64
C128
C+4

I know the IDE64 docs have a 64 list.
2020-03-16 14:30
Krill

Registered: Apr 2002
Posts: 2851
Not sure if that's what you mean, but i have a list of ZP variables here that mustn't be overwritten during load.

From my loader's source (check the end of the lines, too lazy to remove the bloat now):
        .assert (loader_zp_first > STATUS) || (loader_zp_last < STATUS), error, "Loader zeropage variables cross KERNAL STATUS register at $90"
        .assert (loader_zp_first > C3PO) || (loader_zp_last < C3PO), error, "Loader zeropage variables cross KERNAL serial buffer output char buffered flag C3PO at $94"
        .assert (loader_zp_first > BSOUR) || (loader_zp_last < BSOUR), error, "Loader zeropage variables cross KERNAL serial buffer byte BSOUR at $95"

        .if PLATFORM = diskio::platform::COMMODORE_16
        .assert (loader_zp_first > LDTND) || (loader_zp_last < LDTND), error, "Loader zeropage variables cross KERNAL logical file index/open files count at $97"
        .assert (loader_zp_first > DFLTN) || (loader_zp_last < DFLTN), error, "Loader zeropage variables cross KERNAL input device variable DFLTN at $98"
        .assert (loader_zp_first > DFLTO) || (loader_zp_last < DFLTO), error, "Loader zeropage variables cross KERNAL output device variable DFLTO at $99"
        .assert (loader_zp_first > R2D2) || (loader_zp_last < R2D2), error, "Loader zeropage variables cross KERNAL serial bus EOI flag R2D2 at $a6"
        .assert (loader_zp_first > BSOUR1) || (loader_zp_last < BSOUR1), error, "Loader zeropage variables cross KERNAL serial bus shift counter BSOUR1 at $a8"
        .assert (loader_zp_first > COUNT) || (loader_zp_last < COUNT), error, "Loader zeropage variables cross KERNAL serial bus counter COUNT at $aa"
        .assert (loader_zp_first > USE4DY) || (loader_zp_last < USE4DY), error, "Loader zeropage variables cross KERNAL parallel drive state register USE4DY at $f9"
        .else; PLATFORM <> diskio::platform::COMMODORE_16
        .assert (loader_zp_first > LDTND) || (loader_zp_last < LDTND), error, "Loader zeropage variables cross KERNAL logical file index/open files count at $98"
        .assert (loader_zp_first > DFLTN) || (loader_zp_last < DFLTN), error, "Loader zeropage variables cross KERNAL input device variable DFLTN at $99"
        .assert (loader_zp_first > DFLTO) || (loader_zp_last < DFLTO), error, "Loader zeropage variables cross KERNAL output device variable DFLTO at $9a"
        .assert (loader_zp_first > R2D2) || (loader_zp_last < R2D2), error, "Loader zeropage variables cross KERNAL serial bus EOI flag R2D2 at $a3"
        .assert (loader_zp_first > BSOUR1) || (loader_zp_last < BSOUR1), error, "Loader zeropage variables cross KERNAL serial bus shift counter BSOUR1 at $a4"
        .assert (loader_zp_first > COUNT) || (loader_zp_last < COUNT), error, "Loader zeropage variables cross KERNAL serial bus counter COUNT at $a5"
        .endif; PLATFORM <> diskio::platform::COMMODORE_16
Note that C64 and C128 addresses are identical.
This list may not be complete.
2020-03-16 15:24
oziphantom

Registered: Oct 2014
Posts: 478
off the top of my head I can add
FNLEN
LA
SA
FA
FNADR
MYCH
STAL
IOPEN
ICLOSE
ILOAD
ISAVE
I guess some other Ivectors are needed

128 does move some of them. Also adds the Filename bank, load/save bank, JSRFAR,CMPFAR,STAFAR, LDAFAR routines
2020-03-16 15:48
chatGPZ

Registered: Dec 2001
Posts: 11135
- make a testprogram that uses all the function you want to use
- trace load store 2 3ff
- run the testprogram
- sort -u
- there is your list :)

(adjust range for other cbm computers)
2020-03-16 16:26
Krill

Registered: Apr 2002
Posts: 2851
What Groepaz said, then. I was only referring to the mentioned ZP addresses with regard to "same on C128". Some of the vectors aren't actually used by the ROM depending on what is called or running. Some of the mentioned variables don't need to be buffered because they're overwritten before calls. Etc. So yeah, what Groepaz said.

And as usual: what are you actually trying to do? :)
2020-03-16 17:33
oziphantom

Registered: Oct 2014
Posts: 478
load files on the C64, C128 and +4, prg and seq and not have to keep all of Kernal and 200-1000 saved in some cases as per how the machine needs it to be saved.

Basically to Expand Bucket Wars I need to "load" things(maybe save things as well). And I have a 64, 128 and +4 version to support. And maybe also a CX16 but In that case I have 512K of RAM so I can just blanket copy the "reserved" areas into one of the 8K RAM banks and be done with it ;) Also I will need to keep the vectors alive as you can't disable the KERNAL on it.
Normally on the 128, I disabled shared memory and then put my ZP and Stack in Bank 1, and save/restore the vectors. Switch ZP, stack back to bank 0, call kernal, switch back to bank 1. However since I have 64 and +4 support and I might want to use the other bank for other things, I'm going to do the save and restore route on it too.

So basically I'm going to have a
"saveIOVars" function that gets called, a custom version per machine. Then a "restoreIOVars" function that gets called, a custom version per machine.

Although at the moment I'm trying to get the codebase "save file byte by byte" example working. It write the first byte fine, then 2nd but it gives a "Drive no ready" error. The basic version works fine with the same filename...
2020-03-16 17:34
oziphantom

Registered: Oct 2014
Posts: 478
Quote: - make a testprogram that uses all the function you want to use
- trace load store 2 3ff
- run the testprogram
- sort -u
- there is your list :)

(adjust range for other cbm computers)


yeah on windows it is not so practical, luckily the VICE PDB has a script panel that lets me dump the really large pile of data into a text file.
2020-03-16 21:11
chatGPZ

Registered: Dec 2001
Posts: 11135
Quote:
on windows it is not so practical

this can be done exactly like this on windows
Quote:
uckily the VICE PDB has a script panel that lets me dump the really large pile of data into a text file

or just do the same thing right from the monitor (use a recent nightly)
2020-03-16 23:54
Bacchus

Registered: Jan 2002
Posts: 154
In the crack of Alternate Reality I just implemented a ZP swap routine. This swapped all of zero page as zpbase2 was 2 and I didn't just swap the pointers relevant for my own stuff (commented out the "stop"). ZPstore was under the dxxx block and hence the need to update 01...

swapzp: sei
lda #$34
sta $01

ldx #zpbase2

swapzp2: lda $00,x
pha
lda zpstore,x
sta $00,x
pla
sta zpstore,x
inx
// cpx #zpbase2+12
bne swapzp2

lda #$35
sta $01
rts


/Bacchus
2020-03-17 08:58
Comos

Registered: May 2004
Posts: 71
Depends which Kernal call you are acutally executing,some ZP addys can be overwritten temporarily.

Example when calling OPEN (when SETLFS and SETNAM are done before with a valid drive number @ $BA), ZP addy like $90 must be set to $00, because it's updated by OPEN ,other ZP that must be set $98=$00,$99=$00,$9A=$03 , or just call $FFE7 if some heavy ZP use is done before and these address are not relevant afterwards.
During CHKIN or CHKOUT, index tables @ $259-276 must not be tampered (if we are opening just one file,then the index table quite small), that counts also for $99 and $9a.
During CHRIN/CHROUT, the $99 & $9a still must be not tampered.
If the device is Kernal serial calls dependant, the ZP addy $02A1 must remain set to $00 during CHKIN/CHKOUT.
The vector table starting from $0314-$0333 needs to be preserved too, if you need to maintain compatability.
2020-03-17 09:19
TWW

Registered: Jul 2009
Posts: 541
If you can afford the Y-Register you shave of 7 cycle pr byte swapped and save a couple of bytes;

swapzp:
		sei
		lda #$34
		sta $01

		ldx #$02
swapzp2:
		lda $00,x
		ldy zpstore,x
		sty $00,x
		sta zpstore,x
		inx
		bne swapzp2

		lda #$35
		sta $01
		rts
 
... 8 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
fredrikr
Mike
Unlock/Padua/Albion
tlr
Alakran_64
kbs/Pht/Lxt
JEZ
Freestyle/Illusion
Guests online: 108
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Musicians
1 Vincenzo  (9.8)
2 Rob Hubbard  (9.7)
3 Stinsen  (9.7)
4 Jeroen Tel  (9.6)
5 Linus  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.071 sec.