Skip to content

Commit

Permalink
add eggs' src
Browse files Browse the repository at this point in the history
  • Loading branch information
Apaczer committed Feb 23, 2023
1 parent 7fe3dac commit 74078f3
Show file tree
Hide file tree
Showing 16 changed files with 519 additions and 794 deletions.
156 changes: 78 additions & 78 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
#
# race-od for the RetroFW
#
# by pingflood; 2019
#

TARGET = race-od/race-od.dge

CHAINPREFIX := /opt/mipsel-RetroFW-linux-uclibc
CROSS_COMPILE := $(CHAINPREFIX)/usr/bin/mipsel-linux-

CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)g++

SYSROOT := $(shell $(CC) --print-sysroot)
SDL_CFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --cflags)
SDL_LIBS := $(shell $(SYSROOT)/usr/bin/sdl-config --libs)


# Define compilation type
#OSTYPE=msys
OSTYPE=oda320
#OSTYPE=odgcw

PRGNAME = race-od

# define regarding OS, which compiler to use
ifeq "$(OSTYPE)" "msys"
EXESUFFIX = .exe
TOOLCHAIN = /c/MinGW32
CC = gcc
CCP = g++
LD = g++
else
ifeq "$(OSTYPE)" "oda320"
TOOLCHAIN = /opt/miyoo
else
TOOLCHAIN = /opt/gcw0-toolchain/usr
endif
EXESUFFIX = .dge
CC = $(TOOLCHAIN)/bin/arm-miyoo-linux-uclibcgnueabi-gcc
CCP = $(TOOLCHAIN)/bin/arm-miyoo-linux-uclibcgnueabi-g++
LD = $(TOOLCHAIN)/bin/arm-miyoo-linux-uclibcgnueabi-g++
endif

# add SDL dependencies
SDL_LIB = $(TOOLCHAIN)/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/lib
SDL_INCLUDE = $(TOOLCHAIN)/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/include

# change compilation / linking flag options
ifeq "$(OSTYPE)" "msys"
F_OPTS = -fpermissive -fno-exceptions -fno-rtti
CC_OPTS = -O2 -g $(F_OPTS)
CFLAGS = -I$(SDL_INCLUDE) -DZ80 -DTARGET_OD -D_MAX_PATH=2048 -DHOST_FPS=60 -DNOUNCRYPT $(CC_OPTS)
CXXFLAGS=$(CFLAGS)
LDFLAGS = -L$(SDL_LIB) -lmingw32 -lSDLmain -lSDL -lz -mwindows
else
F_OPTS = -falign-functions -falign-loops -falign-labels -falign-jumps \
-ffast-math -fsingle-precision-constant -funsafe-math-optimizations \
-fomit-frame-pointer -fno-builtin -fno-common \
-fstrict-aliasing -fexpensive-optimizations \
-finline -finline-functions -fpeel-loops

CC_OPTS = -O3 -mips32 -G0 -D_OPENDINGUX_ $(F_OPTS)
CFLAGS = -Iemu -Iopendingux $(SDL_CFLAGS) -DOPENDINGUX -DCZ80 -DTARGET_OD -D_MAX_PATH=2048 -DHOST_FPS=60 $(CC_OPTS)
CXXFLAGS = $(CFLAGS)
LDFLAGS = $(SDL_LIBS) $(CC_OPTS) -lstdc++ -lSDL -lSDL_image -lSDL_mixer -lSDL_ttf -lpng -lz

BUILD_EMUL = emu/cz80.o \
emu/cz80_support.o \
emu/input.o \
emu/neopopsound.o \
emu/ngpBios.o \
emu/tlcs900h.o \
emu/memory.o \
emu/flash.o \
emu/graphics.o \
emu/main.o \
emu/state.o \
emu/sound.o

BUILD_MZ = emu/ioapi.o emu/unzip.o
BUILD_PORT = opendingux/main.o opendingux/menu.o

OBJS = $(BUILD_EMUL) $(BUILD_PORT)

-ffast-math -fsingle-precision-constant -funsafe-math-optimizations \
-fomit-frame-pointer -fno-builtin -fno-common \
-fstrict-aliasing -fexpensive-optimizations \
-finline -finline-functions -fpeel-loops -fno-exceptions -fno-rtti -fpermissive \
-fdata-sections -ffunction-sections -fno-PIC
#F_OPTS = -falign-functions -falign-loops -falign-labels -falign-jumps \
# -ffast-math -fsingle-precision-constant -funsafe-math-optimizations \
# -fomit-frame-pointer -fno-builtin -fno-common \
# -fstrict-aliasing -fexpensive-optimizations \
# -finline -finline-functions -fpeel-loops
ifeq "$(OSTYPE)" "oda320"
CC_OPTS = -Ofast -march=armv5te -mtune=arm926ej-s -msoft-float -DNOUNCRYPT $(F_OPTS)
else
CC_OPTS = -O2 -mips32 -mhard-float -G0 -DNOUNCRYPT $(F_OPTS)
endif
CFLAGS = -I$(SDL_INCLUDE) -D_OPENDINGUX_ -DZ80 -DTARGET_OD -D_MAX_PATH=2048 -DHOST_FPS=60 $(CC_OPTS)
CXXFLAGS = $(CFLAGS)
LDFLAGS = -L$(SDL_LIB) $(CC_OPTS) -lstdc++ -lSDL -lSDL_image -lz
#LDFLAGS = $(SDL_LIBS) $(CC_OPTS) -lstdc++ -lSDL -lSDL_image -lSDL_mixer -lSDL_ttf -lz
endif

# Files to be compiled
SRCDIR = ./emu ./opendingux .
VPATH = $(SRCDIR)
SRC_C = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.c))
SRC_CP = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.cpp))
OBJ_C = $(notdir $(patsubst %.c, %.o, $(SRC_C)))
OBJ_CP = $(notdir $(patsubst %.cpp, %.o, $(SRC_CP)))
OBJS = $(OBJ_C) $(OBJ_CP)

# Rules to make executable
all: $(OBJS) $(BUILD_MZ)
$(LD) -o $(TARGET) $^ $(LDFLAGS)

$(OBJS): %.o : %.cpp
$(CC) $(CXXFLAGS) -c -o $@ $<

$(BUILD_MZ): %.o : %.c
$(CC) $(CXXFLAGS) -c -o $@ $<
$(PRGNAME)$(EXESUFFIX): $(OBJS)
ifeq "$(OSTYPE)" "msys"
$(LD) $(CFLAGS) -o $(PRGNAME)$(EXESUFFIX) $^ $(LDFLAGS)
else
$(LD) $(LDFLAGS) -o $(PRGNAME)$(EXESUFFIX) $^
endif

ipk: all
@rm -rf /tmp/.race-od-ipk/ && mkdir -p /tmp/.race-od-ipk/root/home/retrofw/emus/race-od /tmp/.race-od-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators /tmp/.race-od-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators.systems
@cp -r race-od/race-od.dge race-od/race-od.png race-od/backdrop.png race-od/skin.png race-od/race-od.man.txt /tmp/.race-od-ipk/root/home/retrofw/emus/race-od
@cp race-od/race-od.lnk /tmp/.race-od-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators
@cp race-od/ngp.race-od.lnk /tmp/.race-od-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators.systems
@sed "s/^Version:.*/Version: $$(date +%Y%m%d)/" race-od/control > /tmp/.race-od-ipk/control
@cp race-od/conffiles /tmp/.race-od-ipk/
@tar --owner=0 --group=0 -czvf /tmp/.race-od-ipk/control.tar.gz -C /tmp/.race-od-ipk/ control conffiles
@tar --owner=0 --group=0 -czvf /tmp/.race-od-ipk/data.tar.gz -C /tmp/.race-od-ipk/root/ .
@echo 2.0 > /tmp/.race-od-ipk/debian-binary
@ar r race-od/race-od.ipk /tmp/.race-od-ipk/control.tar.gz /tmp/.race-od-ipk/data.tar.gz /tmp/.race-od-ipk/debian-binary
$(OBJ_C) : %.o : %.c
$(CC) $(CFLAGS) -c -o $@ $<

opk: all
@mksquashfs \
race-od/default.retrofw.desktop \
race-od/ngp.retrofw.desktop \
race-od/race-od.dge \
race-od/race-od.png \
race-od/race-od.man.txt \
race-od/backdrop.png \
race-od/skin.png \
race-od/race-od.opk \
-all-root -noappend -no-exports -no-xattrs
$(OBJ_CP) : %.o : %.cpp
$(CCP) $(CXXFLAGS) -c -o $@ $<

clean:
rm -f $(TARGET) *.o emu/*.o opendingux/*.o
rm -f $(PRGNAME)$(EXESUFFIX) *.o
23 changes: 14 additions & 9 deletions emu/flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "flash.h"
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>

//#define DEBUG_FLASH
#ifdef DEBUG_FLASH
Expand Down Expand Up @@ -60,18 +59,18 @@ unsigned char currentCommand = NO_COMMAND;

#define FLASH_VALID_ID 0x0053

typedef struct NGFheaderStruct
typedef struct
{
unsigned short version; //always 0x53?
unsigned short numBlocks; //how many blocks are in the file
unsigned long fileLen; //length of the file
} ;
} NGFheaderStruct;

typedef struct blockStruct
typedef struct
{
unsigned long NGPCaddr; //where this block starts (in NGPC memory map)
unsigned long len; // length of following data
} ;
} blockStruct;

#define MAX_BLOCKS 35 //a 16m chip has 35 blocks (SA0-SA34)
unsigned char blocksDirty[2][MAX_BLOCKS]; //max of 2 chips
Expand Down Expand Up @@ -207,8 +206,11 @@ void setupNGFfilename()
#endif
}

sprintf(ngfFilename, "%s/.race-od/%s", getenv("HOME"), SAVEGAME_DIR);
mkdir(ngfFilename, 0777);
#ifdef TARGET_OD
sprintf(ngfFilename,"%s/.race-od/%s",getenv("HOME"),strrchr(m_emuInfo.RomFileName,'/')+1);
// strcpy(ngfFilename, m_emuInfo.RomFileName);
#else
strcpy(ngfFilename, SAVEGAME_DIR);

pos = strlen(m_emuInfo.RomFileName);

Expand All @@ -224,6 +226,7 @@ void setupNGFfilename()
}

strcat(ngfFilename, &m_emuInfo.RomFileName[slashSpot+1]);
#endif

for(pos=strlen(ngfFilename);pos>=0 && dotSpot == -1; pos--)
{
Expand All @@ -232,12 +235,14 @@ void setupNGFfilename()
}
if(dotSpot == -1)
{
fprintf(stderr, "setupNGFfilename: Couldn't find the . in %s file\n", ngfFilename);
fprintf(stderr, "setupNGFfilename: Couldn't find the . in %s file %d %d %d\n", ngfFilename,strlen(ngfFilename),dotSpot,pos);
return;
}

strcpy(&ngfFilename[dotSpot+1], "ngf");
#ifdef DEBUG_FLASH
fprintf(stdout, "setupNGFfilename: using %s for save-game info\n", ngfFilename);
#endif
}

//write all the dirty blocks out to a file
Expand Down Expand Up @@ -408,7 +413,7 @@ void loadSaveGameFile()
ngfFile = fopen(ngfFilename, "rb");
if(!ngfFile)
{
printf("loadSaveGameFile: Couldn't open %s file\n", ngfFilename);
fprintf(stderr,"loadSaveGameFile: Couldn't open %s file\n", ngfFilename);
return;
}

Expand Down
42 changes: 12 additions & 30 deletions emu/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ unsigned short p2[16] = {
#define SCREEN_X_OFFSET ((screen->w - BLIT_WIDTH)/2)
#define SCREEN_Y_OFFSET ((screen->h - BLIT_HEIGHT)/2)

#define PSP_FUDGE 0//(32) //32 is good for 480x272 -64 is for 320x240 (squish)
#define SCREEN_OFFET (SCREEN_X_OFFSET + (SCREEN_Y_OFFSET*(screen->w+PSP_FUDGE)))//extra fudge factor for PSP?
#define SCREEN_OFFET (SCREEN_X_OFFSET + (SCREEN_Y_OFFSET*screen->w))

#if !defined(TARGET_PSP) && !defined(TARGET_OD)
#define DO_PERIODIC_FLASH_SAVES
Expand Down Expand Up @@ -219,18 +218,18 @@ inline void graphics_paint()
SDL_Flip(actualScreen);
}
prevZoom=zoom;*/

//For now, no variable zooming
SDL_Rect scrRect = {SCREEN_X_OFFSET, SCREEN_Y_OFFSET, BLIT_WIDTH, BLIT_HEIGHT};
SDL_BlitSurface(screen, &scrRect, actualScreen, &scrRect);
SDL_UpdateRects(actualScreen, 1, &scrRect);
#endif
//SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
#endif
//SDL_Flip(screen);
SDL_Flip(screen);
//}
#endif

#ifndef TARGET_OD
#if defined(DO_FPS_DISPLAY) || defined(DO_PERIODIC_FLASH_SAVES)
static unsigned int startTime = 0;
unsigned int currTime;
Expand Down Expand Up @@ -268,6 +267,7 @@ inline void graphics_paint()
startTime = currTime;
frameCount = 0;
}
#endif

#endif
}
Expand Down Expand Up @@ -349,7 +349,8 @@ void (*palette_init)(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask);

void palette_init32(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask)
{
/* dbg_print("in palette_init32(0x%X, 0x%X, 0x%X)\n", dwRBitMask, dwGBitMask, dwBBitMask);
/*
// dbg_print("in palette_init32(0x%X, 0x%X, 0x%X)\n", dwRBitMask, dwGBitMask, dwBBitMask);
char RShiftCount = 0, GShiftCount = 0, BShiftCount = 0;
char RBitCount = 0, GBitCount = 0, BBitCount = 0;
Expand Down Expand Up @@ -393,11 +394,6 @@ void palette_init32(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask)
{
case NGP:
case NGPC:
case GAMEGEAR:
case LYNX:
case WONDERSWAN:
case WONDERSWANCOLOR:
case ADVISION:
for (b=0; b<16; b++)
for (g=0; g<16; g++)
for (r=0; r<16; r++)
Expand All @@ -406,21 +402,8 @@ void palette_init32(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask)
(((g<<(GBitCount-4))+(g>>(4-(GBitCount-4))))<<GShiftCount) +
(((r<<(RBitCount-4))+(r>>(4-(RBitCount-4))))<<RShiftCount);
break;
case GAMEBOY:
case GAMEBOYPOCKET:
case GAMEBOYCOLOR:
case SUPERGAMEBOY:
case SUPERVISION:
case NES:
for (b=0; b<32; b++)
for (g=0; g<32; g++)
for (r=0; r<32; r++)
totalpalette[b*32*32+g*32+r] =
(((b<<(BBitCount-5))+(b>>(5-(BBitCount-5))))<<BShiftCount) +
(((g<<(GBitCount-5))+(g>>(5-(GBitCount-5))))<<GShiftCount) +
(((r<<(RBitCount-5))+(r>>(5-(RBitCount-5))))<<RShiftCount);
break;
}*/
}
*/
}

void palette_init16(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask)
Expand Down Expand Up @@ -472,7 +455,7 @@ void palette_init16(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask)
for (b=0; b<16; b++)
for (g=0; g<16; g++)
for (r=0; r<16; r++)
totalpalette[b*256+g*16+r] =
totalpalette[b*256+g*16+r] =
(((b<<(BBitCount-4))+(b>>(4-(BBitCount-4))))<<BShiftCount) +
(((g<<(GBitCount-4))+(g>>(4-(GBitCount-4))))<<GShiftCount) +
(((r<<(RBitCount-4))+(r>>(4-(RBitCount-4))))<<RShiftCount);
Expand Down Expand Up @@ -906,7 +889,7 @@ inline void lineSprite(SPRITEDEFS *sprDefs)
inline void spriteSortAll(unsigned int bw)
{
unsigned int spriteCode;
unsigned short *pt;
//unsigned short *pt;
unsigned char x, y, prevx=0, prevy=0;
unsigned int i, j, k, scanline;
SPRITE *spr;
Expand Down Expand Up @@ -1486,7 +1469,7 @@ void myGraphicsBlitLine(unsigned char render)
#elif TARGET_PSP
unsigned short* draw = &drawBuffer[(*scanlineY)*(Screen->Width)];
#else
unsigned short* draw = &drawBuffer[(*scanlineY)*(screen->w+PSP_FUDGE)];//extra fudge factor for PSP???
unsigned short* draw = &drawBuffer[(/*8+*/*scanlineY)*SIZEX/*+8*/];
#endif
unsigned short bgcol;
unsigned int bw = (m_emuInfo.machine == NGP);
Expand Down Expand Up @@ -1674,8 +1657,7 @@ BOOL graphics_init(HWND phWnd)

#ifdef TARGET_OD
palette_init = palette_init16;
palette_init(screen->format->Rmask,
screen->format->Gmask, screen->format->Bmask);
palette_init(screen->format->Rmask,screen->format->Gmask, screen->format->Bmask);
drawBuffer = (unsigned short*)screen->pixels;
#elif TARGET_PSP
palette_init = palette_init16;
Expand Down
12 changes: 3 additions & 9 deletions emu/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@
#define NGPC_SIZEX 160
#define NGPC_SIZEY 152

#define ZOOM_SUPPORT

//render screen 260x152 is good for NGPC
#define SIZEX 260//480//368//320//480
#define SIZEY 152//272//207//240//272

// #define SIZEX 320//480//368//320//480
// #define SIZEY 240//272//207//240//272

//render screen
#define SIZEX 320
#define SIZEY 240

//extern unsigned char bwPaletteDirty, spritePaletteDirty, frontPaletteDirty, backPaletteDirty;
//extern unsigned char bgoowDirty;
Expand Down
Loading

0 comments on commit 74078f3

Please sign in to comment.