summaryrefslogtreecommitdiff
path: root/boot1/video.asm
diff options
context:
space:
mode:
Diffstat (limited to 'boot1/video.asm')
-rw-r--r--boot1/video.asm81
1 files changed, 81 insertions, 0 deletions
diff --git a/boot1/video.asm b/boot1/video.asm
new file mode 100644
index 0000000..61ff153
--- /dev/null
+++ b/boot1/video.asm
@@ -0,0 +1,81 @@
+;;; Display the ASCIIZ string at ds:si via BIOS VIDEO call (real mode only)
+Write:
+ lodsb ; load char to al, increment si
+ or al, al ; see if it's null
+ jz .DONE ; if so, we're finished
+ mov ah, 0x0E ; service 0x0E: output one char
+ mov bh, 0x00 ; display page 0
+ mov bl, 0x07 ; char text attrib (white on black)
+ int 0x10 ; invoke bios
+ jmp Write ; next char
+.DONE:
+ ret
+
+;;; Probe the video system of the machine via BIOS VIDEO calls, populate
+;;; the HARDWARE_INFO buffer (real mode only).
+PROBE_VIDEO:
+ ;; identify the display type
+ call DISP_ID
+ mov [bDisplayType], al
+
+ ;; determine the font size
+ call FONT_SIZE
+ mov [bFontSize], al
+ ret
+
+;;; Determine the font size (width in pixels) of the current display.
+FONT_SIZE:
+ cmp al, 0x0a
+ jl .TRY_OLD
+ mov al, BYTE 16
+ ret
+.TRY_OLD:
+ cmp al, BYTE 1
+ jne .TRY_CGA
+ mov al, BYTE 14
+ ret
+.TRY_CGA:
+ cmp al, BYTE 2
+ jne .TRY_VGA
+ mov al, BYTE 8
+ ret
+.TRY_VGA:
+ mov ah, 0x11
+ mov al, 0x30
+ mov bh, 0
+ int 0x10
+ mov al, cl
+ ret
+
+;;; Determine the video type via BIOS VIDEO call
+DISP_ID:
+ xor ax, ax
+ mov ah, 0x1a
+ int 0x10
+ cmp al, 0x1a
+ jne .TRY_EGA
+ mov al, bl
+ ret
+.TRY_EGA:
+ mov ah, 0x12
+ mov bx, 0x10
+ int 0x10
+ cmp bx, 0x10
+ je .OLD_BOARDS
+ cmp bh, 0
+ je .EGA_COLOR
+ mov al, 5
+ ret
+.EGA_COLOR:
+ mov al, 4
+ ret
+.OLD_BOARDS:
+ int 0x11
+ and al, 0x30
+ cmp al, 0x30
+ jne .CGA
+ mov al, 1
+ ret
+.CGA:
+ mov al, 2
+ ret