Skip to content

Instantly share code, notes, and snippets.

raxoft / mouse.asm
Last active March 4, 2020 22:20
Kempston mouse driver for ZX Spectrum.
View mouse.asm
; Kempston mouse driver with master/slave support.
; Written by Patrik Rak in 2013, and revised in 2016.
; Based on a driver originally written for testing ZXDS, see the original WoS post
; in the thread at
ld hl,ports
ld de,mouseinput
ld c,0xDF
.loop ld b,(hl)
raxoft / sudoku.rb
Last active June 14, 2022 13:56
Fast and compact Sudoku solver. I wrote it after seeing the example in "The Ruby Programming Book" to find out how much simpler and cleaner it could be made. I have improved it sligthly later and added a generator just for fun.
View sudoku.rb
# Compact Sudoku solver and generator
# Written by Patrik Rak in 2009 to test the power of Ruby
class Sudoku
# Dimensions.
B = 3
N = B * B
SIZE = N * N
raxoft / z80d.cpp
Created May 27, 2015 15:53
Disassembler of the Z80 instruction set. I wrote it for ZXDS, but made it public later after I have found that none of the publicly available code really reaches the bar, especially as far as the IX/IY instructions are concerned.
View z80d.cpp
// Z80 disassembler.
// Written by Patrik Rak for ZXDS in 2010, released under MIT license in 2011.
// There are two main entry points, one for doing the full blown disassembly,
// the other one for just measuring how many bytes given opcode sequence takes.
// The full details are below:
// const char *
raxoft / money.rb
Last active August 29, 2015 14:21
Simple Money helper. Showcases how to integrate custom types into Ruby, coerce them into other types and define binary operators properly. Example of an extensive unit test is included as well.
View money.rb
# Simple Money helper.
# Written by Patrik Rak in 2014.
# Money class for convenient working with amounts internally stored in cents.
class Money
# Helper class for handling left hand side arguments of binary operators.
class Scalar
include Comparable
raxoft / cmwc.asm
Last active August 2, 2022 14:29
Fast quality CMWC random number generator for Z80 I have created to weed out the crap RNGs out there. 32+10 bytes, 146..149 T cycles, period 253*2^59, which is more than 2^66 or 10^20.
View cmwc.asm
; 8-bit Complementary-Multiply-With-Carry (CMWC) random number generator.
; Created by Patrik Rak in 2012, and revised in 2014/2015,
; with optimization contribution from Einar Saukas and Alan Albrecht.
; See
org 40000
call rnd ; BASIC driver
ld c,a
ld b,0
raxoft / xorshift.asm
Created May 22, 2015 07:36
Fast quality Xor-Shift random number generator for Z80 I have created to weed out the crap RNGs out there. 28 bytes, 122 T cycles, period 2^32-1.
View xorshift.asm
; 8-bit Xor-Shift random number generator.
; Created by Patrik Rak in 2008 and revised in 2011/2012.
; See
org 40000
call rnd ; BASIC driver
ld c,a
ld b,0
raxoft / mufs_password_decoder.rb
Last active January 1, 2022 11:55
This is the decoder of the password format used by the Amiga MultiUser filesytem. I wrote it the other day when I needed to login to an old A4000 whose root password I forgot. Note that some letters in the passwords are ambiguous due to modulo 53 being used, so 'A' and 'v' are the same, as is '0' and 'e' or space and 'U', so take your pick from …
View mufs_password_decoder.rb
# Decoder for passwords created by multiuser.library of Amiga MultiUser muFS filesystem (ACrypt() encoded, AKA AS225r2 format).
# Copyright (C) 2015 Patrik Rak (
# This source code is released under the MIT license.
def decode( password, user, base = 'A' )
r = 53
s ={ |x| x - 'A'.ord } + [ 0 ] * 12