Skip to content

Instantly share code, notes, and snippets.

Patrik Rak raxoft

View GitHub Profile
@raxoft
raxoft / mouse.asm
Last active Mar 4, 2020
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 http://www.worldofspectrum.org/forums/discussion/43026/mouse-systems-for-zx-spectrum
updatemouse
ld hl,ports
ld de,mouseinput
ld c,0xDF
.loop ld b,(hl)
@raxoft
raxoft / sudoku.rb
Last active Aug 29, 2015
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
raxoft / z80d.cpp
Created May 27, 2015
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
raxoft / money.rb
Last active Aug 29, 2015
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
raxoft / cmwc.asm
Last active Mar 4, 2020
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 http://www.worldofspectrum.org/forums/showthread.php?t=39632
org 40000
call rnd ; BASIC driver
ld c,a
ld b,0
@raxoft
raxoft / xorshift.asm
Created May 22, 2015
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 http://www.worldofspectrum.org/forums/showthread.php?t=23070
org 40000
call rnd ; BASIC driver
ld c,a
ld b,0
ret
@raxoft
raxoft / mufs_password_decoder.rb
Last active Aug 29, 2015
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 (patrik@raxoft.cz)
# This source code is released under the MIT license.
def decode( password, user, base = 'A' )
r = 53
s = password.bytes.map{ |x| x - 'A'.ord } + [ 0 ] * 12
You can’t perform that action at this time.