- 论坛徽章:
- 0
|
DOS下看真彩BMP位图的小程序(我给加了注释)
呵呵,看到搂主的代码,让我想起遥远的过去,贴个代码上来。
93-94年自己编写的图形库。当时用的是tasm,现在没什么用了。
- dosseg
- .model large
- viewporttype struc
- left dw 0
- top dw 0
- right dw 0
- bottom dw 0
- clip dw 0
- ends
- fillsettingstype struc
- pattern dw 0
- fillcolor dw 0
- ends
- .data
- forline dw 0
- viewportsetting viewporttype <0,0,639,479,0>;
- fillsettings fillsettingstype <0,0>;
- mode db 0
- addr dw 0
- x0 dw 0
- y0 dw 0
- x1 dw 0
- y1 dw 0
- highh dw 0
- wide dw 0
- color db 1
- bkcolor db 0
- widebyte dw 0
- firstp dw 0
- crease dw 0
- savewritemode db 0
- buf db 48 dup(0)
- hzk db 'c:\service\char.dot'
- db 0
- ascildot db 1536d dup (0)
- db 64d dup (255d) ;定义为96号字符,作覆盖用
- openerror db 'char.dot open error!',0dh,0ah,'$'
- readerror db 'char.dot read error!',0dh,0ah,'$'
- closeerror db 'char.dot close error!',0dh,0ah,'$'
- randsi dw 0
- int_1c_seg dw 0
- int_1c_off dw 0
- old_8_bit db 0
- old_5_bit db 0
- maxtime dw 10d ;minute*1200
- currtime dw 0
- rule dw 0
- timer db 0
- clocker db 0
- timeon db 0
- offhour db 0
- offminute db 0
- offsecond db 0
- timex dw 0
- timey dw 0
- timecol dw 0
- timebkcol dw 0
- clockon db 0
- abshour db 0
- absminute db 0
- abssecond db 0
- clockx dw 0
- clocky dw 0
- clockcol dw 0
- clockbkcol dw 0
- .code
- public @closegraph$qv
- public @initgraph$qv
- public @putpixel$qiii
- public @line$qiiii
- public @setcolor$qi
- public @getcolor$qv
- public @setwritemode$qi
- public @getwritemode$qv
- public @setviewport$qiiiii
- public @getviewsettings$qn12viewporttype
- public @restoreview$qn12viewporttype
- ; public @writergb$qiiii
- public @bar$qiiii
- ; public @setfillstyle$qii
- public @rectangle$qiiii
- public @clearviewport$qv
- public @cleardevice$qv
- public @writehz16$qiiinuc
- public @writeascil$qiiii
- public @loadascil$qv
- public @settimeon$qiiii
- public @settimeoff$qv
- public @setclockon$qiiii
- public @setclockoff$qv
- public @installclock$qv
- public _installclock
- public @setmaxtime$qi
- public _setmaxtime
- public @resetclock$qv
- public _resetclock
- public @quitclock$qv
- public _quitclock
- public @timeout$qv
- public _timeout
- public @M_gettime$qnuc
- public _M_gettime
- public @M_random$qi
- public _M_random
- public _initgraph
- public _restoreview
- public _closegraph
- public _setwritemode
- public _putpixel
- public _rectangle
- public _bar
- public _line
- public _setcolor
- public _getcolor
- public _setviewport
- public _getviewsettings
- public _getmaxx
- public _getmaxy
- public _setfillstyle
- public _getfillsettings
- public _cleardevice
- public _clearviewport
- public _setbkcolor
- public _getbkcolor
- public _drawpoly
- public _setlinestyle
- public _floodfill
- public _getwritemode
- public _writehz16
- public _writeascil
- public _loadascil
- public _settimeon
- public _settimeoff
- public _setclockon
- public _setclockoff
- pushds macro
- push ds
- mov ax,@DATA
- mov ds,ax
- endm
- setmode0 macro
- mov dx,03c4h
- mov al,2
- out dx,al
- inc dx
- mov al,0fh
- out dx,al
- mov dx,03ceh
- mov al,3
- out dx,al
- inc dx
- mov al,0
- out dx,al
- dec dx
- endm
- restoremode macro
- mov dx,03ceh
- mov al,3
- out dx,al
- inc dx
- mov al,[mode]
- out dx,al
- dec dx
- endm
- selreg macro num
- mov al,num
- out dx,al
- inc dx
- endm
- movreg macro num
- mov al,num
- out dx,al
- dec dx
- endm
- @setbkcolor$qi label far
- _setbkcolor proc far
- push bp
- mov bp,sp
- push es
- pushds
- push si
- push di
- mov ax,0a000h
- mov es,ax
- setmode0
- selreg 5
- in al,dx
- and al,252d
- or al,8
- out dx,al
- dec dx
- selreg 2
- movreg [bkcolor]
- mov ax,[bp+6]
- mov [bkcolor],al
- selreg 0
- movreg [bkcolor]
- selreg 1
- movreg 0fh
- xor bx,bx
- mov di,bx
- mov cx,38400d
- selreg 8
- sblb:
- mov al,es:[di]
- cmp al,ah
- jz ll
- mov ah,al
- out dx,al
- ll:
- stosb
- loop sblb
- restoremode
- selreg 1
- movreg 00h
- selreg 8
- movreg 0ffh
- selreg 5
- in al,dx
- and al,247d
- out dx,al
- pop di
- pop si
- pop ds
- pop es
- mov sp,bp
- pop bp
- ret
- _setbkcolor endp
- @line$qiiii label far
- _line proc far
- cli
- push bp
- mov bp,sp
- push es
- pushds
- push si
- push di
- mov ax,0a000h
- mov es,ax
- mov bx,[bp+6] ;x0
- mov cx,[bp+10] ;x1
- mov dx,[bp+12] ;y1
- mov ax,[bp+8] ;y0
- push ax
- mov ax,cx
- and ax,8000h
- jz ll01
- xor cx,cx
- ll01:
- mov ax,bx
- and ax,8000h
- jz ll02
- xor bx,bx
- ll02:
- pop ax
- push bx
- mov bx,ax
- and bx,8000h
- jz ll03
- xor ax,ax
- ll03:
- mov bx,dx
- and bx,8000h
- jz ll04
- xor dx,dx
- ll04:
- pop bx
- add ax,viewportsetting.top
- add bx,viewportsetting.left
- add cx,viewportsetting.left
- add dx,viewportsetting.top
- mov [x0],bx
- mov [y0],ax
- mov [x1],cx
- mov [y1],dx
- cmp bx,cx
- jbe lb0
- mov [x0],cx
- mov [x1],bx
- mov [y0],dx
- mov [y1],ax
- lb0:
- mov ax,[x0]
- cmp ax,viewportsetting.right
- jnbe llexit
- cmp ax,viewportsetting.left
- jnbe ll1
- mov ax,viewportsetting.left
- mov [x0],ax
- ll1:
- mov ax,[x1]
- cmp ax,viewportsetting.right
- jbe ll2
- mov ax,viewportsetting.right
- mov [x1],ax
- ll2:
- mov ax,[y0]
- mov bx,[y1]
- cmp ax,bx
- jbe ll3
- cmp bx,viewportsetting.bottom
- jnbe llexit
- cmp bx,viewportsetting.top
- jnbe ll4
- mov bx,viewportsetting.top
- mov [y1],bx
- ll4:
- cmp ax,viewportsetting.bottom
- jbe ll5
- mov ax,viewportsetting.bottom
- mov [y0],bx
- ll5:
- jmp ll7
- ll3:
- cmp ax,viewportsetting.bottom
- jnbe llexit
- cmp ax,viewportsetting.top
- jnbe ll6
- mov ax,viewportsetting.top
- mov [y0],ax
- ll6:
- cmp bx,viewportsetting.bottom
- jbe ll7
- mov bx,viewportsetting.bottom
- mov [y1],bx
- jmp ll7
- llexit:
- pop di
- pop si
- pop ds
- pop es
- mov sp,bp
- pop bp
- ret
- ll7:
- mov cx,[x1]
- mov bx,[x0]
- sub cx,bx
- mov [wide],cx
- mov dx,[y1]
- mov ax,[y0]
- cmp dx,ax
- jb lb11
- sub dx,ax
- mov [highh],dx
- mov ax,80d
- mov [crease],ax
- jmp lb10
- lb11:
- sub ax,dx
- mov [highh],ax
- mov ax,-80d
- mov [crease],ax
- lb10:
- mov ax,[y0] ;y0
- mov bx,[x0] ;x0
- call _getaddr
- mov dx,3ceh
- selreg 5
- movreg 2
- selreg 8
- movreg cl
- mov cx,[wide]
- cmp cx,[highh]
- jb lb101
- mov cx,[wide]
- mov dx,0
- cmp cx,0
- jbe linelb21
- mov ah,[color]
- linelb2:
- add dx,[highh]
- shr al,1
- cmp al,0
- jne l12
- mov al,128d
- inc bx
- l12:
- push dx
- mov dx,3cfh
- out dx,al
- pop dx
- cmp dx,[wide]
- jb l11
- sub dx,[wide]
- add bx,[crease]
- l11:
- push ax
- mov ah,es:[bx]
- pop ax
- mov es:[bx],ah
- loop linelb2
- linelb21:
- jmp lineexit
- lb101:
- mov cx,highh
- mov dx,0
- mov ah,[color]
- linelb3:
- add dx,[wide]
- add bx,[crease]
- cmp dx,[highh]
- jb l21
- sub dx,[highh]
- shr al,1
- cmp al,0
- jne l22
- mov al,128d
- inc bx
- l22:
- push dx
- mov dx,3cfh
- out dx,al
- pop dx
- l21:
- push ax
- mov ah,es:[bx]
- pop ax
- mov es:[bx],ah
- loop linelb3
- lineexit:
- mov dx,3ceh
- selreg 5
- movreg 0
- selreg 8
- movreg 0ffh
- pop di
- pop si
- pop ds
- pop es
- mov sp,bp
- pop bp
- sti
- ret
- _line endp
- @rectangle$qiiii label far
- _rectangle proc far
- push bp
- mov bp,sp
- push es
- pushds
- push si
- push di
- mov ax,0a000h
- mov es,ax
- mov ax,[bp+8] ;y0
- mov bx,[bp+6] ;x0
- mov cx,[bp+10] ;x1
- mov dx,[bp+12] ;y1
- add ax,viewportsetting.top
- add bx,viewportsetting.left
- add cx,viewportsetting.left
- add dx,viewportsetting.top
- push ax
- cmp bx,cx
- jbe r1b1
- mov ax,cx
- mov cx,bx
- mov bx,ax
- r1b1:
- pop ax
- push bx
- cmp ax,dx
- jbe r1b2
- mov bx,dx
- mov dx,ax
- mov ax,bx
- r1b2:
- pop bx
- cmp ax,viewportsetting.bottom
- jnbe rectexit
- cmp dx,viewportsetting.bottom
- jbe r1b01
- mov dx,viewportsetting.bottom
- r1b01:
- cmp bx,viewportsetting.right
- jnbe rectexit
- cmp cx,viewportsetting.right
- jbe r1b02
- mov cx,viewportsetting.right
- jmp r1b02
- rectexit:
- pop di
- pop si
- pop ds
- pop es
- mov sp,bp
- pop bp
- ret
- r1b02:
- mov [x0],bx
- mov [x1],cx
- mov [y1],dx
- mov [y0],ax
- sub dx,ax
- inc dx
- mov [highh],dx
- shr bx,1
- shr bx,1
- shr bx,1
- inc bx
- shr cx,1
- shr cx,1
- shr cx,1
- xor ax,ax
- mov [widebyte],ax
- cmp cx,bx
- jb lb001
- sub cx,bx
- mov [widebyte],cx
- lb001:
- mov dx,03ceh
- selreg 5
- movreg 2
- mov ax,[y0] ;y0
- mov bx,[x0] ;x0
- call _getaddr
- mov dx,03ceh
- selreg 8
- movreg cl
- mov cx,[highh]
- dec cx
- mov al,[color]
- cmp cx,1
- jbe lb111
- dec cx
- lb1:
- add bx,80d
- mov ah,es:[bx]
- mov es:[bx],al
- loop lb1
- lb111:
- mov ax,[y0] ;y0
- mov bx,[x1] ;x1
- call _getaddr
- mov dx,03ceh
- selreg 8
- movreg cl
- mov cx,[highh]
- mov al,[color]
- dec cx
- cmp cx,1
- jbe lb21
- dec cx
- lb2:
- add bx,80d
- mov ah,es:[bx]
- mov es:[bx],al
- loop lb2
- lb21:
- mov ax,[x0]
- mov bx,[x1]
- shr ax,1
- shr ax,1
- shr ax,1
- inc ax
- shl ax,1
- shl ax,1
- shl ax,1
- cmp ax,bx
- jbe lb201
- mov ax,[y0]
- mov bx,[x1]
- call _getbit
- not cx
- push cx
- mov ax,[y0]
- mov bx,[x1]
- call _getaddr
- pop dx
- or dx,cx
- push dx
- mov ax,[y0]
- mov bx,[x0]
- call _getbit
- pop dx
- and dx,cx
- mov cl,dl
- mov dx,3ceh
- selreg 8
- movreg cl
- mov al,[color]
- mov ah,es:[bx]
- mov es:[bx],al
- mov ax,[y1]
- mov bx,[x0]
- call _getbit
- mov al,[color]
- mov ah,es:[bx]
- mov es:[bx],al
- jmp rbexit
- lb201:
- mov ax,[y0] ;y0
- mov bx,[x0] ;x0
- call _getbit
- mov dx,3ceh
- selreg 8
- movreg cl
- mov al,[color]
- mov ah,es:[bx]
- mov es:[bx],al
- inc bx
- mov dx,3ceh
- selreg 8
- movreg 0ffh
- mov cx,[widebyte]
- mov al,[color]
- cmp cx,0
- jbe lb41
- lb4:
- mov ah,es:[bx]
- mov es:[bx],al
- inc bx
- loop lb4
- lb41:
- mov ax,[y1] ;y1
- mov bx,[x0] ;x0
- call _getbit
- mov dx,3ceh
- selreg 8
- movreg cl
- mov al,[color]
- mov ah,es:[bx]
- mov es:[bx],al
- inc bx
- mov dx,03ceh
- selreg 8
- movreg 0ffh
- mov cx,[widebyte]
- cmp cx,0
- jbe lb51
- lb5:
- mov al,[color]
- mov ah,es:[bx]
- mov es:[bx],al
- inc bx
- loop lb5
- lb51:
- mov ax,[y0] ;y0
- mov bx,[x1] ;x1
- call _getbit
- not cl
- mov dx,3ceh
- selreg 8
- movreg cl
- mov al,[color]
- mov ah,es:[bx]
- mov es:[bx],al
- mov ax,[y1] ;y1
- mov bx,[x1] ;x1
- call _getbit
- cmp cl,0
- je lb52
- not cl
- lb52:
- mov dx,03ceh
- selreg 8
- movreg cl
- mov al,[color]
- mov ah,es:[bx]
- mov es:[bx],al
- rbexit:
- mov dx,03ceh
- selreg 5
- movreg 0
- selreg 8
- movreg 0ffh
- pop di
- pop si
- pop ds
- pop es
- mov sp,bp
- pop bp
- ret
- _rectangle endp
- _drawpoly proc far
- push bp
- mov bp,sp
- push es
- pushds
- mov ax,[bp+6]
- dec ax
- mov [forline],ax ;num of point
- inc ax
- mov bx,[bp+8]
- mov cl,2
- mul cl
- mul cl
- dec ax
- ; push ss:[bx+3]
- ; push ss:[bx+1]
- add bx,ax
- dec bx
- mov [addr],bx
- mov cx,[forline]
- ; push ss:[bx]
- ; push ss:[bx-2]
- ; call _line
- mov [widebyte],bx
- dlb:
- mov ax,ss:[bx]
- push ax
- mov ax,ss:[bx-2]
- push ax
- mov ax,ss:[bx-4]
- push ax
- mov ax,ss:[bx-6]
- push ax
- sub bx,4
- mov ss:[addr],bx
- call _line
- mov bx,ss:[addr]
- mov cx,[forline]
- dec cx
- mov [forline],cx
- cmp cx,0
- jnz dlb
- add bx,4
- mov ax,ss:[bx-4]
- push ax
- mov ax,ss:[bx-6]
- push ax
- mov bx,widebyte
- mov ax,ss:[bx]
- push ax
- mov ax,ss:[bx-2]
- push ax
- call _line
- pop ds
- pop es
- mov sp,bp
- pop bp
- ret
- _drawpoly endp
- @bar$qiiii label far
- _bar proc far
- sti
- push bp
- mov bp,sp
- push es
- pushds
- push si
- push di
- mov ax,0a000h
- mov es,ax
- mov ax,[bp+8] ;y0
- mov bx,[bp+6] ;x0
- mov cx,[bp+10] ;x1
- mov dx,[bp+12] ;y1
- add ax,viewportsetting.top
- add bx,viewportsetting.left
- add cx,viewportsetting.left
- add dx,viewportsetting.top
- push ax
- cmp bx,cx
- jbe blrb1
- mov ax,cx
- mov cx,bx
- mov bx,ax
- blrb1:
- pop ax
- push bx
- cmp ax,dx
- jbe blrb2
- mov bx,dx
- mov dx,ax
- mov ax,bx
- blrb2:
- pop bx
- cmp ax,viewportsetting.bottom
- jnbe barexit1
- cmp dx,viewportsetting.bottom
- jbe blb01
- mov dx,viewportsetting.bottom
- blb01:
- cmp bx,viewportsetting.right
- jnbe barexit1
- cmp cx,viewportsetting.right
- jbe blb02
- mov cx,viewportsetting.right
- jmp blb02
- barexit1:
- pop di
- pop si
- pop ds
- pop es
- mov sp,bp
- pop bp
- cli
- ret
- blb02:
- mov [x0],bx
- mov [x1],cx
- mov [y1],dx
- mov [y0],ax
- sub dx,ax
- inc dx
- mov [highh],dx
- shr bx,1
- shr bx,1
- shr bx,1
- inc bx
- shr cx,1
- shr cx,1
- shr cx,1
- xor ax,ax
- mov [widebyte],ax
- cmp cx,bx
- jb lbb001
- sub cx,bx
- mov [widebyte],cx
- lbb001:
- setmode0
- mov dx,3ceh
- selreg 5
- movreg 2
- mov ax,[x0]
- mov bx,[x1]
- shr ax,1
- shr ax,1
- shr ax,1
- inc ax
- shl ax,1
- shl ax,1
- shl ax,1
- cmp ax,bx
- jbe barlb201
- mov ax,ax
- mov ax,[y0]
- mov bx,[x1]
- call _getbit
- not cx
- push cx
- mov ax,[y0]
- mov bx,[x1]
- call _getaddr
- pop dx
- or cx,dx
- push cx
- mov ax,[y0]
- mov bx,[x0]
- call _getbit
- pop dx
- and dx,cx
- mov cl,dl
- mov dx,3ceh
- selreg 8
- movreg cl
- mov cx,[highh]
- mov ax,fillsettings.fillcolor
- barb3:
- mov ah,es:[bx]
- mov es:[bx],al
- add bx,80
- loop barb3
- jmp barexit
- barlb201:
- mov ax,[y0] ;y0
- mov bx,[x0] ;x0
- call _getbit
- mov dx,3ceh
- selreg 8
- movreg cl
- mov ax,fillsettings.fillcolor
- mov cx,[highh]
- mov [firstp],bx
- barlb3:
- mov ah,es:[bx]
- mov es:[bx],al
- add bx,80
- loop barlb3
- mov cx,[widebyte]
- cmp cx,0
- je barlb52
- selreg 8
- movreg 0ffh
- mov dx,[firstp]
- inc dx
- mov ax,fillsettings.fillcolor
- mov cx,[highh]
- barlb41:
- push cx
- mov bx,dx
- mov cx,[widebyte]
- barlb5:
- mov es:[bx],al
- inc bx
- loop barlb5
- pop cx
- add dx,80
- loop barlb41
- barlb52:
- mov ax,[y0] ;y0
- mov bx,[x1] ;x1
- call _getbit
- not cl
- push cx
- mov ax,[y0] ;y0
- mov bx,[x1] ;x1
- call _getaddr
- pop dx
- or cl,dl
- mov dx,3ceh
- selreg 8
- movreg cl
- mov ax,[fillsettings.fillcolor]
- mov ah,es:[bx]
- mov es:[bx],al
- mov cx,[highh]
- barlb6:
- mov ah,es:[bx]
- mov es:[bx],al
- add bx,80
- loop barlb6
- barexit:
- restoremode
- selreg 5
- movreg 0
- selreg 8
- movreg 0ffh
- pop di
- pop si
- pop ds
- pop es
- mov sp,bp
- pop bp
- cli
- ret
- _bar endp
- @cleardevice$qv label far
- _cleardevice proc far
- sti
- push bp
- mov bp,sp
- push es
- pushds
- push si
- push di
- mov ax,0a000h
- mov es,ax
- setmode0
- mov dx,03ceh
- selreg 5
- movreg 0
- selreg 0
- movreg 0
- selreg 1
- movreg 0fh
- xor bx,bx
- mov di,bx
- mov cx,19200d
- rep stosw
- restoremode
- selreg 1
- movreg 00h
- selreg 5
- movreg 0
- pop di
- pop si
- pop ds
- pop es
- mov sp,bp
- pop bp
- cli
- ret
- _cleardevice endp
- @clearviewport$qv label far
- _clearviewport proc far
- sti
- push bp
- mov bp,sp
- pushds
- push si
- push di
- mov ax,fillsettings.fillcolor
- mov [forline],ax
- mov ax,0
- mov fillsettings.fillcolor,ax
- mov ax,viewportsetting.bottom
- sub ax,viewportsetting.top
- push ax
- mov ax,viewportsetting.right
- sub ax,viewportsetting.left
- push ax
- xor ax,ax
- push ax
- xor ax,ax
- push ax
- call _bar
- mov ax,[forline]
- mov fillsettings.fillcolor,ax
- pop di
- pop si
- pop ds
- mov sp,bp
- pop bp
- cli
- ret
- _clearviewport endp
- _getaddr proc near
- mov cx,80d
- mul cx
- mov cl,bl
- shr bx,1
- shr bx,1
- shr bx,1
- add bx,ax
- and cl,07h
- mov al,80h
- shr al,cl
- mov cl,al
- ret
- _getaddr endp
- _getbit proc near
- mov cx,80d
- mul cx
- mov cl,bl
- shr bx,1
- shr bx,1
- shr bx,1
- add bx,ax
- and cl,07h
- mov al,0ffh
- shr al,cl
- mov cl,al
- ret
- _getbit endp
- @putpixel$qiii label far
- _putpixel proc far
- sti
- push bp
- mov bp,sp
- push es
- pushds
- mov ax,0a000h
- mov es,ax
- setmode0
- selreg 5
- movreg 2
- mov ax,[bp+8]
- mov bx,[bp+6]
- add ax,viewportsetting.top
- add bx,viewportsetting.left
- cmp ax,viewportsetting.bottom
- jnbe putexit
- cmp bx,viewportsetting.right
- jnbe putexit
- call _getaddr
- mov dx,03ceh
- selreg 8
- movreg cl
- mov al,[bp+10]
- mov ah,es:[bx]
- mov es:[bx],al
- putexit:
- restoremode
- selreg 5
- movreg 0
- selreg 8
- movreg 0ffh
- pop ds
- pop es
- mov sp,bp
- pop bp
- cli
- ret
- _putpixel endp
- @setwritemode$qi label far
- _setwritemode proc far
- sti
- push bp
- mov bp,sp
- pushds
- mov dx,3ceh
- selreg 3
- in al,dx
- mov bx,[bp+6]
- cmp bx,0
- jne setlb
- mov al,0
- jmp setlb1
- setlb:
- or al,24d
- setlb1:
- out dx,al
- mov [mode],al
- pop ds
- mov sp,bp
- pop bp
- cli
- ret
- _setwritemode endp
- @setcolor$qi label far
- _setcolor proc far
- push bp
- mov bp,sp
- pushds
- mov bx,[bp+6]
- and bx,15d
- mov [color],bl
- pop ds
- mov sp,bp
- pop bp
- ret
- _setcolor endp
- @setviewport$qiiiii label far
- _setviewport proc far
- push bp
- mov bp,sp
- pushds
- mov ax,[bp+6]
- mov [viewportsetting.left],ax
- mov ax,[bp+8]
- mov [viewportsetting.top],ax
- mov ax,[bp+10]
- cmp ax,[viewportsetting.left]
- jge sl1
- mov bx,ax
- mov ax,[viewportsetting.left]
- mov [viewportsetting.left],bx
- sl1:
- mov [viewportsetting.right],ax
- mov ax,[bp+12]
- cmp ax,[viewportsetting.top]
- jge sl2
- mov bx,ax
- mov ax,[viewportsetting.top]
- mov [viewportsetting.top],bx
- sl2:
- mov [viewportsetting.bottom],ax
- mov ax,[bp+14]
- mov [viewportsetting.clip],ax
- pop ds
- mov sp,bp
- pop bp
- ret
- _setviewport endp
- @getviewsettings$qn12viewporttype label far
- _getviewsettings proc far
- push bp
- mov bp,sp
- pushds
- mov bx,[bp+6]
- mov ax,[viewportsetting.left]
- mov ss:[bx],ax
- mov ax,[viewportsetting.top]
- mov ss:[bx+2],ax
- mov ax,[viewportsetting.right]
- mov ss:[bx+4],ax
- mov ax,[viewportsetting.bottom]
- mov ss:[bx+6],ax
- mov ax,[viewportsetting.clip]
- mov ss:[bx+8],ax
- pop ds
- mov sp,bp
- pop bp
- ret
- _getviewsettings endp
- _setfillstyle proc far
- push bp
- mov bp,sp
- pushds
- mov ax,[bp+6]
- mov fillsettings.pattern,ax
- mov ax,[bp+8]
- mov fillsettings.fillcolor,ax
- pop ds
- mov sp,bp
- pop bp
- ret
- _setfillstyle endp
- _getfillsettings proc far
- push bp
- mov bp,sp
- pushds
- mov bx,[bp+6]
- mov ax,fillsettings.pattern
- mov [bx],ax
- mov ax,fillsettings.fillcolor
- mov [bx+2],ax
- pop ds
- mov sp,bp
- pop bp
- ret
- _getfillsettings endp
- @getmax label far
- _getmaxx proc far
- push bp
- mov bp,sp
- mov ax,639d
- mov sp,bp
- pop bp
- ret
- _getmaxx endp
- @getmaxy$qv label far
- _getmaxy proc far
- push bp
- mov bp,sp
- mov ax,479d
- mov sp,bp
- pop bp
- ret
- _getmaxy endp
- @initgraph$qv label far
- _initgraph proc far
- push bp
- mov bp,sp
- xor ah,ah
- mov al,12h
- int 10h
- mov sp,bp
- pop bp
- ret
- _initgraph endp
- @closegraph$qv label far
- _closegraph proc far
- push bp
- mov bp,sp
- xor ah,ah
- mov al,3
- int 10h
- mov sp,bp
- pop bp
- ret
- _closegraph endp
- @getbkcolor$qv label far
- _getbkcolor proc far
- push bp
- pushds
- mov bp,sp
- xor ah,ah
- mov al,[bkcolor]
- pop ds
- mov sp,bp
- pop bp
- ret
- _getbkcolor endp
- @getcolor$qv label far
- _getcolor proc far
- push bp
- pushds
- mov bp,sp
- xor ah,ah
- mov al,[color]
- pop ds
- mov sp,bp
- pop bp
- ret
- _getcolor endp
- @getwritemode$qv label far
- _getwritemode proc far
- push bp
- mov bp,sp
- pushds
- mov dx,3ceh
- selreg 3
- in al,dx
- and al,24d
- cmp al,0
- je setlbm
- mov al,1
- setlbm:
- xor ah,ah
- pop ds
- mov sp,bp
- pop bp
- ret
- _getwritemode endp
- @setlinestyle$qii label far
- _setlinestyle proc far
- push bp
- pushds
- mov bp,sp
- xor ah,ah
- mov al,[color]
- pop ds
- mov sp,bp
- pop bp
- ret
- _setlinestyle endp
- @floodfill$qiii label far
- _floodfill proc far
- push bp
- pushds
- mov bp,sp
- xor ah,ah
- mov al,[color]
- mov sp,bp
- pop ds
- pop bp
- ret
- _floodfill endp
- ;--------------------------------------------------------------------
- ;功能: 用于获取视窗信息
- ;参数: &VIEWPORTTYPE
- @restoreview$qn12viewporttype label far
- _restoreview proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- push ds
- push es
- push si
- push di
- mov si,[bp+6]
- mov ax,[bp+8]
- mov ds,ax
- mov ax,seg viewportsetting
- mov es,ax
- mov di,offset viewportsetting
- mov cx,5
- rep movsw
- pop di
- pop si
- pop es
- pop ds
- mov sp,bp
- pop bp
- ret
- _restoreview endp
- @writehz16$qiiinuc label far
- _writehz16 proc far
- sti
- push bp
- mov bp,sp
- push es
- pushds
- push si
- push ss
- push di
- mov ax,0a000h
- mov es,ax
- setmode0
- selreg 5
- movreg 2
- mov di,[bp+6] ;x0
- mov bx,di
- and bl,07
- mov bh,0ffh
- mov cl,bl
- shr bh,cl
- mov ax,[bp+8] ;y0
- mov cx,80d
- mul cx
- shr di,1
- shr di,1
- shr di,1
- add di,ax
- mov cx,10h
- mov dx,03ceh
- mov al,8
- out dx,al
- inc dx
- mov ax,[bp+10]
- mov ah,al
- mov si,[bp+14]
- mov ss,si
- mov si,[bp+12]
- cmp bl,0
- jne llpp
- llp:
- mov al,ss:[si]
- out dx,al
- mov al,es:[di]
- mov es:[di],ah
- inc si
- inc di
- mov al,ss:[si]
- inc si
- out dx,al
- mov al,es:[di]
- mov es:[di],ah
- add di,79d
- loop llp
- jmp succ
- llpp:
- push cx
- mov al,ss:[si]
- mov cl,bl
- shr al,cl
- out dx,al
- mov al,es:[di]
- mov es:[di],ah
- inc di
- mov al,ss:[si]
- mov cl,8
- sub cl,bl
- shl al,cl
- inc si
- mov ch,ss:[si]
- mov cl,bl
- shr ch,cl
- or al,ch
- out dx,al
- mov al,es:[di]
- mov es:[di],ah
- inc di
- mov al,ss:[si]
- mov cl,8
- sub cl,bl
- shl al,cl
- out dx,al
- mov al,es:[di]
- mov es:[di],ah
- add di,78d
- inc si
- pop cx
- loop llpp
- succ:
- mov al,0ffh
- out dx,al
- restoremode
- selreg 5
- movreg 0
- pop di
- pop ss
- pop si
- pop ds
- pop es
- mov sp,bp
- pop bp
- cli
- ret
- _writehz16 endp
- @writeascil$qiiii label far
- _writeascil proc far
- sti
- push bp
- mov bp,sp
- push es
- pushds
- push si
- push ss
- push di
- mov ax,0a000h
- mov es,ax
- setmode0
- selreg 5
- in al,dx
- mov old_5_bit,al
- movreg 2
- mov di,[bp+6] ;x0
- mov bx,di
- and bl,07
- mov bh,0ffh
- mov cl,bl
- shr bh,cl
- mov ax,[bp+8] ;y0
- mov cx,80d
- mul cx
- shr di,1
- shr di,1
- shr di,1
- add di,ax
- mov dx,03ceh
- mov al,8
- out dx,al
- inc dx
- in al,dx
- mov old_8_bit,al
- mov ax,[bp+10]
- mov ah,al
- mov si,[bp+12]
- sub si,32d
- shl si,1
- shl si,1
- shl si,1
- shl si,1
- mov cx,offset ascildot
- add si,cx
- mov cx,16d
- cmp bl,0
- jne llpp2
- llp2:
- mov al,[si]
- out dx,al
- mov al,es:[di]
- mov es:[di],ah
- inc si
- add di,80d
- loop llp2
- jmp succ2
- llpp2:
- push cx
- mov al,[si]
- mov cl,bl
- shr al,cl
- out dx,al
- mov al,es:[di]
- mov es:[di],ah
- inc di
- mov al,[si]
- mov cl,8
- sub cl,bl
- shl al,cl
- out dx,al
- mov al,es:[di]
- mov es:[di],ah
- add di,79d
- inc si
- pop cx
- loop llpp2
- succ2:
- restoremode
- selreg 5
- movreg old_5_bit
- selreg 8
- movreg old_8_bit
- pop di
- pop ss
- pop si
- pop ds
- pop es
- mov sp,bp
- pop bp
- cli
- ret
- _writeascil endp
- @loadascil$qv label far
- _loadascil proc far
- push bp
- mov bp,sp
- pushds
- mov dx,offset hzk
- mov ah,03dh
- xor al,al
- int 21h
- jnb openright
- mov dx,offset openerror
- mov ah,9
- int 21h
- jmp closeright
- openright:
- mov bx,ax
- mov ah,03fh
- mov dx,offset ascildot
- mov cx,1536d
- int 21h
- jnb readright
- mov dx,offset readerror
- mov ah,9
- int 21h
- jmp closeright
- readright:
- mov ah,03eh
- int 21h
- jnb closeright
- mov dx,offset closeerror
- mov ah,9
- int 21h
- jmp closeright
- closeright:
- pop ds
- pop bp
- ret
- _loadascil endp
- ;--------------------------------------------------------------------
- @installclock$qv label far
- _installclock proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- push es
- mov ah,35h
- mov al,1ch
- int 21h
- mov int_1c_off,bx
- mov int_1c_seg,es
- push ds
- mov ax,cs
- mov ds,ax
- mov ah,25h
- mov al,1ch
- mov dx,offset new_int_1c
- int 21h
- pop ds
- pop es
- pop ds
- mov sp,bp
- pop bp
- ret
- _installclock endp
- ;--------------------------------------------------------------------
- @quitclock$qv label far
- _quitclock proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- mov dx,int_1c_off
- mov ax,int_1c_seg
- mov ds,ax
- mov ah,25h
- mov al,1ch
- int 21h
- pop ds
- mov sp,bp
- pop bp
- ret
- _quitclock endp
- ;--------------------------------------------------------------------
- @resetclock$qv label far
- _resetclock proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- xor ax,ax
- mov currtime,ax
- pop ds
- mov sp,bp
- pop bp
- ret
- _resetclock endp
- ;--------------------------------------------------------------------
- @setmaxtime$qi label far
- _setmaxtime proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- mov ax,[bp+6]
- mov maxtime,ax
- pop ds
- mov sp,bp
- pop bp
- ret
- _setmaxtime endp
- ;--------------------------------------------------------------------
- @timeout$qv label far
- _timeout proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- mov ax,currtime
- cmp ax,maxtime
- jge outt
- xor ax,ax
- jmp out1
- outt:
- mov ax,1
- out1:
- pop ds
- mov sp,bp
- pop bp
- ret
- _timeout endp
- ;--------------------------------------------------------------------
- showtime proc far
- ;--------------------------------------------------------------------
- mov cl,10d
- div cl
- mov cx,ax
- xor ax,ax
- mov al,cl
- add ax,48d
- push cx
- push ax
- mov ax,128d
- push ax
- mov ax,timebkcol
- push ax
- push dx
- push bx
- call _writeascil
- pop bx
- pop dx
- pop ax
- pop ax
- pop ax
- push ax
- mov ax,timecol
- push ax
- push dx
- push bx
- call _writeascil
- pop bx
- pop dx
- pop ax
- pop ax
- pop cx
- xor ax,ax
- mov al,ch
- add ax,48d
- add bx,8
- push ax
- mov ax,128d
- push ax
- mov ax,timebkcol
- push ax
- push dx
- push bx
- call _writeascil
- pop bx
- pop dx
- pop ax
- pop ax
- pop ax
- push ax
- mov ax,timecol
- push ax
- push dx
- push bx
- call _writeascil
- pop bx
- pop dx
- pop ax
- pop ax
- ret
- showtime endp
- newtime proc far
- mov al,offsecond
- inc al
- mov bx,timex
- add bx,48d
- mov dx,timey
- push ax
- push bx
- call showtime
- pop bx
- pop ax
- mov offsecond,al
- cmp al,60d
- jb ot1
- xor al,al
- mov offsecond,al
- push ax
- push bx
- call showtime
- pop bx
- pop ax
- mov al,offminute
- inc al
- mov offminute,al
- sub bx,24d
- push ax
- push bx
- call showtime
- pop bx
- pop ax
- cmp al,60d
- jb ot1
- xor al,al
- mov offminute,al
- push ax
- push bx
- call showtime
- pop bx
- pop ax
- mov al,offhour
- inc al
- mov offhour,al
- sub bx,24d
- push ax
- push bx
- call showtime
- pop bx
- pop ax
- ot1:
- ret
- newtime endp
- ;--------------------------------------------------------------------
- @settimeon$qiiii label far
- _settimeon proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- mov ax,[bp+6]
- mov timex,ax
- mov ax,[bp+8]
- mov timey,ax
- mov ax,[bp+10]
- mov timecol,ax
- mov ax,[bp+12]
- mov timebkcol,ax
- mov al,0
- mov offhour,al
- mov offminute,al
- mov offsecond,al
- mov timer,al
- mov al,1
- mov timeon,al
- pop ds
- mov sp,bp
- pop bp
- ret
- _settimeon endp
- ;--------------------------------------------------------------------
- @setclockon$qiiii label far
- _setclockon proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- mov ax,[bp+6]
- mov clockx,ax
- mov ax,[bp+8]
- mov clocky,ax
- mov ax,[bp+10]
- mov timecol,ax
- mov ax,[bp+12]
- mov timebkcol,ax
- mov ah,2ch
- int 21h
- mov abshour,ch
- mov absminute,cl
- mov abssecond,dh
- mov al,1
- mov clockon,al
- pop ds
- mov sp,bp
- pop bp
- ret
- _setclockon endp
- ;--------------------------------------------------------------------
- @M_gettime$qnuc label far
- _M_gettime proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- push si
- mov si,[bp+6]
- mov ax,[bp+8]
- mov ds,ax
- mov ah,2ch
- int 21h
- xor ax,ax
- mov al,ch
- mov dl,10d
- div dl
- add ah,48d
- add al,48d
- mov ds:[si],al
- inc si
- mov ds:[si],ah
- inc si
- mov ah,':'
- mov ds:[si],ah
- inc si
- xor ax,ax
- mov al,cl
- mov dl,10d
- div dl
- add ah,48d
- add al,48d
- mov ds:[si],al
- inc si
- mov ds:[si],ah
- inc si
- mov ah,':'
- mov ds:[si],ah
- inc si
- xor ax,ax
- mov al,dh
- mov dl,10d
- div dl
- add ah,48d
- add al,48d
- mov ds:[si],al
- inc si
- mov ds:[si],ah
- inc si
- xor ah,ah
- mov ds:[si],ah
- pop si
- pop ds
- mov sp,bp
- pop bp
- ret
- _M_gettime endp
- ;--------------------------------------------------------------------
- @setclockoff$qv label far
- _setclockoff proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- mov al,0
- mov clockon,al
- pop ds
- mov sp,bp
- pop bp
- ret
- _setclockoff endp
- ;--------------------------------------------------------------------
- @settimeoff$qv label far
- _settimeoff proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- mov al,0
- mov timeon,al
- pop ds
- mov sp,bp
- pop bp
- ret
- _settimeoff endp
- ;--------------------------------------------------------------------
- @M_random$qi label far
- _M_random proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- pushds
- push es
- push di
- push si
- xor ax,ax
- mov es,ax
- mov di,046ch
- mov si,es:[di]
- mov ax,ds:[si]
- ; mov dx,ds:[si+2]
- and dx,00h
- ; and ax,ffffh
- mov si,randsi
- inc si
- cmp si,982d
- jb lk
- mov si,0
- lk:
- mov randsi,si
- mov bl,ascildot[si]
- mov bh,ascildot[si+1]
- add ax,bx
- mov bx,[bp+6]
- cmp bx,0
- je oi
- div bx
- oi:
- mov ax,dx
- pop si
- pop di
- pop es
- pop ds
- mov sp,bp
- pop bp
- ret
- _M_random endp
- newclock proc far
- ; xor ah,ah
- mov al,abssecond
- inc al
- mov bx,clockx
- add bx,48d
- mov dx,clocky
- push ax
- push bx
- call showtime
- pop bx
- pop ax
- mov abssecond,al
- cmp al,60d
- jb oot1
- xor al,al
- mov abssecond,al
- push ax
- push bx
- call showtime
- pop bx
- pop ax
- mov al,absminute
- inc al
- mov absminute,al
- sub bx,24d
- push ax
- push bx
- call showtime
- pop bx
- pop ax
- cmp al,60d
- jb oot1
- xor al,al
- mov absminute,al
- push ax
- push bx
- call showtime
- pop bx
- pop ax
- mov al,abshour
- inc al
- mov abshour,al
- sub bx,24d
- push ax
- push bx
- call showtime
- pop bx
- pop ax
- oot1:
- ret
- newclock endp
- ;--------------------------------------------------------------------
- new_int_1c proc far
- ;--------------------------------------------------------------------
- push bp
- mov bp,sp
- push es
- push ax
- push bx
- push cx
- push dx
- push si
- push di
- pushf
- pushds
- mov al,clocker
- inc al
- cmp al,18d
- jb llll
- mov ax,currtime
- inc ax
- mov currtime,ax
- mov ax,0
- llll:
- mov clocker,al
- mov ax,rule
- inc ax
- mov rule,ax
- cmp ax,1620d
- jb lllll
- mov ax,0
- mov rule,ax
- mov al,offsecond
- inc al
- mov offsecond,al
- mov al,abssecond
- inc al
- mov abssecond,al
- lllll:
- mov al,clockon
- cmp al,1
- je ottt
- mov al,timeon
- cmp al,1
- je ottt
- jmp ot
- ottt:
- mov al,timer
- inc al
- mov timer,al
- cmp al,18d
- jb ot
- xor ax,ax
- mov timer,al
- mov al,clockon
- cmp al,0
- je oto
- call newclock
- oto:
- mov al,timeon
- cmp al,0
- je ot
- call newtime
- ot:
- pop ds
- popf
- pop di
- pop si
- pop dx
- pop cx
- pop bx
- pop ax
- pop es
- mov sp,bp
- pop bp
- iret
- new_int_1c endp
- end
复制代码 |
|