This commit is contained in:
SilSon 2018-01-17 00:59:50 +01:00
parent 4ec645a60e
commit 3330d7b3c1
5 changed files with 14907082 additions and 12 deletions

70
Makefile Normal file
View File

@ -0,0 +1,70 @@
prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
CC = gcc
LD = $(CC)
AS = $(CC)
INSTALL = /usr/bin/install -c
CFLAGS = -ansi -pedantic -Wall -O3 -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop -fexpensive-optimizations -fforce-addr -fomit-frame-pointer
LDFLAGS = $(CFLAGS) -s
ASFLAGS = $(CFLAGS)
TARGETS = xgnuboy fbgnuboy sdlgnuboy
ASM_OBJS =
SYS_DEFS = -DHAVE_CONFIG_H -DIS_LITTLE_ENDIAN -DIS_LINUX -D_SVID_SOURCE
SYS_OBJS = sys/nix/nix.o $(ASM_OBJS)
SYS_INCS = -I/usr/local/include -I./sys/nix
FB_OBJS = sys/linux/fbdev.o sys/linux/kb.o sys/pc/keymap.o sys/linux/joy.o sys/oss/oss.o
FB_LIBS =
SVGA_OBJS = sys/svga/svgalib.o sys/pc/keymap.o sys/linux/joy.o sys/oss/oss.o
SVGA_LIBS = -L/usr/local/lib -lvga
SDL_OBJS = sys/sdl/sdl.o sys/sdl/sdl-audio.o sys/sdl/keymap.o
SDL_LIBS = -L/usr/lib/x86_64-linux-gnu -lSDL
SDL_CFLAGS = -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
X11_OBJS = sys/x11/xlib.o sys/x11/keymap.o sys/linux/joy.o sys/oss/oss.o
X11_LIBS = -lX11 -lXext
all: $(TARGETS)
include Rules
fbgnuboy: $(OBJS) $(SYS_OBJS) $(FB_OBJS)
$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(FB_OBJS) -o $@ $(FB_LIBS)
sgnuboy: $(OBJS) $(SYS_OBJS) $(SVGA_OBJS)
$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(SVGA_OBJS) -o $@ $(SVGA_LIBS)
sdlgnuboy: $(OBJS) $(SYS_OBJS) $(SDL_OBJS)
$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(SDL_OBJS) -o $@ $(SDL_LIBS)
sys/sdl/sdl.o: sys/sdl/sdl.c
$(MYCC) $(SDL_CFLAGS) -c $< -o $@
sys/sdl/keymap.o: sys/sdl/keymap.c
$(MYCC) $(SDL_CFLAGS) -c $< -o $@
xgnuboy: $(OBJS) $(SYS_OBJS) $(X11_OBJS)
$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(X11_OBJS) -o $@ $(X11_LIBS)
install: all
$(INSTALL) -d $(bindir)
$(INSTALL) -m 755 $(TARGETS) $(bindir)
clean:
rm -f *gnuboy gmon.out *.o sys/*.o sys/*/*.o asm/*/*.o $(OBJS)
distclean: clean
rm -f config.* sys/nix/config.h Makefile

16
emu.c
View File

@ -1,6 +1,3 @@
#include "defs.h"
#include "regs.h"
#include "hw.h"
@ -17,6 +14,8 @@
static int framelen = 16743;
static int framecount;
rcvar_t emu_exports[] =
{
RCV_INT("framelen", &framelen),
@ -25,17 +24,10 @@ rcvar_t emu_exports[] =
};
void emu_init()
{
}
/*
* emu_reset is called to initialize the state of the emulated
* system. It should set cpu registers, hardware registers, etc. to
@ -49,6 +41,7 @@ void emu_reset()
cpu_reset();
mbc_reset();
sound_reset();
emu_init();
}
@ -72,6 +65,9 @@ void emu_run()
void *timer = sys_timer();
int delay;
unsigned char x,y;
vid_begin();
lcd_begin();
for (;;)

14906882
output.log Normal file

File diff suppressed because it is too large Load Diff

1
sys.h
View File

@ -29,7 +29,6 @@ void kb_init();
void kb_poll();
void kb_close();
/* FIXME these have different prototype for obsolete ( == M$ ) platforms */
#include <sys/time.h>
int sys_elapsed(struct timeval *prev);

View File

@ -13,11 +13,31 @@
#include <SDL/SDL.h>
/* Von Stefan */
#include <string.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define BUFSIZE 5760
#define SERVICE_PORT 2323
#define FRAME_SKIP -1
/* Ende von Stefan */
#include "fb.h"
#include "input.h"
#include "rc.h"
/* By Stefan */
static struct sockaddr_in myaddr, remaddr;
static int fd, slen=sizeof(remaddr);
static char frame[BUFSIZE]; /* message buffer */
static char *server = "195.160.169.37"; /* change this to use a different server */
static int frameCount = 0;
/* End Stefan */
struct fb fb;
static int use_yuv = -1;
@ -203,6 +223,37 @@ void vid_init()
fb.enabled = 1;
fb.dirty = 0;
/* Start Init Stefan */
/* create a socket */
printf("Start Init\n");
if ((fd=socket(AF_INET, SOCK_DGRAM, 0))==-1)
printf("socket created\n");
/* bind it to all local addresses and pick any port number */
memset((char *)&myaddr, 0, sizeof(myaddr));
myaddr.sin_family = AF_INET;
myaddr.sin_addr.s_addr = htonl(INADDR_ANY);
myaddr.sin_port = htons(0);
if (bind(fd, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) {
die("bind failed");
}
/* now define remaddr, the address to whom we want to send messages */
/* For convenience, the host address is expressed as a numeric IP address */
/* that we will convert to a binary format via inet_aton */
memset((char *) &remaddr, 0, sizeof(remaddr));
remaddr.sin_family = AF_INET;
remaddr.sin_port = htons(SERVICE_PORT);
if (inet_aton(server, &remaddr.sin_addr)==0) {
fprintf(stderr, "inet_aton() failed\n");
die("1");
}
printf("End Init\n");
/* Ende Stefan */
}
@ -403,6 +454,9 @@ void vid_settitle(char *title)
void vid_begin()
{
int x;
char y;
if (overlay)
{
SDL_LockYUVOverlay(overlay);
@ -411,6 +465,75 @@ void vid_begin()
}
SDL_LockSurface(screen);
fb.ptr = screen->pixels;
frameCount++;
if (frameCount % FRAME_SKIP) {
return;
}
/* Stefan Start - Sending Frame via UDP to DFI*/
/* Geht so halb...
for(x=0; x<144*40; x++){
if(fb.ptr[x*16]==29) frame[x]=0;
if(fb.ptr[x*16]==99) frame[x]=1;
if(fb.ptr[x*16]==107) frame[x]=2;
if(fb.ptr[x*16]==156) frame[x]=3;
if(fb.ptr[(x*16)+4]==29) frame[x]+=0;
if(fb.ptr[(x*16)+4]==99) frame[x]+=4;
if(fb.ptr[(x*16)+4]==107) frame[x]+=8;
if(fb.ptr[(x*16)+4]==156) frame[x]+=12;
if(fb.ptr[(x*16)+8]==29) frame[x]+=0;
if(fb.ptr[(x*16)+8]==99) frame[x]+=16;
if(fb.ptr[(x*16)+8]==107) frame[x]+=32;
if(fb.ptr[(x*16)+8]==156) frame[x]+=48;
if(fb.ptr[(x*16)+12]==29) frame[x]+=0;
if(fb.ptr[(x*16)+12]==99) frame[x]+=64;
if(fb.ptr[(x*16)+12]==107) frame[x]+=128;
if(fb.ptr[(x*16)+12]==156) frame[x]+=192;
} */
int displaySize = 144*160;
for(x=0; x<displaySize; x++){
int color = fb.ptr[x*4];
if (color == 41) {
y=0;
} else if (color == 99) {
y=1;
} else if (color <= 107) {
y=2;
} else if (color <= 156) {
y=3;
} else {
y=0;
}
int pixelModulo = x %4;
if (pixelModulo == 0) {
frame[x/4] =y;
} else if (pixelModulo == 1) {
frame[x/4]+=(y<<2);
} else if (pixelModulo == 2) {
frame[x/4]+=(y<<4);
} else if (pixelModulo == 3) {
frame[x/4]+=(y<<6);
}
}
if (sendto(fd, frame, BUFSIZE, 0, (struct sockaddr *)&remaddr, slen)==-1) {
printf("error sending frame\n");
}
/*printf("send; %d\n",frameCount);*/
/* Stefan Ende */
}
void vid_end()