restore functioning code
This commit is contained in:
parent
331da168b4
commit
26c71359e9
1 changed files with 16 additions and 16 deletions
32
messages.asm
32
messages.asm
|
@ -6,7 +6,7 @@ HEIGHT equ 0x18 ; 24
|
||||||
VIDEO_MODE equ 0x3 ; 80x25 screen, text mode
|
VIDEO_MODE equ 0x3 ; 80x25 screen, text mode
|
||||||
|
|
||||||
PIT_MODECOMMAND_PORT equ 0x43 ; programmable interval timer mode/command port (used for speaker)
|
PIT_MODECOMMAND_PORT equ 0x43 ; programmable interval timer mode/command port (used for speaker)
|
||||||
PIT_CH2_DATA_PORT equ 0x42 ; PIT channel 2 data port
|
PIT_CH2_DATA_PORT equ 0x42 ; PIT channel 2 data port
|
||||||
|
|
||||||
;; see http://www.ctyme.com/intr/int-10.htm for interrupts
|
;; see http://www.ctyme.com/intr/int-10.htm for interrupts
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ mov sp, 0x2000 ; initialise stack pointer
|
||||||
;; 1 1 8
|
;; 1 1 8
|
||||||
|
|
||||||
;; initialise serial port
|
;; initialise serial port
|
||||||
mov ah, 0x0 ; initialise UART
|
mov ah, 0x0 ; initialise UART
|
||||||
mov al, 0b111_00_0_11 ; baud 9600, no parity, 1 stop bit, 8 data bits
|
mov al, 0b111_00_0_11 ; baud 9600, no parity, 1 stop bit, 8 data bits
|
||||||
mov dx, 0x0 ; COM1
|
mov dx, 0x0 ; COM1
|
||||||
int 0x14
|
int 0x14
|
||||||
|
|
||||||
;; Use color mode
|
;; Use color mode
|
||||||
|
@ -119,7 +119,7 @@ int 0x10
|
||||||
;; - ax
|
;; - ax
|
||||||
;; - bl
|
;; - bl
|
||||||
change_color_mode:
|
change_color_mode:
|
||||||
call readbyte ; get byte from keyboard (in al)
|
call readbyte ; get byte from keyboard (in al)
|
||||||
mov [color_mode], al ; store byte in color_mode variable
|
mov [color_mode], al ; store byte in color_mode variable
|
||||||
|
|
||||||
jmp compare_virtual_and_jump
|
jmp compare_virtual_and_jump
|
||||||
|
@ -159,7 +159,7 @@ newline:
|
||||||
beep:
|
beep:
|
||||||
call read_duration ; get duration from keyboard (in al)
|
call read_duration ; get duration from keyboard (in al)
|
||||||
mov ah, 0
|
mov ah, 0
|
||||||
push ax ; store on stack
|
push ax ; store on stack
|
||||||
|
|
||||||
;; move 182 (0b10 11 011 0) into al
|
;; move 182 (0b10 11 011 0) into al
|
||||||
;; bit 7-6 = channel select (2, PC speaker)
|
;; bit 7-6 = channel select (2, PC speaker)
|
||||||
|
@ -175,15 +175,15 @@ beep:
|
||||||
sal ax, 5 ; multiply by 32
|
sal ax, 5 ; multiply by 32
|
||||||
add ax, 1140
|
add ax, 1140
|
||||||
|
|
||||||
out PIT_CH2_DATA_PORT, al ; Output low byte.
|
out PIT_CH2_DATA_PORT, al ; Output low byte.
|
||||||
mov al, ah
|
mov al, ah
|
||||||
out PIT_CH2_DATA_PORT, al ; Output high byte
|
out PIT_CH2_DATA_PORT, al ; Output high byte
|
||||||
|
|
||||||
;; 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, 0x61 ; 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 0x61, 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.
|
||||||
|
|
||||||
|
@ -199,13 +199,13 @@ beep:
|
||||||
.pause1:
|
.pause1:
|
||||||
mov ecx, 65535
|
mov ecx, 65535
|
||||||
.pause2:
|
.pause2:
|
||||||
dec cx ; count down
|
dec cx ; count down
|
||||||
jne .pause2 ; if not zero keep counting down
|
jne .pause2 ; if not zero keep counting down
|
||||||
|
|
||||||
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, 0x61 ; 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 0x61, al ; Send new value
|
out 0x61, al ; Send new value
|
||||||
|
|
||||||
|
@ -220,10 +220,10 @@ beep:
|
||||||
;; - dx
|
;; - dx
|
||||||
nonewline:
|
nonewline:
|
||||||
;; Write character
|
;; Write character
|
||||||
mov ah, 0x09 ; write character with attribute
|
mov ah, 0x09 ; write character with attribute
|
||||||
mov bh, 0x00 ; page number
|
mov bh, 0x00 ; page number
|
||||||
mov bl, [color_mode] ; BIOS colour code
|
mov bl, [color_mode] ; BIOS colour code
|
||||||
mov cx, 0x01 ; amount of times to print character
|
mov cx, 0x01 ; amount of times to print character
|
||||||
int 0x10
|
int 0x10
|
||||||
|
|
||||||
;; Get current cursor position
|
;; Get current cursor position
|
||||||
|
@ -277,7 +277,7 @@ readbyte:
|
||||||
int 0x16
|
int 0x16
|
||||||
|
|
||||||
;; 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, 0x04 ; First character is upper 4 bits
|
shl bl, 0x04 ; First character is upper 4 bits
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue