Skip to content

Instantly share code, notes, and snippets.

@tomaes
Created March 15, 2014 19:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaes/9572342 to your computer and use it in GitHub Desktop.
Save tomaes/9572342 to your computer and use it in GitHub Desktop.
glitchshifter by 4mat explained
; glitchshifter by 4mat explained
;
* = $7c ; starts in Zeropage. Overwrites some BASIC interpreter parts;
; faux autostart in VICE due to RUN (+return! just that would
; suffice)
SBC $a1 ; Accu minus (slowly updated) system timer byte ($A1)
SEI ; stop interrupts to halt timer temporarily and add some speed-up,
; inner loop starts
ORA $a2 ; bitwise OR'ed Accu with fresh timer data from fast sys timer ($A2)
; (but: the Accu rarely changes in this very fast inner loop)
STA $d418 ; audio output (through SID global volume, pushing 4bit samples)
INY ; count up until Y overflows
BNE $7e ; back to SEI, inner loop end point
CLI ; interrupts back on, delayed timers work again
TAY ; re-init inner loop counter
STA $d011 ; video glitchery (VIC II's raster/video controls stuffed with
; pseudo-random, but periodic Accu value; video changes happen
; far less often than audio changes)
BNE $7c ; back to the entry point, unless TAY sets Zeroflag (main loop)
; JAM opcode follows next in memory, hence code execution halts after a few minutes
; works without SEI/CLI of course, but sound gets more eratic, as timer values
; change more quickly. BNE $7e could jump to $7f just as well, as there're
; little sound changes due to SEI (= 2 more clock cycles).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment