Cross post from the Programming section of the forums (I think belongs here too).
I've been working on a CX16 programming guide and C programming tutorial/guide. I'll be adding more but it's ready enough to share. Even if you don't want to code in C its a good general CX16 programming guide/tutorial. It has C code examples for everything discussed. It uses cc65 but I explain how to do everything "from scratch" before leveraging any libraries that cc65 has to offer so you _should_ be able to use another compiler. I learned a lot putting this together so hopefully someone will find this helpful.
https://github.com/mwiedmann/cx16CodingInC
Here are the current chapters just to give you an idea.
Chapter01-Installation
Chapter02-First-Program-Setup
Chapter03-Numbers
Chapter04-CX16-Overview
Chapter05-Video-Memory
Chapter06-Tiles
Chapter07-MapBase
Chapter08-Palette
Chapter09-Color-Depth-Modes
Chapter10-Tile-Sizes
Chapter11-Bitmap-Mode
Chapter12-Layers
Chapter13-GameLoop-Wait
Chapter14-Controls-and-Input
Chapter15-Sprites
Chapter16-Animations
Chapter17-Collisions
Coming soon - Files and some "Put it all together" game examples.
CX16 Programming and Coding in C Guide/Tutorial
Forum rules
Post guides, tutorials, and other instructional content here.
This topic area requires approval, so please be patient while we review content to make sure it fits the expectations for this topic area.
Tech support questions should be asked in Hardware or Software support.
Post guides, tutorials, and other instructional content here.
This topic area requires approval, so please be patient while we review content to make sure it fits the expectations for this topic area.
Tech support questions should be asked in Hardware or Software support.
- StephenHorn
- Posts: 565
- Joined: Tue Apr 28, 2020 12:00 am
- Contact:
Re: CX16 Programming and Coding in C Guide/Tutorial
Only had a chance to take a quick glance at it, but this looks pretty good so far! This should be a huge help for C programmers wanting to get started with the X16!
Developer for Box16, the other X16 emulator. (Box16 on GitHub)
I also accept pull requests for x16emu, the official X16 emulator. (x16-emulator on GitHub)
I also accept pull requests for x16emu, the official X16 emulator. (x16-emulator on GitHub)
Re: CX16 Programming and Coding in C Guide/Tutorial
Hey, just wanted to leave a note that I'm using this tutorial. I've worked through the first few chapters and this is enormously helpful so far. This is a very well-written tutorial and it is saving me many hours of having to figure these things out "the hard way." Thanks so much for taking the time to write this!
Dr.J
Dr.J
Re: CX16 Programming and Coding in C Guide/Tutorial
Glad it is helping! I've learned a few things since I wrote this so I'll hopefully make a few updates soon. Everything in there is still good to go but some the joystick section needs an update and the (lack of) sound chapter needs a major update (plus a few other minor things). MooingLemur released the fantastic "ZSMKit" and I learned how to use it in C. This part is huge and makes it WAY easier to do music/sound now. Thanks again for checking this out though!
Re: CX16 Programming and Coding in C Guide/Tutorial
Very nice! I plan to learn 6502 assembler coding, but programming in C is a good first step, and I wrote a ton of C code during my long career as a programmer, so I expect, with the help of your tutorial, I will get this step done quickly.
-Bill
-Bill
Re: CX16 Programming and Coding in C Guide/Tutorial
Thanks for providing this guide — I can confirm that the Linux steps you've given so far (in the first couple videos) work just fine on macOS, too. Same use of "make", same convenience putting cl65 in the PATH (I edited the one in my .zshrc, but people using the default Bash shell should put it in .bash_profile).
One question, though, and I don't know if you're covering it in a later video. How do we access Kernal routines from C? There doesn't seem to be a lot of documentation on how the cx16.h library works outside that big "vera" struct, but what if I want to use asm routines for speed in drawing character-cell graphics (like the old Below the Root game)?
One question, though, and I don't know if you're covering it in a later video. How do we access Kernal routines from C? There doesn't seem to be a lot of documentation on how the cx16.h library works outside that big "vera" struct, but what if I want to use asm routines for speed in drawing character-cell graphics (like the old Below the Root game)?
- ahenry3068
- Posts: 1132
- Joined: Tue Apr 04, 2023 9:57 pm
Re: CX16 Programming and Coding in C Guide/Tutorial
I've only played around with the C compiler a little but I believe there are two ways to do that. You can either use inline assembly (Not sure of the keyword, but I think there is one) or "link" in an external library written in assembly.Ringoid wrote: ↑Tue Feb 06, 2024 8:19 am Thanks for providing this guide — I can confirm that the Linux steps you've given so far (in the first couple videos) work just fine on macOS, too. Same use of "make", same convenience putting cl65 in the PATH (I edited the one in my .zshrc, but people using the default Bash shell should put it in .bash_profile).
One question, though, and I don't know if you're covering it in a later video. How do we access Kernal routines from C? There doesn't seem to be a lot of documentation on how the cx16.h library works outside that big "vera" struct, but what if I want to use asm routines for speed in drawing character-cell graphics (like the old Below the Root game)?
- JimmyDansbo
- Posts: 476
- Joined: Sun Apr 26, 2020 8:10 pm
- Location: Denmark
- Contact:
Re: CX16 Programming and Coding in C Guide/Tutorial
You may find this useful for combining C and assembler:
https://techblog.dansbo.dk/?p=62
For short inline assembly, you use the __ASM__ keyword, see:
https://www.cc65.org/doc/cc65-9.html
https://techblog.dansbo.dk/?p=62
For short inline assembly, you use the __ASM__ keyword, see:
https://www.cc65.org/doc/cc65-9.html
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Re: CX16 Programming and Coding in C Guide/Tutorial
I'm a little more than halfway through and this has been an enormous help! Thank you for putting this together. If you turned this into a book I would buy it just to support your efforts. The writing is articulate, easy to read with small examples easily digested, but meaningful enough to show the power they represent. I am planning to use a hybrid C/asm approach and this documentation and samples have been a enormous springboard to get me up and running. Nice work!
- desertfish
- Posts: 1094
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Re: CX16 Programming and Coding in C Guide/Tutorial
I hadn't looked at this before but I browsed through it now. It's really some superb work ! I'm jealous!