libsnes update from Themaister

This commit is contained in:
Barry Harris 2012-01-28 20:14:07 +00:00
parent 845ccaceab
commit 19f5d906e1
9 changed files with 789 additions and 372 deletions

View File

@ -29,6 +29,20 @@ else ifeq ($(platform), ps3)
AR = ppu-lv2-ar
ENDIANNESS_DEFINES = -DWORDS_BIGENDIAN
PLATFORM_DEFINES := -D__CELLOS_LV2 -DSN_TARGET_PS3
else ifeq ($(platform), xenon)
TARGET := libsnes.a
CC = xenon-gcc
CXX = xenon-g++
AR = xenon-ar
ENDIANNESS_DEFINES = -DWORDS_BIGENDIAN
PLATFORM_DEFINES := -D__LIBXENON__ -m32 -D__ppc__
else ifeq ($(platform), wii)
TARGET := libsnes.a
CC = powerpc-eabi-gcc
CXX = powerpc-eabi-g++
AR = powerpc-eabi-ar
ENDIANNESS_DEFINES = -DWORDS_BIGENDIAN
PLATFORM_DEFINES := -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__
else
TARGET := snes.dll
CC = gcc
@ -40,34 +54,114 @@ endif
all: $(TARGET)
MAIN_FBA_DIR := ./fbalpha/trunk/src
MAIN_FBA_DIR := src
FBA_BURN_DIR := $(MAIN_FBA_DIR)/burn
FBA_BURN_DRIVERS_DIR := $(MAIN_FBA_DIR)/burn/drivers
FBA_BURN_DRIVERS_DIR := $(MAIN_FBA_DIR)/burn/drv
FBA_BURNER_DIR := $(MAIN_FBA_DIR)/burner
LIBSNES_DIR := ./libsnes
LIBSNES_DIR := libsnes
FBA_CPU_DIR := $(MAIN_FBA_DIR)/cpu
FBA_LIB_DIR := ./utils
FBA_INTERFACE_DIR := $(MAIN_FBA_DIR)/interface
FBA_LIB_DIR := $(MAIN_FBA_DIR)/dep/libs
FBA_INTERFACE_DIR := $(MAIN_FBA_DIR)/intf
BURN_BLACKLIST := $(FBA_BURN_DIR)/zet_c68k.cpp $(FBA_BURN_DIR)/sek_c68k.cpp $(FBA_BURNER_DIR)/tracklst.cpp $(FBA_CPU_DIR)/arm7/arm7exec.c $(FBA_CPU_DIR)/arm7/arm7core.c $(FBA_CPU_DIR)/hd6309/6309tbl.c $(FBA_CPU_DIR)/hd6309/6309ops.c $(FBA_CPU_DIR)/konami/konamtbl.c $(FBA_CPU_DIR)/konami/konamops.c $(FBA_CPU_DIR)/m68k/m68k_in.c $(FBA_CPU_DIR)/m6800/6800ops.c $(FBA_CPU_DIR)/m6800/6800tbl.c $(FBA_CPU_DIR)/m6805/6805ops.c $(FBA_CPU_DIR)/m6809/6809ops.c $(FBA_CPU_DIR)/m6809/6809tbl.c $(FBA_CPU_DIR)/sh2/mksh2.cpp $(FBA_CPU_DIR)/sh2/mksh2-x86.cpp $(FBA_CPU_DIR)/m68k/m68kmake.c $(FBA_BURNER_DIR)/wave_writer.cpp $(FBA_CPU_DIR)/m68k/m68kdasm.c $(FBA_LIBSNES_DIR)/menu.cpp $(FBA_CPU_DIR)/sh2/mksh2.cpp $(FBA_BURNER_DIR)/sshot.cpp $(FBA_BURNER_DIR)/conc.cpp $(FBA_BURNER_DIR)/dat.cpp $(FBA_BURNER_DIR)/cong.cpp $(FBA_BURNER_DIR)/image.cpp $(FBA_BURNER_DIR)/misc.cpp $(FBA_CPU_DIR)/h6280/tblh6280.c $(FBA_CPU_DIR)/m6502/t65sc02.c $(FBA_CPU_DIR)/m6502/t65c02.c $(FBA_CPU_DIR)/m6502/tdeco16.c $(FBA_CPU_DIR)/m6502/tn2a03.c $(FBA_CPU_DIR)/m6502/t6502.c $(FBA_CPU_DIR)/nec/v25sfr.c $(FBA_CPU_DIR)/nec/v25instr.c $(FBA_CPU_DIR)/nec/necinstr.c $(FBA_BURN_DIR)/drivers/capcom/ctv_make.cpp
BURN_BLACKLIST := $(FBA_BURN_DIR)/zet_c68k.cpp \
$(FBA_BURN_DIR)/sek_c68k.cpp \
$(FBA_BURNER_DIR)/tracklst.cpp \
$(FBA_CPU_DIR)/arm7/arm7exec.c \
$(FBA_CPU_DIR)/arm7/arm7core.c \
$(FBA_CPU_DIR)/hd6309/6309tbl.c \
$(FBA_CPU_DIR)/hd6309/6309ops.c \
$(FBA_CPU_DIR)/konami/konamtbl.c \
$(FBA_CPU_DIR)/konami/konamops.c \
$(FBA_CPU_DIR)/m68k/m68k_in.c \
$(FBA_CPU_DIR)/m6800/6800ops.c \
$(FBA_CPU_DIR)/m6800/6800tbl.c \
$(FBA_CPU_DIR)/m6805/6805ops.c \
$(FBA_CPU_DIR)/m6809/6809ops.c \
$(FBA_CPU_DIR)/m6809/6809tbl.c \
$(FBA_CPU_DIR)/sh2/mksh2.cpp \
$(FBA_CPU_DIR)/sh2/mksh2-x86.cpp \
$(FBA_CPU_DIR)/m68k/m68kmake.c \
$(FBA_BURNER_DIR)/wave_writer.cpp \
$(FBA_CPU_DIR)/m68k/m68kdasm.c \
$(FBA_LIBSNES_DIR)/menu.cpp \
$(FBA_CPU_DIR)/sh2/mksh2.cpp \
$(FBA_BURNER_DIR)/sshot.cpp \
$(FBA_BURNER_DIR)/conc.cpp \
$(FBA_BURNER_DIR)/dat.cpp \
$(FBA_BURNER_DIR)/cong.cpp \
$(FBA_BURNER_DIR)/image.cpp \
$(FBA_BURNER_DIR)/misc.cpp \
$(FBA_CPU_DIR)/h6280/tblh6280.c \
$(FBA_CPU_DIR)/m6502/t65sc02.c \
$(FBA_CPU_DIR)/m6502/t65c02.c \
$(FBA_CPU_DIR)/m6502/tdeco16.c \
$(FBA_CPU_DIR)/m6502/tn2a03.c \
$(FBA_CPU_DIR)/m6502/t6502.c \
$(FBA_CPU_DIR)/nec/v25sfr.c \
$(FBA_CPU_DIR)/nec/v25instr.c \
$(FBA_CPU_DIR)/nec/necinstr.c \
$(FBA_BURN_DIR)/drv/capcom/ctv_make.cpp
FBA_BURN_DIRS := $(FBA_BURN_DIR) $(FBA_BURN_DIR)/devices $(FBA_BURN_DIR)/sound $(FBA_BURN_DRIVERS_DIR)/capcom $(FBA_BURN_DRIVERS_DIR)/cave $(FBA_BURN_DRIVERS_DIR)/dataeast $(FBA_BURN_DRIVERS_DIR)/cps3 $(FBA_BURN_DRIVERS_DIR)/galaxian $(FBA_BURN_DRIVERS_DIR)/konami $(FBA_BURN_DRIVERS_DIR)/irem $(FBA_BURN_DRIVERS_DIR)/megadrive $(FBA_BURN_DRIVERS_DIR)/misc $(FBA_BURN_DRIVERS_DIR)/neogeo $(FBA_BURN_DRIVERS_DIR)/pgm $(FBA_BURN_DRIVERS_DIR)/psikyo $(FBA_BURN_DRIVERS_DIR)/sega $(FBA_BURN_DRIVERS_DIR)/taito $(FBA_BURN_DRIVERS_DIR)/toaplan $(FBA_BURN_DRIVERS_DIR)/misc_post90s $(FBA_BURN_DRIVERS_DIR)/misc_pre90s
FBA_BURN_DIRS := $(FBA_BURN_DIR) \
$(FBA_BURN_DIR)/devices \
$(FBA_BURN_DIR)/snd \
$(FBA_BURN_DRIVERS_DIR)/capcom \
$(FBA_BURN_DRIVERS_DIR)/cave \
$(FBA_BURN_DRIVERS_DIR)/dataeast \
$(FBA_BURN_DRIVERS_DIR)/cps3 \
$(FBA_BURN_DRIVERS_DIR)/galaxian \
$(FBA_BURN_DRIVERS_DIR)/konami \
$(FBA_BURN_DRIVERS_DIR)/irem \
$(FBA_BURN_DRIVERS_DIR)/megadrive \
$(FBA_BURN_DRIVERS_DIR)/misc \
$(FBA_BURN_DRIVERS_DIR)/neogeo \
$(FBA_BURN_DRIVERS_DIR)/pgm \
$(FBA_BURN_DRIVERS_DIR)/psikyo \
$(FBA_BURN_DRIVERS_DIR)/sega \
$(FBA_BURN_DRIVERS_DIR)/taito \
$(FBA_BURN_DRIVERS_DIR)/toaplan \
$(FBA_BURN_DRIVERS_DIR)/pre90s
FBA_CPU_DIRS := $(FBA_CPU_DIR) $(FBA_CPU_DIR)/arm7 $(FBA_CPU_DIR)/arm $(FBA_CPU_DIR)/hd6309 $(FBA_CPU_DIR)/i8039 $(FBA_CPU_DIR)/konami $(FBA_CPU_DIR)/m68k $(FBA_CPU_DIR)/m6502 $(FBA_CPU_DIR)/m6800 $(FBA_CPU_DIR)/m6805 $(FBA_CPU_DIR)/m6809 $(FBA_CPU_DIR)/nec $(FBA_CPU_DIR)/s2650 $(FBA_CPU_DIR)/sh2 $(FBA_CPU_DIR)/z80 $(FBA_CPU_DIR)/h6280
FBA_CPU_DIRS := $(FBA_CPU_DIR) \
$(FBA_CPU_DIR)/arm7 \
$(FBA_CPU_DIR)/arm \
$(FBA_CPU_DIR)/hd6309 \
$(FBA_CPU_DIR)/i8039 \
$(FBA_CPU_DIR)/konami \
$(FBA_CPU_DIR)/m68k \
$(FBA_CPU_DIR)/m6502 \
$(FBA_CPU_DIR)/m6800 \
$(FBA_CPU_DIR)/m6805 \
$(FBA_CPU_DIR)/m6809 \
$(FBA_CPU_DIR)/nec \
$(FBA_CPU_DIR)/s2650 \
$(FBA_CPU_DIR)/sh2 \
$(FBA_CPU_DIR)/z80 \
$(FBA_CPU_DIR)/h6280
FBA_LIB_DIRS := $(FBA_LIB_DIR)/zlib $(FBA_LIB_DIR)/File_Extractor/fex $(FBA_LIB_DIR)/File_Extractor/7z_C
FBA_LIB_DIRS := $(FBA_LIB_DIR)/zlib
FBA_SRC_DIRS := $(FBA_BURNER_DIR) $(FBA_BURN_DIRS) $(FBA_CPU_DIRS) $(FBA_BURNER_DIRS) $(FBA_LIB_DIRS)
FBA_CXXSRCS := $(filter-out $(BURN_BLACKLIST),$(foreach dir,$(FBA_SRC_DIRS),$(wildcard $(dir)/*.cpp)))
FBA_CXXSRCS += $(LIBSNES_DIR)/libsnes.cpp $(LIBSNES_DIR)/archive.cpp $(FBA_BURNER_DIR)/platform/win32/neocdlist.cpp
FBA_CXXSRCS += $(LIBSNES_DIR)/libsnes.cpp $(LIBSNES_DIR)/neocdlist.cpp
FBA_CXXOBJ := $(FBA_CXXSRCS:.cpp=.o)
FBA_CSRCS := $(filter-out $(BURN_BLACKLIST),$(foreach dir,$(FBA_SRC_DIRS),$(wildcard $(dir)/*.c)))
FBA_COBJ := $(FBA_CSRCS:.c=.o)
OBJS := $(FBA_COBJ) $(FBA_CXXOBJ)
FBA_DEFINES := -DNO_ASMCORE -DNO_AUTOFIRE -DNO_CHEATSEARCH -DNO_COMBO -DUSE_SPEEDHACKS -DNO_PNG -DOLD_AUDIOCORE=0 -D__LIBSNES__ $(ENDIANNESS_DEFINES) $(PLATFORM_DEFINES) -DTIXML_USE_TICPP
FBA_DEFINES := -DNO_ASMCORE \
-DNO_AUTOFIRE \
-DNO_CHEATSEARCH \
-DNO_COMBO \
-DUSE_SPEEDHACKS \
-DNO_PNG \
-DOLD_AUDIOCORE=0 \
-D__LIBSNES__ \
$(ENDIANNESS_DEFINES) \
$(PLATFORM_DEFINES) \
-DTIXML_USE_TICPP
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
@ -81,12 +175,53 @@ CFLAGS += -std=gnu99 $(fpic) -Wno-write-strings $(FBA_DEFINES)
CXXFLAGS += $(fpic) -Wno-write-strings $(FBA_DEFINES)
LDFLAGS += -Wl,-no-undefined $(fpic) -Wl,--version-script=libsnes/link.T
INCDIRS := -I$(FBA_BURNER_DIR)/platform/win32 -I$(LIBSNES_DIR) -I$(FBA_BURN_DIR) -I$(FBA_BURN_DIR)/burner -I$(MAIN_FBA_DIR)/cpu -I$(FBA_BURN_DIR)/sound -I$(FBA_BURN_DIR)/devices -I../../generated -I$(FBA_INTERFACE_DIR) -I$(FBA_INTERFACE_DIR)/input -I$(FBA_INTERFACE_DIR)/cd -I$(FBA_BURNER_DIR) -I$(MAIN_FBA_DIR)/generated -I$(FBA_CPU_DIR) -I$(FBA_CPU_DIR)/m6809 -I$(FBA_CPU_DIR)/m6805 -I$(FBA_CPU_DIR)/m6800 -I$(FBA_CPU_DIR)/nec -I$(FBA_CPU_DIR)/hd6309 -I$(FBA_CPU_DIR)/arm7 -I$(FBA_CPU_DIR)/i8039 -I$(FBA_CPU_DIR)/konami -I$(FBA_CPU_DIR)/m68k -I$(FBA_CPU_DIR)/m6502 -I$(FBA_CPU_DIR)/z80 -I$(FBA_CPU_DIR)/sh2 -I$(FBA_CPU_DIR)/s2650 -I$(FBA_CPU_DIR)/arm -I$(FBA_LIB_DIR)/zlib -I$(FBA_BURN_DIR)/drivers/capcom -I$(FBA_BURN_DIR)/drivers/dataeast -I$(FBA_BURN_DIR)/drivers/cave -I$(FBA_BURN_DIR)/drivers/neogeo -I$(FBA_BURN_DIR)/drivers/psikyo -I$(FBA_BURN_DIR)/drivers/sega -I$(FBA_BURN_DIR)/drivers/toaplan -I$(FBA_BURN_DIR)/drivers/taito -I$(FBA_BURN_DIR)/drivers/misc_post90s -I$(FBA_LIB_DIR)
INCDIRS := -I$(FBA_BURNER_DIR)/win32 \
-I$(LIBSNES_DIR) \
-I$(FBA_BURN_DIR) \
-I$(FBA_BURN_DIR)/burner \
-I$(MAIN_FBA_DIR)/cpu \
-I$(FBA_BURN_DIR)/snd \
-I$(FBA_BURN_DIR)/devices \
-I$(FBA_INTERFACE_DIR) \
-I$(FBA_INTERFACE_DIR)/input \
-I$(FBA_INTERFACE_DIR)/cd \
-I$(FBA_BURNER_DIR) \
-I$(MAIN_FBA_DIR)/generated \
-I$(FBA_CPU_DIR) \
-I$(FBA_CPU_DIR)/m6809 \
-I$(FBA_CPU_DIR)/m6805 \
-I$(FBA_CPU_DIR)/m6800 \
-I$(FBA_CPU_DIR)/h6280 \
-I$(FBA_CPU_DIR)/nec \
-I$(FBA_CPU_DIR)/hd6309 \
-I$(FBA_CPU_DIR)/arm7 \
-I$(FBA_CPU_DIR)/i8039 \
-I$(FBA_CPU_DIR)/konami \
-I$(FBA_CPU_DIR)/m68k \
-I$(FBA_CPU_DIR)/m6502 \
-I$(FBA_CPU_DIR)/z80 \
-I$(FBA_CPU_DIR)/sh2 \
-I$(FBA_CPU_DIR)/s2650 \
-I$(FBA_CPU_DIR)/arm \
-I$(FBA_LIB_DIR)/zlib \
-I$(FBA_BURN_DIR)/drv/capcom \
-I$(FBA_BURN_DIR)/drv/dataeast \
-I$(FBA_BURN_DIR)/drv/cave \
-I$(FBA_BURN_DIR)/drv/neogeo \
-I$(FBA_BURN_DIR)/drv/psikyo \
-I$(FBA_BURN_DIR)/drv/sega \
-I$(FBA_BURN_DIR)/drv/toaplan \
-I$(FBA_BURN_DIR)/drv/taito \
-I$(FBA_LIB_DIR)
$(TARGET): $(OBJS)
@echo "LD $@"
ifeq ($(platform), ps3)
@$(AR) rcs $@ $(OBJECTS)
else ifeq ($(platform), xenon)
@$(AR) rcs $@ $(OBJECTS)
else ifeq ($(platform), wii)
@$(AR) rcs $@ $(OBJECTS)
else
@$(CXX) -o $@ $(SHARED) $(OBJS) $(LDFLAGS)
endif

View File

@ -173,15 +173,15 @@ extern "C" TCHAR* BurnDrvGetText(UINT32 i)
#else
static INT8 szShortNameA[32];
static INT8 szDateA[32];
static INT8 szFullNameA[256];
static INT8 szCommentA[256];
static INT8 szManufacturerA[256];
static INT8 szSystemA[256];
static INT8 szParentA[32];
static INT8 szBoardROMA[32];
static INT8 szSampleNameA[32];
static char szShortNameA[32];
static char szDateA[32];
static char szFullNameA[256];
static char szCommentA[256];
static char szManufacturerA[256];
static char szSystemA[256];
static char szParentA[32];
static char szBoardROMA[32];
static char szSampleNameA[32];
#endif
@ -410,6 +410,7 @@ extern "C" char* BurnDrvGetTextA(UINT32 i)
}
}
#if defined (_UNICODE)
void BurnLocalisationSetName(char *szName, TCHAR *szLongName)
{
for (UINT32 i = 0; i < nBurnDrvCount; i++) {
@ -419,6 +420,7 @@ void BurnLocalisationSetName(char *szName, TCHAR *szLongName)
}
}
}
#endif
// Get the zip names for the driver
extern "C" INT32 BurnDrvGetZipName(char** pszName, UINT32 i)

View File

@ -1,296 +0,0 @@
// Archive extract module, added by regret
// use Blargg's File_Extractor (http://www.slack.net/~ant/)
/* changelog:
update 5: change loadonefile() to use separate fex handle
update 4: update to Blargg's File_Extractor 1.0.0
update 3: rewrite interface, use Blargg's great File_Extractor
update 2: add load one file from archive
update 1: add 7zip aupport
*/
#include "burner.h"
#include "File_Extractor/fex/fex.h"
#include "archive.h"
static File_Extractor* fex = NULL;
static fex_err_t err = NULL;
static int nCurrFile = 0; // The current file we are pointing to
static inline bool error(const char* error)
{
if (error)
{
#ifdef _DEBUG
printf("fex Error: %s\n", error);
#endif
return true;
}
return false;
}
// check if input name has 7z or zip file, the name will link with extension
// return value: 0:zip; 1:7z; -1:none
int archiveCheck(char* name, int zipOnly)
{
if (!name)
return ARC_NONE;
static char archiveName[MAX_PATH] = "";
int ret = ARC_NONE;
// try zip first
sprintf(archiveName, "%s.zip", name);
static File_Extractor* fex_scan = NULL;
static fex_err_t err_scan = NULL;
err_scan = fex_open(&fex_scan, archiveName);
if (!error(err_scan)) {
ret = ARC_ZIP;
strcat(name, ".zip");
} else {
if (!zipOnly) {
// try 7z
sprintf(archiveName, "%s.7z", name);
err_scan = fex_open(&fex_scan, archiveName);
if (!error(err_scan)) {
ret = ARC_7Z;
strcat(name, ".7z");
}
}
}
if (fex_scan) {
fex_close(fex_scan);
fex_scan = NULL;
}
return ret;
}
int archiveOpen(const char* archive)
{
if (!archive)
return 1;
err = fex_open(&fex, archive);
if (error(err))
return 1;
nCurrFile = 0;
return 0;
}
int archiveClose()
{
if (fex) {
fex_close(fex);
fex = NULL;
}
return 0;
}
// Get the contents of a archive file into an array of ArcEntry
int archiveGetList(ArcEntry** list, int* count)
{
if (!fex || !list)
return 1;
int nListLen = 0;
while (!fex_done(fex))
{
err = fex_next(fex);
if (error(err))
{
archiveClose();
return 1;
}
nListLen++;
}
// Make an array of File Entries
if (nListLen == 0)
{
archiveClose();
return 1;
}
ArcEntry* List = (struct ArcEntry *)malloc(nListLen * sizeof(struct ArcEntry));
if (List == NULL)
{
archiveClose();
return 1;
}
memset(List, 0, nListLen * sizeof(ArcEntry));
err = fex_rewind(fex);
if (error(err))
{
archiveClose();
return 1;
}
// Step through all of the files, until we get to the end
for (nCurrFile = 0, err = NULL;
nCurrFile < nListLen && !error(err);
nCurrFile++, err = fex_next(fex))
{
fex_stat(fex);
// Allocate space for the filename
const char* name = fex_name(fex);
if (name == NULL) continue;
char* szName = (char *)malloc(strlen(name) + 1);
if (szName == NULL) continue;
strcpy(szName, name);
List[nCurrFile].szName = szName;
List[nCurrFile].nLen = fex_size(fex);
List[nCurrFile].nCrc = fex_crc32(fex);
}
// return the file list
*list = List;
if (count)
*count = nListLen;
err = fex_rewind(fex);
if (error(err))
{
archiveClose();
return 1;
}
nCurrFile = 0;
return 0;
}
int archiveLoadFile(uint8_t* dest, int nLen, int nEntry, int* wrote)
{
if (!fex || nLen <= 0)
return 1;
// if (nEntry < nCurrFile)
{
err = fex_rewind(fex);
if (error(err))
return 1;
nCurrFile = 0;
}
// Now step through to the file we need
while (nCurrFile < nEntry)
{
err = fex_next(fex);
if (error(err) || fex_done(fex))
return 1;
nCurrFile++;
}
err = fex_read(fex, dest, nLen);
if (error(err))
return 1;
if (wrote != NULL)
*wrote = nLen;
return 0;
}
int archiveLoadOneFile(const char* arc, const char* file, void** dest, int* wrote)
{
File_Extractor* fex_one = NULL;
fex_err_t err_one = fex_open(&fex_one, arc);
if (error(err_one))
return 1;
int nListLen = 0;
while (!fex_done(fex_one))
{
err_one = fex_next(fex_one);
if (error(err_one))
{
fex_close(fex_one);
return 1;
}
nListLen++;
}
if (nListLen <= 0)
{
fex_close(fex_one);
return 1;
}
err_one = fex_rewind(fex_one);
if (error(err_one))
{
fex_close(fex_one);
return 1;
}
if (file) {
const char* filename = file;
int currentFile = 0;
for (currentFile = 0, err_one = NULL;
currentFile < nListLen && !error(err_one);
currentFile++, err_one = fex_next(fex_one))
{
fex_stat(fex_one);
const char* name = fex_name(fex_one);
if (name == NULL)
continue;
if (!strcmp(name, filename))
break;
}
if (currentFile == nListLen)
{
fex_close(fex_one);
return 1; // didn't find
}
}
fex_stat(fex_one);
long len = fex_size(fex_one);
if (*dest == NULL)
{
*dest = (unsigned char*)malloc(len);
if (!*dest)
{
fex_close(fex_one);
return 1;
}
}
// Extract file
err_one = fex_read(fex_one, *dest, len);
if (wrote != NULL) *wrote = len;
fex_close(fex_one);
if (error(err_one))
{
free(*dest);
return 1;
}
return 0;
}

View File

@ -1,18 +0,0 @@
#ifndef ARCHIVE_H__
#define ARCHIVE_H__
#include <stdint.h>
#include <stddef.h>
struct ArcEntry { char* szName; unsigned int nLen; unsigned int nCrc; };
enum ARCTYPE { ARC_NONE = -1, ARC_ZIP = 0, ARC_7Z, ARC_NUM };
int archiveCheck(char* name, int zipOnly = 0);
int archiveOpen(const char* archive);
int archiveClose();
int archiveGetList(ArcEntry** list, int* count = NULL);
int archiveLoadFile(uint8_t* dest, int len, int entry, int* wrote = NULL);
#endif

View File

@ -0,0 +1,82 @@
#!/bin/bash
if [ -f ../src/generated/driverlist.h ]; then
echo "Generated files already built ..."
exit 0
fi
cd ../src
mkdir -p generated
#generate gamelist.txt and generated/driverlist.h
echo ""
echo "generate_driverlist.sh: Generate all files from scripts directory"
echo ""
echo "1) gamelist.pl"
perl dep/scripts/gamelist.pl -o generated/driverlist.h -l gamelist.txt \
burn/drv/capcom \
burn/drv/cave \
burn/drv/cps3 \
burn/drv/dataeast \
burn/drv/galaxian \
burn/drv/irem \
burn/drv/konami \
burn/drv/megadrive \
burn/drv/pre90s \
burn/drv/neogeo \
burn/drv/pgm \
burn/drv/psikyo \
burn/drv/sega \
burn/drv/snes \
burn/drv/taito \
burn/drv/toaplan
#generate generated/neo_sprite_func.h and generated/neo_sprite_func_table.h
echo ""
echo "2) neo_sprite_func.pl"
perl dep/scripts/neo_sprite_func.pl -o generated/neo_sprite_func.h
#generate generated/psikyo_tile_func.h and generated/psikyo_tile_func_table.h
echo ""
echo "3) psikyo_tile_func.pl"
perl dep/scripts/psikyo_tile_func.pl -o generated/psikyo_tile_func.h
#generate generated/cave_sprite_func.h and generated/cave_sprite_func_table.h
echo ""
echo "4) cave_sprite_func.pl"
perl dep/scripts/cave_sprite_func.pl -o generated/cave_sprite_func.h
#generate generated/cave_tile_func.h and generated/cave_tile_func_table.h
echo ""
echo "5) cave_tile_func.pl"
perl dep/scripts/cave_tile_func.pl -o generated/cave_tile_func.h
#generate generated/toa_gp9001_func.h and generated/toa_gp9001_func_table.h
echo ""
echo "6) toa_gp9001_func.pl"
perl dep/scripts/toa_gp9001_func.pl -o generated/toa_gp9001_func.h
echo ""
echo "7) pgm_sprite_create.cpp"
g++ -o pgm_sprite_create burn/drv/pgm/pgm_sprite_create.cpp
./pgm_sprite_create > burn/drv/pgm/pgm_sprite.h
#compile m68kmakeecho
echo ""
echo "8) compile m68kmake"
gcc -o m68kmake cpu/m68k/m68kmake.c
#create m68kops.h with m68kmake
echo ""
echo "9) Create m68kops.h with m68kmake"
./m68kmake cpu/m68k/ cpu/m68k/m68k_in.c
#compile ctv_make
echo ""
echo "10) compile ctvmake"
g++ -o ctvmake burn/drv/capcom/ctv_make.cpp
#create ctv.h
echo ""
echo "11) Create ctv.h with ctvmake"
./ctvmake > generated/ctv.h

View File

@ -1,5 +1,4 @@
#include "libsnes.hpp"
#include "archive.h"
#include "burner.h"
#include "inp_keys.h"
#include "state.h"
@ -10,13 +9,13 @@
#include <string>
#include <ctype.h>
// FBA cruft.
static unsigned int BurnDrvGetIndexByName(const char* name);
unsigned ArcadeJoystick;
int bDrvOkay;
int bRunPause;
bool bAlwaysProcessKeyboardInput;
#define STAT_NOFIND 0
#define STAT_OK 1
#define STAT_CRC 2
#define STAT_SMALL 3
#define STAT_LARGE 4
struct ROMFIND
{
@ -25,15 +24,6 @@ struct ROMFIND
int nPos;
};
unsigned int BurnDrvGetIndexByName(const char* name);
int BurnDrvGetArchiveName(char** pszName, unsigned int i, bool ext, unsigned int type);
#define STAT_NOFIND 0
#define STAT_OK 1
#define STAT_CRC 2
#define STAT_SMALL 3
#define STAT_LARGE 4
static std::vector<std::string> g_find_list_path;
static ROMFIND g_find_list[1024];
static unsigned g_rom_count;
@ -69,6 +59,15 @@ static void poll_input();
static bool init_input();
// FBA stubs
unsigned ArcadeJoystick;
int bDrvOkay;
int bRunPause;
bool bAlwaysProcessKeyboardInput;
bool bDoIpsPatch;
void IpsApplyPatches(UINT8 *, char *) {}
TCHAR szAppHiscorePath[MAX_PATH];
TCHAR szAppSamplesPath[MAX_PATH];
TCHAR szAppBurnVer[16];
@ -108,7 +107,7 @@ char *LabelCheck(char *, char *) { return 0; }
const int nConfigMinVersion = 0x020921;
//////////////
static int find_rom_by_crc(unsigned crc, const ArcEntry *list, unsigned elems)
static int find_rom_by_crc(unsigned crc, const ZipEntry *list, unsigned elems)
{
for (unsigned i = 0; i < elems; i++)
{
@ -119,7 +118,7 @@ static int find_rom_by_crc(unsigned crc, const ArcEntry *list, unsigned elems)
return -1;
}
static void free_archive_list(ArcEntry *list, unsigned count)
static void free_archive_list(ZipEntry *list, unsigned count)
{
if (list)
{
@ -136,19 +135,19 @@ static int archive_load_rom(uint8_t *dest, int *wrote, int i)
int archive = g_find_list[i].nArchive;
if (archiveOpen(g_find_list_path[archive].c_str()))
if (ZipOpen(g_find_list_path[archive].c_str()) != 0)
return 1;
BurnRomInfo ri = {0};
BurnDrvGetRomInfo(&ri, i);
if (archiveLoadFile(dest, ri.nLen, g_find_list[i].nPos, wrote))
if (ZipLoadFile(dest, ri.nLen, wrote, g_find_list[i].nPos) != 0)
{
archiveClose();
ZipClose();
return 1;
}
archiveClose();
ZipClose();
return 0;
}
@ -167,15 +166,17 @@ static bool open_archive()
char *rom_name;
for (unsigned index = 0; index < 32; index++)
{
if (BurnDrvGetArchiveName(&rom_name, index, false, 0))
//if (BurnDrvGetArchiveName(&rom_name, index, false, 0))
// continue;
if (BurnDrvGetZipName(&rom_name, index))
continue;
char path[1024];
snprintf(path, sizeof(path), "%s/%s", g_rom_dir, rom_name);
int ret = archiveCheck(path, 0);
if (ret == ARC_NONE)
continue;
if (ZipOpen(path) != 0)
return false;
ZipClose();
g_find_list_path.push_back(path);
}
@ -184,12 +185,12 @@ static bool open_archive()
for (unsigned z = 0; z < g_find_list_path.size(); z++)
{
if (archiveOpen(g_find_list_path[z].c_str()))
if (ZipOpen(g_find_list_path[z].c_str()) != 0)
continue;
ArcEntry *list;
ZipEntry *list = NULL;
int count;
archiveGetList(&list, &count);
ZipGetList(&list, &count);
// Try to map the ROMs FBA wants to ROMs we find inside our pretty archives ...
for (unsigned i = 0; i < g_rom_count; i++)
@ -203,7 +204,7 @@ static bool open_archive()
int index = find_rom_by_crc(ri.nCrc, list, count);
if (index < 0)
{
archiveClose();
ZipClose();
return false;
}
@ -212,10 +213,6 @@ static bool open_archive()
g_find_list[i].nPos = index;
g_find_list[i].nState = STAT_OK;
// Sanity checking ...
//if (!(ri.nType & BRF_OPT) && ri.nCrc)
// nTotalSize += ri.nLen;
if (list[index].nLen == ri.nLen)
{
if (ri.nCrc && list[index].nCrc != ri.nCrc)
@ -229,8 +226,7 @@ static bool open_archive()
free_archive_list(list, count);
archiveClose();
ZipClose();
}
BurnExtLoadRom = archive_load_rom;
@ -539,7 +535,7 @@ unsigned snes_get_memory_size(unsigned) { return 0; }
unsigned snes_library_revision_major() { return 1; }
unsigned snes_library_revision_minor() { return 3; }
const char *snes_library_id() { return "FBANext/libsnes"; }
const char *snes_library_id() { return "FBAlpha/libsnes"; }
void snes_set_controller_port_device(bool, unsigned) {}
// Input stuff.
@ -930,3 +926,16 @@ static void poll_input()
}
}
static unsigned int BurnDrvGetIndexByName(const char* name)
{
unsigned int ret = ~0U;
for (unsigned int i = 0; i < nBurnDrvCount; i++) {
nBurnDrvActive = i;
if (strcmp(BurnDrvGetText(DRV_NAME), name) == 0) {
ret = i;
break;
}
}
return ret;
}

View File

@ -0,0 +1,500 @@
// ---------------------------------------------------------------------------------------
// NeoGeo CD Game Info Module (by CaptainCPS-X)
// ---------------------------------------------------------------------------------------
#include "burner.h"
#include "neocdlist.h"
struct NGCDGAME games[] =
{
// ---------------------------------------------------------------------------------------------------------------------------------------------//
// * Name * Title * Year * Company * Game ID //
// ---------------------------------------------------------------------------------------------------------------------------------------------//
{ _T("nam1975") , _T("NAM-1975") , _T("1990") , _T("SNK") , 0x0001 }, //
{ _T("bstars") , _T("Baseball Stars Professional") , _T("1991") , _T("SNK") , 0x0002 }, //
{ _T("tpgolf") , _T("Top Player's Golf") , _T("1990") , _T("SNK") , 0x0003 }, //
{ _T("mahretsu") , _T("Mahjong Kyo Retsuden - Nishi Nihon Hen") , _T("1990") , _T("SNK") , 0x0004 }, //
{ _T("maglord") , _T("Magician Lord") , _T("1990") , _T("ADK") , 0x0005 }, //
{ _T("ridhero") , _T("Riding Hero") , _T("1991") , _T("SNK") , 0x0006 }, //
{ _T("alpham2") , _T("Alpha Mission II / ASO II - Last Guardian") , _T("1994") , _T("SNK") , 0x0007 }, //
{ _T("ncombat") , _T("Ninja Combat") , _T("1990") , _T("SNK/ADK") , 0x0009 }, //
{ _T("cyberlip") , _T("Cyber-Lip") , _T("1991") , _T("SNK") , 0x0010 }, //
{ _T("superspy") , _T("The Super Spy") , _T("1990") , _T("SNK") , 0x0011 }, //
{ _T("mutnat") , _T("Mutation Nation") , _T("1995") , _T("SNK") , 0x0014 }, //
{ _T("sengoku") , _T("Sengoku / Sengoku Denshou") , _T("1994") , _T("SNK") , 0x0017 }, //
{ _T("burningf") , _T("Burning Fight") , _T("1994") , _T("SNK") , 0x0018 }, //
{ _T("lbowling") , _T("League Bowling") , _T("1994") , _T("SNK") , 0x0019 }, //
{ _T("gpilots") , _T("Ghost Pilots") , _T("1991") , _T("SNK") , 0x0020 }, //
{ _T("joyjoy") , _T("Puzzled / Joy Joy Kid") , _T("1990") , _T("SNK") , 0x0021 }, //
{ _T("bjourney") , _T("Blue's Journey / Raguy") , _T("1990") , _T("SNK/ADK") , 0x0022 }, //
{ _T("lresort") , _T("Last Resort") , _T("1994") , _T("SNK") , 0x0024 }, //
{ _T("2020bb") , _T("2020 Super Baseball") , _T("1994") , _T("SNK") , 0x0030 }, //
{ _T("socbrawl") , _T("Soccer Brawl") , _T("1991") , _T("SNK") , 0x0031 }, //
{ _T("roboarmy") , _T("Robo Army") , _T("1991") , _T("SNK") , 0x0032 }, //
{ _T("fatfury") , _T("Fatal Fury - The Battle of Fury") , _T("1994") , _T("SNK") , 0x0033 }, //
{ _T("fbfrenzy") , _T("Football Frenzy") , _T("1994") , _T("SNK") , 0x0034 }, //
{ _T("crswords") , _T("Crossed Swords") , _T("1994") , _T("SNK/ADK") , 0x0037 }, //
{ _T("rallych") , _T("Rally Chase") , _T("1991") , _T("SNK/ADK") , 0x0038 }, //
{ _T("kotm2") , _T("King of the Monsters 2") , _T("1992") , _T("SNK") , 0x0039 }, //
{ _T("sengoku2") , _T("Sengoku 2 / Sengoku Denshou 2") , _T("1994") , _T("SNK") , 0x0040 }, //
{ _T("bstars2") , _T("Baseball Stars 2") , _T("1992") , _T("SNK") , 0x0041 }, //
{ _T("3countb") , _T("3 Count Bout / Fire Suplex") , _T("1995") , _T("SNK") , 0x0043 }, //
{ _T("aof") , _T("Art of Fighting / Ryuuko no Ken") , _T("1994") , _T("SNK") , 0x0044 }, //
{ _T("samsho") , _T("Samurai Shodown / Samurai Spirits") , _T("1993") , _T("SNK") , 0x0045 }, //
{ _T("tophuntr") , _T("Top Hunter - Roddy & Cathy") , _T("1994") , _T("SNK") , 0x0046 }, //
{ _T("fatfury2") , _T("Fatal Fury 2 / Garou Densetsu 2 - Aratanaru Tatakai") , _T("1994") , _T("SNK") , 0x0047 }, //
{ _T("janshin") , _T("Janshin Densetsu - Quest of the Jongmaster") , _T("1995") , _T("Yubis") , 0x0048 }, //
{ _T("ncommand") , _T("Ninja Commando") , _T("1992") , _T("SNK") , 0x0050 }, //
{ _T("viewpoin") , _T("Viewpoint") , _T("1992") , _T("Sammy/Aicom") , 0x0051 }, //
{ _T("ssideki") , _T("Super Sidekicks / Tokuten Oh") , _T("1993") , _T("SNK") , 0x0052 }, //
{ _T("wh1") , _T("World Heroes") , _T("1992") , _T("ADK") , 0x0053 }, //
{ _T("crsword2") , _T("Crossed Swords II") , _T("1995") , _T("SNK/ADK") , 0x0054 }, //
{ _T("kof94") , _T("The King of Fighters '94 (JP)") , _T("1994") , _T("SNK") , 0x0055 }, //
{ _T("kof94ju") , _T("The King of Fighters '94 (JP-US)") , _T("1994") , _T("SNK") , 0x1055 }, // custom id
{ _T("aof2") , _T("Art of Fighting 2 / Ryuuko no Ken 2") , _T("1994") , _T("SNK") , 0x0056 }, //
{ _T("wh2") , _T("World Heroes 2") , _T("1995") , _T("SNK/ADK") , 0x0057 }, //
{ _T("fatfursp") , _T("Fatal Fury Special / Garou Densetsu Special") , _T("1994") , _T("SNK") , 0x0058 }, //
{ _T("savagere") , _T("Savage Reign / Fu'un Mokujiroku - Kakutou Sousei") , _T("1995") , _T("SNK") , 0x0059 }, //
{ _T("ssideki2") , _T("Super Sidekicks 2 / Tokuten Oh 2") , _T("1994") , _T("SNK") , 0x0061 }, //
{ _T("samsho2") , _T("Samurai Shodown 2 / Shin Samurai Spirits") , _T("1994") , _T("SNK") , 0x0063 }, //
{ _T("wh2j") , _T("World Heroes 2 Jet") , _T("1995") , _T("SNK/ADK") , 0x0064 }, //
{ _T("wjammers") , _T("Windjammers / Flying Power Disc") , _T("1994") , _T("Data East") , 0x0065 }, //
{ _T("karnovr") , _T("Karnov's Revenge / Fighters History Dynamite") , _T("1994") , _T("Data East") , 0x0066 }, //
{ _T("pspikes2") , _T("Power Spikes II") , _T("1994") , _T("Video System") , 0x0068 }, //
{ _T("aodk") , _T("Aggressors of Dark Kombat / Tsuukai GanGan Koushinkyoku") , _T("1994"), _T("SNK/ADK") , 0x0074 }, //
{ _T("sonicwi2") , _T("Aero Fighters 2 / Sonic Wings 2") , _T("1994") , _T("Video System") , 0x0075 }, //
{ _T("galaxyfg") , _T("Galaxy Fight - Universal Warriors") , _T("1995") , _T("Sunsoft") , 0x0078 }, //
{ _T("strhoop") , _T("Street Hoop / Dunk Dream") , _T("1994") , _T("Data East") , 0x0079 }, //
{ _T("quizkof") , _T("Quiz King of Fighters") , _T("1993") , _T("SNK/Saurus") , 0x0080 }, //
{ _T("ssideki3") , _T("Super Sidekicks 3 - The Next Glory / Tokuten Oh 3 - Eikoue No Chousen"), _T("1995") , _T("SNK") , 0x0081 }, //
{ _T("doubledr") , _T("Double Dragon") , _T("1995") , _T("Technos") , 0x0082 }, //
{ _T("pbobblen") , _T("Puzzle Bobble / Bust-A-Move") , _T("1994") , _T("SNK") , 0x0083 }, //
{ _T("kof95") , _T("The King of Fighters '95 (JP-US)") , _T("1995") , _T("SNK") , 0x0084 }, //
{ _T("kof95r1") , _T("The King of Fighters '95 (JP-US)(Rev 1)") , _T("1995") , _T("SNK") , 0x1084 }, //
{ _T("ssrpg") , _T("Shinsetsu Samurai Spirits - Bushidohretsuden") , _T("1997") , _T("SNK") , 0x0085 }, //
{ _T("samsho3") , _T("Samurai Shodown 3 / Samurai Spirits 3") , _T("1995") , _T("SNK") , 0x0087 }, //
{ _T("stakwin") , _T("Stakes Winner - GI Kanzen Seiha Heno Machi") , _T("1995") , _T("Saurus") , 0x0088 }, //
{ _T("pulstar") , _T("Pulstar") , _T("1995") , _T("Aicom") , 0x0089 }, //
{ _T("whp") , _T("World Heroes Perfect") , _T("1995") , _T("ADK") , 0x0090 }, //
{ _T("kabukikl") , _T("Kabuki Klash / Tengai Makyou Shinden - Far East of Eden") , _T("1995"), _T("Hudson") , 0x0092 }, //
{ _T("gowcaizr") , _T("Voltage Fighter Gowcaizer / Choujin Gakuen Gowcaizer"), _T("1995") , _T("Technos") , 0x0094 }, //
{ _T("rbff1") , _T("Real Bout Fatal Fury") , _T("1995") , _T("SNK") , 0x0095 }, //
{ _T("aof3") , _T("Art of Fighting 3: Path of the Warrior") , _T("1996") , _T("SNK") , 0x0096 }, //
{ _T("sonicwi3") , _T("Aero Fighters 3 / Sonic Wings 3") , _T("1995") , _T("SNK") , 0x0097 }, //
{ _T("fromanc2") , _T("Idol Mahjong Final Romance 2") , _T("1995") , _T("Video Systems") , 0x0098 }, //
{ _T("turfmast") , _T("Neo Turf Masters / Big Tournament Golf") , _T("1996") , _T("Nazca") , 0x0200 }, //
{ _T("mslug") , _T("Metal Slug - Super Vehicle-001") , _T("1996") , _T("Nazca") , 0x0201 }, //
{ _T("mosyougi") , _T("Shougi no Tatsujin - Master of Syougi") , _T("1995") , _T("ADK") , 0x0203 }, //
{ _T("adkworld") , _T("ADK World / ADK Special") , _T("1995") , _T("ADK") , 0x0204 }, //
{ _T("ngcdsp") , _T("Neo Geo CD Special") , _T("1995") , _T("SNK") , 0x0205 }, //
{ _T("zintrick") , _T("Zintrick / Oshidashi Zintrick") , _T("1996") , _T("ADK") , 0x0211 }, //
{ _T("overtop") , _T("OverTop") , _T("1996") , _T("ADK") , 0x0212 }, //
{ _T("neodrift") , _T("Neo DriftOut") , _T("1996") , _T("Visco") , 0x0213 }, //
{ _T("kof96") , _T("The King of Fighters '96") , _T("1996") , _T("SNK") , 0x0214 }, //
{ _T("ninjamas") , _T("Ninja Master's - Haou Ninpou-Chou") , _T("1996") , _T("ADK/SNK") , 0x0217 }, //
{ _T("ragnagrd") , _T("Ragnagard / Shinouken") , _T("1996") , _T("Saurus") , 0x0218 }, //
{ _T("pgoal") , _T("Pleasuregoal - 5 on 5 Mini Soccer / Futsal") , _T("1996") , _T("Saurus") , 0x0219 }, //
{ _T("ironclad") , _T("Ironclad / Choutetsu Brikin'ger") , _T("1996") , _T("Saurus") , 0x0220 }, //
{ _T("magdrop2") , _T("Magical Drop 2") , _T("1996") , _T("Data East") , 0x0221 }, //
{ _T("samsho4") , _T("Samurai Shodown IV - Amakusa's Revenge") , _T("1996") , _T("SNK") , 0x0222 }, //
{ _T("rbffspec") , _T("Real Bout Fatal Fury Special") , _T("1996") , _T("SNK") , 0x0223 }, //
{ _T("twinspri") , _T("Twinkle Star Sprites") , _T("1996") , _T("ADK") , 0x0224 }, //
{ _T("kof96ngc") , _T("The King of Fighters '96 NEOGEO Collection") , _T("1996") , _T("SNK") , 0x0229 }, //
{ _T("breakers") , _T("Breakers") , _T("1996") , _T("Visco") , 0x0230 }, //
{ _T("kof97") , _T("The King of Fighters '97") , _T("1997") , _T("SNK") , 0x0232 }, //
{ _T("lastblad") , _T("The Last Blade / Bakumatsu Roman - Gekka no Kenshi") , _T("1997") , _T("SNK") , 0x0234 }, //
{ _T("rbff2") , _T("Real Bout Fatal Fury 2 / Garou Densetsu 2 - Aratanaru Tatakai"), _T("1998"), _T("SNK") , 0x0240 }, //
{ _T("mslug2") , _T("Metal Slug 2 - Super Vehicle-001/II") , _T("1998") , _T("SNK") , 0x0241 }, //
{ _T("kof98") , _T("The King of Fighters '98 - The Slugfest") , _T("1998") , _T("SNK") , 0x0242 }, //
{ _T("lastbld2") , _T("The Last Blade 2") , _T("1998") , _T("SNK") , 0x0243 }, //
{ _T("kof99") , _T("The King of Fighters '99 - Millennium Battle") , _T("1999") , _T("SNK") , 0x0251 }, //
{ _T("fatfury3") , _T("Fatal Fury 3 - Road to the Final Victory / Garou Densetsu 3 - Harukanaru Tatakai"), _T("1995"), _T("SNK"), 0x069c }, //
};
NGCDGAME* GetNeoGeoCDInfo(unsigned int nID)
{
for(unsigned int nGame = 0; nGame < (sizeof(games) / sizeof(NGCDGAME)); nGame++) {
if(nID == games[nGame].id ) {
return &games[nGame];
}
}
return NULL;
}
NGCDGAME* game;
// Get the title
int GetNeoCDTitle(unsigned int nGameID)
{
game = (NGCDGAME*)malloc(sizeof(NGCDGAME));
memset(game, 0, sizeof(NGCDGAME));
if(GetNeoGeoCDInfo(nGameID))
{
memcpy(game, GetNeoGeoCDInfo(nGameID), sizeof(NGCDGAME));
return 1;
}
game = NULL;
return 0;
}
void iso9660_ReadOffset(unsigned char *Dest, FILE* fp, unsigned int lOffset, unsigned int lSize, unsigned int lLength)
{
if(fp == NULL) return;
if (Dest == NULL) return;
fseek(fp, lOffset, SEEK_SET);
fread(Dest, lLength, lSize, fp);
}
static void NeoCDList_iso9660_CheckDirRecord(FILE* fp, int nSector)
{
int nSectorLength = 2048;
//int nFile = 0;
unsigned int lBytesRead = 0;
//int nLen = 0;
unsigned int lOffset = 0;
bool bNewSector = false;
bool bRevisionQueve = false;
int nRevisionQueveID = 0;
lOffset = (nSector * nSectorLength);
unsigned char* nLenDR = (unsigned char*)malloc(1 * sizeof(unsigned char));
unsigned char* Flags = (unsigned char*)malloc(1 * sizeof(unsigned char));
unsigned char* ExtentLoc = (unsigned char*)malloc(8 * sizeof(unsigned char));
unsigned char* Data = (unsigned char*)malloc(0x10b * sizeof(unsigned char));
unsigned char* LEN_FI = (unsigned char*)malloc(1 * sizeof(unsigned char));
char *File = (char*)malloc(32 * sizeof(char));
while(1)
{
iso9660_ReadOffset(nLenDR, fp, lOffset, 1, sizeof(unsigned char));
if(nLenDR[0] == 0x22) {
lOffset += nLenDR[0];
lBytesRead += nLenDR[0];
continue;
}
if(nLenDR[0] < 0x22)
{
if(bNewSector)
{
if(bRevisionQueve) {
bRevisionQueve = false;
GetNeoCDTitle(nRevisionQueveID);
}
return;
}
nLenDR[0] = 0;
iso9660_ReadOffset(nLenDR, fp, lOffset + 1, 1, sizeof(unsigned char));
if(nLenDR[0] < 0x22) {
lOffset += (2048 - lBytesRead);
lBytesRead = 0;
bNewSector = true;
continue;
}
}
bNewSector = false;
iso9660_ReadOffset(Flags, fp, lOffset + 25, 1, sizeof(unsigned char));
if(!(Flags[0] & (1 << 1)))
{
iso9660_ReadOffset(ExtentLoc, fp, lOffset + 2, 8, sizeof(unsigned char));
char szValue[9];
sprintf(szValue, "%02x%02x%02x%02x", ExtentLoc[4], ExtentLoc[5], ExtentLoc[6], ExtentLoc[7]);
unsigned int nValue = 0;
sscanf(szValue, "%x", &nValue);
iso9660_ReadOffset(Data, fp, nValue * 2048, 0x10a, sizeof(unsigned char));
char szData[8];
sprintf(szData, "%c%c%c%c%c%c%c", Data[0x100], Data[0x101], Data[0x102], Data[0x103], Data[0x104], Data[0x105], Data[0x106]);
if(!strncmp(szData, "NEO-GEO", 7))
{
char id[] = "0000";
sprintf(id, "%02X%02X", Data[0x108], Data[0x109]);
unsigned int nID = 0;
sscanf(id, "%x", &nID);
iso9660_ReadOffset(LEN_FI, fp, lOffset + 32, 1, sizeof(unsigned char));
iso9660_ReadOffset((unsigned char*)File, fp, lOffset + 33, LEN_FI[0], sizeof(char));
strncpy(File, File, LEN_FI[0]);
File[LEN_FI[0]] = 0;
// King of Fighters '94, The (1994)(SNK)(JP)
// 10-6-1994 (P1.PRG)
if(nID == 0x0055 && Data[0x67] == 0xDE) {
// ...continue
}
// King of Fighters '94, The (1994)(SNK)(JP-US)
// 11-21-1994 (P1.PRG)
if(nID == 0x0055 && Data[0x67] == 0xE6) {
// Change to custom revision id
nID = 0x1055;
}
// King of Fighters '95, The (1995)(SNK)(JP-US)[!][NGCD-084 MT B01, B03-B06, NGCD-084E MT B01]
// 9-11-1995 (P1.PRG)
if(nID == 0x0084 && Data[0x6C] == 0xC0) {
// ... continue
}
// King of Fighters '95, The (1995)(SNK)(JP-US)[!][NGCD-084 MT B10, NGCD-084E MT B03]
// 10-5-1995 (P1.PRG)
if(nID == 0x0084 && Data[0x6C] == 0xFF) {
// Change to custom revision id
nID = 0x1084;
}
// King of Fighters '96 NEOGEO Collection, The
if(nID == 0x0229) {
bRevisionQueve = false;
GetNeoCDTitle(nID);
break;
}
// King of Fighters '96, The
if(nID == 0x0214) {
bRevisionQueve = true;
nRevisionQueveID = nID;
lOffset += nLenDR[0];
lBytesRead += nLenDR[0];
continue;
}
GetNeoCDTitle(nID);
break;
}
}
lOffset += nLenDR[0];
lBytesRead += nLenDR[0];
}
if (nLenDR) {
free(nLenDR);
nLenDR = NULL;
}
if (Flags) {
free(Flags);
Flags = NULL;
}
if (ExtentLoc) {
free(ExtentLoc);
ExtentLoc = NULL;
}
if (Data) {
free(Data);
Data = NULL;
}
if (LEN_FI) {
free(LEN_FI);
LEN_FI = NULL;
}
if (File) {
free(File);
File = NULL;
}
}
// Check the specified ISO, and proceed accordingly
static int NeoCDList_CheckISO(TCHAR* pszFile)
{
if(!pszFile) {
// error
return 0;
}
// Make sure we have a valid ISO file extension...
if(_tcsstr(pszFile, _T(".iso")) || _tcsstr(pszFile, _T(".ISO")) )
{
FILE* fp = _tfopen(pszFile, _T("rb"));
if(fp)
{
// Read ISO and look for 68K ROM standard program header, ID is always there
// Note: This function works very quick, doesn't compromise performance :)
// it just read each sector first 264 bytes aproximately only.
// Get ISO Size (bytes)
fseek(fp, 0, SEEK_END);
unsigned int lSize = 0;
lSize = ftell(fp);
//rewind(fp);
fseek(fp, 0, SEEK_SET);
// If it has at least 16 sectors proceed
if(lSize > (2048 * 16))
{
// Check for Standard ISO9660 Identifier
unsigned char IsoHeader[2048 * 16 + 1];
unsigned char IsoCheck[6];
fread(IsoHeader, 1, 2048 * 16 + 1, fp); // advance to sector 16 and PVD Field 2
fread(IsoCheck, 1, 5, fp); // get Standard Identifier Field from PVD
// Verify that we have indeed a valid ISO9660 MODE1/2048
if(!memcmp(IsoCheck, "CD001", 5))
{
//bprintf(PRINT_NORMAL, _T(" Standard ISO9660 Identifier Found. \n"));
iso9660_VDH vdh;
// Get Volume Descriptor Header
memset(&vdh, 0, sizeof(vdh));
//memcpy(&vdh, iso9660_ReadOffset(fp, (2048 * 16), sizeof(vdh)), sizeof(vdh));
iso9660_ReadOffset((unsigned char*)&vdh, fp, 2048 * 16, 1, sizeof(vdh));
// Check for a valid Volume Descriptor Type
if(vdh.vdtype == 0x01)
{
#if 0
// This will fail on 64-bit due to differing variable sizes in the pvd struct
// Get Primary Volume Descriptor
iso9660_PVD pvd;
memset(&pvd, 0, sizeof(pvd));
//memcpy(&pvd, iso9660_ReadOffset(fp, (2048 * 16), sizeof(pvd)), sizeof(pvd));
iso9660_ReadOffset((unsigned char*)&pvd, fp, 2048 * 16, 1, sizeof(pvd));
// ROOT DIRECTORY RECORD
// Handle Path Table Location
char szRootSector[32];
unsigned int nRootSector = 0;
sprintf(szRootSector, "%02X%02X%02X%02X",
pvd.root_directory_record.location_of_extent[4],
pvd.root_directory_record.location_of_extent[5],
pvd.root_directory_record.location_of_extent[6],
pvd.root_directory_record.location_of_extent[7]);
// Convert HEX string to Decimal
sscanf(szRootSector, "%X", &nRootSector);
#else
// Just read from the file directly at the correct offset (0x8000 + 0x9e for the start of the root directory record)
unsigned char buffer[8];
char szRootSector[4];
unsigned int nRootSector = 0;
fseek(fp, 0x809e, SEEK_SET);
fread(buffer, 1, 8, fp);
sprintf(szRootSector, "%02x%02x%02x%02x", buffer[4], buffer[5], buffer[6], buffer[7]);
sscanf(szRootSector, "%x", &nRootSector);
#endif
// Process the Root Directory Records
NeoCDList_iso9660_CheckDirRecord(fp, nRootSector);
// Path Table Records are not processed, since NeoGeo CD should not have subdirectories
// ...
}
} else {
//bprintf(PRINT_NORMAL, _T(" Standard ISO9660 Identifier Not Found, cannot continue. \n"));
return 0;
}
}
} else {
//bprintf(PRINT_NORMAL, _T(" Couldn't open %s \n"), GetIsoPath());
return 0;
}
if(fp) fclose(fp);
} else {
//bprintf(PRINT_NORMAL, _T(" File doesn't have a valid ISO extension [ .iso / .ISO ] \n"));
return 0;
}
return 1;
}
// This will do everything
int GetNeoGeoCD_Identifier()
{
if(!GetIsoPath() || !IsNeoGeoCD()) {
return 0;
}
// Make sure we have a valid ISO file extension...
if(_tcsstr(GetIsoPath(), _T(".iso")) || _tcsstr(GetIsoPath(), _T(".ISO")) )
{
if(_tfopen(GetIsoPath(), _T("rb")))
{
// Read ISO and look for 68K ROM standard program header, ID is always there
// Note: This function works very quick, doesn't compromise performance :)
// it just read each sector first 264 bytes aproximately only.
NeoCDList_CheckISO(GetIsoPath());
} else {
bprintf(PRINT_NORMAL, _T(" Couldn't open %s \n"), GetIsoPath());
return 0;
}
} else {
bprintf(PRINT_NORMAL, _T(" File doesn't have a valid ISO extension [ .iso / .ISO ] \n"));
return 0;
}
return 1;
}
int NeoCDInfo_Init()
{
NeoCDInfo_Exit();
return GetNeoGeoCD_Identifier();
}
TCHAR* NeoCDInfo_Text(int nText)
{
if(!game || !IsNeoGeoCD() || !bDrvOkay) return NULL;
switch(nText)
{
case DRV_NAME: return game->pszName;
case DRV_FULLNAME: return game->pszTitle;
case DRV_MANUFACTURER: return game->pszCompany;
case DRV_DATE: return game->pszYear;
}
return NULL;
}
int NeoCDInfo_ID()
{
if(!game || !IsNeoGeoCD() || !bDrvOkay) return 0;
return game->id;
}
void NeoCDInfo_Exit()
{
if(game) {
free(game);
game = NULL;
}
}

View File

@ -0,0 +1 @@
// Dummy header as core needs to include this for some reason.

View File

@ -10,6 +10,8 @@
#undef __cdecl
#define __cdecl
typedef struct { int x, y, width, height; } RECT;
#define bprintf(...) {}
#define _strnicmp(s1, s2, n) strncasecmp(s1, s2, n)
#define _stricmp(x, y) strcasecmp(x,y)