Cartridge Autostart

Get technical support from the community & developers with specific X16 programs if you can't find the solution elsewhere
(for general non-support related chat about programs please comment directly under the program in the software library)
Post Reply
Martin Schmalenbach
Posts: 135
Joined: Tue Jul 21, 2020 10:08 pm

Cartridge Autostart

Post 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?
TomXP411
Posts: 1760
Joined: Tue May 19, 2020 8:49 pm

Re: Cartridge Autostart

Post 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.
Martin Schmalenbach
Posts: 135
Joined: Tue Jul 21, 2020 10:08 pm

Re: Cartridge Autostart

Post 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!
fraggintarget
Posts: 5
Joined: Sun Jan 31, 2021 11:02 pm

Re: Cartridge Autostart

Post by fraggintarget »

Are there any tutorial for creating a ROM cartridge from start to finish step by step?
JayKominek
Posts: 6
Joined: Tue Oct 31, 2023 6:43 am

Re: Cartridge Autostart

Post 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.
SunSailor
Posts: 10
Joined: Mon Apr 03, 2023 10:50 pm

Re: Cartridge Autostart

Post 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.
fraggintarget
Posts: 5
Joined: Sun Jan 31, 2021 11:02 pm

Re: Cartridge Autostart

Post by fraggintarget »

Thanks. Simple instructions tend help me be successful.
fraggintarget
Posts: 5
Joined: Sun Jan 31, 2021 11:02 pm

Re: Cartridge Autostart

Post 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.
Post Reply