| |
AmiDog
Registered: Mar 2003 Posts: 97 |
C128 coding
I recently decided to atempt some C128 coding, as in porting a little something from C64 mode to native C128 one. Some things I've learned:
1. The C128 has ROM all over the place. If you use exomizer and have a start address >= $4000, you need to have exomizer enable some RAM (-Di_ram_exit=$0e) or you end up trying to execute ROM.
2. Did I mention the C128 has ROM all over the place? Poke $3e to $ff00 to enable RAM all over the place. But remember to disable raster interrupts first (or prepare to crash), as it's used by the C128 kernel.
3. Ever been annoyed about the hardware vectors getting in your way? Prepare to be annoyed about the MMU register mirror at $ff00. Accidently poke the "wrong" value there and you end up switching 64K RAM bank (=crash).
4. $01 is a totally different beast on the C128. Poke your normal $35 in there and you end up disabling CharROM in the current bank (which is handy) but you also tell VIC to access one of the ColorRAM banks while the CPU accesses the other. Took me some time to figure out why my $d800 writes didn't have any effect.
5. I told you about the kernel using raster interrupts, right? Well, unless you disable them, you need to use the shadow VIC registers or become confused as to why your VIC register writes gets wiped out all the time.
Now it's time to try to understand the banking and take advantage of the extra 64K somehow... |
|
| |
ready.
Registered: Feb 2003 Posts: 441 |
interesting, I have always thought it'd be cool to do a C128 demo myself, but I need to get myself study this machine. Sometime in the not-so-near future..... |
| |
Skate
Registered: Jul 2003 Posts: 494 |
3. Isn't it the expected behaviour? Try poking wrong values to hw vectors on c64 and see what happens. :)
4. This looks a little bit weird at the beginning but when you start using color ram double buffering feature, you will stop complaining. ;)
|
| |
AmiDog
Registered: Mar 2003 Posts: 97 |
@Skate
3. The annoying thing about the MMU registers is that they basically waste a full page at the end of the 64K bank. My problem was that I was using that page as part of a charset on the C64 and things just blew up when I copied that charset to the last page during setup. On the C64 the hardware vectors are only a problem when interrupts are enabled, but the MMU registers are there all the time.
4. Yes, double buffered ColorRAM is nice.
|
| |
Skate
Registered: Jul 2003 Posts: 494 |
Thanks for the explanation on the 3rd item.
I had a platform game project for C128 but somehow it turned into a C64 game project. :) I hadn't own a C128 until last year. I bought it to examine the real thing but because of my other projects on several platforms, my C128 projects are in pending status.
Continue discussing C128 stuff. It will help me and other coders who are interested in C128 in the future when searching CSDB forums. :) |
| |
AmiDog
Registered: Mar 2003 Posts: 97 |
Having two 64K banks is nice, but how to use them both? There are a few ways:
1. Enable a little common RAM. Common RAM is basically bank 0 RAM visible in bank 1 as well. This means you can swap between banks at any time as long as the code currently running is in common RAM.
2. Relocate page 0 and/or page 1. As these pages can be put in the opposite bank (whichever that currently is), you basically have two 256 byte windows (or a combined 512 byte one) which can be used to poke and peek the other bank. Just rememner that $00 and $01 will remain special even when page 0 is relocated.
3. As a PHA is only three cycles, people seem to like to copy between banks by relocating page 1 and doing:
-
LDA (SRC),Y
PHA
DEY
BNE -
4. As the VIC can be directed to a different bank than the CPU, you can have 64K reserved for the VIC and 64K for code and data, if you need a lot of VIC banks that is :-) |