⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 video.asm

📁 分形源程序集合 分形源程序集合 分形源程序集合
💻 ASM
📖 第 1 页 / 共 5 页
字号:
        mov     cx,16384                ; clear out 32K
        mov     di,0
        rep     stosw
        mov     cx,16384                ; clear out 32K
        rep     stosw
        dec     bx                      ; another page?
        cmp     bx,0
        jge     xloop
return: ret
xga_clear       endp

xga_setpalette  proc    uses es si di, palette:word     ; set the XGA palette
        cmp     xga_isinmode,2          ; are we in an XGA graphics mode?
        jl      return                  ;  nope

        mov     dx,xga_reg_base         ; wait for a retrace
        add     dx,5
        mov     al,1                    ; clear the start-of-blanking
        out     dx,al
bloop:  in      al,dx
        test    al,01h                  ; blanking started?
        jz      bloop                   ;  nope - try again

        mov     dx,xga_reg_base         ; set up for a palette load
        add     dx,0ah
        mov     ax,0064h                ; make invisible
        out     dx,ax
        mov     ax,0055h                ; border color
        out     dx,ax
        mov     ax,0066h                ; palette mode
        out     dx,ax
        mov     ax,0060h                ; start at palette 0
        out     dx,ax
        mov     ax,0061h
        out     dx,ax

        mov     si,palette
        mov     cx,768
        mov     ax,065h                 ; palette update
        out     dx,al
        inc     dx                      ; palette data
.186
        rep     outsb
.8086
        dec     dx

        mov     ax,0ff64h               ; make visible
        out     dx,ax

return: ret
xga_setpalette  endp

xga_detect      proc    uses es di si

        cmp     xga_reg_base,-2         ; has the XGA detector already failed?
        jne     xga_sk1                 ; ne = not yet
        jmp     xga_notfound            ; e = yes, fail again
xga_sk1:cmp     xga_reg_base,-1         ; have we already found the XGA?
        je      xga_loc                 ; e = no
        jmp     xga_found               ; yes, process it

xga_loc:push    bp                      ; save around int 10H calls
        mov     ax,1f00h                ; XGA-2 detect:
        int     10h                     ;  get DMQS length
        pop     bp                      ; restore BP
        cmp     al,1fh                  ; did this work?
        jne     xga_man                 ;  nope - try the older, manual approach
        cmp     bx,768                  ; room for the results?
        ja      xga_man                 ;  no?!?  try the older approach
        mov     ax,1f01h                ; get DMQS info
        push    ds                      ;  into here
        pop     es                      ;  ...
        mov     di, offset dacbox       ;  ...
        int     10h                     ;  ...
        cmp     al,1fh                  ; safety first
        jne     xga_man                 ; ?? try the older approach
        mov     bx, word ptr dacbox+09h ; get the register base
        mov     xga_reg_base,bx         ; save the results
        mov     xga_result,1            ; say we found an adapter
        cmp     byte ptr dacbox+15h,4   ; do we have 1MB of adapter RAM?
        jb      @F                      ;  nope
        or      xga_result,8h           ;  yup - say so.
@@:     mov     bx, word ptr dacbox+13h ; get the composite monitor ID
        and     bx,0f00h                ; high-rez-monitor?
        cmp     bx,0f00h                ;  ..
        je      @F                      ;  nope
        or      xga_result,4            ;  yup
@@:     jmp     xga_found               ; say we found the adapter

xga_man:mov     ah,35h                  ; DOS get interrupt vector
        mov     al,15h                  ; Int 15h
        int     21h                     ; returns vector in es:bx
        mov     ax,es                   ; segment part
        or      ax,ax                   ; undefined vector?
        jnz     xga_sk2                 ; nz = no, OK so far
        jmp     xga_notfound            ; z = yes - not an MCA machine
xga_sk2:mov     dx,-1                   ; start with an invalid POS address
        mov     ax,0c400h               ; look for POS base address
        int     15h                     ;  (Microchannel machines only)
        jnc     xga_sk3                 ; nc = success
        jmp     xga_notfound            ; error - not an MC machine
xga_sk3:mov     xga_pos_base,dx         ; save pos_base_address
        xor     cx,cx                   ; check all MCA slots & motherboard
        cmp     dx,-1                   ; do we have a good POS?
        jne     xga_lp1                 ; ne = yes, proceed with MCA checks
        jmp     xga_notfound            ; no, fail
xga_lp1:cli                             ; no interrupts, please
        cmp     cx,0                    ; treat the motherboard differently?
        jne     xga_sk4                 ; ne = yes
        mov     al,0dfh                 ; enable the motherboard for setup
        mov     dx,94h
        out     dx,al
        jmp     short xga_sk5
xga_sk4:mov     ax,0c401h               ; enable an MCA slot for setup
        mov     bx,cx                   ;  this slot
        int     15h
xga_sk5:mov     dx,xga_pos_base         ; get pos record for the slot ID
        in      ax,dx
        mov     xga_cardid,ax
        add     dx,2                    ; compute IO Res Base
        in      al,dx                   ;  get POS data byte1
        mov     byte ptr xga_1mb,al     ;   save it temporarily
        inc     dx                      ; switch to byte 2
        in      al,dx                   ;  get POS data
        mov     byte ptr xga_1mb+1,al   ;   save it temporarily
        inc     dx                      ; switch to byte 3
        in      al,dx                   ;  get POS data
        mov     byte ptr xga_1mb+2,al   ;   save it temporarily
        inc     dx                      ; switch to byte 4
        in      al,dx                   ;  get POS data
        mov     byte ptr xga_1mb+3,al   ;   save it temporarily
        cmp     cx,0                    ; treat the motherboard differently
        jne     xga_sk6                 ; ne = yes
        mov     al,0ffh                 ; enable the motherboard for normal
        out     094h,al
        jmp     short xga_sk7
xga_sk6:mov     ax,0c402h               ; enable the MCA slot for normal
        mov     bx,cx                   ;  this slot
        int     15h
xga_sk7:sti                             ; interrupts on again

        mov     ax,xga_cardid           ; is an XGA adapter on this slot?
        cmp     ax,08fd8h
        jae     xga_sk8                 ; ae = yes
        jmp     xga_lp2                 ; try another slot
xga_sk8:cmp     ax,08fdbh               ; still within range?
        jbe     xga_sk9                 ; be = yes
        jmp     xga_lp2                 ; no, try another slot

xga_sk9:mov     al,byte ptr xga_1mb     ;  restore POS data byte 1
        and     ax,0eh                  ;  muck about with it to get reg base
        shl     ax,1
        shl     ax,1
        shl     ax,1
        add     ax,2100h
        mov     xga_reg_base,ax
        mov     dx,xga_reg_base         ; is there a monitor on this slot?
        add     dx,0ah
        mov     al,052h
        out     dx,al
        mov     dx,xga_reg_base
        add     dx,0bh
        in      al,dx
        and     al,0fh
        cmp     al,00h                  ; illegal value, returned under Win 3.0
        je      xga_lp2
        cmp     al,0fh
        jne     xga_isthere             ; ne = yes

xga_lp2:inc     cx                      ; try another adapter?
        cmp     cx,9                    ; done all slots?
        ja      xga_ska                 ; a = yes
        jmp     xga_lp1                 ; no, try another slot

xga_ska:jmp     xga_notfound            ; forget it - no XGA here

xga_isthere:
        and     ax,06h                  ; strip off the low & high bit
        xor     ax,05h                  ; reverse the 3rd & low bits
        mov     xga_result,ax           ; save the result flag

        mov     dx,xga_reg_base         ; is this XGA in VGA mode?
        in      al,dx
        test    al,1
        jnz     xga_skb                 ; nz = yes - single-monitor setup
        or      xga_result,10h          ;  dual-monitor setup
xga_skb:

        mov     ah,byte ptr xga_1mb+2   ; retrieve POS data byte 3
        and     ax,0fe00h               ; eliminate the low-order bits
        mov     bl,byte ptr xga_1mb     ; retrieve POS data byte 1
        and     bx,0eh                  ; strip it down to the IODA
        mov     cx,5                    ; shift it up 5 bits
        shl     bx,cl
        or      ax,bx                   ; compute the 4MB aperture value
        mov     word ptr xga_4mb+2,ax   ; save the result

        mov     al, byte ptr xga_1mb+3  ; retrieve POS data byte 4
        and     ax,0fh                  ; select the 1MB aperture bits
        mov     cx,4                    ; shift it up 4 bits
        shl     ax,cl
        mov     word ptr xga_1mb+2,ax   ; save the result
        mov     ax,0
        mov     word ptr xga_1mb,ax

        mov     dx,xga_reg_base         ; Interrupt Disable
        add     dx,4
        xor     al,al
        out     dx,al

        mov     dx,xga_reg_base         ; Switch to Extended Mode
;;      add     dx,00h
        mov     al,4
        out     dx,al

        mov     dx,xga_reg_base         ; Aperture Control
        add     dx,01h
        mov     al,1
        out     dx,al

        mov     dx,xga_reg_base         ; disable Palette Mask
        add     dx,0ah
        mov     ax,0064h
        out     dx,ax

        mov     xga_isinmode,2          ; pretend we're already in graphics
        mov     al,12                   ; select page 12
        call    xga_newbank

        push    es                      ; see if this page has any memory
        mov     ax,0a000h
        push    ax
        pop     es
        mov     ah,000a5h
        mov     es:0,al
        mov     es:1,ah
        cmp     es:0,al
        jne     xga_512
        add     xga_result,8            ; 1MB RAM found
xga_512:pop     es

        mov     al,0                    ; select page 0
        call    xga_newbank
        mov     xga_isinmode,0          ; replace the "in-graphics" flag

        mov     dx,xga_reg_base         ; Palette Mask
        add     dx,0ah
        mov     ax,0ff64h
        out     dx,ax

        test    xga_result,10h          ; dual monitor setup?
        jnz     xga_found               ;  yup - don't restore as a VGA

        mov     dx,xga_reg_base         ; Switch to VGA Mode
;;      add     dx,00h
        mov     al,1
        out     dx,al

        mov     dx,03c3h                ; Enable VGA Address Code
        mov     al,1
        out     dx,al

        jmp     short   xga_found

xga_notfound:
        mov     xga_reg_base,-2         ; set failure flag
xga_found:
        mov     ax,xga_result           ; return the result
        ret

xga_detect      endp

xga_mode        proc    uses es di si, mode:word

        mov     curbk,-1                ; preload impossible bank number

        call    xga_detect              ; is an XGA adapter present?
        cmp     ax,0
        jne     whichmode
        jmp     nope                    ;  nope
whichmode:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -