1 ;; NASM note
: this file abuses the section flags in such a way that
2 ;; NASM
0.98.37 broke when this was compiled with
:
3 ;; nasm
-o tmap.o
-f elf
-DLINUX tmap.nas
5 ;;-----------------------------------------------------------------------------
9 ;; Copyright
(C
) 1998-2000 by DooM Legacy Team.
11 ;; This program is free software
; you can redistribute it
and/or
12 ;; modify it under the terms of the GNU General Public License
13 ;; as published by the Free Software Foundation
; either version
2
14 ;; of the License
, or (at your option
) any later version.
16 ;; This program is distributed in the hope that it will be useful
,
17 ;; but WITHOUT ANY WARRANTY
; without even the implied warranty of
18 ;; MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License
for more details.
23 ;; Revision
1.2 2003/09/10 23:33:38 hpa
24 ;; Use the version of tmap.nas that actually caused problems
26 ;; Revision
1.10 2001/02/24 13:35:21 bpereira
29 ;; Revision
1.9 2001/02/10 15:24:19 hurdler
30 ;; Apply Rob
's patch for Linux version
32 ;; Revision 1.8 2000/11/12 09:48:15 bpereira
35 ;; Revision 1.7 2000/11/06 20:52:16 bpereira
38 ;; Revision 1.6 2000/11/03 11:48:40 hurdler
39 ;; Fix compiling problem under win32 with 3D-Floors and FragglScript (to verify!)
41 ;; Revision 1.5 2000/11/03 03:27:17 stroggonmeth
42 ;; Again with the bug fixing...
44 ;; Revision 1.4 2000/11/02 17:50:10 stroggonmeth
45 ;; Big 3Dfloors & FraggleScript commit!!
47 ;; Revision 1.3 2000/04/24 20:24:38 bpereira
50 ;; Revision 1.2 2000/02/27 00:42:11 hurdler
53 ;; Revision 1.1.1.1 2000/02/22 20:32:32 hurdler
54 ;; Initial import into CVS (v1.29 pr3)
58 ;; assembler optimised rendering code for software mode
59 ;; draw floor spans, and wall columns.
61 ;;-----------------------------------------------------------------------------
75 %define CODE_SEG .data
87 %define CODE_SEG .text
116 ;cextern ds_textureheight
118 ; polygon edge rasterizer
122 ;;----------------------------------------------------------------------
126 ;; New optimised version 10-01-1998 by D.Fabrice and P.Boris
127 ;; TO DO: optimise it much farther... should take at most 3 cycles/pix
128 ;; once it's fixed
, add code to patch the offsets so that it
129 ;; works in every screen width.
131 ;;----------------------------------------------------------------------
140 [SECTION CODE_SEG write
]
142 ;----------------------------------------------------------------------------
143 ;fixed_t FixedMul
(fixed_t a
, fixed_t b
)
144 ;----------------------------------------------------------------------------
153 ;----------------------------------------------------------------------------
154 ;fixed_t FixedDiv2
(fixed_t a
, fixed_t b
);
155 ;----------------------------------------------------------------------------
160 mov edx
,eax
;; these two instructions allow the next
161 sar edx
,31 ;; two to pair
, on the Pentium processor.
167 ;----------------------------------------------------------------------------
168 ; void ASM_PatchRowBytes
(int rowbytes
);
169 ;----------------------------------------------------------------------------
170 cglobal ASM_PatchRowBytes
212 ;----------------------------------------------------------------------------
214 ;----------------------------------------------------------------------------
216 cglobal R_DrawColumn_8
219 push ebp
;; preserve caller
's stack frame pointer
220 push esi ;; preserve register variables
224 ;; dest = ylookup[dc_yl] + columnofs[dc_x];
228 mov edi,[ylookup+ebx*4]
230 add edi,[columnofs+ebx*4] ;; edi = dest
232 ;; pixelcount = yh - yl + 1
236 sub eax,ebp ;; pixel count
237 mov [pixelcount],eax ;; save for final pixel
238 jle near vdone ;; nothing to scale
240 ;; frac = dc_texturemid - (centery-dc_yl)*fracstep;
242 mov ecx,[dc_iscale] ;; fracstep
246 mov edx,[dc_texturemid]
249 shr ebx,16 ;; frac int.
251 shl edx,16 ;; y frac up
254 shl ebp,16 ;; fracstep f. up
255 shr ecx,16 ;; fracstep i. ->cl
264 mov ch,al ;; quad count
265 mov eax,[dc_colormap]
274 mov al,[esi+ebx] ;; prep un-even loops
275 add edx,ebp ;; ypos f += ystep f
276 adc bl,cl ;; ypos i += ystep i
277 mov dl,[eax] ;; colormap texel
278 and bl,0x7f ;; mask 0-127 texture index
279 mov [edi],dl ;; output pixel
280 p1: add edi,0x12345678
282 ;; do two non-quad-aligned pixels
288 mov al,[esi+ebx] ;; fetch source texel
289 add edx,ebp ;; ypos f += ystep f
290 adc bl,cl ;; ypos i += ystep i
291 mov dl,[eax] ;; colormap texel
292 and bl,0x7f ;; mask 0-127 texture index
293 mov [edi],dl ;; output pixel
295 add edx,ebp ;; fetch source texel
296 adc bl,cl ;; ypos f += ystep f
297 mov dl,[eax] ;; ypos i += ystep i
298 and bl,0x7f ;; colormap texel
299 p2: add edi,0x12345678 ;; mask 0-127 texture index
301 p3: add edi,0x12345678 ;; output pixel
303 ;; test if there was at least 4 pixels
306 test ch,0xff ;; test quad count
309 ;; ebp : ystep frac. upper 16 bits
310 ;; edx : y frac. upper 16 bits
311 ;; ebx : y i. lower 7 bits, masked for index
312 ;; ecx : ch = counter, cl = y step i.
313 ;; eax : colormap aligned 256
314 ;; esi : source texture column
318 mov dh,0x7f ;; prep mask
321 mov al,[esi+ebx] ;; prep loop
322 add edx,ebp ;; ypos f += ystep f
323 adc bl,cl ;; ypos i += ystep i
324 mov dl,[eax] ;; colormap texel
325 mov [edi],dl ;; output pixel
326 and bl,0x7f ;; mask 0-127 texture index
328 mov al,[esi+ebx] ;; fetch source texel
331 p4: add edi,0x12345678
336 mov al,[esi+ebx] ;; fetch source texel
339 p5: add edi,0x12345678
344 mov al,[esi+ebx] ;; fetch source texel
347 p6: add edi,0x12345678
352 p7: add edi,0x12345678
358 pop ebx ;; restore register variables
361 pop ebp ;; restore caller's stack frame pointer
364 ;;----------------------------------------------------------------------
366 ;; R_DrawSkyColumn
: same as R_DrawColumn but
:
368 ;; - wrap around
256 instead of
127.
369 ;; this is needed because we have a higher texture
for mouselook
,
370 ;; we need at least
200 lines
for the sky.
372 ;; NOTE
: the sky should never wrap
, so it could use a faster method.
373 ;; for the moment
, we
'll still use a wrapping method...
375 ;; IT S JUST A QUICK CUT N PASTE, WAS NOT OPTIMISED AS IT SHOULD BE !!!
377 ;;----------------------------------------------------------------------
379 cglobal R_DrawSkyColumn_8
387 ;; dest = ylookup[dc_yl] + columnofs[dc_x];
391 mov edi,[ylookup+ebx*4]
393 add edi,[columnofs+ebx*4] ;; edi = dest
395 ;; pixelcount = yh - yl + 1
399 sub eax,ebp ;; pixel count
400 mov [pixelcount],eax ;; save for final pixel
401 jle near vskydone ;; nothing to scale
403 ;; frac = dc_texturemid - (centery-dc_yl)*fracstep;
405 mov ecx,[dc_iscale] ;; fracstep
409 mov edx,[dc_texturemid]
412 shr ebx,16 ;; frac int.
414 shl edx,16 ;; y frac up
416 shl ebp,16 ;; fracstep f. up
417 shr ecx,16 ;; fracstep i. ->cl
425 mov ch,al ;; quad count
426 mov eax,[dc_colormap]
434 mov al,[esi+ebx] ;; prep un-even loops
435 add edx,ebp ;; ypos f += ystep f
436 adc bl,cl ;; ypos i += ystep i
437 mov dl,[eax] ;; colormap texel
438 mov [edi],dl ;; output pixel
439 p8: add edi,0x12345678
441 ;; do two non-quad-aligned pixels
446 mov al,[esi+ebx] ;; fetch source texel
447 add edx,ebp ;; ypos f += ystep f
448 adc bl,cl ;; ypos i += ystep i
449 mov dl,[eax] ;; colormap texel
450 mov [edi],dl ;; output pixel
452 mov al,[esi+ebx] ;; fetch source texel
453 add edx,ebp ;; ypos f += ystep f
454 adc bl,cl ;; ypos i += ystep i
455 mov dl,[eax] ;; colormap texel
456 p9: add edi,0x12345678
457 mov [edi],dl ;; output pixel
459 pa: add edi,0x12345678
461 ;; test if there was at least 4 pixels
463 skyf3: test ch,0xff ;; test quad count
466 ;; ebp : ystep frac. upper 24 bits
467 ;; edx : y frac. upper 24 bits
468 ;; ebx : y i. lower 7 bits, masked for index
469 ;; ecx : ch = counter, cl = y step i.
470 ;; eax : colormap aligned 256
471 ;; esi : source texture column
476 mov al,[esi+ebx] ;; prep loop
477 add edx,ebp ;; ypos f += ystep f
478 mov dl,[eax] ;; colormap texel
479 adc bl,cl ;; ypos i += ystep i
480 mov [edi],dl ;; output pixel
482 mov al,[esi+ebx] ;; fetch source texel
485 pb: add edi,0x12345678
489 mov al,[esi+ebx] ;; fetch source texel
492 pc: add edi,0x12345678
496 mov al,[esi+ebx] ;; fetch source texel
499 pd: add edi,0x12345678
503 pe: add edi,0x12345678
515 ;;----------------------------------------------------------------------
516 ;; R_DrawTranslucentColumn_8
518 ;; Vertical column texture drawer, with transparency. Replaces Doom2's
519 ;; 'fuzz' effect
, which was not so beautiful.
520 ;; Transparency is always impressive in some way
, don
't know why...
521 ;;----------------------------------------------------------------------
523 cglobal R_DrawTranslucentColumn_8
524 R_DrawTranslucentColumn_8:
525 push ebp ;; preserve caller's stack frame pointer
526 push esi
;; preserve register variables
530 ;; dest
= ylookup
[dc_yl
] + columnofs
[dc_x
];
534 mov edi
,[ylookup
+ebx
*4]
536 add edi
,[columnofs
+ebx
*4] ;; edi
= dest
538 ;; pixelcount
= yh
- yl
+ 1
542 sub eax
,ebp
;; pixel count
543 mov
[pixelcount
],eax
;; save
for final pixel
544 jle near vtdone
;; nothing to scale
546 ;; frac
= dc_texturemid
- (centery
-dc_yl
)*fracstep
;
548 mov ecx
,[dc_iscale
] ;; fracstep
552 mov edx
,[dc_texturemid
]
556 shr ebx
,16 ;; frac
int.
558 shl edx
,16 ;; y frac up
561 shl ebp
,16 ;; fracstep f. up
562 shr ecx
,16 ;; fracstep i.
->cl
567 mov edx
,[dc_colormap
]
574 test byte
[pixelcount
],0x3
575 mov ch
,al
;; quad count
576 mov eax
,[dc_transmap
]
581 test byte
[pixelcount
],0x1
584 mov ah
,[esi
+ebx
] ;; fetch texel
: colormap number
587 mov al
,[edi
] ;; fetch dest
: index into colormap
592 pf
: add edi
,0x12345678
594 ;; do two non
-quad
-aligned pixels
596 trf2
: test byte
[pixelcount
],0x2
599 mov ah
,[esi
+ebx
] ;; fetch texel
: colormap number
602 mov al
,[edi
] ;; fetch dest
: index into colormap
607 pg
: add edi
,0x12345678
609 mov ah
,[esi
+ebx
] ;; fetch texel
: colormap number
612 mov al
,[edi
] ;; fetch dest
: index into colormap
617 ph
: add edi
,0x12345678
619 ;; test
if there was at least
4 pixels
621 trf3
: test ch
,0xff ;; test quad count
625 ;; ebp
: ystep frac. upper
24 bits
626 ;; edx
: y frac. upper
24 bits
627 ;; ebx
: y i. lower
7 bits
, masked
for index
628 ;; ecx
: ch
= counter
, cl
= y step i.
629 ;; eax
: colormap aligned
256
630 ;; esi
: source texture column
634 mov ah
,[esi
+ebx
] ;; fetch texel
: colormap number
636 pi
: add edi
,0x12345678
637 mov al
,[edi
] ;; fetch dest
: index into colormap
638 pj
: sub edi
,0x12345678
640 pk
: sub edi
,0x12345678
646 q1
: add ebp
,0x23456789
649 mov ah
,[esi
+ebx
] ;; fetch texel
: colormap number
652 mov al
,[ebp
] ;; fetch dest
: index into colormap
656 q2
: add edi
,0x23456789
659 mov ah
,[esi
+ebx
] ;; fetch texel
: colormap number
662 mov al
,[edi
] ;; fetch dest
: index into colormap
666 q3
: add ebp
,0x23456789
669 mov ah
,[esi
+ebx
] ;; fetch texel
: colormap number
672 mov al
,[ebp
] ;; fetch dest
: index into colormap
676 q4
: add edi
,0x23456789
679 mov ah
,[esi
+ebx
] ;; fetch texel
: colormap number
682 mov al
,[edi
] ;; fetch dest
: index into colormap
694 ;;----------------------------------------------------------------------
697 ;; for smoke..etc.. test.
698 ;;----------------------------------------------------------------------
699 cglobal R_DrawShadeColumn_8
701 push ebp
;; preserve caller
's stack frame pointer
702 push esi ;; preserve register variables
707 ;; dest = ylookup[dc_yl] + columnofs[dc_x];
711 mov edi,[ylookup+ebx*4]
713 add edi,[columnofs+ebx*4] ;; edi = dest
715 ;; pixelcount = yh - yl + 1
719 sub eax,ebp ;; pixel count
720 mov [pixelcount],eax ;; save for final pixel
721 jle near shdone ;; nothing to scale
723 ;; frac = dc_texturemid - (centery-dc_yl)*fracstep;
725 mov ecx,[dc_iscale] ;; fracstep
729 mov edx,[dc_texturemid]
732 shr ebx,16 ;; frac int.
734 shl edx,16 ;; y frac up
737 shl ebp,16 ;; fracstep f. up
738 shr ecx,16 ;; fracstep i. ->cl
748 mov ch,al ;; quad count
758 mov ah,[esi+ebx] ;; fetch texel : colormap number
761 mov al,[edi] ;; fetch dest : index into colormap
765 pl: add edi,0x12345678
767 ;; do two non-quad-aligned pixels
773 mov ah,[esi+ebx] ;; fetch texel : colormap number
776 mov al,[edi] ;; fetch dest : index into colormap
780 pm: add edi,0x12345678
782 mov ah,[esi+ebx] ;; fetch texel : colormap number
785 mov al,[edi] ;; fetch dest : index into colormap
789 pn: add edi,0x12345678
791 ;; test if there was at least 4 pixels
794 test ch,0xff ;; test quad count
798 ;; ebp : ystep frac. upper 24 bits
799 ;; edx : y frac. upper 24 bits
800 ;; ebx : y i. lower 7 bits, masked for index
801 ;; ecx : ch = counter, cl = y step i.
802 ;; eax : colormap aligned 256
803 ;; esi : source texture column
807 mov dh,0x7f ;; prep mask
808 mov ah,[esi+ebx] ;; fetch texel : colormap number
810 po: add edi,0x12345678
811 mov al,[edi] ;; fetch dest : index into colormap
812 pp: sub edi,0x12345678
814 pq: sub edi,0x12345678
822 q5: add ebp,0x12345678
824 mov ah,[esi+ebx] ;; fetch texel : colormap number
826 mov al,[ebp] ;; fetch dest : index into colormap
831 q6: add edi,0x12345678
833 mov ah,[esi+ebx] ;; fetch texel : colormap number
835 mov al,[edi] ;; fetch dest : index into colormap
840 q7: add ebp,0x12345678
842 mov ah,[esi+ebx] ;; fetch texel : colormap number
844 mov al,[ebp] ;; fetch dest : index into colormap
849 q8: add edi,0x12345678
851 mov ah,[esi+ebx] ;; fetch texel : colormap number
853 mov al,[edi] ;; fetch dest : index into colormap
859 pop ebx ;; restore register variables
862 pop ebp ;; restore caller's stack frame pointer
867 ;;----------------------------------------------------------------------
871 ;; Horizontal texture mapping
873 ;;----------------------------------------------------------------------
880 [SECTION CODE_SEG write
]
884 push ebp
;; preserve caller
's stack frame pointer
885 push esi ;; preserve register variables
889 ;; initilise registers
915 mov edi, [ylookup+edi*4]
917 add edi, [columnofs+esi*4]
918 sub esi, ecx ;; pixel count
920 mov ecx, [ds_colormap]
924 jnc near .midloop ;; check parity
927 ; edx = high16bit xfrac[0..13], ah=ystep[16..24] al=xtep[14..21]
928 ; ebx = high16bit =0, bh=yfrac[16..24], bl=xfrac[14..21]
929 ; ecx = colormap table cl=0 (colormap is aligned 8 bits)
930 ; eax = high16bit yfrac[0..15], dx = count
931 ; esi = flat texture source
932 ; edi = screeen buffer destination
933 ; ebp = work register
934 ; pixelcount = high16bit xstep[0..13] rest to 0
935 ; tystep = high16bit ystep[0..15] low 16 bit = 2 (increment of count)
950 add edx, [pixelcount]
962 .hdone: pop ebx ;; restore register variables
965 pop ebp ;; restore caller's stack frame pointer
976 cglobal R_DrawSpan_8_old
978 push ebp
;; preserve caller
's stack frame pointer
979 push esi ;; preserve register variables
987 sub eax,[ds_x1] ;; pixel count
988 mov [pixelcount],eax ;; save for final pixel
989 js near .hdone ;; nothing to scale
990 shr eax,0x1 ;; double pixel count
993 ;; build composite position
1006 ;; calculate screen dest
1008 mov edi,[ylookup+edi*4]
1010 add edi,[columnofs+eax*4]
1012 ;; build composite step
1025 ;; %eax aligned colormap
1026 ;; %ebx aligned colormap
1027 ;; %ecx,%edx scratch
1028 ;; %esi virtual source
1029 ;; %edi moving destination pointer
1032 mov eax,[ds_colormap]
1034 add ebp,ebx ;; advance frac pointer
1037 and ecx,4095 ;; finish calculation for third pixel
1041 add ebp,ebx ;; advance frac pointer
1042 and edx,4095 ;; finish calculation for fourth pixel
1044 mov al,[esi+ecx] ;; get first pixel
1045 mov bl,[esi+edx] ;; get second pixel
1047 test dword [pixelcount],0xfffffffe
1049 mov dl,[eax] ;; color translate first pixel
1051 ;; movw $0xf0f0,%dx ;;see visplanes start
1055 mov dh,[ebx] ;; color translate second pixel
1062 add ebp,[obelix] ;; advance frac pointer
1063 mov [edi],dx ;; write first pixel
1064 and ecx,4095 ;; finish calculation for third pixel
1069 and edx,4095 ;; finish calculation for fourth pixel
1070 mov al,[ecx] ;; get third pixel
1071 add ebp,[obelix] ;; advance frac pointer
1073 mov bl,[edx] ;; get fourth pixel
1074 mov dl,[eax] ;; color translate third pixel
1075 add edi,byte +0x2 ;; advance to third pixel destination
1076 dec esi ;; done with loop?
1077 mov dh,[ebx] ;; color translate fourth pixel
1079 ;; check for final pixel
1081 test dword [pixelcount],0x1
1083 mov [edi],dl ;; write final pixel
1084 .hdone: pop ebx ;; restore register variables
1087 pop ebp ;; restore caller's stack frame pointer
1091 ;; ========================================================================
1092 ;; Rasterization des segments d
'un polyg“ne textur‚ de maniŠre LINEAIRE.
1093 ;; Il s'agit donc d
'interpoler les coordonn‚es aux bords de la texture en
1094 ;; mˆme temps que les abscisses minx/maxx pour chaque ligne.
1095 ;; L'argument
'dir' indique quels bords de la texture sont interpolés
:
1096 ;; 0 : segments associ‚s aux bord SUPERIEUR et INFERIEUR
( TY constant
)
1097 ;; 1 : segments associ‚s aux bord GAUCHE et DROITE
( TX constant
)
1098 ;; ========================================================================
1100 ;; void rasterize_segment_tex
( LONG x1
, LONG y1
, LONG x2
, LONG y2
, LONG tv1
, LONG tv2
, LONG tc
, LONG dir
);
1101 ;; ARG1 ARG2 ARG3 ARG4 ARG5 ARG6 ARG7 ARG8
1103 ;; Pour dir
= 0, (tv1
,tv2
) = (tX1
,tX2
), tc
= tY
, en effet TY est constant.
1105 ;; Pour dir
= 1, (tv1
,tv2
) = (tY1
,tY2
), tc
= tX
, en effet TX est constant.
1108 ;; Uses
: extern struct rastery
*_rastertab
;
1111 [SECTION CODE_SEG write
]
1119 RASTERY_SIZEOF EQU
24
1121 cglobal rasterize_segment_tex
1122 rasterize_segment_tex
:
1126 sub esp
,byte
+0x8 ;; alloue les variables locales
1134 ;; #define DX [ebp-4]
1135 ;; #define TD [ebp-8]
1137 mov eax
,[ebp
+0xc] ;; y1
1138 mov ebx
,[ebp
+0x14] ;; y2
1140 je near .L_finished
;; special
(y1
==y2
) segment horizontal
, exit
!
1142 jg near .L_rasterize_right
1144 ;;rasterize_left
: ;; on rasterize un segment … la GAUCHE du polyg“ne
1150 mov eax
,RASTERY_SIZEOF
1152 mov esi
,[prastertab
]
1153 add esi
,eax
;; point into rastertab
[y2
]
1155 mov eax
,[ebp
+0x8] ;; ARG1
1156 sub eax
,[ebp
+0x10] ;; ARG3
1157 shl eax
,0x10 ;; ((x1
-x2
)<<PRE
) ...
1159 idiv ecx
;; dx
= ...
/ (y1
-y2
+1)
1160 mov
[ebp
-0x4],eax
;; DX
1162 mov eax
,[ebp
+0x18] ;; ARG5
1163 sub eax
,[ebp
+0x1c] ;; ARG6
1166 idiv ecx
;; tdx
=((tx1
-tx2
)<<PRE
) / (y1
-y2
+1)
1167 mov
[ebp
-0x8],eax
;; idem tdy
=((ty1
-ty2
)<<PRE
) / (y1
-y2
+1)
1169 mov eax
,[ebp
+0x10] ;; ARG3
1170 shl eax
,0x10 ;; x
= x2
<<PRE
1172 mov ebx
,[ebp
+0x1c] ;; ARG6
1173 shl ebx
,0x10 ;; tx
= tx2
<<PRE d0
1175 mov edx
,[ebp
+0x20] ;; ARG7
1176 shl edx
,0x10 ;; ty
= ty
<<PRE d0
1179 mov edi
,[ebp
-0x4] ;; DX
1180 cmp dword
[ebp
+0x24],byte
+0x0 ;; ARG8 direction ?
1182 mov ebp
,[ebp
-0x8] ;; TD
1185 ;; TY varie
, TX est constant
1188 mov
[esi
+MINX
],eax
;; rastertab
[y
].minx
= x
1190 mov
[esi
+TX1
],edx
;; .tx1
= tx
1192 mov
[esi
+TY1
],ebx
;; .ty1
= ty
1194 ;;addl DX
, %eax
// x
+= dx
1195 ;;addl TD
, %ebx
// ty
+= tdy
1197 add esi
,RASTERY_SIZEOF
;; next raster line into rastertab
[]
1203 ;; TX varie
, TY est constant
1206 mov
[esi
+MINX
],eax
;; rastertab
[y
].minx
= x
1208 mov
[esi
+TX1
],ebx
;; .tx1
= tx
1210 mov
[esi
+TY1
],edx
;; .ty1
= ty
1212 ;;addl DX
, %eax
// x
+= dx
1213 ;;addl TD
, %ebx
// tx
+= tdx
1215 add esi
,RASTERY_SIZEOF
;; next raster line into rastertab
[]
1221 ;; on rasterize un segment … la DROITE du polyg“ne
1228 mov ebx
,RASTERY_SIZEOF
1230 mov esi
,[prastertab
]
1231 add esi
,eax
;; point into rastertab
[y1
]
1233 mov eax
,[ebp
+0x10] ;; ARG3
1234 sub eax
,[ebp
+0x8] ;; ARG1
1235 shl eax
,0x10 ;; ((x2
-x1
)<<PRE
) ...
1237 idiv ecx
;; dx
= ...
/ (y2
-y1
+1)
1238 mov
[ebp
-0x4],eax
;; DX
1240 mov eax
,[ebp
+0x1c] ;; ARG6
1241 sub eax
,[ebp
+0x18] ;; ARG5
1244 idiv ecx
;; tdx
=((tx2
-tx1
)<<PRE
) / (y2
-y1
+1)
1245 mov
[ebp
-0x8],eax
;; idem tdy
=((ty2
-ty1
)<<PRE
) / (y2
-y1
+1)
1247 mov eax
,[ebp
+0x8] ;; ARG1
1248 shl eax
,0x10 ;; x
= x1
<<PRE
1250 mov ebx
,[ebp
+0x18] ;; ARG5
1251 shl ebx
,0x10 ;; tx
= tx1
<<PRE d0
1253 mov edx
,[ebp
+0x20] ;; ARG7
1254 shl edx
,0x10 ;; ty
= ty
<<PRE d0
1257 mov edi
,[ebp
-0x4] ;; DX
1259 cmp dword
[ebp
+0x24], 0 ;; direction ?
1261 mov ebp
,[ebp
-0x8] ;; TD
1264 ;; TY varie
, TX est constant
1268 mov
[esi
+MAXX
],eax
;; rastertab
[y
].maxx
= x
1270 mov
[esi
+TX2
],edx
;; .tx2
= tx
1272 mov
[esi
+TY2
],ebx
;; .ty2
= ty
1274 ;;addl DX
, %eax
// x
+= dx
1275 ;;addl TD
, %ebx
// ty
+= tdy
1277 add esi
,RASTERY_SIZEOF
1279 jne .L_rright_v_loop
1283 jmp short .L_finished
1285 ;; TX varie
, TY est constant
1288 mov
[esi
+MAXX
],eax
;; rastertab
[y
].maxx
= x
1290 mov
[esi
+TX2
],ebx
;; .tx2
= tx
1292 mov
[esi
+TY2
],edx
;; .ty2
= ty
1294 ;;addl DX
, %eax
// x
+= dx
1295 ;;addl TD
, %ebx
// tx
+= tdx
1297 add esi
,RASTERY_SIZEOF
1299 jne .L_rright_h_loop
1315 ;;; this version can draw
64x64 tiles
, but they would have to be arranged
4 per row
,
1316 ;; so that the stride from one line to the next is
256
1321 ;;texwidth dd
64 ;; texture width
1323 ;; this code is kept in case we add high
-detail floor textures
for example
(256x256
)
1326 ; push ebp
;; preserve caller
's stack frame pointer
1327 ; push esi ;; preserve register variables
1335 ; sub eax,[ds_x1] ;; pixel count
1336 ; mov [pixelcount],eax ;; save for final pixel
1337 ; js near .hdone ;; nothing to scale
1339 ;; calculate screen dest
1342 ; mov edi,[ylookup+edi*4]
1344 ; add edi,[columnofs+eax*4]
1346 ;; prepare registers for inner loop
1349 ; mov edx,[ds_xfrac]
1352 ; mov ecx,[ds_yfrac]
1356 ; mov ebx,[ds_xstep]
1359 ; and ebx,0xffff0000
1361 ; mov ebx,[ds_ystep]
1364 ; and ebx,0xffff0000
1367 ; mov esi,[ds_source]
1369 ;;; %eax Yi,Xi in %ah,%al
1370 ;;; %ebx aligned colormap
1371 ;;; %ecx Yfrac upper, dXi in %ch, %cl is counter (upto 1024pels, =4x256)
1372 ;;; %edx Xfrac upper, dYi in %dh, %dl receives mapped pixels from (ebx)
1373 ;;; ystep dYfrac, add to %ecx, low word is 0
1374 ;;; xstep dXfrac, add to %edx, low word is 0
1375 ;;; %ebp temporary register serves as offset like %eax
1376 ;;; %esi virtual source
1377 ;;; %edi moving destination pointer
1379 ; mov ebx,[pixelcount]
1380 ; shr ebx,0x2 ;; 4 pixels per loop
1382 ; je near .hchecklast
1385 ; mov ebx,[dc_colormap]
1387 ;;; prepare loop with first pixel
1389 ; add ecx,[ystep] ;;pr‚a1
1394 ; mov bl,[esi+eax] ;;pr‚b1
1395 ; mov dl,[ebx] ;;pr‚c1
1397 ; add ecx,[ystep] ;;a2
1438 ; jne near .hdoubleloop
1439 ;;; check for final pixel