1; Example of using playroutine 1 (standard) 2; 3; playeraddress+0 = init music (A = tunenumber starting from 0) 4; playeraddress+3 = play music 5; 6; Remember that this player uses 2 zeropage locations, so save those 7; locations before calling the player, if you need all of the ZP. 8; The player doesn't depend on their contents between calls at all! 9 10 11 processor 6502 12 org 2048 13 14getin = $ffe4 15 16start: jsr initraster 17 lda #22 18 sta $d018 19 lda #$00 20 jsr $1000 ;Initialize subtune 0 21 ldx #$00 22 lda #$20 23clearscreen: sta $0400,x 24 sta $0500,x 25 sta $0600,x 26 sta $0700,x 27 inx 28 bne clearscreen 29textloop: lda text,x 30 jsr convertascii 31 sta $0400,x 32 lda #$01 33 sta $d800,x 34 inx 35 cpx #5*40 36 bcc textloop 37 ldx #$00 38authorloop: lda $1020,x 39 jsr convertascii 40 sta $0458,x 41 inx 42 cpx #32 43 bne authorloop 44idle: lda currraster 45 ldx #52 46 jsr printhex 47 lda maxraster 48 ldx #55 49 jsr printhex 50 jmp idle 51 52printhex: pha 53 lsr 54 lsr 55 lsr 56 lsr 57 tay 58 lda hexnybble,y 59 jsr convertascii 60 sta $0400,x 61 pla 62 and #$0f 63 tay 64 lda hexnybble,y 65 jsr convertascii 66 sta $0401,x 67 rts 68 69convertascii: cmp #$60 70 bcc ca_ok 71 sbc #$60 72ca_ok: rts 73 74initraster: sei 75 lda #<raster 76 sta $0314 77 lda #>raster 78 sta $0315 79 lda #50 ;Set low bits of raster 80 sta $d012 ;position 81 lda $d011 82 and #$7f ;Set high bit of raster 83 sta $d011 ;position (0) 84 lda #$7f ;Set timer interrupt off 85 sta $dc0d 86 lda #$01 ;Set raster interrupt on 87 sta $d01a 88 lda $dc0d ;Acknowledge timer interrupt 89 cli 90irwait: lda maxraster 91 beq irwait 92 lda #$00 93 sta maxraster 94 rts 95 96raster: nop 97 nop 98 nop 99 nop 100 nop 101 lda $d012 102 sta raster_cmp+1 103 inc $d020 104 jsr $1003 ;Play music and measure 105 lda $d012 ;rastertime it took 106 dec $d020 107 sec 108raster_cmp: sbc #$00 109 sta currraster 110 cmp maxraster 111 bcc raster_skip 112 sta maxraster 113raster_skip: dec $d019 114 jmp $ea31 115 116text: dc.b "Example 1: Standard musicroutine " 117 dc.b "Rastertime: / " 118 dc.b "Author: " 119 dc.b " " 120 dc.b " " 121 122anaal: pha 123 pla 124 pha 125 pla 126 rts 127 128hexnybble: dc.b "0123456789ABCDEF" 129 130maxraster: dc.b 0 131currraster: dc.b 0 132 133 org $1000 134 135 incbin example1.bin 136 137