pouët.net

SQUAREPUSHER

; SQUAREPUSHER
; 95 UNINTERESTING BYTES OF ALIASED RANDOMNESS FOR THE COMMODORE C=64
; CODE: WERTSTAHL / G*P (7/2012)
; INSTALLER/AUTOLOADER method borrowed from STREETUFF´s "AETHERWAVES"
; INSPIRED BY ALL THE TINY MAD GLITCHERS OUT THERE

; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
; IMPORTANT NOTE: PRESS SOME KEYS (PREFERRABLY SPACE) TO STIR THE SHIT UP OR FAST FORWARD
; THIS NEEDS SOME SECONDS TO SYNC. IT HAS NO ENDING.
; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

; SID MODEL RECOMMENDED: 8580R5 3691 + digi boost

; YES, STILL I AM HOOKED UP WITH THE COLOR RAM BUS NOISE. 
; IF THIS IS NOT PROCEDURAL ENOUGH FOR YOU, PLEASE EXPAND YOUR SHORT TERM MEMORY.

; SYNTAX: CBM PRG STUDIO 

*=$0326
            word getin
            word $f6ed
getin       rol $d018           ;flush screen
            sty $d020           ;black border    
loop        lda $02
            eor #$ff            ;alternate amplitude
            sta $02
ww0         inc $d011           ;pouet
            sta $d418           ;set amplitude
            dey                 ;wait last d012 times
            bne ww0
            iny                 ;surpress further y operation
            dec $d011           ;pouet
            dec $04             ;wait random seq byte times
            bne ww0             ;max wait time is $1ff. that * all the instructions = wavelenght
sync        cmp $d012
            bne linear          ;this makes it a bit more digital-ish
            ldx #$ee            ;loadx inc
rdout       lda $d9ab           ;loada busnoise 
choice      and #$f0            ;hi or lo state?
cswitch     bne setupd          ;<-- branch command is randomized
            ldx #$ce            ;in some cases load dec
setupd      stx upd             ;update counter advance command
            inc rdout+1         ;change bus read position
upd         dec waitinc+1       ;modify waitbyte (base freq) in an unknown way   
linear      ldx $d012           ;d012 in x
            txa
            ora #$01            ;better dont be 0
            asl                 ;shift this up
            asl                 ;
            asl                 ;
            asl                 ;
            sta cswitch         ;and write branch command 
waitinc     lda #$80            ;random waitbyte
            sta $04             ;to waitbyte container
            eor $02             ;invert (or maybe not)
            sta $d400,x         ;mess up some sound register randomly
            tax
            lda $0200,x         ;waitbyte multiplicator (sequenced by d012)     
            sta $d400,x         ;mess up some sound register randomly (doppelt haelt besser)
            lsr                 ;make sure the waiting times are 
            lsr                 ;a bit more aliased
            tay
            jmp loop

; for curious people: 
; adding one or removing one or both of the LSR´s (in line 60 and 61) will give you some nice variations
; also, moving the TAX from line 57 to line 55 (before the EOR) will change everything strongly