02-26-2004, 12:49 PM
I was trying to make a Flattriangle routine but Im having errors regarding macros.
1. How do I use macros with parameters?
2. Why can't macros use @@ and @ in labels?
3. any Macro tutorial for TASM you know?
I'm using TASM.
Thanks!!!
Here's the unassemblable code:
1. How do I use macros with parameters?
2. Why can't macros use @@ and @ in labels?
3. any Macro tutorial for TASM you know?
I'm using TASM.
Thanks!!!
Here's the unassemblable code:
Code:
.Model Medium, BASIC
.386
.Code
align 2
Public RelTriF
Hline Macro x1: word, y: word, x2: word , clr: byte
Local @PostSwapX, @PostclipLeft, @PostclipRight, @swapx, @clipLeft, @clipRight, @exit
push ax
push bx
push cx
push dx
mov cx, y
cmp cx, 199
jg @exit
cmp cx, 0
jl @exit
;; calc offset
xchg ch, cl
mov di, cx
shr di, 2
add di,cx ;di=320*y1
;;
;;
mov ax, x1
mov bx, x2
cmp ax, bx
jg @swapx
@PostSwapX:
cmp ax, 319
jg @exit
cmp ax, 0
jl @clipLeft
@PostclipLeft:
cmp bx, 0
jl @exit
cmp bx, 319
jg @clipRight
@PostclipRight:
sub bx,ax
inc bx ;bx=width,ax=X1
;;;
;;;
add di,ax ;di=320*y+x
;;ax=free
;;bx=width
;;cx=free
;store color
mov ax, clr
mov ah, al
mov cx, ax
shl eax, 16
mov ax,cx ;eax=color(all the bytes)
mov cx, bx
shr cx,2 ;w\4
and bx,3 ;remainder
;;
;;
;;;;mov es, Layer
rep stosd
mov cx, bx
rep stosb
Jmp Hexit
;;;;;;Subs
;;;;;;
@swapx:
xchg ax, bx
Jmp @PostSwapX
@clipLeft:
mov cx, bx
sub cx,ax
add ax, cx
cmp ax, 0
jl @exit
xor ax,ax
Jmp @PostclipLeft
@clipRight:
mov bx, 319
Jmp @PostclipRight
@exit:
Pop dx
pop cx
pop bx
pop ax
EndM
;***************************************************************************
RelTriF Proc Uses es di,\
Layer:word, x1:word, y1:word, x2:word, y2:word, x3:word, y3:word, clr:word
Local tx1 : word
Local ty1 : word
Local tx2 : word
Local ty2 : word
Local tx3 : word
Local ty3 : word
Local d1 : dword
Local d2 : dword
Local d3 : dword
Local Hei : word
Mov d1, 0
Mov d2, 0
Mov d3, 0
mov ax, y1
mov bx, y2
mov cx, x1
mov dx, x2
cmp ax, bx
jle @NoSwap1
xchg ax, bx
xchg cx, dx
@Noswap1:
mov ty1, ax
mov ty2, bx
mov tx1, cx
mov tx2, dx
;ax=y1 , bx= y2 , cx= x1 , dx = x2
mov bx, y3
mov dx, x3
cmp ax, bx
jle @Noswap2
xchg ax, bx
xchg cx, dx
@Noswap2:
mov ty1, ax
mov ty3, bx
mov tx1, cx
mov tx3, dx
;ax=y1 , bx= y3 , cx= x1 , dx = x3
mov ax, ty2
mov cx, tx2
cmp ax, bx
jle @NoSwap3
xchg ax, bx
xchg cx, dx
@Noswap3:
mov ty2, ax
mov ty3, bx
mov tx2, cx
mov tx3, dx
mov ax, ty2
sub ax, ty1
cwde ;eax = ydiffa
mov ebx, eax
or ebx,ebx
jz @NoDiv1
mov ax, tx2
sub ax, tx1
cwde
xor edx, edx
sal eax, 16
idev ebx
mov d1, eax
@NoDiv1:
mov ax, ty3
sub ax, ty2
cwde
mov ebx, eax
or ebx, ebx
jz @NoDiv2
mov ax, tx3
sub ax, tx2
cwde
xor edx, edx
sal eax, 16
idiv ebx
mov d2, eax
@NoDiv2:
mov ax, ty3
sub ax, ty1
cwde
mov ebx, eax
or ebx, ebx
jz @NoDiv3
mov ax, tx3
sub ax, tx1
cwde
xor edx, edx
sal ax, 16
idiv ebx
mov d3, eax
@NoDiv3:
xor eax, eax
mov ax, tx1
sal eax, 16
mov ebx, eax
mov es, Layer
mov dx, ty1
mov hei, dx
@yloop1:
mov ecx, eax
sar ecx, 16
mov edx, ebx
sar edx, 16
Hline cx, hei, dx, clr
add eax, d1
add ebx, d2
mov cx, ty3
inc hei
cmp hei, cx
jl @yloop1
mov ax, tx2
sal eax, 16
mov dx, ty2
mov hei, dx
@yloop2:
mov ecx, eax
sar ecx, 16
mov edx, ebx
sar edx, 16
Hline cx, hei, dx, clr
add eax, d2
add ebx, d3
mov cx, ty3
inc hei
cmp hei, cx
jl @yloop2
endp
END