You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于BIOS的自研OS选择页:VGA光标隐藏的其他实现方法问询

Hiding the VGA Cursor via BIOS: Alternatives to Off-Screen Placement

Great question! When building a selection screen for a custom OS, polishing the visual experience by hiding that blinking VGA cursor is a nice touch—and there are reliable BIOS-based methods beyond just moving it outside the screen bounds. Here are the most practical ones:

1. Set Cursor Type to Invisible via INT 0x10, AH=0x01

The VGA BIOS provides a dedicated function to control the cursor's shape. By setting the cursor's start scan line to a value greater than or equal to its end scan line, the BIOS will render the cursor completely invisible. This is the standard, widely compatible approach.

For VGA text modes (common for boot-time selection screens), the cursor typically spans 8 scan lines (0 to 7). To hide it, just set the start line higher than the end line. Here's how to implement this in x86 assembly:

; Optional: Save current cursor state if you need to restore it later
mov ah, 0x01
int 0x10
push cx          ; CH=start line, CL=end line saved to stack

; Hide the cursor
mov ah, 0x01
mov ch, 0x10     ; Start line (0x10 is well above the max 0x07 for 8-line cursors)
mov cl, 0x00     ; End line (irrelevant since start > end)
int 0x10

; To restore the cursor later:
; pop cx
; mov ah, 0x01
; int 0x10

This method is more reliable than moving the cursor off-screen because some BIOS implementations or video operations (like scrolling text) might reset the cursor position back to a visible area. Setting the cursor type to invisible maintains the hidden state more consistently.

2. Mode-Specific BIOS Cursor Toggles (Less Universal)

A small number of older BIOSes or specialized VGA adapters support additional cursor control functions via INT 0x10. For example, some systems recognize AH=0x12 with BL=0x30 to toggle cursor visibility, but this is not standardized across all hardware. Stick with the first method for broad compatibility.

Key Notes

  • Test across emulators (QEMU, Bochs) and real hardware if possible—BIOS implementations can vary.
  • If you switch video modes later in the boot process, the BIOS will likely reset the cursor state, so you'll need to re-apply the invisible setting.
  • Always save the original cursor shape parameters if you plan to restore the cursor later.

内容的提问来源于stack exchange,提问作者Nafe Bon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 07:42:27