您的位置:首页 > 其它

面向对象相关

2016-01-27 18:00 260 查看
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;filename bios.inc
;asm macro about the bios
;create on 06.3.10 by yqg
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;**************setmode macro*****************;
setmode macro var
    push ax
    mov ah,0
    mov al,var
    int 10h      ;set the screen mode
    pop ax
endm
;*************setmode endm********************;
 
;***********setpixel macro**********************;
;notice that this is can use in 13mode
;it direct set rom from 0xa0000000
;notice the x,y only can use reg by bl,al
setpixel MACRO x,y,color
    PUSH ES
    PUSH DI
    PUSH AX
    push dx
    MOV       AX,0a000h
    MOV       ES,AX
    mov       al,y
    mov       ah,0
    mov       bl,160
    mul       bl
    mov       bx,2
    mul       bx        ;this here will made dx 0
    pop       dx
    push      dx
    mov       bl,x
    mov       bh,0
    add       ax,bx  ;location,only a 1 kb,don't afraid to overflow
    mov       DI,ax
    MOV       AL,color
    MOV       ES:[DI],AL     ;set color 
    pop dx
    POP AX
    POP DI
    POP ES
ENDM
;***********setpixel endm*************************;
;--------------------------------------------------;
;***********setbkcolor macro************************;
 setbkcolor macro color
  local again
    PUSH ES
    PUSH DI
    PUSH AX
    push cx
    MOV       AX,0a000h
    MOV       ES,AX
    XOR       DI,DI
    MOV       AL,color
    mov       cx,64000
 again:
    MOV       ES:[DI],AL     ;set color
    inc       di
    loop again
    pop cx
    POP AX
    POP DI
    POP ES
endm
;***********line macro*****************************;
;notice the line now only can draw straight
;that meant that x1=x2 or y1=y2
line macro x1,y1,x2,y2,color
    local again,again1
    PUSH ES
    PUSH DI
    PUSH AX
    push cx
    MOV       AX,0a000h
    MOV       ES,AX
    XOR       DI,DI
    mov       di,x1+y1*320    ;across line
    MOV       AL,color
    mov       cx,x2-x1+1
 again:
    MOV       ES:[DI],AL     ;set color
    inc       di
    loop again
    mov       di,x1+y1*320   
    MOV       AL,color
    mov       cx,y2-y1+1
  again1:
    MOV       ES:[DI],AL    
    add       di,320
    loop again1
    pop cx
    POP AX
    POP DI
    POP ES
endm
;***********line endm****************************;
;---------------------------------------------------;
;**************box endm******************************;
box macro x1,y1,x2,y2,color
    line x1,y1,x2,y1,color
    line x1,y1,x1,y2,color
    line x1,y2,x2,y2,color
    line x2,y1,x2,y2,color
endm
;***************box endm******************************;
 
;************outchar macro********************;
outchar macro x,y,char,color
   local again,again1,next
   push es
   push bp
   push ax
   push bx
   push cx
   push dx
   mov ax,0f000h
   mov es,ax
   mov bp,0fa6eh 
   add bp,char*8       ;get the char address
   mov cx,8
   mov dl,x
   mov dh,y
again1:
   push cx
   mov ah,es:[bp]
   mov cx,8
again:
   rcl ah,1
   jnc next
   setpixel dl,dh,color  
 next:
   inc dl
   loop again
   mov dl,x
   pop cx
   inc dh
   inc bp
   loop again1
   pop dx
   pop cx
   pop bx
   pop ax
   pop bp
   pop es
endm
;*************outchar endm*******************;
    
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: