Skip to content

Instantly share code, notes, and snippets.

View lhz's full-sized avatar

Lars Haugseth lhz

View GitHub Profile
#!/bin/sh
# Reload program and label definitions into a running x64sc session
# Send command to emulator's remote monitor
send () {
echo "$1" | nc -N localhost 6510 >/dev/null
}
# Verify command line parameters
@lhz
lhz / sort_null_last.py
Last active October 23, 2020 04:05
Sort list of strings containing Null values with Nulls at the end
#!/usr/bin/env python3
from locale import strcoll
from functools import cmp_to_key
def null_last_cmp(a, b):
"""Comparison function that rates non-Null values lower than Null"""
if a is None:
return 0 if b is None else 1
@lhz
lhz / tiny_sids.txt
Last active November 19, 2019 14:28
../HVSC-71 $ find -name "*.sid" -size -1024c | xargs du -b | grep -v BASIC | sort
160 MUSICIANS/0-9/4-Mat/Glitchshifter.sid
249 MUSICIANS/G/Galleon/Science_451_Intro.sid
251 DEMOS/A-F/A_Riddle_1K_Intro.sid
252 MUSICIANS/B/BOGG/A_Message.sid
273 GAMES/A-F/Defenseur.sid
288 GAMES/A-F/Chomper_Man.sid
291 GAMES/S-Z/Spelloon.sid
293 GAMES/M-R/Rodney_to_the_Rescue.sid
SINE_GEN_LENGTH = 256
SineGenerate:
lea SineGenTable + 8, a0
move.l #$7FFF6216, d6 ; 2*cos(π/512) >> 2
move.l #SINE_GEN_LENGTH - 3, d7
.Loop: move.l -4(a0), d0 ; A = sin(i)
move.l d6, d1 ; B = 2*cos(π/512) >> 2
@lhz
lhz / sine_gen.s
Last active March 26, 2018 10:04
Sine generator
SineGenerate:
lea Sine + 8, a0
move.l #$7FFF6216, d6 ; 2*cos(π/512) >> 2
move.l #253, d7
.Loop:
move.l -4(a0), d0 ; A = sin(i)
move.l d6, d1 ; B = 2*cos(π/512) >> 2
move.l d0, d2
move.l d1, d3
; a0: Source 8-bit chunky data
; a1: Target bitplane memory
; d0: Bitplane height (or 1 for non-interleaved)
; d1: Bitplane width (or size for non-interleaved) in bytes
ChunkyToPlanar5:
move.l a1, a2
add.l d1, a2
move.l a2, a3
@lhz
lhz / chequer.s
Last active October 1, 2015 13:52
Fill screen at $0400 with chequer pattern.
;; Self-modifying code ($18 bytes in ZP, $1A bytes elsewhere)
a: lda #$20
ldy #$18
a_row: ldx #$28
a_col: sta $03E8,y
eor #$80
dex
bmi a_row
iny
@lhz
lhz / aid.yml
Created February 24, 2015 08:47
# ~/.tmuxinator/aid.yml
name: aid
root: ~/src/amedia/aid
# Optional tmux socket
# socket_name: foo
# Runs before everything. Use it to start daemons etc.
pre:
@lhz
lhz / app.rb
Last active August 29, 2015 14:06
Timestamped rack.errors log
class App < Sinatra::Base
error_log = File.new('log/rack_errors.log', 'a+')
error_log.sync = true
def error_log.puts(*messages)
messages.first.prepend "[#{Time.now.strftime '%F %X.%6N'}] "
super
end
@lhz
lhz / stars.s
Last active August 29, 2015 14:01
;-------------------------------------------------------------------------
; StarField Example 13.01.94
;-------------------------------------------------------------------------
; Programming by Lars Haugseth (Perplex)
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
; CONSTANTS
;-------------------------------------------------------------------------