MOV AH,0
MOV AL,12H ;640*480*16
INT 10H
;########画细点宏########
;参数:页面、Y坐标、X坐标、颜色,通过将AH放入0CH,通过10H中断来描点
;0黑色 1蓝色 2绿色 3青色 4红色 5紫色 6橙色 7白色 8灰色
POINT_THIN MACRO PAGE,ROW,COLUMN,COLOR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AH,0CH
MOV AL,COLOR
MOV BH,PAGE
MOV DX,ROW
MOV CX,COLUMN
INT 10H
POP DX
POP CX
POP BX
POP AX
ENDM
;########画横线宏,参数:X坐标、Y坐标、长度、颜色
DRAWLINE1 MACRO COLUMN,ROW,FREE_LENGTH,COLOR
LOCAL LIN1
PUSH CX
PUSH SI
MOV CX,FREE_LENGTH
MOV SI,COLUMN
LIN1:
POINT_THIN 0,ROW,SI,COLOR
INC SI
LOOP LIN1
POP SI
POP CX
ENDM
;画任意两点间线宏。参数:起点X、起点Y、终点X、终点Y、颜色
LINE MACRO X1,Y1,X2,Y2,COLOR
LOCAL EXIT
LOCAL LINEZHENG,LINEFUN
LOCAL LINEZHENGZHENG,LINEZHENGFUN
LOCAL LINEFUNZHENG,LINEFUNFUN
LOCAL LINE1,LINE2,LINE3
LOCAL LINE11,LINE12,LINE13
LOCAL LINE21,LINE22,LINE23
LOCAL LINE31,LINE32,LINE33
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
MOV SI,0
MOV DI,0
MOV AX,X1
MOV BX,X2
MOV CX,Y1
MOV DX,Y2
CMP AX,BX
JA LINEFUN
LINEZHENG:
CMP CX,DX
JA LINEZHENGFUN
LINEZHENGZHENG:
MOV AH,0CH
MOV AL,COLOR
MOV BH,0
MOV CX,X1
MOV DX,Y1
LINE1:ADD SI,(Y2-Y1)
CMP SI,(X2-X1)
JBE LINE2
SUB SI,(X2-X1)
INC DX
LINE2:ADD DI,(X2-X1)
CMP DI,(Y2-Y1)
JBE LINE3
SUB DI,(Y2-Y1)
INC CX
LINE3:INT 10H
CMP CX,X2
JB LINE1
LEA BX,EXIT
JMP BX
LINEZHENGFUN:
MOV AH,0CH
MOV AL,COLOR
MOV BH,0
MOV CX,X1
MOV DX,Y1
LINE11:ADD SI,(Y1-Y2)
CMP SI,(X2-X1)
JBE LINE12
SUB SI,(X2-X1)
DEC DX
LINE12:ADD DI,(X2-X1)
CMP DI,(Y1-Y2)
JBE LINE13
SUB DI,(Y1-Y2)
INC CX
LINE13:INT 10H
CMP CX,X2
JB LINE11
LEA BX,EXIT
JMP BX
LINEFUN:
MOV CX,Y1
MOV DX,Y2
CMP CX,DX
JA LINEFUNFUN
LINEFUNZHENG:
MOV AH,0CH
MOV AL,COLOR
MOV BH,0
MOV CX,X1
MOV DX,Y1
LINE21:
ADD SI,(Y2-Y1)
CMP SI,(X1-X2)
JBE LINE22
SUB SI,(X1-X2)
INC DX
LINE22:ADD DI,(X1-X2)
CMP DI,(Y2-Y1)
JBE LINE23
SUB DI,(Y2-Y1)
DEC CX
LINE23:INT 10H
CMP CX,X2
JA LINE21
JMP EXIT
LINEFUNFUN:
MOV CX,X1
MOV DX,Y1
MOV AH,0CH
MOV AL,COLOR
MOV BH,0
LINE31:ADD SI,(Y1-Y2)
CMP SI,(X1-X2)
JBE LINE32
SUB SI,(X1-X2)
DEC DX
LINE32:ADD DI,(X1-X2)
CMP DI,(Y1-Y2)
JBE LINE33
SUB DI,(Y1-Y2)
DEC CX
LINE33:INT 10H
CMP CX,X2
JA LINE31
EXIT:
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
ENDM