diff --git a/glide3x/Makefile.DJ b/glide3x/Makefile.DJ index 686db52..1978d52 100644 --- a/glide3x/Makefile.DJ +++ b/glide3x/Makefile.DJ @@ -1,4 +1,4 @@ -# DOS/DJGPP makefile for Glide3(h5) and Texus2 +# DOS/DJGPP makefile for Glide3 and Texus2 # # Copyright (c) 2003 - Borca Daniel # Email : dborca@users.sourceforge.net @@ -12,25 +12,36 @@ # Available options: # # Environment variables: +# FX_GLIDE_HW build for the given ASIC (cvg, h3, h5). +# default = h5 # H4=1 Avenger/Napalm. +# target = h3, h5 # default = no # CPU optimize for the given processor. +# target = cvg, h3, h5 # default = pentium # DEBUG=1 disable optimizations and build for debug. +# target = cvg, h3, h5 # default = no -# USE_X86=1 use assembler triangle specializations. +# USE_X86=1 use assembler triangle specializations; req by CVG +# target = cvg, h3, h5 # default = no # USE_3DNOW=1 allow 3DNow! specializations. However, the true CPU # capabilities are still checked at run-time to avoid # crashes. +# target = cvg, h3, h5 # default = no # USE_MMX=1 (see USE_3DNOW) +# target = h5 # default = no # USE_SSE=1 (see USE_3DNOW) +# target = h5 # default = no # USE_SSE2=1 (see USE_3DNOW) +# target = h5 # default = no # TEXUS2=1 embed Texus2 functions into Glide3. +# target = cvg, h3, h5 # default = no # # Targets: @@ -54,7 +65,7 @@ GLIDE_DXE = glide3x.dxe GLIDE_IMP = libgld3i.a TEXUS_EXE = texus2.exe -FX_GLIDE_HW = h5 +FX_GLIDE_HW ?= h5 FX_GLIDE_SW = swlibs GLIDE_LIBDIR = $(FX_GLIDE_HW)/lib TEXUS_EXEDIR = $(FX_GLIDE_SW)/bin @@ -83,15 +94,20 @@ endif CDEFS = -D__DOS__ -D__DOS32__ # general -CDEFS += -DGLIDE3 -DGLIDE3_ALPHA -DGLIDE_HW_TRI_SETUP=1 -DGLIDE_INIT_HWC -DGLIDE_PACKED_RGB=0 -DGLIDE_PACKET3_TRI_SETUP=1 -DGLIDE_TRI_CULLING=1 -DH3 -DUSE_PACKET_FIFO=1 +CDEFS += -DGLIDE3 -DGLIDE3_ALPHA -DGLIDE_HW_TRI_SETUP=1 -DGLIDE_INIT_HWC -DGLIDE_PACKED_RGB=0 -DGLIDE_PACKET3_TRI_SETUP=1 -DGLIDE_TRI_CULLING=1 -DUSE_PACKET_FIFO=1 # subsystem +ifeq ($(FX_GLIDE_HW),cvg) +CDEFS += -DCVG +else +CDEFS += -DH3 ifdef H4 CDEFS += -DH4 endif ifeq ($(FX_GLIDE_HW),h5) CDEFS += -DFX_GLIDE_H5_CSIM=1 -DFX_GLIDE_NAPALM=1 endif +endif # debug ifdef DEBUG @@ -101,7 +117,14 @@ endif # other CDEFS += -DGLIDE_PLUG -DGLIDE_SPLASH #CDEFS += -DGLIDE_LIB +ifeq ($(FX_GLIDE_HW),cvg) +#CDEFS += -DGLIDE3_SCALER +CDEFS += -DGLIDE_DISPATCH_SETUP -DGLIDE_DISPATCH_DOWNLOAD +CDEFS += -DINIT_DOS +CDEFS += -D__3Dfx_PCI_CFG__ +else #CDEFS += -DGLIDE_CHECK_CONTEXT +endif ############################################################################### # flags @@ -125,11 +148,21 @@ CPU ?= pentium CFLAGS += -O2 -ffast-math -mcpu=$(CPU) endif -CFLAGS += -I$(FX_GLIDE_HW)/glide3/src -I$(FX_GLIDE_HW)/incsrc -I$(FX_GLIDE_HW)/minihwc -I$(FX_GLIDE_HW)/cinit +CFLAGS += -I$(FX_GLIDE_HW)/glide3/src -I$(FX_GLIDE_HW)/incsrc -I$(FX_GLIDE_HW)/minihwc -I$(FX_GLIDE_HW)/cinit -I$(FX_GLIDE_HW)/init CFLAGS += -I$(FX_GLIDE_SW)/fxmisc -I$(FX_GLIDE_SW)/newpci/pcilib -I$(FX_GLIDE_SW)/fxmemmap CFLAGS += -I$(FX_GLIDE_SW)/texus2/lib CFLAGS += $(CDEFS) +ifeq ($(FX_GLIDE_HW),cvg) +override USE_X86 = 1 +else +ifeq ($(FX_GLIDE_HW),h3) +override USE_MMX = 0 +override USE_SSE = 0 +override USE_SSE2 = 0 +endif +endif + ifeq ($(USE_3DNOW),1) CFLAGS += -DGL_AMD3D override USE_X86 = 1 @@ -156,10 +189,14 @@ endif ############################################################################### GLIDE_OBJECTS = \ + $(FX_GLIDE_HW)/glide3/src/fifo.o \ + $(FX_GLIDE_HW)/glide3/src/distate.o \ + $(FX_GLIDE_HW)/glide3/src/gstrip.o \ + $(FX_GLIDE_HW)/glide3/src/distrip.o \ + $(FX_GLIDE_HW)/glide3/src/diget.o \ $(FX_GLIDE_HW)/glide3/src/gsplash.o \ $(FX_GLIDE_HW)/glide3/src/g3df.o \ $(FX_GLIDE_HW)/glide3/src/gu.o \ - $(FX_GLIDE_HW)/glide3/src/gthread.o \ $(FX_GLIDE_HW)/glide3/src/gpci.o \ $(FX_GLIDE_HW)/glide3/src/diglide.o \ $(FX_GLIDE_HW)/glide3/src/disst.o \ @@ -169,15 +206,14 @@ GLIDE_OBJECTS = \ $(FX_GLIDE_HW)/glide3/src/gaa.o \ $(FX_GLIDE_HW)/glide3/src/gdraw.o \ $(FX_GLIDE_HW)/glide3/src/gglide.o \ - $(FX_GLIDE_HW)/glide3/src/distate.o \ - $(FX_GLIDE_HW)/glide3/src/gstrip.o \ - $(FX_GLIDE_HW)/glide3/src/distrip.o \ - $(FX_GLIDE_HW)/glide3/src/diget.o \ $(FX_GLIDE_HW)/glide3/src/glfb.o \ $(FX_GLIDE_HW)/glide3/src/gsst.o \ $(FX_GLIDE_HW)/glide3/src/gtex.o \ $(FX_GLIDE_HW)/glide3/src/gtexdl.o \ - $(FX_GLIDE_HW)/glide3/src/fifo.o + $(FX_GLIDE_HW)/glide3/src/cpuid.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxpci.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxdpmi2.o \ + $(FX_GLIDE_HW)/glide3/src/xtexdl_def.o ifeq ($(USE_X86),1) GLIDE_OBJECTS += \ @@ -207,18 +243,31 @@ GLIDE_OBJECTS += \ $(FX_GLIDE_HW)/glide3/src/gxdraw.o endif +ifeq ($(FX_GLIDE_HW),cvg) GLIDE_OBJECTS += \ - $(FX_GLIDE_HW)/glide3/src/xtexdl_def.o - + $(FX_GLIDE_HW)/glide3/src/digutex.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxmsr.o \ + $(FX_GLIDE_HW)/init/canopus.o \ + $(FX_GLIDE_HW)/init/dac.o \ + $(FX_GLIDE_HW)/init/gamma.o \ + $(FX_GLIDE_HW)/init/gdebug.o \ + $(FX_GLIDE_HW)/init/info.o \ + $(FX_GLIDE_HW)/init/parse.o \ + $(FX_GLIDE_HW)/init/print.o \ + $(FX_GLIDE_HW)/init/sli.o \ + $(FX_GLIDE_HW)/init/sst1init.o \ + $(FX_GLIDE_HW)/init/util.o \ + $(FX_GLIDE_HW)/init/video.o \ + $(FX_GLIDE_HW)/init/fxremap.o +else GLIDE_OBJECTS += \ - $(FX_GLIDE_HW)/glide3/src/cpuid.o \ - $(FX_GLIDE_HW)/cinit/h3cinit.o \ - $(FX_GLIDE_SW)/newpci/pcilib/fxpci.o \ - $(FX_GLIDE_SW)/newpci/pcilib/fxdpmi2.o \ + $(FX_GLIDE_HW)/glide3/src/gthread.o \ $(FX_GLIDE_HW)/minihwc/hwcio.o \ $(FX_GLIDE_HW)/minihwc/gdebug.o \ $(FX_GLIDE_HW)/minihwc/minihwc.o \ - $(FX_GLIDE_HW)/minihwc/dos_mode.o + $(FX_GLIDE_HW)/minihwc/dos_mode.o \ + h5/cinit/h3cinit.o +endif TEXUS_SOURCES = \ $(FX_GLIDE_SW)/texus2/lib/texuslib.c \ @@ -288,6 +337,13 @@ endif # rules(2) ############################################################################### +cvg/glide3/src/xtexdl_def.o: cvg/glide3/src/xtexdl.c + $(CC) -o $@ $(CFLAGS) -c $< +cvg/glide3/src/cpuid.o: cvg/glide3/src/cpudtect.asm + $(AS) -o $@ $(ASFLAGS) $< +h3/glide3/src/cpuid.o: h3/glide3/src/cpudtect.asm + $(AS) -o $@ $(ASFLAGS) $< + $(FX_GLIDE_HW)/glide3/src/xdraw2_def.o: $(FX_GLIDE_HW)/glide3/src/xdraw2.asm $(AS) -o $@ $(ASFLAGS) $< $(FX_GLIDE_HW)/glide3/src/xdraw3_def.o: $(FX_GLIDE_HW)/glide3/src/xdraw3.asm @@ -307,8 +363,10 @@ $(FX_GLIDE_HW)/glide3/src/xdraw3_sse.o: $(FX_GLIDE_HW)/glide3/src/xdraw3.asm $(FX_GLIDE_HW)/glide3/src/xtexdl_sse2.o: $(FX_GLIDE_HW)/glide3/src/xtexdl.asm $(AS) -o $@ $(ASFLAGS) -DGL_SSE2=1 $< +ifeq ($(FX_GLIDE_HW),h5) GENDATE = $(FX_GLIDE_HW)/incsrc/gendate.h FXBLDNO = $(FX_GLIDE_HW)/glide3/src/fxbldno.h +endif $(GLIDE_OBJECTS): $(FX_GLIDE_HW)/glide3/src/fxinline.h $(FX_GLIDE_HW)/glide3/src/fxgasm.h $(FXBLDNO) @@ -338,7 +396,8 @@ fxbldno.exe: $(FXBLDNO:.h=.c) ############################################################################### clean: - -$(call UNLINK,$(FX_GLIDE_HW)/cinit/*.o) + -$(call UNLINK,cvg/init/*.o) + -$(call UNLINK,h5/cinit/*.o) -$(call UNLINK,$(FX_GLIDE_HW)/glide3/src/*.o) -$(call UNLINK,$(FX_GLIDE_HW)/minihwc/*.o) -$(call UNLINK,$(FX_GLIDE_SW)/newpci/pcilib/*.o) diff --git a/glide3x/cvg/glide3/src/gtexdl.c b/glide3x/cvg/glide3/src/gtexdl.c index 05434f4..0132a06 100644 --- a/glide3x/cvg/glide3/src/gtexdl.c +++ b/glide3x/cvg/glide3/src/gtexdl.c @@ -19,6 +19,9 @@ ** ** $Header$ ** $Log$ +** Revision 1.1.1.1.8.1 2003/11/03 13:34:29 dborca +** Voodoo2 happiness (DJGPP & Linux) +** ** Revision 1.1.1.1 1999/12/07 21:42:34 joseph ** Initial checkin into SourceForge. ** @@ -199,7 +202,7 @@ GR_DDFUNC(_grTexDownloadNccTableExt, _GlideRoot.stats.palDownloads++; _GlideRoot.stats.palBytes += (end-start+1)<<2; - if (gc->tmu_state[tmu].ncc_table[which] != table) { + /*if (gc->tmu_state[tmu].ncc_table[which] != table)*/ { SstRegs* texHW; int i; #ifdef GLIDE_POINTCAST_PALETTE @@ -488,7 +491,7 @@ GR_DDFUNC(_grTexDownloadNccTable, _GlideRoot.stats.palDownloads++; _GlideRoot.stats.palBytes += (end-start+1)<<2; - if (gc->tmu_state[tmu].ncc_table[which] != table) { + /*if (gc->tmu_state[tmu].ncc_table[which] != table)*/ { SstRegs* texHW; int i; #ifdef GLIDE_POINTCAST_PALETTE diff --git a/glide3x/cvg/glide3/src/xdraw3.asm b/glide3x/cvg/glide3/src/xdraw3.asm index 3dd66e5..780d0ca 100644 --- a/glide3x/cvg/glide3/src/xdraw3.asm +++ b/glide3x/cvg/glide3/src/xdraw3.asm @@ -32,7 +32,7 @@ extrn _FifoMakeRoom segment CONST ALIGN 8 -_F256_F256 DD 043800000h, 43800000h ; 256 | 256 +_F256_F256 DD 043800000h, 43800000h segment DATA ALIGN 8 diff --git a/glide3x/h3/glide3/src/cpudtect.asm b/glide3x/h3/glide3/src/cpudtect.asm index a11787f..a37d0c5 100644 --- a/glide3x/h3/glide3/src/cpudtect.asm +++ b/glide3x/h3/glide3/src/cpudtect.asm @@ -19,6 +19,9 @@ ;; ;; $Header$ ;; $Log$ +;; Revision 1.1.1.1 1999/11/24 21:44:53 joseph +;; Initial checkin for SourceForge +;; ;; ;; 4 4/06/99 3:54p Dow ;; Alt tab again. @@ -45,10 +48,7 @@ ;; ;; -TITLE cpudtect.asm - -.586P -.model FLAT,C ; Flat memory, mangle publics with leading '_' +%include "xos.inc" ;; Data for data segment goes here ;_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'; @@ -56,14 +56,14 @@ TITLE cpudtect.asm ;;; Some useful constants ; CPU Type -CPUTypeUnknown = 0ffffffffh -CPUTypePrePent = 4h -CPUTypeP5 = 5h -CPUTypeP6 = 6h +CPUTypeUnknown equ 0ffffffffh +CPUTypePrePent equ 4h +CPUTypeP5 equ 5h +CPUTypeP6 equ 6h ;;; References to external data: -_TEXT SEGMENT +segment TEXT ;; ;; _cpu_detect_asm - detect the type of CPU ;; @@ -73,10 +73,8 @@ _TEXT SEGMENT ;; ;; returns 4 for non-pen -PUBLIC _cpu_detect_asm -_cpu_detect_asm PROC NEAR +proc _cpu_detect_asm P6Stuff: - .586 push esi ; save registers that are not volatile push edi push ebx @@ -276,45 +274,38 @@ UnknownVendor: jmp DoneCpu -_cpu_detect_asm ENDP +endp ;------------------------------------------------------------------------------ ; this routine sets the precision to single ; which effects all adds, mults, and divs align 4 ; - PUBLIC single_precision_asm -single_precision_asm PROC NEAR -.586 +proc single_precision_asm push eax ; make room fnclex ; clear pending exceptions - fstcw WORD PTR [esp] - mov eax, DWORD PTR [esp] + fstcw WORD [esp] + mov eax, DWORD [esp] and eax, 0000fcffh ; clear bits 9:8 - mov DWORD PTR [esp], eax - fldcw WORD PTR [esp] + mov DWORD [esp], eax + fldcw WORD [esp] pop eax - ret 0 -single_precision_asm ENDP + ret +endp ;------------------------------------------------------------------------------ ; this routine sets the precision to double ; which effects all adds, mults, and divs align 4 ; - PUBLIC double_precision_asm -double_precision_asm PROC NEAR -.586 +proc double_precision_asm push eax ; make room fnclex ; clear pending exceptions - fstcw WORD PTR [esp] - mov eax, DWORD PTR [esp] + fstcw WORD [esp] + mov eax, DWORD [esp] and eax, 0000fcffh ; clear bits 9:8 or eax, 000002ffh ; set 9:8 to 10 - mov DWORD PTR [esp], eax - fldcw WORD PTR [esp] + mov DWORD [esp], eax + fldcw WORD [esp] pop eax - ret 0 -double_precision_asm ENDP - -_TEXT ENDS -END + ret +endp diff --git a/glide3x/h3/glide3/src/diget.c b/glide3x/h3/glide3/src/diget.c index 6cf1601..bc2c4dd 100644 --- a/glide3x/h3/glide3/src/diget.c +++ b/glide3x/h3/glide3/src/diget.c @@ -19,6 +19,9 @@ ** ** $Header$ ** $Log$ +** Revision 1.1.1.1 1999/11/24 21:44:54 joseph +** Initial checkin for SourceForge +** ** ** 5 5/24/99 2:48p Jamesb ** Added ptrLostContext to exported cmdTransport struct. @@ -686,6 +689,32 @@ GR_DIENTRY(grGetString, const char *, (FxU32 pname)) #undef FN_NAME } /* grGetString */ +/*------------------------------------------------------------------- + Function: grGetRegistryOrEnvironmentStringExt + Date: 4/17/2000 + Implementor(s): atom + Description: + + This is here so the spooky code for finding the correct registry + tweak path in 9x/NT/2K does not have to be duplicated in 3dfxogl. + + Arguments: char* to the name of the setting to check for. + + Return: char* to the requested entry either from the registry + or the environment settings. NULL on error. + -------------------------------------------------------------------*/ +GR_EXT_ENTRY(grGetRegistryOrEnvironmentString, char*, (char* theEntry)) +{ +#define FN_NAME "grGetRegistryOrEnvironmentString" + char* retval ; + + retval = getenv(theEntry) ; + + return retval ; + +#undef FN_NAME +} /* grGetRegistryOrEnvironmentString */ + /*------------------------------------------------------------------- Function: grReset Date: 16-Dec-97 @@ -790,6 +819,7 @@ typedef struct { } GrExtensionTuple; static GrExtensionTuple _extensionTable[] = { + { "grGetRegistryOrEnvironmentStringExt", (GrProc)grGetRegistryOrEnvironmentString }, { "grChromaRangeModeExt", (GrProc)grChromaRangeMode }, { "grChromaRangeExt", (GrProc)grChromaRange }, { "grTexChromaModeExt", (GrProc)grTexChromaMode }, @@ -805,6 +835,8 @@ static GrExtensionTuple _extensionTable[] = { #endif /* (GLIDE_PLATFORM & GLIDE_OS_WIN32) */ { "grCommandTransportInfoExt2", (GrProc)_grCommandTransportInfo }, { "grCommandTransportMakeRoomExt2", (GrProc)_grCommandTransportMakeRoom }, + /* POINTCAST */ + { "grTexDownloadTableExt", (GrProc)grTexDownloadTableExt }, { 0, 0 } }; diff --git a/glide3x/h3/glide3/src/distate.c b/glide3x/h3/glide3/src/distate.c index ed3b739..991fc13 100644 --- a/glide3x/h3/glide3/src/distate.c +++ b/glide3x/h3/glide3/src/distate.c @@ -19,6 +19,9 @@ ** ** $Header$ ** $Log$ + ** Revision 1.2.4.1 2003/06/29 18:45:55 guillemj + ** Fixed preprocessor invalid token errors. + ** ** Revision 1.2 2000/11/24 18:36:48 alanh ** Add new grStippleMode and grStipplePattern functions for both Voodoo3 and ** Voodoo5 hardware. @@ -553,7 +556,6 @@ GR_DIENTRY(grDepthBufferMode, void , (GrDepthBufferMode_t mode) ) Return: -------------------------------------------------------------------*/ -#ifdef __linux__ GR_EXT_ENTRY(grStipplePattern, void , (GrStipplePattern_t stipple)) { #define FN_NAME "grStipplePattern" @@ -566,7 +568,6 @@ GR_EXT_ENTRY(grStipplePattern, void , (GrStipplePattern_t stipple)) #undef FN_NAME } /* grStipplePattern */ -#endif /* __linux__ */ /*------------------------------------------------------------------- Function: grStippleMode @@ -578,7 +579,6 @@ GR_EXT_ENTRY(grStipplePattern, void , (GrStipplePattern_t stipple)) Return: -------------------------------------------------------------------*/ -#ifdef __linux__ GR_DIENTRY(grStippleMode, void , (GrStippleMode_t mode) ) { #define FN_NAME "grStippleMode" @@ -591,7 +591,6 @@ GR_DIENTRY(grStippleMode, void , (GrStippleMode_t mode) ) #undef FN_NAME } /* grStippleMode */ -#endif /* __linux__ */ /*------------------------------------------------------------------- Function: grDitherMode @@ -952,9 +951,7 @@ _grValidateState() _grDepthBufferFunction(LOADARG(grDepthBufferFunction, fnc)); _grDepthBufferMode(LOADARG(grDepthBufferMode, mode)); _grDitherMode(LOADARG(grDitherMode, mode)); -#ifdef __linux__ _grStippleMode(LOADARG(grStippleMode, mode)); -#endif /* __linux__ */ _grSstOrigin(LOADARG(grSstOrigin, origin)); _grRenderBuffer(LOADARG(grRenderBuffer, buffer)); @@ -1013,7 +1010,6 @@ _grValidateState() reg_cnt++; } -#ifdef __linux__ if (NOTVALID(stipple)) { gc->state.shadow.stipple = LOADARG(grStipplePattern, stipple); REG_GROUP_BEGIN(BROADCAST_ID, stipple, 1, 0x01); @@ -1022,7 +1018,6 @@ _grValidateState() } REG_GROUP_END(); } -#endif /* __linux__ */ if (NOTVALID(lfbMode)) { FxU32 @@ -1392,7 +1387,7 @@ GR_DIENTRY(grViewport, void , (FxI32 x, FxI32 y, FxI32 width, FxI32 height) ) #undef FN_NAME } /* grViewport */ -#ifdef __linux__ +#if DRI_BUILD void _grInvalidateAll() { diff --git a/glide3x/h3/glide3/src/ditex.c b/glide3x/h3/glide3/src/ditex.c index 41d83c4..b034bbe 100644 --- a/glide3x/h3/glide3/src/ditex.c +++ b/glide3x/h3/glide3/src/ditex.c @@ -19,6 +19,9 @@ ** ** $Header$ ** $Log$ +** Revision 1.1.1.1 1999/11/24 21:44:54 joseph +** Initial checkin for SourceForge +** ** ** 6 6/10/99 12:17p Stb_mmcclure ** Cleaned up comments made in grTexMinAddress @@ -555,7 +558,7 @@ GR_DIENTRY(grTexMinAddress, FxU32, ( GrChipID_t tmu )) FXUNUSED(hw); -#ifndef __linux__ +#if GLIDE_CHECK_CONTEXT if (!gc->lostContext) return 0; diff --git a/glide3x/h3/glide3/src/fifo.c b/glide3x/h3/glide3/src/fifo.c index bb88ae6..633ef04 100644 --- a/glide3x/h3/glide3/src/fifo.c +++ b/glide3x/h3/glide3/src/fifo.c @@ -19,6 +19,9 @@ ** ** $Header$ ** $Log$ + ** Revision 1.1.1.1.6.1 2003/05/05 07:12:46 dborca + ** no message + ** ** Revision 1.1.1.1 1999/11/24 21:44:55 joseph ** Initial checkin for SourceForge ** @@ -827,7 +830,7 @@ _grCommandTransportMakeRoom(const FxI32 blockSize, const char* fName, const int * we wrap check the current hw fifo pointer which is going to be the * 2d driver's fifo if we lost our context. */ -#if defined(GLIDE_INIT_HWC) && !defined(__linux__) +#if defined(GLIDE_INIT_HWC) && GLIDE_CHECK_CONTEXT gc->contextP = hwcQueryContext(gc->bInfo); #else gc->contextP = 1; @@ -1171,7 +1174,7 @@ _reg_group_begin_internal_wax( FxU32 __regBase, #endif /* GLIDE_DEBUG */ #endif /* USE_PACKET_FIFO */ -#ifdef __linux__ +#if DRI_BUILD void _grImportFifo(int fifoPtr, int fifoRead) { struct cmdTransportInfo* gcFifo; diff --git a/glide3x/h3/glide3/src/fxgasm.c b/glide3x/h3/glide3/src/fxgasm.c index 34e894a..54a03a4 100644 --- a/glide3x/h3/glide3/src/fxgasm.c +++ b/glide3x/h3/glide3/src/fxgasm.c @@ -37,7 +37,29 @@ * macros for creating assembler offset files *----------------------------------------------------------------------*/ -#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__DJGPP__) /* [dBorca] */ +#if 1 /* defined(NASM) - default */ +#define NEWLINE printf("\n") +#define COMMENT printf(";----------------------------------------------------------------------\n") + +#define HEADER(str) NEWLINE; COMMENT; \ + printf("; Assembler offsets for %s struct\n",str);\ + COMMENT; NEWLINE + +#define OFFSET(p,o,pname) if (hex) \ + printf("%s\tequ %08xh\n",pname,((int)&p.o)-(int)&p); \ + else printf("%s\tequ %10d\n",pname,((int)&p.o)-(int)&p) + +#define OFFSET2(p,o,pname) if (hex) \ + printf("%s\tequ %08xh\n",pname,((int)&o)-(int)&p); \ + else printf("%s\tequ %10d\n",pname,((int)&o)-(int)&p) + +#define SIZEOF(p,pname) if (hex) \ + printf("SIZEOF_%s\tequ %08lxh\n",pname,sizeof(p)); \ + else printf("SIZEOF_%s\tequ %10ld\n",pname,sizeof(p)) + +#else /* !NASM */ + +#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__DJGPP__) #define NEWLINE printf("\n") #define COMMENT printf(";----------------------------------------------------------------------\n") @@ -79,6 +101,8 @@ else printf("#define SIZEOF_%s %10ld\n",pname,sizeof(p)) #endif +#endif /* defined(NASM)*/ + int main (int argc, char **argv) @@ -136,6 +160,9 @@ main (int argc, char **argv) OFFSET (gc,state.cull_mode,"cull_mode\t"); #ifndef GLIDE3 OFFSET (gc, regDataList,"regDataList\t"); +#endif +#ifdef GLIDE_DEBUG + OFFSET (gc,checkPtr,"checkPtr\t\t"); #endif OFFSET (gc, tsuDataList,"tsuDataList\t"); OFFSET (gc, cmdTransportInfo.triPacketHdr, "triPacketHdr"); diff --git a/glide3x/h3/glide3/src/fxglide.h b/glide3x/h3/glide3/src/fxglide.h index 7e6819f..ae751df 100644 --- a/glide3x/h3/glide3/src/fxglide.h +++ b/glide3x/h3/glide3/src/fxglide.h @@ -19,6 +19,9 @@ ** ** $Header$ ** $Log$ +** Revision 1.2.4.3 2003/07/25 07:13:41 dborca +** removed debris +** ** Revision 1.2.4.2 2003/06/29 18:45:55 guillemj ** Fixed preprocessor invalid token errors. ** @@ -779,14 +782,12 @@ typedef struct { struct { GrDitherMode_t mode; } grDitherModeArgs; -#ifdef __linux__ struct { GrStippleMode_t mode; } grStippleModeArgs; struct { GrStipplePattern_t stipple; } grStipplePatternArgs; -#endif /* __linux__ */ struct { GrBuffer_t buffer; } grRenderBufferArgs; @@ -835,11 +836,7 @@ typedef struct { */ #define GR_MEMTYPE GR_GET_RESERVED_1 -#if !defined(__linux__) && (!defined(__DJGPP__) || defined(GLIDE_USE_C_TRISETUP)) /* [dBorca] */ #define TRISETUPARGS const void *a, const void *b, const void *c -#else -#define TRISETUPARGS const void *g, const void *a, const void *b, const void *c -#endif /* gpci.c * @@ -1244,11 +1241,8 @@ typedef struct GrGC_s windowedState; #endif /* GLIDE_INIT_HWC */ } cmdTransportInfo; -#if !defined(__linux__) && (!defined(__DJGPP__) || defined(GLIDE_USE_C_TRISETUP)) /* [dBorca] */ + FxI32 (FX_CALL *triSetupProc)(const void *a, const void *b, const void *c); -#else - FxI32 (FX_CALL *triSetupProc)(const void *gc, const void *a, const void *b, const void *c); -#endif SstIORegs *ioRegs; /* I/O remap regs */ @@ -1626,9 +1620,11 @@ _trisetup_noclip_valid(TRISETUPARGS); #else -#if defined( __linux__ ) || (defined(__DJGPP__) && !defined(GLIDE_USE_C_TRISETUP)) /* [dBorca] */ +#if defined( __linux__ ) || defined(__DJGPP__) /* [dBorca] */ -#define TRISETUP(a, b, c) (gc->triSetupProc)(gc, a, b, c) +#define TRISETUP \ + __asm(""::"d"(gc)); \ + (*gc->triSetupProc) #else #define TRISETUP \ @@ -1670,11 +1666,9 @@ _grColorCombine( FxBool invert ); -#ifdef __linux__ void FX_CALL grStipplePattern( GrStipplePattern_t stipple); -#endif /* __linux__ */ void FX_CALL grChromaRangeMode(GrChromaRangeMode_t mode); @@ -1718,10 +1712,8 @@ _grDepthBufferMode( GrDepthBufferMode_t mode ); void _grDitherMode( GrDitherMode_t mode ); -#ifdef __linux__ void _grStippleMode( GrStippleMode_t mode ); -#endif /* __linux__ */ void _grRenderBuffer( GrBuffer_t buffer ); @@ -2281,5 +2273,8 @@ extern const FxU32 _gr_aspect_xlate_table[]; #define HEIGHT_BY_ASPECT_LOD(__aspect, __lod) \ _grMipMapHostWH[G3_ASPECT_TRANSLATE(__aspect)][G3_LOD_TRANSLATE(__lod)][1] -#endif /* __FXGLIDE_H__ */ +GR_EXT_ENTRY(grTexDownloadTableExt, + void, + (GrChipID_t tmu, GrTexTable_t type, void *data)); +#endif /* __FXGLIDE_H__ */ diff --git a/glide3x/h3/glide3/src/gglide.c.dri b/glide3x/h3/glide3/src/gglide.c similarity index 99% rename from glide3x/h3/glide3/src/gglide.c.dri rename to glide3x/h3/glide3/src/gglide.c index e889e84..1597636 100644 --- a/glide3x/h3/glide3/src/gglide.c.dri +++ b/glide3x/h3/glide3/src/gglide.c @@ -19,6 +19,10 @@ ** ** $Header$ ** $Log$ +** Revision 1.5 2000/11/24 18:36:48 alanh +** Add new grStippleMode and grStipplePattern functions for both Voodoo3 and +** Voodoo5 hardware. +** ** Revision 1.4 2000/11/16 20:25:38 alanh ** fix a typo ** @@ -438,7 +442,7 @@ #include "fxcmd.h" #include "fxinline.h" -#ifdef __linux__ +#if DRI_BUILD #include #endif @@ -907,7 +911,7 @@ GR_ENTRY(grBufferClear, void, (GrColor_t color, GrAlpha_t alpha, FxU32 depth)) REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 2, 0x3); REG_GROUP_SET(hw, colBufferAddr,gc->buffers[gc->grColBuf]); -#ifdef __linux__ +#if DRI_BUILD REG_GROUP_SET(hw, colBufferStride, (!gc->curBuffer)? driInfo.stride : gc->state.shadow.auxBufferStride); #else @@ -941,7 +945,7 @@ GR_ENTRY(grBufferClear, void, (GrColor_t color, GrAlpha_t alpha, FxU32 depth)) REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 2, 0x3); REG_GROUP_SET(hw, colBufferAddr, gc->buffers[gc->windowed ? 0 : gc->curBuffer]); -#ifdef __linux__ +#if DRI_BUILD REG_GROUP_SET(hw, colBufferStride, (!gc->curBuffer) ? driInfo.stride : gc->state.shadow.colBufferStride); #else @@ -1032,7 +1036,7 @@ GR_ENTRY(grBufferClear, void, (GrColor_t color, GrAlpha_t alpha, FxU32 depth)) } /* grBufferClear */ #endif -#if 0 +#if !DRI_BUILD /*--------------------------------------------------------------------------- ** grBufferSwap ** @@ -1913,7 +1917,6 @@ GR_ENTRY(grDisableAllEffects, void, (void)) ** grStippleMode */ -#ifdef __linux__ GR_STATE_ENTRY(grStippleMode, void, (GrStippleMode_t mode)) { #define FN_NAME "_grStippleMode" @@ -1947,7 +1950,6 @@ GR_STATE_ENTRY(grStippleMode, void, (GrStippleMode_t mode)) #endif /* !GLIDE3 */ #undef FN_NAME } /* grStippleMode */ -#endif /* __linux__ */ /*--------------------------------------------------------------------------- ** grDitherMode @@ -2315,7 +2317,7 @@ GR_ENTRY(grGlideSetState, void, (const void *state)) ** and the only drawbuffer modes supported by the fbzMode register are 0 ** (back) and 1 (front) */ -#ifndef __linux__ +#if !DRI_BUILD GR_STATE_ENTRY(grRenderBuffer, void, (GrBuffer_t buffer)) { #define FN_NAME "_grRenderBuffer" @@ -2342,7 +2344,7 @@ GR_STATE_ENTRY(grRenderBuffer, void, (GrBuffer_t buffer)) GR_END(); #undef FN_NAME } /* grRenderBuffer */ -#else /* __linux__ */ +#else /* DRI_BUILD */ GR_STATE_ENTRY(grRenderBuffer, void, (GrBuffer_t buffer)) { #define FN_NAME "_grRenderBuffer" diff --git a/glide3x/h3/glide3/src/gglide.c.save b/glide3x/h3/glide3/src/gglide.c.save deleted file mode 100644 index d866a00..0000000 --- a/glide3x/h3/glide3/src/gglide.c.save +++ /dev/null @@ -1,3129 +0,0 @@ -/* -** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY -** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT -** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX -** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE -** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). -** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER -** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A -** FULL TEXT OF THE NON-WARRANTY PROVISIONS. -** -** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO -** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN -** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013, -** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR -** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF -** THE UNITED STATES. -** -** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED -** -** $Header$ -** $Log$ -** Revision 1.1.1.1 1999/11/24 21:45:02 joseph -** Initial checkin for SourceForge -** -** -** 6 5/12/99 10:39p Stb_gkincade -** Adding user support for turning on/off dither substraction -** -** 5 4/29/99 10:24a Atai -** fixed grDitherMode -** -** 4 4/06/99 3:54p Dow -** Alt tab again. -** -** 87 3/24/99 6:17p Peter -** streamlined (made more dangerouse) state validation -** -** 86 3/10/99 10:42a Peter -** bump-n-grind workaround for katmai until the bug is better -** characterized -** -** 85 3/05/99 10:31p Peter -** coalesced texture state change nop into validate state -** -** 84 3/02/99 2:03p Peter -** removed no_check variant that led me astray -** -** 83 2/18/99 3:27p Kcd -** Fixed direct register access, removed surface extension call for -** non-Win32. -** -** 82 2/11/99 1:38p Atai -** sync buffer swap pending code, the right way. -** -** 81 2/09/99 5:08p Atai -** fixed fog ext win coords that I broke in my previous check-in -** -** 80 2/02/99 4:39p Peter -** cleaned up wax commands -** -** 79 1/28/99 3:04p Atai -** fixed clip coord fog extension (c and asm version) -** -** 78 1/25/99 6:34p Peter -** _grDepthBufferFunction should not write to hw as an intermediary step -** -** 77 1/15/99 10:52a Peter -** cleanup lazy evaluation of fbzMode for grDepthMask and grColorMask -** -** 76 12/21/98 3:01p Peter -** cleaned up shutdow semantics -** -** 75 12/09/98 6:25p Atai -** grTexCombine did the right thing for the un-used TMU. Initialize the -** 2nd TMU value to take care of "set FX_GLIDE_NUM_TMU=1" -** -** 74 12/09/98 5:10p Atai -** set MAXLOD = MINLOD = 8 in _grUpdateParamIndex if ST1 is not used -** -** 73 12/09/98 3:59p Peter -** test20 state validation bug -** -** 72 12/07/98 4:42p Atai -** enable w is good enough for qx/q -** -** 71 12/05/98 2:51p Dow -** Fixed swapinterval -** -** 70 12/03/98 11:26p Dow -** Code 'cleanup' heheh -** -** 69 12/02/98 11:30a Dow -** Fixed effed-up size checking in gglide.c -** -** 68 11/30/98 6:57p Peter -** windowed texture f*ckage -** -** 67 11/18/98 6:34p Dow -** Fixed clear problem on v3/banshee -** -** 66 11/17/98 4:27p Atai -** fixed gc->triSetupProc for clip coords grDrawTriangle -** -** 65 11/15/98 3:21a Atai -** first attempt to make 2 tmus work in H4 glide3x full screen mode, just -** in time check-in for comdex demo. warning: the code is not completed -** yet. -** -** 64 11/02/98 5:34p Peter -** tls per thread for fullscreen contexts -** -** 63 10/30/98 3:45p Dow -** Fixed Tiled/Linear color/aux bug -** -** 62 10/08/98 10:29a Dow -** Fixes triple buffering -** -** 61 9/30/98 12:59p Atai -** use texchromakey and texchromarange shadow state -** -** 60 9/08/98 7:19p Atai -** fix debug info. added underline for internal routines and some \n -** -** 59 9/02/98 3:34p Atai -** fixed texturing transition bug -** -** 58 8/31/98 7:11p Atai -** fix clip coord tmu q param bug. send 1/w or Qn/w -** -** 57 8/30/98 1:34p Dow -** State & other optimizations -** -** 56 8/29/98 10:04p Peter -** sdram clear fixes -** -** 55 8/29/98 8:12p Dow -** Clip optimization -** -** 54 8/29/98 2:29p Peter -** call grSstWinClose w/ correct context parameter -** -** 53 8/27/98 9:54p Peter -** clear aux buffer w/ rgb not rbg -** -** 52 8/27/98 5:52p Jdt -** removed maxx maxy check from grClipwindow -** -** 51 8/27/98 1:55p Peter -** use converted color on sdram boards -** -** 50 8/26/98 3:01p Jdt -** tsuIndices may not be used to index p_str < debugging bug only > -** -** 49 8/18/98 1:44p Atai -** fixed "w param is turned off in clip space" -** -** 48 8/14/98 1:56p Atai -** fix fog coord bug -** -** 47 8/14/98 10:21a Dow -** Fixed fog for B silicon -** -** 46 8/06/98 8:04p Dow -** Fixed SDRAM for full-screen -** -** 45 8/06/98 7:50p Dow -** Fixed SDRAM stuff -** -** 43 8/05/98 11:46p Atai -** 1. grBufferSwap argument FxU32 -** 2. grGet return FxU32 -** -** 42 8/03/98 6:40a Jdt -** moved stats, curvertexsize, curtrisize into gc from global -** -** 41 7/18/98 1:45p Jdt -** Removed TACO_MEMORY_FIFO_HACK -** -** 40 7/18/98 12:27a Jdt -** Added shadowing of fog tables. Chagnes to reflect new shadow register -** structure. -** -** 39 7/17/98 2:04p Jdt -** Remove pointless SST_DRAWBUFFER bits. -** -** 38 7/16/98 8:18a Jdt -** Removed conditional screen clear for A1 -** -** fxcmd.h -** -** 37 7/02/98 1:55p Atai -** grDepthBiasLevel argument is FxI32 -** -** 36 7/01/98 12:40p Jdt -** Protected hacks for Glide/Win ( FX_TACO_MEMORY_FIFO_HACK ) -** -** 35 6/21/98 11:56a Atai -** fixed fogcoord paramindex -** -** 34 6/10/98 12:53p Atai -** replace grSstControl with grEnable/grDisable(GR_PASSTHRU) -** -** 33 6/09/98 11:59a Atai -** 1. update glide header -** 2. fix cull mode -** 3. fix tri stats -** -** 32 5/29/98 6:39p Atai -** fix chromarange -** -** 31 5/29/98 11:45a Atai -** 1.added _EXT for extension #defines. -** 2. change GR_TEXBASE_* values -** 3. Remove GR_TEXCHROMA_ENABLE_SUBSTITUTE_RGB -** -** 30 5/28/98 2:07p Peter -** banshee merge -** -** 29 5/27/98 9:52a Peter -** grBufferClear is constrained by clipping -** -** 28 5/21/98 7:15p Atai -** fix q0 and q1 for clip coords -** -** 27 5/19/98 2:00p Atai -** use GR_PARAM_Q for fbi w -** -** 26 5/15/98 4:02p Atai -** fogCoord and texchroma extension for Banshee -** -** 25 4/30/98 5:01p Peter -** first pass glide3 merge -** -** 23 4/22/98 4:57p Peter -** glide2x merge -** -** 22 4/21/98 1:34p Atai -** make 32 bit clean -** -** 21 3/23/98 6:34p Atai -** Fixed texture state validation bug in grColorCombine -** -** 20 3/21/98 11:31a Atai -** added GR_TRIANGLE_STRIP_CONTINUE and GR_TRIANGLE_FAN_CONTINUE -** -** 19 2/20/98 2:17p Peter -** shutting down hw should clear hwInit and open -** -** 18 2/17/98 5:07p Atai -** fixed packed a -** -** 17 2/17/98 12:40p Peter -** fog table fix -** -** 16 2/12/98 4:08p Atai -** casting value -** -** 15 2/12/98 3:40p Peter -** single buffering for opengl -** -** 14 2/12/98 3:05p Peter -** fixed naming change for glid3 -** -** 13 2/11/98 7:31p Peter -** blit clear vs grRenderBuffer -** -** 12 2/05/98 6:52p Atai -** fixed pargb vertex size -** -** 11 2/05/98 6:19p Atai -** lazy evaluate for grVertexLayout -** -** 10 1/30/98 4:21p Peter -** fixed old glide-ism -** -** 9 1/30/98 4:18p Peter -** sli/y-origin blit clear -** -** 8 1/30/98 1:19p Atai -** fixed chromarange -** -** 7 1/28/98 2:20p Atai -** fixed lfb state validation -** -** 6 1/23/98 3:07p Peter -** uswc nightmare -** -** 5 1/19/98 1:38p Atai -** fixed _grDrawLineStrip zero length lline -** -** 4 1/19/98 11:03a Atai -** remove assignment before validate the state -** -** 3 1/18/98 12:03p Atai -** sync to rev 17 spec - * - * 2 1/16/98 6:44p Atai - * fixed for glide 3 build - * - * 1 1/16/98 4:29p Atai - * create glide 3 src - * - * 137 1/15/98 1:12p Peter - * only one culler please - * - * 136 1/13/98 7:48p Atai - * fixed gu3dfGetInfo, grBufferClear, and GrState size - * - * 135 1/13/98 12:42p Atai - * fixed grtexinfo, grVertexLayout, and draw triangle - * - * 134 1/09/98 7:29p Atai - * fixed grBufferSwap for glide3 - * - * 133 1/08/98 9:25p Peter - * infinite recurrsion in debugging assert - * - * 132 1/08/98 9:23p Peter - * fixed macro effage - * - * 131 1/08/98 7:09p Peter - * real hw stuff modulo makefile change - * - * 130 1/08/98 4:58p Atai - * tex table broadcast, grVertexLayout enable/disable, stq, and some - * defines - * - * 129 1/07/98 5:22p Atai - * fixed grGet compiler error - * - * 128 1/07/98 10:22a Peter - * merged John's ooz fix - * - * 127 1/06/98 3:53p Atai - * remove grHint, modify grLfbWriteRegion and grGet - * - * 126 1/05/98 6:06p Atai - * glide extension stuff - * - * 125 12/22/97 12:40p Peter - * added new grColorCombine factor for OpenGL - * - * 124 12/18/97 2:13p Peter - * fogTable cataclysm - * - * 123 12/17/97 4:45p Peter - * groundwork for CrybabyGlide - * - * 122 12/17/97 4:06p Atai - * added grChromaRange(), grGammaCorrecionRGB(), grRest(), and grGet() - * functions - * - * 120 12/16/97 11:38a Atai - * added grChromaRange() - * - * 118 12/08/97 10:49a Atai - * rename some state variables - * - * 117 12/03/97 11:35a Peter - * reset for swapping - * - * 116 11/21/97 6:05p Atai - * use one datalist (tsuDataList) in glide3 - * - * 115 11/21/97 3:20p Peter - * direct writes tsu registers - * - * 114 11/18/97 6:11p Peter - * fixed glide3 effage - * - * 113 11/18/97 4:36p Peter - * chipfield stuff cleanup and w/ direct writes - * - * 112 11/18/97 3:27p Atai - * update vData - * optimize state monster - * - * 111 11/17/97 4:55p Peter - * watcom warnings/chipfield stuff - * - * 110 11/16/97 2:20p Peter - * cleanup - * - * 109 11/15/97 7:43p Peter - * more comdex silliness - * - * 108 11/14/97 5:02p Peter - * more comdex stuff - * - * 107 11/14/97 12:09a Peter - * comdex thing and some other stuff - * - * 106 11/13/97 4:39p Atai - * enable _grUpdateParamIndex for grGlideSetState - * - * 105 11/12/97 9:54p Peter - * fixed all the effage from new config - * - * 104 11/12/97 2:27p Peter - * - * 103 11/12/97 11:16a Peter - * cleaned up assertions - * - * 102 11/06/97 3:38p Dow - * More banshee stuff - * - * 101 11/04/97 5:59p Peter - * more of the same - * - * 100 11/03/97 3:43p Peter - * h3/cvg cataclysm - * - * 99 11/01/97 10:01a Peter - * tri dispatch stuff - * -** -*/ - -#include -#include <3dfx.h> -#include - -#define FX_DLL_DEFINITION -#include -#include - -#include "fxglide.h" -#include "fxcmd.h" -#include "fxinline.h" - -#include "rcver.h" -static char glideIdent[] = "@#%" VERSIONSTR ; - -#if GLIDE_HW_TRI_SETUP -static void -_grUpdateTriPacketHdr(FxU32 paramMask, - const GrCullMode_t mode); -#endif /* GLIDE_HW_TRI_SETUP */ - -/*--------------------------------------------------------------------------- -** grAlphaBlendFunction -** -** GMT: BUG if grColorMask() turns off alphaplanes then destination alpha -** blending wont work! -*/ - -GR_STATE_ENTRY(grAlphaBlendFunction, void, - (GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, - GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df)) -{ -#define FN_NAME "_grAlphaBlendFunction" - FxU32 alphamode; - GR_BEGIN_NOFIFOCHECK("_grAlphaBlendFunction", 85); - GDBG_INFO_MORE(gc->myLevel, "(%d,%d,%d,%d)\n", - rgb_sf, rgb_df, alpha_sf, alpha_df); - - /* Watcom warning suppressor */ - glideIdent[0] = glideIdent[0]; - - alphamode = gc->state.shadow.alphaMode; - if (alpha_sf != GR_BLEND_ONE && alpha_sf != GR_BLEND_ZERO) { - GR_CHECK_W(myName, 1, "unsupported alpha source blend function"); - alpha_sf = GR_BLEND_ONE; - } - - if (alpha_df != GR_BLEND_ONE && alpha_df != GR_BLEND_ZERO) { - GR_CHECK_W(myName, 1, "unsupported alpha destination blend function"); - alpha_df = GR_BLEND_ZERO; - } - - if (rgb_sf == GR_BLEND_ONE && rgb_df == GR_BLEND_ZERO && - alpha_sf == GR_BLEND_ONE && alpha_df == GR_BLEND_ZERO) - alphamode &= ~SST_ENALPHABLEND; - else - alphamode |= SST_ENALPHABLEND; - - alphamode &= ~(SST_RGBSRCFACT | SST_RGBDSTFACT | SST_ASRCFACT | SST_ADSTFACT); - - alphamode |= ((((FxU32) rgb_sf) << SST_RGBSRCFACT_SHIFT) | - (((FxU32) rgb_df) << SST_RGBDSTFACT_SHIFT) | - (((FxU32) alpha_sf) << SST_ASRCFACT_SHIFT) | - (((FxU32) alpha_df) << SST_ADSTFACT_SHIFT)); - - gc->state.shadow.alphaMode = alphamode; - -#if !GLIDE3 - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, alphaMode, alphamode); - GR_CHECK_SIZE(); -#endif -#undef FN_NAME -} /* grAlphaBlendFunction */ - -/*--------------------------------------------------------------------------- -** grAlphaCombine -*/ - -GR_STATE_ENTRY(grAlphaCombine, void, - (GrCombineFunction_t function, GrCombineFactor_t factor, - GrCombineLocal_t local, GrCombineOther_t other, FxBool invert)) -{ -#define FN_NAME "_grAlphaCombine" - FxU32 fbzColorPath; - - GR_BEGIN_NOFIFOCHECK("_grAlphaCombine",85); - GDBG_INFO_MORE(gc->myLevel,"(%d,%d,%d,%d,%d)\n",function,factor,local,other,invert); - GR_CHECK_W(myName, - function < GR_COMBINE_FUNCTION_ZERO || - function > GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA, - "unsupported alpha combine function"); - GR_CHECK_W(myName, - (factor & 0x7) < GR_COMBINE_FACTOR_ZERO || - (factor & 0x7) > GR_COMBINE_FACTOR_TEXTURE_ALPHA || - factor > GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA, - "unsupported alpha combine scale factor"); - - GR_CHECK_W(myName, - local < GR_COMBINE_LOCAL_ITERATED || local > GR_COMBINE_LOCAL_DEPTH, - "unsupported alpha combine local color"); - GR_CHECK_W(myName, - other < GR_COMBINE_OTHER_ITERATED || other > GR_COMBINE_OTHER_CONSTANT, - "unsupported alpha combine other color"); - - fbzColorPath = gc->state.shadow.fbzColorPath; - fbzColorPath &= ~(SST_ENTEXTUREMAP | - SST_ASELECT | - SST_ALOCALSELECT | - SST_CCA_ZERO_OTHER | - SST_CCA_SUB_CLOCAL | - SST_CCA_MSELECT | - SST_CCA_REVERSE_BLEND | - SST_CCA_ADD_CLOCAL | - SST_CCA_ADD_ALOCAL | - SST_CCA_INVERT_OUTPUT); - - /* setup reverse blending first, then strip off the the high bit */ - if ((factor & 0x8) == 0) - fbzColorPath |= SST_CCA_REVERSE_BLEND; - factor &= 0x7; - - /* NOTE: we use boolean OR instead of logical to avoid branches */ - gc->state.ac_requires_texture = ((factor == GR_COMBINE_FACTOR_TEXTURE_ALPHA) | - (other == GR_COMBINE_OTHER_TEXTURE)); - gc->state.ac_requires_it_alpha = ((local == GR_COMBINE_LOCAL_ITERATED) | - (other == GR_COMBINE_OTHER_ITERATED)); - - /* setup scale factor bits */ - fbzColorPath |= factor << SST_CCA_MSELECT_SHIFT; - - /* setup local color bits */ - fbzColorPath |= local << SST_ALOCALSELECT_SHIFT; - - /* setup other color bits */ - fbzColorPath |= other << SST_ASELECT_SHIFT; - - - /* setup invert output bits */ - if (invert) - fbzColorPath |= SST_CCA_INVERT_OUTPUT; - - /* setup core color combine unit bits */ - switch (function) { - case GR_COMBINE_FUNCTION_ZERO: - fbzColorPath |= SST_CCA_ZERO_OTHER; - break; - - case GR_COMBINE_FUNCTION_LOCAL: - case GR_COMBINE_FUNCTION_LOCAL_ALPHA: - fbzColorPath |= SST_CCA_ZERO_OTHER | SST_CCA_ADD_ALOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_OTHER: - break; - - case GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL: - case GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA: - fbzColorPath |= SST_CCA_ADD_ALOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL: - fbzColorPath |= SST_CCA_SUB_CLOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL: - case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA: - fbzColorPath |= SST_CCA_SUB_CLOCAL | SST_CCA_ADD_ALOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL: - case GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA: - fbzColorPath |= SST_CCA_ZERO_OTHER | SST_CCA_SUB_CLOCAL | SST_CCA_ADD_ALOCAL; - break; - } - - /* if either color or alpha combine requires texture then enable it */ - if (gc->state.cc_requires_texture || gc->state.ac_requires_texture) - fbzColorPath |= SST_ENTEXTUREMAP; - gc->state.shadow.fbzColorPath = fbzColorPath; - - GR_END(); -#undef FN_NAME -} /* grAlphaCombine */ - -/*--------------------------------------------------------------------------- -** grAlphaControlsITRGBLighting -** -** Determines whether the LSB of alpha controls what lighting is used-- -** Specifically whether grConstantColorValu or the interated RGB values are used -** during TEXTURE_TIMES_itrgb & TEXTURE_TIMES_ITRGB_DELTA0 color combine modes. -** -*/ - -GR_STATE_ENTRY(grAlphaControlsITRGBLighting, void, (FxBool enable)) -{ -#define FN_NAME "_grAlphaControlsITRGBLighting" - FxU32 fbzColorPath; - GR_BEGIN_NOFIFOCHECK("_grAlphaControlsITRGBLighting", 85); - GDBG_INFO_MORE(gc->myLevel, "(%d)\n", enable); - - fbzColorPath = gc->state.shadow.fbzColorPath; - if (enable) { - fbzColorPath |= SST_LOCALSELECT_OVERRIDE_WITH_ATEX; - } else { - fbzColorPath &= ~SST_LOCALSELECT_OVERRIDE_WITH_ATEX; - } - - gc->state.shadow.fbzColorPath = fbzColorPath; -#if !GLIDE3 - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, fbzColorPath, fbzColorPath); - GR_CHECK_SIZE(); -#endif /* !GLIDE3 */ -#undef FN_NAME -} /* grAlphaControlsITRGBLighting() */ - -/*--------------------------------------------------------------------------- -** grAlphaTestFunction -*/ - -GR_STATE_ENTRY(grAlphaTestFunction, void, (GrCmpFnc_t fnc)) -{ -#define FN_NAME "_grAlphaTestFunction" - FxU32 alphamode; - GR_BEGIN_NOFIFOCHECK("_grAlphaTestFunction", 85); - GDBG_INFO_MORE(gc->myLevel,"(%d)\n",fnc); - - alphamode = gc->state.shadow.alphaMode; - alphamode &= ~(SST_ALPHAFUNC | SST_ENALPHAFUNC); - if (fnc != GR_CMP_ALWAYS) - alphamode |= ((fnc << SST_ALPHAFUNC_SHIFT) | SST_ENALPHAFUNC); - - gc->state.shadow.alphaMode = alphamode; - -#if !GLIDE3 - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, alphaMode, alphamode); - GR_CHECK_SIZE(); -#endif /* !GLIDE3 */ -#undef FN_NAME -} /* grAlphaTestFunction */ - -/*--------------------------------------------------------------------------- -** grAlphaTestReferenceValue -*/ - -GR_STATE_ENTRY(grAlphaTestReferenceValue, void, (GrAlpha_t value)) -{ -#define FN_NAME "_grAlphaTestReferenceValue" - FxU32 alphamode; - GR_BEGIN_NOFIFOCHECK("_grAlphaTestReferenceValue", 85); - GDBG_INFO_MORE(gc->myLevel,"(%d)\n",value); - - alphamode = gc->state.shadow.alphaMode; - alphamode &= ~SST_ALPHAREF; - alphamode |= (((FxU32) value) << SST_ALPHAREF_SHIFT); - - gc->state.shadow.alphaMode = alphamode; - -#if !GLIDE3 - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, alphaMode, alphamode); - GR_CHECK_SIZE(); -#endif /* !GLIDE3 */ -#undef FN_NAME -} /* grAlphaTestReferenceValue */ - - - -static void -_grBufferClear2D(const FxU32 buffOffset, - const FxU32 clipLeft, const FxU32 clipTop, - const FxU32 width, const FxU32 height, - const FxU32 color) -{ -#define FN_NAME "_grBufferClear2D" - FxU32 /* Registers we use */ - clip0min, clip0max, dstBaseAddr, dstFormat, commandEx, colorFore, command; - FxU32 - regMask = 0L; - - GR_BEGIN_NOFIFOCHECK("_grBufferClear2D", 86); - -#define ADDWAXMASK(mask, reg, base) mask |= (1 << ((offsetof(SstGRegs, reg) - offsetof(SstGRegs, base)) >> 2)) - - ADDWAXMASK(regMask, clip0min, clip0min); - ADDWAXMASK(regMask, clip0max, clip0min); - ADDWAXMASK(regMask, dstBaseAddr, clip0min); - ADDWAXMASK(regMask, dstFormat, clip0min); - ADDWAXMASK(regMask, commandEx, clip0min); - - REG_GROUP_BEGIN_WAX(clip0min, 5, regMask); - - /* XXX USE CONSTANTS! */ - - /* Setup clipping rectangle based on top left origin */ - clip0min = ((clipTop << 16) | clipLeft); - clip0max = ((clipLeft + width) | ((clipTop + height) << 16)); - REG_GROUP_SET_WAX(gc->gRegs, clip0min, clip0min); - REG_GROUP_SET_WAX(gc->gRegs, clip0max, clip0max); - - /* Set buffer address and or in the tiled bit */ - dstBaseAddr = buffOffset | (1 << 31); - REG_GROUP_SET_WAX(gc->gRegs, dstBaseAddr, dstBaseAddr); - - /* Build up dstFormat (Should this be done globally?) */ - dstFormat = gc->strideInTiles; - dstFormat |= (0x3 << 16); - REG_GROUP_SET_WAX(gc->gRegs, dstFormat, dstFormat); - - /* Setup Command extra */ - commandEx = 0; - REG_GROUP_SET_WAX(gc->gRegs, commandEx, commandEx); - - REG_GROUP_END(); - - - regMask = 0L; - - ADDWAXMASK(regMask, colorFore, colorFore); - ADDWAXMASK(regMask, dstSize, colorFore); - ADDWAXMASK(regMask, dstXY, colorFore); - ADDWAXMASK(regMask, command, colorFore); - - REG_GROUP_BEGIN_WAX(colorFore, 4, regMask); - - /* Setup colorFore */ - colorFore = color; - REG_GROUP_SET_WAX(gc->gRegs, colorFore, colorFore); - - /* Setup dstSize - height/width */ - REG_GROUP_SET_WAX(gc->gRegs, dstSize, clip0max); - - /* Setup dstXY - starting coordinate */ - REG_GROUP_SET_WAX(gc->gRegs, dstXY, clip0min); - - /* Setup command */ - command = SSTG_RECTFILL; /* rectangle fill */ - command |= SSTG_GO; /* Initiate immediately */ - command |= 0xcc000000; /* Src ROP */ - - REG_GROUP_SET_WAX(gc->gRegs, command, command); - REG_GROUP_END(); -#undef FN_NAME -} /* _grBufferClear2D */ - - - -/*--------------------------------------------------------------------------- -** grBufferClear -*/ - -GR_ENTRY(grBufferClear, void, (GrColor_t color, GrAlpha_t alpha, FxU32 depth)) -{ -#define FN_NAME "grBufferClear" - GR_BEGIN_NOFIFOCHECK("grBufferClear", 86); - GDBG_INFO_MORE(gc->myLevel, "(0x%x,0x%x,0x%x)\n", color, alpha, depth); - - /* validate the state */ - if (gc->state.invalid) _grValidateState(); - - { - const GrColor_t oldc1 = gc->state.shadow.color1; - const FxU32 oldzacolor = gc->state.shadow.zaColor; - const FxU32 fbzMode = gc->state.shadow.fbzMode; - FxU32 zacolor = oldzacolor; - - FxBool doneP = FXFALSE; - FxBool doColorP, doAuxP = FXFALSE; - - /* validate the state */ - /* Setup source registers */ - doColorP = ((fbzMode & SST_RGBWRMASK) != 0); - if (doColorP) _grSwizzleColor(&color); - - if ((fbzMode & SST_ZAWRMASK) != 0) { - if ((fbzMode & SST_ENALPHABUFFER) != 0) { - doAuxP = FXTRUE; - - zacolor &= ~SST_ZACOLOR_ALPHA; - zacolor |= (((FxU32) alpha) << SST_ZACOLOR_ALPHA_SHIFT); - } else if ((fbzMode & SST_ENDEPTHBUFFER) != 0) { - doAuxP = FXTRUE; - - zacolor &= ~SST_ZACOLOR_DEPTH; - zacolor |= (((FxU32) depth) << SST_ZACOLOR_DEPTH_SHIFT); - } - } - - /* Why were we called? */ - if (!doColorP && !doAuxP) return; - - if (!doneP) { - if (!gc->bInfo->sdRAM && !gc->windowed) { - REG_GROUP_BEGIN(BROADCAST_ID, zaColor, 2, 0x41); - { - REG_GROUP_SET(hw, zaColor, zacolor); - REG_GROUP_SET(hw, c1, color); - } - REG_GROUP_END(); - - REG_GROUP_BEGIN(BROADCAST_ID, fastfillCMD, 3, 0x209); - { - /* Execute the FASTFILL command */ - REG_GROUP_SET(hw, fastfillCMD, 1); - - /* Restore C1 and ZACOLOR */ - REG_GROUP_SET(hw, zaColor, oldzacolor); - REG_GROUP_SET(hw, c1, oldc1); - } - REG_GROUP_END(); - } else { - const FxU32 colorBufMode = ((fbzMode & ~(SST_ZAWRMASK | SST_ENDEPTHBUFFER)) | - SST_RGBWRMASK | - SST_ENRECTCLIP); - - /* Turn off writes to the aux buffer */ - REG_GROUP_BEGIN(BROADCAST_ID, fbzMode, 1, 1); - REG_GROUP_SET(hw, fbzMode, colorBufMode); - REG_GROUP_END(); - - if (doColorP) { - /* Clear Color Buffer */ - REG_GROUP_BEGIN(BROADCAST_ID, c1, 1, 0x1); - REG_GROUP_SET(hw, c1, color); - REG_GROUP_END(); - - /* Execute the FASTFILL command */ - REG_GROUP_BEGIN(BROADCAST_ID, fastfillCMD, 1, 1); - REG_GROUP_SET(hw, fastfillCMD, 1); - REG_GROUP_END(); - } - - if (doAuxP) { - FxU32 - red, green, blue, convertedDepth; -#define GETRED(a) ((a >> 11) & 0x1f) -#define GETGREEN(a) ((a >> 5) & 0x3f) -#define GETBLUE(a) (a & 0x1f) - - /* Convert 16-bit depth to 24-bit, ready for truncation: - 20 10 0 - 321098765432109876543210 - RRRRR000GGGGGG00BBBBB000 - - So, we get the 565 out of 16-bit depth, then operate - like this: - - RED' = red << 3 - GREEN' = green << 2 - BLUE' = blue << 3 - - This way, when the fastFill hardware truncates, we - still have all the bits we were given. - - We then simply recombin RED', BLUE', and GREEN' to make - a 24-bit color value. - - capisce? - - */ - - red = GETRED(depth) << 3; - green = GETGREEN(depth) << 2; - blue = GETBLUE(depth) << 3; - - convertedDepth = ((red << 16) | (green << 8) | blue); - - /* Clear Aux Buffer */ - REG_GROUP_BEGIN(BROADCAST_ID, c1, 1, 0x1); - REG_GROUP_SET(hw, c1, convertedDepth); - REG_GROUP_END(); - - REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 2, 0x3); - REG_GROUP_SET(hw, colBufferAddr,gc->buffers[gc->grColBuf]); - REG_GROUP_SET(hw,colBufferStride,gc->state.shadow.auxBufferStride); - REG_GROUP_END(); - - REG_GROUP_BEGIN(BROADCAST_ID, fbzMode, 2, 0x21); - { - /* Write the depth buffer as if it were a color buffer, - * but w/ actual color buffer features - * (dithering/chroma/stipple) cleared so that the - * converted depth value does not get dorked along the - * way down the eerie pathways of banshee. - */ - REG_GROUP_SET(hw, fbzMode, colorBufMode & ~(SST_ENCHROMAKEY | - SST_ENSTIPPLE | - SST_ENDITHER)); - - /* Execute the FASTFILL command */ - REG_GROUP_SET(hw, fastfillCMD, 1); - } - REG_GROUP_END(); - } - - /* Restore trashed things */ - REG_GROUP_BEGIN(BROADCAST_ID, c1, 1, 0x1); - REG_GROUP_SET(hw, c1, oldc1); - REG_GROUP_END(); - - REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 2, 0x3); - REG_GROUP_SET(hw, colBufferAddr, gc->buffers[gc->windowed ? 0 : gc->curBuffer]); - REG_GROUP_SET(hw,colBufferStride,gc->state.shadow.colBufferStride); - REG_GROUP_END(); - - REG_GROUP_BEGIN(BROADCAST_ID, fbzMode, 1, 1); - REG_GROUP_SET(hw, fbzMode, fbzMode); - REG_GROUP_END(); - } - } - } -#undef FN_NAME -} /* grBufferClear */ - -#if 0 -/*--------------------------------------------------------------------------- -** grBufferClear -*/ - -GR_ENTRY(grBufferClear, void, (GrColor_t color, GrAlpha_t alpha, FxU32 depth)) -{ -#define FN_NAME "grBufferClear" - GR_BEGIN_NOFIFOCHECK("grBufferClear", 86); - GDBG_INFO_MORE(gc->myLevel, "(0x%x,0x%x,0x%x)\n", color, alpha, depth); - - /* validate the state */ - if (gc->state.invalid) - _grValidateState(); - - { - const GrColor_t - oldc1 = gc->state.shadow.color1; - const FxU32 - oldzacolor = gc->state.shadow.zaColor; - const FxU32 - fbzMode = gc->state.shadow.fbzMode; - FxU32 - zacolor = oldzacolor; - FxBool - doColorP = ((fbzMode & SST_RGBWRMASK) != 0), - doneP = FXFALSE, - doAuxP = FXFALSE; - - /* Setup source registers */ - if (doColorP) _grSwizzleColor(&color); - - if ((fbzMode & SST_ZAWRMASK) != 0) { - if ((fbzMode & SST_ENALPHABUFFER) != 0) { - doAuxP = FXTRUE; - - zacolor &= ~SST_ZACOLOR_ALPHA; - zacolor |= (((FxU32) alpha) << SST_ZACOLOR_ALPHA_SHIFT); - } else if ((fbzMode & SST_ENDEPTHBUFFER) != 0) { - doAuxP = FXTRUE; - - zacolor &= ~SST_ZACOLOR_DEPTH; - zacolor |= (((FxU32) depth) << SST_ZACOLOR_DEPTH_SHIFT); - } - } - - /* Why were we called? */ - if (!doColorP && !doAuxP) return; - - /* A2 and above have functioning fastfill */ - if (!doneP) { - REG_GROUP_BEGIN(BROADCAST_ID, zaColor, 2, 0x41); - { - REG_GROUP_SET(hw, zaColor, zacolor); - REG_GROUP_SET(hw, c1, color); - } - REG_GROUP_END(); - - REG_GROUP_BEGIN(BROADCAST_ID, fastfillCMD, 3, 0x209); - { - /* Execute the FASTFILL command */ - REG_GROUP_SET(hw, fastfillCMD, 1); - - /* Restore C1 and ZACOLOR */ - REG_GROUP_SET(hw, zaColor, oldzacolor); - REG_GROUP_SET(hw, c1, oldc1); - } - REG_GROUP_END(); - } - } -#undef FN_NAME -} /* grBufferClear */ -#endif - - -/*--------------------------------------------------------------------------- -** grBufferSwap -** -** NOTE: This routine should be COMPLETELY device-independant, -** but it isn't right now because we need to move all the -** code for the splash screen into the init library. -*/ - -GR_ENTRY(grBufferSwap, void, (FxU32 swapInterval)) -{ - static int hack=0; -#define FN_NAME "grBufferSwap" - GR_BEGIN_NOFIFOCHECK(FN_NAME,86); - GDBG_INFO_MORE(gc->myLevel,"(%d)\n",swapInterval); - - /* optionally display the 3Dfx powerfield logo overlay */ - if (_GlideRoot.environment.shamelessPlug) _grShamelessPlug(); - - /* check for environmental override */ - if (_GlideRoot.environment.swapInterval >= 0) { - swapInterval = _GlideRoot.environment.swapInterval; - } - - if (swapInterval) { - if (swapInterval > 1) - swapInterval = ((swapInterval - 1) << 1) | 1; /* Format for hw */ - } - - while(_grBufferNumPending() > 3); - - /* Cycle the buffer indices */ - { - const FxU32 numBufs = gc->state.num_buffers; - FxU32* bufPtrs[3]; - FxU32 i; - - bufPtrs[0] = &gc->curBuffer; - bufPtrs[1] = &gc->frontBuffer; - bufPtrs[2] = &gc->backBuffer; - - for(i = 0; i < sizeof(bufPtrs) / sizeof(*bufPtrs); i++) { - FxU32 curBufIndex = *bufPtrs[i] + 1; - if (curBufIndex == numBufs) curBufIndex = 0; - *bufPtrs[i] = curBufIndex; - } - } - -#if USE_PACKET_FIFO - { - int i, j = -1; - - for ( i = 0; i < MAX_BUFF_PENDING && j == -1; i++) { - if (gc->bufferSwaps[i] == 0xffffffff) { - gc->bufferSwaps[i] = - (FxU32) gc->cmdTransportInfo.fifoPtr - - (FxU32) gc->cmdTransportInfo.fifoStart; - j = i; - } - } - GR_ASSERT(j != -1); - - gc->swapsPending++; - - } -#endif - - REG_GROUP_BEGIN(BROADCAST_ID, leftOverlayBuf, 1, 0x1); - REG_GROUP_SET(hw, leftOverlayBuf, gc->buffers[gc->frontBuffer]); - REG_GROUP_END(); - - /* Just 0x1 for mask is OK here since we're writing one register */ - REG_GROUP_BEGIN(BROADCAST_ID, swapbufferCMD, 1, 0x1); - REG_GROUP_SET(hw, swapbufferCMD, swapInterval); - REG_GROUP_END(); - -#if defined( TACO_MEMORY_FIFO_HACK ) - _FifoFlush(); -#endif - - REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 1, 0x1); - REG_GROUP_SET(hw, colBufferAddr, gc->buffers[gc->curBuffer]); - REG_GROUP_END(); - -#ifdef GLIDE_DEBUG - { - if ((FxI32)_GlideRoot.environment.snapshot > 0) { - static char saveDBG[GDBG_MAX_LEVELS]; - int i; - - /* turn off tracing after frame 0 and the snapshot frame */ - if ((gc->stats.bufferSwaps == 0) || - (gc->stats.bufferSwaps == _GlideRoot.environment.snapshot + 3)) { - GDBG_PRINTF(FN_NAME": FX_SNAPSHOT (%ld)\n", gc->stats.bufferSwaps); - - for (i = 1; i < GDBG_MAX_LEVELS; i++) { - if (gc->stats.bufferSwaps == 0) saveDBG[i] = (char)GDBG_GET_DEBUGLEVEL(i); - GDBG_SET_DEBUGLEVEL(i, 0); - } - } - /* turn on tracing after the snapshot frame */ - if (gc->stats.bufferSwaps == _GlideRoot.environment.snapshot) { - GDBG_PRINTF(FN_NAME": FX_SNAPSHOT (%ld)\n", gc->stats.bufferSwaps); - - for (i = 1; i < GDBG_MAX_LEVELS; i++) { - GDBG_SET_DEBUGLEVEL(i, saveDBG[i]); - } - } - } - } -#endif /* GLIDE_DEBUG */ - - gc->stats.bufferSwaps++; - - GR_END(); -#undef FN_NAME -} /* grBufferSwap */ - -/*--------------------------------------------------------------------------- -** grBufferNumPending -*/ - -int FX_CSTYLE -_grBufferNumPending(void) -{ -#if USE_PACKET_FIFO - volatile FxU32 - dummy, - depth0, depth1, - readPtr0, readPtr1, readPtr; - volatile int - i; - int - pend; /* Num Swaps pending */ - - GR_DCL_GC; - - /* If we're not using hole counting then we need to make sure that - * any queued commands are actually flushed before checking the fifo - * ptr's location. - */ - if (!gc->cmdTransportInfo.autoBump) - GR_BUMP_N_GRIND; - - /* HACK HACK HACK */ - do { - readPtr0 = GET(gc->cRegs->cmdFifo0.readPtrL) - gc->cmdTransportInfo.fifoOffset; - dummy = GET(gc->ioRegs->status); - readPtr1 = GET(gc->cRegs->cmdFifo0.readPtrL) - gc->cmdTransportInfo.fifoOffset; - } while (readPtr0 != readPtr1); - - readPtr = readPtr1; - - if (readPtr == gc->lastSwapCheck) { - do { - depth0 = GET(gc->cRegs->cmdFifo0.depth); - depth1 = GET(gc->cRegs->cmdFifo0.depth); - } while (depth0 != depth1); - - if (depth0 == 0) { - for (i = 0; i < MAX_BUFF_PENDING; i++) - gc->bufferSwaps[i] = 0xffffffff; - gc->swapsPending = 0; - goto NPDONE; - } - } - - /* - ** There are two cases here: One where the read pointer has wrapped around - ** behind us, and one where it's ahead of us. - */ - if (readPtr < gc->lastSwapCheck) { /* We've wrapped */ - for (i = 0; i < MAX_BUFF_PENDING; i++) { - /* If it's between the last check and the end of the FIFO or between the - beginning of the FIFO and the current Read pointer, then it's gone - */ - if ( (gc->bufferSwaps[i] != 0xffffffff) && ( - (gc->bufferSwaps[i] >= gc->lastSwapCheck) || - (gc->bufferSwaps[i] <= readPtr)) ) { - --gc->swapsPending; - gc->bufferSwaps[i] = 0xffffffff; /* Free swap slot */ - } - } - } else { /* It's behind us */ - for (i = 0; i < MAX_BUFF_PENDING; i++) { - if ((gc->bufferSwaps[i] != 0xffffffff) && ( - (gc->bufferSwaps[i] >= gc->lastSwapCheck) && (gc->bufferSwaps[i] <= - readPtr))) { - --gc->swapsPending; - gc->bufferSwaps[i] = 0xffffffff; /* Free swap slot */ - } - } - } - - gc->lastSwapCheck = readPtr; - -NPDONE: - pend = gc->swapsPending; - GDBG_INFO(86,"grBufferNumPending() = %d\n", pend); - - return pend; -#else - return 0; -#endif -} /* grBufferNumPending */ - -/*--------------------------------------------------------------------------- -** grChromakeyMode -*/ - -GR_STATE_ENTRY(grChromakeyMode, void, (GrChromakeyMode_t mode)) -{ -#define FN_NAME "_grChromakeyMode" - FxU32 fbzMode; - GR_BEGIN_NOFIFOCHECK("_grChromakeyMode", 85); - GDBG_INFO_MORE(gc->myLevel, "(%d)\n", mode); - - fbzMode = gc->state.shadow.fbzMode; - if (mode == GR_CHROMAKEY_ENABLE) - fbzMode |= SST_ENCHROMAKEY; - else - fbzMode &= ~SST_ENCHROMAKEY; - - gc->state.shadow.fbzMode = fbzMode; -#undef FN_NAME -} /* grChromaKeyMode */ - -GR_STATE_ENTRY(grChromaMode, void, (GrChromaRangeMode_t mode)) -{ -#define FN_NAME "_grChromaMode" - FxU32 fbzMode, chromaRange; - GR_BEGIN_NOFIFOCHECK("_grChromaMode", 85); - GDBG_INFO_MORE(gc->myLevel, "(%d)\n", mode); - - fbzMode = gc->state.shadow.fbzMode; - chromaRange = gc->state.shadow.chromaRange; - if (mode == GR_CHROMARANGE_ENABLE_EXT) { - fbzMode |= SST_ENCHROMAKEY; - chromaRange |= SST_ENCHROMARANGE; - } - else if ((mode == GR_CHROMARANGE_DISABLE_EXT) && - (gc->state.stateArgs.grChromakeyModeArgs.mode == GR_CHROMAKEY_DISABLE)) { - fbzMode &= ~SST_ENCHROMAKEY; - chromaRange |= ~SST_ENCHROMARANGE; - } - else - chromaRange |= ~SST_ENCHROMARANGE; - - gc->state.shadow.fbzMode = fbzMode; - gc->state.shadow.chromaRange = chromaRange; -#undef FN_NAME -} /* grChromaMode */ - -/*--------------------------------------------------------------------------- -** _grClipNormalizeAndGenerateRegValues -** -** This routine normalizes clip variables to screen_width and -** screen_height, then generates the values to be written to the -** registers clipLeftRight and clipBottomTop. The reason for its -** existence is that BOTH grClipWindow() and grSstControl() need to -** write these registers. -*/ -void -_grClipNormalizeAndGenerateRegValues(FxU32 minx, FxU32 miny, FxU32 maxx, - FxU32 maxy, FxU32 *clipLeftRight, - FxU32 *clipBottomTop) -{ -#define FN_NAME "_grClipNormalizeAndGenerateRegValues" - GR_DCL_GC; - - GDBG_INFO(85, "%s: minx = %d, maxx = %d, miny = %d, maxy = %d\n", - FN_NAME, minx, maxx, miny, maxy); - - GR_CHECK_COMPATABILITY(FN_NAME, - ((minx > LONG_MAX) || (miny > LONG_MAX)), - "Negative min clip coordinate"); - - /* don't allow bogus clip coords!!! */ - if (maxx > gc->state.screen_width) maxx = gc->state.screen_width; - if (maxy > gc->state.screen_height) maxy = gc->state.screen_height; - if (minx > maxx) minx = maxx; - if (miny > maxy) miny = maxy; - - GDBG_INFO(85, "%s: normalized minx = %d, maxx = %d, miny = %d, maxy = %d\n", - FN_NAME, minx, maxx, miny, maxy); - - *clipLeftRight = (minx << SST_CLIPLEFT_SHIFT) | (maxx << SST_CLIPRIGHT_SHIFT); - *clipBottomTop = (miny << SST_CLIPBOTTOM_SHIFT) | (maxy << SST_CLIPTOP_SHIFT); - - GDBG_INFO(85, "%s: clipLeftRight = 0x%x, clipBottomTop = 0x%x\n", - FN_NAME, clipLeftRight, clipBottomTop); - -#undef FN_NAME -} /* _grClipNormalizeAndGenerateRegValues */ - -/*--------------------------------------------------------------------------- -** grClipWindow -*/ -GR_STATE_ENTRY(grClipWindow, void, (FxU32 minx, FxU32 miny, - FxU32 maxx, FxU32 maxy)) -{ -#define FN_NAME "_grClipWindow" - FxU32 - clipLeftRight, /* SST Clipping Registers */ - clipBottomTop; - - GR_BEGIN_NOFIFOCHECK("_grClipWindow",83); - GDBG_INFO_MORE(gc->myLevel,"(%d,%d %d,%d)\n",minx,miny,maxx,maxy); - - _grClipNormalizeAndGenerateRegValues(minx, miny, maxx, maxy, - &clipLeftRight, &clipBottomTop); - -#if !GLIDE3 - REG_GROUP_BEGIN(BROADCAST_ID, clipLeftRight, 2, 0x03); - { - REG_GROUP_SET(hw, clipLeftRight, clipLeftRight); - REG_GROUP_SET(hw, clipBottomTop, clipBottomTop); - } - REG_GROUP_END(); -#endif /* !GLIDE3 */ - - gc->state.shadow.clipLeftRight = clipLeftRight; - gc->state.shadow.clipBottomTop = clipBottomTop; - - gc->state.clipwindowf_xmin = (float) minx; - gc->state.clipwindowf_xmax = (float) maxx; - gc->state.clipwindowf_ymin = (float) miny; - gc->state.clipwindowf_ymax = (float) maxy; - - GR_END(); -#undef FN_NAME -} /* grClipWindow */ - -/*--------------------------------------------------------------------------- -** grColorCombine -*/ - -GR_STATE_ENTRY(grColorCombine, void, - (GrCombineFunction_t function, GrCombineFactor_t factor, - GrCombineLocal_t local, GrCombineOther_t other, FxBool invert)) -{ -#define FN_NAME "_grColorCombine" - FxU32 fbzColorPath; - - GR_BEGIN_NOFIFOCHECK("_grColorCombine",85); - GDBG_INFO_MORE(gc->myLevel,"(%d,%d,%d,%d,%d)\n",function,factor,local,other,invert); - - GR_CHECK_W(myName, - function < GR_COMBINE_FUNCTION_ZERO || - function > GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA , - "unsupported color combine function"); - - /* Starting w/ Voodoo^2 the ccu has texture RGB mode as well. */ - GR_CHECK_W(myName, - (factor & 0x7) < GR_COMBINE_FACTOR_ZERO || - (factor & 0x7) > GR_COMBINE_FACTOR_TEXTURE_RGB || - factor > GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA, - "unsupported color combine scale factor"); - GR_CHECK_W(myName, - local < GR_COMBINE_LOCAL_ITERATED || local > GR_COMBINE_LOCAL_DEPTH, - "unsupported color combine local color"); - GR_CHECK_W(myName, - other < GR_COMBINE_OTHER_ITERATED || other > GR_COMBINE_OTHER_CONSTANT, - "unsupported color combine other color"); - - fbzColorPath = gc->state.shadow.fbzColorPath; - fbzColorPath &= ~(SST_ENTEXTUREMAP | - SST_RGBSELECT | - SST_LOCALSELECT | - SST_CC_ZERO_OTHER | - SST_CC_SUB_CLOCAL | - SST_CC_MSELECT | - SST_CC_REVERSE_BLEND | - SST_CC_ADD_CLOCAL | - SST_CC_ADD_ALOCAL | - SST_CC_INVERT_OUTPUT); - - /* this is bogus, it should be done once, somewhere. */ - fbzColorPath |= SST_PARMADJUST; - - /* setup reverse blending first, then strip off the the high bit */ - if ((factor & 0x8) == 0) - fbzColorPath |= SST_CC_REVERSE_BLEND; - factor &= 0x7; - - /* NOTE: we use boolean OR instead of logical to avoid branches */ - gc->state.cc_requires_texture = ((factor == GR_COMBINE_FACTOR_TEXTURE_ALPHA) | - (factor == GR_COMBINE_FACTOR_TEXTURE_RGB) | - (other == GR_COMBINE_OTHER_TEXTURE)); - gc->state.cc_requires_it_rgb = ((local == GR_COMBINE_LOCAL_ITERATED) | - (other == GR_COMBINE_OTHER_ITERATED)); - - /* setup scale factor bits */ - fbzColorPath |= factor << SST_CC_MSELECT_SHIFT; - - /* setup local color bits */ - fbzColorPath |= local << SST_LOCALSELECT_SHIFT; - - /* setup other color bits */ - fbzColorPath |= other << SST_RGBSELECT_SHIFT; - - /* setup invert output bits */ - if (invert) - fbzColorPath |= SST_CC_INVERT_OUTPUT; - - /* setup core color combine unit bits */ - switch (function) { - case GR_COMBINE_FUNCTION_ZERO: - fbzColorPath |= SST_CC_ZERO_OTHER; - break; - - case GR_COMBINE_FUNCTION_LOCAL: - fbzColorPath |= SST_CC_ZERO_OTHER | SST_CC_ADD_CLOCAL; - break; - - case GR_COMBINE_FUNCTION_LOCAL_ALPHA: - fbzColorPath |= SST_CC_ZERO_OTHER | SST_CC_ADD_ALOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_OTHER: - break; - - case GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL: - fbzColorPath |= SST_CC_ADD_CLOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA: - fbzColorPath |= SST_CC_ADD_ALOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL: - fbzColorPath |= SST_CC_SUB_CLOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL: - fbzColorPath |= SST_CC_SUB_CLOCAL | SST_CC_ADD_CLOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA: - fbzColorPath |= SST_CC_SUB_CLOCAL | SST_CC_ADD_ALOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL: - fbzColorPath |= SST_CC_ZERO_OTHER | SST_CC_SUB_CLOCAL | SST_CC_ADD_CLOCAL; - break; - - case GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA: - fbzColorPath |= SST_CC_ZERO_OTHER | SST_CC_SUB_CLOCAL | SST_CC_ADD_ALOCAL; - break; - } - - /* if either color or alpha combine requires texture then enable it */ - if (gc->state.cc_requires_texture || gc->state.ac_requires_texture) - fbzColorPath |= SST_ENTEXTUREMAP; - gc->state.shadow.fbzColorPath = fbzColorPath; - - GR_END(); -#undef FN_NAME -} /* grColorCombine */ - -/* NB: These are only called when GLIDE_DEBUG is set for tracing */ -#if GLIDE_DEBUG -/*--------------------------------------------------------------------------- -** grDepthMask -*/ -GR_STATE_ENTRY(grDepthMask, void, (FxBool enable)) -{ -#define FN_NAME "_grDepthMask" - GR_BEGIN_NOFIFOCHECK("_grDepthMask", 85); - GDBG_INFO_MORE(gc->myLevel, "(%d)\n", enable); - - GR_CHECK_COMPATABILITY(FN_NAME, - (enable && (gc->grAuxBuf == 0)), - "Cannot enable depth buffer w/o allocating one"); -#undef FN_NAME -} /* grDepthMask */ - -/*--------------------------------------------------------------------------- -** grColorMask -*/ -GR_STATE_ENTRY(grColorMask, void, (FxBool rgb, FxBool alpha)) -{ -#define FN_NAME "_grColorMask" - GR_BEGIN_NOFIFOCHECK("_grColorMask", 85); - GDBG_INFO_MORE(gc->myLevel, "(0x%x,0x%x)\n", rgb, alpha); -#undef FN_NAME -} /* grColorMask */ - -/*--------------------------------------------------------------------------- -** grFogColorValue -*/ -GR_STATE_ENTRY(grFogColorValue, void, (GrColor_t color)) -{ -#define FN_NAME "_grFogColorValue" - GR_BEGIN_NOFIFOCHECK("_grFogColorValue", 85); - GDBG_INFO_MORE(gc->myLevel, "(0x%x)\n", color); - - _grSwizzleColor(&color); - - gc->state.shadow.fogColor = color; - -#if !GLIDE3 - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, fogColor, color); - GR_CHECK_SIZE(); -#endif /* !GLIDE3 */ -#undef FN_NAME -} /* grFogColorValue */ - -/*--------------------------------------------------------------------------- -** grDepthBiasLevel -** -** Sets the depth bias level. -*/ -GR_STATE_ENTRY(grDepthBiasLevel, void, (FxI32 level)) -{ -#define FN_NAME "_grDepthBiasLevel" - FxU32 zacolor; - GR_BEGIN_NOFIFOCHECK("_grDepthBiasLevel", 85); - GDBG_INFO_MORE(gc->myLevel,"(%d)\n",level); - - zacolor = gc->state.shadow.zaColor; - zacolor = (zacolor & ~SST_ZACOLOR_DEPTH) | ((FxI16)level & SST_ZACOLOR_DEPTH); - - gc->state.shadow.zaColor = zacolor; - -#if !GLIDE3 - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, zaColor, zacolor); - GR_CHECK_SIZE(); -#endif /* !GLIDE3 */ -#undef FN_NAME -} /* grDepthBiasLevel */ - -/*--------------------------------------------------------------------------- -** grChromaRange -*/ - -GR_STATE_ENTRY(grChromaRange, void, (GrColor_t max, GrChromaRangeMode_t mode)) -{ - FxU32 chromaRange; - GR_BEGIN_NOFIFOCHECK("_grChromakeyValue", 85); - GDBG_INFO_MORE(gc->myLevel, "(0x%x)\n", max); - GDBG_INFO_MORE(gc->myLevel, "(0x%x)\n", mode); - - chromaRange = gc->state.shadow.chromaRange & SST_ENCHROMARANGE; - _grSwizzleColor(&max); - gc->state.shadow.chromaRange = chromaRange | (max & 0x00ffffff) | (mode << 24); -} /* grChromaRange */ - -/*--------------------------------------------------------------------------- -** grChromakeyValue -*/ -GR_STATE_ENTRY(grChromakeyValue, void, (GrColor_t color)) -{ -#define FN_NAME "_grChromakeyValue" - GR_BEGIN_NOFIFOCHECK("_grChromakeyValue", 85); - GDBG_INFO_MORE(gc->myLevel, "(0x%x)\n", color); - - _grSwizzleColor(&color); - - gc->state.shadow.chromaKey = color; -#undef FN_NAME -} /* grChromaKeyValue */ - -#endif /* GLIDE_DEBUG */ - -/*--------------------------------------------------------------------------- -** grConstantColorValue -*/ - -GR_STATE_ENTRY(grConstantColorValue, void, (GrColor_t color)) -{ -#define FN_NAME "_grConstantColorValue" - GR_BEGIN_NOFIFOCHECK("_grConstantColorValue",85); - GDBG_INFO_MORE(gc->myLevel,"(0x%x)\n",color); - - _grSwizzleColor(&color); - -#if !GLIDE3 - REG_GROUP_BEGIN(BROADCAST_ID, c0, 2, 0x03); - { - REG_GROUP_SET(hw, c0, color); - REG_GROUP_SET(hw, c1, color); - } - REG_GROUP_END(); -#endif /* !GLIDE3 */ - - gc->state.shadow.color0 = color; - gc->state.shadow.color1 = color; - - GR_END(); -#undef FN_NAME -} /* grConstanColorValue */ - -/*--------------------------------------------------------------------------- -** grCullMode -** -** GMT: warning - gaa.c has the guts of this in-line -*/ - -GR_ENTRY(grCullMode, void, (GrCullMode_t mode)) -{ -#define FN_NAME "grCullMode" - GR_BEGIN_NOFIFOCHECK("grCullMode",85); - GDBG_INFO_MORE(gc->myLevel,"(%d)\n",mode); - gc->state.cull_mode = mode; - -#if GLIDE_HW_TRI_SETUP - _grUpdateTriPacketHdr(gc->cmdTransportInfo.paramMask, mode); -#endif /* GLIDE_HW_TRI_SETUP */ - - GR_END(); -#undef FN_NAME -} /* grCullMode */ - -/*--------------------------------------------------------------------------- -** grDepthBufferFunction -*/ - -GR_STATE_ENTRY(grDepthBufferFunction, void, (GrCmpFnc_t fnc)) -{ -#define FN_NAME "_grDepthBufferFunction" - FxU32 fbzMode; - - GR_BEGIN_NOFIFOCHECK("_grDepthBufferFunction",85); - GDBG_INFO_MORE(gc->myLevel,"(%d)\n",fnc); - - fbzMode = gc->state.shadow.fbzMode; - fbzMode &= ~SST_ZFUNC; - fbzMode |= (fnc << SST_ZFUNC_SHIFT); - - gc->state.shadow.fbzMode = fbzMode; - GR_END(); -#undef FN_NAME -} /* grDepthBufferFunction */ - -/*--------------------------------------------------------------------------- -** grDepthBufferMode -*/ - -GR_STATE_ENTRY(grDepthBufferMode, void, (GrDepthBufferMode_t mode)) -{ -#define FN_NAME "_grDepthBufferMode" - FxU32 fbzMode; - GR_BEGIN_NOFIFOCHECK("_grDepthBufferMode", 85); - GDBG_INFO_MORE(gc->myLevel, "(%d)\n", mode); - - /* This is fatal because they could stomp on the cmd fifo. */ - GR_CHECK_COMPATABILITY(FN_NAME, - (mode != GR_DEPTHBUFFER_DISABLE) && (gc->grAuxBuf == 0), - "cannot enable depth buffer w/o allocating one"); - - /* turn off all the bits and then turn them back on selectively */ - fbzMode = gc->state.shadow.fbzMode; - fbzMode &= ~(SST_ENDEPTHBUFFER | - SST_WBUFFER | - SST_ENZBIAS | - SST_ZCOMPARE_TO_ZACOLOR | - SST_DEPTH_FLOAT_SEL); - - switch (mode) { - case GR_DEPTHBUFFER_DISABLE: - break; - - case GR_DEPTHBUFFER_ZBUFFER: - fbzMode |= SST_ENDEPTHBUFFER | SST_ENZBIAS; - break; - - case GR_DEPTHBUFFER_WBUFFER: - /* - ** if fog coordinate is enabled, we need to enable floating point z buffer for w buffering - */ - fbzMode |= SST_ENDEPTHBUFFER | SST_WBUFFER | SST_ENZBIAS; - if (gc->state.vData.fogInfo.mode == GR_PARAM_ENABLE) - fbzMode |= SST_DEPTH_FLOAT_SEL; - break; - - case GR_DEPTHBUFFER_ZBUFFER_COMPARE_TO_BIAS: - fbzMode |= SST_ENDEPTHBUFFER | SST_ZCOMPARE_TO_ZACOLOR; - break; - - case GR_DEPTHBUFFER_WBUFFER_COMPARE_TO_BIAS: - fbzMode |= SST_ENDEPTHBUFFER | SST_WBUFFER | SST_ZCOMPARE_TO_ZACOLOR; - if (gc->state.vData.fogInfo.mode == GR_PARAM_ENABLE) - fbzMode |= SST_DEPTH_FLOAT_SEL; - break; - } - - /* - ** Update hardware and Glide state - */ - gc->state.shadow.fbzMode = fbzMode; - -#if !GLIDE3 - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, fbzMode, fbzMode); - GR_CHECK_SIZE(); - - _grUpdateParamIndex(); -#endif /* !GLIDE3 */ -#undef FN_NAME -} /* grDepthBufferMode */ - -/*--------------------------------------------------------------------------- -** No Comment -*/ -#ifdef GLIDE_DEBUG -static FxBool -_grCanSupportDepthBuffer(void) -{ - GR_DCL_GC; - if (gc->state.screen_height == 640) { - if (gc->fbuf_size == 1) { - return FXFALSE; - } - } else if (gc->state.screen_width == 800) { - if ((gc->fbuf_size == 1) || - (gc->fbuf_size == 2)) { - return FXFALSE; - } - } - return FXTRUE; -} /* _grCanSupportDepthBuffer */ -#endif - -/*--------------------------------------------------------------------------- -** grDisableAllEffects -*/ - -GR_ENTRY(grDisableAllEffects, void, (void)) -{ - GDBG_INFO(87,"grDisableAllEffects()\n"); - grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO); - grAlphaTestFunction(GR_CMP_ALWAYS); - grChromakeyMode(GR_CHROMAKEY_DISABLE); - grDepthBiasLevel(0); - grDepthBufferMode(GR_DEPTHBUFFER_DISABLE); - grFogMode(GR_FOG_DISABLE); -} /* grDisableAllEffects */ - -/*--------------------------------------------------------------------------- -** grDitherMode -*/ - -GR_STATE_ENTRY(grDitherMode, void, (GrDitherMode_t mode)) -{ -#define FN_NAME "_grDitherMode" - FxU32 fbzMode; - GR_BEGIN_NOFIFOCHECK("_grDitherMode", 85); - GDBG_INFO_MORE(gc->myLevel, "(%d)\n", mode); - - fbzMode = gc->state.shadow.fbzMode; - - /****************************************************************** - * 4/30/99 gregk - * Forcing dither rendering matrix to 2x2 - * Adding user support for turning on/off dither substraction - * According to Alpha Blending Quality Tab of control panel choices - * Optimal/Sharper -> disable dither subtraction - * Smoother -> enable dither subtraction - * (see also _GlideInitEnvironment() in gpci.c ) - ******************************************************************/ - - fbzMode &= ~(SST_ENDITHER | SST_DITHER2x2 | SST_ENDITHERSUBTRACT); - - switch (mode) { - case GR_DITHER_DISABLE: - break; - case GR_DITHER_2x2: - case GR_DITHER_4x4: - fbzMode |= (SST_ENDITHER | SST_DITHER2x2 | SST_ENDITHERSUBTRACT); - - if (_GlideRoot.environment.disableDitherSub == FXTRUE) - fbzMode &= ~(SST_ENDITHERSUBTRACT); - break; - } - - gc->state.shadow.fbzMode = fbzMode; - -#if !GLIDE3 - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, fbzMode, fbzMode); - GR_CHECK_SIZE(); -#endif /* !GLIDE3 */ -#undef FN_NAME -} /* grDitherMode */ - -/*--------------------------------------------------------------------------- -** grFogMode -*/ - -GR_STATE_ENTRY(grFogMode, void, (GrFogMode_t mode)) -{ -#define FN_NAME "_grFogMode" - FxU32 fogmode; - GR_BEGIN_NOFIFOCHECK("_grFogMode", 85); - GDBG_INFO_MORE(gc->myLevel,"(%d)\n",mode); - - fogmode = gc->state.shadow.fogMode; - fogmode &= ~(SST_ENFOGGING | - SST_FOGADD | - SST_FOGMULT | - SST_FOG_Z | - SST_FOG_CONSTANT); - - switch (mode & 0xFF) { /* switch based on lower 8 bits */ - case GR_FOG_DISABLE: - break; - - /* - ** disable in Glide 3. - */ -#if 0 - case GR_FOG_WITH_ITERATED_ALPHA: - fogmode |= (SST_ENFOGGING | SST_FOG_ALPHA); - break; -#endif - - /* - ** iterate perspective correct fog - */ - case GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT: - fogmode |= (SST_ENFOGGING); - break; - - case GR_FOG_WITH_ITERATED_Z: /* Bug 735 */ - fogmode |= (SST_ENFOGGING | SST_FOG_Z); - break; - - case GR_FOG_WITH_TABLE_ON_W: - fogmode |= (SST_ENFOGGING); - break; - } - if (mode & GR_FOG_MULT2) fogmode |= SST_FOGMULT; - if (mode & GR_FOG_ADD2) fogmode |= SST_FOGADD; - - /* GMT says that this should be enabled for CVG. It is always safe - * to enable these even when fogging is not enabled. - */ - fogmode |= (SST_FOG_DITHER | SST_FOG_ZONES); - - /* - ** Update the hardware and Glide state - */ - gc->state.shadow.fogMode = fogmode; - -#if !GLIDE3 - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, fogMode, fogmode); - GR_CHECK_SIZE(); - - _grUpdateParamIndex(); -#endif /* !GLIDE3 */ -#undef FN_NAME -} /* grFogMode */ - -/* -** grFogTable -*/ -GR_ENTRY(grFogTable, void, (const GrFog_t fogtable[])) -{ -#define FN_NAME "grFogTable" - int i = 0; - const int iend = (kInternalFogTableEntryCount >> 1); - const GrFog_t *locTable = fogtable; - - GR_BEGIN_NOFIFOCHECK("grFogTable",85); - GDBG_INFO_MORE(gc->myLevel,"(0x%x)\n",fogtable); - GR_ASSERT(fogtable != NULL); - - while(i < iend) { - REG_GROUP_LONG_BEGIN(BROADCAST_ID, fogTable[i], 32); - { - int j; - - for (j = 0; j < 32; j++) { - GrFog_t e0, e1, d0, d1; - FxU32 entry; - - e0 = locTable[0]; /* lower entry */ - e1 = locTable[1]; /* upper entry */ - d0 = ((e1 - e0) << 2); /* del0 in .2 format */ - d1 = (((i + j) == (iend - 1)) /* don't access beyond end of table */ - ? e1 - : locTable[2]); - d1 = (d1 - e1) << 2; /* del1 in .2 format */ - - entry = ((e1 << 24) | (d1 << 16) | (e0 << 8) | d0); - - gc->state.shadow.fogTable[i+j] = entry; - REG_GROUP_SET(hw, fogTable[i + j], entry ); - locTable += 2; - } - } - REG_GROUP_END(); - - i += 32; - } - GR_END(); -#undef FN_NAME -} /* grFogTable */ - -/*------------------------------------------------------------------- - Function: grGlideShutdown - Date: 3/16 - Implementor(s): dow, gmt, jdt - Library: Glide - Description: - Shutdown the Glide Library. Iterate through all hardware and - call grSstWinClose(). Call InitShutdown() which unmaps all - hardware from linear memory. - Arguments: - none - Return: - none - -------------------------------------------------------------------*/ - -GR_ENTRY(grGlideShutdown, void, (void)) -{ - if (!_GlideRoot.initialized) return; /* never made it thru startup */ - - /* GMT: reset the counter so we can proceed without assertions */ - { - GR_DCL_GC; - if (gc != NULL) gc->counter = gc->expected_counter = 0; - } - - { - int i; - - GDBG_INFO(80, "grGlideShutdown()\n"); - - for(i = 0; i < _GlideRoot.hwConfig.num_sst; i++) { - GrGC* gc = _GlideRoot.GCs + i; - - /* We can only do the fullscreen shutdown here if we actually did an open */ - if (gc->open) { - grSstSelect(i); - grSstWinClose((GrContext_t)gc); - } - } - - /* Force all fullscreen contexts to be closed */ - _GlideRoot.windowsInit = 0; - - /* If there are any surface contexts close them up now too */ - { - for(i = 0; i < MAX_NUM_CONTEXTS; i++) { - GrGC* gc = _GlideRoot.surfaceGCHeap[i]; - - if (gc != NULL) { - /* NB: We need to set the current thread's context before - * continuing so that any internal glide calls have a valid - * gc from tls via GR_DCL_GC. F*ck this up at your own peril. - */ - setThreadValue((FxU32)gc); -#if (GLIDE_PLATFORM & GLIDE_OS_WIN32) - /* Flush any remaining commands and cleanup any per gc state */ - grSurfaceReleaseContext((GrContext_t)gc); -#endif - } - } - } - } -} /* grGlideShutdown */ - - -/*------------------------------------------------------------------- - Function: _grFlushCommonStateRegs - Date: 14-Oct-97 - Implementor(s): dpc - Description: - Flushes all State Monster regs. If we're not doing Glide 3, - then it's still used by grGlideSetState() - Arguments: - - Return: - -------------------------------------------------------------------*/ -void -_grFlushCommonStateRegs() -{ -#define FN_NAME "_grFlushCommonStateRegs" - GR_BEGIN_NOFIFOCHECK(FN_NAME, 97); - - /* NB: This logical write must be split into two writes since the - * registers are non-contiguous (not good for packet 1) and are the - * register span is larget (greater than the 14 register mask size - * for packet 4). - */ - REG_GROUP_BEGIN(BROADCAST_ID, fbzColorPath, 11, 0x3C7F); - { - REG_GROUP_SET(hw, fbzColorPath, gc->state.shadow.fbzColorPath); - REG_GROUP_SET(hw, fogMode, gc->state.shadow.fogMode); - REG_GROUP_SET(hw, alphaMode, gc->state.shadow.alphaMode); - REG_GROUP_SET(hw, fbzMode, gc->state.shadow.fbzMode); - - REG_GROUP_SET(hw, lfbMode, gc->state.shadow.lfbMode); - REG_GROUP_SET(hw, clipLeftRight, gc->state.shadow.clipLeftRight); - REG_GROUP_SET(hw, clipBottomTop, gc->state.shadow.clipBottomTop); - /* nopCMD */ - - /* fastFillCmd */ - /* swapBufferCmd */ - REG_GROUP_SET(hw, fogColor, gc->state.shadow.fogColor); - REG_GROUP_SET(hw, zaColor, gc->state.shadow.zaColor); - - REG_GROUP_SET(hw, chromaKey, gc->state.shadow.chromaKey); - REG_GROUP_SET(hw, chromaRange, gc->state.shadow.chromaRange); - } - REG_GROUP_END(); - - REG_GROUP_BEGIN(BROADCAST_ID, stipple, 3, 0x07); - { - REG_GROUP_SET(hw, stipple, gc->state.shadow.stipple); - REG_GROUP_SET(hw, c0, gc->state.shadow.color0); - REG_GROUP_SET(hw, c1, gc->state.shadow.color1); - } - REG_GROUP_END(); - -#if GLIDE3 - gc->state.invalid = 0; -#endif /* GLIDE3 */ - - GR_END(); -#undef FN_NAME -} /* _grFlushCommonStateRegs */ - -/*--------------------------------------------------------------------------- -** grGlideSetState -*/ -GR_ENTRY(grGlideSetState, void, (const void *state)) -{ -#define FN_NAME "grGlideSetState" - GR_BEGIN_NOFIFOCHECK(FN_NAME, 87); - GDBG_INFO_MORE(gc->myLevel,"(0x%x)\n",state); - - GR_ASSERT(state != NULL); - - /* if texture mapping changed then we need to issue a NOP command*/ - { - const FxBool texChangeP = (((gc->state.shadow.fbzColorPath ^ - ((GrState*)state)->shadow.fbzColorPath) & SST_ENTEXTUREMAP) != 0); - if (texChangeP) { - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, nopCMD, 0); - GR_CHECK_SIZE(); - } - } - - /* copy all the state */ - gc->state = *((GrState *)state); - - /* Update the hardware state from the saved state. */ - _grFlushCommonStateRegs(); - - { - int tmu; - - for(tmu = 0; tmu < gc->num_tmu; tmu++) { - SstRegs* tmuregs = SST_TMU(hw, tmu); - const FifoChipField chipField = (FifoChipField)(0x02UL << tmu); - - /* Synch flush data w/ new state */ - gc->tmuMemInfo[tmu].postPacket[1] = ~gc->state.shadow.tmuState[tmu].texBaseAddr; - gc->tmuMemInfo[tmu].postPacket[5] = gc->state.shadow.tmuState[tmu].texBaseAddr; - - REG_GROUP_BEGIN(chipField, textureMode, 7, 0x7F); - { - REG_GROUP_SET(tmuregs, textureMode, gc->state.shadow.tmuState[tmu].textureMode); - REG_GROUP_SET(tmuregs, tLOD, gc->state.shadow.tmuState[tmu].tLOD); - REG_GROUP_SET(tmuregs, tDetail, gc->state.shadow.tmuState[tmu].tDetail); - REG_GROUP_SET(tmuregs, texBaseAddr, gc->state.shadow.tmuState[tmu].texBaseAddr); - - REG_GROUP_SET(tmuregs, texBaseAddr1, gc->state.shadow.tmuState[tmu].texBaseAddr_1); - REG_GROUP_SET(tmuregs, texBaseAddr2, gc->state.shadow.tmuState[tmu].texBaseAddr_2); - REG_GROUP_SET(tmuregs, texBaseAddr38, gc->state.shadow.tmuState[tmu].texBaseAddr_3_8); - } - REG_GROUP_END(); - - REG_GROUP_BEGIN(chipField, chromaKey, 2, 0x03); - { - REG_GROUP_SET(tmuregs, chromaKey, gc->state.shadow.tmuState[tmu].texchromaKey); - REG_GROUP_SET(tmuregs, chromaRange, gc->state.shadow.tmuState[tmu].texchromaRange); - } - REG_GROUP_END(); - } - } - - - /* NOTE: since glide state includes things like hints and all cached - * variables like paramIndex we needn't recompute these, BUT: we do - * need to rebuild stuff that depends on them!!! - */ - _grUpdateParamIndex(); - - GR_END(); -#undef FN_NAME -} /* grGlideSetState */ - -/*--------------------------------------------------------------------------- -** grRenderBuffer -** -** Although SST1 supports triple buffering, it's a hack in the hardware, -** and the only drawbuffer modes supported by the fbzMode register are 0 -** (back) and 1 (front) -*/ - -GR_STATE_ENTRY(grRenderBuffer, void, (GrBuffer_t buffer)) -{ -#define FN_NAME "_grRenderBuffer" - GR_BEGIN_NOFIFOCHECK(FN_NAME, 85); - GDBG_INFO_MORE(gc->myLevel,"(%d)\n",buffer); - GR_CHECK_F(myName, buffer >= GR_BUFFER_AUXBUFFER, "invalid buffer"); - - { - const FxU32 - oldBuffer = gc->curBuffer; - - gc->curBuffer = ((buffer == GR_BUFFER_FRONTBUFFER) - ? gc->frontBuffer - : gc->backBuffer); - if (oldBuffer != gc->curBuffer) { - REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 1, 0x1); - REG_GROUP_SET(hw, colBufferAddr, gc->buffers[gc->curBuffer]); - REG_GROUP_END(); - - gc->state.shadow.colBufferAddr = gc->buffers[gc->curBuffer]; - } - } - - GR_END(); -#undef FN_NAME -} /* grRenderBuffer */ - -GR_ENTRY(grCheckForRoom, void, (FxI32 n)) -{ -#define FN_NAME "grCheckForRoom" - GR_DCL_GC; - - /* dpc - 13 sep 1997 - FixMe! - * Setting one packet for now. - */ - GR_CHECK_FOR_ROOM(n, 1); -#undef FN_NAME -} - -/*--------------------------------------------------------------------------- -** _grUpdateParamIndex -** -** Updates the paramIndex bits based on Glide state and the hints. -** -*/ -GR_DDFUNC(_grUpdateParamIndex, void, (void)) -{ -#define FN_NAME "_grUpdateParamIndex" - GR_DCL_GC; - FxU32 paramIndex = 0; - const FxU32 fbzColorPath = gc->state.shadow.fbzColorPath; - const FxU32 fogMode = gc->state.shadow.fogMode; - const FxU32 fbzMode = gc->state.shadow.fbzMode; - - /* - ** First, turn on every bit that we think we need. We can prune them - ** back later. - */ - - /* Turn on the texture bits based on what grTexCombine set */ - if (fbzColorPath & SST_ENTEXTUREMAP) { - /* No matter what, we need oow from the main grvertex structure */ - static FxU32 paramI_array[] = { - /* 0 */ - STATE_REQUIRES_OOW_FBI, - - /* 1 */ - STATE_REQUIRES_OOW_FBI | - STATE_REQUIRES_W_TMU0 | STATE_REQUIRES_ST_TMU0, - - /* 2 */ - STATE_REQUIRES_OOW_FBI | - STATE_REQUIRES_W_TMU1 | STATE_REQUIRES_ST_TMU1, - - /* 3 */ - STATE_REQUIRES_OOW_FBI | - STATE_REQUIRES_W_TMU0 | STATE_REQUIRES_ST_TMU0 | - STATE_REQUIRES_W_TMU1 | STATE_REQUIRES_ST_TMU1, - - /* 4 */ - STATE_REQUIRES_OOW_FBI | - STATE_REQUIRES_W_TMU2 | STATE_REQUIRES_ST_TMU2, - - /* 5 */ - STATE_REQUIRES_OOW_FBI | - STATE_REQUIRES_W_TMU0 | STATE_REQUIRES_ST_TMU0 | - STATE_REQUIRES_W_TMU2 | STATE_REQUIRES_ST_TMU2, - - /* 6 */ - STATE_REQUIRES_OOW_FBI | - STATE_REQUIRES_W_TMU1 | STATE_REQUIRES_ST_TMU1 | - STATE_REQUIRES_W_TMU2 | STATE_REQUIRES_ST_TMU2, - - /* 7 */ - STATE_REQUIRES_OOW_FBI | - STATE_REQUIRES_W_TMU0 | STATE_REQUIRES_ST_TMU0 | - STATE_REQUIRES_W_TMU1 | STATE_REQUIRES_ST_TMU1 | - STATE_REQUIRES_W_TMU2 | STATE_REQUIRES_ST_TMU2, - }; - - GR_ASSERT(gc->state.tmuMask < sizeof(paramI_array) / sizeof(paramI_array[0])); - paramIndex |= paramI_array[gc->state.tmuMask]; - } - - /* See if we need iterated RGB */ - if (gc->state.cc_requires_it_rgb ) { - paramIndex |= STATE_REQUIRES_IT_DRGB; - } - - /* See if we need to iterate alpha based on the value of - ac_requires_it_alpha */ - if (gc->state.ac_requires_it_alpha) { - paramIndex |= STATE_REQUIRES_IT_ALPHA; - } - - /* See what fbzColorPath contributes - BUG 1084*/ - if (( fbzColorPath & SST_ALOCALSELECT ) == SST_ALOCAL_Z ) { - paramIndex |= STATE_REQUIRES_OOZ; - } - - /* See what fbzMode contributes */ - if (fbzMode & SST_ENDEPTHBUFFER) { - if (fbzMode & SST_WBUFFER) { - paramIndex |= STATE_REQUIRES_OOW_FBI; - /* - ** enable z iterator if we are using fog coordinate and w buffering - */ - if ((fogMode & SST_ENFOGGING) && (gc->state.vData.fogInfo.mode == GR_PARAM_ENABLE)) - paramIndex |= STATE_REQUIRES_OOZ; - } else { - paramIndex |= STATE_REQUIRES_OOZ; - } - } - - /* See what fogMode contributes */ - if (fogMode & SST_ENFOGGING) { - if (fogMode & SST_FOG_Z) { - paramIndex |= STATE_REQUIRES_OOZ; - } else { - paramIndex |= STATE_REQUIRES_OOW_FBI; - } - } - - /* - ** Now we know everything that needs to be iterated. Prune back - ** the stuff that isn't explicitly different - ** - ** NOTE: by GMT, STATE_REQUIRES_OOW_FBI is set whenever texture mapping - ** is enabled - */ -#if defined(GLIDE3) && (GLIDE3_ALPHA) - /* Turn off W for TMU0 if we don't have a hint */ - if (paramIndex & STATE_REQUIRES_W_TMU0) { - GR_ASSERT(paramIndex & STATE_REQUIRES_OOW_FBI); - if (gc->state.vData.fogInfo.mode == GR_PARAM_DISABLE) { - if (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS) { - if (gc->state.vData.q0Info.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_W_TMU0; - } - else { - if ((gc->state.vData.q0Info.mode == GR_PARAM_DISABLE) || - (gc->state.vData.wInfo.mode == GR_PARAM_DISABLE)) - paramIndex &= ~STATE_REQUIRES_W_TMU0; - } - } - else { - /* - ** win coords and no texturing - */ - if (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS) { - if ((gc->state.vData.q0Info.mode == GR_PARAM_DISABLE) && - (gc->state.vData.qInfo.mode == GR_PARAM_DISABLE)) - paramIndex &= ~STATE_REQUIRES_W_TMU0; - } - /* - ** clip coords and no texturing - */ - else { - if ((gc->state.vData.q0Info.mode == GR_PARAM_DISABLE) && - (gc->state.vData.wInfo.mode == GR_PARAM_DISABLE)) - paramIndex &= ~STATE_REQUIRES_W_TMU0; - } - } - } - - /* Turn off ST for TMU1 if TMU0 is active and TMU1 is not different */ - if (((paramIndex & (STATE_REQUIRES_ST_TMU0 | STATE_REQUIRES_ST_TMU1)) == - (STATE_REQUIRES_ST_TMU0 | STATE_REQUIRES_ST_TMU1)) && - gc->state.vData.st1Info.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_ST_TMU1; - - /* Turn off W for TMU1 if we have a previous W, and don't have a hint */ - if (paramIndex & STATE_REQUIRES_W_TMU1) { - if (gc->state.vData.fogInfo.mode == GR_PARAM_DISABLE) { - if (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS) { - if (gc->state.vData.q1Info.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_W_TMU1; - } - else { - if ((gc->state.vData.q1Info.mode == GR_PARAM_DISABLE) || - (gc->state.vData.wInfo.mode == GR_PARAM_DISABLE)) - paramIndex &= ~STATE_REQUIRES_W_TMU1; - } - } - else { - /* - ** win coords and no texturing - */ - if (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS) { - if ((gc->state.vData.q1Info.mode == GR_PARAM_DISABLE) && - (gc->state.vData.qInfo.mode == GR_PARAM_DISABLE)) - paramIndex &= ~STATE_REQUIRES_W_TMU1; - } - /* - ** clip coords and no texturing - */ - else { - if ((gc->state.vData.q1Info.mode == GR_PARAM_DISABLE) && - (gc->state.vData.wInfo.mode == GR_PARAM_DISABLE)) - paramIndex &= ~STATE_REQUIRES_W_TMU1; - } - } - } -#else - /* Turn off W for TMU0 if we don't have a hint */ - if (paramIndex & STATE_REQUIRES_W_TMU0) { - GR_ASSERT(paramIndex & STATE_REQUIRES_OOW_FBI); - if (!(hints & GR_STWHINT_W_DIFF_TMU0)) - paramIndex &= ~STATE_REQUIRES_W_TMU0; - } - - /* Turn off ST for TMU1 if TMU0 is active and TMU1 is not different */ - if (((paramIndex & (STATE_REQUIRES_ST_TMU0 | STATE_REQUIRES_ST_TMU1)) == - (STATE_REQUIRES_ST_TMU0 | STATE_REQUIRES_ST_TMU1)) && - !(hints & GR_STWHINT_ST_DIFF_TMU1)) - paramIndex &= ~STATE_REQUIRES_ST_TMU1; - - /* Turn off W for TMU1 if we have a previous W, and don't have a hint */ - if ((paramIndex & STATE_REQUIRES_W_TMU1) && !(hints & GR_STWHINT_W_DIFF_TMU1)) - paramIndex &= ~STATE_REQUIRES_W_TMU1; -#endif - -#if (GLIDE_NUM_TMU > 2) - /* Turn off ST for TMU1 if it's not different & any other is set up. */ - if ((paramIndex & (STATE_REQUIRES_ST_TMU0 | STATE_REQURES_ST_TMU1)) && - (paramIndex & STATE_REQUIRES_ST_TMU2) && - !(hints & GR_STWHINT_ST_DIFF_TMU2)) - paramIndex &= ~STATE_REQUIRES_ST_TMU2; - - /* Turn off W for TMU2 if we have a previous W, and don't have a hint */ - if ((paramIndex & STATE_REQUIRES_W_TMU2) && !(hints & GR_STWHINT_W_DIFF_TMU2)) - paramIndex &= ~STATE_REQUIRES_W_TMU2; -#endif - - /* - ** last check - */ - if (gc->state.vData.colorType == GR_U8) { - if (gc->state.vData.pargbInfo.mode == GR_PARAM_DISABLE) { - paramIndex &= ~STATE_REQUIRES_IT_ALPHA; - paramIndex &= ~STATE_REQUIRES_IT_DRGB; - } - } - else { - if (gc->state.vData.aInfo.mode == GR_PARAM_DISABLE) { - paramIndex &= ~STATE_REQUIRES_IT_ALPHA; - } - if (gc->state.vData.rgbInfo.mode == GR_PARAM_DISABLE) { - paramIndex &= ~STATE_REQUIRES_IT_DRGB; - } - } - if (gc->state.vData.fogInfo.mode == GR_PARAM_DISABLE) { - if (gc->state.vData.zInfo.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_OOZ; - if (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS) { - if (gc->state.vData.qInfo.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_OOW_FBI; - } - else { - if (gc->state.vData.wInfo.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_OOW_FBI; - } - } - else { - if (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS) { - if (gc->state.vData.qInfo.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_OOZ; - } - else { - if (gc->state.vData.wInfo.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_OOZ; - } - } - if (gc->state.vData.st0Info.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_ST_TMU0; - if (gc->state.vData.st1Info.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_ST_TMU1; - if (gc->state.vData.fogInfo.mode == GR_PARAM_DISABLE) { - if (gc->state.vData.q0Info.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_W_TMU0; - if (gc->state.vData.q1Info.mode == GR_PARAM_DISABLE) - paramIndex &= ~STATE_REQUIRES_W_TMU1; - } - - gc->state.paramIndex = paramIndex; - - _grRebuildDataList(); -#undef FN_NAME -} /* _grUpdateParamIndex */ - -#if defined(GLIDE_USE_ALT_REGMAP) -#define RED Fr_ALT -#define DRDX Fdrdx_ALT -#define DRDY Fdrdy_ALT -#define GRN Fg_ALT -#define DGDX Fdgdx_ALT -#define DGDY Fdgdy_ALT -#define BLU Fb_ALT -#define DBDX Fdbdx_ALT -#define DBDY Fdbdy_ALT -#define ALF Fa_ALT -#define DADX Fdadx_ALT -#define DADY Fdady_ALT -#define Z Fz_ALT -#define DZDX Fdzdx_ALT -#define DZDY Fdzdy_ALT -#define S Fs_ALT -#define DSDX Fdsdx_ALT -#define DSDY Fdsdy_ALT -#define T Ft_ALT -#define DTDX Fdtdx_ALT -#define DTDY Fdtdy_ALT -#define W Fw_ALT -#define DWDX Fdwdx_ALT -#define DWDY Fdwdy_ALT -#else -#define RED Fr -#define DRDX Fdrdx -#define DRDY Fdrdy -#define GRN Fg -#define DGDX Fdgdx -#define DGDY Fdgdy -#define BLU Fb -#define DBDX Fdbdx -#define DBDY Fdbdy -#define ALF Fa -#define DADX Fdadx -#define DADY Fdady -#define Z Fz -#define DZDX Fdzdx -#define DZDY Fdzdy -#define S Fs -#define DSDX Fdsdx -#define DSDY Fdsdy -#define T Ft -#define DTDX Fdtdx -#define DTDY Fdtdy -#define W Fw -#define DWDX Fdwdx -#define DWDY Fdwdy -#endif - -#if GLIDE_HW_TRI_SETUP -static void -_grUpdateTriPacketHdr(FxU32 paramMask, - const GrCullMode_t cullMode) -{ - GR_DCL_GC; - FxU32 sMode = ((cullMode != GR_CULL_DISABLE) - ? kSetupCullEnable - : kSetupPingPongDisable); - if (sMode != kSetupPingPongDisable) sMode |= ((cullMode == GR_CULL_POSITIVE) - ? kSetupCullPositive - : kSetupCullNegative); - -#define COLOR_COMP_ARGB ((SST_SETUP_RGB | SST_SETUP_A) << SSTCP_PKT3_PMASK_SHIFT) -#define COLOR_COMP_RGB (SST_SETUP_RGB << SSTCP_PKT3_PMASK_SHIFT) -#define COLOR_COMP_MASK COLOR_COMP_ARGB - - gc->cmdTransportInfo.paramMask = paramMask; - - /* Compute the common case packet 3 header which just needs - * the vertex count and strip/command type to be completed. - */ - gc->cmdTransportInfo.cullStripHdr = ((sMode << SSTCP_PKT3_SMODE_SHIFT) | - paramMask | - SSTCP_PKT3); - - /* Independent triangle hdr for grDrawTriangle */ - gc->cmdTransportInfo.triPacketHdr = (gc->cmdTransportInfo.cullStripHdr | - (0x3UL << SSTCP_PKT3_NUMVERTEX_SHIFT) | - SSTCP_PKT3_BDDBDD); - -#if GLIDE_TRI_CULLING - /* If we're doing sw culling for independent triangles then turn off - * the hw culling so we're consistent. HW culling, however, remains - * enabled for things using strips/fans. - */ - if (cullMode != GR_CULL_DISABLE) { - gc->cmdTransportInfo.triPacketHdr &= ~(kSetupCullEnable << SSTCP_PKT3_SMODE_SHIFT); - } -#endif /* GLIDE_TRI_CULLING */ -} -#endif /* GLIDE_HW_TRI_SETUP */ - -/*--------------------------------------------------------------------------- - * _grRebuildDataList - * - * NB: For CVG is *IMPERATIVE* that the writes to the parameter - * dataList remain in the order below otherwise the parameters - * will get written to the command packet in the wrong order. - */ -GR_DDFUNC(_grRebuildDataList, void, (void)) -{ -#define FN_NAME "_grRebuildDataList" - GR_DCL_GC; - GR_DCL_HW; - int curTriSize, params; - FxU32 i; - SstRegs *tmu0; - SstRegs *tmu1; - -#if GLIDE3 || GLIDE_PACKED_RGB - FxBool packedRGB = FXFALSE; -#endif /* GLIDE3 || GLIDE_PACKED_RGB */ - -#ifdef GLIDE_DEBUG - /* - tsuIndices aren't fixed, they are programmable, ..taco - static char *p_str[] = {"x","y","z","r","g","b","ooz","a","oow", - "s0","t0","w0","s1","t1","w1","s2","t2","w2"}; - */ -#endif /* GLIDE_DEBUG */ - - GDBG_INFO(85,"(s) paramIndex=0x%x\n", FN_NAME, gc->state.paramIndex); - - curTriSize = params = 0; - i = gc->state.paramIndex; -#ifdef GLIDE_USE_ALT_REGMAP - hw = SST_WRAP(hw,128); /* wrap 128-257 are ALTernate register mappings */ -#endif /* GLIDE_USE_ALT_REGMAP */ - - tmu0 = SST_CHIP(hw,0xE); /* tmu 0,1,2 */ - tmu1 = SST_CHIP(hw,0xC); /* tmu 1,2 */ - -#if GLIDE_HW_TRI_SETUP - gc->cmdTransportInfo.paramMask = 0x00; -#endif /* GLIDE_HW_TRI_SETUP */ - -#ifdef GLIDE3 - gc->state.vData.vSize = 8; /* XY * 3 */ - /* - ** make x, y default to 0 and 1 - */ - /* - gc->sDataList[sVtxSize++] = gc->state.vData.vertexInfo.offset + GR_VERTEX_OFFSET_X; - gc->sDataList[sVtxSize++] = gc->state.vData.vertexInfo.offset + GR_VERTEX_OFFSET_Y; - */ -#endif /* GLIDE3 */ - - if (i & STATE_REQUIRES_IT_DRGB) { -#if GLIDE_HW_TRI_SETUP && !defined(GLIDE3) - gc->cmdTransportInfo.paramMask |= SST_SETUP_RGB; - gc->tsuDataList[curTriSize + 0] = GR_VERTEX_R_OFFSET << 2; - - /* When using packed color we only add *ONE* item to the data list - * and this signals the entire color set since it is not possible - * to specify a single color component in any packet. - */ -#if !GLIDE_PACKED_RGB - gc->tsuDataList[curTriSize + 1] = GR_VERTEX_G_OFFSET << 2; - gc->tsuDataList[curTriSize + 2] = GR_VERTEX_B_OFFSET << 2; -#endif /* !GLIDE_PACKED_RGB */ -#elif defined(GLIDE3) - gc->cmdTransportInfo.paramMask |= SST_SETUP_RGB; - if (gc->state.vData.colorType == GR_FLOAT) { - gc->tsuDataList[curTriSize + 0] = gc->state.vData.rgbInfo.offset; - gc->tsuDataList[curTriSize + 1] = gc->state.vData.rgbInfo.offset + GR_COLOR_OFFSET_GREEN; - gc->tsuDataList[curTriSize + 2] = gc->state.vData.rgbInfo.offset + GR_COLOR_OFFSET_BLUE; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize + 0] = 2; - gc->tsuDataListScaler[curTriSize + 1] = 2; - gc->tsuDataListScaler[curTriSize + 2] = 2; -#endif - gc->state.vData.vSize += 12; /* RGB */ - } - else { - gc->tsuDataList[curTriSize + 0] = gc->state.vData.pargbInfo.offset; - packedRGB = FXTRUE; - gc->state.vData.vSize += 4; - } -#endif /* GLIDE_HW_TRI_SETUP */ - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - gc->regDataList[curTriSize + 0].i = GR_VERTEX_R_OFFSET << 2; - gc->regDataList[curTriSize + 1].i = GR_VERTEX_G_OFFSET << 2; - gc->regDataList[curTriSize + 2].i = GR_VERTEX_B_OFFSET << 2; - - gc->regDataList[curTriSize + 0].addr = (float*)&hw->RED; - gc->regDataList[curTriSize + 1].addr = (float*)&hw->GRN; - gc->regDataList[curTriSize + 2].addr = (float*)&hw->BLU; -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ - -#if GLIDE_PACKED_RGB -#if GLIDE3 -#if !GLIDE3_VERTEX_LAYOUT - if (gc->state.vData.colorType == GR_FLOAT) { -#else /* GLIDE3_VERTEX_LAYOUT */ - if (gc->state.vData.colorType == GR_FLOAT) { -#endif /* GLIDE3_VERTEX_LAYOUT */ - curTriSize += 3; - params += 3; - } else { - curTriSize += 1; - params += 1; - - packedRGB = FXTRUE; - } -#else /* !GLIDE3 */ - curTriSize += 1; - params += 1; - - packedRGB = FXTRUE; -#endif /* GLIDE3 */ -#else /* !GLIDE_PACKED_RGB */ - if (gc->state.vData.colorType == GR_FLOAT) { - curTriSize += 3; - params += 3; - } - else { - curTriSize += 1; - params += 1; - } -#endif /* !GLIDE_PACKED_RGB */ - } - - if (i & STATE_REQUIRES_IT_ALPHA) { -#if GLIDE_HW_TRI_SETUP && !defined(GLIDE3) - gc->cmdTransportInfo.paramMask |= SST_SETUP_A; - gc->tsuDataList[curTriSize + 0] = GR_VERTEX_A_OFFSET << 2; -#elif defined(GLIDE3) - gc->cmdTransportInfo.paramMask |= SST_SETUP_A; - if (gc->state.vData.colorType == GR_FLOAT) { - gc->tsuDataList[curTriSize] = gc->state.vData.aInfo.offset; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 2; -#endif - gc->state.vData.vSize += 4; - } - else if (!(i & STATE_REQUIRES_IT_DRGB)) { - packedRGB = FXTRUE; - gc->tsuDataList[curTriSize] = gc->state.vData.pargbInfo.offset; - gc->state.vData.vSize += 4; - } -#endif /* GLIDE_HW_TRI_SETUP */ - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - gc->regDataList[curTriSize + 0].i = GR_VERTEX_A_OFFSET << 2; - gc->regDataList[curTriSize + 0].addr = (float*)&hw->ALF; -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ - -#if GLIDE_HW_TRI_SETUP && !defined(GLIDE3) - curTriSize += 1; -#elif defined(GLIDE3) - if ((gc->state.vData.colorType == GR_FLOAT) || (!(i & STATE_REQUIRES_IT_DRGB))) - curTriSize += 1; -#endif /* GLIDE_HW_TRI_SETUP */ - -#if GLIDE_PACKED_RGB -#if GLIDE3 -#if !GLIDE3_VERTEX_LAYOUT - if (gc->state.vData.colorInfo.type == GR_FLOAT) { -#else /* GLIDE3_VERTEX_LAYOUT */ - if (gc->state.vData.colorType == GR_FLOAT) { -#endif /* GLIDE3_VERTEX_LAYOUT */ - params += 1; - } - else -#endif /* GLIDE3 */ - { - /* Only increment the parameter packet size if we have not already - * added the rgb fields. - */ - if ((i & STATE_REQUIRES_IT_DRGB) == 0) params += 1; - packedRGB = FXTRUE; - } -#else /* !GLIDE_PACKED_RGB */ - if ((gc->state.vData.colorType == GR_FLOAT) || !(i & STATE_REQUIRES_IT_DRGB)) - params += 1; -#endif /* !GLIDE_PACKED_RGB */ - } - - if (i & STATE_REQUIRES_OOZ) { -#if GLIDE_HW_TRI_SETUP && !defined(GLIDE3) - gc->tsuDataList[curTriSize + 0] = GR_VERTEX_OOZ_OFFSET << 2; - gc->cmdTransportInfo.paramMask |= SST_SETUP_Z; -#elif defined(GLIDE3) - /* - ** use z iterator for w if w buffering and fog coordinate enable - */ - if ((gc->state.shadow.fbzMode & SST_DEPTH_FLOAT_SEL) && - (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS)) { - gc->tsuDataList[curTriSize] = gc->state.vData.qInfo.offset; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 0; -#endif - } - else { - gc->tsuDataList[curTriSize] = gc->state.vData.zInfo.offset; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 1; -#endif - } - gc->cmdTransportInfo.paramMask |= SST_SETUP_Z; - - gc->state.vData.vSize += 4; -#endif /* GLIDE_HW_TRI_SETUP */ - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - gc->regDataList[curTriSize + 0].i = GR_VERTEX_OOZ_OFFSET << 2; - gc->regDataList[curTriSize + 0].addr = (float*)&hw->Z; -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ - - curTriSize += 1; - params += 1; - } - - /* we squeeze FBI.OOW in here for sequential writes in the simple case */ - if (i & STATE_REQUIRES_OOW_FBI) { -#if GLIDE_HW_TRI_SETUP && !defined(GLIDE3) - gc->tsuDataList[curTriSize + 0] = GR_VERTEX_OOW_OFFSET << 2; - gc->cmdTransportInfo.paramMask |= SST_SETUP_Wfbi; -#elif defined(GLIDE3) - /* - ** if fog coordinate is enabled, use w for fog coord - */ - if ((gc->state.vData.fogInfo.mode == GR_PARAM_ENABLE) && - (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS)) { - gc->tsuDataList[curTriSize] = gc->state.vData.fogInfo.offset; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 4; -#endif - } - else { - gc->tsuDataList[curTriSize] = gc->state.vData.qInfo.offset; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 0; -#endif - } - gc->cmdTransportInfo.paramMask |= SST_SETUP_Wfbi; - - gc->state.vData.vSize += 4; -#endif /* GLIDE_HW_TRI_SETUP */ - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - gc->regDataList[curTriSize + 0].i = GR_VERTEX_OOW_OFFSET << 2; - gc->regDataList[curTriSize + 0].addr = (float*)&hw->W; -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ - - curTriSize += 1; - params += 1; - } - -#if GLIDE_FP_CLAMP_TEX -#if !GLIDE_FP_CLAMP || !GLIDE_HW_TRI_SETUP -#error "Does not make sense to have GLIDE_FP_CLAMP_TEX w/o GLIDE_FP_CLAMP or GLIDE_HW_TRI_SETUP" -#endif /* !GLIDE_FP_CLAMP || !GLIDE_HW_TRI_SETUP */ - - /* Simplify the test for clamping only the texture parameters by - * sticking an extra empty slot into the data list. - * - * NB: This means that the code that runs through the parameter list - * needs to increment the datalist pointer before moving onto the - * texture parameters. - */ - gc->tsuDataList[curTriSize++] = 0; -#endif /* GLIDE_FP_CLAMP_TEX */ - - /* NOTE: this is the first */ - if (i & STATE_REQUIRES_W_TMU0) { -#if GLIDE_HW_TRI_SETUP && !defined(GLIDE3) - gc->tsuDataList[curTriSize + 0] = GR_VERTEX_OOW_TMU0_OFFSET << 2; - gc->cmdTransportInfo.paramMask |= SST_SETUP_W0; -#elif defined(GLIDE3) - /* - ** if q0 is disabled and fogCoord/Q(in clip coords) is enabled, we need to move oow to w0 - */ - if (gc->state.vData.q0Info.mode == GR_PARAM_ENABLE) { - gc->tsuDataList[curTriSize] = gc->state.vData.q0Info.offset; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 4; -#endif - } - else { - if (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS) - gc->tsuDataList[curTriSize] = gc->state.vData.qInfo.offset; - else - gc->tsuDataList[curTriSize] = gc->state.vData.wInfo.offset; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 0; -#endif - } - - gc->cmdTransportInfo.paramMask |= SST_SETUP_W0; - gc->state.vData.vSize += 4; -#endif /* GLIDE_HW_TRI_SETUP */ - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - gc->regDataList[curTriSize + 0].i = GR_VERTEX_OOW_TMU0_OFFSET << 2; - gc->regDataList[curTriSize + 0].addr = (float*)&tmu0->W; -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ - - curTriSize += 1; - params += 1; - } - - /* TMU0 --------------------------------- */ - /* always output to ALL chips, saves from having to change CHIP field */ - if (i & STATE_REQUIRES_ST_TMU0) { -#if GLIDE_HW_TRI_SETUP && !defined(GLIDE3) - gc->tsuDataList[curTriSize + 0] = GR_VERTEX_SOW_TMU0_OFFSET << 2; - gc->tsuDataList[curTriSize + 1] = GR_VERTEX_TOW_TMU0_OFFSET << 2; - gc->cmdTransportInfo.paramMask |= SST_SETUP_ST0; -#elif defined(GLIDE3) - gc->tsuDataList[curTriSize + 0] = gc->state.vData.st0Info.offset; - gc->tsuDataList[curTriSize + 1] = gc->state.vData.st0Info.offset - + GR_TEXTURE_OFFSET_T; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 3; - gc->tsuDataListScaler[curTriSize+1] = 3; -#endif - gc->cmdTransportInfo.paramMask |= SST_SETUP_ST0; - gc->state.vData.vSize += 8; -#endif /* GLIDE_HW_TRI_SETUP */ - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - gc->regDataList[curTriSize + 0].i = GR_VERTEX_SOW_TMU0_OFFSET << 2; - gc->regDataList[curTriSize + 1].i = GR_VERTEX_TOW_TMU0_OFFSET << 2; - gc->regDataList[curTriSize + 0].addr = (float*)&tmu0->S; - gc->regDataList[curTriSize + 1].addr = (float*)&tmu0->T; -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ - - curTriSize += 2; - params += 2; - } - - /* TMU1 --------------------------------- */ - if (i & STATE_REQUIRES_W_TMU1) { -#if GLIDE_HW_TRI_SETUP && !defined(GLIDE3) - gc->tsuDataList[curTriSize + 0] = GR_VERTEX_OOW_TMU1_OFFSET << 2; - gc->cmdTransportInfo.paramMask |= SST_SETUP_W1; -#elif defined(GLIDE3) - /* - ** if q1 is disabled and fogCoord/Q(in clip coords) is enabled, we need to move oow to w1 - */ - if (gc->state.vData.q1Info.mode == GR_PARAM_ENABLE) { - gc->tsuDataList[curTriSize] = gc->state.vData.q1Info.offset; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 4; -#endif - } - else { - if (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS) - gc->tsuDataList[curTriSize] = gc->state.vData.qInfo.offset; - else - gc->tsuDataList[curTriSize] = gc->state.vData.wInfo.offset; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 0; -#endif - } - gc->cmdTransportInfo.paramMask |= SST_SETUP_W1; - gc->state.vData.vSize += 4; -#endif /* GLIDE_HW_TRI_SETUP */ - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - gc->regDataList[curTriSize + 0].i = GR_VERTEX_OOW_TMU1_OFFSET << 2; - gc->regDataList[curTriSize + 0].addr = (float*)&tmu1->W; -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ - - curTriSize += 1; - params += 1; - - } - - if (i & STATE_REQUIRES_ST_TMU1) { -#if GLIDE_HW_TRI_SETUP && !defined(GLIDE3) - gc->tsuDataList[curTriSize + 0] = GR_VERTEX_SOW_TMU1_OFFSET << 2; - gc->tsuDataList[curTriSize + 1] = GR_VERTEX_TOW_TMU1_OFFSET << 2; - gc->cmdTransportInfo.paramMask |= SST_SETUP_ST1; -#elif defined(GLIDE3) - gc->tsuDataList[curTriSize + 0] = gc->state.vData.st1Info.offset; - gc->tsuDataList[curTriSize + 1] = gc->state.vData.st1Info.offset + GR_TEXTURE_OFFSET_T; -#ifdef GLIDE3_SCALER - gc->tsuDataListScaler[curTriSize] = 3; - gc->tsuDataListScaler[curTriSize+1] = 3; -#endif - gc->cmdTransportInfo.paramMask |= SST_SETUP_ST1; - gc->state.vData.vSize += 8; -#endif /* GLIDE_HW_TRI_SETUP */ - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - gc->regDataList[curTriSize + 0].i = GR_VERTEX_SOW_TMU1_OFFSET << 2; - gc->regDataList[curTriSize + 0].addr = (float*)&tmu1->S; - gc->regDataList[curTriSize + 1].i = GR_VERTEX_TOW_TMU1_OFFSET << 2; - gc->regDataList[curTriSize + 1].addr = (float*)&tmu1->T; -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ - - curTriSize += 2; - params += 2; - } - -#ifdef GLIDE_VERTEX_TABLE - { - FxU32 vsize = 0; - for (i = 0; i < 16; i++) { - gc->state.vTable[i] = vsize; - vsize += gc->state.vData.vSize; - } - } -#endif - -#if (GLIDE_NUM_TMU > 2) -#error "GLIDE_NUM_TMU > 2: Write this code." -#endif - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - gc->regDataList[curTriSize].i = 0; /* terminate the list with 0,* */ -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ - -#if GLIDE_HW_TRI_SETUP - gc->tsuDataList[curTriSize] = 0; -#endif /* GLIDE_HW_TRI_SETUP */ - - curTriSize++; - -#if GLIDE_HW_TRI_SETUP - /* Per vertex size: (xy [required] + parameters) * param size (32 bit word) */ - gc->curVertexSize = ((2 + params) << 2); - - /* Packet size: 3 * vertex size */ - gc->curTriSize = (gc->curVertexSize << 1) + gc->curVertexSize; - - /* Shift the parameter mask to just write into the packet header. */ - GDBG_INFO(191, "CVG ParamMask: 0x%X\n", gc->cmdTransportInfo.paramMask); - gc->cmdTransportInfo.paramMask <<= SSTCP_PKT3_PMASK_SHIFT; - -#if GLIDE_PACKED_RGB || GLIDE3 - if (packedRGB) gc->cmdTransportInfo.paramMask |= SSTCP_PKT3_PACKEDCOLOR; -#endif /* GLIDE_PACKED_RGB || GLIDE3 */ - - /* Update common packet 3 headers */ - _grUpdateTriPacketHdr(gc->cmdTransportInfo.paramMask, gc->state.cull_mode); -#endif /* GLIDE_HW_TRI_SETUP */ - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - gc->regDataList[curTriSize].i = 1; - gc->regDataList[curTriSize].addr = (float*)&hw->FtriangleCMD; - - /* 6 X,Y values plus AREA = 7, plus parameters */ - _GlideRoot.paramCount = params; - _GlideRoot.curTriSize = (6 + curTriSize + (params << 1)) << 2; - - /* Need to know tri size without gradients for planar polygons */ - _GlideRoot.curTriSizeNoGradient = _GlideRoot.curTriSize - (params << 3); -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ - -#if GLIDE_FP_CLAMP_TEX - /* Stick one more 0 in the dataList so that the texture clamping - * loop does not go one more iteration. - */ - gc->tsuDataList[++curTriSize] = 0; -#endif /* GLIDE_FP_CLAMP_TEX */ - -#ifdef GDBG_INFO_ON -#if GLIDE_HW_TRI_SETUP - for (i = 0; gc->tsuDataList[i]; i++) { - GDBG_INFO(282," tsuDataList[%d] = %2d \n", - i, gc->tsuDataList[i] >> 2 ); - } -#endif /* GLIDE_HW_TRI_SETUP */ - -#if !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP - for (i = 0; gc->regDataList[i].i; i++) { - GDBG_INFO(282," dataList[%d] = %2d 0x%x [%s]\n", - i, gc->regDataList[i].i >> 2, gc->regDataList[i].addr, - p_str[gc->regDataList[i].i >> 2]); - } -#endif /* !GLIDE_HW_TRI_SETUP || !GLIDE_PACKET3_TRI_SETUP */ -#endif /* GDBG_INFO_ON */ - -#undef FN_NAME -} /* _grRebuildDataList */ - -#if GLIDE_MULTIPLATFORM -/* - _grInitializeGCFuncs - initialize the gcFuncs Structure for this - device. -*/ -GR_DDFUNC(_grInitializeGCFuncs, void, (GrGC *gc)) -{ - - gc->gcFuncs._grColorCombineDelta0Mode = (void *) - GR_DDNAME(_grColorCombineDelta0Mode); - gc->gcFuncs._grRebuildDataList = (void *) GR_DDNAME(_grRebuildDataList); - gc->gcFuncs._grTexDetailControl = (void *) GR_DDNAME(_grTexDetailControl); - gc->gcFuncs._grTexDownloadNccTable = (void *) - GR_DDNAME(_grTexDownloadNccTable); - gc->gcFuncs._grTexDownloadPalette = (void *) - GR_DDNAME(_grTexDownloadPalette); - gc->gcFuncs._gumpTexCombineFunction = (void *) - GR_DDNAME(_gumpTexCombineFunction); - gc->gcFuncs._grUpdateParamIndex = (void *) - GR_DDNAME(_grUpdateParamIndex); - gc->gcFuncs._trisetup = (void *) GR_DDNAME(_trisetup); - gc->gcFuncs._trisetup_nogradients = (void *) - GR_DDNAME(_trisetup_nogradients); - gc->gcFuncs.grAADrawLine = (void *) GR_DDNAME(grAADrawLine); - gc->gcFuncs.grAADrawPoint = (void *) GR_DDNAME(grAADrawPoint); - gc->gcFuncs.grAADrawPolygon = (void *) GR_DDNAME(grAADrawPolygon); - gc->gcFuncs.grAADrawPolygonVertexList = (void *) - GR_DDNAME(grAADrawPolygonVertexList); - gc->gcFuncs.grAADrawTriangle = (void *) GR_DDNAME(grAADrawTriangle); - gc->gcFuncs.grAlphaBlendFunction = (void *) - GR_DDNAME(grAlphaBlendFunction); - gc->gcFuncs.grAlphaCombine = (void *) GR_DDNAME(grAlphaCombine); - gc->gcFuncs.grAlphaControlsITRGBLighting = (void *) - GR_DDNAME(grAlphaControlsITRGBLighting); - gc->gcFuncs.grAlphaTestFunction = (void *) - GR_DDNAME(grAlphaTestFunction); - gc->gcFuncs.grAlphaTestReferenceValue = (void *) - GR_DDNAME(grAlphaTestReferenceValue); - gc->gcFuncs.grBufferClear = (void *) GR_DDNAME(grBufferClear); - gc->gcFuncs.grBufferNumPending = (void *) - GR_DDNAME(grBufferNumPending); - gc->gcFuncs.grBufferSwap = (void *) GR_DDNAME(grBufferSwap); - gc->gcFuncs.grChromakeyMode = (void *) GR_DDNAME(grChromakeyMode); - gc->gcFuncs.grChromakeyValue = (void *) GR_DDNAME(grChromakeyValue); - gc->gcFuncs.grClipWindow = (void *) GR_DDNAME(grClipWindow); - gc->gcFuncs.grColorCombine = (void *) GR_DDNAME(grColorCombine); - gc->gcFuncs.grColorMask = (void *) GR_DDNAME(grColorMask); - gc->gcFuncs.grConstantColorValue = (void *) - GR_DDNAME(grConstantColorValue); - gc->gcFuncs.grConstantColorValue4 = (void *) - GR_DDNAME(grConstantColorValue4); - gc->gcFuncs.grCullMode = (void *) GR_DDNAME(grCullMode); - gc->gcFuncs.grDepthBiasLevel = (void *) GR_DDNAME(grDepthBiasLevel); - gc->gcFuncs.grDepthBufferFunction = (void *) - GR_DDNAME(grDepthBufferFunction); - gc->gcFuncs.grDepthBufferMode = (void *) GR_DDNAME(grDepthBufferMode); - - gc->gcFuncs.grDepthMask = (void *) GR_DDNAME(grDepthMask); - gc->gcFuncs.grDisableAllEffects = (void *) - GR_DDNAME(grDisableAllEffects); - gc->gcFuncs.grDitherMode = (void *) GR_DDNAME(grDitherMode); - gc->gcFuncs.grDrawLine = (void *) GR_DDNAME(grDrawLine); - gc->gcFuncs.grDrawPlanarPolygon = (void *) - GR_DDNAME(grDrawPlanarPolygon); - gc->gcFuncs.grDrawPlanarPolygonVertexList = (void *) - GR_DDNAME(grDrawPlanarPolygonVertexList); - gc->gcFuncs.grDrawPoint = (void *) GR_DDNAME(grDrawPoint); - gc->gcFuncs.grDrawPolygon = (void *) GR_DDNAME(grDrawPolygon); - gc->gcFuncs.grDrawPolygonVertexList = (void *) - GR_DDNAME(grDrawPolygonVertexList); - gc->gcFuncs.grDrawTriangle = (void *) GR_DDNAME(grDrawTriangle); - gc->gcFuncs.grFogColorValue = (void *) GR_DDNAME(grFogColorValue); - gc->gcFuncs.grFogMode = (void *) GR_DDNAME(grFogMode); - gc->gcFuncs.grFogTable = (void *) GR_DDNAME(grFogTable); - gc->gcFuncs.grGammaCorrectionValue = (void *) - GR_DDNAME(grGammaCorrectionValue); - gc->gcFuncs.grGlideSetState = (void *) GR_DDNAME(grGlideSetState); - gc->gcFuncs.grGlideShutdown = (void *) GR_DDNAME(grGlideShutdown); - gc->gcFuncs.grLfbConstantAlpha = (void *) - GR_DDNAME(grLfbConstantAlpha); - gc->gcFuncs.grLfbConstantDepth = (void *) - GR_DDNAME(grLfbConstantDepth); - gc->gcFuncs.grLfbLock = (void *)GR_DDNAME(grLfbLock); - gc->gcFuncs.grLfbUnlock = (void*)GR_DDNAME(grLfbUnlock); - gc->gcFuncs.grLfbWriteColorFormat = (void *) - GR_DDNAME(grLfbWriteColorFormat); - gc->gcFuncs.grLfbWriteColorSwizzle = (void *) - GR_DDNAME(grLfbWriteColorSwizzle); - gc->gcFuncs.grRenderBuffer = (void *) GR_DDNAME(grRenderBuffer); - gc->gcFuncs.grSstConfigPipeline = (void *) - GR_DDNAME(grSstConfigPipeline); - gc->gcFuncs.grSstIdle = (void *) GR_DDNAME(grSstIdle); - gc->gcFuncs.grSstIsBusy = (void *) GR_DDNAME(grSstIsBusy); - gc->gcFuncs.grSstOpen = (void *) GR_DDNAME(grSstOpen); - gc->gcFuncs.grSstOrigin = (void *) GR_DDNAME(grSstOrigin); - gc->gcFuncs.grSstPassthruMode = (void *) GR_DDNAME(grSstPassthruMode); - - gc->gcFuncs.grSstPerfStats = (void *) GR_DDNAME(grSstPerfStats); - gc->gcFuncs.grSstResetPerfStats = (void *) GR_DDNAME(grSstResetPerfStats); - gc->gcFuncs.grSstStatus = (void *) GR_DDNAME(grSstStatus); - gc->gcFuncs.grSstVRetraceOn = (void *) GR_DDNAME(grSstVRetraceOn); - gc->gcFuncs.grSstVideoLine = (void *) GR_DDNAME(grSstVideoLine); - gc->gcFuncs.grTexClampMode = (void *) GR_DDNAME(grTexClampMode); - gc->gcFuncs.grTexCombine = (void *) GR_DDNAME(grTexCombine); - gc->gcFuncs.grTexDownloadMipMapLevelPartial = (void *) - GR_DDNAME(grTexDownloadMipMapLevelPartial); - gc->gcFuncs.grTexFilterMode = (void *) GR_DDNAME(grTexFilterMode); - gc->gcFuncs.grTexLodBiasValue = (void *) GR_DDNAME(grTexLodBiasValue); - gc->gcFuncs.grTexMipMapMode = (void *) GR_DDNAME(grTexMipMapMode); - gc->gcFuncs.grTexMultibase = (void *) GR_DDNAME(grTexMultibase); - gc->gcFuncs.grTexMultibaseAddress = (void *) - GR_DDNAME(grTexMultibaseAddress); - gc->gcFuncs.grTexNCCTable = (void *) GR_DDNAME(grTexNCCTable); - gc->gcFuncs.grTexSource = (void *) GR_DDNAME(grTexSource); - gc->gcFuncs.guMPDrawTriangle = (void *) GR_DDNAME(guMPDrawTriangle); - gc->gcFuncs.guTexSource = (void *) GR_DDNAME(guTexSource); - gc->gcFuncs.ConvertAndDownloadRle=(void *) GR_DDNAME(ConvertAndDownloadRle); - gc->gcFuncs.grCheckForRoom=(void *) GR_DDNAME(grCheckForRoom); -} /* _grInitializeGCFuncs */ -#endif diff --git a/glide3x/h3/glide3/src/glfb.c.dri b/glide3x/h3/glide3/src/glfb.c similarity index 99% rename from glide3x/h3/glide3/src/glfb.c.dri rename to glide3x/h3/glide3/src/glfb.c index 7a2c675..0c9f2fe 100644 --- a/glide3x/h3/glide3/src/glfb.c.dri +++ b/glide3x/h3/glide3/src/glfb.c @@ -19,6 +19,9 @@ ** ** $Header$ ** $Log$ +** Revision 1.1.1.1 1999/11/24 21:45:02 joseph +** Initial checkin for SourceForge +** ** ** 4 4/06/99 3:54p Dow ** Alt tab again. @@ -211,7 +214,7 @@ #include "fxglide.h" #include "fxcmd.h" -#ifdef __linux__ +#if DRI_BUILD #include #endif @@ -450,7 +453,7 @@ GR_ENTRY(grLfbLock, FxBool,(GrLock_t type, GrBuffer_t buffer, } if (rv) { -#ifdef __linux__ +#if DRI_BUILD if (!colBufferIndex) info->strideInBytes = driInfo.stride; else @@ -481,7 +484,7 @@ GR_ENTRY(grLfbLock, FxBool,(GrLock_t type, GrBuffer_t buffer, GR_CHECK_SIZE(); info->lfbPtr = (void *)gc->lfb_ptr; -#ifdef __linux__ +#if DRI_BUILD info->strideInBytes = 0x1000; #endif diff --git a/glide3x/h3/glide3/src/glfb.c.save b/glide3x/h3/glide3/src/glfb.c.save deleted file mode 100644 index e8ef1d0..0000000 --- a/glide3x/h3/glide3/src/glfb.c.save +++ /dev/null @@ -1,952 +0,0 @@ -/* -** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY -** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT -** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX -** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE -** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). -** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER -** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A -** FULL TEXT OF THE NON-WARRANTY PROVISIONS. -** -** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO -** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN -** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013, -** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR -** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF -** THE UNITED STATES. -** -** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED -** -** $Header$ -** $Log$ -** -** 4 4/06/99 3:54p Dow -** Alt tab again. -** -** 25 4/04/99 8:51p Atai -** Partial check-in for alt-tab issue. set FX_GLIDE_ALT_TAB=1 to build -** glide3x with hwcQueryContext built into GR_BEGIN_NOFIFOCHECK. It works -** with DEBUG glide only. In the non-debug glide, we can still see the -** desktop corruption. -** -** 24 3/24/99 6:17p Peter -** streamlined (made more dangerouse) state validation -** -** 23 3/10/99 6:47p Peter -** need to bump-n-grind in lfb lock too, fixed nested lock error condition -** -** 22 3/08/99 4:28p Mikec -** Made sure when we return raw lfb ptr in a write lock (pix pipe is off), -** the origin is not lower left. -** -** 21 1/25/99 6:33p Peter -** removed some cruft I saw when cleaning up tiled textures -** -** 20 9/10/98 12:40p Mikec -** Changed grLfbLock to be in sync with glide2x. -** -** 19 9/08/98 7:19p Atai -** fix debug info. added underline for internal routines and some \n -** -** 18 9/01/98 9:59a Dow -** Fixed stride bug for 32-bit formats. -** -** 17 8/29/98 12:14p Mikec -** Changed grLfbLock to return the current buffer lfbptr (read ptr) if it -** is writeOnly and 565 and not pixelpipe. -** -** 15 8/11/98 7:22p Atai -** fix grLfbLock read only -** -** 14 7/18/98 1:45p Jdt -** Removed TACO_MEMORY_FIFO_HACK -** -** 13 7/18/98 12:28a Jdt -** Changes to reflect new shadow register structure. -** -** 12 7/16/98 8:18a Jdt -** fxcmd.h -** -** 11 7/01/98 12:41p Jdt -** Moved some code around to do proper flushing for lfb -** accesses -** Protected hacks for Glide/Win ( FX_TACO_MEMORY_FIFO_HACK ) -** Moved towards fixing lfb read on Banshee -** -** 10 6/10/98 11:58a Peter -** lfb tiled addressing -** -** 9 4/30/98 5:01p Peter -** first pass glide3 merge -** -** 7 4/22/98 4:57p Peter -** glide2x merge -** -** 6 4/21/98 1:34p Atai -** make 32 bit clean -** -** 5 2/01/98 7:52p Peter -** grLfbWriteRegion byte count problems -** -** 4 1/28/98 2:20p Atai -** fixed lfb state validation -** -** 3 1/22/98 10:35a Atai -** 1. introduce GLIDE_VERSION, g3\glide.h, g3\glideutl.h, g2\glide.h, -** g2\glideutl.h -** 2. fixed grChromaRange, grSstOrigin, and grGetProcAddress - * - * 2 1/16/98 6:44p Atai - * fixed for glide 3 build - * - * 1 1/16/98 4:29p Atai - * create glide 3 src - * - * 58 1/16/98 4:18p Atai - * fixed lfb and grLoadGammaTable - * - * 57 1/06/98 3:53p Atai - * remove grHint, modify grLfbWriteRegion and grGet - * - * 56 12/17/97 4:45p Peter - * groundwork for CrybabyGlide - * - * 55 12/15/97 6:04p Atai - * disable obsolete glide2 api for glide3 - * - * 54 12/15/97 5:54p Peter - * swizzle reads too - * - * 53 12/11/97 4:15p Peter - * mac lfb write region - * - * 52 12/01/97 5:18p Peter - * - * 51 11/25/97 12:09p Peter - * nested calls to grLfbLock vs init code locking on v2 - * - * 50 11/18/97 4:36p Peter - * chipfield stuff cleanup and w/ direct writes - * - * 49 11/17/97 4:55p Peter - * watcom warnings/chipfield stuff - * - * 48 11/06/97 3:38p Dow - * More banshee stuff - * - * 47 11/04/97 5:04p Peter - * cataclysm part deux - * - * 46 11/03/97 3:43p Peter - * h3/cvg cataclysm - * - * 45 10/27/97 11:10a Peter - * starting cleanup - * - * 44 10/09/97 8:02p Dow - * State Monster 1st Cut - * - * 43 10/08/97 5:18p Peter - * fixed grLfbLock wrt writemode_any - * - * 42 10/08/97 11:33a Peter - * hmmmm.... - * - * 41 9/30/97 1:03p Peter - * more debugging code - * - * 40 9/25/97 1:35p Peter - * - * 39 9/24/97 4:09p Peter - * lfb/idle fixes - * - * 38 9/24/97 1:31p Peter - * assert if grXX call inside lock/unlock - * - * 37 9/20/97 10:54a Peter - * naked lfb writes - * - * 36 9/15/97 7:31p Peter - * more cmdfifo cleanup, fixed normal buffer clear, banner in the right - * place, lfb's are on, Hmmmm.. probably more - * - * 35 9/10/97 10:13p Peter - * fifo logic from GaryT, non-normalized fp first cut - * - * 34 9/05/97 5:29p Peter - * changes for direct hw - * - * 33 9/04/97 3:32p Peter - * starting grouping serial reg writes - * - * 32 8/18/97 3:52p Peter - * pre-hw arrival fixes/cleanup - * - * 31 7/30/97 2:42p Peter - * more cleanup - * - * 30 7/28/97 2:41p Peter - * turned sli code back on for cvg, but waiting for hal - * - * 29 7/26/97 3:04p Peter - * gratuitous plug is translucent - * - * 28 7/02/97 12:28p Peter - * removed spurious NOP, tex dl - * - * 27 6/26/97 10:14a Peter - * cmd fifo for lfb - * - * 26 6/06/97 10:47a Peter - * texture downloading, fixed 640x480 dimension, changed cvg dep to be the - * same as sst1 - * -** -*/ -#include <3dfx.h> -#define FX_DLL_DEFINITION -#include -#include - -#include "fxglide.h" -#include "fxcmd.h" - -/*--------------------------------------------------------------------------- -** grLfbConstantAlpha -*/ -GR_ENTRY(grLfbConstantAlpha, void, (GrAlpha_t alpha)) -{ - GR_BEGIN_NOFIFOCHECK("grLfbConstantAlpha",82); - GDBG_INFO_MORE(gc->myLevel,"(0x%x)\n",alpha); - - gc->state.lfb_constant_alpha = alpha; - GR_END(); -} /* grLfbConstantAlpha */ - -/*--------------------------------------------------------------------------- -** grLfbConstantDepth -*/ -GR_ENTRY(grLfbConstantDepth, void, (FxU32 depth)) -{ - GR_BEGIN_NOFIFOCHECK("grLfbConstantDepth",82); - GDBG_INFO_MORE(gc->myLevel,"(0x%x)\n",depth); - - gc->state.lfb_constant_depth = depth; - GR_END(); -} /* grLfbConstantDepth */ - -/*------------------------------------------------------------------- - Function: grLfbLock - Date: 2/19 - Implementor(s): jdt - Library: Glide - Description: - Secures a pointer to a requested frame buffer and guarantees ordered - access to that buffer. - - Arguments: - type - type of lock, one of: - GR_LOCK_WRITE_ONLY - GR_LOCK_READ_ONLY - buffer - which buffer to lock, one of: - GR_BUFFER_FRONTBUFFER - GR_BUFFER_BACKBUFFER - GR_BUFFER_AUXBUFFER - writeMode - desired destination color format - origin - desired lfb origin - pixelPipeline - flag whether to process through pixpipe - info - pointer to info structure - Return: - FXTRUE - lock is successful - FXFALSE - lock fails - -------------------------------------------------------------------*/ - -GR_ENTRY(grLfbLock, FxBool,(GrLock_t type, GrBuffer_t buffer, - GrLfbWriteMode_t writeMode, GrOriginLocation_t origin, - FxBool pixelPipeline, GrLfbInfo_t *info)) -{ -#define FN_NAME "grLfbLock" - FxBool - rv = FXTRUE; - const FxBool - idleLockP = ((type & GR_LFB_NOIDLE) == 0); - FxU32 - lfbMode, - zaColor, - fbzMode; - - GR_BEGIN_NOFIFOCHECK_RET("grLfbLock", 82); - GDBG_INFO_MORE(gc->myLevel,"(%d,%d,0x%x)\n", type, buffer, info); - - GR_CHECK_COMPATABILITY(FN_NAME, !info, - "Null info structure passed."); - /* there is only one revision extant */ - GR_CHECK_COMPATABILITY(FN_NAME, info->size != sizeof(GrLfbInfo_t), - "uninitialized info structure passed."); - - type = type & ~(GR_LFB_NOIDLE); -#if defined(GLIDE3) - _grValidateState(); -#endif - - /* Load now flushed state */ - lfbMode = gc->state.shadow.lfbMode; - fbzMode = gc->state.shadow.fbzMode; - zaColor = gc->state.shadow.zaColor; - - type = type & ~(GR_LFB_NOIDLE); - if (gc->lockPtrs[type] != (FxU32)-1) { - GDBG_INFO(83, "Read lock failure due to existing lock"); - rv = FXFALSE; - } - - if (rv) { - switch(type) { - case GR_LFB_READ_ONLY: - lfbMode &= ~(SST_LFB_READBUFSELECT | - SST_LFB_YORIGIN); - - switch(buffer) { - case GR_BUFFER_FRONTBUFFER: - case GR_BUFFER_BACKBUFFER: - lfbMode |= SST_LFB_READCOLORBUFFER; - break; - - case GR_BUFFER_AUXBUFFER: - lfbMode |= SST_LFB_READDEPTHABUFFER; - break; - - default: - GR_CHECK_F(myName, - 1, - "illegal buffer parameter passed"); - rv = FXFALSE; - break; - } - - lfbMode |= (origin ? SST_LFB_YORIGIN : 0); - break; - - case GR_LFB_WRITE_ONLY: - /* Set up the constant depth register because it may have - * been trashed by a call to grDepthBiasLevel - * (depthbiaslevel and constant depth use the same register) - */ - zaColor = (((FxU32) gc->state.lfb_constant_depth) << SST_ZACOLOR_DEPTH_SHIFT); - zaColor |= (gc->state.lfb_constant_alpha << SST_ZACOLOR_ALPHA_SHIFT); - - /* disable depth biasing */ - fbzMode &= ~(SST_ENZBIAS); - - lfbMode &= ~(SST_LFB_YORIGIN | - SST_LFB_FORMAT | - SST_LFB_ENPIXPIPE); - - switch(writeMode) { - case GR_LFBWRITEMODE_RESERVED1: - case GR_LFBWRITEMODE_RESERVED2: - case GR_LFBWRITEMODE_RESERVED3: - case GR_LFBWRITEMODE_RESERVED4: - case GR_LFBWRITEMODE_RESERVED5: - case GR_LFBWRITEMODE_RESERVED6: - case GR_LFBWRITEMODE_RESERVED7: - rv = FXFALSE; - } - - /* Default to hw */ - if (writeMode == GR_LFBWRITEMODE_ANY) { - writeMode = ((buffer == GR_BUFFER_AUXBUFFER) - ? GR_LFBWRITEMODE_ZA16 - : GR_LFBWRITEMODE_565); - } - - switch(buffer) { - case GR_BUFFER_FRONTBUFFER: - case GR_BUFFER_BACKBUFFER: - rv = (writeMode != GR_LFBWRITEMODE_ZA16); - break; - - case GR_BUFFER_AUXBUFFER: - rv = (writeMode == GR_LFBWRITEMODE_ZA16); - break; - - default: - GR_CHECK_F(myName, 1, "illegal buffer parameter passed"); - break; - } - - lfbMode |= (writeMode << SST_LFB_FORMAT_SHIFT); - lfbMode |= (origin ? SST_LFB_YORIGIN : 0); - - if (pixelPipeline) { - lfbMode |= SST_LFB_ENPIXPIPE; - - fbzMode &= ~SST_YORIGIN; - fbzMode |= (origin ? SST_YORIGIN : 0); - } - info->writeMode = writeMode; - break; - - default: - rv = FXFALSE; - GDBG_INFO(gc->myLevel, "Lock failed because of invalid lock type."); - break; - } - } - - if (rv) { - const FxU32 - lockCount = gc->cmdTransportInfo.lfbLockCount; - - gc->lockPtrs[type] = buffer; - gc->cmdTransportInfo.lfbLockCount = 0x00UL; - - /* Setup the hw w/ the settings computed above. */ - switch(type) { - case GR_LFB_READ_ONLY: - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, lfbMode, lfbMode); - GR_CHECK_SIZE(); - break; - - case GR_LFB_WRITE_ONLY: - REG_GROUP_BEGIN(BROADCAST_ID, fbzMode, 3, 0x103); - { - REG_GROUP_SET(hw, fbzMode, fbzMode); - REG_GROUP_SET(hw, lfbMode, lfbMode); - REG_GROUP_SET(hw, zaColor, zaColor); - } - REG_GROUP_END(); - break; - } - gc->state.shadow.lfbMode = lfbMode; - - /* Get the current lfb buffer */ - { - /* FixMe: Is this true if we're triple buffering? */ - FxU32 colBufferIndex; - - switch(buffer) { - case GR_BUFFER_FRONTBUFFER: - colBufferIndex = gc->frontBuffer; - break; - - case GR_BUFFER_BACKBUFFER: - colBufferIndex = gc->backBuffer; - break; - - case GR_BUFFER_AUXBUFFER: - colBufferIndex = gc->grColBuf; - break; - - default: - GR_CHECK_F(myName, 1, "illegal buffer parameter passed"); - rv = FXFALSE; - break; - } - - if (rv) { - info->strideInBytes = 0x1000; - info->origin = origin; - - if (type == GR_LFB_READ_ONLY) { - info->lfbPtr = (void *)gc->lfbBuffers[colBufferIndex]; - } - /* Next, If it is writeOnly and 565 and not pixelpipe, - we just return the current buffer lfbPtr as the write ptr. - This fixes those games that use the lfb write pointer to do - lfb reads. --mikec */ - else if ((type == GR_LFB_WRITE_ONLY) && - (writeMode == GR_LFBWRITEMODE_565) && - (!pixelPipeline) && - /* Origin must be upper left since we will return raw lfb */ - (origin != GR_ORIGIN_LOWER_LEFT)){ - info->lfbPtr = (void *)gc->lfbBuffers[colBufferIndex]; - gc->state.shadow.colBufferAddr = gc->buffers[colBufferIndex]; - } else { - gc->state.shadow.colBufferAddr = gc->buffers[colBufferIndex]; - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, colBufferAddr, gc->buffers[colBufferIndex]); - GR_CHECK_SIZE(); - - info->lfbPtr = (void *)gc->lfb_ptr; - - switch (writeMode) { - case GR_LFBWRITEMODE_565_DEPTH: - case GR_LFBWRITEMODE_555_DEPTH: - case GR_LFBWRITEMODE_1555_DEPTH: - case GR_LFBWRITEMODE_888: - case GR_LFBWRITEMODE_8888: - info->strideInBytes <<= 1; - break; - } - } - - if (idleLockP) { - /* This is required to flush the write buffers before the - * actual LFB accesses. - */ - P6FENCE; - - /* If we're not using hole counting then we need to make sure that - * any queued commands are actually flushed before checking the fifo - * ptr's location. - */ - if (!gc->cmdTransportInfo.autoBump) - GR_BUMP_N_GRIND; - - grFinish(); - } - - /* Increment lock count */ - gc->cmdTransportInfo.lfbLockCount = lockCount + 1; - } - } - } - - GR_RETURN(rv); -#undef FN_NAME -} /* grLfbLock */ - -/*------------------------------------------------------------------- - Function: grLfbUnlock - Date: 2/21 - Implementor(s): jdt - Library: Glide - Description: - Unlock a previously locked buffer - Arguments: - type - type of lock (read only/write only) - buffer - which buffer to unlock - Return: - FXTRUE - success - FXFALSE - failure - -------------------------------------------------------------------*/ - -GR_ENTRY(grLfbUnlock, FxBool, (GrLock_t type, GrBuffer_t buffer)) -{ -#define FN_NAME "grLfbUnlock" - FxBool rval = FXFALSE; - - GR_BEGIN_NOFIFOCHECK_RET("grLfbUnLock", 83); - GDBG_INFO_MORE(gc->myLevel,"(%d, %d)\n", type, buffer); - - type = type & ~(GR_LFB_NOIDLE); - - GR_CHECK_COMPATABILITY(FN_NAME, - type != GR_LFB_WRITE_ONLY && - type != GR_LFB_READ_ONLY, - "Bad type"); - - GR_CHECK_COMPATABILITY(FN_NAME, - buffer != GR_BUFFER_FRONTBUFFER && - buffer != GR_BUFFER_BACKBUFFER && - buffer != GR_BUFFER_AUXBUFFER, - "Bad buffer"); - - rval = (gc->lockPtrs[type] == (FxU32)buffer); - if (rval) { - const FxU32 - lockCount = gc->cmdTransportInfo.lfbLockCount; - - /* Clear the current lfb lock state */ - gc->cmdTransportInfo.lfbLockCount = 0; - gc->lockPtrs[type] = (FxU32)-1; - - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, colBufferAddr, gc->buffers[gc->curBuffer]); - GR_CHECK_SIZE(); - gc->state.shadow.colBufferAddr = gc->buffers[gc->curBuffer]; - - if (type == GR_LFB_WRITE_ONLY) { - GR_SET_EXPECTED_SIZE(sizeof(FxU32) << 1, 2); - { - /* Restore depth bias level */ - GR_SET(BROADCAST_ID, hw, zaColor, gc->state.shadow.zaColor); - - /* turn back on depth biasing */ - GR_SET(BROADCAST_ID, hw, fbzMode, gc->state.shadow.fbzMode); - } - GR_CHECK_SIZE(); - } - - gc->cmdTransportInfo.lfbLockCount = lockCount - 1; - } - - GR_RETURN(rval); -#undef FN_NAME -} /* grLfbUnlock */ - - -#if GLIDE_DEBUG -/*--------------------------------------------------------------------------- -** grLfbWriteColorFormat -** -*/ - -GR_STATE_ENTRY(grLfbWriteColorFormat, void, (GrColorFormat_t colorFormat)) -{ -#define FN_NAME "_grLfbWriteColorFormat" - FxU32 lfbMode; - - GR_BEGIN_NOFIFOCHECK("_grLfbWriteColorFormat",82); - GDBG_INFO_MORE(gc->myLevel,"(%d)\n",colorFormat); - - GR_CHECK_F(myName, - colorFormat < 0 || colorFormat > 0x3, - "invalid color format"); - - lfbMode = gc->state.shadow.lfbMode; - lfbMode &= ~SST_LFB_RGBALANES; - lfbMode |= (colorFormat << SST_LFB_RGBALANES_SHIFT); - - gc->state.shadow.lfbMode = lfbMode; - - GR_END(); -#undef FN_NAME -} /* grLfbWriteColorFormat */ - - -/*--------------------------------------------------------------------------- -** grLfbWriteColorSwizzle - set up SST for byte swizzling and word swapping -** -** Registers/Bits Affected: -** lfbMode: bit(11), bit(12) -** -** WARNING: GMT: SST_LFB_WRITE_SWAP16 changes pixel addressing!!! -*/ -GR_STATE_ENTRY(grLfbWriteColorSwizzle, void, (FxBool swizzleBytes, FxBool swapWords)) -{ -#define FN_NAME "_grLfbWriteColorSwizzle" - FxU32 lfbMode; - - GR_BEGIN_NOFIFOCHECK("_grLfbWriteColorSwizzle",82); - GDBG_INFO_MORE(gc->myLevel,"(%d,%d)\n",swizzleBytes,swapWords); - - /* Clear out the bits we'll set back if appropriate */ - lfbMode = gc->state.shadow.lfbMode; - lfbMode &= ~(SST_LFB_WRITE_SWAP16 | SST_LFB_WRITE_BYTESWAP); - - if (swizzleBytes) - lfbMode |= SST_LFB_WRITE_BYTESWAP; - - if (swapWords) - lfbMode |= SST_LFB_WRITE_SWAP16; - - gc->state.shadow.lfbMode = lfbMode; - - GR_END(); -#undef FN_NAME -} /* grLfbWriteColorSwizzle */ -#endif /* GLIDE_DEBUG */ - -FxBool -_grLfbWriteRegion(FxBool pixPipelineP, - GrBuffer_t dst_buffer, FxU32 dst_x, FxU32 dst_y, - GrLfbSrcFmt_t src_format, - FxU32 src_width, FxU32 src_height, - FxI32 src_stride, const void *src_data) -{ -#define FN_NAME "_grLfbWriteRegion" - FxBool rv = FXTRUE; - GrLfbInfo_t info; - GrLfbWriteMode_t writeMode; - - GR_BEGIN_NOFIFOCHECK_RET("_grLfbWriteRegion", 82); - GDBG_INFO_MORE(gc->myLevel, - "(0x%x, %s, %d, %d, %d, %d, %d, %d, 0x%x)\n", - dst_buffer, - (pixPipelineP ? "Enable" : "Disable"), - dst_x, dst_y, - src_format, src_width, src_height, - src_stride, src_data); - - writeMode = ((src_format == GR_LFB_SRC_FMT_RLE16) - ? GR_LFBWRITEMODE_565 - : src_format); - - info.size = sizeof(info); - - if (grLfbLock(GR_LFB_WRITE_ONLY, - dst_buffer, - writeMode, - GR_ORIGIN_UPPER_LEFT, - pixPipelineP, - &info)) { - FxU32 *srcData; /* Tracking Source Pointer */ - FxU32 *dstData; /* Tracking Destination Pointer */ - FxU32 *end; /* Demarks End of each Scanline */ - FxI32 srcJump; /* bytes to next scanline */ - FxU32 dstJump; /* bytes to next scanline */ - FxU32 length; /* bytes to copy in scanline */ - FxU32 scanline; /* scanline number */ - int aligned; /* word aligned? */ - - - srcData = (FxU32 *) src_data; - dstData = (FxU32 *) (((char*)info.lfbPtr)+ (dst_y*info.strideInBytes)); - scanline = src_height; - - switch(src_format) { - /* 16-bit aligned */ - case GR_LFB_SRC_FMT_565: - case GR_LFB_SRC_FMT_555: - case GR_LFB_SRC_FMT_1555: - case GR_LFB_SRC_FMT_ZA16: - dstData = (FxU32*)(((FxU16*)dstData) + dst_x); - length = src_width * 2; - aligned = !((int)dstData&0x2); - srcJump = src_stride - length; - dstJump = info.strideInBytes - length; - if (aligned) { - while(scanline--) { - end = (FxU32*)((char*)srcData + length - 2); - while(srcData < end) { - SET(dstData[0], srcData[0]); - dstData++; - srcData++; - } - - if (((int)length) & 0x2) { - SET16((*(FxU16*)&(dstData[0])), - (*(FxU16*)&(srcData[0]))); - dstData = (FxU32*)(((FxU16*)dstData) + 1); - srcData = (FxU32*)(((FxU16*)srcData) + 1); - } - - dstData = (FxU32*)(((char*)dstData)+dstJump); - srcData = (FxU32*)(((char*)srcData)+srcJump); - } - } else { - while(scanline--) { - end = (FxU32*)((char*)srcData + length - 2); - - SET16((*(FxU16*)&(dstData[0])), - (*(FxU16*)&(srcData[0]))); - dstData = (FxU32*)(((FxU16*)dstData) + 1); - srcData = (FxU32*)(((FxU16*)srcData) + 1); - - while(srcData < end) { - SET(dstData[0], srcData[0]); - dstData++; - srcData++; - } - - if (!(length & 0x2)) { - SET16((*(FxU16*)&(dstData[0])), - (*(FxU16*)&(srcData[0]))); - dstData = (FxU32*)(((FxU16*)dstData) + 1); - srcData = (FxU32*)(((FxU16*)srcData) + 1); - } - - dstData = (FxU32*)(((char*)dstData)+dstJump); - srcData = (FxU32*)(((char*)srcData)+srcJump); - } - } - break; - - /* 32-bit aligned */ - case GR_LFB_SRC_FMT_888: - case GR_LFB_SRC_FMT_8888: - case GR_LFB_SRC_FMT_565_DEPTH: - case GR_LFB_SRC_FMT_555_DEPTH: - case GR_LFB_SRC_FMT_1555_DEPTH: - dstData = ((FxU32*)dstData) + dst_x; - length = src_width * 4; - srcJump = src_stride - length; - dstJump = info.strideInBytes - length; - while(scanline--) { - end = (FxU32*)((char*)srcData + length); - while(srcData < end) { - SET(dstData[0], srcData[0]); - dstData++; - srcData++; - } - dstData = (FxU32*)(((char*)dstData)+dstJump); - srcData = (FxU32*)(((char*)srcData)+srcJump); - } - break; - - case GR_LFB_SRC_FMT_RLE16: - /* needs to be implemented */ - rv = FXFALSE; - break; - } - grLfbUnlock(GR_LFB_WRITE_ONLY, dst_buffer); - } else { - rv = FXFALSE; - } - - GR_RETURN(rv); -#undef FN_NAME -} /* _grLfbWriteRegion */ - -/*------------------------------------------------------------------- - Function: grLfbWriteRegion - Date: 3/5 - Implementor(s): jdt - Library: Glide - Description: - Write a pixel rectangle to the frame buffer as efficiently as possible - Arguments: - dst_buffer - buffer to which to copy data - dst_x,dst_y - destination image start coordinates - src_format - data format of source image - src_width, src_height - - dimensions of source image - src_stride - stride of source image in bytes, not meaningful - for RLE images - src_data - pointer to source data memory - Return: - FXTRUE succeed - FXFALSE fail - -------------------------------------------------------------------*/ -#if defined(GLIDE3) && defined(GLIDE3_ALPHA) -GR_ENTRY(grLfbWriteRegion, FxBool, (GrBuffer_t dst_buffer, - FxU32 dst_x, FxU32 dst_y, - GrLfbSrcFmt_t src_format, - FxU32 src_width, FxU32 src_height, - FxBool pixelPipeline, - FxI32 src_stride, void *src_data)) -#else -GR_ENTRY(grLfbWriteRegion, FxBool, (GrBuffer_t dst_buffer, - FxU32 dst_x, FxU32 dst_y, - GrLfbSrcFmt_t src_format, - FxU32 src_width, FxU32 src_height, - FxI32 src_stride, void *src_data)) -#endif -{ - FxBool rv = FXTRUE; - - GR_BEGIN_NOFIFOCHECK_RET("grLfbWriteRegion",82); - GDBG_INFO_MORE(gc->myLevel, - "(0x%x,%d,%d,%d,%d,%d,%d,0x%x)\n", - dst_buffer, dst_x, dst_y, - src_format, src_width, src_height, - src_stride, src_data); - -#if defined(GLIDE3) && defined(GLIDE3_ALPHA) - if ((_GlideRoot.hwConfig.SSTs[_GlideRoot.current_sst].type == GR_SSTTYPE_SST96) && (pixelPipeline == FXTRUE)) - rv = FXFALSE; - else - rv = _grLfbWriteRegion(pixelPipeline, dst_buffer, dst_x, dst_y, - src_format, src_width, src_height, - src_stride, src_data); -#else - rv = _grLfbWriteRegion(FXFALSE, dst_buffer, dst_x, dst_y, - src_format, src_width, src_height, - src_stride, src_data); -#endif - - GR_RETURN(rv); -} /* grLfbWriteRegion */ - -/*------------------------------------------------------------------- - Function: grLfbReadRegion - Date: 3/12 - Implementor(s): jdt - Library: Glide - Description: - Grab a rectangle from the frame buffer into user supplied memory - Arguments: - src_buffer - buffer to read from - src_x - x coordinate of upper left corner rectangle to read - src_y - y coordinate of upper left corner of rectangle to read - src_width - width of rectangle to read - src_height - height of rectangle to read - dst_stride - distance between scanlines in destination buffer - dst_data - pointer to user memory in which to place image - Return: - FXTRUE - success - FXFALSE - failure - -------------------------------------------------------------------*/ -GR_ENTRY(grLfbReadRegion, FxBool, (GrBuffer_t src_buffer, - FxU32 src_x, FxU32 src_y, - FxU32 src_width, FxU32 src_height, - FxU32 dst_stride, void *dst_data)) -{ -#define FN_NAME "grLfbReadRegion" - FxBool rv = FXTRUE; - GrLfbInfo_t info; - - GR_BEGIN_NOFIFOCHECK_RET("grLfbReadRegion",82); - GDBG_INFO_MORE(gc->myLevel, - "(0x%x,%d,%d,%d,%d,%d,0x%x)\n", - src_buffer, src_x, src_y, - src_width, src_height, dst_stride, dst_data); - - info.size = sizeof(info); - if (grLfbLock(GR_LFB_READ_ONLY, - src_buffer, - GR_LFBWRITEMODE_ANY, - GR_ORIGIN_UPPER_LEFT, - FXFALSE, - &info)) { - FxU32 *srcData; /* Tracking Source Pointer */ - FxU32 *dstData; /* Tracking Destination Pointer */ - FxU32 *end; /* Demarks End of each Scanline */ - FxU32 srcJump; /* bytes to next scanline */ - FxU32 dstJump; /* bytes to next scanline */ - FxU32 length; /* bytes to copy in scanline */ - FxU32 scanline; /* scanline number */ - int aligned; /* word aligned? */ - FxU32 odd; /* is src_y odd? (for sli) */ - - dstData = (FxU32 *) dst_data; - srcData = (FxU32 *) (((char*)info.lfbPtr)+ - (src_y*info.strideInBytes) + - (src_x<<1)); - scanline = src_height; - length = src_width * 2; - dstJump = dst_stride - length; - srcJump = info.strideInBytes - length; - aligned = !((int)srcData&0x2); - odd = (src_y+src_height) & 0x1; - - if (aligned) { - while(scanline--) { - end = (FxU32*)((char*)srcData + length - 2); - - while(srcData < end) { - *dstData++ = GR_GET(*srcData++); - } - - if (((int)length) & 0x2) { - (*(FxU16*)dstData) = GR_GET16(*srcData); - dstData = (FxU32*)(((FxU16*)dstData) + 1); - srcData = (FxU32*)(((FxU16*)srcData) + 1); - } - - dstData = (FxU32*)(((char*)dstData)+dstJump); - srcData = (FxU32*)(((char*)srcData)+srcJump); - } - } else { - while(scanline--) { - end = (FxU32*)((char*)srcData + length - 2); - - (*(FxU16*)dstData) = (FxU16)GR_GET16(*srcData); - dstData = (FxU32*)(((FxU16*)dstData) + 1); - srcData = (FxU32*)(((FxU16*)srcData) + 1); - - while(srcData < end) { - *dstData++ = GR_GET(*srcData++); - } - - if (!(((int)length) & 0x2)) { - (*(FxU16*)dstData) = GR_GET16(*srcData); - dstData = (FxU32*)(((FxU16*)dstData) + 1); - srcData = (FxU32*)(((FxU16*)srcData) + 1); - } - - dstData = (FxU32*)(((char*)dstData)+dstJump); - srcData = (FxU32*)(((char*)srcData)+srcJump); - } - } - grLfbUnlock(GR_LFB_READ_ONLY, src_buffer); - } else { - rv = FXFALSE; - } - GR_RETURN(rv); -#undef FN_NAME -}/* grLfbReadRegion */ - diff --git a/glide3x/h3/glide3/src/glide.h b/glide3x/h3/glide3/src/glide.h index b0124f0..807263d 100644 --- a/glide3x/h3/glide3/src/glide.h +++ b/glide3x/h3/glide3/src/glide.h @@ -52,9 +52,7 @@ extern "C" { typedef FxU32 GrColor_t; typedef FxU8 GrAlpha_t; typedef FxU32 GrMipMapId_t; -#ifdef __linux__ typedef FxU32 GrStipplePattern_t; -#endif /* __linux__ */ typedef FxU8 GrFog_t; typedef FxU32 GrContext_t; typedef int (FX_CALL *GrProc)(); @@ -253,12 +251,10 @@ typedef FxI32 GrDitherMode_t; #define GR_DITHER_2x2 0x1 #define GR_DITHER_4x4 0x2 -#ifdef __linux__ typedef FxI32 GrStippleMode_t; #define GR_STIPPLE_DISABLE 0x0 #define GR_STIPPLE_PATTERN 0x1 #define GR_STIPPLE_ROTATE 0x2 -#endif /* __linux__ */ typedef FxI32 GrFogMode_t; #define GR_FOG_DISABLE 0x0 @@ -709,13 +705,11 @@ grDisableAllEffects( void ); FX_ENTRY void FX_CALL grDitherMode( GrDitherMode_t mode ); -#ifdef __linux__ FX_ENTRY void FX_CALL grStippleMode( GrStippleMode_t mode ); FX_ENTRY void FX_CALL grStipplePattern( GrStipplePattern_t mode ); -#endif /* __linux__ */ FX_ENTRY void FX_CALL grFogColorValue( GrColor_t fogcolor ); diff --git a/glide3x/h3/glide3/src/gsst.c.dri b/glide3x/h3/glide3/src/gsst.c similarity index 98% rename from glide3x/h3/glide3/src/gsst.c.dri rename to glide3x/h3/glide3/src/gsst.c index 7fd4735..43e2fd1 100644 --- a/glide3x/h3/glide3/src/gsst.c.dri +++ b/glide3x/h3/glide3/src/gsst.c @@ -19,6 +19,9 @@ ** ** $Header$ ** $Log$ +** Revision 1.1.1.1.6.1 2003/06/29 18:43:27 guillemj +** Fix compilation warnings. +** ** Revision 1.1.1.1 1999/11/24 21:45:01 joseph ** Initial checkin for SourceForge ** @@ -531,7 +534,7 @@ #include #endif -#ifdef __linux__ +#if DRI_BUILD #include #endif @@ -743,7 +746,7 @@ initGC ( GrGC *gc ) GDBG_INFO(95, FN_NAME"(0x%X)\n", gc); /* Setup the indices of the logical buffers */ -#ifdef __linux__ +#if DRI_BUILD gc->curBuffer = (gc->grColBuf > 1) ? 1 : 0; gc->frontBuffer = 0; #else @@ -936,7 +939,7 @@ GR_ENTRY(grSstWinOpen, GrContext_t, ( FxU32 hWnd, struct cmdTransportInfo *gcFifo = 0; GrContext_t retVal = 0; -#ifndef __linux__ +#if !defined(__linux__) && !defined(__DJGPP__) if (!hWnd) GrErrorCallback("grSstWinOpen: need to use a valid window handle", FXTRUE); @@ -974,7 +977,7 @@ GR_ENTRY(grSstWinOpen, GrContext_t, ( FxU32 hWnd, ? GR_RESOLUTION_640x480 : resolution; -#ifdef __linux__ +#if DRI_BUILD gc->state.screen_width = driInfo.screenWidth; gc->state.screen_height = driInfo.screenHeight; #else @@ -1056,7 +1059,7 @@ GR_ENTRY(grSstWinOpen, GrContext_t, ( FxU32 hWnd, gc->hwInitP = FXTRUE; } -#ifdef __linux__ +#if DRI_BUILD vInfo->xRes = driInfo.w; vInfo->yRes = driInfo.h; #else @@ -1115,7 +1118,7 @@ GR_ENTRY(grSstWinOpen, GrContext_t, ( FxU32 hWnd, /* This actually gets taken in hwcInitVideo */ gc->contextP = FXTRUE; -#ifndef __linux__ +#if GLIDE_CHECK_CONTEXT /* CSR - Set up flag for display driver to tell us that context was lost */ if ( !gc->open ) /* If we already have a context open, then lets not re-initialize the pointers */ @@ -1397,7 +1400,7 @@ GR_ENTRY(grSstWinOpen, GrContext_t, ( FxU32 hWnd, gcFifo->fifoPtr = gcFifo->fifoStart; gcFifo->fifoRead = HW_FIFO_PTR( FXTRUE ); -#ifndef __linux__ +#if !DRI_BUILD if ( (void*)gcFifo->fifoPtr != (void*)gcFifo->fifoRead ) { #ifdef GLIDE_INIT_HWC hwcRestoreVideo( bInfo ); @@ -1439,7 +1442,7 @@ GR_ENTRY(grSstWinOpen, GrContext_t, ( FxU32 hWnd, gcFifo->fifoSize, gcFifo->fifoPtr ); -#ifdef __linux__ +#if DRI_BUILD _grImportFifo(*driInfo.fifoPtr, *driInfo.fifoRead); #endif @@ -1493,7 +1496,7 @@ GR_ENTRY(grSstWinOpen, GrContext_t, ( FxU32 hWnd, REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 4, 0xf); { REG_GROUP_SET(hw, colBufferAddr, gc->state.shadow.colBufferAddr); -#ifdef __linux__ +#if DRI_BUILD REG_GROUP_SET(hw, colBufferStride, (!gc->curBuffer) ? driInfo.stride : gc->state.shadow.colBufferStride); #else @@ -1507,7 +1510,7 @@ GR_ENTRY(grSstWinOpen, GrContext_t, ( FxU32 hWnd, GDBG_INFO( gc->myLevel, " Setting all Glide state\n" ); assertDefaultState(); -#ifdef __linux__ +#if DRI_BUILD if (nColBuffers>1) grRenderBuffer(GR_BUFFER_BACKBUFFER); else @@ -1575,7 +1578,7 @@ GR_ENTRY(grSstWinClose, FxBool, (GrContext_t context)) GrGC* gc = (GrGC*)context; GDBG_INFO(80, FN_NAME"(0x%X)\n", context); -#ifndef __linux__ +#if GLIDE_CHECK_CONTEXT if (gc->lostContext) { if (*gc->lostContext) return 0; @@ -1623,7 +1626,7 @@ GR_ENTRY(grSstWinClose, FxBool, (GrContext_t context)) * safe everywhere. */ GDBG_INFO(gc->myLevel, " Restore Video"); -#ifndef __linux__ +#if GLIDE_CHECK_CONTEXT if (!*gc->lostContext) #endif hwcRestoreVideo(gc->bInfo); @@ -1654,7 +1657,7 @@ GR_ENTRY(grSstWinClose, FxBool, (GrContext_t context)) } _GlideRoot.windowsInit--; -#ifndef __linux__ +#if !defined(__linux__) && !defined (__DJGPP__) if ( gc->bInfo->osNT ) hwcUnmapMemory(); else @@ -1665,7 +1668,27 @@ GR_ENTRY(grSstWinClose, FxBool, (GrContext_t context)) #undef FN_NAME } /* grSstWinClose */ +/*------------------------------------------------------------------- + Function: grSetNumPendingBuffers + Date: 13-Oct-2000 + Implementor(s): mmcclure + Description: + + Allow the application to supply the number of pending buffers + Arguments: + + NumPendingBuffers - Sent to force number of pending buffers + + Return: + -------------------------------------------------------------------*/ +GR_DIENTRY(grSetNumPendingBuffers, void, (FxI32 NumPendingBuffers)) +{ + /* [dBorca] TODO + * + _GlideRoot.environment.swapPendingCount = NumPendingBuffers; + */ +} /*------------------------------------------------------------------- Function: grSelectContext @@ -1728,7 +1751,7 @@ GR_DIENTRY(grSelectContext, FxBool , (GrContext_t context) ) GR_ASSERT((gc >= _GlideRoot.GCs) && (gc <= _GlideRoot.GCs + MAX_NUM_SST)); -#if defined( GLIDE_INIT_HWC ) && !defined(__linux__) +#if defined( GLIDE_INIT_HWC ) && GLIDE_CHECK_CONTEXT gc->contextP = hwcQueryContext(gc->bInfo); #else gc->contextP = 1; @@ -1879,7 +1902,7 @@ GR_ENTRY(grFinish, void, (void)) grFlush(); if ( gc->windowed ) { -#if defined( GLIDE_INIT_HWC ) && !defined( __linux__ ) +#if defined( GLIDE_INIT_HWC ) && !defined( __linux__ ) && !defined( __DJGPP__ ) struct cmdTransportInfo* gcFifo = &gc->cmdTransportInfo; diff --git a/glide3x/h3/glide3/src/gsst.c.save b/glide3x/h3/glide3/src/gsst.c.save deleted file mode 100644 index 7532eac..0000000 --- a/glide3x/h3/glide3/src/gsst.c.save +++ /dev/null @@ -1,2042 +0,0 @@ -/* -** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY -** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT -** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX -** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE -** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). -** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER -** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A -** FULL TEXT OF THE NON-WARRANTY PROVISIONS. -** -** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO -** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN -** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013, -** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR -** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF -** THE UNITED STATES. -** -** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED -** -** $Header$ -** $Log$ -** Revision 1.1.1.1 1999/11/24 21:45:00 joseph -** Initial checkin for SourceForge -** -** -** 11 6/24/99 1:28a Stb_mmcclure -** Modifications to fix PRS 6627. Added hwcUnmapMemory9x for revised 9x -** context switching code. -** -** 10 6/10/99 12:19p Stb_mmcclure -** Modifications for per-process lost context for glide in Win9x -** environments. RT3 Fix PRS 6249. -** -** 9 5/28/99 12:58p Atai -** move color format above doSplash. The new glide/splash api is smart -** enough to take the in-coming color format -** -** 8 5/24/99 2:48p Jamesb -** Added ptrLostContext to exported cmdTransport struct. -** -** 7 4/15/99 5:38p Dow -** protected winclose -** -** 110 4/15/99 5:34p Dow -** Protected WinClose -** -** 109 4/10/99 2:21p Atai -** set contexP to 1 -** -** 108 4/10/99 1:24p Atai -** fixed code to compile in packet fifo mode -** -** 107 4/09/99 4:52p Dow -** Get lostcontext each time -** -** 106 4/07/99 7:18p Atai -** added uma extension -** -** 105 4/05/99 8:25p Dow -** Alt tab mostly happy -** -** 104 4/05/99 4:05p Atai -** I removed hwcShareContextData code in my previous check-in -** -** 103 4/04/99 8:51p Atai -** Partial check-in for alt-tab issue. set FX_GLIDE_ALT_TAB=1 to build -** glide3x with hwcQueryContext built into GR_BEGIN_NOFIFOCHECK. It works -** with DEBUG glide only. In the non-debug glide, we can still see the -** desktop corruption. -** -** 100 4/02/99 11:51a Peter -** only monitor state changes not every time -** -** 99 4/01/99 7:55p Peter -** change to allow fsem recovery -** -** 98 3/31/99 9:02p Dow -** context loosing means no writing to hw -** -** 97 3/24/99 6:17p Peter -** reduce nop flush for chain downloads -** -** 96 3/22/99 5:38p Peter -** single load of splash -** -** 95 3/19/99 11:30a Peter -** protect against splash screen not restoring app state -** -** 94 3/17/99 5:08p Peter -** removed whacky stuff now that the command fifo threshold stuff appears -** to make all happy (including the k7) -** -** 93 3/14/99 1:48p Peter -** cmd's bng optimization -** -** 92 3/12/99 2:27p Dow -** Turn off hole counting for PIII and K7 -** -** 91 3/11/99 6:42p Dow -** Resolution help -** -** 90 3/10/99 10:42a Peter -** bump-n-grind workaround for katmai until the bug is better -** characterized -** -** 89 3/05/99 10:33p Peter -** fixed the surface fifo state race condition (thanks to Ken Dyke) -** -** 88 3/02/99 2:04p Peter -** removed tmu check that should be done in grTexCombine -** -** 87 2/27/99 12:25p Dow -** gsst.c -** -** 86 2/26/99 10:27a Peter -** Mmmm.... 8.3 -** -** 85 2/19/99 8:03p Peter -** new splash crapola -** -** 84 2/18/99 3:51p Kcd -** Fixed dumb Codewarrior warning. -** -** 83 2/18/99 3:05p Atai -** allow calls to guGammaCorrectionRGB after -** grGlideShutdown. Check if we have a null gc. -** -** 82 2/13/99 2:01p Dow -** Added code for new resolutions -** -** 81 2/11/99 1:38p Atai -** sync buffer swap pending code, the right way. -** -** 80 2/05/99 9:38a Atai -** fixed grSelectContext return value. If the gc is open, return FXTRUE. -** -** 79 2/02/99 4:41p Peter -** debugging info to grFlush -** -** 78 1/25/99 6:35p Peter -** tiled texture cleanup, default lfb buffer when single buffering -** -** 77 1/06/99 11:30a Peter -** cleanup win fifo locking -** -** 76 12/23/98 2:01p Peter -** nt currently has mutexing problems via ddraw and extescape -** -** 75 12/11/98 1:36p Peter -** made grFlush's operation more obvious -** -** 74 12/09/98 6:25p Atai -** grTexCombine did the right thing for the un-used TMU. Initialize the -** 2nd TMU value to take care of "set FX_GLIDE_NUM_TMU=1" -** -** 73 12/09/98 5:10p Atai -** set MAXLOD = MINLOD = 8 in _grUpdateParamIndex if ST1 is not used -** -** 72 12/09/98 2:02p Atai -** Added _grTexForceLod back. Set tLOD min = max = 8 for the 2nd TMU by -** default for Avenger to increase single texturing tri fillrate. -** -** 71 12/09/98 10:22a Dow -** Fixed infinite recursion on shutdown -** -** 70 12/08/98 2:23p Dow -** Fixed effage in grSstWinClose when invalid context is passed -** -** 69 12/03/98 11:26p Dow -** Code 'cleanup' heheh -** -** 68 12/02/98 2:07p Dow -** removed spurious call to guGammaCorrectionRGB -** -** 67 11/30/98 6:57p Peter -** video memory fifo's -** -** 66 11/25/98 12:10p Atai -** fixed sdram buffer clear (gc->state.shadow.auxBufferStride not -** initialized) -** -** 65 11/21/98 10:19a Atai -** fixed test37 grChromaRangeModeExt error and rename functions -** -** 64 11/15/98 3:21a Atai -** first attempt to make 2 tmus work in H4 glide3x full screen mode, just -** in time check-in for comdex demo. warning: the code is not completed -** yet. -** -** 63 11/12/98 3:12p Mikec -** In winOpen, moved setting color format in gc to after splash. Fixed the -** red screen bug after splash (RGBA format). -** -** 62 11/02/98 5:34p Peter -** tls per thread for fullscreen contexts -** -** 61 10/14/98 3:38p Dow -** Gamma stuff -** -** 60 10/14/98 1:47p Jdt -** Fix state restore buffer and add archDispatchProcs setup to -** selectContext -** -** 59 10/13/98 8:47p Dow -** Works with 4MB boards -** -** 58 10/12/98 9:51a Peter -** dynamic 3DNow!(tm) -** -** 57 10/08/98 10:29a Dow -** Fixes triple buffering -** -** 56 9/18/98 10:52a Dow -** VidMode Stuff -** -** 55 9/14/98 9:57a Jdt -** -** 54 9/11/98 10:45p Jdt -** switch over to statically allocated in-memory fifo. -** -** 53 9/09/98 1:33p Atai -** callback the error routine if window handle is not valid in -** grSstWinOpen -** -** 52 9/04/98 11:35a Peter -** re-open fix for nt (thanks to taco/rob/nt bob) -** -** 51 8/31/98 4:03p Dow -** Contol Panel -** -** 50 8/30/98 1:34p Dow -** State & other optimizations -** -** 49 8/29/98 2:29p Peter -** set context value in case grGlideInit was called from a different -** thread -** -** 48 8/28/98 4:37p Atai -** 1. added MIN_FIFO_SIZE for memory checking -** 2. hack for resolution checking if we have 8M board and triple -** buffering on -** -** 47 8/27/98 9:27p Atai -** fix env variable for glide3x -** -** 46 8/27/98 5:57p Dow -** Indentation -** -** 45 8/26/98 9:59p Jdt -** Compute and store pointer to aux buffer. -** -** 44 8/21/98 3:48p Jdt -** Fixed flush bug that was causing exit. -** -** 43 8/03/98 10:40a Atai -** rename slpash dll to "3dfxspl3.dll" -** -** 42 8/03/98 6:41a Jdt -** removed gc argument from assertDefaultState, multi-thread changes -** -** 41 8/02/98 5:01p Dow -** Glide Surface Extension -** -** 39 7/20/98 10:49p Jdt -** Don't send chromarange to all chips on H3.... -** -** 38 7/18/98 1:45p Jdt -** Removed TACO_MEMORY_FIFO_HACK -** -** 37 7/18/98 10:41a Dow -** Num TMU -** -** 36 7/18/98 12:30a Jdt -** Remove reference to colorcombinedelta0mode -** Added initialzation for state restoreation buffer to initGC. -** Changes to reflect new shadow register structure. -** -** 35 7/17/98 10:44a Atai -** fixed grTexNCCTable and clip coords st with aspect ratio -** -** 34 7/16/98 8:19a Jdt -** TACO_MEMORY_FIFO_HACK now enables 1 window glide in window. -** -** more direct read protection. -** -** 33 7/13/98 10:43p Jdt -** Various Surface Implementation Changes -** -** 32 7/13/98 9:57p Jdt -** Removed guTexMemReset() -** -** Made initGC public. -** -** 31 7/01/98 12:41p Jdt -** Reorganized grSstWinOpen, factoring out initialization functionality -** that will be shared between fullscreen and windowed -** operation. -** Protected hacks for Glide/Win ( FX_TACO_MEMORY_FIFO_HACK ) -** -** 28 6/12/98 11:35a Atai -** temporary disable guGammaCorrectionRGB -** -** 27 6/11/98 12:53p Atai -** remove grGammaCorrectionValue -** -** 26 6/10/98 12:53p Atai -** replace grSstControl with grEnable/grDisable(GR_PASSTHRU) -** -** 25 6/10/98 11:58a Peter -** lfb tiled addressing -** -** 24 6/04/98 12:12p Peter -** splash dll rename -** -** 23 4/30/98 5:01p Peter -** first pass glide3 merge -** -** 22 4/30/98 10:34a Peter -** merged w/ cvg again -** -** 20 4/22/98 4:57p Peter -** glide2x merge -** -** 19 3/30/98 3:28p Atai -** set gamma to 1.3 -** -** 18 3/13/98 4:03p Peter -** start glide3 merge -** -** 17 3/02/98 7:26p Peter -** clear slop on sli systems when changing y origin -** -** 16 2/23/98 11:44a Peter -** merged monitor detection and fixed compilation error from recent -** videobuffer changes -** -** 15 2/12/98 3:40p Peter -** single buffering for opengl -** -** 14 2/10/98 7:04p Atai -** fix grvertexlayout for migration dll -** -** 13 2/05/98 3:07p Atai -** fix migration dll -** -** 12 1/30/98 4:58p Atai -** fix gamma table parameters -** -** 11 1/30/98 4:29p Peter -** no uswc for sli slave -** -** 10 1/26/98 12:20p Atai -** fix grVertexLayout in grSplash() -** -** 9 1/26/98 11:30a Atai -** update to new glide.h -** -** 8 1/22/98 10:35a Atai -** 1. introduce GLIDE_VERSION, g3\glide.h, g3\glideutl.h, g2\glide.h, -** g2\glideutl.h -** 2. fixed grChromaRange, grSstOrigin, and grGetProcAddress -** -** 7 1/20/98 11:03a Peter -** env var to force triple buffering -** -** 6 1/18/98 12:03p Atai -** sync to rev 17 spec - * - * 5 1/17/98 2:26p Atai - * fix grvertexlayout - * - * 4 1/17/98 1:12p Atai - * set default as back buffer - * - * 3 1/16/98 6:54p Atai - * disable gamma table for now - * - * 1 1/16/98 4:29p Atai - * create glide 3 src - * - * 116 1/16/98 4:18p Atai - * fixed lfb and grLoadGammaTable - * - * 115 1/16/98 10:47a Peter - * fixed idle effage - * - * 114 1/16/98 10:16a Atai - * fixed grSstIldle - * - * 113 1/10/98 4:01p Atai - * inititialize vertex layout, viewport, added defines - * - * 110 1/06/98 6:47p Atai - * undo grSplash and remove gu routines - * - * 109 1/06/98 3:53p Atai - * remove grHint, modify grLfbWriteRegion and grGet - * - * 107 12/18/97 2:12p Peter - * grSstControl on v2 - * - * 106 12/17/97 4:48p Peter - * groundwork for CrybabyGlide - * - * 105 12/17/97 4:06p Atai - * added grChromaRange(), grGammaCorrecionRGB(), grRest(), and grGet() - * functions - * - * 104 12/16/97 1:33p Atai - * added grGammaCorrectionRGB() - * - * 103 12/16/97 10:03a Atai - * fixed gutexmemreset for glide2 - * - * 101 12/09/97 12:20p Peter - * mac glide port - * - * 100 12/05/97 4:26p Peter - * watcom warnings - * - * 99 12/03/97 11:35a Peter - * is busy thing - * - * 98 11/25/97 12:09p Peter - * nested calls to grLfbLock vs init code locking on v2 - * - * 97 11/21/97 1:02p Peter - * v^2 supported resolutions - * - * 96 11/21/97 11:19a Dow - * Added RESOLUTION_NONE hack for Banshee - * - * 95 11/19/97 2:49p Peter - * env vars in registry for win32 - * - * 94 11/19/97 2:22p Dow - * gsst.c - * - * 93 11/18/97 4:50p Peter - * chipfield stuff cleanup and w/ direct writes - * - * 92 11/18/97 4:00p Atai - * fixed the GR_BEGIN and GR_END error in previous check-in - * - * 91 11/18/97 3:27p Atai - * update vData - * optimize state monster - * - * 90 11/17/97 4:55p Peter - * watcom warnings/chipfield stuff - * - * 89 11/16/97 2:20p Peter - * cleanup - * - * 88 11/15/97 7:43p Peter - * more comdex silliness - * - * 87 11/14/97 11:10p Peter - * open vs hw init confusion - * - * 86 11/14/97 5:02p Peter - * more comdex stuff - * - * 85 11/14/97 4:47p Dow - * New splash screen - * - * 84 11/14/97 12:09a Peter - * comdex thing and some other stuff - * - * 83 11/12/97 9:37p Dow - * Banshee crap - * - * 82 11/12/97 2:27p Peter - * - * 81 11/12/97 1:09p Dow - * H3 Stuf - * - * 80 11/12/97 9:22a Dow - * H3 Mods - * - * 79 11/06/97 3:46p Peter - * sli shutdown problem - * - * 78 11/06/97 3:38p Dow - * More banshee stuff - * - * 77 11/04/97 5:04p Peter - * cataclysm part deux - * - * 76 11/04/97 3:58p Dow - * Banshee stuff - * - * 75 11/03/97 3:43p Peter - * h3/cvg cataclysm - * - * 74 10/29/97 4:59p Peter - * - * 73 10/29/97 2:45p Peter - * C version of Taco's packing code - * - * 72 10/23/97 5:28p Peter - * sli fifo thing - * - * 71 10/17/97 3:15p Peter - * grSstVidMode thingee - * - * 70 10/14/97 2:44p Peter - * moved close flag set - * - * 69 10/09/97 8:02p Dow - * State Monster 1st Cut - * -** -*/ - -#include -#include -#include <3dfx.h> - -#include - -#define FX_DLL_DEFINITION -#include -#include - -#include "fxglide.h" -#include "fxcmd.h" - -#if (GLIDE_PLATFORM & GLIDE_OS_WIN32) -#define WIN32_LEAN_AND_MEAN -#include -#endif - -#define kPageBoundarySlop 0x1000UL -#define kPageBoundaryMask (kPageBoundarySlop - 1) - -/* Init hw */ - -ResEntry -_resTable[] = { - GR_RESOLUTION_320x200, 320, 200, /* 0x0 */ - GR_RESOLUTION_320x240, 320, 240, /* 0x1 */ - GR_RESOLUTION_400x256, 400, 256, /* 0x2 */ - GR_RESOLUTION_512x384, 512, 384, /* 0x3 */ - GR_RESOLUTION_640x200, 640, 200, /* 0x4 */ - GR_RESOLUTION_640x350, 640, 350, /* 0x5 */ - GR_RESOLUTION_640x400, 640, 400, /* 0x6 */ - GR_RESOLUTION_640x480, 640, 480, /* 0x7 */ - GR_RESOLUTION_800x600, 800, 600, /* 0x8 */ - GR_RESOLUTION_960x720, 960, 720, /* 0x9 */ - GR_RESOLUTION_856x480, 856, 480, /* 0xa */ - GR_RESOLUTION_512x256, 512, 256, /* 0xb */ - GR_RESOLUTION_1024x768, 1024, 768, /* 0xC */ - GR_RESOLUTION_1280x1024, 1280, 1024, /* 0xD */ - GR_RESOLUTION_1600x1200, 1600, 1200, /* 0xE */ - GR_RESOLUTION_400x300, 400, 300, /* 0xF */ - GR_RESOLUTION_1152x864, 1152, 864, /* 0x10 */ - GR_RESOLUTION_1280x960, 1280, 960, /* 0x11 */ - GR_RESOLUTION_1600x1024, 1600, 1024, /* 0x12 */ - GR_RESOLUTION_1792x1344, 1792, 1344, /* 0x13 */ - GR_RESOLUTION_1856x1392, 1856, 1392, /* 0x14 */ - GR_RESOLUTION_1920x1440, 1920, 1440, /* 0x15 */ - GR_RESOLUTION_2048x1536, 2048, 1536, /* 0x16 */ - GR_RESOLUTION_2048x2048, 2048, 2048 /* 0x17 */ -}; - -/* --------------------------------------------- - This function both sets and documents the - expected default state for any rendering - context - - ..taco - separated out in preparation for - multiple contexts - ---------------------------------------------*/ -void -assertDefaultState( void ) -{ - GR_DCL_GC; - - grDisable(GR_ALLOW_MIPMAP_DITHER); - grSstOrigin(gc->state.origin); - grAlphaBlendFunction(GR_BLEND_ONE , GR_BLEND_ZERO, - GR_BLEND_ONE, GR_BLEND_ZERO); - grAlphaTestFunction(GR_CMP_ALWAYS); - grAlphaTestReferenceValue(0); - grChromakeyMode(GR_CHROMAKEY_DISABLE); - grChromaRangeMode( GR_CHROMAKEY_DISABLE ); - grTexChromaMode( GR_TMU0, GR_TEXCHROMA_DISABLE_EXT ); - grConstantColorValue((FxU32) ~0); - grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_LOCAL_ITERATED, - GR_COMBINE_OTHER_ITERATED, - FXFALSE); - grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_LOCAL_NONE, - GR_COMBINE_OTHER_CONSTANT, - FXFALSE); - grColorMask(FXTRUE, FXFALSE); - grCullMode(GR_CULL_DISABLE); - grDepthBiasLevel(0); - grDepthMask(FXFALSE); - grDepthBufferMode(GR_DEPTHBUFFER_DISABLE); - grDepthBufferFunction(GR_CMP_LESS); - grDepthBiasLevel(0); - grDitherMode(GR_DITHER_4x4); - grFogMode(GR_FOG_DISABLE); - grFogColorValue(0x00000000); - - /* - ** initialize default state for viewport and grVertexLayout - */ - grCoordinateSpace(GR_WINDOW_COORDS); - grViewport(0, 0, gc->state.screen_width, gc->state.screen_height ); - - switch (gc->num_tmu) { - case 2: - grTexClampMode(GR_TMU1, GR_TEXTURECLAMP_CLAMP, GR_TEXTURECLAMP_CLAMP); - grTexDetailControl(GR_TMU1, 0, 1, 1.0F); - grTexFilterMode(GR_TMU1, GR_TEXTUREFILTER_POINT_SAMPLED, - GR_TEXTUREFILTER_POINT_SAMPLED); - grTexLodBiasValue(GR_TMU1, 0.0F); - grTexMipMapMode(GR_TMU1, GR_MIPMAP_DISABLE, FXFALSE); - grTexCombine(GR_TMU1, GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, - FXFALSE, FXFALSE); - /* Intentional fallthrough */ - - case 1: - grTexClampMode(GR_TMU0, GR_TEXTURECLAMP_CLAMP, GR_TEXTURECLAMP_CLAMP); - grTexDetailControl(GR_TMU0, 0, 1, 1.0F); - grTexFilterMode(GR_TMU0, GR_TEXTUREFILTER_POINT_SAMPLED, - GR_TEXTUREFILTER_POINT_SAMPLED); - grTexLodBiasValue(GR_TMU0, 0.0F); - grTexMipMapMode(GR_TMU0, GR_MIPMAP_DISABLE, FXFALSE); - grTexCombine(GR_TMU0, - GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, - FXFALSE, FXFALSE); - } - grLfbConstantAlpha(0xFF); - grLfbConstantDepth(0); - - gc->triSetupProc = CUR_TRI_PROC(FXTRUE, (gc->state.cull_mode != GR_CULL_DISABLE)); -} /* assertDefaultState */ - -static void -clearBuffers( GrGC *gc ) -{ - /* Get rid of crap in the buffers. */ - grClipWindow(0, 0, gc->state.screen_width, - gc->state.screen_height); - if ( gc->state.num_buffers > 1 ) { - grBufferClear( 0, 0, 0UL ); - grBufferSwap( 1 ); - grBufferClear( 0, 0, 0xFFFFFFFFUL ); - grBufferSwap( 1 ); - grBufferClear( 0, 0, 0xFFFFFFFFUL ); - grBufferSwap( 1 ); - grRenderBuffer( GR_BUFFER_BACKBUFFER ); - } else { - grBufferClear( 0, 0, 0xFFFFFFFFUL ); - grRenderBuffer( GR_BUFFER_FRONTBUFFER ); - } -} /* clearBuffers */ - -static void -doSplash( void ) -{ - GR_DCL_GC; - -#if (GLIDE_PLATFORM & GLIDE_OS_WIN32) - { - FxBool - didLoad; - - if (gc->pluginInfo.moduleHandle == NULL) gc->pluginInfo.moduleHandle = LoadLibrary("3dfxspl3.dll"); - didLoad = (gc->pluginInfo.moduleHandle != NULL); - if (didLoad) { - gc->pluginInfo.initProc = (GrSplashInitProc)GetProcAddress(gc->pluginInfo.moduleHandle, - "_fxSplashInit@24"); - gc->pluginInfo.shutdownProc = (GrSplashShutdownProc)GetProcAddress(gc->pluginInfo.moduleHandle, - "_fxSplashShutdown@0"); - gc->pluginInfo.splashProc = (GrSplashProc)GetProcAddress(gc->pluginInfo.moduleHandle, - "_fxSplash@20"); - gc->pluginInfo.plugProc = (GrSplashPlugProc)GetProcAddress(gc->pluginInfo.moduleHandle, - "_fxSplashPlug@16"); - - didLoad = ((gc->pluginInfo.initProc != NULL) && - (gc->pluginInfo.splashProc != NULL) && - (gc->pluginInfo.plugProc != NULL) && - (gc->pluginInfo.shutdownProc != NULL)); - if (didLoad) { - GrState glideState; - - /* Protect ourselves from the splash screen */ - grGlideGetState(&glideState); - { - didLoad = (*gc->pluginInfo.initProc)(gc->grHwnd, - gc->state.screen_width, gc->state.screen_height, - gc->grColBuf, gc->grAuxBuf, - gc->state.color_format); - if (!didLoad) (*gc->pluginInfo.shutdownProc)(); - } - grGlideSetState((const void*)&glideState); - } - - if (!didLoad) FreeLibrary(gc->pluginInfo.moduleHandle); - } - - /* Clear all the info if we could not load for some reason */ - if (!didLoad) memset(&gc->pluginInfo, 0, sizeof(gc->pluginInfo)); - } -#endif /* (GLIDE_PLATFORM & GLIDE_OS_WIN32) */ - - if (_GlideRoot.environment.noSplash == 0) { - grSplash(0.0f, 0.0f, - (float)gc->state.screen_width, - (float)gc->state.screen_height, - 0); - } - _GlideRoot.environment.noSplash = 1; -} /* doSplash */ - - -/*---------------------------------------------------- - Return a GC to reset state - - ...taco - separated out as a first pass since this will - be common function per context - ----------------------------------------------------*/ -void -initGC ( GrGC *gc ) -{ -#define FN_NAME "initGC" - FxI32 t = 0; - - GDBG_INFO(95, FN_NAME"(0x%X)\n", gc); - - /* Setup the indices of the logical buffers */ - gc->curBuffer = 0; - gc->frontBuffer = ((gc->grColBuf > 1) ? 1 : 0); - gc->backBuffer = (gc->grColBuf > 2) ? 2 : gc->curBuffer; - - for (t = 0; t < 7; t++) { - gc->bufferSwaps[t] = 0xffffffff; - } - - gc->bufferSwaps[0] = ((FxU32) gc->cmdTransportInfo.fifoPtr - - (FxU32) gc->cmdTransportInfo.fifoStart); - - gc->swapsPending = 1; - - gc->lockPtrs[GR_LFB_READ_ONLY] = (FxU32)-1; - gc->lockPtrs[GR_LFB_WRITE_ONLY] = (FxU32)-1; - - /* initialize command packet headers for state - restore buffer */ - gc->state.shadow.pkt4Hdr_0 = - 0x1 << 11 | /* note, don't send chromarange to tmu... */ - ( SR_MASK_0 << SSTCP_PKT4_MASK_SHIFT ) | - SSTCP_REGBASE_FROM_ADDR( SR_ADDR_0 ) | - SSTCP_PKT4; - - gc->state.shadow.pkt4Hdr_1 = - ( SR_MASK_1 << SSTCP_PKT4_MASK_SHIFT ) | - SSTCP_REGBASE_FROM_ADDR( SR_ADDR_1 ) | - SSTCP_PKT4; - - gc->state.shadow.pkt1Hdr_2 = - ( SR_WORDS_2 << SSTCP_PKT1_NWORDS_SHIFT ) | - SSTCP_INC | - SSTCP_REGBASE_FROM_ADDR( SR_ADDR_2 ) | - SSTCP_PKT1; - - gc->state.shadow.pkt4Hdr_3 = - ( SR_MASK_3 << SSTCP_PKT4_MASK_SHIFT ) | - SSTCP_REGBASE_FROM_ADDR( SR_ADDR_3 ) | - SSTCP_PKT4; - - for( t = 0; t < 32; t++ ) { - gc->state.shadow.paletteRow[t].pkt1Hdr_P = - ( SR_WORDS_P << SSTCP_PKT1_NWORDS_SHIFT ) | - SSTCP_INC | - SSTCP_REGBASE_FROM_ADDR( SR_ADDR_P ) | - SSTCP_PKT1; - } - - /* Initialize the read/write registers to all 0 */ - gc->state.shadow.fbzColorPath = 0; - gc->state.shadow.fogMode = 0; - gc->state.shadow.alphaMode = 0; - gc->state.shadow.fbzMode = 0; - gc->state.shadow.lfbMode = 0; - gc->state.shadow.clipLeftRight = 0; - gc->state.shadow.clipBottomTop = 0; - gc->state.shadow.fogColor = 0; - gc->state.shadow.zaColor = 0; - gc->state.shadow.chromaKey = 0; - gc->state.shadow.stipple = 0; - gc->state.shadow.color0 = 0; - gc->state.shadow.color1 = 0; - - /* NB: This loop has to setup the packet headers for *ALL* of the - * tmu persistent state. Mess this up at your own peril because - * someone who cares about running glide in a window will come and - * kill you as you sit in your cube. - */ - for (t = 0; t < GLIDE_NUM_TMU; t ++) { - gc->state.shadow.tmuState[t].texPkt4Hdr_0 = (( SR_MASK_4 << SSTCP_PKT4_MASK_SHIFT ) | - FIFO_REG((0x02UL << t), textureMode) | - SSTCP_PKT4); - - gc->state.shadow.tmuState[t].textureMode = 0x00000000; - gc->state.shadow.tmuState[t].tLOD = 0x00000000; - gc->state.shadow.tmuState[t].tDetail = 0x00000000; - gc->state.shadow.tmuState[t].texBaseAddr = 0x00000000; - gc->state.shadow.tmuState[t].texBaseAddr_1 = 0x00000000; - gc->state.shadow.tmuState[t].texBaseAddr_2 = 0x00000000; - gc->state.shadow.tmuState[t].texBaseAddr_3_8 = 0x00000000; - - gc->state.shadow.tmuState[t].texPkt4Hdr_1 = - ( SR_MASK_5 << SSTCP_PKT4_MASK_SHIFT ) | - FIFO_REG((0x02UL << t), chromaKey) | - SSTCP_PKT4; - - gc->state.shadow.tmuState[t].texPkt1Hdr_2 = - ( SR_WORDS_6 << SSTCP_PKT1_NWORDS_SHIFT ) | - SSTCP_INC | - FIFO_REG((0x02UL << t), nccTable0) | - SSTCP_PKT1; - - gc->tmuMemInfo[t].prePacket[0] = ((0x01UL << SSTCP_PKT1_NWORDS_SHIFT) | - FIFO_REG_WAX(command) | - SSTCP_PKT1); - gc->tmuMemInfo[t].prePacket[1] = (SSTG_NOP + SSTG_GO); - - gc->tmuMemInfo[t].postPacket[0] = ((0x01UL << SSTCP_PKT1_NWORDS_SHIFT) | - FIFO_REG((0x02UL << t), texBaseAddr) | - SSTCP_PKT1); - gc->tmuMemInfo[t].postPacket[1] = ~gc->state.shadow.tmuState[t].texBaseAddr; - gc->tmuMemInfo[t].postPacket[2] = ((0x01UL << SSTCP_PKT1_NWORDS_SHIFT) | - FIFO_REG(BROADCAST_ID, nopCMD) | - SSTCP_PKT1); - gc->tmuMemInfo[t].postPacket[3] = 0x00UL; - gc->tmuMemInfo[t].postPacket[4] = ((0x01UL << SSTCP_PKT1_NWORDS_SHIFT) | - FIFO_REG((0x02UL << t), texBaseAddr) | - SSTCP_PKT1); - gc->tmuMemInfo[t].postPacket[5] = gc->state.shadow.tmuState[t].texBaseAddr; - gc->tmuMemInfo[t].postPacket[6] = ((0x01UL << SSTCP_PKT1_NWORDS_SHIFT) | - FIFO_REG_WAX(command) | - SSTCP_PKT1); - gc->tmuMemInfo[t].postPacket[7] = (SSTG_NOP + SSTG_GO); - - /* This is the signal to flush */ - gc->tmuMemInfo[t].flushCount = 1; - - gc->state.per_tmu[t].mmMode = GR_MIPMAP_NEAREST; - gc->state.per_tmu[t].smallLod = G3_LOD_TRANSLATE(GR_LOD_LOG2_1); - gc->state.per_tmu[t].largeLod = G3_LOD_TRANSLATE(GR_LOD_LOG2_1); - gc->state.per_tmu[t].s_scale = 256.f; - gc->state.per_tmu[t].t_scale = 256.f; - gc->state.per_tmu[t].evenOdd = GR_MIPMAPLEVELMASK_BOTH; - gc->state.per_tmu[t].nccTable = GR_NCCTABLE_NCC0; - } -#undef FN_NAME -} /* initGC */ - -/*------------------------------------------------------------------- - Function: grSstWinOpen - Date: 3/16 - Implementor(s): dow, gmt, murali, jdt - Mutator: dpc - Library: Glide - Description: - - Initialize the selected SST - - Arguments: - hwnd - pointer to a window handle or null. If NULL, then - the application window handle will be inferred though - the GetActiveWindow() api. - resolution - either one of the pre-defined glide resolutions, - or GR_RESOLUTION_NONE, in which case the window - size is inferred from the size application window - refresh - requested fullscreen refresh rate, ignored in a window - format - requested ccolor format for glide packed color values - origin - location of coordinate origin either upper left or - lower right - nColBuffers - number of color buffers to attempt to allocate - 0 - meaningless - 1 - allocate a front buffer only - 2 - allocate a front and back buffer - 3 - allocate a front, back, aux buffer for tripple buffering - nAuxBuffers - number of aux buffers to attempt to allocate - 0 - no alpha or z buffers - 1 - allocate one aux buffer for alpha/depth buffering - 2 - allocate on depth and one alpha buffer (unsup) - Return: - NULL - glide was unable to create a fullscreen context - context handle - glide was able to create a context with handle H - -------------------------------------------------------------------*/ -GR_ENTRY(grSstWinOpen, GrContext_t, ( FxU32 hWnd, - GrScreenResolution_t resolution, - GrScreenRefresh_t refresh, - GrColorFormat_t format, - GrOriginLocation_t origin, - int nColBuffers, - int nAuxBuffers) ) -{ -#define FN_NAME "grSstWinOpen" -#define TILE_WIDTH_PXLS 64 -#define TILE_HEIGHT_PXLS 32 -#define BYTES_PER_PIXEL 2 -#define MIN_TEXTURE_STORE 0x200000 -#define MIN_FIFO_SIZE 0x10000 -#if defined( GLIDE_INIT_HWC ) - hwcBoardInfo *bInfo = 0; - hwcVidInfo *vInfo = 0; - hwcBufferInfo *bufInfo = 0; - hwcFifoInfo *fInfo = 0; -#elif defined( GLIDE_INIT_HAL ) - FxDeviceInfo devInfo; -#endif /* defined ( GLIDE_INIT_HAL ) */ - int buffer; - struct cmdTransportInfo *gcFifo = 0; - GrContext_t retVal = 0; - -#if !defined(__linux__) && !defined(__DJGPP__) /* [dBorca] */ - if (!hWnd) - GrErrorCallback("grSstWinOpen: need to use a valid window handle", - FXTRUE); -#endif - - /* NB: TLS must be setup before the 'declaration' which grabs the - * current gc. This gc is valid for all threads in the fullscreen - * context. - */ - setThreadValue( (FxU32)&_GlideRoot.GCs[_GlideRoot.current_sst] ); - - { - /* Partial Argument Validation */ - GR_BEGIN_NOFIFOCHECK_NORET("grSstWinOpen",80); - GDBG_INFO_MORE(gc->myLevel, - "(rez=%d,ref=%d,cformat=%d,origin=%s,#bufs=%d, #abufs=%d)\n", - resolution,refresh,format, - origin ? "LL" : "UL", - nColBuffers, nAuxBuffers); - GR_CHECK_F(FN_NAME, !gc, "no SST selected as current (gc==NULL)"); - - /* - ** check if the environment variable for triple buffering is on - */ - if (_GlideRoot.environment.nColorBuffer != -1) { - if ((_GlideRoot.environment.nColorBuffer > 0) && - (_GlideRoot.environment.nColorBuffer <= 3) - ){ - nColBuffers = _GlideRoot.environment.nColorBuffer; - } - } - - resolution = - (((FxU32)resolution) > (sizeof(_resTable) / sizeof(ResEntry))) - ? GR_RESOLUTION_640x480 - : resolution; - - gc->state.screen_width = _resTable[resolution].xres; - gc->state.screen_height = _resTable[resolution].yres; - GR_CHECK_F( FN_NAME, - resolution != _resTable[resolution].resolution, - "resolution table compilation incorrect" ); - if ( gc->vidTimings ) { - gc->state.screen_width = gc->vidTimings->xDimension; - gc->state.screen_height = gc->vidTimings->yDimension; - } - - gc->state.origin = origin; - gc->grSstRez = resolution; - gc->grSstRefresh = refresh; - gc->grColBuf = gc->state.num_buffers = nColBuffers; - gc->grAuxBuf = nAuxBuffers; - gc->fbStride = gc->state.screen_width * BYTES_PER_PIXEL; - gc->grHwnd = (int) hWnd; - - /* compute tile dimensions */ - gc->strideInTiles = ( gc->state.screen_width + ( TILE_WIDTH_PXLS - 1 ) ) / TILE_WIDTH_PXLS; - GDBG_INFO(80, "%s: strideInTiles = 0X%x\n", FN_NAME, gc->strideInTiles); - gc->heightInTiles = ( gc->state.screen_height + ( TILE_HEIGHT_PXLS - 1 ) ) / TILE_HEIGHT_PXLS; - GDBG_INFO(80, "%s: heightInTiles = 0x%x\n", FN_NAME, gc->heightInTiles); - gc->bufferStride = gc->strideInTiles * TILE_WIDTH_PXLS * BYTES_PER_PIXEL; - GDBG_INFO(80, "%s: bufferStride = 0x%x\n", FN_NAME, gc->bufferStride); - gc->bufSizeInTiles = gc->strideInTiles * gc->heightInTiles; - GDBG_INFO(80, "%s: bufSizeInTiles = 0x%x\n", FN_NAME, gc->bufSizeInTiles); - gc->bufSize = gc->bufSizeInTiles * TILE_WIDTH_PXLS * TILE_HEIGHT_PXLS * BYTES_PER_PIXEL; - GDBG_INFO(80, "%s: bufSize = 0x%x\n", FN_NAME, gc->bufSize); - - /* Check for enough memory */ -#ifdef GLIDE_INIT_HWC - if ( ( gc->bufSize * ( gc->grColBuf + gc->grAuxBuf ) + MIN_TEXTURE_STORE + MIN_FIFO_SIZE) > - ( gc->bInfo->h3Mem << 20 ) ) { - GDBG_INFO( gc->myLevel, "Failed to open for insufficient memory\n" ); - GrErrorCallback( "grSstWinOpen: not enough memory for requested buffers", FXFALSE ); - return 0; - } -#endif - - /* Allocate Color/Aux Buffers, Set Memory Layout */ - gcFifo = &gc->cmdTransportInfo; - -#if defined( USE_PACKET_FIFO ) -#if defined( GLIDE_INIT_HWC ) - bInfo = gc->bInfo; - vInfo = &bInfo->vidInfo; - bufInfo = &bInfo->buffInfo; - - /* If we closed down then the hw may have been un-mapped (on - * systems that actually support this) so we need to re-map the - * board and re-cache our hw pointers. - */ - if (!gc->hwInitP) { - if (!hwcMapBoard(bInfo, HWC_BASE_ADDR_MASK)) { - GDBG_INFO( gc->myLevel, "Failed to re-map the hw.\n" ); - GrErrorCallback( FN_NAME": Failed to re-map the hw.", FXFALSE ); - GR_RETURN( FXFALSE ); - } - - if (!hwcInitRegisters(bInfo)) { - GDBG_INFO( gc->myLevel, "Failed to re-initialize the hw.\n" ); - GrErrorCallback( FN_NAME": Failed to re-initialize the hw.", FXFALSE ); - GR_RETURN( FXFALSE ); - } - - gc->sstRegs = (SstRegs*)bInfo->regInfo.sstBase; - gc->ioRegs = (SstIORegs*)bInfo->regInfo.ioMemBase; - gc->cRegs = (SstCRegs*)bInfo->regInfo.cmdAGPBase; - gc->lfb_ptr = (FxU32*)bInfo->regInfo.lfbBase; - gc->rawLfb = (FxU32*)bInfo->regInfo.rawLfbBase; - gc->tex_ptr = (FxU32*)SST_TEX_ADDRESS(bInfo->regInfo.sstBase); - - gc->hwInitP = FXTRUE; - } - - vInfo->xRes = gc->state.screen_width; - vInfo->yRes = gc->state.screen_height; - vInfo->refresh = gc->grSstRefresh; - vInfo->tiled = FXTRUE; - vInfo->initialized = FXTRUE; - - if ( hwcAllocBuffers( bInfo, nColBuffers, nAuxBuffers ) == FXFALSE ) { - GDBG_INFO( gc->myLevel, "hwcAllocBuffers failed\n" ); - GrErrorCallback(hwcGetErrorString(), FXFALSE); - return 0; - } - - for (buffer = 0; buffer < nColBuffers; buffer++) { - gc->buffers[buffer] = bufInfo->colBuffStart[buffer]; - GDBG_INFO(80, "Buffer %d: Start: 0x%x\n", buffer, gc->buffers[buffer]); - gc->lfbBuffers[buffer] = (FxU32)gc->rawLfb + bufInfo->lfbBuffAddr[buffer]; - } - if (nAuxBuffers != 0) { - gc->buffers[buffer] = bufInfo->auxBuffStart; - GDBG_INFO(80, "Aux Buffer: Start: 0x%x\n", gc->buffers[buffer]); - gc->lfbBuffers[buffer] = (FxU32)gc->rawLfb + bufInfo->lfbBuffAddr[buffer]; - } - - vInfo->hWnd = gc->grHwnd; - vInfo->sRes = gc->grSstRez; - vInfo->vRefresh = gc->grSstRefresh; - - if ( hwcInitVideo( bInfo, FXTRUE, gc->vidTimings, FXTRUE ) == FXFALSE ) { - GrErrorCallback(hwcGetErrorString(), FXFALSE); - GDBG_INFO( gc->myLevel, "hwcInitVideo failed\n" ); - return 0; - } - - /* Restore the function specializations if the user is trying to - * recover. This only resets the non-null environment. The actual - * function specializations are recovered later in the mainline - * code path for the open. - */ - if (gc->open && !gc->contextP) { - GrTriSetupProcArchVector* - curTriProcs = _GlideRoot.deviceArchProcs.curTriProcs; - GrVertexListProc* - curVertexListProcs = _GlideRoot.deviceArchProcs.curVertexListProcs; - - _GlideRoot.deviceArchProcs.curTriProcs = _GlideRoot.deviceArchProcs.nullTriProcs; - _GlideRoot.deviceArchProcs.curVertexListProcs = _GlideRoot.deviceArchProcs.nullVertexListProcs; - - _GlideRoot.deviceArchProcs.nullTriProcs = curTriProcs; - _GlideRoot.deviceArchProcs.nullVertexListProcs = curVertexListProcs; - } - - /* This actually gets taken in hwcInitVideo */ - gc->contextP = FXTRUE; - -#ifndef __linux__ - /* CSR - Set up flag for display driver to tell us that context was lost */ - if ( !gc->open ) /* If we already have a context open, then lets not - re-initialize the pointers */ - { - hwcShareContextData(gc->bInfo, &(gc->lostContext)); - gc->cmdTransportInfo.ptrLostContext = &(gc->lostContext); - } - - *gc->lostContext = FXFALSE; -#endif - - if (_GlideRoot.environment.gammaR != -1.f && - _GlideRoot.environment.gammaG != -1.f && - _GlideRoot.environment.gammaB != -1.f) { - hwcGammaRGB(gc->bInfo, - _GlideRoot.environment.gammaR, - _GlideRoot.environment.gammaG, - _GlideRoot.environment.gammaB); - } else { - hwcGammaRGB(gc->bInfo, 1.3f, 1.3f, 1.3f); - } - - /* Setup memory configuration */ - gc->fbOffset = bInfo->fbOffset; - switch (gc->num_tmu) { - case 2: - if (gc->state.grEnableArgs.texture_uma_mode == GR_MODE_ENABLE) { - gc->tmuMemInfo[0].tramOffset = gc->tmuMemInfo[1].tramOffset = bInfo->tramOffset; - gc->tmuMemInfo[0].tramSize = gc->tmuMemInfo[1].tramSize = bInfo->tramSize; - gc->tmu_state[0].total_mem = gc->tmu_state[1].total_mem = gc->tmuMemInfo[0].tramSize; - } - else { - gc->tmuMemInfo[0].tramOffset = bInfo->tramOffset; - - /* - ** if the environment variable is on, use the its texture memory size * 2 - */ - if ((_GlideRoot.environment.tmuMemory != -1) && (gc->fbOffset >= 0x200000)) - bInfo->tramSize = _GlideRoot.environment.tmuMemory << 21; - - /* - ** when tmu size is 2, split the texture memory for each tmu - */ - gc->tmuMemInfo[0].tramSize = bInfo->tramSize >> 1; - gc->tmu_state[0].total_mem = gc->tmuMemInfo[0].tramSize; - - gc->tmuMemInfo[1].tramOffset = gc->tmuMemInfo[0].tramOffset + gc->tmuMemInfo[0].tramSize; - gc->tmuMemInfo[1].tramSize = (bInfo->tramSize >> 1); - gc->tmu_state[1].total_mem = gc->tmuMemInfo[1].tramSize; - } - break; - - case 1: - default: - gc->tmuMemInfo[0].tramOffset = bInfo->tramOffset; - - /* - ** if the environment variable is on, use the its texture memory size - */ - if ((_GlideRoot.environment.tmuMemory != -1) && (gc->fbOffset >= 0x200000)) - bInfo->tramSize = _GlideRoot.environment.tmuMemory << 20; - - gc->tmuMemInfo[0].tramSize = bInfo->tramSize; - gc->tmu_state[0].total_mem = gc->tmuMemInfo[0].tramSize; - break; - } - - gc->tBuffer.bufType = HWC_BUFFER_TEXTUREBUFFER; - gc->tBuffer.bufOffset = bInfo->tramOffset; - gc->tBuffer.bufSize = bInfo->tramSize; - gc->tBuffer.tiled = FXFALSE; - gc->tBuffer.bufBPP = 0xffffffff; /* Don't matter to me */ - - GDBG_INFO(1, "autoBump: 0x%x\n", _GlideRoot.environment.autoBump); - if ((gc->cmdTransportInfo.autoBump = _GlideRoot.environment.autoBump)) { /* [dBorca] avoid warning */ - if (!hwcInitFifo( bInfo, gc->cmdTransportInfo.autoBump)) { - hwcRestoreVideo(bInfo); - GrErrorCallback(hwcGetErrorString(), FXFALSE); - GDBG_INFO(gc->myLevel, "hwcInitFifo failed\n"); - GR_RETURN(FXFALSE); - } - } else { - if (!hwcInitAGPFifo(bInfo, FXTRUE)) { - hwcRestoreVideo(bInfo); - GrErrorCallback(hwcGetErrorString(), FXFALSE); - GDBG_INFO(gc->myLevel, "hwcInitFifo failed\n"); - GR_RETURN(FXFALSE); - } - - /* Check to see where the command fifo was placed since the agp - * allocation might have failed for some reason, and fallen back - * to using the normal video command fifo. - */ - gc->cmdTransportInfo.autoBump = ((GR_CAGP_GET(baseSize) & SST_CMDFIFO_DISABLE_HOLES) == 0); - } - - /* COMMAND FIFO SETUP */ - fInfo = &gc->bInfo->fifoInfo; - - /* Establish physical bounds of cmd fifo from HWC calculation */ - gcFifo->fifoOffset = fInfo->fifoStart; - gcFifo->fifoSize = fInfo->fifoLength; -#elif defined( GLIDE_INIT_HAL ) -#if 0 - gc->fbOffset = 0x200000; - gc->tramOffset = 0x0; - gc->tramSize = gc->fbOffset; - gc->tmu_state[0].total_mem = gc->tramSize; -#else - /* gc->fbOffset = (FxU32)fxHalFbiGetMemory((SstRegs*)gc->reg_ptr); */ - gc->fbOffset = (FxU32)gc->rawLfb; - gc->tmuMemInfo[0].tramOffset = 0x200000; - gc->tmuMemInfo[0].tramSize = 0x200000; - gc->tmuMemInfo[1].tramOffset = gc->tmuMemInfo[0].tramSize + gc->tmuMemInfo[0].tramOffset; - gc->tmuMemInfo[1].tramSize = 0x200000; - gc->tmu_state[0].total_mem = gc->tmuMemInfo[0].tramSize; - gc->tmu_state[1].total_mem = gc->tmuMemInfo[1].tramSize; -#endif - - for ( buffer = 0; buffer < nColBuffers; buffer++ ) { - gc->buffers[buffer] = gc->fbOffset + buffer * gc->bufSize; - /* XXXjdt: this is never initialized in the old code */ - gc->lfbBuffers[buffer] = 0; - GDBG_INFO(80, "%s: Buffer %d: 0x%x\n", - FN_NAME, buffer, gc->buffers[buffer]); - } - if( !fxHalGetDeviceInfo((SstRegs*)gc->reg_ptr, &devInfo) ) { - GrErrorCallback(" XXXGetDeviceInfo failed.\n", FXFALSE); - GDBG_INFO( gc->myLevel, - " XXXGetDeviceInfo failed. (0x%x)\n", - gc->reg_ptr ); - return 0; - } - - /* COMMAND FIFO SETUP */ -#if 0 - gcFifo->fifoOffset = gc->fbOffset + - ( gc->bufSize * ( gc->grColBuf + gc->grAuxBuf ) ); - gcFifo->fifoSize = 0x400000 - gcFifo->fifoOffset + gc->fbOffset; -#else - gcFifo->fifoOffset = ( gc->bufSize * ( gc->grColBuf + gc->grAuxBuf ) ); - gcFifo->fifoSize = 0x20000; -#endif - - if ( !fxHalInitCmdFifo((SstRegs *) gc->reg_ptr, - 0, /* which fifo - 0 for 3d cmd fifo */ - /* v fifoStart - offset from hw base v */ - gcFifo->fifoOffset, - gcFifo->fifoSize, /* size - in bytes */ - FXTRUE, /* directExec */ - FXFALSE, /* disableHoles */ - FXFALSE) /* agpEnable */ ) { -#ifdef GLIDE_INIT_HWC - GrErrorCallBack( "fxHalInitCmdFifo failed.\n", FxFALSE ); -#endif - GDBG_INFO( 0, "Error: fxHalInitCmdFifo failed\n" ); - return 0; - } - if ( !fxHalInitVideo( (SstRegs*) gc->reg_ptr, - (resolution == GR_RESOLUTION_NONE) ? GR_RESOLUTION_640x480 - : (resolution), - refresh, - NULL ) ) { -#ifdef GLIDE_INIT_HWC - GrErrorCallBack( "fxHalInitVideo failed.\n", FxFALSE ); -#endif - GDBG_INFO( 0, "Error: fxHalInitVideo failed\n" ); - GR_RETURN( FXFALSE ); - } - fxHalInitVideoOverlaySurface( (SstRegs*) gc->reg_ptr, /* SstRegs */ - FXTRUE, /* 1=enable Overlay surface*/ - FXFALSE, /* 1=enable OS stereo, 0=disable*/ - FXFALSE, /* 1=enable horizontal*/ - 0, /* horizontal scale factor (ignored if*/ - FXFALSE, /* 1=enable vertical scaling,*/ - 0, /* vertical scale factor (ignored if not*/ - 0, /* duh*/ - 1, /* 0=OS linear, 1=tiled*/ - SST_OVERLAY_PIXEL_RGB565U, /* pixel format of OS*/ - FXFALSE, /* bypass clut for OS?*/ - FXFALSE, /* 0=lower 256 CLUT entries,*/ - gc->buffers[gc->curBuffer], /* board address of beginning of OS */ - gc->strideInTiles ); /* distance between scanlines of the OS, in*/ - - gc->contextP = FXTRUE; - -#endif /* defined( GLIDE_INIT_HAL ) */ -#else /* !defined( USE_PACKET_FIFO ) */ - gc->fbOffset = 0x0; - gc->tramOffset[0] = 0x200000; - gc->tramSize[0] = 0x200000; - gc->tramOffset[1] = gc->tramSize[0] + gc->tramOffset[0]; - gc->tramSize[1] = 0x200000; -#if 0 - gc->tmu_state[0].total_mem = gc->tramSize; - gc->fbOffset = 0x200000; - gc->tramOffset = 0x0; - gc->tramSize = gc->fbOffset; - gc->tmu_state[0].total_mem = gc->tramSize; - - for ( buffer = 0; buffer < nColBuffers; buffer++ ) { - gc->buffers[buffer] = gc->fbOffset + buffer * gc->bufSize; - /* XXXjdt: this is never initialized in the old code */ - gc->lfbBuffers[buffer] = 0; - GDBG_INFO(80, "%s: Buffer %d: 0x%x\n", - FN_NAME, buffer, gc->buffers[buffer]); - } -#endif - if( !fxHalGetDeviceInfo((SstRegs*)gc->reg_ptr, &devInfo) ) { - GrErrorCallback(" XXXGetDeviceInfo failed.\n", FXFALSE); - GDBG_INFO( gc->myLevel, - " XXXGetDeviceInfo failed. (0x%x)\n", - gc->reg_ptr ); - GR_RETURN( 0 ); - } -#if 0 - /* COMMAND FIFO SETUP */ - gcFifo->fifoOffset = gc->fbOffset + - ( gc->bufSize * ( gc->grColBuf + gc->grAuxBuf ) ); - gcFifo->fifoSize = 0x400000 - gcFifo->fifoOffset + gc->fbOffset; - - if ( !fxHalInitCmdFifo((SstRegs *) gc->reg_ptr, - 0, /* which fifo - 0 for 3d cmd fifo */ - /* v fifoStart - offset from hw base v */ - gcFifo->fifoOffset, - gcFifo->fifoSize, /* size - in bytes */ - FXTRUE, /* directExec */ - FXFALSE, /* disableHoles */ - FXFALSE) /* agpEnable */ ) { -#ifdef FX_FAIL_HWC - GrErrorCallBack( "fxHalInitCmdFifo failed.\n", FxFALSE ); -#endif - GDBG_INFO( 0, "Error: fxHalInitCmdFifo failed\n" ); - GR_RETURN( 0 ); - } -#endif - if ( !fxHalInitVideo( (SstRegs*) gc->reg_ptr, - (resolution == GR_RESOLUTION_NONE) ? GR_RESOLUTION_640x480 - : (resolution), - refresh, - NULL ) ) { - GR_RETURN( 0 ); - } - fxHalInitVideoOverlaySurface( (SstRegs*) gc->reg_ptr, /* SstRegs */ - FXTRUE, /* 1=enable Overlay surface*/ - FXFALSE, /* 1=enable OS stereo, 0=disable*/ - FXFALSE, /* 1=enable horizontal*/ - 0, /* horizontal scale factor (ignored if*/ - FXFALSE, /* 1=enable vertical scaling,*/ - 0, /* vertical scale factor (ignored if not*/ - 0, /* duh*/ - 1, /* 0=OS linear, 1=tiled*/ - SST_OVERLAY_PIXEL_RGB565U, /* pixel format of OS*/ - FXFALSE, /* bypass clut for OS?*/ - FXFALSE, /* 0=lower 256 CLUT entries,*/ - gc->buffers[gc->curBuffer], /* board address of beginning of OS */ - gc->strideInTiles ); /* distance between scanlines of the OS, in*/ - _grReCacheFifo(0); -#endif /* !defined( USE_PACKET_FIFO ) */ - - /* Compute Virtual FIFO address extents */ - gcFifo->fifoStart = gc->rawLfb + ( gcFifo->fifoOffset >> 2 ); - gcFifo->fifoEnd = gcFifo->fifoStart + ( gcFifo->fifoSize >> 2 ); - - /* Adjust room values. - ** RoomToEnd needs enough room for the jmp packet since we never - ** allow the hw to auto-wrap. RoomToRead needs to be adjusted so that - ** we never acutally write onto the read ptr. - ** - ** fifoRoom is generally the min of roomToEnd and roomToRead, but we - ** 'know' here that roomToRead < roomToEnd. - */ - gcFifo->roomToEnd = gcFifo->fifoSize - FIFO_END_ADJUST; - gcFifo->fifoRoom = gcFifo->roomToReadPtr = gcFifo->roomToEnd - sizeof( FxU32 ); - - /* Set initial fifo state. hw read and sw write pointers at - * start of the fifo. - */ - gcFifo->fifoPtr = gcFifo->fifoStart; - gcFifo->fifoRead = HW_FIFO_PTR( FXTRUE ); - - if ( (void*)gcFifo->fifoPtr != (void*)gcFifo->fifoRead ) { -#ifdef GLIDE_INIT_HWC - hwcRestoreVideo( bInfo ); -#endif - GDBG_INFO( gc->myLevel, "Initial fifo state is incorrect\n" ); - return 0; - } - - if (!gc->cmdTransportInfo.autoBump) { - gcFifo->bumpSize = _GlideRoot.environment.bumpSize; - - gcFifo->lastBump = gcFifo->fifoPtr; - gcFifo->bumpPos = gcFifo->fifoPtr + gcFifo->bumpSize; - - gcFifo->fifoJmpHdr[0] = - ( SSTCP_PKT0_JMP_AGP | - ( gcFifo->fifoOffset << ( SSTCP_PKT0_ADDR_SHIFT - 2 ))); - gcFifo->fifoJmpHdr[1] = (gcFifo->fifoOffset >> 25); - - - } else { - gcFifo->fifoJmpHdr[0] = - ( SSTCP_PKT0_JMP_LOCAL | - ( gcFifo->fifoOffset << ( SSTCP_PKT0_ADDR_SHIFT - 2 ))); - - - } - - GDBG_INFO(80, "Command Fifo:\n" - "\tfifoStart: 0x%x\n" - "\tfifoEnd: 0x%x\n" - "\tfifoOffset: 0x%x\n" - "\tfifoSize: 0x%x\n" - "\tfifoPtr: 0x%x\n", - gcFifo->fifoStart, - gcFifo->fifoEnd, - gcFifo->fifoOffset, - gcFifo->fifoSize, - gcFifo->fifoPtr ); - - /* The hw is now in a usable state from the fifo macros. - * - * NB: See the comment in fxglide.h for the difference between - * these flags. - */ - gc->open = FXTRUE; - - /* Setup the procs that we can do w/o any mode knowledge */ - gc->archDispatchProcs.texDownloadProcs = _GlideRoot.deviceArchProcs.curTexProcs; - gc->archDispatchProcs.drawTrianglesProc = _GlideRoot.deviceArchProcs.curDrawTrisProc; - - /* Default render procs to window space */ - gc->archDispatchProcs.coorModeTriVector = (*_GlideRoot.deviceArchProcs.curTriProcs) + GR_WINDOW_COORDS; - gc->archDispatchProcs.drawVertexList = _GlideRoot.deviceArchProcs.curVertexListProcs[GR_WINDOW_COORDS]; - - /*------------------------------------------------------ - GC Init - ------------------------------------------------------*/ - GDBG_INFO(gc->myLevel, " GC Init\n"); - initGC( gc ); - - gc->orgSW = gc->state.screen_width; - gc->orgSH = gc->state.screen_height; - - /*------------------------------------------------------ - 3D State Init - ------------------------------------------------------*/ - GDBG_INFO( gc->myLevel, " 3D State Init\n"); - - GDBG_INFO( gc->myLevel, " Setting default register states\n" ); - gc->state.shadow.fbzMode = ( SST_ENRECTCLIP | SST_ENZBIAS ); - - GDBG_INFO( gc->myLevel, " Setting up initial draw buffer state\n" ); - REG_GROUP_BEGIN(BROADCAST_ID, leftOverlayBuf, 1, 0x1); - REG_GROUP_SET(hw, leftOverlayBuf, gc->buffers[1]); - REG_GROUP_END(); - - REG_GROUP_BEGIN(BROADCAST_ID, swapbufferCMD, 1, 0x1); - REG_GROUP_SET(hw, swapbufferCMD, 0x0); - REG_GROUP_END(); - - gc->state.shadow.colBufferAddr = gc->buffers[gc->curBuffer]; - gc->state.shadow.colBufferStride = gc->strideInTiles | SST_BUFFER_MEMORY_TILED; - gc->state.shadow.auxBufferAddr = gc->buffers[nColBuffers]; - gc->state.shadow.auxBufferStride = gc->strideInTiles | SST_BUFFER_MEMORY_TILED; - -#ifdef GLIDE_INIT_HWC - REG_GROUP_BEGIN(BROADCAST_ID, colBufferAddr, 4, 0xf); - { - REG_GROUP_SET(hw, colBufferAddr, gc->state.shadow.colBufferAddr); - REG_GROUP_SET(hw, colBufferStride, gc->state.shadow.colBufferStride); - REG_GROUP_SET(hw, auxBufferAddr, gc->state.shadow.auxBufferAddr); - REG_GROUP_SET(hw, auxBufferStride, gc->state.shadow.auxBufferStride); - } - REG_GROUP_END(); -#endif - - GDBG_INFO( gc->myLevel, " Setting all Glide state\n" ); - assertDefaultState(); - clearBuffers( gc ); - - /* The new splash know the color format so we move it above splash screen */ - gc->state.color_format = format; - - /* -------------------------------------------------------- - Splash Screen - --------------------------------------------------------*/ - doSplash(); - - - gc->windowed = FXFALSE; - _GlideRoot.windowsInit++; /* to avoid race with grSstControl() */ - - retVal = (GrContext_t)gc; - - GR_END(); - } - - return retVal; -#undef FN_NAME -} /* grSstWinOpen */ - -/*------------------------------------------------------------------- - Function: grSstWinClose - Date: 3/16 - Implementor(s): jdt - Library: Glide - Description: - Shut down the selected SST - - Shutdown has 4 steps - - 3D Idle - the 3D engine must be idled to make sure that there are no - commands executing in the transport when the registers are - reset - - GC Reset - the GC is flagged as unitialized - (nosup) - - Command Transport Disable - the command transport to the 3D device is put in a state - of reset. No further commands may be issued throught the - command transport - - Video Restore - video is restored to its pre-open state. - - Arguments: - none - Return: - none - -------------------------------------------------------------------*/ -GR_ENTRY(grSstWinClose, FxBool, (GrContext_t context)) -{ -#define FN_NAME "grSstWinClose" - GrGC* gc = (GrGC*)context; - GDBG_INFO(80, FN_NAME"(0x%X)\n", context); - -#ifndef __linux__ - if (gc->lostContext) { - if (*gc->lostContext) - return 0; - } -#endif - - /* NB: The gc that is being closed is the passed gc not the - * currently selected gc. This must be setup before the - * 'declaration' which grabs the current gc in grFlush. In - * addition, it is possible for us to have 'missed' a thread attach - * if the current thread came into existance before glide was - * explicitly loaded by an application. In this case we have to set - * the tls gc explicitly otherwise other whacky-ness (read 'random - * crashes' will ensue). - */ - setThreadValue((FxU32)gc); - if ((gc != NULL) && gc->open) grFlush(); - - /* Make sure that the user specified gc is not whacked */ - if ((gc != NULL) && - (gc >= _GlideRoot.GCs) && - (gc <= _GlideRoot.GCs + MAX_NUM_SST)) { - if (gc->open) { -#if GLIDE_INIT_HAL - /* dpc - 22 may 1997 - FixMe! - * We need the equivilant stuff in the hal layer too. - */ -#else /* !GLIDE_INIT_HAL */ - /*-------------------------- - 3D Idle - --------------------------*/ - GDBG_INFO(gc->myLevel, " 3D Idle"); - - /*-------------------------- - Command Transport Disable - --------------------------*/ - GDBG_INFO(gc->myLevel, " Command Transport Disable"); - - /* Video Restore - * - * NB: The hwcRestoreVideo in addition to restoring the video also - * turns off the command fifo and then releases the hw context - * which can unmap the board at the driver level. The next time - * we use grSstWinOpen we need to re-map the board etc just to be - * safe everywhere. - */ - GDBG_INFO(gc->myLevel, " Restore Video"); -#ifndef __linux__ - if (!*gc->lostContext) -#endif - hwcRestoreVideo(gc->bInfo); -#endif /* !GLIDE_INIT_HAL */ - - /*-------------------------- - GC Reset - --------------------------*/ - GDBG_INFO(gc->myLevel, " GC Reset"); - - /* These are really two different things. - * - * hwInitP indicates whether the init code mapping/init sequence - * is active for this hw. - * - * open includes setting up video, command transport, and the - * initial glide state. - */ - gc->hwInitP = FXFALSE; - - _grDisplayStats(); - } - gc->open = FXFALSE; - gc->grSstRez = GR_RESOLUTION_NONE; - gc->grSstRefresh = GR_REFRESH_NONE; - - - } - _GlideRoot.windowsInit--; - -#if !defined(__linux__) && !defined(__DJGPP__) /* [dBorca] */ - if ( gc->bInfo->osNT ) - hwcUnmapMemory(); - else - hwcUnmapMemory9x ( gc->bInfo ); -#endif - - return FXTRUE; -#undef FN_NAME -} /* grSstWinClose */ - - - -/*------------------------------------------------------------------- - Function: grSelectContext - Date: 18-Jan-98 - Implementor(s): atai, taco - Description: - - Designates a context as current. This selects a named state vector - with it's own command transport as the current target for all glide - commands. - - Arguments: - - context - name of context - - Return: - - TRUE - valid context - FALSE - invalid context - -------------------------------------------------------------------*/ -/* NOTE: THIS FUNCTION CAN BE CALLED WHEN THERE IS NO VALID GC */ -GR_DIENTRY(grSelectContext, FxBool , (GrContext_t context) ) -{ -#define FN_NAME "grSelectContext" - GrGC* - gc = (GrGC*)context; - FxBool - rv = FXFALSE; - - GDBG_INFO( 80, FN_NAME"(0x%X)\n", context ); - - /* WTF?!?!?!?!!? - dpc - 31 mar 1999 - I was not aware that apps - * could select invalid contexts. They're not supposed to call - * grSstWinClose w/ some whacked value, why's this function any - * different? - */ - if ( context == 0 ) { - GDBG_INFO( 80, "NULL Context passed\n" ); - rv = FXFALSE; - } else { - setThreadValue( context ); - if (gc != NULL) { - if (gc->windowed) { - /* Setup the procs that we can do w/o any mode knowledge */ - gc->archDispatchProcs.texDownloadProcs = _GlideRoot.deviceArchProcs.curTexProcs; - gc->archDispatchProcs.drawTrianglesProc = _GlideRoot.deviceArchProcs.curDrawTrisProc; - - /* Default render procs to window space */ - gc->archDispatchProcs.coorModeTriVector = (*_GlideRoot.deviceArchProcs.curTriProcs) + GR_WINDOW_COORDS; - gc->archDispatchProcs.drawVertexList = _GlideRoot.deviceArchProcs.curVertexListProcs[GR_WINDOW_COORDS]; - - gc->contextP = FXTRUE; - gc->open = FXTRUE; - - rv = FXTRUE; - } else { - const FxBool - oldContextState = gc->contextP; - - GR_ASSERT((gc >= _GlideRoot.GCs) && - (gc <= _GlideRoot.GCs + MAX_NUM_SST)); - -#if defined( GLIDE_INIT_HWC ) && !defined(__linux__) - gc->contextP = hwcQueryContext(gc->bInfo); -#else - gc->contextP = 1; -#endif - rv = gc->contextP; - - /* We may now need to fiddle w/ the current specialization - * vectors. The fifo writing macros are 'smart' (in a dumb - * sort of way) about not writing to the fifo, but the - * specialized routines in assembly are not. We replace the - * base specialization vectors here w/ null (empty that is) - * vectors that don't do anything. - */ - if (!gc->contextP && oldContextState) { - GrTriSetupProcArchVector* - curTriProcs = _GlideRoot.deviceArchProcs.curTriProcs; - GrVertexListProc* - curVertexListProcs = _GlideRoot.deviceArchProcs.curVertexListProcs; - - _GlideRoot.deviceArchProcs.curTriProcs = _GlideRoot.deviceArchProcs.nullTriProcs; - _GlideRoot.deviceArchProcs.curVertexListProcs = _GlideRoot.deviceArchProcs.nullVertexListProcs; - - _GlideRoot.deviceArchProcs.nullTriProcs = curTriProcs; - _GlideRoot.deviceArchProcs.nullVertexListProcs = curVertexListProcs; - - gc->archDispatchProcs.texDownloadProcs = _GlideRoot.deviceArchProcs.nullTexProcs; - gc->archDispatchProcs.drawTrianglesProc = _GlideRoot.deviceArchProcs.nullDrawTrisProc; - gc->archDispatchProcs.coorModeTriVector = (*_GlideRoot.deviceArchProcs.curTriProcs) + GR_WINDOW_COORDS; - gc->archDispatchProcs.drawVertexList = _GlideRoot.deviceArchProcs.curVertexListProcs[GR_WINDOW_COORDS]; - } - } - } - } - - GDBG_INFO(80, "%s() => 0x%x---------------------\n", FN_NAME, rv ); - return rv; -#undef FN_NAME -} /* grSelectConetext */ - - -/*--------------------------------------------------------------------------- -** grStatsResetPerfStats -*/ - -void FX_CSTYLE -_grSstResetPerfStats(void) -{ -#define FN_NAME "grSstResetPerfStats" - GR_BEGIN("grSstResetPerfStats",83,4, 1); - GDBG_INFO_MORE(gc->myLevel,"()\n"); - GR_SET(BROADCAST_ID, hw, nopCMD, 1); - GR_END(); -#undef FN_NAME -} /* grSstResetPerfStats */ - - -/*--------------------------------------------------------------------------- -** grSstStatus - return contents of status register -*/ - -FxU32 FX_CSTYLE -_grSstStatus(void) -{ -#define FN_NAME "grSstStatus" - FxU32 status; - - GR_BEGIN_NOFIFOCHECK_RET(FN_NAME, 83); - - status = GR_GET(hw->status); - - return(status); - - GR_END(); -#undef FN_NAME -}/* grSstStatus */ - -/*--------------------------------------------------------------------------- -** grSstVideoLine - return current video line number -*/ - -FxU32 FX_CSTYLE -_grSstVideoLine(void) -{ - FxU32 vline = 1; - - return vline; -}/* grSstVideoLine */ - -/*--------------------------------------------------------------------------- -** grSstVRetrace - return contents of SST_VRETRACE bit of status register; -*/ - -FxBool FX_CSTYLE -_grSstVRetraceOn(void) -{ - FxU32 status; - GR_BEGIN_NOFIFOCHECK_RET("grSstVRetraceOn",83); - - status = GR_GET(hw->status); - - return ((status & SST_VRETRACE) == 0); - -}/* grSstVRetrace */ - -/*------------------------------------------------------------------- - Function: grFlush - Date: 09-Jan-98 - Implementor(s): atai - Description: - - Arguments: - - Return: - -------------------------------------------------------------------*/ -GR_ENTRY(grFlush, void, (void)) -{ -#define FN_NAME "grFlush" - GR_BEGIN_NOFIFOCHECK( "grFlush", 80 ); - GDBG_INFO_MORE(gc->myLevel,"()\n"); - - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, nopCMD, 0x0); - GR_CHECK_SIZE(); - - if ( gc->windowed ) { -#ifdef GLIDE_INIT_HWC - GDBG_INFO(gc->myLevel + 200, FN_NAME": cmdSize(0x%X)\n", - ((FxU32)gc->cmdTransportInfo.fifoPtr - - (FxU32)gc->cmdTransportInfo.hwcFifoInfo.cmdBuf.baseAddr)); -#endif - _FifoFlush(); - } else if (!gc->cmdTransportInfo.autoBump) { - GR_BUMP_N_GRIND; - } - - GR_END(); -#undef FN_NAME -} /* grFlush */ - -/*--------------------------------------------------------------------------- -** grSstIdle/grFinish -*/ -GR_ENTRY(grFinish, void, (void)) -#define FN_NAME "grFinish" -{ - GR_BEGIN_NOFIFOCHECK(FN_NAME, 83); - GDBG_INFO_MORE(gc->myLevel,"()\n"); - - grFlush(); - if ( gc->windowed ) { -#if defined( GLIDE_INIT_HWC ) && !defined( __linux__ ) && !defined(__DJGPP__) /* [dBorca] */ - struct cmdTransportInfo* - gcFifo = &gc->cmdTransportInfo; - - /* Make sure that the issued commands have been executed. */ - while(hwcExecuteStatusWinFifo(gc->bInfo, - &gcFifo->hwcFifoInfo, - gcFifo->issuedSerialNumber) != gcFifo->issuedSerialNumber) { - /* Do Nothing? */; - } -#endif - } else { - while((_grSstStatus() & SST_BUSY) != 0) - /* Do Nothing */; - } - - GR_END(); -#undef FN_NAME -} /* grSstIdle */ - -/*--------------------------------------------------------------------------- -** grSstIsBusy - find out if the SST is busy or not -*/ - -FxBool FX_CSTYLE -grSstIsBusy(void) -{ -#define FN_NAME "grSstIsBusy" - static FxBool nopP = FXTRUE; - FxBool busy; - GR_BEGIN_NOFIFOCHECK_RET("grSstIsBusy", 80); - - /* dpc - 22 may 1997 - FixMe! - * Seems like the simplest way to do it, but is this really the way - * to do it? - */ - if (nopP) { - GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); - GR_SET(BROADCAST_ID, hw, nopCMD, 0); - GR_CHECK_SIZE(); - } - - if ( gc->windowed ) { - _FifoFlush(); - busy = 0; - } else { - busy = ((_grSstStatus() & SST_BUSY) != 0); - } - - nopP = !busy; - - GDBG_INFO(84,"grSstIsBusy() => 0x%x\n", busy); - - return busy; -#undef FN_NAME -}/* grSstIsBusy */ - -#if defined(GLIDE3) && defined(GLIDE3_ALPHA) -/*--------------------------------------------------------------------------- -** guGammaCorrectionRGB - set the gamma correction value -*/ - -GR_ENTRY(guGammaCorrectionRGB, void, (float r, float g, float b)) -{ - GR_BEGIN_NOFIFOCHECK("guGammaCorrectionValue",80); - GDBG_INFO_MORE(gc->myLevel,"(%g %g %g)\n",r, g, b); - -#if GLIDE_INIT_HAL - fxHalInitGamma(hw, r); -#else /* !GLIDE_INIT_HAL */ - if (gc) - hwcGammaRGB(gc->bInfo, r, g, b); -#endif /* !GLIDE_INIT_HAL */ - - GR_END(); -} /* guGammaCorrectionRGB */ - -/*------------------------------------------------------------------- - Function: grLoadGammaTable - Date: 05-Jan-97 - Implementor(s): atai - Description: - - Arguments: - - Return: - -------------------------------------------------------------------*/ -GR_DIENTRY(grLoadGammaTable, void, (FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue)) -{ -#define FN_NAME "grLoadGammaTable" - FxU32 max; - - GR_BEGIN_NOFIFOCHECK("grLoadGammaTable",80); - - grGet(GR_GAMMA_TABLE_ENTRIES, 4, (FxI32 *)&max); - if (nentries > max) - nentries = max; - -#ifdef GLIDE_INIT_HWC - hwcGammaTable(gc->bInfo, nentries, red, green, blue); -#endif - - GR_END(); -#undef FN_NAME -} -#endif - -#ifndef GLIDE3 -/*--------------------------------------------------------------------------- -** grGammaCorrectionValue - set the gamma correction value -*/ - -GR_ENTRY(grGammaCorrectionValue, void, (float gamma)) -{ - GR_BEGIN_NOFIFOCHECK("grGammaCorrectionValue",80); - GDBG_INFO_MORE(gc->myLevel,"(%g)\n",gamma); - -#if GLIDE_INIT_HAL - fxHalInitGamma(hw, gamma); -#else /* !GLIDE_INIT_HAL */ - - hwcGamma(gc->bInfo, gamma, gamma, gamma); - -#endif /* !GLIDE_INIT_HAL */ - - GR_END(); -} /* grGammaCorrectionValue */ -#endif - -/*--------------------------------------------------------------------------- -** grSstOrigin - Set the orgin orientation of the screen. -** -** Returns: -** -** Notes: -** -*/ - -GR_STATE_ENTRY(grSstOrigin, void, (GrOriginLocation_t origin)) -{ -#define FN_NAME "grSstOrigin" - FxU32 fbzMode; - GR_BEGIN_NOFIFOCHECK("grSstOrigin", 83); - GDBG_INFO_MORE(gc->myLevel, "(%d)\n", origin); - - /* Initialize FBZMODE register */ - fbzMode = gc->state.shadow.fbzMode; - if (origin == GR_ORIGIN_LOWER_LEFT) - fbzMode |= SST_YORIGIN; - else - fbzMode &= ~(SST_YORIGIN); - - /* dpc - 22 may 1997 - FixMe! - * Do we need to do anything here for the HAL? - */ -#if !GLIDE_INIT_HAL - /* dpc - 5 sep 1997 - FixMe! - * This is the old way. Is there anything else we - * need to do here? - * - * initOrigin(origin); - */ -#endif - - gc->state.shadow.fbzMode = fbzMode; - -#if !GLIDE3 - REG_GROUP_BEGIN(BROADCAST_ID, fbzMode, 0x1, 0x1); - REG_GROUP_SET(hw, fbzMode, fbzMode); - REG_GROUP_END(); -#endif - -#undef FN_NAME -} /* grSstOrigin */ - -/* GMT: do we really have users for this??? - * CHD: No. - * JDT: Huh? If you're talking about grSstOrigin, you're smoking crack. - * if you are talking about SstConfigPipeline, it is evil and must - * be destroyed. :) - * dpc: There is one user that I know of. This 'Nature' demo that Scott just - * gave me. - * chd: It's a stub now. - * (much time elapses) - * chd: But WTF is that forward decl down there? - * dpc: Its to get rid of the damn compiler warning for a function that - * we only sort of export. - */ - -extern FX_ENTRY void FX_CALL -grSstConfigPipeline(GrChipID_t chip, FxU32 reg, FxU32 value); - -/*--------------------------------------------------------------------------- -** grSstConfigPipeline -*/ - -GR_ENTRY(grSstConfigPipeline, void, (GrChipID_t chip, FxU32 reg, FxU32 value)) -{ -} /* grSstConfigPipeline */ - diff --git a/glide3x/h3/glide3/src/gtexdl.c b/glide3x/h3/glide3/src/gtexdl.c index 3d1c163..bfd7fc1 100644 --- a/glide3x/h3/glide3/src/gtexdl.c +++ b/glide3x/h3/glide3/src/gtexdl.c @@ -19,6 +19,9 @@ ** ** $Header$ ** $Log$ +** Revision 1.1.1.1 1999/11/24 21:44:57 joseph +** Initial checkin for SourceForge +** ** ** 5 5/26/99 9:22a Stb_acampbel ** Removed an extra string format parameter from a debug output statement @@ -264,6 +267,361 @@ #include "fxglide.h" #include "fxcmd.h" +#define GLIDE_POINTCAST_PALETTE 1 + +/*--------------------------------------------------------------------------- +** _grTexDownloadNccTableExt +** +** Downloads an ncctable to the specified _physical_ TMU(s). This +** function is called internally by Glide and should not be executed +** by an application. +*/ +GR_DDFUNC(_grTexDownloadNccTableExt, + void, + (GrChipID_t tmu, FxU32 which, const GuNccTable *table, int start, int end)) +{ +#define FN_NAME "_grTexDownloadNccTableExt" + GR_BEGIN_NOFIFOCHECK(FN_NAME,89); + GDBG_INFO_MORE(gc->myLevel,"(%d,%d, 0x%x, %d,%d)\n",tmu,which,table,start,end); + GR_ASSERT(start==0); + GR_ASSERT(end==11); + + /* check for null pointer */ + if (table == NULL) return; + + gc->stats.palDownloads++; + gc->stats.palBytes += (end-start+1)<<2; + + /*if (gc->tmu_state[tmu].ncc_table[which] != table)*/ { + SstRegs* texHW; + int i; +#ifdef GLIDE_POINTCAST_PALETTE + texHW = SST_TMU(hw,tmu); +#else + texHW = SST_CHIP(hw, 0x06UL); +#endif + + if (which == 0) { +#ifdef GLIDE_POINTCAST_PALETTE + REG_GROUP_BEGIN((0x02UL << tmu), nccTable0, 12, 0x0FFF); +#else + REG_GROUP_BEGIN(0x06UL, nccTable0, 12, 0x0FFF); +#endif + for (i = 0; i < 12; i++) { + gc->state.shadow.tmuState[tmu].nccTable0[i] = table->packed_data[i]; + REG_GROUP_SET(texHW, nccTable0[i], table->packed_data[i]); + } + REG_GROUP_END(); + } else { +#ifdef GLIDE_POINTCAST_PALETTE + REG_GROUP_BEGIN((0x02UL << tmu), nccTable1, 12, 0x0FFF); +#else + REG_GROUP_BEGIN(0x06UL, nccTable1, 12, 0x0FFF); +#endif + for (i = 0; i < 12; i++) { + gc->state.shadow.tmuState[tmu].nccTable1[i] = table->packed_data[i]; + REG_GROUP_SET(texHW, nccTable1[i], table->packed_data[i]); + } + REG_GROUP_END(); + } + + gc->tmu_state[tmu].ncc_table[which] = table; + } + + GR_END(); +#undef FN_NAME +} /* _grTexDownloadNccTableExt */ + +/*------------------------------------------------------------------- + Function: _grTexDownloadPaletteExt + Date: 6/9 + Implementor(s): jdt + Library: Glide + Description: + Private function to download a palette to the specified tmu + Arguments: + tmu - which tmu to download the palette to + pal - the pallete data + start - beginning index to download + end - ending index to download + Return: + none + -------------------------------------------------------------------*/ +GR_DDFUNC(_grTexDownloadPaletteExt, + void, + (GrChipID_t tmu, GrTexTable_t type, GuTexPalette *pal, int start, int end)) +{ +#define FN_NAME "_grTexDownloadPaletteExt" + GR_BEGIN_NOFIFOCHECK(FN_NAME, 89); + GDBG_INFO_MORE(gc->myLevel,"(%d,0x%x, %d,%d)\n",tmu,pal,start,end); + + GR_CHECK_F(FN_NAME, pal == NULL, "pal invalid"); + GR_CHECK_F(FN_NAME, start < 0, "invalid start index"); + GR_CHECK_F(FN_NAME, end > 255, "invalid end index"); + + /* NOTE: + ** + ** This code broadcasts the palette because in the future, we will + ** only support one global texture palette no matter how many TMUs + ** there are. This is fallout from the fact that future hardware + ** has a unified memory architecture. + ** + ** Source licensees (meaning arcade or LBE vendors that) require the + ** one palette/tmu mode should define GLIDE_POINTCAST_PALETTE on + ** the command line for this file. Understand, however, that this + ** will not work on future hardware. + */ + +#ifdef GLIDE_POINTCAST_PALETTE + /* + ** FURTHER NOTE: + ** There is a sublety (nice way of saying BUG) here. + ** If TMU0 is specified, then the palette will be broadcast to all + ** TMUS. So, if the user downloads TMU1's palette, then TMU0's + ** palette, TMU0's palette will be on *both* TMUs. This is a + ** pretty strong indicator that no one is using separate palettes + ** on different TMUs. + */ + hw = SST_TMU(hw,tmu); +#else + hw = SST_CHIP(hw,0xE); +#endif + + gc->stats.palDownloads++; + gc->stats.palBytes += ((end - start + 1) << 2); + + /* We divide the writes into 3 chunks trying to group things into + * complete 8 word grouped packets to fit the nccTable palette + * format: stuff before the 8 word alignment, aligned writes, and + * stuff after the 8 word alignment to the end. The slop regions + * are one packet apiece. + */ + { +#ifdef GLIDE_POINTCAST_PALETTE + const FifoChipField chipId = (FifoChipField)(0x02UL << tmu); +#else + const FifoChipField chipId = (FifoChipField)0x06UL; +#endif + const int endSlop = (end & ~0x07); + const int startSlop = MIN(((start + 8) & ~0x07) - 1, end); + int i = start; + + if (type == GR_TEXTABLE_PALETTE) { + /* Is the start of the palette range unaligned or is the end of + * the range less than a completely aligned range? + */ + if (((start & 0x07) != 0) || (end < ((start + 8) & ~0x07))) { + const FxI32 slopCount = startSlop - start + 1; + GR_ASSERT((slopCount > 0) && (slopCount <= 8)); + + REG_GROUP_BEGIN(chipId, nccTable0[4 + (start & 0x07)], + slopCount, (0xFF >> (8 - slopCount))); + while(i < start + slopCount) { + FxU32 entry; + + entry = (0x80000000 | ((i & 0xFE) << 23) | pal->data[i] & 0xFFFFFF); + + gc->state.shadow.paletteRow[i>>3].data[i&7] = entry; + REG_GROUP_SET(hw, nccTable0[4 + (i & 0x07)], entry ); + + i++; + } + REG_GROUP_END(); + } + + /* Do all of the aligned palette ranges. */ + while(i < endSlop) { + const int endIndex = i + 8; + + REG_GROUP_BEGIN(chipId, nccTable0[4], 8, 0xFF); + while(i < endIndex) { + FxU32 entry; + + entry = (0x80000000 | ((i & 0xFE) << 23) | pal->data[i] & 0xFFFFFF); + + gc->state.shadow.paletteRow[i>>3].data[i&7] = entry; + REG_GROUP_SET(hw, nccTable0[4 + (i & 0x07)], entry ); + + i++; + } + REG_GROUP_END(); + } + + /* Do we have any more slop at the end of the ragne? */ + if (i <= end) { + const FxU32 slopCount = end - endSlop + 1; + + REG_GROUP_BEGIN(chipId, nccTable0[4], + slopCount, (0xFF >> (8 - slopCount))); + while(i <= end) { + FxU32 entry; + + entry = (0x80000000 | ((i & 0xFE) << 23) | pal->data[i] & 0xFFFFFF); + + gc->state.shadow.paletteRow[i>>3].data[i&7] = entry; + REG_GROUP_SET(hw, nccTable0[4 + (i & 0x07)], entry ); + + i++; + } + REG_GROUP_END(); + } + } else { + /* Is the start of the palette range unaligned or is the end of + * the range less than a completely aligned range? + */ + if (((start & 0x07) != 0) || (end < ((start + 8) & ~0x07))) { + const FxI32 slopCount = startSlop - start + 1; + GR_ASSERT((slopCount > 0) && (slopCount <= 8)); + + REG_GROUP_BEGIN(chipId, nccTable0[4 + (start & 0x07)], + slopCount, (0xFF >> (8 - slopCount))); + while(i < start + slopCount) { + FxU32 + p1, p2, p3, p4, + entry; + + p1 = p2 = pal->data[i]; + p1 &= 0xfc000000; p2 &= 0x00fc0000; + p1 >>= 8; p2 >>= 6; + p3 = p4 = pal->data[i]; + p3 &= 0x0000fc00; p4 &= 0x000000fc; + p3 >>= 4; p4 >>= 2; + p1 |= p2; p3 |= p4; p1 |= p3; + + entry = (0x80000000UL | ((i & 0xFEUL) << 23) | p1); + gc->state.shadow.paletteRow[i>>3].data[i&7] = entry; + REG_GROUP_SET(hw, nccTable0[4 + (i & 0x07)], entry); + + i++; + } + REG_GROUP_END(); + } + + /* Do all of the aligned palette ranges. */ + while(i < endSlop) { + const int endIndex = i + 8; + + REG_GROUP_BEGIN(chipId, nccTable0[4], 8, 0xFF); + while(i < endIndex) { + FxU32 p1, p2, p3, p4; + p1 = p2 = pal->data[i]; + p1 &= 0xfc000000; p2 &= 0x00fc0000; + p1 >>= 8; p2 >>= 6; + p3 = p4 = pal->data[i]; + p3 &= 0x0000fc00; p4 &= 0x000000fc; + p3 >>= 4; p4 >>= 2; + p1 |= p2; p3 |= p4; p1 |= p3; + REG_GROUP_SET(hw, nccTable0[4 + (i & 0x07)], + (0x80000000 | ((i & 0xFE) << 23) | p1)); + i++; + } + REG_GROUP_END(); + } + + /* Do we have any more slop at the end of the ragne? */ + if (i <= end) { + const FxU32 slopCount = end - endSlop + 1; + + REG_GROUP_BEGIN(chipId, nccTable0[4], + slopCount, (0xFF >> (8 - slopCount))); + while(i <= end) { + FxU32 + p1, p2, p3, p4, + entry; + + p1 = p2 = pal->data[i]; + p1 &= 0xfc000000; p2 &= 0x00fc0000; + p1 >>= 8; p2 >>= 6; + p3 = p4 = pal->data[i]; + p3 &= 0x0000fc00; p4 &= 0x000000fc; + p3 >>= 4; p4 >>= 2; + p1 |= p2; p3 |= p4; p1 |= p3; + + entry = (0x80000000UL | ((i & 0xFE) << 23) | p1); + gc->state.shadow.paletteRow[i>>3].data[i&7] = entry; + REG_GROUP_SET(hw, nccTable0[4 + (i & 0x07)], entry); + + i++; + } + REG_GROUP_END(); + } + } + } + + /* NB: If we're changing table types and the currently selected texture is + * a palettized texture then we need to change the texture format + * behind the user's back to match the table type. + */ + if (type != gc->state.tex_table) { + FxI32 + i; + + for(i = 0; i < gc->num_tmu; i++) { + const FxU32 + texFmt = (gc->state.shadow.tmuState[i].textureMode & SST_TFORMAT), + newTexMode = (gc->state.shadow.tmuState[i].textureMode ^ + ((GR_TEXFMT_P_8 ^ GR_TEXFMT_P_8_RGBA) << SST_TFORMAT_SHIFT)); + + if ((texFmt == (GR_TEXFMT_P_8 << SST_TFORMAT_SHIFT)) || + (texFmt == (GR_TEXFMT_P_8_RGBA << SST_TFORMAT_SHIFT))) { + + GR_SET_EXPECTED_SIZE(sizeof(FxU32), 1); + GR_SET((0x02UL << i), SST_TMU(hw, i), textureMode, newTexMode); + GR_CHECK_SIZE(); + + gc->state.shadow.tmuState[i].textureMode = newTexMode; + } + } + } + + GR_END(); +#undef FN_NAME +} /* _grTexDownloadPaletteExt */ + +/*------------------------------------------------------------------- + Function: grTexDownloadTableExt + Date: 6/3 + Implementor(s): jdt, GaryMcT + Library: glide + Description: + download look up table data to a tmu + Arguments: + tmu - which tmu + type - what type of table to download + One of: + GR_TEXTABLE_NCC0 + GR_TEXTABLE_NCC1 + GR_TEXTABLE_PALETTE + void *data - pointer to table data + Return: + none + -------------------------------------------------------------------*/ +GR_EXT_ENTRY(grTexDownloadTableExt, + void, + (GrChipID_t tmu, GrTexTable_t type, void *data)) +{ + GR_BEGIN_NOFIFOCHECK("grTexDownloadTableExt",89); + GDBG_INFO_MORE(gc->myLevel,"(%d,0x%x)\n",type,data); + GR_CHECK_F(myName, type > GR_TEXTABLE_PALETTE_6666_EXT, "invalid table specified"); + GR_CHECK_F(myName, !data, "invalid data pointer"); + + if ((type == GR_TEXTABLE_PALETTE) || (type == GR_TEXTABLE_PALETTE_6666_EXT)) { + _grTexDownloadPaletteExt(tmu, type, (GuTexPalette *)data, 0, 255); + } else { /* Type is an ncc table */ + _grTexDownloadNccTableExt(tmu, type, (GuNccTable*)data, 0, 11); + } + + /* NB: Set the current palette type after we do the download because + * the palette download code may need to know that there is a table + * type change and do something hoopti. + */ + gc->state.tex_table = type; + + GR_END(); +} /* grTexDownloadTableExt */ + +#undef GLIDE_POINTCAST_PALETTE + /*--------------------------------------------------------------------------- ** _grTexDownloadNccTable ** @@ -287,7 +645,7 @@ GR_DDFUNC(_grTexDownloadNccTable, gc->stats.palDownloads++; gc->stats.palBytes += (end-start+1)<<2; - if (gc->tmu_state[tmu].ncc_table[which] != table) { + /*if (gc->tmu_state[tmu].ncc_table[which] != table)*/ { SstRegs* texHW; int i; #ifdef GLIDE_POINTCAST_PALETTE diff --git a/glide3x/h3/glide3/src/xdraw2.asm b/glide3x/h3/glide3/src/xdraw2.asm index 1443f54..2ffba6e 100644 --- a/glide3x/h3/glide3/src/xdraw2.asm +++ b/glide3x/h3/glide3/src/xdraw2.asm @@ -19,6 +19,9 @@ ;; $Header$ ;; $Revision$ ;; $Log$ +;; Revision 1.1.1.1 1999/11/24 21:44:58 joseph +;; Initial checkin for SourceForge +;; ;; ;; 4 4/06/99 3:54p Dow ;; Alt tab again. @@ -82,59 +85,61 @@ ; B4 Chip field fix. ;; -TITLE xdraw2.asm -OPTION OLDSTRUCTS - -.586P -.MMX -.K3D +%include "xos.inc" ;;; Definitions of cvg regs and glide root structures. -INCLUDE fxgasm.h +%INCLUDE "fxgasm.h" -EXTRN __GlideRoot: DWORD -EXTRN __grCommandTransportMakeRoom@12: NEAR -EXTRN __grValidateState:NEAR -EXTRN _hwcQueryContext:NEAR +extrn _GlideRoot +extrn _grCommandTransportMakeRoom, 12 +extrn _grValidateState + +%MACRO GR_FIFO_WRITE 3 + mov [%1 + %2], %3 +%ENDMACRO ; GR_FIFO_WRITE -_DATA SEGMENT - One DD 03f800000r + +%MACRO WRITE_MM1_FIFO_ALIGNED 1 + movq [fifo+%1], mm1 ; store current param | previous param +%ENDMACRO ; WRITE_MM1_FIFO_ALIGNED + + +%MACRO WRITE_MM1LOW_FIFO 0 + movd [fifo], mm1 ; store current param | previous param +%ENDMACRO ; WRITE_MM1LOW_FIFO + +segment DATA + One DD 1.0 Area DD 0 -_DATA ENDS -CONST SEGMENT -$T2003 DD 046400000r ; 12288 -$T2005 DD 03f800000r ; 1 -$T2006 DD 043800000r ; 256 -CONST ENDS +segment CONST +$T2003 DD 12288.0 +$T2005 DD 1.0 +$T2006 DD 256.0 ; Arguments (STKOFF = 16 from 4 pushes) -STKOFF = 16 -_va$ = 4 + STKOFF -_vb$ = 8 + STKOFF -_vc$ = 12 + STKOFF +STKOFF equ 16 +_va$ equ 4 + STKOFF +_vb$ equ 8 + STKOFF +_vc$ equ 12 + STKOFF ;; coordinate offsets into vertex. ;; NB: These are constants and are not ;; user settable like the rest of the ;; parameter offset. Weird. -X = 0 -Y = 4 +X equ 0 +Y equ 4 -PROC_TYPE MACRO procType:= - IFDEF GL_AMD3D - EXITM <__trisetup_3DNow_&procType&@12> - ELSE - EXITM <__trisetup_Default_&procType&@12> - ENDIF - ENDM +%MACRO PROC_TYPE 1 + %IFDEF GL_AMD3D + proc _trisetup_3DNow_%1, 12 + %ELSE + proc _trisetup_Default_%1, 12 + %ENDIF +%ENDM ;; enables/disables trisProcessed and trisDrawn counters -STATS = 1 - -;; offsets into vertex struct -X = 0 -Y = 4 +%define STATS 1 ;; NB: All of the base triangle procs expect to have the gc ;; passed from the caller in edx so that we can avoid @@ -145,206 +150,186 @@ Y = 4 ;-------------------------------------------------------------------------- -_TEXT SEGMENT PAGE PUBLIC USE32 'CODE' - ASSUME DS: FLAT, SS: FLAT +segment TEXT ALIGN 32 - PUBLIC PROC_TYPE(clip_nocull_invalid) -PROC_TYPE(clip_nocull_invalid) PROC NEAR +PROC_TYPE clip_nocull_invalid -GLIDE_VALIDATE_STATE textequ <1> -GLIDE_CLIP_COORDS textequ <1> -GLIDE_CULLING textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_GENERIC_SETUP textequ <0> -INCLUDE xdraw2.inc -GLIDE_GENERIC_SETUP textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_CULLING textequ <0> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_VALIDATE_STATE textequ <0> +%define GLIDE_VALIDATE_STATE 1 +%define GLIDE_CLIP_COORDS 1 +%define GLIDE_CULLING 0 +%define GLIDE_PACK_RGB 0 +%define GLIDE_PACK_ALPHA 0 +%define GLIDE_GENERIC_SETUP 0 +%INCLUDE "xdraw2.inc" +%undef GLIDE_GENERIC_SETUP +%undef GLIDE_PACK_ALPHA +%undef GLIDE_PACK_RGB +%undef GLIDE_CULLING +%undef GLIDE_CLIP_COORDS +%undef GLIDE_VALIDATE_STATE -PROC_TYPE(clip_nocull_invalid) ENDP +endp ALIGN 32 - PUBLIC PROC_TYPE(clip_cull_invalid) -PROC_TYPE(clip_cull_invalid) PROC NEAR +PROC_TYPE clip_cull_invalid -GLIDE_VALIDATE_STATE textequ <1> -GLIDE_CLIP_COORDS textequ <1> -GLIDE_CULLING textequ <1> -GLIDE_PACK_RGB textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_GENERIC_SETUP textequ <0> -INCLUDE xdraw2.inc -GLIDE_GENERIC_SETUP textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_CULLING textequ <0> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_VALIDATE_STATE textequ <0> +%define GLIDE_VALIDATE_STATE 1 +%define GLIDE_CLIP_COORDS 1 +%define GLIDE_CULLING 1 +%define GLIDE_PACK_RGB 0 +%define GLIDE_PACK_ALPHA 0 +%define GLIDE_GENERIC_SETUP 0 +%INCLUDE "xdraw2.inc" +%undef GLIDE_GENERIC_SETUP +%undef GLIDE_PACK_ALPHA +%undef GLIDE_PACK_RGB +%undef GLIDE_CULLING +%undef GLIDE_CLIP_COORDS +%undef GLIDE_VALIDATE_STATE -PROC_TYPE(clip_cull_invalid) ENDP - - ALIGN 32 - PUBLIC PROC_TYPE(clip_cull_valid) -PROC_TYPE(clip_cull_valid) PROC NEAR - -GLIDE_VALIDATE_STATE textequ <0> -GLIDE_CLIP_COORDS textequ <1> -GLIDE_CULLING textequ <1> -GLIDE_PACK_RGB textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_GENERIC_SETUP textequ <0> -INCLUDE xdraw2.inc -GLIDE_GENERIC_SETUP textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_CULLING textequ <0> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_VALIDATE_STATE textequ <0> - -PROC_TYPE(clip_cull_valid) ENDP - - ALIGN 32 - PUBLIC PROC_TYPE(clip_nocull_valid) -PROC_TYPE(clip_nocull_valid) PROC NEAR - -GLIDE_VALIDATE_STATE textequ <0> -GLIDE_CLIP_COORDS textequ <1> -GLIDE_CULLING textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_GENERIC_SETUP textequ <0> -INCLUDE xdraw2.inc -GLIDE_GENERIC_SETUP textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_CULLING textequ <0> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_VALIDATE_STATE textequ <0> - -PROC_TYPE(clip_nocull_valid) ENDP +endp ALIGN 32 - PUBLIC PROC_TYPE(win_nocull_invalid) -PROC_TYPE(win_nocull_invalid) PROC NEAR +PROC_TYPE clip_cull_valid + +%define GLIDE_VALIDATE_STATE 0 +%define GLIDE_CLIP_COORDS 1 +%define GLIDE_CULLING 1 +%define GLIDE_PACK_RGB 0 +%define GLIDE_PACK_ALPHA 0 +%define GLIDE_GENERIC_SETUP 0 +%INCLUDE "xdraw2.inc" +%undef GLIDE_GENERIC_SETUP +%undef GLIDE_PACK_ALPHA +%undef GLIDE_PACK_RGB +%undef GLIDE_CULLING +%undef GLIDE_CLIP_COORDS +%undef GLIDE_VALIDATE_STATE + +endp + + ALIGN 32 +PROC_TYPE clip_nocull_valid + +%define GLIDE_VALIDATE_STATE 0 +%define GLIDE_CLIP_COORDS 1 +%define GLIDE_CULLING 0 +%define GLIDE_PACK_RGB 0 +%define GLIDE_PACK_ALPHA 0 +%define GLIDE_GENERIC_SETUP 0 +%INCLUDE "xdraw2.inc" +%undef GLIDE_GENERIC_SETUP +%undef GLIDE_PACK_ALPHA +%undef GLIDE_PACK_RGB +%undef GLIDE_CULLING +%undef GLIDE_CLIP_COORDS +%undef GLIDE_VALIDATE_STATE + +endp + + ALIGN 32 +PROC_TYPE win_nocull_invalid -GLIDE_VALIDATE_STATE textequ <1> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_CULLING textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_GENERIC_SETUP textequ <0> -INCLUDE xdraw2.inc -GLIDE_GENERIC_SETUP textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_CULLING textequ <0> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_VALIDATE_STATE textequ <0> +%define GLIDE_VALIDATE_STATE 1 +%define GLIDE_CLIP_COORDS 0 +%define GLIDE_CULLING 0 +%define GLIDE_PACK_RGB 0 +%define GLIDE_PACK_ALPHA 0 +%define GLIDE_GENERIC_SETUP 0 +%INCLUDE "xdraw2.inc" +%undef GLIDE_GENERIC_SETUP +%undef GLIDE_PACK_ALPHA +%undef GLIDE_PACK_RGB +%undef GLIDE_CULLING +%undef GLIDE_CLIP_COORDS +%undef GLIDE_VALIDATE_STATE -PROC_TYPE(win_nocull_invalid) ENDP +endp ALIGN 32 - PUBLIC PROC_TYPE(win_cull_invalid) - -PROC_TYPE(win_cull_invalid) PROC NEAR +PROC_TYPE win_cull_invalid -GLIDE_VALIDATE_STATE textequ <1> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_CULLING textequ <1> -GLIDE_PACK_RGB textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_GENERIC_SETUP textequ <0> -INCLUDE xdraw2.inc -GLIDE_GENERIC_SETUP textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_CULLING textequ <0> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_VALIDATE_STATE textequ <0> +%define GLIDE_VALIDATE_STATE 1 +%define GLIDE_CLIP_COORDS 0 +%define GLIDE_CULLING 1 +%define GLIDE_PACK_RGB 0 +%define GLIDE_PACK_ALPHA 0 +%define GLIDE_GENERIC_SETUP 0 +%INCLUDE "xdraw2.inc" +%undef GLIDE_GENERIC_SETUP +%undef GLIDE_PACK_ALPHA +%undef GLIDE_PACK_RGB +%undef GLIDE_CULLING +%undef GLIDE_CLIP_COORDS +%undef GLIDE_VALIDATE_STATE -PROC_TYPE(win_cull_invalid) ENDP +endp ALIGN 32 - PUBLIC PROC_TYPE(win_cull_valid) -PROC_TYPE(win_cull_valid) PROC NEAR +PROC_TYPE win_cull_valid -GLIDE_VALIDATE_STATE textequ <0> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_CULLING textequ <1> -GLIDE_PACK_RGB textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_GENERIC_SETUP textequ <0> -INCLUDE xdraw2.inc -GLIDE_GENERIC_SETUP textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_CULLING textequ <0> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_VALIDATE_STATE textequ <0> +%define GLIDE_VALIDATE_STATE 0 +%define GLIDE_CLIP_COORDS 0 +%define GLIDE_CULLING 1 +%define GLIDE_PACK_RGB 0 +%define GLIDE_PACK_ALPHA 0 +%define GLIDE_GENERIC_SETUP 0 +%INCLUDE "xdraw2.inc" +%undef GLIDE_GENERIC_SETUP +%undef GLIDE_PACK_ALPHA +%undef GLIDE_PACK_RGB +%undef GLIDE_CULLING +%undef GLIDE_CLIP_COORDS +%undef GLIDE_VALIDATE_STATE -PROC_TYPE(win_cull_valid) ENDP +endp ALIGN 32 - PUBLIC PROC_TYPE(win_nocull_valid) -PROC_TYPE(win_nocull_valid) PROC NEAR +PROC_TYPE win_nocull_valid -GLIDE_VALIDATE_STATE textequ <0> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_CULLING textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_GENERIC_SETUP textequ <0> -INCLUDE xdraw2.inc -GLIDE_GENERIC_SETUP textequ <0> -GLIDE_PACK_ALPHA textequ <0> -GLIDE_PACK_RGB textequ <0> -GLIDE_CULLING textequ <0> -GLIDE_CLIP_COORDS textequ <0> -GLIDE_VALIDATE_STATE textequ <0> +%define GLIDE_VALIDATE_STATE 0 +%define GLIDE_CLIP_COORDS 0 +%define GLIDE_CULLING 0 +%define GLIDE_PACK_RGB 0 +%define GLIDE_PACK_ALPHA 0 +%define GLIDE_GENERIC_SETUP 0 +%INCLUDE "xdraw2.inc" +%undef GLIDE_GENERIC_SETUP +%undef GLIDE_PACK_ALPHA +%undef GLIDE_PACK_RGB +%undef GLIDE_CULLING +%undef GLIDE_CLIP_COORDS +%undef GLIDE_VALIDATE_STATE -PROC_TYPE(win_nocull_valid) ENDP +endp -IFDEF GL_AMD3D +%IFDEF GL_AMD3D ALIGN 32 - PUBLIC __trisetup_clip_coor_thunk@12 -__trisetup_clip_coor_thunk@12 PROC NEAR +proc _trisetup_clip_coor_thunk, 12 + +%define procPtr eax +%define vPtr ecx +%define gc edx ; Current graphics context passed implicitly through edx -procPtr TEXTEQU -vPtr TEXTEQU -gc TEXTEQU ; Current graphics context passed implicitly through edx - ;; Call through to the gc->curArchProcs.drawTrianglesProc w/o ;; adding extra stuff to the stack. I wish we could actually ;; do a direct return here w/o too much work. lea vPtr, [esp + _va$ - STKOFF] ; Get vertex pointer address mov procPtr, [gc + drawTrianglesProc] ; Prefetch drawTriangles proc addr - - push vPtr ; vertex array address - push 3 ; 3 vertices ;; If debugging make sure that we're in clip coordinates -IFDEF GLIDE_DEBUG - mov eax, [gc + CoordinateSpace] - test eax, 1 +%IFDEF GLIDE_DEBUG + test dword [gc + CoordinateSpace], 1 jnz __clipSpace xor eax, eax mov [eax], eax __clipSpace: -ENDIF ; GLIDE_DEBUG +%ENDIF ; GLIDE_DEBUG - push 1 ; mode = grDrawVertexArray - call procPtr ; (*gc->curArchProcs.drawTrianglesProc)(grDrawVertexArray, 3, vPtr) + invoke procPtr, 1, 3, vPtr ; (*gc->curArchProcs.drawTrianglesProc)(grDrawVertexArray, 3, vPtr) - ret 12 ; pop 3 dwords (vertex addrs) and return -__trisetup_clip_coor_thunk@12 ENDP - -ENDIF ; GL_AMD3D - -_TEXT ENDS - END + ret ; pop 3 dwords (vertex addrs) and return +endp +%ENDIF ; GL_AMD3D diff --git a/glide3x/h3/glide3/src/xdraw2.inc b/glide3x/h3/glide3/src/xdraw2.inc index 4867f8b..7b9a783 100644 --- a/glide3x/h3/glide3/src/xdraw2.inc +++ b/glide3x/h3/glide3/src/xdraw2.inc @@ -20,6 +20,9 @@ ;; $Header$ ;; $Revision$ ;; $Log$ +;; Revision 1.1.1.1 1999/11/24 21:44:58 joseph +;; Initial checkin for SourceForge +;; ; ; 2 10/30/97 6:53p Peter ; first real cut at tri asm @@ -41,60 +44,32 @@ ;; ;; YOU HAVE BEEN WARNED -ifdef GL_AMD3D +%ifdef GL_AMD3D ;--------------------------------------------------------------------------- ; start 3DNow! version ;--------------------------------------------------------------------------- -TITLE xdraw2.inc -.586P -.MMX -.K3D +%define gc edi ; points to graphics context +%define fifo ebp ; points to fifo entries +%define tempVal esi - -GR_FIFO_WRITE MACRO __addr, __offset, __data - mov [__addr + __offset], __data -ENDM ; GR_FIFO_WRITE - - -WRITE_MM1_FIFO_ALIGNED MACRO __offset - movq [fifo+__offset], mm1 ; store current param | previous param -ENDM ; WRITE_MM1_FIFO_ALIGNED - - -WRITE_MM1LOW_FIFO MACRO - movd [fifo], mm1 ; store current param | previous param -ENDM ; WRITE_MM1LOW_FIFO - - -; Arguments (STKOFF = 16 from 4 pushes) -STKOFF = 16 -_va$ = 4 + STKOFF -_vb$ = 8 + STKOFF -_vc$ = 12 + STKOFF - - -gc TEXTEQU ; points to graphics context -fifo TEXTEQU ; points to fifo entries -tempVal TEXTEQU - -IF GLIDE_CLIP_COORDS +%IF GLIDE_CLIP_COORDS ;; NB: Currently, the 3DNow!(tm) clip coordinate stuff ;; thunks through to the grDrawTriangles functions ;; which has already been specialized for 3DNow!(tm). ;; This means that we should never get here. -IFDEF GLIDE_DEBUG +%IFDEF GLIDE_DEBUG xor eax, eax mov [eax], eax -ENDIF -ELSE -IF GLIDE_CULLING -fa TEXTEQU ; vtx a from caller -fb TEXTEQU ; vtx b from caller -fc TEXTEQU ; vtx c from caller -cull TEXTEQU ; cull mode -intArea TEXTEQU ; area temp storage +%ENDIF +%ELSE +%IF GLIDE_CULLING +%define fa eax ; vtx a from caller +%define fb ebx ; vtx b from caller +%define fc ecx ; vtx c from caller +%define cull edx ; cull mode +%define intArea ecx ; area temp storage ;; Prologue stuff push edi ; save caller's register variable @@ -106,25 +81,21 @@ intArea TEXTEQU ; area temp storage mov fb, [esp + _vb$ - 4] ; get base address of vertex B push ebp ; save frame pointer -if GLIDE_CLIP_COORDS +%if GLIDE_CLIP_COORDS mov esi, [gc+CoordinateSpace] ; which coord. space (clip/window)? -endif +%endif -if GLIDE_VALIDATE_STATE +%if GLIDE_VALIDATE_STATE mov ebp, [gc + invalid] ; state validated? -endif +%endif -if GLIDE_CLIP_COORDS +%if GLIDE_CLIP_COORDS lea eax, [esp+ _va$] ; pointer to vertex pointers test esi, esi ; window coordinates ? jz win_coordinates ; yup - push eax ; pointer to vertex pointers - push 3 ; 3 vertices - push 1 ; mode = grDrawVertexArray - - call __grDrawTriangles@12 ; draw the triangle in clip coordinate space + invoke _grDrawTriangles, 1, 3, eax; draw the triangle in clip coordinate space pop ebp ; restore frame pointer pop ebx ; restore caller's register variable @@ -132,20 +103,20 @@ if GLIDE_CLIP_COORDS pop esi ; restore caller's register variable pop edi ; restore caller's register variable - ret 12 ; return, pop 3 DWORD arguments off stack + ret ; return, pop 3 DWORD arguments off stack -win_coordinates: -endif ; GLIDE_CLIP_COORDS +.win_coordinates: +%endif ; GLIDE_CLIP_COORDS -if GLIDE_VALIDATE_STATE +%if GLIDE_VALIDATE_STATE test ebp, ebp ; does state need validation? - jz no_validation ; valid, don't need to validate + jz .no_validation ; valid, don't need to validate - call __grValidateState ; validate state + invoke _grValidateState ; validate state -no_validation: +.no_validation: -endif ; GLIDE_VALIDATE_STATE +%endif ; GLIDE_VALIDATE_STATE mov cull, [gc + cull_mode]; get cull mode nop ; filler @@ -162,7 +133,7 @@ endif ; GLIDE_VALIDATE_STATE ;; Cull Check - jz nocull ; nope, no culling + jz .nocull ; nope, no culling mov fa, [esp + _va$] ; get base address of vertex A movq mm2, [fc + X] ; yc | xc @@ -195,27 +166,23 @@ endif ; GLIDE_VALIDATE_STATE ; Zero Area Triangle Check test intArea, 7fffffffh ; if ((j & 0x7FFFFFFF) == 0) - jz __cullFail ; area zero, triangle culled + jz .__cullFail ; area zero, triangle culled xor intArea, cull ; if (j ^ (culltest << 31)) - jge __cullFail ; triangle facing away from viewer, culled + jge .__cullFail ; triangle facing away from viewer, culled cmp ebx, tempVal ; fifo space required >= space available ? - jge __triBegin ; yup, push out triangle data to Voodoo + jge .__triBegin ; yup, push out triangle data to Voodoo - push @Line ; line number inside this function - push 0h ; pointer to function name = NULL - - push tempVal ; fifo space required - call __grCommandTransportMakeRoom@12 ; note: updates fifoPtr + invoke _grCommandTransportMakeRoom, tempVal, 0, __LINE__; note: updates fifoPtr - jmp __triBegin ; merge back with short path + jmp .__triBegin ; merge back with short path ;; culling disabled ALIGN 16 -nocull: +.nocull: ;; Check to make sure that we have enough room for ;; the complete triangle packet. @@ -223,14 +190,10 @@ nocull: mov ebx, [gc + fifoRoom] ; fifo space available cmp ebx, tempVal ; fifo spce available >= space needed ? - jge __triBegin ; yup, ready to draw triangle + jge .__triBegin ; yup, ready to draw triangle - push @Line ; line number inside this function - push 0h ; pointer to function name = NULL - - push tempVal ; fifo space needed - call __grCommandTransportMakeRoom@12 ; note: updates fifoPtr -ELSE ; !GLIDE_CULLING + invoke _grCommandTransportMakeRoom, tempVal, 0, __LINE__; note: updates fifoPtr +%ELSE ; !GLIDE_CULLING ;; Prologue stuff @@ -242,25 +205,21 @@ ELSE ; !GLIDE_CULLING push ebp ; save frame pointer -if GLIDE_CLIP_COORDS +%if GLIDE_CLIP_COORDS mov edx, [gc+CoordinateSpace]; window coordinates or clip coordinates ? -endif +%endif -if GLIDE_VALIDATE_STATE +%if GLIDE_VALIDATE_STATE mov ebp, [gc + invalid] ; state validated? -endif +%endif -if GLIDE_CLIP_COORDS +%if GLIDE_CLIP_COORDS lea eax, [esp+ _va$] ; pointer to vertex pointers test edx, edx ; window coordinates ? jz win_coordinates ; yup - push eax ; pointer to vertex pointers - push 3 ; 3 vertices - push 1 ; mode = grDrawVertexArray - - call __grDrawTriangles@12 ; draw the triangle in coordinate space + invoke _grDrawTriangles, 1, 3, eax; draw the triangle in coordinate space pop ebp ; restore frame pointer pop ebx ; restore caller's register variable @@ -268,22 +227,22 @@ if GLIDE_CLIP_COORDS pop esi ; restore caller's register variable pop edi ; restore caller's register variable - ret 12 ; return, pop 3 DWORD arguments off stack + ret ; return, pop 3 DWORD arguments off stack ALIGN 16 -win_coordinates: +.win_coordinates: -endif +%endif -if GLIDE_VALIDATE_STATE +%if GLIDE_VALIDATE_STATE test ebp, ebp ; does state need validation? - jz no_validation ; valid, don't need to validate + jz .no_validation ; valid, don't need to validate - call __grValidateState ; validate state + invoke _grValidateState ; validate state -no_validation: +.no_validation: -endif +%endif mov tempVal, [gc + curTriSize] ; data for whole triangle in bytes add tempVal, 4 ; fifo space needed (include 4-byte header) @@ -292,25 +251,21 @@ endif femms ; will use AMD3D, clear FPU/MMX registers cmp ebx, tempVal ; fifo spce available >= space needed ? - jge __triBegin ; yup, ready to draw triangle + jge .__triBegin ; yup, ready to draw triangle - push @Line ; line number inside this function - push 0h ; pointer to function name = NULL - - push tempVal ; fifo space needed - call __grCommandTransportMakeRoom@12 ; note: updates fifoPtr + invoke _grCommandTransportMakeRoom, tempVal, 0, __LINE__; note: updates fifoPtr - jmp __triBegin ; large distance due to alignment -endif ; GLIDE_CULLING + jmp .__triBegin ; large distance due to alignment +%ENDIF ; GLIDE_CULLING -dlp TEXTEQU ; points to dataList structure -dlpstrt TEXTEQU ; points to begin of dataList structure -vertex TEXTEQU ; the current vertex +%define dlp ebx ; points to dataList structure +%define dlpstrt ecx ; points to begin of dataList structure +%define vertex edx ; the current vertex ALIGN 32 -__triBegin: +.__triBegin: mov eax, [gc+triPacketHdr]; Packet 3 header lea dlp,[gc + tsuDataList]; Reset the dataList @@ -320,7 +275,7 @@ __triBegin: mov dlpstrt, dlp ; save pointer to start of dataList test fifo, 4 ; is fifo pointer qword aligned ? - jz __fifo_aligned ; yes, it is qword aligned + jz .__fifo_aligned ; yes, it is qword aligned movq mm1, [vertex+X] ; y | x GR_FIFO_WRITE fifo, 0, eax ; write header to fifo; now qword aligned @@ -334,14 +289,14 @@ __triBegin: add dlp, 4 ; dlp++ test eax, eax ; at end of list ? - jz __paramLoopDoneWBzero1; yes, "write buffer" empty + jz .__paramLoopDoneWBzero1; yes, "write buffer" empty -__paramLoop1a: +.__paramLoop1a: movd mm1, [eax+vertex] ; get next parameter mov eax, [dlp] ; offset = *(dlp + 1) test eax, eax ; at end of offset list (offset == 0) ? - jz __paramLoopDoneWBone1 ; exit, write buffer contains one DWORD + jz .__paramLoopDoneWBone1; exit, write buffer contains one DWORD movd mm2, [eax+vertex] ; get next parameter add dlp, 8 ; dlp += 2 @@ -353,11 +308,11 @@ __paramLoop1a: test eax, eax ; at end of offset list (offset == 0) ? WRITE_MM1_FIFO_ALIGNED -8 ; PCI write current param | previous param - jnz __paramLoop1a ; nope, copy next parameter + jnz .__paramLoop1a ; nope, copy next parameter - jmp __paramLoopDoneWBzero1; write buffer empty + jmp .__paramLoopDoneWBzero1; write buffer empty -__fifo_aligned: +.__fifo_aligned: movd mm2, [vertex+X] ; y | x of vertex A add fifo, 8 ; fifoPtr += 2*sizeof(FxU32) @@ -371,9 +326,9 @@ __fifo_aligned: add dlp, 4 ; dlp++ test eax, eax ; end of list ? - jz __paramLoopDoneWBone1 ; yes, "write buffer" has y data + jz .__paramLoopDoneWBone1; yes, "write buffer" has y data -__paramLoop1b: +.__paramLoop1b: movd mm2, [eax+vertex] ; get next parameter add fifo, 8 ; fifoPtr += 2*sizeof(FxU32) @@ -384,15 +339,15 @@ __paramLoop1b: test eax, eax ; at end of offset list (offset == 0) ? WRITE_MM1_FIFO_ALIGNED -8 ; PCI write current param | previous param - jz __paramLoopDoneWBzero1; exit, "write buffer" empty + jz .__paramLoopDoneWBzero1; exit, "write buffer" empty movd mm1, [eax+vertex] ; get next parameter mov eax, [dlp-4] ; offset = *(dlp + 1) test eax, eax ; at end of offset list (offset == 0) ? - jnz __paramLoop1b ; nope, copy next parameter + jnz .__paramLoop1b ; nope, copy next parameter -__paramLoopDoneWBone1: +.__paramLoopDoneWBone1: ;; here: "write buffer" has one DWORD left over from vertex A @@ -411,9 +366,9 @@ __paramLoopDoneWBone1: add dlp, 4 ; dlp++ test eax, eax ; end of list ? - jz __paramLoopDoneWBone2 ; yes, "write buffer" has y data + jz .__paramLoopDoneWBone2; yes, "write buffer" has y data -__paramLoop2b: +.__paramLoop2b: movd mm2, [eax+vertex] ; get next parameter add fifo, 8 ; fifoPtr += 2*sizeof(FxU32) @@ -424,17 +379,17 @@ __paramLoop2b: cmp eax, 0 ; at end of offset list (offset == 0) ? WRITE_MM1_FIFO_ALIGNED -8 ; PCI write current param | previous param - jz __paramLoopDoneWBzero2; exit, "write buffer" empty + jz .__paramLoopDoneWBzero2; exit, "write buffer" empty movd mm1, [eax+vertex] ; get next parameter mov eax, [dlp-4] ; offset = *(dlp + 1) test eax, eax ; at end of offset list (offset == 0) ? - jnz __paramLoop2b ; nope, copy next parameter + jnz .__paramLoop2b ; nope, copy next parameter - jmp __paramLoopDoneWBone2 ; write buffer contains one DWORD + jmp .__paramLoopDoneWBone2; write buffer contains one DWORD -__paramLoopDoneWBzero1: +.__paramLoopDoneWBzero1: mov vertex, [esp + _vb$] ; Current vertex = B mov dlp, dlpstrt ; Reset the dataList @@ -451,14 +406,14 @@ __paramLoopDoneWBzero1: add dlp, 4 ; dlp++ cmp eax, 0 ; at end of list ? - jz __paramLoopDoneWBzero2; yes, "write buffer" empty + jz .__paramLoopDoneWBzero2; yes, "write buffer" empty -__paramLoop2a: +.__paramLoop2a: movd mm1, [eax+vertex] ; get next parameter mov eax, [dlp] ; offset = *(dlp + 1) cmp eax, 0 ; at end of offset list (offset == 0) ? - jz __paramLoopDoneWBone2 ; exit, write buffer contains one DWORD + jz .__paramLoopDoneWBone2; exit, write buffer contains one DWORD movd mm2, [eax+vertex] ; get next parameter add dlp, 8 ; dlp += 2 @@ -470,9 +425,9 @@ __paramLoop2a: test eax, eax ; at end of offset list (offset == 0) ? WRITE_MM1_FIFO_ALIGNED -8 ; PCI write current param | previous param - jnz __paramLoop2a ; nope, copy next parameter + jnz .__paramLoop2a ; nope, copy next parameter -__paramLoopDoneWBzero2: +.__paramLoopDoneWBzero2: mov vertex, [esp + _vc$] ; Current vertex = C mov dlp, dlpstrt ; Reset the dataList @@ -488,14 +443,14 @@ __paramLoopDoneWBzero2: add dlp, 4 ; dlp++ test eax, eax ; at end of list ? - jz __paramLoopDoneWBzero3; yes, "write buffer" empty + jz .__paramLoopDoneWBzero3; yes, "write buffer" empty -__paramLoop3a: +.__paramLoop3a: movd mm1, [eax+vertex] ; get next parameter mov eax, [dlp] ; offset = *(dlp + 1) test eax, eax ; at end of offset list (offset == 0) ? - jz __paramLoopDoneWBone3 ; exit, write buffer contains one DWORD + jz .__paramLoopDoneWBone3; exit, write buffer contains one DWORD movd mm2, [eax+vertex] ; get next parameter add dlp, 8 ; dlp += 2 @@ -507,11 +462,11 @@ __paramLoop3a: test eax, eax ; at end of offset list (offset == 0) ? WRITE_MM1_FIFO_ALIGNED -8 ; PCI write current param | previous param - jnz __paramLoop3a ; nope, copy next parameter + jnz .__paramLoop3a ; nope, copy next parameter - jmp __paramLoopDoneWBzero3; write buffer empty + jmp .__paramLoopDoneWBzero3; write buffer empty -__paramLoopDoneWBone2: +.__paramLoopDoneWBone2: ;; here: "write buffer" has one DWORD left over from vertex B @@ -531,9 +486,9 @@ __paramLoopDoneWBone2: add dlp, 4 ; dlp++ test eax, eax ; end of list ? - jz __paramLoopDoneWBone3 ; yes, "write buffer" has y data + jz .__paramLoopDoneWBone3; yes, "write buffer" has y data -__paramLoop3b: +.__paramLoop3b: movd mm2, [eax+vertex] ; get next parameter add fifo, 8 ; fifoPtr += 2*sizeof(FxU32) @@ -544,22 +499,22 @@ __paramLoop3b: test eax, eax ; at end of offset list (offset == 0) ? WRITE_MM1_FIFO_ALIGNED -8 ; PCI write current param | previous param - jz __paramLoopDoneWBzero3; exit, "write buffer" empty + jz .__paramLoopDoneWBzero3; exit, "write buffer" empty movd mm1, [eax+vertex] ; get next parameter mov eax, [dlp-4] ; offset = *(dlp + 1) test eax, eax ; at end of offset list (offset == 0) ? - jnz __paramLoop3b ; nope, copy next parameter + jnz .__paramLoop3b ; nope, copy next parameter -__paramLoopDoneWBone3: +.__paramLoopDoneWBone3: ; "write buffer" contains one DWORD that needs to be flushed WRITE_MM1LOW_FIFO ; add fifo, 4 ; -__paramLoopDoneWBzero3: +.__paramLoopDoneWBzero3: ;; Update gc->fifoPtr and gc->fifoRoom @@ -583,7 +538,7 @@ __paramLoopDoneWBzero3: ;; Restore trashed registers -__triDone_nocull: +.__triDone_nocull: inc esi ; _GlideRoot.stats.trisProcessed++ pop ebp ; restore frame pointer @@ -596,17 +551,17 @@ __triDone_nocull: femms ; no more AMD3D code, clear FPU/MMX regs - ret 12 ; return to caller + ret ; return to caller -IF GLIDE_CULLING -__cullFail: +%IF GLIDE_CULLING +.__cullFail: mov esi, [gc + trisProcessed]; triangles processed so far xor eax, eax ; return value = triangle not drawn femms ; no more AMD3D code, clear FPU/MMX regs -__triDone_cull: +.__triDone_cull: ;; Restore trashed registers inc esi ; _GlideRoot.stats.trisProcessed++; pop ebp ; restore frame pointer @@ -617,48 +572,45 @@ __triDone_cull: pop esi pop edi - ret 12 -ENDIF ; GLIDE_CULLING -ENDIF ; !GLIDE_CLIP_COORDS + ret +%ENDIF ; GLIDE_CULLING +%ENDIF ; !GLIDE_CLIP_COORDS ;--------------------------------------------------------------------------- ; end 3DNow! version ;--------------------------------------------------------------------------- -endif ; GL_AMD3D +%endif ; GL_AMD3D -ifndef GL_AMD3D +%ifndef GL_AMD3D ;--------------------------------------------------------------------------- ; original code ;--------------------------------------------------------------------------- - -TITLE xdraw2.inc -.586P ; Ugly, but seems to workaround the problem with locally defined ; data segment globals not getting relocated properly when using ; djgpp. -zArea TEXTEQU -zdxAB TEXTEQU -zdxBC TEXTEQU -zdyAB TEXTEQU -zdyBC TEXTEQU -zculltest TEXTEQU +%define zArea One+04h +%define zdxAB One+08h +%define zdxBC One+0ch +%define zdyAB One+10h +%define zdyBC One+14h +%define zculltest One+18h -gc TEXTEQU ; points to graphics context +%define gc esi ; points to graphics context -IF GLIDE_CLIP_COORDS +%IF GLIDE_CLIP_COORDS ;; NB: We should never hit this because the proc is ;; either specialized or we thunk through to ;; grDrawTriangles for the clipping etc. -IFDEF GLIDE_DEBUG +%IFDEF GLIDE_DEBUG xor eax, eax mov [eax], eax -ENDIF -ELSE +%ENDIF +%ELSE ;; Prologue stuff push esi push edi @@ -669,7 +621,7 @@ ELSE ;; call getThreadValueSLOW ;; mov gc, eax -IF 0 +%IF 0 ;;; TRICKY STUFF HERE: ;;; The following code would be expressed like this if MASM didn't suck: ;;; mov eax, DWORD PTR fs:[18h] @@ -682,46 +634,46 @@ IF 0 db 00h db 00h - add eax, DWORD PTR __GlideRoot + tlsOffset + add eax, DWORD [_GlideRoot + tlsOffset] mov gc, [eax] -ELSE +%ELSE mov gc, edx -ENDIF -IFDEF GLIDE_ALT_TAB +%ENDIF +%IFDEF GLIDE_ALT_TAB test gc, gc - je __triDone - mov edx, [gc + windowed] + je .__triDone + mov edx, [gc + windowed] test edx, 1 - jnz pastContextTest ; - mov edx, DWORD PTR [gc+lostContext] - mov ebx, [edx] + jnz .pastContextTest ; + mov edx, DWORD [gc+lostContext] + mov ebx, [edx] test ebx, 1 - jnz __triDone -pastContextTest: + jnz .__triDone +.pastContextTest: -ENDIF +%ENDIF align 4 -IF GLIDE_VALIDATE_STATE +%IF GLIDE_VALIDATE_STATE ;;; GR_FLUSH_STATE() - mov edx, DWORD PTR [gc+invalid] + mov edx, DWORD [gc+invalid] test edx, edx - je SHORT no_validatioin - call __grValidateState -no_validatioin: -ENDIF + je .no_validatioin + invoke _grValidateState +.no_validatioin: +%ENDIF align 4 -IF GLIDE_CULLING -fa TEXTEQU ; vtx a from caller -fb TEXTEQU ; vtx b from caller -fc TEXTEQU ; vtx c from caller +%IF GLIDE_CULLING +%define fa eax ; vtx a from caller +%define fb ebx ; vtx b from caller +%define fc ecx ; vtx c from caller -cull TEXTEQU -intArea TEXTEQU ; temp Y storage +%define cull edx +%define intArea ebp ; temp Y storage ; some useful floating load and store macros -flds TEXTEQU -fsubs TEXTEQU -fmuls TEXTEQU +%define flds fld DWORD +%define fsubs fsub DWORD +%define fmuls fmul DWORD ;; Pre-load the current culling mode before all of the ;; floating point area stuff. @@ -732,11 +684,11 @@ fmuls TEXTEQU mov fc, [esp + _vc$] test cull, cull - jz nocull + jz .nocull shl cull, 31 ; culltest << 31 -Area_Computation: +; Area_Computation: ; 47-3 ; jmp ret_pop0f flds [fa + X] ; xa @@ -747,34 +699,34 @@ Area_Computation: fsubs [fc + Y] ; | | dyBC flds [fa + Y] ; | | | ya fsubs [fb + Y] ; | | | dyAB - fld st(3) ; | | | | dxAB - fmul st, st(2) ; | | | | t0 t0=dxAB*dyBC - fld st(3) ; | | | | | dxBC - fmul st, st(2) ; | | | | | t1 t1=dxBC*dyAB - fsubp st(1),st ; | | | | area - fst zArea ; | | | | area + fld st3 ; | | | | dxAB + fmul st0, st2 ; | | | | t0 t0=dxAB*dyBC + fld st3 ; | | | | | dxBC + fmul st0, st2 ; | | | | | t1 t1=dxBC*dyAB + fsubp st1,st0 ; | | | | area + fst dword [zArea] ; | | | | area ;; Pop temp things from the sw culling off the fp stack - fstp st(0) ; 4 - fstp st(0) ; 3 - fstp st(0) ; 2 - fstp st(0) ; 1 - fstp st(0) ; 0 + fstp st0 ; 4 + fstp st0 ; 3 + fstp st0 ; 2 + fstp st0 ; 1 + fstp st0 ; 0 - mov intArea, zArea ; j = *(long *)&area + mov intArea, [zArea] ; j = *(long *)&area xor eax, eax ; Clear the return value (0 == culled) ; Zero Area Triangle Check and intArea, 7fffffffh ; if ((j & 0x7FFFFFFF) == 0) - jz __triDone + jz .__triDone ;; Triangle area check vs culling mode - mov intArea, zArea ; reload area just in case we're culling + mov intArea, [zArea] ; reload area just in case we're culling xor intArea, cull ; if (j ^ (culltest << 31)) - jge __triDone -nocull: -ENDIF ; GLIDE_CULLING + jge .__triDone +.nocull: +%ENDIF ; GLIDE_CULLING align 4 ;; Check to make sure that we have enough room for @@ -785,30 +737,22 @@ ENDIF ; GLIDE_CULLING add eax, 4 cmp ebx, eax - jge __triBegin + jge .__triBegin - push @Line - push 0h - - push eax - call __grCommandTransportMakeRoom@12 + invoke _grCommandTransportMakeRoom, eax, 0, __LINE__ ;; Send triangle parameters -dlp TEXTEQU ; points to dataList structure -fifo TEXTEQU ; points to next entry in fifo -vertex TEXTEQU ; the current vertex -vOffset TEXTEQU ; Current vertex offset +%define dlp ebx ; points to dataList structure +%define fifo ebp ; points to next entry in fifo +%define vertex edx ; the current vertex +%define vOffset ecx ; Current vertex offset -packCol TEXTEQU -tempVal TEXTEQU - -GR_FIFO_WRITE MACRO __addr, __offset, __data - mov [__addr + __offset], __data -ENDM ; GR_FIFO_WRITE +%define packCol edi +%define tempVal edi align 32 -__triBegin: +.__triBegin: mov fifo, [gc + fifoPtr] ; Fetch Fifo Ptr mov vOffset, 4 ; Starting vertex @@ -819,53 +763,53 @@ __triBegin: add fifo, 4 ; Advance fifo for hdr & x/y coordinate align 32 -__vertexStart: +.__vertexStart: mov vertex, [esp + STKOFF + vOffset] ; Current vertex add fifo, 8 nop ; Avoid p5 agi w/ load of vertex ptr nop - mov eax, DWORD PTR [vertex] ; X + mov eax, DWORD [vertex] ; X lea dlp, [gc + tsuDataList] ; Reset the dataList GR_FIFO_WRITE fifo, -8, eax ; PCI write X - mov eax, DWORD PTR [vertex + 4] ; Y + mov eax, DWORD [vertex + 4] ; Y xor packCol, packCol ; Clear packed color GR_FIFO_WRITE fifo, -4, eax ; PCI write Y -__doParams: - mov eax, DWORD PTR [dlp] ; Get first offset from the data list +.__doParams: + mov eax, DWORD [dlp] ; Get first offset from the data list add dlp, 4 ; dlp++ cmp eax, 0 ; Are we done? - je __nextVertex + je .__nextVertex ;; Not using align directive here because it sometimes ;; introduces an agi for the eax use below. nop nop -__paramLoop: - mov tempVal, DWORD PTR [eax + vertex] ; Get the parameter from teh vertex +.__paramLoop: + mov tempVal, DWORD [eax + vertex] ; Get the parameter from teh vertex add fifo, 4 ; fifoPtr += sizeof(FxU32) - mov eax, DWORD PTR [dlp] ; offset = *(dlp + 1) + mov eax, DWORD [dlp] ; offset = *(dlp + 1) add dlp, 4 ; dlp++ cmp eax, 0 ; Are we done? GR_FIFO_WRITE fifo, -4, tempVal ; *fifoPtr = data - jne SHORT __paramLoop + jne .__paramLoop align 4 -__nextVertex: +.__nextVertex: ;; On to the next vertex add vOffset, 4 cmp vOffset, 16 ; Offset of one past last vertex? - jne __vertexStart + jne .__vertexStart ;; Update gc->fifoPtr and gc->fifoRoom mov eax, fifo @@ -883,7 +827,7 @@ __nextVertex: ;; return 1 (triangle drawn) mov eax, 1h -__triDone: +.__triDone: ;; Restore trashed registers mov ecx, [gc + trisProcessed] pop ebp @@ -895,6 +839,6 @@ __triDone: mov [gc + trisProcessed], ecx pop esi - ret 12 -ENDIF ; !GLIDE_CLIP_COOR -ENDIF ; !GL_AMD3D + ret +%ENDIF ; !GLIDE_CLIP_COOR +%ENDIF ; !GL_AMD3D diff --git a/glide3x/h3/glide3/src/xdraw3.asm b/glide3x/h3/glide3/src/xdraw3.asm index 2d68ddb..916b211 100644 --- a/glide3x/h3/glide3/src/xdraw3.asm +++ b/glide3x/h3/glide3/src/xdraw3.asm @@ -16,48 +16,41 @@ ;; ;; COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED -TITLE xdraw3.asm -.586P -.MMX -.K3D +%include "xos.inc" -EXTRN __GlideRoot:DWORD -EXTRN __grValidateState:NEAR -EXTRN __grCommandTransportMakeRoom@12:NEAR +extrn _GlideRoot +extrn _grValidateState +extrn _grCommandTransportMakeRoom, 12 -ifdef GL_AMD3D +%ifdef GL_AMD3D ;;-------------------------------------------------------------------------- ;; start AMD3D version ;;-------------------------------------------------------------------------- ;;; include listing.inc -INCLUDE fxgasm.h +%INCLUDE "fxgasm.h" -CONST SEGMENT +segment CONST ALIGN 8 -_F256_F256 DQ 04380000043800000h ; 256 | 256 -CONST ENDS +_F256_F256 DD 256.0, 256.0 -_DATA SEGMENT +segment DATA ALIGN 8 -btab DD 8 DUP(0) -atab DD 8 DUP(0) +btab DD 0, 0, 0, 0, 0, 0, 0, 0 +atab DD 0, 0, 0, 0, 0, 0, 0, 0 vSize DD 0 strideinbytes DD 0 vertices DD 0 -_DATA ENDS -_TEXT SEGMENT PAGE PUBLIC USE32 'CODE' - ASSUME DS: FLAT, SS: FLAT +segment TEXT ALIGN 32 -PUBLIC __grDrawTriangles_3DNow@12 -_mode = 20 -_count = 24 -_pointers = 28 -__grDrawTriangles_3DNow@12 PROC NEAR +%define _mode 20 +%define _count 24 +%define _pointers 28 +proc _grDrawTriangles_3DNow, 12 ; 930 : { ; 931 : #define FN_NAME "_grDrawTriangles" @@ -77,38 +70,38 @@ __grDrawTriangles_3DNow@12 PROC NEAR ; 945 : ; 946 : GR_FLUSH_STATE(); -gc TEXTEQU ; points to graphics context -fifo TEXTEQU ; points to next entry in fifo -dlp TEXTEQU ; points to dataList structure -vertexCount TEXTEQU ; Current vertex counter in the packet -vertexPtr TEXTEQU ; Current vertex pointer (in deref mode) -vertex TEXTEQU ; Current vertex (in non-deref mode) -dlpStart TEXTEQU ; Pointer to start of offset list +%define gc edi ; points to graphics context +%define fifo ecx ; points to next entry in fifo +%define dlp ebp ; points to dataList structure +%define vertexCount esi ; Current vertex counter in the packet +%define vertexPtr ebx ; Current vertex pointer (in deref mode) +%define vertex ebx ; Current vertex (in non-deref mode) +%define dlpStart edx ; Pointer to start of offset list push edi ; save caller's register variable - mov eax, DWORD PTR fs:[18h] ; get thread local storage base pointer + SET_TLSBASE eax ; get thread local storage base pointer push esi ; save caller's register variable - mov edx, [__GlideRoot+tlsOffset]; offset of GC into tls + SET_TLSOFFSET edx ; offset of GC into tls push ebx ; save caller's register variable mov vertexCount, [esp+_count-4]; number of vertices in triangles - mov gc, [eax+edx] ; get GC for current thread + GET_GC eax, edx ; get GC for current thread mov vertexPtr, [esp+_pointers-4]; get current vertex pointer (deref mode) push ebp ; save frame pointer mov edx, [gc + invalid] ; state needs validation ? test vertexCount, vertexCount ; number of vertices <= 0 ? - jle $tris_done ; yup, triangles are done + jle .tris_done ; yup, triangles are done test edx, edx ; do we need to validate state ? - je $no_validation ; nope, it's valid + je .no_validation ; nope, it's valid - call __grValidateState ; validate state + invoke _grValidateState ; validate state -$no_validation: +.no_validation: ; 947 : ; 948 : #ifdef GLIDE_DEBUG @@ -155,7 +148,7 @@ $no_validation: mov [gc + trisProcessed], eax ; trisProcessed test edx, edx ; mode 0 (array of vertices) ? - jnz $deref_mode ; nope, it's mode 1 (array of pointers to vertices) + jnz .deref_mode ; nope, it's mode 1 (array of pointers to vertices) mov edx, [gc + vertexStride] ; get stride in DWORDs @@ -163,7 +156,7 @@ $no_validation: test ecx, ecx ; coordinate space == 0 (window) ? mov [strideinbytes], edx ; save off stride (in bytes) - jnz $clip_coordinates_ND ; nope, coordinate space != window + jnz .clip_coordinates_ND ; nope, coordinate space != window ; 961 : while (count > 0) { ; 962 : FxI32 vcount = count >=15 ? 15 : count; @@ -171,7 +164,7 @@ $no_validation: ; 964 : TRI_STRIP_BEGIN(kSetupStrip, vcount, gc->state.vData.vSize, SSTCP_PKT3_BDDBDD); ; 965 : -$win_coords_loop_ND: +.win_coords_loop_ND: sub vertexCount, 15 ; vertexCount >= 15 ? CF=0 : CF=1 mov ecx, [gc + vertexSize] ; bytes of data for each vertex @@ -187,16 +180,12 @@ $win_coords_loop_ND: add ecx, 4 ; add header size ==> total packet size cmp eax, ecx ; fifo space avail >= packet size ? - jge $win_tri_begin_ND ; yup, start writing triangle data + jge .win_tri_begin_ND ; yup, start writing triangle data - push @Line ; line number inside this function - push 0h ; pointer to function name = NULL - - push ecx ; fifo space needed - call __grCommandTransportMakeRoom@12 ; note: updates fifoPtr + invoke _grCommandTransportMakeRoom, ecx, 0, __LINE__; note: updates fifoPtr align 32 -$win_tri_begin_ND: +.win_tri_begin_ND: mov eax, vertexCount ; number of vertices in triangles mov fifo, [gc + fifoPtr] ; get fifoPtr @@ -208,7 +197,7 @@ $win_tri_begin_ND: or eax, ebp ; setup vertex count and type test fifo, 4 ; fifoPtr QWORD aligned ? - jz $fifo_aligned_ND ; yup + jz .fifo_aligned_ND ; yup mov [fifo], eax ; PCI write packet type add fifo, 4 ; fifo pointer now QWORD aligned @@ -237,7 +226,7 @@ $win_tri_begin_ND: ; 987 : count -= 15; ; 988 : } -$win_vertex_loop_ND_WB0: ; nothing in "write buffer" +.win_vertex_loop_ND_WB0: ; nothing in "write buffer" mov eax, [dlpStart] ; get first offset from offset list mov dlp, dlpStart ; point to start of offset list @@ -249,15 +238,15 @@ $win_vertex_loop_ND_WB0: ; nothing in "write buffer" test eax, eax ; if offset == 0, end of list movq [fifo-8], mm1 ; PCI write x, y - jz $win_datalist_end_ND_WB0 ; no more vertex data, nothing in "write buffer" + jz .win_datalist_end_ND_WB0 ; no more vertex data, nothing in "write buffer" -$win_datalist_loop_ND_WB0: ; nothing in "write buffer" +.win_datalist_loop_ND_WB0: ; nothing in "write buffer" movd mm1, [vertex + eax] ; get next parameter mov eax, [dlp] ; get next offset from offset list test eax, eax ; at end of offset list (offset == 0) ? - jz $win_datalist_end_ND_WB1 ; exit, write buffer contains one DWORD + jz .win_datalist_end_ND_WB1 ; exit, write buffer contains one DWORD movd mm2, [vertex + eax] ; get next parameter add dlp, 8 ; dlp++ @@ -269,17 +258,17 @@ $win_datalist_loop_ND_WB0: ; nothing in "write buffer" punpckldq mm1, mm2 ; current param | previous param movq [fifo-8], mm1 ; PCI write current param | previous param - jnz $win_datalist_loop_ND_WB0 ; nope, copy next parameter + jnz .win_datalist_loop_ND_WB0 ; nope, copy next parameter -$win_datalist_end_ND_WB0: +.win_datalist_end_ND_WB0: mov eax, [strideinbytes] ; get offset to next vertex dec vertexCount ; another vertex done. Any left? lea vertex, [vertex + eax] ; points to next vertex - jnz $win_vertex_loop_ND_WB0 ; yup, output next vertex + jnz .win_vertex_loop_ND_WB0 ; yup, output next vertex -$win_vertex_end_ND_WB0: +.win_vertex_end_ND_WB0: mov eax, [gc + fifoPtr] ; old fifoPtr mov ebp, [gc + fifoRoom] ; old number of bytes available in fifo @@ -297,7 +286,7 @@ $win_vertex_end_ND_WB0: test vertexCount, vertexCount ; any vertices left to process ? nop ; filler - jg $win_coords_loop_ND ; loop if number of vertices to process >= 0 + jg .win_coords_loop_ND ; loop if number of vertices to process >= 0 femms ; no more MMX code; clear MMX/FPU state @@ -307,13 +296,13 @@ $win_vertex_end_ND_WB0: pop esi ; restore caller's register variable pop edi ; restore caller's register variable - ret 12 ; return, pop 3 DWORD parameters off stack + ret ; return, pop 3 DWORD parameters off stack -$fifo_aligned_ND: +.fifo_aligned_ND: movd mm1, eax ; move header into "write buffer" -$win_vertex_loop_ND_WB1: ; one DWORD in "write buffer" +.win_vertex_loop_ND_WB1: ; one DWORD in "write buffer" movd mm2, [vertex] ; 0 | x of vertex add fifo, 8 ; fifoPtr += 2*sizeof(FxU32) @@ -328,9 +317,9 @@ $win_vertex_loop_ND_WB1: ; one DWORD in "write buffer" movd mm1, [vertex+4] ; 0 | y of vertex cmp eax, 0 ; offset == 0 (list empty) ? - jz $win_datalist_end_ND_WB1 ; yup, no more vertex data, one DWORD in "write buffer" + jz .win_datalist_end_ND_WB1 ; yup, no more vertex data, one DWORD in "write buffer" -$win_datalist_loop_ND_WB1: ; one DWORD in "write buffer" +.win_datalist_loop_ND_WB1: ; one DWORD in "write buffer" movd mm2, [vertex + eax] ; get next parameter add fifo, 8 ; fifoPtr += 2*sizeof(FxU32) @@ -342,23 +331,23 @@ $win_datalist_loop_ND_WB1: ; one DWORD in "write buffer" cmp eax, 0 ; at end of offset list (offset == 0) ? movq [fifo-8], mm1 ; PCI write current param | previous param - jz $win_datalist_end_ND_WB0 ; yes, exit, "write buffer" empty + jz .win_datalist_end_ND_WB0 ; yes, exit, "write buffer" empty movd mm1, [vertex + eax] ; get next parameter mov eax, [dlp-4] ; get next offset from offset list cmp eax, 0 ; at end of offset list (offset == 0) ? - jnz $win_datalist_loop_ND_WB1 ; nope, copy next parameter + jnz .win_datalist_loop_ND_WB1 ; nope, copy next parameter -$win_datalist_end_ND_WB1: +.win_datalist_end_ND_WB1: mov eax, [strideinbytes] ; get offset to next vertex dec vertexCount ; another vertex done. Any left? lea vertex, [vertex + eax] ; points to next vertex - jnz $win_vertex_loop_ND_WB1 ; yup, output next vertex + jnz .win_vertex_loop_ND_WB1 ; yup, output next vertex -$win_vertex_end_ND_WB1: +.win_vertex_end_ND_WB1: movd [fifo], mm1 ; flush "write buffer" mov eax, [gc + fifoPtr] ; old fifoPtr @@ -379,7 +368,7 @@ $win_vertex_end_ND_WB1: test vertexCount, vertexCount ; any vertices left to process ? nop ; filler - jg $win_coords_loop_ND ; loop if number of vertices to process >= 0 + jg .win_coords_loop_ND ; loop if number of vertices to process >= 0 femms ; no more MMX code; clear MMX/FPU state @@ -389,18 +378,18 @@ $win_vertex_end_ND_WB1: pop esi ; restore caller's register variable pop edi ; restore caller's register variable - ret 12 ; return, pop 3 DWORD parameters off stack + ret ; return, pop 3 DWORD parameters off stack align 32 -$deref_mode: +.deref_mode: prefetch [vertexPtr] ; pre-load first group of pointers test ecx, ecx ; coordinate space == 0 (window) ? - jnz $clip_coordinates_D ; nope, coordinate space != window + jnz .clip_coordinates_D ; nope, coordinate space != window -$win_coords_loop_D: +.win_coords_loop_D: sub vertexCount, 15 ; vertexCount >= 15 ? CF=0 : CF=1 mov ecx, [gc + vertexSize] ; bytes of data for each vertex @@ -416,16 +405,12 @@ $win_coords_loop_D: add ecx, 4 ; add header size ==> total packet size cmp eax, ecx ; fifo space avail >= packet size ? - jge $win_tri_begin_D ; yup, start writing triangle data + jge .win_tri_begin_D ; yup, start writing triangle data - push @Line ; line number inside this function - push 0h ; pointer to function name = NULL - - push ecx ; fifo space needed - call __grCommandTransportMakeRoom@12 ; note: updates fifoPtr + invoke _grCommandTransportMakeRoom, ecx, 0, __LINE__ ; note: updates fifoPtr align 32 -$win_tri_begin_D: +.win_tri_begin_D: mov eax, vertexCount ; number of vertices in triangles mov fifo, [gc + fifoPtr] ; get fifoPtr @@ -437,12 +422,12 @@ $win_tri_begin_D: lea dlpStart, [gc+tsuDataList] ; pointer to start of offset list test fifo, 4 ; fifoPtr QWORD aligned ? - jz $fifo_aligned_D ; yup + jz .fifo_aligned_D ; yup mov [fifo], eax ; PCI write packet type add fifo, 4 ; fifo pointer now QWORD aligned -$win_vertex_loop_D_WB0: ; nothing in "write buffer" +.win_vertex_loop_D_WB0: ; nothing in "write buffer" mov edx, [vertexPtr] ; dereference pointer, edx points to vertex add vertexPtr, 4 ; next pointer @@ -457,15 +442,15 @@ $win_vertex_loop_D_WB0: ; nothing in "write buffer" add fifo, 8 ; fifo += 2 test eax, eax ; if offset == 0, end of offset list - je $win_datalist_end_D_WB0 ; no more vertex data, nothing in "write buffer" + je .win_datalist_end_D_WB0 ; no more vertex data, nothing in "write buffer" -$win_datalist_loop_D_WB0: ; nothing in "write buffer" +.win_datalist_loop_D_WB0: ; nothing in "write buffer" movd mm1, [edx + eax] ; get next parameter mov eax, [dlp] ; get next offset from offset list test eax, eax ; at end of offset list (offset == 0) ? - jz $win_datalist_end_D_WB1 ; exit, write buffer contains one DWORD + jz .win_datalist_end_D_WB1 ; exit, write buffer contains one DWORD movd mm2, [edx + eax] ; get next parameter add dlp, 8 ; dlp++ @@ -477,14 +462,14 @@ $win_datalist_loop_D_WB0: ; nothing in "write buffer" cmp eax, 0 ; at end of offset list (offset == 0) ? movq [fifo-8], mm1 ; PCI write current param | previous param - jnz $win_datalist_loop_D_WB0 ; nope, copy next parameter + jnz .win_datalist_loop_D_WB0 ; nope, copy next parameter -$win_datalist_end_D_WB0: +.win_datalist_end_D_WB0: dec vertexCount ; another vertex done. Any left? - jnz $win_vertex_loop_D_WB0 ; yup, output next vertex + jnz .win_vertex_loop_D_WB0 ; yup, output next vertex -$win_vertex_end_D_WB0: +.win_vertex_end_D_WB0: mov eax, [gc + fifoPtr] ; old fifoPtr nop ; filler @@ -504,7 +489,7 @@ $win_vertex_end_D_WB0: test vertexCount, vertexCount ; any vertices left to process ? mov [esp + _count], vertexCount; remaining number of vertices to process - jg $win_coords_loop_D ; loop if number of vertices to process >= 0 + jg .win_coords_loop_D ; loop if number of vertices to process >= 0 femms ; no more MMX code; clear MMX/FPU state @@ -514,13 +499,13 @@ $win_vertex_end_D_WB0: pop esi ; restore caller's register variable pop edi ; restore caller's register variable - ret 12 ; return, pop 3 DWORD parameters off stack + ret ; return, pop 3 DWORD parameters off stack -$fifo_aligned_D: +.fifo_aligned_D: movd mm1, eax ; move header into "write buffer" -$win_vertex_loop_D_WB1: ; one DWORD in "write buffer" +.win_vertex_loop_D_WB1: ; one DWORD in "write buffer" mov edx, [vertexPtr] ; dereference pointer, edx points to vertex add vertexPtr, 4 ; next pointer @@ -538,9 +523,9 @@ $win_vertex_loop_D_WB1: ; one DWORD in "write buffer" movd mm1, [edx + 4] ; 0 | y of vertex cmp eax, 0 ; offset == 0 (list empty) ? - je $win_datalist_end_D_WB1 ; yup, no more vertex data, one DWORD in "write buffer" + je .win_datalist_end_D_WB1 ; yup, no more vertex data, one DWORD in "write buffer" -$win_datalist_loop_D_WB1: ; one DWORD in "write buffer" = MM1 +.win_datalist_loop_D_WB1: ; one DWORD in "write buffer" = MM1 movd mm2, [edx + eax] ; get next parameter add fifo, 8 ; fifoPtr += 2*sizeof(FxU32) @@ -552,20 +537,20 @@ $win_datalist_loop_D_WB1: ; one DWORD in "write buffer" = MM1 test eax, eax ; at end of offset list (offset == 0) ? movq [fifo-8], mm1 ; PCI write current param | previous param - jz $win_datalist_end_D_WB0 ; yes, exit, "write buffer" empty + jz .win_datalist_end_D_WB0 ; yes, exit, "write buffer" empty movd mm1, [edx + eax] ; get next parameter mov eax, [dlp-4] ; get next offset from offset list test eax, eax ; at end of offset list (offset == 0) ? - jnz $win_datalist_loop_D_WB1 ; nope, copy next parameter + jnz .win_datalist_loop_D_WB1 ; nope, copy next parameter -$win_datalist_end_D_WB1: +.win_datalist_end_D_WB1: dec vertexCount ; another vertex done. Any left? - jnz $win_vertex_loop_D_WB1 ; yup, output next vertex + jnz .win_vertex_loop_D_WB1 ; yup, output next vertex -$win_vertex_end_D_WB1: +.win_vertex_end_D_WB1: movd [fifo], mm1 ; flush "write buffer" mov eax, [gc + fifoPtr] ; old fifoPtr @@ -586,7 +571,7 @@ $win_vertex_end_D_WB1: cmp vertexCount, 0 ; any vertices left to process ? nop ; filler - jg $win_coords_loop_D ; loop if number of vertices to process >= 0 + jg .win_coords_loop_D ; loop if number of vertices to process >= 0 femms ; no more MMX code; clear MMX/FPU state @@ -596,7 +581,7 @@ $win_vertex_end_D_WB1: pop esi ; restore caller's register variable pop edi ; restore caller's register variable - ret 12 ; return, pop 3 DWORD parameters off stack + ret ; return, pop 3 DWORD parameters off stack ALIGN 32 @@ -634,17 +619,17 @@ $win_vertex_end_D_WB1: ; 1020 : } ; 1021 : } -$clip_coordinates_D: +.clip_coordinates_D: - mov [strideinbytes], 4 ; unit stride for array of pointers to vertices + mov dword [strideinbytes], 4 ; unit stride for array of pointers to vertices -$clip_coordinates_ND: +.clip_coordinates_ND: -dataElem textequ ; number of vertex components processed +%define dataElem ebp ; number of vertex components processed - movd mm6,[__GlideRoot+pool_f255]; GlideRoot.pool.f255 + movd mm6,[_GlideRoot+pool_f255] ; GlideRoot.pool.f255 -$clip_coords_begin: +.clip_coords_begin: sub vertexCount, 15 ; vertexCount >= 15 ? CF=0 : CF=1 mov ecx, [gc + vertexSize] ; bytes of data for each vertex @@ -660,16 +645,12 @@ $clip_coords_begin: add ecx, 4 ; add header size ==> total packet size cmp eax, ecx ; fifo space avail >= packet size ? - jge $clip_tri_begin ; yup, start writing triangle data + jge .clip_tri_begin ; yup, start writing triangle data - push @Line ; line number inside this function - push 0h ; pointer to function name = NULL - - push ecx ; fifo space needed - call __grCommandTransportMakeRoom@12 ; note: updates fifoPtr + invoke _grCommandTransportMakeRoom, ecx, 0, __LINE__ ; note: updates fifoPtr align 32 -$clip_tri_begin: +.clip_tri_begin: mov edx, vertexCount ; number of vertices in triangles mov fifo, [gc + fifoPtr] ; get fifoPtr @@ -681,7 +662,7 @@ $clip_tri_begin: mov [fifo], edx ; PCI write packet type add fifo, 4 ; fifo pointer now QWORD aligned -$clip_for_begin: +.clip_for_begin: mov edx, vertexPtr ; vertex = vertexPtr (assume no-deref mode) mov eax, [esp+_mode] ; mode 0 = no deref, mode 1 = deref @@ -690,11 +671,11 @@ $clip_for_begin: test eax, eax ; deref mode ? mov eax, [gc + wInfo_offset] ; get offset of W into vertex struct - jz $clip_noderef ; yup, no-deref mode + jz .clip_noderef ; yup, no-deref mode mov edx, [vertexPtr] ; vertex = *vertexPtr -$clip_noderef: +.clip_noderef: movd mm0, [edx + eax] ; 0 | W of current vertex pfrcp mm1, mm0 ; 0 | 1/W approx @@ -744,13 +725,13 @@ $clip_noderef: mov eax, [gc + tsuDataList] ; first entry from offset list movq [fifo-8], mm2 ; PCI write transformed x, y - jz $clip_setup_ooz ; nope, no color at all needed + jz .clip_setup_ooz ; nope, no color at all needed - cmp DWORD PTR [gc+colorType], 0; gc->state.vData.colorType == GR_FLOAT ? - jne $clip_setup_pargb ; nope, packed ARGB format + cmp DWORD [gc+colorType], 0 ; gc->state.vData.colorType == GR_FLOAT ? + jne .clip_setup_pargb ; nope, packed ARGB format test esi, 1 ; STATE_REQUIRES_IT_DRGB ? - jz $clip_setup_a ; no, but definitely A + jz .clip_setup_a ; no, but definitely A movd mm2, [edx + eax] ; 0 | r mov eax, [gc + tsuDataList+4] ; offset of g part of vertex data @@ -774,9 +755,9 @@ $clip_noderef: lea fifo, [fifo+12] ; fifoPtr += 3*sizeof(FxFloat) movd [fifo-4], mm2 ; PCI write b*255 - jz $clip_setup_ooz ; nope, no alpha, proceeed with ooz + jz .clip_setup_ooz ; nope, no alpha, proceeed with ooz -$clip_setup_a: +.clip_setup_a: movd mm2, [eax+edx] ; 0 | a add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -787,9 +768,9 @@ $clip_setup_a: mov eax, [gc+dataElem+tsuDataList]; offset of next part of vertex data movd [fifo-4], mm2 ; PCI write a*255 - jmp $clip_setup_ooz ; check whether we need to push out z + jmp .clip_setup_ooz ; check whether we need to push out z -$clip_setup_pargb: +.clip_setup_pargb: movd mm2, [eax+edx] ; get packed ARGB data add fifo, 4 ; fifoPtr += sizeof(FxU32) @@ -815,16 +796,16 @@ $clip_setup_pargb: ;;; } \ ;;; } \ -$clip_setup_ooz: +.clip_setup_ooz: test esi, 4 ; STATE_REQUIRES_OOZ ? - jz $clip_setup_qow ; nope + jz .clip_setup_qow ; nope - test DWORD PTR[gc+fbi_fbzMode],200000h ; gc->state.fbi_config.fbzMode & SST_DEPTH_FLOAT_SEL != 0 ? - je $clip_setup_ooz_nofog ; nope + test DWORD [gc+fbi_fbzMode],200000h ; gc->state.fbi_config.fbzMode & SST_DEPTH_FLOAT_SEL != 0 ? + je .clip_setup_ooz_nofog ; nope - cmp DWORD PTR[gc+qInfo_mode], 0; gc->state.vData.qInfo.mode == GR_PARAM_ENABLE ? - jz $clip_setup_fog_oow ; nope + cmp DWORD [gc+qInfo_mode], 0 ; gc->state.vData.qInfo.mode == GR_PARAM_ENABLE ? + jz .clip_setup_fog_oow ; nope mov eax, [gc + qInfo_offset] ; offset of Q component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -836,9 +817,9 @@ $clip_setup_ooz: pfmul mm2, mm0 ; 0 | q*oow movd [fifo-4], mm2 ; PCI write transformed Q - jmp $clip_setup_qow ; check whether we need to write Q or W + jmp .clip_setup_qow ; check whether we need to write Q or W -$clip_setup_fog_oow: +.clip_setup_fog_oow: add fifo, 4 ; fifoPtr += sizeof(FxFloat) add dataElem, 4 ; dataElem++ @@ -846,9 +827,9 @@ $clip_setup_fog_oow: movd [fifo-4], mm0 ; PCI write oow mov eax,[gc+dataElem+tsuDataList]; pointer to next vertex component - jmp $clip_setup_qow ; check whether we need to write Q or W + jmp .clip_setup_qow ; check whether we need to write Q or W -$clip_setup_ooz_nofog: +.clip_setup_ooz_nofog: movd mm2, [eax + edx] ; 0 | z component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -878,12 +859,12 @@ $clip_setup_ooz_nofog: ;;; i = gc->tsuDataList[dataElem]; \ ;;; } \ -$clip_setup_qow: +.clip_setup_qow: test esi, 8 ; STATE_REQUIRES_OOW_FBI ? - jz $clip_setup_qow0 ; nope + jz .clip_setup_qow0 ; nope - cmp DWORD PTR[gc+fogInfo_mode],0; gc->state.vData.fogInfo.mode == GR_PARAM_ENABLE ? - jz $clip_setup_oow_nofog ; nope, no fog + cmp DWORD [gc+fogInfo_mode],0 ; gc->state.vData.fogInfo.mode == GR_PARAM_ENABLE ? + jz .clip_setup_oow_nofog ; nope, no fog mov eax, [gc + fogInfo_offset] ; offset of fogInfo component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -895,12 +876,12 @@ $clip_setup_qow: pfmul mm2, mm0 ; fogInfo*oow movd [fifo-4], mm2 ; PCI write transformed Q - jmp $clip_setup_qow0 ; continue with q0 + jmp .clip_setup_qow0 ; continue with q0 -$clip_setup_oow_nofog: +.clip_setup_oow_nofog: - cmp DWORD PTR [gc+qInfo_mode],0; gc->state.vData.qInfo.mode == GR_PARAM_ENABLE ? - je $clip_setup_oow ; nope, write oow, not Q + cmp DWORD [gc+qInfo_mode],0 ; gc->state.vData.qInfo.mode == GR_PARAM_ENABLE ? + je .clip_setup_oow ; nope, write oow, not Q mov eax, [gc + qInfo_offset] ; offset of Q component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -912,9 +893,9 @@ $clip_setup_oow_nofog: pfmul mm2, mm0 ; q*oow movd [fifo-4], mm2 ; PCI write transformed Q - jmp $clip_setup_qow0 ; continue with q0 + jmp .clip_setup_qow0 ; continue with q0 -$clip_setup_oow: +.clip_setup_oow: add fifo, 4 ; fifoPtr += sizeof(FxFloat) add dataElem, 4 ; dataElem++ @@ -932,12 +913,12 @@ $clip_setup_oow: ;;; i = gc->tsuDataList[dataElem]; \ ;;; } \ -$clip_setup_qow0: +.clip_setup_qow0: test esi, 16 ; STATE_REQUIRES_W_TMU0 ? - jz $clip_setup_stow0 ; nope + jz .clip_setup_stow0 ; nope - cmp DWORD PTR [gc+q0Info_mode],0; does vertex have Q component ? - je $clip_setup_oow0 ; nope, not Q but W + cmp DWORD [gc+q0Info_mode],0 ; does vertex have Q component ? + je .clip_setup_oow0 ; nope, not Q but W mov eax, [gc+q0Info_offset] ; offset of Q component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -949,11 +930,11 @@ $clip_setup_qow0: pfmul mm2, mm0 ; q0*oow movd [fifo-4], mm2 ; PCI write transformed q0 - jmp $clip_setup_stow0 ; continue with stow0 + jmp .clip_setup_stow0 ; continue with stow0 nop ; filler -$clip_setup_oow0: +.clip_setup_oow0: add fifo, 4 ; fifoPtr += sizeof(FxFloat) add dataElem, 4 ; dataElem++ @@ -965,10 +946,10 @@ $clip_setup_oow0: ;;; DA_SETF_SCALE_ADVANCE(_s,_oow*gc->state.tmu_config[0].t_scale); \ ;;; } \ -$clip_setup_stow0: +.clip_setup_stow0: test esi, 32 ; STATE_REQUIRES_ST_TMU0 ? - jz $clip_setup_qow1 ; nope + jz .clip_setup_qow1 ; nope movq mm7, [gc + tmu0_s_scale] ; state.tmu_config[0].t_scale | state.tmu_config[0].s_scale add fifo, 8 ; fifoPtr += 2*sizeof(FxFloat) @@ -999,12 +980,12 @@ $clip_setup_stow0: ;;; i = gc->tsuDataList[dataElem]; \ ;;; } \ -$clip_setup_qow1: +.clip_setup_qow1: test esi, 64 ; STATE_REQUIRES_W_TMU1 ? - jz $clip_setup_stow1 ; nope + jz .clip_setup_stow1 ; nope - cmp DWORD PTR [gc+q1Info_mode],0; does vertex have Q component ? - je $clip_setup_oow1 ; nope, not Q but W + cmp DWORD [gc+q1Info_mode],0 ; does vertex have Q component ? + je .clip_setup_oow1 ; nope, not Q but W mov eax, [gc+q1Info_offset] ; offset of Q component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -1016,9 +997,9 @@ $clip_setup_qow1: pfmul mm2, mm0 ; q1*oow movd [fifo-4], mm2 ; PCI write transformed q1 - jmp $clip_setup_stow1 ; continue with stow1 + jmp .clip_setup_stow1 ; continue with stow1 -$clip_setup_oow1: +.clip_setup_oow1: add fifo, 4 ; fifoPtr += sizeof(FxFloat) add dataElem, 4 ; dataElem++ @@ -1030,13 +1011,13 @@ $clip_setup_oow1: ;;; DA_SETF_SCALE_ADVANCE(_s,_oow*gc->state.tmu_config[1].t_scale); \ ;;; } \ -$clip_setup_stow1: +.clip_setup_stow1: test esi, 128 ; STATE_REQUIRES_ST_TMU1 ? mov vertexCount, [vertices] ; get number of vertices movq mm7, [gc + tmu1_s_scale] ; state.tmu_config[1].t_scale | state.tmu_config[1].s_scale - jz $clip_setup_end ; nope + jz .clip_setup_end ; nope movd mm2, [edx + eax] ; param1 add fifo, 8 ; fifoPtr += 2*sizeof(FxFloat) @@ -1050,12 +1031,12 @@ $clip_setup_stow1: pfmul mm2, mm7 ; param2*oow*state.tmu_config[1].t_scale | param1*oow*state.tmu_config[1].s_scale movq [fifo-8], mm2 ; PCI write param2*oow*state.tmu_config[1].t_scale | param1*oow*state.tmu_config[1].s_scale -$clip_setup_end: +.clip_setup_end: dec vertexCount ; vcount-- - jnz $clip_for_begin ; until + jnz .clip_for_begin ; until -$clip_for_end: +.clip_for_end: mov eax, [gc + fifoPtr] ; old fifoPtr mov ebp, [gc + fifoRoom] ; old number of bytes available in fifo @@ -1072,62 +1053,61 @@ $clip_for_end: mov [esp + _count], vertexCount; remaining number of vertices to process cmp vertexCount, 0 ; any vertices left to process ? - jg $clip_coords_begin ; loop if number of vertices to process >= 0 + jg .clip_coords_begin ; loop if number of vertices to process >= 0 femms ; no more MMX code; clear MMX/FPU state -$tris_done: +.tris_done: pop ebp ; restore frame pointer pop ebx ; restore caller's register variable pop esi ; restore caller's register variable pop edi ; restore caller's register variable - ret 12 ; return, pop 3 DWORD parameters -__grDrawTriangles_3DNow@12 ENDP + ret ; return, pop 3 DWORD parameters +endp -_pktype = 20 -_type = 24 -_mode = 28 -_count = 32 -_pointers = 36 +_pktype equ 20 +_type equ 24 +%define _mode 28 +%define _count 32 +%define _pointers 36 -gc TEXTEQU ; points to graphics context -fifo TEXTEQU ; points to next entry in fifo -dlp TEXTEQU ; points to dataList structure -vertexCount TEXTEQU ; Current vertex counter in the packet -vertexPtr TEXTEQU ; Current vertex pointer (in deref mode) -vertex TEXTEQU ; Current vertex (in non-deref mode) -dlpStart TEXTEQU ; Pointer to start of offset list +%define gc edi ; points to graphics context +%define fifo ecx ; points to next entry in fifo +%define dlp ebp ; points to dataList structure +%define vertexCount esi ; Current vertex counter in the packet +%define vertexPtr ebx ; Current vertex pointer (in deref mode) +%define vertex ebx ; Current vertex (in non-deref mode) +%define dlpStart edx ; Pointer to start of offset list -X TEXTEQU <0> -Y TEXTEQU <4> +%define X 0 +%define Y 4 ALIGN 32 - PUBLIC __grDrawVertexList_3DNow_Window@20 -__grDrawVertexList_3DNow_Window@20 PROC NEAR +proc _grDrawVertexList_3DNow_Window, 20 ; 132 : { - mov edx, DWORD PTR fs:[18h] ; get thread local storage base pointer + SET_TLSBASE edx ; get thread local storage base pointer push edi ; save caller's register variable push esi ; save caller's register variable mov vertexCount, [esp+_count-8]; number of vertices in strip/fan push ebp ; save frame pointer - mov ebp, [__GlideRoot + tlsOffset]; GC position relative to tls base + SET_TLSOFFSET ebp ; GC position relative to tls base push ebx ; save caller's register variable mov vertexPtr, [esp+_pointers] ; get current vertex pointer (deref mode) ; get current vertex (non-deref mode) - mov gc, [edx + ebp] ; get current graphics context from tls + GET_GC edx, ebp ; get current graphics context from tls test vertexCount, vertexCount ; number of vertices <= 0 ? nop ; filler - jle strip_done ; yup, the strip/fan is done - + jle .strip_done ; yup, the strip/fan is done + ;;; vSize = gc->state.vData.vSize ;;; if (stride == 0) ;;; stride = gc->state.vData.vStride; @@ -1150,7 +1130,7 @@ __grDrawVertexList_3DNow_Window@20 PROC NEAR test edx, edx ; mode 0 (array of vertices) ? mov edx, [gc + vertexStride] ; get stride in DWORDs - jnz deref_mode ; nope, it's mode 1 (array of pointers to vertices) + jnz .deref_mode ; nope, it's mode 1 (array of pointers to vertices) femms ; we'll use MMX; clear MMX/3DX state @@ -1169,7 +1149,7 @@ __grDrawVertexList_3DNow_Window@20 PROC NEAR ;;; TRI_STRIP_BEGIN(type, vcount, vSize, pktype); -win_coords_loop_ND: +.win_coords_loop_ND: sub vertexCount, 15 ; vertexCount >= 15 ? CF=0 : CF=1 mov ecx, [gc + vertexSize] ; bytes of data for each vertex @@ -1185,16 +1165,12 @@ win_coords_loop_ND: add ecx, 4 ; add header size ==> total packet size cmp eax, ecx ; fifo space avail >= packet size ? - jge win_strip_begin_ND ; yup, start writing strip data + jge .win_strip_begin_ND ; yup, start writing strip data - push @Line ; line number inside this function - push 0h ; pointer to function name = NULL - - push ecx ; fifo space needed - call __grCommandTransportMakeRoom@12 ; note: updates fifoPtr + invoke _grCommandTransportMakeRoom, ecx, 0, __LINE__; note: updates fifoPtr align 32 -win_strip_begin_ND: +.win_strip_begin_ND: ;;; Setup packet header ;;; mov eax, vertexCount ; number of vertices in strip/fan @@ -1216,7 +1192,7 @@ win_strip_begin_ND: lea dlpStart, [gc+tsuDataList] ; pointer to start of offset list test fifo, 4 ; fifoPtr QWORD aligned ? - jz fifo_aligned_ND ; yup + jz .fifo_aligned_ND ; yup mov [fifo], eax ; PCI write packet type add fifo, 4 ; fifo pointer now QWORD aligned @@ -1234,7 +1210,7 @@ win_strip_begin_ND: ;;; TRI_SETF(FARRAY(vPtr, 4)); ;;; i = gc->tsuDataList[dataElem]; -win_vertex_loop_ND_WB0: ; nothing in "write buffer" +.win_vertex_loop_ND_WB0: ; nothing in "write buffer" mov eax, [dlpStart] ; get first offset from offset list lea dlp, [dlpStart+4] ; point to start of offset list @@ -1246,7 +1222,7 @@ win_vertex_loop_ND_WB0: ; nothing in "write buffer" test eax, eax ; if offset == 0, end of list movq [fifo-8], mm1 ; PCI write x, y - jz win_datalist_end_ND_WB0 ; no more vertex data, nothing in "write buffer" + jz .win_datalist_end_ND_WB0 ; no more vertex data, nothing in "write buffer" ;;; while (i != GR_DLIST_END) { ;;; TRI_SETF(FARRAY(vPtr, i)); @@ -1254,13 +1230,13 @@ win_vertex_loop_ND_WB0: ; nothing in "write buffer" ;;; i = gc->tsuDataList[dataElem]; ;;; } -win_datalist_loop_ND_WB0: ; nothing in "write buffer" +.win_datalist_loop_ND_WB0: ; nothing in "write buffer" movd mm1, [vertex + eax] ; get next parameter mov eax, [dlp] ; get next offset from offset list test eax, eax ; at end of offset list (offset == 0) ? - jz win_datalist_end_ND_WB1 ; exit, write buffer contains one DWORD + jz .win_datalist_end_ND_WB1 ; exit, write buffer contains one DWORD movd mm2, [vertex + eax] ; get next parameter add dlp, 8 ; dlp++ @@ -1272,17 +1248,17 @@ win_datalist_loop_ND_WB0: ; nothing in "write buffer" punpckldq mm1, mm2 ; current param | previous param movq [fifo-8], mm1 ; PCI write current param | previous param - jnz win_datalist_loop_ND_WB0 ; nope, copy next parameter + jnz .win_datalist_loop_ND_WB0 ; nope, copy next parameter -win_datalist_end_ND_WB0: +.win_datalist_end_ND_WB0: mov eax, [strideinbytes] ; get offset to next vertex sub vertexCount, 1 ; another vertex done. Any left? lea vertex, [vertex + eax] ; points to next vertex - jnz win_vertex_loop_ND_WB0 ; yup, output next vertex + jnz .win_vertex_loop_ND_WB0 ; yup, output next vertex -win_vertex_end_ND_WB0: +.win_vertex_end_ND_WB0: ;;; TRI_END; ;;; Prepare for the next packet (if the strip size is longer than 15) @@ -1310,7 +1286,7 @@ win_vertex_end_ND_WB0: mov [esp + _count], vertexCount; remaining number of vertices to process test vertexCount, vertexCount ; any vertices left to process ? - jg win_coords_loop_ND ; loop if number of vertices to process >= 0 + jg .win_coords_loop_ND ; loop if number of vertices to process >= 0 femms ; no more MMX code; clear MMX/FPU state @@ -1320,15 +1296,15 @@ win_vertex_end_ND_WB0: pop esi ; restore caller's register variable pop edi ; restire caller's register variable - ret 20 ; return, pop 5 DWORD parameters off stack + ret ; return, pop 5 DWORD parameters off stack ALIGN 32 -fifo_aligned_ND: +.fifo_aligned_ND: movd mm1, eax ; move header into "write buffer" -win_vertex_loop_ND_WB1: ; one DWORD in "write buffer" +.win_vertex_loop_ND_WB1: ; one DWORD in "write buffer" movd mm2, [vertex + X] ; 0 | x of vertex add fifo, 8 ; fifoPtr += 2*sizeof(FxU32) @@ -1343,7 +1319,7 @@ win_vertex_loop_ND_WB1: ; one DWORD in "write buffer" movd mm1, [vertex + Y] ; 0 | y of vertex cmp eax, 0 ; offset == 0 (list empty) ? - jz win_datalist_end_ND_WB1 ; yup, no more vertex data, one DWORD in "write buffer" + jz .win_datalist_end_ND_WB1 ; yup, no more vertex data, one DWORD in "write buffer" ;;; while (i != GR_DLIST_END) { ;;; TRI_SETF(FARRAY(vPtr, i)); @@ -1351,7 +1327,7 @@ win_vertex_loop_ND_WB1: ; one DWORD in "write buffer" ;;; i = gc->tsuDataList[dataElem]; ;;; } -win_datalist_loop_ND_WB1: ; one DWORD in "write buffer" +.win_datalist_loop_ND_WB1: ; one DWORD in "write buffer" movd mm2, [vertex + eax] ; get next parameter add fifo, 8 ; fifoPtr += 2*sizeof(FxU32) @@ -1363,23 +1339,23 @@ win_datalist_loop_ND_WB1: ; one DWORD in "write buffer" cmp eax, 0 ; at end of offset list (offset == 0) ? movq [fifo-8], mm1 ; PCI write current param | previous param - jz win_datalist_end_ND_WB0 ; yes, exit, "write buffer" empty + jz .win_datalist_end_ND_WB0 ; yes, exit, "write buffer" empty movd mm1, [vertex+eax] ; get next parameter mov eax, [dlp-4] ; get next offset from offset list test eax, eax ; at end of offset list (offset == 0) ? - jnz win_datalist_loop_ND_WB1 ; nope, copy next parameter + jnz .win_datalist_loop_ND_WB1 ; nope, copy next parameter -win_datalist_end_ND_WB1: +.win_datalist_end_ND_WB1: mov eax, [strideinbytes] ; get offset to next vertex sub vertexCount, 1 ; another vertex done. Any left? lea vertex, [vertex + eax] ; points to next vertex - jnz win_vertex_loop_ND_WB1 ; yup, output next vertex + jnz .win_vertex_loop_ND_WB1 ; yup, output next vertex -win_vertex_end_ND_WB1: +.win_vertex_end_ND_WB1: movd [fifo], mm1 ; flush "write buffer" add fifo, 4 ; fifoPtr += sizeof(FxU32) @@ -1410,7 +1386,7 @@ win_vertex_end_ND_WB1: test vertexCount, vertexCount ; any vertices left to process ? nop ; filler - jg win_coords_loop_ND ; loop if number of vertices to process >= 0 + jg .win_coords_loop_ND ; loop if number of vertices to process >= 0 femms ; no more MMX code; clear MMX/FPU state @@ -1420,17 +1396,17 @@ win_vertex_end_ND_WB1: pop esi ; restore caller's register variable pop edi ; restire caller's register variable - ret 20 ; return, pop 5 DWORD parameters off stack + ret ; return, pop 5 DWORD parameters off stack ALIGN 32 -deref_mode: +.deref_mode: femms ; we'll use MMX; clear FPU/MMX state prefetch [vertexPtr] ; pre-load first group of pointers -win_coords_loop_D: +.win_coords_loop_D: sub vertexCount, 15 ; vertexCount >= 15 ? CF=0 : CF=1 mov ecx, [gc + vertexSize] ; bytes of data for each vertex @@ -1446,16 +1422,12 @@ win_coords_loop_D: add ecx, 4 ; add header size ==> total packet size cmp eax, ecx ; fifo space avail >= packet size ? - jge win_strip_begin_D ; yup, start writing strip data + jge .win_strip_begin_D ; yup, start writing strip data - push @Line ; line number inside this function - push 0h ; pointer to function name = NULL - - push ecx ; fifo space needed - call __grCommandTransportMakeRoom@12 ; note: updates fifoPtr + invoke _grCommandTransportMakeRoom, ecx, 0, __LINE__; note: updates fifoPtr align 32 -win_strip_begin_D: +.win_strip_begin_D: ;;; Setup packet header ;;; mov eax, vertexCount ; number of vertices in strip/fan @@ -1477,7 +1449,7 @@ win_strip_begin_D: lea dlpStart, [gc+tsuDataList] ; pointer to start of offset list test fifo, ebp ; fifoPtr QWORD aligned ? - jz fifo_aligned_D ; yup + jz .fifo_aligned_D ; yup mov [fifo], eax ; PCI write packet type add fifo, 4 ; fifo pointer now QWORD aligned @@ -1496,7 +1468,7 @@ win_strip_begin_D: ;;; i = gc->tsuDataList[dataElem]; -win_vertex_loop_D_WB0: ; nothing in "write buffer" +.win_vertex_loop_D_WB0: ; nothing in "write buffer" mov edx, [vertexPtr] ; dereference pointer, edx points to vertex add vertexPtr, 4 ; next pointer @@ -1511,7 +1483,7 @@ win_vertex_loop_D_WB0: ; nothing in "write buffer" movq [fifo-8], mm1 ; PCI write x, y test eax, eax ; if offset == 0, end of offset list - je win_datalist_end_D_WB0 ; no more vertex data, nothing in "write buffer" + je .win_datalist_end_D_WB0 ; no more vertex data, nothing in "write buffer" ;;; while (i != GR_DLIST_END) { ;;; TRI_SETF(FARRAY(vPtr, i)); @@ -1519,13 +1491,13 @@ win_vertex_loop_D_WB0: ; nothing in "write buffer" ;;; i = gc->tsuDataList[dataElem]; ;;; } -win_datalist_loop_D_WB0: ; nothing in "write buffer" +.win_datalist_loop_D_WB0: ; nothing in "write buffer" movd mm1, [edx + eax] ; get next parameter mov eax, [dlp] ; get next offset from offset list test eax, eax ; at end of offset list (offset == 0) ? - jz win_datalist_end_D_WB1 ; exit, write buffer contains one DWORD + jz .win_datalist_end_D_WB1 ; exit, write buffer contains one DWORD add dlp, 8 ; dlp++ movd mm2, [edx + eax] ; get next parameter @@ -1537,14 +1509,14 @@ win_datalist_loop_D_WB0: ; nothing in "write buffer" test eax, eax ; at end of offset list (offset == 0) ? movq [fifo-8], mm1 ; PCI write current param | previous param - jnz win_datalist_loop_D_WB0 ; nope, copy next parameter + jnz .win_datalist_loop_D_WB0 ; nope, copy next parameter -win_datalist_end_D_WB0: +.win_datalist_end_D_WB0: dec vertexCount ; another vertex done. Any left? - jnz win_vertex_loop_D_WB0 ; yup, output next vertex + jnz .win_vertex_loop_D_WB0 ; yup, output next vertex -win_vertex_end_D_WB0: +.win_vertex_end_D_WB0: ;;; TRI_END; ;;; Prepare for the next packet (if the strip size is longer than 15) @@ -1572,7 +1544,7 @@ win_vertex_end_D_WB0: test vertexCount, vertexCount ; any vertices left to process ? nop ; filler - jg win_coords_loop_D ; loop if number of vertices to process >= 0 + jg .win_coords_loop_D ; loop if number of vertices to process >= 0 femms ; no more MMX code; clear MMX/FPU state @@ -1582,15 +1554,15 @@ win_vertex_end_D_WB0: pop esi ; restore caller's register variable pop edi ; restire caller's register variable - ret 20 ; return, pop 5 DWORD parameters off stack + ret ; return, pop 5 DWORD parameters off stack ALIGN 32 -fifo_aligned_D: +.fifo_aligned_D: movd mm1, eax ; move header into "write buffer" -win_vertex_loop_D_WB1: ; one DWORD in "write buffer" +.win_vertex_loop_D_WB1: ; one DWORD in "write buffer" mov edx, [vertexPtr] ; dereference pointer, edx points to vertex add vertexPtr, 4 ; next pointer @@ -1608,7 +1580,7 @@ win_vertex_loop_D_WB1: ; one DWORD in "write buffer" movd mm1, [edx + Y] ; 0 | y of vertex test eax, eax ; offset == 0 (list empty) ? - je win_datalist_end_D_WB1 ; yup, no more vertex data, one DWORD in "write buffer" + je .win_datalist_end_D_WB1 ; yup, no more vertex data, one DWORD in "write buffer" ;;; while (i != GR_DLIST_END) { ;;; TRI_SETF(FARRAY(vPtr, i)); @@ -1616,7 +1588,7 @@ win_vertex_loop_D_WB1: ; one DWORD in "write buffer" ;;; i = gc->tsuDataList[dataElem]; ;;; } -win_datalist_loop_D_WB1: ; one DWORD in "write buffer" = MM1 +.win_datalist_loop_D_WB1: ; one DWORD in "write buffer" = MM1 movd mm2, [edx + eax] ; get next parameter add fifo, 8 ; fifoPtr += 2*sizeof(FxU32) @@ -1628,20 +1600,20 @@ win_datalist_loop_D_WB1: ; one DWORD in "write buffer" = MM1 cmp eax, 0 ; at end of offset list (offset == 0) ? movq [fifo-8], mm1 ; PCI write current param | previous param - jz win_datalist_end_D_WB0 ; yes, exit, "write buffer" empty + jz .win_datalist_end_D_WB0 ; yes, exit, "write buffer" empty movd mm1, [edx + eax] ; get next parameter mov eax, [dlp-4] ; get next offset from offset list cmp eax, 0 ; at end of offset list (offset == 0) ? - jnz win_datalist_loop_D_WB1 ; nope, copy next parameter + jnz .win_datalist_loop_D_WB1 ; nope, copy next parameter -win_datalist_end_D_WB1: +.win_datalist_end_D_WB1: dec vertexCount ; another vertex done. Any left? - jnz win_vertex_loop_D_WB1 ; yup, output next vertex + jnz .win_vertex_loop_D_WB1 ; yup, output next vertex -win_vertex_end_D_WB1: +.win_vertex_end_D_WB1: movd [fifo], mm1 ; flush "write buffer" add fifo, 4 ; fifoPtr++ @@ -1672,48 +1644,47 @@ win_vertex_end_D_WB1: cmp vertexCount, 0 ; any vertices left to process ? mov [esp + _count], vertexCount; remaining number of vertices to process - jg win_coords_loop_D ; loop if number of vertices to process >= 0 + jg .win_coords_loop_D ; loop if number of vertices to process >= 0 femms ; no more MMX code; clear MMX/FPU state -strip_done: +.strip_done: pop ebx ; restore caller's register variable pop ebp ; restore frame pointer pop esi ; restore caller's register variable pop edi ; restire caller's register variable - ret 20 ; return, pop 5 DWORD parameters off stack + ret ; return, pop 5 DWORD parameters off stack -__grDrawVertexList_3DNow_Window@20 ENDP +endp - PUBLIC __grDrawVertexList_3DNow_Clip@20 -__grDrawVertexList_3DNow_Clip@20 PROC NEAR -; 132 : { - ALIGN 32 - mov edx, DWORD PTR fs:[18h] ; get thread local storage base pointer +proc _grDrawVertexList_3DNow_Clip, 20 +; 132 : { + + SET_TLSBASE edx ; get thread local storage base pointer push edi ; save caller's register variable push esi ; save caller's register variable mov vertexCount, [esp+_count-8]; number of vertices in strip/fan push ebp ; save frame pointer - mov ebp, [__GlideRoot + tlsOffset]; GC position relative to tls base + SET_TLSOFFSET ebp ; GC position relative to tls base push ebx ; save caller's register variable mov vertexPtr, [esp+_pointers] ; get current vertex pointer (deref mode) ; get current vertex (non-deref mode) - mov gc, [edx + ebp] ; get current graphics context from tls + GET_GC edx, ebp ; get current graphics context from tls test vertexCount, vertexCount ; number of vertices <= 0 ? - jle strip_done ; yup, the strip/fan is done - + jle .strip_done ; yup, the strip/fan is done + ;;; vSize = gc->state.vData.vSize ;;; if (stride == 0) ;;; stride = gc->state.vData.vStride; @@ -1736,20 +1707,20 @@ __grDrawVertexList_3DNow_Clip@20 PROC NEAR test edx, edx ; mode 0 (array of vertices) ? mov edx, [gc + vertexStride] ; get stride in DWORDs - movd mm6, [__GlideRoot+pool_f255]; GlideRoot.pool.f255 - mov [strideinbytes], 4 ; array of pointers + movd mm6, [_GlideRoot+pool_f255]; GlideRoot.pool.f255 + mov dword [strideinbytes], 4 ; array of pointers - jnz clip_coords_begin ; nope, it's mode 1 + jnz .clip_coords_begin ; nope, it's mode 1 -clip_coordinates_ND: +.clip_coordinates_ND: shl edx, 2 ; stride in bytes mov [strideinbytes], edx ; save off stride (in bytes) align 32 -clip_coords_begin: +.clip_coords_begin: -dataElem textequ ; number of vertex components processed +%define dataElem ebp ; number of vertex components processed ;;; { ;;; float oow; @@ -1771,16 +1742,12 @@ dataElem textequ ; number of vertex components processed nop ; filler cmp eax, ecx ; fifo space avail >= packet size ? - jge clip_strip_begin ; yup, start writing strip data + jge .clip_strip_begin ; yup, start writing strip data - push @Line ; line number inside this function - push 0h ; pointer to function name = NULL - - push ecx ; fifo space needed - call __grCommandTransportMakeRoom@12 ; note: updates fifoPtr + invoke _grCommandTransportMakeRoom, ecx, 0, __LINE__; note: updates fifoPtr align 32 -clip_strip_begin: +.clip_strip_begin: ;;; TRI_STRIP_BEGIN(type, vcount, vSize, pktype) mov edx, [esp + _type] ; setup mode @@ -1805,7 +1772,7 @@ clip_strip_begin: ;;; float *vPtr ;;; vPtr = pointers -clip_for_begin: +.clip_for_begin: ;;; if (mode) ;;; vPtr = *(float **)vPtr @@ -1817,12 +1784,12 @@ clip_for_begin: test eax, eax ; deref mode ? mov eax, [gc+wInfo_offset] ; get offset of W into vertex struct - jz clip_noderef ; yup, no-deref mode + jz .clip_noderef ; yup, no-deref mode mov edx, [vertexPtr] ; vertex = *vertexPtr lea esp, [esp] ; filler -clip_noderef: +.clip_noderef: ;;; oow = 1.0f / FARRAY(vPtr, gc->state.vData.wInfo.offset) @@ -1863,13 +1830,13 @@ clip_noderef: ;;; TRI_VP_SETFS(vPtr, oow); movq [fifo-8], mm2 ; PCI write transformed x, y - jz clip_setup_ooz ; nope, no color at all needed + jz .clip_setup_ooz ; nope, no color at all needed - cmp DWORD PTR [gc+colorType], 0; gc->state.vData.colorType == GR_FLOAT ? - jne clip_setup_pargb ; nope, packed ARGB format + cmp DWORD [gc+colorType], 0 ; gc->state.vData.colorType == GR_FLOAT ? + jne .clip_setup_pargb ; nope, packed ARGB format test esi, 1 ; STATE_REQUIRES_IT_DRGB ? - jz clip_setup_a ; no, but definitely A + jz .clip_setup_a ; no, but definitely A movd mm2, [edx + eax] ; 0 | r mov eax, [gc+tsuDataList+4] ; offset of g part of vertex data @@ -1893,9 +1860,9 @@ clip_noderef: lea fifo, [fifo+12] ; fifoPtr += 3*sizeof(FxFloat) movd [fifo-4], mm2 ; PCI write b*255 - jz clip_setup_ooz ; nope, no alpha, proceeed with ooz + jz .clip_setup_ooz ; nope, no alpha, proceeed with ooz -clip_setup_a: +.clip_setup_a: movd mm2, [eax+edx] ; 0 | a add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -1906,11 +1873,11 @@ clip_setup_a: mov eax, [gc+dataElem+tsuDataList]; offset of next part of vertex data movd [fifo-4], mm2 ; PCI write a*255 - jmp clip_setup_ooz ; check whether we need to push out z + jmp .clip_setup_ooz ; check whether we need to push out z ALIGN 32 -clip_setup_pargb: +.clip_setup_pargb: movd mm2, [eax+edx] ; get packed ARGB data add fifo, 4 ; fifoPtr += sizeof(FxU32) @@ -1919,16 +1886,16 @@ clip_setup_pargb: movd [fifo-4], mm2 ; PCI write packed ARGB -clip_setup_ooz: +.clip_setup_ooz: test esi, 4 ; STATE_REQUIRES_OOZ ? - jz clip_setup_qow ; nope + jz .clip_setup_qow ; nope - test DWORD PTR[gc+fbi_fbzMode],200000h ; gc->state.fbi_config.fbzMode & SST_DEPTH_FLOAT_SEL != 0 ? - je clip_setup_ooz_nofog ; nope + test DWORD [gc+fbi_fbzMode],200000h ; gc->state.fbi_config.fbzMode & SST_DEPTH_FLOAT_SEL != 0 ? + je .clip_setup_ooz_nofog ; nope - cmp DWORD PTR[gc+qInfo_mode], 0; gc->state.vData.qInfo.mode == GR_PARAM_ENABLE ? - jz clip_setup_fog_oow ; nope + cmp DWORD [gc+qInfo_mode], 0 ; gc->state.vData.qInfo.mode == GR_PARAM_ENABLE ? + jz .clip_setup_fog_oow ; nope mov eax, [gc + qInfo_offset] ; offset of Q component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -1940,9 +1907,9 @@ clip_setup_ooz: pfmul mm2, mm0 ; 0 | q*oow movd [fifo-4], mm2 ; PCI write transformed Q - jmp clip_setup_qow ; check whether we need to write Q or W + jmp .clip_setup_qow ; check whether we need to write Q or W -clip_setup_fog_oow: +.clip_setup_fog_oow: add fifo, 4 ; fifoPtr += sizeof(FxFloat) add dataElem, 4 ; dataElem++ @@ -1950,9 +1917,9 @@ clip_setup_fog_oow: movd [fifo-4], mm0 ; PCI write oow mov eax,[gc+dataElem+tsuDataList]; pointer to next vertex component - jmp clip_setup_qow ; check whether we need to write Q or W + jmp .clip_setup_qow ; check whether we need to write Q or W -clip_setup_ooz_nofog: +.clip_setup_ooz_nofog: movd mm2, [eax + edx] ; 0 | z component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -1969,12 +1936,12 @@ clip_setup_ooz_nofog: pfadd mm2, mm4 ; 0 | TRI_SETF(FARRAY(_s, i)*_oow*gc->state.Viewport.hdepth+gc->state.Viewport.oz movd [fifo-4], mm2 ; PCI write transformed Z -clip_setup_qow: +.clip_setup_qow: test esi, 8 ; STATE_REQUIRES_OOW_FBI ? - jz clip_setup_qow0 ; nope + jz .clip_setup_qow0 ; nope - cmp DWORD PTR[gc+fogInfo_mode],0; gc->state.vData.fogInfo.mode == GR_PARAM_ENABLE ? - jz clip_setup_oow_nofog ; nope, no fog + cmp DWORD [gc+fogInfo_mode],0 ; gc->state.vData.fogInfo.mode == GR_PARAM_ENABLE ? + jz .clip_setup_oow_nofog ; nope, no fog mov eax, [gc + fogInfo_offset] ; offset of fogInfo component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -1986,12 +1953,12 @@ clip_setup_qow: pfmul mm2, mm0 ; fogInfo*oow movd [fifo-4], mm2 ; PCI write transformed Q - jmp clip_setup_qow0 ; continue with q0 + jmp .clip_setup_qow0 ; continue with q0 -clip_setup_oow_nofog: +.clip_setup_oow_nofog: - cmp DWORD PTR [gc+qInfo_mode],0; does vertex have Q component ? - je clip_setup_oow ; nope, not Q but W + cmp DWORD [gc+qInfo_mode],0 ; does vertex have Q component ? + je .clip_setup_oow ; nope, not Q but W add fifo, 4 ; fifoPtr += sizeof(FxFloat) mov eax, [gc+qInfo_offset] ; offset of Q component of vertex @@ -2003,23 +1970,23 @@ clip_setup_oow_nofog: pfmul mm2, mm0 ; q*oow movd [fifo-4], mm2 ; PCI write transformed Q - jmp clip_setup_qow0 ; continue with q0 + jmp .clip_setup_qow0 ; continue with q0 ALIGN 32 -clip_setup_oow: +.clip_setup_oow: add fifo, 4 ; fifoPtr += sizeof(FxFloat) add dataElem, 4 ; dataElem++ movd [fifo-4], mm0 ; PCI write oow mov eax,[gc+dataElem+tsuDataList]; pointer to next vertex component -clip_setup_qow0: +.clip_setup_qow0: test esi, 16 ; STATE_REQUIRES_W_TMU0 ? - jz clip_setup_stow0 ; nope + jz .clip_setup_stow0 ; nope - cmp DWORD PTR [gc+q0Info_mode],0; does vertex have Q component ? - je clip_setup_oow0 ; nope, not Q but W + cmp DWORD [gc+q0Info_mode],0 ; does vertex have Q component ? + je .clip_setup_oow0 ; nope, not Q but W mov eax, [gc+q0Info_offset] ; offset of Q component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -2031,21 +1998,21 @@ clip_setup_qow0: pfmul mm2, mm0 ; q0*oow movd [fifo-4], mm2 ; PCI write transformed q0 - jmp clip_setup_stow0 ; continue with stow0 + jmp .clip_setup_stow0 ; continue with stow0 ALIGN 32 -clip_setup_oow0: +.clip_setup_oow0: add fifo, 4 ; fifoPtr += sizeof(FxFloat) add dataElem, 4 ; dataElem++ movd [fifo-4], mm0 ; PCI write oow mov eax,[gc+dataElem+tsuDataList]; pointer to next vertex component -clip_setup_stow0: +.clip_setup_stow0: test esi, 32 ; STATE_REQUIRES_ST_TMU0 ? - jz clip_setup_qow1 ; nope + jz .clip_setup_qow1 ; nope movq mm7, [gc + tmu0_s_scale] ; state.tmu_config[0].t_scale | state.tmu_config[0].s_scale add fifo, 8 ; fifoPtr += 2*sizeof(FxFloat) @@ -2064,12 +2031,12 @@ clip_setup_stow0: movq [fifo-8], mm2 ; PCI write param2*oow*tmu0_t_scale | param1*oow*tmu0_s_scale mov eax, [gc+dataElem+tsuDataList]; pointer to next vertex component -clip_setup_qow1: +.clip_setup_qow1: test esi, 64 ; STATE_REQUIRES_W_TMU1 ? - jz clip_setup_stow1 ; nope + jz .clip_setup_stow1 ; nope - cmp DWORD PTR [gc+q1Info_mode],0; does vertex have Q component ? - je clip_setup_oow1 ; nope, not Q but W + cmp DWORD [gc+q1Info_mode],0 ; does vertex have Q component ? + je .clip_setup_oow1 ; nope, not Q but W mov eax, [gc+q1Info_offset] ; offset of Q component of vertex add fifo, 4 ; fifoPtr += sizeof(FxFloat) @@ -2081,24 +2048,24 @@ clip_setup_qow1: pfmul mm2, mm0 ; q1*oow movd [fifo-4], mm2 ; PCI write transformed q1 - jmp clip_setup_stow1 ; continue with stow1 + jmp .clip_setup_stow1 ; continue with stow1 ALIGN 32 -clip_setup_oow1: +.clip_setup_oow1: add fifo, 4 ; fifoPtr += sizeof(FxFloat) add dataElem, 4 ; dataElem++ movd [fifo-4], mm0 ; PCI write oow mov eax,[gc+dataElem+tsuDataList]; pointer to next vertex component -clip_setup_stow1: +.clip_setup_stow1: test esi, 128 ; STATE_REQUIRES_ST_TMU1 ? mov vertexCount, [vertices] ; get number of vertices movq mm7, [gc + tmu1_s_scale] ; state.tmu_config[1].t_scale | state.tmu_config[1].s_scale - jz clip_setup_end ; nope + jz .clip_setup_end ; nope movd mm2, [edx+eax] ; param1 add fifo, 8 ; fifoPtr += 2*sizeof(FxFloat) @@ -2112,13 +2079,13 @@ clip_setup_stow1: pfmul mm2, mm7 ; param2*oow*state.tmu_config[1].t_scale | param1*oow*state.tmu_config[1].s_scale movq [fifo-8], mm2 ; PCI write param2*oow*state.tmu_config[1].t_scale | param1*oow*state.tmu_config[1].s_scale -clip_setup_end: +.clip_setup_end: ; 206 : for (k = 0; k < vcount; k++) { dec vertexCount ; vcount-- - jnz clip_for_begin ; until -clip_for_end: + jnz .clip_for_begin ; until +.clip_for_end: ; 221 : } ; 222 : TRI_END; @@ -2141,12 +2108,12 @@ clip_for_end: mov [esp + _count], vertexCount; remaining number of vertices to process cmp vertexCount, 0 ; any vertices left to process ? - mov DWORD PTR [esp+_pktype], 16; pktype = SSTCP_PKT3_DDDDDD (strip continuation) - jg clip_coords_begin ; loop if number of vertices to process >= 0 + mov DWORD [esp+_pktype], 16 ; pktype = SSTCP_PKT3_DDDDDD (strip continuation) + jg .clip_coords_begin ; loop if number of vertices to process >= 0 femms ; no more MMX code; clear MMX/FPU state -strip_done: +.strip_done: ;;; } ;;; #undef FN_NAME ;;; } /* _grDrawVertexList */ @@ -2157,37 +2124,33 @@ strip_done: pop esi ; restore caller's register variable pop edi ; restore caller's register variable - ret 20 ; return, pop 5 DWORD parameters off stack + ret ; return, pop 5 DWORD parameters off stack -__grDrawVertexList_3DNow_Clip@20 ENDP +endp -_TEXT ENDS ;;-------------------------------------------------------------------------- ;; end AMD3D version ;;-------------------------------------------------------------------------- -endif ; GL_AMD3D +%endif ; GL_AMD3D ;;-------------------------------------------------------------------------- ;; start original code ;;-------------------------------------------------------------------------- -ifndef GL_AMD3D +%ifndef GL_AMD3D -TITLE xdraw3.asm -.586P ;;; include listing.inc -INCLUDE fxgasm.h +%INCLUDE "fxgasm.h" -CONST SEGMENT -_F1 DD 03f800000r ; 1 -_F256 DD 043800000r ; 256 +segment CONST +_F1 DD 1.0 +_F256 DD 256.0 -_VPF1 DD 03f800000r ; 1 -_VPF256 DD 043800000r ; 256 -CONST ENDS +_VPF1 DD 1.0 +_VPF256 DD 256.0 -_DATA SEGMENT +segment DATA vSize DD 0 ccoow DD 0 packetVal DD 0 @@ -2198,36 +2161,33 @@ oowa DD 0 vPtr0 DD 0 vPtr1 DD 0 vPtr2 DD 0 -_DATA ENDS -_TEXT SEGMENT PAGE PUBLIC USE32 'CODE' - ASSUME DS: FLAT, SS: FLAT +segment TEXT -_pktype = 20 -_type = 24 -_mode = 28 -_count = 32 -_pointers = 36 +_pktype equ 20 +_type equ 24 +_mode equ 28 +_count equ 32 +_pointers equ 36 -gc TEXTEQU ; points to graphics context -fifo TEXTEQU ; points to next entry in fifo -dlp TEXTEQU ; points to dataList structure -vertexCount TEXTEQU ; Current vertex counter in the packet -vertexPtr TEXTEQU ; Current vertex pointer +%define gc esi ; points to graphics context +%define fifo ecx ; points to next entry in fifo +%define dlp ebp ; points to dataList structure +%define vertexCount ebx ; Current vertex counter in the packet +%define vertexPtr edi ; Current vertex pointer ALIGN 32 - PUBLIC __drawvertexlist@20 -__drawvertexlist@20 PROC NEAR +proc _drawvertexlist, 20 ; 132 : { - mov eax, DWORD PTR fs:[18h]; get thread local storage base pointer + SET_TLSBASE eax ; get thread local storage base pointer push esi - mov esi, [__GlideRoot + tlsOffset]; GC position relative to tls base + SET_TLSOFFSET esi ; GC position relative to tls base push edi - mov gc, DWORD PTR [eax + esi] + GET_GC eax, esi push ebx ;;; GR_DCL_GC @@ -2235,23 +2195,23 @@ __drawvertexlist@20 PROC NEAR ;;; if (stride == 0) ;;; stride = gc->state.vData.vStride; push ebp - mov ecx, DWORD PTR [gc+vertexSize] + mov ecx, DWORD [gc+vertexSize] - mov edx, DWORD PTR [esp+_mode] - mov vertexCount, DWORD PTR [esp+_count] + mov edx, DWORD [esp+_mode] + mov vertexCount, DWORD [esp+_count] - mov vertexPtr, DWORD PTR [esp+_pointers] - mov DWORD PTR vSize, ecx + mov vertexPtr, DWORD [esp+_pointers] + mov DWORD [vSize], ecx shl edx, 2 -;;; mov ecx, DWORD PTR [gc+CoordinateSpace] +;;; mov ecx, DWORD [gc+CoordinateSpace] test edx, edx - jne SHORT no_stride - mov edx, DWORD PTR [gc+vertexStride] + jne .no_stride + mov edx, DWORD [gc+vertexStride] shl edx, 2 align 4 -no_stride: +.no_stride: ;;; Draw the first (or possibly only) set. This is necessary because ;;; the packet is 3_BDDDDDD, and in the next set, the packet is 3_DDDDDD @@ -2261,58 +2221,55 @@ no_stride: ;;; if (gc->state.grCoordinateSpaceArgs.coordinate_space_mode == GR_WINDOW_COORDS) { ;;; test ecx, ecx - mov DWORD PTR strideinbytes, edx + mov DWORD [strideinbytes], edx ;;; while (count > 0) { ;;; FxI32 k, vcount = count >= 15 ? 15 : count; ;;; GR_SET_EXPECTED_SIZE(vcount * vSize, 1); ;;; TRI_STRIP_BEGIN(type, vcount, vSize, pktype); - mov eax, DWORD PTR [esp+_count] + mov eax, DWORD [esp+_count] ;;; jne clip_coordinates test eax, eax - jle strip_done + jle .strip_done align 4 -window_coords_begin: +.window_coords_begin: cmp vertexCount, 15 ; 0000000fH - jl SHORT win_partial_packet + jl .win_partial_packet mov vertexCount, 15 ; 0000000fH align 4 -win_partial_packet: +.win_partial_packet: - mov eax, DWORD PTR vSize - mov ecx, DWORD PTR [gc+fifoRoom] + mov eax, DWORD [vSize] + mov ecx, DWORD [gc+fifoRoom] imul eax, vertexCount add eax, 4 cmp ecx, eax - jge SHORT win_strip_begin - push @Line - push 0h - push eax - call __grCommandTransportMakeRoom@12 + jge .win_strip_begin + invoke _grCommandTransportMakeRoom, eax, 0, __LINE__ align 4 -win_strip_begin: +.win_strip_begin: ;;; Setup pacet header ;;; - mov fifo, DWORD PTR [gc+fifoPtr] + mov fifo, DWORD [gc+fifoPtr] mov eax, vertexCount - mov edx, DWORD PTR [esp+_type] - mov ebp, DWORD PTR [gc+cullStripHdr] + mov edx, DWORD [esp+_type] + mov ebp, DWORD [gc+cullStripHdr] shl edx, 22 ; 00000010H add fifo, 4 shl eax, 6 or ebp, edx or eax, ebp - mov edx, DWORD PTR [esp+_pktype] + mov edx, DWORD [esp+_pktype] or eax, edx nop - mov DWORD PTR [fifo-4], eax + mov DWORD [fifo-4], eax ;;; for (k = 0; k < vcount; k++) { ;;; FxI32 i; @@ -2328,31 +2285,31 @@ win_strip_begin: ;;; i = gc->tsuDataList[dataElem]; align 4 -win_for_begin: +.win_for_begin: mov edx, vertexPtr - mov eax, DWORD PTR strideinbytes + mov eax, DWORD [strideinbytes] cmp eax, 4 - jne SHORT win_no_deref - mov edx, DWORD PTR [vertexPtr] + jne .win_no_deref + mov edx, DWORD [vertexPtr] align 4 -win_no_deref: +.win_no_deref: add fifo, 8 add vertexPtr, eax - mov eax, DWORD PTR [edx] - mov ebp, DWORD PTR [edx+4] + mov eax, DWORD [edx] + mov ebp, DWORD [edx+4] - mov DWORD PTR [fifo-8], eax - mov eax, DWORD PTR [gc+tsuDataList] + mov DWORD [fifo-8], eax + mov eax, DWORD [gc+tsuDataList] - mov DWORD PTR [fifo-4], ebp + mov DWORD [fifo-4], ebp test eax, eax - lea dlp, DWORD PTR [gc+tsuDataList] - je SHORT win_datalist_end + lea dlp, [gc+tsuDataList] + je .win_datalist_end align 4 @@ -2362,25 +2319,25 @@ win_no_deref: ;;; i = gc->tsuDataList[dataElem]; ;;; } -win_datalist_begin: +.win_datalist_begin: add fifo, 4 add dlp, 4 - mov eax, DWORD PTR [edx+eax] + mov eax, DWORD [edx+eax] nop - mov DWORD PTR [fifo-4], eax - mov eax, DWORD PTR [dlp] + mov DWORD [fifo-4], eax + mov eax, DWORD [dlp] test eax, eax - jne SHORT win_datalist_begin -win_datalist_end: + jne .win_datalist_begin +.win_datalist_end: dec vertexCount - jne SHORT win_for_begin -win_for_end: + jne .win_for_begin +.win_for_end: ;;; TRI_END; ;;; Prepare for the next packet (if the strip size is longer than 15) @@ -2389,487 +2346,477 @@ win_for_end: ;;; pktype = SSTCP_PKT3_DDDDDD; ;;; } - mov eax, DWORD PTR [gc+fifoPtr] - mov edx, DWORD PTR [gc+fifoRoom] + mov eax, DWORD [gc+fifoPtr] + mov edx, DWORD [gc+fifoRoom] sub eax, fifo - mov vertexCount, DWORD PTR [esp+_count] + mov vertexCount, DWORD [esp+_count] add edx, eax sub vertexCount, 15 ; 0000000fH - mov DWORD PTR [gc+fifoRoom], edx - mov DWORD PTR [esp+_count], vertexCount + mov DWORD [gc+fifoRoom], edx + mov DWORD [esp+_count], vertexCount - mov DWORD PTR [gc+fifoPtr], fifo + mov DWORD [gc+fifoPtr], fifo test vertexCount, vertexCount - mov DWORD PTR [esp+_pktype], 16 ; 00000010H - jg window_coords_begin + mov DWORD [esp+_pktype], 16 ; 00000010H + jg .window_coords_begin -strip_done: +.strip_done: pop ebp pop ebx pop edi pop esi - ret 20 ; 00000014H + ret ; 00000014H -__drawvertexlist@20 ENDP +endp -_pktype = 20 -_type = 24 -_mode = 28 -_count = 32 -_pointers = 36 - -gc TEXTEQU ; points to graphics context -fifo TEXTEQU ; points to next entry in fifo -vertexPtr TEXTEQU ; pointer to vertex or vertex array +%define gc esi ; points to graphics context +%define fifo ecx ; points to next entry in fifo +%define vertexPtr edx ; pointer to vertex or vertex array ALIGN 32 - PUBLIC __vpdrawvertexlist@20 -__vpdrawvertexlist@20 PROC NEAR +proc _vpdrawvertexlist, 20 - mov eax, DWORD PTR fs: [18h] ; tls base pointer + SET_TLSBASE eax ; tls base pointer push esi - mov esi, [__GlideRoot + tlsOffset]; gc position relative to tls base + SET_TLSOFFSET esi ; gc position relative to tls base push edi push ebx - mov gc, [eax + esi] - + GET_GC eax, esi + push ebp - mov ecx, DWORD PTR [esp+_mode] + mov ecx, DWORD [esp+_mode] - mov edi, DWORD PTR [esp+_pointers] - mov eax, DWORD PTR [gc+wInfo_offset] + mov edi, DWORD [esp+_pointers] + mov eax, DWORD [gc+wInfo_offset] test ecx, ecx - je w_no_dref + je .w_no_dref - mov edi, DWORD PTR [edi] + mov edi, DWORD [edi] align 4 -w_no_dref: +.w_no_dref: ;;; load first w - fld DWORD PTR [edi+eax] - fdivr DWORD PTR _F1 + fld DWORD [edi+eax] + fdivr DWORD [_F1] - mov ecx, DWORD PTR [gc+vertexSize] - mov edx, DWORD PTR [esp+_mode] + mov ecx, DWORD [gc+vertexSize] + mov edx, DWORD [esp+_mode] - mov edi, DWORD PTR [esp+_count] -;;; mov vertexArray, DWORD PTR [esp+_pointers] + mov edi, DWORD [esp+_count] +;;; mov vertexArray, DWORD [esp+_pointers] shl edx, 2 - mov DWORD PTR vSize, ecx + mov DWORD [vSize], ecx test edx, edx - jne SHORT no_stride + jne .no_stride - mov edx, DWORD PTR [gc+vertexStride] + mov edx, DWORD [gc+vertexStride] shl edx, 2 align 4 -no_stride: +.no_stride: - mov DWORD PTR strideinbytes, edx - mov eax, DWORD PTR [esp+_type] + mov DWORD [strideinbytes], edx + mov eax, DWORD [esp+_type] shl eax, 16 ; 00000010H - mov DWORD PTR packetVal, eax + mov DWORD [packetVal], eax -clip_coords_begin: +.clip_coords_begin: cmp edi, 15 - jl SHORT clip_partial_packet + jl .clip_partial_packet mov edi, 15 -clip_partial_packet: +.clip_partial_packet: ;;; GR_SET_EXPECTED_SIZE(vcount * vSize, 1) - mov eax, DWORD PTR vSize - mov ecx, DWORD PTR [gc+fifoRoom] + mov eax, DWORD [vSize] + mov ecx, DWORD [gc+fifoRoom] imul eax, edi add eax, 4 cmp ecx, eax - jge SHORT clip_strip_begin - push @Line - push 0h - push eax - call __grCommandTransportMakeRoom@12 + jge .clip_strip_begin + invoke _grCommandTransportMakeRoom, eax, 0, __LINE__ align 4 -clip_strip_begin: +.clip_strip_begin: ;;; TRI_STRIP_BEGIN(type, vcount, vSize, pktype) - mov fifo, DWORD PTR [gc+fifoPtr] + mov fifo, DWORD [gc+fifoPtr] mov eax, edi - mov edx, DWORD PTR packetVal - mov ebp, DWORD PTR [gc+cullStripHdr] + mov edx, DWORD [packetVal] + mov ebp, DWORD [gc+cullStripHdr] or eax, edx add fifo, 4 shl eax, 6 - mov edx, DWORD PTR [esp+_pktype] + mov edx, DWORD [esp+_pktype] or eax, ebp or eax, edx - mov DWORD PTR [fifo-4], eax + mov DWORD [fifo-4], eax - mov vertexPtr, DWORD PTR [esp+_pointers] - mov eax, DWORD PTR [esp+_mode] + mov vertexPtr, DWORD [esp+_pointers] + mov eax, DWORD [esp+_mode] test eax, eax - je SHORT clip_for_begin - mov vertexPtr, DWORD PTR [vertexPtr] + je .clip_for_begin + mov vertexPtr, DWORD [vertexPtr] align 4 -clip_for_begin: +.clip_for_begin: add fifo, 8 - mov ebp, DWORD PTR strideinbytes + mov ebp, DWORD [strideinbytes] - add DWORD PTR [esp+_pointers], ebp - mov eax, DWORD PTR [gc+paramIndex] + add DWORD [esp+_pointers], ebp + mov eax, DWORD [gc+paramIndex] xor ebp, ebp - mov ebx, DWORD PTR [gc+tsuDataList] + mov ebx, DWORD [gc+tsuDataList] ;;; ; setup x and y - fld DWORD PTR [gc+vp_hwidth] - fmul DWORD PTR [vertexPtr] - fmul st, st(1) - fadd DWORD PTR [gc+vp_ox] - fxch st(1) + fld DWORD [gc+vp_hwidth] + fmul DWORD [vertexPtr] + fmul st0, st1 + fadd DWORD [gc+vp_ox] + fxch st1 - fld DWORD PTR [gc+vp_hheight] - fmul DWORD PTR [vertexPtr+4] + fld DWORD [gc+vp_hheight] + fmul DWORD [vertexPtr+4] test al, 3 - fmul st, st(1) - fadd DWORD PTR [gc+vp_oy] - fxch st(1) - fstp DWORD PTR ccoow - fxch st(1) - fstp DWORD PTR [fifo-8] - fstp DWORD PTR [fifo-4] + fmul st0, st1 + fadd DWORD [gc+vp_oy] + fxch st1 + fstp DWORD [ccoow] + fxch st1 + fstp DWORD [fifo-8] + fstp DWORD [fifo-4] ;;; ; set up color - je clip_setup_ooz + je .clip_setup_ooz - cmp DWORD PTR [gc+colorType], ebp - jne SHORT clip_setup_pargb + cmp DWORD [gc+colorType], ebp + jne .clip_setup_pargb test al, 1 - je SHORT clip_setup_a + je .clip_setup_a add fifo, 12 mov ebp, 3 - fld DWORD PTR __GlideRoot+pool_f255 - fmul DWORD PTR [ebx+vertexPtr] - fld DWORD PTR __GlideRoot+pool_f255 - fmul DWORD PTR [ebx+vertexPtr+4] - fld DWORD PTR __GlideRoot+pool_f255 - fmul DWORD PTR [ebx+vertexPtr+8] - fxch st(2) - fstp DWORD PTR [fifo-12] - fstp DWORD PTR [fifo-8] - fstp DWORD PTR [fifo-4] - mov ebx, DWORD PTR [gc+tsuDataList+12] + fld DWORD [_GlideRoot+pool_f255] + fmul DWORD [ebx+vertexPtr] + fld DWORD [_GlideRoot+pool_f255] + fmul DWORD [ebx+vertexPtr+4] + fld DWORD [_GlideRoot+pool_f255] + fmul DWORD [ebx+vertexPtr+8] + fxch st2 + fstp DWORD [fifo-12] + fstp DWORD [fifo-8] + fstp DWORD [fifo-4] + mov ebx, DWORD [gc+tsuDataList+12] align 4 -clip_setup_a: +.clip_setup_a: test al, 2 - je SHORT clip_setup_ooz + je .clip_setup_ooz add fifo, 4 inc ebp - fld DWORD PTR [ebx+vertexPtr] - fmul DWORD PTR __GlideRoot+pool_f255 - fstp DWORD PTR [fifo-4] + fld DWORD [ebx+vertexPtr] + fmul DWORD [_GlideRoot+pool_f255] + fstp DWORD [fifo-4] - mov ebx, DWORD PTR [gc+ebp*4+tsuDataList] - jmp SHORT clip_setup_ooz + mov ebx, DWORD [gc+ebp*4+tsuDataList] + jmp .clip_setup_ooz align 4 -clip_setup_pargb: +.clip_setup_pargb: add fifo, 4 - mov ebx, DWORD PTR [ebx+vertexPtr] + mov ebx, DWORD [ebx+vertexPtr] - mov DWORD PTR [fifo-4], ebx + mov DWORD [fifo-4], ebx nop mov ebp, 1 - mov ebx, DWORD PTR [gc+tsuDataList+4] + mov ebx, DWORD [gc+tsuDataList+4] align 4 -clip_setup_ooz: +.clip_setup_ooz: test al, 4 - je SHORT clip_setup_qow + je .clip_setup_qow add fifo, 4 inc ebp - test DWORD PTR [gc+fbi_fbzMode], 200000h - je clip_setup_ooz_nofog + test DWORD [gc+fbi_fbzMode], 200000h + je .clip_setup_ooz_nofog - mov ebx, DWORD PTR [gc+qInfo_mode] + mov ebx, DWORD [gc+qInfo_mode] test ebx, ebx - je SHORT clip_setup_fog_oow - mov ebx, DWORD PTR [gc+qInfo_offset] + je .clip_setup_fog_oow + mov ebx, DWORD [gc+qInfo_offset] - fld DWORD PTR [vertexPtr+ebx] - fmul DWORD PTR ccoow - fstp DWORD PTR [fifo-4] + fld DWORD [vertexPtr+ebx] + fmul DWORD [ccoow] + fstp DWORD [fifo-4] - mov ebx, DWORD PTR [gc+ebp*4+tsuDataList] - jmp clip_setup_qow + mov ebx, DWORD [gc+ebp*4+tsuDataList] + jmp .clip_setup_qow align 4 -clip_setup_fog_oow: - mov ebx, DWORD PTR ccoow +.clip_setup_fog_oow: + mov ebx, dword [ccoow] - mov DWORD PTR [fifo-4], ebx - mov ebx, DWORD PTR [gc+ebp*4+tsuDataList] - jmp clip_setup_qow + mov dword [fifo-4], ebx + mov ebx, DWORD [gc+ebp*4+tsuDataList] + jmp .clip_setup_qow align 4 -clip_setup_ooz_nofog: +.clip_setup_ooz_nofog: - fld DWORD PTR [ebx+vertexPtr] - fmul DWORD PTR [gc+vp_hdepth] - fmul DWORD PTR ccoow - fadd DWORD PTR [gc+vp_oz] - fstp DWORD PTR [fifo-4] + fld DWORD [ebx+vertexPtr] + fmul DWORD [gc+vp_hdepth] + fmul DWORD [ccoow] + fadd DWORD [gc+vp_oz] + fstp DWORD [fifo-4] - mov ebx, DWORD PTR [gc+ebp*4+tsuDataList] + mov ebx, DWORD [gc+ebp*4+tsuDataList] align 4 -clip_setup_qow: +.clip_setup_qow: test al, 8 - je SHORT clip_setup_qow0 + je .clip_setup_qow0 - mov ebx, DWORD PTR [gc+fogInfo_mode] + mov ebx, DWORD [gc+fogInfo_mode] test ebx, ebx - je SHORT clip_setup_oow_nofog - mov ebx, DWORD PTR [gc+fogInfo_offset] + je .clip_setup_oow_nofog + mov ebx, DWORD [gc+fogInfo_offset] - fld DWORD PTR [vertexPtr+ebx] - fmul DWORD PTR ccoow - fstp DWORD PTR [fifo] + fld DWORD [vertexPtr+ebx] + fmul DWORD [ccoow] + fstp DWORD [fifo] - jmp SHORT clip_setup_oow_inc + jmp .clip_setup_oow_inc align 4 -clip_setup_oow_nofog: +.clip_setup_oow_nofog: - mov ebx, DWORD PTR [gc+qInfo_mode] + mov ebx, DWORD [gc+qInfo_mode] test ebx, ebx - je SHORT clip_setup_oow - mov ebx, DWORD PTR [gc+qInfo_offset] + je .clip_setup_oow + mov ebx, DWORD [gc+qInfo_offset] - fld DWORD PTR [vertexPtr+ebx] - fmul DWORD PTR ccoow - fstp DWORD PTR [fifo] + fld DWORD [vertexPtr+ebx] + fmul DWORD [ccoow] + fstp DWORD [fifo] - jmp SHORT clip_setup_oow_inc + jmp .clip_setup_oow_inc align 4 -clip_setup_oow: - mov ebx, DWORD PTR ccoow +.clip_setup_oow: + mov ebx, DWORD [ccoow] - mov DWORD PTR [fifo], ebx + mov DWORD [fifo], ebx align 4 -clip_setup_oow_inc: +.clip_setup_oow_inc: - mov ebx, DWORD PTR [gc+ebp*4+tsuDataList+4] + mov ebx, DWORD [gc+ebp*4+tsuDataList+4] add fifo, 4 inc ebp align 4 -clip_setup_qow0: +.clip_setup_qow0: test al, 16 - je SHORT clip_setup_stow0 + je .clip_setup_stow0 - mov ebx, DWORD PTR [gc+q0Info_mode] + mov ebx, DWORD [gc+q0Info_mode] cmp ebx, 1 - jne SHORT clip_setup_oow0 + jne .clip_setup_oow0 - mov ebx, DWORD PTR [gc+q0Info_offset] + mov ebx, DWORD [gc+q0Info_offset] - fld DWORD PTR [ebx+vertexPtr] - fmul DWORD PTR ccoow - fstp DWORD PTR [fifo] + fld DWORD [ebx+vertexPtr] + fmul DWORD [ccoow] + fstp DWORD [fifo] - jmp SHORT clip_setup_oow0_inc + jmp .clip_setup_oow0_inc align 4 -clip_setup_oow0: - mov ebx, DWORD PTR ccoow +.clip_setup_oow0: + mov ebx, DWORD [ccoow] - mov DWORD PTR [fifo], ebx + mov DWORD [fifo], ebx align 4 -clip_setup_oow0_inc: - mov ebx, DWORD PTR [gc+ebp*4+tsuDataList+4] +.clip_setup_oow0_inc: + mov ebx, DWORD [gc+ebp*4+tsuDataList+4] add fifo, 4 inc ebp align 4 -clip_setup_stow0: +.clip_setup_stow0: test al, 32 - je SHORT clip_setup_qow1 + je .clip_setup_qow1 - fld DWORD PTR ccoow - fmul DWORD PTR [ebx+vertexPtr] + fld DWORD [ccoow] + fmul DWORD [ebx+vertexPtr] add fifo, 8 add ebp, 2 - fmul DWORD PTR [gc+tmu0_s_scale] - fld DWORD PTR ccoow - fmul DWORD PTR [ebx+vertexPtr+4] - mov ebx, DWORD PTR [gc+ebp*4+tsuDataList] - fmul DWORD PTR [gc+tmu0_t_scale] + fmul DWORD [gc+tmu0_s_scale] + fld DWORD [ccoow] + fmul DWORD [ebx+vertexPtr+4] + mov ebx, DWORD [gc+ebp*4+tsuDataList] + fmul DWORD [gc+tmu0_t_scale] fxch - fstp DWORD PTR [fifo-8] - fstp DWORD PTR [fifo-4] + fstp DWORD [fifo-8] + fstp DWORD [fifo-4] align 4 -clip_setup_qow1: +.clip_setup_qow1: test al, 64 - je SHORT clip_setup_stow1 + je .clip_setup_stow1 - mov ebx, DWORD PTR [gc+q1Info_mode] + mov ebx, DWORD [gc+q1Info_mode] cmp ebx, 1 - jne SHORT clip_setup_oow1 + jne .clip_setup_oow1 - mov ebx, DWORD PTR [gc+q1Info_offset] + mov ebx, DWORD [gc+q1Info_offset] - fld DWORD PTR [ebx+vertexPtr] - fmul DWORD PTR ccoow - fstp DWORD PTR [fifo] + fld DWORD [ebx+vertexPtr] + fmul DWORD [ccoow] + fstp DWORD [fifo] - jmp SHORT clip_setup_oow1_inc + jmp .clip_setup_oow1_inc align 4 -clip_setup_oow1: - mov ebx, DWORD PTR ccoow +.clip_setup_oow1: + mov ebx, DWORD [ccoow] - mov DWORD PTR [fifo], ebx + mov DWORD [fifo], ebx align 4 -clip_setup_oow1_inc: +.clip_setup_oow1_inc: - mov ebx, DWORD PTR [gc+ebp*4+tsuDataList+4] + mov ebx, DWORD [gc+ebp*4+tsuDataList+4] add fifo, 4 inc ebp align 4 -clip_setup_stow1: +.clip_setup_stow1: test al, 128 - je SHORT clip_setup_end + je .clip_setup_end - fld DWORD PTR ccoow - fmul DWORD PTR [ebx+vertexPtr] + fld DWORD [ccoow] + fmul DWORD [ebx+vertexPtr] add fifo, 8 - fmul DWORD PTR [gc+tmu1_s_scale] - fld DWORD PTR ccoow - fmul DWORD PTR [ebx+vertexPtr+4] - mov ebx, DWORD PTR [gc+ebp*4+tsuDataList+4] - fmul DWORD PTR [gc+tmu1_t_scale] + fmul DWORD [gc+tmu1_s_scale] + fld DWORD [ccoow] + fmul DWORD [ebx+vertexPtr+4] + mov ebx, DWORD [gc+ebp*4+tsuDataList+4] + fmul DWORD [gc+tmu1_t_scale] fxch - fstp DWORD PTR [fifo-8] - fstp DWORD PTR [fifo-4] + fstp DWORD [fifo-8] + fstp DWORD [fifo-4] align 4 -clip_setup_end: +.clip_setup_end: dec edi - jz clip_for_end + jz .clip_for_end - mov vertexPtr, DWORD PTR [esp+_pointers] - mov ebx, DWORD PTR [esp+_mode] + mov vertexPtr, DWORD [esp+_pointers] + mov ebx, DWORD [esp+_mode] test ebx, ebx - je SHORT w_clip_no_deref + je .w_clip_no_deref - mov vertexPtr, DWORD PTR [vertexPtr] + mov vertexPtr, DWORD [vertexPtr] align 4 -w_clip_no_deref: +.w_clip_no_deref: - mov ebx, DWORD PTR [gc+wInfo_offset] + mov ebx, DWORD [gc+wInfo_offset] - fld DWORD PTR [ebx+vertexPtr] - fdivr DWORD PTR _F1 + fld DWORD [ebx+vertexPtr] + fdivr DWORD [_F1] - jmp clip_for_begin + jmp .clip_for_begin align 4 -clip_for_end: +.clip_for_end: - mov ebx, DWORD PTR [gc+fifoPtr] - mov edx, DWORD PTR [gc+fifoRoom] + mov ebx, DWORD [gc+fifoPtr] + mov edx, DWORD [gc+fifoRoom] sub ebx, fifo - mov edi, DWORD PTR [esp+_count] + mov edi, DWORD [esp+_count] add edx, ebx sub edi, 15 ; 0000000fH - mov DWORD PTR [gc+fifoRoom], edx - mov DWORD PTR [esp+_count], edi + mov DWORD [gc+fifoRoom], edx + mov DWORD [esp+_count], edi - mov DWORD PTR [gc+fifoPtr], fifo - mov DWORD PTR [esp+_pktype], 16 ; 00000010H + mov DWORD [gc+fifoPtr], fifo + mov DWORD [esp+_pktype], 16 ; 00000010H - jle strip_done - mov edx, DWORD PTR [esp+_pointers] + jle .strip_done + mov edx, DWORD [esp+_pointers] - mov ebx, DWORD PTR [esp+_mode] + mov ebx, DWORD [esp+_mode] test ebx, ebx - je SHORT w1_clip_no_deref - mov edx, DWORD PTR [edx] + je .w1_clip_no_deref + mov edx, DWORD [edx] align 4 -w1_clip_no_deref: +.w1_clip_no_deref: - mov ebx, DWORD PTR [gc+wInfo_offset] - fld DWORD PTR [ebx+edx] - fdivr DWORD PTR _F1 + mov ebx, DWORD [gc+wInfo_offset] + fld DWORD [ebx+edx] + fdivr DWORD [_F1] - jmp clip_coords_begin + jmp .clip_coords_begin align 4 -strip_done: +.strip_done: pop ebp pop ebx pop edi pop esi - ret 20 ; 00000014H -__vpdrawvertexlist@20 ENDP + ret ; 00000014H +endp -gc TEXTEQU ; points to graphics context -fifo TEXTEQU ; points to next entry in fifo -vertexPtr TEXTEQU ; Current vertex pointer +%define gc esi ; points to graphics context +%define fifo ecx ; points to next entry in fifo +%define vertexPtr edi ; Current vertex pointer ;; NB: All of the base triangle procs expect to have the gc ;; passed from the caller in edx so that we can avoid @@ -2880,353 +2827,362 @@ vertexPtr TEXTEQU ; Current vertex pointer ALIGN 32 - PUBLIC __vptrisetup_cull@12 -__vptrisetup_cull@12 PROC NEAR -_va = 20 -_vb = 24 -_vc = 28 +proc _vptrisetup_cull, 12 +_va equ 20 +_vb equ 24 +_vc equ 28 push ebx push esi push edi mov gc, edx + +%if 1 + ; + ; AJB: Clip Coord mode needs to call grValidateState + ; + mov edx, [gc + invalid] ; state needs validation ? + + test edx, edx ; do we need to validate state ? + je .no_validation ; nope, it's valid + + invoke _grValidateState ; validate state + +.no_validation: +%endif - mov ecx, DWORD PTR [esp+_va-4] - mov eax, DWORD PTR [gc+wInfo_offset] + mov ecx, DWORD [esp+_va-4] + mov eax, DWORD [gc+wInfo_offset] push ebp nop ;;; ; oow[0] = 1.0f / FARRAY(va, gc->state.vData.wInfo.offset) - fld DWORD PTR [eax+ecx] + fld DWORD [eax+ecx] - fdivr DWORD PTR _F1 + fdivr DWORD [_F1] - mov ecx, DWORD PTR [esp+_vb] - mov ebx, DWORD PTR [esp+_vc] + mov ecx, DWORD [esp+_vb] + mov ebx, DWORD [esp+_vc] nop nop - mov ebp, DWORD PTR [eax+ecx] - mov edi, DWORD PTR [eax+ebx] + mov ebp, DWORD [eax+ecx] + mov edi, DWORD [eax+ebx] - mov DWORD PTR vPtr1, ebp - mov DWORD PTR vPtr2, edi + mov DWORD [vPtr1], ebp + mov DWORD [vPtr2], edi ;;; ; GR_SET_EXPECTED_SIZE(_GlideRoot.curTriSize, 1) - mov eax, DWORD PTR __GlideRoot+curTriSize - mov ecx, DWORD PTR [gc+fifoRoom] + mov eax, DWORD [gc+curTriSize] + mov ecx, DWORD [gc+fifoRoom] add eax, 4 nop cmp ecx, eax - jge SHORT setup_pkt_hdr + jge .setup_pkt_hdr - push @Line ; line number inside this function - push 0h ; pointer to function name = NULL - - push eax - call __grCommandTransportMakeRoom@12 + invoke _grCommandTransportMakeRoom, eax, 0, __LINE__ align 4 -setup_pkt_hdr: +.setup_pkt_hdr: ;;; ; TRI_STRIP_BEGIN(kSetupStrip, 3, gc->state.vData.vSize, SSTCP_PKT3_BDDBDD) - mov fifo, DWORD PTR [gc+fifoPtr] - mov eax, DWORD PTR [gc+cullStripHdr] + mov fifo, DWORD [gc+fifoPtr] + mov eax, DWORD [gc+cullStripHdr] add fifo, 4 - lea ebp, DWORD PTR [esp+_va] + lea ebp, [esp+_va] or eax, 192 ; 000000c0H mov edx, 0 - mov DWORD PTR [fifo-4], eax - mov vertexPtr, DWORD PTR [ebp] + mov DWORD [fifo-4], eax + mov vertexPtr, DWORD [ebp] - mov eax, DWORD PTR [gc+paramIndex] + mov eax, DWORD [gc+paramIndex] nop ;;; Begin loop align 4 -begin_for_loop: +.begin_for_loop: add edx, 4 add fifo, 8 xor ebx, ebx - mov ebp, DWORD PTR [gc+tsuDataList] + mov ebp, DWORD [gc+tsuDataList] ;;; ; setup x and y - fld DWORD PTR [gc+vp_hwidth] - fmul DWORD PTR [vertexPtr] - fmul st, st(1) - fadd DWORD PTR [gc+vp_ox] - fxch st(1) + fld DWORD [gc+vp_hwidth] + fmul DWORD [vertexPtr] + fmul st0, st1 + fadd DWORD [gc+vp_ox] + fxch st1 - fld DWORD PTR [vertexPtr+4] - fmul DWORD PTR [gc+vp_hheight] + fld DWORD [vertexPtr+4] + fmul DWORD [gc+vp_hheight] test al, 3 - fmul st, st(1) - fadd DWORD PTR [gc+vp_oy] - fxch st(1) - fstp DWORD PTR oowa - fxch st(1) - fstp DWORD PTR [fifo-8] - fstp DWORD PTR [fifo-4] + fmul st0, st1 + fadd DWORD [gc+vp_oy] + fxch st1 + fstp DWORD [oowa] + fxch st1 + fstp DWORD [fifo-8] + fstp DWORD [fifo-4] ;;; ; set up color - je clip_setup_ooz + je .clip_setup_ooz - cmp DWORD PTR [gc+colorType], ebx - jne SHORT clip_setup_pargb + cmp DWORD [gc+colorType], ebx + jne .clip_setup_pargb test al, 1 - je SHORT clip_setup_a + je .clip_setup_a add fifo, 12 add ebx, 3 - fld DWORD PTR __GlideRoot+pool_f255 - fmul DWORD PTR [vertexPtr+ebp] - fld DWORD PTR __GlideRoot+pool_f255 - fmul DWORD PTR [vertexPtr+ebp+4] - fld DWORD PTR __GlideRoot+pool_f255 - fmul DWORD PTR [vertexPtr+ebp+8] - fxch st(2) - fstp DWORD PTR [fifo-12] - fstp DWORD PTR [fifo-8] - fstp DWORD PTR [fifo-4] - mov ebp, DWORD PTR [gc+tsuDataList+12] + fld DWORD [_GlideRoot+pool_f255] + fmul DWORD [vertexPtr+ebp] + fld DWORD [_GlideRoot+pool_f255] + fmul DWORD [vertexPtr+ebp+4] + fld DWORD [_GlideRoot+pool_f255] + fmul DWORD [vertexPtr+ebp+8] + fxch st2 + fstp DWORD [fifo-12] + fstp DWORD [fifo-8] + fstp DWORD [fifo-4] + mov ebp, DWORD [gc+tsuDataList+12] align 4 -clip_setup_a: +.clip_setup_a: test al, 2 - je SHORT clip_setup_ooz + je .clip_setup_ooz add fifo, 4 inc ebx - fld DWORD PTR [vertexPtr+ebp] - fmul DWORD PTR __GlideRoot+pool_f255 - fstp DWORD PTR [fifo-4] + fld DWORD [vertexPtr+ebp] + fmul DWORD [_GlideRoot+pool_f255] + fstp DWORD [fifo-4] - mov ebp, DWORD PTR [gc+tsuDataList+ebx*4] - jmp SHORT clip_setup_ooz + mov ebp, DWORD [gc+tsuDataList+ebx*4] + jmp .clip_setup_ooz align 4 -clip_setup_pargb: +.clip_setup_pargb: add fifo, 4 - mov ebx, DWORD PTR [vertexPtr+ebp] + mov ebx, DWORD [vertexPtr+ebp] - mov DWORD PTR [fifo-4], ebx + mov DWORD [fifo-4], ebx nop mov ebx, 1 - mov ebp, DWORD PTR [gc+tsuDataList+4] + mov ebp, DWORD [gc+tsuDataList+4] align 4 -clip_setup_ooz: +.clip_setup_ooz: test al, 4 - je SHORT clip_setup_qow + je .clip_setup_qow add fifo, 4 inc ebx - test DWORD PTR [gc+fbi_fbzMode], 200000h - je clip_setup_ooz_nofog + test DWORD [gc+fbi_fbzMode], 200000h + je .clip_setup_ooz_nofog - mov ebp, DWORD PTR [gc+qInfo_mode] + mov ebp, DWORD [gc+qInfo_mode] test ebp, ebp - je SHORT clip_setup_fog_oow - mov ebp, DWORD PTR [gc+qInfo_offset] + je .clip_setup_fog_oow + mov ebp, DWORD [gc+qInfo_offset] - fld DWORD PTR [vertexPtr+ebp] - fmul DWORD PTR oowa - fstp DWORD PTR [fifo-4] + fld DWORD [vertexPtr+ebp] + fmul DWORD [oowa] + fstp DWORD [fifo-4] - mov ebp, DWORD PTR [gc+tsuDataList+ebx*4] - jmp clip_setup_qow + mov ebp, DWORD [gc+tsuDataList+ebx*4] + jmp .clip_setup_qow align 4 -clip_setup_fog_oow: - mov ebp, DWORD PTR oowa +.clip_setup_fog_oow: + mov ebp, dword [oowa] - mov DWORD PTR [fifo-4], ebp - mov ebp, DWORD PTR [gc+tsuDataList+ebx*4] - jmp clip_setup_qow + mov dword [fifo-4], ebp + mov ebp, DWORD [gc+tsuDataList+ebx*4] + jmp .clip_setup_qow align 4 -clip_setup_ooz_nofog: +.clip_setup_ooz_nofog: - fld DWORD PTR [vertexPtr+ebp] - fmul DWORD PTR [gc+vp_hdepth] - fmul DWORD PTR oowa - fadd DWORD PTR [gc+vp_oz] - fstp DWORD PTR [fifo-4] + fld DWORD [vertexPtr+ebp] + fmul DWORD [gc+vp_hdepth] + fmul DWORD [oowa] + fadd DWORD [gc+vp_oz] + fstp DWORD [fifo-4] - mov ebp, DWORD PTR [gc+tsuDataList+ebx*4] + mov ebp, DWORD [gc+tsuDataList+ebx*4] align 4 -clip_setup_qow: +.clip_setup_qow: test al, 8 - je SHORT clip_setup_qow0 + je .clip_setup_qow0 - cmp DWORD PTR [gc+fogInfo_mode], 1 - jne SHORT clip_setup_oow_nofog + cmp DWORD [gc+fogInfo_mode], 1 + jne .clip_setup_oow_nofog - mov ebp, DWORD PTR [gc+fogInfo_offset] - fld DWORD PTR oowa - fmul DWORD PTR [ebp+vertexPtr] - fstp DWORD PTR [fifo] + mov ebp, DWORD [gc+fogInfo_offset] + fld DWORD [oowa] + fmul DWORD [vertexPtr+ebp] + fstp DWORD [fifo] - jmp SHORT clip_setup_oow_inc + jmp .clip_setup_oow_inc align 4 -clip_setup_oow_nofog: - cmp DWORD PTR [gc+qInfo_mode], 1 - jne SHORT clip_setup_oow +.clip_setup_oow_nofog: + cmp DWORD [gc+qInfo_mode], 1 + jne .clip_setup_oow - mov ebp, DWORD PTR [gc+qInfo_offset] - fld DWORD PTR oowa - fmul DWORD PTR [ebp+vertexPtr] - fstp DWORD PTR [fifo] + mov ebp, DWORD [gc+qInfo_offset] + fld DWORD [oowa] + fmul DWORD [vertexPtr+ebp] + fstp DWORD [fifo] - jmp SHORT clip_setup_oow_inc + jmp .clip_setup_oow_inc align 4 -clip_setup_oow: +.clip_setup_oow: - mov ebp, DWORD PTR oowa + mov ebp, DWORD [oowa] - mov DWORD PTR [fifo], ebp + mov DWORD [fifo], ebp align 4 -clip_setup_oow_inc: - mov ebp, DWORD PTR [gc+tsuDataList+ebx*4+4] +.clip_setup_oow_inc: + mov ebp, DWORD [gc+tsuDataList+ebx*4+4] add fifo, 4 inc ebx align 4 -clip_setup_qow0: +.clip_setup_qow0: test al, 16 ; 00000010H - je SHORT clip_setup_stow0 + je .clip_setup_stow0 - cmp DWORD PTR [gc+q0Info_mode], 1 - jne SHORT clip_setup_oow0 + cmp DWORD [gc+q0Info_mode], 1 + jne .clip_setup_oow0 - mov ebp, DWORD PTR [gc+q0Info_offset] + mov ebp, DWORD [gc+q0Info_offset] - fld DWORD PTR oowa - fmul DWORD PTR [ebp+vertexPtr] - fstp DWORD PTR [fifo] + fld DWORD [oowa] + fmul DWORD [ebp+vertexPtr] + fstp DWORD [fifo] - jmp SHORT clip_setup_oow0_inc + jmp .clip_setup_oow0_inc align 4 -clip_setup_oow0: - mov ebp, DWORD PTR oowa +.clip_setup_oow0: + mov ebp, DWORD [oowa] - mov DWORD PTR [fifo], ebp + mov DWORD [fifo], ebp align 4 -clip_setup_oow0_inc: - mov ebp, DWORD PTR [gc+tsuDataList+ebx*4+4] +.clip_setup_oow0_inc: + mov ebp, DWORD [gc+tsuDataList+ebx*4+4] add fifo, 4 inc ebx align 4 -clip_setup_stow0: +.clip_setup_stow0: test al, 32 - je SHORT clip_setup_qow1 + je .clip_setup_qow1 - fld DWORD PTR oowa - fmul DWORD PTR [vertexPtr+ebp] + fld DWORD [oowa] + fmul DWORD [vertexPtr+ebp] add fifo, 8 add ebx, 2 - fmul DWORD PTR [gc+tmu0_s_scale] - fld DWORD PTR oowa - fmul DWORD PTR [vertexPtr+ebp+4] - mov ebp, DWORD PTR [gc+tsuDataList+ebx*4] - fmul DWORD PTR [gc+tmu0_t_scale] + fmul DWORD [gc+tmu0_s_scale] + fld DWORD [oowa] + fmul DWORD [vertexPtr+ebp+4] + mov ebp, DWORD [gc+tsuDataList+ebx*4] + fmul DWORD [gc+tmu0_t_scale] fxch - fstp DWORD PTR [fifo-8] - fstp DWORD PTR [fifo-4] + fstp DWORD [fifo-8] + fstp DWORD [fifo-4] align 4 -clip_setup_qow1: +.clip_setup_qow1: test al, 64 - je SHORT clip_setup_stow1 + je .clip_setup_stow1 - cmp DWORD PTR [gc+q1Info_mode], 1 - jne SHORT clip_setup_oow1 + cmp DWORD [gc+q1Info_mode], 1 + jne .clip_setup_oow1 - mov ebp, DWORD PTR [gc+q1Info_offset] + mov ebp, DWORD [gc+q1Info_offset] - fld DWORD PTR [ebp+vertexPtr] - fmul DWORD PTR oowa - fstp DWORD PTR [fifo] + fld DWORD [vertexPtr+ebp] + fmul DWORD [oowa] + fstp DWORD [fifo] - jmp SHORT clip_setup_oow1_inc + jmp .clip_setup_oow1_inc align 4 -clip_setup_oow1: - mov ebp, DWORD PTR oowa +.clip_setup_oow1: + mov ebp, DWORD [oowa] - mov DWORD PTR [fifo], ebp + mov DWORD [fifo], ebp align 4 -clip_setup_oow1_inc: - mov ebp, DWORD PTR [gc+tsuDataList+ebx*4+4] +.clip_setup_oow1_inc: + mov ebp, DWORD [gc+tsuDataList+ebx*4+4] add fifo, 4 inc ebx align 4 -clip_setup_stow1: +.clip_setup_stow1: test al, 128 - je SHORT clip_setup_end + je .clip_setup_end - fld DWORD PTR oowa - fmul DWORD PTR [vertexPtr+ebp] + fld DWORD [oowa] + fmul DWORD [vertexPtr+ebp] add fifo, 8 - fmul DWORD PTR [gc+tmu1_s_scale] - fld DWORD PTR oowa - fmul DWORD PTR [vertexPtr+ebp+4] - fmul DWORD PTR [gc+tmu1_t_scale] + fmul DWORD [gc+tmu1_s_scale] + fld DWORD [oowa] + fmul DWORD [vertexPtr+ebp+4] + fmul DWORD [gc+tmu1_t_scale] fxch - fstp DWORD PTR [fifo-8] - fstp DWORD PTR [fifo-4] + fstp DWORD [fifo-8] + fstp DWORD [fifo-4] align 4 -clip_setup_end: +.clip_setup_end: cmp edx, 12 - je update_fifo_ptr + je .update_fifo_ptr - fld DWORD PTR vPtr0[edx] - fdivr DWORD PTR _F1 + fld DWORD [vPtr0+edx] + fdivr DWORD [_F1] - lea ebx, DWORD PTR [esp+_va] - mov ebp, DWORD PTR [gc+wInfo_offset] + lea ebx, [esp+_va] + mov ebp, DWORD [gc+wInfo_offset] - mov vertexPtr, DWORD PTR [ebx+edx] - jmp begin_for_loop + mov vertexPtr, DWORD [ebx+edx] + jmp .begin_for_loop align 4 -update_fifo_ptr: +.update_fifo_ptr: - mov ebx, DWORD PTR [gc+fifoPtr] - mov edx, DWORD PTR [gc+fifoRoom] + mov ebx, dword [gc+fifoPtr] + mov edx, dword [gc+fifoRoom] sub ebx, fifo mov eax, 1 @@ -3234,11 +3190,11 @@ update_fifo_ptr: add edx, ebx pop ebp - mov DWORD PTR [gc+fifoRoom], edx + mov dword [gc+fifoRoom], edx pop edi - mov DWORD PTR [gc+fifoPtr], fifo - mov ebx, DWORD PTR __GlideRoot+trisProcessed + mov dword [gc+fifoPtr], fifo + mov ebx, dword [_GlideRoot+trisProcessed] ;;; ; _GlideRoot.stats.trisProcessed++ @@ -3246,14 +3202,12 @@ update_fifo_ptr: pop esi inc ebx - mov DWORD PTR __GlideRoot+trisProcessed, ebx + mov dword [_GlideRoot+trisProcessed], ebx pop ebx - ret 12 ; 0000000cH + ret ; 0000000cH -__vptrisetup_cull@12 ENDP -_TEXT ENDS +endp -endif ; !GL_AMD3D +%endif ; !GL_AMD3D -END diff --git a/glide3x/h3/glide3/src/xos.inc b/glide3x/h3/glide3/src/xos.inc new file mode 100644 index 0000000..9b4f3ce --- /dev/null +++ b/glide3x/h3/glide3/src/xos.inc @@ -0,0 +1,159 @@ +; +; compulsory header for h5/glide3/xdraw* assembly specializations (NASM) +; +; $Header$ +; $Log$ +; Revision 1.1.2.2 2003/06/13 07:22:59 dborca +; more fixes to NASM sources +; +; Revision 1.1.2.1 2003/06/07 09:53:25 dborca +; initial checkin for NASM sources +; + +;--------------------------------------- +; platform defines +;--------------------------------------- +%define XOS_DJGPP 1 +%define XOS_LINUX 2 +%define XOS_WIN32 4 + +%define STDCALL 0 + +;--------------------------------------- +; pick up the right OS +;--------------------------------------- +%ifdef __DJGPP__ +%define XOS XOS_DJGPP +%elifdef __linux__ +%define XOS XOS_LINUX +%elifdef __WIN32__ +%define XOS XOS_WIN32 +%define STDCALL 1 +%else +%error Unknown OS +%endif + +;--------------------------------------- +; general purpose macros +;--------------------------------------- +%macro extrn 1-2 0 + %if (XOS == XOS_WIN32) && STDCALL && (%2 > 0) + %define %1 %1@%2 + %endif + extern %1 +%endmacro + +%macro globl 1-2 0 + %if (XOS == XOS_WIN32) && STDCALL && (%2 > 0) + %define %1 %1@%2 + %endif + global %1 +%endmacro + +%macro proc 1-2 0 + %push proc + %if STDCALL && (%2 > 0) + %define %$ret RET %2 + %else + %define %$ret RET + %endif + globl %1, %2 +%1: +%endmacro + +%macro endp 0 + %ifnctx proc + %error Mismatched `endp'/`proc' + %else + %pop + %endif +%endmacro + +%macro ret 0 + %ifnctx proc + RET + %else + %$ret + %endif +%endmacro + +%macro invoke 1-* + %rep %0 - 1 + %rotate -1 + push %1 + %endrep + %rotate -1 + call %1 +%if (STDCALL == 0) && (%0 > 1) + add esp, 4 * (%0 - 1) +%endif +%endmacro + +;--------------------------------------- +; Windows +;--------------------------------------- +%if XOS == XOS_WIN32 + +%define TEXT .text align=32 +%define DATA .data align=32 +%define CONST .rdata align=32 + +%macro SET_TLSBASE 1 + mov %1, dword [fs:18h] ; get thread local storage base pointer +%endmacro + +%macro SET_TLSOFFSET 1 + mov %1, [_GlideRoot+tlsOffset] ; offset of GC into tls +%endmacro + +%macro GET_GC 2 + mov gc, [%1 + %2] +%endmacro + +%endif + +;--------------------------------------- +; DJGPP +;--------------------------------------- +%if XOS == XOS_DJGPP + +%define TEXT .text +%define DATA .data +%define CONST .rodata + +extrn threadValueDJGPP + +%macro SET_TLSBASE 1 +%endmacro + +%macro SET_TLSOFFSET 1 +%endmacro + +%macro GET_GC 2 + mov gc, [threadValueDJGPP] +%endmacro + +%endif + +;--------------------------------------- +; Linux +;--------------------------------------- +%if XOS == XOS_LINUX + +%define TEXT .text align=32 +%define DATA .data align=32 +%define CONST .rodata align=32 + +extrn threadValueLinux + +%macro SET_TLSBASE 1 +%endmacro + +%macro SET_TLSOFFSET 1 +%endmacro + +%macro GET_GC 2 + mov gc, [threadValueLinux] +%endmacro + +%endif diff --git a/glide3x/h3/glide3/src/xtexdl.asm b/glide3x/h3/glide3/src/xtexdl.asm index cac80d5..8e0153d 100644 --- a/glide3x/h3/glide3/src/xtexdl.asm +++ b/glide3x/h3/glide3/src/xtexdl.asm @@ -19,9 +19,18 @@ ;; $Header$ ;; $Revision$ ;; $Log$ +;; Revision 1.1.8.7 2003/09/12 05:08:35 koolsmoky +;; preparing for graphic context checks +;; +;; Revision 1.1.8.6 2003/07/07 23:29:06 koolsmoky +;; cleaned logs +;; +;; +;; Revision 1.1 2000/06/15 00:27:43 joseph +;; Initial checkin into SourceForge. ;; -;; 5 4/08/99 6:21p Atai -;; added contect check for _grTexDownload_3DNow_MMX +;; 10 8/17/99 6:35p Atai +;; fixed amd debug mode ;; ;; 9 4/08/99 1:22p Atai ;; added contect check for _grTexDownload_3DNow_MMX @@ -45,7 +54,7 @@ ;; added #ifdefs for hwc ;; ;; 2 10/14/98 12:05p Peter -;; fixed my f*cked up assumption about non-volatile regs +;; fixed my effed up assumption about non-volatile regs ;; ;; 1 10/09/98 6:48p Peter ;; 3DNow!(tm) version of wide texture downloads @@ -60,54 +69,55 @@ ;; mmx stuff for 3DNow!(tm) capable processors ;; -TITLE xtexdl.asm -OPTION OLDSTRUCTS +%include "xos.inc" -.586P -.MMX -.K3D - -ifdef USE_PACKET_FIFO -EXTRN __grCommandTransportMakeRoom@12: NEAR -endif +%ifdef USE_PACKET_FIFO +extrn _grCommandTransportMakeRoom, 12 +%endif ;;; Definitions of cvg regs and glide root structures. -INCLUDE fxgasm.h +%INCLUDE "fxgasm.h" ; Arguments (STKOFF = 16 from 4 dword pushes) -STACKOFFSET = 16 -_gc$ = 4 + STACKOFFSET -_baseAddr$ = 8 + STACKOFFSET -_maxS$ = 12 + STACKOFFSET -_minT$ = 16 + STACKOFFSET -_maxT$ = 20 + STACKOFFSET -_texData$ = 24 + STACKOFFSET +STACKOFFSET equ 16 +_gc$ equ 4 + STACKOFFSET +_baseAddr$ equ 8 + STACKOFFSET +_maxS$ equ 12 + STACKOFFSET +_minT$ equ 16 + STACKOFFSET +_maxT$ equ 20 + STACKOFFSET +_texData$ equ 24 + STACKOFFSET ;; NB: The first set of registers (eax, ecx, and edx) are volatile across ;; function calls. The remaining registers are supposedly non-volatile ;; so they only store things that are non-volatile across the call. -fifo TEXTEQU ; fifo ptr in inner loop -gc TEXTEQU ; graphics context -dataPtr TEXTEQU ; pointer to exture data to be downloaded -curT TEXTEQU ; counter for texture scan lines (t-coordinate) -curS TEXTEQU ; texture s-coordinate -fRoom TEXTEQU ; room available in fifo (in bytes) - -GR_FIFO_WRITE MACRO __addr, __offset, __data - mov [__addr + __offset], __data -ENDM ; GR_FIFO_WRITE +%define fifo ebp ; fifo ptr in inner loop +%define gc esi ; graphics context +%define dataPtr edi ; pointer to exture data to be downloaded +%define curT ebx ; counter for texture scan lines (t-coordinate) +%define curS ecx ; texture s-coordinate +%define fRoom edx ; room available in fifo (in bytes) ;-------------------------------------------------------------------------- -_TEXT SEGMENT PAGE PUBLIC USE32 'CODE' - ASSUME DS: FLAT, SS: FLAT +%IFNDEF GL_SSE2 + +;-------------------------------------------------------------------------- +; +; GL_AMD3D, GL_MMX +; +;-------------------------------------------------------------------------- + +segment TEXT ALIGN 32 - PUBLIC __grTexDownload_3DNow_MMX@24 - -__grTexDownload_3DNow_MMX@24 PROC NEAR +%IFDEF GL_AMD3D +proc _grTexDownload_3DNow_MMX, 24 +%ENDIF +%IFDEF GL_MMX +proc _grTexDownload_MMX, 24 +%ENDIF push ebx ; save caller's register variable mov curT, [esp + _maxT$ - 12] ; curT = maxT @@ -121,14 +131,18 @@ __grTexDownload_3DNow_MMX@24 PROC NEAR push ebp ; save caller's register variable mov dataPtr, [esp + _texData$]; dataPtr -IFDEF GLIDE_ALT_TAB +%IFDEF GLIDE_ALT_TAB test gc, gc - je __dlDone - mov edx, DWORD PTR [gc+lostContext] + je .dlDone +; mov edx, [gc + windowed] +; test edx, 1 +; jnz .pastContextTest + mov edx, DWORD [gc+lostContext] mov ecx, [edx] test ecx, 1 - jnz __dlDone -ENDIF + jnz .dlDone +;.pastContextTest: +%ENDIF sub curT, eax ; curT = maxT - minT mov fifo, [gc + fifoPtr] ; fifoPtr @@ -136,7 +150,12 @@ ENDIF mov curS, [esp + _maxS$] ; curS = maxS add curT, 1 ; curT = maxT - minT + 1 +%IFDEF GL_AMD3D femms ; we'll use MMX/3DNow!, make sure FPU register cleared +%ENDIF +%IFDEF GL_MMX + emms ; we'll use MMX +%ENDIF mov edx, curS ; curS = maxS = scanline width in DWORDs movd mm3, [esp + _baseAddr$] ; 0 | address of texture to download @@ -167,18 +186,14 @@ ENDIF ;; edx = fifoRoom, mm1 = texAddr|packetHdr, mm2 = TEX_ROW_ADDR_INCR(1)|0 test fifo, 4 ; is fifo QWORD aligned ? - jz __startDownload ; yup, start texture download + jz .startDownload ; yup, start texture download cmp fRoom, 4 ; enough room for NULL packet in fifo? - jge __mmxAlignFifo ; yes, write NULL packet to align fifo + jge .mmxAlignFifo ; yes, write NULL packet to align fifo -ifdef USE_PACKET_FIFO - push @Line ; Line # inside this function - push 0 ; NULL file name - - push 4 ; fifo space required (bytes) - call __grCommandTransportMakeRoom@12 ; make fifo room -endif +%ifdef USE_PACKET_FIFO + invoke _grCommandTransportMakeRoom, 4, 0, __LINE__; make fifo room +%endif mov fifo, [gc + fifoPtr] ; fifoPtr modified by _grCommandTransportMakeRoom, reload @@ -186,37 +201,41 @@ endif mov curS, [esp + _maxS$] ; reload maxS (destroyed by call to _grCommandTransportMakeRoom) test fifo, 4 ; new fifoPtr QWORD aligned ? - jz __startDownload ; yup, start texture download + jz .startDownload ; yup, start texture download -__mmxAlignFifo: +.mmxAlignFifo: - mov DWORD PTR [fifo], 0 ; write NULL packet + mov DWORD [fifo], 0 ; write NULL packet sub fRoom, 4 ; fifoRoom -= 4 mov [gc + fifoRoom], fRoom ; store new fifoRoom add fifo, 4 ; fifoPtr += 4 +%IFDEF GLIDE_DEBUG + mov [gc + checkPtr], fifo ; checkPtr +%ENDIF + mov [gc + fifoPtr], fifo ; store new fifoPtr - jmp __startDownload ; fifo aligned, download texture now + jmp .startDownload ; fifo aligned, download texture now align 32 ;; ebx = curT, edi = dataPtr, esi = gc, ebp = fifo, ecx = maxS = curS ;; edx=fifoRoom, mm1 = texAddr|packetHdr, mm2 = TEX_ROW_ADDR_INCR(1)|0 -__loopT: +.loopT: -IFDEF GLIDE_DEBUG +%IFDEF GLIDE_DEBUG ;; Make sure that we have a QWORD aligned fifoPtr; force GP if not aligned test fifo, 4 ; is fifoPtr QWORD aligned ? - jz __alignmentOK ; yup, continue + jz .alignmentOK ; yup, continue xor eax, eax ; create 0 mov [eax], eax ; move to DS:[0] forces GP -__alignmentOK: -ENDIF ; GLIDE_DEBUG +.alignmentOK: +%ENDIF ; GLIDE_DEBUG ;; Compute packet header words ;; hdr1: downloadSpace[31:30] numWords[21:3] packetType[2:0] @@ -227,7 +246,7 @@ ENDIF ; GLIDE_DEBUG ;; S coordinate inner loop unrolled for 8 texels a write -__loopS: +.loopS: movq mm0, [dataPtr] ; load 64 bit data (8 texels) add fifo, 8 ; pre-increment fifoPtr += 2 * sizeof(FxU32) @@ -236,7 +255,7 @@ __loopS: sub curS, 8 ; curS -= 2 * sizeof(FxU32) movq [fifo - 8], mm0 ; *fifoPtr = texelData[64 bits] - jnz __loopS ; loop while curS > 0 + jnz .loopS ; loop while curS > 0 mov ecx, [gc + fifoPtr] ; old fifo ptr nop ; filler @@ -244,6 +263,10 @@ __loopS: mov eax, fifo ; new fifo ptr mov [gc + fifoPtr], fifo ; save new fifo ptr +%IFDEF GLIDE_DEBUG + mov [gc + checkPtr], fifo ; checkPtr +%ENDIF + sub eax, ecx ; new fifo ptr - old fifo ptr = fifo space used up mov curS, [esp + _maxS$] ; curS = maxS = width of scanline (bytes) @@ -251,7 +274,7 @@ __loopS: sub curT, 1 ; curT-- mov [gc + fifoRoom], fRoom ; save new fifo space available - jz __dlDone ; loop while curT > 0 + jz .dlDone ; loop while curT > 0 ;; Check for room to write the next texture scanline @@ -260,40 +283,426 @@ __loopS: paddd mm1, mm2 ; texAddr+=TEX_ROW_ADDR_INCR(1) | packetHdr mov esp, esp ; filler -__startDownload: +.startDownload: lea eax, [curS+8] ; fifo space needed = scan line width + header size cmp fRoom, eax ; fifo space available >= fifo space required ? - jge __loopT ; yup, write next scan line + jge .loopT ; yup, write next scan line -ifdef USE_PACKET_FIFO - push @Line ; Line # inside this function - push 0h ; NULL file name - - push eax ; fifo space required - call __grCommandTransportMakeRoom@12 ; make fifo room (if fifoPtr QWORD aligned before -endif +%ifdef USE_PACKET_FIFO + invoke _grCommandTransportMakeRoom, eax, 0, __LINE__; make fifo room (if fifoPtr QWORD aligned before +%endif mov fifo, [gc + fifoPtr] ; fifoPtr was modified by _grCommandTransportMakeRoom, reload mov fRoom, [gc + fifoRoom] ; fifoRoom was modified by _grCommandTransportMakeRoom, reload mov curS, [esp + _maxS$] ; curS = maxS = width of scanline (bytes) - jmp __loopT ; we now have enough fifo room, write next scanline - -__dlDone: + jmp .loopT ; we now have enough fifo room, write next scanline +.dlDone: +%IFDEF GL_AMD3D femms ; exit 3DNow!(tm) state - +%ENDIF +%IFDEF GL_MMX + emms ; exit MMX state +%ENDIF + pop ebp ; restore caller's register variable pop edi ; restore caller's register variable pop esi ; restore caller's register variable pop ebx ; restore caller's register variable - ret 24 ; pop 6 DWORD parameters and return + ret ; pop 6 DWORD parameters and return +endp -__grTexDownload_3DNow_MMX@24 ENDP +%ELSE ; !GL_SSE2 -_TEXT ENDS +;-------------------------------------------------------------------------- +; +; GL_SSE2 +; +;-------------------------------------------------------------------------- -END +segment TEXT + + ALIGN 32 + +proc _grTexDownload_SSE2_64, 24 + + push ebx ; save caller's register variable + mov curT, [esp + _maxT$ - 12] ; curT = maxT + + push esi ; save caller's register variable + mov eax, [esp + _minT$ - 8] ; minT + + push edi ; save caller's register variable + mov gc, [esp + _gc$ - 4] ; gc + + push ebp ; save caller's register variable + mov dataPtr, [esp + _texData$]; dataPtr + +%IFDEF GLIDE_ALT_TAB + test gc, gc + je .dlDone +; mov edx, [gc + windowed] +; test edx, 1 +; jnz .pastContextTest + mov edx, DWORD [gc+lostContext] + mov ecx, [edx] + test ecx, 1 + jnz .dlDone +;.pastContextTest: +%ENDIF + + sub curT, eax ; curT = maxT - minT + mov fifo, [gc + fifoPtr] ; fifoPtr + + mov curS, [esp + _maxS$] ; curS = maxS + add curT, 1 ; curT = maxT - minT + 1 + + mov edx, curS ; curS = maxS = scanline width in DWORDs + movd xmm3,[esp + _baseAddr$] ; 0 | 0 | 0 | address of texture to download + + shl curS, 2 ; scan line width (in bytes) + mov eax, [esp + _minT$] ; 0 | 0 | 0 | minT + + mov [esp + _maxS$], curS ; save scan line width (in bytes) + shl edx, 3 ; packetHdr<21:3> = maxS = scanline width in DWORDs + + imul eax, curS ; TEX_ROW_ADDR_INCR(minT) = minT * TEX_ROW_ADDR_INCR(1) + + movd xmm2,curS ; 0 | 0 | TEX_ROW_ADDR_INCR(1) + or edx, 00000005h ; packetHdr<31:30> = lfb port + ; packetHdr<21:3> = maxS + ; packetHdr<2:0> = packetType 5 + + movd xmm1,edx ; 0 | 0 | packetHdr + movd xmm4,eax ; 0 | 0 | TEX_ROW_ADDR_INCR(minT) + + psllq xmm2,32 ; 0 | 0 | TEX_ROW_ADDR_INCR(1) | 0 + paddd xmm3,xmm4 ; 0 | 0 | texAddr = texBaseAddr + TEX_ROW_ADDR_INCR(minT) + + mov fRoom, [gc + fifoRoom] ; get available fifoRoom (in bytes) + punpckldq xmm1,xmm3 ; 0 | 0 | hdr2 = texAddr | hdr1 = packetHdr + + ;; ebx = curT, edi = dataPtr, esi = gc, ebp = fifo, ecx = curS = maxS + ;; edx = fifoRoom, xmm1 = texAddr|packetHdr, xmm2 = TEX_ROW_ADDR_INCR(1)|0 + + test fifo, 4 ; is fifo QWORD aligned ? + jz .startDownload ; yup, start texture download + + cmp fRoom, 4 ; enough room for NULL packet in fifo? + jge .xmmAlignFifo ; yes, write NULL packet to align fifo + +%ifdef USE_PACKET_FIFO + invoke _grCommandTransportMakeRoom, 4, 0, __LINE__; make fifo room +%endif + + mov fifo, [gc + fifoPtr] ; fifoPtr modified by _grCommandTransportMakeRoom, reload + + mov fRoom, [gc + fifoRoom] ; fifoRoom modified by _grCommandTransportMakeRoom, reload + mov curS, [esp + _maxS$] ; reload maxS (destroyed by call to _grCommandTransportMakeRoom) + + test fifo, 4 ; new fifoPtr QWORD aligned ? + jz .startDownload ; yup, start texture download + +.xmmAlignFifo: + + mov DWORD [fifo], 0 ; write NULL packet + sub fRoom, 4 ; fifoRoom -= 4 + + mov [gc + fifoRoom], fRoom ; store new fifoRoom + add fifo, 4 ; fifoPtr += 4 + +%IFDEF GLIDE_DEBUG + mov [gc + checkPtr], fifo ; checkPtr +%ENDIF + + mov [gc + fifoPtr], fifo ; store new fifoPtr + jmp .startDownload ; fifo aligned, download texture now + + align 32 + + ;; ebx = curT, edi = dataPtr, esi = gc, ebp = fifo, ecx = maxS = curS + ;; edx=fifoRoom, xmm1 = texAddr|packetHdr, xmm2 = TEX_ROW_ADDR_INCR(1)|0 + +.loopT: + +%IFDEF GLIDE_DEBUG + + ;; Make sure that we have a QWORD aligned fifoPtr; force GP if not aligned + + test fifo, 4 ; is fifoPtr QWORD aligned ? + jz .alignmentOK ; yup, continue + + xor eax, eax ; create 0 + mov [eax], eax ; move to DS:[0] forces GP +.alignmentOK: +%ENDIF ; GLIDE_DEBUG + + ;; Compute packet header words + ;; hdr1: downloadSpace[31:30] numWords[21:3] packetType[2:0] + ;; hdr2: download address[29:0] + + movq [fifo],xmm1 ; store hdr2 | hdr1 + add fifo, 8 ; increment fifo ptr (hdr1 + hdr2) + + ;; S coordinate inner loop unrolled for 8 texels a write + +.loopS: + + movq xmm0,[dataPtr] ; load 64 bit data (8 texels) + add fifo, 8 ; pre-increment fifoPtr += 2 * sizeof(FxU32) + + add dataPtr, 8 ; dataPtr += 2 * sizeof(FxU32) + sub curS, 8 ; curS -= 2 * sizeof(FxU32) + + movq [fifo - 8],xmm0 ; *fifoPtr = texelData[64 bits] + jnz .loopS ; loop while curS > 0 + + mov ecx, [gc + fifoPtr] ; old fifo ptr + nop ; filler + + mov eax, fifo ; new fifo ptr + mov [gc + fifoPtr], fifo ; save new fifo ptr + +%IFDEF GLIDE_DEBUG + mov [gc + checkPtr], fifo ; checkPtr +%ENDIF + + sub eax, ecx ; new fifo ptr - old fifo ptr = fifo space used up + mov curS, [esp + _maxS$] ; curS = maxS = width of scanline (bytes) + + sub fRoom, eax ; new fifo space available = old fifo space available - fifo space used up = new fifo space available + sub curT, 1 ; curT-- + + mov [gc + fifoRoom], fRoom ; save new fifo space available + jz .dlDone ; loop while curT > 0 + + ;; Check for room to write the next texture scanline + + ;; ebx = curT, edi = dataPtr, esi = gc, ebp = fifo + ;; edx = fifoRoom, xmm1 = texAddr|packetHdr, xmm2 = TEX_ROW_ADDR_INCR(1)|0 + + paddd xmm1,xmm2 ; 0 | 0 | texAddr+=TEX_ROW_ADDR_INCR(1) | packetHdr + mov esp, esp ; filler +.startDownload: + lea eax, [curS+8] ; fifo space needed = scan line width + header size + + cmp fRoom, eax ; fifo space available >= fifo space required ? + jge .loopT ; yup, write next scan line + +%ifdef USE_PACKET_FIFO + invoke _grCommandTransportMakeRoom, eax, 0, __LINE__; make fifo room (if fifoPtr QWORD aligned before +%endif + + mov fifo, [gc + fifoPtr] ; fifoPtr was modified by _grCommandTransportMakeRoom, reload + + mov fRoom, [gc + fifoRoom] ; fifoRoom was modified by _grCommandTransportMakeRoom, reload + mov curS, [esp + _maxS$] ; curS = maxS = width of scanline (bytes) + jmp .loopT ; we now have enough fifo room, write next scanline + +.dlDone: + pop ebp ; restore caller's register variable + pop edi ; restore caller's register variable + + pop esi ; restore caller's register variable + pop ebx ; restore caller's register variable + + ret ; pop 6 DWORD parameters and return +endp + + + +segment TEXT + + ALIGN 32 + +proc _grTexDownload_SSE2_128, 24 + + push ebx ; save caller's register variable + mov curT, [esp + _maxT$ - 12] ; curT = maxT + + push esi ; save caller's register variable + mov eax, [esp + _minT$ - 8] ; minT + + push edi ; save caller's register variable + mov gc, [esp + _gc$ - 4] ; gc + + push ebp ; save caller's register variable + mov dataPtr, [esp + _texData$]; dataPtr + +%IFDEF GLIDE_ALT_TAB + test gc, gc + je .dlDone +; mov edx, [gc + windowed] +; test edx, 1 +; jnz .pastContextTest + mov edx, DWORD [gc+lostContext] + mov ecx, [edx] + test ecx, 1 + jnz .dlDone +;.pastContextTest: +%ENDIF + + sub curT, eax ; curT = maxT - minT + mov fifo, [gc + fifoPtr] ; fifoPtr + + mov curS, [esp + _maxS$] ; curS = maxS + add curT, 1 ; curT = maxT - minT + 1 + + mov edx, curS ; curS = maxS = scanline width in DWORDs + movd xmm3,[esp + _baseAddr$] ; 0 | 0 | 0 | address of texture to download + + shl curS, 2 ; scan line width (in bytes) + mov eax, [esp + _minT$] ; 0 | minT + + mov [esp + _maxS$], curS ; save scan line width (in bytes) + shl edx, 3 ; packetHdr<21:3> = maxS = scanline width in DWORDs + + imul eax, curS ; TEX_ROW_ADDR_INCR(minT) = minT * TEX_ROW_ADDR_INCR(1) + + movd xmm2,curS ; 0 | 0 | 0 | TEX_ROW_ADDR_INCR(1) + or edx, 00000005h ; packetHdr<31:30> = lfb port + ; packetHdr<21:3> = maxS + ; packetHdr<2:0> = packetType 5 + + movd xmm1,edx ; 0 | 0 | 0 | packetHdr + movd xmm4,eax ; 0 | 0 | 0 | TEX_ROW_ADDR_INCR(minT) + + psllq xmm2,32 ; 0 | 0 | TEX_ROW_ADDR_INCR(1) | 0 + paddd xmm3,xmm4 ; 0 | 0 | 0 | texAddr = texBaseAddr + TEX_ROW_ADDR_INCR(minT) + + mov fRoom, [gc + fifoRoom] ; get available fifoRoom (in bytes) + punpckldq xmm1,xmm3 ; 0 | 0 | hdr2 = texAddr | hdr1 = packetHdr + + ;; ebx = curT, edi = dataPtr, esi = gc, ebp = fifo, ecx = curS = maxS + ;; edx = fifoRoom, xmm1 = texAddr|packetHdr, xmm2 = TEX_ROW_ADDR_INCR(1)|0 + + test fifo, 4 ; is fifo QWORD aligned ? + jz .startDownload ; yup, start texture download + + cmp fRoom, 4 ; enough room for NULL packet in fifo? + jge .xmmAlignFifo ; yes, write NULL packet to align fifo + +%ifdef USE_PACKET_FIFO + invoke _grCommandTransportMakeRoom, 4, 0, __LINE__; make fifo room +%endif + + mov fifo, [gc + fifoPtr] ; fifoPtr modified by _grCommandTransportMakeRoom, reload + + mov fRoom, [gc + fifoRoom] ; fifoRoom modified by _grCommandTransportMakeRoom, reload + mov curS, [esp + _maxS$] ; reload maxS (destroyed by call to _grCommandTransportMakeRoom) + + test fifo, 4 ; new fifoPtr QWORD aligned ? + jz .startDownload ; yup, start texture download + +.xmmAlignFifo: + + mov DWORD [fifo], 0 ; write NULL packet + sub fRoom, 4 ; fifoRoom -= 4 + + mov [gc + fifoRoom], fRoom ; store new fifoRoom + add fifo, 4 ; fifoPtr += 4 + +%IFDEF GLIDE_DEBUG + mov [gc + checkPtr], fifo ; checkPtr +%ENDIF + + mov [gc + fifoPtr], fifo ; store new fifoPtr + jmp .startDownload ; fifo aligned, download texture now + + align 32 + + ;; ebx = curT, edi = dataPtr, esi = gc, ebp = fifo, ecx = maxS = curS + ;; edx=fifoRoom, xmm1 = texAddr|packetHdr, xmm2 = TEX_ROW_ADDR_INCR(1)|0 + +.loopT: + +%IFDEF GLIDE_DEBUG + + ;; Make sure that we have a QWORD aligned fifoPtr; force GP if not aligned + + test fifo, 4 ; is fifoPtr QWORD aligned ? + jz .alignmentOK ; yup, continue + + xor eax, eax ; create 0 + mov [eax], eax ; move to DS:[0] forces GP +.alignmentOK: +%ENDIF ; GLIDE_DEBUG + + ;; Compute packet header words + ;; hdr1: downloadSpace[31:30] numWords[21:3] packetType[2:0] + ;; hdr2: download address[29:0] + + movq [fifo],xmm1 ; store hdr2 | hdr1 + add fifo, 8 ; increment fifo ptr (hdr1 + hdr2) + + ;; S coordinate inner loop unrolled for 8 texels a write + +.loopS: + + movdqu xmm0, [dataPtr] ; load 128 bit data (8 texels) ; isn't 16 bytes aligned? + add fifo, 16 ; pre-increment fifoPtr += 4 * sizeof(FxU32) + + add dataPtr, 16 ; dataPtr += 4 * sizeof(FxU32) + sub curS, 16 ; curS -= 4 * sizeof(FxU32) + + movdqu [fifo - 16], xmm0 ; *fifoPtr = texelData[128 bits] ; isn't 16 bytes aligned? + jnz .loopS ; loop while curS > 0 + + mov ecx, [gc + fifoPtr] ; old fifo ptr + nop ; filler + + mov eax, fifo ; new fifo ptr + mov [gc + fifoPtr], fifo ; save new fifo ptr + +%IFDEF GLIDE_DEBUG + mov [gc + checkPtr], fifo ; checkPtr +%ENDIF + + sub eax, ecx ; new fifo ptr - old fifo ptr = fifo space used up + mov curS, [esp + _maxS$] ; curS = maxS = width of scanline (bytes) + + sub fRoom, eax ; new fifo space available = old fifo space available - fifo space used up = new fifo space available + sub curT, 1 ; curT-- + + mov [gc + fifoRoom], fRoom ; save new fifo space available + jz .dlDone ; loop while curT > 0 + + ;; Check for room to write the next texture scanline + + ;; ebx = curT, edi = dataPtr, esi = gc, ebp = fifo + ;; edx = fifoRoom, xmm1 = texAddr|packetHdr, xmm2 = TEX_ROW_ADDR_INCR(1)|0 + + paddd xmm1,xmm2 ; 0 | 0 | texAddr+=TEX_ROW_ADDR_INCR(1) | packetHdr + mov esp, esp ; filler +.startDownload: + lea eax, [curS+8] ; fifo space needed = scan line width + header size + + cmp fRoom, eax ; fifo space available >= fifo space required ? + jge .loopT ; yup, write next scan line + +%ifdef USE_PACKET_FIFO + invoke _grCommandTransportMakeRoom, eax, 0, __LINE__; make fifo room (if fifoPtr QWORD aligned before +%endif + + mov fifo, [gc + fifoPtr] ; fifoPtr was modified by _grCommandTransportMakeRoom, reload + + mov fRoom, [gc + fifoRoom] ; fifoRoom was modified by _grCommandTransportMakeRoom, reload + mov curS, [esp + _maxS$] ; curS = maxS = width of scanline (bytes) + jmp .loopT ; we now have enough fifo room, write next scanline + +.dlDone: + pop ebp ; restore caller's register variable + pop edi ; restore caller's register variable + + pop esi ; restore caller's register variable + pop ebx ; restore caller's register variable + + ret ; pop 6 DWORD parameters and return +endp + + +%ENDIF ; GL_SSE2 diff --git a/glide3x/h3/minihwc/lin_mode.c b/glide3x/h3/minihwc/lin_mode.c new file mode 100644 index 0000000..e828849 --- /dev/null +++ b/glide3x/h3/minihwc/lin_mode.c @@ -0,0 +1,238 @@ +/* +** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONL +** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGH +** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DF +** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE +** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). +** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR +** FULL TEXT OF THE NON-WARRANTY PROVISIONS. +** +** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT T +** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS I +** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013 +** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FA +** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS O +** THE UNITED STATES. +** +** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVE +** +** $Header$ +*/ + +#include +#include +#include + +#if USE_XDGA_SWITCH +#include +#include +#include +static Display *dpy = 0; +static XDGADevice *dev = 0; +static XDGAMode *vidModes = 0; +#endif + +#include +#include +#include "h3cinit.h" +#include "glide.h" +#include "fxglide.h" + + +#define CFG_FILE "/etc/conf.3dfx/voodoo3" + +#if 1 +#define LOG(x) +#else +#define LOG(x) \ + do { \ + FILE *dbg = fopen("debug.txt","a"); \ + fprintf x ; \ + fclose(dbg); \ + } while(0); +#endif + +static struct envitem_t { + char *env; + char *val; + struct envitem_t *next; +} *first = NULL; + + +static FxU32 saveVidProcCfg; +static FxU32 saveLfbMemoryConfig; +static FxU32 saveMiscInit0; + + +FxBool setVideoMode(void *hwnd, + int xRes, + int yRes, + int h3pixelSize, + int refresh, + void *hmon, + char *regpath, + char *devicename) +{ + GR_DCL_GC; + hwcBoardInfo *bInfo = gc->bInfo; + +#if USE_XDGA_SWITCH + int eventbase, errorbase; + int i, numModes; + + dpy=XOpenDisplay(""); + if (!dpy) { + GDBG_INFO(80, "Failed to open X display\n"); + return FXFALSE; + } + + if (XDGAQueryExtension(dpy, &eventbase, &errorbase)) { + int major, minor; + XDGAQueryVersion(dpy, &major, &minor); + if (major>1 && minor<0) { + XCloseDisplay(dpy); + GDBG_INFO(80, "Banshee/V3 requires DGA version 1.x\n"); + return FXFALSE; + } + } + + vidModes = XDGAQueryModes(dpy, DefaultScreen(dpy), &numModes); + + for (i=0; iregInfo.ioPortBase, xRes, yRes, refresh, FXTRUE)) { + GDBG_INFO(80, "Setmode failed -- unimplemented resolution\n"); + return FXFALSE; + } +#endif + + HWC_IO_LOAD(bInfo->regInfo, vidProcCfg, saveVidProcCfg); + HWC_IO_LOAD(bInfo->regInfo, lfbMemoryConfig, saveLfbMemoryConfig); + HWC_IO_LOAD(bInfo->regInfo, miscInit0, saveMiscInit0); + + return FXTRUE; +} /* setVideoMode */ + + +void resetVideo (void) +{ + GR_DCL_GC; + hwcBoardInfo *bInfo = gc->bInfo; + + HWC_IO_STORE(bInfo->regInfo, lfbMemoryConfig, saveLfbMemoryConfig); + HWC_IO_STORE(bInfo->regInfo, vidProcCfg, saveVidProcCfg); + HWC_IO_STORE(bInfo->regInfo, miscInit0, saveMiscInit0); + +#if USE_XDGA_SWITCH + if (dpy) { + if (!XDGASetMode(dpy, DefaultScreen(dpy), 0)) { + GDBG_INFO(80, "Failed to return to previous video mode\n"); + } + vidModes = NULL; + XCloseDisplay(dpy); + dpy = NULL; + XFree(dev); + } +#else + /* XXX to do */ +#endif + + GDBG_INFO(80, "resetVideo(): \n"); +} /* resetVideo */ + + +static void loadEnvFile (void) +{ + FILE *file; + char data[256]; + char *env, *val; + struct envitem_t *item; + FxBool sawError = FXFALSE; + static FxBool envinit = FXFALSE; + + if (envinit) { + return; + } + envinit = FXTRUE; + if ((file = fopen(CFG_FILE, "r")) == NULL) { + return; + } + while (fgets(data, 255, file) != NULL) { + if ((*data=='#') || (*data=='\n')) { + continue; + } + if ((val = strchr(data, '=')) == NULL) { + if (!sawError) { + sawError = FXTRUE; + fprintf(stderr, "In config file " CFG_FILE ":\n"); + } + fprintf(stderr, "Malformed line: %s\n", data); + continue; + } + *val++ = '\0'; + env = data; + item = malloc(sizeof(struct envitem_t)); + item->env = malloc(strlen(env)+1); + strcpy(item->env, env); + item->val = malloc(strlen(val)+1); + strcpy(item->val, val); + item->next = first; + first = item; + } +} + + +char *file_getenv (const char *a) +{ + struct envitem_t *ptr; + char *result; + + if ((result = getenv(a)) != NULL) { + return result; + } + loadEnvFile(); + for (ptr = first; ptr != NULL; ptr = ptr->next) { + if (!strcmp(ptr->env, a)) { + return ptr->val; + } + } + + return NULL; +} + + +#include + +/*------------------------------------------------------------------- + Function: tlKbHit + Date: 2/28 + Implementor(s): jdt + Library: test library + Description: + Returns true if there are pending characters in the input queue + Arguments: + none + Return: + nonzero if keys in queue + -------------------------------------------------------------------*/ +int hwcKbHit( void ) { + return lin_kbhit(); +} + +char hwcGetCH( void ) { + return lin_getch(); +} diff --git a/glide3x/h3/minihwc/linhwc.c.dri b/glide3x/h3/minihwc/linhwc.c similarity index 100% rename from glide3x/h3/minihwc/linhwc.c.dri rename to glide3x/h3/minihwc/linhwc.c diff --git a/glide3x/h3/minihwc/linhwc.c.save b/glide3x/h3/minihwc/linhwc.c.save deleted file mode 100644 index a9e5ff4..0000000 --- a/glide3x/h3/minihwc/linhwc.c.save +++ /dev/null @@ -1,1247 +0,0 @@ -/* -** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY -** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT -** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX -** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE -** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). -** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER -** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A -** FULL TEXT OF THE NON-WARRANTY PROVISIONS. -** -** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO -** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN -** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013, -** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR -** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF -** THE UNITED STATES. -** -** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED -*/ - -/* - We need to provide the following functions: - -char * -hwcGetErrorString(void); - -hwcInfo * -hwcInit(FxU32 vID, FxU32 dID); - -FxBool -hwcMapBoard(hwcBoardInfo *bInfo, FxU32 bAddrMask); - -FxBool -hwcInitRegisters(hwcBoardInfo *bInfo); - -FxBool -hwcAllocBuffers(hwcBoardInfo *bInfo, FxU32 nColBuffers, FxU32 nAuxBuffers); - -FxBool -hwcInitFifo(hwcBoardInfo *bInfo); - -FxU32 -hwcInitAGPFifo(hwcBoardInfo *bInfo); - -FxBool -hwcInitVideo(hwcBoardInfo *bInfo, FxBool tiled, FxVideoTimingInfo - *vidTiming, FxBool overlay); - -FxBool -hwcRestoreVideo(hwcBoardInfo *bInfo); - -FxBool -hwcCheckMemSize(hwcBoardInfo *bInfo, FxU32 xres, FxU32 yres, FxU32 nColBuffers, - FxU32 nAuxBuffers, FxBool tiled); -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -static FxU32 fenceVar; -#define P6FENCE asm("xchg %%eax, %0" : : "m" (fenceVar) : "eax"); - -#define MAXFIFOSIZE 0x40000 -#define MAXFIFOSIZE_16MB 0xff000 -#define FIFOPAD 0x0000 -#define AUXPAD 0x1000 -#define HWC_TILED_BUFFER_BYTES 0x1000UL /* 128 Bytes x 32 lines */ -#define HWC_TILED_BUFFER_Y_ALIGN 0x20000UL -#define HWC_TILED_BUFFER_X_ADJUST 0x80UL - -static hwcInfo hInfo; -static char errorString[1024]; -static FxU32 saveVidProcCfg; -static FxU32 saveLfbMemoryConfig; -static FxU32 saveMiscInit0; -static FxU32 finalVidProcCfg; -static FxU32 finalLfbMemoryCfg; -static FxU32 finalVidDesktopOverlayStride; - -static Display *dpy = 0; -static int screenNum = 0; -static int screenWidth = 0; -static int screenHeight= 0; -static int screenDepth = 0; -static void* screenPhys = 0; -static int screenMem = 0; -static XF86VidModeModeInfo **vidModes = 0; -static int inDGA = 0; - -static FxU32 calcBufferStride(FxU32 xres, FxBool tiled); -static FxU32 calcBufferSize(FxU32 xres, FxU32 yres, FxBool tiled); -static FxU32 calcBufferSizeInTiles(FxU32 xres, FxU32 yres); -static FxU32 calcBufferHeightInTiles(FxU32 yres); -static FxU32 hwcBufferLfbAddr(FxU32 bufNum, const hwcBoardInfo* bInfo, - FxBool colBufAlignP); - -typedef struct envitem_t { - char *env; - char *val; - struct envitem_t *next; -} envitem; - -static envitem *first=0; -static int envinit=0; - -static void loadEnvFile() { - FILE *file; - char data[128]; - char *env, *val; - envitem *item; - int first=1; - - if (envinit) return; - envinit=1; - file=fopen("/etc/conf.3dfx/voodoo3", "r"); - if (!file) return; - while (1) { - if (!fgets(data, 128, file)) return; - if (*data=='#') continue; - if (*data=='\n') continue; - val=strchr(data, '='); - if (!val) { - if (first) { - fprintf(stderr, "In config file /etc/conf.3dfx/voodoo3:\n"); - first=0; - } - fprintf(stderr, "Malformed line: %s\n", data); - continue; - } - *val=0; - env=data; - val++; - item=malloc(sizeof(envitem)); - item->env=malloc(strlen(env)+1); - strcpy(item->env, env); - item->val=malloc(strlen(val)+1); - strcpy(item->val, val); - item->next=first; - first=item; - } -} - -static void deleteEnvData() { - envitem *ptr, *next; - - ptr=first; - while (ptr) { - next=ptr->next; - if (ptr->env) free(ptr->env); - if (ptr->val) free(ptr->val); - free(ptr); - ptr=next; - } - first=0; - envinit=0; -} - -char * -hwcGetErrorString() -{ -#define FN_NAME "hwcGetErrorString" - return errorString; -#undef FN_NAME -} /* hwcGetErrorString */ - -static int initX(int index) { - int eventbase, errorbase, flags; - int banksize; - - if (dpy!=0) return FXTRUE; - dpy=XOpenDisplay(""); - if (!dpy) { - sprintf(errorString, "Banshee/V3 only runs under local X connection\n"); - return FXFALSE; - } - if (XF86DGAQueryExtension(dpy, &eventbase, &errorbase)) { - int major, minor; - XF86DGAQueryVersion(dpy, &major, &minor); - if (major>1 && minor<0) { - XCloseDisplay(dpy); - sprintf(errorString,"Banshee/V3 requires DGA version 1.x\n"); - return FXFALSE; - } - } - screenNum=DefaultScreen(dpy); - XF86DGAGetVideoLL(dpy, screenNum, (int*)&screenPhys, &screenWidth, &banksize, - &screenMem); - screenMem*=1024; - screenHeight=DisplayHeight(dpy, screenNum); - screenDepth=DefaultDepth(dpy, screenNum); - if (XF86DGAQueryDirectVideo(dpy, DefaultScreen(dpy), &flags)==False || - !flags) { - sprintf(errorString,"Banshee/V3 requires X server to suppoer direct video\n"); - return FXFALSE; - } - hInfo.boardInfo[index].h3Mem = screenMem>>20; - XCloseDisplay(dpy); - dpy=0; - return FXTRUE; -} - -hwcInfo * -hwcInit(FxU32 vID, FxU32 dID) { - int i; - FxU32 bn; - - pciOpen(); - - /* hInfo.nBoards = 0; */ - - errorString[0] = '\0'; - - for (i = 0; i < HWC_MAX_BOARDS; i++) { - hInfo.boardInfo[i].pciInfo.initialized = 0; - if (pciFindCardMulti(vID, dID, &bn, i)) { - hInfo.nBoards++; - hInfo.boardInfo[i].boardNum = 0; - - hInfo.boardInfo[i].pciInfo.initialized = 1; - hInfo.boardInfo[i].pciInfo.vendorID = vID; - hInfo.boardInfo[i].pciInfo.deviceID = dID; - /* - * NOTE: in the code above we learn about memsize here: - * hInfo.boardInfo[i].h3Mem - * - * However, in DOS, since we have not mapped the board yet, so we have - * to wait until later. (see hwcInitRegisters()) - dwj - */ - - /* Get some board Info */ - pciGetConfigData( PCI_REVISION_ID, bn, &hInfo.boardInfo[i].devRev); - - /* Get all the base addresses */ - pciGetConfigData(PCI_BASE_ADDRESS_0, bn, - &hInfo.boardInfo[i].pciInfo.pciBaseAddr[0]); - pciGetConfigData(PCI_BASE_ADDRESS_1, bn, - &hInfo.boardInfo[i].pciInfo.pciBaseAddr[1]); - pciGetConfigData(PCI_IO_BASE_ADDRESS, bn, - &hInfo.boardInfo[i].pciInfo.pciBaseAddr[2]); - pciGetConfigData(PCI_ROM_BASE_ADDRESS, bn, - &hInfo.boardInfo[i].pciInfo.pciBaseAddr[3]); - } - } - if (hInfo.nBoards) { - if (!initX(0)) return 0; - return &hInfo; - } else { - sprintf(errorString, "Can't find or access Banshee/V3 board\n"); - return 0; - } -} - -FxBool -hwcMapBoard(hwcBoardInfo *bInfo, FxU32 bAddrMask) { - FxU32 bAddr; - - if (bInfo->pciInfo.initialized == FXFALSE) { - sprintf(errorString, "hwcMapBoard: Called before hwcInit\n"); - return FXFALSE; - } - - bInfo->linearInfo.initialized = FXTRUE; - - for (bAddr = 0; bAddr < HWC_NUM_BASE_ADDR; bAddr++) { - if ((bAddrMask >> bAddr) & 0x1) { - bInfo->linearInfo.linearAddress[bAddr] = (FxU32) - pciMapCardMulti(bInfo->pciInfo.vendorID, bInfo->pciInfo.deviceID, - 0x2000000, &bInfo->deviceNum, bInfo->boardNum, bAddr); - } - } - return FXTRUE; -} - -FxBool -hwcUnmapBoard(hwcBoardInfo *bInfo) { - FxU32 bAddr; - - for (bAddr=0; bAddrlinearInfo.linearAddress[bAddr], 0x2000000); - } - return FXTRUE; -} - -FxBool -hwcInitRegisters(hwcBoardInfo *bInfo) { - int dramInit1; - - if (bInfo->linearInfo.initialized == FXFALSE) { - printf(errorString, "hwcInitRegisters Called before hwcMapBoard\n"); - return FXFALSE; - } - - bInfo->regInfo.initialized = FXTRUE; - - bInfo->regInfo.ioMemBase = - bInfo->linearInfo.linearAddress[0] + SST_IO_OFFSET; - bInfo->regInfo.cmdAGPBase = - bInfo->linearInfo.linearAddress[0] + SST_CMDAGP_OFFSET; - bInfo->regInfo.waxBase = - bInfo->linearInfo.linearAddress[0] + SST_2D_OFFSET; - bInfo->regInfo.sstBase = - bInfo->linearInfo.linearAddress[0] + SST_3D_OFFSET; - bInfo->regInfo.lfbBase = - bInfo->linearInfo.linearAddress[0] + SST_LFB_OFFSET; - bInfo->regInfo.rawLfbBase = - bInfo->linearInfo.linearAddress[1]; - bInfo->regInfo.ioPortBase = (FxU16) bInfo->pciInfo.pciBaseAddr[2] & ~0x1; - - /* Figure out if it's SDRAM */ - HWC_IO_LOAD(bInfo->regInfo, dramInit1, dramInit1); - dramInit1 &= SST_MCTL_TYPE_SDRAM; - if ( dramInit1 & SST_MCTL_TYPE_SDRAM ) - bInfo->sdRAM = FXTRUE; - else - bInfo->sdRAM = FXFALSE; - - { - FxU32 - pciInit0, - pciCommandReg = - BIT(0) | /* enable i/o decode */ - BIT(1); /* enable memory decode */ - - /* Enable PCI memory and I/O decode */ - pciSetConfigData(PCI_COMMAND, bInfo->deviceNum, &pciCommandReg); - - HWC_IO_LOAD(bInfo->regInfo, pciInit0, pciInit0); - pciInit0 |= SST_PCI_READ_WS | SST_PCI_WRITE_WS; - HWC_IO_STORE(bInfo->regInfo, pciInit0, pciInit0); - } - - return FXTRUE; -} - -FxBool -hwcAllocBuffers(hwcBoardInfo *bInfo, FxU32 nColBuffers, FxU32 nAuxBuffers) -{ -#define FN_NAME "hwcAllocBuffers" - FxBool - bufferAlignP; - FxU32 - bNum, - h3Mem = bInfo->h3Mem << 20, - bufStride, - bufSize; - FxI32 - i, - tramSize, fifoSize; - - if (bInfo->vidInfo.initialized == FXFALSE) { - sprintf(errorString, "%s: Called before video initialization\n", FN_NAME); - return FXFALSE; - } - - GDBG_INFO(80, "%s(0x%x, 0x%x, 0x%x)\n", FN_NAME, bInfo, nColBuffers, nAuxBuffers); - - /* I've decided on > 2 instead of == 3 because we may support more - than 3 buffers in the future, and want 4 to set the - triple-buffering bit in dramInit1, also */ - bInfo->vidInfo.tripleBuffering = (nColBuffers > 2); - - bInfo->vidInfo.stride = bufStride = - calcBufferStride(bInfo->vidInfo.xRes, bInfo->vidInfo.tiled); - - /* We want to place the FIFO after the tram but before the color - buffers with some pad */ - bufSize = calcBufferSize(bInfo->vidInfo.xRes, bInfo->vidInfo.yRes, - bInfo->vidInfo.tiled); - - bInfo->buffInfo.bufStride = bufStride; - bInfo->buffInfo.bufSize = bufSize; - - if (bInfo->vidInfo.tiled) { - bInfo->buffInfo.bufStrideInTiles = (bufStride >> 7); - bInfo->buffInfo.bufSizeInTiles = - calcBufferSizeInTiles(bInfo->vidInfo.xRes, bInfo->vidInfo.yRes); - bInfo->buffInfo.bufHeightInTiles = - calcBufferHeightInTiles(bInfo->vidInfo.yRes); - } - - bInfo->buffInfo.initialized = FXTRUE; - bInfo->buffInfo.nColBuffers = nColBuffers; - bInfo->buffInfo.nAuxBuffers = nAuxBuffers; - - /* Subtract 0x1000 from h3mem to leave the X cursor (in high mem) alone */ - h3Mem-=0x1000; - - /* First, do the buffer allocation */ - - if (nAuxBuffers > 0) { - bInfo->buffInfo.auxBuffEnd = - bInfo->buffInfo.auxBuffStart = h3Mem; - - bInfo->buffInfo.auxBuffStart -= bufSize; - - /* auxBuffers start on odd pages, so we need to check to see if - * it's on an even page and, if so, make it odd. - * - * NB: We need to do the same sort of 'alignment' thing here as for - * the color buffers. - */ - bufferAlignP = ((bInfo->buffInfo.auxBuffStart & 0x1000UL) == 0); - if (bufferAlignP) bInfo->buffInfo.auxBuffStart -= 0x1000; - - } - - for (i = nColBuffers - 1; i >= 0; i--) { - if ((FxU32) i == (nColBuffers - 1)) { - FxU32 top; - if (nAuxBuffers > 0) - top = bInfo->buffInfo.auxBuffStart; - else - top = h3Mem; - - bInfo->buffInfo.colBuffStart[i] = - bInfo->buffInfo.colBuffEnd[i] = top; - } else { - bInfo->buffInfo.colBuffStart[i] = - bInfo->buffInfo.colBuffEnd[i] = - bInfo->buffInfo.colBuffStart[i + 1]; - } - - bInfo->buffInfo.colBuffStart[i] -= bufSize; - - /* As a memory access optmization colorBuffers start on even - * pages, while aux buffers start on odd pages. Thus we must - * check to see if we're startding on an odd page here and, if so, - * add a page to the start. - */ - bufferAlignP = ((bInfo->buffInfo.colBuffStart[i] & 0x1000UL) != 0); - if (bufferAlignP) bInfo->buffInfo.colBuffStart[i] -= 0x1000; - } - - /* Now we can calculate some other stuff... */ - bInfo->fbOffset = bInfo->buffInfo.colBuffStart[0]; - bInfo->tramOffset = 0; - fifoSize = (bInfo->h3Mem>8) ? MAXFIFOSIZE_16MB : MAXFIFOSIZE; - tramSize = bInfo->fbOffset - bInfo->tramOffset - fifoSize; - if (tramSize < (FxI32)bInfo->min_tramSize) { - /* Now we have to shrink the FIFO */ - tramSize = bInfo->min_tramSize; - fifoSize = bInfo->fbOffset - bInfo->min_tramSize; - if (fifoSize < 0) { - GDBG_INFO(80, "%s: Not enough memory for resolution + min texture\n", - FN_NAME); - sprintf(errorString, - "%s: Not enough memory for resolution + min texture\n", - FN_NAME); - return FXFALSE; - } - } - - bInfo->fifoInfo.fifoLength = (FxU32) fifoSize; - bInfo->fifoInfo.fifoStart = bInfo->fbOffset - fifoSize; - - bInfo->fifoInfo.fifoLength -= 0x2000; - - bInfo->tramSize = tramSize; - -#if 0 - if (tramSize>screenWidth*screenHeight*(screenDepth+7)/8+bInfo->min_tramSize) { - bInfo->tramOffset = screenWidth*screenHeight*(screenDepth+7)/8; - bInfo->tramSize = (FxU32)(tramSize-screenWidth*screenHeight*(screenDepth+7)/8); - } else { - bInfo->tramOffset = 0; - bInfo->tramSize = (FxU32)tramSize; - } -#endif - -#define LFBSTRIDE 0x1000 - { - FxU32 colBuffOffset = 0; - FxU32 colBufAlignP = 0; - - for (bNum = 0; bNum < nColBuffers; bNum++) { - if ((colBuffOffset & 0x1000UL) != 0) { - colBuffOffset += 0x1000UL; - colBufAlignP++; - } - bInfo->buffInfo.lfbBuffAddr[bNum] = - hwcBufferLfbAddr(bNum, bInfo, colBufAlignP); - colBuffOffset += bufSize; - } - - if (nAuxBuffers > 0) { - if ((colBuffOffset & 0x1000UL) != 0) { - colBuffOffset += 0x1000UL; - colBufAlignP++; - } - bInfo->buffInfo.lfbBuffAddr[nColBuffers] = - hwcBufferLfbAddr(nColBuffers, bInfo, colBufAlignP); - } - } - -#if 0 - for (i=0; i<2580*10; i++) { - bInfo->buffInfo.lfbBuffAddr[0]=i%256; - bInfo->buffInfo.lfbBuffAddr[1]=i%256; - } -#endif - - GDBG_INFO(80, "%s: Board Info:\n", FN_NAME); - GDBG_INFO(80, "\thdc: 0x%x\n", bInfo->hdc); - GDBG_INFO(80, "\textContextID: 0x%x\n", bInfo->extContextID); - GDBG_INFO(80, "\tdevRev: 0x%x\n", bInfo->devRev); - GDBG_INFO(80, "\tfbOffset: 0x%x\n", bInfo->fbOffset); - GDBG_INFO(80, "\th3Rev: 0x%x\n", bInfo->h3Rev); - GDBG_INFO(80, "\th3Mem: 0x%x\n", bInfo->h3Mem); - GDBG_INFO(80, "\tboardNum: 0x%x\n", bInfo->boardNum); - GDBG_INFO(80, "\tdeviceNum: 0x%x\n", bInfo->deviceNum); - - GDBG_INFO(80, "%s: Buffer Info:\n", FN_NAME); - GDBG_INFO(80, "\tbufSize: 0x%x\n", bInfo->buffInfo.bufSize); - GDBG_INFO(80, "\tbufSizeInTiles: 0x%x\n", bInfo->buffInfo.bufSizeInTiles); - GDBG_INFO(80, "\tbufStride: 0x%x\n", bInfo->buffInfo.bufStride); - GDBG_INFO(80, "\tbufStrideInTiles:0x%x\n", bInfo->buffInfo.bufStrideInTiles); - GDBG_INFO(80, "\tbufHeightInTiles:0x%x\n", bInfo->buffInfo.bufHeightInTiles); - GDBG_INFO(80, "\tnColBuffers: 0x%x\n", bInfo->buffInfo.nColBuffers); - for (i = 0; i < (FxI32) nColBuffers; i++) { - GDBG_INFO(80, "\tcolBuff %d Start: 0x%x\n", i, bInfo->buffInfo.colBuffStart[i]); - GDBG_INFO(80, "\tcolBuff %d End: 0x%x\n", i, bInfo->buffInfo.colBuffEnd[i]); - } - GDBG_INFO(80, "\tnAuxBuffers: 0x%x\n", bInfo->buffInfo.nAuxBuffers); - GDBG_INFO(80, "\tauxBuffStart: 0x%x\n", bInfo->buffInfo.auxBuffStart); - GDBG_INFO(80, "\tauxBuffEnd: 0x%x\n", bInfo->buffInfo.auxBuffEnd); - - GDBG_INFO(80, "%s: FIFO Info:\n", FN_NAME); - GDBG_INFO(80, "\tfifoStart: 0x%x\n", bInfo->fifoInfo.fifoStart); - GDBG_INFO(80, "\tfifoLength: 0x%x\n", bInfo->fifoInfo.fifoLength); - - GDBG_INFO(80, "%s: TRAM Info:\n", FN_NAME); - GDBG_INFO(80, "\ttramOffset: 0x%x\n", bInfo->tramOffset); - GDBG_INFO(80, "\ttramSize: 0x%x\n", bInfo->tramSize); - GDBG_INFO(80, "\tMin TramSize: 0x%x\n", bInfo->min_tramSize); - - return FXTRUE; - -#undef FN_NAME -} /* hwcAllocBuffers */ - -FxBool -hwcInitFifo(hwcBoardInfo *bInfo, FxBool enableHoleCounting) -{ -#define FN_NAME "hwcInitFifo" - FxBool - agpEnable = FXFALSE; - FxU32 - cagpRegs; /* pointer to Cmd/AGP regs */ - - if (bInfo->regInfo.initialized == FXFALSE) { - sprintf(errorString, "%s: Called before hwcMapBoard\n", FN_NAME); - return FXFALSE; - } - cagpRegs = bInfo->regInfo.cmdAGPBase; - - if (bInfo->buffInfo.initialized == FXFALSE) { - sprintf(errorString, "%s: Called before hwcInitBuffers\n", FN_NAME); - return FXFALSE; - } - - /* disable the CMD fifo */ - HWC_CAGP_STORE(bInfo->regInfo, cmdFifo0.baseSize, 0); - - HWC_CAGP_STORE(bInfo->regInfo, cmdFifo0.baseAddrL, - bInfo->fifoInfo.fifoStart>>12); - HWC_CAGP_STORE(bInfo->regInfo, cmdFifo0.readPtrL, bInfo->fifoInfo.fifoStart); - HWC_CAGP_STORE(bInfo->regInfo, cmdFifo0.readPtrH, 0); - HWC_CAGP_STORE(bInfo->regInfo, cmdFifo0.aMin, bInfo->fifoInfo.fifoStart-4); - HWC_CAGP_STORE(bInfo->regInfo, cmdFifo0.aMax, bInfo->fifoInfo.fifoStart-4); - - HWC_CAGP_STORE(bInfo->regInfo, cmdFifo0.depth, 0); - HWC_CAGP_STORE(bInfo->regInfo, cmdFifo0.holeCount, 0); - /* Fifo LWM /HWM/ THRESHOLD */ - if (bInfo->pciInfo.deviceID == 0x3) { /* banshee */ - HWC_CAGP_STORE(bInfo->regInfo, cmdFifoThresh, - (0x09 << SST_HIGHWATER_SHIFT) | 0x2); - } else { - HWC_CAGP_STORE(bInfo->regInfo, cmdFifoThresh, - (0xf << SST_HIGHWATER_SHIFT) | 0x8); - } - HWC_CAGP_STORE(bInfo->regInfo, cmdFifo0.baseSize, - ((bInfo->fifoInfo.fifoLength >> 12) - 1) | SST_EN_CMDFIFO | - (enableHoleCounting ? 0 : SST_CMDFIFO_DISABLE_HOLES) | - (agpEnable ? SST_CMDFIFO_AGP : 0)); - - GDBG_INFO(80 ,"%s: CMD FIFO placed at physical addr 0x%x\n", FN_NAME, - bInfo->fifoInfo.fifoStart); - - return FXTRUE; - -#undef FN_NAME -} /* hwcInitFifo */ - -static void -hwcInitVideoOverlaySurface( - hwcRegInfo *rInfo, - FxU32 enable, /* 1=enable Overlay surface (OS), 1=disable */ - FxU32 stereo, /* 1=enable OS stereo, 0=disable */ - FxU32 horizScaling, /* 1=enable horizontal scaling, 0=disable */ - FxU32 dudx, /* horizontal scale factor (ignored if not */ - /* scaling) */ - FxU32 verticalScaling, /* 1=enable vertical scaling, 0=disable */ - FxU32 dvdy, /* vertical scale factor (ignored if not */ - /* scaling) */ - FxU32 filterMode, /* duh */ - FxU32 tiled, /* 0=OS linear, 1=tiled */ - FxU32 pixFmt, /* pixel format of OS */ - FxU32 clutBypass, /* bypass clut for OS? */ - FxU32 clutSelect, /* 0=lower 256 CLUT entries, 1=upper 256 */ - FxU32 startAddress, /* board address of beginning of OS */ - FxU32 stride) /* distance between scanlines of the OS, in */ - /* units of bytes for linear OS's and tiles for */ - /* tiled OS's */ -{ - FxU32 doStride; - FxU32 vidProcCfg; - - HWC_IO_LOAD((*rInfo), vidProcCfg, vidProcCfg); - - vidProcCfg &= ~(SST_OVERLAY_TILED_EN | - SST_OVERLAY_STEREO_EN | - SST_OVERLAY_HORIZ_SCALE_EN | - SST_OVERLAY_VERT_SCALE_EN | - SST_OVERLAY_TILED_EN | - SST_OVERLAY_PIXEL_FORMAT | - SST_OVERLAY_CLUT_BYPASS | - SST_OVERLAY_CLUT_SELECT); - - if (enable) - vidProcCfg |= SST_OVERLAY_EN; - - if (stereo) - vidProcCfg |= SST_OVERLAY_STEREO_EN; - - if (horizScaling) - vidProcCfg |= SST_OVERLAY_HORIZ_SCALE_EN; - - if (verticalScaling) - vidProcCfg |= SST_OVERLAY_VERT_SCALE_EN; - - if (tiled) { - vidProcCfg |= SST_OVERLAY_TILED_EN; - } - - vidProcCfg |= pixFmt; - - vidProcCfg &= ~SST_CURSOR_EN; /* Turn off HW Cursor */ - - if (clutBypass) - vidProcCfg |= SST_OVERLAY_CLUT_BYPASS; - - if (clutSelect) - vidProcCfg |= SST_OVERLAY_CLUT_SELECT; - - HWC_IO_STORE((*rInfo), vidProcCfg, vidProcCfg); - - /* */ - HWC_IO_LOAD((*rInfo), vidDesktopOverlayStride, doStride); - doStride &= ~(SST_OVERLAY_LINEAR_STRIDE | SST_OVERLAY_TILE_STRIDE); - - stride <<= SST_OVERLAY_STRIDE_SHIFT; - if (tiled) - stride &= SST_OVERLAY_TILE_STRIDE; - else - stride &= SST_OVERLAY_LINEAR_STRIDE; - doStride |= stride; - - HWC_IO_STORE((*rInfo), vidDesktopOverlayStride, doStride); - - finalVidDesktopOverlayStride = doStride; - - /* This isn't required, but is useful for debugging */ - HWC_SST_STORE((*rInfo), leftOverlayBuf, startAddress); - -} /* hwcInitVideoOverlaySurface */ - -FxBool -hwcInitVideo(hwcBoardInfo *bInfo, FxBool tiled, FxVideoTimingInfo - *vidTiming, FxBool overlay) { - FxU32 pixFmt = SST_OVERLAY_PIXEL_RGB565D; - FxU32 stride, dramInit1, miscInit0, lfbMemoryConfig; - FxU32 scrWidth, scrHeight, ovlWidth, ovlHeight, scale, - vidOverlayDudx, vidOverlayDvdy, - vidProcCfg, vidScreenSize, vidOverlayEndScreenCoord; - int i, numModes; - - - dpy=XOpenDisplay(""); - if (!dpy) { - /* This should never happen since we opened in initX */ - sprintf(errorString, "Failed to open X display\n"); - return FXFALSE; - } - if (XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectGraphics)) { - inDGA=1; - } else { - sprintf(errorString, "Failed to enter DGA Graphics mode\n"); - return FXFALSE; - } - if (XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &numModes, - &vidModes)==False) { - sprintf(errorString, "Couldn't query vidmode list\n"); - return FXFALSE; - } - for (i=0; ihdisplay==bInfo->vidInfo.xRes) && - (vidModes[i]->vdisplay==bInfo->vidInfo.yRes)) - break; - if (i==numModes) { - sprintf(errorString, "Server doesn't support requested resolution\n"); - if (inDGA) { - XF86DGADirectVideo(dpy, DefaultScreen(dpy), 0); - inDGA=0; - } - if (vidModes) { - XFree(vidModes); - vidModes=0; - } - return FXFALSE; - } - if (XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), vidModes[i])==False) { - sprintf(errorString, "Failed to set required video mode\n"); - return FXFALSE; - } - XSync(dpy, False); - - stride= (tiled) ? bInfo->buffInfo.bufStrideInTiles : bInfo->vidInfo.stride; - - HWC_IO_LOAD(bInfo->regInfo, vidProcCfg, saveVidProcCfg); - HWC_IO_LOAD(bInfo->regInfo, lfbMemoryConfig, saveLfbMemoryConfig); - HWC_IO_LOAD(bInfo->regInfo, miscInit0, saveMiscInit0); - - HWC_IO_STORE(bInfo->regInfo, vidOverlayDudxOffsetSrcWidth, - ((bInfo->vidInfo.xRes << 1) << 19)); - - /* Video pixel buffer threshold */ - { - FxU32 vidPixelBufThold; - FxU32 thold = 32; - - if (getenv("SSTVB_PIXTHOLD")) { - thold = atoi(getenv("SSTVB_PIXTHOLD")); - } - - thold &= 0x3f; - - vidPixelBufThold = (thold | (thold << 6) | (thold << 12)); - - HWC_IO_STORE(bInfo->regInfo, vidPixelBufThold, vidPixelBufThold); - } - - hwcInitVideoOverlaySurface( - &bInfo->regInfo, - FXTRUE, /* 1=enable Overlay surface (OS), 1=disable */ - FXFALSE, /* 1=enable OS stereo, 0=disable */ - FXFALSE, /* 1=enable horizontal scaling, 0=disable */ - 0, /* horizontal scale factor (ignored if not) */ - FXFALSE, /* 1=enable vertical scaling, 0=disable */ - 0, /* vertical scale factor (ignored if not) */ - 0, /* Filter mode */ - tiled, /* tiled */ - pixFmt, /* pixel format of OS */ - FXFALSE, /* bypass clut for OS? */ - 0, /* 0=lower 256 CLUT entries, 1=upper 256 */ - bInfo->buffInfo.colBuffStart[0],/* board address of beginning of OS */ - stride); /* distance between scanlines of the OS, in - units of bytes for linear OS's and tiles for - tiled OS's */ - - HWC_IO_STORE(bInfo->regInfo, vidOverlayStartCoords, 0); - HWC_IO_STORE(bInfo->regInfo, vidOverlayEndScreenCoord, - (bInfo->vidInfo.yRes << SST_OVERLAY_Y_SHIFT) | - (bInfo->vidInfo.xRes & SST_OVERLAY_X) ); - - /* - Setup video scaling for half-modes - */ - - /* Get some important info */ - HWC_IO_LOAD(bInfo->regInfo, vidScreenSize, vidScreenSize); - HWC_IO_LOAD(bInfo->regInfo, vidProcCfg, vidProcCfg); - HWC_IO_LOAD(bInfo->regInfo, vidOverlayEndScreenCoord, vidOverlayEndScreenCoord); - - scrWidth = (vidScreenSize >> SST_VIDEO_SCREEN_WIDTH_SHIFT) & 0xfff; - scrHeight = (vidScreenSize >> SST_VIDEO_SCREEN_HEIGHT_SHIFT) & 0xfff; - - ovlWidth = ((vidOverlayEndScreenCoord) >> SST_OVERLAY_X_SHIFT) & 0xfff; - ovlHeight = ((vidOverlayEndScreenCoord) >> SST_OVERLAY_Y_SHIFT) & 0xfff; - - ovlWidth += 1; - ovlHeight += 1; - - /* Check to see if the screen and overlay dimensions match. - * There are two cases that can happen in reality. - * - * scrXXX > appXXX: This is a 'real' case, and the overlay dimension - * needs to mag scaled so that it fits the requested size. - * - * (scrXXX == appXXX) && (ovlXXX != scrXXX): This is a somewhat artificial - * case where someone left the overlay set to some value, and these did - * not get reset in the setVideoMode processing. (For example, if the user is - * running an application which bus masters data directly to our video overlay - * when launching a glide application). In this case we need to fiddle w/ the - * overlay dimension so that it matches the requested resolution. - * - * (scrXXX < appXXX): If setVideoMode is actually working correctly, this cannot - * happen because that code has to know that we can't do min scaling. - */ - - if (scrWidth > bInfo->vidInfo.xRes) { - vidProcCfg |= SST_OVERLAY_HORIZ_SCALE_EN; - - ovlWidth = scrWidth; - - scale = ((float) bInfo->vidInfo.xRes) / ((float) ovlWidth); - - vidOverlayDudx = (FxU32) (scale * ((float) (1 << 20))); - HWC_IO_STORE(bInfo->regInfo, vidOverlayDudx, vidOverlayDudx); - } else if (ovlWidth != scrWidth) { - ovlWidth = scrWidth; - } - - if (scrHeight > bInfo->vidInfo.yRes) { - vidProcCfg |= SST_OVERLAY_VERT_SCALE_EN; - - ovlHeight = scrHeight; - - scale = ((float) bInfo->vidInfo.yRes) / ((float) ovlHeight); - - vidOverlayDvdy = (FxU32) (scale * ((float) (1 << 20))); - HWC_IO_STORE(bInfo->regInfo, vidOverlayDvdy, vidOverlayDvdy); - } else if (ovlHeight != scrHeight) { - ovlHeight = scrHeight; - } - - vidOverlayEndScreenCoord = (((ovlHeight - 1) << SST_OVERLAY_Y_SHIFT) | - ((ovlWidth - 1) << SST_OVERLAY_X_SHIFT)); - HWC_IO_STORE(bInfo->regInfo, vidOverlayEndScreenCoord, vidOverlayEndScreenCoord); - - vidProcCfg &= ~SST_OVERLAY_FILTER_MODE; - if (GETENV("SSTH3_OVERLAY_FILTER_2x2")) { - if (!(vidProcCfg & SST_VIDEO_2X_MODE_EN)) - vidProcCfg |= SST_OVERLAY_FILTER_2X2; - } else { - vidProcCfg |= SST_OVERLAY_FILTER_4X4; - } - - HWC_IO_STORE(bInfo->regInfo, vidProcCfg, vidProcCfg); - - finalVidProcCfg = vidProcCfg; - - /* Get miscInit0 for y-sub */ - HWC_IO_LOAD(bInfo->regInfo, miscInit0, miscInit0); - - /* Clear out relavent bits */ - miscInit0 &= ~SST_YORIGIN_TOP; - miscInit0 |= ((bInfo->vidInfo.yRes - 1) << SST_YORIGIN_TOP_SHIFT); - - HWC_IO_STORE(bInfo->regInfo, miscInit0, miscInit0); - - /* Set up lfbMemoryConfig */ - lfbMemoryConfig = - (bInfo->fbOffset >> 12) | - SST_RAW_LFB_ADDR_STRIDE_4K | - (bInfo->buffInfo.bufStrideInTiles << SST_RAW_LFB_TILE_STRIDE_SHIFT); - - HWC_IO_STORE(bInfo->regInfo, lfbMemoryConfig, lfbMemoryConfig); - - finalLfbMemoryCfg = lfbMemoryConfig; - - /* Set up dramInit1 for triple or double buffering */ - HWC_IO_LOAD(bInfo->regInfo, dramInit1, dramInit1); - if (bInfo->vidInfo.tripleBuffering) - dramInit1 |= SST_TRIPLE_BUFFER_EN; - else - dramInit1 &= ~SST_TRIPLE_BUFFER_EN; - HWC_IO_STORE(bInfo->regInfo, dramInit1, dramInit1); - - HWC_IO_STORE(bInfo->regInfo, vidMaxRGBDelta, 0x100810); - - HWC_IO_STORE( bInfo->regInfo, vidDesktopOverlayStride, - ( bInfo->buffInfo.bufStrideInTiles << 16 ) | - bInfo->buffInfo.bufStrideInTiles ); - - HWC_IO_LOAD( bInfo->regInfo, vidDesktopOverlayStride, finalVidDesktopOverlayStride); - - return FXTRUE; -} - -void repaintX() { - XSetWindowAttributes xswa; - unsigned long mask=0; - Visual visual; - int win; - - xswa.background_pixmap = None; - mask |= CWBackPixmap; - xswa.override_redirect = True; - xswa.backing_store = NotUseful; - xswa.save_under = False; - mask |= (CWOverrideRedirect | CWBackingStore | CWSaveUnder); - visual.visualid = CopyFromParent; - win = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, - screenWidth, screenHeight, 0, - DefaultDepth(dpy, screenNum), InputOutput, &visual, - mask, &xswa); - XMapWindow (dpy, win); -} - -FxBool -hwcRestoreVideo(hwcBoardInfo *bInfo) { - FxU32 depth; - - /* Disable FIFO */ - do { - HWC_CAGP_LOAD(bInfo->regInfo, cmdFifo0.depth, depth); - } while (depth); - - HWC_CAGP_STORE(bInfo->regInfo, cmdFifo0.baseSize, 0); - HWC_IO_STORE(bInfo->regInfo, lfbMemoryConfig, saveLfbMemoryConfig); - HWC_IO_STORE(bInfo->regInfo, vidProcCfg, saveVidProcCfg); - HWC_IO_STORE(bInfo->regInfo, miscInit0, saveMiscInit0); - if (!dpy) return FXTRUE; - if (XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), vidModes[0])==False) { - GDBG_INFO(80, "Failed to return to previous video mode\n"); - } - if (inDGA) { - XF86DGADirectVideo(dpy, DefaultScreen(dpy), 0); - inDGA=0; - } - if (vidModes) { - XFree(vidModes); - vidModes=0; - } - repaintX(); - XCloseDisplay(dpy); - dpy=0; - return FXTRUE; -} - -static FxU32 -calcBufferStride(FxU32 xres, FxBool tiled) -{ - FxU32 - strideInTiles; - - if (tiled == FXTRUE) { - /* Calculate tile width stuff */ - strideInTiles = (xres << 1) >> 7; - if ((xres << 1) & (HWC_TILE_WIDTH - 1)) - strideInTiles++; - - return (strideInTiles * HWC_TILE_WIDTH); - - } else { - return (xres << 1); - } -} /* calcBufferStride */ - -static FxU32 -calcBufferHeightInTiles(FxU32 yres) -{ - FxU32 - heightInTiles; /* Height of buffer in tiles */ - - - /* Calculate tile height stuff */ - heightInTiles = yres >> 5; - - if (yres & (HWC_TILE_HEIGHT - 1)) - heightInTiles++; - - return heightInTiles; - -} /* calcBufferHeightInTiles */ - -static FxU32 -calcBufferSizeInTiles(FxU32 xres, FxU32 yres) { - FxU32 - bufSizeInTiles; /* Size of buffer in tiles */ - - bufSizeInTiles = - calcBufferHeightInTiles(yres) * (calcBufferStride(xres, FXTRUE) >> 7); - - return bufSizeInTiles; - -} /* calcBufferSizeInTiles */ - -static FxU32 -calcBufferSize(FxU32 xres, FxU32 yres, FxBool tiled) -{ - FxU32 - stride, - height, - bufSize; /* Size of buffer in bytes */ - - if (tiled) { - stride = calcBufferStride(xres, tiled); - height = HWC_TILE_HEIGHT * calcBufferHeightInTiles(yres); - } else { - stride = xres << 1; - height = yres; - } - - bufSize = stride * height; - - return bufSize; - -} /* calcBufferSize */ - -FxBool -hwcCheckMemSize(hwcBoardInfo *bInfo, FxU32 xres, FxU32 yres, FxU32 nColBuffers, - FxU32 nAuxBuffers, FxBool tiled) -{ -#define FN_NAME "hwcCheckMemSize" - FxU32 - bufSize, totSize; - - bufSize = calcBufferSize(xres, yres, tiled); - - totSize = (nColBuffers + nAuxBuffers) * bufSize; - - if (totSize < ((bInfo->h3Mem << 20) - 0x200000)) /* Need 2M for texture */ - return FXTRUE; - else - return FXFALSE; -#undef FN_NAME -} /* hwcCheckMemSize */ - -static FxU32 -pow2Round(FxU32 val, FxU32 pow2Const) -{ - const FxU32 pow2Mask = (pow2Const - 1UL); - - return ((val + pow2Mask) & ~pow2Mask); -} - -static FxU32 -hwcBufferLfbAddr(FxU32 bufNum, - const hwcBoardInfo* bInfo, - FxBool colBufAlignP) -{ - FxU32 retVal = 0x00UL; - - if (bInfo->vidInfo.tiled) { - retVal = (bInfo->fbOffset + - pow2Round(bufNum * bInfo->vidInfo.yRes * HWC_TILED_BUFFER_BYTES, - HWC_TILED_BUFFER_Y_ALIGN) + - (colBufAlignP ? HWC_TILED_BUFFER_X_ADJUST : 0)); - } else if (bufNum < bInfo->buffInfo.nColBuffers) { - retVal = bInfo->buffInfo.colBuffStart[bufNum]; - } else if (bufNum == bInfo->buffInfo.nColBuffers) { - retVal = bInfo->buffInfo.auxBuffStart; - } - - return retVal; -} - -FxU32 -hwcInitAGPFifo(hwcBoardInfo *bInfo, FxBool enableHoleCounting) -{ - return hwcInitFifo(bInfo, enableHoleCounting); -} - -#define RED_SHIFT 16 -#define GREEN_SHIFT 8 -#define BLUE_SHIFT 0 - -FxBool -hwcGammaTable(hwcBoardInfo *bInfo, FxU32 nEntries, FxU32 *r, FxU32 *g, FxU32 *b) -{ -#define FN_NAME "hwcGammaTable" - FxU32 gRamp[256]; - FxU32 i; - FxU32 vidProcCfg; - FxU32 dacBase; - FxU32 rDacBase; - FxU32 rDacData; - - /* Load the table into the Display driver as above */ - for (i = 0; i < nEntries; i++) { - gRamp[i] = - ((r[i] & 0xff) << RED_SHIFT) | - ((g[i] & 0xff) << GREEN_SHIFT) | - ((b[i] & 0xff) << BLUE_SHIFT); - } - - /* - ** On W9X/DOS, we can do this ourselves--which is much easier than - ** mucking about with a bunch of 32-bit data in 16-bit driver - ** code. - */ - HWC_IO_LOAD( bInfo->regInfo, vidProcCfg, vidProcCfg); - - /* Determin which set of CLUT entries are selected */ - if (vidProcCfg & SST_OVERLAY_CLUT_SELECT) - dacBase = 256; - else - dacBase = 0; - - /* Print out some useful info RE the vidProcCfg register */ - GDBG_INFO(80, "%s: vidProcCFG(SST_OVERLAY_CLUT_SELECT) = %d\n", - FN_NAME, (vidProcCfg & SST_OVERLAY_CLUT_SELECT) ? 1 : 0); - GDBG_INFO(80, "%s: vidProcCFG(SST_OVERLAY_EN) = %d\n", - FN_NAME, (vidProcCfg & SST_OVERLAY_EN) ? 1 : 0); - GDBG_INFO(80, "%s: vidProcCFG(SST_OVERLAY_CLUT_BYPASS) = %d\n", - FN_NAME, (vidProcCfg & SST_OVERLAY_CLUT_BYPASS) ? 1 : 0); - - for (i = 0; i < nEntries; i++) { - int repeat = 100; - do { - HWC_IO_STORE( bInfo->regInfo, dacAddr, dacBase + i); - P6FENCE; - HWC_IO_LOAD( bInfo->regInfo, dacAddr, rDacBase); - P6FENCE; - repeat--; - } while (repeat && rDacBase != dacBase + i); - if (!repeat) { - GDBG_INFO(0, "%s:Error Writting DacAddr %d. DacBase =%d\n", - FN_NAME, dacBase+i, dacBase); - } - repeat = 100; - do { - HWC_IO_STORE( bInfo->regInfo, dacData, gRamp[i]); - P6FENCE; - HWC_IO_LOAD( bInfo->regInfo, dacData, rDacData); - P6FENCE; - repeat--; - } while (repeat && rDacData != gRamp[i]); - if (!repeat) { - GDBG_INFO(0, "%s:Error Writting Data [%d, %x]. DacBase =%d\n", - FN_NAME, i, gRamp[i], dacBase); - } - } - - return FXTRUE; - -#undef FN_NAME -} /* hwcGammaTable */ - -FxBool -hwcGammaRGB(hwcBoardInfo *bInfo, float gammaR, float gammaG, float gammaB) -{ -#define FN_NAME "hwcGammaRGB" - FxU32 - grRamp[256], ggRamp[256], gbRamp[256]; - int - i; - - GDBG_INFO(80, FN_NAME "(0x%x, %1.2f, %1.2f, %1.2f)\n", - bInfo, gammaR, gammaG, gammaB); - - /* - ** NB: The system eventually devised by Bob and Ken *may* require - ** separate R, G, and B vectors. - */ - - for (i = 0; i < 256; i++) { - grRamp[i] = (FxU32)((pow(i/255.0F, 1.0F/gammaR)) * 255.0F + 0.5F); - ggRamp[i] = (FxU32)((pow(i/255.0F, 1.0F/gammaG)) * 255.0F + 0.5F); - gbRamp[i] = (FxU32)((pow(i/255.0F, 1.0F/gammaB)) * 255.0F + 0.5F); - } - - hwcGammaTable(bInfo, 256, grRamp, ggRamp, gbRamp); - - /* - ** Now that we have a gamma table, we can give it to the driver via - ** a call to ExtEscape() when that is defined..... - */ - - return FXFALSE; - -#undef FN_NAME -} /* hwcGammaRGB */ - -#define M 1 -#define K 1 - -FxBool -hwcSetGrxClock(hwcBoardInfo *bInfo, FxU32 speedInMHz) -{ -#define FN_NAME "hwcSetGrxClock" - FxU32 - pllCtrl1, - dramInit0 = 0xc17ae29, - dramInit1 = 0x26c031, - n, - m = 1; - - n = (FxU32) ((speedInMHz - 4.76f)/2.38f); - - pllCtrl1 = - (K << SST_PLL_K_SHIFT) | (m << SST_PLL_M_SHIFT) | (n << SST_PLL_N_SHIFT); - - GDBG_INFO(80, "%s: Setting Graphics Clock to %d\n", FN_NAME, speedInMHz); - - HWC_IO_STORE( bInfo->regInfo, dramInit0, dramInit0); - HWC_IO_STORE( bInfo->regInfo, dramInit1, dramInit1); - HWC_IO_STORE( bInfo->regInfo, pllCtrl1, pllCtrl1); - - return FXTRUE; - -#undef FN_NAME -} /* hwcSetGrxClock */ - -FxBool -hwcSetMemClock(hwcBoardInfo *bInfo, FxU32 speedInMHz) -{ -#define FN_NAME "hwcSetMemClock" - return FXFALSE; -#undef FN_NAME -} /* hwcSetMemClock */ - -char * -hwcGetenv(char *a) -{ - envitem *ptr; - - char *result; - result=getenv(a); - if (result) return result; - if (!envinit) loadEnvFile(); - ptr=first; - while (ptr) { - if (!strcmp(ptr->env, a)) return ptr->val; - ptr=ptr->next; - } - return 0; -} - -FxBool -hwcResolutionSupported(hwcBoardInfo *bInfo, GrScreenResolution_t res) -{ -#define FN_NAME "hwcResolutionSupported" - - /* For now we're just going to retur TRUE. We should check with - vmode extension to see if the requested size is available */ - return FXTRUE; - -#undef FN_NAME -} /* hwcResolutionSupported */ diff --git a/glide3x/h3/minihwc/minihwc.c b/glide3x/h3/minihwc/minihwc.c index dd578d3..0f14240 100644 --- a/glide3x/h3/minihwc/minihwc.c +++ b/glide3x/h3/minihwc/minihwc.c @@ -19,6 +19,9 @@ ** ** $Header$ ** $Log$ +** Revision 1.1.1.1.6.2 2003/06/21 12:43:04 dborca +** h3cinit cleanup +** ** Revision 1.1.1.1.6.1 2003/05/05 07:12:47 dborca ** no message ** @@ -585,6 +588,8 @@ modify [eax]; /* [dBorca] */ #elif defined(__DJGPP__) #define P6FENCE __asm __volatile ("xchg %%eax, _fenceVar":::"%eax"); +#elif defined(__linux__) +#define P6FENCE __asm __volatile ("xchg %%eax, fenceVar":::"%eax") #else #error "P6 Fencing in-line assembler code needs to be added for this compiler" #endif /* Compiler specific fence commands */ @@ -3202,7 +3207,7 @@ hwcInitVideo(hwcBoardInfo *bInfo, FxBool tiled, FxVideoTimingInfo *vidTiming, } #endif -#ifdef __DOS32__ +#ifndef __WIN32__ /* DOS and Linux */ /* Now call the cinit code */ h3InitVideoOverlaySurface( @@ -3439,7 +3444,7 @@ hwcInitVideo(hwcBoardInfo *bInfo, FxBool tiled, FxVideoTimingInfo *vidTiming, ( bInfo->buffInfo.bufStrideInTiles << 16 ) | bInfo->buffInfo.bufStrideInTiles ); -#ifdef __DJGPP__ +#if defined(__DJGPP__) || defined(__linux__) HWC_IO_STORE(bInfo->regInfo, vidProcCfg, vidProcCfg | SST_VIDEO_PROCESSOR_EN); #endif @@ -4083,6 +4088,9 @@ hwcGetenv(char *a) RegCloseKey(hKey); } return (char*)retVal; +#elif defined(__linux__) + extern char *file_getenv (const char *a); + return file_getenv(a); #else return getenv(a); #endif @@ -4209,7 +4217,7 @@ hwcShareContextData(hwcBoardInfo *bInfo, FxU32 **data) ctxRes.optData.shareContextDWORDRes.contextDWORD); /* [dBorca] that must be initialized to something... */ -#elif defined(__DJGPP__) +#elif defined(__DJGPP__) || defined(__linux__) *data = &dummyContextDWORD; #endif return retVal; diff --git a/glide3x/h5/glide3/src/fxglide.h b/glide3x/h5/glide3/src/fxglide.h index 48e5070..9e9c980 100644 --- a/glide3x/h5/glide3/src/fxglide.h +++ b/glide3x/h5/glide3/src/fxglide.h @@ -3260,7 +3260,7 @@ static GrLOD_t g3LodXlat_base[2] = { GR_LOD_LOG2_256, GR_LOD_LOG2_2048 }; (g3LodXlat_base[tBig] - someLOD) #endif -GR_ENTRY(grTexDownloadTableExt, +GR_EXT_ENTRY(grTexDownloadTableExt, void, (GrChipID_t tmu, GrTexTable_t type, void *data)); diff --git a/glide3x/h5/glide3/src/gtexdl.c b/glide3x/h5/glide3/src/gtexdl.c index dfe189a..ce6408c 100644 --- a/glide3x/h5/glide3/src/gtexdl.c +++ b/glide3x/h5/glide3/src/gtexdl.c @@ -348,7 +348,7 @@ GR_DDFUNC(_grTexDownloadNccTableExt, gc->stats.palDownloads++; gc->stats.palBytes += (end-start+1)<<2; - if (gc->tmu_state[tmu].ncc_table[which] != table) { + /*if (gc->tmu_state[tmu].ncc_table[which] != table)*/ { SstRegs* texHW; int i; #ifdef GLIDE_POINTCAST_PALETTE @@ -652,7 +652,7 @@ GR_DDFUNC(_grTexDownloadPaletteExt, Return: none -------------------------------------------------------------------*/ -GR_ENTRY(grTexDownloadTableExt, +GR_EXT_ENTRY(grTexDownloadTableExt, void, (GrChipID_t tmu, GrTexTable_t type, void *data)) { @@ -664,10 +664,10 @@ GR_ENTRY(grTexDownloadTableExt, switch(type) { case GR_TEXTABLE_PALETTE: case GR_TEXTABLE_PALETTE_6666_EXT: - _grTexDownloadPalette(tmu, type, (GuTexPalette *)data, 0, 255); + _grTexDownloadPaletteExt(tmu, type, (GuTexPalette *)data, 0, 255); break; default: /* Type is an ncc table */ - _grTexDownloadNccTable(tmu, type, (GuNccTable*)data, 0, 11); + _grTexDownloadNccTableExt(tmu, type, (GuNccTable*)data, 0, 11); break; } @@ -705,7 +705,7 @@ GR_DDFUNC(_grTexDownloadNccTable, gc->stats.palDownloads++; gc->stats.palBytes += (end-start+1)<<2; - if (gc->tmu_state[tmu].ncc_table[which] != table) { + /*if (gc->tmu_state[tmu].ncc_table[which] != table)*/ { SstRegs* texHW; int i; #ifdef GLIDE_POINTCAST_PALETTE diff --git a/glide3x/h5/glide3/src/xdraw2.asm b/glide3x/h5/glide3/src/xdraw2.asm index b3777ba..83855c7 100644 --- a/glide3x/h5/glide3/src/xdraw2.asm +++ b/glide3x/h5/glide3/src/xdraw2.asm @@ -19,6 +19,10 @@ ;; $Header$ ;; $Revision$ ;; $Log$ +;; Revision 1.1.8.8 2003/09/12 05:11:45 koolsmoky +;; preparing for graphic context checks +;; fixed jmp errors +;; ;; Revision 1.1.8.7 2003/07/07 23:29:06 koolsmoky ;; cleaned logs ;; @@ -223,7 +227,7 @@ Y equ 4 %ENDM ;; enables/disables trisProcessed and trisDrawn counters -STATS equ 1 +%define STATS 1 ;; NB: All of the base triangle procs expect to have the gc ;; passed from the caller in edx so that we can avoid diff --git a/glide3x/h5/glide3/src/xdraw2.inc b/glide3x/h5/glide3/src/xdraw2.inc index d3efe7f..af04ffc 100644 --- a/glide3x/h5/glide3/src/xdraw2.inc +++ b/glide3x/h5/glide3/src/xdraw2.inc @@ -20,6 +20,10 @@ ;; $Header$ ;; $Revision$ ;; $Log$ +;; Revision 1.1.8.7 2003/09/12 05:11:45 koolsmoky +;; preparing for graphic context checks +;; fixed jmp errors +;; ;; Revision 1.1.8.6 2003/07/07 23:29:06 koolsmoky ;; cleaned logs ;; @@ -123,7 +127,7 @@ ;; lea eax, [esp+ _va$] ; pointer to vertex pointers ;; test esi, esi ; window coordinates ? ;; -;; jz win_coordinates ; yup +;; jz .win_coordinates ; yup ;; ;; invoke _grDrawTriangles, 1, 3, eax; draw the triangle in clip coordinate space ;; @@ -135,7 +139,7 @@ ;; ;; ret ; return, pop 3 DWORD arguments off stack ;; -;;win_coordinates: +;;.win_coordinates: ;;%endif ; GLIDE_CLIP_COORDS %if GLIDE_VALIDATE_STATE @@ -260,7 +264,7 @@ ;; lea eax, [esp+ _va$] ; pointer to vertex pointers ;; test edx, edx ; window coordinates ? ;; -;; jz win_coordinates ; yup +;; jz .win_coordinates ; yup ;; ;; invoke _grDrawTriangles, 1, 3, eax; draw the triangle in coordinate space ;; @@ -273,7 +277,7 @@ ;; ret ; return, pop 3 DWORD arguments off stack ;; ;; ALIGN 16 -;;win_coordinates: +;;.win_coordinates: ;; ;;%endif @@ -702,7 +706,7 @@ ;; lea eax, [esp+ _va$] ; pointer to vertex pointers ;; test esi, esi ; window coordinates ? ;; -;; jz win_coordinates ; yup +;; jz .win_coordinates ; yup ;; ;; invoke _grDrawTriangles, 1, 3, eax; draw the triangle in clip coordinate space ;; @@ -714,7 +718,7 @@ ;; ;; ret ; return, pop 3 DWORD arguments off stack ;; -;;win_coordinates: +;;.win_coordinates: ;;%endif ; GLIDE_CLIP_COORDS %if GLIDE_VALIDATE_STATE @@ -837,7 +841,7 @@ ;; lea eax, [esp+ _va$] ; pointer to vertex pointers ;; test edx, edx ; window coordinates ? ;; -;; jz win_coordinates ; yup +;; jz .win_coordinates ; yup ;; ;; invoke _grDrawTriangles, 1, 3, eax; draw the triangle in coordinate space ;; @@ -850,7 +854,7 @@ ;; ret ; return, pop 3 DWORD arguments off stack ;; ;; ALIGN 16 -;;win_coordinates: +;;.win_coordinates: ;; ;;%endif @@ -1249,7 +1253,7 @@ db 00h db 00h - add eax, DWORD PTR __GlideRoot + tlsOffset + add eax, DWORD [_GlideRoot + tlsOffset] mov gc, [eax] %ELSE mov gc, edx diff --git a/glide3x/h5/glide3/src/xdraw3.asm b/glide3x/h5/glide3/src/xdraw3.asm index c8fabd8..d5111d3 100644 --- a/glide3x/h5/glide3/src/xdraw3.asm +++ b/glide3x/h5/glide3/src/xdraw3.asm @@ -35,7 +35,7 @@ extrn _grCommandTransportMakeRoom, 12 segment CONST ALIGN 8 -_F256_F256 DD 43800000h, 43800000h ; 256 | 256 +_F256_F256 DD 256.0, 256.0 segment DATA ALIGN 8 diff --git a/glide3x/makefile.linux b/glide3x/makefile.linux index 29b607f..006b7d7 100644 --- a/glide3x/makefile.linux +++ b/glide3x/makefile.linux @@ -1,4 +1,4 @@ -# Linux makefile for Glide3(h5) and Texus2 +# Linux makefile for Glide3 and Texus2 # # Copyright (c) 2003 - Borca Daniel # Email : dborca@users.sourceforge.net @@ -12,31 +12,45 @@ # Available options: # # Environment variables: +# FX_GLIDE_HW build for the given ASIC (cvg, h3, h5). +# default = h5 # DRI=1 Build DRI version. +# target = h3, h5 # default = no # DGA=1 Build DGA version (experimental). +# target = h3, h5 # default = no # XPATH specify X libraries path; needed by DRI and DGA. +# target = h3, h5 # default = /usr/X11/lib # H4=1 Avenger/Napalm. +# target = h3, h5 # default = no # CPU optimize for the given processor. +# target = cvg, h3, h5 # default = pentium # DEBUG=1 disable optimizations and build for debug. +# target = cvg, h3, h5 # default = no -# USE_X86=1 use assembler triangle specializations. +# USE_X86=1 use assembler triangle specializations; req by CVG +# target = cvg, h3, h5 # default = no # USE_3DNOW=1 allow 3DNow! specializations. However, the true CPU # capabilities are still checked at run-time to avoid # crashes. +# target = cvg, h3, h5 # default = no # USE_MMX=1 (see USE_3DNOW) +# target = h5 # default = no # USE_SSE=1 (see USE_3DNOW) +# target = h5 # default = no # USE_SSE2=1 (see USE_3DNOW) +# target = h5 # default = no -# TEXUS2=1 embed Texus2 functions into Glide3 library. +# TEXUS2=1 embed Texus2 functions into Glide3. +# target = cvg, h3, h5 # default = no # # Targets: @@ -62,7 +76,7 @@ GLIDE_LIB = libglide3.a GLIDE_SO = libglide3.so TEXUS_EXE = texus2 -FX_GLIDE_HW = h5 +FX_GLIDE_HW ?= h5 FX_GLIDE_SW = swlibs GLIDE_LIBDIR = $(FX_GLIDE_HW)/lib TEXUS_EXEDIR = $(FX_GLIDE_SW)/bin @@ -83,8 +97,9 @@ CP = cp ############################################################################### # platform -XPATH ?= /usr/X11/lib CDEFS = -D__linux__ +ifneq ($(FX_GLIDE_HW),cvg) +XPATH ?= /usr/X11/lib ifeq ($(DRI),1) CDEFS += -DDRI_BUILD LDFLAGS = -L$(XPATH) @@ -95,17 +110,23 @@ CDEFS += -DUSE_XDGA_SWITCH=1 LDFLAGS = -L$(XPATH) LDLIBS = -lX11 -lXext -lXxf86dga endif +endif # general -CDEFS += -DGLIDE3 -DGLIDE3_ALPHA -DGLIDE_HW_TRI_SETUP=1 -DGLIDE_INIT_HWC -DGLIDE_PACKED_RGB=0 -DGLIDE_PACKET3_TRI_SETUP=1 -DGLIDE_TRI_CULLING=1 -DH3 -DUSE_PACKET_FIFO=1 +CDEFS += -DGLIDE3 -DGLIDE3_ALPHA -DGLIDE_HW_TRI_SETUP=1 -DGLIDE_INIT_HWC -DGLIDE_PACKED_RGB=0 -DGLIDE_PACKET3_TRI_SETUP=1 -DGLIDE_TRI_CULLING=1 -DUSE_PACKET_FIFO=1 # subsystem +ifeq ($(FX_GLIDE_HW),cvg) +CDEFS += -DCVG +else +CDEFS += -DH3 ifdef H4 CDEFS += -DH4 endif ifeq ($(FX_GLIDE_HW),h5) CDEFS += -DFX_GLIDE_H5_CSIM=1 -DFX_GLIDE_NAPALM=1 endif +endif # debug ifdef DEBUG @@ -115,7 +136,14 @@ endif # other CDEFS += -DGLIDE_PLUG -DGLIDE_SPLASH #CDEFS += -DGLIDE_LIB +ifeq ($(FX_GLIDE_HW),cvg) +#CDEFS += -DGLIDE3_SCALER +CDEFS += -DGLIDE_DISPATCH_SETUP -DGLIDE_DISPATCH_DOWNLOAD +CDEFS += -DINIT_LINUX +CDEFS += -D__3Dfx_PCI_CFG__ +else #CDEFS += -DGLIDE_CHECK_CONTEXT +endif ############################################################################### # flags @@ -139,11 +167,21 @@ CPU ?= pentium CFLAGS += -O2 -ffast-math -mcpu=$(CPU) endif -CFLAGS += -I$(FX_GLIDE_HW)/glide3/src -I$(FX_GLIDE_HW)/incsrc -I$(FX_GLIDE_HW)/minihwc -I$(FX_GLIDE_HW)/cinit +CFLAGS += -I$(FX_GLIDE_HW)/glide3/src -I$(FX_GLIDE_HW)/incsrc -I$(FX_GLIDE_HW)/minihwc -I$(FX_GLIDE_HW)/cinit -I$(FX_GLIDE_HW)/init CFLAGS += -I$(FX_GLIDE_SW)/fxmisc -I$(FX_GLIDE_SW)/newpci/pcilib -I$(FX_GLIDE_SW)/fxmemmap CFLAGS += -I$(FX_GLIDE_SW)/texus2/lib CFLAGS += $(CDEFS) +ifeq ($(FX_GLIDE_HW),cvg) +override USE_X86 = 1 +else +ifeq ($(FX_GLIDE_HW),h3) +override USE_MMX = 0 +override USE_SSE = 0 +override USE_SSE2 = 0 +endif +endif + ifeq ($(USE_3DNOW),1) CFLAGS += -DGL_AMD3D override USE_X86 = 1 @@ -170,10 +208,14 @@ endif ############################################################################### GLIDE_OBJECTS = \ + $(FX_GLIDE_HW)/glide3/src/fifo.o \ + $(FX_GLIDE_HW)/glide3/src/distate.o \ + $(FX_GLIDE_HW)/glide3/src/gstrip.o \ + $(FX_GLIDE_HW)/glide3/src/distrip.o \ + $(FX_GLIDE_HW)/glide3/src/diget.o \ $(FX_GLIDE_HW)/glide3/src/gsplash.o \ $(FX_GLIDE_HW)/glide3/src/g3df.o \ $(FX_GLIDE_HW)/glide3/src/gu.o \ - $(FX_GLIDE_HW)/glide3/src/gthread.o \ $(FX_GLIDE_HW)/glide3/src/gpci.o \ $(FX_GLIDE_HW)/glide3/src/diglide.o \ $(FX_GLIDE_HW)/glide3/src/disst.o \ @@ -183,15 +225,15 @@ GLIDE_OBJECTS = \ $(FX_GLIDE_HW)/glide3/src/gaa.o \ $(FX_GLIDE_HW)/glide3/src/gdraw.o \ $(FX_GLIDE_HW)/glide3/src/gglide.o \ - $(FX_GLIDE_HW)/glide3/src/distate.o \ - $(FX_GLIDE_HW)/glide3/src/gstrip.o \ - $(FX_GLIDE_HW)/glide3/src/distrip.o \ - $(FX_GLIDE_HW)/glide3/src/diget.o \ $(FX_GLIDE_HW)/glide3/src/glfb.o \ $(FX_GLIDE_HW)/glide3/src/gsst.o \ $(FX_GLIDE_HW)/glide3/src/gtex.o \ $(FX_GLIDE_HW)/glide3/src/gtexdl.o \ - $(FX_GLIDE_HW)/glide3/src/fifo.o + $(FX_GLIDE_HW)/glide3/src/cpuid.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxpci.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxlinux.o \ + $(FX_GLIDE_SW)/fxmisc/linutil.o \ + $(FX_GLIDE_HW)/glide3/src/xtexdl_def.o ifeq ($(USE_X86),1) GLIDE_OBJECTS += \ @@ -221,25 +263,36 @@ GLIDE_OBJECTS += \ $(FX_GLIDE_HW)/glide3/src/gxdraw.o endif +ifeq ($(FX_GLIDE_HW),cvg) GLIDE_OBJECTS += \ - $(FX_GLIDE_HW)/glide3/src/xtexdl_def.o - + $(FX_GLIDE_HW)/glide3/src/digutex.o \ + $(FX_GLIDE_SW)/newpci/pcilib/fxmsr.o \ + $(FX_GLIDE_HW)/init/canopus.o \ + $(FX_GLIDE_HW)/init/dac.o \ + $(FX_GLIDE_HW)/init/gamma.o \ + $(FX_GLIDE_HW)/init/gdebug.o \ + $(FX_GLIDE_HW)/init/info.o \ + $(FX_GLIDE_HW)/init/parse.o \ + $(FX_GLIDE_HW)/init/print.o \ + $(FX_GLIDE_HW)/init/sli.o \ + $(FX_GLIDE_HW)/init/sst1init.o \ + $(FX_GLIDE_HW)/init/util.o \ + $(FX_GLIDE_HW)/init/video.o \ + $(FX_GLIDE_HW)/init/fxremap.o +else GLIDE_OBJECTS += \ - $(FX_GLIDE_HW)/glide3/src/cpuid.o \ - $(FX_GLIDE_SW)/newpci/pcilib/fxpci.o \ - $(FX_GLIDE_SW)/newpci/pcilib/fxlinux.o \ - $(FX_GLIDE_SW)/fxmisc/linutil.o \ + $(FX_GLIDE_HW)/glide3/src/gthread.o \ $(FX_GLIDE_HW)/minihwc/hwcio.o \ $(FX_GLIDE_HW)/minihwc/gdebug.o \ - ifeq ($(DRI),1) GLIDE_OBJECTS += \ $(FX_GLIDE_HW)/minihwc/linhwc.o else GLIDE_OBJECTS += \ - $(FX_GLIDE_HW)/cinit/h3cinit.o \ $(FX_GLIDE_HW)/minihwc/minihwc.o \ - $(FX_GLIDE_HW)/minihwc/lin_mode.o + $(FX_GLIDE_HW)/minihwc/lin_mode.o \ + h5/cinit/h3cinit.o +endif endif TEXUS_SOURCES = \ @@ -277,6 +330,10 @@ endif .c.o: $(CC) -o $@ $(CFLAGS) -c $< +.S.o: + $(CC) -o $@ $(CFLAGS) -c $< +.s.o: + $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $< .c.lo: $(CC) -o $@ $(CFLAGS) -DPIC -fPIC -c $< @@ -304,6 +361,13 @@ endif # rules(2) ############################################################################### +cvg/glide3/src/xtexdl_def.o: cvg/glide3/src/xtexdl.c + $(CC) -o $@ $(CFLAGS) -c $< +cvg/glide3/src/cpuid.o: cvg/glide3/src/cpudtect.asm + $(AS) -o $@ $(ASFLAGS) $< +h3/glide3/src/cpuid.o: h3/glide3/src/cpudtect.asm + $(AS) -o $@ $(ASFLAGS) $< + $(FX_GLIDE_HW)/glide3/src/xdraw2_def.o: $(FX_GLIDE_HW)/glide3/src/xdraw2.asm $(AS) -o $@ $(ASFLAGS) $< $(FX_GLIDE_HW)/glide3/src/xdraw3_def.o: $(FX_GLIDE_HW)/glide3/src/xdraw3.asm @@ -323,6 +387,13 @@ $(FX_GLIDE_HW)/glide3/src/xdraw3_sse.o: $(FX_GLIDE_HW)/glide3/src/xdraw3.asm $(FX_GLIDE_HW)/glide3/src/xtexdl_sse2.o: $(FX_GLIDE_HW)/glide3/src/xtexdl.asm $(AS) -o $@ $(ASFLAGS) -DGL_SSE2=1 $< +cvg/glide3/src/xtexdl_def.lo: cvg/glide3/src/xtexdl.c + $(CC) -o $@ $(CFLAGS) -DPIC -fPIC -c $< +cvg/glide3/src/cpuid.lo: cvg/glide3/src/cpuid.o + $(CP) $< $@ +h3/glide3/src/cpuid.lo: h3/glide3/src/cpuid.o + $(CP) $< $@ + $(FX_GLIDE_HW)/glide3/src/xdraw2_def.lo: $(FX_GLIDE_HW)/glide3/src/xdraw2_def.o $(CP) $< $@ $(FX_GLIDE_HW)/glide3/src/xdraw3_def.lo: $(FX_GLIDE_HW)/glide3/src/xdraw3_def.o @@ -342,8 +413,10 @@ $(FX_GLIDE_HW)/glide3/src/xdraw3_sse.lo: $(FX_GLIDE_HW)/glide3/src/xdraw3_sse.o $(FX_GLIDE_HW)/glide3/src/xtexdl_sse2.lo: $(FX_GLIDE_HW)/glide3/src/xtexdl_sse2.o $(CP) $< $@ +ifeq ($(FX_GLIDE_HW),h5) GENDATE = $(FX_GLIDE_HW)/incsrc/gendate.h FXBLDNO = $(FX_GLIDE_HW)/glide3/src/fxbldno.h +endif $(GLIDE_OBJECTS): $(FX_GLIDE_HW)/glide3/src/fxinline.h $(FX_GLIDE_HW)/glide3/src/fxgasm.h $(FXBLDNO) @@ -373,22 +446,17 @@ fxbldno: $(FXBLDNO:.h=.c) ############################################################################### clean: - -$(RM) $(FX_GLIDE_HW)/cinit/*.o - -$(RM) $(FX_GLIDE_HW)/cinit/*.lo - -$(RM) $(FX_GLIDE_HW)/glide3/src/*.o - -$(RM) $(FX_GLIDE_HW)/glide3/src/*.lo - -$(RM) $(FX_GLIDE_HW)/minihwc/*.o - -$(RM) $(FX_GLIDE_HW)/minihwc/*.lo - -$(RM) $(FX_GLIDE_SW)/newpci/pcilib/*.o - -$(RM) $(FX_GLIDE_SW)/newpci/pcilib/*.lo - -$(RM) $(FX_GLIDE_SW)/fxmisc/*.o - -$(RM) $(FX_GLIDE_SW)/fxmisc/*.lo + -$(RM) cvg/init/*.[l]o + -$(RM) h5/cinit/*.[l]o + -$(RM) $(FX_GLIDE_HW)/glide3/src/*.[l]o + -$(RM) $(FX_GLIDE_HW)/minihwc/*.[l]o + -$(RM) $(FX_GLIDE_SW)/newpci/pcilib/*.[l]o -$(RM) $(FX_GLIDE_HW)/glide3/src/fxinline.h -$(RM) $(FX_GLIDE_HW)/glide3/src/fxgasm.h -$(RM) $(GENDATE) -$(RM) $(FXBLDNO) - -$(RM) $(FX_GLIDE_SW)/texus2/lib/*.o) - -$(RM) $(FX_GLIDE_SW)/texus2/lib/*.lo) + -$(RM) $(FX_GLIDE_SW)/fxmisc/*.[l]o + -$(RM) $(FX_GLIDE_SW)/texus2/lib/*.[l]o) realclean: clean -$(RM) $(GLIDE_LIBDIR)/$(GLIDE_LIB)