diff --git a/libmednahawk/libmednahawk.vcxproj b/libmednahawk/libmednahawk.vcxproj index 7acf14f0db..ffb220f736 100644 --- a/libmednahawk/libmednahawk.vcxproj +++ b/libmednahawk/libmednahawk.vcxproj @@ -312,8 +312,6 @@ - - @@ -437,9 +435,6 @@ true - - - diff --git a/libmednahawk/libmednahawk.vcxproj.filters b/libmednahawk/libmednahawk.vcxproj.filters index 24623bcfc7..d4011d4380 100644 --- a/libmednahawk/libmednahawk.vcxproj.filters +++ b/libmednahawk/libmednahawk.vcxproj.filters @@ -49,15 +49,6 @@ {a3e7626e-55bc-4387-b374-de3b4c608880} - - {abc744d2-84b0-4a48-854b-7c1a92fd277e} - - - {3726dd22-b931-47f4-a2d3-29683b41b727} - - - {9fad4099-1fba-4cc2-8866-ad9be1671961} - {f36488fc-db6a-4348-84ad-94128fb86fbf} @@ -420,12 +411,6 @@ src\hw_cpu\z80-fuse - - src\hw_sound\ym2612 - - - src\hw_sound\sms_apu - src\desa68 @@ -778,15 +763,6 @@ src\hw_cpu\z80-fuse - - src\hw_sound\ym2612 - - - src\hw_sound\sms_apu - - - src\hw_sound\sms_apu - src\desa68 diff --git a/libmednahawk/src/demo/Makefile.am b/libmednahawk/src/demo/Makefile.am deleted file mode 100644 index 5556fa2f1d..0000000000 --- a/libmednahawk/src/demo/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -AUTOMAKE_OPTIONS = subdir-objects -DEFS = -DLOCALEDIR=\"$(datadir)/locale\" @DEFS@ @MATH_OPTIMIZER_FLAGS@ -DEFAULT_INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/intl - -noinst_LIBRARIES = libdemo.a - -libdemo_a_SOURCES = demo.cpp diff --git a/libmednahawk/src/demo/Makefile.in b/libmednahawk/src/demo/Makefile.in deleted file mode 100644 index 363b9c7d4d..0000000000 --- a/libmednahawk/src/demo/Makefile.in +++ /dev/null @@ -1,596 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -target_triplet = @target@ -subdir = src/demo -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ - $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/fcntl-o.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc2.m4 \ - $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intl.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ - $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ - $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ - $(top_srcdir)/m4/threadlib.m4 $(top_srcdir)/m4/uintmax_t.m4 \ - $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ - $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ - $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/include/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -LIBRARIES = $(noinst_LIBRARIES) -ARFLAGS = cru -AM_V_AR = $(am__v_AR_$(V)) -am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY)) -am__v_AR_0 = @echo " AR " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -libdemo_a_AR = $(AR) $(ARFLAGS) -libdemo_a_LIBADD = -am_libdemo_a_OBJECTS = demo.$(OBJEXT) -libdemo_a_OBJECTS = $(am_libdemo_a_OBJECTS) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) -am__v_lt_0 = --silent -LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CXXFLAGS) $(CXXFLAGS) -AM_V_CXX = $(am__v_CXX_$(V)) -am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) -am__v_CXX_0 = @echo " CXX " $@; -CXXLD = $(CXX) -CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ - $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CXXLD = $(am__v_CXXLD_$(V)) -am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) -am__v_CXXLD_0 = @echo " CXXLD " $@; -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(libdemo_a_SOURCES) -DIST_SOURCES = $(libdemo_a_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -ALSA_CFLAGS = @ALSA_CFLAGS@ -ALSA_LIBS = @ALSA_LIBS@ -AMTAR = @AMTAR@ -AM_CFLAGS = @AM_CFLAGS@ -AM_CXXFLAGS = @AM_CXXFLAGS@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ -CATOBJEXT = @CATOBJEXT@ -CC = @CC@ -CCAS = @CCAS@ -CCASDEPMODE = @CCASDEPMODE@ -CCASFLAGS = @CCASFLAGS@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DATADIRNAME = @DATADIRNAME@ -DEFS = -DLOCALEDIR=\"$(datadir)/locale\" @DEFS@ @MATH_OPTIMIZER_FLAGS@ -DEPDIR = @DEPDIR@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GBA_EXTRA_FLAGS = @GBA_EXTRA_FLAGS@ -GENCAT = @GENCAT@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GLIBC2 = @GLIBC2@ -GLIBC21 = @GLIBC21@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GREP = @GREP@ -HAVE_ASPRINTF = @HAVE_ASPRINTF@ -HAVE_NEWLOCALE = @HAVE_NEWLOCALE@ -HAVE_POSIX_PRINTF = @HAVE_POSIX_PRINTF@ -HAVE_SNPRINTF = @HAVE_SNPRINTF@ -HAVE_VISIBILITY = @HAVE_VISIBILITY@ -HAVE_WPRINTF = @HAVE_WPRINTF@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTOBJEXT = @INSTOBJEXT@ -INTLBISON = @INTLBISON@ -INTLLIBS = @INTLLIBS@ -INTLOBJS = @INTLOBJS@ -INTL_DEFAULT_VERBOSITY = @INTL_DEFAULT_VERBOSITY@ -INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -JACK_CFLAGS = @JACK_CFLAGS@ -JACK_LIBS = @JACK_LIBS@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBCDIO_CFLAGS = @LIBCDIO_CFLAGS@ -LIBCDIO_LIBS = @LIBCDIO_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBMULTITHREAD = @LIBMULTITHREAD@ -LIBOBJS = @LIBOBJS@ -LIBPTH = @LIBPTH@ -LIBPTH_PREFIX = @LIBPTH_PREFIX@ -LIBS = @LIBS@ -LIBTHREAD = @LIBTHREAD@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBC = @LTLIBC@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ -LTLIBOBJS = @LTLIBOBJS@ -LTLIBPTH = @LTLIBPTH@ -LTLIBTHREAD = @LTLIBTHREAD@ -MAKEINFO = @MAKEINFO@ -MATH_OPTIMIZER_FLAGS = @MATH_OPTIMIZER_FLAGS@ -MKDIR_P = @MKDIR_P@ -MMX_CFLAGS = @MMX_CFLAGS@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POSUB = @POSUB@ -PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ -RANLIB = @RANLIB@ -SDL_CFLAGS = @SDL_CFLAGS@ -SDL_CONFIG = @SDL_CONFIG@ -SDL_LIBS = @SDL_LIBS@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -SNDFILE_CFLAGS = @SNDFILE_CFLAGS@ -SNDFILE_LIBS = @SNDFILE_LIBS@ -SNES_EXTRA_CXXFLAGS = @SNES_EXTRA_CXXFLAGS@ -SNES_EXTRA_FLAGS = @SNES_EXTRA_FLAGS@ -SSE2_CFLAGS = @SSE2_CFLAGS@ -SSE3_CFLAGS = @SSE3_CFLAGS@ -SSE_CFLAGS = @SSE_CFLAGS@ -STRIP = @STRIP@ -TRIO_CFLAGS = @TRIO_CFLAGS@ -USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ -USE_NLS = @USE_NLS@ -VERSION = @VERSION@ -WARNING_FLAGS = @WARNING_FLAGS@ -WINDRES = @WINDRES@ -WOE32 = @WOE32@ -WOE32DLL = @WOE32DLL@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -XMKMF = @XMKMF@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target = @target@ -target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AUTOMAKE_OPTIONS = subdir-objects -DEFAULT_INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/intl -noinst_LIBRARIES = libdemo.a -libdemo_a_SOURCES = demo.cpp -all: all-am - -.SUFFIXES: -.SUFFIXES: .cpp .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/demo/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/demo/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) -libdemo.a: $(libdemo_a_OBJECTS) $(libdemo_a_DEPENDENCIES) - $(AM_V_at)-rm -f libdemo.a - $(AM_V_AR)$(libdemo_a_AR) libdemo.a $(libdemo_a_OBJECTS) $(libdemo_a_LIBADD) - $(AM_V_at)$(RANLIB) libdemo.a - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo.Po@am__quote@ - -.cpp.o: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.cpp.lo: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ -@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LIBRARIES) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLIBRARIES ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libmednahawk/src/demo/demo.cpp b/libmednahawk/src/demo/demo.cpp deleted file mode 100644 index 47eb15a934..0000000000 --- a/libmednahawk/src/demo/demo.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "../mednafen.h" - -#if 0 - -MDFNGI EmulatedDEMO = -{ - "demo", - "Mednafen Demo/Example Module", - KnownExtensions, - MODPRIO_INTERNAL_LOW, - NULL, // Debugger - &SNESInputInfo, - Load, - NULL, - NULL, - NULL, - CloseGame, - SetLayerEnableMask, - "Background\0Sprites\0", - NULL, - NULL, - NULL, //InstallReadPatch, - NULL, //RemoveReadPatches, - NULL, //MemRead, - false, - NULL, //StateAction, - Emulate, - SetInput, - SetSoundRate, - DoSimpleCommand, - SNESSettings, - 0, - 0, - FALSE, // Multires - 320, // Nominal width - 240, // Nominal height - 512, // Framebuffer width - 256, // Framebuffer height -}; - -#endif diff --git a/libmednahawk/src/hw_sound/Makefile.am b/libmednahawk/src/hw_sound/Makefile.am deleted file mode 100644 index 9d29ec3a3e..0000000000 --- a/libmednahawk/src/hw_sound/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -AUTOMAKE_OPTIONS = subdir-objects -DEFS = -DLOCALEDIR=\"$(datadir)/locale\" @DEFS@ @MATH_OPTIMIZER_FLAGS@ -DEFAULT_INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/intl -I$(top_builddir)/include/blip -I$(top_srcdir) - -noinst_LIBRARIES = libmdfnhwsound.a - -ym2413_SOURCES = ym2413/emu2413.cpp -ym2612_SOURCES = ym2612/Ym2612_Emu.cpp -gb_apu_SOURCES = gb_apu/Gb_Apu.cpp gb_apu/Gb_Apu_State.cpp gb_apu/Gb_Oscs.cpp -sms_apu_SOURCES = sms_apu/Sms_Apu.cpp -pce_psg_SOURCES = pce_psg/pce_psg.cpp - -libmdfnhwsound_a_SOURCES = $(ym2413_SOURCES) $(ym2612_SOURCES) $(gb_apu_SOURCES) $(sms_apu_SOURCES) $(pce_psg_SOURCES) - diff --git a/libmednahawk/src/hw_sound/Makefile.in b/libmednahawk/src/hw_sound/Makefile.in deleted file mode 100644 index 3719e3cee2..0000000000 --- a/libmednahawk/src/hw_sound/Makefile.in +++ /dev/null @@ -1,676 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -target_triplet = @target@ -subdir = src/hw_sound -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ - $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/fcntl-o.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc2.m4 \ - $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intl.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ - $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ - $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ - $(top_srcdir)/m4/threadlib.m4 $(top_srcdir)/m4/uintmax_t.m4 \ - $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ - $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ - $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/include/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -LIBRARIES = $(noinst_LIBRARIES) -ARFLAGS = cru -AM_V_AR = $(am__v_AR_$(V)) -am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY)) -am__v_AR_0 = @echo " AR " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -libmdfnhwsound_a_AR = $(AR) $(ARFLAGS) -libmdfnhwsound_a_LIBADD = -am__dirstamp = $(am__leading_dot)dirstamp -am__objects_1 = ym2413/emu2413.$(OBJEXT) -am__objects_2 = ym2612/Ym2612_Emu.$(OBJEXT) -am__objects_3 = gb_apu/Gb_Apu.$(OBJEXT) gb_apu/Gb_Apu_State.$(OBJEXT) \ - gb_apu/Gb_Oscs.$(OBJEXT) -am__objects_4 = sms_apu/Sms_Apu.$(OBJEXT) -am__objects_5 = pce_psg/pce_psg.$(OBJEXT) -am_libmdfnhwsound_a_OBJECTS = $(am__objects_1) $(am__objects_2) \ - $(am__objects_3) $(am__objects_4) $(am__objects_5) -libmdfnhwsound_a_OBJECTS = $(am_libmdfnhwsound_a_OBJECTS) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) -am__v_lt_0 = --silent -LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CXXFLAGS) $(CXXFLAGS) -AM_V_CXX = $(am__v_CXX_$(V)) -am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) -am__v_CXX_0 = @echo " CXX " $@; -CXXLD = $(CXX) -CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ - $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CXXLD = $(am__v_CXXLD_$(V)) -am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) -am__v_CXXLD_0 = @echo " CXXLD " $@; -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(libmdfnhwsound_a_SOURCES) -DIST_SOURCES = $(libmdfnhwsound_a_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -ALSA_CFLAGS = @ALSA_CFLAGS@ -ALSA_LIBS = @ALSA_LIBS@ -AMTAR = @AMTAR@ -AM_CFLAGS = @AM_CFLAGS@ -AM_CXXFLAGS = @AM_CXXFLAGS@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ -CATOBJEXT = @CATOBJEXT@ -CC = @CC@ -CCAS = @CCAS@ -CCASDEPMODE = @CCASDEPMODE@ -CCASFLAGS = @CCASFLAGS@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DATADIRNAME = @DATADIRNAME@ -DEFS = -DLOCALEDIR=\"$(datadir)/locale\" @DEFS@ @MATH_OPTIMIZER_FLAGS@ -DEPDIR = @DEPDIR@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GBA_EXTRA_FLAGS = @GBA_EXTRA_FLAGS@ -GENCAT = @GENCAT@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GLIBC2 = @GLIBC2@ -GLIBC21 = @GLIBC21@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GREP = @GREP@ -HAVE_ASPRINTF = @HAVE_ASPRINTF@ -HAVE_NEWLOCALE = @HAVE_NEWLOCALE@ -HAVE_POSIX_PRINTF = @HAVE_POSIX_PRINTF@ -HAVE_SNPRINTF = @HAVE_SNPRINTF@ -HAVE_VISIBILITY = @HAVE_VISIBILITY@ -HAVE_WPRINTF = @HAVE_WPRINTF@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTOBJEXT = @INSTOBJEXT@ -INTLBISON = @INTLBISON@ -INTLLIBS = @INTLLIBS@ -INTLOBJS = @INTLOBJS@ -INTL_DEFAULT_VERBOSITY = @INTL_DEFAULT_VERBOSITY@ -INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -JACK_CFLAGS = @JACK_CFLAGS@ -JACK_LIBS = @JACK_LIBS@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBCDIO_CFLAGS = @LIBCDIO_CFLAGS@ -LIBCDIO_LIBS = @LIBCDIO_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBMULTITHREAD = @LIBMULTITHREAD@ -LIBOBJS = @LIBOBJS@ -LIBPTH = @LIBPTH@ -LIBPTH_PREFIX = @LIBPTH_PREFIX@ -LIBS = @LIBS@ -LIBTHREAD = @LIBTHREAD@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBC = @LTLIBC@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ -LTLIBOBJS = @LTLIBOBJS@ -LTLIBPTH = @LTLIBPTH@ -LTLIBTHREAD = @LTLIBTHREAD@ -MAKEINFO = @MAKEINFO@ -MATH_OPTIMIZER_FLAGS = @MATH_OPTIMIZER_FLAGS@ -MKDIR_P = @MKDIR_P@ -MMX_CFLAGS = @MMX_CFLAGS@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POSUB = @POSUB@ -PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ -RANLIB = @RANLIB@ -SDL_CFLAGS = @SDL_CFLAGS@ -SDL_CONFIG = @SDL_CONFIG@ -SDL_LIBS = @SDL_LIBS@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -SNDFILE_CFLAGS = @SNDFILE_CFLAGS@ -SNDFILE_LIBS = @SNDFILE_LIBS@ -SNES_EXTRA_CXXFLAGS = @SNES_EXTRA_CXXFLAGS@ -SNES_EXTRA_FLAGS = @SNES_EXTRA_FLAGS@ -SSE2_CFLAGS = @SSE2_CFLAGS@ -SSE3_CFLAGS = @SSE3_CFLAGS@ -SSE_CFLAGS = @SSE_CFLAGS@ -STRIP = @STRIP@ -TRIO_CFLAGS = @TRIO_CFLAGS@ -USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ -USE_NLS = @USE_NLS@ -VERSION = @VERSION@ -WARNING_FLAGS = @WARNING_FLAGS@ -WINDRES = @WINDRES@ -WOE32 = @WOE32@ -WOE32DLL = @WOE32DLL@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -XMKMF = @XMKMF@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target = @target@ -target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AUTOMAKE_OPTIONS = subdir-objects -DEFAULT_INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/intl -I$(top_builddir)/include/blip -I$(top_srcdir) -noinst_LIBRARIES = libmdfnhwsound.a -ym2413_SOURCES = ym2413/emu2413.cpp -ym2612_SOURCES = ym2612/Ym2612_Emu.cpp -gb_apu_SOURCES = gb_apu/Gb_Apu.cpp gb_apu/Gb_Apu_State.cpp gb_apu/Gb_Oscs.cpp -sms_apu_SOURCES = sms_apu/Sms_Apu.cpp -pce_psg_SOURCES = pce_psg/pce_psg.cpp -libmdfnhwsound_a_SOURCES = $(ym2413_SOURCES) $(ym2612_SOURCES) $(gb_apu_SOURCES) $(sms_apu_SOURCES) $(pce_psg_SOURCES) -all: all-am - -.SUFFIXES: -.SUFFIXES: .cpp .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/hw_sound/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/hw_sound/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) -ym2413/$(am__dirstamp): - @$(MKDIR_P) ym2413 - @: > ym2413/$(am__dirstamp) -ym2413/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) ym2413/$(DEPDIR) - @: > ym2413/$(DEPDIR)/$(am__dirstamp) -ym2413/emu2413.$(OBJEXT): ym2413/$(am__dirstamp) \ - ym2413/$(DEPDIR)/$(am__dirstamp) -ym2612/$(am__dirstamp): - @$(MKDIR_P) ym2612 - @: > ym2612/$(am__dirstamp) -ym2612/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) ym2612/$(DEPDIR) - @: > ym2612/$(DEPDIR)/$(am__dirstamp) -ym2612/Ym2612_Emu.$(OBJEXT): ym2612/$(am__dirstamp) \ - ym2612/$(DEPDIR)/$(am__dirstamp) -gb_apu/$(am__dirstamp): - @$(MKDIR_P) gb_apu - @: > gb_apu/$(am__dirstamp) -gb_apu/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) gb_apu/$(DEPDIR) - @: > gb_apu/$(DEPDIR)/$(am__dirstamp) -gb_apu/Gb_Apu.$(OBJEXT): gb_apu/$(am__dirstamp) \ - gb_apu/$(DEPDIR)/$(am__dirstamp) -gb_apu/Gb_Apu_State.$(OBJEXT): gb_apu/$(am__dirstamp) \ - gb_apu/$(DEPDIR)/$(am__dirstamp) -gb_apu/Gb_Oscs.$(OBJEXT): gb_apu/$(am__dirstamp) \ - gb_apu/$(DEPDIR)/$(am__dirstamp) -sms_apu/$(am__dirstamp): - @$(MKDIR_P) sms_apu - @: > sms_apu/$(am__dirstamp) -sms_apu/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) sms_apu/$(DEPDIR) - @: > sms_apu/$(DEPDIR)/$(am__dirstamp) -sms_apu/Sms_Apu.$(OBJEXT): sms_apu/$(am__dirstamp) \ - sms_apu/$(DEPDIR)/$(am__dirstamp) -pce_psg/$(am__dirstamp): - @$(MKDIR_P) pce_psg - @: > pce_psg/$(am__dirstamp) -pce_psg/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) pce_psg/$(DEPDIR) - @: > pce_psg/$(DEPDIR)/$(am__dirstamp) -pce_psg/pce_psg.$(OBJEXT): pce_psg/$(am__dirstamp) \ - pce_psg/$(DEPDIR)/$(am__dirstamp) -libmdfnhwsound.a: $(libmdfnhwsound_a_OBJECTS) $(libmdfnhwsound_a_DEPENDENCIES) - $(AM_V_at)-rm -f libmdfnhwsound.a - $(AM_V_AR)$(libmdfnhwsound_a_AR) libmdfnhwsound.a $(libmdfnhwsound_a_OBJECTS) $(libmdfnhwsound_a_LIBADD) - $(AM_V_at)$(RANLIB) libmdfnhwsound.a - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -rm -f gb_apu/Gb_Apu.$(OBJEXT) - -rm -f gb_apu/Gb_Apu_State.$(OBJEXT) - -rm -f gb_apu/Gb_Oscs.$(OBJEXT) - -rm -f pce_psg/pce_psg.$(OBJEXT) - -rm -f sms_apu/Sms_Apu.$(OBJEXT) - -rm -f ym2413/emu2413.$(OBJEXT) - -rm -f ym2612/Ym2612_Emu.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@gb_apu/$(DEPDIR)/Gb_Apu.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@gb_apu/$(DEPDIR)/Gb_Apu_State.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@gb_apu/$(DEPDIR)/Gb_Oscs.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@pce_psg/$(DEPDIR)/pce_psg.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@sms_apu/$(DEPDIR)/Sms_Apu.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ym2413/$(DEPDIR)/emu2413.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@ym2612/$(DEPDIR)/Ym2612_Emu.Po@am__quote@ - -.cpp.o: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.cpp.lo: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ -@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LIBRARIES) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -rm -f gb_apu/$(DEPDIR)/$(am__dirstamp) - -rm -f gb_apu/$(am__dirstamp) - -rm -f pce_psg/$(DEPDIR)/$(am__dirstamp) - -rm -f pce_psg/$(am__dirstamp) - -rm -f sms_apu/$(DEPDIR)/$(am__dirstamp) - -rm -f sms_apu/$(am__dirstamp) - -rm -f ym2413/$(DEPDIR)/$(am__dirstamp) - -rm -f ym2413/$(am__dirstamp) - -rm -f ym2612/$(DEPDIR)/$(am__dirstamp) - -rm -f ym2612/$(am__dirstamp) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf gb_apu/$(DEPDIR) pce_psg/$(DEPDIR) sms_apu/$(DEPDIR) ym2413/$(DEPDIR) ym2612/$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf gb_apu/$(DEPDIR) pce_psg/$(DEPDIR) sms_apu/$(DEPDIR) ym2413/$(DEPDIR) ym2612/$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLIBRARIES ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libmednahawk/src/hw_sound/gb_apu/Gb_Apu.cpp b/libmednahawk/src/hw_sound/gb_apu/Gb_Apu.cpp deleted file mode 100644 index 4b58aedf1a..0000000000 --- a/libmednahawk/src/hw_sound/gb_apu/Gb_Apu.cpp +++ /dev/null @@ -1,394 +0,0 @@ -// Gb_Snd_Emu 0.2.0. http://www.slack.net/~ant/ - -#include "Gb_Apu.h" - -/* Copyright (C) 2003-2007 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -unsigned const vol_reg = 0xFF24; -unsigned const stereo_reg = 0xFF25; -unsigned const status_reg = 0xFF26; -unsigned const wave_ram = 0xFF30; - -int const power_mask = 0x80; - -void Gb_Apu::treble_eq( blip_eq_t const& eq ) -{ - good_synth.treble_eq( eq ); - med_synth .treble_eq( eq ); -} - -inline int Gb_Apu::calc_output( int osc ) const -{ - int bits = regs [stereo_reg - start_addr] >> osc; - return (bits >> 3 & 2) | (bits & 1); -} - -void Gb_Apu::set_output( Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right, int osc ) -{ - // Must be silent (all NULL), mono (left and right NULL), or stereo (none NULL) - require( !center || (center && !left && !right) || (center && left && right) ); - require( (unsigned) osc <= osc_count ); // fails if you pass invalid osc index - - if ( !center || !left || !right ) - { - left = center; - right = center; - } - - int i = (unsigned) osc % osc_count; - do - { - Gb_Osc& o = *oscs [i]; - o.outputs [1] = right; - o.outputs [2] = left; - o.outputs [3] = center; - o.output = o.outputs [calc_output( i )]; - } - while ( ++i < osc ); -} - -void Gb_Apu::synth_volume( int iv ) -{ - double v = volume_ * 0.60 / osc_count / 15 /*steps*/ / 8 /*master vol range*/ * iv; - good_synth.volume( v ); - med_synth .volume( v ); -} - -void Gb_Apu::apply_volume() -{ - // TODO: Doesn't handle differing left and right volumes (panning). - // Not worth the complexity. - int data = regs [vol_reg - start_addr]; - int left = data >> 4 & 7; - int right = data & 7; - //if ( data & 0x88 ) dprintf( "Vin: %02X\n", data & 0x88 ); - //if ( left != right ) dprintf( "l: %d r: %d\n", left, right ); - synth_volume( max( left, right ) + 1 ); -} - -void Gb_Apu::volume( double v ) -{ - if ( volume_ != v ) - { - volume_ = v; - apply_volume(); - } -} - -void Gb_Apu::reset_regs() -{ - for ( int i = 0; i < 0x20; i++ ) - regs [i] = 0; - - square1.reset(); - square2.reset(); - wave .reset(); - noise .reset(); - - apply_volume(); -} - -void Gb_Apu::reset_lengths() -{ - square1.length_ctr = 64; - square2.length_ctr = 64; - wave .length_ctr = 256; - noise .length_ctr = 64; -} - -void Gb_Apu::reduce_clicks( bool reduce ) -{ - reduce_clicks_ = reduce; - - // Click reduction makes DAC off generate same output as volume 0 - int dac_off_amp = 0; - if ( reduce && wave.mode != mode_agb ) // AGB already eliminates clicks - dac_off_amp = -Gb_Osc::dac_bias; - - for ( int i = 0; i < osc_count; i++ ) - oscs [i]->dac_off_amp = dac_off_amp; - - // AGB always eliminates clicks on wave channel using same method - if ( wave.mode == mode_agb ) - wave.dac_off_amp = -Gb_Osc::dac_bias; -} - -void Gb_Apu::reset( mode_t mode, bool agb_wave ) -{ - // Hardware mode - if ( agb_wave ) - mode = mode_agb; // using AGB wave features implies AGB hardware - wave.agb_mask = agb_wave ? 0xFF : 0; - for ( int i = 0; i < osc_count; i++ ) - oscs [i]->mode = mode; - reduce_clicks( reduce_clicks_ ); - - // Reset state - frame_time = 0; - last_time = 0; - frame_phase = 0; - - reset_regs(); - reset_lengths(); - - // Load initial wave RAM - static byte const initial_wave [2] [16] = { - {0x84,0x40,0x43,0xAA,0x2D,0x78,0x92,0x3C,0x60,0x59,0x59,0xB0,0x34,0xB8,0x2E,0xDA}, - {0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF}, - }; - for ( int b = 2; --b >= 0; ) - { - // Init both banks (does nothing if not in AGB mode) - // TODO: verify that this works - write_register( 0, 0xFF1A, b * 0x40 ); - for ( unsigned i = 0; i < sizeof initial_wave [0]; i++ ) - write_register( 0, i + wave_ram, initial_wave [(mode != mode_dmg)] [i] ); - } -} - -void Gb_Apu::set_tempo( double t ) -{ - frame_period = 4194304 / 512; // 512 Hz - if ( t != 1.0 ) - frame_period = blip_time_t (frame_period / t); -} - -Gb_Apu::Gb_Apu() -{ - wave.wave_ram = ®s [wave_ram - start_addr]; - - oscs [0] = &square1; - oscs [1] = &square2; - oscs [2] = &wave; - oscs [3] = &noise; - - for ( int i = osc_count; --i >= 0; ) - { - Gb_Osc& o = *oscs [i]; - o.regs = ®s [i * 5]; - o.output = 0; - o.outputs [0] = 0; - o.outputs [1] = 0; - o.outputs [2] = 0; - o.outputs [3] = 0; - o.good_synth = &good_synth; - o.med_synth = &med_synth; - } - - reduce_clicks_ = false; - set_tempo( 1.0 ); - volume_ = 1.0; - reset(); -} - -void Gb_Apu::run_until_( blip_time_t end_time ) -{ - while ( true ) - { - // run oscillators - blip_time_t time = end_time; - if ( time > frame_time ) - time = frame_time; - - square1.run( last_time, time ); - square2.run( last_time, time ); - wave .run( last_time, time ); - noise .run( last_time, time ); - last_time = time; - - if ( time == end_time ) - break; - - // run frame sequencer - frame_time += frame_period * Gb_Osc::clk_mul; - switch ( frame_phase++ ) - { - case 2: - case 6: - // 128 Hz - square1.clock_sweep(); - case 0: - case 4: - // 256 Hz - square1.clock_length(); - square2.clock_length(); - wave .clock_length(); - noise .clock_length(); - break; - - case 7: - // 64 Hz - frame_phase = 0; - square1.clock_envelope(); - square2.clock_envelope(); - noise .clock_envelope(); - } - } -} - -inline void Gb_Apu::run_until( blip_time_t time ) -{ - require( time >= last_time ); // end_time must not be before previous time - if ( time > last_time ) - run_until_( time ); -} - -void Gb_Apu::end_frame( blip_time_t end_time ) -{ - if ( end_time > last_time ) - run_until( end_time ); - - frame_time -= end_time; - assert( frame_time >= 0 ); - - last_time -= end_time; - assert( last_time >= 0 ); -} - -void Gb_Apu::silence_osc( Gb_Osc& o ) -{ - int delta = -o.last_amp; - if ( delta ) - { - o.last_amp = 0; - if ( o.output ) - { - o.output->set_modified(); - med_synth.offset( last_time, delta, o.output ); - } - } -} - -void Gb_Apu::apply_stereo() -{ - for ( int i = osc_count; --i >= 0; ) - { - Gb_Osc& o = *oscs [i]; - Blip_Buffer* out = o.outputs [calc_output( i )]; - if ( o.output != out ) - { - silence_osc( o ); - o.output = out; - } - } -} - -void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data ) -{ - require( (unsigned) data < 0x100 ); - - int reg = addr - start_addr; - if ( (unsigned) reg >= register_count ) - { - require( false ); - return; - } - - if ( addr < status_reg && !(regs [status_reg - start_addr] & power_mask) ) - { - // Power is off - - // length counters can only be written in DMG mode - if ( wave.mode != mode_dmg || (reg != 1 && reg != 5+1 && reg != 10+1 && reg != 15+1) ) - return; - - if ( reg < 10 ) - data &= 0x3F; // clear square duty - } - - run_until( time ); - - if ( addr >= wave_ram ) - { - wave.write( addr, data ); - } - else - { - int old_data = regs [reg]; - regs [reg] = data; - - if ( addr < vol_reg ) - { - // Oscillator - write_osc( reg / 5, reg, old_data, data ); - } - else if ( addr == vol_reg && data != old_data ) - { - // Master volume - for ( int i = osc_count; --i >= 0; ) - silence_osc( *oscs [i] ); - - apply_volume(); - } - else if ( addr == stereo_reg ) - { - // Stereo panning - apply_stereo(); - } - else if ( addr == status_reg && (data ^ old_data) & power_mask ) - { - // Power control - frame_phase = 0; - for ( int i = osc_count; --i >= 0; ) - silence_osc( *oscs [i] ); - - reset_regs(); - if ( wave.mode != mode_dmg ) - reset_lengths(); - - regs [status_reg - start_addr] = data; - } - } -} - -int Gb_Apu::read_register( blip_time_t time, unsigned addr ) -{ - run_until( time ); - - int reg = addr - start_addr; - if ( (unsigned) reg >= register_count ) - { - require( false ); - return 0; - } - - if ( addr >= wave_ram ) - return wave.read( addr ); - - // Value read back has some bits always set - static byte const masks [] = { - 0x80,0x3F,0x00,0xFF,0xBF, - 0xFF,0x3F,0x00,0xFF,0xBF, - 0x7F,0xFF,0x9F,0xFF,0xBF, - 0xFF,0xFF,0x00,0x00,0xBF, - 0x00,0x00,0x70, - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF - }; - int mask = masks [reg]; - if ( wave.agb_mask && (reg == 10 || reg == 12) ) - mask = 0x1F; // extra implemented bits in wave regs on AGB - int data = regs [reg] | mask; - - // Status register - if ( addr == status_reg ) - { - data &= 0xF0; - data |= (int) square1.enabled << 0; - data |= (int) square2.enabled << 1; - data |= (int) wave .enabled << 2; - data |= (int) noise .enabled << 3; - } - - return data; -} diff --git a/libmednahawk/src/hw_sound/gb_apu/Gb_Apu.h b/libmednahawk/src/hw_sound/gb_apu/Gb_Apu.h deleted file mode 100644 index 284b152cad..0000000000 --- a/libmednahawk/src/hw_sound/gb_apu/Gb_Apu.h +++ /dev/null @@ -1,182 +0,0 @@ -// Nintendo Game Boy sound hardware emulator with save state support - -// Gb_Snd_Emu 0.2.0 -#ifndef GB_APU_H -#define GB_APU_H - -#include "Gb_Oscs.h" - -struct gb_apu_state_t; - -class Gb_Apu { -public: -// Basics - - // Clock rate that sound hardware runs at. - enum { clock_rate = 4194304 * GB_APU_OVERCLOCK }; - - // Sets buffer(s) to generate sound into. If left and right are NULL, output is mono. - // If all are NULL, no output is generated but other emulation still runs. - // If chan is specified, only that channel's output is changed, otherwise all are. - enum { osc_count = 4 }; // 0: Square 1, 1: Square 2, 2: Wave, 3: Noise - void set_output( Blip_Buffer* center, Blip_Buffer* left = NULL, Blip_Buffer* right = NULL, - int chan = osc_count ); - - // Resets hardware to initial power on state BEFORE boot ROM runs. Mode selects - // sound hardware. Additional AGB wave features are enabled separately. - enum mode_t { - mode_dmg, // Game Boy monochrome - mode_cgb, // Game Boy Color - mode_agb // Game Boy Advance - }; - void reset( mode_t mode = mode_cgb, bool agb_wave = false ); - - // Reads and writes must be within the start_addr to end_addr range, inclusive. - // Addresses outside this range are not mapped to the sound hardware. - enum { start_addr = 0xFF10 }; - enum { end_addr = 0xFF3F }; - enum { register_count = end_addr - start_addr + 1 }; - - // Times are specified as the number of clocks since the beginning of the - // current time frame. - - // Emulates CPU write of data to addr at specified time. - void write_register( blip_time_t time, unsigned addr, int data ); - - // Emulates CPU read from addr at specified time. - int read_register( blip_time_t time, unsigned addr ); - - // Emulates sound hardware up to specified time, ends current time frame, then - // starts a new frame at time 0. - void end_frame( blip_time_t frame_length ); - -// Sound adjustments - - // Sets overall volume, where 1.0 is normal. - void volume( double ); - - // If true, reduces clicking by disabling DAC biasing. Note that this reduces - // emulation accuracy, since the clicks are authentic. - void reduce_clicks( bool reduce = true ); - - // Sets treble equalization. - void treble_eq( blip_eq_t const& ); - - // Treble and bass values for various hardware. - enum { - speaker_treble = -47, // speaker on system - speaker_bass = 2000, - dmg_treble = 0, // headphones on each system - dmg_bass = 30, - cgb_treble = 0, - cgb_bass = 300, // CGB has much less bass - agb_treble = 0, - agb_bass = 30 - }; - - // Sets frame sequencer rate, where 1.0 is normal. Meant for adjusting the - // tempo in a game music player. - void set_tempo( double ); - -// Save states - - // Saves full emulation state to state_out. Data format is portable and - // includes some extra space to avoid expansion in case more state needs - // to be stored in the future. - void save_state( gb_apu_state_t* state_out ); - - // Loads state. You should call reset() BEFORE this. - blargg_err_t load_state( gb_apu_state_t const& in ); - -public: - Gb_Apu(); - - // Use set_output() in place of these - BLARGG_DEPRECATED void output ( Blip_Buffer* c ) { set_output( c, c, c ); } - BLARGG_DEPRECATED void output ( Blip_Buffer* c, Blip_Buffer* l, Blip_Buffer* r ) { set_output( c, l, r ); } - BLARGG_DEPRECATED void osc_output( int i, Blip_Buffer* c ) { set_output( c, c, c, i ); } - BLARGG_DEPRECATED void osc_output( int i, Blip_Buffer* c, Blip_Buffer* l, Blip_Buffer* r ) { set_output( c, l, r, i ); } - -private: - // noncopyable - Gb_Apu( const Gb_Apu& ); - Gb_Apu& operator = ( const Gb_Apu& ); - - Gb_Osc* oscs [osc_count]; - blip_time_t last_time; // time sound emulator has been run to - blip_time_t frame_period; // clocks between each frame sequencer step - double volume_; - bool reduce_clicks_; - - Gb_Sweep_Square square1; - Gb_Square square2; - Gb_Wave wave; - Gb_Noise noise; - blip_time_t frame_time; // time of next frame sequencer action - int frame_phase; // phase of next frame sequencer step - enum { regs_size = register_count + 0x10 }; - BOOST::uint8_t regs [regs_size];// last values written to registers - - // large objects after everything else - Gb_Osc::Good_Synth good_synth; - Gb_Osc::Med_Synth med_synth; - - void reset_lengths(); - void reset_regs(); - int calc_output( int osc ) const; - void apply_stereo(); - void apply_volume(); - void synth_volume( int ); - void run_until_( blip_time_t ); - void run_until( blip_time_t ); - void silence_osc( Gb_Osc& ); - void write_osc( int index, int reg, int old_data, int data ); - const char* save_load( gb_apu_state_t*, bool save ); - void save_load2( gb_apu_state_t*, bool save ); - friend class Gb_Apu_Tester; -}; - -// Format of save state. Should be stable across versions of the library, -// with earlier versions properly opening later save states. Includes some -// room for expansion so the state size shouldn't increase. -struct gb_apu_state_t -{ -#if GB_APU_CUSTOM_STATE - // Values stored as plain int so your code can read/write them easily. - // Structure can NOT be written to disk, since format is not portable. - typedef int val_t; -#else - // Values written in portable little-endian format, allowing structure - // to be written directly to disk. - typedef unsigned char val_t [4]; -#endif - - enum { format0 = 0x50414247 }; - - val_t format; // format of all following data - val_t version; // later versions just add fields to end - - unsigned char regs [0x40]; - val_t frame_time; - val_t frame_phase; - - val_t sweep_freq; - val_t sweep_delay; - val_t sweep_enabled; - val_t sweep_neg; - val_t noise_divider; - val_t wave_buf; - - val_t delay [4]; - val_t length_ctr [4]; - val_t phase [4]; - val_t enabled [4]; - - val_t env_delay [3]; - val_t env_volume [3]; - val_t env_enabled [3]; - - val_t unused [13]; // for future expansion -}; - -#endif diff --git a/libmednahawk/src/hw_sound/gb_apu/Gb_Apu_State.cpp b/libmednahawk/src/hw_sound/gb_apu/Gb_Apu_State.cpp deleted file mode 100644 index 9015f7f681..0000000000 --- a/libmednahawk/src/hw_sound/gb_apu/Gb_Apu_State.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Gb_Snd_Emu 0.2.0. http://www.slack.net/~ant/ - -#include "Gb_Apu.h" - -#include - -/* Copyright (C) 2007 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -#if GB_APU_CUSTOM_STATE - #define REFLECT( x, y ) (save ? (io->y) = (x) : (x) = (io->y) ) -#else - #define REFLECT( x, y ) (save ? set_val( io->y, x ) : (void) ((x) = get_val( io->y ))) - - static blargg_ulong get_val( byte const* p ) - { - return p [3] * 0x1000000 + p [2] * 0x10000 + p [1] * 0x100 + p [0]; - } - - static void set_val( byte* p, blargg_ulong n ) - { - p [0] = (byte) (n ); - p [1] = (byte) (n >> 8); - p [2] = (byte) (n >> 16); - p [3] = (byte) (n >> 24); - } -#endif - -inline const char* Gb_Apu::save_load( gb_apu_state_t* io, bool save ) -{ - #if !GB_APU_CUSTOM_STATE - assert( sizeof (gb_apu_state_t) == 256 ); - #endif - - int format = io->format0; - REFLECT( format, format ); - if ( format != io->format0 ) - return "Unsupported sound save state format"; - - int version = 0; - REFLECT( version, version ); - - // Registers and wave RAM - assert( regs_size == sizeof io->regs ); - if ( save ) - memcpy( io->regs, regs, sizeof io->regs ); - else - memcpy( regs, io->regs, sizeof regs ); - - // Frame sequencer - REFLECT( frame_time, frame_time ); - REFLECT( frame_phase, frame_phase ); - - REFLECT( square1.sweep_freq, sweep_freq ); - REFLECT( square1.sweep_delay, sweep_delay ); - REFLECT( square1.sweep_enabled, sweep_enabled ); - REFLECT( square1.sweep_neg, sweep_neg ); - - REFLECT( noise.divider, noise_divider ); - REFLECT( wave.sample_buf, wave_buf ); - - return 0; -} - -// second function to avoid inline limits of some compilers -inline void Gb_Apu::save_load2( gb_apu_state_t* io, bool save ) -{ - for ( int i = osc_count; --i >= 0; ) - { - Gb_Osc& osc = *oscs [i]; - REFLECT( osc.delay, delay [i] ); - REFLECT( osc.length_ctr, length_ctr [i] ); - REFLECT( osc.phase, phase [i] ); - REFLECT( osc.enabled, enabled [i] ); - - if ( i != 2 ) - { - int j = min( i, 2 ); - Gb_Env& env = STATIC_CAST(Gb_Env&,osc); - REFLECT( env.env_delay, env_delay [j] ); - REFLECT( env.volume, env_volume [j] ); - REFLECT( env.env_enabled, env_enabled [j] ); - } - } -} - -void Gb_Apu::save_state( gb_apu_state_t* out ) -{ - (void) save_load( out, true ); - save_load2( out, true ); - - #if !GB_APU_CUSTOM_STATE - memset( out->unused, 0, sizeof out->unused ); - #endif -} - -blargg_err_t Gb_Apu::load_state( gb_apu_state_t const& in ) -{ - RETURN_ERR( save_load( CONST_CAST(gb_apu_state_t*,&in), false ) ); - save_load2( CONST_CAST(gb_apu_state_t*,&in), false ); - - apply_stereo(); - synth_volume( 0 ); // suppress output for the moment - run_until_( last_time ); // get last_amp updated - apply_volume(); // now use correct volume - - return 0; -} diff --git a/libmednahawk/src/hw_sound/gb_apu/Gb_Oscs.cpp b/libmednahawk/src/hw_sound/gb_apu/Gb_Oscs.cpp deleted file mode 100644 index 12315e08a0..0000000000 --- a/libmednahawk/src/hw_sound/gb_apu/Gb_Oscs.cpp +++ /dev/null @@ -1,665 +0,0 @@ -// Gb_Snd_Emu 0.2.0. http://www.slack.net/~ant/ - -#include "Gb_Apu.h" - -/* Copyright (C) 2003-2007 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -#include "blargg_source.h" - -bool const cgb_02 = false; // enables bug in early CGB units that causes problems in some games -bool const cgb_05 = false; // enables CGB-05 zombie behavior - -int const trigger_mask = 0x80; -int const length_enabled = 0x40; - -void Gb_Osc::reset() -{ - output = 0; - last_amp = 0; - delay = 0; - phase = 0; - enabled = false; -} - -inline void Gb_Osc::update_amp( blip_time_t time, int new_amp ) -{ - output->set_modified(); - int delta = new_amp - last_amp; - if ( delta ) - { - last_amp = new_amp; - med_synth->offset( time, delta, output ); - } -} - -// Units - -void Gb_Osc::clock_length() -{ - if ( (regs [4] & length_enabled) && length_ctr ) - { - if ( --length_ctr <= 0 ) - enabled = false; - } -} - -inline int Gb_Env::reload_env_timer() -{ - int raw = regs [2] & 7; - env_delay = (raw ? raw : 8); - return raw; -} - -void Gb_Env::clock_envelope() -{ - if ( env_enabled && --env_delay <= 0 && reload_env_timer() ) - { - int v = volume + (regs [2] & 0x08 ? +1 : -1); - if ( 0 <= v && v <= 15 ) - volume = v; - else - env_enabled = false; - } -} - -inline void Gb_Sweep_Square::reload_sweep_timer() -{ - sweep_delay = (regs [0] & period_mask) >> 4; - if ( !sweep_delay ) - sweep_delay = 8; -} - -void Gb_Sweep_Square::calc_sweep( bool update ) -{ - int const shift = regs [0] & shift_mask; - int const delta = sweep_freq >> shift; - sweep_neg = (regs [0] & 0x08) != 0; - int const freq = sweep_freq + (sweep_neg ? -delta : delta); - - if ( freq > 0x7FF ) - { - enabled = false; - } - else if ( shift && update ) - { - sweep_freq = freq; - - regs [3] = freq & 0xFF; - regs [4] = (regs [4] & ~0x07) | (freq >> 8 & 0x07); - } -} - -void Gb_Sweep_Square::clock_sweep() -{ - if ( --sweep_delay <= 0 ) - { - reload_sweep_timer(); - if ( sweep_enabled && (regs [0] & period_mask) ) - { - calc_sweep( true ); - calc_sweep( false ); - } - } -} - -int Gb_Wave::access( unsigned addr ) const -{ - if ( enabled ) - { - addr = phase & (bank_size - 1); - if ( mode == Gb_Apu::mode_dmg ) - { - addr++; - if ( delay > clk_mul ) - return -1; // can only access within narrow time window while playing - } - addr >>= 1; - } - return addr & 0x0F; -} - -// write_register - -int Gb_Osc::write_trig( int frame_phase, int max_len, int old_data ) -{ - int data = regs [4]; - - if ( (frame_phase & 1) && !(old_data & length_enabled) && length_ctr ) - { - if ( (data & length_enabled) || cgb_02 ) - length_ctr--; - } - - if ( data & trigger_mask ) - { - enabled = true; - if ( !length_ctr ) - { - length_ctr = max_len; - if ( (frame_phase & 1) && (data & length_enabled) ) - length_ctr--; - } - } - - if ( !length_ctr ) - enabled = false; - - return data & trigger_mask; -} - -inline void Gb_Env::zombie_volume( int old, int data ) -{ - int v = volume; - if ( mode == Gb_Apu::mode_agb || cgb_05 ) - { - // CGB-05 behavior, very close to AGB behavior as well - if ( (old ^ data) & 8 ) - { - if ( !(old & 8) ) - { - v++; - if ( old & 7 ) - v++; - } - - v = 16 - v; - } - else if ( (old & 0x0F) == 8 ) - { - v++; - } - } - else - { - // CGB-04&02 behavior, very close to MGB behavior as well - if ( !(old & 7) && env_enabled ) - v++; - else if ( !(old & 8) ) - v += 2; - - if ( (old ^ data) & 8 ) - v = 16 - v; - } - volume = v & 0x0F; -} - -bool Gb_Env::write_register( int frame_phase, int reg, int old, int data ) -{ - int const max_len = 64; - - switch ( reg ) - { - case 1: - length_ctr = max_len - (data & (max_len - 1)); - break; - - case 2: - if ( !dac_enabled() ) - enabled = false; - - zombie_volume( old, data ); - - if ( (data & 7) && env_delay == 8 ) - { - env_delay = 1; - clock_envelope(); // TODO: really happens at next length clock - } - break; - - case 4: - if ( write_trig( frame_phase, max_len, old ) ) - { - volume = regs [2] >> 4; - reload_env_timer(); - env_enabled = true; - if ( frame_phase == 7 ) - env_delay++; - if ( !dac_enabled() ) - enabled = false; - return true; - } - } - return false; -} - -bool Gb_Square::write_register( int frame_phase, int reg, int old_data, int data ) -{ - bool result = Gb_Env::write_register( frame_phase, reg, old_data, data ); - if ( result ) - delay = (delay & (4 * clk_mul - 1)) + period(); - return result; -} - -inline void Gb_Noise::write_register( int frame_phase, int reg, int old_data, int data ) -{ - if ( Gb_Env::write_register( frame_phase, reg, old_data, data ) ) - { - phase = 0x7FFF; - delay += 8 * clk_mul; - } -} - -inline void Gb_Sweep_Square::write_register( int frame_phase, int reg, int old_data, int data ) -{ - if ( reg == 0 && sweep_enabled && sweep_neg && !(data & 0x08) ) - enabled = false; // sweep negate disabled after used - - if ( Gb_Square::write_register( frame_phase, reg, old_data, data ) ) - { - sweep_freq = frequency(); - sweep_neg = false; - reload_sweep_timer(); - sweep_enabled = (regs [0] & (period_mask | shift_mask)) != 0; - if ( regs [0] & shift_mask ) - calc_sweep( false ); - } -} - -void Gb_Wave::corrupt_wave() -{ - int pos = ((phase + 1) & (bank_size - 1)) >> 1; - if ( pos < 4 ) - wave_ram [0] = wave_ram [pos]; - else - for ( int i = 4; --i >= 0; ) - wave_ram [i] = wave_ram [(pos & ~3) + i]; -} - -inline void Gb_Wave::write_register( int frame_phase, int reg, int old_data, int data ) -{ - int const max_len = 256; - - switch ( reg ) - { - case 0: - if ( !dac_enabled() ) - enabled = false; - break; - - case 1: - length_ctr = max_len - data; - break; - - case 4: - bool was_enabled = enabled; - if ( write_trig( frame_phase, max_len, old_data ) ) - { - if ( !dac_enabled() ) - enabled = false; - else if ( mode == Gb_Apu::mode_dmg && was_enabled && - (unsigned) (delay - 2 * clk_mul) < 2 * clk_mul ) - corrupt_wave(); - - phase = 0; - delay = period() + 6 * clk_mul; - } - } -} - -void Gb_Apu::write_osc( int index, int reg, int old_data, int data ) -{ - reg -= index * 5; - switch ( index ) - { - case 0: square1.write_register( frame_phase, reg, old_data, data ); break; - case 1: square2.write_register( frame_phase, reg, old_data, data ); break; - case 2: wave .write_register( frame_phase, reg, old_data, data ); break; - case 3: noise .write_register( frame_phase, reg, old_data, data ); break; - } -} - -// Synthesis - -void Gb_Square::run( blip_time_t time, blip_time_t end_time ) -{ - // Calc duty and phase - static byte const duty_offsets [4] = { 1, 1, 3, 7 }; - static byte const duties [4] = { 1, 2, 4, 6 }; - int const duty_code = regs [1] >> 6; - int duty_offset = duty_offsets [duty_code]; - int duty = duties [duty_code]; - if ( mode == Gb_Apu::mode_agb ) - { - // AGB uses inverted duty - duty_offset -= duty; - duty = 8 - duty; - } - int ph = (this->phase + duty_offset) & 7; - - // Determine what will be generated - int vol = 0; - Blip_Buffer* const out = this->output; - if ( out ) - { - int amp = dac_off_amp; - if ( dac_enabled() ) - { - if ( enabled ) - vol = this->volume; - - amp = -dac_bias; - if ( mode == Gb_Apu::mode_agb ) - amp = -(vol >> 1); - - // Play inaudible frequencies as constant amplitude - if ( frequency() >= 0x7FA && delay < 32 * clk_mul ) - { - amp += (vol * duty) >> 3; - vol = 0; - } - - if ( ph < duty ) - { - amp += vol; - vol = -vol; - } - } - update_amp( time, amp ); - } - - // Generate wave - time += delay; - if ( time < end_time ) - { - int const per = this->period(); - if ( !vol ) - { - // Maintain phase when not playing - int count = (end_time - time + per - 1) / per; - ph += count; // will be masked below - time += (blip_time_t) count * per; - } - else - { - // Output amplitude transitions - int delta = vol; - do - { - ph = (ph + 1) & 7; - if ( ph == 0 || ph == duty ) - { - good_synth->offset_inline( time, delta, out ); - delta = -delta; - } - time += per; - } - while ( time < end_time ); - - if ( delta != vol ) - last_amp -= delta; - } - this->phase = (ph - duty_offset) & 7; - } - delay = time - end_time; -} - -// Quickly runs LFSR for a large number of clocks. For use when noise is generating -// no sound. -static unsigned run_lfsr( unsigned s, unsigned mask, int count ) -{ - bool const optimized = true; // set to false to use only unoptimized loop in middle - - // optimization used in several places: - // ((s & (1 << b)) << n) ^ ((s & (1 << b)) << (n + 1)) = (s & (1 << b)) * (3 << n) - - if ( mask == 0x4000 && optimized ) - { - if ( count >= 32767 ) - count %= 32767; - - // Convert from Fibonacci to Galois configuration, - // shifted left 1 bit - s ^= (s & 1) * 0x8000; - - // Each iteration is equivalent to clocking LFSR 255 times - while ( (count -= 255) > 0 ) - s ^= ((s & 0xE) << 12) ^ ((s & 0xE) << 11) ^ (s >> 3); - count += 255; - - // Each iteration is equivalent to clocking LFSR 15 times - // (interesting similarity to single clocking below) - while ( (count -= 15) > 0 ) - s ^= ((s & 2) * (3 << 13)) ^ (s >> 1); - count += 15; - - // Remaining singles - while ( --count >= 0 ) - s = ((s & 2) * (3 << 13)) ^ (s >> 1); - - // Convert back to Fibonacci configuration - s &= 0x7FFF; - } - else if ( count < 8 || !optimized ) - { - // won't fully replace upper 8 bits, so have to do the unoptimized way - while ( --count >= 0 ) - s = (s >> 1 | mask) ^ (mask & -((s - 1) & 2)); - } - else - { - if ( count > 127 ) - { - count %= 127; - if ( !count ) - count = 127; // must run at least once - } - - // Need to keep one extra bit of history - s = s << 1 & 0xFF; - - // Convert from Fibonacci to Galois configuration, - // shifted left 2 bits - s ^= (s & 2) * 0x80; - - // Each iteration is equivalent to clocking LFSR 7 times - // (interesting similarity to single clocking below) - while ( (count -= 7) > 0 ) - s ^= ((s & 4) * (3 << 5)) ^ (s >> 1); - count += 7; - - // Remaining singles - while ( --count >= 0 ) - s = ((s & 4) * (3 << 5)) ^ (s >> 1); - - // Convert back to Fibonacci configuration and - // repeat last 8 bits above significant 7 - s = (s << 7 & 0x7F80) | (s >> 1 & 0x7F); - } - - return s; -} - -void Gb_Noise::run( blip_time_t time, blip_time_t end_time ) -{ - // Determine what will be generated - int vol = 0; - Blip_Buffer* const out = this->output; - if ( out ) - { - int amp = dac_off_amp; - if ( dac_enabled() ) - { - if ( enabled ) - vol = this->volume; - - amp = -dac_bias; - if ( mode == Gb_Apu::mode_agb ) - amp = -(vol >> 1); - - if ( !(phase & 1) ) - { - amp += vol; - vol = -vol; - } - } - - // AGB negates final output - if ( mode == Gb_Apu::mode_agb ) - { - vol = -vol; - amp = -amp; - } - - update_amp( time, amp ); - } - - // Run timer and calculate time of next LFSR clock - static byte const period1s [8] = { 1, 2, 4, 6, 8, 10, 12, 14 }; - int const period1 = period1s [regs [3] & 7] * clk_mul; - { - int extra = (end_time - time) - delay; - int const per2 = this->period2(); - time += delay + ((divider ^ (per2 >> 1)) & (per2 - 1)) * period1; - - int count = (extra < 0 ? 0 : (extra + period1 - 1) / period1); - divider = (divider - count) & period2_mask; - delay = count * period1 - extra; - } - - // Generate wave - if ( time < end_time ) - { - unsigned const mask = this->lfsr_mask(); - unsigned bits = this->phase; - - int per = period2( period1 * 8 ); - if ( period2_index() >= 0xE ) - { - time = end_time; - } - else if ( !vol ) - { - // Maintain phase when not playing - int count = (end_time - time + per - 1) / per; - time += (blip_time_t) count * per; - bits = run_lfsr( bits, ~mask, count ); - } - else - { - // Output amplitude transitions - int delta = -vol; - do - { - unsigned changed = bits + 1; - bits = bits >> 1 & mask; - if ( changed & 2 ) - { - bits |= ~mask; - delta = -delta; - med_synth->offset_inline( time, delta, out ); - } - time += per; - } - while ( time < end_time ); - - if ( delta == vol ) - last_amp += delta; - } - this->phase = bits; - } -} - -void Gb_Wave::run( blip_time_t time, blip_time_t end_time ) -{ - // Calc volume - static byte const volumes [8] = { 0, 4, 2, 1, 3, 3, 3, 3 }; - int const volume_shift = 2; - int const volume_idx = regs [2] >> 5 & (agb_mask | 3); // 2 bits on DMG/CGB, 3 on AGB - int const volume_mul = volumes [volume_idx]; - - // Determine what will be generated - int playing = false; - Blip_Buffer* const out = this->output; - if ( out ) - { - int amp = dac_off_amp; - if ( dac_enabled() ) - { - // Play inaudible frequencies as constant amplitude - amp = 8 << 4; // really depends on average of all samples in wave - - // if delay is larger, constant amplitude won't start yet - if ( frequency() <= 0x7FB || delay > 15 * clk_mul ) - { - if ( volume_mul ) - playing = (int) enabled; - - amp = (sample_buf << (phase << 2 & 4) & 0xF0) * playing; - } - - amp = ((amp * volume_mul) >> (volume_shift + 4)) - dac_bias; - } - update_amp( time, amp ); - } - - // Generate wave - time += delay; - if ( time < end_time ) - { - byte const* wave = this->wave_ram; - - // wave size and bank - int const size20_mask = 0x20; - int const flags = regs [0] & agb_mask; - int const wave_mask = (flags & size20_mask) | 0x1F; - int swap_banks = 0; - if ( flags & bank40_mask ) - { - swap_banks = flags & size20_mask; - wave += bank_size/2 - (swap_banks >> 1); - } - - int ph = this->phase ^ swap_banks; - ph = (ph + 1) & wave_mask; // pre-advance - - int const per = this->period(); - if ( !playing ) - { - // Maintain phase when not playing - int count = (end_time - time + per - 1) / per; - ph += count; // will be masked below - time += (blip_time_t) count * per; - } - else - { - // Output amplitude transitions - int lamp = this->last_amp + dac_bias; - do - { - // Extract nybble - int nybble = wave [ph >> 1] << (ph << 2 & 4) & 0xF0; - ph = (ph + 1) & wave_mask; - - // Scale by volume - int amp = (nybble * volume_mul) >> (volume_shift + 4); - - int delta = amp - lamp; - if ( delta ) - { - lamp = amp; - med_synth->offset_inline( time, delta, out ); - } - time += per; - } - while ( time < end_time ); - this->last_amp = lamp - dac_bias; - } - ph = (ph - 1) & wave_mask; // undo pre-advance and mask position - - // Keep track of last byte read - if ( enabled ) - sample_buf = wave [ph >> 1]; - - this->phase = ph ^ swap_banks; // undo swapped banks - } - delay = time - end_time; -} diff --git a/libmednahawk/src/hw_sound/gb_apu/Gb_Oscs.h b/libmednahawk/src/hw_sound/gb_apu/Gb_Oscs.h deleted file mode 100644 index 03916d968e..0000000000 --- a/libmednahawk/src/hw_sound/gb_apu/Gb_Oscs.h +++ /dev/null @@ -1,190 +0,0 @@ -// Private oscillators used by Gb_Apu - -// Gb_Snd_Emu 0.2.0 -#ifndef GB_OSCS_H -#define GB_OSCS_H - -#include "blargg_common.h" -#include "Blip_Buffer.h" - -#ifndef GB_APU_OVERCLOCK - #define GB_APU_OVERCLOCK 1 -#endif - -#if GB_APU_OVERCLOCK & (GB_APU_OVERCLOCK - 1) - #error "GB_APU_OVERCLOCK must be a power of 2" -#endif - -class Gb_Osc { -protected: - - // 11-bit frequency in NRx3 and NRx4 - int frequency() const { return (regs [4] & 7) * 0x100 + regs [3]; } - - void update_amp( blip_time_t, int new_amp ); - int write_trig( int frame_phase, int max_len, int old_data ); -public: - - enum { clk_mul = GB_APU_OVERCLOCK }; - enum { dac_bias = 7 }; - - Blip_Buffer* outputs [4];// NULL, right, left, center - Blip_Buffer* output; // where to output sound - BOOST::uint8_t* regs; // osc's 5 registers - int mode; // mode_dmg, mode_cgb, mode_agb - int dac_off_amp;// amplitude when DAC is off - int last_amp; // current amplitude in Blip_Buffer - typedef Blip_Synth Good_Synth; - typedef Blip_Synth Med_Synth; - Good_Synth const* good_synth; - Med_Synth const* med_synth; - - int delay; // clocks until frequency timer expires - int length_ctr; // length counter - unsigned phase; // waveform phase (or equivalent) - bool enabled; // internal enabled flag - - void clock_length(); - void reset(); -}; - -class Gb_Env : public Gb_Osc { -public: - int env_delay; - int volume; - bool env_enabled; - - void clock_envelope(); - bool write_register( int frame_phase, int reg, int old_data, int data ); - - void reset() - { - env_delay = 0; - volume = 0; - Gb_Osc::reset(); - } -protected: - // Non-zero if DAC is enabled - int dac_enabled() const { return regs [2] & 0xF8; } -private: - void zombie_volume( int old, int data ); - int reload_env_timer(); -}; - -class Gb_Square : public Gb_Env { -public: - bool write_register( int frame_phase, int reg, int old_data, int data ); - void run( blip_time_t, blip_time_t ); - - void reset() - { - Gb_Env::reset(); - delay = 0x40000000; // TODO: something less hacky (never clocked until first trigger) - } -private: - // Frequency timer period - int period() const { return (2048 - frequency()) * (4 * clk_mul); } -}; - -class Gb_Sweep_Square : public Gb_Square { -public: - int sweep_freq; - int sweep_delay; - bool sweep_enabled; - bool sweep_neg; - - void clock_sweep(); - void write_register( int frame_phase, int reg, int old_data, int data ); - - void reset() - { - sweep_freq = 0; - sweep_delay = 0; - sweep_enabled = false; - sweep_neg = false; - Gb_Square::reset(); - } -private: - enum { period_mask = 0x70 }; - enum { shift_mask = 0x07 }; - - void calc_sweep( bool update ); - void reload_sweep_timer(); -}; - -class Gb_Noise : public Gb_Env { -public: - - int divider; // noise has more complex frequency divider setup - - void run( blip_time_t, blip_time_t ); - void write_register( int frame_phase, int reg, int old_data, int data ); - - void reset() - { - divider = 0; - Gb_Env::reset(); - delay = 4 * clk_mul; // TODO: remove? - } -private: - enum { period2_mask = 0x1FFFF }; - - int period2_index() const { return regs [3] >> 4; } - int period2( int base = 8 ) const { return base << period2_index(); } - unsigned lfsr_mask() const { return (regs [3] & 0x08) ? ~0x4040 : ~0x4000; } -}; - -class Gb_Wave : public Gb_Osc { -public: - int sample_buf; // last wave RAM byte read (hardware has this as well) - - void write_register( int frame_phase, int reg, int old_data, int data ); - void run( blip_time_t, blip_time_t ); - - // Reads/writes wave RAM - int read( unsigned addr ) const; - void write( unsigned addr, int data ); - - void reset() - { - sample_buf = 0; - Gb_Osc::reset(); - } - -private: - enum { bank40_mask = 0x40 }; - enum { bank_size = 32 }; - - int agb_mask; // 0xFF if AGB features enabled, 0 otherwise - BOOST::uint8_t* wave_ram; // 32 bytes (64 nybbles), stored in APU - - friend class Gb_Apu; - - // Frequency timer period - int period() const { return (2048 - frequency()) * (2 * clk_mul); } - - // Non-zero if DAC is enabled - int dac_enabled() const { return regs [0] & 0x80; } - - void corrupt_wave(); - - BOOST::uint8_t* wave_bank() const { return &wave_ram [(~regs [0] & bank40_mask) >> 2 & agb_mask]; } - - // Wave index that would be accessed, or -1 if no access would occur - int access( unsigned addr ) const; -}; - -inline int Gb_Wave::read( unsigned addr ) const -{ - int index = access( addr ); - return (index < 0 ? 0xFF : wave_bank() [index]); -} - -inline void Gb_Wave::write( unsigned addr, int data ) -{ - int index = access( addr ); - if ( index >= 0 ) - wave_bank() [index] = data;; -} - -#endif diff --git a/libmednahawk/src/hw_sound/gb_apu/blargg_common.h b/libmednahawk/src/hw_sound/gb_apu/blargg_common.h deleted file mode 100644 index 0638918b55..0000000000 --- a/libmednahawk/src/hw_sound/gb_apu/blargg_common.h +++ /dev/null @@ -1,206 +0,0 @@ -// Sets up common environment for Shay Green's libraries. -// To change configuration options, modify blargg_config.h, not this file. - -// Gb_Snd_Emu 0.2.0 -#ifndef BLARGG_COMMON_H -#define BLARGG_COMMON_H - -#include -#include -#include -#include - -#undef BLARGG_COMMON_H -// allow blargg_config.h to #include blargg_common.h -#include "blargg_config.h" -#ifndef BLARGG_COMMON_H -#define BLARGG_COMMON_H - -// BLARGG_RESTRICT: equivalent to restrict, where supported -#if __GNUC__ >= 3 || _MSC_VER >= 1100 - #define BLARGG_RESTRICT __restrict -#else - #define BLARGG_RESTRICT -#endif - -// STATIC_CAST(T,expr): Used in place of static_cast (expr) -// CONST_CAST( T,expr): Used in place of const_cast (expr) -#ifndef STATIC_CAST - #if __GNUC__ >= 4 - #define STATIC_CAST(T,expr) static_cast (expr) - #define CONST_CAST( T,expr) const_cast (expr) - #else - #define STATIC_CAST(T,expr) ((T) (expr)) - #define CONST_CAST( T,expr) ((T) (expr)) - #endif -#endif - -// blargg_err_t (0 on success, otherwise error string) -#ifndef blargg_err_t - typedef const char* blargg_err_t; -#endif - -// blargg_vector - very lightweight vector of POD types (no constructor/destructor) -template -class blargg_vector { - T* begin_; - size_t size_; -public: - blargg_vector() : begin_( 0 ), size_( 0 ) { } - ~blargg_vector() { free( begin_ ); } - size_t size() const { return size_; } - T* begin() const { return begin_; } - T* end() const { return begin_ + size_; } - blargg_err_t resize( size_t n ) - { - // TODO: blargg_common.cpp to hold this as an outline function, ugh - void* p = realloc( begin_, n * sizeof (T) ); - if ( p ) - begin_ = (T*) p; - else if ( n > size_ ) // realloc failure only a problem if expanding - return "Out of memory"; - size_ = n; - return 0; - } - void clear() { void* p = begin_; begin_ = 0; size_ = 0; free( p ); } - T& operator [] ( size_t n ) const - { - assert( n <= size_ ); // <= to allow past-the-end value - return begin_ [n]; - } -}; - -#ifndef BLARGG_DISABLE_NOTHROW - // throw spec mandatory in ISO C++ if operator new can return NULL - #if __cplusplus >= 199711 || __GNUC__ >= 3 - #define BLARGG_THROWS( spec ) throw spec - #else - #define BLARGG_THROWS( spec ) - #endif - #define BLARGG_DISABLE_NOTHROW \ - void* operator new ( size_t s ) BLARGG_THROWS(()) { return malloc( s ); }\ - void operator delete ( void* p ) { free( p ); } - #define BLARGG_NEW new -#else - #include - #define BLARGG_NEW new (std::nothrow) -#endif - -// BLARGG_4CHAR('a','b','c','d') = 'abcd' (four character integer constant) -#define BLARGG_4CHAR( a, b, c, d ) \ - ((a&0xFF)*0x1000000 + (b&0xFF)*0x10000 + (c&0xFF)*0x100 + (d&0xFF)) - -// BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0. -#ifndef BOOST_STATIC_ASSERT - #ifdef _MSC_VER - // MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified - #define BOOST_STATIC_ASSERT( expr ) \ - void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] ) - #else - // Some other compilers fail when declaring same function multiple times in class, - // so differentiate them by line - #define BOOST_STATIC_ASSERT( expr ) \ - void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] ) - #endif -#endif - -// BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1, -// compiler is assumed to support bool. If undefined, availability is determined. -#ifndef BLARGG_COMPILER_HAS_BOOL - #if defined (__MWERKS__) - #if !__option(bool) - #define BLARGG_COMPILER_HAS_BOOL 0 - #endif - #elif defined (_MSC_VER) - #if _MSC_VER < 1100 - #define BLARGG_COMPILER_HAS_BOOL 0 - #endif - #elif defined (__GNUC__) - // supports bool - #elif __cplusplus < 199711 - #define BLARGG_COMPILER_HAS_BOOL 0 - #endif -#endif -#if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL - // If you get errors here, modify your blargg_config.h file - typedef int bool; - const bool true = 1; - const bool false = 0; -#endif - -// blargg_long/blargg_ulong = at least 32 bits, int if it's big enough - -#if INT_MAX < 0x7FFFFFFF || LONG_MAX == 0x7FFFFFFF - typedef long blargg_long; -#else - typedef int blargg_long; -#endif - -#if UINT_MAX < 0xFFFFFFFF || ULONG_MAX == 0xFFFFFFFF - typedef unsigned long blargg_ulong; -#else - typedef unsigned blargg_ulong; -#endif - -// BOOST::int8_t etc. - -// HAVE_STDINT_H: If defined, use for int8_t etc. -#if defined (HAVE_STDINT_H) - #include - #define BOOST - -// HAVE_INTTYPES_H: If defined, use for int8_t etc. -#elif defined (HAVE_INTTYPES_H) - #include - #define BOOST - -#else - struct BOOST - { - #if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F - typedef signed char int8_t; - typedef unsigned char uint8_t; - #else - // No suitable 8-bit type available - typedef struct see_blargg_common_h int8_t; - typedef struct see_blargg_common_h uint8_t; - #endif - - #if USHRT_MAX == 0xFFFF - typedef short int16_t; - typedef unsigned short uint16_t; - #else - // No suitable 16-bit type available - typedef struct see_blargg_common_h int16_t; - typedef struct see_blargg_common_h uint16_t; - #endif - - #if ULONG_MAX == 0xFFFFFFFF - typedef long int32_t; - typedef unsigned long uint32_t; - #elif UINT_MAX == 0xFFFFFFFF - typedef int int32_t; - typedef unsigned int uint32_t; - #else - // No suitable 32-bit type available - typedef struct see_blargg_common_h int32_t; - typedef struct see_blargg_common_h uint32_t; - #endif - }; -#endif - -#if __GNUC__ >= 3 - #define BLARGG_DEPRECATED __attribute__ ((deprecated)) -#else - #define BLARGG_DEPRECATED -#endif - -// Use in place of "= 0;" for a pure virtual, since these cause calls to std C++ lib. -// During development, BLARGG_PURE( x ) expands to = 0; -// virtual int func() BLARGG_PURE( { return 0; } ) -#ifndef BLARGG_PURE - #define BLARGG_PURE( def ) def -#endif - -#endif -#endif diff --git a/libmednahawk/src/hw_sound/gb_apu/blargg_config.h b/libmednahawk/src/hw_sound/gb_apu/blargg_config.h deleted file mode 100644 index ced1a7ce9c..0000000000 --- a/libmednahawk/src/hw_sound/gb_apu/blargg_config.h +++ /dev/null @@ -1,31 +0,0 @@ -// $package user configuration file. Don't replace when updating library. - -#ifndef BLARGG_CONFIG_H -#define BLARGG_CONFIG_H - -// Uncomment to have Gb_Apu run at 4x normal clock rate (16777216 Hz), useful in -// a Game Boy Advance emulator. -#define GB_APU_OVERCLOCK 4 - -// Uncomment to enable platform-specific (and possibly non-portable) optimizations. -//#define BLARGG_NONPORTABLE 1 - -// Uncomment if automatic byte-order determination doesn't work -//#define BLARGG_BIG_ENDIAN 1 - -// Uncomment to use zlib for transparent decompression of gzipped files -//#define HAVE_ZLIB_H - -// Uncomment if you get errors in the bool section of blargg_common.h -//#define BLARGG_COMPILER_HAS_BOOL 1 - -// Uncomment to disable out-of-memory exceptions -//#include -//#define BLARGG_NEW new (std::nothrow) - -// Use standard config.h if present -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#endif diff --git a/libmednahawk/src/hw_sound/gb_apu/blargg_source.h b/libmednahawk/src/hw_sound/gb_apu/blargg_source.h deleted file mode 100644 index 53c354aa79..0000000000 --- a/libmednahawk/src/hw_sound/gb_apu/blargg_source.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Included at the beginning of library source files, AFTER all other #include lines. -Sets up helpful macros and services used in my source code. Since this is only "active" -in my source code, I don't have to worry about polluting the global namespace with -unprefixed names. */ - -// Gb_Snd_Emu 0.2.0 -#ifndef BLARGG_SOURCE_H -#define BLARGG_SOURCE_H - -// The following four macros are for debugging only. Some or all might be defined -// to do nothing, depending on the circumstances. Described is what happens when -// a particular macro is defined to do something. When defined to do nothing, the -// macros do NOT evaluate their argument(s). - -// If expr is false, prints file and line number, then aborts program. Meant for -// checking internal state and consistency. A failed assertion indicates a bug -// in MY code. -// -// void assert( bool expr ); -#include - -// If expr is false, prints file and line number, then aborts program. Meant for -// checking caller-supplied parameters and operations that are outside the control -// of the module. A failed requirement probably indicates a bug in YOUR code. -// -// void require( bool expr ); -#undef require -#define require( expr ) assert( expr ) - -// Like printf() except output goes to debugging console/file. -// -// void dprintf( const char* format, ... ); -static inline void blargg_dprintf_( const char*, ... ) { } -#undef dprintf -#define dprintf (1) ? (void) 0 : blargg_dprintf_ - -// If expr is false, prints file and line number to debug console/log, then -// continues execution normally. Meant for flagging potential problems or things -// that should be looked into, but that aren't serious problems. -// -// void check( bool expr ); -#undef check -#define check( expr ) ((void) 0) - -// If expr yields non-NULL error string, returns it from current function, -// otherwise continues normally. -#undef RETURN_ERR -#define RETURN_ERR( expr ) do { \ - blargg_err_t blargg_return_err_ = (expr); \ - if ( blargg_return_err_ ) return blargg_return_err_; \ - } while ( 0 ) - -// If ptr is NULL, returns "Out of memory" error string, otherwise continues normally. -#undef CHECK_ALLOC -#define CHECK_ALLOC( ptr ) do { if ( (ptr) == 0 ) return "Out of memory"; } while ( 0 ) - -// The usual min/max functions for built-in types. -// -// template T min( T x, T y ) { return x < y ? x : y; } -// template T max( T x, T y ) { return x > y ? x : y; } -#define BLARGG_DEF_MIN_MAX( type ) \ - static inline type blargg_min( type x, type y ) { if ( y < x ) x = y; return x; }\ - static inline type blargg_max( type x, type y ) { if ( x < y ) x = y; return x; } - -BLARGG_DEF_MIN_MAX( int ) -BLARGG_DEF_MIN_MAX( unsigned ) -BLARGG_DEF_MIN_MAX( long ) -BLARGG_DEF_MIN_MAX( unsigned long ) -BLARGG_DEF_MIN_MAX( float ) -BLARGG_DEF_MIN_MAX( double ) - -#undef min -#define min blargg_min - -#undef max -#define max blargg_max - -// typedef unsigned char byte; -typedef unsigned char blargg_byte; -#undef byte -#define byte blargg_byte - -// deprecated -#define BLARGG_CHECK_ALLOC CHECK_ALLOC -#define BLARGG_RETURN_ERR RETURN_ERR - -// BLARGG_SOURCE_BEGIN: If defined, #included, allowing redefition of dprintf and check -#ifdef BLARGG_SOURCE_BEGIN - #include BLARGG_SOURCE_BEGIN -#endif - -#endif diff --git a/libmednahawk/src/hw_sound/pce_psg/pce_psg.cpp b/libmednahawk/src/hw_sound/pce_psg/pce_psg.cpp deleted file mode 100644 index 7a1b15804d..0000000000 --- a/libmednahawk/src/hw_sound/pce_psg/pce_psg.cpp +++ /dev/null @@ -1,909 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mednafen/mednafen.h" -#include "pce_psg.h" - -#include -#include -#include - -void PCE_PSG::SetVolume(double new_volume) -{ - OutputVolume = new_volume; - - Synth.volume(OutputVolume / 6); -} - -// Note: Changing the 0x1F(not that there should be) would require changing the channel pseudo-off volume check logic later on. -static const int scale_tab[] = -{ - 0x00, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, - 0x10, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F -}; - -#define CLOCK_LFSR(lfsr) { unsigned int newbit = ((lfsr >> 0) ^ (lfsr >> 1) ^ (lfsr >> 11) ^ (lfsr >> 12) ^ (lfsr >> 17)) & 1; lfsr = (lfsr >> 1) | (newbit << 17); } - -void PCE_PSG::UpdateOutput_Norm(const int32 timestamp, psg_channel *ch) -{ - int32 samp[2]; - int sv = ch->dda; - - samp[0] = dbtable[ch->vl[0]][sv]; - samp[1] = dbtable[ch->vl[1]][sv]; - - Synth.offset(timestamp, samp[0] - ch->blip_prev_samp[0], sbuf[0]); - Synth.offset(timestamp, samp[1] - ch->blip_prev_samp[1], sbuf[1]); - - ch->blip_prev_samp[0] = samp[0]; - ch->blip_prev_samp[1] = samp[1]; -} - -void PCE_PSG::UpdateOutput_Noise(const int32 timestamp, psg_channel *ch) -{ - int32 samp[2]; - int sv = ((ch->lfsr & 1) << 5) - (ch->lfsr & 1); //(ch->lfsr & 0x1) ? 0x1F : 0; - - samp[0] = dbtable[ch->vl[0]][sv]; - samp[1] = dbtable[ch->vl[1]][sv]; - - Synth.offset(timestamp, samp[0] - ch->blip_prev_samp[0], sbuf[0]); - Synth.offset(timestamp, samp[1] - ch->blip_prev_samp[1], sbuf[1]); - - ch->blip_prev_samp[0] = samp[0]; - ch->blip_prev_samp[1] = samp[1]; -} - -void PCE_PSG::UpdateOutput_Off(const int32 timestamp, psg_channel *ch) -{ - int32 samp[2]; - - samp[0] = samp[1] = 0; - - Synth.offset_inline(timestamp, samp[0] - ch->blip_prev_samp[0], sbuf[0]); - Synth.offset_inline(timestamp, samp[1] - ch->blip_prev_samp[1], sbuf[1]); - - ch->blip_prev_samp[0] = samp[0]; - ch->blip_prev_samp[1] = samp[1]; -} - - -void PCE_PSG::UpdateOutput_Accum(const int32 timestamp, psg_channel *ch) -{ - int32 samp[2]; - - samp[0] = ((int32)dbtable_volonly[ch->vl[0]] * ((int32)ch->samp_accum - 496)) >> (8 + 5); - samp[1] = ((int32)dbtable_volonly[ch->vl[1]] * ((int32)ch->samp_accum - 496)) >> (8 + 5); - - Synth.offset_inline(timestamp, samp[0] - ch->blip_prev_samp[0], sbuf[0]); - Synth.offset_inline(timestamp, samp[1] - ch->blip_prev_samp[1], sbuf[1]); - - ch->blip_prev_samp[0] = samp[0]; - ch->blip_prev_samp[1] = samp[1]; -} - -// This function should always be called after RecalcFreqCache() (it's not called from RecalcFreqCache to avoid redundant code) -void PCE_PSG::RecalcUOFunc(int chnum) -{ - psg_channel *ch = &channel[chnum]; - - //printf("UO Update: %d, %02x\n", chnum, ch->control); - - if((revision != REVISION_HUC6280 && !(ch->control & 0xC0)) || (revision == REVISION_HUC6280 && !(ch->control & 0x80))) - ch->UpdateOutput = &PCE_PSG::UpdateOutput_Off; - else if(ch->noisectrl & ch->control & 0x80) - ch->UpdateOutput = &PCE_PSG::UpdateOutput_Noise; - // If the control for the channel is in waveform play mode, and the (real) playback frequency is too high, and the channel is either not the LFO modulator channel or - // if the LFO trigger bit(which halts the LFO modulator channel's waveform incrementing when set) is clear - else if((ch->control & 0xC0) == 0x80 && ch->freq_cache <= 0xA && (chnum != 1 || !(lfoctrl & 0x80)) ) - ch->UpdateOutput = &PCE_PSG::UpdateOutput_Accum; - else - ch->UpdateOutput = &PCE_PSG::UpdateOutput_Norm; -} - - -void PCE_PSG::RecalcFreqCache(int chnum) -{ - psg_channel *ch = &channel[chnum]; - - if(chnum == 0 && (lfoctrl & 0x03)) - { - const uint32 shift = (((lfoctrl & 0x3) - 1) << 1); - uint8 la = channel[1].dda; - int32 tmp_freq = ((int32)ch->frequency + ((la - 0x10) << shift)) & 0xFFF; - - ch->freq_cache = (tmp_freq ? tmp_freq : 4096) << 1; - } - else - { - ch->freq_cache = (ch->frequency ? ch->frequency : 4096) << 1; - - if(chnum == 1 && (lfoctrl & 0x03)) - ch->freq_cache *= lfofreq ? lfofreq : 256; - } -} - -void PCE_PSG::RecalcNoiseFreqCache(int chnum) -{ - psg_channel *ch = &channel[chnum]; - int32 freq = 0x1F - (ch->noisectrl & 0x1F); - - if(!freq) - freq = 0x20; - else - freq <<= 6; - - freq <<= 1; - - ch->noise_freq_cache = freq; -} - -void PCE_PSG::PeekWave(const unsigned int ch, uint32 Address, uint32 Length, uint8 *Buffer) -{ - assert(ch <= 5); - - while(Length--) - { - Address &= 0x1F; - *Buffer = channel[ch].waveform[Address]; - Address++; - Buffer++; - } -} - -void PCE_PSG::PokeWave(const unsigned int ch, uint32 Address, uint32 Length, const uint8 *Buffer) -{ - assert(ch <= 5); - - while(Length--) - { - Address &= 0x1F; - channel[ch].samp_accum -= channel[ch].waveform[Address]; - channel[ch].waveform[Address] = *Buffer & 0x1F; - channel[ch].samp_accum += channel[ch].waveform[Address]; - Address++; - Buffer++; - } -} - -uint32 PCE_PSG::GetRegister(const unsigned int id, char *special, const uint32 special_len) -{ - uint32 value = 0xDEADBEEF; - const int ch = (id >> 8) & 0xF; - - switch(id & 0xF0FF) - { - default: break; - - case PSG_GSREG_SELECT: - value = select; - break; - - case PSG_GSREG_GBALANCE: - value = globalbalance; - break; - - case PSG_GSREG_LFOFREQ: - value = lfofreq; - break; - - case PSG_GSREG_LFOCTRL: - value = lfoctrl; - break; - - case PSG_GSREG_CH0_FREQ: - value = channel[ch].frequency; - break; - - case PSG_GSREG_CH0_CTRL: - value = channel[ch].control; - break; - - case PSG_GSREG_CH0_BALANCE: - value = channel[ch].balance; - break; - - case PSG_GSREG_CH0_WINDEX: - value = channel[ch].waveform_index; - break; - - case PSG_GSREG_CH0_SCACHE: - value = channel[ch].dda; - break; - - case PSG_GSREG_CH0_NCTRL: - value = channel[ch].noisectrl; - break; - - case PSG_GSREG_CH0_LFSR: - value = channel[ch].lfsr & 0x7FFF; - break; - } - return(value); -} - - -void PCE_PSG::SetRegister(const unsigned int id, const uint32 value) -{ - const int ch = (id >> 8) & 0xF; - - switch(id & 0xF0FF) - { - default: break; - - case PSG_GSREG_SELECT: - select = value & 0x07; - break; - - case PSG_GSREG_GBALANCE: - globalbalance = value & 0xFF; - break; - - case PSG_GSREG_LFOFREQ: - lfofreq = value & 0xFF; - break; - - case PSG_GSREG_LFOCTRL: - lfoctrl = value & 0x83; - RecalcFreqCache(0); - RecalcUOFunc(0); - RecalcFreqCache(1); - RecalcUOFunc(1); - break; - - case PSG_GSREG_CH0_FREQ: - channel[ch].frequency = value & 0xFFF; - RecalcFreqCache(ch); - RecalcUOFunc(ch); - break; - - case PSG_GSREG_CH0_CTRL: - channel[ch].control = value & 0xFF; - RecalcFreqCache(ch); - RecalcUOFunc(ch); - break; - - case PSG_GSREG_CH0_BALANCE: - channel[ch].balance = value & 0xFF; - break; - - case PSG_GSREG_CH0_WINDEX: - channel[ch].waveform_index = value & 0x1F; - break; - - case PSG_GSREG_CH0_SCACHE: - channel[ch].dda = value & 0x1F; - break; - - case PSG_GSREG_CH0_NCTRL: - channel[ch].noisectrl = value & 0xFF; - RecalcNoiseFreqCache(ch); - RecalcUOFunc(ch); - break; - - case PSG_GSREG_CH0_LFSR: - channel[ch].lfsr = value & 0x7FFF; - break; - } -} - - -#if 0 -void PSG_SetRegister(const unsigned int id, const uint32 value) -{ - - - if(name == "Select") - PSG_Write(0x00, V); - else if(name == "GBalance") - PSG_Write(0x01, V); - else if(name == "LFOFreq") - { - PSG_Write(0x08, V); - } - else if(name == "LFOCtrl") - PSG_Write(0x09, V); - else if(!strncmp(name.c_str(), "CH", 2)) - { - unsigned int psg_sel_save = select; - int ch = name[2] - '0'; - char moomoo[64]; - strncpy(moomoo, name.c_str() + 3, 63); - - PSG_Write(0x00, ch); - - if(!strcmp(moomoo, "Freq")) - { - PSG_Write(0x02, V); - PSG_Write(0x03, V >> 8); - } - else if(!strcmp(moomoo, "Ctrl")) - PSG_Write(0x04, V); - else if(!strcmp(moomoo, "Balance")) - PSG_Write(0x05, V); - else if(!strcmp(moomoo, "WIndex")) - psg.channel[ch].waveform_index = V & 0x1F; - else if(!strcmp(moomoo, "SCache")) - psg.channel[ch].dda = V & 0x1F; - else if(!strcmp(moomoo, "NCtrl") && ch < 4) - psg.channel[ch].noisectrl = V; - else if(!strcmp(moomoo, "LFSR") && ch < 4) - psg.channel[ch].lfsr = V & 0x3FFFF; - - PSG_Write(0x00, psg_sel_save); - } -} -#endif - -PCE_PSG::PCE_PSG(Blip_Buffer *bb_l, Blip_Buffer *bb_r, int want_revision) -{ - revision = want_revision; - - sbuf[0] = bb_l; - sbuf[1] = bb_r; - - SoundEnabled = (sbuf[0] && sbuf[1]); - - lastts = 0; - for(int ch = 0; ch < 6; ch++) - { - channel[ch].blip_prev_samp[0] = 0; - channel[ch].blip_prev_samp[1] = 0; - channel[ch].lastts = 0; - } - - SetVolume(1.0); - - for(int vl = 0; vl < 32; vl++) - { - double flub = 1; - - if(vl) - flub /= pow(2, (double)1 / 4 * vl); // ~1.5dB reduction per increment of vl - - if(vl == 0x1F) - flub = 0; - - for(int samp = 0; samp < 32; samp++) - { - int eff_samp; - - if(revision == REVISION_HUC6280) - eff_samp = samp * 2; - else - eff_samp = samp * 2 - 0x1F; - - dbtable[vl][samp] = (int32)(flub * eff_samp * 128); - dbtable_volonly[vl] = (int32)(flub * 65536); - } - } - - Power(0); -} - -PCE_PSG::~PCE_PSG() -{ - - -} - -int32 PCE_PSG::GetVL(const int chnum, const int lr) -{ - psg_channel *ch = &channel[chnum]; - - const int gbal = 0x1F - scale_tab[(globalbalance >> (lr ? 0 : 4)) & 0xF]; - const int bal = 0x1F - scale_tab[(ch->balance >> (lr ? 0 : 4)) & 0xF]; - const int al = 0x1F - (ch->control & 0x1F); - int vol_reduction; - - vol_reduction = gbal + bal + al; - - if(vol_reduction > 0x1F) - vol_reduction = 0x1F; - - return(vol_reduction); -} - -void PCE_PSG::Write(int32 timestamp, uint8 A, uint8 V) -{ - A &= 0x0F; - - if(A == 0x00) - { - select = (V & 0x07); - return; - } - - Update(timestamp); - - psg_channel *ch = &channel[select]; - - //if(A == 0x01 || select == 5) - // printf("Write Ch: %d %04x %02x, %d\n", select, A, V, timestamp); - - switch(A) - { - default: break; - - case 0x01: /* Global sound balance */ - globalbalance = V; - - if(REVISION_ENHANCED == revision) - { - for(int cht = 0; cht < 6; cht++) - for(int lr = 0; lr < 2; lr++) - channel[cht].vl[lr] = GetVL(cht, lr); - } - else - vol_pending = true; - break; - - case 0x02: /* Channel frequency (LSB) */ - if(select > 5) return; // no more than 6 channels, silly game. - - ch->frequency = (ch->frequency & 0x0F00) | V; - RecalcFreqCache(select); - RecalcUOFunc(select); - break; - - case 0x03: /* Channel frequency (MSB) */ - if(select > 5) return; // no more than 6 channels, silly game. - - ch->frequency = (ch->frequency & 0x00FF) | ((V & 0x0F) << 8); - RecalcFreqCache(select); - RecalcUOFunc(select); - break; - - case 0x04: /* Channel enable, DDA, volume */ - if(select > 5) return; // no more than 6 channels, silly game. - - if((ch->control & 0x40) && !(V & 0x40)) - { - ch->waveform_index = 0; - ch->dda = ch->waveform[ch->waveform_index]; - ch->counter = ch->freq_cache; - } - - if(!(ch->control & 0x80) && (V & 0x80)) - { - if(!(V & 0x40)) - { - ch->waveform_index = (ch->waveform_index + 1) & 0x1F; - ch->dda = ch->waveform[ch->waveform_index]; - } - } - - ch->control = V; - RecalcFreqCache(select); - RecalcUOFunc(select); - - if(REVISION_ENHANCED == revision) - { - ch->vl[0] = GetVL(select, 0); - ch->vl[1] = GetVL(select, 1); - } - else - vol_pending = true; - - break; - - case 0x05: /* Channel balance */ - if(select > 5) return; // no more than 6 channels, silly game. - ch->balance = V; - - if(REVISION_ENHANCED == revision) - { - ch->vl[0] = GetVL(select, 0); - ch->vl[1] = GetVL(select, 1); - } - else - vol_pending = true; - - break; - - case 0x06: /* Channel waveform data */ - if(select > 5) return; // no more than 6 channels, silly game. - V &= 0x1F; - - if(!(ch->control & 0x40)) - { - ch->samp_accum -= ch->waveform[ch->waveform_index]; - ch->waveform[ch->waveform_index] = V; - ch->samp_accum += ch->waveform[ch->waveform_index]; - } - - if((ch->control & 0xC0) == 0x00) - ch->waveform_index = ((ch->waveform_index + 1) & 0x1F); - - if(ch->control & 0x80) - { - // According to my tests(on SuperGrafx), writing to this channel - // will update the waveform value cache/latch regardless of DDA mode being enabled. - ch->dda = V; - - if(REVISION_ENHANCED == revision) - { - if(&PCE_PSG::UpdateOutput_Norm == ch->UpdateOutput) - UpdateOutput_Norm(timestamp, ch); - } - } - break; - - case 0x07: /* Noise enable and frequency */ - if(select > 5) return; // no more than 6 channels, silly game. - if(select >= 4) - { - ch->noisectrl = V; - RecalcNoiseFreqCache(select); - RecalcUOFunc(select); - } - break; - - case 0x08: /* LFO frequency */ - lfofreq = V & 0xFF; - //printf("LFO Freq: %02x\n", V); - break; - - case 0x09: /* LFO trigger and control */ - //printf("LFO Ctrl: %02x\n", V); - if(V & 0x80) - { - channel[1].waveform_index = 0; - channel[1].dda = channel[1].waveform[channel[1].waveform_index]; - channel[1].counter = channel[1].freq_cache; - } - lfoctrl = V; - RecalcFreqCache(0); - RecalcUOFunc(0); - RecalcFreqCache(1); - RecalcUOFunc(1); - break; - } -} - -// Don't use INLINE, which has always_inline in it, due to gcc's inability to cope with the type of recursion -// used in this function. -inline void PCE_PSG::RunChannel(int chc, int32 timestamp, const bool LFO_On) -{ - psg_channel *ch = &channel[chc]; - int32 running_timestamp = ch->lastts; - int32 run_time = timestamp - ch->lastts; - - ch->lastts = timestamp; - - if(!run_time) - return; - - //if(chc != 5) - // return; - - if(REVISION_ENHANCED != revision) - (this->*ch->UpdateOutput)(running_timestamp, ch); - - if(chc >= 4) - { - int32 freq = ch->noise_freq_cache; - - ch->noisecount -= run_time; - - if(&PCE_PSG::UpdateOutput_Noise == ch->UpdateOutput) - while(ch->noisecount <= 0) - { - CLOCK_LFSR(ch->lfsr); - UpdateOutput_Noise(timestamp + ch->noisecount, ch); - ch->noisecount += freq; - } - else - while(ch->noisecount <= 0) - { - CLOCK_LFSR(ch->lfsr); - ch->noisecount += freq; - } - } - - // D7 of control is 0, don't clock the counter at all. - // D7 of lfocontrol is 1(and chc == 1), don't clock the counter at all(not sure about this) - // In DDA mode, don't clock the counter. - // (Noise being enabled isn't handled here since AFAIK it doesn't disable clocking of the waveform portion, its sound just overrides the sound from - // the waveform portion when the noise enable bit is set, which is handled in our RecalcUOFunc). - if(!(ch->control & 0x80) || (chc == 1 && (lfoctrl & 0x80)) || (ch->control & 0x40)) - return; - - ch->counter -= run_time; - - if(!LFO_On && ch->freq_cache <= 0xA) - { - if(ch->counter <= 0) - { - const int32 inc_count = ((0 - ch->counter) / ch->freq_cache) + 1; - - ch->counter += inc_count * ch->freq_cache; - - ch->waveform_index = (ch->waveform_index + inc_count) & 0x1F; - ch->dda = ch->waveform[ch->waveform_index]; - } - } - - while(ch->counter <= 0) - { - ch->waveform_index = (ch->waveform_index + 1) & 0x1F; - ch->dda = ch->waveform[ch->waveform_index]; - - (this->*ch->UpdateOutput)(timestamp + ch->counter, ch); - - if(LFO_On) - { - RunChannel(1, timestamp + ch->counter, false); - RecalcFreqCache(0); - RecalcUOFunc(0); - - ch->counter += (ch->freq_cache <= 0xA) ? 0xA : ch->freq_cache; // Not particularly accurate, but faster. - } - else - ch->counter += ch->freq_cache; - } -} - -void PCE_PSG::UpdateSubLFO(int32 timestamp) -{ - for(int chc = 0; chc < 6; chc++) - RunChannel(chc, timestamp, chc == 0); -} - -void PCE_PSG::UpdateSubNonLFO(int32 timestamp) -{ - for(int chc = 0; chc < 6; chc++) - RunChannel(chc, timestamp, false); -} - -//static int32 last_read; -//static int32 last_apply; - -void PCE_PSG::Update(int32 timestamp) -{ - int32 run_time = timestamp - lastts; - - if(!SoundEnabled) - return; - - if(REVISION_ENHANCED != revision) - { - if(vol_pending && !vol_update_counter && !vol_update_which) - { - vol_update_counter = 1; - vol_pending = false; - } - } - - bool lfo_on = (bool)(lfoctrl & 0x03); - - if(lfo_on) - { - if(!(channel[1].control & 0x80) || (lfoctrl & 0x80)) - { - lfo_on = 0; - RecalcFreqCache(0); - RecalcUOFunc(0); - } - } - - int32 clocks = run_time; - int32 running_timestamp = lastts; - - while(clocks > 0) - { - int32 chunk_clocks = clocks; - - if(REVISION_ENHANCED != revision) - { - if(vol_update_counter > 0 && chunk_clocks > vol_update_counter) - chunk_clocks = vol_update_counter; - } - - running_timestamp += chunk_clocks; - clocks -= chunk_clocks; - - if(lfo_on) - UpdateSubLFO(running_timestamp); - else - UpdateSubNonLFO(running_timestamp); - - if(REVISION_ENHANCED != revision && vol_update_counter > 0) - { - vol_update_counter -= chunk_clocks; - if(!vol_update_counter) - { - const int phase = vol_update_which & 1; - const int lr = ((vol_update_which >> 1) & 1) ^ 1; - const int chnum = vol_update_which >> 2; - - if(!phase) - { - //printf("Volume update(Read, %d since last): ch=%d, lr=%d, ts=%d\n", running_timestamp - last_read, chnum, lr, running_timestamp); - - if(chnum < 6) - { - vol_update_vllatch = GetVL(chnum, lr); - } - //last_read = running_timestamp; - } - else - { - // printf("Volume update(Apply): ch=%d, lr=%d, ts=%d\n", chnum, lr, running_timestamp); - if(chnum < 6) - { - channel[chnum].vl[lr] = vol_update_vllatch; - } - //last_apply = running_timestamp; - } - vol_update_which = (vol_update_which + 1) & 0x1F; - - if(vol_update_which) - vol_update_counter = phase ? 1 : 255; - else if(vol_pending) - { - vol_update_counter = phase ? 1 : 255; - vol_pending = false; - } - } - } - - lastts = running_timestamp; - } -} - -void PCE_PSG::EndFrame(int32 timestamp) -{ - Update(timestamp); - lastts = 0; - for(int chc = 0; chc < 6; chc++) - channel[chc].lastts = 0; -} - -void PCE_PSG::Power(const int32 timestamp) -{ - // Not sure about power-on values, these are mostly just intuitive guesses(with some laziness thrown in). - if(timestamp != lastts) - Update(timestamp); - - memset(&channel, 0, sizeof(channel)); - - select = 0; - globalbalance = 0; - lfofreq = 0; - lfoctrl = 0; - - for(int ch = 0; ch < 6; ch++) - { - channel[ch].frequency = 0; - channel[ch].control = 0x00; - channel[ch].balance = 0; - memset(channel[ch].waveform, 0, 32); - channel[ch].samp_accum = 0; - - channel[ch].waveform_index = 0; - channel[ch].dda = 0x00; - channel[ch].noisectrl = 0x00; - - channel[ch].vl[0] = 0x1F; - channel[ch].vl[1] = 0x1F; - - channel[ch].samp_accum = 0; - - RecalcFreqCache(ch); - RecalcUOFunc(ch); - - channel[ch].counter = channel[ch].freq_cache; - - if(ch >= 4) - { - RecalcNoiseFreqCache(ch); - channel[ch].noisecount = 1; - channel[ch].lfsr = 1; - } - } - - vol_pending = false; - vol_update_counter = 0; - vol_update_which = 0; -} - -int PCE_PSG::StateAction(StateMem *sm, int load, int data_only) -{ - int ret = 1; - - for(int ch = 0; ch < 6; ch++) - { - char tmpstr[5] = "SCHx"; - psg_channel *pt = &channel[ch]; - - SFORMAT CH_StateRegs[] = - { - SFVARN(pt->counter, "counter"), - SFVARN(pt->frequency, "frequency"), - SFVARN(pt->control, "control"), - SFVARN(pt->balance, "balance"), - SFARRAYN(pt->waveform, 32, "waveform"), - SFVARN(pt->waveform_index, "waveform_index"), - SFVARN(pt->dda, "dda"), - SFVARN(pt->noisectrl, "noisectrl"), - SFVARN(pt->noisecount, "noisecount"), - SFVARN(pt->lfsr, "lfsr"), - SFARRAY32N(pt->vl, 2, "vl"), // TODO - SFEND - }; - tmpstr[3] = '0' + ch; - ret &= MDFNSS_StateAction(sm, load, data_only, CH_StateRegs, tmpstr); - } - - SFORMAT PSG_StateRegs[] = - { - SFVAR(select), - SFVAR(globalbalance), - SFVAR(lfofreq), - SFVAR(lfoctrl), - - SFVAR(vol_update_counter), - SFVAR(vol_update_which), - SFVAR(vol_pending), - SFEND - }; - - ret &= MDFNSS_StateAction(sm, load, data_only, PSG_StateRegs, "PSG"); - - if(load) - { - vol_update_which &= 0x1F; - - if(!channel[4].lfsr) - channel[4].lfsr = 1; - - if(!channel[5].lfsr) - channel[5].lfsr = 1; - - for(int ch = 0; ch < 6; ch++) - { - channel[ch].samp_accum = 0; - for(int wi = 0; wi < 32; wi++) - { - channel[ch].waveform[wi] &= 0x1F; - channel[ch].samp_accum += channel[ch].waveform[wi]; - } - - for(int lr = 0; lr < 2; lr++) - channel[ch].vl[lr] &= 0x1F; - - if(!channel[ch].noisecount && ch >= 4) - { - printf("ch=%d, noisecount == 0\n", ch); - channel[ch].noisecount = 1; - } - - if(channel[ch].counter <= 0) - { - printf("ch=%d, counter <= 0\n", ch); - channel[ch].counter = 1; - } - - if(ch >= 4) - RecalcNoiseFreqCache(ch); - RecalcFreqCache(ch); - RecalcUOFunc(ch); - } - } - return(ret); -} diff --git a/libmednahawk/src/hw_sound/pce_psg/pce_psg.h b/libmednahawk/src/hw_sound/pce_psg/pce_psg.h deleted file mode 100644 index 1b2eef6c71..0000000000 --- a/libmednahawk/src/hw_sound/pce_psg/pce_psg.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef _PCE_PSG_H -#define _PCE_PSG_H - -#include -#include - -class PCE_PSG; - -struct psg_channel -{ - int32 counter; - uint16 frequency; /* Channel frequency */ - uint32 freq_cache; - uint8 control; /* Channel enable, DDA, volume */ - uint8 balance; /* Channel balance */ - uint8 waveform[32]; /* Waveform data */ - uint8 waveform_index; /* Waveform data index */ - uint8 dda; - uint8 noisectrl; /* Noise enable/ctrl (channels 4,5 only) */ - uint32 noise_freq_cache; // Channel 4,5 only - int32 noisecount; - uint32 lfsr; - - //int32 sample_cache[2]; - - int32 vl[2]; //vll, vlr; - - int samp_accum; // The result of adding up all the samples in the waveform buffer(part of an optimization for high-frequency playback). - - int32 blip_prev_samp[2]; - int32 lastts; - - void (PCE_PSG::*UpdateOutput)(const int32 timestamp, psg_channel *ch); -}; - -// Only CH4 and CH5 have NCTRL and LFSR, but it's here for the other channels for "consistency". -enum -{ - PSG_GSREG_CH0_FREQ = 0x000, -// PSG_GSREG_CH0_COUNTER, - PSG_GSREG_CH0_CTRL, - PSG_GSREG_CH0_BALANCE, - PSG_GSREG_CH0_WINDEX, - PSG_GSREG_CH0_SCACHE, - PSG_GSREG_CH0_NCTRL, - PSG_GSREG_CH0_LFSR, - - PSG_GSREG_CH1_FREQ = 0x100, -// PSG_GSREG_CH1_COUNTER, - PSG_GSREG_CH1_CTRL, - PSG_GSREG_CH1_BALANCE, - PSG_GSREG_CH1_WINDEX, - PSG_GSREG_CH1_SCACHE, - PSG_GSREG_CH1_NCTRL, - PSG_GSREG_CH1_LFSR, - - PSG_GSREG_CH2_FREQ = 0x200, -// PSG_GSREG_CH2_COUNTER, - PSG_GSREG_CH2_CTRL, - PSG_GSREG_CH2_BALANCE, - PSG_GSREG_CH2_WINDEX, - PSG_GSREG_CH2_SCACHE, - PSG_GSREG_CH2_NCTRL, - PSG_GSREG_CH2_LFSR, - - PSG_GSREG_CH3_FREQ = 0x300, -// PSG_GSREG_CH3_COUNTER, - PSG_GSREG_CH3_CTRL, - PSG_GSREG_CH3_BALANCE, - PSG_GSREG_CH3_WINDEX, - PSG_GSREG_CH3_SCACHE, - PSG_GSREG_CH3_NCTRL, - PSG_GSREG_CH3_LFSR, - - PSG_GSREG_CH4_FREQ = 0x400, -// PSG_GSREG_CH4_COUNTER, - PSG_GSREG_CH4_CTRL, - PSG_GSREG_CH4_BALANCE, - PSG_GSREG_CH4_WINDEX, - PSG_GSREG_CH4_SCACHE, - PSG_GSREG_CH4_NCTRL, - PSG_GSREG_CH4_LFSR, - - PSG_GSREG_CH5_FREQ = 0x500, -// PSG_GSREG_CH5_COUNTER, - PSG_GSREG_CH5_CTRL, - PSG_GSREG_CH5_BALANCE, - PSG_GSREG_CH5_WINDEX, - PSG_GSREG_CH5_SCACHE, - PSG_GSREG_CH5_NCTRL, - PSG_GSREG_CH5_LFSR, - - PSG_GSREG_SELECT = 0x1000, - PSG_GSREG_GBALANCE, - PSG_GSREG_LFOFREQ, - PSG_GSREG_LFOCTRL, - _PSG_GSREG_COUNT -}; - -class PCE_PSG -{ - public: - - enum - { - REVISION_HUC6280 = 0, - REVISION_HUC6280A, - REVISION_ENHANCED, - _REVISION_COUNT - }; - - - PCE_PSG(Blip_Buffer *bb_l, Blip_Buffer *bb_r, int want_revision); - ~PCE_PSG(); - - int StateAction(StateMem *sm, int load, int data_only); - - void Power(const int32 timestamp); - void Write(int32 timestamp, uint8 A, uint8 V); - - void SetVolume(double new_volume); - - void EndFrame(int32 timestamp); - - // TODO: timestamp - uint32 GetRegister(const unsigned int id, char *special, const uint32 special_len); - void SetRegister(const unsigned int id, const uint32 value); - - void PeekWave(const unsigned int ch, uint32 Address, uint32 Length, uint8 *Buffer); - void PokeWave(const unsigned int ch, uint32 Address, uint32 Length, const uint8 *Buffer); - - private: - - void Update(int32 timestamp); - - void UpdateSubLFO(int32 timestamp); - void UpdateSubNonLFO(int32 timestamp); - - void RecalcUOFunc(int chnum); - void UpdateOutput_Off(const int32 timestamp, psg_channel *ch); - void UpdateOutput_Accum(const int32 timestamp, psg_channel *ch); - void UpdateOutput_Norm(const int32 timestamp, psg_channel *ch); - void UpdateOutput_Noise(const int32 timestamp, psg_channel *ch); - -// void UpdateOutput_Norm_IL(const int32 timestamp, psg_channel *ch); -// void UpdateOutput_Noise_IL(const int32 timestamp, psg_channel *ch); - - - int32 GetVL(const int chnum, const int lr); - - void RecalcFreqCache(int chnum); - void RecalcNoiseFreqCache(int chnum); - void RunChannel(int chc, int32 timestamp, bool LFO_On); - double OutputVolume; - - uint8 select; /* Selected channel (0-5) */ - uint8 globalbalance; /* Global sound balance */ - uint8 lfofreq; /* LFO frequency */ - uint8 lfoctrl; /* LFO control */ - - int32 vol_update_counter; - int32 vol_update_which; - int32 vol_update_vllatch; - bool vol_pending; - - psg_channel channel[6]; - - int32 lastts; - int revision; - - bool SoundEnabled; - Blip_Buffer *sbuf[2]; - Blip_Synth Synth; - - int32 dbtable_volonly[32]; - - int32 dbtable[32][32]; -}; - -#endif diff --git a/libmednahawk/src/hw_sound/sms_apu/Sms_Apu.cpp b/libmednahawk/src/hw_sound/sms_apu/Sms_Apu.cpp deleted file mode 100644 index a76fc26c84..0000000000 --- a/libmednahawk/src/hw_sound/sms_apu/Sms_Apu.cpp +++ /dev/null @@ -1,384 +0,0 @@ -// Sms_Snd_Emu 0.1.4. http://www.slack.net/~ant/ - -#include "mednafen.h" -#include "Sms_Apu.h" - -/* Copyright (C) 2003-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -// Sms_Osc - -Sms_Osc::Sms_Osc() -{ - output = 0; - outputs [0] = 0; // always stays NULL - outputs [1] = 0; - outputs [2] = 0; - outputs [3] = 0; -} - -void Sms_Osc::reset() -{ - delay = 0; - last_amp = 0; - volume = 0; - output_select = 3; - output = outputs [3]; -} - -// Sms_Square - -blip_inline void Sms_Square::reset() -{ - period = 0; - phase = 0; - Sms_Osc::reset(); -} - -void Sms_Square::run( blip_time_t time, blip_time_t end_time ) -{ - int amp = volume; - if ( period > 128 ) - amp = amp << 1 & -phase; - - { - int delta = amp - last_amp; - if ( delta ) - { - last_amp = amp; - synth->offset( time, delta, output ); - } - } - - time += delay; - delay = 0; - if ( period ) - { - if ( time < end_time ) - { - if ( !volume || period <= 128 ) // ignore 16kHz and higher - { - // keep calculating phase - int count = (end_time - time + period - 1) / period; - phase = (phase + count) & 1; - time += count * period; - } - else - { - Blip_Buffer* const output = this->output; - int delta = amp * 2 - volume * 2; - do - { - delta = -delta; - synth->offset_inline( time, delta, output ); - time += period; - } - while ( time < end_time ); - - last_amp = (delta >> 1) + volume; - phase = (delta >= 0); - } - } - delay = time - end_time; - } -} - -// Sms_Noise - -static int const noise_periods [3] = { 0x100, 0x200, 0x400 }; - -blip_inline void Sms_Noise::reset() -{ - period = &noise_periods [0]; - shifter = 0x8000; - feedback = 0x9000; - Sms_Osc::reset(); -} - -void Sms_Noise::run( blip_time_t time, blip_time_t end_time ) -{ - int amp = (shifter & 1) ? 0 : volume * 2; - - { - int delta = amp - last_amp; - if ( delta ) - { - last_amp = amp; - synth.offset( time, delta, output ); - } - } - - time += delay; - if ( !volume ) - time = end_time; - - if ( time < end_time ) - { - Blip_Buffer* const output = this->output; - unsigned shifter = this->shifter; - int delta = (shifter & 1) ? (-volume * 2) : (volume * 2); - int period = *this->period * 2; - if ( !period ) - period = 16; - - do - { - int changed = shifter + 1; - shifter = (feedback & -(shifter & 1)) ^ (shifter >> 1); - if ( changed & 2 ) // true if bits 0 and 1 differ - { - amp = (shifter & 1) ? 0 : volume * 2; - delta = -delta; - synth.offset_inline( time, delta, output ); - last_amp = amp; - } - time += period; - } - while ( time < end_time ); - - this->shifter = shifter; - this->last_amp = (shifter & 1) ? 0 : volume * 2; //delta >> 1; - } - delay = time - end_time; -} - -// Sms_Apu - -Sms_Apu::Sms_Apu() -{ - for ( int i = 0; i < 3; i++ ) - { - squares [i].synth = &square_synth; - oscs [i] = &squares [i]; - } - oscs [3] = &noise; - - volume( 1.0 ); - reset(); -} - -Sms_Apu::~Sms_Apu() -{ -} - -void Sms_Apu::volume( double vol ) -{ - vol *= 0.85 / (osc_count * 64 * 2); - square_synth.volume( vol ); - noise.synth.volume( vol ); -} - -void Sms_Apu::treble_eq( const blip_eq_t& eq ) -{ - square_synth.treble_eq( eq ); - noise.synth.treble_eq( eq ); -} - -void Sms_Apu::osc_output( int index, Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right ) -{ - require( (unsigned) index < osc_count ); - require( (center && left && right) || (!center && !left && !right) ); - Sms_Osc& osc = *oscs [index]; - osc.outputs [1] = right; - osc.outputs [2] = left; - osc.outputs [3] = center; - osc.output = osc.outputs [osc.output_select]; -} - -void Sms_Apu::output( Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right ) -{ - for ( int i = 0; i < osc_count; i++ ) - osc_output( i, center, left, right ); -} - -void Sms_Apu::reset( unsigned feedback, int noise_width ) -{ - last_time = 0; - latch = 0; - ggstereo_save = 0xFF; - - if ( !feedback || !noise_width ) - { - feedback = 0x0009; - noise_width = 16; - } - // convert to "Galios configuration" - looped_feedback = 1 << (noise_width - 1); - noise_feedback = 0; - while ( noise_width-- ) - { - noise_feedback = (noise_feedback << 1) | (feedback & 1); - feedback >>= 1; - } - - squares [0].reset(); - squares [1].reset(); - squares [2].reset(); - noise.reset(); -} - -void Sms_Apu::run_until( blip_time_t end_time ) -{ - require( end_time >= last_time ); // end_time must not be before previous time - - if ( end_time > last_time ) - { - // run oscillators - for ( int i = 0; i < osc_count; ++i ) - { - Sms_Osc& osc = *oscs [i]; - if ( osc.output ) - { - if ( i < 3 ) - squares [i].run( last_time, end_time ); - else - noise.run( last_time, end_time ); - } - } - - last_time = end_time; - } -} - -void Sms_Apu::end_frame( blip_time_t end_time ) -{ - if ( end_time > last_time ) - run_until( end_time ); - - assert( last_time >= end_time ); - last_time -= end_time; -} - -void Sms_Apu::write_ggstereo( blip_time_t time, int data ) -{ - require( (unsigned) data <= 0xFF ); - - ggstereo_save = data; - - run_until( time ); - - for ( int i = 0; i < osc_count; i++ ) - { - Sms_Osc& osc = *oscs [i]; - int flags = data >> i; - Blip_Buffer* old_output = osc.output; - osc.output_select = (flags >> 3 & 2) | (flags & 1); - osc.output = osc.outputs [osc.output_select]; - if ( osc.output != old_output && osc.last_amp ) - { - if ( old_output ) - { - square_synth.offset( time, -osc.last_amp, old_output ); - } - osc.last_amp = 0; - } - } -} - -// volumes [i] = 64 * pow( 1.26, 15 - i ) / pow( 1.26, 15 ) -static unsigned char const volumes [16] = { - 64, 50, 39, 31, 24, 19, 15, 12, 9, 7, 5, 4, 3, 2, 1, 0 -}; - -void Sms_Apu::write_data( blip_time_t time, int data ) -{ - require( (unsigned) data <= 0xFF ); - - run_until( time ); - - if ( data & 0x80 ) - latch = data; - - int index = (latch >> 5) & 3; - - //if(index == 3) - //printf("Write @ %d; Index: %d, %d, Value: %02x\n", time, index, latch, data); - - if ( latch & 0x10 ) - { - oscs [index]->volume = volumes [data & 15]; - } - else if ( index < 3 ) - { - Sms_Square& sq = squares [index]; - if ( data & 0x80 ) - sq.period = (sq.period & 0xFF00) | (data << 4 & 0x00FF); - else - sq.period = (sq.period & 0x00FF) | (data << 8 & 0x3F00); - } - else - { - int select = data & 3; - if ( select < 3 ) - noise.period = &noise_periods [select]; - else - noise.period = &squares [2].period; - - noise.feedback = (data & 0x04) ? noise_feedback : looped_feedback; - noise.shifter = 0x8000; - } -} - - -void Sms_Apu::save_state(Sms_ApuState *ret) -{ - memset(ret, 0, sizeof(Sms_ApuState)); - - ret->ggstereo = ggstereo_save; - - for(int x = 0; x < 4; x++) - { - ret->volume[x] = oscs[x]->volume; - } - - for(int x = 0; x < 3; x++) - { - ret->sq_period[x] = squares[x].period; - ret->sq_phase[x] = squares[x].phase; - } - - ret->noise_shifter = noise.shifter; - ret->noise_feedback = noise.feedback; - - if(noise.period == &noise_periods[0]) - ret->noise_period = 0; - else if(noise.period == &noise_periods[1]) - ret->noise_period = 1; - else if(noise.period == &noise_periods[2]) - ret->noise_period = 2; - else ret->noise_period = 3; -} - -void Sms_Apu::load_state(const Sms_ApuState *state) -{ - for(int x = 0; x < 4; x++) - { - oscs[x]->volume = state->volume[x]; - } - - for(int x = 0; x < 3; x++) - { - squares[x].period = state->sq_period[x]; - squares[x].phase = state->sq_phase[x]; - } - noise.shifter = state->noise_shifter; - noise.feedback = state->noise_feedback; - - int select = state->noise_period; - - if ( select < 3 ) - noise.period = &noise_periods [select]; - else - noise.period = &squares [2].period; - - write_ggstereo(0, state->ggstereo); -} - diff --git a/libmednahawk/src/hw_sound/sms_apu/Sms_Apu.h b/libmednahawk/src/hw_sound/sms_apu/Sms_Apu.h deleted file mode 100644 index 466128608a..0000000000 --- a/libmednahawk/src/hw_sound/sms_apu/Sms_Apu.h +++ /dev/null @@ -1,92 +0,0 @@ -// Sega Master System SN76489 PSG sound chip emulator - -// Sms_Snd_Emu 0.1.4 -#ifndef SMS_APU_H -#define SMS_APU_H - -#include "Sms_Oscs.h" - -typedef struct -{ - int32 sq_period[3]; - int32 sq_phase[3]; - int32 noise_period; - uint32 noise_shifter; - uint32 noise_feedback; - - int32 volume[4]; - uint8 ggstereo; - uint8 latch; -} Sms_ApuState; - -class Sms_Apu { -public: - // Set overall volume of all oscillators, where 1.0 is full volume - void volume( double ); - - // Set treble equalization - void treble_eq( const blip_eq_t& ); - - // Outputs can be assigned to a single buffer for mono output, or to three - // buffers for stereo output (using Stereo_Buffer to do the mixing). - - // Assign all oscillator outputs to specified buffer(s). If buffer - // is NULL, silences all oscillators. - void output( Blip_Buffer* mono ); - void output( Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right ); - - // Assign single oscillator output to buffer(s). Valid indicies are 0 to 3, - // which refer to Square 1, Square 2, Square 3, and Noise. If buffer is NULL, - // silences oscillator. - enum { osc_count = 4 }; - void osc_output( int index, Blip_Buffer* mono ); - void osc_output( int index, Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right ); - - // Reset oscillators and internal state - void reset( unsigned noise_feedback = 0, int noise_width = 0 ); - - // Write GameGear left/right assignment byte - void write_ggstereo( blip_time_t, int ); - - // Write to data port - void write_data( blip_time_t, int ); - - // Run all oscillators up to specified time, end current frame, then - // start a new frame at time 0. - void end_frame( blip_time_t ); - - void save_state(Sms_ApuState *); - void load_state(const Sms_ApuState *); - -public: - Sms_Apu(); - ~Sms_Apu(); -private: - // noncopyable - Sms_Apu( const Sms_Apu& ); - Sms_Apu& operator = ( const Sms_Apu& ); - - Sms_Osc* oscs [osc_count]; - Sms_Square squares [3]; - Sms_Square::Synth square_synth; // used by squares - blip_time_t last_time; - int latch; - Sms_Noise noise; - unsigned noise_feedback; - unsigned looped_feedback; - unsigned int ggstereo_save; - - void run_until( blip_time_t ); -}; - -struct sms_apu_state_t -{ - unsigned char regs [8] [2]; - unsigned char latch; -}; - -inline void Sms_Apu::output( Blip_Buffer* b ) { output( b, b, b ); } - -inline void Sms_Apu::osc_output( int i, Blip_Buffer* b ) { osc_output( i, b, b, b ); } - -#endif diff --git a/libmednahawk/src/hw_sound/sms_apu/Sms_Oscs.h b/libmednahawk/src/hw_sound/sms_apu/Sms_Oscs.h deleted file mode 100644 index dda9918218..0000000000 --- a/libmednahawk/src/hw_sound/sms_apu/Sms_Oscs.h +++ /dev/null @@ -1,48 +0,0 @@ -// Private oscillators used by Sms_Apu - -// Sms_Snd_Emu 0.1.4 -#ifndef SMS_OSCS_H -#define SMS_OSCS_H - -#include - -struct Sms_Osc -{ - Blip_Buffer* outputs [4]; // NULL, right, left, center - Blip_Buffer* output; - int output_select; - - int delay; - int last_amp; - int volume; - - Sms_Osc(); - void reset(); -}; - -struct Sms_Square : Sms_Osc -{ - int period; - int phase; - - typedef Blip_Synth Synth; - const Synth* synth; - - void reset(); - void run( blip_time_t, blip_time_t ); -}; - -struct Sms_Noise : Sms_Osc -{ - const int* period; - unsigned shifter; - unsigned feedback; - - typedef Blip_Synth Synth; - Synth synth; - - void reset(); - void run( blip_time_t, blip_time_t ); -}; - -#endif diff --git a/libmednahawk/src/hw_sound/ym2413/2413tone.h b/libmednahawk/src/hw_sound/ym2413/2413tone.h deleted file mode 100644 index a8ded868a1..0000000000 --- a/libmednahawk/src/hw_sound/ym2413/2413tone.h +++ /dev/null @@ -1,20 +0,0 @@ -0x49,0x4c,0x4c,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x61,0x61,0x1e,0x17,0xf0,0x7f,0x00,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x13,0x41,0x16,0x0e,0xfd,0xf4,0x23,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x03,0x01,0x9a,0x04,0xf3,0xf3,0x13,0xf3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x11,0x61,0x0e,0x07,0xfa,0x64,0x70,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x22,0x21,0x1e,0x06,0xf0,0x76,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x22,0x16,0x05,0xf0,0x71,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x61,0x1d,0x07,0x82,0x80,0x17,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x23,0x21,0x2d,0x16,0x90,0x90,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x21,0x1b,0x06,0x64,0x65,0x10,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x21,0x0b,0x1a,0x85,0xa0,0x70,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x23,0x01,0x83,0x10,0xff,0xb4,0x10,0xf4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x97,0xc1,0x20,0x07,0xff,0xf4,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x61,0x00,0x0c,0x05,0xc2,0xf6,0x40,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x01,0x56,0x03,0x94,0xc2,0x03,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x21,0x01,0x89,0x03,0xf1,0xe4,0xf0,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x07,0x21,0x14,0x00,0xee,0xf8,0xff,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x31,0x00,0x00,0xf8,0xf7,0xf8,0xf7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x25,0x11,0x00,0x00,0xf8,0xfa,0xf8,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - diff --git a/libmednahawk/src/hw_sound/ym2413/emu2413.cpp b/libmednahawk/src/hw_sound/ym2413/emu2413.cpp deleted file mode 100644 index 6bc45b944d..0000000000 --- a/libmednahawk/src/hw_sound/ym2413/emu2413.cpp +++ /dev/null @@ -1,1768 +0,0 @@ -/* Modified for usage in Mednafen's SMS emulation(YMF281B tone data removed, code simplified, and more!). - - License: - - Copyright (C) Mitsutaka Okazaki 2004 - - This software is provided 'as-is', without any express or implied warranty. - In no event will the authors be held liable for any damages arising from - the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/*********************************************************************************** - - emu2413.c -- YM2413 emulator written by Mitsutaka Okazaki 2001 - - 2001 01-08 : Version 0.10 -- 1st version. - 2001 01-15 : Version 0.20 -- semi-public version. - 2001 01-16 : Version 0.30 -- 1st public version. - 2001 01-17 : Version 0.31 -- Fixed bassdrum problem. - : Version 0.32 -- LPF implemented. - 2001 01-18 : Version 0.33 -- Fixed the drum problem, refine the mix-down method. - -- Fixed the LFO bug. - 2001 01-24 : Version 0.35 -- Fixed the drum problem, - support undocumented EG behavior. - 2001 02-02 : Version 0.38 -- Improved the performance. - Fixed the hi-hat and cymbal model. - Fixed the default percussive datas. - Noise reduction. - Fixed the feedback problem. - 2001 03-03 : Version 0.39 -- Fixed some drum bugs. - Improved the performance. - 2001 03-04 : Version 0.40 -- Improved the feedback. - Change the default table size. - Clock and Rate can be changed during play. - 2001 06-24 : Version 0.50 -- Improved the hi-hat and the cymbal tone. - Added VRC7 patch (EMU2413_reset_patch is changed). - Fixed EMU2413_reset() bug. - Added EMU2413_setMask, EMU2413_getMask and EMU2413_toggleMask. - Added EMU2413_writeIO. - 2001 09-28 : Version 0.51 -- Removed the noise table. - 2002 01-28 : Version 0.52 -- Added Stereo mode. - 2002 02-07 : Version 0.53 -- Fixed some drum bugs. - 2002 02-20 : Version 0.54 -- Added the best quality mode. - 2002 03-02 : Version 0.55 -- Removed EMU2413_init & EMU2413_close. - 2002 05-30 : Version 0.60 -- Fixed HH&CYM generator and all voice datas. - 2004 04-10 : Version 0.61 -- Added YMF281B tone (defined by Chabin). - - References: - fmopl.c -- 1999,2000 written by Tatsuyuki Satoh (MAME development). - fmopl.c(fixed) -- (C) 2002 Jarek Burczynski. - s_opl.c -- 2001 written by Mamiya (NEZplug development). - fmgen.cpp -- 1999,2000 written by cisc. - fmpac.ill -- 2000 created by NARUTO. - MSX-Datapack - YMU757 data sheet - YM2143 data sheet - -**************************************************************************************/ - -#include "mednafen/mednafen.h" -#include -#include -#include - -#include "emu2413.h" - -#define EMU2413_TONE_NUM 1 -static unsigned char default_inst[EMU2413_TONE_NUM][(16 + 3) * 16] = { - { -#include "2413tone.h" - } -}; - -/* Size of Sintable ( 8 -- 18 can be used. 9 recommended.) */ -#define PG_BITS 9 -#define PG_WIDTH (1<>(b)) - -/* Leave the lower b bit(s). */ -#define LOWBITS(c,b) ((c)&((1<<(b))-1)) - -/* Expand x which is s bits to d bits. */ -#define EXPAND_BITS(x,s,d) ((x)<<((d)-(s))) - -/* Expand x which is s bits to d bits and fill expanded bits '1' */ -#define EXPAND_BITS_X(x,s,d) (((x)<<((d)-(s)))|((1<<((d)-(s)))-1)) - -#define MOD(o,x) (&(o)->slot[(x)<<1]) -#define CAR(o,x) (&(o)->slot[((x)<<1)|1]) - -#define BIT(s,b) (((s)>>(b))&1) - -/* Input clock */ -static uint32 clk = 844451141; - -/* WaveTable for each envelope amp */ -static uint32 fullsintable[PG_WIDTH]; -static uint32 halfsintable[PG_WIDTH]; - -static uint32 *waveform[2] = { fullsintable, halfsintable }; - -/* LFO Table */ -static int32 pmtable[PM_PG_WIDTH]; -static int32 amtable[AM_PG_WIDTH]; - -/* Phase delta for LFO */ -static uint32 pm_dphase; -static uint32 am_dphase; - -/* dB to Liner table */ -static int32 DB2LIN_TABLE[(DB_MUTE + DB_MUTE) * 2]; - -/* Liner to Log curve conversion table (for Attack rate). */ -static uint32 AR_ADJUST_TABLE[1 << EG_BITS]; - -/* Empty voice data */ -static EMU2413_PATCH null_patch = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -/* Basic voice Data */ -static EMU2413_PATCH default_patch[EMU2413_TONE_NUM][(16 + 3) * 2]; - -/* Definition of envelope mode */ -enum EMU2413_EG_STATE -{ READY, ATTACK, DECAY, SUSHOLD, SUSTINE, RELEASE, SETTLE, FINISH }; - -/* Phase incr table for Attack */ -static uint32 dphaseARTable[16][16]; -/* Phase incr table for Decay and Release */ -static uint32 dphaseDRTable[16][16]; - -/* KSL + TL Table */ -static uint32 tllTable[16][8][1 << TL_BITS][4]; -static int32 rksTable[2][8][2]; - -/* Phase incr table for PG */ -static uint32 dphaseTable[512][8][16]; - -/*************************************************** - - Create tables - -****************************************************/ -INLINE static int32 -Min (int32 i, int32 j) -{ - if (i < j) - return i; - else - return j; -} - -/* Table for AR to LogCurve. */ -static void -makeAdjustTable (void) -{ - int32 i; - - AR_ADJUST_TABLE[0] = (1 << EG_BITS) - 1; - for (i = 1; i < (1<= DB_MUTE) DB2LIN_TABLE[i] = 0; - DB2LIN_TABLE[i + DB_MUTE + DB_MUTE] = (int32) (-DB2LIN_TABLE[i]); - //printf("%d\n", DB2LIN_TABLE[i]); - } -} - -/* Liner(+0.0 - +1.0) to dB((1<> (20 - DP_BITS)); -} - -static void -makeTllTable (void) -{ -#define dB2(x) ((x)*2) - - static double kltable[16] = { - dB2 (0.000), dB2 (9.000), dB2 (12.000), dB2 (13.875), dB2 (15.000), dB2 (16.125), dB2 (16.875), dB2 (17.625), - dB2 (18.000), dB2 (18.750), dB2 (19.125), dB2 (19.500), dB2 (19.875), dB2 (20.250), dB2 (20.625), dB2 (21.000) - }; - - int32 tmp; - int32 fnum, block, TL, KL; - - for (fnum = 0; fnum < 16; fnum++) - for (block = 0; block < 8; block++) - for (TL = 0; TL < 64; TL++) - for (KL = 0; KL < 4; KL++) - { - if (KL == 0) - { - tllTable[fnum][block][TL][KL] = TL2EG (TL); - } - else - { - tmp = (int32) (kltable[fnum] - dB2 (3.000) * (7 - block)); - if (tmp <= 0) - tllTable[fnum][block][TL][KL] = TL2EG (TL); - else - tllTable[fnum][block][TL][KL] = (uint32) ((tmp >> (3 - KL)) / EG_STEP) + TL2EG (TL); - } - } -} - -#ifdef USE_SPEC_ENV_SPEED -static double attacktime[16][4] = { - {0, 0, 0, 0}, - {1730.15, 1400.60, 1153.43, 988.66}, - {865.08, 700.30, 576.72, 494.33}, - {432.54, 350.15, 288.36, 247.16}, - {216.27, 175.07, 144.18, 123.58}, - {108.13, 87.54, 72.09, 61.79}, - {54.07, 43.77, 36.04, 30.90}, - {27.03, 21.88, 18.02, 15.45}, - {13.52, 10.94, 9.01, 7.72}, - {6.76, 5.47, 4.51, 3.86}, - {3.38, 2.74, 2.25, 1.93}, - {1.69, 1.37, 1.13, 0.97}, - {0.84, 0.70, 0.60, 0.54}, - {0.50, 0.42, 0.34, 0.30}, - {0.28, 0.22, 0.18, 0.14}, - {0.00, 0.00, 0.00, 0.00} -}; - -static double decaytime[16][4] = { - {0, 0, 0, 0}, - {20926.60, 16807.20, 14006.00, 12028.60}, - {10463.30, 8403.58, 7002.98, 6014.32}, - {5231.64, 4201.79, 3501.49, 3007.16}, - {2615.82, 2100.89, 1750.75, 1503.58}, - {1307.91, 1050.45, 875.37, 751.79}, - {653.95, 525.22, 437.69, 375.90}, - {326.98, 262.61, 218.84, 187.95}, - {163.49, 131.31, 109.42, 93.97}, - {81.74, 65.65, 54.71, 46.99}, - {40.87, 32.83, 27.36, 23.49}, - {20.44, 16.41, 13.68, 11.75}, - {10.22, 8.21, 6.84, 5.87}, - {5.11, 4.10, 3.42, 2.94}, - {2.55, 2.05, 1.71, 1.47}, - {1.27, 1.27, 1.27, 1.27} -}; -#endif - -/* Rate Table for Attack */ -static void -makeDphaseARTable (void) -{ - int32 AR, Rks, RM, RL; - -#ifdef USE_SPEC_ENV_SPEED - uint32 attacktable[16][4]; - - for (RM = 0; RM < 16; RM++) - for (RL = 0; RL < 4; RL++) - { - if (RM == 0) - attacktable[RM][RL] = 0; - else if (RM == 15) - attacktable[RM][RL] = EG_DP_WIDTH; - else - attacktable[RM][RL] = (uint32) ((double) (1 << EG_DP_BITS) / (attacktime[RM][RL] * 3579545 / 72000)); - - } -#endif - - for (AR = 0; AR < 16; AR++) - for (Rks = 0; Rks < 16; Rks++) - { - RM = AR + (Rks >> 2); - RL = Rks & 3; - if (RM > 15) - RM = 15; - switch (AR) - { - case 0: - dphaseARTable[AR][Rks] = 0; - break; - case 15: - dphaseARTable[AR][Rks] = 0;/*EG_DP_WIDTH;*/ - break; - default: -#ifdef USE_SPEC_ENV_SPEED - dphaseARTable[AR][Rks] = (attacktable[RM][RL]); -#else - dphaseARTable[AR][Rks] = ((3 * (RL + 4) << (RM + 1))); -#endif - break; - } - } -} - -/* Rate Table for Decay and Release */ -static void -makeDphaseDRTable (void) -{ - int32 DR, Rks, RM, RL; - -#ifdef USE_SPEC_ENV_SPEED - uint32 decaytable[16][4]; - - for (RM = 0; RM < 16; RM++) - for (RL = 0; RL < 4; RL++) - if (RM == 0) - decaytable[RM][RL] = 0; - else - decaytable[RM][RL] = (uint32) ((double) (1 << EG_DP_BITS) / (decaytime[RM][RL] * 3579545 / 72000)); -#endif - - for (DR = 0; DR < 16; DR++) - for (Rks = 0; Rks < 16; Rks++) - { - RM = DR + (Rks >> 2); - RL = Rks & 3; - if (RM > 15) - RM = 15; - switch (DR) - { - case 0: - dphaseDRTable[DR][Rks] = 0; - break; - default: -#ifdef USE_SPEC_ENV_SPEED - dphaseDRTable[DR][Rks] = (decaytable[RM][RL]); -#else - dphaseDRTable[DR][Rks] = ((RL + 4) << (RM - 1)); -#endif - break; - } - } -} - -static void -makeRksTable (void) -{ - - int32 fnum8, block, KR; - - for (fnum8 = 0; fnum8 < 2; fnum8++) - for (block = 0; block < 8; block++) - for (KR = 0; KR < 2; KR++) - { - if (KR != 0) - rksTable[fnum8][block][KR] = (block << 1) + fnum8; - else - rksTable[fnum8][block][KR] = block >> 1; - } -} - -void -EMU2413_dump2patch (const uint8 * dump, EMU2413_PATCH * patch) -{ - patch[0].AM = (dump[0] >> 7) & 1; - patch[1].AM = (dump[1] >> 7) & 1; - patch[0].PM = (dump[0] >> 6) & 1; - patch[1].PM = (dump[1] >> 6) & 1; - patch[0].EG = (dump[0] >> 5) & 1; - patch[1].EG = (dump[1] >> 5) & 1; - patch[0].KR = (dump[0] >> 4) & 1; - patch[1].KR = (dump[1] >> 4) & 1; - patch[0].ML = (dump[0]) & 15; - patch[1].ML = (dump[1]) & 15; - patch[0].KL = (dump[2] >> 6) & 3; - patch[1].KL = (dump[3] >> 6) & 3; - patch[0].TL = (dump[2]) & 63; - patch[0].FB = (dump[3]) & 7; - patch[0].WF = (dump[3] >> 3) & 1; - patch[1].WF = (dump[3] >> 4) & 1; - patch[0].AR = (dump[4] >> 4) & 15; - patch[1].AR = (dump[5] >> 4) & 15; - patch[0].DR = (dump[4]) & 15; - patch[1].DR = (dump[5]) & 15; - patch[0].SL = (dump[6] >> 4) & 15; - patch[1].SL = (dump[7] >> 4) & 15; - patch[0].RR = (dump[6]) & 15; - patch[1].RR = (dump[7]) & 15; -} - -void -EMU2413_getDefaultPatch (int32 type, int32 num, EMU2413_PATCH * patch) -{ - EMU2413_dump2patch (default_inst[type] + num * 16, patch); -} - -static void -makeDefaultPatch () -{ - int32 i, j; - - for (i = 0; i < EMU2413_TONE_NUM; i++) - for (j = 0; j < 19; j++) - EMU2413_getDefaultPatch (i, j, &default_patch[i][j * 2]); - -} - -void -EMU2413_setPatch (EMU2413 * opll, const uint8 * dump) -{ - EMU2413_PATCH patch[2]; - int i; - - for (i = 0; i < 19; i++) - { - EMU2413_dump2patch (dump + i * 16, patch); - memcpy (&opll->patch[i*2+0], &patch[0], sizeof (EMU2413_PATCH)); - memcpy (&opll->patch[i*2+1], &patch[1], sizeof (EMU2413_PATCH)); - } -} - -void -EMU2413_patch2dump (const EMU2413_PATCH * patch, uint8 * dump) -{ - dump[0] = (uint8) ((patch[0].AM << 7) + (patch[0].PM << 6) + (patch[0].EG << 5) + (patch[0].KR << 4) + patch[0].ML); - dump[1] = (uint8) ((patch[1].AM << 7) + (patch[1].PM << 6) + (patch[1].EG << 5) + (patch[1].KR << 4) + patch[1].ML); - dump[2] = (uint8) ((patch[0].KL << 6) + patch[0].TL); - dump[3] = (uint8) ((patch[1].KL << 6) + (patch[1].WF << 4) + (patch[0].WF << 3) + patch[0].FB); - dump[4] = (uint8) ((patch[0].AR << 4) + patch[0].DR); - dump[5] = (uint8) ((patch[1].AR << 4) + patch[1].DR); - dump[6] = (uint8) ((patch[0].SL << 4) + patch[0].RR); - dump[7] = (uint8) ((patch[1].SL << 4) + patch[1].RR); - dump[8] = 0; - dump[9] = 0; - dump[10] = 0; - dump[11] = 0; - dump[12] = 0; - dump[13] = 0; - dump[14] = 0; - dump[15] = 0; -} - -/************************************************************ - - Calc Parameters - -************************************************************/ - -INLINE static uint32 -calc_eg_dphase (EMU2413_SLOT * slot) -{ - - switch (slot->eg_mode) - { - case ATTACK: - return dphaseARTable[slot->patch->AR][slot->rks]; - - case DECAY: - return dphaseDRTable[slot->patch->DR][slot->rks]; - - case SUSHOLD: - return 0; - - case SUSTINE: - return dphaseDRTable[slot->patch->RR][slot->rks]; - - case RELEASE: - if (slot->sustine) - return dphaseDRTable[5][slot->rks]; - else if (slot->patch->EG) - return dphaseDRTable[slot->patch->RR][slot->rks]; - else - return dphaseDRTable[7][slot->rks]; - - case SETTLE: - return dphaseDRTable[15][0]; - - case FINISH: - return 0; - - default: - return 0; - } -} - -/************************************************************* - - EMU2413 internal interfaces - -*************************************************************/ -#define SLOT_BD1 12 -#define SLOT_BD2 13 -#define SLOT_HH 14 -#define SLOT_SD 15 -#define SLOT_TOM 16 -#define SLOT_CYM 17 - -#define UPDATE_PG(S) (S)->dphase = dphaseTable[(S)->fnum][(S)->block][(S)->patch->ML] -#define UPDATE_TLL(S)\ -(((S)->type==0)?\ -((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->patch->TL][(S)->patch->KL]):\ -((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->volume][(S)->patch->KL])) -#define UPDATE_RKS(S) (S)->rks = rksTable[((S)->fnum)>>8][(S)->block][(S)->patch->KR] -#define UPDATE_WF(S) (S)->sintbl = waveform[(S)->patch->WF] -#define UPDATE_EG(S) (S)->eg_dphase = calc_eg_dphase(S) -#define UPDATE_ALL(S)\ - UPDATE_PG(S);\ - UPDATE_TLL(S);\ - UPDATE_RKS(S);\ - UPDATE_WF(S); \ - UPDATE_EG(S) /* EG should be updated last. */ - - -/* Slot key on */ -INLINE static void -slotOn (EMU2413_SLOT * slot) -{ - slot->eg_mode = ATTACK; - slot->eg_phase = 0; - slot->phase = 0; - UPDATE_EG(slot); -} - -/* Slot key on without reseting the phase */ -INLINE static void -slotOn2 (EMU2413_SLOT * slot) -{ - slot->eg_mode = ATTACK; - slot->eg_phase = 0; - UPDATE_EG(slot); -} - -/* Slot key off */ -INLINE static void -slotOff (EMU2413_SLOT * slot) -{ - if (slot->eg_mode == ATTACK) - slot->eg_phase = EXPAND_BITS (AR_ADJUST_TABLE[HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS)], EG_BITS, EG_DP_BITS); - slot->eg_mode = RELEASE; - UPDATE_EG(slot); -} - -/* Channel key on */ -INLINE static void -keyOn (EMU2413 * opll, int32 i) -{ - if (!opll->slot_on_flag[i * 2]) - slotOn (MOD(opll,i)); - if (!opll->slot_on_flag[i * 2 + 1]) - slotOn (CAR(opll,i)); - opll->key_status[i] = 1; -} - -/* Channel key off */ -INLINE static void -keyOff (EMU2413 * opll, int32 i) -{ - if (opll->slot_on_flag[i * 2 + 1]) - slotOff (CAR(opll,i)); - opll->key_status[i] = 0; -} - -INLINE static void -keyOn_BD (EMU2413 * opll) -{ - keyOn (opll, 6); -} -INLINE static void -keyOn_SD (EMU2413 * opll) -{ - if (!opll->slot_on_flag[SLOT_SD]) - slotOn (CAR(opll,7)); -} -INLINE static void -keyOn_TOM (EMU2413 * opll) -{ - if (!opll->slot_on_flag[SLOT_TOM]) - slotOn (MOD(opll,8)); -} -INLINE static void -keyOn_HH (EMU2413 * opll) -{ - if (!opll->slot_on_flag[SLOT_HH]) - slotOn2 (MOD(opll,7)); -} -INLINE static void -keyOn_CYM (EMU2413 * opll) -{ - if (!opll->slot_on_flag[SLOT_CYM]) { - slotOn2 (CAR(opll,8)); - } -} - -/* Drum key off */ -INLINE static void -keyOff_BD (EMU2413 * opll) -{ - keyOff (opll, 6); -} -INLINE static void -keyOff_SD (EMU2413 * opll) -{ - if (opll->slot_on_flag[SLOT_SD]) - slotOff (CAR(opll,7)); -} -INLINE static void -keyOff_TOM (EMU2413 * opll) -{ - if (opll->slot_on_flag[SLOT_TOM]) - slotOff (MOD(opll,8)); -} -INLINE static void -keyOff_HH (EMU2413 * opll) -{ - if (opll->slot_on_flag[SLOT_HH]) - slotOff (MOD(opll,7)); -} -INLINE static void -keyOff_CYM (EMU2413 * opll) -{ - if (opll->slot_on_flag[SLOT_CYM]) { - CAR(opll,8)->sustine = 1; - slotOff (CAR(opll,8)); - } -} - -/* Change a voice */ -INLINE static void -setPatch (EMU2413 * opll, int32 i, int32 num) -{ - opll->patch_number[i] = num; - MOD(opll,i)->patch = &opll->patch[num * 2 + 0]; - CAR(opll,i)->patch = &opll->patch[num * 2 + 1]; -} - -/* Change a rhythm voice */ -INLINE static void -setSlotPatch (EMU2413_SLOT * slot, EMU2413_PATCH * patch) -{ - slot->patch = patch; -} - -/* Set sustine parameter */ -INLINE static void -setSustine (EMU2413 * opll, int32 c, int32 sustine) -{ - CAR(opll,c)->sustine = sustine; - if (MOD(opll,c)->type) - MOD(opll,c)->sustine = sustine; -} - -/* Volume : 6bit ( Volume register << 2 ) */ -INLINE static void -setVolume (EMU2413 * opll, int32 c, int32 volume) -{ - CAR(opll,c)->volume = volume; -} - -INLINE static void -setSlotVolume (EMU2413_SLOT * slot, int32 volume) -{ - slot->volume = volume; -} - -/* Set F-Number ( fnum : 9bit ) */ -INLINE static void -setFnumber (EMU2413 * opll, int32 c, int32 fnum) -{ - CAR(opll,c)->fnum = fnum; - MOD(opll,c)->fnum = fnum; -} - -/* Set Block data (block : 3bit ) */ -INLINE static void -setBlock (EMU2413 * opll, int32 c, int32 block) -{ - CAR(opll,c)->block = block; - MOD(opll,c)->block = block; -} - -/* Change Rhythm Mode */ -INLINE static void -update_rhythm_mode (EMU2413 * opll) -{ - if (opll->patch_number[6] & 0x10) - { - if (!(opll->slot_on_flag[SLOT_BD2] | (opll->reg[0x0e] & 32))) - { - opll->slot[SLOT_BD1].eg_mode = FINISH; - opll->slot[SLOT_BD2].eg_mode = FINISH; - setPatch (opll, 6, opll->reg[0x36] >> 4); - } - } - else if (opll->reg[0x0e] & 32) - { - opll->patch_number[6] = 16; - opll->slot[SLOT_BD1].eg_mode = FINISH; - opll->slot[SLOT_BD2].eg_mode = FINISH; - setSlotPatch (&opll->slot[SLOT_BD1], &opll->patch[16 * 2 + 0]); - setSlotPatch (&opll->slot[SLOT_BD2], &opll->patch[16 * 2 + 1]); - } - - if (opll->patch_number[7] & 0x10) - { - if (!((opll->slot_on_flag[SLOT_HH] && opll->slot_on_flag[SLOT_SD]) | (opll->reg[0x0e] & 32))) - { - opll->slot[SLOT_HH].type = 0; - opll->slot[SLOT_HH].eg_mode = FINISH; - opll->slot[SLOT_SD].eg_mode = FINISH; - setPatch (opll, 7, opll->reg[0x37] >> 4); - } - } - else if (opll->reg[0x0e] & 32) - { - opll->patch_number[7] = 17; - opll->slot[SLOT_HH].type = 1; - opll->slot[SLOT_HH].eg_mode = FINISH; - opll->slot[SLOT_SD].eg_mode = FINISH; - setSlotPatch (&opll->slot[SLOT_HH], &opll->patch[17 * 2 + 0]); - setSlotPatch (&opll->slot[SLOT_SD], &opll->patch[17 * 2 + 1]); - } - - if (opll->patch_number[8] & 0x10) - { - if (!((opll->slot_on_flag[SLOT_CYM] && opll->slot_on_flag[SLOT_TOM]) | (opll->reg[0x0e] & 32))) - { - opll->slot[SLOT_TOM].type = 0; - opll->slot[SLOT_TOM].eg_mode = FINISH; - opll->slot[SLOT_CYM].eg_mode = FINISH; - setPatch (opll, 8, opll->reg[0x38] >> 4); - } - } - else if (opll->reg[0x0e] & 32) - { - opll->patch_number[8] = 18; - opll->slot[SLOT_TOM].type = 1; - opll->slot[SLOT_TOM].eg_mode = FINISH; - opll->slot[SLOT_CYM].eg_mode = FINISH; - setSlotPatch (&opll->slot[SLOT_TOM], &opll->patch[18 * 2 + 0]); - setSlotPatch (&opll->slot[SLOT_CYM], &opll->patch[18 * 2 + 1]); - } -} - -INLINE static void -update_key_status (EMU2413 * opll) -{ - int ch; - - for (ch = 0; ch < 9; ch++) - opll->slot_on_flag[ch * 2] = opll->slot_on_flag[ch * 2 + 1] = (opll->reg[0x20 + ch]) & 0x10; - - if (opll->reg[0x0e] & 32) - { - opll->slot_on_flag[SLOT_BD1] |= (opll->reg[0x0e] & 0x10); - opll->slot_on_flag[SLOT_BD2] |= (opll->reg[0x0e] & 0x10); - opll->slot_on_flag[SLOT_SD] |= (opll->reg[0x0e] & 0x08); - opll->slot_on_flag[SLOT_HH] |= (opll->reg[0x0e] & 0x01); - opll->slot_on_flag[SLOT_TOM] |= (opll->reg[0x0e] & 0x04); - opll->slot_on_flag[SLOT_CYM] |= (opll->reg[0x0e] & 0x02); - } -} - -void -EMU2413_copyPatch (EMU2413 * opll, int32 num, EMU2413_PATCH * patch) -{ - memcpy (&opll->patch[num], patch, sizeof (EMU2413_PATCH)); -} - -/*********************************************************** - - Initializing - -***********************************************************/ - -static void -EMU2413_SLOT_reset (EMU2413_SLOT * slot, int type) -{ - slot->type = type; - slot->sintbl = waveform[0]; - slot->phase = 0; - slot->dphase = 0; - slot->output[0] = 0; - slot->output[1] = 0; - slot->feedback = 0; - slot->eg_mode = FINISH; - slot->eg_phase = EG_DP_WIDTH; - slot->eg_dphase = 0; - slot->rks = 0; - slot->tll = 0; - slot->sustine = 0; - slot->fnum = 0; - slot->block = 0; - slot->volume = 0; - slot->pgout = 0; - slot->egout = 0; - slot->patch = &null_patch; -} - -static void -internal_refresh (void) -{ - makeDphaseTable (); - makeDphaseARTable (); - makeDphaseDRTable (); - pm_dphase = (uint32) (PM_SPEED * PM_DP_WIDTH / (clk / 72)); - am_dphase = (uint32) (AM_SPEED * AM_DP_WIDTH / (clk / 72)); -} - -static void maketables (uint32 c) -{ - if (c != clk) - { - clk = c; - makePmTable (); - makeAmTable (); - makeDB2LinTable (); - makeAdjustTable (); - makeTllTable (); - makeRksTable (); - makeSinTable (); - makeDefaultPatch (); - } - internal_refresh (); -} - -EMU2413 *EMU2413_new (uint32 new_clk) -{ - EMU2413 *opll; - int32 i; - - maketables (new_clk); - - opll = (EMU2413 *) calloc (sizeof (EMU2413), 1); - if (opll == NULL) - return NULL; - - for (i = 0; i < 19 * 2; i++) - memcpy(&opll->patch[i],&null_patch,sizeof(EMU2413_PATCH)); - - opll->mask = 0; - - EMU2413_reset (opll); - EMU2413_reset_patch (opll, 0); - - return opll; -} - - -void -EMU2413_delete (EMU2413 * opll) -{ - free (opll); -} - - -/* Reset patch datas by system default. */ -void -EMU2413_reset_patch (EMU2413 * opll, int32 type) -{ - int32 i; - - for (i = 0; i < 19 * 2; i++) - EMU2413_copyPatch (opll, i, &default_patch[type % EMU2413_TONE_NUM][i]); -} - -/* Reset whole of EMU2413 except patch datas. */ -void -EMU2413_reset (EMU2413 * opll) -{ - int32 i; - - if (!opll) - return; - - opll->adr = 0; - opll->out = 0; - - opll->pm_phase = 0; - opll->am_phase = 0; - - opll->noise_seed = 0xffff; - opll->mask = 0; - - for (i = 0; i <18; i++) - EMU2413_SLOT_reset(&opll->slot[i], i%2); - - for (i = 0; i < 9; i++) - { - opll->key_status[i] = 0; - setPatch (opll, i, 0); - } - - for (i = 0; i < 0x40; i++) - EMU2413_writeReg (opll, i, 0); -} - -/* Force Refresh (When external program changes some parameters). */ -void EMU2413_forceRefresh (EMU2413 * opll) -{ - int32 i; - - if (opll == NULL) - return; - - for (i = 0; i < 9; i++) - setPatch(opll,i,opll->patch_number[i]); - - for (i = 0; i < 18; i++) - { - UPDATE_PG (&opll->slot[i]); - UPDATE_RKS (&opll->slot[i]); - UPDATE_TLL (&opll->slot[i]); - UPDATE_WF (&opll->slot[i]); - UPDATE_EG (&opll->slot[i]); - } -} - -/********************************************************* - - Generate wave data - -*********************************************************/ -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 2PI). */ -#if ( SLOT_AMP_BITS - PG_BITS ) > 0 -#define wave2_2pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS )) -#else -#define wave2_2pi(e) ( (e) << ( PG_BITS - SLOT_AMP_BITS )) -#endif - -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 4PI). */ -#if ( SLOT_AMP_BITS - PG_BITS - 1 ) == 0 -#define wave2_4pi(e) (e) -#elif ( SLOT_AMP_BITS - PG_BITS - 1 ) > 0 -#define wave2_4pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 1 )) -#else -#define wave2_4pi(e) ( (e) << ( 1 + PG_BITS - SLOT_AMP_BITS )) -#endif - -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 8PI). */ -#if ( SLOT_AMP_BITS - PG_BITS - 2 ) == 0 -#define wave2_8pi(e) (e) -#elif ( SLOT_AMP_BITS - PG_BITS - 2 ) > 0 -#define wave2_8pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 2 )) -#else -#define wave2_8pi(e) ( (e) << ( 2 + PG_BITS - SLOT_AMP_BITS )) -#endif - -/* Update AM, PM unit */ -static void -update_ampm (EMU2413 * opll) -{ - opll->pm_phase = (opll->pm_phase + pm_dphase) & (PM_DP_WIDTH - 1); - opll->am_phase = (opll->am_phase + am_dphase) & (AM_DP_WIDTH - 1); - opll->lfo_am = amtable[HIGHBITS (opll->am_phase, AM_DP_BITS - AM_PG_BITS)]; - opll->lfo_pm = pmtable[HIGHBITS (opll->pm_phase, PM_DP_BITS - PM_PG_BITS)]; -} - -/* PG */ -INLINE static void calc_phase (EMU2413_SLOT * slot, int32 lfo) -{ - if (slot->patch->PM) - slot->phase += (slot->dphase * lfo) >> PM_AMP_BITS; - else - slot->phase += slot->dphase; - - slot->phase &= (DP_WIDTH - 1); - - slot->pgout = HIGHBITS (slot->phase, DP_BASE_BITS); -} - -/* Update Noise unit */ -static void -update_noise (EMU2413 * opll) -{ - if(opll->noise_seed&1) opll->noise_seed ^= 0x8003020; - opll->noise_seed >>= 1; -} - -/* EG */ -static void -calc_envelope (EMU2413_SLOT * slot, int32 lfo) -{ -#define S2E(x) (SL2EG((int32)(x/SL_STEP))<<(EG_DP_BITS-EG_BITS)) - - static uint32 SL[16] = { - S2E (0.0), S2E (3.0), S2E (6.0), S2E (9.0), S2E (12.0), S2E (15.0), S2E (18.0), S2E (21.0), - S2E (24.0), S2E (27.0), S2E (30.0), S2E (33.0), S2E (36.0), S2E (39.0), S2E (42.0), S2E (48.0) - }; - - uint32 egout; - - switch (slot->eg_mode) - { - case ATTACK: - egout = AR_ADJUST_TABLE[HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS)]; - slot->eg_phase += slot->eg_dphase; - if((EG_DP_WIDTH & slot->eg_phase)||(slot->patch->AR==15)) - { - egout = 0; - slot->eg_phase = 0; - slot->eg_mode = DECAY; - UPDATE_EG (slot); - } - break; - - case DECAY: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if (slot->eg_phase >= SL[slot->patch->SL]) - { - if (slot->patch->EG) - { - slot->eg_phase = SL[slot->patch->SL]; - slot->eg_mode = SUSHOLD; - UPDATE_EG (slot); - } - else - { - slot->eg_phase = SL[slot->patch->SL]; - slot->eg_mode = SUSTINE; - UPDATE_EG (slot); - } - } - break; - - case SUSHOLD: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - if (slot->patch->EG == 0) - { - slot->eg_mode = SUSTINE; - UPDATE_EG (slot); - } - break; - - case SUSTINE: - case RELEASE: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if (egout >= (1 << EG_BITS)) - { - slot->eg_mode = FINISH; - egout = (1 << EG_BITS) - 1; - } - break; - - case SETTLE: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if (egout >= (1 << EG_BITS)) - { - slot->eg_mode = ATTACK; - egout = (1 << EG_BITS) - 1; - UPDATE_EG(slot); - } - break; - - case FINISH: - egout = (1 << EG_BITS) - 1; - break; - - default: - egout = (1 << EG_BITS) - 1; - break; - } - - if (slot->patch->AM) - egout = EG2DB (egout + slot->tll) + lfo; - else - egout = EG2DB (egout + slot->tll); - - if (egout >= DB_MUTE) - egout = DB_MUTE - 1; - - slot->egout = egout | 3; -} - -/* CARRIOR */ -INLINE static int32 calc_slot_car (EMU2413_SLOT * slot, int32 fm) -{ - if (slot->egout >= (DB_MUTE - 1)) - { - slot->output[0] = 0; - } - else - { - slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout+wave2_8pi(fm))&(PG_WIDTH-1)] + slot->egout]; - } - - slot->output[1] = (slot->output[1] + slot->output[0]) >> 1; - return slot->output[1]; -} - -/* MODULATOR */ -INLINE static int32 calc_slot_mod (EMU2413_SLOT * slot) -{ - int32 fm; - - slot->output[1] = slot->output[0]; - - if (slot->egout >= (DB_MUTE - 1)) - { - slot->output[0] = 0; - } - else if (slot->patch->FB != 0) - { - fm = wave2_4pi (slot->feedback) >> (7 - slot->patch->FB); - slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout+fm)&(PG_WIDTH-1)] + slot->egout]; - } - else - { - slot->output[0] = DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout]; - } - - slot->feedback = (slot->output[1] + slot->output[0]) >> 1; - - return slot->feedback; - -} - -/* TOM */ -INLINE static int32 calc_slot_tom (EMU2413_SLOT * slot) -{ - if (slot->egout >= (DB_MUTE - 1)) - return 0; - - return DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout]; - -} - -/* SNARE */ -INLINE static int32 calc_slot_snare (EMU2413_SLOT * slot, uint32 noise) -{ - if(slot->egout>=(DB_MUTE-1)) - return 0; - - if(BIT(slot->pgout,7)) - return DB2LIN_TABLE[(noise?DB_POS(0.0):DB_POS(15.0))+slot->egout]; - else - return DB2LIN_TABLE[(noise?DB_NEG(0.0):DB_NEG(15.0))+slot->egout]; -} - -/* - TOP-CYM - */ -INLINE static int32 calc_slot_cym (EMU2413_SLOT * slot, uint32 pgout_hh) -{ - uint32 dbout; - - if (slot->egout >= (DB_MUTE - 1)) - return 0; - else if( - /* the same as fmopl.c */ - ((BIT(pgout_hh,PG_BITS-8)^BIT(pgout_hh,PG_BITS-1))|BIT(pgout_hh,PG_BITS-7)) ^ - /* different from fmopl.c */ - (BIT(slot->pgout,PG_BITS-7)&!BIT(slot->pgout,PG_BITS-5)) - ) - dbout = DB_NEG(3.0); - else - dbout = DB_POS(3.0); - - return DB2LIN_TABLE[dbout + slot->egout]; -} - -/* - HI-HAT -*/ -INLINE static int32 calc_slot_hat (EMU2413_SLOT *slot, int32 pgout_cym, uint32 noise) -{ - uint32 dbout; - - if (slot->egout >= (DB_MUTE - 1)) - return 0; - else if( - /* the same as fmopl.c */ - ((BIT(slot->pgout,PG_BITS-8)^BIT(slot->pgout,PG_BITS-1))|BIT(slot->pgout,PG_BITS-7)) ^ - /* different from fmopl.c */ - (BIT(pgout_cym,PG_BITS-7)&!BIT(pgout_cym,PG_BITS-5)) - ) - { - if(noise) - dbout = DB_NEG(12.0); - else - dbout = DB_NEG(24.0); - } - else - { - if(noise) - dbout = DB_POS(12.0); - else - dbout = DB_POS(24.0); - } - - return DB2LIN_TABLE[dbout + slot->egout]; -} - -static int32 calc (EMU2413 * opll) -{ - int32 inst = 0, perc = 0, out = 0; - int32 i; - - update_ampm (opll); - update_noise (opll); - - for (i = 0; i < 18; i++) - { - calc_phase(&opll->slot[i],opll->lfo_pm); - calc_envelope(&opll->slot[i],opll->lfo_am); - } - - for (i = 0; i < 6; i++) - if (!(opll->mask & EMU2413_MASK_CH (i)) && (CAR(opll,i)->eg_mode != FINISH)) - inst += calc_slot_car (CAR(opll,i), calc_slot_mod(MOD(opll,i))); - - /* CH6 */ - if (opll->patch_number[6] <= 15) - { - if (!(opll->mask & EMU2413_MASK_CH (6)) && (CAR(opll,6)->eg_mode != FINISH)) - inst += calc_slot_car (CAR(opll,6), calc_slot_mod(MOD(opll,6))); - } - else - { - if (!(opll->mask & EMU2413_MASK_BD) && (CAR(opll,6)->eg_mode != FINISH)) - perc += calc_slot_car (CAR(opll,6), calc_slot_mod(MOD(opll,6))); - } - - /* CH7 */ - if (opll->patch_number[7] <= 15) - { - if (!(opll->mask & EMU2413_MASK_CH (7)) && (CAR(opll,7)->eg_mode != FINISH)) - inst += calc_slot_car (CAR(opll,7), calc_slot_mod(MOD(opll,7))); - } - else - { - if (!(opll->mask & EMU2413_MASK_HH) && (MOD(opll,7)->eg_mode != FINISH)) - perc += calc_slot_hat (MOD(opll,7), CAR(opll,8)->pgout, opll->noise_seed&1); - if (!(opll->mask & EMU2413_MASK_SD) && (CAR(opll,7)->eg_mode != FINISH)) - perc -= calc_slot_snare (CAR(opll,7), opll->noise_seed&1); - } - - /* CH8 */ - if (opll->patch_number[8] <= 15) - { - if (!(opll->mask & EMU2413_MASK_CH(8)) && (CAR(opll,8)->eg_mode != FINISH)) - inst += calc_slot_car (CAR(opll,8), calc_slot_mod (MOD(opll,8))); - } - else - { - if (!(opll->mask & EMU2413_MASK_TOM) && (MOD(opll,8)->eg_mode != FINISH)) - perc += calc_slot_tom (MOD(opll,8)); - if (!(opll->mask & EMU2413_MASK_CYM) && (CAR(opll,8)->eg_mode != FINISH)) - perc -= calc_slot_cym (CAR(opll,8), MOD(opll,7)->pgout); - } - - out = inst + (perc << 1); - return (int32) out; -} - -int32 EMU2413_calc (EMU2413 * opll) -{ - return calc (opll); -} - -uint32 EMU2413_setMask (EMU2413 * opll, uint32 mask) -{ - uint32 ret; - - if (opll) - { - ret = opll->mask; - opll->mask = mask; - return ret; - } - else - return 0; -} - -uint32 EMU2413_toggleMask (EMU2413 * opll, uint32 mask) -{ - uint32 ret; - - if (opll) - { - ret = opll->mask; - opll->mask ^= mask; - return ret; - } - else - return 0; -} - -/**************************************************** - - I/O Ctrl - -*****************************************************/ - -void EMU2413_writeReg (EMU2413 * opll, uint32 reg, uint32 data) -{ - - int32 i, v, ch; - - data = data & 0xff; - reg = reg & 0x3f; - opll->reg[reg] = (uint8) data; - - switch (reg) - { - case 0x00: - opll->patch[0].AM = (data >> 7) & 1; - opll->patch[0].PM = (data >> 6) & 1; - opll->patch[0].EG = (data >> 5) & 1; - opll->patch[0].KR = (data >> 4) & 1; - opll->patch[0].ML = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_PG (MOD(opll,i)); - UPDATE_RKS (MOD(opll,i)); - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x01: - opll->patch[1].AM = (data >> 7) & 1; - opll->patch[1].PM = (data >> 6) & 1; - opll->patch[1].EG = (data >> 5) & 1; - opll->patch[1].KR = (data >> 4) & 1; - opll->patch[1].ML = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_PG (CAR(opll,i)); - UPDATE_RKS (CAR(opll,i)); - UPDATE_EG (CAR(opll,i)); - } - } - break; - - case 0x02: - opll->patch[0].KL = (data >> 6) & 3; - opll->patch[0].TL = (data) & 63; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_TLL(MOD(opll,i)); - } - } - break; - - case 0x03: - opll->patch[1].KL = (data >> 6) & 3; - opll->patch[1].WF = (data >> 4) & 1; - opll->patch[0].WF = (data >> 3) & 1; - opll->patch[0].FB = (data) & 7; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_WF(MOD(opll,i)); - UPDATE_WF(CAR(opll,i)); - } - } - break; - - case 0x04: - opll->patch[0].AR = (data >> 4) & 15; - opll->patch[0].DR = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x05: - opll->patch[1].AR = (data >> 4) & 15; - opll->patch[1].DR = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_EG(CAR(opll,i)); - } - } - break; - - case 0x06: - opll->patch[0].SL = (data >> 4) & 15; - opll->patch[0].RR = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x07: - opll->patch[1].SL = (data >> 4) & 15; - opll->patch[1].RR = (data) & 15; - for (i = 0; i < 9; i++) - { - if (opll->patch_number[i] == 0) - { - UPDATE_EG (CAR(opll,i)); - } - } - break; - - case 0x0e: - update_rhythm_mode (opll); - if (data & 32) - { - if (data & 0x10) - keyOn_BD (opll); - else - keyOff_BD (opll); - if (data & 0x8) - keyOn_SD (opll); - else - keyOff_SD (opll); - if (data & 0x4) - keyOn_TOM (opll); - else - keyOff_TOM (opll); - if (data & 0x2) - keyOn_CYM (opll); - else - keyOff_CYM (opll); - if (data & 0x1) - keyOn_HH (opll); - else - keyOff_HH (opll); - } - update_key_status (opll); - - UPDATE_ALL (MOD(opll,6)); - UPDATE_ALL (CAR(opll,6)); - UPDATE_ALL (MOD(opll,7)); - UPDATE_ALL (CAR(opll,7)); - UPDATE_ALL (MOD(opll,8)); - UPDATE_ALL (CAR(opll,8)); - - break; - - case 0x0f: - break; - - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - ch = reg - 0x10; - setFnumber (opll, ch, data + ((opll->reg[0x20 + ch] & 1) << 8)); - UPDATE_ALL (MOD(opll,ch)); - UPDATE_ALL (CAR(opll,ch)); - break; - - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - ch = reg - 0x20; - setFnumber (opll, ch, ((data & 1) << 8) + opll->reg[0x10 + ch]); - setBlock (opll, ch, (data >> 1) & 7); - setSustine (opll, ch, (data >> 5) & 1); - if (data & 0x10) - keyOn (opll, ch); - else - keyOff (opll, ch); - UPDATE_ALL (MOD(opll,ch)); - UPDATE_ALL (CAR(opll,ch)); - update_key_status (opll); - update_rhythm_mode (opll); - break; - - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - i = (data >> 4) & 15; - v = data & 15; - if ((opll->reg[0x0e] & 32) && (reg >= 0x36)) - { - switch (reg) - { - case 0x37: - setSlotVolume (MOD(opll,7), i << 2); - break; - case 0x38: - setSlotVolume (MOD(opll,8), i << 2); - break; - default: - break; - } - } - else - { - setPatch (opll, reg - 0x30, i); - } - setVolume (opll, reg - 0x30, v << 2); - UPDATE_ALL (MOD(opll,reg - 0x30)); - UPDATE_ALL (CAR(opll,reg - 0x30)); - break; - - default: - break; - - } -} - -void EMU2413_writeIO (EMU2413 * opll, uint32 adr, uint32 val) -{ - if (adr & 1) - EMU2413_writeReg (opll, opll->adr, val); - else - opll->adr = val; -} - -#ifndef EMU2413_COMPACTION -/* STEREO MODE (OPT) */ -void EMU2413_set_pan (EMU2413 * opll, uint32 ch, uint32 pan) -{ - opll->pan[ch & 15] = pan & 3; -} - -static void calc_stereo (EMU2413 * opll, int32 out[2]) -{ - int32 b[4] = { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */ - int32 r[4] = { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */ - int32 i; - - update_ampm (opll); - update_noise (opll); - - for(i=0;i<18;i++) - { - calc_phase(&opll->slot[i],opll->lfo_pm); - calc_envelope(&opll->slot[i],opll->lfo_am); - } - - for (i = 0; i < 6; i++) - if (!(opll->mask & EMU2413_MASK_CH (i)) && (CAR(opll,i)->eg_mode != FINISH)) - b[opll->pan[i]] += calc_slot_car (CAR(opll,i), calc_slot_mod (MOD(opll,i))); - - - if (opll->patch_number[6] <= 15) - { - if (!(opll->mask & EMU2413_MASK_CH (6)) && (CAR(opll,6)->eg_mode != FINISH)) - b[opll->pan[6]] += calc_slot_car (CAR(opll,6), calc_slot_mod (MOD(opll,6))); - } - else - { - if (!(opll->mask & EMU2413_MASK_BD) && (CAR(opll,6)->eg_mode != FINISH)) - r[opll->pan[9]] += calc_slot_car (CAR(opll,6), calc_slot_mod (MOD(opll,6))); - } - - if (opll->patch_number[7] <= 15) - { - if (!(opll->mask & EMU2413_MASK_CH (7)) && (CAR (opll,7)->eg_mode != FINISH)) - b[opll->pan[7]] += calc_slot_car (CAR (opll,7), calc_slot_mod (MOD (opll,7))); - } - else - { - if (!(opll->mask & EMU2413_MASK_HH) && (MOD (opll,7)->eg_mode != FINISH)) - r[opll->pan[10]] += calc_slot_hat (MOD (opll,7), CAR(opll,8)->pgout, opll->noise_seed&1); - if (!(opll->mask & EMU2413_MASK_SD) && (CAR (opll,7)->eg_mode != FINISH)) - r[opll->pan[11]] -= calc_slot_snare (CAR (opll,7), opll->noise_seed&1); - } - - if (opll->patch_number[8] <= 15) - { - if (!(opll->mask & EMU2413_MASK_CH (8)) && (CAR (opll,8)->eg_mode != FINISH)) - b[opll->pan[8]] += calc_slot_car (CAR (opll,8), calc_slot_mod (MOD (opll,8))); - } - else - { - if (!(opll->mask & EMU2413_MASK_TOM) && (MOD (opll,8)->eg_mode != FINISH)) - r[opll->pan[12]] += calc_slot_tom (MOD (opll,8)); - if (!(opll->mask & EMU2413_MASK_CYM) && (CAR (opll,8)->eg_mode != FINISH)) - r[opll->pan[13]] -= calc_slot_cym (CAR (opll,8), MOD(opll,7)->pgout); - } - - out[1] = (b[1] + b[3] + ((r[1] + r[3]) << 1)); - out[0] = (b[2] + b[3] + ((r[2] + r[3]) << 1)); -} - -void EMU2413_calc_stereo (EMU2413 * opll, int32 out[2]) -{ - calc_stereo (opll, out); -} -#endif /* EMU2413_COMPACTION */ diff --git a/libmednahawk/src/hw_sound/ym2413/emu2413.h b/libmednahawk/src/hw_sound/ym2413/emu2413.h deleted file mode 100644 index 7b1ac0644e..0000000000 --- a/libmednahawk/src/hw_sound/ym2413/emu2413.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef _EMU2413_H_ -#define _EMU2413_H_ - -#define PI 3.14159265358979323846 - -enum {EMU2413_2413_TONE = 0}; - -/* voice data */ -typedef struct { - uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ; -} EMU2413_PATCH ; - -/* slot */ -typedef struct { - - EMU2413_PATCH *patch; - - int32 type ; /* 0 : modulator 1 : carrier */ - - /* OUTPUT */ - int32 feedback ; - int32 output[2] ; /* Output value of slot */ - - /* for Phase Generator (PG) */ - uint32 *sintbl ; /* Wavetable */ - uint32 phase ; /* Phase */ - uint32 dphase ; /* Phase increment amount */ - uint32 pgout ; /* output */ - - /* for Envelope Generator (EG) */ - int32 fnum ; /* F-Number */ - int32 block ; /* Block */ - int32 volume ; /* Current volume */ - int32 sustine ; /* Sustine 1 = ON, 0 = OFF */ - uint32 tll ; /* Total Level + Key scale level*/ - uint32 rks ; /* Key scale offset (Rks) */ - int32 eg_mode ; /* Current state */ - uint32 eg_phase ; /* Phase */ - uint32 eg_dphase ; /* Phase increment amount */ - uint32 egout ; /* output */ - -} EMU2413_SLOT ; - -/* Mask */ -#define EMU2413_MASK_CH(x) (1<<(x)) -#define EMU2413_MASK_HH (1<<(9)) -#define EMU2413_MASK_CYM (1<<(10)) -#define EMU2413_MASK_TOM (1<<(11)) -#define EMU2413_MASK_SD (1<<(12)) -#define EMU2413_MASK_BD (1<<(13)) -#define EMU2413_MASK_RHYTHM ( EMU2413_MASK_HH | EMU2413_MASK_CYM | EMU2413_MASK_TOM | EMU2413_MASK_SD | EMU2413_MASK_BD ) - -/* opll */ -typedef struct -{ - - uint32 adr ; - int32 out ; - - uint32 pan[16]; - - /* Register */ - uint8 reg[0x40] ; - int32 slot_on_flag[18] ; - - /* Pitch Modulator */ - uint32 pm_phase ; - int32 lfo_pm ; - - /* Amp Modulator */ - int32 am_phase ; - int32 lfo_am ; - - /* Noise Generator */ - uint32 noise_seed ; - - /* Channel Data */ - int32 patch_number[9]; - int32 key_status[9] ; - - /* Slot */ - EMU2413_SLOT slot[18] ; - - /* Voice Data */ - EMU2413_PATCH patch[19*2] ; - int32 patch_update[2] ; /* flag for check patch update */ - - uint32 mask ; - -} EMU2413 ; - -/* Create Object */ -EMU2413 *EMU2413_new(uint32 clk); -void EMU2413_delete(EMU2413 *); - -/* Setup */ -void EMU2413_reset(EMU2413 *); -void EMU2413_reset_patch(EMU2413 *, int32); -void EMU2413_set_pan(EMU2413 *, uint32 ch, uint32 pan); - -/* Port/Register access */ -void EMU2413_writeIO(EMU2413 *, uint32 reg, uint32 val) ; -void EMU2413_writeReg(EMU2413 *, uint32 reg, uint32 val) ; - -/* Synthsize */ -int32 EMU2413_calc(EMU2413 *) ; -void EMU2413_calc_stereo(EMU2413 *, int32 out[2]) ; - -/* Misc */ -void EMU2413_setPatch(EMU2413 *, const uint8 *dump) ; -void EMU2413_copyPatch(EMU2413 *, int32, EMU2413_PATCH *) ; -void EMU2413_forceRefresh(EMU2413 *) ; - -/* Utility */ -void EMU2413_dump2patch(const uint8 *dump, EMU2413_PATCH *patch) ; -void EMU2413_patch2dump(const EMU2413_PATCH *patch, uint8 *dump) ; -void EMU2413_getDefaultPatch(int32 type, int32 num, EMU2413_PATCH *) ; - -/* Channel Mask */ -uint32 EMU2413_setMask(EMU2413 *, uint32 mask) ; -uint32 EMU2413_toggleMask(EMU2413 *, uint32 mask) ; - -#endif diff --git a/libmednahawk/src/hw_sound/ym2612/Ym2612_Emu.cpp b/libmednahawk/src/hw_sound/ym2612/Ym2612_Emu.cpp deleted file mode 100644 index d589031ff3..0000000000 --- a/libmednahawk/src/hw_sound/ym2612/Ym2612_Emu.cpp +++ /dev/null @@ -1,1146 +0,0 @@ -/* Copyright (C) 2002 Stéphane Dallongeville (gens AT consolemul.com) */ -/* Copyright (C) 2004-2006 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -details. You should have received a copy of the GNU Lesser General Public -License along with this module; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - -// This is mostly the original source in its C style and all. -// -// Somewhat optimized and simplified. Uses a template to generate the many -// variants of Update_Chan. Rewrote header file. In need of full rewrite by -// someone more familiar with FM sound and the YM2612. Has some inaccuracies -// compared to the Sega Genesis sound, particularly being mixed at such a -// high sample accuracy (the Genesis sounds like it has only 8 bit samples). -// - Shay - -// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ - -// Based on Gens 2.10 ym2612.c - -/* Some emulation improvements(ostensibly!) done for Mednafen: - Handle detune underflow correctly(hopefully. :b) - - Don't update active fnum/block(octave) on $A4-$A6, $AC-$AE writes; only on $A0-$A2, $A8-$AA writes. - - LFO FM applied to 11-bit fnum - - Rewritten EG code. - - Misc other stuff. -*/ - - -#include "Ym2612_Emu.h" - -#include -#include -#include -#include -#include -#include -#include - -const int output_bits = 14; - -#include "ym2612_opeg.inc" - -struct slot_t -{ - const int *DT; // parametre detune - int MUL; // parametre "multiple de frequence" - int KSR_S; // Key Scale Rate Shift = facteur de prise en compte du KSL dans la variations de l'enveloppe - - int Fcnt; // Frequency Count = compteur-frequence pour determiner l'amplitude actuelle (SIN[Finc >> 16]) - int INd; // input data of the slot = donnees en entree du slot - int AMS; // AMS depth level of this SLOT = degre de modulation de l'amplitude par le LFO - int AMSon; // AMS enable flag = drapeau d'activation de l'AMS - - OpEG eg; -}; - -struct channel_t -{ - int S0_OUT[4]; // anciennes sorties slot 0 (pour le feed back) - int LEFT; // LEFT enable flag - int RIGHT; // RIGHT enable flag - int ALGO; // Algorythm = determine les connections entre les operateurs - int FB; // shift count of self feed back = degre de "Feed-Back" du SLOT 1 (il est son unique entree) - int FMS; // Frequency Modulation Sensitivity of channel = degre de modulation de la frequence sur la voie par le LFO - int AMS; // Amplitude Modulation Sensitivity of channel = degre de modulation de l'amplitude sur la voie par le LFO - int FNUM[4]; // hauteur frequence de la voie (+ 3 pour le mode special) - int FOCT[4]; // octave de la voie (+ 3 pour le mode special) - int KC[4]; // Key Code = valeur fonction de la frequence (voir KSR pour les slots, KSR = KC >> KSR_S) - slot_t SLOT[4]; // four slot.operators = les 4 slots de la voie -}; - -struct state_t -{ - int Status; // YM2612 Status (timer overflow) - int TimerA; // timerA limit = valeur jusqu'à laquelle le timer A doit compter - int TimerAL; - int TimerAcnt; // timerA counter = valeur courante du Timer A - int TimerB; // timerB limit = valeur jusqu'à laquelle le timer B doit compter - int TimerBL; - int TimerBcnt; // timerB counter = valeur courante du Timer B - int Mode; // Mode actuel des voie 3 et 6 (normal / special) - int DAC; // DAC enabled flag - int DACdata; - - uint32 EGCycleCounter; - uint32 EGDivCounter; - - int LFOcnt; // LFO counter = compteur-frequence pour le LFO - int LFOinc; // LFO step counter = pas d'incrementation du compteur-frequence du LFO - // plus le pas est grand, plus la frequence est grande - - channel_t CHANNEL[Ym2612_Emu::channel_count]; // Les 6 voies du YM2612 - int REG[2][0x100]; // Sauvegardes des valeurs de tout les registres, c'est facultatif - // cela nous rend le debuggage plus facile -}; - -#ifndef PI -#define PI 3.14159265358979323846 -#endif - -// SIN_LBITS <= 16 -// LFO_HBITS <= 16 -// (SIN_LBITS + SIN_HBITS) <= 26 -// (LFO_LBITS + LFO_HBITS) <= 28 - -// DON'T CHANGE THESE TWO DEFINES. -#define SIN_HBITS 10 // Sinus phase counter int part -#define SIN_LBITS 10 // Sinus phase counter float part (best setting) - - - -#define ENV_HBITS 12 // Env phase counter int part - -#define LFO_HBITS 10 // LFO phase counter int part -#define LFO_LBITS (28 - LFO_HBITS) // LFO phase counter float part (best setting) - -#define SIN_LENGHT (1 << SIN_HBITS) -#define ENV_LENGHT (1 << ENV_HBITS) -#define LFO_LENGHT (1 << LFO_HBITS) - -#define TL_LENGHT (ENV_LENGHT * 3) // Env + TL scaling + LFO - -#define SIN_MASK (SIN_LENGHT - 1) -#define ENV_MASK (ENV_LENGHT - 1) -#define LFO_MASK (LFO_LENGHT - 1) - -#define ENV_STEP (96.0 / ENV_LENGHT) // ENV_MAX = 96 dB - -#define MAX_OUT_BITS (SIN_HBITS + SIN_LBITS + 2) // Modulation = -4 <--> +4 -#define MAX_OUT ((1 << MAX_OUT_BITS) - 1) - -#define PG_CUT_OFF ((int) (78.0 / ENV_STEP)) - -#define S0 0 // Stupid typo of the YM2612 -#define S1 2 -#define S2 1 -#define S3 3 - -struct tables_t -{ - short SIN_TAB [SIN_LENGHT]; // SINUS TABLE (offset into TL TABLE) - int DT_TAB [8] [32]; // Detune table - int LFO_INC_TAB [8]; // LFO step table - - short LFO_ENV_TAB [LFO_LENGHT]; // LFO AMS TABLE (adjusted for 11.8 dB) - int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus) -}; - -static const unsigned char DT_DEF_TAB [4][32] = -{ -// FD = 0 - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - }, - -// FD = 1 - { - 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, - 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 8, 8, 8, 8, - }, - -// FD = 2 - { - 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, - 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 16, 16, 16, 16, - }, - -// FD = 3 - { - 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, - 8 , 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 20, 22, 22, 22, 22 - } -}; - -static const unsigned char FKEY_TAB [16] = -{ - 0, 0, 0, 0, - 0, 0, 0, 1, - 2, 3, 3, 3, - 3, 3, 3, 3 -}; - -static const unsigned char LFO_AMS_TAB [4] = -{ - 31, 3, 1, 0 -}; - -static const unsigned int LFO_PhaseMod_Table[8][8] = -{ - { 0, 0, 0, 0, 0, 0, 0, 0 }, // 0 - { 0, 0, 0, 0, 1, 1, 1, 1 }, // 1 - { 0, 0, 0, 1, 1, 1, 2, 2 }, // 2 - { 0, 0, 1, 1, 2, 2, 3, 3 }, // 3 - { 0, 0, 1, 2, 2, 2, 3, 4 }, // 4 - { 0, 0, 2, 3, 4, 4, 5, 6 }, // 5 - { 0, 0, 4, 6, 8, 8,10,12 }, // 6 - { 0, 0, 8,12,16,16,20,24 }, // 7 -}; - -struct Ym2612_Impl -{ - enum { channel_count = Ym2612_Emu::channel_count }; - - state_t YM2612; - int mute_mask; - tables_t g; - - int SLOT_SET( int, int ); - int CHANNEL_SET( int, int ); - int YM_SET( int, int ); - - void set_rate(void); - void reset(); - void write0( int addr, int data ); - void write1( int addr, int data ); - int read(void); - void run_timer( void ); - void run( Ym2612_Emu::sample_t* ); -}; - -int Ym2612_Impl::SLOT_SET( int Adr, int data ) -{ - int nch = Adr & 3; - if ( nch == 3 ) - return 1; - - channel_t& ch = YM2612.CHANNEL [nch + (Adr & 0x100 ? 3 : 0)]; - slot_t& sl = ch.SLOT [(Adr >> 2) & 3]; - - switch ( Adr & 0xF0 ) - { - case 0x30: - if ( (sl.MUL = (data & 0x0F)) != 0 ) sl.MUL <<= 1; - else sl.MUL = 1; - - sl.DT = &g.DT_TAB [(data >> 4) & 7][0]; - - break; - - case 0x40: - sl.eg.SetTL(data & 0x7F); - break; - - case 0x50: - sl.eg.SetAR(data & 0x1F); - - sl.KSR_S = 3 - (data >> 6); - - break; - - case 0x60: - sl.eg.SetDR(data & 0x1F); - - if ( (sl.AMSon = (data & 0x80)) != 0 ) sl.AMS = ch.AMS; - else sl.AMS = 31; - break; - - case 0x70: - sl.eg.SetSR(data & 0x1F); - break; - - case 0x80: - sl.eg.SetSL((data >> 4) & 0x0F); - sl.eg.SetRR(data & 0x0F); - break; - - case 0x90: - // SSG-EG envelope shapes : - /* - E At Al H - - 1 0 0 0 \\\\ - 1 0 0 1 \___ - 1 0 1 0 \/\/ - 1 0 1 1 \ - 1 1 0 0 //// - 1 1 0 1 / - 1 1 1 0 /\/\ - 1 1 1 1 /___ - - E = SSG-EG enable - At = Start negate - Al = Altern - H = Hold */ - //data = 0; - //if(data & 8) - //printf("SSG: %02x, %02x\n", Adr, data); - sl.eg.SetSSG_EG(data & 0x0F); - break; - } - - return 0; -} - - -int Ym2612_Impl::CHANNEL_SET( int Adr, int data ) -{ - int num = Adr & 3; - if ( num == 3 ) - return 1; - - channel_t& ch = YM2612.CHANNEL [num + (Adr & 0x100 ? 3 : 0)]; - - switch ( Adr & 0xFC ) - { - case 0xA0: - { - int od = YM2612.REG[(bool)(Adr & 0x100)][(Adr & 0xFF) | 0x04]; - - ch.FNUM [0] = (ch.FNUM [0] & 0x0FF) + ((od & 0x07) << 8); - ch.FOCT [0] = (od & 0x38) >> 3; - } - - ch.FNUM [0] = (ch.FNUM [0] & 0x700) + data; - ch.KC [0] = (ch.FOCT [0] << 2) | FKEY_TAB [ch.FNUM [0] >> 7]; - break; - - case 0xA4: - break; - - case 0xA8: - if ( Adr < 0x100 ) - { - num++; - - { - int od = YM2612.REG[(bool)(Adr & 0x100)][(Adr & 0xFF) | 0x04]; - - YM2612.CHANNEL [2].FNUM [num] = (YM2612.CHANNEL [2].FNUM [num] & 0x0FF) + ((od & 0x07) << 8); - YM2612.CHANNEL [2].FOCT [num] = (od & 0x38) >> 3; - } - - YM2612.CHANNEL [2].FNUM [num] = (YM2612.CHANNEL [2].FNUM [num] & 0x700) + data; - YM2612.CHANNEL [2].KC [num] = (YM2612.CHANNEL [2].FOCT [num] << 2) | - FKEY_TAB [YM2612.CHANNEL [2].FNUM [num] >> 7]; - } - break; - - case 0xAC: - break; - - case 0xB0: - if ( ch.ALGO != (data & 7) ) - { - ch.ALGO = data & 7; - ch.SLOT[S0].eg.InstrParamChanged(); - ch.SLOT[S1].eg.InstrParamChanged(); - ch.SLOT[S2].eg.InstrParamChanged(); - ch.SLOT[S3].eg.InstrParamChanged(); - } - - ch.FB = 9 - ((data >> 3) & 7); // Real thing ? - -// if (ch.FB = ((data >> 3) & 7)) ch.FB = 9 - ch.FB; // Thunder force 4 (music stage 8), Gynoug, Aladdin bug sound... -// else ch.FB = 31; - break; - - case 0xB4: { - ch.LEFT = 0 - ((data >> 7) & 1); - ch.RIGHT = 0 - ((data >> 6) & 1); - - ch.AMS = LFO_AMS_TAB [(data >> 4) & 3]; - ch.FMS = data & 7; - - for ( int i = 0; i < 4; i++ ) - { - slot_t& sl = ch.SLOT [i]; - sl.AMS = (sl.AMSon ? ch.AMS : 31); - } - break; - } - } - - return 0; -} - - -int Ym2612_Impl::YM_SET(int Adr, int data) -{ - switch ( Adr ) - { - case 0x22: - //printf("%02x\n", data); - if (data & 8) // LFO enable - { - // Cool Spot music 1, LFO modified severals time which - // distord the sound, have to check that on a real genesis... - - if(YM2612.LFOinc == 0) - YM2612.LFOcnt = 0; - - YM2612.LFOinc = g.LFO_INC_TAB [data & 7]; - } - else - { - YM2612.LFOinc = 0; - } - //printf("%d\n", g.LFOcnt); - break; - - case 0x24: - YM2612.TimerA = (YM2612.TimerA & 0x003) | (((int) data) << 2); - - if (YM2612.TimerAL != (1024 - YM2612.TimerA)) - { - YM2612.TimerAcnt = YM2612.TimerAL = (1024 - YM2612.TimerA); - } - break; - - case 0x25: - YM2612.TimerA = (YM2612.TimerA & 0x3FC) | (data & 3); - - if (YM2612.TimerAL != (1024 - YM2612.TimerA)) - { - YM2612.TimerAcnt = YM2612.TimerAL = (1024 - YM2612.TimerA); - } - break; - - case 0x26: - YM2612.TimerB = data; - - if (YM2612.TimerBL != (256 - YM2612.TimerB) << 4) - { - YM2612.TimerBcnt = YM2612.TimerBL = (256 - YM2612.TimerB) << 4; - } - break; - - case 0x27: - // Parametre divers - // b7 = CSM MODE - // b6 = 3 slot mode - // b5 = reset b - // b4 = reset a - // b3 = timer enable b - // b2 = timer enable a - // b1 = load b - // b0 = load a - -// if ((data & 2) && (YM2612.Status & 2)) YM2612.TimerBcnt = YM2612.TimerBL; -// if ((data & 1) && (YM2612.Status & 1)) YM2612.TimerAcnt = YM2612.TimerAL; - -// YM2612.Status &= (~data >> 4); // Reset du Status au cas ou c'est demande - YM2612.Status &= (~data >> 4) & (data >> 2); // Reset Status - - YM2612.Mode = data; - break; - - case 0x28: { - int nch = data & 3; - if ( nch == 3 ) - return 1; - if ( data & 4 ) - nch += 3; - channel_t& ch = YM2612.CHANNEL [nch]; - - ch.SLOT[S0].eg.SetKONOFF((bool)(data & 0x10)); - ch.SLOT[S1].eg.SetKONOFF((bool)(data & 0x20)); - ch.SLOT[S2].eg.SetKONOFF((bool)(data & 0x40)); - ch.SLOT[S3].eg.SetKONOFF((bool)(data & 0x80)); - break; - } - case 0x2A: - YM2612.DACdata = ((int)data - 0x80) << 5; - break; - - case 0x2B: - YM2612.DAC = data & 0x80; // activation/desactivation du DAC - break; - } - - return 0; -} - -void Ym2612_Impl::set_rate(void) -{ - int i; - - // 144 = 12 * (prescale * 2) = 12 * 6 * 2 - // prescale set to 6 by default - double sample_rate = 53267; - - // Tableau TL : - // [0 - 4095] = +output [4095 - ...] = +output overflow (fill with 0) - // [12288 - 16383] = -output [16384 - ...] = -output overflow (fill with 0) - - for(i = 0; i < TL_LENGHT; i++) - { - double x = MAX_OUT; // Max output - - x /= pow(2.0, 16.0 * i / ENV_LENGHT); - - if(i >= 4096) - x = 0; - - //printf("%d: %f, %f\n", i, x, 20.0 * log10(x / MAX_OUT)); - //printf("%d\n", MAX_OUT); - - g.TL_TAB [i] = (int) x; - g.TL_TAB [TL_LENGHT + i] = -g.TL_TAB [i]; - } - - // Tableau SIN : - // g.SIN_TAB [x] [y] = sin(x) * y; - // x = phase and y = volume - - assert(SIN_LENGHT == 1024); - for(int x = 0; x < 256; x++) - { - double y = round(-log(sin((x+0.5)*M_PI/256/2))/log(2.0)*256); //zero 29-oct-2012 - changed log(2) to log(2.0) FOR RYPHECHA - - g.SIN_TAB [x] = g.SIN_TAB [(SIN_LENGHT / 2) - x - 1] = y; - g.SIN_TAB [(SIN_LENGHT / 2) + x] = g.SIN_TAB [SIN_LENGHT - x - 1] = TL_LENGHT + y; - } - - // Tableau LFO (LFO wav) : - assert(LFO_LENGHT == 1024); - for(i = 0; i < LFO_LENGHT; i++) - { - double x = sin(PI + (PI / 2) + 2.0 * PI * (double) (i) / (double) (LFO_LENGHT)); // Sinus - x += 1.0; - x /= 2.0; // positive only - x *= 11.8 / ENV_STEP; // ajusted to MAX enveloppe modulation - - g.LFO_ENV_TAB [i] = (int) x; - //printf("%d %d\n", i, (int)x); - } - - // Tableau Detune - - for(i = 0; i < 4; i++) - { - for (unsigned int kc = 0; kc < 32; kc++) - { - unsigned int y = DT_DEF_TAB[i][kc]; - - g.DT_TAB [i + 0][kc] = (int) y; - g.DT_TAB [i + 4][kc] = (int) -y; - } - } - - // Tableau LFO - g.LFO_INC_TAB [0] = (unsigned int) (3.98 * (double) (1 << (LFO_HBITS + LFO_LBITS)) / sample_rate); - g.LFO_INC_TAB [1] = (unsigned int) (5.56 * (double) (1 << (LFO_HBITS + LFO_LBITS)) / sample_rate); - g.LFO_INC_TAB [2] = (unsigned int) (6.02 * (double) (1 << (LFO_HBITS + LFO_LBITS)) / sample_rate); - g.LFO_INC_TAB [3] = (unsigned int) (6.37 * (double) (1 << (LFO_HBITS + LFO_LBITS)) / sample_rate); - g.LFO_INC_TAB [4] = (unsigned int) (6.88 * (double) (1 << (LFO_HBITS + LFO_LBITS)) / sample_rate); - g.LFO_INC_TAB [5] = (unsigned int) (9.63 * (double) (1 << (LFO_HBITS + LFO_LBITS)) / sample_rate); - g.LFO_INC_TAB [6] = (unsigned int) (48.1 * (double) (1 << (LFO_HBITS + LFO_LBITS)) / sample_rate); - g.LFO_INC_TAB [7] = (unsigned int) (72.2 * (double) (1 << (LFO_HBITS + LFO_LBITS)) / sample_rate); - - reset(); -} - - -Ym2612_Emu::Ym2612_Emu() -{ - impl = new Ym2612_Impl(); - impl->mute_mask = 0; - - memset( &impl->YM2612, 0, sizeof impl->YM2612 ); // fixme, don't memset() a non-POD type(OpEG) - impl->set_rate(); -} - -Ym2612_Emu::~Ym2612_Emu() -{ - delete impl; -} - -inline void Ym2612_Impl::write0( int opn_addr, int data ) -{ - assert( (unsigned) data <= 0xFF ); - - if ( opn_addr < 0x30 ) - { - YM2612.REG [0] [opn_addr] = data; - YM_SET( opn_addr, data ); - } - else - { - YM2612.REG [0] [opn_addr] = data; - - if ( opn_addr < 0xA0 ) - SLOT_SET( opn_addr, data ); - else - CHANNEL_SET( opn_addr, data ); - } -} - -inline void Ym2612_Impl::write1( int opn_addr, int data ) -{ - assert( (unsigned) data <= 0xFF ); - - if ( opn_addr >= 0x30 ) - { - YM2612.REG [1] [opn_addr] = data; - - if ( opn_addr < 0xA0 ) - SLOT_SET( opn_addr + 0x100, data ); - else - CHANNEL_SET( opn_addr + 0x100, data ); - } -} - -inline int Ym2612_Impl::read( void ) -{ - return(YM2612.Status); -} - -void Ym2612_Emu::reset() -{ - impl->reset(); -} - -void Ym2612_Impl::reset() -{ - YM2612.LFOcnt = 0; - YM2612.TimerA = 0; - YM2612.TimerAL = 0; - YM2612.TimerAcnt = 0; - YM2612.TimerB = 0; - YM2612.TimerBL = 0; - YM2612.TimerBcnt = 0; - YM2612.DAC = 0; - YM2612.DACdata = 0; - YM2612.Status = 0; - - YM2612.EGDivCounter = 0; - YM2612.EGCycleCounter = 0; - - int i; - for ( i = 0; i < channel_count; i++ ) - { - channel_t& ch = YM2612.CHANNEL [i]; - - ch.LEFT = ~0; - ch.RIGHT = ~0; - ch.ALGO = 0; - ch.FB = 31; - ch.FMS = 0; - ch.AMS = 0; - - for ( int j = 0 ;j < 4 ; j++ ) - { - ch.S0_OUT [j] = 0; - ch.FNUM [j] = 0; - ch.FOCT [j] = 0; - ch.KC [j] = 0; - - ch.SLOT [j].Fcnt = 0; - - ch.SLOT [j].eg.Reset(); - } - } - - for ( i = 0; i < 0x100; i++ ) - { - YM2612.REG [0] [i] = -1; - YM2612.REG [1] [i] = -1; - } - - for ( i = 0xB6; i >= 0xB4; i-- ) - { - write0( i, 0xC0 ); - write1( i, 0xC0 ); - } - - for ( i = 0xB2; i >= 0x22; i-- ) - { - write0( i, 0 ); - write1( i, 0 ); - } - - write0( 0x2A, 0x80 ); -} - -void Ym2612_Emu::write0( int addr, int data ) -{ - impl->write0( addr, data ); -} - -void Ym2612_Emu::write1( int addr, int data ) -{ - impl->write1( addr, data ); -} - -int Ym2612_Emu::read(void) -{ - return(impl->read()); -} - -void Ym2612_Emu::mute_voices( int mask ) { impl->mute_mask = mask; } - -template -struct ym2612_update_chan { - static void func( state_t& st, tables_t&, channel_t&, Ym2612_Emu::sample_t*); -}; - -typedef void (*ym2612_update_chan_t)( state_t& st, tables_t&, channel_t&, Ym2612_Emu::sample_t*); - -//void MDFN_DispMessage(const char *format, ...) throw(); - -template -void ym2612_update_chan::func( state_t& st, tables_t& g, channel_t& ch, - Ym2612_Emu::sample_t* buf ) -{ - // algo is a compile-time constant, so all conditions based on it are resolved - // during compilation - int CH_S0_OUT_1 = ch.S0_OUT [1]; - - int in0 = ch.SLOT [S0].Fcnt; - int in1 = ch.SLOT [S1].Fcnt; - int in2 = ch.SLOT [S2].Fcnt; - int in3 = ch.SLOT [S3].Fcnt; - -// MDFN_DispMessage("%08x", in2); - { - // envelope - int const env_LFO = g.LFO_ENV_TAB [(st.LFOcnt >> LFO_LBITS) & LFO_MASK]; - - #define CALC_EN( x ) \ - int temp##x = (ch.SLOT [S##x].eg.GetOutAttenuation() << 2) + (env_LFO >> ch.SLOT [S##x].AMS); \ - int en##x = (temp##x < 0x1000) ? temp##x : 0xFFF; \ - - CALC_EN( 0 ) - CALC_EN( 1 ) - CALC_EN( 2 ) - CALC_EN( 3 ) - - int const* const TL_TAB = g.TL_TAB; - - #define SINT( i, o ) (TL_TAB [g.SIN_TAB [(i)] + (o)]) - - // feedback - int CH_S0_OUT_0 = ch.S0_OUT [0]; - { - int temp = in0 + ((CH_S0_OUT_0 + CH_S0_OUT_1) >> ch.FB); - CH_S0_OUT_1 = CH_S0_OUT_0; - CH_S0_OUT_0 = SINT( (temp >> SIN_LBITS) & SIN_MASK, en0 ); - } - - int CH_OUTd; - if ( algo == 0 ) - { - int temp = in1 + CH_S0_OUT_1; - temp = in2 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en1 ); - temp = in3 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en2 ); - CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); - } - else if ( algo == 1 ) - { - int temp = in2 + CH_S0_OUT_1 + SINT( (in1 >> SIN_LBITS) & SIN_MASK, en1 ); - temp = in3 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en2 ); - CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); - } - else if ( algo == 2 ) - { - int temp = in2 + SINT( (in1 >> SIN_LBITS) & SIN_MASK, en1 ); - temp = in3 + CH_S0_OUT_1 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en2 ); - CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); - } - else if ( algo == 3 ) - { - int temp = in1 + CH_S0_OUT_1; - temp = in3 + SINT( (temp >> SIN_LBITS) & SIN_MASK, en1 ) + - SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ); - CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ); - } - else if ( algo == 4 ) - { - int temp = in3 + SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ); - CH_OUTd = SINT( (temp >> SIN_LBITS) & SIN_MASK, en3 ) + - SINT( ((in1 + CH_S0_OUT_1) >> SIN_LBITS) & SIN_MASK, en1 ); - //DO_LIMIT - } - else if ( algo == 5 ) - { - int temp = CH_S0_OUT_1; - CH_OUTd = SINT( ((in3 + temp) >> SIN_LBITS) & SIN_MASK, en3 ) + - SINT( ((in1 + temp) >> SIN_LBITS) & SIN_MASK, en1 ) + - SINT( ((in2 + temp) >> SIN_LBITS) & SIN_MASK, en2 ); - //DO_LIMIT - } - else if ( algo == 6 ) - { - CH_OUTd = SINT( (in3 >> SIN_LBITS) & SIN_MASK, en3 ) + - SINT( ((in1 + CH_S0_OUT_1) >> SIN_LBITS) & SIN_MASK, en1 ) + - SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ); - //DO_LIMIT - } - else if ( algo == 7 ) - { - CH_OUTd = SINT( (in3 >> SIN_LBITS) & SIN_MASK, en3 ) + - SINT( (in1 >> SIN_LBITS) & SIN_MASK, en1 ) + - SINT( (in2 >> SIN_LBITS) & SIN_MASK, en2 ) + CH_S0_OUT_1; - //DO_LIMIT - } - - CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; - - int t0 = buf [0] + (CH_OUTd & ch.LEFT); - int t1 = buf [1] + (CH_OUTd & ch.RIGHT); - - ch.S0_OUT [0] = CH_S0_OUT_0; - buf [0] = t0; - buf [1] = t1; - buf += 2; - } - - ch.S0_OUT [1] = CH_S0_OUT_1; - - ch.SLOT [S0].Fcnt = in0; - ch.SLOT [S1].Fcnt = in1; - ch.SLOT [S2].Fcnt = in2; - ch.SLOT [S3].Fcnt = in3; -} - -static const ym2612_update_chan_t UPDATE_CHAN [8] = { - &ym2612_update_chan<0>::func, - &ym2612_update_chan<1>::func, - &ym2612_update_chan<2>::func, - &ym2612_update_chan<3>::func, - &ym2612_update_chan<4>::func, - &ym2612_update_chan<5>::func, - &ym2612_update_chan<6>::func, - &ym2612_update_chan<7>::func -}; - -void Ym2612_Impl::run_timer(void) -{ - YM2612.CHANNEL[2].SLOT[0].eg.SetCSMKONOFF(false); - YM2612.CHANNEL[2].SLOT[1].eg.SetCSMKONOFF(false); - YM2612.CHANNEL[2].SLOT[2].eg.SetCSMKONOFF(false); - YM2612.CHANNEL[2].SLOT[3].eg.SetCSMKONOFF(false); - - if (YM2612.Mode & 1) // Timer A ON ? - { - YM2612.TimerAcnt--; - - if(YM2612.TimerAcnt <= 0) - { - // timer a overflow - YM2612.Status |= (YM2612.Mode & 0x04) >> 2; - YM2612.TimerAcnt += YM2612.TimerAL; - - if((YM2612.Mode & 0xC0) == 0x80) - { - YM2612.CHANNEL[2].SLOT[0].eg.SetCSMKONOFF(true); - YM2612.CHANNEL[2].SLOT[1].eg.SetCSMKONOFF(true); - YM2612.CHANNEL[2].SLOT[2].eg.SetCSMKONOFF(true); - YM2612.CHANNEL[2].SLOT[3].eg.SetCSMKONOFF(true); - } - } - } - - - if (YM2612.Mode & 2) // Timer B ON ? - { - YM2612.TimerBcnt--; - - if (YM2612.TimerBcnt <= 0) - { - // timer b overflow - YM2612.Status |= (YM2612.Mode & 0x08) >> 2; - YM2612.TimerBcnt += YM2612.TimerBL; - } - } -} -#include "../../math_ops.h" -void Ym2612_Impl::run( Ym2612_Emu::sample_t* out ) -{ - if ( YM2612.Mode & 3 ) - run_timer(); - - for(int i = 0; i < channel_count; i++) - { - Ym2612_Emu::sample_t tmp_out[2] = { 0, 0 }; - - UPDATE_CHAN[YM2612.CHANNEL [i].ALGO](YM2612, g, YM2612.CHANNEL [i], tmp_out); - - if(i == 5 && YM2612.DAC) - { - tmp_out[0] = YM2612.DACdata & YM2612.CHANNEL[5].LEFT; - tmp_out[1] = YM2612.DACdata & YM2612.CHANNEL[5].RIGHT; - } - - if(mute_mask & (1 << i)) - { - tmp_out[0] = tmp_out[1] = 0; - } - - out[0] += tmp_out[0]; - out[1] += tmp_out[1]; - } - - unsigned lfo_pm_position = ((YM2612.LFOcnt >> LFO_LBITS) & LFO_MASK) >> (LFO_HBITS - 5); - unsigned lfo_pm_tabposition = (lfo_pm_position & 0x8) ? (0x7 - (lfo_pm_position & 0x7)) : (lfo_pm_position & 0x7); - -// printf("%d %d\n", lfo_pm_position, lfo_pm_tabposition); - - for ( int chi = 0; chi < channel_count; chi++ ) - { - channel_t& ch = YM2612.CHANNEL [chi]; - - int i2 = 0; - if ( chi == 2 && (YM2612.Mode & 0x40) ) - i2 = 2; - - for ( int i = 0; i < 4; i++ ) - { - // static int seq [4] = { 2, 1, 3, 0 }; - // if ( i2 ) i2 = seq [i]; - slot_t& sl = ch.SLOT [i]; - int lfo_fnm_delta = 0; - - if(ch.FNUM[i2]) - { - int amp = LFO_PhaseMod_Table[ch.FMS][lfo_pm_tabposition]; - - lfo_fnm_delta = (amp << uilog2(ch.FNUM[i2])) >> 9; - - if(lfo_pm_position & 0x10) - lfo_fnm_delta = -lfo_fnm_delta; - - //if(lfo_fnm_delta) - // printf("%d %d: %d\n", chi, i, lfo_fnm_delta); - } - - int fnm = (ch.FNUM[i2] + lfo_fnm_delta) & 0x7FF; - int finc_tmp = (fnm << ch.FOCT [i2]) >> 1; - int finc = ((((finc_tmp + sl.DT[ch.KC[i2]]) & 0x1FFFF) * sl.MUL) >> 1) & 0xFFFFF; - int ksr = ch.KC [i2] >> sl.KSR_S; // keycode attenuation - - if(sl.eg.Run(YM2612.EGDivCounter == 0, YM2612.EGCycleCounter, ksr)) - sl.Fcnt += finc; - else - sl.Fcnt = 0; - - if ( i2 ) - i2 = (i2 ^ 2) ^ (i2 >> 1); - } - } - - //printf("%d %d\n", YM2612.EGDivCounter, YM2612.EGCycleCounter); - YM2612.EGDivCounter++; - if(YM2612.EGDivCounter == 3) - { - YM2612.EGDivCounter = 0; - YM2612.EGCycleCounter++; - } - - YM2612.LFOcnt += YM2612.LFOinc; -} - -void Ym2612_Emu::run( sample_t* out ) { impl->run( out ); } - - -void Ym2612_Emu::serialize(MDFN::LEPacker &slizer, bool load) -{ - state_t *s = &impl->YM2612; - tables_t *g = &impl->g; - const int cur_version = 0; - int version_saved = cur_version; - - slizer.set_read_mode(load); - - slizer ^ version_saved; - - if(version_saved != cur_version) - { - // ERROR - } - - for(int r0 = 0; r0 < 2; r0++) - { - for(int r1 = 0; r1 < 0x100; r1++) - { - slizer ^ s->REG[r0][r1]; - } - } - - slizer ^ s->Status; - slizer ^ s->TimerA; - slizer ^ s->TimerAL; - slizer ^ s->TimerAcnt; - slizer ^ s->TimerB; - slizer ^ s->TimerBL; - slizer ^ s->TimerBcnt; - slizer ^ s->Mode; - slizer ^ s->DAC; - slizer ^ s->DACdata; - slizer ^ s->EGCycleCounter; - slizer ^ s->EGDivCounter; - - slizer ^ s->LFOinc; - slizer ^ s->LFOcnt; - - - for(int ch = 0; ch < channel_count; ch++) - { - channel_t *c = &s->CHANNEL[ch]; - - for(int i = 0; i < 4; i++) - { - slizer ^ c->S0_OUT[i]; - } - - slizer ^ c->LEFT; - slizer ^ c->RIGHT; - slizer ^ c->ALGO; - slizer ^ c->FB; - slizer ^ c->FMS; - slizer ^ c->AMS; - - if(load) - { - c->ALGO &= 0x07; - c->FMS &= 0x07; - } - - for(int i = 0; i < 4; i++) - { - slizer ^ c->FNUM[i]; - } - - for(int i = 0; i < 4; i++) - { - slizer ^ c->FOCT[i]; - } - for(int i = 0; i < 4; i++) - { - slizer ^ c->KC[i]; - - if(load) - { - c->KC[i] &= 0x1F; - } - } - - for(int slot = 0; slot < 4; slot++) - { - slot_t *sl = &c->SLOT[slot]; - unsigned int tun = (unsigned int)(sl->DT - &g->DT_TAB[0][0]); - - slizer ^ tun; - - if(load) - { - tun &= 0x07; - sl->DT = &g->DT_TAB[tun][0]; - } - - slizer ^ sl->MUL; - slizer ^ sl->KSR_S; - - slizer ^ sl->Fcnt; - - slizer ^ sl->INd; - slizer ^ sl->AMS; - slizer ^ sl->AMSon; - - sl->eg.serialize(slizer, load); - } - } -} - - - -#if 0 - -#define SLOT_STATEREG(ch,sln) \ - SFVARN(s->CHANNEL[ch].SLOT[sln].DT, "DT"), \ - SFVARN(s->CHANNEL[ch].SLOT[sln].MUL, "MUL"), \ - SFVARN(s->CHANNEL[ch].SLOT[sln].KSR_S, "KSR_S"), \ - SFVARN(s->CHANNEL[ch].SLOT[sln].Fcnt, "Fcnt"), \ - SFVARN(s->CHANNEL[ch].SLOT[sln].INd, "INd"), \ - SFVARN(s->CHANNEL[ch].SLOT[sln].AMS, "AMS"), \ - SFVARN(s->CHANNEL[ch].SLOT[sln].AMSon, "AMSon"), - -#define CH_STATEREG(ch) SFARRAY32N(s->CHANNEL[ch].S0_OUT, 4, "S0_OUT"), \ - SFVARN(s->CHANNEL[ch].LEFT, "LEFT"), \ - SFVARN(s->CHANNEL[ch].RIGHT, "RIGHT"), \ - SFVARN(s->CHANNEL[ch].ALGO, "ALGO"), \ - SFVARN(s->CHANNEL[ch].FB, "FB"), \ - SFVARN(s->CHANNEL[ch].FMS, "FMS"), \ - SFVARN(s->CHANNEL[ch].AMS, "AMS"), \ - SFARRAY32N(s->CHANNEL[ch].FNUM, 4, "FNUM"), \ - SFARRAY32N(s->CHANNEL[ch].FOCT, 4, "FOCT"), \ - SFARRAY32N(s->CHANNEL[ch].KC, 4, "KC"), \ - SLOT_STATEREG(ch,0) \ - SLOT_STATEREG(ch,1) \ - SLOT_STATEREG(ch,2) \ - SLOT_STATEREG(ch,3) - -// EG here - -#define STATEREG(n) SFVARN(s->n, #n), - -int Ym2612_Emu::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - state_t *s = &impl->YM2612; - tables_t *g = &impl->g; - - SFORMAT StateRegs[] = - { - STATEREG(Status) - STATEREG(TimerA) - STATEREG(TimerAL) - STATEREG(TimerAcnt) - STATEREG(TimerB) - STATEREG(TimerBL) - STATEREG(TimerBcnt) - STATEREG(Mode) - STATEREG(DAC) - STATEREG(DACdata) - STATEREG(EGCycleCounter) - STATEREG(EGDivCounter) - - CH_STATEREG(0) - CH_STATEREG(1) - CH_STATEREG(2) - CH_STATEREG(3) - CH_STATEREG(4) - CH_STATEREG(5) - - SFARRAY32N(&s->REG[0][0], sizeof(s->REG) / sizeof(s->REG[0][0]), "REGS"), - SFEND - }; - -} - -#undef SLOT_STATEREG -#undef CH_STATEREG -#undef STATEREG - -#endif diff --git a/libmednahawk/src/hw_sound/ym2612/Ym2612_Emu.h b/libmednahawk/src/hw_sound/ym2612/Ym2612_Emu.h deleted file mode 100644 index 74ded0369f..0000000000 --- a/libmednahawk/src/hw_sound/ym2612/Ym2612_Emu.h +++ /dev/null @@ -1,39 +0,0 @@ -// YM2612 FM sound chip emulator interface -#ifndef YM2612_EMU_H -#define YM2612_EMU_H - -#include "../../mednafen.h" -#include "../../lepacker.h" - -struct Ym2612_Impl; - -class Ym2612_Emu { - Ym2612_Impl* impl; -public: - Ym2612_Emu(); - ~Ym2612_Emu(); - - // Reset to power-up state - void reset(); - - // Mute voice n if bit n (1 << n) of mask is set - enum { channel_count = 6 }; - void mute_voices( int mask ); - - // Write addr to register 0 then data to register 1 - void write0( int addr, int data ); - - // Write addr to register 2 then data to register 3 - void write1( int addr, int data ); - - int read(void); - - // Run and add nt samples into current output buffer contents - typedef short sample_t; - enum { out_chan_count = 2 }; // stereo - void run( sample_t* out ); - - void serialize(MDFN::LEPacker &slizer, bool load); -}; - -#endif diff --git a/libmednahawk/src/hw_sound/ym2612/ym2612_opeg.inc b/libmednahawk/src/hw_sound/ym2612/ym2612_opeg.inc deleted file mode 100644 index ffce718599..0000000000 --- a/libmednahawk/src/hw_sound/ym2612/ym2612_opeg.inc +++ /dev/null @@ -1,400 +0,0 @@ -class OpEG -{ - public: - - OpEG(); - ~OpEG(); - - void serialize(MDFN::LEPacker &slizer, bool load); - - void Reset(void); - - void SetKONOFF(bool); - void SetCSMKONOFF(bool); - void InstrParamChanged(void); - - bool Run(bool div3_run_eg, unsigned GlobalEGCycleCounter, unsigned ksr); - - void SetTL(unsigned); - void SetSL(unsigned); - void SetAR(unsigned); - void SetDR(unsigned); - void SetSR(unsigned); - void SetRR(unsigned); - void SetSSG_EG(unsigned); - - uint32 GetOutAttenuation(void); - - // - // - // - private: - - void CheckPhaseAdvance(void); - unsigned CalcRate(unsigned ksr); - - bool NeedFullKON; - bool KONOFF; - bool CSMKONOFF; - bool LA_OT_KONOFF; - uint8 TL, SL; - uint8 SSG_EG; - - union - { - struct - { - uint8 AR, DR, SR, RR; // Note: RR is stored (<< 1) | 1 here - }; - uint8 RawRates[4]; - }; - - unsigned CurPhase; - signed Attenuation; - bool SSGInvert; - - enum - { - ADSR_ATTACK = 0, - ADSR_DECAY = 1, - ADSR_SUSTAIN = 2, - ADSR_RELEASE = 3 - }; - #define SSGEG_MASK_HOLD 0x01 - #define SSGEG_MASK_ALTERNATE 0x02 - #define SSGEG_MASK_ATTACK 0x04 - #define SSGEG_MASK_ENABLE 0x08 -}; - -OpEG::OpEG() -{ - Reset(); -} - -OpEG::~OpEG() -{ - - -} - -void OpEG::serialize(MDFN::LEPacker &slizer, bool load) -{ - slizer ^ KONOFF; - slizer ^ CSMKONOFF; - slizer ^ LA_OT_KONOFF; - slizer ^ NeedFullKON; - slizer ^ TL; - slizer ^ SL; - slizer ^ SSG_EG; - - slizer ^ AR; - slizer ^ DR; - slizer ^ SR; - slizer ^ RR; - - slizer ^ CurPhase; - slizer ^ Attenuation; - slizer ^ SSGInvert; -} - -void OpEG::Reset(void) -{ - TL = 0; - SL = 0; - SSG_EG = 0; - - AR = 0; - DR = 0; - SR = 0; - RR = 1; - - CurPhase = ADSR_RELEASE; - Attenuation = 0x3FF; - SSGInvert = false; - KONOFF = false; - CSMKONOFF = false; - LA_OT_KONOFF = false; - - NeedFullKON = false; -} - - -void OpEG::InstrParamChanged(void) -{ - NeedFullKON = true; -} - -void OpEG::SetCSMKONOFF(bool ns) -{ - CSMKONOFF = ns; -} - -void OpEG::SetKONOFF(bool ns) -{ - // printf("NS: %d\n", ns); - //if(LA_OT_KONOFF != (KONOFF | CSMKONOFF)) - // puts("IYEE :(\n\n"); - - KONOFF = ns; -} - - -void OpEG::SetTL(unsigned v) -{ - TL = v & 0x7F; -} - -void OpEG::SetSL(unsigned v) -{ - SL = v & 0x0F; -} - -void OpEG::SetAR(unsigned v) -{ - AR = v & 0x1F; - //if(LA_OT_KONOFF != (KONOFF | CSMKONOFF) || CurPhase != ADSR_RELEASE) - // puts("AR Evil"); -} - -void OpEG::SetDR(unsigned v) -{ - DR = v & 0x1F; - //if(LA_OT_KONOFF != (KONOFF | CSMKONOFF) || CurPhase != ADSR_RELEASE) - // puts("DR Evil"); -} - -void OpEG::SetSR(unsigned v) -{ - SR = v & 0x1F; - //if(LA_OT_KONOFF != (KONOFF | CSMKONOFF) || CurPhase != ADSR_RELEASE) - // puts("SR Evil"); -} - -void OpEG::SetRR(unsigned v) -{ - RR = ((v & 0x0F) << 1) | 1; - //if(LA_OT_KONOFF != (KONOFF | CSMKONOFF) || CurPhase != ADSR_RELEASE) - // puts("RR Evil"); -} - -void OpEG::SetSSG_EG(unsigned v) -{ - SSG_EG = v & 0xF; -} - -unsigned OpEG::CalcRate(unsigned ksr) -{ - unsigned int rate = ((RawRates[CurPhase] << 1) + (RawRates[CurPhase] ? ksr : 0)); - - if(rate > 0x3F) - rate = 0x3F; - - return(rate); -} - - -// See Mega Turrican track 3, and Flashback track 3. -void OpEG::CheckPhaseAdvance(void) -{ - if(CurPhase == ADSR_ATTACK) - { - if(Attenuation == 0) - { - CurPhase = ADSR_DECAY; - } - } - - - if(CurPhase == ADSR_DECAY) - { - if(Attenuation >= ((SL == 0x0F) ? 0x3FF : (SL << 5))) - { - CurPhase = ADSR_SUSTAIN; - } - } -} - -// -bool OpEG::Run(bool div3_run_eg, unsigned GlobalEGCycleCounter, unsigned ksr) -{ - bool ret = true; - bool combo_KONOFF = KONOFF | CSMKONOFF; - - if(combo_KONOFF != LA_OT_KONOFF) - { - if(combo_KONOFF) // Key on - { - //printf("Key on\n"); - ret = false; - - CurPhase = ADSR_ATTACK; - SSGInvert = false; - - if(NeedFullKON) - { - Attenuation = 0x3FF; - NeedFullKON = false; - } - - if(CalcRate(ksr) >= 0x3E) - { - Attenuation = 0; - } - CheckPhaseAdvance(); - } - else // Key off - { - //printf("Key off\n"); - CurPhase = ADSR_RELEASE; - - if((SSG_EG & 0x08) && (SSGInvert ^ (bool)(SSG_EG & SSGEG_MASK_ATTACK))) - { - Attenuation = (0x200 - Attenuation) & 0x3FF; - } - } - } - LA_OT_KONOFF = combo_KONOFF; - - if((SSG_EG & 0x08) && (Attenuation >= 0x200)) - { - if((SSG_EG & SSGEG_MASK_ALTERNATE) && (!(SSG_EG & SSGEG_MASK_HOLD) || !SSGInvert)) - { - SSGInvert = !SSGInvert; - } - - if(!(SSG_EG & SSGEG_MASK_ALTERNATE) && !(SSG_EG & SSGEG_MASK_HOLD)) - { - ret = false; - } - - if(CurPhase != ADSR_ATTACK) - { - if((CurPhase != ADSR_RELEASE) && !(SSG_EG & SSGEG_MASK_HOLD)) - { - ret = false; - - CurPhase = ADSR_ATTACK; - - //Attenuation = 0x3FF; - if(NeedFullKON) - { - Attenuation = 0x3FF; - NeedFullKON = false; - } - - if(CalcRate(ksr) >= 0x3E) - { - Attenuation = 0; - } - CheckPhaseAdvance(); - } - else if((CurPhase == ADSR_RELEASE) || !(SSGInvert ^ (bool)(SSG_EG & SSGEG_MASK_ATTACK))) - { - Attenuation = 0x3FF; - CheckPhaseAdvance(); - } - } - } - - - if(div3_run_eg) - { - static const uint8 counter_shift_table[0x40] = { - 11, 11, 11, 11, // 0-3 (0x00-0x03) - 10, 10, 10, 10, // 4-7 (0x04-0x07) - 9, 9, 9, 9, // 8-11 (0x08-0x0B) - 8, 8, 8, 8, // 12-15 (0x0C-0x0F) - 7, 7, 7, 7, // 16-19 (0x10-0x13) - 6, 6, 6, 6, // 20-23 (0x14-0x17) - 5, 5, 5, 5, // 24-27 (0x18-0x1B) - 4, 4, 4, 4, // 28-31 (0x1C-0x1F) - 3, 3, 3, 3, // 32-35 (0x20-0x23) - 2, 2, 2, 2, // 36-39 (0x24-0x27) - 1, 1, 1, 1, // 40-43 (0x28-0x2B) - 0, 0, 0, 0, // 44-47 (0x2C-0x2F) - 0, 0, 0, 0, // 48-51 (0x30-0x33) - 0, 0, 0, 0, // 52-55 (0x34-0x37) - 0, 0, 0, 0, // 56-59 (0x38-0x3B) - 0, 0, 0, 0, // 60-63 (0x3C-0x3F) - }; - - static const uint8 atten_inc_table[0x40][0x08] = { - { 0,0,0,0,0,0,0,0 }, { 0,0,0,0,0,0,0,0 }, { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,0,1,0,1 }, // 0-3 (0x00-0x03) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,0,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,0,1,1,1 }, // 4-7 (0x04-0x07) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,1,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,1,1,1,1 }, // 8-11 (0x08-0x0B) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,1,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,1,1,1,1 }, // 12-15 (0x0C-0x0F) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,1,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,1,1,1,1 }, // 16-19 (0x10-0x13) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,1,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,1,1,1,1 }, // 20-23 (0x14-0x17) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,1,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,1,1,1,1 }, // 24-27 (0x18-0x1B) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,1,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,1,1,1,1 }, // 28-31 (0x1C-0x1F) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,1,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,1,1,1,1 }, // 32-35 (0x20-0x23) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,1,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,1,1,1,1 }, // 36-39 (0x24-0x27) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,1,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,1,1,1,1 }, // 40-43 (0x28-0x2B) - { 0,1,0,1,0,1,0,1 }, { 0,1,0,1,1,1,0,1 }, { 0,1,1,1,0,1,1,1 }, { 0,1,1,1,1,1,1,1 }, // 44-47 (0x2C-0x2F) - { 1,1,1,1,1,1,1,1 }, { 1,1,1,2,1,1,1,2 }, { 1,2,1,2,1,2,1,2 }, { 1,2,2,2,1,2,2,2 }, // 48-51 (0x30-0x33) - { 2,2,2,2,2,2,2,2 }, { 2,2,2,4,2,2,2,4 }, { 2,4,2,4,2,4,2,4 }, { 2,4,4,4,2,4,4,4 }, // 52-55 (0x34-0x37) - { 4,4,4,4,4,4,4,4 }, { 4,4,4,8,4,4,4,8 }, { 4,8,4,8,4,8,4,8 }, { 4,8,8,8,4,8,8,8 }, // 56-59 (0x38-0x3B) - { 8,8,8,8,8,8,8,8 }, { 8,8,8,8,8,8,8,8 }, { 8,8,8,8,8,8,8,8 }, { 8,8,8,8,8,8,8,8 }, // 60-63 (0x3C-0x3F) - }; - - unsigned rate = CalcRate(ksr); - - if((GlobalEGCycleCounter & ((1 << counter_shift_table[rate]) - 1)) == 0) - { - unsigned sub_cycle = (GlobalEGCycleCounter >> counter_shift_table[rate]) & 0x07; - signed inc_amount = atten_inc_table[rate][sub_cycle]; - - if(CurPhase == ADSR_ATTACK) - { - if(rate < 0x3E) - { - Attenuation += ((~Attenuation) * inc_amount) >> 4; - if(Attenuation < 0) - { - //printf("%d\n", Attenuation); - Attenuation = 0; - } - } - } - else - { - if(SSG_EG & 0x8) - { - if(Attenuation < 0x200) - { - Attenuation += inc_amount * 4; - } - } - else - Attenuation += inc_amount; - } - - if(Attenuation > 0x3FF) - Attenuation = 0x3FF; - - CheckPhaseAdvance(); - } - } - - return(ret); -} - - -uint32 OpEG::GetOutAttenuation(void) -{ - unsigned ret; - - if((SSG_EG & 0x08) && (CurPhase != ADSR_RELEASE) && (SSGInvert ^ (bool)(SSG_EG & SSGEG_MASK_ATTACK))) - { - ret = ((0x200 - Attenuation) & 0x3FF); - } - else - ret = Attenuation & 0x3FF; - - ret += TL << 3; - - if(ret > 0x3FF) - ret = 0x3FF; - - return(ret); -} diff --git a/libmednahawk/src/hw_video/Makefile.am b/libmednahawk/src/hw_video/Makefile.am deleted file mode 100644 index b7da299b32..0000000000 --- a/libmednahawk/src/hw_video/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -AUTOMAKE_OPTIONS = subdir-objects -DEFS = -DLOCALEDIR=\"$(datadir)/locale\" @DEFS@ @MATH_OPTIMIZER_FLAGS@ -DEFAULT_INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/intl -I$(top_builddir)/include/blip -I$(top_srcdir) - -noinst_LIBRARIES = libmdfnhwvideo.a - -libmdfnhwvideo_a_SOURCES = huc6270/vdc.cpp - diff --git a/libmednahawk/src/hw_video/Makefile.in b/libmednahawk/src/hw_video/Makefile.in deleted file mode 100644 index 014925e200..0000000000 --- a/libmednahawk/src/hw_video/Makefile.in +++ /dev/null @@ -1,608 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -target_triplet = @target@ -subdir = src/hw_video -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ - $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/fcntl-o.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc2.m4 \ - $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intl.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ - $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ - $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ - $(top_srcdir)/m4/threadlib.m4 $(top_srcdir)/m4/uintmax_t.m4 \ - $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ - $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ - $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/include/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -LIBRARIES = $(noinst_LIBRARIES) -ARFLAGS = cru -AM_V_AR = $(am__v_AR_$(V)) -am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY)) -am__v_AR_0 = @echo " AR " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -libmdfnhwvideo_a_AR = $(AR) $(ARFLAGS) -libmdfnhwvideo_a_LIBADD = -am__dirstamp = $(am__leading_dot)dirstamp -am_libmdfnhwvideo_a_OBJECTS = huc6270/vdc.$(OBJEXT) -libmdfnhwvideo_a_OBJECTS = $(am_libmdfnhwvideo_a_OBJECTS) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) -am__v_lt_0 = --silent -LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CXXFLAGS) $(CXXFLAGS) -AM_V_CXX = $(am__v_CXX_$(V)) -am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) -am__v_CXX_0 = @echo " CXX " $@; -CXXLD = $(CXX) -CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ - $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CXXLD = $(am__v_CXXLD_$(V)) -am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) -am__v_CXXLD_0 = @echo " CXXLD " $@; -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(libmdfnhwvideo_a_SOURCES) -DIST_SOURCES = $(libmdfnhwvideo_a_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -ALSA_CFLAGS = @ALSA_CFLAGS@ -ALSA_LIBS = @ALSA_LIBS@ -AMTAR = @AMTAR@ -AM_CFLAGS = @AM_CFLAGS@ -AM_CXXFLAGS = @AM_CXXFLAGS@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ -CATOBJEXT = @CATOBJEXT@ -CC = @CC@ -CCAS = @CCAS@ -CCASDEPMODE = @CCASDEPMODE@ -CCASFLAGS = @CCASFLAGS@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DATADIRNAME = @DATADIRNAME@ -DEFS = -DLOCALEDIR=\"$(datadir)/locale\" @DEFS@ @MATH_OPTIMIZER_FLAGS@ -DEPDIR = @DEPDIR@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GBA_EXTRA_FLAGS = @GBA_EXTRA_FLAGS@ -GENCAT = @GENCAT@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GLIBC2 = @GLIBC2@ -GLIBC21 = @GLIBC21@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GREP = @GREP@ -HAVE_ASPRINTF = @HAVE_ASPRINTF@ -HAVE_NEWLOCALE = @HAVE_NEWLOCALE@ -HAVE_POSIX_PRINTF = @HAVE_POSIX_PRINTF@ -HAVE_SNPRINTF = @HAVE_SNPRINTF@ -HAVE_VISIBILITY = @HAVE_VISIBILITY@ -HAVE_WPRINTF = @HAVE_WPRINTF@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTOBJEXT = @INSTOBJEXT@ -INTLBISON = @INTLBISON@ -INTLLIBS = @INTLLIBS@ -INTLOBJS = @INTLOBJS@ -INTL_DEFAULT_VERBOSITY = @INTL_DEFAULT_VERBOSITY@ -INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -JACK_CFLAGS = @JACK_CFLAGS@ -JACK_LIBS = @JACK_LIBS@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBCDIO_CFLAGS = @LIBCDIO_CFLAGS@ -LIBCDIO_LIBS = @LIBCDIO_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBMULTITHREAD = @LIBMULTITHREAD@ -LIBOBJS = @LIBOBJS@ -LIBPTH = @LIBPTH@ -LIBPTH_PREFIX = @LIBPTH_PREFIX@ -LIBS = @LIBS@ -LIBTHREAD = @LIBTHREAD@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBC = @LTLIBC@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ -LTLIBOBJS = @LTLIBOBJS@ -LTLIBPTH = @LTLIBPTH@ -LTLIBTHREAD = @LTLIBTHREAD@ -MAKEINFO = @MAKEINFO@ -MATH_OPTIMIZER_FLAGS = @MATH_OPTIMIZER_FLAGS@ -MKDIR_P = @MKDIR_P@ -MMX_CFLAGS = @MMX_CFLAGS@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POSUB = @POSUB@ -PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ -RANLIB = @RANLIB@ -SDL_CFLAGS = @SDL_CFLAGS@ -SDL_CONFIG = @SDL_CONFIG@ -SDL_LIBS = @SDL_LIBS@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -SNDFILE_CFLAGS = @SNDFILE_CFLAGS@ -SNDFILE_LIBS = @SNDFILE_LIBS@ -SNES_EXTRA_CXXFLAGS = @SNES_EXTRA_CXXFLAGS@ -SNES_EXTRA_FLAGS = @SNES_EXTRA_FLAGS@ -SSE2_CFLAGS = @SSE2_CFLAGS@ -SSE3_CFLAGS = @SSE3_CFLAGS@ -SSE_CFLAGS = @SSE_CFLAGS@ -STRIP = @STRIP@ -TRIO_CFLAGS = @TRIO_CFLAGS@ -USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ -USE_NLS = @USE_NLS@ -VERSION = @VERSION@ -WARNING_FLAGS = @WARNING_FLAGS@ -WINDRES = @WINDRES@ -WOE32 = @WOE32@ -WOE32DLL = @WOE32DLL@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -XMKMF = @XMKMF@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target = @target@ -target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AUTOMAKE_OPTIONS = subdir-objects -DEFAULT_INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/intl -I$(top_builddir)/include/blip -I$(top_srcdir) -noinst_LIBRARIES = libmdfnhwvideo.a -libmdfnhwvideo_a_SOURCES = huc6270/vdc.cpp -all: all-am - -.SUFFIXES: -.SUFFIXES: .cpp .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/hw_video/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/hw_video/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) -huc6270/$(am__dirstamp): - @$(MKDIR_P) huc6270 - @: > huc6270/$(am__dirstamp) -huc6270/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) huc6270/$(DEPDIR) - @: > huc6270/$(DEPDIR)/$(am__dirstamp) -huc6270/vdc.$(OBJEXT): huc6270/$(am__dirstamp) \ - huc6270/$(DEPDIR)/$(am__dirstamp) -libmdfnhwvideo.a: $(libmdfnhwvideo_a_OBJECTS) $(libmdfnhwvideo_a_DEPENDENCIES) - $(AM_V_at)-rm -f libmdfnhwvideo.a - $(AM_V_AR)$(libmdfnhwvideo_a_AR) libmdfnhwvideo.a $(libmdfnhwvideo_a_OBJECTS) $(libmdfnhwvideo_a_LIBADD) - $(AM_V_at)$(RANLIB) libmdfnhwvideo.a - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -rm -f huc6270/vdc.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@huc6270/$(DEPDIR)/vdc.Po@am__quote@ - -.cpp.o: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.cpp.lo: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ -@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LIBRARIES) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -rm -f huc6270/$(DEPDIR)/$(am__dirstamp) - -rm -f huc6270/$(am__dirstamp) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf huc6270/$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf huc6270/$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLIBRARIES ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libmednahawk/src/hw_video/huc6270/backup/vdc.cpp b/libmednahawk/src/hw_video/huc6270/backup/vdc.cpp deleted file mode 100644 index f6620ff438..0000000000 --- a/libmednahawk/src/hw_video/huc6270/backup/vdc.cpp +++ /dev/null @@ -1,1950 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* VDC emulation */ - -#include "mednafen/mednafen.h" -#include "mednafen/video.h" -#include "mednafen/lepacker.h" - -#include -#include -#include "vdc.h" - -#define VDC_DEBUG(x, ...) { } -//#define VDC_DEBUG(x, ...) printf(x ": HPhase=%d, HPhaseCounter=%d, RCRCount=%d\n", ## __VA_ARGS__, HPhase, HPhaseCounter, RCRCount); - -#define VDC_UNDEFINED(format, ...) { } -//#define VDC_UNDEFINED(format, ...) printf(format " RCRCount=%d" "\n", ## __VA_ARGS__, RCRCount) - -#define VDC_WARNING(format, ...) { } -//#define VDC_WARNING(format, ...) { printf(format "\n", ## __VA_ARGS__); } - -#define ULE_BG 1 -#define ULE_SPR 2 - -static const unsigned int bat_width_tab[4] = { 32, 64, 128, 128 }; -static const unsigned int bat_width_shift_tab[4] = { 5, 6, 7, 7 }; -static const unsigned int bat_height_tab[2] = { 32, 64 }; - -void VDC::FixTileCache(uint16 A) -{ - uint32 charname = (A >> 4); - uint32 y = (A & 0x7); - uint8 *tc = bg_tile_cache[charname][y]; - - uint32 bitplane01 = VRAM[y + charname * 16]; - uint32 bitplane23 = VRAM[y+ 8 + charname * 16]; - - for(int x = 0; x < 8; x++) - { - uint32 raw_pixel = ((bitplane01 >> x) & 1); - raw_pixel |= ((bitplane01 >> (x + 8)) & 1) << 1; - raw_pixel |= ((bitplane23 >> x) & 1) << 2; - raw_pixel |= ((bitplane23 >> (x + 8)) & 1) << 3; - tc[7 - x] = raw_pixel; - } -} - -// Some virtual vdc macros to make code simpler to read -#define M_vdc_HSW (HSR & 0x1F) // Horizontal Synchro Width -#define M_vdc_HDS ((HSR >> 8) & 0x7F) // Horizontal Display Start -#define M_vdc_HDW (HDR & 0x7F) // Horizontal Display Width -#define M_vdc_HDE ((HDR >> 8) & 0x7F) // Horizontal Display End - -#define M_vdc_VSW (VSR & 0x1F) // Vertical synchro width -#define M_vdc_VDS ((VSR >> 8) & 0xFF) // Vertical Display Start -#define M_vdc_VDW (VDR & 0x1FF) // Vertical Display Width(Height? :b) -#define M_vdc_VCR (VCR & 0xFF) - -#define M_vdc_EX ((CR >> 4) & 0x3) -#define M_vdc_TE ((CR >> 8) & 0x3) - -#define VDCS_CR 0x01 // Sprite #0 collision interrupt occurred -#define VDCS_OR 0x02 // sprite overflow "" "" -#define VDCS_RR 0x04 // RCR "" "" -#define VDCS_DS 0x08 // VRAM to SAT DMA completion interrupt occurred -#define VDCS_DV 0x10 // VRAM to VRAM DMA completion interrupt occurred -#define VDCS_VD 0x20 // Vertical blank interrupt occurred -#define VDCS_BSY 0x40 // VDC is waiting for a CPU access slot during the active display area?? - -uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 special_len) -{ - uint32 value = 0xDEADBEEF; - - switch(id) - { - case GSREG_SELECT: - value = select; - break; - - case GSREG_STATUS: - value = status; - break; - - case GSREG_MAWR: - value = MAWR; - break; - - case GSREG_MARR: - value = MARR; - break; - - case GSREG_CR: - value = CR; - - if(special) - { - trio_snprintf(special, special_len, "Sprite Hit IRQ: %s, Sprite Overflow IRQ: %s, RCR IRQ: %s, VBlank IRQ: %s, Sprites: %s, Background: %s", (value & 1) ? "On" : "Off", (value & 2) ? "On" : "Off", - (value & 4) ? "On" : "Off", (value & 8) ? "On" : "Off", (value & 0x40) ? "On" : "Off", (value & 0x80) ? "On" : "Off"); - } - break; - - case GSREG_RCR: - value = RCR; - break; - - case GSREG_BXR: - value = BXR; - break; - - case GSREG_BYR: - value = BYR; - break; - - case GSREG_MWR: - value = MWR; - - if(special) - { - trio_snprintf(special, special_len, "CG Mode: %d, BAT Width: %d(tiles), BAT Height: %d(tiles)", (int)(bool)(value & 0x80), - bat_width_tab[(value >> 4) & 0x3], - bat_height_tab[(value >> 6) & 0x1]); - } - break; - - case GSREG_HSR: - value = HSR; - if(special) - { - trio_snprintf(special, special_len, "HSW: %02x, HDS: %02x", value & 0x1F, (value >> 8) & 0x7F); - } - break; - - case GSREG_HDR: - value = HDR; - if(special) - { - trio_snprintf(special, special_len, "HDW: %02x, HDE: %02x", value & 0x7F, (value >> 8) & 0x7F); - } - break; - - - case GSREG_VSR: - value = VSR; - if(special) - { - trio_snprintf(special, special_len, "VSW: %02x, VDS: %02x", value & 0x1F, (value >> 8) & 0xFF); - } - break; - - case GSREG_VDR: - value = VDR; - break; - - case GSREG_VCR: - value = VCR; - break; - - case GSREG_DCR: - value = DCR; - if(special) - { - trio_snprintf(special, special_len, "SATB DMA IRQ: %s, VRAM DMA IRQ: %s, DMA Source Address: %s, DMA Dest Address: %s, Auto SATB DMA: %s", - (DCR & 0x1) ? "On" : "Off", (DCR & 0x2) ? "On" : "Off", (DCR & 0x4) ? "Decrement" : "Increment", (DCR & 0x8) ? "Decrement" : "Increment", - (DCR & 0x10) ? "On" : "Off"); - } - break; - - case GSREG_SOUR: - value = SOUR; - break; - - case GSREG_DESR: - value = DESR; - break; - - case GSREG_LENR: - value = LENR; - break; - - case GSREG_DVSSR: - value = DVSSR; - break; - } - - return(value); -} - -void VDC::SetRegister(const unsigned int id, const uint32 value) -{ - switch(id) - { - default: break; - - case GSREG_STATUS: - status = value & 0x3F; - break; - - case GSREG_SELECT: - select = value & 0x1F; - break; - - case GSREG_MAWR: - MAWR = value & 0xFFFF; - break; - - case GSREG_MARR: - MARR = value & 0xFFFF; - break; - - case GSREG_CR: - CR = value & 0xFFFF; - break; - - case GSREG_RCR: - RCR = value & 0x3FF; - break; - - case GSREG_BXR: - BXR = value & 0x3FF; - break; - - case GSREG_BYR: - BYR = value & 0x1FF; - break; - - case GSREG_MWR: - MWR = value & 0xFFFF; - break; - - case GSREG_HSR: - HSR = value & 0xFFFF; - break; - - case GSREG_HDR: - HDR = value & 0xFFFF; - break; - - case GSREG_VSR: - VSR = value & 0xFFFF; - break; - - case GSREG_VDR: - VDR = value & 0xFFFF; - break; - - case GSREG_VCR: - VCR = value & 0xFFFF; - break; - - case GSREG_DCR: - DCR = value & 0xFFFF; - break; - - case GSREG_SOUR: - SOUR = value & 0xFFFF; - break; - - case GSREG_DESR: - DESR = value & 0xFFFF; - break; - - case GSREG_LENR: - LENR = value & 0xFFFF; - break; - - case GSREG_DVSSR: - DVSSR = value & 0xFFFF; - break; - } -} - -bool VDC::ToggleLayer(int which) -{ - userle ^= 1 << which; - return((userle >> which) & 1); -} - -void VDC::RunSATDMA(int32 cycles, bool force_completion) -{ - assert(sat_dma_counter > 0); - - if(force_completion) - cycles = sat_dma_counter; - - sat_dma_counter -= cycles; - if(sat_dma_counter <= 0) - { - if(DCR & 0x01) - { - VDC_DEBUG("Sprite DMA IRQ"); - status |= VDCS_DS; - IRQHook(TRUE); - } - CheckAndCommitPending(); - burst_mode = true; - } -} - -void VDC::RunDMA(int32 cycles, bool force_completion) -{ - int num_transfers = 0; - - if(force_completion) - { - VDMA_CycleCounter = 0; - - num_transfers = 65536 * 2; - } - else - { - VDMA_CycleCounter += cycles; - num_transfers = VDMA_CycleCounter >> 1; - VDMA_CycleCounter -= num_transfers << 1; - } - - while(num_transfers--) - { - if(!DMAReadWrite) - { - if(SOUR >= VRAM_Size) - VDC_UNDEFINED("Unmapped VRAM DMA read"); - - DMAReadBuffer = VRAM[SOUR]; - //printf("DMA Read: %04x, %04x\n", SOUR, DMAReadBuffer); - } - else - { - if(DESR < VRAM_Size) - { - VRAM[DESR] = DMAReadBuffer; - FixTileCache(DESR); - } - - SOUR += (((DCR & 0x4) >> 1) ^ 2) - 1; - DESR += (((DCR & 0x8) >> 2) ^ 2) - 1; - LENR--; - - if(LENR == 0xFFFF) // DMA is done. - { - DMARunning = 0; // Clear this BEFORE CheckAndCommitPending() - - CheckAndCommitPending(); - - if(DCR & 0x02) - { - status |= VDCS_DV; - IRQHook(TRUE); - VDC_DEBUG("DMA IRQ"); - } - break; - } - } - DMAReadWrite ^= 1; - } -} - -/* - ChrlyMac: Was it you who determined exactly how many VDC clocks the SAT DMA took? - I know someone did, but I can't remember the results... - 1024 - It happens at the VDW->VCR transition -*/ - -void VDC::IncRCR(void) -{ - NeedBGYInc = true; - RCRCount++; - - VPhaseCounter--; - - if(VPhaseCounter <= 0) - { - VPhase = (VPhase + 1) % VPHASE_COUNT; - switch(VPhase) - { - case VPHASE_VDS: VPhaseCounter = VDS_cache + 2; - break; - - case VPHASE_VDW: VPhaseCounter = VDW_cache + 1; - //BG_YMoo = BYR - 1; - RCRCount = 0; - burst_mode = !(CR & 0xC0); - NeedVBIRQTest = true; - NeedSATDMATest = true; - - if(!burst_mode) - { - if(sat_dma_counter > 0) - { - printf("SAT DMA cancelled???\n"); - sat_dma_counter = 0; - CheckAndCommitPending(); - } - if(DMARunning) - { - printf("DMA Running Cancelled\n"); - DMARunning = false; - CheckAndCommitPending(); - } - } - break; - - case VPHASE_VCR: VPhaseCounter = VCR_cache; - break; - - case VPHASE_VSW: VPhaseCounter = VSW_cache + 1; - MWR_cache = MWR; - VDS_cache = M_vdc_VDS; - VSW_cache = M_vdc_VSW; - VDW_cache = M_vdc_VDW; - VCR_cache = M_vdc_VCR; - //VDC_WARNING("VSW Started"); - break; - } - } - - if(VPhase == VPHASE_VDW && !burst_mode) - { - FetchSpriteData(); - } - - if((int)RCRCount == ((int)RCR - 0x40) && (CR & 0x04)) - { - VDC_DEBUG("RCR IRQ"); - status |= VDCS_RR; - IRQHook(TRUE); - } -} - -void VDC::DoVBIRQTest(void) -{ - if(CR & 0x08) - { - VDC_DEBUG("VBlank IRQ"); - status |= VDCS_VD; - IRQHook(TRUE); - } -} - -static const int Cycles_Between_RCRIRQ_And_HDWEnd = 4; - -int VDC::TimeFromHDSStartToBYRLatch(void) -{ - int ret = 1; - - if(HDS_cache > 2) - ret += ((HDS_cache + 1) * 8) - 24 + 2; - - - //printf("%d, %d\n", HDS_cache, ret); - - return(ret); -} - -int VDC::TimeFromBYRLatchToBXRLatch(void) -{ - int ret = 2; - - if(HDS_cache > 2) - ret = 1; - - return(ret); -} - -void VDC::HDS_Start(void) -{ - if(NeedRCRInc) - { - if(NeedBGYInc) - { - NeedBGYInc = false; - if(0 == RCRCount) - BG_YMoo = BYR; - else - BG_YMoo++; - } - - IncRCR(); - NeedRCRInc = false; - } - - if(sprite_cg_fetch_counter > 0) - { - VDC_WARNING("Sprite truncation on %d. Wanted sprites: %d, cycles needed but not left: %d\n", RCRCount, active_sprites, sprite_cg_fetch_counter); - sprite_cg_fetch_counter = 0; - CheckAndCommitPending(); - } - - HSW_cache = M_vdc_HSW; - HDS_cache = M_vdc_HDS; - HDW_cache = M_vdc_HDW; - HDE_cache = M_vdc_HDE; - - VDC_DEBUG("HDS Start! HSW: %d, HDW: %d, HDW: %d, HDE: %d\n", HSW_cache, HDS_cache, HDW_cache, HDE_cache); - - CR_cache = CR; - - HPhase = HPHASE_HDS; - HPhaseCounter = TimeFromHDSStartToBYRLatch(); -} - -int32 VDC::HSync(bool hb) -{ - if(M_vdc_EX) - { - in_exhsync = 0; - return(CalcNextEvent()); - } - in_exhsync = hb; - - if(hb) // Going into hsync - { - mystery_counter = 48; - mystery_phase = false; - } - else // Leaving hsync - { - HPhase = HPHASE_HSW; - HPhaseCounter = 8; - - //HDS_Start(); - //HPhaseCounter += 8; - - pixel_copy_count = 0; - } - - - return(CalcNextEvent()); -} - -int32 VDC::VSync(bool vb) -{ - if(M_vdc_EX >= 0x2) - { - in_exvsync = 0; - return(CalcNextEvent()); - } - in_exvsync = vb; - - //printf("VBlank: %d\n", vb); - if(vb) // Going into vsync - { - NeedRCRInc = false; - NeedBGYInc = false; -/* if(NeedRCRInc) - { - IncRCR(); - NeedRCRInc = false; - } -*/ - MWR_cache = MWR; - - VDS_cache = M_vdc_VDS; - VSW_cache = M_vdc_VSW; - VDW_cache = M_vdc_VDW; - VCR_cache = M_vdc_VCR; - - VPhase = VPHASE_VSW; - VPhaseCounter = VSW_cache + 1; - } - else // Leaving vsync - { - - } - return(CalcNextEvent()); -} - -//int32 VDC::Run(int32 clocks, bool hs, bool vs, uint16 *pixels, bool skip) -int32 VDC::Run(int32 clocks, uint16 *pixels, bool skip) -{ - //uint16 *spixels = pixels; - - //puts("Run begin"); - //fflush(stdout); - - while(clocks > 0) - { - int32 chunk_clocks = clocks; - - if(chunk_clocks > HPhaseCounter) - { - chunk_clocks = HPhaseCounter; - } - - if(sat_dma_counter > 0 && chunk_clocks > sat_dma_counter) - chunk_clocks = sat_dma_counter; - - if(sprite_cg_fetch_counter > 0 && chunk_clocks > sprite_cg_fetch_counter) - chunk_clocks = sprite_cg_fetch_counter; - - if(mystery_counter > 0 && chunk_clocks > mystery_counter) - chunk_clocks = mystery_counter; - - if(mystery_counter > 0) - { - mystery_counter -= chunk_clocks; - if(mystery_counter <= 0) - { - mystery_phase = !mystery_phase; - if(mystery_phase) - mystery_counter = 16; - else - CheckAndCommitPending(); - } - } - - if(sprite_cg_fetch_counter > 0) - { - sprite_cg_fetch_counter -= chunk_clocks; - if(sprite_cg_fetch_counter <= 0) - CheckAndCommitPending(); - } - - if(VPhase != VPHASE_VDW) - { - if(NeedSATDMATest) - { - NeedSATDMATest = false; - if(SATBPending || (DCR & 0x10)) - { - SATBPending = 0; - - sat_dma_counter = 1024; - - if(DVSSR > (VRAM_Size - 0x100)) - VDC_UNDEFINED("Unmapped VRAM DVSSR DMA read"); - - if(DVSSR < VRAM_Size) - { - uint32 len = 256; - if(DVSSR > (VRAM_Size - 0x100)) - len = VRAM_Size - DVSSR; - memcpy(SAT, &VRAM[DVSSR], len * sizeof(uint16)); - } - } - } - } - - - - - if(DMAPending && burst_mode) - { - VDC_DEBUG("DMA Started"); - DMAPending = false; - DMARunning = true; - VDMA_CycleCounter = 0; - DMAReadWrite = 0; - } - - if(sat_dma_counter > 0) - RunSATDMA(chunk_clocks); - else if(DMARunning) - RunDMA(chunk_clocks); - - if(pixel_copy_count > 0) - { - if(!skip) - { - for(int i = 0; i < chunk_clocks; i++) - pixels[i] = linebuf[pixel_desu + i]; - //memcpy(pixels, linebuf + pixel_desu, chunk_clocks * sizeof(uint16)); - - if(M_vdc_TE == 0x1) - for(int i = 0; i < chunk_clocks; i++) - pixels[i] |= VDC_DISP_OUT_MASK; - } - - pixel_desu += chunk_clocks; - pixel_copy_count -= chunk_clocks; - } - else - { - uint16 pix = 0x100; - - if(M_vdc_TE == 0x1) - { - if(HPhase != HPHASE_HDS && HPhase != HPHASE_HDS_PART2 && HPhase != HPHASE_HDS_PART3) - pix |= VDC_DISP_OUT_MASK; - } - - if(HPhase == HPHASE_HSW) - { - if(M_vdc_EX >= 0x1) - pix |= VDC_HSYNC_OUT_MASK; - - if(M_vdc_TE >= 0x2) - pix |= VDC_DISP_OUT_MASK; - } - if(VPhase == VPHASE_VSW && M_vdc_EX >= 0x2) - pix |= VDC_VSYNC_OUT_MASK; - - if(!(userle & 1)) - pix |= VDC_BGDISABLE_OUT_MASK; - - if(!skip) - { - for(int i = 0; i < chunk_clocks; i++) - pixels[i] = pix; - } - } - - HPhaseCounter -= chunk_clocks; - - assert(HPhaseCounter >= 0); - - while(HPhaseCounter <= 0) - { - HPhase = (HPhase + 1) % HPHASE_COUNT; - - switch(HPhase) - { - case HPHASE_HDS: HDS_Start(); - break; - - - case HPHASE_HDS_PART2: - HPhaseCounter = TimeFromBYRLatchToBXRLatch(); - - if(NeedBGYInc) - { - NeedBGYInc = false; - - if(0 == RCRCount) - BG_YMoo = BYR; - else - BG_YMoo++; - } - BG_YOffset = BG_YMoo; - break; - - case HPHASE_HDS_PART3: - HPhaseCounter = (HDS_cache + 1) * 8 - TimeFromHDSStartToBYRLatch() - TimeFromBYRLatchToBXRLatch(); - - assert(HPhaseCounter > 0); - - BG_XOffset = BXR; - break; - - case HPHASE_HDW: - NeedRCRInc = true; - if(VPhase != VPHASE_VDW && NeedVBIRQTest) - { - DoVBIRQTest(); - NeedVBIRQTest = false; - } - CheckAndCommitPending(); - - HPhaseCounter = (HDW_cache + 1) * 8 - Cycles_Between_RCRIRQ_And_HDWEnd; - if(VPhase == VPHASE_VDW) - { - if(!burst_mode) - { - pixel_desu = 0; - pixel_copy_count = (HDW_cache + 1) * 8; - - // BG off, sprite on: fill = 0x100. bg off, sprite off: fill = 0x000 - if(!(CR_cache & 0x80)) - { - uint16 fill_val; - - if(!(CR_cache & 0xC0)) // Sprites and BG off - fill_val = 0x000; - else // Only BG off - fill_val = 0x100 | ((userle & ULE_BG) ? 0 : VDC_BGDISABLE_OUT_MASK); - - if(!(userle & ULE_BG)) - fill_val |= VDC_BGDISABLE_OUT_MASK; - - for(int i = 0; i < pixel_copy_count; i++) - linebuf[i] = fill_val; - } - - if(!skip) - if(CR_cache & 0x80) - { - DrawBG(linebuf, userle & ULE_BG); - } - //printf("%d %02x %02x\n", RCRCount, CR, CR_cache); - if(CR_cache & 0x40) - DrawSprites(linebuf, (userle & ULE_SPR) && !skip); - } - } - break; - - case HPHASE_HDW_FINAL: - if(NeedRCRInc) - { - IncRCR(); - NeedRCRInc = false; - } - HPhaseCounter = Cycles_Between_RCRIRQ_And_HDWEnd; - break; - - case HPHASE_HDE: //if(!burst_mode) //if(VPhase == VPHASE_VDW) //if(!burst_mode) - // lastats = 16; // + 16; - //else - // lastats = 16; - HPhaseCounter = (HDE_cache + 1) * 8; - break; - - case HPHASE_HSW: HPhaseCounter = (HSW_cache + 1) * 8; break; - } - } - pixels += chunk_clocks; - clocks -= chunk_clocks; - } - - //puts("Run end"); - //fflush(stdout); - - return(CalcNextEvent()); -} - - -void VDC::CalcWidthStartEnd(uint32 &display_width, uint32 &start, uint32 &end) -{ - display_width = (M_vdc_HDW + 1) * 8; - - start = 0; - end = start + display_width; -} - -void VDC::DrawBG(uint16 *target, int enabled) -{ - uint32 width; - uint32 start; - uint32 end; - int bat_width = bat_width_tab[(MWR_cache >> 4) & 3]; - int bat_width_mask = bat_width - 1; - int bat_width_shift = bat_width_shift_tab[(MWR_cache >> 4) & 3]; - int bat_height_mask = bat_height_tab[(MWR_cache >> 6) & 1] - 1; - - CalcWidthStartEnd(width, start, end); - - if(!enabled) - { - for(uint32 x = start; x < end; x++) - target[x] = 0x000 | VDC_BGDISABLE_OUT_MASK; - return; - } - - { - int bat_y = ((BG_YOffset >> 3) & bat_height_mask) << bat_width_shift; - uint32 first_end = start + 8 - (BG_XOffset & 7); - uint32 dohmask = 0xFFFFFFFF; - - if((MWR_cache & 0x3) == 0x3) - { - if(MWR_cache & 0x80) - dohmask = 0xCCCCCCCC; - else - dohmask = 0x33333333; - } - - // Draw the first pixels of the first tile, depending on the lower 3 bits of the xscroll/xoffset register, to - // we can render the rest of the line in 8x1 chunks, which is faster. - for(uint32 x = start; x < first_end; x++) - { - int bat_x = (BG_XOffset >> 3) & bat_width_mask; - uint16 bat = VRAM[bat_x | bat_y]; - const uint8 pal_or = ((bat >> 8) & 0xF0); - int palette_index = ((bat >> 12) & 0x0F) << 4; - uint32 raw_pixel; - - raw_pixel = bg_tile_cache[bat & 0xFFF][BG_YOffset & 7][BG_XOffset & 0x7] & dohmask; - target[x] = palette_index | raw_pixel | pal_or; - - if((bat & 0xFFF) > VRAM_BGTileNoMask) - VDC_UNDEFINED("Unmapped BG tile read"); - - BG_XOffset++; - } - - int bat_boom = (BG_XOffset >> 3) & bat_width_mask; - int line_sub = BG_YOffset & 7; - - if((MWR_cache & 0x3) == 0x3) - { - for(uint32 x = first_end; x < end; x+=8) - { - const uint16 bat = VRAM[bat_boom | bat_y]; - const uint8 pal_or = ((bat >> 8) & 0xF0); - uint8 *pix_lut = bg_tile_cache[bat & 0xFFF][line_sub]; - - if((bat & 0xFFF) > VRAM_BGTileNoMask) - VDC_UNDEFINED("Unmapped BG tile read"); - - - (target + 0)[x] = (pix_lut[0] & dohmask) | pal_or; - (target + 1)[x] = (pix_lut[1] & dohmask) | pal_or; - (target + 2)[x] = (pix_lut[2] & dohmask) | pal_or; - (target + 3)[x] = (pix_lut[3] & dohmask) | pal_or; - (target + 4)[x] = (pix_lut[4] & dohmask) | pal_or; - (target + 5)[x] = (pix_lut[5] & dohmask) | pal_or; - (target + 6)[x] = (pix_lut[6] & dohmask) | pal_or; - (target + 7)[x] = (pix_lut[7] & dohmask) | pal_or; - - bat_boom = (bat_boom + 1) & bat_width_mask; - BG_XOffset++; - - } - } - else - for(uint32 x = first_end; x < end; x+=8) // This will draw past the right side of the buffer, but since our pitch is 1024, and max width is ~512, we're safe. Also, - // any overflow that is on the visible screen are will be hidden by the overscan color code below this code. - { - const uint16 bat = VRAM[bat_boom | bat_y]; - const uint8 pal_or = ((bat >> 8) & 0xF0); - uint8 *pix_lut = bg_tile_cache[bat & 0xFFF][line_sub]; - - if((bat & 0xFFF) > VRAM_BGTileNoMask) - VDC_UNDEFINED("Unmapped BG tile read"); - - #ifdef LSB_FIRST - #if SIZEOF_LONG == 8 - uint64 doh = *(uint64 *)pix_lut; - - (target + 0)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 1)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 2)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 3)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 4)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 5)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 6)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 7)[x] = (doh) | pal_or; - #else - uint32 doh = *(uint32 *)pix_lut; - (target + 0)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 1)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 2)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 3)[x] = doh | pal_or; - doh = *(uint32 *)(pix_lut + 4); - (target + 4)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 5)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 6)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 7)[x] = doh | pal_or; - #endif - #else - (target + 0)[x] = pix_lut[0] | pal_or; - (target + 1)[x] = pix_lut[1] | pal_or; - (target + 2)[x] = pix_lut[2] | pal_or; - (target + 3)[x] = pix_lut[3] | pal_or; - (target + 4)[x] = pix_lut[4] | pal_or; - (target + 5)[x] = pix_lut[5] | pal_or; - (target + 6)[x] = pix_lut[6] | pal_or; - (target + 7)[x] = pix_lut[7] | pal_or; - #endif - - bat_boom = (bat_boom + 1) & bat_width_mask; - BG_XOffset++; - } - } -} - -#define SPRF_PRIORITY 0x00080 -#define SPRF_HFLIP 0x00800 -#define SPRF_VFLIP 0x08000 -#define SPRF_SPRITE0 0x10000 - -static const unsigned int sprite_height_tab[4] = { 16, 32, 64, 64 }; -static const unsigned int sprite_height_no_mask[4] = { ~0, ~2, ~6, ~6 }; -static const unsigned int sprite_width_tab[2] = { 16, 32 }; - -void VDC::FetchSpriteData(void) -{ - active_sprites = 0; - - // First, grab the up to 16 sprites. - for(int i = 0; i < 64; i++) - { - int16 y = (SAT[i * 4 + 0] & 0x3FF) - 0x40; - uint16 x = (SAT[i * 4 + 1] & 0x3FF); - uint16 no = (SAT[i * 4 + 2] >> 1) & 0x3FF; // Todo, cg mode bit - uint16 flags = (SAT[i * 4 + 3]); - - uint32 palette_index = (flags & 0xF) << 4; - uint32 height = sprite_height_tab[(flags >> 12) & 3]; - uint32 width = sprite_width_tab[(flags >> 8) & 1]; - - if((int32)RCRCount >= y && (int32)RCRCount < (int32)(y + height)) - { - bool second_half = 0; - uint32 y_offset = RCRCount - y; - if(y_offset > height) continue; - - - breepbreep: - - if(active_sprites == 16) - { - if(CR & 0x2) - { - status |= VDCS_OR; - IRQHook(TRUE); - VDC_DEBUG("Overflow IRQ"); - } - if(!unlimited_sprites) - break; - } - - - { - if(flags & SPRF_VFLIP) - y_offset = height - 1 - y_offset; - - no &= sprite_height_no_mask[(flags >> 12) & 3]; - no |= (y_offset & 0x30) >> 3; - if(width == 32) no &= ~1; - if(second_half) - no |= 1; - - SpriteList[active_sprites].flags = flags; - - if(flags & SPRF_HFLIP && width == 32) - no ^= 1; - //printf("Found: %d %d\n", RCRCount, x); - SpriteList[active_sprites].x = x; - SpriteList[active_sprites].palette_index = palette_index; - - if((no * 64) >= VRAM_Size) - VDC_UNDEFINED("Unmapped VRAM sprite tile read"); - - if((MWR_cache & 0xC) == 4) - { - if(SAT[i * 4 + 2] & 1) - { - SpriteList[active_sprites].pattern_data[0] = VRAM[no * 64 + (y_offset & 15) + 32]; - SpriteList[active_sprites].pattern_data[1] = VRAM[no * 64 + (y_offset & 15) + 48]; - SpriteList[active_sprites].pattern_data[2] = 0; - SpriteList[active_sprites].pattern_data[3] = 0; - } - else - { - SpriteList[active_sprites].pattern_data[0] = VRAM[no * 64 + (y_offset & 15) ]; - SpriteList[active_sprites].pattern_data[1] = VRAM[no * 64 + (y_offset & 15) + 16]; - SpriteList[active_sprites].pattern_data[2] = 0; - SpriteList[active_sprites].pattern_data[3] = 0; - } - } - else - { - SpriteList[active_sprites].pattern_data[0] = VRAM[no * 64 + (y_offset & 15) ]; - SpriteList[active_sprites].pattern_data[1] = VRAM[no * 64 + (y_offset & 15) + 16]; - SpriteList[active_sprites].pattern_data[2] = VRAM[no * 64 + (y_offset & 15) + 32]; - SpriteList[active_sprites].pattern_data[3] = VRAM[no * 64 + (y_offset & 15) + 48]; - } - - SpriteList[active_sprites].flags |= i ? 0 : SPRF_SPRITE0; - - active_sprites++; - - if(width == 32 && !second_half) - { - second_half = 1; - x += 16; - y_offset = RCRCount - y; // Fix the y offset so that sprites that are hflipped + vflipped display properly - goto breepbreep; - } - } - } - } - - sprite_cg_fetch_counter = ((active_sprites < 16) ? active_sprites : 16) * 4; -} - -void VDC::DrawSprites(uint16 *target, int enabled) -{ - MDFN_ALIGN(16) uint16 sprite_line_buf[1024]; - - uint32 display_width, start, end; - - CalcWidthStartEnd(display_width, start, end); - - for(unsigned int i = start; i < end; i++) - sprite_line_buf[i] = 0; - - for(int i = (active_sprites - 1) ; i >= 0; i--) - { - int32 pos = SpriteList[i].x - 0x20 + start; - uint32 prio_or = 0; - - if(SpriteList[i].flags & SPRF_PRIORITY) - prio_or = 0x200; - - if((SpriteList[i].flags & SPRF_SPRITE0) && (CR & 0x01)) - { - for(uint32 x = 0; x < 16; x++) - { - uint32 raw_pixel; - uint32 pi = SpriteList[i].palette_index; - uint32 rev_x = 15 - x; - - if(SpriteList[i].flags & SPRF_HFLIP) - rev_x = x; - - raw_pixel = (SpriteList[i].pattern_data[0] >> rev_x) & 1; - raw_pixel |= ((SpriteList[i].pattern_data[1] >> rev_x) & 1) << 1; - raw_pixel |= ((SpriteList[i].pattern_data[2] >> rev_x) & 1) << 2; - raw_pixel |= ((SpriteList[i].pattern_data[3] >> rev_x) & 1) << 3; - - if(raw_pixel) - { - pi |= 0x100; - uint32 tx = pos + x; - - if(tx >= end) // Covers negative and overflowing the right side. - continue; - - if(sprite_line_buf[tx] & 0xF) - { - status |= VDCS_CR; - VDC_DEBUG("Sprite hit IRQ"); - IRQHook(TRUE); - } - sprite_line_buf[tx] = pi | raw_pixel | prio_or; - } - } - } // End sprite hit loop - else - { - for(uint32 x = 0; x < 16; x++) - { - uint32 raw_pixel; - uint32 pi = SpriteList[i].palette_index; - uint32 rev_x = 15 - x; - - if(SpriteList[i].flags & SPRF_HFLIP) - rev_x = x; - - raw_pixel = (SpriteList[i].pattern_data[0] >> rev_x) & 1; - raw_pixel |= ((SpriteList[i].pattern_data[1] >> rev_x) & 1) << 1; - raw_pixel |= ((SpriteList[i].pattern_data[2] >> rev_x) & 1) << 2; - raw_pixel |= ((SpriteList[i].pattern_data[3] >> rev_x) & 1) << 3; - - if(raw_pixel) - { - pi |= 0x100; - uint32 tx = pos + x; - - if(tx >= end) // Covers negative and overflowing the right side. - continue; - sprite_line_buf[tx] = pi | raw_pixel | prio_or; - } - } - } // End non-sprite-hit loop - } - - if(enabled) - { - for(unsigned int x = start; x < end; x++) - { - if(sprite_line_buf[x] & 0x0F) - { - if(!(target[x] & 0x0F) || (sprite_line_buf[x] & 0x200)) - target[x] = sprite_line_buf[x] & 0x1FF; - } - } - } - active_sprites = 0; -} - -void VDC::DoWaitStates(void) -{ - //bool did_wait = VDC_IS_BSY; - - while(VDC_IS_BSY) - { - int32 to_wait = CalcNextEvent(); - - if(!WSHook || !WSHook(to_wait)) - { - if(DMARunning) - { - VDC_WARNING("VRAM DMA completion forced."); - RunDMA(0, TRUE); - } - - if(sat_dma_counter > 0) - { - VDC_WARNING("SAT DMA completion forced."); - RunSATDMA(0, TRUE); - } - - if(mystery_phase) - { - bool backup_mystery_phase = mystery_phase; - mystery_phase = false; - CheckAndCommitPending(); - mystery_phase = backup_mystery_phase; - } - - break; - } - } - - //if(did_wait) - // printf("End of wait stating: %d %d\n", VDMA_CycleCounter, sat_dma_counter); - - assert(!pending_read); - assert(!pending_write); -} - -uint8 VDC::Read(uint32 A, int32 &next_event, bool peek) -{ - uint8 ret = 0; - int msb = A & 1; - - A &= 0x3; - - switch(A) - { - case 0x0: ret = status | (VDC_IS_BSY ? 0x40 : 0x00); - - if(!peek) - { - status &= ~0x3F; - IRQHook(FALSE); - } - break; - - case 0x2: - case 0x3: - if(!peek) - { - // Should we only wait on MSB reads... - DoWaitStates(); - } - - ret = VDC_REGGETP(read_buffer, msb); - - if(select == 0x2) // VRR - VRAM Read Register - { - if(msb) - { - if(!peek) - { - pending_read = TRUE; - pending_read_addr = MARR; - MARR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - } - } - } - break; - } - - return(ret); -} - -uint16 VDC::Read16(bool A, bool peek) -{ - uint16 ret = 0; - - if(!A) - { - ret = status | (VDC_IS_BSY ? 0x40 : 0x00); - - if(!peek) - { - status &= ~0x3F; - IRQHook(FALSE); - } - } - else - { - if(!peek) - DoWaitStates(); - - ret = read_buffer; - - if(select == 0x2) // VRR - VRAM Read Register - { - if(!peek) - { - pending_read = TRUE; - pending_read_addr = MARR; - MARR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - } - } - } - - return(ret); -} - - -void VDC::CheckAndCommitPending(void) -{ - if(sat_dma_counter <= 0 && !DMARunning /* && sprite_cg_fetch_counter <= 0*/ && !mystery_phase) - { - if(pending_write) - { - if(pending_write_addr < VRAM_Size) - { - VRAM[pending_write_addr] = pending_write_latch; - FixTileCache(pending_write_addr); - } - //else - // VDC_UNDEFINED("Unmapped VRAM write"); - - pending_write = FALSE; - } - - if(pending_read) - { - if(pending_read_addr >= VRAM_Size) - VDC_UNDEFINED("Unmapped VRAM VRR read"); - - read_buffer = VRAM[pending_read_addr]; - pending_read = FALSE; - } - } -} - - -void VDC::Write(uint32 A, uint8 V, int32 &next_event) -{ - int msb = A & 1; - - A &= 0x3; - - //if((A == 0x2 || A == 0x3) && (select >= 0xF && select <= 0x12)) - //if((A == 2 || A == 3) && select != 2) - // printf("VDC Write(RCRCount=%d): A=%02x, Select=%02x, V=%02x\n", RCRCount, A, select, V); - - switch(A) - { - case 0x0: select = V & 0x1F; - break; - - case 0x2: - case 0x3: - //if((select & 0x1F) >= 0x9 && (select & 0x1F) <= 0x1F) - // VDC_DEBUG("%02x %d, %02x", select & 0x1F, msb, V); - - switch(select & 0x1F) - { - case 0x00: VDC_REGSETP(MAWR, V, msb); - break; - - case 0x01: VDC_REGSETP(MARR, V, msb); - if(msb) - { - DoWaitStates(); - - pending_read = TRUE; - pending_read_addr = MARR; - MARR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - } - break; - - case 0x02: if(!msb) - { - write_latch = V; - } - else - { - // We must call CommitPendingWrite at the end of SAT/VRAM DMA for this to work! - DoWaitStates(); - - pending_write = TRUE; - pending_write_addr = MAWR; - pending_write_latch = write_latch | (V << 8); - MAWR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - } - break; - - case 0x05: VDC_REGSETP(CR, V, msb); - //printf("CR: %04x, %d\n", CR, msb); - break; - - case 0x06: VDC_REGSETP(RCR, V, msb); - RCR &= 0x3FF; - break; - - case 0x07: VDC_REGSETP(BXR, V, msb); - BXR &= 0x3FF; - //VDC_DEBUG("BXR Set"); - break; - - case 0x08: VDC_REGSETP(BYR, V, msb); - BYR &= 0x1FF; - BG_YMoo = BYR; // Set it on LSB and MSB writes(only changing on MSB breaks Youkai Douchuuki) - //VDC_DEBUG("BYR Set"); - break; - - case 0x09: VDC_REGSETP(MWR, V, msb); break; - case 0x0a: VDC_REGSETP(HSR, V, msb); break; - case 0x0b: VDC_REGSETP(HDR, V, msb); break; - case 0x0c: VDC_REGSETP(VSR, V, msb); break; - case 0x0d: VDC_REGSETP(VDR, V, msb); break; - case 0x0e: VDC_REGSETP(VCR, V, msb); break; - case 0x0f: VDC_REGSETP(DCR, V, msb); - if(DMARunning) - { - VDC_UNDEFINED("Set DCR during DMA: %04x\n", DCR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set DCR while DMAPending: %04x\n", DCR); - } - - break; - - case 0x10: VDC_REGSETP(SOUR, V, msb); - if(DMARunning) - { - VDC_UNDEFINED("Set SOUR during DMA: %04x\n", SOUR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set SOUR while DMAPending: %04x\n", SOUR); - } - break; - - case 0x11: VDC_REGSETP(DESR, V, msb); - if(DMARunning) - { - VDC_UNDEFINED("Set DESR during DMA: %04x\n", DESR); - } - if(DMAPending) - { - VDC_UNDEFINED("Set DESR while DMAPending: %04x\n", DESR); - } - break; - - case 0x12: VDC_REGSETP(LENR, V, msb); - if(DMARunning) - { - VDC_UNDEFINED("Set LENR during DMA: %04x\n", LENR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set LENR while DMAPending: %04x\n", LENR); - } - - if(msb) - { - VDC_DEBUG("DMA: %04x %04x %04x, %02x", SOUR, DESR, LENR, DCR); - DMAPending = 1; - } - break; - - case 0x13: VDC_REGSETP(DVSSR, V, msb); - SATBPending = 1; - break; - - default: VDC_WARNING("Unknown VDC register write: %04x %02x", select, V); - break; - } - break; - } -} - - -void VDC::Write16(bool A, uint16 V) -{ - if(!A) - select = V & 0x1F; - else - { - switch(select & 0x1F) - { - case 0x00: MAWR = V; - break; - - - case 0x01: MARR = V; - - DoWaitStates(); - - pending_read = TRUE; - pending_read_addr = MARR; - - MARR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - break; - - - case 0x02: // We must call CommitPendingWrite at the end of SAT/VRAM DMA for this to work! - DoWaitStates(); - - pending_write = TRUE; - pending_write_addr = MAWR; - pending_write_latch = V; - MAWR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - break; - - case 0x05: CR = V; - break; - - case 0x06: RCR = V & 0x3FF; - break; - - case 0x07: BXR = V & 0x3FF; - //VDC_DEBUG("BXR Set"); - break; - - case 0x08: BYR = V & 0x1FF; - BG_YMoo = BYR; - //VDC_DEBUG("BYR Set"); - break; - - case 0x09: MWR = V; break; - case 0x0a: HSR = V; break; - case 0x0b: HDR = V; break; - case 0x0c: VSR = V; break; - case 0x0d: VDR = V; break; - case 0x0e: VCR = V; break; - - case 0x0f: DCR = V; - if(DMARunning) - { - VDC_UNDEFINED("Set DCR during DMA: %04x\n", DCR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set DCR while DMAPending: %04x\n", DCR); - } - - break; - - case 0x10: SOUR = V; - if(DMARunning) - { - VDC_UNDEFINED("Set SOUR during DMA: %04x\n", SOUR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set SOUR while DMAPending: %04x\n", SOUR); - } - break; - - case 0x11: DESR = V; - if(DMARunning) - { - VDC_UNDEFINED("Set DESR during DMA: %04x\n", DESR); - } - if(DMAPending) - { - VDC_UNDEFINED("Set DESR while DMAPending: %04x\n", DESR); - } - break; - - case 0x12: LENR = V; - if(DMARunning) - { - VDC_UNDEFINED("Set LENR during DMA: %04x\n", LENR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set LENR while DMAPending: %04x\n", LENR); - } - - VDC_DEBUG("DMA: %04x %04x %04x, %02x", SOUR, DESR, LENR, DCR); - - DMAPending = 1; - break; - - case 0x13: DVSSR = V; - SATBPending = 1; - break; - - default: VDC_WARNING("Oops 2: %04x %02x", select, V); - break; - } - } - -} - - - -int32 VDC::Reset(void) -{ - memset(VRAM, 0, sizeof(VRAM)); - memset(SAT, 0, sizeof(SAT)); - memset(SpriteList, 0, sizeof(SpriteList)); - - for(uint32 A = 0; A < 65536; A += 16) - FixTileCache(A); - - pending_read = false; - pending_read_addr = 0xFFFF; - read_buffer = 0xFFFF; - write_latch = 0; - - pending_write = false; - pending_write_addr = 0xFFFF; - pending_write_latch = 0xFFFF; - - status = 0; - - HSR = 0; - HDR = 0; - VSR = 0; - VDR = 0; - VCR = 0; - - HSW_cache = M_vdc_HSW; - HDS_cache = M_vdc_HDS; - HDW_cache = M_vdc_HDW; - HDE_cache = M_vdc_HDE; - - VDS_cache = M_vdc_VDS; - VSW_cache = M_vdc_VSW; - VDW_cache = M_vdc_VDW; - VCR_cache = M_vdc_VCR; - - - - MAWR = 0; - MARR = 0; - - CR = CR_cache = 0; - RCR = 0; - BXR = 0; - BYR = 0; - MWR = 0; - MWR_cache = 0; - - DCR = 0; - SOUR = 0; - DESR = 0; - LENR = 0; - DVSSR = 0; - - VDMA_CycleCounter = 0; - - RCRCount = 0; - - DMAReadBuffer = 0; - DMAReadWrite = 0; - DMARunning = 0; - DMAPending = 0; - SATBPending = 0; - burst_mode = 0; - - BG_XOffset = 0; - BG_YOffset = 0; - BG_YMoo = 0; - - sat_dma_counter = 0; - select = 0; - - pixel_copy_count = 0; - - - NeedRCRInc = false; - NeedVBIRQTest = false; - NeedSATDMATest = false; - NeedBGYInc = false; - - HPhase = 0; - VPhase = 0; - HPhaseCounter = 1; - VPhaseCounter = 1; - - sprite_cg_fetch_counter = 0; - - mystery_counter = 0; - mystery_phase = false; - - pixel_desu = 0; - pixel_copy_count = 0; - active_sprites = 0; - - return(CalcNextEvent()); -} - -VDC::VDC(bool nospritelimit, uint32 par_VRAM_Size) -{ - unlimited_sprites = nospritelimit; //MDFN_GetSettingB("pce.nospritelimit"); - userle = ~0; - - assert(par_VRAM_Size == round_up_pow2(par_VRAM_Size)); - assert(par_VRAM_Size >= 16 && par_VRAM_Size <= 65536); - - VRAM_Size = par_VRAM_Size; - VRAM_SizeMask = VRAM_Size - 1; - VRAM_BGTileNoMask = VRAM_SizeMask / 16; - - WSHook = NULL; - IRQHook = NULL; - - in_exhsync = false; - in_exvsync = false; -} - -VDC::~VDC() -{ - -} - -void VDC::StateExtra(MDFN::LEPacker &sl_packer, bool load) -{ - sl_packer.set_read_mode(load); - - for(int i = 0; i < 64 * 2; i++) - { - sl_packer ^ SpriteList[i].x; - sl_packer ^ SpriteList[i].flags; - sl_packer ^ SpriteList[i].palette_index; - - for(int pd = 0; pd < 4; pd++) - sl_packer ^ SpriteList[i].pattern_data[pd]; - } -} - -int VDC::StateAction(StateMem *sm, int load, int data_only, const char *sname) -{ - int ret = 1; - MDFN::LEPacker sl_packer; - - StateExtra(sl_packer, false); - - SFORMAT StateRegs[] = - { - SFVAR(in_exhsync), - SFVAR(in_exvsync), - - SFVARN(sat_dma_counter, "sat_dma_counter"), - - SFVARN(select, "select"), - SFVARN(MAWR, "MAWR"), - SFVARN(MARR, "MARR"), - SFVARN(CR, "CR"), - SFVAR(CR_cache), - SFVARN(RCR, "RCR"), - SFVARN(BXR, "BXR"), - SFVARN(BYR, "BYR"), - SFVARN(MWR, "MWR"), - - SFVARN(HSR, "HSR"), - SFVARN(HDR, "HDR"), - SFVARN(VSR, "VSR"), - SFVARN(VDR, "VDR"), - - SFVARN(VCR, "VCR"), - SFVARN(DCR, "DCR"), - SFVARN(SOUR, "SOUR"), - SFVARN(DESR, "DESR"), - SFVARN(LENR, "LENR"), - SFVARN(DVSSR, "SATB"), - - - SFVAR(VDMA_CycleCounter), - - SFVARN(RCRCount, "RCRCount"), - - - SFVAR(pending_read), - SFVAR(pending_read_addr), - SFVAR(read_buffer), - - SFVAR(write_latch), - - SFVAR(pending_write), - SFVAR(pending_write_addr), - SFVAR(pending_write_latch), - - SFVARN(status, "status"), - - SFARRAY16N(SAT, 0x100, "SAT"), - - SFARRAY16N(VRAM, VRAM_Size, "VRAM"), - - SFVARN(DMAReadBuffer, "DMAReadBuffer"), - SFVARN(DMAReadWrite, "DMAReadWrite"), - SFVARN(DMARunning, "DMARunning"), - SFVAR(DMAPending), - SFVARN(SATBPending, "SATBPending"), - SFVARN(burst_mode, "burst_mode"), - - SFVARN(BG_YOffset, "BG_YOffset"), - SFVARN(BG_XOffset, "BG_XOffset"), - - SFVAR(HSW_cache), - SFVAR(HDS_cache), - SFVAR(HDW_cache), - SFVAR(HDE_cache), - - SFVARN(VDS_cache, "VDS_cache"), - SFVARN(VSW_cache, "VSW_cache"), - SFVARN(VDW_cache, "VDW_cache"), - SFVARN(VCR_cache, "VCR_cache"), - SFVARN(MWR_cache, "MWR_cache"), - - - SFVAR(BG_YMoo), - SFVAR(NeedRCRInc), - SFVAR(NeedVBIRQTest), - SFVAR(NeedSATDMATest), - SFVAR(NeedBGYInc), - - SFVAR(HPhase), - SFVAR(VPhase), - SFVAR(HPhaseCounter), - SFVAR(VPhaseCounter), - - SFVAR(sprite_cg_fetch_counter), - - SFVAR(mystery_counter), - SFVAR(mystery_phase), - - SFVAR(active_sprites), - - SFARRAYN(&sl_packer[0], sl_packer.size(), "ExtraState"), - //SFARRAY(SpriteListTemp, sizeof(SpriteListTemp)), - - SFEND - }; - - ret &= MDFNSS_StateAction(sm, load, data_only, StateRegs, sname); - - if(load) - { - StateExtra(sl_packer, true); - - for(int x = 0; x < VRAM_Size; x++) - FixTileCache(x); - } - - return(ret); -} - -#ifdef WANT_DEBUGGER -bool VDC::DoGfxDecode(uint32 *target, const uint32 *color_table, const uint32 TransparentColor, bool DecodeSprites, - int32 w, int32 h, int32 scroll) -{ - const uint32 *palette_ptr = color_table; - - if(DecodeSprites) - { - for(int y = 0; y < h; y++) - { - for(int x = 0; x < w; x += 16) - { - int which_tile = (x / 16) + (scroll + (y / 16)) * (w / 16); - - if(which_tile >= VRAM_Size / 64) - { - for(int sx = 0; sx < 16; sx++) - { - target[x + sx] = TransparentColor; - target[x + w * 1 + sx] = 0; - target[x + w * 2 + sx] = 0; - } - continue; - } - - uint16 cg[4]; - cg[0] = VRAM[which_tile * 64 + (y & 15)]; - cg[1] = VRAM[which_tile * 64 + (y & 15) + 16]; - cg[2] = VRAM[which_tile * 64 + (y & 15) + 32]; - cg[3] = VRAM[which_tile * 64 + (y & 15) + 48]; - for(int sx = 0; sx < 16; sx++) - { - int rev_sx = 15 - sx; - target[x + sx] = palette_ptr[(((cg[0] >> rev_sx) & 1) << 0) | - (((cg[1] >> rev_sx) & 1) << 1) | (((cg[2] >> rev_sx) & 1) << 2) | (((cg[3] >> rev_sx) & 1) << 3)]; - target[x + w * 1 + sx] = which_tile; - target[x + w * 2 + sx] = which_tile * 64; - } - } - target += w * 3; - } - } - else for(int y = 0; y < h; y++) - { - for(int x = 0; x < w; x+=8) - { - int which_tile = (x / 8) + (scroll + (y / 8)) * (w / 8); - - if(which_tile >= (VRAM_Size / 16)) - { - for(int sx = 0; sx < 8; sx++) - { - target[x + sx] = TransparentColor; - target[x + w * 1 + sx] = 0; - target[x + w * 2 + sx] = 0; - } - continue; - } - - target[x + 0] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][0]]; - target[x + 1] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][1]]; - target[x + 2] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][2]]; - target[x + 3] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][3]]; - target[x + 4] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][4]]; - target[x + 5] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][5]]; - target[x + 6] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][6]]; - target[x + 7] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][7]]; - - target[x + w*1 + 0]=target[x + w*1 + 1]=target[x + w*1 + 2]=target[x + w*1 + 3] = - target[x + w*1 + 4]=target[x + w*1 + 5]=target[x + w*1 + 6]=target[x + w*1 + 7] = which_tile; - - target[x + w*2 + 0]=target[x + w*2 + 1]=target[x + w*2 + 2]=target[x + w*2 + 3] = - target[x + w*2 + 4]=target[x + w*2 + 5]=target[x + w*2 + 6]=target[x + w*2 + 7] = which_tile * 16; - } - target += w * 3; - } - - return(1); -} -#endif - diff --git a/libmednahawk/src/hw_video/huc6270/backup/vdc.h b/libmednahawk/src/hw_video/huc6270/backup/vdc.h deleted file mode 100644 index 292d0d1887..0000000000 --- a/libmednahawk/src/hw_video/huc6270/backup/vdc.h +++ /dev/null @@ -1,448 +0,0 @@ -#ifndef __PCE_VDC_H -#define __PCE_VDC_H - -#include "mednafen/lepacker.h" - -#define VDC_PIXEL_OUT_MASK 0x01FF - -// This bit will be set for a non-sprite pixel if the BG layer is disabled(via ToggleLayer()), -#define VDC_BGDISABLE_OUT_MASK 0x0200 - -// HSync and VSync out bits are only valid when the EX bits in VDC's CR -// are set so that the VDC will output sync signals rather than -// input them. If it is not configured in this manner, the bit(s) shall always be 0. -#define VDC_HSYNC_OUT_MASK 0x2000 -#define VDC_VSYNC_OUT_MASK 0x4000 - -// The DISP bit can either denote active display area(1 = active, 0 = inactive), -// colorburst insertion period(0 = insert colorburst, 1 = not in colorburst period; may not be emulated correctly), -// or "internal horizontal synchronous signal"(may not be emulated correctly), depending on the TE -// bits in the VDC's CR. -#define VDC_DISP_OUT_MASK 0x8000 - -#define VDC_REGSETP(_reg, _data, _msb) { _reg &= 0xFF << ((_msb) ? 0 : 8); _reg |= (_data) << ((_msb) ? 8 : 0); } -#define VDC_REGGETP(_reg, _msb) ((_reg >> ((_msb) ? 8 : 0)) & 0xFF) - -static const unsigned int vram_inc_tab[4] = { 1, 32, 64, 128 }; - -#define VDC_IS_BSY (pending_read || pending_write) - -typedef struct -{ - uint32 x; - uint32 flags; - uint8 palette_index; - uint16 pattern_data[4]; -} SPRLE; - -typedef struct -{ - // In the case the VDC access doesn't cause a VRAM read/write, only ReadCount/WriteCount will be set to 0. - uint32 ReadStart; - uint32 ReadCount; - uint32 WriteStart; - uint32 WriteCount; -} VDC_SimulateResult; - -class VDC -{ - public: - - // The VRAM size is specified in 16-bit words. - VDC(bool nospritelimit, uint32 par_VRAM_Size); - ~VDC(); - -#if 0 - void *operator new(size_t bcount) - { - void *ret = calloc(1, bcount); - return(ret); - } - - void operator delete(void *ptr) - { - free(ptr); - } -#endif - - int32 Reset(void) MDFN_WARN_UNUSED_RESULT; - - // ResetSimulate(), SimulateWrite(), and SimulateRead() are intended to handle VRAM read/write breakpoints. - // SimulateWrite() and SimulateRead() will return the VRAM address that will EVENTUALLY be written(upper 32-bits) and/or read(lower 32-bits) to - // due to the access, or 0xFFFFFFFF in the upper or lower 32-bits if no VRAM access of that type occurs. - // - // The feature is intended to support block moves to VRAM in a single instruction. It may not function properly if the address passed to SimulateRead() - // or SimulateWrite() alternates(even if just once) between the data port high byte and control port between calls to ResetSimulate() - // Call to reset simulation state. - - - INLINE void ResetSimulate(void) - { - Simulate_MAWR = MAWR; - Simulate_MARR = MARR; - - Simulate_select = select; - Simulate_CR = CR; - - Simulate_LENR = LENR; - } - - INLINE void SimulateRead(uint32 A, VDC_SimulateResult *result) - { - result->ReadCount = 0; - result->WriteCount = 0; - result->ReadStart = 0; - result->WriteStart = 0; - - if((A & 0x3) == 0x3 && Simulate_select == 0x02) - { - Simulate_MARR += vram_inc_tab[(Simulate_CR >> 11) & 0x3]; - - result->ReadStart = Simulate_MARR; - result->ReadCount = 1; - } - } - - INLINE void SimulateWrite(uint32 A, uint8 V, VDC_SimulateResult *result) - { - result->ReadCount = 0; - result->WriteCount = 0; - result->ReadStart = 0; - result->WriteStart = 0; - - const unsigned int msb = A & 1; - - switch(A & 0x3) - { - case 0x00: Simulate_select = V & 0x1F; - break; - - case 0x02: - case 0x03: - - switch(Simulate_select) - { - case 0x00: VDC_REGSETP(Simulate_MAWR, V, msb); - break; - - case 0x01: VDC_REGSETP(Simulate_MARR, V, msb); - Simulate_MARR += vram_inc_tab[(Simulate_CR >> 11) & 0x3]; - - result->ReadStart = Simulate_MARR; - result->ReadCount = 1; - break; - - case 0x02: if(msb) - { - result->WriteStart = Simulate_MAWR; - result->WriteCount = 1; - - Simulate_MAWR += vram_inc_tab[(Simulate_CR >> 11) & 0x3]; - } - break; - - case 0x12: VDC_REGSETP(Simulate_LENR, V, msb); - if(msb) - { - result->ReadStart = SOUR; - result->ReadCount = Simulate_LENR + 1; - - if(DCR & 0x4) - result->ReadStart = (result->ReadStart - (result->ReadCount - 1)) & 0xFFFF; - - result->WriteStart = DESR; - result->WriteCount = Simulate_LENR + 1; - - if(DCR & 0x8) - result->WriteStart = (result->WriteStart - (result->WriteCount - 1)) & 0xFFFF; - } - break; - - } - break; - } - } - - - int32 HSync(bool); - int32 VSync(bool); - - - void Write(uint32 A, uint8 V, int32 &next_event); - uint8 Read(uint32 A, int32 &next_event, bool peek = FALSE); - - void Write16(bool A, uint16 V); - uint16 Read16(bool A, bool peek = FALSE); - - int32 Run(int32 clocks, /*bool hs, bool vs,*/ uint16 *pixels, bool skip); - - - void FixTileCache(uint16); - bool ToggleLayer(int); - - void RunDMA(int32, bool force_completion = FALSE); - void RunSATDMA(int32, bool force_completion = FALSE); - - void IncRCR(void); - void DoVBIRQTest(void); - void HDS_Start(void); - - void StateExtra(MDFN::LEPacker &sl_packer, bool load); - int StateAction(StateMem *sm, int load, int data_only, const char *sname); - - // Peek(VRAM/SAT) and Poke(VRAM/SAT) work in 16-bit VRAM word units. - INLINE uint16 PeekVRAM(uint16 Address) - { - if(Address < VRAM_Size) - return(VRAM[Address]); - else - return(0); - } - - INLINE uint16 PeekSAT(uint8 Address) - { - return(SAT[Address]); - } - - INLINE void PokeVRAM(uint16 Address, const uint16 Data) - { - if(Address < VRAM_Size) - { - VRAM[Address] = Data; - FixTileCache(Address); - } - } - - INLINE void PokeSAT(uint8 Address, const uint16 Data) - { - SAT[Address] = Data; - } - - - // Register enums for GetRegister() and SetRegister() - enum - { - GSREG_MAWR = 0, - GSREG_MARR, - GSREG_CR, - GSREG_RCR, - GSREG_BXR, - GSREG_BYR, - GSREG_MWR, - GSREG_HSR, - GSREG_HDR, - GSREG_VSR, - GSREG_VDR, - GSREG_VCR, - GSREG_DCR, - GSREG_SOUR, - GSREG_DESR, - GSREG_LENR, - GSREG_DVSSR, - - GSREG_SELECT, - GSREG_STATUS, - - __GSREG_COUNT - }; - - // Pass NULL if you don't want more information about the special meaning of the value in the specified - // register. Otherwise, pass a buffer of at least 256 bytes in size. - uint32 GetRegister(const unsigned int id, char *special, const uint32 special_len); - void SetRegister(const unsigned int id, const uint32 value); - - #ifdef WANT_DEBUGGER - bool DoGfxDecode(uint32 *target, const uint32 *color_table, const uint32 TransparentColor, bool DecodeSprites, - int32 w, int32 h, int32 scroll); - #endif - - INLINE bool PeekIRQ(void) - { - return((bool)(status & 0x3F)); - } - - INLINE void SetIRQHook(void (*irqh)(bool)) - { - IRQHook = irqh; - } - - INLINE void SetWSHook(bool (*wsh)(int32)) - { - WSHook = wsh; - } - - private: - - int TimeFromHDSStartToBYRLatch(void); - int TimeFromBYRLatchToBXRLatch(void); - - enum - { - HPHASE_HDS = 0, - HPHASE_HDS_PART2, - HPHASE_HDS_PART3, - HPHASE_HDW, - HPHASE_HDW_FINAL, - HPHASE_HDE, - HPHASE_HSW, - HPHASE_COUNT - }; - - enum - { - VPHASE_VDS = 0, - VPHASE_VDW, - VPHASE_VCR, - VPHASE_VSW, - VPHASE_COUNT - }; - - int VRAM_Size; // = 0x8000; - int VRAM_SizeMask; // = VRAM_Size - 1; //0x7FFF; - int VRAM_BGTileNoMask; // = VRAM_SizeMask / 16; //0x7FF; - - void (*IRQHook)(bool); - bool (*WSHook)(int32); - - void DoWaitStates(void); - void CheckAndCommitPending(void); - - INLINE int32 CalcNextEvent(void) - { - int32 next_event = HPhaseCounter; - - if(sat_dma_counter > 0 && sat_dma_counter < next_event) - next_event = sat_dma_counter; - - if(sprite_cg_fetch_counter > 0 && sprite_cg_fetch_counter < next_event) - next_event = sprite_cg_fetch_counter; - - if(DMARunning) - { - assert(VDMA_CycleCounter < 2); - - int32 next_vram_dma_event = ((LENR + 1) * 4) - (DMAReadWrite * 2) - VDMA_CycleCounter; - - assert(next_vram_dma_event > 0); - - if(next_vram_dma_event > 0 && next_vram_dma_event < next_event) - next_event = next_vram_dma_event; - - //printf("Next VRAM DMA event: %d(LENR = %d)\n", next_vram_dma_event, LENR); - } - - assert(next_event > 0); - return(next_event); - } - - bool in_exhsync, in_exvsync; - - void CalcWidthStartEnd(uint32 &display_width, uint32 &start, uint32 &end); - void DrawBG(uint16 *target, int enabled); - void DrawSprites(uint16 *target, int enabled); - void FetchSpriteData(void); - - - uint8 Simulate_select; - uint16 Simulate_MAWR; - uint16 Simulate_MARR; - uint16 Simulate_CR; - uint16 Simulate_LENR; - - int32 sat_dma_counter; - - uint8 select; - uint16 MAWR; // Memory Address Write Register - uint16 MARR; // Memory Address Read Register - - uint16 CR; // Control Register - uint16 CR_cache; // Cache for BG/SPR enable - uint16 RCR; // Raster Compare Register - uint16 BXR; // Background X-Scroll Register - uint16 BYR; // Background Y-Scroll Register - uint16 MWR; // Memory Width Register - - uint16 HSR; // Horizontal Sync Register - uint16 HDR; // Horizontal Display Register - uint16 VSR; - uint16 VDR; - - uint16 VCR; - uint16 DCR; - uint16 SOUR; - uint16 DESR; - uint16 LENR; - uint16 DVSSR; - - // Internal SAT DMA transfer variables. - //uint16 SAT_SOUR; - //uint16 SAT_DESR; - //uint16 SAT_LENR; - - int32 VDMA_CycleCounter; - - uint32 RCRCount; - - bool pending_read; - uint16 pending_read_addr; - uint16 read_buffer; - - uint8 write_latch; // LSB - - bool pending_write; - uint16 pending_write_addr; - uint16 pending_write_latch; - - uint8 status; - - uint16 SAT[0x100]; - - uint16 VRAM[65536]; //VRAM_Size]; - - union - { - uint64 bg_tile_cache64[65536 / 16][8]; // Tile, y, x - uint8 bg_tile_cache[65536 / 16][8][8]; - }; - - uint16 DMAReadBuffer; - bool DMAReadWrite; - bool DMARunning; - bool DMAPending; - bool SATBPending; - bool burst_mode; - - uint32 BG_YOffset; // Reloaded from BYR at start of display area? - uint32 BG_XOffset; // Reloaded from BXR at each scanline, methinks. - - uint32 HSW_cache, HDS_cache, HDW_cache, HDE_cache; - - uint32 VDS_cache; - uint32 VSW_cache; - uint32 VDW_cache; - uint32 VCR_cache; - uint16 MWR_cache; - - - uint32 BG_YMoo; - bool NeedRCRInc, NeedVBIRQTest, NeedSATDMATest, NeedBGYInc; - int HPhase, VPhase; - int32 HPhaseCounter, VPhaseCounter; - - int32 sprite_cg_fetch_counter; - - - int32 mystery_counter; - bool mystery_phase; - - uint16 linebuf[1024 + 512]; - uint32 pixel_desu; - int32 pixel_copy_count; - uint32 userle; // User layer enable. - bool unlimited_sprites; - - int active_sprites; - SPRLE SpriteList[64 * 2]; // (see unlimited_sprites option, *2 to accommodate 32-pixel-width sprites ) //16]; -}; - -#endif diff --git a/libmednahawk/src/hw_video/huc6270/vdc.cpp b/libmednahawk/src/hw_video/huc6270/vdc.cpp deleted file mode 100644 index 540455be16..0000000000 --- a/libmednahawk/src/hw_video/huc6270/vdc.cpp +++ /dev/null @@ -1,1953 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* VDC emulation */ - -#include "mednafen/mednafen.h" -#include "mednafen/video.h" -#include "mednafen/lepacker.h" - -#include -#include -#include "vdc.h" - -#define VDC_DEBUG(x, ...) { } -//#define VDC_DEBUG(x, ...) printf(x ": HPhase=%d, HPhaseCounter=%d, RCRCount=%d\n", ## __VA_ARGS__, HPhase, HPhaseCounter, RCRCount); - -#define VDC_UNDEFINED(format, ...) { } -//#define VDC_UNDEFINED(format, ...) printf(format " RCRCount=%d" "\n", ## __VA_ARGS__, RCRCount) - -#define VDC_WARNING(format, ...) { } -//#define VDC_WARNING(format, ...) { printf(format "\n", ## __VA_ARGS__); } - -#define ULE_BG 1 -#define ULE_SPR 2 - -static const unsigned int bat_width_tab[4] = { 32, 64, 128, 128 }; -static const unsigned int bat_width_shift_tab[4] = { 5, 6, 7, 7 }; -static const unsigned int bat_height_tab[2] = { 32, 64 }; - -void VDC::FixTileCache(uint16 A) -{ - uint32 charname = (A >> 4); - uint32 y = (A & 0x7); - uint8 *tc = bg_tile_cache[charname][y]; - - uint32 bitplane01 = VRAM[y + charname * 16]; - uint32 bitplane23 = VRAM[y+ 8 + charname * 16]; - - for(int x = 0; x < 8; x++) - { - uint32 raw_pixel = ((bitplane01 >> x) & 1); - raw_pixel |= ((bitplane01 >> (x + 8)) & 1) << 1; - raw_pixel |= ((bitplane23 >> x) & 1) << 2; - raw_pixel |= ((bitplane23 >> (x + 8)) & 1) << 3; - tc[7 - x] = raw_pixel; - } -} - -// Some virtual vdc macros to make code simpler to read -#define M_vdc_HSW (HSR & 0x1F) // Horizontal Synchro Width -#define M_vdc_HDS ((HSR >> 8) & 0x7F) // Horizontal Display Start -#define M_vdc_HDW (HDR & 0x7F) // Horizontal Display Width -#define M_vdc_HDE ((HDR >> 8) & 0x7F) // Horizontal Display End - -#define M_vdc_VSW (VSR & 0x1F) // Vertical synchro width -#define M_vdc_VDS ((VSR >> 8) & 0xFF) // Vertical Display Start -#define M_vdc_VDW (VDR & 0x1FF) // Vertical Display Width(Height? :b) -#define M_vdc_VCR (VCR & 0xFF) - -#define M_vdc_EX ((CR >> 4) & 0x3) -#define M_vdc_TE ((CR >> 8) & 0x3) - -#define VDCS_CR 0x01 // Sprite #0 collision interrupt occurred -#define VDCS_OR 0x02 // sprite overflow "" "" -#define VDCS_RR 0x04 // RCR "" "" -#define VDCS_DS 0x08 // VRAM to SAT DMA completion interrupt occurred -#define VDCS_DV 0x10 // VRAM to VRAM DMA completion interrupt occurred -#define VDCS_VD 0x20 // Vertical blank interrupt occurred -#define VDCS_BSY 0x40 // VDC is waiting for a CPU access slot during the active display area?? - -uint32 VDC::GetRegister(const unsigned int id, char *special, const uint32 special_len) -{ - uint32 value = 0xDEADBEEF; - - switch(id) - { - case GSREG_SELECT: - value = select; - break; - - case GSREG_STATUS: - value = status; - break; - - case GSREG_MAWR: - value = MAWR; - break; - - case GSREG_MARR: - value = MARR; - break; - - case GSREG_CR: - value = CR; - - if(special) - { - trio_snprintf(special, special_len, "Sprite Hit IRQ: %s, Sprite Overflow IRQ: %s, RCR IRQ: %s, VBlank IRQ: %s, Sprites: %s, Background: %s", (value & 1) ? "On" : "Off", (value & 2) ? "On" : "Off", - (value & 4) ? "On" : "Off", (value & 8) ? "On" : "Off", (value & 0x40) ? "On" : "Off", (value & 0x80) ? "On" : "Off"); - } - break; - - case GSREG_RCR: - value = RCR; - break; - - case GSREG_BXR: - value = BXR; - break; - - case GSREG_BYR: - value = BYR; - break; - - case GSREG_MWR: - value = MWR; - - if(special) - { - trio_snprintf(special, special_len, "CG Mode: %d, BAT Width: %d(tiles), BAT Height: %d(tiles)", (int)(bool)(value & 0x80), - bat_width_tab[(value >> 4) & 0x3], - bat_height_tab[(value >> 6) & 0x1]); - } - break; - - case GSREG_HSR: - value = HSR; - if(special) - { - trio_snprintf(special, special_len, "HSW: %02x, HDS: %02x", value & 0x1F, (value >> 8) & 0x7F); - } - break; - - case GSREG_HDR: - value = HDR; - if(special) - { - trio_snprintf(special, special_len, "HDW: %02x, HDE: %02x", value & 0x7F, (value >> 8) & 0x7F); - } - break; - - - case GSREG_VSR: - value = VSR; - if(special) - { - trio_snprintf(special, special_len, "VSW: %02x, VDS: %02x", value & 0x1F, (value >> 8) & 0xFF); - } - break; - - case GSREG_VDR: - value = VDR; - break; - - case GSREG_VCR: - value = VCR; - break; - - case GSREG_DCR: - value = DCR; - if(special) - { - trio_snprintf(special, special_len, "SATB DMA IRQ: %s, VRAM DMA IRQ: %s, DMA Source Address: %s, DMA Dest Address: %s, Auto SATB DMA: %s", - (DCR & 0x1) ? "On" : "Off", (DCR & 0x2) ? "On" : "Off", (DCR & 0x4) ? "Decrement" : "Increment", (DCR & 0x8) ? "Decrement" : "Increment", - (DCR & 0x10) ? "On" : "Off"); - } - break; - - case GSREG_SOUR: - value = SOUR; - break; - - case GSREG_DESR: - value = DESR; - break; - - case GSREG_LENR: - value = LENR; - break; - - case GSREG_DVSSR: - value = DVSSR; - break; - } - - return(value); -} - -void VDC::SetRegister(const unsigned int id, const uint32 value) -{ - switch(id) - { - default: break; - - case GSREG_STATUS: - status = value & 0x3F; - break; - - case GSREG_SELECT: - select = value & 0x1F; - break; - - case GSREG_MAWR: - MAWR = value & 0xFFFF; - break; - - case GSREG_MARR: - MARR = value & 0xFFFF; - break; - - case GSREG_CR: - CR = value & 0xFFFF; - break; - - case GSREG_RCR: - RCR = value & 0x3FF; - break; - - case GSREG_BXR: - BXR = value & 0x3FF; - break; - - case GSREG_BYR: - BYR = value & 0x1FF; - break; - - case GSREG_MWR: - MWR = value & 0xFFFF; - break; - - case GSREG_HSR: - HSR = value & 0xFFFF; - break; - - case GSREG_HDR: - HDR = value & 0xFFFF; - break; - - case GSREG_VSR: - VSR = value & 0xFFFF; - break; - - case GSREG_VDR: - VDR = value & 0xFFFF; - break; - - case GSREG_VCR: - VCR = value & 0xFFFF; - break; - - case GSREG_DCR: - DCR = value & 0xFFFF; - break; - - case GSREG_SOUR: - SOUR = value & 0xFFFF; - break; - - case GSREG_DESR: - DESR = value & 0xFFFF; - break; - - case GSREG_LENR: - LENR = value & 0xFFFF; - break; - - case GSREG_DVSSR: - DVSSR = value & 0xFFFF; - break; - } -} - -void VDC::SetLayerEnableMask(uint64 mask) -{ - userle = mask; -} - -void VDC::RunSATDMA(int32 cycles, bool force_completion) -{ - assert(sat_dma_counter > 0); - - if(force_completion) - cycles = sat_dma_counter; - - sat_dma_counter -= cycles; - if(sat_dma_counter <= 0) - { - if(DCR & 0x01) - { - VDC_DEBUG("Sprite DMA IRQ"); - status |= VDCS_DS; - IRQHook(TRUE); - } - CheckAndCommitPending(); - burst_mode = true; - } -} - -void VDC::RunDMA(int32 cycles, bool force_completion) -{ - int num_transfers = 0; - - if(force_completion) - { - VDMA_CycleCounter = 0; - - num_transfers = 65536 * 2; - } - else - { - VDMA_CycleCounter += cycles; - num_transfers = VDMA_CycleCounter >> 1; - VDMA_CycleCounter -= num_transfers << 1; - } - - while(num_transfers--) - { - if(!DMAReadWrite) - { - if(SOUR >= VRAM_Size) - VDC_UNDEFINED("Unmapped VRAM DMA read"); - - DMAReadBuffer = VRAM[SOUR]; - //printf("DMA Read: %04x, %04x\n", SOUR, DMAReadBuffer); - } - else - { - if(DESR < VRAM_Size) - { - VRAM[DESR] = DMAReadBuffer; - FixTileCache(DESR); - } - - SOUR += (((DCR & 0x4) >> 1) ^ 2) - 1; - DESR += (((DCR & 0x8) >> 2) ^ 2) - 1; - LENR--; - - if(LENR == 0xFFFF) // DMA is done. - { - DMARunning = 0; // Clear this BEFORE CheckAndCommitPending() - - CheckAndCommitPending(); - - if(DCR & 0x02) - { - status |= VDCS_DV; - IRQHook(TRUE); - VDC_DEBUG("DMA IRQ"); - } - break; - } - } - DMAReadWrite ^= 1; - } -} - -/* - ChrlyMac: Was it you who determined exactly how many VDC clocks the SAT DMA took? - I know someone did, but I can't remember the results... - 1024 - It happens at the VDW->VCR transition -*/ - -void VDC::IncRCR(void) -{ - if(NeedBGYInc) - { - NeedBGYInc = false; - if(0 == RCRCount) - BG_YMoo = BYR; - else - BG_YMoo++; - } - - NeedBGYInc = true; - RCRCount++; - - VPhaseCounter--; - - if(VPhaseCounter <= 0) - { - VPhase = (VPhase + 1) % VPHASE_COUNT; - switch(VPhase) - { - case VPHASE_VDS: VPhaseCounter = VDS_cache + 2; - break; - - case VPHASE_VDW: VPhaseCounter = VDW_cache + 1; - //BG_YMoo = BYR - 1; - RCRCount = 0; - burst_mode = !(CR & 0xC0); - NeedVBIRQTest = true; - NeedSATDMATest = true; - - if(!burst_mode) - { - if(sat_dma_counter > 0) - { - printf("SAT DMA cancelled???\n"); - sat_dma_counter = 0; - CheckAndCommitPending(); - } - if(DMARunning) - { - printf("DMA Running Cancelled\n"); - DMARunning = false; - CheckAndCommitPending(); - } - } - break; - - case VPHASE_VCR: VPhaseCounter = VCR_cache; - break; - - case VPHASE_VSW: VPhaseCounter = VSW_cache + 1; - MWR_cache = MWR; - VDS_cache = M_vdc_VDS; - VSW_cache = M_vdc_VSW; - VDW_cache = M_vdc_VDW; - VCR_cache = M_vdc_VCR; - //VDC_WARNING("VSW Started"); - break; - } - } - - if(VPhase == VPHASE_VDW && !burst_mode) - { - FetchSpriteData(); - } - - if((int)RCRCount == ((int)RCR - 0x40) && (CR & 0x04)) - { - VDC_DEBUG("RCR IRQ"); - status |= VDCS_RR; - IRQHook(TRUE); - } -} - -void VDC::DoVBIRQTest(void) -{ - if(CR & 0x08) - { - VDC_DEBUG("VBlank IRQ"); - status |= VDCS_VD; - IRQHook(TRUE); - } -} - -static const int Cycles_Between_RCRIRQ_And_HDWEnd = 4; - -int VDC::TimeFromHDSStartToBYRLatch(void) -{ - int ret = 1; - - if(HDS_cache > 2) - ret += ((HDS_cache + 1) * 8) - 24 + 2; - - - //printf("%d, %d\n", HDS_cache, ret); - - return(ret); -} - -int VDC::TimeFromBYRLatchToBXRLatch(void) -{ - int ret = 2; - - if(HDS_cache > 2) - ret = 1; - - return(ret); -} - -void VDC::HDS_Start(void) -{ - if(NeedRCRInc) - { - IncRCR(); - NeedRCRInc = false; - } - - if(sprite_cg_fetch_counter > 0) - { - VDC_WARNING("Sprite truncation on %d. Wanted sprites: %d, cycles needed but not left: %d\n", RCRCount, active_sprites, sprite_cg_fetch_counter); - sprite_cg_fetch_counter = 0; - CheckAndCommitPending(); - } - - HSW_cache = M_vdc_HSW; - HDS_cache = M_vdc_HDS; - HDW_cache = M_vdc_HDW; - HDE_cache = M_vdc_HDE; - - VDC_DEBUG("HDS Start! HSW: %d, HDW: %d, HDW: %d, HDE: %d\n", HSW_cache, HDS_cache, HDW_cache, HDE_cache); - - CR_cache = CR; - - HPhase = HPHASE_HDS; - HPhaseCounter = TimeFromHDSStartToBYRLatch(); -} - -int32 VDC::HSync(bool hb) -{ - if(M_vdc_EX) - { - in_exhsync = 0; - return(CalcNextEvent()); - } - in_exhsync = hb; - - if(hb) // Going into hsync - { - mystery_counter = 48; - mystery_phase = false; - } - else // Leaving hsync - { - HPhase = HPHASE_HSW; - HPhaseCounter = 8; - - //HDS_Start(); - //HPhaseCounter += 8; - - pixel_copy_count = 0; - } - - - return(CalcNextEvent()); -} - -int32 VDC::VSync(bool vb) -{ - if(M_vdc_EX >= 0x2) - { - in_exvsync = 0; - return(CalcNextEvent()); - } - in_exvsync = vb; - - //printf("VBlank: %d\n", vb); - if(vb) // Going into vsync - { - NeedRCRInc = false; - NeedBGYInc = false; -/* if(NeedRCRInc) - { - IncRCR(); - NeedRCRInc = false; - } -*/ - MWR_cache = MWR; - - VDS_cache = M_vdc_VDS; - VSW_cache = M_vdc_VSW; - VDW_cache = M_vdc_VDW; - VCR_cache = M_vdc_VCR; - - VPhase = VPHASE_VSW; - VPhaseCounter = VSW_cache + 1; - } - else // Leaving vsync - { - - } - return(CalcNextEvent()); -} - -//int32 VDC::Run(int32 clocks, bool hs, bool vs, uint16 *pixels, bool skip) -int32 VDC::Run(int32 clocks, uint16 *pixels, bool skip) -{ - //uint16 *spixels = pixels; - - //puts("Run begin"); - //fflush(stdout); - - while(clocks > 0) - { - int32 chunk_clocks = clocks; - - if(chunk_clocks > HPhaseCounter) - { - chunk_clocks = HPhaseCounter; - } - - if(sat_dma_counter > 0 && chunk_clocks > sat_dma_counter) - chunk_clocks = sat_dma_counter; - - if(sprite_cg_fetch_counter > 0 && chunk_clocks > sprite_cg_fetch_counter) - chunk_clocks = sprite_cg_fetch_counter; - - if(mystery_counter > 0 && chunk_clocks > mystery_counter) - chunk_clocks = mystery_counter; - - if(mystery_counter > 0) - { - mystery_counter -= chunk_clocks; - if(mystery_counter <= 0) - { - mystery_phase = !mystery_phase; - if(mystery_phase) - mystery_counter = 16; - else - CheckAndCommitPending(); - } - } - - if(sprite_cg_fetch_counter > 0) - { - sprite_cg_fetch_counter -= chunk_clocks; - if(sprite_cg_fetch_counter <= 0) - CheckAndCommitPending(); - } - - if(VPhase != VPHASE_VDW) - { - if(NeedSATDMATest) - { - NeedSATDMATest = false; - if(SATBPending || (DCR & 0x10)) - { - SATBPending = 0; - - sat_dma_counter = 1024; - - if(DVSSR > (VRAM_Size - 0x100)) - VDC_UNDEFINED("Unmapped VRAM DVSSR DMA read"); - - if(DVSSR < VRAM_Size) - { - uint32 len = 256; - if(DVSSR > (VRAM_Size - 0x100)) - len = VRAM_Size - DVSSR; - memcpy(SAT, &VRAM[DVSSR], len * sizeof(uint16)); - } - } - } - } - - - - - if(DMAPending && burst_mode) - { - VDC_DEBUG("DMA Started"); - DMAPending = false; - DMARunning = true; - VDMA_CycleCounter = 0; - DMAReadWrite = 0; - } - - if(sat_dma_counter > 0) - RunSATDMA(chunk_clocks); - else if(DMARunning) - RunDMA(chunk_clocks); - - if(pixel_copy_count > 0) - { - if(!skip) - { - for(int i = 0; i < chunk_clocks; i++) - pixels[i] = linebuf[pixel_desu + i]; - //memcpy(pixels, linebuf + pixel_desu, chunk_clocks * sizeof(uint16)); - - if(M_vdc_TE == 0x1) - for(int i = 0; i < chunk_clocks; i++) - pixels[i] |= VDC_DISP_OUT_MASK; - } - - pixel_desu += chunk_clocks; - pixel_copy_count -= chunk_clocks; - } - else - { - uint16 pix = 0x100; - - if(M_vdc_TE == 0x1) - { - if(HPhase != HPHASE_HDS && HPhase != HPHASE_HDS_PART2 && HPhase != HPHASE_HDS_PART3) - pix |= VDC_DISP_OUT_MASK; - } - - if(HPhase == HPHASE_HSW) - { - if(M_vdc_EX >= 0x1) - pix |= VDC_HSYNC_OUT_MASK; - - if(M_vdc_TE >= 0x2) - pix |= VDC_DISP_OUT_MASK; - } - if(VPhase == VPHASE_VSW && M_vdc_EX >= 0x2) - pix |= VDC_VSYNC_OUT_MASK; - - if(!(userle & 1)) - pix |= VDC_BGDISABLE_OUT_MASK; - - if(!skip) - { - for(int i = 0; i < chunk_clocks; i++) - pixels[i] = pix; - } - } - - HPhaseCounter -= chunk_clocks; - - assert(HPhaseCounter >= 0); - - while(HPhaseCounter <= 0) - { - HPhase = (HPhase + 1) % HPHASE_COUNT; - - switch(HPhase) - { - case HPHASE_HDS: HDS_Start(); - break; - - - case HPHASE_HDS_PART2: - HPhaseCounter = TimeFromBYRLatchToBXRLatch(); - - if(NeedBGYInc && !in_exhsync) - { - NeedBGYInc = false; - - if(0 == RCRCount) - BG_YMoo = BYR; - else - BG_YMoo++; - } - BG_YOffset = BG_YMoo; - break; - - case HPHASE_HDS_PART3: - HPhaseCounter = (HDS_cache + 1) * 8 - TimeFromHDSStartToBYRLatch() - TimeFromBYRLatchToBXRLatch(); - - assert(HPhaseCounter > 0); - - BG_XOffset = BXR; - break; - - case HPHASE_HDW: - NeedRCRInc = true; - if(VPhase != VPHASE_VDW && NeedVBIRQTest) - { - DoVBIRQTest(); - NeedVBIRQTest = false; - } - CheckAndCommitPending(); - - HPhaseCounter = (HDW_cache + 1) * 8 - Cycles_Between_RCRIRQ_And_HDWEnd; - if(VPhase == VPHASE_VDW) - { - if(!burst_mode) - { - pixel_desu = 0; - pixel_copy_count = (HDW_cache + 1) * 8; - - // BG off, sprite on: fill = 0x100. bg off, sprite off: fill = 0x000 - if(!(CR_cache & 0x80)) - { - uint16 fill_val; - - if(!(CR_cache & 0xC0)) // Sprites and BG off - fill_val = 0x000; - else // Only BG off - fill_val = 0x100 | ((userle & ULE_BG) ? 0 : VDC_BGDISABLE_OUT_MASK); - - if(!(userle & ULE_BG)) - fill_val |= VDC_BGDISABLE_OUT_MASK; - - for(int i = 0; i < pixel_copy_count; i++) - linebuf[i] = fill_val; - } - - if(!skip) - if(CR_cache & 0x80) - { - DrawBG(linebuf, userle & ULE_BG); - } - //printf("%d %02x %02x\n", RCRCount, CR, CR_cache); - if(CR_cache & 0x40) - DrawSprites(linebuf, (userle & ULE_SPR) && !skip); - } - } - break; - - case HPHASE_HDW_FINAL: - if(NeedRCRInc) - { - IncRCR(); - NeedRCRInc = false; - } - HPhaseCounter = Cycles_Between_RCRIRQ_And_HDWEnd; - break; - - case HPHASE_HDE: //if(!burst_mode) //if(VPhase == VPHASE_VDW) //if(!burst_mode) - // lastats = 16; // + 16; - //else - // lastats = 16; - HPhaseCounter = (HDE_cache + 1) * 8; - break; - - case HPHASE_HSW: HPhaseCounter = (HSW_cache + 1) * 8; break; - } - } - pixels += chunk_clocks; - clocks -= chunk_clocks; - } - - //puts("Run end"); - //fflush(stdout); - - return(CalcNextEvent()); -} - - -void VDC::CalcWidthStartEnd(uint32 &display_width, uint32 &start, uint32 &end) -{ - display_width = (M_vdc_HDW + 1) * 8; - - start = 0; - end = start + display_width; -} - -void VDC::DrawBG(uint16 *target, int enabled) -{ - uint32 width; - uint32 start; - uint32 end; - int bat_width = bat_width_tab[(MWR_cache >> 4) & 3]; - int bat_width_mask = bat_width - 1; - int bat_width_shift = bat_width_shift_tab[(MWR_cache >> 4) & 3]; - int bat_height_mask = bat_height_tab[(MWR_cache >> 6) & 1] - 1; - - CalcWidthStartEnd(width, start, end); - - if(!enabled) - { - for(uint32 x = start; x < end; x++) - target[x] = 0x000 | VDC_BGDISABLE_OUT_MASK; - return; - } - - { - int bat_y = ((BG_YOffset >> 3) & bat_height_mask) << bat_width_shift; - uint32 first_end = start + 8 - (BG_XOffset & 7); - uint32 dohmask = 0xFFFFFFFF; - - if((MWR_cache & 0x3) == 0x3) - { - if(MWR_cache & 0x80) - dohmask = 0xCCCCCCCC; - else - dohmask = 0x33333333; - } - - // Draw the first pixels of the first tile, depending on the lower 3 bits of the xscroll/xoffset register, to - // we can render the rest of the line in 8x1 chunks, which is faster. - for(uint32 x = start; x < first_end; x++) - { - int bat_x = (BG_XOffset >> 3) & bat_width_mask; - uint16 bat = VRAM[bat_x | bat_y]; - const uint8 pal_or = ((bat >> 8) & 0xF0); - int palette_index = ((bat >> 12) & 0x0F) << 4; - uint32 raw_pixel; - - raw_pixel = bg_tile_cache[bat & 0xFFF][BG_YOffset & 7][BG_XOffset & 0x7] & dohmask; - target[x] = palette_index | raw_pixel | pal_or; - - if((bat & 0xFFF) > VRAM_BGTileNoMask) - VDC_UNDEFINED("Unmapped BG tile read"); - - BG_XOffset++; - } - - int bat_boom = (BG_XOffset >> 3) & bat_width_mask; - int line_sub = BG_YOffset & 7; - - if((MWR_cache & 0x3) == 0x3) - { - for(uint32 x = first_end; x < end; x+=8) - { - const uint16 bat = VRAM[bat_boom | bat_y]; - const uint8 pal_or = ((bat >> 8) & 0xF0); - uint8 *pix_lut = bg_tile_cache[bat & 0xFFF][line_sub]; - - if((bat & 0xFFF) > VRAM_BGTileNoMask) - VDC_UNDEFINED("Unmapped BG tile read"); - - - (target + 0)[x] = (pix_lut[0] & dohmask) | pal_or; - (target + 1)[x] = (pix_lut[1] & dohmask) | pal_or; - (target + 2)[x] = (pix_lut[2] & dohmask) | pal_or; - (target + 3)[x] = (pix_lut[3] & dohmask) | pal_or; - (target + 4)[x] = (pix_lut[4] & dohmask) | pal_or; - (target + 5)[x] = (pix_lut[5] & dohmask) | pal_or; - (target + 6)[x] = (pix_lut[6] & dohmask) | pal_or; - (target + 7)[x] = (pix_lut[7] & dohmask) | pal_or; - - bat_boom = (bat_boom + 1) & bat_width_mask; - BG_XOffset++; - - } - } - else - for(uint32 x = first_end; x < end; x+=8) // This will draw past the right side of the buffer, but since our pitch is 1024, and max width is ~512, we're safe. Also, - // any overflow that is on the visible screen are will be hidden by the overscan color code below this code. - { - const uint16 bat = VRAM[bat_boom | bat_y]; - const uint8 pal_or = ((bat >> 8) & 0xF0); - uint8 *pix_lut = bg_tile_cache[bat & 0xFFF][line_sub]; - - if((bat & 0xFFF) > VRAM_BGTileNoMask) - VDC_UNDEFINED("Unmapped BG tile read"); - - #ifdef LSB_FIRST - #if SIZEOF_LONG == 8 - uint64 doh = *(uint64 *)pix_lut; - - (target + 0)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 1)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 2)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 3)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 4)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 5)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 6)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 7)[x] = (doh) | pal_or; - #else - uint32 doh = *(uint32 *)pix_lut; - (target + 0)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 1)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 2)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 3)[x] = doh | pal_or; - doh = *(uint32 *)(pix_lut + 4); - (target + 4)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 5)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 6)[x] = (doh & 0xFF) | pal_or; - doh >>= 8; - (target + 7)[x] = doh | pal_or; - #endif - #else - (target + 0)[x] = pix_lut[0] | pal_or; - (target + 1)[x] = pix_lut[1] | pal_or; - (target + 2)[x] = pix_lut[2] | pal_or; - (target + 3)[x] = pix_lut[3] | pal_or; - (target + 4)[x] = pix_lut[4] | pal_or; - (target + 5)[x] = pix_lut[5] | pal_or; - (target + 6)[x] = pix_lut[6] | pal_or; - (target + 7)[x] = pix_lut[7] | pal_or; - #endif - - bat_boom = (bat_boom + 1) & bat_width_mask; - BG_XOffset++; - } - } -} - -#define SPRF_PRIORITY 0x00080 -#define SPRF_HFLIP 0x00800 -#define SPRF_VFLIP 0x08000 -#define SPRF_SPRITE0 0x10000 - -static const unsigned int sprite_height_tab[4] = { 16, 32, 64, 64 }; -static const unsigned int sprite_height_no_mask[4] = { ~0U, ~2U, ~6U, ~6U }; -static const unsigned int sprite_width_tab[2] = { 16, 32 }; - -void VDC::FetchSpriteData(void) -{ - active_sprites = 0; - - // First, grab the up to 16 sprites. - for(int i = 0; i < 64; i++) - { - int16 y = (SAT[i * 4 + 0] & 0x3FF) - 0x40; - uint16 x = (SAT[i * 4 + 1] & 0x3FF); - uint16 no = (SAT[i * 4 + 2] >> 1) & 0x3FF; // Todo, cg mode bit - uint16 flags = (SAT[i * 4 + 3]); - - uint32 palette_index = (flags & 0xF) << 4; - uint32 height = sprite_height_tab[(flags >> 12) & 3]; - uint32 width = sprite_width_tab[(flags >> 8) & 1]; - - if((int32)RCRCount >= y && (int32)RCRCount < (int32)(y + height)) - { - bool second_half = 0; - uint32 y_offset = RCRCount - y; - if(y_offset > height) continue; - - - breepbreep: - - if(active_sprites == 16) - { - if(CR & 0x2) - { - status |= VDCS_OR; - IRQHook(TRUE); - VDC_DEBUG("Overflow IRQ"); - } - if(!unlimited_sprites) - break; - } - - - { - if(flags & SPRF_VFLIP) - y_offset = height - 1 - y_offset; - - no &= sprite_height_no_mask[(flags >> 12) & 3]; - no |= (y_offset & 0x30) >> 3; - if(width == 32) no &= ~1; - if(second_half) - no |= 1; - - SpriteList[active_sprites].flags = flags; - - if(flags & SPRF_HFLIP && width == 32) - no ^= 1; - //printf("Found: %d %d\n", RCRCount, x); - SpriteList[active_sprites].x = x; - SpriteList[active_sprites].palette_index = palette_index; - - if((no * 64) >= VRAM_Size) - VDC_UNDEFINED("Unmapped VRAM sprite tile read"); - - if((MWR_cache & 0xC) == 4) - { - if(SAT[i * 4 + 2] & 1) - { - SpriteList[active_sprites].pattern_data[0] = VRAM[no * 64 + (y_offset & 15) + 32]; - SpriteList[active_sprites].pattern_data[1] = VRAM[no * 64 + (y_offset & 15) + 48]; - SpriteList[active_sprites].pattern_data[2] = 0; - SpriteList[active_sprites].pattern_data[3] = 0; - } - else - { - SpriteList[active_sprites].pattern_data[0] = VRAM[no * 64 + (y_offset & 15) ]; - SpriteList[active_sprites].pattern_data[1] = VRAM[no * 64 + (y_offset & 15) + 16]; - SpriteList[active_sprites].pattern_data[2] = 0; - SpriteList[active_sprites].pattern_data[3] = 0; - } - } - else - { - SpriteList[active_sprites].pattern_data[0] = VRAM[no * 64 + (y_offset & 15) ]; - SpriteList[active_sprites].pattern_data[1] = VRAM[no * 64 + (y_offset & 15) + 16]; - SpriteList[active_sprites].pattern_data[2] = VRAM[no * 64 + (y_offset & 15) + 32]; - SpriteList[active_sprites].pattern_data[3] = VRAM[no * 64 + (y_offset & 15) + 48]; - } - - SpriteList[active_sprites].flags |= i ? 0 : SPRF_SPRITE0; - - active_sprites++; - - if(width == 32 && !second_half) - { - second_half = 1; - x += 16; - y_offset = RCRCount - y; // Fix the y offset so that sprites that are hflipped + vflipped display properly - goto breepbreep; - } - } - } - } - - sprite_cg_fetch_counter = ((active_sprites < 16) ? active_sprites : 16) * 4; -} - -void VDC::DrawSprites(uint16 *target, int enabled) -{ - MDFN_ALIGN(16) uint16 sprite_line_buf[1024]; - - uint32 display_width, start, end; - - CalcWidthStartEnd(display_width, start, end); - - for(unsigned int i = start; i < end; i++) - sprite_line_buf[i] = 0; - - for(int i = (active_sprites - 1) ; i >= 0; i--) - { - int32 pos = SpriteList[i].x - 0x20 + start; - uint32 prio_or = 0; - - if(SpriteList[i].flags & SPRF_PRIORITY) - prio_or = 0x200; - - if((SpriteList[i].flags & SPRF_SPRITE0) && (CR & 0x01)) - { - for(uint32 x = 0; x < 16; x++) - { - uint32 raw_pixel; - uint32 pi = SpriteList[i].palette_index; - uint32 rev_x = 15 - x; - - if(SpriteList[i].flags & SPRF_HFLIP) - rev_x = x; - - raw_pixel = (SpriteList[i].pattern_data[0] >> rev_x) & 1; - raw_pixel |= ((SpriteList[i].pattern_data[1] >> rev_x) & 1) << 1; - raw_pixel |= ((SpriteList[i].pattern_data[2] >> rev_x) & 1) << 2; - raw_pixel |= ((SpriteList[i].pattern_data[3] >> rev_x) & 1) << 3; - - if(raw_pixel) - { - pi |= 0x100; - uint32 tx = pos + x; - - if(tx >= end) // Covers negative and overflowing the right side. - continue; - - if(sprite_line_buf[tx] & 0xF) - { - status |= VDCS_CR; - VDC_DEBUG("Sprite hit IRQ"); - IRQHook(TRUE); - } - sprite_line_buf[tx] = pi | raw_pixel | prio_or; - } - } - } // End sprite hit loop - else - { - for(uint32 x = 0; x < 16; x++) - { - uint32 raw_pixel; - uint32 pi = SpriteList[i].palette_index; - uint32 rev_x = 15 - x; - - if(SpriteList[i].flags & SPRF_HFLIP) - rev_x = x; - - raw_pixel = (SpriteList[i].pattern_data[0] >> rev_x) & 1; - raw_pixel |= ((SpriteList[i].pattern_data[1] >> rev_x) & 1) << 1; - raw_pixel |= ((SpriteList[i].pattern_data[2] >> rev_x) & 1) << 2; - raw_pixel |= ((SpriteList[i].pattern_data[3] >> rev_x) & 1) << 3; - - if(raw_pixel) - { - pi |= 0x100; - uint32 tx = pos + x; - - if(tx >= end) // Covers negative and overflowing the right side. - continue; - sprite_line_buf[tx] = pi | raw_pixel | prio_or; - } - } - } // End non-sprite-hit loop - } - - if(enabled) - { - for(unsigned int x = start; x < end; x++) - { - if(sprite_line_buf[x] & 0x0F) - { - if(!(target[x] & 0x0F) || (sprite_line_buf[x] & 0x200)) - target[x] = sprite_line_buf[x] & 0x1FF; - } - } - } - active_sprites = 0; -} - -/* - Caution: If we ever add something to Write() or Read() that will affect the timing of the next event, make sure - to set the passed-by-reference next_event BEFORE calling this function, or otherwise re-engineer this convoluted setup. -*/ -void VDC::DoWaitStates(void) -{ - //bool did_wait = VDC_IS_BSY; - - while(VDC_IS_BSY) - { - //int32 to_wait = CalcNextEvent(); - //if(!WSHook || !WSHook(to_wait)) - if(!WSHook || !WSHook(-1)) // Event-counter-based wait-stating - { - if(DMARunning) - { - VDC_WARNING("VRAM DMA completion forced."); - RunDMA(0, TRUE); - } - - if(sat_dma_counter > 0) - { - VDC_WARNING("SAT DMA completion forced."); - RunSATDMA(0, TRUE); - } - - if(mystery_phase) - { - bool backup_mystery_phase = mystery_phase; - mystery_phase = false; - CheckAndCommitPending(); - mystery_phase = backup_mystery_phase; - } - - break; - } - } - - //if(did_wait) - // printf("End of wait stating: %d %d\n", VDMA_CycleCounter, sat_dma_counter); - - assert(!pending_read); - assert(!pending_write); -} - -uint8 VDC::Read(uint32 A, int32 &next_event, bool peek) -{ - uint8 ret = 0; - int msb = A & 1; - - A &= 0x3; - - switch(A) - { - case 0x0: ret = status | (VDC_IS_BSY ? 0x40 : 0x00); - - if(!peek) - { - status &= ~0x3F; - IRQHook(FALSE); - } - break; - - case 0x2: - case 0x3: - if(!peek) - { - // Should we only wait on MSB reads... - DoWaitStates(); - } - - ret = VDC_REGGETP(read_buffer, msb); - - if(select == 0x2) // VRR - VRAM Read Register - { - if(msb) - { - if(!peek) - { - pending_read = TRUE; - pending_read_addr = MARR; - MARR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - } - } - } - break; - } - - return(ret); -} - -uint16 VDC::Read16(bool A, bool peek) -{ - uint16 ret = 0; - - if(!A) - { - ret = status | (VDC_IS_BSY ? 0x40 : 0x00); - - if(!peek) - { - status &= ~0x3F; - IRQHook(FALSE); - } - } - else - { - if(!peek) - DoWaitStates(); - - ret = read_buffer; - - if(select == 0x2) // VRR - VRAM Read Register - { - if(!peek) - { - pending_read = TRUE; - pending_read_addr = MARR; - MARR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - } - } - } - - return(ret); -} - - -void VDC::CheckAndCommitPending(void) -{ - if(sat_dma_counter <= 0 && !DMARunning /* && sprite_cg_fetch_counter <= 0*/ && !mystery_phase) - { - if(pending_write) - { - if(pending_write_addr < VRAM_Size) - { - VRAM[pending_write_addr] = pending_write_latch; - FixTileCache(pending_write_addr); - } - //else - // VDC_UNDEFINED("Unmapped VRAM write"); - - pending_write = FALSE; - } - - if(pending_read) - { - if(pending_read_addr >= VRAM_Size) - VDC_UNDEFINED("Unmapped VRAM VRR read"); - - read_buffer = VRAM[pending_read_addr]; - pending_read = FALSE; - } - } -} - - -void VDC::Write(uint32 A, uint8 V, int32 &next_event) -{ - int msb = A & 1; - - A &= 0x3; - - //if((A == 0x2 || A == 0x3) && (select >= 0xF && select <= 0x12)) - //if((A == 2 || A == 3) && select != 2) - // printf("VDC Write(RCRCount=%d): A=%02x, Select=%02x, V=%02x\n", RCRCount, A, select, V); - - switch(A) - { - case 0x0: select = V & 0x1F; - break; - - case 0x2: - case 0x3: - //if((select & 0x1F) >= 0x9 && (select & 0x1F) <= 0x1F) - // VDC_DEBUG("%02x %d, %02x", select & 0x1F, msb, V); - - switch(select & 0x1F) - { - case 0x00: VDC_REGSETP(MAWR, V, msb); - break; - - case 0x01: VDC_REGSETP(MARR, V, msb); - if(msb) - { - DoWaitStates(); - - pending_read = TRUE; - pending_read_addr = MARR; - MARR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - } - break; - - case 0x02: if(!msb) - { - write_latch = V; - } - else - { - // We must call CommitPendingWrite at the end of SAT/VRAM DMA for this to work! - DoWaitStates(); - - pending_write = TRUE; - pending_write_addr = MAWR; - pending_write_latch = write_latch | (V << 8); - MAWR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - } - break; - - case 0x05: VDC_REGSETP(CR, V, msb); - //printf("CR: %04x, %d\n", CR, msb); - break; - - case 0x06: VDC_REGSETP(RCR, V, msb); - RCR &= 0x3FF; - break; - - case 0x07: VDC_REGSETP(BXR, V, msb); - BXR &= 0x3FF; - //VDC_DEBUG("BXR Set"); - break; - - case 0x08: VDC_REGSETP(BYR, V, msb); - BYR &= 0x1FF; - BG_YMoo = BYR; // Set it on LSB and MSB writes(only changing on MSB breaks Youkai Douchuuki) - //VDC_DEBUG("BYR Set"); - break; - - case 0x09: VDC_REGSETP(MWR, V, msb); break; - case 0x0a: VDC_REGSETP(HSR, V, msb); break; - case 0x0b: VDC_REGSETP(HDR, V, msb); break; - case 0x0c: VDC_REGSETP(VSR, V, msb); break; - case 0x0d: VDC_REGSETP(VDR, V, msb); break; - case 0x0e: VDC_REGSETP(VCR, V, msb); break; - case 0x0f: VDC_REGSETP(DCR, V, msb); - if(DMARunning) - { - VDC_UNDEFINED("Set DCR during DMA: %04x\n", DCR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set DCR while DMAPending: %04x\n", DCR); - } - - break; - - case 0x10: VDC_REGSETP(SOUR, V, msb); - if(DMARunning) - { - VDC_UNDEFINED("Set SOUR during DMA: %04x\n", SOUR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set SOUR while DMAPending: %04x\n", SOUR); - } - break; - - case 0x11: VDC_REGSETP(DESR, V, msb); - if(DMARunning) - { - VDC_UNDEFINED("Set DESR during DMA: %04x\n", DESR); - } - if(DMAPending) - { - VDC_UNDEFINED("Set DESR while DMAPending: %04x\n", DESR); - } - break; - - case 0x12: VDC_REGSETP(LENR, V, msb); - if(DMARunning) - { - VDC_UNDEFINED("Set LENR during DMA: %04x\n", LENR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set LENR while DMAPending: %04x\n", LENR); - } - - if(msb) - { - VDC_DEBUG("DMA: %04x %04x %04x, %02x", SOUR, DESR, LENR, DCR); - DMAPending = 1; - } - break; - - case 0x13: VDC_REGSETP(DVSSR, V, msb); - SATBPending = 1; - break; - - default: VDC_WARNING("Unknown VDC register write: %04x %02x", select, V); - break; - } - break; - } -} - - -void VDC::Write16(bool A, uint16 V) -{ - if(!A) - select = V & 0x1F; - else - { - switch(select & 0x1F) - { - case 0x00: MAWR = V; - break; - - - case 0x01: MARR = V; - - DoWaitStates(); - - pending_read = TRUE; - pending_read_addr = MARR; - - MARR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - break; - - - case 0x02: // We must call CommitPendingWrite at the end of SAT/VRAM DMA for this to work! - DoWaitStates(); - - pending_write = TRUE; - pending_write_addr = MAWR; - pending_write_latch = V; - MAWR += vram_inc_tab[(CR >> 11) & 0x3]; - - CheckAndCommitPending(); - break; - - case 0x05: CR = V; - break; - - case 0x06: RCR = V & 0x3FF; - break; - - case 0x07: BXR = V & 0x3FF; - //VDC_DEBUG("BXR Set"); - break; - - case 0x08: BYR = V & 0x1FF; - BG_YMoo = BYR; - //VDC_DEBUG("BYR Set"); - break; - - case 0x09: MWR = V; break; - case 0x0a: HSR = V; break; - case 0x0b: HDR = V; break; - case 0x0c: VSR = V; break; - case 0x0d: VDR = V; break; - case 0x0e: VCR = V; break; - - case 0x0f: DCR = V; - if(DMARunning) - { - VDC_UNDEFINED("Set DCR during DMA: %04x\n", DCR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set DCR while DMAPending: %04x\n", DCR); - } - - break; - - case 0x10: SOUR = V; - if(DMARunning) - { - VDC_UNDEFINED("Set SOUR during DMA: %04x\n", SOUR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set SOUR while DMAPending: %04x\n", SOUR); - } - break; - - case 0x11: DESR = V; - if(DMARunning) - { - VDC_UNDEFINED("Set DESR during DMA: %04x\n", DESR); - } - if(DMAPending) - { - VDC_UNDEFINED("Set DESR while DMAPending: %04x\n", DESR); - } - break; - - case 0x12: LENR = V; - if(DMARunning) - { - VDC_UNDEFINED("Set LENR during DMA: %04x\n", LENR); - } - - if(DMAPending) - { - VDC_UNDEFINED("Set LENR while DMAPending: %04x\n", LENR); - } - - VDC_DEBUG("DMA: %04x %04x %04x, %02x", SOUR, DESR, LENR, DCR); - - DMAPending = 1; - break; - - case 0x13: DVSSR = V; - SATBPending = 1; - break; - - default: VDC_WARNING("Oops 2: %04x %02x", select, V); - break; - } - } - -} - - - -int32 VDC::Reset(void) -{ - memset(VRAM, 0, sizeof(VRAM)); - memset(SAT, 0, sizeof(SAT)); - memset(SpriteList, 0, sizeof(SpriteList)); - - for(uint32 A = 0; A < 65536; A += 16) - FixTileCache(A); - - pending_read = false; - pending_read_addr = 0xFFFF; - read_buffer = 0xFFFF; - write_latch = 0; - - pending_write = false; - pending_write_addr = 0xFFFF; - pending_write_latch = 0xFFFF; - - status = 0; - - HSR = 0; - HDR = 0; - VSR = 0; - VDR = 0; - VCR = 0; - - HSW_cache = M_vdc_HSW; - HDS_cache = M_vdc_HDS; - HDW_cache = M_vdc_HDW; - HDE_cache = M_vdc_HDE; - - VDS_cache = M_vdc_VDS; - VSW_cache = M_vdc_VSW; - VDW_cache = M_vdc_VDW; - VCR_cache = M_vdc_VCR; - - - - MAWR = 0; - MARR = 0; - - CR = CR_cache = 0; - RCR = 0; - BXR = 0; - BYR = 0; - MWR = 0; - MWR_cache = 0; - - DCR = 0; - SOUR = 0; - DESR = 0; - LENR = 0; - DVSSR = 0; - - VDMA_CycleCounter = 0; - - RCRCount = 0; - - DMAReadBuffer = 0; - DMAReadWrite = 0; - DMARunning = 0; - DMAPending = 0; - SATBPending = 0; - burst_mode = 0; - - BG_XOffset = 0; - BG_YOffset = 0; - BG_YMoo = 0; - - sat_dma_counter = 0; - select = 0; - - pixel_copy_count = 0; - - - NeedRCRInc = false; - NeedVBIRQTest = false; - NeedSATDMATest = false; - NeedBGYInc = false; - - HPhase = 0; - VPhase = 0; - HPhaseCounter = 1; - VPhaseCounter = 1; - - sprite_cg_fetch_counter = 0; - - mystery_counter = 0; - mystery_phase = false; - - pixel_desu = 0; - pixel_copy_count = 0; - active_sprites = 0; - - return(CalcNextEvent()); -} - -VDC::VDC(bool nospritelimit, uint32 par_VRAM_Size) -{ - unlimited_sprites = nospritelimit; //MDFN_GetSettingB("pce.nospritelimit"); - userle = ~0; - - assert(par_VRAM_Size == round_up_pow2(par_VRAM_Size)); - assert(par_VRAM_Size >= 16 && par_VRAM_Size <= 65536); - - VRAM_Size = par_VRAM_Size; - VRAM_SizeMask = VRAM_Size - 1; - VRAM_BGTileNoMask = VRAM_SizeMask / 16; - - WSHook = NULL; - IRQHook = NULL; - - in_exhsync = false; - in_exvsync = false; -} - -VDC::~VDC() -{ - -} - -void VDC::StateExtra(MDFN::LEPacker &sl_packer, bool load) -{ - sl_packer.set_read_mode(load); - - for(int i = 0; i < 64 * 2; i++) - { - sl_packer ^ SpriteList[i].x; - sl_packer ^ SpriteList[i].flags; - sl_packer ^ SpriteList[i].palette_index; - - for(int pd = 0; pd < 4; pd++) - sl_packer ^ SpriteList[i].pattern_data[pd]; - } -} - -int VDC::StateAction(StateMem *sm, int load, int data_only, const char *sname) -{ - int ret = 1; - MDFN::LEPacker sl_packer; - - StateExtra(sl_packer, false); - - SFORMAT StateRegs[] = - { - SFVAR(in_exhsync), - SFVAR(in_exvsync), - - SFVARN(sat_dma_counter, "sat_dma_counter"), - - SFVARN(select, "select"), - SFVARN(MAWR, "MAWR"), - SFVARN(MARR, "MARR"), - SFVARN(CR, "CR"), - SFVAR(CR_cache), - SFVARN(RCR, "RCR"), - SFVARN(BXR, "BXR"), - SFVARN(BYR, "BYR"), - SFVARN(MWR, "MWR"), - - SFVARN(HSR, "HSR"), - SFVARN(HDR, "HDR"), - SFVARN(VSR, "VSR"), - SFVARN(VDR, "VDR"), - - SFVARN(VCR, "VCR"), - SFVARN(DCR, "DCR"), - SFVARN(SOUR, "SOUR"), - SFVARN(DESR, "DESR"), - SFVARN(LENR, "LENR"), - SFVARN(DVSSR, "SATB"), - - - SFVAR(VDMA_CycleCounter), - - SFVARN(RCRCount, "RCRCount"), - - - SFVAR(pending_read), - SFVAR(pending_read_addr), - SFVAR(read_buffer), - - SFVAR(write_latch), - - SFVAR(pending_write), - SFVAR(pending_write_addr), - SFVAR(pending_write_latch), - - SFVARN(status, "status"), - - SFARRAY16N(SAT, 0x100, "SAT"), - - SFARRAY16N(VRAM, VRAM_Size, "VRAM"), - - SFVARN(DMAReadBuffer, "DMAReadBuffer"), - SFVARN(DMAReadWrite, "DMAReadWrite"), - SFVARN(DMARunning, "DMARunning"), - SFVAR(DMAPending), - SFVARN(SATBPending, "SATBPending"), - SFVARN(burst_mode, "burst_mode"), - - SFVARN(BG_YOffset, "BG_YOffset"), - SFVARN(BG_XOffset, "BG_XOffset"), - - SFVAR(HSW_cache), - SFVAR(HDS_cache), - SFVAR(HDW_cache), - SFVAR(HDE_cache), - - SFVARN(VDS_cache, "VDS_cache"), - SFVARN(VSW_cache, "VSW_cache"), - SFVARN(VDW_cache, "VDW_cache"), - SFVARN(VCR_cache, "VCR_cache"), - SFVARN(MWR_cache, "MWR_cache"), - - - SFVAR(BG_YMoo), - SFVAR(NeedRCRInc), - SFVAR(NeedVBIRQTest), - SFVAR(NeedSATDMATest), - SFVAR(NeedBGYInc), - - SFVAR(HPhase), - SFVAR(VPhase), - SFVAR(HPhaseCounter), - SFVAR(VPhaseCounter), - - SFVAR(sprite_cg_fetch_counter), - - SFVAR(mystery_counter), - SFVAR(mystery_phase), - - SFVAR(active_sprites), - - SFARRAYN(&sl_packer[0], sl_packer.size(), "ExtraState"), - //SFARRAY(SpriteListTemp, sizeof(SpriteListTemp)), - - SFEND - }; - - ret &= MDFNSS_StateAction(sm, load, data_only, StateRegs, sname); - - if(load) - { - StateExtra(sl_packer, true); - - for(int x = 0; x < VRAM_Size; x++) - FixTileCache(x); - } - - return(ret); -} - -#ifdef WANT_DEBUGGER -bool VDC::DoGfxDecode(uint32 *target, const uint32 *color_table, const uint32 TransparentColor, bool DecodeSprites, - int32 w, int32 h, int32 scroll) -{ - const uint32 *palette_ptr = color_table; - - if(DecodeSprites) - { - for(int y = 0; y < h; y++) - { - for(int x = 0; x < w; x += 16) - { - int which_tile = (x / 16) + (scroll + (y / 16)) * (w / 16); - - if(which_tile >= VRAM_Size / 64) - { - for(int sx = 0; sx < 16; sx++) - { - target[x + sx] = TransparentColor; - target[x + w * 1 + sx] = 0; - target[x + w * 2 + sx] = 0; - } - continue; - } - - uint16 cg[4]; - cg[0] = VRAM[which_tile * 64 + (y & 15)]; - cg[1] = VRAM[which_tile * 64 + (y & 15) + 16]; - cg[2] = VRAM[which_tile * 64 + (y & 15) + 32]; - cg[3] = VRAM[which_tile * 64 + (y & 15) + 48]; - for(int sx = 0; sx < 16; sx++) - { - int rev_sx = 15 - sx; - target[x + sx] = palette_ptr[(((cg[0] >> rev_sx) & 1) << 0) | - (((cg[1] >> rev_sx) & 1) << 1) | (((cg[2] >> rev_sx) & 1) << 2) | (((cg[3] >> rev_sx) & 1) << 3)]; - target[x + w * 1 + sx] = which_tile; - target[x + w * 2 + sx] = which_tile * 64; - } - } - target += w * 3; - } - } - else for(int y = 0; y < h; y++) - { - for(int x = 0; x < w; x+=8) - { - int which_tile = (x / 8) + (scroll + (y / 8)) * (w / 8); - - if(which_tile >= (VRAM_Size / 16)) - { - for(int sx = 0; sx < 8; sx++) - { - target[x + sx] = TransparentColor; - target[x + w * 1 + sx] = 0; - target[x + w * 2 + sx] = 0; - } - continue; - } - - target[x + 0] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][0]]; - target[x + 1] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][1]]; - target[x + 2] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][2]]; - target[x + 3] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][3]]; - target[x + 4] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][4]]; - target[x + 5] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][5]]; - target[x + 6] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][6]]; - target[x + 7] = palette_ptr[ bg_tile_cache[which_tile][y & 0x7][7]]; - - target[x + w*1 + 0]=target[x + w*1 + 1]=target[x + w*1 + 2]=target[x + w*1 + 3] = - target[x + w*1 + 4]=target[x + w*1 + 5]=target[x + w*1 + 6]=target[x + w*1 + 7] = which_tile; - - target[x + w*2 + 0]=target[x + w*2 + 1]=target[x + w*2 + 2]=target[x + w*2 + 3] = - target[x + w*2 + 4]=target[x + w*2 + 5]=target[x + w*2 + 6]=target[x + w*2 + 7] = which_tile * 16; - } - target += w * 3; - } - - return(1); -} -#endif - diff --git a/libmednahawk/src/hw_video/huc6270/vdc.h b/libmednahawk/src/hw_video/huc6270/vdc.h deleted file mode 100644 index 05d27e8167..0000000000 --- a/libmednahawk/src/hw_video/huc6270/vdc.h +++ /dev/null @@ -1,448 +0,0 @@ -#ifndef __PCE_VDC_H -#define __PCE_VDC_H - -#include "mednafen/lepacker.h" - -#define VDC_PIXEL_OUT_MASK 0x01FF - -// This bit will be set for a non-sprite pixel if the BG layer is disabled(via ToggleLayer()), -#define VDC_BGDISABLE_OUT_MASK 0x0200 - -// HSync and VSync out bits are only valid when the EX bits in VDC's CR -// are set so that the VDC will output sync signals rather than -// input them. If it is not configured in this manner, the bit(s) shall always be 0. -#define VDC_HSYNC_OUT_MASK 0x2000 -#define VDC_VSYNC_OUT_MASK 0x4000 - -// The DISP bit can either denote active display area(1 = active, 0 = inactive), -// colorburst insertion period(0 = insert colorburst, 1 = not in colorburst period; may not be emulated correctly), -// or "internal horizontal synchronous signal"(may not be emulated correctly), depending on the TE -// bits in the VDC's CR. -#define VDC_DISP_OUT_MASK 0x8000 - -#define VDC_REGSETP(_reg, _data, _msb) { _reg &= 0xFF << ((_msb) ? 0 : 8); _reg |= (_data) << ((_msb) ? 8 : 0); } -#define VDC_REGGETP(_reg, _msb) ((_reg >> ((_msb) ? 8 : 0)) & 0xFF) - -static const unsigned int vram_inc_tab[4] = { 1, 32, 64, 128 }; - -#define VDC_IS_BSY (pending_read || pending_write) - -typedef struct -{ - uint32 x; - uint32 flags; - uint8 palette_index; - uint16 pattern_data[4]; -} SPRLE; - -typedef struct -{ - // In the case the VDC access doesn't cause a VRAM read/write, only ReadCount/WriteCount will be set to 0. - uint32 ReadStart; - uint32 ReadCount; - uint32 WriteStart; - uint32 WriteCount; -} VDC_SimulateResult; - -class VDC -{ - public: - - // The VRAM size is specified in 16-bit words. - VDC(bool nospritelimit, uint32 par_VRAM_Size); - ~VDC(); - -#if 0 - void *operator new(size_t bcount) - { - void *ret = calloc(1, bcount); - return(ret); - } - - void operator delete(void *ptr) - { - free(ptr); - } -#endif - - int32 Reset(void) MDFN_WARN_UNUSED_RESULT; - - // ResetSimulate(), SimulateWrite(), and SimulateRead() are intended to handle VRAM read/write breakpoints. - // SimulateWrite() and SimulateRead() will return the VRAM address that will EVENTUALLY be written(upper 32-bits) and/or read(lower 32-bits) to - // due to the access, or 0xFFFFFFFF in the upper or lower 32-bits if no VRAM access of that type occurs. - // - // The feature is intended to support block moves to VRAM in a single instruction. It may not function properly if the address passed to SimulateRead() - // or SimulateWrite() alternates(even if just once) between the data port high byte and control port between calls to ResetSimulate() - // Call to reset simulation state. - - - INLINE void ResetSimulate(void) - { - Simulate_MAWR = MAWR; - Simulate_MARR = MARR; - - Simulate_select = select; - Simulate_CR = CR; - - Simulate_LENR = LENR; - } - - INLINE void SimulateRead(uint32 A, VDC_SimulateResult *result) - { - result->ReadCount = 0; - result->WriteCount = 0; - result->ReadStart = 0; - result->WriteStart = 0; - - if((A & 0x3) == 0x3 && Simulate_select == 0x02) - { - Simulate_MARR += vram_inc_tab[(Simulate_CR >> 11) & 0x3]; - - result->ReadStart = Simulate_MARR; - result->ReadCount = 1; - } - } - - INLINE void SimulateWrite(uint32 A, uint8 V, VDC_SimulateResult *result) - { - result->ReadCount = 0; - result->WriteCount = 0; - result->ReadStart = 0; - result->WriteStart = 0; - - const unsigned int msb = A & 1; - - switch(A & 0x3) - { - case 0x00: Simulate_select = V & 0x1F; - break; - - case 0x02: - case 0x03: - - switch(Simulate_select) - { - case 0x00: VDC_REGSETP(Simulate_MAWR, V, msb); - break; - - case 0x01: VDC_REGSETP(Simulate_MARR, V, msb); - Simulate_MARR += vram_inc_tab[(Simulate_CR >> 11) & 0x3]; - - result->ReadStart = Simulate_MARR; - result->ReadCount = 1; - break; - - case 0x02: if(msb) - { - result->WriteStart = Simulate_MAWR; - result->WriteCount = 1; - - Simulate_MAWR += vram_inc_tab[(Simulate_CR >> 11) & 0x3]; - } - break; - - case 0x12: VDC_REGSETP(Simulate_LENR, V, msb); - if(msb) - { - result->ReadStart = SOUR; - result->ReadCount = Simulate_LENR + 1; - - if(DCR & 0x4) - result->ReadStart = (result->ReadStart - (result->ReadCount - 1)) & 0xFFFF; - - result->WriteStart = DESR; - result->WriteCount = Simulate_LENR + 1; - - if(DCR & 0x8) - result->WriteStart = (result->WriteStart - (result->WriteCount - 1)) & 0xFFFF; - } - break; - - } - break; - } - } - - - int32 HSync(bool); - int32 VSync(bool); - - - void Write(uint32 A, uint8 V, int32 &next_event); - uint8 Read(uint32 A, int32 &next_event, bool peek = FALSE); - - void Write16(bool A, uint16 V); - uint16 Read16(bool A, bool peek = FALSE); - - int32 Run(int32 clocks, /*bool hs, bool vs,*/ uint16 *pixels, bool skip); - - - void FixTileCache(uint16); - void SetLayerEnableMask(uint64 mask); - - void RunDMA(int32, bool force_completion = FALSE); - void RunSATDMA(int32, bool force_completion = FALSE); - - void IncRCR(void); - void DoVBIRQTest(void); - void HDS_Start(void); - - void StateExtra(MDFN::LEPacker &sl_packer, bool load); - int StateAction(StateMem *sm, int load, int data_only, const char *sname); - - // Peek(VRAM/SAT) and Poke(VRAM/SAT) work in 16-bit VRAM word units. - INLINE uint16 PeekVRAM(uint16 Address) - { - if(Address < VRAM_Size) - return(VRAM[Address]); - else - return(0); - } - - INLINE uint16 PeekSAT(uint8 Address) - { - return(SAT[Address]); - } - - INLINE void PokeVRAM(uint16 Address, const uint16 Data) - { - if(Address < VRAM_Size) - { - VRAM[Address] = Data; - FixTileCache(Address); - } - } - - INLINE void PokeSAT(uint8 Address, const uint16 Data) - { - SAT[Address] = Data; - } - - - // Register enums for GetRegister() and SetRegister() - enum - { - GSREG_MAWR = 0, - GSREG_MARR, - GSREG_CR, - GSREG_RCR, - GSREG_BXR, - GSREG_BYR, - GSREG_MWR, - GSREG_HSR, - GSREG_HDR, - GSREG_VSR, - GSREG_VDR, - GSREG_VCR, - GSREG_DCR, - GSREG_SOUR, - GSREG_DESR, - GSREG_LENR, - GSREG_DVSSR, - - GSREG_SELECT, - GSREG_STATUS, - - __GSREG_COUNT - }; - - // Pass NULL if you don't want more information about the special meaning of the value in the specified - // register. Otherwise, pass a buffer of at least 256 bytes in size. - uint32 GetRegister(const unsigned int id, char *special, const uint32 special_len); - void SetRegister(const unsigned int id, const uint32 value); - - #ifdef WANT_DEBUGGER - bool DoGfxDecode(uint32 *target, const uint32 *color_table, const uint32 TransparentColor, bool DecodeSprites, - int32 w, int32 h, int32 scroll); - #endif - - INLINE bool PeekIRQ(void) - { - return((bool)(status & 0x3F)); - } - - INLINE void SetIRQHook(void (*irqh)(bool)) - { - IRQHook = irqh; - } - - INLINE void SetWSHook(bool (*wsh)(int32)) - { - WSHook = wsh; - } - - private: - - int TimeFromHDSStartToBYRLatch(void); - int TimeFromBYRLatchToBXRLatch(void); - - enum - { - HPHASE_HDS = 0, - HPHASE_HDS_PART2, - HPHASE_HDS_PART3, - HPHASE_HDW, - HPHASE_HDW_FINAL, - HPHASE_HDE, - HPHASE_HSW, - HPHASE_COUNT - }; - - enum - { - VPHASE_VDS = 0, - VPHASE_VDW, - VPHASE_VCR, - VPHASE_VSW, - VPHASE_COUNT - }; - - int VRAM_Size; // = 0x8000; - int VRAM_SizeMask; // = VRAM_Size - 1; //0x7FFF; - int VRAM_BGTileNoMask; // = VRAM_SizeMask / 16; //0x7FF; - - void (*IRQHook)(bool); - bool (*WSHook)(int32); - - void DoWaitStates(void); - void CheckAndCommitPending(void); - - INLINE int32 CalcNextEvent(void) - { - int32 next_event = HPhaseCounter; - - if(sat_dma_counter > 0 && sat_dma_counter < next_event) - next_event = sat_dma_counter; - - if(sprite_cg_fetch_counter > 0 && sprite_cg_fetch_counter < next_event) - next_event = sprite_cg_fetch_counter; - - if(DMARunning) - { - assert(VDMA_CycleCounter < 2); - - int32 next_vram_dma_event = ((LENR + 1) * 4) - (DMAReadWrite * 2) - VDMA_CycleCounter; - - assert(next_vram_dma_event > 0); - - if(next_vram_dma_event > 0 && next_vram_dma_event < next_event) - next_event = next_vram_dma_event; - - //printf("Next VRAM DMA event: %d(LENR = %d)\n", next_vram_dma_event, LENR); - } - - assert(next_event > 0); - return(next_event); - } - - bool in_exhsync, in_exvsync; - - void CalcWidthStartEnd(uint32 &display_width, uint32 &start, uint32 &end); - void DrawBG(uint16 *target, int enabled); - void DrawSprites(uint16 *target, int enabled); - void FetchSpriteData(void); - - - uint8 Simulate_select; - uint16 Simulate_MAWR; - uint16 Simulate_MARR; - uint16 Simulate_CR; - uint16 Simulate_LENR; - - int32 sat_dma_counter; - - uint8 select; - uint16 MAWR; // Memory Address Write Register - uint16 MARR; // Memory Address Read Register - - uint16 CR; // Control Register - uint16 CR_cache; // Cache for BG/SPR enable - uint16 RCR; // Raster Compare Register - uint16 BXR; // Background X-Scroll Register - uint16 BYR; // Background Y-Scroll Register - uint16 MWR; // Memory Width Register - - uint16 HSR; // Horizontal Sync Register - uint16 HDR; // Horizontal Display Register - uint16 VSR; - uint16 VDR; - - uint16 VCR; - uint16 DCR; - uint16 SOUR; - uint16 DESR; - uint16 LENR; - uint16 DVSSR; - - // Internal SAT DMA transfer variables. - //uint16 SAT_SOUR; - //uint16 SAT_DESR; - //uint16 SAT_LENR; - - int32 VDMA_CycleCounter; - - uint32 RCRCount; - - bool pending_read; - uint16 pending_read_addr; - uint16 read_buffer; - - uint8 write_latch; // LSB - - bool pending_write; - uint16 pending_write_addr; - uint16 pending_write_latch; - - uint8 status; - - uint16 SAT[0x100]; - - uint16 VRAM[65536]; //VRAM_Size]; - - union - { - uint64 bg_tile_cache64[65536 / 16][8]; // Tile, y, x - uint8 bg_tile_cache[65536 / 16][8][8]; - }; - - uint16 DMAReadBuffer; - bool DMAReadWrite; - bool DMARunning; - bool DMAPending; - bool SATBPending; - bool burst_mode; - - uint32 BG_YOffset; // Reloaded from BYR at start of display area? - uint32 BG_XOffset; // Reloaded from BXR at each scanline, methinks. - - uint32 HSW_cache, HDS_cache, HDW_cache, HDE_cache; - - uint32 VDS_cache; - uint32 VSW_cache; - uint32 VDW_cache; - uint32 VCR_cache; - uint16 MWR_cache; - - - uint32 BG_YMoo; - bool NeedRCRInc, NeedVBIRQTest, NeedSATDMATest, NeedBGYInc; - int HPhase, VPhase; - int32 HPhaseCounter, VPhaseCounter; - - int32 sprite_cg_fetch_counter; - - - int32 mystery_counter; - bool mystery_phase; - - uint16 linebuf[1024 + 512]; - uint32 pixel_desu; - int32 pixel_copy_count; - uint32 userle; // User layer enable. - bool unlimited_sprites; - - int active_sprites; - SPRLE SpriteList[64 * 2]; // (see unlimited_sprites option, *2 to accommodate 32-pixel-width sprites ) //16]; -}; - -#endif diff --git a/libmednahawk/src/md/Makefile.am b/libmednahawk/src/md/Makefile.am deleted file mode 100644 index db2a2543cf..0000000000 --- a/libmednahawk/src/md/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -AUTOMAKE_OPTIONS = subdir-objects -DEFS = -DLOCALEDIR=\"$(datadir)/locale\" @DEFS@ @MATH_OPTIMIZER_FLAGS@ -DEFAULT_INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/intl -I$(top_srcdir)/src/hw_cpu -I$(top_srcdir)/src/hw_sound - - -noinst_LIBRARIES = libmd.a - -libmd_a_SOURCES = vdp.cpp genesis.cpp genio.cpp header.cpp mem68k.cpp membnk.cpp memvdp.cpp memz80.cpp sound.cpp system.cpp - -libmd_a_SOURCES += cart/cart.cpp cart/map_eeprom.cpp cart/map_realtec.cpp cart/map_ssf2.cpp cart/map_ff.cpp cart/map_rom.cpp cart/map_sbb.cpp cart/map_yase.cpp cart/map_rmx3.cpp cart/map_sram.cpp cart/map_svp.cpp -# cart/ssp16.c - -libmd_a_SOURCES += input/mouse.cpp input/gamepad.cpp - -libmd_a_SOURCES += cd/cd.cpp cd/timer.cpp cd/interrupt.cpp cd/pcm.cpp cd/cdc_cdd.cpp - -if WANT_DEBUGGER -libmd_a_SOURCES += debug.cpp -endif diff --git a/libmednahawk/src/md/Makefile.in b/libmednahawk/src/md/Makefile.in deleted file mode 100644 index 9d8dde3efd..0000000000 --- a/libmednahawk/src/md/Makefile.in +++ /dev/null @@ -1,728 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -target_triplet = @target@ -@WANT_DEBUGGER_TRUE@am__append_1 = debug.cpp -subdir = src/md -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ - $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/fcntl-o.m4 \ - $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc2.m4 \ - $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intl.m4 \ - $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax.m4 \ - $(top_srcdir)/m4/inttypes-pri.m4 \ - $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ - $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ - $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/stdint_h.m4 \ - $(top_srcdir)/m4/threadlib.m4 $(top_srcdir)/m4/uintmax_t.m4 \ - $(top_srcdir)/m4/visibility.m4 $(top_srcdir)/m4/wchar_t.m4 \ - $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ - $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = $(top_builddir)/include/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -LIBRARIES = $(noinst_LIBRARIES) -ARFLAGS = cru -AM_V_AR = $(am__v_AR_$(V)) -am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY)) -am__v_AR_0 = @echo " AR " $@; -AM_V_at = $(am__v_at_$(V)) -am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) -am__v_at_0 = @ -libmd_a_AR = $(AR) $(ARFLAGS) -libmd_a_LIBADD = -am__libmd_a_SOURCES_DIST = vdp.cpp genesis.cpp genio.cpp header.cpp \ - mem68k.cpp membnk.cpp memvdp.cpp memz80.cpp sound.cpp \ - system.cpp cart/cart.cpp cart/map_eeprom.cpp \ - cart/map_realtec.cpp cart/map_ssf2.cpp cart/map_ff.cpp \ - cart/map_rom.cpp cart/map_sbb.cpp cart/map_yase.cpp \ - cart/map_rmx3.cpp cart/map_sram.cpp cart/map_svp.cpp \ - input/mouse.cpp input/gamepad.cpp cd/cd.cpp cd/timer.cpp \ - cd/interrupt.cpp cd/pcm.cpp cd/cdc_cdd.cpp debug.cpp -am__dirstamp = $(am__leading_dot)dirstamp -@WANT_DEBUGGER_TRUE@am__objects_1 = debug.$(OBJEXT) -am_libmd_a_OBJECTS = vdp.$(OBJEXT) genesis.$(OBJEXT) genio.$(OBJEXT) \ - header.$(OBJEXT) mem68k.$(OBJEXT) membnk.$(OBJEXT) \ - memvdp.$(OBJEXT) memz80.$(OBJEXT) sound.$(OBJEXT) \ - system.$(OBJEXT) cart/cart.$(OBJEXT) cart/map_eeprom.$(OBJEXT) \ - cart/map_realtec.$(OBJEXT) cart/map_ssf2.$(OBJEXT) \ - cart/map_ff.$(OBJEXT) cart/map_rom.$(OBJEXT) \ - cart/map_sbb.$(OBJEXT) cart/map_yase.$(OBJEXT) \ - cart/map_rmx3.$(OBJEXT) cart/map_sram.$(OBJEXT) \ - cart/map_svp.$(OBJEXT) input/mouse.$(OBJEXT) \ - input/gamepad.$(OBJEXT) cd/cd.$(OBJEXT) cd/timer.$(OBJEXT) \ - cd/interrupt.$(OBJEXT) cd/pcm.$(OBJEXT) cd/cdc_cdd.$(OBJEXT) \ - $(am__objects_1) -libmd_a_OBJECTS = $(am_libmd_a_OBJECTS) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -AM_V_lt = $(am__v_lt_$(V)) -am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) -am__v_lt_0 = --silent -LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CXXFLAGS) $(CXXFLAGS) -AM_V_CXX = $(am__v_CXX_$(V)) -am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) -am__v_CXX_0 = @echo " CXX " $@; -CXXLD = $(CXX) -CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ - $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CXXLD = $(am__v_CXXLD_$(V)) -am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) -am__v_CXXLD_0 = @echo " CXXLD " $@; -AM_V_GEN = $(am__v_GEN_$(V)) -am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(libmd_a_SOURCES) -DIST_SOURCES = $(am__libmd_a_SOURCES_DIST) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ALLOCA = @ALLOCA@ -ALSA_CFLAGS = @ALSA_CFLAGS@ -ALSA_LIBS = @ALSA_LIBS@ -AMTAR = @AMTAR@ -AM_CFLAGS = @AM_CFLAGS@ -AM_CXXFLAGS = @AM_CXXFLAGS@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ -CATOBJEXT = @CATOBJEXT@ -CC = @CC@ -CCAS = @CCAS@ -CCASDEPMODE = @CCASDEPMODE@ -CCASFLAGS = @CCASFLAGS@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DATADIRNAME = @DATADIRNAME@ -DEFS = -DLOCALEDIR=\"$(datadir)/locale\" @DEFS@ @MATH_OPTIMIZER_FLAGS@ -DEPDIR = @DEPDIR@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GBA_EXTRA_FLAGS = @GBA_EXTRA_FLAGS@ -GENCAT = @GENCAT@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GLIBC2 = @GLIBC2@ -GLIBC21 = @GLIBC21@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GREP = @GREP@ -HAVE_ASPRINTF = @HAVE_ASPRINTF@ -HAVE_NEWLOCALE = @HAVE_NEWLOCALE@ -HAVE_POSIX_PRINTF = @HAVE_POSIX_PRINTF@ -HAVE_SNPRINTF = @HAVE_SNPRINTF@ -HAVE_VISIBILITY = @HAVE_VISIBILITY@ -HAVE_WPRINTF = @HAVE_WPRINTF@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INSTOBJEXT = @INSTOBJEXT@ -INTLBISON = @INTLBISON@ -INTLLIBS = @INTLLIBS@ -INTLOBJS = @INTLOBJS@ -INTL_DEFAULT_VERBOSITY = @INTL_DEFAULT_VERBOSITY@ -INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -JACK_CFLAGS = @JACK_CFLAGS@ -JACK_LIBS = @JACK_LIBS@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBCDIO_CFLAGS = @LIBCDIO_CFLAGS@ -LIBCDIO_LIBS = @LIBCDIO_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBMULTITHREAD = @LIBMULTITHREAD@ -LIBOBJS = @LIBOBJS@ -LIBPTH = @LIBPTH@ -LIBPTH_PREFIX = @LIBPTH_PREFIX@ -LIBS = @LIBS@ -LIBTHREAD = @LIBTHREAD@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBC = @LTLIBC@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ -LTLIBOBJS = @LTLIBOBJS@ -LTLIBPTH = @LTLIBPTH@ -LTLIBTHREAD = @LTLIBTHREAD@ -MAKEINFO = @MAKEINFO@ -MATH_OPTIMIZER_FLAGS = @MATH_OPTIMIZER_FLAGS@ -MKDIR_P = @MKDIR_P@ -MMX_CFLAGS = @MMX_CFLAGS@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POSUB = @POSUB@ -PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ -RANLIB = @RANLIB@ -SDL_CFLAGS = @SDL_CFLAGS@ -SDL_CONFIG = @SDL_CONFIG@ -SDL_LIBS = @SDL_LIBS@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -SNDFILE_CFLAGS = @SNDFILE_CFLAGS@ -SNDFILE_LIBS = @SNDFILE_LIBS@ -SNES_EXTRA_CXXFLAGS = @SNES_EXTRA_CXXFLAGS@ -SNES_EXTRA_FLAGS = @SNES_EXTRA_FLAGS@ -SSE2_CFLAGS = @SSE2_CFLAGS@ -SSE3_CFLAGS = @SSE3_CFLAGS@ -SSE_CFLAGS = @SSE_CFLAGS@ -STRIP = @STRIP@ -TRIO_CFLAGS = @TRIO_CFLAGS@ -USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ -USE_NLS = @USE_NLS@ -VERSION = @VERSION@ -WARNING_FLAGS = @WARNING_FLAGS@ -WINDRES = @WINDRES@ -WOE32 = @WOE32@ -WOE32DLL = @WOE32DLL@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -XMKMF = @XMKMF@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target = @target@ -target_alias = @target_alias@ -target_cpu = @target_cpu@ -target_os = @target_os@ -target_vendor = @target_vendor@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AUTOMAKE_OPTIONS = subdir-objects -DEFAULT_INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/intl -I$(top_srcdir)/src/hw_cpu -I$(top_srcdir)/src/hw_sound -noinst_LIBRARIES = libmd.a -# cart/ssp16.c -libmd_a_SOURCES = vdp.cpp genesis.cpp genio.cpp header.cpp mem68k.cpp \ - membnk.cpp memvdp.cpp memz80.cpp sound.cpp system.cpp \ - cart/cart.cpp cart/map_eeprom.cpp cart/map_realtec.cpp \ - cart/map_ssf2.cpp cart/map_ff.cpp cart/map_rom.cpp \ - cart/map_sbb.cpp cart/map_yase.cpp cart/map_rmx3.cpp \ - cart/map_sram.cpp cart/map_svp.cpp input/mouse.cpp \ - input/gamepad.cpp cd/cd.cpp cd/timer.cpp cd/interrupt.cpp \ - cd/pcm.cpp cd/cdc_cdd.cpp $(am__append_1) -all: all-am - -.SUFFIXES: -.SUFFIXES: .cpp .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/md/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/md/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) -cart/$(am__dirstamp): - @$(MKDIR_P) cart - @: > cart/$(am__dirstamp) -cart/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) cart/$(DEPDIR) - @: > cart/$(DEPDIR)/$(am__dirstamp) -cart/cart.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -cart/map_eeprom.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -cart/map_realtec.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -cart/map_ssf2.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -cart/map_ff.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -cart/map_rom.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -cart/map_sbb.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -cart/map_yase.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -cart/map_rmx3.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -cart/map_sram.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -cart/map_svp.$(OBJEXT): cart/$(am__dirstamp) \ - cart/$(DEPDIR)/$(am__dirstamp) -input/$(am__dirstamp): - @$(MKDIR_P) input - @: > input/$(am__dirstamp) -input/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) input/$(DEPDIR) - @: > input/$(DEPDIR)/$(am__dirstamp) -input/mouse.$(OBJEXT): input/$(am__dirstamp) \ - input/$(DEPDIR)/$(am__dirstamp) -input/gamepad.$(OBJEXT): input/$(am__dirstamp) \ - input/$(DEPDIR)/$(am__dirstamp) -cd/$(am__dirstamp): - @$(MKDIR_P) cd - @: > cd/$(am__dirstamp) -cd/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) cd/$(DEPDIR) - @: > cd/$(DEPDIR)/$(am__dirstamp) -cd/cd.$(OBJEXT): cd/$(am__dirstamp) cd/$(DEPDIR)/$(am__dirstamp) -cd/timer.$(OBJEXT): cd/$(am__dirstamp) cd/$(DEPDIR)/$(am__dirstamp) -cd/interrupt.$(OBJEXT): cd/$(am__dirstamp) \ - cd/$(DEPDIR)/$(am__dirstamp) -cd/pcm.$(OBJEXT): cd/$(am__dirstamp) cd/$(DEPDIR)/$(am__dirstamp) -cd/cdc_cdd.$(OBJEXT): cd/$(am__dirstamp) cd/$(DEPDIR)/$(am__dirstamp) -libmd.a: $(libmd_a_OBJECTS) $(libmd_a_DEPENDENCIES) - $(AM_V_at)-rm -f libmd.a - $(AM_V_AR)$(libmd_a_AR) libmd.a $(libmd_a_OBJECTS) $(libmd_a_LIBADD) - $(AM_V_at)$(RANLIB) libmd.a - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -rm -f cart/cart.$(OBJEXT) - -rm -f cart/map_eeprom.$(OBJEXT) - -rm -f cart/map_ff.$(OBJEXT) - -rm -f cart/map_realtec.$(OBJEXT) - -rm -f cart/map_rmx3.$(OBJEXT) - -rm -f cart/map_rom.$(OBJEXT) - -rm -f cart/map_sbb.$(OBJEXT) - -rm -f cart/map_sram.$(OBJEXT) - -rm -f cart/map_ssf2.$(OBJEXT) - -rm -f cart/map_svp.$(OBJEXT) - -rm -f cart/map_yase.$(OBJEXT) - -rm -f cd/cd.$(OBJEXT) - -rm -f cd/cdc_cdd.$(OBJEXT) - -rm -f cd/interrupt.$(OBJEXT) - -rm -f cd/pcm.$(OBJEXT) - -rm -f cd/timer.$(OBJEXT) - -rm -f input/gamepad.$(OBJEXT) - -rm -f input/mouse.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genesis.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genio.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/header.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem68k.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/membnk.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memvdp.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memz80.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sound.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/system.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vdp.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/cart.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/map_eeprom.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/map_ff.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/map_realtec.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/map_rmx3.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/map_rom.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/map_sbb.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/map_sram.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/map_ssf2.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/map_svp.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cart/$(DEPDIR)/map_yase.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cd/$(DEPDIR)/cd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cd/$(DEPDIR)/cdc_cdd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cd/$(DEPDIR)/interrupt.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cd/$(DEPDIR)/pcm.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@cd/$(DEPDIR)/timer.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@input/$(DEPDIR)/gamepad.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@input/$(DEPDIR)/mouse.Po@am__quote@ - -.cpp.o: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.cpp.lo: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ -@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo -@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LIBRARIES) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -rm -f cart/$(DEPDIR)/$(am__dirstamp) - -rm -f cart/$(am__dirstamp) - -rm -f cd/$(DEPDIR)/$(am__dirstamp) - -rm -f cd/$(am__dirstamp) - -rm -f input/$(DEPDIR)/$(am__dirstamp) - -rm -f input/$(am__dirstamp) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) cart/$(DEPDIR) cd/$(DEPDIR) input/$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) cart/$(DEPDIR) cd/$(DEPDIR) input/$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLIBRARIES ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/libmednahawk/src/md/cart/cart.cpp b/libmednahawk/src/md/cart/cart.cpp deleted file mode 100644 index a1c79ce4c2..0000000000 --- a/libmednahawk/src/md/cart/cart.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cart.h" - -#include "map_rom.h" -#include "map_sram.h" -#include "map_eeprom.h" -#include "map_svp.h" - -#include "map_realtec.h" -#include "map_ssf2.h" - -#include "map_ff.h" -#include "map_rmx3.h" -#include "map_sbb.h" -#include "map_yase.h" - -#include "../header.h" -#include "../../md5.h" -#include "../../general.h" -#include - -static MD_Cart_Type *cart_hardware = NULL; -static uint32 Cart_ROM_Size; - -void MDCart_Write8(uint32 A, uint8 V) -{ - cart_hardware->Write8(A, V); -} - -void MDCart_Write16(uint32 A, uint16 V) -{ - cart_hardware->Write16(A, V); -} - -uint8 MDCart_Read8(uint32 A) -{ - return(cart_hardware->Read8(A)); -} - -uint16 MDCart_Read16(uint32 A) -{ - return(cart_hardware->Read16(A)); -} - -void MDCart_Reset(void) -{ - cart_hardware->Reset(); -} - -// MD_Cart_Type* (*MapperMake)(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size); -// MD_Make_Cart_Type_REALTEC -// MD_Make_Cart_Type_SSF2 -// Final Fantasy -// MD_Make_Cart_Type_FF -// MD_Make_Cart_Type_RMX3 -// MD_Make_Cart_Type_SBB -// MD_Make_Cart_Type_YaSe - -typedef struct -{ - // Set any field to 0(or -1 for signed fields) to ignore it - const char *id; - - const uint64 md5; - const uint64 header_md5; - - const char *mapper; - - // Overrides for bad headers - const uint32 sram_type; - const int32 sram_start; - const int32 sram_end; - - const uint32 region_support; -} game_db_t; - -static game_db_t GamesDB[] = -{ - // Balloon Boy - { NULL, 0, 0xa9509f505d00db6eULL, "REALTEC", 0, 0, 0, 0 }, - - // Earth Defend - { NULL, 0, 0xcf6afbf45299a800ULL, "REALTEC", 0, 0, 0, 0 }, - - // Whac a Critter - { NULL, 0, 0x5499d14fcef32f60ULL, "REALTEC", 0, 0, 0, 0 }, - - // Super Street Fighter II - { "T-12056 -00", 0, 0, "SSF2", 0, 0, 0, 0 }, - { "T-12043 -00", 0, 0, "SSF2", 0, 0, 0, 0 }, - -// "Conquering the world III 0x3fff" -// "Xin Qi Gai Wing Zi", " -// 0xFFFF, 0x400000, 0x40ffff -// "Rings of Power", 0x200000 0x203fff - - // Final Fantasy - { NULL, 0, 0x7c0e11c426d65105ULL, "FF", 0, 0, 0, 0 }, - { NULL, 0, 0xe144baf931c8b61eULL, "FF", 0, 0, 0, 0 }, - - // Rockman X3 - { NULL, 0, 0x1d1add6f2a64fb99ULL, "RMX3", 0, 0, 0, 0 }, - - // Super Bubble Bobble - { NULL, 0, 0x8eff5373b653111eULL, "SBB", 0, 0, 0, 0 }, - - // Ya-Se Chuan Shuo - { NULL, 0, 0x2786df4902ef8856ULL, "YaSe", 0, 0, 0, 0 }, - - // Virtua Racing - { "MK-1229 -00", 0, 0, "SVP", 0, 0, 0, 0 }, - - - /*************************************** - // - // SRAM-related header corrections - // - ***************************************/ - - // Chaoji Dafuweng - { NULL, 0, 0x13639e87230c85aaULL, NULL, 0x5241f820, 0x200001, 0x200fff, 0 }, - - // Psy-O-Blade - { "T-26013 -00", 0, 0, NULL, 0x5241f820, 0x200000, 0x203fff, 0 }, - - // Sonic and Knuckles and Sonic 3 - { NULL, 0xde0ac4e17a844d10ULL, 0, NULL, 0x5241f820, 0x200000, 0x2003ff, 0 }, - - // Starflight - { "T-50216 -00", 0, 0, NULL, 0x5241f820, 0x200000, 0x203fff, 0 }, - { "T-50216 -01", 0, 0, NULL, 0x5241f820, 0x200000, 0x203fff, 0 }, - - // Taiwan Tycoon(TODO) - - // Top Shooter - { NULL, 0, 0x31fea3093b231863ULL, NULL, 0x5241f820, 0x200001, 0x203fff, 0 }, - - // World Pro Baseball 94 - { NULL, 0, 0xe7bb31787f189ebeULL, NULL, 0x5241f820, 0x200001, 0x20ffff, 0 }, - - - /*************************************** - // - // EEPROM Carts - // - ***************************************/ - - // - // Acclaim - // - // NBA Jam (UE) - {"T-081326 00", 0, 0, "Acclaim_24C02_Old", 0, 0, 0, 0 }, - - // NBA Jam (J) - {"T-81033 00", 0, 0, "Acclaim_24C02_Old", 0, 0, 0, 0 }, - - // NFL Quarterback Club - {"T-081276 00", 0, 0, "Acclaim_24C02", 0, 0, 0, 0 }, - - // NBA Jam TE - {"T-81406 -00", 0, 0, "Acclaim_24C04", 0, 0, 0, 0 }, - - // NFL Quarterback Club '96 - {"T-081586-00", 0, 0, "Acclaim_24C16", 0, 0, 0, 0 }, - - // College Slam - {"T-81576 -00", 0, 0, "Acclaim_24C65", 0, 0, 0, 0 }, - - // Frank Thomas Big Hurt Baseball - {"T-81476 -00", 0, 0, "Acclaim_24C65", 0, 0, 0, 0 }, - - // - // EA - // - // Rings of Power - {"T-50176 -00", 0, 0, "EA_24C01", 0, 0, 0, 0 }, - - // NHLPA Hockey 93 (UE) - {"T-50396 -00", 0, 0, "EA_24C01", 0, 0, 0, 0 }, - - // John Madden Football 93 - {"T-50446 -00", 0, 0, "EA_24C01", 0, 0, 0, 0 }, - - // John Madden Football 93 (Championship Edition) - {"T-50516 -00", 0, 0, "EA_24C01", 0, 0, 0, 0 }, - - // Bill Walsh College Football - {"T-50606 -00", 0, 0, "EA_24C01", 0, 0, 0, 0 }, - - - - // - // Sega - // - // Megaman - The Wily Wars - {"T-12046 -00", 0, 0, "Sega_24C01", 0, 0, 0, 0 }, - - // Rockman Mega World (J) - {"T-12053 -00", 0, 0x969a9e19a5850e7cULL, "Sega_24C01", 0, 0, 0, 0 }, // Hash necessary due to hacked RAM-using version floating around. - - // Evander 'Real Deal' Holyfield's Boxing - {"MK-1215 -00", 0, 0, "Sega_24C01", 0, 0, 0, 0 }, - - // Greatest Heavyweights of the Ring (U) - {"MK-1228 -00", 0, 0, "Sega_24C01", 0, 0, 0, 0 }, - - // Greatest Heavyweights of the Ring (J) - {"G-5538 -00", 0, 0, "Sega_24C01", 0, 0, 0, 0 }, - - // Greatest Heavyweights of the Ring (E) - {"PR-1993 -00", 0, 0, "Sega_24C01", 0, 0, 0, 0 }, // Confirm correct product code. - - // Wonderboy in Monster World - {"G-4060 -00", 0, 0, "Sega_24C01", 0, 0, 0, 0 }, - - // Sports Talk Baseball - {"00001211-00", 0, 0, "Sega_24C01", 0, 0, 0, 0 }, - - // Honoo no Toukyuuji Dodge Danpei - {"_00004076-00", 0, 0, "Sega_24C01", 0, 0, 0, 0 }, - - // Ninja Burai Densetsu - {"G-4524 -00", 0, 0, "Sega_24C01", 0, 0, 0, 0 }, - - // Game Toshokan - {"00054503-00", 0, 0, "Sega_24C01", 0, 0, 0, 0 }, - - - // - // Codemasters - // - // Brian Lara Cricket - {"T-120106-00", 0, 0, "Codemasters_24C08", 0, 0, 0, 0 }, - {"T-120106-50", 0, 0, "Codemasters_24C08", 0, 0, 0, 0 }, - - // Micro Machines Military - { NULL, 0, 0x34253755ee0eed41ULL, "Codemasters_24C08", 0, 0, 0, 0 }, - - // Micro Machines Military (bad) - { NULL, 0, 0x3241b7da6ce42fecULL, "Codemasters_24C08", 0, 0, 0, 0 }, - - // Micro Machines 2 - Turbo Tournament (E) - {"T-120096-50", 0, 0, "Codemasters_24C16", 0, 0, 0, 0 }, - - // Micro Machines Turbo Tournament 96 - {NULL, 0, 0xe672e84fed6ce270ULL, "Codemasters_24C16", 0, 0, 0, 0 }, - - // Micro Machines Turbo Tournament 96 (bad) - {NULL, 0, 0x290afe3cd27be26cULL, "Codemasters_24C16", 0, 0, 0, 0 }, - - // Brian Lara Cricket 96, Shane Warne Cricket - {"T-120146-50", 0, 0, "Codemasters_24C65", 0, 0, 0, 0 }, - // - // End EEPROM carts - // - - /* - ** Header region corrections - */ -/* - REGIONMASK_JAPAN_NTSC = 1, - REGIONMASK_JAPAN_PAL = 2, - REGIONMASK_OVERSEAS_NTSC = 4, - REGIONMASK_OVERSEAS_PAL = 8 - - REGIONMASK_JAPAN_NTSC -*/ -}; - -typedef struct -{ - const char *boardname; - MD_Cart_Type *(*MapperMake)(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, - const uint32 iparam, const char *sparam); - const uint32 iparam; - const char *sparam; -} BoardHandler_t; - -static BoardHandler_t BoardHandlers[] = -{ - { "ROM", MD_Make_Cart_Type_ROM, 0, NULL }, - { "SRAM", MD_Make_Cart_Type_SRAM, 0, NULL }, - - { "SVP", MD_Make_Cart_Type_SVP, 0, NULL }, - - { "REALTEC", MD_Make_Cart_Type_REALTEC, 0, NULL }, - { "SSF2", MD_Make_Cart_Type_SSF2, 0, NULL }, - { "FF", MD_Make_Cart_Type_FF, 0, NULL }, - { "RMX3", MD_Make_Cart_Type_RMX3, 0, NULL }, - { "SBB", MD_Make_Cart_Type_SBB, 0, NULL }, - { "YaSe", MD_Make_Cart_Type_YaSe, 0, NULL }, - - { "Acclaim_24C02_Old", MD_Make_Cart_Type_EEPROM, EEP_ACCLAIM_24C02_OLD, NULL }, - { "Acclaim_24C02", MD_Make_Cart_Type_EEPROM, EEP_ACCLAIM_24C02, NULL }, - { "Acclaim_24C04", MD_Make_Cart_Type_EEPROM, EEP_ACCLAIM_24C04, NULL }, - { "Acclaim_24C16", MD_Make_Cart_Type_EEPROM, EEP_ACCLAIM_24C16, NULL }, - { "Acclaim_24C65", MD_Make_Cart_Type_EEPROM, EEP_ACCLAIM_24C65, NULL }, - - { "EA_24C01", MD_Make_Cart_Type_EEPROM, EEP_EA_24C01, NULL }, - - { "Sega_24C01", MD_Make_Cart_Type_EEPROM, EEP_SEGA_24C01, NULL }, - - { "Codemasters_24C08", MD_Make_Cart_Type_EEPROM, EEP_CM_24C08, NULL }, - { "Codemasters_24C16", MD_Make_Cart_Type_EEPROM, EEP_CM_24C16, NULL }, - { "Codemasters_24C65", MD_Make_Cart_Type_EEPROM, EEP_CM_24C65, NULL }, - { NULL, NULL, 0, NULL }, -}; - -bool MDCart_TestMagic(const char *name, MDFNFILE *fp) -{ - if(fp->size < 512) - return(FALSE); - - //if((fp->size & 512) && fp->data[0x01] == 0x03 && fp->data[0x08] == 0xAA && fp->data[0x09] == 0xBB && fp->data[0x0A] == 0x06) - // return(TRUE); - - if(!memcmp(fp->data + 0x100, "SEGA MEGA DRIVE", 15) || !memcmp(fp->data + 0x100, "SEGA GENESIS", 12) || !memcmp(fp->data + 0x100, "SEGA 32X", 8)) - return(TRUE); - - if((!memcmp(fp->data + 0x100, "SEGA", 4) || !memcmp(fp->data + 0x100, " SEGA", 5)) && !strcmp(fp->ext, "bin")) - return(TRUE); - - if(!strcmp(fp->ext, "gen") || !strcmp(fp->ext, "md")) - return(TRUE); - - return(FALSE); -} - -int MDCart_Load(md_game_info *ginfo, const char *name, MDFNFILE *fp) -{ - const char *mapper = NULL; - md5_context md5; - - MD_ReadSegaHeader(fp->data + 0x100, ginfo); - Cart_ROM_Size = fp->size; - - cart_rom = (uint8 *)MDFN_calloc(1, Cart_ROM_Size, _("Cart ROM")); - memcpy(cart_rom, fp->data, fp->size); - - ginfo->rom_size = Cart_ROM_Size = fp->size; - - md5.starts(); - md5.update(fp->data, fp->size); - md5.finish(ginfo->md5); - - md5.starts(); - md5.update(fp->data + 0x100, 0x100); - md5.finish(ginfo->info_header_md5); - - ginfo->checksum_real = 0; - for(uint32 i = 0x200; i < fp->size; i += 2) - { - ginfo->checksum_real += cart_rom[i + 0] << 8; - ginfo->checksum_real += cart_rom[i + 1] << 0; - } - - // Rockman MegaWorld: 5241e840 - // Sonic 3: 5241f820 - - uint32 sram_type = READ_32_MSB(cart_rom, 0x1B0); - uint32 sram_start = READ_32_MSB(cart_rom, 0x1B4); - uint32 sram_end = READ_32_MSB(cart_rom, 0x1B8); - - { - uint64 hmd5_partial = 0; - uint64 md5_partial = 0; - - for(int i = 0; i < 8; i++) - { - hmd5_partial |= (uint64)ginfo->info_header_md5[15 - i] << (8 * i); - md5_partial |= (uint64)ginfo->md5[15 - i] << (8 * i); - } - printf("Real: 0x%016llxULL Header: 0x%016llxULL\n", (unsigned long long)md5_partial, (unsigned long long)hmd5_partial); - - for(unsigned int i = 0; i < sizeof(GamesDB) / sizeof(game_db_t); i++) - { - bool found = true; - - if(GamesDB[i].header_md5 && GamesDB[i].header_md5 != hmd5_partial) - found = false; - - if(GamesDB[i].md5 && GamesDB[i].md5 != md5_partial) - found = false; - - if(GamesDB[i].id && strcmp(GamesDB[i].id, ginfo->product_code)) - found = false; - - if(found) - { - if(GamesDB[i].mapper) - mapper = GamesDB[i].mapper; - - if(GamesDB[i].sram_type != ~0U) - sram_type = GamesDB[i].sram_type; - if(GamesDB[i].sram_start > 0) - sram_start = GamesDB[i].sram_start; - if(GamesDB[i].sram_end > 0) - sram_end = GamesDB[i].sram_end; - - if(GamesDB[i].region_support > 0) - ginfo->region_support = GamesDB[i].region_support; - - break; - } - } - } - - printf("%08x, %08x, %08x\n", sram_type, sram_start, sram_end); - - if(sram_type == 0x5241f820 && sram_start == 0x20202020) - sram_type = 0x20202020; - - ginfo->sram_type = sram_type; - ginfo->sram_start = sram_start; - ginfo->sram_end = sram_end; - - if(!mapper) - { - if(sram_type == 0x5241f820) - mapper = "SRAM"; - else if(sram_type == 0x5241e840) - mapper = "Sega_24C01"; - else - mapper = "ROM"; - } - - { - const BoardHandler_t *bh = BoardHandlers; - bool BoardFound = FALSE; - - printf("Mapper: %s\n", mapper); - while(bh->boardname) - { - if(!strcasecmp(bh->boardname, mapper)) - { - cart_hardware = bh->MapperMake(ginfo, cart_rom, Cart_ROM_Size, bh->iparam, bh->sparam); - BoardFound = TRUE; - break; - } - bh++; - } - if(!BoardFound) - { - MDFN_printf(_("Handler for mapper/board \"%s\" not found!\n"), mapper); - return(0); - } - } - - //MD_Cart_Type* (*MapperMake)(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) = NULL; - //cart_hardware = MapperMake(ginfo, cart_rom, Cart_ROM_Size); - - return(1); -} - -bool MDCart_LoadNV(void) -{ - // Load any saved RAM/EEPROM now! - if(cart_hardware->GetNVMemorySize()) - { - uint32 sizeof_buf = cart_hardware->GetNVMemorySize(); - uint8 *buf = new uint8[sizeof_buf]; - - memset(buf, 0, sizeof(buf)); - gzFile sp; - - if((sp = gzopen(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), "rb"))) - { - if(gzread(sp, buf, sizeof_buf) == sizeof_buf) - { - cart_hardware->WriteNVMemory(buf); - } - gzclose(sp); - } - delete[] buf; - } - return(TRUE); -} - -bool MDCart_Close(void) -{ - if(cart_hardware) - { - if(cart_hardware->GetNVMemorySize()) - { - uint32 sizeof_buf = cart_hardware->GetNVMemorySize(); - uint8* buf = new uint8[sizeof_buf]; - - cart_hardware->ReadNVMemory(buf); - - MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 6, buf, sizeof_buf); - delete[] buf; - } - - delete cart_hardware; - - cart_hardware = NULL; - } - return(TRUE); -} - -int MDCart_StateAction(StateMem *sm, int load, int data_only) -{ - return(cart_hardware->StateAction(sm, load, data_only, "CARTBOARD")); -} - diff --git a/libmednahawk/src/md/cart/cart.h b/libmednahawk/src/md/cart/cart.h deleted file mode 100644 index 03de61ad74..0000000000 --- a/libmednahawk/src/md/cart/cart.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef __MDFN_MD_CART_H -#define __MDFN_MD_CART_H - -#include "../header.h" - -void MDCart_Write8(uint32 address, uint8 value); -void MDCart_Write16(uint32 address, uint16 value); -uint8 MDCart_Read8(uint32 address); -uint16 MDCart_Read16(uint32 address); - -void MDCart_Reset(void); - -int MDCart_Load(md_game_info *ginfo, const char *name, MDFNFILE *fp); -bool MDCart_TestMagic(const char *name, MDFNFILE *fp); -bool MDCart_LoadNV(void); -bool MDCart_Close(void); - -int MDCart_StateAction(StateMem *sm, int load, int data_only); - -class MD_Cart_Type -{ - public: - MD_Cart_Type() - { - - } - MD_Cart_Type(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) - { - - } - virtual ~MD_Cart_Type() - { - - } - - // Hard reset - virtual void Reset(void) - { - - } - - virtual void Write8(uint32 A, uint8 V) - { - } - - virtual void Write16(uint32 A, uint8 V) - { - } - - virtual uint8 Read8(uint32 A) - { - return(0xFF); - } - - virtual uint16 Read16(uint32 A) - { - return(0xFF); - } - - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name) - { - return(1); - } - - // In bytes - virtual uint32 GetNVMemorySize(void) - { - return(0); - } - - virtual void ReadNVMemory(uint8 *buffer) - { - } - - virtual void WriteNVMemory(const uint8 *buffer) - { - } -}; - - -#endif diff --git a/libmednahawk/src/md/cart/map_eeprom.cpp b/libmednahawk/src/md/cart/map_eeprom.cpp deleted file mode 100644 index 3cb866bc48..0000000000 --- a/libmednahawk/src/md/cart/map_eeprom.cpp +++ /dev/null @@ -1,646 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * Copyright (C) 2007, 2008, 2009 EkeEke - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -/* - Genesis Plus GX EEPROM emulation modified 2011 for usage in Mednafen -*/ - -#include "../shared.h" -#include "cart.h" -#include "map_eeprom.h" - -typedef enum -{ - STAND_BY = 0, - WAIT_STOP, - GET_SLAVE_ADR, - GET_WORD_ADR_7BITS, - GET_WORD_ADR_HIGH, - GET_WORD_ADR_LOW, - WRITE_DATA, - READ_DATA, - -} T_EEPROM_STATE; - -/* this defines the type of EEPROM inside the game cartridge as Backup RAM - * - * Here are some notes from 8BitWizard (http://www.spritesmind.net/_GenDev/forum): - * - * Mode 1 (7-bit) - the chip takes a single byte with a 7-bit memory address and a R/W bit (24C01) - * Mode 2 (8-bit) - the chip takes a 7-bit device address and R/W bit followed by an 8-bit memory address; - * the device address may contain up to three more memory address bits (24C01 - 24C16). - * You can also string eight 24C01, four 24C02, two 24C08, or various combinations, set their address config lines correctly, - * and the result appears exactly the same as a 24C16 - * Mode 3 (16-bit) - the chip takes a 7-bit device address and R/W bit followed by a 16-bit memory address (24C32 and larger) - * - * Also, while most 24Cxx are addressed at 200000-2FFFFF, I have found two different ways of mapping the control lines. - * EA uses SDA on D7 (read/write) and SCL on D6 (write only), and I have found boards using different mapping (I think Accolade) - * which uses D1-read=SDA, D0-write=SDA, D1-write=SCL. Accolade also has a custom-chip mapper which may even use a third method. - */ - -typedef struct -{ - uint8 address_bits; /* number of bits needed to address memory: 7, 8 or 16 */ - uint16 size_mask; /* depends on the max size of the memory (in bytes) */ - uint16 pagewrite_mask; /* depends on the maximal number of bytes that can be written in a single write cycle */ - uint32 sda_in_adr; /* 68000 memory address mapped to SDA_IN */ - uint32 sda_out_adr; /* 68000 memory address mapped to SDA_OUT */ - uint32 scl_adr; /* 68000 memory address mapped to SCL */ - uint8 sda_in_bit; /* bit offset for SDA_IN */ - uint8 sda_out_bit; /* bit offset for SDA_OUT */ - uint8 scl_bit; /* bit offset for SCL */ - -} T_EEPROM_TYPE; - -typedef struct -{ - int board_type; - T_EEPROM_TYPE type; -} EEPROM_Config; - -static const EEPROM_Config database[EEP_TOTAL] = -{ - /* ACCLAIM mappers */ - /* 24C02 (old mapper) */ - { EEP_ACCLAIM_24C02_OLD,{8, 0xFF, 0xFF, 0x200001, 0x200001, 0x200001, 0, 1, 1}}, - - /* 24C02 */ - { EEP_ACCLAIM_24C02, {8, 0xFF, 0xFF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, - - /* 24C04 */ - { EEP_ACCLAIM_24C04, {8, 0x1FF, 0x1FF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, - - /* 24C16 */ - { EEP_ACCLAIM_24C16, {8, 0x7FF, 0x7FF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, - - /* 24C65 */ - {EEP_ACCLAIM_24C65, {16, 0x1FFF, 0x1FFF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, - - /* EA mapper (24C01 only) */ - { EEP_EA_24C01, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, - - /* SEGA mapper (24C01 only) */ - { EEP_SEGA_24C01, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, - - /* CODEMASTERS mapper */ - - /* 24C08 */ - { EEP_CM_24C08, {8, 0x3FF, 0x3FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, - - /* 24C16 */ - { EEP_CM_24C16, {8, 0x7FF, 0x7FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, - - /* 24C65 */ - { EEP_CM_24C65, {16, 0x1FFF, 0x1FFF, 0x300000, 0x380001, 0x300000, 0, 7, 1}} -}; - - -class MD_Cart_Type_EEPROM : public MD_Cart_Type -{ - public: - - MD_Cart_Type_EEPROM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const int BoardType); - virtual ~MD_Cart_Type_EEPROM(); - virtual void Reset(void); - - virtual void Write8(uint32 A, uint8 V); - virtual void Write16(uint32 A, uint8 V); - virtual uint8 Read8(uint32 A); - virtual uint16 Read16(uint32 A); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name); - - // In bytes - virtual uint32 GetNVMemorySize(void); - virtual void ReadNVMemory(uint8 *buffer); - virtual void WriteNVMemory(const uint8 *buffer); - - private: - - void WriteEEPROM(unsigned int address, unsigned int value, bool word_access); - unsigned int ReadEEPROM(unsigned int address, bool word_access); - - - const uint8 *rom; - uint32 rom_size; - - void Detect_START(); - void Detect_STOP(); - - uint8 sda; /* current /SDA line state */ - uint8 scl; /* current /SCL line state */ - uint8 old_sda; /* previous /SDA line state */ - uint8 old_scl; /* previous /SCL line state */ - uint8 cycles; /* current operation cycle number (0-9) */ - uint8 rw; /* operation type (1:READ, 0:WRITE) */ - uint16 slave_mask; /* device address (shifted by the memory address width)*/ - uint16 word_address; /* memory address */ - - uint8 *sram; - - T_EEPROM_STATE state; /* current operation state */ - T_EEPROM_TYPE type; /* EEPROM characteristics for this game */ -}; - - -MD_Cart_Type_EEPROM::MD_Cart_Type_EEPROM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const int BoardType) -{ - bool found_board_type = FALSE; - - this->rom = ROM; - this->rom_size = ROM_size; - - /* initialize eeprom */ - sda = old_sda = 1; - scl = old_scl = 1; - state = STAND_BY; - - for(int i = 0; i < EEP_TOTAL; i++) - { - if(database[i].board_type == BoardType) - { - memcpy(&type, &database[i].type, sizeof(T_EEPROM_TYPE)); - found_board_type = TRUE; - break; - } - } - - // Debugging sanity check - if(!found_board_type) - throw(0); - - /* set SRAM start & end address */ - if(!(sram = (uint8 *)MDFN_malloc(type.size_mask + 1, _("Cart EEPROM")))) - { - // FIXME - throw(-1); - } - - memset(sram, 0xFF, type.size_mask + 1); -} - -MD_Cart_Type_EEPROM::~MD_Cart_Type_EEPROM() -{ - if(sram) - MDFN_free(sram); -} - -INLINE void MD_Cart_Type_EEPROM::Detect_START() -{ - if (old_scl && scl) - { - if (old_sda && !sda) - { - cycles = 0; - slave_mask = 0; - if (type.address_bits == 7) - { - word_address = 0; - state = GET_WORD_ADR_7BITS; - } - else state = GET_SLAVE_ADR; - } - } -} - -INLINE void MD_Cart_Type_EEPROM::Detect_STOP() -{ - if (old_scl && scl) - { - if (!old_sda && sda) - { - state = STAND_BY; - } - } -} - -void MD_Cart_Type_EEPROM::Reset(void) -{ - sda = old_sda = 1; - scl = old_scl = 1; - state = STAND_BY; - cycles = 0; - rw = 0; - slave_mask = 0; - word_address = 0; -} - -void MD_Cart_Type_EEPROM::WriteEEPROM(unsigned int address, unsigned int data, bool word_access) -{ - /* decode SCL and SDA value */ - if (word_access) - { - /* 16-bits access */ - if (type.sda_in_adr == address) sda = (data >> (8 + type.sda_in_bit)) & 1; /* MSB */ - else if (type.sda_in_adr == (address | 1)) sda = (data >> type.sda_in_bit) & 1; /* LSB */ - else sda = old_sda; - - if (type.scl_adr == address) scl = (data >> (8 + type.scl_bit)) & 1; /* MSB */ - else if (type.scl_adr == (address | 1)) scl = (data >> type.scl_bit) & 1; /* LSB */ - else scl = old_scl; - } - else - { - if (type.sda_in_adr == address) sda = (data >> type.sda_in_bit) & 1; - else sda = old_sda; - - if (type.scl_adr == address) scl = (data >> type.scl_bit) & 1; - else scl = old_scl; - } - - /* EEPROM current state */ - switch (state) - { - /* Standby Mode */ - case STAND_BY: - Detect_START(); - Detect_STOP(); - break; - - /* Suspended Mode */ - case WAIT_STOP: - Detect_STOP(); - break; - - /* Get Word Address 7 bits: MODE-1 only (24C01) - * and R/W bit - */ - case GET_WORD_ADR_7BITS: - Detect_START(); - Detect_STOP(); - - /* look for SCL LOW to HIGH transition */ - if (!old_scl && scl) - { - if (cycles == 0) cycles ++; - } - - - /* look for SCL HIGH to LOW transition */ - if (old_scl && !scl && (cycles > 0)) - { - if (cycles < 8) - { - word_address |= (old_sda << (7 - cycles)); - } - else if (cycles == 8) - { - rw = old_sda; - } - else - { /* ACK CYCLE */ - cycles = 0; - word_address &= type.size_mask; - state = rw ? READ_DATA : WRITE_DATA; - } - - cycles ++; - } - break; - - - /* Get Slave Address (3bits) : MODE-2 & MODE-3 only (24C01 - 24C512) (0-3bits, depending on the array size) - * or/and Word Address MSB: MODE-2 only (24C04 - 24C16) (0-3bits, depending on the array size) - * and R/W bit - */ - case GET_SLAVE_ADR: - - Detect_START(); - Detect_STOP(); - - /* look for SCL LOW to HIGH transition */ - if (!old_scl && scl) - { - if (cycles == 0) cycles ++; - } - - /* look for SCL HIGH to LOW transition */ - if (old_scl && !scl && (cycles > 0)) - { - if ((cycles > 4) && (cycles <8)) - { - if ((type.address_bits == 16) || - (type.size_mask < (1 << (15 - cycles)))) - { - /* this is a SLAVE ADDRESS bit */ - slave_mask |= (old_sda << (7 - cycles)); - } - else - { - /* this is a WORD ADDRESS high bit */ - if (old_sda) word_address |= (1 << (15 - cycles)); - else word_address &= ~(1 << (15 - cycles)); - } - } - else if (cycles == 8) rw = old_sda; - else if (cycles > 8) - { - /* ACK CYCLE */ - cycles = 0; - if (type.address_bits == 16) - { - /* two ADDRESS bytes */ - state = rw ? READ_DATA : GET_WORD_ADR_HIGH; - slave_mask <<= 16; - } - else - { - /* one ADDRESS byte */ - state = rw ? READ_DATA : GET_WORD_ADR_LOW; - slave_mask <<= 8; - } - } - - cycles ++; - } - break; - - /* Get Word Address MSB (4-8bits depending on the array size) - * MODE-3 only (24C32 - 24C512) - */ - case GET_WORD_ADR_HIGH: - - Detect_START(); - Detect_STOP(); - - /* look for SCL HIGH to LOW transition */ - if (old_scl && !scl) - { - if (cycles < 9) - { - if ((type.size_mask + 1) < (1 << (17 - cycles))) - { - /* ignored bit: slave mask should be right-shifted by one */ - slave_mask >>= 1; - } - else - { - /* this is a WORD ADDRESS high bit */ - if (old_sda) word_address |= (1 << (16 - cycles)); - else word_address &= ~(1 << (16 - cycles)); - } - - cycles ++; - } - else - { - /* ACK CYCLE */ - cycles = 1; - state = GET_WORD_ADR_LOW; - } - } - break; - - - /* Get Word Address LSB: 7bits (24C01) or 8bits (24C02-24C512) - * MODE-2 and MODE-3 only (24C01 - 24C512) - */ - case GET_WORD_ADR_LOW: - - Detect_START(); - Detect_STOP(); - - /* look for SCL HIGH to LOW transition */ - if (old_scl && !scl) - { - if (cycles < 9) - { - if ((type.size_mask + 1) < (1 << (9 - cycles))) - { - /* ignored bit (X24C01): slave mask should be right-shifted by one */ - slave_mask >>= 1; - } - else - { - /* this is a WORD ADDRESS high bit */ - if (old_sda) word_address |= (1 << (8 - cycles)); - else word_address &= ~(1 << (8 - cycles)); - } - - cycles ++; - } - else - { - /* ACK CYCLE */ - cycles = 1; - word_address &= type.size_mask; - state = WRITE_DATA; - } - } - break; - - - /* - * Read Cycle - */ - case READ_DATA: - - Detect_START(); - Detect_STOP(); - - /* look for SCL HIGH to LOW transition */ - if (old_scl && !scl) - { - if (cycles < 9) cycles ++; - else - { - cycles = 1; - - /* ACK not received */ - if (old_sda) state = WAIT_STOP; - } - } - break; - - - /* - * Write Cycle - */ - case WRITE_DATA: - - Detect_START(); - Detect_STOP(); - - /* look for SCL HIGH to LOW transition */ - if (old_scl && !scl) - { - if (cycles < 9) - { - /* Write DATA bits (max 64kBytes) */ - uint16 sram_address = (slave_mask | word_address) & 0xFFFF; - if (old_sda) sram[sram_address] |= (1 << (8 - cycles)); - else sram[sram_address] &= ~(1 << (8 - cycles)); - - if (cycles == 8) - { - /* WORD ADDRESS is incremented (roll up at maximum pagesize) */ - word_address = (word_address & (0xFFFF - type.pagewrite_mask)) | - ((word_address + 1) & type.pagewrite_mask); - } - - cycles ++; - } - else cycles = 1; /* ACK cycle */ - } - break; - } - - old_scl = scl; - old_sda = sda; -} - -unsigned int MD_Cart_Type_EEPROM::ReadEEPROM(unsigned int address, bool word_access) -{ - uint8 sda_out = sda; - - /* EEPROM state */ - switch (state) - { - case READ_DATA: - if (cycles < 9) - { - /* Return DATA bits (max 64kBytes) */ - uint16 sram_address = (slave_mask | word_address) & 0xffff; - sda_out = (sram[sram_address] >> (8 - cycles)) & 1; - - if (cycles == 8) - { - /* WORD ADDRESS is incremented (roll up at maximum array size) */ - word_address ++; - word_address &= type.size_mask; - } - } - break; - - case GET_WORD_ADR_7BITS: - case GET_SLAVE_ADR: - case GET_WORD_ADR_HIGH: - case GET_WORD_ADR_LOW: - case WRITE_DATA: - if (cycles == 9) sda_out = 0; - break; - - default: - break; - } - - /* memory access */ - if (word_access) - { - /* 16-bits access */ - if (type.sda_out_adr & 1) return (sda_out << type.sda_out_bit); /* LSB */ - else return (sda_out << (type.sda_out_bit + 8)); /* MSB */ - } - else return (sda_out << type.sda_out_bit); -} - - -void MD_Cart_Type_EEPROM::Write8(uint32 A, uint8 V) -{ - if((A == type.sda_in_adr) || (A == type.scl_adr)) - WriteEEPROM(A, V, false); -} - -void MD_Cart_Type_EEPROM::Write16(uint32 A, uint8 V) -{ - if((A == (type.sda_in_adr & 0xFFFFFE)) || (A == (type.scl_adr & 0xFFFFFE))) - WriteEEPROM(A, V, true); -} - -uint8 MD_Cart_Type_EEPROM::Read8(uint32 A) -{ - if(A == type.sda_out_adr) - return(ReadEEPROM(A, false)); - - // - - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Moo: %08x\n", A); - return(0); - } - return(READ_BYTE_MSB(rom, A)); - } - return(m68k_read_bus_8(A)); -} - -uint16 MD_Cart_Type_EEPROM::Read16(uint32 A) -{ - if(A == (type.sda_out_adr & 0xFFFFFE)) - return(ReadEEPROM(A, true)); - - // - - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Moo: %08x\n", A); - return(0); - } - return(READ_WORD_MSB(rom, A)); - } - - return(m68k_read_bus_16(A)); -} - -int MD_Cart_Type_EEPROM::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - SFORMAT StateRegs[] = - { - SFVAR(sda), - SFVAR(scl), - SFVAR(old_sda), - SFVAR(old_scl), - SFVAR(cycles), - SFVAR(rw), - SFVAR(slave_mask), - SFVAR(word_address), - SFVAR(state), - SFARRAY(sram, type.size_mask + 1), - SFEND - }; - - int ret = MDFNSS_StateAction(sm, load, data_only, StateRegs, section_name); - if(load) - { - - } - return(ret); -} - -uint32 MD_Cart_Type_EEPROM::GetNVMemorySize(void) -{ - return(type.size_mask + 1); -} - -void MD_Cart_Type_EEPROM::ReadNVMemory(uint8 *buffer) -{ - memcpy(buffer, sram, type.size_mask + 1); -} - -void MD_Cart_Type_EEPROM::WriteNVMemory(const uint8 *buffer) -{ - memcpy(sram, buffer, type.size_mask + 1); -} - -MD_Cart_Type *MD_Make_Cart_Type_EEPROM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam) -{ - return(new MD_Cart_Type_EEPROM(ginfo, ROM, ROM_size, iparam)); -} diff --git a/libmednahawk/src/md/cart/map_eeprom.h b/libmednahawk/src/md/cart/map_eeprom.h deleted file mode 100644 index f28bebda48..0000000000 --- a/libmednahawk/src/md/cart/map_eeprom.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __MD_MAP_EEPROM_H -#define __MD_MAP_EEPROM_H - -enum -{ - EEP_NONE = 0, - EEP_ACCLAIM_24C02_OLD = 1, - EEP_ACCLAIM_24C02, - EEP_ACCLAIM_24C04, - EEP_ACCLAIM_24C16, - EEP_ACCLAIM_24C65, - - EEP_EA_24C01, - - EEP_SEGA_24C01, - - EEP_CM_24C08, - EEP_CM_24C16, - EEP_CM_24C65, - EEP_TOTAL -}; - -MD_Cart_Type *MD_Make_Cart_Type_EEPROM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam); - -#endif diff --git a/libmednahawk/src/md/cart/map_ff.cpp b/libmednahawk/src/md/cart/map_ff.cpp deleted file mode 100644 index e1670208da..0000000000 --- a/libmednahawk/src/md/cart/map_ff.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cart.h" -#include "map_rom.h" - -class MD_Cart_Type_FF : public MD_Cart_Type -{ - public: - - MD_Cart_Type_FF(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size); - virtual ~MD_Cart_Type_FF(); - virtual void Reset(void); - virtual void Write8(uint32 A, uint8 V); - virtual void Write16(uint32 A, uint8 V); - virtual uint8 Read8(uint32 A); - virtual uint16 Read16(uint32 A); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name); - - // In bytes - virtual uint32 GetNVMemorySize(void); - virtual void ReadNVMemory(uint8 *buffer); - virtual void WriteNVMemory(const uint8 *buffer); - - private: - - const uint8 *rom; - uint32 rom_size; - - uint8 latch; - uint8 sram[8192]; -}; - - -MD_Cart_Type_FF::MD_Cart_Type_FF(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) -{ - this->rom = ROM; - this->rom_size = ROM_size; -} - -MD_Cart_Type_FF::~MD_Cart_Type_FF() -{ - memset(sram, 0xFF, 8192); -} - -void MD_Cart_Type_FF::Reset(void) -{ - latch = 0; -} - -void MD_Cart_Type_FF::Write8(uint32 A, uint8 V) -{ - if(A >= 0x200000 && A <= 0x203fff) - { - if(A & 1) - sram[(A >> 1) & 0x1FFF] = V; - } - else if(A == 0x400006) - latch = V; - else - printf("Write8: %08x %02x\n", A, V); - -} - -void MD_Cart_Type_FF::Write16(uint32 A, uint8 V) -{ - if(A >= 0x200000 && A <= 0x203fff) - { - sram[(A >> 1) & 0x1FFF] = V; - } - else - printf("Write16: %08x %04x\n", A, V); -} - -uint8 MD_Cart_Type_FF::Read8(uint32 A) -{ - if(A < 0x400000) - { - if(A >= 0x200000 && A <= 0x203fff) - { - if(A & 1) - return(sram[(A >> 1) & 0x1FFF]); - } - - if(A > rom_size) - { - printf("Moo8: %08x\n", A); - return(0); - } - return(READ_BYTE_MSB(rom, A)); - } - - if(A == 0x400006) - return(latch); - - if(A > 0x410000) - printf("Moo8: %08x\n", A); - - if(A >= 0x400000) - return(READ_BYTE_MSB(rom, (A & 0xFFFFF) + (61 * 32768))); - - return(m68k_read_bus_8(A)); -} - -uint16 MD_Cart_Type_FF::Read16(uint32 A) -{ - if(A < 0x400000) - { - if(A >= 0x200000 && A <= 0x203fff) - return(sram[(A >> 1) & 0x1FFF]); - - if(A > rom_size) - { - printf("Moo16: %08x\n", A); - return(0); - } - return(READ_WORD_MSB(rom, A)); - } - - printf("Moo16: %08x\n", A); - return(m68k_read_bus_16(A)); -} - -int MD_Cart_Type_FF::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - SFORMAT StateRegs[] = - { - SFVAR(latch), - SFARRAY(sram, 8192), - SFEND - }; - - int ret = MDFNSS_StateAction(sm, load, data_only, StateRegs, section_name); - if(load) - { - - } - return(ret); - - return(1); -} - -uint32 MD_Cart_Type_FF::GetNVMemorySize(void) -{ - return(8192); -} - -void MD_Cart_Type_FF::ReadNVMemory(uint8 *buffer) -{ - memcpy(buffer, sram, 8192); -} - -void MD_Cart_Type_FF::WriteNVMemory(const uint8 *buffer) -{ - memcpy(sram, buffer, 8192); -} - -MD_Cart_Type *MD_Make_Cart_Type_FF(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam) -{ - return(new MD_Cart_Type_FF(ginfo, ROM, ROM_size)); -} diff --git a/libmednahawk/src/md/cart/map_ff.h b/libmednahawk/src/md/cart/map_ff.h deleted file mode 100644 index 75e3302e18..0000000000 --- a/libmednahawk/src/md/cart/map_ff.h +++ /dev/null @@ -1,2 +0,0 @@ -MD_Cart_Type *MD_Make_Cart_Type_FF(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam); - diff --git a/libmednahawk/src/md/cart/map_realtec.cpp b/libmednahawk/src/md/cart/map_realtec.cpp deleted file mode 100644 index 4e3a6bb927..0000000000 --- a/libmednahawk/src/md/cart/map_realtec.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cart.h" -#include "map_rom.h" - -class MD_Cart_Type_REALTEC : public MD_Cart_Type -{ - public: - - MD_Cart_Type_REALTEC(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size); - virtual ~MD_Cart_Type_REALTEC(); - virtual void Reset(void); - - virtual void Write8(uint32 A, uint8 V); - virtual void Write16(uint32 A, uint8 V); - virtual uint8 Read8(uint32 A); - virtual uint16 Read16(uint32 A); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name); - - // In bytes - virtual uint32 GetNVMemorySize(void); - virtual void ReadNVMemory(uint8 *buffer); - virtual void WriteNVMemory(const uint8 *buffer); - - private: - - const uint8 *rom; - uint32 rom_size; - - bool boot_mode; - uint8 bank_size; - uint8 bank_select; -}; - - -MD_Cart_Type_REALTEC::MD_Cart_Type_REALTEC(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) -{ - this->rom = ROM; - this->rom_size = ROM_size; -} - -MD_Cart_Type_REALTEC::~MD_Cart_Type_REALTEC() -{ - -} - -void MD_Cart_Type_REALTEC::Reset(void) -{ - boot_mode = TRUE; - bank_select = 0; - bank_size = 0; -} - -void MD_Cart_Type_REALTEC::Write8(uint32 A, uint8 V) -{ - //printf("Write8: %08x %02x\n", A, V); - - switch(A & 0xC06000) - { - case 0x400000: boot_mode = !(V & 0x1); - bank_select &= ~0xC; - bank_select |= (V & 0x6) << 2; - break; - - case 0x402000: bank_size = V; - break; - - case 0x404000: bank_select &= ~0x7; - bank_select |= V & 0x7; - break; - } -} - -void MD_Cart_Type_REALTEC::Write16(uint32 A, uint8 V) -{ - //printf("Write16: %08x %04x\n", A, V); - switch(A & 0xC06000) - { - case 0x400000: boot_mode = !(V & 0x1); - bank_select &= ~0xC; - bank_select |= (V & 0x6) << 2; - break; - - case 0x402000: bank_size = V; - break; - - case 0x404000: bank_select &= ~0x7; - bank_select |= V & 0x7; - break; - } -} - -uint8 MD_Cart_Type_REALTEC::Read8(uint32 A) -{ - if(A < 0x400000) - { - uint32 rom_offset; - - if(boot_mode) - rom_offset = (A & 0x1FFF) | 0x7E000; //(rom_size &~ 0x1FFF) - 0x2000; - else - { - rom_offset = (A & ((0x20000 * bank_size) - 1)) | (bank_select * 0x20000); - } - - if(rom_offset >= rom_size) - return(0); - - return(READ_BYTE_MSB(rom, rom_offset)); - } - return(m68k_read_bus_8(A)); -} - -uint16 MD_Cart_Type_REALTEC::Read16(uint32 A) -{ - if(A < 0x400000) - { - uint32 rom_offset; - - if(boot_mode) - rom_offset = (A & 0x1FFF) | 0x07E000; //rom_size &~ 0x1FFF) - 0x2000; - else - { - rom_offset = (A & ((0x20000 * bank_size) - 1)) | (bank_select * 0x20000); - } - - if(rom_offset >= rom_size) - return(0); - - return(READ_WORD_MSB(rom, rom_offset)); - } - - return(m68k_read_bus_16(A)); -} - -int MD_Cart_Type_REALTEC::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - SFORMAT StateRegs[] = - { - SFVAR(bank_size), - SFVAR(bank_select), - SFVAR(boot_mode), - SFEND - }; - - int ret = MDFNSS_StateAction(sm, load, data_only, StateRegs, section_name); - if(load) - { - - } - return(ret); - - return(1); -} - -uint32 MD_Cart_Type_REALTEC::GetNVMemorySize(void) -{ - return(0); -} - -void MD_Cart_Type_REALTEC::ReadNVMemory(uint8 *buffer) -{ - -} - -void MD_Cart_Type_REALTEC::WriteNVMemory(const uint8 *buffer) -{ - -} - -MD_Cart_Type *MD_Make_Cart_Type_REALTEC(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam) -{ - return(new MD_Cart_Type_REALTEC(ginfo, ROM, ROM_size)); -} diff --git a/libmednahawk/src/md/cart/map_realtec.h b/libmednahawk/src/md/cart/map_realtec.h deleted file mode 100644 index 82f00d6250..0000000000 --- a/libmednahawk/src/md/cart/map_realtec.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __MD_MAP_REALTEC_H -#define __MD_MAP_REALTEC_H - -MD_Cart_Type *MD_Make_Cart_Type_REALTEC(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam); - -#endif diff --git a/libmednahawk/src/md/cart/map_rmx3.cpp b/libmednahawk/src/md/cart/map_rmx3.cpp deleted file mode 100644 index 7c3357a80b..0000000000 --- a/libmednahawk/src/md/cart/map_rmx3.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cart.h" -#include "map_rom.h" - -class MD_Cart_Type_RMX3 : public MD_Cart_Type -{ - public: - - MD_Cart_Type_RMX3(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size); - virtual ~MD_Cart_Type_RMX3(); - - virtual void Write8(uint32 A, uint8 V); - virtual void Write16(uint32 A, uint8 V); - virtual uint8 Read8(uint32 A); - virtual uint16 Read16(uint32 A); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name); - - // In bytes - virtual uint32 GetNVMemorySize(void); - virtual void ReadNVMemory(uint8 *buffer); - virtual void WriteNVMemory(const uint8 *buffer); - - private: - - const uint8 *rom; - uint32 rom_size; - -}; - - -MD_Cart_Type_RMX3::MD_Cart_Type_RMX3(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) -{ - this->rom = ROM; - this->rom_size = ROM_size; -} - -MD_Cart_Type_RMX3::~MD_Cart_Type_RMX3() -{ - -} - - -void MD_Cart_Type_RMX3::Write8(uint32 A, uint8 V) -{ - -} - -void MD_Cart_Type_RMX3::Write16(uint32 A, uint8 V) -{ - -} - -uint8 MD_Cart_Type_RMX3::Read8(uint32 A) -{ - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Moo8: %08x\n", A); - return(0); - } - return(READ_BYTE_MSB(rom, A)); - } - - if(A == 0xa13000) - return(0x0C); - if(A == 0x400004) - return(0x88); - - printf("Moo8: %08x\n", A); - return(m68k_read_bus_8(A)); -} - -uint16 MD_Cart_Type_RMX3::Read16(uint32 A) -{ - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Moo16: %08x\n", A); - return(0); - } - return(READ_WORD_MSB(rom, A)); - } - - if(A == 0xa13000) - return(0x0C); - if(A == 0x400004) - return(0x88); - - printf("Moo16: %08x\n", A); - return(m68k_read_bus_16(A)); -} - -int MD_Cart_Type_RMX3::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - return(1); -} - -uint32 MD_Cart_Type_RMX3::GetNVMemorySize(void) -{ - return(0); -} - -void MD_Cart_Type_RMX3::ReadNVMemory(uint8 *buffer) -{ - -} - -void MD_Cart_Type_RMX3::WriteNVMemory(const uint8 *buffer) -{ - -} - -MD_Cart_Type *MD_Make_Cart_Type_RMX3(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam) -{ - return(new MD_Cart_Type_RMX3(ginfo, ROM, ROM_size)); -} diff --git a/libmednahawk/src/md/cart/map_rmx3.h b/libmednahawk/src/md/cart/map_rmx3.h deleted file mode 100644 index e8d3993fbe..0000000000 --- a/libmednahawk/src/md/cart/map_rmx3.h +++ /dev/null @@ -1,2 +0,0 @@ -MD_Cart_Type *MD_Make_Cart_Type_RMX3(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam); - diff --git a/libmednahawk/src/md/cart/map_rom.cpp b/libmednahawk/src/md/cart/map_rom.cpp deleted file mode 100644 index 5096ebe0cb..0000000000 --- a/libmednahawk/src/md/cart/map_rom.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cart.h" -#include "map_rom.h" - -// Basic flat-space ROM-only mapper. - -class MD_Cart_Type_ROM : public MD_Cart_Type -{ - public: - - MD_Cart_Type_ROM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size); - virtual ~MD_Cart_Type_ROM(); - - virtual void Write8(uint32 A, uint8 V); - virtual void Write16(uint32 A, uint8 V); - virtual uint8 Read8(uint32 A); - virtual uint16 Read16(uint32 A); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name); - - // In bytes - virtual uint32 GetNVMemorySize(void); - virtual void ReadNVMemory(uint8 *buffer); - virtual void WriteNVMemory(const uint8 *buffer); - - private: - - const uint8 *rom; - uint32 rom_size; - -}; - - -MD_Cart_Type_ROM::MD_Cart_Type_ROM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) -{ - this->rom = ROM; - this->rom_size = ROM_size; -} - -MD_Cart_Type_ROM::~MD_Cart_Type_ROM() -{ - -} - - -void MD_Cart_Type_ROM::Write8(uint32 A, uint8 V) -{ - printf("Write8: %08x %02x\n", A, V); -} - -void MD_Cart_Type_ROM::Write16(uint32 A, uint8 V) -{ - printf("Write16: %08x %04x\n", A, V); -} - -uint8 MD_Cart_Type_ROM::Read8(uint32 A) -{ - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Read8: %08x\n", A); - return(0); - } - return(READ_BYTE_MSB(rom, A)); - } - printf("Read8: %08x\n", A); - return(m68k_read_bus_8(A)); -} - -uint16 MD_Cart_Type_ROM::Read16(uint32 A) -{ - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Read16: %08x\n", A); - return(0); - } - return(READ_WORD_MSB(rom, A)); - } - - printf("Read16: %08x\n", A); - - return(m68k_read_bus_16(A)); -} - -int MD_Cart_Type_ROM::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - return(1); -} - -uint32 MD_Cart_Type_ROM::GetNVMemorySize(void) -{ - return(0); -} - -void MD_Cart_Type_ROM::ReadNVMemory(uint8 *buffer) -{ - -} - -void MD_Cart_Type_ROM::WriteNVMemory(const uint8 *buffer) -{ - -} - -MD_Cart_Type *MD_Make_Cart_Type_ROM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam) -{ - return(new MD_Cart_Type_ROM(ginfo, ROM, ROM_size)); -} diff --git a/libmednahawk/src/md/cart/map_rom.h b/libmednahawk/src/md/cart/map_rom.h deleted file mode 100644 index ebaccc0e3b..0000000000 --- a/libmednahawk/src/md/cart/map_rom.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __MD_MAP_ROM_H -#define __MD_MAP_ROM_H - -MD_Cart_Type *MD_Make_Cart_Type_ROM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam); - -#endif diff --git a/libmednahawk/src/md/cart/map_sbb.cpp b/libmednahawk/src/md/cart/map_sbb.cpp deleted file mode 100644 index c0f4a7afdd..0000000000 --- a/libmednahawk/src/md/cart/map_sbb.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cart.h" -#include "map_rom.h" - -class MD_Cart_Type_SBB : public MD_Cart_Type -{ - public: - - MD_Cart_Type_SBB(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size); - virtual ~MD_Cart_Type_SBB(); - - virtual void Write8(uint32 A, uint8 V); - virtual void Write16(uint32 A, uint8 V); - virtual uint8 Read8(uint32 A); - virtual uint16 Read16(uint32 A); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name); - - // In bytes - virtual uint32 GetNVMemorySize(void); - virtual void ReadNVMemory(uint8 *buffer); - virtual void WriteNVMemory(const uint8 *buffer); - - private: - - const uint8 *rom; - uint32 rom_size; - -}; - - -MD_Cart_Type_SBB::MD_Cart_Type_SBB(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) -{ - this->rom = ROM; - this->rom_size = ROM_size; -} - -MD_Cart_Type_SBB::~MD_Cart_Type_SBB() -{ - -} - - -void MD_Cart_Type_SBB::Write8(uint32 A, uint8 V) -{ - -} - -void MD_Cart_Type_SBB::Write16(uint32 A, uint8 V) -{ - -} - -uint8 MD_Cart_Type_SBB::Read8(uint32 A) -{ - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Moo: %08x\n", A); - return(0); - } - return(READ_BYTE_MSB(rom, A)); - } - - if(A == 0x400000) - return(0x55); - if(A == 0x400002) - return(0x0f); - - printf("Moo: %08x\n", A); - return(m68k_read_bus_8(A)); -} - -uint16 MD_Cart_Type_SBB::Read16(uint32 A) -{ - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Moo: %08x\n", A); - return(0); - } - return(READ_WORD_MSB(rom, A)); - } - - if(A == 0x400000) - return(0x55); - if(A == 0x400002) - return(0x0f); - - printf("Moo: %08x\n", A); - return(m68k_read_bus_16(A)); -} - -int MD_Cart_Type_SBB::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - return(1); -} - -uint32 MD_Cart_Type_SBB::GetNVMemorySize(void) -{ - return(0); -} - -void MD_Cart_Type_SBB::ReadNVMemory(uint8 *buffer) -{ - -} - -void MD_Cart_Type_SBB::WriteNVMemory(const uint8 *buffer) -{ - -} - -MD_Cart_Type *MD_Make_Cart_Type_SBB(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam) -{ - return(new MD_Cart_Type_SBB(ginfo, ROM, ROM_size)); -} diff --git a/libmednahawk/src/md/cart/map_sbb.h b/libmednahawk/src/md/cart/map_sbb.h deleted file mode 100644 index 1a1d5bc7cc..0000000000 --- a/libmednahawk/src/md/cart/map_sbb.h +++ /dev/null @@ -1,2 +0,0 @@ -MD_Cart_Type *MD_Make_Cart_Type_SBB(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam); - diff --git a/libmednahawk/src/md/cart/map_sram.cpp b/libmednahawk/src/md/cart/map_sram.cpp deleted file mode 100644 index aaa16c7eae..0000000000 --- a/libmednahawk/src/md/cart/map_sram.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cart.h" -#include "map_sram.h" - -// TODO: Add suport for 8-bit mapped into 16-bit space correctly - -class MD_Cart_Type_SRAM : public MD_Cart_Type -{ - public: - - MD_Cart_Type_SRAM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size); - virtual ~MD_Cart_Type_SRAM(); - virtual void Reset(void); - - virtual void Write8(uint32 A, uint8 V); - virtual void Write16(uint32 A, uint8 V); - virtual uint8 Read8(uint32 A); - virtual uint16 Read16(uint32 A); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name); - - // In bytes - virtual uint32 GetNVMemorySize(void); - virtual void ReadNVMemory(uint8 *buffer); - virtual void WriteNVMemory(const uint8 *buffer); - - private: - - const uint8 *rom; - uint32 rom_size; - - uint32 sram_start; - uint32 sram_end; - uint32 sram_size; - - bool sram_enabled; - uint8 *sram; -}; - - -MD_Cart_Type_SRAM::MD_Cart_Type_SRAM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) -{ - this->rom = ROM; - this->rom_size = ROM_size; - - sram_start = ginfo->sram_start; - sram_end = ginfo->sram_end; - - sram_size = 0; - - sram_start &= 0xFFFFFE; - sram_end |= 0x000001; - - if((uint32)(sram_end - sram_start) >= 0x10000 || sram_start == sram_end) - { - sram_end = sram_start + 0xFFFF; - } - sram_size = sram_end - sram_start + 1; - - printf("%08x %08x %08x\n", sram_start, sram_end, sram_size); - - if(!(sram = (uint8 *)MDFN_malloc(sram_size, _("Cart SRAM")))) - { - // FIXME - throw(-1); - } - memset(sram, 0xFF, sram_size); -} - -MD_Cart_Type_SRAM::~MD_Cart_Type_SRAM() -{ - if(sram) - free(sram); -} - -void MD_Cart_Type_SRAM::Reset(void) -{ - if(rom_size > sram_start) - sram_enabled = FALSE; - else - sram_enabled = TRUE; -} - -void MD_Cart_Type_SRAM::Write8(uint32 A, uint8 V) -{ - if(A == 0xA130F1) - sram_enabled = V & 1; - - if(A >= sram_start && A <= sram_end) - { - WRITE_BYTE_MSB(sram, A - sram_start, V); - } -} - -void MD_Cart_Type_SRAM::Write16(uint32 A, uint8 V) -{ - if(A == 0xA130F0) - sram_enabled = V & 1; - - if(A >= sram_start && A <= sram_end) - { - WRITE_WORD_MSB(sram, A - sram_start, V); - } -} - -uint8 MD_Cart_Type_SRAM::Read8(uint32 A) -{ - if(sram_enabled && A >= sram_start && A <= sram_end) - { - return(READ_BYTE_MSB(sram, A - sram_start)); - } - - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Moo: %08x\n", A); - return(0); - } - return(READ_BYTE_MSB(rom, A)); - } - return(m68k_read_bus_8(A)); -} - -uint16 MD_Cart_Type_SRAM::Read16(uint32 A) -{ - if(sram_enabled && A >= sram_start && A <= sram_end) - { - return(READ_WORD_MSB(sram, A - sram_start)); - } - - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Moo: %08x\n", A); - return(0); - } - return(READ_WORD_MSB(rom, A)); - } - - return(m68k_read_bus_16(A)); -} - -int MD_Cart_Type_SRAM::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - SFORMAT StateRegs[] = - { - SFVAR(sram_enabled), - SFARRAY(sram, sram_size), - SFEND - }; - - int ret = MDFNSS_StateAction(sm, load, data_only, StateRegs, section_name); - if(load) - { - - } - return(ret); -} - -uint32 MD_Cart_Type_SRAM::GetNVMemorySize(void) -{ - return(sram_size); -} - -void MD_Cart_Type_SRAM::ReadNVMemory(uint8 *buffer) -{ - memcpy(buffer, sram, sram_size); -} - -void MD_Cart_Type_SRAM::WriteNVMemory(const uint8 *buffer) -{ - memcpy(sram, buffer, sram_size); -} - -MD_Cart_Type *MD_Make_Cart_Type_SRAM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam) -{ - return(new MD_Cart_Type_SRAM(ginfo, ROM, ROM_size)); -} diff --git a/libmednahawk/src/md/cart/map_sram.h b/libmednahawk/src/md/cart/map_sram.h deleted file mode 100644 index 8e460b0413..0000000000 --- a/libmednahawk/src/md/cart/map_sram.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __MD_MAP_SRAM_H -#define __MD_MAP_SRAM_H - -MD_Cart_Type *MD_Make_Cart_Type_SRAM(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam); - -#endif diff --git a/libmednahawk/src/md/cart/map_ssf2.cpp b/libmednahawk/src/md/cart/map_ssf2.cpp deleted file mode 100644 index 15c2f57e92..0000000000 --- a/libmednahawk/src/md/cart/map_ssf2.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cart.h" -#include "map_rom.h" - -class MD_Cart_Type_SSF2 : public MD_Cart_Type -{ - public: - - MD_Cart_Type_SSF2(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size); - virtual ~MD_Cart_Type_SSF2(); - virtual void Reset(void); - - virtual void Write8(uint32 A, uint8 V); - virtual void Write16(uint32 A, uint8 V); - virtual uint8 Read8(uint32 A); - virtual uint16 Read16(uint32 A); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name); - - // In bytes - virtual uint32 GetNVMemorySize(void); - virtual void ReadNVMemory(uint8 *buffer); - virtual void WriteNVMemory(const uint8 *buffer); - - private: - - const uint8 *rom; - uint32 rom_size; - uint8 sf2_banks[8]; - uint8 control; -}; - - -MD_Cart_Type_SSF2::MD_Cart_Type_SSF2(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) -{ - this->rom = ROM; - this->rom_size = ROM_size; -} - -MD_Cart_Type_SSF2::~MD_Cart_Type_SSF2() -{ - -} - -void MD_Cart_Type_SSF2::Reset(void) -{ - control = 0; - - for(int i = 0; i < 8; i++) - sf2_banks[i] = i; -} - -void MD_Cart_Type_SSF2::Write8(uint32 A, uint8 V) -{ - switch(A) - { - default: printf("Write8: %08x %02x\n", A, V); break; - case 0xA130F1: control = V & 0x3; break; - case 0xA130F3: sf2_banks[1] = V & 0x3F; break; - case 0xA130F5: sf2_banks[2] = V & 0x3F; break; - case 0xA130F7: sf2_banks[3] = V & 0x3F; break; - case 0xA130F9: sf2_banks[4] = V & 0x3F; break; - case 0xA130FB: sf2_banks[5] = V & 0x3F; break; - case 0xA130FD: sf2_banks[6] = V & 0x3F; break; - case 0xA130FF: sf2_banks[7] = V & 0x3F; break; - } -} - -void MD_Cart_Type_SSF2::Write16(uint32 A, uint8 V) -{ - // Just a guess - switch(A) - { - default: printf("Write16: %08x %04x\n", A, V); break; - case 0xA130F0: control = V & 0x3; break; - case 0xA130F2: sf2_banks[1] = V & 0x3F; break; - case 0xA130F4: sf2_banks[2] = V & 0x3F; break; - case 0xA130F6: sf2_banks[3] = V & 0x3F; break; - case 0xA130F8: sf2_banks[4] = V & 0x3F; break; - case 0xA130FA: sf2_banks[5] = V & 0x3F; break; - case 0xA130FC: sf2_banks[6] = V & 0x3F; break; - case 0xA130FE: sf2_banks[7] = V & 0x3F; break; - } -} - -uint8 MD_Cart_Type_SSF2::Read8(uint32 A) -{ - if(A < 0x400000) - { - uint32 rom_offset = (sf2_banks[(A >> 19) & 0x7] << 19) | (A & 0x7FFFF); - - if(rom_offset >= rom_size) - return(0); - - return(READ_BYTE_MSB(rom, rom_offset)); - } - return(m68k_read_bus_8(A)); -} - -uint16 MD_Cart_Type_SSF2::Read16(uint32 A) -{ - if(A < 0x400000) - { - uint32 rom_offset = (sf2_banks[(A >> 19) & 0x7] << 19) | (A & 0x7FFFF); - - if(rom_offset >= rom_size) - return(0); - - return(READ_WORD_MSB(rom, rom_offset)); - } - - return(m68k_read_bus_16(A)); -} - -int MD_Cart_Type_SSF2::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - SFORMAT StateRegs[] = - { - SFARRAY(sf2_banks, 8), - SFVAR(control), - SFEND - }; - - int ret = MDFNSS_StateAction(sm, load, data_only, StateRegs, section_name); - if(load) - { - - } - return(ret); - - return(1); -} - -uint32 MD_Cart_Type_SSF2::GetNVMemorySize(void) -{ - return(0); -} - -void MD_Cart_Type_SSF2::ReadNVMemory(uint8 *buffer) -{ - -} - -void MD_Cart_Type_SSF2::WriteNVMemory(const uint8 *buffer) -{ - -} - -MD_Cart_Type *MD_Make_Cart_Type_SSF2(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam) -{ - return(new MD_Cart_Type_SSF2(ginfo, ROM, ROM_size)); -} diff --git a/libmednahawk/src/md/cart/map_ssf2.h b/libmednahawk/src/md/cart/map_ssf2.h deleted file mode 100644 index 41a235ccdc..0000000000 --- a/libmednahawk/src/md/cart/map_ssf2.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __MD_MAP_SSF2_H -#define __MD_MAP_SSF2_H - -MD_Cart_Type *MD_Make_Cart_Type_SSF2(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam); - -#endif diff --git a/libmednahawk/src/md/cart/map_svp.cpp b/libmednahawk/src/md/cart/map_svp.cpp deleted file mode 100644 index 4fd7d50781..0000000000 --- a/libmednahawk/src/md/cart/map_svp.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cart.h" -#include "map_svp.h" - -// UNFINISHED - -class MD_Cart_Type_SVP : public MD_Cart_Type -{ - public: - - MD_Cart_Type_SVP(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size); - virtual ~MD_Cart_Type_SVP(); - - virtual void Write8(uint32 A, uint8 V); - virtual void Write16(uint32 A, uint8 V); - virtual uint8 Read8(uint32 A); - virtual uint16 Read16(uint32 A); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name); - - // In bytes - virtual uint32 GetNVMemorySize(void); - virtual void ReadNVMemory(uint8 *buffer); - virtual void WriteNVMemory(const uint8 *buffer); - - private: - - const uint8 *rom; - uint32 rom_size; - -}; - - -MD_Cart_Type_SVP::MD_Cart_Type_SVP(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) -{ - this->rom = ROM; - this->rom_size = ROM_size; -} - -MD_Cart_Type_SVP::~MD_Cart_Type_SVP() -{ - -} - - -void MD_Cart_Type_SVP::Write8(uint32 A, uint8 V) -{ - printf("Write8: %08x %02x\n", A, V); -} - -void MD_Cart_Type_SVP::Write16(uint32 A, uint8 V) -{ - printf("Write16: %08x %04x\n", A, V); -} - -uint8 MD_Cart_Type_SVP::Read8(uint32 A) -{ - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Read8: %08x\n", A); - return(0); - } - return(READ_BYTE_MSB(rom, A)); - } - printf("Read8: %08x\n", A); - return(m68k_read_bus_8(A)); -} - -uint16 MD_Cart_Type_SVP::Read16(uint32 A) -{ - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Read16: %08x\n", A); - return(0); - } - return(READ_WORD_MSB(rom, A)); - } - - printf("Read16: %08x\n", A); - - return(m68k_read_bus_16(A)); -} - -int MD_Cart_Type_SVP::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - return(1); -} - -uint32 MD_Cart_Type_SVP::GetNVMemorySize(void) -{ - return(0); -} - -void MD_Cart_Type_SVP::ReadNVMemory(uint8 *buffer) -{ - -} - -void MD_Cart_Type_SVP::WriteNVMemory(const uint8 *buffer) -{ - -} - -MD_Cart_Type *MD_Make_Cart_Type_SVP(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam) -{ - return(new MD_Cart_Type_SVP(ginfo, ROM, ROM_size)); -} diff --git a/libmednahawk/src/md/cart/map_svp.h b/libmednahawk/src/md/cart/map_svp.h deleted file mode 100644 index b73b88f633..0000000000 --- a/libmednahawk/src/md/cart/map_svp.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __MD_MAP_SVP_H -#define __MD_MAP_SVP_H - -MD_Cart_Type *MD_Make_Cart_Type_SVP(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam); - -#endif diff --git a/libmednahawk/src/md/cart/map_yase.cpp b/libmednahawk/src/md/cart/map_yase.cpp deleted file mode 100644 index e2d9bf65d7..0000000000 --- a/libmednahawk/src/md/cart/map_yase.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cart.h" -#include "map_rom.h" - -class MD_Cart_Type_YaSe : public MD_Cart_Type -{ - public: - - MD_Cart_Type_YaSe(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size); - virtual ~MD_Cart_Type_YaSe(); - - virtual void Write8(uint32 A, uint8 V); - virtual void Write16(uint32 A, uint8 V); - virtual uint8 Read8(uint32 A); - virtual uint16 Read16(uint32 A); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_name); - - // In bytes - virtual uint32 GetNVMemorySize(void); - virtual void ReadNVMemory(uint8 *buffer); - virtual void WriteNVMemory(const uint8 *buffer); - - private: - - const uint8 *rom; - uint32 rom_size; - uint8 sram[4096]; -}; - - -MD_Cart_Type_YaSe::MD_Cart_Type_YaSe(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size) -{ - this->rom = ROM; - this->rom_size = ROM_size; - - memset(sram, 0xFF, 4096); -} - -MD_Cart_Type_YaSe::~MD_Cart_Type_YaSe() -{ - -} - - -void MD_Cart_Type_YaSe::Write8(uint32 A, uint8 V) -{ - if(A >= 0x200000 && A <= 0x201fff) - { - if(A & 1) - sram[(A >> 1) & 0x1FFF] = V; - } -} - -void MD_Cart_Type_YaSe::Write16(uint32 A, uint8 V) -{ - if(A >= 0x200000 && A <= 0x201fff) - { - sram[(A >> 1) & 0x1FFF] = V; - } -} - -uint8 MD_Cart_Type_YaSe::Read8(uint32 A) -{ - if(A >= 0x200000 && A <= 0x201fff) - { - if(A & 1) - return(sram[(A >> 1) & 0x1FFF]); - } - - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Moo8: %08x\n", A); - return(0); - } - return(READ_BYTE_MSB(rom, A)); - } - - if(A == 0x400000) - return(0x63); - if(A == 0x400002) - return(0x98); - if(A == 0x400004) - return(0xC9); - if(A == 0x400006) - return(0x18); - - printf("Moo8: %08x\n", A); - return(m68k_read_bus_8(A)); -} - -uint16 MD_Cart_Type_YaSe::Read16(uint32 A) -{ - if(A >= 0x200000 && A <= 0x201fff) - return(sram[(A >> 1) & 0x1FFF]); - - if(A < 0x400000) - { - if(A > rom_size) - { - printf("Moo16: %08x\n", A); - return(0); - } - return(READ_WORD_MSB(rom, A)); - } - - if(A == 0x400000) - return(0x63); - if(A == 0x400002) - return(0x98); - if(A == 0x400004) - return(0xC9); - if(A == 0x400006) - return(0x18); - - printf("Moo16: %08x\n", A); - return(m68k_read_bus_16(A)); -} - -int MD_Cart_Type_YaSe::StateAction(StateMem *sm, int load, int data_only, const char *section_name) -{ - return(1); -} - -uint32 MD_Cart_Type_YaSe::GetNVMemorySize(void) -{ - return(4096); -} - -void MD_Cart_Type_YaSe::ReadNVMemory(uint8 *buffer) -{ - memcpy(buffer, sram, 4096); -} - -void MD_Cart_Type_YaSe::WriteNVMemory(const uint8 *buffer) -{ - memcpy(sram, buffer, 4096); -} - -MD_Cart_Type *MD_Make_Cart_Type_YaSe(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam) -{ - return(new MD_Cart_Type_YaSe(ginfo, ROM, ROM_size)); -} diff --git a/libmednahawk/src/md/cart/map_yase.h b/libmednahawk/src/md/cart/map_yase.h deleted file mode 100644 index 2013f3ecf8..0000000000 --- a/libmednahawk/src/md/cart/map_yase.h +++ /dev/null @@ -1,2 +0,0 @@ -MD_Cart_Type *MD_Make_Cart_Type_YaSe(const md_game_info *ginfo, const uint8 *ROM, const uint32 ROM_size, const uint32 iparam, const char *sparam); - diff --git a/libmednahawk/src/md/cart/ssp16.c b/libmednahawk/src/md/cart/ssp16.c deleted file mode 100644 index 517b9d4ea5..0000000000 --- a/libmednahawk/src/md/cart/ssp16.c +++ /dev/null @@ -1,1246 +0,0 @@ -/* - * basic, incomplete SSP160x (SSP1601?) interpreter - * with SVP memory controller emu - * - * Copyright (c) Gražvydas "notaz" Ignotas, 2008 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the organization nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -//#define USE_DEBUGGER -/* detect ops with unimplemented/invalid fields. - * Useful for homebrew or if a new VR revision pops up. */ -//#define DO_CHECKS - -/* - * Register info - * - * 0. "-" - * size: 16 - * desc: Constant register with all bits set (0xffff). - * - * 1. "X" - * size: 16 - * desc: Generic register. When set, updates P (P = X * Y * 2) - * - * 2. "Y" - * size: 16 - * desc: Generic register. When set, updates P (P = X * Y * 2) - * - * 3. "A" - * size: 32 - * desc: Accumulator. - * - * 4. "ST" - * size: 16 - * desc: Status register. From MAME: bits 0-9 are CONTROL, other FLAG - * fedc ba98 7654 3210 - * 210 - RPL (?) "Loop size". If non-zero, makes (rX+) and (rX-) respectively - * modulo-increment and modulo-decrement. The value shows which - * power of 2 to use, i.e. 4 means modulo by 16. - * (e: fir16_32.sc, IIR_4B.SC, DECIM.SC) - * 43 - RB (?) - * 5 - GP0_0 (ST5?) Changed before acessing PM0 (affects banking?). - * 6 - GP0_1 (ST6?) Cleared before acessing PM0 (affects banking?). Set after. - * datasheet says these (5,6) bits correspond to hardware pins. - * 7 - IE (?) Not directly used by SVP code (never set, but preserved)? - * 8 - OP (?) Not used by SVP code (only cleared)? (MAME: saturated value - * (probably means clamping? i.e. 0x7ffc + 9 -> 0x7fff)) - * 9 - MACS (?) Not used by SVP code (only cleared)? (e: "mac shift") - * a - GPI_0 Interrupt 0 enable/status? - * b - GPI_1 Interrupt 1 enable/status? - * c - L L flag. Carry? - * d - Z Zero flag. - * e - OV Overflow flag. - * f - N Negative flag. - * seen directly changing code sequences: - * ldi ST, 0 ld A, ST ld A, ST ld A, ST ldi st, 20h - * ldi ST, 60h ori A, 60h and A, E8h and A, E8h - * ld ST, A ld ST, A ori 3 - * ld ST, A - * - * 5. "STACK" - * size: 16 - * desc: hw stack of 6 levels (according to datasheet) - * - * 6. "PC" - * size: 16 - * desc: Program counter. - * - * 7. "P" - * size: 32 - * desc: multiply result register. P = X * Y * 2 - * probably affected by MACS bit in ST. - * - * 8. "PM0" (PM from PMAR name from Tasco's docs) - * size: 16? - * desc: Programmable Memory access register. - * On reset, or when one (both?) GP0 bits are clear, - * acts as status for XST, mapped at 015004 at 68k side: - * bit0: ssp has written something to XST (cleared when 015004 is read) - * bit1: 68k has written something through a1500{0|2} (cleared on PM0 read) - * - * 9. "PM1" - * size: 16? - * desc: Programmable Memory access register. - * This reg. is only used as PMAR. - * - * 10. "PM2" - * size: 16? - * desc: Programmable Memory access register. - * This reg. is only used as PMAR. - * - * 11. "XST" - * size: 16? - * desc: eXternal STate. Mapped to a15000 and a15002 at 68k side. - * Can be programmed as PMAR? (only seen in test mode code) - * Affects PM0 when written to? - * - * 12. "PM4" - * size: 16? - * desc: Programmable Memory access register. - * This reg. is only used as PMAR. The most used PMAR by VR. - * - * 13. (unused by VR) - * - * 14. "PMC" (PMC from PMAC name from Tasco's docs) - * size: 32? - * desc: Programmable Memory access Control. Set using 2 16bit writes, - * first address, then mode word. After setting PMAC, PMAR sould - * be blind accessed (ld -, PMx or ld PMx, -) to program it for - * reading and writing respectively. - * Reading the register also shifts it's state (from "waiting for - * address" to "waiting for mode" and back). Reads always return - * address related to last PMx register accressed. - * (note: addresses do not wrap). - * - * 15. "AL" - * size: 16 - * desc: Accumulator Low. 16 least significant bits of accumulator. - * (normally reading acc (ld X, A) you get 16 most significant bits). - * - * - * There are 8 8-bit pointer registers rX. r0-r3 (ri) point to RAM0, r4-r7 (rj) point to RAM1. - * They can be accessed directly, or 2 indirection levels can be used [ (rX), ((rX)) ], - * which work similar to * and ** operators in C, only they use different memory banks and - * ((rX)) also does post-increment. First indirection level (rX) accesses RAMx, second accesses - * program memory at address read from (rX), and increments value in (rX). - * - * r0,r1,r2,r4,r5,r6 can be modified [ex: ldi r0, 5]. - * 3 modifiers can be applied (optional): - * + : post-increment [ex: ld a, (r0+) ]. Can be made modulo-increment by setting RPL bits in ST. - * - : post-decrement. Can be made modulo-decrement by setting RPL bits in ST (not sure). - * +!: post-increment, unaffected by RPL (probably). - * These are only used on 1st indirection level, so things like [ld a, ((r0+))] and [ld X, r6-] - * ar probably invalid. - * - * r3 and r7 are special and can not be changed (at least Samsung samples and VR code never do). - * They are fixed to the start of their RAM banks. (They are probably changeable for ssp1605+, - * Samsung's old DSP page claims that). - * 1 of these 4 modifiers must be used (short form direct addressing?): - * |00: RAMx[0] [ex: (r3|00), 0] (based on sample code) - * |01: RAMx[1] - * |10: RAMx[2] ? maybe 10h? accortding to Div_c_dp.sc, 2 - * |11: RAMx[3] - * - * - * Instruction notes - * - * ld a, * doesn't affect flags! (e: A_LAW.SC, Div_c_dp.sc) - * - * mld (rj), (ri) [, b] - * operation: A = 0; P = (rj) * (ri) - * notes: based on IIR_4B.SC sample. flags? what is b??? - * - * mpya (rj), (ri) [, b] - * name: multiply and add? - * operation: A += P; P = (rj) * (ri) - * - * mpys (rj), (ri), b - * name: multiply and subtract? - * notes: not used by VR code. - * - * mod cond, op - * mod cond, shr does arithmetic shift - * - * 'ld -, AL' and probably 'ld AL, -' are for dummy assigns - * - * memory map: - * 000000 - 1fffff ROM, accessable by both - * 200000 - 2fffff unused? - * 300000 - 31ffff DRAM, both - * 320000 - 38ffff unused? - * 390000 - 3907ff IRAM. can only be accessed by ssp? - * 390000 - 39ffff similar mapping to "cell arrange" in Sega CD, 68k only? - * 3a0000 - 3affff similar mapping to "cell arrange" in Sega CD, a bit different - * - * 30fe02 - 0 if SVP busy, 1 if done (set by SVP, checked and cleared by 68k) - * 30fe06 - also sync related. - * 30fe08 - job number [1-12] for SVP. 0 means no job. Set by 68k, read-cleared by VR. - * - * Assumptions and limitations in this code - * only Z and N status flags are emulated (others unused by VR) - * so all condition checks except N and Z are ignored (not used by VR) - * modifiers for 'OP a, ri' and ((ri)) are ignored (not used by VR) - * loop repeat mode when (ri) is destination is ignored - * ops not used by VR are not implemented - */ - -#include "stdlib.h" // NULL -#include "deps.h" -#include "svp.h" - -// 0 -#define rX ssp->gr[SSP_X].h -#define rY ssp->gr[SSP_Y].h -#define rA ssp->gr[SSP_A].h -#define rST ssp->gr[SSP_ST].h // 4 -#define rSTACK ssp->gr[SSP_STACK].h -#define rPC ssp->gr[SSP_PC].h -#define rP ssp->gr[SSP_P] -#define rPM0 ssp->gr[SSP_PM0].h // 8 -#define rPM1 ssp->gr[SSP_PM1].h -#define rPM2 ssp->gr[SSP_PM2].h -#define rXST ssp->gr[SSP_XST].h -#define rPM4 ssp->gr[SSP_PM4].h // 12 -// 13 -#define rPMC ssp->gr[SSP_PMC] // will keep addr in .l, mode in .h -#define rAL ssp->gr[SSP_A].l - -#define rA32 ssp->gr[SSP_A].v -#define rIJ ssp->r - -#define IJind (((op>>6)&4)|(op&3)) - -#define GET_PC() (PC - (unsigned short *)svp->iram_rom) -#define GET_PPC_OFFS() ((unsigned char *)PC - svp->iram_rom - 2) -#define SET_PC(d) PC = (unsigned short *)svp->iram_rom + d - -#define REG_READ(r) (((r) <= 4) ? ssp->gr[r].h : read_handlers[r]()) -#define REG_WRITE(r,d) { \ - int r1 = r; \ - if (r1 >= 4) write_handlers[r1](d); \ - else if (r1 > 0) ssp->gr[r1].h = d; \ -} - -// flags -#define SSP_FLAG_L (1<<0xc) -#define SSP_FLAG_Z (1<<0xd) -#define SSP_FLAG_V (1<<0xe) -#define SSP_FLAG_N (1<<0xf) - -// update ZN according to 32bit ACC. -#define UPD_ACC_ZN \ - rST &= ~(SSP_FLAG_Z|SSP_FLAG_N); \ - if (!rA32) rST |= SSP_FLAG_Z; \ - else rST |= (rA32>>16)&SSP_FLAG_N; - -// it seems SVP code never checks for L and OV, so we leave them out. -// rST |= (t>>4)&SSP_FLAG_L; -#define UPD_LZVN \ - rST &= ~(SSP_FLAG_L|SSP_FLAG_Z|SSP_FLAG_V|SSP_FLAG_N); \ - if (!rA32) rST |= SSP_FLAG_Z; \ - else rST |= (rA32>>16)&SSP_FLAG_N; - -// standard cond processing. -// again, only Z and N is checked, as VR doesn't seem to use any other conds. -#define COND_CHECK \ - switch (op&0xf0) { \ - case 0x00: cond = 1; break; /* always true */ \ - case 0x50: cond = !((rST ^ (op<<5)) & SSP_FLAG_Z); break; /* Z matches f(?) bit */ \ - case 0x70: cond = !((rST ^ (op<<7)) & SSP_FLAG_N); break; /* N matches f(?) bit */ \ - default:elprintf(EL_SVP|EL_ANOMALY, "ssp FIXME: unimplemented cond @ %04x", GET_PPC_OFFS()); break; \ - } - -// ops with accumulator. -// how is low word really affected by these? -// nearly sure 'ld A' doesn't affect flags -#define OP_LDA(x) \ - ssp->gr[SSP_A].h = x - -#define OP_LDA32(x) \ - rA32 = x - -#define OP_SUBA(x) { \ - rA32 -= (x) << 16; \ - UPD_LZVN \ -} - -#define OP_SUBA32(x) { \ - rA32 -= (x); \ - UPD_LZVN \ -} - -#define OP_CMPA(x) { \ - u32 t = rA32 - ((x) << 16); \ - rST &= ~(SSP_FLAG_L|SSP_FLAG_Z|SSP_FLAG_V|SSP_FLAG_N); \ - if (!t) rST |= SSP_FLAG_Z; \ - else rST |= (t>>16)&SSP_FLAG_N; \ -} - -#define OP_CMPA32(x) { \ - u32 t = rA32 - (x); \ - rST &= ~(SSP_FLAG_L|SSP_FLAG_Z|SSP_FLAG_V|SSP_FLAG_N); \ - if (!t) rST |= SSP_FLAG_Z; \ - else rST |= (t>>16)&SSP_FLAG_N; \ -} - -#define OP_ADDA(x) { \ - rA32 += (x) << 16; \ - UPD_LZVN \ -} - -#define OP_ADDA32(x) { \ - rA32 += (x); \ - UPD_LZVN \ -} - -#define OP_ANDA(x) \ - rA32 &= (x) << 16; \ - UPD_ACC_ZN - -#define OP_ANDA32(x) \ - rA32 &= (x); \ - UPD_ACC_ZN - -#define OP_ORA(x) \ - rA32 |= (x) << 16; \ - UPD_ACC_ZN - -#define OP_ORA32(x) \ - rA32 |= (x); \ - UPD_ACC_ZN - -#define OP_EORA(x) \ - rA32 ^= (x) << 16; \ - UPD_ACC_ZN - -#define OP_EORA32(x) \ - rA32 ^= (x); \ - UPD_ACC_ZN - - -#define OP_CHECK32(OP) { \ - if ((op & 0x0f) == SSP_P) { /* A <- P */ \ - read_P(); /* update P */ \ - OP(rP.v); \ - break; \ - } \ - if ((op & 0x0f) == SSP_A) { /* A <- A */ \ - OP(rA32); \ - break; \ - } \ -} - - -#ifdef DO_CHECKS -#define CHECK_IMM16() if (op&0x1ff) elprintf(EL_ANOMALY, "imm bits! %04x @ %04x", op, GET_PPC_OFFS()) -#define CHECK_B_SET() if (op&0x100) elprintf(EL_ANOMALY, "b set! %04x @ %04x", op, GET_PPC_OFFS()) -#define CHECK_B_CLEAR() if (!(op&0x100)) elprintf(EL_ANOMALY, "b clear! %04x @ %04x", op, GET_PPC_OFFS()) -#define CHECK_MOD() if (op&0x00c) elprintf(EL_ANOMALY, "mod bits! %04x @ %04x", op, GET_PPC_OFFS()) -#define CHECK_10f() if (op&0x10f) elprintf(EL_ANOMALY, "bits 10f! %04x @ %04x", op, GET_PPC_OFFS()) -#define CHECK_008() if (op&0x008) elprintf(EL_ANOMALY, "bits 008! %04x @ %04x", op, GET_PPC_OFFS()) -#define CHECK_00f() if (op&0x00f) elprintf(EL_ANOMALY, "bits 00f! %04x @ %04x", op, GET_PPC_OFFS()) -#define CHECK_0f0() if (op&0x0f0) elprintf(EL_ANOMALY, "bits 0f0! %04x @ %04x", op, GET_PPC_OFFS()) -#define CHECK_1f0() if (op&0x1f0) elprintf(EL_ANOMALY, "bits 1f0! %04x @ %04x", op, GET_PPC_OFFS()) -#define CHECK_RPL() if (rST&7) elprintf(EL_ANOMALY, "unhandled RPL! %04x @ %04x", op, GET_PPC_OFFS()) -#define CHECK_ST(d) if((rST^d)&0xf98)elprintf(EL_ANOMALY, "ssp FIXME ST %04x -> %04x @ %04x", rST, d, GET_PPC_OFFS()) -#else -#define CHECK_IMM16() -#define CHECK_B_SET() -#define CHECK_B_CLEAR() -#define CHECK_MOD() -#define CHECK_10f() -#define CHECK_008() -#define CHECK_00f() -#define CHECK_0f0() -#define CHECK_1f0() -#define CHECK_RPL() -#define CHECK_ST(d) -#endif - -ssp1601_t *ssp; -static unsigned short *PC; -static int g_cycles; - -#ifdef USE_DEBUGGER -static int running = 0; -static int last_iram = 0; -#endif - -// ----------------------------------------------------- -// register i/o handlers - -// 0-4, 13 -static u32 read_unknown(void) -{ - elprintf(EL_ANOMALY|EL_SVP, "ssp FIXME: unknown read @ %04x", GET_PPC_OFFS()); - return 0; -} - -static void write_unknown(u32 d) -{ - elprintf(EL_ANOMALY|EL_SVP, "ssp FIXME: unknown write @ %04x", GET_PPC_OFFS()); -} - -// 4 -static void write_ST(u32 d) -{ - CHECK_ST(d); - rST = d; -} - -// 5 -static u32 read_STACK(void) -{ - --rSTACK; - if ((short)rSTACK < 0) { - rSTACK = 5; - elprintf(EL_ANOMALY|EL_SVP, "ssp FIXME: stack underflow! (%i) @ %04x", rSTACK, GET_PPC_OFFS()); - } - return ssp->stack[rSTACK]; -} - -static void write_STACK(u32 d) -{ - if (rSTACK >= 6) { - elprintf(EL_ANOMALY|EL_SVP, "ssp FIXME: stack overflow! (%i) @ %04x", rSTACK, GET_PPC_OFFS()); - rSTACK = 0; - } - ssp->stack[rSTACK++] = d; -} - -// 6 -static u32 read_PC(void) -{ - return GET_PC(); -} - -static void write_PC(u32 d) -{ - SET_PC(d); - g_cycles--; -} - -// 7 -static u32 read_P(void) -{ - int m1 = (signed short)rX; - int m2 = (signed short)rY; - rP.v = (m1 * m2 * 2); - return rP.h; -} - -// ----------------------------------------------------- - -static int get_inc(int mode) -{ - int inc = (mode >> 11) & 7; - if (inc != 0) { - if (inc != 7) inc--; - inc = 1 << inc; // 0 1 2 4 8 16 32 128 - if (mode & 0x8000) inc = -inc; // decrement mode - } - return inc; -} - -#define overwrite_write(dst, d) \ -{ \ - if (d & 0xf000) { dst &= ~0xf000; dst |= d & 0xf000; } \ - if (d & 0x0f00) { dst &= ~0x0f00; dst |= d & 0x0f00; } \ - if (d & 0x00f0) { dst &= ~0x00f0; dst |= d & 0x00f0; } \ - if (d & 0x000f) { dst &= ~0x000f; dst |= d & 0x000f; } \ -} - -static u32 pm_io(int reg, int write, u32 d) -{ - if (ssp->emu_status & SSP_PMC_SET) - { - // this MUST be blind r or w - if ((*(PC-1) & 0xff0f) && (*(PC-1) & 0xfff0)) { - elprintf(EL_SVP|EL_ANOMALY, "ssp FIXME: tried to set PM%i (%c) with non-blind i/o %08x @ %04x", - reg, write ? 'w' : 'r', rPMC.v, GET_PPC_OFFS()); - ssp->emu_status &= ~SSP_PMC_SET; - return 0; - } - elprintf(EL_SVP, "PM%i (%c) set to %08x @ %04x", reg, write ? 'w' : 'r', rPMC.v, GET_PPC_OFFS()); - ssp->pmac_read[write ? reg + 6 : reg] = rPMC.v; - ssp->emu_status &= ~SSP_PMC_SET; - if ((rPMC.v & 0x7fffff) == 0x1c8000 || (rPMC.v & 0x7fffff) == 0x1c8240) { - elprintf(EL_SVP, "ssp IRAM copy from %06x to %04x", (ssp->RAM1[0]-1)<<1, (rPMC.v&0x7fff)<<1); -#ifdef USE_DEBUGGER - last_iram = (ssp->RAM1[0]-1)<<1; -#endif - } - return 0; - } - - // just in case - if (ssp->emu_status & SSP_PMC_HAVE_ADDR) { - elprintf(EL_SVP|EL_ANOMALY, "ssp FIXME: PM%i (%c) with only addr set @ %04x", - reg, write ? 'w' : 'r', GET_PPC_OFFS()); - ssp->emu_status &= ~SSP_PMC_HAVE_ADDR; - } - - if (reg == 4 || (rST & 0x60)) - { - #define CADDR ((((mode<<16)&0x7f0000)|addr)<<1) - unsigned short *dram = (unsigned short *)svp->dram; - if (write) - { - int mode = ssp->pmac_write[reg]>>16; - int addr = ssp->pmac_write[reg]&0xffff; - if ((mode & 0xb800) == 0xb800) - elprintf(EL_SVP|EL_ANOMALY, "ssp FIXME: mode %04x", mode); - if ((mode & 0x43ff) == 0x0018) // DRAM - { - int inc = get_inc(mode); - elprintf(EL_SVP, "ssp PM%i DRAM w [%06x] %04x (inc %i, ovrw %i)", - reg, CADDR, d, inc, (mode>>10)&1); - if (mode & 0x0400) { - overwrite_write(dram[addr], d); - } else dram[addr] = d; - ssp->pmac_write[reg] += inc; - } - else if ((mode & 0xfbff) == 0x4018) // DRAM, cell inc - { - elprintf(EL_SVP, "ssp PM%i DRAM w [%06x] %04x (cell inc, ovrw %i) @ %04x", - reg, CADDR, d, (mode>>10)&1, GET_PPC_OFFS()); - if (mode & 0x0400) { - overwrite_write(dram[addr], d); - } else dram[addr] = d; - ssp->pmac_write[reg] += (addr&1) ? 31 : 1; - } - else if ((mode & 0x47ff) == 0x001c) // IRAM - { - int inc = get_inc(mode); - if ((addr&0xfc00) != 0x8000) - elprintf(EL_SVP|EL_ANOMALY, "ssp FIXME: invalid IRAM addr: %04x", addr<<1); - elprintf(EL_SVP, "ssp IRAM w [%06x] %04x (inc %i)", (addr<<1)&0x7ff, d, inc); - ((unsigned short *)svp->iram_rom)[addr&0x3ff] = d; - ssp->pmac_write[reg] += inc; - } - else - { - elprintf(EL_SVP|EL_ANOMALY, "ssp FIXME: PM%i unhandled write mode %04x, [%06x] %04x @ %04x", - reg, mode, CADDR, d, GET_PPC_OFFS()); - } - } - else - { - int mode = ssp->pmac_read[reg]>>16; - int addr = ssp->pmac_read[reg]&0xffff; - if ((mode & 0xfff0) == 0x0800) // ROM, inc 1, verified to be correct - { - elprintf(EL_SVP, "ssp ROM r [%06x] %04x", CADDR, - ((unsigned short *)Pico_rom)[addr|((mode&0xf)<<16)]); - ssp->pmac_read[reg] += 1; - d = ((unsigned short *)Pico_rom)[addr|((mode&0xf)<<16)]; - } - else if ((mode & 0x47ff) == 0x0018) // DRAM - { - int inc = get_inc(mode); - elprintf(EL_SVP, "ssp PM%i DRAM r [%06x] %04x (inc %i)", reg, CADDR, dram[addr]); - d = dram[addr]; - ssp->pmac_read[reg] += inc; - } - else - { - elprintf(EL_SVP|EL_ANOMALY, "ssp FIXME: PM%i unhandled read mode %04x, [%06x] @ %04x", - reg, mode, CADDR, GET_PPC_OFFS()); - d = 0; - } - } - - // PMC value corresponds to last PMR accessed (not sure). - rPMC.v = ssp->pmac_read[write ? reg + 6 : reg]; - - return d; - } - - return (u32)-1; -} - -// 8 -static u32 read_PM0(void) -{ - u32 d = pm_io(0, 0, 0); - if (d != (u32)-1) return d; - elprintf(EL_SVP, "PM0 raw r %04x @ %04x", rPM0, GET_PPC_OFFS()); - d = rPM0; - if (!(d & 2) && (GET_PPC_OFFS() == 0x800 || GET_PPC_OFFS() == 0x1851E)) { - ssp->emu_status |= SSP_WAIT_PM0; elprintf(EL_SVP, "det TIGHT loop: PM0"); - } - rPM0 &= ~2; // ? - return d; -} - -static void write_PM0(u32 d) -{ - u32 r = pm_io(0, 1, d); - if (r != (u32)-1) return; - elprintf(EL_SVP, "PM0 raw w %04x @ %04x", d, GET_PPC_OFFS()); - rPM0 = d; -} - -// 9 -static u32 read_PM1(void) -{ - u32 d = pm_io(1, 0, 0); - if (d != (u32)-1) return d; - // can be removed? - elprintf(EL_SVP|EL_ANOMALY, "PM1 raw r %04x @ %04x", rPM1, GET_PPC_OFFS()); - return rPM1; -} - -static void write_PM1(u32 d) -{ - u32 r = pm_io(1, 1, d); - if (r != (u32)-1) return; - // can be removed? - elprintf(EL_SVP|EL_ANOMALY, "PM1 raw w %04x @ %04x", d, GET_PPC_OFFS()); - rPM1 = d; -} - -// 10 -static u32 read_PM2(void) -{ - u32 d = pm_io(2, 0, 0); - if (d != (u32)-1) return d; - // can be removed? - elprintf(EL_SVP|EL_ANOMALY, "PM2 raw r %04x @ %04x", rPM2, GET_PPC_OFFS()); - return rPM2; -} - -static void write_PM2(u32 d) -{ - u32 r = pm_io(2, 1, d); - if (r != (u32)-1) return; - // can be removed? - elprintf(EL_SVP|EL_ANOMALY, "PM2 raw w %04x @ %04x", d, GET_PPC_OFFS()); - rPM2 = d; -} - -// 11 -static u32 read_XST(void) -{ - // can be removed? - u32 d = pm_io(3, 0, 0); - if (d != (u32)-1) return d; - - elprintf(EL_SVP, "XST raw r %04x @ %04x", rXST, GET_PPC_OFFS()); - return rXST; -} - -static void write_XST(u32 d) -{ - // can be removed? - u32 r = pm_io(3, 1, d); - if (r != (u32)-1) return; - - elprintf(EL_SVP, "XST raw w %04x @ %04x", d, GET_PPC_OFFS()); - rPM0 |= 1; - rXST = d; -} - -// 12 -static u32 read_PM4(void) -{ - u32 d = pm_io(4, 0, 0); - - if (d == 0) { - switch (GET_PPC_OFFS()) { - case 0x0854: ssp->emu_status |= SSP_WAIT_30FE08; elprintf(EL_SVP, "det TIGHT loop: [30fe08]"); break; - case 0x4f12: ssp->emu_status |= SSP_WAIT_30FE06; elprintf(EL_SVP, "det TIGHT loop: [30fe06]"); break; - } - } - - if (d != (u32)-1) return d; - // can be removed? - elprintf(EL_SVP|EL_ANOMALY, "PM4 raw r %04x @ %04x", rPM4, GET_PPC_OFFS()); - return rPM4; -} - -static void write_PM4(u32 d) -{ - u32 r = pm_io(4, 1, d); - if (r != (u32)-1) return; - // can be removed? - elprintf(EL_SVP|EL_ANOMALY, "PM4 raw w %04x @ %04x", d, GET_PPC_OFFS()); - rPM4 = d; -} - -// 14 -static u32 read_PMC(void) -{ - elprintf(EL_SVP, "PMC r a %04x (st %c) @ %04x", rPMC.l, - (ssp->emu_status & SSP_PMC_HAVE_ADDR) ? 'm' : 'a', GET_PPC_OFFS()); - if (ssp->emu_status & SSP_PMC_HAVE_ADDR) { - //if (ssp->emu_status & SSP_PMC_SET) - // elprintf(EL_ANOMALY|EL_SVP, "prev PMC not used @ %04x", GET_PPC_OFFS()); - ssp->emu_status |= SSP_PMC_SET; - ssp->emu_status &= ~SSP_PMC_HAVE_ADDR; - return ((rPMC.l << 4) & 0xfff0) | ((rPMC.l >> 4) & 0xf); - } else { - ssp->emu_status |= SSP_PMC_HAVE_ADDR; - return rPMC.l; - } -} - -static void write_PMC(u32 d) -{ - if (ssp->emu_status & SSP_PMC_HAVE_ADDR) { - //if (ssp->emu_status & SSP_PMC_SET) - // elprintf(EL_ANOMALY|EL_SVP, "prev PMC not used @ %04x", GET_PPC_OFFS()); - ssp->emu_status |= SSP_PMC_SET; - ssp->emu_status &= ~SSP_PMC_HAVE_ADDR; - rPMC.h = d; - elprintf(EL_SVP, "PMC w m %04x @ %04x", rPMC.h, GET_PPC_OFFS()); - } else { - ssp->emu_status |= SSP_PMC_HAVE_ADDR; - rPMC.l = d; - elprintf(EL_SVP, "PMC w a %04x @ %04x", rPMC.l, GET_PPC_OFFS()); - } -} - -// 15 -static u32 read_AL(void) -{ - if (*(PC-1) == 0x000f) - elprintf(EL_SVP, "ssp dummy PM assign %08x @ %04x", rPMC.v, GET_PPC_OFFS()); - ssp->emu_status &= ~(SSP_PMC_SET|SSP_PMC_HAVE_ADDR); // ? - return rAL; -} - -static void write_AL(u32 d) -{ - rAL = d; -} - - -typedef u32 (*read_func_t)(void); -typedef void (*write_func_t)(u32 d); - -static read_func_t read_handlers[16] = -{ - read_unknown, read_unknown, read_unknown, read_unknown, // -, X, Y, A - read_unknown, // 4 ST - read_STACK, - read_PC, - read_P, - read_PM0, // 8 - read_PM1, - read_PM2, - read_XST, - read_PM4, // 12 - read_unknown, // 13 gr13 - read_PMC, - read_AL -}; - -static write_func_t write_handlers[16] = -{ - write_unknown, write_unknown, write_unknown, write_unknown, // -, X, Y, A -// write_unknown, // 4 ST - write_ST, // 4 ST (debug hook) - write_STACK, - write_PC, - write_unknown, // 7 P - write_PM0, // 8 - write_PM1, - write_PM2, - write_XST, - write_PM4, // 12 - write_unknown, // 13 gr13 - write_PMC, - write_AL -}; - -// ----------------------------------------------------- -// pointer register handlers - -// -#define ptr1_read(op) ptr1_read_(op&3,(op>>6)&4,(op<<1)&0x18) - -static u32 ptr1_read_(int ri, int isj2, int modi3) -{ - //int t = (op&3) | ((op>>6)&4) | ((op<<1)&0x18); - u32 mask, add = 0, t = ri | isj2 | modi3; - unsigned char *rp = NULL; - switch (t) - { - // mod=0 (00) - case 0x00: - case 0x01: - case 0x02: return ssp->RAM0[ssp->r0[t&3]]; - case 0x03: return ssp->RAM0[0]; - case 0x04: - case 0x05: - case 0x06: return ssp->RAM1[ssp->r1[t&3]]; - case 0x07: return ssp->RAM1[0]; - // mod=1 (01), "+!" - case 0x08: - case 0x09: - case 0x0a: return ssp->RAM0[ssp->r0[t&3]++]; - case 0x0b: return ssp->RAM0[1]; - case 0x0c: - case 0x0d: - case 0x0e: return ssp->RAM1[ssp->r1[t&3]++]; - case 0x0f: return ssp->RAM1[1]; - // mod=2 (10), "-" - case 0x10: - case 0x11: - case 0x12: rp = &ssp->r0[t&3]; t = ssp->RAM0[*rp]; - if (!(rST&7)) { (*rp)--; return t; } - add = -1; goto modulo; - case 0x13: return ssp->RAM0[2]; - case 0x14: - case 0x15: - case 0x16: rp = &ssp->r1[t&3]; t = ssp->RAM1[*rp]; - if (!(rST&7)) { (*rp)--; return t; } - add = -1; goto modulo; - case 0x17: return ssp->RAM1[2]; - // mod=3 (11), "+" - case 0x18: - case 0x19: - case 0x1a: rp = &ssp->r0[t&3]; t = ssp->RAM0[*rp]; - if (!(rST&7)) { (*rp)++; return t; } - add = 1; goto modulo; - case 0x1b: return ssp->RAM0[3]; - case 0x1c: - case 0x1d: - case 0x1e: rp = &ssp->r1[t&3]; t = ssp->RAM1[*rp]; - if (!(rST&7)) { (*rp)++; return t; } - add = 1; goto modulo; - case 0x1f: return ssp->RAM1[3]; - } - - return 0; - -modulo: - mask = (1 << (rST&7)) - 1; - *rp = (*rp & ~mask) | ((*rp + add) & mask); - return t; -} - -static void ptr1_write(int op, u32 d) -{ - int t = (op&3) | ((op>>6)&4) | ((op<<1)&0x18); - switch (t) - { - // mod=0 (00) - case 0x00: - case 0x01: - case 0x02: ssp->RAM0[ssp->r0[t&3]] = d; return; - case 0x03: ssp->RAM0[0] = d; return; - case 0x04: - case 0x05: - case 0x06: ssp->RAM1[ssp->r1[t&3]] = d; return; - case 0x07: ssp->RAM1[0] = d; return; - // mod=1 (01), "+!" - // mod=3, "+" - case 0x08: - case 0x09: - case 0x0a: ssp->RAM0[ssp->r0[t&3]++] = d; return; - case 0x0b: ssp->RAM0[1] = d; return; - case 0x0c: - case 0x0d: - case 0x0e: ssp->RAM1[ssp->r1[t&3]++] = d; return; - case 0x0f: ssp->RAM1[1] = d; return; - // mod=2 (10), "-" - case 0x10: - case 0x11: - case 0x12: ssp->RAM0[ssp->r0[t&3]--] = d; CHECK_RPL(); return; - case 0x13: ssp->RAM0[2] = d; return; - case 0x14: - case 0x15: - case 0x16: ssp->RAM1[ssp->r1[t&3]--] = d; CHECK_RPL(); return; - case 0x17: ssp->RAM1[2] = d; return; - // mod=3 (11), "+" - case 0x18: - case 0x19: - case 0x1a: ssp->RAM0[ssp->r0[t&3]++] = d; CHECK_RPL(); return; - case 0x1b: ssp->RAM0[3] = d; return; - case 0x1c: - case 0x1d: - case 0x1e: ssp->RAM1[ssp->r1[t&3]++] = d; CHECK_RPL(); return; - case 0x1f: ssp->RAM1[3] = d; return; - } -} - -static u32 ptr2_read(int op) -{ - int mv = 0, t = (op&3) | ((op>>6)&4) | ((op<<1)&0x18); - switch (t) - { - // mod=0 (00) - case 0x00: - case 0x01: - case 0x02: mv = ssp->RAM0[ssp->r0[t&3]]++; break; - case 0x03: mv = ssp->RAM0[0]++; break; - case 0x04: - case 0x05: - case 0x06: mv = ssp->RAM1[ssp->r1[t&3]]++; break; - case 0x07: mv = ssp->RAM1[0]++; break; - // mod=1 (01) - case 0x0b: mv = ssp->RAM0[1]++; break; - case 0x0f: mv = ssp->RAM1[1]++; break; - // mod=2 (10) - case 0x13: mv = ssp->RAM0[2]++; break; - case 0x17: mv = ssp->RAM1[2]++; break; - // mod=3 (11) - case 0x1b: mv = ssp->RAM0[3]++; break; - case 0x1f: mv = ssp->RAM1[3]++; break; - default: elprintf(EL_SVP|EL_ANOMALY, "ssp FIXME: invalid mod in ((rX))? @ %04x", GET_PPC_OFFS()); - return 0; - } - - return ((unsigned short *)svp->iram_rom)[mv]; -} - - -// ----------------------------------------------------- - -#if defined(USE_DEBUGGER) -static void debug_dump2file(const char *fname, void *mem, int len) -{ - FILE *f = fopen(fname, "wb"); - unsigned short *p = mem; - int i; - if (f) { - for (i = 0; i < len/2; i++) p[i] = (p[i]<<8) | (p[i]>>8); - fwrite(mem, 1, len, f); - fclose(f); - for (i = 0; i < len/2; i++) p[i] = (p[i]<<8) | (p[i]>>8); - printf("dumped to %s\n", fname); - } - else - printf("dump failed\n"); -} -#endif - -#ifdef USE_DEBUGGER -static void debug_dump(void) -{ - printf("GR0: %04x X: %04x Y: %04x A: %08x\n", ssp->gr[SSP_GR0].h, rX, rY, ssp->gr[SSP_A].v); - printf("PC: %04x (%04x) P: %08x\n", GET_PC(), GET_PC() << 1, rP.v); - printf("PM0: %04x PM1: %04x PM2: %04x\n", rPM0, rPM1, rPM2); - printf("XST: %04x PM4: %04x PMC: %08x\n", rXST, rPM4, rPMC.v); - printf(" ST: %04x %c%c%c%c, GP0_0 %i, GP0_1 %i\n", rST, rST&SSP_FLAG_N?'N':'n', rST&SSP_FLAG_V?'V':'v', - rST&SSP_FLAG_Z?'Z':'z', rST&SSP_FLAG_L?'L':'l', (rST>>5)&1, (rST>>6)&1); - printf("STACK: %i %04x %04x %04x %04x %04x %04x\n", rSTACK, ssp->stack[0], ssp->stack[1], - ssp->stack[2], ssp->stack[3], ssp->stack[4], ssp->stack[5]); - printf("r0-r2: %02x %02x %02x r4-r6: %02x %02x %02x\n", rIJ[0], rIJ[1], rIJ[2], rIJ[4], rIJ[5], rIJ[6]); - elprintf(EL_SVP, "cycles: %i, emu_status: %x", g_cycles, ssp->emu_status); -} - -static void debug_dump_mem(void) -{ - int h, i; - printf("RAM0\n"); - for (h = 0; h < 32; h++) - { - if (h == 16) printf("RAM1\n"); - printf("%03x:", h*16); - for (i = 0; i < 16; i++) - printf(" %04x", ssp->RAM[h*16+i]); - printf("\n"); - } -} - -static int bpts[10] = { 0, }; - -static void debug(unsigned int pc, unsigned int op) -{ - static char buffo[64] = {0,}; - char buff[64] = {0,}; - int i; - - if (running) { - for (i = 0; i < 10; i++) - if (pc != 0 && bpts[i] == pc) { - printf("breakpoint %i\n", i); - running = 0; - break; - } - } - if (running) return; - - printf("%04x (%02x) @ %04x\n", op, op >> 9, pc<<1); - - while (1) - { - printf("dbg> "); - fflush(stdout); - fgets(buff, sizeof(buff), stdin); - if (buff[0] == '\n') strcpy(buff, buffo); - else strcpy(buffo, buff); - - switch (buff[0]) { - case 0: exit(0); - case 'c': - case 'r': running = 1; return; - case 's': - case 'n': return; - case 'x': debug_dump(); break; - case 'm': debug_dump_mem(); break; - case 'b': { - char *baddr = buff + 2; - i = 0; - if (buff[3] == ' ') { i = buff[2] - '0'; baddr = buff + 4; } - bpts[i] = strtol(baddr, NULL, 16) >> 1; - printf("breakpoint %i set @ %04x\n", i, bpts[i]<<1); - break; - } - case 'd': - sprintf(buff, "iramrom_%04x.bin", last_iram); - debug_dump2file(buff, svp->iram_rom, sizeof(svp->iram_rom)); - debug_dump2file("dram.bin", svp->dram, sizeof(svp->dram)); - break; - default: printf("unknown command\n"); break; - } - } -} -#endif // USE_DEBUGGER - - -void ssp1601_reset(ssp1601_t *l_ssp) -{ - ssp = l_ssp; - ssp->emu_status = 0; - ssp->gr[SSP_GR0].v = 0xffff0000; - rPC = 0x400; - rSTACK = 0; // ? using ascending stack - rST = 0; -} - - -void ssp1601_run(int cycles) -{ - SET_PC(rPC); - - g_cycles = cycles; - - while (g_cycles > 0 && !(ssp->emu_status & SSP_WAIT_MASK)) - { - int op; - u32 tmpv; - - op = *PC++; -#ifdef USE_DEBUGGER - debug(GET_PC()-1, op); -#endif - switch (op >> 9) - { - // ld d, s - case 0x00: - CHECK_B_SET(); - if (op == 0) break; // nop - if (op == ((SSP_A<<4)|SSP_P)) { // A <- P - read_P(); // update P - rA32 = rP.v; - } - else - { - tmpv = REG_READ(op & 0x0f); - REG_WRITE((op & 0xf0) >> 4, tmpv); - } - break; - - // ld d, (ri) - case 0x01: tmpv = ptr1_read(op); REG_WRITE((op & 0xf0) >> 4, tmpv); break; - - // ld (ri), s - case 0x02: tmpv = REG_READ((op & 0xf0) >> 4); ptr1_write(op, tmpv); break; - - // ldi d, imm - case 0x04: CHECK_10f(); tmpv = *PC++; REG_WRITE((op & 0xf0) >> 4, tmpv); g_cycles--; break; - - // ld d, ((ri)) - case 0x05: CHECK_MOD(); tmpv = ptr2_read(op); REG_WRITE((op & 0xf0) >> 4, tmpv); g_cycles -= 2; break; - - // ldi (ri), imm - case 0x06: tmpv = *PC++; ptr1_write(op, tmpv); g_cycles--; break; - - // ld adr, a - case 0x07: ssp->RAM[op & 0x1ff] = rA; break; - - // ld d, ri - case 0x09: CHECK_MOD(); tmpv = rIJ[(op&3)|((op>>6)&4)]; REG_WRITE((op & 0xf0) >> 4, tmpv); break; - - // ld ri, s - case 0x0a: CHECK_MOD(); rIJ[(op&3)|((op>>6)&4)] = REG_READ((op & 0xf0) >> 4); break; - - // ldi ri, simm - case 0x0c: - case 0x0d: - case 0x0e: - case 0x0f: rIJ[(op>>8)&7] = op; break; - - // call cond, addr - case 0x24: { - int cond = 0; - CHECK_00f(); - COND_CHECK - if (cond) { int new_PC = *PC++; write_STACK(GET_PC()); SET_PC(new_PC); } - else PC++; - g_cycles--; // always 2 cycles - break; - } - - // ld d, (a) - case 0x25: - CHECK_10f(); - tmpv = ((unsigned short *)svp->iram_rom)[rA]; - REG_WRITE((op & 0xf0) >> 4, tmpv); - g_cycles -= 2; // 3 cycles total - break; - - // bra cond, addr - case 0x26: { - int cond = 0; - CHECK_00f(); - COND_CHECK - if (cond) { int new_PC = *PC++; SET_PC(new_PC); } - else PC++; - g_cycles--; - break; - } - - // mod cond, op - case 0x48: { - int cond = 0; - CHECK_008(); - COND_CHECK - if (cond) { - switch (op & 7) { - case 2: rA32 = (signed int)rA32 >> 1; break; // shr (arithmetic) - case 3: rA32 <<= 1; break; // shl - case 6: rA32 = -(signed int)rA32; break; // neg - case 7: if ((int)rA32 < 0) rA32 = -(signed int)rA32; break; // abs - default: elprintf(EL_SVP|EL_ANOMALY, "ssp FIXME: unhandled mod %i @ %04x", - op&7, GET_PPC_OFFS()); - } - UPD_ACC_ZN - } - break; - } - - // mpys? - case 0x1b: - CHECK_B_CLEAR(); - read_P(); // update P - rA32 -= rP.v; - UPD_ACC_ZN - rX = ptr1_read_(op&3, 0, (op<<1)&0x18); - rY = ptr1_read_((op>>4)&3, 4, (op>>3)&0x18); - break; - - // mpya (rj), (ri), b - case 0x4b: - CHECK_B_CLEAR(); - read_P(); // update P - rA32 += rP.v; - UPD_ACC_ZN - rX = ptr1_read_(op&3, 0, (op<<1)&0x18); - rY = ptr1_read_((op>>4)&3, 4, (op>>3)&0x18); - break; - - // mld (rj), (ri), b - case 0x5b: - CHECK_B_CLEAR(); - rA32 = 0; - rST &= 0x0fff; - rST |= SSP_FLAG_Z; - rX = ptr1_read_(op&3, 0, (op<<1)&0x18); - rY = ptr1_read_((op>>4)&3, 4, (op>>3)&0x18); - break; - - // OP a, s - case 0x10: CHECK_1f0(); OP_CHECK32(OP_SUBA32); tmpv = REG_READ(op & 0x0f); OP_SUBA(tmpv); break; - case 0x30: CHECK_1f0(); OP_CHECK32(OP_CMPA32); tmpv = REG_READ(op & 0x0f); OP_CMPA(tmpv); break; - case 0x40: CHECK_1f0(); OP_CHECK32(OP_ADDA32); tmpv = REG_READ(op & 0x0f); OP_ADDA(tmpv); break; - case 0x50: CHECK_1f0(); OP_CHECK32(OP_ANDA32); tmpv = REG_READ(op & 0x0f); OP_ANDA(tmpv); break; - case 0x60: CHECK_1f0(); OP_CHECK32(OP_ORA32 ); tmpv = REG_READ(op & 0x0f); OP_ORA (tmpv); break; - case 0x70: CHECK_1f0(); OP_CHECK32(OP_EORA32); tmpv = REG_READ(op & 0x0f); OP_EORA(tmpv); break; - - // OP a, (ri) - case 0x11: CHECK_0f0(); tmpv = ptr1_read(op); OP_SUBA(tmpv); break; - case 0x31: CHECK_0f0(); tmpv = ptr1_read(op); OP_CMPA(tmpv); break; - case 0x41: CHECK_0f0(); tmpv = ptr1_read(op); OP_ADDA(tmpv); break; - case 0x51: CHECK_0f0(); tmpv = ptr1_read(op); OP_ANDA(tmpv); break; - case 0x61: CHECK_0f0(); tmpv = ptr1_read(op); OP_ORA (tmpv); break; - case 0x71: CHECK_0f0(); tmpv = ptr1_read(op); OP_EORA(tmpv); break; - - // OP a, adr - case 0x03: tmpv = ssp->RAM[op & 0x1ff]; OP_LDA (tmpv); break; - case 0x13: tmpv = ssp->RAM[op & 0x1ff]; OP_SUBA(tmpv); break; - case 0x33: tmpv = ssp->RAM[op & 0x1ff]; OP_CMPA(tmpv); break; - case 0x43: tmpv = ssp->RAM[op & 0x1ff]; OP_ADDA(tmpv); break; - case 0x53: tmpv = ssp->RAM[op & 0x1ff]; OP_ANDA(tmpv); break; - case 0x63: tmpv = ssp->RAM[op & 0x1ff]; OP_ORA (tmpv); break; - case 0x73: tmpv = ssp->RAM[op & 0x1ff]; OP_EORA(tmpv); break; - - // OP a, imm - case 0x14: CHECK_IMM16(); tmpv = *PC++; OP_SUBA(tmpv); g_cycles--; break; - case 0x34: CHECK_IMM16(); tmpv = *PC++; OP_CMPA(tmpv); g_cycles--; break; - case 0x44: CHECK_IMM16(); tmpv = *PC++; OP_ADDA(tmpv); g_cycles--; break; - case 0x54: CHECK_IMM16(); tmpv = *PC++; OP_ANDA(tmpv); g_cycles--; break; - case 0x64: CHECK_IMM16(); tmpv = *PC++; OP_ORA (tmpv); g_cycles--; break; - case 0x74: CHECK_IMM16(); tmpv = *PC++; OP_EORA(tmpv); g_cycles--; break; - - // OP a, ((ri)) - case 0x15: CHECK_MOD(); tmpv = ptr2_read(op); OP_SUBA(tmpv); g_cycles -= 2; break; - case 0x35: CHECK_MOD(); tmpv = ptr2_read(op); OP_CMPA(tmpv); g_cycles -= 2; break; - case 0x45: CHECK_MOD(); tmpv = ptr2_read(op); OP_ADDA(tmpv); g_cycles -= 2; break; - case 0x55: CHECK_MOD(); tmpv = ptr2_read(op); OP_ANDA(tmpv); g_cycles -= 2; break; - case 0x65: CHECK_MOD(); tmpv = ptr2_read(op); OP_ORA (tmpv); g_cycles -= 2; break; - case 0x75: CHECK_MOD(); tmpv = ptr2_read(op); OP_EORA(tmpv); g_cycles -= 2; break; - - // OP a, ri - case 0x19: CHECK_MOD(); tmpv = rIJ[IJind]; OP_SUBA(tmpv); break; - case 0x39: CHECK_MOD(); tmpv = rIJ[IJind]; OP_CMPA(tmpv); break; - case 0x49: CHECK_MOD(); tmpv = rIJ[IJind]; OP_ADDA(tmpv); break; - case 0x59: CHECK_MOD(); tmpv = rIJ[IJind]; OP_ANDA(tmpv); break; - case 0x69: CHECK_MOD(); tmpv = rIJ[IJind]; OP_ORA (tmpv); break; - case 0x79: CHECK_MOD(); tmpv = rIJ[IJind]; OP_EORA(tmpv); break; - - // OP simm - case 0x1c: CHECK_B_SET(); OP_SUBA(op & 0xff); break; - case 0x3c: CHECK_B_SET(); OP_CMPA(op & 0xff); break; - case 0x4c: CHECK_B_SET(); OP_ADDA(op & 0xff); break; - case 0x5c: CHECK_B_SET(); OP_ANDA(op & 0xff); break; - case 0x6c: CHECK_B_SET(); OP_ORA (op & 0xff); break; - case 0x7c: CHECK_B_SET(); OP_EORA(op & 0xff); break; - - default: - elprintf(EL_ANOMALY|EL_SVP, "ssp FIXME unhandled op %04x @ %04x", op, GET_PPC_OFFS()); - break; - } - g_cycles--; - } - - rPC = GET_PC(); - read_P(); // update P -} - diff --git a/libmednahawk/src/md/cart/ssp16.h b/libmednahawk/src/md/cart/ssp16.h deleted file mode 100644 index bcda5a0d5f..0000000000 --- a/libmednahawk/src/md/cart/ssp16.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * basic, incomplete SSP160x (SSP1601?) interpreter - * - * Copyright (c) Gražvydas "notaz" Ignotas, 2008 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the organization nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -// register names -enum { - SSP_GR0, SSP_X, SSP_Y, SSP_A, - SSP_ST, SSP_STACK, SSP_PC, SSP_P, - SSP_PM0, SSP_PM1, SSP_PM2, SSP_XST, - SSP_PM4, SSP_gr13, SSP_PMC, SSP_AL -}; - -typedef union -{ - unsigned int v; - struct { - unsigned short l; - unsigned short h; - }; -} ssp_reg_t; - -typedef struct -{ - union { - unsigned short RAM[256*2]; // 000 2 internal RAM banks - struct { - unsigned short RAM0[256]; - unsigned short RAM1[256]; - }; - }; - ssp_reg_t gr[16]; // 400 general registers - union { - unsigned char r[8]; // 440 BANK pointers - struct { - unsigned char r0[4]; - unsigned char r1[4]; - }; - }; - unsigned short stack[6]; // 448 - unsigned int pmac_read[6]; // 454 read modes/addrs for PM0-PM5 - unsigned int pmac_write[6]; // 46c write ... - // - #define SSP_PMC_HAVE_ADDR 0x0001 // address written to PMAC, waiting for mode - #define SSP_PMC_SET 0x0002 // PMAC is set - #define SSP_WAIT_PM0 0x2000 // bit1 in PM0 - #define SSP_WAIT_30FE06 0x4000 // ssp tight loops on 30FE06 to become non-zero - #define SSP_WAIT_30FE08 0x8000 // same for 30FE06 - #define SSP_WAIT_MASK 0xe000 - unsigned int emu_status; // 484 - /* used by recompiler only: */ - struct { - unsigned int ptr_rom; // 488 - unsigned int ptr_iram_rom; // 48c - unsigned int ptr_dram; // 490 - unsigned int iram_dirty; // 494 - unsigned int iram_context; // 498 - unsigned int ptr_btable; // 49c - unsigned int ptr_btable_iram; // 4a0 - unsigned int tmp0; // 4a4 - unsigned int tmp1; // 4a8 - unsigned int tmp2; // 4ac - } drc; -} ssp1601_t; - - -void ssp1601_reset(ssp1601_t *ssp); -void ssp1601_run(int cycles); - -#ifdef __cplusplus -} -#endif - diff --git a/libmednahawk/src/md/cd/cd.cpp b/libmednahawk/src/md/cd/cd.cpp deleted file mode 100644 index b66803034e..0000000000 --- a/libmednahawk/src/md/cd/cd.cpp +++ /dev/null @@ -1,1057 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "../../cdrom/cdromif.h" -#include "../../general.h" -#include -#include "cd.h" -#include "pcm.h" -#include "cdc_cdd.h" -#include "interrupt.h" -#include "timer.h" - -#define READ8of16(value, a) ((value >> ((((a) & 1) ^ 1) << 3)) & 0xFF) - -c68k_struc Sub68K; -static int64 Sub68KCycleCounter; - -static uint8 *BIOS = NULL; // BIOS ROM, 128KiB -static uint8 *PRAM = NULL; // Program RAM, 512KiB -static uint8 *WordRAM = NULL; // Word RAM, 256KiB -static uint8 *BRAM = NULL; // 8KiB, Battery-backed RAM, accessible by sub CPU. -static bool SRES; // Sub CPU Reset. 0 = reset, 1 = run -static bool SBRQ; // Sub CPU Bus Req. - // Write: 0 = cancel, 1 = request - // Read: 0 = Sub CPU "operating"(?), 1 = acknowledge -static bool SACK; - -static uint8 LEDControl; -static bool InPeripheralReset; - -static uint8 MM_WP; // Write protect -static uint8 MM_BK; // R/W only on main. PRAM bank select for the main CPU -static uint8 MM_PM; // R/W only on sub. Priority mode. -static bool MM_MODE; // R/W on main and sub. 0 = 2M mode, 1 = 1M mode -enum -{ - MODE_2M = 0, - MODE_1M = 1, -}; - -static bool MM_DMNA; /* R/W on main, R only on sub. Dependent on MODE: - 2M Mode(0): If set, the main CPU can't access sub CPU word RAM at all. - 1M Mode(1): If set, sends a swap request to sub CPU. Returns 0 when the swap request is done. - */ -static bool MM_RET; /* R on main, R/W on sub. */ - -static uint16 StopWatchCounter; -static int32 StopWatchDiv; - -static uint16 COMM_FLAGS; - -// Both COMM_*[8] arrays are readable by both CPUs. CMD is only writeable by main, STATUS is only writeable by sub. -// Changed to uint8 arrays to simplify handling. -static uint8 COMM_CMD[8 * 2]; -static uint8 COMM_STATUS[8 * 2]; - -#define DEBUGMAIN(format, ...) { printf("MAIN " format, ## __VA_ARGS__); } -#define DEBUGSUB(format, ...) { printf("SUB " format, ## __VA_ARGS__); } - -#define UNDEFMAIN(format, ...) { printf("MAIN Undefined " format, ## __VA_ARGS__); } -#define UNDEFSUB(format, ...) { printf("SUB Undefined " format, ## __VA_ARGS__); } - -//#if 0 -//#define DEBUGMAIN(format, ...) { } -//#define DEBUGSUB(format, ...) - -//#define UNDEFMAIN(format, ...) { } -//#define UNDEFSUB(format, ...) -//#endif - -static void MDCD_MainWrite8(uint32 A, uint8 V) -{ - A &= 0xFFFFFF; - - if(A >= 0x40000) - DEBUGMAIN("Write8: %08x %02x\n", A, V); - - if(A >= 0x20000 && A <= 0x3FFFF) // Sub68k program RAM(banked) - { - if(!SBRQ) - { - UNDEFMAIN("Write8 to PRAM when BUSREQ is not held: %08x:%02x\n",A,V); - } - else - { - uint32 offset = (A & 0x1FFFF) | (MM_BK << 17); - - WRITE_BYTE_MSB(PRAM, offset, V); - } - } - else if(A >= 0x200000 && A <= 0x23FFFF) // Sub68k word RAM(switchable banking/mirroring) - { - if(MM_MODE == MODE_2M) - { - if(MM_DMNA) - { - UNDEFMAIN("Write to WordRAM when DMNA is set to 1: %08x %02x", A, V); - } - else - { - WRITE_BYTE_MSB(WordRAM, A & 0x3FFFF, V); - } - } - else - { - if(A <= 0x21FFFF) - { - uint32 offset = (A & 0x1FFFF) | (MM_RET << 17); - WRITE_BYTE_MSB(WordRAM, offset, V); - } - } - } - else if(A >= 0xa12000 && A <= 0xa120ff) - { - switch(A & 0xFF) - { - default: UNDEFMAIN("Unknown write: %08x %02x\n", A, V); - break; - case 0x00: if(V & 0x1) - MDCD_InterruptAssert(2, TRUE); - break; - case 0x01: - if(SRES != (V & 0x1)) - { - C68k_Reset(&Sub68K); - } - - SRES = V & 0x1; - SBRQ = V & 0x2; - SACK = SBRQ | (!SRES); - break; - - case 0x02: MM_WP = V; - break; - - case 0x03: MM_BK = (V >> 6) & 0x3; - MM_DMNA = (V >> 1) & 0x1; - printf("DMNA: %02x\n", MM_DMNA); - //if(MM_MODE == MODE_1M) - //{ - // if(!MM_DMNA) // Writing 0 to DMNA triggers it - // { - // MM_RET = !MM_RET; - //MM_DMNA = FALSE; - // } - //} - break; - - // CDC registers: - //zero 22-feb-2012 - removed case range - case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: - MDCD_CDC_MainWrite8(A & 0xFF, V); - break; - - case 0x0E: COMM_FLAGS &= 0x00FF; - COMM_FLAGS |= V << 8; - break; - case 0x0F: // Unused on main CPU writes - break; -//zero 22-feb-2012 - removed case range - case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: - WRITE_BYTE_MSB(COMM_CMD, A & 0xF, V); - break; - //zero 22-feb-2012 - removed case range - case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: break; // Unused on main cpu writes - - } - } -} - -static void MDCD_MainWrite16(uint32 A, uint16 V) -{ - A &= 0xFFFFFF; - - if(A >= 0x40000) - DEBUGMAIN("Write16: %08x %04x\n", A, V); - - if(A >= 0x20000 && A <= 0x3FFFF) // Sub68k program RAM(banked) - { - if(!SBRQ) - { - UNDEFMAIN("Write16 to PRAM when BUSREQ is not held: %08x:%04x\n",A,V); - } - else - { - uint32 offset = (A & 0x1FFFF) | (MM_BK << 17); - - WRITE_WORD_MSB(PRAM, offset, V); - } - } - else if(A >= 0x200000 && A <= 0x23FFFF) // Sub68k word RAM(switchable banking/mirroring) - { - if(MM_MODE == MODE_2M) - { - if(MM_DMNA) - { - UNDEFMAIN("Write to WordRAM when DMNA is set to 1: %08x %02x", A, V); - } - else - { - WRITE_WORD_MSB(WordRAM, A & 0x3FFFF, V); - } - } - else - { - if(A <= 0x21FFFF) - { - uint32 offset = (A & 0x1FFFF) | (MM_RET << 17); - WRITE_WORD_MSB(WordRAM, offset, V); - } - } - } - else if(A >= 0xa12000 && A <= 0xa120ff) - { - switch(A & 0xFF) - { - default: UNDEFMAIN("Unknown write: %08x %04x\n", A, V); - break; - - case 0x00: if(V & 0x0100) - MDCD_InterruptAssert(2, TRUE); - - if(SRES != (V & 0x1)) - { - C68k_Reset(&Sub68K); - } - SRES = V & 0x1; - SBRQ = V & 0x2; - SACK = SBRQ | (!SRES); - - break; - - case 0x02: MM_WP = V >> 8; - MM_DMNA = (V >> 1) & 0x1; - MM_BK = (V >> 6) & 0x3; - printf("DMNA: %02x\n", MM_DMNA); - //if(MM_MODE == MODE_1M) - //{ - // if(MM_DMNA) - // { - // MM_RET = !MM_RET; - //MM_DMNA = FALSE; - // } - // } - break; - - // CDC registers: - //zero 22-feb-2012 - removed case range - case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: - MDCD_CDC_MainWrite16(A & 0xFF, V); - break; - - case 0x0E: COMM_FLAGS &= 0x00FF; - COMM_FLAGS |= V & 0xFF00; - break; - //zero 22-feb-2012 - removed case range - case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: - - WRITE_WORD_MSB(COMM_CMD, A & 0xF, V); - break; - //zero 22-feb-2012 - removed case range - case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: // Unused on main CPU writes - break; - } - } -} - -static uint8 MDCD_MainRead8(uint32 A) -{ - A &= 0xFFFFFF; - - if(A >= 0x40000) - DEBUGMAIN("Read8: %08x\n", A); - - if(A <= 0x1FFFF) // BIOS ROM - { - return(READ_BYTE_MSB(BIOS, A)); - } - else if(A >= 0x20000 && A <= 0x3FFFF) // Sub68k program RAM(banked) - { - if(!SBRQ) - { - UNDEFMAIN("Read8 from PRAM when BUSREQ is not held: %08x\n",A); - } - else - { - uint32 offset = (A & 0x1FFFF) | (MM_BK << 17); - return(READ_BYTE_MSB(PRAM, offset)); - } - } - else if(A >= 0x200000 && A <= 0x23FFFF) // Sub68k word RAM(switchable banking/mirroring) - { - if(MM_MODE == MODE_2M) - { - if(MM_DMNA) - { - UNDEFMAIN("Read8 from WordRAM when DMNA is set to 1: %08x", A); - } - else - { - return(READ_BYTE_MSB(WordRAM, A & 0x3FFFF)); - } - } - else - { - if(A <= 0x21FFFF) - { - uint32 offset = (A & 0x1FFFF) | (MM_RET << 17); - return(READ_BYTE_MSB(WordRAM, offset)); - } - } - } - else if(A >= 0xa12000 && A <= 0xa120ff) - { - uint8 ret = 0; - switch(A & 0xFF) - { - case 0x00: ret |= MDCD_InterruptGetAsserted(2) ? 0x01 : 0x00; - ret |= MDCD_InterruptGetMask(2) ? 0x80 : 0x00; - return(ret); - - case 0x01: ret |= SRES ? 0x1 : 0x0; - ret |= SACK ? 0x2 : 0x0; - return(ret); - - case 0x02: ret = MM_WP; - return(ret); - - case 0x03: ret |= MM_BK << 6; - ret |= MM_MODE ? 0x4 : 0x0; - ret |= MM_DMNA ? 0x2 : 0x0; - ret |= MM_RET ? 0x1 : 0x0; - return(ret); - - // CDC registers: - //zero 22-feb-2012 - removed case range - case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: - return(MDCD_CDC_MainRead8(A & 0xFF)); - - // Communications: - case 0x0C: - case 0x0D: return(READ8of16(StopWatchCounter, A & 1)); - - case 0x0E: return(COMM_FLAGS >> 8); - case 0x0F: return(COMM_FLAGS >> 0); - //zero 22-feb-2012 - removed case range - case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: - - return(READ_BYTE_MSB(COMM_CMD, (A & 0xF))); - //zero 22-feb-2012 - removed case range - case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: return(READ_BYTE_MSB(COMM_STATUS, (A & 0xF))); - } - } - printf("Unknown main read8: %08x\n", A); - return(0x0); -} - -static uint16 MDCD_MainRead16(uint32 A) -{ - A &= 0xFFFFFF; - - if(A >= 0x40000) - DEBUGMAIN("Read16: %08x\n", A); - - if(A <= 0x1FFFF) // BIOS ROM - { - return(READ_WORD_MSB(BIOS, A)); - } - else if(A >= 0x20000 && A <= 0x3FFFF) // Sub68k program RAM(banked) - { - if(!SBRQ) - { - UNDEFMAIN("Read16 from PRAM when BUSREQ is not held: %08x\n",A); - } - else - { - uint32 offset = (A & 0x1FFFF) | (MM_BK << 17); - return(READ_WORD_MSB(PRAM, offset)); - } - } - else if(A >= 0x200000 && A <= 0x23FFFF) // Sub68k word RAM(switchable banking/mirroring) - { - if(MM_MODE == MODE_2M) - { - if(MM_DMNA) - { - UNDEFMAIN("Read16 from WordRAM when DMNA is set to 1: %08x", A); - } - else - { - return(READ_WORD_MSB(WordRAM, A & 0x3FFFF)); - } - } - else - { - if(A <= 0x21FFFF) - { - uint32 offset = (A & 0x1FFFF) | (MM_RET << 17); - return(READ_WORD_MSB(WordRAM, offset)); - } - } - } - else if(A >= 0xa12000 && A <= 0xa120ff) - { - uint16 ret = 0; - - switch(A & 0xFF) - { - case 0x00: - ret |= MDCD_InterruptGetAsserted(2) ? 0x0100 : 0x0000; - ret |= MDCD_InterruptGetMask(2) ? 0x8000 : 0x0000; - ret |= SRES ? 0x1 : 0x0; - ret |= SACK ? 0x2 : 0x0; - return(ret); - - case 0x02: ret |= MM_WP << 8; - ret |= MM_BK << 6; - ret |= MM_MODE ? 0x4 : 0x0; - ret |= MM_DMNA ? 0x2 : 0x0; - ret |= MM_RET ? 0x1 : 0x0; - return(ret); - - // CDC registers: - //zero 22-feb-2012 - removed case range - case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: - return(MDCD_CDC_MainRead16(A & 0xFF)); - - case 0x0C: return(StopWatchCounter); - case 0x0E: return(COMM_FLAGS); - //zero 22-feb-2012 - removed case range - case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: - - return(READ_WORD_MSB(COMM_CMD, (A & 0xF))); - //zero 22-feb-2012 - removed case range - case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: return(READ_WORD_MSB(COMM_STATUS, (A & 0xF))); - } - } - - printf("Unknown main Read16: %08x\n", A); -} - -////////////////////////////////// -// -// Sub 68K memory map handling: -// -////////////////////////////////// -static void MDCD_SubWrite8(uint32 A, uint8 V) -{ - A &= 0xFFFFFF; - - if(A >= 0x80000) - DEBUGSUB("Write8: %08x %02x\n", A, V); - - if(A <= 0x7FFFF) // Program RAM - { - if((A >> 8) < MM_WP) - { - printf("Oops8: %08x:%02x\n", A, V); - } - else - { - WRITE_BYTE_MSB(PRAM, A, V); - } - } - else if(A >= 0x80000 && A <= 0xBFFFF) // Word RAM - { // 2M mode: full 256KiB - // 1M mode: - if(MM_MODE == MODE_2M) - { - WRITE_BYTE_MSB(WordRAM, A & 0x3FFFF, V); - } - else - { - uint32 base = ((MM_RET ^ 1) << 17); - - } - } - else if(A >= 0xFE0000 && A <= 0xFE3FFF) //8KiB BRAM mapped into a 16KiB space - { - // Are even bytes open bus, 0, or the same as odd bytes? - if(A & 1) - BRAM[(A & 0x3FFF) >> 1] = V; - else - printf("Invalid write8: %08x:%02x\n", A, V); - } - else if(A >= 0xFE4000 && A <= 0xFEFFFF) //BRAM mirror(read only? unstable? reserved?) - { - printf("Invalid write8: %08x:%02x\n", A, V); - } - else if(A >= 0xFF0000 && A <= 0xFF3FFF) // PCM sound source - { - MDCD_PCM_Write((A >> 1) & 0x1FFF, V); - } - else if(A >= 0xFF4000 && A <= 0xFF7FFF) // PCM sound source mirror(read only? unstable? reserved?) - { - printf("Invalid write8: %08x:%02x\n", A, V); - } - else if(A >= 0xFF8000 && A <= 0xFF81FF) // Registers(as if everything else isn't ;)) - { - // - // Sub cpu registers! - // - switch(A & 0x1FF) - { - default: UNDEFSUB("Unknown write: %08x %02x\n", A, V); - break; - - case 0x00: LEDControl = (V & 0x3); - break; - case 0x01: if(!(V & 0x1)) - InPeripheralReset = TRUE; - break; - - case 0x02: break; // WP, unused on sub cpu writes - case 0x03: MM_PM = (V >> 3) & 0x3; - MM_MODE = (V >> 2) & 0x1; - MM_RET = (V >> 0) & 0x1; - printf("Cha8: %02x\n", V); - break; - - //zero 22-feb-2012 - removed case range - case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: - MDCD_CDC_SubWrite8(A & 0x1FF, V); - break; - - case 0x0C: - case 0x0D: StopWatchCounter = 0; - // Should we reset the divider too? - break; - - //case 0x0E: break; // Unused on sub cpu writes. TODO: Investigate Dragon's Lair - case 0x0F: COMM_FLAGS &= 0xFF00; - COMM_FLAGS |= V << 0; - break; - - //zero 22-feb-2012 - removed case range -case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: - - break; // Unused on sub cpu writes - //zero 22-feb-2012 - removed case range -case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: WRITE_BYTE_MSB(COMM_STATUS, (A & 0xF), V); - break; - - case 0x30: break; - case 0x31: MDCD_Timer_Write(V); - break; - - case 0x32: break; - case 0x33: MDCD_InterruptWrite(V); - - //zero 22-feb-2012 - removed case range - case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: case 0x3A: case 0x3B: case 0x3C: case 0x3D: case 0x3E: case 0x3F: case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47: case 0x48: case 0x49: case 0x4A: case 0x4B: - MDCD_CDD_Write8(A & 0x1FF, V); - break; - - } - } -} - -static void MDCD_SubWrite16(uint32 A, uint16 V) -{ - A &= 0xFFFFFF; - - assert(!(A & 1)); - - if(A >= 0x80000) - DEBUGSUB("Write16: %08x %04x\n", A, V); - - if(A <= 0x7FFFF) // Program RAM - { - if((A >> 8) < MM_WP) - { - printf("Oops16: %08x:%04x\n", A, V); - } - else - { - WRITE_WORD_MSB(PRAM, A, V); - } - } - else if(A >= 0x80000 && A <= 0xBFFFF) // Word RAM - { // 2M mode: full 256KiB - // 1M mode: - if(MM_MODE == MODE_2M) - { - WRITE_WORD_MSB(WordRAM, A & 0x3FFFF, V); - } - else - { - uint32 base = ((MM_RET ^ 1) << 17); - - } - } - else if(A >= 0xFE0000 && A <= 0xFE3FFF) //8KiB BRAM mapped into a 16KiB space - { - BRAM[(A & 0x3FFF) >> 1] = V & 0xFF; - } - else if(A >= 0xFE4000 && A <= 0xFEFFFF) //BRAM mirror(read only? unstable? reserved?) - { - printf("Invalid write16: %08x:%04x\n", A, V); - } - else if(A >= 0xFF0000 && A <= 0xFF3FFF) // PCM sound source - { - MDCD_PCM_Write((A >> 1) & 0x1FFF, V & 0xFF); - } - else if(A >= 0xFF4000 && A <= 0xFF7FFF) // PCM sound source mirror(read only? unstable? reserved?) - { - printf("Invalid write16: %08x:%04x\n", A, V); - } - else if(A >= 0xFF8000 && A <= 0xFF81FF) // Registers(as if everything else isn't ;)) - { - // - // Sub cpu registers! - // - switch(A & 0x1FF) - { - default: UNDEFSUB("Unknown write: %08x %04x\n", A, V); - break; - - case 0x02: - MM_PM = (V >> 3) & 0x3; - MM_MODE = (V >> 2) & 0x1; - MM_RET = (V >> 0) & 0x1; - printf("Cha16: %04x\n", V); - break; - - //zero 22-feb-2012 - removed case range -case 0x04: case 0x05: case 0x06: case 0x07: case 0x08: case 0x09: case 0x0A: case 0x0B: - MDCD_CDC_SubWrite16(A & 0x1FF, V); - break; - - case 0x0C: StopWatchCounter = 0; - // Should we reset the divider too? - break; - - case 0x0E: - COMM_FLAGS &= 0xFF00; - COMM_FLAGS |= V & 0x00FF; - break; - - case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: - - break; // Unused on sub cpu writes - //zero 22-feb-2012 - removed case range -case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: WRITE_WORD_MSB(COMM_STATUS, (A & 0xF), V); - break; - - case 0x30: MDCD_Timer_Write(V & 0xFF); - break; - - case 0x32: MDCD_InterruptWrite(V); - break; - - //zero 22-feb-2012 - removed case range -case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: case 0x3A: case 0x3B: case 0x3C: case 0x3D: case 0x3E: case 0x3F: case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46: case 0x47: case 0x48: case 0x49: case 0x4A: case 0x4B: - MDCD_CDD_Write16(A & 0x1FF, V); - break; - } - } -} - -static uint8 MDCD_SubRead8(uint32 A) -{ - A &= 0xFFFFFF; - - if(A >= 0x80000) - DEBUGSUB("Read8: %08x\n", A); - - if(A <= 0x7FFFF) // Program RAM - { - return(READ_BYTE_MSB(PRAM, A)); - } - else if(A >= 0x80000 && A <= 0xBFFFF) // Word RAM - { // 2M mode: full 256KiB - // 1M mode: - if(MM_MODE == MODE_2M) - { - return(READ_BYTE_MSB(WordRAM, A & 0x3FFFF)); - } - else - { - uint32 base = ((MM_RET ^ 1) << 17); - - } - } - else if(A >= 0xC0000 && A <= 0xDFFFF) // Word RAM. - { // 2M mode: Unmapped - // 1M mode: Selectable - if(MM_MODE == MODE_1M) - { - uint32 offset = (A & 0x1FFFF) | ((MM_RET ^ 1) << 17); - return(READ_BYTE_MSB(WordRAM, offset)); - } - } - else if(A >= 0xFE0000 && A <= 0xFE3FFF) //8KiB BRAM mapped into a 16KiB space - { - // Are even bytes open bus, 0, or the same as odd bytes? - return(BRAM[(A & 0x3FFF) >> 1]); - } - else if(A >= 0xFE4000 && A <= 0xFEFFFF) //BRAM mirror(read only? unstable? reserved?) - { - return(BRAM[(A & 0x3FFF) >> 1]); - } - else if(A >= 0xFF0000 && A <= 0xFF3FFF) // PCM sound source - { - - } - else if(A >= 0xFF4000 && A <= 0xFF7FFF) // PCM sound source mirror(read only? unstable? reserved?) - { - - } - else if(A >= 0xFF8000 && A <= 0xFF81FF) // Registers(as if everything else isn't ;)) - { - // - // Sub cpu registers! - // - uint8 ret = 0; - - switch(A & 0x1FF) - { - case 0x00: ret |= LEDControl << 0; - return(ret); - case 0x01: ret |= 1 << 0; - ret |= 0 << 4; // Version - return(ret); - - case 0x02: return(MM_WP); - case 0x03: ret |= MM_RET << 0; - ret |= MM_DMNA << 1; - ret |= MM_MODE << 2; - ret |= MM_PM << 3; - return(ret); - - case 0x0C: - case 0x0D: return(READ8of16(StopWatchCounter, A & 1)); - - case 0x0E: return(COMM_FLAGS >> 8); - case 0x0F: return(COMM_FLAGS >> 0); - - //zero 22-feb-2012 - removed case range -case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: - - return(READ_BYTE_MSB(COMM_CMD, (A & 0xF))); - //zero 22-feb-2012 - removed case range -case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: return(READ_BYTE_MSB(COMM_STATUS, (A & 0xF))); - - case 0x30: break; - case 0x31: return(MDCD_Timer_Read()); - - case 0x32: break; - case 0x33: return(MDCD_InterruptRead()); - } - } - else if(A >= 0xFF8200 && A <= 0xFFFFFF) // Reserved - { - - } - - printf("Unknown Sub read8: %08x\n", A); - - return(0); -} - -static uint16 MDCD_SubRead16(uint32 A) -{ - A &= 0xFFFFFF; - - assert(!(A & 1)); - - if(A >= 0x80000) - DEBUGSUB("Read16: %08x\n", A); - - if(A <= 0x7FFFF) // Program RAM - { - return(READ_WORD_MSB(PRAM, A)); - } - else if(A >= 0x80000 && A <= 0xBFFFF) // Word RAM - { // 2M mode: full 256KiB - // 1M mode: - if(MM_MODE == MODE_2M) - { - return(READ_WORD_MSB(WordRAM, A & 0x3FFFF)); - } - else - { - uint32 base = ((MM_RET ^ 1) << 17); - - } - } - else if(A >= 0xFE0000 && A <= 0xFE3FFF) //8KiB BRAM mapped into a 16KiB space - { - return(BRAM[(A & 0x3FFF) >> 1]); - } - else if(A >= 0xFE4000 && A <= 0xFEFFFF) //BRAM mirror(read only? unstable? reserved?) - { - return(BRAM[(A & 0x3FFF) >> 1]); - } - else if(A >= 0xFF0000 && A <= 0xFF3FFF) // PCM sound source - { - - } - else if(A >= 0xFF4000 && A <= 0xFF7FFF) // PCM sound source mirror(read only? unstable? reserved?) - { - - } - else if(A >= 0xFF8000 && A <= 0xFF81FF) // Registers(as if everything else isn't ;)) - { - // - // Sub cpu registers! - // - uint16 ret = 0; - - switch(A & 0x1FF) - { - case 0x02: ret = MM_WP << 8; - ret |= MM_RET << 0; - ret |= MM_DMNA << 1; - ret |= MM_MODE << 2; - ret |= MM_PM << 3; - return(ret); - - case 0x0C: return(StopWatchCounter); - case 0x0E: return(COMM_FLAGS); - //zero 22-feb-2012 - removed case range -case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F: - - return(READ_WORD_MSB(COMM_CMD, (A & 0xF))); - //zero 22-feb-2012 - removed case range -case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F: return(READ_WORD_MSB(COMM_STATUS, (A & 0xF))); - case 0x30: return(MDCD_Timer_Read()); - case 0x32: return(MDCD_InterruptRead()); - } - } - else if(A >= 0xFF8200 && A <= 0xFFFFFF) // Reserved - { - - } - - printf("Unknown Sub read16: %08x\n", A); - return(0); -} - -#define SUBCPU_CLOCK 12500000 - -void MDCD_Run(int32 md_master_cycles) -{ - const uint32 md_master_clock = CLOCK_NTSC; - - Sub68KCycleCounter += (int64)md_master_cycles * SUBCPU_CLOCK; - - while(Sub68KCycleCounter > 0) - { - int32 temp_cycles; - - if(MM_MODE) - exit(1); - - if(!SRES || SBRQ) - temp_cycles = 8; - else - { - //printf("Yay: %08x\n", C68k_Get_PC(&Sub68K)); - Sub68K.timestamp = 0; - C68k_Exec(&Sub68K); - temp_cycles = Sub68K.timestamp; - } - MDCD_Timer_Run(temp_cycles); - MDCD_PCM_Run(temp_cycles); - - // Run stop watch - StopWatchDiv -= temp_cycles; - while(StopWatchDiv <= 0) - { - StopWatchCounter = (StopWatchCounter + 1) & 0xFFF; - StopWatchDiv += 384; - } - Sub68KCycleCounter -= (int64)temp_cycles * md_master_clock; - } -} - -void MDCD_Close(void) -{ - if(BIOS) - { - MDFN_free(BIOS); - BIOS = NULL; - } - - if(PRAM) - { - MDFN_free(PRAM); - PRAM = NULL; - } - - if(WordRAM) - { - MDFN_free(WordRAM); - WordRAM = NULL; - } -} - -bool MDCD_Init(void) -{ - if(!(BIOS = (uint8 *)MDFN_calloc(1, 0x20000, _("BIOS ROM")))) - { - return(FALSE); - } - - if(!(BRAM = (uint8 *)MDFN_calloc(1, 0x2000, _("Battery-backed RAM")))) - { - return(FALSE); - } - memset(BRAM, 0xFF, 8192); - - if(!(PRAM = (uint8 *)MDFN_calloc(1, 0x80000, _("Program RAM")))) - { - return(FALSE); - } - - if(!(WordRAM = (uint8 *)MDFN_calloc(1, 0x40000, _("Word RAM")))) - { - return(FALSE); - } - - // Load the BIOS - static const FileExtensionSpecStruct KnownBIOSExtensions[] = - { - { ".bin", gettext_noop("BIOS Image") }, - { ".bios", gettext_noop("BIOS Image") }, - { NULL, NULL } - }; - std::string bios_path = MDFN_MakeFName(MDFNMKF_FIRMWARE, 0, MDFN_GetSettingS("md.cdbios").c_str()); - MDFNFILE bios_fp; - - if(!bios_fp.Open(bios_path.c_str(), KnownBIOSExtensions)) - { - MDFN_PrintError(_("Could not open CD BIOS file \"%s\": %s\n"), bios_path.c_str(), strerror(errno)); - return(0); - } - - if(bios_fp.Size() != 0x20000) - { - MDFN_PrintError(_("BIOS is incorrect size.")); - return(0); - } - - memcpy(BIOS, bios_fp.Data(), 0x20000); - - bios_fp.Close(); - - MD_ExtRead8 = MDCD_MainRead8; - MD_ExtRead16 = MDCD_MainRead16; - MD_ExtWrite8 = MDCD_MainWrite8; - MD_ExtWrite16 = MDCD_MainWrite16; - - C68k_Init(&Sub68K, MDCD_InterruptAck); - C68k_Set_ReadB(&Sub68K, MDCD_SubRead8); - C68k_Set_ReadW(&Sub68K, MDCD_SubRead16); - C68k_Set_WriteB(&Sub68K, MDCD_SubWrite8); - C68k_Set_WriteW(&Sub68K, MDCD_SubWrite16); - - return(TRUE); -} - -static int32 CheckValidTrack(CDIF *cdiface, uint8 *sector_buffer) -{ - CDUtility::TOC toc; - bool DTFound = 0; - int32 track; - - cdiface->ReadTOC(&toc); - - for(track = toc.first_track; track <= toc.last_track; track++) - { - if(toc.tracks[track].control & 0x4) - { - DTFound = 1; - break; - } - } - - if(DTFound) // Only add the MD5 hash if we were able to find a data track. - { - if(cdiface->ReadSector(sector_buffer, toc.tracks[track].lba, 1)) - { - if(!memcmp(sector_buffer + 0x100, "SEGA MEGA DRIVE", 15) || !memcmp(sector_buffer + 0x100, "SEGA GENESIS", 12)) - return(track); - } - } - - return(0); -} - -bool MDCD_TestMagic(std::vector *CDInterfaces) -{ - uint8 sector_buffer[2048]; - - return((bool)CheckValidTrack((*CDInterfaces)[0], sector_buffer)); -} - -bool MDCD_Load(std::vector *CDInterfaces, md_game_info *ginfo) -{ - uint8 sector_buffer[2048]; - - if(!CheckValidTrack((*CDInterfaces)[0], sector_buffer)) - return(FALSE); - - MD_ReadSegaHeader(sector_buffer + 0x100, ginfo); - - //uint8 sector_buffer[2048]; - //for(int x = 0; x < 128; x++) - //{ - // memset(sector_buffer, 0, 2048); - // CDIF_ReadSector(sector_buffer, NULL, start_sector + x, 1); - // md5.update(sector_buffer, 2048); - //} - //} - - return(MDCD_Init()); -} - - -void MDCD_Reset(bool poweron) -{ - if(poweron) - { - memset(PRAM, 0, 0x80000); - memset(WordRAM, 0, 0x40000); - } - - C68k_Reset(&Sub68K); - MDCD_InterruptReset(); - MDCD_PCM_Reset(); - - SRES = 1; - SBRQ = 1; - SACK = 1; - - MM_WP = 0; - MM_BK = 0; - - MM_RET = 1; -} diff --git a/libmednahawk/src/md/cd/cd.h b/libmednahawk/src/md/cd/cd.h deleted file mode 100644 index 1799fc6378..0000000000 --- a/libmednahawk/src/md/cd/cd.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __MDFN_MD_CD_H -#define __MDFN_MD_CD_H - -extern c68k_struc Sub68K; - -void MDCD_Run(int32 md_master_cycles); -void MDCD_PCM_Run(int32 cycles); -void MDCD_Reset(bool poweron); -bool MDCD_Load(std::vector *CDInterfaces, md_game_info *); -bool MDCD_TestMagic(std::vector *CDInterfaces); -void MDCD_Close(void); - -#endif diff --git a/libmednahawk/src/md/cd/cdc_cdd.cpp b/libmednahawk/src/md/cd/cdc_cdd.cpp deleted file mode 100644 index 1ff8082451..0000000000 --- a/libmednahawk/src/md/cd/cdc_cdd.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "../shared.h" -#include "cd.h" -#include "cdc_cdd.h" - -void MDCD_CDC_MainWrite8(uint32 A, uint8 V) -{ - -} - - -void MDCD_CDC_MainWrite16(uint32 A, uint16 V) -{ - -} - -uint8 MDCD_CDC_MainRead8(uint32 A) -{ - - return 0; -} - -uint16 MDCD_CDC_MainRead16(uint32 A) -{ - - return 0; -} - - -void MDCD_CDC_SubWrite8(uint32 A, uint8 V) -{ - -} - -void MDCD_CDC_SubWrite16(uint32 A, uint16 V) -{ - -} - -uint8 MDCD_CDC_SubRead8(uint32 A) -{ - return 0; -} - -uint16 MDCD_CDC_SubRead16(uint32 A) -{ - return 0; -} - - - - -void MDCD_CDD_Write8(uint32 A, uint8 V) -{ - -} - - -void MDCD_CDD_Write16(uint32 A, uint16 V) -{ - -} - -uint8 MDCD_CDD_Read8(uint32 A) -{ - - return 0; -} - -uint16 MDCD_CDD_Read16(uint32 A) -{ - - return 0; -} - diff --git a/libmednahawk/src/md/cd/cdc_cdd.h b/libmednahawk/src/md/cd/cdc_cdd.h deleted file mode 100644 index 130f14171e..0000000000 --- a/libmednahawk/src/md/cd/cdc_cdd.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __MDFN_MDCD_CDCCDD_H -#define __MDFN_MDCD_CDCCDD_H - -void MDCD_CDC_MainWrite8(uint32 A, uint8 V); -void MDCD_CDC_MainWrite16(uint32 A, uint16 V); -uint8 MDCD_CDC_MainRead8(uint32 A); -uint16 MDCD_CDC_MainRead16(uint32 A); - -void MDCD_CDC_SubWrite8(uint32 A, uint8 V); -void MDCD_CDC_SubWrite16(uint32 A, uint16 V); -uint8 MDCD_CDC_SubRead8(uint32 A); -uint16 MDCD_CDC_SubRead16(uint32 A); - - -void MDCD_CDD_Write8(uint32 A, uint8 V); -void MDCD_CDD_Write16(uint32 A, uint16 V); -uint8 MDCD_CDD_Read8(uint32 A); -uint16 MDCD_CDD_Read16(uint32 A); - -#endif diff --git a/libmednahawk/src/md/cd/interrupt.cpp b/libmednahawk/src/md/cd/interrupt.cpp deleted file mode 100644 index 65071a0dd8..0000000000 --- a/libmednahawk/src/md/cd/interrupt.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cd.h" -#include "interrupt.h" - -/* SegaCD interrupt levels: - 6 - Sub-channel buffering completed - 5 - CDC, error correction or buffer completed - 4 - CDD, command reception is completed? - 3 - Timer - 2 - Software int from main CPU - 1 - Graphics operation is completed -*/ - - -static uint32 asserted; -static uint32 InterruptMask; - -static void Rebuild(void) -{ - int pending_level = 0; - uint32 awm = asserted & InterruptMask; - - // Level 0 doesn't exist per-se. - // Level 7 doesn't seem to be used on the SegaCD - for(int i = 6; i > 0; i--) - { - if(awm & (1 << i)) - { - pending_level = i; - break; - } - } - - C68k_Set_IRQ(&Sub68K, pending_level); -} - -uint8 MDCD_InterruptRead(void) -{ - return(InterruptMask); -} - -bool MDCD_InterruptGetMask(int level) -{ - return((InterruptMask >> level) & 1); -} - -bool MDCD_InterruptGetAsserted(int level) -{ - return((asserted >> level) & 1); -} - -void MDCD_InterruptWrite(uint8 V) -{ - InterruptMask = V & 0x7E; - Rebuild(); -} - -int MDCD_InterruptAck(int level) -{ - printf("Interrupt: %d\n", level); - - asserted &= ~(1 << level); - Rebuild(); - - return(C68K_INT_ACK_AUTOVECTOR); -} - -void MDCD_InterruptAssert(int level, bool status) -{ - assert(status == 0 || status == 1); - - asserted &= ~(1 << level); - asserted |= status << level; - Rebuild(); -} - -void MDCD_InterruptReset(void) -{ - asserted = 0; - Rebuild(); -} - -void MDCD_InterruptInit(void) -{ - - -} diff --git a/libmednahawk/src/md/cd/interrupt.h b/libmednahawk/src/md/cd/interrupt.h deleted file mode 100644 index 6fc54d6a50..0000000000 --- a/libmednahawk/src/md/cd/interrupt.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __MDFN_MDCD_INTERRUPT_H -#define __MDFN_MDCD_INTERRUPT_H - -bool MDCD_InterruptGetMask(int level); -bool MDCD_InterruptGetAsserted(int level); -int MDCD_InterruptAck(int level); -void MDCD_InterruptAssert(int level, bool status); -void MDCD_InterruptReset(void); - -uint8 MDCD_InterruptRead(void); -void MDCD_InterruptWrite(uint8 V); - -#endif diff --git a/libmednahawk/src/md/cd/pcm.cpp b/libmednahawk/src/md/cd/pcm.cpp deleted file mode 100644 index 3c2edfae36..0000000000 --- a/libmednahawk/src/md/cd/pcm.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cd.h" -#include "pcm.h" - -static bool IC_On; // Set by D7 of writes to 0x0007. -static uint8 WB; // Wave bank select. Set by the lower 4 bits of writes to 0x0007 when D6 is clear. -static uint8 CB; // Channel select. Set by the lower 3 bits of wries to 0x0007 when D6 is set. -static uint8 ChannelOn; // Register 0x0008, on/off register for each of the 8 channels -static uint8 WaveData[0x10000]; // 64KiB of waveform data -typedef struct -{ - uint32 Counter; // Address counter. The lower 11 bits are the fractional component. - uint8 ENV; // 0x0000 - uint8 PAN; // 0x0001. Upper 4 bits affect R output, lower 4 bits affect L output. - uint16 FD; // FDL(0x0002) and FDH(0x0003) Controls the incrementing of the address counter. - uint16 LS; // LSL(0x0004) and LSH(0x0005) When 0xFF(stop data) is read from waveform memory, - // the address counter will be reloaded with this value. - uint8 ST; // 0x0006 - // Upper 8-bits of the channel's read address are set to when a channel is enabled(the lower 8 bits are set to 0). - -} pcm_channel_t; - -static pcm_channel_t Channels[8]; - - -// Last timestamp -static int32 last_ts; - -// Divide by (4 * 384) counter -static int32 div_count; - -static void PCM_Clock(void); -static void MDCD_PCM_Update(void); - -void MDCD_PCM_Write(uint32 A, uint8 V) -{ - A &= 0x1FFF; - - MDCD_PCM_Update(); - - if(A >= 0x1000) - { - WaveData[(WB << 12) | (A & 0x0FFF)] = V; - } - else switch(A) - { - case 0x00: Channels[CB].ENV = V; - break; - - case 0x01: Channels[CB].PAN = V; - break; - - case 0x02: Channels[CB].FD &= 0xFF00; - Channels[CB].FD |= V << 0; - break; - - case 0x03: Channels[CB].FD &= 0x00FF; - Channels[CB].FD |= V << 8; - break; - - case 0x04: Channels[CB].LS &= 0xFF00; - Channels[CB].LS |= V << 0; - break; - - case 0x05: Channels[CB].LS &= 0x00FF; - Channels[CB].LS |= V << 8; - break; - - case 0x06: Channels[CB].ST = V; - break; - - case 0x07: IC_On = V & 0x80; - if(V & 0x40) - CB = V & 0x7; - else - WB = V & 0xF; - break; - - case 0x08: ChannelOn = V; - break; - } -} - -static void PCM_Clock(void) -{ - int32 left = 0; - int32 right = 0; - - for(int ch = 0; ch < 8; ch++) - { - pcm_channel_t *CurChan = &Channels[ch]; - - if(!IC_On) - { - CurChan->Counter = CurChan->ST << (8 + 11); - } - else - { - uint8 tmp_sample; - - CurChan->Counter += CurChan->FD; - tmp_sample = WaveData[(CurChan->Counter >> 11) & 0xFFFF]; - - if(tmp_sample == 0xFF) - { - CurChan->Counter = CurChan->LS << 11; - } - } - int32 sample = WaveData[(CurChan->Counter >> 11) & 0xFFFF]; - - if(sample & 0x80) - sample = -(sample & 0x7F); - - sample *= CurChan->ENV; - - if(ChannelOn & (1 << ch)) - { - left += (sample * (CurChan->PAN & 0x0F)) >> 4; - right += (sample * ((CurChan->PAN >> 4) & 0x0F)) >> 4; - } - } - - if(left < -0x8000) - left = -0x8000; - if(left > 0x7FFF) - left = 0x7FFF; - - if(right < -0x8000) - right = -0x8000; - if(right > 0x7FFF) - right = 0x7FFF; -} - -void MDCD_PCM_Run(int32 cycles) -{ - div_count -= cycles; - while(div_count <= 0) - { - PCM_Clock(); - div_count += 384; - } -} - -void MDCD_PCM_Update(void) -{ - #if 0 - int32 cycles = md_cd_timestamp - last_ts; - - - last_ts = md_cd_timestamp; - #endif -} - -void MDCD_PCM_Reset(void) -{ - IC_On = 0; - WB = 0; - CB = 0; - ChannelOn = 0; - - - memset(WaveData, 0, sizeof(WaveData)); - memset(Channels, 0, sizeof(Channels)); -} diff --git a/libmednahawk/src/md/cd/pcm.h b/libmednahawk/src/md/cd/pcm.h deleted file mode 100644 index dfab5c4917..0000000000 --- a/libmednahawk/src/md/cd/pcm.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __MDFN_MD_PCM_H -#define __MDFN_MD_PCM_H - -void MDCD_PCM_Write(uint32 A, uint8 V); -void MDCD_PCM_Reset(void); - -#endif diff --git a/libmednahawk/src/md/cd/timer.cpp b/libmednahawk/src/md/cd/timer.cpp deleted file mode 100644 index f3e0b5d2aa..0000000000 --- a/libmednahawk/src/md/cd/timer.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "cd.h" -#include "timer.h" -#include "interrupt.h" - -static uint8 TimerLatch; -static int32 TimerDiv; - -void MDCD_Timer_Reset(void) -{ - TimerLatch = 0; - TimerDiv = 0; - MDCD_InterruptAssert(3, FALSE); -} - -void MDCD_Timer_Run(int32 clocks) -{ - TimerDiv -= clocks; - - while(TimerDiv <= 0) - { - if(TimerLatch) - { - TimerLatch--; - if(!TimerLatch) - { - MDCD_InterruptAssert(3, TRUE); - } - } - TimerDiv += 384; - } -} - - -void MDCD_Timer_Write(uint8 V) -{ - TimerLatch = V; - // Should we cancel a pending interrupt on writes(or writes of 0)? -} - -uint8 MDCD_Timer_Read(void) -{ - return(TimerLatch); -} diff --git a/libmednahawk/src/md/cd/timer.h b/libmednahawk/src/md/cd/timer.h deleted file mode 100644 index 139ed45370..0000000000 --- a/libmednahawk/src/md/cd/timer.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __MDFN_MDCD_TIMER_H -#define __MDFN_MDCD_TIMER_H - -void MDCD_Timer_Reset(void); -void MDCD_Timer_Run(int32 clocks); -void MDCD_Timer_Write(uint8 V); -uint8 MDCD_Timer_Read(void); - -#endif diff --git a/libmednahawk/src/md/cpuintrf.h b/libmednahawk/src/md/cpuintrf.h deleted file mode 100644 index d78b29d0c2..0000000000 --- a/libmednahawk/src/md/cpuintrf.h +++ /dev/null @@ -1,30 +0,0 @@ - -#ifndef CPUINTRF_H -#define CPUINTRF_H - -#include "osd_cpu.h" - -#define CPU_16BIT_PORT 0x4000 -#define CPU_FLAGS_MASK 0xff00 -#define CLEAR_LINE 0 -#define ASSERT_LINE 1 -#define REG_PREVIOUSPC -1 -#define REG_SP_CONTENTS -2 - -/* daisy-chain link */ -typedef struct { - void (*reset)(int); /* reset callback */ - int (*interrupt_entry)(int); /* entry callback */ - void (*interrupt_reti)(int); /* reti callback */ - int irq_param; /* callback paramater */ -} Z80_DaisyChain; - -#define Z80_MAXDAISY 4 /* maximum of daisy chan device */ - -#define Z80_INT_REQ 0x01 /* interrupt request mask */ -#define Z80_INT_IEO 0x02 /* interrupt disable mask(IEO) */ - -#define Z80_VECTOR(device,state) (((device)<<8)|(state)) - - -#endif /* CPUINTRF_H */ diff --git a/libmednahawk/src/md/debug.cpp b/libmednahawk/src/md/debug.cpp deleted file mode 100644 index 4d103901df..0000000000 --- a/libmednahawk/src/md/debug.cpp +++ /dev/null @@ -1,477 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "shared.h" -#include "debug.h" -#include - -namespace MDFN_IEN_MD -{ -bool MD_DebugMode = FALSE; - -static void (*DriverCPUHook)(uint32); - - -static c68k_struc Main68K_BP; -static void (*BPCallB)(uint32 PC) = NULL; -static bool BPActive = FALSE; // Any breakpoints on? -static bool BPNonPCActive = FALSE; // Any breakpoints other than PC on? -static bool FoundBPoint; - -typedef struct -{ - uint32 A[2]; - int type; -} MD_BPOINT; - -static std::vector BreakPointsPC, BreakPointsRead, BreakPointsWrite; -static std::vector BreakPointsAux0Read, BreakPointsAux0Write; - -enum -{ - C68K_GSREG_PC = 0, - C68K_GSREG_SR, - - C68K_GSREG_D0, - C68K_GSREG_D7 = C68K_GSREG_D0 + 7, - - C68K_GSREG_A0, - C68K_GSREG_A7 = C68K_GSREG_A0 + 7, - - -}; - - -static uint32 M68K_GetRegister(const unsigned int id, char *special, const uint32 special_len) -{ - uint32 ret = 0xDEADBEEF; - - if(id == C68K_GSREG_PC) - { - ret = C68k_Get_PC(&Main68K); - } - else if(id == C68K_GSREG_SR) - { - ret = C68k_Get_SR(&Main68K); - } - else if(id >= C68K_GSREG_D0 && id <= C68K_GSREG_D7) - { - ret = C68k_Get_DReg(&Main68K, id - C68K_GSREG_D0); - } - else if(id >= C68K_GSREG_A0 && id <= C68K_GSREG_A7) - { - ret = C68k_Get_AReg(&Main68K, id - C68K_GSREG_A0); - } - return(ret); -} - -void M68K_SetRegister(const unsigned int id, uint32 value) -{ - if(id == C68K_GSREG_PC) - { - C68k_Set_PC(&Main68K, value); - } -} - - -static RegType M68K_Regs[] = -{ - { C68K_GSREG_PC, "PC", "Program Counter", 4 }, - - { 0, "------", "", 0xFFFF }, - - { C68K_GSREG_D0 + 0, "D0", "D0(Data Register 0)", 4 }, - { C68K_GSREG_D0 + 1, "D1", "D1(Data Register 1)", 4 }, - { C68K_GSREG_D0 + 2, "D2", "D2(Data Register 2)", 4 }, - { C68K_GSREG_D0 + 3, "D3", "D3(Data Register 3)", 4 }, - { C68K_GSREG_D0 + 4, "D4", "D4(Data Register 4)", 4 }, - { C68K_GSREG_D0 + 5, "D5", "D5(Data Register 5)", 4 }, - { C68K_GSREG_D0 + 6, "D6", "D6(Data Register 6)", 4 }, - { C68K_GSREG_D0 + 7, "D7", "D7(Data Register 7)", 4 }, - - { 0, "------", "", 0xFFFF }, - - { C68K_GSREG_A0 + 0, "A0", "A0(Address Register 0)", 4 }, - { C68K_GSREG_A0 + 1, "A1", "A1(Address Register 1)", 4 }, - { C68K_GSREG_A0 + 2, "A2", "A2(Address Register 2)", 4 }, - { C68K_GSREG_A0 + 3, "A3", "A3(Address Register 3)", 4 }, - { C68K_GSREG_A0 + 4, "A4", "A4(Address Register 4)", 4 }, - { C68K_GSREG_A0 + 5, "A5", "A5(Address Register 5)", 4 }, - { C68K_GSREG_A0 + 6, "A6", "A6(Address Register 6)", 4 }, - { C68K_GSREG_A0 + 7, "A7", "A7/USP(Address Register 7 / User Stack Pointer)", 4 }, - - { 0, "------", "", 0xFFFF }, - { C68K_GSREG_SR, "SR", "Status Register", 2 }, - - { 0, "", "", 0 }, -}; - -static RegGroupType M68K_RegsGroup = -{ - "M68K", - M68K_Regs, - M68K_GetRegister, - M68K_SetRegister -}; - - -uint32 MemPeek(uint32 A, unsigned int bsize, bool hl, bool logical) -{ - uint32 ret = 0; - - MD_HackyHackyMode++; - - for(unsigned int i = 0; i < bsize; i++) - { - A &= 0xFFFFFF; - ret |= MD_ReadMemory8(A) << ((bsize - 1 - i) * 8); - - A++; - } - - MD_HackyHackyMode--; - return(ret); -} - -static uint16_t dis_callb(uint32_t A, void *private_data) -{ - return(MD_ReadMemory16(A & 0xFFFFFF)); -} - -void Disassemble(uint32 &a, uint32 SpecialA, char *TextBuf) -{ - DESA68parm_t d; - - a &= 0xFFFFFE; - - //printf("Disassemble %06x: ", a); - - strcpy(TextBuf, "Invalid"); - memset(&d, 0, sizeof(DESA68parm_t)); - - d.mem_callb = dis_callb; - d.memmsk = 0xFFFFFF; - d.pc = a; - d.str = TextBuf; - d.strmax = 255; // FIXME, MDFN API change - - MD_HackyHackyMode++; - desa68(&d); - MD_HackyHackyMode--; - - a = d.pc & 0xFFFFFF; - - if(d.pc & 1) - puts("Oops"); - - if(!d.status) - strcpy(TextBuf, "Invalid"); - //printf("%d\n", d.status); -// puts(TextBuf); -} - -static inline void C68k_Copy_State2(const c68k_struc *source, c68k_struc *dest) -{ - memcpy(&dest->D[0], &source->D[0], ((uint8 *)&(source->dirty1)) - ((uint8 *)&(source->D[0]))); -} - -void MDDBG_CPUHook(void) //uint32 PC, uint16 op) -{ - uint32 PC = C68k_Get_PC(&Main68K); - std::vector::iterator bpit; - - FoundBPoint = 0; - - for(bpit = BreakPointsPC.begin(); bpit != BreakPointsPC.end(); bpit++) - { - if(PC >= bpit->A[0] && PC <= bpit->A[1]) - { - FoundBPoint = TRUE; - break; - } - } - - if(BPNonPCActive) - { - MD_HackyHackyMode++; - - C68k_Copy_State2(&Main68K, &Main68K_BP); - - //printf("Moo: %08x\n", C68k_Get_PC(&Main68K_BP)); //, (int)(((uint8 *)&(Main68K.dirty1)) - ((uint8 *)&(Main68K.D[0])))); - - C68k_Exec(&Main68K_BP); - - MD_HackyHackyMode--; - } - - if(FoundBPoint) - BPCallB(PC); - - if(DriverCPUHook) - DriverCPUHook(PC); -} - -static void RedoCPUHook(void) -{ - //C68k_Set_Debug(&Main68K, DriverCPUHook ? CPUHookHandler : NULL); - - BPNonPCActive = BreakPointsRead.size() || BreakPointsWrite.size() || BreakPointsAux0Read.size() || BreakPointsAux0Write.size(); - BPActive = BPNonPCActive || BreakPointsPC.size(); - - MD_DebugMode = (DriverCPUHook || BPActive); -} - -static void AddBreakPoint(int type, unsigned int A1, unsigned int A2, bool logical) -{ - MD_BPOINT tmp; - - tmp.A[0] = A1; - tmp.A[1] = A2; - tmp.type = type; - - if(type == BPOINT_READ) - BreakPointsRead.push_back(tmp); - else if(type == BPOINT_WRITE) - BreakPointsWrite.push_back(tmp); - else if(type == BPOINT_IO_READ) - BreakPointsAux0Read.push_back(tmp); - else if(type == BPOINT_AUX_WRITE) - BreakPointsAux0Write.push_back(tmp); - else if(type == BPOINT_PC) - BreakPointsPC.push_back(tmp); - - RedoCPUHook(); -} - - -void FlushBreakPoints(int type) -{ - std::vector::iterator bpit; - - if(type == BPOINT_READ) - BreakPointsRead.clear(); - else if(type == BPOINT_WRITE) - BreakPointsWrite.clear(); - else if(type == BPOINT_AUX_READ) - BreakPointsAux0Read.clear(); - else if(type == BPOINT_AUX_WRITE) - BreakPointsAux0Write.clear(); - else if(type == BPOINT_PC) - BreakPointsPC.clear(); - - RedoCPUHook(); -} - -void SetCPUCallback(void (*callb)(uint32 PC)) -{ - DriverCPUHook = callb; - RedoCPUHook(); -} - -void SetBPCallback(void (*callb)(uint32 PC)) -{ - BPCallB = callb; -} - -std::vector GetBranchTrace(void) -{ - std::vector ret; - - return(ret); -} - -static void GetAddressSpaceBytes(const char *name, uint32 Address, uint32 Length, uint8 *Buffer) -{ - MD_HackyHackyMode++; - - if(!strcmp(name, "cpu")) - { - while(Length--) - { - Address &= 0xFFFFFF; - *Buffer = MD_ReadMemory8(Address); - Address++; - Buffer++; - } - } - else if(!strcmp(name, "ram")) - { - while(Length--) - { - *Buffer = MD_ReadMemory8((Address & 0xFFFF) | 0xFF0000); - Address++; - Buffer++; - } - } - - MD_HackyHackyMode--; -} - -static void PutAddressSpaceBytes(const char *name, uint32 Address, uint32 Length, uint32 Granularity, bool hl, const uint8 *Buffer) -{ - if(!strcmp(name, "cpu")) - { - while(Length--) - { - Address &= 0xFFFFFF; - } - } - else if(!strcmp(name, "ram")) - { - while(Length--) - { - MD_WriteMemory8((Address & 0xFFFF) | 0xFF0000, *Buffer); - Address++; - Buffer++; - } - } -} - -static int dbg_int_ack_callback(int int_level) -{ - return C68K_INT_ACK_AUTOVECTOR; -} - -static uint8 MDDBG_ReadMemory8(uint32 address) -{ - std::vector::iterator bpit; - address &= 0xFFFFFF; - - for(bpit = BreakPointsRead.begin(); bpit != BreakPointsRead.end(); bpit++) - { - if(address >= bpit->A[0] && address <= bpit->A[1]) - { - FoundBPoint = TRUE; - break; - } - } - - - return(MD_ReadMemory8(address)); -} - -static uint16 MDDBG_ReadMemory16(uint32 address) -{ - std::vector::iterator bpit; - - address &= 0xFFFFFF; - - for(bpit = BreakPointsRead.begin(); bpit != BreakPointsRead.end(); bpit++) - { - if((address | 1) >= bpit->A[0] && address <= bpit->A[1]) - { - FoundBPoint = TRUE; - break; - } - } - - //printf("Read: %08x\n", address); - - return(MD_ReadMemory16(address)); -} - -static void MDDBG_WriteMemory8(uint32 address, uint8 value) -{ - std::vector::iterator bpit; - - address &= 0xFFFFFF; - - for(bpit = BreakPointsWrite.begin(); bpit != BreakPointsWrite.end(); bpit++) - { - if(address >= bpit->A[0] && address <= bpit->A[1]) - { - FoundBPoint = TRUE; - break; - } - } - - - -} - -static void MDDBG_WriteMemory16(uint32 address, uint16 value) -{ - std::vector::iterator bpit; - - address &= 0xFFFFFF; - - - for(bpit = BreakPointsWrite.begin(); bpit != BreakPointsWrite.end(); bpit++) - { - if((address | 1) >= bpit->A[0] && address <= bpit->A[1]) - { - FoundBPoint = TRUE; - break; - } - } - - -} - - - -bool MDDBG_Init(void) -{ - MDFNDBG_AddRegGroup(&M68K_RegsGroup); - - ASpace_Add(GetAddressSpaceBytes, PutAddressSpaceBytes, "cpu", "CPU Physical", 24); - ASpace_Add(GetAddressSpaceBytes, PutAddressSpaceBytes, "ram", "Work RAM", 16); - - - C68k_Init(&Main68K_BP, dbg_int_ack_callback); - - C68k_Set_TAS_Hack(&Main68K_BP, 1); - - C68k_Set_ReadB(&Main68K_BP, MDDBG_ReadMemory8); - C68k_Set_ReadW(&Main68K_BP, MDDBG_ReadMemory16); - - C68k_Set_WriteB(&Main68K_BP, MDDBG_WriteMemory8); - C68k_Set_WriteW(&Main68K_BP, MDDBG_WriteMemory16); - - MD_DebugMode = FALSE; - - return(TRUE); -} - -DebuggerInfoStruct DBGInfo = -{ - "shift_jis", - 10, // Max instruction size(bytes) - 2, // Instruction alignment(bytes) - 24, // Logical address bits - 24, // Physical address bits - 0xFF0000, // Default watch address - ~0U, // ZP - - MemPeek, - Disassemble, - NULL, - NULL, // IRQ, - NULL, // NESDBG_GetVector, - FlushBreakPoints, - AddBreakPoint, - SetCPUCallback, - SetBPCallback, - GetBranchTrace, - NULL, //SetGraphicsDecode, - NULL, //GetGraphicsDecodeBuffer, - NULL, //SetLogFunc, -}; - - - -}; diff --git a/libmednahawk/src/md/debug.h b/libmednahawk/src/md/debug.h deleted file mode 100644 index b6e793941c..0000000000 --- a/libmednahawk/src/md/debug.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __MDFN_MD_DEBUG_H -#define __MDFN_MD_DEBUG_H - -#ifdef WANT_DEBUGGER -namespace MDFN_IEN_MD -{ - - -extern DebuggerInfoStruct DBGInfo; -bool MDDBG_Init(void); -void MDDBG_CPUHook(void); - -extern bool MD_DebugMode; - - -}; - -#endif - -#endif diff --git a/libmednahawk/src/md/genesis.cpp b/libmednahawk/src/md/genesis.cpp deleted file mode 100644 index 1248d3753f..0000000000 --- a/libmednahawk/src/md/genesis.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#include "shared.h" - -namespace MDFN_IEN_MD -{ - -uint8 (*MD_ExtRead8)(uint32 address) = NULL; -uint16 (*MD_ExtRead16)(uint32 address) = NULL; -void (*MD_ExtWrite8)(uint32 address, uint8 value) = NULL; -void (*MD_ExtWrite16)(uint32 address, uint16 value) = NULL; - -uint8 *cart_rom = NULL; //[0x400000]; /* Cartridge ROM */ -uint8 work_ram[0x10000]; /* 68K work RAM */ -uint8 zram[0x2000]; /* Z80 work RAM */ -uint8 zbusreq; /* /BUSREQ from Z80 */ -uint8 zreset; /* /RESET to Z80 */ -uint8 zbusack; /* /BUSACK to Z80 */ -uint8 zirq; /* /IRQ to Z80 */ -uint32 zbank; /* Address of Z80 bank window */ - -uint8 gen_running; - -c68k_struc Main68K; -MDVDP MainVDP; - -/*--------------------------------------------------------------------------*/ -/* Init, reset, shutdown functions */ -/*--------------------------------------------------------------------------*/ -int vdp_int_ack_callback(int int_level) -{ - return(MainVDP.IntAckCallback(int_level)); -} - -void gen_init(void) -{ - C68k_Init(&Main68K, vdp_int_ack_callback); - C68k_Set_TAS_Hack(&Main68K, 1); - - C68k_Set_ReadB(&Main68K, MD_ReadMemory8); - C68k_Set_ReadW(&Main68K, MD_ReadMemory16); - - C68k_Set_WriteB(&Main68K, MD_WriteMemory8); - C68k_Set_WriteW(&Main68K, MD_WriteMemory16); -} - -void gen_reset(bool poweron) -{ - /* Clear RAM */ - if(poweron) - { - memset(work_ram, 0, sizeof(work_ram)); - memset(zram, 0, sizeof(zram)); - } - - gen_running = 1; - zreset = 0; /* Z80 is reset */ - zbusreq = 0; /* Z80 has control of the Z bus */ - zbusack = 1; /* Z80 is busy using the Z bus */ - zbank = 0; /* Assume default bank is 000000-007FFF */ - zirq = 0; /* No interrupts occuring */ - - if(poweron) - { - gen_io_reset(); - } - - C68k_Reset(&Main68K); - z80_reset(); -} - -void gen_shutdown(void) -{ - -} - -/*--------------------------------------------------------------------------*/ -/* Bus controller chip functions */ -/*--------------------------------------------------------------------------*/ - -int gen_busack_r(void) -{ - //printf("busack_r: %d, %d\n", zbusack, md_timestamp); - return (zbusack & 1); -} - -void gen_busreq_w(int state) -{ - //printf("BUSREQ: %d, %d, %d\n", state, md_timestamp, scanline); - zbusreq = (state & 1); - zbusack = 1 ^ (zbusreq & zreset); -} - -void gen_reset_w(int state) -{ - //printf("ZRESET: %d, %d\n", state, md_timestamp); - zreset = (state & 1); - zbusack = 1 ^ (zbusreq & zreset); - - MDSound_SetYM2612Reset(!zreset); - - if(zreset == 0) - { - z80_reset(); - } -} - - -void gen_bank_w(int state) -{ - zbank = ((zbank >> 1) | ((state & 1) << 23)) & 0xFF8000; -} - -} diff --git a/libmednahawk/src/md/genesis.h b/libmednahawk/src/md/genesis.h deleted file mode 100644 index c3a16ba73e..0000000000 --- a/libmednahawk/src/md/genesis.h +++ /dev/null @@ -1,42 +0,0 @@ - -#ifndef _GENESIS_H_ -#define _GENESIS_H_ - -namespace MDFN_IEN_MD -{ - -extern uint8 (*MD_ExtRead8)(uint32 address); -extern uint16 (*MD_ExtRead16)(uint32 address); -extern void (*MD_ExtWrite8)(uint32 address, uint8 value); -extern void (*MD_ExtWrite16)(uint32 address, uint16 value); - -class MDVDP; - -/* Global variables */ -extern uint8 *cart_rom; //[0x400000]; -extern uint8 work_ram[0x10000]; -extern uint8 zram[0x2000]; -extern uint8 zbusreq; -extern uint8 zbusack; -extern uint8 zreset; -extern uint8 zirq; -extern uint32 zbank; -extern uint8 gen_running; -extern c68k_struc Main68K; -extern MDVDP MainVDP; - -/* Function prototypes */ -void gen_init(void); -void gen_reset(bool poweron); -void gen_shutdown(void); -int gen_busack_r(void); -void gen_busreq_w(int state); -void gen_reset_w(int state); -void gen_bank_w(int state); -int z80_irq_callback(int param); -void m68k_irq_ack_callback(int int_level); - -} - -#endif /* _GEN_H_ */ - diff --git a/libmednahawk/src/md/genio.cpp b/libmednahawk/src/md/genio.cpp deleted file mode 100644 index a9d6badeb9..0000000000 --- a/libmednahawk/src/md/genio.cpp +++ /dev/null @@ -1,401 +0,0 @@ -/* - genio.c - I/O controller chip emulation -*/ - -#include "shared.h" -#include "input/gamepad.h" -#include "input/mouse.h" - -namespace MDFN_IEN_MD -{ - -static bool is_pal; -static bool is_overseas; -static bool is_overseas_reported; -static bool is_pal_reported; - -// 3 internal ports -enum port_names {PORT_A = 0, PORT_B, PORT_C, PORT_MAX}; -enum device_names {DEVICE_NONE = 0, DEVICE_MS2B, DEVICE_MD3B, DEVICE_MD6B, DEVICE_MM}; - -static void SetDevice(int i, int type); - -static MD_Input_Device *port[PORT_MAX] = { NULL }; - -static InputDeviceInfoStruct InputDeviceInfo[] = -{ - // None - { - "none", - "none", - NULL, - NULL, - 0, - NULL - }, - - { - "gamepad2", - "2-Button Gamepad", - NULL, - NULL, - sizeof(Gamepad2IDII) / sizeof(InputDeviceInputInfoStruct), - Gamepad2IDII, - }, - - { - "gamepad", - "3-Button Gamepad", - NULL, - NULL, - sizeof(GamepadIDII) / sizeof(InputDeviceInputInfoStruct), - GamepadIDII, - }, - - { - "gamepad6", - "6-Button Gamepad", - NULL, - NULL, - sizeof(Gamepad6IDII) / sizeof(InputDeviceInputInfoStruct), - Gamepad6IDII, - }, - - { - "megamouse", - "Sega Mega Mouse", - NULL, - NULL, - sizeof(MegaMouseIDII) / sizeof(InputDeviceInputInfoStruct), - MegaMouseIDII, - }, - -}; - -static const InputPortInfoStruct PortInfo[] = -{ - { "port1", "Port 1", sizeof(InputDeviceInfo) / sizeof(InputDeviceInfoStruct), InputDeviceInfo, "gamepad" }, - { "port2", "Port 2", sizeof(InputDeviceInfo) / sizeof(InputDeviceInfoStruct), InputDeviceInfo, "gamepad" } -}; - -InputInfoStruct MDInputInfo = -{ - sizeof(PortInfo) / sizeof(InputPortInfoStruct), - PortInfo -}; - -static void UpdateBusThing(const int32 master_timestamp); - -void MDIO_Init(bool overseas, bool PAL, bool overseas_reported, bool PAL_reported) -{ - is_overseas = overseas; - is_pal = PAL; - is_overseas_reported = overseas_reported; - is_pal_reported = PAL_reported; - - for(int i = 0; i < PORT_MAX; i++) - SetDevice(i, DEVICE_NONE); - - UpdateBusThing(md_timestamp); -} - -static uint8 PortData[3]; -static uint8 PortDataBus[3]; -static uint8 PortCtrl[3]; -static uint8 PortTxData[3]; -static uint8 PortSCtrl[3]; - -static void UpdateBusThing(const int32 master_timestamp) -{ - for(int i = 0; i < PORT_MAX; i++) - { - PortDataBus[i] &= ~PortCtrl[i]; - PortDataBus[i] |= PortData[i] & PortCtrl[i]; - port[i]->UpdateBus(master_timestamp, PortDataBus[i], PortCtrl[i] & 0x7F); - } -} - - -void gen_io_reset(void) -{ - for(int i = 0; i < 3; i++) - { - PortDataBus[i] = 0x7F; - PortData[i] = 0x00; - PortCtrl[i] = 0x00; - PortTxData[i] = 0xFF; - PortSCtrl[i] = 0x00; - - port[i]->Power(); // Should be called before Write(...) - } - PortTxData[2] = 0xFB; - - UpdateBusThing(0); -} - -/*--------------------------------------------------------------------------*/ -/* I/O chip functions */ -/*--------------------------------------------------------------------------*/ - -void gen_io_w(int offset, int value) -{ - //printf("I/O Write: %04x:%04x, %d @ %08x\n", offset, value, md_timestamp, C68k_Get_PC(&Main68K)); - - switch(offset) - { - case 0x01: /* Port A Data */ - case 0x02: /* Port B Data */ - case 0x03: /* Port C Data */ - { - int wp = offset - 0x01; - PortData[wp] = value; - } - UpdateBusThing(md_timestamp); - break; - - case 0x04: /* Port A Ctrl */ - case 0x05: /* Port B Ctrl */ - case 0x06: /* Port C Ctrl */ - { - int wp = offset - 0x04; - - PortCtrl[wp] = value; - } - UpdateBusThing(md_timestamp); - break; - - case 0x07: /* Port A TxData */ - case 0x0A: /* Port B TxData */ - case 0x0D: /* Port C TxData */ - PortTxData[(offset - 0x07) / 3] = value; - break; - - case 0x09: /* Port A S-Ctrl */ - case 0x0C: /* Port B S-Ctrl */ - case 0x0F: /* Port C S-Ctrl */ - PortSCtrl[(offset - 0x09) / 3] = value & 0xF8; - break; - } -} - -int gen_io_r(int offset) -{ - uint8 ret; - uint8 temp; - uint8 has_scd = MD_IsCD ? 0x00 : 0x20; - uint8 gen_ver = 0x00; /* Version 0 hardware */ - - switch(offset) - { - default: - ret = 0x00; - printf("Unmapped I/O Read: %04x\n", offset); - break; - - case 0x00: /* Version */ - temp = 0x00; - if(is_overseas_reported) - temp |= 0x80; - if(is_pal_reported) - temp |= 0x40; - ret = (temp | has_scd | gen_ver); - break; - - case 0x01: /* Port A Data */ - case 0x02: /* Port B Data */ - case 0x03: /* Port C Data */ - { - int wp = offset - 0x01; - - UpdateBusThing(md_timestamp); - ret = (PortDataBus[wp] & 0x7F) | (PortCtrl[wp] & 0x80); - } - break; - - case 0x04: /* Port A Ctrl */ - case 0x05: /* Port B Ctrl */ - case 0x06: /* Port C Ctrl */ - ret = PortCtrl[offset - 0x04]; - break; - - case 0x07: /* Port A TxData */ - case 0x0A: /* Port B TxData */ - case 0x0D: /* Port C TxData */ - ret = PortTxData[(offset - 0x07) / 3]; - break; - - case 0x09: /* Port A S-Ctrl */ - case 0x0C: /* Port B S-Ctrl */ - case 0x0F: /* Port C S-Ctrl */ - ret = PortSCtrl[(offset - 0x09) / 3]; - break; - } - - //printf("I/O Read: %04x ret=%02x, %d @ %08x\n", offset, ret, md_timestamp, C68k_Get_PC(&Main68K)); - - return(ret); -} - - -void MDIO_BeginTimePeriod(const int32 timestamp_base) -{ - for(int i = 0; i < 3; i++) - port[i]->BeginTimePeriod(timestamp_base); -} - -void MDIO_EndTimePeriod(const int32 master_timestamp) -{ - for(int i = 0; i < 3; i++) - port[i]->EndTimePeriod(master_timestamp); -} - - -/*--------------------------------------------------------------------------*/ -/* Null device */ -/*--------------------------------------------------------------------------*/ -MD_Input_Device::MD_Input_Device() -{ - -} - -MD_Input_Device::~MD_Input_Device() -{ - - -} - -void MD_Input_Device::Power(void) -{ - -} - -void MD_Input_Device::UpdateBus(const int32 master_timestamp, uint8 &bus, const uint8 genesis_asserted) -{ -// printf("%02x -- %02x\n", bus, genesis_asserted); -// bus |= 0x3F &~ genesis_asserted; -// bus &= genesis_asserted; -} - -void MD_Input_Device::UpdatePhysicalState(const void *data) -{ - -} - -void MD_Input_Device::BeginTimePeriod(const int32 timestamp_base) -{ - -} - -void MD_Input_Device::EndTimePeriod(const int32 master_timestamp) -{ - -} - - -int MD_Input_Device::StateAction(StateMem *sm, int load, int data_only, const char *section_prefix) -{ - return(1); -} - - -static void SetDevice(int i, int type) -{ - if(port[i]) - delete port[i]; - - switch(type) - { - case DEVICE_NONE: - port[i] = new MD_Input_Device(); - break; - - case DEVICE_MS2B: - port[i] = MDInput_MakeMS2B(); - break; - - case DEVICE_MD3B: - port[i] = MDInput_MakeMD3B(); - break; - - case DEVICE_MD6B: - port[i] = MDInput_MakeMD6B(); - break; - - case DEVICE_MM: - port[i] = MDInput_MakeMegaMouse(); - break; - } - - port[i]->Power(); -} - -static void *data_ptr[8]; - -void MDINPUT_Frame(void) -{ - for(int i = 0; i < 2; i++) - { - port[i]->UpdatePhysicalState(data_ptr[i]); - } -} - -void MDINPUT_SetInput(int aport, const char *type, void *ptr) -{ - int itype = 0; - - if(!strcasecmp(type, "none")) - { - itype = DEVICE_NONE; - } - if(!strcasecmp(type, "gamepad")) - { - itype = DEVICE_MD3B; - } - else if(!strcasecmp(type, "gamepad6")) - { - itype = DEVICE_MD6B; - } - else if(!strcasecmp(type, "gamepad2")) - { - itype = DEVICE_MS2B; - } - else if(!strcasecmp(type, "megamouse")) - { - itype = DEVICE_MM; - } - - data_ptr[aport] = ptr; - SetDevice(aport, itype); - - UpdateBusThing(md_timestamp); -} - -int MDINPUT_StateAction(StateMem *sm, int load, int data_only) -{ - SFORMAT StateRegs[] = - { - SFARRAY(PortData, 3), - SFARRAY(PortCtrl, 3), - SFARRAY(PortTxData, 3), - SFARRAY(PortSCtrl, 3), - - SFARRAY(PortDataBus, 3), - SFEND - }; - - int ret = MDFNSS_StateAction(sm, load, data_only, StateRegs, "IO"); - - ret &= port[0]->StateAction(sm, load, data_only, "PRTA"); - ret &= port[1]->StateAction(sm, load, data_only, "PRTB"); - ret &= port[2]->StateAction(sm, load, data_only, "PRTC"); - - if(load) - { - - } - return(ret); -} - - -} diff --git a/libmednahawk/src/md/genio.h b/libmednahawk/src/md/genio.h deleted file mode 100644 index 0c1794ab26..0000000000 --- a/libmednahawk/src/md/genio.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __MDFN_MD_GENIO_H -#define __MDFN_MD_GENIO_H - -namespace MDFN_IEN_MD -{ - -/* Function prototypes */ -extern void gen_io_reset(void); -extern void gen_io_w(int offset, int value); -extern int gen_io_r(int offset); - -extern void gen_io_update(void); -extern void gen_io_set_device(int which, int type); - -void MDIO_BeginTimePeriod(const int32 timestamp_base); -void MDIO_EndTimePeriod(const int32 master_timestamp); - -void MDIO_Init(bool overseas, bool PAL, bool overseas_reported, bool PAL_reported); - -void MDINPUT_Frame(void); -void MDINPUT_SetInput(int port, const char *type, void *ptr); - -extern InputInfoStruct MDInputInfo; - -class MD_Input_Device -{ - public: - MD_Input_Device(); - virtual ~MD_Input_Device(); - - virtual void Power(void); - - // genesis_asserted is intended for more accurately emulating a device that has pull-up or pull-down resistors - // on one or more data lines. - virtual void UpdateBus(const int32 master_timestamp, uint8 &bus, const uint8 genesis_asserted); // genesis_asserted should - virtual void UpdatePhysicalState(const void *data); - virtual void BeginTimePeriod(const int32 timestamp_base); - virtual void EndTimePeriod(const int32 master_timestamp); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_prefix); -}; - -int MDINPUT_StateAction(StateMem *sm, int load, int data_only); - -} - -#endif - diff --git a/libmednahawk/src/md/hcnt.h b/libmednahawk/src/md/hcnt.h deleted file mode 100644 index 2968a5f851..0000000000 --- a/libmednahawk/src/md/hcnt.h +++ /dev/null @@ -1,69 +0,0 @@ -static const uint8 cycle2hc32[488] = -{ - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, - 0x05, 0x05, 0x06, 0x06, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0A, - 0x0B, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x10, 0x10, - 0x10, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x14, 0x14, 0x15, 0x15, 0x15, 0x16, - 0x16, 0x16, 0x17, 0x17, 0x17, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, - 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x21, - 0x21, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, - 0x27, 0x27, 0x27, 0x28, 0x28, 0x29, 0x29, 0x29, 0x2A, 0x2A, 0x2A, 0x2B, 0x2B, 0x2B, 0x2C, 0x2C, - 0x2C, 0x2D, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x2F, 0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x32, - 0x32, 0x32, 0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35, 0x36, 0x36, 0x36, 0x37, 0x37, 0x37, - 0x38, 0x38, 0x38, 0x39, 0x39, 0x39, 0x3A, 0x3A, 0x3A, 0x3B, 0x3B, 0x3B, 0x3C, 0x3C, 0x3D, 0x3D, - 0x3D, 0x3E, 0x3E, 0x3E, 0x3F, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, - 0x43, 0x43, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47, 0x47, 0x48, 0x48, - 0x48, 0x49, 0x49, 0x4A, 0x4A, 0x4A, 0x4B, 0x4B, 0x4B, 0x4C, 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4E, - 0x4E, 0x4E, 0x4F, 0x4F, 0x4F, 0x50, 0x50, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, - 0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0x57, 0x58, 0x58, 0x58, 0x59, 0x59, - 0x59, 0x5A, 0x5A, 0x5A, 0x5B, 0x5B, 0x5B, 0x5C, 0x5C, 0x5C, 0x5D, 0x5D, 0x5E, 0x5E, 0x5E, 0x5F, - 0x5F, 0x5F, 0x60, 0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 0x63, 0x63, 0x63, 0x64, 0x64, - 0x65, 0x65, 0x65, 0x66, 0x66, 0x66, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68, 0x69, 0x69, 0x69, 0x6A, - 0x6A, 0x6A, 0x6B, 0x6B, 0x6C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6D, 0x6E, 0x6E, 0x6E, 0x6F, 0x6F, 0x6F, - 0x70, 0x70, 0x70, 0x71, 0x71, 0x72, 0x72, 0x72, 0x73, 0x73, 0x73, 0x74, 0x74, 0x74, 0x75, 0x75, - 0x75, 0x76, 0x76, 0x76, 0x77, 0x77, 0x77, 0x78, 0x78, 0x79, 0x79, 0x79, 0x7A, 0x7A, 0x7A, 0x7B, - 0x7B, 0x7B, 0x7C, 0x7C, 0x7C, 0x7D, 0x7D, 0x7D, 0x7E, 0x7E, 0x7E, 0x7F, 0x7F, 0x80, 0x80, 0x80, - 0x81, 0x81, 0x81, 0x82, 0x82, 0x82, 0x83, 0x83, 0x83, 0x84, 0x84, 0x84, 0x85, 0x85, 0x85, 0x86, - 0x86, 0x87, 0x87, 0x87, 0x88, 0x88, 0x88, 0x89, 0x89, 0x89, 0x8A, 0x8A, 0x8A, 0x8B, 0x8B, 0x8B, - 0x8C, 0x8C, 0x8D, 0x8D, 0x8D, 0x8E, 0x8E, 0x8E, 0x8F, 0x8F, 0x8F, 0x90, 0x90, 0x90, 0x91, 0x91, - 0x91, 0x92, 0x92, 0x92, 0x93, 0x93, 0xE9, 0xE9, 0xE9, 0xEA, 0xEA, 0xEA, 0xEB, 0xEB, 0xEB, 0xEC, - 0xEC, 0xEC, 0xED, 0xED, 0xED, 0xEE, 0xEE, 0xEE, 0xEF, 0xEF, 0xF0, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, - 0xF2, 0xF2, 0xF2, 0xF3, 0xF3, 0xF3, 0xF4, 0xF4, 0xF4, 0xF5, 0xF5, 0xF6, 0xF6, 0xF6, 0xF7, 0xF7, - 0xF7, 0xF8, 0xF8, 0xF8, 0xF9, 0xF9, 0xF9, 0xFA, 0xFA, 0xFA, 0xFB, 0xFB, 0xFB, 0xFC, 0xFC, 0xFD, - 0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, -}; - -static const uint8 cycle2hc40[488] = -{ - 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, - 0x06, 0x07, 0x07, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0D, - 0x0D, 0x0E, 0x0E, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x11, 0x11, 0x12, 0x12, 0x13, 0x13, 0x13, 0x14, - 0x14, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17, 0x18, 0x18, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1B, - 0x1B, 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1E, 0x1E, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, - 0x22, 0x23, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25, 0x26, 0x26, 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, - 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, - 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x33, 0x34, 0x34, 0x35, 0x35, 0x36, 0x36, 0x36, - 0x37, 0x37, 0x38, 0x38, 0x39, 0x39, 0x39, 0x3A, 0x3A, 0x3B, 0x3B, 0x3C, 0x3C, 0x3D, 0x3D, 0x3D, - 0x3E, 0x3E, 0x3F, 0x3F, 0x40, 0x40, 0x40, 0x41, 0x41, 0x42, 0x42, 0x43, 0x43, 0x43, 0x44, 0x44, - 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x49, 0x49, 0x4A, 0x4A, 0x4A, 0x4B, 0x4B, - 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4E, 0x4E, 0x4F, 0x4F, 0x50, 0x50, 0x50, 0x51, 0x51, 0x52, 0x52, - 0x53, 0x53, 0x53, 0x54, 0x54, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0x57, 0x58, 0x58, 0x59, 0x59, - 0x5A, 0x5A, 0x5A, 0x5B, 0x5B, 0x5C, 0x5C, 0x5D, 0x5D, 0x5D, 0x5E, 0x5E, 0x5F, 0x5F, 0x60, 0x60, - 0x60, 0x61, 0x61, 0x62, 0x62, 0x63, 0x63, 0x63, 0x64, 0x64, 0x65, 0x65, 0x66, 0x66, 0x67, 0x67, - 0x67, 0x68, 0x68, 0x69, 0x69, 0x6A, 0x6A, 0x6A, 0x6B, 0x6B, 0x6C, 0x6C, 0x6D, 0x6D, 0x6D, 0x6E, - 0x6E, 0x6F, 0x6F, 0x70, 0x70, 0x70, 0x71, 0x71, 0x72, 0x72, 0x73, 0x73, 0x73, 0x74, 0x74, 0x75, - 0x75, 0x76, 0x76, 0x77, 0x77, 0x77, 0x78, 0x78, 0x79, 0x79, 0x7A, 0x7A, 0x7A, 0x7B, 0x7B, 0x7C, - 0x7C, 0x7D, 0x7D, 0x7D, 0x7E, 0x7E, 0x7F, 0x7F, 0x80, 0x80, 0x80, 0x81, 0x81, 0x82, 0x82, 0x83, - 0x83, 0x84, 0x84, 0x84, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x87, 0x88, 0x88, 0x89, 0x89, 0x8A, - 0x8A, 0x8A, 0x8B, 0x8B, 0x8C, 0x8C, 0x8D, 0x8D, 0x8D, 0x8E, 0x8E, 0x8F, 0x8F, 0x90, 0x90, 0x90, - 0x91, 0x91, 0x92, 0x92, 0x93, 0x93, 0x94, 0x94, 0x94, 0x95, 0x95, 0x96, 0x96, 0x97, 0x97, 0x97, - 0x98, 0x98, 0x99, 0x99, 0x9A, 0x9A, 0x9A, 0x9B, 0x9B, 0x9C, 0x9C, 0x9D, 0x9D, 0x9D, 0x9E, 0x9E, - 0x9F, 0x9F, 0xA0, 0xA0, 0xA1, 0xA1, 0xA1, 0xA2, 0xA2, 0xA3, 0xA3, 0xA4, 0xA4, 0xA4, 0xA5, 0xA5, - 0xA6, 0xA6, 0xA7, 0xA7, 0xA7, 0xA8, 0xA8, 0xA9, 0xA9, 0xAA, 0xAA, 0xAA, 0xAB, 0xAB, 0xAC, 0xAC, - 0xAD, 0xAD, 0xAD, 0xAE, 0xAE, 0xAF, 0xAF, 0xB0, 0xB0, 0xB1, 0xB1, 0xB1, 0xB2, 0xB2, 0xB3, 0xB3, - 0xB4, 0xB4, 0xB4, 0xB5, 0xB5, 0xB6, 0xB6, 0xE4, 0xE4, 0xE4, 0xE5, 0xE5, 0xE6, 0xE6, 0xE7, 0xE7, - 0xE7, 0xE8, 0xE8, 0xE9, 0xE9, 0xEA, 0xEA, 0xEB, 0xEB, 0xEB, 0xEC, 0xEC, 0xED, 0xED, 0xEE, 0xEE, - 0xEE, 0xEF, 0xEF, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xF2, 0xF2, 0xF3, 0xF3, 0xF4, 0xF4, 0xF4, 0xF5, - 0xF5, 0xF6, 0xF6, 0xF7, 0xF7, 0xF7, 0xF8, 0xF8, 0xF9, 0xF9, 0xFA, 0xFA, 0xFB, 0xFB, 0xFB, 0xFC, - 0xFC, 0xFD, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, -}; diff --git a/libmednahawk/src/md/header.cpp b/libmednahawk/src/md/header.cpp deleted file mode 100644 index 829f0ccff8..0000000000 --- a/libmednahawk/src/md/header.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "shared.h" -#include "header.h" -#include "../general.h" -#include - -namespace MDFN_IEN_MD -{ - -typedef struct -{ - uint8 ascii; - uint8 numeric; -} region_lut_t; - -static const region_lut_t region_lut[] = -{ - { 0xFF, 0x1 }, - { 0x00, 0x1 }, - { 0xd4, 0x1 }, - - { 4, 0x4 }, // Silly Toy Story - - { ' ', 0x1 }, // Assume Japanese - { 'J', 0x1 }, - { 'U', 0x4 }, - { 'E', 0x8 }, - - { '0', 0x0 }, - { '1', 0x1 }, - { '2', 0x2 }, - { '3', 0x3 }, - { '4', 0x4 }, - { '5', 0x5 }, - { '6', 0x6 }, - { '7', 0x7 }, - { '8', 0x8 }, - { '9', 0x9 }, - { 'A', 0xa }, - { 'B', 0xb }, - { 'C', 0xc }, - { 'D', 0xd }, - { 'E', 0xe }, - { 'F', 0xf } -}; - -static uint8 get_region_numeric(uint8 code) -{ - code = toupper(code); - - for(int i = 0; i < sizeof(region_lut) / sizeof(region_lut_t); i++) - { - if(region_lut[i].ascii == code) - { - return(region_lut[i].numeric); - } - } - - printf("Unknown region code: %c %02x\n", code, code); - //exit(1); - - return(0x0); -} - -void MD_ReadSegaHeader(const uint8 *header, md_game_info *ginfo) -{ - ginfo->rom_size = 0; //fp->size; - - memcpy(ginfo->copyright, header + 0x10, 16); - ginfo->copyright[16] = 0; - MDFN_RemoveControlChars(ginfo->copyright); - - memcpy(ginfo->domestic_name, header + 0x20, 0x30); - ginfo->domestic_name[0x30] = 0; - MDFN_RemoveControlChars(ginfo->domestic_name); - - memcpy(ginfo->overseas_name, header + 0x50, 0x30); - ginfo->overseas_name[0x30] = 0; - MDFN_RemoveControlChars(ginfo->overseas_name); - - memcpy(ginfo->product_code, header + 0x82, 0x0C); - ginfo->product_code[0xC] = 0; - MDFN_RemoveControlChars(ginfo->product_code); - MDFN_trim(ginfo->product_code); - - ginfo->checksum = (header[0x8E] << 8) | (header[0x8F] << 0); - - for(int i = 0; i < 16; i++) - { - for(unsigned int iot = 0; iot < sizeof(IO_types) / sizeof(IO_type_t); iot++) - { - if(IO_types[iot].code_char == header[0x90 + i]) - { - ginfo->io_support |= 1 << IO_types[iot].id; - break; - } - } - } - - ginfo->region_support = get_region_numeric(header[0xF0]); -} - - -} diff --git a/libmednahawk/src/md/header.h b/libmednahawk/src/md/header.h deleted file mode 100644 index 7ec3d4fbdc..0000000000 --- a/libmednahawk/src/md/header.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef __MDFN_MD_HEADER_H -#define __MDFN_MD_HEADER_H - -namespace MDFN_IEN_MD -{ - -enum -{ - REGIONMASK_JAPAN_NTSC = 1, - REGIONMASK_JAPAN_PAL = 2, - REGIONMASK_OVERSEAS_NTSC = 4, - REGIONMASK_OVERSEAS_PAL = 8 -}; - -enum -{ - IOS_GAMEPAD = 0, - IOS_GAMEPAD6B, - IOS_KEYBOARD, - IOS_PRINTER, - IOS_BALL, - IOS_FLOPPY, - IOS_ACTIVATOR, - IOS_TEAM_PLAY, - IOS_GAMEPAD_MS, - IOS_RS232C, - IOS_TABLET, - IOS_PADDLE, - IOS_CDROM, - IOS_MEGA_MOUSE -}; - -typedef struct -{ - const int id; - const char code_char; - const char *name; -} IO_type_t; - -static const IO_type_t IO_types[] = -{ - { IOS_GAMEPAD, 'J', "3-Button Gamepad" }, - { IOS_GAMEPAD6B, '6', "6-Button Gamepad" }, - { IOS_KEYBOARD, 'K', "Keyboard" }, - { IOS_PRINTER, 'P', "Printer" }, - { IOS_BALL, 'B', "Ball Controller" }, - { IOS_FLOPPY, 'F', "Floppy disk drive" }, - { IOS_ACTIVATOR, 'L', "Activator" }, - { IOS_TEAM_PLAY, '4', "Team Play" }, - { IOS_GAMEPAD_MS, '0', "2-Button Master System Gamepad" }, - { IOS_RS232C, 'R', "RS232C Serial Port" }, - { IOS_TABLET, 'T', "Tablet" }, - { IOS_PADDLE, 'V', "Paddle Controller" }, - { IOS_CDROM, 'C', "CD-ROM" }, - { IOS_MEGA_MOUSE, 'M', "Mega Mouse" }, -}; - -typedef struct -{ - uint32 rom_size; - - uint32 io_support; - char copyright[0x10 + 1]; - char domestic_name[0x30 + 1]; - char overseas_name[0x30 + 1]; - char product_code[0xC + 1]; - uint16 checksum; // Recorded game checksum - uint8 region_support; - - uint32 sram_type; - uint32 sram_start; - uint32 sram_end; - - // Convenience, not set by the header parsing code: - uint8 md5[16]; - uint8 info_header_md5[16]; - uint16 checksum_real; -} md_game_info; - -void MD_ReadSegaHeader(const uint8 *header, md_game_info *ginfo); - -} - -#endif diff --git a/libmednahawk/src/md/hvc.h b/libmednahawk/src/md/hvc.h deleted file mode 100644 index f5e787d031..0000000000 --- a/libmednahawk/src/md/hvc.h +++ /dev/null @@ -1,817 +0,0 @@ -/*************************************************************************************** - * Genesis Plus - * HV Counters - * - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald - * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - ****************************************************************************************/ - -/* - NTSC, 256x192 - ------------- - - Lines Description - - 192 Active display - 24 Bottom border - 3 Bottom blanking - 3 Vertical blanking - 13 Top blanking - 27 Top border - - V counter values - 00-DA, D5-FF - - NTSC, 256x224 - ------------- - - Lines Description - - 224 Active display - 8 Bottom border - 3 Bottom blanking - 3 Vertical blanking - 13 Top blanking - 11 Top border - - V counter values - 00-EA, E5-FF - - NTSC, 256x240 - ------------- - - This mode does not work on NTSC machines. All 30 rows of the name table are - displayed, there is no border, blanking, or retrace period, and the next - frame starts after the 30th row. The display rolls continuously though it - can be stabilized by adjusting the vertical hold. - - V counter values - 00-FF, 00-06 - - PAL, 256x192 - ------------ - - Lines Description - - 192 Active display - 48 Bottom border - 3 Bottom blanking - 3 Vertical blanking - 13 Top blanking - 54 Top border - - V counter values - 00-F2, BA-FF - - PAL, 256x224 - ------------ - - Lines Description - - 224 Active display - 32 Bottom border - 3 Bottom blanking - 3 Vertical blanking - 13 Top blanking - 38 Top border - - V counter values - 00-FF, 00-02, CA-FF - - PAL, 256x240 - ------------ - - Lines Description - - 240 Active display - 24 Bottom border - 3 Bottom blanking - 3 Vertical blanking - 13 Top blanking - 30 Top border - - V counter values - 00-FF, 00-0A, D2-FF - - Here are some details about what the different screen areas look like, - useful if you are emulating overscan or if you want to have a 'virtual' - vertical hold control in your emulator. - - Active display - Where the display generated by the VDP goes. - Bottom border - Filled with border color from VDP register #7. - Bottom blanking - Filled with a light black color. (like display was blanked) - Vertical sync - Filled with a pure black color. (like display was turned off) - Top blanking - Filled with a light black color. (like display was blanked) - Top border - Filled with the border color from VDP register #7. - -*/ -#ifndef _HVC_H_ -#define _HVC_H_ - -/***************************************************************/ -/* */ -/* H-counter timings in H32 & H40 modes (starts from HINT) */ -/* */ -/* There are exactly 3420 Master Clock counts per raster line. */ -/* */ -/* in H32 mode, dot clock is divided from MCLK (MCLK/10). */ -/* in H40 mode, dot clock is divided from EDCLK (EDCLK/2). */ -/* */ -/* EDCLK (external dot clock ?) is generated outside the VDP: */ -/* During HSYNC, it is oscillating between MCLK/10 and MCLK/8, */ -/* otherwise it is fixed to MCLK/8. */ -/* */ -/***************************************************************/ - -static const uint8 cycle2hc32[3420] = -{ - /* end of active display (16 pixels -> 160 Mcycles) , H interrupt triggered, Vcounter increment */ - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, - - /* right border (14 pixels -> 140 Mcycles) */ - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - - /* right blanking (9 pixels -> 90 Mcycles) , VDP status HBLANK flag set */ - 0xe9, 0xe9, 0xe9, 0xe9, - 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, - 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, - 0xea, 0xea, 0xea, 0xea, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, - 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, - 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xed, 0xed, 0xed, 0xed, - 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, - - /* horizontal sync (26 pixels -> 260 Mcycles) */ - 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, - 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, - 0xee, 0xee, 0xee, 0xee, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, - 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf1, 0xf1, 0xf1, 0xf1, - 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, - 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, - 0xf2, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, - 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, - 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf5, - 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, - 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, - 0xf6, 0xf6, 0xf6, 0xf6, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, - 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, - 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, - - /* left blanking (24 pixels -> 240 Mcycles) */ - 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, - 0xfa, 0xfa, 0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, - 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, - 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfd, 0xfd, 0xfd, 0xfd, - 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, - /* V interrupt triggered (MD mode) */ - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - - /* left border (13 pixels -> 130 Mcycles) , VDP status HBLANK flag cleared */ - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, - 0x0a, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - - /* remaining active display (240 pixels -> 2400 Mcycles) */ - 0x0d, 0x0d, 0x0d, 0x0d, - 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, - 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, - 0x0e, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, - 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, - 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, - 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, - 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, - 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, - 0x1a, 0x1a, 0x1a, 0x1a, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, - 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, - 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d, 0x1d, 0x1d, - 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, - 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, - 0x1e, 0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, - 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, - 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, - 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, - 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x25, 0x25, 0x25, 0x25, - 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, - 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, - 0x26, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, - 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, - 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x29, - 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, - 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a, 0x2a, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, - 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, - 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, - 0x2e, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, - 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x31, - 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, - 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, - 0x32, 0x32, 0x32, 0x32, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, - 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, - 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x35, 0x35, 0x35, 0x35, - 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, - 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, - 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x39, 0x39, 0x39, 0x39, - 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, - 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, - 0x3a, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, - 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, - 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3d, - 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, - 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, - 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, - 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, - 0x42, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, - 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x45, - 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, - 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x46, 0x46, 0x46, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, - 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, - 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, - 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, - 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, - 0x4a, 0x4a, 0x4a, 0x4a, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, - 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, - 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x4d, - 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, - 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, - 0x4e, 0x4e, 0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, - 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, - 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x51, 0x51, 0x51, 0x51, - 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, - 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, - 0x52, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, - 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, - 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x55, - 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, - 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, - 0x56, 0x56, 0x56, 0x56, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, - 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, - 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x59, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, - 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, - 0x5a, 0x5a, 0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, - 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, - 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5d, 0x5d, 0x5d, 0x5d, - 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, - 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, - 0x5e, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, - 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x61, 0x61, 0x61, 0x61, - 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, - 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, - 0x62, 0x62, 0x62, 0x62, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, - 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, - 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x65, 0x65, 0x65, 0x65, - 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, - 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, - 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x69, 0x69, 0x69, 0x69, - 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, - 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, - 0x6a, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, - 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6d, 0x6d, 0x6d, 0x6d, - 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, - 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, - 0x6e, 0x6e, 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, - 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, - 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, - 0x72, 0x72, 0x72, 0x72, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, - 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, - 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x75, 0x75, 0x75, 0x75, - 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, - 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, - 0x76, 0x76, 0x76, 0x76, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x79, 0x79, 0x79, 0x79, - 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, - 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, - 0x7a, 0x7a, 0x7a, 0x7a, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, - 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, - 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7d, 0x7d, 0x7d, 0x7d, - 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, - 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, - 0x7e, 0x7e, 0x7e, 0x7e, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, - 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, -}; - -static const uint8 cycle2hc40[3420] = -{ - /* end of active display (16 pixels -> 128 Mcycles) , HINT triggered , Vcounter increment */ - 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, - 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, 0xa7, - 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, 0xa9, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, - 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, - - /* right border (14 pixels -> 112 Mcycles) */ - 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, - 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, 0xae, - 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, - 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, 0xb0, - 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, 0xb1, - 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, 0xb2, - 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, - - /* right blanking (9 pixels -> 72 Mcycles) , VDP status HBLANK flag set */ - 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, - 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, - 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xb6, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, - 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, 0xe5, - 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, - - /* horizontal sync (32 pixels -> 313 Mcycles) */ - 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, 0xe6, - 0xe6, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, - 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, - 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, - 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea, - 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea, 0xeb, - 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, 0xeb, - 0xeb, 0xeb, 0xeb, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, - 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xec, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, - 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xed, 0xee, 0xee, 0xee, 0xee, 0xee, - 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xef, 0xef, - 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, - 0xef, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, - 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, - 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3, 0xf3, - 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xf4, - 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, 0xf4, - 0xf4, 0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, - 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, - 0xf6, - - /* left blanking (32 pixels -> 259 Mcycles) */ - 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf6, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, - 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0xf8, 0xf8, - 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xfa, 0xfa, 0xfa, 0xfa, - 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfb, - 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc, 0xfc, - 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfd, 0xfd, 0xfd, 0xfd, - 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - /* Vertical Interrupt triggered */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, - - /* left border (13 pixels -> 104 Mcycles) , VDP status HBLANK flag cleared */ - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0a, - 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - - /* remaining active display (304 pixels -> 2432 Mcycles) */ - 0x0d, 0x0d, 0x0d, 0x0d, - 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e, - 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, - 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, - 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, - 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a, 0x1a, - 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1b, 0x1b, 0x1b, 0x1b, - 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1c, 0x1c, - 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1d, 0x1d, 0x1d, 0x1d, - 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1e, 0x1e, 0x1e, 0x1e, - 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f, - 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, - 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23, 0x23, - 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, 0x24, - 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x25, 0x25, 0x25, 0x25, - 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, 0x26, - 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27, 0x27, - 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x28, 0x28, 0x28, 0x28, - 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x29, - 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x2a, 0x2a, 0x2a, 0x2a, - 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2b, 0x2b, 0x2b, 0x2b, - 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2c, 0x2c, 0x2c, 0x2c, - 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2e, - 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x2f, 0x2f, - 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x30, 0x30, 0x30, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x31, - 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32, 0x32, - 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x33, 0x33, 0x33, 0x33, - 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x34, - 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x35, 0x35, 0x35, 0x35, - 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x37, 0x37, 0x37, - 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x38, 0x38, 0x38, 0x38, - 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x39, 0x39, 0x39, 0x39, - 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3a, - 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b, 0x3b, 0x3b, - 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3c, 0x3c, 0x3c, 0x3c, - 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3d, - 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e, 0x3e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3f, 0x3f, 0x3f, 0x3f, - 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x40, - 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 0x42, - 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 0x43, - 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x45, - 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x47, 0x47, 0x47, 0x47, - 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x48, 0x48, 0x48, 0x48, - 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, - 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a, 0x4a, - 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4b, 0x4b, 0x4b, 0x4b, - 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4b, 0x4c, 0x4c, 0x4c, 0x4c, - 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x4d, - 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4d, 0x4e, 0x4e, 0x4e, 0x4e, - 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4f, 0x4f, 0x4f, 0x4f, - 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x50, 0x50, 0x50, 0x50, - 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x51, 0x51, 0x51, 0x51, - 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x52, - 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, - 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x54, 0x54, 0x54, 0x54, - 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x55, - 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x56, - 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x57, 0x57, 0x57, 0x57, - 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x58, - 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x59, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x5a, 0x5a, 0x5a, 0x5a, - 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5b, - 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, 0x5c, 0x5c, - 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5d, 0x5d, 0x5d, 0x5d, - 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5e, - 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f, 0x5f, 0x5f, - 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x60, 0x60, 0x60, 0x60, - 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x61, 0x61, 0x61, 0x61, - 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 0x62, - 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x63, 0x63, 0x63, 0x63, - 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x64, - 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x65, 0x65, 0x65, 0x65, - 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x67, 0x67, 0x67, 0x67, - 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x68, 0x68, 0x68, 0x68, - 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x69, 0x69, 0x69, 0x69, - 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6a, - 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b, 0x6b, 0x6b, - 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6c, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6d, 0x6d, 0x6d, 0x6d, - 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6d, 0x6e, 0x6e, 0x6e, 0x6e, - 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6e, 0x6f, 0x6f, 0x6f, 0x6f, - 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x72, 0x72, 0x72, 0x72, - 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x73, 0x73, 0x73, 0x73, - 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x74, 0x74, 0x74, 0x74, - 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x75, 0x75, 0x75, 0x75, - 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x76, 0x76, 0x76, 0x76, - 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x79, 0x79, 0x79, 0x79, - 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x7a, 0x7a, 0x7a, 0x7a, - 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7a, 0x7b, 0x7b, 0x7b, 0x7b, - 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7c, 0x7c, 0x7c, 0x7c, - 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7d, 0x7d, 0x7d, 0x7d, - 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7d, 0x7e, 0x7e, 0x7e, 0x7e, - 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7f, 0x7f, 0x7f, 0x7f, - 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x8a, 0x8a, 0x8a, 0x8a, - 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8a, 0x8b, 0x8b, 0x8b, 0x8b, - 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8b, 0x8c, 0x8c, 0x8c, 0x8c, - 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8d, 0x8d, 0x8d, 0x8d, - 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8d, 0x8e, 0x8e, 0x8e, 0x8e, - 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8f, 0x8f, 0x8f, 0x8f, - 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a, 0x9a, 0x9a, 0x9a, - 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9a, 0x9b, 0x9b, 0x9b, 0x9b, - 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9b, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9d, 0x9d, 0x9d, 0x9d, - 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9e, - 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f, 0x9f, 0x9f, - 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa1, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2, 0xa2, - 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4, 0xa4}; - -#endif /* _HVC_H_ */ - -#if 0 - - -#ifndef _HVC_H_ -#define _HVC_H_ - - -#if 0 - -/* V counter values for NTSC 192-line display */ -static const uint8 vc_ntsc_192[262] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, - 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -/* V counter values for NTSC 224-line display */ -static const uint8 vc_ntsc_224[262] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, - 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -/* V counter values for NTSC 240-line display */ -static const uint8 vc_ntsc_240[262] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 -}; - -/* V counter values for PAL 192-line display */ -static const uint8 vc_pal_192[313] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, - 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -/* V counter values for PAL 224-line display */ -static const uint8 vc_pal_224[313] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, - 0x00, 0x01, 0x02, - 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -/* V counter values for PAL 240-line display */ -static const uint8 vc_pal_240[313] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, - 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, -}; -#endif - -/* H counter values for a 256-pixel wide display (342 pixel max.) */ -static const uint8 hc_256[171] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, - 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -/* H counter values for a 320-pixel wide display (442[sic, is it really 422?] pixels max.) */ -static const uint8 hc_320[211] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, - 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -#if 0 -static const uint8 *vc_table[6] = { - vc_ntsc_192, - vc_ntsc_224, - vc_ntsc_240, - vc_pal_192, - vc_pal_224, - vc_pal_240 -}; -#endif - -static const uint8 *hc_table[2] = { - hc_256, - hc_320, -}; - -#endif /* _HVC_H_ */ - -#endif diff --git a/libmednahawk/src/md/input/gamepad.cpp b/libmednahawk/src/md/input/gamepad.cpp deleted file mode 100644 index 0c9c4aa5c7..0000000000 --- a/libmednahawk/src/md/input/gamepad.cpp +++ /dev/null @@ -1,408 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * Copyright notice for this file: - * Copyright (C) 1999, 2000, 2001, 2002, 2003 Charles MacDonald - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "gamepad.h" -#include - -/*--------------------------------------------------------------------------*/ -/* Master System 2-button gamepad */ -/*--------------------------------------------------------------------------*/ -class Gamepad2 : public MD_Input_Device -{ - public: - Gamepad2(); - virtual ~Gamepad2(); - virtual void UpdateBus(const int32 master_timestamp, uint8 &bus, const uint8 genesis_asserted); - virtual void UpdatePhysicalState(const void *data); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_prefix); - - private: - uint8 buttons; -}; - -/*--------------------------------------------------------------------------*/ -/* Genesis 3-button gamepad */ -/*--------------------------------------------------------------------------*/ -class Gamepad3 : public MD_Input_Device -{ - public: - Gamepad3(); - virtual ~Gamepad3(); - virtual void UpdateBus(const int32 master_timestamp, uint8 &bus, const uint8 genesis_asserted); - virtual void UpdatePhysicalState(const void *data); - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_prefix); - - private: - uint8 buttons; -}; - -/*--------------------------------------------------------------------------*/ -/* Fighting Pad 6B */ -/*--------------------------------------------------------------------------*/ -class Gamepad6 : public MD_Input_Device -{ - public: - Gamepad6(); - virtual ~Gamepad6(); - - virtual void Power(void); - - virtual void UpdateBus(const int32 master_timestamp, uint8 &bus, const uint8 genesis_asserted); - virtual void UpdatePhysicalState(const void *data); - virtual void BeginTimePeriod(const int32 timestamp_base); - virtual void EndTimePeriod(const int32 master_timestamp); - - virtual int StateAction(StateMem *sm, int load, int data_only, const char *section_prefix); - - private: - void Run(const int32 master_timestamp); - - int32 prev_timestamp; - int32 count; - bool old_select; - int32 timeout; - uint16 buttons; - - bool compat_mode; -}; - -const InputDeviceInputInfoStruct Gamepad2IDII[7] = -{ - { "up", "UP ↑", 0, IDIT_BUTTON, "down" }, - { "down", "DOWN ↓", 1, IDIT_BUTTON, "up" }, - { "left", "LEFT â†", 2, IDIT_BUTTON, "right" }, - { "right", "RIGHT →", 3, IDIT_BUTTON, "left" }, - { "a", "A", 5, IDIT_BUTTON_CAN_RAPID, NULL }, - { "b", "B", 6, IDIT_BUTTON_CAN_RAPID, NULL }, - { "start", "Start", 4, IDIT_BUTTON, NULL }, -}; - -Gamepad2::Gamepad2() -{ - buttons = 0; -} - -Gamepad2::~Gamepad2() -{ - -} - -int Gamepad2::StateAction(StateMem *sm, int load, int data_only, const char *section_prefix) -{ - SFORMAT StateRegs[] = - { - SFVAR(buttons), - SFEND - }; - - int ret = 1; - char sname[64]; - - trio_snprintf(sname, sizeof(sname), "%s-gp2", section_prefix); - - ret &= MDFNSS_StateAction(sm, load, data_only, StateRegs, sname); - - if(load) - { - - } - return(ret); -} - - -void Gamepad2::UpdateBus(const int32 master_timestamp, uint8 &bus, const uint8 genesis_asserted) -{ - bus = (bus &~ 0x3F) | (0x3F & ~buttons); -} - -void Gamepad2::UpdatePhysicalState(const void *data) -{ - buttons = *(uint8 *)data; -} - -const InputDeviceInputInfoStruct GamepadIDII[8] = -{ - { "up", "UP ↑", 0, IDIT_BUTTON, "down" }, - { "down", "DOWN ↓", 1, IDIT_BUTTON, "up" }, - { "left", "LEFT â†", 2, IDIT_BUTTON, "right" }, - { "right", "RIGHT →", 3, IDIT_BUTTON, "left" }, - { "b", "B", 6, IDIT_BUTTON_CAN_RAPID, NULL }, - { "c", "C", 7, IDIT_BUTTON_CAN_RAPID, NULL }, - { "a", "A", 5, IDIT_BUTTON_CAN_RAPID, NULL }, - { "start", "Start", 4, IDIT_BUTTON, NULL }, -}; - -Gamepad3::Gamepad3() -{ - buttons = 0; -} - -Gamepad3::~Gamepad3() -{ - -} - -void Gamepad3::UpdateBus(const int32 master_timestamp, uint8 &bus, const uint8 genesis_asserted) -{ - const bool select = (bus >> 6) & 1; - uint8 temp; - - if(select) - temp = 0x3F & ~buttons; - else - temp = 0x33 & ~(buttons & 0x3) & ~((buttons >> 2) & 0x30); - - bus = (bus & ~0x3F) | temp; -} - -void Gamepad3::UpdatePhysicalState(const void *data) -{ - buttons = *(uint8 *)data; -} - -int Gamepad3::StateAction(StateMem *sm, int load, int data_only, const char *section_prefix) -{ - SFORMAT StateRegs[] = - { - SFVAR(buttons), - SFEND - }; - - int ret = 1; - char sname[64]; - - trio_snprintf(sname, sizeof(sname), "%s-gp3", section_prefix); - - ret &= MDFNSS_StateAction(sm, load, data_only, StateRegs, sname); - - if(load) - { - - } - return(ret); -} - - -const InputDeviceInputInfoStruct Gamepad6IDII[12] = -{ - { "up", "UP ↑", 0, IDIT_BUTTON, "down" }, - { "down", "DOWN ↓", 1, IDIT_BUTTON, "up" }, - { "left", "LEFT â†", 2, IDIT_BUTTON, "right" }, - { "right", "RIGHT →", 3, IDIT_BUTTON, "left" }, - { "b", "B", 6, IDIT_BUTTON_CAN_RAPID, NULL }, - { "c", "C", 7, IDIT_BUTTON_CAN_RAPID, NULL }, - { "a", "A", 5, IDIT_BUTTON_CAN_RAPID, NULL }, - { "start", "Start", 4, IDIT_BUTTON, NULL }, - { "z", "Z", 10, IDIT_BUTTON_CAN_RAPID, NULL }, - { "y", "Y", 9, IDIT_BUTTON_CAN_RAPID, NULL }, - { "x", "X", 8, IDIT_BUTTON_CAN_RAPID, NULL }, - { "mode", "Mode", 11, IDIT_BUTTON, NULL }, -}; - -Gamepad6::Gamepad6() -{ - buttons = 0; - old_select = 0; - prev_timestamp = 0; -} - -Gamepad6::~Gamepad6() // Destructor. DEEEEEEEE. Don't put variables to initialize here again! -{ - -} - -void Gamepad6::Power(void) -{ - count = 0; - timeout = 0; - - //compat_mode = false; //(bool)(buttons & (1 << 11)); - //compat_mode_counter = 4474431; // ~5 video frames - compat_mode = (bool)(buttons & (1 << 11)); -} - -int Gamepad6::StateAction(StateMem *sm, int load, int data_only, const char *section_prefix) -{ - SFORMAT StateRegs[] = - { - SFVAR(old_select), - SFVAR(buttons), - SFVAR(count), - SFVAR(timeout), - SFVAR(compat_mode), - SFEND - }; - int ret = 1; - char sname[64]; - - trio_snprintf(sname, sizeof(sname), "%s-gp6", section_prefix); - - ret &= MDFNSS_StateAction(sm, load, data_only, StateRegs, sname); - - if(load) - { - - } - - return(ret); -} - - -void Gamepad6::Run(const int32 master_timestamp) -{ - const int32 clocks = master_timestamp - prev_timestamp; - - //printf("%d\n", master_timestamp - prev_timestamp); -#if 0 - if(compat_mode_counter >= 0) - { - if(!(buttons & (1 << 11))) - compat_mode_counter = false; - else - { - compat_mode_counter -= clocks; - if(compat_mode_counter <= 0) - compat_mode = true; - } - } -#endif - - timeout += clocks; - - if(timeout >= 8192 * 7) - { - timeout = 0; - count = 0; - - //if(!select) - // count++; - //printf("TIMEOUT: %d\n", select); - } - - prev_timestamp = master_timestamp; -} - -void Gamepad6::BeginTimePeriod(const int32 timestamp_base) -{ - //printf("Begin: %d\n", timestamp_base); - prev_timestamp = timestamp_base; -} - -void Gamepad6::EndTimePeriod(const int32 master_timestamp) -{ - //printf("End: %d\n", master_timestamp); - Run(master_timestamp); -} - -/* - How it's implemented here(copy/pasted from Charles' doc, and rearranged a bit): - - Count: - - 0 TH = 0 : ?0SA00DU 3-button pad return value - 0 TH = 1 : ?1CBRLDU 3-button pad return value - - 1 TH = 0 : ?0SA00DU 3-button pad return value - 1 TH = 1 : ?1CBRLDU 3-button pad return value - - 2 TH = 0 : ?0SA00DU 3-button pad return value - 2 TH = 1 : ?1CBRLDU 3-button pad return value - - 3 TH = 0 : ?0SA0000 D3-0 are forced to '0' - 3 TH = 1 : ?1CBMXYZ Extra buttons returned in D3-0 - - 4 TH = 0 : ?0SA1111 D3-0 are forced to '1' - 4 TH = 1 : ?1CBRLDU 3-button pad return value - - ... TH = 0 : ?0SA00DU 3-button pad return value - ... TH = 1 : ?1CBRLDU 3-button pad return value - -*/ - -void Gamepad6::UpdateBus(const int32 master_timestamp, uint8 &bus, const uint8 genesis_asserted) -{ - Run(master_timestamp); - - const bool select = (bus >> 6) & 1; - uint8 temp = 0x3F; - - // Only take action if TH changed. - if(select != old_select) - { - timeout = 0; - old_select = select; - - if(!select && count < 5 && !compat_mode) // If TH is going from 1->0, and we haven't reached the end yet, increment the counter. - count++; - } - - switch(count) - { - case 5: - case 0: - case 1: - case 2: - if(select) - temp = 0x3F & ~buttons; - else - temp = 0x33 & ~(buttons & 0x3) & ~((buttons >> 2) & 0x30); - break; - - case 3: - if(select) - temp = (0x30 & ~buttons) | (0x0F & ~(buttons >> 8)); - else - temp = 0x30 & ~((buttons >> 2) & 0x30); - break; - - case 4: - if(select) - temp = 0x3F & ~buttons; - else - temp = 0x3F & ~((buttons >> 2) & 0x30); - break; - } - - //printf("Read: %d 0x%02x\n", (count << 1) | select, temp); - bus = (bus & ~0x3F) | temp; -} - -void Gamepad6::UpdatePhysicalState(const void *data) -{ - //printf("Buttons: %04x\n", MDFN_de16lsb((uint8 *)data)); - buttons = MDFN_de16lsb((uint8 *)data); -} - -MD_Input_Device *MDInput_MakeMS2B(void) -{ - return new Gamepad2; -} - -MD_Input_Device *MDInput_MakeMD3B(void) -{ - return new Gamepad3; -} - -MD_Input_Device *MDInput_MakeMD6B(void) -{ - return new Gamepad6; -} - diff --git a/libmednahawk/src/md/input/gamepad.h b/libmednahawk/src/md/input/gamepad.h deleted file mode 100644 index 0b7baa8905..0000000000 --- a/libmednahawk/src/md/input/gamepad.h +++ /dev/null @@ -1,7 +0,0 @@ -extern const InputDeviceInputInfoStruct Gamepad2IDII[7]; -extern const InputDeviceInputInfoStruct GamepadIDII[8]; -extern const InputDeviceInputInfoStruct Gamepad6IDII[12]; -MD_Input_Device *MDInput_MakeMS2B(void); -MD_Input_Device *MDInput_MakeMD3B(void); -MD_Input_Device *MDInput_MakeMD6B(void); - diff --git a/libmednahawk/src/md/input/mouse.cpp b/libmednahawk/src/md/input/mouse.cpp deleted file mode 100644 index cd6114d032..0000000000 --- a/libmednahawk/src/md/input/mouse.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/* Mednafen - Multi-system Emulator - * - * Copyright notice for this file: - * Copyright (C) 1999, 2000, 2001, 2002, 2003 Charles MacDonald - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "../shared.h" -#include "mouse.h" - -enum -{ - MASK_TH = 0x40, - MASK_TR = 0x20, - MASK_TL = 0x10, - MASK_DATA = 0x0F -}; - -class MegaMouse : public MD_Input_Device -{ - public: - MegaMouse(); - virtual ~MegaMouse(); - virtual void UpdateBus(const int32 master_timestamp, uint8 &bus, const uint8 genesis_asserted); - virtual void UpdatePhysicalState(const void *data); - - private: - int32 mouse_x; - int32 mouse_y; - uint8 buttons; - - uint8 data_buffer[0xA]; - uint8 counter; - bool last_th; - bool last_tr; - - bool tl_ret; - bool happy_mode; - int32 busy_meow; -}; - -const InputDeviceInputInfoStruct MegaMouseIDII[6] = -{ - { "x_axis", "X Axis", -1, IDIT_X_AXIS_REL }, - { "y_axis", "Y Axis", -1, IDIT_Y_AXIS_REL }, - { "left", "Left Button", 0, IDIT_BUTTON, NULL }, - { "right", "Right Button", 1, IDIT_BUTTON, NULL }, - { "middle", "Middle Button", 2, IDIT_BUTTON, NULL }, - { "start", "Start Button", 3, IDIT_BUTTON, NULL }, -}; - -MegaMouse::MegaMouse() -{ - mouse_x = 0; - mouse_y = 0; - buttons = 0; - - counter = 0; - last_th = 0; - last_tr = 0; - - tl_ret = 0; - happy_mode = 0; - busy_meow = 0; -} - -MegaMouse::~MegaMouse() -{ - -} - -void MegaMouse::UpdateBus(const int32 master_timestamp, uint8 &bus, const uint8 genesis_asserted) -{ - const uint8 data = bus; - uint8 temp; - - //printf("Write: %02x\n", data); - #if 0 - if((data & 0x60) == 0x60 && counter == 9) - { - happy_mode = FALSE; - tl_ret = FALSE; - last_th = 0; - last_tr = 0; - return; - } - #endif - - if(((data & MASK_TH) && !(last_th)) || (data & 0x60) == 0x60) - { - if((data & 0x60) == 0x60) - { - happy_mode = TRUE; - tl_ret = TRUE; - } - int32 rel_x = mouse_x; - int32 rel_y = mouse_y; - bool x_neg = 0; - bool y_neg = 0; - - if(rel_x < -255) - rel_x = -255; - - if(rel_x > 255) - rel_x = 255; - - if(rel_y < -255) - rel_y = -255; - - if(rel_y > 255) - rel_y = 255; - - mouse_x -= rel_x; - mouse_y -= rel_y; - - rel_y = -rel_y; - - if(rel_x < 0) - { - x_neg = TRUE; - } - - if(rel_y < 0) - { - y_neg = TRUE; - } - - //printf("%02x, %d %d\n", buttons, rel_x, rel_y); - counter = 0; - data_buffer[0] = 0x0; - data_buffer[1] = 0xB; - data_buffer[2] = 0xF; - data_buffer[3] = 0xF; - data_buffer[4] = (x_neg ? 0x1 : 0x0) | (y_neg ? 0x2 : 0x0); // Axis sign and overflow - data_buffer[5] = buttons; // Button state - data_buffer[6] = (rel_x >> 4) & 0xF; // X axis MSN - data_buffer[7] = (rel_x >> 0) & 0xF; // X axis LSN - data_buffer[8] = (rel_y >> 4) & 0xF; // Y axis MSN - data_buffer[9] = (rel_y >> 0) & 0xF; // Y axis LSN - } - else if(!(data & MASK_TH) && last_th) - { - counter++; - if(counter > 9) - counter = 9; - } - - // Mouse vs Mega - if(!(data & MASK_TH)) - { - if((data & MASK_TR) && !last_tr) - { - tl_ret = TRUE; - counter++; - - if(counter > 9) - counter = 9; - if(counter == 9) - busy_meow = 10; - } - else if(!(data & MASK_TR) && (last_tr)) - { - tl_ret = FALSE; - counter++; - if(counter > 9) - counter = 9; - } - } - - last_th = data & MASK_TH; - last_tr = data & MASK_TR; - - // - // - // - - temp = data_buffer[counter]; - - if(tl_ret) - temp |= MASK_TL; - - if(busy_meow > 0) - { - busy_meow--; - if(!busy_meow) - tl_ret = 0; - } - - bus = (bus & ~0x60) | (temp & 0x1F); - //printf("Read: %02x, %d\n", ret, counter); -} - -void MegaMouse::UpdatePhysicalState(const void *data) -{ - mouse_x += (int32)MDFN_de32lsb((uint8 *)data + 0); - mouse_y += (int32)MDFN_de32lsb((uint8 *)data + 4); - buttons = ((uint8 *)data)[8]; - MDFNGameInfo->mouse_sensitivity = 1.0; //MDFN_GetSettingF("pcfx.mouse_sensitivity"); -} - -MD_Input_Device *MDInput_MakeMegaMouse(void) -{ - MD_Input_Device *ret = new MegaMouse(); - - - return(ret); -} diff --git a/libmednahawk/src/md/input/mouse.h b/libmednahawk/src/md/input/mouse.h deleted file mode 100644 index d2a8470fb7..0000000000 --- a/libmednahawk/src/md/input/mouse.h +++ /dev/null @@ -1,3 +0,0 @@ -extern const InputDeviceInputInfoStruct MegaMouseIDII[6]; -MD_Input_Device *MDInput_MakeMegaMouse(void); - diff --git a/libmednahawk/src/md/macros.h b/libmednahawk/src/md/macros.h deleted file mode 100644 index f3b238c8a0..0000000000 --- a/libmednahawk/src/md/macros.h +++ /dev/null @@ -1,68 +0,0 @@ - -#ifndef _MACROS_H_ -#define _MACROS_H_ - -static inline uint8 READ_BYTE_MSB(const uint8 *base, const unsigned int addr) -{ - return(base[addr + 0]); -} - -static inline uint16 READ_WORD_MSB(const uint8 *base, const unsigned int addr) -{ - return((base[addr + 0] << 8) | (base[addr + 1] << 0)); -} - -static inline uint32 READ_32_MSB(const uint8 *base, const unsigned int addr, const bool is_aligned = 0) -{ - #ifdef MSB_FIRST - if(is_aligned) - return(*(uint32 *)&base[addr]); - else - #endif - return((base[addr + 0] << 24) | (base[addr + 1] << 16) | (base[addr + 2] << 8) | (base[addr + 3] << 0)); -} - -static inline void WRITE_BYTE_MSB(uint8 *base, const unsigned int addr, const uint8 value) -{ - base[addr + 0] = value; -} - -static inline void WRITE_WORD_MSB(uint8 *base, const unsigned int addr, const uint16 value) -{ - base[addr + 0] = value >> 8; - base[addr + 1] = value; -} - -static inline uint8 READ_BYTE_LSB(const uint8 *base, const unsigned int addr) -{ - return(base[addr + 0]); -} - -static inline uint16 READ_WORD_LSB(const uint8 *base, const unsigned int addr) -{ - return((base[addr + 0] << 0) | (base[addr + 1] << 8)); -} - -static inline uint32 READ_32_LSB(const uint8 *base, const unsigned int addr, const bool is_aligned = 0) -{ - #ifdef LSB_FIRST - if(is_aligned) - return(*(uint32 *)&base[addr]); - else - #endif - return((base[addr + 0] << 0) | (base[addr + 1] << 8) | (base[addr + 2] << 16) | (base[addr + 3] << 24)); -} - -static inline void WRITE_BYTE_LSB(uint8 *base, const unsigned int addr, const uint8 value) -{ - base[addr + 0] = value; -} - -static inline void WRITE_WORD_LSB(uint8 *base, const unsigned int addr, const uint16 value) -{ - base[addr + 0] = value >> 0; - base[addr + 1] = value >> 8; -} - -#endif /* _MACROS_H_ */ - diff --git a/libmednahawk/src/md/mem68k.cpp b/libmednahawk/src/md/mem68k.cpp deleted file mode 100644 index 32db802e54..0000000000 --- a/libmednahawk/src/md/mem68k.cpp +++ /dev/null @@ -1,710 +0,0 @@ -/* - Copyright (C) 1999, 2000, 2001, 2002, 2003 Charles MacDonald - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "shared.h" - -namespace MDFN_IEN_MD -{ - -unsigned int m68k_read_bus_8(unsigned int address) -{ - uint16 temp = m68k_read_bus_16(address); - return ((address & 1) ? (temp & 0xFF) : (temp >> 8)); -} - -unsigned int m68k_read_bus_16(unsigned int address) -{ - uint16 temp = 0x4e71; - - if(address >= 0xC00000) - { - return (temp); - } - else - { - return (temp & 0xFF00); - } -} - -void m68k_unused_8_w(unsigned int address, unsigned int value) -{ - printf("Unused %08X = %02X\n", address, value); -} - -void m68k_unused_16_w(unsigned int address, unsigned int value) -{ - printf("Unused %08X = %04X\n", address, value); -} - -/* - Functions to handle memory accesses which cause the Genesis to halt - either temporarily (press RESET button to restart) or unrecoverably - (cycle power to restart). -*/ - -void m68k_lockup_w_8(unsigned int address, unsigned int value) -{ - printf("Lockup %08X = %02X (%08X)\n", address, value, C68k_Get_PC(&Main68K)); -} - -void m68k_lockup_w_16(unsigned int address, unsigned int value) -{ - printf("Lockup %08X = %04X (%08X)\n", address, value, C68k_Get_PC(&Main68K)); -} - -unsigned int m68k_lockup_r_8(unsigned int address) -{ - printf("Lockup %08X.b (%08X)\n", address, C68k_Get_PC(&Main68K)); - return -1; -} - -unsigned int m68k_lockup_r_16(unsigned int address) -{ - printf("Lockup %08X.w (%08X)\n", address, C68k_Get_PC(&Main68K)); - return -1; -} - -/*--------------------------------------------------------------------------*/ -/* 68000 memory handlers */ -/*--------------------------------------------------------------------------*/ - -uint8 MD_ReadMemory8(uint32 address) -{ - MD_UpdateSubStuff(); - - address &= 0xFFFFFF; - - //printf("Read8: %08x\n", address); - - switch((address >> 21) & 7) - { - case 0: /* ROM */ - case 1: - case 2: /* Unused */ - case 3: - return(MD_ExtRead8(address)); - - case 7: /* RAM */ - return READ_BYTE_MSB(work_ram, address & 0xFFFF); - - case 5: /* Z80 & I/O */ - if(address <= 0xA0FFFF) - { - if(zbusack == 1) - { - /* Z80 controls Z bus */ - return (m68k_read_bus_8(address)); - } - else - { - /* Read data from Z bus */ - switch(address & 0x6000) - { - case 0x0000: /* RAM */ - case 0x2000: - return (zram[(address & 0x1FFF)]); - - case 0x4000: /* YM2612 */ - return (MDSound_ReadFM(address & 3)); - - case 0x6000: /* Unused */ - switch(address & 0xFF00) - { - case 0x7F00: /* VDP */ - m68k_lockup_r_8(address); - - default: /* Unused */ - return (0xFF); - } - break; - } - } - } - else - { - switch((address >> 8) & 0xFF) - { - case 0x00: /* I/O CHIP */ - if(address <= 0xA1001F) - { - return (gen_io_r((address >> 1) & 0x0F)); - } - else - { - return (m68k_read_bus_8(address)); - } - break; - - case 0x10: /* MEMORY MODE */ - return (m68k_read_bus_8(address)); - - case 0x11: /* BUSACK */ - if((address & 1) == 0) - { - return (gen_busack_r() | (m68k_read_bus_8(address) & 0xFE)); - } - else - return (m68k_read_bus_8(address)); - - case 0x12: /* RESET */ - case 0x13: /* TIME */ - case 0x20: /* UNKNOWN */ - case 0x30: /* UNKNOWN */ - return (MD_ExtRead8(address)); - - default: /* Unused */ - return (m68k_lockup_r_8(address)); - } - } - break; - - case 6: /* VDP */ - if((address & 0xE700E0) == 0xC00000) - { - switch(address & 0x1F) - { - case 0x00: /* DATA */ - case 0x02: - return (MainVDP.vdp_data_r() >> 8); - - case 0x01: /* DATA */ - case 0x03: - return (MainVDP.vdp_data_r() & 0xFF); - - case 0x04: /* CTRL */ - case 0x06: - return ((m68k_read_bus_8(address) & 0xFC) | (MainVDP.vdp_ctrl_r() >> 8)); - - case 0x05: /* CTRL */ - case 0x07: - return (MainVDP.vdp_ctrl_r() & 0xFF); - - case 0x08: /* HVC */ - case 0x0A: - case 0x0C: - case 0x0E: - return (MainVDP.vdp_hvc_r() >> 8); - - case 0x09: /* HVC */ - case 0x0B: - case 0x0D: - case 0x0F: - return (MainVDP.vdp_hvc_r() & 0xFF); - - case 0x10: /* PSG */ - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - return (m68k_lockup_r_8(address)); - - case 0x18: /* Unused */ - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - return (m68k_read_bus_8(address)); - } - } - else - { - /* Unused */ - return (m68k_lockup_r_8(address)); - } - break; - - case 4: /* Unused */ - return (m68k_lockup_r_8(address)); - } - - return -1; -} - - -uint16 MD_ReadMemory16(uint32 address) -{ - MD_UpdateSubStuff(); - - if(address & 1) - { - // TODO: Generate 68K exception(and remove address &= ~1) - printf("16-bit unaligned read: %08x\n", address); - address &= ~1; - } - address &= 0xFFFFFF; - - //printf("Read16: %08x\n", address); - - switch((address >> 21) & 7) - { - - case 0: /* ROM */ - case 1: - case 2: - case 3: - return(MD_ExtRead16(address)); - - case 7: /* RAM */ - return READ_WORD_MSB(work_ram, address & 0xFFFF); - - case 5: /* Z80 & I/O */ - if(address <= 0xA0FFFF) - { - if(zbusack == 1) - { - return (m68k_read_bus_16(address)); - } - else - { - uint8 temp; - - switch(address & 0x6000) - { - case 0x0000: /* RAM */ - case 0x2000: - temp = zram[address & 0x1FFF]; - return (temp << 8 | temp); - - case 0x4000: /* YM2612 */ - temp = MDSound_ReadFM(address & 3); - return (temp << 8 | temp); - - case 0x6000: - switch(address & 0xFF00) - { - case 0x7F00: /* VDP */ - m68k_lockup_r_16(address); - - default: /* Unused */ - return (0xFFFF); - } - break; - } - } - } - else - { - if(address <= 0xA1001F) - { - uint8 temp = gen_io_r((address >> 1) & 0x0F); - return (temp << 8 | temp); - } - else - { - switch((address >> 8) & 0xFF) - { - case 0x10: /* MEMORY MODE */ - return (m68k_read_bus_16(address)); - - case 0x11: /* BUSACK */ - return ((m68k_read_bus_16(address) & 0xFEFF) | (gen_busack_r() << 8)); - - case 0x12: /* RESET */ - case 0x13: /* TIME */ - case 0x20: /* UNKNOWN */ - case 0x30: /* UNKNOWN */ - return(MD_ExtRead16(address)); - - default: /* Unused */ - return (m68k_lockup_r_16(address)); - } - } - } - break; - - case 6: - if((address & 0xE700E0) == 0xC00000) - { - switch(address & 0x1F) - { - case 0x00: /* DATA */ - case 0x02: - return (MainVDP.vdp_data_r()); - - case 0x04: /* CTRL */ - case 0x06: - return (MainVDP.vdp_ctrl_r() | (m68k_read_bus_16(address) & 0xFC00)); - - case 0x08: /* HVC */ - case 0x0A: - case 0x0C: - case 0x0E: - return (MainVDP.vdp_hvc_r()); - - case 0x10: /* PSG */ - case 0x12: - case 0x14: - case 0x16: - return (m68k_lockup_r_16(address)); - - case 0x18: /* Unused */ - case 0x1A: - case 0x1C: - case 0x1E: - return (m68k_read_bus_16(address)); - } - } - else - { - return (m68k_lockup_r_16(address)); - } - break; - - case 4: - return (m68k_lockup_r_16(address)); - } - - return (0xA5A5); -} - - -void MD_WriteMemory8(uint32 address, uint8 value) -{ - MD_UpdateSubStuff(); - - address &= 0xFFFFFF; - - //printf("Write8: %08x %02x\n", address & 0xFFFFFF, value); - - switch((address >> 21) & 7) - { - case 7: - WRITE_BYTE_MSB(work_ram, address & 0xFFFF, value); - return; - - case 6: - if((address & 0xE700E0) == 0xC00000) - { - switch(address & 0x1F) - { - case 0x00: /* DATA */ - case 0x01: - case 0x02: - case 0x03: - MainVDP.vdp_data_w(value << 8 | value); - return; - - case 0x04: /* CTRL */ - case 0x05: - case 0x06: - case 0x07: - MainVDP.vdp_ctrl_w(value << 8 | value); - return; - - case 0x08: /* HVC */ - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - m68k_lockup_w_8(address, value); - return; - - case 0x10: /* PSG */ - case 0x12: - case 0x14: - case 0x16: - m68k_unused_8_w(address, value); - return; - - case 0x11: /* PSG */ - case 0x13: - case 0x15: - case 0x17: - psg_write(value); - return; - - case 0x18: /* Unused */ - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - m68k_unused_8_w(address, value); - return; - } - } - else - { - m68k_lockup_w_8(address, value); - return; - } - - case 5: - if(address <= 0xA0FFFF) - { - if(zbusack == 1) - { - m68k_unused_8_w(address, value); - return; - } - else - { - switch(address & 0x6000) - { - case 0x0000: - case 0x2000: - zram[(address & 0x1FFF)] = value; - return; - - case 0x4000: - fm_write(address & 3, value); - return; - - case 0x6000: - switch(address & 0xFF00) - { - case 0x6000: /* BANK */ - gen_bank_w(value & 1); - return; - - case 0x7F00: /* VDP */ - m68k_lockup_w_8(address, value); - return; - - default: /* Unused */ - m68k_unused_8_w(address, value); - return; - } - break; - } - } - } - else - { - if(address <= 0xA1001F) - { - /* I/O chip only gets /LWR */ - if(address & 1) - gen_io_w((address >> 1) & 0x0F, value); - return; - } - else - { - /* Bus control chip registers */ - switch((address >> 8) & 0xFF) - { - case 0x10: /* MEMORY MODE */ - m68k_unused_8_w(address, value); - return; - - case 0x11: /* BUSREQ */ - if((address & 1) == 0) - { - gen_busreq_w(value & 1); - } - else - { - m68k_unused_8_w(address, value); - } - return; - - case 0x12: /* RESET */ - gen_reset_w(value & 1); - return; - - case 0x13: /* TIME */ - case 0x20: /* UNKNOWN */ - case 0x30: /* UNKNOWN */ - MD_ExtWrite8(address, value); - return; - - default: /* Unused */ - m68k_lockup_w_8(address, value); - return; - } - } - } - break; - - - case 0: /* ROM */ - case 1: /* ROM */ - case 2: /* Unused */ - case 3: - MD_ExtWrite8(address, value); - //m68k_unused_8_w(address, value); - return; - - case 4: /* Unused */ - m68k_lockup_w_8(address, value); - return; - } - -} - - -void MD_WriteMemory16(uint32 address, uint16 value) -{ - MD_UpdateSubStuff(); - - if(address & 1) - { - // TODO: Generate 68K exception(and remove address &= ~1) - printf("16-bit unaligned write: %08x %04x\n", address, value); - address &= ~1; - } - address &= 0xFFFFFF; - - //printf("Write16: %08x %04x\n", address & 0xFFFFFF, value); - - switch((address >> 21) & 7) - { - case 0: /* ROM */ - case 1: /* ROM */ - case 2: /* Unused */ - case 3: - MD_ExtWrite16(address, value); - return; - - case 4: /* Unused */ - m68k_lockup_w_16(address, value); - return; - - case 5: /* Z80 area, I/O chip, miscellaneous. */ - if(address <= 0xA0FFFF) - { - /* Writes are ignored when the Z80 hogs the Z-bus */ - if(zbusack == 1) { - m68k_unused_8_w(address, value); - return; - } - - /* Write into Z80 address space */ - switch(address & 0x6000) - { - case 0x0000: /* Work RAM */ - case 0x2000: /* Work RAM */ - zram[(address & 0x1FFF)] = (value >> 8) & 0xFF; - return; - - case 0x4000: /* YM2612 */ - fm_write(address & 3, (value >> 8) & 0xFF); - return; - - case 0x6000: /* Bank register and VDP */ - switch(address & 0x7F00) - { - case 0x6000: /* Bank register */ - printf("Bank16: %04x\n", value); - gen_bank_w((value >> 8) & 1); - return; - - case 0x7F00: /* VDP registers */ - m68k_lockup_w_16(address, value); - return; - - default: /* Unused */ - m68k_unused_16_w(address, value); - return; - } - break; - } - } - else - { - /* I/O chip */ - if(address <= 0xA1001F) - { - gen_io_w((address >> 1) & 0x0F, value & 0x00FF); - return; - } - else - { - /* Bus control chip registers */ - switch((address >> 8) & 0xFF) - { - case 0x10: /* MEMORY MODE */ - m68k_unused_16_w(address, value); - return; - - case 0x11: /* BUSREQ */ - gen_busreq_w((value >> 8) & 1); - return; - - case 0x12: /* RESET */ - gen_reset_w((value >> 8) & 1); - return; - - case 0x13: /* TIME */ - case 0x20: /* UNKNOWN */ - case 0x30: /* UNKNOWN */ - MD_ExtWrite16(address, value); - return; - - default: /* Unused */ - m68k_lockup_w_16(address, value); - return; - } - } - } - break; - - case 6: /* VDP */ - if((address & 0xE700E0) == 0xC00000) - { - switch(address & 0x1C) - { - case 0x00: /* DATA */ - MainVDP.vdp_data_w(value); - return; - - case 0x04: /* CTRL */ - MainVDP.vdp_ctrl_w(value); - return; - - case 0x08: /* HV counter */ - case 0x0C: /* HV counter */ - m68k_lockup_w_16(address, value); - return; - - case 0x10: /* PSG */ - case 0x14: /* PSG */ - psg_write(value & 0xFF); - return; - - case 0x18: /* Unused */ - case 0x1C: /* Unused */ - m68k_unused_8_w(address, value); - return; - } - } - else - { - /* Invalid address */ - m68k_lockup_w_16(address, value); - } - break; - - case 7: /* Work RAM */ - WRITE_WORD_MSB(work_ram, address & 0xFFFF, value); - return; - } -} - -} diff --git a/libmednahawk/src/md/mem68k.h b/libmednahawk/src/md/mem68k.h deleted file mode 100644 index ca8d2a9cdc..0000000000 --- a/libmednahawk/src/md/mem68k.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _MEM68K_H_ -#define _MEM68K_H_ - -namespace MDFN_IEN_MD -{ - -/* Function prototypes */ -unsigned int m68k_read_bus_8(unsigned int address); -unsigned int m68k_read_bus_16(unsigned int address); - -void m68k_lockup_w_8(unsigned int address, unsigned int value); -void m68k_lockup_w_16(unsigned int address, unsigned int value); -unsigned int m68k_lockup_r_8(unsigned int address); -unsigned int m68k_lockup_r_16(unsigned int address); - - -uint8 MD_ReadMemory8(uint32 address); -uint16 MD_ReadMemory16(uint32 address); -void MD_WriteMemory8(uint32 address, uint8 value); -void MD_WriteMemory16(uint32 address, uint16 value); - -} - -#endif /* _MEM68K_H_ */ diff --git a/libmednahawk/src/md/membnk.cpp b/libmednahawk/src/md/membnk.cpp deleted file mode 100644 index 2e0bf17cb6..0000000000 --- a/libmednahawk/src/md/membnk.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/* - membnk.c -- - Memory handlers Z80 access to the banked V-bus address space. -*/ - -#include "shared.h" -#include "cart/cart.h" - -namespace MDFN_IEN_MD -{ - -void z80_write_banked_memory(unsigned int address, unsigned int data) -{ - //printf("Z80 Banked Write: %02x, %08x, %02x\n", address >> 21, address, data); - - switch((address >> 21) & 7) - { - case 0: /* Cartridge ROM */ - case 1: - MD_ExtWrite8(address, data); - return; - - case 2: /* Unused */ - case 3: - MD_ExtWrite8(address, data); - return; - - case 4: /* Unused (lockup) */ - z80bank_lockup_w(address, data); - return; - - case 5: /* Z80, I/O chip, etc. */ - if(address <= 0xA0FFFF) - { - z80bank_lockup_w(address, data); - return; - } - else - { - switch((address >> 8) & 0xFF) - { - case 0x00: /* I/O chip */ - if(address <= 0xA1001F) - gen_io_w((address >> 1) & 0x0F, data); - else - z80bank_unused_w(address, data); - return; - - case 0x10: /* DRAM refresh */ - z80bank_unused_w(address, data); - return; - - case 0x11: /* /BUSREQ */ - if(address & 1) - z80bank_unused_w(address, data); - else - gen_busreq_w(data & 1); - return; - - case 0x12: /* /RESET (w) */ - if(address & 1) - z80bank_unused_w(address, data); - else - gen_reset_w(data & 1); - return; - - case 0x13: /* /TIME region */ - case 0x20: /* ? */ - case 0x30: /* ? */ - MD_ExtWrite8(address, data); - return; - - default: /* Invalid */ - z80bank_lockup_w(address, data); - return; - } - } - return; - - case 6: /* VDP */ - z80bank_vdp_w(address, data); - return; - - case 7: /* Work RAM */ - WRITE_BYTE_MSB(work_ram, address & 0xFFFF, data); - return; - } -} - - -int z80_read_banked_memory(unsigned int address) -{ - //printf("Z80 Banked Read: %02x, %08x\n", address >> 21, address); - - switch((address >> 21) & 7) - { - case 0: /* Cartridge ROM */ - case 1: - return(MD_ExtRead8(address)); - - case 2: /* Unused */ - case 3: - return(MD_ExtRead8(address)); - - case 4: /* Unused (lockup) */ - return z80bank_lockup_r(address); - - case 5: /* Z80, I/O chip, etc.*/ - if(address <= 0xA0FFFF) - { - return z80bank_lockup_r(address); - } - else - { - switch((address >> 8) & 0xFF) - { - case 0x00: /* I/O chip */ - if(address <= 0xA1001F) - return gen_io_r((address >> 1) & 0x0F); - else - return z80bank_unused_r(address); - break; - - case 0x10: /* Unused */ - return z80bank_unused_r(address); - - case 0x11: /* /BUSACK from Z80 */ - /* The Z80 can't read this bit (it would be halted - when the bit was zero) so we always return '1'. */ - return 0xFF; - - case 0x12: /* Unused */ - case 0x13: /* /TIME region */ - case 0x20: /* Unused */ - case 0x30: /* Unused */ - return(MD_ExtRead8(address)); - - default: /* Lockup */ - return z80bank_lockup_r(address); - } - } - break; - - case 6: /* VDP */ - return z80bank_vdp_r(address); - - case 7: /* Work RAM - can't be read on some Genesis models (!) */ - return 0xFF; - } - - return (-1); -} - - -void z80bank_vdp_w(int address, int data) -{ - if((address & 0xE700E0) == 0xC00000) - { - switch(address & 0x1F) - { - case 0x00: /* Data port */ - case 0x01: - case 0x02: - case 0x03: - puts("MOO2"); - MainVDP.vdp_data_w(data << 8 | data); - return; - - case 0x04: /* Control port */ - case 0x05: - case 0x06: - case 0x07: - MainVDP.vdp_ctrl_w(data << 8 | data); - return; - - case 0x08: /* Lockup (HVC) */ - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - z80bank_lockup_w(address, data); - return; - - case 0x10: /* Unused */ - case 0x12: - case 0x14: - case 0x16: - z80bank_unused_w(address, data); - return; - - case 0x11: /* PSG */ - case 0x13: - case 0x15: - case 0x17: - psg_write(data); - return; - - case 0x18: /* Unused */ - case 0x19: - case 0x1A: - case 0x1B: - z80bank_unused_w(address, data); - return; - - case 0x1C: /* Test register */ - case 0x1D: - case 0x1E: - case 0x1F: - MainVDP.vdp_test_w(data << 8 | data); - return; - } - } - else - { - /* Invalid VDP address */ - z80bank_lockup_w(address, data); - return; - } -} - - -int z80bank_vdp_r(int address) -{ - if((address & 0xE700E0) == 0xC00000) - { - switch(address & 0x1F) - { - case 0x00: /* Data */ - case 0x02: - return (MainVDP.vdp_data_r() >> 8) & 0xFF; - - case 0x01: /* Data */ - case 0x03: - return MainVDP.vdp_data_r() & 0xFF; - - case 0x04: /* Control */ - case 0x06: - return (0xFC | (MainVDP.vdp_ctrl_r() >> 8)) & 0xFF; - - case 0x05: /* Control */ - case 0x07: - return MainVDP.vdp_ctrl_r() & 0xFF; - - case 0x08: /* HVC */ - case 0x0A: - case 0x0C: - case 0x0E: - return (MainVDP.vdp_hvc_r() >> 8) & 0xFF; - - case 0x09: /* HVC */ - case 0x0B: - case 0x0D: - case 0x0F: - return MainVDP.vdp_hvc_r() & 0xFF; - - case 0x10: /* Lockup */ - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - return z80bank_lockup_r(address); - - case 0x18: /* Unused */ - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - return (z80bank_unused_r(address) | 0xFF); - } - } - else - { - /* Invalid VDP address */ - return z80bank_lockup_r(address); - } - - return 0xFF; -} - - - - -/* - Handlers for access to unused addresses and those which make the - machine lock up. -*/ -void z80bank_unused_w(int address, int data) -{ - error("Z80 bank unused write %06X = %02X (%04X)\n", address, data, z80_get_reg(Z80_PC)); -} - -int z80bank_unused_r(int address) -{ - error("Z80 bank unused read %06X (%04X)\n", address, z80_get_reg(Z80_PC)); - return (address & 1) ? 0x00 : 0xFF; -} - -void z80bank_lockup_w(int address, int data) -{ - printf("Z80 bank lockup write %06X = %02X (%04X)\n", address, data, z80_getpc()); //_reg(Z80_PC)); - gen_running = 0; - // FIXME/TODO - //z80_end_timeslice(); -} - -int z80bank_lockup_r(int address) -{ - printf("Z80 bank lockup read %06X (%04X)\n", address, z80_getpc()); //reg(Z80_PC)); - gen_running = 0; - //z80_end_timeslice(); - // FIXME/TODO - return 0xFF; -} - -} diff --git a/libmednahawk/src/md/membnk.h b/libmednahawk/src/md/membnk.h deleted file mode 100644 index 55e13030bd..0000000000 --- a/libmednahawk/src/md/membnk.h +++ /dev/null @@ -1,22 +0,0 @@ - -#ifndef _MEMBNK_H_ -#define _MEMBNK_H_ - -namespace MDFN_IEN_MD -{ - -/* Function prototypes */ -void z80_write_banked_memory(unsigned int address, unsigned int data); -int z80_read_banked_memory(unsigned int address); - -void z80bank_vdp_w(int address, int data); -int z80bank_vdp_r(int address); - -void z80bank_unused_w(int address, int data); -int z80bank_unused_r(int address); -void z80bank_lockup_w(int address, int data); -int z80bank_lockup_r(int address); - -} - -#endif /* _MEMBNK_H_ */ diff --git a/libmednahawk/src/md/memvdp.cpp b/libmednahawk/src/md/memvdp.cpp deleted file mode 100644 index 0367cb8acd..0000000000 --- a/libmednahawk/src/md/memvdp.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - memvdp.c -- - Memory handlers for when the VDP reads the V-bus during DMA. -*/ - -#include "shared.h" -#include "cart/cart.h" - -namespace MDFN_IEN_MD -{ - -unsigned int vdp_dma_r(unsigned int address) -{ - switch((address >> 21) & 7) - { - case 0: /* Cartridge ROM */ - case 1: - case 2: /* Unused */ - case 3: - return(MD_ExtRead16(address)); - //return READ_WORD_MSB(cart_rom, address); - //return 0xFF00; - - case 4: /* Work RAM */ - case 6: - case 7: - return READ_WORD_MSB(work_ram, address & 0xFFFF); - - case 5: /* Z80 area and I/O chip */ - - /* Z80 area always returns $FFFF */ - if(address <= 0xA0FFFF) - { - /* Return $FFFF only when the Z80 isn't hogging the Z-bus. - (e.g. Z80 isn't reset and 68000 has the bus) */ - return (zbusack == 0) - ? 0xFFFF - : READ_WORD_MSB(work_ram, address & 0xFFFF); - } - else - - /* The I/O chip and work RAM try to drive the data bus which - results in both values being combined in random ways when read. - We return the I/O chip values which seem to have precedence, */ - if(address <= 0xA1001F) - { - uint8 temp = gen_io_r((address >> 1) & 0x0F); - return (temp << 8 | temp); - } - else - - /* All remaining locations access work RAM */ - return READ_WORD_MSB(work_ram, address & 0xFFFF); - } - - return -1; -} - -} diff --git a/libmednahawk/src/md/memvdp.h b/libmednahawk/src/md/memvdp.h deleted file mode 100644 index 97d263e5ca..0000000000 --- a/libmednahawk/src/md/memvdp.h +++ /dev/null @@ -1,14 +0,0 @@ - -#ifndef _MEMVDP_H_ -#define _MEMVDP_H_ - -namespace MDFN_IEN_MD -{ - - -/* Function prototypes */ -unsigned int vdp_dma_r(unsigned int address); - -} - -#endif /* _MEMVDP_H_ */ diff --git a/libmednahawk/src/md/memz80.cpp b/libmednahawk/src/md/memz80.cpp deleted file mode 100644 index 8ac162a5b3..0000000000 --- a/libmednahawk/src/md/memz80.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* - memz80.c -- - Memory handlers for Z80 memory and port access, and the Z80 to - VDP interface. -*/ - -#define LOG_PORT 0 /* 1= Log Z80 I/O port accesses */ - -#include "shared.h" - -namespace MDFN_IEN_MD -{ - - -uint8 MD_Z80_ReadByte(uint16 address) -{ - switch((address >> 13) & 7) - { - case 0: /* Work RAM */ - case 1: - return zram[address & 0x1FFF]; - - case 2: /* YM2612 */ - return MDSound_ReadFM(address & 3); - - case 3: /* VDP */ - // printf("Z80 Read: %08x, %04x, %08x\n", zbank, address, zbank | address); - if((address & 0xFF00) == 0x7F00) - return z80_vdp_r(address); - return 0xFF; - - default: /* V-bus bank */ - return z80_read_banked_memory(zbank | (address & 0x7FFF)); - } - - return 0xFF; -} - - -void MD_Z80_WriteByte(uint16 address, uint8 data) -{ - switch((address >> 13) & 7) - { - case 0: /* Work RAM */ - case 1: - zram[address & 0x1FFF] = data; - return; - - case 2: /* YM2612 */ - fm_write(address & 3, data); - return; - - case 3: /* Bank register and VDP */ - //printf("Z80 Write: %08x, %04x, %08x\n", zbank, address, zbank | address); - switch(address & 0xFF00) - { - case 0x6000: - gen_bank_w(data & 1); - return; - - case 0x7F00: - z80_vdp_w(address, data); - return; - - default: - z80_unused_w(address, data); - return; - } - return; - - default: /* V-bus bank */ - z80_write_banked_memory(zbank | (address & 0x7FFF), data); - return; - } -} - - -int z80_vdp_r(int address) -{ - switch(address & 0xFF) - { - case 0x00: /* VDP data port */ - case 0x02: - return (MainVDP.vdp_data_r() >> 8) & 0xFF; - - case 0x01: /* VDP data port */ - case 0x03: - return (MainVDP.vdp_data_r() & 0xFF); - - case 0x04: /* VDP control port */ - case 0x06: - return (0xFF | ((MainVDP.vdp_ctrl_r() >> 8) & 3)); - - case 0x05: /* VDP control port */ - case 0x07: - return (MainVDP.vdp_ctrl_r() & 0xFF); - - case 0x08: /* HV counter */ - case 0x0A: - case 0x0C: - case 0x0E: - return (MainVDP.vdp_hvc_r() >> 8) & 0xFF; - - case 0x09: /* HV counter */ - case 0x0B: - case 0x0D: - case 0x0F: - return (MainVDP.vdp_hvc_r() & 0xFF); - - case 0x10: /* Unused (PSG) */ - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - return z80_lockup_r(address); - - case 0x18: /* Unused */ - case 0x19: - case 0x1A: - case 0x1B: - return z80_unused_r(address); - - case 0x1C: /* Unused (test register) */ - case 0x1D: - case 0x1E: - case 0x1F: - return z80_unused_r(address); - - default: /* Invalid VDP addresses */ - return z80_lockup_r(address); - } - - return 0xFF; -} - - -void z80_vdp_w(int address, int data) -{ - switch(address & 0xFF) - { - case 0x00: /* VDP data port */ - case 0x01: - case 0x02: - case 0x03: - puts("MOO"); - MainVDP.vdp_data_w(data << 8 | data); - return; - - case 0x04: /* VDP control port */ - case 0x05: - case 0x06: - case 0x07: - MainVDP.vdp_ctrl_w(data << 8 | data); - return; - - case 0x08: /* Unused (HV counter) */ - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - z80_lockup_w(address, data); - return; - - case 0x11: /* PSG */ - case 0x13: - case 0x15: - case 0x17: - psg_write(data); - return; - - case 0x10: /* Unused */ - case 0x12: - case 0x14: - case 0x16: - z80_unused_w(address, data); - - case 0x18: /* Unused */ - case 0x19: - case 0x1A: - case 0x1B: - z80_unused_w(address, data); - return; - - case 0x1C: /* Test register */ - case 0x1D: - case 0x1E: - case 0x1F: - MainVDP.vdp_test_w(data << 8 | data); - return; - - default: /* Invalid VDP addresses */ - z80_lockup_w(address, data); - return; - } -} - - -/* - Port handlers. Ports are unused when not in Mark III compatability mode. - - Games that access ports anyway: - - Thunder Force IV reads port $BF in its interrupt handler. -*/ - -uint8 MD_Z80_ReadPort(uint16 address) -{ -#if LOG_PORT - error("Z80 read port %04X (%04X)\n", port, z80_get_reg(Z80_PC)); -#endif - return 0xFF; -} - -void MD_Z80_WritePort(uint16 address, uint8 data) -{ -#if LOG_PORT - error("Z80 write %02X to port %04X (%04X)\n", data, port, z80_get_reg(Z80_PC)); -#endif -} - - -/* - Handlers for access to unused addresses and those which make the - machine lock up. -*/ -void z80_unused_w(int address, int data) -{ - printf("Z80 unused write %04X = %02X (%04X)\n", address, data, z80_getpc()); -} - -int z80_unused_r(int address) -{ - printf("Z80 unused read %04X (%04X)\n", address, z80_getpc()); - return 0xFF; -} - -void z80_lockup_w(int address, int data) -{ - printf("Z80 lockup write %04X = %02X (%04X)\n", address, data, z80_getpc()); - gen_running = 0; - //z80_end_timeslice(); - // FIXME/TODO -} - -int z80_lockup_r(int address) -{ - printf("Z80 lockup read %04X (%04X)\n", address, z80_getpc()); - gen_running = 0; - //z80_end_timeslice(); - // FIXME/TODO - return 0xFF; -} - -} diff --git a/libmednahawk/src/md/memz80.h b/libmednahawk/src/md/memz80.h deleted file mode 100644 index 4a71e87134..0000000000 --- a/libmednahawk/src/md/memz80.h +++ /dev/null @@ -1,23 +0,0 @@ - -#ifndef _MEMZ80_H_ -#define _MEMZ80_H_ - -namespace MDFN_IEN_MD -{ - -/* Function prototypes */ -uint8 MD_Z80_ReadByte(uint16 address); -void MD_Z80_WriteByte(uint16 address, uint8 data); -uint8 MD_Z80_ReadPort(uint16 address); -void MD_Z80_WritePort(uint16 address, uint8 data); - -void z80_unused_w(int address, int data); -int z80_unused_r(int address); -void z80_lockup_w(int address, int data); -int z80_lockup_r(int address); -int z80_vdp_r(int address); -void z80_vdp_w(int address, int data); - -} - -#endif /* _MEMZ80_H_ */ diff --git a/libmednahawk/src/md/osd_cpu.h b/libmednahawk/src/md/osd_cpu.h deleted file mode 100644 index 51b8913ee8..0000000000 --- a/libmednahawk/src/md/osd_cpu.h +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* -* * -* Define size independent data types and operations. * -* * -* The following types must be supported by all platforms: * -* * -* uint8 - Unsigned 8-bit Integer int8 - Signed 8-bit integer * -* uint16 - Unsigned 16-bit Integer int16 - Signed 16-bit integer * -* uint32 - Unsigned 32-bit Integer int32 - Signed 32-bit integer * -* uint64 - Unsigned 64-bit Integer INT64 - Signed 64-bit integer * -* * -* * -* The macro names for the artithmatic operations are composed as follows: * -* * -* XXX_R_A_B, where XXX - 3 letter operation code (ADD, SUB, etc.) * -* R - The type of the result * -* A - The type of operand 1 * -* B - The type of operand 2 (if binary operation) * -* * -* Each type is one of: U8,8,U16,16,U32,32,U64,64 * -* * -*******************************************************************************/ - - -#ifndef OSD_CPU_H -#define OSD_CPU_H - -/* Combine two 32-bit integers into a 64-bit integer */ -#define COMBINE_64_32_32(A,B) ((((uint64)(A))<<32) | (uint32)(B)) -#define COMBINE_U64_U32_U32(A,B) COMBINE_64_32_32(A,B) - -/* Return upper 32 bits of a 64-bit integer */ -#define HI32_32_64(A) (((uint64)(A)) >> 32) -#define HI32_U32_U64(A) HI32_32_64(A) - -/* Return lower 32 bits of a 64-bit integer */ -#define LO32_32_64(A) ((A) & 0xffffffff) -#define LO32_U32_U64(A) LO32_32_64(A) - -#define DIV_64_64_32(A,B) ((A)/(B)) -#define DIV_U64_U64_U32(A,B) ((A)/(uint32)(B)) - -#define MOD_32_64_32(A,B) ((A)%(B)) -#define MOD_U32_U64_U32(A,B) ((A)%(uint32)(B)) - -#define MUL_64_32_32(A,B) ((A)*(INT64)(B)) -#define MUL_U64_U32_U32(A,B) ((A)*(uint64)(uint32)(B)) - - -/****************************************************************************** - * Union of uint8, uint16 and uint32 in native endianess of the target - * This is used to access bytes and words in a machine independent manner. - * The upper bytes h2 and h3 normally contain zero (16 bit CPU cores) - * thus PAIR.d can be used to pass arguments to the memory system - * which expects 'int' really. - ******************************************************************************/ -typedef union { -#ifdef LSB_FIRST - struct { uint8 l,h,h2,h3; } b; - struct { uint16 l,h; } w; -#else - struct { uint8 h3,h2,h,l; } b; - struct { uint16 h,l; } w; -#endif - uint32 d; -} PAIR; - -#endif /* defined OSD_CPU_H */ diff --git a/libmednahawk/src/md/shared.h b/libmednahawk/src/md/shared.h deleted file mode 100644 index 7c1fb555a7..0000000000 --- a/libmednahawk/src/md/shared.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _SHARED_H_ -#define _SHARED_H_ - -#include "../mednafen.h" -#include "../masmem.h" - -#include -#include - -#define error(...) - -enum -{ - CLOCK_NTSC = 53693175, - CLOCK_PAL = 53203424 // Is this correct? -}; - -#include "macros.h" -#include "hw_cpu/c68k/c68k.h" -#include "hw_cpu/z80-fuse/z80.h" -#include "../state.h" -#include "header.h" -#include "debug.h" -#include "genesis.h" -#include "mem68k.h" -#include "memz80.h" -#include "membnk.h" -#include "memvdp.h" -#include "system.h" -#include "genio.h" -#include "sound.h" -#include "vdp.h" - -using namespace MDFN_IEN_MD; - -#endif /* _SHARED_H_ */ - diff --git a/libmednahawk/src/md/sound.cpp b/libmednahawk/src/md/sound.cpp deleted file mode 100644 index 95cfa3ce93..0000000000 --- a/libmednahawk/src/md/sound.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - sound.c - YM2612 and SN76489 emulation -*/ - -#include "shared.h" -#include "hw_sound/ym2612/Ym2612_Emu.h" -#include "hw_sound/sms_apu/Sms_Apu.h" -#include -#include - -static Stereo_Buffer zebuf; -static Sms_Apu apu; - -/* YM2612 data */ -static Blip_Synth FMSynth; -static int16 fm_last_values[2]; -static int32 fm_last_timestamp; -static int32 fm_div; -static uint32 fm_latch; // Address latch(9-bits) -static Ym2612_Emu FMUnit; -static bool FMReset; - -namespace MDFN_IEN_MD -{ - -static void UpdateFM(void) -{ - int32 cycles = md_timestamp - fm_last_timestamp; - - fm_div -= cycles; - while(fm_div <= 0) - { - int16 new_values[2]; - - new_values[0] = new_values[1] = 0; - - if(!FMReset) - FMUnit.run(new_values); - - //if(FSettings.SndRate) - { - FMSynth.offset((md_timestamp + fm_div) / 15, new_values[0] - fm_last_values[0], zebuf.left()); - FMSynth.offset((md_timestamp + fm_div) / 15, new_values[1] - fm_last_values[1], zebuf.right()); - - fm_last_values[0] = new_values[0]; - fm_last_values[1] = new_values[1]; - } - - fm_div += (72 * 7 * 2); - } - - fm_last_timestamp = md_timestamp; -} - -void fm_write(int address, int data) -{ - if(FMReset) - return; - - if(address & 0x1) - { - UpdateFM(); - - if(fm_latch & 0x100) - FMUnit.write1(fm_latch & 0xFF, data); - else - FMUnit.write0(fm_latch & 0xFF, data); - } - else - { - /* Register latch */ - fm_latch = data | ((address & 0x2) ? 0x100 : 0x00); - } -} - - -int MDSound_ReadFM(int address) -{ - if(FMReset) - return(0x00); - - UpdateFM(); - - return(FMUnit.read()); -} - -void MDSound_SetYM2612Reset(bool new_reset) -{ - // Only call the reset routine when reset begins, and just ignore all - // reads/writes while reset is active. - if(new_reset && !FMReset) - { - UpdateFM(); - FMUnit.reset(); - } - FMReset = new_reset; -} - - -void psg_write(int data) -{ - apu.write_data(md_timestamp / 15, data); -} - -static void RedoVolume(void) -{ - apu.output(zebuf.center(), zebuf.left(), zebuf.right()); - //apu.volume(0.15); - apu.volume(0.25); - FMSynth.volume(1.00); -} - -bool MDSound_SetSoundRate(uint32 rate) -{ - zebuf.set_sample_rate(rate ?rate : 44100, 60); - return(TRUE); -} - -int32 MDSound_Flush(int16 *SoundBuf, const int32 MaxSoundFrames) -{ - int32 FrameCount = 0; - - UpdateFM(); - apu.end_frame(md_timestamp / 15); - - zebuf.end_frame(md_timestamp / 15); - - if(SoundBuf) - FrameCount = zebuf.read_samples(SoundBuf, MaxSoundFrames * 2) / 2; - else - zebuf.clear(); - - fm_last_timestamp = 0; - - return(FrameCount); -} - -int MDSound_Init(void) -{ - MDSound_SetSoundRate(0); - zebuf.clock_rate((long)(CLOCK_NTSC / 15)); - - RedoVolume(); - zebuf.bass_freq(20); - - return(1); -} - -void MDSound_Kill(void) -{ - -} - -void MDSound_Power(void) -{ - FMUnit.reset(); - apu.reset(); -} - -int MDSound_StateAction(StateMem *sm, int load, int data_only) -{ - Sms_ApuState sn_state; - MDFN::LEPacker fm_slizer; - - apu.save_state(&sn_state); - FMUnit.serialize(fm_slizer, false); - - SFORMAT StateRegs[] = - { - SFVAR(fm_last_timestamp), - SFVAR(FMReset), - SFVAR(fm_div), - SFVAR(fm_latch), - - SFARRAYN(&fm_slizer[0], fm_slizer.size(), "FMState"), - - SFARRAY32N(sn_state.volume, 4, "Volume"), - SFARRAY32N(sn_state.sq_period, 3, "SQPeriod"), - SFARRAY32N(sn_state.sq_phase, 3, "SQPhase"), - SFVARN(sn_state.noise_period, "NPeriod"), - SFVARN(sn_state.noise_shifter, "NShifter"), - SFVARN(sn_state.noise_feedback, "NFeedback"), - SFVARN(sn_state.latch, "Latch"), - SFEND - }; - - int ret = MDFNSS_StateAction(sm, load, data_only, StateRegs, "SND"); - - if(load) - { - FMUnit.serialize(fm_slizer, true); - apu.load_state(&sn_state); - } - - return(ret); -} - -}; diff --git a/libmednahawk/src/md/sound.h b/libmednahawk/src/md/sound.h deleted file mode 100644 index fc72d3437e..0000000000 --- a/libmednahawk/src/md/sound.h +++ /dev/null @@ -1,25 +0,0 @@ - -#ifndef _SOUND_H_ -#define _SOUND_H_ - -namespace MDFN_IEN_MD -{ - -/* Function prototypes */ -void fm_write(int address, int data); -void psg_write(int data); - -void MDSound_SetYM2612Reset(bool new_reset); -int MDSound_ReadFM(int address); -void MDSound_SetSoundMultiplier(double multiplier); -bool MDSound_SetSoundRate(uint32 rate); -int32 MDSound_Flush(int16 *SoundBuf, const int32 MaxSoundFrames); -int MDSound_Init(void); -void MDSound_Kill(void); -void MDSound_Power(void); - -int MDSound_StateAction(StateMem *sm, int load, int data_only); - -}; - -#endif /* _SOUND_H_ */ diff --git a/libmednahawk/src/md/system.cpp b/libmednahawk/src/md/system.cpp deleted file mode 100644 index 5028355163..0000000000 --- a/libmednahawk/src/md/system.cpp +++ /dev/null @@ -1,599 +0,0 @@ -/* - Copyright (C) 1999, 2000, 2001, 2002, 2003 Charles MacDonald - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "shared.h" -#include "cart/cart.h" -#include "cd/cd.h" -#include "../md5.h" -#include "../general.h" -#include "../mempatcher.h" - -namespace MDFN_IEN_MD -{ - -enum -{ - REGION_SAME = 1, - REGION_GAME, - REGION_OVERSEAS_NTSC, - REGION_OVERSEAS_PAL, - REGION_DOMESTIC_NTSC, - REGION_DOMESTIC_PAL -}; - - -int MD_HackyHackyMode = 0; -bool MD_IsCD; -static int32 z80_cycle_counter; -static int32 z80_last_ts; -int32 md_timestamp; -static bool suspend68k = FALSE; - -static bool run_cpu; - -void MD_Suspend68K(bool state) -{ - suspend68k = state; -} - -bool MD_Is68KSuspended(void) -{ - return(suspend68k); -} - -static void system_init(bool overseas, bool PAL, bool overseas_reported, bool PAL_reported) -{ - gen_running = 1; - - z80_init(); - z80_readbyte = MD_Z80_ReadByte; - z80_writebyte = MD_Z80_WriteByte; - z80_readport = MD_Z80_ReadPort; - z80_writeport = MD_Z80_WritePort; - - gen_init(); - MDIO_Init(overseas, PAL, overseas_reported, PAL_reported); - MainVDP.SetSettings(PAL, PAL_reported, MDFN_GetSettingB("md.correct_aspect")); - -#ifdef WANT_DEBUGGER - MDDBG_Init(); -#endif - -} - -static void system_reset(bool poweron) -{ - z80_cycle_counter = 0; - z80_last_ts = 0; - - if(MD_IsCD) - MDCD_Reset(poweron); - else - MDCart_Reset(); - - gen_reset(poweron); - if(poweron) - MainVDP.Reset(); - MDSound_Power(); -} - -static void system_shutdown(void) -{ - gen_shutdown(); -} - -void MD_ExitCPULoop(void) -{ - run_cpu = FALSE; -} - -void MD_UpdateSubStuff(void) -{ - int32 max_md_timestamp; - - max_md_timestamp = Main68K.timestamp * 7; - - if(zreset == 1 && zbusreq == 0) - { - z80_cycle_counter += max_md_timestamp - z80_last_ts; - - while(z80_cycle_counter > 0) - { - int32 z80_temp = z80_do_opcode() * 15; - - z80_cycle_counter -= z80_temp; - md_timestamp += z80_temp; - - if(md_timestamp > max_md_timestamp) - { - //printf("Meow: %d\n", md_timestamp - max_md_timestamp); - md_timestamp = max_md_timestamp; - } - MainVDP.Run(); - } - } - z80_last_ts = max_md_timestamp; - - md_timestamp = max_md_timestamp; - MainVDP.Run(); - - //if(MD_IsCD) - // MDCD_Run(master_cycles); -} - -static int system_frame(int do_skip) -{ - run_cpu = TRUE; - - while(run_cpu > 0) - { - if(suspend68k) - { - Main68K.timestamp += 4; - } - else - { - #ifdef WANT_DEBUGGER - if(MD_DebugMode) - MDDBG_CPUHook(); - #endif - - C68k_Exec(&Main68K); - } - - MD_UpdateSubStuff(); - } - return gen_running; -} - -static void Emulate(EmulateSpecStruct *espec) -{ - MDFNMP_ApplyPeriodicCheats(); - - MDIO_BeginTimePeriod(md_timestamp); - - MDINPUT_Frame(); - - if(espec->VideoFormatChanged) - MainVDP.SetPixelFormat(espec->surface->format); //.Rshift, espec->surface->format.Gshift, espec->surface->format.Bshift); - - if(espec->SoundFormatChanged) - MDSound_SetSoundRate(espec->SoundRate); - - MainVDP.SetSurface(espec); //espec->surface, &espec->DisplayRect); - - system_frame(0); - - espec->MasterCycles = md_timestamp; - - espec->SoundBufSize = MDSound_Flush(espec->SoundBuf, espec->SoundBufMaxSize); - -#if 0 - { - static double avg = 0; - static double s_avg = 0; - - avg += (espec->MasterCycles - avg) * 0.05; - s_avg += (espec->SoundBufSize - s_avg) * 0.05; - printf("%f, %f\n", avg / 262 / 10, 48000 / s_avg); - } -#endif - - MDIO_EndTimePeriod(md_timestamp); - - md_timestamp = 0; - z80_last_ts = 0; - Main68K.timestamp = 0; - MainVDP.ResetTS(); - - //MainVDP.SetSurface(NULL); -} - -static void CloseGame(void) -{ - MDCart_Close(); -} - -static bool decode_region_setting(const int setting, bool &overseas, bool &pal) -{ - switch(setting) - { - default: assert(0); - return(false); - - case REGION_OVERSEAS_NTSC: - overseas = TRUE; - pal = FALSE; - return(TRUE); - - case REGION_OVERSEAS_PAL: - overseas = TRUE; - pal = TRUE; - return(TRUE); - - case REGION_DOMESTIC_NTSC: - overseas = FALSE; - pal = FALSE; - return(TRUE); - - case REGION_DOMESTIC_PAL: - overseas = FALSE; - pal = TRUE; - return(TRUE); - } -} - -static int LoadCommonPost(const md_game_info &ginfo); -static int LoadCommonPost(const md_game_info &ginfo) -{ - MDFN_printf(_("ROM: %dKiB\n"), (ginfo.rom_size + 1023) / 1024); - MDFN_printf(_("ROM MD5: 0x%s\n"), md5_context::asciistr(ginfo.md5, 0).c_str()); - MDFN_printf(_("Header MD5: 0x%s\n"), md5_context::asciistr(ginfo.info_header_md5, 0).c_str()); - MDFN_printf(_("Product Code: %s\n"), ginfo.product_code); - MDFN_printf(_("Domestic name: %s\n"), ginfo.domestic_name); // TODO: Character set conversion(shift_jis -> utf-8) - MDFN_printf(_("Overseas name: %s\n"), ginfo.overseas_name); - MDFN_printf(_("Copyright: %s\n"), ginfo.copyright); - if(ginfo.checksum == ginfo.checksum_real) - MDFN_printf(_("Checksum: 0x%04x\n"), ginfo.checksum); - else - MDFN_printf(_("Checksum: 0x%04x\n Warning: calculated checksum(0x%04x) does not match\n"), ginfo.checksum, ginfo.checksum_real); - - MDFN_printf(_("Supported I/O devices:\n")); - MDFN_indent(1); - for(unsigned int iot = 0; iot < sizeof(IO_types) / sizeof(IO_type_t); iot++) - { - if(ginfo.io_support & (1 << IO_types[iot].id)) - MDFN_printf(_("%s\n"), _(IO_types[iot].name)); - } - MDFN_indent(-1); - - MDFNMP_Init(8192, (1 << 24) / 8192); - MDFNMP_AddRAM(65536, 0x7 << 21, work_ram); - - MDFNGameInfo->GameSetMD5Valid = FALSE; - - MDSound_Init(); - - MDFN_printf(_("Supported regions:\n")); - MDFN_indent(1); - if(ginfo.region_support & REGIONMASK_JAPAN_NTSC) - MDFN_printf(_("Japan/Domestic NTSC\n")); - if(ginfo.region_support & REGIONMASK_JAPAN_PAL) - MDFN_printf(_("Japan/Domestic PAL\n")); - if(ginfo.region_support & REGIONMASK_OVERSEAS_NTSC) - MDFN_printf(_("Overseas NTSC\n")); - if(ginfo.region_support & REGIONMASK_OVERSEAS_PAL) - MDFN_printf(_("Overseas PAL\n")); - MDFN_indent(-1); - - { - const int region_setting = MDFN_GetSettingI("md.region"); - const int reported_region_setting = MDFN_GetSettingI("md.reported_region"); - - // Default, in case the game doesn't support any regions! - bool game_overseas = TRUE; - bool game_pal = FALSE; - bool overseas; - bool pal; - bool overseas_reported; - bool pal_reported; - - // Preference order, TODO: Make it configurable - if(ginfo.region_support & REGIONMASK_OVERSEAS_NTSC) - { - game_overseas = TRUE; - game_pal = FALSE; - } - else if(ginfo.region_support & REGIONMASK_JAPAN_NTSC) - { - game_overseas = FALSE; - game_pal = FALSE; - } - else if(ginfo.region_support & REGIONMASK_OVERSEAS_PAL) - { - game_overseas = TRUE; - game_pal = TRUE; - } - else if(ginfo.region_support & REGIONMASK_JAPAN_PAL) // WTF? - { - game_overseas = FALSE; - game_pal = TRUE; - } - - if(region_setting == REGION_GAME) - { - overseas = game_overseas; - pal = game_pal; - } - else - { - decode_region_setting(region_setting, overseas, pal); - } - - if(reported_region_setting == REGION_GAME) - { - overseas_reported = game_overseas; - pal_reported = game_pal; - } - else if(reported_region_setting == REGION_SAME) - { - overseas_reported = overseas; - pal_reported = pal; - } - else - { - decode_region_setting(reported_region_setting, overseas_reported, pal_reported); - } - - MDFN_printf("\n"); - MDFN_printf(_("Active Region: %s %s\n"), overseas ? _("Overseas") : _("Domestic"), pal ? _("PAL") : _("NTSC")); - MDFN_printf(_("Active Region Reported: %s %s\n"), overseas_reported ? _("Overseas") : _("Domestic"), pal_reported ? _("PAL") : _("NTSC")); - - system_init(overseas, pal, overseas_reported, pal_reported); - - if(pal) - MDFNGameInfo->nominal_height = 240; - else - MDFNGameInfo->nominal_height = 224; - - MDFNGameInfo->MasterClock = MDFN_MASTERCLOCK_FIXED(pal ? CLOCK_PAL : CLOCK_NTSC); - - if(pal) - MDFNGameInfo->fps = (int64)CLOCK_PAL * 65536 * 256 / (313 * 3420); - else - MDFNGameInfo->fps = (int64)CLOCK_NTSC * 65536 * 256 / (262 * 3420); - - //printf("%f\n", (double)MDFNGameInfo->fps / 65536 / 256); - } - - if(MDFN_GetSettingB("md.correct_aspect")) - { - MDFNGameInfo->nominal_width = 292; - MDFNGameInfo->lcm_width = 1280; - } - else - { - MDFNGameInfo->nominal_width = 320; - MDFNGameInfo->lcm_width = 320; - } - - MDFNGameInfo->lcm_height = MDFNGameInfo->nominal_height * 2; - - MDFNGameInfo->LayerNames = "BG0\0BG1\0OBJ\0"; - - system_reset(true); - - return(1); -} - -static int Load(const char *name, MDFNFILE *fp) -{ - md_game_info ginfo; - int ret; - - memset(&ginfo, 0, sizeof(md_game_info)); - ret = MDCart_Load(&ginfo, name, fp); - if(ret <= 0) - return(ret); - - memcpy(MDFNGameInfo->MD5, ginfo.md5, 16); - - MD_IsCD = FALSE; - - MD_ExtRead8 = MDCart_Read8; - MD_ExtRead16 = MDCart_Read16; - MD_ExtWrite8 = MDCart_Write8; - MD_ExtWrite16 = MDCart_Write16; - - MDCart_LoadNV(); - - if(!LoadCommonPost(ginfo)) - return(0); - - return(1); -} - -static int LoadCD(std::vector *CDInterfaces) -{ - md_game_info ginfo; - - memset(&ginfo, 0, sizeof(md_game_info)); - - MD_IsCD = TRUE; - - if(!MDCD_Load(CDInterfaces, &ginfo)) - { - puts("BOOM"); - return(FALSE); - } - - memcpy(MDFNGameInfo->MD5, ginfo.md5, 16); - - if(!LoadCommonPost(ginfo)) - return(0); - - return(TRUE); -} - -static bool TestMagicCD(std::vector *CDInterfaces) -{ - return(MDCD_TestMagic(CDInterfaces)); -} - -static void DoSimpleCommand(int cmd) -{ - switch(cmd) - { - case MDFN_MSC_POWER: system_reset(true); break; - case MDFN_MSC_RESET: system_reset(false); break; - } -} - -static int StateAction(StateMem *sm, int load, int data_only) -{ - int ret = 1; - unsigned int c68k_state_len = C68k_Get_State_Max_Len(); - //zero 29-oct-2012 - remove dynamic array - uint8* c68k_state = new uint8[c68k_state_len]; - - C68k_Save_State(&Main68K, c68k_state); - - SFORMAT StateRegs[] = - { - SFARRAY(work_ram, 65536), - SFARRAY(zram, 8192), - SFVAR(zbusreq), - SFVAR(zreset), - SFVAR(zbusack), - SFVAR(zirq), - SFVAR(zbank), - - SFVAR(md_timestamp), - SFVAR(suspend68k), - SFVAR(z80_cycle_counter), - - SFARRAY(c68k_state, c68k_state_len), - SFEND - }; - - - ret &= MDFNSS_StateAction(sm, load, data_only, StateRegs, "MAIN"); - ret &= z80_state_action(sm, load, data_only, "Z80"); - ret &= MDINPUT_StateAction(sm, load, data_only); - ret &= MainVDP.StateAction(sm, load, data_only); - ret &= MDSound_StateAction(sm, load, data_only); - ret &= MDCart_StateAction(sm, load, data_only); - - if(load) - { - C68k_Load_State(&Main68K, c68k_state); - z80_set_interrupt(zirq); - } - - delete[] c68k_state; - return(ret); -} - -static const MDFNSetting_EnumList RegionList[] = -{ - { "game", REGION_GAME, gettext_noop("Match game's header."), gettext_noop("Emulate the region that the game indicates it expects to run in via data in the header(or in an internal database for a few games that may have bad header data).") }, - - { "overseas_ntsc", REGION_OVERSEAS_NTSC, gettext_noop("Overseas(non-Japan), NTSC"), gettext_noop("Region used in North America.") }, - { "overseas_pal", REGION_OVERSEAS_PAL, gettext_noop("Overseas(non-Japan), PAL"), gettext_noop("Region used in Europe.") }, - - { "domestic_ntsc", REGION_DOMESTIC_NTSC, gettext_noop("Domestic(Japan), NTSC"), gettext_noop("Region used in Japan.") }, - { "domestic_pal", REGION_DOMESTIC_PAL, gettext_noop("Domestic(Japan), PAL"), gettext_noop("Probably an invalid region, but available for testing purposes anyway.") }, - - { NULL, 0 } -}; - -static const MDFNSetting_EnumList ReportedRegionList[] = -{ - { "same", REGION_SAME, gettext_noop("Match the region emulated.") }, - - { "game", REGION_GAME, gettext_noop("Match game's header."), gettext_noop("This option, in conjunction with the \"md.region\" setting, can be used to run all games at NTSC speeds, or all games at PAL speeds.") }, - - { "overseas_ntsc", REGION_OVERSEAS_NTSC, gettext_noop("Overseas(non-Japan), NTSC"), gettext_noop("Region used in North America.") }, - { "overseas_pal", REGION_OVERSEAS_PAL, gettext_noop("Overseas(non-Japan), PAL"), gettext_noop("Region used in Europe.") }, - - { "domestic_ntsc", REGION_DOMESTIC_NTSC, gettext_noop("Domestic(Japan), NTSC"), gettext_noop("Region used in Japan.") }, - { "domestic_pal", REGION_DOMESTIC_PAL, gettext_noop("Domestic(Japan), PAL"), gettext_noop("Probably an invalid region, but available for testing purposes anyway.") }, - - { NULL, 0 }, -}; - -static MDFNSetting MDSettings[] = -{ - { "md.region", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Emulate the specified region's Genesis/MegaDrive"), NULL, MDFNST_ENUM, "game", NULL, NULL, NULL, NULL, RegionList }, - { "md.reported_region", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE, gettext_noop("Region reported to the game."), NULL, MDFNST_ENUM, "same", NULL, NULL, NULL, NULL, ReportedRegionList }, - - { "md.cdbios", MDFNSF_EMU_STATE, gettext_noop("Path to the CD BIOS"), gettext_noop("SegaCD/MegaCD emulation is currently nonfunctional."), MDFNST_STRING, "us_scd1_9210.bin" }, - - { "md.correct_aspect", MDFNSF_CAT_VIDEO, gettext_noop("Correct the aspect ratio."), NULL, MDFNST_BOOL, "1" }, - - // off, teamplay, 4way, auto - // { "md.input.4player", MDFNSF_EMU_STATE | MDFNSF_UNTRUSTED_SAFE | MDFNSF_CAT_INPUT, gettext_noop("Which 4-player adapter to use."), NULL, MDFNST_STRING, "auto", NULL, NULL }, - - { NULL } -}; - -static const FileExtensionSpecStruct KnownExtensions[] = -{ - { ".bin", gettext_noop("Super Magic Drive binary ROM Image") }, - { ".smd", gettext_noop("Super Magic Drive interleaved format ROM Image") }, - { ".md", gettext_noop("Multi Game Doctor format ROM Image") }, - { NULL, NULL } -}; - -void SetLayerEnableMask(uint64 mask) -{ - MainVDP.SetLayerEnableMask(mask); -} - -} - - -MDFNGI EmulatedMD = -{ - "md", - "Sega Genesis/MegaDrive", - KnownExtensions, - MODPRIO_INTERNAL_HIGH, - #ifdef WANT_DEBUGGER - &DBGInfo, - #else - NULL, - #endif - &MDInputInfo, - Load, - MDCart_TestMagic, - LoadCD, - TestMagicCD, - CloseGame, - SetLayerEnableMask, - NULL, - NULL, - NULL, - NULL, //InstallReadPatch, - NULL, //RemoveReadPatches, - NULL, //MemRead, - false, - StateAction, - Emulate, - MDINPUT_SetInput, - DoSimpleCommand, - MDSettings, - 0, // MasterClock(set in game loading code) - 0, - TRUE, // Multires possible? - - 0, // lcm_width // Calculated in game load - 0, // lcm_height // Calculated in game load - NULL, // Dummy - - - // We want maximum values for nominal width and height here so the automatic fullscreen setting generation code will have - // selected a setting suitable if aspect ratio correction is turned off. - 320, // Nominal width(adjusted in game loading code, with aspect ratio correction enabled, it's 292, otherwise 320) - 240, // Nominal height(adjusted in game loading code to 224 for NTSC, and 240 for PAL) - 1024, // Framebuffer width - 512, // Framebuffer height - - 2, // Number of output sound channels -}; - diff --git a/libmednahawk/src/md/system.h b/libmednahawk/src/md/system.h deleted file mode 100644 index 99d0738f4b..0000000000 --- a/libmednahawk/src/md/system.h +++ /dev/null @@ -1,43 +0,0 @@ - -#ifndef _SYSTEM_H_ -#define _SYSTEM_H_ - -namespace MDFN_IEN_MD -{ - -/* Input devices */ -#define MAX_DEVICES (8) /* Unsure of maximum */ -#define DEVICE_2BUTTON (0) /* 2-button gamepad */ -#define DEVICE_3BUTTON (1) /* 3-button gamepad */ -#define DEVICE_6BUTTON (2) /* 6-button gamepad */ - -/* Input bitmasks */ -#define INPUT_MODE (0x00000800) -#define INPUT_Z (0x00000400) -#define INPUT_Y (0x00000200) -#define INPUT_X (0x00000100) -#define INPUT_START (0x00000080) -#define INPUT_C (0x00000040) -#define INPUT_B (0x00000020) -#define INPUT_A (0x00000010) -#define INPUT_RIGHT (0x00000008) -#define INPUT_LEFT (0x00000004) -#define INPUT_DOWN (0x00000002) -#define INPUT_UP (0x00000001) - -extern int32 md_timestamp; - -void MD_ExitCPULoop(void); -void MD_Suspend68K(bool state); -void MD_68KHALTHack(void); -bool MD_Is68KSuspended(void); - -void MD_UpdateSubStuff(); - -extern bool MD_IsCD; -extern int MD_HackyHackyMode; - -} - -#endif /* _SYSTEM_H_ */ - diff --git a/libmednahawk/src/md/vcnt.h b/libmednahawk/src/md/vcnt.h deleted file mode 100644 index 3e69770a7b..0000000000 --- a/libmednahawk/src/md/vcnt.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __MDFN_MD_VCNT_H_ -#define __MDFN_MD_VCNT_H_ - -// TODO: Recheck vc30 and PAL counts - -static const uint8 vc28_ntsc[262] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, - 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, - 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -static const uint8 vc30_ntsc[262] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, //0x06, -}; - -static const uint8 vc28_pal[313] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, - - 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, - 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, - 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, - 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, - 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -static const uint8 vc30_pal[313] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, - 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, - 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, - 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, - 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; -#endif diff --git a/libmednahawk/src/md/vdp.cpp b/libmednahawk/src/md/vdp.cpp deleted file mode 100644 index c4eaf81e23..0000000000 --- a/libmednahawk/src/md/vdp.cpp +++ /dev/null @@ -1,1924 +0,0 @@ -/* - Copyright (C) 1999, 2000, 2001, 2002, 2003 Charles MacDonald - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -/* - FIXME: - - HC table for 320-pixel mode is mapped to cycles incorrectly. - -*/ - -#include "shared.h" -#include "vcnt.h" -#include "hvc.h" - -namespace MDFN_IEN_MD -{ - -/* - only update window clip on window change (?) - fix leftmost window/nta render and window bug - sprite masking isn't right in sonic/micromachines 2, but - seems ok in galaxy force 2 -*/ - - -/*--------------------------------------------------------------------------*/ -/* Init, reset, shutdown functions */ -/*--------------------------------------------------------------------------*/ - -const uint8 MDVDP::shift_table[4] = { 6, 7, 0, 8 }; -const uint8 MDVDP::col_mask_table[4] = { 0x1F, 0x3F, 0x1F, 0x7F }; -const uint16 MDVDP::row_mask_table[4] = { 0x0FF, 0x1FF, 0x2FF, 0x3FF }; -const uint32 MDVDP::y_mask_table[4] = { 0x1FC0, 0x1FC0, 0x1F80, 0x1F00 }; - - /* Attribute expansion table */ -const uint32 MDVDP::atex_table[8] = { - 0x00000000, 0x10101010, 0x20202020, 0x30303030, - 0x40404040, 0x50505050, 0x60606060, 0x70707070 - }; - -MDVDP::MDVDP() -{ - int bx, ax, i; - - UserLE = ~0; - - /* Allocate and align pixel look-up tables */ - lut_base = (uint8 *)malloc((LUT_MAX * LUT_SIZE) + LUT_SIZE); - lut[0] = (uint8 *)(((uint64)lut_base + LUT_SIZE) & ~(LUT_SIZE - 1)); - for(i = 1; i < LUT_MAX; i += 1) - { - lut[i] = lut[0] + (i * LUT_SIZE); - } - - /* Make pixel look-up table data */ - for(bx = 0; bx < 0x100; bx += 1) - for(ax = 0; ax < 0x100; ax += 1) - { - uint16 index = (bx << 8) | (ax); - lut[0][index] = make_lut_bg(bx, ax); - lut[1][index] = make_lut_obj(bx, ax); - lut[2][index] = make_lut_bg_ste(bx, ax); - lut[3][index] = make_lut_obj_ste(bx, ax); - lut[4][index] = make_lut_bgobj_ste(bx, ax); - } - - /* Make sprite name look-up table */ - make_name_lut(); -} - -void MDVDP::SetSettings(bool PAL, bool PAL_reported, bool auto_aspect) -{ - is_pal = PAL; - report_pal = PAL_reported; - WantAutoAspect = auto_aspect; -} - -MDVDP::~MDVDP() -{ - if(lut_base) free(lut_base); -} - -void MDVDP::RedoViewport(void) -{ - // Warning: Don't test these viewport variables to determine what video mode we're in(do it right, with reg[0xC]) -#if 0 - bitmap.viewport.x = 0x20; - bitmap.viewport.y = 0x20; - bitmap.viewport.w = WantAutoAspect ? ((reg[0xC] & 0x1) ? 320 : 256) : 320; - bitmap.viewport.h = (reg[0x1] & 0x8) ? 240 : 224; - - if((reg[0xC] & 0x06) == 0x06) - bitmap.viewport.h *= 2; - - bitmap.viewport.changed = 1; -#endif -} - -void MDVDP::SyncColors(void) -{ - /* Update colors */ - for(int i = 0; i < 0x40; i++) - color_update(i, cram[i]); - - color_update(0x00, cram[border]); - color_update(0x40, cram[border]); - color_update(0x80, cram[border]); -} - -void MDVDP::Reset(void) -{ - memset(sat, 0, sizeof(sat)); - memset(vram, 0, sizeof(vram)); - memset(cram, 0, sizeof(cram)); - memset(vsram, 0, sizeof(vsram)); - - memset(bg_name_dirty, 0, sizeof(bg_name_dirty)); - memset(bg_name_list, 0, sizeof(bg_name_list)); - bg_list_index = 0; - memset(bg_pattern_cache, 0, sizeof(bg_pattern_cache)); - memset(reg, 0, sizeof(reg)); - - addr = addr_latch = code = pending = buffer = status = 0; - ntab = ntbb = ntwb = satb = hscb = 0; - sat_base_mask = 0xFE00; - sat_addr_mask = 0x01FF; - - /* Mark all colors as dirty to force a palette update */ - border = 0x00; - - playfield_shift = 6; - playfield_col_mask = 0x1F; - playfield_row_mask = 0x0FF; - y_mask = 0x1FC0; - - hint_pending = vint_pending = 0; - counter = 0; - visible_frame_end = 0xE0; - v_counter = v_update = 0; - - fifo_simu_count = 0; - dma_fill_latch = 0; - DMASource = 0; - DMALength = 0; - dma_fill = 0; - im2_flag = 0; - - vdp_last_ts = 0; - vdp_cycle_counter = 102; - vdp_line_phase = 5; - vdp_hcounter_start_ts = 0; - scanline = visible_frame_end; - - MD_Suspend68K(FALSE); - z80_set_interrupt(FALSE); - C68k_Set_IRQ(&Main68K, 0); - - RedoViewport(); - - memset(&clip, 0, sizeof(clip)); - memset(&pixel_32, 0, sizeof(pixel_32)); - - SyncColors(); -} - - -/*--------------------------------------------------------------------------*/ -/* Memory access functions */ -/*--------------------------------------------------------------------------*/ -void MDVDP::vdp_ctrl_w(uint16 data) -{ - if(pending == 0) - { - if((data & 0xC000) == 0x8000) - { - uint8 r = (data >> 8) & 0x1F; - uint8 d = (data >> 0) & 0xFF; - vdp_reg_w(r, d); - } - else - { - pending = 1; - } - - addr = ((addr_latch & 0xC000) | (data & 0x3FFF)) & 0xFFFF; - code = ((code & 0x3C) | ((data >> 14) & 0x03)) & 0x3F; - } - else - { - /* Clear pending flag */ - pending = 0; - - /* Update address and code registers */ - addr = ((addr & 0x3FFF) | ((data & 3) << 14)) & 0xFFFF; - code = ((code & 0x03) | ((data >> 2) & 0x3C)) & 0x3F; - - /* Save address bits A15 and A14 */ - addr_latch = (addr & 0xC000); - - if((code & 0x20) && (reg[1] & 0x10)) - { - // printf("DMA: %02x, %d, %d\n", reg[23], scanline, DMALength); - switch(reg[23] & 0xC0) - { - case 0x00: /* V bus to VDP DMA */ - case 0x40: /* V bus to VDP DMA */ - if((code & 0x0F) != 0x1 && (code & 0x0F) != 0x3 && (code & 0x0F) != 0x5) - printf("Invalid code for V bus to VDP dma: %02x\n", code); - status |= 0x2; - Recalc68KSuspend(); - break; - - case 0x80: /* VRAM fill */ - if((code & 0x0F) != 0x1) - printf("Invalid code for fill dma: %02x\n", code); - dma_fill = 1; - break; - - case 0xC0: /* VRAM copy */ - if((code & 0x0F) != 0x0) - printf("Invalid code for copy dma: %02x\n", code); - status |= 0x2; - break; - } - } - } -} - -uint16 MDVDP::vdp_ctrl_r(void) -{ - #if 1 - uint16 backup_status = status; - bool backup_pending = pending; - #endif - - uint16 temp = 0; //(0x4e71 & 0xFC00); - pending = 0; - - status &= ~0x0001; - status |= report_pal ? 0x0001 : 0x0000; - - if(fifo_simu_count >= 4) - temp |= 0x0100; - - if(fifo_simu_count == 0) - temp |= 0x0200; // FIFO empty - - temp |= status & 0x03FF; - - if(!(reg[1] & 0x40)) - temp |= 0x08; - - status &= ~0x0020; // Clear sprite hit flag on reads. - status &= ~0x0040; // Clear sprite overflow flag on reads. - - - if(MD_HackyHackyMode) - { - status = backup_status; - pending = backup_pending; - } - return (temp); -} - -INLINE void MDVDP::WriteCRAM(uint16 data) -{ - const int index = (addr >> 1) & 0x3F; - uint16 *p = &cram[index]; - uint16 packed_data; - - data &= 0x0EEE; - packed_data = PACK_CRAM(data); - - if(packed_data != *p) - { - *p = packed_data; - - // Must come before the next color_update call! - color_update(index, *p); - - if(index == border || !index) - { - color_update(0x00, cram[border]); - } - - } -} - -// Only used for DMA fill and VRAM->VRAM DMA copy. -// Since CRAM and VSRAM only allow 16-bit accesses, trying -// to use DMA fill on CRAM and CSRAM will probably not work so well. -INLINE void MDVDP::MemoryWrite8(uint8 data) -{ - switch(code & 0x0F) - { - case 0x01: /* VRAM */ - /* Copy SAT data to the internal SAT */ - if((addr & sat_base_mask) == satb) - { - sat[addr & sat_addr_mask] = data; - } - - /* Only write unique data to VRAM */ - if(data != READ_BYTE_LSB(vram, addr & 0xFFFF)) - { - /* Write data to VRAM */ - WRITE_BYTE_LSB(vram, addr & 0xFFFF, data); - - /* Update the pattern cache */ - MARK_BG_DIRTY(addr); - } - break; - case 0x03: /* CRAM */ - WriteCRAM(data); - break; - - case 0x05: /* VSRAM */ - vsram[(addr & 0x7E) >> 1] = data; - break; - } - - /* Bump address register */ - addr += reg[15]; -} - - -INLINE void MDVDP::MemoryWrite16(uint16 data) -{ - switch(code & 0x0F) - { - case 0x01: /* VRAM */ - /* Byte-swap data if A0 is set */ - if(addr & 1) data = (data >> 8) | (data << 8); - - /* Copy SAT data to the internal SAT */ - if((addr & sat_base_mask) == satb) - { - //MDFN_en16lsb(&sat[addr & sat_addr_mask], data); - MDFN_en16lsb(&sat[addr & sat_addr_mask & ~1], data); - } - - /* Only write unique data to VRAM */ - if(data != READ_WORD_LSB(vram, addr & 0xFFFE)) - { - /* Write data to VRAM */ - WRITE_WORD_LSB(vram, addr & 0xFFFE, data); - - /* Update the pattern cache */ - MARK_BG_DIRTY(addr); - } - break; - - case 0x03: /* CRAM */ - WriteCRAM(data); - break; - - case 0x05: /* VSRAM */ - vsram[(addr & 0x7E) >> 1] = data; - break; - } - - /* Bump address register */ - addr += reg[15]; -} - -INLINE void MDVDP::Recalc68KSuspend(void) -{ - MD_Suspend68K((fifo_simu_count > 4) || ((status & 0x2) && (reg[23] & 0xC0) < 0x80)); -} - -void MDVDP::vdp_data_w(uint16 data) -{ - /* Clear pending flag */ - pending = 0; - - if(fifo_simu_count < 16) - fifo_simu_count++; - - //printf("%04x, %d\n", data, scanline); - MemoryWrite16(data); - - if(dma_fill) - { - dma_fill_latch = data >> 8; - status |= 0x2; - //printf("DMA Fill: %d, %02x, %04x\n", DMALength, code & 0x0F, data); - dma_fill = 0; - } - - Recalc68KSuspend(); -} - -uint16 MDVDP::vdp_data_r(void) -{ - uint16 temp = 0; - - /* Clear pending flag */ - if(!MD_HackyHackyMode) - pending = 0; - - switch(code & 0x0F) - { - case 0x00: /* VRAM */ - temp = READ_WORD_LSB(vram, addr & 0xFFFE); - break; - - case 0x08: /* CRAM */ - temp = cram[(addr & 0x7E) >> 1]; - temp = UNPACK_CRAM(temp); - break; - - case 0x04: /* VSRAM */ - temp = vsram[(addr & 0x7E) >> 1]; - break; - } - - /* Bump address register */ - if(!MD_HackyHackyMode) - addr += reg[15]; - - /* return data */ - return (temp); -} - - -/* - The reg[] array is updated at the *end* of this function, so the new - register data can be compared with the previous data. -*/ -void MDVDP::vdp_reg_w(uint8 r, uint8 d) -{ - // If in mode 4, ignore writes to registers >= 0x0B - if(!(reg[1] & 0x4) && r >= 0x0B) - return; - - switch(r) - { - case 0x00: /* CTRL #1 */ - break; - - case 0x01: /* CTRL #2 */ - /* Change the frame timing */ - visible_frame_end = (d & 8) ? 0xF0 : 0xE0; - - /* Check if the viewport height has actually been changed */ - if((reg[1] & 8) != (d & 8)) - { - reg[1] = d; - RedoViewport(); - } - break; - - case 0x02: /* NTAB */ - ntab = (d << 10) & 0xE000; - break; - - case 0x03: /* NTWB */ - ntwb = (d << 10) & 0xF800; - if(reg[12] & 1) ntwb &= 0xF000; - break; - - case 0x04: /* NTBB */ - ntbb = (d << 13) & 0xE000; - break; - - case 0x05: /* SATB */ - sat_base_mask = (reg[12] & 1) ? 0xFC00 : 0xFE00; - sat_addr_mask = (reg[12] & 1) ? 0x03FF : 0x01FF; - satb = (d << 9) & sat_base_mask; - break; - - case 0x07: - d &= 0x3F; - - /* Check if the border color has actually changed */ - if(border != d) - { - /* Mark the border color as modified */ - border = d; - - color_update(0x00, cram[border]); - color_update(0x40, cram[border]); - color_update(0x80, cram[border]); - } - break; - - case 0x0C: - - /* See if the S/TE mode bit has changed */ - if((reg[0x0C] & 8) != (d & 8)) - { - reg[0x0C] = d; - - SyncColors(); - } - - /* Check interlace mode 2 setting */ - im2_flag = ((d & 0x06) == 0x06) ? 1 : 0; - - /* The following register updates check this value */ - reg[0x0C] = d; - - RedoViewport(); - - /* Update display-dependent registers */ - vdp_reg_w(0x03, reg[0x03]); - vdp_reg_w(0x05, reg[0x05]); - - break; - - case 0x0D: /* HSCB */ - hscb = (d << 10) & 0xFC00; - break; - - case 0x10: /* Playfield size */ - playfield_shift = shift_table[(d & 3)]; - playfield_col_mask = col_mask_table[(d & 3)]; - playfield_row_mask = row_mask_table[(d >> 4) & 3]; - y_mask = y_mask_table[(d & 3)]; - break; - - - case 0x13: DMALength &= 0xFF00; - DMALength |= d << 0; - break; - - case 0x14: DMALength &= 0x00FF; - DMALength |= d << 8; - break; - - case 0x15: DMASource &= 0xFFFF00; - DMASource |= d << 0; - break; - - case 0x16: DMASource &= 0xFF00FF; - DMASource |= d << 8; - break; - - case 0x17: DMASource &= 0x00FFFF; - DMASource |= d << 16; - break; - } - - /* Write new register value */ - reg[r] = d; -} - - -uint16 MDVDP::vdp_hvc_r(void) -{ - int32 cycle = (md_timestamp - vdp_hcounter_start_ts) % 3420; - int hc; - uint8 vc; - - hc = (reg[0xC] & 1) ? cycle2hc40[cycle] : cycle2hc32[cycle]; - - if(is_pal) - vc = (reg[0x1] & 0x8) ? vc30_pal[v_counter] : vc28_pal[v_counter]; - else - vc = (reg[0x1] & 0x8) ? vc30_ntsc[v_counter] : vc28_ntsc[v_counter]; - - if(im2_flag) - { - vc = (vc << 1) | (vc >> 7); - } - - return (vc << 8 | hc); -} - -INLINE void MDVDP::CheckDMA(void) -{ - // - static const int vbus_cc[2][2] = - { - { 16, 167 }, - { 18, 205 }, - }; - static const int copy_cc[2][2] = - { - { 8, 83 }, - { 9, 102 }, - }; - static const int fill_cc[2][2] = - { - { 16, 167 }, - { 18, 205 }, - }; - const int vb_index = ((status & 0x8) >> 3) | (((reg[1] & 0x40) ^ 0x40) >> 6); - - if(!(status & 0x2)) - return; - - switch(reg[23] & 0xC0) - { - case 0x00: /* V bus to VDP DMA */ - case 0x40: /* V bus to VDP DMA */ - { - int32 runcount = (vbus_cc[reg[0x0C] & 1][vb_index] + 1) / 2; - - //printf("%08x, %d, %02x\n", DMASource, DMALength, reg[0xC] & 0x81); - do - { - uint16 temp = vdp_dma_r((DMASource & 0x7FFFFF) << 1); - DMASource = (DMASource & 0xFF0000) | ((DMASource + 1) & 0xFFFF); - MemoryWrite16(temp); - DMALength--; - runcount--; - } while (DMALength && runcount); - - if(!DMALength) - { - status &= ~0x2; - Recalc68KSuspend(); - } - break; - } - case 0x80: // DMA Fill - { - int32 runcount = fill_cc[reg[0x0C] & 1][vb_index]; - - do - { - MemoryWrite8(dma_fill_latch); - DMALength--; - runcount--; - } while(DMALength && runcount); - - if(!DMALength) - status &= ~0x2; - - break; - } - - case 0xC0: // VRAM copy - { - int32 runcount = copy_cc[reg[0x0C] & 1][vb_index]; - - do - { - uint8 temp = READ_BYTE_LSB(vram, DMASource & 0xFFFF); - WRITE_BYTE_LSB(vram, addr, temp); - MARK_BG_DIRTY(addr); - if((addr & sat_base_mask) == satb) - { - sat[addr & sat_addr_mask] = temp; - } - DMASource = (DMASource & 0xFF0000) | ((DMASource + 1) & 0xFFFF); - addr = (addr + reg[15]) & 0xFFFF; - DMALength--; - runcount--; - } while(DMALength && runcount); - - if(!DMALength) - { - status &= ~0x2; - } - break; - } - - } -} - - -void MDVDP::vdp_test_w(uint16 value) -{ -} - -void MDVDP::Run(void) -{ - #include "vdp_run.inc" -} - -void MDVDP::ResetTS(void) -{ - //printf("%d, %d\n", vdp_cycle_counter, md_timestamp); - vdp_hcounter_start_ts -= vdp_last_ts; - vdp_last_ts = 0; -} - -int MDVDP::StateAction(StateMem *sm, int load, int data_only) -{ - SFORMAT StateRegs[] = - { - SFARRAY(sat, 0x400), - SFARRAY(vram, 0x10000), - SFARRAY16(cram, 0x40), - SFARRAY16(vsram, 0x40), - SFARRAY(reg, 0x20), - - SFVAR(addr), - SFVAR(addr_latch), - SFVAR(code), - SFVAR(pending), - SFVAR(buffer), - SFVAR(status), - SFVAR(ntab), - SFVAR(ntbb), - SFVAR(ntwb), - SFVAR(satb), - SFVAR(hscb), - SFVAR(sat_base_mask), - SFVAR(sat_addr_mask), - - SFVAR(dma_fill_latch), - SFVAR(DMASource), - SFVAR(DMALength), - SFVAR(border), - SFVAR(playfield_shift), - SFVAR(playfield_col_mask), - SFVAR(playfield_row_mask), - SFVAR(y_mask), - - SFVAR(hint_pending), - SFVAR(vint_pending), - SFVAR(counter), - SFVAR(dma_fill), - SFVAR(im2_flag), - SFVAR(visible_frame_end), - SFVAR(v_counter), - SFVAR(v_update), - SFVAR(vdp_cycle_counter), - SFVAR(vdp_last_ts), - SFVAR(vdp_line_phase), - SFVAR(vdp_hcounter_start_ts), - SFVAR(scanline), - - SFVAR(fifo_simu_count), - - //SFVAR(is_pal), SFVAR(report_pal), - SFEND - }; - - int ret = MDFNSS_StateAction(sm, load, data_only, StateRegs, "VDP"); - - if(load) - { - vdp_line_phase %= 8; // tied to table in vdp_run.inc !!! - - status &= ~(0x200 | 0x100); - - for(int i = 0; i < 0x800; i++) - { - bg_name_list[i] = i; - bg_name_dirty[i] = 0xFF; - } - bg_list_index = 0x800; - - for(int i = 0; i < 0x40; i++) - color_update(i, cram[i]); - - color_update(0x00, cram[border]); - - RedoViewport(); - - update_bg_pattern_cache(); - } - - - return(ret); -} - -/* - - - - - - - -*/ - -/* Draw a single 16-pixel column */ -#define DRAW_COLUMN(ATTR, LINE) \ - atex = atex_table[(ATTR >> 13) & 7]; \ - src = &bg_pattern_cache[(ATTR & 0x1FFF) << 4 | (LINE)]; \ - *dst++ = (*src++ | atex); \ - *dst++ = (*src++ | atex); \ - ATTR >>= 16; \ - atex = atex_table[(ATTR >> 13) & 7]; \ - src = &bg_pattern_cache[(ATTR & 0x1FFF) << 4 | (LINE)]; \ - *dst++ = (*src++ | atex); \ - *dst++ = (*src++ | atex); - -/* Draw a single 16-pixel column */ -#define DRAW_COLUMN_IM2(ATTR, LINE) \ - atex = atex_table[(ATTR >> 13) & 7]; \ - offs = (ATTR & 0x03FF) << 5 | (ATTR & 0x1800) << 4 | (LINE); \ - if(ATTR & 0x1000) offs ^= 0x10; \ - src = &bg_pattern_cache[offs]; \ - *dst++ = (*src++ | atex); \ - *dst++ = (*src++ | atex); \ - ATTR >>= 16; \ - atex = atex_table[(ATTR >> 13) & 7]; \ - offs = (ATTR & 0x03FF) << 5 | (ATTR & 0x1800) << 4 | (LINE); \ - if(ATTR & 0x1000) offs ^= 0x10; \ - src = &bg_pattern_cache[offs]; \ - *dst++ = (*src++ | atex); \ - *dst++ = (*src++ | atex); - -/* - gcc complains about this: - *lb++ = table[(*lb << 8) |(*src++ | palette)]; - .. claiming the result on lb is undefined. - So we manually advance lb and use constant offsets into the line buffer. -*/ -#define DRAW_SPRITE_TILE \ - for(int p = 0; p < 8; p++) \ - { \ - if(((lb[p] & 0x8F) > 0x80) && (*src & 0xF)) \ - status |= 0x20; \ - lb[p] = table[(lb[p] << 8) |(*src++ | palette)]; \ - } - - - -void MDVDP::SetPixelFormat(const MDFN_PixelFormat &format) -{ - /* Make pixel data tables */ - for(int i = 0; i < 0x200; i += 1) - { - const int mult = 17; // 0x7 | 0x8 = 0xF, 0xF * 17 = 0xFF - int r, g, b; - - r = (i >> 6) & 7; - g = (i >> 3) & 7; - b = (i >> 0) & 7; - - //r = g = b = 1; - pixel_32_lut[0][i] = format.MakeColor(mult * r, mult * g, mult * b); - pixel_32_lut[1][i] = format.MakeColor(mult * (r << 1), mult * (g << 1), mult * (b << 1)); - pixel_32_lut[2][i] = format.MakeColor(mult * (r|8), mult * (g|8), mult * (b|8)); - } - - SyncColors(); -} - -void MDVDP::SetSurface(EmulateSpecStruct *espec_arg) //MDFN_Surface *new_surface, MDFN_Rect *new_rect) -{ - espec = espec_arg; - surface = espec->surface; - rect = &espec->DisplayRect; -} - - -void MDVDP::SetLayerEnableMask(uint64 mask) -{ - UserLE = mask; -} - - -void MDVDP::make_name_lut(void) -{ - int col, row; - int vcol, vrow; - int width, height; - int flipx, flipy; - int i, name; - - memset(name_lut, 0, sizeof(name_lut)); - - for(i = 0; i < 0x400; i += 1) - { - vcol = col = i & 3; - vrow = row = (i >> 2) & 3; - height = (i >> 4) & 3; - width = (i >> 6) & 3; - flipx = (i >> 8) & 1; - flipy = (i >> 9) & 1; - - if(flipx) - vcol = (width - col); - if(flipy) - vrow = (height - row); - - name = vrow + (vcol * (height + 1)); - - if((row > height) || col > width) - name = -1; - - name_lut[i] = name; - } -} - - -/*--------------------------------------------------------------------------*/ -/* Line render function */ -/*--------------------------------------------------------------------------*/ - -void MDVDP::render_line(int line) -{ - /* Line buffers */ - uint8 tmp_buf[0x400]; /* Temporary buffer */ - uint8 bg_buf[0x400]; /* Merged background buffer */ - uint8 nta_buf[0x400]; /* Plane A / Window line buffer */ - uint8 ntb_buf[0x400]; /* Plane B line buffer */ - uint8 obj_buf[0x400]; /* Object layer line buffer */ - uint8 *lb = tmp_buf; - - const int32 vp_x = 0x20; - const int32 vp_w = ((reg[0xC] & 0x1) ? 320 : 256); - - // Our display output window is nominally XXX*224 with NTSC, XXX*240 with PAL. - - if(line == 120) - { - rect->x = 0; - rect->w = WantAutoAspect ? vp_w : 320; - } - - if((reg[1] & 0x40) == 0x00 || line >= visible_frame_end) - { - /* Use the overscan color to clear the screen */ - memset(&lb[vp_x], 0x40 | border, vp_w); - } - else - { - update_bg_pattern_cache(); - window_clip(line); - - if(im2_flag) - { - render_ntx_im2(0, line, nta_buf); - render_ntx_im2(1, line, ntb_buf); - } - else - { - if(reg[0x0B] & 4) - { - render_ntx_vs(0, line, nta_buf); - render_ntx_vs(1, line, ntb_buf); - } - else - { - render_ntx(0, line, nta_buf); - render_ntx(1, line, ntb_buf); - } - } - - if(im2_flag) - render_ntw_im2(line, nta_buf); - else - render_ntw(line, nta_buf); - - if(!(UserLE & 0x1)) - memset(&nta_buf[0x20], 0, (reg[12] & 1) ? 320 : 256); - - if(!(UserLE & 0x2)) - memset(&ntb_buf[0x20], 0, (reg[12] & 1) ? 320 : 256); - - if(reg[12] & 8) - { - merge(&nta_buf[0x20], &ntb_buf[0x20], &bg_buf[0x20], lut[2], (reg[12] & 1) ? 320 : 256); - memset(&obj_buf[0x20], 0, (reg[12] & 1) ? 320 : 256); - - if(im2_flag) - render_obj_im2(line, obj_buf, lut[3]); - else - render_obj(line, obj_buf, lut[3]); - - if(!(UserLE & 0x4)) - memset(&obj_buf[0x20], 0, (reg[12] & 1) ? 320 : 256); - - merge(&obj_buf[0x20], &bg_buf[0x20], &lb[0x20], lut[4], (reg[12] & 1) ? 320 : 256); - } - else - { - if(UserLE & 0x4) - merge(&nta_buf[0x20], &ntb_buf[0x20], &lb[0x20], lut[0], (reg[12] & 1) ? 320 : 256); - - if(im2_flag) - render_obj_im2(line, lb, lut[1]); - else - render_obj(line, lb, lut[1]); - - if(!(UserLE & 0x4)) - merge(&nta_buf[0x20], &ntb_buf[0x20], &lb[0x20], lut[0], (reg[12] & 1) ? 320 : 256); - } - - if(reg[0] & 0x20) - { - memset(&lb[vp_x], 0x40 | border, 0x08); - } - } - - const unsigned int lines_per_frame = is_pal ? 313 : 262; // FIXME: have this as an inline function(duplicated in vdp_run.inc) - unsigned int cvp_line = (line + ((240 - visible_frame_end) >> 1)) % lines_per_frame; - - if(cvp_line < 240) - { - int width = (reg[12] & 1) ? 320 : 256; - uint32 *out = &surface->pixels[(cvp_line * (espec->InterlaceOn ? 2 : 1) + espec->InterlaceField) * surface->pitch32]; - - //printf("ION: %d, IFIELD: %d --- %d, %d, im2f=%d\n", espec->InterlaceOn, espec->InterlaceField, line, ((line + ((240 - visible_frame_end) >> 1)) * (espec->InterlaceOn ? 2 : 1) + espec->InterlaceField), im2_flag); - //printf("%d, %d %d\n", line, espec->InterlaceOn, espec->InterlaceField); - - if(!WantAutoAspect) - { - int half_diff = (320 - vp_w) >> 1; - const uint32 cb = pixel_32[0x40 | border]; //surface->MakeColor(0,0,0); - - for(int i = 0; i < half_diff; i++) - { - out[i] = cb; - out[half_diff + vp_w + i] = cb; - } - out += (320 - vp_w) >> 1; - } - - remap_32(lb + 0x20, out, pixel_32, width); - } -} -/*--------------------------------------------------------------------------*/ -/* Window rendering */ -/*--------------------------------------------------------------------------*/ - -void MDVDP::render_ntw(int line, uint8 *buf) -{ - int column, v_line, width; - uint32 *nt, *src, *dst, atex, atbuf; - - v_line = (line & 7) << 1; - width = (reg[12] & 1) ? 7 : 6; - - nt = (uint32 *)&vram[ntwb | ((line >> 3) << width)]; - dst = (uint32 *)&buf[0x20 + (clip[1].left << 4)]; - - for(column = clip[1].left; column < clip[1].right; column += 1) - { - atbuf = le32toh(nt[column]); - DRAW_COLUMN(atbuf, v_line) - } -} - -void MDVDP::render_ntw_im2(int line, uint8 *buf) -{ - int column, v_line, width; - uint32 *nt, *src, *dst, atex, atbuf, offs; - - v_line = ((line & 7) << 1 | ((status >> 4) & 1)) << 1; - width = (reg[12] & 1) ? 7 : 6; - - nt = (uint32 *)&vram[ntwb | ((line >> 3) << width)]; - dst = (uint32 *)&buf[0x20 + (clip[1].left << 4)]; - - for(column = clip[1].left; column < clip[1].right; column += 1) - { - atbuf = le32toh(nt[column]); - DRAW_COLUMN_IM2(atbuf, v_line) - } -} - -/*--------------------------------------------------------------------------*/ -/* Background plane rendering */ -/*--------------------------------------------------------------------------*/ - -void MDVDP::render_ntx(int which, int line, uint8 *buf) -{ - int column; - int start, end; - int index; - int shift; - int nametable_row_mask = (playfield_col_mask >> 1); - int v_line; - uint32 atex, atbuf, *src, *dst; - uint16 xascroll, xbscroll, xscroll; - int y_scroll; - uint8 *nt; - uint16 *vs; - uint16 table; - - - table = (which) ? ntbb : ntab; - - get_hscroll(line, &xascroll, &xbscroll); - xscroll = (which) ? xbscroll : xascroll; - - shift = (xscroll & 0x0F); - index = ((playfield_col_mask + 1) >> 1) - ((xscroll >> 4) & nametable_row_mask); - - if(which) - { - start = 0; - end = (reg[0x0C] & 1) ? 20 : 16; - } - else - { -// Looks correct if clip[0].left has 1 subtracted -// Otherwise window has gap between endpoint and where the first normal -// nta column starts - - if(clip[0].enable == 0) return; - start = clip[0].left; - end = clip[0].right; - index = (index + clip[0].left) & nametable_row_mask; - } - - vs = &vsram[which ? 1 : 0]; - - y_scroll = vs[0]; - y_scroll = (line + (y_scroll & 0x3FF)) & playfield_row_mask; - v_line = (y_scroll & 7) << 1; - nt = &vram[table + (((y_scroll >> 3) << playfield_shift) & y_mask)]; - - if(shift) - { - dst = (uint32 *)&buf[0x20-(0x10-shift)]; - atbuf = MDFN_de32lsb(&nt[((index-1) & nametable_row_mask) << 2]); - DRAW_COLUMN(atbuf, v_line) - } - buf = (buf + 0x20 + shift); - dst = (uint32 *)&buf[start<<4]; - - for(column = start; column < end; column += 1, index += 1) - { - atbuf = MDFN_de32lsb(&nt[(index & nametable_row_mask) << 2]); - DRAW_COLUMN(atbuf, v_line) - } -} - - -void MDVDP::render_ntx_im2(int which, int line, uint8 *buf) -{ - int column; - int start, end; - int index; - int shift; - int nametable_row_mask = (playfield_col_mask >> 1); - int v_line; - uint32 atex, atbuf, *src, *dst; - uint16 xascroll, xbscroll, xscroll; - int y_scroll; - uint8 *nt; - uint16 *vs; - uint16 table; - uint32 offs; - - table = (which) ? ntbb : ntab; - - get_hscroll(line, &xascroll, &xbscroll); - xscroll = (which) ? xbscroll : xascroll; - - shift = (xscroll & 0x0F); - index = ((playfield_col_mask + 1) >> 1) - ((xscroll >> 4) & nametable_row_mask); - - if(which) - { - start = 0; - end = (reg[0x0C] & 1) ? 20 : 16; - } - else - { - if(clip[0].enable == 0) return; - start = clip[0].left; - end = clip[0].right; - index = (index + clip[0].left) & nametable_row_mask; - } - - vs = &vsram[which ? 1 : 0]; - - y_scroll = vs[0]; - y_scroll = (line + ((y_scroll >> 1) & 0x3FF)) & playfield_row_mask; - v_line = (((y_scroll & 7) << 1) | ((status >> 4) & 1)) << 1; - nt = &vram[table + (((y_scroll >> 3) << playfield_shift) & y_mask)]; - - if(shift) - { - dst = (uint32 *)&buf[0x20-(0x10-shift)]; - atbuf = MDFN_de32lsb(&nt[((index-1) & nametable_row_mask) << 2]); - DRAW_COLUMN_IM2(atbuf, v_line) - } - buf = (buf + 0x20 + shift); - dst = (uint32 *)&buf[start<<4]; - - for(column = start; column < end; column += 1, index += 1) - { - atbuf = MDFN_de32lsb(&nt[(index & nametable_row_mask) << 2]); - DRAW_COLUMN_IM2(atbuf, v_line) - } -} - - -void MDVDP::render_ntx_vs(int which, int line, uint8 *buf) -{ - int column; - int start, end; - int index; - int shift; - int nametable_row_mask = (playfield_col_mask >> 1); - int v_line; - uint32 atex, atbuf, *src, *dst; - uint16 xascroll, xbscroll, xscroll; - int y_scroll; - uint8 *nt; - uint16 *vs; - uint16 table; - - table = (which) ? ntbb : ntab; - - get_hscroll(line, &xascroll, &xbscroll); - xscroll = (which) ? xbscroll : xascroll; - shift = (xscroll & 0x0F); - index = ((playfield_col_mask + 1) >> 1) - ((xscroll >> 4) & nametable_row_mask); - - if(which) - { - start = 0; - end = (reg[0x0C] & 1) ? 20 : 16; - } - else - { - if(clip[0].enable == 0) return; - start = clip[0].left; - end = clip[0].right; - index = (index + clip[0].left) & nametable_row_mask; - } - - vs = &vsram[which ? 1 : 0]; - end = (reg[0x0C] & 1) ? 20 : 16; - - if(shift) - { - dst = (uint32 *)&buf[0x20-(0x10-shift)]; - y_scroll = (line & playfield_row_mask); - v_line = (y_scroll & 7) << 1; - nt = &vram[table + (((y_scroll >> 3) << playfield_shift) & y_mask)]; - atbuf = MDFN_de32lsb(&nt[((index-1) & nametable_row_mask) << 2]); - DRAW_COLUMN(atbuf, v_line) - } - - buf = (buf + 0x20 + shift); - dst = (uint32 *)&buf[start << 4]; - - for(column = start; column < end; column += 1, index += 1) - { - y_scroll = vs[column << 1]; - y_scroll = (line + (y_scroll & 0x3FF)) & playfield_row_mask; - v_line = (y_scroll & 7) << 1; - nt = &vram[table + (((y_scroll >> 3) << playfield_shift) & y_mask)]; - atbuf = MDFN_de32lsb(&nt[(index & nametable_row_mask) << 2]); - DRAW_COLUMN(atbuf, v_line) - } -} -/*--------------------------------------------------------------------------*/ -/* Helper functions (cache update, hscroll, window clip) */ -/*--------------------------------------------------------------------------*/ - -void MDVDP::update_bg_pattern_cache(void) -{ - int i; - uint8 x, y, c; - uint16 name; - - if(!bg_list_index) return; - - for(i = 0; i < bg_list_index; i += 1) - { - name = bg_name_list[i]; - bg_name_list[i] = 0; - - for(y = 0; y < 8; y += 1) - { - if(bg_name_dirty[name] & (1 << y)) - { - uint8 *dst = (uint8 *)&bg_pattern_cache[name << 4]; - uint32 bp = READ_32_LSB(vram, (name << 5) | (y << 2)); - - for(x = 0; x < 8; x += 1) - { - c = (bp >> ((x ^ 3) << 2)) & 0x0F; - dst[0x00000 | (y << 3) | (x)] = (c); - dst[0x20000 | (y << 3) | (x ^ 7)] = (c); - dst[0x40000 | ((y ^ 7) << 3) | (x)] = (c); - dst[0x60000 | ((y ^ 7) << 3) | (x ^ 7)] = (c); - } - } - } - bg_name_dirty[name] = 0; - } - bg_list_index = 0; -} - -void MDVDP::get_hscroll(int line, uint16 *scrolla, uint16 *scrollb) -{ - switch(reg[11] & 3) - { - case 0: /* Full-screen */ - *scrolla = READ_WORD_LSB(vram, hscb + 0); - *scrollb = READ_WORD_LSB(vram, hscb + 2); - break; - - case 1: /* First 8 lines */ - *scrolla = READ_WORD_LSB(vram, hscb + ((line & 7) << 2) + 0); - *scrollb = READ_WORD_LSB(vram, hscb + ((line & 7) << 2) + 2); - break; - - case 2: /* Every 8 lines */ - *scrolla = READ_WORD_LSB(vram, hscb + ((line & ~7) << 2) + 0); - *scrollb = READ_WORD_LSB(vram, hscb + ((line & ~7) << 2) + 2); - break; - - case 3: /* Every line */ - *scrolla = READ_WORD_LSB(vram, hscb + (line << 2) + 0); - *scrollb = READ_WORD_LSB(vram, hscb + (line << 2) + 2); - break; - } - - *scrolla &= 0x03FF; - *scrollb &= 0x03FF; -} - -void MDVDP::window_clip(int line) -{ - /* Window size and invert flags */ - int hp = (reg[17] & 0x1F); - int hf = (reg[17] >> 7) & 1; - int vp = (reg[18] & 0x1F) << 3; - int vf = (reg[18] >> 7) & 1; - - /* Display size */ - int sw = (reg[12] & 1) ? 20 : 16; - - /* Clear clipping data */ - memset(&clip, 0, sizeof(clip)); - - /* Check if line falls within window range */ - if(vf == (line >= vp)) - { - /* Window takes up entire line */ - clip[1].right = sw; - clip[1].enable = 1; - } - else - { - /* Perform horizontal clipping; the results are applied in reverse - if the horizontal inversion flag is set */ - int a = hf; - int w = hf ^ 1; - - if(hp) - { - if(hp > sw) - { - /* Plane W takes up entire line */ - clip[w].right = sw; - clip[w].enable = 1; - } - else - { - /* Window takes left side, Plane A takes right side */ - clip[w].right = hp; - clip[a].left = hp; - clip[a].right = sw; - clip[0].enable = clip[1].enable = 1; - } - } - else - { - /* Plane A takes up entire line */ - clip[a].right = sw; - clip[a].enable = 1; - } - } -} - - - -/*--------------------------------------------------------------------------*/ -/* Look-up table functions */ -/*--------------------------------------------------------------------------*/ - -/* Input (bx): d5-d0=color, d6=priority, d7=unused */ -/* Input (ax): d5-d0=color, d6=priority, d7=unused */ -/* Output: d5-d0=color, d6=priority, d7=unused */ -int MDVDP::make_lut_bg(int bx, int ax) -{ - int bf, bp, b; - int af, ap, a; - int x = 0; - int c; - - bf = (bx & 0x7F); - bp = (bx >> 6) & 1; - b = (bx & 0x0F); - - af = (ax & 0x7F); - ap = (ax >> 6) & 1; - a = (ax & 0x0F); - - c = (ap ? (a ? af : (b ? bf : x)) : \ - (bp ? (b ? bf : (a ? af : x)) : \ - ( (a ? af : (b ? bf : x)) ))); - - /* Strip palette bits from transparent pixels */ - if((c & 0x0F) == 0x00) c = (c & 0xC0); - - return (c); -} - - -/* Input (bx): d5-d0=color, d6=priority, d7=sprite pixel marker */ -/* Input (sx): d5-d0=color, d6=priority, d7=unused */ -/* Output: d5-d0=color, d6=zero, d7=sprite pixel marker */ -int MDVDP::make_lut_obj(int bx, int sx) -{ - int bf, bp, bs, b; - int sf, sp, s; - int c; - - bf = (bx & 0x3F); - bs = (bx >> 7) & 1; - bp = (bx >> 6) & 1; - b = (bx & 0x0F); - - sf = (sx & 0x3F); - sp = (sx >> 6) & 1; - s = (sx & 0x0F); - - if(s == 0) return bx; - - if(bs) - { - c = bf; - } - else - { - c = (sp ? (s ? sf : bf) : \ - (bp ? (b ? bf : (s ? sf : bf)) : \ - (s ? sf : bf) )); - } - - /* Strip palette bits from transparent pixels */ - if((c & 0x0F) == 0x00) c = (c & 0xC0); - - return (c | 0x80); -} - - -/* Input (bx): d5-d0=color, d6=priority, d7=unused */ -/* Input (sx): d5-d0=color, d6=priority, d7=unused */ -/* Output: d5-d0=color, d6=priority, d7=intensity select (half/normal) */ -int MDVDP::make_lut_bg_ste(int bx, int ax) -{ - int bf, bp, b; - int af, ap, a; - int gi; - int x = 0; - int c; - - bf = (bx & 0x7F); - bp = (bx >> 6) & 1; - b = (bx & 0x0F); - - af = (ax & 0x7F); - ap = (ax >> 6) & 1; - a = (ax & 0x0F); - - gi = (ap | bp) ? 0x80 : 0x00; - - c = (ap ? (a ? af : (b ? bf : x )) : \ - (bp ? (b ? bf : (a ? af : x )) : \ - ( (a ? af : (b ? bf : x)) ))); - - c |= gi; - - /* Strip palette bits from transparent pixels */ - if((c & 0x0F) == 0x00) c = (c & 0xC0); - - return (c); -} - - -/* Input (bx): d5-d0=color, d6=priority, d7=sprite pixel marker */ -/* Input (sx): d5-d0=color, d6=priority, d7=unused */ -/* Output: d5-d0=color, d6=priority, d7=sprite pixel marker */ -int MDVDP::make_lut_obj_ste(int bx, int sx) -{ - int bf, bs; - int sf; - int c; - - bf = (bx & 0x7F); - bs = (bx >> 7) & 1; - sf = (sx & 0x7F); - - if((sx & 0x0F) == 0) return bx; - - c = (bs) ? bf : sf; - - /* Strip palette bits from transparent pixels */ - if((c & 0x0F) == 0x00) c = (c & 0xC0); - - return (c | 0x80); -} - - -/* Input (bx): d5-d0=color, d6=priority, d7=intensity (half/normal) */ -/* Input (sx): d5-d0=color, d6=priority, d7=sprite marker */ -/* Output: d5-d0=color, d6=intensity (half/normal), d7=(double/invalid) */ -int MDVDP::make_lut_bgobj_ste(int bx, int sx) -{ - int c; - - int bf = (bx & 0x3F); - int bp = (bx >> 6) & 1; - int bi = (bx & 0x80) ? 0x40 : 0x00; - int b = (bx & 0x0F); - - int sf = (sx & 0x3F); - int sp = (sx >> 6) & 1; - int si = (sx & 0x40); - int s = (sx & 0x0F); - - if(bi & 0x40) si |= 0x40; - - if(sp) - { - if(s) - { - if((sf & 0x3E) == 0x3E) - { - if(sf & 1) - { - c = (bf | 0x00); - } - else - { - c = (bx & 0x80) ? (bf | 0x80) : (bf | 0x40); - } - } - else - { - if(sf == 0x0E || sf == 0x1E || sf == 0x2E) - { - c = (sf | 0x40); - } - else - { - c = (sf | si); - } - } - } - else - { - c = (bf | bi); - } - } - else - { - if(bp) - { - if(b) - { - c = (bf | bi); - } - else - { - if(s) - { - if((sf & 0x3E) == 0x3E) - { - if(sf & 1) - { - c = (bf | 0x00); - } - else - { - c = (bx & 0x80) ? (bf | 0x80) : (bf | 0x40); - } - } - else - { - if(sf == 0x0E || sf == 0x1E || sf == 0x2E) - { - c = (sf | 0x40); - } - else - { - c = (sf | si); - } - } - } - else - { - c = (bf | bi); - } - } - } - else - { - if(s) - { - if((sf & 0x3E) == 0x3E) - { - if(sf & 1) - { - c = (bf | 0x00); - } - else - { - c = (bx & 0x80) ? (bf | 0x80) : (bf | 0x40); - } - } - else - { - if(sf == 0x0E || sf == 0x1E || sf == 0x2E) - { - c = (sf | 0x40); - } - else - { - c = (sf | si); - } - } - } - else - { - c = (bf | bi); - } - } - } - - if((c & 0x0f) == 0x00) c = (c & 0xC0); - - return (c); -} - -/*--------------------------------------------------------------------------*/ -/* Remap functions */ -/*--------------------------------------------------------------------------*/ - -void MDVDP::remap_32(uint8 *src, uint32 *dst, uint32 *table, int length) -{ - int count; - for(count = 0; count < length; count += 1) - { - *dst++ = table[*src++]; - } -} - -/*--------------------------------------------------------------------------*/ -/* Merge functions */ -/*--------------------------------------------------------------------------*/ - -void MDVDP::merge(uint8 *srca, uint8 *srcb, uint8 *dst, uint8 *table, int width) -{ - int i; - for(i = 0; i < width; i += 1) - { - uint8 a = srca[i]; - uint8 b = srcb[i]; - uint8 c = table[(b << 8) | (a)]; - dst[i] = c; - } -} - -/*--------------------------------------------------------------------------*/ -/* Color update functions */ -/*--------------------------------------------------------------------------*/ - -void MDVDP::color_update(int index, uint16 data) -{ - if(reg[12] & 8) - { - pixel_32[0x00 | index] = pixel_32_lut[0][data]; - pixel_32[0x40 | index] = pixel_32_lut[1][data]; - pixel_32[0x80 | index] = pixel_32_lut[2][data]; - } - else - { - uint32 temp = pixel_32_lut[1][data]; - pixel_32[0x00 | index] = temp; - pixel_32[0x40 | index] = temp; - pixel_32[0x80 | index] = temp; - } -} - -/*--------------------------------------------------------------------------*/ -/* Object render functions */ -/*--------------------------------------------------------------------------*/ - -void MDVDP::parse_satb(int line) -{ - static const uint8 sizetab[] = {8, 16, 24, 32}; - uint8 *p, *q, link = 0; - uint16 ypos; - int pixel_count = 0; - int max_pixel_count = (reg[12] & 1) ? 320 : 256; - - int count; - int height; - - int limit = (reg[12] & 1) ? 20 : 16; - int total = (reg[12] & 1) ? 80 : 64; - - object_index_count = 0; - - for(count = 0; count < total; count += 1) - { - q = &sat[link << 3]; - p = &vram[satb + (link << 3)]; - - ypos = MDFN_de16lsb(&q[0]); - - if(im2_flag) - ypos = (ypos >> 1) & 0x1FF; - else - ypos &= 0x1FF; - - height = sizetab[q[3] & 3]; - - if((line >= ypos) && (line < (ypos + height))) - { - pixel_count += sizetab[(q[3] >> 2) & 3]; - - if(pixel_count > max_pixel_count) - { - status |= 0x40; - return; - } - - object_info[object_index_count].ypos = MDFN_de16lsb(&q[0]); - object_info[object_index_count].xpos = MDFN_de16lsb(&p[6]); - - // using xpos from internal satb stops sprite x - // scrolling in bloodlin.bin, - // but this seems to go against the test prog - //object_info[object_index_count].xpos = MDFN_de16lsb(&q[6]); - object_info[object_index_count].attr = MDFN_de16lsb(&p[4]); - object_info[object_index_count].size = q[3]; - object_info[object_index_count].index = count; - - object_index_count += 1; - - if(object_index_count == limit) - { - status |= 0x40; - return; - } - } - - link = q[2] & 0x7F; - if(link == 0) break; - } -} - -void MDVDP::render_obj(int line, uint8 *buf, uint8 *table) -{ - uint16 ypos; - uint16 attr; - uint16 xpos; - uint8 sizetab[] = {8, 16, 24, 32}; - uint8 size; - uint8 *src; - - int count; - int pixellimit = (reg[12] & 1) ? 320 : 256; - int pixelcount = 0; - int width; - int height; - int v_line; - int column; - int sol_flag = 0; - int left = 0x80; - int right = 0x80 + ((reg[12] & 1) ? 320 : 256); - - uint8 *s, *lb; - uint16 name, index; - uint8 palette; - - int attr_mask, nt_row; - - if(object_index_count == 0) return; - - for(count = 0; count < object_index_count; count += 1) - { - size = object_info[count].size & 0x0f; - xpos = object_info[count].xpos; - xpos &= 0x1ff; - - width = sizetab[(size >> 2) & 3]; - - if(xpos != 0) sol_flag = 1; - else - if(xpos == 0 && sol_flag) return; - - if(pixelcount > pixellimit) return; - pixelcount += width; - - if(((xpos + width) >= left) && (xpos < right)) - { - ypos = object_info[count].ypos; - ypos &= 0x1ff; - - attr = object_info[count].attr; - attr_mask = (attr & 0x1800); - - height = sizetab[size & 3]; - palette = (attr >> 9) & 0x70; - - v_line = (line - ypos); - nt_row = (v_line >> 3) & 3; - v_line = (v_line & 7) << 1; - - name = (attr & 0x07FF); - s = &name_lut[((attr >> 3) & 0x300) | (size << 4) | (nt_row << 2)]; - - lb = (uint8 *)&buf[0x20 + (xpos - 0x80)]; - if((0x20 + (xpos - 0x80)) < 0 || xpos >= 0x300) - printf("BLAH: %d\n", 0x20 + (xpos - 0x80)); - width >>= 3; - for(column = 0; column < width; column += 1, lb+=8) - { - index = attr_mask | ((name + s[column]) & 0x07FF); - src = (uint8 *)&bg_pattern_cache[(index << 4) | (v_line)]; - DRAW_SPRITE_TILE; - } - } - } -} - -void MDVDP::render_obj_im2(int line, uint8 *buf, uint8 *table) -{ - uint16 ypos; - uint16 attr; - uint16 xpos; - uint8 sizetab[] = {8, 16, 24, 32}; - uint8 size; - uint8 *src; - - int count; - int pixellimit = (reg[12] & 1) ? 320 : 256; - int pixelcount = 0; - int width; - int height; - int v_line; - int column; - int sol_flag = 0; - int left = 0x80; - int right = 0x80 + ((reg[12] & 1) ? 320 : 256); - - uint8 *s, *lb; - uint16 name, index; - uint8 palette; - uint32 offs; - - int attr_mask, nt_row; - - if(object_index_count == 0) return; - - for(count = 0; count < object_index_count; count += 1) - { - size = object_info[count].size & 0x0f; - xpos = object_info[count].xpos; - xpos &= 0x1ff; - - width = sizetab[(size >> 2) & 3]; - - if(xpos != 0) sol_flag = 1; - else - if(xpos == 0 && sol_flag) return; - - if(pixelcount > pixellimit) return; - pixelcount += width; - - if(((xpos + width) >= left) && (xpos < right)) - { - ypos = object_info[count].ypos; - ypos = (ypos >> 1) & 0x1ff; - - attr = object_info[count].attr; - attr_mask = (attr & 0x1800); - - height = sizetab[size & 3]; - palette = (attr >> 9) & 0x70; - - v_line = (line - ypos); - nt_row = (v_line >> 3) & 3; - v_line = (((v_line & 7) << 1) | ((status >> 4) & 1)) << 1; - - name = (attr & 0x03FF); - s = &name_lut[((attr >> 3) & 0x300) | (size << 4) | (nt_row << 2)]; - - lb = (uint8 *)&buf[0x20 + (xpos - 0x80)]; - - width >>= 3; - for(column = 0; column < width; column += 1, lb+=8) - { - index = (name + s[column]) & 0x3ff; - offs = (index << 5) | (attr_mask << 4) | v_line; - if(attr & 0x1000) offs ^= 0x10; - - src = (uint8 *)&bg_pattern_cache[offs]; - DRAW_SPRITE_TILE; - } - } - } -} - - - - -} - - - - - - - diff --git a/libmednahawk/src/md/vdp.h b/libmednahawk/src/md/vdp.h deleted file mode 100644 index 03d7a1129b..0000000000 --- a/libmednahawk/src/md/vdp.h +++ /dev/null @@ -1,254 +0,0 @@ -#ifndef _VDP_H_ -#define _VDP_H_ - -namespace MDFN_IEN_MD -{ - -/* Pack and unpack CRAM data */ -#define PACK_CRAM(d) ((((d)&0xE00)>>9)|(((d)&0x0E0)>>2)|(((d)&0x00E)<<5)) -#define UNPACK_CRAM(d) ((((d)&0x1C0)>>5)|((d)&0x038)<<2|(((d)&0x007)<<9)) - -/* Mark a pattern as dirty */ -#define MARK_BG_DIRTY(addr) \ -{ \ - int name = (addr >> 5) & 0x7FF; \ - if(bg_name_dirty[name] == 0) \ - { \ - assert(bg_list_index < 0x800); \ - bg_name_list[bg_list_index] = name; \ - bg_list_index += 1; \ - } \ - bg_name_dirty[name] |= (1 << ((addr >> 2) & 0x07)); \ -} - -/* Look-up pixel table information */ -#define LUT_MAX (5) -#define LUT_SIZE (0x10000) - -/* Clip structure */ -typedef struct -{ - uint8 left; - uint8 right; - uint8 enable; -} clip_t; - -typedef struct -{ - uint16 ypos; - uint16 xpos; - uint16 attr; - uint8 size; - uint8 index; -} object_info_t; - -class MDVDP -{ - public: - - /* Function prototypes */ - MDVDP(void); - ~MDVDP(); - - void SetSettings(bool PAL, bool PAL_reported, bool auto_aspect); - - void Reset(void); - void vdp_ctrl_w(uint16 data); - uint16 vdp_ctrl_r(void); - void vdp_data_w(uint16 data); - uint16 vdp_data_r(void); - void vdp_reg_w(uint8 r, uint8 d); - uint16 vdp_hvc_r(void); - void dma_copy(void); - void dma_vbus(void); - void vdp_test_w(uint16 value); - - void SyncColors(void); - - void SetPixelFormat(const MDFN_PixelFormat &format); //int rs, int gs, int bs); - void SetSurface(EmulateSpecStruct *espec); //MDFN_Surface *surface, MDFN_Rect *rect); - - void SetLayerEnableMask(uint64 mask); - - int StateAction(StateMem *sm, int load, int data_only); - void ResetTS(void); - - inline int IntAckCallback(int int_level) - { - // printf("Callback: %d; %d %d, %d\n", int_level, hint_pending, vint_pending, scanline); - switch(int_level) - { - case 4: - hint_pending = 0; - status &= ~0x0080; - vint_pending = 0; - break; - - case 6: - status &= ~0x0080; - vint_pending = 0; - break; - } - // C68k_Set_IRQ(&Main68K, 0); - - return C68K_INT_ACK_AUTOVECTOR; - } - - private: - /* Tables that define the playfield layout */ - static const uint8 shift_table[4]; - static const uint8 col_mask_table[4]; - static const uint16 row_mask_table[4]; - static const uint32 y_mask_table[4]; - - /* Attribute expansion table */ - static const uint32 atex_table[8]; - - enum - { - //(Totally guesstimated and bsed VDP timing :b) - - // H-counter starts at H40: 0xE4, H32: 0xE9 from here - // H-int is done here as well? - // Increment scanline here as well? - VDPLP_HRETRACE_0 = 0, // H40: 56, H32: 46 - - // H-counter starts at 0 from here. - VDPLP_HRETRACE_1, // H40: 16, H32: 13 - - // Vertical interrupt happens here on the appropriate line - VDPLP_VISIBLE_0, // H40: 4, H32: 4 - VDPLP_VISIBLE_1, // H40: 320 H32: 256 - - // Vblank flag is set here - VDPLP_VISIBLE_2, // H40: 26 H32: 23 - VDPLP_TOTAL - }; - - - uint8 sat[0x400]; /* Internal copy of sprite attribute table */ - uint8 vram[0x10000]; /* Video RAM (64Kx8) */ - uint16 cram[0x40]; /* On-chip color RAM (64x9) */ - uint16 vsram[0x40]; /* On-chip vertical scroll RAM (40x11) */ - uint8 reg[0x20]; /* Internal VDP registers (23x8) */ - - uint16 addr; /* Address register */ - uint16 addr_latch; /* Latched A15, A14 of address */ - uint8 code; /* Code register */ - uint8 pending; /* Pending write flag */ - uint16 buffer; /* Read buffer */ - uint16 status; /* VDP status flags */ - uint16 ntab; /* Name table A base address */ - uint16 ntbb; /* Name table B base address */ - uint16 ntwb; /* Name table W base address */ - uint16 satb; /* Sprite attribute table base address */ - uint16 hscb; /* Horizontal scroll table base address */ - uint16 sat_base_mask; /* Base bits of SAT */ - uint16 sat_addr_mask; /* Index bits of SAT */ - - uint8 dma_fill_latch; - uint32 DMASource; - uint16 DMALength; - - uint8 border; /* Border color index */ - uint8 bg_name_dirty[0x800]; /* 1= This pattern is dirty */ - uint16 bg_name_list[0x800]; /* List of modified pattern indices */ - uint16 bg_list_index; /* # of modified patterns in list */ - uint32 bg_pattern_cache[0x80000 / sizeof(uint32)];/* Cached and flipped patterns */ - uint8 playfield_shift; /* Width of planes A, B (in bits) */ - uint8 playfield_col_mask; /* Vertical scroll mask */ - uint16 playfield_row_mask; /* Horizontal scroll mask */ - uint32 y_mask; /* Name table Y-index bits mask */ - - bool hint_pending; /* 0= Line interrupt is pending */ - bool vint_pending; /* 1= Frame interrupt is pending */ - uint16 counter; /* Raster counter */ - bool dma_fill; /* 1= DMA fill has been requested */ - int im2_flag; /* 1= Interlace mode 2 is being used */ - int visible_frame_end; /* End-of-frame (IRQ line) */ - int v_counter; /* VDP scan line counter */ - int v_update; /* 1= VC was updated by a ctrl or HV read */ - - int32 vdp_cycle_counter; - int32 vdp_last_ts; - int32 vdp_line_phase; - int32 vdp_hcounter_start_ts; - - int32 fifo_simu_count; - - int32 scanline; - bool is_pal, report_pal; - bool WantAutoAspect; - - - void RedoViewport(void); - void WriteCRAM(uint16); - void MemoryWrite8(uint8); - void MemoryWrite16(uint16); - void CheckDMA(void); - - - MDFN_Surface *surface; - MDFN_Rect *rect; - EmulateSpecStruct *espec; - - /* Clip data */ - clip_t clip[2]; - - /* Sprite name look-up table */ - uint8 name_lut[0x400]; - - /* Sprite line buffer data */ - uint8 object_index_count; - - object_info_t object_info[20]; - - /* Pixel look-up tables and table base address */ - uint8 *lut[5]; - uint8 *lut_base; - - /* 32-bit pixel remapping data */ - uint32 pixel_32[0x100]; - uint32 pixel_32_lut[3][0x200]; - - uint32 UserLE; // User layer enable; - -/* Function prototypes */ - void render_line(int line); - void render_obj(int line, uint8 *buf, uint8 *table); - void render_obj_im2(int line, uint8 *buf, uint8 *table); - void render_ntw(int line, uint8 *buf); - void render_ntw_im2(int line, uint8 *buf); - void render_ntx(int which, int line, uint8 *buf); - void render_ntx_im2(int which, int line, uint8 *buf); - void render_ntx_vs(int which, int line, uint8 *buf); - void update_bg_pattern_cache(void); - void get_hscroll(int line, uint16 *scrolla, uint16 *scrollb); - void window_clip(int line); - int make_lut_bg(int bx, int ax); - int make_lut_obj(int bx, int sx); - int make_lut_bg_ste(int bx, int ax); - int make_lut_obj_ste(int bx, int sx); - int make_lut_bgobj_ste(int bx, int sx); - void remap_32(uint8 *src, uint32 *dst, uint32 *table, int length); - void merge(uint8 *srca, uint8 *srcb, uint8 *dst, uint8 *table, int width); - void color_update(int index, uint16 data); - void make_name_lut(void); - void parse_satb(int line); - - void Recalc68KSuspend(void); - - public: - #if 0 - inline void Run(void) - { - #include "vdp_run.inc" - } - #else - void Run(void); - #endif -}; - -} - -#endif /* _VDP_H_ */ diff --git a/libmednahawk/src/md/vdp_run.inc b/libmednahawk/src/md/vdp_run.inc deleted file mode 100644 index ed65b29317..0000000000 --- a/libmednahawk/src/md/vdp_run.inc +++ /dev/null @@ -1,307 +0,0 @@ - - int32 cycles = md_timestamp - vdp_last_ts; - bool hcell_mode = (reg[0x0C] & 1); // True on H40, FALSE on H32 - bool do_skip = FALSE; - - /* Maximum FIFO wait times(there is no wait during vblank): - 5.98uSec - H32 cell mode - 4.77uSec - H40 cell mode - - Maximum VRAM(8-bit??)/CRAM(16-bit)/VSRAM(16-bit) FIFO writes during a scanline("unlimited" during vblank): - 16 - H32 cell mode - - Maximum v-bus(68K) to VRAM writes per line: - 16 - H32 cell mode, active display - 167 - H32 cell mode, vblank - 18 - H40 cell mode, active display - 205 - H40 cell mode, vblank - - Maximum VRAM fill writes per line: - 15 - H32 cell mode, active display - 166 - H32 cell mode, vblank - 17 - H40 cell mode, active display - 204 - H40 cell mode, vblank - - Maximum VRAM copy read/write combos per line: - 8 - H32 cell mode, active display - 83 - H32 cell mode, vblank - 9 - H40 cell mode, active display - 102 - H40 cell mode, vblank - - - H display - H retrace - - - Horizontal blanking(H40 cell mode): - Start: H-counter = 0xE4 - End: H-counter = 0x08 (of the next line) - - Horizontal blanking(H32 cell mode): - Start: H-counter = 0xE9 - End: H-counter = ? - - Vertical blanking(H40 cell mode, V28 cell mode): - Start: V-Counter = 0xE0, H-counter = 0xAA - End: V-Counter = 0xFF, H-counter = 0xAA - - Vertical interrupt(H40 cell mode, V28 cell mode): - Start: V-Counter = 0xE0, H-counter = 0x08+ish - End: ?? - - - / 10 in H32 mode - / 8 in H40 mode? - - - 28 - */ - const int divider = hcell_mode ? 8 : 10; - const int lines_per_frame = is_pal ? 313 : 262; - static const int event_count = 8; - - //zero 29-oct-2012 - max hacks to avoid label pointers - #define DEF_EVT_END_OF_ACTIVE 0 - #define DEF_EVT_RIGHT_BORDER 1 - #define DEF_EVT_RIGHT_BLANKING 2 - #define DEF_EVT_HSYNC 3 - #define DEF_EVT_LEFT_BLANKING 4 - #define DEF_EVT_VINT 5 - #define DEF_EVT_LEFT_BORDER 6 - #define DEF_EVT_REMAINING_AD 7 - - // If we change this table, we need to fix "vdp_line_phase" and related init values in MDVDP::Reset(), and also handle old values - // without crashing when loading save states. - static struct - { - const int lptr; - int32 cyc_to_next[2]; - } line_event_table[event_count] = - { - { DEF_EVT_END_OF_ACTIVE, { 160, 128 } }, - { DEF_EVT_RIGHT_BORDER, { 140, 112 } }, - { DEF_EVT_RIGHT_BLANKING, { 90, 72 } }, - { DEF_EVT_HSYNC, { 260, 313 } }, - { DEF_EVT_LEFT_BLANKING, { 138, 163 } }, - { DEF_EVT_VINT, { 102, 96 } }, - { DEF_EVT_LEFT_BORDER, { 130, 104 } }, - { DEF_EVT_REMAINING_AD, { 2400, 2432 } }, - }; - - if(fifo_simu_count) - { - bool in_vb = ((status & 0x8) >> 3) | (((reg[1] & 0x40) ^ 0x40) >> 6); - int div = ((hcell_mode ? 190 : 214) << ((code & 0xF) == 0x1)); - int run_count = ((md_timestamp - vdp_hcounter_start_ts) / div) - ((vdp_last_ts - vdp_hcounter_start_ts) / div); - - if(in_vb) - run_count = 1000; - - fifo_simu_count -= run_count; - if(fifo_simu_count <= 0) - { - fifo_simu_count = 0; - } - - Recalc68KSuspend(); - } - - - vdp_cycle_counter -= cycles; - while(vdp_cycle_counter <= 0) - { - vdp_line_phase = (vdp_line_phase + 1) % event_count; - //printf("%d, %d\n", scanline, vdp_line_phase); - - //goto *(line_event_table[vdp_line_phase].lptr); -switch(line_event_table[vdp_line_phase].lptr) -{ - case DEF_EVT_END_OF_ACTIVE: goto EVT_END_OF_ACTIVE; - case DEF_EVT_RIGHT_BORDER: goto EVT_RIGHT_BORDER; - case DEF_EVT_RIGHT_BLANKING: goto EVT_RIGHT_BLANKING; - case DEF_EVT_HSYNC: goto EVT_HSYNC; - case DEF_EVT_LEFT_BLANKING: goto EVT_LEFT_BLANKING; - case DEF_EVT_VINT: goto EVT_VINT; - case DEF_EVT_LEFT_BORDER: goto EVT_LEFT_BORDER; - case DEF_EVT_REMAINING_AD: goto EVT_REMAINING_AD; -} - - EVT_END_OF_ACTIVE: - vdp_hcounter_start_ts = md_timestamp + vdp_cycle_counter; - - scanline = (scanline + 1) % lines_per_frame; - v_counter = scanline; - - render_line(scanline); - - if(scanline < (visible_frame_end - 1)) - parse_satb(0x81 + scanline); - else if(scanline == (lines_per_frame - 1)) - parse_satb(0x80); - - if(scanline <= visible_frame_end) - { - counter--; - if(counter == 0xFFFF) - { - counter = reg[10]; - hint_pending = 1; - } - } - else - { - counter = reg[10]; - } - - goto EVT_exit; - - EVT_RIGHT_BORDER: - if(scanline == visible_frame_end) - { - /* Set V-Blank flag */ - status |= 0x0008; - } - - CheckDMA(); - - if(scanline == lines_per_frame - 1) - { - rect->y = is_pal ? 0 : 8; - rect->h = is_pal ? 240 : 224; - - if(im2_flag) - { - status ^= 0x0010; - espec->InterlaceOn = true; - espec->InterlaceField = (bool)(status & 0x10); - - // Double-vertical-resolution interlaced mode - rect->y *= 2; - rect->h *= 2; - } - else - status &= ~0x0010; - - /* Clear V-Blank flag */ - status &= ~0x0008; - } - goto EVT_exit; - - EVT_RIGHT_BLANKING: - status |= 0x0004; // Set h-blank flag - goto EVT_exit; - - EVT_HSYNC: - goto EVT_exit; - - EVT_LEFT_BLANKING: - goto EVT_exit; - - EVT_VINT: - /* If a Z80 interrupt is still pending after a scanline, cancel it */ - if(zirq == 1) - { - zirq = 0; - z80_set_interrupt(FALSE); - } - - if(scanline == visible_frame_end) - { - status |= 0x0080; - vint_pending = 1; - - z80_set_interrupt(TRUE); - zirq = 1; - MD_ExitCPULoop(); - } - - goto EVT_exit; - - EVT_LEFT_BORDER: - status &= ~0x0004; // Clear h-blank flag - goto EVT_exit; - - EVT_REMAINING_AD: - goto EVT_exit; - - EVT_exit: ; - vdp_cycle_counter += line_event_table[vdp_line_phase].cyc_to_next[hcell_mode]; - } - - -#if 0 - //while(cycles > 0) - { - vdp_cycle_counter -= cycles; //this_cycles; - while(vdp_cycle_counter <= 0) - { - vdp_line_phase = (vdp_line_phase + 1) % VDPLP_TOTAL; - - // Now, we're going INTO the phase that the if statement corresponds to. - if(vdp_line_phase == VDPLP_HRETRACE_0) - { - - - } - else if(vdp_line_phase == VDPLP_HRETRACE_1) - { - //printf("%d\n", md_timestamp - vdp_hcounter_start_ts); - //vdp_hcounter_start_ts = md_timestamp + vdp_cycle_counter; - vdp_cycle_counter += divider * (hcell_mode ? 16 : 13); - } - else if(vdp_line_phase == VDPLP_VISIBLE_0) - { - status &= ~0x0004; //C lear h-blank flag - - vdp_cycle_counter += divider * (hcell_mode ? 4 : 4); - - /* If a Z80 interrupt is still pending after a scanline, cancel it */ - if(zirq == 1) - { - zirq = 0; - z80_set_interrupt(FALSE); - } - if(scanline == visible_frame_end) - { - status |= 0x0080; - vint_pending = 1; - - z80_set_interrupt(TRUE); - zirq = 1; - MD_ExitCPULoop(); - } - } - else if(vdp_line_phase == VDPLP_VISIBLE_1) - { - vdp_cycle_counter += divider * (hcell_mode ? 320 : 256); - } - else if(vdp_line_phase == VDPLP_VISIBLE_2) - { - vdp_cycle_counter += divider * (hcell_mode ? 26 : 23); - } - } - } -#endif - - if(!MD_Is68KSuspended()) - { - if(vint_pending && (reg[1] & 0x20)) - { - //printf("V-int: %d, %d\n", scanline, md_timestamp); - C68k_Set_IRQ(&Main68K, 6); - } - else if(hint_pending && (reg[0] & 0x10)) - { - //printf("H-int: %d %d\n", scanline, md_timestamp); - C68k_Set_IRQ(&Main68K, 4); - } - else - { - //printf("Int end: %d %d\n", scanline, md_timestamp); - C68k_Set_IRQ(&Main68K, 0); - } - } - - vdp_last_ts = md_timestamp; - -