123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- ; playmusic
- ; parameters:
- ; hl = list of notes to play
- ; destroys: a,bc,hl
- ; preserves: de,ix
- spt_playmusic:
- pop hl
- ; fall through to playmusic
- playmusic: ;music routine
- .getnote:
- ld c,(hl)
- ld a,c
- or a
- jr z,.end ; zero duration: we are done
- inc hl
- ld a,(hl)
- or a
- jr z,.rest ; zero frequency: rest
- .cycle: ; tone cycle. First low part of square wave
- ld b,(hl)
- out (0d4h),a
- .loophalf:
- nop12
- nop12
- nop12
- djnz .loophalf
- bit 1,a
- jr nz,.cycle
- dec c
- jr nz,.cycle
- ; ld b,80
- ; .between_inner: ; delay between notes
- ; nop12
- ; djnz .between_inner
- jr .nextnote
- .rest:
- ld b,0
- .restloop:
- nop12
- nop12
- djnz .restloop
- dec c
- jr nz,.rest
- .nextnote:
- ld a,(hl)
- inc hl
- jr .getnote
- .end:
- ld a,080h
- out (0d4h),a
- ret
- tones_welcome:
- db $60,$40
- db $00,$00 ;end
- tones_vram: db $10,$81 ;each note is first byte duration
- db $10,$80 ;then next byte frequency -- the higher the second byte, the lower the frequency
- db $10,$81
- db $10,$80
- db $10,$81
- db $10,$80
- db $10,$81
- db $10,$80
- ; db $40,$00 ;rest
- db $00,$00 ;end
- ; tones_vram: db $30,$60
- ; db $10,$90 ;each note is first byte duration
- ; db $20,$40 ;then next byte frequency -- the higher the second byte, the lower the frequency
- ; db $10,$90
- ; db $20,$40
- ; db $30,$60
- ; ; db $30,$50
- ; ; db $f0,$c0
- ; db $60,$00 ;rest
- ; db $00,$00 ;end
- ; tones_sad: db $30,$50 ;each note is first byte duration
- ; db $30,$60 ;then next byte frequency -- the higher the second byte, the lower the frequency
- ; db $30,$70
- ; db $30,$80
- ; db $30,$90
- ; db $30,$a0
- ; db $30,$b0
- ; db $f0,$c0
- ; db $00,$00 ;end
- tones_vramgood: db $03,$c0 ;each note is first byte duration
- db $03,$b0 ;then next byte frequency -- the higher the second byte, the lower the frequency
- db $04,$a0
- db $04,$90
- db $04,$80
- db $05,$70
- db $05,$60
- db $40,$50
- ; db $40,$00 ;rest
- db $00,$00 ;end
- tones_bitgood: db $40,$30
- db $20,$00 ;rest
- db $00,$00 ;end
- tones_bitbad: db $10,$C0
- db $20,$00 ;rest
- db $00,$00 ;end
- tones_bytegood: db $FF,$30
- db $00,$00 ;end
- tones_bytebad: db $44,$C0
- db $80,$00 ;rest
- db $00,$00 ;end
|