📄 clext.c
字号:
retfcirrus_vesa_pmbios_entry: pushf push bp cmp ah, #0x4F jnz cirrus_vesa_pmbios_unimplemented cmp al, #0x0F ja cirrus_vesa_pmbios_unimplemented push bx xor bx, bx mov bl, al shl bx, 1 db 0x2e ;; cs: mov bp, cirrus_vesa_handlers[bx] pop bx push #cirrus_vesa_pmbios_return push bp retcirrus_vesa_pmbios_unimplemented: mov ax, #0x014Fcirrus_vesa_pmbios_return: pop bp popf retf; in si:mode tablecirrus_switch_mode: push ds push bx push dx push cs pop ds mov bx, [si+10] ;; seq mov dx, #0x3c4 mov ax, #0x1206 out dx, ax ;; Unlock cirrus special call cirrus_switch_mode_setregs mov bx, [si+12] ;; graph mov dx, #0x3ce call cirrus_switch_mode_setregs mov bx, [si+14] ;; crtc call cirrus_get_crtc call cirrus_switch_mode_setregs mov dx, #0x3c6 mov al, #0x00 out dx, al in al, dx in al, dx in al, dx in al, dx mov al, [si+8] ;; hidden dac out dx, al mov al, #0xff out dx, al mov al, #0x00 mov bl, [si+17] ;; memory model or bl, bl jz is_text_mode mov al, #0x01 cmp bl, #0x03 jnz is_text_mode or al, #0x40is_text_mode: mov bl, #0x10 call biosfn_get_single_palette_reg and bh, #0xfe or bh, al call biosfn_set_single_palette_reg pop dx pop bx pop ds retcirrus_enable_16k_granularity: push ax push dx mov dx, #0x3ce mov al, #0x0b out dx, al inc dx in al, dx or al, #0x20 ;; enable 16k out dx, al pop dx pop ax retcirrus_switch_mode_setregs:csms_1: mov ax, [bx] cmp ax, #0xffff jz csms_2 out dx, ax add bx, #0x2 jmp csms_1csms_2: retcirrus_extbios_80h: push dx call cirrus_get_crtc mov al, #0x27 out dx, al inc dx in al, dx mov bx, #_cirrus_id_tablec80h_1: db 0x2e ;; cs: mov ah, [bx] cmp ah, al jz c80h_2 cmp ah, #0xff jz c80h_2 inc bx inc bx jmp c80h_1c80h_2: db 0x2e ;; cs: mov al, 0x1[bx] pop dx mov ah, #0x00 xor bx, bx retcirrus_extbios_81h: mov ax, #0x103 ;; XXX retcirrus_extbios_82h: push dx call cirrus_get_crtc xor ax, ax mov al, #0x27 out dx, al inc dx in al, dx and al, #0x03 mov ah, #0xAF pop dx retcirrus_extbios_85h: push cx push dx mov dx, #0x3C4 mov al, #0x0f ;; get DRAM band width out dx, al inc dx in al, dx ;; al = 4 << bandwidth mov cl, al shr cl, #0x03 and cl, #0x03 cmp cl, #0x03 je c85h2 mov al, #0x04 shl al, cl jmp c85h3c85h2:;; 4MB or 2MB and al, #0x80 mov al, #0x20 ;; 2 MB je c85h3 mov al, #0x40 ;; 4 MBc85h3: pop dx pop cx retcirrus_extbios_9Ah: mov ax, #0x4060 mov cx, #0x1132 retcirrus_extbios_A0h: call cirrus_get_modeentry mov ah, #0x01 sbb ah, #0x00 mov bx, cirrus_extbios_A0h_callback mov si, #0xffff mov di, bx mov ds, bx mov es, bx retcirrus_extbios_A0h_callback: ;; fatal: not implemented yet cli hlt retfcirrus_extbios_A1h: mov bx, #0x0E00 ;; IBM 8512/8513, color retcirrus_extbios_A2h: mov al, #0x07 ;; HSync 31.5 - 64.0 kHz retcirrus_extbios_AEh: mov al, #0x01 ;; High Refresh 75Hz retcirrus_extbios_unimplemented: retcirrus_vesa_00h: push ds push si mov bp, di push es pop ds cld mov ax, [di] cmp ax, #0x4256 ;; VB jnz cv00_1 mov ax, [di+2] cmp ax, #0x3245 ;; E2 jnz cv00_1 ;; VBE2 lea di, 0x14[bp] mov ax, #0x0100 ;; soft ver. stosw mov ax, # cirrus_vesa_vendorname stosw mov ax, cs stosw mov ax, # cirrus_vesa_productname stosw mov ax, cs stosw mov ax, # cirrus_vesa_productrevision stosw mov ax, cs stoswcv00_1: mov di, bp mov ax, #0x4556 ;; VE stosw mov ax, #0x4153 ;; SA stosw mov ax, #0x0200 ;; v2.00 stosw mov ax, # cirrus_vesa_oemname stosw mov ax, cs stosw xor ax, ax ;; caps stosw stosw lea ax, 0x40[bp] stosw mov ax, es stosw call cirrus_extbios_85h ;; vram in 64k mov ah, #0x00 stosw push cs pop ds lea di, 0x40[bp] mov si, #_cirrus_vesa_modelistcv00_2: lodsw stosw add si, #2 cmp ax, #0xffff jnz cv00_2 mov ax, #0x004F mov di, bp pop si pop ds retcirrus_vesa_01h: mov ax, cx and ax, #0x3fff call cirrus_vesamode_to_mode cmp ax, #0xffff jnz cirrus_vesa_01h_1 jmp cirrus_vesa_unimplementedcirrus_vesa_01h_1: push ds push si push cx push dx push bx mov bp, di cld push cs pop ds call cirrus_get_modeentry_nomask push di xor ax, ax mov cx, #0x80 rep stosw ;; clear buffer pop di mov ax, #0x003b ;; mode stosw mov ax, #0x0007 ;; attr stosw mov ax, #0x0010 ;; granularity =16K stosw mov ax, #0x0040 ;; size =64K stosw mov ax, #0xA000 ;; segment A stosw xor ax, ax ;; no segment B stosw mov ax, #cirrus_vesa_05h_farentry stosw mov ax, cs stosw call cirrus_get_line_offset_entry stosw ;; bytes per scan line mov ax, [si+2] ;; width stosw mov ax, [si+4] ;; height stosw mov ax, #0x08 stosb mov ax, #0x10 stosb mov al, #1 ;; count of planes stosb mov al, [si+6] ;; bpp stosb mov al, #0x1 ;; XXX number of banks stosb mov al, [si+17] stosb ;; memory model mov al, #0x0 ;; XXX size of bank in K stosb call cirrus_get_line_offset_entry mov bx, [si+4] mul bx ;; dx:ax=vramdisp or ax, ax jz cirrus_vesa_01h_3 inc dxcirrus_vesa_01h_3: call cirrus_extbios_85h ;; al=vram in 64k mov ah, #0x00 mov cx, dx xor dx, dx div cx dec ax stosb ;; number of image pages = vramtotal/vramdisp-1 mov al, #0x00 stosb ;; v1.2+ stuffs push si add si, #18 movsw movsw movsw movsw pop si mov ah, [si+16] mov al, #0x0 sub ah, #9 rcl al, #1 ; bit 0=palette flag stosb ;; direct screen mode info ;; v2.0+ stuffs ;; 32-bit LFB address xor ax, ax stosw call cirrus_get_lfb_addr stosw or ax, ax jz cirrus_vesa_01h_4 push di mov di, bp db 0x26 ;; es: mov ax, [di] or ax, #0x0080 ;; mode bit 7:LFB stosw pop dicirrus_vesa_01h_4: xor ax, ax stosw ; reserved stosw ; reserved stosw ; reserved mov ax, #0x004F mov di, bp pop bx pop dx pop cx pop si pop ds test cx, #0x4000 ;; LFB flag jz cirrus_vesa_01h_5 push cx db 0x26 ;; es: mov cx, [di] cmp cx, #0x0080 ;; is LFB supported? jnz cirrus_vesa_01h_6 mov ax, #0x014F ;; error - no LFBcirrus_vesa_01h_6: pop cxcirrus_vesa_01h_5: retcirrus_vesa_02h: ;; XXX support CRTC registers test bx, #0x3e00 jnz cirrus_vesa_02h_2 ;; unknown flags mov ax, bx and ax, #0x1ff ;; bit 8-0 mode cmp ax, #0x100 ;; legacy VGA mode jb cirrus_vesa_02h_legacy call cirrus_vesamode_to_mode cmp ax, #0xffff jnz cirrus_vesa_02h_1cirrus_vesa_02h_2: jmp cirrus_vesa_unimplementedcirrus_vesa_02h_legacy:#ifdef CIRRUS_VESA3_PMINFO db 0x2e ;; cs: cmp byte ptr [cirrus_vesa_is_protected_mode], #0 jnz cirrus_vesa_02h_2#endif // CIRRUS_VESA3_PMINFO int #0x10 mov ax, #0x004F retcirrus_vesa_02h_1: push si push ax call cirrus_get_modeentry_nomask call cirrus_switch_mode test bx, #0x4000 ;; LFB jnz cirrus_vesa_02h_3 call cirrus_enable_16k_granularitycirrus_vesa_02h_3: test bx, #0x8000 ;; no clear jnz cirrus_vesa_02h_4 push ax xor ax,ax call cirrus_clear_vram pop axcirrus_vesa_02h_4: pop ax push ds#ifdef CIRRUS_VESA3_PMINFO db 0x2e ;; cs: mov si, [cirrus_vesa_sel0000_data]#else xor si, si#endif mov ds, si mov [PM_BIOSMEM_CURRENT_MODE], al mov [PM_BIOSMEM_VBE_MODE], bx pop ds pop si mov ax, #0x004F retcirrus_vesa_03h: push ds#ifdef CIRRUS_VESA3_PMINFO db 0x2e ;; cs: mov ax, [cirrus_vesa_sel0000_data]#else xor ax, ax#endif mov ds, ax mov bx, # PM_BIOSMEM_VBE_MODE mov ax, [bx] mov bx, ax test bx, bx jnz cirrus_vesa_03h_1 mov bx, # PM_BIOSMEM_CURRENT_MODE mov al, [bx] mov bl, al xor bh, bhcirrus_vesa_03h_1: mov ax, #0x004f pop ds retcirrus_vesa_05h_farentry: call cirrus_vesa_05h retfcirrus_vesa_05h: cmp bl, #0x01 ja cirrus_vesa_05h_1 cmp bh, #0x00 jz cirrus_vesa_05h_setmempage cmp bh, #0x01 jz cirrus_vesa_05h_getmempagecirrus_vesa_05h_1: jmp cirrus_vesa_unimplementedcirrus_vesa_05h_setmempage: or dh, dh ; address must be < 0x100 jnz cirrus_vesa_05h_1 push dx mov al, bl ;; bl=bank number add al, #0x09 mov ah, dl ;; dx=window address in granularity mov dx, #0x3ce out dx, ax pop dx mov ax, #0x004F retcirrus_vesa_05h_getmempage: mov al, bl ;; bl=bank number add al, #0x09 mov dx, #0x3ce out dx, al inc dx in al, dx xor dx, dx mov dl, al ;; dx=window address in granularity mov ax, #0x004F retcirrus_vesa_06h: mov ax, cx cmp bl, #0x01 je cirrus_vesa_06h_3 cmp bl, #0x02 je cirrus_vesa_06h_2 jb cirrus_vesa_06h_1 mov ax, #0x0100 retcirrus_vesa_06h_1: call cirrus_get_bpp_bytes mov bl, al xor bh, bh mov ax, cx mul bxcirrus_vesa_06h_2: call cirrus_set_line_offsetcirrus_vesa_06h_3: call cirrus_get_bpp_bytes mov bl, al xor bh, bh xor dx, dx call cirrus_get_line_offset push ax div bx mov cx, ax pop bx call cirrus_extbios_85h ;; al=vram in 64k xor dx, dx mov dl, al xor ax, ax div bx mov dx, ax mov ax, #0x004f retcirrus_vesa_07h: cmp bl, #0x80 je cirrus_vesa_07h_1 cmp bl, #0x01 je cirrus_vesa_07h_2 jb cirrus_vesa_07h_1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -