What's new

Glide64 repository questions

DarkJezter

New member
Hey, there. I have been using a version of Glide64 I found in the forums here, called Glide64-wonder+ release 12. I get the impression that the version we're using is based on an earlier release, (anyone know for sure on this one? I've been looking at diffs of the two sources to figure out as best I can) I've also noticed that the version added to the repository doesn't want to compile on my 32 bit system.

I'd like to make the following enhancements:
  1. configure the glide64 makefile to use the same pre.mk file that the rest of mupen64 uses
  2. use this pre.mk to allow the project to compile as either a 32bit or 64bit version
  3. integrate any enhancements in Glide64-wonder+ into the repository

Anyone else playing with or looking at the glide64 plugin?
 

Richard42

Emulator Developer
I was planning on cleaning up the compiler warnings and doing #1 and 2 on your list this weekend. I believe that the Glide64 which Gunther ported to 64-bit (which is in my SVN server) is based on v12.
 

Günther1

New member
As can be seen in the history of my Glide64 repos, I based my work on Glide64-wonder+-linux v12. I also imported some earlier versions I found, so one can see the changes done to the linux versions easily.

Compilation on 32 bit should work, but I broke it with my last commit. It now works again. Assembler is a pain.
 

kosmi

New member
It also not compile for 32bit linux for me (snapshot from today's pyro commit). v12 (Ziggy's) from this forum compiles nicely:)

Code:
milan@ubuntu:~/downloads/Glide64$ make
gcc -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -funroll-loops -fexpensive-optimizations  -MMD -MP -MQ compiletex.o compiletex.c -c -o compiletex.o
g++ -o compiletex compiletex.o
./compiletex font.tex font.h font
./compiletex cursor.tex cursor.h cursor
g++ -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -funroll-loops -fexpensive-optimizations  -MMD -MP -MQ Main.o Main.cpp -c -o Main.o
g++ -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -funroll-loops -fexpensive-optimizations  -MMD -MP -MQ rdp.o rdp.cpp -c -o rdp.o
ucode06.h: In function ‘void DrawImage(DRAWIMAGE*)’:
ucode06.h:232: warning: ‘line’ may be used uninitialized in this function
ucode06.h:231: warning: ‘y_shift’ may be used uninitialized in this function
ucode06.h:230: warning: ‘x_shift’ may be used uninitialized in this function
ucode06.h:229: warning: ‘y_size’ may be used uninitialized in this function
ucode06.h:228: warning: ‘x_size’ may be used uninitialized in this function
g++ -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -funroll-loops -fexpensive-optimizations  -MMD -MP -MQ Ini.o Ini.cpp -c -o Ini.o
g++ -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -funroll-loops -fexpensive-optimizations  -MMD -MP -MQ TexCache.o TexCache.cpp -c -o TexCache.o
TexLoad.h:76: warning: missing braces around initializer
TexLoad.h:76: warning: missing braces around initializer
TexLoad.h:76: warning: missing braces around initializer
TexCache.cpp: In function ‘void GetTexInfo(int, int)’:
TexCache.cpp:278: warning: ‘crc’ may be used uninitialized in this function
g++ -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -funroll-loops -fexpensive-optimizations  -MMD -MP -MQ Debugger.o Debugger.cpp -c -o Debugger.o
g++ -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -funroll-loops -fexpensive-optimizations  -MMD -MP -MQ Util.o Util.cpp -c -o Util.o
Util.cpp: In function ‘void update_scissor()’:
Util.cpp:1334: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1335: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1336: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1337: warning: converting to ‘DWORD’ from ‘float’
Util.cpp: In function ‘void update()’:
Util.cpp:1653: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1654: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1655: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1656: warning: converting to ‘DWORD’ from ‘float’
g++ -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -funroll-loops -fexpensive-optimizations  -MMD -MP -MQ CRC.o CRC.cpp -c -o CRC.o
g++ -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -funroll-loops -fexpensive-optimizations  -MMD -MP -MQ Combine.o Combine.cpp -c -o Combine.o
Combine.cpp: In function ‘void cc_one_sub_env_mul_prim_add__t0_inter_t1_using_env()’:
Combine.cpp:3725: warning: unused variable ‘factor’
Combine.cpp: In function ‘void cc__t0_inter_t1_using_prim__mul_shade()’:
Combine.cpp:5533: warning: unused variable ‘factor’
Combine.cpp: At global scope:
Combine.cpp:11504: warning: missing braces around initializer
Combine.cpp:11504: warning: missing braces around initializer
Combine.cpp: In function ‘void Combine()’:
Combine.cpp:11609: warning: ‘current_combine’ may be used uninitialized in this function
Combine.cpp: In function ‘void ColorCombinerToExtension()’:
Combine.cpp:11914: warning: ‘ext_local_a’ may be used uninitialized in this function
Combine.cpp:11914: warning: ‘ext_local’ may be used uninitialized in this function
Combine.cpp:11914: warning: ‘ext_other_a’ may be used uninitialized in this function
Combine.cpp:11914: warning: ‘ext_other’ may be used uninitialized in this function
Combine.cpp: In function ‘void TexColorCombinerToExtension(GrChipID_t)’:
Combine.cpp:12229: warning: ‘tc_ext_c_invert’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_c’ may be used uninitialized in this function
Combine.cpp:12229: warning: ‘tc_ext_d_invert’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_d’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_b_mode’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_b’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_a_mode’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_a’ may be used uninitialized in this function
Combine.cpp: In function ‘void TexAlphaCombinerToExtension(GrChipID_t)’:
Combine.cpp:12412: warning: ‘ta_ext_c_invert’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_c’ may be used uninitialized in this function
Combine.cpp:12412: warning: ‘ta_ext_d_invert’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_d’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_b_mode’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_b’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_a_mode’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_a’ may be used uninitialized in this function
Combine.cpp: At global scope:
Combine.cpp:1508: warning: ‘void cc__t0_inter_t1_using_primlod__add_prim()’ defined but not used
g++ -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -funroll-loops -fexpensive-optimizations  -MMD -MP -MQ TexBuffer.o TexBuffer.cpp -c -o TexBuffer.o
TexBuffer.cpp: In function ‘HIRES_COLOR_IMAGE* AllocateTextureBuffer(COLOR_IMAGE&)’:
TexBuffer.cpp:188: warning: ‘texbuf$u_shift’ is used uninitialized in this function
TexBuffer.cpp:188: warning: ‘texbuf$clear’ is used uninitialized in this function
TexBuffer.cpp:188: warning: ‘texbuf$info$data’ is used uninitialized in this function
nasm -f elf32 Tmem_nasm.asm -o Tmem_nasm.o
nasm: fatal: unrecognised output format `elf32' - use -hf for a list
type `nasm -h' for help
make: *** [Tmem_nasm.o] Error 1
milan@ubuntu:~/downloads/Glide64$
 

kosmi

New member
When i try with that, there is another error from nasm (v.0.98.38):

Code:
nasm -f elf Tmem_nasm.asm -o Tmem_nasm.o
 Tmem_nasm.asm:2: error: symbol `__BITS__' not defined before use
 make: *** [Tmem_nasm.o] Error 1
 

Richard42

Emulator Developer
I switched my project to use an assembler called 'yasm' instead of NASM for Glide64. The 64-bit support in NASM is fairly new (ie, it's not in 0.98.38, which is what ships with many distros). YASM is a fork of NASM and has included 64-bit support for a long time. Here's the command line:

yasm -f elf32 -DBITS=32 Tmem_nasm.asm -o Tmem_nasm.o

I may have made a couple more small modifications to the source to make it work; you can check out the source from my SVN repo if needed.
 

Richard42

Emulator Developer
  1. configure the glide64 makefile to use the same pre.mk file that the rest of mupen64 uses
  2. use this pre.mk to allow the project to compile as either a 32bit or 64bit version
  3. integrate any enhancements in Glide64-wonder+ into the repository

Anyone else playing with or looking at the glide64 plugin?

I worked on this today, and have committed my changes to SVN. I refactored and cleaned up the Glide64 makefile to work in the same way as the others. I fixed all the warnings and you should be able to build 32-bit libraries from 64-bit machines now.

It looks like this plugin has been through a lot of development and is compatible with a very large number of games. I'm glad it's part of our project now and look forward to testing with it against Rice Video to see how it stacks up.
 

kosmi

New member
Sorry but i'm not familiar with svn, don't know how to checkout any svn repo?
Maybe if you leave exactly which command to type:)
I try yasm with Günther's last git version and there is errors again:( With Ziggy's
v12 and yasm (elf instead of elf32) it works:)
Code:
yasm -f elf -DBITS=32 Tmem_nasm.asm -o Tmem_nasm.o
 

Richard42

Emulator Developer
No problem. The file upload is unfortunately still broken in emutalk, so I've just pasted the contents of Tmem_nasm.asm into a code block here. You should be able to save this to a file and build it with the yasm command you posted here.

Code:
%if BITS=64
DEFAULT REL
%else
%define rax eax
%define rbx ebx
%define rcx ecx
%define rsi esi
%define rdi edi
%define rdx edx
%endif

global CopyBlock
global _SwapBlock32
global _SwapBlock64

[section .text]

;****************************************************************
; CopyBlock - copies a block from base_addr+offset to dest_addr, while unswapping the
;  data within
;
; edi = dest_addr -> end of dest
; ecx = num_words
; esi = base_addr (preserved)
; edx = offset (preserved)
;****************************************************************

ALIGN 4

CopyBlock:
	push rax
	push rbx
	push rsi
	push rdx

	or ecx,ecx
	jz near copyblock_end

	push rcx

	; first, set the source address and check if not on a dword boundary
	push rsi
	push rdx
	mov ebx,edx
	and edx,0FFFFFFFCh
	add esi,edx

	and ebx,3				; ebx = # we DON'T need to copy
	jz copyblock_copy

	mov edx,4				; ecx = # we DO need to copy
	sub edx,ebx

	; load the first word, accounting for swapping

	mov eax, [rsi]
	add rsi,4
copyblock_precopy_skip:
	rol eax,8
	dec ebx
	jnz copyblock_precopy_skip

copyblock_precopy_copy:
	rol eax,8
	mov [rdi],al
	inc rdi
	dec edx
	jnz copyblock_precopy_copy

	mov eax,[rsi]
	add rsi,4
	bswap eax
	mov [rdi],eax
	add rdi,4

	dec ecx		; 1 less word to copy
	jz copyblock_postcopy

copyblock_copy:
	mov eax,[rsi]
	bswap eax
	mov [rdi],eax

	mov eax,[rsi+4]
	bswap eax
	mov [rdi+4],eax

	add rsi,8
	add rdi,8

	dec ecx
	jnz copyblock_copy

copyblock_postcopy:
	pop rdx
	pop rsi
	pop rcx

	; check again if on dword boundary
	mov ebx,edx						; ebx = # we DO need to copy

	and ebx,3
	jz copyblock_end

	shl ecx,3						; ecx = num_words * 8
	add edx,ecx
	and edx,0FFFFFFFCh
	add rsi,rdx

	mov eax,[rsi]

copyblock_postcopy_copy:
	rol eax,8
	mov [rdi],al
	inc rdi
	dec ebx
	jnz copyblock_postcopy_copy

copyblock_end:
	pop rdx
	pop rsi
	pop rbx
	pop rax
	ret


;****************************************************************
; SwapBlock - swaps every other 32-bit word at addr
;
; ecx = num_words -> 0
; edi = addr -> end of dest
;****************************************************************

ALIGN 4

_SwapBlock32:
	push rax
	push rbx
	or ecx,ecx
	jz swapblock_end
swapblock_loop:
	mov eax,[rdi]
	mov ebx,[rdi+4]
	mov [rdi+4],eax
	mov [rdi],ebx
	add rdi,8
	dec ecx
	jnz swapblock_loop
swapblock_end:
	pop rbx
	pop rax
	ret


ALIGN 4

_SwapBlock64:
	push rax
	push rbx
	push rdx
	shr ecx,1
	or ecx,ecx
	jz swapblock_end2
swapblock_loop2:
	mov eax,[rdi]
	mov edx,[rdi+8]
	mov ebx,[rdi+4]
	mov [rdi+8],eax
	mov eax,[rdi+12]
	mov [rdi],edx
	mov [rdi+12],ebx
	mov [rdi+4],eax
	add rdi,16
	dec ecx
	jnz swapblock_loop2
swapblock_end2:
	pop rdx
	pop rbx
	pop rax
	ret


END
 

kosmi

New member
With that Tmem_nasm.asm and yasm command in Makefile it finished and plugin
works like v12 (tested with DD:Quack Attack and Rayman2). It has some warnings from building time, but works great;) My comp specs are: Athlon2200+(1800MHz)/768MB/ATI9250 128MB with Mesa 7.03beta driver.

Code:
milan@ubuntu:~/downloads/Glide64$ make
gcc -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ compiletex.o compiletex.c -c -o compiletex.o
g++ -march=athlon64 -o compiletex compiletex.o
./compiletex font.tex font.h font
./compiletex cursor.tex cursor.h cursor
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ Main.o Main.cpp -c -o Main.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ rdp.o rdp.cpp -c -o rdp.o
ucode06.h: In function ‘void DrawImage(DRAWIMAGE*)’:
ucode06.h:232: warning: ‘line’ may be used uninitialized in this function
ucode06.h:231: warning: ‘y_shift’ may be used uninitialized in this function
ucode06.h:230: warning: ‘x_shift’ may be used uninitialized in this function
ucode06.h:229: warning: ‘y_size’ may be used uninitialized in this function
ucode06.h:228: warning: ‘x_size’ may be used uninitialized in this function
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ Ini.o Ini.cpp -c -o Ini.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ TexCache.o TexCache.cpp -c -o TexCache.o
TexLoad.h:76: warning: missing braces around initializer
TexLoad.h:76: warning: missing braces around initializer
TexLoad.h:76: warning: missing braces around initializer
TexCache.cpp: In function ‘void GetTexInfo(int, int)’:
TexCache.cpp:278: warning: ‘crc’ may be used uninitialized in this function
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ Debugger.o Debugger.cpp -c -o Debugger.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ Util.o Util.cpp -c -o Util.o
Util.cpp: In function ‘void update_scissor()’:
Util.cpp:1334: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1335: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1336: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1337: warning: converting to ‘DWORD’ from ‘float’
Util.cpp: In function ‘void update()’:
Util.cpp:1653: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1654: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1655: warning: converting to ‘DWORD’ from ‘float’
Util.cpp:1656: warning: converting to ‘DWORD’ from ‘float’
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ CRC.o CRC.cpp -c -o CRC.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ Combine.o Combine.cpp -c -o Combine.o
Combine.cpp: In function ‘void cc_one_sub_env_mul_prim_add__t0_inter_t1_using_env()’:
Combine.cpp:3725: warning: unused variable ‘factor’
Combine.cpp: In function ‘void cc__t0_inter_t1_using_prim__mul_shade()’:
Combine.cpp:5533: warning: unused variable ‘factor’
Combine.cpp: At global scope:
Combine.cpp:10312: warning: missing braces around initializer
Combine.cpp:10312: warning: missing braces around initializer
Combine.cpp:11504: warning: missing braces around initializer
Combine.cpp:11504: warning: missing braces around initializer
Combine.cpp: In function ‘void Combine()’:
Combine.cpp:11609: warning: ‘current_combine’ may be used uninitialized in this function
Combine.cpp: In function ‘void ColorCombinerToExtension()’:
Combine.cpp:11914: warning: ‘ext_local_a’ may be used uninitialized in this function
Combine.cpp:11914: warning: ‘ext_local’ may be used uninitialized in this function
Combine.cpp:11914: warning: ‘ext_other_a’ may be used uninitialized in this function
Combine.cpp:11914: warning: ‘ext_other’ may be used uninitialized in this function
Combine.cpp: In function ‘void TexColorCombinerToExtension(GrChipID_t)’:
Combine.cpp:12229: warning: ‘tc_ext_c_invert’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_c’ may be used uninitialized in this function
Combine.cpp:12229: warning: ‘tc_ext_d_invert’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_d’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_b_mode’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_b’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_a_mode’ may be used uninitialized in this function
Combine.cpp:12228: warning: ‘tc_ext_a’ may be used uninitialized in this function
Combine.cpp: In function ‘void TexAlphaCombinerToExtension(GrChipID_t)’:
Combine.cpp:12412: warning: ‘ta_ext_c_invert’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_c’ may be used uninitialized in this function
Combine.cpp:12412: warning: ‘ta_ext_d_invert’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_d’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_b_mode’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_b’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_a_mode’ may be used uninitialized in this function
Combine.cpp:12411: warning: ‘ta_ext_a’ may be used uninitialized in this function
Combine.cpp: At global scope:
Combine.cpp:1508: warning: ‘void cc__t0_inter_t1_using_primlod__add_prim()’ defined but not used
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ TexBuffer.o TexBuffer.cpp -c -o TexBuffer.o
TexBuffer.cpp: In function ‘HIRES_COLOR_IMAGE* AllocateTextureBuffer(COLOR_IMAGE&)’:
TexBuffer.cpp:188: warning: ‘texbuf$u_shift’ is used uninitialized in this function
TexBuffer.cpp:188: warning: ‘texbuf$clear’ is used uninitialized in this function
TexBuffer.cpp:188: warning: ‘texbuf$info$data’ is used uninitialized in this function
yasm -f elf -DBITS=32 Tmem_nasm.asm -o Tmem_nasm.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ Config.o Config.cpp -c -o Config.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ 3dmath.o 3dmath.cpp -c -o 3dmath.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ DepthBufferRender.o DepthBufferRender.cpp -c -o DepthBufferRender.o
gcc -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ support.o support.c -c -o support.o
gcc -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ messagebox.o messagebox.c -c -o messagebox.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ wrapper/combiner.o wrapper/combiner.cpp -c -o wrapper/combiner.o
wrapper/combiner.cpp:43: warning: ‘fragment_bw_shader_object’ defined but not used
wrapper/combiner.cpp:47: warning: ‘program_object_bw’ defined but not used
wrapper/combiner.cpp:104: warning: ‘fragment_shader_depth’ defined but not used
wrapper/combiner.cpp:111: warning: ‘fragment_shader_bw’ defined but not used
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ wrapper/textures.o wrapper/textures.cpp -c -o wrapper/textures.o
wrapper/textures.cpp:41: warning: ‘szTex’ defined but not used
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ wrapper/main.o wrapper/main.cpp -c -o wrapper/main.o
wrapper/main.cpp:261:1: warning: "LOG" redefined
In file included from wrapper/main.cpp:19:
wrapper/main.h:270:1: warning: this is the location of the previous definition
wrapper/main.cpp: In function ‘void opt_glCopyTexImage2D(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint)’:
wrapper/main.cpp:45: warning: comparison between signed and unsigned integer expressions
wrapper/main.cpp: At global scope:
wrapper/main.cpp:159: warning: non-local variable ‘<anonymous struct> tmu_usage [2]’ uses anonymous type
wrapper/main.cpp:159: warning: missing braces around initializer
wrapper/main.cpp: In function ‘void grSstOrigin(GrOriginLocation_t)’:
wrapper/main.cpp:267: warning: left-hand operand of comma has no effect
wrapper/main.cpp: In function ‘void grClipWindow(FxU32, FxU32, FxU32, FxU32)’:
wrapper/main.cpp:275: warning: left-hand operand of comma has no effect
wrapper/main.cpp:275: warning: right-hand operand of comma has no effect
wrapper/main.cpp:275: warning: right-hand operand of comma has no effect
wrapper/main.cpp:275: warning: right-hand operand of comma has no effect
wrapper/main.cpp:291: warning: comparison between signed and unsigned integer expressions
wrapper/main.cpp:292: warning: comparison between signed and unsigned integer expressions
wrapper/main.cpp: In function ‘void grColorMask(FxBool, FxBool)’:
wrapper/main.cpp:305: warning: left-hand operand of comma has no effect
wrapper/main.cpp:305: warning: right-hand operand of comma has no effect
wrapper/main.cpp: In function ‘void grGlideInit()’:
wrapper/main.cpp:313: warning: statement has no effect
wrapper/main.cpp: In function ‘void grSstSelect(int)’:
wrapper/main.cpp:319: warning: left-hand operand of comma has no effect
wrapper/main.cpp: In function ‘GrContext_t grSstWinOpenExt(FxU32, GrScreenResolution_t, GrScreenRefresh_t, GrColorFormat_t, GrOriginLocation_t, int, int, int)’:
wrapper/main.cpp:407: warning: left-hand operand of comma has no effect
wrapper/main.cpp:407: warning: right-hand operand of comma has no effect
wrapper/main.cpp:407: warning: right-hand operand of comma has no effect
wrapper/main.cpp:407: warning: right-hand operand of comma has no effect
wrapper/main.cpp:407: warning: right-hand operand of comma has no effect
wrapper/main.cpp:407: warning: right-hand operand of comma has no effect
wrapper/main.cpp:407: warning: right-hand operand of comma has no effect
wrapper/main.cpp: In function ‘GrContext_t grSstWinOpen(FxU32, GrScreenResolution_t, GrScreenRefresh_t, GrColorFormat_t, GrOriginLocation_t, int, int)’:
wrapper/main.cpp:474: warning: left-hand operand of comma has no effect
wrapper/main.cpp:474: warning: right-hand operand of comma has no effect
wrapper/main.cpp:474: warning: right-hand operand of comma has no effect
wrapper/main.cpp:474: warning: right-hand operand of comma has no effect
wrapper/main.cpp:474: warning: right-hand operand of comma has no effect
wrapper/main.cpp:474: warning: right-hand operand of comma has no effect
wrapper/main.cpp:474: warning: right-hand operand of comma has no effect
wrapper/main.cpp: In function ‘void grGlideShutdown()’:
wrapper/main.cpp:982: warning: statement has no effect
wrapper/main.cpp: In function ‘FxBool grSstWinClose(GrContext_t)’:
wrapper/main.cpp:990: warning: left-hand operand of comma has no effect
wrapper/main.cpp: In function ‘void grTextureBufferExt(GrChipID_t, FxU32, GrLOD_t, GrLOD_t, GrAspectRatio_t, GrTextureFormat_t, FxU32)’:
wrapper/main.cpp:1087: warning: left-hand operand of comma has no effect
wrapper/main.cpp:1087: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1087: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1087: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1087: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1087: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1087: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1166: warning: comparison between signed and unsigned integer expressions
wrapper/main.cpp:1168: warning: comparison between signed and unsigned integer expressions
wrapper/main.cpp: In function ‘int CheckTextureBufferFormat(GrChipID_t, FxU32, GrTexInfo*)’:
wrapper/main.cpp:1320: warning: comparison between signed and unsigned integer expressions
wrapper/main.cpp:1320: warning: comparison between signed and unsigned integer expressions
wrapper/main.cpp: In function ‘void grTextureAuxBufferExt(GrChipID_t, FxU32, GrLOD_t, GrLOD_t, GrAspectRatio_t, GrTextureFormat_t, FxU32)’:
wrapper/main.cpp:1427: warning: left-hand operand of comma has no effect
wrapper/main.cpp:1427: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1427: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1427: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1427: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1427: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1427: warning: right-hand operand of comma has no effect
wrapper/main.cpp: In function ‘int (* grGetProcAddress(const char*))()’:
wrapper/main.cpp:1436: warning: left-hand operand of comma has no effect
wrapper/main.cpp: In function ‘FxU32 grGet(FxU32, FxU32, FxI32*)’:
wrapper/main.cpp:1477: warning: left-hand operand of comma has no effect
wrapper/main.cpp:1477: warning: right-hand operand of comma has no effect
wrapper/main.cpp: In function ‘const char* grGetString(FxU32)’:
wrapper/main.cpp:1589: warning: left-hand operand of comma has no effect
wrapper/main.cpp: In function ‘void reloadTexture()’:
wrapper/main.cpp:1721: warning: left-hand operand of comma has no effect
wrapper/main.cpp:1721: warning: right-hand operand of comma has no effect
wrapper/main.cpp: In function ‘void updateTexture()’:
wrapper/main.cpp:1749: warning: left-hand operand of comma has no effect
wrapper/main.cpp:1754: warning: left-hand operand of comma has no effect
wrapper/main.cpp: In function ‘void grRenderBuffer(GrBuffer_t)’:
wrapper/main.cpp:1837: warning: left-hand operand of comma has no effect
wrapper/main.cpp: In function ‘void grAuxBufferExt(GrBuffer_t)’:
wrapper/main.cpp:1963: warning: left-hand operand of comma has no effect
wrapper/main.cpp: In function ‘void grBufferClear(GrColor_t, GrAlpha_t, FxU32)’:
wrapper/main.cpp:1990: warning: left-hand operand of comma has no effect
wrapper/main.cpp:1990: warning: right-hand operand of comma has no effect
wrapper/main.cpp:1990: warning: right-hand operand of comma has no effect
wrapper/main.cpp: In function ‘void grBufferSwap(FxU32)’:
wrapper/main.cpp:2025: warning: left-hand operand of comma has no effect
wrapper/main.cpp: In function ‘FxBool grLfbLock(GrLock_t, GrBuffer_t, GrLfbWriteMode_t, GrOriginLocation_t, FxBool, GrLfbInfo_t*)’:
wrapper/main.cpp:2072: warning: left-hand operand of comma has no effect
wrapper/main.cpp:2072: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2072: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2072: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2072: warning: right-hand operand of comma has no effect
wrapper/main.cpp: In function ‘FxBool grLfbUnlock(GrLock_t, GrBuffer_t)’:
wrapper/main.cpp:2145: warning: left-hand operand of comma has no effect
wrapper/main.cpp:2145: warning: right-hand operand of comma has no effect
wrapper/main.cpp: In function ‘FxBool grLfbReadRegion(GrBuffer_t, FxU32, FxU32, FxU32, FxU32, FxU32, void*)’:
wrapper/main.cpp:2163: warning: left-hand operand of comma has no effect
wrapper/main.cpp:2163: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2163: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2163: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2163: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2163: warning: right-hand operand of comma has no effect
wrapper/main.cpp: In function ‘FxBool grLfbWriteRegion(GrBuffer_t, FxU32, FxU32, GrLfbSrcFmt_t, FxU32, FxU32, FxBool, FxI32, void*)’:
wrapper/main.cpp:2231: warning: left-hand operand of comma has no effect
wrapper/main.cpp:2231: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2231: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2231: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2231: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2231: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2231: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2231: warning: right-hand operand of comma has no effect
wrapper/main.cpp:2361: warning: unused variable ‘num’
wrapper/main.cpp: At global scope:
wrapper/main.cpp:157: warning: ‘g_depthRenderBuffer’ defined but not used
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ wrapper/geometry.o wrapper/geometry.cpp -c -o wrapper/geometry.o
wrapper/geometry.cpp:33: warning: ‘depth_bias’ defined but not used
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ wrapper/config.o wrapper/config.cpp -c -o wrapper/config.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ wrapper/filter.o wrapper/filter.cpp -c -o wrapper/filter.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ wrapper/2xsai.o wrapper/2xsai.cpp -c -o wrapper/2xsai.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ wrapper/hq2x.o wrapper/hq2x.cpp -c -o wrapper/hq2x.o
g++ -march=athlon64 -O2 -Wall -g -DGCC -DUSE_GTK  -I/usr/local/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -D_GTK2 -Iwrapper/ -ffast-math -MMD -MP -MQ wrapper/hq4x.o wrapper/hq4x.cpp -c -o wrapper/hq4x.o
g++ -march=athlon64 -L/usr/local/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0   -o Glide64.so Main.o rdp.o Ini.o TexCache.o Debugger.o Util.o CRC.o Combine.o TexBuffer.o Tmem_nasm.o Config.o 3dmath.o DepthBufferRender.o support.o messagebox.o wrapper/combiner.o wrapper/textures.o wrapper/main.o wrapper/geometry.o wrapper/config.o wrapper/filter.o wrapper/2xsai.o wrapper/hq2x.o wrapper/hq4x.o -g -shared -Wl,-Bsymbolic -lGL -lGLU -L/usr/X11R6/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSDL -lpthread -fomit-frame-pointer
Makefile:192: please copy Glide64.so AND Glide64.ini in the plugins/ folder of the emulator
milan@ubuntu:~/downloads/Glide64$
 

Günther1

New member
When i try with that, there is another error from nasm (v.0.98.38):

Code:
nasm -f elf Tmem_nasm.asm -o Tmem_nasm.o
 Tmem_nasm.asm:2: error: symbol `__BITS__' not defined before use
 make: *** [Tmem_nasm.o] Error 1

I added an ifdef so that older nasm versions should work again, and pulled Richard42's warning cleanups. With make NASM=yasm you can also use that for 32 bit, but yasm somehow didn't work for me for 64 bit, so I'll stay with nasm. Those functions should be rewritten in C or C++ anyway, imho ;-)
 

Richard42

Emulator Developer
Today I slightly refactored almost all of the inline ASM code and committed it to my SVN. I fixed many instances of 2 classes of bugs which I experienced and diagnosed on my 64-bit machine, and may have affected 32-bit machines as well. The bugs will only show up in certain games and with certain compilers, etc.

The first problem is that there were variables assigned to registers in the 'input' list of the extended asm statements which were being modified by the asm code: counters, pointers, etc. The AT&T syntax specifies that anything defined in the input list will not be modified by the code, so the compiler optimizer will expect these to stay the same and it can cause weird bugs if they are modified. The way to fix this is to move those quantities that are modified from the input list to the output list and use the "+" constraint modifier, which means that it's read and written.

The second problem I found with the debugger on my 64-bit PC. The compiler was saving and restoring the callee-saved registers (rbp, rbx, r8-12) at locations like (rsp-8), (rsp-16), etc. This is unusual for a compiler to do because it is an optimization which will only work if certain conditions are met (no function calls or local variables). The compiler was smart enough to recognize that these conditions were met, and apply the optimization. But the inline code was pushing counters on the stack and trashing these callee-saved registers, which causes hard-to-find bugs later in a different part of code. I fixed this by using temporary local variables. I tested the 64-bit version and it was fixed; I didn't run the 32-bit binary but I verified that it compiles with no errors.
 

Günther1

New member
The first problem is that there were variables assigned to registers in the 'input' list of the extended asm statements which were being modified by the asm code: counters, pointers, etc.
Hm, I remember worrying about that, but the functions I looked at at that moment did not use those variables after the asm statement, so I stopped worrying. I admit that I got impatient and somewhat sloppy towards the end. Initially I wanted to rewrite all assembler in C++. I still think that would be the right thing to do because these inline assembler blocks don't strike me as particularly optimized, but that would be a lot of work.

Edit: Hm, doesn't "+" mean that the inline assembly changes the variable and the C code should use the new value afterwards? In some cases, this is not what the original code did, iirc. I did not check wether thats affects any function.
Also, "long" is 32 bit on Win64. Not that anybody cares about that platform, but "intptr_t" or something is more correct than long when one wants a variable as big as a pointer.
 
Last edited:

Richard42

Emulator Developer
Hm, I remember worrying about that, but the functions I looked at at that moment did not use those variables after the asm statement, so I stopped worrying. I admit that I got impatient and somewhat sloppy towards the end. Initially I wanted to rewrite all assembler in C++. I still think that would be the right thing to do because these inline assembler blocks don't strike me as particularly optimized, but that would be a lot of work.

I didn't trace this issue from a crash but I saw it and knew that it was wrong, so I fixed it. I think the optimizer can work over a scope greater than the function, so if you have an input parameter (which is passed via register in x86_64) which is modified incorrectly by the asm, the calling function may expect it to be untouched and not reload it. I didn't look deep enough in the code to verify that this could happen, though. It's always better to just fix it.

I agree that some of this inline ASM is very bad and should be re-written in C. In the last few years I've found that compilers are so good that they will beat hand-written ASM for just about any non-SIMD code. It's only my MMX/SSE2 skills that are keeping me employed. :) Some of the bit-manipulation code that's used for the weird texture format conversions may be better in ASM, as there may not be an elegant way to express the operations in C.

Also, "long" is 32 bit on Win64. Not that anybody cares about that platform, but "intptr_t" or something is more correct than long when one wants a variable as big as a pointer.

I saw the intptr_t definitions but hadn't used this before so I just stuck with what I know works. As you say, nobody cares about 64-bit Windows. I did some web research and found that this is standard in C99 but may not be in the latest ISO C++ yet. I'll start using this for portability in the future.
 

RadicalHarmony

New member
ongoing compiling issues

Hey everyone. I'd really like to get this plugin working (primarily because I cannot proceed with the lens of truth in Majora's Mask) but I have compiling problems.

With nasm, I got the (seemingly typical)

nasm -f elf64 Tmem_nasm.asm -o Tmem_nasm.o
nasm: fatal: unrecognised output format `elf64' - use -hf for a list
type `nasm -h' for help
make: *** [Tmem_nasm.o] Error 1


However, yasm, doesn't seem to work either. It gives me this:

yasm -f elf64 Tmem_nasm.asm -o Tmem_nasm.o
Tmem_nasm.asm:36: invalid combination of opcode and operands
Tmem_nasm.asm:37: invalid combination of opcode and operands
Tmem_nasm.asm:38: invalid combination of opcode and operands
Tmem_nasm.asm:39: invalid combination of opcode and operands
Tmem_nasm.asm:44: invalid combination of opcode and operands
Tmem_nasm.asm:47: invalid combination of opcode and operands
Tmem_nasm.asm:48: invalid combination of opcode and operands
Tmem_nasm.asm:100: invalid combination of opcode and operands
Tmem_nasm.asm:101: invalid combination of opcode and operands
Tmem_nasm.asm:102: invalid combination of opcode and operands
Tmem_nasm.asm:125: invalid combination of opcode and operands
Tmem_nasm.asm:126: invalid combination of opcode and operands
Tmem_nasm.asm:127: invalid combination of opcode and operands
Tmem_nasm.asm:128: invalid combination of opcode and operands
Tmem_nasm.asm:142: invalid combination of opcode and operands
Tmem_nasm.asm:143: invalid combination of opcode and operands
Tmem_nasm.asm:155: invalid combination of opcode and operands
Tmem_nasm.asm:156: invalid combination of opcode and operands
Tmem_nasm.asm:163: invalid combination of opcode and operands
Tmem_nasm.asm:164: invalid combination of opcode and operands
Tmem_nasm.asm:165: invalid combination of opcode and operands
Tmem_nasm.asm:182: invalid combination of opcode and operands
Tmem_nasm.asm:183: invalid combination of opcode and operands
Tmem_nasm.asm:184: invalid combination of opcode and operands
make: *** [Tmem_nasm.o] Error 1



I tried going back and using an earlier version from git, and it gives this:

yasm -f elf64 Tmem_nasm.asm -o Tmem_nasm.o
Tmem_nasm.asm:10: symbol references not supported
Tmem_nasm.asm:10: non-constant value given to `%if'
make: *** [Tmem_nasm.o] Error 1



Any ideas?

I'm running Ubuntu Gutsy with an AMD64.
 

Günther1

New member
nasm -f elf64 Tmem_nasm.asm -o Tmem_nasm.o
nasm: fatal: unrecognised output format `elf64' - use -hf for a list
type `nasm -h' for help
make: *** [Tmem_nasm.o] Error 1

A 2.x version of nasm should work. I also pushed a fix for yasm on 64 bit. yasm and nasm unfortunately do not have a common syntax to define a macro on the command line, making this more difficult than necessary.
 

Top