Post your Commander X16 program here

May 22, 2019
409
211
43
Reply with a link to your CX16 programs.

Thread rules: PROGRAMS ONLY. No comments, commentary, questions, etc. To discuss an entry, create a new thread and link back to the post in this one.

Use the Share button (circled below) to get the URL of the specific message. The 1569900472637.png button can be used to copy the link to the clipboard.

1569900402996.png
 

Attachments

Schol-R-LEA

New Member
Sep 20, 2019
10
9
3
OK, Let's start off with a simple implementation of the assembly equivalent of "Hello, World!": printing out a list of ASCII (or in this case, PETSCII) characters. Now, just to be clear, I am not usually quite this prolix with my comments, but I wanted to start off things with a solid, clear example, as well as to eliminate any ambiguities about the dev and test systems if others can't get it working on different systems. If the comments are TL;DR for you, just scroll to the end of the code window for the actual code. ;)

Code:
;;; PETSCII-simple - a quick and dirty demo for Commander x16
;;; using the ca65 assembler (part of the cc65 toolchain,
;;; see https://github.com/cc65/cc65 for downloads).
;;;
;;; target platform: Commander X16, Sept 2019 design
;;; test platform: cx16emu r.32
;;; dev host platform: Ryzen 3 2200g PC running Manjaro Linux
;;;
;;;
;;; Uses the Kernal print-character routine to print all of the
;;; characters of the first character set (40 hex to 7F hex).
;;;
;;; Since this was just a quick demo, I kept it simple,
;;; with all of the constants as local equates rather than
;;; using a separate header (as I plan to do with future programs).
;;;
;;; to assemble:
;;;    ca65 petscii-simple.asm -o petscii-simple.o -l petscii-simple.lst
;;; link:
;;;    cl65 petscii-simple.o -C cx16-asm.cfg -o petscii-simple.prg
;;; run:
;;;    x16emu -prg petscii-simple.prg -run

;;; constants
Kernal_bank   = $07
ROM_bank_ctrl = $9F61
BSOUT         = $FFD2

.org  $0801

;; common header for binary executable PRGs
.byte $0b,$08,$01,$00,$9e,$32,$30,$36,$31,$00,$00,$00

start:
      ; initialize the ROM Bank to 'kernal'
      ; while this is not strictly necessary since
      ; the BASIC ROM also includes the Kernal ROM,
      ; I wanted to make sure I had the procedure correct
      lda #Kernal_bank       ; get the bank ID #
      sta ROM_bank_ctrl      ; set the bank control

      ; print out all of the characts of the primary code set
      lda #$40               ; load the character '@'
loop:
      jsr BSOUT              ; print the current char
      adc #1                 ; increment the accumulator
      cmp #$7F               ; are we at the end of the codeset?
      bne loop               ; if not, loop
exit:
      rts
To assemble using ACME instead, just change these lines:
Code:
.org  $0801

;; common header for binary executable PRGs
.byte $0b,$08,$01,$00,$9e,$32,$30,$36,$31,$00,$00,$00
to:
Code:
*=  $0801

;; common header for binary executable PRGs
!byte $0b,$08,$01,$00,$9e,$32,$30,$36,$31,$00,$00,$00
and assemble as:
Code:
acme -f cbm -DMACHINE_C64=0 -o petscii-simple-acme.prg petscii-simple-acme.asm
The output of this (truncated for screen space) is:

PETSCII-simple test.png
 
Last edited:

DarwinNE

New Member
Sep 19, 2019
11
11
3
Here is a text adventure game called Two Days to the Race.

commanderX16_two_days.png

Free download (search for the Commander X16 version): http://davbucci.chez-alice.fr/index.php?argument=varie/two_days/two_days.inc&language=English

Your name is Emilia Vittorini, You're the daughter of Augusto Vittorini, who founded the Industria Torinese Automobili (ITA) with his brother Tullio. Your father is abroad trying to raise funds, but something went wrong and you heard your uncle coming back slamming the door. Your mission is to find what happened and how you can help your family. I will be your ears and eyes. Good luck.

It's a classical adventure where you should read descriptions carefully and type commands such as 'examine bed'. Type "north", "south", ... to move around. Abbreviations are possible "x" for "examine", "l" to "look" (i.e. describe again the place where you are), "i" for "inventory," "n" for "north" and so on. To quit the game, type "bye". To restart it, type "restart".

Discussion here: https://murray2.com/threads/a-text-adventure-game-for-the-cx16.339/
 

millenniumtree

New Member
Oct 2, 2019
24
16
3
Here's a little color demonstration with some randomness built in for a funky dithered gradient effect
Code:
10 FOR Y=0 TO 56:FOR X=0 TO 79 : REM FILL THE SCREEN
20 P=Y*256+X*2: REM SCREEN POSITION
30 VPOKE 0,P,INT(RND(1)*2)+205: REM OUTPUT RANDOM SLASH CHARACTER
40 VPOKE 0,P+1,INT((X+Y+RND(1)*16)/16): REM WITH A SOMEWHAT RANDOM COLOR
50 NEXT X,Y
 

Attachments

May 22, 2019
409
211
43
Here's a quick SMPTE-like color bars program. (You can't actually have SMPTE color bars without NTSC video, but this gives you an approximation...)


Code:
5 POKE $0286,1:PRINT"ô"
20 DATA 5, 35, 2
25 DATA 7, 1 ,7,3,13,4,10,14
30 DATA 40, 5, 2
35 DATA 7, 14,00,4,00,3,0,1
40 DATA 45,10, 10
45 DATA 7, 1,15,12,11,0,0,0
100 DIM C(16)
110 FOR Z=1 TO 3
120 READ Y1, YC, X1, CN
130 CN=CN-1:FOR I=0 TO CN:READ C(I):NEXT
140 GOSUB 2000
150 NEXT
999 END
1000 FOR N=0 TO 15
1010 POKE $0286,N
1020 PRINT N
1030 NEXT
1040 END
1999 :
2000 REM DRAW COLOR BARS
2005 :
2010 W=INT(80/(CN+1))
2020 FOR Y=1 TO YC
2030 N=Y1*256+X1:Y1=Y1+1
2040 FOR C=0 TO CN
2050 FOR X=1 TO W
2060 VPOKE 0,N,160
2070 VPOKE 0,N+1,C(C)
2080 N=N+2
2090 NEXT
2100 NEXT
2110 C=0
2120 NEXT
2130 RETURN

1570225716835.png
 

qbradq

New Member
Sep 14, 2019
24
13
3
Updated .BAS file with one compatible with more recent releases (r32+)

MINEFIELD.BAS
A work-in-progress Mine Sweeper game in BASIC. Comments welcome via DM for now, thanks! WARNING: Large minefields take a while to generate and run slow. But watching the flood fill algorithm in real-time is kinda neat :) Instructions on opening screen.

At the moment I am distributing as source code due to some token changes causing issues with users.

Screenshot_2019-10-05_20-27-38.png
 

Attachments

Last edited:

thrawn235

New Member
Oct 12, 2019
4
7
3
My very first Program for the X16.
Snake!

snake.jpg

Its still pretty crude, especially the keyboard function, it doesn't react sometimes.
I would need an interrupt to fix this.
Unfortunately i have no idea how to implement one. Maybe one of you can help me.

The Tail is also bugged. thats unfortunatly a major design flaw. it would require a complete redesign so i left it for now, maybe ill figure something out later.

I also have no idea how to return to the basic promt...

comments and critique welcome!

(source code and assets are included in the archive)

Discussion here: https://murray2.com/threads/my-snake-program.453/
 

Attachments

Last edited: