Skip to content

Instantly share code, notes, and snippets.

View lhz's full-sized avatar

Lars Haugseth lhz

View GitHub Profile
[1] pry(main)> !(1..2)
=> false
[2] pry(main)> not((1..2))
=> false
[3] pry(main)> not(1..2)
(pry):3: warning: integer literal in conditional range
(pry):3: warning: integer literal in conditional range
=> true
@lhz
lhz / gist:5748054
Last active December 18, 2015 07:39
#!/usr/bin/env ruby
require 'bundler/setup'
require 'c64'
require 'c64/prototype'
class BallTest < C64::Prototype
border :black
screen :white
@lhz
lhz / stars.s
Last active August 29, 2015 14:01
;-------------------------------------------------------------------------
; StarField Example 13.01.94
;-------------------------------------------------------------------------
; Programming by Lars Haugseth (Perplex)
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
; CONSTANTS
;-------------------------------------------------------------------------
@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 / 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 / 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
; 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 / 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
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 / 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