Hello. I'm trying to rewrite this asm code in C, but my asm knowledge very bad.
struct
{
union
{
struct{
WORD ShiftZ0;
WORD ShiftZ1;
WORD ShiftZ2;
WORD ShiftZ3; };
struct{
DWORD ShiftZ01;
DWORD ShiftZ23; };
};
short ShiftZ0Align;
short ShiftZ1Align;
short ShiftZ2Align;
short ShiftZ3Align;
int deltaZ0ToNextLine;
int deltaZ1ToNextLine;
void *Palette;
} AsmDrawData;
inline void AsmDrawWithZ16(BYTE *zdata,BYTE *data,WORD *zbuffer,void *video,int no_dot) {
__asm
{
cmp no_dot,0
je end
mov esi,zdata
mov edi,video
mov ebx,zbuffer
mov ecx,AsmDrawData.Palette
lp:
mov eax,AsmDrawData.ShiftZ01
add ax,[esi]
cmp ax,[ebx]
jle end_out_byte
mov [ebx],ax
mov edx,data
movzx edx,byte ptr [edx]
mov DX_REG,[ecx+edx*(COLOR_DEPTH/8)]
mov [edi],DX_REG
end_out_byte:
add edi,(COLOR_DEPTH/8)
add ebx,2
add esi,2
inc data
dec no_dot
jg lp
end:
}
}
This is what I write, but this wrong:
inline void AsmDrawWithZ16(BYTE *zdata,BYTE *data,WORD *zbuffer,void *video,int no_dot) {
for( int i = 0; i < no_dot; i++ ) {
if( ((WORD*)zdata)[i] + AsmDrawData.ShiftZ0 >= ((WORD*)zbuffer)[i] )
{
((WORD*)zbuffer)[i] = ((WORD*)zdata)[i] + AsmDrawData.ShiftZ0;
((WORD*)video)[i] = ((WORD*)AsmDrawData.Palette)[((BYTE*)data)[i]];
}
}
}
Where I could be wrong? (sorry for my very very bad english)