Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Simple piano keyboard. (c)2022 Miguel A. Rodriguez Jodar. mcleod_ideafix
- org 40000
- di
- ld bc,00feh
- WaitKeyPress in a,(c)
- cpl
- and 1fh
- jp z,WaitKeyPress
- ld b,0fbh ;Q-T
- in a,(c)
- cpl
- and 1fh
- jp z,NotQT
- ld hl,ToneTableQT
- SeekToneParQT bit 0,a
- jp nz,ToneFound
- inc hl
- inc hl
- sra a
- jp SeekToneParQT
- NotQT ld b,0dfh ;Y-P
- in a,(c)
- cpl
- and 1fh
- jp z,NotYP
- ld hl,ToneTableYP
- SeekToneParYP bit 4,a
- jp nz,ToneFound
- inc hl
- inc hl
- sla a
- jp SeekToneParYP
- NotYP jp WaitKeyPress
- ToneFound ld e,(hl)
- inc hl
- ld d,(hl)
- ld b,0
- ld a,(23624)
- sra a
- sra a
- sra a
- and 7
- DoHalfPeriod ld h,d
- ld l,e
- xor 10h
- out (c),a
- WaitHalfPeriod dec hl ;6T
- dec h ;4T
- inc h ;4T
- jp p,WaitHalfPeriod ;10T Total: 24T -> 6.85714286 us per HL count
- ld l,a
- in a,(c)
- cpl
- and 1fh
- jp z,WaitKeyPress
- ld a,l
- jp DoHalfPeriod
- ToneTableQT dw 557 ; Key Q. C0 (semitone 0) . Value is 145833.33333333 / (261.63*2^(semitone/12)).
- dw 496 ; Key W. D0 (semitone 2)
- dw 442 ; Key E. E0 (semitone 4)
- dw 418 ; Key R. F0 (semitone 5)
- dw 372 ; Key T. G0 (semitone 7)
- ToneTableYP dw 331 ; Key Y. A0 (semitone 9)
- dw 295 ; Key U. B0 (semitone 11)
- dw 279 ; Key I. C1 (semitone 12)
- dw 248 ; Key O. D1 (semitone 14)
- dw 221 ; Key P. E1 (semitone 16)
- end 40000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement