Page 1 of 1

Cartridge Autostart

Posted: Thu Jul 11, 2024 9:25 pm
by Martin Schmalenbach
Apologies if this is already covered somewhere else - use of the search function didn’t reveal usable information for me…

… what is the mechanism for auto detecting and then running the code on a cartridge?

Re: Cartridge Autostart

Posted: Fri Jul 12, 2024 12:06 am
by TomXP411
https://github.com/X16Community/x16-doc ... cartridges

It's in a less-than-obvious place... we could probably call that out in a better spot in the manual.

Re: Cartridge Autostart

Posted: Fri Jul 12, 2024 1:01 am
by Martin Schmalenbach
TomXP411 wrote: Fri Jul 12, 2024 12:06 am https://github.com/X16Community/x16-doc ... cartridges

It's in a less-than-obvious place... we could probably call that out in a better spot in the manual.
Perfect - thank you!

Re: Cartridge Autostart

Posted: Sat Jul 20, 2024 7:34 pm
by fraggintarget
Are there any tutorial for creating a ROM cartridge from start to finish step by step?

Re: Cartridge Autostart

Posted: Thu Aug 01, 2024 2:08 am
by JayKominek
fraggintarget wrote: Sat Jul 20, 2024 7:34 pm Are there any tutorial for creating a ROM cartridge from start to finish step by step?
If you mean the hardware part, I've got a 'tutorial' schematic at https://github.com/jkominek/x16simplecart which includes gerber files for a PCB you can have made for personal use. Or you can work through the schematic, replicate that, and do as you please with the result.

I don't think I've seen anything on the software portion, but if I do I'll try to remember to add a link to it.

Re: Cartridge Autostart

Posted: Thu Aug 01, 2024 9:51 pm
by SunSailor
fraggintarget wrote: Sat Jul 20, 2024 7:34 pm Are there any tutorial for creating a ROM cartridge from start to finish step by step?
I think I answered that in my thread already, but I can repeat it here in a maybe better structured way. At least, if you're speaking about the software side:
  • You want to have at least one ROM bank of 16kb, which starts with "CX16" at $c000 and is attached with the -cart parameter of the emulator.
  • In case you're unsure about the keymap used by your assembler, use $43, $58, $31, $36 directly.
  • Assemble your boot code into a bin file without any program header or start addresse at the beginning.
  • Build your cartridge with the created bin file with the makecart utility of the emulator, use -rom_file 32 my.bin to make it bank 32, which is read by the kernal and tested for the header (See boot_cartridge in kernal\drivers\x16.s)
  • Your program starts from $c004, it is up to you, how to handle the system now.
  • Most likely you want to do some initialization now and copy a payload code into the RAM of the X16.
  • Jump to the start address of this payload, assuming, your code begins at the head of it, otherwise another appropiate address
Things get a bit more complicated, if you want to use a c compiler, like the CC65. You need to copy multiple segments from ROM into RAM, at least, if you want to switch the bank later. Anyway, you need to copy at least the DATA segment, which is read-write enabled and relocate the BSS segment. You'll need to write your own crt.s for this, as the given one doesn't cater for these steps, but that is not a big deal. Configuring a custom memory map on the other hand is a bit of a hazzle, but doable.

Keep in mind some issues with the makecart utility:
  • In the docs, it is specified, that the payload of the cartridge starts at byte 512, but in reality, it is byte 480.
  • The -rom_file parameter documents, it would pack multiple bin files back to back in the specified bank and continuing, but due to a bug in the parameter parsing, this is not the case yet, only one file is considered. Better you concat the bin files yourself and provide a single file instead.

Re: Cartridge Autostart

Posted: Sat Aug 03, 2024 3:49 am
by fraggintarget
Thanks. Simple instructions tend help me be successful.

Re: Cartridge Autostart

Posted: Sat Aug 03, 2024 3:51 am
by fraggintarget
JayKominek wrote: Thu Aug 01, 2024 2:08 am
fraggintarget wrote: Sat Jul 20, 2024 7:34 pm Are there any tutorial for creating a ROM cartridge from start to finish step by step?
If you mean the hardware part, I've got a 'tutorial' schematic at https://github.com/jkominek/x16simplecart which includes gerber files for a PCB you can have made for personal use. Or you can work through the schematic, replicate that, and do as you please with the result.

I don't think I've seen anything on the software portion, but if I do I'll try to remember to add a link to it.
Just received 5 boards and will be putting something on them soon.