Last active
December 10, 2023 08:38
-
-
Save moesoha/4b9e8bb8d6b29abc65b72c9ba4851d9d to your computer and use it in GitHub Desktop.
Enable/Disable hardware blinking provided by text mode on CGA/EGA/VGA cards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;; blink control ;;;;; | |
;;;;; CGA/EGA/VGA ;;;;; | |
; by Soha <[email protected]> ; | |
; with MASM, 2023/12/09 ; | |
;;;;;;;;;;;;;;;;;;;;;;;;; | |
.model small | |
.stack | |
.data | |
no_ansi_prompt db "no ANSI.SYS or equivalent detected, please load it in CONFIG.SYS", 0dh, 0ah | |
db "$" | |
help db "Turn " | |
db 1bh, "[30;5;47m", "blinking text mode", 1bh, "[m" ; 5 for showing result | |
db " on/off on CGA/EGA/VGA cards.", 0dh, 0ah | |
db "Usage: BLINK.EXE [/]<1|0>", 0dh, 0ah | |
db "Author: Soha Jin <[email protected]>", 0dh, 0ah | |
db "$" | |
log_cga db "CGA detected, $" | |
log_ega db "EGA/VGA detected, $" | |
log_ok db 1bh, "[1;37;5;41m" ; 5 for showing result | |
db " OK! " | |
db 1bh, "[m", 0dh, 0ah | |
db "$" | |
.code | |
print macro data | |
mov dx, seg data | |
mov ds, dx | |
lea dx, data | |
mov ah, 09h | |
int 21h | |
endm | |
commit: ; dl (0 = off, 1 = on) | |
mov ah, 12h | |
mov bl, 10h | |
int 10h | |
cmp bl, 4 ; BL is memory size enum, EGA/VGA should < 4 | |
mov bl, dl | |
ja commit_cga | |
jmp commit_bios | |
commit_bios: ; bl (0 = off, 1 = on), for EGA/VGA | |
print log_ega | |
mov ax, 1003h | |
xor bh, bh | |
int 10h | |
jmp committed | |
commit_cga: ; bl (0 = off, 1 = on), for CGA | |
print log_cga | |
mov ax, 40h ; BIOS | |
mov es, ax | |
mov dx, es:[63h] ; 40:0063 is the port address for 6845 chip | |
mov al, es:[65h] ; 40:0065 is the current value for MSR | |
add dx, 4 ; MSR (Mode Select Register) address | |
and al, 11011111b ; clr blink bit | |
test bl, bl | |
jz commit_cga_no_set | |
or al, 00100000b ; set blink bit | |
commit_cga_no_set: | |
out dx, al | |
mov es:[65h], al | |
committed: | |
print log_ok | |
ret | |
main proc | |
mov ax, 1a00h ; for ANSI.SYS | |
int 2fh ; MS-DOS Multiplex Interrupt | |
test al, al | |
jz no_ansi | |
xor bx, bx | |
mov bl, byte ptr ds:[80h] ; arg length | |
test bl, bl | |
jz usage | |
xor di, di | |
ckloop: mov ch, byte ptr ds:[81h+di] | |
cmp ch, 20h ; ' ' | |
je ckloop_inc | |
cmp ch, 2fh ; '/' | |
je ckloop_inc | |
sub ch, 30h | |
jmp ckloop_exit | |
ckloop_inc: inc di | |
cmp di, bx | |
jb ckloop | |
jmp usage | |
ckloop_exit: mov dl, ch | |
cmp dl, 1 | |
ja usage | |
call commit | |
jmp exit | |
no_ansi: | |
print no_ansi_prompt | |
jmp exit | |
usage: print help | |
exit: mov ax, 4c00h | |
int 21h | |
main endp | |
end main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prebuilt EXE can be found here.
BLINK 0
disables blinking, can use 16 colors on background in text modeBLINK 1
enables blinking, can use 8 colors on background in text modeTested with CGA/EGA/VGA cards on 86Box (emulator) with 8088.
Tested with CGA (HD6845) and VGA (Cirrus Logic GD5429) cards on Book8088 (a laptop with 8088 made in 2023).
Tested with VGA (Chips & Technologies F65555) card on Toshiba Satellite Pro 480 CDT (a laptop with Pentium w/ MMX 233MHz).
There are more details in my blog (Chinese only).