1 ;; Jeremy English Dec 11 2007 2 ;; Random walk 3 lda #16 4 sta $0 ; The current x pos 5 sta $1 ; The current y pos 6 lda $fe ; Get random color 7 sta $5 ; Store the color 8 lda $fe ; Amount of time to use this color 9 sta $6 10 11loop: 12 ldx $0 13 ldy $1 14 lda $5 15 jsr paint 16 jsr walk 17 dec $6 18 bne loop 19 ;; get a new color 20 lda $fe 21 sta $5 22 ;; get a new duration 23 lda $fe 24 sta $6 25 jmp loop 26 27walk: 28 lda $fe 29 and #3 30 cmp #0 31 beq right 32 cmp #1 33 beq left 34 cmp #2 35 beq up 36 jmp down 37 38right: 39 inc $0 40 jmp done 41left: 42 dec $0 43 jmp done 44up: 45 dec $1 46 jmp done 47down: 48 inc $1 49 jmp done 50done: 51 lda $0 52 and #31 53 sta $0 54 lda $1 55 and #31 56 sta $1 57 rts 58 59paint: 60 pha 61 lda yl,y 62 sta $2 63 lda yh,y 64 sta $3 65 txa 66 tay 67 pla 68 sta ($2),y 69 rts 70 71 ;; Y cord MSB 72yh: 73 dcb $02, $02, $02, $02, $02, $02, $02, $02 74 dcb $03, $03, $03, $03, $03, $03, $03, $03 75 dcb $04, $04, $04, $04, $04, $04, $04, $04 76 dcb $05, $05, $05, $05, $05, $05, $05, $05 77 ;; Y cord LSB 78yl: 79 dcb $00, $20, $40, $60, $80, $a0, $c0, $e0 80 dcb $00, $20, $40, $60, $80, $a0, $c0, $e0 81 dcb $00, $20, $40, $60, $80, $a0, $c0, $e0 82 dcb $00, $20, $40, $60, $80, $a0, $c0, $e0 83