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

📄 copper.doc

📁 80386单片机
💻 DOC
字号:
By Craig Allsop

I figured I might as well give everyone the macros from my source that 
display the copper bars.  (They were  written for Tasm,  Ideal  mode - 
but are easily converted) - I reveal all!

macro   waithorz                ; DX = 3DAh!
        local   a,b
a:      in      al,dx
        rcr     al,1
        jc      a
b:      in      al,dx
        rcr     al,1
        jnc     b
endm

macro   waitvert
        local   a,b
a:      in      al,dx
        test    al,8
        jnz     a
b:      in      al,dx
        test    al,8
        jz      b
endm

macro   copper                  ; SI = Colour table, CX = # of Colours
        local   a               ; BL = Palette to change
        mov     ah,0c9h
        mov     dl,3
a:      mov     dl,0c8h
        mov     al,bl
        out     dx,al           ; Select palette
        inc     dl
        outsb
        outsb                   ; Send first 2 values
        lodsb                   ; Get next one ready
        mov     bh,al           ; and hang onto it
        mov     dl,0dah
        waithorz                ; Wait for the horz. retrace
        mov     dl,ah
        mov     al,bh
        out     dx,al           ; Send last value (Causes static!)
        dec     cx
        jnz     a               ; Continue...
endm


To use them, requires a 'waitvert' before using 'copper' to execute it, 
and 'waitvert' requires dx = 3dah. Simple really. Eg:

        mov     si, <address of palette>
        mov     cx, <number of colours/lines>
        mov     bl, <palette to change>
        mov     dx, 3dah
        waitvert
        copper

You will notice that I send two values before waiting for the retrace, 
because the  VGA only loads them into a buffer,  and only updates  the 
palette registers when it gets the last value,  which is also when you 
get the static 'dot' appearing on the screen.  Since I'm doing it this 
way,  on slow machines it works perfectly,  and on faster machines you 
get static on the right side  of the  screen,  but you can  remove the 
overscan on the right side to fix that problem.

Regards,
Craig.

If anyone uses the above macros, or modify the above code for suitable
functions in another lanugage, then be my guest,but please give credit 
where its due, and mention my name  or my alias  'Daemon' - the  above 
macros must conatin this paragraph in any source and are Public Domain 
in all other respects.

⌨️ 快捷键说明

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