Subject: Re: Genesis emulators?
To: Michael Core <520079546242-0001@t-online.de>
From: Alistair Crooks <agc@wasabisystems.com>
List: current-users
Date: 05/09/2002 21:14:05
I've added generator to pkgsrc (pkgsrc/emulators/generator), but was
unable to test it myself, due to lack of games for it.

I suppose there will still need to be modifications made to the pkgsrc
version, because of this lack of testing. Left as an exercise for the
reader.

The version in pkgsrc at the moment compiles and runs to the point of
being able to bring down menus, etc.

Regards,
Alistair

On Thu, May 09, 2002 at 08:41:29PM +0200, Michael Core wrote:
> Peter Seebach wrote:
> 
> > In message <20020509154313.2c7ff807.520079546242-0001@t-online.de>,
> > Michael Cor e writes:
> > >This one works well, it lacks a fullscreen mode, only:
> > >http://www.squish.net/generator
> > 
> > My attempt to get it to build failed for lack of <sys/soundcard.h>.
> 
> You'll have to patch a few lines. BTW, there's really something strange. I
> had to exchange stat() against lseek() because stat() sets statbuf.st_size
> to 0 here. I cannot understand that at all. The patch is at the end of
> this post. Move to generator-0.34/main and run "patch < patchfile".
> 
> > >There's also one called "dgen", but it doesn't work if my soundcard _is
> > >not_ busy:
> > 
> > >http://www.pknet.com/~joe/dgen-sdl.html
> > 
> > Weird!  I had noticed that dgen seemed to wedge.  I didn't try playing
> > other sounds.
> 
> Alad*in without sound? Are you crazy?? ;-) Most Genesis games have really
> cool sound. I wouldn't want to miss it.
> 
> --- generator.c.orig	Sat Oct 20 19:04:00 2001
> +++ generator.c	Thu May  9 20:28:08 2002
> @@ -3,9 +3,8 @@
>  #include <stdlib.h>
>  #include <stdio.h>
>  #include <string.h>
> -#include <sys/stat.h>
> -#include <unistd.h>
>  #include <sys/types.h>
> +#include <unistd.h>
>  #include <fcntl.h>
>  #include <ctype.h>
>  #include <signal.h>
> @@ -147,7 +146,7 @@
>  char *gen_loadimage(const char *filename)
>  {
>    int file, imagetype, bytes, bytesleft;
> -  struct stat statbuf;
> +  off_t	filesize;
>    const char *extension;
>    uint8 *buffer;
>    unsigned int blocks, x, i;
> @@ -162,11 +161,31 @@
>    }
>  
>    /* Load file */
> -  if (stat(filename, &statbuf) != 0)
> -    return ("Unable to stat file.");
> -  cpu68k_romlen = statbuf.st_size;
> +#ifdef ALLEGRO
> +  if ((file = open(filename, O_RDONLY | O_BINARY, 0)) == -1) {
> +#else
> +  if ((file = open(filename, O_RDONLY)) == -1) {
> +#endif
> +    perror("open");
> +    cpu68k_rom = NULL;
> +    cpu68k_romlen = 0;
> +    return ("Unable to open file.");
> +  }
> +
> +  if (	(filesize = lseek(file, 0, SEEK_END)) == -1 || // get size
> +  		lseek(file, 0, SEEK_SET) == -1) // then seek to start
> +  {
> +   perror ("lseek failed");
> +   close (file);
> +   return ("Error accessing file");
> +  }
> +  
> +  cpu68k_romlen = filesize;
>    if (cpu68k_romlen < 0x200)
> -    return ("File is too small");
> +  {
> +    close(file);
> +	return ("File is too small");
> +  }	
>  
>    /* allocate enough memory plus 16 bytes for disassembler to cope
>       with the last instruction */
> @@ -176,16 +195,7 @@
>    }
>    gen_freerom = 1;
>    memset(cpu68k_rom, 0, cpu68k_romlen + 16);
> -#ifdef ALLEGRO
> -  if ((file = open(filename, O_RDONLY | O_BINARY, 0)) == -1) {
> -#else
> -  if ((file = open(filename, O_RDONLY, 0)) == -1) {
> -#endif
> -    perror("open");
> -    cpu68k_rom = NULL;
> -    cpu68k_romlen = 0;
> -    return ("Unable to open file.");
> -  }
> +
>    buffer = cpu68k_rom;
>    bytesleft = cpu68k_romlen;
>    do {
> --- gensoundp-unix.c.orig	Sat Oct  6 23:11:17 2001
> +++ gensoundp-unix.c	Thu May  9 20:28:15 2002
> @@ -22,7 +22,11 @@
>  #  include "fm.h"
>  #endif
>  
> -#include <sys/soundcard.h>
> +#ifdef __NetBSD__
> +#	include <soundcard.h>
> +#else
> +#	include <sys/soundcard.h>
> +#endif /* __NetBSD__ */
>  
>  #define SOUND_DEVICE "/dev/dsp"
>