mirror of
https://github.com/libretro/FBNeo.git
synced 2024-11-23 08:59:39 +00:00
cleaner sdl2 commits :)
This commit is contained in:
parent
37e13147c3
commit
c6c2d3a0ef
4
.github/workflows/code.yml
vendored
4
.github/workflows/code.yml
vendored
@ -6,9 +6,9 @@ jobs:
|
||||
codeartifact:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
fetch-depth: 1
|
||||
- name: Upload code artifact
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
|
@ -1,11 +1,11 @@
|
||||
name: SDL CI
|
||||
name: SDL1.2 CI
|
||||
|
||||
on:
|
||||
push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build SDL variant
|
||||
name: Build SDL1.2 variant
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
18
.github/workflows/sdl2.yml
vendored
Normal file
18
.github/workflows/sdl2.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: SDL2 CI
|
||||
|
||||
on:
|
||||
push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build SDL2 variant
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Install prerequisites
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install libsdl2-dev libsdl-image1.2-dev
|
||||
- name: Build
|
||||
run: |
|
||||
make sdl -j9 RELEASEBUILD=1 SKIPDEPEND=1
|
4
.github/workflows/vs2019-win32.yml
vendored
4
.github/workflows/vs2019-win32.yml
vendored
@ -6,9 +6,7 @@ jobs:
|
||||
buildvsx86:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- uses: actions/checkout@v1
|
||||
- name: Setup MSBuild.exe
|
||||
uses: warrenbuckley/Setup-MSBuild@v1
|
||||
- name: MSBuild x86
|
||||
|
4
.github/workflows/vs2019-x64.yml
vendored
4
.github/workflows/vs2019-x64.yml
vendored
@ -6,9 +6,7 @@ jobs:
|
||||
buildvsx64:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- uses: actions/checkout@v1
|
||||
- name: Setup MSBuild.exe
|
||||
uses: warrenbuckley/Setup-MSBuild@v1
|
||||
- name: MSBuild x64
|
||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -3,6 +3,7 @@
|
||||
################################################################################
|
||||
|
||||
/.vs
|
||||
.vscode
|
||||
/projectfiles/visualstudio-2019/enc_temp_folder
|
||||
.DS_Store
|
||||
obj/
|
||||
@ -17,3 +18,6 @@ xcuserdata
|
||||
project.xcworkspace
|
||||
projectfiles/xcode/build
|
||||
nvram
|
||||
*.nvr
|
||||
config/*
|
||||
fbneo.dat
|
||||
|
@ -6,7 +6,7 @@ This is the official repository of FinalBurn Neo, an Emulator for Arcade Games &
|
||||
Use of this program and its source code is subject to the license conditions provided in the [license.txt](/src/license.txt) file in the src folder.
|
||||
|
||||
# Work in Progress builds
|
||||
If the below build status badge is green, you can download the latest builds from [this repository](https://github.com/finalburnneo/FBNeo-WIP-Storage-Facility/releases/tag/appveyor-build). Please note that if the below build status badge is not green then the build will be out of date. As this build is of the last commit occasionally you might run into incomplete code, crashes or other issues that [official releases](https://github.com/finalburnneo/FBNeo/releases) will not have.
|
||||
If the below build status badge is green, you can download the latest builds from [this repository](https://github.com/finalburnneo/FBNeo-WIP-Storage-Facility/releases/tag/appveyor-build). Please note that if the below build status badge is not green then the build will be out of date. As this build is of the last commit occasionally you might run into incomplete code, crashes or other issues that [official releases](https://github.com/finalburnneo/FBNeo/releases) will not have.
|
||||
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/8rkefxtvxd3cllag/branch/master?svg=true)](https://ci.appveyor.com/project/tmaul/fbneo-kbhgd/branch/master)
|
||||
|
||||
@ -18,7 +18,9 @@ macOS [build instructions](README-macOS.md) and [releases](https://github.com/fb
|
||||
|
||||
[LibRetro port](https://github.com/libretro/FBNeo) with builds availble via [RetroArch](https://www.retroarch.com/) for most platforms.
|
||||
|
||||
For SDL builds just type `make sdl` (requires SDL1.2 and GCC, make, perl and nasm)
|
||||
For SDL1.2 builds just type `make sdl` (requires SDL1.2 and GCC, make, perl and nasm)
|
||||
|
||||
For SDL2 builds just type `make sdl2` (requires SDL2, SDL2_image, gcc, make, perl and nasm)
|
||||
|
||||
# Reporting Issues
|
||||
|
||||
|
9
makefile
9
makefile
@ -75,19 +75,22 @@ mingw345: FORCE
|
||||
|
||||
mingw452: FORCE
|
||||
@$(MAKE) -s -f makefile.mingw GCC452=1
|
||||
|
||||
|
||||
mingw471: FORCE
|
||||
@$(MAKE) -s -f makefile.mingw GCC471=1
|
||||
|
||||
|
||||
mingw510: FORCE
|
||||
@$(MAKE) -s -f makefile.mingw GCC510=1
|
||||
|
||||
mamemingw: FORCE
|
||||
@$(MAKE) -s -f makefile.mamemingw
|
||||
@$(MAKE) -s -f makefile.mamemingw
|
||||
|
||||
sdl: FORCE
|
||||
@$(MAKE) -s -f makefile.sdl
|
||||
|
||||
sdl2: FORCE
|
||||
@$(MAKE) -s -f makefile.sdl2
|
||||
|
||||
vc: FORCE
|
||||
@$(MAKE) -s -f makefile.vc
|
||||
|
||||
|
@ -69,7 +69,7 @@ depobj += neocdlist.o \
|
||||
2xpm.o 2xsai.o ddt3x.o epx.o hq2xs.o hq2xs_16.o xbr.o \
|
||||
\
|
||||
inp_pi.o aud_sdl.o support_paths.o \
|
||||
ips_manager.o scrn.o cd_isowav.o cdsound.o config.o \
|
||||
ips_manager.o scrn.o config.o \
|
||||
main_pi.o run_pi.o stringset.o bzip.o drv.o media.o inpdipsw.o \
|
||||
matrix.o vid_pi.o dynhuff.o replay.o
|
||||
|
||||
|
15
makefile.sdl
15
makefile.sdl
@ -11,6 +11,11 @@ ifeq ($(UNAME_S),Darwin)
|
||||
DARWIN=1
|
||||
endif
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
WINDOWS=1
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# Flags. Uncomment any of these declarations to enable their function.
|
||||
#
|
||||
@ -64,8 +69,8 @@ depobj += neocdlist.o \
|
||||
2xpm.o 2xsai.o ddt3x.o epx.o hq2xs.o hq2xs_16.o xbr.o \
|
||||
\
|
||||
inp_sdl.o aud_sdl.o support_paths.o ips_manager.o scrn.o \
|
||||
cd_isowav.o cdsound.o config.o main.o run.o stringset.o bzip.o drv.o media.o \
|
||||
inpdipsw.o vid_sdlfx.o dynhuff.o replay.o vid_sdlopengl.o
|
||||
cd_sdl2.o config.o main.o run.o stringset.o bzip.o drv.o media.o \
|
||||
inpdipsw.o vid_sdlfx.o dynhuff.o replay.o vid_sdlopengl.o input.o stated.o
|
||||
|
||||
ifdef INCLUDE_7Z_SUPPORT
|
||||
depobj += un7z.o \
|
||||
@ -86,7 +91,11 @@ incdir = $(foreach dir,$(alldir),-I$(srcdir)$(dir)) -I$(objdir)dep/generated \
|
||||
-I/local/include -I$(srcdir)dep/sdl/include \
|
||||
-I$(srcdir)intf/input/sdl `sdl-config --cflags`
|
||||
|
||||
ifdef WINDOWS
|
||||
lib = -lstdc++ -lSDL `sdl-config --libs` -lopengl32 -lm
|
||||
else
|
||||
lib = -lstdc++ -lSDL `sdl-config --libs` -lGL -lm
|
||||
endif
|
||||
|
||||
ifdef DARWIN
|
||||
lib += -L/System/Library/Frameworks/OpenGL.framework/Libraries/
|
||||
@ -393,7 +402,7 @@ $(objdir)dep/generated/m68kops.h $(objdir)dep/generated/m68kops.c: $(objdir)cpu/
|
||||
|
||||
$(objdir)cpu/m68k/m68kmake: $(srcdir)cpu/m68k/m68kmake.c
|
||||
@echo Compiling Musashi MC680x0 core \(m68kmake.c\)...
|
||||
@$(CC) $(CFLAGS) $(srcdir)cpu/m68k/m68kmake.c -o $(objdir)cpu/m68k/m68kmake
|
||||
@$(CC) $(CFLAGS) $(srcdir)cpu/m68k/m68kmake.c -o $(objdir)cpu/m68k/m68kmake -Dmain=main
|
||||
|
||||
|
||||
#
|
||||
|
603
makefile.sdl2
Normal file
603
makefile.sdl2
Normal file
@ -0,0 +1,603 @@
|
||||
# Makefile for FBNeo, SDL2
|
||||
#
|
||||
# The first pass makes sure all intermediary targets are present. The second pass updates
|
||||
# any targets, if necessary. (Intermediary) targets which have their own unique rules
|
||||
# are generated as required.
|
||||
|
||||
unexport
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
DARWIN=1
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
WINDOWS=1
|
||||
endif
|
||||
|
||||
#
|
||||
# Flags. Uncomment any of these declarations to enable their function.
|
||||
#
|
||||
|
||||
# Check for changes in header files
|
||||
ifndef SKIPDEPEND
|
||||
DEPEND = 1
|
||||
endif
|
||||
|
||||
# SANITIZE = 1
|
||||
|
||||
#
|
||||
# Declare variables
|
||||
#
|
||||
|
||||
# Specify the name of the executable file, without ".exe"
|
||||
NAME = fbneo
|
||||
|
||||
BUILD_X86_ASM=
|
||||
INCLUDE_AVI_RECORDING=
|
||||
BUILD_A68K=
|
||||
UNICODE=
|
||||
|
||||
|
||||
#
|
||||
# Specify paths/files
|
||||
#
|
||||
|
||||
objdir = obj/
|
||||
srcdir = src/
|
||||
|
||||
include makefile.burn_rules
|
||||
|
||||
# Platform stuff
|
||||
alldir += burner burner/sdl burner/sdl dep/libs/libpng dep/libs/lib7z dep/libs/zlib intf intf/video \
|
||||
intf/video/scalers intf/video/sdl intf/audio intf/audio/sdl intf/input intf/input/sdl intf/cd intf/cd/sdl \
|
||||
intf/perfcount intf/perfcount/sdl dep/generated
|
||||
|
||||
depobj += neocdlist.o \
|
||||
\
|
||||
conc.o cong.o dat.o gamc.o gami.o image.o ioapi.o misc.o sshot.o state.o statec.o unzip.o zipfn.o \
|
||||
\
|
||||
adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o \
|
||||
trees.o uncompr.o zutil.o \
|
||||
\
|
||||
png.o pngerror.o pngget.o pngmem.o pngpread.o pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o \
|
||||
pngwrite.o pngwtran.o pngwutil.o \
|
||||
\
|
||||
aud_dsp.o aud_interface.o cd_interface.o inp_interface.o interface.o lowpass2.o vid_interface.o \
|
||||
vid_softfx.o vid_support.o \
|
||||
\
|
||||
2xpm.o 2xsai.o ddt3x.o epx.o hq2xs.o hq2xs_16.o xbr.o \
|
||||
\
|
||||
inp_sdl2.o aud_sdl.o support_paths.o ips_manager.o scrn.o \
|
||||
cd_sdl2.o config.o main.o run.o stringset.o bzip.o drv.o media.o sdl2_gui_ingame.o sdl2_gui_common.o \
|
||||
inpdipsw.o vid_sdl2opengl.o vid_sdl2.o dynhuff.o replay.o sdl2_gui.o sdl2_inprint.o input_sdl2.o stated.o
|
||||
|
||||
ifdef INCLUDE_7Z_SUPPORT
|
||||
depobj += un7z.o \
|
||||
\
|
||||
7zArcIn.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zCrcOpt.o 7zDec.o 7zFile.o 7zStream.o Bcj2.o Bra.o Bra86.o BraIA64.o CpuArch.o \
|
||||
Delta.o LzmaDec.o Lzma2Dec.o Ppmd7.o Ppmd7Dec.o Sha256.o Xz.o XzCrc64.o XzCrc64Opt.o XzDec.o
|
||||
endif
|
||||
|
||||
autobj += $(depobj)
|
||||
|
||||
ifdef BUILD_X86_ASM
|
||||
autobj += eagle_fm.o 2xsaimmx.o hq2x32.o hq3x32.o hq4x32.o superscale.o
|
||||
endif
|
||||
|
||||
# End, platform stuff
|
||||
|
||||
incdir = $(foreach dir,$(alldir),-I$(srcdir)$(dir)) -I$(objdir)dep/generated \
|
||||
-I/local/include -I$(srcdir)dep/sdl/include \
|
||||
-I$(srcdir)intf/input/sdl `sdl2-config --cflags`
|
||||
|
||||
ifdef WINDOWS
|
||||
lib = -lstdc++ `sdl2-config --libs` -lopengl32 -lSDL2_image -lm
|
||||
else
|
||||
lib = -lstdc++ `sdl2-config --libs` -lGL -lSDL2_image -lm
|
||||
endif
|
||||
|
||||
|
||||
|
||||
ifdef DARWIN
|
||||
lib += -L/System/Library/Frameworks/OpenGL.framework/Libraries/
|
||||
endif
|
||||
|
||||
autdep = $(depobj:.o=.d)
|
||||
drvdep = $(drvsrc:.o=.d)
|
||||
|
||||
ifdef BUILD_A68K
|
||||
a68k.o = $(objdir)cpu/a68k/a68k.o
|
||||
endif
|
||||
|
||||
driverlist.h = $(srcdir)dep/generated/driverlist.h
|
||||
ctv.h = $(srcdir)dep/generated/ctv.h
|
||||
toa_gp9001_func.h = $(srcdir)dep/generated/toa_gp9001_func.h
|
||||
neo_sprite_func.h = $(srcdir)dep/generated/neo_sprite_func.h
|
||||
cave_tile_func.h = $(srcdir)dep/generated/cave_tile_func.h
|
||||
cave_sprite_func.h = $(srcdir)dep/generated/cave_sprite_func.h
|
||||
psikyo_tile_func.h = $(srcdir)dep/generated/psikyo_tile_func.h
|
||||
pgm_sprite.h = $(srcdir)dep/generated/pgm_sprite.h
|
||||
build_details.h = $(srcdir)dep/generated/build_details.h
|
||||
|
||||
allobj = $(objdir)cpu/m68k/m68kcpu.o $(objdir)cpu/m68k/m68kops.o \
|
||||
$(foreach file,$(autobj:.o=.c), \
|
||||
$(foreach dir,$(alldir),$(subst $(srcdir),$(objdir), \
|
||||
$(firstword $(subst .c,.o,$(wildcard $(srcdir)$(dir)/$(file))))))) \
|
||||
$(foreach file,$(autobj:.o=.cpp), \
|
||||
$(foreach dir,$(alldir),$(subst $(srcdir),$(objdir), \
|
||||
$(firstword $(subst .cpp,.o,$(wildcard $(srcdir)$(dir)/$(file))))))) \
|
||||
$(foreach file,$(autobj:.o=.asm), \
|
||||
$(foreach dir,$(alldir),$(subst $(srcdir),$(objdir), \
|
||||
$(firstword $(subst .asm,.o,$(wildcard $(srcdir)$(dir)/$(file))))))) \
|
||||
$(foreach file,$(autobj:.o=.rc), \
|
||||
$(foreach dir,$(alldir),$(subst $(srcdir),$(objdir), \
|
||||
$(firstword $(subst .rc,.o,$(wildcard $(srcdir)$(dir)/$(file)))))))
|
||||
|
||||
ifdef BUILD_A68K
|
||||
allobj += $(a68k.o)
|
||||
endif
|
||||
|
||||
alldep = $(foreach file,$(autobj:.o=.c), \
|
||||
$(foreach dir,$(alldir),$(subst $(srcdir),$(objdir), \
|
||||
$(firstword $(subst .c,.d,$(wildcard $(srcdir)$(dir)/$(file))))))) \
|
||||
$(foreach file,$(autobj:.o=.cpp), \
|
||||
$(foreach dir,$(alldir),$(subst $(srcdir),$(objdir), \
|
||||
$(firstword $(subst .cpp,.d,$(wildcard $(srcdir)$(dir)/$(file))))))) \
|
||||
$(foreach file,$(autobj:.o=.rc), \
|
||||
$(foreach dir,$(alldir),$(subst $(srcdir),$(objdir), \
|
||||
$(firstword $(subst .rc,.d,$(wildcard $(srcdir)$(dir)/$(file)))))))
|
||||
|
||||
autdrv := $(drvsrc:.cpp=.o)
|
||||
|
||||
#
|
||||
#
|
||||
# Specify compiler/linker/assembler
|
||||
#
|
||||
#
|
||||
|
||||
ifdef DARWIN
|
||||
# GCC 4.2.1 Segfaults during build
|
||||
CC = gcc-9
|
||||
else
|
||||
CC = gcc
|
||||
endif
|
||||
|
||||
CXX = $(CC)
|
||||
LD = $(CC)
|
||||
AS = nasm
|
||||
|
||||
#LDFLAGS = -static
|
||||
|
||||
CFLAGS = -O2 -fomit-frame-pointer -Wno-write-strings \
|
||||
-Wall -Wno-long-long -Wno-sign-compare -Wno-uninitialized -Wno-unused \
|
||||
-Wno-conversion -Wno-attributes \
|
||||
-Wno-unused-parameter -Wno-unused-value -std=c99 \
|
||||
$(PLATFLAGS) $(DEF) $(incdir)
|
||||
|
||||
CXXFLAGS = -O2 -fomit-frame-pointer -Wno-write-strings \
|
||||
-Wall -W -Wno-long-long \
|
||||
-Wunknown-pragmas -Wundef -Wconversion -Wno-missing-braces \
|
||||
-Wuninitialized -Wpointer-arith -Winline -Wno-multichar \
|
||||
-Wno-conversion -Wno-attributes \
|
||||
-Wno-unused-parameter -Wno-unused-value -Wno-narrowing \
|
||||
$(PLATFLAGS) $(DEF) $(incdir)
|
||||
|
||||
ASFLAGS = -O1 -f coff -w-orphan-labels
|
||||
|
||||
# D3DUtils & D3DMath need these
|
||||
# DEF = -Dsinf=\(float\)sin -Dcosf=\(float\)cos -Dasinf=\(float\)asin -Dacosf=\(float\)acos -Dsqrtf=\(float\)sqrt
|
||||
|
||||
# FIXME
|
||||
DEF := -DBUILD_SDL2 -DUSE_SPEEDHACKS -DFILENAME=$(NAME) -DUSE_FILE32API
|
||||
|
||||
ifdef WINDOWS
|
||||
DEF := $(DEF) -DSDL_WINDOWS
|
||||
endif
|
||||
|
||||
ifdef UNICODE
|
||||
DEF := $(DEF) -D_UNICODE
|
||||
endif
|
||||
|
||||
ifdef SPECIALBUILD
|
||||
DEF := $(DEF) -DSPECIALBUILD=$(SPECIALBUILD)
|
||||
endif
|
||||
|
||||
ifdef FASTCALL
|
||||
DEF := $(DEF) -DFASTCALL
|
||||
endif
|
||||
|
||||
ifdef DEBUG
|
||||
DEF := $(DEF) -DFBNEO_DEBUG
|
||||
endif
|
||||
|
||||
ifdef ROM_VERIFY
|
||||
DEF := $(DEF) -DROM_VERIFY
|
||||
endif
|
||||
|
||||
ifdef INCLUDE_7Z_SUPPORT
|
||||
DEF := $(DEF) -DINCLUDE_7Z_SUPPORT
|
||||
endif
|
||||
|
||||
ifdef INCLUDE_AVI_RECORDING
|
||||
DEF := $(DEF) -DINCLUDE_AVI_RECORDING
|
||||
endif
|
||||
|
||||
ifdef LSB_FIRST
|
||||
DEF := $(DEF) -DLSB_FIRST
|
||||
endif
|
||||
|
||||
ifdef INCLUDE_LIB_PNGH
|
||||
DEF := $(DEF) -DINCLUDE_LIB_PNGH
|
||||
endif
|
||||
|
||||
ifdef BUILD_A68K
|
||||
DEF := $(DEF) -DBUILD_A68K
|
||||
endif
|
||||
|
||||
ifdef BUILD_X86_ASM
|
||||
DEF := $(DEF) -DBUILD_X86_ASM
|
||||
endif
|
||||
|
||||
ifdef BUILD_X64_EXE
|
||||
DEF := $(DEF) -DBUILD_X64_EXE -DXBYAK_NO_OP_NAMES -DMIPS3_X64_DRC
|
||||
endif
|
||||
|
||||
ifdef SYMBOL
|
||||
|
||||
CFLAGS += -ggdb3 -fno-omit-frame-pointer
|
||||
CXXFLAGS += -ggdb3 -fno-omit-frame-pointer
|
||||
ASFLAGS += -g
|
||||
DEF := $(DEF) -D_DEBUG
|
||||
|
||||
ifdef SANITIZE
|
||||
CFLAGS += -fsanitize=address -fsanitize=undefined -fsanitize=bounds-strict
|
||||
CXXFLAGS += -fsanitize=address -fsanitize=undefined -fsanitize=bounds-strict
|
||||
endif
|
||||
|
||||
ifdef PROFILE
|
||||
CFLAGS += -pg
|
||||
CXXFLAGS += -pg
|
||||
endif
|
||||
|
||||
else
|
||||
LDFLAGS += -s
|
||||
endif
|
||||
|
||||
# For zlib
|
||||
DEF := $(DEF) -DNO_VIZ -D_LARGEFILE64_SOURCE=0 -D_FILE_OFFSET_BITS=32
|
||||
|
||||
# For lib7z
|
||||
ifdef INCLUDE_7Z_SUPPORT
|
||||
DEF := $(DEF) -D_7ZIP_PPMD_SUPPPORT
|
||||
endif
|
||||
|
||||
#
|
||||
#
|
||||
# Specify paths
|
||||
#
|
||||
#
|
||||
|
||||
vpath %.asm $(foreach dir,$(alldir),$(srcdir)$(dir)/ )
|
||||
vpath %.cpp $(foreach dir,$(alldir),$(srcdir)$(dir)/ )
|
||||
vpath %.c $(foreach dir,$(alldir),$(srcdir)$(dir)/ )
|
||||
vpath %.h $(foreach dir,$(alldir),$(srcdir)$(dir)/ )
|
||||
vpath %.rc $(foreach dir,$(alldir),$(srcdir)$(dir)/ )
|
||||
|
||||
vpath %.o $(foreach dir,$(alldir),$(objdir)$(dir)/ )
|
||||
vpath %.d $(foreach dir,$(alldir),$(objdir)$(dir)/ )
|
||||
|
||||
#
|
||||
#
|
||||
# Rules
|
||||
#
|
||||
#
|
||||
|
||||
.PHONY: all init cleandep touch clean
|
||||
|
||||
ifeq ($(MAKELEVEL),1)
|
||||
ifdef DEPEND
|
||||
|
||||
all: init $(drvdep) $(autdep) $(autobj) $(autdrv)
|
||||
@$(MAKE) -f makefile.sdl2 -s
|
||||
|
||||
else
|
||||
|
||||
all: init $(autobj) $(autdrv)
|
||||
@$(MAKE) -f makefile.sdl2 -s
|
||||
|
||||
endif
|
||||
else
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
#
|
||||
# Rule for linking the executable
|
||||
#
|
||||
#
|
||||
|
||||
ifeq ($(MAKELEVEL),2)
|
||||
|
||||
$(objdir)drivers.o: $(autdrv)
|
||||
@echo Linking drivers...
|
||||
@$(LD) -r -nostdlib -o $@ $^
|
||||
|
||||
ifdef WINDOWS
|
||||
|
||||
$(NAME): $(allobj) $(objdir)drivers.o
|
||||
@echo
|
||||
@echo Linking executable... $(NAME)
|
||||
@$(LD) -mconsole $(CFLAGS) $(LDFLAGS) -o $@ $^ $(lib)
|
||||
|
||||
else
|
||||
|
||||
$(NAME): $(allobj) $(objdir)drivers.o
|
||||
@echo
|
||||
@echo Linking executable... $(NAME)
|
||||
@$(LD) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(lib)
|
||||
endif
|
||||
|
||||
|
||||
ifdef DEBUG
|
||||
|
||||
# Don't compress when making a debug build
|
||||
|
||||
else
|
||||
ifdef COMPRESS
|
||||
@upx --best $@
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MAKELEVEL),1)
|
||||
ifdef FORCE_UPDATE
|
||||
$(build_details.h): FORCE
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# Generate the gamelist
|
||||
#
|
||||
|
||||
burn.o burn.d: driverlist.h
|
||||
|
||||
$(driverlist.h): $(drvsrc) $(srcdir)dep/scripts/gamelist.pl
|
||||
ifdef PERL
|
||||
@$(srcdir)dep/scripts/gamelist.pl -o $@ -l gamelist.txt \
|
||||
$(filter %.cpp,$(foreach file,$(drvsrc:.o=.cpp),$(foreach dir,$(alldir), \
|
||||
$(firstword $(wildcard $(srcdir)$(dir)/$(file))))))
|
||||
else
|
||||
ifeq ($(MAKELEVEL),2)
|
||||
@echo
|
||||
@echo Warning: Perl is not available on this system.
|
||||
@echo $@ cannot be updated or created!
|
||||
@echo
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# Verify if driverlist.h needs to be updated
|
||||
#
|
||||
|
||||
#ifeq ($(MAKELEVEL),1)
|
||||
#ifdef FORCE_UPDATE
|
||||
#$(driverlist.h): FORCE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#
|
||||
# Compile 68000 cores
|
||||
#
|
||||
|
||||
# A68K
|
||||
|
||||
ifdef BUILD_A68K
|
||||
$(a68k.o): fba_make68k.c
|
||||
@echo Compiling A68K MC68000 core...
|
||||
@$(CC) -mconsole $(CFLAGS) $(LDFLAGS) -DWIN32 -Wno-unused -Wno-conversion -Wno-missing-prototypes \
|
||||
-s $< -o $(subst $(srcdir),$(objdir),$(<D))/$(<F:.c=.exe)
|
||||
@$(subst $(srcdir),$(objdir),$(<D))/$(<F:.c=.exe) $(@:.o=.asm) \
|
||||
$(@D)/a68k_tab.asm 00 $(ppro)
|
||||
@echo Assembling A68K MC68000 core...
|
||||
@$(AS) $(ASFLAGS) $(@:.o=.asm) -o $@
|
||||
endif
|
||||
|
||||
# Musashi
|
||||
|
||||
$(objdir)cpu/m68k/m68kcpu.o: $(srcdir)cpu/m68k/m68kcpu.c $(objdir)dep/generated/m68kops.h $(srcdir)cpu/m68k/m68k.h $(srcdir)cpu/m68k/m68kconf.h
|
||||
@echo Compiling Musashi MC680x0 core \(m68kcpu.c\)...
|
||||
@$(CC) $(CFLAGS) -c $(srcdir)cpu/m68k/m68kcpu.c -o $(objdir)cpu/m68k/m68kcpu.o
|
||||
|
||||
$(objdir)cpu/m68k/m68kops.o: $(objdir)cpu/m68k/m68kmake $(objdir)dep/generated/m68kops.h $(objdir)dep/generated/m68kops.c $(srcdir)cpu/m68k/m68k.h $(srcdir)cpu/m68k/m68kconf.h
|
||||
@echo Compiling Musashi MC680x0 core \(m68kops.c\)...
|
||||
@$(CC) $(CFLAGS) -c $(objdir)dep/generated/m68kops.c -o $(objdir)cpu/m68k/m68kops.o
|
||||
|
||||
$(objdir)dep/generated/m68kops.h $(objdir)dep/generated/m68kops.c: $(objdir)cpu/m68k/m68kmake $(srcdir)cpu/m68k/m68k_in.c
|
||||
$(objdir)cpu/m68k/m68kmake $(objdir)dep/generated/ $(srcdir)cpu/m68k/m68k_in.c
|
||||
|
||||
$(objdir)cpu/m68k/m68kmake: $(srcdir)cpu/m68k/m68kmake.c
|
||||
@echo Compiling Musashi MC680x0 core \(m68kmake.c\)...
|
||||
@$(CC) $(CFLAGS) $(srcdir)cpu/m68k/m68kmake.c -o $(objdir)cpu/m68k/m68kmake -Dmain=main
|
||||
|
||||
|
||||
#
|
||||
# Extra rules for generated header file ctv.h, needed by ctv.cpp
|
||||
#
|
||||
|
||||
ctv.d ctv.o: $(ctv.h)
|
||||
|
||||
$(ctv.h): ctv_make.cpp
|
||||
@echo Generating $(srcdir)dep/generated/$(@F)...
|
||||
@$(CC) $(CXXFLAGS) $(LDFLAGS) $< \
|
||||
-o $(subst $(srcdir),$(objdir),$(<D))/$(<F:.cpp=.exe) -Dmain=main
|
||||
@$(subst $(srcdir),$(objdir),$(<D))/$(<F:.cpp=.exe) >$@
|
||||
|
||||
#
|
||||
# Extra rules for generated header file toa_gp9001_func.h, needed by toa_gp9001.cpp
|
||||
#
|
||||
|
||||
toa_bcu2.d toa_bcu2.o toa_gp9001.d toa_gp9001.o: $(toa_gp9001_func.h)
|
||||
|
||||
$(toa_gp9001_func.h): $(srcdir)dep/scripts/toa_gp9001_func.pl
|
||||
@$(srcdir)dep/scripts/toa_gp9001_func.pl -o $(toa_gp9001_func.h)
|
||||
|
||||
#
|
||||
# Extra rules for generated header file neo_sprite_func.h, needed by neo_sprite.cpp
|
||||
#
|
||||
|
||||
neo_sprite.d neo_sprite.o: $(neo_sprite_func.h)
|
||||
|
||||
$(neo_sprite_func.h): $(srcdir)dep/scripts/neo_sprite_func.pl
|
||||
@$(srcdir)dep/scripts/neo_sprite_func.pl -o $(neo_sprite_func.h)
|
||||
|
||||
#
|
||||
# Extra rules for generated header file cave_tile_func.h, needed by cave_tile.cpp
|
||||
#
|
||||
|
||||
cave_tile.d cave_tile.o: $(cave_tile_func.h)
|
||||
|
||||
$(cave_tile_func.h): $(srcdir)dep/scripts/cave_tile_func.pl
|
||||
@$(srcdir)dep/scripts/cave_tile_func.pl -o $(cave_tile_func.h)
|
||||
|
||||
#
|
||||
# Extra rules for generated header file cave_sprite_func.h, needed by cave_sprite.cpp
|
||||
#
|
||||
|
||||
cave_sprite.d cave_sprite.o: $(cave_sprite_func.h)
|
||||
|
||||
$(cave_sprite_func.h): $(srcdir)dep/scripts/cave_sprite_func.pl
|
||||
@$(srcdir)dep/scripts/cave_sprite_func.pl -o $(cave_sprite_func.h)
|
||||
|
||||
#
|
||||
# Extra rules for generated header file psikyo_tile_func.h / psikyo_sprite_func.h, needed by psikyo_tile.cpp / psikyo_sprite.cpp
|
||||
#
|
||||
|
||||
psikyo_tile.d psikyo_tile.o psikyosprite.d psikyo_sprite.o: $(psikyo_tile_func.h)
|
||||
|
||||
$(psikyo_tile_func.h): $(srcdir)dep/scripts/psikyo_tile_func.pl
|
||||
$(srcdir)dep/scripts/psikyo_tile_func.pl -o $(psikyo_tile_func.h)
|
||||
|
||||
#
|
||||
# Extra rules for generated header file pgm_sprite.h, needed by pgm_draw.cpp
|
||||
#
|
||||
|
||||
pgm_draw.d pgm_draw.o: $(pgm_sprite.h)
|
||||
|
||||
$(pgm_sprite.h): pgm_sprite_create.cpp
|
||||
@echo Generating $(srcdir)dep/generated/$(@F)...
|
||||
@$(CC) $(CXXFLAGS) $(LDFLAGS) $< \
|
||||
-o $(subst $(srcdir),$(objdir),$(<D))/$(<F:.cpp=.exe) -Dmain=main
|
||||
@$(subst $(srcdir),$(objdir),$(<D))/$(<F:.cpp=.exe) >$@
|
||||
|
||||
|
||||
ifeq ($(MAKELEVEL),2)
|
||||
ifdef DEPEND
|
||||
|
||||
include $(alldep)
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# Generic rules for C/C++ files
|
||||
#
|
||||
# Note: require init to complete before assembling anything (see "| init" below)
|
||||
# to avoid parallization issues on fresh builds.
|
||||
#
|
||||
|
||||
ifeq ($(MAKELEVEL),1)
|
||||
|
||||
%.o: %.cpp
|
||||
@echo Compiling $<...
|
||||
@$(CC) $(CXXFLAGS) -c $< -o $(subst $(srcdir),$(objdir),$(<D))/$(@F)
|
||||
|
||||
%.o: %.c
|
||||
@echo Compiling $<...
|
||||
@$(CC) $(CFLAGS) -c $< -o $(subst $(srcdir),$(objdir),$(<D))/$(@F)
|
||||
|
||||
%.o: %.asm | init
|
||||
@echo Assembling $<...
|
||||
@$(AS) $(ASFLAGS) $< -o $(subst $(srcdir),$(objdir),$(<D))/$(@F)
|
||||
|
||||
else
|
||||
|
||||
%.o: %.c
|
||||
@echo Compiling $<...
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.asm | init
|
||||
@echo Assembling $<...
|
||||
@$(AS) $(ASFLAGS) $< -o $@
|
||||
|
||||
%.o:
|
||||
@echo Compiling $<...
|
||||
@$(CC) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
# Generate dependencies for C/C++ files
|
||||
#
|
||||
|
||||
ifdef DEPEND
|
||||
|
||||
%.d: %.c
|
||||
@echo Generating depend file for $<...
|
||||
@$(CC) -MM -MT "$(subst $(srcdir),$(objdir),$(<D))/$(*F).o $(subst $(srcdir),$(objdir),$(<D))/$(@F)" -x c++ $(CXXFLAGS) $< >$(subst $(srcdir),$(objdir),$(<D))/$(@F)
|
||||
|
||||
%.d: %.cpp
|
||||
@echo Generating depend file for $<...
|
||||
@$(CC) -MM -MT "$(subst $(srcdir),$(objdir),$(<D))/$(*F).o $(subst $(srcdir),$(objdir),$(<D))/$(@F)" -x c++ $(CXXFLAGS) $< >$(subst $(srcdir),$(objdir),$(<D))/$(@F)
|
||||
|
||||
%.d: %.rc
|
||||
@echo Generating depend file for $<...
|
||||
@$(CC) -MM -MT "$(subst $(srcdir),$(objdir),$(<D))/$(*F).o $(subst $(srcdir),$(objdir),$(<D))/$(@F)" -x c++ $(CXXFLAGS) $< >$(subst $(srcdir),$(objdir),$(<D))/$(@F)
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
# Phony targets
|
||||
#
|
||||
|
||||
init:
|
||||
|
||||
ifdef DEBUG
|
||||
@echo Making debug build...
|
||||
else
|
||||
@echo Making normal build...
|
||||
endif
|
||||
@echo
|
||||
@mkdir -p $(foreach dir, $(alldir),$(objdir)$(dir))
|
||||
@mkdir -p $(srcdir)dep/generated
|
||||
|
||||
cleandep:
|
||||
@echo Removing depend files from $(objdir)...
|
||||
-@for dir in $(alldir); do rm -f $(objdir)$$dir/*.d; done
|
||||
|
||||
touch:
|
||||
@echo Marking all targets for $(NAME) as uptodate...
|
||||
-@touch $(NAME).exe
|
||||
-@touch -c -r $(NAME).exe $(srcdir)/dep/generated/*
|
||||
-@for dir in $(alldir); do touch -c -r $(NAME).exe $(objdir)$$dir/*; done
|
||||
|
||||
clean:
|
||||
@echo Removing build files...
|
||||
-@rm -fr $(objdir) $(ctv.h) $(dep)generated gamelist.txt $(NAME)
|
||||
|
||||
ifdef PERL
|
||||
@echo Removing all files generated with perl scripts...
|
||||
-@rm -f -r $(app_gnuc.rc) $(driverlist)
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# Rule to force recompilation of any target that depends on it
|
||||
#
|
||||
|
||||
FORCE:
|
@ -511,7 +511,7 @@
|
||||
<ClCompile Include="..\..\src\burn\drv\pre90s\d_mcr.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\pre90s\d_mcr3.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\pre90s\d_senjyo.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\pre90s\d_spdodgeb.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\pre90s\d_spdodgeb.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\pst90s\d_itech32.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\pst90s\d_legionna.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\sega\d_sys24.cpp" />
|
||||
@ -536,29 +536,29 @@
|
||||
<ClCompile Include="..\..\src\intf\cd\win32\cd_img.cpp" />
|
||||
<ClCompile Include="generated\m68kops.c" />
|
||||
<CustomBuild Include="..\..\src\burn\drv\capcom\ctv_make.cpp">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cl ..\..\src\burn\drv\capcom\%(Filename).cpp
|
||||
%(Filename).exe > generated\ctv.h
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cl ..\..\src\burn\drv\capcom\%(Filename).cpp
|
||||
%(Filename).exe > generated\ctv.h
|
||||
|
||||
del %(Filename).obj
|
||||
|
||||
del %(Filename).exe</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\generated\ctv.h</Outputs>
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</DeploymentContent>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cl ..\..\src\burn\drv\capcom\%(Filename).cpp
|
||||
%(Filename).exe > generated\ctv.h
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cl ..\..\src\burn\drv\capcom\%(Filename).cpp
|
||||
%(Filename).exe > generated\ctv.h
|
||||
|
||||
del %(Filename).obj
|
||||
|
||||
del %(Filename).exe</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\generated\ctv.h</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cl ..\..\src\burn\drv\capcom\%(Filename).cpp
|
||||
%(Filename).exe > generated\ctv.h
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cl ..\..\src\burn\drv\capcom\%(Filename).cpp
|
||||
%(Filename).exe > generated\ctv.h
|
||||
|
||||
del %(Filename).obj
|
||||
|
||||
del %(Filename).exe</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cl ..\..\src\burn\drv\capcom\%(Filename).cpp
|
||||
%(Filename).exe > generated\ctv.h
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cl ..\..\src\burn\drv\capcom\%(Filename).cpp
|
||||
%(Filename).exe > generated\ctv.h
|
||||
|
||||
del %(Filename).obj
|
||||
|
||||
@ -771,24 +771,24 @@ del %(Filename).exe</Command>
|
||||
<ClCompile Include="..\..\src\burn\drv\pgm\pgm_draw.cpp" />
|
||||
<ClCompile Include="..\..\src\burn\drv\pgm\pgm_run.cpp" />
|
||||
<CustomBuild Include="..\..\src\burn\drv\pgm\pgm_sprite_create.cpp">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cl ..\..\src\burn\drv\pgm\%(Filename).cpp
|
||||
%(Filename).exe > generated\pgm_sprite.h
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cl ..\..\src\burn\drv\pgm\%(Filename).cpp
|
||||
%(Filename).exe > generated\pgm_sprite.h
|
||||
del %(Filename).obj
|
||||
del %(Filename).exe
|
||||
</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">pgm_sprite.h</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cl ..\..\src\burn\drv\pgm\%(Filename).cpp
|
||||
%(Filename).exe > generated\pgm_sprite.h
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cl ..\..\src\burn\drv\pgm\%(Filename).cpp
|
||||
%(Filename).exe > generated\pgm_sprite.h
|
||||
del %(Filename).obj
|
||||
del %(Filename).exe</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">pgm_sprite.h</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cl ..\..\src\burn\drv\pgm\%(Filename).cpp
|
||||
%(Filename).exe > generated\pgm_sprite.h
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cl ..\..\src\burn\drv\pgm\%(Filename).cpp
|
||||
%(Filename).exe > generated\pgm_sprite.h
|
||||
del %(Filename).obj
|
||||
del %(Filename).exe</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">pgm_sprite.h</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cl ..\..\src\burn\drv\pgm\%(Filename).cpp
|
||||
%(Filename).exe > generated\pgm_sprite.h
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cl ..\..\src\burn\drv\pgm\%(Filename).cpp
|
||||
%(Filename).exe > generated\pgm_sprite.h
|
||||
del %(Filename).obj
|
||||
del %(Filename).exe</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">pgm_sprite.h</Outputs>
|
||||
|
@ -1002,8 +1002,6 @@
|
||||
FEED9DFA23576B9F00B7AF83 /* support_paths.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEED9DF923576B9F00B7AF83 /* support_paths.cpp */; };
|
||||
FEED9DFC23576BD500B7AF83 /* inpdipsw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEED9DFB23576BD500B7AF83 /* inpdipsw.cpp */; };
|
||||
FEED9DFE23576C2500B7AF83 /* scrn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEED9DFD23576C2500B7AF83 /* scrn.cpp */; };
|
||||
FEED9E0323576D1B00B7AF83 /* cdsound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEED9E0023576D1B00B7AF83 /* cdsound.cpp */; settings = {COMPILER_FLAGS = "-Wno-return-type"; }; };
|
||||
FEED9E0423576D1B00B7AF83 /* cd_isowav.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEED9E0123576D1B00B7AF83 /* cd_isowav.cpp */; };
|
||||
FEED9E0623576DD800B7AF83 /* ips_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEED9E0523576DD800B7AF83 /* ips_manager.cpp */; };
|
||||
FEED9E0823576E1900B7AF83 /* stated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEED9E0723576E1900B7AF83 /* stated.cpp */; };
|
||||
FEED9E0A23576E3800B7AF83 /* replay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEED9E0923576E3800B7AF83 /* replay.cpp */; };
|
||||
@ -2535,9 +2533,6 @@
|
||||
FEED9DF923576B9F00B7AF83 /* support_paths.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = support_paths.cpp; sourceTree = "<group>"; };
|
||||
FEED9DFB23576BD500B7AF83 /* inpdipsw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = inpdipsw.cpp; sourceTree = "<group>"; };
|
||||
FEED9DFD23576C2500B7AF83 /* scrn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scrn.cpp; sourceTree = "<group>"; };
|
||||
FEED9E0023576D1B00B7AF83 /* cdsound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cdsound.cpp; sourceTree = "<group>"; };
|
||||
FEED9E0123576D1B00B7AF83 /* cd_isowav.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cd_isowav.cpp; sourceTree = "<group>"; };
|
||||
FEED9E0223576D1B00B7AF83 /* cdsound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cdsound.h; sourceTree = "<group>"; };
|
||||
FEED9E0523576DD800B7AF83 /* ips_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ips_manager.cpp; sourceTree = "<group>"; };
|
||||
FEED9E0723576E1900B7AF83 /* stated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stated.cpp; sourceTree = "<group>"; };
|
||||
FEED9E0923576E3800B7AF83 /* replay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = replay.cpp; sourceTree = "<group>"; };
|
||||
@ -4788,9 +4783,6 @@
|
||||
FEED9DFF23576D1B00B7AF83 /* sdl */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FEED9E0023576D1B00B7AF83 /* cdsound.cpp */,
|
||||
FEED9E0123576D1B00B7AF83 /* cd_isowav.cpp */,
|
||||
FEED9E0223576D1B00B7AF83 /* cdsound.h */,
|
||||
);
|
||||
path = sdl;
|
||||
sourceTree = "<group>";
|
||||
@ -5371,7 +5363,6 @@
|
||||
FE1B24C423561A750065200C /* sms.cpp in Sources */,
|
||||
FE1B264423561A770065200C /* cps.cpp in Sources */,
|
||||
FE1B275823561A780065200C /* d_timelimt.cpp in Sources */,
|
||||
FEED9E0423576D1B00B7AF83 /* cd_isowav.cpp in Sources */,
|
||||
FE1B23DB23561A750065200C /* upd7725.cpp in Sources */,
|
||||
FE1B275123561A780065200C /* d_himesiki.cpp in Sources */,
|
||||
FE1B245523561A750065200C /* crc32.c in Sources */,
|
||||
@ -5770,7 +5761,6 @@
|
||||
FE1B26EC23561A780065200C /* d_kncljoe.cpp in Sources */,
|
||||
FE1B277F23561A790065200C /* ym2151.c in Sources */,
|
||||
FE1B244223561A750065200C /* Sha256.c in Sources */,
|
||||
FEED9E0323576D1B00B7AF83 /* cdsound.cpp in Sources */,
|
||||
FE1B271523561A780065200C /* d_blockade.cpp in Sources */,
|
||||
FE1B25E123561A760065200C /* d_ajax.cpp in Sources */,
|
||||
FE1B23D423561A750065200C /* konami.cpp in Sources */,
|
||||
|
@ -20,13 +20,13 @@ INT32 nBurnVer = BURN_VERSION; // Version number of the library
|
||||
UINT32 nBurnDrvCount = 0; // Count of game drivers
|
||||
UINT32 nBurnDrvActive = ~0U; // Which game driver is selected
|
||||
UINT32 nBurnDrvSelect[8] = { ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U }; // Which games are selected (i.e. loaded but not necessarily active)
|
||||
|
||||
|
||||
bool bBurnUseMMX;
|
||||
#if defined BUILD_A68K
|
||||
bool bBurnUseASMCPUEmulation = false;
|
||||
#endif
|
||||
|
||||
// Just so we can start using FBNEO_DEBUG and keep backwards compatablity should whatever is left of FB Alpha rise from it's grave.
|
||||
// Just so we can start using FBNEO_DEBUG and keep backwards compatablity should whatever is left of FB Alpha rise from it's grave.
|
||||
#if defined (FBNEO_DEBUG) && (!defined FBA_DEBUG)
|
||||
#define FBA_DEBUG 1
|
||||
#endif
|
||||
@ -196,10 +196,10 @@ extern "C" TCHAR* BurnDrvGetText(UINT32 i)
|
||||
|
||||
if (!(i & DRV_ASCIIONLY)) {
|
||||
switch (i & 0xFF) {
|
||||
#if !defined(__LIBRETRO__) && !defined(BUILD_SDL) && !defined(BUILD_MACOS)
|
||||
#if !defined(__LIBRETRO__) && !defined(BUILD_SDL) && !defined(BUILD_SDL2) && !defined(BUILD_MACOS)
|
||||
case DRV_FULLNAME:
|
||||
pszStringW = pDriver[nBurnDrvActive]->szFullNameW;
|
||||
|
||||
|
||||
if (i & DRV_NEXTNAME) {
|
||||
if (pszCurrentNameW && pDriver[nBurnDrvActive]->szFullNameW) {
|
||||
pszCurrentNameW += wcslen(pszCurrentNameW) + 1;
|
||||
@ -543,7 +543,7 @@ extern "C" INT32 BurnDrvSetVisibleSize(INT32 pnWidth, INT32 pnHeight)
|
||||
pDriver[nBurnDrvActive]->nWidth = pnWidth;
|
||||
pDriver[nBurnDrvActive]->nHeight = pnHeight;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -552,7 +552,7 @@ extern "C" INT32 BurnDrvSetAspect(INT32 pnXAspect,INT32 pnYAspect)
|
||||
pDriver[nBurnDrvActive]->nXAspect = pnXAspect;
|
||||
pDriver[nBurnDrvActive]->nYAspect = pnYAspect;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the hardware code
|
||||
@ -690,13 +690,13 @@ extern "C" INT32 BurnDrvExit()
|
||||
CheatExit();
|
||||
CheatSearchExit();
|
||||
BurnStateExit();
|
||||
|
||||
|
||||
nBurnCPUSpeedAdjust = 0x0100;
|
||||
|
||||
pBurnDrvPalette = NULL;
|
||||
|
||||
|
||||
pBurnDrvPalette = NULL;
|
||||
|
||||
INT32 nRet = pDriver[nBurnDrvActive]->Exit(); // Forward to drivers function
|
||||
|
||||
|
||||
BurnExitMemoryManager();
|
||||
#if defined FBNEO_DEBUG
|
||||
DebugTrackerExit();
|
||||
@ -930,7 +930,7 @@ struct MovieExtInfo
|
||||
UINT32 hour, minute, second;
|
||||
};
|
||||
|
||||
#if !defined(BUILD_SDL) && !defined(BUILD_MACOS)
|
||||
#if !defined(BUILD_SDL) && !defined(BUILD_SDL2) && !defined(BUILD_MACOS)
|
||||
extern struct MovieExtInfo MovieInfo; // from replay.cpp
|
||||
#else
|
||||
struct MovieExtInfo MovieInfo = { 0, 0, 0, 0, 0, 0 };
|
||||
|
@ -26,6 +26,10 @@
|
||||
#define FBA
|
||||
#define FBANEO
|
||||
|
||||
#ifndef M_PI // SDL2 is making this not found
|
||||
#define M_PI 3.14159265358979323846264338327950288
|
||||
#endif
|
||||
|
||||
typedef unsigned char UINT8;
|
||||
typedef signed char INT8;
|
||||
typedef unsigned short UINT16;
|
||||
|
@ -53,7 +53,7 @@ static struct BurnInputInfo BatmanInputList[] = {
|
||||
{"P1 Button 2", BIT_DIGITAL, DrvJoy1 + 10, "p1 fire 2" },
|
||||
|
||||
{"P2 Coin", BIT_DIGITAL, DrvJoy2 + 0, "p2 coin" },
|
||||
|
||||
|
||||
{"Reset", BIT_DIGITAL, &DrvReset, "reset" },
|
||||
{"Tilt", BIT_DIGITAL, DrvJoy2 + 2, "tilt" },
|
||||
{"Service", BIT_DIGITAL, DrvJoy2 + 3, "service" },
|
||||
@ -782,7 +782,7 @@ static struct BurnRomInfo batmanRomDesc[] = {
|
||||
{ "136085-1042.17e", 0x20000, 0x8c496986, 6 | BRF_GRA }, // 25
|
||||
{ "136085-1043.15e", 0x20000, 0x51812d3b, 6 | BRF_GRA }, // 26
|
||||
{ "136085-1044.12e", 0x20000, 0x5e2d7f31, 6 | BRF_GRA }, // 27
|
||||
|
||||
|
||||
{ "batman-eeprom.bin", 0x00800, 0xc859b535, 7 | BRF_PRG | BRF_ESS }, // 28 NVRAM Data
|
||||
|
||||
{ "gal16v8a-136085-1001.m9", 0x00117, 0x45dfc0cf, 8 | BRF_OPT }, // 29 PLDs
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf ("typedef INT32 (*sprite_draw_function)(UINT16 *dest, UINT8 *adata, INT32 pal);\n");
|
||||
printf ("typedef INT32 (*sprite_draw_nozoom_function)(UINT16 *dest, UINT8 *pdest, UINT8 *adata, INT32 pal, INT32 pri);\n\n");
|
||||
|
@ -33,28 +33,28 @@ void updatecpumode()
|
||||
}
|
||||
|
||||
/*Addressing modes*/
|
||||
static inline UINT32 absolute()
|
||||
static UINT32 absolute()
|
||||
{
|
||||
UINT32 temp = readmemw(snes_cpu.pbr | snes_cpu.pc);
|
||||
snes_cpu.pc += 2;
|
||||
return temp | snes_cpu.dbr;
|
||||
}
|
||||
|
||||
static inline UINT32 absolutex()
|
||||
static UINT32 absolutex()
|
||||
{
|
||||
UINT32 temp = (readmemw(snes_cpu.pbr | snes_cpu.pc)) + REG_XW() + snes_cpu.dbr;
|
||||
snes_cpu.pc += 2;
|
||||
return temp;
|
||||
}
|
||||
|
||||
static inline UINT32 absolutey()
|
||||
static UINT32 absolutey()
|
||||
{
|
||||
UINT32 temp = (readmemw(snes_cpu.pbr | snes_cpu.pc)) + REG_YW() + snes_cpu.dbr;
|
||||
snes_cpu.pc += 2;
|
||||
return temp;
|
||||
}
|
||||
|
||||
static inline UINT32 absolutelong()
|
||||
static UINT32 absolutelong()
|
||||
{
|
||||
UINT32 temp = readmemw(snes_cpu.pbr | snes_cpu.pc);
|
||||
snes_cpu.pc += 2;
|
||||
@ -63,7 +63,7 @@ static inline UINT32 absolutelong()
|
||||
return temp;
|
||||
}
|
||||
|
||||
static inline UINT32 absolutelongx()
|
||||
static UINT32 absolutelongx()
|
||||
{
|
||||
UINT32 temp = (readmemw(snes_cpu.pbr | snes_cpu.pc)) + REG_XW();
|
||||
snes_cpu.pc += 2;
|
||||
@ -72,7 +72,7 @@ static inline UINT32 absolutelongx()
|
||||
return temp;
|
||||
}
|
||||
|
||||
static inline UINT32 zeropage() /*It's actually direct page, but I'm used to calling it zero page*/
|
||||
static UINT32 zeropage() /*It's actually direct page, but I'm used to calling it zero page*/
|
||||
{
|
||||
UINT32 temp = snes_readmem(snes_cpu.pbr | snes_cpu.pc);
|
||||
snes_cpu.pc++;
|
||||
@ -85,7 +85,7 @@ static inline UINT32 zeropage() /*It's actually direct page, but I'm used to cal
|
||||
return temp & 0xFFFF;
|
||||
}
|
||||
|
||||
static inline UINT32 zeropagex()
|
||||
static UINT32 zeropagex()
|
||||
{
|
||||
UINT32 temp = snes_readmem(snes_cpu.pbr | snes_cpu.pc) + REG_XW();
|
||||
snes_cpu.pc++;
|
||||
@ -102,7 +102,7 @@ static inline UINT32 zeropagex()
|
||||
return temp & 0xFFFF;
|
||||
}
|
||||
|
||||
static inline UINT32 zeropagey()
|
||||
static UINT32 zeropagey()
|
||||
{
|
||||
UINT32 temp = snes_readmem(snes_cpu.pbr | snes_cpu.pc) + REG_YW();
|
||||
snes_cpu.pc++;
|
||||
@ -119,7 +119,7 @@ static inline UINT32 zeropagey()
|
||||
return temp & 0xFFFF;
|
||||
}
|
||||
|
||||
static inline UINT32 stack()
|
||||
static UINT32 stack()
|
||||
{
|
||||
UINT32 temp = snes_readmem(snes_cpu.pbr | snes_cpu.pc);
|
||||
snes_cpu.pc++;
|
||||
@ -127,40 +127,40 @@ static inline UINT32 stack()
|
||||
return temp & 0xFFFF;
|
||||
}
|
||||
|
||||
static inline UINT32 indirect()
|
||||
static UINT32 indirect()
|
||||
{
|
||||
UINT32 temp = (snes_readmem(snes_cpu.pbr | snes_cpu.pc) + snes_cpu.dp) & 0xFFFF;
|
||||
snes_cpu.pc++;
|
||||
return (readmemw(temp)) + snes_cpu.dbr;
|
||||
}
|
||||
|
||||
static inline UINT32 indirectx()
|
||||
static UINT32 indirectx()
|
||||
{
|
||||
UINT32 temp = (snes_readmem(snes_cpu.pbr | snes_cpu.pc) + snes_cpu.dp + REG_XW()) & 0xFFFF;
|
||||
snes_cpu.pc++;
|
||||
return (readmemw(temp)) + snes_cpu.dbr;
|
||||
}
|
||||
static inline UINT32 jindirectx() /*JSR (,x) uses p.pbr instead of p.dbr, and 2 byte address insted of 1 + p.dp*/
|
||||
static UINT32 jindirectx() /*JSR (,x) uses p.pbr instead of p.dbr, and 2 byte address insted of 1 + p.dp*/
|
||||
{
|
||||
UINT32 temp = (snes_readmem(snes_cpu.pbr | snes_cpu.pc) + (snes_readmem((snes_cpu.pbr | snes_cpu.pc) + 1) << 8) + REG_XW()) + snes_cpu.pbr;
|
||||
snes_cpu.pc += 2;
|
||||
return temp;
|
||||
}
|
||||
|
||||
static inline UINT32 indirecty()
|
||||
static UINT32 indirecty()
|
||||
{
|
||||
UINT32 temp = (snes_readmem(snes_cpu.pbr | snes_cpu.pc) + snes_cpu.dp) & 0xFFFF;
|
||||
snes_cpu.pc++;
|
||||
return (readmemw(temp)) + REG_YW() + snes_cpu.dbr;
|
||||
}
|
||||
static inline UINT32 sindirecty()
|
||||
static UINT32 sindirecty()
|
||||
{
|
||||
UINT32 temp = (snes_readmem(snes_cpu.pbr | snes_cpu.pc) + REG_SW()) & 0xFFFF;
|
||||
snes_cpu.pc++;
|
||||
return (readmemw(temp)) + REG_YW() + snes_cpu.dbr;
|
||||
}
|
||||
|
||||
static inline UINT32 indirectl()
|
||||
static UINT32 indirectl()
|
||||
{
|
||||
UINT32 temp = (snes_readmem(snes_cpu.pbr | snes_cpu.pc) + snes_cpu.dp) & 0xFFFF;
|
||||
snes_cpu.pc++;
|
||||
@ -168,7 +168,7 @@ static inline UINT32 indirectl()
|
||||
return address;
|
||||
}
|
||||
|
||||
static inline UINT32 indirectly()
|
||||
static UINT32 indirectly()
|
||||
{
|
||||
UINT32 temp = (snes_readmem(snes_cpu.pbr | snes_cpu.pc) + snes_cpu.dp) & 0xFFFF;
|
||||
snes_cpu.pc++;
|
||||
@ -5750,4 +5750,4 @@ void irq65816()
|
||||
SET_IRQ();
|
||||
CLEAR_DECIMAL();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1595,7 +1595,7 @@ SNES_INLINE static unsigned int CalcCol(UINT16 nColour)
|
||||
//g = pal5bit(nColour >> 5);
|
||||
//b = pal5bit(nColour >> 10);
|
||||
|
||||
r = (nColour & 0x7C00) >> 7; // Red
|
||||
r = (nColour & 0x7C00) >> 7; // Red
|
||||
r |= r >> 0;
|
||||
g = (nColour & 0x03E0) >> 2; // Green
|
||||
g |= g >> 5;
|
||||
@ -1802,7 +1802,7 @@ void dohdma(int line)
|
||||
hdmaaddr[c] = dmasrc[c];
|
||||
hdmacount[c] = 0;
|
||||
// if (c==2)
|
||||
// printf("Reset HDMA %i loading from %02X%04X %i\n",c,dmabank[c],hdmaaddr[c],hdmacount[c]);
|
||||
// /src/burn("Reset HDMA %i loading from %02X%04X %i\n",c,dmabank[c],hdmaaddr[c],hdmacount[c]);
|
||||
}
|
||||
if (hdmaena & (1 << c) && hdmacount[c] != -1)
|
||||
{
|
||||
@ -1961,7 +1961,7 @@ void dumphdma()
|
||||
int c;
|
||||
for (c = 0; c < 8; c++)
|
||||
{
|
||||
printf("HDMA %i %s - src %06X dest %04X mode %02X stat %i len %i\n", c, (hdmaena & (1 << c)) ? "on" : "off", (dmabank[c] << 16) | dmasrc[c], dmadest[c], dmactrl[c], hdmastat[c], hdmacount[c]);
|
||||
// printf("HDMA %i %s - src %06X dest %04X mode %02X stat %i len %i\n", c, (hdmaena & (1 << c)) ? "on" : "off", (dmabank[c] << 16) | dmasrc[c], dmadest[c], dmactrl[c], hdmastat[c], hdmacount[c]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2467,7 +2467,7 @@ void writeppu(UINT16 offset, UINT8 data)
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("%x, %x", offset, data);
|
||||
//printf("%x, %x", offset, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
** Copyright (C) 2001, 2002, 2003 Jarek Burczynski (bujar at mame dot net)
|
||||
** Copyright (C) 1998 Tatsuyuki Satoh , MultiArcadeMachineEmulator development
|
||||
**
|
||||
** Version 1.4 (final beta)
|
||||
** Version 1.4 (final beta)
|
||||
**
|
||||
** Additional code & fixes by Eke-Eke for Genesis Plus GX
|
||||
**
|
||||
@ -31,7 +31,7 @@
|
||||
** 12-03-2017 Eke-Eke (Genesis Plus GX):
|
||||
** - fixed Op1 self-feedback regression introduced by previous modifications
|
||||
** - removed one-sample extra delay on Op1 calculated output
|
||||
** - refactored chan_calc() function
|
||||
** - refactored chan_calc() function
|
||||
**
|
||||
** 01-09-2012 Eke-Eke (Genesis Plus GX):
|
||||
** - removed input clock / output samplerate frequency ratio, chip now always run at (original) internal sample frequency
|
||||
@ -48,7 +48,7 @@
|
||||
** - adjusted lowest EG rates increment values
|
||||
** - fixed Attack Rate not being updated in some specific cases (Batman & Robin intro)
|
||||
** - fixed EG behavior when Attack Rate is maximal
|
||||
** - fixed EG behavior when SL=0 (Mega Turrican tracks 03,09...) or/and Key ON occurs at minimal attenuation
|
||||
** - fixed EG behavior when SL=0 (Mega Turrican tracks 03,09...) or/and Key ON occurs at minimal attenuation
|
||||
** - implemented EG output immediate changes on register writes
|
||||
** - fixed YM2612 initial values (after the reset): fixes missing intro in B.O.B
|
||||
** - implemented Detune overflow (Ariel, Comix Zone, Shaq Fu, Spiderman & many other games using GEMS sound engine)
|
||||
@ -646,7 +646,7 @@ static YM2612 ym2612;
|
||||
static INT32 m2,c1,c2; /* Phase Modulation input for operators 2,3,4 */
|
||||
static INT32 mem; /* one sample delay memory */
|
||||
static INT32 out_fm[8]; /* outputs of working channels */
|
||||
static UINT32 bitmask; /* working channels output bitmasking (DAC quantization) */
|
||||
static UINT32 bitmask; /* working channels output bitmasking (DAC quantization) */
|
||||
|
||||
|
||||
INLINE void FM_KEYON(FM_CH *CH , int s )
|
||||
@ -867,9 +867,9 @@ INLINE void set_timers(int v )
|
||||
ym2612.OPN.ST.TAC = ym2612.OPN.ST.TAL;
|
||||
if ((v&2) && !(ym2612.OPN.ST.mode&2))
|
||||
ym2612.OPN.ST.TBC = ym2612.OPN.ST.TBL;
|
||||
|
||||
|
||||
/* reset Timers flags */
|
||||
ym2612.OPN.ST.status &= (~v >> 4);
|
||||
ym2612.OPN.ST.status &= (~v >> 4);
|
||||
|
||||
ym2612.OPN.ST.mode = v;
|
||||
}
|
||||
@ -1034,7 +1034,7 @@ INLINE void set_sr(FM_SLOT *SLOT,int v)
|
||||
INLINE void set_sl_rr(FM_SLOT *SLOT,int v)
|
||||
{
|
||||
SLOT->sl = sl_table[ v>>4 ];
|
||||
|
||||
|
||||
/* check EG state changes */
|
||||
if ((SLOT->state == EG_DEC) && (SLOT->volume >= (INT32)(SLOT->sl)))
|
||||
SLOT->state = EG_SUS;
|
||||
@ -1305,7 +1305,7 @@ INLINE void update_ssg_eg_channels(FM_CH *CH)
|
||||
INLINE void update_phase_lfo_slot(FM_SLOT *SLOT, UINT32 pm, UINT8 kc, UINT32 fc)
|
||||
{
|
||||
INT32 lfo_fn_offset = lfo_pm_table[(((fc & 0x7f0) >> 4) << 8) + pm];
|
||||
|
||||
|
||||
if (lfo_fn_offset) /* LFO phase modulation active */
|
||||
{
|
||||
/* block is not modified by LFO PM */
|
||||
@ -1329,7 +1329,7 @@ INLINE void update_phase_lfo_slot(FM_SLOT *SLOT, UINT32 pm, UINT8 kc, UINT32 fc)
|
||||
INLINE void update_phase_lfo_channel(FM_CH *CH)
|
||||
{
|
||||
UINT32 fc = CH->block_fnum;
|
||||
|
||||
|
||||
INT32 lfo_fn_offset = lfo_pm_table[(((fc & 0x7f0) >> 4) << 8) + CH->pms + ym2612.OPN.LFO_PM];
|
||||
|
||||
if (lfo_fn_offset) /* LFO phase modulation active */
|
||||
@ -1741,7 +1741,7 @@ INLINE void OPNWriteReg(int r, int v)
|
||||
ym2612.OPN.SL3.block_fnum[c] = (blk<<11) | fn;
|
||||
ym2612.CH[2].SLOT[SLOT1].Incr=-1;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 3: /* 0xac-0xae : 3CH FNUM2,BLK */
|
||||
if(r < 0x100)
|
||||
ym2612.OPN.SL3.fn_h = v&0x3f;
|
||||
@ -1756,7 +1756,7 @@ INLINE void OPNWriteReg(int r, int v)
|
||||
CH->ALGO = v&7;
|
||||
CH->FB = SIN_BITS - ((v>>3)&7);
|
||||
setup_connection( CH, c );
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case 1: /* 0xb4-0xb6 : L , R , AMS , PMS */
|
||||
/* b0-2 PMS */
|
||||
@ -1873,7 +1873,7 @@ static void init_tables(void)
|
||||
UINT32 offset_fnum_bit;
|
||||
UINT32 bit_tmp;
|
||||
|
||||
for (step=0; step<8; step++)
|
||||
for (step=0; step<8; step++)
|
||||
{
|
||||
value = 0;
|
||||
for (bit_tmp=0; bit_tmp<7; bit_tmp++) /* 7 bits */
|
||||
@ -1942,7 +1942,7 @@ void MDYM2612Reset(void)
|
||||
|
||||
ym2612.dacen = 0;
|
||||
ym2612.dacout = 0;
|
||||
|
||||
|
||||
set_timers(0x30);
|
||||
ym2612.OPN.ST.TB = 0;
|
||||
ym2612.OPN.ST.TBL = 256 << 4;
|
||||
@ -2044,7 +2044,7 @@ void MDYM2612Update(INT16 **buffer, int length)
|
||||
refresh_fc_eg_chan(&ym2612.CH[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
/* 3SLOT MODE (operator order is 0,1,3,2) */
|
||||
if(ym2612.CH[2].SLOT[SLOT1].Incr==-1)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ typedef struct tagIMAGE {
|
||||
#include "burner_win32.h"
|
||||
#elif defined (BUILD_MACOS)
|
||||
#include "burner_macos.h"
|
||||
#elif defined (BUILD_SDL)
|
||||
#elif defined (BUILD_SDL) || defined (BUILD_SDL2)
|
||||
#include "burner_sdl.h"
|
||||
#elif defined (_XBOX) && !defined(__LIBRETRO__)
|
||||
#include "burner_xbox.h"
|
||||
|
@ -6,16 +6,31 @@ const INT32 nConfigMinVersion = 0x020921;
|
||||
|
||||
bool bSaveInputs = true;
|
||||
|
||||
#ifdef BUILD_SDL2
|
||||
static char* szSDLconfigPath = NULL;
|
||||
#endif
|
||||
|
||||
static TCHAR* GameConfigName()
|
||||
{
|
||||
// Return the path of the config file for this game
|
||||
static TCHAR szName[64];
|
||||
if (NeoCDInfo_ID()) {
|
||||
_stprintf(szName, _T("config/games/ngcd_%s.ini"), NeoCDInfo_Text(DRV_NAME));
|
||||
} else {
|
||||
_stprintf(szName, _T("config/games/%s.ini"), BurnDrvGetText(DRV_NAME));
|
||||
}
|
||||
static TCHAR szName[MAX_PATH];
|
||||
|
||||
#if defined(BUILD_SDL2) && !defined(SDL_WINDOWS)
|
||||
if (szSDLconfigPath == NULL) {
|
||||
szSDLconfigPath = SDL_GetPrefPath("fbneo", "config");
|
||||
}
|
||||
if (NeoCDInfo_ID()) {
|
||||
snprintf(szName, MAX_PATH, "%sngcd_%s.ini", szSDLconfigPath, BurnDrvGetText(DRV_NAME));
|
||||
} else {
|
||||
snprintf(szName, MAX_PATH, "%s%s.ini", szSDLconfigPath, BurnDrvGetText(DRV_NAME));
|
||||
}
|
||||
#else
|
||||
// Return the path of the config file for this game
|
||||
if (NeoCDInfo_ID()) {
|
||||
_stprintf(szName, _T("config/games/ngcd_%s.ini"), NeoCDInfo_Text(DRV_NAME));
|
||||
} else {
|
||||
_stprintf(szName, _T("config/games/%s.ini"), BurnDrvGetText(DRV_NAME));
|
||||
}
|
||||
#endif
|
||||
return szName;
|
||||
}
|
||||
|
||||
@ -121,4 +136,3 @@ INT32 ConfigGameSave(bool bSave)
|
||||
fclose(h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,6 @@ INT32 write_datfile(INT32 bType, FILE* fDat)
|
||||
memset(szGameNameBuffer, 0, 255);
|
||||
memset(szManufacturer, 0, 255);
|
||||
memset(szManufacturerBuffer, 0, 255);
|
||||
|
||||
strcpy(szGameName, DecorateGameName(nBurnDrvActive));
|
||||
ReplaceAmpersand(szGameNameBuffer, szGameName);
|
||||
memset(szGameName, 0, 255);
|
||||
|
@ -356,7 +356,7 @@ static void GameInpInitMacros()
|
||||
pgi->nType = BIT_DIGITAL;
|
||||
pgi->Macro.nMode = 0;
|
||||
|
||||
sprintf(pgi->Macro.szName, "P%i 3× Punch", nPlayer + 1);
|
||||
sprintf(pgi->Macro.szName, "P%i 3x Punch", nPlayer + 1);
|
||||
for (INT32 j = 0; j < 3; j++) {
|
||||
BurnDrvGetInputInfo(&bii, nPunchInputs[nPlayer][j]);
|
||||
pgi->Macro.pVal[j] = bii.pVal;
|
||||
@ -372,7 +372,7 @@ static void GameInpInitMacros()
|
||||
pgi->nType = BIT_DIGITAL;
|
||||
pgi->Macro.nMode = 0;
|
||||
|
||||
sprintf(pgi->Macro.szName, "P%i 3× Kick", nPlayer + 1);
|
||||
sprintf(pgi->Macro.szName, "P%i 3x Kick", nPlayer + 1);
|
||||
for (INT32 j = 0; j < 3; j++) {
|
||||
BurnDrvGetInputInfo(&bii, nKickInputs[nPlayer][j]);
|
||||
pgi->Macro.pVal[j] = bii.pVal;
|
||||
@ -1828,4 +1828,3 @@ INT32 GameInpCustomRead(TCHAR* szVal, bool bOverWrite)
|
||||
{
|
||||
return AddCustomMacro(szVal, bOverWrite);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,8 @@ extern bool bRunPause;
|
||||
extern bool bAlwaysProcessKeyboardInput;
|
||||
TCHAR* ANSIToTCHAR(const char* pszInString, TCHAR* pszOutString, int nOutSize);
|
||||
char* TCHARToANSI(const TCHAR* pszInString, char* pszOutString, int nOutSize);
|
||||
#define _TtoA(a) TCHARToANSI(a, NULL, 0)
|
||||
#define _AtoT(a) ANSIToTCHAR(a, NULL, 0)
|
||||
bool AppProcessKeyboardInput();
|
||||
|
||||
// drv.cpp
|
||||
@ -39,6 +41,12 @@ int AppError(TCHAR* szText, int bWarning);
|
||||
|
||||
//run.cpp
|
||||
extern int RunReset();
|
||||
#define MESSAGE_MAX_FRAMES 180 // assuming 60fps this would be 3 seconds...
|
||||
#define MESSAGE_MAX_LENGTH 255
|
||||
|
||||
extern UINT32 messageFrames;
|
||||
extern char lastMessage[MESSAGE_MAX_LENGTH];
|
||||
void UpdateMessage(char* message);
|
||||
|
||||
// media.cpp
|
||||
int MediaInit();
|
||||
|
@ -8,6 +8,7 @@ extern int nEnableFreeplayHack;
|
||||
int nAppVirtualFps = 6000; // App fps * 100
|
||||
bool bRunPause = 0;
|
||||
bool bAlwaysProcessKeyboardInput=0;
|
||||
TCHAR szAppBurnVer[16];
|
||||
|
||||
void formatBinary(int number, int sizeBytes, char *dest, int len)
|
||||
{
|
||||
@ -159,6 +160,19 @@ int main(int argc, char *argv[])
|
||||
const char *romname = NULL;
|
||||
nEnableFreeplayHack = 0;
|
||||
|
||||
// Make version string
|
||||
if (nBurnVer & 0xFF)
|
||||
{
|
||||
// private version (alpha)
|
||||
_stprintf(szAppBurnVer, _T("%x.%x.%x.%02x"), nBurnVer >> 20, (nBurnVer >> 16) & 0x0F, (nBurnVer >> 8) & 0xFF, nBurnVer & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
// public version
|
||||
_stprintf(szAppBurnVer, _T("%x.%x.%x"), nBurnVer >> 20, (nBurnVer >> 16) & 0x0F, (nBurnVer >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (*argv[i] != '-') {
|
||||
romname = argv[i];
|
||||
|
@ -14,7 +14,7 @@ static unsigned int nNormalLast = 0; // Last value of timeGetTime()
|
||||
static int nNormalFrac = 0; // Extra fraction we did
|
||||
|
||||
static bool bAppDoStep = 0;
|
||||
static bool bAppDoFast = 0;
|
||||
bool bAppDoFast = 0;
|
||||
static int nFastSpeed = 6;
|
||||
|
||||
int SaveNVRAM();
|
||||
|
@ -1,19 +1,30 @@
|
||||
// Header for SDL 1.2 & SDL2
|
||||
#include <SDL.h>
|
||||
|
||||
#ifdef BUILD_SDL2
|
||||
#include "sdl2_gui.h"
|
||||
#include "sdl2_inprint.h"
|
||||
#endif
|
||||
|
||||
// defines to override various #ifndef _WIN32
|
||||
typedef struct tagRECT {
|
||||
#ifndef _WIN32
|
||||
typedef struct tagRECT
|
||||
{
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
} RECT,*PRECT,*LPRECT;
|
||||
typedef const RECT *LPCRECT;
|
||||
} RECT, * PRECT, * LPRECT;
|
||||
typedef const RECT* LPCRECT;
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
typedef unsigned long DWORD;
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned long DWORD;
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 511
|
||||
#define MAX_PATH 511
|
||||
#endif
|
||||
|
||||
#ifndef __cdecl
|
||||
@ -22,11 +33,26 @@ typedef unsigned char BYTE;
|
||||
|
||||
//main.cpp
|
||||
int SetBurnHighCol(int nDepth);
|
||||
extern int nAppVirtualFps;
|
||||
extern bool bRunPause;
|
||||
extern bool bAlwaysProcessKeyboardInput;
|
||||
|
||||
extern int nAppVirtualFps;
|
||||
extern bool bRunPause;
|
||||
extern bool bAppDoFast; // TODO: bad
|
||||
extern char fpsstring[20]; // TODO: also bad
|
||||
extern bool bAppShowFPS; // TODO: Also also bad
|
||||
extern bool bAlwaysProcessKeyboardInput;
|
||||
extern TCHAR szAppBurnVer[16];
|
||||
extern bool bAppFullscreen;
|
||||
extern bool bIntegerScale;
|
||||
|
||||
extern TCHAR* GetIsoPath();
|
||||
|
||||
TCHAR* ANSIToTCHAR(const char* pszInString, TCHAR* pszOutString, int nOutSize);
|
||||
char* TCHARToANSI(const TCHAR* pszInString, char* pszOutString, int nOutSize);
|
||||
|
||||
#define _TtoA(a) TCHARToANSI(a, NULL, 0)
|
||||
#define _AtoT(a) ANSIToTCHAR(a, NULL, 0)
|
||||
|
||||
|
||||
bool AppProcessKeyboardInput();
|
||||
|
||||
//config.cpp
|
||||
@ -34,7 +60,7 @@ int ConfigAppLoad();
|
||||
int ConfigAppSave();
|
||||
|
||||
// drv.cpp
|
||||
extern int bDrvOkay; // 1 if the Driver has been initted okay, and it's okay to use the BurnDrv functions
|
||||
extern int bDrvOkay; // 1 if the Driver has been initted okay, and it's okay to use the BurnDrv functions
|
||||
extern char szAppRomPaths[DIRS_MAX][MAX_PATH];
|
||||
int DrvInit(int nDrvNum, bool bRestore);
|
||||
int DrvInitCallback(); // Used when Burn library needs to load a game. DrvInit(nBurnSelect, false)
|
||||
@ -46,6 +72,15 @@ int AppError(TCHAR* szText, int bWarning);
|
||||
extern int RunMessageLoop();
|
||||
extern int RunReset();
|
||||
|
||||
#define MESSAGE_MAX_FRAMES 180 // assuming 60fps this would be 3 seconds...
|
||||
#define MESSAGE_MAX_LENGTH 255
|
||||
|
||||
extern UINT32 messageFrames;
|
||||
extern char lastMessage[MESSAGE_MAX_LENGTH];
|
||||
|
||||
void UpdateMessage(char* message);
|
||||
int StatedAuto(int bSave);
|
||||
|
||||
// media.cpp
|
||||
int MediaInit();
|
||||
int MediaExit();
|
||||
@ -58,17 +93,19 @@ int InputInit();
|
||||
int InputExit();
|
||||
int InputMake(bool bCopy);
|
||||
|
||||
//TODO:
|
||||
#define szAppBurnVer 1
|
||||
// stated.cpp
|
||||
int QuickState(int bSave);
|
||||
extern int bDrvSaveAll;
|
||||
|
||||
//stringset.cpp
|
||||
class StringSet {
|
||||
public:
|
||||
TCHAR* szText;
|
||||
int nLen;
|
||||
int nLen;
|
||||
// printf function to add text to the Bzip string
|
||||
int __cdecl Add(TCHAR* szFormat, ...);
|
||||
int Reset();
|
||||
|
||||
StringSet();
|
||||
~StringSet();
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,51 +1,78 @@
|
||||
// Burner Config file module
|
||||
#include "burner.h"
|
||||
|
||||
int nIniVersion = 0;
|
||||
|
||||
#ifdef BUILD_SDL2
|
||||
static char* szSDLconfigPath = NULL;
|
||||
#endif
|
||||
|
||||
static void CreateConfigName(char* szConfig)
|
||||
{
|
||||
memcpy(szConfig, "fbneo.ini", 12);
|
||||
#if defined(BUILD_SDL2) && !defined(SDL_WINDOWS)
|
||||
char cfgdir[MAX_PATH] = { 0 };
|
||||
|
||||
if (szSDLconfigPath == NULL)
|
||||
{
|
||||
szSDLconfigPath = SDL_GetPrefPath("fbneo", "config");
|
||||
}
|
||||
|
||||
snprintf(cfgdir, MAX_PATH, "%sfbneo.ini", szSDLconfigPath);
|
||||
memcpy(szConfig, cfgdir, sizeof(cfgdir));
|
||||
#else
|
||||
_stprintf(szConfig, _T("fbneo.ini"));
|
||||
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Read in the config file for the whole application
|
||||
int ConfigAppLoad()
|
||||
{
|
||||
char szConfig[MAX_PATH];
|
||||
FILE *f;
|
||||
char szConfig[MAX_PATH];
|
||||
FILE* f;
|
||||
|
||||
CreateConfigName(szConfig);
|
||||
|
||||
if ((f = fopen(szConfig,"rt")) == NULL) {
|
||||
if ((f = fopen(szConfig, "rt")) == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define VAR(x) { char *szValue = LabelCheck(szLine, #x); \
|
||||
if (szValue) x = strtol(szValue, NULL, 0); }
|
||||
#define FLT(x) { char *szValue = LabelCheck(szLine, #x); \
|
||||
if (szValue) x = atof(szValue); }
|
||||
#define STR(x) { char *szValue = LabelCheck(szLine, #x " "); \
|
||||
if (szValue) strcpy(x,szValue); }
|
||||
printf("Loading config from %s\n", szConfig);
|
||||
#define VAR(x) { char *szValue = LabelCheck(szLine, #x); \
|
||||
if (szValue) { x = strtol(szValue, NULL, 0); } }
|
||||
#define FLT(x) { char *szValue = LabelCheck(szLine, #x); \
|
||||
if (szValue) { x = atof(szValue); } }
|
||||
#define STR(x) { char *szValue = LabelCheck(szLine, #x " "); \
|
||||
if (szValue) { strcpy(x, szValue); } }
|
||||
|
||||
// Go through each line of the config file
|
||||
char szLine[256];
|
||||
while (fgets(szLine, sizeof(szLine), f)) {
|
||||
while (fgets(szLine, sizeof(szLine), f))
|
||||
{
|
||||
// Get rid of the linefeed at the end
|
||||
int nLen = strlen(szLine);
|
||||
if (szLine[nLen - 1] == 10) {
|
||||
if (szLine[nLen - 1] == 10)
|
||||
{
|
||||
szLine[nLen - 1] = 0;
|
||||
nLen--;
|
||||
}
|
||||
|
||||
VAR(nIniVersion);
|
||||
#ifndef BUILD_PI
|
||||
VAR(nVidSelect); // video mode select
|
||||
VAR(nVidSelect); // video mode select
|
||||
VAR(bVidFullStretch);
|
||||
VAR(nAutoFireRate);
|
||||
#endif
|
||||
VAR(bVidScanlines);
|
||||
VAR(bDoGamma);
|
||||
FLT(nGamma);
|
||||
VAR(nAudSampleRate[0]);
|
||||
|
||||
VAR(nAudDSPModule[0]);
|
||||
VAR(nInterpolation);
|
||||
VAR(nFMInterpolation);
|
||||
VAR(EnableHiscores);
|
||||
// Other
|
||||
STR(szAppRomPaths[0]);
|
||||
STR(szAppRomPaths[1]);
|
||||
@ -79,37 +106,50 @@ int ConfigAppLoad()
|
||||
// Write out the config file for the whole application
|
||||
int ConfigAppSave()
|
||||
{
|
||||
char szConfig[MAX_PATH];
|
||||
FILE *f;
|
||||
char szConfig[MAX_PATH];
|
||||
FILE* f;
|
||||
|
||||
CreateConfigName(szConfig);
|
||||
|
||||
if ((f = fopen(szConfig, "wt")) == NULL) {
|
||||
if ((f = fopen(szConfig, "wt")) == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#define VAR(x) fprintf(f, #x " %d\n", x)
|
||||
#define FLT(x) fprintf(f, #x " %f\n", x)
|
||||
#define STR(x) fprintf(f, #x " %s\n", x)
|
||||
#define VAR(x) fprintf(f, #x " %d\n", x)
|
||||
#define FLT(x) fprintf(f, #x " %f\n", x)
|
||||
#define STR(x) fprintf(f, #x " %s\n", x)
|
||||
|
||||
fprintf(f,"\n// The application version this file was saved from\n");
|
||||
fprintf(f, "\n// The application version this file was saved from\n");
|
||||
// We can't use the macros for this!
|
||||
fprintf(f, "nIniVersion 0x%06X", nBurnVer);
|
||||
|
||||
#ifndef BUILD_PI
|
||||
fprintf(f,"\n// video mode 0 = standard SDL 1= (very expiermental) opengl\n");
|
||||
VAR(nVidSelect); // video mode select
|
||||
fprintf(f,"\n// If non-zero, allow stretching of the image to any size\n");
|
||||
fprintf(f, "\n// video mode 0 = standard SDL 1= (very expiermental) opengl\n");
|
||||
VAR(nVidSelect); // video mode select
|
||||
fprintf(f, "\n// If non-zero, allow stretching of the image to any size\n");
|
||||
VAR(bVidFullStretch);
|
||||
fprintf(f,"\n// Auto-Fire Rate, non-linear - use the GUI to change this setting!\n");
|
||||
fprintf(f, "\n// Auto-Fire Rate, non-linear - use the GUI to change this setting!\n");
|
||||
VAR(nAutoFireRate);
|
||||
#endif
|
||||
fprintf(f,"\n// If non-zero, enable scanlines\n");
|
||||
fprintf(f, "\n// If non-zero, enable scanlines\n");
|
||||
VAR(bVidScanlines);
|
||||
fprintf(f, "\n// If non-zero, enable software gamma correction\n");
|
||||
VAR(bDoGamma);
|
||||
_ftprintf(f, _T("\n// Gamma to correct with\n"));
|
||||
FLT(nGamma);
|
||||
VAR(nAudSampleRate[0]);
|
||||
fprintf(f, "\n// If non-zero, enable DSP filter\n");
|
||||
VAR(nAudDSPModule[0]);
|
||||
_ftprintf(f, _T("\n// The order of PCM/ADPCM interpolation\n"));
|
||||
VAR(nInterpolation);
|
||||
_ftprintf(f, _T("\n// The order of FM interpolation\n"));
|
||||
VAR(nFMInterpolation);
|
||||
_ftprintf(f, _T("\n// If non-zero, enable high score saving support.\n"));
|
||||
VAR(EnableHiscores);
|
||||
|
||||
fprintf(f,"\n// The paths to search for rom zips. (include trailing backslash)\n");
|
||||
fprintf(f, "\n// The paths to search for rom zips. (include trailing backslash)\n");
|
||||
STR(szAppRomPaths[0]);
|
||||
STR(szAppRomPaths[1]);
|
||||
STR(szAppRomPaths[2]);
|
||||
@ -131,7 +171,7 @@ int ConfigAppSave()
|
||||
STR(szAppRomPaths[18]);
|
||||
STR(szAppRomPaths[19]);
|
||||
|
||||
fprintf(f,"\n\n\n");
|
||||
fprintf(f, "\n\n\n");
|
||||
|
||||
#undef STR
|
||||
#undef FLT
|
||||
|
@ -1,13 +1,33 @@
|
||||
// Driver Init module
|
||||
#include "burner.h"
|
||||
#include "neocdlist.h"
|
||||
int bDrvOkay = 0; // 1 if the Driver has been initted okay, and it's okay to use the BurnDrv functions
|
||||
|
||||
int bDrvOkay = 0; // 1 if the Driver has been initted okay, and it's okay to use the BurnDrv functions
|
||||
|
||||
char szAppRomPaths[DIRS_MAX][MAX_PATH] = {{"/usr/local/share/roms/"},{"roms/"}, };
|
||||
char szAppRomPaths[DIRS_MAX][MAX_PATH] = { { "/usr/local/share/roms/" }, { "roms/" }, };
|
||||
|
||||
static bool bSaveRAM = false;
|
||||
|
||||
static int DoLibInit() // Do Init of Burn library driver
|
||||
static INT32 nNeoCDZnAudSampleRateSave = 0;
|
||||
|
||||
void NeoCDZRateChangeback()
|
||||
{
|
||||
if (nNeoCDZnAudSampleRateSave != 0) {
|
||||
bprintf(PRINT_IMPORTANT, _T("Switching sound rate back to user-selected %dhz\n"), nNeoCDZnAudSampleRateSave);
|
||||
nAudSampleRate[nAudSelect] = nNeoCDZnAudSampleRateSave;
|
||||
nNeoCDZnAudSampleRateSave = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void NeoCDZRateChange()
|
||||
{
|
||||
if (nAudSampleRate[nAudSelect] != 44100) {
|
||||
nNeoCDZnAudSampleRateSave = nAudSampleRate[nAudSelect];
|
||||
bprintf(PRINT_IMPORTANT, _T("Switching sound rate to 44100hz (from %dhz) as required by NeoGeo CDZ\n"), nNeoCDZnAudSampleRateSave);
|
||||
nAudSampleRate[nAudSelect] = 44100; // force 44100hz for CDDA
|
||||
}
|
||||
}
|
||||
|
||||
static int DoLibInit() // Do Init of Burn library driver
|
||||
{
|
||||
int nRet;
|
||||
|
||||
@ -21,9 +41,12 @@ static int DoLibInit() // Do Init of Burn library driver
|
||||
|
||||
//ProgressDestroy();
|
||||
|
||||
if (nRet) {
|
||||
if (nRet)
|
||||
{
|
||||
return 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -36,8 +59,9 @@ static int DrvLoadRom(unsigned char* Dest, int* pnWrote, int i)
|
||||
|
||||
BzipOpen(false);
|
||||
|
||||
if ((nRet = BurnExtLoadRom(Dest, pnWrote, i)) != 0) {
|
||||
char szText[256] = "";
|
||||
if ((nRet = BurnExtLoadRom(Dest, pnWrote, i)) != 0)
|
||||
{
|
||||
char szText[256] = "";
|
||||
char* pszFilename;
|
||||
|
||||
BurnDrvGetRomName(&pszFilename, i, 0);
|
||||
@ -58,65 +82,85 @@ int DrvInit(int nDrvNum, bool bRestore)
|
||||
DrvExit(); // Make sure exitted
|
||||
MediaExit();
|
||||
|
||||
nBurnDrvSelect[0] = nDrvNum; // Set the driver number
|
||||
nBurnDrvActive = nDrvNum; // Set the driver number
|
||||
|
||||
MediaInit();
|
||||
|
||||
if ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_NEOCD) {
|
||||
if (CDEmuInit()) {
|
||||
printf("CD emu failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
NeoCDInfo_Init();
|
||||
|
||||
NeoCDZRateChange();
|
||||
}
|
||||
|
||||
{ // Init input and audio, save blitter init for later. (reduce # of mode changes, nice for emu front-ends)
|
||||
bVidOkay = 1;
|
||||
MediaInit();
|
||||
bVidOkay = 0;
|
||||
}
|
||||
|
||||
// Define nMaxPlayers early; GameInpInit() needs it (normally defined in DoLibInit()).
|
||||
nMaxPlayers = BurnDrvGetMaxPlayers();
|
||||
GameInpInit(); // Init game input
|
||||
GameInpInit(); // Init game input
|
||||
|
||||
ConfigGameLoad(true);
|
||||
InputMake(true);
|
||||
|
||||
GameInpDefault();
|
||||
|
||||
if (DoLibInit()) { // Init the Burn library's driver
|
||||
if (DoLibInit()) // Init the Burn library's driver
|
||||
{
|
||||
char szTemp[512];
|
||||
|
||||
BurnDrvExit(); // Exit the driver
|
||||
BurnDrvExit(); // Exit the driver
|
||||
|
||||
_stprintf (szTemp, _T("There was an error starting '%s'.\n"), BurnDrvGetText(DRV_FULLNAME));
|
||||
_stprintf(szTemp, _T("There was an error starting '%s'.\n"), BurnDrvGetText(DRV_FULLNAME));
|
||||
return 1;
|
||||
}
|
||||
|
||||
BurnExtLoadRom = DrvLoadRom;
|
||||
|
||||
bDrvOkay = 1; // Okay to use all BurnDrv functions
|
||||
bDrvOkay = 1; // Okay to use all BurnDrv functions
|
||||
|
||||
bSaveRAM = false;
|
||||
nBurnLayer = 0xFF; // show all layers
|
||||
nBurnLayer = 0xFF; // show all layers
|
||||
|
||||
// Reset the speed throttling code, so we don't 'jump' after the load
|
||||
RunReset();
|
||||
VidExit();
|
||||
AudSoundExit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DrvInitCallback()
|
||||
{
|
||||
return DrvInit(nBurnDrvSelect[0], false);
|
||||
return DrvInit(nBurnDrvActive, false);
|
||||
}
|
||||
|
||||
int DrvExit()
|
||||
{
|
||||
if (bDrvOkay) {
|
||||
if (nBurnDrvSelect[0] < nBurnDrvCount) {
|
||||
if (bSaveRAM) {
|
||||
|
||||
if (bDrvOkay)
|
||||
{
|
||||
if (nBurnDrvActive < nBurnDrvCount)
|
||||
{
|
||||
if (bSaveRAM)
|
||||
{
|
||||
bSaveRAM = false;
|
||||
}
|
||||
|
||||
ConfigGameSave(bSaveInputs);
|
||||
|
||||
GameInpExit(); // Exit game input
|
||||
BurnDrvExit(); // Exit the driver
|
||||
GameInpExit(); // Exit game input
|
||||
BurnDrvExit(); // Exit the driver
|
||||
}
|
||||
}
|
||||
|
||||
BurnExtLoadRom = NULL;
|
||||
|
||||
bDrvOkay = 0; // Stop using the BurnDrv functions
|
||||
nBurnDrvSelect[0] = ~0U; // no driver selected
|
||||
bDrvOkay = 0; // Stop using the BurnDrv functions
|
||||
// nBurnDrvActive = ~0U; // no driver selected
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,144 +1,160 @@
|
||||
// Burner DipSwitches Dialog module
|
||||
#include "burner.h"
|
||||
|
||||
static unsigned char nPrevDIPSettings[4];
|
||||
|
||||
static int nDIPOffset;
|
||||
|
||||
static bool bOK;
|
||||
|
||||
static void InpDIPSWGetOffset()
|
||||
{
|
||||
BurnDIPInfo bdi;
|
||||
|
||||
nDIPOffset = 0;
|
||||
for (int i = 0; BurnDrvGetDIPInfo(&bdi, i) == 0; i++) {
|
||||
if (bdi.nFlags == 0xF0) {
|
||||
nDIPOffset = bdi.nInput;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InpDIPSWResetDIPs()
|
||||
{
|
||||
int i = 0;
|
||||
BurnDIPInfo bdi;
|
||||
struct GameInp* pgi;
|
||||
|
||||
InpDIPSWGetOffset();
|
||||
|
||||
while (BurnDrvGetDIPInfo(&bdi, i) == 0) {
|
||||
if (bdi.nFlags == 0xFF) {
|
||||
pgi = GameInp + bdi.nInput + nDIPOffset;
|
||||
pgi->Input.Constant.nConst = (pgi->Input.Constant.nConst & ~bdi.nMask) | (bdi.nSetting & bdi.nMask);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static int InpDIPSWListBegin()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool CheckSetting(int i)
|
||||
{
|
||||
BurnDIPInfo bdi;
|
||||
BurnDrvGetDIPInfo(&bdi, i);
|
||||
struct GameInp* pgi = GameInp + bdi.nInput + nDIPOffset;
|
||||
|
||||
if ((pgi->Input.Constant.nConst & bdi.nMask) == bdi.nSetting) {
|
||||
unsigned char nFlags = bdi.nFlags;
|
||||
if ((nFlags & 0x0F) <= 1) {
|
||||
return true;
|
||||
} else {
|
||||
for (int j = 1; j < (nFlags & 0x0F); j++) {
|
||||
BurnDrvGetDIPInfo(&bdi, i + j);
|
||||
pgi = GameInp + bdi.nInput + nDIPOffset;
|
||||
if (nFlags & 0x80) {
|
||||
if ((pgi->Input.Constant.nConst & bdi.nMask) == bdi.nSetting) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ((pgi->Input.Constant.nConst & bdi.nMask) != bdi.nSetting) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make a list view of the DIPswitches
|
||||
static int InpDIPSWListMake()
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int InpDIPSWInit()
|
||||
{
|
||||
BurnDIPInfo bdi;
|
||||
struct GameInp *pgi;
|
||||
|
||||
InpDIPSWGetOffset();
|
||||
|
||||
InpDIPSWListBegin();
|
||||
InpDIPSWListMake();
|
||||
|
||||
for (int i = 0, j = 0; BurnDrvGetDIPInfo(&bdi, i) == 0; i++) {
|
||||
if (bdi.nInput >= 0 && bdi.nFlags == 0xFF) {
|
||||
pgi = GameInp + bdi.nInput + nDIPOffset;
|
||||
nPrevDIPSettings[j] = pgi->Input.Constant.nConst;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int InpDIPSWExit()
|
||||
{
|
||||
GameInpCheckMouse();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void InpDIPSWCancel()
|
||||
{
|
||||
if (!bOK) {
|
||||
int i = 0, j = 0;
|
||||
BurnDIPInfo bdi;
|
||||
struct GameInp *pgi;
|
||||
while (BurnDrvGetDIPInfo(&bdi, i) == 0) {
|
||||
if (bdi.nInput >= 0 && bdi.nFlags == 0xFF) {
|
||||
pgi = GameInp + bdi.nInput + nDIPOffset;
|
||||
pgi->Input.Constant.nConst = nPrevDIPSettings[j];
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the list of possible values for a DIPswitch
|
||||
static void InpDIPSWSelect()
|
||||
{
|
||||
}
|
||||
|
||||
int InpDIPSWCreate()
|
||||
{
|
||||
if (bDrvOkay == 0) { // No game is loaded
|
||||
return 1;
|
||||
}
|
||||
|
||||
bOK = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
// Burner DipSwitches Dialog module
|
||||
#include "burner.h"
|
||||
|
||||
static unsigned char nPrevDIPSettings[4];
|
||||
|
||||
static int nDIPOffset;
|
||||
|
||||
static bool bOK;
|
||||
|
||||
static void InpDIPSWGetOffset()
|
||||
{
|
||||
BurnDIPInfo bdi;
|
||||
|
||||
nDIPOffset = 0;
|
||||
for (int i = 0; BurnDrvGetDIPInfo(&bdi, i) == 0; i++)
|
||||
{
|
||||
if (bdi.nFlags == 0xF0)
|
||||
{
|
||||
nDIPOffset = bdi.nInput;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InpDIPSWResetDIPs()
|
||||
{
|
||||
int i = 0;
|
||||
BurnDIPInfo bdi;
|
||||
struct GameInp* pgi;
|
||||
|
||||
InpDIPSWGetOffset();
|
||||
|
||||
while (BurnDrvGetDIPInfo(&bdi, i) == 0)
|
||||
{
|
||||
if (bdi.nFlags == 0xFF)
|
||||
{
|
||||
pgi = GameInp + bdi.nInput + nDIPOffset;
|
||||
pgi->Input.Constant.nConst = (pgi->Input.Constant.nConst & ~bdi.nMask) | (bdi.nSetting & bdi.nMask);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static int InpDIPSWListBegin()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool CheckSetting(int i)
|
||||
{
|
||||
BurnDIPInfo bdi;
|
||||
|
||||
BurnDrvGetDIPInfo(&bdi, i);
|
||||
struct GameInp* pgi = GameInp + bdi.nInput + nDIPOffset;
|
||||
|
||||
if ((pgi->Input.Constant.nConst & bdi.nMask) == bdi.nSetting)
|
||||
{
|
||||
unsigned char nFlags = bdi.nFlags;
|
||||
if ((nFlags & 0x0F) <= 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 1; j < (nFlags & 0x0F); j++)
|
||||
{
|
||||
BurnDrvGetDIPInfo(&bdi, i + j);
|
||||
pgi = GameInp + bdi.nInput + nDIPOffset;
|
||||
if (nFlags & 0x80)
|
||||
{
|
||||
if ((pgi->Input.Constant.nConst & bdi.nMask) == bdi.nSetting)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((pgi->Input.Constant.nConst & bdi.nMask) != bdi.nSetting)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make a list view of the DIPswitches
|
||||
static int InpDIPSWListMake()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int InpDIPSWInit()
|
||||
{
|
||||
BurnDIPInfo bdi;
|
||||
struct GameInp* pgi;
|
||||
|
||||
InpDIPSWGetOffset();
|
||||
|
||||
InpDIPSWListBegin();
|
||||
InpDIPSWListMake();
|
||||
|
||||
for (int i = 0, j = 0; BurnDrvGetDIPInfo(&bdi, i) == 0; i++)
|
||||
{
|
||||
if (bdi.nInput >= 0 && bdi.nFlags == 0xFF)
|
||||
{
|
||||
pgi = GameInp + bdi.nInput + nDIPOffset;
|
||||
nPrevDIPSettings[j] = pgi->Input.Constant.nConst;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int InpDIPSWExit()
|
||||
{
|
||||
GameInpCheckMouse();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void InpDIPSWCancel()
|
||||
{
|
||||
if (!bOK)
|
||||
{
|
||||
int i = 0, j = 0;
|
||||
BurnDIPInfo bdi;
|
||||
struct GameInp* pgi;
|
||||
while (BurnDrvGetDIPInfo(&bdi, i) == 0)
|
||||
{
|
||||
if (bdi.nInput >= 0 && bdi.nFlags == 0xFF)
|
||||
{
|
||||
pgi = GameInp + bdi.nInput + nDIPOffset;
|
||||
pgi->Input.Constant.nConst = nPrevDIPSettings[j];
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the list of possible values for a DIPswitch
|
||||
static void InpDIPSWSelect()
|
||||
{
|
||||
}
|
||||
|
||||
int InpDIPSWCreate()
|
||||
{
|
||||
if (bDrvOkay == 0) // No game is loaded
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bOK = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
262
src/burner/sdl/input.cpp
Normal file
262
src/burner/sdl/input.cpp
Normal file
@ -0,0 +1,262 @@
|
||||
#include "burner.h"
|
||||
|
||||
/* todo implement barcade joystick(arcade panel support) and ipac keyboad device mapping
|
||||
*/
|
||||
|
||||
|
||||
//static int GameInpConfig(int nPlayer, int nPcDev, int nAnalog);
|
||||
static void GameInpConfigOne(int nPlayer, int nPcDev, int nAnalog, struct GameInp* pgi, char* szi);
|
||||
//INT32 display_set_controls();
|
||||
INT32 Mapcoins(struct GameInp* pgi, char* szi, INT32 nPlayer, INT32 nDevice);
|
||||
|
||||
#define KEY(x) { pgi->nInput = GIT_SWITCH; pgi->Input.Switch.nCode = (UINT16)(x); }
|
||||
|
||||
int usebarcade = 0;
|
||||
|
||||
static unsigned int capcom6Layout[] = {
|
||||
2, 3, 4, 0, 1, 5,
|
||||
};
|
||||
|
||||
|
||||
/* keep the snes layout on xbox360 controller
|
||||
Phscial button layout on the encoder should be
|
||||
X Y L
|
||||
2 3 4
|
||||
0 1 5
|
||||
A B R
|
||||
no need to change this for sf2 as use the capcom6Layout when for it when its needed its the same as that with the rows reversed
|
||||
*/
|
||||
|
||||
static unsigned int barcade_Layout[] = {
|
||||
|
||||
0, 1, 5, 2, 3, 4,
|
||||
|
||||
};
|
||||
|
||||
|
||||
static bool usesStreetFighterLayout()
|
||||
{
|
||||
int fireButtons = 0;
|
||||
bool Volume = false;
|
||||
struct BurnInputInfo bii;
|
||||
|
||||
for (UINT32 i = 0; i < 0x1000; i++) {
|
||||
bii.szName = NULL;
|
||||
if (BurnDrvGetInputInfo(&bii, i)) {
|
||||
break;
|
||||
}
|
||||
|
||||
BurnDrvGetInputInfo(&bii, i);
|
||||
if (bii.szName == NULL) {
|
||||
bii.szName = "";
|
||||
}
|
||||
|
||||
bool bPlayerInInfo = (toupper(bii.szInfo[0]) == 'P' && bii.szInfo[1] >= '1' && bii.szInfo[1] <= '4'); // Because some of the older drivers don't use the standard input naming.
|
||||
bool bPlayerInName = (bii.szName[0] == 'P' && bii.szName[1] >= '1' && bii.szName[1] <= '4');
|
||||
|
||||
if (bPlayerInInfo || bPlayerInName) {
|
||||
INT32 nPlayer = 0;
|
||||
|
||||
if (bPlayerInName) {
|
||||
nPlayer = bii.szName[1] - '1';
|
||||
}
|
||||
if (bPlayerInInfo && nPlayer == 0) {
|
||||
nPlayer = bii.szInfo[1] - '1';
|
||||
}
|
||||
if (nPlayer == 0) {
|
||||
if (strncmp(" fire", bii.szInfo + 2, 5) == 0) {
|
||||
fireButtons++;
|
||||
}
|
||||
}
|
||||
if ((strncmp("Volume", bii.szName, 6) == 0) && (strncmp(" fire", bii.szInfo + 2, 5) == 0)) {
|
||||
Volume = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nFireButtons >= 5 && (BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_CAPCOM_CPS2 && !Volume) {
|
||||
bStreetFighterLayout = true;
|
||||
printf("Using SF2 Layout\n");
|
||||
}
|
||||
return bStreetFighterLayout;
|
||||
}
|
||||
|
||||
static int GameInpConfig(int nPlayer, int nPcDev, int nAnalog) {
|
||||
struct GameInp* pgi = NULL;
|
||||
unsigned int i;
|
||||
for (i = 0, pgi = GameInp; i < nGameInpCount; i++, pgi++) {
|
||||
struct BurnInputInfo bii;
|
||||
// Get the extra info about the input
|
||||
bii.szInfo = NULL;
|
||||
BurnDrvGetInputInfo(&bii, i);
|
||||
if (bii.pVal == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (bii.szInfo == NULL) {
|
||||
bii.szInfo = "";
|
||||
}
|
||||
GameInpConfigOne(nPlayer, nPcDev, nAnalog, pgi, bii.szInfo);
|
||||
}
|
||||
for (i = 0; i < nMacroCount; i++, pgi++) {
|
||||
GameInpConfigOne(nPlayer, nPcDev, nAnalog, pgi, pgi->Macro.szName);
|
||||
}
|
||||
GameInpCheckLeftAlt();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void GameInpConfigOne(int nPlayer, int nPcDev, int nAnalog, struct GameInp* pgi, char* szi) {
|
||||
switch (nPcDev) {
|
||||
case 0:
|
||||
GamcPlayer(pgi, szi, nPlayer, -1); // Keyboard
|
||||
GamcAnalogKey(pgi, szi, nPlayer, nAnalog);
|
||||
GamcMisc(pgi, szi, nPlayer);
|
||||
Mapcoins(pgi, szi, nPlayer, nPcDev);
|
||||
break;
|
||||
case 1:
|
||||
GamcPlayer(pgi, szi, nPlayer, 0); // Joystick 1
|
||||
GamcAnalogJoy(pgi, szi, nPlayer, 0, nAnalog);
|
||||
GamcMisc(pgi, szi, nPlayer);
|
||||
Mapcoins(pgi, szi, nPlayer, nPcDev);
|
||||
break;
|
||||
case 2:
|
||||
GamcPlayer(pgi, szi, nPlayer, 1); // Joystick 2
|
||||
GamcAnalogJoy(pgi, szi, nPlayer, 1, nAnalog);
|
||||
GamcMisc(pgi, szi, nPlayer);
|
||||
Mapcoins(pgi, szi, nPlayer, nPcDev);
|
||||
|
||||
break;
|
||||
case 3:
|
||||
GamcPlayer(pgi, szi, nPlayer, 2); // Joystick 3
|
||||
GamcAnalogJoy(pgi, szi, nPlayer, 2, nAnalog);
|
||||
GamcMisc(pgi, szi, nPlayer);
|
||||
break;
|
||||
case 4:
|
||||
GamcPlayerHotRod(pgi, szi, nPlayer, 0x10, nAnalog); // X-Arcade left side
|
||||
GamcMisc(pgi, szi, -1);
|
||||
break;
|
||||
case 5:
|
||||
GamcPlayerHotRod(pgi, szi, nPlayer, 0x11, nAnalog); // X-Arcade right side
|
||||
GamcMisc(pgi, szi, -1);
|
||||
break;
|
||||
case 6:
|
||||
GamcPlayerHotRod(pgi, szi, nPlayer, 0x00, nAnalog); // HotRod left side
|
||||
GamcMisc(pgi, szi, -1);
|
||||
break;
|
||||
case 7:
|
||||
GamcPlayerHotRod(pgi, szi, nPlayer, 0x01, nAnalog); // HotRod right size
|
||||
GamcMisc(pgi, szi, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
INT32 Mapcoins(struct GameInp* pgi, char* szi, INT32 nPlayer, INT32 nDevice)
|
||||
{
|
||||
INT32 nJoyBase = 0;
|
||||
if (nDevice == 0) return 0; // using keyboard for this player
|
||||
nDevice--;
|
||||
nJoyBase = 0x4000;
|
||||
nJoyBase |= nDevice << 8;
|
||||
bStreetFighterLayout = usesStreetFighterLayout();
|
||||
switch (nPlayer)
|
||||
{
|
||||
case 0:
|
||||
/* dont map coins and start until mapping joysicks is implemented
|
||||
if (strcmp(szi, "p1 coin" ) == 0 && nPlayer == 0 )
|
||||
{
|
||||
KEY(nJoyBase + 0x80 + 8);
|
||||
return 0;
|
||||
|
||||
}
|
||||
if (strcmp(szi, "p1 start") == 0 && nPlayer == 0 )
|
||||
{
|
||||
KEY(nJoyBase + 0x80 + 9);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
if (strncmp(szi, "p1 fire ", 7) == 0)
|
||||
{
|
||||
char* szb = szi + 7;
|
||||
INT32 nButton = strtol(szb, NULL, 0);
|
||||
if (nButton >= 1)
|
||||
{
|
||||
nButton--;
|
||||
}
|
||||
if (bStreetFighterLayout) KEY(nJoyBase + 0x80 + capcom6Layout[nButton]);
|
||||
if (!bStreetFighterLayout && usebarcade) KEY(nJoyBase + 0x80 + barcade_Layout[nButton])
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* dont map coins and start until mapping joysicks is implemented
|
||||
if (strcmp(szi, "p2 coin" ) == 0 && nPlayer == 1 )
|
||||
{
|
||||
KEY(nJoyBase + 0x80 + 8);
|
||||
return 0;
|
||||
|
||||
}
|
||||
if (strcmp(szi, "p2 start") == 0 && nPlayer == 1 )
|
||||
{
|
||||
KEY(nJoyBase + 0x80 + 9);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
if (strncmp(szi, "p2 fire ", 7) == 0 && bStreetFighterLayout)
|
||||
{
|
||||
char* szb = szi + 7;
|
||||
INT32 nButton = strtol(szb, NULL, 0);
|
||||
if (nButton >= 1)
|
||||
{
|
||||
nButton--;
|
||||
}
|
||||
if (bStreetFighterLayout) KEY(nJoyBase + 0x80 + capcom6Layout[nButton]);
|
||||
if (!bStreetFighterLayout && usebarcade) KEY(nJoyBase + 0x80 + barcade_Layout[nButton])
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
INT32 display_set_controls()
|
||||
{
|
||||
struct GameInp* pgi = NULL;
|
||||
unsigned int i;
|
||||
for (i = 0, pgi = GameInp; i < nGameInpCount; i++, pgi++) {
|
||||
struct BurnInputInfo bii;
|
||||
// Get the extra info about the input
|
||||
bii.szInfo = NULL;
|
||||
BurnDrvGetInputInfo(&bii, i);
|
||||
if (bii.pVal == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (bii.szInfo == NULL) {
|
||||
bii.szInfo = "";
|
||||
}
|
||||
printf("%s %s\n", bii.szInfo, InputCodeDesc(pgi->Input.Switch.nCode));
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
INT32 Init_Joysticks(int p_one_use_joystick)
|
||||
{
|
||||
if (!p_one_use_joystick)
|
||||
{
|
||||
/*keyboard p1, joy0 p2) */
|
||||
GameInpConfig(0, 0, 1);
|
||||
GameInpConfig(1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* p1 joy0 , p2 joy1 */
|
||||
GameInpConfig(0, 1, 1);
|
||||
GameInpConfig(1, 2, 1);
|
||||
}
|
||||
display_set_controls();
|
||||
return 0;
|
||||
};
|
320
src/burner/sdl/input_sdl2.cpp
Normal file
320
src/burner/sdl/input_sdl2.cpp
Normal file
@ -0,0 +1,320 @@
|
||||
#include "burner.h"
|
||||
|
||||
/* todo implement barcade joystick(arcade panel support) and ipac keyboad device mapping
|
||||
*/
|
||||
|
||||
|
||||
//static int GameInpConfig(int nPlayer, int nPcDev, int nAnalog);
|
||||
static void GameInpConfigOne(int nPlayer, int nPcDev, int nAnalog, struct GameInp* pgi, char* szi);
|
||||
//INT32 display_set_controls();
|
||||
INT32 MapJoystick(struct GameInp* pgi, char* szi, INT32 nPlayer, INT32 nDevice);
|
||||
extern int buttons [4][8];
|
||||
|
||||
#define KEY(x) { pgi->nInput = GIT_SWITCH; pgi->Input.Switch.nCode = (UINT16)(x); }
|
||||
|
||||
|
||||
static bool usesStreetFighterLayout()
|
||||
{
|
||||
int fireButtons = 0;
|
||||
bool Volume = false;
|
||||
struct BurnInputInfo bii;
|
||||
|
||||
for (UINT32 i = 0; i < 0x1000; i++) {
|
||||
bii.szName = NULL;
|
||||
if (BurnDrvGetInputInfo(&bii, i)) {
|
||||
break;
|
||||
}
|
||||
|
||||
BurnDrvGetInputInfo(&bii, i);
|
||||
if (bii.szName == NULL) {
|
||||
bii.szName = "";
|
||||
}
|
||||
|
||||
bool bPlayerInInfo = (toupper(bii.szInfo[0]) == 'P' && bii.szInfo[1] >= '1' && bii.szInfo[1] <= '4'); // Because some of the older drivers don't use the standard input naming.
|
||||
bool bPlayerInName = (bii.szName[0] == 'P' && bii.szName[1] >= '1' && bii.szName[1] <= '4');
|
||||
|
||||
if (bPlayerInInfo || bPlayerInName) {
|
||||
INT32 nPlayer = 0;
|
||||
|
||||
if (bPlayerInName) {
|
||||
nPlayer = bii.szName[1] - '1';
|
||||
}
|
||||
if (bPlayerInInfo && nPlayer == 0) {
|
||||
nPlayer = bii.szInfo[1] - '1';
|
||||
}
|
||||
if (nPlayer == 0) {
|
||||
if (strncmp(" fire", bii.szInfo + 2, 5) == 0) {
|
||||
fireButtons++;
|
||||
}
|
||||
}
|
||||
if ((strncmp("Volume", bii.szName, 6) == 0) && (strncmp(" fire", bii.szInfo + 2, 5) == 0)) {
|
||||
Volume = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nFireButtons >= 5 && (BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_CAPCOM_CPS2 && !Volume) {
|
||||
bStreetFighterLayout = true;
|
||||
printf("Using SF2 Layout\n");
|
||||
}
|
||||
return bStreetFighterLayout;
|
||||
}
|
||||
|
||||
static int GameInpConfig(int nPlayer, int nPcDev, int nAnalog) {
|
||||
struct GameInp* pgi = NULL;
|
||||
unsigned int i;
|
||||
for (i = 0, pgi = GameInp; i < nGameInpCount; i++, pgi++) {
|
||||
struct BurnInputInfo bii;
|
||||
// Get the extra info about the input
|
||||
bii.szInfo = NULL;
|
||||
BurnDrvGetInputInfo(&bii, i);
|
||||
if (bii.pVal == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (bii.szInfo == NULL) {
|
||||
bii.szInfo = "";
|
||||
}
|
||||
GameInpConfigOne(nPlayer, nPcDev, nAnalog, pgi, bii.szInfo);
|
||||
}
|
||||
for (i = 0; i < nMacroCount; i++, pgi++) {
|
||||
GameInpConfigOne(nPlayer, nPcDev, nAnalog, pgi, pgi->Macro.szName);
|
||||
}
|
||||
GameInpCheckLeftAlt();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void GameInpConfigOne(int nPlayer, int nPcDev, int nAnalog, struct GameInp* pgi, char* szi) {
|
||||
switch (nPcDev) {
|
||||
case 0:
|
||||
GamcPlayer(pgi, szi, nPlayer, -1); // Keyboard
|
||||
GamcAnalogKey(pgi, szi, nPlayer, nAnalog);
|
||||
GamcMisc(pgi, szi, nPlayer);
|
||||
MapJoystick(pgi, szi, nPlayer, nPcDev);
|
||||
break;
|
||||
case 1:
|
||||
GamcPlayer(pgi, szi, nPlayer, 0); // Joystick 1
|
||||
GamcAnalogJoy(pgi, szi, nPlayer, 0, nAnalog);
|
||||
GamcMisc(pgi, szi, nPlayer);
|
||||
MapJoystick(pgi, szi, nPlayer, nPcDev);
|
||||
break;
|
||||
case 2:
|
||||
GamcPlayer(pgi, szi, nPlayer, 1); // Joystick 2
|
||||
GamcAnalogJoy(pgi, szi, nPlayer, 1, nAnalog);
|
||||
GamcMisc(pgi, szi, nPlayer);
|
||||
MapJoystick(pgi, szi, nPlayer, nPcDev);
|
||||
|
||||
break;
|
||||
case 3:
|
||||
GamcPlayer(pgi, szi, nPlayer, 2); // Joystick 3
|
||||
GamcAnalogJoy(pgi, szi, nPlayer, 2, nAnalog);
|
||||
GamcMisc(pgi, szi, nPlayer);
|
||||
break;
|
||||
case 4:
|
||||
GamcPlayerHotRod(pgi, szi, nPlayer, 0x10, nAnalog); // X-Arcade left side
|
||||
GamcMisc(pgi, szi, -1);
|
||||
break;
|
||||
case 5:
|
||||
GamcPlayerHotRod(pgi, szi, nPlayer, 0x11, nAnalog); // X-Arcade right side
|
||||
GamcMisc(pgi, szi, -1);
|
||||
break;
|
||||
case 6:
|
||||
GamcPlayerHotRod(pgi, szi, nPlayer, 0x00, nAnalog); // HotRod left side
|
||||
GamcMisc(pgi, szi, -1);
|
||||
break;
|
||||
case 7:
|
||||
GamcPlayerHotRod(pgi, szi, nPlayer, 0x01, nAnalog); // HotRod right size
|
||||
GamcMisc(pgi, szi, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
INT32 MapJoystick(struct GameInp* pgi, char* szi, INT32 nPlayer, INT32 nDevice)
|
||||
{
|
||||
INT32 nJoyBase = 0;
|
||||
if (nDevice == 0) return 0; // using keyboard for this player
|
||||
nDevice--;
|
||||
nJoyBase = 0x4000;
|
||||
nJoyBase |= nDevice << 8;
|
||||
bStreetFighterLayout = usesStreetFighterLayout();
|
||||
switch (nPlayer)
|
||||
{
|
||||
case 0:
|
||||
if (strcmp(szi, "p1 coin" ) == 0 )
|
||||
{
|
||||
if ( buttons[nDevice][6] != -1) KEY(nJoyBase + 0x80 + buttons[nDevice][6]);
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(szi, "p1 start") == 0 )
|
||||
{
|
||||
if ( buttons[nDevice][7] != -1) KEY(nJoyBase + 0x80 + buttons[nDevice][7]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strncmp(szi, "p1 fire ", 7) == 0)
|
||||
{
|
||||
char* szb = szi + 7;
|
||||
INT32 nButton = strtol(szb, NULL, 0);
|
||||
if (nButton >= 1)
|
||||
{
|
||||
nButton--;
|
||||
}
|
||||
if (buttons[nDevice][nButton] != -1 && !bStreetFighterLayout) { KEY(nJoyBase + 0x80 + buttons[nDevice][nButton]); }
|
||||
else if (buttons[nDevice][nButton] != -1 && bStreetFighterLayout)
|
||||
{
|
||||
if (nButton == 0) KEY(nJoyBase + 0x80 + buttons[nDevice][2]);
|
||||
if (nButton == 1) KEY(nJoyBase + 0x80 + buttons[nDevice][3]);
|
||||
if (nButton == 2) KEY(nJoyBase + 0x80 + buttons[nDevice][4]);
|
||||
if (nButton == 3) KEY(nJoyBase + 0x80 + buttons[nDevice][0]);
|
||||
if (nButton == 4) KEY(nJoyBase + 0x80 + buttons[nDevice][1]);
|
||||
if (nButton == 5) KEY(nJoyBase + 0x80 + buttons[nDevice][5]);
|
||||
}
|
||||
else KEY(nJoyBase + 0x80 + nButton); // joystick not mapped or isint plugged use fba default settings
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (strcmp(szi, "p2 coin" ) == 0 )
|
||||
{
|
||||
if ( buttons[nDevice][6] != -1) KEY(nJoyBase + 0x80 + buttons[nDevice][6]);
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(szi, "p2 start") == 0 )
|
||||
{
|
||||
if ( buttons[nDevice][7] != -1) KEY(nJoyBase + 0x80 + buttons[nDevice][7]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strncmp(szi, "p2 fire ", 7) == 0)
|
||||
{
|
||||
char* szb = szi + 7;
|
||||
INT32 nButton = strtol(szb, NULL, 0);
|
||||
if (nButton >= 1)
|
||||
{
|
||||
nButton--;
|
||||
}
|
||||
if (buttons[nDevice][nButton] != -1 && !bStreetFighterLayout) { KEY(nJoyBase + 0x80 + buttons[nDevice][nButton]); }
|
||||
else if (buttons[nDevice][nButton] != -1 && bStreetFighterLayout)
|
||||
{
|
||||
if (nButton == 0) KEY(nJoyBase + 0x80 + buttons[nDevice][2]);
|
||||
if (nButton == 1) KEY(nJoyBase + 0x80 + buttons[nDevice][3]);
|
||||
if (nButton == 2) KEY(nJoyBase + 0x80 + buttons[nDevice][4]);
|
||||
if (nButton == 3) KEY(nJoyBase + 0x80 + buttons[nDevice][0]);
|
||||
if (nButton == 4) KEY(nJoyBase + 0x80 + buttons[nDevice][1]);
|
||||
if (nButton == 5) KEY(nJoyBase + 0x80 + buttons[nDevice][5]);
|
||||
}
|
||||
else KEY(nJoyBase + 0x80 + nButton); // joystick not mapped or isint plugged use fba default settings
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (strcmp(szi, "p3 coin" ) == 0 )
|
||||
{
|
||||
if ( buttons[nDevice][6] != -1) KEY(nJoyBase + 0x80 + buttons[nDevice][6]);
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(szi, "p3 start") == 0 )
|
||||
{
|
||||
if ( buttons[nDevice][7] != -1) KEY(nJoyBase + 0x80 + buttons[nDevice][7]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strncmp(szi, "p3 fire ", 7) == 0)
|
||||
{
|
||||
char* szb = szi + 7;
|
||||
INT32 nButton = strtol(szb, NULL, 0);
|
||||
if (nButton >= 1)
|
||||
{
|
||||
nButton--;
|
||||
}
|
||||
if (buttons[nDevice][nButton] != -1 && !bStreetFighterLayout) { KEY(nJoyBase + 0x80 + buttons[nDevice][nButton]); }
|
||||
else if (buttons[nDevice][nButton] != -1 && bStreetFighterLayout)
|
||||
{
|
||||
if (nButton == 0) KEY(nJoyBase + 0x80 + buttons[nDevice][2]);
|
||||
if (nButton == 1) KEY(nJoyBase + 0x80 + buttons[nDevice][3]);
|
||||
if (nButton == 2) KEY(nJoyBase + 0x80 + buttons[nDevice][4]);
|
||||
if (nButton == 3) KEY(nJoyBase + 0x80 + buttons[nDevice][0]);
|
||||
if (nButton == 4) KEY(nJoyBase + 0x80 + buttons[nDevice][1]);
|
||||
if (nButton == 5) KEY(nJoyBase + 0x80 + buttons[nDevice][5]);
|
||||
}
|
||||
else KEY(nJoyBase + 0x80 + nButton); // joystick not mapped or isint plugged use fba default settings
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (strcmp(szi, "p4 coin" ) == 0 )
|
||||
{
|
||||
if ( buttons[nDevice][6] != -1) KEY(nJoyBase + 0x80 + buttons[nDevice][6]);
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(szi, "p4 start") == 0 )
|
||||
{
|
||||
if ( buttons[nDevice][7] != -1) KEY(nJoyBase + 0x80 + buttons[nDevice][7]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strncmp(szi, "p4 fire ", 7) == 0)
|
||||
{
|
||||
char* szb = szi + 7;
|
||||
INT32 nButton = strtol(szb, NULL, 0);
|
||||
if (nButton >= 1)
|
||||
{
|
||||
nButton--;
|
||||
}
|
||||
if (buttons[nDevice][nButton] != -1 && !bStreetFighterLayout) { KEY(nJoyBase + 0x80 + buttons[nDevice][nButton]); }
|
||||
else if (buttons[nDevice][nButton] != -1 && bStreetFighterLayout)
|
||||
{
|
||||
if (nButton == 0) KEY(nJoyBase + 0x80 + buttons[nDevice][2]);
|
||||
if (nButton == 1) KEY(nJoyBase + 0x80 + buttons[nDevice][3]);
|
||||
if (nButton == 2) KEY(nJoyBase + 0x80 + buttons[nDevice][4]);
|
||||
if (nButton == 3) KEY(nJoyBase + 0x80 + buttons[nDevice][0]);
|
||||
if (nButton == 4) KEY(nJoyBase + 0x80 + buttons[nDevice][1]);
|
||||
if (nButton == 5) KEY(nJoyBase + 0x80 + buttons[nDevice][5]);
|
||||
}
|
||||
else KEY(nJoyBase + 0x80 + nButton); // joystick not mapped or isint plugged use fba default settings
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
INT32 display_set_controls()
|
||||
{
|
||||
struct GameInp* pgi = NULL;
|
||||
unsigned int i;
|
||||
for (i = 0, pgi = GameInp; i < nGameInpCount; i++, pgi++) {
|
||||
struct BurnInputInfo bii;
|
||||
// Get the extra info about the input
|
||||
bii.szInfo = NULL;
|
||||
BurnDrvGetInputInfo(&bii, i);
|
||||
if (bii.pVal == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (bii.szInfo == NULL) {
|
||||
bii.szInfo = "";
|
||||
}
|
||||
printf("%s %s\n", bii.szInfo, InputCodeDesc(pgi->Input.Switch.nCode));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
INT32 Init_Joysticks(int p_one_use_joystick)
|
||||
{
|
||||
if (!p_one_use_joystick)
|
||||
{
|
||||
/*keyboard p1, joy0 p2) */
|
||||
GameInpConfig(0, 0, 1);
|
||||
GameInpConfig(1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*init all joysticks (4 max atm) to map or the default will think
|
||||
p1 is keyboard and p2 p3 p4 is joy 0 1 2 instead of joy 1 2 3 */
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
GameInpConfig(i, i+1, 1);
|
||||
}
|
||||
}
|
||||
display_set_controls();
|
||||
return 0;
|
||||
};
|
@ -1,155 +1,186 @@
|
||||
|
||||
#include "burner.h"
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#endif
|
||||
// Game patching
|
||||
|
||||
#define UTF8_SIGNATURE "\xef\xbb\xbf"
|
||||
#define IPS_SIGNATURE "PATCH"
|
||||
#define IPS_TAG_EOF "EOF"
|
||||
#define IPS_EXT ".ips"
|
||||
|
||||
#define BYTE3_TO_UINT(bp) \
|
||||
(((unsigned int)(bp)[0] << 16) & 0x00FF0000) | \
|
||||
(((unsigned int)(bp)[1] << 8) & 0x0000FF00) | \
|
||||
((unsigned int)(bp)[2] & 0x000000FF)
|
||||
|
||||
#define BYTE2_TO_UINT(bp) \
|
||||
(((unsigned int)(bp)[0] << 8) & 0xFF00) | \
|
||||
((unsigned int) (bp)[1] & 0x00FF)
|
||||
|
||||
bool bDoIpsPatch = FALSE;
|
||||
|
||||
INT32 nIpsMaxFileLen = 0;
|
||||
|
||||
static void PatchFile(const char* ips_path, UINT8* base)
|
||||
{
|
||||
char buf[6];
|
||||
FILE* f = NULL;
|
||||
int Offset, Size;
|
||||
UINT8* mem8 = NULL;
|
||||
|
||||
if (NULL == (f = fopen(ips_path, "rb")))
|
||||
return;
|
||||
|
||||
memset(buf, 0, sizeof buf);
|
||||
fread(buf, 1, 5, f);
|
||||
if (strcmp(buf, IPS_SIGNATURE)) {
|
||||
return;
|
||||
} else {
|
||||
UINT8 ch = 0;
|
||||
int bRLE = 0;
|
||||
while (!feof(f)) {
|
||||
// read patch address offset
|
||||
fread(buf, 1, 3, f);
|
||||
buf[3] = 0;
|
||||
if (strcmp(buf, IPS_TAG_EOF) == 0)
|
||||
break;
|
||||
|
||||
Offset = BYTE3_TO_UINT(buf);
|
||||
|
||||
// read patch length
|
||||
fread(buf, 1, 2, f);
|
||||
Size = BYTE2_TO_UINT(buf);
|
||||
|
||||
bRLE = (Size == 0);
|
||||
if (bRLE) {
|
||||
fread(buf, 1, 2, f);
|
||||
Size = BYTE2_TO_UINT(buf);
|
||||
ch = fgetc(f);
|
||||
}
|
||||
|
||||
while (Size--) {
|
||||
mem8 = base + Offset;
|
||||
Offset++;
|
||||
if (Offset > nIpsMaxFileLen) nIpsMaxFileLen = Offset; // file size is growing
|
||||
*mem8 = bRLE ? ch : fgetc(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static void DoPatchGame(const char* patch_name, char* game_name, UINT8* base)
|
||||
{
|
||||
char s[MAX_PATH];
|
||||
char* p = NULL;
|
||||
char* rom_name = NULL;
|
||||
char* ips_name = NULL;
|
||||
FILE* fp = NULL;
|
||||
unsigned long nIpsSize;
|
||||
|
||||
if ((fp = fopen(patch_name, "rb")) != NULL) {
|
||||
// get ips size
|
||||
fseek(fp, 0, SEEK_END);
|
||||
nIpsSize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
while (!feof(fp)) {
|
||||
if (fgets(s, sizeof s, fp) != NULL) {
|
||||
p = s;
|
||||
|
||||
// skip UTF-8 sig
|
||||
if (strncmp(p, UTF8_SIGNATURE, strlen(UTF8_SIGNATURE)) == 0)
|
||||
p += strlen(UTF8_SIGNATURE);
|
||||
|
||||
if (p[0] == '[') // '['
|
||||
break;
|
||||
|
||||
rom_name = strtok(p, " \t\r\n");
|
||||
if (!rom_name)
|
||||
continue;
|
||||
if (*rom_name == '#')
|
||||
continue;
|
||||
if (_stricmp(rom_name, game_name))
|
||||
continue;
|
||||
|
||||
ips_name = strtok(NULL, " \t\r\n");
|
||||
if (!ips_name)
|
||||
continue;
|
||||
|
||||
// skip CRC check
|
||||
strtok(NULL, "\r\n");
|
||||
|
||||
char ips_path[MAX_PATH];
|
||||
char ips_dir[MAX_PATH];
|
||||
TCHARToANSI(szAppIpsPath, ips_dir, sizeof(ips_dir));
|
||||
|
||||
if (strchr(ips_name, '\\')) {
|
||||
// ips in parent's folder
|
||||
sprintf(ips_path, "%s\\%s%s", ips_dir, ips_name, IPS_EXT);
|
||||
} else {
|
||||
sprintf(ips_path, "%s%s\\%s%s", ips_dir, BurnDrvGetTextA(DRV_NAME), ips_name, IPS_EXT);
|
||||
}
|
||||
|
||||
PatchFile(ips_path, base);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
void IpsApplyPatches(UINT8* base, char* rom_name)
|
||||
{
|
||||
nIpsMaxFileLen = 0;
|
||||
#if 0
|
||||
char ips_data[MAX_PATH];
|
||||
|
||||
int nActivePatches = GetIpsNumActivePatches();
|
||||
|
||||
for (int i = 0; i < nActivePatches; i++) {
|
||||
memset(ips_data, 0, MAX_PATH);
|
||||
TCHARToANSI(szIpsActivePatches[i], ips_data, sizeof(ips_data));
|
||||
DoPatchGame(ips_data, rom_name, base);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void IpsPatchExit()
|
||||
{
|
||||
bDoIpsPatch = FALSE;
|
||||
}
|
||||
#include "burner.h"
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#endif
|
||||
// Game patching
|
||||
|
||||
#define UTF8_SIGNATURE "\xef\xbb\xbf"
|
||||
#define IPS_SIGNATURE "PATCH"
|
||||
#define IPS_TAG_EOF "EOF"
|
||||
#define IPS_EXT ".ips"
|
||||
|
||||
#define BYTE3_TO_UINT(bp) \
|
||||
(((unsigned int)(bp)[0] << 16) & 0x00FF0000) | \
|
||||
(((unsigned int)(bp)[1] << 8) & 0x0000FF00) | \
|
||||
((unsigned int)(bp)[2] & 0x000000FF)
|
||||
|
||||
#define BYTE2_TO_UINT(bp) \
|
||||
(((unsigned int)(bp)[0] << 8) & 0xFF00) | \
|
||||
((unsigned int)(bp)[1] & 0x00FF)
|
||||
|
||||
bool bDoIpsPatch = FALSE;
|
||||
|
||||
INT32 nIpsMaxFileLen = 0;
|
||||
|
||||
static void PatchFile(const char* ips_path, UINT8* base)
|
||||
{
|
||||
char buf[6];
|
||||
FILE* f = NULL;
|
||||
int Offset, Size;
|
||||
UINT8* mem8 = NULL;
|
||||
|
||||
if (NULL == (f = fopen(ips_path, "rb")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
memset(buf, 0, sizeof buf);
|
||||
fread(buf, 1, 5, f);
|
||||
if (strcmp(buf, IPS_SIGNATURE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT8 ch = 0;
|
||||
int bRLE = 0;
|
||||
while (!feof(f))
|
||||
{
|
||||
// read patch address offset
|
||||
fread(buf, 1, 3, f);
|
||||
buf[3] = 0;
|
||||
if (strcmp(buf, IPS_TAG_EOF) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Offset = BYTE3_TO_UINT(buf);
|
||||
|
||||
// read patch length
|
||||
fread(buf, 1, 2, f);
|
||||
Size = BYTE2_TO_UINT(buf);
|
||||
|
||||
bRLE = (Size == 0);
|
||||
if (bRLE)
|
||||
{
|
||||
fread(buf, 1, 2, f);
|
||||
Size = BYTE2_TO_UINT(buf);
|
||||
ch = fgetc(f);
|
||||
}
|
||||
|
||||
while (Size--)
|
||||
{
|
||||
mem8 = base + Offset;
|
||||
Offset++;
|
||||
if (Offset > nIpsMaxFileLen)
|
||||
{
|
||||
nIpsMaxFileLen = Offset; // file size is growing
|
||||
}
|
||||
*mem8 = bRLE ? ch : fgetc(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static void DoPatchGame(const char* patch_name, char* game_name, UINT8* base)
|
||||
{
|
||||
char s[MAX_PATH];
|
||||
char* p = NULL;
|
||||
char* rom_name = NULL;
|
||||
char* ips_name = NULL;
|
||||
FILE* fp = NULL;
|
||||
unsigned long nIpsSize;
|
||||
|
||||
if ((fp = fopen(patch_name, "rb")) != NULL)
|
||||
{
|
||||
// get ips size
|
||||
fseek(fp, 0, SEEK_END);
|
||||
nIpsSize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
while (!feof(fp))
|
||||
{
|
||||
if (fgets(s, sizeof s, fp) != NULL)
|
||||
{
|
||||
p = s;
|
||||
|
||||
// skip UTF-8 sig
|
||||
if (strncmp(p, UTF8_SIGNATURE, strlen(UTF8_SIGNATURE)) == 0)
|
||||
{
|
||||
p += strlen(UTF8_SIGNATURE);
|
||||
}
|
||||
|
||||
if (p[0] == '[') // '['
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
rom_name = strtok(p, " \t\r\n");
|
||||
if (!rom_name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (*rom_name == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (_stricmp(rom_name, game_name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ips_name = strtok(NULL, " \t\r\n");
|
||||
if (!ips_name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip CRC check
|
||||
strtok(NULL, "\r\n");
|
||||
|
||||
char ips_path[MAX_PATH];
|
||||
char ips_dir[MAX_PATH];
|
||||
TCHARToANSI(szAppIpsPath, ips_dir, sizeof(ips_dir));
|
||||
|
||||
if (strchr(ips_name, '\\'))
|
||||
{
|
||||
// ips in parent's folder
|
||||
sprintf(ips_path, "%s\\%s%s", ips_dir, ips_name, IPS_EXT);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(ips_path, "%s%s\\%s%s", ips_dir, BurnDrvGetTextA(DRV_NAME), ips_name, IPS_EXT);
|
||||
}
|
||||
|
||||
PatchFile(ips_path, base);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
void IpsApplyPatches(UINT8* base, char* rom_name)
|
||||
{
|
||||
nIpsMaxFileLen = 0;
|
||||
#if 0
|
||||
char ips_data[MAX_PATH];
|
||||
|
||||
int nActivePatches = GetIpsNumActivePatches();
|
||||
|
||||
for (int i = 0; i < nActivePatches; i++)
|
||||
{
|
||||
memset(ips_data, 0, MAX_PATH);
|
||||
TCHARToANSI(szIpsActivePatches[i], ips_data, sizeof(ips_data));
|
||||
DoPatchGame(ips_data, rom_name, base);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void IpsPatchExit()
|
||||
{
|
||||
bDoIpsPatch = FALSE;
|
||||
}
|
||||
|
@ -1,74 +1,206 @@
|
||||
/*----------------
|
||||
Stuff to finish:
|
||||
* Stuff to finish:
|
||||
*
|
||||
* It wouldn't be a stretch of the imagination to think the whole of the sdl 'port' needs a redo but here are the main things wrong with this version:
|
||||
*
|
||||
*
|
||||
* The audio output code code could maybe do with some work, but it's getting there...
|
||||
* There are lots of problems with the opengl renderer, but you should just use the SDL2 build anyway
|
||||
*
|
||||
* TODO for SDL2:
|
||||
* Add autostart to menu as an ini config option
|
||||
* Add menu for options e.g. dips, mapping, saves, IPS patches
|
||||
* Maybe a better font output setup with some sort of scaling, maybe add sdl1 support?
|
||||
* figure out what is going on with the sdl sound output, something breaks after a few frames
|
||||
* ------------------*/
|
||||
|
||||
It wouldn't be a stretch of the imagination to think the whole of the sdl 'port' needs a redo but here are the main things wrong with this version:
|
||||
|
||||
|
||||
There is OSD of any kind which makes it hard to display info to the users.
|
||||
There are lots of problems with the audio output code.
|
||||
There are lots of problems with the opengl renderer
|
||||
probably many other things.
|
||||
------------------*/
|
||||
#include "burner.h"
|
||||
|
||||
int nAppVirtualFps = 6000; // App fps * 100
|
||||
bool bRunPause=0;
|
||||
bool bAlwaysProcessKeyboardInput=0;
|
||||
INT32 Init_Joysticks(int p1_use_joystick);
|
||||
|
||||
void CheckFirstTime()
|
||||
int nAppVirtualFps = 0; // App fps * 100
|
||||
bool bRunPause = 0;
|
||||
bool bAppFullscreen = 0;
|
||||
bool bAlwaysProcessKeyboardInput = 0;
|
||||
int usemenu = 0, usejoy = 0, vsync = 1, dat = 0;
|
||||
bool saveconfig = 1;
|
||||
bool bIntegerScale = false;
|
||||
|
||||
TCHAR szAppBurnVer[16];
|
||||
char videofiltering[3];
|
||||
|
||||
#ifdef BUILD_SDL2
|
||||
static char* szSDLeepromPath = NULL;
|
||||
static char* szSDLhiscorePath = NULL;
|
||||
static char* szSDLHDDPath = NULL;
|
||||
static char* szSDLSamplePath = NULL;
|
||||
#endif
|
||||
|
||||
#define set_commandline_option(i,v) i = v; saveconfig = 0;
|
||||
#define set_commandline_option_string(i, v, length) snprintf(i, length, v); saveconfig = 0;
|
||||
|
||||
int parseSwitches(int argc, char* argv[])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ProcessCommandLine(int argc, char *argv[])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#undef main
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
UINT32 i=0;
|
||||
|
||||
ConfigAppLoad();
|
||||
|
||||
CheckFirstTime(); // check for first time run
|
||||
|
||||
SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO);
|
||||
|
||||
BurnLibInit();
|
||||
|
||||
SDL_WM_SetCaption("FinalBurn Neo", "FinalBurn Neo");
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
if (argc < 2)
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
printf ("Usage: %1$s <romname>\n ie: %1$s uopoko\n Note: no extension.\n\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
for (i = 0; i < nBurnDrvCount; i++) {
|
||||
//nBurnDrvSelect[0] = i;
|
||||
nBurnDrvActive = i;
|
||||
if (strcmp(BurnDrvGetTextA(0), argv[1]) == 0) {
|
||||
break;
|
||||
}
|
||||
if (*argv[i] != '-')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == nBurnDrvCount) {
|
||||
printf("%s is not supported by FinalBurn Neo.\n",argv[1]);
|
||||
return 1;
|
||||
if (strcmp(argv[i] + 1, "joy") == 0)
|
||||
{
|
||||
set_commandline_option(usejoy, 1)
|
||||
}
|
||||
|
||||
if (strcmp(argv[i] + 1, "menu") == 0)
|
||||
{
|
||||
set_commandline_option(usemenu, 1)
|
||||
}
|
||||
|
||||
if (strcmp(argv[i] + 1, "novsync") == 0)
|
||||
{
|
||||
set_commandline_option(vsync, 0)
|
||||
}
|
||||
|
||||
if (strcmp(argv[i] + 1, "integerscale") == 0)
|
||||
{
|
||||
set_commandline_option(bIntegerScale, 1)
|
||||
}
|
||||
|
||||
if (strcmp(argv[i] + 1, "dat") == 0)
|
||||
{
|
||||
set_commandline_option(dat, 1)
|
||||
}
|
||||
|
||||
if (strcmp(argv[i] + 1, "fullscreen") == 0)
|
||||
{
|
||||
set_commandline_option(bAppFullscreen, 1)
|
||||
}
|
||||
|
||||
if (strcmp(argv[i] + 1, "nearest") == 0)
|
||||
{
|
||||
set_commandline_option_string(videofiltering, "0", 3)
|
||||
}
|
||||
|
||||
if (strcmp(argv[i] + 1, "linear") == 0)
|
||||
{
|
||||
set_commandline_option_string(videofiltering, "1", 3)
|
||||
}
|
||||
|
||||
if (strcmp(argv[i] + 1, "best") == 0)
|
||||
{
|
||||
set_commandline_option_string(videofiltering, "2", 3)
|
||||
}
|
||||
if (strcmp(argv[i] + 1, "autosave") == 0)
|
||||
{
|
||||
bDrvSaveAll = 1;
|
||||
}
|
||||
if (strcmp(argv[i] + 1, "cd") == 0)
|
||||
{
|
||||
_tcscpy(CDEmuImage, argv[i + 1]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bCheatsAllowed = false;
|
||||
ConfigAppLoad();
|
||||
ConfigAppSave();
|
||||
if (!DrvInit(i, 0))
|
||||
{
|
||||
void generateDats()
|
||||
{
|
||||
char filename[1024] = { 0 };
|
||||
|
||||
#if defined(BUILD_SDL2)
|
||||
printf("Creating fbneo dats in %s\n", SDL_GetPrefPath("fbneo", "dats"));
|
||||
#if defined(ALT_DAT)
|
||||
sprintf(filename, "%sFBNeo_-_ALL_SYSTEMS.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, -1);
|
||||
#endif
|
||||
sprintf(filename, "%sFBNeo_-_Arcade.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_ARCADE_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_MegaDrive.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_MEGADRIVE_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_PC_ENGINE.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_PCENGINE_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_TurboGrafx-16.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_TG16_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_PC_Engine_SuperGrafx.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_SGX_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_Sega_SG-1000.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_SG1000_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_ColecoVision.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_COLECO_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_Sega_Master_System.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_MASTERSYSTEM_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_Sega_Game_Gear.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_GAMEGEAR_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_MSX.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_MSX_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_Sinclair_ZX_Spectrum.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_SPECTRUM_ONLY);
|
||||
|
||||
sprintf(filename, "%sFBNeo_-_Neogeo.dat", SDL_GetPrefPath("fbneo", "dats"));
|
||||
create_datfile(filename, DAT_NEOGEO_ONLY);
|
||||
#else
|
||||
printf("Creating fbneo dats\n");
|
||||
|
||||
#if defined(ALT_DAT)
|
||||
sprintf(filename, "FBNeo_-_ALL_SYSTEMS.dat");
|
||||
create_datfile(filename, -1);
|
||||
#endif
|
||||
sprintf(filename, "FBNeo_-_Arcade.dat");
|
||||
create_datfile(filename, DAT_ARCADE_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_MegaDrive.dat");
|
||||
create_datfile(filename, DAT_MEGADRIVE_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_PC_ENGINE.dat");
|
||||
create_datfile(filename, DAT_PCENGINE_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_TurboGrafx-16.dat");
|
||||
create_datfile(filename, DAT_TG16_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_PC_Engine_SuperGrafx.dat");
|
||||
create_datfile(filename, DAT_SGX_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_Sega_SG-1000.dat");
|
||||
create_datfile(filename, DAT_SG1000_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_ColecoVision.dat");
|
||||
create_datfile(filename, DAT_COLECO_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_Sega_Master_System.dat");
|
||||
create_datfile(filename, DAT_MASTERSYSTEM_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_Sega_Game_Gear.dat");
|
||||
create_datfile(filename, DAT_GAMEGEAR_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_MSX.dat");
|
||||
create_datfile(filename, DAT_MSX_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_Sinclair_ZX_Spectrum.dat");
|
||||
create_datfile(filename, DAT_SPECTRUM_ONLY);
|
||||
|
||||
sprintf(filename, "FBNeo_-_Neogeo.dat");
|
||||
create_datfile(filename, DAT_NEOGEO_ONLY);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void DoGame(int gameToRun)
|
||||
{
|
||||
if (!DrvInit(gameToRun, 0))
|
||||
{
|
||||
MediaInit();
|
||||
Init_Joysticks(usejoy);
|
||||
RunMessageLoop();
|
||||
}
|
||||
else
|
||||
@ -76,16 +208,227 @@ int main(int argc, char *argv[])
|
||||
printf("There was an error loading your selected game.\n");
|
||||
}
|
||||
|
||||
if (saveconfig)
|
||||
{
|
||||
ConfigAppSave();
|
||||
}
|
||||
DrvExit();
|
||||
MediaExit();
|
||||
}
|
||||
|
||||
ConfigAppSave();
|
||||
void bye(void)
|
||||
{
|
||||
printf("Doing exit cleanup\n");
|
||||
|
||||
DrvExit();
|
||||
MediaExit();
|
||||
BurnLibExit();
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
static int __cdecl AppDebugPrintf(int nStatus, TCHAR* pszFormat, ...)
|
||||
{
|
||||
|
||||
va_list args;
|
||||
va_start(args, pszFormat);
|
||||
printf(pszFormat, args);
|
||||
va_end(args);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* romname = NULL;
|
||||
UINT32 i = 0;
|
||||
bool gamefound = 0;
|
||||
int fail = 0;
|
||||
atexit(bye);
|
||||
// TODO: figure out if we can use hardware Gamma until then, force software gamma
|
||||
bVidUseHardwareGamma = 0;
|
||||
bHardwareGammaOnly = 0;
|
||||
//
|
||||
|
||||
// Make version string
|
||||
if (nBurnVer & 0xFF)
|
||||
{
|
||||
// private version (alpha)
|
||||
_stprintf(szAppBurnVer, _T("%x.%x.%x.%02x"), nBurnVer >> 20, (nBurnVer >> 16) & 0x0F, (nBurnVer >> 8) & 0xFF, nBurnVer & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
// public version
|
||||
_stprintf(szAppBurnVer, _T("%x.%x.%x"), nBurnVer >> 20, (nBurnVer >> 16) & 0x0F, (nBurnVer >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
// set default videofiltering
|
||||
snprintf(videofiltering, 3, "0");
|
||||
|
||||
printf("FBNeo v%s\n", szAppBurnVer);
|
||||
|
||||
// create a default ini if one is not valid
|
||||
fail = ConfigAppLoad();
|
||||
if (fail)
|
||||
{
|
||||
if (saveconfig)
|
||||
{
|
||||
ConfigAppSave();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (*argv[i] != '-' && !gamefound)
|
||||
{
|
||||
romname = argv[i];
|
||||
gamefound = 1;
|
||||
}
|
||||
}
|
||||
|
||||
parseSwitches(argc, argv);
|
||||
|
||||
if (romname == NULL)
|
||||
{
|
||||
printf("Usage: %s [-cd] [-joy] [-menu] [-novsync] [-integerscale] [-fullscreen] [-dat] [-autosave] [-nearest] [-linear] [-best] <romname>\n", argv[0]);
|
||||
printf("Note the -menu switch does not require a romname\n");
|
||||
printf("e.g.: %s mslug\n", argv[0]);
|
||||
printf("e.g.: %s -menu -joy\n", argv[0]);
|
||||
printf("For NeoCD games:\n");
|
||||
printf("%s neocdz -cd path/to/ccd/filename.cue (or .ccd)\n", argv[0]);
|
||||
printf("Usage is restricted by the license at https://raw.githubusercontent.com/finalburnneo/FBNeo/master/src/license.txt\n");
|
||||
|
||||
if (!usemenu && !dat)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Do these bits before override via ConfigAppLoad
|
||||
bCheatsAllowed = false;
|
||||
nAudDSPModule[0] = 0;
|
||||
EnableHiscores = 1;
|
||||
|
||||
#ifdef BUILD_SDL
|
||||
SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO);
|
||||
|
||||
SDL_WM_SetCaption("FinalBurn Neo", "FinalBurn Neo");
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_SDL2
|
||||
#ifdef SDL_WINDOWS
|
||||
char *base_path = SDL_GetBasePath();
|
||||
#define DIRCNT 9
|
||||
// Make sure there are roms and cfg subdirectories
|
||||
TCHAR szDirs[DIRCNT][MAX_PATH] = {
|
||||
{_T("config")},
|
||||
{_T("config/games")},
|
||||
{_T("config/ips")},
|
||||
{_T("config/localisation")},
|
||||
{_T("config/presets")},
|
||||
{_T("recordings")},
|
||||
{_T("roms")},
|
||||
{_T("savestates")},
|
||||
{_T("screenshots")},
|
||||
};
|
||||
TCHAR currentPath[MAX_PATH];
|
||||
for(int x = 0; x < DIRCNT; x++) {
|
||||
snprintf(currentPath, MAX_PATH, "%s%s", base_path, szDirs[x]);
|
||||
CreateDirectory(currentPath, NULL);
|
||||
}
|
||||
#undef DIRCNT
|
||||
|
||||
SDL_setenv("SDL_AUDIODRIVER", "directsound", true); // fix audio for windows
|
||||
#endif
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
|
||||
{
|
||||
printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
#if defined(BUILD_SDL2) && !defined(SDL_WINDOWS)
|
||||
szSDLhiscorePath = SDL_GetPrefPath("fbneo", "hiscore");
|
||||
szSDLeepromPath = SDL_GetPrefPath("fbneo", "eeprom");
|
||||
szSDLHDDPath = SDL_GetPrefPath("fbneo", "hdd");
|
||||
szSDLSamplePath = SDL_GetPrefPath("fbneo", "samples");
|
||||
_stprintf(szAppHiscorePath, _T("%s"), szSDLhiscorePath);
|
||||
_stprintf(szAppEEPROMPath, _T("%s"), szSDLeepromPath);
|
||||
_stprintf(szAppHDDPath, _T("%s"), szSDLHDDPath);
|
||||
_stprintf(szAppSamplesPath, _T("%s"), szSDLSamplePath);
|
||||
#endif
|
||||
|
||||
fail = ConfigAppLoad();
|
||||
if (fail)
|
||||
{
|
||||
if (saveconfig)
|
||||
{
|
||||
ConfigAppSave();
|
||||
}
|
||||
}
|
||||
ComputeGammaLUT();
|
||||
#if defined(BUILD_SDL2) && !defined(SDL_WINDOWS)
|
||||
bprintf = AppDebugPrintf;
|
||||
#endif
|
||||
BurnLibInit();
|
||||
|
||||
// Search for a game now, for use in the menu and loading a games
|
||||
if (romname != NULL)
|
||||
{
|
||||
for (i = 0; i < nBurnDrvCount; i++)
|
||||
{
|
||||
nBurnDrvActive = i;
|
||||
if (strcmp(BurnDrvGetTextA(DRV_NAME), romname) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (usemenu)
|
||||
{
|
||||
#ifdef BUILD_SDL2
|
||||
bool quit = 0;
|
||||
|
||||
while (!quit)
|
||||
{
|
||||
gui_init();
|
||||
int selectedOk = gui_process();
|
||||
gui_exit();
|
||||
|
||||
switch (selectedOk)
|
||||
{
|
||||
case -1:
|
||||
BurnLibExit();
|
||||
SDL_Quit();
|
||||
quit = 1;
|
||||
return 0;
|
||||
|
||||
default:
|
||||
DoGame(selectedOk);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (dat)
|
||||
{
|
||||
generateDats();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i == nBurnDrvCount)
|
||||
{
|
||||
printf("%s is not supported by FinalBurn Neo.\n", romname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
DoGame(i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* const */ TCHAR* ANSIToTCHAR(const char* pszInString, TCHAR* pszOutString, int nOutSize)
|
||||
{
|
||||
@ -93,15 +436,17 @@ int main(int argc, char *argv[])
|
||||
static TCHAR szStringBuffer[1024];
|
||||
|
||||
TCHAR* pszBuffer = pszOutString ? pszOutString : szStringBuffer;
|
||||
int nBufferSize = pszOutString ? nOutSize * 2 : sizeof(szStringBuffer);
|
||||
int nBufferSize = pszOutString ? nOutSize * 2 : sizeof(szStringBuffer);
|
||||
|
||||
if (MultiByteToWideChar(CP_ACP, 0, pszInString, -1, pszBuffer, nBufferSize)) {
|
||||
if (MultiByteToWideChar(CP_ACP, 0, pszInString, -1, pszBuffer, nBufferSize))
|
||||
{
|
||||
return pszBuffer;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
#else
|
||||
if (pszOutString) {
|
||||
if (pszOutString)
|
||||
{
|
||||
_tcscpy(pszOutString, pszInString);
|
||||
return pszOutString;
|
||||
}
|
||||
@ -110,7 +455,6 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* const */ char* TCHARToANSI(const TCHAR* pszInString, char* pszOutString, int nOutSize)
|
||||
{
|
||||
#if defined (UNICODE)
|
||||
@ -118,15 +462,17 @@ int main(int argc, char *argv[])
|
||||
memset(szStringBuffer, 0, sizeof(szStringBuffer));
|
||||
|
||||
char* pszBuffer = pszOutString ? pszOutString : szStringBuffer;
|
||||
int nBufferSize = pszOutString ? nOutSize * 2 : sizeof(szStringBuffer);
|
||||
int nBufferSize = pszOutString ? nOutSize * 2 : sizeof(szStringBuffer);
|
||||
|
||||
if (WideCharToMultiByte(CP_ACP, 0, pszInString, -1, pszBuffer, nBufferSize, NULL, NULL)) {
|
||||
if (WideCharToMultiByte(CP_ACP, 0, pszInString, -1, pszBuffer, nBufferSize, NULL, NULL))
|
||||
{
|
||||
return pszBuffer;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
#else
|
||||
if (pszOutString) {
|
||||
if (pszOutString)
|
||||
{
|
||||
strcpy(pszOutString, pszInString);
|
||||
return pszOutString;
|
||||
}
|
||||
@ -135,7 +481,6 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool AppProcessKeyboardInput()
|
||||
{
|
||||
return true;
|
||||
|
@ -1,66 +1,72 @@
|
||||
// Media module
|
||||
#include "burner.h"
|
||||
|
||||
int MediaInit()
|
||||
{
|
||||
//ScrnInit() // Init the Scrn Window
|
||||
|
||||
if (!bInputOkay) {
|
||||
InputInit(); // Init Input
|
||||
}
|
||||
|
||||
nAppVirtualFps = nBurnFPS;
|
||||
|
||||
if (!bAudOkay) {
|
||||
AudSoundInit(); // Init Sound (not critical if it fails)
|
||||
}
|
||||
|
||||
nBurnSoundRate = 0; // Assume no sound
|
||||
pBurnSoundOut = NULL;
|
||||
if (bAudOkay) {
|
||||
nBurnSoundRate = nAudSampleRate[nAudSelect];
|
||||
nBurnSoundLen = nAudSegLen;
|
||||
}
|
||||
|
||||
if (!bVidOkay) {
|
||||
// Reinit the video plugin
|
||||
VidInit();
|
||||
if (!bVidOkay && nVidFullscreen) {
|
||||
|
||||
nVidFullscreen = 0;
|
||||
|
||||
MediaExit();
|
||||
return (MediaInit());
|
||||
}
|
||||
if (!nVidFullscreen) {
|
||||
//ScrnSize();
|
||||
}
|
||||
|
||||
if (!bVidOkay) {
|
||||
printf("Initialized video: %s\n", VidGetModuleName());
|
||||
}
|
||||
|
||||
if (bVidOkay && (bRunPause || !bDrvOkay)) {
|
||||
VidRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MediaExit()
|
||||
{
|
||||
nBurnSoundRate = 0; // Blank sound
|
||||
pBurnSoundOut = NULL;
|
||||
|
||||
AudSoundExit(); // Exit sound
|
||||
|
||||
VidExit();
|
||||
|
||||
InputExit();
|
||||
|
||||
//ScrnExit(); // Exit the Scrn Window
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Media module
|
||||
#include "burner.h"
|
||||
|
||||
int MediaInit()
|
||||
{
|
||||
//ScrnInit() // Init the Scrn Window
|
||||
|
||||
if (!bInputOkay)
|
||||
{
|
||||
InputInit(); // Init Input
|
||||
}
|
||||
|
||||
nAppVirtualFps = nBurnFPS;
|
||||
|
||||
if (!bAudOkay)
|
||||
{
|
||||
AudSoundInit(); // Init Sound (not critical if it fails)
|
||||
}
|
||||
|
||||
nBurnSoundRate = 0; // Assume no sound
|
||||
pBurnSoundOut = NULL;
|
||||
if (bAudOkay)
|
||||
{
|
||||
nBurnSoundRate = nAudSampleRate[nAudSelect];
|
||||
nBurnSoundLen = nAudSegLen;
|
||||
}
|
||||
|
||||
if (!bVidOkay)
|
||||
{
|
||||
// Reinit the video plugin
|
||||
VidInit();
|
||||
if (!bVidOkay && nVidFullscreen)
|
||||
{
|
||||
nVidFullscreen = 0;
|
||||
|
||||
MediaExit();
|
||||
return MediaInit();
|
||||
}
|
||||
if (!nVidFullscreen)
|
||||
{
|
||||
//ScrnSize();
|
||||
}
|
||||
|
||||
if (!bVidOkay)
|
||||
{
|
||||
printf("Initialized video: %s\n", VidGetModuleName());
|
||||
}
|
||||
|
||||
if (bVidOkay && (bRunPause || !bDrvOkay))
|
||||
{
|
||||
VidRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MediaExit()
|
||||
{
|
||||
nBurnSoundRate = 0; // Blank sound
|
||||
pBurnSoundOut = NULL;
|
||||
|
||||
AudSoundExit(); // Exit sound
|
||||
bAudOkay = 0;
|
||||
VidExit();
|
||||
|
||||
InputExit();
|
||||
|
||||
//ScrnExit(); // Exit the Scrn Window
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,116 +4,122 @@
|
||||
#include "burner.h"
|
||||
#include "neocdlist.h"
|
||||
|
||||
struct NGCDGAME games[] =
|
||||
const int nSectorLength = 2352;
|
||||
|
||||
NGCDGAME* game;
|
||||
|
||||
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 }, //
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------------------//
|
||||
// * 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 }, //
|
||||
{ _T("lasthope") , _T("Last Hope") , _T("2007") , _T("NG.DEV.TEAM") , 0x0666 }, //
|
||||
{ _T("neon") , _T("Project Neon: Caravan Demo") , _T("2019") , _T("Team Project Neon") , 0x7777 }, //
|
||||
};
|
||||
|
||||
NGCDGAME* GetNeoGeoCDInfo(unsigned int nID)
|
||||
{
|
||||
for(unsigned int nGame = 0; nGame < (sizeof(games) / sizeof(NGCDGAME)); nGame++) {
|
||||
if(nID == games[nGame].id ) {
|
||||
for (unsigned int nGame = 0; nGame < (sizeof(games) / sizeof(NGCDGAME)); nGame++) {
|
||||
if (nID == games[nGame].id) {
|
||||
return &games[nGame];
|
||||
}
|
||||
}
|
||||
@ -122,98 +128,101 @@ NGCDGAME* GetNeoGeoCDInfo(unsigned int nID)
|
||||
}
|
||||
|
||||
// Update the main window title
|
||||
void SetNeoCDTitle(TCHAR* pszTitle)
|
||||
static void SetNeoCDTitle(TCHAR* pszTitle)
|
||||
{
|
||||
TCHAR szText[1024] = _T("");
|
||||
_stprintf(szText, _T(APP_TITLE) _T( " v%.20s") _T(SEPERATOR_1) _T("%s") _T(SEPERATOR_1) _T("%s"), szAppBurnVer, BurnDrvGetText(DRV_FULLNAME), pszTitle);
|
||||
#ifdef BUILD_WIN32
|
||||
SetWindowText(hScrnWnd, szText);
|
||||
#endif
|
||||
_stprintf(szText, _T(APP_TITLE) _T(" v%.20s") _T(SEPERATOR_1) _T("%s") _T(SEPERATOR_1) _T("%s"), szAppBurnVer, BurnDrvGetText(DRV_FULLNAME), pszTitle);
|
||||
|
||||
// SetWindowText(hScrnWnd, szText);
|
||||
}
|
||||
|
||||
NGCDGAME* game;
|
||||
void NeoCDInfo_SetTitle()
|
||||
{
|
||||
if (IsNeoGeoCD() && game && game->id) {
|
||||
SetNeoCDTitle(game->pszTitle);
|
||||
}
|
||||
else if (IsNeoGeoCD()) {
|
||||
SetNeoCDTitle("Unknown CD");
|
||||
}
|
||||
}
|
||||
|
||||
// Get the title
|
||||
int GetNeoCDTitle(unsigned int nGameID)
|
||||
// Get the title
|
||||
int GetNeoCDTitle(unsigned int nGameID)
|
||||
{
|
||||
game = (NGCDGAME*)malloc(sizeof(NGCDGAME));
|
||||
memset(game, 0, sizeof(NGCDGAME));
|
||||
|
||||
if(GetNeoGeoCDInfo(nGameID))
|
||||
{
|
||||
|
||||
if (GetNeoGeoCDInfo(nGameID)) {
|
||||
memcpy(game, GetNeoGeoCDInfo(nGameID), sizeof(NGCDGAME));
|
||||
|
||||
bprintf(PRINT_NORMAL, _T(" Title: %s \n") , game->pszTitle);
|
||||
bprintf(PRINT_NORMAL, _T(" Shortname: %s \n") , game->pszName);
|
||||
bprintf(PRINT_NORMAL, _T(" Year: %s \n") , game->pszYear);
|
||||
bprintf(PRINT_NORMAL, _T(" Company: %s \n") , game->pszCompany);
|
||||
|
||||
bprintf(PRINT_NORMAL, _T(" Title: %s \n"), game->pszTitle);
|
||||
bprintf(PRINT_NORMAL, _T(" Shortname: %s \n"), game->pszName);
|
||||
bprintf(PRINT_NORMAL, _T(" Year: %s \n"), game->pszYear);
|
||||
bprintf(PRINT_NORMAL, _T(" Company: %s \n"), game->pszCompany);
|
||||
|
||||
// Update the main window title
|
||||
SetNeoCDTitle(game->pszTitle);
|
||||
//SetNeoCDTitle(game->pszTitle);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
//SetNeoCDTitle(FBALoadStringEx(hAppInst, IDS_UNIDENTIFIED_CD, true));
|
||||
}
|
||||
|
||||
game = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void iso9660_ReadOffset(unsigned char *Dest, FILE* fp, unsigned int lOffset, unsigned int lSize, unsigned int lLength)
|
||||
void iso9660_ReadOffset(UINT8* 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);
|
||||
if (fp == NULL || Dest == NULL) return;
|
||||
|
||||
fseek(fp, lOffset + ((nSectorLength == 2352) ? 16 : 0), SEEK_SET);
|
||||
fread(Dest, lLength, lSize, fp);
|
||||
}
|
||||
|
||||
static void NeoCDList_iso9660_CheckDirRecord(FILE* fp, int nSector)
|
||||
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));
|
||||
unsigned int lBytesRead = 0;
|
||||
unsigned int lOffset = 0;
|
||||
bool bNewSector = false;
|
||||
bool bRevisionQueve = false;
|
||||
int nRevisionQueveID = 0;
|
||||
|
||||
while(1)
|
||||
lOffset = (nSector * nSectorLength);
|
||||
|
||||
UINT8 nLenDR;
|
||||
UINT8 Flags;
|
||||
UINT8 LEN_FI;
|
||||
UINT8* ExtentLoc = (UINT8*)malloc(8 + 32);
|
||||
UINT8* Data = (UINT8*)malloc(0x10b + 32);
|
||||
char* File = (char*)malloc(32 + 32);
|
||||
|
||||
while (1)
|
||||
{
|
||||
iso9660_ReadOffset(nLenDR, fp, lOffset, 1, sizeof(unsigned char));
|
||||
|
||||
if(nLenDR[0] == 0x22) {
|
||||
lOffset += nLenDR[0];
|
||||
lBytesRead += nLenDR[0];
|
||||
iso9660_ReadOffset(&nLenDR, fp, lOffset, 1, sizeof(UINT8));
|
||||
|
||||
if (nLenDR == 0x22) {
|
||||
lOffset += nLenDR;
|
||||
lBytesRead += nLenDR;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(nLenDR[0] < 0x22)
|
||||
if (nLenDR < 0x22)
|
||||
{
|
||||
if(bNewSector)
|
||||
if (bNewSector)
|
||||
{
|
||||
if(bRevisionQueve) {
|
||||
bRevisionQueve = false;
|
||||
|
||||
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);
|
||||
nLenDR = 0;
|
||||
iso9660_ReadOffset(&nLenDR, fp, lOffset + 1, 1, sizeof(UINT8));
|
||||
|
||||
if (nLenDR < 0x22) {
|
||||
lOffset += (nSectorLength - lBytesRead);
|
||||
lBytesRead = 0;
|
||||
bNewSector = true;
|
||||
continue;
|
||||
@ -221,66 +230,66 @@ static void NeoCDList_iso9660_CheckDirRecord(FILE* fp, int nSector)
|
||||
}
|
||||
|
||||
bNewSector = false;
|
||||
|
||||
iso9660_ReadOffset(Flags, fp, lOffset + 25, 1, sizeof(unsigned char));
|
||||
|
||||
if(!(Flags[0] & (1 << 1)))
|
||||
iso9660_ReadOffset(&Flags, fp, lOffset + 25, 1, sizeof(UINT8));
|
||||
|
||||
if (!(Flags & (1 << 1)))
|
||||
{
|
||||
iso9660_ReadOffset(ExtentLoc, fp, lOffset + 2, 8, sizeof(unsigned char));
|
||||
iso9660_ReadOffset(ExtentLoc, fp, lOffset + 2, 8, sizeof(UINT8));
|
||||
|
||||
char szValue[9];
|
||||
char szValue[32];
|
||||
sprintf(szValue, "%02x%02x%02x%02x", ExtentLoc[4], ExtentLoc[5], ExtentLoc[6], ExtentLoc[7]);
|
||||
|
||||
unsigned int nValue = 0;
|
||||
sscanf(szValue, "%x", &nValue);
|
||||
sscanf(szValue, "%x", &nValue);
|
||||
|
||||
iso9660_ReadOffset(Data, fp, nValue * 2048, 0x10a, sizeof(unsigned char));
|
||||
iso9660_ReadOffset(Data, fp, nValue * nSectorLength, 0x10a, sizeof(UINT8));
|
||||
|
||||
char szData[8];
|
||||
char szData[32];
|
||||
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))
|
||||
if (!strncmp(szData, "NEO-GEO", 7))
|
||||
{
|
||||
char id[] = "0000";
|
||||
sprintf(id, "%02X%02X", Data[0x108], Data[0x109]);
|
||||
char id[32];
|
||||
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(&LEN_FI, fp, lOffset + 32, 1, sizeof(UINT8));
|
||||
|
||||
iso9660_ReadOffset((unsigned char*)File, fp, lOffset + 33, LEN_FI[0], sizeof(char));
|
||||
strncpy(File, File, LEN_FI[0]);
|
||||
File[LEN_FI[0]] = 0;
|
||||
iso9660_ReadOffset((UINT8*)File, fp, lOffset + 33, LEN_FI, sizeof(UINT8));
|
||||
strncpy(File, File, LEN_FI);
|
||||
File[LEN_FI] = 0;
|
||||
|
||||
// King of Fighters '94, The (1994)(SNK)(JP)
|
||||
// 10-6-1994 (P1.PRG)
|
||||
if(nID == 0x0055 && Data[0x67] == 0xDE) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
if (nID == 0x0084 && Data[0x6C] == 0xFF) {
|
||||
// Change to custom revision id
|
||||
nID = 0x1084;
|
||||
}
|
||||
|
||||
// King of Fighters '96 NEOGEO Collection, The
|
||||
if(nID == 0x0229) {
|
||||
if (nID == 0x0229) {
|
||||
bRevisionQueve = false;
|
||||
|
||||
GetNeoCDTitle(nID);
|
||||
@ -288,49 +297,33 @@ static void NeoCDList_iso9660_CheckDirRecord(FILE* fp, int nSector)
|
||||
}
|
||||
|
||||
// King of Fighters '96, The
|
||||
if(nID == 0x0214) {
|
||||
bRevisionQueve = true;
|
||||
nRevisionQueveID = nID;
|
||||
lOffset += nLenDR[0];
|
||||
lBytesRead += nLenDR[0];
|
||||
if (nID == 0x0214) {
|
||||
bRevisionQueve = true;
|
||||
nRevisionQueveID = nID;
|
||||
lOffset += nLenDR;
|
||||
lBytesRead += nLenDR;
|
||||
continue;
|
||||
}
|
||||
|
||||
GetNeoCDTitle(nID);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lOffset += nLenDR[0];
|
||||
lBytesRead += nLenDR[0];
|
||||
}
|
||||
|
||||
lOffset += nLenDR;
|
||||
lBytesRead += nLenDR;
|
||||
}
|
||||
|
||||
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;
|
||||
@ -340,16 +333,16 @@ static void NeoCDList_iso9660_CheckDirRecord(FILE* fp, int nSector)
|
||||
// Check the specified ISO, and proceed accordingly
|
||||
static int NeoCDList_CheckISO(TCHAR* pszFile)
|
||||
{
|
||||
if(!pszFile) {
|
||||
if (!pszFile) {
|
||||
// error
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make sure we have a valid ISO file extension...
|
||||
if(_tcsstr(pszFile, _T(".iso")) || _tcsstr(pszFile, _T(".ISO")) )
|
||||
if (IsFileExt(pszFile, _T(".img")) || IsFileExt(pszFile, _T(".bin")))
|
||||
{
|
||||
FILE* fp = _tfopen(pszFile, _T("rb"));
|
||||
if(fp)
|
||||
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 :)
|
||||
@ -359,40 +352,38 @@ static int NeoCDList_CheckISO(TCHAR* pszFile)
|
||||
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))
|
||||
{
|
||||
if (lSize > (nSectorLength * 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))
|
||||
UINT8 IsoCheck[32];
|
||||
|
||||
// advance to sector 16 and PVD Field 2
|
||||
iso9660_ReadOffset(&IsoCheck[0], fp, nSectorLength * 16 + 1, 1, 5); // get Standard Identifier Field from PVD
|
||||
|
||||
// Verify that we have indeed a valid ISO9660 MODE1/2352
|
||||
if (!memcmp(IsoCheck, "CD001", 5))
|
||||
{
|
||||
//bprintf(PRINT_NORMAL, _T(" Standard ISO9660 Identifier Found. \n"));
|
||||
iso9660_VDH vdh;
|
||||
|
||||
// Get Volume Descriptor Header
|
||||
// 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));
|
||||
iso9660_ReadOffset((UINT8*)&vdh, fp, 16 * nSectorLength, 1, sizeof(vdh));
|
||||
|
||||
// Check for a valid Volume Descriptor Type
|
||||
if(vdh.vdtype == 0x01)
|
||||
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
|
||||
// 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));
|
||||
iso9660_ReadOffset((UINT8*)&pvd, fp, nSectorLength * 16, 1, sizeof(pvd));
|
||||
|
||||
// ROOT DIRECTORY RECORD
|
||||
|
||||
@ -400,49 +391,51 @@ static int NeoCDList_CheckISO(TCHAR* pszFile)
|
||||
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],
|
||||
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];
|
||||
// Just read from the file directly at the correct offset (SECTOR_SIZE * 16 + 0x9e for the start of the root directory record)
|
||||
UINT8 buffer[32];
|
||||
char szRootSector[32];
|
||||
unsigned int nRootSector = 0;
|
||||
|
||||
fseek(fp, 0x809e, SEEK_SET);
|
||||
fread(buffer, 1, 8, fp);
|
||||
|
||||
|
||||
iso9660_ReadOffset(&buffer[0], fp, nSectorLength * 16 + 0x9e, 1, 8);
|
||||
|
||||
sprintf(szRootSector, "%02x%02x%02x%02x", buffer[4], buffer[5], buffer[6], buffer[7]);
|
||||
|
||||
|
||||
sscanf(szRootSector, "%x", &nRootSector);
|
||||
#endif
|
||||
|
||||
#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 {
|
||||
}
|
||||
else {
|
||||
|
||||
//bprintf(PRINT_NORMAL, _T(" Standard ISO9660 Identifier Not Found, cannot continue. \n"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
//bprintf(PRINT_NORMAL, _T(" Couldn't open %s \n"), GetIsoPath());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(fp) fclose(fp);
|
||||
if (fp) fclose(fp);
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
//bprintf(PRINT_NORMAL, _T(" File doesn't have a valid ISO extension [ .iso / .ISO ] \n"));
|
||||
return 0;
|
||||
@ -454,36 +447,39 @@ static int NeoCDList_CheckISO(TCHAR* pszFile)
|
||||
// This will do everything
|
||||
int GetNeoGeoCD_Identifier()
|
||||
{
|
||||
if(!GetIsoPath() || !IsNeoGeoCD()) {
|
||||
if (!GetIsoPath() || !IsNeoGeoCD()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make sure we have a valid ISO file extension...
|
||||
if(_tcsstr(GetIsoPath(), _T(".iso")) || _tcsstr(GetIsoPath(), _T(".ISO")) )
|
||||
if (IsFileExt(GetIsoPath(), _T(".img")) || IsFileExt(GetIsoPath(), _T(".bin")))
|
||||
{
|
||||
if(_tfopen(GetIsoPath(), _T("rb")))
|
||||
if (_tfopen(GetIsoPath(), _T("rb")))
|
||||
{
|
||||
bprintf(0, _T("NeoCDList: checking %s\n"), GetIsoPath());
|
||||
// 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 {
|
||||
}
|
||||
else {
|
||||
|
||||
bprintf(PRINT_NORMAL, _T(" Couldn't open %s \n"), GetIsoPath());
|
||||
return 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
bprintf(PRINT_NORMAL, _T(" File doesn't have a valid ISO extension [ .iso / .ISO ] \n"));
|
||||
bprintf(PRINT_NORMAL, _T(" File doesn't have a valid ISO extension [ .img / .bin ] \n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int NeoCDInfo_Init()
|
||||
int NeoCDInfo_Init()
|
||||
{
|
||||
NeoCDInfo_Exit();
|
||||
return GetNeoGeoCD_Identifier();
|
||||
@ -491,28 +487,28 @@ int NeoCDInfo_Init()
|
||||
|
||||
TCHAR* NeoCDInfo_Text(int nText)
|
||||
{
|
||||
if(!game || !IsNeoGeoCD() || !bDrvOkay) return NULL;
|
||||
if (!game || !IsNeoGeoCD()) return NULL;
|
||||
|
||||
switch(nText)
|
||||
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;
|
||||
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()
|
||||
int NeoCDInfo_ID()
|
||||
{
|
||||
if(!game || !IsNeoGeoCD() || !bDrvOkay) return 0;
|
||||
if (!game || !IsNeoGeoCD()) return 0;
|
||||
return game->id;
|
||||
}
|
||||
|
||||
void NeoCDInfo_Exit()
|
||||
void NeoCDInfo_Exit()
|
||||
{
|
||||
if(game) {
|
||||
if (game) {
|
||||
free(game);
|
||||
game = NULL;
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
// Functions for recording & replaying input
|
||||
// Stub version for SDL/Pi
|
||||
#include "burner.h"
|
||||
|
||||
INT32 nReplayStatus = 0; // 1 record, 2 replay, 0 nothing
|
||||
INT32 nReplayUndoCount = 0;
|
||||
UINT32 nReplayCurrentFrame = 0;
|
||||
UINT32 nStartFrame = 0;
|
||||
|
||||
INT32 FreezeInput(UINT8** buf, INT32* size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
INT32 UnfreezeInput(const UINT8* buf, INT32 size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// Functions for recording & replaying input
|
||||
// Stub version for SDL/Pi
|
||||
#include "burner.h"
|
||||
|
||||
INT32 nReplayStatus = 0; // 1 record, 2 replay, 0 nothing
|
||||
INT32 nReplayUndoCount = 0;
|
||||
UINT32 nReplayCurrentFrame = 0;
|
||||
UINT32 nStartFrame = 0;
|
||||
|
||||
INT32 FreezeInput(UINT8** buf, INT32* size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
INT32 UnfreezeInput(const UINT8* buf, INT32 size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,131 +1,209 @@
|
||||
// Run module
|
||||
#include "burner.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
static unsigned int nDoFPS = 0;
|
||||
bool bAltPause = 0;
|
||||
|
||||
int bAlwaysDrawFrames = 0;
|
||||
|
||||
static bool bShowFPS = false;
|
||||
int counter; // General purpose variable used when debugging
|
||||
|
||||
int counter; // General purpose variable used when debugging
|
||||
|
||||
static unsigned int nNormalLast = 0; // Last value of timeGetTime()
|
||||
static int nNormalFrac = 0; // Extra fraction we did
|
||||
static unsigned int nNormalLast = 0; // Last value of GetTime()
|
||||
static int nNormalFrac = 0; // Extra fraction we did
|
||||
|
||||
static bool bAppDoStep = 0;
|
||||
static bool bAppDoFast = 0;
|
||||
static int nFastSpeed = 6;
|
||||
bool bAppDoFast = 0;
|
||||
bool bAppShowFPS = 0;
|
||||
static int nFastSpeed = 6;
|
||||
|
||||
static int GetInput(bool bCopy)
|
||||
UINT32 messageFrames = 0;
|
||||
char lastMessage[MESSAGE_MAX_LENGTH];
|
||||
|
||||
/// Ingame gui
|
||||
#ifdef BUILD_SDL2
|
||||
extern SDL_Renderer* sdlRenderer;
|
||||
extern void ingame_gui_start(SDL_Renderer* renderer);
|
||||
#endif
|
||||
|
||||
/// Save States
|
||||
#ifdef BUILD_SDL2
|
||||
static char* szSDLSavePath = NULL;
|
||||
#endif
|
||||
|
||||
int bDrvSaveAll = 0;
|
||||
|
||||
// The automatic save
|
||||
int StatedAuto(int bSave)
|
||||
{
|
||||
static int i = 0;
|
||||
InputMake(bCopy); // get input
|
||||
static TCHAR szName[MAX_PATH] = _T("");
|
||||
int nRet;
|
||||
|
||||
// Update Input dialog ever 3 frames
|
||||
if (i == 0) {
|
||||
//InpdUpdate();
|
||||
#if defined(BUILD_SDL2) && !defined(SDL_WINDOWS)
|
||||
if (szSDLSavePath == NULL)
|
||||
{
|
||||
szSDLSavePath = SDL_GetPrefPath("fbneo", "states");
|
||||
}
|
||||
|
||||
i++;
|
||||
snprintf(szName, MAX_PATH, "%s%s.fs", szSDLSavePath, BurnDrvGetText(DRV_NAME));
|
||||
|
||||
if (i >= 3) {
|
||||
i = 0;
|
||||
#else
|
||||
|
||||
_stprintf(szName, _T("config/games/%s.fs"), BurnDrvGetText(DRV_NAME));
|
||||
|
||||
#endif
|
||||
|
||||
if (bSave == 0)
|
||||
{
|
||||
printf("loading state %i %s\n", bDrvSaveAll, szName);
|
||||
nRet = BurnStateLoad(szName, bDrvSaveAll, NULL); // Load ram
|
||||
if (nRet && bDrvSaveAll)
|
||||
{
|
||||
nRet = BurnStateLoad(szName, 0, NULL); // Couldn't get all - okay just try the nvram
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("saving state %i %s\n", bDrvSaveAll, szName);
|
||||
nRet = BurnStateSave(szName, bDrvSaveAll); // Save ram
|
||||
}
|
||||
|
||||
// Update Input Set dialog
|
||||
//InpsUpdate();
|
||||
return 0;
|
||||
return nRet;
|
||||
}
|
||||
|
||||
|
||||
/// End Save States
|
||||
|
||||
char fpsstring[20];
|
||||
|
||||
static time_t fpstimer;
|
||||
static unsigned int nPreviousFrames;
|
||||
|
||||
static void DisplayFPSInit()
|
||||
{
|
||||
nDoFPS = 0;
|
||||
fpstimer = 0;
|
||||
nPreviousFrames = nFramesRendered;
|
||||
}
|
||||
|
||||
static void DisplayFPS()
|
||||
{
|
||||
static time_t fpstimer;
|
||||
static unsigned int nPreviousFrames;
|
||||
|
||||
char fpsstring[8];
|
||||
time_t temptime = clock();
|
||||
float fps = static_cast<float>(nFramesRendered - nPreviousFrames) * CLOCKS_PER_SEC / (temptime - fpstimer);
|
||||
sprintf(fpsstring, "%2.1f", fps);
|
||||
double fps = (double)(nFramesRendered - nPreviousFrames) * CLOCKS_PER_SEC / (temptime - fpstimer);
|
||||
if (bAppDoFast) {
|
||||
fps *= nFastSpeed + 1;
|
||||
}
|
||||
if (fpstimer && temptime - fpstimer > 0) { // avoid strange fps values
|
||||
sprintf(fpsstring, "%2.2lf", fps);
|
||||
}
|
||||
|
||||
fpstimer = temptime;
|
||||
nPreviousFrames = nFramesRendered;
|
||||
}
|
||||
|
||||
|
||||
//crappy message system
|
||||
void UpdateMessage(char* message)
|
||||
{
|
||||
snprintf(lastMessage, MESSAGE_MAX_LENGTH, "%s", message);
|
||||
messageFrames = MESSAGE_MAX_FRAMES;
|
||||
}
|
||||
|
||||
// define this function somewhere above RunMessageLoop()
|
||||
void ToggleLayer(unsigned char thisLayer)
|
||||
{
|
||||
nBurnLayer ^= thisLayer; // xor with thisLayer
|
||||
nBurnLayer ^= thisLayer; // xor with thisLayer
|
||||
VidRedraw();
|
||||
VidPaint(0);
|
||||
}
|
||||
|
||||
|
||||
struct timeval start;
|
||||
|
||||
unsigned int GetTime(void)
|
||||
{
|
||||
unsigned int ticks;
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
ticks = (now.tv_sec - start.tv_sec) * 1000000 + now.tv_usec - start.tv_usec;
|
||||
return ticks;
|
||||
}
|
||||
|
||||
// With or without sound, run one frame.
|
||||
// If bDraw is true, it's the last frame before we are up to date, and so we should draw the screen
|
||||
static int RunFrame(int bDraw, int bPause)
|
||||
{
|
||||
static int bPrevPause = 0;
|
||||
static int bPrevDraw = 0;
|
||||
|
||||
if (bPrevDraw && !bPause) {
|
||||
VidPaint(0); // paint the screen (no need to validate)
|
||||
}
|
||||
|
||||
if (!bDrvOkay) {
|
||||
if (!bDrvOkay)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bPause)
|
||||
if (bPause)
|
||||
{
|
||||
GetInput(false); // Update burner inputs, but not game inputs
|
||||
if (bPause != bPrevPause)
|
||||
{
|
||||
VidPaint(2); // Redraw the screen (to ensure mode indicators are updated)
|
||||
}
|
||||
}
|
||||
else
|
||||
InputMake(false);
|
||||
VidPaint(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
nFramesEmulated++;
|
||||
nCurrentFrame++;
|
||||
GetInput(true); // Update inputs
|
||||
InputMake(true);
|
||||
}
|
||||
if (bDraw) {
|
||||
|
||||
if (bDraw)
|
||||
{
|
||||
nFramesRendered++;
|
||||
if (VidFrame()) { // Do one frame
|
||||
AudBlankSound();
|
||||
if (VidFrame())
|
||||
{
|
||||
AudBlankSound();
|
||||
}
|
||||
}
|
||||
else { // frame skipping
|
||||
pBurnDraw = NULL; // Make sure no image is drawn
|
||||
VidPaint(0); // paint the screen (no need to validate)
|
||||
}
|
||||
else
|
||||
{ // frame skipping
|
||||
pBurnDraw = NULL; // Make sure no image is drawn
|
||||
BurnDrvFrame();
|
||||
}
|
||||
bPrevPause = bPause;
|
||||
bPrevDraw = bDraw;
|
||||
|
||||
if (bAppShowFPS) {
|
||||
if (nDoFPS < nFramesRendered) {
|
||||
DisplayFPS();
|
||||
nDoFPS = nFramesRendered + 30;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Callback used when DSound needs more sound
|
||||
static int RunGetNextSound(int bDraw)
|
||||
{
|
||||
if (nAudNextSound == NULL) {
|
||||
if (nAudNextSound == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bRunPause) {
|
||||
if (bAppDoStep) {
|
||||
if (bRunPause)
|
||||
{
|
||||
if (bAppDoStep)
|
||||
{
|
||||
RunFrame(bDraw, 0);
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2); // Write silence into the buffer
|
||||
} else {
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2); // Write silence into the buffer
|
||||
}
|
||||
else
|
||||
{
|
||||
RunFrame(bDraw, 1);
|
||||
}
|
||||
|
||||
bAppDoStep = 0; // done one step
|
||||
bAppDoStep = 0; // done one step
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bAppDoFast) { // do more frames
|
||||
for (int i = 0; i < nFastSpeed; i++) {
|
||||
if (bAppDoFast)
|
||||
{ // do more frames
|
||||
for (int i = 0; i < nFastSpeed; i++)
|
||||
{
|
||||
RunFrame(0, 0);
|
||||
}
|
||||
}
|
||||
@ -133,30 +211,48 @@ static int RunGetNextSound(int bDraw)
|
||||
// Render frame with sound
|
||||
pBurnSoundOut = nAudNextSound;
|
||||
RunFrame(bDraw, 0);
|
||||
if (bAppDoStep) {
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2); // Write silence into the buffer
|
||||
if (bAppDoStep)
|
||||
{
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2); // Write silence into the buffer
|
||||
}
|
||||
bAppDoStep = 0; // done one step
|
||||
bAppDoStep = 0; // done one step
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int delay_ticks(int ticks)
|
||||
{
|
||||
//sdl_delay can take up to 10 - 15 ticks it doesnt guarentee below this
|
||||
int startTicks = 0;
|
||||
int endTicks = 0;
|
||||
int checkTicks = 0;
|
||||
|
||||
startTicks=SDL_GetTicks();
|
||||
|
||||
while (checkTicks <= ticks)
|
||||
{
|
||||
endTicks=SDL_GetTicks();
|
||||
checkTicks = endTicks - startTicks;
|
||||
}
|
||||
|
||||
return ticks;
|
||||
}
|
||||
int RunIdle()
|
||||
{
|
||||
int nTime, nCount;
|
||||
|
||||
if (bAudPlaying) {
|
||||
if (bAudPlaying)
|
||||
{
|
||||
// Run with sound
|
||||
AudSoundCheck();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Run without sound
|
||||
nTime = SDL_GetTicks() - nNormalLast;
|
||||
nTime = GetTime() - nNormalLast;
|
||||
nCount = (nTime * nAppVirtualFps - nNormalFrac) / 100000;
|
||||
if (nCount <= 0) { // No need to do anything for a bit
|
||||
SDL_Delay(3);
|
||||
|
||||
//delay_ticks(2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -164,26 +260,37 @@ int RunIdle()
|
||||
nNormalLast += nNormalFrac / nAppVirtualFps;
|
||||
nNormalFrac %= nAppVirtualFps;
|
||||
|
||||
if (bAppDoFast){ // Temporarily increase virtual fps
|
||||
nCount *= nFastSpeed;
|
||||
}
|
||||
if (nCount > 100) { // Limit frame skipping
|
||||
nCount = 100;
|
||||
}
|
||||
if (bRunPause) {
|
||||
if (bAppDoStep) { // Step one frame
|
||||
nCount = 10;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
RunFrame(1, 1); // Paused
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
bAppDoStep = 0;
|
||||
|
||||
for (int i = nCount / 10; i > 0; i--) { // Mid-frames
|
||||
RunFrame(!bAlwaysDrawFrames, 0);
|
||||
|
||||
if (bAppDoFast)
|
||||
{ // do more frames
|
||||
for (int i = 0; i < nFastSpeed; i++)
|
||||
{
|
||||
RunFrame(0, 0);
|
||||
}
|
||||
}
|
||||
RunFrame(1, 0); // End-frame
|
||||
|
||||
if (!bAlwaysDrawFrames)
|
||||
{
|
||||
for (int i = nCount / 10; i > 0; i--)
|
||||
{ // Mid-frames
|
||||
RunFrame(0, 0);
|
||||
}
|
||||
}
|
||||
RunFrame(1, 0); // End-frame
|
||||
// temp added for SDLFBA
|
||||
//VidPaint(0);
|
||||
return 0;
|
||||
@ -193,28 +300,31 @@ int RunReset()
|
||||
{
|
||||
// Reset the speed throttling code
|
||||
nNormalLast = 0; nNormalFrac = 0;
|
||||
if (!bAudPlaying) {
|
||||
if (!bAudPlaying)
|
||||
{
|
||||
// run without sound
|
||||
nNormalLast = SDL_GetTicks();
|
||||
nNormalLast = GetTime();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RunInit()
|
||||
{
|
||||
gettimeofday(&start, NULL);
|
||||
DisplayFPSInit();
|
||||
// Try to run with sound
|
||||
AudSetCallback(RunGetNextSound);
|
||||
AudSoundPlay();
|
||||
|
||||
RunReset();
|
||||
|
||||
StatedAuto(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RunExit()
|
||||
{
|
||||
nNormalLast = 0;
|
||||
|
||||
StatedAuto(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -222,27 +332,70 @@ int RunExit()
|
||||
// The main message loop
|
||||
int RunMessageLoop()
|
||||
{
|
||||
int quit = 0;
|
||||
int quit = 0;
|
||||
|
||||
MediaInit();
|
||||
RunInit();
|
||||
GameInpCheckMouse(); // Hide the cursor
|
||||
RunInit();
|
||||
GameInpCheckMouse(); // Hide the cursor
|
||||
|
||||
while (!quit) {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_QUIT: /* Windows was closed */
|
||||
quit = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (!quit)
|
||||
{
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT: /* Windows was closed */
|
||||
quit = 1;
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN: // need to find a nicer way of doing this...
|
||||
switch (event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_F1:
|
||||
bAppDoFast = 1;
|
||||
break;
|
||||
case SDLK_F9:
|
||||
QuickState(0);
|
||||
break;
|
||||
case SDLK_F10:
|
||||
QuickState(1);
|
||||
break;
|
||||
case SDLK_F11:
|
||||
bAppShowFPS = !bAppShowFPS;
|
||||
break;
|
||||
#ifdef BUILD_SDL2
|
||||
case SDLK_TAB:
|
||||
ingame_gui_start(sdlRenderer);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_KEYUP: // need to find a nicer way of doing this...
|
||||
switch (event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_F1:
|
||||
bAppDoFast = 0;
|
||||
break;
|
||||
|
||||
case SDLK_F12:
|
||||
quit = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
RunIdle();
|
||||
}
|
||||
|
||||
RunExit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
RunIdle();
|
||||
}
|
||||
|
||||
RunExit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#include "burner.h"
|
||||
|
||||
void Reinitialise()
|
||||
|
607
src/burner/sdl/sdl2_gui.cpp
Normal file
607
src/burner/sdl/sdl2_gui.cpp
Normal file
@ -0,0 +1,607 @@
|
||||
#include <SDL_image.h>
|
||||
#include "burner.h"
|
||||
#include "sdl2_gui_common.h"
|
||||
|
||||
extern char videofiltering[3];
|
||||
|
||||
static SDL_Window* sdlWindow = NULL;
|
||||
static SDL_Renderer* sdlRenderer = NULL;
|
||||
|
||||
static SDL_Texture* titleTexture = NULL;
|
||||
|
||||
static int nVidGuiWidth = 800;
|
||||
static int nVidGuiHeight = 600;
|
||||
|
||||
static int startGame = 0; // game at top of list as it is displayed on the menu
|
||||
static unsigned int gamesperscreen = 12;
|
||||
static unsigned int gamesperscreen_halfway = 6;
|
||||
static unsigned int gametoplay = 0;
|
||||
|
||||
const int JOYSTICK_DEAD_ZONE = 8000;
|
||||
SDL_GameController* gGameController = NULL;
|
||||
|
||||
#define NUMSTARS 512
|
||||
|
||||
static float star_x[NUMSTARS];
|
||||
static float star_y[NUMSTARS];
|
||||
static float star_z[NUMSTARS];
|
||||
|
||||
static int star_screenx[NUMSTARS];
|
||||
static int star_screeny[NUMSTARS];
|
||||
|
||||
static float star_zv[NUMSTARS];
|
||||
|
||||
static int centerx = 0;
|
||||
static int centery = 0;
|
||||
|
||||
static SDL_Rect title_texture_rect;
|
||||
static SDL_Rect dest_title_texture_rect;
|
||||
|
||||
static char* gameAv = NULL;
|
||||
|
||||
SDL_Texture* LoadTitleImage(SDL_Renderer* renderer, SDL_Texture* loadedTexture)
|
||||
{
|
||||
char titlePath[MAX_PATH] = { 0 };
|
||||
int w, h;
|
||||
|
||||
int currentSelected = nBurnDrvActive;
|
||||
nBurnDrvActive = gametoplay;
|
||||
#ifndef _WIN32
|
||||
snprintf(titlePath, MAX_PATH, "%s%s.png", "/usr/local/share/titles/", BurnDrvGetTextA(0));
|
||||
#else
|
||||
snprintf(titlePath, MAX_PATH, "\\support\\titles\\%s.png", BurnDrvGetTextA(0));
|
||||
#endif
|
||||
|
||||
loadedTexture = IMG_LoadTexture(renderer, titlePath);
|
||||
SDL_QueryTexture(loadedTexture, NULL, NULL, &w, &h);
|
||||
|
||||
title_texture_rect.x = 0; //the x coordinate
|
||||
title_texture_rect.y = 0; // the y coordinate
|
||||
title_texture_rect.w = w; //the width of the texture
|
||||
title_texture_rect.h = h; //the height of the texture
|
||||
|
||||
dest_title_texture_rect.x = nVidGuiWidth - w; //the x coordinate
|
||||
dest_title_texture_rect.y = (nVidGuiHeight / 2) - (h / 2); // the y coordinate
|
||||
dest_title_texture_rect.w = w; //the width of the texture
|
||||
dest_title_texture_rect.h = h; //the height of the texture
|
||||
nBurnDrvActive = currentSelected;
|
||||
return loadedTexture;
|
||||
}
|
||||
|
||||
void star_init(int screencenterx, int screencentery)
|
||||
{
|
||||
centerx = screencenterx;
|
||||
centery = screencentery;
|
||||
srand(time(0));
|
||||
for (int i = 0; i < NUMSTARS; i++)
|
||||
{
|
||||
star_x[i] = randomRange(-1000, 1000);
|
||||
star_y[i] = randomRange(-1000, 1000);
|
||||
star_z[i] = randomRange(100, 1000);
|
||||
star_zv[i] = randomRange(0.5, 5);
|
||||
}
|
||||
}
|
||||
|
||||
void star_render(SDL_Renderer* renderer)
|
||||
{
|
||||
for (int i = 0; i < NUMSTARS; i++)
|
||||
{
|
||||
star_z[i] = star_z[i] - star_zv[i];
|
||||
star_screenx[i] = star_x[i] / star_z[i] * 100 + centerx;
|
||||
star_screeny[i] = star_y[i] / star_z[i] * 100 + centery;
|
||||
if (star_screenx[i] > nVidGuiWidth || star_screeny[i] > nVidGuiHeight || star_z[i] < 1)
|
||||
{
|
||||
star_x[i] = randomRange(-1000, 1000);
|
||||
star_y[i] = randomRange(-1000, 1000);
|
||||
star_z[i] = randomRange(100, 1000);
|
||||
star_zv[i] = randomRange(0.5, 5);
|
||||
}
|
||||
|
||||
int b = 255 - ((255) * star_zv[i]) * (1000 / star_z[i]);
|
||||
SDL_SetRenderDrawColor(renderer, b, b, b, 255);
|
||||
SDL_RenderDrawPoint(renderer, star_screenx[i], star_screeny[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void CreateRomDatName(TCHAR* szRomDat)
|
||||
{
|
||||
#if defined(BUILD_SDL2) && !defined(SDL_WINDOWS)
|
||||
_stprintf(szRomDat, _T("%s/roms.found"), SDL_GetPrefPath("fbneo", "config"));
|
||||
#else
|
||||
_stprintf(szRomDat, _T("fbneo.dat"));
|
||||
#endif
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int WriteGameAvb()
|
||||
{
|
||||
TCHAR szRomDat[MAX_PATH];
|
||||
FILE* h;
|
||||
|
||||
CreateRomDatName(szRomDat);
|
||||
|
||||
if ((h = _tfopen(szRomDat, _T("wt"))) == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
_ftprintf(h, _T(APP_TITLE) _T(" v%.20s ROMs"), szAppBurnVer); // identifier
|
||||
_ftprintf(h, _T(" 0x%04X "), nBurnDrvCount); // no of games
|
||||
|
||||
for (unsigned int i = 0; i < nBurnDrvCount; i++) {
|
||||
if (gameAv[i] & 2) {
|
||||
_fputtc(_T('*'), h);
|
||||
}
|
||||
else {
|
||||
if (gameAv[i] & 1) {
|
||||
_fputtc(_T('+'), h);
|
||||
}
|
||||
else {
|
||||
_fputtc(_T('-'), h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_ftprintf(h, _T(" END")); // end marker
|
||||
|
||||
fclose(h);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int DoCheck(TCHAR* buffPos)
|
||||
{
|
||||
TCHAR label[256];
|
||||
|
||||
// Check identifier
|
||||
memset(label, 0, sizeof(label));
|
||||
_stprintf(label, _T(APP_TITLE) _T(" v%.20s ROMs"), szAppBurnVer);
|
||||
if ((buffPos = LabelCheck(buffPos, label)) == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Check no of supported games
|
||||
memset(label, 0, sizeof(label));
|
||||
memcpy(label, buffPos, 16);
|
||||
buffPos += 8;
|
||||
unsigned int n = _tcstol(label, NULL, 0);
|
||||
if (n != nBurnDrvCount) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < nBurnDrvCount; i++) {
|
||||
if (*buffPos == _T('*')) {
|
||||
gameAv[i] = 3;
|
||||
}
|
||||
else {
|
||||
if (*buffPos == _T('+')) {
|
||||
gameAv[i] = 1;
|
||||
}
|
||||
else {
|
||||
if (*buffPos == _T('-')) {
|
||||
gameAv[i] = 0;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buffPos++;
|
||||
}
|
||||
|
||||
memset(label, 0, sizeof(label));
|
||||
_stprintf(label, _T(" END"));
|
||||
if (LabelCheck(buffPos, label) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CheckGameAvb()
|
||||
{
|
||||
TCHAR szRomDat[MAX_PATH];
|
||||
FILE* h;
|
||||
int bOK;
|
||||
int nBufferSize = nBurnDrvCount + 256;
|
||||
TCHAR* buffer = (TCHAR*)malloc(nBufferSize * sizeof(TCHAR));
|
||||
if (buffer == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(buffer, 0, nBufferSize * sizeof(TCHAR));
|
||||
CreateRomDatName(szRomDat);
|
||||
|
||||
if ((h = _tfopen(szRomDat, _T("r"))) == NULL) {
|
||||
if (buffer)
|
||||
{
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
_fgetts(buffer, nBufferSize, h);
|
||||
fclose(h);
|
||||
|
||||
bOK = DoCheck(buffer);
|
||||
|
||||
if (buffer) {
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
return bOK;
|
||||
}
|
||||
|
||||
//TODO: multithread the rendering...
|
||||
void RefreshRomList(bool force_rescan)
|
||||
{
|
||||
UINT32 tempgame;
|
||||
SDL_Event e;
|
||||
float screenpercentage = nVidGuiWidth / 100;
|
||||
|
||||
SDL_Rect fillRect = { 0, 70, 0, 70 };
|
||||
|
||||
tempgame = nBurnDrvActive;
|
||||
nBurnDrvActive = 0;
|
||||
|
||||
if (!CheckGameAvb() && !force_rescan)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (UINT32 i = 0; i < nBurnDrvCount; i++)
|
||||
{
|
||||
nBurnDrvActive = i;
|
||||
switch (BzipOpen(true))
|
||||
{
|
||||
case 0:
|
||||
gameAv[i] = 3;
|
||||
break;
|
||||
case 2:
|
||||
gameAv[i] = 1;
|
||||
break;
|
||||
case 1:
|
||||
gameAv[i] = 0;
|
||||
break;
|
||||
}
|
||||
BzipClose();
|
||||
|
||||
if (i % 200 == 0)
|
||||
{
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0x1a, 0x1e, 0x1d, SDL_ALPHA_OPAQUE);
|
||||
SDL_RenderClear(sdlRenderer);
|
||||
|
||||
// draw a progress bar
|
||||
fillRect = { 0, 70, (int)(((i * 100) / nBurnDrvCount) * screenpercentage) , 70 };
|
||||
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 0xb3, 0x3b, 0xFF);
|
||||
SDL_RenderFillRect(sdlRenderer, &fillRect);
|
||||
|
||||
incolor(fbn_color, /* unused */ 0);
|
||||
inprint(sdlRenderer, "FinalBurn Neo", 10, 10);
|
||||
inprint(sdlRenderer, "=============", 10, 20);
|
||||
|
||||
inprint(sdlRenderer, "Scanning for ROM:", 10, 30);
|
||||
inprint(sdlRenderer, BurnDrvGetTextA(DRV_FULLNAME), 10, 40);
|
||||
SDL_RenderPresent(sdlRenderer);
|
||||
SDL_PollEvent(&e); // poll some events so OS doesn't think it's crashed
|
||||
}
|
||||
}
|
||||
WriteGameAvb();
|
||||
nBurnDrvActive = tempgame;
|
||||
}
|
||||
|
||||
void gui_exit()
|
||||
{
|
||||
SDL_GameControllerClose( gGameController );
|
||||
gGameController = NULL;
|
||||
|
||||
kill_inline_font();
|
||||
SDL_DestroyTexture(titleTexture);
|
||||
SDL_DestroyRenderer(sdlRenderer);
|
||||
SDL_DestroyWindow(sdlWindow);
|
||||
free(gameAv);
|
||||
}
|
||||
|
||||
void gui_init()
|
||||
{
|
||||
gameAv = (char*)malloc(nBurnDrvCount);
|
||||
memset(gameAv, 0, nBurnDrvCount);
|
||||
|
||||
if( SDL_NumJoysticks() < 1 )
|
||||
{
|
||||
printf( "Warning: No joysticks connected!\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < SDL_NumJoysticks(); ++i) {
|
||||
if (SDL_IsGameController(i)) {
|
||||
gGameController = SDL_GameControllerOpen(i);
|
||||
if (gGameController) {
|
||||
printf("Found a joypad!\n");
|
||||
break;
|
||||
} else {
|
||||
printf("Could not open gamecontroller %i: %s\n", i, SDL_GetError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
printf("vid init error\n");
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
Uint32 screenFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE;
|
||||
|
||||
if (bAppFullscreen)
|
||||
{
|
||||
SDL_DisplayMode dm;
|
||||
if (SDL_GetDesktopDisplayMode(0, &dm) != 0)
|
||||
{
|
||||
SDL_Log("SDL_GetDesktopDisplayMode failed: %s", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
nVidGuiWidth = dm.w;
|
||||
nVidGuiHeight = dm.h;
|
||||
screenFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
}
|
||||
|
||||
|
||||
sdlWindow = SDL_CreateWindow(
|
||||
"FBNeo - Choose your weapon...",
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
nVidGuiWidth,
|
||||
nVidGuiHeight,
|
||||
screenFlags
|
||||
);
|
||||
|
||||
star_init(nVidGuiWidth / 2, nVidGuiHeight / 2);
|
||||
|
||||
// Check that the window was successfully created
|
||||
if (sdlWindow == NULL)
|
||||
{
|
||||
// In the case that the window could not be made...
|
||||
printf("Could not create window: %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: I guess it make sense to always vsync on the menu??
|
||||
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
if (sdlRenderer == NULL)
|
||||
{
|
||||
// In the case that the window could not be made...
|
||||
printf("Could not create renderer: %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
if (bIntegerScale)
|
||||
{
|
||||
SDL_RenderSetIntegerScale(sdlRenderer, SDL_TRUE);
|
||||
}
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, videofiltering);
|
||||
SDL_RenderSetLogicalSize(sdlRenderer, nVidGuiWidth, nVidGuiHeight);
|
||||
|
||||
inrenderer(sdlRenderer);
|
||||
prepare_inline_font();
|
||||
|
||||
gamesperscreen = (nVidGuiHeight - 100) / 10;
|
||||
gamesperscreen_halfway = gamesperscreen / 2;
|
||||
|
||||
startGame = nBurnDrvActive - gamesperscreen_halfway;
|
||||
|
||||
RefreshRomList(false);
|
||||
}
|
||||
|
||||
void gui_render()
|
||||
{
|
||||
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0x1a, 0x1e, 0x1d, SDL_ALPHA_OPAQUE);
|
||||
SDL_RenderClear(sdlRenderer);
|
||||
|
||||
SDL_Rect fillRect = { 0, 28 + (gamesperscreen_halfway * 10), nVidGuiWidth, 12};
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0x41, 0x1d, 0x62, 0xFF);
|
||||
SDL_RenderFillRect(sdlRenderer, &fillRect);
|
||||
|
||||
star_render(sdlRenderer);
|
||||
|
||||
if (titleTexture != NULL) // JUST FOR TESTING!!
|
||||
{
|
||||
SDL_RenderCopy(sdlRenderer, titleTexture, &title_texture_rect, &dest_title_texture_rect);
|
||||
}
|
||||
|
||||
incolor(fbn_color, /* unused */ 0);
|
||||
inprint(sdlRenderer, "FinalBurn Neo", 10, 10);
|
||||
inprint(sdlRenderer, "=============", 10, 20);
|
||||
incolor(normal_color, /* unused */ 0);
|
||||
for (unsigned int i = startGame, game_counter = 0; game_counter < gamesperscreen; i++, game_counter++)
|
||||
{
|
||||
if (i > 0 && i < nBurnDrvCount)
|
||||
{
|
||||
nBurnDrvActive = i;
|
||||
if (game_counter == gamesperscreen_halfway)
|
||||
{
|
||||
calcSelectedItemColor();
|
||||
//incolor(select_color, /* unused */ 0);
|
||||
inprint_shadowed(sdlRenderer, BurnDrvGetTextA(DRV_FULLNAME), 10, 30 + (gamesperscreen_halfway * 10));
|
||||
gametoplay = i;
|
||||
|
||||
fillRect = { 0, nVidGuiHeight - 70, nVidGuiWidth, nVidGuiHeight };
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 0, 0, 0xFF);
|
||||
SDL_RenderFillRect(sdlRenderer, &fillRect);
|
||||
|
||||
incolor(info_color, /* unused */ 0);
|
||||
char infoLine[512];
|
||||
snprintf(infoLine, 512, "Year: %s - Manufacturer: %s - System: %s", BurnDrvGetTextA(DRV_DATE), BurnDrvGetTextA(DRV_MANUFACTURER), BurnDrvGetTextA(DRV_SYSTEM));
|
||||
char romLine[512];
|
||||
snprintf(romLine, 512, "Romset: %s - Parent: %s", BurnDrvGetTextA(DRV_NAME), BurnDrvGetTextA(DRV_PARENT));
|
||||
|
||||
inprint_shadowed(sdlRenderer, BurnDrvGetTextA(DRV_FULLNAME), 10, nVidGuiHeight - 60);
|
||||
inprint_shadowed(sdlRenderer, infoLine, 10, nVidGuiHeight - 50);
|
||||
inprint_shadowed(sdlRenderer, romLine, 10, nVidGuiHeight - 40);
|
||||
inprint_shadowed(sdlRenderer, BurnDrvGetTextA(DRV_COMMENT), 10, nVidGuiHeight - 30);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gameAv[nBurnDrvActive])
|
||||
{
|
||||
incolor(unavailable_color, /* unused */ 0);
|
||||
}
|
||||
else if (BurnDrvGetTextA(DRV_PARENT) == NULL)
|
||||
{
|
||||
incolor(normal_color_parent, /* unused */ 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
incolor(normal_color, /* unused */ 0);
|
||||
}
|
||||
inprint(sdlRenderer, BurnDrvGetTextA(DRV_FULLNAME), 10, 30 + (game_counter * 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_RenderPresent(sdlRenderer);
|
||||
}
|
||||
|
||||
int gui_process()
|
||||
{
|
||||
SDL_Event e;
|
||||
bool quit = false;
|
||||
static UINT32 previousSelected;
|
||||
|
||||
while (!quit)
|
||||
{
|
||||
//TODO: probably move this down inside the while (SDL_pollevent) bit...
|
||||
SDL_GameControllerUpdate();
|
||||
if (SDL_GameControllerGetAxis(gGameController, SDL_CONTROLLER_AXIS_LEFTY)<= -JOYSTICK_DEAD_ZONE)
|
||||
{
|
||||
startGame--;
|
||||
}
|
||||
else if (SDL_GameControllerGetAxis(gGameController, SDL_CONTROLLER_AXIS_LEFTY)>=JOYSTICK_DEAD_ZONE)
|
||||
{
|
||||
startGame++;
|
||||
}
|
||||
if (SDL_GameControllerGetButton(gGameController, SDL_CONTROLLER_BUTTON_A))
|
||||
{
|
||||
nBurnDrvActive = gametoplay;
|
||||
if (gameAv[nBurnDrvActive])
|
||||
{
|
||||
return gametoplay;
|
||||
}
|
||||
}
|
||||
if (SDL_GameControllerGetButton(gGameController, SDL_CONTROLLER_BUTTON_Y))
|
||||
{
|
||||
RefreshRomList(true);
|
||||
}
|
||||
|
||||
while (SDL_PollEvent(&e))
|
||||
{
|
||||
if (e.type == SDL_QUIT)
|
||||
{
|
||||
quit = true;
|
||||
}
|
||||
if (e.type == SDL_MOUSEWHEEL)
|
||||
{
|
||||
if (e.wheel.y > 0) // scroll up
|
||||
{
|
||||
startGame--;
|
||||
}
|
||||
else if (e.wheel.y < 0) // scroll down
|
||||
{
|
||||
startGame++;
|
||||
}
|
||||
}
|
||||
if (e.type == SDL_MOUSEBUTTONDOWN)
|
||||
{
|
||||
switch (e.button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
nBurnDrvActive = gametoplay;
|
||||
if (gameAv[nBurnDrvActive])
|
||||
{
|
||||
return gametoplay;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_RIGHT:
|
||||
quit = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (e.type == SDL_KEYDOWN)
|
||||
{
|
||||
switch (e.key.keysym.sym)
|
||||
{
|
||||
case SDLK_UP:
|
||||
startGame--;
|
||||
break;
|
||||
|
||||
case SDLK_DOWN:
|
||||
startGame++;
|
||||
break;
|
||||
|
||||
case SDLK_LEFT:
|
||||
startGame -= 10;
|
||||
break;
|
||||
|
||||
case SDLK_RIGHT:
|
||||
startGame += 10;
|
||||
break;
|
||||
|
||||
case SDLK_RETURN:
|
||||
nBurnDrvActive = gametoplay;
|
||||
if (gameAv[nBurnDrvActive])
|
||||
{
|
||||
return gametoplay;
|
||||
}
|
||||
break;
|
||||
case SDLK_F1:
|
||||
RefreshRomList(true);
|
||||
break;
|
||||
case SDLK_F12:
|
||||
quit = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: Need to put more clamping logic here....
|
||||
if (startGame < -(int)gamesperscreen_halfway + 1)
|
||||
{
|
||||
startGame = -gamesperscreen_halfway + 1;
|
||||
}
|
||||
|
||||
if (startGame > (int)nBurnDrvCount - (int)gamesperscreen_halfway - 1)
|
||||
{
|
||||
startGame = nBurnDrvCount - gamesperscreen_halfway - 1;
|
||||
}
|
||||
|
||||
if (previousSelected != gametoplay)
|
||||
{
|
||||
SDL_DestroyTexture(titleTexture);
|
||||
titleTexture = LoadTitleImage(sdlRenderer, titleTexture);
|
||||
}
|
||||
|
||||
previousSelected = gametoplay;
|
||||
|
||||
gui_render();
|
||||
}
|
||||
return -1;
|
||||
}
|
5
src/burner/sdl/sdl2_gui.h
Normal file
5
src/burner/sdl/sdl2_gui.h
Normal file
@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
void gui_init();
|
||||
void gui_exit();
|
||||
int gui_process();
|
35
src/burner/sdl/sdl2_gui_common.cpp
Normal file
35
src/burner/sdl/sdl2_gui_common.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "burner.h"
|
||||
#include "sdl2_gui_common.h"
|
||||
|
||||
int color_result = 0;
|
||||
double color_x = 0.01;
|
||||
double color_y = 0.01;
|
||||
double color_z = 0.01;
|
||||
|
||||
void calcSelectedItemColor()
|
||||
{
|
||||
color_x += randomRange(0.01, 0.02);
|
||||
color_y += randomRange(0.01, 0.07);
|
||||
color_z += randomRange(0.01, 0.09);
|
||||
|
||||
SDL_Color pal[1];
|
||||
pal[0].r = 190 + 64 * sin(color_x + (color_result * 0.004754));
|
||||
pal[0].g = 190 + 64 * sin(color_y + (color_result * 0.006754));
|
||||
pal[0].b = 190 + 64 * sin(color_z + (color_result * 0.005754));
|
||||
color_result+5;
|
||||
|
||||
incolor1(pal);
|
||||
}
|
||||
|
||||
|
||||
float random_gen()
|
||||
{
|
||||
return rand() / (float)RAND_MAX;
|
||||
}
|
||||
|
||||
float randomRange(float low, float high)
|
||||
{
|
||||
float range = high - low;
|
||||
|
||||
return (float)(random_gen() * range) + low;
|
||||
}
|
17
src/burner/sdl/sdl2_gui_common.h
Normal file
17
src/burner/sdl/sdl2_gui_common.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#define fbn_color 0xfe8a71
|
||||
#define select_color 0xffffff
|
||||
#define normal_color 0x1eaab7
|
||||
#define normal_color_parent 0xaebac7
|
||||
#define unavailable_color 0xFF0000
|
||||
#define info_color 0x3a3e3d
|
||||
|
||||
extern double color_x;
|
||||
extern double color_y;
|
||||
extern double color_z;
|
||||
extern int color_result;
|
||||
|
||||
void calcSelectedItemColor();
|
||||
float random_gen();
|
||||
float randomRange(float low, float high);
|
245
src/burner/sdl/sdl2_gui_ingame.cpp
Normal file
245
src/burner/sdl/sdl2_gui_ingame.cpp
Normal file
@ -0,0 +1,245 @@
|
||||
#include "burner.h"
|
||||
#include "sdl2_gui_common.h"
|
||||
|
||||
#if SDL_BYTEORDER != SDL_BIG_ENDIAN
|
||||
const UINT32 amask = 0xff000000;
|
||||
const UINT32 rmask = 0x00ff0000;
|
||||
const UINT32 gmask = 0x0000ff00;
|
||||
const UINT32 bmask = 0x000000ff;
|
||||
#else
|
||||
const UINT32 amask = 0x000000ff;
|
||||
const UINT32 rmask = 0x0000ff00;
|
||||
const UINT32 gmask = 0x00ff0000;
|
||||
const UINT32 bmask = 0xff000000;
|
||||
#endif
|
||||
|
||||
static SDL_Renderer* sdlRenderer = NULL;
|
||||
static SDL_Surface* screenshot = NULL;
|
||||
static SDL_Texture* screenshotTexture = NULL;
|
||||
|
||||
static SDL_Rect title_texture_rect;
|
||||
static SDL_Rect dest_title_texture_rect;
|
||||
|
||||
static int screenW = 0;
|
||||
static int screenH = 0;
|
||||
|
||||
|
||||
struct MenuItem
|
||||
{
|
||||
const char* name; // The filename of the zip file (without extension)
|
||||
int (*menuFunction)();
|
||||
char* (*menuText)();
|
||||
};
|
||||
|
||||
#define MAINMENU 0
|
||||
#define DIPMENU 1
|
||||
#define CONTROLLERMENU 2
|
||||
#define SAVESTATE 3
|
||||
#define LOADSTATE 4
|
||||
#define SCREENSHOT 5
|
||||
#define RESET 6
|
||||
|
||||
// menu item tracking
|
||||
static UINT16 current_menu = MAINMENU;
|
||||
static UINT16 current_selected_item = 0;
|
||||
|
||||
int QuickSave()
|
||||
{
|
||||
QuickState(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int QuickLoad()
|
||||
{
|
||||
QuickState(0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MainMenuSelected()
|
||||
{
|
||||
current_selected_item = 0;
|
||||
current_menu = MAINMENU;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ControllerMenuSelected()
|
||||
{
|
||||
current_selected_item = 0;
|
||||
current_menu = CONTROLLERMENU;
|
||||
//TODO work out UI for controller mappings
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DIPMenuSelected()
|
||||
{
|
||||
current_selected_item = 0;
|
||||
current_menu = DIPMENU;
|
||||
//TODO Load the dips into an array of MenuItems
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BackToGameSelected()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define MAINMENU_COUNT 6
|
||||
|
||||
struct MenuItem mainMenu[MAINMENU_COUNT] =
|
||||
{
|
||||
{"DIP Switches\0", DIPMenuSelected, NULL},
|
||||
{"Controller Options\0", ControllerMenuSelected, NULL},
|
||||
{"Save State\0", QuickSave, NULL},
|
||||
{"Load State\0", QuickLoad, NULL},
|
||||
{"Save Screenshot\0", NULL, NULL},
|
||||
{"Back to Game!\0", BackToGameSelected, NULL},
|
||||
};
|
||||
|
||||
#define DIPMENU_COUNT 1
|
||||
|
||||
struct MenuItem dipMenu[DIPMENU_COUNT] =
|
||||
{
|
||||
{"BACK \0", MainMenuSelected, NULL},
|
||||
};
|
||||
|
||||
#define CONTROLLERMENU_COUNT 1
|
||||
|
||||
struct MenuItem controllerMenu[CONTROLLERMENU_COUNT] =
|
||||
{
|
||||
{"BACK \0", MainMenuSelected, NULL},
|
||||
};
|
||||
|
||||
// menu instance tracking
|
||||
struct MenuItem *current_menu_items = mainMenu;
|
||||
static UINT16 current_item_count = MAINMENU_COUNT;
|
||||
|
||||
void ingame_gui_init()
|
||||
{
|
||||
AudSoundStop();
|
||||
}
|
||||
|
||||
void ingame_gui_exit()
|
||||
{
|
||||
AudSoundPlay();
|
||||
SDL_FreeSurface(screenshot);
|
||||
SDL_DestroyTexture(screenshotTexture);
|
||||
}
|
||||
|
||||
void ingame_gui_render()
|
||||
{
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0x1a, 0x1e, 0x1d, SDL_ALPHA_OPAQUE);
|
||||
SDL_RenderClear(sdlRenderer);
|
||||
SDL_RenderCopy(sdlRenderer, screenshotTexture, &title_texture_rect, &dest_title_texture_rect);
|
||||
incolor(fbn_color, /* unused */ 0);
|
||||
inprint(sdlRenderer, "FinalBurn Neo", 10, 10);
|
||||
inprint(sdlRenderer, "=============", 10, 20);
|
||||
|
||||
switch (current_menu)
|
||||
{
|
||||
case MAINMENU:
|
||||
current_item_count = MAINMENU_COUNT;
|
||||
current_menu_items = mainMenu;
|
||||
break;
|
||||
case DIPMENU:
|
||||
current_item_count = DIPMENU_COUNT;
|
||||
current_menu_items = dipMenu;
|
||||
break;
|
||||
case CONTROLLERMENU:
|
||||
current_item_count = CONTROLLERMENU_COUNT;
|
||||
current_menu_items = controllerMenu;
|
||||
break;
|
||||
}
|
||||
|
||||
for(int i=0; i < current_item_count; i ++)
|
||||
{
|
||||
if (i ==current_selected_item)
|
||||
{
|
||||
calcSelectedItemColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
incolor(normal_color, /* unused */ 0);
|
||||
}
|
||||
inprint(sdlRenderer,current_menu_items[i].name , 10, 30+(10*i));
|
||||
}
|
||||
|
||||
SDL_RenderPresent(sdlRenderer);
|
||||
}
|
||||
|
||||
int ingame_gui_process()
|
||||
{
|
||||
SDL_Event e;
|
||||
|
||||
while (SDL_PollEvent(&e))
|
||||
{
|
||||
if (e.type == SDL_QUIT)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (e.type == SDL_KEYDOWN)
|
||||
{
|
||||
switch (e.key.keysym.sym)
|
||||
{
|
||||
case SDLK_TAB:
|
||||
return 1;
|
||||
break;
|
||||
case SDLK_UP:
|
||||
if (current_selected_item > 0)
|
||||
{
|
||||
current_selected_item--;
|
||||
}
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
if (current_selected_item < current_item_count-1)
|
||||
{
|
||||
current_selected_item++;
|
||||
}
|
||||
break;
|
||||
case SDLK_RETURN:
|
||||
if (current_menu_items[current_selected_item].menuFunction!=NULL)
|
||||
{
|
||||
int (*menuFunction)();
|
||||
menuFunction = current_menu_items[current_selected_item].menuFunction;
|
||||
return menuFunction();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ingame_gui_start(SDL_Renderer* renderer)
|
||||
{
|
||||
int finished = 0;
|
||||
|
||||
sdlRenderer = renderer;
|
||||
SDL_GetRendererOutputSize(sdlRenderer, &screenW, &screenH);
|
||||
|
||||
screenshot = SDL_CreateRGBSurface(0, screenW, screenH, 32, rmask, gmask, bmask, amask);
|
||||
SDL_RenderReadPixels(renderer, NULL, SDL_PIXELFORMAT_ARGB8888, screenshot->pixels, screenshot->pitch);
|
||||
screenshotTexture = SDL_CreateTextureFromSurface(renderer, screenshot);
|
||||
SDL_FreeSurface(screenshot);
|
||||
screenshot = NULL;
|
||||
|
||||
title_texture_rect.x = 0; //the x coordinate
|
||||
title_texture_rect.y = 0; // the y coordinate
|
||||
title_texture_rect.w = screenW; //the width of the texture
|
||||
title_texture_rect.h = screenH; //the height of the texture
|
||||
|
||||
dest_title_texture_rect.x = 150; //the x coordinate
|
||||
dest_title_texture_rect.y = 0; // the y coordinate
|
||||
dest_title_texture_rect.w = 50; //the width of the texture
|
||||
dest_title_texture_rect.h = 50; //the height of the texture
|
||||
|
||||
ingame_gui_init();
|
||||
|
||||
while (!finished)
|
||||
{
|
||||
finished = ingame_gui_process();
|
||||
ingame_gui_render();
|
||||
}
|
||||
|
||||
ingame_gui_exit();
|
||||
|
||||
}
|
246
src/burner/sdl/sdl2_inprint.cpp
Normal file
246
src/burner/sdl/sdl2_inprint.cpp
Normal file
@ -0,0 +1,246 @@
|
||||
//SDL_inprint (c) driedfruit https://github.com/driedfruit/SDL_inprint
|
||||
// modified for use in FBNeo
|
||||
|
||||
#include "burner.h"
|
||||
|
||||
#define inline_font_width 128
|
||||
#define inline_font_height 64
|
||||
static unsigned char inline_font_bits[] = {
|
||||
0x01, 0x66, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0x39, 0xa5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39, 0x18, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x39,
|
||||
0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x19, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x98, 0xa5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x66, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xbf,
|
||||
0xe7, 0x99, 0x01, 0x83, 0xff, 0xe7, 0xe7, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xf8, 0x8f, 0xc3, 0x99, 0x24, 0x39, 0xff, 0xc3, 0xc3, 0xe7, 0xe7, 0xf3,
|
||||
0xff, 0xff, 0xff, 0xff, 0xe0, 0x83, 0x81, 0x99, 0x24, 0xe3, 0xff, 0x81, 0x81,
|
||||
0xe7, 0xcf, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x80, 0x80, 0xe7, 0x99, 0x21, 0xc9,
|
||||
0xff, 0xe7, 0xe7, 0xe7, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x83, 0xe7,
|
||||
0x99, 0x27, 0xc9, 0x81, 0x81, 0xe7, 0x81, 0xcf, 0xf9, 0xff, 0xff, 0xff, 0xff,
|
||||
0xf8, 0x8f, 0x81, 0xff, 0x27, 0xe3, 0x81, 0xc3, 0xe7, 0xc3, 0xe7, 0xf3, 0xff,
|
||||
0xff, 0xff, 0xff, 0xfe, 0xbf, 0xc3, 0x99, 0x27, 0xcc, 0x81, 0xe7, 0xe7, 0xe7,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xe1, 0xff,
|
||||
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xc9, 0xc9,
|
||||
0xf3, 0xff, 0xe3, 0xf9, 0xe7, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff,
|
||||
0xe1, 0xc9, 0xc9, 0xc1, 0x9c, 0xc9, 0xf9, 0xf3, 0xf3, 0x99, 0xf3, 0xff, 0xff,
|
||||
0xff, 0xcf, 0xff, 0xe1, 0xc9, 0x80, 0xfc, 0xcc, 0xe3, 0xfc, 0xf9, 0xe7, 0xc3,
|
||||
0xf3, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xf3, 0xff, 0xc9, 0xe1, 0xe7, 0x91, 0xff,
|
||||
0xf9, 0xe7, 0x00, 0xc0, 0xff, 0xc0, 0xff, 0xf3, 0xff, 0xf3, 0xff, 0x80, 0xcf,
|
||||
0xf3, 0xc4, 0xff, 0xf9, 0xe7, 0xc3, 0xf3, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff,
|
||||
0xff, 0xc9, 0xe0, 0x99, 0xcc, 0xff, 0xf3, 0xf3, 0x99, 0xf3, 0xf3, 0xff, 0xf3,
|
||||
0xfc, 0xff, 0xf3, 0xff, 0xc9, 0xf3, 0x9c, 0x91, 0xff, 0xe7, 0xf9, 0xff, 0xff,
|
||||
0xf3, 0xff, 0xf3, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xc1, 0xf3, 0xe1, 0xe1, 0xc7, 0xc0,
|
||||
0xe3, 0xc0, 0xe1, 0xe1, 0xff, 0xff, 0xe7, 0xff, 0xf9, 0xe1, 0x9c, 0xf1, 0xcc,
|
||||
0xcc, 0xc3, 0xfc, 0xf9, 0xcc, 0xcc, 0xcc, 0xf3, 0xf3, 0xf3, 0xff, 0xf3, 0xcc,
|
||||
0x8c, 0xf3, 0xcf, 0xcf, 0xc9, 0xe0, 0xfc, 0xcf, 0xcc, 0xcc, 0xf3, 0xf3, 0xf9,
|
||||
0xc0, 0xe7, 0xcf, 0x84, 0xf3, 0xe3, 0xe3, 0xcc, 0xcf, 0xe0, 0xe7, 0xe1, 0xc1,
|
||||
0xff, 0xff, 0xfc, 0xff, 0xcf, 0xe7, 0x90, 0xf3, 0xf9, 0xcf, 0x80, 0xcf, 0xcc,
|
||||
0xf3, 0xcc, 0xcf, 0xff, 0xff, 0xf9, 0xff, 0xe7, 0xf3, 0x98, 0xf3, 0xcc, 0xcc,
|
||||
0xcf, 0xcc, 0xcc, 0xf3, 0xcc, 0xe7, 0xf3, 0xf3, 0xf3, 0xc0, 0xf3, 0xff, 0xc1,
|
||||
0xc0, 0xc0, 0xe1, 0x87, 0xe1, 0xe1, 0xf3, 0xe1, 0xf1, 0xf3, 0xf3, 0xe7, 0xff,
|
||||
0xf9, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xf9, 0xff, 0xff, 0xff, 0xff, 0xc1, 0xf3, 0xc0, 0xc3, 0xe0, 0x80, 0x80, 0xc3,
|
||||
0xcc, 0xe1, 0x87, 0x98, 0xf0, 0x9c, 0x9c, 0xe3, 0x9c, 0xe1, 0x99, 0x99, 0xc9,
|
||||
0xb9, 0xb9, 0x99, 0xcc, 0xf3, 0xcf, 0x99, 0xf9, 0x88, 0x98, 0xc9, 0x84, 0xcc,
|
||||
0x99, 0xfc, 0x99, 0xe9, 0xe9, 0xfc, 0xcc, 0xf3, 0xcf, 0xc9, 0xf9, 0x80, 0x90,
|
||||
0x9c, 0x84, 0xcc, 0xc1, 0xfc, 0x99, 0xe1, 0xe1, 0xfc, 0xc0, 0xf3, 0xcf, 0xe1,
|
||||
0xf9, 0x80, 0x84, 0x9c, 0x84, 0xc0, 0x99, 0xfc, 0x99, 0xe9, 0xe9, 0x8c, 0xcc,
|
||||
0xf3, 0xcc, 0xc9, 0xb9, 0x94, 0x8c, 0x9c, 0xfc, 0xcc, 0x99, 0x99, 0xc9, 0xb9,
|
||||
0xf9, 0x99, 0xcc, 0xf3, 0xcc, 0x99, 0x99, 0x9c, 0x9c, 0xc9, 0xe1, 0xcc, 0xc0,
|
||||
0xc3, 0xe0, 0x80, 0xf0, 0x83, 0xcc, 0xe1, 0xe1, 0x98, 0x80, 0x9c, 0x9c, 0xe3,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xc0, 0xe1, 0xc0, 0xe1, 0xc0, 0xcc, 0xcc, 0x9c, 0x9c, 0xcc,
|
||||
0x80, 0xe1, 0xfc, 0xe1, 0xf7, 0xff, 0x99, 0xcc, 0x99, 0xcc, 0xd2, 0xcc, 0xcc,
|
||||
0x9c, 0x9c, 0xcc, 0x9c, 0xf9, 0xf9, 0xe7, 0xe3, 0xff, 0x99, 0xcc, 0x99, 0xf8,
|
||||
0xf3, 0xcc, 0xcc, 0x9c, 0xc9, 0xcc, 0xce, 0xf9, 0xf3, 0xe7, 0xc9, 0xff, 0xc1,
|
||||
0xcc, 0xc1, 0xf1, 0xf3, 0xcc, 0xcc, 0x94, 0xe3, 0xe1, 0xe7, 0xf9, 0xe7, 0xe7,
|
||||
0x9c, 0xff, 0xf9, 0xc4, 0xc9, 0xc7, 0xf3, 0xcc, 0xcc, 0x80, 0xe3, 0xf3, 0xb3,
|
||||
0xf9, 0xcf, 0xe7, 0xff, 0xff, 0xf9, 0xe1, 0x99, 0xcc, 0xf3, 0xcc, 0xe1, 0x88,
|
||||
0xc9, 0xf3, 0x99, 0xf9, 0x9f, 0xe7, 0xff, 0xff, 0xf0, 0xc7, 0x98, 0xe1, 0xe1,
|
||||
0xc0, 0xf3, 0x9c, 0x9c, 0xe1, 0x80, 0xe1, 0xbf, 0xe1, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0xf3, 0xff, 0xf8, 0xff, 0xc7, 0xff, 0xe3, 0xff, 0xf8, 0xf3, 0xcf, 0xf8,
|
||||
0xf1, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xf9, 0xff, 0xcf, 0xff, 0xc9, 0xff, 0xf9,
|
||||
0xff, 0xff, 0xf9, 0xf3, 0xff, 0xff, 0xff, 0xe7, 0xe1, 0xf9, 0xe1, 0xcf, 0xe1,
|
||||
0xf9, 0x91, 0xc9, 0xf1, 0xcf, 0x99, 0xf3, 0xcc, 0xe0, 0xe1, 0xff, 0xcf, 0xc1,
|
||||
0xcc, 0xc1, 0xcc, 0xf0, 0xcc, 0x91, 0xf3, 0xcf, 0xc9, 0xf3, 0x80, 0xcc, 0xcc,
|
||||
0xff, 0xc1, 0x99, 0xfc, 0xcc, 0xc0, 0xf9, 0xcc, 0x99, 0xf3, 0xcf, 0xe1, 0xf3,
|
||||
0x80, 0xcc, 0xcc, 0xff, 0xcc, 0x99, 0xcc, 0xcc, 0xfc, 0xf9, 0xc1, 0x99, 0xf3,
|
||||
0xcc, 0xc9, 0xf3, 0x94, 0xcc, 0xcc, 0xff, 0x91, 0xc4, 0xe1, 0x91, 0xe1, 0xf0,
|
||||
0xcf, 0x98, 0xe1, 0xcc, 0x98, 0xe1, 0x9c, 0xcc, 0xe1, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xe7, 0xf8,
|
||||
0x91, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xf3, 0xe7, 0xf3, 0xc4, 0xf7, 0xc4, 0x91, 0xc4, 0xc1, 0xc1, 0xcc, 0xcc, 0x9c,
|
||||
0x9c, 0xcc, 0xc0, 0xf3, 0xe7, 0xf3, 0xff, 0xe3, 0x99, 0xcc, 0x91, 0xfc, 0xf3,
|
||||
0xcc, 0xcc, 0x94, 0xc9, 0xcc, 0xe6, 0xf8, 0xff, 0xc7, 0xff, 0xc9, 0x99, 0xcc,
|
||||
0x99, 0xe1, 0xf3, 0xcc, 0xcc, 0x80, 0xe3, 0xcc, 0xf3, 0xf3, 0xe7, 0xf3, 0xff,
|
||||
0x9c, 0xc1, 0xc1, 0xf9, 0xcf, 0xd3, 0xcc, 0xe1, 0x80, 0xc9, 0xc1, 0xd9, 0xf3,
|
||||
0xe7, 0xf3, 0xff, 0x9c, 0xf9, 0xcf, 0xf0, 0xe0, 0xe7, 0x91, 0xf3, 0xc9, 0x9c,
|
||||
0xcf, 0xc0, 0xc7, 0xe7, 0xf8, 0xff, 0x80, 0xf0, 0x87, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
};
|
||||
|
||||
#define CHARACTERS_PER_ROW 16 /* I like 16 x 8 fontsets. */
|
||||
#define CHARACTERS_PER_COLUMN 8 /* 128 x 1 is another popular format. */
|
||||
|
||||
static SDL_Renderer* selected_renderer = NULL;
|
||||
static SDL_Texture* inline_font = NULL;
|
||||
static SDL_Texture* selected_font = NULL;
|
||||
static Uint16 selected_font_w, selected_font_h;
|
||||
|
||||
void prepare_inline_font()
|
||||
{
|
||||
Uint32* pix_ptr, tmp;
|
||||
int i, len, j;
|
||||
SDL_Surface* surface;
|
||||
Uint32 colors[2];
|
||||
|
||||
selected_font_w = inline_font_width;
|
||||
selected_font_h = inline_font_height;
|
||||
|
||||
if (inline_font != NULL)
|
||||
{
|
||||
selected_font = inline_font; return;
|
||||
}
|
||||
|
||||
surface = SDL_CreateRGBSurface(0, inline_font_width, inline_font_height, 32,
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
|
||||
#else
|
||||
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
|
||||
#endif
|
||||
);
|
||||
colors[0] = SDL_MapRGBA(surface->format, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
colors[1] = SDL_MapRGBA(surface->format, 0x00, 0x00, 0x00, 0x00 /* or 0xFF, to have bg-color */);
|
||||
|
||||
/* Get pointer to pixels and array length */
|
||||
pix_ptr = (Uint32*)surface->pixels;
|
||||
len = surface->h * surface->w / 8;
|
||||
|
||||
/* Copy */
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
tmp = (Uint8)inline_font_bits[i];
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
Uint8 mask = (0x01 << j);
|
||||
pix_ptr[i * 8 + j] = colors[(tmp & mask) >> j];
|
||||
}
|
||||
}
|
||||
|
||||
inline_font = SDL_CreateTextureFromSurface(selected_renderer, surface);
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
selected_font = inline_font;
|
||||
}
|
||||
|
||||
void kill_inline_font(void)
|
||||
{
|
||||
SDL_DestroyTexture(inline_font); inline_font = NULL;
|
||||
}
|
||||
|
||||
void inrenderer(SDL_Renderer* renderer)
|
||||
{
|
||||
selected_renderer = renderer;
|
||||
}
|
||||
|
||||
void infont(SDL_Texture* font)
|
||||
{
|
||||
Uint32 format;
|
||||
int access;
|
||||
int w, h;
|
||||
|
||||
if (font == NULL)
|
||||
{
|
||||
prepare_inline_font(); return;
|
||||
}
|
||||
|
||||
SDL_QueryTexture(font, &format, &access, &w, &h);
|
||||
|
||||
selected_font = font;
|
||||
selected_font_w = w;
|
||||
selected_font_h = h;
|
||||
}
|
||||
|
||||
void incolor1(SDL_Color* color)
|
||||
{
|
||||
SDL_SetTextureColorMod(selected_font, color->r, color->g, color->b);
|
||||
}
|
||||
|
||||
void incolor(Uint32 fore, Uint32 unused) /* Color must be in 0x00RRGGBB format ! */
|
||||
{
|
||||
SDL_Color pal[1];
|
||||
|
||||
pal[0].r = (Uint8)((fore & 0x00FF0000) >> 16);
|
||||
pal[0].g = (Uint8)((fore & 0x0000FF00) >> 8);
|
||||
pal[0].b = (Uint8)((fore & 0x000000FF));
|
||||
SDL_SetTextureColorMod(selected_font, pal[0].r, pal[0].g, pal[0].b);
|
||||
}
|
||||
|
||||
void inprint(SDL_Renderer* dst, const char* str, Uint32 x, Uint32 y)
|
||||
{
|
||||
SDL_Rect s_rect;
|
||||
SDL_Rect d_rect;
|
||||
|
||||
if (str == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
d_rect.x = x;
|
||||
d_rect.y = y;
|
||||
s_rect.w = selected_font_w / CHARACTERS_PER_ROW;
|
||||
s_rect.h = selected_font_h / CHARACTERS_PER_COLUMN;
|
||||
d_rect.w = s_rect.w;
|
||||
d_rect.h = s_rect.h;
|
||||
|
||||
if (dst == NULL)
|
||||
{
|
||||
dst = selected_renderer;
|
||||
}
|
||||
|
||||
for (; *str; str++)
|
||||
{
|
||||
int id = (int)*str;
|
||||
#if (CHARACTERS_PER_COLUMN != 1)
|
||||
int row = id / CHARACTERS_PER_ROW;
|
||||
int col = id % CHARACTERS_PER_ROW;
|
||||
s_rect.x = col * s_rect.w;
|
||||
s_rect.y = row * s_rect.h;
|
||||
#else
|
||||
s_rect.x = id * s_rect.w;
|
||||
s_rect.y = 0;
|
||||
#endif
|
||||
if (id == '\n')
|
||||
{
|
||||
d_rect.x = x;
|
||||
d_rect.y += s_rect.h;
|
||||
continue;
|
||||
}
|
||||
SDL_RenderCopy(dst, selected_font, &s_rect, &d_rect);
|
||||
d_rect.x += s_rect.w;
|
||||
}
|
||||
}
|
||||
|
||||
void inprint_shadowed(SDL_Renderer* dst, const char* str, Uint32 x, Uint32 y)
|
||||
{
|
||||
SDL_Color pal[1];
|
||||
|
||||
SDL_GetTextureColorMod(selected_font, &pal[0].r, &pal[0].g, &pal[0].b);
|
||||
incolor(0x000000, 0);
|
||||
inprint(dst, str, x + 2, y + 2);
|
||||
SDL_SetTextureColorMod(selected_font, pal[0].r, pal[0].g, pal[0].b);
|
||||
inprint(dst, str, x, y);
|
||||
}
|
||||
|
||||
SDL_Texture* get_inline_font(void)
|
||||
{
|
||||
return selected_font;
|
||||
}
|
18
src/burner/sdl/sdl2_inprint.h
Normal file
18
src/burner/sdl/sdl2_inprint.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef SDL2_inprint_h
|
||||
#define SDL2_inprint_h
|
||||
|
||||
#include "burner.h"
|
||||
|
||||
|
||||
extern void prepare_inline_font(void);
|
||||
extern void kill_inline_font(void);
|
||||
|
||||
extern void inrenderer(SDL_Renderer* renderer);
|
||||
extern void infont(SDL_Texture* font);
|
||||
extern void incolor1(SDL_Color* color);
|
||||
extern void incolor(Uint32 color, Uint32 unused); /* Color must be in 0x00RRGGBB format ! */
|
||||
extern void inprint(SDL_Renderer* dst, const char* str, Uint32 x, Uint32 y);
|
||||
extern void inprint_shadowed(SDL_Renderer* dst, const char* str, Uint32 x, Uint32 y);
|
||||
extern SDL_Texture* get_inline_font(void);
|
||||
|
||||
#endif /* SDL2_inprint_h */
|
@ -1,27 +1,39 @@
|
||||
// State dialog module
|
||||
#include "burner.h"
|
||||
|
||||
int bDrvSaveAll=0;
|
||||
|
||||
|
||||
// The automatic save
|
||||
int StatedAuto(int bSave)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void CreateStateName(int nSlot)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int StatedLoad(int nSlot) // int nSlot = 0
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int StatedSave(int nSlot) // int nSlot = 0
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
#include "burner.h"
|
||||
|
||||
/// Save States
|
||||
#ifdef BUILD_SDL2
|
||||
static char* szSDLSavePath = NULL;
|
||||
#endif
|
||||
|
||||
// The automatic save
|
||||
int QuickState(int bSave)
|
||||
{
|
||||
static TCHAR szName[MAX_PATH] = _T("");
|
||||
int nRet;
|
||||
|
||||
#if defined(BUILD_SDL2) && !defined(SDL_WINDOWS)
|
||||
if (szSDLSavePath == NULL)
|
||||
{
|
||||
szSDLSavePath = SDL_GetPrefPath("fbneo", "states");
|
||||
}
|
||||
|
||||
snprintf(szName, MAX_PATH, "%squick_%s.fs", szSDLSavePath, BurnDrvGetText(DRV_NAME));
|
||||
#else
|
||||
|
||||
_stprintf(szName, _T("config/games/quick_%s.fs"), BurnDrvGetText(DRV_NAME));
|
||||
|
||||
#endif
|
||||
|
||||
if (bSave == 0)
|
||||
{
|
||||
nRet = BurnStateLoad(szName, 1, NULL); // Load ram
|
||||
UpdateMessage("Quicksave: State Loaded");
|
||||
}
|
||||
else
|
||||
{
|
||||
nRet = BurnStateSave(szName, 1); // Save ram
|
||||
UpdateMessage("Quicksave: State Saved");
|
||||
}
|
||||
|
||||
return nRet;
|
||||
}
|
||||
|
@ -1,24 +1,25 @@
|
||||
// StringSet C++ class
|
||||
#include "burner.h"
|
||||
|
||||
int __cdecl StringSet::Add(TCHAR* szFormat,...)
|
||||
int __cdecl StringSet::Add(TCHAR* szFormat, ...)
|
||||
{
|
||||
TCHAR szAdd[256];
|
||||
int nAddLen = 0;
|
||||
TCHAR szAdd[256];
|
||||
int nAddLen = 0;
|
||||
TCHAR* NewMem;
|
||||
va_list Arg;
|
||||
|
||||
va_start(Arg, szFormat);
|
||||
_vstprintf(szAdd, szFormat, Arg);
|
||||
|
||||
nAddLen = _tcslen(szAdd); // find out the length of the new text
|
||||
nAddLen = _tcslen(szAdd); // find out the length of the new text
|
||||
NewMem = (TCHAR*)realloc(szText, (nLen + nAddLen + 1) * sizeof(TCHAR));
|
||||
if (NewMem) {
|
||||
if (NewMem)
|
||||
{
|
||||
szText = NewMem;
|
||||
// copy the new text to the end
|
||||
_tcsncpy(szText + nLen, szAdd, nAddLen);
|
||||
nLen += nAddLen;
|
||||
szText[nLen] = 0; // zero-terminate
|
||||
szText[nLen] = 0; // zero-terminate
|
||||
}
|
||||
|
||||
va_end(Arg);
|
||||
@ -30,8 +31,9 @@ int StringSet::Reset()
|
||||
{
|
||||
// Reset the text
|
||||
nLen = 0;
|
||||
szText= (TCHAR*)realloc(szText, sizeof(TCHAR));
|
||||
if (szText == NULL) {
|
||||
szText = (TCHAR*)realloc(szText, sizeof(TCHAR));
|
||||
if (szText == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
szText[0] = 0;
|
||||
@ -43,10 +45,10 @@ StringSet::StringSet()
|
||||
{
|
||||
szText = NULL;
|
||||
nLen = 0;
|
||||
Reset(); // reset string to nothing
|
||||
Reset(); // reset string to nothing
|
||||
}
|
||||
|
||||
StringSet::~StringSet()
|
||||
{
|
||||
realloc(szText, 0); // Free BZip text
|
||||
realloc(szText, 0); // Free BZip text
|
||||
}
|
||||
|
@ -1,29 +1,29 @@
|
||||
#include "burner.h"
|
||||
|
||||
TCHAR szAppPreviewsPath[MAX_PATH] = _T("support\\previews\\");
|
||||
TCHAR szAppTitlesPath[MAX_PATH] = _T("support\\titles\\");
|
||||
TCHAR szAppSelectPath[MAX_PATH] = _T("support\\select\\");
|
||||
TCHAR szAppVersusPath[MAX_PATH] = _T("support\\versus\\");
|
||||
TCHAR szAppHowtoPath[MAX_PATH] = _T("support\\howto\\");
|
||||
TCHAR szAppScoresPath[MAX_PATH] = _T("support\\scores\\");
|
||||
TCHAR szAppBossesPath[MAX_PATH] = _T("support\\bosses\\");
|
||||
TCHAR szAppGameoverPath[MAX_PATH] = _T("support\\gameover\\");
|
||||
TCHAR szAppFlyersPath[MAX_PATH] = _T("support\\flyers\\");
|
||||
TCHAR szAppMarqueesPath[MAX_PATH] = _T("support\\marquees\\");
|
||||
TCHAR szAppControlsPath[MAX_PATH] = _T("support\\controls\\");
|
||||
TCHAR szAppCabinetsPath[MAX_PATH] = _T("support\\cabinets\\");
|
||||
TCHAR szAppPCBsPath[MAX_PATH] = _T("support\\pcbs\\");
|
||||
TCHAR szAppCheatsPath[MAX_PATH] = _T("support\\cheats\\");
|
||||
TCHAR szAppHistoryPath[MAX_PATH] = _T("support\\");
|
||||
TCHAR szAppListsPath[MAX_PATH] = _T("support\\lists\\lst\\");
|
||||
TCHAR szAppDatListsPath[MAX_PATH] = _T("support\\lists\\dat\\");
|
||||
TCHAR szAppIpsPath[MAX_PATH] = _T("support\\ips\\");
|
||||
TCHAR szAppIconsPath[MAX_PATH] = _T("support\\icons\\");
|
||||
TCHAR szAppArchivesPath[MAX_PATH] = _T("support\\archives\\");
|
||||
TCHAR szAppHiscorePath[MAX_PATH] = _T("support\\hiscores\\");
|
||||
TCHAR szAppSamplesPath[MAX_PATH] = _T("support\\samples\\");
|
||||
TCHAR szAppPreviewsPath[MAX_PATH] = _T("support/previews/");
|
||||
TCHAR szAppTitlesPath[MAX_PATH] = _T("support/titles/");
|
||||
TCHAR szAppCheatsPath[MAX_PATH] = _T("support/cheats/");
|
||||
TCHAR szAppHiscorePath[MAX_PATH] = _T("support/hiscores/");
|
||||
TCHAR szAppSamplesPath[MAX_PATH] = _T("support/samples/");
|
||||
TCHAR szAppHDDPath[MAX_PATH] = _T("support/hdd/");
|
||||
TCHAR szAppBlendPath[MAX_PATH] = _T("support\\blend\\");
|
||||
TCHAR szAppIpsPath[MAX_PATH] = _T("support/ips/");
|
||||
TCHAR szAppIconsPath[MAX_PATH] = _T("support/icons/");
|
||||
TCHAR szAppBlendPath[MAX_PATH] = _T("support/blend/");
|
||||
TCHAR szAppSelectPath[MAX_PATH] = _T("support/select/");
|
||||
TCHAR szAppVersusPath[MAX_PATH] = _T("support/versus/");
|
||||
TCHAR szAppHowtoPath[MAX_PATH] = _T("support/howto/");
|
||||
TCHAR szAppScoresPath[MAX_PATH] = _T("support/scores/");
|
||||
TCHAR szAppBossesPath[MAX_PATH] = _T("support/bosses/");
|
||||
TCHAR szAppGameoverPath[MAX_PATH] = _T("support/gameover/");
|
||||
TCHAR szAppFlyersPath[MAX_PATH] = _T("support/flyers/");
|
||||
TCHAR szAppMarqueesPath[MAX_PATH] = _T("support/marquees/");
|
||||
TCHAR szAppControlsPath[MAX_PATH] = _T("support/cpanel/");
|
||||
TCHAR szAppCabinetsPath[MAX_PATH] = _T("support/cabinets/");
|
||||
TCHAR szAppPCBsPath[MAX_PATH] = _T("support/pcbs/");
|
||||
TCHAR szAppHistoryPath[MAX_PATH] = _T("support/history/");
|
||||
TCHAR szAppEEPROMPath[MAX_PATH] = _T("config/games/");
|
||||
TCHAR szAppListsPath[MAX_PATH] = _T("support/lists/lst/");
|
||||
TCHAR szAppDatListsPath[MAX_PATH] = _T("support/lists/dat/");
|
||||
TCHAR szAppArchivesPath[MAX_PATH] = _T("support/archives/");
|
||||
|
||||
TCHAR szCheckIconsPath[MAX_PATH];
|
||||
|
@ -2,56 +2,56 @@
|
||||
#ifdef _UNICODE
|
||||
//TODO: bah
|
||||
#include <wchar.h>
|
||||
#define __TEXT(q) L##q
|
||||
#define __TEXT(q) L ## q
|
||||
|
||||
typedef wchar_t TCHAR;
|
||||
typedef wchar_t _TCHAR;
|
||||
typedef wchar_t TCHAR;
|
||||
typedef wchar_t _TCHAR;
|
||||
|
||||
#else
|
||||
|
||||
#define __TEXT(q) q
|
||||
#define __TEXT(q) q
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
typedef char TCHAR;
|
||||
typedef char _TCHAR;
|
||||
typedef char TCHAR;
|
||||
typedef char _TCHAR;
|
||||
#endif
|
||||
|
||||
#define _tcslen strlen
|
||||
#define _tcscpy strcpy
|
||||
#define _tcsncpy strncpy
|
||||
#define _tcslen strlen
|
||||
#define _tcscpy strcpy
|
||||
#define _tcsncpy strncpy
|
||||
|
||||
#define _tprintf printf
|
||||
#define _vstprintf vsprintf
|
||||
#define _vsntprintf vsnprintf
|
||||
#define _stprintf sprintf
|
||||
#define _sntprintf snprintf
|
||||
#define _ftprintf fprintf
|
||||
#define _tsprintf sprintf
|
||||
#define _tprintf printf
|
||||
#define _vstprintf vsprintf
|
||||
#define _vsntprintf vsnprintf
|
||||
#define _stprintf sprintf
|
||||
#define _sntprintf snprintf
|
||||
#define _ftprintf fprintf
|
||||
#define _tsprintf sprintf
|
||||
|
||||
#define _tcscmp strcmp
|
||||
#define _tcsncmp strncmp
|
||||
#define _tcsicmp strcasecmp
|
||||
#define _tcsnicmp strncasecmp
|
||||
#define _tcstol strtol
|
||||
#define _tcsrchr strrchr
|
||||
#define _tcsstr strstr
|
||||
#define _tcscmp strcmp
|
||||
#define _tcsncmp strncmp
|
||||
#define _tcsicmp strcasecmp
|
||||
#define _tcsnicmp strncasecmp
|
||||
#define _tcstol strtol
|
||||
#define _tcsrchr strrchr
|
||||
#define _tcsstr strstr
|
||||
|
||||
#define _fgetts fgets
|
||||
#define _fputts fputs
|
||||
#define _fgetts fgets
|
||||
#define _fputts fputs
|
||||
#define _fputtc fputc
|
||||
|
||||
#define _istspace isspace
|
||||
#define _istspace isspace
|
||||
|
||||
#define _tfopen fopen
|
||||
#define _tfopen fopen
|
||||
|
||||
#define _stricmp strcasecmp
|
||||
#define stricmp strcasecmp
|
||||
#define _strnicmp strncmp
|
||||
#define _stricmp strcasecmp
|
||||
#define stricmp strcasecmp
|
||||
#define _strnicmp strncmp
|
||||
|
||||
// FBA function, change this!
|
||||
#define dprintf printf
|
||||
#define dprintf printf
|
||||
|
||||
#endif
|
||||
|
||||
#define _TEXT(x) __TEXT(x)
|
||||
#define _T(x) __TEXT(x)
|
||||
|
||||
#define _T(x) __TEXT(x)
|
||||
|
@ -792,7 +792,7 @@ static int AppInit()
|
||||
|
||||
// Write a clrmame dat file if we are verifying roms
|
||||
#if defined (ROM_VERIFY)
|
||||
create_datfile(_T("fba.dat"), 0);
|
||||
create_datfile(_T("fbneo.dat"), 0);
|
||||
#endif
|
||||
|
||||
bNumlockStatus = SetNumLock(false);
|
||||
|
@ -688,4 +688,3 @@ int RunMessageLoop()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,11 @@ void mips3::tlb_init()
|
||||
m_tlb = new tlb_entry[m_tlb_entries];
|
||||
}
|
||||
|
||||
void mips3::tlb_exit()
|
||||
{
|
||||
delete[] m_tlb;
|
||||
}
|
||||
|
||||
void mips3::tlb_flush()
|
||||
{
|
||||
for (int i = 0; i < m_tlb_entries; i++) {
|
||||
|
@ -41,6 +41,7 @@ mips3::mips3() : m_tlb_entries(48)
|
||||
|
||||
mips3::~mips3()
|
||||
{
|
||||
tlb_exit();
|
||||
}
|
||||
|
||||
void mips3::reset()
|
||||
|
@ -125,6 +125,7 @@ private:
|
||||
bool check_breakpoint();
|
||||
#endif
|
||||
void tlb_init();
|
||||
void tlb_exit();
|
||||
void tlb_flush();
|
||||
void cop0_reset();
|
||||
void cop0_execute(uint32_t opcode);
|
||||
|
@ -21,7 +21,7 @@ static UINT32 nAudActive = 0;
|
||||
extern struct AudOut AudOutXAudio2;
|
||||
#elif defined (BUILD_MACOS)
|
||||
extern struct AudOut AudOutMacOS;
|
||||
#elif defined (BUILD_SDL)
|
||||
#elif defined (BUILD_SDL) || defined (BUILD_SDL2)
|
||||
extern struct AudOut AudOutSDL;
|
||||
#elif defined (_XBOX)
|
||||
extern struct AudOut AudOutXAudio2;
|
||||
@ -39,7 +39,7 @@ static struct AudOut *pAudOut[]=
|
||||
&AudOutXAudio2,
|
||||
#elif defined (BUILD_MACOS)
|
||||
&AudOutMacOS,
|
||||
#elif defined (BUILD_SDL)
|
||||
#elif defined (BUILD_SDL) || defined (BUILD_SDL2)
|
||||
&AudOutSDL,
|
||||
#elif defined (_XBOX)
|
||||
&AudOutXAudio2,
|
||||
@ -79,7 +79,7 @@ INT32 AudSoundInit()
|
||||
if (nAudSelect >= AUD_LEN) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
nAudActive = nAudSelect;
|
||||
|
||||
if ((nRet = pAudOut[nAudActive]->SoundInit()) == 0) {
|
||||
@ -102,12 +102,12 @@ INT32 AudSoundPlay()
|
||||
if (!bAudOkay || nAudActive >= AUD_LEN) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
INT32 nRet = pAudOut[nAudActive]->SoundPlay();
|
||||
if (!nRet) {
|
||||
bAudPlaying = true;
|
||||
}
|
||||
|
||||
|
||||
return nRet;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ INT32 AudSoundStop()
|
||||
if (nAudActive >= AUD_LEN) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bAudPlaying = false;
|
||||
|
||||
return pAudOut[nAudActive]->SoundStop();
|
||||
@ -125,16 +125,16 @@ INT32 AudSoundStop()
|
||||
INT32 AudSoundExit()
|
||||
{
|
||||
IntInfoFree(&AudInfo);
|
||||
|
||||
|
||||
if (!bAudOkay || nAudActive >= AUD_LEN) {
|
||||
return 1;
|
||||
}
|
||||
bAudOkay = false;
|
||||
|
||||
INT32 nRet = pAudOut[nAudActive]->SoundExit();
|
||||
|
||||
|
||||
nAudActive = 0;
|
||||
|
||||
|
||||
return nRet;
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ INT32 AudSelect(UINT32 nPlugIn)
|
||||
nAudSelect = nPlugIn;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,10 @@
|
||||
|
||||
static unsigned int nSoundFps;
|
||||
|
||||
extern int delay_ticks(int ticks);
|
||||
|
||||
int nSDLVolume = SDL_MIX_MAXVOLUME;
|
||||
int (*GetNextSound)(int); // Callback used to request more sound
|
||||
int (*GetNextSound)(int); // Callback used to request more sound
|
||||
|
||||
static SDL_AudioSpec audiospec;
|
||||
|
||||
@ -19,47 +21,44 @@ static int nAudLoopLen;
|
||||
|
||||
void audiospec_callback(void* /* data */, Uint8* stream, int len)
|
||||
{
|
||||
// dprintf(_T("audiospec_callback %i"), len);
|
||||
|
||||
#ifdef BUILD_SDL2
|
||||
SDL_memset(stream, 0, len);
|
||||
#endif
|
||||
int end = nSDLPlayPos + len;
|
||||
if (end > nAudLoopLen) {
|
||||
|
||||
// dprintf(_T(" %i - %i"), nSDLPlayPos, nSDLPlayPos + nAudLoopLen - nSDLPlayPos);
|
||||
|
||||
if (end > nAudLoopLen)
|
||||
{
|
||||
SDL_MixAudio(stream, (Uint8*)SDLAudBuffer + nSDLPlayPos, nAudLoopLen - nSDLPlayPos, nSDLVolume);
|
||||
end -= nAudLoopLen;
|
||||
|
||||
// dprintf(_T(", %i - %i (%i)"), 0, end, nAudLoopLen - nSDLPlayPos + end);
|
||||
|
||||
SDL_MixAudio(stream + nAudLoopLen - nSDLPlayPos, (Uint8*)SDLAudBuffer, end, nSDLVolume);
|
||||
nSDLPlayPos = end;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_MixAudio(stream, (Uint8*)SDLAudBuffer + nSDLPlayPos, len, nSDLVolume);
|
||||
nSDLPlayPos = end;
|
||||
|
||||
if (nSDLPlayPos == nAudLoopLen) {
|
||||
|
||||
if (nSDLPlayPos == nAudLoopLen)
|
||||
{
|
||||
nSDLPlayPos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// dprintf(_T("\n"));
|
||||
}
|
||||
|
||||
static int SDLSoundGetNextSoundFiller(int) // int bDraw
|
||||
static int SDLSoundGetNextSoundFiller(int) // int bDraw
|
||||
{
|
||||
if (nAudNextSound == NULL) {
|
||||
if (nAudNextSound == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2); // Write silence into the buffer
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2); // Write silence into the buffer
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int SDLSoundBlankSound()
|
||||
{
|
||||
dprintf (_T("SDLBlankSound\n"));
|
||||
if (nAudNextSound) {
|
||||
dprintf (_T("blanking nAudNextSound\n"));
|
||||
if (nAudNextSound)
|
||||
{
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2);
|
||||
}
|
||||
return 0;
|
||||
@ -71,60 +70,54 @@ static int SDLSoundCheck()
|
||||
{
|
||||
int nPlaySeg, nFollowingSeg;
|
||||
|
||||
if (!bAudPlaying) {
|
||||
dprintf(_T("SDLSoundCheck (not playing)\n"));
|
||||
return 0;
|
||||
}
|
||||
if (!bAudPlaying)
|
||||
return 1;
|
||||
|
||||
// Since the SDL buffer is smaller than a segment, only fill the buffer up to the start of the currently playing segment
|
||||
nPlaySeg = nSDLPlayPos / (nAudSegLen << 2) - 1;
|
||||
|
||||
// dprintf(_T("SDLSoundCheck (seg %i)\n"), nPlaySeg);
|
||||
|
||||
if (nPlaySeg >= nAudSegCount) {
|
||||
if (nPlaySeg >= nAudSegCount)
|
||||
{
|
||||
nPlaySeg -= nAudSegCount;
|
||||
}
|
||||
if (nPlaySeg < 0) {
|
||||
if (nPlaySeg < 0)
|
||||
{
|
||||
nPlaySeg = nAudSegCount - 1;
|
||||
}
|
||||
|
||||
if (nSDLFillSeg == nPlaySeg) {
|
||||
SDL_Delay(1);
|
||||
return 0;
|
||||
}
|
||||
// delay_ticks(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// work out which seg we will fill next
|
||||
nFollowingSeg = nSDLFillSeg;
|
||||
WRAP_INC(nFollowingSeg);
|
||||
|
||||
while (nSDLFillSeg != nPlaySeg) {
|
||||
while (nSDLFillSeg != nPlaySeg)
|
||||
{
|
||||
int bDraw;
|
||||
|
||||
// fill nSDLFillSeg
|
||||
// dprintf(_T("Filling seg %i at %i\n"), nSDLFillSeg, nSDLFillSeg * (nAudSegLen << 2));
|
||||
|
||||
bDraw = (nFollowingSeg == nPlaySeg);// || bAlwaysDrawFrames; // If this is the last seg of sound, flag bDraw (to draw the graphics)
|
||||
GetNextSound(bDraw); // get more sound into nAudNextSound
|
||||
|
||||
// nAudNextSound = SDLAudBuffer + nSDLFillSeg * (nAudSegLen << 1);
|
||||
GetNextSound(bDraw); // get more sound into nAudNextSound
|
||||
|
||||
// if (nAudDSPModule) {
|
||||
// DspDo(nAudNextSound, nAudSegLen);
|
||||
// }
|
||||
if (nAudDSPModule[0])
|
||||
{
|
||||
DspDo(nAudNextSound, nAudSegLen);
|
||||
}
|
||||
|
||||
memcpy((char*)SDLAudBuffer + nSDLFillSeg * (nAudSegLen << 2), nAudNextSound, nAudSegLen << 2);
|
||||
|
||||
nSDLFillSeg = nFollowingSeg;
|
||||
WRAP_INC(nFollowingSeg);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int SDLSoundExit()
|
||||
{
|
||||
dprintf(_T("SDLSoundExit\n"));
|
||||
|
||||
DspExit();
|
||||
SDL_CloseAudio();
|
||||
|
||||
free(SDLAudBuffer);
|
||||
@ -138,11 +131,13 @@ static int SDLSoundExit()
|
||||
|
||||
static int SDLSetCallback(int (*pCallback)(int))
|
||||
{
|
||||
if (pCallback == NULL) {
|
||||
if (pCallback == NULL)
|
||||
{
|
||||
GetNextSound = SDLSoundGetNextSoundFiller;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
GetNextSound = pCallback;
|
||||
dprintf(_T("SDL callback set\n"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -152,16 +147,20 @@ static int SDLSoundInit()
|
||||
SDL_AudioSpec audiospec_req;
|
||||
int nSDLBufferSize;
|
||||
|
||||
dprintf(_T("SDLSoundInit (%dHz)\n"), nAudSampleRate[0]);
|
||||
printf("SDLSoundInit (%dHz) (%dFPS)\n", nAudSampleRate[0], nAppVirtualFps);
|
||||
|
||||
if (nAudSampleRate[0] <= 0) {
|
||||
if (nAudSampleRate[0] <= 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
nSoundFps = nAppVirtualFps;
|
||||
nAudSegLen = (nAudSampleRate[0] * 100 + (nSoundFps >> 1)) / nSoundFps;
|
||||
nAudLoopLen = (nAudSegLen * nAudSegCount) << 2;
|
||||
for (nSDLBufferSize = 64; nSDLBufferSize < (nAudSegLen >> 1); nSDLBufferSize <<= 1) { }
|
||||
for (nSDLBufferSize = 64; nSDLBufferSize < (nAudSegLen >> 1); nSDLBufferSize <<= 1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
audiospec_req.freq = nAudSampleRate[0];
|
||||
audiospec_req.format = AUDIO_S16;
|
||||
@ -170,15 +169,17 @@ static int SDLSoundInit()
|
||||
audiospec_req.callback = audiospec_callback;
|
||||
|
||||
SDLAudBuffer = (short*)malloc(nAudLoopLen);
|
||||
if (SDLAudBuffer == NULL) {
|
||||
dprintf(_T("Couldn't malloc SDLAudBuffer\n"));
|
||||
if (SDLAudBuffer == NULL)
|
||||
{
|
||||
printf("Couldn't malloc SDLAudBuffer\n");
|
||||
SDLSoundExit();
|
||||
return 1;
|
||||
}
|
||||
memset(SDLAudBuffer, 0, nAudLoopLen);
|
||||
|
||||
nAudNextSound = (short*)malloc(nAudSegLen << 2);
|
||||
if (nAudNextSound == NULL) {
|
||||
if (nAudNextSound == NULL)
|
||||
{
|
||||
SDLSoundExit();
|
||||
return 1;
|
||||
}
|
||||
@ -186,12 +187,12 @@ static int SDLSoundInit()
|
||||
nSDLPlayPos = 0;
|
||||
nSDLFillSeg = nAudSegCount - 1;
|
||||
|
||||
if(SDL_OpenAudio(&audiospec_req, &audiospec)) {
|
||||
if (SDL_OpenAudio(&audiospec_req, &audiospec))
|
||||
{
|
||||
fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
|
||||
dprintf(_T("Couldn't open audio: %s\n"), SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
DspInit();
|
||||
SDLSetCallback(NULL);
|
||||
|
||||
return 0;
|
||||
@ -199,8 +200,6 @@ static int SDLSoundInit()
|
||||
|
||||
static int SDLSoundPlay()
|
||||
{
|
||||
dprintf(_T("SDLSoundPlay\n"));
|
||||
|
||||
SDL_PauseAudio(0);
|
||||
bAudPlaying = 1;
|
||||
|
||||
@ -209,8 +208,6 @@ static int SDLSoundPlay()
|
||||
|
||||
static int SDLSoundStop()
|
||||
{
|
||||
dprintf(_T("SDLSoundStop\n"));
|
||||
|
||||
SDL_PauseAudio(1);
|
||||
bAudPlaying = 0;
|
||||
|
||||
@ -219,7 +216,6 @@ static int SDLSoundStop()
|
||||
|
||||
static int SDLSoundSetVolume()
|
||||
{
|
||||
dprintf(_T("SDLSoundSetVolume\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,8 @@ static InterfaceInfo CDEmuInfo = { NULL, NULL, NULL };
|
||||
|
||||
#if defined BUILD_WIN32
|
||||
extern struct CDEmuDo cdimgDo;
|
||||
#elif defined BUILD_SDL
|
||||
// CD emulation module
|
||||
#elif defined BUILD_SDL2 || defined BUILD_SDL
|
||||
extern struct CDEmuDo cdimgDo;
|
||||
#elif defined (_XBOX)
|
||||
extern struct CDEmuDo cdimgDo;
|
||||
#endif
|
||||
@ -20,8 +20,8 @@ static struct CDEmuDo* pCDEmuDo[] =
|
||||
{
|
||||
#if defined BUILD_WIN32
|
||||
&cdimgDo,
|
||||
#elif defined BUILD_SDL
|
||||
// CD emulation module
|
||||
#elif defined BUILD_SDL2 || defined BUILD_SDL
|
||||
&cdimgDo,
|
||||
#elif defined (_XBOX)
|
||||
&cdimgDo,
|
||||
#endif
|
||||
|
@ -1,600 +0,0 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// iso/cue/wav support
|
||||
/*-----------------------------------------------------------------------------
|
||||
Modified by: CaptainCPS-X
|
||||
Updates:
|
||||
(10/24/2011)
|
||||
- removed libmad and MP3 support
|
||||
- added my custom DirectSound library to add WAV support
|
||||
- removed most (if not all) references to MP3
|
||||
- modified a few other things as needed
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "burner.h"
|
||||
#include "cdsound.h"
|
||||
|
||||
#define MAXIMUM_NUMBER_TRACKS (100)
|
||||
|
||||
#define CD_FRAMES_MINUTE (60 * 75)
|
||||
#define CD_FRAMES_SECOND ( 75)
|
||||
#define CD_FRAMES_PREGAP ( 2 * 75)
|
||||
|
||||
struct isowavTRACK_DATA {
|
||||
char Control;
|
||||
char TrackNumber;
|
||||
char Address[4];
|
||||
TCHAR* Filename;
|
||||
};
|
||||
|
||||
struct isowavCDROM_TOC {
|
||||
char FirstTrack;
|
||||
char LastTrack;
|
||||
isowavTRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS];
|
||||
};
|
||||
|
||||
static isowavCDROM_TOC* isowavTOC;
|
||||
|
||||
static FILE* isowavFile = NULL;
|
||||
static int isowavTrack = 0;
|
||||
static int isowavLBA = 0;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static const char* isowavLBAToMSF(const int LBA)
|
||||
{
|
||||
static char address[4];
|
||||
|
||||
address[0] = 0;
|
||||
address[1] = LBA / CD_FRAMES_MINUTE;
|
||||
address[2] = LBA % CD_FRAMES_MINUTE / CD_FRAMES_SECOND;
|
||||
address[3] = LBA % CD_FRAMES_SECOND;
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
static int isowavMSFToLBA(const char* address)
|
||||
{
|
||||
int LBA;
|
||||
|
||||
LBA = address[3];
|
||||
LBA += address[2] * CD_FRAMES_SECOND;
|
||||
LBA += address[1] * CD_FRAMES_MINUTE;
|
||||
|
||||
return LBA;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static int isowavGetTrackSizes()
|
||||
{
|
||||
// determine the lenght of the .iso / .mp3 files to complete the TOC
|
||||
|
||||
FILE* h;
|
||||
|
||||
for (int i = isowavTOC->FirstTrack - 1; i < isowavTOC->LastTrack; i++) {
|
||||
|
||||
const char* address;
|
||||
|
||||
if (isowavTOC->TrackData[i].Control & 4) {
|
||||
|
||||
// data track
|
||||
|
||||
h = _tfopen(isowavTOC->TrackData[i].Filename, _T("rb"));
|
||||
if (h == NULL) return 1;
|
||||
|
||||
fseek(h, 0, SEEK_END);
|
||||
|
||||
address = isowavLBAToMSF((ftell(h) + 2047) / 2048 + isowavMSFToLBA(isowavTOC->TrackData[i].Address));
|
||||
|
||||
if(h) fclose(h);
|
||||
|
||||
} else {
|
||||
|
||||
// audio track
|
||||
|
||||
h = _tfopen(isowavTOC->TrackData[i].Filename, _T("rb"));
|
||||
if (h == NULL)return 1;
|
||||
|
||||
fseek(h, 0, SEEK_END);
|
||||
|
||||
address = isowavLBAToMSF(((ftell(h) + 2047) / 2048) + isowavMSFToLBA(isowavTOC->TrackData[i].Address));
|
||||
if(h) fclose(h);
|
||||
}
|
||||
|
||||
isowavTOC->TrackData[i + 1].Address[0] += 0; // always 0 [?]
|
||||
isowavTOC->TrackData[i + 1].Address[1] += address[1]; // M
|
||||
isowavTOC->TrackData[i + 1].Address[2] += address[2]; // S
|
||||
isowavTOC->TrackData[i + 1].Address[3] += address[3]; // F
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isowavTestISO()
|
||||
{
|
||||
TCHAR fullname[MAX_PATH];
|
||||
TCHAR* filename;
|
||||
int length = 0;
|
||||
int offset = 0;
|
||||
int track = 2;
|
||||
FILE* h;
|
||||
|
||||
_tcscpy(fullname, CDEmuImage);
|
||||
length = _tcslen(fullname);
|
||||
|
||||
// assume CD-ROM mode1/2048 format
|
||||
|
||||
if (length <= 4 && (_tcscmp(_T(".iso"), fullname + length - 4) || _tcscmp(_T(".bin"), fullname + length - 4))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create a TOC with only the data track first
|
||||
|
||||
isowavTOC->FirstTrack = 1;
|
||||
isowavTOC->LastTrack = 1;
|
||||
|
||||
isowavTOC->TrackData[0].TrackNumber = 1;
|
||||
|
||||
isowavTOC->TrackData[0].Address[1] = 0;
|
||||
isowavTOC->TrackData[0].Address[2] = 2;
|
||||
isowavTOC->TrackData[0].Address[3] = 0;
|
||||
|
||||
isowavTOC->TrackData[0].Filename = (TCHAR*)malloc((length + 1) * sizeof(TCHAR));
|
||||
if (isowavTOC->TrackData[0].Filename == NULL) {
|
||||
return 1;
|
||||
}
|
||||
_tcscpy(isowavTOC->TrackData[0].Filename, fullname);
|
||||
|
||||
isowavTOC->TrackData[0].Control = 4;
|
||||
|
||||
// if the filename has a number in it, try to find .mp3 tracks
|
||||
|
||||
filename = ExtractFilename(fullname);
|
||||
offset = (filename - fullname) + length - 6;
|
||||
while (offset >= 0 && fullname[offset] != _T('0') && fullname[offset + 1] != _T('1')) {
|
||||
offset--;
|
||||
}
|
||||
if (offset < 0) {
|
||||
return isowavGetTrackSizes();
|
||||
}
|
||||
|
||||
_stprintf(fullname + length - 4, _T(".wav"));
|
||||
|
||||
while (1) {
|
||||
fullname[offset] = _T('0') + track / 10; fullname[offset + 1] = _T('0') + track % 10;
|
||||
|
||||
if ((h = _tfopen(fullname, _T("rb"))) == NULL) {
|
||||
break;
|
||||
}
|
||||
fclose(h);
|
||||
|
||||
isowavTOC->TrackData[track - 1].TrackNumber = track;
|
||||
|
||||
isowavTOC->TrackData[track - 1].Filename = (TCHAR*)malloc((length + 1) * sizeof(TCHAR));
|
||||
if (isowavTOC->TrackData[track - 1].Filename == NULL) {
|
||||
return 1;
|
||||
}
|
||||
_tcscpy(isowavTOC->TrackData[track - 1].Filename, fullname);
|
||||
|
||||
isowavTOC->LastTrack = track;
|
||||
|
||||
track++;
|
||||
}
|
||||
|
||||
return isowavGetTrackSizes();
|
||||
}
|
||||
|
||||
static int isowavParseCueFile()
|
||||
{
|
||||
TCHAR szLine[1024];
|
||||
TCHAR szFile[1024];
|
||||
TCHAR* s;
|
||||
TCHAR* t;
|
||||
FILE* h;
|
||||
int track = 0;
|
||||
int length;
|
||||
|
||||
isowavTOC->FirstTrack = 1;
|
||||
isowavTOC->LastTrack = 1;
|
||||
|
||||
isowavTOC->TrackData[0].Address[1] = 0;
|
||||
isowavTOC->TrackData[0].Address[2] = 2;
|
||||
isowavTOC->TrackData[0].Address[3] = 0;
|
||||
|
||||
h = _tfopen(CDEmuImage, _T("rt"));
|
||||
if (h == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (_fgetts(szLine, sizeof(szLine), h) == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
length = _tcslen(szLine);
|
||||
// get rid of the linefeed at the end
|
||||
while (length && (szLine[length - 1] == _T('\r') || szLine[length - 1] == _T('\n'))) {
|
||||
szLine[length - 1] = 0;
|
||||
length--;
|
||||
}
|
||||
|
||||
s = szLine;
|
||||
|
||||
// file info
|
||||
if ((t = LabelCheck(s, _T("FILE"))) != 0) {
|
||||
s = t;
|
||||
|
||||
TCHAR* szQuote;
|
||||
|
||||
// read filename
|
||||
QuoteRead(&szQuote, NULL, s);
|
||||
|
||||
_sntprintf(szFile, ExtractFilename(CDEmuImage) - CDEmuImage, _T("%s"), CDEmuImage);
|
||||
_sntprintf(szFile + (ExtractFilename(CDEmuImage) - CDEmuImage), 1024 - (ExtractFilename(CDEmuImage) - CDEmuImage), _T("/%s"), szQuote);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// track info
|
||||
if ((t = LabelCheck(s, _T("TRACK"))) != 0) {
|
||||
s = t;
|
||||
|
||||
// track number
|
||||
track = _tcstol(s, &t, 10);
|
||||
|
||||
if (track < 1 || track > MAXIMUM_NUMBER_TRACKS) {
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (track < isowavTOC->FirstTrack) {
|
||||
isowavTOC->FirstTrack = track;
|
||||
}
|
||||
if (track > isowavTOC->LastTrack) {
|
||||
isowavTOC->LastTrack = track;
|
||||
}
|
||||
isowavTOC->TrackData[track - 1].TrackNumber = track;
|
||||
|
||||
isowavTOC->TrackData[track - 1].Filename = (TCHAR*)malloc((_tcslen(szFile) + 1) * sizeof(TCHAR));
|
||||
if (isowavTOC->TrackData[track - 1].Filename == NULL) {
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
_tcscpy(isowavTOC->TrackData[track - 1].Filename, szFile);
|
||||
|
||||
s = t;
|
||||
|
||||
// type of track
|
||||
|
||||
if ((t = LabelCheck(s, _T("MODE1/2048"))) != 0) {
|
||||
isowavTOC->TrackData[track - 1].Control = 4;
|
||||
|
||||
continue;
|
||||
}
|
||||
if ((t = LabelCheck(s, _T("AUDIO"))) != 0) {
|
||||
isowavTOC->TrackData[track - 1].Control = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// pregap
|
||||
if ((t = LabelCheck(s, _T("PREGAP"))) != 0) {
|
||||
s = t;
|
||||
|
||||
int M, S, F;
|
||||
|
||||
// pregap M
|
||||
M = _tcstol(s, &t, 10);
|
||||
s = t + 1;
|
||||
// pregap S
|
||||
S = _tcstol(s, &t, 10);
|
||||
s = t + 1;
|
||||
// pregap F
|
||||
F = _tcstol(s, &t, 10);
|
||||
|
||||
if (M < 0 || M > 100 || S < 0 || S > 59 || F < 0 || F > 74) {
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
isowavTOC->TrackData[track - 1].Address[1] = M;
|
||||
isowavTOC->TrackData[track - 1].Address[2] = S;
|
||||
isowavTOC->TrackData[track - 1].Address[3] = F;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(h);
|
||||
|
||||
return isowavGetTrackSizes();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static int isowavExit()
|
||||
{
|
||||
wav_exit();
|
||||
|
||||
if (isowavFile) {
|
||||
fclose(isowavFile);
|
||||
isowavFile = NULL;
|
||||
}
|
||||
|
||||
isowavTrack = 0;
|
||||
isowavLBA = 0;
|
||||
|
||||
if (isowavTOC) {
|
||||
for (int i = 0; i < MAXIMUM_NUMBER_TRACKS; i++) {
|
||||
free(isowavTOC->TrackData[i].Filename);
|
||||
}
|
||||
|
||||
free(isowavTOC);
|
||||
isowavTOC = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isowavInit()
|
||||
{
|
||||
wav_exit();
|
||||
|
||||
isowavTOC = (isowavCDROM_TOC*)malloc(sizeof(isowavCDROM_TOC));
|
||||
if (isowavTOC == NULL) {
|
||||
return 1;
|
||||
}
|
||||
memset(isowavTOC, 0, sizeof(isowavCDROM_TOC));
|
||||
|
||||
TCHAR* filename = ExtractFilename(CDEmuImage);
|
||||
|
||||
if (_tcslen(filename) < 4) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (_tcscmp(_T(".cue"), filename + _tcslen(filename) - 4) == 0) {
|
||||
if (isowavParseCueFile()) {
|
||||
dprintf(_T("*** Couldn't parse .cue file\n"));
|
||||
isowavExit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (isowavTestISO()) {
|
||||
dprintf(_T("*** Couldn't find .iso / .bin file\n"));
|
||||
isowavExit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
dprintf(_T(" CD image TOC read\n"));
|
||||
|
||||
for (int i = isowavTOC->FirstTrack - 1; i < isowavTOC->LastTrack; i++) {
|
||||
dprintf(_T(" track %2i start %02i:%02i:%02i control 0x%02X %s\n"), isowavTOC->TrackData[i].TrackNumber, isowavTOC->TrackData[i].Address[1], isowavTOC->TrackData[i].Address[2], isowavTOC->TrackData[i].Address[3], isowavTOC->TrackData[i].Control, isowavTOC->TrackData[i].Filename);
|
||||
}
|
||||
dprintf(_T(" total running time %02i:%02i:%02i\n"), isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[1], isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[2], isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[3]);
|
||||
|
||||
CDEmuStatus = idle;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TCHAR* GetIsoPath()
|
||||
{
|
||||
if(isowavTOC) {
|
||||
return isowavTOC->TrackData[0].Filename;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int isowavStop()
|
||||
{
|
||||
wav_stop();
|
||||
|
||||
if (isowavFile) {
|
||||
fclose(isowavFile);
|
||||
isowavFile = NULL;
|
||||
}
|
||||
CDEmuStatus = idle;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isowavPlayLBA(int LBA)
|
||||
{
|
||||
isowavLBA = LBA;
|
||||
|
||||
for (isowavTrack = isowavTOC->FirstTrack - 1; isowavTrack < isowavTOC->LastTrack; isowavTrack++) {
|
||||
if (isowavLBA < isowavMSFToLBA(isowavTOC->TrackData[isowavTrack + 1].Address)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isowavTrack >= isowavTOC->LastTrack) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bprintf(PRINT_IMPORTANT, _T(" playing track %2i - %s\n"), isowavTrack + 1, isowavTOC->TrackData[isowavTrack].Filename);
|
||||
|
||||
isowavFile = _tfopen(isowavTOC->TrackData[isowavTrack].Filename, _T("rb"));
|
||||
if (isowavFile == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( strstr(isowavTOC->TrackData[isowavTrack].Filename, _T(".wav")) || strstr(isowavTOC->TrackData[isowavTrack].Filename, _T(".WAV"))) {
|
||||
// is a wav, no need to keep this file pointer
|
||||
if (isowavFile) {
|
||||
fclose(isowavFile);
|
||||
isowavFile = NULL;
|
||||
}
|
||||
|
||||
if(wav_open(isowavTOC->TrackData[isowavTrack].Filename)) {
|
||||
wav_play();
|
||||
} else {
|
||||
// error creating the WAV stream
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//dprintf(_T("*** WAV: wBitsPerSample: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_pwfx->wBitsPerSample);
|
||||
//dprintf(_T("*** WAV: nAvgBytesPerSec: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_pwfx->nAvgBytesPerSec);
|
||||
//dprintf(_T("*** WAV: m_dwSize: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_dwSize);
|
||||
//dprintf(_T("*** WAV: nBlockAlign: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_pwfx->nBlockAlign);
|
||||
|
||||
isowavLBA = isowavMSFToLBA(isowavTOC->TrackData[isowavTrack].Address);
|
||||
CDEmuStatus = playing;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isowavPlay(unsigned char M, unsigned char S, unsigned char F)
|
||||
{
|
||||
const char address[] = { 0, M, S, F };
|
||||
|
||||
return isowavPlayLBA(isowavMSFToLBA(address));
|
||||
}
|
||||
|
||||
static int isowavLoadSector(int LBA, char* pBuffer)
|
||||
{
|
||||
LBA += CD_FRAMES_PREGAP;
|
||||
|
||||
if (LBA != isowavLBA) {
|
||||
|
||||
int track;
|
||||
|
||||
for (track = isowavTOC->FirstTrack - 1; track < isowavTOC->LastTrack; track++) {
|
||||
if (LBA < isowavMSFToLBA(isowavTOC->TrackData[track + 1].Address)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isowavFile == NULL || track != isowavTrack) {
|
||||
isowavStop();
|
||||
|
||||
isowavTrack = track;
|
||||
|
||||
bprintf(PRINT_IMPORTANT, _T(" reading track %2i - %s\n"), isowavTrack + 1, isowavTOC->TrackData[isowavTrack].Filename);
|
||||
|
||||
isowavFile = _tfopen(isowavTOC->TrackData[isowavTrack].Filename, _T("rb"));
|
||||
if (isowavFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (fseek(isowavFile, (LBA - isowavMSFToLBA(isowavTOC->TrackData[isowavTrack].Address)) * 2048, SEEK_SET)) {
|
||||
dprintf(_T("*** couldn't seek\n"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
isowavLBA = (ftell(isowavFile) + 2047) / 2048;
|
||||
|
||||
CDEmuStatus = reading;
|
||||
}
|
||||
|
||||
if (fread(pBuffer, 1, 2048, isowavFile) <= 0) {
|
||||
dprintf(_T("*** couldn't read from file\n"));
|
||||
|
||||
isowavStop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
isowavLBA = isowavMSFToLBA(isowavTOC->TrackData[isowavTrack].Address) + (ftell(isowavFile) + 2047) / 2048;
|
||||
|
||||
return isowavLBA - CD_FRAMES_PREGAP;
|
||||
}
|
||||
|
||||
static unsigned char* isowavReadTOC(int track)
|
||||
{
|
||||
static unsigned char TOCEntry[4];
|
||||
|
||||
if (track == -1) {
|
||||
TOCEntry[0] = isowavTOC->FirstTrack - 1;
|
||||
TOCEntry[1] = isowavTOC->LastTrack;
|
||||
TOCEntry[2] = 0;
|
||||
TOCEntry[3] = 0;
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
if (track == -2) {
|
||||
TOCEntry[0] = isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[1];
|
||||
TOCEntry[1] = isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[2];
|
||||
TOCEntry[2] = isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[3];
|
||||
|
||||
TOCEntry[3] = 0;
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
|
||||
if (track >= isowavTOC->FirstTrack - 1 && track <= isowavTOC->LastTrack) {
|
||||
TOCEntry[0] = isowavTOC->TrackData[track - 1].Address[1];
|
||||
TOCEntry[1] = isowavTOC->TrackData[track - 1].Address[2];
|
||||
TOCEntry[2] = isowavTOC->TrackData[track - 1].Address[3];
|
||||
TOCEntry[3] = isowavTOC->TrackData[track - 1].Control;
|
||||
}
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
|
||||
static unsigned char* isowavReadQChannel()
|
||||
{
|
||||
static unsigned char QChannelData[8];
|
||||
|
||||
switch (CDEmuStatus) {
|
||||
case reading:
|
||||
case playing: {
|
||||
const char* AddressAbs = isowavLBAToMSF(isowavLBA);
|
||||
const char* AddressRel = isowavLBAToMSF(isowavLBA - isowavMSFToLBA(isowavTOC->TrackData[isowavTrack].Address));
|
||||
|
||||
QChannelData[0] = isowavTOC->TrackData[isowavTrack].TrackNumber;
|
||||
|
||||
QChannelData[1] = AddressAbs[1];
|
||||
QChannelData[2] = AddressAbs[2];
|
||||
QChannelData[3] = AddressAbs[3];
|
||||
|
||||
QChannelData[4] = AddressRel[1];
|
||||
QChannelData[5] = AddressRel[2];
|
||||
QChannelData[6] = AddressRel[3];
|
||||
|
||||
QChannelData[7] = isowavTOC->TrackData[isowavTrack].Control;
|
||||
|
||||
break;
|
||||
}
|
||||
case paused: {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
memset(QChannelData, 0, sizeof(QChannelData));
|
||||
}
|
||||
}
|
||||
|
||||
return QChannelData;
|
||||
}
|
||||
|
||||
static int isowavGetSoundBuffer(short* /*buffer*/, int /*samples*/)
|
||||
{
|
||||
// ---------------------------------------------------------------------
|
||||
// TODO:
|
||||
// Port the old 'isomp3GetSoundBuffer()' function from 'cd_isomp3.cpp'
|
||||
// to use WAVE stream data, porting that function will fix the
|
||||
// 00:00 progress status on the main NeoGeo CD BIOS menu.
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 isowavScan(INT32 nAction, INT32 *pnMin)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isowavGetSettings(InterfaceInfo* /*pInfo*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct CDEmuDo isowavDo = { isowavExit, isowavInit, isowavStop, isowavPlay, isowavLoadSector, isowavReadTOC, isowavReadQChannel, isowavGetSoundBuffer, isowavScan, isowavGetSettings, _T("cue/iso/wav CD emulation") };
|
897
src/intf/cd/sdl/cd_sdl2.cpp
Normal file
897
src/intf/cd/sdl/cd_sdl2.cpp
Normal file
@ -0,0 +1,897 @@
|
||||
// FBAlpha cd-img, TruRip .ccd/.sub/.img support by Jan Klaassen
|
||||
// .bin/.cue re-work by dink
|
||||
|
||||
#include "burner.h"
|
||||
|
||||
const int MAXIMUM_NUMBER_TRACKS = 100;
|
||||
|
||||
const int CD_FRAMES_MINUTE = 60 * 75;
|
||||
const int CD_FRAMES_SECOND = 75;
|
||||
|
||||
const int CD_TYPE_NONE = 1 << 0;
|
||||
const int CD_TYPE_BINCUE = 1 << 1;
|
||||
const int CD_TYPE_CCD = 1 << 2;
|
||||
|
||||
static int cd_pregap;
|
||||
|
||||
struct MSF { UINT8 M; UINT8 S; UINT8 F; };
|
||||
|
||||
struct cdimgTRACK_DATA { UINT8 Control; UINT8 TrackNumber; UINT8 Address[4]; UINT8 EndAddress[4]; };
|
||||
struct cdimgCDROM_TOC { UINT8 FirstTrack; UINT8 LastTrack; UINT8 ImageType; TCHAR Image[MAX_PATH]; cdimgTRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS]; };
|
||||
|
||||
static cdimgCDROM_TOC* cdimgTOC;
|
||||
|
||||
static FILE* cdimgFile = NULL;
|
||||
static int cdimgFileSize = 0;
|
||||
static int cdimgTrack = 0;
|
||||
static int cdimgLBA = 0;
|
||||
|
||||
static int cdimgSamples = 0;
|
||||
|
||||
// identical to the format used in clonecd .sub files, can use memcpy
|
||||
struct QData { UINT8 Control; char track; char index; MSF MSFrel; char unused; MSF MSFabs; unsigned short CRC; };
|
||||
|
||||
static QData* QChannel = NULL;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const int cdimgOUT_SIZE = 2352;
|
||||
static int cdimgOutputbufferSize = 0;
|
||||
|
||||
static short* cdimgOutputbuffer = NULL;
|
||||
|
||||
static int cdimgOutputPosition;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
TCHAR* GetIsoPath()
|
||||
{
|
||||
if (cdimgTOC) {
|
||||
return cdimgTOC->Image;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT8 bcd(const UINT8 v)
|
||||
{
|
||||
return ((v >> 4) * 10) + (v & 0x0F);
|
||||
}
|
||||
|
||||
static UINT8 tobcd(const UINT8 v)
|
||||
{
|
||||
return ((v / 10) << 4) | (v % 10);
|
||||
}
|
||||
|
||||
static const UINT8* cdimgLBAToMSF(int LBA)
|
||||
{
|
||||
static UINT8 address[4];
|
||||
|
||||
address[0] = 0;
|
||||
address[1] = tobcd(LBA / CD_FRAMES_MINUTE);
|
||||
address[2] = tobcd(LBA % CD_FRAMES_MINUTE / CD_FRAMES_SECOND);
|
||||
address[3] = tobcd(LBA % CD_FRAMES_SECOND);
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
static int cdimgMSFToLBA(const UINT8* address)
|
||||
{
|
||||
int LBA;
|
||||
|
||||
LBA = bcd(address[3]);
|
||||
LBA += bcd(address[2]) * CD_FRAMES_SECOND;
|
||||
LBA += bcd(address[1]) * CD_FRAMES_MINUTE;
|
||||
|
||||
return LBA;
|
||||
}
|
||||
|
||||
static const UINT8* dinkLBAToMSF(const int LBA) // not BCD version
|
||||
{
|
||||
static UINT8 address[4];
|
||||
|
||||
address[0] = 0;
|
||||
address[1] = LBA / CD_FRAMES_MINUTE;
|
||||
address[2] = LBA % CD_FRAMES_MINUTE / CD_FRAMES_SECOND;
|
||||
address[3] = LBA % CD_FRAMES_SECOND;
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
static int dinkMSFToLBA(const UINT8* address)
|
||||
{
|
||||
int LBA;
|
||||
|
||||
LBA = address[3];
|
||||
LBA += address[2] * CD_FRAMES_SECOND;
|
||||
LBA += address[1] * CD_FRAMES_MINUTE;
|
||||
|
||||
return LBA;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static void cdimgExitStream()
|
||||
{
|
||||
free(cdimgOutputbuffer);
|
||||
cdimgOutputbuffer = NULL;
|
||||
}
|
||||
|
||||
static int cdimgInitStream()
|
||||
{
|
||||
cdimgExitStream();
|
||||
|
||||
cdimgOutputbuffer = (short*)malloc(cdimgOUT_SIZE * 2 * sizeof(short));
|
||||
if (cdimgOutputbuffer == NULL)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cdimgSkip(FILE* h, int samples)
|
||||
{
|
||||
fseek(h, samples * 4, SEEK_CUR);
|
||||
|
||||
return samples * 4;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static void cdimgPrintImageInfo()
|
||||
{
|
||||
bprintf(0, _T("Image file: %s\n"), cdimgTOC->Image);
|
||||
|
||||
bprintf(0, _T(" CD image TOC - "));
|
||||
if (cdimgTOC->ImageType == CD_TYPE_CCD)
|
||||
bprintf(0, _T("TruRip (.CCD/.SUB/.IMG) format\n"));
|
||||
if (cdimgTOC->ImageType == CD_TYPE_BINCUE)
|
||||
bprintf(0, _T("Disk At Once (.BIN/.CUE) format\n"));
|
||||
|
||||
for (INT32 trk = cdimgTOC->FirstTrack - 1; trk <= cdimgTOC->LastTrack; trk++) {
|
||||
const UINT8* addressUNBCD = dinkLBAToMSF(cdimgMSFToLBA(cdimgTOC->TrackData[trk].Address));
|
||||
|
||||
if (trk != cdimgTOC->LastTrack) {
|
||||
bprintf(0, _T("Track %02d: %02d:%02d:%02d\n"), trk + 1, addressUNBCD[1], addressUNBCD[2], addressUNBCD[3]);
|
||||
}
|
||||
else {
|
||||
bprintf(0, _T(" total running time %02i:%02i:%02i\n"), addressUNBCD[1], addressUNBCD[2], addressUNBCD[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void cdimgAddLastTrack()
|
||||
{ // Make a fake last-track w/total image size (for bounds checking)
|
||||
FILE* h = fopen(cdimgTOC->Image, _T("rb"));
|
||||
if (h)
|
||||
{
|
||||
fseek(h, 0, SEEK_END);
|
||||
const UINT8* address = cdimgLBAToMSF(((ftell(h) + 2351) / 2352) + cd_pregap);
|
||||
fclose(h);
|
||||
|
||||
cdimgTOC->TrackData[cdimgTOC->LastTrack].Address[1] = address[1];
|
||||
cdimgTOC->TrackData[cdimgTOC->LastTrack].Address[2] = address[2];
|
||||
cdimgTOC->TrackData[cdimgTOC->LastTrack].Address[3] = address[3];
|
||||
}
|
||||
}
|
||||
|
||||
// parse .sub file and build a TOC based in Q sub channel data
|
||||
static int cdimgParseSubFile()
|
||||
{
|
||||
TCHAR filename_sub[MAX_PATH];
|
||||
int length = 0;
|
||||
QData* Q = 0;
|
||||
int Qsize = 0;
|
||||
FILE* h;
|
||||
int track = 1;
|
||||
|
||||
cdimgTOC->ImageType = CD_TYPE_CCD;
|
||||
cdimgTOC->FirstTrack = 1;
|
||||
|
||||
_tcscpy(filename_sub, CDEmuImage);
|
||||
length = _tcslen(filename_sub);
|
||||
|
||||
if (length <= 4 ||
|
||||
(!IsFileExt(filename_sub, _T(".ccd")) &&
|
||||
!IsFileExt(filename_sub, _T(".img")) &&
|
||||
!IsFileExt(filename_sub, _T(".sub"))))
|
||||
{
|
||||
dprintf(_T("*** Bad image: %s\n"), filename_sub);
|
||||
return 1;
|
||||
}
|
||||
|
||||
_tcscpy(cdimgTOC->Image, CDEmuImage);
|
||||
_tcscpy(cdimgTOC->Image + length - 4, _T(".img"));
|
||||
//bprintf(0, _T("Image file: %s\n"),cdimgTOC->Image);
|
||||
// if (access(cdimgTOC->Image, 4) == -1)
|
||||
// {
|
||||
// dprintf(_T("*** Bad image: %s\n"), cdimgTOC->Image);
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
_tcscpy(filename_sub + length - 4, _T(".sub"));
|
||||
//bprintf(0, _T("filename_sub: %s\n"),filename_sub);
|
||||
h = fopen(filename_sub, _T("rb"));
|
||||
if (h == 0)
|
||||
{
|
||||
dprintf(_T("*** Bad image: %s\n"), filename_sub);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fseek(h, 0, SEEK_END);
|
||||
|
||||
INT32 subQidx = 0;
|
||||
INT32 subQsize = ftell(h);
|
||||
UINT8* subQdata = (UINT8*)malloc(subQsize);
|
||||
memset(subQdata, 0, subQsize);
|
||||
|
||||
//bprintf(0, _T("raw .sub data size: %d\n"), subQsize);
|
||||
fseek(h, 0, SEEK_SET);
|
||||
fread(subQdata, subQsize, 1, h);
|
||||
fclose(h);
|
||||
|
||||
Qsize = (subQsize + 95) / 96 * sizeof(QData);
|
||||
Q = QChannel = (QData*)malloc(Qsize);
|
||||
memset(Q, 0, Qsize);
|
||||
|
||||
INT32 track_linear = 1;
|
||||
|
||||
while (1)
|
||||
{
|
||||
subQidx += 12;
|
||||
if (subQidx >= subQsize) break;
|
||||
memcpy(Q, &subQdata[subQidx], 12);
|
||||
subQidx += 12;
|
||||
subQidx += 6 * 12;
|
||||
|
||||
if (Q->index && (Q->Control & 1) && (cdimgTOC->TrackData[bcd(Q->track) - 1].TrackNumber == 0))
|
||||
{
|
||||
// new track
|
||||
track = bcd(Q->track);
|
||||
|
||||
if (track == track_linear) {
|
||||
//dprintf(_T(" - Track %i found starting at %02X:%02X:%02X\n"), track, Q->MSFabs.M, Q->MSFabs.S, Q->MSFabs.F);
|
||||
//bprintf(0, _T(" contrl: %X track %X(%d) indx %X\n"),Q->Control,Q->track,track,Q->index);
|
||||
|
||||
cdimgTOC->TrackData[track - 1].Control = Q->Control; // >> 4;
|
||||
cdimgTOC->TrackData[track - 1].TrackNumber = Q->track;
|
||||
cdimgTOC->TrackData[track - 1].Address[1] = Q->MSFabs.M;
|
||||
cdimgTOC->TrackData[track - 1].Address[2] = Q->MSFabs.S;
|
||||
cdimgTOC->TrackData[track - 1].Address[3] = Q->MSFabs.F;
|
||||
track_linear++;
|
||||
}
|
||||
else {
|
||||
//bprintf(0, _T("skipped weird track: %X (%X)\n"), track, Q->track);
|
||||
}
|
||||
}
|
||||
|
||||
Q++;
|
||||
}
|
||||
|
||||
cdimgTOC->LastTrack = track;
|
||||
|
||||
free(subQdata);
|
||||
|
||||
cd_pregap = QChannel[0].MSFabs.F + QChannel[0].MSFabs.S * CD_FRAMES_SECOND + QChannel[0].MSFabs.M * CD_FRAMES_MINUTE;
|
||||
//bprintf(0, _T("pregap lba: %d MSF: %d:%d:%d\n"), cd_pregap, QChannel[0].MSFabs.M, QChannel[0].MSFabs.S, QChannel[0].MSFabs.F);
|
||||
|
||||
cdimgAddLastTrack();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cdimgParseCueFile()
|
||||
{
|
||||
TCHAR szLine[1024];
|
||||
TCHAR szFile[1024];
|
||||
TCHAR* s;
|
||||
TCHAR* t;
|
||||
FILE* h;
|
||||
int track = 1;
|
||||
int length;
|
||||
|
||||
cdimgTOC->ImageType = CD_TYPE_BINCUE;
|
||||
cdimgTOC->FirstTrack = 1;
|
||||
cdimgTOC->LastTrack = 1;
|
||||
|
||||
cdimgTOC->TrackData[0].Address[1] = 0;
|
||||
cdimgTOC->TrackData[0].Address[2] = 2;
|
||||
cdimgTOC->TrackData[0].Address[3] = 0;
|
||||
|
||||
cd_pregap = 150; // default for bin/cue?
|
||||
|
||||
// derive .bin name from .cue filename (it gets the actual name from the .cue, below)
|
||||
length = _tcslen(CDEmuImage);
|
||||
_tcscpy(cdimgTOC->Image, CDEmuImage);
|
||||
_tcscpy(cdimgTOC->Image + length - 4, _T(".img"));
|
||||
//bprintf(0, _T("Image file: %s\n"),cdimgTOC->Image);
|
||||
|
||||
h = _tfopen(CDEmuImage, _T("rt"));
|
||||
if (h == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (_fgetts(szLine, sizeof(szLine), h) == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
length = _tcslen(szLine);
|
||||
// get rid of the linefeed at the end
|
||||
while (length && (szLine[length - 1] == _T('\r') || szLine[length - 1] == _T('\n'))) {
|
||||
szLine[length - 1] = 0;
|
||||
length--;
|
||||
}
|
||||
|
||||
s = szLine;
|
||||
//TODO: This needs to check for the img/bin filename from the cue but also include the path
|
||||
// file info
|
||||
/* if ((t = LabelCheck(s, _T("FILE"))) != 0) {
|
||||
s = t;
|
||||
|
||||
TCHAR* szQuote;
|
||||
|
||||
// read filename
|
||||
QuoteRead(&szQuote, NULL, s);
|
||||
|
||||
_sntprintf(szFile, ExtractFilename(CDEmuImage) - CDEmuImage, _T("%s"), CDEmuImage);
|
||||
_sntprintf(szFile + (ExtractFilename(CDEmuImage) - CDEmuImage), 1024 - (ExtractFilename(CDEmuImage) - CDEmuImage), _T("\\%s"), szQuote);
|
||||
|
||||
if (track == 1) {
|
||||
//bprintf(0, _T("Image file (from .CUE): %s\n"), szFile);
|
||||
_tcscpy(cdimgTOC->Image, szFile);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
// track info
|
||||
if ((t = LabelCheck(s, _T("TRACK"))) != 0) {
|
||||
s = t;
|
||||
|
||||
// track number
|
||||
track = _tcstol(s, &t, 10);
|
||||
|
||||
if (track < 1 || track > MAXIMUM_NUMBER_TRACKS) {
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (track < cdimgTOC->FirstTrack) {
|
||||
cdimgTOC->FirstTrack = track;
|
||||
}
|
||||
if (track > cdimgTOC->LastTrack) {
|
||||
cdimgTOC->LastTrack = track;
|
||||
}
|
||||
cdimgTOC->TrackData[track - 1].TrackNumber = tobcd(track);
|
||||
|
||||
s = t;
|
||||
|
||||
// type of track
|
||||
|
||||
if ((t = LabelCheck(s, _T("MODE1/2352"))) != 0) {
|
||||
cdimgTOC->TrackData[track - 1].Control = 0x41;
|
||||
//bprintf(0, _T(".cue: Track #%d, data.\n"), track);
|
||||
continue;
|
||||
}
|
||||
if ((t = LabelCheck(s, _T("AUDIO"))) != 0) {
|
||||
cdimgTOC->TrackData[track - 1].Control = 0x01;
|
||||
//bprintf(0, _T(".cue: Track #%d, AUDIO.\n"), track);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// PREGAP (not handled)
|
||||
if ((t = LabelCheck(s, _T("PREGAP"))) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TRACK Index
|
||||
if ((t = LabelCheck(s, _T("INDEX 01"))) != 0) {
|
||||
s = t;
|
||||
|
||||
int M, S, F;
|
||||
|
||||
// index M
|
||||
M = _tcstol(s, &t, 10);
|
||||
s = t + 1;
|
||||
// index S
|
||||
S = _tcstol(s, &t, 10);
|
||||
s = t + 1;
|
||||
// index F
|
||||
F = _tcstol(s, &t, 10);
|
||||
|
||||
if (M < 0 || M > 100 || S < 0 || S > 59 || F < 0 || F > 74) {
|
||||
bprintf(0, _T("Bad M:S:F!\n"));
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const UINT8 address[] = { 0, (UINT8)M, (UINT8)S, (UINT8)F };
|
||||
const UINT8* newaddress = cdimgLBAToMSF(dinkMSFToLBA(address) + cd_pregap);
|
||||
//const UINT8* newaddressUNBCD = dinkLBAToMSF(dinkMSFToLBA(address) + cd_pregap);
|
||||
//bprintf(0, _T("Track MSF: %02d:%02d:%02d "), newaddressUNBCD[1], newaddressUNBCD[2], newaddressUNBCD[3]);
|
||||
|
||||
cdimgTOC->TrackData[track - 1].Address[1] = newaddress[1];
|
||||
cdimgTOC->TrackData[track - 1].Address[2] = newaddress[2];
|
||||
cdimgTOC->TrackData[track - 1].Address[3] = newaddress[3];
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(h);
|
||||
|
||||
cdimgAddLastTrack();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static int cdimgExit()
|
||||
{
|
||||
cdimgExitStream();
|
||||
|
||||
if (cdimgFile)
|
||||
fclose(cdimgFile);
|
||||
cdimgFile = NULL;
|
||||
|
||||
cdimgFileSize = 0;
|
||||
cdimgTrack = 0;
|
||||
cdimgLBA = 0;
|
||||
|
||||
if (cdimgTOC)
|
||||
free(cdimgTOC);
|
||||
cdimgTOC = NULL;
|
||||
|
||||
free(QChannel);
|
||||
QChannel = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cdimgInit()
|
||||
{
|
||||
cdimgTOC = (cdimgCDROM_TOC*)malloc(sizeof(cdimgCDROM_TOC));
|
||||
if (cdimgTOC == NULL)
|
||||
return 1;
|
||||
|
||||
memset(cdimgTOC, 0, sizeof(cdimgCDROM_TOC));
|
||||
|
||||
cdimgTOC->ImageType = CD_TYPE_NONE;
|
||||
|
||||
TCHAR* filename = ExtractFilename(CDEmuImage);
|
||||
|
||||
if (_tcslen(filename) < 4)
|
||||
return 1;
|
||||
|
||||
if (IsFileExt(filename, _T(".cue")))
|
||||
{
|
||||
if (cdimgParseCueFile())
|
||||
{
|
||||
dprintf(_T("*** Couldn't parse .cue file\n"));
|
||||
cdimgExit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
if (IsFileExt(filename, _T(".ccd")))
|
||||
{
|
||||
if (cdimgParseSubFile())
|
||||
{
|
||||
dprintf(_T("*** Couldn't parse .sub file\n"));
|
||||
cdimgExit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dprintf(_T("*** Couldn't find .img / .bin file\n"));
|
||||
cdimgExit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
cdimgPrintImageInfo();
|
||||
|
||||
CDEmuStatus = idle;
|
||||
|
||||
cdimgInitStream();
|
||||
|
||||
{
|
||||
char buf[2048];
|
||||
FILE* h = fopen(cdimgTOC->Image, _T("rb")); cdimgLBA++;
|
||||
|
||||
if (h)
|
||||
{
|
||||
if (fseek(h, 16 * 2352 + 16, SEEK_SET) == 0)
|
||||
{
|
||||
if (fread(buf, 1, 2048, h) == 2048)
|
||||
{
|
||||
if (strncmp("CD001", buf + 1, 5) == 0)
|
||||
{
|
||||
buf[48] = 0;
|
||||
/* BurnDrvFindMedium(buf + 40); */
|
||||
}
|
||||
else
|
||||
dprintf(_T("*** Bad CD!\n"));
|
||||
}
|
||||
}
|
||||
|
||||
fclose(h);
|
||||
}
|
||||
|
||||
//CDEmuPrintCDName();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cdimgCloseFile()
|
||||
{
|
||||
if (cdimgFile)
|
||||
{
|
||||
fclose(cdimgFile);
|
||||
cdimgFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int cdimgStop()
|
||||
{
|
||||
cdimgCloseFile();
|
||||
CDEmuStatus = idle;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cdimgFindTrack(int LBA)
|
||||
{
|
||||
int trk = 0;
|
||||
for (trk = cdimgTOC->FirstTrack - 1; trk < cdimgTOC->LastTrack; trk++)
|
||||
if (LBA < cdimgMSFToLBA(cdimgTOC->TrackData[trk + 1].Address))
|
||||
break;
|
||||
return trk;
|
||||
}
|
||||
|
||||
static int cdimgPlayLBA(int LBA) // audio play start
|
||||
{
|
||||
cdimgStop();
|
||||
|
||||
if (QChannel != NULL) { // .CCD dump w/.SUB
|
||||
if (QChannel[LBA].Control & 0x40)
|
||||
return 1;
|
||||
}
|
||||
else { // .BIN/.CUE dump
|
||||
if (cdimgTOC->TrackData[cdimgFindTrack(LBA)].Control & 0x40)
|
||||
return 1;
|
||||
}
|
||||
|
||||
cdimgLBA = LBA;
|
||||
|
||||
cdimgTrack = cdimgFindTrack(cdimgLBA);
|
||||
|
||||
if (cdimgTrack >= cdimgTOC->LastTrack)
|
||||
return 1;
|
||||
|
||||
bprintf(PRINT_IMPORTANT, _T(" playing track %2i\n"), cdimgTrack + 1);
|
||||
|
||||
cdimgFile = fopen(cdimgTOC->Image, _T("rb"));
|
||||
if (cdimgFile == NULL)
|
||||
return 1;
|
||||
|
||||
// advance if we're not starting at the beginning of a CD
|
||||
if (cdimgLBA > cd_pregap)
|
||||
cdimgSkip(cdimgFile, (cdimgLBA - cd_pregap) * (44100 / CD_FRAMES_SECOND));
|
||||
|
||||
// fill the input buffer
|
||||
if ((cdimgOutputbufferSize = fread(cdimgOutputbuffer, 4, cdimgOUT_SIZE, cdimgFile)) <= 0)
|
||||
return 1;
|
||||
|
||||
cdimgOutputPosition = 0;
|
||||
|
||||
cdimgSamples = 0;
|
||||
// this breaks states, commenting for now just in-case. -dink
|
||||
//cdimgLBA = cdimgMSFToLBA(cdimgTOC->TrackData[cdimgTrack].Address); // start at the beginning of track
|
||||
CDEmuStatus = playing;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cdimgPlay(UINT8 M, UINT8 S, UINT8 F)
|
||||
{
|
||||
const UINT8 address[] = { 0, M, S, F };
|
||||
|
||||
const UINT8* displayaddress = dinkLBAToMSF(cdimgMSFToLBA(address));
|
||||
dprintf(_T(" play %02i:%02i:%02i\n"), displayaddress[1], displayaddress[2], displayaddress[3]);
|
||||
|
||||
return cdimgPlayLBA(cdimgMSFToLBA(address));
|
||||
}
|
||||
|
||||
static int cdimgLoadSector(int LBA, char* pBuffer)
|
||||
{
|
||||
if (CDEmuStatus == playing) return 0; // data loading
|
||||
|
||||
if (LBA != cdimgLBA || cdimgFile == NULL)
|
||||
{
|
||||
if (cdimgFile == NULL)
|
||||
{
|
||||
cdimgStop();
|
||||
|
||||
cdimgFile = fopen(cdimgTOC->Image, _T("rb"));
|
||||
if (cdimgFile == NULL)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//bprintf(PRINT_IMPORTANT, _T(" loading data at LBA %08u 0x%08X\n"), (LBA - cdimgMSFToLBA(cdimgTOC->TrackData[cdimgTrack].Address)) * 2352, LBA * 2352);
|
||||
|
||||
if (fseek(cdimgFile, (LBA - cd_pregap) * 2352, SEEK_SET))
|
||||
{
|
||||
dprintf(_T("*** couldn't seek (LBA %08u)\n"), LBA);
|
||||
|
||||
//cdimgStop(); // stopping here will break ssrpg
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CDEmuStatus = reading;
|
||||
}
|
||||
|
||||
//dprintf(_T(" reading LBA %08i 0x%08X"), LBA, ftell(cdimgFile));
|
||||
|
||||
cdimgLBA = cdimgMSFToLBA(cdimgTOC->TrackData[0].Address) + (ftell(cdimgFile) + 2351) / 2352 - cd_pregap;
|
||||
|
||||
bool status = (fread(pBuffer, 1, 2352, cdimgFile) <= 0);
|
||||
|
||||
if (status)
|
||||
{
|
||||
dprintf(_T("*** couldn't read from file\n"));
|
||||
|
||||
cdimgStop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
// dprintf(_T(" [ %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X ]\n"), pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3], pBuffer[4], pBuffer[5], pBuffer[6], pBuffer[7], pBuffer[8], pBuffer[9], pBuffer[10], pBuffer[11], pBuffer[12], pBuffer[13], pBuffer[14], pBuffer[15]);
|
||||
|
||||
cdimgLBA++;
|
||||
|
||||
return cdimgLBA;
|
||||
}
|
||||
|
||||
static UINT8* cdimgReadTOC(int track)
|
||||
{
|
||||
static UINT8 TOCEntry[4];
|
||||
|
||||
memset(&TOCEntry, 0, sizeof(TOCEntry));
|
||||
|
||||
if (track == CDEmuTOC_FIRSTLAST)
|
||||
{
|
||||
TOCEntry[0] = tobcd(cdimgTOC->FirstTrack - 1);
|
||||
TOCEntry[1] = tobcd(cdimgTOC->LastTrack);
|
||||
TOCEntry[2] = 0;
|
||||
TOCEntry[3] = 0;
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
if (track == CDEmuTOC_LASTMSF)
|
||||
{
|
||||
TOCEntry[0] = cdimgTOC->TrackData[cdimgTOC->LastTrack].Address[1];
|
||||
TOCEntry[1] = cdimgTOC->TrackData[cdimgTOC->LastTrack].Address[2];
|
||||
TOCEntry[2] = cdimgTOC->TrackData[cdimgTOC->LastTrack].Address[3];
|
||||
|
||||
TOCEntry[3] = 0;
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
if (track == CDEmuTOC_FIRSTINDEX)
|
||||
{
|
||||
if (cdimgLBA < cdimgMSFToLBA(cdimgTOC->TrackData[cdimgTOC->FirstTrack].Address))
|
||||
{
|
||||
const UINT8* addressUNBCD = dinkLBAToMSF(cdimgLBA);
|
||||
UINT8 index = ((addressUNBCD[1] * 60) + (addressUNBCD[2] + 4)) / 4;
|
||||
TOCEntry[0] = tobcd((index < 100) ? index : 99);
|
||||
}
|
||||
else
|
||||
{
|
||||
TOCEntry[0] = tobcd(1);
|
||||
}
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
if (track == CDEmuTOC_ENDOFDISC)
|
||||
{
|
||||
if (cdimgLBA >= cdimgMSFToLBA(cdimgTOC->TrackData[cdimgTOC->LastTrack].Address))
|
||||
{
|
||||
bprintf(0, _T("END OF DISC: curr.lba %06d end lba: %06d\n"), cdimgLBA, cdimgMSFToLBA(cdimgTOC->TrackData[cdimgTOC->LastTrack].Address));
|
||||
TOCEntry[0] = 1;
|
||||
}
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
|
||||
track = bcd(track);
|
||||
if (track >= cdimgTOC->FirstTrack - 1 && track <= cdimgTOC->LastTrack)
|
||||
{
|
||||
TOCEntry[0] = cdimgTOC->TrackData[track - 1].Address[1];
|
||||
TOCEntry[1] = cdimgTOC->TrackData[track - 1].Address[2];
|
||||
TOCEntry[2] = cdimgTOC->TrackData[track - 1].Address[3];
|
||||
TOCEntry[3] = cdimgTOC->TrackData[track - 1].Control >> 4;
|
||||
}
|
||||
|
||||
// dprintf(_T(" track %02i - %02x:%02x:%02x\n"), track, TOCEntry[0], TOCEntry[1], TOCEntry[2]);
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
|
||||
static UINT8* cdimgReadQChannel()
|
||||
{
|
||||
// Q channel format
|
||||
// byte 0: 41 = data, 1 = cdda ( flags described at https://en.wikipedia.org/wiki/Compact_Disc_subcode )
|
||||
// track, index, M rel, S rel, F rel, M to start, S to start, F to start, 0, CRC, CRC
|
||||
// if index is 0, MSF rel counts down to next track
|
||||
|
||||
static UINT8 QChannelData[8];
|
||||
|
||||
switch (CDEmuStatus)
|
||||
{
|
||||
case reading:
|
||||
case playing:
|
||||
{
|
||||
if (QChannel != NULL) { // .CCD/.SUB
|
||||
QChannelData[0] = QChannel[cdimgLBA].track;
|
||||
|
||||
QChannelData[1] = QChannel[cdimgLBA].MSFrel.M;
|
||||
QChannelData[2] = QChannel[cdimgLBA].MSFrel.S;
|
||||
QChannelData[3] = QChannel[cdimgLBA].MSFrel.F;
|
||||
|
||||
QChannelData[4] = QChannel[cdimgLBA].MSFrel.M;
|
||||
QChannelData[5] = QChannel[cdimgLBA].MSFrel.S;
|
||||
QChannelData[6] = QChannel[cdimgLBA].MSFrel.F;
|
||||
|
||||
QChannelData[7] = QChannel[cdimgLBA].Control;
|
||||
}
|
||||
else { // .BIN/.ISO
|
||||
const UINT8* AddressAbs = cdimgLBAToMSF(cdimgLBA);
|
||||
const UINT8* AddressRel = cdimgLBAToMSF(cdimgLBA - cdimgMSFToLBA(cdimgTOC->TrackData[cdimgTrack].Address));
|
||||
|
||||
QChannelData[0] = cdimgTOC->TrackData[cdimgTrack].TrackNumber;
|
||||
|
||||
QChannelData[1] = AddressAbs[1];
|
||||
QChannelData[2] = AddressAbs[2];
|
||||
QChannelData[3] = AddressAbs[3];
|
||||
|
||||
QChannelData[4] = AddressRel[1];
|
||||
QChannelData[5] = AddressRel[2];
|
||||
QChannelData[6] = AddressRel[3];
|
||||
|
||||
QChannelData[7] = cdimgTOC->TrackData[cdimgTrack].Control;
|
||||
}
|
||||
|
||||
// dprintf(_T(" Q %02x %02x %02x:%02x:%02x %02x:%02x:%02x\n"), QChannel[cdimgLBA].track, QChannel[cdimgLBA].index, QChannel[cdimgLBA].MSFrel.M, QChannel[cdimgLBA].MSFrel.S, QChannel[cdimgLBA].MSFrel.F, QChannel[cdimgLBA].MSFabs.M, QChannel[cdimgLBA].MSFabs.S, QChannel[cdimgLBA].MSFabs.F);
|
||||
|
||||
break;
|
||||
}
|
||||
case paused:
|
||||
break;
|
||||
|
||||
default:
|
||||
memset(QChannelData, 0, sizeof(QChannelData));
|
||||
}
|
||||
|
||||
return QChannelData;
|
||||
}
|
||||
|
||||
static int cdimgGetSoundBuffer(short* buffer, int samples)
|
||||
{
|
||||
|
||||
#define CLIP(A) ((A) < -0x8000 ? -0x8000 : (A) > 0x7fff ? 0x7fff : (A))
|
||||
|
||||
if (CDEmuStatus != playing) {
|
||||
memset(cdimgOutputbuffer, 0x00, cdimgOUT_SIZE * 2 * sizeof(short));
|
||||
return 0;
|
||||
}
|
||||
|
||||
cdimgSamples += samples;
|
||||
while (cdimgSamples > (44100 / CD_FRAMES_SECOND))
|
||||
{
|
||||
cdimgSamples -= (44100 / CD_FRAMES_SECOND);
|
||||
cdimgLBA++;
|
||||
|
||||
/* if (cdimgFile == NULL) // play next track? bad idea. -dink
|
||||
if (cdimgLBA >= cdimgMSFToLBA(cdimgTOC->TrackData[cdimgTrack + 1].Address))
|
||||
cdimgPlayLBA(cdimgLBA); */
|
||||
}
|
||||
|
||||
#if 0
|
||||
extern int counter;
|
||||
if (counter) {
|
||||
const UINT8* displayaddress = dinkLBAToMSF(cdimgLBA);
|
||||
dprintf(_T(" index %02i:%02i:%02i"), displayaddress[1], displayaddress[2], displayaddress[3]);
|
||||
INT32 endt = cdimgMSFToLBA(cdimgTOC->TrackData[cdimgTrack + 1 /* next track */].Address);
|
||||
const UINT8* displayaddressend = dinkLBAToMSF(endt);
|
||||
dprintf(_T(" end %02i:%02i:%02i\n"), displayaddressend[1], displayaddressend[2], displayaddressend[3]);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cdimgFile == NULL) { // restart play if fileptr lost
|
||||
bprintf(0, _T("CDDA file pointer lost, re-starting @ %d!\n"), cdimgLBA);
|
||||
if (cdimgLBA < cdimgMSFToLBA(cdimgTOC->TrackData[cdimgTrack + 1].Address))
|
||||
cdimgPlayLBA(cdimgLBA);
|
||||
}
|
||||
|
||||
if (cdimgFile == NULL) { // restart failed (really?) - time to give up.
|
||||
cdimgStop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cdimgLBA >= cdimgMSFToLBA(cdimgTOC->TrackData[cdimgTrack + 1 /* next track */].Address)) {
|
||||
bprintf(0, _T("End of audio track %d reached!! stopping.\n"), cdimgTrack + 1);
|
||||
cdimgStop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((cdimgOutputPosition + samples) >= cdimgOutputbufferSize)
|
||||
{
|
||||
short* src = cdimgOutputbuffer + cdimgOutputPosition * 2;
|
||||
short* dst = buffer;
|
||||
|
||||
for (int i = (cdimgOutputbufferSize - cdimgOutputPosition) * 2 - 1; i > 0; )
|
||||
{
|
||||
dst[i] = CLIP((src[i]) + dst[i]); i--;
|
||||
dst[i] = CLIP((src[i]) + dst[i]); i--;
|
||||
}
|
||||
|
||||
buffer += (cdimgOutputbufferSize - cdimgOutputPosition) * 2;
|
||||
samples -= (cdimgOutputbufferSize - cdimgOutputPosition);
|
||||
|
||||
cdimgOutputPosition = 0;
|
||||
if ((cdimgOutputbufferSize = fread(cdimgOutputbuffer, 4, cdimgOUT_SIZE, cdimgFile)) <= 0)
|
||||
cdimgStop();
|
||||
}
|
||||
|
||||
if ((cdimgOutputPosition + samples) < cdimgOutputbufferSize)
|
||||
{
|
||||
short* src = cdimgOutputbuffer + cdimgOutputPosition * 2;
|
||||
short* dst = buffer;
|
||||
|
||||
for (int i = samples * 2 - 1; i > 0; )
|
||||
{
|
||||
dst[i] = CLIP((src[i]) + dst[i]); i--;
|
||||
dst[i] = CLIP((src[i]) + dst[i]); i--;
|
||||
}
|
||||
|
||||
cdimgOutputPosition += samples;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
#undef CLIP
|
||||
|
||||
}
|
||||
|
||||
static INT32 cdimgScan(INT32 nAction, INT32* pnMin)
|
||||
{
|
||||
if (nAction & ACB_VOLATILE) {
|
||||
SCAN_VAR(CDEmuStatus);
|
||||
SCAN_VAR(cdimgTrack);
|
||||
SCAN_VAR(cdimgLBA);
|
||||
}
|
||||
|
||||
if (nAction & ACB_WRITE) {
|
||||
cdimgCloseFile();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cdimgGetSettings(InterfaceInfo* pInfo)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct CDEmuDo cdimgDo = { cdimgExit, cdimgInit, cdimgStop, cdimgPlay, cdimgLoadSector, cdimgReadTOC, cdimgReadQChannel, cdimgGetSoundBuffer, cdimgScan, cdimgGetSettings, _T("raw image CD emulation") };
|
@ -1,22 +0,0 @@
|
||||
#include "burner.h"
|
||||
#include "cd_interface.h"
|
||||
|
||||
void wav_exit()
|
||||
{
|
||||
}
|
||||
|
||||
int wav_open(TCHAR* szFile)
|
||||
{
|
||||
}
|
||||
|
||||
void wav_stop()
|
||||
{
|
||||
}
|
||||
|
||||
void wav_play()
|
||||
{
|
||||
}
|
||||
|
||||
void wav_pause(bool bResume)
|
||||
{
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#ifndef _WavClass_H_
|
||||
#define _WavClass_H_
|
||||
|
||||
void wav_exit();
|
||||
int wav_open(TCHAR* szFile);
|
||||
void wav_stop();
|
||||
void wav_play();
|
||||
|
||||
#endif
|
@ -13,6 +13,8 @@ static bool bCinpOkay;
|
||||
extern struct InputInOut InputInOutMacOS;
|
||||
#elif defined (BUILD_SDL)
|
||||
extern struct InputInOut InputInOutSDL;
|
||||
#elif defined (BUILD_SDL2)
|
||||
extern struct InputInOut InputInOutSDL2;
|
||||
#elif defined (_XBOX)
|
||||
extern struct InputInOut InputInOutXInput2;
|
||||
#elif defined (BUILD_QT)
|
||||
@ -25,6 +27,8 @@ static struct InputInOut *pInputInOut[]=
|
||||
&InputInOutDInput,
|
||||
#elif defined (BUILD_MACOS)
|
||||
&InputInOutMacOS,
|
||||
#elif defined (BUILD_SDL2)
|
||||
&InputInOutSDL2,
|
||||
#elif defined (BUILD_SDL)
|
||||
&InputInOutSDL,
|
||||
#elif defined (_XBOX)
|
||||
|
@ -208,10 +208,10 @@ int SDLinpMouseAxis(int i, int nAxis)
|
||||
}
|
||||
|
||||
switch (nAxis) {
|
||||
case 0:
|
||||
return SDLinpMouseState.xdelta;
|
||||
case 1:
|
||||
return SDLinpMouseState.ydelta;
|
||||
case 0:
|
||||
return SDLinpMouseState.xdelta;
|
||||
case 1:
|
||||
return SDLinpMouseState.ydelta;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -236,22 +236,22 @@ static int JoystickState(int i, int nSubCode)
|
||||
}
|
||||
|
||||
switch (nSubCode) {
|
||||
case 0x00: return SDL_JoystickGetAxis(JoyList[i], 0) < -DEADZONE; // Left
|
||||
case 0x01: return SDL_JoystickGetAxis(JoyList[i], 0) > DEADZONE; // Right
|
||||
case 0x02: return SDL_JoystickGetAxis(JoyList[i], 1) < -DEADZONE; // Up
|
||||
case 0x03: return SDL_JoystickGetAxis(JoyList[i], 1) > DEADZONE; // Down
|
||||
case 0x04: return SDL_JoystickGetAxis(JoyList[i], 2) < -DEADZONE;
|
||||
case 0x05: return SDL_JoystickGetAxis(JoyList[i], 2) > DEADZONE;
|
||||
case 0x06: return SDL_JoystickGetAxis(JoyList[i], 3) < -DEADZONE;
|
||||
case 0x07: return SDL_JoystickGetAxis(JoyList[i], 3) > DEADZONE;
|
||||
case 0x08: return SDL_JoystickGetAxis(JoyList[i], 4) < -DEADZONE;
|
||||
case 0x09: return SDL_JoystickGetAxis(JoyList[i], 4) > DEADZONE;
|
||||
case 0x0A: return SDL_JoystickGetAxis(JoyList[i], 5) < -DEADZONE;
|
||||
case 0x0B: return SDL_JoystickGetAxis(JoyList[i], 5) > DEADZONE;
|
||||
case 0x0C: return SDL_JoystickGetAxis(JoyList[i], 6) < -DEADZONE;
|
||||
case 0x0D: return SDL_JoystickGetAxis(JoyList[i], 6) > DEADZONE;
|
||||
case 0x0E: return SDL_JoystickGetAxis(JoyList[i], 7) < -DEADZONE;
|
||||
case 0x0F: return SDL_JoystickGetAxis(JoyList[i], 7) > DEADZONE;
|
||||
case 0x00: return SDL_JoystickGetAxis(JoyList[i], 0) < -DEADZONE; // Left
|
||||
case 0x01: return SDL_JoystickGetAxis(JoyList[i], 0) > DEADZONE; // Right
|
||||
case 0x02: return SDL_JoystickGetAxis(JoyList[i], 1) < -DEADZONE; // Up
|
||||
case 0x03: return SDL_JoystickGetAxis(JoyList[i], 1) > DEADZONE; // Down
|
||||
case 0x04: return SDL_JoystickGetAxis(JoyList[i], 2) < -DEADZONE;
|
||||
case 0x05: return SDL_JoystickGetAxis(JoyList[i], 2) > DEADZONE;
|
||||
case 0x06: return SDL_JoystickGetAxis(JoyList[i], 3) < -DEADZONE;
|
||||
case 0x07: return SDL_JoystickGetAxis(JoyList[i], 3) > DEADZONE;
|
||||
case 0x08: return SDL_JoystickGetAxis(JoyList[i], 4) < -DEADZONE;
|
||||
case 0x09: return SDL_JoystickGetAxis(JoyList[i], 4) > DEADZONE;
|
||||
case 0x0A: return SDL_JoystickGetAxis(JoyList[i], 5) < -DEADZONE;
|
||||
case 0x0B: return SDL_JoystickGetAxis(JoyList[i], 5) > DEADZONE;
|
||||
case 0x0C: return SDL_JoystickGetAxis(JoyList[i], 6) < -DEADZONE;
|
||||
case 0x0D: return SDL_JoystickGetAxis(JoyList[i], 6) > DEADZONE;
|
||||
case 0x0E: return SDL_JoystickGetAxis(JoyList[i], 7) < -DEADZONE;
|
||||
case 0x0F: return SDL_JoystickGetAxis(JoyList[i], 7) > DEADZONE;
|
||||
}
|
||||
}
|
||||
if (nSubCode < 0x20) { // POV hat controls
|
||||
@ -260,14 +260,14 @@ static int JoystickState(int i, int nSubCode)
|
||||
}
|
||||
|
||||
switch (nSubCode & 3) {
|
||||
case 0: // Left
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2) & SDL_HAT_LEFT;
|
||||
case 1: // Right
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2) & SDL_HAT_RIGHT;
|
||||
case 2: // Up
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2) & SDL_HAT_UP;
|
||||
case 3: // Down
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2) & SDL_HAT_DOWN;
|
||||
case 0: // Left
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2)& SDL_HAT_LEFT;
|
||||
case 1: // Right
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2)& SDL_HAT_RIGHT;
|
||||
case 2: // Up
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2)& SDL_HAT_UP;
|
||||
case 3: // Down
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2)& SDL_HAT_DOWN;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -286,12 +286,12 @@ static int JoystickState(int i, int nSubCode)
|
||||
static int CheckMouseState(unsigned int nSubCode)
|
||||
{
|
||||
switch (nSubCode & 0x7F) {
|
||||
case 0:
|
||||
return (SDLinpMouseState.buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;
|
||||
case 1:
|
||||
return (SDLinpMouseState.buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
||||
case 2:
|
||||
return (SDLinpMouseState.buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
|
||||
case 0:
|
||||
return (SDLinpMouseState.buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;
|
||||
case 1:
|
||||
return (SDLinpMouseState.buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
||||
case 2:
|
||||
return (SDLinpMouseState.buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -401,7 +401,8 @@ int SDLinpFind(bool CreateBaseline)
|
||||
if (nDeltaY != 0) {
|
||||
return 0x8000 | 1;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (nDeltaX != 0) {
|
||||
return 0x8000 | 0;
|
||||
}
|
||||
@ -431,31 +432,31 @@ int SDLinpGetControlName(int nCode, TCHAR* pszDeviceName, TCHAR* pszControlName)
|
||||
}
|
||||
|
||||
switch (nCode & 0xC000) {
|
||||
case 0x0000: {
|
||||
_tcscpy(pszDeviceName, _T("System keyboard"));
|
||||
case 0x0000: {
|
||||
_tcscpy(pszDeviceName, _T("System keyboard"));
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case 0x4000: {
|
||||
int i = (nCode >> 8) & 0x3F;
|
||||
|
||||
if (i >= nJoystickCount) { // This joystick isn't connected
|
||||
return 0;
|
||||
}
|
||||
case 0x4000: {
|
||||
int i = (nCode >> 8) & 0x3F;
|
||||
_tsprintf(pszDeviceName, "%hs", SDL_JoystickName(i));
|
||||
|
||||
if (i >= nJoystickCount) { // This joystick isn't connected
|
||||
return 0;
|
||||
}
|
||||
_tsprintf(pszDeviceName, "%hs", SDL_JoystickName(i));
|
||||
break;
|
||||
}
|
||||
case 0x8000: {
|
||||
int i = (nCode >> 8) & 0x3F;
|
||||
|
||||
break;
|
||||
if (i >= 1) {
|
||||
return 0;
|
||||
}
|
||||
case 0x8000: {
|
||||
int i = (nCode >> 8) & 0x3F;
|
||||
_tcscpy(pszDeviceName, _T("System mouse"));
|
||||
|
||||
if (i >= 1) {
|
||||
return 0;
|
||||
}
|
||||
_tcscpy(pszDeviceName, _T("System mouse"));
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
763
src/intf/input/sdl/inp_sdl2.cpp
Normal file
763
src/intf/input/sdl/inp_sdl2.cpp
Normal file
@ -0,0 +1,763 @@
|
||||
// Module for input using SDL
|
||||
#include <SDL.h>
|
||||
|
||||
#include "burner.h"
|
||||
|
||||
|
||||
#define MAX_JOYSTICKS (8)
|
||||
|
||||
static int FBKtoSDL[512] = { 0 };
|
||||
static int SDLtoFBK[512] = { -1 };
|
||||
static int nInitedSubsytems = 0;
|
||||
static SDL_Joystick* JoyList[MAX_JOYSTICKS];
|
||||
static int* JoyPrevAxes = NULL;
|
||||
static int nJoystickCount = 0; // Number of joysticks connected to this machine
|
||||
int buttons [4][8]= { {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1}, {-1,-1,-1,-1,-1,-1,-1,-1} }; // 4 joysticks buttons 0 -5 and start / select
|
||||
|
||||
void setup_kemaps(void)
|
||||
{
|
||||
SDLtoFBK[SDL_SCANCODE_UNKNOWN] = 0;
|
||||
SDLtoFBK[SDL_SCANCODE_A] = FBK_A;
|
||||
SDLtoFBK[SDL_SCANCODE_B] = FBK_B;
|
||||
SDLtoFBK[SDL_SCANCODE_C] = FBK_C;
|
||||
SDLtoFBK[SDL_SCANCODE_D] = FBK_D;
|
||||
SDLtoFBK[SDL_SCANCODE_E] = FBK_E;
|
||||
SDLtoFBK[SDL_SCANCODE_F] = FBK_F;
|
||||
SDLtoFBK[SDL_SCANCODE_G] = FBK_G;
|
||||
SDLtoFBK[SDL_SCANCODE_H] = FBK_H;
|
||||
SDLtoFBK[SDL_SCANCODE_I] = FBK_I;
|
||||
SDLtoFBK[SDL_SCANCODE_J] = FBK_J;
|
||||
SDLtoFBK[SDL_SCANCODE_K] = FBK_K;
|
||||
SDLtoFBK[SDL_SCANCODE_L] = FBK_L;
|
||||
SDLtoFBK[SDL_SCANCODE_M] = FBK_M;
|
||||
SDLtoFBK[SDL_SCANCODE_N] = FBK_N;
|
||||
SDLtoFBK[SDL_SCANCODE_O] = FBK_O;
|
||||
SDLtoFBK[SDL_SCANCODE_P] = FBK_P;
|
||||
SDLtoFBK[SDL_SCANCODE_Q] = FBK_Q;
|
||||
SDLtoFBK[SDL_SCANCODE_R] = FBK_R;
|
||||
SDLtoFBK[SDL_SCANCODE_S] = FBK_S;
|
||||
SDLtoFBK[SDL_SCANCODE_T] = FBK_T;
|
||||
SDLtoFBK[SDL_SCANCODE_U] = FBK_U;
|
||||
SDLtoFBK[SDL_SCANCODE_V] = FBK_V;
|
||||
SDLtoFBK[SDL_SCANCODE_W] = FBK_W;
|
||||
SDLtoFBK[SDL_SCANCODE_X] = FBK_X;
|
||||
SDLtoFBK[SDL_SCANCODE_Y] = FBK_Y;
|
||||
SDLtoFBK[SDL_SCANCODE_Z] = FBK_Z;
|
||||
|
||||
SDLtoFBK[SDL_SCANCODE_1] = FBK_1;
|
||||
SDLtoFBK[SDL_SCANCODE_2] = FBK_2;
|
||||
SDLtoFBK[SDL_SCANCODE_3] = FBK_3;
|
||||
SDLtoFBK[SDL_SCANCODE_4] = FBK_4;
|
||||
SDLtoFBK[SDL_SCANCODE_5] = FBK_5;
|
||||
SDLtoFBK[SDL_SCANCODE_6] = FBK_6;
|
||||
SDLtoFBK[SDL_SCANCODE_7] = FBK_7;
|
||||
SDLtoFBK[SDL_SCANCODE_8] = FBK_8;
|
||||
SDLtoFBK[SDL_SCANCODE_9] = FBK_9;
|
||||
SDLtoFBK[SDL_SCANCODE_0] = FBK_0;
|
||||
|
||||
SDLtoFBK[SDL_SCANCODE_RETURN] = FBK_RETURN;
|
||||
SDLtoFBK[SDL_SCANCODE_ESCAPE] = FBK_ESCAPE;
|
||||
SDLtoFBK[SDL_SCANCODE_BACKSPACE] = FBK_BACK;
|
||||
SDLtoFBK[SDL_SCANCODE_TAB] = FBK_TAB;
|
||||
SDLtoFBK[SDL_SCANCODE_SPACE] = FBK_SPACE;
|
||||
SDLtoFBK[SDL_SCANCODE_MINUS] = FBK_MINUS;
|
||||
SDLtoFBK[SDL_SCANCODE_EQUALS] = FBK_EQUALS;
|
||||
SDLtoFBK[SDL_SCANCODE_LEFTBRACKET] = FBK_LBRACKET;
|
||||
SDLtoFBK[SDL_SCANCODE_RIGHTBRACKET] = FBK_RBRACKET;
|
||||
SDLtoFBK[SDL_SCANCODE_BACKSLASH] = FBK_BACKSLASH;
|
||||
SDLtoFBK[SDL_SCANCODE_NONUSHASH] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_SEMICOLON] = FBK_SEMICOLON;
|
||||
SDLtoFBK[SDL_SCANCODE_APOSTROPHE] = FBK_APOSTROPHE;
|
||||
SDLtoFBK[SDL_SCANCODE_GRAVE] = FBK_GRAVE;
|
||||
SDLtoFBK[SDL_SCANCODE_COMMA] = FBK_COMMA;
|
||||
SDLtoFBK[SDL_SCANCODE_PERIOD] = FBK_PERIOD;
|
||||
SDLtoFBK[SDL_SCANCODE_SLASH] = FBK_SLASH;
|
||||
SDLtoFBK[SDL_SCANCODE_CAPSLOCK] = FBK_CAPITAL;
|
||||
|
||||
SDLtoFBK[SDL_SCANCODE_F1] = FBK_F1;
|
||||
SDLtoFBK[SDL_SCANCODE_F2] = FBK_F2;
|
||||
SDLtoFBK[SDL_SCANCODE_F3] = FBK_F3;
|
||||
SDLtoFBK[SDL_SCANCODE_F4] = FBK_F4;
|
||||
SDLtoFBK[SDL_SCANCODE_F5] = FBK_F5;
|
||||
SDLtoFBK[SDL_SCANCODE_F6] = FBK_F6;
|
||||
SDLtoFBK[SDL_SCANCODE_F7] = FBK_F7;
|
||||
SDLtoFBK[SDL_SCANCODE_F8] = FBK_F8;
|
||||
SDLtoFBK[SDL_SCANCODE_F9] = FBK_F9;
|
||||
SDLtoFBK[SDL_SCANCODE_F10] = FBK_F10;
|
||||
SDLtoFBK[SDL_SCANCODE_F11] = FBK_F11;
|
||||
SDLtoFBK[SDL_SCANCODE_F12] = FBK_F12;
|
||||
|
||||
SDLtoFBK[SDL_SCANCODE_PRINTSCREEN] = FBK_SYSRQ;
|
||||
SDLtoFBK[SDL_SCANCODE_SCROLLLOCK] = FBK_SCROLL;
|
||||
SDLtoFBK[SDL_SCANCODE_PAUSE] = FBK_PAUSE;
|
||||
SDLtoFBK[SDL_SCANCODE_INSERT] = FBK_INSERT;
|
||||
SDLtoFBK[SDL_SCANCODE_HOME] = FBK_HOME;
|
||||
SDLtoFBK[SDL_SCANCODE_PAGEUP] = FBK_PRIOR;
|
||||
SDLtoFBK[SDL_SCANCODE_DELETE] = FBK_DELETE;
|
||||
SDLtoFBK[SDL_SCANCODE_END] = FBK_END;
|
||||
SDLtoFBK[SDL_SCANCODE_PAGEDOWN] = FBK_NEXT;
|
||||
SDLtoFBK[SDL_SCANCODE_RIGHT] = FBK_RIGHTARROW;
|
||||
SDLtoFBK[SDL_SCANCODE_LEFT] = FBK_LEFTARROW;
|
||||
SDLtoFBK[SDL_SCANCODE_DOWN] = FBK_DOWNARROW;
|
||||
SDLtoFBK[SDL_SCANCODE_UP] = FBK_UPARROW;
|
||||
|
||||
SDLtoFBK[SDL_SCANCODE_NUMLOCKCLEAR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_DIVIDE] = FBK_DIVIDE;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_MULTIPLY] = FBK_MULTIPLY;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_MINUS] = FBK_SUBTRACT;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_PLUS] = FBK_ADD;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_ENTER] = FBK_NUMPADENTER;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_1] = FBK_NUMPAD1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_2] = FBK_NUMPAD2;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_3] = FBK_NUMPAD3;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_4] = FBK_NUMPAD4;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_5] = FBK_NUMPAD5;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_6] = FBK_NUMPAD6;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_7] = FBK_NUMPAD7;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_8] = FBK_NUMPAD8;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_9] = FBK_NUMPAD9;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_0] = FBK_NUMPAD0;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_PERIOD] = FBK_DECIMAL;
|
||||
|
||||
SDLtoFBK[SDL_SCANCODE_NONUSBACKSLASH] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_APPLICATION] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_POWER] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_EQUALS] = FBK_NUMPADEQUALS;
|
||||
SDLtoFBK[SDL_SCANCODE_F13] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F14] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F15] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F16] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F17] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F18] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F19] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F20] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F21] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F22] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F23] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_F24] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_EXECUTE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_HELP] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_MENU] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_SELECT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_STOP] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AGAIN] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_UNDO] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_CUT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_COPY] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_PASTE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_FIND] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_MUTE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_VOLUMEUP] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_VOLUMEDOWN] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_COMMA] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_EQUALSAS400] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_INTERNATIONAL1] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_INTERNATIONAL2] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_INTERNATIONAL3] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_INTERNATIONAL4] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_INTERNATIONAL5] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_INTERNATIONAL6] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_INTERNATIONAL7] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_INTERNATIONAL8] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_INTERNATIONAL9] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LANG1] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LANG2] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LANG3] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LANG4] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LANG5] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LANG6] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LANG7] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LANG8] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LANG9] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_ALTERASE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_SYSREQ] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_CANCEL] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_CLEAR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_PRIOR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_RETURN2] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_SEPARATOR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_OUT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_OPER] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_CLEARAGAIN] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_CRSEL] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_EXSEL] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_00] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_000] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_THOUSANDSSEPARATOR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_DECIMALSEPARATOR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_CURRENCYUNIT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_CURRENCYSUBUNIT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_LEFTPAREN] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_RIGHTPAREN] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_LEFTBRACE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_RIGHTBRACE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_TAB] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_BACKSPACE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_A] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_B] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_C] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_D] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_E] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_F] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_XOR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_POWER] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_PERCENT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_LESS] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_GREATER] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_AMPERSAND] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_DBLAMPERSAND] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_VERTICALBAR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_DBLVERTICALBAR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_COLON] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_HASH] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_SPACE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_AT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_EXCLAM] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_MEMSTORE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_MEMRECALL] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_MEMCLEAR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_MEMADD] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_MEMSUBTRACT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_MEMMULTIPLY] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_MEMDIVIDE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_PLUSMINUS] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_CLEAR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_CLEARENTRY] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_BINARY] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_OCTAL] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_DECIMAL] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KP_HEXADECIMAL] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LCTRL] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LSHIFT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LALT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_LGUI] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_RCTRL] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_RSHIFT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_RALT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_RGUI] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_MODE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AUDIONEXT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AUDIOPREV] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AUDIOSTOP] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AUDIOPLAY] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AUDIOMUTE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_MEDIASELECT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_WWW] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_MAIL] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_CALCULATOR] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_COMPUTER] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AC_SEARCH] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AC_HOME] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AC_BACK] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AC_FORWARD] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AC_STOP] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AC_REFRESH] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AC_BOOKMARKS] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_BRIGHTNESSDOWN] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_BRIGHTNESSUP] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_DISPLAYSWITCH] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KBDILLUMTOGGLE] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KBDILLUMDOWN] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_KBDILLUMUP] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_EJECT] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_SLEEP] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_APP1] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_APP2] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AUDIOREWIND] = -1;
|
||||
SDLtoFBK[SDL_SCANCODE_AUDIOFASTFORWARD] = -1;
|
||||
};
|
||||
|
||||
// Sets up one Joystick (for example the range of the joystick's axes)
|
||||
static int SDLinpJoystickInit(int i)
|
||||
{
|
||||
SDL_GameController *temp;
|
||||
SDL_GameControllerButtonBind bind;
|
||||
|
||||
JoyList[i] = SDL_JoystickOpen(i);
|
||||
|
||||
// need this for any mapps that need done might just read a local file and do a readme on how to add your controller this will do for now
|
||||
SDL_JoystickGUID guid = SDL_JoystickGetGUID(JoyList[i]);
|
||||
char guid_str[1024];
|
||||
SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str));
|
||||
|
||||
|
||||
char *mapping ="03000000ff1100003133000000000000,GameStation Gear Pc control pad,a:b2,b:b1,y:b0,x:b3,start:b11,back:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,leftstick:b8,rightstick:b9,";
|
||||
// remap my problamatic old gamepad that conflicts with sdl2 see https://github.com/gabomdq/SDL_GameControllerDB/issues/308#event-2941370014
|
||||
const char* name = SDL_JoystickName(JoyList[i]);
|
||||
if ( (strcmp(guid_str, "03000000ff1100003133000000000000") == 0) && (strcmp(name, "PC Game Controller ") == 0) )
|
||||
{
|
||||
|
||||
SDL_GameControllerAddMapping(mapping) ;
|
||||
}
|
||||
|
||||
temp = SDL_GameControllerOpen(i);
|
||||
mapping = SDL_GameControllerMapping(temp);
|
||||
printf("mapping %s\n",mapping);
|
||||
bind = SDL_GameControllerGetBindForButton(temp, SDL_CONTROLLER_BUTTON_A );
|
||||
|
||||
bind = SDL_GameControllerGetBindForButton(temp, SDL_CONTROLLER_BUTTON_A );
|
||||
buttons[i][0] = bind.value.button;
|
||||
|
||||
bind = SDL_GameControllerGetBindForButton(temp, SDL_CONTROLLER_BUTTON_B);
|
||||
buttons[i][1] = bind.value.button;
|
||||
|
||||
bind = SDL_GameControllerGetBindForButton(temp, SDL_CONTROLLER_BUTTON_X );
|
||||
buttons[i][2] = bind.value.button;
|
||||
|
||||
bind = SDL_GameControllerGetBindForButton(temp, SDL_CONTROLLER_BUTTON_Y);
|
||||
buttons[i][3] = bind.value.button;
|
||||
|
||||
bind = SDL_GameControllerGetBindForButton(temp, SDL_CONTROLLER_BUTTON_LEFTSHOULDER );
|
||||
buttons[i][4] = bind.value.button;
|
||||
|
||||
bind = SDL_GameControllerGetBindForButton(temp, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER );
|
||||
buttons[i][5] = bind.value.button;
|
||||
|
||||
bind = SDL_GameControllerGetBindForButton(temp, SDL_CONTROLLER_BUTTON_BACK );
|
||||
buttons[i][6] = bind.value.button;
|
||||
|
||||
bind = SDL_GameControllerGetBindForButton(temp, SDL_CONTROLLER_BUTTON_START );
|
||||
buttons[i][7] = bind.value.button;
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set up the keyboard
|
||||
static int SDLinpKeyboardInit()
|
||||
{
|
||||
for (int i = 0; i < 512; i++) {
|
||||
if (SDLtoFBK[i] > 0)
|
||||
FBKtoSDL[SDLtoFBK[i]] = i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get an interface to the mouse
|
||||
static int SDLinpMouseInit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDLinpSetCooperativeLevel(bool bExclusive, bool /*bForeGround*/)
|
||||
{
|
||||
SDL_SetRelativeMouseMode((bDrvOkay && (bExclusive || nVidFullscreen)) ? SDL_TRUE : SDL_FALSE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDLinpExit()
|
||||
{
|
||||
// Close all joysticks
|
||||
for (int i = 0; i < MAX_JOYSTICKS; i++) {
|
||||
if (JoyList[i]) {
|
||||
SDL_JoystickClose(JoyList[i]);
|
||||
JoyList[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
nJoystickCount = 0;
|
||||
|
||||
free(JoyPrevAxes);
|
||||
JoyPrevAxes = NULL;
|
||||
|
||||
nInitedSubsytems = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDLinpInit()
|
||||
{
|
||||
int nSize;
|
||||
setup_kemaps();
|
||||
SDLinpExit();
|
||||
|
||||
memset(&JoyList, 0, sizeof(JoyList));
|
||||
|
||||
nSize = MAX_JOYSTICKS * 8 * sizeof(int);
|
||||
if ((JoyPrevAxes = (int*)malloc(nSize)) == NULL) {
|
||||
SDLinpExit();
|
||||
return 1;
|
||||
}
|
||||
memset(JoyPrevAxes, 0, nSize);
|
||||
|
||||
nInitedSubsytems = SDL_WasInit(SDL_INIT_JOYSTICK);
|
||||
|
||||
if (!(nInitedSubsytems & SDL_INIT_JOYSTICK)) {
|
||||
SDL_Init(SDL_INIT_JOYSTICK);
|
||||
}
|
||||
|
||||
// Set up the joysticks
|
||||
nJoystickCount = SDL_NumJoysticks();
|
||||
for (int i = 0; i < nJoystickCount; i++) {
|
||||
SDLinpJoystickInit(i);
|
||||
}
|
||||
SDL_JoystickEventState(SDL_IGNORE);
|
||||
|
||||
// Set up the keyboard
|
||||
SDLinpKeyboardInit();
|
||||
|
||||
// Set up the mouse
|
||||
SDLinpMouseInit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned char bKeyboardRead = 0;
|
||||
const Uint8* SDLinpKeyboardState;
|
||||
|
||||
static unsigned char bJoystickRead = 0;
|
||||
|
||||
static unsigned char bMouseRead = 0;
|
||||
static struct { unsigned char buttons; int xdelta; int ydelta; } SDLinpMouseState;
|
||||
|
||||
#define SDL_KEY_IS_DOWN(key) (FBKtoSDL[key] > 0 ? SDLinpKeyboardState[FBKtoSDL[key]] : 0)
|
||||
|
||||
// Call before checking for Input in a frame
|
||||
int SDLinpStart()
|
||||
{
|
||||
// Update SDL event queue
|
||||
SDL_PumpEvents();
|
||||
|
||||
// Keyboard not read this frame
|
||||
bKeyboardRead = 0;
|
||||
|
||||
// No joysticks have been read for this frame
|
||||
bJoystickRead = 0;
|
||||
|
||||
// Mouse not read this frame
|
||||
bMouseRead = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read one of the joysticks
|
||||
static int ReadJoystick()
|
||||
{
|
||||
if (bJoystickRead) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
// All joysticks have been Read this frame
|
||||
bJoystickRead = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read one joystick axis
|
||||
int SDLinpJoyAxis(int i, int nAxis)
|
||||
{
|
||||
if (i < 0 || i >= nJoystickCount) { // This joystick number isn't connected
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ReadJoystick() != 0) { // There was an error polling the joystick
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nAxis >= SDL_JoystickNumAxes(JoyList[i])) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SDL_JoystickGetAxis(JoyList[i], nAxis) << 1;
|
||||
}
|
||||
|
||||
// Read the keyboard
|
||||
static int ReadKeyboard()
|
||||
{
|
||||
int numkeys;
|
||||
|
||||
if (bKeyboardRead) { // already read this frame - ready to go
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDLinpKeyboardState = SDL_GetKeyboardState(&numkeys);
|
||||
if (SDLinpKeyboardState == NULL) {
|
||||
return 1;
|
||||
}
|
||||
// The keyboard has been successfully Read this frame
|
||||
bKeyboardRead = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ReadMouse()
|
||||
{
|
||||
if (bMouseRead) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDLinpMouseState.buttons = SDL_GetRelativeMouseState(&(SDLinpMouseState.xdelta), &(SDLinpMouseState.ydelta));
|
||||
|
||||
bMouseRead = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read one mouse axis
|
||||
int SDLinpMouseAxis(int i, int nAxis)
|
||||
{
|
||||
if (i < 0 || i >= 1) { // Only the system mouse is supported by SDL
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (nAxis) {
|
||||
case 0:
|
||||
return SDLinpMouseState.xdelta;
|
||||
case 1:
|
||||
return SDLinpMouseState.ydelta;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check a subcode (the 40xx bit in 4001, 4102 etc) for a joystick input code
|
||||
static int JoystickState(int i, int nSubCode)
|
||||
{
|
||||
if (i < 0 || i >= nJoystickCount) { // This joystick isn't connected
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ReadJoystick() != 0) { // Error polling the joystick
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nSubCode < 0x10) { // Joystick directions
|
||||
const int DEADZONE = 0x4000;
|
||||
|
||||
if (SDL_JoystickNumAxes(JoyList[i]) <= nSubCode) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (nSubCode) {
|
||||
case 0x00: return SDL_JoystickGetAxis(JoyList[i], 0) < -DEADZONE; // Left
|
||||
case 0x01: return SDL_JoystickGetAxis(JoyList[i], 0) > DEADZONE; // Right
|
||||
case 0x02: return SDL_JoystickGetAxis(JoyList[i], 1) < -DEADZONE; // Up
|
||||
case 0x03: return SDL_JoystickGetAxis(JoyList[i], 1) > DEADZONE; // Down
|
||||
case 0x04: return SDL_JoystickGetAxis(JoyList[i], 2) < -DEADZONE;
|
||||
case 0x05: return SDL_JoystickGetAxis(JoyList[i], 2) > DEADZONE;
|
||||
case 0x06: return SDL_JoystickGetAxis(JoyList[i], 3) < -DEADZONE;
|
||||
case 0x07: return SDL_JoystickGetAxis(JoyList[i], 3) > DEADZONE;
|
||||
case 0x08: return SDL_JoystickGetAxis(JoyList[i], 4) < -DEADZONE;
|
||||
case 0x09: return SDL_JoystickGetAxis(JoyList[i], 4) > DEADZONE;
|
||||
case 0x0A: return SDL_JoystickGetAxis(JoyList[i], 5) < -DEADZONE;
|
||||
case 0x0B: return SDL_JoystickGetAxis(JoyList[i], 5) > DEADZONE;
|
||||
case 0x0C: return SDL_JoystickGetAxis(JoyList[i], 6) < -DEADZONE;
|
||||
case 0x0D: return SDL_JoystickGetAxis(JoyList[i], 6) > DEADZONE;
|
||||
case 0x0E: return SDL_JoystickGetAxis(JoyList[i], 7) < -DEADZONE;
|
||||
case 0x0F: return SDL_JoystickGetAxis(JoyList[i], 7) > DEADZONE;
|
||||
}
|
||||
}
|
||||
if (nSubCode < 0x20) { // POV hat controls
|
||||
if (SDL_JoystickNumHats(JoyList[i]) <= ((nSubCode & 0x0F) >> 2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (nSubCode & 3) {
|
||||
case 0: // Left
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2)& SDL_HAT_LEFT;
|
||||
case 1: // Right
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2)& SDL_HAT_RIGHT;
|
||||
case 2: // Up
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2)& SDL_HAT_UP;
|
||||
case 3: // Down
|
||||
return SDL_JoystickGetHat(JoyList[i], (nSubCode & 0x0F) >> 2)& SDL_HAT_DOWN;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
if (nSubCode < 0x80) { // Undefined
|
||||
return 0;
|
||||
}
|
||||
if (nSubCode < 0x80 + SDL_JoystickNumButtons(JoyList[i])) { // Joystick buttons
|
||||
return SDL_JoystickGetButton(JoyList[i], nSubCode & 0x7F);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check a subcode (the 80xx bit in 8001, 8102 etc) for a mouse input code
|
||||
static int CheckMouseState(unsigned int nSubCode)
|
||||
{
|
||||
switch (nSubCode & 0x7F) {
|
||||
case 0:
|
||||
return (SDLinpMouseState.buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;
|
||||
case 1:
|
||||
return (SDLinpMouseState.buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
||||
case 2:
|
||||
return (SDLinpMouseState.buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the state (pressed = 1, not pressed = 0) of a particular input code
|
||||
int SDLinpState(int nCode)
|
||||
{
|
||||
if (nCode < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nCode < 0x100) {
|
||||
if (ReadKeyboard() != 0) { // Check keyboard has been read - return not pressed on error
|
||||
return 0;
|
||||
}
|
||||
return SDL_KEY_IS_DOWN(nCode); // Return key state
|
||||
}
|
||||
|
||||
if (nCode < 0x4000) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nCode < 0x8000) {
|
||||
// Codes 4000-8000 = Joysticks
|
||||
int nJoyNumber = (nCode - 0x4000) >> 8;
|
||||
|
||||
// Find the joystick state in our array
|
||||
return JoystickState(nJoyNumber, nCode & 0xFF);
|
||||
}
|
||||
|
||||
if (nCode < 0xC000) {
|
||||
// Codes 8000-C000 = Mouse
|
||||
if ((nCode - 0x8000) >> 8) { // Only the system mouse is supported by SDL
|
||||
return 0;
|
||||
}
|
||||
if (ReadMouse() != 0) { // Error polling the mouse
|
||||
return 0;
|
||||
}
|
||||
return CheckMouseState(nCode & 0xFF);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// This function finds which key is pressed, and returns its code
|
||||
int SDLinpFind(bool CreateBaseline)
|
||||
{
|
||||
int nRetVal = -1; // assume nothing pressed
|
||||
|
||||
// check if any keyboard keys are pressed
|
||||
if (ReadKeyboard() == 0) {
|
||||
for (int i = 0; i < 0x100; i++) {
|
||||
if (SDL_KEY_IS_DOWN(i) > 0) {
|
||||
nRetVal = i;
|
||||
goto End;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now check all the connected joysticks
|
||||
for (int i = 0; i < nJoystickCount; i++) {
|
||||
int j;
|
||||
if (ReadJoystick() != 0) { // There was an error polling the joystick
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < 0x10; j++) { // Axes
|
||||
int nDelta = JoyPrevAxes[(i << 3) + (j >> 1)] - SDLinpJoyAxis(i, (j >> 1));
|
||||
if (nDelta < -0x4000 || nDelta > 0x4000) {
|
||||
if (JoystickState(i, j)) {
|
||||
nRetVal = 0x4000 | (i << 8) | j;
|
||||
goto End;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0x10; j < 0x20; j++) { // POV hats
|
||||
if (JoystickState(i, j)) {
|
||||
nRetVal = 0x4000 | (i << 8) | j;
|
||||
goto End;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0x80; j < 0x80 + SDL_JoystickNumButtons(JoyList[i]); j++) {
|
||||
if (JoystickState(i, j)) {
|
||||
nRetVal = 0x4000 | (i << 8) | j;
|
||||
goto End;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now the mouse
|
||||
if (ReadMouse() == 0) {
|
||||
int nDeltaX, nDeltaY;
|
||||
|
||||
for (unsigned int j = 0x80; j < 0x80 + 0x80; j++) {
|
||||
if (CheckMouseState(j)) {
|
||||
nRetVal = 0x8000 | j;
|
||||
goto End;
|
||||
}
|
||||
}
|
||||
|
||||
nDeltaX = SDLinpMouseAxis(0, 0);
|
||||
nDeltaY = SDLinpMouseAxis(0, 1);
|
||||
if (abs(nDeltaX) < abs(nDeltaY)) {
|
||||
if (nDeltaY != 0) {
|
||||
return 0x8000 | 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (nDeltaX != 0) {
|
||||
return 0x8000 | 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
End:
|
||||
|
||||
if (CreateBaseline) {
|
||||
for (int i = 0; i < nJoystickCount; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
JoyPrevAxes[(i << 3) + j] = SDLinpJoyAxis(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nRetVal;
|
||||
}
|
||||
|
||||
int SDLinpGetControlName(int nCode, TCHAR* pszDeviceName, TCHAR* pszControlName)
|
||||
{
|
||||
if (pszDeviceName) {
|
||||
pszDeviceName[0] = _T('\0');
|
||||
}
|
||||
if (pszControlName) {
|
||||
pszControlName[0] = _T('\0');
|
||||
}
|
||||
|
||||
switch (nCode & 0xC000) {
|
||||
case 0x0000: {
|
||||
_tcscpy(pszDeviceName, _T("System keyboard"));
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x4000: {
|
||||
int i = (nCode >> 8) & 0x3F;
|
||||
|
||||
if (i >= nJoystickCount) { // This joystick isn't connected
|
||||
return 0;
|
||||
}
|
||||
// _tsprintf(pszDeviceName, "%hs", SDL_JoystickName(i));
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x8000: {
|
||||
int i = (nCode >> 8) & 0x3F;
|
||||
|
||||
if (i >= 1) {
|
||||
return 0;
|
||||
}
|
||||
_tcscpy(pszDeviceName, _T("System mouse"));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct InputInOut InputInOutSDL2 = { SDLinpInit, SDLinpExit, SDLinpSetCooperativeLevel, SDLinpStart, SDLinpState, SDLinpJoyAxis, SDLinpMouseAxis, SDLinpFind, SDLinpGetControlName, NULL, _T("SDL input") };
|
478
src/intf/video/sdl/vid_sdl2.cpp
Normal file
478
src/intf/video/sdl/vid_sdl2.cpp
Normal file
@ -0,0 +1,478 @@
|
||||
// blitter effects via SDL2
|
||||
#include "burner.h"
|
||||
#include "vid_support.h"
|
||||
#include "vid_softfx.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
|
||||
extern int vsync;
|
||||
extern char videofiltering[3];
|
||||
|
||||
static unsigned char* VidMem = NULL;
|
||||
static SDL_Window* sdlWindow = NULL;
|
||||
SDL_Renderer* sdlRenderer = NULL;
|
||||
static SDL_Texture* sdlTexture = NULL;
|
||||
static SDL_Texture* overlayTexture = NULL;
|
||||
static int nRotateGame = 0;
|
||||
static bool bFlipped = false;
|
||||
static SDL_Rect dstrect;
|
||||
static SDL_Rect title_texture_rect;
|
||||
static SDL_Rect dest_title_texture_rect;
|
||||
static bool bHasOverlay = false;
|
||||
|
||||
static int screenh, screenw;
|
||||
|
||||
SDL_Texture* LoadOverlayImage(SDL_Renderer* renderer, SDL_Texture* loadedTexture)
|
||||
{
|
||||
char titlePath[MAX_PATH] = { 0 };
|
||||
int overlaywidth, overlayheight;
|
||||
|
||||
if (!bAppFullscreen)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
snprintf(titlePath, MAX_PATH, "%s%s.png", "/usr/local/share/overlays/", BurnDrvGetTextA(0));
|
||||
#else
|
||||
snprintf(titlePath, MAX_PATH, "support\\overlays\\%s.png", BurnDrvGetTextA(0));
|
||||
#endif
|
||||
printf("path %s\n", titlePath);
|
||||
loadedTexture = IMG_LoadTexture(renderer, titlePath);
|
||||
SDL_QueryTexture(loadedTexture, NULL, NULL, &overlaywidth, &overlayheight);
|
||||
|
||||
SDL_GetWindowSize(sdlWindow,
|
||||
&screenw,
|
||||
&screenh);
|
||||
|
||||
title_texture_rect.x = 0; //the x coordinate
|
||||
title_texture_rect.y = 0; // the y coordinate
|
||||
title_texture_rect.w = overlaywidth; //the width of the texture
|
||||
title_texture_rect.h = overlayheight; //the height of the texture
|
||||
|
||||
dest_title_texture_rect.x = (screenw - overlaywidth) / 2; //the x coordinate
|
||||
dest_title_texture_rect.y = (screenh - overlayheight) / 2; // the y coordinate
|
||||
dest_title_texture_rect.w = overlaywidth; //the width of the texture
|
||||
dest_title_texture_rect.h = overlayheight; //the height of the texture
|
||||
|
||||
#ifndef _WIN32
|
||||
snprintf(titlePath, MAX_PATH, "%s%s.cfg", "/usr/local/share/overlays/", BurnDrvGetTextA(0));
|
||||
#else
|
||||
snprintf(titlePath, MAX_PATH, "support\\overlays\\%s.cfg", BurnDrvGetTextA(0));
|
||||
#endif
|
||||
|
||||
FILE* h;
|
||||
TCHAR szLine[1024];
|
||||
TCHAR* t;
|
||||
TCHAR* s;
|
||||
TCHAR* szQuote;
|
||||
|
||||
int destx = 0, desty = 0 , destw = 0, desth = 0;
|
||||
int length;
|
||||
h = _tfopen(titlePath, _T("rt"));
|
||||
if (h == NULL) {
|
||||
printf("overlay config %s not found \n" ,titlePath );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (_fgetts(szLine, sizeof(szLine), h) == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
length = _tcslen(szLine);
|
||||
// get rid of the linefeed at the end
|
||||
while (length && (szLine[length - 1] == _T('\r') || szLine[length - 1] == _T('\n'))) {
|
||||
szLine[length - 1] = 0;
|
||||
length--;
|
||||
}
|
||||
|
||||
s = szLine;
|
||||
if ((t = LabelCheck(s, _T("custom_viewport_height"))) != 0) {
|
||||
s = t;
|
||||
FIND_QT(s)
|
||||
QuoteRead(&szQuote, NULL, s);
|
||||
printf("h: %s, %s , %s \n",szQuote, t, s);
|
||||
desth = _tcstol(szQuote, &t, 10);
|
||||
continue;
|
||||
}
|
||||
if ((t = LabelCheck(s, _T("custom_viewport_width"))) != 0) {
|
||||
s = t;
|
||||
FIND_QT(s)
|
||||
QuoteRead(&szQuote, NULL, s);
|
||||
destw = _tcstol(szQuote, &t, 10);
|
||||
continue;
|
||||
}
|
||||
if ((t = LabelCheck(s, _T("custom_viewport_x"))) != 0) {
|
||||
s = t;
|
||||
FIND_QT(s)
|
||||
QuoteRead(&szQuote, NULL, s);
|
||||
destx = _tcstol(szQuote, &t, 10);
|
||||
continue;
|
||||
}
|
||||
if ((t = LabelCheck(s, _T("custom_viewport_y"))) != 0) {
|
||||
s = t;
|
||||
FIND_QT(s)
|
||||
QuoteRead(&szQuote, NULL, s);
|
||||
desty = _tcstol(szQuote, &t, 10);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(h);
|
||||
if (destx && desty && destw && desth)
|
||||
{
|
||||
bHasOverlay = true;
|
||||
dstrect.y = desty;
|
||||
dstrect.x = destx;
|
||||
dstrect.h = desth;
|
||||
dstrect.w = destw;
|
||||
|
||||
if (nRotateGame)
|
||||
{
|
||||
dstrect.y = desty + (desty/2);
|
||||
dstrect.x = destx - (destx/2);
|
||||
dstrect.h = destw;
|
||||
dstrect.w = desth;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return loadedTexture;
|
||||
}
|
||||
|
||||
|
||||
void RenderMessage()
|
||||
{
|
||||
// First render anything that is key-held based
|
||||
if (bAppDoFast)
|
||||
{
|
||||
inprint_shadowed(sdlRenderer, "FFWD", 10, 10);
|
||||
}
|
||||
if (bAppShowFPS)
|
||||
{
|
||||
inprint_shadowed(sdlRenderer, fpsstring, 10, 50);
|
||||
}
|
||||
|
||||
if (messageFrames > 1)
|
||||
{
|
||||
inprint_shadowed(sdlRenderer, lastMessage, 10, 30);
|
||||
messageFrames--;
|
||||
}
|
||||
}
|
||||
|
||||
static int Exit()
|
||||
{
|
||||
kill_inline_font(); //TODO: This is not supposed to be here
|
||||
SDL_DestroyTexture(overlayTexture);
|
||||
SDL_DestroyTexture(sdlTexture);
|
||||
SDL_DestroyRenderer(sdlRenderer);
|
||||
SDL_DestroyWindow(sdlWindow);
|
||||
|
||||
free(VidMem);
|
||||
return 0;
|
||||
}
|
||||
static int display_w = 400, display_h = 300;
|
||||
|
||||
|
||||
static int Init()
|
||||
{
|
||||
int nMemLen = 0;
|
||||
int GameAspectX = 4, GameAspectY = 3;
|
||||
bHasOverlay = false;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
printf("vid init error\n");
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
|
||||
return 3;
|
||||
}
|
||||
|
||||
nRotateGame = 0;
|
||||
|
||||
if (bDrvOkay)
|
||||
{
|
||||
// Get the game screen size
|
||||
BurnDrvGetVisibleSize(&nVidImageWidth, &nVidImageHeight);
|
||||
BurnDrvGetAspect(&GameAspectX, &GameAspectY);
|
||||
|
||||
display_w = nVidImageWidth;
|
||||
display_h = nVidImageWidth * GameAspectY / GameAspectX;
|
||||
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)
|
||||
{
|
||||
BurnDrvGetVisibleSize(&nVidImageHeight, &nVidImageWidth);
|
||||
BurnDrvGetAspect(&GameAspectY, &GameAspectX);
|
||||
//BurnDrvGetAspect(&GameAspectX, &GameAspectY);
|
||||
printf("Vertical\n");
|
||||
nRotateGame = 1;
|
||||
display_w = nVidImageHeight * GameAspectX / GameAspectY;
|
||||
display_h = nVidImageHeight;
|
||||
}
|
||||
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED)
|
||||
{
|
||||
printf("Flipped\n");
|
||||
bFlipped = 1;
|
||||
}
|
||||
}
|
||||
|
||||
char title[512];
|
||||
|
||||
sprintf(title, "FBNeo - %s - %s", BurnDrvGetTextA(DRV_NAME), BurnDrvGetTextA(DRV_FULLNAME));
|
||||
|
||||
Uint32 screenFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE;
|
||||
|
||||
if (bAppFullscreen)
|
||||
{
|
||||
screenFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
}
|
||||
|
||||
dstrect.y = 0;
|
||||
dstrect.x = 0;
|
||||
dstrect.h = display_h;
|
||||
dstrect.w = display_w;
|
||||
|
||||
if (nRotateGame)
|
||||
{
|
||||
sdlWindow = SDL_CreateWindow(
|
||||
title,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
display_h,
|
||||
display_w,
|
||||
screenFlags
|
||||
);
|
||||
dstrect.y = (display_w - display_h) / 2;
|
||||
dstrect.x = (display_h - display_w) / 2;
|
||||
dstrect.h = display_h;
|
||||
dstrect.w = display_w;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sdlWindow = SDL_CreateWindow(
|
||||
title,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
display_w,
|
||||
display_h,
|
||||
screenFlags
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check that the window was successfully created
|
||||
if (sdlWindow == NULL)
|
||||
{
|
||||
// In the case that the window could not be made...
|
||||
printf("Could not create window: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
Uint32 renderflags = SDL_RENDERER_ACCELERATED;
|
||||
|
||||
if (vsync)
|
||||
{
|
||||
renderflags = renderflags | SDL_RENDERER_PRESENTVSYNC;
|
||||
}
|
||||
|
||||
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, renderflags);
|
||||
if (sdlRenderer == NULL)
|
||||
{
|
||||
// In the case that the window could not be made...
|
||||
printf("Could not create renderer: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
overlayTexture = LoadOverlayImage(sdlRenderer, overlayTexture);
|
||||
if (bHasOverlay)
|
||||
{
|
||||
SDL_SetRenderDrawBlendMode(sdlRenderer, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_SetRenderDrawBlendMode(sdlRenderer, SDL_BLENDMODE_NONE);
|
||||
}
|
||||
|
||||
nVidImageDepth = 32;
|
||||
|
||||
if (BurnDrvGetFlags() & BDF_16BIT_ONLY)
|
||||
{
|
||||
nVidImageDepth = 16;
|
||||
printf("Forcing 16bit color\n");
|
||||
}
|
||||
printf("bbp: %d\n", nVidImageDepth);
|
||||
|
||||
if (bIntegerScale)
|
||||
{
|
||||
SDL_RenderSetIntegerScale(sdlRenderer, SDL_TRUE);
|
||||
}
|
||||
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, videofiltering);
|
||||
|
||||
if (!bHasOverlay)
|
||||
{
|
||||
printf("setting logical size w: %d h: %d", display_w, display_h);
|
||||
|
||||
if (nRotateGame)
|
||||
{
|
||||
SDL_RenderSetLogicalSize(sdlRenderer, display_h, display_w);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_RenderSetLogicalSize(sdlRenderer, display_w, display_h);
|
||||
}
|
||||
}
|
||||
|
||||
inrenderer(sdlRenderer); //TODO: this is not supposed to be here
|
||||
prepare_inline_font(); // TODO: BAD
|
||||
incolor(0xFFF000, 0);
|
||||
|
||||
if (nVidImageDepth == 32)
|
||||
{
|
||||
sdlTexture = SDL_CreateTexture(sdlRenderer,
|
||||
SDL_PIXELFORMAT_RGB888,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
nVidImageWidth, nVidImageHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
sdlTexture = SDL_CreateTexture(sdlRenderer,
|
||||
SDL_PIXELFORMAT_RGB565,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
nVidImageWidth, nVidImageHeight);
|
||||
}
|
||||
if (!sdlTexture)
|
||||
{
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create sdlTexture from surface: %s", SDL_GetError());
|
||||
return 3;
|
||||
}
|
||||
|
||||
nVidImageBPP = (nVidImageDepth + 7) >> 3;
|
||||
nBurnBpp = nVidImageBPP;
|
||||
|
||||
SetBurnHighCol(nVidImageDepth);
|
||||
|
||||
nVidImagePitch = nVidImageWidth * nVidImageBPP;
|
||||
nBurnPitch = nVidImagePitch;
|
||||
|
||||
nMemLen = nVidImageWidth * nVidImageHeight * nVidImageBPP;
|
||||
|
||||
printf("nVidImageWidth=%d nVidImageHeight=%d nVidImagePitch=%d\n", nVidImageWidth, nVidImageHeight, nVidImagePitch);
|
||||
|
||||
VidMem = (unsigned char*)malloc(nMemLen);
|
||||
if (VidMem)
|
||||
{
|
||||
memset(VidMem, 0, nMemLen);
|
||||
pVidImage = VidMem;
|
||||
printf("Malloc for video Ok %d\n", nMemLen);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pVidImage = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
printf("done vid init");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vidScale(RECT*, int, int)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Run one frame and render the screen
|
||||
static int Frame(bool bRedraw) // bRedraw = 0
|
||||
{
|
||||
if (pVidImage == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bDrvOkay)
|
||||
{
|
||||
if (bRedraw)
|
||||
{ // Redraw current frame
|
||||
if (BurnDrvRedraw())
|
||||
{
|
||||
BurnDrvFrame(); // No redraw function provided, advance one frame
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BurnDrvFrame(); // Run one frame and draw the screen
|
||||
}
|
||||
|
||||
if ((BurnDrvGetFlags() & BDF_16BIT_ONLY) && pVidTransCallback)
|
||||
{
|
||||
pVidTransCallback();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Paint the BlitFX surface onto the primary surface
|
||||
static int Paint(int bValidate)
|
||||
{
|
||||
void* pixels;
|
||||
int pitch;
|
||||
|
||||
SDL_RenderClear(sdlRenderer);
|
||||
|
||||
if (nRotateGame)
|
||||
{SDL_Point window_size = {nVidImageHeight, nVidImageWidth};
|
||||
SDL_UpdateTexture(sdlTexture, NULL, pVidImage, nVidImagePitch);
|
||||
if (nRotateGame && bFlipped)
|
||||
{
|
||||
SDL_RenderCopyEx(sdlRenderer, sdlTexture, NULL, &dstrect, 90, NULL, SDL_FLIP_NONE);
|
||||
}
|
||||
if (nRotateGame && !bFlipped)
|
||||
{
|
||||
SDL_RenderCopyEx(sdlRenderer, sdlTexture, NULL, &dstrect, 270, NULL, SDL_FLIP_NONE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_LockTexture(sdlTexture, NULL, &pixels, &pitch);
|
||||
memcpy(pixels, pVidImage, nVidImagePitch * nVidImageHeight);
|
||||
SDL_UnlockTexture(sdlTexture);
|
||||
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, &dstrect);
|
||||
}
|
||||
|
||||
RenderMessage();
|
||||
|
||||
|
||||
if (bHasOverlay)
|
||||
{
|
||||
if (bIntegerScale)
|
||||
{
|
||||
SDL_RenderSetIntegerScale(sdlRenderer, SDL_FALSE);
|
||||
}
|
||||
|
||||
SDL_RenderCopy(sdlRenderer, overlayTexture, &title_texture_rect, &dest_title_texture_rect);
|
||||
|
||||
if (bIntegerScale)
|
||||
{
|
||||
SDL_RenderSetIntegerScale(sdlRenderer, SDL_TRUE);
|
||||
}
|
||||
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, "0");
|
||||
}
|
||||
|
||||
SDL_RenderPresent(sdlRenderer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int GetSettings(InterfaceInfo* pInfo)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The Video Output plugin:
|
||||
struct VidOut VidOutSDL2 = { Init, Exit, Frame, Paint, vidScale, GetSettings, _T("SDL2 video output") };
|
384
src/intf/video/sdl/vid_sdl2opengl.cpp
Normal file
384
src/intf/video/sdl/vid_sdl2opengl.cpp
Normal file
@ -0,0 +1,384 @@
|
||||
// OpenGL via SDL2
|
||||
#include "burner.h"
|
||||
#include "vid_support.h"
|
||||
#include "vid_softfx.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_opengl.h>
|
||||
|
||||
static SDL_GLContext glContext = NULL;
|
||||
|
||||
static int nInitedSubsytems = 0;
|
||||
|
||||
static int nGamesWidth = 0, nGamesHeight = 0; // screen size
|
||||
|
||||
static GLint texture_type = GL_UNSIGNED_BYTE;
|
||||
static SDL_Window* screen = NULL;
|
||||
static unsigned char* texture = NULL;
|
||||
static unsigned char* gamescreen = NULL;
|
||||
|
||||
static int nTextureWidth = 512;
|
||||
static int nTextureHeight = 512;
|
||||
|
||||
static int nSize;
|
||||
static int nUseBlitter;
|
||||
|
||||
static int nRotateGame = 0;
|
||||
static bool bFlipped = false;
|
||||
|
||||
static int BlitFXExit()
|
||||
{
|
||||
SDL_DestroyWindow(screen);
|
||||
SDL_GL_DeleteContext(glContext);
|
||||
free(texture);
|
||||
free(gamescreen);
|
||||
nRotateGame = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int GetTextureSize(int Size)
|
||||
{
|
||||
int nTextureSize = 128;
|
||||
|
||||
while (nTextureSize < Size)
|
||||
{
|
||||
nTextureSize <<= 1;
|
||||
}
|
||||
|
||||
return nTextureSize;
|
||||
}
|
||||
|
||||
static int BlitFXInit()
|
||||
{
|
||||
int nMemLen = 0;
|
||||
|
||||
nVidImageDepth = bDrvOkay ? 16 : 32;
|
||||
nVidImageBPP = (nVidImageDepth + 7) >> 3;
|
||||
nBurnBpp = nVidImageBPP;
|
||||
|
||||
SetBurnHighCol(nVidImageDepth);
|
||||
|
||||
if (!nRotateGame)
|
||||
{
|
||||
nVidImageWidth = nGamesWidth;
|
||||
nVidImageHeight = nGamesHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
nVidImageWidth = nGamesHeight;
|
||||
nVidImageHeight = nGamesWidth;
|
||||
}
|
||||
|
||||
nVidImagePitch = nVidImageWidth * nVidImageBPP;
|
||||
nBurnPitch = nVidImagePitch;
|
||||
|
||||
nMemLen = nVidImageWidth * nVidImageHeight * nVidImageBPP;
|
||||
|
||||
printf("nVidImageWidth=%d nVidImageHeight=%d nVidImagePitch=%d\n", nVidImageWidth, nVidImageHeight, nVidImagePitch);
|
||||
printf("nTextureWidth=%d nTextureHeight=%d TexturePitch=%d\n", nTextureWidth, nTextureHeight, nTextureWidth * nVidImageBPP);
|
||||
|
||||
texture = (unsigned char*)malloc(nTextureWidth * nTextureHeight * nVidImageBPP);
|
||||
|
||||
gamescreen = (unsigned char*)malloc(nMemLen);
|
||||
if (gamescreen)
|
||||
{
|
||||
memset(gamescreen, 0, nMemLen);
|
||||
pVidImage = gamescreen;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pVidImage = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Exit()
|
||||
{
|
||||
BlitFXExit();
|
||||
|
||||
if (!(nInitedSubsytems & SDL_INIT_VIDEO))
|
||||
{
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
nInitedSubsytems = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void init_gl()
|
||||
{
|
||||
printf("opengl config\n");
|
||||
|
||||
if ((BurnDrvGetFlags() & BDF_16BIT_ONLY) || (nVidImageBPP != 3))
|
||||
{
|
||||
texture_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
}
|
||||
else
|
||||
{
|
||||
texture_type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
glDisable(GL_POLYGON_SMOOTH);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, nTextureWidth, nTextureHeight, 0, GL_RGB, texture_type, texture);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
if (!nRotateGame)
|
||||
{
|
||||
glRotatef(0.0, 0.0, 0.0, 1.0);
|
||||
glOrtho(0, nGamesWidth, nGamesHeight, 0, -1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
glRotatef((bFlipped ? 270.0 : 90.0), 0.0, 0.0, 1.0);
|
||||
glOrtho(0, nGamesHeight, nGamesWidth, 0, -1, 1);
|
||||
}
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
printf("opengl config done . . . \n");
|
||||
}
|
||||
|
||||
static int VidSScaleImage(RECT* pRect)
|
||||
{
|
||||
int nScrnWidth, nScrnHeight;
|
||||
|
||||
int nGameAspectX = 4, nGameAspectY = 3;
|
||||
int nWidth = pRect->right - pRect->left;
|
||||
int nHeight = pRect->bottom - pRect->top;
|
||||
|
||||
if (bVidFullStretch)
|
||||
{ // Arbitrary stretch
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bDrvOkay)
|
||||
{
|
||||
if ((BurnDrvGetFlags() & (BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED)))
|
||||
{
|
||||
BurnDrvGetAspect(&nGameAspectY, &nGameAspectX);
|
||||
}
|
||||
else
|
||||
{
|
||||
BurnDrvGetAspect(&nGameAspectX, &nGameAspectY);
|
||||
}
|
||||
}
|
||||
|
||||
nScrnWidth = nGameAspectX;
|
||||
nScrnHeight = nGameAspectY;
|
||||
|
||||
int nWidthScratch = nHeight * nVidScrnAspectY * nGameAspectX * nScrnWidth /
|
||||
(nScrnHeight * nVidScrnAspectX * nGameAspectY);
|
||||
|
||||
if (nWidthScratch > nWidth)
|
||||
{ // The image is too wide
|
||||
if (nGamesWidth < nGamesHeight)
|
||||
{ // Vertical games
|
||||
nHeight = nWidth * nVidScrnAspectY * nGameAspectY * nScrnWidth /
|
||||
(nScrnHeight * nVidScrnAspectX * nGameAspectX);
|
||||
}
|
||||
else
|
||||
{ // Horizontal games
|
||||
nHeight = nWidth * nVidScrnAspectX * nGameAspectY * nScrnHeight /
|
||||
(nScrnWidth * nVidScrnAspectY * nGameAspectX);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nWidth = nWidthScratch;
|
||||
}
|
||||
|
||||
pRect->left = (pRect->right + pRect->left) / 2;
|
||||
pRect->left -= nWidth / 2;
|
||||
pRect->right = pRect->left + nWidth;
|
||||
|
||||
pRect->top = (pRect->top + pRect->bottom) / 2;
|
||||
pRect->top -= nHeight / 2;
|
||||
pRect->bottom = pRect->top + nHeight;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Init()
|
||||
{
|
||||
nInitedSubsytems = SDL_WasInit(SDL_INIT_VIDEO);
|
||||
|
||||
if (!(nInitedSubsytems & SDL_INIT_VIDEO))
|
||||
{
|
||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
nGamesWidth = nVidImageWidth;
|
||||
nGamesHeight = nVidImageHeight;
|
||||
|
||||
nRotateGame = 0;
|
||||
|
||||
if (bDrvOkay) {
|
||||
// Get the game screen size
|
||||
BurnDrvGetVisibleSize(&nGamesWidth, &nGamesHeight);
|
||||
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)
|
||||
{
|
||||
printf("Vertical\n");
|
||||
nRotateGame = 1;
|
||||
}
|
||||
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED)
|
||||
{
|
||||
printf("Flipped\n");
|
||||
bFlipped = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nRotateGame)
|
||||
{
|
||||
nTextureWidth = GetTextureSize(nGamesWidth);
|
||||
nTextureHeight = GetTextureSize(nGamesHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
nTextureWidth = GetTextureSize(nGamesHeight);
|
||||
nTextureHeight = GetTextureSize(nGamesWidth);
|
||||
}
|
||||
|
||||
nSize = 2;
|
||||
bVidScanlines = 0;
|
||||
|
||||
RECT test_rect;
|
||||
test_rect.left = 0;
|
||||
test_rect.right = nGamesWidth;
|
||||
test_rect.top = 0;
|
||||
test_rect.bottom = nGamesHeight;
|
||||
|
||||
printf("correctx before %d, %d\n", test_rect.right, test_rect.bottom);
|
||||
VidSScaleImage(&test_rect);
|
||||
printf("correctx after %d, %d\n", test_rect.right, test_rect.bottom);
|
||||
|
||||
|
||||
screen = SDL_CreateWindow("FBNeo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, test_rect.right * nSize,
|
||||
test_rect.bottom * nSize, SDL_WINDOW_OPENGL);
|
||||
glContext = SDL_GL_CreateContext(screen);
|
||||
// Initialize the buffer surfaces
|
||||
BlitFXInit();
|
||||
|
||||
// Init opengl
|
||||
init_gl();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Run one frame and render the screen
|
||||
static int Frame(bool bRedraw) // bRedraw = 0
|
||||
{
|
||||
if (pVidImage == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bDrvOkay)
|
||||
{
|
||||
if (bRedraw)
|
||||
{ // Redraw current frame
|
||||
if (BurnDrvRedraw())
|
||||
{
|
||||
BurnDrvFrame(); // No redraw function provided, advance one frame
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BurnDrvFrame(); // Run one frame and draw the screen
|
||||
}
|
||||
|
||||
if ((BurnDrvGetFlags() & BDF_16BIT_ONLY) && pVidTransCallback)
|
||||
{
|
||||
pVidTransCallback();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SurfToTex()
|
||||
{
|
||||
int nVidPitch = nTextureWidth * nVidImageBPP;
|
||||
|
||||
unsigned char* ps = (unsigned char*)gamescreen;
|
||||
unsigned char* pd = (unsigned char*)texture;
|
||||
|
||||
for (int y = nVidImageHeight; y--;)
|
||||
{
|
||||
memcpy(pd, ps, nVidImagePitch);
|
||||
pd += nVidPitch;
|
||||
ps += nVidImagePitch;
|
||||
}
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, nTextureWidth, nTextureHeight, 0,
|
||||
GL_RGB, texture_type, texture);
|
||||
}
|
||||
|
||||
static void TexToQuad()
|
||||
{
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2i(0, 0);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2i(0, nTextureHeight);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2i(nTextureWidth, nTextureHeight);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2i(nTextureWidth, 0);
|
||||
glEnd();
|
||||
glFinish();
|
||||
}
|
||||
|
||||
// Paint the BlitFX surface onto the primary surface
|
||||
static int Paint(int bValidate)
|
||||
{
|
||||
|
||||
SurfToTex();
|
||||
TexToQuad();
|
||||
SDL_GL_SwapWindow(screen);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vidScale(RECT*, int, int)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int GetSettings(InterfaceInfo* pInfo)
|
||||
{
|
||||
TCHAR szString[MAX_PATH] = _T("");
|
||||
|
||||
_sntprintf(szString, MAX_PATH, _T("Prescaling using %s (%i<> zoom)"), VidSoftFXGetEffect(nUseBlitter), nSize);
|
||||
IntInfoAddStringModule(pInfo, szString);
|
||||
|
||||
if (nRotateGame)
|
||||
{
|
||||
IntInfoAddStringModule(pInfo, _T("Using software rotation"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The Video Output plugin:
|
||||
struct VidOut VidOutSDL2Opengl = { Init, Exit, Frame, Paint, vidScale, GetSettings, _T("SDL OpenGL Video output") };
|
@ -6,7 +6,7 @@
|
||||
static int nInitedSubsytems = 0;
|
||||
|
||||
static int nGameWidth = 0, nGameHeight = 0; // screen size
|
||||
SDL_Surface* sdlsBlitFX[2] = {NULL, }; // The image surfaces
|
||||
SDL_Surface* sdlsBlitFX[2] = { NULL, }; // The image surfaces
|
||||
SDL_Surface* sdlsFramebuf = NULL;
|
||||
|
||||
static int nSize;
|
||||
@ -74,14 +74,16 @@ static int BlitFXInit()
|
||||
if (nRotateGame & 1) {
|
||||
nVidImageWidth = nGameHeight;
|
||||
nVidImageHeight = nGameWidth;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
nVidImageWidth = nGameWidth;
|
||||
nVidImageHeight = nGameHeight;
|
||||
}
|
||||
|
||||
if (nUseBlitter >= 7 && nUseBlitter <= 9) {
|
||||
nVidImageDepth = 16; // Use 565 format
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
nVidImageDepth = sdlsFramebuf->format->BitsPerPixel;// Use color depth of primary surface
|
||||
}
|
||||
nVidImageBPP = sdlsFramebuf->format->BytesPerPixel;
|
||||
@ -133,13 +135,14 @@ static int Init()
|
||||
// Get the game screen size
|
||||
BurnDrvGetVisibleSize(&nGameWidth, &nGameHeight);
|
||||
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
|
||||
if (nVidRotationAdjust & 1) {
|
||||
int n = nGameWidth;
|
||||
nGameWidth = nGameHeight;
|
||||
nGameHeight = n;
|
||||
nRotateGame |= (nVidRotationAdjust & 2);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
nRotateGame |= 1;
|
||||
}
|
||||
}
|
||||
@ -160,7 +163,8 @@ static int Init()
|
||||
dprintf(_T("*** Couldn't enter fullscreen mode.\n"));
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if ((sdlsFramebuf = SDL_SetVideoMode(nGameWidth * nSize, nGameHeight * nSize, 0, SDL_RESIZABLE | SDL_HWSURFACE)) == NULL) {
|
||||
return 1;
|
||||
}
|
||||
@ -181,7 +185,7 @@ static int Init()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vidScale(RECT* , int, int)
|
||||
static int vidScale(RECT*, int, int)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -206,7 +210,7 @@ static int MemToSurf()
|
||||
unsigned char* VidSurf = (unsigned char*)sdlsBlitFX[0]->pixels;
|
||||
int nVidPitch = sdlsBlitFX[0]->pitch;
|
||||
|
||||
unsigned char *pd, *ps;
|
||||
unsigned char* pd, * ps;
|
||||
|
||||
int nHeight = nGameHeight * nSize;
|
||||
|
||||
@ -234,7 +238,8 @@ static int Frame(bool bRedraw) // bRedraw = 0
|
||||
if (BurnDrvRedraw()) {
|
||||
BurnDrvFrame(); // No redraw function provided, advance one frame
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BurnDrvFrame(); // Run one frame and draw the screen
|
||||
}
|
||||
|
||||
@ -266,7 +271,8 @@ static int Paint(int bValidate)
|
||||
return 1;
|
||||
}
|
||||
SDL_Flip(sdlsFramebuf);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Normal
|
||||
|
||||
if (SDL_BlitSurface(sdlsBlitFX[nUseSys], NULL, sdlsFramebuf, &sdlrDest)) {
|
||||
|
@ -13,11 +13,10 @@ static int nInitedSubsytems = 0;
|
||||
|
||||
static int nGamesWidth = 0, nGamesHeight = 0; // screen size
|
||||
|
||||
static SDL_Surface *screen=NULL;
|
||||
static unsigned char *texture = NULL;
|
||||
static unsigned char *gamescreen=NULL;
|
||||
static SDL_Surface* screen = NULL;
|
||||
static unsigned char* texture = NULL;
|
||||
static unsigned char* gamescreen = NULL;
|
||||
|
||||
static GLint color_type = GL_RGB;
|
||||
static GLint texture_type = GL_UNSIGNED_BYTE;
|
||||
|
||||
static int nTextureWidth = 512;
|
||||
@ -29,17 +28,6 @@ static int nUseBlitter;
|
||||
static int nRotateGame = 0;
|
||||
static bool bFlipped = false;
|
||||
|
||||
static int PrimClear()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create a secondary DD surface for the screen
|
||||
static int BlitFXMakeSurf()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int BlitFXExit()
|
||||
{
|
||||
SDL_FreeSurface(screen);
|
||||
@ -54,7 +42,8 @@ static int GetTextureSize(int Size)
|
||||
{
|
||||
int nTextureSize = 128;
|
||||
|
||||
while (nTextureSize < Size) {
|
||||
while (nTextureSize < Size)
|
||||
{
|
||||
nTextureSize <<= 1;
|
||||
}
|
||||
|
||||
@ -71,10 +60,13 @@ static int BlitFXInit()
|
||||
|
||||
SetBurnHighCol(nVidImageDepth);
|
||||
|
||||
if (!nRotateGame) {
|
||||
if (!nRotateGame)
|
||||
{
|
||||
nVidImageWidth = nGamesWidth;
|
||||
nVidImageHeight = nGamesHeight;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
nVidImageWidth = nGamesHeight;
|
||||
nVidImageHeight = nGamesWidth;
|
||||
}
|
||||
@ -84,19 +76,20 @@ static int BlitFXInit()
|
||||
|
||||
nMemLen = nVidImageWidth * nVidImageHeight * nVidImageBPP;
|
||||
|
||||
printf("nVidImageWidth=%d nVidImageHeight=%d nVidImagePitch=%d\n",
|
||||
nVidImageWidth, nVidImageHeight, nVidImagePitch);
|
||||
printf("nTextureWidth=%d nTextureHeight=%d TexturePitch=%d\n",
|
||||
nTextureWidth, nTextureHeight, nTextureWidth * nVidImageBPP);
|
||||
printf("nVidImageWidth=%d nVidImageHeight=%d nVidImagePitch=%d\n", nVidImageWidth, nVidImageHeight, nVidImagePitch);
|
||||
printf("nTextureWidth=%d nTextureHeight=%d TexturePitch=%d\n", nTextureWidth, nTextureHeight, nTextureWidth * nVidImageBPP);
|
||||
|
||||
texture = (unsigned char *)malloc(nTextureWidth * nTextureHeight * nVidImageBPP);
|
||||
texture = (unsigned char*)malloc(nTextureWidth * nTextureHeight * nVidImageBPP);
|
||||
|
||||
gamescreen = (unsigned char *)malloc(nMemLen);
|
||||
if (gamescreen) {
|
||||
gamescreen = (unsigned char*)malloc(nMemLen);
|
||||
if (gamescreen)
|
||||
{
|
||||
memset(gamescreen, 0, nMemLen);
|
||||
pVidImage = gamescreen;
|
||||
return 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
pVidImage = NULL;
|
||||
return 1;
|
||||
}
|
||||
@ -108,7 +101,8 @@ static int Exit()
|
||||
{
|
||||
BlitFXExit();
|
||||
|
||||
if (!(nInitedSubsytems & SDL_INIT_VIDEO)) {
|
||||
if (!(nInitedSubsytems & SDL_INIT_VIDEO))
|
||||
{
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
@ -119,14 +113,14 @@ static int Exit()
|
||||
|
||||
void init_gl()
|
||||
{
|
||||
const unsigned char *glVersion;
|
||||
int isGL12 = GL_FALSE;
|
||||
|
||||
printf("opengl config\n");
|
||||
|
||||
if ((BurnDrvGetFlags() & BDF_16BIT_ONLY) || (nVidImageBPP != 3)) {
|
||||
if ((BurnDrvGetFlags() & BDF_16BIT_ONLY) || (nVidImageBPP != 3))
|
||||
{
|
||||
texture_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
texture_type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
@ -141,16 +135,18 @@ void init_gl()
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, nTextureWidth, nTextureHeight,
|
||||
0, GL_RGB, texture_type, texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, nTextureWidth, nTextureHeight, 0, GL_RGB, texture_type, texture);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
if (!nRotateGame) {
|
||||
if (!nRotateGame)
|
||||
{
|
||||
glRotatef(0.0, 0.0, 0.0, 1.0);
|
||||
glOrtho(0, nGamesWidth, nGamesHeight, 0, -1, 1);
|
||||
} else {
|
||||
glOrtho(0, nGamesWidth, nGamesHeight, 0, -1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
glRotatef((bFlipped ? 270.0 : 90.0), 0.0, 0.0, 1.0);
|
||||
glOrtho(0, nGamesHeight, nGamesWidth, 0, -1, 1);
|
||||
}
|
||||
@ -169,14 +165,19 @@ int VidSScaleImage(RECT* pRect)
|
||||
int nWidth = pRect->right - pRect->left;
|
||||
int nHeight = pRect->bottom - pRect->top;
|
||||
|
||||
if (bVidFullStretch) { // Arbitrary stretch
|
||||
if (bVidFullStretch)
|
||||
{ // Arbitrary stretch
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bDrvOkay) {
|
||||
if ((BurnDrvGetFlags() & (BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED))) {
|
||||
if (bDrvOkay)
|
||||
{
|
||||
if ((BurnDrvGetFlags() & (BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED)))
|
||||
{
|
||||
BurnDrvGetAspect(&nGameAspectY, &nGameAspectX);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
BurnDrvGetAspect(&nGameAspectX, &nGameAspectY);
|
||||
}
|
||||
}
|
||||
@ -185,17 +186,23 @@ int VidSScaleImage(RECT* pRect)
|
||||
nScrnHeight = nGameAspectY;
|
||||
|
||||
int nWidthScratch = nHeight * nVidScrnAspectY * nGameAspectX * nScrnWidth /
|
||||
(nScrnHeight * nVidScrnAspectX * nGameAspectY);
|
||||
(nScrnHeight * nVidScrnAspectX * nGameAspectY);
|
||||
|
||||
if (nWidthScratch > nWidth) { // The image is too wide
|
||||
if (nGamesWidth < nGamesHeight) { // Vertical games
|
||||
if (nWidthScratch > nWidth)
|
||||
{ // The image is too wide
|
||||
if (nGamesWidth < nGamesHeight)
|
||||
{ // Vertical games
|
||||
nHeight = nWidth * nVidScrnAspectY * nGameAspectY * nScrnWidth /
|
||||
(nScrnHeight * nVidScrnAspectX * nGameAspectX);
|
||||
} else { // Horizontal games
|
||||
nHeight = nWidth * nVidScrnAspectX * nGameAspectY * nScrnHeight /
|
||||
(nScrnWidth * nVidScrnAspectY * nGameAspectX);
|
||||
(nScrnHeight * nVidScrnAspectX * nGameAspectX);
|
||||
}
|
||||
} else {
|
||||
else
|
||||
{ // Horizontal games
|
||||
nHeight = nWidth * nVidScrnAspectX * nGameAspectY * nScrnHeight /
|
||||
(nScrnWidth * nVidScrnAspectY * nGameAspectX);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nWidth = nWidthScratch;
|
||||
}
|
||||
|
||||
@ -214,7 +221,8 @@ static int Init()
|
||||
{
|
||||
nInitedSubsytems = SDL_WasInit(SDL_INIT_VIDEO);
|
||||
|
||||
if (!(nInitedSubsytems & SDL_INIT_VIDEO)) {
|
||||
if (!(nInitedSubsytems & SDL_INIT_VIDEO))
|
||||
{
|
||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
@ -227,25 +235,36 @@ static int Init()
|
||||
// Get the game screen size
|
||||
BurnDrvGetVisibleSize(&nGamesWidth, &nGamesHeight);
|
||||
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)
|
||||
{
|
||||
printf("Vertical\n");
|
||||
nRotateGame = 1;
|
||||
}
|
||||
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED) {
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED)
|
||||
{
|
||||
printf("Flipped\n");
|
||||
bFlipped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!nRotateGame) {
|
||||
if (!nRotateGame)
|
||||
{
|
||||
nTextureWidth = GetTextureSize(nGamesWidth);
|
||||
nTextureHeight = GetTextureSize(nGamesHeight);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
nTextureWidth = GetTextureSize(nGamesHeight);
|
||||
nTextureHeight = GetTextureSize(nGamesWidth);
|
||||
}
|
||||
|
||||
printf("Checking video modes\n");
|
||||
const SDL_VideoInfo* info = SDL_GetVideoInfo(); //<-- calls SDL_GetVideoInfo();
|
||||
int screenWidth = info->current_w;
|
||||
int screenHeight = info->current_h;
|
||||
printf("screen w: %i h: %i\n", screenWidth, screenHeight);
|
||||
|
||||
nSize = 2;
|
||||
bVidScanlines = 0;
|
||||
|
||||
@ -258,9 +277,18 @@ static int Init()
|
||||
printf("correctx before %d, %d\n", test_rect.right, test_rect.bottom);
|
||||
VidSScaleImage(&test_rect);
|
||||
printf("correctx after %d, %d\n", test_rect.right, test_rect.bottom);
|
||||
// Make the window as big as possible, but not too big..
|
||||
if (test_rect.right > test_rect.bottom)
|
||||
{
|
||||
nSize = floor(screenWidth / test_rect.right) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nSize = floor(screenHeight / test_rect.bottom) - 1;
|
||||
}
|
||||
|
||||
screen = SDL_SetVideoMode(test_rect.right * nSize,
|
||||
test_rect.bottom * nSize, 32, SDL_OPENGL);
|
||||
test_rect.bottom * nSize, 32, SDL_OPENGL);
|
||||
|
||||
// Initialize the buffer surfaces
|
||||
BlitFXInit();
|
||||
@ -274,21 +302,29 @@ static int Init()
|
||||
// Run one frame and render the screen
|
||||
static int Frame(bool bRedraw) // bRedraw = 0
|
||||
{
|
||||
if (pVidImage == NULL) {
|
||||
if (pVidImage == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bDrvOkay) {
|
||||
if (bRedraw) { // Redraw current frame
|
||||
if (BurnDrvRedraw()) {
|
||||
if (bDrvOkay)
|
||||
{
|
||||
if (bRedraw)
|
||||
{ // Redraw current frame
|
||||
if (BurnDrvRedraw())
|
||||
{
|
||||
BurnDrvFrame(); // No redraw function provided, advance one frame
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
BurnDrvFrame(); // Run one frame and draw the screen
|
||||
}
|
||||
|
||||
if ((BurnDrvGetFlags() & BDF_16BIT_ONLY) && pVidTransCallback)
|
||||
{
|
||||
pVidTransCallback();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -298,17 +334,18 @@ static void SurfToTex()
|
||||
{
|
||||
int nVidPitch = nTextureWidth * nVidImageBPP;
|
||||
|
||||
unsigned char *ps = (unsigned char *)gamescreen;
|
||||
unsigned char *pd = (unsigned char *)texture;
|
||||
unsigned char* ps = (unsigned char*)gamescreen;
|
||||
unsigned char* pd = (unsigned char*)texture;
|
||||
|
||||
for (int y = nVidImageHeight; y--;) {
|
||||
for (int y = nVidImageHeight; y--;)
|
||||
{
|
||||
memcpy(pd, ps, nVidImagePitch);
|
||||
pd += nVidPitch;
|
||||
ps += nVidImagePitch;
|
||||
}
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, nTextureWidth, nTextureHeight, 0,
|
||||
GL_RGB, texture_type, texture);
|
||||
GL_RGB, texture_type, texture);
|
||||
}
|
||||
|
||||
static void TexToQuad()
|
||||
@ -324,7 +361,7 @@ static void TexToQuad()
|
||||
glVertex2i(nTextureWidth, 0);
|
||||
glEnd();
|
||||
glFinish();
|
||||
}
|
||||
}
|
||||
|
||||
// Paint the BlitFX surface onto the primary surface
|
||||
static int Paint(int bValidate)
|
||||
@ -343,7 +380,8 @@ static int Paint(int bValidate)
|
||||
gettimeofday(&end, NULL);
|
||||
sec = end.tv_sec - start.tv_sec;
|
||||
usec = end.tv_usec - start.tv_usec;
|
||||
if (usec < 0) {
|
||||
if (usec < 0)
|
||||
{
|
||||
usec += 1000000;
|
||||
sec--;
|
||||
}
|
||||
@ -353,21 +391,21 @@ static int Paint(int bValidate)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vidScale(RECT *, int, int)
|
||||
static int vidScale(RECT*, int, int)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int GetSettings(InterfaceInfo *pInfo)
|
||||
static int GetSettings(InterfaceInfo* pInfo)
|
||||
{
|
||||
TCHAR szString[MAX_PATH] = _T("");
|
||||
|
||||
_sntprintf(szString, MAX_PATH, _T("Prescaling using %s (%i× zoom)"),
|
||||
VidSoftFXGetEffect(nUseBlitter), nSize);
|
||||
_sntprintf(szString, MAX_PATH, _T("Prescaling using %s (%i<> zoom)"), VidSoftFXGetEffect(nUseBlitter), nSize);
|
||||
IntInfoAddStringModule(pInfo, szString);
|
||||
|
||||
if (nRotateGame) {
|
||||
if (nRotateGame)
|
||||
{
|
||||
IntInfoAddStringModule(pInfo, _T("Using software rotation"));
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,9 @@
|
||||
extern struct VidOut VidOutMacOS;
|
||||
#elif defined (BUILD_PI)
|
||||
extern struct VidOut VidOutPi;
|
||||
#elif defined (BUILD_SDL2)
|
||||
extern struct VidOut VidOutSDL2;
|
||||
extern struct VidOut VidOutSDL2Opengl;
|
||||
#elif defined (BUILD_SDL)
|
||||
extern struct VidOut VidOutSDLOpenGL;
|
||||
extern struct VidOut VidOutSDLFX;
|
||||
@ -36,6 +39,9 @@ static struct VidOut *pVidOut[] = {
|
||||
&VidOutMacOS,
|
||||
#elif defined (BUILD_PI)
|
||||
&VidOutPi,
|
||||
#elif defined (BUILD_SDL2)
|
||||
&VidOutSDL2,
|
||||
&VidOutSDL2Opengl,
|
||||
#elif defined (BUILD_SDL)
|
||||
&VidOutSDLOpenGL,
|
||||
&VidOutSDLFX,
|
||||
@ -197,9 +203,9 @@ INT32 VidInit()
|
||||
} else {
|
||||
hbitmap = (HBITMAP)LoadImage(hAppInst, MAKEINTRESOURCE(BMP_SPLASH), IMAGE_BITMAP, 304, 224, 0);
|
||||
}
|
||||
|
||||
|
||||
if (!hbitmap) hbitmap = (HBITMAP)LoadImage(hAppInst, MAKEINTRESOURCE(BMP_SPLASH), IMAGE_BITMAP, 304, 224, 0);
|
||||
|
||||
|
||||
GetObject(hbitmap, sizeof(BITMAP), &bitmap);
|
||||
|
||||
nVidImageWidth = bitmap.bmWidth; nVidImageHeight = bitmap.bmHeight;
|
||||
@ -250,7 +256,7 @@ INT32 VidInit()
|
||||
bitmapinfo.bmiHeader.biPlanes = 1;
|
||||
bitmapinfo.bmiHeader.biBitCount = 24;
|
||||
bitmapinfo.bmiHeader.biCompression = BI_RGB;
|
||||
|
||||
|
||||
for (INT32 y = 0; y < nVidImageHeight; y++) {
|
||||
UINT8* pd = pVidImage + y * nVidImagePitch;
|
||||
UINT8* ps = pLineBuffer;
|
||||
@ -362,7 +368,7 @@ static void VidDoFrameCallback()
|
||||
static INT32 VidDoFrame(bool bRedraw)
|
||||
{
|
||||
INT32 nRet;
|
||||
|
||||
|
||||
if (pVidTransImage && pVidTransPalette) {
|
||||
if (bVidRecalcPalette) {
|
||||
for (INT32 r = 0; r < 256; r += 8) {
|
||||
|
@ -79,7 +79,7 @@
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
h4 {
|
||||
color: #C03029;
|
||||
font-size: 1.0em;
|
||||
@ -405,6 +405,7 @@
|
||||
</ul></li>
|
||||
<li>Hook up protection MCU for Wyvern F0 [dink]</li>
|
||||
<li>Add support and options for vertical monitor aspect ratio [tokuio]</li>
|
||||
<li>Added SDL2 build [kev, grant2258]<li>
|
||||
<li> []</li>
|
||||
<li> []</li>
|
||||
<li> []</li>
|
||||
@ -628,14 +629,14 @@
|
||||
<li>Added Lethal Enforcers (ver EAD, 11/11/92 10:52) [caius, JacKc]</li>
|
||||
<li>Added Gals Panic S - Extra Edition (Asia) [Jürgen Probe, JacKc]</li>
|
||||
<li>Added Double Axle (US) [Evan Korzon, Jordan Eldredge, Brian Troha, Smitdogg, The Dumping Union, JacKc]</li>
|
||||
<li>Added X-Men (4 Players ver JEA) [Artemio Urbina, The Dumping Union, JacKc]</li>
|
||||
<li>Added X-Men (4 Players ver JEA) [Artemio Urbina, The Dumping Union, JacKc]</li>
|
||||
<li>Added Double Dragon II - The Revenge (Japan) [Layer, JacKc]</li>
|
||||
<li>Added Jiao! Jiao! Jiao! (China, 2P set) [Bill D., The Dumping Union, JacKc]</li>
|
||||
<li>Added Kamikaze (Euromatic S.A., Spanish bootleg of Scramble) [David Torres, ClawGrip, Recreativas.org, JacKc]</li>
|
||||
<li>Added Kamikaze (Euromatic S.A., Spanish bootleg of Scramble) [David Torres, ClawGrip, Recreativas.org, JacKc]</li>
|
||||
<li>Added Super Cobra (bootleg, set 3) [David Torres, ClawGrip, Recreativas.org, JacKc]</li>
|
||||
<li>Added Guardian Storm (horizontal, Australia) [xodaraP, dink]</li>
|
||||
<li>Added Top Secret (Japan, revision B) [FabC, JacKc]</li>
|
||||
<li>Added Tetris Plus 2 (World, V2.7) [Team Japump!!!, JacKc]</li>
|
||||
<li>Added Top Secret (Japan, revision B) [FabC, JacKc]</li>
|
||||
<li>Added Tetris Plus 2 (World, V2.7) [Team Japump!!!, JacKc]</li>
|
||||
<li>Added Street Fighter: The Movie (v1.14N, Japan) [Jorge Silva, JacKc]</li>
|
||||
<li>Added Eagle Shot Golf (Japan, bootleg?) [Joshua Inman, JacKc]</li>
|
||||
<li>Added Klax (Japan, version 4) [farzeno, The Dumping Union, JacKc]</li>
|
||||
@ -881,7 +882,7 @@
|
||||
<li>Added driver for Crazy Ballon [iq_132, dink]</li>
|
||||
<li>Added driver for Clash Road and Fire Battle [iq_132]</li>
|
||||
<li>Added driver for Flack Attack / MX5000 by Konami [iq_132, dink]</li>
|
||||
<li>Added driver for Master Boy (older/Z80 HW) [iq_132]</li>
|
||||
<li>Added driver for Master Boy (older/Z80 HW) [iq_132]</li>
|
||||
<li>Added driver for Beam Invader *WIP/not working* [iq_132]</li>
|
||||
<li>Added driver for Dribling [iq_132]</li>
|
||||
<li>Added driver for Dora-Chan [iq_132]</li>
|
||||
@ -1576,7 +1577,7 @@
|
||||
<li>Fixed crash in Shadow force in the Laboratory level when the bridge breaks apart [dink, Pityesz]</li>
|
||||
<li>Fixed clicking noise when a replayed input ends [dink]</li>
|
||||
<li>Fixed many Megadrive games: The Chaos Engine, Ooze, Rock 'n Roll Racing, Outrunners, Buck Rogers, Dragon Slayer I & II, Krusty's Super Funhouse, S.S. Lucifer, The Earth Defense, Super Mario Bros. and Battle City, Klax, Feng Shen Ying Jie Chuan (Chi), Tiny Toon Adventures 3, Back to the Future part III (USA), Mickey Mania and possibly others. [dink]</li>
|
||||
<li>Mega Megadrive Overhaul pt.2: [dink]</li>
|
||||
<li>Mega Megadrive Overhaul pt.2: [dink]</li>
|
||||
<li><ul>
|
||||
<li>Added support for mid-frame palette changes (For water effects in Sonic, Rocket Knight Adventures, Burning Force scrolls now..etc.)</li>
|
||||
<li>Fixed audio glitches in Doom Troopers and Battle Squadron</li>
|
||||
@ -3104,7 +3105,7 @@
|
||||
<li>Fixed "most recent games" list when using Neo Geo multi-slot [Barry]</li>
|
||||
<li>Added a module to identify Neo Geo CD games [CaptainCPS]</li>
|
||||
</ul></li>
|
||||
<li>Ported H6280 CPU Core from MAME [iq_132]</li>
|
||||
<li>Ported H6280 CPU Core from MAME [iq_132]</li>
|
||||
<li>Added module to support vector games [iq_132]</li>
|
||||
<li>Added driver for Aztarac [iq_132]</li>
|
||||
<li>Hooked up analog joystick and dial in Aztarac driver [Barry]</li>
|
||||
|
Loading…
Reference in New Issue
Block a user