Commodore 128 Alive!

Commodore 128 => 128 programmers => Topic started by: hannenz on January 13, 2008, 11:52 PM

Title: safe places in zeropage
Post by: hannenz on January 13, 2008, 11:52 PM
which locations are safe to use in zero page besides $fa - $ff?
and btw: i don't quite understand the concept of relocating zeropage:

$d507 holds the P0L Register and $d508 the P0H according to the c128's manual
but $d507 needs the Hi-BYte (Page) location of the desired Page. What is the P0H good for.
And: To which RAM Bank does all this apply. Always to the currennt visible?!
Title: Re: safe places in zeropage
Post by: airship on January 14, 2008, 01:52 AM
Unfortunately, the cassette tape buffer on the C128 is in page one, not page zero like it is on the C64, so that's out.

Are you using BASIC? If so, you're kind of screwed. If not, that opens up several possibilities. There are pointer locations in page zero for tape and RS-232 operations that you could use if you're not using those. The two floating point accumulator locations should be free for M/L. There are also work areas for string functions, etc. that are available if you're not using them. The best thing to do is buy or download a copy of Mapping the C128 and go through byte by byte and try to figure out what you can hijack. Be VERY careful with locations that are used by the Kernal, as opposed to those that are just used by BASIC. Sometimes 'Mapping' only lists the PRIMARY function of a zero page location, but it's also used for other things by other routines.

Good luck!
Title: Re: safe places in zeropage
Post by: hannenz on January 14, 2008, 02:39 AM
thanks :)
Title: Re: safe places in zeropage
Post by: nikoniko on January 14, 2008, 06:19 AM
$D507 is the page number (high byte) zero page accesses will be redirected to. Bit 0 of $D508 is used to select which RAM bank zero page will go to. Bits 0-3 are actually reserved here, which may suggest that if you have an internal RAM expansion you could also direct zero page to one of the extra banks, but I'm not sure if that really works in practice. I don't personally know anyone who has an internally expanded 128.

There are some things to be mindful of when redirecting zero page:

Title: Re: safe places in zeropage
Post by: hannenz on January 14, 2008, 07:37 AM
ok, these are precious information; thanks a lot, this will help me a lot
Title: Re: safe places in zeropage
Post by: BigDumbDinosaur on January 14, 2008, 12:30 PM
And, if all else fails, RTFM.  Mapping the Commodore 128 contains a detailed explanation of what every ZP location does.  In fact, read the entire book.  :-)  That's how I learned the machine.  Geesh!
Title: Re: safe places in zeropage
Post by: BigDumbDinosaur on January 14, 2008, 12:39 PM
Quote from: airship on January 14, 2008, 01:52 AM
Unfortunately, the cassette tape buffer on the C128 is in page one, not page zero like it is on the C64, so that's out.

Are you using BASIC? If so, you're kind of screwed. If not, that opens up several possibilities. There are pointer locations in page zero for tape and RS-232 operations that you could use if you're not using those. The two floating point accumulator locations should be free for M/L. There are also work areas for string functions, etc. that are available if you're not using them. The best thing to do is buy or download a copy of Mapping the C128 and go through byte by byte and try to figure out what you can hijack. Be VERY careful with locations that are used by the Kernal, as opposed to those that are just used by BASIC. Sometimes 'Mapping' only lists the PRIMARY function of a zero page location, but it's also used for other things by other routines.

Good luck!
The 128's cassette buffer is at $0B00, which is page 11.  The stack is in page 1.  Are you confusing pages with RAM banks?

Unless changed. common low RAM extends from $0000 to $03FF.  Therefore, the 128's cassette buffer is in RAM bank 0.  It is possible to point logical zero page to the casette buffer if tape is not going to be used.  The fake RS-232 buffers at $0C00 and $0D00 are also possible.  In fact, any page between $0B00 and $1000 is theoretically okay for relocated ZPs and stacks, as long as the functions that normally use these areas are not invoked.  Also, if BASIC is not to be used, its runtime stack at $0800 is fair game.  If only 80 column display is to be used, you can steal any of the four pages that encompass VIC character RAM ($0400-$07FF).
Title: Re: safe places in zeropage
Post by: airship on January 15, 2008, 01:22 AM
Just a temporary brain glitch on the cassette buffer location. Page 11 it is.
Title: Re: safe places in zeropage
Post by: wte on January 15, 2008, 06:58 AM
Quote from: BigDumbDinosaur on January 14, 2008, 12:39 PM
[...] Unless changed. common low RAM extends from $0000 to $03FF.  Therefore, the 128's cassette buffer is in RAM bank 0.  It is possible to point logical zero page to the casette buffer if tape is not going to be used. [...]
Using the tape buffer is not a good idea if you are using BOOT and may be some other BASIC 7.0 DOS commands.
BOOT destroys the buffer and some other DOS commands are using the first 2 or 3 bytes as temporary storage.
Only if you don't use BOOT and don't need the first bytes the tape buffer is a good place for ML or data.

WTE
Title: Re: safe places in zeropage
Post by: hannenz on January 15, 2008, 08:16 AM
thanks for all your replies, but i am not interested in the tape buffer at all - i asked for ZEROpage locations ;) and tape buffer isn't located in the zeropage neither on c128 nor on the c64 (it is at $33c - $3xx on c64).
Title: Re: safe places in zeropage
Post by: BigDumbDinosaur on January 15, 2008, 09:25 AM
Quote from: wte on January 15, 2008, 06:58 AM
Quote from: BigDumbDinosaur on January 14, 2008, 12:39 PM
[...] Unless changed. common low RAM extends from $0000 to $03FF.  Therefore, the 128's cassette buffer is in RAM bank 0.  It is possible to point logical zero page to the casette buffer if tape is not going to be used. [...]
Using the tape buffer is not a good idea if you are using BOOT and may be some other BASIC 7.0 DOS commands.
BOOT destroys the buffer and some other DOS commands are using the first 2 or 3 bytes as temporary storage.
Only if you don't use BOOT and don't need the first bytes the tape buffer is a good place for ML or data.

WTE
Most people don't manually use boot, and the kernal call to boot_call ($FF53) at boot-time will be working with the standard map.  In any case, the application using a relocated ZP or stack is going to be custom, by definition, and therefore it will be the programmer's responsibility to analyze memory usage.  That's what makes M/L so fun!  :-)
Title: Re: safe places in zeropage
Post by: BigDumbDinosaur on January 15, 2008, 09:26 AM
Quote from: hannenz on January 15, 2008, 08:16 AM
thanks for all your replies, but i am not interested in the tape buffer at all - i asked for ZEROpage locations ;) and tape buffer isn't located in the zeropage neither on c128 nor on the c64 (it is at $33c - $3xx on c64).

Yes, but you did ask about relocating ZP and the buffer is one of several possible places for that sort of activity.
Title: Re: safe places in zeropage
Post by: hannenz on January 15, 2008, 08:05 PM
oops - you're right - sorry  ::)
EhPortal 1.34 © 2025, WebDev