Post your Commander X16 program here

May 22, 2019
493
255
63
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
17
10
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
12
14
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
23
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
493
255
63
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
15
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:
  • Like
Reactions: JayLewis

thrawn235

New Member
Oct 12, 2019
7
8
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:

blitmaps

New Member
Oct 25, 2019
1
2
3
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 View attachment 310 button can be used to copy the link to the clipboard.

View attachment 308
Here is a small puzzle game I put together in C. You use the Enter Key to start, then the SPACE key to change the colour of your stack of blocks. Matching blocks are deleted when blocks collide, levels get harder quickly. Just a quick demo, I think it should return to BASIC properly. Works in R33, should work with a JOY1 too.


Screenshot 2019-10-25 at 14.16.46.pngScreenshot 2019-10-25 at 14.17.02.png
 

Attachments

Schol-R-LEA

New Member
Sep 20, 2019
17
10
3
Relating to another threa, I ended up implementing the Bresenham circle algorithm in BASIC. As it turns out, there wasn't much point to it (as Tom made it clear he knew the algorithm better than I do), but I figured I'd post it anyway.

Code:
5 SCREEN $80
10 PI=3:LF=150:TP=50:RT=250:BT=150:FC=10
20 FRAME LF,TP,RT,BT,FC
30 CX=200:CY=100:R=50:CC=6
40 X=0:Y=R:D=PI-(2*R)
100 IF X>Y THEN 500
110 PSET CX+X,CY+Y,CC
120 PSET CX+X,CY-Y,CC
130 PSET CX-X,CY+Y,CC
140 PSET CX-X,CY-Y,CC
150 PSET CX+Y,CY+X,CC
160 PSET CX+Y,CY-X,CC
170 PSET CX-Y,CY+X,CC  
180 PSET CX-Y,CY-X,CC
200 X=X+1
210 IF D>0 THEN 300
230 D=D+(4*X)+6
240 GOTO 100
300 Y=Y-1
310 D=D+(4*(X-Y))+10
320 GOTO 100
500 END
To illustrate the algorithm better for those more familiar with newer languages, I also came up with the following Python code:
Code:
# assumes that 0,0 is in the upper left.
# adjust accordingly for other coordinate maps
circle (cx, cy, radius):
    if r < 0:
        plot(cx, cy)
    else:
        x = 0
        y = r
        # D is the 'decision value' which determines how to
        # update x and y
        # For the integer version, set PI to 3;
        # accuracy improves with more significant figures
        D = PI - 2 * r
      
        while y >= x:
            # first, plot the existing points at the quadrants
            for dx in [x, -x]:
               for dy in [y, -y]:
                   plot(cx+dx, cy+dy)
                   plot(cx+dy, cy+dx)
            # then, update the values for D, x, and y
            x += 1
            if D > 0:
                y -= 1
                D += (4 * (x - y)) + 10
            else:
                D += (4 * x) + 6