glide2x, h3: converted asm to nasm syntax, adjusted fxgasm.c for it.

it builds for linux now. (not tested though..)
This commit is contained in:
sezero
2018-08-18 17:15:02 +03:00
parent 4e3b368794
commit 14b3357ab8
5 changed files with 498 additions and 556 deletions

View File

@@ -34,7 +34,6 @@
* macros for creating assembler offset files
*----------------------------------------------------------------------*/
#ifndef __linux__
#define NEWLINE printf("\n")
#define COMMENT printf(";----------------------------------------------------------------------\n")
@@ -43,35 +42,16 @@
COMMENT; NEWLINE
#define OFFSET(p,o,pname) if (hex) \
printf("%s\t= %08xh\n",pname,((int)&p.o)-(int)&p); \
else printf("%s\t= %10d\n",pname,((int)&p.o)-(int)&p)
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\t= %08xh\n",pname,((int)&o)-(int)&p); \
else printf("%s\t= %10d\n",pname,((int)&o)-(int)&p)
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\t= %08xh\n",pname,sizeof(p)); \
else printf("SIZEOF_%s\t= %10d\n",pname,sizeof(p))
#else
#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("#define %s\t 0x%08x\n",pname,((int)&p.o)-(int)&p); \
else printf("#define %s\t %10d\n",pname,((int)&p.o)-(int)&p)
#define OFFSET2(p,o,pname) if (hex) \
printf("#define %s\t 0x%08x\n",pname,((int)&o)-(int)&p); \
else printf("#define %s\t %10d\n",pname,((int)&o)-(int)&p)
#define SIZEOF(p,pname) if (hex) \
printf("#define SIZEOF_%s\t 0x%08x\n",pname,sizeof(p)); \
else printf("#define SIZEOF_%s\t %10d\n",pname,sizeof(p))
#endif
printf("SIZEOF_%s\tequ %08xh\n",pname,sizeof(p)); \
else printf("SIZEOF_%s\tequ %10d\n",pname,sizeof(p))
int
main (int argc, char **argv)

View File

@@ -241,24 +241,24 @@ $(GLIDE_LIBDIR)/$(GLIDE_SHARED): $(GLIDE_OBJECTS:.o=.lo)
# rules(2)
###############################################################################
## NASM SUPPORT IS NOT HERE YET...
##
#cpuid.o: cpudtect.asm
# $(AS) -o $@ $(ASFLAGS) $<
#xdraw2_def.o: xdraw2.asm
# $(AS) -o $@ $(ASFLAGS) $<
#xdraw2_3dnow.o: xdraw2.asm
# $(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $<
#xtexdl_3dnow.o: xtexdl.asm
# $(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $<
cpuid.o: cpudtect.S
$(CC) -o $@ -xassembler-with-cpp -c $(CDEFS) $<
xdraw2_def.o: xdraw2.S
$(CC) -o $@ -xassembler-with-cpp -c $(CDEFS) $<
xdraw2_3dnow.o: xdraw2.S
$(CC) -o $@ -xassembler-with-cpp -c $(CDEFS) -DGL_AMD3D=1 $<
xtexdl_3dnow.o: xtexdl.S
$(CC) -o $@ -xassembler-with-cpp -c $(CDEFS) -DGL_AMD3D=1 $<
#using nasm now
#
#cpuid.o: cpudtect.S
# $(CC) -o $@ -xassembler-with-cpp -c $(CDEFS) $<
#xdraw2_def.o: xdraw2.S
# $(CC) -o $@ -xassembler-with-cpp -c $(CDEFS) $<
#xdraw2_3dnow.o: xdraw2.S
# $(CC) -o $@ -xassembler-with-cpp -c $(CDEFS) -DGL_AMD3D=1 $<
#xtexdl_3dnow.o: xtexdl.S
# $(CC) -o $@ -xassembler-with-cpp -c $(CDEFS) -DGL_AMD3D=1 $<
cpuid.o: cpudtect.asm
$(AS) -o $@ $(ASFLAGS) $<
xdraw2_def.o: xdraw2.asm
$(AS) -o $@ $(ASFLAGS) $<
xdraw2_3dnow.o: xdraw2.asm
$(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $<
xtexdl_3dnow.o: xtexdl.asm
$(AS) -o $@ $(ASFLAGS) -DGL_AMD3D=1 $<
cpuid.lo: cpuid.o
$(CP) $< $@

View File

@@ -52,161 +52,143 @@
; B4 Chip field fix.
;;
TITLE xdraw2.asm
OPTION OLDSTRUCTS
%include "xos.inc"
.586P
.MMX
.K3D
extrn _GlideRoot
extrn _FifoMakeRoom
EXTRN __GlideRoot: DWORD
EXTRN __FifoMakeRoom: NEAR
_DATA SEGMENT
One DD 03f800000r
segment SEG_DATA
One DD 1.0
Area DD 0
IF GLIDE_PACKED_RGB
%if GLIDE_PACKED_RGB
bias0 DD 0
bias1 DD 0
ENDIF
_DATA ENDS
%endif
; Ugly, but seems to workaround the problem with locally defined
; data segment globals not getting relocated properly when using
; djgpp.
zArea TEXTEQU <One+04h>
%define zArea One+04h
;;; Definitions of cvg regs and glide root structures.
INCLUDE fxgasm.h
%include "fxgasm.h"
; 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
PROC_TYPE MACRO procType:=<Default>
IFDEF GL_AMD3D
EXITM <__trisetup_3DNow_&procType&@12>
ELSE
EXITM <__trisetup_Default_&procType&@12>
ENDIF
ENDM
X equ 0
Y equ 4
%MACRO PROC_TYPE 1
%IFDEF GL_AMD3D
proc _trisetup_3DNow_%1, 12
%ELSE
proc _trisetup_Default_%1, 12
%ENDIF
%ENDM
;--------------------------------------------------------------------------
_TEXT SEGMENT PAGE PUBLIC USE32 'CODE'
ASSUME DS: FLAT, SS: FLAT
segment SEG_TEXT
ALIGN 32
PROC_TYPE cull
%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
endp
ALIGN 32
PUBLIC PROC_TYPE(cull)
PROC_TYPE(cull) PROC NEAR
%IF GLIDE_PACKED_RGB
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>
PROC_TYPE cull_rgb
PROC_TYPE(cull) ENDP
%define GLIDE_CULLING 1
%define GLIDE_PACK_RGB 1
%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
endp
ALIGN 32
PROC_TYPE cull_argb
%define GLIDE_CULLING 1
%define GLIDE_PACK_RGB 1
%define GLIDE_PACK_ALPHA 1
%define GLIDE_GENERIC_SETUP 0
%INCLUDE "xdraw2.inc"
%undef GLIDE_GENERIC_SETUP
%undef GLIDE_PACK_ALPHA
%undef GLIDE_PACK_RGB
%undef GLIDE_CULLING
endp
%ENDIF ; GLIDE_PACKED_RGB
ALIGN 32
PROC_TYPE Default
%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
endp
ALIGN 32
IF GLIDE_PACKED_RGB
PUBLIC PROC_TYPE(cull_rgb)
PROC_TYPE(cull_rgb) PROC NEAR
%IF GLIDE_PACKED_RGB
GLIDE_CULLING textequ <1>
GLIDE_PACK_RGB textequ <1>
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>
PROC_TYPE rgb
PROC_TPYE(cull_rgb) ENDP
%define GLIDE_CULLING 0
%define GLIDE_PACK_RGB 1
%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
endp
ALIGN 32
PROC_TYPE argb
PUBLIC PROC_TPYE(cull_argb)
PROC_TPYE(cull_argb) PROC NEAR
GLIDE_CULLING textequ <1>
GLIDE_PACK_RGB textequ <1>
GLIDE_PACK_ALPHA textequ <1>
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>
PROC_TPYE(cull_argb) ENDP
ENDIF ; GLIDE_PACKED_RGB
ALIGN 32
PUBLIC PROC_TYPE()
PROC_TYPE() PROC NEAR
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>
PROC_TYPE() ENDP
ALIGN 32
IF GLIDE_PACKED_RGB
PUBLIC PROC_TYPE(rgb)
PROC_TPYE(rgb) PROC NEAR
GLIDE_CULLING textequ <0>
GLIDE_PACK_RGB textequ <1>
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>
PROC_TPYE(rgb) ENDP
ALIGN 32
PUBLIC PROC_TPYE(argb)
PROC_TPYE(argb) PROC NEAR
GLIDE_CULLING textequ <0>
GLIDE_PACK_RGB textequ <1>
GLIDE_PACK_ALPHA textequ <1>
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>
PROC_TPYE(argb) ENDP
ENDIF ; GLIDE_PACKED_RGB
_TEXT ENDS
END
%define GLIDE_CULLING 0
%define GLIDE_PACK_RGB 1
%define GLIDE_PACK_ALPHA 1
%define GLIDE_GENERIC_SETUP 0
%INCLUDE "xdraw2.inc"
%undef GLIDE_GENERIC_SETUP
%undef GLIDE_PACK_ALPHA
%undef GLIDE_PACK_RGB
%undef GLIDE_CULLING
endp
%ENDIF ; GLIDE_PACKED_RGB

File diff suppressed because it is too large Load Diff

View File

@@ -50,55 +50,46 @@
;; mmx stuff for 3DNow!(tm) capable processors
;;
TITLE xtexdl.asm
OPTION OLDSTRUCTS
.586P
.MMX
.K3D
ifdef USE_PACKET_FIFO
EXTRN __FifoMakeRoom: NEAR
endif
%include "xos.inc"
%ifdef USE_PACKET_FIFO
extrn _FifoMakeRoom
%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 <ebp> ; fifo ptr in inner loop
gc TEXTEQU <esi> ; graphics context
dataPtr TEXTEQU <edi> ; pointer to exture data to be downloaded
curT TEXTEQU <ebx> ; counter for texture scan lines (t-coordinate)
curS TEXTEQU <ecx> ; texture s-coordinate
fRoom TEXTEQU <edx> ; room available in fifo (in bytes)
%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)
GR_FIFO_WRITE MACRO __addr, __offset, __data
mov [__addr + __offset], __data
ENDM ; GR_FIFO_WRITE
%MACRO GR_FIFO_WRITE 3
mov [%1 + _%2], %3
%ENDM ; GR_FIFO_WRITE
;--------------------------------------------------------------------------
_TEXT SEGMENT PAGE PUBLIC USE32 'CODE'
ASSUME DS: FLAT, SS: FLAT
segment SEG_TEXT
ALIGN 32
PUBLIC __grTexDownload_3DNow_MMX@24
__grTexDownload_3DNow_MMX@24 PROC NEAR
proc _grTexDownload_3DNow_MMX, 24
push ebx ; save caller's register variable
mov curT, [esp + _maxT$ - 12] ; curT = maxT
@@ -154,15 +145,15 @@ __grTexDownload_3DNow_MMX@24 PROC NEAR
cmp fRoom, 4 ; enough room for NULL packet in fifo?
jge __mmxAlignFifo ; yes, write NULL packet to align fifo
ifdef USE_PACKET_FIFO
push @Line ; Line # inside this function
%ifdef USE_PACKET_FIFO
push __LINE__ ; Line # inside this function
push 0 ; NULL file name
push 4 ; fifo space required (bytes)
call __FifoMakeRoom ; make fifo room
call _FifoMakeRoom ; make fifo room
add esp, 12 ; pop 3 DWORD parameters to FifoMakeRoom
endif
%endif
mov fifo, [gc + fifoPtr] ; fifoPtr modified by FifoMakeRoom, reload
mov fRoom, [gc + fifoRoom] ; fifoRoom modified by FifoMakeRoom, reload
@@ -173,7 +164,7 @@ endif
__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
@@ -189,7 +180,7 @@ __mmxAlignFifo:
__loopT:
IFDEF GLIDE_DEBUG
%IFDEF GLIDE_DEBUG
;; Make sure that we have a QWORD aligned fifoPtr; force GP if not aligned
@@ -199,7 +190,7 @@ IFDEF GLIDE_DEBUG
xor eax, eax ; create 0
mov [eax], eax ; move to DS:[0] forces GP
__alignmentOK:
ENDIF ; GLIDE_DEBUG
%ENDIF ; GLIDE_DEBUG
;; Compute packet header words
;; hdr1: downloadSpace[31:30] numWords[21:3] packetType[2:0]
@@ -249,15 +240,15 @@ __startDownload:
cmp fRoom, eax ; fifo space available >= fifo space required ?
jge __loopT ; yup, write next scan line
ifdef USE_PACKET_FIFO
push @Line ; Line # inside this function
%ifdef USE_PACKET_FIFO
push __LINE__ ; Line # inside this function
push 0h ; NULL file name
push eax ; fifo space required
call __FifoMakeRoom ; make fifo room (if fifoPtr QWORD aligned before
call _FifoMakeRoom ; make fifo room (if fifoPtr QWORD aligned before
add esp, 12 ; pop 3 DWORD parameters to FifoMakeRoom
endif
%endif
mov fifo, [gc + fifoPtr] ; fifoPtr was modified by FifoMakeRoom, reload
mov fRoom, [gc + fifoRoom] ; fifoRoom was modified by FifoMakeRoom, reload
@@ -274,10 +265,7 @@ __dlDone:
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
__grTexDownload_3DNow_MMX@24 ENDP
endp
_TEXT ENDS
END