* remove "\r" nonsense
[mascara-docs.git] / amd64 / bareMetalOS-0.5.2 / baremetal0.5.2 / programs / keyboard.asm
blob8480d99ef2d0694d17544be5f3b97069fd040cc4
1 ; -----------------------------------------------------------------
2 ; Music keyboard
3 ; Based on keyboard.asm from MikeOS
4 ; Use Z key rightwards for an octave
5 ; -----------------------------------------------------------------
8 [BITS 64]
9 [ORG 0x0000000000200000]
11 %INCLUDE "bmdev.asm"
13 music_keyboard:
15 mov rsi, startstring
16 call b_print_string
17 call b_print_newline
19 .retry:
20 call b_input_key_wait
22 ; And start matching keys with notes
24 cmp al, 'z'
25 jne .x
26 mov al, 'C'
27 call b_print_char ; Print note
28 mov ax, 4000
29 jmp .playnote
31 .x:
32 cmp al, 'x'
33 jne .c
34 mov al, 'D'
35 call b_print_char ; Print note
36 mov ax, 3600
37 jmp .playnote
39 .c:
40 cmp al, 'c'
41 jne .v
42 mov al, 'E'
43 call b_print_char ; Print note
44 mov ax, 3200
45 jmp .playnote
47 .v:
48 cmp al, 'v'
49 jne .b
50 mov al, 'F'
51 call b_print_char ; Print note
52 mov ax, 3000
53 jmp .playnote
55 .b:
56 cmp al, 'b'
57 jne .n
58 mov al, 'G'
59 call b_print_char ; Print note
60 mov ax, 2700
61 jmp .playnote
63 .n:
64 cmp al, 'n'
65 jne .m
66 mov al, 'A'
67 call b_print_char ; Print note
68 mov ax, 2400
69 jmp .playnote
71 .m:
72 cmp al, 'm'
73 jne .comma
74 mov al, 'B'
75 call b_print_char
76 mov ax, 2100
77 jmp .playnote
79 .comma:
80 cmp al, ','
81 jne .space
82 mov al, 'C'
83 call b_print_char
84 mov ax, 2000
85 jmp .playnote
87 .space:
88 cmp al, ' '
89 jne .q
90 call b_speaker_off
91 jmp .retry
93 .playnote:
94 call b_speaker_tone
95 jmp .retry
97 .q:
98 cmp al, 'q'
99 je .end
100 cmp al, 'Q'
101 je .end
102 jmp .retry ; Didn't get any key we were expecting so try again.
104 .end:
105 call b_speaker_off
106 call b_print_newline
107 ret ; Back to OS
109 ; -----------------------------------------------------------------
111 startstring: db 'Musical keyboard. Use "Z"-"," to play notes. Space to stop the note. Q to quit.', 0