Now that the Juno First release candidate is out, I have a bit more time to look at other 2600 programming. I have been interested in batari basic for a while as I have several game ideas that could be done with a custom kernel strapped on. However, until recently I hadn't really looked at batari basic properly.
One thing that has been bothering me is that batari basic doesn't have a way to load playfield data directly from ROM. There are several games (e.g. Cave In) that have a high resolution playfield, but this requires extra superchip RAM. To cut a long story short, I have now written a prototype batari kernel that can load playfield data directly from ROM, without the need for the superchip. This should make several new kinds of games possible, and allow some existing superchip games to be released on regular carts.
The new kernel works by copying a single line of the playfield into RAM at a time. When a new playfield line is required, the kernel performs a bankswitch and copies the next line into RAM. The key to the technique is the following code which is placed in each bank. To make this code work, X is set to the bank containing the PF data, pfptr points to the start of the data, and pfoffset holds the current playfield offset from the start:
BS_loadPF ; Switch To Playfield Bank & Copy Data lda bankswitch_hotspot-1,x;  + 4 ldy pfoffset;  + 3 lda (pfptr),y;  + 5 sta aux1;  + 3 iny ;  + 2 lda (pfptr),y;  + 5 sta aux2;  + 3 iny ;  + 2 lda (pfptr),y;  + 5 sta aux3;  + 3 iny ;  + 2 lda (pfptr),y;  + 5 sta aux4;  + 3 iny ;  + 2 sty pfoffset;  + 3 ifconst bankswitch if bankswitch == 8 lda $FFF9;  + 4 endif if bankswitch == 16 lda $FFF9;  + 4 endif if bankswitch == 32 lda $FFFB;  + 4 endif endif jmp EndLoad;  + 3
This code requires 57 cycles, so an extra blank line is required between PF rows. However, I think it still looks good (compare the attached Cave In screenshots below to see the difference). Let me know if you can see any improvements to this technique? Obviously it could be improved if the playfield data was always in the same bank as the kernel, but this isn't practical for many games.
Because the PF data is loaded from ROM, it could technically support more than the 31 PF rows of the superchip kernel, though I haven't tried this yet. The kernel is still at a prototype stage and I could use a bit of help to improve it and integrate it properly into batari basic. The files that I have changed from the standard 1.0 release of batari basic are attached (in batarifiles.zip).
The main issues are:
- There isn't enough RAM left to support various kernel options, e.g. pfscore, pfheighttable, pfcolortable, lives, etc. This can probably be fixed by reorganising things a bit.
- The colour data for the player 1 sprite is off by one line (not sure why).
- It should probably be integrated as a new kernel, rather than a hack of the standard kernel.
- It is relatively tolerant of page boundary crossings in the playfield data, but this could be improved.
- There are some weird issues display missile and ball sprites (occasionally it craps out completely).
I have been using the Cave In source code as a testbed for this kernel. However, I don't want to post the code here as I haven't heard from Atarius Maximus yet. I can only compile pre-RC1 versions as the new kernel requires a bit of extra space in each bank and this is pushing things over the limit. Hopefully this issue can be fixed in later versions.
Anyway, let me know what you think? I'm not sure of the status of the superchip boards, so this kernel might not be necessary, but I still think it would be nice to avoid using the superchip if it is not strictly required.