make hex number formats consistent
This commit is contained in:
parent
a97e70ee99
commit
03be68cfb7
1 changed files with 19 additions and 19 deletions
36
messages.asm
36
messages.asm
|
@ -43,7 +43,7 @@ int 0x14
|
||||||
|
|
||||||
;; Use color mode
|
;; Use color mode
|
||||||
mov ax, VIDEO_MODE
|
mov ax, VIDEO_MODE
|
||||||
int 10h
|
int 0x10
|
||||||
|
|
||||||
;; Clear screen
|
;; Clear screen
|
||||||
mov ah, 0x06 ; scroll screen up
|
mov ah, 0x06 ; scroll screen up
|
||||||
|
@ -63,25 +63,25 @@ int 0x10
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
;; read a character, ASCII in al
|
;; read a character, ASCII in al
|
||||||
mov ah, 0x0 ; Read character
|
mov ah, 0x00 ; Read character
|
||||||
int 0x16
|
int 0x16
|
||||||
|
|
||||||
;; a null character will be sent before every command from the virtual keyboard
|
;; a null character will be sent before every command from the virtual keyboard
|
||||||
;; so if a null is detected go to the virtual_kbd_loop instead
|
;; so if a null is detected go to the virtual_kbd_loop instead
|
||||||
cmp al, 0x0 ; null
|
cmp al, 0x00 ; null
|
||||||
je .virtual_kbd_loop_init
|
je .virtual_kbd_loop_init
|
||||||
|
|
||||||
mov ah, 0x1
|
mov ah, 0x01
|
||||||
mov dx, 0x0
|
mov dx, 0x00
|
||||||
int 0x14
|
int 0x14
|
||||||
|
|
||||||
cmp al, 0x08 ; backspace
|
cmp al, 0x08 ; backspace
|
||||||
je change_color_mode
|
je change_color_mode
|
||||||
|
|
||||||
cmp al, 0x1b ; esc
|
cmp al, 0x1B ; esc
|
||||||
je beep
|
je beep
|
||||||
|
|
||||||
cmp al, 0x0d ; enter
|
cmp al, 0x0D ; enter
|
||||||
je .nl
|
je .nl
|
||||||
|
|
||||||
jmp nonewline ; all other characters
|
jmp nonewline ; all other characters
|
||||||
|
@ -96,19 +96,19 @@ int 0x10
|
||||||
mov byte[is_from_virtual_kbd], 0x1 ; update state variable
|
mov byte[is_from_virtual_kbd], 0x1 ; update state variable
|
||||||
.virtual_kbd_loop:
|
.virtual_kbd_loop:
|
||||||
;; read a character, ASCII in al
|
;; read a character, ASCII in al
|
||||||
mov ah, 0x0
|
mov ah, 0x00
|
||||||
int 0x16
|
int 0x16
|
||||||
|
|
||||||
cmp al, 0x08 ; backspace
|
cmp al, 0x08 ; backspace
|
||||||
je change_color_mode
|
je change_color_mode
|
||||||
|
|
||||||
cmp al, 0x1b ; esc
|
cmp al, 0x1B ; esc
|
||||||
je beep
|
je beep
|
||||||
|
|
||||||
;; an enter character signifies the end of a command
|
;; an enter character signifies the end of a command
|
||||||
;; so a newline should get printed and then the program should resume
|
;; so a newline should get printed and then the program should resume
|
||||||
;; from the main .loop again
|
;; from the main .loop again
|
||||||
cmp al, 0xD ; enter
|
cmp al, 0x0D ; enter
|
||||||
je .nl_reset_state
|
je .nl_reset_state
|
||||||
|
|
||||||
jmp nonewline ; all other characters
|
jmp nonewline ; all other characters
|
||||||
|
@ -143,7 +143,7 @@ newline:
|
||||||
|
|
||||||
;; Move cursor to beginning of screen
|
;; Move cursor to beginning of screen
|
||||||
mov ah, 0x02 ; set cursors position
|
mov ah, 0x02 ; set cursors position
|
||||||
mov bh, 0x0 ; page number
|
mov bh, 0x00 ; page number
|
||||||
mov dh, HEIGHT ; row
|
mov dh, HEIGHT ; row
|
||||||
mov dl, 0x00 ; col
|
mov dl, 0x00 ; col
|
||||||
int 0x10
|
int 0x10
|
||||||
|
@ -181,9 +181,9 @@ beep:
|
||||||
|
|
||||||
;; Port 0x61 does a whole lot but only the bottom 2 bits are relevant here
|
;; Port 0x61 does a whole lot but only the bottom 2 bits are relevant here
|
||||||
;; (speaker enable and speaker input select)
|
;; (speaker enable and speaker input select)
|
||||||
in al, 61h ; Preserve previous value
|
in al, 0x61 ; Preserve previous value
|
||||||
or al, 00000011b ; Set bits 1 and 0 (enable speaker, input = channel 2)
|
or al, 00000011b ; Set bits 1 and 0 (enable speaker, input = channel 2)
|
||||||
out 61h, al ; Send new value
|
out 0x61, al ; Send new value
|
||||||
|
|
||||||
;; mov bx, 50000 ; Pause for duration of note.
|
;; mov bx, 50000 ; Pause for duration of note.
|
||||||
|
|
||||||
|
@ -205,9 +205,9 @@ beep:
|
||||||
dec bx ; decrement duration counter
|
dec bx ; decrement duration counter
|
||||||
jne .pause1 ; keep doing that until it is 0
|
jne .pause1 ; keep doing that until it is 0
|
||||||
|
|
||||||
in al, 61h ; Preserve previous value
|
in al, 0x61 ; Preserve previous value
|
||||||
and al, 11111100b ; Clear bits 1 and 0 (disable speaker, clear channel select)
|
and al, 11111100b ; Clear bits 1 and 0 (disable speaker, clear channel select)
|
||||||
out 61h, al ; Send new value
|
out 0x61, al ; Send new value
|
||||||
|
|
||||||
jmp compare_virtual_and_jump
|
jmp compare_virtual_and_jump
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ nonewline:
|
||||||
;; if it did, jump to the virtual keyboard loop
|
;; if it did, jump to the virtual keyboard loop
|
||||||
;; if it didn't, jump to the main loop
|
;; if it didn't, jump to the main loop
|
||||||
compare_virtual_and_jump:
|
compare_virtual_and_jump:
|
||||||
cmp byte[is_from_virtual_kbd], 0x1
|
cmp byte[is_from_virtual_kbd], 0x01
|
||||||
je start.virtual_kbd_loop
|
je start.virtual_kbd_loop
|
||||||
jmp start.loop
|
jmp start.loop
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ readbyte:
|
||||||
;; Read character is in al
|
;; Read character is in al
|
||||||
sub al, 'a' ; Normalise
|
sub al, 'a' ; Normalise
|
||||||
mov bl, al
|
mov bl, al
|
||||||
shl bl, 0x4 ; First character is upper 4 bits
|
shl bl, 0x04 ; First character is upper 4 bits
|
||||||
|
|
||||||
mov ah, 0x00 ; Read character
|
mov ah, 0x00 ; Read character
|
||||||
int 0x16
|
int 0x16
|
||||||
|
@ -311,7 +311,7 @@ read_duration:
|
||||||
;; Variable to store color mode information for writing to the screen
|
;; Variable to store color mode information for writing to the screen
|
||||||
color_mode: db 0x02
|
color_mode: db 0x02
|
||||||
;; State variable for detecting whether keystrokes are virtual or real
|
;; State variable for detecting whether keystrokes are virtual or real
|
||||||
is_from_virtual_kbd: db 0x0
|
is_from_virtual_kbd: db 0x00
|
||||||
|
|
||||||
;; Magic number must be in the last 2 bytes of the sector so
|
;; Magic number must be in the last 2 bytes of the sector so
|
||||||
;; fill the binary with zeroes until it is 510 bytes in size
|
;; fill the binary with zeroes until it is 510 bytes in size
|
||||||
|
|
Loading…
Reference in a new issue