source: golgotha/src/render/software/affine_map_unlit_alpha_asm.cc

Last change on this file was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.3 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "software/r1_software_globals.hh"
10
11void texture_scanline_affine_unlit_alpha(w16 *start_pixel,
12                                         sw32 start_x,
13                                         void *left, //actually affine_span *left
14                                         sw32 width)
15{
16  _asm
17  { 
18    mov edi,dword ptr [left]
19   
20    mov esi,dword ptr [r1_software_texture_ptr] //esi has texture base ptr
21    mov ebx,dword ptr [edi]affine_span.s //get s in ecx
22   
23    shr esi,1 //get half the texture pointer   
24    mov eax,dword ptr [edi]affine_span.t //get t in edx
25
26    sar ebx,16 //get integral part of s
27    mov cl,byte ptr [r1_software_twidth_log2]
28   
29    sar eax,16 //get integral part of t
30    add esi,ebx //setup starting texture ptr
31
32    shl eax,cl //shift left to multiply t by texture width   
33   
34    mov ecx,dword ptr [edi]affine_span.s //get s in ecx
35    add esi,eax //finish setup of starting texture ptr
36
37    sal ecx,16 //shift left to get fractional part of s
38    mov edx,[edi]affine_span.t //get t again in edx
39           
40    sal edx,16 //shift left to get fractional part of t               
41    mov edi,dword ptr [start_pixel]
42
43    mov ebx,dword ptr [width] //setup loop counter
44    add edi,dword ptr [start_x]
45
46    mov ch,16 //initial alpha accumulator value is 16 (since max alpha 15 should draw the pixel)
47    push ebp
48
49    ALIGN 16       
50loopcount:
51    mov ax,word ptr [esi*2]   
52    add edx,dword ptr [dtdx_frac]
53
54    sbb ebp,ebp
55    and ch,240
56
57    mov cl,ah
58    add edi,2
59
60    and eax,4095
61    add ecx,dword ptr [dsdx_frac]
62
63    adc esi,dword ptr [4+s_t_carry+ebp*4]           
64    add ch,cl
65
66    jnc skip_pixel
67    mov ax,word ptr [alpha_table+eax*2]
68
69    mov word ptr [edi-2],ax
70    add ch,16
71   
72skip_pixel:   
73   
74    dec ebx
75    jnz loopcount
76
77    pop ebp
78  } 
79}
Note: See TracBrowser for help on using the repository browser.