]> icculus.org git repositories - btb/d2x.git/blob - texmap/tmapfade.asm
use the orientation parameter of g3_draw_bitmap
[btb/d2x.git] / texmap / tmapfade.asm
1 ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
2 ;SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
3 ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
4 ;ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
5 ;IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
6 ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
7 ;FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
8 ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
9 ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
10 ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
11 ;
12 ;
13 ; .
14 ;
15 ;
16 [BITS 32]
17 global  _asm_tmap_scanline_shaded
18 global  asm_tmap_scanline_shaded
19
20 [SECTION .data]
21
22 %include        "tmap_inc.asm"
23 _loop_count             dd      0
24
25 [SECTION .text]
26
27 ; --------------------------------------------------------------------------------------------------
28 ; Enter:
29 ;       _xleft  fixed point left x coordinate
30 ;       _xright fixed point right x coordinate
31 ;       _y      fixed point y coordinate
32 ;**;    _pixptr address of source pixel map
33
34 ;   for (x = (int) xleft; x <= (int) xright; x++) {
35 ;      _setcolor(read_pixel_from_tmap(srcb,((int) (u/z)) & 63,((int) (v/z)) & 63));
36 ;      _setpixel(x,y);
37 ;
38 ;      z += dz_dx;
39 ;   }
40 align 4
41
42 _asm_tmap_scanline_shaded:
43 asm_tmap_scanline_shaded:
44 ;        push fs
45         pusha
46
47 ;        mov     fs, [_gr_fade_table_selector] ; DPH: No selectors in windows
48
49 ; Setup for loop:       _loop_count  iterations = (int) xright - (int) xleft
50 ;       edi     initial row pointer = y*320+x
51
52 ; set edi = address of first pixel to modify
53         mov     edi,[_fx_y]
54  cmp edi,_window_bottom
55  jae near _none_to_do
56
57         imul    edi,[_bytes_per_row]
58         mov     eax,[_fx_xleft]
59         test    eax,eax
60         jns     eax_ok
61         sub     eax,eax
62 eax_ok:
63         add     edi,eax
64         add     edi,[_write_buffer]
65
66 ; set _loop_count = # of iterations
67         mov     eax,[_fx_xright]
68
69         cmp     eax,[_window_right]
70         jl      eax_ok1
71         mov     eax,[_window_right]
72 eax_ok1:        cmp     eax,[_window_left]
73         jg      eax_ok2
74         mov     eax,[_window_left]
75 eax_ok2:
76         mov     ebx,[_fx_xleft]
77         sub     eax,ebx
78         js      near _none_to_do
79         cmp     eax,[_window_width]
80         jbe     _ok_to_do
81         mov     eax,[_window_width]
82 _ok_to_do:
83         mov     [_loop_count], eax
84
85         mov     ecx, 0
86         mov     ch,[_tmap_flat_shade_value]
87         and     ch, 31
88
89 ;_size = (_end1 - _start1)/num_iters
90         mov     eax,num_iters-1
91         sub     eax,[_loop_count]
92         jns     j_eax_ok1
93         inc     eax     ; sort of a hack, but we can get -1 here and want to be graceful
94         jns     j_eax_ok1       ; if we jump, we had -1, which is kind of ok, if not, we int 3
95         int     3       ; oops, going to jump behind _start1, very bad...
96         sub     eax,eax ; ok to continue
97 j_eax_ok1:      imul    eax,eax,(_end1 - _start1)/num_iters
98         add     eax, _start1        ;originally offset _start1
99         jmp     eax
100
101         align   4
102 _start1:
103
104 %rep num_iters
105         mov     cl, [edi]               ; get pixel
106         mov     al, [_gr_fade_table + ecx]            ; darken pixel
107         mov     [edi], al               ; write pixel
108         inc     edi                     ; goto next pixel
109 %endrep
110 _end1:
111
112 _none_to_do:    popa
113 ;                pop     fs
114         ret
115