Skip to content

Instantly share code, notes, and snippets.

View darrylsloan's full-sized avatar

Darryl Sloan darrylsloan

View GitHub Profile
@darrylsloan
darrylsloan / knights.asm
Created April 9, 2020 08:56
Puzzle game for the Sinclair ZX Spectrum (Z80 assembly language)
; KNIGHTS by Darryl Sloan, 16 May 2018
; Enhanced version: https://spectrumcomputing.co.uk/index.php?cat=96&id=32308
ORG 43000
LASTK EQU 23560
START LD A, 0 ; border black
CALL 8859
LD A, 2 ; select upper screen
CALL 5633
@darrylsloan
darrylsloan / chess_clock.py
Created February 15, 2019 09:00
Chess clock for the BBC micro:bit, user-programmable for games of 1 to 25 mins per player.
# CHESS CLOCK by Darryl Sloan, 11 February 2019
# Press A repeatedly to choose the desired play time (1 LED = 1 min).
# Press B to start the clock.
# White player presses A after each move.
# Black player presses B after each move.
# Optional extra: if a speaker is attached, a tone sounds when time is up.
from microbit import *
import music
@darrylsloan
darrylsloan / music_sequencer.py
Last active October 14, 2020 00:56
Music sequencer for the BBC micro:bit
# MUSIC SEQUENCER by Darryl Sloan (30/11/2017)
# Step 1: press A to toggle the first note of the desired scale, then B to select.
# Step 2: press A to toggle the time signature (3/4, 4/4 or 5/4), then B to select.
# Step 3: press A to toggle the desired number of patterns (1 to 4), then B to select.
# Press A to move the range of notes selected. Press B to randomise the selected notes.
# The direction of tilt determines which scale the random notes conform to:
# Left = minor; right = major; forward = minor pentatonic; backward = major pentatonic.
# While holding A during the first note of the sequence, tilting up/down increases/decreases the tempo,
# tilting left/right selects a lower/higher octave.
@darrylsloan
darrylsloan / connect4.asm
Created July 6, 2017 14:16
Connect 4 (Z80 assembly language for the ZX Spectrum 48K)
; CONNECT 4 by Darryl Sloan, 3 July 2017
org 50000
last_k equ 23560
ld hl, udgs ; UDGs
ld (23675), hl ; set up UDG system variable
ld a, 2 ; upper screen
call 5633 ; open channel
@darrylsloan
darrylsloan / bitris.py
Last active February 14, 2019 20:12
A "Tetris"-inspired game for the BBC micro:bit (uses an 8x4 NeoPixel array, e.g. Proto-Pic's micro:pixel). Guide the falling blocks using the A & B buttons. When any 3 blocks are arranged in the shape of a letter L, they vanish. White blocks are special; they explode on impact and randomly change the colour of the block underneath.
# BITRIS - Copyright 2017 Darryl Sloan
from microbit import *
import neopixel
from random import randint
# Enable NeoPixels to use x & y values
def np_plot(x, y, r, g, b):
np[31-y-abs(x-3)*8] = (r, g, b)