Cartridge Autostart

Get help from the community & developers with the X16 hardware if you can't find the solution elsewhere
Post Reply
mgkaiser
Posts: 33
Joined: Sat Dec 02, 2023 6:49 pm

Cartridge Autostart

Post by mgkaiser »

Right now we check ROM bank 32 for a signature and autostart the cartridge if it is present. Have we considered checking multiple banks, perhaps 32-35, so that each slot could have its own ROM? We reserve 32 for "cartridges" and any expansion card would need jumpers to select 33-35 for its ROM. Then we would need a way to call into the ROM, allow it to do some setup, and return to the Kernal. I'm thinking about using this for an network card which would present itself as an IEC device. All the code to deal with the card would be in its own ROM, but it would need a way of adjusting the vectors so it's ROM would get a chance to see if its device was being accessed. I'm sure there would be other applications of this as well.
DragWx
Posts: 306
Joined: Tue Mar 07, 2023 9:07 pm

Re: Cartridge Autostart

Post by DragWx »

An immediate workaround I can think of is:
1) A flag in the card's IO region to enable or disable ROM, disabled by default. (Compatibility with autoboot cartridges, sharing the ROM space with multiple cards)
2) Some lines in AUTOBOOT.X16 to enable the card's ROM and then a SYS call to its initialization code.

This would depend on having storage present at boot, and this whole thing gets skipped when an autoboot cartridge is inserted (may not be a bad thing).


As far as the Kernal automatically running expansion card init routines, I don't have any simple ideas. Banks 32-255 need to be available for any plugged-in cartridges. Is there any different way for the Kernal to query for initializable expansion cards in a standardized way?
TomXP411
Posts: 1718
Joined: Tue May 19, 2020 8:49 pm

Re: Cartridge Autostart

Post by TomXP411 »

I see the problem. If you want the ROM for your network card to live in a high bank number, say $FE, then the KERNAL is not going to start the driver.

This is what AUTOBOOT.X16 is for. You can use that to SYS to the network driver's initialization routine, then maybe display a message that this has been done.

Here's a quick and dirty routine to check for the presence of a ROM in an arbitrary bank and start it.
10 BANK 0,$FE
20 A$="CX16"
30 FOR N=$C000 TO $C003
40 IF PEEK(N) <> ASC(MID$(A$,N,1)) THEN PRINT "ROM NOT FOUND":END
50 NEXT
60 POKE $BF00,$FF
70 SYS $C004
At this point, it would be up to your ROM to do its setup and cleanly return to BASIC. I can think of a few ways to detect whether BASIC
has already started running, but the simplest way may be to have two different entry points: $C004 would start the cold boot version (which jumps to BASIC after the init is done), and $C010 could start a version that RTSs back to BASIC after starting the driver.

In fact, the code at $C004 could literally just be something like
JSR $C010
JMP enter_basic
So line 70 above becomes
SYS $C010
Post Reply