Skip to content

Instantly share code, notes, and snippets.

@Frank-Buss
Frank-Buss / demo.c
Created September 14, 2019 12:17
Commander X16 hello world with CC65
// save as demo.c and compile like this:
// cl65 -t c64 -O -o demo.prg demo.c
#include <stdint.h>
#include <cbm.h>
#define BSOUT(c) \
__AX__ = c; \
asm("jsr BSOUT");
@Frank-Buss
Frank-Buss / music.bas
Created September 24, 2019 19:05
play some music on the Commander X16
100 O=5:N=10:GOSUB 1000
110 O=5:N=10:GOSUB 1000
120 O=6:N=4:GOSUB 1000
130 O=6:N=4:GOSUB 1000
140 O=6:N=6:GOSUB 1000
150 O=6:N=6:GOSUB 1000
160 O=6:N=4:GOSUB 1000
170 O=6:N=4:GOSUB 1000
900 END
1000 REM N = NOTE, O = OCTAVE
@Frank-Buss
Frank-Buss / dumpvgm.py
Created September 25, 2019 04:19
Converts a VGM file to BASIC POKEs
#!/usr/bin/python3
import argparse
# parse arguments
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
description='Converts a VGM file to BASIC POKEs.')
parser.add_argument('input', help='the input file name')
args = parser.parse_args()
@Frank-Buss
Frank-Buss / gong.bas
Created September 25, 2019 05:09
4 tone gong on the Commander X16
100 REM RESET SOUND CHIP
110 FOR I = 0 TO 255 : POKE $9FE0, I : POKE $9FE1, 0 : NEXT
120 REM GONG
130 O=5:N=0:C=0:GOSUB 1000
140 O=5:N=9:C=1:GOSUB 1000
150 O=6:N=0:C=2:GOSUB 1000
160 O=6:N=9:C=3:GOSUB 1000
170 REM NOTE OFF FOR ALL 4 CHANNELS
180 FOR I = 1 TO 4000:NEXT
190 POKE $9FE0, $08 : POKE $9FE1, $00
@Frank-Buss
Frank-Buss / stardust.c
Created September 26, 2019 05:16
Commander X16 YM2151 player
// ym2151 basic player by Barry Yost - sep 25, 2019
// original original tune "Stardust" from C64 game "Lazy Jones"
// ported to C by Frank Buss
#include <stdint.h>
#include <6502.h>
struct YM2151_t {
uint8_t reg;
uint8_t data;
@Frank-Buss
Frank-Buss / snake.lua
Created September 26, 2019 11:13
Lua Player snake game
--[[
Snake, Copyright (c) 2005 Frank Buss <fb@frank-buss.de> (aka Shine)
artworks by Gundrosen
coding by Shine
background music: "Stranglehold", composed by Jeroen Tel, (C) 1995 Maniacs of Noise
]]
-- default options
options = { speed = 2, level = "desert", music = "on", sound = "on" }
@Frank-Buss
Frank-Buss / logging.py
Created October 5, 2019 03:46
GPIB voltage logging with a Fluke 8842A
#!/usr/bin/python
# reads a voltage each 10 seconds and prints it
# sample output:
#
# instrument FLUKE,8842A,0,V3.0
# start Sat Oct 5 05:36:48 2019
#
# time voltage
# 0 4.191300
@Frank-Buss
Frank-Buss / dmp2c.py
Last active October 25, 2019 11:43
converts a DefleMask DMP instrument file to a C array or binary file
#!/usr/bin/env python3
# Copyright (c) 2019, Frank Buss
# All rights reserved.
# based on a PHP script by Barry Yost
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
@Frank-Buss
Frank-Buss / gameoflife.s
Created November 23, 2019 03:31
Game of Life implementation for Commander X16
; Game of Life implementation for Commander X16
; Copyright 2019 by Frank Buss
;
; compile with CC65 like this:
; cl65 --cpu 65c02 -t none -o gameoflife.prg gameoflife.s
VERA_ADDR_LO = $9f20
VERA_ADDR_MID = $9f21
VERA_ADDR_HI = $9f22
VERA_DATA0 = $9f23
@Frank-Buss
Frank-Buss / counter.diff
Created November 25, 2019 23:33
cycle counter hack for X16 emulator
diff --git a/cpu/instructions.h b/cpu/instructions.h
index 09757cc..38dd1f1 100644
--- a/cpu/instructions.h
+++ b/cpu/instructions.h
@@ -505,3 +505,14 @@ static void tya() {
zerocalc(a);
signcalc(a);
}
+
+#include <inttypes.h>