Skip to content

Commit

Permalink
notes are now printed on screen, z now clears the screen, added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
spagootie committed Jul 2, 2020
1 parent d96e23e commit 92474b0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
59 changes: 39 additions & 20 deletions pcano.asm
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
mov ah, 00h ; clears the screen and makes the cursor invisible
mov al, 03h
int 10h
mov ah, 01h
mov cx, 2607h
int 10h
mov ah, 02h
mov dl, 0
int 10h
clear:
mov ah, 00h ; clears the screen and sets the cursor to the first position on the screen
mov al, 03h
int 10h
mov ah, 02h
mov dl, 0
int 10h

input: ; takes user input
in al, 60h
cmp al, 44
je clear
cmp al, 18
je lower
cmp al, 16
Expand All @@ -34,74 +34,93 @@ input: ; takes user input
je setcolon
jmp stopnote

lower:

lower: ; lower the note later
mov cl, 1
jmp input

middle:
middle: ; set note to normal pitch
mov cl, 0
jmp input

upper:
upper: ; raise the note later
mov cl, 2
jmp input

seta:
mov bx, 4560
mov al, 'C'
jmp playnote

sets:
mov bx, 4063
mov al, 'D'
jmp playnote

setd:
mov bx, 3619
mov al, 'E'
jmp playnote

setf:
mov bx, 3416
mov al, 'F'
jmp playnote

setj:
mov bx, 3043
mov al, 'G'
jmp playnote

setk:
mov bx, 2711
mov al, 'A'
jmp playnote

setl:
mov bx, 2415
mov al, 'B'
jmp playnote

setcolon:
mov bx, 2280
mov al, 'C'
jmp playnote

octlow:
octhigh: ; raises the note by an octave
xor dl, dl
mov ax, bx
mov bx, 2
div bx
mov bx, ax
mov al, '5'
jmp portnote

octhigh:
octlow: ; lowers the note by an octave
mov ax, 2
mul bx
mov bx, ax
mov al, '3'
jmp portnote
playnote:
mov al, 182 ; playing sounds n stuff
mov ah, 0x0e ; prints the char in al
int 10h

mov al, 182
out 43h, al
cmp cl, 2
je octhigh
cmp cl, 1
cmp cl, 2 ; if certain keys were pressed, changes the pitch of the note
je octlow
cmp cl, 1
je octhigh
mov al, '4'
portnote:
mov ax, bx
mov ah, 0x0e ; prints the octave number
int 10h

mov ax, bx ; plays the note
out 42h, al
mov al, ah
out 42h, al
Expand All @@ -117,7 +136,7 @@ waitforrelease:
jne stopnote
jmp waitforrelease

stopnote:
stopnote: ; turns off the speaker
in al, 61h
and al, 11111100b
out 61h, al
Expand Down
Binary file modified pcano.img
Binary file not shown.

0 comments on commit 92474b0

Please sign in to comment.