Zsnes (compilación para 64bit)

From HSS
(Redirected from Zsnes)

idea

que en el server anfibio esté instalado zsnes para que el que quiera jugar un rato pueda. para que el servidor no tenga archivos que puedan estar sujetos a algún problema legal del mundo cretino, sugiero la idea de portar juegos en pendrives ;-)

descargar zsnes

cd docs/

cat README.LINUX

  • advierte que hay que tener instalado SDL 1.2.0
    • apt install libsdl1.2-dev
      • requiere instalar: libasound2-dev libblkid-dev libcaca-dev libgl-dev libglib2.0-dev libglib2.0-dev-bin libglu1-mesa libglu1-mesa-dev libglx-dev libmount-dev libopengl-dev libopengl0 libpcre2-32-0 libpcre2-dev libpcre2-posix3 libpkgconf3 libpng-dev libpng-tools libpthread-stubs0-dev libpulse-dev libpulse-mainloop-glib0 libselinux1-dev libsepol-dev libslang2-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxext-dev pkg-config pkgconf pkgconf-bin uuid-dev x11proto-dev xorg-sgml-doctools xtrans-dev

cat install.txt

tl;dr hay que tener instalados: sdl, nasm, zlib, libpng, Curses/NCurses

SDL (Simple DirectMedia Layer) : check www.libsdl.org to grab SDL 1.2.0 or later. If you are using rpm packages, don't forget the -devel package. instalado recién

NASM v0.98.39 : http://nasm.sf.net/. apt install nasm la versión actual es la 1.16.

zlib v1.2.3 or higher : http://www.zlib.net it is probably already installed on your system, maybe you are just missing the development headers. Check in the packages available with your distributionor go to the page above apt install zlib1g-dev ya estaba instalado, v. 1.2.13

libpng : http://www.libpng.org/ You might also need libpng, ZSNES will compile without PNG support but I have found doing so to make ZSNES unstable for some weird reason. If you don't have libpng, either get it and install it or pass the --without-png option to the 'configure' script. no lo instalaré porque la idea es que use el SDL, no weis png.

Curses/NCurses Check your distro. One of these is needed if you compile with the debugger enabled. You may also have to symlink ncurses.h to curses.h in your include directory.. apt install lib32ncurses-dev. Requiere instalar gcc-12-multilib gcc-multilib lib32asan8 lib32atomic1 lib32gcc-12-dev lib32gcc-s1 lib32gomp1 lib32itm1 lib32ncurses6 lib32ncursesw6 lib32quadmath0 lib32stdc++6 lib32tinfo6 lib32ubsan1 libc6-dev-i386 libc6-dev-x32 libc6-i386 libc6-x32 libncurses-dev libx32asan8 libx32atomic1 libx32gcc-12-dev libx32gcc-s1 libx32gomp1 libx32itm1 libx32quadmath0 libx32stdc++6 libx32ubsan1

cd ../src

./autogen.sh && gmake && gmake install

./autogen.sh

Todo dice que está ok. Dejo ultima parte del stdout.

# ./autogen.sh

[...]

ZSNES v1.51

SDL support                   Version 1.2.15
NASM support                  NASM version 2.16.01
zlib support                  Version 1.2.13
PNG support                   Yes, version 1.6.39
OpenGL support                Yes
JMA support                   Yes
ZSNES debugger                Enabled

The binary will be installed in /usr/local/bin

Configure complete, now type 'make' and pray.

gmake

  • PRIMER INTENTO
 # gmake
g++  -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT  -D__OPENGL__ -march=native -O3 -fomit-frame-pointer -s -fno-rtti -o tools/fileutil.o -c tools/fileutil.cpp
g++  -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT  -D__OPENGL__ -march=native -O3 -fomit-frame-pointer -s -fno-rtti -o tools/strutil.o -c tools/strutil.cpp
In file included from tools/strutil.cpp:22:
tools/strutil.h: In static member function ‘static int ci_char_traits::compare(const char*, const char*, size_t)’:
tools/strutil.h:34:73: error: ‘strncasecmp’ was not declared in this scope; did you mean ‘wcsncasecmp’?
   34 |   static int compare(const char* s1, const char* s2, size_t n) { return strncasecmp( s1, s2, n ); }
      |                                                                         ^~~~~~~~~~~
      |                                                                         wcsncasecmp
gmake: *** [Makefile:96: tools/strutil.o] Error 1

Seguiremos el consejo y editaré el archivo tools/strutil.h

  • Segundo intento

Aquí creo que se empieza a ir a la cresta...

 # gmake
g++  -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT  -D__OPENGL__ -march=native -O3 -fomit-frame-pointer -s -fno-rtti -o tools/strutil.o -c tools/strutil.cpp
In file included from tools/strutil.cpp:22:
tools/strutil.h: In static member function ‘static int ci_char_traits::compare(const char*, const char*, size_t)’:
tools/strutil.h:36:88: error: cannot convert ‘const char*’ to ‘const wchar_t*’
   36 | ic int compare(const char* s1, const char* s2, size_t n) { return wcsncasecmp( s1, s2, n ); }
      |                                                                                ^~
      |                                                                                |
      |                                                                                const char*

In file included from /usr/include/c++/12/cwchar:44,
                 from /usr/include/c++/12/bits/postypes.h:40,
                 from /usr/include/c++/12/bits/char_traits.h:39,
                 from /usr/include/c++/12/string:40,
                 from tools/strutil.h:25:
/usr/include/wchar.h:117:40: note:   initializing argument 1 of ‘int wcsncasecmp(const wchar_t*, const wchar_t*, size_t)’
  117 | extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
      |                         ~~~~~~~~~~~~~~~^~~~
gmake: *** [Makefile:96: tools/strutil.o] Error 1

...así que restauré el archivo que edité y busqué si había info en internet sobre el primer error y llegué a este post en un hilo en que se hablaba de compilar zsnes. Transcribo las indicaciones que deja y que seguiré a continuación:

The latest version are still not compiling so here is the patch! To build zsnes-1.51 do the following:

First open zsnes-1.51/parsegen.cpp

First add #include <cstring>

#include <fstream>
#include <string>
+#include <cstring>
#include <vector>
#include <algorithm>

then find and change one line ...

}
}

-int main(size_t argc, const char *const *const argv)
+int main(int argc, const char *const *const argv)
{
const char *cheader_file = 0;
___________________________________________________

Then Open file zsnes-1.51/tools/depbuild.cpp

First add #include <cstdlib> and #include <unistd.h>

#include <string>
#include <cstdio>
+#include <cstdlib>
+#include <unistd.h>
using namespace std;

#include "fileutil.h"

then find and change one line ...

}

-int main(size_t argc, const char *const *const argv)
+int main(int argc, const char *const *const argv)
{
if (argc < 5)
__________________________________________________

Then open zsnes-1.51/tools/strutil.h

First add #include <cstring>

#include <string>
+#include <cstring>
#include <vector>

  • Tercer intento

Hice las ediciones señaladas y ahora gmake avanzó mucho más... pero volvió a chocar.

# gmake 
tools/depbuild gcc " -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT  -D__OPENGL__ -march=native -O3 -fomit-frame-pointer -s" nasm " -w-orphan-labels -D__UNIXSDL__ -f elf -DELF -D__OPENGL__ -O1" cfg.o endmem.o init.o initc.o input.o md.o patch.o ui.o vcache.o version.o zloader.o zmovie.o zpath.o zstate.o ztime.o ztimec.o chips/c4emu.o chips/c4proc.o chips/dsp1emu.o chips/dsp1proc.o chips/dsp2proc.o chips/dsp3emu.o chips/dsp3proc.o chips/dsp4emu.o chips/dsp4proc.o chips/fxemu2.o chips/fxemu2b.o chips/fxemu2c.o chips/fxtable.o chips/obc1emu.o chips/obc1proc.o chips/sa1proc.o chips/sa1regs.o chips/sdd1emu.o chips/seta10.o chips/sfxproc.o chips/st10proc.o chips/7110proc.o chips/seta11.o chips/st11proc.o cpu/dma.o cpu/dsp.o cpu/dspproc.o cpu/execute.o cpu/executec.o cpu/irq.o cpu/memory.o cpu/memtable.o cpu/spc700.o cpu/stable.o cpu/table.o cpu/tablec.o debugasm.o debugger.o gui/gui.o gui/guifuncs.o gui/menu.o effects/burn.o effects/smoke.o effects/water.o jma/7zlzma.o jma/crc32.o jma/iiostrm.o	jma/inbyte.o jma/jma.o jma/lzma.o	jma/lzmadec.o jma/winout.o jma/zsnesjma.o mmlib/mm.o mmlib/linux.o  video/makev16b.o video/makev16t.o video/makevid.o video/mode716.o video/mode716b.o video/mode716d.o video/mode716e.o video/mode716t.o video/mode7.o video/mode7ext.o video/mv16tms.o video/m716text.o video/newg162.o video/newgfx.o video/newgfx16.o video/newgfx2.o video/procvid.o video/procvidc.o video/sw_draw.o video/2xsaiw.o video/hq2x16.o video/hq2x32.o video/hq3x16.o video/hq3x32.o video/hq4x16.o video/hq4x32.o video/ntsc.o video/copyvwin.o linux/audio.o linux/battery.o linux/sdlintrf.o linux/sdllink.o linux/gl_draw.o linux/sw_draw.o linux/safelib.o zip/unzip.o zip/zpng.o > makefile.dep
vcache.asm:914: warning: dropping trailing empty parameter in call to multi-line macro `newsym' [-w+pp-macro-params-legacy]
cpu/execute.asm:35: warning: dropping trailing empty parameter in call to multi-line macro `extern' [-w+pp-macro-params-legacy]
cpu/spc700.asm:54: warning: dropping trailing empty parameter in call to multi-line macro `newsym' [-w+pp-macro-params-legacy]
cpu/spc700.asm:56: warning: dropping trailing empty parameter in call to multi-line macro `newsym' [-w+pp-macro-params-legacy]
cpu/spc700.asm:61: warning: dropping trailing empty parameter in call to multi-line macro `newsym' [-w+pp-macro-params-legacy]
cpu/spc700.asm:66: warning: dropping trailing empty parameter in call to multi-line macro `newsym' [-w+pp-macro-params-legacy]
cpu/spc700.asm:71: warning: dropping trailing empty parameter in call to multi-line macro `newsym' [-w+pp-macro-params-legacy]
cpu/spc700.asm:76: warning: dropping trailing empty parameter in call to multi-line macro `newsym' [-w+pp-macro-params-legacy]
gui/gui.asm:226: warning: dropping trailing empty parameter in call to multi-line macro `newsym' [-w+pp-macro-params-legacy]
gui/menu.asm:28: warning: dropping trailing empty parameter in call to multi-line macro `extern' [-w+pp-macro-params-legacy]
g++  -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT  -D__OPENGL__ -march=native -O3 -fomit-frame-pointer -s -fno-rtti -o jma/jma.o -c jma/jma.cpp
In file included from jma/jma.cpp:19:
jma/jma.h:67:28: error: ISO C++17 does not allow dynamic exception specifications
   67 |     jma_open(const char *) throw(jma_errors);
      |                            ^~~~~
jma/jma.h:71:65: error: ISO C++17 does not allow dynamic exception specifications
   71 |     std::vector<unsigned char *> get_all_files(unsigned char *) throw(jma_errors);
      |                                                                 ^~~~~
jma/jma.h:72:59: error: ISO C++17 does not allow dynamic exception specifications
   72 |     void extract_file(std::string& name, unsigned char *) throw(jma_errors);
      |                                                           ^~~~~
jma/jma.h:82:35: error: ISO C++17 does not allow dynamic exception specifications
   82 |     void chunk_seek(unsigned int) throw(jma_errors);
      |                                   ^~~~~
jma/jma.h:83:32: error: ISO C++17 does not allow dynamic exception specifications
   83 |     void retrieve_file_block() throw(jma_errors);
      |                                ^~~~~
In file included from jma/jma.cpp:24:
jma/crc32.h:23:83: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   23 |   unsigned int CRC32(const unsigned char *, size_t, register unsigned int crc32 = 0xFFFFFFFF);
      |                                                                                   ^~~~~~~~~~
jma/jma.cpp:51:40: error: ISO C++17 does not allow dynamic exception specifications
   51 |   void jma_open::retrieve_file_block() throw(jma_errors)
      |                                        ^~~~~
jma/jma.cpp:171:56: error: ISO C++17 does not allow dynamic exception specifications
  171 |   jma_open::jma_open(const char *compressed_file_name) throw (jma_errors)
      |                                                        ^~~~~
jma/jma.cpp:232:53: error: ISO C++17 does not allow dynamic exception specifications
  232 |   void jma_open::chunk_seek(unsigned int chunk_num) throw(jma_errors)
      |                                                     ^~~~~
jma/jma.cpp:260:74: error: ISO C++17 does not allow dynamic exception specifications
  260 |   vector<unsigned char *> jma_open::get_all_files(unsigned char *buffer) throw(jma_errors)
      |                                                                          ^~~~~
jma/jma.cpp:399:68: error: ISO C++17 does not allow dynamic exception specifications
  399 |   void jma_open::extract_file(string& name, unsigned char *buffer) throw(jma_errors)
      |                                                                    ^~~~~
gmake: *** [Makefile:96: jma/jma.o] Error 1

El problema está en el archivo jma que está relacionado, al parecer con un determinado tipo de archivos que zsnes puede abrir, según filext.com, en los siguientes términos:

Todo sobre los archivos JMA

El tipo de archivo JMA está asociado principalmente con Super Nintendo.
Extensión de archivo JMA
	Extensión de archivo: JMA
Tipo de archivo:  	Juego comprimido NSRT
¿Qué es un archivo JMA?
Los archivos JMA pertenecen principalmente a Super Nintendo de Nintendo. Se reproduce en Snes9x y ZSNES.
Cómo abrir un archivo JMA

Necesitas un software adecuado como Super Nintendo de Nintendo para abrir un archivo JMA. Sin un software adecuado, recibirás un mensaje de Windows diciendo: "¿Cómo quieres abrir este archivo?" o "Windows no puede abrir este archivo" o una alerta similar de Mac/iPhone/Android. Si no puedes abrir el archivo JMA correctamente, intenta hacer clic derecho o mantener presionado el archivo. Después, haz clic en "Abrir con" y elige una aplicación. También puedes mostrar un archivo JMA directamente en el navegador. Sólo tienes que arrastrar el archivo a esta ventana del navegador y soltarlo. 

Una opción es buscar como deshabilitar esto y tener una versión de zsnes que simplemente no abra archivos .jma. Ahora bien, qué es JMA? en este este hilo en un foro de zsnes lo describen así: JMA features an incredible efficiency of compression for roms. For single OR solid archives, jma is better than zip, rar, and 7z.

Compilación de JMA

Al ejecutar gmake, el error que más se repite es error: ISO C++17 does not allow dynamic exception specifications, así que lo busqué y encontré esta solución en un hilo de reddit, está referida a un problema concreto, pero creo que puede servir. Transcribo:

"C++17 does not allow dynamic exception specifications" error when trying to compile a package from the AUR
SOLVED
Solution. Thanks to u/K900_, the solution was to add

  CXXFLAGS="-std=c++14"

to the top of the build() function in PKGBUILD

No supe hacer esto u_u, pero por acá tal vez va la cosa... sin embargo

PLOT-TWIST Jma como mencioné es un formato de compresión de juegos de snes, así que fui al código de snes9x y es un código muy similar, pero de 2008 (el que trae zsnes es de 2007). Así que reemplacé jma.cpp y jma.h originales y... ahora sí! gmake avanzó mucho más, pero llegó hasta el siguiente error:

gcc  -pipe -I. -I/usr/local/include -I/usr/include -D__UNIXSDL__  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT  -D__OPENGL__ -march=native -O3 -fomit-frame-pointer -s -o zip/zpng.o -c zip/zpng.c
zip/zpng.c: In function ‘Png_Dump’:
zip/zpng.c:132:17: error: invalid use of incomplete typedef ‘png_info’ {aka ‘struct png_info_def’}
  132 |         info_ptr->color_type = PNG_COLOR_TYPE_RGB;
      |                 ^~
gmake: *** [Makefile:94: zip/zpng.o] Error 1

y, hasta aquí llegué. Ojalá podamos terminar de configurar esto mañana. Parece que va a haber que instalar libpng xd

./configure --enable-release

aun no