;
; r_varsa.asm
; global refresh variables
;
; this file uses NASM syntax.
;
; Copyright (C) 1996-1997  Id Software, Inc.
; Copyright (C) 1997-1998  Raven Software Corp.
;
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2
; of the License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
;
; See the GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to:
; Free Software Foundation, Inc.
; 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
;

%include "asm_nasm.inc"

; underscore prefix handling
; for C-shared symbols:
%ifmacro _sym_prefix
; C-shared externs:
; C-shared globals:
 _sym_prefix r_bmodelactive
 _sym_prefix d_sdivzstepu
 _sym_prefix d_tdivzstepu
 _sym_prefix d_zistepu
 _sym_prefix d_sdivzstepv
 _sym_prefix d_tdivzstepv
 _sym_prefix d_zistepv
 _sym_prefix d_sdivzorigin
 _sym_prefix d_tdivzorigin
 _sym_prefix d_ziorigin
 _sym_prefix sadjust
 _sym_prefix tadjust
 _sym_prefix bbextents
 _sym_prefix bbextentt
 _sym_prefix cacheblock
 _sym_prefix d_viewbuffer
 _sym_prefix cachewidth
 _sym_prefix d_pzbuffer
 _sym_prefix d_zrowbytes
 _sym_prefix d_zwidth
%endif	; _sym_prefix

SEGMENT .data

;
; ASM-only variables
;
 global float_1, float_particle_z_clip, float_point5
 global float_minus_1, float_0
float_0 dd 0.0
float_1 dd 1.0
float_minus_1 dd -1.0
float_particle_z_clip dd 8.0
float_point5 dd 0.5

 global fp_16, fp_64k, fp_1m, fp_64kx64k
 global fp_1m_minus_1
 global fp_8
fp_1m dd 1048576.0
fp_1m_minus_1 dd 1048575.0
fp_64k dd 65536.0
fp_8 dd 8.0
fp_16 dd 16.0
fp_64kx64k dd 04f000000h

 global FloatZero, Float2ToThe31nd, FloatMinus2ToThe31nd
FloatZero dd 0
Float2ToThe31nd dd 04f000000h
FloatMinus2ToThe31nd dd 0cf000000h

;
; C-shared variables
;
 global r_bmodelactive
r_bmodelactive dd 0


 ALIGN 4

 global d_sdivzstepu
 global d_tdivzstepu
 global d_zistepu
 global d_sdivzstepv
 global d_tdivzstepv
 global d_zistepv
 global d_sdivzorigin
 global d_tdivzorigin
 global d_ziorigin
d_sdivzstepu dd 0
d_tdivzstepu dd 0
d_zistepu dd 0
d_sdivzstepv dd 0
d_tdivzstepv dd 0
d_zistepv dd 0
d_sdivzorigin dd 0
d_tdivzorigin dd 0
d_ziorigin dd 0

 global sadjust
 global tadjust
 global bbextents
 global bbextentt
sadjust dd 0
tadjust dd 0
bbextents dd 0
bbextentt dd 0

 global cacheblock
 global d_viewbuffer
 global cachewidth
 global d_pzbuffer
 global d_zrowbytes
 global d_zwidth
cacheblock dd 0
cachewidth dd 0
d_viewbuffer dd 0
d_pzbuffer dd 0
d_zrowbytes dd 0
d_zwidth dd 0

;
; ASM-only variables
;
 global izi
izi dd 0

 global pbase, s, t, sfracf, tfracf, snext, tnext
 global spancountminus1, zi16stepu, sdivz16stepu, tdivz16stepu
 global zi8stepu, sdivz8stepu, tdivz8stepu, pz
s dd 0
t dd 0
snext dd 0
tnext dd 0
sfracf dd 0
tfracf dd 0
pbase dd 0
zi8stepu dd 0
sdivz8stepu dd 0
tdivz8stepu dd 0
zi16stepu dd 0
sdivz16stepu dd 0
tdivz16stepu dd 0
spancountminus1 dd 0
pz dd 0

 global izistep
izistep dd 0

 global reciprocal_table_16, entryvec_table_16
reciprocal_table_16 dd 040000000h, 02aaaaaaah, 020000000h
 dd 019999999h, 015555555h, 012492492h
 dd 010000000h, 0e38e38eh, 0ccccccch, 0ba2e8bah
 dd 0aaaaaaah, 09d89d89h, 09249249h, 08888888h

 extern Entry2_16
 extern Entry3_16
 extern Entry4_16
 extern Entry5_16
 extern Entry6_16
 extern Entry7_16
 extern Entry8_16
 extern Entry9_16
 extern Entry10_16
 extern Entry11_16
 extern Entry12_16
 extern Entry13_16
 extern Entry14_16
 extern Entry15_16
 extern Entry16_16
entryvec_table_16 dd 0, Entry2_16, Entry3_16, Entry4_16
 dd Entry5_16, Entry6_16, Entry7_16, Entry8_16
 dd Entry9_16, Entry10_16, Entry11_16, Entry12_16
 dd Entry13_16, Entry14_16, Entry15_16, Entry16_16

 global DP_Count, DP_u, DP_v, DP_32768, DP_Color, DP_Pix, DP_EntryTable
DP_Count dd 0
DP_u dd 0
DP_v dd 0
DP_32768 dd 32768.0
DP_Color dd 0
DP_Pix dd 0

%if 0
 extern DP_1x1
 extern DP_2x2
 extern DP_3x3
 extern DP_4x4
DP_EntryTable dd DP_1x1, DP_2x2, DP_3x3, DP_4x4
%endif

 global advancetable, sstep, tstep, pspantemp, counttemp, jumptemp
advancetable dd 0, 0
sstep dd 0
tstep dd 0
pspantemp dd 0
counttemp dd 0
jumptemp dd 0

 global reciprocal_table, entryvec_table
reciprocal_table dd 040000000h, 02aaaaaaah, 020000000h
 dd 019999999h, 015555555h, 012492492h

%if 0
 extern Entry2_8
 extern Entry3_8
 extern Entry4_8
 extern Entry5_8
 extern Entry6_8
 extern Entry7_8
 extern Entry8_8
entryvec_table dd 0, Entry2_8, Entry3_8, Entry4_8
 dd Entry5_8, Entry6_8, Entry7_8, Entry8_8
%endif

 extern Spr8Entry2_8
 extern Spr8Entry3_8
 extern Spr8Entry4_8
 extern Spr8Entry5_8
 extern Spr8Entry6_8
 extern Spr8Entry7_8
 extern Spr8Entry8_8
 global spr8entryvec_table
spr8entryvec_table dd 0, Spr8Entry2_8, Spr8Entry3_8, Spr8Entry4_8
 dd Spr8Entry5_8, Spr8Entry6_8, Spr8Entry7_8, Spr8Entry8_8

