A few SDL cleanups and a makefile
This commit is contained in:
parent
0143471949
commit
3fb1543ce1
|
@ -0,0 +1,556 @@
|
|||
# Makefile for FBASDL, for use with GNU make & GCC
|
||||
#
|
||||
# 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
|
||||
|
||||
#
|
||||
# Flags. Uncomment any of these declarations to enable their function.
|
||||
#
|
||||
|
||||
# Check for changes in header files
|
||||
DEPEND = 1
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Declare variables
|
||||
#
|
||||
|
||||
# Specify the name of the executable file, without ".exe"
|
||||
NAME = fbasdl
|
||||
|
||||
ifdef BUILD_X64_EXE
|
||||
ifdef BUILD_A68K
|
||||
undefine BUILD_A68K
|
||||
endif
|
||||
ifdef BUILD_X86_ASM
|
||||
undefine BUILD_X86_ASM
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef CPUTYPE
|
||||
CPUTYPE = i686
|
||||
endif
|
||||
|
||||
MMX = 0
|
||||
|
||||
ifndef BUILD_X86_ASM
|
||||
NAME := $(NAME)n
|
||||
endif
|
||||
ifdef BUILD_X64_EXE
|
||||
NAME = $(NAME)64
|
||||
endif
|
||||
ifdef DEBUG
|
||||
NAME := $(NAME)d
|
||||
endif
|
||||
ifdef SYMBOL
|
||||
NAME := $(NAME)s
|
||||
endif
|
||||
ifndef UNICODE
|
||||
NAME := $(NAME)a
|
||||
endif
|
||||
|
||||
ifeq ($(CPUTYPE),i686)
|
||||
ppro = ppro
|
||||
else
|
||||
NAME := $(NAME)$(CPUTYPE)
|
||||
endif
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Specify paths/files
|
||||
#
|
||||
|
||||
objdir = obj/SDL/$(NAME)/
|
||||
|
||||
|
||||
srcdir = src/
|
||||
|
||||
include makefile.rules
|
||||
|
||||
incdir = $(foreach dir,$(alldir),-I$(srcdir)$(dir)) -I$(objdir)depend/generated
|
||||
|
||||
lib += `sdl-config --libs`
|
||||
|
||||
depobj += resource.o \
|
||||
|
||||
autdep = $(depobj:.o=.d)
|
||||
|
||||
ifdef BUILD_A68K
|
||||
a68k.o = $(objdir)cpu/a68k/a68k.o
|
||||
endif
|
||||
|
||||
|
||||
license.rtf = $(srcdir)depend/generated/license.rtf
|
||||
driverlist.h = $(srcdir)depend/generated/driverlist.h
|
||||
ctv.h = $(srcdir)depend/generated/ctv.h
|
||||
toa_gp9001_func.h = $(srcdir)depend/generated/toa_gp9001_func.h
|
||||
neo_sprite_func.h = $(srcdir)depend/generated/neo_sprite_func.h
|
||||
cave_tile_func.h = $(srcdir)depend/generated/cave_tile_func.h
|
||||
cave_sprite_func.h = $(srcdir)depend/generated/cave_sprite_func.h
|
||||
psikyo_tile_func.h = $(srcdir)depend/generated/psikyo_tile_func.h
|
||||
pgm_sprite.h = $(srcdir)depend/generated/pgm_sprite.h
|
||||
build_details.h = $(srcdir)depend/generated/build_details.h
|
||||
|
||||
allobj = $(objdir)cpu/m68k/m68kcpu.o $(objdir)cpu/m68k/m68kopnz.o $(objdir)cpu/m68k/m68kopdm.o $(objdir)cpu/m68k/m68kopac.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))))))) \
|
||||
|
||||
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))))))) \
|
||||
|
||||
#
|
||||
#
|
||||
# Specify compiler/linker/assembler
|
||||
#
|
||||
#
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
LD = $(CXX)
|
||||
AS = nasm
|
||||
|
||||
LDFLAGS = -static
|
||||
|
||||
|
||||
CFLAGS = -pipe \
|
||||
-std=gnu99 -march=$(CPUTYPE) -O1 \
|
||||
-fforce-mem -fforce-addr -finline-limit=1200 -fthread-jumps \
|
||||
-freduce-all-givs -fmove-all-movables -fexpensive-optimizations \
|
||||
-Wall -Wno-long-long -Wno-sign-compare -Wno-uninitialized -Wno-unused \
|
||||
$(DEF) $(incdir) `sdl-config --cflags`
|
||||
|
||||
CXXFLAGS = -pipe \
|
||||
-march=$(CPUTYPE) -O1 \
|
||||
-fforce-mem -fforce-addr -finline-limit=1200 -fthread-jumps \
|
||||
-freduce-all-givs -fmove-all-movables -fexpensive-optimizations \
|
||||
-fcheck-new \
|
||||
-Wall -W -pedantic -Wno-long-long \
|
||||
-Wunknown-pragmas -Wundef -Wconversion -Wno-missing-braces \
|
||||
-Wuninitialized -Wpointer-arith -Winline -Wno-multichar \
|
||||
$(DEF) $(incdir) `sdl-config --cflags`
|
||||
endif
|
||||
|
||||
ifdef BUILD_X64_EXE
|
||||
CFLAGS += -m64
|
||||
CXXFLAGS += -m64
|
||||
LDFLAGS += -m64
|
||||
else
|
||||
CFLAGS += -m32
|
||||
CXXFLAGS += -m32
|
||||
LDFLAGS += -m32
|
||||
endif
|
||||
endif
|
||||
|
||||
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
|
||||
|
||||
DEF := -DUSE_SPEEDHACKS -DFILENAME=$(NAME) -DMMX=0
|
||||
|
||||
ifdef UNICODE
|
||||
DEF := $(DEF) -D_UNICODE
|
||||
endif
|
||||
|
||||
ifdef SPECIALBUILD
|
||||
DEF := $(DEF) -DSPECIALBUILD=$(SPECIALBUILD)
|
||||
endif
|
||||
|
||||
ifdef FASTCALL
|
||||
DEF := $(DEF) -DFASTCALL
|
||||
endif
|
||||
|
||||
ifdef DEBUG
|
||||
DEF := $(DEF) -DFBA_DEBUG
|
||||
endif
|
||||
|
||||
ifdef ROM_VERIFY
|
||||
DEF := $(DEF) -DROM_VERIFY
|
||||
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
|
||||
endif
|
||||
|
||||
ifdef SYMBOL
|
||||
|
||||
CFLAGS += -ggdb3
|
||||
ASFLAGS += -g
|
||||
DEF := $(DEF) -D_DEBUG
|
||||
|
||||
ifdef PROFILE
|
||||
CFLAGS += -pg
|
||||
CXXFLAGS += -pg
|
||||
else
|
||||
CFLAGS += -fomit-frame-pointer
|
||||
CXXFLAGS += -fomit-frame-pointer
|
||||
endif
|
||||
|
||||
else
|
||||
LDFLAGS += -s
|
||||
endif
|
||||
|
||||
|
||||
# For zlib
|
||||
DEF := $(DEF) -DNO_VIZ -D_LARGEFILE64_SOURCE=0 -D_FILE_OFFSET_BITS=32
|
||||
|
||||
#
|
||||
#
|
||||
# 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 %.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 $(autdep) $(autobj)
|
||||
@$(MAKE) -f makefile.sdl
|
||||
|
||||
else
|
||||
|
||||
all: init $(autobj)
|
||||
@$(MAKE) -f makefile.sdl
|
||||
|
||||
endif
|
||||
else
|
||||
|
||||
all: $(NAME).exe
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
#
|
||||
# Rule for linking the executable
|
||||
#
|
||||
#
|
||||
|
||||
ifeq ($(MAKELEVEL),2)
|
||||
|
||||
$(NAME).exe: $(allobj)
|
||||
@echo
|
||||
@echo Linking executable... $(NAME).exe
|
||||
@$(LD) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(lib)
|
||||
|
||||
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): $(drvobj) $(srcdir)depend/scripts/gamelist.pl
|
||||
ifdef PERL
|
||||
@$(srcdir)depend/scripts/gamelist.pl -o $@ -l gamelist.txt \
|
||||
$(filter %.cpp,$(foreach file,$(drvobj:.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
|
||||
|
||||
|
||||
#
|
||||
# Generate some info on the build details
|
||||
#
|
||||
|
||||
about.o about.d: $(build_details.h)
|
||||
|
||||
$(build_details.h): $(srcdir)depend/scripts/build_details.cpp
|
||||
@$(CXX) -mconsole $(CXXFLAGS) $(LDFLAGS) $< -o $(objdir)depend/generated/build_details.exe
|
||||
@$(objdir)depend/generated/build_details.exe >$@
|
||||
|
||||
#
|
||||
# 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)depend/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.exe $(objdir)depend/generated/m68kops.h $(objdir)depend/generated/m68kops.c $(srcdir)cpu/m68k/m68k.h $(srcdir)cpu/m68k/m68kconf.h
|
||||
@echo Compiling Musashi MC680x0 core \(m68kops.c\)...
|
||||
@$(CC) $(CFLAGS) -c $(objdir)depend/generated/m68kops.c -o $(objdir)cpu/m68k/m68kops.o
|
||||
|
||||
$(objdir)cpu/m68k/m68kopac.o: $(objdir)cpu/m68k/m68kmake.exe $(objdir)depend/generated/m68kops.h $(objdir)depend/generated/m68kopac.c $(srcdir)cpu/m68k/m68k.h $(srcdir)cpu/m68k/m68kconf.h
|
||||
@echo Compiling Musashi MC680x0 core \(m68kopac.c\)...
|
||||
@$(CC) $(CFLAGS) -c $(objdir)depend/generated/m68kopac.c -o $(objdir)cpu/m68k/m68kopac.o
|
||||
|
||||
$(objdir)cpu/m68k/m68kopdm.o: $(objdir)cpu/m68k/m68kmake.exe $(objdir)depend/generated/m68kops.h $(objdir)depend/generated/m68kopdm.c $(srcdir)cpu/m68k/m68k.h $(srcdir)cpu/m68k/m68kconf.h
|
||||
@echo Compiling Musashi MC680x0 core \(m68kopdm.c\)...
|
||||
@$(CC) $(CFLAGS) -c $(objdir)depend/generated/m68kopdm.c -o $(objdir)cpu/m68k/m68kopdm.o
|
||||
|
||||
$(objdir)cpu/m68k/m68kopnz.o: $(objdir)cpu/m68k/m68kmake.exe $(objdir)depend/generated/m68kops.h $(objdir)depend/generated/m68kopnz.c $(srcdir)cpu/m68k/m68k.h $(srcdir)cpu/m68k/m68kconf.h
|
||||
@echo Compiling Musashi MC680x0 core \(m68kopnz.c\)...
|
||||
@$(CC) $(CFLAGS) -c $(objdir)depend/generated/m68kopnz.c -o $(objdir)cpu/m68k/m68kopnz.o
|
||||
|
||||
$(objdir)depend/generated/m68kops.h: $(objdir)cpu/m68k/m68kmake.exe $(srcdir)cpu/m68k/m68k_in.c
|
||||
$(objdir)/cpu/m68k/m68kmake $(objdir)depend/generated/ $(srcdir)cpu/m68k/m68k_in.c
|
||||
|
||||
$(objdir)cpu/m68k/m68kmake.exe: $(srcdir)cpu/m68k/m68kmake.c
|
||||
@echo Compiling Musashi MC680x0 core \(m68kmake.c\)...
|
||||
@$(CC) $(CFLAGS) $(srcdir)cpu/m68k/m68kmake.c -o $(objdir)cpu/m68k/m68kmake.exe
|
||||
|
||||
|
||||
#
|
||||
# Extra rules for generated header file cvt.h, needed by ctv.cpp
|
||||
#
|
||||
|
||||
ctv.d ctv.o: $(ctv.h)
|
||||
|
||||
$(ctv.h): ctv_make.cpp
|
||||
@echo Generating $(srcdir)depend/generated/$(@F)...
|
||||
@$(CC) -mconsole $(CXXFLAGS) $(LDFLAGS) $< \
|
||||
-o $(subst $(srcdir),$(objdir),$(<D))/$(<F:.cpp=.exe)
|
||||
@$(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)depend/scripts/toa_gp9001_func.pl
|
||||
@$(srcdir)depend/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)depend/scripts/neo_sprite_func.pl
|
||||
@$(srcdir)depend/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)depend/scripts/cave_tile_func.pl
|
||||
@$(srcdir)depend/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)depend/scripts/cave_sprite_func.pl
|
||||
@$(srcdir)depend/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)depend/scripts/psikyo_tile_func.pl
|
||||
$(srcdir)depend/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)depend/generated/$(@F)...
|
||||
@$(CC) -mconsole $(CXXFLAGS) $(LDFLAGS) $< \
|
||||
-o $(subst $(srcdir),$(objdir),$(<D))/$(<F:.cpp=.exe)
|
||||
@$(subst $(srcdir),$(objdir),$(<D))/$(<F:.cpp=.exe) >$@
|
||||
|
||||
|
||||
ifeq ($(MAKELEVEL),2)
|
||||
ifdef DEPEND
|
||||
|
||||
include $(alldep)
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# Generic rules for C/C++ files
|
||||
#
|
||||
|
||||
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
|
||||
@echo Assembling $<...
|
||||
@$(AS) $(ASFLAGS) $< -o $(subst $(srcdir),$(objdir),$(<D))/$(@F)
|
||||
|
||||
else
|
||||
|
||||
%.o: %.c
|
||||
@echo Compiling $<...
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.asm
|
||||
@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)depend/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)/depend/generated/*
|
||||
-@for dir in $(alldir); do touch -c -r $(NAME).exe $(objdir)$$dir/*; done
|
||||
|
||||
clean:
|
||||
@echo Removing all files from $(objdir)...
|
||||
-@rm -f -r $(objdir)
|
||||
-@rm -f -r $(ctv.h)
|
||||
|
||||
ifdef PERL
|
||||
@echo Removing all files generated with perl scripts...
|
||||
-@rm -f -r $(driverlist)
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# Rule to force recompilation of any target that depends on it
|
||||
#
|
||||
|
||||
FORCE:
|
|
@ -15,31 +15,7 @@ static int DoLibInit() // Do Init of Burn library driver
|
|||
|
||||
// If there is an error with the romset, report it
|
||||
if (nBzipError) {
|
||||
/* char *szTitle;
|
||||
int nIcon, nButton;
|
||||
|
||||
// Make the correct title and icon
|
||||
if (nBzipError & 1) {
|
||||
nIcon = MB_ICONERROR;
|
||||
szTitle = APP_TITLE " Error";
|
||||
} else {
|
||||
nIcon = MB_ICONWARNING;
|
||||
szTitle = APP_TITLE " Warning";
|
||||
}
|
||||
|
||||
if (nBzipError & 0x08) {
|
||||
nButton = MB_OK; // no data at all - pretty basic!
|
||||
} else {
|
||||
BzipText.Add("\nWould you like more detailed information?\n(For experts only!)\n");
|
||||
nButton = MB_DEFBUTTON2 | MB_YESNO;
|
||||
}
|
||||
|
||||
// We can't use AppError, so use MessageBox directly
|
||||
if (MessageBox(hScrnWnd, BzipText.szText, szTitle, nButton | nIcon | MB_SETFOREGROUND) == IDYES) {
|
||||
// Give the more detailed information string
|
||||
MessageBox(hScrnWnd, BzipDetail.szText, szTitle, MB_OK | nIcon | MB_SETFOREGROUND);
|
||||
}
|
||||
*/ }
|
||||
}
|
||||
|
||||
//ProgressCreate();
|
||||
|
||||
|
@ -47,8 +23,6 @@ static int DoLibInit() // Do Init of Burn library driver
|
|||
|
||||
BzipClose();
|
||||
|
||||
// ProgressDestroy();
|
||||
|
||||
if (nRet) {
|
||||
return 1;
|
||||
} else {
|
||||
|
@ -131,17 +105,11 @@ int DrvInitCallback()
|
|||
int DrvExit()
|
||||
{
|
||||
if (bDrvOkay) {
|
||||
|
||||
// StopReplay();
|
||||
|
||||
VidExit();
|
||||
|
||||
if (nBurnDrvSelect < nBurnDrvCount) {
|
||||
|
||||
//MemCardEject(); // Eject memory card if present
|
||||
|
||||
if (bSaveRAM) {
|
||||
//StatedAuto(1); // Save NV (or full) RAM
|
||||
|
||||
bSaveRAM = false;
|
||||
}
|
||||
|
||||
|
@ -156,8 +124,6 @@ int DrvExit()
|
|||
|
||||
bDrvOkay = 0; // Stop using the BurnDrv functions
|
||||
|
||||
//bRunPause = 0; // Don't pause when exitted
|
||||
|
||||
if (bAudOkay) {
|
||||
// // Write silence into the sound buffer on exit, and for drivers which don't use pBurnSoundOut
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2);
|
||||
|
|
|
@ -3,11 +3,10 @@ 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 burner directory has a few common files with the windows version, so they should be updated at some point.
|
||||
|
||||
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
|
||||
I need to merge in the stuff from the only non intel version of fba so we have a C z80 core
|
||||
probably many other things.
|
||||
------------------*/
|
||||
#include "burner.h"
|
||||
|
@ -19,13 +18,10 @@ bool bAlwaysProcessKeyboardInput=0;
|
|||
|
||||
void init_emu(int gamenum)
|
||||
{
|
||||
// by default use C 68000, and soon C Z80
|
||||
bBurnUseASMCPUEmulation=0;
|
||||
bCheatsAllowed=false;
|
||||
ConfigAppLoad();
|
||||
ConfigAppSave();
|
||||
//CreateDirectory(".:\\cfg", NULL);
|
||||
//CreateDirectory(".:\\state", NULL);
|
||||
DrvInit(gamenum,0);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Run module
|
||||
#include "burner.h"
|
||||
//#include "app.h"
|
||||
//#include "kailleraclient.h"
|
||||
|
||||
|
||||
bool bAltPause = 0;
|
||||
|
||||
|
@ -9,8 +8,6 @@ int bAlwaysDrawFrames = 0;
|
|||
|
||||
static bool bShowFPS = false;
|
||||
|
||||
//int kNetGame = 0; // Non-zero if Kaillera is being used
|
||||
|
||||
int counter; // General purpose variable used when debugging
|
||||
|
||||
static unsigned int nNormalLast = 0; // Last value of timeGetTime()
|
||||
|
@ -91,26 +88,9 @@ static int RunFrame(int bDraw, int bPause)
|
|||
{
|
||||
nFramesEmulated++;
|
||||
nCurrentFrame++;
|
||||
|
||||
/* {
|
||||
if (nReplayStatus == 2) {
|
||||
GetInput(false); // Update burner inputs, but not game inputs
|
||||
if (ReplayInput()) { // Read input from file
|
||||
bAltPause = 1;
|
||||
bRunPause = 1;
|
||||
MenuEnableItems();
|
||||
InputSetCooperativeLevel(false, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
*/ {
|
||||
GetInput(true); // Update inputs
|
||||
}
|
||||
GetInput(true); // Update inputs
|
||||
}
|
||||
/* if (nReplayStatus == 1) {
|
||||
RecordInput(); // Write input to file
|
||||
}
|
||||
*/ if (bDraw) {
|
||||
if (bDraw) {
|
||||
nFramesRendered++;
|
||||
if (VidFrame()) { // Do one frame
|
||||
AudBlankSound();
|
||||
|
@ -120,14 +100,6 @@ static int RunFrame(int bDraw, int bPause)
|
|||
pBurnDraw = NULL; // Make sure no image is drawn
|
||||
BurnDrvFrame();
|
||||
}
|
||||
/*
|
||||
if (bShowFPS) {
|
||||
if (nDoFPS < nFramesRendered) {
|
||||
DisplayFPS();
|
||||
nDoFPS = nFramesRendered + 30;
|
||||
}
|
||||
}
|
||||
*/
|
||||
bPrevPause = bPause;
|
||||
bPrevDraw = bDraw;
|
||||
|
||||
|
@ -163,12 +135,6 @@ static int RunGetNextSound(int bDraw)
|
|||
// Render frame with sound
|
||||
pBurnSoundOut = nAudNextSound;
|
||||
RunFrame(bDraw, 0);
|
||||
/*
|
||||
if (WaveLog != NULL && pBurnSoundOut != NULL) { // log to the file
|
||||
fwrite(pBurnSoundOut, 1, nBurnSoundLen << 2, WaveLog);
|
||||
pBurnSoundOut = NULL;
|
||||
}
|
||||
*/
|
||||
if (bAppDoStep) {
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2); // Write silence into the buffer
|
||||
}
|
||||
|
@ -272,35 +238,13 @@ int RunMessageLoop()
|
|||
if (!bVidOkay && nVidFullscreen) {
|
||||
|
||||
nVidFullscreen = 0;
|
||||
|
||||
// MediaExit(bRestartVideo);
|
||||
// MediaInit();
|
||||
VidInit();
|
||||
}
|
||||
if (!nVidFullscreen) {
|
||||
//ScrnSize();
|
||||
}
|
||||
|
||||
/* if (!bVidOkay && (bDrvOkay || bVidUsePlaceholder)) {
|
||||
// Maske sure the error will be visible
|
||||
SplashDestroy(1);
|
||||
|
||||
AppError("VidInit Failed", 0);
|
||||
}
|
||||
*/
|
||||
/* if (bVidOkay && (bRunPause || !bDrvOkay)) {
|
||||
VidRedraw();
|
||||
}
|
||||
*/ }
|
||||
}
|
||||
|
||||
RunInit();
|
||||
|
||||
// ShowWindow(hScrnWnd, nAppShowCmd); // Show the screen window
|
||||
// nAppShowCmd = SW_NORMAL;
|
||||
|
||||
// SetForegroundWindow(hScrnWnd);
|
||||
|
||||
//GameInpCheckLeftAlt();
|
||||
GameInpCheckMouse(); // Hide the cursor
|
||||
while (!finished) {
|
||||
SDL_Event event;
|
||||
|
@ -313,8 +257,6 @@ int RunMessageLoop()
|
|||
}
|
||||
else
|
||||
{
|
||||
// No messages are waiting
|
||||
//SplashDestroy(0);
|
||||
RunIdle();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,261 +1,231 @@
|
|||
// SDL_Sound module
|
||||
|
||||
#ifdef BUILD_SDL
|
||||
|
||||
//#include "burner.h"
|
||||
#include "SDL.h"
|
||||
#include "burner.h"
|
||||
#include "aud_dsp.h"
|
||||
#include <math.h>
|
||||
|
||||
class AudioSDL : public Audio {
|
||||
public:
|
||||
SDL_AudioSpec SDLAudioSpec;
|
||||
static unsigned int nSoundFps;
|
||||
|
||||
short* SDLAudBuffer;
|
||||
int nSDLPlayPos;
|
||||
int nSDLFillSeg;
|
||||
int (*GetNextSound)(int); // Callback used to request more sound
|
||||
|
||||
int (*SDLGetNextSound)(int);
|
||||
static SDL_AudioSpec audiospec;
|
||||
|
||||
int set(int (*callback)(int))
|
||||
{
|
||||
if (callback == NULL) {
|
||||
SDLGetNextSound = AudWriteSlience;
|
||||
} else {
|
||||
SDLGetNextSound = callback;
|
||||
dprintf(_T("SDL callback set\n"));
|
||||
static short* SDLAudBuffer;
|
||||
static int nSDLPlayPos;
|
||||
static int nSDLFillSeg;
|
||||
static int nAudLoopLen;
|
||||
|
||||
void audiospec_callback(void* /* data */, Uint8* stream, int len)
|
||||
{
|
||||
// dprintf(_T("audiospec_callback %i"), len);
|
||||
|
||||
int end = nSDLPlayPos + len;
|
||||
if (end > nAudLoopLen) {
|
||||
|
||||
// dprintf(_T(" %i - %i"), nSDLPlayPos, nSDLPlayPos + nAudLoopLen - nSDLPlayPos);
|
||||
|
||||
SDL_MixAudio(stream, (Uint8*)SDLAudBuffer + nSDLPlayPos, nAudLoopLen - nSDLPlayPos, SDL_MIX_MAXVOLUME);
|
||||
end -= nAudLoopLen;
|
||||
|
||||
// dprintf(_T(", %i - %i (%i)"), 0, end, nAudLoopLen - nSDLPlayPos + end);
|
||||
|
||||
SDL_MixAudio(stream + nAudLoopLen - nSDLPlayPos, (Uint8*)SDLAudBuffer, end, SDL_MIX_MAXVOLUME);
|
||||
nSDLPlayPos = end;
|
||||
} else {
|
||||
SDL_MixAudio(stream, (Uint8*)SDLAudBuffer + nSDLPlayPos, len, SDL_MIX_MAXVOLUME);
|
||||
nSDLPlayPos = end;
|
||||
|
||||
if (nSDLPlayPos == nAudLoopLen) {
|
||||
nSDLPlayPos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// dprintf(_T("\n"));
|
||||
}
|
||||
|
||||
static int SDLSoundGetNextSoundFiller(int) // int bDraw
|
||||
{
|
||||
if (nAudNextSound == NULL) {
|
||||
return 1;
|
||||
}
|
||||
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"));
|
||||
memset(nAudNextSound, 0, nAudSegLen << 2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define WRAP_INC(x) { x++; if (x >= nAudSegCount) x = 0; }
|
||||
|
||||
static int SDLSoundCheck()
|
||||
{
|
||||
int nPlaySeg, nFollowingSeg;
|
||||
|
||||
if (!bAudPlaying) {
|
||||
dprintf(_T("SDLSoundCheck (not playing)\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int blank()
|
||||
{
|
||||
dprintf (_T("SDLBlankSound\n"));
|
||||
// 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;
|
||||
|
||||
if (SDLAudBuffer) {
|
||||
memset(SDLAudBuffer, 0, loopLen);
|
||||
}
|
||||
// dprintf(_T("SDLSoundCheck (seg %i)\n"), nPlaySeg);
|
||||
|
||||
if (pAudNextSound) {
|
||||
dprintf (_T("blanking pAudNextSound\n"));
|
||||
AudWriteSlience();
|
||||
}
|
||||
if (nPlaySeg >= nAudSegCount) {
|
||||
nPlaySeg -= nAudSegCount;
|
||||
}
|
||||
if (nPlaySeg < 0) {
|
||||
nPlaySeg = nAudSegCount - 1;
|
||||
}
|
||||
|
||||
if (nSDLFillSeg == nPlaySeg) {
|
||||
SDL_Delay(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int check()
|
||||
{
|
||||
#define WRAP_INC(x) { x++; if (x >= nAudSegCount) x = 0; }
|
||||
// work out which seg we will fill next
|
||||
nFollowingSeg = nSDLFillSeg;
|
||||
WRAP_INC(nFollowingSeg);
|
||||
|
||||
// Since the SDL buffer is smaller than a segment,
|
||||
// only fill the buffer up to the start of the currently playing segment
|
||||
int nPlaySeg = nSDLPlayPos / nAudAllocSegLen - 1;
|
||||
while (nSDLFillSeg != nPlaySeg) {
|
||||
int bDraw;
|
||||
|
||||
if (nPlaySeg >= nAudSegCount) {
|
||||
nPlaySeg -= nAudSegCount;
|
||||
}
|
||||
if (nPlaySeg < 0) {
|
||||
nPlaySeg = nAudSegCount - 1;
|
||||
}
|
||||
// fill nSDLFillSeg
|
||||
// dprintf(_T("Filling seg %i at %i\n"), nSDLFillSeg, nSDLFillSeg * (nAudSegLen << 2));
|
||||
|
||||
// dprintf(_T("SDLSoundCheck (seg %i)\n"), nPlaySeg);
|
||||
bDraw = (nFollowingSeg == nPlaySeg);// || bAlwaysDrawFrames; // If this is the last seg of sound, flag bDraw (to draw the graphics)
|
||||
|
||||
if (nSDLFillSeg == nPlaySeg) {
|
||||
SDL_Delay(1);
|
||||
return 0;
|
||||
}
|
||||
// nAudNextSound = SDLAudBuffer + nSDLFillSeg * (nAudSegLen << 1);
|
||||
GetNextSound(bDraw); // get more sound into nAudNextSound
|
||||
|
||||
// work out which seg we will fill next
|
||||
int nFollowingSeg = nSDLFillSeg;
|
||||
// if (nAudDSPModule) {
|
||||
// DspDo(nAudNextSound, nAudSegLen);
|
||||
// }
|
||||
|
||||
memcpy((char*)SDLAudBuffer + nSDLFillSeg * (nAudSegLen << 2), nAudNextSound, nAudSegLen << 2);
|
||||
|
||||
nSDLFillSeg = nFollowingSeg;
|
||||
WRAP_INC(nFollowingSeg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (nSDLFillSeg != nPlaySeg) {
|
||||
// fill nSDLFillSeg
|
||||
// dprintf(_T("Filling seg %i at %i\n"), nSDLFillSeg, nSDLFillSeg * (nAudAllocSegLen));
|
||||
static int SDLSoundExit()
|
||||
{
|
||||
dprintf(_T("SDLSoundExit\n"));
|
||||
|
||||
memcpy((char*)SDLAudBuffer + nSDLFillSeg * nAudAllocSegLen, pAudNextSound, nAudAllocSegLen);
|
||||
SDL_CloseAudio();
|
||||
|
||||
// If this is the last seg of sound, flag bDraw (to draw the graphics)
|
||||
int bDraw = (nFollowingSeg == nPlaySeg);// || !autoFrameSkip;
|
||||
free(SDLAudBuffer);
|
||||
SDLAudBuffer = NULL;
|
||||
|
||||
// pAudNextSound = SDLAudBuffer + nSDLFillSeg * (nAudSegLen << 1);
|
||||
SDLGetNextSound(bDraw); // get more sound into pAudNextSound
|
||||
free(nAudNextSound);
|
||||
nAudNextSound = NULL;
|
||||
|
||||
if (nAudDSPModule & 1) {
|
||||
if (bRunPause)
|
||||
AudWriteSlience();
|
||||
else
|
||||
DspDo(pAudNextSound, nAudSegLen);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
nSDLFillSeg = nFollowingSeg;
|
||||
WRAP_INC(nFollowingSeg);
|
||||
}
|
||||
static int SDLSetCallback(int (*pCallback)(int))
|
||||
{
|
||||
if (pCallback == NULL) {
|
||||
GetNextSound = SDLSoundGetNextSoundFiller;
|
||||
} else {
|
||||
GetNextSound = pCallback;
|
||||
dprintf(_T("SDL callback set\n"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
static int SDLSoundInit()
|
||||
{
|
||||
SDL_AudioSpec audiospec_req;
|
||||
int nSDLBufferSize;
|
||||
|
||||
dprintf(_T("SDLSoundInit (%dHz)"), nAudSampleRate);
|
||||
|
||||
if (nAudSampleRate <= 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int exit()
|
||||
{
|
||||
dprintf(_T("SDLSoundExit\n"));
|
||||
nSoundFps = nAppVirtualFps;
|
||||
nAudSegLen = (nAudSampleRate * 100 + (nSoundFps >> 1)) / nSoundFps;
|
||||
nAudLoopLen = (nAudSegLen * nAudSegCount) << 2;
|
||||
for (nSDLBufferSize = 64; nSDLBufferSize < (nAudSegLen >> 1); nSDLBufferSize <<= 1) { }
|
||||
|
||||
DspExit();
|
||||
audiospec_req.freq = nAudSampleRate;
|
||||
audiospec_req.format = AUDIO_S16;
|
||||
audiospec_req.channels = 2;
|
||||
audiospec_req.samples = nSDLBufferSize;
|
||||
audiospec_req.callback = audiospec_callback;
|
||||
|
||||
SDL_CloseAudio();
|
||||
SDLAudBuffer = (short*)malloc(nAudLoopLen);
|
||||
if (SDLAudBuffer == NULL) {
|
||||
dprintf(_T("Couldn't malloc SDLAudBuffer\n"));
|
||||
SDLSoundExit();
|
||||
return 1;
|
||||
}
|
||||
memset(SDLAudBuffer, 0, nAudLoopLen);
|
||||
|
||||
free(SDLAudBuffer);
|
||||
SDLAudBuffer = NULL;
|
||||
|
||||
free(pAudNextSound);
|
||||
pAudNextSound = NULL;
|
||||
|
||||
return 0;
|
||||
nAudNextSound = (short*)malloc(nAudSegLen << 2);
|
||||
if (nAudNextSound == NULL) {
|
||||
SDLSoundExit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void audiospec_callback(void* /* data */, Uint8* stream, int len)
|
||||
{
|
||||
// dprintf(_T("audiospec_callback %i"), len);
|
||||
nAudNextSound = SDLAudBuffer;
|
||||
nSDLPlayPos = 0;
|
||||
nSDLFillSeg = nAudSegCount - 1;
|
||||
|
||||
int end = nSDLPlayPos + len;
|
||||
if (end > loopLen) {
|
||||
// dprintf(_T(" %i - %i"), nSDLPlayPos, nSDLPlayPos + loopLen - nSDLPlayPos);
|
||||
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;
|
||||
}
|
||||
|
||||
SDL_MixAudio(stream, (Uint8*)SDLAudBuffer + nSDLPlayPos, loopLen - nSDLPlayPos, volume);
|
||||
end -= loopLen;
|
||||
SDLSetCallback(NULL);
|
||||
|
||||
// dprintf(_T(", %i - %i (%i)"), 0, end, loopLen - nSDLPlayPos + end);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_MixAudio(stream + loopLen - nSDLPlayPos, (Uint8*)SDLAudBuffer, end, volume);
|
||||
nSDLPlayPos = end;
|
||||
} else {
|
||||
SDL_MixAudio(stream, (Uint8*)SDLAudBuffer + nSDLPlayPos, len, volume);
|
||||
nSDLPlayPos = end;
|
||||
static int SDLSoundPlay()
|
||||
{
|
||||
dprintf(_T("SDLSoundPlay\n"));
|
||||
|
||||
if (nSDLPlayPos == loopLen) {
|
||||
nSDLPlayPos = 0;
|
||||
}
|
||||
}
|
||||
SDL_PauseAudio(0);
|
||||
bAudPlaying = 1;
|
||||
|
||||
// dprintf(_T("\n"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int init()
|
||||
{
|
||||
dprintf(_T("SDLSoundInit (%dHz)"), nAudSampleRate);
|
||||
static int SDLSoundStop()
|
||||
{
|
||||
dprintf(_T("SDLSoundStop\n"));
|
||||
|
||||
if (nAudSampleRate <= 0) {
|
||||
return 1;
|
||||
}
|
||||
SDL_PauseAudio(1);
|
||||
bAudPlaying = 0;
|
||||
|
||||
fps = nAppVirtualFps;
|
||||
nAudSegLen = (nAudSampleRate * 100 + (fps >> 1)) / fps;
|
||||
nAudAllocSegLen = nAudSegLen << 2;
|
||||
loopLen = (nAudSegLen * nAudSegCount) << 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nSDLBufferSize;
|
||||
for (nSDLBufferSize = 64; nSDLBufferSize < (nAudSegLen >> 1); nSDLBufferSize <<= 1) { }
|
||||
static int SDLSoundSetVolume()
|
||||
{
|
||||
dprintf(_T("SDLSoundSetVolume\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_AudioSpec audiospec_req;
|
||||
audiospec_req.freq = nAudSampleRate;
|
||||
audiospec_req.format = AUDIO_S16;
|
||||
audiospec_req.channels = 2;
|
||||
audiospec_req.samples = nSDLBufferSize;
|
||||
audiospec_req.callback = audiospec_callback;
|
||||
static int SDLGetSettings(InterfaceInfo* /* pInfo */)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDLAudBuffer = (short*)malloc(loopLen);
|
||||
if (SDLAudBuffer == NULL) {
|
||||
dprintf(_T("Couldn't malloc SDLAudBuffer\n"));
|
||||
exit();
|
||||
return 1;
|
||||
}
|
||||
memset(SDLAudBuffer, 0, loopLen);
|
||||
|
||||
pAudNextSound = (short*)malloc(nAudAllocSegLen);
|
||||
if (pAudNextSound == NULL) {
|
||||
exit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
nSDLPlayPos = 0;
|
||||
nSDLFillSeg = nAudSegCount - 1;
|
||||
|
||||
if (SDL_OpenAudio(&audiospec_req, &SDLAudioSpec)) {
|
||||
fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
|
||||
dprintf(_T("Couldn't open audio: %s\n"), SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
set(NULL);
|
||||
|
||||
DspInit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int play()
|
||||
{
|
||||
dprintf(_T("SDLSoundPlay\n"));
|
||||
|
||||
SDL_PauseAudio(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stop()
|
||||
{
|
||||
dprintf(_T("SDLSoundStop\n"));
|
||||
|
||||
SDL_PauseAudio(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setvolume(int vol)
|
||||
{
|
||||
dprintf(_T("SDLSoundSetVolume\n"));
|
||||
|
||||
if (vol == 10000) {
|
||||
volume = SDL_MIX_MAXVOLUME;
|
||||
} else {
|
||||
if (vol == 0) {
|
||||
volume = 0;
|
||||
} else {
|
||||
volume = SDL_MIX_MAXVOLUME * vol / 10000;
|
||||
}
|
||||
}
|
||||
|
||||
if (volume < 0) {
|
||||
volume = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get(void* info)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setfps()
|
||||
{
|
||||
if (nAudSampleRate <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AudioSDL() {
|
||||
SDLAudBuffer = NULL;
|
||||
nSDLPlayPos = 0;
|
||||
nSDLFillSeg = 0;
|
||||
|
||||
loopLen = 0;
|
||||
fps = 0;
|
||||
volume = SDL_MIX_MAXVOLUME;
|
||||
}
|
||||
|
||||
~AudioSDL() {
|
||||
exit();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
struct AudOut AudOutSDL = { SDLSoundBlankSound, SDLSoundCheck, SDLSoundInit, SDLSetCallback, SDLSoundPlay, SDLSoundStop, SDLSoundExit, SDLSoundSetVolume, SDLGetSettings, _T("SDL audio output") };
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
// Module for input using SDL
|
||||
|
||||
#ifdef BUILD_SDL
|
||||
#include <SDL.h>
|
||||
|
||||
#include "burner.h"
|
||||
#include "inp_sdl_keys.h"
|
||||
#include "../../lib/SDL/SDL.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "SDL")
|
||||
#pragma comment(lib, "SDLmain")
|
||||
#endif
|
||||
|
||||
#define MAX_JOYSTICKS (8)
|
||||
|
||||
|
@ -81,11 +74,13 @@ int SDLinpExit()
|
|||
|
||||
int SDLinpInit()
|
||||
{
|
||||
int nSize;
|
||||
|
||||
SDLinpExit();
|
||||
|
||||
memset(&JoyList, 0, sizeof(JoyList));
|
||||
|
||||
int nSize = MAX_JOYSTICKS * 8 * sizeof(int);
|
||||
nSize = MAX_JOYSTICKS * 8 * sizeof(int);
|
||||
if ((JoyPrevAxes = (int*)malloc(nSize)) == NULL) {
|
||||
SDLinpExit();
|
||||
return 1;
|
||||
|
@ -185,11 +180,12 @@ int SDLinpJoyAxis(int i, int nAxis)
|
|||
// Read the keyboard
|
||||
static int ReadKeyboard()
|
||||
{
|
||||
int numkeys;
|
||||
|
||||
if (bKeyboardRead) { // already read this frame - ready to go
|
||||
return 0;
|
||||
}
|
||||
|
||||
int numkeys;
|
||||
SDLinpKeyboardState = SDL_GetKeyState(&numkeys);
|
||||
if (SDLinpKeyboardState == NULL) {
|
||||
return 1;
|
||||
|
@ -217,7 +213,7 @@ static int ReadMouse()
|
|||
// Read one mouse axis
|
||||
int SDLinpMouseAxis(int i, int nAxis)
|
||||
{
|
||||
if (i < 0 || i >= 1) { // Only the system mouse is supported by SDL
|
||||
if (i < 0 || i >= 1) { // Only the system mouse is supported by SDL
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -234,15 +230,15 @@ int SDLinpMouseAxis(int i, int nAxis)
|
|||
// 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
|
||||
if (i < 0 || i >= nJoystickCount) { // This joystick isn't connected
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ReadJoystick() != 0) { // Error polling the joystick
|
||||
if (ReadJoystick() != 0) { // Error polling the joystick
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nSubCode < 0x10) { // Joystick directions
|
||||
if (nSubCode < 0x10) { // Joystick directions
|
||||
const int DEADZONE = 0x4000;
|
||||
|
||||
if (SDL_JoystickNumAxes(JoyList[i]) <= nSubCode) {
|
||||
|
@ -319,10 +315,10 @@ int SDLinpState(int nCode)
|
|||
}
|
||||
|
||||
if (nCode < 0x100) {
|
||||
if (ReadKeyboard() != 0) { // Check keyboard has been read - return not pressed on error
|
||||
if (ReadKeyboard() != 0) { // Check keyboard has been read - return not pressed on error
|
||||
return 0;
|
||||
}
|
||||
return SDL_KEY_DOWN(nCode); // Return key state
|
||||
return SDL_KEY_DOWN(nCode); // Return key state
|
||||
}
|
||||
|
||||
if (nCode < 0x4000) {
|
||||
|
@ -339,10 +335,10 @@ int SDLinpState(int nCode)
|
|||
|
||||
if (nCode < 0xC000) {
|
||||
// Codes 8000-C000 = Mouse
|
||||
if ((nCode - 0x8000) >> 8) { // Only the system mouse is supported by SDL
|
||||
if ((nCode - 0x8000) >> 8) { // Only the system mouse is supported by SDL
|
||||
return 0;
|
||||
}
|
||||
if (ReadMouse() != 0) { // Error polling the mouse
|
||||
if (ReadMouse() != 0) { // Error polling the mouse
|
||||
return 0;
|
||||
}
|
||||
return CheckMouseState(nCode & 0xFF);
|
||||
|
@ -354,7 +350,7 @@ int SDLinpState(int nCode)
|
|||
// This function finds which key is pressed, and returns its code
|
||||
int SDLinpFind(bool CreateBaseline)
|
||||
{
|
||||
int nRetVal = -1; // assume nothing pressed
|
||||
int nRetVal = -1; // assume nothing pressed
|
||||
|
||||
// check if any keyboard keys are pressed
|
||||
if (ReadKeyboard() == 0) {
|
||||
|
@ -369,11 +365,11 @@ int SDLinpFind(bool CreateBaseline)
|
|||
// 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
|
||||
if (ReadJoystick() != 0) { // There was an error polling the joystick
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < 0x10; j++) { // Axes
|
||||
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)) {
|
||||
|
@ -383,7 +379,7 @@ int SDLinpFind(bool CreateBaseline)
|
|||
}
|
||||
}
|
||||
|
||||
for (j = 0x10; j < 0x20; j++) { // POV hats
|
||||
for (j = 0x10; j < 0x20; j++) { // POV hats
|
||||
if (JoystickState(i, j)) {
|
||||
nRetVal = 0x4000 | (i << 8) | j;
|
||||
goto End;
|
||||
|
@ -456,7 +452,7 @@ int SDLinpGetControlName(int nCode, TCHAR* pszDeviceName, TCHAR* pszControlName)
|
|||
if (i >= nJoystickCount) { // This joystick isn't connected
|
||||
return 0;
|
||||
}
|
||||
_stprintf(pszDeviceName, _T("%hs"), SDL_JoystickName(i));
|
||||
_tsprintf(pszDeviceName, "%hs", SDL_JoystickName(i));
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -475,6 +471,4 @@ int SDLinpGetControlName(int nCode, TCHAR* pszDeviceName, TCHAR* pszControlName)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct InputInOut InputInOutSDL = { SDLinpInit, SDLinpExit, SDLinpSetCooperativeLevel, SDLinpStart, SDLinpState, SDLinpJoyAxis, SDLinpMouseAxis, SDLinpFind, SDLinpGetControlName, NULL };
|
||||
|
||||
#endif
|
||||
struct InputInOut InputInOutSDL = { SDLinpInit, SDLinpExit, SDLinpSetCooperativeLevel, SDLinpStart, SDLinpState, SDLinpJoyAxis, SDLinpMouseAxis, SDLinpFind, SDLinpGetControlName, NULL, _T("SDL input") };
|
||||
|
|
|
@ -1,26 +1,20 @@
|
|||
// Software blitter effects via SDL
|
||||
|
||||
#ifdef BUILD_SDL
|
||||
|
||||
#include "burner.h"
|
||||
#include "vid_support.h"
|
||||
#include "vid_filter.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "SDL")
|
||||
#pragma comment(lib, "SDLmain")
|
||||
#endif
|
||||
#include "vid_softfx.h"
|
||||
|
||||
static int nInitedSubsytems = 0;
|
||||
|
||||
static int nGameWidth = 0, nGameHeight = 0; // screen size
|
||||
SDL_Surface* sdlsBlitFX[2] = {NULL, }; // The image surfaces
|
||||
SDL_Surface* sdlsFramebuf = NULL;
|
||||
|
||||
static int nSize;
|
||||
static int nUseBlitter;
|
||||
|
||||
static int nUseSys = 0;
|
||||
static int nUseSys;
|
||||
static int nDirectAccess = 1;
|
||||
static int nRotateGame = 0;
|
||||
|
||||
static int PrimClear()
|
||||
{
|
||||
|
@ -85,10 +79,9 @@ static int BlitFXInit()
|
|||
nVidImageHeight = nGameHeight;
|
||||
}
|
||||
|
||||
// if (nUseBlitter == FILTER_HQ2X || nUseBlitter == FILTER_HQ3X) {
|
||||
// nVidImageDepth = 16; // Use 565 format
|
||||
// } else
|
||||
{
|
||||
if (nUseBlitter >= 7 && nUseBlitter <= 9) {
|
||||
nVidImageDepth = 16; // Use 565 format
|
||||
} else {
|
||||
nVidImageDepth = sdlsFramebuf->format->BitsPerPixel;// Use color depth of primary surface
|
||||
}
|
||||
nVidImageBPP = sdlsFramebuf->format->BytesPerPixel;
|
||||
|
@ -131,11 +124,33 @@ static int Init()
|
|||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
nUseBlitter = nVidFilter;//nVidBlitterOpt[nVidSelect] & 0xFF;
|
||||
nUseBlitter = nVidBlitterOpt[nVidSelect] & 0xFF;
|
||||
|
||||
VidInitInfo();
|
||||
nGameWidth = nVidImageWidth; nGameHeight = nVidImageHeight;
|
||||
|
||||
nSize = VidFilterGetZoom(nUseBlitter);
|
||||
nRotateGame = 0;
|
||||
if (bDrvOkay) {
|
||||
// Get the game screen size
|
||||
BurnDrvGetVisibleSize(&nGameWidth, &nGameHeight);
|
||||
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
|
||||
if (nVidRotationAdjust & 1) {
|
||||
int n = nGameWidth;
|
||||
nGameWidth = nGameHeight;
|
||||
nGameHeight = n;
|
||||
nRotateGame |= (nVidRotationAdjust & 2);
|
||||
} else {
|
||||
nRotateGame |= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED) {
|
||||
nRotateGame ^= 2;
|
||||
}
|
||||
}
|
||||
|
||||
nSize = VidSoftFXGetZoom(nUseBlitter);
|
||||
bVidScanlines = 0; // !!!
|
||||
|
||||
if (nVidFullscreen) {
|
||||
|
||||
|
@ -156,8 +171,8 @@ static int Init()
|
|||
// Initialize the buffer surfaces
|
||||
BlitFXInit();
|
||||
|
||||
if (VidFilterInit(nUseBlitter, nRotateGame)) {
|
||||
if (VidFilterInit(0, nRotateGame)) {
|
||||
if (VidSoftFXInit(nUseBlitter, nRotateGame)) {
|
||||
if (VidSoftFXInit(0, nRotateGame)) {
|
||||
Exit();
|
||||
return 1;
|
||||
}
|
||||
|
@ -166,32 +181,14 @@ static int Init()
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int vidScale(RECT* pRect, int nWidth, int nHeight)
|
||||
static int vidScale(RECT* , int, int)
|
||||
{
|
||||
if (vidUseFilter && vidForceFilterSize) {
|
||||
return VidFilterScale(pRect, nWidth, nHeight);
|
||||
}
|
||||
|
||||
return VidSScaleImage(pRect, nWidth, nHeight);
|
||||
}
|
||||
|
||||
static int vidFilterApplyEffect(SDL_Surface* pSurf)
|
||||
{
|
||||
// Lock the surface so we can write to it
|
||||
if (SDL_LockSurface(pSurf)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
VidFilterApplyEffect((unsigned char*)pSurf->pixels, pSurf->pitch);
|
||||
|
||||
SDL_UnlockSurface(pSurf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int MemToSurf()
|
||||
{
|
||||
vidFilterApplyEffect(sdlsBlitFX[1 ^ nDirectAccess]);
|
||||
VidSoftFXApplyEffectSDL(sdlsBlitFX[1 ^ nDirectAccess]);
|
||||
|
||||
if (nUseSys == 0 && nDirectAccess == 0) {
|
||||
|
||||
|
@ -282,6 +279,9 @@ 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"));
|
||||
}
|
||||
|
@ -290,6 +290,5 @@ static int GetSettings(InterfaceInfo* pInfo)
|
|||
}
|
||||
|
||||
// The Video Output plugin:
|
||||
struct VidOut VidOutSDLFX = { Init, Exit, Frame, Paint, vidScale, GetSettings };
|
||||
struct VidOut VidOutSDLFX = { Init, Exit, Frame, Paint, vidScale, GetSettings, _T("SDL Software Effects video output") };
|
||||
|
||||
#endif
|
||||
|
|
|
@ -311,32 +311,21 @@ void SurfToTex()
|
|||
{
|
||||
memcpy(pd, ps, nPitch);
|
||||
}
|
||||
/* if (nVidImageBPP==3)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, nVidImageBPP, nTextureWidth, nTextureHeight, 0, color_type,texture_type, texture);
|
||||
}
|
||||
else
|
||||
*/ {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0,3, nTextureWidth, nTextureHeight, 0, GL_RGB, texture_type, texture);
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_2D, 0,3, nTextureWidth, nTextureHeight, 0, GL_RGB, texture_type, texture);
|
||||
}
|
||||
|
||||
void TexToQuad()
|
||||
{
|
||||
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
|
||||
// glColor3f(1,1,1);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0,0);
|
||||
glTexCoord2f(0,0);
|
||||
glVertex2i(0,0);
|
||||
glTexCoord2f(0,1);
|
||||
glTexCoord2f(0,1);
|
||||
glVertex2i(0,nTextureHeight);
|
||||
glTexCoord2f(1,1);
|
||||
glVertex2i(nTextureWidth,nTextureHeight);
|
||||
glTexCoord2f(1,0);
|
||||
glVertex2i(nTextureWidth,0);
|
||||
glEnd();
|
||||
//glFlush();
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue