diff --git a/3rdparty/genie/src/actions/make/make_cpp.lua b/3rdparty/genie/src/actions/make/make_cpp.lua index 353dd15de7a..93444e6999a 100644 --- a/3rdparty/genie/src/actions/make/make_cpp.lua +++ b/3rdparty/genie/src/actions/make/make_cpp.lua @@ -104,7 +104,7 @@ _p('\t$(SILENT) $(LINKCMD) $(OBJECTS)' .. (os.is("MacOSX") and " 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'" or "")) else _p('\t$(call RM,$(TARGET))') - _p('\t@$(call max_args,$(LINKCMD),'.. prj.archivesplit_size ..',$(OBJECTS))' .. (os.is("MacOSX") and " 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'" or "")) + _p('\t$(call max_args,$(SILENT) $(LINKCMD),'.. prj.archivesplit_size ..',$(OBJECTS))' .. (os.is("MacOSX") and " 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'" or "")) _p('\t$(SILENT) $(LINKCMD_NDX)') end else diff --git a/3rdparty/genie/src/host/scripts.c b/3rdparty/genie/src/host/scripts.c index 2075408a6ad..2ec3228b8b1 100644 --- a/3rdparty/genie/src/host/scripts.c +++ b/3rdparty/genie/src/host/scripts.c @@ -212,19 +212,19 @@ const char* builtin_scripts[] = { /* actions/make/make_cpp.lua */ "premake.make.cpp = { }\npremake.make.override = { }\npremake.make.makefile_ignore = false\nlocal cpp = premake.make.cpp\nlocal make = premake.make\nfunction premake.make_cpp(prj)\nlocal cc = premake.gettool(prj)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\npremake.gmake_cpp_header(prj, cc, platforms)\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\npremake.gmake_cpp_config(prj, cfg, cc)\nend\nend\ntable.sort(prj.allfiles)\nlocal objdirs = {}\nlocal additionalobjdirs = {}\nfor _, file in ipairs(prj.allfiles) do\nif path.isSourceFile(file) then\nobjdirs[_MAKE.esc(path.getdirectory(path.trimdots(file)))] = 1\nend\nend\nfor _, custombuildtask in ipairs(prj.custombuildtask or {}) do\nfor _, buildtask in ipairs(custombuildtask or {}) do\nadditionalobjdirs[_MAKE.esc(path.getdirectory(path.getrelative(prj.location,buildtask[2])))] = 1\nend\nend\n_p('OBJDIRS := \\\\')\n_p('\\t$(OBJDIR) \\\\')\nfor dir, _ in iter.sortByKeys(objdirs) do\n_p(" "'\\t$(OBJDIR)/%s \\\\', dir)\nend\nfor dir, _ in iter.sortByKeys(additionalobjdirs) do\n_p('\\t%s \\\\', dir)\nend\n_p('')\n_p('RESOURCES := \\\\')\nfor _, file in ipairs(prj.allfiles) do\nif path.isresourcefile(file) then\n_p('\\t$(OBJDIR)/%s.res \\\\', _MAKE.esc(path.getbasename(file)))\nend\nend\n_p('')\n_p('.PHONY: clean prebuild prelink')\n_p('')\nif os.is(\"MacOSX\") and prj.kind == \"WindowedApp\" then\n_p('all: $(OBJDIRS) prebuild prelink $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist | $(TARGETDIR)')\nelse\n_p('all: $(OBJDIRS) prebuild prelink $(TARGET) | $(TARGETDIR)')\nend\n_p('\\t@:')\n_p('')\nif (prj.kind == \"StaticLib\" and prj.options.ArchiveSplit) then\n_p('define max_args')\n_p('\\t$(eval _args:=)')\n_p('\\t$(foreach obj,$3,$(eval _args+=$(obj))$(if $(word $2,$(_args)),$1$(_args)$(EOL)$(eval _args:=)))')\n_p('\\t$(if $(_args),$1$(_args))')\n_p('endef')\n_p('')\n_p('define EOL')\n_p('')\n_p('')\n_p('endef')\n_p('')\nend\n_p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(EXTERNAL" - "_LIBS) $(RESOURCES) | $(TARGETDIR) $(OBJDIRS)')\nif prj.kind == \"StaticLib\" then\nif prj.msgarchiving then\n_p('\\t@echo ' .. prj.msgarchiving)\nelse\n_p('\\t@echo Archiving %s', prj.name)\nend\nif (not prj.archivesplit_size) then\nprj.archivesplit_size=200\nend\nif (not prj.options.ArchiveSplit) then\n_p('\\t$(SILENT) $(LINKCMD) $(OBJECTS)' .. (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\"))\nelse\n_p('\\t$(call RM,$(TARGET))')\n_p('\\t@$(call max_args,$(LINKCMD),'.. prj.archivesplit_size ..',$(OBJECTS))' .. (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\"))\n_p('\\t$(SILENT) $(LINKCMD_NDX)')\nend\nelse\nif prj.msglinking then\n_p('\\t@echo ' .. prj.msglinking)\nelse\n_p('\\t@echo Linking %s', prj.name)\nend\n_p('\\t$(SILENT) $(LINKCMD)')\nend\n_p('\\t$(POSTBUILDCMDS)')\n_p('')\n_p('$(TARGETDIR):')\npremake.make_mkdirrule(\"$(TARGETDIR)\")\n_p('$(OBJDIRS):')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution." - "messageskip, \"SkipCreatingMessage\")) then\n_p('\\t@echo Creating $(@)')\nend\n_p('\\t-$(call MKDIR,$@)')\n_p('')\nif os.is(\"MacOSX\") and prj.kind == \"WindowedApp\" then\n_p('$(dir $(TARGETDIR))PkgInfo:')\n_p('$(dir $(TARGETDIR))Info.plist:')\n_p('')\nend\n_p('clean:')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCleaningMessage\")) then\n_p('\\t@echo Cleaning %s', prj.name)\nend\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGET)')\n_p('\\t$(SILENT) rm -rf $(OBJDIR)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGET)) del $(subst /,\\\\\\\\,$(TARGET))')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\\\\\,$(OBJDIR))')\n_p('endif')\n_p('')\n_p('prebuild:')\n_p('\\t$(PREBUILDCMDS)')\n_p('')\n_p('prelink:')\n_p('\\t$(PRELINKCMDS)')\n_p('')\ncpp.pchrules(prj)\ncpp.fileRules(prj, cc)\ncpp.dependencyRules(prj)\nfor _, custombuildtask in ipairs(prj.custombuildtask or {}) do\nfor _, buildtask in ipair" - "s(custombuildtask or {}) do\nlocal deps = string.format(\"%s \",path.getrelative(prj.location,buildtask[1]))\nfor _, depdata in ipairs(buildtask[3] or {}) do\ndeps = deps .. string.format(\"%s \",path.getrelative(prj.location,depdata))\nend\n_p('%s: %s | $(TARGETDIR) $(OBJDIRS)'\n,path.getrelative(prj.location,buildtask[2])\n, deps\n)\nfor _, cmdline in ipairs(buildtask[4] or {}) do\nlocal cmd = cmdline\nlocal num = 1\nfor _, depdata in ipairs(buildtask[3] or {}) do\ncmd = string.gsub(cmd,\"%$%(\" .. num ..\"%)\", string.format(\"%s \",path.getrelative(prj.location,depdata)))\nnum = num + 1\nend\ncmd = string.gsub(cmd, \"%$%(<%)\", \"$<\")\ncmd = string.gsub(cmd, \"%$%(@%)\", \"$@\")\n_p('\\t$(SILENT) %s',cmd)\nend\n_p('')\nend\nend\n_p('-include $(OBJECTS:%%.o=%%.d)')\n_p('ifneq (,$(PCH))')\n_p(' -include $(OBJDIR)/$(notdir $(PCH)).d')\n_p(' -include $(OBJDIR)/$(notdir $(PCH))_objc.d')\n_p('endif')\nend\nfunction premake.gmake_cpp_header(prj, cc, platforms)\n_p('# %s project makefile autogenerated by GENie" - "', premake.action.current().shortname)\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true)))\n_p('endif')\n_p('')\n_p('ifndef verbose')\n_p(' SILENT = @')\n_p('endif')\n_p('')\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(MAKESHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(' MKDIR = $(SILENT) mkdir -p \"$(1)\"')\n_p(' COPY = $(SILENT) cp -fR \"$(1)\" \"$(2)\"')\n_p(' RM = $(SILENT) rm -f \"$(1)\"')\n_p('else')\n_p(' MKDIR = $(SILENT) mkdir \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p(' COPY = $(SILENT) copy /Y \"$(subst /,\\\\\\\\,$(1))\" \"$(subst /,\\\\\\\\,$(2))\"')\n_p(' RM = $(SILENT) del /F \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p('endif')\n_p('')\n_p('CC = %s', cc.cc)\n_p('" - "CXX = %s', cc.cxx)\n_p('AR = %s', cc.ar)\n_p('')\n_p('ifndef RESCOMP')\n_p(' ifdef WINDRES')\n_p(' RESCOMP = $(WINDRES)')\n_p(' else')\n_p(' RESCOMP = windres')\n_p(' endif')\n_p('endif')\n_p('')\nif (not premake.make.makefile_ignore) then\n_p('MAKEFILE = %s', _MAKE.getmakefilename(prj, true))\n_p('')\nend\nend\nlocal function is_excluded(prj, cfg, file)\nif table.icontains(prj.excludes, file) then\nreturn true\nend\nif table.icontains(cfg.excludes, file) then\nreturn true\nend\nreturn false\nend\nfunction premake.gmake_cpp_config(prj, cfg, cc)\n_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))\ncpp.platformtools(cfg, cc)\n_p(' ' .. (table.contains(premake.make.override,\"OBJDIR\") and \"override \" or \"\") .. 'OBJDIR = %s', _MAKE.esc(cfg.objectsdir))\n_p(' ' .. (table.contains(premake.make.override,\"TARGETDIR\") and \"override \" or \"\") .. 'TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory))\n_p(' ' .. (table.contains(premake.make.override,\"TARGET\") and \"over" - "ride \" or \"\") .. 'TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))\n_p(' DEFINES +=%s', make.list(cc.getdefines(cfg.defines)))\n_p(' INCLUDES +=%s', make.list(cc.getincludedirs(cfg.includedirs)))\n_p(' INCLUDES +=%s', make.list(cc.getquoteincludedirs(cfg.userincludedirs)))\ncpp.pchconfig(cfg)\ncpp.flags(cfg, cc)\ncpp.linker(prj, cfg, cc)\ntable.sort(cfg.files)\n_p(' OBJECTS := \\\\')\nfor _, file in ipairs(cfg.files) do\nif path.isSourceFile(file) then\nif not is_excluded(prj, cfg, file) then\n_p('\\t$(OBJDIR)/%s.o \\\\'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n)\nend\nend\nend\n_p('')\n_p(' define PREBUILDCMDS')\nif #cfg.prebuildcommands > 0 then\n_p('\\t@echo Running pre-build commands')\n_p('\\t%s', table.implode(cfg.prebuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define PRELINKCMDS')\nif #cfg.prelinkcommands > 0 then\n_p('\\t@echo Running pre-link commands')\n_p('\\t%s', table.implode(cfg.prelinkcommands, \"\"" - ", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define POSTBUILDCMDS')\nif #cfg.postbuildcommands > 0 then\n_p('\\t@echo Running post-build commands')\n_p('\\t%s', table.implode(cfg.postbuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\nmake.settings(cfg, cc)\n_p('endif')\n_p('')\nend\nfunction cpp.platformtools(cfg, cc)\nlocal platform = cc.platforms[cfg.platform]\nif platform.cc then\n_p(' CC = %s', platform.cc)\nend\nif platform.cxx then\n_p(' CXX = %s', platform.cxx)\nend\nif platform.ar then\n_p(' AR = %s', platform.ar)\nend\nend\nfunction cpp.flags(cfg, cc)\nif cfg.pchheader and not cfg.flags.NoPCH then\n_p(' FORCE_INCLUDE += -include $(OBJDIR)/$(notdir $(PCH))')\n_p(' FORCE_INCLUDE_OBJC += -include $(OBJDIR)/$(notdir $(PCH))_objc')\nend\nif #cfg.forcedincludes > 0 then\n_p(' FORCE_INCLUDE += -include %s'\n,_MAKE.esc(table.concat(cfg.forcedincludes, \";\")))\nend\n_p(' ALL_CPPFLAGS += $(CPPFLAGS) %s $(DEFINES) $(INCLUDES)', table.concat(cc.getcppfla" - "gs(cfg), \" \"))\n_p(' ALL_ASMFLAGS += $(ASMFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_asm)))\n_p(' ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_c)))\n_p(' ALL_CXXFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_cpp)))\n_p(' ALL_OBJCFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_objc)))\n_p(' ALL_OBJCPPFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_objcpp)))\n_p(' ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)%s',\n make.list(table.join(cc.getdefines(cfg.resdefines),\n cc.getincludedirs(cfg" - ".resincludedirs), cfg.resoptions)))\nend\nfunction cpp.linker(prj, cfg, cc)\n_p(' ALL_LDFLAGS += $(LDFLAGS)%s', make.list(table.join(cc.getlibdirflags(cfg), cc.getldflags(cfg), cfg.linkoptions)))\n_p(' LDDEPS +=%s', make.list(_MAKE.esc(premake.getlinks(cfg, \"siblings\", \"fullpath\"))))\n_p(' LIBS += $(LDDEPS)%s', make.list(cc.getlinkflags(cfg)))\n_p(' EXTERNAL_LIBS +=%s', make.list(cc.getlibfiles(cfg)))\nif cfg.kind == \"StaticLib\" then\nif (not prj.options.ArchiveSplit) then\n_p(' LINKCMD = $(AR) %s $(TARGET)', make.list(cc.getarchiveflags(prj, cfg, false)))\nelse\n_p(' LINKCMD = $(AR) %s $(TARGET)', make.list(cc.getarchiveflags(prj, cfg, false)))\n_p(' LINKCMD_NDX = $(AR) %s $(TARGET)', make.list(cc.getarchiveflags(prj, cfg, true)))\nend\nelse\nlocal tool = iif(cfg.language == \"C\", \"CC\", \"CXX\")\n_p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)', tool)\nend\nend\nfunction " - "cpp.pchconfig(cfg)\nif not cfg.pchheader or cfg.flags.NoPCH then\nreturn\nend\nlocal pch = cfg.pchheader\nfor _, incdir in ipairs(cfg.includedirs) do\nlocal abspath = path.getabsolute(path.join(cfg.project.location, incdir))\nlocal testname = path.join(abspath, pch)\nif os.isfile(testname) then\npch = path.getrelative(cfg.location, testname)\nbreak\nend\nend\n_p(' PCH = %s', _MAKE.esc(pch))\n_p(' GCH = $(OBJDIR)/$(notdir $(PCH)).gch')\n_p(' GCH_OBJC = $(OBJDIR)/$(notdir $(PCH))_objc.gch')\nend\nfunction cpp.pchrules(prj)\n_p('ifneq (,$(PCH))')\n_p('$(GCH): $(PCH) $(MAKEFILE) | $(OBJDIR)')\nif prj.msgprecompile then\n_p('\\t@echo ' .. prj.msgprecompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\nlocal cmd = iif(prj.language == \"C\", \"$(CC) $(ALL_CFLAGS) -x c-header\", \"$(CXX) $(ALL_CXXFLAGS) -x c++-header\")\n_p('\\t$(SILENT) %s $(DEFINES) $(INCLUDES) -o \"$@\" -c \"$<\"', cmd)\n_p('')\n_p('$(GCH_OBJC): $(PCH) $(MAKEFILE) | $(OBJDIR)')\nif prj.msgprecompile then\n_" - "p('\\t@echo ' .. prj.msgprecompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\nlocal cmd = iif(prj.language == \"C\", \"$(CC) $(ALL_OBJCFLAGS) -x objective-c-header\", \"$(CXX) $(ALL_OBJCPPFLAGS) -x objective-c++-header\")\n_p('\\t$(SILENT) %s $(DEFINES) $(INCLUDES) -o \"$@\" -c \"$<\"', cmd)\n_p('endif')\n_p('')\nend\nfunction cpp.fileRules(prj, cc)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\ntable.sort(prj.allfiles)\nfor _, file in ipairs(prj.allfiles or {}) do\nif path.isSourceFile(file) then\nif (path.isobjcfile(file)) then\n_p('$(OBJDIR)/%s.o: %s $(GCH_OBJC) $(MAKEFILE)'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(file)\n)\nelse\n_p('$(OBJDIR)/%s.o: %s $(GCH) $(MAKEFILE)'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(file)\n)\nend\nif (path.isobjcfile(file) and prj.msgcompile_objc) then\n_p('\\t@echo ' .. prj.msgcompile_objc)\nelseif prj.msgcompile then\n_p('\\t@echo ' .. prj.msgcompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\nif (" - "path.isobjcfile(file)) then\nif (path.iscfile(file)) then\n_p('\\t$(SILENT) $(CXX) $(ALL_OBJCFLAGS) $(FORCE_INCLUDE_OBJC) -o \"$@\" -c \"$<\"')\nelse\n_p('\\t$(SILENT) $(CXX) $(ALL_OBJCPPFLAGS) $(FORCE_INCLUDE_OBJC) -o \"$@\" -c \"$<\"')\nend\nelseif (path.isasmfile(file)) then\n_p('\\t$(SILENT) $(CC) $(ALL_ASMFLAGS) -o \"$@\" -c \"$<\"')\nelse\ncpp.buildcommand(path.iscfile(file) and not prj.options.ForceCPP, \"o\")\nend\nfor _, task in ipairs(prj.postcompiletasks or {}) do\n_p('\\t$(SILENT) %s', task)\n_p('')\nend\n_p('')\nelseif (path.getextension(file) == \".rc\") then\n_p('$(OBJDIR)/%s.res: %s', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file))\nif prj.msgresource then\n_p('\\t@echo ' .. prj.msgresource)\nelse\n_p('\\t@echo $(notdir $<)')\nend\n_p('\\t$(SILENT) $(RESCOMP) $< -O coff -o \"$@\" $(ALL_RESFLAGS)')\n_p('')\nend\nend\nend\nfunction cpp.dependencyRules(prj)\nfor _, dependency in ipairs(prj.dependency or {}) do\nfor _, dep in ipairs(dependency or {}) do\nif (dep[3]==nil or dep[3]==false) then\n" - "_p('$(OBJDIR)/%s.o: %s'\n, _MAKE.esc(path.trimdots(path.removeext(path.getrelative(prj.location, dep[1]))))\n, _MAKE.esc(path.getrelative(prj.location, dep[2]))\n)\nelse\n_p('%s: %s'\n, _MAKE.esc(dep[1])\n, _MAKE.esc(path.getrelative(prj.location, dep[2]))\n)\nend\n_p('')\nend\nend\nend\nfunction cpp.buildcommand(iscfile, objext)\nlocal flags = iif(iscfile, '$(CC) $(ALL_CFLAGS)', '$(CXX) $(ALL_CXXFLAGS)')\n_p('\\t$(SILENT) %s $(FORCE_INCLUDE) -o \"$@\" -c \"$<\"', flags, objext)\nend\n", + "_LIBS) $(RESOURCES) | $(TARGETDIR) $(OBJDIRS)')\nif prj.kind == \"StaticLib\" then\nif prj.msgarchiving then\n_p('\\t@echo ' .. prj.msgarchiving)\nelse\n_p('\\t@echo Archiving %s', prj.name)\nend\nif (not prj.archivesplit_size) then\nprj.archivesplit_size=200\nend\nif (not prj.options.ArchiveSplit) then\n_p('\\t$(SILENT) $(LINKCMD) $(OBJECTS)' .. (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\"))\nelse\n_p('\\t$(call RM,$(TARGET))')\n_p('\\t$(call max_args,$(SILENT) $(LINKCMD),'.. prj.archivesplit_size ..',$(OBJECTS))' .. (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\"))\n_p('\\t$(SILENT) $(LINKCMD_NDX)')\nend\nelse\nif prj.msglinking then\n_p('\\t@echo ' .. prj.msglinking)\nelse\n_p('\\t@echo Linking %s', prj.name)\nend\n_p('\\t$(SILENT) $(LINKCMD)')\nend\n_p('\\t$(POSTBUILDCMDS)')\n_p('')\n_p('$(TARGETDIR):')\npremake.make_mkdirrule(\"$(TARGETDIR)\")\n_p('$(OBJDIRS):')\nif (not prj.solution.messageskip) or (not table.contains(prj." + "solution.messageskip, \"SkipCreatingMessage\")) then\n_p('\\t@echo Creating $(@)')\nend\n_p('\\t-$(call MKDIR,$@)')\n_p('')\nif os.is(\"MacOSX\") and prj.kind == \"WindowedApp\" then\n_p('$(dir $(TARGETDIR))PkgInfo:')\n_p('$(dir $(TARGETDIR))Info.plist:')\n_p('')\nend\n_p('clean:')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCleaningMessage\")) then\n_p('\\t@echo Cleaning %s', prj.name)\nend\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGET)')\n_p('\\t$(SILENT) rm -rf $(OBJDIR)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGET)) del $(subst /,\\\\\\\\,$(TARGET))')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\\\\\,$(OBJDIR))')\n_p('endif')\n_p('')\n_p('prebuild:')\n_p('\\t$(PREBUILDCMDS)')\n_p('')\n_p('prelink:')\n_p('\\t$(PRELINKCMDS)')\n_p('')\ncpp.pchrules(prj)\ncpp.fileRules(prj, cc)\ncpp.dependencyRules(prj)\nfor _, custombuildtask in ipairs(prj.custombuildtask or {}) do\nfor _, buildtask" + " in ipairs(custombuildtask or {}) do\nlocal deps = string.format(\"%s \",path.getrelative(prj.location,buildtask[1]))\nfor _, depdata in ipairs(buildtask[3] or {}) do\ndeps = deps .. string.format(\"%s \",path.getrelative(prj.location,depdata))\nend\n_p('%s: %s | $(TARGETDIR) $(OBJDIRS)'\n,path.getrelative(prj.location,buildtask[2])\n, deps\n)\nfor _, cmdline in ipairs(buildtask[4] or {}) do\nlocal cmd = cmdline\nlocal num = 1\nfor _, depdata in ipairs(buildtask[3] or {}) do\ncmd = string.gsub(cmd,\"%$%(\" .. num ..\"%)\", string.format(\"%s \",path.getrelative(prj.location,depdata)))\nnum = num + 1\nend\ncmd = string.gsub(cmd, \"%$%(<%)\", \"$<\")\ncmd = string.gsub(cmd, \"%$%(@%)\", \"$@\")\n_p('\\t$(SILENT) %s',cmd)\nend\n_p('')\nend\nend\n_p('-include $(OBJECTS:%%.o=%%.d)')\n_p('ifneq (,$(PCH))')\n_p(' -include $(OBJDIR)/$(notdir $(PCH)).d')\n_p(' -include $(OBJDIR)/$(notdir $(PCH))_objc.d')\n_p('endif')\nend\nfunction premake.gmake_cpp_header(prj, cc, platforms)\n_p('# %s project makefile autogenerated" + " by GENie', premake.action.current().shortname)\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true)))\n_p('endif')\n_p('')\n_p('ifndef verbose')\n_p(' SILENT = @')\n_p('endif')\n_p('')\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(MAKESHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(' MKDIR = $(SILENT) mkdir -p \"$(1)\"')\n_p(' COPY = $(SILENT) cp -fR \"$(1)\" \"$(2)\"')\n_p(' RM = $(SILENT) rm -f \"$(1)\"')\n_p('else')\n_p(' MKDIR = $(SILENT) mkdir \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p(' COPY = $(SILENT) copy /Y \"$(subst /,\\\\\\\\,$(1))\" \"$(subst /,\\\\\\\\,$(2))\"')\n_p(' RM = $(SILENT) del /F \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p('endif')\n_p('')\n_p('CC = %s', cc." + "cc)\n_p('CXX = %s', cc.cxx)\n_p('AR = %s', cc.ar)\n_p('')\n_p('ifndef RESCOMP')\n_p(' ifdef WINDRES')\n_p(' RESCOMP = $(WINDRES)')\n_p(' else')\n_p(' RESCOMP = windres')\n_p(' endif')\n_p('endif')\n_p('')\nif (not premake.make.makefile_ignore) then\n_p('MAKEFILE = %s', _MAKE.getmakefilename(prj, true))\n_p('')\nend\nend\nlocal function is_excluded(prj, cfg, file)\nif table.icontains(prj.excludes, file) then\nreturn true\nend\nif table.icontains(cfg.excludes, file) then\nreturn true\nend\nreturn false\nend\nfunction premake.gmake_cpp_config(prj, cfg, cc)\n_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))\ncpp.platformtools(cfg, cc)\n_p(' ' .. (table.contains(premake.make.override,\"OBJDIR\") and \"override \" or \"\") .. 'OBJDIR = %s', _MAKE.esc(cfg.objectsdir))\n_p(' ' .. (table.contains(premake.make.override,\"TARGETDIR\") and \"override \" or \"\") .. 'TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory))\n_p(' ' .. (table.contains(premake.make.override,\"TARGET\") a" + "nd \"override \" or \"\") .. 'TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))\n_p(' DEFINES +=%s', make.list(cc.getdefines(cfg.defines)))\n_p(' INCLUDES +=%s', make.list(cc.getincludedirs(cfg.includedirs)))\n_p(' INCLUDES +=%s', make.list(cc.getquoteincludedirs(cfg.userincludedirs)))\ncpp.pchconfig(cfg)\ncpp.flags(cfg, cc)\ncpp.linker(prj, cfg, cc)\ntable.sort(cfg.files)\n_p(' OBJECTS := \\\\')\nfor _, file in ipairs(cfg.files) do\nif path.isSourceFile(file) then\nif not is_excluded(prj, cfg, file) then\n_p('\\t$(OBJDIR)/%s.o \\\\'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n)\nend\nend\nend\n_p('')\n_p(' define PREBUILDCMDS')\nif #cfg.prebuildcommands > 0 then\n_p('\\t@echo Running pre-build commands')\n_p('\\t%s', table.implode(cfg.prebuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define PRELINKCMDS')\nif #cfg.prelinkcommands > 0 then\n_p('\\t@echo Running pre-link commands')\n_p('\\t%s', table.implode(cfg.prelinkcomma" + "nds, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define POSTBUILDCMDS')\nif #cfg.postbuildcommands > 0 then\n_p('\\t@echo Running post-build commands')\n_p('\\t%s', table.implode(cfg.postbuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\nmake.settings(cfg, cc)\n_p('endif')\n_p('')\nend\nfunction cpp.platformtools(cfg, cc)\nlocal platform = cc.platforms[cfg.platform]\nif platform.cc then\n_p(' CC = %s', platform.cc)\nend\nif platform.cxx then\n_p(' CXX = %s', platform.cxx)\nend\nif platform.ar then\n_p(' AR = %s', platform.ar)\nend\nend\nfunction cpp.flags(cfg, cc)\nif cfg.pchheader and not cfg.flags.NoPCH then\n_p(' FORCE_INCLUDE += -include $(OBJDIR)/$(notdir $(PCH))')\n_p(' FORCE_INCLUDE_OBJC += -include $(OBJDIR)/$(notdir $(PCH))_objc')\nend\nif #cfg.forcedincludes > 0 then\n_p(' FORCE_INCLUDE += -include %s'\n,_MAKE.esc(table.concat(cfg.forcedincludes, \";\")))\nend\n_p(' ALL_CPPFLAGS += $(CPPFLAGS) %s $(DEFINES) $(INCLUDES)', table.concat(cc." + "getcppflags(cfg), \" \"))\n_p(' ALL_ASMFLAGS += $(ASMFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_asm)))\n_p(' ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_c)))\n_p(' ALL_CXXFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_cpp)))\n_p(' ALL_OBJCFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_objc)))\n_p(' ALL_OBJCPPFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_objcpp)))\n_p(' ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)%s',\n make.list(table.join(cc.getdefines(cfg.resdefines),\n cc.getinclud" + "edirs(cfg.resincludedirs), cfg.resoptions)))\nend\nfunction cpp.linker(prj, cfg, cc)\n_p(' ALL_LDFLAGS += $(LDFLAGS)%s', make.list(table.join(cc.getlibdirflags(cfg), cc.getldflags(cfg), cfg.linkoptions)))\n_p(' LDDEPS +=%s', make.list(_MAKE.esc(premake.getlinks(cfg, \"siblings\", \"fullpath\"))))\n_p(' LIBS += $(LDDEPS)%s', make.list(cc.getlinkflags(cfg)))\n_p(' EXTERNAL_LIBS +=%s', make.list(cc.getlibfiles(cfg)))\nif cfg.kind == \"StaticLib\" then\nif (not prj.options.ArchiveSplit) then\n_p(' LINKCMD = $(AR) %s $(TARGET)', make.list(cc.getarchiveflags(prj, cfg, false)))\nelse\n_p(' LINKCMD = $(AR) %s $(TARGET)', make.list(cc.getarchiveflags(prj, cfg, false)))\n_p(' LINKCMD_NDX = $(AR) %s $(TARGET)', make.list(cc.getarchiveflags(prj, cfg, true)))\nend\nelse\nlocal tool = iif(cfg.language == \"C\", \"CC\", \"CXX\")\n_p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)', tool)\nend\nend\n" + "function cpp.pchconfig(cfg)\nif not cfg.pchheader or cfg.flags.NoPCH then\nreturn\nend\nlocal pch = cfg.pchheader\nfor _, incdir in ipairs(cfg.includedirs) do\nlocal abspath = path.getabsolute(path.join(cfg.project.location, incdir))\nlocal testname = path.join(abspath, pch)\nif os.isfile(testname) then\npch = path.getrelative(cfg.location, testname)\nbreak\nend\nend\n_p(' PCH = %s', _MAKE.esc(pch))\n_p(' GCH = $(OBJDIR)/$(notdir $(PCH)).gch')\n_p(' GCH_OBJC = $(OBJDIR)/$(notdir $(PCH))_objc.gch')\nend\nfunction cpp.pchrules(prj)\n_p('ifneq (,$(PCH))')\n_p('$(GCH): $(PCH) $(MAKEFILE) | $(OBJDIR)')\nif prj.msgprecompile then\n_p('\\t@echo ' .. prj.msgprecompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\nlocal cmd = iif(prj.language == \"C\", \"$(CC) $(ALL_CFLAGS) -x c-header\", \"$(CXX) $(ALL_CXXFLAGS) -x c++-header\")\n_p('\\t$(SILENT) %s $(DEFINES) $(INCLUDES) -o \"$@\" -c \"$<\"', cmd)\n_p('')\n_p('$(GCH_OBJC): $(PCH) $(MAKEFILE) | $(OBJDIR)')\nif prj.msgprecompil" + "e then\n_p('\\t@echo ' .. prj.msgprecompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\nlocal cmd = iif(prj.language == \"C\", \"$(CC) $(ALL_OBJCFLAGS) -x objective-c-header\", \"$(CXX) $(ALL_OBJCPPFLAGS) -x objective-c++-header\")\n_p('\\t$(SILENT) %s $(DEFINES) $(INCLUDES) -o \"$@\" -c \"$<\"', cmd)\n_p('endif')\n_p('')\nend\nfunction cpp.fileRules(prj, cc)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\ntable.sort(prj.allfiles)\nfor _, file in ipairs(prj.allfiles or {}) do\nif path.isSourceFile(file) then\nif (path.isobjcfile(file)) then\n_p('$(OBJDIR)/%s.o: %s $(GCH_OBJC) $(MAKEFILE)'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(file)\n)\nelse\n_p('$(OBJDIR)/%s.o: %s $(GCH) $(MAKEFILE)'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(file)\n)\nend\nif (path.isobjcfile(file) and prj.msgcompile_objc) then\n_p('\\t@echo ' .. prj.msgcompile_objc)\nelseif prj.msgcompile then\n_p('\\t@echo ' .. prj.msgcompile)\nelse\n_p('\\t@echo $(notdir $<)')\n" + "end\nif (path.isobjcfile(file)) then\nif (path.iscfile(file)) then\n_p('\\t$(SILENT) $(CXX) $(ALL_OBJCFLAGS) $(FORCE_INCLUDE_OBJC) -o \"$@\" -c \"$<\"')\nelse\n_p('\\t$(SILENT) $(CXX) $(ALL_OBJCPPFLAGS) $(FORCE_INCLUDE_OBJC) -o \"$@\" -c \"$<\"')\nend\nelseif (path.isasmfile(file)) then\n_p('\\t$(SILENT) $(CC) $(ALL_ASMFLAGS) -o \"$@\" -c \"$<\"')\nelse\ncpp.buildcommand(path.iscfile(file) and not prj.options.ForceCPP, \"o\")\nend\nfor _, task in ipairs(prj.postcompiletasks or {}) do\n_p('\\t$(SILENT) %s', task)\n_p('')\nend\n_p('')\nelseif (path.getextension(file) == \".rc\") then\n_p('$(OBJDIR)/%s.res: %s', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file))\nif prj.msgresource then\n_p('\\t@echo ' .. prj.msgresource)\nelse\n_p('\\t@echo $(notdir $<)')\nend\n_p('\\t$(SILENT) $(RESCOMP) $< -O coff -o \"$@\" $(ALL_RESFLAGS)')\n_p('')\nend\nend\nend\nfunction cpp.dependencyRules(prj)\nfor _, dependency in ipairs(prj.dependency or {}) do\nfor _, dep in ipairs(dependency or {}) do\nif (dep[3]==nil or dep[3]==fals" + "e) then\n_p('$(OBJDIR)/%s.o: %s'\n, _MAKE.esc(path.trimdots(path.removeext(path.getrelative(prj.location, dep[1]))))\n, _MAKE.esc(path.getrelative(prj.location, dep[2]))\n)\nelse\n_p('%s: %s'\n, _MAKE.esc(dep[1])\n, _MAKE.esc(path.getrelative(prj.location, dep[2]))\n)\nend\n_p('')\nend\nend\nend\nfunction cpp.buildcommand(iscfile, objext)\nlocal flags = iif(iscfile, '$(CC) $(ALL_CFLAGS)', '$(CXX) $(ALL_CXXFLAGS)')\n_p('\\t$(SILENT) %s $(FORCE_INCLUDE) -o \"$@\" -c \"$<\"', flags, objext)\nend\n", /* actions/make/make_csharp.lua */ "local function getresourcefilename(cfg, fname)\nif path.getextension(fname) == \".resx\" then\n local name = cfg.buildtarget.basename .. \".\"\n local dir = path.getdirectory(fname)\n if dir ~= \".\" then \nname = name .. path.translate(dir, \".\") .. \".\"\nend\nreturn \"$(OBJDIR)/\" .. _MAKE.esc(name .. path.getbasename(fname)) .. \".resources\"\nelse\nreturn fname\nend\nend\nfunction premake.make_csharp(prj)\nlocal csc = premake.dotnet\nlocal cfglibs = { }\nlocal cfgpairs = { }\nlocal anycfg\nfor cfg in premake.eachconfig(prj) do\nanycfg = cfg\ncfglibs[cfg] = premake.getlinks(cfg, \"siblings\", \"fullpath\")\ncfgpairs[cfg] = { }\nfor _, fname in ipairs(cfglibs[cfg]) do\nif path.getdirectory(fname) ~= cfg.buildtarget.directory then\ncfgpairs[cfg][\"$(TARGETDIR)/\" .. _MAKE.esc(path.getname(fname))] = _MAKE.esc(fname)\nend\nend\nend\nlocal sources = {}\nlocal embedded = { }\nlocal copypairs = { }\nfor fcfg in premake.project.eachfile(prj) do\nlocal action = csc.getbuildaction(fcfg)\nif action == \"Co" diff --git a/3rdparty/softfloat/fpu_constant.h b/3rdparty/softfloat/fpu_constant.h index 3ac8862ba0c..fdd9719eb99 100644 --- a/3rdparty/softfloat/fpu_constant.h +++ b/3rdparty/softfloat/fpu_constant.h @@ -37,11 +37,11 @@ these four paragraphs for those parts of this code that are retained. // 128-bit PI fraction #ifdef BETTER_THAN_PENTIUM -#define FLOAT_PI_HI (U64(0xc90fdaa22168c234)) -#define FLOAT_PI_LO (U64(0xc4c6628b80dc1cd1)) +#define FLOAT_PI_HI (0xc90fdaa22168c234U) +#define FLOAT_PI_LO (0xc4c6628b80dc1cd1U) #else -#define FLOAT_PI_HI (U64(0xc90fdaa22168c234)) -#define FLOAT_PI_LO (U64(0xC000000000000000)) +#define FLOAT_PI_HI (0xc90fdaa22168c234U) +#define FLOAT_PI_LO (0xC000000000000000U) #endif #define FLOATX80_PI2_EXP (0x3FFF) @@ -55,11 +55,11 @@ these four paragraphs for those parts of this code that are retained. // 128-bit 3PI/4 fraction #ifdef BETTER_THAN_PENTIUM -#define FLOAT_3PI4_HI (U64(0x96cbe3f9990e91a7)) -#define FLOAT_3PI4_LO (U64(0x9394c9e8a0a5159c)) +#define FLOAT_3PI4_HI (0x96cbe3f9990e91a7U) +#define FLOAT_3PI4_LO (0x9394c9e8a0a5159cU) #else -#define FLOAT_3PI4_HI (U64(0x96cbe3f9990e91a7)) -#define FLOAT_3PI4_LO (U64(0x9000000000000000)) +#define FLOAT_3PI4_HI (0x96cbe3f9990e91a7U) +#define FLOAT_3PI4_LO (0x9000000000000000U) #endif ////////////////////////////// @@ -70,11 +70,11 @@ these four paragraphs for those parts of this code that are retained. // 128-bit 1/LN2 fraction #ifdef BETTER_THAN_PENTIUM -#define FLOAT_LN2INV_HI (U64(0xb8aa3b295c17f0bb)) -#define FLOAT_LN2INV_LO (U64(0xbe87fed0691d3e89)) +#define FLOAT_LN2INV_HI (0xb8aa3b295c17f0bbU) +#define FLOAT_LN2INV_LO (0xbe87fed0691d3e89U) #else -#define FLOAT_LN2INV_HI (U64(0xb8aa3b295c17f0bb)) -#define FLOAT_LN2INV_LO (U64(0xC000000000000000)) +#define FLOAT_LN2INV_HI (0xb8aa3b295c17f0bbU) +#define FLOAT_LN2INV_LO (0xC000000000000000U) #endif #endif diff --git a/3rdparty/softfloat/fsincos.c b/3rdparty/softfloat/fsincos.c index 742c07f2b3b..a57b9ccbf87 100644 --- a/3rdparty/softfloat/fsincos.c +++ b/3rdparty/softfloat/fsincos.c @@ -31,8 +31,8 @@ these four paragraphs for those parts of this code that are retained. //#include "softfloat-specialize" #include "fpu_constant.h" -static const floatx80 floatx80_one = packFloatx80(0, 0x3fff, U64(0x8000000000000000)); -static const floatx80 floatx80_default_nan = packFloatx80(0, 0xffff, U64(0xffffffffffffffff)); +static const floatx80 floatx80_one = packFloatx80(0, 0x3fff, 0x8000000000000000U); +static const floatx80 floatx80_default_nan = packFloatx80(0, 0xffff, 0xffffffffffffffffU); #define packFloat2x128m(zHi, zLo) {(zHi), (zLo)} #define PACK_FLOAT_128(hi,lo) packFloat2x128m(LIT64(hi),LIT64(lo)) @@ -83,7 +83,7 @@ INLINE floatx80 propagateFloatx80NaNOneArg(floatx80 a) if (floatx80_is_signaling_nan(a)) float_raise(float_flag_invalid); - a.low |= U64(0xC000000000000000); + a.low |= 0xC000000000000000U; return a; } @@ -322,7 +322,7 @@ int sf_fsincos(floatx80 a, floatx80 *sin_a, floatx80 *cos_a) // float_raise(float_flag_denormal); /* handle pseudo denormals */ - if (! (aSig0 & U64(0x8000000000000000))) + if (! (aSig0 & 0x8000000000000000U)) { float_raise(float_flag_inexact); if (sin_a) @@ -435,7 +435,7 @@ int floatx80_ftan(floatx80 &a) if (aSig0 == 0) return 0; // float_raise(float_flag_denormal); /* handle pseudo denormals */ - if (! (aSig0 & U64(0x8000000000000000))) + if (! (aSig0 & 0x8000000000000000U)) { float_raise(float_flag_inexact | float_flag_underflow); return 0; @@ -616,7 +616,7 @@ floatx80 floatx80_scale(floatx80 a, floatx80 b) } if (aSig && (aExp == 0)) float_raise(float_flag_denormal); if (bSign) return packFloatx80(aSign, 0, 0); - return packFloatx80(aSign, 0x7FFF, U64(0x8000000000000000)); + return packFloatx80(aSign, 0x7FFF, 0x8000000000000000U); } if (aExp == 0) { if (aSig == 0) return a; diff --git a/3rdparty/softfloat/fyl2x.c b/3rdparty/softfloat/fyl2x.c index d7c5baa3e70..44c3e7610bc 100644 --- a/3rdparty/softfloat/fyl2x.c +++ b/3rdparty/softfloat/fyl2x.c @@ -32,10 +32,10 @@ these four paragraphs for those parts of this code that are retained. //#include "softfloat-specialize" #include "fpu_constant.h" -static const floatx80 floatx80_log10_2 = packFloatx80(0, 0x3ffd, U64(0x9a209a84fbcff798)); -static const floatx80 floatx80_ln_2 = packFloatx80(0, 0x3ffe, U64(0xb17217f7d1cf79ac)); -static const floatx80 floatx80_one = packFloatx80(0, 0x3fff, U64(0x8000000000000000)); -static const floatx80 floatx80_default_nan = packFloatx80(0, 0xffff, U64(0xffffffffffffffff)); +static const floatx80 floatx80_log10_2 = packFloatx80(0, 0x3ffd, 0x9a209a84fbcff798U); +static const floatx80 floatx80_ln_2 = packFloatx80(0, 0x3ffe, 0xb17217f7d1cf79acU); +static const floatx80 floatx80_one = packFloatx80(0, 0x3fff, 0x8000000000000000U); +static const floatx80 floatx80_default_nan = packFloatx80(0, 0xffff, 0xffffffffffffffffU); #define packFloat_128(zHi, zLo) {(zHi), (zLo)} #define PACK_FLOAT_128(hi,lo) packFloat_128(LIT64(hi),LIT64(lo)) @@ -87,7 +87,7 @@ INLINE floatx80 propagateFloatx80NaNOneArg(floatx80 a) if (floatx80_is_signaling_nan(a)) float_raise(float_flag_invalid); - a.low |= U64(0xC000000000000000); + a.low |= 0xC000000000000000U; return a; } @@ -130,8 +130,8 @@ static floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b) int aIsSignalingNaN = floatx80_is_signaling_nan(a); int bIsNaN = floatx80_is_nan(b); int bIsSignalingNaN = floatx80_is_signaling_nan(b); - a.low |= U64(0xC000000000000000); - b.low |= U64(0xC000000000000000); + a.low |= 0xC000000000000000U; + b.low |= 0xC000000000000000U; if (aIsSignalingNaN | bIsSignalingNaN) float_raise(float_flag_invalid); if (aIsSignalingNaN) { if (bIsSignalingNaN) goto returnLargerSignificand; @@ -150,14 +150,14 @@ static floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b) } static const float128 float128_one = - packFloat_128(U64(0x3fff000000000000), U64(0x0000000000000000)); + packFloat_128(0x3fff000000000000U, 0x0000000000000000U); static const float128 float128_two = - packFloat_128(U64(0x4000000000000000), U64(0x0000000000000000)); + packFloat_128(0x4000000000000000U, 0x0000000000000000U); static const float128 float128_ln2inv2 = - packFloat_128(U64(0x400071547652b82f), U64(0xe1777d0ffda0d23a)); + packFloat_128(0x400071547652b82fU, 0xe1777d0ffda0d23aU); -#define SQRT2_HALF_SIG U64(0xb504f333f9de6484) +#define SQRT2_HALF_SIG 0xb504f333f9de6484U extern float128 OddPoly(float128 x, float128 *arr, unsigned n); @@ -279,7 +279,7 @@ invalid: if (bSig == 0) goto invalid; float_raise(float_flag_denormal); } - return packFloatx80(bSign, 0x7FFF, U64(0x8000000000000000)); + return packFloatx80(bSign, 0x7FFF, 0x8000000000000000U); } } if (bExp == 0x7FFF) @@ -289,16 +289,16 @@ invalid: if (aSig && (aExp == 0)) float_raise(float_flag_denormal); if (aExp < 0x3FFF) { - return packFloatx80(zSign, 0x7FFF, U64(0x8000000000000000)); + return packFloatx80(zSign, 0x7FFF, 0x8000000000000000U); } if (aExp == 0x3FFF && ((uint64_t) (aSig<<1) == 0)) goto invalid; - return packFloatx80(bSign, 0x7FFF, U64(0x8000000000000000)); + return packFloatx80(bSign, 0x7FFF, 0x8000000000000000U); } if (aExp == 0) { if (aSig == 0) { if ((bExp | bSig) == 0) goto invalid; float_raise(float_flag_divbyzero); - return packFloatx80(zSign, 0x7FFF, U64(0x8000000000000000)); + return packFloatx80(zSign, 0x7FFF, 0x8000000000000000U); } if (aSign) goto invalid; float_raise(float_flag_denormal); @@ -393,7 +393,7 @@ invalid: if (bSig == 0) goto invalid; float_raise(float_flag_denormal); } - return packFloatx80(bSign, 0x7FFF, U64(0x8000000000000000)); + return packFloatx80(bSign, 0x7FFF, 0x8000000000000000U); } } if (bExp == 0x7FFF) @@ -406,7 +406,7 @@ invalid: float_raise(float_flag_denormal); } - return packFloatx80(zSign, 0x7FFF, U64(0x8000000000000000)); + return packFloatx80(zSign, 0x7FFF, 0x8000000000000000U); } if (aExp == 0) { if (aSig == 0) { diff --git a/android-project/app/src/main/AndroidManifest.xml b/android-project/app/src/main/AndroidManifest.xml index 4ab4f0b722d..eebca8ab551 100644 --- a/android-project/app/src/main/AndroidManifest.xml +++ b/android-project/app/src/main/AndroidManifest.xml @@ -8,8 +8,8 @@ android:versionName="0.179" android:installLocation="auto"> - - + + diff --git a/hash/archimedes.xml b/hash/archimedes.xml index 891687fb9d6..d837b15efe4 100644 --- a/hash/archimedes.xml +++ b/hash/archimedes.xml @@ -735,7 +735,7 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) - EGO - Repton 4 + EGO: Repton 4 1992 ProAction @@ -800,6 +800,17 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) + + Enthar Seven + 1988 + Robico + + + + + + + Fervour (Bad Dump?) 19?? @@ -899,6 +910,17 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) + + Hostages + 1990 + Superior Software + + + + + + + Ibix the Viking 19?? @@ -1016,6 +1038,17 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) + + Leeds United Champions! + 19?? + CDS + + + + + + + Legend of the Lost Temple 19?? @@ -1102,11 +1135,11 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) Master Break - 19?? + 1989 Superior Software - + @@ -1386,6 +1419,17 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) + + Speech! + 1991 + Superior Software + + + + + + + Speedball 2 - Brutal Deluxe 1992 @@ -1925,10 +1969,9 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) - DesktopHacker (v1.01) + Desktop Hacker (v1.01) 1994 - <homebrew> - + DoggySoft @@ -1951,8 +1994,7 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) Fruitz 19?? - <homebrew> - + Digital Fantasy @@ -2015,30 +2057,6 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) - - Impression Jr - 19?? - <homebrew> - - - - - - - - - - Leeds Utd - Champions! - 19?? - <homebrew> - - - - - - - - MadDash 2 2001 @@ -2075,18 +2093,6 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) - - Pen Down (v1.72) - 1992 - <homebrew> - - - - - - - - The Punters Predictor 19?? @@ -2148,18 +2154,6 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) - - Startwrite (Bad Dump?) - 1992 - <homebrew> - - - - - - - - System Interrupt Demos 1-5 1989 @@ -2195,44 +2189,6 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) - - - - Acorn Archimedes RISC OS Application Suite (v1.00) - 19?? - Acorn - - - - - - - - - - - - - - - - Acorn Archimedes RISC OS Application Suite (v1.00, Alt) - 19?? - Acorn - - - - - - - - - - - - - - Coconizer (v1.3) 1990 @@ -2284,17 +2240,6 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) - - Speech! (v1.3) - 1991 - Superior Software - - - - - - - VZap 2000 @@ -2664,6 +2609,169 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) + + + + 1st Word Plus (Release 2) + 1989 + Acorn + + + + + + + + + + APEC Utils Disk v1.3 + 1989 + Atomwide Ltd + + + + + + + + + Archimedes Hard Disc Utilities Disc + 1989 + Watford Electronics + + + + + + + + + Acorn Desktop Publisher + 1989 + Acorn + + + + + + + + + + + + + + + + + Euclid + 1988 + Ace Computing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Impression Junior + 1989 + Computer Concepts + + + + + + + + + Archimedes Magpie + 1992 + Logotron + + + + + + + + + Pen Down (v1.72) + 1992 + Logotron + + + + + + + + + PipeDream 3 + 1989 + Colton Software + + + + + + + + + PipeDream 4 Demonstration Disc + 1991 + Colton Software + + + + + + + + + StartWrite (Bad Dump?) + 1992 + Icon Technology + + + + + + + @@ -2892,4 +3000,1337 @@ Zelanites: The Onslaught by Micro Power (RiscOS2) + + + + Acorn ANSI C (Release 2) + 1988 + Acorn + + + + + + + + + + Acorn ANSI C (Release 3) + 1989 + Acorn + + + + + + + + + + + + + + + + + + + + + + Acorn C/C++ (Release 5) + 1995 + Acorn + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Acorn Computing MegaDisk: Vol.10 No.8 + 1992 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.10 No.9 + 1992 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.10 No.10 + 1992 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.10 No.11 + 1993 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.10 No.12 + 1993 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.1 + 1993 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.2 + 1993 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.3 + 1993 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.4 + 1993 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.5 + 1993 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.6 + 1993 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.7 + 1993 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.8 + 1993 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.10 + 1993 + Acorn Computing + + + + + + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.11 Special + 1993 + Acorn Computing + + + + + + + + + + + + + + Acorn Computing MegaDisk: Vol.11 No.13 + 1994 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.12 No.2 + 1994 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.12 No.4 + 1994 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.12 No.5 + 1994 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.12 No.6 + 1994 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.12 No.7 + 1994 + Acorn Computing + + + + + + + + + Acorn Computing MegaDisk: Vol.13 No.1 + 1995 + Acorn Computing + + + + + + + + + Acorn User Issue 135 (Oct 1993) + 1993 + Acorn User + + + + + + + + + Acorn User Issue 136 (Nov 1993) + 1993 + Acorn User + + + + + + + + + Acorn User Issue 138 (Jan 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 139 (Feb 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 140 (Mar 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 142 (May 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 143 (Jun 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 144 (Jul 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 145 (Aug 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 146 (Sep 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 147 (Oct 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 148 (Nov 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 149 (Dec 1994) + 1994 + Acorn User + + + + + + + + + Acorn User Issue 151 (Jan 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 152 (Feb 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 153 (Mar 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 154 (Apr 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 155 (May 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 156 (Jun 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 157 (Jul 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 158 (Aug 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 159 (Sep 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 160 (Oct 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 161 (Nov 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 162 (Dec 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 163 (Xmas 1995) + 1995 + Acorn User + + + + + + + + + Acorn User Issue 164 (Jan 1996) + 1996 + Acorn User + + + + + + + + + Acorn User Issue 165 (Feb 1996) + 1996 + Acorn User + + + + + + + + + Acorn User Issue 201 (Dec 1998) + 1998 + Acorn User + + + + + + + + + Archimedes World February 1991 + 1991 + Archimedes World + + + + + + + + + Archimedes World April 1991 + 1991 + Archimedes World + + + + + + + + + Archimedes World May 1991 + 1991 + Archimedes World + + + + + + + + + Archimedes World June 1991 + 1991 + Archimedes World + + + + + + + + + Archimedes World July 1991 + 1991 + Archimedes World + + + + + + + + + Archimedes World August 1991 + 1991 + Archimedes World + + + + + + + + + Archimedes World September 1991 + 1991 + Archimedes World + + + + + + + + + Archimedes World October 1991 + 1991 + Archimedes World + + + + + + + + + Archimedes World November 1991 + 1991 + Archimedes World + + + + + + + + + Archimedes World December 1991 + 1991 + Archimedes World + + + + + + + + + Archimedes World March 1992 + 1992 + Archimedes World + + + + + + + + + Archimedes World April 1992 + 1992 + Archimedes World + + + + + + + + + Archimedes World July 1992 + 1992 + Archimedes World + + + + + + + + + Archimedes World August 1992 + 1992 + Archimedes World + + + + + + + + + Archimedes World September 1992 + 1992 + Archimedes World + + + + + + + + + Archimedes World November 1992 + 1992 + Archimedes World + + + + + + + + + Archimedes World December 1992 + 1992 + Archimedes World + + + + + + + + + Archimedes World January 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World February 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World March 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World April 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World May 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World June 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World July 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World August 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World September 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World October 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World November 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World December 1993 + 1993 + Archimedes World + + + + + + + + + Archimedes World January 1994 + 1994 + Archimedes World + + + + + + + + + Archimedes World February 1994 + 1994 + Archimedes World + + + + + + + + + Archimedes World March 1994 + 1994 + Archimedes World + + + + + + + + + + + + + + Archimedes World April 1994 + 1994 + Archimedes World + + + + + + + + + + + + + + Archimedes World May 1994 + 1994 + Archimedes World + + + + + + + + + + + + + + Archimedes World June 1994 + 1994 + Archimedes World + + + + + + + + + + + + + + Archimedes World July 1994 + 1994 + Archimedes World + + + + + + + + + + + + + + Archimedes World August 1994 + 1994 + Archimedes World + + + + + + + + + + + + + + Archimedes World September 1994 + 1994 + Archimedes World + + + + + + + + + + + + + + Archimedes World October 1994 + 1994 + Archimedes World + + + + + + + + + + + + + + Archimedes World November 1994 + 1994 + Archimedes World + + + + + + + + + + + + + + Archimedes World December 1994 + 1994 + Archimedes World + + + + + + + + + + + + + + Archimedes World January 1995 + 1995 + Archimedes World + + + + + + + + + + + + + + Archimedes World February 1995 + 1995 + Archimedes World + + + + + + + + + + + + + + Archimedes World March 1995 + 1995 + Archimedes World + + + + + + + + + + + + + + Archimedes World April 1995 + 1995 + Archimedes World + + + + + + + + + + + + + + Archimedes World May 1995 + 1995 + Archimedes World + + + + + + + + + + + + + + Archimedes World June 1995 + 1995 + Archimedes World + + + + + + + + + + + + + + Archimedes World July 1995 + 1995 + Archimedes World + + + + + + + + + Archimedes World November 1995 + 1995 + Archimedes World + + + + + + + + + Archimedes World Vol.15 Iss.7 + 199? + Archimedes World + + + + + + + + + + + Welcome (Arthur) + 1987 + Acorn + + + + + + + + + Acorn Archimedes RISC OS Application Suite (v1.00) + 1988 + Acorn + + + + + + + + + + + + + + + + Acorn Archimedes RISC OS Application Suite (v1.00, Alt) + 1988 + Acorn + + + + + + + + + + + + + + diff --git a/hash/bbc_flop_6502.xml b/hash/bbc_flop_6502.xml index 51b0c9863fe..13ce8bf12b5 100644 --- a/hash/bbc_flop_6502.xml +++ b/hash/bbc_flop_6502.xml @@ -68,6 +68,43 @@ + + Hi-InterSheet + 1986 + Computer Concepts + + + + + + + + + + Hi-View + 1984 + Acornsoft + + + + + + + + + + + Hi-Wordwise Plus + 1985 + Computer Concepts + + + + + + + + Econet Level 2 Fileserver Software 1985 diff --git a/hash/bbc_flop_65c102.xml b/hash/bbc_flop_65c102.xml index efc30b3f5e9..4626e439a75 100644 --- a/hash/bbc_flop_65c102.xml +++ b/hash/bbc_flop_65c102.xml @@ -12,13 +12,13 @@ BBC Master 65C102 Co-Processor Support Disc - 1983 + 1986 Acorn Computers - + diff --git a/hash/bbca_cass.xml b/hash/bbca_cass.xml index af527dbb29b..e0416169bc7 100644 --- a/hash/bbca_cass.xml +++ b/hash/bbca_cass.xml @@ -27,8 +27,8 @@ - - Airline + + Airline (Model A) 1983 CCS diff --git a/hash/bbcb_cass.xml b/hash/bbcb_cass.xml index d7cd2c11f68..b4b25861ebb 100644 --- a/hash/bbcb_cass.xml +++ b/hash/bbcb_cass.xml @@ -451,7 +451,7 @@ Adventurescape - Lost in Xanadu 1985 - AB + A&B Computing @@ -493,8 +493,8 @@ - - Airline + + Airline (Model B) 1983 CCS @@ -1008,7 +1008,7 @@ - The Axe of Kolt + Axe of Kolt 1987 Elk Adventure Club @@ -1599,7 +1599,7 @@ Bomber Baron - 198? + 1986 Optyx @@ -1791,8 +1791,8 @@ Bridge Master - 19?? - J Keyne + 1983 + J.Keyne @@ -4958,7 +4958,7 @@ Froggy 198? - JSD + JSD Software @@ -6939,8 +6939,8 @@ Keyboard to Joystick Convertor - 198? - Bud + 1984 + Bud Software @@ -7073,7 +7073,7 @@ - Know Your Own Personality + Know Your Own PSI-Q 1984 Mirrorsoft @@ -8389,7 +8389,7 @@ Multi Base 198? - GSoft + G.Soft Micro Software @@ -8802,7 +8802,7 @@ Osprey! - 198? + 1984 Bourne Educational Software @@ -9168,8 +9168,8 @@ Pilgrims Progress - 198? - Su + 1984 + Scripture Union @@ -9627,7 +9627,7 @@ ProLink Joystick Software - 198? + 1983 Aztec @@ -10696,7 +10696,7 @@ Scrabble - 198? + 1984 Leisure Genius @@ -12605,7 +12605,7 @@ System 15000 2nd Edition - 198? + 1984 AVS @@ -12840,8 +12840,8 @@ Text Editor - 198? - GSoft + 1983 + G.Soft Micro Software @@ -13057,7 +13057,7 @@ The Inter-City - 198? + 1988 SRS @@ -13350,7 +13350,7 @@ 1983 Gemini - + @@ -14255,7 +14255,7 @@ William the Conqueror - 198? + 1984 Molimerx @@ -14809,8 +14809,8 @@ The Spreadsheet - 198? - Microl + 1983 + MiCROL @@ -15302,7 +15302,7 @@ Happy Numbers - 198? + 1983 Bourne Educational Software @@ -15414,7 +15414,7 @@ Map Rally - 198? + 1983 Bourne Educational Software @@ -15656,7 +15656,7 @@ Timeman Two - 198? + 1983 Bourne Educational Software @@ -15920,7 +15920,7 @@ AMX Art - 198? + 1984 Advanced Memory Systems @@ -16175,6 +16175,42 @@ + + The Music System: Cassette Pack 1 + 1984 + Island Logic + + + + + + + + + + + + + + + + The Music System: Cassette Pack 2 + 1984 + Island Logic + + + + + + + + + + + + + + diff --git a/hash/bbcb_flop_orig.xml b/hash/bbcb_flop_orig.xml index a97da680488..44c5a81e95f 100644 --- a/hash/bbcb_flop_orig.xml +++ b/hash/bbcb_flop_orig.xml @@ -1679,7 +1679,7 @@ - The Music System (1986) + The Music System (BBC B/Master Series) 1986 Island Logic @@ -3432,32 +3432,33 @@ - Farm Management Suite - 198? + Farm Management Package + 1986 Acornsoft + - - - + + + - - - + + + - - - + + + - - - + + + @@ -3521,7 +3522,7 @@ Dinosaur Discovery - 198? + 1986 4mation @@ -3727,7 +3728,7 @@ Happy Numbers - 198? + 1983 Bourne Educational Software diff --git a/hash/bbcmc_flop.xml b/hash/bbcmc_flop.xml index b6b62d634dd..a44f0baac72 100644 --- a/hash/bbcmc_flop.xml +++ b/hash/bbcmc_flop.xml @@ -10,10 +10,22 @@ + + ALPS - Adventure Language Programming System + 1988 + Alpine Software + + + + + + + Elite 1986 Superior Software/Acornsoft + @@ -22,7 +34,7 @@ - BBC Master Compact Welcome Disc + Welcome & Utilities Disc for Master Compact 1986 Acorn diff --git a/hash/electron_cass.xml b/hash/electron_cass.xml index 5148240ac97..c73d793ea5a 100644 --- a/hash/electron_cass.xml +++ b/hash/electron_cass.xml @@ -315,7 +315,7 @@ Adventure Anthology 198? - Database + Database Publications @@ -495,7 +495,7 @@ Arcade Game Creator 198? - Database + Database Publications @@ -1026,7 +1026,7 @@ Bomber Baron - 198? + 1986 Optyx @@ -1138,9 +1138,9 @@ - Bridgemaster - 19?? - J Keyne + Bridge Master + 1983 + J.Keyne @@ -1567,7 +1567,7 @@ Classic Arcade Games 198? - Database + Database Publications @@ -1578,7 +1578,7 @@ 9 Classic Card and Board Games No.1 198? - Database + Database Publications @@ -1589,7 +1589,7 @@ 9 Classic Card and Board Games No.2 1986 - Database + Database Publications @@ -2470,9 +2470,9 @@ - Electron User Vol.1 No.1 + Electron User Vol.1, No.1-4 1984 - Electron User + Database Publications @@ -2481,9 +2481,9 @@ - Electron User Vol.1 No.5 + Electron User Vol.1, No.5: Lunar Lander 1984 - Electron User + Database Publications @@ -2492,9 +2492,9 @@ - Electron User Vol.1 No.6 + Electron User Vol.1, No.6: Chicken! 1984 - Electron User + Database Publications @@ -2503,9 +2503,9 @@ - Electron User Vol.1 No.7 + Electron User Vol.1, No.7: Space Hike 1984 - Electron User + Database Publications @@ -2514,9 +2514,9 @@ - Electron User Vol.1 No.8 + Electron User Vol.1, No.8: Rally Driver 1984 - Electron User + Database Publications @@ -2525,9 +2525,9 @@ - Electron User Vol.1 No.9 + Electron User Vol.1, No.9: Money Maze 1984 - Electron User + Database Publications @@ -2536,9 +2536,9 @@ - Electron User Vol.1 No.10 + Electron User Vol.1, No.10: Golf 1984 - Electron User + Database Publications @@ -2547,9 +2547,9 @@ - Electron User Vol.1 No.11 + Electron User Vol.1, No.11: Castles of Sand 1984 - Electron User + Database Publications @@ -2558,9 +2558,9 @@ - Electron User Vol.1 No.12 + Electron User Vol.1, No.12: Haunted House 1984 - Electron User + Database Publications @@ -2569,9 +2569,9 @@ - Electron User Vol.2 No.1 + Electron User Vol.2, No.1: Break Free! 1984 - Electron User + Database Publications @@ -2580,9 +2580,9 @@ - Electron User Vol.2 No.2 + Electron User Vol.2, No.2 1984 - Electron User + Database Publications @@ -2591,9 +2591,9 @@ - Electron User Vol.2 No.3 + Electron User Vol.2, No.3: Christmas Box 1984 - Electron User + Database Publications @@ -2602,9 +2602,9 @@ - Electron User Vol.2 No.4 + Electron User Vol.2, No.4 1985 - Electron User + Database Publications @@ -2613,9 +2613,9 @@ - Electron User Vol.2 No.5 + Electron User Vol.2, No.5: The Kingdom of Craal 1985 - Electron User + Database Publications @@ -2624,9 +2624,9 @@ - Electron User Vol.2 No.6 + Electron User Vol.2, No.6 1985 - Electron User + Database Publications @@ -2635,9 +2635,9 @@ - Electron User Vol.2 No.7 + Electron User Vol.2, No.7 1985 - Electron User + Database Publications @@ -2646,9 +2646,9 @@ - Electron User Vol.2 No.8 + Electron User Vol.2, No.8: Skramble 1985 - Electron User + Database Publications @@ -2657,9 +2657,9 @@ - Electron User Vol.2 No.9 + Electron User Vol.2, No.9 1985 - Electron User + Database Publications @@ -2668,9 +2668,9 @@ - Electron User Vol.2 No.10 + Electron User Vol.2, No.10: Manic Mole! 1985 - Electron User + Database Publications @@ -2679,9 +2679,9 @@ - Electron User Vol.2 No.11 + Electron User Vol.2, No.11 1985 - Electron User + Database Publications @@ -2690,9 +2690,9 @@ - Electron User Vol.2 No.12 + Electron User Vol.2, No.12 1985 - Electron User + Database Publications @@ -2701,9 +2701,9 @@ - Electron User Vol.3 No.1 + Electron User Vol.3, No.1 1985 - Electron User + Database Publications @@ -2712,9 +2712,9 @@ - Electron User Vol.3 No.2 + Electron User Vol.3, No.2 1985 - Electron User + Database Publications @@ -2723,9 +2723,9 @@ - Electron User Vol.3 No.3 + Electron User Vol.3, No.3 1985 - Electron User + Database Publications @@ -2734,9 +2734,9 @@ - Electron User Vol.3 No.4 + Electron User Vol.3, No.4 1986 - Electron User + Database Publications @@ -2745,9 +2745,9 @@ - Electron User Vol.3 No.5 + Electron User Vol.3, No.5 1986 - Electron User + Database Publications @@ -2756,9 +2756,9 @@ - Electron User Vol.3 No.6 + Electron User Vol.3, No.6 1986 - Electron User + Database Publications @@ -2767,9 +2767,9 @@ - Electron User Vol.3 No.7 + Electron User Vol.3, No.7 1986 - Electron User + Database Publications @@ -2778,9 +2778,9 @@ - Electron User Vol.3 No.8 + Electron User Vol.3, No.8 1986 - Electron User + Database Publications @@ -2789,9 +2789,9 @@ - Electron User Vol.3 No.9 + Electron User Vol.3, No.9 1986 - Electron User + Database Publications @@ -2800,9 +2800,9 @@ - Electron User Vol.3 No.10 + Electron User Vol.3, No.10 1986 - Electron User + Database Publications @@ -2811,9 +2811,9 @@ - Electron User Vol.3 No.11 + Electron User Vol.3, No.11 1986 - Electron User + Database Publications @@ -2822,9 +2822,9 @@ - Electron User Vol.3 No.12 + Electron User Vol.3, No.12 1986 - Electron User + Database Publications @@ -2833,9 +2833,9 @@ - Electron User Vol.4 No.1 + Electron User Vol.4, No.1 1986 - Electron User + Database Publications @@ -2844,9 +2844,9 @@ - Electron User Vol.4 No.2 + Electron User Vol.4, No.2 1986 - Electron User + Database Publications @@ -2855,9 +2855,9 @@ - Electron User Vol.4 No.3 + Electron User Vol.4, No.3 1986 - Electron User + Database Publications @@ -2866,9 +2866,9 @@ - Electron User Vol.4 No.4 + Electron User Vol.4, No.4 1987 - Electron User + Database Publications @@ -2877,9 +2877,9 @@ - Electron User Vol.4 No.5 + Electron User Vol.4, No.5 1987 - Electron User + Database Publications @@ -2888,9 +2888,9 @@ - Electron User Vol.4 No.6 + Electron User Vol.4, No.6 1987 - Electron User + Database Publications @@ -2899,9 +2899,9 @@ - Electron User Vol.4 No.7 + Electron User Vol.4, No.7 1987 - Electron User + Database Publications @@ -2910,9 +2910,9 @@ - Electron User Vol.4 No.8 + Electron User Vol.4, No.8 1987 - Electron User + Database Publications @@ -2921,9 +2921,9 @@ - Electron User Vol.4 No.9 + Electron User Vol.4, No.9 1987 - Electron User + Database Publications @@ -2932,9 +2932,9 @@ - Electron User Vol.4 No.10 + Electron User Vol.4, No.10 1987 - Electron User + Database Publications @@ -2943,9 +2943,9 @@ - Electron User Vol.4 No.11 + Electron User Vol.4, No.11 1987 - Electron User + Database Publications @@ -2954,9 +2954,9 @@ - Electron User Vol.4 No.12 + Electron User Vol.4, No.12 1987 - Electron User + Database Publications @@ -2965,9 +2965,9 @@ - Electron User Vol.5 No.1 + Electron User Vol.5, No.1 1987 - Electron User + Database Publications @@ -2976,9 +2976,9 @@ - Electron User Vol.5 No.2 + Electron User Vol.5, No.2 1987 - Electron User + Database Publications @@ -2987,9 +2987,9 @@ - Electron User Vol.5 No.3 + Electron User Vol.5, No.3 1987 - Electron User + Database Publications @@ -2998,9 +2998,9 @@ - Electron User Vol.5 No.4 + Electron User Vol.5, No.4 1988 - Electron User + Database Publications @@ -3009,9 +3009,9 @@ - Electron User Vol.5 No.5 + Electron User Vol.5, No.5 1988 - Electron User + Database Publications @@ -3020,9 +3020,9 @@ - Electron User Vol.5 No.6 + Electron User Vol.5, No.6 1988 - Electron User + Database Publications @@ -3031,9 +3031,9 @@ - Electron User Vol.5 No.7 + Electron User Vol.5, No.7 1988 - Electron User + Database Publications @@ -3042,9 +3042,9 @@ - Electron User Vol.5 No.8 + Electron User Vol.5, No.8 1988 - Electron User + Database Publications @@ -3053,9 +3053,9 @@ - Electron User Vol.5 No.9 + Electron User Vol.5, No.9 1988 - Electron User + Database Publications @@ -3064,9 +3064,9 @@ - Electron User Vol.5 No.10 + Electron User Vol.5, No.10 1988 - Electron User + Database Publications @@ -3075,9 +3075,9 @@ - Electron User Vol.5 No.11 + Electron User Vol.5, No.11 1988 - Electron User + Database Publications @@ -3086,9 +3086,9 @@ - Electron User Vol.5 No.12 + Electron User Vol.5, No.12 1988 - Electron User + Database Publications @@ -3097,9 +3097,9 @@ - Electron User Vol.6 No.1 + Electron User Vol.6, No.1 1988 - Electron User + Database Publications @@ -3108,9 +3108,9 @@ - Electron User Vol.6 No.2 + Electron User Vol.6, No.2 1988 - Electron User + Database Publications @@ -3119,9 +3119,9 @@ - Electron User Vol.6 No.3 + Electron User Vol.6, No.3 1988 - Electron User + Database Publications @@ -3130,9 +3130,9 @@ - Electron User Vol.6 No.4 + Electron User Vol.6, No.4 1989 - Electron User + Database Publications @@ -3141,9 +3141,9 @@ - Electron User Vol.6 No.5 + Electron User Vol.6, No.5 1989 - Electron User + Database Publications @@ -3152,9 +3152,9 @@ - Electron User Vol.6 No.6 + Electron User Vol.6, No.6 1989 - Electron User + Database Publications @@ -3163,9 +3163,9 @@ - Electron User Vol.6 No.7 + Electron User Vol.6, No.7 1989 - Electron User + Database Publications @@ -3174,9 +3174,9 @@ - Electron User Vol.6 No.8 + Electron User Vol.6, No.8 1989 - Electron User + Database Publications @@ -3185,9 +3185,9 @@ - Electron User Vol.6 No.9 + Electron User Vol.6, No.9 1989 - Electron User + Database Publications @@ -3196,9 +3196,9 @@ - Electron User Vol.6 No.10 + Electron User Vol.6, No.10 1989 - Electron User + Database Publications @@ -3207,9 +3207,9 @@ - Electron User Vol.6 No.11 + Electron User Vol.6, No.11 1989 - Electron User + Database Publications @@ -3218,9 +3218,9 @@ - Electron User Vol.6 No.12 + Electron User Vol.6, No.12 1989 - Electron User + Database Publications @@ -3229,9 +3229,9 @@ - Electron User Vol.7 No.1 + Electron User Vol.7, No.1 1989 - Electron User + Database Publications @@ -3240,9 +3240,9 @@ - Electron User Vol.7 No.2 + Electron User Vol.7, No.2 1989 - Electron User + Database Publications @@ -3251,9 +3251,9 @@ - Electron User Vol.7 No.3 + Electron User Vol.7, No.3 1989 - Electron User + Database Publications @@ -3262,9 +3262,9 @@ - Electron User Vol.7 No.4 + Electron User Vol.7, No.4 1990 - Electron User + Database Publications @@ -3273,9 +3273,9 @@ - Electron User Vol.7 No.5 + Electron User Vol.7, No.5 1990 - Electron User + Database Publications @@ -3284,9 +3284,9 @@ - Electron User Vol.7 No.6 + Electron User Vol.7, No.6 1990 - Electron User + Database Publications @@ -3295,9 +3295,9 @@ - Electron User Vol.7 No.7 + Electron User Vol.7, No.7 1990 - Electron User + Database Publications @@ -3306,9 +3306,9 @@ - Electron User Vol.7 No.8 + Electron User Vol.7, No.8 1990 - Electron User + Database Publications @@ -3317,9 +3317,9 @@ - Electron User Vol.7 No.9 + Electron User Vol.7, No.9 1990 - Electron User + Database Publications @@ -3328,9 +3328,9 @@ - Electron User Vol.7 No.10 + Electron User Vol.7, No.10 1990 - Electron User + Database Publications @@ -3666,7 +3666,7 @@ First Byte Joystick Utility - 198? + 1984 First Byte @@ -3780,8 +3780,8 @@ French On The Run - 198? - Database + 1985 + Database Publications @@ -5204,7 +5204,7 @@ - Know Your Own Personality + Know Your Own PSI-Q 1984 Mirrorsoft @@ -5705,7 +5705,7 @@ Micro Olympics 1984 - database + Database Publications @@ -5825,7 +5825,7 @@ Mini Office 1984 - Database + Database Publications @@ -8537,7 +8537,7 @@ Ten of the Best! Vol.1 1984 - Database + Database Publications @@ -8609,7 +8609,7 @@ Ten of the Best! Vol.2 1984 - Database + Database Publications @@ -8681,7 +8681,7 @@ Ten of the Best! Vol.3 1984 - Database + Database Publications @@ -8822,7 +8822,7 @@ - The Axe of Kolt + Axe of Kolt 1987 Elk Adventure Club @@ -9154,7 +9154,7 @@ The Magic Sword 1984 - Database Software + Database Publications @@ -9439,7 +9439,7 @@ 1983 Gemini - + diff --git a/hash/electron_flop.xml b/hash/electron_flop.xml index d7941cb0817..f9df327951d 100644 --- a/hash/electron_flop.xml +++ b/hash/electron_flop.xml @@ -8,7 +8,8 @@ 9 Classic Card and Board Games No.1 198? - Database + Database Publications + @@ -19,7 +20,8 @@ 9 Classic Card and Board Games No.2 1986 - Database + Database Publications + @@ -27,10 +29,131 @@ + + Acheton + 1987 + Topologika + + + + + + + + + + ALPS - Adventure Language Programming System + 1988 + Alpine Software + + + + + + + + + + AMX Art + 1987 + P.R.E.S. + + + + + + + + + + Answer Back - General Knowledge Senior Quiz + 1984 + Kosmos + + + + + + + + + + Arcade Game Creator (5.25") + 198? + Database Publications + + + + + + + + + + Arcade Game Creator (3.5") + 198? + Database Publications + + + + + + + + + + Around the World in 40 Screens + 1987 + Superior Software/Acornsoft + + + + + + + + + + Avon + 1989 + Topologika + + + + + + + + + + Baron + 1989 + Superior Software/Acornsoft + + + + + + + + + + Bone Cruncher + 1987 + Superior Software/Acornsoft + + + + + + + + Classic Arcade Games 198? - Database + Database Publications + @@ -38,10 +161,35 @@ + + Classroom Computing Vol.1 + 1984 + Database Publications + + + + + + + + + + Classroom Computing Vol.2 + 1984 + Database Publications + + + + + + + + Codename: Droid 1987 Superior Software/Acornsoft + @@ -49,10 +197,23 @@ + + Countdown to Doom + 1987 + Topologika + + + + + + + + Crazee Rider 1987 Superior Software/Acornsoft + @@ -65,6 +226,7 @@ 1984 Acornsoft + @@ -76,6 +238,7 @@ Dreamtime 1988 Heyley Software + @@ -87,6 +250,7 @@ Elixir 1987 Superior Software/Acornsoft + @@ -94,11 +258,24 @@ + + Enthar Seven + 1986 + Robico + + + + + + + + Hard Hat Harry 2011 Retro Software + @@ -106,11 +283,24 @@ + + Hezarin + 1990 + Topologika + + + + + + + + Hyper Viper 2011 Retro Software + @@ -123,6 +313,7 @@ 2012 Retro Software + @@ -130,10 +321,119 @@ + + Keyword + 1989 + Swift + + + + + + + + + + Kingdom of Hamil + 1987 + Topologika + + + + + + + + + + Knitwear Designer + 1987 + Database Publications + + + + + + + + + + Last Days of Doom + 1990 + Topologika + + + + + + + + + + The Life of Repton + 1987 + Superior Software/Acornsoft + + + + + + + + + + The Magic Sword (5.25") + 1984 + Database Publications + + + + + + + + + + The Magic Sword (3.5") + 1984 + Database Publications + + + + + + + + + + Maths 'O' Level Revision Part One + 1984 + Ampalsoft + + + + + + + + + + Nursery Rhymes + 198? + Database Publications + + + + + + + + Palace of Magic 1987 Superior Software/Acornsoft + @@ -141,10 +441,22 @@ + + Philosopher's Quest + 1987 + Topologika + + + + + + + Pirate's Peril 1988 Heyley Software + @@ -153,9 +465,22 @@ - Play It Again Sam + Play It Again Sam (5.25") 1987 Superior Software/Acornsoft + + + + + + + + + + Play It Again Sam (3.5") + 1987 + Superior Software/Acornsoft + @@ -168,6 +493,7 @@ 198? Acornsoft + @@ -179,6 +505,7 @@ Plus 3 Games (New Zealand) 198? Acornsoft + @@ -190,6 +517,7 @@ P.R.E.S. Games Disc 1 1984 P.R.E.S. + @@ -201,6 +529,7 @@ P.R.E.S. Games Disc 2 1984 P.R.E.S. + @@ -212,6 +541,7 @@ P.R.E.S. Games Disc 3 1984 P.R.E.S. + @@ -223,6 +553,7 @@ P.R.E.S. Games Disc 4 1984 P.R.E.S. + @@ -234,6 +565,7 @@ P.R.E.S. Games Disc 5 1984 P.R.E.S. + @@ -245,6 +577,7 @@ P.R.E.S. Games Disc 6 1984 P.R.E.S. + @@ -252,10 +585,71 @@ + + Repton 3 + 1986 + Superior Software/Acornsoft + + + + + + + + + + Repton Thru Time + 1988 + Superior Software/Acornsoft + + + + + + + + + + Return to Doom + 1988 + Topologika + + + + + + + + + + Spellbinder + 1987 + Superior Software/Acornsoft + + + + + + + + + + Spy Snatcher + 1989 + Topologika + + + + + + + + The Superior Collection Vol.3 1987 Superior Software/Acornsoft + @@ -267,6 +661,7 @@ Stranded! 1988 Heyley Software + @@ -278,6 +673,7 @@ The Taroda Scheme 1988 Heyley Software + @@ -285,10 +681,59 @@ + + Ten of the Best! Vol.1 + 1984 + Database Publications + + + + + + + + + + Ten of the Best! Vol.2 + 1984 + Database Publications + + + + + + + + + + Ten of the Best! Vol.3 + 1984 + Database Publications + + + + + + + + + + Ten of the Best! Vol.4 + 1984 + Database Publications + + + + + + + + The Ultimate Prize 1988 Heyley Software + @@ -300,6 +745,7 @@ Welcome 198? Acorn + @@ -313,6 +759,7 @@ Electron User Vol.4 No.1 October 1986 1986 P.R.E.S. + @@ -324,6 +771,7 @@ Electron User Vol.4 No.2 November 1986 1986 P.R.E.S. + @@ -335,6 +783,7 @@ Electron User Vol.4 No.8 May 1987 1987 P.R.E.S. + @@ -346,6 +795,7 @@ Electron User Vol.4 No.11 August 1987 1987 P.R.E.S. + @@ -357,6 +807,7 @@ Electron User Vol.5 No.1 October 1987 1987 P.R.E.S. + @@ -368,6 +819,7 @@ Electron User Vol.5 No.3 December 1987 1987 P.R.E.S. + @@ -379,6 +831,7 @@ Electron User Vol.5 No.6 March 1988 1988 P.R.E.S. + @@ -390,6 +843,7 @@ Electron User Vol.5 No.12 September 1988 1988 P.R.E.S. + @@ -401,6 +855,7 @@ Electron User Vol.6 No.9 June 1989 1989 P.R.E.S. + @@ -412,6 +867,7 @@ Electron User Group #00 1991 E.U.G. + @@ -423,6 +879,7 @@ Electron User Group #01 19?? E.U.G. + @@ -434,6 +891,7 @@ Electron User Group #02 19?? E.U.G. + @@ -445,6 +903,7 @@ Electron User Group #03 19?? E.U.G. + @@ -456,6 +915,7 @@ Electron User Group #04 19?? E.U.G. + @@ -467,6 +927,7 @@ Electron User Group #05 19?? E.U.G. + @@ -478,6 +939,7 @@ Electron User Group #06 19?? E.U.G. + @@ -489,6 +951,7 @@ Electron User Group #07 19?? E.U.G. + @@ -500,6 +963,7 @@ Electron User Group #08 19?? E.U.G. + @@ -511,6 +975,7 @@ Electron User Group #09 19?? E.U.G. + @@ -522,6 +987,7 @@ Electron User Group #10 19?? E.U.G. + @@ -533,6 +999,7 @@ Electron User Group #11 19?? E.U.G. + @@ -544,6 +1011,7 @@ Electron User Group #12 19?? E.U.G. + @@ -555,6 +1023,7 @@ Electron User Group #13 19?? E.U.G. + @@ -566,6 +1035,7 @@ Electron User Group #14 19?? E.U.G. + @@ -577,6 +1047,7 @@ Electron User Group #15 19?? E.U.G. + @@ -588,6 +1059,7 @@ Electron User Group #16 19?? E.U.G. + @@ -599,6 +1071,7 @@ Electron User Group #17 19?? E.U.G. + @@ -610,6 +1083,7 @@ Electron User Group #18 19?? E.U.G. + @@ -621,6 +1095,7 @@ Electron User Group #19 19?? E.U.G. + @@ -632,6 +1107,7 @@ Electron User Group #20 19?? E.U.G. + @@ -643,6 +1119,7 @@ Electron User Group #21 19?? E.U.G. + @@ -667,6 +1144,7 @@ Electron User Group #22 19?? E.U.G. + @@ -678,6 +1156,7 @@ Electron User Group #23 19?? E.U.G. + @@ -689,6 +1168,7 @@ Electron User Group #24 19?? E.U.G. + @@ -700,6 +1180,7 @@ Electron User Group #25 19?? E.U.G. + @@ -711,6 +1192,7 @@ Electron User Group #26 19?? E.U.G. + @@ -722,6 +1204,7 @@ Electron User Group #27 19?? E.U.G. + @@ -733,6 +1216,7 @@ Electron User Group #28 19?? E.U.G. + @@ -744,6 +1228,7 @@ Electron User Group #29 19?? E.U.G. + @@ -755,6 +1240,7 @@ Electron User Group #30 19?? E.U.G. + @@ -766,6 +1252,7 @@ Electron User Group #31 19?? E.U.G. + @@ -777,6 +1264,7 @@ Electron User Group #32 19?? E.U.G. + @@ -788,6 +1276,7 @@ Electron User Group #33 19?? E.U.G. + @@ -799,6 +1288,7 @@ Electron User Group #34 19?? E.U.G. + @@ -810,6 +1300,7 @@ Electron User Group #35 19?? E.U.G. + @@ -821,6 +1312,7 @@ Electron User Group #36 19?? E.U.G. + @@ -832,6 +1324,7 @@ Electron User Group #37 19?? E.U.G. + @@ -843,6 +1336,7 @@ Electron User Group #38 19?? E.U.G. + @@ -854,6 +1348,7 @@ Electron User Group #39 19?? E.U.G. + @@ -865,6 +1360,7 @@ Electron User Group #40 19?? E.U.G. + @@ -876,6 +1372,7 @@ Electron User Group #41 19?? E.U.G. + @@ -887,6 +1384,7 @@ Electron User Group #42 19?? E.U.G. + @@ -898,6 +1396,7 @@ Electron User Group #43/#44 19?? E.U.G. + @@ -909,6 +1408,7 @@ Electron User Group #45 19?? E.U.G. + @@ -920,6 +1420,7 @@ Electron User Group #46 19?? E.U.G. + @@ -931,6 +1432,7 @@ Electron User Group #47 19?? E.U.G. + @@ -942,6 +1444,7 @@ Electron User Group #48 19?? E.U.G. + @@ -953,6 +1456,7 @@ Electron User Group #49 19?? E.U.G. + @@ -964,6 +1468,7 @@ Electron User Group #50 19?? E.U.G. + @@ -975,6 +1480,7 @@ Electron User Group #51 19?? E.U.G. + @@ -986,6 +1492,7 @@ Electron User Group #52 19?? E.U.G. + @@ -997,6 +1504,7 @@ Electron User Group #53 19?? E.U.G. + @@ -1008,6 +1516,7 @@ Electron User Group #54 19?? E.U.G. + @@ -1019,6 +1528,7 @@ Electron User Group #55 19?? E.U.G. + @@ -1030,6 +1540,7 @@ Electron User Group #56 19?? E.U.G. + @@ -1041,6 +1552,7 @@ Electron User Group #57 19?? E.U.G. + @@ -1052,6 +1564,7 @@ Electron User Group #58 19?? E.U.G. + @@ -1063,6 +1576,7 @@ Electron User Group #59 19?? E.U.G. + @@ -1074,6 +1588,7 @@ Electron User Group #60 20?? E.U.G. + @@ -1085,6 +1600,7 @@ Electron User Group #61 20?? E.U.G. + @@ -1096,6 +1612,7 @@ Electron User Group #62 2002 E.U.G. + @@ -1107,6 +1624,7 @@ Electron User Group #63 20?? E.U.G. + @@ -1118,6 +1636,7 @@ Electron User Group #64 20?? E.U.G. + @@ -1129,6 +1648,7 @@ Electron User Group #65 20?? E.U.G. + @@ -1140,6 +1660,7 @@ Electron User Group #66 20?? E.U.G. + diff --git a/hash/pc8801_flop.xml b/hash/pc8801_flop.xml index 2c01d406d38..11e211a94e8 100644 --- a/hash/pc8801_flop.xml +++ b/hash/pc8801_flop.xml @@ -2534,12 +2534,13 @@ ExtractDisk [02]"SAGA#1 " -> "adventure land_02.d88" 日本テレネット (Nihon Telenet) - - + + + American Truck (Alt) 1985 @@ -2558,8 +2559,8 @@ ExtractDisk [02]"SAGA#1 " -> "adventure land_02.d88" 日本テレネット (Nihon Telenet) - - + + diff --git a/hash/pico.xml b/hash/pico.xml index 77e1808613f..00922ecae17 100644 --- a/hash/pico.xml +++ b/hash/pico.xml @@ -651,6 +651,19 @@ Published by Others (T-yyy*** serial codes, for yyy depending on the publisher) + + Cooking Pico (Jpn) + 1999 + Sega Toys + + + + + + + + + Crayola - Create a World (USA) 19?? diff --git a/hash/pro128s_flop.xml b/hash/pro128s_flop.xml index ad06426769c..11e86f9862c 100644 --- a/hash/pro128s_flop.xml +++ b/hash/pro128s_flop.xml @@ -285,6 +285,17 @@ + + Disco Welcome + 1987 + Olivetti Prodest + + + + + + + XOR (Ita) 1987 diff --git a/hash/sawatte.xml b/hash/sawatte.xml index c72719da411..2d6478edba7 100644 --- a/hash/sawatte.xml +++ b/hash/sawatte.xml @@ -17,6 +17,19 @@ + + Doraemon Nobita no Dou Butsu Land + 1996 + Sega + + + + + + + + + Mickey no Kudamonoya-san 1996 @@ -77,7 +90,20 @@ - + + Soreike! Anpanman Onamae Na~ni + 1996 + Sega + + + + + + + + + + Tokyo Disneyland - Mickey no Nakayoshi Tankentai 1998 Sega? @@ -122,4 +148,17 @@ + + Ultra Hero Touch + 1997 + Bandai + + + + + + + + + diff --git a/scripts/build/complay.py b/scripts/build/complay.py index c8a61396dce..4eecaa97353 100644 --- a/scripts/build/complay.py +++ b/scripts/build/complay.py @@ -1,69 +1,152 @@ #!/usr/bin/python ## ## license:BSD-3-Clause -## copyright-holders:Aaron Giles, Andrew Gardner +## copyright-holders:Vas Crabb -from __future__ import with_statement - -import sys import os +import sys +import xml.sax +import xml.sax.saxutils import zlib -if len(sys.argv) < 4: - print('Usage:') - print(' complay ') - print('') - sys.exit(0) -srcfile = sys.argv[1] -dstfile = sys.argv[2] -varname = sys.argv[3] -type = 'uint8_t' +class ErrorHandler(object): + def __init__(self, **kwargs): + super(ErrorHandler, self).__init__(**kwargs) + self.errors = 0 + self.warnings = 0 -try: - myfile = open(srcfile, 'rb') -except IOError: - sys.stderr.write("Unable to open source file '%s'\n" % srcfile) - sys.exit(-1) + def error(self, exception): + self.errors += 1 + sys.stderr.write('error: %s' % (exception)) -byteCount = os.path.getsize(srcfile) -compsize = 0 -compressiontype = 1 + def fatalError(self, exception): + raise exception -try: - dst = open(dstfile,'w') - dst.write('const %s %s_data[] =\n{\n\t' % ( type, varname)) - offs = 0 - with open(srcfile, "rb") as src: - while True: - chunk = src.read(byteCount) - if chunk: - compchunk = bytearray(zlib.compress(chunk, 9)) - compsize = len(compchunk) - for b in compchunk: - dst.write('%d' % b) - offs += 1 - if offs != compsize: - dst.write(',') + def warning(self, exception): + self.warnings += 1 + sys.stderr.write('warning: %s' % (exception)) + + +class Minifyer(object): + def __init__(self, output, **kwargs): + super(Minifyer, self).__init__(**kwargs) + + self.output = output + self.incomplete_tag = False + self.element_content = '' + + def setDocumentLocator(self, locator): + pass + + def startDocument(self): + self.output('') + + def endDocument(self): + self.output('\n') + + def startElement(self, name, attrs): + self.flushElementContent() + if self.incomplete_tag: + self.output('>') + self.output('<%s' % (name)) + for name in attrs.getNames(): + self.output(' %s=%s' % (name, xml.sax.saxutils.quoteattr(attrs[name]))) + self.incomplete_tag = True + + def endElement(self, name): + self.flushElementContent() + if self.incomplete_tag: + self.output('/>') + else: + self.output('' % (name)) + self.incomplete_tag = False + + def characters(self, content): + self.element_content += content + + def ignorableWhitespace(self, whitespace): + pass + + def processingInstruction(self, target, data): + pass + + def flushElementContent(self): + self.element_content = self.element_content.strip() + if self.element_content: + if self.incomplete_tag: + self.output('>') + self.incomplete_tag = False + self.output(xml.sax.saxutils.escape(self.element_content)) + self.element_content = '' + + +class XmlError(Exception): + pass + + +def compressLayout(src, dst, comp): + state = [0, 0] + def write(block): + for ch in bytearray(block): + if 0 == state[0]: + dst('\t') + elif 0 == (state[0] % 32): + dst(',\n\t') else: - break - dst.write('\n\t') + dst(', ') + state[0] += 1 + dst('%3u' % (ch)) - dst.write('\n};\n') + def output(text): + block = text.encode('UTF-8') + state[1] += len(block) + write(comp.compress(block)) -except IOError: - sys.stderr.write("Unable to open output file '%s'\n" % dstfile) - sys.exit(-1) + error_handler = ErrorHandler() + content_handler = Minifyer(output) + parser = xml.sax.make_parser() + parser.setErrorHandler(error_handler) + parser.setContentHandler(content_handler) + try: + parser.parse(src) + write(comp.flush()) + dst('\n') + except xml.sax.SAXException as exception: + print('fatal error: %s' % (exception)) + raise XmlError('Fatal error parsing XML') + if (error_handler.errors > 0) or (error_handler.warnings > 0): + raise XmlError('Error(s) and/or warning(s) parsing XML') -try: - dst.write('extern const internal_layout %s;\n' % ( varname )) - dst.write('const internal_layout %s = { \n\t' % ( varname )) - dst.write('%d,%d,%d,%s_data\n' % ( byteCount, compsize, compressiontype, varname )) - dst.write('\n};\n') + return state[1], state[0] - dst.close() -except IOError: - sys.stderr.write("Unable to open output file '%s'\n" % dstfile) - sys.exit(-1) +if __name__ == '__main__': + if len(sys.argv) != 4: + print('Usage:') + print(' complay ') + sys.exit(0 if len(sys.argv) <= 1 else 1) + srcfile = sys.argv[1] + dstfile = sys.argv[2] + varname = sys.argv[3] + + comp_type = 1 + try: + dst = open(dstfile,'w') + dst.write('static const unsigned char %s_data[] = {\n' % (varname)) + byte_count, comp_size = compressLayout(srcfile, lambda x: dst.write(x), zlib.compressobj()) + dst.write('};\n\n') + dst.write('const internal_layout %s = {\n' % (varname)) + dst.write('\t%d, sizeof(%s_data), %d, %s_data\n' % (byte_count, varname, comp_type, varname)) + dst.write('};\n') + dst.close() + except XmlError: + dst.close() + os.remove(dstfile) + sys.exit(2) + except IOError: + sys.stderr.write("Unable to open output file '%s'\n" % dstfile) + os.remove(dstfile) + dst.close() + sys.exit(3) diff --git a/scripts/build/verinfo.py b/scripts/build/verinfo.py index a73d8ad2689..c294df827aa 100644 --- a/scripts/build/verinfo.py +++ b/scripts/build/verinfo.py @@ -11,7 +11,7 @@ import sys def parse_args(): def usage(): - sys.stderr.write('Usage: verinfo.py [-b mame|mess|ume|ldplayer] [-r|-p] [-o ] \n') + sys.stderr.write('Usage: verinfo.py [-b mame|mess|ume] [-r|-p] [-o ] \n') sys.exit(1) flags = True diff --git a/scripts/src/3rdparty.lua b/scripts/src/3rdparty.lua index a4196e867a5..3eced474d17 100644 --- a/scripts/src/3rdparty.lua +++ b/scripts/src/3rdparty.lua @@ -413,7 +413,7 @@ end MAME_DIR .. "3rdparty/lzma/C/BraIA64.c", MAME_DIR .. "3rdparty/lzma/C/CpuArch.c", MAME_DIR .. "3rdparty/lzma/C/Delta.c", - MAME_DIR .. "3rdparty/lzma/C/DllSecur.c", + -- MAME_DIR .. "3rdparty/lzma/C/DllSecur.c", MAME_DIR .. "3rdparty/lzma/C/LzFind.c", -- MAME_DIR .. "3rdparty/lzma/C/LzFindMt.c", MAME_DIR .. "3rdparty/lzma/C/Lzma2Dec.c", diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 38fea58bf1f..30393418485 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -2919,8 +2919,9 @@ end if (BUSES["HP9845_IO"]~=null) then files { MAME_DIR .. "src/devices/bus/hp9845_io/hp9845_io.cpp", - MAME_DIR .. "src/devices/bus/hp9845_io/98035.cpp" - } + MAME_DIR .. "src/devices/bus/hp9845_io/98034.cpp", + MAME_DIR .. "src/devices/bus/hp9845_io/98035.cpp", + } end --------------------------------------------------- diff --git a/scripts/src/lib.lua b/scripts/src/lib.lua index b89b58655d7..51b92d098d2 100644 --- a/scripts/src/lib.lua +++ b/scripts/src/lib.lua @@ -100,35 +100,3 @@ project "utils" MAME_DIR .. "src/lib/util/zippath.cpp", MAME_DIR .. "src/lib/util/zippath.h", } - - -project "http" - uuid "d7930d44-21d1-4c5d-b6af-582c141cd23a" - kind (LIBTYPE) - - addprojectflags() - - includedirs { - MAME_DIR .. "3rdparty", - MAME_DIR .. "3rdparty/asio/include", - MAME_DIR .. "src/osd", - } - - files { - MAME_DIR .. "src/lib/http/connection.cpp", - MAME_DIR .. "src/lib/http/connection.hpp", - MAME_DIR .. "src/lib/http/connection_manager.cpp", - MAME_DIR .. "src/lib/http/connection_manager.hpp", - MAME_DIR .. "src/lib/http/header.hpp", - MAME_DIR .. "src/lib/http/mime_types.cpp", - MAME_DIR .. "src/lib/http/mime_types.hpp", - MAME_DIR .. "src/lib/http/reply.cpp", - MAME_DIR .. "src/lib/http/reply.hpp", - MAME_DIR .. "src/lib/http/request.hpp", - MAME_DIR .. "src/lib/http/request_handler.cpp", - MAME_DIR .. "src/lib/http/request_handler.hpp", - MAME_DIR .. "src/lib/http/request_parser.cpp", - MAME_DIR .. "src/lib/http/request_parser.hpp", - MAME_DIR .. "src/lib/http/server.cpp", - MAME_DIR .. "src/lib/http/server.hpp", - } diff --git a/scripts/src/main.lua b/scripts/src/main.lua index c3c4ac235be..a5559ef151b 100644 --- a/scripts/src/main.lua +++ b/scripts/src/main.lua @@ -234,7 +234,6 @@ end if (STANDALONE~=true) then links { "frontend", - "http", } end if (MACHINES["NETLIST"]~=null) then diff --git a/scripts/target/ldplayer/ldplayer.lua b/scripts/target/ldplayer/ldplayer.lua deleted file mode 100644 index 4348f3bd318..00000000000 --- a/scripts/target/ldplayer/ldplayer.lua +++ /dev/null @@ -1,88 +0,0 @@ --- license:BSD-3-Clause --- copyright-holders:MAMEdev Team - ---------------------------------------------------------------------------- --- --- ldplayer.lua --- --- Small makefile to build a standalone laserdisc player --- ---------------------------------------------------------------------------- - --------------------------------------------------- --- specify required CPU cores (none) --------------------------------------------------- - -CPUS["MCS48"] = true -CPUS["Z80"] = true - - - --------------------------------------------------- --- specify required sound cores --------------------------------------------------- - -SOUNDS["WAVE"] = true - - --------------------------------------------------- --- specify available video cores --------------------------------------------------- - --------------------------------------------------- --- specify available machine cores --------------------------------------------------- - -MACHINES["LDV1000"] = true -MACHINES["LDPR8210"] = true - --------------------------------------------------- --- specify available bus cores --- --- MIDI is here as dummy bus to allow libbus.a to --- be created on OSX. --------------------------------------------------- - -BUSES["MIDI"] = true - --------------------------------------------------- --- this is the list of driver libraries that --- comprise MAME plus mamedriv.o which contains --- the list of drivers --------------------------------------------------- - -function createProjects_ldplayer_ldplayer(_target, _subtarget) - project ("drvldplayer") - targetsubdir(_target .."_" .. _subtarget) - kind (LIBTYPE) - uuid (os.uuid("drvldplayer")) - - includedirs { - MAME_DIR .. "src/osd", - MAME_DIR .. "src/emu", - MAME_DIR .. "src/devices", - MAME_DIR .. "src/mame", - MAME_DIR .. "src/lib", - MAME_DIR .. "src/lib/util", - MAME_DIR .. "3rdparty", - GEN_DIR .. "mame/layout", - } - - files{ - MAME_DIR .. "src/emu/drivers/emudummy.cpp", - } - - dependency { - { MAME_DIR .. "src/emu/drivers/emudummy.cpp", GEN_DIR .. "ldplayer/layout/pr8210.lh" }, - } - - custombuildtask { - layoutbuildtask("ldplayer/layout", "pr8210"), - } -end - -function linkProjects_ldplayer_ldplayer(_target, _subtarget) - links { - "drvldplayer", - } -end diff --git a/scripts/target/mame/virtual.lua b/scripts/target/mame/virtual.lua index 6d13a002948..5a884e33fc0 100644 --- a/scripts/target/mame/virtual.lua +++ b/scripts/target/mame/virtual.lua @@ -15,6 +15,8 @@ CPUS["M6502"] = true CPUS["H6280"] = true +CPUS["MCS48"] = true +CPUS["Z80"] = true -------------------------------------------------- -- specify available sound cores; some of these are @@ -37,6 +39,8 @@ SOUNDS["MULTIPCM"] = true SOUNDS["GB_SOUND"] = true SOUNDS["POKEY"] = true SOUNDS["C352"] = true +SOUNDS["OKIM6295"] = true +SOUNDS["WAVE"] = true -------------------------------------------------- -- specify available video cores @@ -46,7 +50,8 @@ SOUNDS["C352"] = true -------------------------------------------------- -- specify available machine cores -------------------------------------------------- - +MACHINES["LDV1000"] = true +MACHINES["LDPR8210"] = true -------------------------------------------------- -- specify available bus cores @@ -78,12 +83,13 @@ function createVirtualProjects(_target, _subtarget, _name) MAME_DIR .. "src/mame", MAME_DIR .. "src/lib", MAME_DIR .. "src/lib/util", - MAME_DIR .. "src/lib/netlist", MAME_DIR .. "3rdparty", + GEN_DIR .. "mame/layout", } includedirs { ext_includedir("zlib"), + ext_includedir("flac"), } end @@ -91,5 +97,6 @@ function createProjects_mame_virtual(_target, _subtarget) createVirtualProjects(_target, _subtarget, "virtual") files { MAME_DIR .. "src/mame/drivers/vgmplay.cpp", + MAME_DIR .. "src/mame/drivers/ldplayer.cpp", } end diff --git a/src/devices/bus/bbc/1mhzbus/opus3.cpp b/src/devices/bus/bbc/1mhzbus/opus3.cpp index 75bb8700cfd..6dc39151a08 100644 --- a/src/devices/bus/bbc/1mhzbus/opus3.cpp +++ b/src/devices/bus/bbc/1mhzbus/opus3.cpp @@ -54,6 +54,7 @@ const device_type BBC_OPUS3 = &device_creator; FLOPPY_FORMATS_MEMBER(floppy_formats) FLOPPY_ACORN_SSD_FORMAT, FLOPPY_ACORN_DSD_FORMAT, + FLOPPY_ACORN_CPM_FORMAT, FLOPPY_FSD_FORMAT, FLOPPY_OPUS_DDOS_FORMAT FLOPPY_FORMATS_END0 diff --git a/src/devices/bus/bbc/fdc/acorn.cpp b/src/devices/bus/bbc/fdc/acorn.cpp index b0a159470a0..32448ff8c90 100644 --- a/src/devices/bus/bbc/fdc/acorn.cpp +++ b/src/devices/bus/bbc/fdc/acorn.cpp @@ -65,8 +65,10 @@ ROM_START( acorn8271 ) // Acorn ROM_SYSTEM_BIOS(0, "dfs090", "Acorn DFS 0.90") ROMX_LOAD("dfs090.rom", 0x0000, 0x2000, CRC(3ce609cf) SHA1(5cc0f14b8f46855c70eaa653cca4ad079b458732), ROM_BIOS(1)) + ROM_RELOAD( 0x2000, 0x2000) ROM_SYSTEM_BIOS(1, "dfs098", "Acorn DFS 0.98") ROMX_LOAD("dfs098.rom", 0x0000, 0x2000, CRC(90852e7d) SHA1(6df3552d5426f3a4625b9a0c7829bdba03f05e84), ROM_BIOS(2)) + ROM_RELOAD( 0x2000, 0x2000) ROM_SYSTEM_BIOS(2, "dnfs100", "Acorn DFS 1.00") ROMX_LOAD("dnfs100.rom", 0x0000, 0x4000, CRC(7e367e8c) SHA1(161f585dc45665ea77433c84afd2f95049f7f5a0), ROM_BIOS(3)) ROM_SYSTEM_BIOS(3, "dnfs120", "Acorn DFS 1.20") @@ -74,14 +76,19 @@ ROM_START( acorn8271 ) // Pace/Amcom ROM_SYSTEM_BIOS(4, "amdfs0000", "Amcom DFS 00000") ROMX_LOAD("amcomdfs_00000.rom", 0x0000, 0x2000, CRC(28947e95) SHA1(43eb9bfc70bb710e01c0c9d48703ea812f9266e4), ROM_BIOS(5)) + ROM_RELOAD( 0x2000, 0x2000) ROM_SYSTEM_BIOS(5, "amdfs7259", "Amcom DFS A7259") ROMX_LOAD("amcomdfs_a7259.rom", 0x0000, 0x2000, CRC(a3366a98) SHA1(7b8b08edf5ebf17fcbcfbb2af0c189ac903285c2), ROM_BIOS(6)) + ROM_RELOAD( 0x2000, 0x2000) ROM_SYSTEM_BIOS(6, "amdfs4084", "Amcom DFS B4084") ROMX_LOAD("amcomdfs_b4084.rom", 0x0000, 0x2000, CRC(487b049b) SHA1(559e056fe77ede2c87a314fcd8d3e2cab2b49b09), ROM_BIOS(7)) + ROM_RELOAD( 0x2000, 0x2000) ROM_SYSTEM_BIOS(7, "amdfs4088", "Amcom DFS B4088") ROMX_LOAD("amcomdfs_b4088.rom", 0x0000, 0x2000, CRC(3b6e2f82) SHA1(3f5e5039a926c980957f169de2112793eb1a9890), ROM_BIOS(8)) + ROM_RELOAD( 0x2000, 0x2000) ROM_SYSTEM_BIOS(8, "amdfs4218", "Amcom DFS B4218") ROMX_LOAD("amcomdfs_b4218.rom", 0x0000, 0x2000, CRC(98248af5) SHA1(17986b029d641047555eedc538d6790f0cf911a9), ROM_BIOS(9)) + ROM_RELOAD( 0x2000, 0x2000) // Watford Electronics ROM_SYSTEM_BIOS(9, "wdfs110", "Watford Electronics DFS 1.10") ROMX_LOAD("wedfs110.rom", 0x0000, 0x4000, CRC(73c47a91) SHA1(658eb78b104806e76a0e51de9eb238a51daf646d), ROM_BIOS(10)) @@ -95,7 +102,7 @@ ROM_START( acorn8271 ) ROMX_LOAD("wedfs143.rom", 0x0000, 0x4000, CRC(3755ee18) SHA1(69bc258880b8e163ff85a293a25e5f00931d030b), ROM_BIOS(14)) ROM_SYSTEM_BIOS(14, "wdfs144", "Watford Electronics DFS 1.44") ROMX_LOAD("wedfs144.rom", 0x0000, 0x4000, CRC(9fb8d13f) SHA1(387d2468c6e1360f5b531784ce95d5f71a50c2b5), ROM_BIOS(15)) - // Business Systems + // Computer Users Club ROM_SYSTEM_BIOS(15, "bsdos219", "BS-DOS 2.19") ROMX_LOAD("bs-dos219.rom", 0x0000, 0x4000, CRC(299b17b2) SHA1(175fdcc802a7d94d7c36d6f3fd52a192a7cfbc98), ROM_BIOS(16)) ROM_SYSTEM_BIOS(16, "bsdos222", "BS-DOS 2.22") @@ -103,11 +110,13 @@ ROM_START( acorn8271 ) // Others ROM_SYSTEM_BIOS(17, "cucdos", "C.U.C DOS 1.00") ROMX_LOAD("cucdos.rom", 0x0000, 0x2000, CRC(4adf8ecb) SHA1(ca3c1f9e89799459b6fd5197304129441443ca54), ROM_BIOS(18)) + ROM_RELOAD( 0x2000, 0x2000) ROM_END ROM_START( acorn1770 ) ROM_REGION(0x4000, "dfs_rom", 0) ROM_DEFAULT_BIOS("dfs223") + // Acorn ROM_SYSTEM_BIOS(0, "dfs210", "Acorn DFS 2.10") ROMX_LOAD("dfs v2.10 (1985)(acorn).bin", 0x0000, 0x4000, CRC(4f828787) SHA1(112a315e1598cb4db2abcfe9d89fcd97444b276d), ROM_BIOS(1)) ROM_SYSTEM_BIOS(1, "dfs220", "Acorn DFS 2.20") @@ -118,6 +127,11 @@ ROM_START( acorn1770 ) ROMX_LOAD("dfs v2.25 (1986)(acorn).bin", 0x0000, 0x4000, CRC(f855a75b) SHA1(f11271748e6303c60182955e5fa478624b616fcf), ROM_BIOS(4)) ROM_SYSTEM_BIOS(4, "dfs226", "Acorn DFS 2.26") ROMX_LOAD("dfs v2.26 (1986)(acorn).bin", 0x0000, 0x4000, CRC(5ae33e94) SHA1(cf2ebc422a8d24ec6f1a0320520c38a0e704109a), ROM_BIOS(5)) + // Advanced Computer Products + ROM_SYSTEM_BIOS(5, "acp108", "Advanced 1770 DFS 1.08") + ROMX_LOAD("advanced 1770 dfs 1.08 (acp).rom", 0x0000, 0x4000, CRC(eb0eaa34) SHA1(d16ba3c8ed5e5ab6af62aad13a8e567b1c3639c2), ROM_BIOS(6)) + ROM_SYSTEM_BIOS(6, "acp200", "Advanced 1770 DFS 2.00") + ROMX_LOAD("advanced 1770 dfs 2.00 (acp).rom", 0x0000, 0x4000, CRC(65c0d170) SHA1(6907806e2b5b904a6f2041c11f8ccbd298d63ab9), ROM_BIOS(7)) ROM_END @@ -225,26 +239,14 @@ void bbc_acorn1770_device::device_reset() WRITE_LINE_MEMBER(bbc_acorn8271_device::motor_w) { - for (int i = 0; i != 2; i++) { - char devname[8]; - sprintf(devname, "%d", i); - floppy_connector *con = m_fdc->subdevice(devname); - if (con) { - con->get_device()->mon_w(!state); - } - } + if (m_floppy0->get_device()) m_floppy0->get_device()->mon_w(!state); + if (m_floppy1->get_device()) m_floppy1->get_device()->mon_w(!state); } WRITE_LINE_MEMBER(bbc_acorn8271_device::side_w) { - for (int i = 0; i != 2; i++) { - char devname[8]; - sprintf(devname, "%d", i); - floppy_connector *con = m_fdc->subdevice(devname); - if (con) { - con->get_device()->ss_w(state); - } - } + if (m_floppy0->get_device()) m_floppy0->get_device()->ss_w(state); + if (m_floppy1->get_device()) m_floppy1->get_device()->ss_w(state); } WRITE_LINE_MEMBER(bbc_acorn8271_device::fdc_intrq_w) @@ -265,8 +267,8 @@ WRITE8_MEMBER(bbc_acorn1770_device::wd1770l_write) m_drive_control = data; // bit 0, 1: drive select - if (BIT(data, 0)) floppy = m_fdc->subdevice("0")->get_device(); - if (BIT(data, 1)) floppy = m_fdc->subdevice("1")->get_device(); + if (BIT(data, 0)) floppy = m_floppy0->get_device(); + if (BIT(data, 1)) floppy = m_floppy1->get_device(); m_fdc->set_floppy(floppy); // bit 2: side select diff --git a/src/devices/bus/electron/plus3.cpp b/src/devices/bus/electron/plus3.cpp index d24cdaa014b..62f8e77f69a 100644 --- a/src/devices/bus/electron/plus3.cpp +++ b/src/devices/bus/electron/plus3.cpp @@ -37,9 +37,7 @@ FLOPPY_FORMATS_MEMBER(floppy_formats) FLOPPY_FORMATS_END0 SLOT_INTERFACE_START(electron_floppies) - SLOT_INTERFACE("35ssdd", FLOPPY_35_SSDD) SLOT_INTERFACE("35dd", FLOPPY_35_DD) - SLOT_INTERFACE("525sssd", FLOPPY_525_SSSD) SLOT_INTERFACE("525sd", FLOPPY_525_SD) SLOT_INTERFACE("525dd", FLOPPY_525_DD) SLOT_INTERFACE("525qd", FLOPPY_525_QD) @@ -50,6 +48,7 @@ MACHINE_CONFIG_FRAGMENT( plus3 ) /* fdc */ MCFG_WD1770_ADD("fdc", XTAL_16MHz / 2) MCFG_FLOPPY_DRIVE_ADD("fdc:0", electron_floppies, "35dd", floppy_formats) + MCFG_SLOT_FIXED(true) MCFG_FLOPPY_DRIVE_SOUND(true) MCFG_FLOPPY_DRIVE_ADD("fdc:1", electron_floppies, nullptr, floppy_formats) MCFG_FLOPPY_DRIVE_SOUND(true) @@ -57,7 +56,7 @@ MACHINE_CONFIG_FRAGMENT( plus3 ) /* software lists */ MCFG_SOFTWARE_LIST_ADD("flop_ls", "electron_flop") - // pass-through + /* pass-through */ MCFG_ELECTRON_PASSTHRU_EXPANSION_SLOT_ADD(nullptr) MACHINE_CONFIG_END @@ -66,11 +65,16 @@ ROM_START( plus3 ) // Bank 4 Disc ROM_REGION(0x4000, "exp_rom", 0) ROM_DEFAULT_BIOS("adfs") - ROM_SYSTEM_BIOS(0, "adfs", "Acorn ADFS") + // ADFS + ROM_SYSTEM_BIOS(0, "adfs100", "Acorn ADFS 1.00") ROMX_LOAD("adfs.rom", 0x0000, 0x4000, CRC(3289bdc6) SHA1(e7c7a1094d50a3579751df2007269067c8ff6812), ROM_BIOS(1)) - - ROM_SYSTEM_BIOS(1, "dfs200", "Advanced 1770 DFS 2.00") - ROMX_LOAD("acp_dfs1770_200.rom", 0x0000, 0x4000, CRC(5a3a13c7) SHA1(d5dad7ab5a0237c44d0426cd85a8ec86545747e0), ROM_BIOS(2)) + ROM_SYSTEM_BIOS(1, "adfs113", "PRES ADFS 1.13") + ROMX_LOAD("pres_adfs_113.rom", 0x0000, 0x4000, CRC(f06ca04a) SHA1(3c8221d63457c552aa2c9a502db632ce1dea66b4), ROM_BIOS(2)) + ROM_SYSTEM_BIOS(2, "adfs115", "PRES ADFS 1.15") + ROMX_LOAD("pres_adfs_115.rom", 0x0000, 0x4000, CRC(8f81edc3) SHA1(32007425058a7b0f8bd5c17b3c22552aa3a03eca), ROM_BIOS(3)) + // DFS + ROM_SYSTEM_BIOS(3, "dfs200", "Advanced 1770 DFS 2.00") + ROMX_LOAD("acp_dfs1770_200.rom", 0x0000, 0x4000, CRC(5a3a13c7) SHA1(d5dad7ab5a0237c44d0426cd85a8ec86545747e0), ROM_BIOS(4)) ROM_END //------------------------------------------------- @@ -115,8 +119,8 @@ void electron_plus3_device::device_start() address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM); m_slot = dynamic_cast(owner()); - space.install_write_handler(0xfcc0, 0xfcc3, WRITE8_DELEGATE(electron_plus3_device, wd1770_status_w)); - space.install_readwrite_handler(0xfcc4, 0xfccf, READ8_DEVICE_DELEGATE(m_fdc, wd1770_t, read), WRITE8_DEVICE_DELEGATE(m_fdc, wd1770_t, write)); + space.install_readwrite_handler(0xfcc0, 0xfcc0, READ8_DELEGATE(electron_plus3_device, wd1770_status_r), WRITE8_DELEGATE(electron_plus3_device, wd1770_status_w)); + space.install_readwrite_handler(0xfcc4, 0xfcc7, READ8_DEVICE_DELEGATE(m_fdc, wd1770_t, read), WRITE8_DEVICE_DELEGATE(m_fdc, wd1770_t, write)); } //------------------------------------------------- @@ -133,6 +137,12 @@ void electron_plus3_device::device_reset() // IMPLEMENTATION //************************************************************************** +READ8_MEMBER(electron_plus3_device::wd1770_status_r) +{ + return 0xff; +} + + WRITE8_MEMBER(electron_plus3_device::wd1770_status_w) { floppy_image_device *floppy = nullptr; @@ -140,8 +150,8 @@ WRITE8_MEMBER(electron_plus3_device::wd1770_status_w) m_drive_control = data; // bit 0, 1: drive select - if (BIT(data, 0)) floppy = m_fdc->subdevice("0")->get_device(); - if (BIT(data, 1)) floppy = m_fdc->subdevice("1")->get_device(); + if (BIT(data, 0)) floppy = m_floppy0->get_device(); + if (BIT(data, 1)) floppy = m_floppy1->get_device(); m_fdc->set_floppy(floppy); // bit 2: side select @@ -151,8 +161,6 @@ WRITE8_MEMBER(electron_plus3_device::wd1770_status_w) // bit 3: density m_fdc->dden_w(BIT(data, 3)); - // bit 4: interrupt enable? - // bit 5: reset if (!BIT(data, 5)) m_fdc->soft_reset(); } diff --git a/src/devices/bus/electron/plus3.h b/src/devices/bus/electron/plus3.h index f5a07585635..a16af3f370c 100644 --- a/src/devices/bus/electron/plus3.h +++ b/src/devices/bus/electron/plus3.h @@ -33,6 +33,7 @@ public: virtual machine_config_constructor device_mconfig_additions() const override; virtual const tiny_rom_entry *device_rom_region() const override; + DECLARE_READ8_MEMBER(wd1770_status_r); DECLARE_WRITE8_MEMBER(wd1770_status_w); protected: diff --git a/src/devices/bus/hp9845_io/98034.cpp b/src/devices/bus/hp9845_io/98034.cpp new file mode 100644 index 00000000000..9dfec3a35c5 --- /dev/null +++ b/src/devices/bus/hp9845_io/98034.cpp @@ -0,0 +1,375 @@ +// license:BSD-3-Clause +// copyright-holders: F. Ulivi +/********************************************************************* + + 98034.cpp + + 98034 module (HPIB interface) + + TODO: Implement Parallel Poll response + + The main reference for this module is: + HP 98034-90001, 98034 Installation and Service Manual + +*********************************************************************/ + +#include "98034.h" +#include "coreutil.h" + +// Debugging +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +#define BIT_MASK(n) (1U << (n)) + +// Macros to clear/set single bits +#define BIT_CLR(w , n) ((w) &= ~BIT_MASK(n)) +#define BIT_SET(w , n) ((w) |= BIT_MASK(n)) + +hp98034_io_card::hp98034_io_card(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : hp9845_io_card_device(mconfig , HP98034_IO_CARD , "HP98034 card" , tag , owner , clock , "hp98034" , __FILE__), + m_cpu(*this , "np"), + m_sw1(*this , "sw1"), + m_ieee488(*this , IEEE488_TAG) +{ +} + +hp98034_io_card::~hp98034_io_card() +{ +} + +static INPUT_PORTS_START(hp98034_port) + MCFG_HP9845_IO_SC(7) + PORT_START("sw1") + PORT_DIPNAME(0x1f , 0x15 , "HPIB address") + PORT_DIPLOCATION("S1:1,2,3,4,5") + PORT_DIPSETTING(0x00 , "0") + PORT_DIPSETTING(0x01 , "1") + PORT_DIPSETTING(0x02 , "2") + PORT_DIPSETTING(0x03 , "3") + PORT_DIPSETTING(0x04 , "4") + PORT_DIPSETTING(0x05 , "5") + PORT_DIPSETTING(0x06 , "6") + PORT_DIPSETTING(0x07 , "7") + PORT_DIPSETTING(0x08 , "8") + PORT_DIPSETTING(0x09 , "9") + PORT_DIPSETTING(0x0a , "10") + PORT_DIPSETTING(0x0b , "11") + PORT_DIPSETTING(0x0c , "12") + PORT_DIPSETTING(0x0d , "13") + PORT_DIPSETTING(0x0e , "14") + PORT_DIPSETTING(0x0f , "15") + PORT_DIPSETTING(0x10 , "16") + PORT_DIPSETTING(0x11 , "17") + PORT_DIPSETTING(0x12 , "18") + PORT_DIPSETTING(0x13 , "19") + PORT_DIPSETTING(0x14 , "20") + PORT_DIPSETTING(0x15 , "21") + PORT_DIPSETTING(0x16 , "22") + PORT_DIPSETTING(0x17 , "23") + PORT_DIPSETTING(0x18 , "24") + PORT_DIPSETTING(0x19 , "25") + PORT_DIPSETTING(0x1a , "26") + PORT_DIPSETTING(0x1b , "27") + PORT_DIPSETTING(0x1c , "28") + PORT_DIPSETTING(0x1d , "29") + PORT_DIPSETTING(0x1e , "30") + PORT_DIPSETTING(0x1f , "31") + PORT_DIPNAME(0x20 , 0x00 , "Sys. controller") + PORT_DIPLOCATION("S1:6") + PORT_DIPSETTING(0x00 , DEF_STR(On)) + PORT_DIPSETTING(0x20 , DEF_STR(Off)) +INPUT_PORTS_END + +ioport_constructor hp98034_io_card::device_input_ports() const +{ + return INPUT_PORTS_NAME(hp98034_port); +} + +void hp98034_io_card::device_start() +{ + save_item(NAME(m_dc)); + save_item(NAME(m_idr)); + save_item(NAME(m_odr)); + save_item(NAME(m_force_flg)); + save_item(NAME(m_mode_reg)); + save_item(NAME(m_clr_hpib)); + save_item(NAME(m_ctrl_out)); + save_item(NAME(m_data_out)); +} + +void hp98034_io_card::device_reset() +{ + hp9845_io_card_device::device_reset(); + install_readwrite_handler(read16_delegate(FUNC(hp98034_io_card::reg_r) , this) , write16_delegate(FUNC(hp98034_io_card::reg_w) , this)); + + m_idr = 0; + m_odr = 0; + m_force_flg = false; + m_mode_reg = 0xff; + m_clr_hpib = false; + m_ctrl_out = 0; + m_data_out = 0; + update_dc(); +} + +READ16_MEMBER(hp98034_io_card::reg_r) +{ + uint16_t res = m_odr; + + if (offset == 1 || offset == 3) { + // Reading from R5 or R7 forces bits 4&5 to 1 + res |= 0x30; + } + + // Mode register + // Bits Value + // ========== + // 7-4 1 + // 3-2 ~offset + // 1-0 1 + m_mode_reg = (uint8_t)((offset << 2) ^ 0xff); + m_force_flg = true; + + update_flg(); + + LOG(("read R%u=%04x\n" , offset + 4 , res)); + return res; +} + +WRITE16_MEMBER(hp98034_io_card::reg_w) +{ + m_idr = (uint8_t)data; + + // Mode register + // Bits Value + // ========== + // 7-4 1 + // 3-2 ~offset + // 1 0 + // 0 1 + m_mode_reg = (uint8_t)((offset << 2) ^ 0xfd); + m_force_flg = true; + + update_flg(); + LOG(("write R%u=%04x\n" , offset + 4 , data)); +} + +WRITE8_MEMBER(hp98034_io_card::dc_w) +{ + if (data != m_dc) { + //LOG(("DC=%02x\n" , data)); + m_dc = data; + update_dc(); + } +} + +READ8_MEMBER(hp98034_io_card::dc_r) +{ + uint8_t res; + + if (m_force_flg) { + // Force DC3 low + res = 0xf7; + } else { + res = 0xff; + } + + return res; +} + +WRITE8_MEMBER(hp98034_io_card::hpib_data_w) +{ + m_data_out = data; + update_data_out(); +} + +WRITE8_MEMBER(hp98034_io_card::hpib_ctrl_w) +{ + m_ctrl_out = data; + update_ctrl_out(); +} + +READ8_MEMBER(hp98034_io_card::hpib_ctrl_r) +{ + uint8_t res = 0; + + if (!m_ieee488->dav_r()) { + BIT_SET(res , 0); + } + if (!m_ieee488->nrfd_r()) { + BIT_SET(res , 1); + } + if (!m_ieee488->ndac_r()) { + BIT_SET(res , 2); + } + if (!m_ieee488->ifc_r()) { + BIT_SET(res , 3); + } + if (!m_ieee488->atn_r()) { + BIT_SET(res , 4); + } + if (!m_ieee488->srq_r()) { + BIT_SET(res , 5); + } + if (!m_ieee488->ren_r()) { + BIT_SET(res , 6); + } + if (!m_ieee488->eoi_r()) { + BIT_SET(res , 7); + } + + return res; +} + +READ8_MEMBER(hp98034_io_card::hpib_data_r) +{ + return ~m_ieee488->dio_r(); +} + +READ8_MEMBER(hp98034_io_card::idr_r) +{ + return m_idr; +} + +WRITE8_MEMBER(hp98034_io_card::odr_w) +{ + m_odr = data; +} + +READ8_MEMBER(hp98034_io_card::mode_reg_r) +{ + return m_mode_reg; +} + +WRITE8_MEMBER(hp98034_io_card::mode_reg_clear_w) +{ + m_mode_reg = 0xff; + m_force_flg = false; + update_flg(); +} + +READ8_MEMBER(hp98034_io_card::switch_r) +{ + return m_sw1->read() | 0xc0; +} + +IRQ_CALLBACK_MEMBER(hp98034_io_card::irq_callback) +{ + int res = 0xff; + + if (irqline == 0 && !m_ieee488->ifc_r()) { + BIT_CLR(res, 1); + } + + return res; +} + +WRITE_LINE_MEMBER(hp98034_io_card::ieee488_ctrl_w) +{ + update_clr_hpib(); +} + +void hp98034_io_card::update_dc(void) +{ + irq_w(!BIT(m_dc , 0)); + sts_w(BIT(m_dc , 4)); + update_flg(); + update_clr_hpib(); +} + +void hp98034_io_card::update_flg(void) +{ + flg_w(BIT(m_dc , 3) && !m_force_flg); +} + +void hp98034_io_card::update_np_irq(void) +{ + m_cpu->set_input_line(0 , (!m_ieee488->ifc_r() || m_clr_hpib) && BIT(m_dc , HP_NANO_IE_DC)); +} + +void hp98034_io_card::update_data_out(void) +{ + if (m_clr_hpib) { + m_data_out = 0; + } + m_ieee488->dio_w(~m_data_out); +} + +void hp98034_io_card::update_ctrl_out(void) +{ + if (m_clr_hpib) { + m_ieee488->dav_w(1); + m_ieee488->nrfd_w(1); + m_ieee488->eoi_w(1); + m_ieee488->ndac_w(0); + } else { + m_ieee488->dav_w(BIT(m_dc , 2)); + m_ieee488->nrfd_w(BIT(m_dc , 1)); + m_ieee488->eoi_w(!BIT(m_ctrl_out , 4)); + m_ieee488->ndac_w(BIT(m_dc , 6)); + } + m_ieee488->srq_w(!BIT(m_ctrl_out , 0)); + m_ieee488->ren_w(!BIT(m_ctrl_out , 1)); + m_ieee488->atn_w(!BIT(m_ctrl_out , 2)); + m_ieee488->ifc_w(!BIT(m_ctrl_out , 3)); +} + +void hp98034_io_card::update_clr_hpib(void) +{ + m_clr_hpib = !m_ieee488->atn_r() && BIT(m_dc , 5); + update_data_out(); + update_ctrl_out(); + update_np_irq(); + LOG(("clr_hpib %d\n" , m_clr_hpib)); +} + +ROM_START(hp98034) + ROM_REGION(0x400 , "np" , 0) + ROM_LOAD("1816-1242.bin" , 0 , 0x400 , CRC(301a9f5f) SHA1(3d7c1ace38c4d3178fdbf764c044535d9f6ac94f)) +ROM_END + +static ADDRESS_MAP_START(np_program_map , AS_PROGRAM , 8 , hp98034_io_card) + ADDRESS_MAP_UNMAP_HIGH + AM_RANGE(0x000 , 0x3ff) AM_ROM AM_REGION("np" , 0) +ADDRESS_MAP_END + +static ADDRESS_MAP_START(np_io_map , AS_IO , 8 , hp98034_io_card) + ADDRESS_MAP_UNMAP_HIGH + AM_RANGE(0 , 0) AM_WRITE(hpib_data_w) + AM_RANGE(1 , 1) AM_WRITE(hpib_ctrl_w) + AM_RANGE(2 , 2) AM_READ(hpib_ctrl_r) + AM_RANGE(3 , 3) AM_READ(hpib_data_r) + AM_RANGE(4 , 4) AM_READ(idr_r) + AM_RANGE(5 , 5) AM_WRITE(odr_w) + AM_RANGE(6 , 6) AM_READWRITE(mode_reg_r , mode_reg_clear_w) + AM_RANGE(7 , 7) AM_READ(switch_r) +ADDRESS_MAP_END + +static MACHINE_CONFIG_FRAGMENT(hp98034) +// Clock for NP is generated by a RC oscillator. Manual says its typical frequency +// is around 2 MHz. + MCFG_CPU_ADD("np" , HP_NANOPROCESSOR , 2000000) + MCFG_CPU_PROGRAM_MAP(np_program_map) + MCFG_CPU_IO_MAP(np_io_map) + MCFG_HP_NANO_DC_CHANGED(WRITE8(hp98034_io_card , dc_w)) + MCFG_HP_NANO_READ_DC_CB(READ8(hp98034_io_card , dc_r)) + MCFG_CPU_IRQ_ACKNOWLEDGE_DRIVER(hp98034_io_card , irq_callback) + + MCFG_IEEE488_BUS_ADD() + MCFG_IEEE488_IFC_CALLBACK(WRITELINE(hp98034_io_card , ieee488_ctrl_w)) + MCFG_IEEE488_ATN_CALLBACK(WRITELINE(hp98034_io_card , ieee488_ctrl_w)) +MACHINE_CONFIG_END + +const tiny_rom_entry *hp98034_io_card::device_rom_region() const +{ + return ROM_NAME(hp98034); +} + +machine_config_constructor hp98034_io_card::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME(hp98034); +} + +// device type definition +const device_type HP98034_IO_CARD = &device_creator; diff --git a/src/devices/bus/hp9845_io/98034.h b/src/devices/bus/hp9845_io/98034.h new file mode 100644 index 00000000000..317259925b5 --- /dev/null +++ b/src/devices/bus/hp9845_io/98034.h @@ -0,0 +1,85 @@ +// license:BSD-3-Clause +// copyright-holders: F. Ulivi +/********************************************************************* + + 98034.h + + 98034 module (HPIB interface) + +*********************************************************************/ + +#pragma once + +#ifndef _98034_H_ +#define _98034_H_ + +#include "hp9845_io.h" +#include "cpu/nanoprocessor/nanoprocessor.h" +#include "bus/ieee488/ieee488.h" + +class hp98034_io_card : public hp9845_io_card_device +{ +public: + // construction/destruction + hp98034_io_card(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + virtual ~hp98034_io_card(); + + // device-level overrides + virtual ioport_constructor device_input_ports() const override; + virtual void device_start() override; + virtual void device_reset() override; + virtual const tiny_rom_entry *device_rom_region() const override; + virtual machine_config_constructor device_mconfig_additions() const override; + + DECLARE_READ16_MEMBER(reg_r); + DECLARE_WRITE16_MEMBER(reg_w); + + DECLARE_WRITE8_MEMBER(dc_w); + DECLARE_READ8_MEMBER(dc_r); + + DECLARE_WRITE8_MEMBER(hpib_data_w); + DECLARE_WRITE8_MEMBER(hpib_ctrl_w); + DECLARE_READ8_MEMBER(hpib_ctrl_r); + DECLARE_READ8_MEMBER(hpib_data_r); + DECLARE_READ8_MEMBER(idr_r); + DECLARE_WRITE8_MEMBER(odr_w); + DECLARE_READ8_MEMBER(mode_reg_r); + DECLARE_WRITE8_MEMBER(mode_reg_clear_w); + DECLARE_READ8_MEMBER(switch_r); + + IRQ_CALLBACK_MEMBER(irq_callback); + + DECLARE_WRITE_LINE_MEMBER(ieee488_ctrl_w); + +private: + required_device m_cpu; + required_ioport m_sw1; + required_device m_ieee488; + + // DC lines + uint8_t m_dc; + + // Interface state + uint8_t m_idr; // Input Data Register + uint8_t m_odr; // Output Data Register + bool m_force_flg; + uint8_t m_mode_reg; + + // 488 bus state + bool m_clr_hpib; + uint8_t m_ctrl_out; + uint8_t m_data_out; + + void update_dc(void); + void update_flg(void); + void update_np_irq(void); + void update_data_out(void); + void update_ctrl_out(void); + void update_clr_hpib(void); + +}; + +// device type definition +extern const device_type HP98034_IO_CARD; + +#endif /* _98034_H_ */ diff --git a/src/devices/bus/hp9845_io/98035.cpp b/src/devices/bus/hp9845_io/98035.cpp index 28004e6d04f..7f5718b497c 100644 --- a/src/devices/bus/hp9845_io/98035.cpp +++ b/src/devices/bus/hp9845_io/98035.cpp @@ -153,7 +153,7 @@ hp98035_io_card::~hp98035_io_card() } static INPUT_PORTS_START(hp98035_port) - MCFG_HP9845_IO_SC + MCFG_HP9845_IO_SC(1) INPUT_PORTS_END ioport_constructor hp98035_io_card::device_input_ports() const diff --git a/src/devices/bus/hp9845_io/hp9845_io.cpp b/src/devices/bus/hp9845_io/hp9845_io.cpp index 1702c2ad4d6..9cbfceaf289 100644 --- a/src/devices/bus/hp9845_io/hp9845_io.cpp +++ b/src/devices/bus/hp9845_io/hp9845_io.cpp @@ -80,7 +80,9 @@ void hp9845_io_card_device::install_readwrite_handler(read16_delegate rhandler, } #include "98035.h" +#include "98034.h" SLOT_INTERFACE_START(hp9845_io_slot_devices) +SLOT_INTERFACE("98034_hpib" , HP98034_IO_CARD) SLOT_INTERFACE("98035_rtc" , HP98035_IO_CARD) SLOT_INTERFACE_END diff --git a/src/devices/bus/hp9845_io/hp9845_io.h b/src/devices/bus/hp9845_io/hp9845_io.h index a5c0f39b9b1..1c159fc862a 100644 --- a/src/devices/bus/hp9845_io/hp9845_io.h +++ b/src/devices/bus/hp9845_io/hp9845_io.h @@ -21,9 +21,9 @@ #define HP9845_IO_FIRST_SC 1 // Lowest SC used by I/O cards -#define MCFG_HP9845_IO_SC\ +#define MCFG_HP9845_IO_SC(_default_sc) \ PORT_START("SC") \ - PORT_CONFNAME(0xf , 0 , "Select Code") \ + PORT_CONFNAME(0xf , (_default_sc) - HP9845_IO_FIRST_SC , "Select Code") \ PORT_CONFSETTING(0 , "1")\ PORT_CONFSETTING(1 , "2")\ PORT_CONFSETTING(2 , "3")\ diff --git a/src/devices/bus/ieee488/ieee488.cpp b/src/devices/bus/ieee488/ieee488.cpp index 1b2f71c3f6a..385f3a8cd28 100644 --- a/src/devices/bus/ieee488/ieee488.cpp +++ b/src/devices/bus/ieee488/ieee488.cpp @@ -188,6 +188,7 @@ ieee488_device::daisy_entry::daisy_entry(device_t *device) void ieee488_device::set_signal(device_t *device, int signal, int state) { bool changed = false; + int old_state = get_signal(signal); if (device == this) { @@ -218,8 +219,13 @@ void ieee488_device::set_signal(device_t *device, int signal, int state) } } - if (changed) - { + if (!changed) { + return; + } + + state = get_signal(signal); + + if (old_state != state) { switch (signal) { case EOI: m_write_eoi(state); break; @@ -289,21 +295,18 @@ int ieee488_device::get_signal(int signal) { int state = m_line[signal]; - if (state) - { - daisy_entry *entry = m_device_list.first(); + daisy_entry *entry = m_device_list.first(); - while (entry) + while (state && entry) { if (!entry->m_line[signal]) - { - state = 0; - break; - } + { + state = 0; + break; + } entry = entry->next(); } - } return state; } @@ -352,7 +355,7 @@ uint8_t ieee488_device::get_data() daisy_entry *entry = m_device_list.first(); - while (entry) + while (data && entry) { data &= entry->m_dio; diff --git a/src/devices/bus/isa/isa.h b/src/devices/bus/isa/isa.h index d4f67b55f74..25e6bb281ce 100644 --- a/src/devices/bus/isa/isa.h +++ b/src/devices/bus/isa/isa.h @@ -216,7 +216,7 @@ public: } void install_device(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler); - template void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(class address_map &map), int bits = 8, uint64_t unitmask = U64(0xffffffffffffffff)) + template void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(class address_map &map), int bits = 8, uint64_t unitmask = 0xffffffffffffffffU) { m_iospace->install_device(addrstart, addrend, device, map, bits, unitmask); } diff --git a/src/devices/bus/isa/sc499.cpp b/src/devices/bus/isa/sc499.cpp index 3d1e60f873d..0623733f65d 100644 --- a/src/devices/bus/isa/sc499.cpp +++ b/src/devices/bus/isa/sc499.cpp @@ -1257,6 +1257,10 @@ void sc499_device::write_block() check_tape(); } + // write block to image file as well + m_image->fseek((int64_t) m_tape_pos * SC499_CTAPE_BLOCK_SIZE, SEEK_SET); + m_image->fwrite(&m_ctape_block_buffer[0], SC499_CTAPE_BLOCK_SIZE); + m_image->write_block(m_tape_pos, &m_ctape_block_buffer[0]); m_ctape_block_count = m_tape_pos; m_ctape_block_index = 0; @@ -1313,7 +1317,7 @@ void sc499_ctape_image_device::device_config_complete() uint8_t *sc499_ctape_image_device::read_block(int block_num) { // access beyond end of tape cart - if (m_ctape_data.size() <= (block_num + 1) * SC499_CTAPE_BLOCK_SIZE) + if (m_ctape_data.size() < (block_num + 1) * SC499_CTAPE_BLOCK_SIZE) return nullptr; else return &m_ctape_data[block_num * SC499_CTAPE_BLOCK_SIZE]; @@ -1321,8 +1325,10 @@ uint8_t *sc499_ctape_image_device::read_block(int block_num) void sc499_ctape_image_device::write_block(int block_num, uint8_t *ptr) { - if (!(m_ctape_data.size() <= (block_num + 1) * SC499_CTAPE_BLOCK_SIZE)) - memcpy(&m_ctape_data[block_num * SC499_CTAPE_BLOCK_SIZE], ptr, SC499_CTAPE_BLOCK_SIZE); + if ((m_ctape_data.size() < (block_num + 1) * SC499_CTAPE_BLOCK_SIZE)) + m_ctape_data.resize((block_num + 1) * SC499_CTAPE_BLOCK_SIZE); + + memcpy(&m_ctape_data[block_num * SC499_CTAPE_BLOCK_SIZE], ptr, SC499_CTAPE_BLOCK_SIZE); } image_init_result sc499_ctape_image_device::call_load() diff --git a/src/devices/bus/msx_cart/yamaha.cpp b/src/devices/bus/msx_cart/yamaha.cpp index b5841580917..f3f2bfb3815 100644 --- a/src/devices/bus/msx_cart/yamaha.cpp +++ b/src/devices/bus/msx_cart/yamaha.cpp @@ -164,7 +164,7 @@ READ8_MEMBER(msx_cart_sfg::read_cart) if (offset < 0x8000) { - return m_region_sfg->u8(offset & m_rom_mask); + return m_region_sfg->as_u8(offset & m_rom_mask); } return 0xff; diff --git a/src/devices/bus/neogeo/slot.h b/src/devices/bus/neogeo/slot.h index a2413d81589..e11fa0fe066 100644 --- a/src/devices/bus/neogeo/slot.h +++ b/src/devices/bus/neogeo/slot.h @@ -108,7 +108,7 @@ public: void rom_alloc(uint32_t size) { m_rom.resize(size/sizeof(uint16_t)); } uint16_t* get_rom_base() { return &m_rom[0]; } uint32_t get_rom_size() { return m_rom.size() * sizeof(uint16_t); } - uint16_t* get_region_rom_base() { if (m_region_rom.found()) return &m_region_rom->u16(0); return nullptr; } + uint16_t* get_region_rom_base() { if (m_region_rom.found()) return &m_region_rom->as_u16(0); return nullptr; } uint32_t get_region_rom_size() { if (m_region_rom.found()) return m_region_rom->bytes(); return 0; } void fixed_alloc(uint32_t size) { m_fixed.resize(size); } diff --git a/src/devices/bus/snes/sa1.cpp b/src/devices/bus/snes/sa1.cpp index 3608aa9bd8d..86363038992 100644 --- a/src/devices/bus/snes/sa1.cpp +++ b/src/devices/bus/snes/sa1.cpp @@ -765,7 +765,7 @@ void sns_sa1_device::write_regs(address_space &space, uint32_t offset, uint8_t d case 2: //sigma (accumulative multiplication) case 3: uint64_t acum = (int16_t)m_math_a * (int16_t)m_math_b; - uint64_t mask = U64(0xffffffffff); + uint64_t mask = 0xffffffffffU; m_math_res += acum; m_math_overflow = (m_math_res > mask) ? 0x80 : 0; m_math_res &= mask; diff --git a/src/devices/bus/svi3x8/expander/sv603.cpp b/src/devices/bus/svi3x8/expander/sv603.cpp index 1adc323377e..ba69250becd 100644 --- a/src/devices/bus/svi3x8/expander/sv603.cpp +++ b/src/devices/bus/svi3x8/expander/sv603.cpp @@ -117,7 +117,7 @@ READ8_MEMBER( sv603_device::mreq_r ) if (offset >= 0x8000 && offset < 0xa000) { m_expander->ramdis_w(0); - return m_bios->u8(offset & 0x1fff); + return m_bios->as_u8(offset & 0x1fff); } return 0xff; diff --git a/src/devices/bus/svi3x8/slot/sv806.cpp b/src/devices/bus/svi3x8/slot/sv806.cpp index b45da2f7abb..ec16d84c656 100644 --- a/src/devices/bus/svi3x8/slot/sv806.cpp +++ b/src/devices/bus/svi3x8/slot/sv806.cpp @@ -98,7 +98,7 @@ MC6845_UPDATE_ROW( sv806_device::crtc_update_row ) for (int i = 0; i < x_count; i++) { - uint8_t data = m_gfx->u8((m_ram[(ma + i) & 0x7ff] << 4) | ra); + uint8_t data = m_gfx->as_u8((m_ram[(ma + i) & 0x7ff] << 4) | ra); if (i == cursor_x) data = 0xff; diff --git a/src/devices/bus/ti99x/gromport.cpp b/src/devices/bus/ti99x/gromport.cpp index eb655be167e..8ac6edf02e5 100644 --- a/src/devices/bus/ti99x/gromport.cpp +++ b/src/devices/bus/ti99x/gromport.cpp @@ -118,6 +118,7 @@ #define TRACE_GROM 0 #define TRACE_GKRACKER 0 #define TRACE_CRU 0 +#define TRACE_BANKSWITCH 0 #define GROM3_TAG "grom3" #define GROM4_TAG "grom4" @@ -1654,7 +1655,7 @@ WRITE8_MEMBER(ti99_cartridge_pcb::write) { if (m_romspace_selected) { - if (TRACE_ILLWRITE) space.device().logerror("Cannot write to ROM space at %04x\n", offset); + if (TRACE_ILLWRITE) m_cart->logerror("Cannot write to ROM space at %04x\n", offset); } else { @@ -1760,6 +1761,7 @@ WRITE8_MEMBER(ti99_paged12k_cartridge::write) if (m_romspace_selected) { m_rom_page = (offset >> 1) & 1; + if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } else { @@ -1807,6 +1809,7 @@ WRITE8_MEMBER(ti99_paged16k_cartridge::write) if (m_romspace_selected) { m_rom_page = (offset >> 1) & 1; + if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } else { @@ -1863,7 +1866,7 @@ WRITE8_MEMBER(ti99_minimem_cartridge::write) { if ((offset & 0x1000)==0x0000) { - if (TRACE_ILLWRITE) space.device().logerror("Write access to cartridge ROM at address %04x ignored", offset); + if (TRACE_ILLWRITE) m_cart->logerror("Write access to cartridge ROM at address %04x ignored", offset); } else { @@ -1969,7 +1972,7 @@ READ8Z_MEMBER(ti99_super_cartridge::crureadz) if ((offset & 0xfff0) == 0x0800) { - if (TRACE_CRU) space.device().logerror("CRU accessed at %04x\n", offset); + if (TRACE_CRU) m_cart->logerror("CRU accessed at %04x\n", offset); uint8_t val = 0x02 << (m_ram_page << 1); *value = (val >> ((offset - 0x0800)>>1)) & 0xff; } @@ -1979,9 +1982,12 @@ WRITE8_MEMBER(ti99_super_cartridge::cruwrite) { if ((offset & 0xfff0) == 0x0800) { - if (TRACE_CRU) space.device().logerror("CRU accessed at %04x\n", offset); + if (TRACE_CRU) m_cart->logerror("CRU accessed at %04x\n", offset); if (data != 0) + { m_ram_page = (offset-0x0802)>>2; + if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set RAM page = %d (CRU address %04x)\n", m_ram_page, offset); + } } } @@ -2034,7 +2040,7 @@ READ8Z_MEMBER(ti99_mbx_cartridge::readz) { // Also reads the value of 6ffe *value = m_ram_ptr[offset & 0x03ff]; - if (TRACE_READ) space.device().logerror("%04x (RAM) -> %02x\n", offset + 0x6000, *value); + if (TRACE_READ) m_cart->logerror("%04x (RAM) -> %02x\n", offset + 0x6000, *value); } else { @@ -2045,7 +2051,7 @@ READ8Z_MEMBER(ti99_mbx_cartridge::readz) else // 7000 area *value = m_rom_ptr[(offset & 0x0fff) | (m_rom_page << 12)]; - if (TRACE_READ) space.device().logerror("%04x(%04x) -> %02x\n", offset + 0x6000, offset | (m_rom_page<<13), *value); + if (TRACE_READ) m_cart->logerror("%04x(%04x) -> %02x\n", offset + 0x6000, offset | (m_rom_page<<13), *value); } } } @@ -2066,13 +2072,13 @@ WRITE8_MEMBER(ti99_mbx_cartridge::write) { // Valid values are 0, 1, 2, 3 m_rom_page = data & 3; - if (TRACE_WRITE) if ((offset & 1)==0) space.device().logerror("Set ROM page = %d\n", data); + if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } if (m_ram_ptr != nullptr) m_ram_ptr[offset & 0x03ff] = data; else - if (TRACE_ILLWRITE) space.device().logerror("Write access to %04x but no RAM present\n", offset+0x6000); + if (TRACE_ILLWRITE) m_cart->logerror("Write access to %04x but no RAM present\n", offset+0x6000); } } else @@ -2150,6 +2156,7 @@ WRITE8_MEMBER(ti99_paged379i_cartridge::write) // The page is determined by the inverted outputs. m_rom_page = (~offset)>>1 & mask; + if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } } @@ -2190,6 +2197,7 @@ WRITE8_MEMBER(ti99_paged378_cartridge::write) if (m_romspace_selected) { m_rom_page = ((offset >> 1)&0x003f); + if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } } @@ -2226,7 +2234,10 @@ WRITE8_MEMBER(ti99_paged377_cartridge::write) // Bits: 011x xxxb bbbb bbbx // x = don't care, bbbb = bank if (m_romspace_selected) + { m_rom_page = ((offset >> 1)&0x00ff); + if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); + } } /***************************************************************************** @@ -2298,6 +2309,7 @@ WRITE8_MEMBER(ti99_pagedcru_cartridge::cruwrite) if (data != 0 && bit > 0) { m_rom_page = (bit-1)/2; + if (TRACE_BANKSWITCH) m_cart->logerror("Set ROM page = %d (CRU address %d)\n", m_rom_page, offset); } } } @@ -2394,6 +2406,7 @@ WRITE8_MEMBER(ti99_gromemu_cartridge::write) return; // no paging } m_rom_page = (offset >> 1) & 1; + if (TRACE_BANKSWITCH) if ((offset & 1)==0) m_cart->logerror("Set ROM page = %d (writing to %04x)\n", m_rom_page, (offset | 0x6000)); } else { @@ -2445,7 +2458,7 @@ WRITE8_MEMBER(ti99_gromemu_cartridge::gromemuwrite) } else { - if (TRACE_ILLWRITE) space.device().logerror("Ignoring write to GROM area at address %04x\n", m_grom_address); + if (TRACE_ILLWRITE) m_cart->logerror("Ignoring write to GROM area at address %04x\n", m_grom_address); } } diff --git a/src/devices/cpu/8x300/8x300.cpp b/src/devices/cpu/8x300/8x300.cpp index 827c064783a..c9ec6839e9e 100644 --- a/src/devices/cpu/8x300/8x300.cpp +++ b/src/devices/cpu/8x300/8x300.cpp @@ -581,8 +581,8 @@ void n8x300_cpu_device::execute_run() } while (m_icount > 0); } -offs_t n8x300_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t n8x300_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( n8x300 ); - return CPU_DISASSEMBLE_NAME(n8x300)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(n8x300)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/8x300/8x300.h b/src/devices/cpu/8x300/8x300.h index 286701142f9..45d3f71cd91 100644 --- a/src/devices/cpu/8x300/8x300.h +++ b/src/devices/cpu/8x300/8x300.h @@ -73,7 +73,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) override; address_space_config m_program_config; address_space_config m_io_config; diff --git a/src/devices/cpu/8x300/8x300dasm.cpp b/src/devices/cpu/8x300/8x300dasm.cpp index 5b66dbd1f05..db6f3d2cd00 100644 --- a/src/devices/cpu/8x300/8x300dasm.cpp +++ b/src/devices/cpu/8x300/8x300dasm.cpp @@ -41,7 +41,7 @@ static inline bool is_src_rot(uint16_t opcode) return true; } -static offs_t internal_disasm_n8x300(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(n8x300) { unsigned startpc = pc; uint16_t opcode = (oprom[pc - startpc] << 8) | oprom[pc+1 - startpc]; @@ -129,13 +129,3 @@ static offs_t internal_disasm_n8x300(cpu_device *device, std::ostream &stream, o return (pc - startpc); } - - -CPU_DISASSEMBLE(n8x300) -{ - std::ostringstream stream; - offs_t result = internal_disasm_n8x300(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/adsp2100/2100dasm.cpp b/src/devices/cpu/adsp2100/2100dasm.cpp index 1508d360c81..a126cfa0bcb 100644 --- a/src/devices/cpu/adsp2100/2100dasm.cpp +++ b/src/devices/cpu/adsp2100/2100dasm.cpp @@ -233,7 +233,7 @@ static void aluconst(std::ostream &stream, int dest, int op) /* execute instructions on this CPU until icount expires */ -static offs_t internal_disasm_adsp21xx(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(adsp21xx) { unsigned int op = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16); unsigned dasmflags = 0; @@ -551,14 +551,3 @@ static offs_t internal_disasm_adsp21xx(cpu_device *device, std::ostream &stream, return 1 | dasmflags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(adsp21xx) -{ - std::ostringstream stream; - offs_t result = internal_disasm_adsp21xx(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - diff --git a/src/devices/cpu/adsp2100/adsp2100.cpp b/src/devices/cpu/adsp2100/adsp2100.cpp index 617f2324540..edd7cbd9cd3 100644 --- a/src/devices/cpu/adsp2100/adsp2100.cpp +++ b/src/devices/cpu/adsp2100/adsp2100.cpp @@ -774,10 +774,10 @@ uint32_t adsp21xx_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t adsp21xx_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t adsp21xx_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( adsp21xx ); - return CPU_DISASSEMBLE_NAME(adsp21xx)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(adsp21xx)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/adsp2100/adsp2100.h b/src/devices/cpu/adsp2100/adsp2100.h index f5e43700b0f..aa7fb7853dc 100644 --- a/src/devices/cpu/adsp2100/adsp2100.h +++ b/src/devices/cpu/adsp2100/adsp2100.h @@ -243,7 +243,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // helpers void create_tables(); diff --git a/src/devices/cpu/alph8201/8201dasm.cpp b/src/devices/cpu/alph8201/8201dasm.cpp index 6ffae084cea..307456f0633 100644 --- a/src/devices/cpu/alph8201/8201dasm.cpp +++ b/src/devices/cpu/alph8201/8201dasm.cpp @@ -349,7 +349,7 @@ static void InitDasm8201(void) OpInizialized = 1; } -static offs_t internal_disasm_alpha8201(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(alpha8201) { offs_t dasmflags = 0; int i; @@ -413,12 +413,3 @@ static offs_t internal_disasm_alpha8201(cpu_device *device, std::ostream &stream return cnt | dasmflags | DASMFLAG_SUPPORTED; } - -CPU_DISASSEMBLE(alpha8201) -{ - std::ostringstream stream; - offs_t result = internal_disasm_alpha8201(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/alph8201/alph8201.cpp b/src/devices/cpu/alph8201/alph8201.cpp index 9fecc803742..eb4390e251f 100644 --- a/src/devices/cpu/alph8201/alph8201.cpp +++ b/src/devices/cpu/alph8201/alph8201.cpp @@ -688,8 +688,8 @@ void alpha8201_cpu_device::execute_set_input(int inputnum, int state) } -offs_t alpha8201_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t alpha8201_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( alpha8201 ); - return CPU_DISASSEMBLE_NAME(alpha8201)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(alpha8201)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/alph8201/alph8201.h b/src/devices/cpu/alph8201/alph8201.h index d9b34389e69..2f10923e39a 100644 --- a/src/devices/cpu/alph8201/alph8201.h +++ b/src/devices/cpu/alph8201/alph8201.h @@ -76,7 +76,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; uint8_t M_RDMEM(uint16_t A) { return m_program->read_byte(A); } void M_WRMEM(uint16_t A,uint8_t V) { m_program->write_byte(A, V); } diff --git a/src/devices/cpu/alto2/alto2cpu.h b/src/devices/cpu/alto2/alto2cpu.h index 8c832e517dd..eb275154216 100644 --- a/src/devices/cpu/alto2/alto2cpu.h +++ b/src/devices/cpu/alto2/alto2cpu.h @@ -238,7 +238,7 @@ protected: //! device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: diff --git a/src/devices/cpu/alto2/alto2dsm.cpp b/src/devices/cpu/alto2/alto2dsm.cpp index 791cafb56e7..65c5d0b4acd 100644 --- a/src/devices/cpu/alto2/alto2dsm.cpp +++ b/src/devices/cpu/alto2/alto2dsm.cpp @@ -206,9 +206,9 @@ static const char *addrname(int a) return dst; } -offs_t alto2_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t alto2_cpu_device::disasm_disassemble(std::ostream &main_stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - size_t len = 128; + std::ostringstream stream; uint32_t mir = (static_cast(oprom[0]) << 24) | (static_cast(oprom[1]) << 16) | @@ -228,7 +228,6 @@ offs_t alto2_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8 (static_cast(src[2]) << 8) | (static_cast(src[3]) << 0); uint16_t prefetch = next2 & 1023; - char *dst = buffer; offs_t result = 1 | DASMFLAG_SUPPORTED; uint8_t pa; @@ -236,87 +235,87 @@ offs_t alto2_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8 result |= DASMFLAG_STEP_OUT; if (t) - dst += snprintf(dst, len - (size_t)(dst - buffer), "T<-%s ", t_bus_alu[aluf]); + util::stream_format(stream, "T<-%s ", t_bus_alu[aluf]); if (l) - dst += snprintf(dst, len - (size_t)(dst - buffer), "L<- "); + util::stream_format(stream, "L<- "); if (bs == 1) - dst += snprintf(dst, len - (size_t)(dst - buffer), "%s<- ", regname[rsel]); + util::stream_format(stream, "%s<- ", regname[rsel]); switch (aluf) { case 0: // T?: BUS // this is somehow redundant and just wasting space - // dst += snprintf(dst, len - (size_t)(dst - buffer), "ALUF(BUS) "); + // util::stream_format(stream, "ALUF(BUS) "); break; case 1: // : T - dst += snprintf(dst, len - (size_t)(dst - buffer), "T "); + util::stream_format(stream, "T "); break; case 2: // T?: BUS OR T - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS|T "); + util::stream_format(stream, "BUS|T "); break; case 3: // : BUS AND T - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS&T "); + util::stream_format(stream, "BUS&T "); break; case 4: // : BUS XOR T - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS^T "); + util::stream_format(stream, "BUS^T "); break; case 5: // T?: BUS + 1 - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS+1 "); + util::stream_format(stream, "BUS+1 "); break; case 6: // T?: BUS - 1 - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS-1 "); + util::stream_format(stream, "BUS-1 "); break; case 7: // : BUS + T - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS+T "); + util::stream_format(stream, "BUS+T "); break; case 8: // : BUS - T - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS-T "); + util::stream_format(stream, "BUS-T "); break; case 9: // : BUS - T - 1 - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS-T-1 "); + util::stream_format(stream, "BUS-T-1 "); break; case 10: // T?: BUS + T + 1 - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS+T+1 "); + util::stream_format(stream, "BUS+T+1 "); break; case 11: // T?: BUS + SKIP - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS+SKIP "); + util::stream_format(stream, "BUS+SKIP "); break; case 12: // T?: BUS, T (AND) - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS,T "); + util::stream_format(stream, "BUS,T "); break; case 13: // : BUS AND NOT T - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS&~T "); + util::stream_format(stream, "BUS&~T "); break; case 14: // : undefined - dst += snprintf(dst, len - (size_t)(dst - buffer), "*BUS "); + util::stream_format(stream, "*BUS "); break; case 15: // : undefined - dst += snprintf(dst, len - (size_t)(dst - buffer), "*BUS "); + util::stream_format(stream, "*BUS "); break; } switch (bs) { case 0: // read R - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS<-%s ", regname[rsel]); + util::stream_format(stream, "BUS<-%s ", regname[rsel]); break; case 1: // load R from shifter output - // dst += snprintf(dst, len - (size_t)(dst - buffer), "; %s<-", regname[rsel]); + // util::stream_format(stream, "; %s<-", regname[rsel]); break; case 2: // enables no source to the BUS, leaving it all ones - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS<-177777 "); + util::stream_format(stream, "BUS<-177777 "); break; case 3: // performs different functions in different tasks - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS<-BS3 "); + util::stream_format(stream, "BUS<-BS3 "); break; case 4: // performs different functions in different tasks - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS<-BS4 "); + util::stream_format(stream, "BUS<-BS4 "); break; case 5: // memory data - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS<-MD "); + util::stream_format(stream, "BUS<-MD "); break; case 6: // BUS[3-0] <- MOUSE; BUS[15-4] <- -1 - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS<-MOUSE "); + util::stream_format(stream, "BUS<-MOUSE "); break; case 7: // IR[7-0], possibly sign extended - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS<-DISP "); + util::stream_format(stream, "BUS<-DISP "); break; } @@ -325,29 +324,29 @@ offs_t alto2_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8 case 0: // no operation break; case 1: // load MAR from ALU output; start main memory reference - dst += snprintf(dst, len - (size_t)(dst - buffer), "MAR<-ALU "); + util::stream_format(stream, "MAR<-ALU "); break; case 2: // switch tasks if higher priority wakeup is pending - dst += snprintf(dst, len - (size_t)(dst - buffer), "TASK "); + util::stream_format(stream, "TASK "); break; case 3: // disable the current task until re-enabled by a hardware-generated condition - dst += snprintf(dst, len - (size_t)(dst - buffer), "BLOCK "); + util::stream_format(stream, "BLOCK "); break; case 4: // SHIFTER output will be L shifted left one place - dst += snprintf(dst, len - (size_t)(dst - buffer), "SHIFTER<-L(LSH1) "); + util::stream_format(stream, "SHIFTER<-L(LSH1) "); break; case 5: // SHIFTER output will be L shifted right one place - dst += snprintf(dst, len - (size_t)(dst - buffer), "SHIFTER<-L(RSH1) "); + util::stream_format(stream, "SHIFTER<-L(RSH1) "); break; case 6: // SHIFTER output will be L rotated left 8 places - dst += snprintf(dst, len - (size_t)(dst - buffer), "SHIFTER<-L(LCY8) "); + util::stream_format(stream, "SHIFTER<-L(LCY8) "); break; case 7: // put the constant from PROM (RSELECT,BS) on the bus pa = (rsel << 3) | bs; - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS<-%05o ", const_prom[pa]); + util::stream_format(stream, "BUS<-%05o ", const_prom[pa]); break; default: - dst += snprintf(dst, len - (size_t)(dst - buffer), "F1_%02o ", f1); + util::stream_format(stream, "F1_%02o ", f1); break; } @@ -355,39 +354,43 @@ offs_t alto2_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8 case 0: // no operation break; case 1: // NEXT <- NEXT OR (BUS==0 ? 1 : 0) - dst += snprintf(dst, len - (size_t)(dst - buffer), "[BUS==0 ? %s:%s] ", + util::stream_format(stream, "[BUS==0 ? %s:%s] ", addrname((prefetch | 1) & MCODE_MASK), addrname(prefetch & MCODE_MASK)); break; case 2: // NEXT <- NEXT OR (SHIFTER==0 ? 1 : 0) - dst += snprintf(dst, len - (size_t)(dst - buffer), "[SH==0 ? %s:%s] ", + util::stream_format(stream, "[SH==0 ? %s:%s] ", addrname((prefetch | 1) & MCODE_MASK), addrname(prefetch & MCODE_MASK)); break; case 3: // NEXT <- NEXT OR (SHIFTER<0 ? 1 : 0) - dst += snprintf(dst, len - (size_t)(dst - buffer), "[SH<0 ? %s:%s] ", + util::stream_format(stream, "[SH<0 ? %s:%s] ", addrname((prefetch | 1) & MCODE_MASK), addrname(prefetch & MCODE_MASK)); break; case 4: // NEXT <- NEXT OR BUS - dst += snprintf(dst, len - (size_t)(dst - buffer), "NEXT<-BUS "); + util::stream_format(stream, "NEXT<-BUS "); break; case 5: // NEXT <- NEXT OR ALUC0. ALUC0 is the carry produced by last L loading microinstruction. - dst += snprintf(dst, len - (size_t)(dst - buffer), "[ALUC0 ? %s:%s] ", + util::stream_format(stream, "[ALUC0 ? %s:%s] ", addrname((prefetch | 1) & MCODE_MASK), addrname(prefetch & MCODE_MASK)); break; case 6: // write BUS data to memory - dst += snprintf(dst, len - (size_t)(dst - buffer), "MD<-BUS "); + util::stream_format(stream, "MD<-BUS "); break; case 7: // put the constant from PROM (RSELECT,BS) on the bus if (f1 != 7) { pa = 8 * rsel + bs; - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS<-%05o", const_prom[pa]); + util::stream_format(stream, "BUS<-%05o", const_prom[pa]); } break; default: - dst += snprintf(dst, len - (size_t)(dst - buffer), "BUS<-F2_%02o ", f2); + util::stream_format(stream, "BUS<-F2_%02o ", f2); break; } - if (dst > buffer && dst[-1] == ' ') - *--dst = '\0'; + + // need to trim last space + std::string output = stream.str(); + if (output.length() > 0 && output[output.length() - 1] == ' ') + output.resize(output.length() - 1); + main_stream << output; return result; } diff --git a/src/devices/cpu/am29000/am29000.cpp b/src/devices/cpu/am29000/am29000.cpp index 3c808b8c27b..fbc5a231ac3 100644 --- a/src/devices/cpu/am29000/am29000.cpp +++ b/src/devices/cpu/am29000/am29000.cpp @@ -695,8 +695,8 @@ void am29000_cpu_device::execute_set_input(int inputnum, int state) } -offs_t am29000_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t am29000_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( am29000 ); - return CPU_DISASSEMBLE_NAME(am29000)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(am29000)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/am29000/am29000.h b/src/devices/cpu/am29000/am29000.h index d78097b90df..d685e5c7272 100644 --- a/src/devices/cpu/am29000/am29000.h +++ b/src/devices/cpu/am29000/am29000.h @@ -468,7 +468,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; void signal_exception(uint32_t type); void external_irq_check(); diff --git a/src/devices/cpu/am29000/am29dasm.cpp b/src/devices/cpu/am29000/am29dasm.cpp index 7357fb929ec..8c7f832e69f 100644 --- a/src/devices/cpu/am29000/am29dasm.cpp +++ b/src/devices/cpu/am29000/am29dasm.cpp @@ -117,7 +117,7 @@ static const char* get_spr(int spid) } } -static offs_t internal_disasm_am29000(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(am29000) { uint32_t op = (oprom[0] << 24) | (oprom[1] << 16) | (oprom[2] << 8) | oprom[3]; uint32_t flags = 0; @@ -230,12 +230,3 @@ static offs_t internal_disasm_am29000(cpu_device *device, std::ostream &stream, return 4 | flags | DASMFLAG_SUPPORTED; } - -CPU_DISASSEMBLE(am29000) -{ - std::ostringstream stream; - offs_t result = internal_disasm_am29000(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/amis2000/amis2000.cpp b/src/devices/cpu/amis2000/amis2000.cpp index e5e9b3898fb..a9b45e865b3 100644 --- a/src/devices/cpu/amis2000/amis2000.cpp +++ b/src/devices/cpu/amis2000/amis2000.cpp @@ -89,10 +89,10 @@ void amis2000_base_device::state_string_export(const device_state_entry &entry, } } -offs_t amis2000_base_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t amis2000_base_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(amis2000); - return CPU_DISASSEMBLE_NAME(amis2000)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(amis2000)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/amis2000/amis2000.h b/src/devices/cpu/amis2000/amis2000.h index 5d7967eeb38..f5611b4d54d 100644 --- a/src/devices/cpu/amis2000/amis2000.h +++ b/src/devices/cpu/amis2000/amis2000.h @@ -88,7 +88,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 1; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/amis2000/amis2000d.cpp b/src/devices/cpu/amis2000/amis2000d.cpp index 90a786de0af..2dd3433718f 100644 --- a/src/devices/cpu/amis2000/amis2000d.cpp +++ b/src/devices/cpu/amis2000/amis2000d.cpp @@ -100,7 +100,7 @@ static const uint8_t s2000_mnemonic[0x100] = -static offs_t internal_disasm_amis2000(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(amis2000) { int pos = 0; uint8_t op = oprom[pos++]; @@ -130,13 +130,3 @@ static offs_t internal_disasm_amis2000(cpu_device *device, std::ostream &stream, return pos | s_flags[instr] | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(amis2000) -{ - std::ostringstream stream; - offs_t result = internal_disasm_amis2000(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/apexc/apexc.cpp b/src/devices/cpu/apexc/apexc.cpp index cbd824d5978..cf132550263 100644 --- a/src/devices/cpu/apexc/apexc.cpp +++ b/src/devices/cpu/apexc/apexc.cpp @@ -847,8 +847,8 @@ void apexc_cpu_device::execute_run() } -offs_t apexc_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t apexc_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( apexc ); - return CPU_DISASSEMBLE_NAME(apexc)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(apexc)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/apexc/apexc.h b/src/devices/cpu/apexc/apexc.h index eefff1e7c73..28aba6a5b52 100644 --- a/src/devices/cpu/apexc/apexc.h +++ b/src/devices/cpu/apexc/apexc.h @@ -42,7 +42,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; inline uint32_t apexc_readmem(uint32_t address) { return m_program->read_dword((address)<<2); } inline void apexc_writemem(uint32_t address, uint32_t data) { m_program->write_dword((address)<<2, (data)); } diff --git a/src/devices/cpu/apexc/apexcdsm.cpp b/src/devices/cpu/apexc/apexcdsm.cpp index 6113ef2e137..e3626a40af9 100644 --- a/src/devices/cpu/apexc/apexcdsm.cpp +++ b/src/devices/cpu/apexc/apexcdsm.cpp @@ -83,7 +83,7 @@ static const instr_desc instructions[16] = { "A", store }, { "S", swap } }; -static offs_t internal_disasm_apexc(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(apexc) { uint32_t instruction; /* 32-bit machine instruction */ int x, y, function, c6, vector; /* instruction fields */ @@ -179,16 +179,5 @@ static offs_t internal_disasm_apexc(cpu_device *device, std::ostream &stream, of /* print Y address */ util::stream_format(stream, "%03X(%02d/%02d)", y<<2, (y >> 5) & 0x1f, y & 0x1f); /* 7 chars */ - return 4; } - - -CPU_DISASSEMBLE(apexc) -{ - std::ostringstream stream; - offs_t result = internal_disasm_apexc(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/arc/arc.cpp b/src/devices/cpu/arc/arc.cpp index c9f1f0ecf2d..71c55b674a2 100644 --- a/src/devices/cpu/arc/arc.cpp +++ b/src/devices/cpu/arc/arc.cpp @@ -25,10 +25,10 @@ arc_device::arc_device(const machine_config &mconfig, const char *tag, device_t } -offs_t arc_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t arc_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( arc ); - return CPU_DISASSEMBLE_NAME(arc)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(arc)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/arc/arc.h b/src/devices/cpu/arc/arc.h index dd92ea5f36d..04639abf17c 100644 --- a/src/devices/cpu/arc/arc.h +++ b/src/devices/cpu/arc/arc.h @@ -45,7 +45,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/arc/arcdasm.cpp b/src/devices/cpu/arc/arcdasm.cpp index abf36e83027..752ece7a150 100644 --- a/src/devices/cpu/arc/arcdasm.cpp +++ b/src/devices/cpu/arc/arcdasm.cpp @@ -180,7 +180,7 @@ static const char *regnames[0x40] = #define ARC_REGOP_SHIMM ((op & 0x000001ff) >> 0 ) // aka D -static offs_t internal_disasm_arc(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(arc) { uint32_t op = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24); op = big_endianize_int32(op); @@ -207,14 +207,3 @@ static offs_t internal_disasm_arc(cpu_device *device, std::ostream &stream, offs return 4 | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(arc) -{ - std::ostringstream stream; - offs_t result = internal_disasm_arc(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - diff --git a/src/devices/cpu/arcompact/arcompact.cpp b/src/devices/cpu/arcompact/arcompact.cpp index e3498cd01cb..cd44d6b5681 100644 --- a/src/devices/cpu/arcompact/arcompact.cpp +++ b/src/devices/cpu/arcompact/arcompact.cpp @@ -58,10 +58,10 @@ arcompact_device::arcompact_device(const machine_config &mconfig, const char *ta } -offs_t arcompact_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t arcompact_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( arcompact ); - return CPU_DISASSEMBLE_NAME(arcompact)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(arcompact)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/arcompact/arcompact.h b/src/devices/cpu/arcompact/arcompact.h index fd18ce0a124..227abe8f912 100644 --- a/src/devices/cpu/arcompact/arcompact.h +++ b/src/devices/cpu/arcompact/arcompact.h @@ -104,7 +104,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; diff --git a/src/devices/cpu/arcompact/arcompactdasm.cpp b/src/devices/cpu/arcompact/arcompactdasm.cpp index 8103797deea..cd557017332 100644 --- a/src/devices/cpu/arcompact/arcompactdasm.cpp +++ b/src/devices/cpu/arcompact/arcompactdasm.cpp @@ -22,7 +22,7 @@ #define ARCOMPACT_OPERATION ((op & 0xf800) >> 11) -static offs_t internal_disasm_arcompact(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(arcompact) { int size; @@ -87,13 +87,3 @@ static offs_t internal_disasm_arcompact(cpu_device *device, std::ostream &stream return size | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(arcompact) -{ - std::ostringstream stream; - offs_t result = internal_disasm_arcompact(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/arm/arm.cpp b/src/devices/cpu/arm/arm.cpp index 1b342b3ea56..a46bdb03ed6 100644 --- a/src/devices/cpu/arm/arm.cpp +++ b/src/devices/cpu/arm/arm.cpp @@ -1553,15 +1553,15 @@ void arm_cpu_device::HandleCoPro( uint32_t insn ) } -offs_t arm_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t arm_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( arm ); - return CPU_DISASSEMBLE_NAME(arm)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(arm)(this, stream, pc, oprom, opram, options); } -offs_t arm_be_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t arm_be_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( arm_be ); - return CPU_DISASSEMBLE_NAME(arm_be)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(arm_be)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/arm/arm.h b/src/devices/cpu/arm/arm.h index 051c88f64b9..4c8dbec4384 100644 --- a/src/devices/cpu/arm/arm.h +++ b/src/devices/cpu/arm/arm.h @@ -66,7 +66,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; @@ -113,7 +113,7 @@ public: arm_be_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; diff --git a/src/devices/cpu/arm/armdasm.cpp b/src/devices/cpu/arm/armdasm.cpp index b93b509789e..67d65209871 100644 --- a/src/devices/cpu/arm/armdasm.cpp +++ b/src/devices/cpu/arm/armdasm.cpp @@ -390,23 +390,14 @@ static uint32_t arm_disasm( std::ostream &stream, uint32_t pc, uint32_t opcode ) return dasmflags | DASMFLAG_SUPPORTED; } -static uint32_t arm_disasm(char *buffer, uint32_t pc, uint32_t opcode) -{ - std::ostringstream stream; - uint32_t result = arm_disasm(stream, pc, opcode); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE( arm ) { uint32_t opcode = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24); - return 4 | arm_disasm(buffer, pc, opcode); + return 4 | arm_disasm(stream, pc, opcode); } CPU_DISASSEMBLE( arm_be ) { uint32_t opcode = oprom[3] | (oprom[2] << 8) | (oprom[1] << 16) | (oprom[0] << 24); - return 4 | arm_disasm(buffer, pc, opcode); + return 4 | arm_disasm(stream, pc, opcode); } diff --git a/src/devices/cpu/arm7/arm7.cpp b/src/devices/cpu/arm7/arm7.cpp index 67a91a4f19c..9ae2d06cb85 100644 --- a/src/devices/cpu/arm7/arm7.cpp +++ b/src/devices/cpu/arm7/arm7.cpp @@ -764,7 +764,7 @@ void arm7_cpu_device::execute_set_input(int irqline, int state) } -offs_t arm7_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t arm7_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( arm7arm ); extern CPU_DISASSEMBLE( arm7thumb ); @@ -774,16 +774,16 @@ offs_t arm7_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_ if (T_IS_SET(m_r[eCPSR])) { if ( m_endian == ENDIANNESS_BIG ) - return CPU_DISASSEMBLE_NAME(arm7thumb_be)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(arm7thumb_be)(this, stream, pc, oprom, opram, options); else - return CPU_DISASSEMBLE_NAME(arm7thumb)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(arm7thumb)(this, stream, pc, oprom, opram, options); } else { if ( m_endian == ENDIANNESS_BIG ) - return CPU_DISASSEMBLE_NAME(arm7arm_be)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(arm7arm_be)(this, stream, pc, oprom, opram, options); else - return CPU_DISASSEMBLE_NAME(arm7arm)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(arm7arm)(this, stream, pc, oprom, opram, options); } } diff --git a/src/devices/cpu/arm7/arm7.h b/src/devices/cpu/arm7/arm7.h index 8309b3b7dee..7007f4b4be6 100644 --- a/src/devices/cpu/arm7/arm7.h +++ b/src/devices/cpu/arm7/arm7.h @@ -76,7 +76,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; diff --git a/src/devices/cpu/arm7/arm7dasm.cpp b/src/devices/cpu/arm7/arm7dasm.cpp index e0416d8aacd..5288f27e9b5 100644 --- a/src/devices/cpu/arm7/arm7dasm.cpp +++ b/src/devices/cpu/arm7/arm7dasm.cpp @@ -1300,40 +1300,22 @@ static uint32_t thumb_disasm(std::ostream &stream, uint32_t pc, uint16_t opcode) return dasmflags | DASMFLAG_SUPPORTED; } -static uint32_t arm7_disasm(char *buffer, uint32_t pc, uint32_t opcode) -{ - std::ostringstream stream; - uint32_t result = arm7_disasm(stream, pc, opcode); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - -static uint32_t thumb_disasm(char *buffer, uint32_t pc, uint16_t opcode) -{ - std::ostringstream stream; - uint32_t result = thumb_disasm(stream, pc, opcode); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE( arm7arm ) { - return arm7_disasm(buffer, pc, oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24)) | 4; + return arm7_disasm(stream, pc, oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24)) | 4; } CPU_DISASSEMBLE( arm7arm_be ) { - return arm7_disasm(buffer, pc, oprom[3] | (oprom[2] << 8) | (oprom[1] << 16) | (oprom[0] << 24)) | 4; + return arm7_disasm(stream, pc, oprom[3] | (oprom[2] << 8) | (oprom[1] << 16) | (oprom[0] << 24)) | 4; } CPU_DISASSEMBLE( arm7thumb ) { - return thumb_disasm(buffer, pc, oprom[0] | (oprom[1] << 8)) | 2; + return thumb_disasm(stream, pc, oprom[0] | (oprom[1] << 8)) | 2; } CPU_DISASSEMBLE( arm7thumb_be ) { - return thumb_disasm(buffer, pc, oprom[1] | (oprom[0] << 8)) | 2; + return thumb_disasm(stream, pc, oprom[1] | (oprom[0] << 8)) | 2; } diff --git a/src/devices/cpu/arm7/arm7drc.hxx b/src/devices/cpu/arm7/arm7drc.hxx index 2dc32cd68c2..7df82e359ab 100644 --- a/src/devices/cpu/arm7/arm7drc.hxx +++ b/src/devices/cpu/arm7/arm7drc.hxx @@ -1362,7 +1362,7 @@ void arm7_cpu_device::saturate_qbit_overflow(drcuml_block *block) UML_DCMP(block, uml::I0, 0x000000007fffffffL); UML_MOVc(block, uml::COND_G, uml::I1, Q_MASK); UML_MOVc(block, uml::COND_G, uml::I0, 0x7fffffff); - UML_DCMP(block, uml::I0, U64(0xffffffff80000000)); + UML_DCMP(block, uml::I0, 0xffffffff80000000ULL); UML_MOVc(block, uml::COND_L, uml::I1, Q_MASK); UML_MOVc(block, uml::COND_L, uml::I0, 0x80000000); UML_OR(block, DRC_CPSR, DRC_CPSR, uml::I1); diff --git a/src/devices/cpu/asap/asap.cpp b/src/devices/cpu/asap/asap.cpp index c5271ab128a..6e539784ab1 100644 --- a/src/devices/cpu/asap/asap.cpp +++ b/src/devices/cpu/asap/asap.cpp @@ -324,10 +324,10 @@ uint32_t asap_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t asap_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t asap_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( asap ); - return CPU_DISASSEMBLE_NAME(asap)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(asap)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/asap/asap.h b/src/devices/cpu/asap/asap.h index 1ed0583d4d1..4ac44a9bcdb 100644 --- a/src/devices/cpu/asap/asap.h +++ b/src/devices/cpu/asap/asap.h @@ -53,7 +53,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // helpers inline uint32_t readop(offs_t pc); diff --git a/src/devices/cpu/asap/asapdasm.cpp b/src/devices/cpu/asap/asapdasm.cpp index 1f24fef64ec..f26c6db046f 100644 --- a/src/devices/cpu/asap/asapdasm.cpp +++ b/src/devices/cpu/asap/asapdasm.cpp @@ -45,7 +45,7 @@ static inline char *src2(uint32_t op, int scale) return temp; } -static offs_t internal_disasm_asap(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(asap) { uint32_t op = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24); int opcode = op >> 27; @@ -141,16 +141,6 @@ static offs_t internal_disasm_asap(cpu_device *device, std::ostream &stream, off util::stream_format(stream, "jmp%s %s[%s]", setcond[cond], reg[rsrc1], src2(op,2)); break; case 0x1f: util::stream_format(stream, "trap $1f"); flags = DASMFLAG_STEP_OVER; break; - } + } return 4 | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(asap) -{ - std::ostringstream stream; - offs_t result = internal_disasm_asap(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/avr8/avr8.cpp b/src/devices/cpu/avr8/avr8.cpp index 6f0a4278d5b..7ae680fd3b5 100644 --- a/src/devices/cpu/avr8/avr8.cpp +++ b/src/devices/cpu/avr8/avr8.cpp @@ -949,10 +949,10 @@ uint32_t avr8_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t avr8_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t avr8_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( avr8 ); - return CPU_DISASSEMBLE_NAME(avr8)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(avr8)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/avr8/avr8.h b/src/devices/cpu/avr8/avr8.h index 006d052f70c..ffef27cd781 100644 --- a/src/devices/cpu/avr8/avr8.h +++ b/src/devices/cpu/avr8/avr8.h @@ -128,7 +128,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/avr8/avr8dasm.cpp b/src/devices/cpu/avr8/avr8dasm.cpp index bd870b5d840..cfc99b955d3 100644 --- a/src/devices/cpu/avr8/avr8dasm.cpp +++ b/src/devices/cpu/avr8/avr8dasm.cpp @@ -25,7 +25,7 @@ #define ACONST6(op) ((((op) >> 5) & 0x0030) | ((op) & 0x000f)) #define MULCONST2(op) ((((op) >> 6) & 0x0002) | (((op) >> 3) & 0x0001)) -static offs_t internal_disasm_avr8(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(avr8) { int pos = 0; uint32_t op = oprom[pos++]; @@ -671,13 +671,3 @@ static offs_t internal_disasm_avr8(cpu_device *device, std::ostream &stream, off return pos | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(avr8) -{ - std::ostringstream stream; - offs_t result = internal_disasm_avr8(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/ccpu/ccpu.cpp b/src/devices/cpu/ccpu/ccpu.cpp index cc40e4edcd4..ad9fbedca86 100644 --- a/src/devices/cpu/ccpu/ccpu.cpp +++ b/src/devices/cpu/ccpu/ccpu.cpp @@ -687,8 +687,8 @@ void ccpu_cpu_device::execute_run() } -offs_t ccpu_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t ccpu_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( ccpu ); - return CPU_DISASSEMBLE_NAME(ccpu)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(ccpu)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/ccpu/ccpu.h b/src/devices/cpu/ccpu/ccpu.h index 6fff475a3b6..73cd5c6109c 100644 --- a/src/devices/cpu/ccpu/ccpu.h +++ b/src/devices/cpu/ccpu/ccpu.h @@ -87,7 +87,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 3; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; address_space_config m_data_config; diff --git a/src/devices/cpu/ccpu/ccpudasm.cpp b/src/devices/cpu/ccpu/ccpudasm.cpp index 309b4167cc1..bb843374c2b 100644 --- a/src/devices/cpu/ccpu/ccpudasm.cpp +++ b/src/devices/cpu/ccpu/ccpudasm.cpp @@ -14,7 +14,7 @@ #include "ccpu.h" -static offs_t internal_disasm_ccpu(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(ccpu) { unsigned startpc = pc; uint8_t opcode = oprom[pc++ - startpc]; @@ -328,13 +328,3 @@ static offs_t internal_disasm_ccpu(cpu_device *device, std::ostream &stream, off return (pc - startpc) | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(ccpu) -{ - std::ostringstream stream; - offs_t result = internal_disasm_ccpu(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/cop400/cop400.cpp b/src/devices/cpu/cop400/cop400.cpp index 58a5c672a35..fd0164f83a1 100644 --- a/src/devices/cpu/cop400/cop400.cpp +++ b/src/devices/cpu/cop400/cop400.cpp @@ -1171,7 +1171,7 @@ void cop400_cpu_device::state_string_export(const device_state_entry &entry, std } -offs_t cop400_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t cop400_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( cop410 ); extern CPU_DISASSEMBLE( cop420 ); @@ -1179,15 +1179,15 @@ offs_t cop400_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint if ( m_featuremask & COP444_FEATURE ) { - return CPU_DISASSEMBLE_NAME(cop444)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(cop444)(this, stream, pc, oprom, opram, options); } if ( m_featuremask & COP420_FEATURE ) { - return CPU_DISASSEMBLE_NAME(cop420)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(cop420)(this, stream, pc, oprom, opram, options); } - return CPU_DISASSEMBLE_NAME(cop410)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(cop410)(this, stream, pc, oprom, opram, options); } READ8_MEMBER( cop400_cpu_device::microbus_rd ) diff --git a/src/devices/cpu/cop400/cop400.h b/src/devices/cpu/cop400/cop400.h index 6788d52c2a2..bace4710008 100644 --- a/src/devices/cpu/cop400/cop400.h +++ b/src/devices/cpu/cop400/cop400.h @@ -169,7 +169,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; address_space_config m_data_config; diff --git a/src/devices/cpu/cop400/cop410ds.cpp b/src/devices/cpu/cop400/cop410ds.cpp index 1c28ea070bf..b6f6f4d06f4 100644 --- a/src/devices/cpu/cop400/cop410ds.cpp +++ b/src/devices/cpu/cop400/cop410ds.cpp @@ -10,7 +10,7 @@ #include "emu.h" -static offs_t internal_disasm_cop410(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(cop410) { uint8_t opcode = oprom[0]; uint8_t next_opcode = oprom[1]; @@ -348,13 +348,3 @@ static offs_t internal_disasm_cop410(cpu_device *device, std::ostream &stream, o return bytes | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(cop410) -{ - std::ostringstream stream; - offs_t result = internal_disasm_cop410(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/cop400/cop420ds.cpp b/src/devices/cpu/cop400/cop420ds.cpp index bf032238687..7c337edb0a1 100644 --- a/src/devices/cpu/cop400/cop420ds.cpp +++ b/src/devices/cpu/cop400/cop420ds.cpp @@ -10,7 +10,7 @@ #include "emu.h" -static offs_t internal_disasm_cop420(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(cop420) { uint8_t opcode = oprom[0]; uint8_t next_opcode = oprom[1]; @@ -396,13 +396,3 @@ static offs_t internal_disasm_cop420(cpu_device *device, std::ostream &stream, o return bytes | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(cop420) -{ - std::ostringstream stream; - offs_t result = internal_disasm_cop420(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/cop400/cop440ds.cpp b/src/devices/cpu/cop400/cop440ds.cpp index 0150e20ea76..5f7517fca05 100644 --- a/src/devices/cpu/cop400/cop440ds.cpp +++ b/src/devices/cpu/cop400/cop440ds.cpp @@ -10,7 +10,7 @@ #include "emu.h" -static offs_t internal_disasm_cop444(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(cop444) { uint8_t opcode = oprom[0]; uint8_t next_opcode = oprom[1]; @@ -413,13 +413,3 @@ static offs_t internal_disasm_cop444(cpu_device *device, std::ostream &stream, o return bytes | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(cop444) -{ - std::ostringstream stream; - offs_t result = internal_disasm_cop444(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/cosmac/cosdasm.cpp b/src/devices/cpu/cosmac/cosdasm.cpp index c5689b25fcc..72f039037b5 100644 --- a/src/devices/cpu/cosmac/cosdasm.cpp +++ b/src/devices/cpu/cosmac/cosdasm.cpp @@ -185,23 +185,13 @@ static uint32_t disassemble(device_t *device, std::ostream &stream, offs_t pc, c } -static uint32_t disassemble(device_t *device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t variant) -{ - std::ostringstream stream; - uint32_t result = disassemble(device, stream, pc, oprom, opram, variant); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - - CPU_DISASSEMBLE( cdp1801 ) { - return disassemble(device, buffer, pc, oprom, opram, TYPE_1801); + return disassemble(device, stream, pc, oprom, opram, TYPE_1801); } CPU_DISASSEMBLE( cdp1802 ) { - return disassemble(device, buffer, pc, oprom, opram, TYPE_1802); + return disassemble(device, stream, pc, oprom, opram, TYPE_1802); } diff --git a/src/devices/cpu/cosmac/cosmac.cpp b/src/devices/cpu/cosmac/cosmac.cpp index a05d9cd1825..0e8c3de3f3c 100644 --- a/src/devices/cpu/cosmac/cosmac.cpp +++ b/src/devices/cpu/cosmac/cosmac.cpp @@ -512,16 +512,16 @@ uint32_t cosmac_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t cdp1801_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t cdp1801_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( cdp1801 ); - return CPU_DISASSEMBLE_NAME( cdp1801 )(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME( cdp1801 )(this, stream, pc, oprom, opram, options); } -offs_t cdp1802_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t cdp1802_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( cdp1802 ); - return CPU_DISASSEMBLE_NAME( cdp1802 )(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME( cdp1802 )(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/cosmac/cosmac.h b/src/devices/cpu/cosmac/cosmac.h index 7e4728f918b..e9ff3b705bb 100644 --- a/src/devices/cpu/cosmac/cosmac.h +++ b/src/devices/cpu/cosmac/cosmac.h @@ -451,7 +451,7 @@ public: protected: // device_disasm_interface overrides - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual cosmac_device::ophandler get_ophandler(uint8_t opcode) override; @@ -469,7 +469,7 @@ public: protected: // device_disasm_interface overrides - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual cosmac_device::ophandler get_ophandler(uint8_t opcode) override; diff --git a/src/devices/cpu/cp1610/1610dasm.cpp b/src/devices/cpu/cp1610/1610dasm.cpp index 5a2daf2cbfe..0e9ed461dd3 100644 --- a/src/devices/cpu/cp1610/1610dasm.cpp +++ b/src/devices/cpu/cp1610/1610dasm.cpp @@ -4,7 +4,7 @@ #include "debugger.h" #include "cp1610.h" -static offs_t internal_disasm_cp1610(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(cp1610) { uint16_t oprom16[4]={ static_cast((oprom[0] << 8) | oprom[1]), static_cast((oprom[2] << 8) | oprom[3]), static_cast((oprom[4] << 8) | oprom[5]), static_cast((oprom[6] << 8) | oprom[7]) }; uint16_t op = oprom16[0]; uint16_t subop; @@ -1488,13 +1488,3 @@ static offs_t internal_disasm_cp1610(cpu_device *device, std::ostream &stream, o return size; } - - -CPU_DISASSEMBLE(cp1610) -{ - std::ostringstream stream; - offs_t result = internal_disasm_cp1610(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/cp1610/cp1610.cpp b/src/devices/cpu/cp1610/cp1610.cpp index 9c2ed837b3b..b2b923fbc8f 100644 --- a/src/devices/cpu/cp1610/cp1610.cpp +++ b/src/devices/cpu/cp1610/cp1610.cpp @@ -3417,8 +3417,8 @@ void cp1610_cpu_device::state_string_export(const device_state_entry &entry, std } -offs_t cp1610_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t cp1610_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( cp1610 ); - return CPU_DISASSEMBLE_NAME(cp1610)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(cp1610)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/cp1610/cp1610.h b/src/devices/cpu/cp1610/cp1610.h index cec2c567776..545c37fbb83 100644 --- a/src/devices/cpu/cp1610/cp1610.h +++ b/src/devices/cpu/cp1610/cp1610.h @@ -61,7 +61,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/cubeqcpu/cubedasm.cpp b/src/devices/cpu/cubeqcpu/cubedasm.cpp index 6d346f9dc7a..20fd5a266d0 100644 --- a/src/devices/cpu/cubeqcpu/cubedasm.cpp +++ b/src/devices/cpu/cubeqcpu/cubedasm.cpp @@ -58,7 +58,7 @@ static const char *const dst[] = SOUND DISASSEMBLY HOOK ***************************************************************************/ -static offs_t internal_disasm_cquestsnd(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(cquestsnd) { static const char *const jmps[] = { @@ -125,21 +125,11 @@ static offs_t internal_disasm_cquestsnd(cpu_device *device, std::ostream &stream } -CPU_DISASSEMBLE(cquestsnd) -{ - std::ostringstream stream; - offs_t result = internal_disasm_cquestsnd(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - - /*************************************************************************** ROTATE DISASSEMBLY HOOK ***************************************************************************/ -static offs_t internal_disasm_cquestrot(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(cquestrot) { static const char *const jmps[] = { @@ -231,21 +221,11 @@ static offs_t internal_disasm_cquestrot(cpu_device *device, std::ostream &stream } -CPU_DISASSEMBLE(cquestrot) -{ - std::ostringstream stream; - offs_t result = internal_disasm_cquestrot(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - - /*************************************************************************** LINE DRAWER DISASSEMBLY HOOK ***************************************************************************/ -static offs_t internal_disasm_cquestlin(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(cquestlin) { static const char *const jmps[] = { @@ -325,13 +305,3 @@ static offs_t internal_disasm_cquestlin(cpu_device *device, std::ostream &stream return 1 | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(cquestlin) -{ - std::ostringstream stream; - offs_t result = internal_disasm_cquestlin(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/cubeqcpu/cubeqcpu.cpp b/src/devices/cpu/cubeqcpu/cubeqcpu.cpp index 6939332b647..a2216a1025a 100644 --- a/src/devices/cpu/cubeqcpu/cubeqcpu.cpp +++ b/src/devices/cpu/cubeqcpu/cubeqcpu.cpp @@ -84,10 +84,10 @@ cquestsnd_cpu_device::cquestsnd_cpu_device(const machine_config &mconfig, const } -offs_t cquestsnd_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t cquestsnd_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( cquestsnd ); - return CPU_DISASSEMBLE_NAME(cquestsnd)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(cquestsnd)(this, stream, pc, oprom, opram, options); } @@ -105,10 +105,10 @@ READ16_MEMBER( cquestrot_cpu_device::linedata_r ) } -offs_t cquestrot_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t cquestrot_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( cquestrot ); - return CPU_DISASSEMBLE_NAME(cquestrot)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(cquestrot)(this, stream, pc, oprom, opram, options); } @@ -122,10 +122,10 @@ cquestlin_cpu_device::cquestlin_cpu_device(const machine_config &mconfig, const } -offs_t cquestlin_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t cquestlin_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( cquestlin ); - return CPU_DISASSEMBLE_NAME(cquestlin)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(cquestlin)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/cubeqcpu/cubeqcpu.h b/src/devices/cpu/cubeqcpu/cubeqcpu.h index 824ec9c29b1..590993d07d5 100644 --- a/src/devices/cpu/cubeqcpu/cubeqcpu.h +++ b/src/devices/cpu/cubeqcpu/cubeqcpu.h @@ -166,7 +166,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 8; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; @@ -237,7 +237,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 8; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; @@ -321,7 +321,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 8; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/drcbex64.cpp b/src/devices/cpu/drcbex64.cpp index 3c136fff783..27404d0f066 100644 --- a/src/devices/cpu/drcbex64.cpp +++ b/src/devices/cpu/drcbex64.cpp @@ -273,7 +273,7 @@ inline x86_memref drcbe_x64::MABS(const void *ptr) drcbe_x64::opcode_generate_func drcbe_x64::s_opcode_table[OP_MAX]; // size-to-mask table -//static const uint64_t size_to_mask[] = { 0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0, U64(0xffffffffffffffff) }; +//static const uint64_t size_to_mask[] = { 0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0, 0xffffffffffffffffU }; // register mapping tables static const uint8_t int_register_map[REG_I_COUNT] = @@ -642,7 +642,7 @@ drcbe_x64::drcbe_x64(drcuml_state &drcuml, device_t &device, drc_cache &cache, u m_absmask32 = (uint32_t *)(((uintptr_t)m_absmask32 + 15) & ~15); m_absmask32[0] = m_absmask32[1] = m_absmask32[2] = m_absmask32[3] = 0x7fffffff; m_absmask64 = (uint64_t *)&m_absmask32[4]; - m_absmask64[0] = m_absmask64[1] = U64(0x7fffffffffffffff); + m_absmask64[0] = m_absmask64[1] = 0x7fffffffffffffffU; // get pointers to C functions we need to call m_near.debug_cpu_instruction_hook = (x86code *)debugger_instruction_hook; @@ -1975,7 +1975,7 @@ void drcbe_x64::emit_and_r64_p64(x86code *&dst, uint8_t reg, const be_parameter { if (param.is_immediate()) { - if (inst.flags() != 0 || param.immediate() != U64(0xffffffffffffffff)) + if (inst.flags() != 0 || param.immediate() != 0xffffffffffffffffU) { if (short_immediate(param.immediate())) emit_and_r64_imm(dst, reg, param.immediate()); // and reg,param @@ -2002,7 +2002,7 @@ void drcbe_x64::emit_and_m64_p64(x86code *&dst, x86_memref memref, const be_para { if (param.is_immediate()) { - if (inst.flags() != 0 || param.immediate() != U64(0xffffffffffffffff)) + if (inst.flags() != 0 || param.immediate() != 0xffffffffffffffffU) { if (short_immediate(param.immediate())) emit_and_m64_imm(dst, memref, param.immediate()); // and [mem],param @@ -2132,7 +2132,7 @@ void drcbe_x64::emit_xor_r64_p64(x86code *&dst, uint8_t reg, const be_parameter { if (inst.flags() != 0 || param.immediate() != 0) { - if (param.immediate() == U64(0xffffffffffffffff)) + if (param.immediate() == 0xffffffffffffffffU) emit_not_r64(dst, reg); // not reg else if (short_immediate(param.immediate())) emit_xor_r64_imm(dst, reg, param.immediate()); // xor reg,param @@ -2161,7 +2161,7 @@ void drcbe_x64::emit_xor_m64_p64(x86code *&dst, x86_memref memref, const be_para { if (inst.flags() != 0 || param.immediate() != 0) { - if (param.immediate() == U64(0xffffffffffffffff)) + if (param.immediate() == 0xffffffffffffffffU) emit_not_m64(dst, memref); // not [mem] else if (short_immediate(param.immediate())) emit_xor_m64_imm(dst, memref, param.immediate()); // xor [mem],param diff --git a/src/devices/cpu/drcbex86.cpp b/src/devices/cpu/drcbex86.cpp index 5f7bf220ef2..d4435ef9514 100644 --- a/src/devices/cpu/drcbex86.cpp +++ b/src/devices/cpu/drcbex86.cpp @@ -148,7 +148,7 @@ const uint32_t PTYPE_MF = PTYPE_M | PTYPE_F; drcbe_x86::opcode_generate_func drcbe_x86::s_opcode_table[OP_MAX]; // size-to-mask table -//static const uint64_t size_to_mask[] = { 0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0, U64(0xffffffffffffffff) }; +//static const uint64_t size_to_mask[] = { 0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0, 0xffffffffffffffffU }; // register mapping tables static const uint8_t int_register_map[REG_I_COUNT] = @@ -5243,7 +5243,7 @@ void drcbe_x86::op_and(x86code *&dst, const instruction &inst) } // AND with immediate 0xffffffff00000000 - else if (src2p.is_immediate_value(U64(0xffffffff00000000)) && inst.flags() == 0) + else if (src2p.is_immediate_value(0xffffffff00000000U) && inst.flags() == 0) { if (src1p != dstp) { diff --git a/src/devices/cpu/dsp16/dsp16.cpp b/src/devices/cpu/dsp16/dsp16.cpp index 6cefa03836c..6baaa215e73 100644 --- a/src/devices/cpu/dsp16/dsp16.cpp +++ b/src/devices/cpu/dsp16/dsp16.cpp @@ -108,8 +108,8 @@ void dsp16_device::device_start() state_add(DSP16_X, "X", m_x); state_add(DSP16_Y, "Y", m_y); state_add(DSP16_P, "P", m_p); - state_add(DSP16_A0, "A0", m_a0).mask(U64(0xfffffffff)); - state_add(DSP16_A1, "A1", m_a1).mask(U64(0xfffffffff)); + state_add(DSP16_A0, "A0", m_a0).mask(0xfffffffffU); + state_add(DSP16_A1, "A1", m_a1).mask(0xfffffffffU); state_add(DSP16_AUC, "AUC", m_auc).formatstr("%8s"); state_add(DSP16_PSW, "PSW", m_psw).formatstr("%16s"); state_add(DSP16_C0, "C0", m_c0); @@ -348,10 +348,10 @@ uint32_t dsp16_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t dsp16_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t dsp16_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( dsp16a ); - return CPU_DISASSEMBLE_NAME(dsp16a)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(dsp16a)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/dsp16/dsp16.h b/src/devices/cpu/dsp16/dsp16.h index 1a558f1f18a..e138edae5b4 100644 --- a/src/devices/cpu/dsp16/dsp16.h +++ b/src/devices/cpu/dsp16/dsp16.h @@ -51,7 +51,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // address spaces const address_space_config m_program_config; diff --git a/src/devices/cpu/dsp16/dsp16dis.cpp b/src/devices/cpu/dsp16/dsp16dis.cpp index 52b76fee297..c1166dd105f 100644 --- a/src/devices/cpu/dsp16/dsp16dis.cpp +++ b/src/devices/cpu/dsp16/dsp16dis.cpp @@ -248,7 +248,7 @@ bool disasmSIField(const uint8_t& SI) } -static offs_t internal_disasm_dsp16a(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(dsp16a) { uint8_t opSize = 1; uint32_t dasmflags = 0; @@ -584,13 +584,3 @@ static offs_t internal_disasm_dsp16a(cpu_device *device, std::ostream &stream, o return opSize | dasmflags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(dsp16a) -{ - std::ostringstream stream; - offs_t result = internal_disasm_dsp16a(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/dsp16/dsp16ops.hxx b/src/devices/cpu/dsp16/dsp16ops.hxx index 6893819f754..ab54a577fef 100644 --- a/src/devices/cpu/dsp16/dsp16ops.hxx +++ b/src/devices/cpu/dsp16/dsp16ops.hxx @@ -67,10 +67,10 @@ void dsp16_device::writeRegister(void* reg, const uint16_t &value) else if (reg == &m_psw) { // Writes to the a0 & a1 guard bits too - m_a0 &= U64(0x0ffffffff); - m_a0 |= U64(m_psw & 0x000f) << 32; - m_a1 &= U64(0x0ffffffff); - m_a1 |= U64(m_psw & 0x01e0) << 27; + m_a0 &= 0x0ffffffffU; + m_a0 |= u64(m_psw & 0x000fU) << 32; + m_a1 &= 0x0ffffffffU; + m_a1 |= u64(m_psw & 0x01e0U) << 27; m_psw = value; } else if (reg == &m_i) @@ -293,12 +293,12 @@ void dsp16_device::executeF1Field(const uint8_t& F1, const uint8_t& D, const uin { // aS-y int64_t aS = *sourceReg; - if (aS & U64(0x800000000)) - aS |= U64(0xfffffff000000000); + if (aS & 0x800000000U) + aS |= 0xfffffff000000000U; int64_t y = (m_y & 0xffff0000) >> 16; if (y & 0x8000) - y |= U64(0xffffffffffff0000); + y |= 0xffffffffffff0000U; result = aS-y; justATest = true; @@ -314,12 +314,12 @@ void dsp16_device::executeF1Field(const uint8_t& F1, const uint8_t& D, const uin { // Ad = aS+y int64_t aS = *sourceReg; - if (aS & U64(0x800000000)) - aS |= U64(0xfffffff000000000); + if (aS & 0x800000000U) + aS |= 0xfffffff000000000U; int64_t y = (m_y & 0xffff0000) >> 16; if (y & 0x8000) - y |= U64(0xffffffffffff0000); + y |= 0xffffffffffff0000U; result = aS+y; break; @@ -334,12 +334,12 @@ void dsp16_device::executeF1Field(const uint8_t& F1, const uint8_t& D, const uin { // Ad = aS-y int64_t aS = *sourceReg; - if (aS & U64(0x800000000)) - aS |= U64(0xfffffff000000000); + if (aS & 0x800000000U) + aS |= 0xfffffff000000000U; int64_t y = (m_y & 0xffff0000) >> 16; if (y & 0x8000) - y |= U64(0xffffffffffff0000); + y |= 0xffffffffffff0000U; result = aS-y; break; @@ -348,13 +348,13 @@ void dsp16_device::executeF1Field(const uint8_t& F1, const uint8_t& D, const uin // CPU Flags (page 3-4) // LMI (logical minus) - if (result & U64(0x800000000)) + if (result & 0x800000000U) m_psw |= 0x8000; else m_psw &= (~0x8000); // LEQ (logical equal) - if (result == U64(0x000000000)) + if (result == 0x000000000U) m_psw |= 0x4000; else m_psw &= (~0x4000); @@ -363,15 +363,15 @@ void dsp16_device::executeF1Field(const uint8_t& F1, const uint8_t& D, const uin // TODO // LMV (mathematical overflow) - if ((result & U64(0xf00000000)) != U64(0xf00000000) && - (result & U64(0xf00000000)) != U64(0x000000000)) + if ((result & 0xf00000000U) != 0xf00000000U && + (result & 0xf00000000U) != 0x000000000U) m_psw |= 0x1000; else m_psw &= (~0x1000); // If it was a real operation, make sure the data goes where it should if (!justATest) - *destinationReg = (uint64_t)result & U64(0x0000000fffffffff); + *destinationReg = (uint64_t)result & 0x0000000fffffffffU; } @@ -471,11 +471,11 @@ void dsp16_device::execute_one(const uint16_t& op, uint8_t& cycles, uint8_t& pcA uint16_t aRegValue = 0x0000; if (op & 0xc000) { - aRegValue = (m_a0 & U64(0x0ffff0000)) >> 16; + aRegValue = (m_a0 & 0x0ffff0000U) >> 16; } else { - aRegValue = (m_a1 & U64(0x0ffff0000)) >> 16; + aRegValue = (m_a1 & 0x0ffff0000U) >> 16; } data_write(*destinationReg, aRegValue); executeYFieldPost(Y); @@ -614,7 +614,7 @@ void dsp16_device::execute_one(const uint16_t& op, uint8_t& cycles, uint8_t& pcA } uint16_t sourceAddress = *(registerFromYFieldUpper(Y)); int64_t sourceValueSigned = (int16_t)data_read(sourceAddress); - *destinationReg = sourceValueSigned & U64(0xffffffffff); + *destinationReg = sourceValueSigned & 0xffffffffffU; executeYFieldPost(Y); cycles = 1; pcAdvance = 1; @@ -771,7 +771,7 @@ void dsp16_device::execute_one(const uint16_t& op, uint8_t& cycles, uint8_t& pcA const uint8_t S = (op & 0x1000) >> 12; void* destinationReg = registerFromRTable(R); uint64_t* sourceReg = (S) ? &m_a1 : &m_a0; - uint16_t sourceValue = (*sourceReg & U64(0x0ffff0000)) >> 16; + uint16_t sourceValue = (*sourceReg & 0x0ffff0000U) >> 16; writeRegister(destinationReg, sourceValue); cycles = 2; pcAdvance = 1; @@ -791,10 +791,10 @@ void dsp16_device::execute_one(const uint16_t& op, uint8_t& cycles, uint8_t& pcA default: break; } void* sourceReg = registerFromRTable(R); - *destinationReg &= U64(0x00000ffff); + *destinationReg &= 0x00000ffffU; *destinationReg |= (*(uint16_t*)sourceReg) << 16; // TODO: Fix for all registers if (*(uint16_t*)sourceReg & 0x8000) - *destinationReg |= U64(0xf00000000); + *destinationReg |= 0xf00000000U; // TODO: Special function encoding cycles = 2; pcAdvance = 1; diff --git a/src/devices/cpu/dsp32/dsp32.cpp b/src/devices/cpu/dsp32/dsp32.cpp index 2f0d8d2eeab..ca4a757ee41 100644 --- a/src/devices/cpu/dsp32/dsp32.cpp +++ b/src/devices/cpu/dsp32/dsp32.cpp @@ -421,10 +421,10 @@ uint32_t dsp32c_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t dsp32c_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t dsp32c_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( dsp32c ); - return CPU_DISASSEMBLE_NAME(dsp32c)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(dsp32c)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/dsp32/dsp32.h b/src/devices/cpu/dsp32/dsp32.h index 62a56ef4a0a..4b39600284a 100644 --- a/src/devices/cpu/dsp32/dsp32.h +++ b/src/devices/cpu/dsp32/dsp32.h @@ -128,7 +128,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // memory accessors uint32_t ROPCODE(offs_t pc); diff --git a/src/devices/cpu/dsp32/dsp32dis.cpp b/src/devices/cpu/dsp32/dsp32dis.cpp index d893b412f44..aaf9dc63abb 100644 --- a/src/devices/cpu/dsp32/dsp32dis.cpp +++ b/src/devices/cpu/dsp32/dsp32dis.cpp @@ -694,21 +694,11 @@ static unsigned dasm_dsp32(std::ostream &stream, unsigned pc, uint32_t op) } -static unsigned dasm_dsp32(char *buffer, unsigned pc, uint32_t op) -{ - std::ostringstream stream; - unsigned result = dasm_dsp32(stream, pc, op); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - - /*************************************************************************** DISASSEMBLY HOOK ***************************************************************************/ CPU_DISASSEMBLE( dsp32c ) { - return dasm_dsp32(buffer, pc, oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24)); + return dasm_dsp32(stream, pc, oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24)); } diff --git a/src/devices/cpu/dsp56k/dsp56dsm.cpp b/src/devices/cpu/dsp56k/dsp56dsm.cpp index 27d80cbfc77..133cfc40509 100644 --- a/src/devices/cpu/dsp56k/dsp56dsm.cpp +++ b/src/devices/cpu/dsp56k/dsp56dsm.cpp @@ -16,7 +16,7 @@ /*****************************/ /* Main disassembly function */ /*****************************/ -static offs_t internal_disasm_dsp56k(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(dsp56k) { const uint16_t w0 = oprom[0] | (oprom[1] << 8); const uint16_t w1 = oprom[2] | (oprom[3] << 8); @@ -28,13 +28,3 @@ static offs_t internal_disasm_dsp56k(cpu_device *device, std::ostream &stream, o const unsigned size = op.size(); return (size | DASMFLAG_SUPPORTED); } - - -CPU_DISASSEMBLE(dsp56k) -{ - std::ostringstream stream; - offs_t result = internal_disasm_dsp56k(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/dsp56k/dsp56k.cpp b/src/devices/cpu/dsp56k/dsp56k.cpp index 1442aa8254d..a4ace1425a8 100644 --- a/src/devices/cpu/dsp56k/dsp56k.cpp +++ b/src/devices/cpu/dsp56k/dsp56k.cpp @@ -293,8 +293,8 @@ void dsp56k_device::device_start() state_add(DSP56K_X, "X", m_dsp56k_core.ALU.x.d).mask(0xffffffff).formatstr("%9s"); state_add(DSP56K_Y, "Y", m_dsp56k_core.ALU.y.d).mask(0xffffffff).formatstr("%9s"); - state_add(DSP56K_A, "A", m_dsp56k_core.ALU.a.q).mask((uint64_t)U64(0xffffffffffffffff)).formatstr("%12s"); /* could benefit from a better mask? */ - state_add(DSP56K_B, "B", m_dsp56k_core.ALU.b.q).mask((uint64_t)U64(0xffffffffffffffff)).formatstr("%12s"); /* could benefit from a better mask? */ + state_add(DSP56K_A, "A", m_dsp56k_core.ALU.a.q).mask(u64(0xffffffffffffffffU)).formatstr("%12s"); /* could benefit from a better mask? */ + state_add(DSP56K_B, "B", m_dsp56k_core.ALU.b.q).mask(u64(0xffffffffffffffffU)).formatstr("%12s"); /* could benefit from a better mask? */ state_add(DSP56K_R0, "R0", m_dsp56k_core.AGU.r0).formatstr("%04X"); state_add(DSP56K_R1, "R1", m_dsp56k_core.AGU.r1).formatstr("%04X"); @@ -494,8 +494,8 @@ void dsp56k_device::execute_run() } -offs_t dsp56k_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t dsp56k_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( dsp56k ); - return CPU_DISASSEMBLE_NAME(dsp56k)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(dsp56k)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/dsp56k/dsp56k.h b/src/devices/cpu/dsp56k/dsp56k.h index 419800a3265..443dd811508 100644 --- a/src/devices/cpu/dsp56k/dsp56k.h +++ b/src/devices/cpu/dsp56k/dsp56k.h @@ -236,7 +236,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/dsp56k/dsp56ops.hxx b/src/devices/cpu/dsp56k/dsp56ops.hxx index 0395e08d337..0c898e7c674 100644 --- a/src/devices/cpu/dsp56k/dsp56ops.hxx +++ b/src/devices/cpu/dsp56k/dsp56ops.hxx @@ -344,7 +344,7 @@ static void execute_one(dsp56k_core* cpustate) int parallelType = -1; uint16_t op_byte = 0x0000; typed_pointer d_register = {nullptr, DT_BYTE}; - uint64_t prev_accum_value = U64(0x0000000000000000); + uint64_t prev_accum_value = 0x0000000000000000U; /* Note: it's important that NPDM comes before RtRDM here */ /* No Parallel Data Move : 0100 1010 .... .... : A-131 */ @@ -1142,8 +1142,8 @@ static size_t dsp56k_op_addsub_2(dsp56k_core* cpustate, const uint16_t op_byte, } /* Sign-extend word for proper add/sub op */ - if ((S.data_type == DT_WORD) && useVal & U64(0x0000000080000000)) - useVal |= U64(0x000000ff00000000); + if ((S.data_type == DT_WORD) && (useVal & 0x0000000080000000U)) + useVal |= 0x000000ff00000000U; /* Operate*/ if (op_type == OP_ADD) @@ -1157,8 +1157,8 @@ static size_t dsp56k_op_addsub_2(dsp56k_core* cpustate, const uint16_t op_byte, /* S L E U N Z V C */ /* * * * * * * * * */ /* TODO S, L, E, U, V, C */ - if (*((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if (*((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; /* TODO: + mv oscillator cycles */ return 1; @@ -1188,16 +1188,16 @@ static size_t dsp56k_op_mac_1(dsp56k_core* cpustate, const uint16_t op_byte, typ /* Sign extend D into a temp variable */ opD = (*((uint64_t*)D)); - if (opD & U64(0x0000008000000000)) - opD |= U64(0xffffff0000000000); + if (opD & 0x0000008000000000U) + opD |= 0xffffff0000000000U; else - opD &= U64(0x000000ffffffffff); + opD &= 0x000000ffffffffffU; /* Accumulate */ opD += result; /* And out the bits that don't live in the register */ - opD &= U64(0x000000ffffffffff); + opD &= 0x000000ffffffffffU; (*((uint64_t*)D)) = (uint64_t)opD; @@ -1208,8 +1208,8 @@ static size_t dsp56k_op_mac_1(dsp56k_core* cpustate, const uint16_t op_byte, typ /* S L E U N Z V C */ /* * * * * * * * - */ /* TODO: S, L, E, V */ - if ( *((uint64_t*)D) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D) & U64(0x000000ffffffffff)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D) & 0x000000ffffffffffU) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; /* TODO: +mv oscillator cycles */ return 1; @@ -1253,7 +1253,7 @@ static size_t dsp56k_op_mpy_1(dsp56k_core* cpustate, const uint16_t op_byte, typ result = (s1 * s2) << 1; /* And out the bits that don't live in the register */ - (*((uint64_t*)D)) = result & U64(0x000000ffffffffff); + (*((uint64_t*)D)) = result & 0x000000ffffffffffU; /* For the parallel move */ d_register->addr = D; @@ -1262,8 +1262,8 @@ static size_t dsp56k_op_mpy_1(dsp56k_core* cpustate, const uint16_t op_byte, typ /* S L E U N Z V C */ /* * * * * * * * - */ /* TODO: S, L, E, V */ - if ( *((uint64_t*)D) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D) & U64(0x000000ffffffffff)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D) & 0x000000ffffffffffU) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; /* TODO: +mv oscillator cycles */ return 1; @@ -1306,7 +1306,7 @@ static size_t dsp56k_op_clr(dsp56k_core* cpustate, const uint16_t op_byte, typed { typed_pointer D = {nullptr, DT_LONG_WORD}; typed_pointer clear = {nullptr, DT_LONG_WORD}; - uint64_t clear_val = U64(0x0000000000000000); + uint64_t clear_val = 0x0000000000000000U; decode_F_table(cpustate, BITS(op_byte,0x0008), &D); @@ -1351,8 +1351,8 @@ static size_t dsp56k_op_add(dsp56k_core* cpustate, const uint16_t op_byte, typed } /* Sign-extend word for proper add/sub op */ - if ((S.data_type == DT_WORD) && addVal & U64(0x0000000080000000)) - addVal |= U64(0x000000ff00000000); + if ((S.data_type == DT_WORD) && (addVal & 0x0000000080000000U)) + addVal |= 0x000000ff00000000U; /* Operate*/ *((uint64_t*)D.addr) += addVal; @@ -1363,8 +1363,8 @@ static size_t dsp56k_op_add(dsp56k_core* cpustate, const uint16_t op_byte, typed /* S L E U N Z V C */ /* * * * * * * * * */ /* TODO S, L, E, U, V, C */ - if (*((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if (*((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; /* TODO: + mv oscillator cycles */ return 1; @@ -1418,10 +1418,10 @@ static size_t dsp56k_op_rnd(dsp56k_core* cpustate, const uint16_t op_byte, typed *p_accum = *((uint64_t*)D.addr); /* WARNING : ROUNDING NOT FULLY IMPLEMENTED YET! */ - if ((*((uint64_t*)D.addr) & U64(0x000000000000ffff)) >= 0x8000) - *((uint64_t*)D.addr) += U64(0x0000000000010000); + if ((*((uint64_t*)D.addr) & 0x000000000000ffffU) >= 0x8000) + *((uint64_t*)D.addr) += 0x0000000000010000U; - *((uint64_t*)D.addr) = *((uint64_t*)D.addr) & U64(0x000000ffffff0000); + *((uint64_t*)D.addr) = *((uint64_t*)D.addr) & 0x000000ffffff0000U; d_register->addr = D.addr; d_register->data_type = D.data_type; @@ -1429,8 +1429,8 @@ static size_t dsp56k_op_rnd(dsp56k_core* cpustate, const uint16_t op_byte, typed /* S L E U N Z V C */ /* * * * * * * * - */ /* TODO: S, L, E, U, V */ - if ((*((uint64_t*)D.addr)) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D.addr)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ((*((uint64_t*)D.addr)) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D.addr)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; /* TODO: + mv oscillator clock cycles */ return 1; @@ -1451,8 +1451,8 @@ static size_t dsp56k_op_tst(dsp56k_core* cpustate, const uint16_t op_byte, typed /* S L E U N Z V C */ /* 0 * * * * * 0 0 */ /* TODO: S, L, E, U */ - if ((*((uint64_t*)D.addr)) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D.addr)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ((*((uint64_t*)D.addr)) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D.addr)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); DSP56K_V_CLEAR(); DSP56K_C_CLEAR(); @@ -1470,7 +1470,7 @@ static size_t dsp56k_op_inc(dsp56k_core* cpustate, const uint16_t op_byte, typed *p_accum = *((uint64_t*)D.addr); /* Make sure the destination is a real 40-bit value */ - *((uint64_t*)D.addr) &= U64(0x000000ffffffffff); + *((uint64_t*)D.addr) &= 0x000000ffffffffffU; /* Increment */ *((uint64_t*)D.addr) = *((uint64_t*)D.addr) + 1; @@ -1481,10 +1481,10 @@ static size_t dsp56k_op_inc(dsp56k_core* cpustate, const uint16_t op_byte, typed /* S L E U N Z V C */ /* * * * * * * * * */ /* TODO: S, L, E, U */ - if ( *((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0x000000ffffff0000)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0xffffff0000000000)) != 0) DSP56K_V_SET(); else DSP56K_V_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0xffffff0000000000)) != 0) DSP56K_C_SET(); else DSP56K_C_CLEAR(); + if ( *((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D.addr) & 0x000000ffffff0000U) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ((*((uint64_t*)D.addr) & 0xffffff0000000000U) != 0) DSP56K_V_SET(); else DSP56K_V_CLEAR(); + if ((*((uint64_t*)D.addr) & 0xffffff0000000000U) != 0) DSP56K_C_SET(); else DSP56K_C_CLEAR(); cycles += 2; /* TODO: +mv oscillator cycles */ return 1; @@ -1502,12 +1502,12 @@ static size_t dsp56k_op_inc24(dsp56k_core* cpustate, const uint16_t op_byte, typ *p_accum = *((uint64_t*)D.addr); /* TODO: I wonder if workBits24 should be signed? */ - workBits24 = ((*((uint64_t*)D.addr)) & U64(0x000000ffffff0000)) >> 16; + workBits24 = ((*((uint64_t*)D.addr)) & 0x000000ffffff0000U) >> 16; workBits24++; //workBits24 &= 0x00ffffff; /* Solves -x issues - TODO: huh? */ /* Set the D bits with the dec result */ - *((uint64_t*)D.addr) &= U64(0x000000000000ffff); + *((uint64_t*)D.addr) &= 0x000000000000ffffU; *((uint64_t*)D.addr) |= (((uint64_t)(workBits24)) << 16); d_register->addr = D.addr; @@ -1516,8 +1516,8 @@ static size_t dsp56k_op_inc24(dsp56k_core* cpustate, const uint16_t op_byte, typ /* S L E U N Z V C */ /* * * * * * ? * * */ /* TODO: S, L, E, U */ - if ( *((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0x000000ffffff0000)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D.addr) & 0x000000ffffff0000U) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); if ((workBits24 & 0xff000000) != 0) DSP56K_V_SET(); else DSP56K_V_CLEAR(); if ((workBits24 & 0xff000000) != 0) DSP56K_C_SET(); else DSP56K_C_CLEAR(); @@ -1545,8 +1545,8 @@ static size_t dsp56k_op_or(dsp56k_core* cpustate, const uint16_t op_byte, typed_ /* S L E U N Z V C */ /* * * - - ? ? 0 - */ /* TODO: S, L */ - if ( *((uint64_t*)D.addr) & U64(0x0000000080000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0x00000000ffff0000)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D.addr) & 0x0000000080000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D.addr) & 0x00000000ffff0000U) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); DSP56K_V_CLEAR(); cycles += 2; /* TODO: + mv oscillator cycles */ @@ -1564,10 +1564,10 @@ static size_t dsp56k_op_asr(dsp56k_core* cpustate, const uint16_t op_byte, typed *((uint64_t*)D.addr) = (*((uint64_t*)D.addr)) >> 1; /* Make sure the MSB is maintained */ - if (*p_accum & U64(0x0000008000000000)) - *((uint64_t*)D.addr) |= U64(0x0000008000000000); + if (*p_accum & 0x0000008000000000U) + *((uint64_t*)D.addr) |= 0x0000008000000000U; else - *((uint64_t*)D.addr) &= (~U64(0x0000008000000000)); + *((uint64_t*)D.addr) &= (~u64(0x0000008000000000U)); /* For the parallel move */ d_register->addr = D.addr; @@ -1576,10 +1576,10 @@ static size_t dsp56k_op_asr(dsp56k_core* cpustate, const uint16_t op_byte, typed /* S L E U N Z V C */ /* * * * * * * 0 ? */ /* TODO: S, L, E, U */ - if (*((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if (*((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); DSP56K_V_CLEAR(); - if (*p_accum & U64(0x0000000000000001)) DSP56K_C_SET(); else DSP56K_C_CLEAR(); + if (*p_accum & 0x0000000000000001U) DSP56K_C_SET(); else DSP56K_C_CLEAR(); cycles += 2; /* TODO: + mv oscillator cycles */ return 1; @@ -1617,9 +1617,9 @@ static size_t dsp56k_op_lsr(dsp56k_core* cpustate, const uint16_t op_byte, typed /* * * - - ? ? 0 ? */ /* TODO: S, L */ DSP56K_N_CLEAR(); - if (((PAIR64*)D.addr)->w.h == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if (((PAIR64*)D.addr)->w.h == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); DSP56K_V_CLEAR(); - if (*p_accum & U64(0x0000000000010000)) DSP56K_C_SET(); else DSP56K_C_CLEAR(); + if (*p_accum & 0x0000000000010000U) DSP56K_C_SET(); else DSP56K_C_CLEAR(); cycles += 2; /* TODO: + mv oscillator cycles */ return 1; @@ -1674,12 +1674,12 @@ static size_t dsp56k_op_sub(dsp56k_core* cpustate, const uint16_t op_byte, typed } /* Sign-extend word for proper sub op */ - if ((S.data_type == DT_WORD) && useVal & U64(0x0000000080000000)) - useVal |= U64(0x000000ff00000000); + if ((S.data_type == DT_WORD) && useVal & 0x0000000080000000U) + useVal |= 0x000000ff00000000U; /* Make sure they're both real 40-bit values */ - useVal &= U64(0x000000ffffffffff); - *((uint64_t*)D.addr) &= U64(0x000000ffffffffff); + useVal &= 0x000000ffffffffffU; + *((uint64_t*)D.addr) &= 0x000000ffffffffffU; /* Operate*/ *((uint64_t*)D.addr) -= useVal; @@ -1690,10 +1690,10 @@ static size_t dsp56k_op_sub(dsp56k_core* cpustate, const uint16_t op_byte, typed /* S L E U N Z V C */ /* * * * * * * * * */ /* TODO S, L, E, U */ - if ( *((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ( *((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0xffffff0000000000)) != 0) DSP56K_V_SET(); else DSP56K_V_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0xffffff0000000000)) != 0) DSP56K_C_SET(); else DSP56K_C_CLEAR(); + if ( *((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ( *((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ((*((uint64_t*)D.addr) & 0xffffff0000000000U) != 0) DSP56K_V_SET(); else DSP56K_V_CLEAR(); + if ((*((uint64_t*)D.addr) & 0xffffff0000000000U) != 0) DSP56K_C_SET(); else DSP56K_C_CLEAR(); cycles += 2; /* TODO: + mv oscillator cycles */ return 1; @@ -1737,12 +1737,12 @@ static size_t dsp56k_op_cmp(dsp56k_core* cpustate, const uint16_t op_byte, typed } /* Sign-extend word for proper subtraction op */ - if ((S.data_type == DT_WORD) && cmpVal & U64(0x0000000080000000)) - cmpVal |= U64(0x000000ff00000000); + if ((S.data_type == DT_WORD) && cmpVal & 0x0000000080000000U) + cmpVal |= 0x000000ff00000000U; /* Make sure they're both real 40-bit values */ - cmpVal &= U64(0x000000ffffffffff); - *((uint64_t*)D.addr) &= U64(0x000000ffffffffff); + cmpVal &= 0x000000ffffffffffU; + *((uint64_t*)D.addr) &= 0x000000ffffffffffU; /* Operate */ result = *((uint64_t*)D.addr) - cmpVal; @@ -1753,10 +1753,10 @@ static size_t dsp56k_op_cmp(dsp56k_core* cpustate, const uint16_t op_byte, typed /* S L E U N Z V C */ /* * * * * * * * * */ /* TODO: S, L, E, U */ - if ( result & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ( result & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); if ( result == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); - if ((result & U64(0xffffff0000000000)) != 0) DSP56K_V_SET(); else DSP56K_V_CLEAR(); - if ((result & U64(0xffffff0000000000)) != 0) DSP56K_C_SET(); else DSP56K_C_CLEAR(); + if ((result & 0xffffff0000000000U) != 0) DSP56K_V_SET(); else DSP56K_V_CLEAR(); + if ((result & 0xffffff0000000000U) != 0) DSP56K_C_SET(); else DSP56K_C_CLEAR(); cycles += 2; /* TODO: + mv oscillator clock cycles */ @@ -1788,8 +1788,8 @@ static size_t dsp56k_op_not(dsp56k_core* cpustate, const uint16_t op_byte, typed /* S L E U N Z V C */ /* * * - - ? ? 0 - */ /* TODO: S?, L */ - if ( *((uint64_t*)D.addr) & U64(0x0000000080000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0x00000000ffff0000)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D.addr) & 0x0000000080000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D.addr) & 0x00000000ffff0000U) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); DSP56K_V_CLEAR(); cycles += 2; /* TODO: + mv oscillator cycles */ @@ -1816,12 +1816,12 @@ static size_t dsp56k_op_dec24(dsp56k_core* cpustate, const uint16_t op_byte, typ *p_accum = *((uint64_t*)D.addr); /* TODO: I wonder if workBits24 should be signed? */ - workBits24 = ((*((uint64_t*)D.addr)) & U64(0x000000ffffff0000)) >> 16; + workBits24 = ((*((uint64_t*)D.addr)) & 0x000000ffffff0000U) >> 16; workBits24--; workBits24 &= 0x00ffffff; /* Solves -x issues */ /* Set the D bits with the dec result */ - *((uint64_t*)D.addr) &= U64(0x000000000000ffff); + *((uint64_t*)D.addr) &= 0x000000000000ffffU; *((uint64_t*)D.addr) |= (((uint64_t)(workBits24)) << 16); d_register->addr = D.addr; @@ -1830,8 +1830,8 @@ static size_t dsp56k_op_dec24(dsp56k_core* cpustate, const uint16_t op_byte, typ /* S L E U N Z V C */ /* * * * * * ? * * */ /* TODO: S, L, E, U, V, C */ - if ( *((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0x000000ffffff0000)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D.addr) & 0x000000ffffff0000U) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; /* TODO: + mv oscillator clock cycles */ return 1; @@ -1857,8 +1857,8 @@ static size_t dsp56k_op_and(dsp56k_core* cpustate, const uint16_t op_byte, typed /* S L E U N Z V C */ /* * * - - ? ? 0 - */ /* TODO: S, L */ - if ( *((uint64_t*)D.addr) & U64(0x0000000080000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0x00000000ffff0000)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D.addr) & 0x0000000080000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D.addr) & 0x00000000ffff0000U) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); DSP56K_V_CLEAR(); cycles += 2; /* TODO: + mv oscillator cycles */ @@ -1877,28 +1877,28 @@ static size_t dsp56k_op_abs(dsp56k_core* cpustate, const uint16_t op_byte, typed /* Sign extend D into a temp variable */ opD = *p_accum; - if (opD & U64(0x0000008000000000)) - opD |= U64(0xffffff0000000000); + if (opD & 0x0000008000000000U) + opD |= 0xffffff0000000000U; else - opD &= U64(0x000000ffffffffff); + opD &= 0x000000ffffffffffU; /* Take the absolute value and clean up */ opD = (opD < 0) ? -opD : opD; - opD &= U64(0x000000ffffffffff); + opD &= 0x000000ffffffffffU; /* Reassign */ *((uint64_t*)D.addr) = opD; /* Special overflow case */ - if ((*p_accum) == U64(0x0000008000000000)) - *((uint64_t*)D.addr) = U64(0x0000007fffffffff); + if ((*p_accum) == 0x0000008000000000U) + *((uint64_t*)D.addr) = 0x0000007fffffffffU; /* S L E U N Z V C */ /* * * * * * * * - */ /* TODO: S, L, E, U */ - if ( *((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D.addr) & U64(0x000000ffffffffff)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); - if ((*p_accum) == U64(0x0000008000000000)) DSP56K_V_SET(); else DSP56K_V_CLEAR(); + if ( *((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D.addr) & 0x000000ffffffffffU) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ((*p_accum) == 0x0000008000000000U) DSP56K_V_SET(); else DSP56K_V_CLEAR(); cycles += 2; /* TODO: + mv oscillator clock cycles */ return 1; @@ -1944,14 +1944,14 @@ static size_t dsp56k_op_cmpm(dsp56k_core* cpustate, const uint16_t op_byte, type if (S.addr == &A || S.addr == &B) { absS = *((uint64_t*)S.addr); - if (absS & U64(0x0000008000000000)) - absS |= U64(0xffffff8000000000); + if (absS & 0x0000008000000000U) + absS |= 0xffffff8000000000U; } else { absS = (*((uint16_t*)S.addr)) << 16; - if (absS & U64(0x0000000080000000)) - absS |= U64(0xffffffff80000000); + if (absS & 0x0000000080000000U) + absS |= 0xffffffff80000000U; } absS = (absS < 0) ? -absS : absS; @@ -1959,14 +1959,14 @@ static size_t dsp56k_op_cmpm(dsp56k_core* cpustate, const uint16_t op_byte, type if (D.addr == &A || D.addr == &B) { absD = *((uint64_t*)D.addr); - if (absD & U64(0x0000008000000000)) - absD |= U64(0xffffff8000000000); + if (absD & 0x0000008000000000U) + absD |= 0xffffff8000000000U; } else { absD = (*((uint16_t*)D.addr)) << 16; - if (absS & U64(0x0000000080000000)) - absS |= U64(0xffffffff80000000); + if (absS & 0x0000000080000000U) + absS |= 0xffffffff80000000U; } absD = (absD < 0) ? -absD : absD; @@ -1979,10 +1979,10 @@ static size_t dsp56k_op_cmpm(dsp56k_core* cpustate, const uint16_t op_byte, type /* S L E U N Z V C */ /* * * * * * * * * */ /* TODO: S, L, E, U */ - if ( (absResult) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if (((absResult) & U64(0x000000ffffffffff)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); - if ( (absResult & U64(0xffffff0000000000)) != 0) DSP56K_V_SET(); else DSP56K_V_CLEAR(); - if ( (absResult & U64(0xffffff0000000000)) != 0) DSP56K_C_SET(); else DSP56K_C_CLEAR(); + if ( (absResult) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if (((absResult) & 0x000000ffffffffffU) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( (absResult & 0xffffff0000000000U) != 0) DSP56K_V_SET(); else DSP56K_V_CLEAR(); + if ( (absResult & 0xffffff0000000000U) != 0) DSP56K_C_SET(); else DSP56K_C_CLEAR(); cycles += 2; /* TODO: +mv oscillator cycles */ return 1; @@ -2016,13 +2016,13 @@ static size_t dsp56k_op_mpy(dsp56k_core* cpustate, const uint16_t op_byte, typed if (k) result *= -1; - (*((uint64_t*)D)) = result & U64(0x000000ffffffffff); + (*((uint64_t*)D)) = result & 0x000000ffffffffffU; /* S L E U N Z V C */ /* * * * * * * * - */ /* TODO: S, L, E, V */ - if ( *((uint64_t*)D) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D) & U64(0x000000ffffffffff)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D) & 0x000000ffffffffffU) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; /* TODO: +mv oscillator cycles */ return 1; @@ -2063,10 +2063,10 @@ static size_t dsp56k_op_mac(dsp56k_core* cpustate, const uint16_t op_byte, typed /* Sign extend D into a temp variable */ opD = (*((uint64_t*)D)); - if (opD & U64(0x0000008000000000)) - opD |= U64(0xffffff0000000000); + if (opD & 0x0000008000000000U) + opD |= 0xffffff0000000000U; else - opD &= U64(0x000000ffffffffff); + opD &= 0x000000ffffffffffU; /* Negate if necessary */ if (k) @@ -2076,7 +2076,7 @@ static size_t dsp56k_op_mac(dsp56k_core* cpustate, const uint16_t op_byte, typed opD += result; /* And out the bits that don't live in the register */ - opD &= U64(0x000000ffffffffff); + opD &= 0x000000ffffffffffU; (*((uint64_t*)D)) = (uint64_t)opD; @@ -2087,8 +2087,8 @@ static size_t dsp56k_op_mac(dsp56k_core* cpustate, const uint16_t op_byte, typed /* S L E U N Z V C */ /* * * * * * * * - */ /* TODO: S, L, E, V */ - if ( *((uint64_t*)D) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D) & U64(0x000000ffffffffff)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D) & 0x000000ffffffffffU) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; /* TODO: +mv oscillator cycles */ return 1; @@ -2121,10 +2121,10 @@ static size_t dsp56k_op_macr(dsp56k_core* cpustate, const uint16_t op_byte, type /* Sign extend D into a temp variable */ opD = (*((uint64_t*)D)); - if (opD & U64(0x0000008000000000)) - opD |= U64(0xffffff0000000000); + if (opD & 0x0000008000000000U) + opD |= 0xffffff0000000000U; else - opD &= U64(0x000000ffffffffff); + opD &= 0x000000ffffffffffU; /* Negate if necessary */ if (k) @@ -2135,13 +2135,13 @@ static size_t dsp56k_op_macr(dsp56k_core* cpustate, const uint16_t op_byte, type /* Round the result */ /* WARNING : ROUNDING NOT FULLY IMPLEMENTED YET! */ - if ((opD & U64(0x000000000000ffff)) >= 0x8000) - opD += U64(0x0000000000010000); + if ((opD & 0x000000000000ffffU) >= 0x8000) + opD += 0x0000000000010000U; - opD &= U64(0x000000ffffff0000); + opD &= 0x000000ffffff0000U; /* And out the bits that don't live in the register */ - opD &= U64(0x000000ffffffffff); + opD &= 0x000000ffffffffffU; /* Store the result */ (*((uint64_t*)D)) = (uint64_t)opD; @@ -2153,8 +2153,8 @@ static size_t dsp56k_op_macr(dsp56k_core* cpustate, const uint16_t op_byte, type /* S L E U N Z V C */ /* * * * * * * * - */ /* TODO: S, L, E, V */ - if ( *((uint64_t*)D) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D) & U64(0x000000ffffffffff)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D) & 0x000000ffffffffffU) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; /* TODO: +mv oscillator cycles */ return 1; @@ -2215,7 +2215,7 @@ static size_t dsp56k_op_asl4(dsp56k_core* cpustate, const uint16_t op, uint8_t* p_accum = *((uint64_t*)D.addr); *((uint64_t*)D.addr) = (*((uint64_t*)D.addr)) << 4; - *((uint64_t*)D.addr) = (*((uint64_t*)D.addr)) & U64(0x000000ffffffffff); + *((uint64_t*)D.addr) = (*((uint64_t*)D.addr)) & 0x000000ffffffffffU; /* S L E U N Z V C */ /* - ? * * * * ? ? */ @@ -2223,10 +2223,10 @@ static size_t dsp56k_op_asl4(dsp56k_core* cpustate, const uint16_t op, uint8_t* /* V - Set if an arithmetic overflow occurs in the 40 bit result. Also set if bit 35 through 39 are not the same. */ /* C - Set if bit 36 of source operand is set. Cleared otherwise. */ - if (*((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); - if ( (*((uint64_t*)D.addr) & U64(0x000000ff00000000)) != (p_accum & U64(0x000000ff00000000)) ) DSP56K_V_SET(); else DSP56K_V_CLEAR(); - if (p_accum & U64(0x0000001000000000)) DSP56K_C_SET(); else DSP56K_C_CLEAR(); + if (*((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( (*((uint64_t*)D.addr) & 0x000000ff00000000U) != (p_accum & 0x000000ff00000000U) ) DSP56K_V_SET(); else DSP56K_V_CLEAR(); + if (p_accum & 0x0000001000000000U) DSP56K_C_SET(); else DSP56K_C_CLEAR(); cycles += 2; return 1; @@ -2242,22 +2242,22 @@ static size_t dsp56k_op_asr4(dsp56k_core* cpustate, const uint16_t op, uint8_t* p_accum = *((uint64_t*)D.addr); *((uint64_t*)D.addr) = (*((uint64_t*)D.addr)) >> 4; - *((uint64_t*)D.addr) = (*((uint64_t*)D.addr)) & U64(0x000000ffffffffff); + *((uint64_t*)D.addr) = (*((uint64_t*)D.addr)) & 0x000000ffffffffffU; /* The top 4 bits become the old bit 39 */ - if (p_accum & U64(0x0000008000000000)) - *((uint64_t*)D.addr) |= U64(0x000000f000000000); + if (p_accum & 0x0000008000000000U) + *((uint64_t*)D.addr) |= 0x000000f000000000U; else - *((uint64_t*)D.addr) &= (~U64(0x000000f000000000)); + *((uint64_t*)D.addr) &= (~u64(0x000000f000000000U)); /* S L E U N Z V C */ /* - * * * * * 0 ? */ /* TODO: E, U */ /* C - Set if bit 3 of source operand is set. Cleared otherwise. */ - if (*((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if (*((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); DSP56K_V_CLEAR(); - if (p_accum & U64(0x0000000000000008)) DSP56K_C_SET(); else DSP56K_C_CLEAR(); + if (p_accum & 0x0000000000000008U) DSP56K_C_SET(); else DSP56K_C_CLEAR(); cycles += 2; return 1; @@ -2275,18 +2275,18 @@ static size_t dsp56k_op_asr16(dsp56k_core* cpustate, const uint16_t op, uint8_t* *((uint64_t*)D.addr) = *((uint64_t*)D.addr) >> 16; - if(backupVal & U64(0x0000008000000000)) - *((uint64_t*)D.addr) |= U64(0x000000ffff000000); + if (backupVal & 0x0000008000000000U) + *((uint64_t*)D.addr) |= 0x000000ffff000000U; else - *((uint64_t*)D.addr) &= U64(0x0000000000ffffff); + *((uint64_t*)D.addr) &= 0x0000000000ffffffU; /* S L E U N Z V C */ /* - * * * * * 0 ? */ /* TODO: E, U */ - if (*((uint64_t*)D.addr) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if (*((uint64_t*)D.addr) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if (*((uint64_t*)D.addr) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); DSP56K_V_CLEAR(); - if (backupVal & U64(0x0000000000008000)) DSP56K_C_SET(); else DSP56K_C_CLEAR(); + if (backupVal & 0x0000000000008000U) DSP56K_C_SET(); else DSP56K_C_CLEAR(); cycles += 2; return 1; @@ -2774,8 +2774,8 @@ static size_t dsp56k_op_dmac(dsp56k_core* cpustate, const uint16_t op, uint8_t* /* S L E U N Z V C */ /* - * * * * * * - */ /* TODO: L, E, U, V */ - if ( *((uint64_t*)D) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D) & U64(0x000000ffffffffff)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D) & 0x000000ffffffffffU) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; return 1; @@ -2982,16 +2982,16 @@ static size_t dsp56k_op_imac(dsp56k_core* cpustate, const uint16_t op, uint8_t* /* Sign extend D into a temp variable */ opD = (*((uint64_t*)D)); - if (opD & U64(0x0000008000000000)) - opD |= U64(0xffffff0000000000); + if (opD & 0x0000008000000000U) + opD |= 0xffffff0000000000U; else - opD &= U64(0x000000ffffffffff); + opD &= 0x000000ffffffffffU; /* Accumulate */ opD += result; /* And out the bits that don't live in the register */ - opD &= U64(0x000000ffffffffff); + opD &= 0x000000ffffffffffU; (*((uint64_t*)D)) = (uint64_t)opD; @@ -2999,8 +2999,8 @@ static size_t dsp56k_op_imac(dsp56k_core* cpustate, const uint16_t op, uint8_t* /* - * ? ? * ? ? - */ /* TODO: L */ /* U,E - Will not be set correctly by this instruction*/ - if ( *((uint64_t*)D) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D) & U64(0x000000ffffff0000)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D) & 0x000000ffffff0000U) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); DSP56K_V_CLEAR(); cycles += 2; @@ -3231,13 +3231,13 @@ static size_t dsp56k_op_macsuuu(dsp56k_core* cpustate, const uint16_t op, uint8_ (*((uint64_t*)D)) += result; /* And out the bits that don't live in the register */ - (*((uint64_t*)D)) &= U64(0x000000ffffffffff); + (*((uint64_t*)D)) &= 0x000000ffffffffffU; /* S L E U N Z V C */ /* - * * * * * * - */ /* TODO: L, E, U, V */ - if ( *((uint64_t*)D) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D) & U64(0x000000ffffffffff)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D) & 0x000000ffffffffffU) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; return 1; @@ -3702,13 +3702,13 @@ static size_t dsp56k_op_mpysuuu(dsp56k_core* cpustate, const uint16_t op, uint8_ (*((uint64_t*)D)) = result; /* And out the bits that don't live in the register */ - (*((uint64_t*)D)) &= U64(0x000000ffffffffff); + (*((uint64_t*)D)) &= 0x000000ffffffffffU; /* S L E U N Z V C */ /* - * * * * * * - */ /* TODO: L, E, U, V */ - if ( *((uint64_t*)D) & U64(0x0000008000000000)) DSP56K_N_SET(); else DSP56K_N_CLEAR(); - if ((*((uint64_t*)D) & U64(0x000000ffffffffff)) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); + if ( *((uint64_t*)D) & 0x0000008000000000U) DSP56K_N_SET(); else DSP56K_N_CLEAR(); + if ((*((uint64_t*)D) & 0x000000ffffffffffU) == 0) DSP56K_Z_SET(); else DSP56K_Z_CLEAR(); cycles += 2; return 1; @@ -4828,7 +4828,7 @@ static void SetDestinationValue(typed_pointer source, typed_pointer dest) case DT_BYTE: *((uint8_t*)dest.addr) = (*((uint8_t*) source.addr)) & 0xff; break; case DT_WORD: *((uint8_t*)dest.addr) = (*((uint16_t*)source.addr)) & 0x00ff; break; case DT_DOUBLE_WORD: *((uint8_t*)dest.addr) = (*((uint32_t*)source.addr)) & 0x000000ff; break; - case DT_LONG_WORD: *((uint8_t*)dest.addr) = (*((uint64_t*)source.addr)) & U64(0x00000000000000ff); break; + case DT_LONG_WORD: *((uint8_t*)dest.addr) = (*((uint64_t*)source.addr)) & 0x00000000000000ffU; break; } break ; @@ -4839,7 +4839,7 @@ static void SetDestinationValue(typed_pointer source, typed_pointer dest) case DT_BYTE: *((uint16_t*)dest.addr) = (*((uint8_t*) source.addr)) & 0xff; break; case DT_WORD: *((uint16_t*)dest.addr) = (*((uint16_t*)source.addr)) & 0xffff; break; case DT_DOUBLE_WORD: *((uint16_t*)dest.addr) = (*((uint32_t*)source.addr)) & 0x0000ffff; break; - case DT_LONG_WORD: *((uint16_t*)dest.addr) = (*((uint64_t*)source.addr)) & U64(0x000000000000ffff); break; /* TODO: Shift limiter action! A-147 */ + case DT_LONG_WORD: *((uint16_t*)dest.addr) = (*((uint64_t*)source.addr)) & 0x000000000000ffffU; break; /* TODO: Shift limiter action! A-147 */ } break ; @@ -4850,7 +4850,7 @@ static void SetDestinationValue(typed_pointer source, typed_pointer dest) case DT_BYTE: *((uint32_t*)dest.addr) = (*((uint8_t*) source.addr)) & 0xff; break; case DT_WORD: *((uint32_t*)dest.addr) = (*((uint16_t*)source.addr)) & 0xffff; break; case DT_DOUBLE_WORD: *((uint32_t*)dest.addr) = (*((uint32_t*)source.addr)) & 0xffffffff; break; - case DT_LONG_WORD: *((uint32_t*)dest.addr) = (*((uint64_t*)source.addr)) & U64(0x00000000ffffffff); break; + case DT_LONG_WORD: *((uint32_t*)dest.addr) = (*((uint64_t*)source.addr)) & 0x00000000ffffffffU; break; } break ; @@ -4861,12 +4861,12 @@ static void SetDestinationValue(typed_pointer source, typed_pointer dest) case DT_BYTE: *((uint64_t*)dest.addr) = (*((uint8_t*)source.addr)) & 0xff; break; case DT_WORD: destinationValue = (*((uint16_t*)source.addr)) << 16; - if (destinationValue & U64(0x0000000080000000)) - destinationValue |= U64(0x000000ff00000000); + if (destinationValue & 0x0000000080000000U) + destinationValue |= 0x000000ff00000000U; *((uint64_t*)dest.addr) = (uint64_t)destinationValue; break; /* Forget not, yon shift register */ case DT_DOUBLE_WORD: *((uint64_t*)dest.addr) = (*((uint32_t*)source.addr)) & 0xffffffff; break; - case DT_LONG_WORD: *((uint64_t*)dest.addr) = (*((uint64_t*)source.addr)) & U64(0x000000ffffffffff); break; + case DT_LONG_WORD: *((uint64_t*)dest.addr) = (*((uint64_t*)source.addr)) & 0x000000ffffffffffU; break; } break ; } @@ -4883,7 +4883,7 @@ static void SetDataMemoryValue(dsp56k_core* cpustate, typed_pointer source, uint /* !!! Is this universal ??? */ /* !!! Forget not, yon shift-limiter !!! */ - case DT_LONG_WORD: cpustate->data->write_word(destinationAddr, (uint16_t)( ((*((uint64_t*)source.addr)) & U64(0x00000000ffff0000)) >> 16) ) ; break ; + case DT_LONG_WORD: cpustate->data->write_word(destinationAddr, (uint16_t)( ((*((uint64_t*)source.addr)) & 0x00000000ffff0000U) >> 16) ) ; break ; } } @@ -4898,6 +4898,6 @@ static void SetProgramMemoryValue(dsp56k_core* cpustate, typed_pointer source, u /* !!! Is this universal ??? */ /* !!! Forget not, yon shift-limiter !!! */ - case DT_LONG_WORD: cpustate->program->write_word(destinationAddr, (uint16_t)( ((*((uint64_t*)source.addr)) & U64(0x00000000ffff0000)) >> 16) ) ; break ; + case DT_LONG_WORD: cpustate->program->write_word(destinationAddr, (uint16_t)( ((*((uint64_t*)source.addr)) & 0x00000000ffff0000U) >> 16) ) ; break ; } } diff --git a/src/devices/cpu/e0c6200/e0c6200.cpp b/src/devices/cpu/e0c6200/e0c6200.cpp index 9cc9468429d..a7ccf514438 100644 --- a/src/devices/cpu/e0c6200/e0c6200.cpp +++ b/src/devices/cpu/e0c6200/e0c6200.cpp @@ -40,10 +40,10 @@ void e0c6200_cpu_device::state_string_export(const device_state_entry &entry, st } } -offs_t e0c6200_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t e0c6200_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(e0c6200); - return CPU_DISASSEMBLE_NAME(e0c6200)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(e0c6200)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/e0c6200/e0c6200.h b/src/devices/cpu/e0c6200/e0c6200.h index cc23c0b1897..e1b95d0381c 100644 --- a/src/devices/cpu/e0c6200/e0c6200.h +++ b/src/devices/cpu/e0c6200/e0c6200.h @@ -43,7 +43,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; address_space_config m_program_config; diff --git a/src/devices/cpu/e0c6200/e0c6200d.cpp b/src/devices/cpu/e0c6200/e0c6200d.cpp index 62cbfab9ad5..eb8c4d55091 100644 --- a/src/devices/cpu/e0c6200/e0c6200d.cpp +++ b/src/devices/cpu/e0c6200/e0c6200d.cpp @@ -110,7 +110,7 @@ static char* decode_param(uint16_t opcode, int param, char* buffer) } -static offs_t internal_disasm_e0c6200(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(e0c6200) { uint16_t op = (oprom[1] | oprom[0] << 8) & 0xfff; @@ -705,13 +705,3 @@ static offs_t internal_disasm_e0c6200(cpu_device *device, std::ostream &stream, return 1 | em_flags[m] | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(e0c6200) -{ - std::ostringstream stream; - offs_t result = internal_disasm_e0c6200(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/e132xs/32xsdasm.cpp b/src/devices/cpu/e132xs/32xsdasm.cpp index bf230f9137a..b44da23a7bb 100644 --- a/src/devices/cpu/e132xs/32xsdasm.cpp +++ b/src/devices/cpu/e132xs/32xsdasm.cpp @@ -2136,16 +2136,7 @@ unsigned dasm_hyperstone(std::ostream &stream, unsigned pc, const uint8_t *oprom return size | flags | DASMFLAG_SUPPORTED; } -static unsigned dasm_hyperstone(char *buffer, unsigned pc, const uint8_t *oprom, unsigned h_flag, int private_fp) -{ - std::ostringstream stream; - unsigned result = dasm_hyperstone(stream, pc, oprom, h_flag, private_fp); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE( hyperstone_generic ) { - return dasm_hyperstone( buffer, pc, oprom, 0, 0 ); + return dasm_hyperstone( stream, pc, oprom, 0, 0 ); } diff --git a/src/devices/cpu/e132xs/e132xs.cpp b/src/devices/cpu/e132xs/e132xs.cpp index 0fea0efe55b..7e3c0b54665 100644 --- a/src/devices/cpu/e132xs/e132xs.cpp +++ b/src/devices/cpu/e132xs/e132xs.cpp @@ -1904,13 +1904,10 @@ uint32_t hyperstone_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t hyperstone_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t hyperstone_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - std::ostringstream stream; - offs_t result = dasm_hyperstone(stream, pc, oprom, GET_H, GET_FP); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; + extern CPU_DISASSEMBLE( hyperstone ); + return dasm_hyperstone(stream, pc, oprom, GET_H, GET_FP); } /* Opcodes */ @@ -2858,7 +2855,7 @@ void hyperstone_device::hyperstone_sardi(struct hyperstone_device::regs_decode * int i; for( i = 0; i < N_VALUE; i++ ) { - val |= (U64(0x8000000000000000) >> i); + val |= (0x8000000000000000U >> i); } } @@ -2908,7 +2905,7 @@ void hyperstone_device::hyperstone_sard(struct hyperstone_device::regs_decode *d int i; for( i = 0; i < n; i++ ) { - val |= (U64(0x8000000000000000) >> i); + val |= (0x8000000000000000U >> i); } } @@ -2965,7 +2962,7 @@ void hyperstone_device::hyperstone_shldi(struct hyperstone_device::regs_decode * low_order = DREGF; val = concat_64(high_order, low_order); - SET_C( (N_VALUE)?(((val<<(N_VALUE-1))&U64(0x8000000000000000))?1:0):0); + SET_C( (N_VALUE)?(((val<<(N_VALUE-1))&0x8000000000000000U)?1:0):0); mask = ((((uint64_t)1) << (32 - N_VALUE)) - 1) ^ 0xffffffff; tmp = high_order << N_VALUE; @@ -3009,7 +3006,7 @@ void hyperstone_device::hyperstone_shld(struct hyperstone_device::regs_decode *d mask = ((((uint64_t)1) << (32 - n)) - 1) ^ 0xffffffff; val = concat_64(high_order, low_order); - SET_C( (n)?(((val<<(n-1))&U64(0x8000000000000000))?1:0):0); + SET_C( (n)?(((val<<(n-1))&0x8000000000000000U)?1:0):0); tmp = high_order << n; if( ((high_order & mask) && (!(tmp & 0x80000000))) || diff --git a/src/devices/cpu/e132xs/e132xs.h b/src/devices/cpu/e132xs/e132xs.h index 376e0cf634a..5b286eda50c 100644 --- a/src/devices/cpu/e132xs/e132xs.h +++ b/src/devices/cpu/e132xs/e132xs.h @@ -238,7 +238,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/es5510/es5510.cpp b/src/devices/cpu/es5510/es5510.cpp index 6191369a6a3..8113c5c3bd9 100644 --- a/src/devices/cpu/es5510/es5510.cpp +++ b/src/devices/cpu/es5510/es5510.cpp @@ -16,8 +16,8 @@ static const int32_t MIN_24 = -(1 << 23); static const int32_t MAX_24 = (1 << 23) - 1; -static const int64_t MIN_48 = -(S64(1) << 47); -static const int64_t MAX_48 = (S64(1) << 47) - 1; +static const int64_t MIN_48 = -(s64(1) << 47); +static const int64_t MAX_48 = (s64(1) << 47) - 1; #define SIGN_BIT_24 (0x00800000) #define GET_SIGN_BIT_24(x) ((x) & SIGN_BIT_24) @@ -27,8 +27,8 @@ static const int64_t MAX_48 = (S64(1) << 47) - 1; static inline int32_t SX(int32_t x) { return IS_NEGATIVE(x) ? x | 0xff000000 : x & 0x00ffffff; } static inline int32_t SC(int32_t x) { return x & 0x00ffffff; } -static inline int64_t SX64(int64_t x) { return (x & S64(0x0000800000000000)) ? x | S64(0xffff000000000000) : x & S64(0x0000ffffffffffff); } -//static inline int64_t SC64(int64_t x) { return x & S64(0x0000ffffffffffff); } +static inline int64_t SX64(int64_t x) { return (x & s64(0x0000800000000000U)) ? x | s64(0xffff000000000000U) : x & s64(0x0000ffffffffffffU); } +//static inline int64_t SC64(int64_t x) { return x & s64(0x0000ffffffffffffU); } #define VERBOSE 0 #define VERBOSE_EXEC 0 @@ -422,12 +422,12 @@ WRITE8_MEMBER(es5510_device::host_w) break; /* 0x03 to 0x08 INSTR Register */ - case 0x03: instr_latch = ((instr_latch&U64(0x00ffffffffff)) | ((int64_t)data&0xff)<<40); LOG(("%s",string_format("ES5510: Host Write INSTR latch[5] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; - case 0x04: instr_latch = ((instr_latch&U64(0xff00ffffffff)) | ((int64_t)data&0xff)<<32); LOG(("%s",string_format("ES5510: Host Write INSTR latch[4] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; - case 0x05: instr_latch = ((instr_latch&U64(0xffff00ffffff)) | ((int64_t)data&0xff)<<24); LOG(("%s",string_format("ES5510: Host Write INSTR latch[3] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; - case 0x06: instr_latch = ((instr_latch&U64(0xffffff00ffff)) | ((int64_t)data&0xff)<<16); LOG(("%s",string_format("ES5510: Host Write INSTR latch[2] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; - case 0x07: instr_latch = ((instr_latch&U64(0xffffffff00ff)) | ((int64_t)data&0xff)<< 8); LOG(("%s",string_format("ES5510: Host Write INSTR latch[1] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; - case 0x08: instr_latch = ((instr_latch&U64(0xffffffffff00)) | ((int64_t)data&0xff)<< 0); LOG(("%s",string_format("ES5510: Host Write INSTR latch[0] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; + case 0x03: instr_latch = ((instr_latch&0x00ffffffffffU) | ((int64_t)data&0xff)<<40); LOG(("%s",string_format("ES5510: Host Write INSTR latch[5] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; + case 0x04: instr_latch = ((instr_latch&0xff00ffffffffU) | ((int64_t)data&0xff)<<32); LOG(("%s",string_format("ES5510: Host Write INSTR latch[4] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; + case 0x05: instr_latch = ((instr_latch&0xffff00ffffffU) | ((int64_t)data&0xff)<<24); LOG(("%s",string_format("ES5510: Host Write INSTR latch[3] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; + case 0x06: instr_latch = ((instr_latch&0xffffff00ffffU) | ((int64_t)data&0xff)<<16); LOG(("%s",string_format("ES5510: Host Write INSTR latch[2] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; + case 0x07: instr_latch = ((instr_latch&0xffffffff00ffU) | ((int64_t)data&0xff)<< 8); LOG(("%s",string_format("ES5510: Host Write INSTR latch[1] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; + case 0x08: instr_latch = ((instr_latch&0xffffffffff00U) | ((int64_t)data&0xff)<< 0); LOG(("%s",string_format("ES5510: Host Write INSTR latch[0] = %02x -> %012I64x\n", data, instr_latch).c_str())); break; /* 0x09 to 0x0b DIL Register (r/o) */ @@ -477,7 +477,7 @@ WRITE8_MEMBER(es5510_device::host_w) break; case 0x80: /* Read select - GPR + INSTR */ - LOG(("%s",string_format("ES5510: Host Read INSTR+GPR %02x (%s): %012I64x %06x (%d)\n", data, REGNAME(data & 0xff), instr[data] & U64(0xffffffffffff), gpr[data] & 0xffffff, gpr[data]).c_str())); + LOG(("%s",string_format("ES5510: Host Read INSTR+GPR %02x (%s): %012I64x %06x (%d)\n", data, REGNAME(data & 0xff), instr[data] & 0xffffffffffffU, gpr[data] & 0xffffff, gpr[data]).c_str())); /* Check if an INSTR address is selected */ if (data < 0xa0) { @@ -498,10 +498,10 @@ WRITE8_MEMBER(es5510_device::host_w) case 0xc0: /* Write select - INSTR */ #if VERBOSE DESCRIBE_INSTR(buf, instr_latch, gpr[data], nullptr, nullptr, nullptr, nullptr); - LOG(("%s",string_format("ES5510: Host Write INSTR %02x %012I64x: %s\n", data, instr_latch&U64(0xffffffffffff), buf).c_str())); + LOG(("%s",string_format("ES5510: Host Write INSTR %02x %012I64x: %s\n", data, instr_latch&0xffffffffffffU, buf).c_str())); #endif if (data < 0xa0) { - instr[data] = instr_latch&U64(0xffffffffffff); + instr[data] = instr_latch&0xffffffffffffU; } break; @@ -802,7 +802,7 @@ void es5510_device::execute_run() { } #endif machl = mulacc.result; - int32_t tmp = mac_overflow ? (machl < 0 ? MIN_24 : MAX_24) : (mulacc.result & U64(0x0000ffffff000000)) >> 24; + int32_t tmp = mac_overflow ? (machl < 0 ? MIN_24 : MAX_24) : (mulacc.result & 0x0000ffffff000000U) >> 24; if (mulacc.dst & SRC_DST_REG) { write_reg(mulacc.cReg, tmp); } @@ -933,7 +933,7 @@ uint32_t es5510_device::disasm_max_opcode_bytes() const return 6; } -offs_t es5510_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t es5510_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return pc; } @@ -1052,7 +1052,7 @@ void es5510_device::write_reg(uint8_t reg, int32_t value) #if VERBOSE_EXEC old = machl; #endif - int64_t masked = machl & (S64(0x00ffffff) << 24); + int64_t masked = machl & (s64(0x00ffffffU) << 24); int64_t shifted = (int64_t)(value & 0x00ffffff) << 0; machl = SX64(masked | shifted); #if VERBOSE_EXEC @@ -1064,7 +1064,7 @@ void es5510_device::write_reg(uint8_t reg, int32_t value) #if VERBOSE_EXEC old = machl; #endif - int64_t masked = machl & (S64(0x00ffffff) << 0); + int64_t masked = machl & (s64(0x00ffffffU) << 0); int64_t shifted = (int64_t)(value & 0x00ffffff) << 24; machl = SX64(masked | shifted); mac_overflow = false; diff --git a/src/devices/cpu/es5510/es5510.h b/src/devices/cpu/es5510/es5510.h index 76d890db2a7..4d85cb87e5c 100644 --- a/src/devices/cpu/es5510/es5510.h +++ b/src/devices/cpu/es5510/es5510.h @@ -134,7 +134,7 @@ protected: virtual void execute_run() override; virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void execute_set_input(int linenum, int state) override; int32_t alu_operation(uint8_t op, int32_t aValue, int32_t bValue, uint8_t &flags); diff --git a/src/devices/cpu/esrip/esrip.cpp b/src/devices/cpu/esrip/esrip.cpp index dc5e79a18d3..f59f4d46bdf 100644 --- a/src/devices/cpu/esrip/esrip.cpp +++ b/src/devices/cpu/esrip/esrip.cpp @@ -398,10 +398,10 @@ uint32_t esrip_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t esrip_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t esrip_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( esrip ); - return CPU_DISASSEMBLE_NAME(esrip)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(esrip)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/esrip/esrip.h b/src/devices/cpu/esrip/esrip.h index 3d7fdc093e2..42f397ca5b4 100644 --- a/src/devices/cpu/esrip/esrip.h +++ b/src/devices/cpu/esrip/esrip.h @@ -149,7 +149,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/esrip/esripdsm.cpp b/src/devices/cpu/esrip/esripdsm.cpp index 61d8d878ad3..04890fba2e4 100644 --- a/src/devices/cpu/esrip/esripdsm.cpp +++ b/src/devices/cpu/esrip/esripdsm.cpp @@ -17,7 +17,7 @@ DISASSEMBLY HOOK (TODO: FINISH) ***************************************************************************/ -static offs_t internal_disasm_esrip(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(esrip) { #if 0 static const char* const jmp_types[] = @@ -93,13 +93,3 @@ static offs_t internal_disasm_esrip(cpu_device *device, std::ostream &stream, of return 1 | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(esrip) -{ - std::ostringstream stream; - offs_t result = internal_disasm_esrip(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/f8/f8.cpp b/src/devices/cpu/f8/f8.cpp index a4470c0686d..4a0b76347cc 100644 --- a/src/devices/cpu/f8/f8.cpp +++ b/src/devices/cpu/f8/f8.cpp @@ -2062,10 +2062,10 @@ void f8_cpu_device::state_string_export(const device_state_entry &entry, std::st } -offs_t f8_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t f8_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( f8 ); - return CPU_DISASSEMBLE_NAME(f8)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(f8)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/f8/f8.h b/src/devices/cpu/f8/f8.h index 6f96bea3f49..114372a23d1 100644 --- a/src/devices/cpu/f8/f8.h +++ b/src/devices/cpu/f8/f8.h @@ -56,7 +56,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 3; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/f8/f8dasm.cpp b/src/devices/cpu/f8/f8dasm.cpp index c67a1372c2d..4c44aa2c424 100644 --- a/src/devices/cpu/f8/f8dasm.cpp +++ b/src/devices/cpu/f8/f8dasm.cpp @@ -9,7 +9,7 @@ static const char *const rname[16] = { "R8", "J", "HU", "HL", "KU", "KL", "QU", "QL" }; -static offs_t internal_disasm_f8(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(f8) { unsigned size = 0; uint8_t op = oprom[size++]; @@ -532,13 +532,3 @@ static offs_t internal_disasm_f8(cpu_device *device, std::ostream &stream, offs_ return size; } - - -CPU_DISASSEMBLE(f8) -{ - std::ostringstream stream; - offs_t result = internal_disasm_f8(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/g65816/g65816.cpp b/src/devices/cpu/g65816/g65816.cpp index 5eef5b1f386..9f2689b93f9 100644 --- a/src/devices/cpu/g65816/g65816.cpp +++ b/src/devices/cpu/g65816/g65816.cpp @@ -759,14 +759,14 @@ void g65816_device::execute_set_input(int line, int state) #include "g65816ds.h" -offs_t g65816_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t g65816_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return g65816_disassemble(buffer, (pc & 0x00ffff), (pc & 0xff0000) >> 16, oprom, FLAG_M, FLAG_X); + return g65816_disassemble(stream, (pc & 0x00ffff), (pc & 0xff0000) >> 16, oprom, FLAG_M, FLAG_X); } CPU_DISASSEMBLE( g65816 ) { - return g65816_disassemble(buffer, (pc & 0x00ffff), (pc & 0xff0000) >> 16, oprom, 0/*FLAG_M*/, 0/*FLAG_X*/); + return g65816_disassemble(stream, (pc & 0x00ffff), (pc & 0xff0000) >> 16, oprom, 0/*FLAG_M*/, 0/*FLAG_X*/); } void g65816_device::g65816_restore_state() diff --git a/src/devices/cpu/g65816/g65816.h b/src/devices/cpu/g65816/g65816.h index 87bb2795101..8e14baabc9f 100644 --- a/src/devices/cpu/g65816/g65816.h +++ b/src/devices/cpu/g65816/g65816.h @@ -87,7 +87,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; diff --git a/src/devices/cpu/g65816/g65816ds.cpp b/src/devices/cpu/g65816/g65816ds.cpp index 0d5d5409086..aad24ceb545 100644 --- a/src/devices/cpu/g65816/g65816ds.cpp +++ b/src/devices/cpu/g65816/g65816ds.cpp @@ -382,16 +382,7 @@ unsigned g65816_disassemble(std::ostream &stream, unsigned int pc, unsigned int return length | DASMFLAG_SUPPORTED | dasm_flags; } -unsigned g65816_disassemble(char *buffer, unsigned int pc, unsigned int pb, const uint8_t *oprom, int m_flag, int x_flag) -{ - std::ostringstream stream; - unsigned result = g65816_disassemble(stream, pc, pb, oprom, m_flag, x_flag); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE( g65816_generic ) { - return g65816_disassemble(buffer, (pc & 0x00ffff), (pc & 0xff0000) >> 16, oprom, 0, 0); + return g65816_disassemble(stream, (pc & 0x00ffff), (pc & 0xff0000) >> 16, oprom, 0, 0); } diff --git a/src/devices/cpu/g65816/g65816ds.h b/src/devices/cpu/g65816/g65816ds.h index a0dfc7a2034..892dd065a10 100644 --- a/src/devices/cpu/g65816/g65816ds.h +++ b/src/devices/cpu/g65816/g65816ds.h @@ -17,7 +17,6 @@ All rights reserved. */ unsigned g65816_disassemble(std::ostream &stream, unsigned int pc, unsigned int pb, const uint8_t *oprom, int m_flag, int x_flag); -unsigned g65816_disassemble(char *buffer, unsigned int pc, unsigned int pb, const uint8_t *oprom, int m_flag, int x_flag); #endif /* __G65816DS_H__ */ diff --git a/src/devices/cpu/h6280/6280dasm.cpp b/src/devices/cpu/h6280/6280dasm.cpp index 2f6d1d9d84f..5679ab17226 100644 --- a/src/devices/cpu/h6280/6280dasm.cpp +++ b/src/devices/cpu/h6280/6280dasm.cpp @@ -144,7 +144,7 @@ static const unsigned char op6280[512]= /***************************************************************************** * Disassemble a single command and return the number of bytes it uses. *****************************************************************************/ -static offs_t internal_disasm_h6280(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(h6280) { uint32_t flags = 0; int PC, OP, opc, arg; @@ -249,16 +249,6 @@ static offs_t internal_disasm_h6280(cpu_device *device, std::ostream &stream, of default: util::stream_format(stream, "%-5s$%02X", token[opc], OP >> 1); - } + } return (PC - pc) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(h6280) -{ - std::ostringstream stream; - offs_t result = internal_disasm_h6280(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/h6280/h6280.cpp b/src/devices/cpu/h6280/h6280.cpp index ecb2420e366..a3fae0075f5 100644 --- a/src/devices/cpu/h6280/h6280.cpp +++ b/src/devices/cpu/h6280/h6280.cpp @@ -2238,10 +2238,10 @@ uint32_t h6280_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t h6280_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t h6280_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( h6280 ); - return CPU_DISASSEMBLE_NAME(h6280)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(h6280)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/h6280/h6280.h b/src/devices/cpu/h6280/h6280.h index 5717b3fa55f..66b7386b399 100644 --- a/src/devices/cpu/h6280/h6280.h +++ b/src/devices/cpu/h6280/h6280.h @@ -95,7 +95,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/h8/h8.cpp b/src/devices/cpu/h8/h8.cpp index fe25c24d61f..6d62453a2ff 100644 --- a/src/devices/cpu/h8/h8.cpp +++ b/src/devices/cpu/h8/h8.cpp @@ -334,7 +334,7 @@ uint32_t h8_device::disasm_max_opcode_bytes() const return 10; } -void h8_device::disassemble_am(char *&buffer, int am, offs_t pc, const uint8_t *oprom, uint32_t opcode, int slot, int offset) +void h8_device::disassemble_am(std::ostream &stream, int am, offs_t pc, const uint8_t *oprom, uint32_t opcode, int slot, int offset) { static const char *const r8_names[16] = { "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h", @@ -352,194 +352,194 @@ void h8_device::disassemble_am(char *&buffer, int am, offs_t pc, const uint8_t * switch(am) { case DASM_r8l: - buffer += sprintf(buffer, "%s", r8_names[opcode & 15]); + util::stream_format(stream, "%s", r8_names[opcode & 15]); break; case DASM_r8h: - buffer += sprintf(buffer, "%s", r8_names[(opcode >> 4) & 15]); + util::stream_format(stream, "%s", r8_names[(opcode >> 4) & 15]); break; case DASM_r8u: - buffer += sprintf(buffer, "%s", r8_names[(opcode >> 8) & 15]); + util::stream_format(stream, "%s", r8_names[(opcode >> 8) & 15]); break; case DASM_r16l: - buffer += sprintf(buffer, "%s", r16_names[opcode & 15]); + util::stream_format(stream, "%s", r16_names[opcode & 15]); break; case DASM_r16h: - buffer += sprintf(buffer, "%s", r16_names[(opcode >> 4) & 15]); + util::stream_format(stream, "%s", r16_names[(opcode >> 4) & 15]); break; case DASM_r32l: - buffer += sprintf(buffer, "%s", r32_names[opcode & 7]); + util::stream_format(stream, "%s", r32_names[opcode & 7]); break; case DASM_r32h: - buffer += sprintf(buffer, "%s", r32_names[(opcode >> 4) & 7]); + util::stream_format(stream, "%s", r32_names[(opcode >> 4) & 7]); break; case DASM_r16ih: - buffer += sprintf(buffer, "@%s", r16_names[(opcode >> 4) & 7]); + util::stream_format(stream, "@%s", r16_names[(opcode >> 4) & 7]); break; case DASM_r16ihh: - buffer += sprintf(buffer, "@%s", r16_names[(opcode >> 20) & 7]); + util::stream_format(stream, "@%s", r16_names[(opcode >> 20) & 7]); break; case DASM_pr16h: - buffer += sprintf(buffer, "@-%s", r16_names[(opcode >> 4) & 7]); + util::stream_format(stream, "@-%s", r16_names[(opcode >> 4) & 7]); break; case DASM_r16ph: - buffer += sprintf(buffer, "@%s+", r16_names[(opcode >> 4) & 7]); + util::stream_format(stream, "@%s+", r16_names[(opcode >> 4) & 7]); break; case DASM_r16d16h: - buffer += sprintf(buffer, "@(%x, %s)", (oprom[offset-2] << 8) | oprom[offset-1], r16_names[(opcode >> 4) & 7]); + util::stream_format(stream, "@(%x, %s)", (oprom[offset-2] << 8) | oprom[offset-1], r16_names[(opcode >> 4) & 7]); break; case DASM_r32ih: - buffer += sprintf(buffer, "@%s", r32_names[(opcode >> 4) & 7]); + util::stream_format(stream, "@%s", r32_names[(opcode >> 4) & 7]); break; case DASM_r32ihh: - buffer += sprintf(buffer, "@%s", r32_names[(opcode >> 20) & 7]); + util::stream_format(stream, "@%s", r32_names[(opcode >> 20) & 7]); break; case DASM_pr32h: - buffer += sprintf(buffer, "@-%s", r32_names[(opcode >> 4) & 7]); + util::stream_format(stream, "@-%s", r32_names[(opcode >> 4) & 7]); break; case DASM_r32pl: - buffer += sprintf(buffer, "@%s+", r32_names[opcode & 7]); + util::stream_format(stream, "@%s+", r32_names[opcode & 7]); break; case DASM_r32ph: - buffer += sprintf(buffer, "@%s+", r32_names[(opcode >> 4) & 7]); + util::stream_format(stream, "@%s+", r32_names[(opcode >> 4) & 7]); break; case DASM_r32d16h: - buffer += sprintf(buffer, "@(%x, %s)", (oprom[offset-2] << 8) | oprom[offset-1], r32_names[(opcode >> 4) & 7]); + util::stream_format(stream, "@(%x, %s)", (oprom[offset-2] << 8) | oprom[offset-1], r32_names[(opcode >> 4) & 7]); break; case DASM_r32d32hh: - buffer += sprintf(buffer, "@(%x, %s)", (oprom[offset-4] << 24) | (oprom[offset-3] << 16) | (oprom[offset-2] << 8) | oprom[offset-1], r32_names[(opcode >> 20) & 7]); + util::stream_format(stream, "@(%x, %s)", (oprom[offset-4] << 24) | (oprom[offset-3] << 16) | (oprom[offset-2] << 8) | oprom[offset-1], r32_names[(opcode >> 20) & 7]); break; case DASM_psp: - buffer += sprintf(buffer, "@-sp"); + util::stream_format(stream, "@-sp"); break; case DASM_spp: - buffer += sprintf(buffer, "@sp+"); + util::stream_format(stream, "@sp+"); break; case DASM_r32n2l: - buffer += sprintf(buffer, "%s-%s", r32_names[opcode & 6], r32_names[(opcode & 6) + 1]); + util::stream_format(stream, "%s-%s", r32_names[opcode & 6], r32_names[(opcode & 6) + 1]); break; case DASM_r32n3l: - buffer += sprintf(buffer, "%s-%s", r32_names[opcode & 4], r32_names[(opcode & 4) + 2]); + util::stream_format(stream, "%s-%s", r32_names[opcode & 4], r32_names[(opcode & 4) + 2]); break; case DASM_r32n4l: - buffer += sprintf(buffer, "%s-%s", r32_names[opcode & 4], r32_names[(opcode & 4) + 3]); + util::stream_format(stream, "%s-%s", r32_names[opcode & 4], r32_names[(opcode & 4) + 3]); break; case DASM_abs8: - buffer += sprintf(buffer, "@%08x", 0xffffff00 | oprom[1]); + util::stream_format(stream, "@%08x", 0xffffff00 | oprom[1]); break; case DASM_abs16: if(offset >= 6) - buffer += sprintf(buffer, "@%08x", int16_t((oprom[offset-4] << 8) | oprom[offset-3])); + util::stream_format(stream, "@%08x", int16_t((oprom[offset-4] << 8) | oprom[offset-3])); else - buffer += sprintf(buffer, "@%08x", int16_t((oprom[offset-2] << 8) | oprom[offset-1])); + util::stream_format(stream, "@%08x", int16_t((oprom[offset-2] << 8) | oprom[offset-1])); break; case DASM_abs32: if(slot == 3) - buffer += sprintf(buffer, "@%08x", (oprom[offset-6] << 24) | (oprom[offset-5] << 16) | (oprom[offset-4] << 8) | oprom[offset-3]); + util::stream_format(stream, "@%08x", (oprom[offset-6] << 24) | (oprom[offset-5] << 16) | (oprom[offset-4] << 8) | oprom[offset-3]); else - buffer += sprintf(buffer, "@%08x", (oprom[offset-4] << 24) | (oprom[offset-3] << 16) | (oprom[offset-2] << 8) | oprom[offset-1]); + util::stream_format(stream, "@%08x", (oprom[offset-4] << 24) | (oprom[offset-3] << 16) | (oprom[offset-2] << 8) | oprom[offset-1]); break; case DASM_abs8i: - buffer += sprintf(buffer, "@%02x", oprom[1]); + util::stream_format(stream, "@%02x", oprom[1]); break; case DASM_abs16e: - buffer += sprintf(buffer, "%04x", (oprom[2] << 8) | oprom[3]); + util::stream_format(stream, "%04x", (oprom[2] << 8) | oprom[3]); break; case DASM_abs24e: - buffer += sprintf(buffer, "%08x", (oprom[1] << 16) | (oprom[2] << 8) | oprom[3]); + util::stream_format(stream, "%08x", (oprom[1] << 16) | (oprom[2] << 8) | oprom[3]); break; case DASM_rel8: - buffer += sprintf(buffer, "%08x", pc + 2 + int8_t(oprom[1])); + util::stream_format(stream, "%08x", pc + 2 + int8_t(oprom[1])); break; case DASM_rel16: - buffer += sprintf(buffer, "%08x", pc + 4 + int16_t((oprom[2] << 8) | oprom[3])); + util::stream_format(stream, "%08x", pc + 4 + int16_t((oprom[2] << 8) | oprom[3])); break; case DASM_one: - buffer += sprintf(buffer, "#1"); + util::stream_format(stream, "#1"); break; case DASM_two: - buffer += sprintf(buffer, "#2"); + util::stream_format(stream, "#2"); break; case DASM_four: - buffer += sprintf(buffer, "#4"); + util::stream_format(stream, "#4"); break; case DASM_imm2: - buffer += sprintf(buffer, "#%x", (opcode >> 4) & 3); + util::stream_format(stream, "#%x", (opcode >> 4) & 3); break; case DASM_imm3: - buffer += sprintf(buffer, "#%x", (opcode >> 4) & 7); + util::stream_format(stream, "#%x", (opcode >> 4) & 7); break; case DASM_imm8: - buffer += sprintf(buffer, "#%02x", oprom[1]); + util::stream_format(stream, "#%02x", oprom[1]); break; case DASM_imm16: - buffer += sprintf(buffer, "#%04x", (oprom[2] << 8) | oprom[3]); + util::stream_format(stream, "#%04x", (oprom[2] << 8) | oprom[3]); break; case DASM_imm32: - buffer += sprintf(buffer, "#%08x", (oprom[2] << 16) | (oprom[3] << 16) | (oprom[4] << 8) | oprom[5]); + util::stream_format(stream, "#%08x", (oprom[2] << 16) | (oprom[3] << 16) | (oprom[4] << 8) | oprom[5]); break; case DASM_ccr: - buffer += sprintf(buffer, "ccr"); + util::stream_format(stream, "ccr"); break; case DASM_exr: - buffer += sprintf(buffer, "exr"); + util::stream_format(stream, "exr"); break; case DASM_macl: - buffer += sprintf(buffer, "macl"); + util::stream_format(stream, "macl"); break; case DASM_mach: - buffer += sprintf(buffer, "mach"); + util::stream_format(stream, "mach"); break; default: - buffer += sprintf(buffer, "<%d>", am); + util::stream_format(stream, "<%d>", am); break; } } -offs_t h8_device::disassemble_generic(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *table) +offs_t h8_device::disassemble_generic(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *table) { uint32_t slot[5]; slot[0] = (oprom[0] << 8) | oprom[1]; @@ -555,23 +555,22 @@ offs_t h8_device::disassemble_generic(char *buffer, offs_t pc, const uint8_t *op break; } const disasm_entry &e = table[inst]; - buffer += sprintf(buffer, "%s", e.opcode); + stream << e.opcode; if(e.am1 != DASM_none) { - *buffer++ = ' '; - disassemble_am(buffer, e.am1, pc, oprom, slot[e.slot], e.slot, e.flags & DASMFLAG_LENGTHMASK); + stream << ' '; + disassemble_am(stream, e.am1, pc, oprom, slot[e.slot], e.slot, e.flags & DASMFLAG_LENGTHMASK); } if(e.am2 != DASM_none) { - *buffer++ = ','; - *buffer++ = ' '; - disassemble_am(buffer, e.am2, pc, oprom, slot[e.slot], e.slot, e.flags & DASMFLAG_LENGTHMASK); + stream << ", "; + disassemble_am(stream, e.am2, pc, oprom, slot[e.slot], e.slot, e.flags & DASMFLAG_LENGTHMASK); } return e.flags | DASMFLAG_SUPPORTED; } -offs_t h8_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t h8_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } uint16_t h8_device::read16i(uint32_t adr) @@ -799,7 +798,7 @@ uint32_t h8_device::do_add32(uint32_t v1, uint32_t v2) CCR |= F_N; if(~(v1^v2) & (v1^res) & 0x80000000) CCR |= F_V; - if(res & U64(0x100000000)) + if(res & 0x100000000U) CCR |= F_C; return res; } @@ -891,7 +890,7 @@ uint32_t h8_device::do_sub32(uint32_t v1, uint32_t v2) CCR |= F_N; if((v1^v2) & (v1^res) & 0x80000000) CCR |= F_V; - if(res & U64(0x100000000)) + if(res & 0x100000000U) CCR |= F_C; return res; } diff --git a/src/devices/cpu/h8/h8.h b/src/devices/cpu/h8/h8.h index 8a106ed852d..089cec91fb7 100644 --- a/src/devices/cpu/h8/h8.h +++ b/src/devices/cpu/h8/h8.h @@ -175,7 +175,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config program_config, io_config; address_space *program, *io; @@ -208,8 +208,8 @@ protected: static const disasm_entry disasm_entries[]; - offs_t disassemble_generic(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *table); - void disassemble_am(char *&buffer, int am, offs_t pc, const uint8_t *oprom, uint32_t opcode, int slot, int offset); + offs_t disassemble_generic(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *table); + void disassemble_am(std::ostream &stream, int am, offs_t pc, const uint8_t *oprom, uint32_t opcode, int slot, int offset); virtual void do_exec_full(); virtual void do_exec_partial(); diff --git a/src/devices/cpu/h8/h8h.cpp b/src/devices/cpu/h8/h8h.cpp index 1710cb930f6..87ae39a884b 100644 --- a/src/devices/cpu/h8/h8h.cpp +++ b/src/devices/cpu/h8/h8h.cpp @@ -10,9 +10,9 @@ h8h_device::h8h_device(const machine_config &mconfig, device_type type, const ch mode_advanced = true; } -offs_t h8h_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t h8h_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } #include "cpu/h8/h8h.hxx" diff --git a/src/devices/cpu/h8/h8h.h b/src/devices/cpu/h8/h8h.h index b4385d96ef6..f634e0aa82a 100644 --- a/src/devices/cpu/h8/h8h.h +++ b/src/devices/cpu/h8/h8h.h @@ -23,7 +23,7 @@ public: protected: static const disasm_entry disasm_entries[]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; diff --git a/src/devices/cpu/h8/h8s2000.cpp b/src/devices/cpu/h8/h8s2000.cpp index ff8997e4728..99086cbc95f 100644 --- a/src/devices/cpu/h8/h8s2000.cpp +++ b/src/devices/cpu/h8/h8s2000.cpp @@ -9,9 +9,9 @@ h8s2000_device::h8s2000_device(const machine_config &mconfig, device_type type, has_exr = true; } -offs_t h8s2000_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t h8s2000_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } #include "cpu/h8/h8s2000.hxx" diff --git a/src/devices/cpu/h8/h8s2000.h b/src/devices/cpu/h8/h8s2000.h index 24808f8d596..34edb361cd8 100644 --- a/src/devices/cpu/h8/h8s2000.h +++ b/src/devices/cpu/h8/h8s2000.h @@ -25,7 +25,7 @@ public: protected: static const disasm_entry disasm_entries[]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; diff --git a/src/devices/cpu/h8/h8s2600.cpp b/src/devices/cpu/h8/h8s2600.cpp index 7717bc2f179..5bd2d7419cc 100644 --- a/src/devices/cpu/h8/h8s2600.cpp +++ b/src/devices/cpu/h8/h8s2600.cpp @@ -8,9 +8,9 @@ h8s2600_device::h8s2600_device(const machine_config &mconfig, device_type type, { } -offs_t h8s2600_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t h8s2600_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } #include "cpu/h8/h8s2600.hxx" diff --git a/src/devices/cpu/h8/h8s2600.h b/src/devices/cpu/h8/h8s2600.h index a7c686e910d..eb2881d66dd 100644 --- a/src/devices/cpu/h8/h8s2600.h +++ b/src/devices/cpu/h8/h8s2600.h @@ -23,7 +23,7 @@ public: protected: static const disasm_entry disasm_entries[]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; diff --git a/src/devices/cpu/hcd62121/hcd62121.cpp b/src/devices/cpu/hcd62121/hcd62121.cpp index 8a3e6fa5049..3c8e98149ea 100644 --- a/src/devices/cpu/hcd62121/hcd62121.cpp +++ b/src/devices/cpu/hcd62121/hcd62121.cpp @@ -525,8 +525,8 @@ void hcd62121_cpu_device::execute_run() } -offs_t hcd62121_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t hcd62121_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( hcd62121 ); - return CPU_DISASSEMBLE_NAME(hcd62121)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(hcd62121)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/hcd62121/hcd62121.h b/src/devices/cpu/hcd62121/hcd62121.h index df804d9a0e3..af105c2a3a3 100644 --- a/src/devices/cpu/hcd62121/hcd62121.h +++ b/src/devices/cpu/hcd62121/hcd62121.h @@ -59,7 +59,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 18; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; uint8_t read_op(); uint8_t datasize( uint8_t op ); diff --git a/src/devices/cpu/hcd62121/hcd62121d.cpp b/src/devices/cpu/hcd62121/hcd62121d.cpp index a0321e63c40..d355385f793 100644 --- a/src/devices/cpu/hcd62121/hcd62121d.cpp +++ b/src/devices/cpu/hcd62121/hcd62121d.cpp @@ -129,7 +129,7 @@ static const hcd62121_dasm hcd62121_ops[256] = }; -static offs_t internal_disasm_hcd62121(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(hcd62121) { uint8_t op; uint8_t op1; @@ -357,12 +357,3 @@ static offs_t internal_disasm_hcd62121(cpu_device *device, std::ostream &stream, return pos | DASMFLAG_SUPPORTED; } - -CPU_DISASSEMBLE(hcd62121) -{ - std::ostringstream stream; - offs_t result = internal_disasm_hcd62121(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/hd61700/hd61700.cpp b/src/devices/cpu/hd61700/hd61700.cpp index 11e0ab9f0c2..c7c646a7a4b 100644 --- a/src/devices/cpu/hd61700/hd61700.cpp +++ b/src/devices/cpu/hd61700/hd61700.cpp @@ -292,10 +292,10 @@ void hd61700_cpu_device::state_string_export(const device_state_entry &entry, st // helper function //------------------------------------------------- -offs_t hd61700_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t hd61700_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( hd61700 ); - return CPU_DISASSEMBLE_NAME(hd61700)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(hd61700)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/hd61700/hd61700.h b/src/devices/cpu/hd61700/hd61700.h index c0b7666b36f..fee2e4cd465 100644 --- a/src/devices/cpu/hd61700/hd61700.h +++ b/src/devices/cpu/hd61700/hd61700.h @@ -100,7 +100,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 16; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // interrupts bool check_irqs(void); diff --git a/src/devices/cpu/hd61700/hd61700d.cpp b/src/devices/cpu/hd61700/hd61700d.cpp index daa45c6b649..53a98be2145 100644 --- a/src/devices/cpu/hd61700/hd61700d.cpp +++ b/src/devices/cpu/hd61700/hd61700d.cpp @@ -392,7 +392,7 @@ uint32_t get_dasmflags(uint8_t op) } -static offs_t internal_disasm_hd61700(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(hd61700) { const hd61700_dasm *inst; uint32_t dasmflags; @@ -433,13 +433,3 @@ static offs_t internal_disasm_hd61700(cpu_device *device, std::ostream &stream, return (pos>>1) | dasmflags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(hd61700) -{ - std::ostringstream stream; - offs_t result = internal_disasm_hd61700(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/hmcs40/hmcs40.cpp b/src/devices/cpu/hmcs40/hmcs40.cpp index b9e9f8e904b..a15b7cc907c 100644 --- a/src/devices/cpu/hmcs40/hmcs40.cpp +++ b/src/devices/cpu/hmcs40/hmcs40.cpp @@ -148,10 +148,10 @@ void hmcs40_cpu_device::state_string_export(const device_state_entry &entry, std } } -offs_t hmcs40_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t hmcs40_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(hmcs40); - return CPU_DISASSEMBLE_NAME(hmcs40)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(hmcs40)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/hmcs40/hmcs40.h b/src/devices/cpu/hmcs40/hmcs40.h index 225d5790b68..73ae6308940 100644 --- a/src/devices/cpu/hmcs40/hmcs40.h +++ b/src/devices/cpu/hmcs40/hmcs40.h @@ -174,7 +174,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; address_space_config m_program_config; diff --git a/src/devices/cpu/hmcs40/hmcs40d.cpp b/src/devices/cpu/hmcs40/hmcs40d.cpp index b322b4c3208..867972d82db 100644 --- a/src/devices/cpu/hmcs40/hmcs40d.cpp +++ b/src/devices/cpu/hmcs40/hmcs40d.cpp @@ -184,7 +184,7 @@ static const uint8_t hmcs40_mnemonic[0x400] = -static offs_t internal_disasm_hmcs40(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(hmcs40) { uint16_t op = (oprom[0] | oprom[1] << 8) & 0x3ff; uint8_t instr = hmcs40_mnemonic[op]; @@ -229,13 +229,3 @@ static offs_t internal_disasm_hmcs40(cpu_device *device, std::ostream &stream, o int pos = s_next_pc[pc & 0x3f] & DASMFLAG_LENGTHMASK; return pos | s_flags[instr] | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(hmcs40) -{ - std::ostringstream stream; - offs_t result = internal_disasm_hmcs40(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/hphybrid/hphybrid.cpp b/src/devices/cpu/hphybrid/hphybrid.cpp index e2c58c86f15..d2930111c2e 100644 --- a/src/devices/cpu/hphybrid/hphybrid.cpp +++ b/src/devices/cpu/hphybrid/hphybrid.cpp @@ -675,10 +675,10 @@ void hp_hybrid_cpu_device::state_string_export(const device_state_entry &entry, } } -offs_t hp_hybrid_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t hp_hybrid_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(hp_hybrid); - return CPU_DISASSEMBLE_NAME(hp_hybrid)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(hp_hybrid)(this, stream, pc, oprom, opram, options); } uint16_t hp_hybrid_cpu_device::remove_mae(uint32_t addr) @@ -1536,10 +1536,10 @@ uint16_t hp_5061_3001_cpu_device::execute_no_bpc_ioc(uint16_t opcode) return m_reg_P + 1; } -offs_t hp_5061_3001_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t hp_5061_3001_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - extern CPU_DISASSEMBLE(hp_5061_3001); - return CPU_DISASSEMBLE_NAME(hp_5061_3001)(this, buffer, pc, oprom, opram, options); + extern CPU_DISASSEMBLE(hp_5061_3001); + return CPU_DISASSEMBLE_NAME(hp_5061_3001)(this, stream, pc, oprom, opram, options); } uint32_t hp_5061_3001_cpu_device::add_mae(aec_cases_t aec_case , uint16_t addr) diff --git a/src/devices/cpu/hphybrid/hphybrid.h b/src/devices/cpu/hphybrid/hphybrid.h index b7b9fc20c93..c4f85f196b5 100644 --- a/src/devices/cpu/hphybrid/hphybrid.h +++ b/src/devices/cpu/hphybrid/hphybrid.h @@ -119,7 +119,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // Different cases of memory access // See patent @ pg 361 @@ -213,8 +213,8 @@ protected: void do_mpy(void); virtual uint16_t execute_no_bpc_ioc(uint16_t opcode) override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; - virtual uint32_t add_mae(aec_cases_t aec_case , uint16_t addr) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual uint32_t add_mae(aec_cases_t aec_case, uint16_t addr) override; virtual uint16_t read_non_common_reg(uint16_t addr) override; virtual void write_non_common_reg(uint16_t addr , uint16_t v) override; diff --git a/src/devices/cpu/hphybrid/hphybrid_dasm.cpp b/src/devices/cpu/hphybrid/hphybrid_dasm.cpp index 269a37a3482..e825e31c36c 100644 --- a/src/devices/cpu/hphybrid/hphybrid_dasm.cpp +++ b/src/devices/cpu/hphybrid/hphybrid_dasm.cpp @@ -371,7 +371,7 @@ static offs_t disassemble_table(uint16_t opcode , offs_t pc , const dis_entry_t return 0; } -static offs_t internal_disasm_hp_hybrid(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(hp_hybrid) { uint16_t opcode = ((uint16_t)oprom[ 0 ] << 8) | oprom[ 1 ]; offs_t res; @@ -388,16 +388,7 @@ static offs_t internal_disasm_hp_hybrid(cpu_device *device, std::ostream &stream return res; } -CPU_DISASSEMBLE(hp_hybrid) -{ - std::ostringstream stream; - offs_t result = internal_disasm_hp_hybrid(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - -static offs_t internal_disasm_hp_5061_3001(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(hp_5061_3001) { uint16_t opcode = ((uint16_t)oprom[ 0 ] << 8) | oprom[ 1 ]; offs_t res; @@ -418,13 +409,3 @@ static offs_t internal_disasm_hp_5061_3001(cpu_device *device, std::ostream &str return res; } - - -CPU_DISASSEMBLE(hp_5061_3001) -{ - std::ostringstream stream; - offs_t result = internal_disasm_hp_5061_3001(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/i386/i386.cpp b/src/devices/cpu/i386/i386.cpp index 46daedf256d..00321d2e364 100644 --- a/src/devices/cpu/i386/i386.cpp +++ b/src/devices/cpu/i386/i386.cpp @@ -3991,13 +3991,9 @@ bool i386_device::memory_translate(address_spacenum spacenum, int intention, off return ret; } -offs_t i386_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i386_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - std::ostringstream stream; - offs_t result = i386_dasm_one(stream, pc, oprom, m_sreg[CS].d ? 32 : 16); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; + return i386_dasm_one(stream, pc, oprom, m_sreg[CS].d ? 32 : 16); } diff --git a/src/devices/cpu/i386/i386.h b/src/devices/cpu/i386/i386.h index 06e74163ee1..c4abab31915 100644 --- a/src/devices/cpu/i386/i386.h +++ b/src/devices/cpu/i386/i386.h @@ -64,7 +64,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 15; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; address_space_config m_io_config; diff --git a/src/devices/cpu/i386/i386dasm.cpp b/src/devices/cpu/i386/i386dasm.cpp index e25819437f5..3c815612ffa 100644 --- a/src/devices/cpu/i386/i386dasm.cpp +++ b/src/devices/cpu/i386/i386dasm.cpp @@ -3115,26 +3115,17 @@ int i386_dasm_one(std::ostream &stream, offs_t eip, const uint8_t *oprom, int mo return i386_dasm_one_ex(stream, eip, oprom, mode); } -static int i386_dasm_one_ex(char *buffer, uint64_t eip, const uint8_t *oprom, int mode) -{ - std::ostringstream stream; - int result = i386_dasm_one_ex(stream, eip, oprom, mode); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE( x86_16 ) { - return i386_dasm_one_ex(buffer, pc, oprom, 16); + return i386_dasm_one_ex(stream, pc, oprom, 16); } CPU_DISASSEMBLE( x86_32 ) { - return i386_dasm_one_ex(buffer, pc, oprom, 32); + return i386_dasm_one_ex(stream, pc, oprom, 32); } CPU_DISASSEMBLE( x86_64 ) { - return i386_dasm_one_ex(buffer, pc, oprom, 64); + return i386_dasm_one_ex(stream, pc, oprom, 64); } diff --git a/src/devices/cpu/i386/pentops.hxx b/src/devices/cpu/i386/pentops.hxx index 00b706bd5f2..42d3958cd0a 100644 --- a/src/devices/cpu/i386/pentops.hxx +++ b/src/devices/cpu/i386/pentops.hxx @@ -4417,36 +4417,36 @@ void i386_device::sse_predicate_compare_double(uint8_t imm8, XMM_REG d, XMM_REG switch (imm8 & 7) { case 0: - d.q[0]=d.f64[0] == s.f64[0] ? U64(0xffffffffffffffff) : 0; - d.q[1]=d.f64[1] == s.f64[1] ? U64(0xffffffffffffffff) : 0; + d.q[0]=d.f64[0] == s.f64[0] ? 0xffffffffffffffffU : 0; + d.q[1]=d.f64[1] == s.f64[1] ? 0xffffffffffffffffU : 0; break; case 1: - d.q[0]=d.f64[0] < s.f64[0] ? U64(0xffffffffffffffff) : 0; - d.q[1]=d.f64[1] < s.f64[1] ? U64(0xffffffffffffffff) : 0; + d.q[0]=d.f64[0] < s.f64[0] ? 0xffffffffffffffffU : 0; + d.q[1]=d.f64[1] < s.f64[1] ? 0xffffffffffffffffU : 0; break; case 2: - d.q[0]=d.f64[0] <= s.f64[0] ? U64(0xffffffffffffffff) : 0; - d.q[1]=d.f64[1] <= s.f64[1] ? U64(0xffffffffffffffff) : 0; + d.q[0]=d.f64[0] <= s.f64[0] ? 0xffffffffffffffffU : 0; + d.q[1]=d.f64[1] <= s.f64[1] ? 0xffffffffffffffffU : 0; break; case 3: - d.q[0]=sse_isdoubleunordered(d.f64[0], s.f64[0]) ? U64(0xffffffffffffffff) : 0; - d.q[1]=sse_isdoubleunordered(d.f64[1], s.f64[1]) ? U64(0xffffffffffffffff) : 0; + d.q[0]=sse_isdoubleunordered(d.f64[0], s.f64[0]) ? 0xffffffffffffffffU : 0; + d.q[1]=sse_isdoubleunordered(d.f64[1], s.f64[1]) ? 0xffffffffffffffffU : 0; break; case 4: - d.q[0]=d.f64[0] != s.f64[0] ? U64(0xffffffffffffffff) : 0; - d.q[1]=d.f64[1] != s.f64[1] ? U64(0xffffffffffffffff) : 0; + d.q[0]=d.f64[0] != s.f64[0] ? 0xffffffffffffffffU : 0; + d.q[1]=d.f64[1] != s.f64[1] ? 0xffffffffffffffffU : 0; break; case 5: - d.q[0]=d.f64[0] < s.f64[0] ? 0 : U64(0xffffffffffffffff); - d.q[1]=d.f64[1] < s.f64[1] ? 0 : U64(0xffffffffffffffff); + d.q[0]=d.f64[0] < s.f64[0] ? 0 : 0xffffffffffffffffU; + d.q[1]=d.f64[1] < s.f64[1] ? 0 : 0xffffffffffffffffU; break; case 6: - d.q[0]=d.f64[0] <= s.f64[0] ? 0 : U64(0xffffffffffffffff); - d.q[1]=d.f64[1] <= s.f64[1] ? 0 : U64(0xffffffffffffffff); + d.q[0]=d.f64[0] <= s.f64[0] ? 0 : 0xffffffffffffffffU; + d.q[1]=d.f64[1] <= s.f64[1] ? 0 : 0xffffffffffffffffU; break; case 7: - d.q[0]=sse_isdoubleordered(d.f64[0], s.f64[0]) ? U64(0xffffffffffffffff) : 0; - d.q[1]=sse_isdoubleordered(d.f64[1], s.f64[1]) ? U64(0xffffffffffffffff) : 0; + d.q[0]=sse_isdoubleordered(d.f64[0], s.f64[0]) ? 0xffffffffffffffffU : 0; + d.q[1]=sse_isdoubleordered(d.f64[1], s.f64[1]) ? 0xffffffffffffffffU : 0; break; } } @@ -4487,28 +4487,28 @@ void i386_device::sse_predicate_compare_double_scalar(uint8_t imm8, XMM_REG d, X switch (imm8 & 7) { case 0: - d.q[0]=d.f64[0] == s.f64[0] ? U64(0xffffffffffffffff) : 0; + d.q[0]=d.f64[0] == s.f64[0] ? 0xffffffffffffffffU : 0; break; case 1: - d.q[0]=d.f64[0] < s.f64[0] ? U64(0xffffffffffffffff) : 0; + d.q[0]=d.f64[0] < s.f64[0] ? 0xffffffffffffffffU : 0; break; case 2: - d.q[0]=d.f64[0] <= s.f64[0] ? U64(0xffffffffffffffff) : 0; + d.q[0]=d.f64[0] <= s.f64[0] ? 0xffffffffffffffffU : 0; break; case 3: - d.q[0]=sse_isdoubleunordered(d.f64[0], s.f64[0]) ? U64(0xffffffffffffffff) : 0; + d.q[0]=sse_isdoubleunordered(d.f64[0], s.f64[0]) ? 0xffffffffffffffffU : 0; break; case 4: - d.q[0]=d.f64[0] != s.f64[0] ? U64(0xffffffffffffffff) : 0; + d.q[0]=d.f64[0] != s.f64[0] ? 0xffffffffffffffffU : 0; break; case 5: - d.q[0]=d.f64[0] < s.f64[0] ? 0 : U64(0xffffffffffffffff); + d.q[0]=d.f64[0] < s.f64[0] ? 0 : 0xffffffffffffffffU; break; case 6: - d.q[0]=d.f64[0] <= s.f64[0] ? 0 : U64(0xffffffffffffffff); + d.q[0]=d.f64[0] <= s.f64[0] ? 0 : 0xffffffffffffffffU; break; case 7: - d.q[0]=sse_isdoubleordered(d.f64[0], s.f64[0]) ? U64(0xffffffffffffffff) : 0; + d.q[0]=sse_isdoubleordered(d.f64[0], s.f64[0]) ? 0xffffffffffffffffU : 0; break; } } diff --git a/src/devices/cpu/i386/x87ops.hxx b/src/devices/cpu/i386/x87ops.hxx index 010a4d2bea3..c2f36e3cfd2 100644 --- a/src/devices/cpu/i386/x87ops.hxx +++ b/src/devices/cpu/i386/x87ops.hxx @@ -91,11 +91,11 @@ * *************************************/ -static const floatx80 fx80_zero = { 0x0000, U64(0x0000000000000000) }; -static const floatx80 fx80_one = { 0x3fff, U64(0x8000000000000000) }; +static const floatx80 fx80_zero = { 0x0000, 0x0000000000000000U }; +static const floatx80 fx80_one = { 0x3fff, 0x8000000000000000U }; -static const floatx80 fx80_ninf = { 0xffff, U64(0x8000000000000000) }; -static const floatx80 fx80_inan = { 0xffff, U64(0xc000000000000000) }; +static const floatx80 fx80_ninf = { 0xffff, 0x8000000000000000U }; +static const floatx80 fx80_inan = { 0xffff, 0xc000000000000000U }; /* Maps x87 round modes to SoftFloat round modes */ static const int x87_to_sf_rc[4] = @@ -141,7 +141,7 @@ static inline int floatx80_is_inf(floatx80 fx) static inline int floatx80_is_denormal(floatx80 fx) { return (((fx.high & 0x7fff) == 0) && - ((fx.low & U64(0x8000000000000000)) == 0) && + ((fx.low & 0x8000000000000000U) == 0) && ((fx.low << 1) != 0)); } @@ -3104,21 +3104,21 @@ void i386_device::x87_fistp_m64int(uint8_t modrm) if (X87_IS_ST_EMPTY(0)) { x87_set_stack_underflow(); - m64int = U64(0x8000000000000000); + m64int = 0x8000000000000000U; } else { floatx80 fx80 = floatx80_round_to_int(ST(0)); - floatx80 lowerLim = int64_to_floatx80(U64(0x8000000000000000)); - floatx80 upperLim = int64_to_floatx80(U64(0x7fffffffffffffff)); + floatx80 lowerLim = int64_to_floatx80(0x8000000000000000U); + floatx80 upperLim = int64_to_floatx80(0x7fffffffffffffffU); m_x87_sw &= ~X87_SW_C1; if (!floatx80_lt(fx80, lowerLim) && floatx80_le(fx80, upperLim)) m64int = floatx80_to_int64(fx80); else - m64int = U64(0x8000000000000000); + m64int = 0x8000000000000000U; } uint32_t ea = GetEA(modrm, 1); @@ -3210,9 +3210,9 @@ void i386_device::x87_fldl2t(uint8_t modrm) value.high = 0x4000; if (X87_RC == X87_CW_RC_UP) - value.low = U64(0xd49a784bcd1b8aff); + value.low = 0xd49a784bcd1b8affU; else - value.low = U64(0xd49a784bcd1b8afe); + value.low = 0xd49a784bcd1b8afeU; m_x87_sw &= ~X87_SW_C1; } @@ -3243,9 +3243,9 @@ void i386_device::x87_fldl2e(uint8_t modrm) value.high = 0x3fff; if (rc == X87_CW_RC_UP || rc == X87_CW_RC_NEAREST) - value.low = U64(0xb8aa3b295c17f0bc); + value.low = 0xb8aa3b295c17f0bcU; else - value.low = U64(0xb8aa3b295c17f0bb); + value.low = 0xb8aa3b295c17f0bbU; m_x87_sw &= ~X87_SW_C1; } @@ -3276,9 +3276,9 @@ void i386_device::x87_fldpi(uint8_t modrm) value.high = 0x4000; if (rc == X87_CW_RC_UP || rc == X87_CW_RC_NEAREST) - value.low = U64(0xc90fdaa22168c235); + value.low = 0xc90fdaa22168c235U; else - value.low = U64(0xc90fdaa22168c234); + value.low = 0xc90fdaa22168c234U; m_x87_sw &= ~X87_SW_C1; } @@ -3309,9 +3309,9 @@ void i386_device::x87_fldlg2(uint8_t modrm) value.high = 0x3ffd; if (rc == X87_CW_RC_UP || rc == X87_CW_RC_NEAREST) - value.low = U64(0x9a209a84fbcff799); + value.low = 0x9a209a84fbcff799U; else - value.low = U64(0x9a209a84fbcff798); + value.low = 0x9a209a84fbcff798U; m_x87_sw &= ~X87_SW_C1; } @@ -3342,9 +3342,9 @@ void i386_device::x87_fldln2(uint8_t modrm) value.high = 0x3ffe; if (rc == X87_CW_RC_UP || rc == X87_CW_RC_NEAREST) - value.low = U64(0xb17217f7d1cf79ac); + value.low = 0xb17217f7d1cf79acU; else - value.low = U64(0xb17217f7d1cf79ab); + value.low = 0xb17217f7d1cf79abU; m_x87_sw &= ~X87_SW_C1; } diff --git a/src/devices/cpu/i4004/4004dasm.cpp b/src/devices/cpu/i4004/4004dasm.cpp index 7b521a2aa86..09cef4a9873 100644 --- a/src/devices/cpu/i4004/4004dasm.cpp +++ b/src/devices/cpu/i4004/4004dasm.cpp @@ -13,7 +13,7 @@ #define OP(A) oprom[(A) - PC] #define ARG(A) opram[(A) - PC] -static offs_t internal_disasm_i4004(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(i4004) { uint32_t flags = 0; uint8_t op; @@ -131,13 +131,3 @@ static offs_t internal_disasm_i4004(cpu_device *device, std::ostream &stream, of } return (pc - PC) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(i4004) -{ - std::ostringstream stream; - offs_t result = internal_disasm_i4004(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/i4004/i4004.cpp b/src/devices/cpu/i4004/i4004.cpp index d0db65e6d63..eaaae3b8148 100644 --- a/src/devices/cpu/i4004/i4004.cpp +++ b/src/devices/cpu/i4004/i4004.cpp @@ -522,8 +522,8 @@ void i4004_cpu_device::state_string_export(const device_state_entry &entry, std: } } -offs_t i4004_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i4004_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( i4004 ); - return CPU_DISASSEMBLE_NAME(i4004)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i4004)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/i4004/i4004.h b/src/devices/cpu/i4004/i4004.h index 1b875f10aee..7bc3d17427b 100644 --- a/src/devices/cpu/i4004/i4004.h +++ b/src/devices/cpu/i4004/i4004.h @@ -59,7 +59,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; uint8_t ROP(); uint8_t READ_ROM(); diff --git a/src/devices/cpu/i8008/8008dasm.cpp b/src/devices/cpu/i8008/8008dasm.cpp index 7cefac8e71e..66be08a40b7 100644 --- a/src/devices/cpu/i8008/8008dasm.cpp +++ b/src/devices/cpu/i8008/8008dasm.cpp @@ -16,7 +16,7 @@ static const char reg[] = { 'a', 'b', 'c', 'd', 'e', 'h', 'l', 'm' }; static const char flag_names[] = { 'c', 'z', 's', 'p' }; -static offs_t internal_disasm_i8008(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(i8008) { uint32_t flags = 0; unsigned PC = pc; @@ -113,13 +113,3 @@ static offs_t internal_disasm_i8008(cpu_device *device, std::ostream &stream, of } return (pc - PC) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(i8008) -{ - std::ostringstream stream; - offs_t result = internal_disasm_i8008(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/i8008/i8008.cpp b/src/devices/cpu/i8008/i8008.cpp index a323ed077c4..f55dac14b88 100644 --- a/src/devices/cpu/i8008/i8008.cpp +++ b/src/devices/cpu/i8008/i8008.cpp @@ -226,10 +226,10 @@ uint32_t i8008_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t i8008_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i8008_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( i8008 ); - return CPU_DISASSEMBLE_NAME(i8008)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i8008)(this, stream, pc, oprom, opram, options); } //************************************************************************** diff --git a/src/devices/cpu/i8008/i8008.h b/src/devices/cpu/i8008/i8008.h index 4ba000f3fe9..fde75d3948a 100644 --- a/src/devices/cpu/i8008/i8008.h +++ b/src/devices/cpu/i8008/i8008.h @@ -50,7 +50,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void execute_one(int opcode); diff --git a/src/devices/cpu/i8085/8085dasm.cpp b/src/devices/cpu/i8085/8085dasm.cpp index 1db5fe0b23f..037d5d9fde1 100644 --- a/src/devices/cpu/i8085/8085dasm.cpp +++ b/src/devices/cpu/i8085/8085dasm.cpp @@ -18,7 +18,7 @@ #define ARG(A) opram[(A) - PC] #define ARGW(A) (opram[(A) - PC] | (opram[(A) + 1 - PC] << 8)) -static offs_t internal_disasm_i8085(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(i8085) { uint32_t flags = 0; uint8_t op; @@ -543,13 +543,3 @@ static offs_t internal_disasm_i8085(cpu_device *device, std::ostream &stream, of } return (pc - PC) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(i8085) -{ - std::ostringstream stream; - offs_t result = internal_disasm_i8085(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/i8085/i8085.cpp b/src/devices/cpu/i8085/i8085.cpp index 09f4a1375d5..f60e594bad9 100644 --- a/src/devices/cpu/i8085/i8085.cpp +++ b/src/devices/cpu/i8085/i8085.cpp @@ -1094,8 +1094,8 @@ void i8085a_cpu_device::execute_set_input(int irqline, int state) } -offs_t i8085a_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i8085a_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( i8085 ); - return CPU_DISASSEMBLE_NAME(i8085)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i8085)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/i8085/i8085.h b/src/devices/cpu/i8085/i8085.h index c1e8c33e70b..71074291d1a 100644 --- a/src/devices/cpu/i8085/i8085.h +++ b/src/devices/cpu/i8085/i8085.h @@ -88,7 +88,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 3; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/i8089/i8089.cpp b/src/devices/cpu/i8089/i8089.cpp index 2b20984c061..234e2e33503 100644 --- a/src/devices/cpu/i8089/i8089.cpp +++ b/src/devices/cpu/i8089/i8089.cpp @@ -148,10 +148,10 @@ const address_space_config *i8089_device::memory_space_config(address_spacenum s // disasm_disassemble - disassembler //------------------------------------------------- -offs_t i8089_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i8089_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(i8089); - return CPU_DISASSEMBLE_NAME(i8089)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i8089)(this, stream, pc, oprom, opram, options); } //------------------------------------------------- diff --git a/src/devices/cpu/i8089/i8089.h b/src/devices/cpu/i8089/i8089.h index 0231f6c3b8a..4354ceffdf2 100644 --- a/src/devices/cpu/i8089/i8089.h +++ b/src/devices/cpu/i8089/i8089.h @@ -85,7 +85,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 7; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/i8089/i8089_dasm.cpp b/src/devices/cpu/i8089/i8089_dasm.cpp index e40e831f337..bbc4ab1a59e 100644 --- a/src/devices/cpu/i8089/i8089_dasm.cpp +++ b/src/devices/cpu/i8089/i8089_dasm.cpp @@ -437,20 +437,10 @@ const char *i8089_instruction::m_reg[] = "ga", "gb", "gc", "bc", "tp", "ix", "cc", "mc" }; -static offs_t internal_disasm_i8089(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(i8089) { std::unique_ptr i = std::make_unique(pc, oprom); stream << i->buffer(); offs_t result = i->length() | i->flags(); return result; } - - -CPU_DISASSEMBLE(i8089) -{ - std::ostringstream stream; - offs_t result = internal_disasm_i8089(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/i86/i86.cpp b/src/devices/cpu/i86/i86.cpp index 799ab25685d..1bcc2bff719 100644 --- a/src/devices/cpu/i86/i86.cpp +++ b/src/devices/cpu/i86/i86.cpp @@ -508,14 +508,10 @@ void i8086_common_cpu_device::execute_set_input( int inptnum, int state ) } } -offs_t i8086_common_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i8086_common_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern int i386_dasm_one(std::ostream &stream, offs_t eip, const uint8_t *oprom, int mode); - std::ostringstream stream; - offs_t result = i386_dasm_one(stream, pc, oprom, 1); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; + return i386_dasm_one(stream, pc, oprom, 1); } uint8_t i8086_common_cpu_device::read_port_byte(uint16_t port) diff --git a/src/devices/cpu/i86/i86.h b/src/devices/cpu/i86/i86.h index 6004158d8c1..9013de54f2e 100644 --- a/src/devices/cpu/i86/i86.h +++ b/src/devices/cpu/i86/i86.h @@ -124,7 +124,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/i860/i860.cpp b/src/devices/cpu/i860/i860.cpp index fff1efec75a..199a410b2db 100644 --- a/src/devices/cpu/i860/i860.cpp +++ b/src/devices/cpu/i860/i860.cpp @@ -225,10 +225,10 @@ void i860_cpu_device::device_reset() } -offs_t i860_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i860_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( i860 ); - return CPU_DISASSEMBLE_NAME(i860)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i860)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/i860/i860.h b/src/devices/cpu/i860/i860.h index 60d2bcd4c65..d107f111c97 100644 --- a/src/devices/cpu/i860/i860.h +++ b/src/devices/cpu/i860/i860.h @@ -82,7 +82,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/i860/i860dis.cpp b/src/devices/cpu/i860/i860dis.cpp index 8b5a6c95cb8..a1230d570cc 100644 --- a/src/devices/cpu/i860/i860dis.cpp +++ b/src/devices/cpu/i860/i860dis.cpp @@ -694,9 +694,5 @@ static offs_t internal_disasm_i860(cpu_device *device, std::ostream &main_stream CPU_DISASSEMBLE(i860) { - std::ostringstream stream; - offs_t result = internal_disasm_i860(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; + return internal_disasm_i860(device, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/i960/i960.cpp b/src/devices/cpu/i960/i960.cpp index 4be6f937e42..1f9db2d385e 100644 --- a/src/devices/cpu/i960/i960.cpp +++ b/src/devices/cpu/i960/i960.cpp @@ -2117,8 +2117,8 @@ void i960_cpu_device::device_reset() } -offs_t i960_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i960_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( i960 ); - return CPU_DISASSEMBLE_NAME(i960)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i960)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/i960/i960.h b/src/devices/cpu/i960/i960.h index a7ebe01bfd0..12de144357c 100644 --- a/src/devices/cpu/i960/i960.h +++ b/src/devices/cpu/i960/i960.h @@ -100,7 +100,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/i960/i960dis.cpp b/src/devices/cpu/i960/i960dis.cpp index 95be77f0aa0..4def96dad4d 100644 --- a/src/devices/cpu/i960/i960dis.cpp +++ b/src/devices/cpu/i960/i960dis.cpp @@ -293,7 +293,7 @@ static void i960_disassemble(disassemble_t *diss) -static offs_t internal_disasm_i960(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(i960) { disassemble_t dis(stream, pc, oprom); @@ -301,13 +301,3 @@ static offs_t internal_disasm_i960(cpu_device *device, std::ostream &stream, off return dis.IPinc | dis.disflags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(i960) -{ - std::ostringstream stream; - offs_t result = internal_disasm_i960(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/ie15/ie15.cpp b/src/devices/cpu/ie15/ie15.cpp index 608d363e8a4..eeebbe2cd4c 100644 --- a/src/devices/cpu/ie15/ie15.cpp +++ b/src/devices/cpu/ie15/ie15.cpp @@ -171,10 +171,10 @@ uint32_t ie15_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t ie15_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t ie15_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( ie15 ); - return CPU_DISASSEMBLE_NAME(ie15)(nullptr, buffer, pc, oprom, opram, 0); + return CPU_DISASSEMBLE_NAME(ie15)(nullptr, stream, pc, oprom, opram, 0); } //************************************************************************** diff --git a/src/devices/cpu/ie15/ie15.h b/src/devices/cpu/ie15/ie15.h index 823dd8f27b6..0fb6baeae06 100644 --- a/src/devices/cpu/ie15/ie15.h +++ b/src/devices/cpu/ie15/ie15.h @@ -50,7 +50,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void execute_one(int opcode); diff --git a/src/devices/cpu/ie15/ie15dasm.cpp b/src/devices/cpu/ie15/ie15dasm.cpp index d18fd3c81a6..f13e8f52e44 100644 --- a/src/devices/cpu/ie15/ie15dasm.cpp +++ b/src/devices/cpu/ie15/ie15dasm.cpp @@ -5,7 +5,7 @@ #define OP(A) oprom[(A) - PC] #define ARG(A) opram[(A) - PC] -static offs_t internal_disasm_ie15(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(ie15) { uint32_t flags = 0; uint8_t op; @@ -122,15 +122,6 @@ static offs_t internal_disasm_ie15(cpu_device *device, std::ostream &stream, off util::stream_format(stream, "ota #$%02x", op & 0x0f); break; } + return (pc - PC) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(ie15) -{ - std::ostringstream stream; - offs_t result = internal_disasm_ie15(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/jaguar/jagdasm.cpp b/src/devices/cpu/jaguar/jagdasm.cpp index 60e70aade59..5be18a327a3 100644 --- a/src/devices/cpu/jaguar/jagdasm.cpp +++ b/src/devices/cpu/jaguar/jagdasm.cpp @@ -182,24 +182,16 @@ static unsigned dasmjag(int variant, std::ostream &stream, unsigned pc, const ui util::stream_format(stream, "addqmod $%x,r%d", convert_zero[reg1], reg2); break; } - return size | flags | DASMFLAG_SUPPORTED; -} -static unsigned dasmjag(int variant, char *buffer, unsigned pc, const uint8_t *oprom) -{ - std::ostringstream stream; - unsigned result = dasmjag(variant, stream, pc, oprom); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; + return size | flags | DASMFLAG_SUPPORTED; } CPU_DISASSEMBLE( jaguargpu ) { - return dasmjag(JAGUAR_VARIANT_GPU, buffer, pc, oprom); + return dasmjag(JAGUAR_VARIANT_GPU, stream, pc, oprom); } CPU_DISASSEMBLE( jaguardsp ) { - return dasmjag(JAGUAR_VARIANT_DSP, buffer, pc, oprom); + return dasmjag(JAGUAR_VARIANT_DSP, stream, pc, oprom); } diff --git a/src/devices/cpu/jaguar/jaguar.cpp b/src/devices/cpu/jaguar/jaguar.cpp index 2906245858d..1a3d7d9f41e 100644 --- a/src/devices/cpu/jaguar/jaguar.cpp +++ b/src/devices/cpu/jaguar/jaguar.cpp @@ -1430,15 +1430,15 @@ WRITE32_MEMBER( jaguardsp_cpu_device::ctrl_w ) } -offs_t jaguargpu_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t jaguargpu_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( jaguargpu ); - return CPU_DISASSEMBLE_NAME(jaguargpu)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(jaguargpu)(this, stream, pc, oprom, opram, options); } -offs_t jaguardsp_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t jaguardsp_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( jaguardsp ); - return CPU_DISASSEMBLE_NAME(jaguardsp)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(jaguardsp)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/jaguar/jaguar.h b/src/devices/cpu/jaguar/jaguar.h index cc71cc35887..e01afb5f24f 100644 --- a/src/devices/cpu/jaguar/jaguar.h +++ b/src/devices/cpu/jaguar/jaguar.h @@ -258,7 +258,7 @@ public: protected: virtual void execute_run() override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; @@ -275,7 +275,7 @@ protected: virtual uint32_t execute_input_lines() const override { return 6; } virtual void execute_run() override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; diff --git a/src/devices/cpu/lc8670/lc8670.h b/src/devices/cpu/lc8670/lc8670.h index 51c78b602c9..e2fc9582e48 100644 --- a/src/devices/cpu/lc8670/lc8670.h +++ b/src/devices/cpu/lc8670/lc8670.h @@ -118,7 +118,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: // helpers diff --git a/src/devices/cpu/lc8670/lc8670dsm.cpp b/src/devices/cpu/lc8670/lc8670dsm.cpp index af2672a88bc..d1a223fc3a8 100644 --- a/src/devices/cpu/lc8670/lc8670dsm.cpp +++ b/src/devices/cpu/lc8670/lc8670dsm.cpp @@ -151,7 +151,7 @@ void lc8670_cpu_device::dasm_arg(uint8_t op, char *buffer, offs_t pc, int arg, c // helper function //------------------------------------------------- -offs_t lc8670_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t lc8670_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { int pos = 0; char arg1[16], arg2[16]; @@ -161,18 +161,15 @@ offs_t lc8670_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint int op_idx = decode_op(op); const dasm_entry *inst = &s_dasm_table[op_idx]; - buffer += sprintf(buffer,"%-8s", inst->str); + util::stream_format(stream, "%-8s", inst->str); dasm_arg(op, inst->inv ? arg2 : arg1, pc+0, inst->arg1, oprom, pos); dasm_arg(op, inst->inv ? arg1 : arg2, pc+1, inst->arg2, oprom, pos); - strcat(buffer, arg1); + stream << arg1; if (inst->arg2 != OP_NULL) - { - strcat(buffer, ","); - strcat(buffer, arg2); - } + stream << "," << arg2; return pos; } diff --git a/src/devices/cpu/lh5801/5801dasm.cpp b/src/devices/cpu/lh5801/5801dasm.cpp index 86cb6bf6e06..2cf6f105b8d 100644 --- a/src/devices/cpu/lh5801/5801dasm.cpp +++ b/src/devices/cpu/lh5801/5801dasm.cpp @@ -663,7 +663,7 @@ const Entry Entry::table_fd[0x100]={ } // anonymous namespace -static offs_t internal_disasm_lh5801(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(lh5801) { int pos = 0; int oper; @@ -747,13 +747,3 @@ static offs_t internal_disasm_lh5801(cpu_device *device, std::ostream &stream, o return pos; } - - -CPU_DISASSEMBLE(lh5801) -{ - std::ostringstream stream; - offs_t result = internal_disasm_lh5801(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/lh5801/lh5801.cpp b/src/devices/cpu/lh5801/lh5801.cpp index 67a09e2ae51..80c218d9e47 100644 --- a/src/devices/cpu/lh5801/lh5801.cpp +++ b/src/devices/cpu/lh5801/lh5801.cpp @@ -248,8 +248,8 @@ void lh5801_cpu_device::execute_set_input(int irqline, int state) } } -offs_t lh5801_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t lh5801_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( lh5801 ); - return CPU_DISASSEMBLE_NAME(lh5801)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(lh5801)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/lh5801/lh5801.h b/src/devices/cpu/lh5801/lh5801.h index 6df2bb06a37..fba37fed2c7 100644 --- a/src/devices/cpu/lh5801/lh5801.h +++ b/src/devices/cpu/lh5801/lh5801.h @@ -95,7 +95,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 5; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/lr35902/lr35902.cpp b/src/devices/cpu/lr35902/lr35902.cpp index d5fcb710c46..137337be5be 100644 --- a/src/devices/cpu/lr35902/lr35902.cpp +++ b/src/devices/cpu/lr35902/lr35902.cpp @@ -226,10 +226,10 @@ void lr35902_cpu_device::device_reset() } -offs_t lr35902_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t lr35902_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( lr35902 ); - return CPU_DISASSEMBLE_NAME(lr35902)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(lr35902)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/lr35902/lr35902.h b/src/devices/cpu/lr35902/lr35902.h index 4288eac51dc..ad032fbebba 100644 --- a/src/devices/cpu/lr35902/lr35902.h +++ b/src/devices/cpu/lr35902/lr35902.h @@ -91,7 +91,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; inline void cycles_passed(uint8_t cycles); inline uint8_t mem_read_byte(uint16_t addr); diff --git a/src/devices/cpu/lr35902/lr35902d.cpp b/src/devices/cpu/lr35902/lr35902d.cpp index 735befe10a4..a723cac408d 100644 --- a/src/devices/cpu/lr35902/lr35902d.cpp +++ b/src/devices/cpu/lr35902/lr35902d.cpp @@ -190,7 +190,7 @@ static const lr35902dasm mnemonic_main[256]= { * Disassemble opcode at PC and return number of bytes it takes ****************************************************************************/ -static offs_t internal_disasm_lr35902(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(lr35902) { const lr35902dasm *d; const char /* *symbol,*/ *src; @@ -273,13 +273,3 @@ static offs_t internal_disasm_lr35902(cpu_device *device, std::ostream &stream, return pos | s_flags[d->mnemonic] | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(lr35902) -{ - std::ostringstream stream; - offs_t result = internal_disasm_lr35902(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/m37710/m37710.cpp b/src/devices/cpu/m37710/m37710.cpp index ea4356f6a26..8da01b9b843 100644 --- a/src/devices/cpu/m37710/m37710.cpp +++ b/src/devices/cpu/m37710/m37710.cpp @@ -939,13 +939,13 @@ void m37710_cpu_device::m37710_set_irq_line(int line, int state) CPU_DISASSEMBLE( m37710 ) { - return m7700_disassemble(buffer, (pc&0xffff), pc>>16, oprom, 0, 0); + return m7700_disassemble(stream, (pc&0xffff), pc>>16, oprom, 0, 0); } -offs_t m37710_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m37710_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return m7700_disassemble(buffer, (pc&0xffff), pc>>16, oprom, FLAG_M, FLAG_X); + return m7700_disassemble(stream, (pc&0xffff), pc>>16, oprom, FLAG_M, FLAG_X); } diff --git a/src/devices/cpu/m37710/m37710.h b/src/devices/cpu/m37710/m37710.h index 32ec57ee04a..d775b8564c3 100644 --- a/src/devices/cpu/m37710/m37710.h +++ b/src/devices/cpu/m37710/m37710.h @@ -122,7 +122,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 6; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/m37710/m7700ds.cpp b/src/devices/cpu/m37710/m7700ds.cpp index 2d1b664086a..ed81e320a3c 100644 --- a/src/devices/cpu/m37710/m7700ds.cpp +++ b/src/devices/cpu/m37710/m7700ds.cpp @@ -636,26 +636,7 @@ int m7700_disassemble(std::ostream &stream, unsigned int pc, unsigned int pb, co return length | flags | DASMFLAG_SUPPORTED; } -int m7700_disassemble(char *buffer, unsigned int pc, unsigned int pb, const uint8_t *oprom, int m_flag, int x_flag) -{ - std::ostringstream stream; - offs_t result = m7700_disassemble(stream, pc, pb, oprom, m_flag, x_flag); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - -static offs_t internal_disasm_m37710_generic(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(m37710_generic) { return m7700_disassemble(stream, (pc&0xffff), pc>>16, oprom, 0, 0); } - - -CPU_DISASSEMBLE(m37710_generic) -{ - std::ostringstream stream; - offs_t result = internal_disasm_m37710_generic(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/m37710/m7700ds.h b/src/devices/cpu/m37710/m7700ds.h index 12bec764f30..061070bf407 100644 --- a/src/devices/cpu/m37710/m7700ds.h +++ b/src/devices/cpu/m37710/m7700ds.h @@ -19,6 +19,5 @@ All rights reserved. */ int m7700_disassemble(std::ostream &stream, unsigned int pc, unsigned int pb, const uint8_t *oprom, int m_flag, int x_flag); -int m7700_disassemble(char* buff, unsigned int pc, unsigned int pb, const uint8_t *oprom, int m_flag, int x_flag); #endif /* __M7700DS_H__ */ diff --git a/src/devices/cpu/m6502/deco16.cpp b/src/devices/cpu/m6502/deco16.cpp index 482c7b1c0b7..d6ad1c7077a 100644 --- a/src/devices/cpu/m6502/deco16.cpp +++ b/src/devices/cpu/m6502/deco16.cpp @@ -22,9 +22,9 @@ deco16_device::deco16_device(const machine_config &mconfig, const char *tag, dev { } -offs_t deco16_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t deco16_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } diff --git a/src/devices/cpu/m6502/deco16.h b/src/devices/cpu/m6502/deco16.h index 3afc7af081f..f018ddec056 100644 --- a/src/devices/cpu/m6502/deco16.h +++ b/src/devices/cpu/m6502/deco16.h @@ -19,7 +19,7 @@ public: static const disasm_entry disasm_entries[0x100]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; diff --git a/src/devices/cpu/m6502/m4510.cpp b/src/devices/cpu/m6502/m4510.cpp index bfb89dbcdc8..61a4f9d8c8f 100644 --- a/src/devices/cpu/m6502/m4510.cpp +++ b/src/devices/cpu/m6502/m4510.cpp @@ -26,9 +26,9 @@ m4510_device::m4510_device(const machine_config &mconfig, const char *tag, devic sprogram_config.m_page_shift = 13; } -offs_t m4510_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m4510_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } void m4510_device::device_start() diff --git a/src/devices/cpu/m6502/m4510.h b/src/devices/cpu/m6502/m4510.h index 97629581531..62e55ea7a8c 100644 --- a/src/devices/cpu/m6502/m4510.h +++ b/src/devices/cpu/m6502/m4510.h @@ -19,7 +19,7 @@ public: static const disasm_entry disasm_entries[0x100]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; diff --git a/src/devices/cpu/m6502/m6502.cpp b/src/devices/cpu/m6502/m6502.cpp index 3562e6c8788..af1110957cb 100644 --- a/src/devices/cpu/m6502/m6502.cpp +++ b/src/devices/cpu/m6502/m6502.cpp @@ -628,15 +628,6 @@ offs_t m6502_device::disassemble_generic(std::ostream &stream, offs_t pc, const return flags; } -offs_t m6502_device::disassemble_generic(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *table) -{ - std::ostringstream stream; - offs_t result = disassemble_generic(stream, pc, oprom, opram, options, table); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - void m6502_device::prefetch() { sync = true; @@ -673,9 +664,9 @@ void m6502_device::set_nz(uint8_t v) P |= F_Z; } -offs_t m6502_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m6502_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } diff --git a/src/devices/cpu/m6502/m6502.h b/src/devices/cpu/m6502/m6502.h index e84fe37b8e0..bb112697431 100644 --- a/src/devices/cpu/m6502/m6502.h +++ b/src/devices/cpu/m6502/m6502.h @@ -146,7 +146,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config program_config, sprogram_config; @@ -172,7 +172,6 @@ protected: static const disasm_entry disasm_entries[0x100]; offs_t disassemble_generic(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *table); - offs_t disassemble_generic(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *table); uint8_t read(uint16_t adr) { return mintf->read(adr); } uint8_t read_9(uint16_t adr) { return mintf->read_9(adr); } void write(uint16_t adr, uint8_t val) { mintf->write(adr, val); } diff --git a/src/devices/cpu/m6502/m6509.cpp b/src/devices/cpu/m6502/m6509.cpp index 459021a9bc6..e0fcedd75cf 100644 --- a/src/devices/cpu/m6502/m6509.cpp +++ b/src/devices/cpu/m6502/m6509.cpp @@ -54,9 +54,9 @@ void m6509_device::state_export(const device_state_entry &entry) } } -offs_t m6509_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m6509_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } diff --git a/src/devices/cpu/m6502/m6509.h b/src/devices/cpu/m6502/m6509.h index ec9e8e6690a..349ea8b20f7 100644 --- a/src/devices/cpu/m6502/m6509.h +++ b/src/devices/cpu/m6502/m6509.h @@ -19,7 +19,7 @@ public: static const disasm_entry disasm_entries[0x100]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; diff --git a/src/devices/cpu/m6502/m6510.cpp b/src/devices/cpu/m6502/m6510.cpp index 26d881438f2..c2f59403780 100644 --- a/src/devices/cpu/m6502/m6510.cpp +++ b/src/devices/cpu/m6502/m6510.cpp @@ -37,9 +37,9 @@ void m6510_device::set_pulls(uint8_t _pullup, uint8_t _floating) floating = _floating; } -offs_t m6510_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m6510_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } void m6510_device::device_start() diff --git a/src/devices/cpu/m6502/m6510.h b/src/devices/cpu/m6502/m6510.h index 101d6bb2c71..e51bf21e718 100644 --- a/src/devices/cpu/m6502/m6510.h +++ b/src/devices/cpu/m6502/m6510.h @@ -34,7 +34,7 @@ public: static const disasm_entry disasm_entries[0x100]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; diff --git a/src/devices/cpu/m6502/m65c02.cpp b/src/devices/cpu/m6502/m65c02.cpp index 1fe8882c63c..1d9d158bf29 100644 --- a/src/devices/cpu/m6502/m65c02.cpp +++ b/src/devices/cpu/m6502/m65c02.cpp @@ -24,9 +24,9 @@ m65c02_device::m65c02_device(const machine_config &mconfig, device_type type, co { } -offs_t m65c02_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m65c02_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } #include "cpu/m6502/m65c02.hxx" diff --git a/src/devices/cpu/m6502/m65c02.h b/src/devices/cpu/m6502/m65c02.h index ff1dbc0c780..5d6d1503c2f 100644 --- a/src/devices/cpu/m6502/m65c02.h +++ b/src/devices/cpu/m6502/m65c02.h @@ -21,7 +21,7 @@ public: static const disasm_entry disasm_entries[0x100]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; diff --git a/src/devices/cpu/m6502/m65ce02.cpp b/src/devices/cpu/m6502/m65ce02.cpp index ce19861f70c..f45d3edcf47 100644 --- a/src/devices/cpu/m6502/m65ce02.cpp +++ b/src/devices/cpu/m6502/m65ce02.cpp @@ -23,9 +23,9 @@ m65ce02_device::m65ce02_device(const machine_config &mconfig, device_type type, { } -offs_t m65ce02_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m65ce02_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } void m65ce02_device::init() diff --git a/src/devices/cpu/m6502/m65ce02.h b/src/devices/cpu/m6502/m65ce02.h index 2046975d103..019ced7d0b2 100644 --- a/src/devices/cpu/m6502/m65ce02.h +++ b/src/devices/cpu/m6502/m65ce02.h @@ -20,7 +20,7 @@ public: static const disasm_entry disasm_entries[0x100]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; diff --git a/src/devices/cpu/m6502/m740.cpp b/src/devices/cpu/m6502/m740.cpp index 005446487db..1f4c1cd45a4 100644 --- a/src/devices/cpu/m6502/m740.cpp +++ b/src/devices/cpu/m6502/m740.cpp @@ -23,9 +23,9 @@ m740_device::m740_device(const machine_config &mconfig, device_type type, const { } -offs_t m740_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m740_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } void m740_device::device_start() diff --git a/src/devices/cpu/m6502/m740.h b/src/devices/cpu/m6502/m740.h index 214cede5edc..2e94a82980a 100644 --- a/src/devices/cpu/m6502/m740.h +++ b/src/devices/cpu/m6502/m740.h @@ -46,7 +46,7 @@ public: virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; virtual void execute_set_input(int inputnum, int state) override; diff --git a/src/devices/cpu/m6502/n2a03.cpp b/src/devices/cpu/m6502/n2a03.cpp index d818813540d..338ee91c3e5 100644 --- a/src/devices/cpu/m6502/n2a03.cpp +++ b/src/devices/cpu/m6502/n2a03.cpp @@ -56,9 +56,9 @@ n2a03_device::n2a03_device(const machine_config &mconfig, const char *tag, devic { } -offs_t n2a03_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t n2a03_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } void n2a03_device::device_start() diff --git a/src/devices/cpu/m6502/n2a03.h b/src/devices/cpu/m6502/n2a03.h index 9d01b5b6f83..9a236839c59 100644 --- a/src/devices/cpu/m6502/n2a03.h +++ b/src/devices/cpu/m6502/n2a03.h @@ -22,7 +22,7 @@ public: static const disasm_entry disasm_entries[0x100]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; virtual void device_clock_changed() override; diff --git a/src/devices/cpu/m6502/r65c02.cpp b/src/devices/cpu/m6502/r65c02.cpp index fe0c4826a83..15594594360 100644 --- a/src/devices/cpu/m6502/r65c02.cpp +++ b/src/devices/cpu/m6502/r65c02.cpp @@ -23,9 +23,9 @@ r65c02_device::r65c02_device(const machine_config &mconfig, device_type type, co { } -offs_t r65c02_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t r65c02_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries); } #include "cpu/m6502/r65c02.hxx" diff --git a/src/devices/cpu/m6502/r65c02.h b/src/devices/cpu/m6502/r65c02.h index d25b1facf40..4a406654422 100644 --- a/src/devices/cpu/m6502/r65c02.h +++ b/src/devices/cpu/m6502/r65c02.h @@ -20,7 +20,7 @@ public: static const disasm_entry disasm_entries[0x100]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; }; diff --git a/src/devices/cpu/m6800/6800dasm.cpp b/src/devices/cpu/m6800/6800dasm.cpp index 1b33f96f599..781af28f468 100644 --- a/src/devices/cpu/m6800/6800dasm.cpp +++ b/src/devices/cpu/m6800/6800dasm.cpp @@ -249,51 +249,42 @@ static unsigned Dasm680x (int subtype, std::ostream &stream, unsigned pc, const } } -static unsigned Dasm680x(int subtype, char *buffer, unsigned pc, const uint8_t *oprom, const uint8_t *opram) -{ - std::ostringstream stream; - unsigned result = Dasm680x(subtype, stream, pc, oprom, opram); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE( m6800 ) { - return Dasm680x(6800,buffer,pc,oprom,opram); + return Dasm680x(6800,stream,pc,oprom,opram); } CPU_DISASSEMBLE( m6801 ) { - return Dasm680x(6801,buffer,pc,oprom,opram); + return Dasm680x(6801,stream,pc,oprom,opram); } CPU_DISASSEMBLE( m6802 ) { - return Dasm680x(6802,buffer,pc,oprom,opram); + return Dasm680x(6802,stream,pc,oprom,opram); } CPU_DISASSEMBLE( m6803 ) { - return Dasm680x(6803,buffer,pc,oprom,opram); + return Dasm680x(6803,stream,pc,oprom,opram); } CPU_DISASSEMBLE( m6808 ) { - return Dasm680x(6808,buffer,pc,oprom,opram); + return Dasm680x(6808,stream,pc,oprom,opram); } CPU_DISASSEMBLE( hd6301 ) { - return Dasm680x(6301,buffer,pc,oprom,opram); + return Dasm680x(6301,stream,pc,oprom,opram); } CPU_DISASSEMBLE( hd63701 ) { - return Dasm680x(63701,buffer,pc,oprom,opram); + return Dasm680x(63701,stream,pc,oprom,opram); } CPU_DISASSEMBLE( nsc8105 ) { - return Dasm680x(8105,buffer,pc,oprom,opram); + return Dasm680x(8105,stream,pc,oprom,opram); } diff --git a/src/devices/cpu/m6800/m6800.cpp b/src/devices/cpu/m6800/m6800.cpp index 4fbdc76c58a..520e46d1c24 100644 --- a/src/devices/cpu/m6800/m6800.cpp +++ b/src/devices/cpu/m6800/m6800.cpp @@ -1752,57 +1752,57 @@ void m6801_cpu_device::m6801_clock_serial() } } -offs_t m6800_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m6800_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( m6800 ); - return CPU_DISASSEMBLE_NAME(m6800)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(m6800)(this, stream, pc, oprom, opram, options); } -offs_t m6801_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m6801_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( m6801 ); - return CPU_DISASSEMBLE_NAME(m6801)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(m6801)(this, stream, pc, oprom, opram, options); } -offs_t m6802_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m6802_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( m6802 ); - return CPU_DISASSEMBLE_NAME(m6802)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(m6802)(this, stream, pc, oprom, opram, options); } -offs_t m6803_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m6803_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( m6803 ); - return CPU_DISASSEMBLE_NAME(m6803)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(m6803)(this, stream, pc, oprom, opram, options); } -offs_t m6808_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m6808_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( m6808 ); - return CPU_DISASSEMBLE_NAME(m6808)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(m6808)(this, stream, pc, oprom, opram, options); } -offs_t hd6301_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t hd6301_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( hd6301 ); - return CPU_DISASSEMBLE_NAME(hd6301)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(hd6301)(this, stream, pc, oprom, opram, options); } -offs_t hd63701_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t hd63701_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( hd63701 ); - return CPU_DISASSEMBLE_NAME(hd63701)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(hd63701)(this, stream, pc, oprom, opram, options); } -offs_t nsc8105_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t nsc8105_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( nsc8105 ); - return CPU_DISASSEMBLE_NAME(nsc8105)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(nsc8105)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/m6800/m6800.h b/src/devices/cpu/m6800/m6800.h index cd36cc7ff3e..c81f98c6fb3 100644 --- a/src/devices/cpu/m6800/m6800.h +++ b/src/devices/cpu/m6800/m6800.h @@ -109,7 +109,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; address_space_config m_decrypted_opcodes_config; @@ -459,7 +459,7 @@ public: protected: virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const override { return (clocks + 4 - 1) / 4; } virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const override { return (cycles * 4); } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; @@ -472,7 +472,7 @@ public: protected: virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const override { return (clocks + 4 - 1) / 4; } virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const override { return (cycles * 4); } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; @@ -482,7 +482,7 @@ public: m6803_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; @@ -492,7 +492,7 @@ public: m6808_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; @@ -503,7 +503,7 @@ public: hd6301_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; @@ -513,7 +513,7 @@ public: hd63701_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; @@ -523,7 +523,7 @@ public: nsc8105_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; diff --git a/src/devices/cpu/m68000/m68000.h b/src/devices/cpu/m68000/m68000.h index c4ce844867f..c7b803fefdf 100644 --- a/src/devices/cpu/m68000/m68000.h +++ b/src/devices/cpu/m68000/m68000.h @@ -110,7 +110,6 @@ enum }; unsigned int m68k_disassemble_raw(std::ostream &stream, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type); -unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type); class m68000_base_device; @@ -137,7 +136,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 10; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; @@ -413,7 +412,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 10; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 4; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -432,7 +431,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 10; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 4; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -454,7 +453,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 10; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 4; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -473,7 +472,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 10; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 4; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -492,7 +491,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 10; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 4; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -511,7 +510,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -530,7 +529,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -549,7 +548,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -568,7 +567,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -587,7 +586,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -608,7 +607,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -627,7 +626,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -646,7 +645,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -665,7 +664,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -684,7 +683,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -703,7 +702,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 10; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 4; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -728,7 +727,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; @@ -749,7 +748,7 @@ public: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; }; virtual uint32_t disasm_max_opcode_bytes() const override { return 20; }; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint32_t execute_min_cycles() const override { return 2; }; virtual uint32_t execute_max_cycles() const override { return 158; }; diff --git a/src/devices/cpu/m68000/m68kcpu.cpp b/src/devices/cpu/m68000/m68kcpu.cpp index dd01540ae3e..244ad3149c8 100644 --- a/src/devices/cpu/m68000/m68kcpu.cpp +++ b/src/devices/cpu/m68000/m68kcpu.cpp @@ -2135,78 +2135,78 @@ void m68000_base_device::init_cpu_coldfire(void) CPU_DISASSEMBLE( dasm_m68000 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68000); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68000); } CPU_DISASSEMBLE( dasm_m68008 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68008); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68008); } CPU_DISASSEMBLE( dasm_m68010 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68010); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68010); } CPU_DISASSEMBLE( dasm_m68020 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68020); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68020); } CPU_DISASSEMBLE( dasm_m68030 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68030); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68030); } CPU_DISASSEMBLE( dasm_m68ec030 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68EC030); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68EC030); } CPU_DISASSEMBLE( dasm_m68040 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68040); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68040); } CPU_DISASSEMBLE( dasm_m68ec040 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68EC040); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68EC040); } CPU_DISASSEMBLE( dasm_m68lc040 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68LC040); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68LC040); } CPU_DISASSEMBLE( dasm_fscpu32 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_FSCPU32); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_FSCPU32); } CPU_DISASSEMBLE( dasm_coldfire ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_COLDFIRE); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_COLDFIRE); } -offs_t m68000_base_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, buffer, pc, oprom, opram, options); } -offs_t m68000_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, buffer, pc, oprom, opram, options); } -offs_t m68301_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, buffer, pc, oprom, opram, options); } -offs_t m68008_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68008)(this, buffer, pc, oprom, opram, options); } -offs_t m68008plcc_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68008)(this, buffer, pc, oprom, opram, options); } -offs_t m68010_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68010)(this, buffer, pc, oprom, opram, options); } -offs_t m68ec020_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, buffer, pc, oprom, opram, options); } -offs_t m68020_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, buffer, pc, oprom, opram, options); } -offs_t m68020fpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, buffer, pc, oprom, opram, options); } -offs_t m68020pmmu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, buffer, pc, oprom, opram, options); } -offs_t m68020hmmu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, buffer, pc, oprom, opram, options); } -offs_t m68ec030_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68ec030)(this, buffer, pc, oprom, opram, options); } -offs_t m68030_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68030)(this, buffer, pc, oprom, opram, options); } -offs_t m68ec040_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68ec040)(this, buffer, pc, oprom, opram, options); } -offs_t m68lc040_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68lc040)(this, buffer, pc, oprom, opram, options); } -offs_t m68040_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68040)(this, buffer, pc, oprom, opram, options); } -offs_t scc68070_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, buffer, pc, oprom, opram, options); } -offs_t fscpu32_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_fscpu32)(this, buffer, pc, oprom, opram, options); } -offs_t mcf5206e_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_coldfire)(this, buffer, pc, oprom, opram, options); } +offs_t m68000_base_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, stream, pc, oprom, opram, options); } +offs_t m68000_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, stream, pc, oprom, opram, options); } +offs_t m68301_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, stream, pc, oprom, opram, options); } +offs_t m68008_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68008)(this, stream, pc, oprom, opram, options); } +offs_t m68008plcc_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68008)(this, stream, pc, oprom, opram, options); } +offs_t m68010_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68010)(this, stream, pc, oprom, opram, options); } +offs_t m68ec020_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, stream, pc, oprom, opram, options); } +offs_t m68020_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, stream, pc, oprom, opram, options); } +offs_t m68020fpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, stream, pc, oprom, opram, options); } +offs_t m68020pmmu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, stream, pc, oprom, opram, options); } +offs_t m68020hmmu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68020)(this, stream, pc, oprom, opram, options); } +offs_t m68ec030_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68ec030)(this, stream, pc, oprom, opram, options); } +offs_t m68030_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68030)(this, stream, pc, oprom, opram, options); } +offs_t m68ec040_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68ec040)(this, stream, pc, oprom, opram, options); } +offs_t m68lc040_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68lc040)(this, stream, pc, oprom, opram, options); } +offs_t m68040_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68040)(this, stream, pc, oprom, opram, options); } +offs_t scc68070_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_m68000)(this, stream, pc, oprom, opram, options); } +offs_t fscpu32_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_fscpu32)(this, stream, pc, oprom, opram, options); } +offs_t mcf5206e_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { return CPU_DISASSEMBLE_NAME(dasm_coldfire)(this, stream, pc, oprom, opram, options); } /* Service an interrupt request and start exception processing */ diff --git a/src/devices/cpu/m68000/m68kcpu.h b/src/devices/cpu/m68000/m68kcpu.h index d9ad9656bf2..2d3d7c27fb0 100644 --- a/src/devices/cpu/m68000/m68kcpu.h +++ b/src/devices/cpu/m68000/m68kcpu.h @@ -153,7 +153,7 @@ class m68000_base_device; #define GET_MSB_16(A) ((A) & 0x8000) #define GET_MSB_17(A) ((A) & 0x10000) #define GET_MSB_32(A) ((A) & 0x80000000) -#define GET_MSB_33(A) ((A) & U64(0x100000000)) +#define GET_MSB_33(A) ((A) & 0x100000000U) /* Isolate nibbles */ #define LOW_NIBBLE(A) ((A) & 0x0f) @@ -168,8 +168,8 @@ class m68000_base_device; #define MASK_OUT_BELOW_16(A) ((A) & ~0xffff) /* No need to mask if we are 32 bit */ -#define MASK_OUT_ABOVE_32(A) ((A) & U64(0xffffffff)) -#define MASK_OUT_BELOW_32(A) ((A) & ~U64(0xffffffff)) +#define MASK_OUT_ABOVE_32(A) ((A) & u64(0xffffffffU)) +#define MASK_OUT_BELOW_32(A) ((A) & ~u64(0xffffffffU)) /* Shift & Rotate Macros. */ #define LSL(A, C) ((A) << (C)) diff --git a/src/devices/cpu/m68000/m68kdasm.cpp b/src/devices/cpu/m68000/m68kdasm.cpp index c92b73126c5..5bd074f731e 100644 --- a/src/devices/cpu/m68000/m68kdasm.cpp +++ b/src/devices/cpu/m68000/m68kdasm.cpp @@ -3900,15 +3900,6 @@ unsigned int m68k_disassemble_raw(std::ostream &stream, unsigned int pc, const u return result; } -unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type) -{ - std::ostringstream stream; - unsigned int result = m68k_disassemble_raw(stream, pc, opdata, argdata, cpu_type); - std::string stream_str = stream.str(); - strcpy(str_buff, stream_str.c_str()); - return result; -} - #ifdef UNUSED_FUNCTION /* Check if the instruction is a valid one */ unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type) @@ -4123,42 +4114,42 @@ unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cp CPU_DISASSEMBLE( m68000 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68000); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68000); } CPU_DISASSEMBLE( m68008 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68008); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68008); } CPU_DISASSEMBLE( m68010 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68010); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68010); } CPU_DISASSEMBLE( m68020 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68020); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68020); } CPU_DISASSEMBLE( m68030 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68030); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68030); } CPU_DISASSEMBLE( m68040 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68040); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_68040); } CPU_DISASSEMBLE( m68340 ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_FSCPU32); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_FSCPU32); } CPU_DISASSEMBLE( coldfire ) { - return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_COLDFIRE); + return m68k_disassemble_raw(stream, pc, oprom, opram, M68K_CPU_TYPE_COLDFIRE); } /* ======================================================================== */ diff --git a/src/devices/cpu/m68000/m68kfpu.hxx b/src/devices/cpu/m68000/m68kfpu.hxx index 9c11acd5fb8..e53f4ad899d 100644 --- a/src/devices/cpu/m68000/m68kfpu.hxx +++ b/src/devices/cpu/m68000/m68kfpu.hxx @@ -10,9 +10,9 @@ #define FPES_OE 0x00002000 #define FPAE_IOP 0x00000080 -#define DOUBLE_INFINITY U64(0x7ff0000000000000) -#define DOUBLE_EXPONENT U64(0x7ff0000000000000) -#define DOUBLE_MANTISSA U64(0x000fffffffffffff) +#define DOUBLE_INFINITY 0x7ff0000000000000U +#define DOUBLE_EXPONENT 0x7ff0000000000000U +#define DOUBLE_MANTISSA 0x000fffffffffffffU extern flag floatx80_is_nan( floatx80 a ); @@ -1239,27 +1239,27 @@ static void fpgen_rm_reg(m68000_base_device *m68k, uint16_t w2) { case 0x0: // Pi source.high = 0x4000; - source.low = U64(0xc90fdaa22168c235); + source.low = 0xc90fdaa22168c235U; break; case 0xb: // log10(2) source.high = 0x3ffd; - source.low = U64(0x9a209a84fbcff798); + source.low = 0x9a209a84fbcff798U; break; case 0xc: // e source.high = 0x4000; - source.low = U64(0xadf85458a2bb4a9b); + source.low = 0xadf85458a2bb4a9bU; break; case 0xd: // log2(e) source.high = 0x3fff; - source.low = U64(0xb8aa3b295c17f0bc); + source.low = 0xb8aa3b295c17f0bcU; break; case 0xe: // log10(e) source.high = 0x3ffd; - source.low = U64(0xde5bd8a937287195); + source.low = 0xde5bd8a937287195U; break; case 0xf: // 0.0 @@ -1268,12 +1268,12 @@ static void fpgen_rm_reg(m68000_base_device *m68k, uint16_t w2) case 0x30: // ln(2) source.high = 0x3ffe; - source.low = U64(0xb17217f7d1cf79ac); + source.low = 0xb17217f7d1cf79acU; break; case 0x31: // ln(10) source.high = 0x4000; - source.low = U64(0x935d8dddaaa8ac17); + source.low = 0x935d8dddaaa8ac17U; break; case 0x32: // 1 (or 100? manuals are unclear, but 1 would make more sense) @@ -1298,47 +1298,47 @@ static void fpgen_rm_reg(m68000_base_device *m68k, uint16_t w2) case 0x37: // 1.0e16 - can't get the right precision from int32_t so go "direct" with constants from h/w source.high = 0x4034; - source.low = U64(0x8e1bc9bf04000000); + source.low = 0x8e1bc9bf04000000U; break; case 0x38: // 1.0e32 source.high = 0x4069; - source.low = U64(0x9dc5ada82b70b59e); + source.low = 0x9dc5ada82b70b59eU; break; case 0x39: // 1.0e64 source.high = 0x40d3; - source.low = U64(0xc2781f49ffcfa6d5); + source.low = 0xc2781f49ffcfa6d5U; break; case 0x3a: // 1.0e128 source.high = 0x41a8; - source.low = U64(0x93ba47c980e98ce0); + source.low = 0x93ba47c980e98ce0U; break; case 0x3b: // 1.0e256 source.high = 0x4351; - source.low = U64(0xaa7eebfb9df9de8e); + source.low = 0xaa7eebfb9df9de8eU; break; case 0x3c: // 1.0e512 source.high = 0x46a3; - source.low = U64(0xe319a0aea60e91c7); + source.low = 0xe319a0aea60e91c7U; break; case 0x3d: // 1.0e1024 source.high = 0x4d48; - source.low = U64(0xc976758681750c17); + source.low = 0xc976758681750c17U; break; case 0x3e: // 1.0e2048 source.high = 0x5a92; - source.low = U64(0x9e8b3b5dc53d5de5); + source.low = 0x9e8b3b5dc53d5de5U; break; case 0x3f: // 1.0e4096 source.high = 0x7525; - source.low = U64(0xc46052028a20979b); + source.low = 0xc46052028a20979bU; break; default: @@ -2002,7 +2002,7 @@ static void do_frestore_null(m68000_base_device *m68k) for (i = 0; i < 8; i++) { REG_FP(m68k)[i].high = 0x7fff; - REG_FP(m68k)[i].low = U64(0xffffffffffffffff); + REG_FP(m68k)[i].low = 0xffffffffffffffffU; } // Mac IIci at 408458e6 wants an FSAVE of a just-restored nullptr frame to also be nullptr diff --git a/src/devices/cpu/m6805/6805dasm.cpp b/src/devices/cpu/m6805/6805dasm.cpp index 0c69248c084..58a02366f31 100644 --- a/src/devices/cpu/m6805/6805dasm.cpp +++ b/src/devices/cpu/m6805/6805dasm.cpp @@ -160,7 +160,7 @@ static const char *const opcode_strings[0x0100] = }; #endif -static offs_t internal_disasm_m6805(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(m6805) { int code, bit; uint16_t ea; @@ -224,13 +224,3 @@ static offs_t internal_disasm_m6805(cpu_device *device, std::ostream &stream, of } return result; } - - -CPU_DISASSEMBLE(m6805) -{ - std::ostringstream stream; - offs_t result = internal_disasm_m6805(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/m6805/m6805.cpp b/src/devices/cpu/m6805/m6805.cpp index 8e7b6b963f8..b8b9a8c7d48 100644 --- a/src/devices/cpu/m6805/m6805.cpp +++ b/src/devices/cpu/m6805/m6805.cpp @@ -540,10 +540,10 @@ uint32_t m6805_base_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t m6805_base_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m6805_base_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( m6805 ); - return CPU_DISASSEMBLE_NAME(m6805)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(m6805)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/m6805/m6805.h b/src/devices/cpu/m6805/m6805.h index 3b146d98ae1..29493af20c9 100644 --- a/src/devices/cpu/m6805/m6805.h +++ b/src/devices/cpu/m6805/m6805.h @@ -48,7 +48,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/m6809/6x09dasm.cpp b/src/devices/cpu/m6809/6x09dasm.cpp index 2efd49e352c..1018db9385c 100644 --- a/src/devices/cpu/m6809/6x09dasm.cpp +++ b/src/devices/cpu/m6809/6x09dasm.cpp @@ -108,7 +108,6 @@ namespace } offs_t disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram); - offs_t disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram); protected: virtual void indirect(std::ostream &stream, uint8_t pb, const uint8_t *opram, int &p) = 0; @@ -176,20 +175,6 @@ const opcodeinfo *m6x09_disassembler_base::fetch_opcode(const uint8_t *oprom, in } -//------------------------------------------------- -// disassemble - core of the disassembler -//------------------------------------------------- - -offs_t m6x09_disassembler_base::disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram) -{ - std::ostringstream stream; - offs_t result = disassemble(stream, pc, oprom, opram); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - - //------------------------------------------------- // disassemble - core of the disassembler //------------------------------------------------- @@ -1098,7 +1083,7 @@ CPU_DISASSEMBLE(m6809) "A", "B", "CC", "DP", "inv", "inv", "inv", "inv" }; m6x09_disassembler disasm(M6x09_GENERAL, m6809_teregs); - return disasm.disassemble(buffer, pc, oprom, opram); + return disasm.disassemble(stream, pc, oprom, opram); } @@ -1114,7 +1099,7 @@ CPU_DISASSEMBLE(hd6309) "A", "B", "CC", "DP", "0", "0", "E", "F" }; m6x09_disassembler disasm(HD6309_EXCLUSIVE, hd6309_teregs); - return disasm.disassemble(buffer, pc, oprom, opram); + return disasm.disassemble(stream, pc, oprom, opram); } @@ -1562,5 +1547,5 @@ void konami_disassembler::register_register(std::ostream &stream, uint8_t pb) CPU_DISASSEMBLE(konami) { konami_disassembler disasm; - return disasm.disassemble(buffer, pc, oprom, opram); + return disasm.disassemble(stream, pc, oprom, opram); } diff --git a/src/devices/cpu/m6809/hd6309.cpp b/src/devices/cpu/m6809/hd6309.cpp index ef9ff98f4f2..d8227c6162f 100644 --- a/src/devices/cpu/m6809/hd6309.cpp +++ b/src/devices/cpu/m6809/hd6309.cpp @@ -313,10 +313,10 @@ uint32_t hd6309_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t hd6309_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t hd6309_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( hd6309 ); - return CPU_DISASSEMBLE_NAME(hd6309)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(hd6309)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/m6809/hd6309.h b/src/devices/cpu/m6809/hd6309.h index 852f03d2d0d..f4eae899bfa 100644 --- a/src/devices/cpu/m6809/hd6309.h +++ b/src/devices/cpu/m6809/hd6309.h @@ -44,7 +44,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual bool is_6809() override { return false; }; diff --git a/src/devices/cpu/m6809/konami.cpp b/src/devices/cpu/m6809/konami.cpp index 8762d358635..ba6acfe05a5 100644 --- a/src/devices/cpu/m6809/konami.cpp +++ b/src/devices/cpu/m6809/konami.cpp @@ -109,10 +109,10 @@ void konami_cpu_device::device_start() // helper function //------------------------------------------------- -offs_t konami_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t konami_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( konami ); - return CPU_DISASSEMBLE_NAME(konami)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(konami)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/m6809/konami.h b/src/devices/cpu/m6809/konami.h index ca42bbfb666..2850eff7372 100644 --- a/src/devices/cpu/m6809/konami.h +++ b/src/devices/cpu/m6809/konami.h @@ -46,7 +46,7 @@ protected: virtual void execute_run() override; // device_disasm_interface overrides - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: typedef m6809_base_device super; diff --git a/src/devices/cpu/m6809/m6809.cpp b/src/devices/cpu/m6809/m6809.cpp index db0cbee9a3c..27b15dc97a5 100644 --- a/src/devices/cpu/m6809/m6809.cpp +++ b/src/devices/cpu/m6809/m6809.cpp @@ -373,10 +373,10 @@ uint32_t m6809_base_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t m6809_base_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m6809_base_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( m6809 ); - return CPU_DISASSEMBLE_NAME(m6809)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(m6809)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/m6809/m6809.h b/src/devices/cpu/m6809/m6809.h index b9b6c365f35..73f8477d51e 100644 --- a/src/devices/cpu/m6809/m6809.h +++ b/src/devices/cpu/m6809/m6809.h @@ -77,7 +77,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_import(const device_state_entry &entry) override; diff --git a/src/devices/cpu/mb86233/mb86233.cpp b/src/devices/cpu/mb86233/mb86233.cpp index f8be4ec3af9..d37ae61e740 100644 --- a/src/devices/cpu/mb86233/mb86233.cpp +++ b/src/devices/cpu/mb86233/mb86233.cpp @@ -37,10 +37,10 @@ mb86233_cpu_device::mb86233_cpu_device(const machine_config &mconfig, const char } -offs_t mb86233_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t mb86233_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( mb86233 ); - return CPU_DISASSEMBLE_NAME(mb86233)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(mb86233)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/mb86233/mb86233.h b/src/devices/cpu/mb86233/mb86233.h index 9169d3477c4..135227a2524 100644 --- a/src/devices/cpu/mb86233/mb86233.h +++ b/src/devices/cpu/mb86233/mb86233.h @@ -79,7 +79,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/mb86233/mb86233d.cpp b/src/devices/cpu/mb86233/mb86233d.cpp index 37e5e52e7b2..afc8a0a65f1 100644 --- a/src/devices/cpu/mb86233/mb86233d.cpp +++ b/src/devices/cpu/mb86233/mb86233d.cpp @@ -750,18 +750,9 @@ static unsigned dasm_mb86233(std::ostream &stream, uint32_t opcode ) return (1 | DASMFLAG_SUPPORTED); } -static offs_t internal_disasm_mb86233(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(mb86233) { uint32_t op = *(uint32_t *)oprom; op = little_endianize_int32(op); return dasm_mb86233(stream, op); } - -CPU_DISASSEMBLE(mb86233) -{ - std::ostringstream stream; - offs_t result = internal_disasm_mb86233(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/mb86235/mb86235.cpp b/src/devices/cpu/mb86235/mb86235.cpp index b765614d074..c2641521ad4 100644 --- a/src/devices/cpu/mb86235/mb86235.cpp +++ b/src/devices/cpu/mb86235/mb86235.cpp @@ -123,8 +123,8 @@ void mb86235_cpu_device::state_string_export(const device_state_entry &entry, st } } -offs_t mb86235_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t mb86235_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( mb86235 ); - return CPU_DISASSEMBLE_NAME(mb86235)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(mb86235)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/mb86235/mb86235.h b/src/devices/cpu/mb86235/mb86235.h index 7531607688c..8a8bd867609 100644 --- a/src/devices/cpu/mb86235/mb86235.h +++ b/src/devices/cpu/mb86235/mb86235.h @@ -47,7 +47,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 8; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/mb86235/mb86235d.cpp b/src/devices/cpu/mb86235/mb86235d.cpp index 73cd908cc29..f32fcba8969 100644 --- a/src/devices/cpu/mb86235/mb86235d.cpp +++ b/src/devices/cpu/mb86235/mb86235d.cpp @@ -86,39 +86,39 @@ static const char *ai2f_field[32] = { "AA0", "AA1", "AA2", "AA3", "AA4", "AA5", "AA6", "AA7", "AB0", "AB1", "AB2", "AB3", "AB4", "AB5", "AB6", "AB7", "PR", "PR++", "PR--", "PR#0", "???", "???", "???", "???", "-1.0E+0", "0.0E+0", "0.5E+0", "1.0E+0", "1.5E+0", "2.0E+0", "3.0E+0", "5.0E+0" }; -static char* get_ea(int md, int arx, int ary, int disp) +static void dasm_ea(std::ostream &stream, int md, int arx, int ary, int disp) { - static char buffer[40]; - char *p = buffer; + if (arx & 0x20) + stream << "B("; + else + stream << "A("; + arx &= 7; switch (md) { - case 0x0: p += sprintf(p, "@AR%d", arx); break; - case 0x1: p += sprintf(p, "@AR%d++", arx); break; - case 0x2: p += sprintf(p, "@AR%d--", arx); break; - case 0x3: p += sprintf(p, "@AR%d++%04X", arx, disp); break; - case 0x4: p += sprintf(p, "@AR%d+AR%d", arx, ary); break; - case 0x5: p += sprintf(p, "@AR%d+AR%d++", arx, ary); break; - case 0x6: p += sprintf(p, "@AR%d+AR%d--", arx, ary); break; - case 0x7: p += sprintf(p, "@AR%d+AR%d++%04X", arx, ary, disp); break; - case 0x8: p += sprintf(p, "@AR%d+AR%dU", arx, ary); break; - case 0x9: p += sprintf(p, "@AR%d+AR%dL", arx, ary); break; - case 0xa: p += sprintf(p, "@AR%d+%04X", arx, disp); break; - case 0xb: p += sprintf(p, "@AR%d+AR%d+%04X", arx, ary, disp); break; - case 0xc: p += sprintf(p, "%04X", disp); break; - case 0xd: p += sprintf(p, "@AR%d+[AR%d++]", arx, ary); break; - case 0xe: p += sprintf(p, "@AR%d+[AR%d--]", arx, ary); break; - case 0xf: p += sprintf(p, "@AR%d+[AR%d++%04X]", arx, ary, disp); break; + case 0x0: util::stream_format(stream, "@AR%d", arx); break; + case 0x1: util::stream_format(stream, "@AR%d++", arx); break; + case 0x2: util::stream_format(stream, "@AR%d--", arx); break; + case 0x3: util::stream_format(stream, "@AR%d++%04X", arx, disp); break; + case 0x4: util::stream_format(stream, "@AR%d+AR%d", arx, ary); break; + case 0x5: util::stream_format(stream, "@AR%d+AR%d++", arx, ary); break; + case 0x6: util::stream_format(stream, "@AR%d+AR%d--", arx, ary); break; + case 0x7: util::stream_format(stream, "@AR%d+AR%d++%04X", arx, ary, disp); break; + case 0x8: util::stream_format(stream, "@AR%d+AR%dU", arx, ary); break; + case 0x9: util::stream_format(stream, "@AR%d+AR%dL", arx, ary); break; + case 0xa: util::stream_format(stream, "@AR%d+%04X", arx, disp); break; + case 0xb: util::stream_format(stream, "@AR%d+AR%d+%04X", arx, ary, disp); break; + case 0xc: util::stream_format(stream, "%04X", disp); break; + case 0xd: util::stream_format(stream, "@AR%d+[AR%d++]", arx, ary); break; + case 0xe: util::stream_format(stream, "@AR%d+[AR%d--]", arx, ary); break; + case 0xf: util::stream_format(stream, "@AR%d+[AR%d++%04X]", arx, ary, disp); break; } - return buffer; + stream << ')'; } -static char* dasm_alu_mul(uint64_t opcode, bool twoop) +static void dasm_alu_mul(std::ostream &stream, uint64_t opcode, bool twoop) { - static char buffer[80]; - char *p = buffer; - int ma = (opcode & ((uint64_t)(1) << 41)) ? 1 : 0; int o = (opcode >> 42) & 0x1f; int i2 = (opcode >> 47) & 0x1f; @@ -130,69 +130,69 @@ static char* dasm_alu_mul(uint64_t opcode, bool twoop) int aluop = (opcode >> 56) & 0x1f; switch (aluop) { - case 0x00: p += sprintf(p, "FADD %s, %s, %s", ai1_field[i1], ai2f_field[i2], mo_field[o]); + case 0x00: util::stream_format(stream, "FADD %s, %s, %s", ai1_field[i1], ai2f_field[i2], mo_field[o]); break; - case 0x01: p += sprintf(p, "FADDZ %s, %s, %s", ai1_field[i1], ai2f_field[i2], mo_field[o]); + case 0x01: util::stream_format(stream, "FADDZ %s, %s, %s", ai1_field[i1], ai2f_field[i2], mo_field[o]); break; - case 0x02: p += sprintf(p, "FSUB %s, %s, %s", ai1_field[i1], ai2f_field[i2], mo_field[o]); + case 0x02: util::stream_format(stream, "FSUB %s, %s, %s", ai1_field[i1], ai2f_field[i2], mo_field[o]); break; - case 0x03: p += sprintf(p, "FSUBZ %s, %s, %s", ai1_field[i1], ai2f_field[i2], mo_field[o]); + case 0x03: util::stream_format(stream, "FSUBZ %s, %s, %s", ai1_field[i1], ai2f_field[i2], mo_field[o]); break; - case 0x04: p += sprintf(p, "FCMP %s, %s", ai1_field[i1], ai2f_field[i2]); + case 0x04: util::stream_format(stream, "FCMP %s, %s", ai1_field[i1], ai2f_field[i2]); break; - case 0x05: p += sprintf(p, "FABS %s, %s", ai1_field[i1], mo_field[o]); + case 0x05: util::stream_format(stream, "FABS %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x06: p += sprintf(p, "FABC %s, %s, %s", ai1_field[i1], ai2f_field[i2], mo_field[o]); + case 0x06: util::stream_format(stream, "FABC %s, %s, %s", ai1_field[i1], ai2f_field[i2], mo_field[o]); break; - case 0x07: p += sprintf(p, "NOP"); + case 0x07: stream << "NOP"; break; - case 0x08: p += sprintf(p, "FEA %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); + case 0x08: util::stream_format(stream, "FEA %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); break; - case 0x09: p += sprintf(p, "FES %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); + case 0x09: util::stream_format(stream, "FES %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); break; - case 0x0a: p += sprintf(p, "FRCP %s, %s", ai1_field[i1], mo_field[o]); + case 0x0a: util::stream_format(stream, "FRCP %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x0b: p += sprintf(p, "FRSQ %s, %s", ai1_field[i1], mo_field[o]); + case 0x0b: util::stream_format(stream, "FRSQ %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x0c: p += sprintf(p, "FLOG %s, %s", ai1_field[i1], mo_field[o]); + case 0x0c: util::stream_format(stream, "FLOG %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x0d: p += sprintf(p, "CIF %s, %s", ai1_field[i1], mo_field[o]); + case 0x0d: util::stream_format(stream, "CIF %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x0e: p += sprintf(p, "CFI %s, %s", ai1_field[i1], mo_field[o]); + case 0x0e: util::stream_format(stream, "CFI %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x0f: p += sprintf(p, "CFIB %s, %s", ai1_field[i1], mo_field[o]); + case 0x0f: util::stream_format(stream, "CFIB %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x10: p += sprintf(p, "ADD %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); + case 0x10: util::stream_format(stream, "ADD %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); break; - case 0x11: p += sprintf(p, "ADDZ %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); + case 0x11: util::stream_format(stream, "ADDZ %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); break; - case 0x12: p += sprintf(p, "SUB %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); + case 0x12: util::stream_format(stream, "SUB %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); break; - case 0x13: p += sprintf(p, "SUBZ %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); + case 0x13: util::stream_format(stream, "SUBZ %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); break; - case 0x14: p += sprintf(p, "CMP %s, %s", ai1_field[i1], ai2_field[i2]); + case 0x14: util::stream_format(stream, "CMP %s, %s", ai1_field[i1], ai2_field[i2]); break; - case 0x15: p += sprintf(p, "ABS %s, %s", ai1_field[i1], mo_field[o]); + case 0x15: util::stream_format(stream, "ABS %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x16: p += sprintf(p, "ATR %s, %s", ai1_field[i1], mo_field[o]); + case 0x16: util::stream_format(stream, "ATR %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x17: p += sprintf(p, "ATRZ %s, %s", ai1_field[i1], mo_field[o]); + case 0x17: util::stream_format(stream, "ATRZ %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x18: p += sprintf(p, "AND %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); + case 0x18: util::stream_format(stream, "AND %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); break; - case 0x19: p += sprintf(p, "OR %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); + case 0x19: util::stream_format(stream, "OR %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); break; - case 0x1a: p += sprintf(p, "XOR %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); + case 0x1a: util::stream_format(stream, "XOR %s, %s, %s", ai1_field[i1], ai2_field[i2], mo_field[o]); break; - case 0x1b: p += sprintf(p, "NOT %s, %s", ai1_field[i1], mo_field[o]); + case 0x1b: util::stream_format(stream, "NOT %s, %s", ai1_field[i1], mo_field[o]); break; - case 0x1c: p += sprintf(p, "LSR %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); + case 0x1c: util::stream_format(stream, "LSR %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); break; - case 0x1d: p += sprintf(p, "LSL %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); + case 0x1d: util::stream_format(stream, "LSL %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); break; - case 0x1e: p += sprintf(p, "ASR %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); + case 0x1e: util::stream_format(stream, "ASR %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); break; - case 0x1f: p += sprintf(p, "ASL %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); + case 0x1f: util::stream_format(stream, "ASL %s, #%02X, %s", ai1_field[i1], i2, mo_field[o]); break; } } @@ -204,29 +204,24 @@ static char* dasm_alu_mul(uint64_t opcode, bool twoop) int mi1 = (opcode >> 37) & 0xf; int mo = (opcode >> 27) & 0x1f; if (opcode & ((uint64_t)(1) << 41)) - p += sprintf(p, " : FMUL %s, %s, %s", mi1_field[mi1], mi2_field[mi2], mo_field[mo]); + util::stream_format(stream, " : FMUL %s, %s, %s", mi1_field[mi1], mi2_field[mi2], mo_field[mo]); else - p += sprintf(p, " : MUL %s, %s, %s", mi1_field[mi1], mi2_field[mi2], mo_field[mo]); + util::stream_format(stream, " : MUL %s, %s, %s", mi1_field[mi1], mi2_field[mi2], mo_field[mo]); } else { if (ma == 0) { if (opcode & ((uint64_t)(1) << 56)) - p += sprintf(p, "FMUL %s, %s, %s", mi1_field[i1], mi2_field[i2], mo_field[o]); + util::stream_format(stream, "FMUL %s, %s, %s", mi1_field[i1], mi2_field[i2], mo_field[o]); else - p += sprintf(p, "MUL %s, %s, %s", mi1_field[i1], mi2_field[i2], mo_field[o]); + util::stream_format(stream, "MUL %s, %s, %s", mi1_field[i1], mi2_field[i2], mo_field[o]); } } - - return buffer; } -static char* dasm_control(uint32_t pc, uint64_t opcode) +static void dasm_control(std::ostream &stream, uint32_t pc, uint64_t opcode) { - static char buffer[80]; - char *p = buffer; - int ef1 = (opcode >> 16) & 0x3f; int ef2 = opcode & 0xffff; @@ -234,66 +229,65 @@ static char* dasm_control(uint32_t pc, uint64_t opcode) int rel12 = (opcode & 0x800) ? (0xfffff000 | (opcode & 0xfff)) : (opcode & 0xfff); - switch (cop) { - case 0x00: p += sprintf(p, "NOP"); + case 0x00: stream << "NOP"; break; case 0x01: if (ef1 == 0) - p += sprintf(p, "REP #%04X", ef2); + util::stream_format(stream, "REP #%04X", ef2); else - p += sprintf(p, "REP AR%d", (ef2 >> 12) & 7); + util::stream_format(stream, "REP AR%d", (ef2 >> 12) & 7); break; case 0x02: if (ef1 == 0) - p += sprintf(p, "SETL #%04X", ef2); + util::stream_format(stream, "SETL #%04X", ef2); else - p += sprintf(p, "SETL AR%d", (ef2 >> 12) & 7); + util::stream_format(stream, "SETL AR%d", (ef2 >> 12) & 7); break; case 0x03: if (ef1 == 1) - p += sprintf(p, "CLRFI"); + stream << "CLRFI"; else if (ef1 == 2) - p += sprintf(p, "CLRFO"); + stream << "CLRFO"; else if (ef1 == 3) - p += sprintf(p, "CLRF"); + stream << "CLRF"; break; case 0x04: - p += sprintf(p, "PUSH %s", regname[(ef2 >> 6) & 0x3f]); + util::stream_format(stream, "PUSH %s", regname[(ef2 >> 6) & 0x3f]); break; case 0x05: - p += sprintf(p, "POP %s", regname[(ef2 >> 6) & 0x3f]); + util::stream_format(stream, "POP %s", regname[(ef2 >> 6) & 0x3f]); break; case 0x08: - p += sprintf(p, "SETM #%04X", ef2); + util::stream_format(stream, "SETM #%04X", ef2); break; case 0x09: - p += sprintf(p, "SETM #%01X, CBSA", (ef2 >> 12) & 7); + util::stream_format(stream, "SETM #%01X, CBSA", (ef2 >> 12) & 7); break; case 0x0a: - p += sprintf(p, "SETM #%01X, CBSB", (ef2 >> 8) & 7); + util::stream_format(stream, "SETM #%01X, CBSB", (ef2 >> 8) & 7); break; case 0x0b: - p += sprintf(p, "SETM #%d, RF", (ef2 >> 7) & 1); + util::stream_format(stream, "SETM #%d, RF", (ef2 >> 7) & 1); break; case 0x0c: - p += sprintf(p, "SETM #%d, RDY", (ef2 >> 4) & 1); + util::stream_format(stream, "SETM #%d, RDY", (ef2 >> 4) & 1); break; case 0x0d: - p += sprintf(p, "SETM #%01X, WAIT", ef2 & 7); + util::stream_format(stream, "SETM #%01X, WAIT", ef2 & 7); break; case 0x13: - p += sprintf(p, "DBLP %04X", pc + rel12); + util::stream_format(stream, "DBLP %04X", pc + rel12); break; case 0x14: - p += sprintf(p, "DBBC AR%d:%d, %04X", (uint32_t)((opcode >> 13) & 7), (uint32_t)((opcode >> 16) & 0xf), pc + rel12); + util::stream_format(stream, "DBBC AR%d:%d, %04X", (uint32_t)((opcode >> 13) & 7), (uint32_t)((opcode >> 16) & 0xf), pc + rel12); break; case 0x15: - p += sprintf(p, "DBBS AR%d:%d, %04X", (uint32_t)((opcode >> 13) & 7), (uint32_t)((opcode >> 16) & 0xf), pc + rel12); + util::stream_format(stream, "DBBS AR%d:%d, %04X", (uint32_t)((opcode >> 13) & 7), (uint32_t)((opcode >> 16) & 0xf), pc + rel12); break; case 0x1b: - p += sprintf(p, "DRET"); + stream << "DRET"; break; case 0x10: // DBcc @@ -304,52 +298,49 @@ static char* dasm_control(uint32_t pc, uint64_t opcode) case 0x12: // DJMP { if (cop == 0x10) - p += sprintf(p, "%s ", db_mnemonic[ef1]); + util::stream_format(stream, "%s ", db_mnemonic[ef1]); else if (cop == 0x11) - p += sprintf(p, "%s ", dbn_mnemonic[ef1]); + util::stream_format(stream, "%s ", dbn_mnemonic[ef1]); else if (cop == 0x18) - p += sprintf(p, "%s ", dc_mnemonic[ef1]); + util::stream_format(stream, "%s ", dc_mnemonic[ef1]); else if (cop == 0x19) - p += sprintf(p, "%s ", dcn_mnemonic[ef1]); + util::stream_format(stream, "%s ", dcn_mnemonic[ef1]); else if (cop == 0x12) - p += sprintf(p, "DJMP "); + stream << "DJMP "; else if (cop == 0x1a) - p += sprintf(p, "DCALL "); + stream << "DCALL "; switch ((opcode >> 12) & 0xf) { - case 0x0: p += sprintf(p, "%03X", ef2 & 0xfff); break; - case 0x1: p += sprintf(p, "%04X", pc + rel12); break; - case 0x2: p += sprintf(p, "%s", regname[(ef2 >> 6) & 0x3f]); break; - case 0x3: p += sprintf(p, "+%s", regname[(ef2 >> 6) & 0x3f]); break; - case 0x4: p += sprintf(p, "%s", regname[(ef2 >> 6) & 0x3f]); break; - case 0x5: p += sprintf(p, "+%s", regname[(ef2 >> 6) & 0x3f]); break; - case 0x6: p += sprintf(p, "%s", regname[(ef2 >> 6) & 0x3f]); break; - case 0x7: p += sprintf(p, "+%s", regname[(ef2 >> 6) & 0x3f]); break; - case 0x8: p += sprintf(p, "A(%03X)", ef2 & 0x3ff); break; - case 0x9: p += sprintf(p, "+A(%03X)", ef2 & 0x3ff); break; - case 0xa: p += sprintf(p, "B(%03X)", ef2 & 0x3ff); break; - case 0xb: p += sprintf(p, "+B(%03X)", ef2 & 0x3ff); break; - case 0xc: p += sprintf(p, "A(%s)", regname[(ef2 >> 6) & 0x3f]); break; - case 0xd: p += sprintf(p, "+A(%s)", regname[(ef2 >> 6) & 0x3f]); break; - case 0xe: p += sprintf(p, "B(%s)", regname[(ef2 >> 6) & 0x3f]); break; - case 0xf: p += sprintf(p, "+B(%s)", regname[(ef2 >> 6) & 0x3f]); break; + case 0x0: util::stream_format(stream, "%03X", ef2 & 0xfff); break; + case 0x1: util::stream_format(stream, "%04X", pc + rel12); break; + case 0x2: util::stream_format(stream, "%s", regname[(ef2 >> 6) & 0x3f]); break; + case 0x3: util::stream_format(stream, "+%s", regname[(ef2 >> 6) & 0x3f]); break; + case 0x4: util::stream_format(stream, "%s", regname[(ef2 >> 6) & 0x3f]); break; + case 0x5: util::stream_format(stream, "+%s", regname[(ef2 >> 6) & 0x3f]); break; + case 0x6: util::stream_format(stream, "%s", regname[(ef2 >> 6) & 0x3f]); break; + case 0x7: util::stream_format(stream, "+%s", regname[(ef2 >> 6) & 0x3f]); break; + case 0x8: util::stream_format(stream, "A(%03X)", ef2 & 0x3ff); break; + case 0x9: util::stream_format(stream, "+A(%03X)", ef2 & 0x3ff); break; + case 0xa: util::stream_format(stream, "B(%03X)", ef2 & 0x3ff); break; + case 0xb: util::stream_format(stream, "+B(%03X)", ef2 & 0x3ff); break; + case 0xc: util::stream_format(stream, "A(%s)", regname[(ef2 >> 6) & 0x3f]); break; + case 0xd: util::stream_format(stream, "+A(%s)", regname[(ef2 >> 6) & 0x3f]); break; + case 0xe: util::stream_format(stream, "B(%s)", regname[(ef2 >> 6) & 0x3f]); break; + case 0xf: util::stream_format(stream, "+B(%s)", regname[(ef2 >> 6) & 0x3f]); break; } break; } } - - return buffer; } -static char* dasm_double_xfer1(uint64_t opcode) +static void dasm_double_xfer1(std::ostream &stream, uint64_t opcode) { - static char buffer[80]; - char *p = buffer; - int sd = (opcode >> 25) & 3; + stream << "MVD1 "; + switch (sd) { case 0: @@ -358,7 +349,7 @@ static char* dasm_double_xfer1(uint64_t opcode) int ad = (opcode >> 15) & 0x1f; int bs = (opcode >> 10) & 0x1f; int bd = (opcode >> 5) & 0x1f; - p += sprintf(p, "MVD1 %s, %s, %s, %s", regname[as], regname[ad], regname[bs], regname[bd]); + util::stream_format(stream, "%s, %s, %s, %s", regname[as], regname[ad], regname[bs], regname[bd]); break; } @@ -372,21 +363,19 @@ static char* dasm_double_xfer1(uint64_t opcode) int bary = (opcode >> 4) & 7; int md = opcode & 0xf; - p += sprintf(p, "MVD1 "); - switch (md) { - case 0x0: p += sprintf(p, "%s, A(@AR%d), %s, B(@AR%d)", regname[areg], aarx, regname[breg], barx); break; - case 0x1: p += sprintf(p, "%s, A(@AR%d++), %s, B(@AR%d++)", regname[areg], aarx, regname[breg], barx); break; - case 0x2: p += sprintf(p, "%s, A(@AR%d--), %s, B(@AR%d--)", regname[areg], aarx, regname[breg], barx); break; - case 0x4: p += sprintf(p, "%s, A(@AR%d+AR%d), %s, B(@AR%d+AR%d)", regname[areg], aarx, aary, regname[breg], barx, bary); break; - case 0x5: p += sprintf(p, "%s, A(@AR%d+AR%d++), %s, B(@AR%d+AR%d++)", regname[areg], aarx, aary, regname[breg], barx, bary); break; - case 0x6: p += sprintf(p, "%s, A(@AR%d+AR%d--), %s, B(@AR%d+AR%d--)", regname[areg], aarx, aary, regname[breg], barx, bary); break; - case 0x8: p += sprintf(p, "%s, A(@AR%d+AR%dU), %s, B(@AR%d+AR%dL)", regname[areg], aarx, aary, regname[breg], barx, bary); break; - case 0x9: p += sprintf(p, "%s, A(@AR%d+AR%dL), %s, B(@AR%d+AR%dU)", regname[areg], aarx, aary, regname[breg], barx, bary); break; - case 0xd: p += sprintf(p, "%s, A(@AR%d+[AR%d++]), %s, B(@AR%d+[AR%d++])", regname[areg], aarx, aary, regname[breg], barx, bary); break; - case 0xe: p += sprintf(p, "%s, A(@AR%d+[AR%d--]), %s, B(@AR%d+[AR%d--])", regname[areg], aarx, aary, regname[breg], barx, bary); break; - default: p += sprintf(p, "???"); break; + case 0x0: util::stream_format(stream, "%s, A(@AR%d), %s, B(@AR%d)", regname[areg], aarx, regname[breg], barx); break; + case 0x1: util::stream_format(stream, "%s, A(@AR%d++), %s, B(@AR%d++)", regname[areg], aarx, regname[breg], barx); break; + case 0x2: util::stream_format(stream, "%s, A(@AR%d--), %s, B(@AR%d--)", regname[areg], aarx, regname[breg], barx); break; + case 0x4: util::stream_format(stream, "%s, A(@AR%d+AR%d), %s, B(@AR%d+AR%d)", regname[areg], aarx, aary, regname[breg], barx, bary); break; + case 0x5: util::stream_format(stream, "%s, A(@AR%d+AR%d++), %s, B(@AR%d+AR%d++)", regname[areg], aarx, aary, regname[breg], barx, bary); break; + case 0x6: util::stream_format(stream, "%s, A(@AR%d+AR%d--), %s, B(@AR%d+AR%d--)", regname[areg], aarx, aary, regname[breg], barx, bary); break; + case 0x8: util::stream_format(stream, "%s, A(@AR%d+AR%dU), %s, B(@AR%d+AR%dL)", regname[areg], aarx, aary, regname[breg], barx, bary); break; + case 0x9: util::stream_format(stream, "%s, A(@AR%d+AR%dL), %s, B(@AR%d+AR%dU)", regname[areg], aarx, aary, regname[breg], barx, bary); break; + case 0xd: util::stream_format(stream, "%s, A(@AR%d+[AR%d++]), %s, B(@AR%d+[AR%d++])", regname[areg], aarx, aary, regname[breg], barx, bary); break; + case 0xe: util::stream_format(stream, "%s, A(@AR%d+[AR%d--]), %s, B(@AR%d+[AR%d--])", regname[areg], aarx, aary, regname[breg], barx, bary); break; + default: stream << "???"; break; } break; } @@ -401,38 +390,31 @@ static char* dasm_double_xfer1(uint64_t opcode) int bary = (opcode >> 4) & 7; int md = opcode & 0xf; - p += sprintf(p, "MVD1 "); - switch (md) { - case 0x0: p += sprintf(p, "A(@AR%d), %s, B(@AR%d), %s", aarx, regname[areg], barx, regname[breg]); break; - case 0x1: p += sprintf(p, "A(@AR%d++), %s, B(@AR%d++), %s", aarx, regname[areg], barx, regname[breg]); break; - case 0x2: p += sprintf(p, "A(@AR%d--), %s, B(@AR%d--), %s", aarx, regname[areg], barx, regname[breg]); break; - case 0x4: p += sprintf(p, "A(@AR%d+AR%d), %s, B(@AR%d+AR%d), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; - case 0x5: p += sprintf(p, "A(@AR%d+AR%d++), %s, B(@AR%d+AR%d++), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; - case 0x6: p += sprintf(p, "A(@AR%d+AR%d--), %s, B(@AR%d+AR%d--), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; - case 0x8: p += sprintf(p, "A(@AR%d+AR%dU), %s, B(@AR%d+AR%dL), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; - case 0x9: p += sprintf(p, "A(@AR%d+AR%dL), %s, B(@AR%d+AR%dU), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; - case 0xd: p += sprintf(p, "A(@AR%d+[AR%d++]), %s, B(@AR%d+[AR%d++]), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; - case 0xe: p += sprintf(p, "A(@AR%d+[AR%d--]), %s, B(@AR%d+[AR%d--]), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; - default: p += sprintf(p, "???"); break; + case 0x0: util::stream_format(stream, "A(@AR%d), %s, B(@AR%d), %s", aarx, regname[areg], barx, regname[breg]); break; + case 0x1: util::stream_format(stream, "A(@AR%d++), %s, B(@AR%d++), %s", aarx, regname[areg], barx, regname[breg]); break; + case 0x2: util::stream_format(stream, "A(@AR%d--), %s, B(@AR%d--), %s", aarx, regname[areg], barx, regname[breg]); break; + case 0x4: util::stream_format(stream, "A(@AR%d+AR%d), %s, B(@AR%d+AR%d), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; + case 0x5: util::stream_format(stream, "A(@AR%d+AR%d++), %s, B(@AR%d+AR%d++), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; + case 0x6: util::stream_format(stream, "A(@AR%d+AR%d--), %s, B(@AR%d+AR%d--), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; + case 0x8: util::stream_format(stream, "A(@AR%d+AR%dU), %s, B(@AR%d+AR%dL), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; + case 0x9: util::stream_format(stream, "A(@AR%d+AR%dL), %s, B(@AR%d+AR%dU), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; + case 0xd: util::stream_format(stream, "A(@AR%d+[AR%d++]), %s, B(@AR%d+[AR%d++]), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; + case 0xe: util::stream_format(stream, "A(@AR%d+[AR%d--]), %s, B(@AR%d+[AR%d--]), %s", aarx, aary, regname[areg], barx, bary, regname[breg]); break; + default: stream << "???"; break; } break; } case 3: - p += sprintf(p, "???"); + stream << "???"; break; } - - return buffer; } -static char* dasm_xfer1(uint64_t opcode) +static void dasm_xfer1(std::ostream &stream, uint64_t opcode) { - static char buffer[80]; - char *p = buffer; - int dr = (opcode >> 12) & 0x7f; int sr = (opcode >> 19) & 0x7f; int md = opcode & 0xf; @@ -441,104 +423,61 @@ static char* dasm_xfer1(uint64_t opcode) int trm = (opcode >> 26) & 1; int dir = (opcode >> 25) & 1; + stream << "MOV1 "; + if (trm == 0) { if (sr == 0x58) { - p += sprintf(p, "MOV1 #%03X, %s", (uint32_t)(opcode & 0xfff), regname[dr]); + util::stream_format(stream, "#%03X, %s", (uint32_t)(opcode & 0xfff), regname[dr]); } else { - p += sprintf(p, "MOV1 "); - if ((sr & 0x40) == 0) - { - p += sprintf(p, "%s", regname[sr]); - } + stream << regname[sr]; else - { - if (sr & 0x20) - p += sprintf(p, "B"); - else - p += sprintf(p, "A"); + dasm_ea(stream, md, sr, ary, disp5); - p += sprintf(p, "(%s)", get_ea(md, sr & 7, ary, disp5)); - } - - p += sprintf(p, ", "); + stream << ", "; if ((dr & 0x40) == 0) - { - p += sprintf(p, "%s", regname[dr]); - } + stream << regname[dr]; else - { - if (dr & 0x20) - p += sprintf(p, "B"); - else - p += sprintf(p, "A"); - - p += sprintf(p, "(%s)", get_ea(md, dr & 7, ary, disp5)); - } + dasm_ea(stream, md, dr, ary, disp5); } } else { if (dir == 0) { - p += sprintf(p, "MOV1 "); - if ((dr & 0x40) == 0) - { - p += sprintf(p, "%s, ", regname[dr]); - } + util::stream_format(stream, "%s, ", regname[dr]); else - { - if (dr & 0x20) - p += sprintf(p, "B"); - else - p += sprintf(p, "A"); + dasm_ea(stream, md, dr, ary, disp5); - p += sprintf(p, "(%s)", get_ea(md, dr & 7, ary, disp5)); - } - - p += sprintf(p, "E(@EB+EO++%02X)", sr); + util::stream_format(stream, "E(@EB+EO++%02X)", sr); } else { - p += sprintf(p, "MOV1 E(@EB+EO++%02X), ", sr); + util::stream_format(stream, "E(@EB+EO++%02X), ", sr); if ((dr & 0x40) == 0) - { - p += sprintf(p, "%s", regname[dr]); - } + stream << regname[dr]; else - { - if (dr & 0x20) - p += sprintf(p, "B"); - else - p += sprintf(p, "A"); - - p += sprintf(p, "(%s)", get_ea(md, dr & 7, ary, disp5)); - } + dasm_ea(stream, md, dr, ary, disp5); } } - - return buffer; } -static char* double_xfer2_field(int sd, uint32_t field) +static void dasm_double_xfer2_field(std::ostream &stream, int sd, uint32_t field) { - static char buffer[40]; - char *p = buffer; - switch (sd) { case 0: { int s = (field >> 13) & 0x1f; int d = (field >> 8) & 0x1f; - p += sprintf(p, "%s, %s", regname[s], regname[d]); + util::stream_format(stream, "%s, %s", regname[s], regname[d]); break; } @@ -552,17 +491,17 @@ static char* double_xfer2_field(int sd, uint32_t field) switch (md) { - case 0x0: p += sprintf(p, "%s, A(@AR%d)", regname[reg], arx); break; - case 0x1: p += sprintf(p, "%s, A(@AR%d++)", regname[reg], arx); break; - case 0x2: p += sprintf(p, "%s, A(@AR%d--)", regname[reg], arx); break; - case 0x4: p += sprintf(p, "%s, A(@AR%d+AR%d))", regname[reg], arx, ary); break; - case 0x5: p += sprintf(p, "%s, A(@AR%d+AR%d++)", regname[reg], arx, ary); break; - case 0x6: p += sprintf(p, "%s, A(@AR%d+AR%d--)", regname[reg], arx, ary); break; - case 0x8: p += sprintf(p, "%s, A(@AR%d+AR%dU)", regname[reg], arx, ary); break; - case 0x9: p += sprintf(p, "%s, A(@AR%d+AR%dL)", regname[reg], arx, ary); break; - case 0xd: p += sprintf(p, "%s, A(@AR%d+[AR%d++])", regname[reg], arx, ary); break; - case 0xe: p += sprintf(p, "%s, A(@AR%d+[AR%d--]", regname[reg], arx, ary); break; - default: p += sprintf(p, "???"); break; + case 0x0: util::stream_format(stream, "%s, A(@AR%d)", regname[reg], arx); break; + case 0x1: util::stream_format(stream, "%s, A(@AR%d++)", regname[reg], arx); break; + case 0x2: util::stream_format(stream, "%s, A(@AR%d--)", regname[reg], arx); break; + case 0x4: util::stream_format(stream, "%s, A(@AR%d+AR%d))", regname[reg], arx, ary); break; + case 0x5: util::stream_format(stream, "%s, A(@AR%d+AR%d++)", regname[reg], arx, ary); break; + case 0x6: util::stream_format(stream, "%s, A(@AR%d+AR%d--)", regname[reg], arx, ary); break; + case 0x8: util::stream_format(stream, "%s, A(@AR%d+AR%dU)", regname[reg], arx, ary); break; + case 0x9: util::stream_format(stream, "%s, A(@AR%d+AR%dL)", regname[reg], arx, ary); break; + case 0xd: util::stream_format(stream, "%s, A(@AR%d+[AR%d++])", regname[reg], arx, ary); break; + case 0xe: util::stream_format(stream, "%s, A(@AR%d+[AR%d--]", regname[reg], arx, ary); break; + default: stream << "???"; break; } break; } @@ -577,34 +516,29 @@ static char* double_xfer2_field(int sd, uint32_t field) switch (md) { - case 0x0: p += sprintf(p, "A(@AR%d), %s", arx, regname[reg]); break; - case 0x1: p += sprintf(p, "A(@AR%d++), %s", arx, regname[reg]); break; - case 0x2: p += sprintf(p, "A(@AR%d--), %s", arx, regname[reg]); break; - case 0x4: p += sprintf(p, "A(@AR%d+AR%d), %s", arx, ary, regname[reg]); break; - case 0x5: p += sprintf(p, "A(@AR%d+AR%d++), %s", arx, ary, regname[reg]); break; - case 0x6: p += sprintf(p, "A(@AR%d+AR%d--), %s", arx, ary, regname[reg]); break; - case 0x8: p += sprintf(p, "A(@AR%d+AR%dU), %s", arx, ary, regname[reg]); break; - case 0x9: p += sprintf(p, "A(@AR%d+AR%dL), %s", arx, ary, regname[reg]); break; - case 0xd: p += sprintf(p, "A(@AR%d+[AR%d++]), %s", arx, ary, regname[reg]); break; - case 0xe: p += sprintf(p, "A(@AR%d+[AR%d--]), %s", arx, ary, regname[reg]); break; - default: p += sprintf(p, "???"); break; + case 0x0: util::stream_format(stream, "A(@AR%d), %s", arx, regname[reg]); break; + case 0x1: util::stream_format(stream, "A(@AR%d++), %s", arx, regname[reg]); break; + case 0x2: util::stream_format(stream, "A(@AR%d--), %s", arx, regname[reg]); break; + case 0x4: util::stream_format(stream, "A(@AR%d+AR%d), %s", arx, ary, regname[reg]); break; + case 0x5: util::stream_format(stream, "A(@AR%d+AR%d++), %s", arx, ary, regname[reg]); break; + case 0x6: util::stream_format(stream, "A(@AR%d+AR%d--), %s", arx, ary, regname[reg]); break; + case 0x8: util::stream_format(stream, "A(@AR%d+AR%dU), %s", arx, ary, regname[reg]); break; + case 0x9: util::stream_format(stream, "A(@AR%d+AR%dL), %s", arx, ary, regname[reg]); break; + case 0xd: util::stream_format(stream, "A(@AR%d+[AR%d++]), %s", arx, ary, regname[reg]); break; + case 0xe: util::stream_format(stream, "A(@AR%d+[AR%d--]), %s", arx, ary, regname[reg]); break; + default: stream << "???"; break; } break; } case 3: - p += sprintf(p, "???"); + stream << "???"; break; } - - return buffer; } -static char* dasm_double_xfer2(uint64_t opcode) +static void dasm_double_xfer2(std::ostream &stream, uint64_t opcode) { - static char buffer[80]; - char *p = buffer; - int asd = (opcode >> 38) & 3; int bsd = (opcode >> 18) & 3; @@ -616,43 +550,41 @@ static char* dasm_double_xfer2(uint64_t opcode) int bmd = opcode & 0xf; int arx = (opcode >> 30) & 7; - p += sprintf(p, "MOVI "); + stream << "MOVI "; switch (bmd) { - case 0x0: p += sprintf(p, "B(@BAR%d)", barx); break; - case 0x1: p += sprintf(p, "B(@BAR%d++)", barx); break; - case 0x2: p += sprintf(p, "B(@BAR%d--)", barx); break; - case 0x3: p += sprintf(p, "B(@BAR%d++%02X)", barx, disp3); break; - case 0x4: p += sprintf(p, "B(@BAR%d+BAR%d)", barx, bary); break; - case 0x5: p += sprintf(p, "B(@BAR%d+BAR%d++)", barx, bary); break; - case 0x6: p += sprintf(p, "B(@BAR%d+BAR%d--)", barx, bary); break; - case 0x7: p += sprintf(p, "B(@BAR%d+BAR%d++%02X)", barx, bary, disp3); break; - case 0x8: p += sprintf(p, "B(@BAR%d+BAR%dU)", barx, bary); break; - case 0x9: p += sprintf(p, "B(@BAR%d+BAR%dL)", barx, bary); break; - case 0xa: p += sprintf(p, "B(@BAR%d+%02X)", barx, disp3); break; - case 0xb: p += sprintf(p, "B(@BAR%d+BAR%d+%02X)", barx, bary, disp3); break; - case 0xc: p += sprintf(p, "???"); break; - case 0xd: p += sprintf(p, "B(@BAR%d+[BAR%d++])", barx, bary); break; - case 0xe: p += sprintf(p, "B(@BAR%d+[BAR%d--])", barx, bary); break; - case 0xf: p += sprintf(p, "B(@BAR%d+[BAR%d++%02X])", barx, bary, disp3); break; + case 0x0: util::stream_format(stream, "B(@BAR%d)", barx); break; + case 0x1: util::stream_format(stream, "B(@BAR%d++)", barx); break; + case 0x2: util::stream_format(stream, "B(@BAR%d--)", barx); break; + case 0x3: util::stream_format(stream, "B(@BAR%d++%02X)", barx, disp3); break; + case 0x4: util::stream_format(stream, "B(@BAR%d+BAR%d)", barx, bary); break; + case 0x5: util::stream_format(stream, "B(@BAR%d+BAR%d++)", barx, bary); break; + case 0x6: util::stream_format(stream, "B(@BAR%d+BAR%d--)", barx, bary); break; + case 0x7: util::stream_format(stream, "B(@BAR%d+BAR%d++%02X)", barx, bary, disp3); break; + case 0x8: util::stream_format(stream, "B(@BAR%d+BAR%dU)", barx, bary); break; + case 0x9: util::stream_format(stream, "B(@BAR%d+BAR%dL)", barx, bary); break; + case 0xa: util::stream_format(stream, "B(@BAR%d+%02X)", barx, disp3); break; + case 0xb: util::stream_format(stream, "B(@BAR%d+BAR%d+%02X)", barx, bary, disp3); break; + case 0xc: stream << "???"; break; + case 0xd: util::stream_format(stream, "B(@BAR%d+[BAR%d++])", barx, bary); break; + case 0xe: util::stream_format(stream, "B(@BAR%d+[BAR%d--])", barx, bary); break; + case 0xf: util::stream_format(stream, "B(@BAR%d+[BAR%d++%02X])", barx, bary, disp3); break; } - p += sprintf(p, ", I(@AR%d++)", arx); + util::stream_format(stream, ", I(@AR%d++)", arx); } else { - p += sprintf(p, "MVD2 %s, %s", double_xfer2_field(asd, (opcode >> 20) & 0x3ffff), double_xfer2_field(bsd, opcode & 0x3ffff)); + stream << "MVD2 "; + dasm_double_xfer2_field(stream, asd, (opcode >> 20) & 0x3ffff); + stream << ", "; + dasm_double_xfer2_field(stream, bsd, opcode & 0x3ffff); } - - return buffer; } -static char* dasm_xfer2(uint64_t opcode) +static void dasm_xfer2(std::ostream &stream, uint64_t opcode) { - static char buffer[80]; - char *p = buffer; - int op = (opcode >> 39) & 3; int trm = (opcode >> 38) & 1; int dir = (opcode >> 37) & 1; @@ -664,130 +596,76 @@ static char* dasm_xfer2(uint64_t opcode) if (op == 0) { + stream << "MOV2 "; + if (trm == 0) { if (sr == 0x58) { - p += sprintf(p, "MOV2 #%06X, %s", (uint32_t)(opcode & 0xffffff), regname[dr]); + util::stream_format(stream, "#%06X, %s", (uint32_t)(opcode & 0xffffff), regname[dr]); } else { - p += sprintf(p, "MOV2 "); - if ((sr & 0x40) == 0) - { - p += sprintf(p, "%s", regname[sr]); - } + stream << regname[sr]; else - { - if (sr & 0x20) - p += sprintf(p, "B"); - else - p += sprintf(p, "A"); + dasm_ea(stream, md, sr, ary, disp14); - p += sprintf(p, "(%s)", get_ea(md, sr & 7, ary, disp14)); - } - - p += sprintf(p, ", "); + stream << ", "; if ((dr & 0x40) == 0) - { - p += sprintf(p, "%s", regname[dr]); - } + stream << regname[dr]; else - { - if (dr & 0x20) - p += sprintf(p, "B"); - else - p += sprintf(p, "A"); - - p += sprintf(p, "(%s)", get_ea(md, dr & 7, ary, disp14)); - } + dasm_ea(stream, md, dr, ary, disp14); } } else { if (dir == 0) - { - p += sprintf(p, "MOV2 %s, E(@EB+EO++%02X)", regname[dr], sr); - } + util::stream_format(stream, "%s, E(@EB+EO++%02X)", regname[dr], sr); else - { - p += sprintf(p, "MOV2 E(@EB+EO++%02X), %s", sr, regname[dr]); - } + util::stream_format(stream, "E(@EB+EO++%02X), %s", sr, regname[dr]); } } else if (op == 2) { + stream << "MOV4 "; + if (trm == 0) { if ((sr & 0x40) == 0) - { - p += sprintf(p, "MOV4 %s, ICDTR%d", regname[sr], dr & 7); - } + stream << regname[sr]; + else if (sr == 0x58) + util::stream_format(stream, "#%06X", (uint32_t)(opcode & 0xffffff)); else - { - if (sr == 0x58) - { - p += sprintf(p, "MOV4 #%06X, ICDTR%d", (uint32_t)(opcode & 0xffffff), dr & 7); - } - else - { - p += sprintf(p, "MOV4 "); + dasm_ea(stream, md, sr, ary, disp14); - if (sr & 0x20) - p += sprintf(p, "B"); - else - p += sprintf(p, "A"); - - p += sprintf(p, "(%s), ICDTR%d", get_ea(md, sr & 7, ary, disp14), dr & 7); - } - } + util::stream_format(stream, ", ICDTR%d", dr & 7); } else { if (dir == 0) - { - p += sprintf(p, "MOV4 ICDTR%d, E(@EB+EO++%02X)", dr & 7, sr); - } + util::stream_format(stream, "ICDTR%d, E(@EB+EO++%02X)", dr & 7, sr); else - { - p += sprintf(p, "MOV4 E(@EB+EO++%02X), ICDTR%d", sr, dr & 7); - } + util::stream_format(stream, "E(@EB+EO++%02X), ICDTR%d", sr, dr & 7); } } - - return buffer; } -static char* dasm_xfer3(uint64_t opcode) +static void dasm_xfer3(std::ostream &stream, uint64_t opcode) { - static char buffer[80]; - char *p = buffer; - uint32_t imm = (uint32_t)(opcode >> 27); int dr = (opcode >> 19) & 0x7f; int disp = (opcode >> 7) & 0xfff; int ary = (opcode >> 4) & 7; int md = opcode & 0xf; - p += sprintf(p, "MOV3 #%08X, ", imm); + util::stream_format(stream, "MOV3 #%08X, ", imm); if ((dr & 0x40) == 0) - { - p += sprintf(p, "%s", regname[dr]); - } + stream << regname[dr]; else - { - if (dr & 0x20) - p += sprintf(p, "B"); - else - p += sprintf(p, "A"); - - p += sprintf(p, "(%s)", get_ea(md, dr & 7, ary, disp)); - } - - return buffer; + dasm_ea(stream, md, dr, ary, disp); } static unsigned dasm_mb86235(std::ostream &stream, uint32_t pc, uint64_t opcode) @@ -795,29 +673,41 @@ static unsigned dasm_mb86235(std::ostream &stream, uint32_t pc, uint64_t opcode) switch ((opcode >> 61) & 7) { case 0: // ALU / MUL / double transfer (type 1) - util::stream_format(stream, "%s : %s", dasm_alu_mul(opcode, true), dasm_double_xfer1(opcode)); + dasm_alu_mul(stream, opcode, true); + stream << " : "; + dasm_double_xfer1(stream, opcode); break; case 1: // ALU / MYL / transfer (type 1) - util::stream_format(stream, "%s : %s", dasm_alu_mul(opcode, true), dasm_xfer1(opcode)); + dasm_alu_mul(stream, opcode, true); + stream << " : "; + dasm_xfer1(stream, opcode); break; case 2: // ALU / MUL / control - util::stream_format(stream, "%s : %s", dasm_alu_mul(opcode, true), dasm_control(pc, opcode)); + dasm_alu_mul(stream, opcode, true); + stream << " : "; + dasm_control(stream, pc, opcode); break; case 4: // ALU or MUL / double transfer (type 2) - util::stream_format(stream, "%s : %s", dasm_alu_mul(opcode, false), dasm_double_xfer2(opcode)); + dasm_alu_mul(stream, opcode, false); + stream << " : "; + dasm_double_xfer2(stream, opcode); break; case 5: // ALU or MUL / transfer (type 2) - util::stream_format(stream, "%s : %s", dasm_alu_mul(opcode, false), dasm_xfer2(opcode)); + dasm_alu_mul(stream, opcode, false); + stream << " : "; + dasm_xfer2(stream, opcode); break; case 6: // ALU or MUL / control - util::stream_format(stream, "%s : %s", dasm_alu_mul(opcode, false), dasm_control(pc, opcode)); + dasm_alu_mul(stream, opcode, false); + stream << " : "; + dasm_control(stream, pc, opcode); break; case 7: // transfer (type 3) - util::stream_format(stream, "%s", dasm_xfer3(opcode)); + dasm_xfer3(stream, opcode); break; default: - util::stream_format(stream, "???"); + stream << "???"; break; } @@ -825,21 +715,10 @@ static unsigned dasm_mb86235(std::ostream &stream, uint32_t pc, uint64_t opcode) } - -static offs_t internal_disasm_mb86235(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(mb86235) { uint64_t op = *(uint64_t*)oprom; op = little_endianize_int64(op); return dasm_mb86235(stream, pc, op); } - - -CPU_DISASSEMBLE(mb86235) -{ - std::ostringstream stream; - offs_t result = internal_disasm_mb86235(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/mb88xx/mb88dasm.cpp b/src/devices/cpu/mb88xx/mb88dasm.cpp index d47eef69559..eced68233b0 100644 --- a/src/devices/cpu/mb88xx/mb88dasm.cpp +++ b/src/devices/cpu/mb88xx/mb88dasm.cpp @@ -13,7 +13,7 @@ #include "mb88xx.h" -static offs_t internal_disasm_mb88(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(mb88) { unsigned startpc = pc; uint8_t op = oprom[pc++ - startpc]; @@ -222,13 +222,3 @@ static offs_t internal_disasm_mb88(cpu_device *device, std::ostream &stream, off return (pc - startpc) | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(mb88) -{ - std::ostringstream stream; - offs_t result = internal_disasm_mb88(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/mb88xx/mb88xx.cpp b/src/devices/cpu/mb88xx/mb88xx.cpp index 2be8354d9f9..0c3c8b70758 100644 --- a/src/devices/cpu/mb88xx/mb88xx.cpp +++ b/src/devices/cpu/mb88xx/mb88xx.cpp @@ -163,10 +163,10 @@ mb8844_cpu_device::mb8844_cpu_device(const machine_config &mconfig, const char * } -offs_t mb88_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t mb88_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( mb88 ); - return CPU_DISASSEMBLE_NAME(mb88)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(mb88)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/mb88xx/mb88xx.h b/src/devices/cpu/mb88xx/mb88xx.h index 911574ce092..e5acb3e7526 100644 --- a/src/devices/cpu/mb88xx/mb88xx.h +++ b/src/devices/cpu/mb88xx/mb88xx.h @@ -97,7 +97,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/mc68hc11/hc11dasm.cpp b/src/devices/cpu/mc68hc11/hc11dasm.cpp index e0ff95a7ad7..20ad20c4d0a 100644 --- a/src/devices/cpu/mc68hc11/hc11dasm.cpp +++ b/src/devices/cpu/mc68hc11/hc11dasm.cpp @@ -1274,7 +1274,7 @@ static uint32_t decode_opcode(std::ostream &stream, uint32_t pc, const M68HC11_O return flags; } -static offs_t internal_disasm_hc11(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(hc11) { uint32_t flags; uint8_t opcode; @@ -1286,13 +1286,3 @@ static offs_t internal_disasm_hc11(cpu_device *device, std::ostream &stream, off return (rombase-oprom) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(hc11) -{ - std::ostringstream stream; - offs_t result = internal_disasm_hc11(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/mc68hc11/mc68hc11.cpp b/src/devices/cpu/mc68hc11/mc68hc11.cpp index fe6f5988d73..c8eeec1ca23 100644 --- a/src/devices/cpu/mc68hc11/mc68hc11.cpp +++ b/src/devices/cpu/mc68hc11/mc68hc11.cpp @@ -54,10 +54,10 @@ mc68hc11_cpu_device::mc68hc11_cpu_device(const machine_config &mconfig, const ch } -offs_t mc68hc11_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t mc68hc11_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( hc11 ); - return CPU_DISASSEMBLE_NAME(hc11)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(hc11)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/mc68hc11/mc68hc11.h b/src/devices/cpu/mc68hc11/mc68hc11.h index 7105a97f987..1c83b137d06 100644 --- a/src/devices/cpu/mc68hc11/mc68hc11.h +++ b/src/devices/cpu/mc68hc11/mc68hc11.h @@ -75,7 +75,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 5; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/mcs48/mcs48.cpp b/src/devices/cpu/mcs48/mcs48.cpp index d27e8cf438e..423c522c195 100644 --- a/src/devices/cpu/mcs48/mcs48.cpp +++ b/src/devices/cpu/mcs48/mcs48.cpp @@ -324,17 +324,17 @@ i8742_device::i8742_device(const machine_config &mconfig, const char *tag, devic } -offs_t mcs48_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t mcs48_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( mcs48 ); - return CPU_DISASSEMBLE_NAME(mcs48)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(mcs48)(this, stream, pc, oprom, opram, options); } -offs_t upi41_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t upi41_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( upi41 ); - return CPU_DISASSEMBLE_NAME(upi41)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(upi41)(this, stream, pc, oprom, opram, options); } /*************************************************************************** diff --git a/src/devices/cpu/mcs48/mcs48.h b/src/devices/cpu/mcs48/mcs48.h index 096b1e6331c..e48f670f496 100644 --- a/src/devices/cpu/mcs48/mcs48.h +++ b/src/devices/cpu/mcs48/mcs48.h @@ -152,7 +152,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; protected: address_space_config m_program_config; @@ -594,7 +594,7 @@ public: DECLARE_WRITE8_MEMBER(upi41_master_w); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; TIMER_CALLBACK_MEMBER( master_callback ); }; diff --git a/src/devices/cpu/mcs48/mcs48dsm.cpp b/src/devices/cpu/mcs48/mcs48dsm.cpp index a19ca9c47eb..08afa12f6b3 100644 --- a/src/devices/cpu/mcs48/mcs48dsm.cpp +++ b/src/devices/cpu/mcs48/mcs48dsm.cpp @@ -315,23 +315,13 @@ static uint32_t common_dasm(device_t *device, std::ostream &stream, offs_t pc, c } -static uint32_t common_dasm(device_t *device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, bool upi41) -{ - std::ostringstream stream; - offs_t result = common_dasm(device, stream, pc, oprom, opram, upi41); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - - CPU_DISASSEMBLE( mcs48 ) { - return common_dasm(device, buffer, pc, oprom, opram, false); + return common_dasm(device, stream, pc, oprom, opram, false); } CPU_DISASSEMBLE( upi41 ) { - return common_dasm(device, buffer, pc, oprom, opram, true); + return common_dasm(device, stream, pc, oprom, opram, true); } diff --git a/src/devices/cpu/mcs51/mcs51.cpp b/src/devices/cpu/mcs51/mcs51.cpp index 19a6434a319..bea6b8351e3 100644 --- a/src/devices/cpu/mcs51/mcs51.cpp +++ b/src/devices/cpu/mcs51/mcs51.cpp @@ -2462,43 +2462,43 @@ uint8_t ds5002fp_device::sfr_read(size_t offset) } -offs_t mcs51_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t mcs51_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( i8051 ); - return CPU_DISASSEMBLE_NAME(i8051)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i8051)(this, stream, pc, oprom, opram, options); } -offs_t i8052_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i8052_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( i8052 ); - return CPU_DISASSEMBLE_NAME(i8052)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i8052)(this, stream, pc, oprom, opram, options); } -offs_t i80c31_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i80c31_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( i80c51 ); - return CPU_DISASSEMBLE_NAME(i80c51)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i80c51)(this, stream, pc, oprom, opram, options); } -offs_t i80c51_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i80c51_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( i80c51 ); - return CPU_DISASSEMBLE_NAME(i80c51)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i80c51)(this, stream, pc, oprom, opram, options); } -offs_t i80c52_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i80c52_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( i80c52 ); - return CPU_DISASSEMBLE_NAME(i80c52)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(i80c52)(this, stream, pc, oprom, opram, options); } -offs_t ds5002fp_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t ds5002fp_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( ds5002fp ); - return CPU_DISASSEMBLE_NAME(ds5002fp)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(ds5002fp)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/mcs51/mcs51.h b/src/devices/cpu/mcs51/mcs51.h index 970ee46b531..df5aba90d11 100644 --- a/src/devices/cpu/mcs51/mcs51.h +++ b/src/devices/cpu/mcs51/mcs51.h @@ -120,7 +120,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 5; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; protected: address_space_config m_program_config; @@ -393,7 +393,7 @@ public: i8052_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, int program_width, int data_width, uint8_t features = 0); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; /* SFR Callbacks */ virtual void sfr_write(size_t offset, uint8_t data) override; @@ -421,7 +421,7 @@ public: i80c31_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; @@ -433,7 +433,7 @@ public: i80c51_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, int program_width, int data_width, uint8_t features = 0); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; class i87c51_device : public i80c51_device @@ -452,7 +452,7 @@ public: i80c52_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, int program_width, int data_width, uint8_t features = 0); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; /* SFR Callbacks */ virtual void sfr_write(size_t offset, uint8_t data) override; @@ -512,7 +512,7 @@ public: static void set_crc(device_t &device, uint8_t crc) { downcast(device).m_ds5002fp.crc = crc; } protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; /* SFR Callbacks */ virtual void sfr_write(size_t offset, uint8_t data) override; diff --git a/src/devices/cpu/mcs51/mcs51dasm.cpp b/src/devices/cpu/mcs51/mcs51dasm.cpp index 447d1bee27c..b96ae46a4a1 100644 --- a/src/devices/cpu/mcs51/mcs51dasm.cpp +++ b/src/devices/cpu/mcs51/mcs51dasm.cpp @@ -1147,15 +1147,6 @@ static offs_t mcs51_dasm( const char **mem_names, std::ostream &stream, offs_t p return (PC - pc) | flags | DASMFLAG_SUPPORTED; } -static offs_t mcs51_dasm(const char **mem_names, char *dst, offs_t pc, const uint8_t *oprom, const uint8_t *opram) -{ - std::ostringstream stream; - offs_t result = mcs51_dasm(mem_names, stream, pc, oprom, opram); - std::string stream_str = stream.str(); - strcpy(dst, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE( i8051 ) { static const char *mem_names[0x200]; @@ -1166,7 +1157,7 @@ CPU_DISASSEMBLE( i8051 ) init_mem_names( FEATURE_NONE, mem_names); mem_names_initialized = 1; } - return mcs51_dasm(mem_names, buffer, pc, oprom, opram); + return mcs51_dasm(mem_names, stream, pc, oprom, opram); } CPU_DISASSEMBLE( i8052 ) @@ -1179,7 +1170,7 @@ CPU_DISASSEMBLE( i8052 ) init_mem_names( FEATURE_I8052, mem_names); mem_names_initialized = 1; } - return mcs51_dasm(mem_names, buffer, pc, oprom, opram); + return mcs51_dasm(mem_names, stream, pc, oprom, opram); } CPU_DISASSEMBLE( i80c51 ) @@ -1192,7 +1183,7 @@ CPU_DISASSEMBLE( i80c51 ) init_mem_names( FEATURE_CMOS, mem_names); mem_names_initialized = 1; } - return mcs51_dasm(mem_names, buffer, pc, oprom, opram); + return mcs51_dasm(mem_names, stream, pc, oprom, opram); } CPU_DISASSEMBLE( i80c52 ) @@ -1205,7 +1196,7 @@ CPU_DISASSEMBLE( i80c52 ) init_mem_names( FEATURE_I8052 | FEATURE_CMOS | FEATURE_I80C52, mem_names); mem_names_initialized = 1; } - return mcs51_dasm(mem_names, buffer, pc, oprom, opram); + return mcs51_dasm(mem_names, stream, pc, oprom, opram); } CPU_DISASSEMBLE( ds5002fp ) @@ -1218,5 +1209,5 @@ CPU_DISASSEMBLE( ds5002fp ) init_mem_names( FEATURE_DS5002FP | FEATURE_CMOS, mem_names); mem_names_initialized = 1; } - return mcs51_dasm(mem_names, buffer, pc, oprom, opram); + return mcs51_dasm(mem_names, stream, pc, oprom, opram); } diff --git a/src/devices/cpu/mcs96/i8x9x.cpp b/src/devices/cpu/mcs96/i8x9x.cpp index f75fdec4f8c..a1302b5c3d7 100644 --- a/src/devices/cpu/mcs96/i8x9x.cpp +++ b/src/devices/cpu/mcs96/i8x9x.cpp @@ -18,9 +18,9 @@ i8x9x_device::i8x9x_device(const machine_config &mconfig, device_type type, cons { } -offs_t i8x9x_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i8x9x_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disasm_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disasm_generic(stream, pc, oprom, opram, options, disasm_entries); } const address_space_config *i8x9x_device::memory_space_config(address_spacenum spacenum) const diff --git a/src/devices/cpu/mcs96/i8x9x.h b/src/devices/cpu/mcs96/i8x9x.h index 099618e94f1..efb8997dabb 100644 --- a/src/devices/cpu/mcs96/i8x9x.h +++ b/src/devices/cpu/mcs96/i8x9x.h @@ -32,7 +32,7 @@ protected: static const disasm_entry disasm_entries[0x100]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; virtual void internal_update(uint64_t current_time) override; diff --git a/src/devices/cpu/mcs96/i8xc196.cpp b/src/devices/cpu/mcs96/i8xc196.cpp index 5d814f7e272..ce9c9b9d8ac 100644 --- a/src/devices/cpu/mcs96/i8xc196.cpp +++ b/src/devices/cpu/mcs96/i8xc196.cpp @@ -16,9 +16,9 @@ i8xc196_device::i8xc196_device(const machine_config &mconfig, device_type type, { } -offs_t i8xc196_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t i8xc196_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return disasm_generic(buffer, pc, oprom, opram, options, disasm_entries); + return disasm_generic(stream, pc, oprom, opram, options, disasm_entries); } void i8xc196_device::io_w8(uint8_t adr, uint8_t data) diff --git a/src/devices/cpu/mcs96/i8xc196.h b/src/devices/cpu/mcs96/i8xc196.h index eeaf580aa64..54e811e35b0 100644 --- a/src/devices/cpu/mcs96/i8xc196.h +++ b/src/devices/cpu/mcs96/i8xc196.h @@ -19,7 +19,7 @@ public: static const disasm_entry disasm_entries[0x100]; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void do_exec_full() override; virtual void do_exec_partial() override; diff --git a/src/devices/cpu/mcs96/mcs96.h b/src/devices/cpu/mcs96/mcs96.h index 26c7886a070..f4cda34c224 100644 --- a/src/devices/cpu/mcs96/mcs96.h +++ b/src/devices/cpu/mcs96/mcs96.h @@ -90,14 +90,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_generic(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *entries) - { - std::ostringstream stream; - offs_t result = disasm_generic(stream, pc, oprom, opram, options, entries); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; - } + virtual offs_t disasm_generic(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *entries); address_space_config program_config; address_space *program; @@ -252,9 +245,6 @@ protected: O(fetch_noirq); #undef O - -private: - offs_t disasm_generic(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *entries); }; enum { diff --git a/src/devices/cpu/melps4/m58846.cpp b/src/devices/cpu/melps4/m58846.cpp index b96f479fdd9..261876c3eef 100644 --- a/src/devices/cpu/melps4/m58846.cpp +++ b/src/devices/cpu/melps4/m58846.cpp @@ -30,10 +30,10 @@ m58846_device::m58846_device(const machine_config &mconfig, const char *tag, dev // disasm -offs_t m58846_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t m58846_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(m58846); - return CPU_DISASSEMBLE_NAME(m58846)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(m58846)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/melps4/m58846.h b/src/devices/cpu/melps4/m58846.h index 0e754b1eafb..d270074ff74 100644 --- a/src/devices/cpu/melps4/m58846.h +++ b/src/devices/cpu/melps4/m58846.h @@ -28,7 +28,7 @@ protected: virtual void execute_one() override; // device_disasm_interface overrides - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // timers virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; diff --git a/src/devices/cpu/melps4/melps4d.cpp b/src/devices/cpu/melps4/melps4d.cpp index a6a358db3a5..efd199097c5 100644 --- a/src/devices/cpu/melps4/melps4d.cpp +++ b/src/devices/cpu/melps4/melps4d.cpp @@ -100,7 +100,7 @@ static const uint8_t m58846_opmap[0xc0] = em_LA, em_LA, em_LA, em_LA, em_LA, em_LA, em_LA, em_LA, em_LA, em_LA, em_LA, em_LA, em_LA, em_LA, em_LA, em_LA // Bx }; -static offs_t internal_disasm_m58846(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(m58846) { uint16_t op = (oprom[0] | oprom[1] << 8) & 0x1ff; @@ -138,13 +138,3 @@ static offs_t internal_disasm_m58846(cpu_device *device, std::ostream &stream, o return 1 | em_flags[instr] | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(m58846) -{ - std::ostringstream stream; - offs_t result = internal_disasm_m58846(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/minx/minx.cpp b/src/devices/cpu/minx/minx.cpp index 4ec4a344371..307cf8d73c7 100644 --- a/src/devices/cpu/minx/minx.cpp +++ b/src/devices/cpu/minx/minx.cpp @@ -228,8 +228,8 @@ void minx_cpu_device::execute_set_input(int inputnum, int state) } -offs_t minx_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t minx_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( minx ); - return CPU_DISASSEMBLE_NAME(minx)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(minx)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/minx/minx.h b/src/devices/cpu/minx/minx.h index ca0c18692ff..8ab7ce18a06 100644 --- a/src/devices/cpu/minx/minx.h +++ b/src/devices/cpu/minx/minx.h @@ -41,7 +41,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 5; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/minx/minxd.cpp b/src/devices/cpu/minx/minxd.cpp index 8005d1ecc9f..0e3b9d5b090 100644 --- a/src/devices/cpu/minx/minxd.cpp +++ b/src/devices/cpu/minx/minxd.cpp @@ -420,7 +420,7 @@ case M_HL: util::stream_format(stream, "%c[HL]", fill); break; \ case OP: util::stream_format(stream, "%c$%02X", fill, op); break; \ case OP1: util::stream_format(stream, "%c$%02X", fill, op1); break; -static offs_t internal_disasm_minx(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(minx) { const minxdasm *instr; uint8_t op, op1; @@ -462,13 +462,3 @@ static offs_t internal_disasm_minx(cpu_device *device, std::ostream &stream, off } return pos | s_flags[instr->mnemonic] | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(minx) -{ - std::ostringstream stream; - offs_t result = internal_disasm_minx(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/mips/mips3.cpp b/src/devices/cpu/mips/mips3.cpp index c5ba79f2440..86f823bafdc 100644 --- a/src/devices/cpu/mips/mips3.cpp +++ b/src/devices/cpu/mips/mips3.cpp @@ -963,14 +963,14 @@ bool mips3_device::memory_translate(address_spacenum spacenum, int intention, of } -offs_t mips3_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t mips3_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { uint32_t op = *(uint32_t *)oprom; if (m_bigendian) op = big_endianize_int32(op); else op = little_endianize_int32(op); - return dasmmips3(buffer, pc, op); + return dasmmips3(stream, pc, op); } @@ -2983,7 +2983,7 @@ void mips3_device::ldl_be(uint32_t op) { offs_t offs = SIMMVAL + RSVAL32; int shift = 8 * (offs & 7); - uint64_t mask = U64(0xffffffffffffffff) << shift; + uint64_t mask = 0xffffffffffffffffU << shift; uint64_t temp; if (RDOUBLE_MASKED(offs & ~7, &temp, mask >> shift) && RTREG) @@ -2994,7 +2994,7 @@ void mips3_device::ldr_be(uint32_t op) { offs_t offs = SIMMVAL + RSVAL32; int shift = 8 * (~offs & 7); - uint64_t mask = U64(0xffffffffffffffff) >> shift; + uint64_t mask = 0xffffffffffffffffU >> shift; uint64_t temp; if (RDOUBLE_MASKED(offs & ~7, &temp, mask << shift) && RTREG) @@ -3021,7 +3021,7 @@ void mips3_device::sdl_be(uint32_t op) { offs_t offs = SIMMVAL + RSVAL32; int shift = 8 * (offs & 7); - uint64_t mask = U64(0xffffffffffffffff) >> shift; + uint64_t mask = 0xffffffffffffffffU >> shift; WDOUBLE_MASKED(offs & ~7, RTVAL64 >> shift, mask); } @@ -3029,7 +3029,7 @@ void mips3_device::sdr_be(uint32_t op) { offs_t offs = SIMMVAL + RSVAL32; int shift = 8 * (~offs & 7); - uint64_t mask = U64(0xffffffffffffffff) << shift; + uint64_t mask = 0xffffffffffffffffU << shift; WDOUBLE_MASKED(offs & ~7, RTVAL64 << shift, mask); } @@ -3061,7 +3061,7 @@ void mips3_device::ldl_le(uint32_t op) { offs_t offs = SIMMVAL + RSVAL32; int shift = 8 * (~offs & 7); - uint64_t mask = U64(0xffffffffffffffff) << shift; + uint64_t mask = 0xffffffffffffffffU << shift; uint64_t temp; if (RDOUBLE_MASKED(offs & ~7, &temp, mask >> shift) && RTREG) @@ -3072,7 +3072,7 @@ void mips3_device::ldr_le(uint32_t op) { offs_t offs = SIMMVAL + RSVAL32; int shift = 8 * (offs & 7); - uint64_t mask = U64(0xffffffffffffffff) >> shift; + uint64_t mask = 0xffffffffffffffffU >> shift; uint64_t temp; if (RDOUBLE_MASKED(offs & ~7, &temp, mask << shift) && RTREG) @@ -3099,7 +3099,7 @@ void mips3_device::sdl_le(uint32_t op) { offs_t offs = SIMMVAL + RSVAL32; int shift = 8 * (~offs & 7); - uint64_t mask = U64(0xffffffffffffffff) >> shift; + uint64_t mask = 0xffffffffffffffffU >> shift; WDOUBLE_MASKED(offs & ~7, RTVAL64 >> shift, mask); } @@ -3107,6 +3107,6 @@ void mips3_device::sdr_le(uint32_t op) { offs_t offs = SIMMVAL + RSVAL32; int shift = 8 * (offs & 7); - uint64_t mask = U64(0xffffffffffffffff) << shift; + uint64_t mask = 0xffffffffffffffffU << shift; WDOUBLE_MASKED(offs & ~7, RTVAL64 << shift, mask); } diff --git a/src/devices/cpu/mips/mips3.h b/src/devices/cpu/mips/mips3.h index e69afbc0c8d..a1a1270ac63 100644 --- a/src/devices/cpu/mips/mips3.h +++ b/src/devices/cpu/mips/mips3.h @@ -308,7 +308,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: @@ -771,7 +771,6 @@ private: ***************************************************************************/ unsigned dasmmips3(std::ostream &stream, unsigned pc, uint32_t op); -unsigned dasmmips3(char *buffer, unsigned pc, uint32_t op); #endif /* __MIPS3_H__ */ diff --git a/src/devices/cpu/mips/mips3com.cpp b/src/devices/cpu/mips/mips3com.cpp index 3410843c3e1..f01f27925fe 100644 --- a/src/devices/cpu/mips/mips3com.cpp +++ b/src/devices/cpu/mips/mips3com.cpp @@ -389,7 +389,7 @@ void mips3_device::tlb_write_common(int tlbindex) /* fill in the new TLB entry from the COP0 registers */ entry->page_mask = m_core->cpr[0][COP0_PageMask]; - entry->entry_hi = m_core->cpr[0][COP0_EntryHi] & ~(entry->page_mask & U64(0x0000000001ffe000)); + entry->entry_hi = m_core->cpr[0][COP0_EntryHi] & ~(entry->page_mask & u64(0x0000000001ffe000U)); entry->entry_lo[0] = m_core->cpr[0][COP0_EntryLo0]; entry->entry_lo[1] = m_core->cpr[0][COP0_EntryLo1]; diff --git a/src/devices/cpu/mips/mips3drc.cpp b/src/devices/cpu/mips/mips3drc.cpp index ad1d824e81b..92299fa3808 100644 --- a/src/devices/cpu/mips/mips3drc.cpp +++ b/src/devices/cpu/mips/mips3drc.cpp @@ -2946,7 +2946,7 @@ bool mips3_device::generate_cop1_fr0(drcuml_block *block, compiler_state *compil generate_get_cop1_reg64(block, compiler, desc, FSREG, F0); // dmov F0, UML_FDNEG(block, F1, F0); // fdneg F1,F0 UML_DCMP(block, F0, 0); // cmp F0,0.0 - UML_DMOVc(block, COND_E, F1, U64(0x8000000000000000)); // dmov F1,-0.0,e + UML_DMOVc(block, COND_E, F1, 0x8000000000000000U); // dmov F1,-0.0,e generate_set_cop1_reg64(block, compiler, desc, FDREG, F1); // dmov ,F1 } return true; @@ -3947,9 +3947,10 @@ void mips3_device::log_add_disasm_comment(drcuml_block *block, uint32_t pc, uint { if (m_drcuml->logging()) { - char buffer[100]; - dasmmips3(buffer, pc, op); - block->append_comment("%08X: %s", pc, buffer); // comment + std::ostringstream stream; + dasmmips3(stream, pc, op); + const std::string stream_string = stream.str(); + block->append_comment("%08X: %s", pc, stream_string.c_str()); // comment } } @@ -4077,19 +4078,21 @@ void mips3_device::log_opcode_desc(drcuml_state *drcuml, const opcode_desc *desc /* output each descriptor */ for ( ; desclist != nullptr; desclist = desclist->next()) { - char buffer[100]; + std::ostringstream buffer; /* disassemle the current instruction and output it to the log */ if (drcuml->logging() || drcuml->logging_native()) { if (desclist->flags & OPFLAG_VIRTUAL_NOOP) - strcpy(buffer, ""); + buffer << ""; else dasmmips3(buffer, desclist->pc, desclist->opptr.l[0]); } else - strcpy(buffer, "???"); - drcuml->log_printf("%08X [%08X] t:%08X f:%s: %-30s", desclist->pc, desclist->physpc, desclist->targetpc, log_desc_flags_to_string(desclist->flags), buffer); + buffer << "???"; + + const std::string buffer_string = buffer.str(); + drcuml->log_printf("%08X [%08X] t:%08X f:%s: %-30s", desclist->pc, desclist->physpc, desclist->targetpc, log_desc_flags_to_string(desclist->flags), buffer_string.c_str()); /* output register states */ log_register_list(drcuml, "use", desclist->regin, nullptr); diff --git a/src/devices/cpu/mips/mips3dsm.cpp b/src/devices/cpu/mips/mips3dsm.cpp index ac490eb94f8..acc7abbcc75 100644 --- a/src/devices/cpu/mips/mips3dsm.cpp +++ b/src/devices/cpu/mips/mips3dsm.cpp @@ -536,21 +536,11 @@ unsigned dasmmips3(std::ostream &stream, unsigned pc, uint32_t op) } -unsigned dasmmips3(char *buffer, unsigned pc, uint32_t op) -{ - std::ostringstream stream; - unsigned result = dasmmips3(stream, pc, op); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - - CPU_DISASSEMBLE( mips3be ) { uint32_t op = *(uint32_t *)oprom; op = big_endianize_int32(op); - return dasmmips3(buffer, pc, op); + return dasmmips3(stream, pc, op); } @@ -558,5 +548,5 @@ CPU_DISASSEMBLE( mips3le ) { uint32_t op = *(uint32_t *)oprom; op = little_endianize_int32(op); - return dasmmips3(buffer, pc, op); + return dasmmips3(stream, pc, op); } diff --git a/src/devices/cpu/mips/r3000.cpp b/src/devices/cpu/mips/r3000.cpp index 2e37da309a0..f959dd4485d 100644 --- a/src/devices/cpu/mips/r3000.cpp +++ b/src/devices/cpu/mips/r3000.cpp @@ -480,15 +480,15 @@ uint32_t r3000_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t r3000_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t r3000_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( r3000le ); extern CPU_DISASSEMBLE( r3000be ); if (m_endianness == ENDIANNESS_BIG) - return CPU_DISASSEMBLE_NAME(r3000be)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(r3000be)(this, stream, pc, oprom, opram, options); else - return CPU_DISASSEMBLE_NAME(r3000le)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(r3000le)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/mips/r3000.h b/src/devices/cpu/mips/r3000.h index 138e6fc2a6f..e424877d9ae 100644 --- a/src/devices/cpu/mips/r3000.h +++ b/src/devices/cpu/mips/r3000.h @@ -131,7 +131,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // memory accessors struct r3000_data_accessors diff --git a/src/devices/cpu/mips/r3kdasm.cpp b/src/devices/cpu/mips/r3kdasm.cpp index 71c7fe2dd35..1e8a2d7a16d 100644 --- a/src/devices/cpu/mips/r3kdasm.cpp +++ b/src/devices/cpu/mips/r3kdasm.cpp @@ -378,21 +378,11 @@ static unsigned dasmr3k(std::ostream &stream, unsigned pc, uint32_t op) } -static unsigned dasmr3k(char *buffer, unsigned pc, uint32_t op) -{ - std::ostringstream stream; - unsigned result = dasmr3k(stream, pc, op); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - - CPU_DISASSEMBLE( r3000be ) { uint32_t op = *(uint32_t *)oprom; op = big_endianize_int32(op); - return dasmr3k(buffer, pc, op); + return dasmr3k(stream, pc, op); } @@ -400,5 +390,5 @@ CPU_DISASSEMBLE( r3000le ) { uint32_t op = *(uint32_t *)oprom; op = little_endianize_int32(op); - return dasmr3k(buffer, pc, op); + return dasmr3k(stream, pc, op); } diff --git a/src/devices/cpu/mn10200/mn10200.cpp b/src/devices/cpu/mn10200/mn10200.cpp index 6f43d7f3f13..77af7f4d180 100644 --- a/src/devices/cpu/mn10200/mn10200.cpp +++ b/src/devices/cpu/mn10200/mn10200.cpp @@ -72,10 +72,10 @@ void mn10200_device::state_string_export(const device_state_entry &entry, std::s } } -offs_t mn10200_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t mn10200_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( mn10200 ); - return CPU_DISASSEMBLE_NAME(mn10200)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(mn10200)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/mn10200/mn10200.h b/src/devices/cpu/mn10200/mn10200.h index 100eb03a2b8..cfa5c53457e 100644 --- a/src/devices/cpu/mn10200/mn10200.h +++ b/src/devices/cpu/mn10200/mn10200.h @@ -93,7 +93,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 7; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/mn10200/mn102dis.cpp b/src/devices/cpu/mn10200/mn102dis.cpp index 617a1bab6f1..be3fb46c0eb 100644 --- a/src/devices/cpu/mn10200/mn102dis.cpp +++ b/src/devices/cpu/mn10200/mn102dis.cpp @@ -1034,9 +1034,5 @@ static int mn102_disassemble(std::ostream &stream, uint32_t pc, const uint8_t *o CPU_DISASSEMBLE( mn10200 ) { - std::ostringstream stream; - offs_t result = mn102_disassemble(stream, pc, oprom); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; + return mn102_disassemble(stream, pc, oprom); } diff --git a/src/devices/cpu/nanoprocessor/nanoprocessor.cpp b/src/devices/cpu/nanoprocessor/nanoprocessor.cpp index 273f73f2c48..a67bd8465c1 100644 --- a/src/devices/cpu/nanoprocessor/nanoprocessor.cpp +++ b/src/devices/cpu/nanoprocessor/nanoprocessor.cpp @@ -159,10 +159,10 @@ void hp_nanoprocessor_device::state_string_export(const device_state_entry &entr } -offs_t hp_nanoprocessor_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t hp_nanoprocessor_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(hp_nanoprocessor); - return CPU_DISASSEMBLE_NAME(hp_nanoprocessor)(this , buffer , pc , oprom , opram , options); + return CPU_DISASSEMBLE_NAME(hp_nanoprocessor)(this , stream , pc , oprom , opram , options); } void hp_nanoprocessor_device::execute_one(uint8_t opcode) diff --git a/src/devices/cpu/nanoprocessor/nanoprocessor.h b/src/devices/cpu/nanoprocessor/nanoprocessor.h index 9193e1b5302..d94c5159599 100644 --- a/src/devices/cpu/nanoprocessor/nanoprocessor.h +++ b/src/devices/cpu/nanoprocessor/nanoprocessor.h @@ -102,7 +102,7 @@ public: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: devcb_write8 m_dc_changed_func; diff --git a/src/devices/cpu/nanoprocessor/nanoprocessor_dasm.cpp b/src/devices/cpu/nanoprocessor/nanoprocessor_dasm.cpp index 4c38d248936..418d6f57c7f 100644 --- a/src/devices/cpu/nanoprocessor/nanoprocessor_dasm.cpp +++ b/src/devices/cpu/nanoprocessor/nanoprocessor_dasm.cpp @@ -114,7 +114,6 @@ static const dis_entry_t dis_table[] = { CPU_DISASSEMBLE(hp_nanoprocessor) { - std::ostringstream stream; const uint8_t opcode = *oprom; opram++; @@ -125,8 +124,6 @@ CPU_DISASSEMBLE(hp_nanoprocessor) if (ent.m_param_fn != nullptr) { ent.m_param_fn(stream , opcode , opram); } - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); return ent.m_dasm_flags | DASMFLAG_SUPPORTED; } } diff --git a/src/devices/cpu/nec/nec.cpp b/src/devices/cpu/nec/nec.cpp index 33c68acbd69..1211e59bbd7 100644 --- a/src/devices/cpu/nec/nec.cpp +++ b/src/devices/cpu/nec/nec.cpp @@ -161,10 +161,10 @@ v33a_device::v33a_device(const machine_config &mconfig, const char *tag, device_ } -offs_t nec_common_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t nec_common_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( nec ); - return CPU_DISASSEMBLE_NAME(nec)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(nec)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/nec/nec.h b/src/devices/cpu/nec/nec.h index 5d696eb417b..36a38019990 100644 --- a/src/devices/cpu/nec/nec.h +++ b/src/devices/cpu/nec/nec.h @@ -49,7 +49,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/nec/necdasm.cpp b/src/devices/cpu/nec/necdasm.cpp index e3fdb36f94a..d313eeaf531 100644 --- a/src/devices/cpu/nec/necdasm.cpp +++ b/src/devices/cpu/nec/necdasm.cpp @@ -1596,16 +1596,7 @@ int necv_dasm_one(std::ostream &stream, uint32_t eip, const uint8_t *oprom, cons return (pc-eip) | dasm_flags | DASMFLAG_SUPPORTED; } -int necv_dasm_one(char *buffer, uint32_t eip, const uint8_t *oprom, const uint8_t *decryption_table) -{ - std::ostringstream stream; - int result = necv_dasm_one(stream, eip, oprom, decryption_table); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE( nec ) { - return necv_dasm_one(buffer, pc, oprom, nullptr); + return necv_dasm_one(stream, pc, oprom, nullptr); } diff --git a/src/devices/cpu/nec/v25.cpp b/src/devices/cpu/nec/v25.cpp index ebce1dbaa90..a7abd58133e 100644 --- a/src/devices/cpu/nec/v25.cpp +++ b/src/devices/cpu/nec/v25.cpp @@ -412,9 +412,9 @@ void v25_common_device::execute_set_input(int irqline, int state) } } -offs_t v25_common_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t v25_common_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return necv_dasm_one(buffer, pc, oprom, m_v25v35_decryptiontable); + return necv_dasm_one(stream, pc, oprom, m_v25v35_decryptiontable); } void v25_common_device::device_start() diff --git a/src/devices/cpu/nec/v25.h b/src/devices/cpu/nec/v25.h index 28815e16609..c5cc0b5ee2a 100644 --- a/src/devices/cpu/nec/v25.h +++ b/src/devices/cpu/nec/v25.h @@ -92,7 +92,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/patinhofeio/patinho_feio.cpp b/src/devices/cpu/patinhofeio/patinho_feio.cpp index ceeab59fcc4..6aa770af3a6 100644 --- a/src/devices/cpu/patinhofeio/patinho_feio.cpp +++ b/src/devices/cpu/patinhofeio/patinho_feio.cpp @@ -775,8 +775,8 @@ void patinho_feio_cpu_device::execute_instruction() printf("unimplemented opcode: 0x%02X\n", m_opcode); } -offs_t patinho_feio_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t patinho_feio_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( patinho_feio ); - return CPU_DISASSEMBLE_NAME(patinho_feio)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(patinho_feio)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/patinhofeio/patinho_feio_dasm.cpp b/src/devices/cpu/patinhofeio/patinho_feio_dasm.cpp index 7f366749c25..c655314f348 100644 --- a/src/devices/cpu/patinhofeio/patinho_feio_dasm.cpp +++ b/src/devices/cpu/patinhofeio/patinho_feio_dasm.cpp @@ -3,7 +3,7 @@ #include "emu.h" #include "cpu/patinhofeio/patinhofeio_cpu.h" -static offs_t internal_disasm_patinho_feio(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(patinho_feio) { int addr, value, n, f; @@ -161,13 +161,3 @@ static offs_t internal_disasm_patinho_feio(cpu_device *device, std::ostream &str util::stream_format(stream, "illegal instruction"); return 1; } - - -CPU_DISASSEMBLE(patinho_feio) -{ - std::ostringstream stream; - offs_t result = internal_disasm_patinho_feio(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/patinhofeio/patinhofeio_cpu.h b/src/devices/cpu/patinhofeio/patinhofeio_cpu.h index b10d3b7f0b1..13d27aec613 100644 --- a/src/devices/cpu/patinhofeio/patinhofeio_cpu.h +++ b/src/devices/cpu/patinhofeio/patinhofeio_cpu.h @@ -66,7 +66,7 @@ public: protected: virtual void execute_run() override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; diff --git a/src/devices/cpu/pdp1/pdp1.cpp b/src/devices/cpu/pdp1/pdp1.cpp index ef7e5524399..4dee1695d4b 100644 --- a/src/devices/cpu/pdp1/pdp1.cpp +++ b/src/devices/cpu/pdp1/pdp1.cpp @@ -412,10 +412,10 @@ void pdp1_device::device_config_complete() } -offs_t pdp1_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t pdp1_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( pdp1 ); - return CPU_DISASSEMBLE_NAME(pdp1)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(pdp1)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/pdp1/pdp1.h b/src/devices/cpu/pdp1/pdp1.h index a17c2d37858..8b6bfa23654 100644 --- a/src/devices/cpu/pdp1/pdp1.h +++ b/src/devices/cpu/pdp1/pdp1.h @@ -114,7 +114,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/pdp1/pdp1dasm.cpp b/src/devices/cpu/pdp1/pdp1dasm.cpp index 21424dc91da..3313aa83f37 100644 --- a/src/devices/cpu/pdp1/pdp1dasm.cpp +++ b/src/devices/cpu/pdp1/pdp1dasm.cpp @@ -20,7 +20,7 @@ static inline void ea (void) #define IN if (ib) util::stream_format(stream, " i") -static offs_t internal_disasm_pdp1(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(pdp1) { int md; //int etime = 0; @@ -290,13 +290,3 @@ static offs_t internal_disasm_pdp1(cpu_device *device, std::ostream &stream, off } return 4; } - - -CPU_DISASSEMBLE(pdp1) -{ - std::ostringstream stream; - offs_t result = internal_disasm_pdp1(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/pdp1/tx0.cpp b/src/devices/cpu/pdp1/tx0.cpp index 25830f4cbb5..3b7e9f47546 100644 --- a/src/devices/cpu/pdp1/tx0.cpp +++ b/src/devices/cpu/pdp1/tx0.cpp @@ -1068,15 +1068,15 @@ void tx0_device::io_complete() } -offs_t tx0_8kw_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tx0_8kw_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tx0_8kw ); - return CPU_DISASSEMBLE_NAME(tx0_8kw)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tx0_8kw)(this, stream, pc, oprom, opram, options); } -offs_t tx0_64kw_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tx0_64kw_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tx0_64kw ); - return CPU_DISASSEMBLE_NAME(tx0_64kw)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tx0_64kw)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/pdp1/tx0.h b/src/devices/cpu/pdp1/tx0.h index 3893cd88e27..afd39fc938a 100644 --- a/src/devices/cpu/pdp1/tx0.h +++ b/src/devices/cpu/pdp1/tx0.h @@ -151,7 +151,7 @@ public: protected: virtual void execute_run() override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: void execute_instruction_8kw(); @@ -166,7 +166,7 @@ public: protected: virtual void execute_run() override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: void execute_instruction_64kw(); diff --git a/src/devices/cpu/pdp1/tx0dasm.cpp b/src/devices/cpu/pdp1/tx0dasm.cpp index e309b27603d..cda24ed930c 100644 --- a/src/devices/cpu/pdp1/tx0dasm.cpp +++ b/src/devices/cpu/pdp1/tx0dasm.cpp @@ -3,7 +3,7 @@ #include "emu.h" #include "cpu/pdp1/tx0.h" -static offs_t internal_disasm_tx0_64kw(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(tx0_64kw) { int md; int x; @@ -29,16 +29,7 @@ static offs_t internal_disasm_tx0_64kw(cpu_device *device, std::ostream &stream, return 1; } -CPU_DISASSEMBLE(tx0_64kw) -{ - std::ostringstream stream; - offs_t result = internal_disasm_tx0_64kw(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - -static offs_t internal_disasm_tx0_8kw(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(tx0_8kw) { int md; int x; @@ -130,12 +121,3 @@ static offs_t internal_disasm_tx0_8kw(cpu_device *device, std::ostream &stream, } return 1; } - -CPU_DISASSEMBLE(tx0_8kw) -{ - std::ostringstream stream; - offs_t result = internal_disasm_tx0_8kw(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/pdp8/pdp8.cpp b/src/devices/cpu/pdp8/pdp8.cpp index 8946932b147..d158786d553 100644 --- a/src/devices/cpu/pdp8/pdp8.cpp +++ b/src/devices/cpu/pdp8/pdp8.cpp @@ -174,10 +174,10 @@ uint32_t pdp8_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t pdp8_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t pdp8_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( pdp8 ); - return CPU_DISASSEMBLE_NAME(pdp8)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(pdp8)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/pdp8/pdp8.h b/src/devices/cpu/pdp8/pdp8.h index 55958cb2029..416ecb4a2a0 100644 --- a/src/devices/cpu/pdp8/pdp8.h +++ b/src/devices/cpu/pdp8/pdp8.h @@ -42,7 +42,7 @@ public: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/pdp8/pdp8dasm.cpp b/src/devices/cpu/pdp8/pdp8dasm.cpp index e71f4ebe61d..5c2219af4f8 100644 --- a/src/devices/cpu/pdp8/pdp8dasm.cpp +++ b/src/devices/cpu/pdp8/pdp8dasm.cpp @@ -160,14 +160,6 @@ static offs_t pdp8_dasm_one(std::ostream &stream, offs_t pc, uint16_t op) return 2 | DASMFLAG_SUPPORTED; } -static offs_t pdp8_dasm_one(char *buffer, offs_t pc, uint16_t op) -{ - std::ostringstream stream; - offs_t result = pdp8_dasm_one(stream, pc, op); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} /*****************************************************************************/ @@ -175,5 +167,5 @@ CPU_DISASSEMBLE( pdp8 ) { uint16_t op = (*(uint8_t *)(opram + 0) << 8) | (*(uint8_t *)(opram + 1) << 0); - return pdp8_dasm_one(buffer, pc, op); + return pdp8_dasm_one(stream, pc, op); } diff --git a/src/devices/cpu/pic16c5x/16c5xdsm.cpp b/src/devices/cpu/pic16c5x/16c5xdsm.cpp index d1bb0494299..03cd0539c8c 100644 --- a/src/devices/cpu/pic16c5x/16c5xdsm.cpp +++ b/src/devices/cpu/pic16c5x/16c5xdsm.cpp @@ -149,7 +149,7 @@ static void InitDasm16C5x(void) OpInizialized = 1; } -static offs_t internal_disasm_pic16c5x(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(pic16c5x) { int a, b, d, f, k; /* these can all be filled in by parsing an instruction */ int i; @@ -250,13 +250,3 @@ static offs_t internal_disasm_pic16c5x(cpu_device *device, std::ostream &stream, } return cnt | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(pic16c5x) -{ - std::ostringstream stream; - offs_t result = internal_disasm_pic16c5x(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/pic16c5x/pic16c5x.cpp b/src/devices/cpu/pic16c5x/pic16c5x.cpp index 48a683eaed7..09279821e06 100644 --- a/src/devices/cpu/pic16c5x/pic16c5x.cpp +++ b/src/devices/cpu/pic16c5x/pic16c5x.cpp @@ -153,10 +153,10 @@ pic16c58_device::pic16c58_device(const machine_config &mconfig, const char *tag, } -offs_t pic16c5x_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t pic16c5x_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( pic16c5x ); - return CPU_DISASSEMBLE_NAME(pic16c5x)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(pic16c5x)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/pic16c5x/pic16c5x.h b/src/devices/cpu/pic16c5x/pic16c5x.h index 3a5aa41f5b3..ef0f7dbbbd4 100644 --- a/src/devices/cpu/pic16c5x/pic16c5x.h +++ b/src/devices/cpu/pic16c5x/pic16c5x.h @@ -122,7 +122,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/pic16c62x/16c62xdsm.cpp b/src/devices/cpu/pic16c62x/16c62xdsm.cpp index 48854d9057a..f9fb88a88d1 100644 --- a/src/devices/cpu/pic16c62x/16c62xdsm.cpp +++ b/src/devices/cpu/pic16c62x/16c62xdsm.cpp @@ -160,7 +160,7 @@ static void InitDasm16C5x(void) OpInizialized = 1; } -static offs_t internal_disasm_pic16c62x(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(pic16c62x) { int a, b, d, f, k; /* these can all be filled in by parsing an instruction */ int i; @@ -261,13 +261,3 @@ static offs_t internal_disasm_pic16c62x(cpu_device *device, std::ostream &stream } return cnt | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(pic16c62x) -{ - std::ostringstream stream; - offs_t result = internal_disasm_pic16c62x(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/pic16c62x/pic16c62x.cpp b/src/devices/cpu/pic16c62x/pic16c62x.cpp index a3b3c270690..ceb12c33bb0 100644 --- a/src/devices/cpu/pic16c62x/pic16c62x.cpp +++ b/src/devices/cpu/pic16c62x/pic16c62x.cpp @@ -158,10 +158,10 @@ pic16c622a_device::pic16c622a_device(const machine_config &mconfig, const char * } -offs_t pic16c62x_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t pic16c62x_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( pic16c62x ); - return CPU_DISASSEMBLE_NAME(pic16c62x)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(pic16c62x)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/pic16c62x/pic16c62x.h b/src/devices/cpu/pic16c62x/pic16c62x.h index 7321296cc9d..0c2c19f41be 100644 --- a/src/devices/cpu/pic16c62x/pic16c62x.h +++ b/src/devices/cpu/pic16c62x/pic16c62x.h @@ -84,7 +84,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/powerpc/ppc.h b/src/devices/cpu/powerpc/ppc.h index 0d20214d47f..c51823fb208 100644 --- a/src/devices/cpu/powerpc/ppc.h +++ b/src/devices/cpu/powerpc/ppc.h @@ -269,7 +269,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; /* exception types */ enum diff --git a/src/devices/cpu/powerpc/ppc_dasm.cpp b/src/devices/cpu/powerpc/ppc_dasm.cpp index 3c067e4a234..77f01f9f552 100644 --- a/src/devices/cpu/powerpc/ppc_dasm.cpp +++ b/src/devices/cpu/powerpc/ppc_dasm.cpp @@ -1169,18 +1169,10 @@ offs_t ppc_dasm_one(std::ostream &stream, uint32_t pc, uint32_t op) return 4 | flags; } -offs_t ppc_dasm_one(char *buffer, uint32_t pc, uint32_t op) -{ - std::ostringstream stream; - offs_t result = ppc_dasm_one(stream, pc, op); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} CPU_DISASSEMBLE( powerpc ) { uint32_t op = *(uint32_t *)oprom; op = big_endianize_int32(op); - return ppc_dasm_one(buffer, pc, op); + return ppc_dasm_one(stream, pc, op); } diff --git a/src/devices/cpu/powerpc/ppccom.cpp b/src/devices/cpu/powerpc/ppccom.cpp index 4d21c59ee0b..2030489da00 100644 --- a/src/devices/cpu/powerpc/ppccom.cpp +++ b/src/devices/cpu/powerpc/ppccom.cpp @@ -26,9 +26,9 @@ CONSTANTS ***************************************************************************/ -#define DOUBLE_SIGN (U64(0x8000000000000000)) -#define DOUBLE_EXP (U64(0x7ff0000000000000)) -#define DOUBLE_FRAC (U64(0x000fffffffffffff)) +#define DOUBLE_SIGN (0x8000000000000000U) +#define DOUBLE_EXP (0x7ff0000000000000U) +#define DOUBLE_FRAC (0x000fffffffffffffU) #define DOUBLE_ZERO (0) @@ -473,8 +473,8 @@ static inline int is_qnan_double(double x) { uint64_t xi = *(uint64_t*)&x; return( ((xi & DOUBLE_EXP) == DOUBLE_EXP) && - ((xi & U64(0x0007fffffffffff)) == U64(0x000000000000000)) && - ((xi & U64(0x000800000000000)) == U64(0x000800000000000)) ); + ((xi & 0x0007fffffffffffU) == 0x000000000000000U) && + ((xi & 0x000800000000000U) == 0x000800000000000U) ); } @@ -489,7 +489,7 @@ static inline int is_snan_double(double x) uint64_t xi = *(uint64_t*)&x; return( ((xi & DOUBLE_EXP) == DOUBLE_EXP) && ((xi & DOUBLE_FRAC) != DOUBLE_ZERO) && - ((xi & U64(0x0008000000000000)) == DOUBLE_ZERO) ); + ((xi & 0x0008000000000000U) == DOUBLE_ZERO) ); } #endif @@ -1010,11 +1010,11 @@ void ppc_device::state_import(const device_state_entry &entry) break; case PPC_TBL: - set_timebase((get_timebase() & ~U64(0x00ffffff00000000)) | m_debugger_temp); + set_timebase((get_timebase() & ~u64(0x00ffffff00000000U)) | m_debugger_temp); break; case PPC_TBH: - set_timebase((get_timebase() & ~U64(0x00000000ffffffff)) | ((uint64_t)(m_debugger_temp & 0x00ffffff) << 32)); + set_timebase((get_timebase() & ~u64(0x00000000ffffffffU)) | ((uint64_t)(m_debugger_temp & 0x00ffffff) << 32)); break; case PPC_DEC: @@ -1232,11 +1232,11 @@ void ppc_device::device_reset() CPU -------------------------------------------------*/ -offs_t ppc_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t ppc_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { uint32_t op = *(uint32_t *)oprom; op = big_endianize_int32(op); - return ppc_dasm_one(buffer, pc, op); + return ppc_dasm_one(stream, pc, op); } @@ -1763,10 +1763,10 @@ void ppc_device::ppccom_execute_mtspr() /* timebase */ case SPR603_TBL_W: - set_timebase((get_timebase() & ~U64(0xffffffff00000000)) | m_core->param1); + set_timebase((get_timebase() & ~u64(0xffffffff00000000U)) | m_core->param1); return; case SPR603_TBU_W: - set_timebase((get_timebase() & ~U64(0x00000000ffffffff)) | ((uint64_t)m_core->param1 << 32)); + set_timebase((get_timebase() & ~u64(0x00000000ffffffffU)) | ((uint64_t)m_core->param1 << 32)); return; } } @@ -1822,10 +1822,10 @@ void ppc_device::ppccom_execute_mtspr() /* timebase */ case SPR4XX_TBLO: - set_timebase((get_timebase() & ~U64(0x00ffffff00000000)) | m_core->param1); + set_timebase((get_timebase() & ~u64(0x00ffffff00000000U)) | m_core->param1); return; case SPR4XX_TBHI: - set_timebase((get_timebase() & ~U64(0x00000000ffffffff)) | ((uint64_t)(m_core->param1 & 0x00ffffff) << 32)); + set_timebase((get_timebase() & ~u64(0x00000000ffffffffU)) | ((uint64_t)(m_core->param1 & 0x00ffffff) << 32)); return; } } diff --git a/src/devices/cpu/powerpc/ppccom.h b/src/devices/cpu/powerpc/ppccom.h index 63e0903666e..3ec511eaac6 100644 --- a/src/devices/cpu/powerpc/ppccom.h +++ b/src/devices/cpu/powerpc/ppccom.h @@ -476,7 +476,6 @@ enum #define G_XO(op) ((op & M_XO) >> (31 - 30)) extern offs_t ppc_dasm_one(std::ostream &stream, uint32_t pc, uint32_t op); -extern offs_t ppc_dasm_one(char *buffer, uint32_t pc, uint32_t op); diff --git a/src/devices/cpu/powerpc/ppcdrc.cpp b/src/devices/cpu/powerpc/ppcdrc.cpp index d03109867c4..6c98830bb96 100644 --- a/src/devices/cpu/powerpc/ppcdrc.cpp +++ b/src/devices/cpu/powerpc/ppcdrc.cpp @@ -1127,7 +1127,7 @@ void ppc_device::static_generate_memory_accessor(int mode, int size, int iswrite { UML_DLOAD(block, I3, fastbase, I0, SIZE_QWORD, SCALE_x1); // dload i3,fastbase,i0,qword_x1 UML_DAND(block, I1, I1, I2); // dand i1,i1,i2 - UML_DXOR(block, I2, I2, U64(0xffffffffffffffff)); // dxor i2,i2,0xfffffffffffffffff + UML_DXOR(block, I2, I2, 0xffffffffffffffffU); // dxor i2,i2,0xfffffffffffffffff UML_DAND(block, I3, I3, I2); // dand i3,i3,i2 UML_DOR(block, I1, I1, I3); // dor i1,i1,i3 } @@ -1209,29 +1209,29 @@ void ppc_device::static_generate_memory_accessor(int mode, int size, int iswrite { if (iswrite) { - UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 - UML_MOV(block, mem(&m_core->tempdata.w.l), I1); // mov [tempdata],i1 + UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 + UML_MOV(block, mem(&m_core->tempdata.w.l), I1); // mov [tempdata],i1 UML_SUB(block, I0, I0, 1); // sub i0,i0,1 UML_SHR(block, I1, I1, 8); // shr i1,i1,8 - UML_MOV(block, I2, 0x00ff); // mov i2,0x00ff - UML_CALLH(block, *masked); // callh masked - UML_ADD(block, I0, mem(&m_core->tempaddr), 1); // add i0,[tempaddr],1 - UML_SHL(block, I1, mem(&m_core->tempdata.w.l), 8); // shl i1,[tempdata],8 - UML_MOV(block, I2, 0xff00); // mov i2,0xff00 - UML_CALLH(block, *masked); // callh masked + UML_MOV(block, I2, 0x00ff); // mov i2,0x00ff + UML_CALLH(block, *masked); // callh masked + UML_ADD(block, I0, mem(&m_core->tempaddr), 1); // add i0,[tempaddr],1 + UML_SHL(block, I1, mem(&m_core->tempdata.w.l), 8); // shl i1,[tempdata],8 + UML_MOV(block, I2, 0xff00); // mov i2,0xff00 + UML_CALLH(block, *masked); // callh masked } else { - UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 + UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 UML_SUB(block, I0, I0, 1); // sub i0,i0,1 - UML_MOV(block, I2, 0x00ff); // mov i2,0x00ff - UML_CALLH(block, *masked); // callh masked - UML_SHL(block, mem(&m_core->tempdata.w.l), I0, 8); // shl [tempdata],i0,8 - UML_ADD(block, I0, mem(&m_core->tempaddr), 1); // add i0,[tempaddr],1 - UML_MOV(block, I2, 0xff00); // mov i2,0xff00 - UML_CALLH(block, *masked); // callh masked + UML_MOV(block, I2, 0x00ff); // mov i2,0x00ff + UML_CALLH(block, *masked); // callh masked + UML_SHL(block, mem(&m_core->tempdata.w.l), I0, 8); // shl [tempdata],i0,8 + UML_ADD(block, I0, mem(&m_core->tempaddr), 1); // add i0,[tempaddr],1 + UML_MOV(block, I2, 0xff00); // mov i2,0xff00 + UML_CALLH(block, *masked); // callh masked UML_SHR(block, I0, I0, 8); // shr i0,i0,8 - UML_OR(block, I0, I0, mem(&m_core->tempdata.w.l)); // or i0,i0,[tempdata] + UML_OR(block, I0, I0, mem(&m_core->tempdata.w.l)); // or i0,i0,[tempdata] } } else if (size == 4) @@ -1239,108 +1239,108 @@ void ppc_device::static_generate_memory_accessor(int mode, int size, int iswrite int offs2, offs3; if (iswrite) { - UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 - UML_MOV(block, mem(&m_core->tempdata.w.l), I1); // mov [tempdata],i1 - UML_TEST(block, I0, 2); // test i0,i0,2 - UML_JMPc(block, COND_NZ, offs2 = label++); // jnz offs2 + UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 + UML_MOV(block, mem(&m_core->tempdata.w.l), I1); // mov [tempdata],i1 + UML_TEST(block, I0, 2); // test i0,i0,2 + UML_JMPc(block, COND_NZ, offs2 = label++); // jnz offs2 UML_SUB(block, I0, I0, 1); // sub i0,i0,1 UML_SHR(block, I1, I1, 8); // shr i1,i1,8 - UML_MOV(block, I2, 0x00ffffff); // mov i2,0x00ffffff - UML_CALLH(block, *masked); // callh masked - UML_ADD(block, I0, mem(&m_core->tempaddr), 3); // add i0,[tempaddr],3 - UML_SHL(block, I1, mem(&m_core->tempdata.w.l), 24); // shl i1,[tempdata],24 - UML_MOV(block, I2, 0xff000000); // mov i2,0xff000000 - UML_CALLH(block, *masked); // callh masked - UML_RET(block); // ret - UML_LABEL(block, offs2); // offs2: - UML_TEST(block, I0, 1); // test i0,i0,1 - UML_JMPc(block, COND_NZ, offs3 = label++); // jnz offs3 + UML_MOV(block, I2, 0x00ffffff); // mov i2,0x00ffffff + UML_CALLH(block, *masked); // callh masked + UML_ADD(block, I0, mem(&m_core->tempaddr), 3); // add i0,[tempaddr],3 + UML_SHL(block, I1, mem(&m_core->tempdata.w.l), 24); // shl i1,[tempdata],24 + UML_MOV(block, I2, 0xff000000); // mov i2,0xff000000 + UML_CALLH(block, *masked); // callh masked + UML_RET(block); // ret + UML_LABEL(block, offs2); // offs2: + UML_TEST(block, I0, 1); // test i0,i0,1 + UML_JMPc(block, COND_NZ, offs3 = label++); // jnz offs3 UML_SUB(block, I0, I0, 2); // sub i0,i0,2 UML_SHR(block, I1, I1, 16); // shr i1,i1,16 - UML_MOV(block, I2, 0x0000ffff); // mov i2,0x0000ffff - UML_CALLH(block, *masked); // callh masked - UML_ADD(block, I0, mem(&m_core->tempaddr), 2); // add i0,[tempaddr],2 - UML_SHL(block, I1, mem(&m_core->tempdata.w.l), 16); // shl i1,[tempdata],16 - UML_MOV(block, I2, 0xffff0000); // mov i2,0xffff0000 - UML_CALLH(block, *masked); // callh masked - UML_RET(block); // ret - UML_LABEL(block, offs3); // offs3: + UML_MOV(block, I2, 0x0000ffff); // mov i2,0x0000ffff + UML_CALLH(block, *masked); // callh masked + UML_ADD(block, I0, mem(&m_core->tempaddr), 2); // add i0,[tempaddr],2 + UML_SHL(block, I1, mem(&m_core->tempdata.w.l), 16); // shl i1,[tempdata],16 + UML_MOV(block, I2, 0xffff0000); // mov i2,0xffff0000 + UML_CALLH(block, *masked); // callh masked + UML_RET(block); // ret + UML_LABEL(block, offs3); // offs3: UML_SUB(block, I0, I0, 3); // sub i0,i0,3 UML_SHR(block, I1, I1, 24); // shr i1,i1,24 - UML_MOV(block, I2, 0x000000ff); // mov i2,0x000000ff - UML_CALLH(block, *masked); // callh masked - UML_ADD(block, I0, mem(&m_core->tempaddr), 1); // add i0,[tempaddr],1 - UML_SHL(block, I1, mem(&m_core->tempdata.w.l), 8); // shl i1,[tempdata],8 - UML_MOV(block, I2, 0xffffff00); // mov i2,0xffffff00 - UML_CALLH(block, *masked); // callh masked + UML_MOV(block, I2, 0x000000ff); // mov i2,0x000000ff + UML_CALLH(block, *masked); // callh masked + UML_ADD(block, I0, mem(&m_core->tempaddr), 1); // add i0,[tempaddr],1 + UML_SHL(block, I1, mem(&m_core->tempdata.w.l), 8); // shl i1,[tempdata],8 + UML_MOV(block, I2, 0xffffff00); // mov i2,0xffffff00 + UML_CALLH(block, *masked); // callh masked } else { - UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 - UML_TEST(block, I0, 2); // test i0,i0,2 - UML_JMPc(block, COND_NZ, offs2 = label++); // jnz offs2 + UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 + UML_TEST(block, I0, 2); // test i0,i0,2 + UML_JMPc(block, COND_NZ, offs2 = label++); // jnz offs2 UML_SUB(block, I0, I0, 1); // sub i0,i0,1 - UML_MOV(block, I2, 0x00ffffff); // mov i2,0x00ffffff - UML_CALLH(block, *masked); // callh masked - UML_SHL(block, mem(&m_core->tempdata.w.l), I0, 8); // shl [tempdata],i0,8 - UML_ADD(block, I0, mem(&m_core->tempaddr), 3); // add i0,[tempaddr],3 - UML_MOV(block, I2, 0xff000000); // mov i2,0xff000000 - UML_CALLH(block, *masked); // callh masked + UML_MOV(block, I2, 0x00ffffff); // mov i2,0x00ffffff + UML_CALLH(block, *masked); // callh masked + UML_SHL(block, mem(&m_core->tempdata.w.l), I0, 8); // shl [tempdata],i0,8 + UML_ADD(block, I0, mem(&m_core->tempaddr), 3); // add i0,[tempaddr],3 + UML_MOV(block, I2, 0xff000000); // mov i2,0xff000000 + UML_CALLH(block, *masked); // callh masked UML_SHR(block, I0, I0, 24); // shr i0,i0,24 - UML_OR(block, I0, I0, mem(&m_core->tempdata.w.l)); // or i0,i0,[tempdata] - UML_RET(block); // ret - UML_LABEL(block, offs2); // offs2: - UML_TEST(block, I0, 1); // test i0,i0,1 - UML_JMPc(block, COND_NZ, offs3 = label++); // jnz offs3 + UML_OR(block, I0, I0, mem(&m_core->tempdata.w.l)); // or i0,i0,[tempdata] + UML_RET(block); // ret + UML_LABEL(block, offs2); // offs2: + UML_TEST(block, I0, 1); // test i0,i0,1 + UML_JMPc(block, COND_NZ, offs3 = label++); // jnz offs3 UML_SUB(block, I0, I0, 2); // sub i0,i0,2 - UML_MOV(block, I2, 0x0000ffff); // mov i2,0x0000ffff - UML_CALLH(block, *masked); // callh masked - UML_SHL(block, mem(&m_core->tempdata.w.l), I0, 16); // shl [tempdata],i0,16 - UML_ADD(block, I0, mem(&m_core->tempaddr), 2); // add i0,[tempaddr],2 - UML_MOV(block, I2, 0xffff0000); // mov i2,0xffff0000 - UML_CALLH(block, *masked); // callh masked + UML_MOV(block, I2, 0x0000ffff); // mov i2,0x0000ffff + UML_CALLH(block, *masked); // callh masked + UML_SHL(block, mem(&m_core->tempdata.w.l), I0, 16); // shl [tempdata],i0,16 + UML_ADD(block, I0, mem(&m_core->tempaddr), 2); // add i0,[tempaddr],2 + UML_MOV(block, I2, 0xffff0000); // mov i2,0xffff0000 + UML_CALLH(block, *masked); // callh masked UML_SHR(block, I0, I0, 16); // shr i0,i0,16 - UML_OR(block, I0, I0, mem(&m_core->tempdata.w.l)); // or i0,i0,[tempdata] - UML_RET(block); // ret - UML_LABEL(block, offs3); // offs3: + UML_OR(block, I0, I0, mem(&m_core->tempdata.w.l)); // or i0,i0,[tempdata] + UML_RET(block); // ret + UML_LABEL(block, offs3); // offs3: UML_SUB(block, I0, I0, 3); // sub i0,i0,3 - UML_MOV(block, I2, 0x000000ff); // mov i2,0x000000ff - UML_CALLH(block, *masked); // callh masked - UML_SHL(block, mem(&m_core->tempdata.w.l), I0, 24); // shl [tempdata],i0,24 - UML_ADD(block, I0, mem(&m_core->tempaddr), 1); // add i0,[tempaddr],1 - UML_MOV(block, I2, 0xffffff00); // mov i2,0xffffff00 - UML_CALLH(block, *masked); // callh masked + UML_MOV(block, I2, 0x000000ff); // mov i2,0x000000ff + UML_CALLH(block, *masked); // callh masked + UML_SHL(block, mem(&m_core->tempdata.w.l), I0, 24); // shl [tempdata],i0,24 + UML_ADD(block, I0, mem(&m_core->tempaddr), 1); // add i0,[tempaddr],1 + UML_MOV(block, I2, 0xffffff00); // mov i2,0xffffff00 + UML_CALLH(block, *masked); // callh masked UML_SHR(block, I0, I0, 8); // shr i0,i0,8 - UML_OR(block, I0, I0, mem(&m_core->tempdata.w.l)); // or i0,i0,[tempdata] + UML_OR(block, I0, I0, mem(&m_core->tempdata.w.l)); // or i0,i0,[tempdata] } } else if (size == 8) { if (iswrite) { - UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 - UML_DMOV(block, mem(&m_core->tempdata.d), I1); // dmov [tempdata],i1 - UML_DSHR(block, I1, I1, 32); // dshr i1,i1,32 - UML_AND(block, I0, I0, ~7); // and i0,i0,~7 - UML_DMOV(block, I2, U64(0x00000000ffffffff)); // dmov i2,0x00000000ffffffff - UML_CALLH(block, *masked); // callh masked - UML_ADD(block, I0, mem(&m_core->tempaddr), 4); // add i0,[tempaddr],4 - UML_DSHL(block, I1, mem(&m_core->tempdata.d), 32); // dshl i1,[tempdata],32 - UML_DMOV(block, I2, U64(0xffffffff00000000)); // dmov i2,0xffffffff00000000 - UML_CALLH(block, *masked); // callh masked + UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 + UML_DMOV(block, mem(&m_core->tempdata.d), I1); // dmov [tempdata],i1 + UML_DSHR(block, I1, I1, 32); // dshr i1,i1,32 + UML_AND(block, I0, I0, ~7); // and i0,i0,~7 + UML_DMOV(block, I2, 0x00000000ffffffffU); // dmov i2,0x00000000ffffffff + UML_CALLH(block, *masked); // callh masked + UML_ADD(block, I0, mem(&m_core->tempaddr), 4); // add i0,[tempaddr],4 + UML_DSHL(block, I1, mem(&m_core->tempdata.d), 32); // dshl i1,[tempdata],32 + UML_DMOV(block, I2, 0xffffffff00000000U); // dmov i2,0xffffffff00000000 + UML_CALLH(block, *masked); // callh masked } else { - UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 - UML_DMOV(block, I2, U64(0x00000000ffffffff)); // mov i2,0x00000000ffffffff - UML_AND(block, I0, I0, ~7); // and i0,i0,~7 - UML_CALLH(block, *masked); // callh masked - UML_DSHL(block, mem(&m_core->tempdata.d), I0, 32); // dshl [tempdata],i0,32 - UML_ADD(block, I0, mem(&m_core->tempaddr), 4); // add i0,[tempaddr],4 - UML_DMOV(block, I2, U64(0xffffffff00000000)); // dmov i2,0xffffffff00000000 - UML_CALLH(block, *masked); // callh masked - UML_DSHR(block, I0, I0, 32); // dshr i0,i0,32 - UML_DOR(block, I0, I0, mem(&m_core->tempdata.d)); // dor i0,i0,[tempdata] + UML_MOV(block, mem(&m_core->tempaddr), I0); // mov [tempaddr],i0 + UML_DMOV(block, I2, 0x00000000ffffffffU); // mov i2,0x00000000ffffffff + UML_AND(block, I0, I0, ~7); // and i0,i0,~7 + UML_CALLH(block, *masked); // callh masked + UML_DSHL(block, mem(&m_core->tempdata.d), I0, 32); // dshl [tempdata],i0,32 + UML_ADD(block, I0, mem(&m_core->tempaddr), 4); // add i0,[tempaddr],4 + UML_DMOV(block, I2, 0xffffffff00000000U); // dmov i2,0xffffffff00000000 + UML_CALLH(block, *masked); // callh masked + UML_DSHR(block, I0, I0, 32); // dshr i0,i0,32 + UML_DOR(block, I0, I0, mem(&m_core->tempdata.d)); // dor i0,i0,[tempdata] } } UML_RET(block); // ret @@ -3745,11 +3745,12 @@ bool ppc_device::generate_instruction_3f(drcuml_block *block, compiler_state *co void ppc_device::log_add_disasm_comment(drcuml_block *block, uint32_t pc, uint32_t op) { - char buffer[100]; if (m_drcuml->logging()) { - ppc_dasm_one(buffer, pc, op); - block->append_comment("%08X: %s", pc, buffer); // comment + util::ovectorstream stream; + ppc_dasm_one(stream, pc, op); + stream.put('\0'); + block->append_comment("%08X: %s", pc, &stream.vec()[0]); // comment } } @@ -3919,6 +3920,8 @@ void ppc_device::log_register_list(drcuml_state *drcuml, const char *string, con void ppc_device::log_opcode_desc(drcuml_state *drcuml, const opcode_desc *desclist, int indent) { + util::ovectorstream buffer; + /* open the file, creating it if necessary */ if (indent == 0) drcuml->log_printf("\nDescriptor list @ %08X\n", desclist->pc); @@ -3926,20 +3929,22 @@ void ppc_device::log_opcode_desc(drcuml_state *drcuml, const opcode_desc *descli /* output each descriptor */ for ( ; desclist != nullptr; desclist = desclist->next()) { - char buffer[100]; + buffer.clear(); + buffer.seekp(0); - /* disassemle the current instruction and output it to the log */ + /* disassemble the current instruction and output it to the log */ if (drcuml->logging() || drcuml->logging_native()) { if (desclist->flags & OPFLAG_VIRTUAL_NOOP) - strcpy(buffer, ""); + buffer << ""; else ppc_dasm_one(buffer, desclist->pc, desclist->opptr.l[0]); } else - strcpy(buffer, "???"); + buffer << "???"; - drcuml->log_printf("%08X [%08X] t:%08X f:%s: %-30s", desclist->pc, desclist->physpc, desclist->targetpc, log_desc_flags_to_string(desclist->flags), buffer); + buffer.put('\0'); + drcuml->log_printf("%08X [%08X] t:%08X f:%s: %-30s", desclist->pc, desclist->physpc, desclist->targetpc, log_desc_flags_to_string(desclist->flags), &buffer.vec()[0]); /* output register states */ log_register_list(drcuml, "use", desclist->regin, nullptr); diff --git a/src/devices/cpu/pps4/pps4.cpp b/src/devices/cpu/pps4/pps4.cpp index a8f0a08e5cc..f71c563caaa 100644 --- a/src/devices/cpu/pps4/pps4.cpp +++ b/src/devices/cpu/pps4/pps4.cpp @@ -100,10 +100,10 @@ void pps4_device::W(uint8_t data) m_SAG = 0; } -offs_t pps4_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t pps4_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( pps4 ); - return CPU_DISASSEMBLE_NAME(pps4)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(pps4)(this, stream, pc, oprom, opram, options); } /** diff --git a/src/devices/cpu/pps4/pps4.h b/src/devices/cpu/pps4/pps4.h index 224060efee1..c590ac85384 100644 --- a/src/devices/cpu/pps4/pps4.h +++ b/src/devices/cpu/pps4/pps4.h @@ -64,7 +64,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/pps4/pps4dasm.cpp b/src/devices/cpu/pps4/pps4dasm.cpp index 3dad2e7d1fd..71bf93dcb44 100644 --- a/src/devices/cpu/pps4/pps4dasm.cpp +++ b/src/devices/cpu/pps4/pps4dasm.cpp @@ -367,7 +367,7 @@ static const uint16_t table[] = { /* ff */ t_TM | t_I6i | t_OVER }; -static offs_t internal_disasm_pps4(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(pps4) { uint32_t flags = 0; unsigned PC = pc; @@ -440,12 +440,3 @@ static offs_t internal_disasm_pps4(cpu_device *device, std::ostream &stream, off return (pc - PC) | flags | DASMFLAG_SUPPORTED; } - -CPU_DISASSEMBLE(pps4) -{ - std::ostringstream stream; - offs_t result = internal_disasm_pps4(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/psx/gte.h b/src/devices/cpu/psx/gte.h index 9402c302035..d6da63e1f5e 100644 --- a/src/devices/cpu/psx/gte.h +++ b/src/devices/cpu/psx/gte.h @@ -43,8 +43,8 @@ protected: public: int44( int64_t value ) : m_value( value ), - m_positive_overflow( value > S64( 0x7ffffffffff ) ), - m_negative_overflow( value < S64( -0x80000000000 ) ) + m_positive_overflow( value > 0x7ffffffffff ), + m_negative_overflow( value < -0x80000000000 ) { } diff --git a/src/devices/cpu/psx/psx.cpp b/src/devices/cpu/psx/psx.cpp index f69e2bf8d00..839bead5b73 100644 --- a/src/devices/cpu/psx/psx.cpp +++ b/src/devices/cpu/psx/psx.cpp @@ -2052,9 +2052,9 @@ void psxcpu_device::state_string_export( const device_state_entry &entry, std::s // helper function //------------------------------------------------- -offs_t psxcpu_device::disasm_disassemble( char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options ) +offs_t psxcpu_device::disasm_disassemble( std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options ) { - return DasmPSXCPU( this, buffer, pc, opram ); + return DasmPSXCPU( this, stream, pc, opram ); } diff --git a/src/devices/cpu/psx/psx.h b/src/devices/cpu/psx/psx.h index 1def8ce9a86..2c2d8cdd17b 100644 --- a/src/devices/cpu/psx/psx.h +++ b/src/devices/cpu/psx/psx.h @@ -227,7 +227,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // CPU registers uint32_t m_pc; @@ -522,7 +522,6 @@ extern const device_type CXD8606CQ; #define CF_TLBP ( 8 ) #define CF_RFE ( 16 ) -extern unsigned DasmPSXCPU( psxcpu_state *state, std::ostream &stream, uint32_t pc, const uint8_t *opram); -extern unsigned DasmPSXCPU( psxcpu_state *state, char *buffer, uint32_t pc, const uint8_t *opram ); +extern unsigned DasmPSXCPU(psxcpu_state *state, std::ostream &stream, uint32_t pc, const uint8_t *opram); #endif /* __PSXCPU_H__ */ diff --git a/src/devices/cpu/psx/psxdasm.cpp b/src/devices/cpu/psx/psxdasm.cpp index e8dd0645577..7d65b097a86 100644 --- a/src/devices/cpu/psx/psxdasm.cpp +++ b/src/devices/cpu/psx/psxdasm.cpp @@ -683,16 +683,8 @@ unsigned DasmPSXCPU( psxcpu_state *state, std::ostream &stream, uint32_t pc, con return ( opram - oldopram ) | flags | DASMFLAG_SUPPORTED; } -unsigned DasmPSXCPU(psxcpu_state *state, char *buffer, uint32_t pc, const uint8_t *opram) -{ - std::ostringstream stream; - unsigned result = DasmPSXCPU(state, stream, pc, opram); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} CPU_DISASSEMBLE( psxcpu_generic ) { - return DasmPSXCPU( nullptr, buffer, pc, opram ); + return DasmPSXCPU( nullptr, stream, pc, opram ); } diff --git a/src/devices/cpu/rsp/rsp.cpp b/src/devices/cpu/rsp/rsp.cpp index 9c0e7e4cbd8..cfad28e91f3 100644 --- a/src/devices/cpu/rsp/rsp.cpp +++ b/src/devices/cpu/rsp/rsp.cpp @@ -139,10 +139,10 @@ rsp_device::rsp_device(const machine_config &mconfig, const char *tag, device_t { } -offs_t rsp_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t rsp_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( rsp ); - return CPU_DISASSEMBLE_NAME( rsp )(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME( rsp )(this, stream, pc, oprom, opram, options); } void rsp_device::rsp_add_imem(uint32_t *base) @@ -308,9 +308,10 @@ void rsp_device::unimplemented_opcode(uint32_t op) { if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) { - char string[200]; + util::ovectorstream string; rsp_dasm_one(string, m_ppc, op); - osd_printf_debug("%08X: %s\n", m_ppc, string); + string.put('\0'); + osd_printf_debug("%08X: %s\n", m_ppc, &string.vec()[0]); } #if SAVE_DISASM @@ -734,12 +735,14 @@ void rsp_device::execute_run() { int i, l; static uint32_t prev_regs[32]; - char string[200]; + + util::ovectorstream string; rsp_dasm_one(string, m_ppc, op); + string.put('\0'); - fprintf(m_exec_output, "%08X: %s", m_ppc, string); + fprintf(m_exec_output, "%08X: %s", m_ppc, &string.vec()[0]); - l = strlen(string); + l = string.vec().size() - 1; if (l < 36) { for (i=l; i < 36; i++) diff --git a/src/devices/cpu/rsp/rsp.h b/src/devices/cpu/rsp/rsp.h index 19e3557bf1e..cee8dfa2dde 100644 --- a/src/devices/cpu/rsp/rsp.h +++ b/src/devices/cpu/rsp/rsp.h @@ -189,7 +189,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; void unimplemented_opcode(uint32_t op); @@ -327,7 +327,6 @@ private: extern const device_type RSP; extern offs_t rsp_dasm_one(std::ostream &stream, offs_t pc, uint32_t op); -extern offs_t rsp_dasm_one(char *buffer, offs_t pc, uint32_t op); #endif /* __RSP_H__ */ diff --git a/src/devices/cpu/rsp/rsp_dasm.cpp b/src/devices/cpu/rsp/rsp_dasm.cpp index bc6f5e76549..1222c0023a4 100644 --- a/src/devices/cpu/rsp/rsp_dasm.cpp +++ b/src/devices/cpu/rsp/rsp_dasm.cpp @@ -341,20 +341,11 @@ offs_t rsp_dasm_one(std::ostream &stream, offs_t pc, uint32_t op) return 4 | flags | DASMFLAG_SUPPORTED; } -offs_t rsp_dasm_one(char *buffer, offs_t pc, uint32_t op) -{ - std::ostringstream stream; - offs_t result = rsp_dasm_one(stream, pc, op); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - /*****************************************************************************/ CPU_DISASSEMBLE( rsp ) { uint32_t op = *(uint32_t *)opram; op = big_endianize_int32(op); - return rsp_dasm_one(buffer, pc, op); + return rsp_dasm_one(stream, pc, op); } diff --git a/src/devices/cpu/rsp/rspcp2d.cpp b/src/devices/cpu/rsp/rspcp2d.cpp index 017d180626e..c755a3528ac 100644 --- a/src/devices/cpu/rsp/rspcp2d.cpp +++ b/src/devices/cpu/rsp/rspcp2d.cpp @@ -133,9 +133,10 @@ void rsp_cop2_drc::cfunc_unimplemented_opcode() const uint32_t ppc = m_rsp.m_ppc; if ((m_machine.debug_flags & DEBUG_FLAG_ENABLED) != 0) { - char string[200]; - rsp_dasm_one(string, ppc, m_rspcop2_state->op); - osd_printf_debug("%08X: %s\n", ppc, string); + std::ostringstream stream; + rsp_dasm_one(stream, ppc, m_rspcop2_state->op); + const std::string stream_string = stream.str(); + osd_printf_debug("%08X: %s\n", ppc, stream_string.c_str()); } fatalerror("RSP: unknown opcode %02X (%08X) at %08X\n", m_rspcop2_state->op >> 26, m_rspcop2_state->op, ppc); } @@ -1363,7 +1364,7 @@ void rsp_cop2_drc::vmulf() if (s1 == -32768 && s2 == -32768) { // overflow - ACCUM(i) = S64(0x0000800080000000); + ACCUM(i) = s64(0x0000800080000000U); m_vres[i] = 0x7fff; } else diff --git a/src/devices/cpu/rsp/rspdrc.cpp b/src/devices/cpu/rsp/rspdrc.cpp index cc4b43a22d1..34204110139 100644 --- a/src/devices/cpu/rsp/rspdrc.cpp +++ b/src/devices/cpu/rsp/rspdrc.cpp @@ -1283,8 +1283,9 @@ void rsp_device::log_add_disasm_comment(drcuml_block *block, uint32_t pc, uint32 { if (m_drcuml->logging()) { - char buffer[100]; + util::ovectorstream buffer; rsp_dasm_one(buffer, pc, op); - block->append_comment("%08X: %s", pc, buffer); // comment + buffer.put('\0'); + block->append_comment("%08X: %s", pc, &buffer.vec()[0]); // comment } } diff --git a/src/devices/cpu/s2650/2650dasm.cpp b/src/devices/cpu/s2650/2650dasm.cpp index 6b078177c56..872de095a3b 100644 --- a/src/devices/cpu/s2650/2650dasm.cpp +++ b/src/devices/cpu/s2650/2650dasm.cpp @@ -221,7 +221,7 @@ static char *ADR(int pc) } /* disassemble one instruction at PC into buff. return byte size of instr */ -static offs_t internal_disasm_s2650(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(s2650) { uint32_t flags = 0; int PC = pc; @@ -866,13 +866,3 @@ static offs_t internal_disasm_s2650(cpu_device *device, std::ostream &stream, of } return (pc - PC) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(s2650) -{ - std::ostringstream stream; - offs_t result = internal_disasm_s2650(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/s2650/s2650.cpp b/src/devices/cpu/s2650/s2650.cpp index 6844a1ee510..65fe70fb13a 100644 --- a/src/devices/cpu/s2650/s2650.cpp +++ b/src/devices/cpu/s2650/s2650.cpp @@ -42,10 +42,10 @@ s2650_device::s2650_device(const machine_config &mconfig, const char *tag, devic } -offs_t s2650_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t s2650_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( s2650 ); - return CPU_DISASSEMBLE_NAME(s2650)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(s2650)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/s2650/s2650.h b/src/devices/cpu/s2650/s2650.h index 8b7f36479f3..ae41f5baa6e 100644 --- a/src/devices/cpu/s2650/s2650.h +++ b/src/devices/cpu/s2650/s2650.h @@ -71,7 +71,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 3; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/saturn/saturn.cpp b/src/devices/cpu/saturn/saturn.cpp index 3f3f05b05bd..324caee4a99 100644 --- a/src/devices/cpu/saturn/saturn.cpp +++ b/src/devices/cpu/saturn/saturn.cpp @@ -58,10 +58,10 @@ saturn_device::saturn_device(const machine_config &mconfig, const char *tag, dev } -offs_t saturn_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t saturn_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( saturn ); - return CPU_DISASSEMBLE_NAME(saturn)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(saturn)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/saturn/saturn.h b/src/devices/cpu/saturn/saturn.h index c12dfd98418..df7c5f80df8 100644 --- a/src/devices/cpu/saturn/saturn.h +++ b/src/devices/cpu/saturn/saturn.h @@ -111,7 +111,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 20; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/saturn/saturnds.cpp b/src/devices/cpu/saturn/saturnds.cpp index a834ca5bc9c..a71aec2cbf6 100644 --- a/src/devices/cpu/saturn/saturnds.cpp +++ b/src/devices/cpu/saturn/saturnds.cpp @@ -1267,7 +1267,7 @@ static const int field_adr_a[]= static const int field_adr_b[]= { FieldP, FieldWP, FieldXS, FieldX, FieldS, FieldM, FieldB, FieldW }; -static offs_t internal_disasm_saturn(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(saturn) { int adr=0; @@ -1468,13 +1468,3 @@ static offs_t internal_disasm_saturn(cpu_device *device, std::ostream &stream, o return pos; } - - -CPU_DISASSEMBLE(saturn) -{ - std::ostringstream stream; - offs_t result = internal_disasm_saturn(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/sc61860/sc61860.cpp b/src/devices/cpu/sc61860/sc61860.cpp index e22bc422270..72843013855 100644 --- a/src/devices/cpu/sc61860/sc61860.cpp +++ b/src/devices/cpu/sc61860/sc61860.cpp @@ -64,10 +64,10 @@ sc61860_device::sc61860_device(const machine_config &mconfig, const char *tag, d } -offs_t sc61860_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t sc61860_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( sc61860 ); - return CPU_DISASSEMBLE_NAME(sc61860)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(sc61860)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/sc61860/sc61860.h b/src/devices/cpu/sc61860/sc61860.h index d8f993a60f4..e3da855936a 100644 --- a/src/devices/cpu/sc61860/sc61860.h +++ b/src/devices/cpu/sc61860/sc61860.h @@ -111,7 +111,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/sc61860/scdasm.cpp b/src/devices/cpu/sc61860/scdasm.cpp index fce5b8cd608..050dfaa3b1d 100644 --- a/src/devices/cpu/sc61860/scdasm.cpp +++ b/src/devices/cpu/sc61860/scdasm.cpp @@ -152,7 +152,7 @@ static const struct { const char *mnemonic; Adr adr; } table[]={ { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, }; -static offs_t internal_disasm_sc61860(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(sc61860) { const uint8_t *base_oprom = oprom; int oper=*(oprom++); @@ -208,13 +208,3 @@ static offs_t internal_disasm_sc61860(cpu_device *device, std::ostream &stream, } return oprom - base_oprom; } - - -CPU_DISASSEMBLE(sc61860) -{ - std::ostringstream stream; - offs_t result = internal_disasm_sc61860(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/scmp/scmp.cpp b/src/devices/cpu/scmp/scmp.cpp index 04f7023ac62..49e5d737695 100644 --- a/src/devices/cpu/scmp/scmp.cpp +++ b/src/devices/cpu/scmp/scmp.cpp @@ -53,10 +53,10 @@ ins8060_device::ins8060_device(const machine_config &mconfig, const char *tag, d } -offs_t scmp_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t scmp_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( scmp ); - return CPU_DISASSEMBLE_NAME(scmp)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(scmp)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/scmp/scmp.h b/src/devices/cpu/scmp/scmp.h index 9706b4167c0..be53c83e16c 100644 --- a/src/devices/cpu/scmp/scmp.h +++ b/src/devices/cpu/scmp/scmp.h @@ -58,7 +58,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/scmp/scmpdasm.cpp b/src/devices/cpu/scmp/scmpdasm.cpp index 359c819bdda..2f77afc519d 100644 --- a/src/devices/cpu/scmp/scmpdasm.cpp +++ b/src/devices/cpu/scmp/scmpdasm.cpp @@ -13,7 +13,7 @@ #define OP(A) oprom[(A) - PC] #define ARG(A) opram[(A) - PC] -static offs_t internal_disasm_scmp(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(scmp) { unsigned PC = pc; uint8_t op = OP(pc++); @@ -151,13 +151,3 @@ static offs_t internal_disasm_scmp(cpu_device *device, std::ostream &stream, off return (pc - PC); } - - -CPU_DISASSEMBLE(scmp) -{ - std::ostringstream stream; - offs_t result = internal_disasm_scmp(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/score/score.h b/src/devices/cpu/score/score.h index 5f4b2ec2c2b..8fb1002095d 100644 --- a/src/devices/cpu/score/score.h +++ b/src/devices/cpu/score/score.h @@ -55,14 +55,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override - { - std::ostringstream stream; - offs_t result = disasm_disassemble(stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; - } + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: // helpers @@ -150,8 +143,6 @@ private: static const char *const m_i1a_op[8]; static const char *const m_i1b_op[8]; static const char *const m_cr_op[2]; - - offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options); }; extern const device_type SCORE7; diff --git a/src/devices/cpu/scudsp/scudsp.cpp b/src/devices/cpu/scudsp/scudsp.cpp index 24880437d21..4d608b3b8d5 100644 --- a/src/devices/cpu/scudsp/scudsp.cpp +++ b/src/devices/cpu/scudsp/scudsp.cpp @@ -139,9 +139,9 @@ uint32_t scudsp_cpu_device::scudsp_get_source_mem_reg_value( uint32_t mode ) switch( mode ) { case 0x9: - return (uint32_t)((m_alu & U64(0x00000000ffffffff)) >> 0); + return u32((m_alu & 0x00000000ffffffffU) >> 0); case 0xA: - return (uint32_t)((m_alu & U64(0x0000ffffffff0000)) >> 16); + return u32((m_alu & 0x0000ffffffff0000U) >> 16); } } return 0; @@ -436,17 +436,17 @@ void scudsp_cpu_device::scudsp_operation(uint32_t opcode) i3 = m_acl.si + m_pl.si; m_alu = (uint64_t)(uint32_t)i3; //SET_Z(i3 == 0); - SET_Z( (i3 & S64(0xffffffffffff)) == 0 ); + SET_Z( (i3 & s64(0xffffffffffffU)) == 0 ); //SET_S(i3 < 0); - SET_S( i3 & S64(0x1000000000000)); - SET_C(i3 & S64(0x100000000)); + SET_S( i3 & s64(0x1000000000000U)); + SET_C(i3 & s64(0x100000000U)); SET_V(((i3) ^ (m_acl.si)) & ((i3) ^ (m_pl.si)) & 0x80000000); break; case 0x5: /* SUB */ i3 = m_acl.si - m_pl.si; m_alu = (uint64_t)(uint32_t)i3; SET_Z(i3 == 0); - SET_C(i3 & S64(0x100000000)); + SET_C(i3 & s64(0x100000000U)); SET_S(i3 < 0); SET_V(((m_pl.si) ^ (m_acl.si)) & ((m_pl.si) ^ (i3)) & 0x80000000); break; @@ -454,10 +454,10 @@ void scudsp_cpu_device::scudsp_operation(uint32_t opcode) i1 = concat_64((int32_t)m_ph.si,m_pl.si); i2 = concat_64((int32_t)m_ach.si,m_acl.si); m_alu = i1 + i2; - SET_Z((m_alu & S64(0xffffffffffff)) == 0); - SET_S((m_alu & S64(0x800000000000)) > 0); - SET_C((m_alu) & S64(0x1000000000000)); - SET_V(((m_alu) ^ (i1)) & ((m_alu) ^ (i2)) & S64(0x800000000000)); + SET_Z((m_alu & s64(0xffffffffffffU)) == 0); + SET_S((m_alu & s64(0x800000000000U)) > 0); + SET_C((m_alu) & s64(0x1000000000000U)); + SET_V(((m_alu) ^ (i1)) & ((m_alu) ^ (i2)) & s64(0x800000000000U)); break; case 0x7: /* ??? */ /* Unrecognized opcode */ @@ -523,8 +523,8 @@ void scudsp_cpu_device::scudsp_operation(uint32_t opcode) case 0x1: /* NOP ? */ break; case 0x2: /* MOV MUL,P */ - m_ph.ui = (uint16_t)((m_mul & U64(0x0000ffff00000000)) >> 32); - m_pl.ui = (uint32_t)((m_mul & U64(0x00000000ffffffff)) >> 0); + m_ph.ui = u16((m_mul & 0x0000ffff00000000U) >> 32); + m_pl.ui = u32((m_mul & 0x00000000ffffffffU) >> 0); break; case 0x3: /* MOV [s],P */ dsp_mem = (opcode & 0x700000) >> 20; @@ -560,8 +560,8 @@ void scudsp_cpu_device::scudsp_operation(uint32_t opcode) m_ach.ui = 0; break; case 0x2: /* MOV ALU,A */ - m_ach.ui = (uint16_t)((m_alu & U64(0x0000ffff00000000)) >> 32); - m_acl.ui = (uint32_t)((m_alu & U64(0x00000000ffffffff)) >> 0); + m_ach.ui = u16((m_alu & 0x0000ffff00000000U) >> 32); + m_acl.ui = u32((m_alu & 0x00000000ffffffffU) >> 0); break; case 0x3: /* MOV [s], A */ dsp_mem = (opcode & 0x1C000 ) >> 14; @@ -1033,8 +1033,8 @@ void scudsp_cpu_device::state_string_export(const device_state_entry &entry, std } -offs_t scudsp_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t scudsp_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( scudsp ); - return CPU_DISASSEMBLE_NAME(scudsp)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(scudsp)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/scudsp/scudsp.h b/src/devices/cpu/scudsp/scudsp.h index fb18d832703..b30667dd319 100644 --- a/src/devices/cpu/scudsp/scudsp.h +++ b/src/devices/cpu/scudsp/scudsp.h @@ -101,7 +101,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; devcb_write_line m_out_irq_cb; devcb_read16 m_in_dma_cb; diff --git a/src/devices/cpu/scudsp/scudspdasm.cpp b/src/devices/cpu/scudsp/scudspdasm.cpp index 068107a99d6..584073aceca 100644 --- a/src/devices/cpu/scudsp/scudspdasm.cpp +++ b/src/devices/cpu/scudsp/scudspdasm.cpp @@ -237,7 +237,7 @@ static void scudsp_dasm_prefix( const char* format, char* buffer, uint32_t *data } -static offs_t internal_disasm_scudsp(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(scudsp) { uint32_t op = oprom[0]<<24|oprom[1]<<16|oprom[2]<<8|oprom[3]<<0; unsigned size = 1; @@ -361,13 +361,3 @@ static offs_t internal_disasm_scudsp(cpu_device *device, std::ostream &stream, o return size; } - - -CPU_DISASSEMBLE(scudsp) -{ - std::ostringstream stream; - offs_t result = internal_disasm_scudsp(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/se3208/se3208.cpp b/src/devices/cpu/se3208/se3208.cpp index 9420e5fabe8..32cbf4d224d 100644 --- a/src/devices/cpu/se3208/se3208.cpp +++ b/src/devices/cpu/se3208/se3208.cpp @@ -1838,8 +1838,8 @@ void se3208_device::execute_set_input( int line, int state ) m_IRQ=state; } -offs_t se3208_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t se3208_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( se3208 ); - return CPU_DISASSEMBLE_NAME(se3208)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(se3208)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/se3208/se3208.h b/src/devices/cpu/se3208/se3208.h index a4fac45e1dd..7f005bec2f3 100644 --- a/src/devices/cpu/se3208/se3208.h +++ b/src/devices/cpu/se3208/se3208.h @@ -37,7 +37,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/se3208/se3208dis.cpp b/src/devices/cpu/se3208/se3208dis.cpp index 093dbc123c3..ca7d3761d61 100644 --- a/src/devices/cpu/se3208/se3208dis.cpp +++ b/src/devices/cpu/se3208/se3208dis.cpp @@ -1400,7 +1400,7 @@ static _OP DecodeOp(uint16_t Opcode) } -static offs_t internal_disasm_se3208(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(se3208) { uint16_t Opcode; @@ -1411,13 +1411,3 @@ static offs_t internal_disasm_se3208(cpu_device *device, std::ostream &stream, o Opcode=oprom[0] | (oprom[1] << 8); return 2 | ((*DecodeOp(Opcode))(Opcode, stream)) | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(se3208) -{ - std::ostringstream stream; - offs_t result = internal_disasm_se3208(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/sh2/sh2.cpp b/src/devices/cpu/sh2/sh2.cpp index 78bf317d3e2..ad000212a13 100644 --- a/src/devices/cpu/sh2/sh2.cpp +++ b/src/devices/cpu/sh2/sh2.cpp @@ -248,10 +248,10 @@ const address_space_config *sh2_device::memory_space_config(address_spacenum spa } } -offs_t sh2_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t sh2_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( sh2 ); - return CPU_DISASSEMBLE_NAME( sh2 )(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME( sh2 )(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/sh2/sh2.h b/src/devices/cpu/sh2/sh2.h index cf38bea2526..b13ce13f618 100644 --- a/src/devices/cpu/sh2/sh2.h +++ b/src/devices/cpu/sh2/sh2.h @@ -135,7 +135,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space *m_program, *m_decrypted_program; private: diff --git a/src/devices/cpu/sh2/sh2dasm.cpp b/src/devices/cpu/sh2/sh2dasm.cpp index a484c2a9cb4..ef823ee28a5 100644 --- a/src/devices/cpu/sh2/sh2dasm.cpp +++ b/src/devices/cpu/sh2/sh2dasm.cpp @@ -606,9 +606,5 @@ unsigned DasmSH2(std::ostream &stream, unsigned pc, uint16_t opcode) CPU_DISASSEMBLE(sh2) { - std::ostringstream stream; - offs_t result = DasmSH2(stream, pc, (oprom[0] << 8) | oprom[1]); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; + return DasmSH2(stream, pc, (oprom[0] << 8) | oprom[1]); } diff --git a/src/devices/cpu/sh4/sh4.cpp b/src/devices/cpu/sh4/sh4.cpp index 831804260a8..0dce1e5c744 100644 --- a/src/devices/cpu/sh4/sh4.cpp +++ b/src/devices/cpu/sh4/sh4.cpp @@ -75,13 +75,17 @@ static ADDRESS_MAP_START( sh4_internal_map, AS_PROGRAM, 64, sh4_base_device ) AM_RANGE(0x1C000000, 0x1C000FFF) AM_RAM AM_MIRROR(0x01FFF000) AM_RANGE(0x1E000000, 0x1E000FFF) AM_RAM AM_MIRROR(0x01FFF000) AM_RANGE(0xE0000000, 0xE000003F) AM_RAM AM_MIRROR(0x03FFFFC0) // todo: store queues should be write only on DC's SH4, executing PREFM shouldn't cause an actual memory read access! - AM_RANGE(0xF6000000, 0xF7FFFFFF) AM_READWRITE(sh4_tlb_r,sh4_tlb_w) - AM_RANGE(0xFE000000, 0xFFFFFFFF) AM_READWRITE32(sh4_internal_r, sh4_internal_w, U64(0xffffffffffffffff)) + + AM_RANGE(0xF6000000, 0xF6FFFFFF) AM_READWRITE(sh4_utlb_address_array_r,sh4_utlb_address_array_w) + AM_RANGE(0xF7000000, 0xF77FFFFF) AM_READWRITE(sh4_utlb_data_array1_r,sh4_utlb_data_array1_w) + AM_RANGE(0xF7800000, 0xF7FFFFFF) AM_READWRITE(sh4_utlb_data_array2_r,sh4_utlb_data_array2_w) + + AM_RANGE(0xFE000000, 0xFFFFFFFF) AM_READWRITE32(sh4_internal_r, sh4_internal_w, 0xffffffffffffffffU) ADDRESS_MAP_END static ADDRESS_MAP_START( sh3_internal_map, AS_PROGRAM, 64, sh3_base_device ) - AM_RANGE(SH3_LOWER_REGBASE, SH3_LOWER_REGEND) AM_READWRITE32(sh3_internal_r, sh3_internal_w, U64(0xffffffffffffffff)) - AM_RANGE(SH3_UPPER_REGBASE, SH3_UPPER_REGEND) AM_READWRITE32(sh3_internal_high_r, sh3_internal_high_w, U64(0xffffffffffffffff)) + AM_RANGE(SH3_LOWER_REGBASE, SH3_LOWER_REGEND) AM_READWRITE32(sh3_internal_r, sh3_internal_w, 0xffffffffffffffffU) + AM_RANGE(SH3_UPPER_REGBASE, SH3_UPPER_REGEND) AM_READWRITE32(sh3_internal_high_r, sh3_internal_high_w, 0xffffffffffffffffU) ADDRESS_MAP_END @@ -99,6 +103,7 @@ sh34_base_device::sh34_base_device(const machine_config &mconfig, device_type ty , c_md7(0) , c_md8(0) , c_clock(0) + , m_mmuhack(1) #if SH4_USE_FASTRAM_OPTIMIZATION , m_bigendian(endianness == ENDIANNESS_BIG) , m_byte_xor(m_bigendian ? BYTE8_XOR_BE(0) : BYTE8_XOR_LE(0)) @@ -151,27 +156,27 @@ sh4be_device::sh4be_device(const machine_config &mconfig, const char *tag, devic } -offs_t sh34_base_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t sh34_base_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( sh4 ); - return CPU_DISASSEMBLE_NAME(sh4)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(sh4)(this, stream, pc, oprom, opram, options); } -offs_t sh3be_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t sh3be_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( sh4be ); - return CPU_DISASSEMBLE_NAME(sh4be)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(sh4be)(this, stream, pc, oprom, opram, options); } -offs_t sh4be_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t sh4be_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( sh4be ); - return CPU_DISASSEMBLE_NAME(sh4be)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(sh4be)(this, stream, pc, oprom, opram, options); } @@ -180,6 +185,37 @@ void sh34_base_device::TODO(const uint16_t opcode) { } +void sh34_base_device::LDTLB(const uint16_t opcode) +{ + logerror("unhandled LDTLB for this CPU type\n"); +} + +void sh4_base_device::LDTLB(const uint16_t opcode) +{ + int replace = (m_m[MMUCR] & 0x0000fc00) >> 10; + + logerror("using LDTLB to replace UTLB entry %02x\n", replace); + + // these come from PTEH + m_utlb[replace].VPN = (m_m[PTEH] & 0xfffffc00) >> 10; +// m_utlb[replace].D = (m_m[PTEH] & 0x00000200) >> 9; // from PTEL +// m_utlb[replace].V = (m_m[PTEH] & 0x00000100) >> 8; // from PTEL + m_utlb[replace].ASID = (m_m[PTEH] & 0x000000ff) >> 0; + // these come from PTEL + m_utlb[replace].PPN = (m_m[PTEL] & 0x1ffffc00) >> 10; + m_utlb[replace].V = (m_m[PTEL] & 0x00000100) >> 8; + m_utlb[replace].PSZ = (m_m[PTEL] & 0x00000080) >> 6; + m_utlb[replace].PSZ |=(m_m[PTEL] & 0x00000010) >> 4; + m_utlb[replace].PPR= (m_m[PTEL] & 0x00000060) >> 5; + m_utlb[replace].C = (m_m[PTEL] & 0x00000008) >> 3; + m_utlb[replace].D = (m_m[PTEL] & 0x00000004) >> 2; + m_utlb[replace].SH = (m_m[PTEL] & 0x00000002) >> 1; + m_utlb[replace].WT = (m_m[PTEL] & 0x00000001) >> 0; + // these come from PTEA + m_utlb[replace].TC = (m_m[PTEA] & 0x00000008) >> 3; + m_utlb[replace].SA = (m_m[PTEA] & 0x00000007) >> 0; +} + #if 0 int sign_of(int n) { @@ -263,21 +299,36 @@ inline uint8_t sh34_base_device::RB(offs_t A) if (A >= 0xe0000000) return m_program->read_byte(A); -#if SH4_USE_FASTRAM_OPTIMIZATION - const offs_t _A = A & AM; - for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) + if (A >= 0x80000000) // P1/P2/P3 region { - if (_A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) +#if SH4_USE_FASTRAM_OPTIMIZATION + const offs_t _A = A & AM; + for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) { - continue; + if (_A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) + { + continue; + } + uint8_t *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; + return fastbase[_A ^ m_byte_xor]; } - uint8_t *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; - return fastbase[_A ^ m_byte_xor]; - } - return m_program->read_byte(_A); + return m_program->read_byte(_A); #else - return m_program->read_byte(A & AM); + return m_program->read_byte(A & AM); #endif + } + else // P0 region + { + if (!m_sh4_mmu_enabled) + { + return m_program->read_byte(A & AM); + } + else + { + A = get_remap(A & AM); + return m_program->read_byte(A); + } + } } @@ -286,21 +337,36 @@ inline uint16_t sh34_base_device::RW(offs_t A) if (A >= 0xe0000000) return m_program->read_word(A); -#if SH4_USE_FASTRAM_OPTIMIZATION - const offs_t _A = A & AM; - for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) + if (A >= 0x80000000) // P1/P2/P3 region { - if (_A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) +#if SH4_USE_FASTRAM_OPTIMIZATION + const offs_t _A = A & AM; + for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) { - continue; + if (_A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) + { + continue; + } + uint8_t *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; + return ((uint16_t*)fastbase)[(_A ^ m_word_xor) >> 1]; } - uint8_t *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; - return ((uint16_t*)fastbase)[(_A ^ m_word_xor) >> 1]; - } - return m_program->read_word(_A); + return m_program->read_word(_A); #else - return m_program->read_word(A & AM); + return m_program->read_word(A & AM); #endif + } + else + { + if (!m_sh4_mmu_enabled) + { + return m_program->read_word(A & AM); + } + else + { + A = get_remap(A & AM); + return m_program->read_word(A); + } + } } @@ -309,21 +375,36 @@ inline uint32_t sh34_base_device::RL(offs_t A) if (A >= 0xe0000000) return m_program->read_dword(A); -#if SH4_USE_FASTRAM_OPTIMIZATION - const offs_t _A = A & AM; - for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) + if (A >= 0x80000000) // P1/P2/P3 region { - if (_A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) +#if SH4_USE_FASTRAM_OPTIMIZATION + const offs_t _A = A & AM; + for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) { - continue; + if (_A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) + { + continue; + } + uint8_t *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; + return ((uint32_t*)fastbase)[(_A^m_dword_xor) >> 2]; } - uint8_t *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; - return ((uint32_t*)fastbase)[(_A^m_dword_xor) >> 2]; - } - return m_program->read_dword(_A); + return m_program->read_dword(_A); #else - return m_program->read_dword(A & AM); + return m_program->read_dword(A & AM); #endif + } + else + { + if (!m_sh4_mmu_enabled) + { + return m_program->read_dword(A & AM); + } + else + { + A = get_remap(A & AM); + return m_program->read_dword(A); + } + } } @@ -334,22 +415,38 @@ inline void sh34_base_device::WB(offs_t A, uint8_t V) m_program->write_byte(A,V); return; } -#if SH4_USE_FASTRAM_OPTIMIZATION - const offs_t _A = A & AM; - for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) + + if (A >= 0x80000000) // P1/P2/P3 region { - if (m_fastram[ramnum].readonly == true || _A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) +#if SH4_USE_FASTRAM_OPTIMIZATION + const offs_t _A = A & AM; + for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) { - continue; + if (m_fastram[ramnum].readonly == true || _A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) + { + continue; + } + uint8_t *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; + fastbase[_A ^ m_byte_xor] = V; + return; } - uint8_t *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; - fastbase[_A ^ m_byte_xor] = V; - return; - } - m_program->write_byte(_A,V); + m_program->write_byte(_A, V); #else - m_program->write_byte(A & AM,V); + m_program->write_byte(A & AM, V); #endif + } + else + { + if (!m_sh4_mmu_enabled) + { + m_program->write_byte(A & AM, V); + } + else + { + A = get_remap(A & AM); + m_program->write_byte(A, V); + } + } } @@ -360,22 +457,38 @@ inline void sh34_base_device::WW(offs_t A, uint16_t V) m_program->write_word(A,V); return; } -#if SH4_USE_FASTRAM_OPTIMIZATION - const offs_t _A = A & AM; - for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) + + if (A >= 0x80000000) // P1/P2/P3 region { - if (m_fastram[ramnum].readonly == true || _A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) +#if SH4_USE_FASTRAM_OPTIMIZATION + const offs_t _A = A & AM; + for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) { - continue; + if (m_fastram[ramnum].readonly == true || _A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) + { + continue; + } + void *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; + ((uint16_t*)fastbase)[(_A ^ m_word_xor) >> 1] = V; + return; } - void *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; - ((uint16_t*)fastbase)[(_A ^ m_word_xor) >> 1] = V; - return; - } - m_program->write_word(_A,V); + m_program->write_word(_A, V); #else - m_program->write_word(A & AM,V); + m_program->write_word(A & AM, V); #endif + } + else + { + if (!m_sh4_mmu_enabled) + { + m_program->write_word(A & AM, V); + } + else + { + A = get_remap(A & AM); + m_program->write_word(A, V); + } + } } @@ -386,22 +499,39 @@ inline void sh34_base_device::WL(offs_t A, uint32_t V) m_program->write_dword(A,V); return; } -#if SH4_USE_FASTRAM_OPTIMIZATION - const offs_t _A = A & AM; - for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) + + if (A >= 0x80000000) // P1/P2/P3 region { - if (m_fastram[ramnum].readonly == true || _A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) +#if SH4_USE_FASTRAM_OPTIMIZATION + const offs_t _A = A & AM; + for (int ramnum = 0; ramnum < m_fastram_select; ramnum++) { - continue; + if (m_fastram[ramnum].readonly == true || _A < m_fastram[ramnum].start || _A > m_fastram[ramnum].end) + { + continue; + } + void *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; + ((uint32_t*)fastbase)[(_A ^ m_dword_xor) >> 2] = V; + return; } - void *fastbase = (uint8_t*)m_fastram[ramnum].base - m_fastram[ramnum].start; - ((uint32_t*)fastbase)[(_A ^ m_dword_xor) >> 2] = V; - return; - } - m_program->write_dword(_A,V); + m_program->write_dword(_A, V); #else - m_program->write_dword(A & AM,V); + m_program->write_dword(A & AM, V); #endif + } + else + { + if (!m_sh4_mmu_enabled) + { + m_program->write_dword(A & AM, V); + } + else + { + A = get_remap(A & AM); + m_program->write_dword(A, V); + } + } + } /* code cycles t-bit @@ -3331,7 +3461,7 @@ inline void sh34_base_device::execute_one_0000(const uint16_t opcode) case 0x08: CLRT(opcode); break; case 0x18: SETT(opcode); break; case 0x28: CLRMAC(opcode); break; - case 0x38: TODO(opcode); break; + case 0x38: LDTLB(opcode); break; case 0x48: CLRS(opcode); break; case 0x58: SETS(opcode); break; case 0x68: NOP(opcode); break; @@ -3339,7 +3469,7 @@ inline void sh34_base_device::execute_one_0000(const uint16_t opcode) case 0x88: CLRT(opcode); break; case 0x98: SETT(opcode); break; case 0xa8: CLRMAC(opcode); break; - case 0xb8: TODO(opcode); break; + case 0xb8: LDTLB(opcode); break; case 0xc8: CLRS(opcode); break; case 0xd8: SETS(opcode); break; case 0xe8: NOP(opcode); break; @@ -3939,7 +4069,10 @@ void sh34_base_device::execute_run() m_ppc = m_pc & AM; debugger_instruction_hook(this, m_pc & AM); - const uint16_t opcode = m_direct->read_word(m_pc & AM, WORD2_XOR_LE(0)); + uint16_t opcode; + + if (!m_sh4_mmu_enabled) opcode = m_direct->read_word(m_pc & AM, WORD2_XOR_LE(0)); + else opcode = RW(m_pc); // should probably use a different function as this needs to go through the ITLB if (m_delay) { @@ -4028,6 +4161,47 @@ void sh4be_device::execute_run() } while( m_sh4_icount > 0 ); } +void sh4_base_device::device_start() +{ + sh34_base_device::device_start(); + + int i; + for (i=0;i<64;i++) + { + m_utlb[i].ASID = 0; + m_utlb[i].VPN = 0; + m_utlb[i].V = 0; + m_utlb[i].PPN = 0; + m_utlb[i].PSZ = 0; + m_utlb[i].SH = 0; + m_utlb[i].C = 0; + m_utlb[i].PPR = 0; + m_utlb[i].D = 0; + m_utlb[i].WT = 0; + m_utlb[i].SA = 0; + m_utlb[i].TC = 0; + } + + for (i=0;i<64;i++) + { + save_item(NAME(m_utlb[i].ASID), i); + save_item(NAME(m_utlb[i].VPN), i); + save_item(NAME(m_utlb[i].V), i); + save_item(NAME(m_utlb[i].PPN), i); + save_item(NAME(m_utlb[i].PSZ), i); + save_item(NAME(m_utlb[i].SH), i); + save_item(NAME(m_utlb[i].C), i); + save_item(NAME(m_utlb[i].PPR), i); + save_item(NAME(m_utlb[i].D), i); + save_item(NAME(m_utlb[i].WT), i); + save_item(NAME(m_utlb[i].SA), i); + save_item(NAME(m_utlb[i].TC), i); + } + +} + + + void sh34_base_device::device_start() { for (int i=0; i<3; i++) @@ -4134,8 +4308,6 @@ void sh34_base_device::device_start() save_item(NAME( m_ioport16_direction)); save_item(NAME(m_ioport4_pullup)); save_item(NAME(m_ioport4_direction)); - save_item(NAME(m_sh4_tlb_address)); - save_item(NAME(m_sh4_tlb_data)); save_item(NAME(m_sh4_mmu_enabled)); save_item(NAME(m_sh3internal_upper)); save_item(NAME(m_sh3internal_lower)); diff --git a/src/devices/cpu/sh4/sh4.h b/src/devices/cpu/sh4/sh4.h index 9af8dd3fa1c..0720ec9375d 100644 --- a/src/devices/cpu/sh4/sh4.h +++ b/src/devices/cpu/sh4/sh4.h @@ -136,6 +136,26 @@ struct sh4_ddt_dma int mode; }; + +// ASID [7:0] | VPN [31:10] | V | | PPN [28:10] | SZ[1:0] | SH | C | PR[1:0] | D | WT | SA[2:0] | TC + +struct sh4_utlb +{ + uint8_t ASID; + uint32_t VPN; + uint8_t V; + uint32_t PPN; + uint8_t PSZ; + uint8_t SH; + uint8_t C; + uint8_t PPR; + uint8_t D; + uint8_t WT; + uint8_t SA; + uint8_t TC; +}; + + typedef void (*sh4_ftcsr_callback)(uint32_t); @@ -170,6 +190,10 @@ typedef void (*sh4_ftcsr_callback)(uint32_t); sh34_base_device::set_sh4_clock(*device, _clock); +#define MCFG_MMU_HACK_TYPE(_hacktype) \ + sh34_base_device::set_mmu_hacktype(*device, _hacktype); + + class sh34_base_device : public cpu_device { public: @@ -191,6 +215,8 @@ public: static void set_md8(device_t &device, int md0) { downcast(device).c_md8 = md0; } static void set_sh4_clock(device_t &device, int clock) { downcast(device).c_clock = clock; } + static void set_mmu_hacktype(device_t &device, int hacktype) { downcast(device).m_mmuhack = hacktype; } + TIMER_CALLBACK_MEMBER( sh4_refresh_timer_callback ); TIMER_CALLBACK_MEMBER( sh4_rtc_timer_callback ); TIMER_CALLBACK_MEMBER( sh4_timer_callback ); @@ -225,7 +251,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; protected: address_space_config m_program_config; @@ -242,6 +268,9 @@ protected: int c_md8; int c_clock; + // hack 1 = Naomi hack, hack 2 = Work in Progress implementation + int m_mmuhack; + uint32_t m_ppc; uint32_t m_pc; uint32_t m_spc; @@ -358,8 +387,6 @@ protected: void (*m_ftcsr_read_callback)(uint32_t data); /* This MMU simulation is good for the simple remap used on Naomi GD-ROM SQ access *ONLY* */ - uint32_t m_sh4_tlb_address[64]; - uint32_t m_sh4_tlb_data[64]; uint8_t m_sh4_mmu_enabled; int m_cpu_type; @@ -451,6 +478,7 @@ protected: void LDSMMACH(const uint16_t opcode); void LDSMMACL(const uint16_t opcode); void LDSMPR(const uint16_t opcode); + virtual void LDTLB(const uint16_t opcode); void MAC_L(const uint16_t opcode); void MAC_W(const uint16_t opcode); void MOV(const uint16_t opcode); @@ -627,7 +655,8 @@ protected: void increment_rtc_time(int mode); void sh4_dmac_nmi(); void sh4_handler_ipra_w(uint32_t data, uint32_t mem_mask); - uint32_t sh4_getsqremap(uint32_t address); + virtual uint32_t get_remap(uint32_t address); + virtual uint32_t sh4_getsqremap(uint32_t address); void sh4_parse_configuration(); void sh4_timer_recompute(int which); uint32_t sh4_handle_tcnt0_addr_r(uint32_t mem_mask); @@ -736,10 +765,21 @@ public: DECLARE_WRITE32_MEMBER( sh4_internal_w ); DECLARE_READ32_MEMBER( sh4_internal_r ); - DECLARE_READ64_MEMBER( sh4_tlb_r ); - DECLARE_WRITE64_MEMBER( sh4_tlb_w ); + DECLARE_READ64_MEMBER( sh4_utlb_address_array_r ); + DECLARE_WRITE64_MEMBER( sh4_utlb_address_array_w ); + DECLARE_READ64_MEMBER( sh4_utlb_data_array1_r ); + DECLARE_WRITE64_MEMBER( sh4_utlb_data_array1_w ); + DECLARE_READ64_MEMBER( sh4_utlb_data_array2_r ); + DECLARE_WRITE64_MEMBER( sh4_utlb_data_array2_w ); + + virtual void LDTLB(const uint16_t opcode) override; + + virtual uint32_t get_remap(uint32_t address) override; + virtual uint32_t sh4_getsqremap(uint32_t address) override; + sh4_utlb m_utlb[64]; protected: + virtual void device_start() override; virtual void device_reset() override; }; @@ -758,7 +798,7 @@ public: protected: virtual void execute_run() override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; @@ -776,7 +816,7 @@ public: protected: virtual void execute_run() override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; diff --git a/src/devices/cpu/sh4/sh4comn.cpp b/src/devices/cpu/sh4/sh4comn.cpp index 985413e4a73..dbb794e0c82 100644 --- a/src/devices/cpu/sh4/sh4comn.cpp +++ b/src/devices/cpu/sh4/sh4comn.cpp @@ -676,26 +676,106 @@ WRITE32_MEMBER( sh4_base_device::sh4_internal_w ) // printf("sh4_internal_w: Write %08x (%x), %08x @ %08x\n", 0xfe000000+((offset & 0x3fc0) << 11)+((offset & 0x3f) << 2), offset, data, mem_mask); - switch( offset ) + switch( offset ) { + case PTEH: // for use with LDTLB opcode + m_m[PTEH] &= 0xffffffff; + /* + NNNN NNNN NNNN NNNN NNNN NN-- AAAA AAAA + + N = VPM = Virtual Page Number + A = ASID = Address Space Identifier + + same as the address table part of the utlb but with 2 unused bits (these are sourced from PTEL instead when LDTLB is called) + */ + + + break; + + case PTEL: + m_m[PTEL] &= 0xffffffff; + /* + ---P PPPP PPPP PPPP PPPP PP-V zRRz CDHW + + same format as data array 1 of the utlb + */ + break; + + case PTEA: + m_m[PTEA] &= 0xffffffff; + /* + ---- ---- ---- ---- ---- ---- ---- TSSS + + same format as data array 2 of the utlb + */ + break; + + case TTB: + m_m[TTB] &= 0xffffffff; + logerror("TTB set to %08x\n", data); + break; + + case TEA: + m_m[TEA] &= 0xffffffff; + logerror("TEA set to %08x\n", data); + break; + + case MMUCR: // MMU Control + logerror("%s: MMUCR %08x\n", machine().describe_context(), data); + m_m[MMUCR] &= 0xffffffff; + /* + LLLL LL-- BBBB BB-- CCCC CCQV ---- -T-A + + L = LRUI = Least recently used ITLB + B = URB = UTLB replace boundary + C = URC = UTLB replace counter + Q = SQMD = Store Queue Mode Bit + V = SV = Single Virtual Mode Bit + T = TI = TLB invaldiate + A = AT = Address translation bit (enable) + */ + + + if (data & MMUCR_AT) { - printf("SH4 MMU Enabled\n"); - printf("If you're seeing this, but running something other than a Naomi GD-ROM game then chances are it won't work\n"); - printf("The MMU emulation is a hack specific to that system\n"); m_sh4_mmu_enabled = 1; - // should be a different bit! - { - int i; - for (i=0;i<64;i++) - { - m_sh4_tlb_address[i] = 0; - m_sh4_tlb_data[i] = 0; - } + if (m_mmuhack == 1) + { + printf("SH4 MMU Enabled\n"); + printf("If you're seeing this, but running something other than a Naomi GD-ROM game then chances are it won't work\n"); + printf("The MMU emulation is a hack specific to that system\n"); } + + + if (m_mmuhack == 2) + { + for (int i = 0;i < 64;i++) + { + if (m_utlb[i].V) + { + printf("(entry %02x | ASID: %02x VPN: %08x V: %02x PPN: %08x SZ: %02x SH: %02x C: %02x PPR: %02x D: %02x WT %02x: SA: %02x TC: %02x)\n", + i, + m_utlb[i].ASID, + m_utlb[i].VPN << 10, + m_utlb[i].V, + m_utlb[i].PPN << 10, + m_utlb[i].PSZ, + m_utlb[i].SH, + m_utlb[i].C, + m_utlb[i].PPR, + m_utlb[i].D, + m_utlb[i].WT, + m_utlb[i].SA, + m_utlb[i].TC); + } + } + } + + } else { @@ -1184,9 +1264,44 @@ void sh34_base_device::sh4_parse_configuration() } } +uint32_t sh34_base_device::get_remap(uint32_t address) +{ + return address; +} + +uint32_t sh4_base_device::get_remap(uint32_t address) +{ + if (m_mmuhack != 2) + return address; + + // is this the correct way around? + int i; + uint32_t topaddr = address&0xfff00000; + + for (i=0;i<64;i++) + { + if (m_utlb[i].V) + { + uint32_t topcmp = (m_utlb[i].PPN << 10) & 0xfff00000; + if (topcmp == topaddr) + return (address & 0x000fffff) | ((m_utlb[i].VPN << 10) & 0xfff00000); + } + } + + //printf("address not in UTLB? %08x\n", address); + + + return address; +} + uint32_t sh34_base_device::sh4_getsqremap(uint32_t address) { - if (!m_sh4_mmu_enabled) + return address; +} + +uint32_t sh4_base_device::sh4_getsqremap(uint32_t address) +{ + if (!m_sh4_mmu_enabled || (m_mmuhack != 1)) return address; else { @@ -1195,44 +1310,156 @@ uint32_t sh34_base_device::sh4_getsqremap(uint32_t address) for (i=0;i<64;i++) { - uint32_t topcmp = m_sh4_tlb_address[i]&0xfff00000; + uint32_t topcmp = (m_utlb[i].VPN<<10)&0xfff00000; if (topcmp==topaddr) - return (address&0x000fffff) | ((m_sh4_tlb_data[i])&0xfff00000); + return (address&0x000fffff) | ((m_utlb[i].PPN<<10)&0xfff00000); } - } return address; } -READ64_MEMBER( sh4_base_device::sh4_tlb_r ) -{ - int offs = offset*8; - if (offs >= 0x01000000) +WRITE64_MEMBER( sh4_base_device::sh4_utlb_address_array_w ) +{ +/* uses bits 13:8 of address to select which UTLB entry we're addressing + bit 7 of the address enables 'associative' mode, causing a search + operation rather than a direct write. + + NNNN NNNN NNNN NNNN NNNN NNDV AAAA AAAA + + N = VPN = Virtual Page Number + D = Dirty Bit + V = Validity Bit + A = ASID = Address Space Identifier +*/ + + logerror("sh4_utlb_address_array_w %08x %08x\n", offset, data); + int offs = offset << 3; + + uint8_t associative = (offs >> 7) & 1; + + if (!associative) { - uint8_t i = (offs>>8)&63; - return m_sh4_tlb_data[i]; + // non-associative mode + uint8_t i = (offs >> 8) & 63; + + m_utlb[i].VPN = (data & 0xfffffc00) >> 10; + m_utlb[i].D = (data & 0x00000200) >> 9; + m_utlb[i].V = (data & 0x00000100) >> 8; + m_utlb[i].ASID = (data & 0x000000ff) >> 0; } else { - uint8_t i = (offs>>8)&63; - return m_sh4_tlb_address[i]; + // associative mode + fatalerror("SH4MMU: associative mode writes unsupported\n"); } } -WRITE64_MEMBER( sh4_base_device::sh4_tlb_w ) +READ64_MEMBER( sh4_base_device::sh4_utlb_address_array_r ) { + // associative bit is ignored for reads int offs = offset*8; - if (offs >= 0x01000000) - { - uint8_t i = (offs>>8)&63; - m_sh4_tlb_data[i] = data&0xffffffff; - } - else - { - uint8_t i = (offs>>8)&63; - m_sh4_tlb_address[i] = data&0xffffffff; - } + uint32_t ret = 0; + + uint8_t i = (offs >> 8) & 63; + + ret |= m_utlb[i].VPN << 10; + ret |= m_utlb[i].D << 9; + ret |= m_utlb[i].V << 8; + ret |= m_utlb[i].ASID << 0; + + return ret; } + + +WRITE64_MEMBER( sh4_base_device::sh4_utlb_data_array1_w ) +{ +/* uses bits 13:8 of address to select which UTLB entry we're addressing + + ---P PPPP PPPP PPPP PPPP PP-V zRRz CDHW + + P = PPN = Physical page number + V = Validity bit + z = SZ = Page Size (2 bits, split) + D = Dirty Bit + R = PR = Protection Key Data + C = Cacheable bit + H = Share status + W = Write through + - = unused (should be 0) +*/ + logerror("sh4_utlb_data_array1_w %08x %08x\n", offset, data); + int offs = offset*8; + + uint8_t i = (offs>>8)&63; + + m_utlb[i].PPN = (data & 0x1ffffc00) >> 10; + m_utlb[i].V = (data & 0x00000100) >> 8; + m_utlb[i].PSZ = (data & 0x00000080) >> 6; + m_utlb[i].PSZ |=(data & 0x00000010) >> 4; + m_utlb[i].PPR= (data & 0x00000060) >> 5; + m_utlb[i].C = (data & 0x00000008) >> 3; + m_utlb[i].D = (data & 0x00000004) >> 2; + m_utlb[i].SH = (data & 0x00000002) >> 1; + m_utlb[i].WT = (data & 0x00000001) >> 0; +} + + +READ64_MEMBER(sh4_base_device::sh4_utlb_data_array1_r) +{ + uint32_t ret = 0; + int offs = offset*8; + + uint8_t i = (offs>>8)&63; + + ret |= m_utlb[i].PPN << 10; + ret |= m_utlb[i].V << 8; + ret |= (m_utlb[i].PSZ & 2) << 6; + ret |= (m_utlb[i].PSZ & 1) << 4; + ret |= m_utlb[i].PPR << 5; + ret |= m_utlb[i].C << 3; + ret |= m_utlb[i].D << 2; + ret |= m_utlb[i].SH << 1; + ret |= m_utlb[i].WT << 0; + + return ret; +} + + + +WRITE64_MEMBER( sh4_base_device::sh4_utlb_data_array2_w ) +{ +/* uses bits 13:8 of address to select which UTLB entry we're addressing + + ---- ---- ---- ---- ---- ---- ---- TSSS + + T = TC = Timing Control + S = SA = Space attributes + - = unused (should be 0) + +*/ + + logerror("sh4_utlb_data_array2_w %08x %08x\n", offset, data); + int offs = offset*8; + + uint8_t i = (offs>>8)&63; + + m_utlb[i].TC = (data & 0x00000008) >> 3; + m_utlb[i].SA = (data & 0x00000007) >> 0; +} + + +READ64_MEMBER(sh4_base_device::sh4_utlb_data_array2_r) +{ + uint32_t ret = 0; + int offs = offset*8; + + uint8_t i = (offs>>8)&63; + + ret |= m_utlb[i].TC << 3; + ret |= m_utlb[i].SA << 0; + + return ret; +} \ No newline at end of file diff --git a/src/devices/cpu/sh4/sh4dasm.cpp b/src/devices/cpu/sh4/sh4dasm.cpp index 2815dc720be..faff895f3a5 100644 --- a/src/devices/cpu/sh4/sh4dasm.cpp +++ b/src/devices/cpu/sh4/sh4dasm.cpp @@ -896,18 +896,10 @@ unsigned DasmSH4(std::ostream &stream, unsigned pc, uint16_t opcode) CPU_DISASSEMBLE(sh4) { - std::ostringstream stream; - offs_t result = DasmSH4(stream, pc, (oprom[1] << 8) | oprom[0]); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; + return DasmSH4(stream, pc, (oprom[1] << 8) | oprom[0]); } CPU_DISASSEMBLE(sh4be) { - std::ostringstream stream; - offs_t result = DasmSH4(stream, pc, (oprom[0] << 8) | oprom[1]); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; + return DasmSH4(stream, pc, (oprom[0] << 8) | oprom[1]); } diff --git a/src/devices/cpu/sharc/sharc.cpp b/src/devices/cpu/sharc/sharc.cpp index 228acd8c61a..2555d25d7ee 100644 --- a/src/devices/cpu/sharc/sharc.cpp +++ b/src/devices/cpu/sharc/sharc.cpp @@ -80,10 +80,10 @@ adsp21062_device::adsp21062_device(const machine_config &mconfig, const char *ta } -offs_t adsp21062_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t adsp21062_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( sharc ); - return CPU_DISASSEMBLE_NAME(sharc)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(sharc)(this, stream, pc, oprom, opram, options); } void adsp21062_device::enable_recompiler() diff --git a/src/devices/cpu/sharc/sharc.h b/src/devices/cpu/sharc/sharc.h index bf3ae7edaa5..7d36321364b 100644 --- a/src/devices/cpu/sharc/sharc.h +++ b/src/devices/cpu/sharc/sharc.h @@ -263,7 +263,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 6; } virtual uint32_t disasm_max_opcode_bytes() const override { return 6; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; direct_read_data *m_direct; diff --git a/src/devices/cpu/sharc/sharcdrc.cpp b/src/devices/cpu/sharc/sharcdrc.cpp index 75c0647da9f..5eaacd58b54 100644 --- a/src/devices/cpu/sharc/sharcdrc.cpp +++ b/src/devices/cpu/sharc/sharcdrc.cpp @@ -2292,7 +2292,7 @@ bool adsp21062_device::generate_opcode(drcuml_block *block, compiler_state *comp switch (subop) { case 0x00: // NOP / idle |000|00000| - if (opcode & U64(0x008000000000)) + if (opcode & 0x008000000000U) { // IDLE UML_MOV(block, mem(&m_core->idle), 1); @@ -3060,7 +3060,7 @@ bool adsp21062_device::generate_opcode(drcuml_block *block, compiler_state *comp case 0x16: // I register modify / bit-reverse |000|10110| { - if (opcode & U64(0x008000000000)) // bit reverse + if (opcode & 0x008000000000U) // bit reverse { return false; } @@ -3087,28 +3087,28 @@ bool adsp21062_device::generate_opcode(drcuml_block *block, compiler_state *comp case 0x17: // push|pop stacks / flush cache |000|10111| { - if (opcode & U64(0x008000000000)) + if (opcode & 0x008000000000U) { fatalerror("sharcdrc: push/pop stacks: push loop not implemented\n"); } - if (opcode & U64(0x004000000000)) + if (opcode & 0x004000000000U) { fatalerror("sharcdrc: push/pop stacks: pop loop not implemented\n"); } - if (opcode & U64(0x002000000000)) + if (opcode & 0x002000000000U) { UML_CALLH(block, *m_push_status); } - if (opcode & U64(0x001000000000)) + if (opcode & 0x001000000000U) { UML_CALLH(block, *m_pop_status); } - if (opcode & U64(0x000800000000)) + if (opcode & 0x000800000000U) { UML_MOV(block, I0, PCSTK); UML_CALLH(block, *m_push_pc); } - if (opcode & U64(0x000400000000)) + if (opcode & 0x000400000000U) { UML_CALLH(block, *m_pop_pc); } @@ -3295,7 +3295,7 @@ bool adsp21062_device::generate_opcode(drcuml_block *block, compiler_state *comp case 3: { - if (opcode & U64(0x100000000000)) // compute / ureg <-> ureg |011|1| + if (opcode & 0x100000000000U) // compute / ureg <-> ureg |011|1| { int src_ureg = (opcode >> 36) & 0xff; int dst_ureg = (opcode >> 23) & 0xff; @@ -3420,7 +3420,7 @@ bool adsp21062_device::generate_opcode(drcuml_block *block, compiler_state *comp case 4: { - if (opcode & U64(0x100000000000)) // immediate data -> DM|PM |100|1| + if (opcode & 0x100000000000U) // immediate data -> DM|PM |100|1| { int i = (opcode >> 41) & 0x7; int m = (opcode >> 38) & 0x7; @@ -3722,22 +3722,22 @@ void adsp21062_device::generate_compute(drcuml_block *block, compiler_state *com switch (ai) { case 0x00: // MR0F - UML_DAND(block, MRF, MRF, U64(0xffffffff00000000)); + UML_DAND(block, MRF, MRF, 0xffffffff00000000U); UML_AND(block, I0, REG(rn), 0xffffffff); UML_DOR(block, MRF, MRF, I0); break; case 0x01: // MR1F - UML_DAND(block, MRF, MRF, U64(0x00000000ffffffff)); + UML_DAND(block, MRF, MRF, 0x00000000ffffffffU); UML_DSHL(block, I0, REG(rn), 32); UML_DOR(block, MRF, MRF, I0); break; case 0x04: // MR0B - UML_DAND(block, MRB, MRB, U64(0xffffffff00000000)); + UML_DAND(block, MRB, MRB, 0xffffffff00000000U); UML_AND(block, I0, REG(rn), 0xffffffff); UML_DOR(block, MRB, MRB, I0); break; case 0x05: // MR1B - UML_DAND(block, MRB, MRB, U64(0x00000000ffffffff)); + UML_DAND(block, MRB, MRB, 0x00000000ffffffffU); UML_DSHL(block, I0, REG(rn), 32); UML_DOR(block, MRB, MRB, I0); break; diff --git a/src/devices/cpu/sharc/sharcdsm.cpp b/src/devices/cpu/sharc/sharcdsm.cpp index 1d99ab16f31..7d570c13e87 100644 --- a/src/devices/cpu/sharc/sharcdsm.cpp +++ b/src/devices/cpu/sharc/sharcdsm.cpp @@ -646,7 +646,7 @@ static uint32_t dasm_direct_jump(uint32_t pc, uint64_t opcode) uint32_t flags = 0; get_if_condition(cond); - if (opcode & U64(0x8000000000)) + if (opcode & 0x8000000000U) { print("CALL"); flags = DASMFLAG_STEP_OVER; @@ -656,7 +656,7 @@ static uint32_t dasm_direct_jump(uint32_t pc, uint64_t opcode) print("JUMP"); } - if (opcode & U64(0x10000000000)) /* PC-relative branch */ + if (opcode & 0x10000000000U) /* PC-relative branch */ { print(" (0x%08X)", pc + SIGN_EXTEND24(addr)); } @@ -699,7 +699,7 @@ static uint32_t dasm_indirect_jump_compute(uint32_t pc, uint64_t opcode) print("JUMP"); } - if (opcode & U64(0x10000000000)) /* PC-relative branch */ + if (opcode & 0x10000000000U) /* PC-relative branch */ { print(" (0x%08X)", pc + SIGN_EXTEND6(reladdr)); } @@ -744,7 +744,7 @@ static uint32_t dasm_indirect_jump_compute_dregdm(uint32_t pc, uint64_t opcode) get_if_condition(cond); print("JUMP"); - if (opcode & U64(0x200000000000)) /* PC-relative branch */ + if (opcode & 0x200000000000U) /* PC-relative branch */ { print(" (0x%08X)", pc + SIGN_EXTEND6(reladdr)); } @@ -780,7 +780,7 @@ static uint32_t dasm_rts_compute(uint32_t pc, uint64_t opcode) get_if_condition(cond); - if (opcode & U64(0x10000000000)) + if (opcode & 0x10000000000U) { print("RTI"); } @@ -817,7 +817,7 @@ static uint32_t dasm_do_until_counter(uint32_t pc, uint64_t opcode) int ureg = (opcode >> 32) & 0xff; uint32_t addr = opcode & 0xffffff; - if (opcode & U64(0x10000000000)) /* Loop counter from universal register */ + if (opcode & 0x10000000000U) /* Loop counter from universal register */ { print("LCNTR = %s, ", GET_UREG(ureg)); print("DO (0x%08X)", pc + SIGN_EXTEND24(addr)); @@ -950,7 +950,7 @@ static uint32_t dasm_ireg_modify(uint32_t pc, uint64_t opcode) int i = (opcode >> 32) & 0x7; uint32_t data = opcode & 0xffffffff; - if (opcode & U64(0x8000000000)) /* with bit-reverse */ + if (opcode & 0x8000000000U) /* with bit-reverse */ { if (g) { @@ -1043,7 +1043,7 @@ static uint32_t dasm_misc(uint32_t pc, uint64_t opcode) static uint32_t dasm_idlenop(uint32_t pc, uint64_t opcode) { - if (opcode & U64(0x8000000000)) + if (opcode & 0x8000000000U) { print("IDLE"); } @@ -1058,7 +1058,7 @@ static uint32_t dasm_idlenop(uint32_t pc, uint64_t opcode) static uint32_t dasm_cjump_rframe(uint32_t pc, uint64_t opcode) { /* TODO */ - if (opcode & U64(0x10000000000)) /* RFRAME */ + if (opcode & 0x10000000000U) /* RFRAME */ { print("TODO: RFRAME"); } @@ -1206,16 +1206,6 @@ static uint32_t sharc_dasm_one(std::ostream &stream, offs_t pc, uint64_t opcode) } -static uint32_t sharc_dasm_one(char *buffer, offs_t pc, uint64_t opcode) -{ - std::ostringstream stream; - uint32_t result = sharc_dasm_one(stream, pc, opcode); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - - CPU_DISASSEMBLE( sharc ) { uint64_t op; @@ -1225,6 +1215,6 @@ CPU_DISASSEMBLE( sharc ) ((uint64_t)oprom[2] << 16) | ((uint64_t)oprom[3] << 24) | ((uint64_t)oprom[4] << 32) | ((uint64_t)oprom[5] << 40); - flags = sharc_dasm_one(buffer, pc, op); + flags = sharc_dasm_one(stream, pc, op); return 1 | flags | DASMFLAG_SUPPORTED; } diff --git a/src/devices/cpu/sharc/sharcfe.cpp b/src/devices/cpu/sharc/sharcfe.cpp index 194dabcea8c..dc060ac733d 100644 --- a/src/devices/cpu/sharc/sharcfe.cpp +++ b/src/devices/cpu/sharc/sharcfe.cpp @@ -227,7 +227,7 @@ bool sharc_frontend::describe(opcode_desc &desc, const opcode_desc *prev) switch (subop) { case 0x00: // NOP / idle |000|00000| - if (opcode & U64(0x008000000000)) + if (opcode & 0x008000000000U) { // IDLE desc.flags |= OPFLAG_END_SEQUENCE; @@ -608,7 +608,7 @@ bool sharc_frontend::describe(opcode_desc &desc, const opcode_desc *prev) case 0x16: // I register modify / bit-reverse |000|10110| { - if (opcode & U64(0x008000000000)) // bit reverse + if (opcode & 0x008000000000U) // bit reverse { fatalerror("sharc_frontend::describe: bit reverse unimplemented"); } @@ -737,7 +737,7 @@ bool sharc_frontend::describe(opcode_desc &desc, const opcode_desc *prev) if (!describe_compute(desc, opcode)) return false; - if (opcode & U64(0x100000000000)) // compute / ureg <-> ureg |011|1| + if (opcode & 0x100000000000U) // compute / ureg <-> ureg |011|1| { int src_ureg = (opcode >> 36) & 0xff; int dst_ureg = (opcode >> 23) & 0xff; @@ -798,7 +798,7 @@ bool sharc_frontend::describe(opcode_desc &desc, const opcode_desc *prev) case 4: { - if (opcode & U64(0x100000000000)) // immediate data -> DM|PM |100|1| + if (opcode & 0x100000000000U) // immediate data -> DM|PM |100|1| { int i = (opcode >> 41) & 0x7; int m = (opcode >> 38) & 0x7; diff --git a/src/devices/cpu/sharc/sharcops.hxx b/src/devices/cpu/sharc/sharcops.hxx index e3140f00352..af1beed292b 100644 --- a/src/devices/cpu/sharc/sharcops.hxx +++ b/src/devices/cpu/sharc/sharcops.hxx @@ -440,8 +440,8 @@ void adsp21062_device::SET_UREG(int ureg, uint32_t data) case 0xd: switch(reg) { - case 0xc: m_core->px &= U64(0xffffffffffff0000); m_core->px |= (data & 0xffff); break; /* PX1 */ - case 0xd: m_core->px &= U64(0x000000000000ffff); m_core->px |= (uint64_t)data << 16; break; /* PX2 */ + case 0xc: m_core->px &= 0xffffffffffff0000U; m_core->px |= (data & 0xffff); break; /* PX1 */ + case 0xd: m_core->px &= 0x000000000000ffffU; m_core->px |= (uint64_t)data << 16; break; /* PX2 */ default: fatalerror("SHARC: SET_UREG: unknown register %08X at %08X\n", ureg, m_core->pc); } break; @@ -2668,29 +2668,29 @@ void adsp21062_device::sharcop_bit_reverse() /* push/pop stacks / flush cache */ void adsp21062_device::sharcop_push_pop_stacks() { - if (m_core->opcode & U64(0x008000000000)) + if (m_core->opcode & 0x008000000000U) { fatalerror("sharcop_push_pop_stacks: push loop not implemented\n"); } - if (m_core->opcode & U64(0x004000000000)) + if (m_core->opcode & 0x004000000000U) { fatalerror("sharcop_push_pop_stacks: pop loop not implemented\n"); } - if (m_core->opcode & U64(0x002000000000)) + if (m_core->opcode & 0x002000000000U) { //fatalerror("sharcop_push_pop_stacks: push sts not implemented\n"); PUSH_STATUS_STACK(); } - if (m_core->opcode & U64(0x001000000000)) + if (m_core->opcode & 0x001000000000U) { //fatalerror("sharcop_push_pop_stacks: pop sts not implemented\n"); POP_STATUS_STACK(); } - if (m_core->opcode & U64(0x000800000000)) + if (m_core->opcode & 0x000800000000U) { PUSH_PC(m_core->pcstk); } - if (m_core->opcode & U64(0x000400000000)) + if (m_core->opcode & 0x000400000000U) { POP_PC(); } @@ -2722,8 +2722,8 @@ void adsp21062_device::sharcop_idle() void adsp21062_device::sharcop_unimplemented() { extern CPU_DISASSEMBLE(sharc); - char dasm[1000]; + std::ostringstream dasm; CPU_DISASSEMBLE_NAME(sharc)(nullptr, dasm, m_core->pc, nullptr, nullptr, 0); - osd_printf_debug("SHARC: %08X: %s\n", m_core->pc, dasm); + osd_printf_debug("SHARC: %08X: %s\n", m_core->pc, dasm.str().c_str()); fatalerror("SHARC: Unimplemented opcode %04X%08X at %08X\n", (uint16_t)(m_core->opcode >> 32), (uint32_t)(m_core->opcode), m_core->pc); } diff --git a/src/devices/cpu/sm510/kb1013vk1-2.h b/src/devices/cpu/sm510/kb1013vk1-2.h index 825b41f8cc3..56896c940ac 100644 --- a/src/devices/cpu/sm510/kb1013vk1-2.h +++ b/src/devices/cpu/sm510/kb1013vk1-2.h @@ -26,7 +26,7 @@ public: kb1013vk12_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void execute_one() override; // opcode handlers diff --git a/src/devices/cpu/sm510/kb1013vk1-2core.cpp b/src/devices/cpu/sm510/kb1013vk1-2core.cpp index 25cb6a8288c..b7286e97401 100644 --- a/src/devices/cpu/sm510/kb1013vk1-2core.cpp +++ b/src/devices/cpu/sm510/kb1013vk1-2core.cpp @@ -34,10 +34,10 @@ kb1013vk12_device::kb1013vk12_device(const machine_config &mconfig, const char * // disasm -offs_t kb1013vk12_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t kb1013vk12_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(kb1013vk12); - return CPU_DISASSEMBLE_NAME(kb1013vk12)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(kb1013vk12)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/sm510/sm500.h b/src/devices/cpu/sm510/sm500.h index 57924114414..262c75fc29b 100644 --- a/src/devices/cpu/sm510/sm500.h +++ b/src/devices/cpu/sm510/sm500.h @@ -50,7 +50,7 @@ public: sm500_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, int stack_levels, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void execute_one() override; virtual void get_opcode_param() override; diff --git a/src/devices/cpu/sm510/sm500core.cpp b/src/devices/cpu/sm510/sm500core.cpp index deb32f652f7..84c1c557eb6 100644 --- a/src/devices/cpu/sm510/sm500core.cpp +++ b/src/devices/cpu/sm510/sm500core.cpp @@ -38,10 +38,10 @@ sm500_device::sm500_device(const machine_config &mconfig, device_type type, cons // disasm -offs_t sm500_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t sm500_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(sm500); - return CPU_DISASSEMBLE_NAME(sm500)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(sm500)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/sm510/sm510.h b/src/devices/cpu/sm510/sm510.h index 0421288f5cb..c60b0395af2 100644 --- a/src/devices/cpu/sm510/sm510.h +++ b/src/devices/cpu/sm510/sm510.h @@ -298,7 +298,7 @@ public: sm510_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void execute_one() override; virtual void get_opcode_param() override; @@ -313,7 +313,7 @@ public: sm511_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, int stack_levels, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void execute_one() override; virtual void get_opcode_param() override; }; diff --git a/src/devices/cpu/sm510/sm510core.cpp b/src/devices/cpu/sm510/sm510core.cpp index e2fdb158544..de503fcbc54 100644 --- a/src/devices/cpu/sm510/sm510core.cpp +++ b/src/devices/cpu/sm510/sm510core.cpp @@ -36,10 +36,10 @@ sm510_device::sm510_device(const machine_config &mconfig, const char *tag, devic // disasm -offs_t sm510_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t sm510_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(sm510); - return CPU_DISASSEMBLE_NAME(sm510)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(sm510)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/sm510/sm510d.cpp b/src/devices/cpu/sm510/sm510d.cpp index 6a5d97f50de..3929c52a82f 100644 --- a/src/devices/cpu/sm510/sm510d.cpp +++ b/src/devices/cpu/sm510/sm510d.cpp @@ -192,15 +192,6 @@ static offs_t sm510_common_disasm(const uint8_t *lut_mnemonic, const uint8_t *lu return len | s_flags[instr] | DASMFLAG_SUPPORTED; } -static offs_t sm510_common_disasm(const uint8_t *lut_mnemonic, const uint8_t *lut_extended, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram) -{ - std::ostringstream stream; - offs_t result = sm510_common_disasm(lut_mnemonic, lut_extended, stream, pc, oprom, opram); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - // SM510 disasm @@ -230,7 +221,7 @@ static const uint8_t sm510_mnemonic[0x100] = CPU_DISASSEMBLE(sm510) { - return sm510_common_disasm(sm510_mnemonic, nullptr, buffer, pc, oprom, opram); + return sm510_common_disasm(sm510_mnemonic, nullptr, stream, pc, oprom, opram); } @@ -272,7 +263,7 @@ CPU_DISASSEMBLE(sm511) memset(ext, 0, 0x100); memcpy(ext + 0x30, sm511_extended, 0x10); - return sm510_common_disasm(sm511_mnemonic, ext, buffer, pc, oprom, opram); + return sm510_common_disasm(sm511_mnemonic, ext, stream, pc, oprom, opram); } @@ -314,7 +305,7 @@ CPU_DISASSEMBLE(sm500) memset(ext, 0, 0x100); memcpy(ext + 0x00, sm500_extended, 0x10); - return sm510_common_disasm(sm500_mnemonic, ext, buffer, pc, oprom, opram); + return sm510_common_disasm(sm500_mnemonic, ext, stream, pc, oprom, opram); } @@ -356,5 +347,5 @@ CPU_DISASSEMBLE(kb1013vk12) memset(ext, 0, 0x100); memcpy(ext + 0x00, kb1013vk12_extended, 0x10); - return sm510_common_disasm(kb1013vk12_mnemonic, ext, buffer, pc, oprom, opram); + return sm510_common_disasm(kb1013vk12_mnemonic, ext, stream, pc, oprom, opram); } diff --git a/src/devices/cpu/sm510/sm511core.cpp b/src/devices/cpu/sm510/sm511core.cpp index b43cacf9dca..ce134b24588 100644 --- a/src/devices/cpu/sm510/sm511core.cpp +++ b/src/devices/cpu/sm510/sm511core.cpp @@ -35,10 +35,10 @@ ADDRESS_MAP_END // disasm -offs_t sm511_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t sm511_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(sm511); - return CPU_DISASSEMBLE_NAME(sm511)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(sm511)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/sm8500/sm8500.cpp b/src/devices/cpu/sm8500/sm8500.cpp index c03ed425dbe..90aaaaf6ed6 100644 --- a/src/devices/cpu/sm8500/sm8500.cpp +++ b/src/devices/cpu/sm8500/sm8500.cpp @@ -341,10 +341,10 @@ void sm8500_cpu_device::process_interrupts() } -offs_t sm8500_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t sm8500_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( sm8500 ); - return CPU_DISASSEMBLE_NAME(sm8500)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(sm8500)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/sm8500/sm8500.h b/src/devices/cpu/sm8500/sm8500.h index 5356b776c8c..eb0c1f9f703 100644 --- a/src/devices/cpu/sm8500/sm8500.h +++ b/src/devices/cpu/sm8500/sm8500.h @@ -76,7 +76,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 5; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; inline void get_sp(); uint8_t mem_readbyte(uint32_t offset) const; diff --git a/src/devices/cpu/sm8500/sm8500d.cpp b/src/devices/cpu/sm8500/sm8500d.cpp index 4e63baf36e3..1b8b7dd2392 100644 --- a/src/devices/cpu/sm8500/sm8500d.cpp +++ b/src/devices/cpu/sm8500/sm8500d.cpp @@ -173,7 +173,7 @@ static const sm8500dasm mnemonic[256] = { }; -static offs_t internal_disasm_sm8500(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(sm8500) { const sm8500dasm *instr; uint8_t op; @@ -579,13 +579,3 @@ static offs_t internal_disasm_sm8500(cpu_device *device, std::ostream &stream, o return pos | s_flags[instr->mnemonic] | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(sm8500) -{ - std::ostringstream stream; - offs_t result = internal_disasm_sm8500(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/sparc/mb86901.cpp b/src/devices/cpu/sparc/mb86901.cpp index e14921dfbe2..3fc1eca330d 100644 --- a/src/devices/cpu/sparc/mb86901.cpp +++ b/src/devices/cpu/sparc/mb86901.cpp @@ -548,10 +548,10 @@ uint32_t mb86901_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t mb86901_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t mb86901_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { uint32_t op = *reinterpret_cast(oprom); - return m_dasm.dasm(buffer, pc, big_endianize_int32(op)); + return m_dasm.dasm(stream, pc, big_endianize_int32(op)); } diff --git a/src/devices/cpu/sparc/sparc.h b/src/devices/cpu/sparc/sparc.h index 07fa4cd10a4..dbd7113f2e5 100644 --- a/src/devices/cpu/sparc/sparc.h +++ b/src/devices/cpu/sparc/sparc.h @@ -45,7 +45,7 @@ public: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/sparc/sparcdasm.cpp b/src/devices/cpu/sparc/sparcdasm.cpp index 38d139249be..296c987a467 100644 --- a/src/devices/cpu/sparc/sparcdasm.cpp +++ b/src/devices/cpu/sparc/sparcdasm.cpp @@ -603,20 +603,13 @@ template inline void sparc_disassembler::add_vis_op_desc(const T &d m_vis_op_desc.insert(it); } -inline void sparc_disassembler::pad_op_field(char *buf, char *&output) const +inline void sparc_disassembler::pad_op_field(std::ostream &stream, std::streampos start_position) const { - while ((output - buf) < m_op_field_width) *output++ = ' '; + const std::streamoff difference(stream.tellp() - start_position); + for (std::streamoff i = difference; i < m_op_field_width; i++) + stream << ' '; } -inline void sparc_disassembler::print(char *&output, const char *fmt, ...) -{ - va_list vl; - va_start(vl, fmt); - output += std::vsprintf(output, fmt, vl); - va_end(vl); -} - - sparc_disassembler::sparc_disassembler(const sparc_debug_state *state, unsigned version) : sparc_disassembler(state, version, vis_none) { @@ -730,7 +723,7 @@ sparc_disassembler::sparc_disassembler(const sparc_debug_state *state, unsigned } -offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm(std::ostream &stream, offs_t pc, uint32_t op) const { switch (OP) { @@ -738,20 +731,20 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const switch (OP2) { case 0: - print(buf, "%-*s0x%06x", m_op_field_width, (m_version >= 9) ? "illtrap" : "unimp", CONST22); + util::stream_format(stream, "%-*s0x%06x", m_op_field_width, (m_version >= 9) ? "illtrap" : "unimp", CONST22); break; case 4: if (IMM22 == 0 && RD == 0) - print(buf, "nop"); + util::stream_format(stream, "nop"); else - print(buf, "%-*s%%hi(0x%08x),%s", m_op_field_width, "sethi", IMM22, REG_NAMES[RD]); + util::stream_format(stream, "%-*s%%hi(0x%08x),%s", m_op_field_width, "sethi", IMM22, REG_NAMES[RD]); break; default: - return dasm_branch(buf, pc, op); + return dasm_branch(stream, pc, op); } return 4 | DASMFLAG_SUPPORTED; case 1: - print(buf, "%-*s%%pc%c0x%08x ! 0x%08x", m_op_field_width, "call", (DISP30 < 0) ? '-' : '+', std::abs(DISP30), pc + DISP30); + util::stream_format(stream, "%-*s%%pc%c0x%08x ! 0x%08x", m_op_field_width, "call", (DISP30 < 0) ? '-' : '+', std::abs(DISP30), pc + DISP30); return 4 | DASMFLAG_SUPPORTED; case 2: switch (OP3) @@ -759,31 +752,31 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const case 0x00: if (USEIMM && (RS1 == RD)) { - if (SIMM13 == 1) print(buf, "%-*s%s", m_op_field_width, "inc", REG_NAMES[RD]); - else print(buf, "%-*s%d,%s", m_op_field_width, "inc", SIMM13, REG_NAMES[RD]); + if (SIMM13 == 1) util::stream_format(stream, "%-*s%s", m_op_field_width, "inc", REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%d,%s", m_op_field_width, "inc", SIMM13, REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; case 0x02: if (RS1 == 0) { - if (USEIMM) print(buf, "%-*s%d,%s", m_op_field_width, "mov", SIMM13, REG_NAMES[RD]); - else if (RS2 == 0) print(buf, "%-*s%s", m_op_field_width, "clr", REG_NAMES[RD]); - else print(buf, "%-*s%s,%s", m_op_field_width, "mov", REG_NAMES[RS2], REG_NAMES[RD]); + if (USEIMM) util::stream_format(stream, "%-*s%d,%s", m_op_field_width, "mov", SIMM13, REG_NAMES[RD]); + else if (RS2 == 0) util::stream_format(stream, "%-*s%s", m_op_field_width, "clr", REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%s,%s", m_op_field_width, "mov", REG_NAMES[RS2], REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } else if (RS1 == RD) { - if (USEIMM) print(buf, "%-*s0x%08x,%s", m_op_field_width, "bset", SIMM13, REG_NAMES[RD]); - else print(buf, "%-*s%s,%s", m_op_field_width, "bset", REG_NAMES[RS2], REG_NAMES[RD]); + if (USEIMM) util::stream_format(stream, "%-*s0x%08x,%s", m_op_field_width, "bset", SIMM13, REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%s,%s", m_op_field_width, "bset", REG_NAMES[RS2], REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; case 0x03: if (RS1 == RD) { - if (USEIMM) print(buf, "%-*s0x%08x,%s", m_op_field_width, "btog", SIMM13, REG_NAMES[RD]); - else print(buf, "%-*s%s,%s", m_op_field_width, "btog", REG_NAMES[RS2], REG_NAMES[RD]); + if (USEIMM) util::stream_format(stream, "%-*s0x%08x,%s", m_op_field_width, "btog", SIMM13, REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%s,%s", m_op_field_width, "btog", REG_NAMES[RS2], REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; @@ -792,8 +785,8 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const { if (RS1 == RD) { - if (SIMM13 == 1) print(buf, "%-*s%s", m_op_field_width, "dec", REG_NAMES[RD]); - else print(buf, "%-*s%d,%s", m_op_field_width, "dec", SIMM13, REG_NAMES[RD]); + if (SIMM13 == 1) util::stream_format(stream, "%-*s%s", m_op_field_width, "dec", REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%d,%s", m_op_field_width, "dec", SIMM13, REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } } @@ -801,8 +794,8 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const { if (RS1 == 0) { - if (RS2 == RD) print(buf, "%-*s%s", m_op_field_width, "neg", REG_NAMES[RD]); - else print(buf, "%-*s%s,%s", m_op_field_width, "neg", REG_NAMES[RS2], REG_NAMES[RD]); + if (RS2 == RD) util::stream_format(stream, "%-*s%s", m_op_field_width, "neg", REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%s,%s", m_op_field_width, "neg", REG_NAMES[RS2], REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } } @@ -810,54 +803,54 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const case 0x05: if (RS1 == RD) { - if (USEIMM) print(buf, "%-*s0x%08x,%s", m_op_field_width, "bclr", SIMM13, REG_NAMES[RD]); - else print(buf, "%-*s%s,%s", m_op_field_width, "bclr", REG_NAMES[RS2], REG_NAMES[RD]); + if (USEIMM) util::stream_format(stream, "%-*s0x%08x,%s", m_op_field_width, "bclr", SIMM13, REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%s,%s", m_op_field_width, "bclr", REG_NAMES[RS2], REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; case 0x07: if ((USEIMM && (SIMM13 == 0)) || (!USEIMM && (RS2 == 0))) { - if (RS1 == RD) print(buf, "%-*s%s", m_op_field_width, "not", REG_NAMES[RD]); - else print(buf, "%-*s%s,%s", m_op_field_width, "not", REG_NAMES[RS1], REG_NAMES[RD]); + if (RS1 == RD) util::stream_format(stream, "%-*s%s", m_op_field_width, "not", REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%s,%s", m_op_field_width, "not", REG_NAMES[RS1], REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; case 0x10: if (USEIMM && (RS1 == RD)) { - if (SIMM13 == 1) print(buf, "%-*s%s", m_op_field_width, "inccc", REG_NAMES[RD]); - else print(buf, "%-*s%d,%s", m_op_field_width, "inccc", SIMM13, REG_NAMES[RD]); + if (SIMM13 == 1) util::stream_format(stream, "%-*s%s", m_op_field_width, "inccc", REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%d,%s", m_op_field_width, "inccc", SIMM13, REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; case 0x12: if (!USEIMM && (RS1 == 0) && (RD == 0)) { - print(buf, "%-*s%s", m_op_field_width, "tst", REG_NAMES[RS2]); + util::stream_format(stream, "%-*s%s", m_op_field_width, "tst", REG_NAMES[RS2]); return 4 | DASMFLAG_SUPPORTED; } break; case 0x14: if (USEIMM && (RS1 == RD) && (RD != 0)) { - if (SIMM13 == 1) print(buf, "%-*s%s", m_op_field_width, "deccc", REG_NAMES[RD]); - else print(buf, "%-*s%d,%s", m_op_field_width, "deccc", SIMM13, REG_NAMES[RD]); + if (SIMM13 == 1) util::stream_format(stream, "%-*s%s", m_op_field_width, "deccc", REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%d,%s", m_op_field_width, "deccc", SIMM13, REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; case 0x25: - return dasm_shift(buf, pc, op, "sll", "sllx", nullptr); + return dasm_shift(stream, pc, op, "sll", "sllx", nullptr); case 0x26: - return dasm_shift(buf, pc, op, "srl", "srlx", "clruw"); + return dasm_shift(stream, pc, op, "srl", "srlx", "clruw"); case 0x27: - return dasm_shift(buf, pc, op, "sra", "srax", "signx"); + return dasm_shift(stream, pc, op, "sra", "srax", "signx"); case 0x28: - return dasm_read_state_reg(buf, pc, op); + return dasm_read_state_reg(stream, pc, op); case 0x29: if (m_version <= 8) { - print(buf, "%-*s%%psr,%s", m_op_field_width, "rd", REG_NAMES[RD]); + util::stream_format(stream, "%-*s%%psr,%s", m_op_field_width, "rd", REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; @@ -866,13 +859,13 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const { if (V9_PRIV_REG_NAMES[RS1]) { - print(buf, "%-*s%s,%s", m_op_field_width, "rdpr", V9_PRIV_REG_NAMES[RS1], REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%s", m_op_field_width, "rdpr", V9_PRIV_REG_NAMES[RS1], REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } } else { - print(buf, "%-*s%%wim,%s", m_op_field_width, "rd", REG_NAMES[RD]); + util::stream_format(stream, "%-*s%%wim,%s", m_op_field_width, "rd", REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; @@ -881,40 +874,40 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const { if (!USEIMM) { - print(buf, "flushw"); + util::stream_format(stream, "flushw"); return 4 | DASMFLAG_SUPPORTED; } } else { - print(buf, "%-*s%%tbr,%s", m_op_field_width, "rd", REG_NAMES[RD]); + util::stream_format(stream, "%-*s%%tbr,%s", m_op_field_width, "rd", REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; case 0x2c: - return dasm_move_cond(buf, pc, op); + return dasm_move_cond(stream, pc, op); case 0x2e: if ((m_version >= 9) && (RS1 == 0)) { - if (USEIMM) print(buf, "%-*s%d,%s", m_op_field_width, "popc", SIMM13, REG_NAMES[RD]); - else print(buf, "%-*s%s,%s", m_op_field_width, "popc", REG_NAMES[RS2], REG_NAMES[RD]); + if (USEIMM) util::stream_format(stream, "%-*s%d,%s", m_op_field_width, "popc", SIMM13, REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%s,%s", m_op_field_width, "popc", REG_NAMES[RS2], REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } break; case 0x2f: - return dasm_move_reg_cond(buf, pc, op); + return dasm_move_reg_cond(stream, pc, op); case 0x30: - return dasm_write_state_reg(buf, pc, op); + return dasm_write_state_reg(stream, pc, op); case 0x31: if (m_version >= 9) { switch (RD) { case 0: - print(buf, "saved"); + util::stream_format(stream, "saved"); return 4 | DASMFLAG_SUPPORTED; case 1: - print(buf, "restored"); + util::stream_format(stream, "restored"); return 4 | DASMFLAG_SUPPORTED; } } @@ -922,13 +915,13 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const { if (RS1 == 0) { - if (USEIMM) print(buf, "%-*s0x%08x,%%psr", m_op_field_width, "mov", SIMM13); - else print(buf, "%-*s%s,%%psr", m_op_field_width, "mov", REG_NAMES[RS2]); + if (USEIMM) util::stream_format(stream, "%-*s0x%08x,%%psr", m_op_field_width, "mov", SIMM13); + else util::stream_format(stream, "%-*s%s,%%psr", m_op_field_width, "mov", REG_NAMES[RS2]); } else { - if (USEIMM) print(buf, "%-*s%s,0x%08x,%%psr", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13); - else print(buf, "%-*s%s,%s,%%psr", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2]); + if (USEIMM) util::stream_format(stream, "%-*s%s,0x%08x,%%psr", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13); + else util::stream_format(stream, "%-*s%s,%s,%%psr", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2]); } return 4 | DASMFLAG_SUPPORTED; } @@ -939,9 +932,9 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const if (V9_PRIV_REG_NAMES[RD]) { // FIXME: this disassembles wrpr to %fq and %ver which are actually illegal - if (!USEIMM) print(buf, "%-*s%s,%s,%s", m_op_field_width, "wrpr", REG_NAMES[RS1], REG_NAMES[RS2], V9_PRIV_REG_NAMES[RD]); - else if (RS1 == 0) print(buf, "%-*s0x%08x,%s", m_op_field_width, "wrpr", SIMM13, V9_PRIV_REG_NAMES[RD]); - else print(buf, "%-*s%s,0x%08x,%s", m_op_field_width, "wrpr", REG_NAMES[RS1], SIMM13, V9_PRIV_REG_NAMES[RD]); + if (!USEIMM) util::stream_format(stream, "%-*s%s,%s,%s", m_op_field_width, "wrpr", REG_NAMES[RS1], REG_NAMES[RS2], V9_PRIV_REG_NAMES[RD]); + else if (RS1 == 0) util::stream_format(stream, "%-*s0x%08x,%s", m_op_field_width, "wrpr", SIMM13, V9_PRIV_REG_NAMES[RD]); + else util::stream_format(stream, "%-*s%s,0x%08x,%s", m_op_field_width, "wrpr", REG_NAMES[RS1], SIMM13, V9_PRIV_REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } } @@ -949,13 +942,13 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const { if (RS1 == 0) { - if (USEIMM) print(buf, "%-*s0x%08x,%%wim", m_op_field_width, "mov", SIMM13); - else print(buf, "%-*s%s,%%wim", m_op_field_width, "mov", REG_NAMES[RS2]); + if (USEIMM) util::stream_format(stream, "%-*s0x%08x,%%wim", m_op_field_width, "mov", SIMM13); + else util::stream_format(stream, "%-*s%s,%%wim", m_op_field_width, "mov", REG_NAMES[RS2]); } else { - if (USEIMM) print(buf, "%-*s%s,0x%08x,%%wim", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13); - else print(buf, "%-*s%s,%s,%%wim", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2]); + if (USEIMM) util::stream_format(stream, "%-*s%s,0x%08x,%%wim", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13); + else util::stream_format(stream, "%-*s%s,%s,%%wim", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2]); } return 4 | DASMFLAG_SUPPORTED; } @@ -965,51 +958,51 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const { if (RS1 == 0) { - if (USEIMM) print(buf, "%-*s0x%08x,%%tbr", m_op_field_width, "mov", SIMM13); - else print(buf, "%-*s%s,%%tbr", m_op_field_width, "mov", REG_NAMES[RS2]); + if (USEIMM) util::stream_format(stream, "%-*s0x%08x,%%tbr", m_op_field_width, "mov", SIMM13); + else util::stream_format(stream, "%-*s%s,%%tbr", m_op_field_width, "mov", REG_NAMES[RS2]); } else { - if (USEIMM) print(buf, "%-*s%s,0x%08x,%%tbr", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13); - else print(buf, "%-*s%s,%s,%%tbr", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2]); + if (USEIMM) util::stream_format(stream, "%-*s%s,0x%08x,%%tbr", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13); + else util::stream_format(stream, "%-*s%s,%s,%%tbr", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2]); } return 4 | DASMFLAG_SUPPORTED; } break; case 0x34: - return dasm_fpop1(buf, pc, op); + return dasm_fpop1(stream, pc, op); case 0x35: - return dasm_fpop2(buf, pc, op); + return dasm_fpop2(stream, pc, op); case 0x36: - return dasm_impdep1(buf, pc, op); + return dasm_impdep1(stream, pc, op); case 0x37: // TODO: hooks for IMPDEP2/CPop2 break; case 0x38: - return dasm_jmpl(buf, pc, op); + return dasm_jmpl(stream, pc, op); case 0x39: - return dasm_return(buf, pc, op); + return dasm_return(stream, pc, op); case 0x3a: - return dasm_tcc(buf, pc, op); + return dasm_tcc(stream, pc, op); case 0x3b: if (m_version >= 8) { - print(buf, "%-*s", m_op_field_width, "flush"); - dasm_address(buf, op); + util::stream_format(stream, "%-*s", m_op_field_width, "flush"); + dasm_address(stream, op); return 4 | DASMFLAG_SUPPORTED; } break; case 0x3c: if (!USEIMM && (RS1 == RS2) && (RS2 == RD) && (RD == 0)) { - print(buf, "save"); + util::stream_format(stream, "save"); return 4 | DASMFLAG_SUPPORTED; } break; case 0x3d: if (!USEIMM && (RS1 == RS2) && (RS2 == RD) && (RD == 0)) { - print(buf, "restore"); + util::stream_format(stream, "restore"); return 4 | DASMFLAG_SUPPORTED; } break; @@ -1018,8 +1011,8 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const { switch (RD) { - case 0: print(buf, "done"); return 4 | DASMFLAG_SUPPORTED; - case 1: print(buf, "retry"); return 4 | DASMFLAG_SUPPORTED; + case 0: util::stream_format(stream, "done"); return 4 | DASMFLAG_SUPPORTED; + case 1: util::stream_format(stream, "retry"); return 4 | DASMFLAG_SUPPORTED; } } break; @@ -1031,115 +1024,115 @@ offs_t sparc_disassembler::dasm(char *buf, offs_t pc, uint32_t op) const if (it->second.g0_synth && (RD == 0)) { if (!USEIMM) - print(buf, "%-*s%s,%s", m_op_field_width, it->second.g0_synth, REG_NAMES[RS1], REG_NAMES[RS2]); + util::stream_format(stream, "%-*s%s,%s", m_op_field_width, it->second.g0_synth, REG_NAMES[RS1], REG_NAMES[RS2]); else if (it->second.hex_imm) - print(buf, "%-*s%s,0x%08x", m_op_field_width, it->second.g0_synth, REG_NAMES[RS1], SIMM13); + util::stream_format(stream, "%-*s%s,0x%08x", m_op_field_width, it->second.g0_synth, REG_NAMES[RS1], SIMM13); else - print(buf, "%-*s%s,%d", m_op_field_width, it->second.g0_synth, REG_NAMES[RS1], SIMM13); + util::stream_format(stream, "%-*s%s,%d", m_op_field_width, it->second.g0_synth, REG_NAMES[RS1], SIMM13); } else { if (!USEIMM) - print(buf, "%-*s%s,%s,%s", m_op_field_width, it->second.mnemonic, REG_NAMES[RS1], REG_NAMES[RS2], REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%s,%s", m_op_field_width, it->second.mnemonic, REG_NAMES[RS1], REG_NAMES[RS2], REG_NAMES[RD]); else if (it->second.hex_imm) - print(buf, "%-*s%s,0x%08x,%s", m_op_field_width, it->second.mnemonic, REG_NAMES[RS1], SIMM13, REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,0x%08x,%s", m_op_field_width, it->second.mnemonic, REG_NAMES[RS1], SIMM13, REG_NAMES[RD]); else - print(buf, "%-*s%s,%d,%s", m_op_field_width, it->second.mnemonic, REG_NAMES[RS1], SIMM13, REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%d,%s", m_op_field_width, it->second.mnemonic, REG_NAMES[RS1], SIMM13, REG_NAMES[RD]); } return 4 | DASMFLAG_SUPPORTED; } } break; case 3: - return dasm_ldst(buf, pc, op); + return dasm_ldst(stream, pc, op); } - return dasm_invalid(buf, pc, op); + return dasm_invalid(stream, pc, op); } -offs_t sparc_disassembler::dasm_invalid(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_invalid(std::ostream &stream, offs_t pc, uint32_t op) const { - print(buf, "%-*s0x%08x ! ", m_op_field_width, ".word", op); + util::stream_format(stream, "%-*s0x%08x ! ", m_op_field_width, ".word", op); if (OP == 0) { - print(buf, "op=%x op2=%01x a=%01x cond=%01x", OP, OP2, ANNUL, COND); + util::stream_format(stream, "op=%x op2=%01x a=%01x cond=%01x", OP, OP2, ANNUL, COND); } else if ((OP == 2) && ((OP3 == 0x34) || (OP3 == 0x35))) { - print(buf, "FPop%d opf=%03x rd=%d rs1=%d rs2=%d", 1 + (OP3 & 1), OPF, RD, RS1, RS2); + util::stream_format(stream, "FPop%d opf=%03x rd=%d rs1=%d rs2=%d", 1 + (OP3 & 1), OPF, RD, RS1, RS2); } else if ((OP == 2) && ((OP3 == 0x36) || (OP3 == 0x37))) { if (m_version >= 9) - print(buf, "IMPDEP%d impl-dep=%02x impl-dep=%05x", 1 + (OP3 & 1), RD, op & 0x7ffff); + util::stream_format(stream, "IMPDEP%d impl-dep=%02x impl-dep=%05x", 1 + (OP3 & 1), RD, op & 0x7ffff); else - print(buf, "CPop%d opf=%03x rd=%d rs1=%d rs2=%d", 1 + (OP3 & 1), OPC, RD, RS1, RS2); + util::stream_format(stream, "CPop%d opf=%03x rd=%d rs1=%d rs2=%d", 1 + (OP3 & 1), OPC, RD, RS1, RS2); } else { - print(buf, "op=%x op3=%02x i=%01x rd=%d", OP, OP3, USEIMM, RD); + util::stream_format(stream, "op=%x op3=%02x i=%01x rd=%d", OP, OP3, USEIMM, RD); } return 4 | DASMFLAG_SUPPORTED; } -offs_t sparc_disassembler::dasm_branch(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_branch(std::ostream &stream, offs_t pc, uint32_t op) const { - char *ptr(buf); + const std::streampos start_position(stream.tellp()); const branch_desc &desc(m_branch_desc[OP2]); const char * const mnemonic(desc.mnemonic[COND]); - if (!mnemonic || (desc.use_cc && !desc.reg_cc[BRCC])) return dasm_invalid(buf, pc, op); + if (!mnemonic || (desc.use_cc && !desc.reg_cc[BRCC])) return dasm_invalid(stream, pc, op); - print(ptr, "%s%s%s", mnemonic, ANNUL ? ",a" : "", (desc.use_pred && !PRED) ? ",pn" : ""); - pad_op_field(buf, ptr); - if (desc.use_cc) print(ptr, "%s,", desc.reg_cc[BRCC]); - if (OP2 == 3) print(ptr, "%s,", REG_NAMES[RS1]); + util::stream_format(stream, "%s%s%s", mnemonic, ANNUL ? ",a" : "", (desc.use_pred && !PRED) ? ",pn" : ""); + pad_op_field(stream, start_position); + if (desc.use_cc) util::stream_format(stream, "%s,", desc.reg_cc[BRCC]); + if (OP2 == 3) util::stream_format(stream, "%s,", REG_NAMES[RS1]); const int32_t disp(desc.get_disp(op)); - print(ptr, "%%pc%c0x%0*x ! 0x%08x", (disp < 0) ? '-' : '+', desc.disp_width, std::abs(disp), pc + disp); + util::stream_format(stream, "%%pc%c0x%0*x ! 0x%08x", (disp < 0) ? '-' : '+', desc.disp_width, std::abs(disp), pc + disp); //const char * const comment(desc.get_comment ? desc.get_comment(m_state, desc.use_cc, pc, op) : nullptr); - //if (comment) print(ptr, " - %s", comment); + //if (comment) util::stream_format(stream, " - %s", comment); return 4 | DASMFLAG_SUPPORTED; } -offs_t sparc_disassembler::dasm_shift(char *buf, offs_t pc, uint32_t op, const char *mnemonic, const char *mnemonicx, const char *mnemonicx0) const +offs_t sparc_disassembler::dasm_shift(std::ostream &stream, offs_t pc, uint32_t op, const char *mnemonic, const char *mnemonicx, const char *mnemonicx0) const { if ((m_version >= 9) && USEEXT) { if (USEIMM) - print(buf, "%-*s%s,%d,%s", m_op_field_width, mnemonicx, REG_NAMES[RS1], SHCNT64, REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%d,%s", m_op_field_width, mnemonicx, REG_NAMES[RS1], SHCNT64, REG_NAMES[RD]); else if (!mnemonicx0 || (RS2 != 0)) - print(buf, "%-*s%s,%s,%s", m_op_field_width, mnemonicx, REG_NAMES[RS1], REG_NAMES[RS2], REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%s,%s", m_op_field_width, mnemonicx, REG_NAMES[RS1], REG_NAMES[RS2], REG_NAMES[RD]); else if (RS1 == RD) - print(buf, "%-*s%s", m_op_field_width, mnemonicx0, REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s", m_op_field_width, mnemonicx0, REG_NAMES[RD]); else - print(buf, "%-*s%s,%s", m_op_field_width, mnemonicx0, REG_NAMES[RS1], REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%s", m_op_field_width, mnemonicx0, REG_NAMES[RS1], REG_NAMES[RD]); } else if (USEIMM) { - print(buf, "%-*s%s,%d,%s", m_op_field_width, mnemonic, REG_NAMES[RS1], SHCNT32, REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%d,%s", m_op_field_width, mnemonic, REG_NAMES[RS1], SHCNT32, REG_NAMES[RD]); } else { - print(buf, "%-*s%s,%s,%s", m_op_field_width, mnemonic, REG_NAMES[RS1], REG_NAMES[RS2], REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%s,%s", m_op_field_width, mnemonic, REG_NAMES[RS1], REG_NAMES[RS2], REG_NAMES[RD]); } return 4 | DASMFLAG_SUPPORTED; } -offs_t sparc_disassembler::dasm_read_state_reg(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_read_state_reg(std::ostream &stream, offs_t pc, uint32_t op) const { if (RS1 == 0) { - print(buf, "%-*s%%y,%s", m_op_field_width, "rd", REG_NAMES[RD]); + util::stream_format(stream, "%-*s%%y,%s", m_op_field_width, "rd", REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } else if ((m_version == 8) || ((m_version >= 9) && !USEIMM)) { if (!USEIMM && (RS1 == 15) && (RD == 0)) { - print(buf, "stbar"); + util::stream_format(stream, "stbar"); return 4 | DASMFLAG_SUPPORTED; } else @@ -1148,50 +1141,50 @@ offs_t sparc_disassembler::dasm_read_state_reg(char *buf, offs_t pc, uint32_t op if ((it == m_state_reg_desc.end()) || !it->second.reserved) { if ((it != m_state_reg_desc.end()) && it->second.read_name) - print(buf, "%-*s%s,%s", m_op_field_width, "rd", it->second.read_name, REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%s", m_op_field_width, "rd", it->second.read_name, REG_NAMES[RD]); else - print(buf, "%-*s%%asr%d,%s ! %s", m_op_field_width, "rd", RS1, REG_NAMES[RD], (RS1 < 16) ? "reserved" : "implementation-dependent"); + util::stream_format(stream, "%-*s%%asr%d,%s ! %s", m_op_field_width, "rd", RS1, REG_NAMES[RD], (RS1 < 16) ? "reserved" : "implementation-dependent"); return 4 | DASMFLAG_SUPPORTED; } } } else if ((m_version >= 9) && USEIMM && (RS1 == 15) && (RD == 0)) { - print(buf, "%-*s", m_op_field_width, "membar"); + util::stream_format(stream, "%-*s", m_op_field_width, "membar"); uint32_t mask(MMASK | (CMASK << 4)); - if (mask == 0) print(buf, "0"); - if (mask & 1) print(buf, "#LoadLoad%s", (mask >> 1) ? "|" : ""); + if (mask == 0) util::stream_format(stream, "0"); + if (mask & 1) util::stream_format(stream, "#LoadLoad%s", (mask >> 1) ? "|" : ""); mask >>= 1; - if (mask & 1) print(buf, "#StoreLoad%s", (mask >> 1) ? "|" : ""); + if (mask & 1) util::stream_format(stream, "#StoreLoad%s", (mask >> 1) ? "|" : ""); mask >>= 1; - if (mask & 1) print(buf, "#LoadStore%s", (mask >> 1) ? "|" : ""); + if (mask & 1) util::stream_format(stream, "#LoadStore%s", (mask >> 1) ? "|" : ""); mask >>= 1; - if (mask & 1) print(buf, "#StoreStore%s", (mask >> 1) ? "|" : ""); + if (mask & 1) util::stream_format(stream, "#StoreStore%s", (mask >> 1) ? "|" : ""); mask >>= 1; - if (mask & 1) print(buf, "#Lookaside%s", (mask >> 1) ? "|" : ""); + if (mask & 1) util::stream_format(stream, "#Lookaside%s", (mask >> 1) ? "|" : ""); mask >>= 1; - if (mask & 1) print(buf, "#MemIssue%s", (mask >> 1) ? "|" : ""); + if (mask & 1) util::stream_format(stream, "#MemIssue%s", (mask >> 1) ? "|" : ""); mask >>= 1; - if (mask & 1) print(buf, "#Sync"); + if (mask & 1) util::stream_format(stream, "#Sync"); return 4 | DASMFLAG_SUPPORTED; } - return dasm_invalid(buf, pc, op); + return dasm_invalid(stream, pc, op); } -offs_t sparc_disassembler::dasm_write_state_reg(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_write_state_reg(std::ostream &stream, offs_t pc, uint32_t op) const { if (RD == 0) { if (RS1 == 0) { - if (USEIMM) print(buf, "%-*s%d,%%y", m_op_field_width, "mov", SIMM13); - else print(buf, "%-*s%s,%%y", m_op_field_width, "mov", REG_NAMES[RS2]); + if (USEIMM) util::stream_format(stream, "%-*s%d,%%y", m_op_field_width, "mov", SIMM13); + else util::stream_format(stream, "%-*s%s,%%y", m_op_field_width, "mov", REG_NAMES[RS2]); } else { - if (USEIMM) print(buf, "%-*s%s,%08x,%%y", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13); - else print(buf, "%-*s%s,%s,%%y", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2]); + if (USEIMM) util::stream_format(stream, "%-*s%s,%08x,%%y", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13); + else util::stream_format(stream, "%-*s%s,%s,%%y", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2]); } return 4 | DASMFLAG_SUPPORTED; } @@ -1199,7 +1192,7 @@ offs_t sparc_disassembler::dasm_write_state_reg(char *buf, offs_t pc, uint32_t o { if ((m_version >= 9) && USEIMM && (RS1 == 0) && (RD == 15)) { - print(buf, "%-*s%d", m_op_field_width, "sir", SIMM13); + util::stream_format(stream, "%-*s%d", m_op_field_width, "sir", SIMM13); return 4 | DASMFLAG_SUPPORTED; } else @@ -1211,13 +1204,13 @@ offs_t sparc_disassembler::dasm_write_state_reg(char *buf, offs_t pc, uint32_t o { if (RS1 == 0) { - if (USEIMM) print(buf, "%-*s%d,%s", m_op_field_width, "mov", SIMM13, it->second.write_name); - else print(buf, "%-*s%s,%s", m_op_field_width, "mov", REG_NAMES[RS2], it->second.write_name); + if (USEIMM) util::stream_format(stream, "%-*s%d,%s", m_op_field_width, "mov", SIMM13, it->second.write_name); + else util::stream_format(stream, "%-*s%s,%s", m_op_field_width, "mov", REG_NAMES[RS2], it->second.write_name); } else { - if (USEIMM) print(buf, "%-*s%s,%08x,%s", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13, it->second.write_name); - else print(buf, "%-*s%s,%s,%s", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2], it->second.write_name); + if (USEIMM) util::stream_format(stream, "%-*s%s,%08x,%s", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13, it->second.write_name); + else util::stream_format(stream, "%-*s%s,%s,%s", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2], it->second.write_name); } } else @@ -1225,65 +1218,65 @@ offs_t sparc_disassembler::dasm_write_state_reg(char *buf, offs_t pc, uint32_t o const char * const comment((RD < 16) ? "reserved" : "implementation-dependent"); if (RS1 == 0) { - if (USEIMM) print(buf, "%-*s%d,%%asr%d ! %s", m_op_field_width, "mov", SIMM13, RD, comment); - else print(buf, "%-*s%s,%%asr%d ! %s", m_op_field_width, "mov", REG_NAMES[RS2], RD, comment); + if (USEIMM) util::stream_format(stream, "%-*s%d,%%asr%d ! %s", m_op_field_width, "mov", SIMM13, RD, comment); + else util::stream_format(stream, "%-*s%s,%%asr%d ! %s", m_op_field_width, "mov", REG_NAMES[RS2], RD, comment); } else { - if (USEIMM) print(buf, "%-*s%s,%08x,%%asr%d ! %s", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13, RD, comment); - else print(buf, "%-*s%s,%s,%%asr%d ! %s", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2], RD, comment); + if (USEIMM) util::stream_format(stream, "%-*s%s,%08x,%%asr%d ! %s", m_op_field_width, "wr", REG_NAMES[RS1], SIMM13, RD, comment); + else util::stream_format(stream, "%-*s%s,%s,%%asr%d ! %s", m_op_field_width, "wr", REG_NAMES[RS1], REG_NAMES[RS2], RD, comment); } } return 4 | DASMFLAG_SUPPORTED; } } } - return dasm_invalid(buf, pc, op); + return dasm_invalid(stream, pc, op); } -offs_t sparc_disassembler::dasm_move_cond(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_move_cond(std::ostream &stream, offs_t pc, uint32_t op) const { - if ((m_version < 9) || !MOVCC_CC_NAMES[MOVCC]) return dasm_invalid(buf, pc, op); + if ((m_version < 9) || !MOVCC_CC_NAMES[MOVCC]) return dasm_invalid(stream, pc, op); - char *ptr(buf); - print(ptr, "mov%s", MOVCC_COND_NAMES[MOVCOND | ((MOVCC << 2) & 16)]); - pad_op_field(buf, ptr); + const std::streampos start_position(stream.tellp()); + util::stream_format(stream, "mov%s", MOVCC_COND_NAMES[MOVCOND | ((MOVCC << 2) & 16)]); + pad_op_field(stream, start_position); if (USEIMM) - print(ptr, "%s,%d,%s", MOVCC_CC_NAMES[MOVCC], SIMM11, REG_NAMES[RD]); + util::stream_format(stream, "%s,%d,%s", MOVCC_CC_NAMES[MOVCC], SIMM11, REG_NAMES[RD]); else - print(ptr, "%s,%s,%s", MOVCC_CC_NAMES[MOVCC], REG_NAMES[RS2], REG_NAMES[RD]); + util::stream_format(stream, "%s,%s,%s", MOVCC_CC_NAMES[MOVCC], REG_NAMES[RS2], REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } -offs_t sparc_disassembler::dasm_move_reg_cond(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_move_reg_cond(std::ostream &stream, offs_t pc, uint32_t op) const { - if ((m_version < 9) || !MOVE_INT_COND_MNEMONICS[RCOND]) return dasm_invalid(buf, pc, op); + if ((m_version < 9) || !MOVE_INT_COND_MNEMONICS[RCOND]) return dasm_invalid(stream, pc, op); if (USEIMM) - print(buf, "%-*s%s,%d,%s", m_op_field_width, MOVE_INT_COND_MNEMONICS[RCOND], REG_NAMES[RS1], SIMM10, REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%d,%s", m_op_field_width, MOVE_INT_COND_MNEMONICS[RCOND], REG_NAMES[RS1], SIMM10, REG_NAMES[RD]); else - print(buf, "%-*s%s,%s,%s", m_op_field_width, MOVE_INT_COND_MNEMONICS[RCOND], REG_NAMES[RS1], REG_NAMES[RS2], REG_NAMES[RD]); + util::stream_format(stream, "%-*s%s,%s,%s", m_op_field_width, MOVE_INT_COND_MNEMONICS[RCOND], REG_NAMES[RS1], REG_NAMES[RS2], REG_NAMES[RD]); return 4 | DASMFLAG_SUPPORTED; } -offs_t sparc_disassembler::dasm_fpop1(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_fpop1(std::ostream &stream, offs_t pc, uint32_t op) const { const auto it(m_fpop1_desc.find(OPF)); - if (it == m_fpop1_desc.end()) return dasm_invalid(buf, pc, op); + if (it == m_fpop1_desc.end()) return dasm_invalid(stream, pc, op); if (it->second.three_op) - print(buf, "%-*s%%f%d,%%f%d,%%f%d", m_op_field_width, it->second.mnemonic, freg(RS1, it->second.rs1_shift), freg(RS2, it->second.rs2_shift), freg(RD, it->second.rd_shift)); + util::stream_format(stream, "%-*s%%f%d,%%f%d,%%f%d", m_op_field_width, it->second.mnemonic, freg(RS1, it->second.rs1_shift), freg(RS2, it->second.rs2_shift), freg(RD, it->second.rd_shift)); else - print(buf, "%-*s%%f%d,%%f%d", m_op_field_width, it->second.mnemonic, freg(RS2, it->second.rs2_shift), freg(RD, it->second.rd_shift)); + util::stream_format(stream, "%-*s%%f%d,%%f%d", m_op_field_width, it->second.mnemonic, freg(RS2, it->second.rs2_shift), freg(RD, it->second.rd_shift)); return 4 | DASMFLAG_SUPPORTED; } -offs_t sparc_disassembler::dasm_fpop2(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_fpop2(std::ostream &stream, offs_t pc, uint32_t op) const { // Move Floating-Point Register on Condition if ((m_version >= 9) && (((op >> 18) & 1) == 0) && MOVCC_CC_NAMES[OPFCC]) @@ -1299,10 +1292,10 @@ offs_t sparc_disassembler::dasm_fpop2(char *buf, offs_t pc, uint32_t op) const } if (mnemonic) { - char *ptr(buf); - print(ptr, "%s%s", mnemonic, MOVCC_COND_NAMES[MOVCOND | ((OPFCC << 2) & 16)]); - pad_op_field(buf, ptr); - print(ptr, "%s,%%f%d,%%f%d", MOVCC_CC_NAMES[OPFCC], freg(RS2, shift), freg(RD, shift)); + const std::streampos start_position(stream.tellp()); + util::stream_format(stream, "%s%s", mnemonic, MOVCC_COND_NAMES[MOVCOND | ((OPFCC << 2) & 16)]); + pad_op_field(stream, start_position); + util::stream_format(stream, "%s,%%f%d,%%f%d", MOVCC_CC_NAMES[OPFCC], freg(RS2, shift), freg(RD, shift)); return 4 | DASMFLAG_SUPPORTED; } } @@ -1314,47 +1307,47 @@ offs_t sparc_disassembler::dasm_fpop2(char *buf, offs_t pc, uint32_t op) const { if (it->second.int_rs1) { - print(buf, "%-*s%s,%%f%d,%%f%d", m_op_field_width, it->second.mnemonic, REG_NAMES[RS1], freg(RS2, it->second.shift), freg(RD, it->second.shift)); + util::stream_format(stream, "%-*s%s,%%f%d,%%f%d", m_op_field_width, it->second.mnemonic, REG_NAMES[RS1], freg(RS2, it->second.shift), freg(RD, it->second.shift)); return 4 | DASMFLAG_SUPPORTED; } else if (RD < 4) { - print(buf, "%-*s%%fcc%d,%%f%d,%%f%d", m_op_field_width, it->second.mnemonic, RD, freg(RS1, it->second.shift), freg(RS2, it->second.shift)); + util::stream_format(stream, "%-*s%%fcc%d,%%f%d,%%f%d", m_op_field_width, it->second.mnemonic, RD, freg(RS1, it->second.shift), freg(RS2, it->second.shift)); return 4 | DASMFLAG_SUPPORTED; } } else if (!it->second.int_rs1) { - print(buf, "%-*s%%f%d,%%f%d", m_op_field_width, it->second.mnemonic, freg(RS1, it->second.shift), freg(RS2, it->second.shift)); + util::stream_format(stream, "%-*s%%f%d,%%f%d", m_op_field_width, it->second.mnemonic, freg(RS1, it->second.shift), freg(RS2, it->second.shift)); return 4 | DASMFLAG_SUPPORTED; } } - return dasm_invalid(buf, pc, op); + return dasm_invalid(stream, pc, op); } -offs_t sparc_disassembler::dasm_impdep1(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_impdep1(std::ostream &stream, offs_t pc, uint32_t op) const { const auto it(m_vis_op_desc.find(OPF)); if (it != m_vis_op_desc.end()) { - print(buf, "%-*s", m_op_field_width, it->second.mnemonic); + util::stream_format(stream, "%-*s", m_op_field_width, it->second.mnemonic); bool args(false); if (it->second.collapse && !RS1) { - dasm_vis_arg(buf, args, it->second.rs2, RS2); + dasm_vis_arg(stream, args, it->second.rs2, RS2); } else if (it->second.collapse && !RS2) { - dasm_vis_arg(buf, args, it->second.rs1, RS1); + dasm_vis_arg(stream, args, it->second.rs1, RS1); } else { - dasm_vis_arg(buf, args, it->second.rs1, RS1); - dasm_vis_arg(buf, args, it->second.rs2, RS2); + dasm_vis_arg(stream, args, it->second.rs1, RS1); + dasm_vis_arg(stream, args, it->second.rs2, RS2); } - dasm_vis_arg(buf, args, it->second.rd, RD); + dasm_vis_arg(stream, args, it->second.rd, RD); return 4 | DASMFLAG_SUPPORTED; } @@ -1363,7 +1356,7 @@ offs_t sparc_disassembler::dasm_impdep1(char *buf, offs_t pc, uint32_t op) const case 0x081: if (m_vis_level >= vis_2) { - print(buf, "%-*s0x%x", m_op_field_width, "siam", IAMODE); + util::stream_format(stream, "%-*s0x%x", m_op_field_width, "siam", IAMODE); return 4 | DASMFLAG_SUPPORTED; } break; @@ -1372,7 +1365,7 @@ offs_t sparc_disassembler::dasm_impdep1(char *buf, offs_t pc, uint32_t op) const if (m_vis_level >= vis_3) { const bool shift(OPF == 0x152); - print(buf, "%-*s%%fcc%d,%%f%d,%%f%d", m_op_field_width, (shift) ? "flcmpd" : "flcmps", RD & 3, freg(RS1, shift), freg(RS2, shift)); + util::stream_format(stream, "%-*s%%fcc%d,%%f%d,%%f%d", m_op_field_width, (shift) ? "flcmpd" : "flcmps", RD & 3, freg(RS1, shift), freg(RS2, shift)); return 4 | DASMFLAG_SUPPORTED; } break; @@ -1380,36 +1373,36 @@ offs_t sparc_disassembler::dasm_impdep1(char *buf, offs_t pc, uint32_t op) const // TODO: driver hook for other kinds of coprocessor? - return dasm_invalid(buf, pc, op); + return dasm_invalid(stream, pc, op); } -offs_t sparc_disassembler::dasm_jmpl(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_jmpl(std::ostream &stream, offs_t pc, uint32_t op) const { if (USEIMM && (RD == 0) && ((RS1 == 15) || (RS1 == 31)) && (SIMM13 == 8)) { - print(buf, (RS1 == 31) ? "ret" : "retl"); + util::stream_format(stream, (RS1 == 31) ? "ret" : "retl"); } else { - print(buf, "%-*s", m_op_field_width, (RD == 0) ? "jmp" : (RD == 15) ? "call" : "jmpl"); - dasm_address(buf, op); + util::stream_format(stream, "%-*s", m_op_field_width, (RD == 0) ? "jmp" : (RD == 15) ? "call" : "jmpl"); + dasm_address(stream, op); if ((RD != 0) && (RD != 15)) - print(buf, ",%s", REG_NAMES[RD]); + util::stream_format(stream, ",%s", REG_NAMES[RD]); } return 4 | DASMFLAG_SUPPORTED; } -offs_t sparc_disassembler::dasm_return(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_return(std::ostream &stream, offs_t pc, uint32_t op) const { - print(buf, "%-*s", m_op_field_width, (m_version >= 9) ? "return" : "rett"); - dasm_address(buf, op); + util::stream_format(stream, "%-*s", m_op_field_width, (m_version >= 9) ? "return" : "rett"); + dasm_address(stream, op); return 4 | DASMFLAG_SUPPORTED; } -offs_t sparc_disassembler::dasm_tcc(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_tcc(std::ostream &stream, offs_t pc, uint32_t op) const { static const char *const tcc_names[16] = { "tn", "te", "tle", "tl", "tleu", "tcs", "tneg", "tvs", @@ -1420,29 +1413,29 @@ offs_t sparc_disassembler::dasm_tcc(char *buf, offs_t pc, uint32_t op) const if (m_version >= 9) { const char *const cc(cc_names[TCCCC]); - if (!cc) return dasm_invalid(buf, pc, op); - print(buf, "%-*s%s,", m_op_field_width, mnemonic, cc); + if (!cc) return dasm_invalid(stream, pc, op); + util::stream_format(stream, "%-*s%s,", m_op_field_width, mnemonic, cc); } else { - print(buf, "%-*s", m_op_field_width, mnemonic); + util::stream_format(stream, "%-*s", m_op_field_width, mnemonic); } if (USEIMM) { - if (RS1 == 0) print(buf, "%d", IMM7); - else print(buf, "%s,%d", REG_NAMES[RS1], IMM7); + if (RS1 == 0) util::stream_format(stream, "%d", IMM7); + else util::stream_format(stream, "%s,%d", REG_NAMES[RS1], IMM7); } else { - if (RS1 == 0) print(buf, "%s", REG_NAMES[RS2]); - else if (RS2 == 0) print(buf, "%s", REG_NAMES[RS1]); - else print(buf, "%s,%s", REG_NAMES[RS1], REG_NAMES[RS2]); + if (RS1 == 0) util::stream_format(stream, "%s", REG_NAMES[RS2]); + else if (RS2 == 0) util::stream_format(stream, "%s", REG_NAMES[RS1]); + else util::stream_format(stream, "%s,%s", REG_NAMES[RS1], REG_NAMES[RS2]); } return 4 | DASMFLAG_SUPPORTED; } -offs_t sparc_disassembler::dasm_ldst(char *buf, offs_t pc, uint32_t op) const +offs_t sparc_disassembler::dasm_ldst(std::ostream &stream, offs_t pc, uint32_t op) const { if (m_version >= 9) { @@ -1451,25 +1444,24 @@ offs_t sparc_disassembler::dasm_ldst(char *buf, offs_t pc, uint32_t op) const case 0x21: // Load floating-point state register if ((RD == 0) || (RD == 1)) { - print(buf, "%-*s[", m_op_field_width, (RD == 1) ? "ldx" : "ld"); - dasm_address(buf, op); - print(buf, "],%%fsr"); + util::stream_format(stream, "%-*s[", m_op_field_width, (RD == 1) ? "ldx" : "ld"); + dasm_address(stream, op); + util::stream_format(stream, "],%%fsr"); return 4 | DASMFLAG_SUPPORTED; } else if ((RD == 3) && (m_vis_level >= vis_3b)) { - print(buf, "%-*s[", m_op_field_width, "ldx"); - dasm_address(buf, op); - print(buf, "],%%efsr"); + util::stream_format(stream, "%-*s[", m_op_field_width, "ldx"); + dasm_address(stream, op); + util::stream_format(stream, "],%%efsr"); } break; case 0x25: // Store floating-point state register if ((RD == 0) || (RD == 1)) { - print(buf, "%-*s%%fsr,[", m_op_field_width, (RD == 1) ? "stx" : "st"); - dasm_address(buf, op); - *buf++ = ']'; - *buf = '\0'; + util::stream_format(stream, "%-*s%%fsr,[", m_op_field_width, (RD == 1) ? "stx" : "st"); + dasm_address(stream, op); + stream << ']'; return 4 | DASMFLAG_SUPPORTED; } break; @@ -1491,23 +1483,23 @@ offs_t sparc_disassembler::dasm_ldst(char *buf, offs_t pc, uint32_t op) const mnemonic = (OP3 == 0x3e) ? "casxl" : "casl"; } } - print(buf, "%-*s[%s]", m_op_field_width, mnemonic, REG_NAMES[RS1]); - if (print_asi) dasm_asi(buf, op); - print(buf, ",%s,%s", REG_NAMES[RS2], REG_NAMES[RD]); - if (print_asi) dasm_asi_comment(buf, op); + util::stream_format(stream, "%-*s[%s]", m_op_field_width, mnemonic, REG_NAMES[RS1]); + if (print_asi) dasm_asi(stream, op); + util::stream_format(stream, ",%s,%s", REG_NAMES[RS2], REG_NAMES[RD]); + if (print_asi) dasm_asi_comment(stream, op); } return 4 | DASMFLAG_SUPPORTED; case 0x2d: // Prefetch data case 0x3d: // Prefetch data from alternate space { - print(buf, "%-*s[", m_op_field_width, (OP3 == 0x3d) ? "prefetcha" : "prefetch"); - dasm_address(buf, op); - *buf++ = ']'; - if (OP3 == 0x3d) dasm_asi(buf, op); + util::stream_format(stream, "%-*s[", m_op_field_width, (OP3 == 0x3d) ? "prefetcha" : "prefetch"); + dasm_address(stream, op); + stream << ']'; + if (OP3 == 0x3d) dasm_asi(stream, op); const auto it(m_prftch_desc.find(RD)); - if (it != m_prftch_desc.end()) print(buf, ",%s", it->second.name); - else print(buf, ",0x%02x", RD); - if (OP3 == 0x3d) dasm_asi_comment(buf, op); + if (it != m_prftch_desc.end()) util::stream_format(stream, ",%s", it->second.name); + else util::stream_format(stream, ",0x%02x", RD); + if (OP3 == 0x3d) dasm_asi_comment(stream, op); } return 4 | DASMFLAG_SUPPORTED; } @@ -1518,127 +1510,123 @@ offs_t sparc_disassembler::dasm_ldst(char *buf, offs_t pc, uint32_t op) const { case 0x21: // Load Floating-point State Register case 0x31: // Load Coprocessor State Register - print(buf, "%-*s[", m_op_field_width, "ld"); - dasm_address(buf, op); - print(buf, "],%%%csr", (OP3 == 0x31) ? 'c' : 'f'); + util::stream_format(stream, "%-*s[", m_op_field_width, "ld"); + dasm_address(stream, op); + util::stream_format(stream, "],%%%csr", (OP3 == 0x31) ? 'c' : 'f'); return 4 | DASMFLAG_SUPPORTED; case 0x25: // Store Floating-point State Register case 0x35: // Store Coprocessor State Register - print(buf, "%-*s%%%csr,[", m_op_field_width, "st", (OP3 == 0x35) ? 'c' : 'f'); - dasm_address(buf, op); - *buf++ = ']'; - *buf = '\0'; + util::stream_format(stream, "%-*s%%%csr,[", m_op_field_width, "st", (OP3 == 0x35) ? 'c' : 'f'); + dasm_address(stream, op); + stream << ']'; return 4 | DASMFLAG_SUPPORTED; case 0x26: // Store Floating-point deferred-trap Queue case 0x36: // Store Coprocessor deferred-trap Queue - print(buf, "%-*s%%%cq,[", m_op_field_width, "std", (OP3 == 0x36) ? 'c' : 'f'); - dasm_address(buf, op); - *buf++ = ']'; - *buf = '\0'; + util::stream_format(stream, "%-*s%%%cq,[", m_op_field_width, "std", (OP3 == 0x36) ? 'c' : 'f'); + dasm_address(stream, op); + stream << ']'; return 4 | DASMFLAG_SUPPORTED; } } const auto it(m_ldst_desc.find(OP3)); if (it == m_ldst_desc.end()) - return dasm_invalid(buf, pc, op); + return dasm_invalid(stream, pc, op); if (it->second.alternate && USEIMM && (m_version < 9)) - return dasm_invalid(buf, pc, op); + return dasm_invalid(stream, pc, op); if (it->second.g0_synth && (RD == 0)) { - print(buf, "%-*s[", m_op_field_width, it->second.g0_synth); - dasm_address(buf, op); - *buf++ = ']'; - *buf = '\0'; + util::stream_format(stream, "%-*s[", m_op_field_width, it->second.g0_synth); + dasm_address(stream, op); + stream << ']'; if (it->second.alternate) { - dasm_asi(buf, op); - dasm_asi_comment(buf, op); + dasm_asi(stream, op); + dasm_asi_comment(stream, op); } } else { - print(buf, "%-*s", m_op_field_width, it->second.mnemonic); + util::stream_format(stream, "%-*s", m_op_field_width, it->second.mnemonic); if (it->second.rd_first) { - if (it->second.rd_alt_reg) print(buf, "%%%c%d,", it->second.rd_alt_reg, freg(RD, it->second.rd_shift)); - else print(buf, "%s,", REG_NAMES[RD]); + if (it->second.rd_alt_reg) util::stream_format(stream, "%%%c%d,", it->second.rd_alt_reg, freg(RD, it->second.rd_shift)); + else util::stream_format(stream, "%s,", REG_NAMES[RD]); } - *buf++ = '['; - dasm_address(buf, op); - *buf++ = ']'; - *buf = '\0'; - if (it->second.alternate) dasm_asi(buf, op); + stream << '['; + dasm_address(stream, op); + stream << ']'; + if (it->second.alternate) dasm_asi(stream, op); if (!it->second.rd_first) { - if (it->second.rd_alt_reg) print(buf, ",%%%c%d", it->second.rd_alt_reg, freg(RD, it->second.rd_shift)); - else print(buf, ",%s", REG_NAMES[RD]); + if (it->second.rd_alt_reg) util::stream_format(stream, ",%%%c%d", it->second.rd_alt_reg, freg(RD, it->second.rd_shift)); + else util::stream_format(stream, ",%s", REG_NAMES[RD]); } - if (it->second.alternate) dasm_asi_comment(buf, op); + if (it->second.alternate) dasm_asi_comment(stream, op); } return 4 | DASMFLAG_SUPPORTED; } -void sparc_disassembler::dasm_address(char *&output, uint32_t op) const +void sparc_disassembler::dasm_address(std::ostream &stream, uint32_t op) const { if (USEIMM) { - if (RS1 == 0) print(output, "0x%08x", SIMM13); - else print(output, "%s%c0x%04x", REG_NAMES[RS1], (SIMM13 < 0) ? '-' : '+', std::abs(SIMM13)); + if (RS1 == 0) util::stream_format(stream, "0x%08x", SIMM13); + else util::stream_format(stream, "%s%c0x%04x", REG_NAMES[RS1], (SIMM13 < 0) ? '-' : '+', std::abs(SIMM13)); } else { - if (RS1 == 0) print(output, "%s", REG_NAMES[RS2]); - else if (RS2 == 0) print(output, "%s", REG_NAMES[RS1]); - else print(output, "%s+%s", REG_NAMES[RS1], REG_NAMES[RS2]); + if (RS1 == 0) util::stream_format(stream, "%s", REG_NAMES[RS2]); + else if (RS2 == 0) util::stream_format(stream, "%s", REG_NAMES[RS1]); + else util::stream_format(stream, "%s+%s", REG_NAMES[RS1], REG_NAMES[RS2]); } } -void sparc_disassembler::dasm_asi(char *&output, uint32_t op) const +void sparc_disassembler::dasm_asi(std::ostream &stream, uint32_t op) const { if (USEIMM) { - print(output, "%%asi"); + util::stream_format(stream, "%%asi"); } else { const auto it(m_asi_desc.find(ASI)); if ((it != m_asi_desc.end()) && it->second.name) - print(output, "%s", it->second.name); + util::stream_format(stream, "%s", it->second.name); else - print(output, "0x%02x", ASI); + util::stream_format(stream, "0x%02x", ASI); } } -void sparc_disassembler::dasm_asi_comment(char *&output, uint32_t op) const +void sparc_disassembler::dasm_asi_comment(std::ostream &stream, uint32_t op) const { if (!USEIMM) { const auto it(m_asi_desc.find(ASI)); if ((it != m_asi_desc.end()) && it->second.desc) - print(output, " ! %s", it->second.desc); + util::stream_format(stream, " ! %s", it->second.desc); } } -void sparc_disassembler::dasm_vis_arg(char *&output, bool &args, vis_op_desc::arg fmt, uint32_t reg) const +void sparc_disassembler::dasm_vis_arg(std::ostream &stream, bool &args, vis_op_desc::arg fmt, uint32_t reg) const { switch (fmt) { case vis_op_desc::X: break; case vis_op_desc::R: - print(output, args ? ",%s" : "%s", REG_NAMES[reg]); + util::stream_format(stream, args ? ",%s" : "%s", REG_NAMES[reg]); args = true; break; case vis_op_desc::Fs: case vis_op_desc::Fd: - print(output, args ? ",%%f%d" : "%%f%d", freg(reg, (fmt == vis_op_desc::Fd))); + util::stream_format(stream, args ? ",%%f%d" : "%%f%d", freg(reg, (fmt == vis_op_desc::Fd))); args = true; break; }; diff --git a/src/devices/cpu/sparc/sparcdasm.h b/src/devices/cpu/sparc/sparcdasm.h index 5b545325967..f5643a0e87b 100644 --- a/src/devices/cpu/sparc/sparcdasm.h +++ b/src/devices/cpu/sparc/sparcdasm.h @@ -106,7 +106,7 @@ public: } } - offs_t dasm(char *buf, offs_t pc, uint32_t op) const; + offs_t dasm(std::ostream &stream, offs_t pc, uint32_t op) const; private: struct branch_desc @@ -175,25 +175,25 @@ private: }; typedef std::map vis_op_desc_map; - offs_t dasm_invalid(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_branch(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_shift(char *buf, offs_t pc, uint32_t op, const char *mnemonic, const char *mnemonicx, const char *mnemonicx0) const; - offs_t dasm_read_state_reg(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_write_state_reg(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_move_cond(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_move_reg_cond(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_fpop1(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_fpop2(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_impdep1(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_jmpl(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_return(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_tcc(char *buf, offs_t pc, uint32_t op) const; - offs_t dasm_ldst(char *buf, offs_t pc, uint32_t op) const; + offs_t dasm_invalid(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_branch(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_shift(std::ostream &stream, offs_t pc, uint32_t op, const char *mnemonic, const char *mnemonicx, const char *mnemonicx0) const; + offs_t dasm_read_state_reg(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_write_state_reg(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_move_cond(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_move_reg_cond(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_fpop1(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_fpop2(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_impdep1(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_jmpl(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_return(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_tcc(std::ostream &stream, offs_t pc, uint32_t op) const; + offs_t dasm_ldst(std::ostream &stream, offs_t pc, uint32_t op) const; - void dasm_address(char *&output, uint32_t op) const; - void dasm_asi(char *&output, uint32_t op) const; - void dasm_asi_comment(char *&output, uint32_t op) const; - void dasm_vis_arg(char *&output, bool &args, vis_op_desc::arg fmt, uint32_t reg) const; + void dasm_address(std::ostream &stream, uint32_t op) const; + void dasm_asi(std::ostream &stream, uint32_t op) const; + void dasm_asi_comment(std::ostream &stream, uint32_t op) const; + void dasm_vis_arg(std::ostream &stream, bool &args, vis_op_desc::arg fmt, uint32_t reg) const; uint32_t freg(uint32_t val, bool shift) const; @@ -203,8 +203,7 @@ private: template void add_ldst_desc(const T &desc); template void add_vis_op_desc(const T &desc); - void pad_op_field(char *buf, char *&output) const; - ATTR_PRINTF(2, 3) static void print(char *&output, const char *fmt, ...); + void pad_op_field(std::ostream &stream, std::streampos start_position) const; static const char * const REG_NAMES[32]; static const branch_desc EMPTY_BRANCH_DESC; diff --git a/src/devices/cpu/spc700/spc700.cpp b/src/devices/cpu/spc700/spc700.cpp index 7d7468f8d9a..39b4efb293c 100644 --- a/src/devices/cpu/spc700/spc700.cpp +++ b/src/devices/cpu/spc700/spc700.cpp @@ -1344,9 +1344,9 @@ void spc700_device::execute_set_input( int inptnum, int state ) #include "spc700ds.h" -offs_t spc700_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t spc700_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return CPU_DISASSEMBLE_NAME(spc700)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(spc700)(this, stream, pc, oprom, opram, options); } //int dump_flag = 0; diff --git a/src/devices/cpu/spc700/spc700.h b/src/devices/cpu/spc700/spc700.h index 948e4d5e27c..ba1e064856d 100644 --- a/src/devices/cpu/spc700/spc700.h +++ b/src/devices/cpu/spc700/spc700.h @@ -35,7 +35,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 3; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/spc700/spc700ds.cpp b/src/devices/cpu/spc700/spc700ds.cpp index 08fbd80fadc..de7accc7cb8 100644 --- a/src/devices/cpu/spc700/spc700ds.cpp +++ b/src/devices/cpu/spc700/spc700ds.cpp @@ -337,7 +337,7 @@ static inline unsigned int read_16_immediate(void) return result | (*rombase++ << 8); } -static offs_t internal_disasm_spc700(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(spc700) { const spc700_opcode_struct* opcode; uint32_t flags = 0; @@ -430,13 +430,3 @@ static offs_t internal_disasm_spc700(cpu_device *device, std::ostream &stream, o } return (g_pc - pc) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(spc700) -{ - std::ostringstream stream; - offs_t result = internal_disasm_spc700(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/ssem/ssem.cpp b/src/devices/cpu/ssem/ssem.cpp index a76d9a44182..c2f462a6738 100644 --- a/src/devices/cpu/ssem/ssem.cpp +++ b/src/devices/cpu/ssem/ssem.cpp @@ -188,10 +188,10 @@ uint32_t ssem_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t ssem_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t ssem_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( ssem ); - return CPU_DISASSEMBLE_NAME(ssem)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(ssem)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/ssem/ssem.h b/src/devices/cpu/ssem/ssem.h index 4bfebaa432e..69118e1326d 100644 --- a/src/devices/cpu/ssem/ssem.h +++ b/src/devices/cpu/ssem/ssem.h @@ -42,7 +42,7 @@ public: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/ssem/ssemdasm.cpp b/src/devices/cpu/ssem/ssemdasm.cpp index 069d2ad9da3..8ad79f96d8c 100644 --- a/src/devices/cpu/ssem/ssemdasm.cpp +++ b/src/devices/cpu/ssem/ssemdasm.cpp @@ -62,17 +62,6 @@ static offs_t ssem_dasm_one(std::ostream &stream, offs_t pc, uint32_t op) return 4 | DASMFLAG_SUPPORTED; } - -static offs_t ssem_dasm_one(char *buffer, offs_t pc, uint32_t op) -{ - std::ostringstream stream; - offs_t result = ssem_dasm_one(stream, pc, op); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - - /*****************************************************************************/ CPU_DISASSEMBLE( ssem ) @@ -81,5 +70,5 @@ CPU_DISASSEMBLE( ssem ) (*(uint8_t *)(opram + 1) << 16) | (*(uint8_t *)(opram + 2) << 8) | (*(uint8_t *)(opram + 3) << 0); - return ssem_dasm_one(buffer, pc, op); + return ssem_dasm_one(stream, pc, op); } diff --git a/src/devices/cpu/ssp1601/ssp1601.cpp b/src/devices/cpu/ssp1601/ssp1601.cpp index 1d38f5981a9..25005fd8701 100644 --- a/src/devices/cpu/ssp1601/ssp1601.cpp +++ b/src/devices/cpu/ssp1601/ssp1601.cpp @@ -200,10 +200,10 @@ ssp1601_device::ssp1601_device(const machine_config &mconfig, const char *tag, d } -offs_t ssp1601_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t ssp1601_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( ssp1601 ); - return CPU_DISASSEMBLE_NAME(ssp1601)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(ssp1601)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/ssp1601/ssp1601.h b/src/devices/cpu/ssp1601/ssp1601.h index b59fff81e4f..cf5029fcee5 100644 --- a/src/devices/cpu/ssp1601/ssp1601.h +++ b/src/devices/cpu/ssp1601/ssp1601.h @@ -45,7 +45,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/ssp1601/ssp1601d.cpp b/src/devices/cpu/ssp1601/ssp1601d.cpp index 71a9dbdcaed..465dd657d90 100644 --- a/src/devices/cpu/ssp1601/ssp1601d.cpp +++ b/src/devices/cpu/ssp1601/ssp1601d.cpp @@ -288,20 +288,11 @@ static unsigned dasm_ssp1601(std::ostream &stream, unsigned pc, const uint8_t *o return size | flags | DASMFLAG_SUPPORTED; } -static unsigned dasm_ssp1601(char *buffer, unsigned pc, const uint8_t *oprom) -{ - std::ostringstream stream; - offs_t result = dasm_ssp1601(stream, pc, oprom); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - // vim:ts=4 CPU_DISASSEMBLE( ssp1601 ) { //ssp1601_state_t *ssp1601_state = get_safe_token(device); - return dasm_ssp1601(buffer, pc, oprom); + return dasm_ssp1601(stream, pc, oprom); } diff --git a/src/devices/cpu/superfx/superfx.cpp b/src/devices/cpu/superfx/superfx.cpp index 9da3d9bd4c7..7ed250b49f4 100644 --- a/src/devices/cpu/superfx/superfx.cpp +++ b/src/devices/cpu/superfx/superfx.cpp @@ -1438,15 +1438,6 @@ void superfx_device::execute_run() } } -offs_t superfx_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) -{ - std::ostringstream stream; - offs_t result = disasm_disassemble(stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - offs_t superfx_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { uint8_t op = *(uint8_t *)(opram + 0); diff --git a/src/devices/cpu/superfx/superfx.h b/src/devices/cpu/superfx/superfx.h index ba62122eaf2..7f04f44171c 100644 --- a/src/devices/cpu/superfx/superfx.h +++ b/src/devices/cpu/superfx/superfx.h @@ -126,7 +126,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 3; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; @@ -209,8 +209,6 @@ private: inline void superfx_add_clocks_internal(uint32_t clocks); void superfx_timing_reset(); inline void superfx_dreg_sfr_sz_update(); - - offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options); }; diff --git a/src/devices/cpu/t11/t11.cpp b/src/devices/cpu/t11/t11.cpp index ce9e4290e87..5c889099cd7 100644 --- a/src/devices/cpu/t11/t11.cpp +++ b/src/devices/cpu/t11/t11.cpp @@ -422,8 +422,8 @@ void t11_device::execute_run() } -offs_t t11_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t t11_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( t11 ); - return CPU_DISASSEMBLE_NAME(t11)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(t11)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/t11/t11.h b/src/devices/cpu/t11/t11.h index 1c62db4ee17..bad743a7645 100644 --- a/src/devices/cpu/t11/t11.h +++ b/src/devices/cpu/t11/t11.h @@ -67,7 +67,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 6; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; protected: address_space_config m_program_config; diff --git a/src/devices/cpu/t11/t11dasm.cpp b/src/devices/cpu/t11/t11dasm.cpp index 54cf781f827..b1936566f9c 100644 --- a/src/devices/cpu/t11/t11dasm.cpp +++ b/src/devices/cpu/t11/t11dasm.cpp @@ -84,7 +84,7 @@ static unsigned MakeEA (char *ea, int lo, unsigned pc, int width) } -static offs_t internal_disasm_t11(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(t11) { char ea1[32], ea2[32]; unsigned PC = pc; @@ -516,13 +516,3 @@ static offs_t internal_disasm_t11(cpu_device *device, std::ostream &stream, offs return (pc - PC) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(t11) -{ - std::ostringstream stream; - offs_t result = internal_disasm_t11(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/tlcs90/tlcs90.h b/src/devices/cpu/tlcs90/tlcs90.h index b303f8dd3f6..ba25d0ff927 100644 --- a/src/devices/cpu/tlcs90/tlcs90.h +++ b/src/devices/cpu/tlcs90/tlcs90.h @@ -58,14 +58,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 6; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override - { - std::ostringstream stream; - offs_t result = disasm_disassemble(stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; - } + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: enum e_mode { @@ -147,7 +140,6 @@ private: void t90_stop_timer(int i); void t90_stop_timer4(); void set_irq_line(int irq, int state); - offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options); }; diff --git a/src/devices/cpu/tlcs900/dasm900.cpp b/src/devices/cpu/tlcs900/dasm900.cpp index aa1bdcbc9b2..a4d46be2dde 100644 --- a/src/devices/cpu/tlcs900/dasm900.cpp +++ b/src/devices/cpu/tlcs900/dasm900.cpp @@ -1433,7 +1433,7 @@ static const char *const s_cond[16] = }; -static offs_t internal_disasm_tlcs900(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(tlcs900) { const tlcs900inst *dasm; std::string buf; @@ -2256,13 +2256,3 @@ static offs_t internal_disasm_tlcs900(cpu_device *device, std::ostream &stream, return pos | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(tlcs900) -{ - std::ostringstream stream; - offs_t result = internal_disasm_tlcs900(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/tlcs900/tlcs900.cpp b/src/devices/cpu/tlcs900/tlcs900.cpp index cdeb65e2d21..9b87d5f54b4 100644 --- a/src/devices/cpu/tlcs900/tlcs900.cpp +++ b/src/devices/cpu/tlcs900/tlcs900.cpp @@ -141,10 +141,10 @@ void tmp95c063_device::device_config_complete() } -offs_t tlcs900h_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tlcs900h_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tlcs900 ); - return CPU_DISASSEMBLE_NAME(tlcs900)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tlcs900)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tlcs900/tlcs900.h b/src/devices/cpu/tlcs900/tlcs900.h index e0ab4a99b15..12e6f8f1914 100644 --- a/src/devices/cpu/tlcs900/tlcs900.h +++ b/src/devices/cpu/tlcs900/tlcs900.h @@ -76,7 +76,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 7; } /* FIXME */ - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; protected: int m_am8_16; diff --git a/src/devices/cpu/tms1000/tms0980.cpp b/src/devices/cpu/tms1000/tms0980.cpp index 523844b6366..b3678165d4a 100644 --- a/src/devices/cpu/tms1000/tms0980.cpp +++ b/src/devices/cpu/tms1000/tms0980.cpp @@ -90,10 +90,10 @@ machine_config_constructor tms1980_cpu_device::device_mconfig_additions() const // disasm -offs_t tms0980_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms0980_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(tms0980); - return CPU_DISASSEMBLE_NAME(tms0980)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms0980)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms1000/tms0980.h b/src/devices/cpu/tms1000/tms0980.h index 921c585769b..afbcaa3647d 100644 --- a/src/devices/cpu/tms1000/tms0980.h +++ b/src/devices/cpu/tms1000/tms0980.h @@ -28,7 +28,7 @@ protected: virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual uint8_t read_k_input() override; virtual void set_cki_bus() override; diff --git a/src/devices/cpu/tms1000/tms1000.cpp b/src/devices/cpu/tms1000/tms1000.cpp index 5948d9753ff..40add17105c 100644 --- a/src/devices/cpu/tms1000/tms1000.cpp +++ b/src/devices/cpu/tms1000/tms1000.cpp @@ -93,10 +93,10 @@ machine_config_constructor tms1000_cpu_device::device_mconfig_additions() const // disasm -offs_t tms1000_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms1000_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(tms1000); - return CPU_DISASSEMBLE_NAME(tms1000)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms1000)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms1000/tms1000.h b/src/devices/cpu/tms1000/tms1000.h index 7cb5ba66ac6..049b24873fd 100644 --- a/src/devices/cpu/tms1000/tms1000.h +++ b/src/devices/cpu/tms1000/tms1000.h @@ -24,7 +24,7 @@ protected: virtual machine_config_constructor device_mconfig_additions() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; class tms1070_cpu_device : public tms1000_cpu_device diff --git a/src/devices/cpu/tms1000/tms1100.cpp b/src/devices/cpu/tms1000/tms1100.cpp index 6ef15a98043..93c7c07a69c 100644 --- a/src/devices/cpu/tms1000/tms1100.cpp +++ b/src/devices/cpu/tms1000/tms1100.cpp @@ -49,10 +49,10 @@ tms1370_cpu_device::tms1370_cpu_device(const machine_config &mconfig, const char // disasm -offs_t tms1100_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms1100_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(tms1100); - return CPU_DISASSEMBLE_NAME(tms1100)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms1100)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms1000/tms1100.h b/src/devices/cpu/tms1000/tms1100.h index e57f880df12..b5df68e40cc 100644 --- a/src/devices/cpu/tms1000/tms1100.h +++ b/src/devices/cpu/tms1000/tms1100.h @@ -22,7 +22,7 @@ protected: // overrides virtual void device_reset() override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void op_setr() override; virtual void op_rstr() override; diff --git a/src/devices/cpu/tms1000/tms1k_dasm.cpp b/src/devices/cpu/tms1000/tms1k_dasm.cpp index b1c4422d369..8987a666726 100644 --- a/src/devices/cpu/tms1000/tms1k_dasm.cpp +++ b/src/devices/cpu/tms1000/tms1k_dasm.cpp @@ -259,32 +259,23 @@ static offs_t tms1k_dasm(std::ostream &stream, const uint8_t *oprom, const uint8 return pos | s_flags[instr] | DASMFLAG_SUPPORTED; } -static offs_t tms1k_dasm(char *buffer, const uint8_t *oprom, const uint8_t *lut_mnemonic, uint16_t opcode_mask) -{ - std::ostringstream stream; - offs_t result = tms1k_dasm(stream, oprom, lut_mnemonic, opcode_mask); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE(tms1000) { - return tms1k_dasm(buffer, oprom, tms1000_mnemonic, 0xff); + return tms1k_dasm(stream, oprom, tms1000_mnemonic, 0xff); } CPU_DISASSEMBLE(tms1100) { - return tms1k_dasm(buffer, oprom, tms1100_mnemonic, 0xff); + return tms1k_dasm(stream, oprom, tms1100_mnemonic, 0xff); } CPU_DISASSEMBLE(tms0980) { - return tms1k_dasm(buffer, oprom, tms0980_mnemonic, 0x1ff); + return tms1k_dasm(stream, oprom, tms0980_mnemonic, 0x1ff); } CPU_DISASSEMBLE(tp0320) { - return tms1k_dasm(buffer, oprom, tp0320_mnemonic, 0x1ff); + return tms1k_dasm(stream, oprom, tp0320_mnemonic, 0x1ff); } diff --git a/src/devices/cpu/tms1000/tp0320.cpp b/src/devices/cpu/tms1000/tp0320.cpp index ab33c3788e2..243ef3bb8e3 100644 --- a/src/devices/cpu/tms1000/tp0320.cpp +++ b/src/devices/cpu/tms1000/tp0320.cpp @@ -58,10 +58,10 @@ machine_config_constructor tp0320_cpu_device::device_mconfig_additions() const // disasm -offs_t tp0320_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tp0320_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(tp0320); - return CPU_DISASSEMBLE_NAME(tp0320)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tp0320)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms1000/tp0320.h b/src/devices/cpu/tms1000/tp0320.h index a85fc253cc4..fcff112a900 100644 --- a/src/devices/cpu/tms1000/tp0320.h +++ b/src/devices/cpu/tms1000/tp0320.h @@ -24,7 +24,7 @@ protected: virtual uint32_t decode_fixed(uint16_t op) override { return 0; } // not yet virtual uint32_t decode_micro(uint8_t sel) override; virtual void device_reset() override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual machine_config_constructor device_mconfig_additions() const override; }; diff --git a/src/devices/cpu/tms32010/32010dsm.cpp b/src/devices/cpu/tms32010/32010dsm.cpp index c1a8f13a914..040a24b11b6 100644 --- a/src/devices/cpu/tms32010/32010dsm.cpp +++ b/src/devices/cpu/tms32010/32010dsm.cpp @@ -222,7 +222,7 @@ static void InitDasm32010(void) OpInizialized = 1; } -static offs_t internal_disasm_tms32010(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(tms32010) { uint32_t flags = 0; int a, b, d, k, m, n, p, r, s, w; /* these can all be filled in by parsing an instruction */ @@ -332,13 +332,3 @@ static offs_t internal_disasm_tms32010(cpu_device *device, std::ostream &stream, } return cnt | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(tms32010) -{ - std::ostringstream stream; - offs_t result = internal_disasm_tms32010(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/tms32010/tms32010.cpp b/src/devices/cpu/tms32010/tms32010.cpp index e5108cb0c7e..76d178b5c73 100644 --- a/src/devices/cpu/tms32010/tms32010.cpp +++ b/src/devices/cpu/tms32010/tms32010.cpp @@ -131,10 +131,10 @@ tms32016_device::tms32016_device(const machine_config &mconfig, const char *tag, } -offs_t tms32010_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms32010_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms32010 ); - return CPU_DISASSEMBLE_NAME(tms32010)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms32010)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms32010/tms32010.h b/src/devices/cpu/tms32010/tms32010.h index 99c2f084e62..4be9b7fe7d1 100644 --- a/src/devices/cpu/tms32010/tms32010.h +++ b/src/devices/cpu/tms32010/tms32010.h @@ -72,7 +72,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/tms32025/32025dsm.cpp b/src/devices/cpu/tms32025/32025dsm.cpp index 1299f2a7f19..cf9a61571b5 100644 --- a/src/devices/cpu/tms32025/32025dsm.cpp +++ b/src/devices/cpu/tms32025/32025dsm.cpp @@ -387,7 +387,7 @@ static void InitDasm32025(void) OpInizialized = 1; } -static offs_t internal_disasm_tms32025(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(tms32025) { uint32_t flags = 0; int a, b, c, d, k, m, n, p, r, s, t, w; /* these can all be filled in by parsing an instruction */ @@ -503,13 +503,3 @@ static offs_t internal_disasm_tms32025(cpu_device *device, std::ostream &stream, } return cnt | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(tms32025) -{ - std::ostringstream stream; - offs_t result = internal_disasm_tms32025(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/tms32025/tms32025.cpp b/src/devices/cpu/tms32025/tms32025.cpp index 991b5a0b050..dc0e69eb7aa 100644 --- a/src/devices/cpu/tms32025/tms32025.cpp +++ b/src/devices/cpu/tms32025/tms32025.cpp @@ -242,10 +242,10 @@ tms32026_device::tms32026_device(const machine_config &mconfig, const char *tag, } -offs_t tms32025_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms32025_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms32025 ); - return CPU_DISASSEMBLE_NAME(tms32025)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms32025)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms32025/tms32025.h b/src/devices/cpu/tms32025/tms32025.h index a2f907e3769..bd752d5885e 100644 --- a/src/devices/cpu/tms32025/tms32025.h +++ b/src/devices/cpu/tms32025/tms32025.h @@ -118,7 +118,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/tms32031/32031ops.hxx b/src/devices/cpu/tms32031/32031ops.hxx index 476c5082a3e..a99d3d0295e 100644 --- a/src/devices/cpu/tms32031/32031ops.hxx +++ b/src/devices/cpu/tms32031/32031ops.hxx @@ -574,14 +574,14 @@ void tms3203x_device::addf(tmsreg &dst, tmsreg &src1, tmsreg &src2) } // if the mantissa is >= 2.0 or < -2.0, normalize - else if (man >= int64_t(U64(0x100000000)) || man < int64_t(U64(0xffffffff00000000))) + else if (man >= int64_t(0x100000000U) || man < int64_t(0xffffffff00000000U)) { man >>= 1; exp++; } // if the mantissa is < 1.0 and > -1.0, normalize - else if (man < int64_t(U64(0x80000000)) && man >= int64_t(U64(0xffffffff80000000))) + else if (man < int64_t(0x80000000U) && man >= int64_t(0xffffffff80000000U)) { if (man > 0) { @@ -687,14 +687,14 @@ void tms3203x_device::subf(tmsreg &dst, tmsreg &src1, tmsreg &src2) } // if the mantissa is >= 2.0 or < -2.0, normalize - else if (man >= int64_t(U64(0x100000000)) || man < int64_t(U64(0xffffffff00000000))) + else if (man >= int64_t(0x100000000U) || man < int64_t(0xffffffff00000000U)) { man >>= 1; exp++; } // if the mantissa is < 1.0 and > -1.0, normalize - else if (man < int64_t(U64(0x80000000)) && man >= int64_t(U64(0xffffffff80000000))) + else if (man < int64_t(0x80000000U) && man >= int64_t(0xffffffff80000000U)) { if (man > 0) { @@ -778,11 +778,11 @@ void tms3203x_device::mpyf(tmsreg &dst, tmsreg &src1, tmsreg &src2) } // if the mantissa is >= 2.0 or <= -2.0, normalize - else if (man >= int64_t(U64(0x100000000))) + else if (man >= int64_t(0x100000000U)) { man >>= 1; exp++; - if (man >= int64_t(U64(0x100000000))) + if (man >= int64_t(0x100000000U)) { man >>= 1; exp++; @@ -790,7 +790,7 @@ void tms3203x_device::mpyf(tmsreg &dst, tmsreg &src1, tmsreg &src2) } // if the mantissa is >= 2.0 or <= -2.0, normalize - else if (man < int64_t(U64(0xffffffff00000000))) + else if (man < int64_t(0xffffffff00000000U)) { man >>= 1; exp++; diff --git a/src/devices/cpu/tms32031/dis32031.cpp b/src/devices/cpu/tms32031/dis32031.cpp index d5c1d01d73b..ddb47a27d44 100644 --- a/src/devices/cpu/tms32031/dis32031.cpp +++ b/src/devices/cpu/tms32031/dis32031.cpp @@ -122,62 +122,65 @@ static const char *const condition[32] = // 19 = LUF (LUF) // 20 = ZUF (Z | UF) -static void append_indirect(uint8_t ma, int8_t disp, char *buffer) +static void append_indirect(uint8_t ma, int8_t disp, std::ostream &stream) { - char *dst = &buffer[strlen(buffer)]; - char dispstr[20]; + std::string dispstr; int mode = (ma >> 3) & 0x1f; int ar = ma & 7; - dispstr[0] = 0; if (disp < 0) - sprintf(dispstr, "(-%X)", -disp & 0xffff); + dispstr = util::string_format("(-%X)", -disp & 0xffff); else if (disp > 0) - sprintf(dispstr, "(%X)", disp); + dispstr = util::string_format("(%X)", disp); switch (mode) { - case 0: sprintf(dst, "*+AR%d%s", ar, dispstr); break; - case 1: sprintf(dst, "*-AR%d%s", ar, dispstr); break; - case 2: sprintf(dst, "*++AR%d%s", ar, dispstr); break; - case 3: sprintf(dst, "*--AR%d%s", ar, dispstr); break; - case 4: sprintf(dst, "*AR%d++%s", ar, dispstr); break; - case 5: sprintf(dst, "*AR%d--%s", ar, dispstr); break; - case 6: sprintf(dst, "*AR%d++%s%%", ar, dispstr); break; - case 7: sprintf(dst, "*AR%d--%s%%", ar, dispstr); break; + case 0: util::stream_format(stream, "*+AR%d%s", ar, dispstr); break; + case 1: util::stream_format(stream, "*-AR%d%s", ar, dispstr); break; + case 2: util::stream_format(stream, "*++AR%d%s", ar, dispstr); break; + case 3: util::stream_format(stream, "*--AR%d%s", ar, dispstr); break; + case 4: util::stream_format(stream, "*AR%d++%s", ar, dispstr); break; + case 5: util::stream_format(stream, "*AR%d--%s", ar, dispstr); break; + case 6: util::stream_format(stream, "*AR%d++%s%%", ar, dispstr); break; + case 7: util::stream_format(stream, "*AR%d--%s%%", ar, dispstr); break; - case 8: sprintf(dst, "*+AR%d(IR0)", ar); break; - case 9: sprintf(dst, "*-AR%d(IR0)", ar); break; - case 10: sprintf(dst, "*++AR%d(IR0)", ar); break; - case 11: sprintf(dst, "*--AR%d(IR0)", ar); break; - case 12: sprintf(dst, "*AR%d++(IR0)", ar); break; - case 13: sprintf(dst, "*AR%d--(IR0)", ar); break; - case 14: sprintf(dst, "*AR%d++(IR0)%%", ar); break; - case 15: sprintf(dst, "*AR%d--(IR0)%%", ar); break; + case 8: util::stream_format(stream, "*+AR%d(IR0)", ar); break; + case 9: util::stream_format(stream, "*-AR%d(IR0)", ar); break; + case 10: util::stream_format(stream, "*++AR%d(IR0)", ar); break; + case 11: util::stream_format(stream, "*--AR%d(IR0)", ar); break; + case 12: util::stream_format(stream, "*AR%d++(IR0)", ar); break; + case 13: util::stream_format(stream, "*AR%d--(IR0)", ar); break; + case 14: util::stream_format(stream, "*AR%d++(IR0)%%", ar); break; + case 15: util::stream_format(stream, "*AR%d--(IR0)%%", ar); break; - case 16: sprintf(dst, "*+AR%d(IR1)", ar); break; - case 17: sprintf(dst, "*-AR%d(IR1)", ar); break; - case 18: sprintf(dst, "*++AR%d(IR1)", ar); break; - case 19: sprintf(dst, "*--AR%d(IR1)", ar); break; - case 20: sprintf(dst, "*AR%d++(IR1)", ar); break; - case 21: sprintf(dst, "*AR%d--(IR1)", ar); break; - case 22: sprintf(dst, "*AR%d++(IR1)%%", ar); break; - case 23: sprintf(dst, "*AR%d--(IR1)%%", ar); break; + case 16: util::stream_format(stream, "*+AR%d(IR1)", ar); break; + case 17: util::stream_format(stream, "*-AR%d(IR1)", ar); break; + case 18: util::stream_format(stream, "*++AR%d(IR1)", ar); break; + case 19: util::stream_format(stream, "*--AR%d(IR1)", ar); break; + case 20: util::stream_format(stream, "*AR%d++(IR1)", ar); break; + case 21: util::stream_format(stream, "*AR%d--(IR1)", ar); break; + case 22: util::stream_format(stream, "*AR%d++(IR1)%%", ar); break; + case 23: util::stream_format(stream, "*AR%d--(IR1)%%", ar); break; - case 24: sprintf(dst, "*AR%d", ar); break; - case 25: sprintf(dst, "*AR%d++(IR0)B", ar); break; + case 24: util::stream_format(stream, "*AR%d", ar); break; + case 25: util::stream_format(stream, "*AR%d++(IR0)B", ar); break; case 28: case 29: case 30: - case 31: strcpy(dst, regname[ma & 31]); break; - default: sprintf(dst, "(unknown mode)"); break; + case 31: stream << regname[ma & 31]; break; + default: util::stream_format(stream, "(unknown mode)"); break; } } -static void append_immediate(uint16_t data, int is_float, int is_unsigned, char *buffer) +static std::string get_indirect(uint8_t ma, int8_t disp) { - char *dst = &buffer[strlen(buffer)]; + std::ostringstream stream; + append_indirect(ma, disp, stream); + return stream.str(); +} +static void append_immediate(uint16_t data, int is_float, int is_unsigned, std::ostream &stream) +{ if (is_float) { int exp = ((int16_t)data >> 12) + 127; @@ -192,22 +195,21 @@ static void append_immediate(uint16_t data, int is_float, int is_unsigned, char else expanded_data += ((-data & 0x0fff) << 12); float_val = *(float *)&expanded_data; - sprintf(dst, "%8f", (double) float_val); + util::stream_format(stream, "%8f", (double) float_val); } else if (!is_unsigned && (int16_t)data < 0) - sprintf(dst, "-$%04X", -data & 0xffff); + util::stream_format(stream, "-$%04X", -data & 0xffff); else - sprintf(dst, "$%04X", data); + util::stream_format(stream, "$%04X", data); } -static void disasm_general(const char *opstring, uint32_t op, int flags, char *buffer) +static void disasm_general(const char *opstring, uint32_t op, int flags, std::ostream &stream) { - sprintf(buffer, "%-6s", opstring); + util::stream_format(stream, "%-6s", opstring); if (flags & SWAPSRCDST) { - strcat(buffer, regname[(op >> 16) & 31]); - strcat(buffer, ","); + stream << regname[(op >> 16) & 31] << ','; } /* switch off of G */ @@ -216,19 +218,19 @@ static void disasm_general(const char *opstring, uint32_t op, int flags, char *b switch ((op >> 21) & 3) { case 0: - strcat(buffer, regname[op & 31]); + stream << regname[op & 31]; break; case 1: - sprintf(&buffer[strlen(buffer)], "($%04X)", op & 0xffff); + util::stream_format(stream, "($%04X)", op & 0xffff); break; case 2: - append_indirect((op >> 8) & 0xff, op, buffer); + append_indirect((op >> 8) & 0xff, op, stream); break; case 3: - append_immediate(op & 0xffff, (flags & FLOAT), (flags & UNSIGNED), buffer); + append_immediate(op & 0xffff, (flags & FLOAT), (flags & UNSIGNED), stream); break; } } @@ -237,14 +239,14 @@ static void disasm_general(const char *opstring, uint32_t op, int flags, char *b if (!(flags & NODEST) && !(flags & SWAPSRCDST)) { if (!(flags & NOSOURCE)) - strcat(buffer, ","); - strcat(buffer, regname[(op >> 16) & 31]); + stream << ','; + stream << regname[(op >> 16) & 31]; } } -static void disasm_3op(const char *opstring, uint32_t op, int flags, char *buffer) +static void disasm_3op(const char *opstring, uint32_t op, int flags, std::ostream &stream) { - sprintf(buffer, "%-6s", opstring); + util::stream_format(stream, "%-6s", opstring); /* switch off of T */ if (!(flags & NOSOURCE1)) @@ -252,11 +254,11 @@ static void disasm_3op(const char *opstring, uint32_t op, int flags, char *buffe switch ((op >> 21) & 1) { case 0: - strcat(buffer, regname[(op >> 8) & 31]); + stream << regname[(op >> 8) & 31]; break; case 1: - append_indirect(op >> 8, 1, buffer); + append_indirect(op >> 8, 1, stream); break; } } @@ -265,15 +267,15 @@ static void disasm_3op(const char *opstring, uint32_t op, int flags, char *buffe if (!(flags & NOSOURCE2)) { if (!(flags & NOSOURCE1)) - strcat(buffer, ","); + stream << ','; switch ((op >> 22) & 1) { case 0: - strcat(buffer, regname[op & 31]); + stream << regname[op & 31]; break; case 1: - append_indirect(op, 1, buffer); + append_indirect(op, 1, stream); break; } } @@ -282,189 +284,173 @@ static void disasm_3op(const char *opstring, uint32_t op, int flags, char *buffe if (!(flags & NODEST)) { if (!(flags & (NOSOURCE1 | NOSOURCE2))) - strcat(buffer, ","); - strcat(buffer, regname[(op >> 16) & 31]); + stream << ','; + stream << regname[(op >> 16) & 31]; } } -static void disasm_conditional(const char *opstring, uint32_t op, int flags, char *buffer) +static void disasm_conditional(const char *opstring, uint32_t op, int flags, std::ostream &stream) { char temp[10]; sprintf(temp, "%s%s", opstring, condition[(op >> 23) & 31]); - disasm_general(temp, op, flags, buffer); + disasm_general(temp, op, flags, stream); } -static void disasm_parallel_3op3op(const char *opstring1, const char *opstring2, uint32_t op, int flags, const uint8_t *srctable, char *buffer) +static void disasm_parallel_3op3op(const char *opstring1, const char *opstring2, uint32_t op, int flags, const uint8_t *srctable, std::ostream &stream) { const uint8_t *s = &srctable[((op >> 24) & 3) * 4]; int d1 = (op >> 23) & 1; int d2 = 2 + ((op >> 22) & 1); - char src[5][20]; + std::string src[5]; - strcpy(src[1], regname[(op >> 19) & 7]); - strcpy(src[2], regname[(op >> 16) & 7]); + src[1].assign(regname[(op >> 19) & 7]); + src[2].assign(regname[(op >> 16) & 7]); + src[3] = get_indirect(op >> 8, 1); + src[4] = get_indirect(op, 1); - src[3][0] = 0; - append_indirect(op >> 8, 1, src[3]); - - src[4][0] = 0; - append_indirect(op, 1, src[4]); - - sprintf(buffer, "%s %s,%s,R%d || %s %s,%s,R%d", + util::stream_format(stream, "%s %s,%s,R%d || %s %s,%s,R%d", opstring1, src[s[0]], src[s[1]], d1, opstring2, src[s[2]], src[s[3]], d2); } -static void disasm_parallel_3opstore(const char *opstring1, const char *opstring2, uint32_t op, int flags, char *buffer) +static void disasm_parallel_3opstore(const char *opstring1, const char *opstring2, uint32_t op, int flags, std::ostream &stream) { int d1 = (op >> 22) & 7; int s1 = (op >> 19) & 7; int s3 = (op >> 16) & 7; - char dst2[20], src2[20]; - dst2[0] = 0; - append_indirect(op >> 8, 1, dst2); - - src2[0] = 0; - append_indirect(op, 1, src2); + std::string dst2 = get_indirect(op >> 8, 1); + std::string src2 = get_indirect(op, 1); if (!(flags & NOSOURCE1)) - sprintf(buffer, "%s R%d,%s,R%d || %s R%d,%s", + util::stream_format(stream, "%s R%d,%s,R%d || %s R%d,%s", opstring1, s1, src2, d1, opstring2, s3, dst2); else - sprintf(buffer, "%s %s,R%d || %s R%d,%s", + util::stream_format(stream, "%s %s,R%d || %s R%d,%s", opstring1, src2, d1, opstring2, s3, dst2); } -static void disasm_parallel_loadload(const char *opstring1, const char *opstring2, uint32_t op, int flags, char *buffer) +static void disasm_parallel_loadload(const char *opstring1, const char *opstring2, uint32_t op, int flags, std::ostream &stream) { int d2 = (op >> 22) & 7; int d1 = (op >> 19) & 7; - char src1[20], src2[20]; - src1[0] = 0; - append_indirect(op >> 8, 1, src1); + std::string src1 = get_indirect(op >> 8, 1); + std::string src2 = get_indirect(op >> 0, 1); - src2[0] = 0; - append_indirect(op, 1, src2); - - sprintf(buffer, "%s %s,R%d || %s %s,R%d", + util::stream_format(stream, "%s %s,R%d || %s %s,R%d", opstring1, src2, d2, opstring2, src1, d1); } -static void disasm_parallel_storestore(const char *opstring1, const char *opstring2, uint32_t op, int flags, char *buffer) +static void disasm_parallel_storestore(const char *opstring1, const char *opstring2, uint32_t op, int flags, std::ostream &stream) { int s2 = (op >> 22) & 7; int s1 = (op >> 16) & 7; - char dst1[20], dst2[20]; - dst1[0] = 0; - append_indirect(op >> 8, 1, dst1); + std::string dst1 = get_indirect(op >> 8, 1); + std::string dst2 = get_indirect(op, 1); - dst2[0] = 0; - append_indirect(op, 1, dst2); - - sprintf(buffer, "%s R%d,%s || %s R%d,%s", + util::stream_format(stream, "%s R%d,%s || %s R%d,%s", opstring1, s2, dst2, opstring2, s1, dst1); } -static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) +static unsigned dasm_tms3203x(std::ostream &stream, unsigned pc, uint32_t op) { uint32_t flags = 0; switch (op >> 23) { - case 0x000: disasm_general("ABSF", op, FLOAT, buffer); break; - case 0x001: disasm_general("ABSI", op, INTEGER, buffer); break; - case 0x002: disasm_general("ADDC", op, INTEGER, buffer); break; - case 0x003: disasm_general("ADDF", op, FLOAT, buffer); break; - case 0x004: disasm_general("ADDI", op, INTEGER, buffer); break; - case 0x005: disasm_general("AND", op, INTEGER | UNSIGNED, buffer); break; - case 0x006: disasm_general("ANDN", op, INTEGER | UNSIGNED, buffer); break; - case 0x007: disasm_general("ASH", op, INTEGER, buffer); break; + case 0x000: disasm_general("ABSF", op, FLOAT, stream); break; + case 0x001: disasm_general("ABSI", op, INTEGER, stream); break; + case 0x002: disasm_general("ADDC", op, INTEGER, stream); break; + case 0x003: disasm_general("ADDF", op, FLOAT, stream); break; + case 0x004: disasm_general("ADDI", op, INTEGER, stream); break; + case 0x005: disasm_general("AND", op, INTEGER | UNSIGNED, stream); break; + case 0x006: disasm_general("ANDN", op, INTEGER | UNSIGNED, stream); break; + case 0x007: disasm_general("ASH", op, INTEGER, stream); break; - case 0x008: disasm_general("CMPF", op, FLOAT, buffer); break; - case 0x009: disasm_general("CMPI", op, INTEGER, buffer); break; - case 0x00a: disasm_general("FIX", op, FLOAT, buffer); break; - case 0x00b: disasm_general("FLOAT", op, INTEGER, buffer); break; - case 0x00c: disasm_general((op & 1) ? "IDLE2" : "IDLE", op, NOSOURCE | NODEST, buffer); break; - case 0x00d: disasm_general("LDE", op, FLOAT, buffer); break; - case 0x00e: disasm_general("LDF", op, FLOAT, buffer); break; - case 0x00f: disasm_general("LDFI", op, FLOAT, buffer); break; + case 0x008: disasm_general("CMPF", op, FLOAT, stream); break; + case 0x009: disasm_general("CMPI", op, INTEGER, stream); break; + case 0x00a: disasm_general("FIX", op, FLOAT, stream); break; + case 0x00b: disasm_general("FLOAT", op, INTEGER, stream); break; + case 0x00c: disasm_general((op & 1) ? "IDLE2" : "IDLE", op, NOSOURCE | NODEST, stream); break; + case 0x00d: disasm_general("LDE", op, FLOAT, stream); break; + case 0x00e: disasm_general("LDF", op, FLOAT, stream); break; + case 0x00f: disasm_general("LDFI", op, FLOAT, stream); break; - case 0x010: disasm_general("LDI", op, INTEGER, buffer); break; - case 0x011: disasm_general("LDII", op, INTEGER, buffer); break; - case 0x012: disasm_general("LDM", op, FLOAT, buffer); break; - case 0x013: disasm_general("LSH", op, INTEGER, buffer); break; - case 0x014: disasm_general("MPYF", op, FLOAT, buffer); break; - case 0x015: disasm_general("MPYI", op, INTEGER, buffer); break; - case 0x016: disasm_general("NEGB", op, INTEGER, buffer); break; - case 0x017: disasm_general("NEGF", op, FLOAT, buffer); break; + case 0x010: disasm_general("LDI", op, INTEGER, stream); break; + case 0x011: disasm_general("LDII", op, INTEGER, stream); break; + case 0x012: disasm_general("LDM", op, FLOAT, stream); break; + case 0x013: disasm_general("LSH", op, INTEGER, stream); break; + case 0x014: disasm_general("MPYF", op, FLOAT, stream); break; + case 0x015: disasm_general("MPYI", op, INTEGER, stream); break; + case 0x016: disasm_general("NEGB", op, INTEGER, stream); break; + case 0x017: disasm_general("NEGF", op, FLOAT, stream); break; - case 0x018: disasm_general("NEGI", op, INTEGER, buffer); break; - case 0x019: disasm_general("NOP", op, NODEST, buffer); break; - case 0x01a: disasm_general("NORM", op, FLOAT, buffer); break; - case 0x01b: disasm_general("NOT", op, INTEGER, buffer); break; - case 0x01c: disasm_general("POP", op, NOSOURCE, buffer); break; - case 0x01d: disasm_general("POPF", op, NOSOURCE, buffer); break; - case 0x01e: disasm_general("PUSH", op, NOSOURCE, buffer); break; - case 0x01f: disasm_general("PUSHF", op, NOSOURCE, buffer); break; + case 0x018: disasm_general("NEGI", op, INTEGER, stream); break; + case 0x019: disasm_general("NOP", op, NODEST, stream); break; + case 0x01a: disasm_general("NORM", op, FLOAT, stream); break; + case 0x01b: disasm_general("NOT", op, INTEGER, stream); break; + case 0x01c: disasm_general("POP", op, NOSOURCE, stream); break; + case 0x01d: disasm_general("POPF", op, NOSOURCE, stream); break; + case 0x01e: disasm_general("PUSH", op, NOSOURCE, stream); break; + case 0x01f: disasm_general("PUSHF", op, NOSOURCE, stream); break; - case 0x020: disasm_general("OR", op, INTEGER | UNSIGNED, buffer); break; - case 0x021: disasm_general((op & 1) ? "LOPOWER" : "MAXSPEED", op, NOSOURCE | NODEST, buffer); break; - case 0x022: disasm_general("RND", op, FLOAT, buffer); break; - case 0x023: disasm_general("ROL", op, INTEGER, buffer); break; - case 0x024: disasm_general("ROLC", op, INTEGER, buffer); break; - case 0x025: disasm_general("ROR", op, INTEGER, buffer); break; - case 0x026: disasm_general("RORC", op, INTEGER, buffer); break; - case 0x027: disasm_general("RTPS", op, INTEGER | NODEST, buffer); break; + case 0x020: disasm_general("OR", op, INTEGER | UNSIGNED, stream); break; + case 0x021: disasm_general((op & 1) ? "LOPOWER" : "MAXSPEED", op, NOSOURCE | NODEST, stream); break; + case 0x022: disasm_general("RND", op, FLOAT, stream); break; + case 0x023: disasm_general("ROL", op, INTEGER, stream); break; + case 0x024: disasm_general("ROLC", op, INTEGER, stream); break; + case 0x025: disasm_general("ROR", op, INTEGER, stream); break; + case 0x026: disasm_general("RORC", op, INTEGER, stream); break; + case 0x027: disasm_general("RTPS", op, INTEGER | NODEST, stream); break; - case 0x028: disasm_general("STF", op, FLOAT | SWAPSRCDST, buffer); break; - case 0x029: disasm_general("STFI", op, FLOAT | SWAPSRCDST, buffer); break; - case 0x02a: disasm_general("STI", op, INTEGER | SWAPSRCDST, buffer); break; - case 0x02b: disasm_general("STII", op, INTEGER | SWAPSRCDST, buffer); break; - case 0x02c: disasm_general("SIGI", op, NOSOURCE | NODEST, buffer); break; - case 0x02d: disasm_general("SUBB", op, INTEGER, buffer); break; - case 0x02e: disasm_general("SUBC", op, INTEGER, buffer); break; - case 0x02f: disasm_general("SUBF", op, FLOAT, buffer); break; + case 0x028: disasm_general("STF", op, FLOAT | SWAPSRCDST, stream); break; + case 0x029: disasm_general("STFI", op, FLOAT | SWAPSRCDST, stream); break; + case 0x02a: disasm_general("STI", op, INTEGER | SWAPSRCDST, stream); break; + case 0x02b: disasm_general("STII", op, INTEGER | SWAPSRCDST, stream); break; + case 0x02c: disasm_general("SIGI", op, NOSOURCE | NODEST, stream); break; + case 0x02d: disasm_general("SUBB", op, INTEGER, stream); break; + case 0x02e: disasm_general("SUBC", op, INTEGER, stream); break; + case 0x02f: disasm_general("SUBF", op, FLOAT, stream); break; - case 0x030: disasm_general("SUBI", op, INTEGER, buffer); break; - case 0x031: disasm_general("SUBRB", op, INTEGER, buffer); break; - case 0x032: disasm_general("SUBRF", op, FLOAT, buffer); break; - case 0x033: disasm_general("SUBRI", op, INTEGER, buffer); break; - case 0x034: disasm_general("TSTB", op, INTEGER, buffer); break; - case 0x035: disasm_general("XOR", op, INTEGER | UNSIGNED, buffer); break; - case 0x036: disasm_general("IACK", op, INTEGER | NODEST, buffer); break; + case 0x030: disasm_general("SUBI", op, INTEGER, stream); break; + case 0x031: disasm_general("SUBRB", op, INTEGER, stream); break; + case 0x032: disasm_general("SUBRF", op, FLOAT, stream); break; + case 0x033: disasm_general("SUBRI", op, INTEGER, stream); break; + case 0x034: disasm_general("TSTB", op, INTEGER, stream); break; + case 0x035: disasm_general("XOR", op, INTEGER | UNSIGNED, stream); break; + case 0x036: disasm_general("IACK", op, INTEGER | NODEST, stream); break; - case 0x040: disasm_3op("ADDC3", op, INTEGER, buffer); break; - case 0x041: disasm_3op("ADDF3", op, FLOAT, buffer); break; - case 0x042: disasm_3op("ADDI3", op, INTEGER, buffer); break; - case 0x043: disasm_3op("AND3", op, INTEGER, buffer); break; - case 0x044: disasm_3op("ANDN3", op, INTEGER, buffer); break; - case 0x045: disasm_3op("ASH3", op, INTEGER, buffer); break; - case 0x046: disasm_3op("CMPF3", op, FLOAT | NODEST, buffer); break; - case 0x047: disasm_3op("CMPI3", op, INTEGER | NODEST, buffer); break; + case 0x040: disasm_3op("ADDC3", op, INTEGER, stream); break; + case 0x041: disasm_3op("ADDF3", op, FLOAT, stream); break; + case 0x042: disasm_3op("ADDI3", op, INTEGER, stream); break; + case 0x043: disasm_3op("AND3", op, INTEGER, stream); break; + case 0x044: disasm_3op("ANDN3", op, INTEGER, stream); break; + case 0x045: disasm_3op("ASH3", op, INTEGER, stream); break; + case 0x046: disasm_3op("CMPF3", op, FLOAT | NODEST, stream); break; + case 0x047: disasm_3op("CMPI3", op, INTEGER | NODEST, stream); break; - case 0x048: disasm_3op("LSH3", op, INTEGER, buffer); break; - case 0x049: disasm_3op("MPYF3", op, FLOAT, buffer); break; - case 0x04a: disasm_3op("MPYI3", op, INTEGER, buffer); break; - case 0x04b: disasm_3op("OR3", op, INTEGER, buffer); break; - case 0x04c: disasm_3op("SUBB3", op, INTEGER, buffer); break; - case 0x04d: disasm_3op("SUBF3", op, FLOAT, buffer); break; - case 0x04e: disasm_3op("SUBI3", op, INTEGER, buffer); break; - case 0x04f: disasm_3op("TSTB3", op, INTEGER, buffer); break; + case 0x048: disasm_3op("LSH3", op, INTEGER, stream); break; + case 0x049: disasm_3op("MPYF3", op, FLOAT, stream); break; + case 0x04a: disasm_3op("MPYI3", op, INTEGER, stream); break; + case 0x04b: disasm_3op("OR3", op, INTEGER, stream); break; + case 0x04c: disasm_3op("SUBB3", op, INTEGER, stream); break; + case 0x04d: disasm_3op("SUBF3", op, FLOAT, stream); break; + case 0x04e: disasm_3op("SUBI3", op, INTEGER, stream); break; + case 0x04f: disasm_3op("TSTB3", op, INTEGER, stream); break; - case 0x050: disasm_3op("XOR3", op, INTEGER, buffer); break; + case 0x050: disasm_3op("XOR3", op, INTEGER, stream); break; case 0x080: case 0x081: case 0x082: case 0x083: case 0x084: case 0x085: case 0x086: case 0x087: @@ -474,7 +460,7 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) case 0x094: case 0x095: case 0x096: case 0x097: case 0x098: case 0x099: case 0x09a: case 0x09b: case 0x09c: case 0x09d: case 0x09e: case 0x09f: - disasm_conditional("LDF", op, FLOAT, buffer); + disasm_conditional("LDF", op, FLOAT, stream); break; case 0x0a0: case 0x0a1: case 0x0a2: case 0x0a3: @@ -485,30 +471,30 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) case 0x0b4: case 0x0b5: case 0x0b6: case 0x0b7: case 0x0b8: case 0x0b9: case 0x0ba: case 0x0bb: case 0x0bc: case 0x0bd: case 0x0be: case 0x0bf: - disasm_conditional("LDI", op, INTEGER, buffer); + disasm_conditional("LDI", op, INTEGER, stream); break; case 0x0c0: case 0x0c1: - sprintf(buffer, "BR $%06X", op & 0xffffff); + util::stream_format(stream, "BR $%06X", op & 0xffffff); break; case 0x0c2: case 0x0c3: - sprintf(buffer, "BRD $%06X", op & 0xffffff); + util::stream_format(stream, "BRD $%06X", op & 0xffffff); break; case 0x0c4: case 0x0c5: - sprintf(buffer, "CALL $%06X", op & 0xffffff); + util::stream_format(stream, "CALL $%06X", op & 0xffffff); flags = DASMFLAG_STEP_OVER; break; case 0x0c8: case 0x0c9: - sprintf(buffer, "RPTB $%06X", op & 0xffffff); + util::stream_format(stream, "RPTB $%06X", op & 0xffffff); break; case 0x0cc: case 0x0cd: case 0x0ce: case 0x0cf: - sprintf(buffer, "SWI"); + util::stream_format(stream, "SWI"); break; @@ -516,7 +502,7 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) { char temp[10]; sprintf(temp, "B%s%s", condition[(op >> 16) & 31], ((op >> 21) & 1) ? "D" : ""); - sprintf(buffer, "%-6s%s", temp, regname[op & 31]); + util::stream_format(stream, "%-6s%s", temp, regname[op & 31]); break; } @@ -524,7 +510,7 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) { char temp[10]; sprintf(temp, "B%s%s", condition[(op >> 16) & 31], ((op >> 21) & 1) ? "D" : ""); - sprintf(buffer, "%-6s$%06X", temp, (pc + (((op >> 21) & 1) ? 3 : 1) + (int16_t)op) & 0xffffff); + util::stream_format(stream, "%-6s$%06X", temp, (pc + (((op >> 21) & 1) ? 3 : 1) + (int16_t)op) & 0xffffff); break; } @@ -533,7 +519,7 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) { char temp[10]; sprintf(temp, "DB%s%s", condition[(op >> 16) & 31], ((op >> 21) & 1) ? "D" : ""); - sprintf(buffer, "%-6sAR%d,%s", temp, (op >> 22) & 7, regname[op & 31]); + util::stream_format(stream, "%-6sAR%d,%s", temp, (op >> 22) & 7, regname[op & 31]); break; } @@ -541,7 +527,7 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) { char temp[10]; sprintf(temp, "DB%s%s", condition[(op >> 16) & 31], ((op >> 21) & 1) ? "D" : ""); - sprintf(buffer, "%-6sAR%d,$%06X", temp, (op >> 22) & 7, (pc + (((op >> 21) & 1) ? 3 : 1) + (int16_t)op) & 0xffffff); + util::stream_format(stream, "%-6sAR%d,$%06X", temp, (op >> 22) & 7, (pc + (((op >> 21) & 1) ? 3 : 1) + (int16_t)op) & 0xffffff); break; } @@ -550,7 +536,7 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) { char temp[10]; sprintf(temp, "CALL%s", condition[(op >> 16) & 31]); - sprintf(buffer, "%-6s%s", temp, regname[op & 31]); + util::stream_format(stream, "%-6s%s", temp, regname[op & 31]); flags = DASMFLAG_STEP_OVER; break; } @@ -559,7 +545,7 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) { char temp[10]; sprintf(temp, "CALL%s", condition[(op >> 16) & 31]); - sprintf(buffer, "%-6s$%06X", temp, (pc + 1 + (int16_t)op) & 0xffffff); + util::stream_format(stream, "%-6s$%06X", temp, (pc + 1 + (int16_t)op) & 0xffffff); flags = DASMFLAG_STEP_OVER; break; } @@ -569,19 +555,19 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) { char temp[10]; sprintf(temp, "TRAP%s", condition[(op >> 16) & 31]); - sprintf(buffer, "%-6s$%02X", temp, op & 31); + util::stream_format(stream, "%-6s$%02X", temp, op & 31); flags = DASMFLAG_STEP_OVER; break; } case 0x0f0: - sprintf(buffer, "RETI%s", condition[(op >> 16) & 31]); + util::stream_format(stream, "RETI%s", condition[(op >> 16) & 31]); flags = DASMFLAG_STEP_OUT; break; case 0x0f1: - sprintf(buffer, "RETS%s", condition[(op >> 16) & 31]); + util::stream_format(stream, "RETS%s", condition[(op >> 16) & 31]); flags = DASMFLAG_STEP_OUT; break; @@ -590,7 +576,7 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) case 0x104: case 0x105: case 0x106: case 0x107: // MPYF3||ADDF3 { static const uint8_t srctable[] = { 3,4,1,2, 3,1,4,2, 1,2,3,4, 3,1,2,4 }; - disasm_parallel_3op3op("MPYF3", "ADDF3", op, FLOAT, srctable, buffer); + disasm_parallel_3op3op("MPYF3", "ADDF3", op, FLOAT, srctable, stream); break; } @@ -599,7 +585,7 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) case 0x10c: case 0x10d: case 0x10e: case 0x10f: // MPYF3||SUBF3 { static const uint8_t srctable[] = { 3,4,1,2, 3,1,4,2, 1,2,3,4, 3,1,2,4 }; - disasm_parallel_3op3op("MPYF3", "SUBF3", op, FLOAT, srctable, buffer); + disasm_parallel_3op3op("MPYF3", "SUBF3", op, FLOAT, srctable, stream); break; } @@ -608,7 +594,7 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) case 0x114: case 0x115: case 0x116: case 0x117: // MPYI3||ADDI3 { static const uint8_t srctable[] = { 3,4,1,2, 3,1,4,2, 1,2,3,4, 3,1,2,4 }; - disasm_parallel_3op3op("MPYI3", "ADDI3", op, INTEGER, srctable, buffer); + disasm_parallel_3op3op("MPYI3", "ADDI3", op, INTEGER, srctable, stream); break; } @@ -617,116 +603,116 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) case 0x11c: case 0x11d: case 0x11e: case 0x11f: // MPYI3||SUBI3 { static const uint8_t srctable[] = { 3,4,1,2, 3,1,4,2, 1,2,3,4, 3,1,2,4 }; - disasm_parallel_3op3op("MPYI3", "SUBI3", op, INTEGER, srctable, buffer); + disasm_parallel_3op3op("MPYI3", "SUBI3", op, INTEGER, srctable, stream); break; } case 0x180: case 0x181: case 0x182: case 0x183: // STF||STF - disasm_parallel_storestore("STF", "STF", op, FLOAT, buffer); + disasm_parallel_storestore("STF", "STF", op, FLOAT, stream); break; case 0x184: case 0x185: case 0x186: case 0x187: // STI||STI - disasm_parallel_storestore("STI", "STI", op, INTEGER, buffer); + disasm_parallel_storestore("STI", "STI", op, INTEGER, stream); break; case 0x188: case 0x189: case 0x18a: case 0x18b: // LDF||LDF - disasm_parallel_loadload("LDF", "LDF", op, FLOAT, buffer); + disasm_parallel_loadload("LDF", "LDF", op, FLOAT, stream); break; case 0x18c: case 0x18d: case 0x18e: case 0x18f: // LDI||LDI - disasm_parallel_loadload("LDI", "LDI", op, INTEGER, buffer); + disasm_parallel_loadload("LDI", "LDI", op, INTEGER, stream); break; case 0x190: case 0x191: case 0x192: case 0x193: // ABSF||STF - disasm_parallel_3opstore("ABSF", "STF", op, FLOAT | NOSOURCE1, buffer); + disasm_parallel_3opstore("ABSF", "STF", op, FLOAT | NOSOURCE1, stream); break; case 0x194: case 0x195: case 0x196: case 0x197: // ABSI||STI - disasm_parallel_3opstore("ABSI", "STI", op, INTEGER | NOSOURCE1, buffer); + disasm_parallel_3opstore("ABSI", "STI", op, INTEGER | NOSOURCE1, stream); break; case 0x198: case 0x199: case 0x19a: case 0x19b: // ADDF3||STF - disasm_parallel_3opstore("ADDF3", "STF", op, FLOAT, buffer); + disasm_parallel_3opstore("ADDF3", "STF", op, FLOAT, stream); break; case 0x19c: case 0x19d: case 0x19e: case 0x19f: // ADDI3||STI - disasm_parallel_3opstore("ADDI3", "STI", op, INTEGER, buffer); + disasm_parallel_3opstore("ADDI3", "STI", op, INTEGER, stream); break; case 0x1a0: case 0x1a1: case 0x1a2: case 0x1a3: // AND3||STI - disasm_parallel_3opstore("AND3", "STI", op, INTEGER, buffer); + disasm_parallel_3opstore("AND3", "STI", op, INTEGER, stream); break; case 0x1a4: case 0x1a5: case 0x1a6: case 0x1a7: // ASH3||STI - disasm_parallel_3opstore("ASH3", "STI", op, INTEGER, buffer); + disasm_parallel_3opstore("ASH3", "STI", op, INTEGER, stream); break; case 0x1a8: case 0x1a9: case 0x1aa: case 0x1ab: // FIX||STI - disasm_parallel_3opstore("FIX", "STF", op, FLOAT | NOSOURCE1, buffer); + disasm_parallel_3opstore("FIX", "STF", op, FLOAT | NOSOURCE1, stream); break; case 0x1ac: case 0x1ad: case 0x1ae: case 0x1af: // FLOAT||STF - disasm_parallel_3opstore("FLOAT", "STF", op, FLOAT | NOSOURCE1, buffer); + disasm_parallel_3opstore("FLOAT", "STF", op, FLOAT | NOSOURCE1, stream); break; case 0x1b0: case 0x1b1: case 0x1b2: case 0x1b3: // LDF||STF - disasm_parallel_3opstore("LDF", "STF", op, FLOAT | NOSOURCE1, buffer); + disasm_parallel_3opstore("LDF", "STF", op, FLOAT | NOSOURCE1, stream); break; case 0x1b4: case 0x1b5: case 0x1b6: case 0x1b7: // LDI||STI - disasm_parallel_3opstore("LDI", "STI", op, INTEGER | NOSOURCE1, buffer); + disasm_parallel_3opstore("LDI", "STI", op, INTEGER | NOSOURCE1, stream); break; case 0x1b8: case 0x1b9: case 0x1ba: case 0x1bb: // LSH3||STI - disasm_parallel_3opstore("LSH3", "STI", op, INTEGER, buffer); + disasm_parallel_3opstore("LSH3", "STI", op, INTEGER, stream); break; case 0x1bc: case 0x1bd: case 0x1be: case 0x1bf: // MPYF3||STF - disasm_parallel_3opstore("MPYF3", "STF", op, FLOAT, buffer); + disasm_parallel_3opstore("MPYF3", "STF", op, FLOAT, stream); break; case 0x1c0: case 0x1c1: case 0x1c2: case 0x1c3: // MPYI3||STI - disasm_parallel_3opstore("MPYI3", "STI", op, INTEGER, buffer); + disasm_parallel_3opstore("MPYI3", "STI", op, INTEGER, stream); break; case 0x1c4: case 0x1c5: case 0x1c6: case 0x1c7: // NEGF||STF - disasm_parallel_3opstore("NEGF", "STF", op, FLOAT | NOSOURCE1, buffer); + disasm_parallel_3opstore("NEGF", "STF", op, FLOAT | NOSOURCE1, stream); break; case 0x1c8: case 0x1c9: case 0x1ca: case 0x1cb: // NEGI||STI - disasm_parallel_3opstore("NEGI", "STI", op, INTEGER | NOSOURCE1, buffer); + disasm_parallel_3opstore("NEGI", "STI", op, INTEGER | NOSOURCE1, stream); break; case 0x1cc: case 0x1cd: case 0x1ce: case 0x1cf: // NOT||STI - disasm_parallel_3opstore("NOT", "STI", op, INTEGER | NOSOURCE1, buffer); + disasm_parallel_3opstore("NOT", "STI", op, INTEGER | NOSOURCE1, stream); break; case 0x1d0: case 0x1d1: case 0x1d2: case 0x1d3: // OR3||STI - disasm_parallel_3opstore("OR3", "STI", op, INTEGER, buffer); + disasm_parallel_3opstore("OR3", "STI", op, INTEGER, stream); break; case 0x1d4: case 0x1d5: case 0x1d6: case 0x1d7: // SUBF3||STF - disasm_parallel_3opstore("SUBF3", "STF", op, FLOAT, buffer); + disasm_parallel_3opstore("SUBF3", "STF", op, FLOAT, stream); break; case 0x1d8: case 0x1d9: case 0x1da: case 0x1db: // SUBI3||STI - disasm_parallel_3opstore("SUBI3", "STI", op, INTEGER, buffer); + disasm_parallel_3opstore("SUBI3", "STI", op, INTEGER, stream); break; case 0x1dc: case 0x1dd: case 0x1de: case 0x1df: // XOR3||STI - disasm_parallel_3opstore("XOR3", "STI", op, INTEGER, buffer); + disasm_parallel_3opstore("XOR3", "STI", op, INTEGER, stream); break; @@ -741,5 +727,5 @@ static unsigned dasm_tms3203x(char *buffer, unsigned pc, uint32_t op) CPU_DISASSEMBLE( tms3203x ) { uint32_t op = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24); - return dasm_tms3203x(buffer, pc, op); + return dasm_tms3203x(stream, pc, op); } diff --git a/src/devices/cpu/tms32031/tms32031.cpp b/src/devices/cpu/tms32031/tms32031.cpp index 06c50c7777a..6f957b685f5 100644 --- a/src/devices/cpu/tms32031/tms32031.cpp +++ b/src/devices/cpu/tms32031/tms32031.cpp @@ -589,10 +589,10 @@ uint32_t tms3203x_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t tms3203x_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms3203x_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms3203x ); - return CPU_DISASSEMBLE_NAME(tms3203x)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms3203x)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms32031/tms32031.h b/src/devices/cpu/tms32031/tms32031.h index 4c554827cf4..acb7f5a3020 100644 --- a/src/devices/cpu/tms32031/tms32031.h +++ b/src/devices/cpu/tms32031/tms32031.h @@ -184,7 +184,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // memory helpers DECLARE_DIRECT_UPDATE_MEMBER(direct_handler); diff --git a/src/devices/cpu/tms32051/dis32051.cpp b/src/devices/cpu/tms32051/dis32051.cpp index 6fda434ab36..b963781beeb 100644 --- a/src/devices/cpu/tms32051/dis32051.cpp +++ b/src/devices/cpu/tms32051/dis32051.cpp @@ -273,7 +273,7 @@ static void dasm_group_bf(uint16_t opcode) } } -static offs_t internal_disasm_tms32051(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(tms32051) { uint32_t flags = 0; uint16_t opcode; @@ -583,13 +583,3 @@ static offs_t internal_disasm_tms32051(cpu_device *device, std::ostream &stream, return (npc-pc) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(tms32051) -{ - std::ostringstream stream; - offs_t result = internal_disasm_tms32051(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/tms32051/tms32051.cpp b/src/devices/cpu/tms32051/tms32051.cpp index 9707b5d6270..816af6dd2e2 100644 --- a/src/devices/cpu/tms32051/tms32051.cpp +++ b/src/devices/cpu/tms32051/tms32051.cpp @@ -112,10 +112,10 @@ tms32053_device::tms32053_device(const machine_config &mconfig, const char *tag, } -offs_t tms32051_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms32051_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms32051 ); - return CPU_DISASSEMBLE_NAME(tms32051)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms32051)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms32051/tms32051.h b/src/devices/cpu/tms32051/tms32051.h index f025db4246f..d276ca79101 100644 --- a/src/devices/cpu/tms32051/tms32051.h +++ b/src/devices/cpu/tms32051/tms32051.h @@ -82,7 +82,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; address_space_config m_data_config; diff --git a/src/devices/cpu/tms32082/dis_mp.cpp b/src/devices/cpu/tms32082/dis_mp.cpp index de5ccdc06f2..0bb6e45d2c5 100644 --- a/src/devices/cpu/tms32082/dis_mp.cpp +++ b/src/devices/cpu/tms32082/dis_mp.cpp @@ -505,16 +505,7 @@ static offs_t tms32082_disasm_mp(std::ostream &stream, offs_t pc, const uint8_t return opbytes | flags | DASMFLAG_SUPPORTED; } -static offs_t tms32082_disasm_mp(char *buffer, offs_t pc, const uint8_t *oprom) -{ - std::ostringstream stream; - offs_t result = tms32082_disasm_mp(stream, pc, oprom); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE(tms32082_mp) { - return tms32082_disasm_mp(buffer, pc, oprom); + return tms32082_disasm_mp(stream, pc, oprom); } diff --git a/src/devices/cpu/tms32082/dis_pp.cpp b/src/devices/cpu/tms32082/dis_pp.cpp index b32b681df3a..b685ab54b4f 100644 --- a/src/devices/cpu/tms32082/dis_pp.cpp +++ b/src/devices/cpu/tms32082/dis_pp.cpp @@ -435,10 +435,10 @@ static offs_t tms32082_disasm_pp(std::ostream &stream, offs_t pc, const uint8_t case 0xe: case 0xf: { - if ((op & U64(0xfaa8100000000000)) == U64(0x8800000000000000)) + if ((op & 0xfaa8100000000000U) == 0x8800000000000000U) { int operation = (op >> 39) & 0x1f; - uint64_t parallel_xfer = (op & U64(0x0000007fffffffff)); + uint64_t parallel_xfer = (op & 0x0000007fffffffffU); switch (operation) { @@ -462,7 +462,7 @@ static offs_t tms32082_disasm_pp(std::ostream &stream, offs_t pc, const uint8_t case 0: case 1: // Base set ALU (5-bit immediate) { - uint64_t parallel_xfer = (op & U64(0x0000007fffffffff)); + uint64_t parallel_xfer = (op & 0x0000007fffffffffU); int dst = (op >> 48) & 7; int src1 = (op >> 45) & 7; @@ -541,7 +541,7 @@ static offs_t tms32082_disasm_pp(std::ostream &stream, offs_t pc, const uint8_t case 2: // Base set ALU (reg src2) { - uint64_t parallel_xfer = (op & U64(0x0000007fffffffff)); + uint64_t parallel_xfer = (op & 0x0000007fffffffffU); int dst = (op >> 48) & 7; int src1 = (op >> 45) & 7; @@ -698,16 +698,7 @@ static offs_t tms32082_disasm_pp(std::ostream &stream, offs_t pc, const uint8_t return 8 | flags | DASMFLAG_SUPPORTED; } -static offs_t tms32082_disasm_pp(char *buffer, offs_t pc, const uint8_t *oprom) -{ - std::ostringstream stream; - offs_t result = tms32082_disasm_pp(stream, pc, oprom); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} - CPU_DISASSEMBLE(tms32082_pp) { - return tms32082_disasm_pp(buffer, pc, oprom); + return tms32082_disasm_pp(stream, pc, oprom); } diff --git a/src/devices/cpu/tms32082/tms32082.cpp b/src/devices/cpu/tms32082/tms32082.cpp index a505a6a2045..1540fdc03a2 100644 --- a/src/devices/cpu/tms32082/tms32082.cpp +++ b/src/devices/cpu/tms32082/tms32082.cpp @@ -51,9 +51,9 @@ tms32082_mp_device::tms32082_mp_device(const machine_config &mconfig, const char } -offs_t tms32082_mp_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms32082_mp_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return CPU_DISASSEMBLE_NAME(tms32082_mp)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms32082_mp)(this, stream, pc, oprom, opram, options); } @@ -489,9 +489,9 @@ tms32082_pp_device::tms32082_pp_device(const machine_config &mconfig, const char } -offs_t tms32082_pp_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms32082_pp_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { - return CPU_DISASSEMBLE_NAME(tms32082_pp)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms32082_pp)(this, stream, pc, oprom, opram, options); } void tms32082_pp_device::device_start() diff --git a/src/devices/cpu/tms32082/tms32082.h b/src/devices/cpu/tms32082/tms32082.h index 0a315d6b79d..9ddf8c6ac00 100644 --- a/src/devices/cpu/tms32082/tms32082.h +++ b/src/devices/cpu/tms32082/tms32082.h @@ -102,7 +102,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 4; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; @@ -197,7 +197,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 8; } virtual uint32_t disasm_max_opcode_bytes() const override { return 8; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; diff --git a/src/devices/cpu/tms34010/34010dsm.cpp b/src/devices/cpu/tms34010/34010dsm.cpp index 70fbabc58db..56fcc3100c0 100644 --- a/src/devices/cpu/tms34010/34010dsm.cpp +++ b/src/devices/cpu/tms34010/34010dsm.cpp @@ -25,116 +25,104 @@ static uint8_t rf; static uint32_t __pc, _pc; static uint16_t op,rs,rd; -static char *buffer; -static char temp[20]; - static const uint8_t *rombase; static const uint8_t *rambase; static offs_t pcbase; -static void print_reg(uint8_t reg) +static void print_reg(std::ostream &stream, uint8_t reg) { if (reg != 0x0f) { - sprintf(temp, "%c%d", rf, reg); - strcat(buffer, temp); + util::stream_format(stream, "%c%d", rf, reg); } else { - strcat(buffer, "SP"); + stream << "SP"; } } -static void print_src_reg(void) +static void print_src_reg(std::ostream &stream) { - print_reg(rs); + print_reg(stream, rs); } -static void print_des_reg(void) +static void print_des_reg(std::ostream &stream) { - print_reg(rd); + print_reg(stream, rd); } -static void print_src_des_reg(void) +static void print_src_des_reg(std::ostream &stream) { - print_src_reg(); - strcat(buffer, ","); - print_des_reg(); + print_src_reg(stream); + stream << ","; + print_des_reg(stream); } -static void print_word_parm(void) +static void print_word_parm(std::ostream &stream) { uint16_t w; PARAM_WORD(w); - sprintf(temp, "%Xh", w); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", w); } -static void print_word_parm_1s_comp(void) +static void print_word_parm_1s_comp(std::ostream &stream) { uint16_t w; PARAM_WORD(w); w = ~w; - sprintf(temp, "%Xh", w); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", w); } -static void print_long_parm(void) +static void print_long_parm(std::ostream &stream) { uint32_t l; PARAM_LONG(l); - sprintf(temp, "%Xh", l); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", l); } -static void print_long_parm_1s_comp(void) +static void print_long_parm_1s_comp(std::ostream &stream) { uint32_t l; PARAM_LONG(l); - sprintf(temp, "%Xh", ~l); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", ~l); } -static void print_constant(void) +static void print_constant(std::ostream &stream) { uint8_t constant = (op >> 5) & 0x1f; - sprintf(temp, "%Xh", constant); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", constant); } -static void print_constant_1_32(void) +static void print_constant_1_32(std::ostream &stream) { uint8_t constant = (op >> 5) & 0x1f; if (!constant) constant = 0x20; - sprintf(temp, "%Xh", constant); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", constant); } -static void print_constant_1s_comp(void) +static void print_constant_1s_comp(std::ostream &stream) { uint8_t constant = (~op >> 5) & 0x1f; - sprintf(temp, "%Xh", constant); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", constant); } -static void print_constant_2s_comp(void) +static void print_constant_2s_comp(std::ostream &stream) { uint8_t constant = 32 - ((op >> 5) & 0x1f); - sprintf(temp, "%Xh", constant); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", constant); } -static void print_relative(void) +static void print_relative(std::ostream &stream) { uint16_t l; int16_t ls; @@ -142,69 +130,65 @@ static void print_relative(void) PARAM_WORD(l); ls = (int16_t)l; - sprintf(temp, "%Xh", PC + 32 + (ls << 4)); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", PC + 32 + (ls << 4)); } -static void print_relative_8bit(void) +static void print_relative_8bit(std::ostream &stream) { int8_t ls = (int8_t)op; - sprintf(temp, "%Xh", PC + 16 + (ls << 4)); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", PC + 16 + (ls << 4)); } -static void print_relative_5bit(void) +static void print_relative_5bit(std::ostream &stream) { int8_t ls = (int8_t)((op >> 5) & 0x1f); if (op & 0x0400) ls = -ls; - sprintf(temp, "%Xh", PC + 16 + (ls << 4)); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", PC + 16 + (ls << 4)); } -static void print_field(void) +static void print_field(std::ostream &stream) { - sprintf(temp, "%c", (op & 0x200) ? '1' : '0'); - strcat(buffer, temp); + util::stream_format(stream, "%c", (op & 0x200) ? '1' : '0'); } -static void print_condition_code(void) +static void print_condition_code(std::ostream &stream) { switch (op & 0x0f00) { - case 0x0000: strcat(buffer, " "); break; /* This is really UC (Unconditional) */ - case 0x0100: strcat(buffer, "P "); break; - case 0x0200: strcat(buffer, "LS"); break; - case 0x0300: strcat(buffer, "HI"); break; - case 0x0400: strcat(buffer, "LT"); break; - case 0x0500: strcat(buffer, "GE"); break; - case 0x0600: strcat(buffer, "LE"); break; - case 0x0700: strcat(buffer, "GT"); break; - case 0x0800: strcat(buffer, "C "); break; - case 0x0900: strcat(buffer, "NC"); break; - case 0x0a00: strcat(buffer, "EQ"); break; - case 0x0b00: strcat(buffer, "NE"); break; - case 0x0c00: strcat(buffer, "V "); break; - case 0x0d00: strcat(buffer, "NV"); break; - case 0x0e00: strcat(buffer, "N "); break; - case 0x0f00: strcat(buffer, "NN"); break; + case 0x0000: stream << " "; break; /* This is really UC (Unconditional) */ + case 0x0100: stream << "P "; break; + case 0x0200: stream << "LS"; break; + case 0x0300: stream << "HI"; break; + case 0x0400: stream << "LT"; break; + case 0x0500: stream << "GE"; break; + case 0x0600: stream << "LE"; break; + case 0x0700: stream << "GT"; break; + case 0x0800: stream << "C "; break; + case 0x0900: stream << "NC"; break; + case 0x0a00: stream << "EQ"; break; + case 0x0b00: stream << "NE"; break; + case 0x0c00: stream << "V "; break; + case 0x0d00: stream << "NV"; break; + case 0x0e00: stream << "N "; break; + case 0x0f00: stream << "NN"; break; } } -static void print_reg_list_range(int8_t first, int8_t last) +static void print_reg_list_range(std::ostream &stream, int8_t first, int8_t last) { if ((first != -1 ) && (first != last)) { if ((last - first) == 1) - strcat(buffer, ","); + stream << ","; else - strcat(buffer, "-"); - print_reg(last); + stream << "-"; + print_reg(stream, last); } } -static void print_reg_list(uint16_t rev) +static void print_reg_list(std::ostream &stream, uint16_t rev) { uint16_t l; uint8_t i; @@ -231,31 +215,30 @@ static void print_reg_list(uint16_t rev) { if (first == -1) { - strcat(buffer, ","); - print_reg(i); + stream << ","; + print_reg(stream, i); first = i; } last = i; } else { - print_reg_list_range(first, last); + print_reg_list_range(stream, first, last); first = -1; } } - print_reg_list_range(first, last); + print_reg_list_range(stream, first, last); } -static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) +static unsigned Dasm340x0(std::ostream &stream, uint32_t pc, bool is_34020) { int flags = 0; uint8_t bad = 0; uint16_t subop; __pc = _pc = pc; - buffer = buff; OP_WORD(op); @@ -270,66 +253,66 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) switch (subop) { case 0x0020: - sprintf (buffer, "REV "); - print_des_reg(); + util::stream_format(stream, "REV "); + print_des_reg(stream); break; case 0x0040: if (is_34020) - sprintf (buffer, "IDLE "); + util::stream_format(stream, "IDLE "); else bad = 1; break; case 0x0080: if (is_34020) - sprintf (buffer, "MWAIT "); + util::stream_format(stream, "MWAIT "); else bad = 1; break; case 0x00e0: if (is_34020) - sprintf (buffer, "BLMOVE %d,%d", (op >> 1) & 1, op & 1); + util::stream_format(stream, "BLMOVE %d,%d", (op >> 1) & 1, op & 1); else bad = 1; break; case 0x0100: - sprintf (buffer, "EMU "); + util::stream_format(stream, "EMU "); break; case 0x0120: - sprintf (buffer, "EXGPC "); - print_des_reg(); + util::stream_format(stream, "EXGPC "); + print_des_reg(stream); break; case 0x0140: - sprintf (buffer, "GETPC "); - print_des_reg(); + util::stream_format(stream, "GETPC "); + print_des_reg(stream); break; case 0x0160: - sprintf (buffer, "JUMP "); - print_des_reg(); + util::stream_format(stream, "JUMP "); + print_des_reg(stream); break; case 0x0180: - sprintf (buffer, "GETST "); - print_des_reg(); + util::stream_format(stream, "GETST "); + print_des_reg(stream); break; case 0x01a0: - sprintf (buffer, "PUTST "); - print_des_reg(); + util::stream_format(stream, "PUTST "); + print_des_reg(stream); break; case 0x01c0: - sprintf (buffer, "POPST "); + util::stream_format(stream, "POPST "); break; case 0x01e0: - sprintf (buffer, "PUSHST "); + util::stream_format(stream, "PUSHST "); break; default: @@ -343,14 +326,14 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { case 0x0040: if (is_34020) - sprintf (buffer, "SETCSP "); + util::stream_format(stream, "SETCSP "); else bad = 1; break; case 0x0060: if (is_34020) - sprintf (buffer, "SETCDP "); + util::stream_format(stream, "SETCDP "); else bad = 1; break; @@ -358,8 +341,8 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x0080: if (is_34020) { - sprintf (buffer, "RPIX "); - print_des_reg(); + util::stream_format(stream, "RPIX "); + print_des_reg(stream); } else bad = 1; @@ -368,8 +351,8 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x00a0: if (is_34020) { - sprintf (buffer, "EXGPS "); - print_des_reg(); + util::stream_format(stream, "EXGPS "); + print_des_reg(stream); } else bad = 1; @@ -378,8 +361,8 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x00c0: if (is_34020) { - sprintf (buffer, "GETPS "); - print_des_reg(); + util::stream_format(stream, "GETPS "); + print_des_reg(stream); } else bad = 1; @@ -387,48 +370,48 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x00e0: if (is_34020) - sprintf (buffer, "SETCMP "); + util::stream_format(stream, "SETCMP "); else bad = 1; break; case 0x0100: - sprintf (buffer, "NOP "); + util::stream_format(stream, "NOP "); break; case 0x0120: - sprintf (buffer, "CLRC "); + util::stream_format(stream, "CLRC "); break; case 0x0140: - sprintf (buffer, "MOVB @"); - print_long_parm(); - strcat(buffer, ",@"); - print_long_parm(); + util::stream_format(stream, "MOVB @"); + print_long_parm(stream); + stream << ",@"; + print_long_parm(stream); break; case 0x0160: - sprintf (buffer, "DINT "); + util::stream_format(stream, "DINT "); break; case 0x0180: - sprintf (buffer, "ABS "); - print_des_reg(); + util::stream_format(stream, "ABS "); + print_des_reg(stream); break; case 0x01a0: - sprintf (buffer, "NEG "); - print_des_reg(); + util::stream_format(stream, "NEG "); + print_des_reg(stream); break; case 0x01c0: - sprintf (buffer, "NEGB "); - print_des_reg(); + util::stream_format(stream, "NEGB "); + print_des_reg(stream); break; case 0x01e0: - sprintf (buffer, "NOT "); - print_des_reg(); + util::stream_format(stream, "NOT "); + print_des_reg(stream); break; default: @@ -446,7 +429,7 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { uint32_t x; PARAM_LONG(x); - sprintf(buffer, "CEXEC %d,%06X,%d", (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); + util::stream_format(stream, "CEXEC %d,%06X,%d", (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); } else bad = 1; @@ -457,10 +440,9 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { uint32_t x; PARAM_LONG(x); - sprintf(buffer, "CMOVGC "); - print_des_reg(); - sprintf(temp, ",%06X,%d", (x >> 8) & 0x1fffff, (x >> 29) & 7); - strcat(buffer, temp); + util::stream_format(stream, "CMOVGC "); + print_des_reg(stream); + util::stream_format(stream, ",%06X,%d", (x >> 8) & 0x1fffff, (x >> 29) & 7); } else bad = 1; @@ -471,13 +453,12 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { uint32_t x; PARAM_LONG(x); - sprintf(buffer, "CMOVGC "); - print_des_reg(); - strcat(buffer, ","); + util::stream_format(stream, "CMOVGC "); + print_des_reg(stream); + stream << ","; rf = (x & 0x10) ? 'B' : 'A'; - print_reg(x & 0x0f); - sprintf(temp, ",%d,%06X,%d", (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); - strcat(buffer, temp); + print_reg(stream, x & 0x0f); + util::stream_format(stream, ",%d,%06X,%d", (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); } else bad = 1; @@ -491,19 +472,17 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) if (op == 0x0660 && (x & 0xff) == 0x01) { - sprintf(buffer, "CMOVCS "); - sprintf(temp, ",%06X,%d", (x >> 8) & 0x1fffff, (x >> 29) & 7); - strcat(buffer, temp); + util::stream_format(stream, "CMOVCS "); + util::stream_format(stream, ",%06X,%d", (x >> 8) & 0x1fffff, (x >> 29) & 7); } else { - sprintf(buffer, "CMOVCG "); - print_des_reg(); - strcat(buffer, ","); + util::stream_format(stream, "CMOVCG "); + print_des_reg(stream); + stream << ","; rf = (x & 0x10) ? 'B' : 'A'; - print_reg(x & 0x0f); - sprintf(temp, ",%d,%06X,%d", (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); - strcat(buffer, temp); + print_reg(stream, x & 0x0f); + util::stream_format(stream, ",%d,%06X,%d", (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); } } else @@ -515,11 +494,10 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { uint32_t x; PARAM_LONG(x); - sprintf(buffer, "CMOVMC *"); + util::stream_format(stream, "CMOVMC *"); rf = (x & 0x10) ? 'B' : 'A'; - print_reg(x & 0x0f); - sprintf(temp, "+,%d,%d,%06X,%d", op & 0x1f, (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); - strcat(buffer, temp); + print_reg(stream, x & 0x0f); + util::stream_format(stream, "+,%d,%d,%06X,%d", op & 0x1f, (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); } else bad = 1; @@ -530,10 +508,9 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { uint32_t x; PARAM_LONG(x); - sprintf(buffer, "CMOVCM *"); - print_des_reg(); - sprintf(temp, "+,%d,%d,%06X,%d", x & 0x1f, (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); - strcat(buffer, temp); + util::stream_format(stream, "CMOVCM *"); + print_des_reg(stream); + util::stream_format(stream, "+,%d,%d,%06X,%d", x & 0x1f, (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); } else bad = 1; @@ -544,10 +521,9 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { uint32_t x; PARAM_LONG(x); - sprintf(buffer, "CMOVCM *-"); - print_des_reg(); - sprintf(temp, ",%d,%d,%06X,%d", x & 0x1f, (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); - strcat(buffer, temp); + util::stream_format(stream, "CMOVCM *-"); + print_des_reg(stream); + util::stream_format(stream, ",%d,%d,%06X,%d", x & 0x1f, (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); } else bad = 1; @@ -558,82 +534,81 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { uint32_t x; PARAM_LONG(x); - sprintf(buffer, "CMOVMC *"); + util::stream_format(stream, "CMOVMC *"); rf = (x & 0x10) ? 'B' : 'A'; - print_reg(x & 0x0f); - strcat(buffer, "+,"); + print_reg(stream, x & 0x0f); + stream << "+,"; rf = (op & 0x10) ? 'B' : 'A'; - print_reg(op & 0x0f); - sprintf(temp, ",%d,%06X,%d", (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); - strcat(buffer, temp); + print_reg(stream, op & 0x0f); + util::stream_format(stream, ",%d,%06X,%d", (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); } else bad = 1; break; case 0x0100: - sprintf (buffer, "SEXT "); - print_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "SEXT "); + print_des_reg(stream); + stream << ","; + print_field(stream); break; case 0x0120: - sprintf (buffer, "ZEXT "); - print_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "ZEXT "); + print_des_reg(stream); + stream << ","; + print_field(stream); break; case 0x0140: case 0x0160: - sprintf (buffer, "SETF %Xh,%X,", + util::stream_format(stream, "SETF %Xh,%X,", (op & 0x1f) ? op & 0x1f : 0x20, (op >> 5) & 1); - print_field(); + print_field(stream); break; case 0x0180: - sprintf (buffer, "MOVE "); - print_des_reg(); - strcat(buffer, ",@"); - print_long_parm(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE "); + print_des_reg(stream); + stream << ",@"; + print_long_parm(stream); + stream << ","; + print_field(stream); break; case 0x01a0: - sprintf (buffer, "MOVE @"); - print_long_parm(); - strcat(buffer, ","); - print_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE @"); + print_long_parm(stream); + stream << ","; + print_des_reg(stream); + stream << ","; + print_field(stream); break; case 0x01c0: - sprintf (buffer, "MOVE @"); - print_long_parm(); - strcat(buffer, ",@"); - print_long_parm(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE @"); + print_long_parm(stream); + stream << ",@"; + print_long_parm(stream); + stream << ","; + print_field(stream); break; case 0x01e0: if (op & 0x200) { - sprintf (buffer, "MOVE @"); - print_long_parm(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "MOVE @"); + print_long_parm(stream); + stream << ","; + print_des_reg(stream); } else { - sprintf (buffer, "MOVB "); - print_des_reg(); - strcat(buffer, ",@"); - print_long_parm(); + util::stream_format(stream, "MOVB "); + print_des_reg(stream); + stream << ",@"; + print_long_parm(stream); } break; @@ -649,7 +624,7 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x0000: if (is_34020) { - sprintf (buffer, "TRAPL "); + util::stream_format(stream, "TRAPL "); flags = DASMFLAG_STEP_OVER; } else @@ -661,11 +636,10 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { uint32_t x; PARAM_LONG(x); - sprintf(buffer, "CMOVMC *-"); + util::stream_format(stream, "CMOVMC *-"); rf = (x & 0x10) ? 'B' : 'A'; - print_reg(x & 0x0f); - sprintf(temp, ",%d,%d,%06X,%d", op & 0x1f, (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); - strcat(buffer, temp); + print_reg(stream, x & 0x0f); + util::stream_format(stream, ",%d,%d,%06X,%d", op & 0x1f, (x >> 7) & 1, (x >> 8) & 0x1fffff, (x >> 29) & 7); } else bad = 1; @@ -673,7 +647,7 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x0040: if (is_34020) - sprintf (buffer, "VBLT B,L"); + util::stream_format(stream, "VBLT B,L"); else bad = 1; break; @@ -681,7 +655,7 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x0060: if (is_34020) { - sprintf(buffer, "RETM "); + util::stream_format(stream, "RETM "); flags = DASMFLAG_STEP_OUT; } else @@ -690,61 +664,60 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x00e0: if (is_34020) - sprintf (buffer, "CLIP "); + util::stream_format(stream, "CLIP "); else bad = 1; break; case 0x0100: - sprintf (buffer, "TRAP %Xh", op & 0x1f); + util::stream_format(stream, "TRAP %Xh", op & 0x1f); flags = DASMFLAG_STEP_OVER; break; case 0x0120: - sprintf (buffer, "CALL "); - print_des_reg(); + util::stream_format(stream, "CALL "); + print_des_reg(stream); flags = DASMFLAG_STEP_OVER; break; case 0x0140: - sprintf (buffer, "RETI "); + util::stream_format(stream, "RETI "); flags = DASMFLAG_STEP_OUT; break; case 0x0160: - sprintf (buffer, "RETS "); + util::stream_format(stream, "RETS "); flags = DASMFLAG_STEP_OUT; if (op & 0x1f) { - sprintf(temp, "%Xh", op & 0x1f); - strcat(buffer, temp); + util::stream_format(stream, "%Xh", op & 0x1f); } break; case 0x0180: - sprintf (buffer, "MMTM "); - print_des_reg(); - print_reg_list(1); + util::stream_format(stream, "MMTM "); + print_des_reg(stream); + print_reg_list(stream, 1); break; case 0x01a0: - sprintf (buffer, "MMFM "); - print_des_reg(); - print_reg_list(0); + util::stream_format(stream, "MMFM "); + print_des_reg(stream); + print_reg_list(stream, 0); break; case 0x01c0: - sprintf (buffer, "MOVI "); - print_word_parm(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "MOVI "); + print_word_parm(stream); + stream << ","; + print_des_reg(stream); break; case 0x01e0: - sprintf (buffer, "MOVI "); - print_long_parm(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "MOVI "); + print_long_parm(stream); + stream << ","; + print_des_reg(stream); break; default: @@ -758,21 +731,21 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { case 0x0000: if (is_34020) - sprintf (buffer, "VLCOL "); + util::stream_format(stream, "VLCOL "); else bad = 1; break; case 0x0020: if (is_34020) - sprintf (buffer, "PFILL XY"); + util::stream_format(stream, "PFILL XY"); else bad = 1; break; case 0x0040: if (is_34020) - sprintf (buffer, "VFILL L"); + util::stream_format(stream, "VFILL L"); else bad = 1; break; @@ -780,8 +753,8 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x0060: if (is_34020) { - sprintf (buffer, "CVMXYL "); - print_des_reg(); + util::stream_format(stream, "CVMXYL "); + print_des_reg(stream); } else bad = 1; @@ -790,8 +763,8 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x0080: if (is_34020) { - sprintf (buffer, "CVDXYL "); - print_des_reg(); + util::stream_format(stream, "CVDXYL "); + print_des_reg(stream); } else bad = 1; @@ -799,72 +772,72 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x00a0: if (is_34020) - sprintf (buffer, "FPIXEQ "); + util::stream_format(stream, "FPIXEQ "); else bad = 1; break; case 0x00c0: if (is_34020) - sprintf (buffer, "FPIXNE "); + util::stream_format(stream, "FPIXNE "); else bad = 1; break; case 0x0100: - sprintf (buffer, "ADDI "); - print_word_parm(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "ADDI "); + print_word_parm(stream); + stream << ","; + print_des_reg(stream); break; case 0x0120: - sprintf (buffer, "ADDI "); - print_long_parm(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "ADDI "); + print_long_parm(stream); + stream << ","; + print_des_reg(stream); break; case 0x0140: - sprintf (buffer, "CMPI "); - print_word_parm_1s_comp(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "CMPI "); + print_word_parm_1s_comp(stream); + stream << ","; + print_des_reg(stream); break; case 0x0160: - sprintf (buffer, "CMPI "); - print_long_parm_1s_comp(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "CMPI "); + print_long_parm_1s_comp(stream); + stream << ","; + print_des_reg(stream); break; case 0x0180: - sprintf (buffer, "ANDI "); - print_long_parm_1s_comp(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "ANDI "); + print_long_parm_1s_comp(stream); + stream << ","; + print_des_reg(stream); break; case 0x01a0: - sprintf (buffer, "ORI "); - print_long_parm(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "ORI "); + print_long_parm(stream); + stream << ","; + print_des_reg(stream); break; case 0x01c0: - sprintf (buffer, "XORI "); - print_long_parm(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "XORI "); + print_long_parm(stream); + stream << ","; + print_des_reg(stream); break; case 0x01e0: - sprintf (buffer, "SUBI "); - print_word_parm_1s_comp(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "SUBI "); + print_word_parm_1s_comp(stream); + stream << ","; + print_des_reg(stream); break; default: @@ -879,10 +852,10 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x0000: if (is_34020) { - sprintf (buffer, "ADDXYI "); - print_long_parm(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "ADDXYI "); + print_long_parm(stream); + stream << ","; + print_des_reg(stream); } else bad = 1; @@ -890,60 +863,60 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x0040: if (is_34020) - sprintf (buffer, "LINIT "); + util::stream_format(stream, "LINIT "); else bad = 1; break; case 0x0100: - sprintf (buffer, "SUBI "); - print_long_parm_1s_comp(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "SUBI "); + print_long_parm_1s_comp(stream); + stream << ","; + print_des_reg(stream); break; case 0x0120: - sprintf (buffer, "CALLR "); - print_relative(); + util::stream_format(stream, "CALLR "); + print_relative(stream); flags = DASMFLAG_STEP_OVER; break; case 0x0140: - sprintf (buffer, "CALLA "); - print_long_parm(); + util::stream_format(stream, "CALLA "); + print_long_parm(stream); flags = DASMFLAG_STEP_OVER; break; case 0x0160: - sprintf (buffer, "EINT "); + util::stream_format(stream, "EINT "); break; case 0x0180: - sprintf (buffer, "DSJ "); - print_des_reg(); - strcat(buffer, ","); - print_relative(); + util::stream_format(stream, "DSJ "); + print_des_reg(stream); + stream << ","; + print_relative(stream); flags = DASMFLAG_STEP_OVER; break; case 0x01a0: - sprintf (buffer, "DSJEQ "); - print_des_reg(); - strcat(buffer, ","); - print_relative(); + util::stream_format(stream, "DSJEQ "); + print_des_reg(stream); + stream << ","; + print_relative(stream); flags = DASMFLAG_STEP_OVER; break; case 0x01c0: - sprintf (buffer, "DSJNE "); - print_des_reg(); - strcat(buffer, ","); - print_relative(); + util::stream_format(stream, "DSJNE "); + print_des_reg(stream); + stream << ","; + print_relative(stream); flags = DASMFLAG_STEP_OVER; break; case 0x01e0: - sprintf (buffer, "SETC "); + util::stream_format(stream, "SETC "); break; default: @@ -958,48 +931,48 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { case 0x0000: if (is_34020) - sprintf (buffer, "PIXBLT L,M,L"); + util::stream_format(stream, "PIXBLT L,M,L"); else bad = 1; break; case 0x00e0: if (is_34020) - sprintf (buffer, "TFILL XY"); + util::stream_format(stream, "TFILL XY"); else bad = 1; break; case 0x0100: - sprintf (buffer, "PIXBLT L,L"); + util::stream_format(stream, "PIXBLT L,L"); break; case 0x0120: - sprintf (buffer, "PIXBLT L,XY"); + util::stream_format(stream, "PIXBLT L,XY"); break; case 0x0140: - sprintf (buffer, "PIXBLT XY,L"); + util::stream_format(stream, "PIXBLT XY,L"); break; case 0x0160: - sprintf (buffer, "PIXBLT XY,XY"); + util::stream_format(stream, "PIXBLT XY,XY"); break; case 0x0180: - sprintf (buffer, "PIXBLT B,L"); + util::stream_format(stream, "PIXBLT B,L"); break; case 0x01a0: - sprintf (buffer, "PIXBLT B,XY"); + util::stream_format(stream, "PIXBLT B,XY"); break; case 0x01c0: - sprintf (buffer, "FILL L"); + util::stream_format(stream, "FILL L"); break; case 0x01e0: - sprintf (buffer, "FILL XY"); + util::stream_format(stream, "FILL XY"); break; default: @@ -1012,15 +985,15 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x1200: if ((op & 0x03e0) != 0x0020) { - sprintf (buffer, "ADDK "); - print_constant_1_32(); - strcat(buffer, ","); + util::stream_format(stream, "ADDK "); + print_constant_1_32(stream); + stream << ","; } else { - sprintf (buffer, "INC "); + util::stream_format(stream, "INC "); } - print_des_reg(); + print_des_reg(stream); break; @@ -1029,89 +1002,89 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x1600: if ((op & 0x03e0) != 0x0020) { - sprintf (buffer, "SUBK "); - print_constant_1_32(); - strcat(buffer, ","); + util::stream_format(stream, "SUBK "); + print_constant_1_32(stream); + stream << ","; } else { - sprintf (buffer, "DEC "); + util::stream_format(stream, "DEC "); } - print_des_reg(); + print_des_reg(stream); break; case 0x1800: case 0x1a00: - sprintf (buffer, "MOVK "); - print_constant_1_32(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "MOVK "); + print_constant_1_32(stream); + stream << ","; + print_des_reg(stream); break; case 0x1c00: case 0x1e00: - sprintf (buffer, "BTST "); - print_constant_1s_comp(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "BTST "); + print_constant_1s_comp(stream); + stream << ","; + print_des_reg(stream); break; case 0x2000: case 0x2200: - sprintf (buffer, "SLA "); - print_constant(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "SLA "); + print_constant(stream); + stream << ","; + print_des_reg(stream); break; case 0x2400: case 0x2600: - sprintf (buffer, "SLL "); - print_constant(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "SLL "); + print_constant(stream); + stream << ","; + print_des_reg(stream); break; case 0x2800: case 0x2a00: - sprintf (buffer, "SRA "); - print_constant_2s_comp(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "SRA "); + print_constant_2s_comp(stream); + stream << ","; + print_des_reg(stream); break; case 0x2c00: case 0x2e00: - sprintf (buffer, "SRL "); - print_constant_2s_comp(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "SRL "); + print_constant_2s_comp(stream); + stream << ","; + print_des_reg(stream); break; case 0x3000: case 0x3200: - sprintf (buffer, "RL "); - print_constant(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "RL "); + print_constant(stream); + stream << ","; + print_des_reg(stream); break; case 0x3400: case 0x3600: if (is_34020) { - sprintf (buffer, "CMPK "); - print_constant_1_32(); - strcat(buffer, ","); - print_des_reg(); + util::stream_format(stream, "CMPK "); + print_constant_1_32(stream); + stream << ","; + print_des_reg(stream); } else bad = 1; @@ -1121,62 +1094,62 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x3a00: case 0x3c00: case 0x3e00: - sprintf (buffer, "DSJS "); - print_des_reg(); - strcat(buffer, ","); - print_relative_5bit(); + util::stream_format(stream, "DSJS "); + print_des_reg(stream); + stream << ","; + print_relative_5bit(stream); flags = DASMFLAG_STEP_OVER; break; case 0x4000: - sprintf (buffer, "ADD "); - print_src_des_reg(); + util::stream_format(stream, "ADD "); + print_src_des_reg(stream); break; case 0x4200: - sprintf (buffer, "ADDC "); - print_src_des_reg(); + util::stream_format(stream, "ADDC "); + print_src_des_reg(stream); break; case 0x4400: - sprintf (buffer, "SUB "); - print_src_des_reg(); + util::stream_format(stream, "SUB "); + print_src_des_reg(stream); break; case 0x4600: - sprintf (buffer, "SUBB "); - print_src_des_reg(); + util::stream_format(stream, "SUBB "); + print_src_des_reg(stream); break; case 0x4800: - sprintf (buffer, "CMP "); - print_src_des_reg(); + util::stream_format(stream, "CMP "); + print_src_des_reg(stream); break; case 0x4a00: - sprintf (buffer, "BTST "); - print_src_des_reg(); + util::stream_format(stream, "BTST "); + print_src_des_reg(stream); break; case 0x4c00: case 0x4e00: - sprintf (buffer, "MOVE "); + util::stream_format(stream, "MOVE "); if (!(op & 0x0200)) { - print_src_des_reg(); + print_src_des_reg(stream); } else { - print_src_reg(); - strcat(buffer, ","); + print_src_reg(stream); + stream << ","; if (rf == 'A') { @@ -1187,120 +1160,120 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) rf = 'A'; } - print_des_reg(); + print_des_reg(stream); } break; case 0x5000: - sprintf (buffer, "AND "); - print_src_des_reg(); + util::stream_format(stream, "AND "); + print_src_des_reg(stream); break; case 0x5200: - sprintf (buffer, "ANDN "); - print_src_des_reg(); + util::stream_format(stream, "ANDN "); + print_src_des_reg(stream); break; case 0x5400: - sprintf (buffer, "OR "); - print_src_des_reg(); + util::stream_format(stream, "OR "); + print_src_des_reg(stream); break; case 0x5600: if (rs != rd) { - sprintf (buffer, "XOR "); - print_src_des_reg(); + util::stream_format(stream, "XOR "); + print_src_des_reg(stream); } else { - sprintf (buffer, "CLR "); - print_des_reg(); + util::stream_format(stream, "CLR "); + print_des_reg(stream); } break; case 0x5800: - sprintf (buffer, "DIVS "); - print_src_des_reg(); + util::stream_format(stream, "DIVS "); + print_src_des_reg(stream); break; case 0x5a00: - sprintf (buffer, "DIVU "); - print_src_des_reg(); + util::stream_format(stream, "DIVU "); + print_src_des_reg(stream); break; case 0x5c00: - sprintf (buffer, "MPYS "); - print_src_des_reg(); + util::stream_format(stream, "MPYS "); + print_src_des_reg(stream); break; case 0x5e00: - sprintf (buffer, "MPYU "); - print_src_des_reg(); + util::stream_format(stream, "MPYU "); + print_src_des_reg(stream); break; case 0x6000: - sprintf (buffer, "SLA "); - print_src_des_reg(); + util::stream_format(stream, "SLA "); + print_src_des_reg(stream); break; case 0x6200: - sprintf (buffer, "SLL "); - print_src_des_reg(); + util::stream_format(stream, "SLL "); + print_src_des_reg(stream); break; case 0x6400: - sprintf (buffer, "SRA "); - print_src_des_reg(); + util::stream_format(stream, "SRA "); + print_src_des_reg(stream); break; case 0x6600: - sprintf (buffer, "SRL "); - print_src_des_reg(); + util::stream_format(stream, "SRL "); + print_src_des_reg(stream); break; case 0x6800: - sprintf (buffer, "RL "); - print_src_des_reg(); + util::stream_format(stream, "RL "); + print_src_des_reg(stream); break; case 0x6a00: - sprintf (buffer, "LMO "); - print_src_des_reg(); + util::stream_format(stream, "LMO "); + print_src_des_reg(stream); break; case 0x6c00: - sprintf (buffer, "MODS "); - print_src_des_reg(); + util::stream_format(stream, "MODS "); + print_src_des_reg(stream); break; case 0x6e00: - sprintf (buffer, "MODU "); - print_src_des_reg(); + util::stream_format(stream, "MODU "); + print_src_des_reg(stream); break; case 0x7a00: if (is_34020) { - sprintf (buffer, "RMO "); - print_src_des_reg(); + util::stream_format(stream, "RMO "); + print_src_des_reg(stream); } else bad = 1; @@ -1309,9 +1282,9 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x7e00: if (is_34020) { - sprintf (buffer, "SWAPF *"); - print_src_des_reg(); - strcat(buffer, ",0"); + util::stream_format(stream, "SWAPF *"); + print_src_des_reg(stream); + stream << ",0"; } else bad = 1; @@ -1320,193 +1293,193 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0x8000: case 0x8200: - sprintf (buffer, "MOVE "); - print_src_reg(); - strcat(buffer, ",*"); - print_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE "); + print_src_reg(stream); + stream << ",*"; + print_des_reg(stream); + stream << ","; + print_field(stream); break; case 0x8400: case 0x8600: - sprintf (buffer, "MOVE *"); - print_src_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE *"); + print_src_des_reg(stream); + stream << ","; + print_field(stream); break; case 0x8800: case 0x8a00: - sprintf (buffer, "MOVE *"); - print_src_reg(); - strcat(buffer, ",*"); - print_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE *"); + print_src_reg(stream); + stream << ",*"; + print_des_reg(stream); + stream << ","; + print_field(stream); break; case 0x8c00: - sprintf (buffer, "MOVB "); - print_src_reg(); - strcat(buffer, ",*"); - print_des_reg(); + util::stream_format(stream, "MOVB "); + print_src_reg(stream); + stream << ",*"; + print_des_reg(stream); break; case 0x8e00: - sprintf (buffer, "MOVB *"); - print_src_des_reg(); + util::stream_format(stream, "MOVB *"); + print_src_des_reg(stream); break; case 0x9000: case 0x9200: - sprintf (buffer, "MOVE "); - print_src_reg(); - strcat(buffer, ",*"); - print_des_reg(); - strcat(buffer, "+,"); - print_field(); + util::stream_format(stream, "MOVE "); + print_src_reg(stream); + stream << ",*"; + print_des_reg(stream); + stream << "+,"; + print_field(stream); break; case 0x9400: case 0x9600: - sprintf (buffer, "MOVE *"); - print_src_reg(); - strcat(buffer, "+,"); - print_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE *"); + print_src_reg(stream); + stream << "+,"; + print_des_reg(stream); + stream << ","; + print_field(stream); break; case 0x9800: case 0x9a00: - sprintf (buffer, "MOVE *"); - print_src_reg(); - strcat(buffer, "+,*"); - print_des_reg(); - strcat(buffer, "+,"); - print_field(); + util::stream_format(stream, "MOVE *"); + print_src_reg(stream); + stream << "+,*"; + print_des_reg(stream); + stream << "+,"; + print_field(stream); break; case 0x9c00: - sprintf (buffer, "MOVB *"); - print_src_reg(); - strcat(buffer, ",*"); - print_des_reg(); + util::stream_format(stream, "MOVB *"); + print_src_reg(stream); + stream << ",*"; + print_des_reg(stream); break; case 0xa000: case 0xa200: - sprintf (buffer, "MOVE "); - print_src_reg(); - strcat(buffer, ",-*"); - print_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE "); + print_src_reg(stream); + stream << ",-*"; + print_des_reg(stream); + stream << ","; + print_field(stream); break; case 0xa400: case 0xa600: - sprintf (buffer, "MOVE -*"); - print_src_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE -*"); + print_src_des_reg(stream); + stream << ","; + print_field(stream); break; case 0xa800: case 0xaa00: - sprintf (buffer, "MOVE -*"); - print_src_reg(); - strcat(buffer, ",-*"); - print_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE -*"); + print_src_reg(stream); + stream << ",-*"; + print_des_reg(stream); + stream << ","; + print_field(stream); break; case 0xac00: - sprintf (buffer, "MOVB "); - print_src_reg(); - strcat(buffer, ",*"); - print_des_reg(); - strcat(buffer, "("); - print_word_parm(); - strcat(buffer, ")"); + util::stream_format(stream, "MOVB "); + print_src_reg(stream); + stream << ",*"; + print_des_reg(stream); + stream << "("; + print_word_parm(stream); + stream << ")"; break; case 0xae00: - sprintf (buffer, "MOVB *"); - print_src_reg(); - strcat(buffer, "("); - print_word_parm(); - strcat(buffer, "),"); - print_des_reg(); + util::stream_format(stream, "MOVB *"); + print_src_reg(stream); + stream << "("; + print_word_parm(stream); + stream << "),"; + print_des_reg(stream); break; case 0xb000: case 0xb200: - sprintf (buffer, "MOVE "); - print_src_reg(); - strcat(buffer, ",*"); - print_des_reg(); - strcat(buffer, "("); - print_word_parm(); - strcat(buffer, "),"); - print_field(); + util::stream_format(stream, "MOVE "); + print_src_reg(stream); + stream << ",*"; + print_des_reg(stream); + stream << "("; + print_word_parm(stream); + stream << "),"; + print_field(stream); break; case 0xb400: case 0xb600: - sprintf (buffer, "MOVE *"); - print_src_reg(); - strcat(buffer, "("); - print_word_parm(); - strcat(buffer, "),"); - print_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "MOVE *"); + print_src_reg(stream); + stream << "("; + print_word_parm(stream); + stream << "),"; + print_des_reg(stream); + stream << ","; + print_field(stream); break; case 0xb800: case 0xba00: - sprintf (buffer, "MOVE *"); - print_src_reg(); - strcat(buffer, "("); - print_word_parm(); - strcat(buffer, "),*"); - print_des_reg(); - strcat(buffer, "("); - print_word_parm(); - strcat(buffer, "),"); - print_field(); + util::stream_format(stream, "MOVE *"); + print_src_reg(stream); + stream << "("; + print_word_parm(stream); + stream << "),*"; + print_des_reg(stream); + stream << "("; + print_word_parm(stream); + stream << "),"; + print_field(stream); break; case 0xbc00: - sprintf (buffer, "MOVB *"); - print_src_reg(); - strcat(buffer, "("); - print_word_parm(); - strcat(buffer, "),*"); - print_des_reg(); - strcat(buffer, "("); - print_word_parm(); - strcat(buffer, ")"); + util::stream_format(stream, "MOVB *"); + print_src_reg(stream); + stream << "("; + print_word_parm(stream); + stream << "),*"; + print_des_reg(stream); + stream << "("; + print_word_parm(stream); + stream << ")"; break; @@ -1520,42 +1493,42 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0xce00: if ((op & 0x00ff) == 0x80) { - sprintf (buffer, "JA"); + util::stream_format(stream, "JA"); } else { - sprintf (buffer, "JR"); + util::stream_format(stream, "JR"); } - print_condition_code(); - strcat (buffer, " "); + print_condition_code(stream); + stream << " "; switch (op & 0x00ff) { case 0x00: - print_relative(); + print_relative(stream); break; case 0x80: - print_long_parm(); + print_long_parm(stream); break; default: - print_relative_8bit(); + print_relative_8bit(stream); } break; case 0xd000: case 0xd200: - sprintf (buffer, "MOVE *"); - print_src_reg(); - strcat(buffer, "("); - print_word_parm(); - strcat(buffer, "),*"); - print_des_reg(); - strcat(buffer, "+,"); - print_field(); + util::stream_format(stream, "MOVE *"); + print_src_reg(stream); + stream << "("; + print_word_parm(stream); + stream << "),*"; + print_des_reg(stream); + stream << "+,"; + print_field(stream); break; @@ -1564,19 +1537,19 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) switch (subop) { case 0x0000: - sprintf (buffer, "MOVE @"); - print_long_parm(); - strcat(buffer, ",*"); - print_des_reg(); - strcat(buffer, "+,"); - print_field(); + util::stream_format(stream, "MOVE @"); + print_long_parm(stream); + stream << ",*"; + print_des_reg(stream); + stream << "+,"; + print_field(stream); break; case 0x0100: - sprintf (buffer, "EXGF "); - print_des_reg(); - strcat(buffer, ","); - print_field(); + util::stream_format(stream, "EXGF "); + print_des_reg(stream); + stream << ","; + print_field(stream); break; default: @@ -1589,7 +1562,7 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { uint32_t x; PARAM_WORD(x); - sprintf(buffer, "CEXEC %d,%06X,%d", op & 1, ((x << 5) & 0x1fffe0) | ((op >> 1) & 0x1f), (x >> 13) & 7); + util::stream_format(stream, "CEXEC %d,%06X,%d", op & 1, ((x << 5) & 0x1fffe0) | ((op >> 1) & 0x1f), (x >> 13) & 7); } else bad = 1; @@ -1601,24 +1574,24 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) { case 0x0000: if (is_34020) - sprintf (buffer, "FLINE 0"); + util::stream_format(stream, "FLINE 0"); else bad = 1; break; case 0x0080: if (is_34020) - sprintf (buffer, "FLINE 1"); + util::stream_format(stream, "FLINE 1"); else bad = 1; break; case 0x0100: - sprintf (buffer, "LINE 0"); + util::stream_format(stream, "LINE 0"); break; case 0x0180: - sprintf (buffer, "LINE 1"); + util::stream_format(stream, "LINE 1"); break; default: @@ -1627,40 +1600,40 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) break; case 0xe000: - sprintf (buffer, "ADDXY "); - print_src_des_reg(); + util::stream_format(stream, "ADDXY "); + print_src_des_reg(stream); break; case 0xe200: - sprintf (buffer, "SUBXY "); - print_src_des_reg(); + util::stream_format(stream, "SUBXY "); + print_src_des_reg(stream); break; case 0xe400: - sprintf (buffer, "CMPXY "); - print_src_des_reg(); + util::stream_format(stream, "CMPXY "); + print_src_des_reg(stream); break; case 0xe600: - sprintf (buffer, "CPW "); - print_src_des_reg(); + util::stream_format(stream, "CPW "); + print_src_des_reg(stream); break; case 0xe800: - sprintf (buffer, "CVXYL "); - print_src_des_reg(); + util::stream_format(stream, "CVXYL "); + print_src_des_reg(stream); break; case 0xea00: if (is_34020) { - sprintf (buffer, "CVSXYL "); - print_src_des_reg(); + util::stream_format(stream, "CVSXYL "); + print_src_des_reg(stream); } else bad = 1; @@ -1668,68 +1641,68 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) case 0xec00: - sprintf (buffer, "MOVX "); - print_src_des_reg(); + util::stream_format(stream, "MOVX "); + print_src_des_reg(stream); break; case 0xee00: - sprintf (buffer, "MOVY "); - print_src_des_reg(); + util::stream_format(stream, "MOVY "); + print_src_des_reg(stream); break; case 0xf000: - sprintf (buffer, "PIXT "); - print_src_reg(); - strcat(buffer, ",*"); - print_des_reg(); - strcat(buffer, ",XY"); + util::stream_format(stream, "PIXT "); + print_src_reg(stream); + stream << ",*"; + print_des_reg(stream); + stream << ",XY"; break; case 0xf200: - sprintf (buffer, "PIXT *"); - print_src_reg(); - strcat(buffer, ",XY,"); - print_des_reg(); + util::stream_format(stream, "PIXT *"); + print_src_reg(stream); + stream << ",XY,"; + print_des_reg(stream); break; case 0xf400: - sprintf (buffer, "PIXT *"); - print_src_reg(); - strcat(buffer, ",XY,*"); - print_des_reg(); - strcat(buffer, ",XY"); + util::stream_format(stream, "PIXT *"); + print_src_reg(stream); + stream << ",XY,*"; + print_des_reg(stream); + stream << ",XY"; break; case 0xf600: - sprintf (buffer, "DRAV "); - print_src_des_reg(); + util::stream_format(stream, "DRAV "); + print_src_des_reg(stream); break; case 0xf800: - sprintf (buffer, "PIXT "); - print_src_reg(); - strcat(buffer, ",*"); - print_des_reg(); + util::stream_format(stream, "PIXT "); + print_src_reg(stream); + stream << ",*"; + print_des_reg(stream); break; case 0xfa00: - sprintf (buffer, "PIXT *"); - print_src_des_reg(); + util::stream_format(stream, "PIXT *"); + print_src_des_reg(stream); break; case 0xfc00: - sprintf (buffer, "PIXT *"); - print_src_reg(); - strcat(buffer, ",*"); - print_des_reg(); + util::stream_format(stream, "PIXT *"); + print_src_reg(stream); + stream << ",*"; + print_des_reg(stream); break; default: @@ -1738,7 +1711,7 @@ static unsigned Dasm340x0(char *buff, uint32_t pc, int is_34020) if (bad) { - sprintf (buffer, "DW %04Xh", op & 0xffff); + util::stream_format(stream, "DW %04Xh", op & 0xffff); } return (_pc - __pc) | flags | DASMFLAG_SUPPORTED; @@ -1749,7 +1722,7 @@ CPU_DISASSEMBLE( tms34010 ) rombase = oprom; rambase = opram; pcbase = pc; - return Dasm340x0(buffer, pc, 0); + return Dasm340x0(stream, pc, false); } CPU_DISASSEMBLE( tms34020 ) @@ -1757,5 +1730,5 @@ CPU_DISASSEMBLE( tms34020 ) rombase = oprom; rambase = opram; pcbase = pc; - return Dasm340x0(buffer, pc, 1); + return Dasm340x0(stream, pc, true); } diff --git a/src/devices/cpu/tms34010/tms34010.cpp b/src/devices/cpu/tms34010/tms34010.cpp index a21e024efd2..23b181147a6 100644 --- a/src/devices/cpu/tms34010/tms34010.cpp +++ b/src/devices/cpu/tms34010/tms34010.cpp @@ -1627,17 +1627,17 @@ void tms340x0_device::state_string_export(const device_state_entry &entry, std:: } -offs_t tms34010_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms34010_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms34010 ); - return CPU_DISASSEMBLE_NAME(tms34010)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms34010)(this, stream, pc, oprom, opram, options); } -offs_t tms34020_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms34020_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms34020 ); - return CPU_DISASSEMBLE_NAME(tms34020)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms34020)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms34010/tms34010.h b/src/devices/cpu/tms34010/tms34010.h index d45d4af6891..a4efa7b14da 100644 --- a/src/devices/cpu/tms34010/tms34010.h +++ b/src/devices/cpu/tms34010/tms34010.h @@ -1029,7 +1029,7 @@ public: protected: virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const override { return (clocks + 8 - 1) / 8; } virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const override { return (cycles * 8); } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; extern const device_type TMS34010; @@ -1046,7 +1046,7 @@ public: protected: virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const override { return (clocks + 4 - 1) / 4; } virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const override { return (cycles * 4); } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; extern const device_type TMS34020; diff --git a/src/devices/cpu/tms57002/57002dsm.cpp b/src/devices/cpu/tms57002/57002dsm.cpp index 4b03fff991d..0f92c9af145 100644 --- a/src/devices/cpu/tms57002/57002dsm.cpp +++ b/src/devices/cpu/tms57002/57002dsm.cpp @@ -12,35 +12,30 @@ #include "debugger.h" #include "tms57002.h" -static const char *get_memadr(uint32_t opcode, char type) +static std::string get_memadr(uint32_t opcode, char type) { - static char buff[2][10]; - static int index = 0; - char *buf; - - index = 1-index; - buf = buff[index]; + std::string buf; if(((opcode & 0x400) && (type == 'c')) || (!(opcode & 0x400) && (type == 'd'))) { if(opcode & 0x100) - sprintf(buf, "%c(%02x)", type, opcode & 0xff); + buf = util::string_format("%c(%02x)", type, opcode & 0xff); else if(opcode & 0x80) - sprintf(buf, "%c*+", type); + buf = util::string_format("%c*+", type); else - sprintf(buf, "%c*", type); + buf = util::string_format("%c*", type); } else if(opcode & 0x200) - sprintf(buf, "%c*+", type); + buf = util::string_format("%c*+", type); else - sprintf(buf, "%c*", type); + buf = util::string_format("%c*", type); return buf; } CPU_DISASSEMBLE(tms57002) { + std::streampos original_pos = stream.tellp(); uint32_t opcode = opram[0] | (opram[1] << 8) | (opram[2] << 16); uint8_t fa = opcode >> 18; - char *buf = buffer; if(fa == 0x3f) { switch((opcode >> 11) & 0x7f) { // category 3 @@ -49,13 +44,12 @@ CPU_DISASSEMBLE(tms57002) #undef DASM3 default: - sprintf(buf, "unk c3 %02x", (opcode >> 11) & 0x7f); + util::stream_format(stream, "unk c3 %02x", (opcode >> 11) & 0x7f); break; } } else { switch(fa) { // category 1 case 0x00: - buf[0] = 0; break; #define DASM1 @@ -63,22 +57,18 @@ CPU_DISASSEMBLE(tms57002) #undef DASM1 default: - sprintf(buf, "unk c1 %02x", fa); + util::stream_format(stream, "unk c1 %02x", fa); break; } - buf += strlen(buf); - if(buf != buffer) { - strcpy(buf, " ; "); - buf += 3; - } + bool next_is_nop = ((opcode >> 11) & 0x7f) == 0x00; + if (!next_is_nop && stream.tellp() != original_pos) + stream << " ; "; switch((opcode >> 11) & 0x7f) { // category 2 case 0x00: - if(buf != buffer) - buf[-3] = 0; - else - sprintf(buf, "nop"); + if (stream.tellp() == original_pos) + util::stream_format(stream, "nop"); break; #define DASM2 @@ -86,7 +76,7 @@ CPU_DISASSEMBLE(tms57002) #undef DASM2 default: - sprintf(buf, "unk c2 %02x", (opcode >> 11) & 0x7f); + util::stream_format(stream, "unk c2 %02x", (opcode >> 11) & 0x7f); break; } } diff --git a/src/devices/cpu/tms57002/tms57002.cpp b/src/devices/cpu/tms57002/tms57002.cpp index eafa912206c..e39b7766107 100644 --- a/src/devices/cpu/tms57002/tms57002.cpp +++ b/src/devices/cpu/tms57002/tms57002.cpp @@ -821,7 +821,7 @@ void tms57002_device::device_start() state_add(TMS57002_ST1, "ST1", st1); state_add(TMS57002_RPTC, "RPTC", rptc); state_add(TMS57002_AACC, "AACC", aacc); - state_add(TMS57002_MACC, "MACC", macc).mask(U64(0xfffffffffffff)); + state_add(TMS57002_MACC, "MACC", macc).mask(0xfffffffffffffU); state_add(TMS57002_BA0, "BA0", ba0); state_add(TMS57002_BA1, "BA1", ba1); state_add(TMS57002_CREG, "CREG", creg); @@ -902,10 +902,10 @@ uint32_t tms57002_device::disasm_max_opcode_bytes() const return 4; } -offs_t tms57002_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms57002_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms57002 ); - return CPU_DISASSEMBLE_NAME(tms57002)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms57002)(this, stream, pc, oprom, opram, options); } const address_space_config *tms57002_device::memory_space_config(address_spacenum spacenum) const diff --git a/src/devices/cpu/tms57002/tms57002.h b/src/devices/cpu/tms57002/tms57002.h index 7ae8102c99c..ba0765b8b07 100644 --- a/src/devices/cpu/tms57002/tms57002.h +++ b/src/devices/cpu/tms57002/tms57002.h @@ -37,7 +37,7 @@ protected: virtual void execute_run() override; virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: enum { diff --git a/src/devices/cpu/tms57002/tms57kdec.cpp b/src/devices/cpu/tms57002/tms57kdec.cpp index c30bd1fc35a..b3b71cb58e4 100644 --- a/src/devices/cpu/tms57002/tms57kdec.cpp +++ b/src/devices/cpu/tms57002/tms57kdec.cpp @@ -72,7 +72,6 @@ inline int tms57002_device::sfma(uint32_t st1) void tms57002_device::decode_error(uint32_t opcode) { - char buf[256]; uint8_t opr[3]; if(unsupported_inst_warning) return; @@ -82,8 +81,9 @@ void tms57002_device::decode_error(uint32_t opcode) opr[1] = opcode >> 8; opr[2] = opcode >> 16; - disasm_disassemble(buf, pc, opr, opr, 0); - popmessage("tms57002: %s - Contact Mamedev", buf); + std::stringstream stream; + disasm_disassemble(stream, pc, opr, opr, 0); + popmessage("tms57002: %s - Contact Mamedev", stream.str()); } void tms57002_device::decode_cat1(uint32_t opcode, unsigned short *op, cstate *cs) diff --git a/src/devices/cpu/tms57002/tmsmake.py b/src/devices/cpu/tms57002/tmsmake.py index 1aaa0fc59e4..19336061c11 100755 --- a/src/devices/cpu/tms57002/tmsmake.py +++ b/src/devices/cpu/tms57002/tmsmake.py @@ -206,7 +206,7 @@ class Instruction: opcode, args = self.GetDasmInfo() args = [", " + a for a in args] print("%scase 0x%02x:" % (prefix, self._id), file=f) - print("%s sprintf(buf, \"%s\"%s);" % (prefix, opcode, "".join(args)), file=f) + print("%s util::stream_format(stream, \"%s\"%s);" % (prefix, opcode, "".join(args)), file=f) print("%s break;" % prefix, file=f) diff --git a/src/devices/cpu/tms7000/7000dasm.cpp b/src/devices/cpu/tms7000/7000dasm.cpp index 12ae32d4dab..1f7f8549852 100644 --- a/src/devices/cpu/tms7000/7000dasm.cpp +++ b/src/devices/cpu/tms7000/7000dasm.cpp @@ -367,7 +367,7 @@ static const tms7000_opcodeinfo opcodes[] = { {0x00, "NOP", 23, 0 } }; -static offs_t internal_disasm_tms7000(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(tms7000) { int opcode, i/*, size = 1*/; int pos = 0; @@ -446,13 +446,3 @@ static offs_t internal_disasm_tms7000(cpu_device *device, std::ostream &stream, stream << "Illegal Opcode"; return pos | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(tms7000) -{ - std::ostringstream stream; - offs_t result = internal_disasm_tms7000(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/tms7000/tms7000.cpp b/src/devices/cpu/tms7000/tms7000.cpp index 61943fa717f..eb6694a02c4 100644 --- a/src/devices/cpu/tms7000/tms7000.cpp +++ b/src/devices/cpu/tms7000/tms7000.cpp @@ -267,10 +267,10 @@ void tms7000_device::state_string_export(const device_state_entry &entry, std::s } } -offs_t tms7000_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms7000_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms7000 ); - return CPU_DISASSEMBLE_NAME(tms7000)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms7000)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms7000/tms7000.h b/src/devices/cpu/tms7000/tms7000.h index 1d7c04e024f..84298d8fa05 100644 --- a/src/devices/cpu/tms7000/tms7000.h +++ b/src/devices/cpu/tms7000/tms7000.h @@ -85,7 +85,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void execute_one(uint8_t op); diff --git a/src/devices/cpu/tms9900/9900dasm.cpp b/src/devices/cpu/tms9900/9900dasm.cpp index bd4b0215d32..5d3eac1c105 100644 --- a/src/devices/cpu/tms9900/9900dasm.cpp +++ b/src/devices/cpu/tms9900/9900dasm.cpp @@ -306,34 +306,36 @@ static inline uint16_t readop_arg(const uint8_t *opram, unsigned pc) return result | opram[PC++ - pc]; } -static int print_arg (char *dest, int mode, int arg, const uint8_t *opram, unsigned pc) +static void print_arg (std::ostream &stream, int mode, int arg, const uint8_t *opram, unsigned pc) { int base; switch (mode) { case 0x0: /* workspace register */ - return sprintf (dest, "R%d", arg); + util::stream_format(stream, "R%d", arg); + break; case 0x1: /* workspace register indirect */ - return sprintf (dest, "*R%d", arg); + util::stream_format(stream, "*R%d", arg); + break; case 0x2: /* symbolic|indexed */ base = readop_arg(opram, pc); if (arg) /* indexed */ - return sprintf (dest, "@>%04x(R%d)", base, arg); + util::stream_format(stream, "@>%04x(R%d)", base, arg); else /* symbolic (direct) */ - return sprintf (dest, "@>%04x", base); + util::stream_format(stream, "@>%04x", base); + break; case 0x3: /* workspace register indirect auto increment */ - return sprintf (dest, "*R%d+", arg); + util::stream_format(stream, "*R%d+", arg); + break; } - - return 0; } /***************************************************************************** * Disassemble a single command and return the number of bytes it uses. *****************************************************************************/ -unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom, const uint8_t *opram) +static unsigned Dasm9900 (std::ostream &stream, unsigned pc, int model_id, const uint8_t *oprom, const uint8_t *opram) { int OP, OP2, opc; int sarg, darg, smode, dmode; @@ -485,20 +487,20 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom dmode = BITS(OP,4,5); darg = BITS(OP,6,9); - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, ","); - buffer += print_arg (buffer, dmode, darg, opram, pc); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, ","); + print_arg(stream, dmode, darg, opram, pc); break; case format_2a: /* jump instructions */ displacement = (signed char)BITS(OP,8,15); - sprintf (buffer, "%-4s >%04x", mnemonic, 0xffff & (PC + displacement * 2)); + util::stream_format(stream, "%-4s >%04x", mnemonic, 0xffff & (PC + displacement * 2)); break; case format_2b: /* bit I/O instructions */ displacement = (signed char)BITS(OP,8,15); - sprintf (buffer, "%-4s >%04x", mnemonic, 0xffff & displacement); + util::stream_format(stream, "%-4s >%04x", mnemonic, 0xffff & displacement); break; case format_3_9: /* logical, multiply, and divide instructions */ @@ -513,15 +515,15 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom if (format == format_3_9) { - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, ",R%d", darg); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, ",R%d", darg); } else { - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, ",%d", darg); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, ",%d", darg); } break; @@ -529,39 +531,39 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom sarg = BITS(OP,12,15); darg = BITS(OP,8,11); - sprintf (buffer, darg ? "%-4s R%d,%d" : "%-4s R%d,R%d", mnemonic, sarg, darg); + util::stream_format(stream, darg ? "%-4s R%d,%d" : "%-4s R%d,R%d", mnemonic, sarg, darg); break; case format_6: /* single address instructions */ smode = BITS(OP,10,11); sarg = BITS(OP,12,15); - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); break; case format_7: /* instructions without operands */ - sprintf (buffer, "%s", mnemonic); + util::stream_format(stream, "%s", mnemonic); break; case format_8a: /* immediate instructions (destination register) */ darg = BITS(OP,12,15); sarg = readop_arg(opram, pc); - sprintf (buffer, "%-4s R%d,>%04x", mnemonic, darg, sarg); + util::stream_format(stream, "%-4s R%d,>%04x", mnemonic, darg, sarg); break; case format_8b: /* immediate instructions (no destination register) */ sarg = readop_arg(opram, pc); - sprintf (buffer, "%-4s >%04x", mnemonic, sarg); + util::stream_format(stream, "%-4s >%04x", mnemonic, sarg); break; case format_10: /* memory map file instruction */ sarg = BITS(OP,12,15); darg = BITS(OP,11,11); - sprintf (buffer, "%-4s R%d,%d", mnemonic, sarg, darg); + util::stream_format(stream, "%-4s R%d,%d", mnemonic, sarg, darg); break; case format_11: /* multiple precision instructions */ @@ -573,11 +575,11 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom darg = BITS(OP2,6,9); byte_count = BITS(OP2,0,3); - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, ","); - buffer += print_arg (buffer, dmode, darg, opram, pc); - buffer += sprintf (buffer, byte_count ? ",%d" : ",R%d", byte_count); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, ","); + print_arg(stream, dmode, darg, opram, pc); + util::stream_format(stream, byte_count ? ",%d" : ",R%d", byte_count); break; case format_12: /* string instructions */ @@ -590,11 +592,11 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom byte_count = BITS(OP2,0,3); checkpoint = BITS(OP,12,15); - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, ","); - buffer += print_arg (buffer, dmode, darg, opram, pc); - buffer += sprintf (buffer, byte_count ? ",%d,R%d" : ",R%d,R%d", byte_count, checkpoint); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, ","); + print_arg(stream, dmode, darg, opram, pc); + util::stream_format(stream, byte_count ? ",%d,R%d" : ",R%d,R%d", byte_count, checkpoint); break; case format_13: /* multiple precision shift instructions */ @@ -605,10 +607,10 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom darg = BITS(OP2,6,9); byte_count = BITS(OP2,0,3); - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, byte_count ? ",%d" : ",R%d", byte_count); - buffer += sprintf (buffer, darg ? ",%d" : ",R%d", darg); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, byte_count ? ",%d" : ",R%d", byte_count); + util::stream_format(stream, darg ? ",%d" : ",R%d", darg); break; case format_14: /* bit testing instructions */ @@ -618,12 +620,12 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom sarg = BITS(OP2,12,15); darg = BITS(OP2,0,9); - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); if (darg == 0x3ff) - buffer += sprintf (buffer, ",R0"); + util::stream_format(stream, ",R0"); else - buffer += sprintf (buffer, ",%d", darg); + util::stream_format(stream, ",%d", darg); break; case format_15: /* invert order of field instruction */ @@ -634,10 +636,10 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom bit_position = BITS(OP2,0,3); bit_width = BITS(OP,12,15); - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, bit_position ? ",(%d," : ",(R%d,", bit_position); - buffer += sprintf (buffer, bit_width ? "%d)" : "R%d)", bit_width); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, bit_position ? ",(%d," : ",(R%d,", bit_position); + util::stream_format(stream, bit_width ? "%d)" : "R%d)", bit_width); break; case format_16: /* field instructions */ @@ -650,12 +652,12 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom bit_position = BITS(OP2,0,3); bit_width = BITS(OP,12,15); - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, ","); - buffer += print_arg (buffer, dmode, darg, opram, pc); - buffer += sprintf (buffer, bit_position ? ",(%d," : ",(%d,", bit_position); - buffer += sprintf (buffer, bit_width ? "%d)" : "R%d)", bit_width); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, ","); + print_arg(stream, dmode, darg, opram, pc); + util::stream_format(stream, bit_position ? ",(%d," : ",(%d,", bit_position); + util::stream_format(stream, bit_width ? "%d)" : "R%d)", bit_width); break; case format_17: /* alter register and jump instructions */ @@ -665,20 +667,20 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom sarg = BITS(OP2,4,7); darg = BITS(OP2,0,3); if (darg) - sprintf (buffer, darg ? "%-4s >%04x,%d,R%d" : "%-4s >%04x,R%d,R%d", + util::stream_format(stream, darg ? "%-4s >%04x,%d,R%d" : "%-4s >%04x,R%d,R%d", mnemonic, 0xffff & (PC + displacement * 2), sarg, darg); break; case format_18: /* single register operand instructions */ sarg = BITS(OP,12,15); - sprintf (buffer, "%-4s R%d", mnemonic, sarg); + util::stream_format(stream, "%-4s R%d", mnemonic, sarg); break; case format_liim: /* liim instruction */ sarg = BITS(OP,14,15); - sprintf (buffer, "%-4s %d", mnemonic, sarg); + util::stream_format(stream, "%-4s %d", mnemonic, sarg); break; case format_19: /* move address instruction */ @@ -689,10 +691,10 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom dmode = BITS(OP2,4,5); darg = BITS(OP2,6,9); - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, ","); - buffer += print_arg (buffer, dmode, darg, opram, pc); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, ","); + print_arg(stream, dmode, darg, opram, pc); break; case format_20: /* list search instructions */ @@ -743,10 +745,10 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom break; } - buffer += sprintf (buffer, "%-4s %s,", mnemonic, condition_code); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, ","); - buffer += print_arg (buffer, dmode, darg, opram, pc); + util::stream_format(stream, "%-4s %s,", mnemonic, condition_code); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, ","); + print_arg(stream, dmode, darg, opram, pc); break; } @@ -763,19 +765,19 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom byte_count = BITS(OP2,0,3); dest_byte_count = BITS(OP,12,15); - buffer += sprintf (buffer, "%-4s ", mnemonic); - buffer += print_arg (buffer, smode, sarg, opram, pc); - buffer += sprintf (buffer, ","); - buffer += print_arg (buffer, dmode, darg, opram, pc); - buffer += sprintf (buffer, byte_count ? ",%d" : ",R%d", byte_count); - buffer += sprintf (buffer, dest_byte_count ? ",%d" : ",R%d", dest_byte_count); + util::stream_format(stream, "%-4s ", mnemonic); + print_arg(stream, smode, sarg, opram, pc); + util::stream_format(stream, ","); + print_arg(stream, dmode, darg, opram, pc); + util::stream_format(stream, byte_count ? ",%d" : ",R%d", byte_count); + util::stream_format(stream, dest_byte_count ? ",%d" : ",R%d", dest_byte_count); break; } default: osd_printf_error("debbugger internal error, file %s, line %d\n", __FILE__, __LINE__); case illegal: - sprintf (buffer, "data >%04x", OP); + util::stream_format(stream, "data >%04x", OP); break; } @@ -784,15 +786,15 @@ unsigned Dasm9900 (char *buffer, unsigned pc, int model_id, const uint8_t *oprom CPU_DISASSEMBLE( tms9900 ) { - return Dasm9900(buffer, pc, TMS9900_ID, oprom, opram); + return Dasm9900(stream, pc, TMS9900_ID, oprom, opram); } CPU_DISASSEMBLE( tms9980 ) { - return Dasm9900(buffer, pc, TMS9980_ID, oprom, opram); + return Dasm9900(stream, pc, TMS9980_ID, oprom, opram); } CPU_DISASSEMBLE( tms9995 ) { - return Dasm9900(buffer, pc, TMS9995_ID, oprom, opram); + return Dasm9900(stream, pc, TMS9995_ID, oprom, opram); } diff --git a/src/devices/cpu/tms9900/ti990_10.cpp b/src/devices/cpu/tms9900/ti990_10.cpp index 6465ecf8475..64858239eb0 100644 --- a/src/devices/cpu/tms9900/ti990_10.cpp +++ b/src/devices/cpu/tms9900/ti990_10.cpp @@ -140,10 +140,10 @@ uint32_t ti990_10_device::disasm_max_opcode_bytes() const } // TODO: check 9900dasm -offs_t ti990_10_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t ti990_10_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms9900 ); - return CPU_DISASSEMBLE_NAME(tms9900)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms9900)(this, stream, pc, oprom, opram, options); } const device_type TI990_10 = &device_creator; diff --git a/src/devices/cpu/tms9900/ti990_10.h b/src/devices/cpu/tms9900/ti990_10.h index 763e64ea00f..8b49abbff41 100644 --- a/src/devices/cpu/tms9900/ti990_10.h +++ b/src/devices/cpu/tms9900/ti990_10.h @@ -34,7 +34,7 @@ protected: // device_disasm_interface overrides uint32_t disasm_min_opcode_bytes() const override; uint32_t disasm_max_opcode_bytes() const override; - offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; const address_space_config* memory_space_config(address_spacenum spacenum) const override; diff --git a/src/devices/cpu/tms9900/tms9900.cpp b/src/devices/cpu/tms9900/tms9900.cpp index 9bac8fdf937..4ee73dc4197 100644 --- a/src/devices/cpu/tms9900/tms9900.cpp +++ b/src/devices/cpu/tms9900/tms9900.cpp @@ -2769,10 +2769,10 @@ uint32_t tms99xx_device::disasm_max_opcode_bytes() const return 6; } -offs_t tms99xx_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms99xx_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms9900 ); - return CPU_DISASSEMBLE_NAME(tms9900)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms9900)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms9900/tms9900.h b/src/devices/cpu/tms9900/tms9900.h index 1d4c54b6e17..2a627c98664 100644 --- a/src/devices/cpu/tms9900/tms9900.h +++ b/src/devices/cpu/tms9900/tms9900.h @@ -83,7 +83,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; const address_space_config* memory_space_config(address_spacenum spacenum) const override; diff --git a/src/devices/cpu/tms9900/tms9980a.cpp b/src/devices/cpu/tms9900/tms9980a.cpp index 5cb028e543a..b6466c52463 100644 --- a/src/devices/cpu/tms9900/tms9980a.cpp +++ b/src/devices/cpu/tms9900/tms9980a.cpp @@ -291,10 +291,10 @@ uint32_t tms9980a_device::disasm_max_opcode_bytes() const return 6; } -offs_t tms9980a_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms9980a_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms9980 ); - return CPU_DISASSEMBLE_NAME(tms9980)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms9980)(this, stream, pc, oprom, opram, options); } const device_type TMS9980A = &device_creator; diff --git a/src/devices/cpu/tms9900/tms9980a.h b/src/devices/cpu/tms9900/tms9980a.h index 3f295b73749..8a7a409f2b8 100644 --- a/src/devices/cpu/tms9900/tms9980a.h +++ b/src/devices/cpu/tms9900/tms9980a.h @@ -45,7 +45,7 @@ protected: uint32_t disasm_min_opcode_bytes() const override; uint32_t disasm_max_opcode_bytes() const override; - offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config80; address_space_config m_io_config80; }; diff --git a/src/devices/cpu/tms9900/tms9995.cpp b/src/devices/cpu/tms9900/tms9995.cpp index b161ec05ce3..67665324a5a 100644 --- a/src/devices/cpu/tms9900/tms9995.cpp +++ b/src/devices/cpu/tms9900/tms9995.cpp @@ -3548,10 +3548,10 @@ uint32_t tms9995_device::disasm_max_opcode_bytes() const return 6; } -offs_t tms9995_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t tms9995_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( tms9995 ); - return CPU_DISASSEMBLE_NAME(tms9995)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(tms9995)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/tms9900/tms9995.h b/src/devices/cpu/tms9900/tms9995.h index f1867d5b0b1..91bb29e09b1 100644 --- a/src/devices/cpu/tms9900/tms9995.h +++ b/src/devices/cpu/tms9900/tms9995.h @@ -94,7 +94,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; const address_space_config* memory_space_config(address_spacenum spacenum) const override; diff --git a/src/devices/cpu/ucom4/ucom4.cpp b/src/devices/cpu/ucom4/ucom4.cpp index f3cff841953..7b804c4c4f3 100644 --- a/src/devices/cpu/ucom4/ucom4.cpp +++ b/src/devices/cpu/ucom4/ucom4.cpp @@ -95,10 +95,10 @@ void ucom4_cpu_device::state_string_export(const device_state_entry &entry, std: } } -offs_t ucom4_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t ucom4_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE(ucom4); - return CPU_DISASSEMBLE_NAME(ucom4)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(ucom4)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/ucom4/ucom4.h b/src/devices/cpu/ucom4/ucom4.h index 5e1f3b20a25..be7905f5065 100644 --- a/src/devices/cpu/ucom4/ucom4.h +++ b/src/devices/cpu/ucom4/ucom4.h @@ -155,7 +155,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; diff --git a/src/devices/cpu/ucom4/ucom4d.cpp b/src/devices/cpu/ucom4/ucom4d.cpp index d1df0ebb5ce..4b29439b5e9 100644 --- a/src/devices/cpu/ucom4/ucom4d.cpp +++ b/src/devices/cpu/ucom4/ucom4d.cpp @@ -113,7 +113,7 @@ static const uint8_t ucom4_mnemonic[0x100] = -static offs_t internal_disasm_ucom4(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(ucom4) { int pos = 0; uint8_t op = oprom[pos++]; @@ -150,13 +150,3 @@ static offs_t internal_disasm_ucom4(cpu_device *device, std::ostream &stream, of return pos | s_flags[instr] | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(ucom4) -{ - std::ostringstream stream; - offs_t result = internal_disasm_ucom4(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/uml.cpp b/src/devices/cpu/uml.cpp index 5b4822cb379..3e14b713c34 100644 --- a/src/devices/cpu/uml.cpp +++ b/src/devices/cpu/uml.cpp @@ -414,8 +414,8 @@ void uml::instruction::simplify() if (m_flags != 0) return; - static const uint64_t instsizemask[] = { 0, 0, 0, 0, 0xffffffff, 0, 0, 0, U64(0xffffffffffffffff) }; - static const uint64_t paramsizemask[] = { 0xff, 0xffff, 0xffffffff, U64(0xffffffffffffffff) }; + static const uint64_t instsizemask[] = { 0, 0, 0, 0, 0xffffffff, 0, 0, 0, 0xffffffffffffffffU }; + static const uint64_t paramsizemask[] = { 0xff, 0xffff, 0xffffffff, 0xffffffffffffffffU }; // loop until we've simplified all we can opcode_t origop; @@ -491,7 +491,7 @@ void uml::instruction::simplify() m_opcode = OP_ROL; m_numparams = 3; } - else if (m_param[2].is_immediate() && m_param[3].is_immediate_value((U64(0xffffffffffffffff) << m_param[2].immediate()) & instsizemask[m_size])) + else if (m_param[2].is_immediate() && m_param[3].is_immediate_value((0xffffffffffffffffU << m_param[2].immediate()) & instsizemask[m_size])) { m_opcode = OP_SHL; m_numparams = 3; diff --git a/src/devices/cpu/unsp/unsp.cpp b/src/devices/cpu/unsp/unsp.cpp index 11500ba0e48..1d40ba330ee 100644 --- a/src/devices/cpu/unsp/unsp.cpp +++ b/src/devices/cpu/unsp/unsp.cpp @@ -23,10 +23,10 @@ unsp_device::unsp_device(const machine_config &mconfig, const char *tag, device_ } -offs_t unsp_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t unsp_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( unsp ); - return CPU_DISASSEMBLE_NAME(unsp)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(unsp)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/unsp/unsp.h b/src/devices/cpu/unsp/unsp.h index 69e1ad962b0..a9a656478ee 100644 --- a/src/devices/cpu/unsp/unsp.h +++ b/src/devices/cpu/unsp/unsp.h @@ -77,7 +77,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/unsp/unspdasm.cpp b/src/devices/cpu/unsp/unspdasm.cpp index 8694b3b433b..68d620fb7b6 100644 --- a/src/devices/cpu/unsp/unspdasm.cpp +++ b/src/devices/cpu/unsp/unspdasm.cpp @@ -46,7 +46,7 @@ static const char *alu[] = #define UNSP_DASM_OK ((OP2X ? 2 : 1) | DASMFLAG_SUPPORTED) -static offs_t internal_disasm_unsp(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(unsp) { uint16_t op = *(uint16_t *)oprom; uint16_t imm16 = *(uint16_t *)(oprom + 2); @@ -258,13 +258,3 @@ static offs_t internal_disasm_unsp(cpu_device *device, std::ostream &stream, off util::stream_format(stream, ""); return UNSP_DASM_OK; } - - -CPU_DISASSEMBLE(unsp) -{ - std::ostringstream stream; - offs_t result = internal_disasm_unsp(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/upd7725/dasm7725.cpp b/src/devices/cpu/upd7725/dasm7725.cpp index 8edeb821e53..f2e644e0bec 100644 --- a/src/devices/cpu/upd7725/dasm7725.cpp +++ b/src/devices/cpu/upd7725/dasm7725.cpp @@ -12,16 +12,13 @@ #include "emu.h" #include "upd7725.h" -CPU_DISASSEMBLE( upd7725 ) +CPU_DISASSEMBLE(upd7725) { - static char output[256]; uint32_t opcode = oprom[2] | (oprom[1] << 8) | (oprom[0] << 16); uint32_t type = (opcode >> 22); // printf("dasm: PC %x opcode %08x\n", pc, opcode); - memset(output, 0, sizeof(output)); - if(type == 0 || type == 1) { //OP,RT uint8_t pselect = (opcode >> 20)&0x3; //P select uint8_t alu = (opcode >> 16)&0xf; //ALU operation mode @@ -33,116 +30,116 @@ CPU_DISASSEMBLE( upd7725 ) uint8_t dst = (opcode >> 0)&0xf; //move destination switch(alu) { - case 0: strcat(output, "nop "); break; - case 1: strcat(output, "or "); break; - case 2: strcat(output, "and "); break; - case 3: strcat(output, "xor "); break; - case 4: strcat(output, "sub "); break; - case 5: strcat(output, "add "); break; - case 6: strcat(output, "sbb "); break; - case 7: strcat(output, "adc "); break; - case 8: strcat(output, "dec "); break; - case 9: strcat(output, "inc "); break; - case 10: strcat(output, "cmp "); break; - case 11: strcat(output, "shr1 "); break; - case 12: strcat(output, "shl1 "); break; - case 13: strcat(output, "shl2 "); break; - case 14: strcat(output, "shl4 "); break; - case 15: strcat(output, "xchg "); break; + case 0: stream << "nop "; break; + case 1: stream << "or "; break; + case 2: stream << "and "; break; + case 3: stream << "xor "; break; + case 4: stream << "sub "; break; + case 5: stream << "add "; break; + case 6: stream << "sbb "; break; + case 7: stream << "adc "; break; + case 8: stream << "dec "; break; + case 9: stream << "inc "; break; + case 10: stream << "cmp "; break; + case 11: stream << "shr1 "; break; + case 12: stream << "shl1 "; break; + case 13: stream << "shl2 "; break; + case 14: stream << "shl4 "; break; + case 15: stream << "xchg "; break; } if(alu < 8) { switch(pselect) { - case 0: strcat(output, "ram,"); break; - case 1: strcat(output, "idb,"); break; - case 2: strcat(output, "m,"); break; - case 3: strcat(output, "n,"); break; + case 0: stream << "ram,"; break; + case 1: stream << "idb,"; break; + case 2: stream << "m,"; break; + case 3: stream << "n,"; break; } } switch(asl) { - case 0: strcat(output, "a"); break; - case 1: strcat(output, "b"); break; + case 0: stream << "a"; break; + case 1: stream << "b"; break; } if(dst) { - strcat(output, " | mov "); + stream << " | mov "; switch(src) { - case 0: strcat(output, "trb,"); break; - case 1: strcat(output, "a,"); break; - case 2: strcat(output, "b,"); break; - case 3: strcat(output, "tr,"); break; - case 4: strcat(output, "dp,"); break; - case 5: strcat(output, "rp,"); break; - case 6: strcat(output, "ro,"); break; - case 7: strcat(output, "sgn,"); break; - case 8: strcat(output, "dr,"); break; - case 9: strcat(output, "drnf,"); break; - case 10: strcat(output, "sr,"); break; - case 11: strcat(output, "sim,"); break; - case 12: strcat(output, "sil,"); break; - case 13: strcat(output, "k,"); break; - case 14: strcat(output, "l,"); break; - case 15: strcat(output, "mem,"); break; + case 0: stream << "trb,"; break; + case 1: stream << "a,"; break; + case 2: stream << "b,"; break; + case 3: stream << "tr,"; break; + case 4: stream << "dp,"; break; + case 5: stream << "rp,"; break; + case 6: stream << "ro,"; break; + case 7: stream << "sgn,"; break; + case 8: stream << "dr,"; break; + case 9: stream << "drnf,"; break; + case 10: stream << "sr,"; break; + case 11: stream << "sim,"; break; + case 12: stream << "sil,"; break; + case 13: stream << "k,"; break; + case 14: stream << "l,"; break; + case 15: stream << "mem,"; break; } switch(dst) { - case 0: strcat(output, "non"); break; - case 1: strcat(output, "a"); break; - case 2: strcat(output, "b"); break; - case 3: strcat(output, "tr"); break; - case 4: strcat(output, "dp"); break; - case 5: strcat(output, "rp"); break; - case 6: strcat(output, "dr"); break; - case 7: strcat(output, "sr"); break; - case 8: strcat(output, "sol"); break; - case 9: strcat(output, "som"); break; - case 10: strcat(output, "k"); break; - case 11: strcat(output, "klr"); break; - case 12: strcat(output, "klm"); break; - case 13: strcat(output, "l"); break; - case 14: strcat(output, "trb"); break; - case 15: strcat(output, "mem"); break; + case 0: stream << "non"; break; + case 1: stream << "a"; break; + case 2: stream << "b"; break; + case 3: stream << "tr"; break; + case 4: stream << "dp"; break; + case 5: stream << "rp"; break; + case 6: stream << "dr"; break; + case 7: stream << "sr"; break; + case 8: stream << "sol"; break; + case 9: stream << "som"; break; + case 10: stream << "k"; break; + case 11: stream << "klr"; break; + case 12: stream << "klm"; break; + case 13: stream << "l"; break; + case 14: stream << "trb"; break; + case 15: stream << "mem"; break; } } if(dpl) { switch(dpl) { - case 0: strcat(output, " | dpnop"); break; - case 1: strcat(output, " | dpinc"); break; - case 2: strcat(output, " | dpdec"); break; - case 3: strcat(output, " | dpclr"); break; + case 0: stream << " | dpnop"; break; + case 1: stream << " | dpinc"; break; + case 2: stream << " | dpdec"; break; + case 3: stream << " | dpclr"; break; } } if(dphm) { switch(dphm) { - case 0: strcat(output, " | m0"); break; - case 1: strcat(output, " | m1"); break; - case 2: strcat(output, " | m2"); break; - case 3: strcat(output, " | m3"); break; - case 4: strcat(output, " | m4"); break; - case 5: strcat(output, " | m5"); break; - case 6: strcat(output, " | m6"); break; - case 7: strcat(output, " | m7"); break; - case 8: strcat(output, " | m8"); break; - case 9: strcat(output, " | m9"); break; - case 10: strcat(output, " | ma"); break; - case 11: strcat(output, " | mb"); break; - case 12: strcat(output, " | mc"); break; - case 13: strcat(output, " | md"); break; - case 14: strcat(output, " | me"); break; - case 15: strcat(output, " | mf"); break; + case 0: stream << " | m0"; break; + case 1: stream << " | m1"; break; + case 2: stream << " | m2"; break; + case 3: stream << " | m3"; break; + case 4: stream << " | m4"; break; + case 5: stream << " | m5"; break; + case 6: stream << " | m6"; break; + case 7: stream << " | m7"; break; + case 8: stream << " | m8"; break; + case 9: stream << " | m9"; break; + case 10: stream << " | ma"; break; + case 11: stream << " | mb"; break; + case 12: stream << " | mc"; break; + case 13: stream << " | md"; break; + case 14: stream << " | me"; break; + case 15: stream << " | mf"; break; } } if(rpdcr == 1) { - strcat(output, " | rpdec"); + stream << " | rpdec"; } if(type == 1) { - strcat(output, " | ret"); + stream << " | ret"; } } @@ -151,84 +148,77 @@ CPU_DISASSEMBLE( upd7725 ) uint16_t na = (opcode >> 2) & 0x7ff; //next address switch(brch) { - case 0x000: strcat(output, "jmpso "); break; - case 0x080: strcat(output, "jnca "); break; - case 0x082: strcat(output, "jca "); break; - case 0x084: strcat(output, "jncb "); break; - case 0x086: strcat(output, "jcb "); break; - case 0x088: strcat(output, "jnza "); break; - case 0x08a: strcat(output, "jza "); break; - case 0x08c: strcat(output, "jnzb "); break; - case 0x08e: strcat(output, "jzb "); break; - case 0x090: strcat(output, "jnova0 "); break; - case 0x092: strcat(output, "jova0 "); break; - case 0x094: strcat(output, "jnovb0 "); break; - case 0x096: strcat(output, "jovb0 "); break; - case 0x098: strcat(output, "jnova1 "); break; - case 0x09a: strcat(output, "jova1 "); break; - case 0x09c: strcat(output, "jnovb1 "); break; - case 0x09e: strcat(output, "jovb1 "); break; - case 0x0a0: strcat(output, "jnsa0 "); break; - case 0x0a2: strcat(output, "jsa0 "); break; - case 0x0a4: strcat(output, "jnsb0 "); break; - case 0x0a6: strcat(output, "jsb0 "); break; - case 0x0a8: strcat(output, "jnsa1 "); break; - case 0x0aa: strcat(output, "jsa1 "); break; - case 0x0ac: strcat(output, "jnsb1 "); break; - case 0x0ae: strcat(output, "jsb1 "); break; - case 0x0b0: strcat(output, "jdpl0 "); break; - case 0x0b1: strcat(output, "jdpln0 "); break; - case 0x0b2: strcat(output, "jdplf "); break; - case 0x0b3: strcat(output, "jdplnf "); break; - case 0x0b4: strcat(output, "jnsiak "); break; - case 0x0b6: strcat(output, "jsiak "); break; - case 0x0b8: strcat(output, "jnsoak "); break; - case 0x0ba: strcat(output, "jsoak "); break; - case 0x0bc: strcat(output, "jnrqm "); break; - case 0x0be: strcat(output, "jrqm "); break; - case 0x100: strcat(output, "ljmp "); break; - case 0x101: strcat(output, "hjmp "); break; - case 0x140: strcat(output, "lcall "); break; - case 0x141: strcat(output, "hcall "); break; - default: strcat(output, "?????? "); break; + case 0x000: stream << "jmpso "; break; + case 0x080: stream << "jnca "; break; + case 0x082: stream << "jca "; break; + case 0x084: stream << "jncb "; break; + case 0x086: stream << "jcb "; break; + case 0x088: stream << "jnza "; break; + case 0x08a: stream << "jza "; break; + case 0x08c: stream << "jnzb "; break; + case 0x08e: stream << "jzb "; break; + case 0x090: stream << "jnova0 "; break; + case 0x092: stream << "jova0 "; break; + case 0x094: stream << "jnovb0 "; break; + case 0x096: stream << "jovb0 "; break; + case 0x098: stream << "jnova1 "; break; + case 0x09a: stream << "jova1 "; break; + case 0x09c: stream << "jnovb1 "; break; + case 0x09e: stream << "jovb1 "; break; + case 0x0a0: stream << "jnsa0 "; break; + case 0x0a2: stream << "jsa0 "; break; + case 0x0a4: stream << "jnsb0 "; break; + case 0x0a6: stream << "jsb0 "; break; + case 0x0a8: stream << "jnsa1 "; break; + case 0x0aa: stream << "jsa1 "; break; + case 0x0ac: stream << "jnsb1 "; break; + case 0x0ae: stream << "jsb1 "; break; + case 0x0b0: stream << "jdpl0 "; break; + case 0x0b1: stream << "jdpln0 "; break; + case 0x0b2: stream << "jdplf "; break; + case 0x0b3: stream << "jdplnf "; break; + case 0x0b4: stream << "jnsiak "; break; + case 0x0b6: stream << "jsiak "; break; + case 0x0b8: stream << "jnsoak "; break; + case 0x0ba: stream << "jsoak "; break; + case 0x0bc: stream << "jnrqm "; break; + case 0x0be: stream << "jrqm "; break; + case 0x100: stream << "ljmp "; break; + case 0x101: stream << "hjmp "; break; + case 0x140: stream << "lcall "; break; + case 0x141: stream << "hcall "; break; + default: stream << "?????? "; break; } - char temp[16]; - - sprintf(temp, "$%x", na); - strcat(output, temp); + util::stream_format(stream, "$%x", na); } if(type == 3) { //LD - strcat(output, "ld "); + stream << "ld "; uint16_t id = opcode >> 6; uint8_t dst = (opcode >> 0) & 0xf; //destination - char temp[16]; - sprintf(temp, "$%x,", id); - strcat(output, temp); + util::stream_format(stream, "$%x,", id); switch(dst) { - case 0: strcat(output, "non"); break; - case 1: strcat(output, "a"); break; - case 2: strcat(output, "b"); break; - case 3: strcat(output, "tr"); break; - case 4: strcat(output, "dp"); break; - case 5: strcat(output, "rp"); break; - case 6: strcat(output, "dr"); break; - case 7: strcat(output, "sr"); break; - case 8: strcat(output, "sol"); break; - case 9: strcat(output, "som"); break; - case 10: strcat(output, "k"); break; - case 11: strcat(output, "klr"); break; - case 12: strcat(output, "klm"); break; - case 13: strcat(output, "l"); break; - case 14: strcat(output, "trb"); break; - case 15: strcat(output, "mem"); break; + case 0: stream << "non"; break; + case 1: stream << "a"; break; + case 2: stream << "b"; break; + case 3: stream << "tr"; break; + case 4: stream << "dp"; break; + case 5: stream << "rp"; break; + case 6: stream << "dr"; break; + case 7: stream << "sr"; break; + case 8: stream << "sol"; break; + case 9: stream << "som"; break; + case 10: stream << "k"; break; + case 11: stream << "klr"; break; + case 12: stream << "klm"; break; + case 13: stream << "l"; break; + case 14: stream << "trb"; break; + case 15: stream << "mem"; break; } } - strcpy(buffer, output); - return 1 | DASMFLAG_SUPPORTED; } diff --git a/src/devices/cpu/upd7725/upd7725.cpp b/src/devices/cpu/upd7725/upd7725.cpp index 841d9322050..d50ff1762c3 100644 --- a/src/devices/cpu/upd7725/upd7725.cpp +++ b/src/devices/cpu/upd7725/upd7725.cpp @@ -308,10 +308,10 @@ uint32_t necdsp_device::disasm_max_opcode_bytes() const // helper function //------------------------------------------------- -offs_t necdsp_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t necdsp_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( upd7725 ); - return CPU_DISASSEMBLE_NAME(upd7725)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(upd7725)(this, stream, pc, oprom, opram, options); } void necdsp_device::execute_run() diff --git a/src/devices/cpu/upd7725/upd7725.h b/src/devices/cpu/upd7725/upd7725.h index 80714d376eb..47ae0bf6f8c 100644 --- a/src/devices/cpu/upd7725/upd7725.h +++ b/src/devices/cpu/upd7725/upd7725.h @@ -115,7 +115,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override; virtual uint32_t disasm_max_opcode_bytes() const override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // inline data const address_space_config m_program_config, m_data_config; diff --git a/src/devices/cpu/upd7810/upd7810.cpp b/src/devices/cpu/upd7810/upd7810.cpp index ba375d196e1..618a3d41638 100644 --- a/src/devices/cpu/upd7810/upd7810.cpp +++ b/src/devices/cpu/upd7810/upd7810.cpp @@ -486,28 +486,28 @@ upd78c06_device::upd78c06_device(const machine_config &mconfig, const char *tag, m_opXX = s_opXX_78c06; } -offs_t upd7810_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t upd7810_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( upd7810 ); - return CPU_DISASSEMBLE_NAME(upd7810)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(upd7810)(this, stream, pc, oprom, opram, options); } -offs_t upd7807_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t upd7807_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( upd7807 ); - return CPU_DISASSEMBLE_NAME(upd7807)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(upd7807)(this, stream, pc, oprom, opram, options); } -offs_t upd7801_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t upd7801_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( upd7801 ); - return CPU_DISASSEMBLE_NAME(upd7801)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(upd7801)(this, stream, pc, oprom, opram, options); } -offs_t upd78c05_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t upd78c05_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( upd78c05 ); - return CPU_DISASSEMBLE_NAME(upd78c05)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(upd78c05)(this, stream, pc, oprom, opram, options); } uint8_t upd7810_device::RP(offs_t port) diff --git a/src/devices/cpu/upd7810/upd7810.h b/src/devices/cpu/upd7810/upd7810.h index 28900cb6c43..8880be1c1bb 100644 --- a/src/devices/cpu/upd7810/upd7810.h +++ b/src/devices/cpu/upd7810/upd7810.h @@ -175,7 +175,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void handle_timers(int cycles); virtual void upd7810_take_irq(); @@ -1376,7 +1376,7 @@ public: upd7807_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; @@ -1389,7 +1389,7 @@ public: protected: virtual void device_reset() override; virtual void execute_set_input(int inputnum, int state) override; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void handle_timers(int cycles) override; virtual void upd7810_take_irq() override; }; @@ -1407,7 +1407,7 @@ protected: virtual void device_reset() override; virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const override { return (clocks + 4 - 1) / 4; } virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const override { return (cycles * 4); } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; virtual void handle_timers(int cycles) override; }; diff --git a/src/devices/cpu/upd7810/upd7810_dasm.cpp b/src/devices/cpu/upd7810/upd7810_dasm.cpp index 0beed6a01d3..f3da1ba4160 100644 --- a/src/devices/cpu/upd7810/upd7810_dasm.cpp +++ b/src/devices/cpu/upd7810/upd7810_dasm.cpp @@ -5416,7 +5416,7 @@ const char *const regname[32] = "illegal", "TMM", "PT", "illegal" }; -offs_t Dasm( char *buffer, offs_t pc, const dasm_s (&dasmXX)[256], const uint8_t *oprom, const uint8_t *opram, int is_7810 ) +offs_t Dasm( std::ostream &stream, offs_t pc, const dasm_s (&dasmXX)[256], const uint8_t *oprom, const uint8_t *opram, bool is_7810 ) { unsigned idx = 0; const uint8_t op = oprom[idx++]; @@ -5424,7 +5424,7 @@ offs_t Dasm( char *buffer, offs_t pc, const dasm_s (&dasmXX)[256], const uint8_t if (desc->is_prefix()) desc = &desc->prefix_get(oprom[idx++]); - buffer += sprintf(buffer, "%-8.8s", desc->name()); + util::stream_format(stream, "%-8.8s", desc->name()); uint32_t flags = desc->is_call() ? DASMFLAG_STEP_OVER : desc->is_return() ? DASMFLAG_STEP_OUT : 0; uint8_t op2; @@ -5440,46 +5440,45 @@ offs_t Dasm( char *buffer, offs_t pc, const dasm_s (&dasmXX)[256], const uint8_t { case 'a': /* address V * 256 + offset */ op2 = opram[idx++]; - buffer += sprintf(buffer, "VV:%02X", op2); + util::stream_format(stream, "VV:%02X", op2); break; case 'b': /* immediate byte */ - buffer += sprintf(buffer, "$%02X", opram[idx++]); + util::stream_format(stream, "$%02X", opram[idx++]); break; case 'w': /* immediate word */ ea = opram[idx++]; ea += opram[idx++] << 8; - buffer += sprintf(buffer, "$%04X", ea); + util::stream_format(stream, "$%04X", ea); break; case 'd': /* JRE address */ op2 = oprom[idx++]; offset = (op & 1) ? -(256 - op2): + op2; - buffer += sprintf(buffer, "$%04X", ( pc + idx + offset ) & 0xFFFF ); + util::stream_format(stream, "$%04X", ( pc + idx + offset ) & 0xFFFF ); break; case 't': /* CALT address */ ea = 0x80 + 2 * (op & (is_7810 ? 0x1f : 0x3f)); - buffer += sprintf(buffer, "($%04X)", ea); + util::stream_format(stream, "($%04X)", ea); break; case 'f': /* CALF address */ op2 = oprom[idx++]; ea = 0x800 + 0x100 * (op & 0x07) + op2; - buffer += sprintf(buffer, "$%04X", ea); + util::stream_format(stream, "$%04X", ea); break; case 'o': /* JR offset */ offset = ( ( op & 0x20 ) ? -0x20 : 0 ) + ( op & 0x1F ); - buffer += sprintf(buffer, "$%04X", ( pc + idx + offset ) & 0xFFFF ); + util::stream_format(stream, "$%04X", ( pc + idx + offset ) & 0xFFFF ); break; case 'i': /* bit manipulation */ op2 = oprom[idx++]; - buffer += sprintf(buffer, "%s,%d", regname[op2 & 0x1f], op2 >> 5); + util::stream_format(stream, "%s,%d", regname[op2 & 0x1f], op2 >> 5); break; default: - *buffer++ = *a; + stream << *a; } } else - *buffer++ = *a; + stream << *a; } - *buffer = '\0'; return idx | flags | DASMFLAG_SUPPORTED; } @@ -5488,20 +5487,20 @@ offs_t Dasm( char *buffer, offs_t pc, const dasm_s (&dasmXX)[256], const uint8_t CPU_DISASSEMBLE( upd7810 ) { - return Dasm( buffer, pc, dasm_s::XX_7810, oprom, opram, 1 ); + return Dasm( stream, pc, dasm_s::XX_7810, oprom, opram, true ); } CPU_DISASSEMBLE( upd7807 ) { - return Dasm( buffer, pc, dasm_s::XX_7807, oprom, opram, 1 ); + return Dasm( stream, pc, dasm_s::XX_7807, oprom, opram, true ); } CPU_DISASSEMBLE( upd7801 ) { - return Dasm( buffer, pc, dasm_s::XX_7801, oprom, opram, 0 ); + return Dasm( stream, pc, dasm_s::XX_7801, oprom, opram, false ); } CPU_DISASSEMBLE( upd78c05 ) { - return Dasm( buffer, pc, dasm_s::XX_78c05, oprom, opram, 0 ); + return Dasm( stream, pc, dasm_s::XX_78c05, oprom, opram, false ); } diff --git a/src/devices/cpu/v30mz/v30mz.cpp b/src/devices/cpu/v30mz/v30mz.cpp index 54197ea82c0..6781756a58c 100644 --- a/src/devices/cpu/v30mz/v30mz.cpp +++ b/src/devices/cpu/v30mz/v30mz.cpp @@ -1296,10 +1296,10 @@ void v30mz_cpu_device::execute_set_input( int inptnum, int state ) } -offs_t v30mz_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t v30mz_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( nec ); - return CPU_DISASSEMBLE_NAME(nec)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(nec)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/v30mz/v30mz.h b/src/devices/cpu/v30mz/v30mz.h index db0e0a3ca22..4b818654437 100644 --- a/src/devices/cpu/v30mz/v30mz.h +++ b/src/devices/cpu/v30mz/v30mz.h @@ -49,7 +49,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 7; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; void interrupt(int int_num); diff --git a/src/devices/cpu/v60/v60.cpp b/src/devices/cpu/v60/v60.cpp index 831a826c035..8fee43ffa58 100644 --- a/src/devices/cpu/v60/v60.cpp +++ b/src/devices/cpu/v60/v60.cpp @@ -112,17 +112,17 @@ v70_device::v70_device(const machine_config &mconfig, const char *tag, device_t } -offs_t v60_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t v60_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( v60 ); - return CPU_DISASSEMBLE_NAME(v60)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(v60)(this, stream, pc, oprom, opram, options); } -offs_t v70_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t v70_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( v70 ); - return CPU_DISASSEMBLE_NAME(v70)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(v70)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/v60/v60.h b/src/devices/cpu/v60/v60.h index 2b6fa22b298..befd696d155 100644 --- a/src/devices/cpu/v60/v60.h +++ b/src/devices/cpu/v60/v60.h @@ -111,7 +111,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 22; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: typedef uint32_t (v60_device::*am_func)(); @@ -778,7 +778,7 @@ public: v70_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; }; diff --git a/src/devices/cpu/v60/v60d.cpp b/src/devices/cpu/v60/v60d.cpp index f30298080c3..70fcdab8296 100644 --- a/src/devices/cpu/v60/v60d.cpp +++ b/src/devices/cpu/v60/v60d.cpp @@ -46,293 +46,293 @@ static signed int read32(unsigned pc) return readop(pc) | (readop(pc+1) << 8)| (readop(pc+2) << 16)| (readop(pc+3) << 24); } -static void out_AM_Register(int reg, char *out) +static void out_AM_Register(int reg, std::ostream &stream) { - strcat(out, v60_reg_names[reg]); + stream << v60_reg_names[reg]; } -static void out_AM_RegisterIndirect(int reg, int opsize, char *out) +static void out_AM_RegisterIndirect(int reg, int opsize, std::ostream &stream) { if(opsize & 0x80) - *out++ = '@'; - sprintf(out, "[%s]", v60_reg_names[reg]); + stream << '@'; + util::stream_format(stream, "[%s]", v60_reg_names[reg]); } -static void out_AM_RegisterIndirectIndexed(int rn, int rx, int opsize, char *out) +static void out_AM_RegisterIndirectIndexed(int rn, int rx, int opsize, std::ostream &stream) { if(opsize & 0x80) - sprintf(out, "%s@[%s]", v60_reg_names[rx], v60_reg_names[rn]); + util::stream_format(stream, "%s@[%s]", v60_reg_names[rx], v60_reg_names[rn]); else - sprintf(out, "[%s](%s)", v60_reg_names[rn], v60_reg_names[rx]); + util::stream_format(stream, "[%s](%s)", v60_reg_names[rn], v60_reg_names[rx]); } -static void out_AM_Autoincrement(int reg, int opsize, char *out) +static void out_AM_Autoincrement(int reg, int opsize, std::ostream &stream) { if(opsize & 0x80) - *out++ = '@'; - sprintf(out, "[%s+]", v60_reg_names[reg]); + stream << '@'; + util::stream_format(stream, "[%s+]", v60_reg_names[reg]); } -static void out_AM_Autodecrement(int reg, int opsize, char *out) +static void out_AM_Autodecrement(int reg, int opsize, std::ostream &stream) { if(opsize & 0x80) - *out++ = '@'; - sprintf(out, "[-%s]", v60_reg_names[reg]); + stream << '@'; + util::stream_format(stream, "[-%s]", v60_reg_names[reg]); } -static void out_AM_Displacement(int reg, int disp, int opsize, char *out) +static void out_AM_Displacement(int reg, int disp, int opsize, std::ostream &stream) { - sprintf(out, "%s%X%s[%s]", + util::stream_format(stream, "%s%X%s[%s]", disp >= 0 ? "" : "-", disp >= 0 ? disp : -disp, opsize & 0x80 ? "@" : "", v60_reg_names[reg]); } -static void out_AM_DisplacementIndexed(int rn, int rx, int disp, int opsize, char *out) +static void out_AM_DisplacementIndexed(int rn, int rx, int disp, int opsize, std::ostream &stream) { if(opsize & 0x80) - sprintf(out, "%s@%s%X[%s]", v60_reg_names[rx], disp >= 0 ? "" : "-", disp >= 0 ? disp : -disp,v60_reg_names[rn]); + util::stream_format(stream, "%s@%s%X[%s]", v60_reg_names[rx], disp >= 0 ? "" : "-", disp >= 0 ? disp : -disp,v60_reg_names[rn]); else - sprintf(out, "%s%X[%s](%s)", disp >= 0 ? "" : "-", disp >= 0 ? disp : -disp,v60_reg_names[rn], v60_reg_names[rx]); + util::stream_format(stream, "%s%X[%s](%s)", disp >= 0 ? "" : "-", disp >= 0 ? disp : -disp,v60_reg_names[rn], v60_reg_names[rx]); } -static void out_AM_PCDisplacement(unsigned pc, int disp, int opsize, char *out) +static void out_AM_PCDisplacement(unsigned pc, int disp, int opsize, std::ostream &stream) { - sprintf(out, "%X%s[PC]", pc+disp, opsize & 0x80 ? "@" : ""); + util::stream_format(stream, "%X%s[PC]", pc+disp, opsize & 0x80 ? "@" : ""); } -static void out_AM_PCDisplacementIndexed(unsigned pc, int disp, int rx, int opsize, char *out) +static void out_AM_PCDisplacementIndexed(unsigned pc, int disp, int rx, int opsize, std::ostream &stream) { if(opsize & 0x80) - sprintf(out, "%s@%X[PC]", v60_reg_names[rx], pc+disp); + util::stream_format(stream, "%s@%X[PC]", v60_reg_names[rx], pc+disp); else - sprintf(out, "%X[PC](%s)", pc+disp, v60_reg_names[rx]); + util::stream_format(stream, "%X[PC](%s)", pc+disp, v60_reg_names[rx]); } -static void out_AM_DisplacementIndirect(int reg, int disp, int opsize, char *out) +static void out_AM_DisplacementIndirect(int reg, int disp, int opsize, std::ostream &stream) { - sprintf(out, "%s[%s%X[%s]]", + util::stream_format(stream, "%s[%s%X[%s]]", opsize & 0x80 ? "@" : "", disp >= 0 ? "" : "-", disp >= 0 ? disp : -disp, v60_reg_names[reg]); } -static void out_AM_DisplacementIndirectIndexed(int rn, int rx, int disp, int opsize, char *out) +static void out_AM_DisplacementIndirectIndexed(int rn, int rx, int disp, int opsize, std::ostream &stream) { if(opsize & 0x80) - sprintf(out, "%s@[%s%X[%s]]", v60_reg_names[rx], disp >= 0 ? "" : "-", disp >= 0 ? disp : -disp,v60_reg_names[rn]); + util::stream_format(stream, "%s@[%s%X[%s]]", v60_reg_names[rx], disp >= 0 ? "" : "-", disp >= 0 ? disp : -disp,v60_reg_names[rn]); else - sprintf(out, "[%s%X[%s]](%s)", disp >= 0 ? "" : "-", disp >= 0 ? disp : -disp,v60_reg_names[rn], v60_reg_names[rx]); + util::stream_format(stream, "[%s%X[%s]](%s)", disp >= 0 ? "" : "-", disp >= 0 ? disp : -disp,v60_reg_names[rn], v60_reg_names[rx]); } -static void out_AM_PCDisplacementIndirect(unsigned pc, int disp, int opsize, char *out) +static void out_AM_PCDisplacementIndirect(unsigned pc, int disp, int opsize, std::ostream &stream) { - sprintf(out, "%s[%X[PC]]", opsize & 0x80 ? "@" : "", pc+disp); + util::stream_format(stream, "%s[%X[PC]]", opsize & 0x80 ? "@" : "", pc+disp); } -static void out_AM_PCDisplacementIndirectIndexed(unsigned pc, int disp, int rx, int opsize, char *out) +static void out_AM_PCDisplacementIndirectIndexed(unsigned pc, int disp, int rx, int opsize, std::ostream &stream) { if(opsize & 0x80) - sprintf(out, "%s@[%X[PC]]", v60_reg_names[rx], pc+disp); + util::stream_format(stream, "%s@[%X[PC]]", v60_reg_names[rx], pc+disp); else - sprintf(out, "[%X[PC]](%s)", pc+disp, v60_reg_names[rx]); + util::stream_format(stream, "[%X[PC]](%s)", pc+disp, v60_reg_names[rx]); } -static void out_AM_DoubleDisplacement(int reg, int disp2, int disp1, int opsize, char *out) +static void out_AM_DoubleDisplacement(int reg, int disp2, int disp1, int opsize, std::ostream &stream) { - sprintf(out, "%s%X%s[%s%X[%s]]", + util::stream_format(stream, "%s%X%s[%s%X[%s]]", disp1 >= 0 ? "" : "-", disp1 >= 0 ? disp1 : -disp1, opsize & 0x80 ? "@" : "", disp2 >= 0 ? "" : "-", disp2 >= 0 ? disp2 : -disp2, v60_reg_names[reg]); } -static void out_AM_PCDoubleDisplacement(unsigned pc, int disp2, int disp1, int opsize, char *out) +static void out_AM_PCDoubleDisplacement(unsigned pc, int disp2, int disp1, int opsize, std::ostream &stream) { - sprintf(out, "%s%X%s[%X[PC]]", + util::stream_format(stream, "%s%X%s[%X[PC]]", disp1 >= 0 ? "" : "-", disp1 >= 0 ? disp1 : -disp1, opsize & 0x80 ? "@" : "", disp2 + pc); } -static void out_AM_DirectAddress(unsigned addr, int opsize, char *out) +static void out_AM_DirectAddress(unsigned addr, int opsize, std::ostream &stream) { if(opsize & 0x80) - *out++ = '@'; - sprintf(out, "%X", addr); + stream << '@'; + util::stream_format(stream, "%X", addr); } -static void out_AM_DirectAddressIndexed(unsigned addr, int rx, int opsize, char *out) +static void out_AM_DirectAddressIndexed(unsigned addr, int rx, int opsize, std::ostream &stream) { if(opsize & 0x80) - sprintf(out, "%s@%X", v60_reg_names[rx], addr); + util::stream_format(stream, "%s@%X", v60_reg_names[rx], addr); else - sprintf(out, "%X(%s)", addr, v60_reg_names[rx]); + util::stream_format(stream, "%X(%s)", addr, v60_reg_names[rx]); } -static void out_AM_DirectAddressDeferred(unsigned addr, int opsize, char *out) +static void out_AM_DirectAddressDeferred(unsigned addr, int opsize, std::ostream &stream) { if(opsize & 0x80) - *out++ = '@'; - sprintf(out, "[%X]", addr); + stream << '@'; + util::stream_format(stream, "[%X]", addr); } -static void out_AM_DirectAddressDeferredIndexed(unsigned addr, int rx, int opsize, char *out) +static void out_AM_DirectAddressDeferredIndexed(unsigned addr, int rx, int opsize, std::ostream &stream) { if(opsize & 0x80) - sprintf(out, "%s@[%X]", v60_reg_names[rx], addr); + util::stream_format(stream, "%s@[%X]", v60_reg_names[rx], addr); else - sprintf(out, "[%X](%s)", addr, v60_reg_names[rx]); + util::stream_format(stream, "[%X](%s)", addr, v60_reg_names[rx]); } -static void out_AM_Immediate(unsigned value, int opsize, char *out) +static void out_AM_Immediate(unsigned value, int opsize, std::ostream &stream) { if(opsize == 0) value &= 0xff; else if(opsize == 1) value &= 0xffff; - sprintf(out, "#%X", value); + util::stream_format(stream, "#%X", value); } -static int decode_AM(unsigned ipc, unsigned pc, int m, int opsize, char *out) +static int decode_AM(unsigned ipc, unsigned pc, int m, int opsize, std::ostream &stream) { unsigned char mod = readop(pc); if(m) { switch(mod>>5) { case 0: // Double displacement (8 bit) - out_AM_DoubleDisplacement(mod&0x1F, read8(pc+1), read8(pc+2), opsize, out); + out_AM_DoubleDisplacement(mod&0x1F, read8(pc+1), read8(pc+2), opsize, stream); return 3; case 1: // Double displacement (16 bit) - out_AM_DoubleDisplacement(mod&0x1F, read16(pc+1), read16(pc+3), opsize, out); + out_AM_DoubleDisplacement(mod&0x1F, read16(pc+1), read16(pc+3), opsize, stream); return 5; case 2: // Double displacement (32 bit) - out_AM_DoubleDisplacement(mod&0x1F, read32(pc+1), read32(pc+5), opsize, out); + out_AM_DoubleDisplacement(mod&0x1F, read32(pc+1), read32(pc+5), opsize, stream); return 9; case 3: // Register - out_AM_Register(mod&0x1F, out); + out_AM_Register(mod&0x1F, stream); return 1; case 4: // Autoincrement - out_AM_Autoincrement(mod&0x1F, opsize, out); + out_AM_Autoincrement(mod&0x1F, opsize, stream); return 1; case 5: // Autodecrement - out_AM_Autodecrement(mod&0x1F, opsize, out); + out_AM_Autodecrement(mod&0x1F, opsize, stream); return 1; case 6: switch (readop(pc+1)>>5) { case 0: // Displacement indexed (8 bit) - out_AM_DisplacementIndexed(readop(pc+1)&0x1F, mod&0x1F, read8(pc+2), opsize, out); + out_AM_DisplacementIndexed(readop(pc+1)&0x1F, mod&0x1F, read8(pc+2), opsize, stream); return 3; case 1: // Displacement indexed (16 bit) - out_AM_DisplacementIndexed(readop(pc+1)&0x1F, mod&0x1F, read16(pc+2), opsize, out); + out_AM_DisplacementIndexed(readop(pc+1)&0x1F, mod&0x1F, read16(pc+2), opsize, stream); return 4; case 2: // Displacement indexed (32 bit) - out_AM_DisplacementIndexed(readop(pc+1)&0x1F, mod&0x1F, read32(pc+2), opsize, out); + out_AM_DisplacementIndexed(readop(pc+1)&0x1F, mod&0x1F, read32(pc+2), opsize, stream); return 6; case 3: // Register indirect indexed - out_AM_RegisterIndirectIndexed(readop(pc+1)&0x1F, mod&0x1F, opsize, out); + out_AM_RegisterIndirectIndexed(readop(pc+1)&0x1F, mod&0x1F, opsize, stream); return 2; case 4: // Displacement indirect indexed (8 bit) - out_AM_DisplacementIndirectIndexed(readop(pc+1)&0x1F, mod&0x1F, read8(pc+2), opsize, out); + out_AM_DisplacementIndirectIndexed(readop(pc+1)&0x1F, mod&0x1F, read8(pc+2), opsize, stream); return 3; case 5: // Displacement indirect indexed (16 bit) - out_AM_DisplacementIndirectIndexed(readop(pc+1)&0x1F, mod&0x1F, read16(pc+2), opsize, out); + out_AM_DisplacementIndirectIndexed(readop(pc+1)&0x1F, mod&0x1F, read16(pc+2), opsize, stream); return 4; case 6: // Displacement indirect indexed (32 bit) - out_AM_DisplacementIndirectIndexed(readop(pc+1)&0x1F, mod&0x1F, read32(pc+2), opsize, out); + out_AM_DisplacementIndirectIndexed(readop(pc+1)&0x1F, mod&0x1F, read32(pc+2), opsize, stream); return 6; case 7: switch (readop(pc+1)&0x1F) { case 16: // PC Displacement Indexed (8 bit) - out_AM_PCDisplacementIndexed(ipc, read8(pc+2), mod&0x1F, opsize, out); + out_AM_PCDisplacementIndexed(ipc, read8(pc+2), mod&0x1F, opsize, stream); return 3; case 17: // PC Displacement Indexed (16 bit) - out_AM_PCDisplacementIndexed(ipc, read16(pc+2), mod&0x1F, opsize, out); + out_AM_PCDisplacementIndexed(ipc, read16(pc+2), mod&0x1F, opsize, stream); return 4; case 18: // PC Displacement Indexed (32 bit) - out_AM_PCDisplacementIndexed(ipc, read32(pc+2), mod&0x1F, opsize, out); + out_AM_PCDisplacementIndexed(ipc, read32(pc+2), mod&0x1F, opsize, stream); return 6; case 19: // Direct Address Indexed - out_AM_DirectAddressIndexed(read32(pc+2), mod&0x1F, opsize, out); + out_AM_DirectAddressIndexed(read32(pc+2), mod&0x1F, opsize, stream); return 6; case 24: // PC Displacement Indirect Indexed(8 bit) - out_AM_PCDisplacementIndirectIndexed(ipc, read8(pc+2), mod&0x1F, opsize, out); + out_AM_PCDisplacementIndirectIndexed(ipc, read8(pc+2), mod&0x1F, opsize, stream); return 3; case 25: // PC Displacement Indirect Indexed (16 bit) - out_AM_PCDisplacementIndirectIndexed(ipc, read16(pc+2), mod&0x1F, opsize, out); + out_AM_PCDisplacementIndirectIndexed(ipc, read16(pc+2), mod&0x1F, opsize, stream); return 4; case 26: // PC Displacement Indirect Indexed (32 bit) - out_AM_PCDisplacementIndirectIndexed(ipc, read32(pc+2), mod&0x1F, opsize, out); + out_AM_PCDisplacementIndirectIndexed(ipc, read32(pc+2), mod&0x1F, opsize, stream); return 6; case 27: // Direct Address Deferred Indexed - out_AM_DirectAddressDeferredIndexed(read32(pc+2), mod&0x1F, opsize, out); + out_AM_DirectAddressDeferredIndexed(read32(pc+2), mod&0x1F, opsize, stream); return 6; default: - strcat(out, "!ERRAM3"); + stream << "!ERRAM3"; return 1; } default: - strcat(out, "!ERRAM2"); + stream << "!ERRAM2"; return 1; } default: - strcat(out, "!ERRAM1"); + stream << "!ERRAM1"; return 1; } } else { switch(mod>>5) { case 0: // Displacement (8 bit) - out_AM_Displacement(mod&0x1F, read8(pc+1), opsize, out); + out_AM_Displacement(mod&0x1F, read8(pc+1), opsize, stream); return 2; case 1: // Displacement (16 bit) - out_AM_Displacement(mod&0x1F, read16(pc+1), opsize, out); + out_AM_Displacement(mod&0x1F, read16(pc+1), opsize, stream); return 3; case 2: // Displacement (32 bit) - out_AM_Displacement(mod&0x1F, read32(pc+1), opsize, out); + out_AM_Displacement(mod&0x1F, read32(pc+1), opsize, stream); return 5; case 3: // Register indirect - out_AM_RegisterIndirect(mod&0x1F, opsize, out); + out_AM_RegisterIndirect(mod&0x1F, opsize, stream); return 1; case 4: // Displacement indirect (8 bit) - out_AM_DisplacementIndirect(mod&0x1F, read8(pc+1), opsize, out); + out_AM_DisplacementIndirect(mod&0x1F, read8(pc+1), opsize, stream); return 2; case 5: // Displacement indirect (16 bit) - out_AM_DisplacementIndirect(mod&0x1F, read16(pc+1), opsize, out); + out_AM_DisplacementIndirect(mod&0x1F, read16(pc+1), opsize, stream); return 3; case 6: // Displacement indirect (32 bit) - out_AM_DisplacementIndirect(mod&0x1F, read32(pc+1), opsize, out); + out_AM_DisplacementIndirect(mod&0x1F, read32(pc+1), opsize, stream); return 5; case 7: @@ -353,288 +353,288 @@ static int decode_AM(unsigned ipc, unsigned pc, int m, int opsize, char *out) case 13: case 14: case 15: - out_AM_Immediate(mod&0x1F, opsize, out); + out_AM_Immediate(mod&0x1F, opsize, stream); return 1; case 16: // PC Displacement (8 bit) - out_AM_PCDisplacement(ipc, read8(pc+1), opsize, out); + out_AM_PCDisplacement(ipc, read8(pc+1), opsize, stream); return 2; case 17: // PC Displacement (16 bit) - out_AM_PCDisplacement(ipc, read16(pc+1), opsize, out); + out_AM_PCDisplacement(ipc, read16(pc+1), opsize, stream); return 3; case 18: // PC Displacement (32 bit) - out_AM_PCDisplacement(ipc, read32(pc+1), opsize, out); + out_AM_PCDisplacement(ipc, read32(pc+1), opsize, stream); return 5; case 19: // Direct Address - out_AM_DirectAddress(read32(pc+1), opsize, out); + out_AM_DirectAddress(read32(pc+1), opsize, stream); return 5; case 20: switch(opsize&0x7F) { case 0: // Immediate (8 bit) - out_AM_Immediate(read8(pc+1), opsize, out); + out_AM_Immediate(read8(pc+1), opsize, stream); return 2; case 1: // Immediate (16 bit) - out_AM_Immediate(read16(pc+1), opsize, out); + out_AM_Immediate(read16(pc+1), opsize, stream); return 3; case 2: // Immediate (32 bit) - out_AM_Immediate(read32(pc+1), opsize, out); + out_AM_Immediate(read32(pc+1), opsize, stream); return 5; default: - strcat(out, "!ERRAM6"); + stream << "!ERRAM6"; return 1; } case 24: // PC Displacement Indirect (8 bit) - out_AM_PCDisplacementIndirect(ipc, read8(pc+1), opsize, out); + out_AM_PCDisplacementIndirect(ipc, read8(pc+1), opsize, stream); return 2; case 25: // PC Displacement Indirect (16 bit) - out_AM_PCDisplacementIndirect(ipc, read16(pc+1), opsize, out); + out_AM_PCDisplacementIndirect(ipc, read16(pc+1), opsize, stream); return 3; case 26: // PC Displacement Indirect (32 bit) - out_AM_PCDisplacementIndirect(ipc, read32(pc+1), opsize, out); + out_AM_PCDisplacementIndirect(ipc, read32(pc+1), opsize, stream); return 5; case 27: // Direct Address Deferred - out_AM_DirectAddressDeferred(read32(pc+1), opsize, out); + out_AM_DirectAddressDeferred(read32(pc+1), opsize, stream); return 5; case 28: // PC Double Displacement (8 bit) - out_AM_PCDoubleDisplacement(ipc, read8(pc+1), read8(pc+2), opsize, out); + out_AM_PCDoubleDisplacement(ipc, read8(pc+1), read8(pc+2), opsize, stream); return 3; case 29: // PC Double Displacement (16 bit) - out_AM_PCDoubleDisplacement(ipc, read16(pc+1), read16(pc+3), opsize, out); + out_AM_PCDoubleDisplacement(ipc, read16(pc+1), read16(pc+3), opsize, stream); return 5; case 30: // PC Double Displacement (32 bit) - out_AM_PCDoubleDisplacement(ipc, read32(pc+1), read32(pc+5), opsize, out); + out_AM_PCDoubleDisplacement(ipc, read32(pc+1), read32(pc+5), opsize, stream); return 9; default: - strcat(out, "!ERRAM5"); + stream << "!ERRAM5"; return 1; } default: - strcat(out, "!ERRAM4"); + stream << "!ERRAM4"; return 1; } } } -static int decode_F1(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F1(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { unsigned char code = readop(pc); - sprintf(out, "%-8s", opnm); + util::stream_format(stream, "%-8s", opnm); if(code & 0x20) { - int ret = decode_AM(ipc, pc+1, code & 0x40, opsize1, out + strlen(out)) + 2; - strcat(out, ", "); - out_AM_Register(code & 0x1f, out + strlen(out)); + int ret = decode_AM(ipc, pc+1, code & 0x40, opsize1, stream) + 2; + stream << ", "; + out_AM_Register(code & 0x1f, stream); return ret; } else { - out_AM_Register(code & 0x1f, out + strlen(out)); - strcat(out, ", "); - return decode_AM(ipc, pc+1, code & 0x40, opsize1, out + strlen(out)) + 2; + out_AM_Register(code & 0x1f, stream); + stream << ", "; + return decode_AM(ipc, pc+1, code & 0x40, opsize1, stream) + 2; } } -static int decode_F2(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F2(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { int ret; unsigned char code = readop(pc); - sprintf(out, "%-8s", opnm); - ret = decode_AM(ipc, pc+1, code & 0x40, opsize1, out + strlen(out)); - strcat(out, ", "); - ret += decode_AM(ipc, pc+1+ret, code & 0x20, opsize2, out + strlen(out)); + util::stream_format(stream, "%-8s", opnm); + ret = decode_AM(ipc, pc+1, code & 0x40, opsize1, stream); + stream << ", "; + ret += decode_AM(ipc, pc+1+ret, code & 0x20, opsize2, stream); return ret+2; } -static int decode_F1F2(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F1F2(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { if(readop(pc) & 0x80) - return decode_F2(opnm, opsize1, opsize2, ipc, pc, out); + return decode_F2(opnm, opsize1, opsize2, ipc, pc, stream); else - return decode_F1(opnm, opsize1, opsize2, ipc, pc, out); + return decode_F1(opnm, opsize1, opsize2, ipc, pc, stream); } -static int decode_F3(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F3(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "%-8s", opnm); - return decode_AM(ipc, pc, readop(pc-1) & 1, opsize1, out + strlen(out)) + 1; + util::stream_format(stream, "%-8s", opnm); + return decode_AM(ipc, pc, readop(pc-1) & 1, opsize1, stream) + 1; } -static int decode_F4a(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F4a(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "%-8s%X", opnm, ipc+read8(pc)); + util::stream_format(stream, "%-8s%X", opnm, ipc+read8(pc)); return 2; } -static int decode_F4b(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F4b(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "%-8s%X", opnm, ipc+read16(pc)); + util::stream_format(stream, "%-8s%X", opnm, ipc+read16(pc)); return 3; } -static int decode_F5(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F5(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { - strcpy(out, opnm); + stream << opnm; return 1; } -static int decode_F6(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F6(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "%-8s%s, %X[PC]", opnm, v60_reg_names[readop(pc) & 0x1f], ipc+read16(pc+1)); + util::stream_format(stream, "%-8s%s, %X[PC]", opnm, v60_reg_names[readop(pc) & 0x1f], ipc+read16(pc+1)); return 4; } -static int decode_F7a(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F7a(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { int ret; unsigned char code = readop(pc); unsigned char code2; - sprintf(out, "%-8s", opnm); - ret = decode_AM(ipc, pc+1, code & 0x40, opsize1, out + strlen(out)); - strcat(out, ", "); + util::stream_format(stream, "%-8s", opnm); + ret = decode_AM(ipc, pc+1, code & 0x40, opsize1, stream); + stream << ", "; code2 = readop(pc+1+ret); if(code2 & 0x80) - out_AM_Register(code2 & 0x1f, out + strlen(out)); + out_AM_Register(code2 & 0x1f, stream); else - out_AM_Immediate(code2, 1, out + strlen(out)); - strcat(out, ", "); + out_AM_Immediate(code2, 1, stream); + stream << ", "; - ret += decode_AM(ipc, pc+2+ret, code & 0x20, opsize2, out + strlen(out)); - strcat(out, ", "); + ret += decode_AM(ipc, pc+2+ret, code & 0x20, opsize2, stream); + stream << ", "; code2 = readop(pc+2+ret); if(code2 & 0x80) - out_AM_Register(code2 & 0x1f, out + strlen(out)); + out_AM_Register(code2 & 0x1f, stream); else - out_AM_Immediate(code2, 1, out + strlen(out)); + out_AM_Immediate(code2, 1, stream); return ret+4; } -static int decode_F7b(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F7b(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { int ret; unsigned char code = readop(pc); unsigned char code2; - sprintf(out, "%-8s", opnm); - ret = decode_AM(ipc, pc+1, code & 0x40, opsize1, out + strlen(out)); - strcat(out, ", "); + util::stream_format(stream, "%-8s", opnm); + ret = decode_AM(ipc, pc+1, code & 0x40, opsize1, stream); + stream << ", "; code2 = readop(pc+1+ret); if(code2 & 0x80) - out_AM_Register(code2 & 0x1f, out + strlen(out)); + out_AM_Register(code2 & 0x1f, stream); else - out_AM_Immediate(code2, 1, out + strlen(out)); - strcat(out, ", "); + out_AM_Immediate(code2, 1, stream); + stream << ", "; - ret += decode_AM(ipc, pc+2+ret, code & 0x20, opsize2, out + strlen(out)); + ret += decode_AM(ipc, pc+2+ret, code & 0x20, opsize2, stream); return ret+3; } -static int decode_F7c(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, char *out) +static int decode_F7c(const char *opnm, int opsize1, int opsize2, unsigned ipc, unsigned pc, std::ostream &stream) { int ret; unsigned char code = readop(pc); unsigned char code2; - sprintf(out, "%-8s", opnm); - ret = decode_AM(ipc, pc+1, code & 0x40, opsize1, out + strlen(out)); - strcat(out, ", "); + util::stream_format(stream, "%-8s", opnm); + ret = decode_AM(ipc, pc+1, code & 0x40, opsize1, stream); + stream << ", "; - ret += decode_AM(ipc, pc+1+ret, code & 0x20, opsize2, out + strlen(out)); - strcat(out, ", "); + ret += decode_AM(ipc, pc+1+ret, code & 0x20, opsize2, stream); + stream << ", "; code2 = readop(pc+1+ret); if(code2 & 0x80) - out_AM_Register(code2 & 0x1f, out + strlen(out)); + out_AM_Register(code2 & 0x1f, stream); else - out_AM_Immediate(code2, 1, out + strlen(out)); + out_AM_Immediate(code2, 1, stream); return ret+3; } -static int dopUNHANDLED(unsigned ipc, unsigned pc, char *out) +static int dopUNHANDLED(unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "$%02X", readop(pc)); + util::stream_format(stream, "$%02X", readop(pc)); return 1; } -static int dop58UNHANDLED(unsigned ipc, unsigned pc, char *out) +static int dop58UNHANDLED(unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "$58"); + util::stream_format(stream, "$58"); return 1; } -static int dop59UNHANDLED(unsigned ipc, unsigned pc, char *out) +static int dop59UNHANDLED(unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "$59"); + util::stream_format(stream, "$59"); return 1; } -static int dop5AUNHANDLED(unsigned ipc, unsigned pc, char *out) +static int dop5AUNHANDLED(unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "$5A"); + util::stream_format(stream, "$5A"); return 1; } -static int dop5BUNHANDLED(unsigned ipc, unsigned pc, char *out) +static int dop5BUNHANDLED(unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "$5B"); + util::stream_format(stream, "$5B"); return 1; } -static int dop5CUNHANDLED(unsigned ipc, unsigned pc, char *out) +static int dop5CUNHANDLED(unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "$5C"); + util::stream_format(stream, "$5C"); return 1; } -static int dop5DUNHANDLED(unsigned ipc, unsigned pc, char *out) +static int dop5DUNHANDLED(unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "$5D"); + util::stream_format(stream, "$5D"); return 1; } -static int dop5EUNHANDLED(unsigned ipc, unsigned pc, char *out) +static int dop5EUNHANDLED(unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "$5E"); + util::stream_format(stream, "$5E"); return 1; } -static int dop5FUNHANDLED(unsigned ipc, unsigned pc, char *out) +static int dop5FUNHANDLED(unsigned ipc, unsigned pc, std::ostream &stream) { - sprintf(out, "$5F"); + util::stream_format(stream, "$5F"); return 1; } #define DEFINE_EASY_OPCODE(name, opnm, ftype, opsize1, opsize2) \ - static int dop ## name(unsigned ipc, unsigned pc, char *out) \ + static int dop ## name(unsigned ipc, unsigned pc, std::ostream &stream) \ { \ - return decode_ ## ftype(opnm, opsize1, opsize2, ipc, pc, out); \ + return decode_ ## ftype(opnm, opsize1, opsize2, ipc, pc, stream); \ } #define DEFINE_EASY_OPCODE_EX(name, opnm, ftype, opsize1, opsize2, flags) \ - static int dop ## name(unsigned ipc, unsigned pc, char *out) \ + static int dop ## name(unsigned ipc, unsigned pc, std::ostream &stream) \ { \ - return decode_ ## ftype(opnm, opsize1, opsize2, ipc, pc, out) | (flags); \ + return decode_ ## ftype(opnm, opsize1, opsize2, ipc, pc, stream) | (flags); \ } #define DEFINE_TRIPLE_OPCODE(name, string, ftype) \ @@ -862,7 +862,7 @@ DEFINE_EASY_OPCODE(XORBSD, "xorbsd", F7b, 0x80, 0x80) DEFINE_EASY_OPCODE(XORNBSU, "xornbsu", F7b, 0x80, 0x80) DEFINE_EASY_OPCODE(XORNBSD, "xornbsd", F7b, 0x80, 0x80) -static int (*const dasm_optable_58[32])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable_58[32])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x00 */ dopCMPCB, /* 0x01 */ dopCMPCFB, @@ -898,7 +898,7 @@ static int (*const dasm_optable_58[32])(unsigned ipc, unsigned pc, char *out) = /* 0x1F */ dop58UNHANDLED }; -static int (*const dasm_optable_59[32])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable_59[32])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x00 */ dopADDDC, /* 0x01 */ dopSUBDC, @@ -934,7 +934,7 @@ static int (*const dasm_optable_59[32])(unsigned ipc, unsigned pc, char *out) = /* 0x1F */ dop59UNHANDLED }; -static int (*const dasm_optable_5A[32])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable_5A[32])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x00 */ dopCMPCH, /* 0x01 */ dopCMPCFH, @@ -970,7 +970,7 @@ static int (*const dasm_optable_5A[32])(unsigned ipc, unsigned pc, char *out) = /* 0x1F */ dop5AUNHANDLED }; -static int (*const dasm_optable_5B[32])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable_5B[32])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x00 */ dopSCH0BSU, /* 0x01 */ dopSCH0BSD, @@ -1006,7 +1006,7 @@ static int (*const dasm_optable_5B[32])(unsigned ipc, unsigned pc, char *out) = /* 0x1F */ dop5BUNHANDLED }; -static int (*const dasm_optable_5C[32])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable_5C[32])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x00 */ dopCMPFS, /* 0x01 */ dop5CUNHANDLED, @@ -1042,7 +1042,7 @@ static int (*const dasm_optable_5C[32])(unsigned ipc, unsigned pc, char *out) = /* 0x1F */ dop5CUNHANDLED }; -static int (*const dasm_optable_5D[32])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable_5D[32])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x00 */ dopCMPBFS, /* 0x01 */ dopCMPBFZ, @@ -1078,7 +1078,7 @@ static int (*const dasm_optable_5D[32])(unsigned ipc, unsigned pc, char *out) = /* 0x1F */ dop5DUNHANDLED }; -static int (*const dasm_optable_5E[32])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable_5E[32])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x00 */ dopCMPFL, /* 0x01 */ dop5EUNHANDLED, @@ -1114,7 +1114,7 @@ static int (*const dasm_optable_5E[32])(unsigned ipc, unsigned pc, char *out) = /* 0x1F */ dop5EUNHANDLED }; -static int (*const dasm_optable_5F[32])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable_5F[32])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x00 */ dopCVTWS, /* 0x01 */ dopCVTSW, @@ -1150,7 +1150,7 @@ static int (*const dasm_optable_5F[32])(unsigned ipc, unsigned pc, char *out) = /* 0x1F */ dop5FUNHANDLED }; -static int (*const dasm_optable_C6[8])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable_C6[8])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x0 */ dopDBV, /* 0x1 */ dopDBL, @@ -1162,7 +1162,7 @@ static int (*const dasm_optable_C6[8])(unsigned ipc, unsigned pc, char *out) = /* 0x7 */ dopDBLE }; -static int (*const dasm_optable_C7[8])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable_C7[8])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x0 */ dopDBNV, /* 0x1 */ dopDBNL, @@ -1174,57 +1174,57 @@ static int (*const dasm_optable_C7[8])(unsigned ipc, unsigned pc, char *out) = /* 0x7 */ dopDBGT }; -static int dop58(unsigned ipc, unsigned pc, char *out) +static int dop58(unsigned ipc, unsigned pc, std::ostream &stream) { - return dasm_optable_58[readop(pc) & 0x1f](ipc, pc, out); + return dasm_optable_58[readop(pc) & 0x1f](ipc, pc, stream); } -static int dop59(unsigned ipc, unsigned pc, char *out) +static int dop59(unsigned ipc, unsigned pc, std::ostream &stream) { - return dasm_optable_59[readop(pc) & 0x1f](ipc, pc, out); + return dasm_optable_59[readop(pc) & 0x1f](ipc, pc, stream); } -static int dop5A(unsigned ipc, unsigned pc, char *out) +static int dop5A(unsigned ipc, unsigned pc, std::ostream &stream) { - return dasm_optable_5A[readop(pc) & 0x1f](ipc, pc, out); + return dasm_optable_5A[readop(pc) & 0x1f](ipc, pc, stream); } -static int dop5B(unsigned ipc, unsigned pc, char *out) +static int dop5B(unsigned ipc, unsigned pc, std::ostream &stream) { - return dasm_optable_5B[readop(pc) & 0x1f](ipc, pc, out); + return dasm_optable_5B[readop(pc) & 0x1f](ipc, pc, stream); } -static int dop5C(unsigned ipc, unsigned pc, char *out) +static int dop5C(unsigned ipc, unsigned pc, std::ostream &stream) { - return dasm_optable_5C[readop(pc) & 0x1f](ipc, pc, out); + return dasm_optable_5C[readop(pc) & 0x1f](ipc, pc, stream); } -static int dop5D(unsigned ipc, unsigned pc, char *out) +static int dop5D(unsigned ipc, unsigned pc, std::ostream &stream) { - return dasm_optable_5D[readop(pc) & 0x1f](ipc, pc, out); + return dasm_optable_5D[readop(pc) & 0x1f](ipc, pc, stream); } -static int dop5E(unsigned ipc, unsigned pc, char *out) +static int dop5E(unsigned ipc, unsigned pc, std::ostream &stream) { - return dasm_optable_5E[readop(pc) & 0x1f](ipc, pc, out); + return dasm_optable_5E[readop(pc) & 0x1f](ipc, pc, stream); } -static int dop5F(unsigned ipc, unsigned pc, char *out) +static int dop5F(unsigned ipc, unsigned pc, std::ostream &stream) { - return dasm_optable_5F[readop(pc) & 0x1f](ipc, pc, out); + return dasm_optable_5F[readop(pc) & 0x1f](ipc, pc, stream); } -static int dopC6(unsigned ipc, unsigned pc, char *out) +static int dopC6(unsigned ipc, unsigned pc, std::ostream &stream) { - return dasm_optable_C6[readop(pc) >> 5](ipc, pc, out); + return dasm_optable_C6[readop(pc) >> 5](ipc, pc, stream); } -static int dopC7(unsigned ipc, unsigned pc, char *out) +static int dopC7(unsigned ipc, unsigned pc, std::ostream &stream) { - return dasm_optable_C7[readop(pc) >> 5](ipc, pc, out); + return dasm_optable_C7[readop(pc) >> 5](ipc, pc, stream); } -static int (*const dasm_optable[256])(unsigned ipc, unsigned pc, char *out) = +static int (*const dasm_optable[256])(unsigned ipc, unsigned pc, std::ostream &stream) = { /* 0x00 */ dopHALT, /* 0x01 */ dopLDTASK, @@ -1484,16 +1484,16 @@ static int (*const dasm_optable[256])(unsigned ipc, unsigned pc, char *out) = /* 0xFF */ dopCLRTLB }; -CPU_DISASSEMBLE( v60 ) +CPU_DISASSEMBLE(v60) { rombase = oprom; pcbase = pc; - return dasm_optable[oprom[0]](pc, pc+1, buffer) | DASMFLAG_SUPPORTED; + return dasm_optable[oprom[0]](pc, pc+1, stream) | DASMFLAG_SUPPORTED; } -CPU_DISASSEMBLE( v70 ) +CPU_DISASSEMBLE(v70) { rombase = oprom; pcbase = pc; - return dasm_optable[oprom[0]](pc, pc+1, buffer) | DASMFLAG_SUPPORTED; + return dasm_optable[oprom[0]](pc, pc+1, stream) | DASMFLAG_SUPPORTED; } diff --git a/src/devices/cpu/v810/v810.cpp b/src/devices/cpu/v810/v810.cpp index ba002562548..ac5cdc75b25 100644 --- a/src/devices/cpu/v810/v810.cpp +++ b/src/devices/cpu/v810/v810.cpp @@ -46,10 +46,10 @@ v810_device::v810_device(const machine_config &mconfig, const char *tag, device_ } -offs_t v810_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t v810_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( v810 ); - return CPU_DISASSEMBLE_NAME(v810)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(v810)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/v810/v810.h b/src/devices/cpu/v810/v810.h index 7b9769cd3ff..e870f514132 100644 --- a/src/devices/cpu/v810/v810.h +++ b/src/devices/cpu/v810/v810.h @@ -106,7 +106,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: typedef uint32_t (v810_device::*opcode_func)(uint32_t op); diff --git a/src/devices/cpu/v810/v810dasm.cpp b/src/devices/cpu/v810/v810dasm.cpp index e4760f9a8e6..8b80a600a94 100644 --- a/src/devices/cpu/v810/v810dasm.cpp +++ b/src/devices/cpu/v810/v810dasm.cpp @@ -39,7 +39,7 @@ static const char *const dRegs[]= #define GET2s(opcode) dRegs[((opcode)>>5)&0x1f] #define GETRs(opcode) dRegs[32+((opcode)&0x1f)] -static offs_t internal_disasm_v810(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(v810) { uint32_t flags = 0; uint32_t opc,opc2; @@ -175,13 +175,3 @@ static offs_t internal_disasm_v810(cpu_device *device, std::ostream &stream, off } return size | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(v810) -{ - std::ostringstream stream; - offs_t result = internal_disasm_v810(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/z180/z180.cpp b/src/devices/cpu/z180/z180.cpp index 0eab56994b8..a9ba848ebdd 100644 --- a/src/devices/cpu/z180/z180.cpp +++ b/src/devices/cpu/z180/z180.cpp @@ -91,10 +91,10 @@ z180_device::z180_device(const machine_config &mconfig, const char *tag, device_ } -offs_t z180_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t z180_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( z180 ); - return CPU_DISASSEMBLE_NAME(z180)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(z180)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/z180/z180.h b/src/devices/cpu/z180/z180.h index 67befa3a4d3..a7d6676a0ed 100644 --- a/src/devices/cpu/z180/z180.h +++ b/src/devices/cpu/z180/z180.h @@ -153,7 +153,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: address_space_config m_program_config; diff --git a/src/devices/cpu/z180/z180dasm.cpp b/src/devices/cpu/z180/z180dasm.cpp index 038b1a5d23d..c5a3d9f0186 100644 --- a/src/devices/cpu/z180/z180dasm.cpp +++ b/src/devices/cpu/z180/z180dasm.cpp @@ -391,7 +391,7 @@ static int offs(int8_t offset) /**************************************************************************** * Disassemble opcode at PC and return number of bytes it takes ****************************************************************************/ -static offs_t internal_disasm_z180(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(z180) { const z80dasm *d; const char *src, *ixy; @@ -513,13 +513,3 @@ static offs_t internal_disasm_z180(cpu_device *device, std::ostream &stream, off return pos | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(z180) -{ - std::ostringstream stream; - offs_t result = internal_disasm_z180(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/z8/z8.cpp b/src/devices/cpu/z8/z8.cpp index 3ce48319632..19e27a4070c 100644 --- a/src/devices/cpu/z8/z8.cpp +++ b/src/devices/cpu/z8/z8.cpp @@ -197,10 +197,10 @@ z8611_device::z8611_device(const machine_config &mconfig, const char *_tag, devi } -offs_t z8_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t z8_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( z8 ); - return CPU_DISASSEMBLE_NAME(z8)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(z8)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/z8/z8.h b/src/devices/cpu/z8/z8.h index 1d3afb9aaa0..99c8e831677 100644 --- a/src/devices/cpu/z8/z8.h +++ b/src/devices/cpu/z8/z8.h @@ -61,7 +61,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 3; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; private: diff --git a/src/devices/cpu/z8/z8dasm.cpp b/src/devices/cpu/z8/z8dasm.cpp index d6eccb080fb..80f23fc312f 100644 --- a/src/devices/cpu/z8/z8dasm.cpp +++ b/src/devices/cpu/z8/z8dasm.cpp @@ -82,7 +82,7 @@ static const char *const CONDITION_CODE[16] = DISASSEMBLER ***************************************************************************/ -static offs_t internal_disasm_z8(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(z8) { const uint8_t *startrom = oprom; uint32_t flags = 0; @@ -377,13 +377,3 @@ static offs_t internal_disasm_z8(cpu_device *device, std::ostream &stream, offs_ return (oprom - startrom) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(z8) -{ - std::ostringstream stream; - offs_t result = internal_disasm_z8(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/z80/z80.cpp b/src/devices/cpu/z80/z80.cpp index 844a5b68373..9e0fec6b487 100644 --- a/src/devices/cpu/z80/z80.cpp +++ b/src/devices/cpu/z80/z80.cpp @@ -3669,10 +3669,10 @@ void z80_device::state_string_export(const device_state_entry &entry, std::strin // helper function //------------------------------------------------- -offs_t z80_device::disasm_disassemble( char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options ) +offs_t z80_device::disasm_disassemble( std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options ) { extern CPU_DISASSEMBLE( z80 ); - return CPU_DISASSEMBLE_NAME(z80)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(z80)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/z80/z80.h b/src/devices/cpu/z80/z80.h index af38e5fec0a..ecfd106e1c1 100644 --- a/src/devices/cpu/z80/z80.h +++ b/src/devices/cpu/z80/z80.h @@ -68,7 +68,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } virtual uint32_t disasm_max_opcode_bytes() const override { return 4; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; #undef PROTOTYPES #define PROTOTYPES(prefix) \ diff --git a/src/devices/cpu/z80/z80dasm.cpp b/src/devices/cpu/z80/z80dasm.cpp index 38b32aae482..2af88954943 100644 --- a/src/devices/cpu/z80/z80dasm.cpp +++ b/src/devices/cpu/z80/z80dasm.cpp @@ -413,7 +413,7 @@ static int offs(int8_t offset) /**************************************************************************** * Disassemble opcode at PC and return number of bytes it takes ****************************************************************************/ -static offs_t internal_disasm_z80(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(z80) { const z80dasm *d; const char *src, *ixy; @@ -527,13 +527,3 @@ static offs_t internal_disasm_z80(cpu_device *device, std::ostream &stream, offs return pos | s_flags[d->mnemonic] | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(z80) -{ - std::ostringstream stream; - offs_t result = internal_disasm_z80(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} \ No newline at end of file diff --git a/src/devices/cpu/z8000/8000dasm.cpp b/src/devices/cpu/z8000/8000dasm.cpp index 1c0bffcd2f1..5a6d6c51596 100644 --- a/src/devices/cpu/z8000/8000dasm.cpp +++ b/src/devices/cpu/z8000/8000dasm.cpp @@ -48,7 +48,7 @@ static const char *const ints[4] = { int z8k_segm; /* Current disassembler mode: 0 - non-segmented, 1 - segmented */ int z8k_segm_mode = Z8K_SEGM_MODE_AUTO; /* User disassembler mode setting: segmented, non-segmented, auto */ -static offs_t internal_disasm_z8000(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) +CPU_DISASSEMBLE(z8000) { int new_pc = pc, i, j, tmp; const char *src; @@ -311,13 +311,3 @@ static offs_t internal_disasm_z8000(cpu_device *device, std::ostream &stream, of } return (new_pc - pc) | flags | DASMFLAG_SUPPORTED; } - - -CPU_DISASSEMBLE(z8000) -{ - std::ostringstream stream; - offs_t result = internal_disasm_z8000(device, stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - return result; -} diff --git a/src/devices/cpu/z8000/z8000.cpp b/src/devices/cpu/z8000/z8000.cpp index f94b0c1d09c..be15136f4ff 100644 --- a/src/devices/cpu/z8000/z8000.cpp +++ b/src/devices/cpu/z8000/z8000.cpp @@ -61,10 +61,10 @@ z8001_device::z8001_device(const machine_config &mconfig, const char *tag, devic } -offs_t z8002_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t z8002_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { extern CPU_DISASSEMBLE( z8000 ); - return CPU_DISASSEMBLE_NAME(z8000)(this, buffer, pc, oprom, opram, options); + return CPU_DISASSEMBLE_NAME(z8000)(this, stream, pc, oprom, opram, options); } diff --git a/src/devices/cpu/z8000/z8000.h b/src/devices/cpu/z8000/z8000.h index 403b3ef729e..410696f500f 100644 --- a/src/devices/cpu/z8000/z8000.h +++ b/src/devices/cpu/z8000/z8000.h @@ -74,7 +74,7 @@ protected: // device_disasm_interface overrides virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } virtual uint32_t disasm_max_opcode_bytes() const override { return 6; } - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; address_space_config m_program_config; address_space_config m_io_config; diff --git a/src/devices/machine/eeprom.cpp b/src/devices/machine/eeprom.cpp index 7e3a552a4d4..f737e7a5c03 100644 --- a/src/devices/machine/eeprom.cpp +++ b/src/devices/machine/eeprom.cpp @@ -81,7 +81,7 @@ void eeprom_base_device::static_set_default_data(device_t &device, const uint8_t { eeprom_base_device &eeprom = downcast(device); assert(eeprom.m_data_bits == 8); - eeprom.m_default_data.u8 = const_cast(data); + eeprom.m_default_data = data; eeprom.m_default_data_size = size; } @@ -89,7 +89,7 @@ void eeprom_base_device::static_set_default_data(device_t &device, const uint16_ { eeprom_base_device &eeprom = downcast(device); assert(eeprom.m_data_bits == 16); - eeprom.m_default_data.u16 = const_cast(data); + eeprom.m_default_data = data; eeprom.m_default_data_size = size / 2; } @@ -245,15 +245,15 @@ void eeprom_base_device::nvram_default() internal_write(offs, default_value); // handle hard-coded data from the driver - if (m_default_data.u8 != nullptr) + if (m_default_data != nullptr) { osd_printf_verbose("Warning: Driver-specific EEPROM defaults are going away soon.\n"); for (offs_t offs = 0; offs < m_default_data_size; offs++) { if (m_data_bits == 8) - internal_write(offs, m_default_data.u8[offs]); + internal_write(offs, static_cast(m_default_data)[offs]); else - internal_write(offs, m_default_data.u16[offs]); + internal_write(offs, static_cast(m_default_data)[offs]); } } diff --git a/src/devices/machine/eeprom.h b/src/devices/machine/eeprom.h index 450a7f774d8..e386d5f42cf 100644 --- a/src/devices/machine/eeprom.h +++ b/src/devices/machine/eeprom.h @@ -101,7 +101,7 @@ protected: uint32_t m_cells; uint8_t m_address_bits; uint8_t m_data_bits; - generic_ptr m_default_data; + const void * m_default_data; uint32_t m_default_data_size; uint32_t m_default_value; bool m_default_value_set; diff --git a/src/devices/machine/intelfsh.cpp b/src/devices/machine/intelfsh.cpp index 88e3cdddec8..fcc24af7904 100644 --- a/src/devices/machine/intelfsh.cpp +++ b/src/devices/machine/intelfsh.cpp @@ -480,12 +480,12 @@ void intelfsh_device::nvram_default() if (m_bits == 8) { for (offs_t offs = 0; offs < bytes; offs++) - m_data[offs] = m_region->u8(offs); + m_data[offs] = m_region->as_u8(offs); } else { for (offs_t offs = 0; offs < bytes; offs += 2) { - uint16_t v = m_region->u16(offs / 2); + uint16_t v = m_region->as_u16(offs / 2); m_data[offs] = v >> 8; m_data[offs+1] = v; } diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index 4fa344e4f4c..3183f8746fb 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -535,7 +535,7 @@ ATTR_COLD uint64_t netlist_mame_cpu_device_t::execute_cycles_to_clocks(uint64_t return cycles; } -ATTR_COLD offs_t netlist_mame_cpu_device_t::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +ATTR_COLD offs_t netlist_mame_cpu_device_t::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { //char tmp[16]; unsigned startpc = pc; @@ -544,11 +544,9 @@ ATTR_COLD offs_t netlist_mame_cpu_device_t::disasm_disassemble(char *buffer, off { int dpc = netlist().queue().size() - relpc - 1; // FIXME: 50 below fixes crash in mame-debugger. It's based on try on error. - snprintf(buffer, 50, "%c %s @%10.7f", (relpc == 0) ? '*' : ' ', netlist().queue()[dpc].m_object->name().cstr(), + util::stream_format(stream, "%c %s @%10.7f", (relpc == 0) ? '*' : ' ', netlist().queue()[dpc].m_object->name().cstr(), netlist().queue()[dpc].m_exec_time.as_double()); } - else - sprintf(buffer, "%s", ""); pc+=1; return (pc - startpc); diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h index e1b5842fe5c..7d5d8848df6 100644 --- a/src/devices/machine/netlist.h +++ b/src/devices/machine/netlist.h @@ -210,7 +210,7 @@ protected: // device_disasm_interface overrides ATTR_COLD virtual uint32_t disasm_min_opcode_bytes() const override { return 1; } ATTR_COLD virtual uint32_t disasm_max_opcode_bytes() const override { return 1; } - ATTR_COLD virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; + ATTR_COLD virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override; // device_memory_interface overrides diff --git a/src/devices/machine/pci.cpp b/src/devices/machine/pci.cpp index c10a58306a8..dd8e767f5a8 100644 --- a/src/devices/machine/pci.cpp +++ b/src/devices/machine/pci.cpp @@ -150,7 +150,7 @@ WRITE32_MEMBER(pci_device::address_base_w) if(bank_reg_infos[offset].hi) bank_infos[bid].adr = (bank_infos[bid].adr & 0xffffffff) | (uint64_t(data) << 32); else { - bank_infos[bid].adr = (bank_infos[bid].adr & U64(0xffffffff00000000)) | data; + bank_infos[bid].adr = (bank_infos[bid].adr & 0xffffffff00000000U) | data; } remap_cb(); } diff --git a/src/devices/machine/z80scc.cpp b/src/devices/machine/z80scc.cpp index e2b14c3ec63..51e92d27a55 100644 --- a/src/devices/machine/z80scc.cpp +++ b/src/devices/machine/z80scc.cpp @@ -88,6 +88,7 @@ DONE (x) (p=partly) NMOS CMOS ESCC EMSCC #define LOGRCV(x) {} LOGPRINT(x) #define LOGCTS(x) {} LOGPRINT(x) #define LOGDCD(x) {} LOGPRINT(x) +#define LOGSYNC(x) {} LOGPRINT(x) #if VERBOSE == 2 #define logerror printf #endif @@ -856,7 +857,7 @@ z80scc_channel::z80scc_channel(const machine_config &mconfig, const char *tag, d m_tx_clock(0), m_dtr(0), m_rts(0), - m_sync(0) + m_sync_pattern(0) #if START_BIT_HUNT ,m_rcv_mode(RCV_IDLE) #endif @@ -956,7 +957,7 @@ void z80scc_channel::device_start() save_item(NAME(m_tx_clock)); save_item(NAME(m_dtr)); save_item(NAME(m_rts)); - save_item(NAME(m_sync)); + save_item(NAME(m_sync_pattern)); device_serial_interface::register_save_state(machine().save(), this); } @@ -1434,6 +1435,7 @@ uint8_t z80scc_channel::do_sccreg_rr6() LOGR(("%s\n", FUNCNAME)); if (m_wr15 & WR15_STATUS_FIFO) { + LOGSYNC((" - Status FIFO for synchronous mode - not implemented\n")); logerror(" - Status FIFO for synchronous mode - not implemented\n"); return 0; } @@ -1635,13 +1637,13 @@ void z80scc_channel::do_sccreg_wr0_resets(uint8_t data) LOG((" CRC_RESET_NULL\n")); break; case WR0_CRC_RESET_RX: /* In Synchronous mode: all Os (zeros) (CCITT-O CRC-16) */ - LOG((" CRC_RESET_RX - not implemented\n")); + LOGSYNC((" CRC_RESET_RX - not implemented\n")); break; case WR0_CRC_RESET_TX: /* In HDLC mode: all 1s (ones) (CCITT-1) */ - LOG((" CRC_RESET_TX - not implemented\n")); + LOGSYNC((" CRC_RESET_TX - not implemented\n")); break; case WR0_CRC_RESET_TX_UNDERRUN: /* Resets Tx underrun/EOM bit (D6 of the RRO register) */ - LOG((" CRC_RESET_TX_UNDERRUN - not implemented\n")); + LOGSYNC((" CRC_RESET_TX_UNDERRUN - not implemented\n")); break; default: /* Will not happen unless someone messes with the mask */ logerror(" Wrong CRC reset/init command:%02x\n", data & WR0_CRC_RESET_CODE_MASK); @@ -1793,9 +1795,9 @@ void z80scc_channel::do_sccreg_wr1(uint8_t data) m_uart->check_interrupts(); } -/*WR2 is the interrupt vector register. Only one vector register exists in the SCC, and it can be -accessed through either channel. The interrupt vector can be modified by status information. This -is controlled by the Vector Includes Status (VIS) and the Status High/Status Low bits in WR9.*/ +/* WR2 is the interrupt vector register. Only one vector register exists in the SCC, and it can be + accessed through either channel. The interrupt vector can be modified by status information. This + is controlled by the Vector Includes Status (VIS) and the Status High/Status Low bits in WR9.*/ void z80scc_channel::do_sccreg_wr2(uint8_t data) { LOG(("%s(%02x) Setting the interrupt vector\n", FUNCNAME, data)); @@ -1806,13 +1808,29 @@ void z80scc_channel::do_sccreg_wr2(uint8_t data) m_uart->check_interrupts(); } +/* + In the SDLC modes, the Sync/Hunt bit is initially set by the Enter Hunt Mode command or when + the receiver is disabled. It is reset when the opening flag of the first frame is detected by the SCC. + An External/Status interrupt is also generated if the Sync/Hunt IE bit is set. Unlike the Monosync + and Bisync modes, once the Sync/Hunt bit is reset in SDLC mode, it does not need to be set when + the end of the frame is detected. The SCC automatically maintains synchronization. The only way + the Sync/Hunt bit is set again is by the Enter Hunt Mode command or by disabling the receiver.*/ void z80scc_channel::do_sccreg_wr3(uint8_t data) { LOG(("%s(%02x) Setting up the receiver\n", FUNCNAME, data)); m_wr3 = data; - LOG(("- Receiver Enable %u\n", (data & WR3_RX_ENABLE) ? 1 : 0)); - LOG(("- Auto Enables %u\n", (data & WR3_AUTO_ENABLES) ? 1 : 0)); + LOG(("- Receiver Enable: %u\n", (data & WR3_RX_ENABLE) ? 1 : 0)); + LOG(("- Sync Char Load Inhibit %u\n", (data & WR3_SYNC_CHAR_LOAD_INHIBIT) ? 1 : 0)); + LOG(("- Address Search Mode %u\n", (data & WR3_ADDRESS_SEARCH_MODE) ? 1 : 0)); + LOG(("- Rx CRC Enable %u\n", (data & WR3_RX_CRC_ENABLE) ? 1 : 0)); + LOG(("- Enter Hunt Mode %u\n", (data & WR3_ENTER_HUNT_MODE) ? 1 : 0)); + LOG(("- Auto Enables %u\n", (data & WR3_AUTO_ENABLES) ? 1 : 0)); LOG(("- Receiver Bits/Character %u\n", get_rx_word_length())); + + if ((m_wr3 & WR3_ENTER_HUNT_MODE) || ((m_wr3 & WR3_RX_ENABLE) == 0)) + { + m_rr0 |= RR0_SYNC_HUNT; // Set the sync/hunt bit + } update_serial(); receive_register_reset(); } @@ -1827,10 +1845,14 @@ void z80scc_channel::do_sccreg_wr4(uint8_t data) else { m_wr4 = data; - LOG(("- Parity Enable %u\n", (data & WR4_PARITY_ENABLE) ? 1 : 0)); - LOG(("- Parity %s\n", (data & WR4_PARITY_EVEN) ? "Even" : "Odd")); - LOG(("- Stop Bits %s\n", stop_bits_tostring(get_stop_bits()))); - LOG(("- Clock Mode %uX\n", get_clock_mode())); + LOG(("- Parity : %s\n", (data & WR4_PARITY_ENABLE) ? ((data & WR4_PARITY_EVEN) ? "Even" : "Odd") : "None")); + LOG(("- Stop Bits : %s\n", data & WR4_STOP_BITS_MASK ? stop_bits_tostring(get_stop_bits()) : "not used, sync modes enabled" )); + LOG(("- Sync Mode : %s\n", !(data & WR4_STOP_BITS_MASK) ? + (data & WR4_BIT5 ? + (data & WR4_BIT4 ? "External Sync Mode - /SYNC is used as input!" : "SDLC - not implemented") + : (data & WR4_BIT4 ? "16 bit" : "8 bit")) + : "Disabled")); + LOG(("- Clock Mode: %uX\n", get_clock_mode())); update_serial(); safe_transmit_register_reset(); receive_register_reset(); @@ -1861,13 +1883,13 @@ void z80scc_channel::do_sccreg_wr5(uint8_t data) void z80scc_channel::do_sccreg_wr6(uint8_t data) { LOG(("%s(%02x) Transmit sync\n", FUNCNAME, data)); - m_sync = (m_sync & 0xff00) | data; + m_sync_pattern = (m_sync_pattern & 0xff00) | data; } void z80scc_channel::do_sccreg_wr7(uint8_t data) { LOG(("%s(%02x) Receive sync\n", FUNCNAME, data)); - m_sync = (data << 8) | (m_sync & 0xff); + m_sync_pattern = (data << 8) | (m_sync_pattern & 0xff); } /* WR8 is the transmit buffer register */ @@ -1924,13 +1946,21 @@ void z80scc_channel::do_sccreg_wr9(uint8_t data) } } -/* WR10 contains miscellaneous control bits for both the receiver and the transmitter. Bit positions -for WR10 are displayed in Figure . On the ESCC and 85C30 with the Extended Read option -enabled, this register may be read as RR11.*/ +/* WR10 contains miscellaneous control bits for both the receiver and the transmitter. + On the ESCC and 85C30 with the Extended Read option enabled, this register may be read as RR11.*/ void z80scc_channel::do_sccreg_wr10(uint8_t data) { m_wr10 = data; LOG(("\"%s\": %c : %s Misc Tx/Rx Control %02x - not implemented \n", m_owner->tag(), 'A' + m_index, FUNCNAME, data)); + LOG(("- 6/8 bit sync %d\n", data & WR10_8_6_BIT_SYNC ? 1 : 0)); + LOG(("- Loop Mode %d\n", data & WR10_LOOP_MODE ? 1 : 0)); + LOG(("- Abort/Flag on underrun %d\n", data & WR10_ABORT_FLAG_UNDERRUN ? 1 : 0)); + LOG(("- Mark/Flag Idle line %d\n", data & WR10_MARK_FLAG_IDLE ? 1 : 0)); + LOG(("- Go active on poll %d\n", data & WR10_GO_ACTIVE_ON_POLL ? 1 : 0)); + LOG(("- Encoding %s\n", data & WR10_BIT6 ? + (data & WR10_BIT5 ? "FM0" : "FM1") : + (data & WR10_BIT5 ? "NRZI" : "NRZ") )); + LOG(("- CRC Preset %d\n", data & WR10_CRC_PRESET ? 1 : 0)); } /* WR11 is the Clock Mode Control register. The bits in this register control the sources of both the @@ -1948,7 +1978,7 @@ void z80scc_channel::do_sccreg_wr11(uint8_t data) /SYNC pin is unavailable for other use. The /SYNC signal is forced to zero internally. A hardware reset forces /NO XTAL. (At least 20 ms should be allowed after this bit is set to allow the oscillator to stabilize.)*/ - LOG((" Clock type %s\n", data & WR11_RCVCLK_TYPE ? "Crystal oscillator between RTxC and /SYNC pins" : "TTL level on RTxC pin")); + LOG((" Clock type %s\n", data & WR11_RCVCLK_TYPE ? "Crystal oscillator between RTxC and /SYNC pins" : "TTL level on RTxC pin and /SYNC can be used")); /*Bits 6 and 5: Receiver Clock select bits 1 and 0 These bits determine the source of the receive clock as listed below. They do not interfere with any of the modes of operation in the SCC, but simply control a multiplexer just @@ -2137,16 +2167,16 @@ void z80scc_channel::do_sccreg_wr14(uint8_t data) #define WR15NO "not implemented" void z80scc_channel::do_sccreg_wr15(uint8_t data) { - LOGINT(("%s(%02x) \"%s\": %c : External/Status Control Bits\n", + LOG(("%s(%02x) \"%s\": %c : External/Status Control Bits\n", FUNCNAME, data, m_owner->tag(), 'A' + m_index)); - LOGINT(("WR7 prime ints : %s\n", data & WR15_WR7PRIME ? WR15NO : "disabled")); - LOGINT(("Zero count ints : %s\n", data & WR15_ZEROCOUNT ? WR15NO : "disabled")); - LOGINT(("14 bit Status FIFO : %s\n", data & WR15_STATUS_FIFO ? WR15NO : "disabled")); - LOGINT(("DCD ints : %s\n", data & WR15_DCD ? WR15EN : "disabled")); - LOGINT(("SYNC/Hunt ints : %s\n", data & WR15_SYNC ? WR15NO : "disabled")); - LOGINT(("CTS ints : %s\n", data & WR15_CTS ? WR15EN : "disabled")); - LOGINT(("Tx underr./EOM ints: %s\n", data & WR15_TX_EOM ? WR15NO : "disabled")); - LOGINT(("Break/Abort ints : %s\n", data & WR15_BREAK_ABORT ? WR15NO : "disabled")); + LOG(("WR7 prime ints : %s\n", data & WR15_WR7PRIME ? WR15NO : "disabled")); + LOG(("Zero count ints : %s\n", data & WR15_ZEROCOUNT ? WR15NO : "disabled")); + LOG(("14 bit Status FIFO : %s\n", data & WR15_STATUS_FIFO ? WR15NO : "disabled")); + LOG(("DCD ints : %s\n", data & WR15_DCD ? WR15EN : "disabled")); + LOG(("SYNC/Hunt ints : %s\n", data & WR15_SYNC ? WR15NO : "disabled")); + LOG(("CTS ints : %s\n", data & WR15_CTS ? WR15EN : "disabled")); + LOG(("Tx underr./EOM ints: %s\n", data & WR15_TX_EOM ? WR15NO : "disabled")); + LOG(("Break/Abort ints : %s\n", data & WR15_BREAK_ABORT ? WR15NO : "disabled")); m_wr15 = data; } @@ -2578,11 +2608,15 @@ WRITE_LINE_MEMBER( z80scc_channel::ri_w ) } //------------------------------------------------- -// sync_w - sync handler +// sync_w - sync handler for external sync mode //------------------------------------------------- WRITE_LINE_MEMBER( z80scc_channel::sync_w ) { - LOGINT(("\"%s\": %c : SYNC %u - not implemented\n", m_owner->tag(), 'A' + m_index, state)); + LOGSYNC(("\"%s\": %c : SYNC %u\n", m_owner->tag(), 'A' + m_index, state)); + if ((m_rr0 & RR0_SYNC_HUNT) != (state ? RR0_SYNC_HUNT : 0)) // SCC change detection logic + { + if (state) m_rr0 |= RR0_SYNC_HUNT; else m_rr0 &= ~RR0_SYNC_HUNT; // Raw pin/status value + } } //------------------------------------------------- diff --git a/src/devices/machine/z80scc.h b/src/devices/machine/z80scc.h index 6884221fcf0..c2b0f81a68d 100644 --- a/src/devices/machine/z80scc.h +++ b/src/devices/machine/z80scc.h @@ -310,10 +310,10 @@ protected: { REG_WR0_COMMAND_REGPT = 0, REG_WR1_INT_DMA_ENABLE = 1, - REG_WR2_INT_VECTOR = 2, - REG_WR3_RX_CONTROL = 3, - REG_WR4_RX_TX_MODES = 4, - REG_WR5_TX_CONTROL = 5, + REG_WR2_INT_VECTOR = 2, + REG_WR3_RX_CONTROL = 3, + REG_WR4_RX_TX_MODES = 4, + REG_WR5_TX_CONTROL = 5, REG_WR6_SYNC_OR_SDLC_A = 6, REG_WR7_SYNC_OR_SDLC_F = 7, REG_WR8_TRANSMIT_DATA = 8, @@ -322,7 +322,7 @@ protected: REG_WR11_CLOCK_MODES = 11, REG_WR12_LO_BAUD_GEN = 12, REG_WR13_HI_BAUD_GEN = 13, - REG_WR14_MISC_CTRL = 14, + REG_WR14_MISC_CTRL = 14, REG_WR15_EXT_ST_INT_CTRL= 15 }; @@ -332,24 +332,24 @@ protected: RR0_ZC = 0x02, RR0_TX_BUFFER_EMPTY = 0x04, RR0_DCD = 0x08, - RR0_SYNC_HUNT = 0x10, // SIO bit, not supported - RR0_CTS = 0x20, // SIO bit - RR0_TX_UNDERRUN = 0x40, // SIO bit, not supported - RR0_BREAK_ABORT = 0x80 // SIO bit, not supported + RR0_SYNC_HUNT = 0x10, + RR0_CTS = 0x20, + RR0_TX_UNDERRUN = 0x40, + RR0_BREAK_ABORT = 0x80 }; enum { - RR1_ALL_SENT = 0x01, // SIO/SCC bit - RR1_RESIDUE_CODE_MASK = 0x0e, // SIO/SCC bits, not supported - RR1_PARITY_ERROR = 0x10, // SIO/SCC bits - RR1_RX_OVERRUN_ERROR = 0x20, // SIO/SCC bits - RR1_CRC_FRAMING_ERROR = 0x40, // SIO/SCC bits - RR1_END_OF_FRAME = 0x80 // SIO/SCC bits, not supported + RR1_ALL_SENT = 0x01, + RR1_RESIDUE_CODE_MASK = 0x0e, + RR1_PARITY_ERROR = 0x10, + RR1_RX_OVERRUN_ERROR = 0x20, + RR1_CRC_FRAMING_ERROR = 0x40, + RR1_END_OF_FRAME = 0x80 }; enum - { // TODO: overload SIO functionality + { RR2_INT_VECTOR_MASK = 0xff, // SCC channel A, SIO channel B (special case) RR2_INT_VECTOR_V1 = 0x02, // SIO (special case) /SCC Channel B RR2_INT_VECTOR_V2 = 0x04, // SIO (special case) /SCC Channel B @@ -409,21 +409,21 @@ protected: WR1_RX_INT_MODE_MASK = 0x18, WR1_RX_INT_DISABLE = 0x00, WR1_RX_INT_FIRST = 0x08, - WR1_RX_INT_ALL_PARITY = 0x10, // not supported + WR1_RX_INT_ALL_PARITY = 0x10, WR1_RX_INT_ALL = 0x18, - WR1_WRDY_ON_RX_TX = 0x20, // not supported - WR1_WRDY_FUNCTION = 0x40, // not supported - WR1_WRDY_ENABLE = 0x80 // not supported + WR1_WRDY_ON_RX_TX = 0x20, + WR1_WRDY_FUNCTION = 0x40, + WR1_WRDY_ENABLE = 0x80 }; enum { - WR3_RX_ENABLE = 0x01, - WR3_SYNC_CHAR_LOAD_INHIBIT = 0x02, // not supported - WR3_ADDRESS_SEARCH_MODE = 0x04, // not supported - WR3_RX_CRC_ENABLE = 0x08, // not supported - WR3_ENTER_HUNT_PHASE = 0x10, // not supported - WR3_AUTO_ENABLES = 0x20, + WR3_RX_ENABLE = 0x01, + WR3_SYNC_CHAR_LOAD_INHIBIT = 0x02, + WR3_ADDRESS_SEARCH_MODE = 0x04, + WR3_RX_CRC_ENABLE = 0x08, + WR3_ENTER_HUNT_MODE = 0x10, + WR3_AUTO_ENABLES = 0x20, WR3_RX_WORD_LENGTH_MASK = 0xc0, WR3_RX_WORD_LENGTH_5 = 0x00, WR3_RX_WORD_LENGTH_7 = 0x40, @@ -437,13 +437,15 @@ protected: WR4_PARITY_EVEN = 0x02, WR4_STOP_BITS_MASK = 0x0c, WR4_STOP_BITS_1 = 0x04, - WR4_STOP_BITS_1_5 = 0x08, // not supported + WR4_STOP_BITS_1_5 = 0x08, WR4_STOP_BITS_2 = 0x0c, - WR4_SYNC_MODE_MASK = 0x30, // not supported - WR4_SYNC_MODE_8_BIT = 0x00, // not supported - WR4_SYNC_MODE_16_BIT = 0x10, // not supported - WR4_SYNC_MODE_SDLC = 0x20, // not supported - WR4_SYNC_MODE_EXT = 0x30, // not supported + WR4_SYNC_MODE_MASK = 0x30, + WR4_SYNC_MODE_8_BIT = 0x00, + WR4_SYNC_MODE_16_BIT = 0x10, + WR4_BIT4 = 0x10, + WR4_SYNC_MODE_SDLC = 0x20, + WR4_BIT5 = 0x20, + WR4_SYNC_MODE_EXT = 0x30, WR4_CLOCK_RATE_MASK = 0xc0, WR4_CLOCK_RATE_X1 = 0x00, WR4_CLOCK_RATE_X16 = 0x40, @@ -453,11 +455,11 @@ protected: enum { - WR5_TX_CRC_ENABLE = 0x01, // not supported - WR5_RTS = 0x02, - WR5_CRC16 = 0x04, // not supported - WR5_TX_ENABLE = 0x08, - WR5_SEND_BREAK = 0x10, + WR5_TX_CRC_ENABLE = 0x01, + WR5_RTS = 0x02, + WR5_CRC16 = 0x04, + WR5_TX_ENABLE = 0x08, + WR5_SEND_BREAK = 0x10, WR5_TX_WORD_LENGTH_MASK = 0x60, WR5_TX_WORD_LENGTH_5 = 0x00, WR5_TX_WORD_LENGTH_6 = 0x40, @@ -479,14 +481,31 @@ protected: WR9_CMD_CHNB_RESET = 0x40, WR9_CMD_CHNA_RESET = 0x80, WR9_CMD_HW_RESET = 0xC0, - WR9_BIT_VIS = 0x01, - WR9_BIT_NV = 0x02, - WR9_BIT_DLC = 0x04, - WR9_BIT_MIE = 0x08, + WR9_BIT_VIS = 0x01, + WR9_BIT_NV = 0x02, + WR9_BIT_DLC = 0x04, + WR9_BIT_MIE = 0x08, WR9_BIT_SHSL = 0x10, WR9_BIT_IACK = 0x20 }; + enum + { + WR10_8_6_BIT_SYNC = 0x01, + WR10_LOOP_MODE = 0x02, + WR10_ABORT_FLAG_UNDERRUN = 0x04, + WR10_MARK_FLAG_IDLE = 0x08, + WR10_GO_ACTIVE_ON_POLL = 0x10, + WR10_ENCODING_MASK = 0x60, + WR10_NRZ_ENCODING = 0x00, + WR10_NRZI_ENCODING = 0x20, + WR10_BIT5 = 0x20, + WR10_FM1_ENCODING = 0x40, + WR10_BIT6 = 0x40, + WR10_FM0_ENCODING = 0x60, + WR10_CRC_PRESET = 0x80 + }; + enum { WR11_RCVCLK_TYPE = 0x80, @@ -600,7 +619,7 @@ protected: int m_rts; // request to send // synchronous state - uint16_t m_sync; // sync character + uint16_t m_sync_pattern; // sync character int m_rcv_mode; int m_index; diff --git a/src/devices/sound/fm.cpp b/src/devices/sound/fm.cpp index 2a8436f3c89..d5ecc730f27 100644 --- a/src/devices/sound/fm.cpp +++ b/src/devices/sound/fm.cpp @@ -1678,7 +1678,7 @@ static inline void CSMKeyControll(uint8_t type, FM_CH *CH) } } -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H /* FM channel save , internal state only */ static void FMsave_state_channel(device_t *device,FM_CH *CH,int num_ch) { @@ -1717,7 +1717,7 @@ static void FMsave_state_st(device_t *device,FM_ST *ST) device->save_item(NAME(ST->TB) ); device->save_item(NAME(ST->TBC) ); } -#endif /* _STATE_H */ +#endif /* MAME_EMU_SAVE_H */ #if BUILD_OPN @@ -2207,7 +2207,7 @@ void ym2203_reset_chip(void *chip) for(i = 0x26 ; i >= 0x20 ; i-- ) OPNWriteReg(OPN,i,0); } -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H void ym2203_postload(void *chip) { if (chip) @@ -2250,7 +2250,7 @@ static void YM2203_save_state(YM2203 *F2203, device_t *device) device->save_item (NAME(F2203->OPN.SL3.fn_h)); device->save_item (NAME(F2203->OPN.SL3.kcode)); } -#endif /* _STATE_H */ +#endif /* MAME_EMU_SAVE_H */ /* ---------- Initialize YM2203 emulator(s) ---------- 'num' is the number of virtual YM2203s to allocate @@ -2282,7 +2282,7 @@ void * ym2203_init(void *param, device_t *device, int clock, int rate, F2203->OPN.ST.IRQ_Handler = IRQHandler; F2203->OPN.ST.SSG = ssg; -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H YM2203_save_state(F2203, device); #endif return F2203; @@ -2659,7 +2659,7 @@ static void FM_ADPCMAWrite(YM2610 *F2610,int r,int v) } } -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H /* FM channel save , internal state only */ static void FMsave_state_adpcma(device_t *device,ADPCM_CH *adpcm) { @@ -2676,7 +2676,7 @@ static void FMsave_state_adpcma(device_t *device,ADPCM_CH *adpcm) device->save_item(NAME(adpcm->adpcm_out), ch); } } -#endif /* _STATE_H */ +#endif /* MAME_EMU_SAVE_H */ #endif /* (BUILD_YM2608||BUILD_YM2610||BUILD_YM2610B) */ @@ -2867,7 +2867,7 @@ void ym2608_update_one(void *chip, FMSAMPLE **buffer, int length) FM_STATUS_SET(&OPN->ST, 0); } -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H void ym2608_postload(void *chip) { if (chip) @@ -2929,7 +2929,7 @@ static void YM2608_save_state(YM2608 *F2608, device_t *device) /* Delta-T ADPCM unit */ YM_DELTAT_savestate(device,&F2608->deltaT); } -#endif /* _STATE_H */ +#endif /* MAME_EMU_SAVE_H */ static void YM2608_deltat_status_set(void *chip, uint8_t changebits) { @@ -2990,7 +2990,7 @@ void * ym2608_init(void *param, device_t *device, int clock, int rate, Init_ADPCMATable(); -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H YM2608_save_state(F2608, device); #endif return F2608; @@ -3544,7 +3544,7 @@ void ym2610b_update_one(void *chip, FMSAMPLE **buffer, int length) #endif /* BUILD_YM2610B */ -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H void ym2610_postload(void *chip) { if (chip) @@ -3610,7 +3610,7 @@ static void YM2610_save_state(YM2610 *F2610, device_t *device) /* Delta-T ADPCM unit */ YM_DELTAT_savestate(device,&F2610->deltaT); } -#endif /* _STATE_H */ +#endif /* MAME_EMU_SAVE_H */ static void YM2610_deltat_status_set(void *chip, uint8_t changebits) { @@ -3664,7 +3664,7 @@ void *ym2610_init(void *param, device_t *device, int clock, int rate, F2610->deltaT.status_change_EOS_bit = 0x80; /* status flag: set bit7 on End Of Sample */ Init_ADPCMATable(); -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H YM2610_save_state(F2610, device); #endif return F2610; diff --git a/src/devices/sound/fm2612.cpp b/src/devices/sound/fm2612.cpp index 40a7f317922..f9b2e133904 100644 --- a/src/devices/sound/fm2612.cpp +++ b/src/devices/sound/fm2612.cpp @@ -1689,7 +1689,7 @@ static inline void CSMKeyControll(fm2612_FM_OPN *OPN, fm2612_FM_CH *CH) OPN->SL3.key_csm = 1; } -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H /* FM channel save , internal state only */ static void FMsave_state_channel(device_t *device,fm2612_FM_CH *CH,int num_ch) { @@ -1728,7 +1728,7 @@ static void FMsave_state_st(device_t *device,fm2612_FM_ST *ST) device->save_item(NAME(ST->TB) ); device->save_item(NAME(ST->TBC) ); } -#endif /* _STATE_H */ +#endif /* MAME_EMU_SAVE_H */ #if BUILD_OPN /* write a OPN mode register 0x20-0x2f */ @@ -2320,7 +2320,7 @@ void ym2612_update_one(void *chip, FMSAMPLE **buffer, int length) INTERNAL_TIMER_B(&OPN->ST,length) } -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H void ym2612_postload(void *chip) { if (chip) @@ -2363,7 +2363,7 @@ static void YM2612_save_state(YM2612 *F2612, device_t *device) /* address register1 */ device->save_item(NAME(F2612->addr_A1)); } -#endif /* _STATE_H */ +#endif /* MAME_EMU_SAVE_H */ /* initialize YM2612 emulator(s) */ void * ym2612_init(void *param, device_t *device, int clock, int rate, @@ -2389,7 +2389,7 @@ void * ym2612_init(void *param, device_t *device, int clock, int rate, F2612->OPN.ST.timer_handler = timer_handler; F2612->OPN.ST.IRQ_Handler = IRQHandler; -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H YM2612_save_state(F2612, device); #endif return F2612; diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp index f7907d04531..8c98cff60ec 100644 --- a/src/devices/sound/pokey.cpp +++ b/src/devices/sound/pokey.cpp @@ -14,7 +14,7 @@ * - changed audio emulation to emulate borrow 3 clock delay and * proper channel reset. New frequency only becomes effective * after the counter hits 0. Emulation also treats counters - * as 8 bit counters which are linked now instead of monolytic + * as 8 bit counters which are linked now instead of monolithic * 16 bit counters. * * 4.51: diff --git a/src/devices/sound/rf5c400.cpp b/src/devices/sound/rf5c400.cpp index c6bfe8797d2..2399acdcd04 100644 --- a/src/devices/sound/rf5c400.cpp +++ b/src/devices/sound/rf5c400.cpp @@ -202,7 +202,7 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, stream_sample_t * if ( (pos>>16) > m_rom.length() || (pos>>16) > end) { pos -= loop<<16; - pos &= U64(0xFFFFFF0000); + pos &= 0xFFFFFF0000U; } } diff --git a/src/devices/sound/ymdeltat.cpp b/src/devices/sound/ymdeltat.cpp index 68ad3add2e8..835443b67dd 100644 --- a/src/devices/sound/ymdeltat.cpp +++ b/src/devices/sound/ymdeltat.cpp @@ -458,7 +458,7 @@ void YM_DELTAT_postload(YM_DELTAT *DELTAT,uint8_t *regs) } void YM_DELTAT_savestate(device_t *device,YM_DELTAT *DELTAT) { -#ifdef __SAVE_H__ +#ifdef MAME_EMU_SAVE_H device->save_item(NAME(DELTAT->portstate)); device->save_item(NAME(DELTAT->now_addr)); device->save_item(NAME(DELTAT->now_step)); diff --git a/src/devices/video/epic12.cpp b/src/devices/video/epic12.cpp index dab2e84a748..bcf4e04ab18 100644 --- a/src/devices/video/epic12.cpp +++ b/src/devices/video/epic12.cpp @@ -944,7 +944,7 @@ void epic12_device::install_handlers(int addr1, int addr2) write = write32_delegate(FUNC(epic12_device::blitter_w), this); } - space.install_readwrite_handler(addr1, addr2, read , write, U64(0xffffffffffffffff)); + space.install_readwrite_handler(addr1, addr2, read , write, 0xffffffffffffffffU); } READ64_MEMBER( epic12_device::fpga_r ) diff --git a/src/devices/video/gb_lcd.cpp b/src/devices/video/gb_lcd.cpp index 3cf9ef945a1..6be32fc7588 100644 --- a/src/devices/video/gb_lcd.cpp +++ b/src/devices/video/gb_lcd.cpp @@ -867,8 +867,8 @@ LOG(("scrollx_to_apply: %u\n", m_line.scrollx_to_apply)); else { // Interleave bits from plane0 and plane1 - m_line.shift_register = (((((m_line.plane0 * U64(0x0101010101010101)) & U64(0x8040201008040201)) * U64(0x0102040810204081)) >> 49) & 0x5555) - | (((((m_line.plane1 * U64(0x0101010101010101)) & U64(0x8040201008040201)) * U64(0x0102040810204081)) >> 48) & 0xAAAA); + m_line.shift_register = (((((m_line.plane0 * 0x0101010101010101U) & 0x8040201008040201U) * 0x0102040810204081U) >> 49) & 0x5555) + | (((((m_line.plane1 * 0x0101010101010101U) & 0x8040201008040201U) * 0x0102040810204081U) >> 48) & 0xAAAA); } if (m_line.pixels_drawn < 8) { diff --git a/src/devices/video/stvvdp2.cpp b/src/devices/video/stvvdp2.cpp index 617252c0ee4..6e78b89bef3 100644 --- a/src/devices/video/stvvdp2.cpp +++ b/src/devices/video/stvvdp2.cpp @@ -3752,8 +3752,8 @@ void saturn_state::stv_vdp2_draw_basic_tilemap(bitmap_rgb32 &bitmap, const recta } } - scalex = (int32_t)((int64_t)S64(0x100000000) / (int64_t)stv2_current_tilemap.incx); - scaley = (int32_t)((int64_t)S64(0x100000000) / (int64_t)stv2_current_tilemap.incy); + scalex = s32(s64(0x100000000U) / s64(stv2_current_tilemap.incx)); + scaley = s32(s64(0x100000000U) / s64(stv2_current_tilemap.incy)); tilesizex = scalex * 8; tilesizey = scaley * 8; drawypos = drawxpos = 0; diff --git a/src/devices/video/upd7220.cpp b/src/devices/video/upd7220.cpp index cc6d9a1ffca..32aa6ba4b18 100644 --- a/src/devices/video/upd7220.cpp +++ b/src/devices/video/upd7220.cpp @@ -641,7 +641,7 @@ upd7220_device::upd7220_device(const machine_config &mconfig, const char *tag, d m_br(0), m_ctop(0), m_cbot(0), - m_lr(0), + m_lr(1), m_disp(0), m_gchr(0), m_bitmap_mod(0), @@ -816,11 +816,12 @@ void upd7220_device::draw_line(int x, int y) { int xi, yi; int d = (m_figs.m_d & 0x2000) ? (int16_t)(m_figs.m_d | 0xe000) : m_figs.m_d; + int d1 = (m_figs.m_d1 & 0x2000) ? (int16_t)(m_figs.m_d1 | 0xe000) : m_figs.m_d1; int d2 = (m_figs.m_d2 & 0x2000) ? (int16_t)(m_figs.m_d2 | 0xe000) : m_figs.m_d2; uint16_t pattern = (m_ra[8]) | (m_ra[9]<<8); const int dot_dir[4] = {1, -1, -1, 1}; - LOG(("uPD7220 line check: %d %d %02x %08x %d %d %d\n",x,y,m_figs.m_dir,m_ead,m_figs.m_d1,m_figs.m_dc,m_bitmap_mod)); + LOG(("uPD7220 line check: %d %d %02x %08x %d %d %d\n",x,y,m_figs.m_dir,m_ead,d1,m_figs.m_dc,m_bitmap_mod)); for(yi = xi = 0; yi <= m_figs.m_dc; yi++) { @@ -840,7 +841,7 @@ void upd7220_device::draw_line(int x, int y) d += d2; } else - d += m_figs.m_d1; + d += d1; } switch(m_figs.m_dir & 3) @@ -866,48 +867,34 @@ void upd7220_device::draw_line(int x, int y) void upd7220_device::draw_arc(int x, int y) { - int xi = m_figs.m_d + 1, yi = 0, err = -m_figs.m_d; - int x0, y0; + int xi = 0, err = -m_figs.m_d, d = m_figs.m_d + 1; uint16_t pattern = (m_ra[8]) | (m_ra[9]<<8); const int dot_dir[4] = {1, -1, -1, 1}; - switch(m_figs.m_dir & 3) - { - case 1: - case 2: - x0 = x; - y0 = y + xi * dot_dir[m_figs.m_dir >> 1]; - break; - default: - x0 = x + xi * dot_dir[((m_figs.m_dir >> 1) + 3) & 3]; - y0 = y; - break; - } - LOG(("uPD7220 arc check: %d %d %02x %08x %d %d %d\n",x,y,m_figs.m_dir,m_ead,m_figs.m_dm,m_figs.m_dc,m_figs.m_d)); - for(int i = 0; i <= m_figs.m_dc; i++) + for(int yi = 0; yi <= m_figs.m_dc; yi++) { - if(i >= m_figs.m_dm) + if(yi >= m_figs.m_dm) { switch(m_figs.m_dir & 3) { case 1: case 2: - draw_pixel(yi * dot_dir[((m_figs.m_dir >> 1) + 3) & 3] + x0, xi * dot_dir[m_figs.m_dir >> 1] + y0, i, pattern); + draw_pixel(yi * dot_dir[((m_figs.m_dir >> 1) + 3) & 3] + x, xi * dot_dir[m_figs.m_dir >> 1] + y, yi, pattern); break; default: - draw_pixel(xi * dot_dir[m_figs.m_dir >> 1] + x0, yi * dot_dir[((m_figs.m_dir >> 1) + 3) & 3] + y0, i, pattern); + draw_pixel(xi * dot_dir[((m_figs.m_dir >> 1) + 3) & 3] + x, yi * dot_dir[m_figs.m_dir >> 1] + y, yi, pattern); break; } } - yi++; if(err < 0) err += (yi + 1) << 1; else { - xi--; - err += (yi - xi + 1) << 1; + xi++; + d--; + err += (yi - d + 1) << 1; } } switch(m_figs.m_dir & 3) diff --git a/src/devices/video/vooddefs.h b/src/devices/video/vooddefs.h index 0840f80eaf4..095f29f972c 100644 --- a/src/devices/video/vooddefs.h +++ b/src/devices/video/vooddefs.h @@ -149,7 +149,7 @@ static inline int32_t fast_reciplog(int64_t value, int32_t *log2) } /* if we've spilled out of 32 bits, push it down under 32 */ - if (value & U64(0xffff00000000)) + if (value & 0xffff00000000U) { temp = (uint32_t)(value >> 16); exp -= 16; @@ -250,7 +250,7 @@ static inline int64_t float_to_int64(uint32_t data, int fixedbits) if (exponent < 64) result <<= exponent; else - result = U64(0x7fffffffffffffff); + result = 0x7fffffffffffffffU; } if (data & 0x80000000) result = -result; @@ -1846,9 +1846,9 @@ do if (FBZMODE_STIPPLE_PATTERN(FBZMODE) == 0) \ { \ vd->reg[stipple].u = (vd->reg[stipple].u << 1) | (vd->reg[stipple].u >> 31);\ - if ((vd->reg[stipple].u & 0x80000000) == 0) \ + if ((vd->reg[stipple].u & 0x80000000) == 0) \ { \ - vd->stats.total_stippled++; \ + vd->stats.total_stippled++; \ goto skipdrawdepth; \ } \ } \ @@ -1857,21 +1857,21 @@ do else \ { \ int stipple_index = (((YY) & 3) << 3) | (~(XX) & 7); \ - if (((vd->reg[stipple].u >> stipple_index) & 1) == 0) \ + if (((vd->reg[stipple].u >> stipple_index) & 1) == 0) \ { \ - vd->stats.total_stippled++; \ + vd->stats.total_stippled++; \ goto skipdrawdepth; \ } \ } \ } \ \ /* compute "floating point" W value (used for depth and fog) */ \ - if ((ITERW) & U64(0xffff00000000)) \ + if ((ITERW) & 0xffff00000000U) \ wfloat = 0x0000; \ else \ { \ - uint32_t temp = (uint32_t)(ITERW); \ - if (!(temp & 0xffff0000)) \ + uint32_t temp = (uint32_t)(ITERW); \ + if (!(temp & 0xffff0000)) \ wfloat = 0xffff; \ else \ { \ @@ -1879,7 +1879,7 @@ do wfloat = ((exp << 12) | ((~temp >> (19 - exp)) & 0xfff)) + 1; \ } \ } \ - fogdepth = wfloat; \ + fogdepth = wfloat; \ /* add the bias for fog selection*/ \ if (FBZMODE_ENABLE_DEPTH_BIAS(FBZMODE)) \ { \ @@ -1900,8 +1900,8 @@ do depthval = 0x0000; \ else \ { \ - uint32_t temp = (ITERZ << 4); \ - if (!(temp & 0xffff0000)) \ + uint32_t temp = (ITERZ << 4); \ + if (!(temp & 0xffff0000)) \ depthval = 0xffff; \ else \ { \ @@ -1909,7 +1909,7 @@ do depthval = ((exp << 12) | ((~temp >> (19 - exp)) & 0xfff)) + 1; \ } \ } \ - } \ + } \ /* add the bias */ \ biasdepth = depthval; \ if (FBZMODE_ENABLE_DEPTH_BIAS(FBZMODE)) \ diff --git a/src/emu/addrmap.cpp b/src/emu/addrmap.cpp index 9996f803e7e..97579fc126a 100644 --- a/src/emu/addrmap.cpp +++ b/src/emu/addrmap.cpp @@ -79,7 +79,7 @@ address_map_entry &address_map_entry::mask(offs_t _mask) // retrieve a submap from a device //------------------------------------------------- -address_map_entry &address_map_entry::set_submap(const char *tag, address_map_delegate func, int bits, uint64_t mask) +address_map_entry &address_map_entry::set_submap(const char *tag, address_map_delegate func, int bits, u64 mask) { if(!bits) bits = m_map.m_databits; @@ -103,7 +103,7 @@ address_map_entry &address_map_entry::set_submap(const char *tag, address_map_de // 8-bit read/write handlers //------------------------------------------------- -address_map_entry &address_map_entry::set_handler(read8_delegate func, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(read8_delegate func, u64 unitmask) { assert(!func.isnull()); assert(unitmask_is_appropriate(8, unitmask, func.name())); @@ -116,7 +116,7 @@ address_map_entry &address_map_entry::set_handler(read8_delegate func, uint64_t } -address_map_entry &address_map_entry::set_handler(write8_delegate func, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(write8_delegate func, u64 unitmask) { assert(!func.isnull()); assert(unitmask_is_appropriate(8, unitmask, func.name())); @@ -129,7 +129,7 @@ address_map_entry &address_map_entry::set_handler(write8_delegate func, uint64_t } -address_map_entry &address_map_entry::set_handler(read8_delegate rfunc, write8_delegate wfunc, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(read8_delegate rfunc, write8_delegate wfunc, u64 unitmask) { set_handler(rfunc, unitmask); set_handler(wfunc, unitmask); @@ -142,7 +142,7 @@ address_map_entry &address_map_entry::set_handler(read8_delegate rfunc, write8_d // 16-bit read/write handlers //------------------------------------------------- -address_map_entry &address_map_entry::set_handler(read16_delegate func, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(read16_delegate func, u64 unitmask) { assert(!func.isnull()); assert(unitmask_is_appropriate(16, unitmask, func.name())); @@ -155,7 +155,7 @@ address_map_entry &address_map_entry::set_handler(read16_delegate func, uint64_t } -address_map_entry &address_map_entry::set_handler(write16_delegate func, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(write16_delegate func, u64 unitmask) { assert(!func.isnull()); assert(unitmask_is_appropriate(16, unitmask, func.name())); @@ -168,7 +168,7 @@ address_map_entry &address_map_entry::set_handler(write16_delegate func, uint64_ } -address_map_entry &address_map_entry::set_handler(read16_delegate rfunc, write16_delegate wfunc, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(read16_delegate rfunc, write16_delegate wfunc, u64 unitmask) { set_handler(rfunc, unitmask); set_handler(wfunc, unitmask); @@ -181,7 +181,7 @@ address_map_entry &address_map_entry::set_handler(read16_delegate rfunc, write16 // 32-bit read/write handlers //------------------------------------------------- -address_map_entry &address_map_entry::set_handler(read32_delegate func, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(read32_delegate func, u64 unitmask) { assert(!func.isnull()); assert(unitmask_is_appropriate(32, unitmask, func.name())); @@ -194,7 +194,7 @@ address_map_entry &address_map_entry::set_handler(read32_delegate func, uint64_t } -address_map_entry &address_map_entry::set_handler(write32_delegate func, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(write32_delegate func, u64 unitmask) { assert(!func.isnull()); assert(unitmask_is_appropriate(32, unitmask, func.name())); @@ -207,7 +207,7 @@ address_map_entry &address_map_entry::set_handler(write32_delegate func, uint64_ } -address_map_entry &address_map_entry::set_handler(read32_delegate rfunc, write32_delegate wfunc, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(read32_delegate rfunc, write32_delegate wfunc, u64 unitmask) { set_handler(rfunc, unitmask); set_handler(wfunc, unitmask); @@ -220,7 +220,7 @@ address_map_entry &address_map_entry::set_handler(read32_delegate rfunc, write32 // 64-bit read/write handlers //------------------------------------------------- -address_map_entry &address_map_entry::set_handler(read64_delegate func, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(read64_delegate func, u64 unitmask) { assert(!func.isnull()); assert(unitmask_is_appropriate(64, unitmask, func.name())); @@ -233,7 +233,7 @@ address_map_entry &address_map_entry::set_handler(read64_delegate func, uint64_t } -address_map_entry &address_map_entry::set_handler(write64_delegate func, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(write64_delegate func, u64 unitmask) { assert(!func.isnull()); assert(unitmask_is_appropriate(64, unitmask, func.name())); @@ -246,7 +246,7 @@ address_map_entry &address_map_entry::set_handler(write64_delegate func, uint64_ } -address_map_entry &address_map_entry::set_handler(read64_delegate rfunc, write64_delegate wfunc, uint64_t unitmask) +address_map_entry &address_map_entry::set_handler(read64_delegate rfunc, write64_delegate wfunc, u64 unitmask) { set_handler(rfunc, unitmask); set_handler(wfunc, unitmask); @@ -274,7 +274,7 @@ address_map_entry &address_map_entry::set_handler(setoffset_delegate func) // provided unitmask is valid and expected //------------------------------------------------- -bool address_map_entry::unitmask_is_appropriate(uint8_t width, uint64_t unitmask, const char *string) +bool address_map_entry::unitmask_is_appropriate(u8 width, u64 unitmask, const char *string) { // if no mask, this must match the default width of the map if (unitmask == 0) @@ -289,12 +289,12 @@ bool address_map_entry::unitmask_is_appropriate(uint8_t width, uint64_t unitmask throw emu_fatalerror("Handler %s is a %d-bit handler and is too wide to be used in a %d-bit address map", string, width, m_map.m_databits); // the mask must represent whole units of width - uint32_t basemask = (width == 8) ? 0xff : (width == 16) ? 0xffff : 0xffffffff; - uint64_t singlemask = basemask; + u32 basemask = (width == 8) ? 0xff : (width == 16) ? 0xffff : 0xffffffff; + u64 singlemask = basemask; while (singlemask != 0) { if ((unitmask & singlemask) != 0 && (unitmask & singlemask) != singlemask) - throw emu_fatalerror("Handler %s specified a mask of %08X%08X; needs to be in even chunks of %X", string, (uint32_t)(unitmask >> 32), (uint32_t)unitmask, basemask); + throw emu_fatalerror("Handler %s specified a mask of %08X%08X; needs to be in even chunks of %X", string, (u32)(unitmask >> 32), (u32)unitmask, basemask); singlemask <<= width; } return true; @@ -373,7 +373,7 @@ address_map::address_map(device_t &device, address_map_entry *entry) // address_map - constructor dynamic device mapping case //---------------------------------------------------------- -address_map::address_map(const address_space &space, offs_t start, offs_t end, int bits, uint64_t unitmask, device_t &device, address_map_delegate submap_delegate) +address_map::address_map(const address_space &space, offs_t start, offs_t end, int bits, u64 unitmask, device_t &device, address_map_delegate submap_delegate) : m_spacenum(space.spacenum()), m_device(&device), m_databits(space.data_width()), @@ -399,7 +399,7 @@ address_map::~address_map() // values //------------------------------------------------- -void address_map::configure(address_spacenum spacenum, uint8_t databits) +void address_map::configure(address_spacenum spacenum, u8 databits) { assert(m_spacenum == spacenum); if (m_databits == 0xff) @@ -471,14 +471,14 @@ void address_map::uplift_submaps(running_machine &machine, device_t &owner, endi offs_t mirror_address_mask = (databytes - 1) & ~(entry_bytes - 1); - uint64_t entry_mask = (2ULL << (entry_bits-1)) - 1; + u64 entry_mask = (2ULL << (entry_bits-1)) - 1; int slot_offset[8]; int slot_count = 0; int max_slot_count = m_databits / entry_bits; int slot_xor_mask = endian == ENDIANNESS_LITTLE ? 0 : max_slot_count - 1; - uint64_t global_mask = entry->m_read.m_mask; + u64 global_mask = entry->m_read.m_mask; // zero means all if (!global_mask) global_mask = ~global_mask; @@ -547,10 +547,10 @@ void address_map::uplift_submaps(running_machine &machine, device_t &owner, endi if (mdata.m_bits == 0 && entry_bits != m_databits) mdata.m_bits = entry_bits; - uint64_t mask = 0; + u64 mask = 0; if (mdata.m_bits != m_databits) { - uint64_t unitmask = mdata.m_mask ? mdata.m_mask : entry_mask; + u64 unitmask = mdata.m_mask ? mdata.m_mask : entry_mask; for (int slot = start_slot; slot <= end_slot; slot++) mask |= unitmask << slot_offset[slot]; } @@ -602,8 +602,8 @@ void address_map::map_validity_check(validity_checker &valid, address_spacenum s // loop over entries and look for errors for (address_map_entry &entry : m_entrylist) { - uint32_t bytestart = spaceconfig.addr2byte(entry.m_addrstart); - uint32_t byteend = spaceconfig.addr2byte_end(entry.m_addrend); + u32 bytestart = spaceconfig.addr2byte(entry.m_addrstart); + u32 byteend = spaceconfig.addr2byte_end(entry.m_addrend); // look for overlapping entries if (!detected_overlap) diff --git a/src/emu/addrmap.h b/src/emu/addrmap.h index 4dde0005a13..ac6736c6b51 100644 --- a/src/emu/addrmap.h +++ b/src/emu/addrmap.h @@ -58,11 +58,11 @@ public: m_name(nullptr), m_tag(nullptr) { } - map_handler_type m_type; // type of the handler - uint8_t m_bits; // width of the handler in bits, or 0 for default - uint64_t m_mask; // mask for which lanes apply - const char * m_name; // name of the handler - const char * m_tag; // tag for I/O ports and banks + map_handler_type m_type; // type of the handler + u8 m_bits; // width of the handler in bits, or 0 for default + u64 m_mask; // mask for which lanes apply + const char * m_name; // name of the handler + const char * m_tag; // tag for I/O ports and banks }; @@ -120,7 +120,7 @@ public: address_map_entry &set_write_type(map_handler_type _type) { m_write.m_type = _type; return *this; } // submap referencing - address_map_entry &set_submap(const char *tag, address_map_delegate func, int bits, uint64_t mask); + address_map_entry &set_submap(const char *tag, address_map_delegate func, int bits, u64 mask); // public state address_map_entry * m_next; // pointer to the next entry @@ -162,28 +162,28 @@ public: offs_t m_bytemask; // byte-adjusted mask bits // handler setters for 8-bit functions - address_map_entry &set_handler(read8_delegate func, uint64_t mask = 0); - address_map_entry &set_handler(write8_delegate func, uint64_t mask = 0); - address_map_entry &set_handler(read8_delegate rfunc, write8_delegate wfunc, uint64_t mask = 0); + address_map_entry &set_handler(read8_delegate func, u64 mask = 0); + address_map_entry &set_handler(write8_delegate func, u64 mask = 0); + address_map_entry &set_handler(read8_delegate rfunc, write8_delegate wfunc, u64 mask = 0); // handler setters for 16-bit functions - address_map_entry &set_handler(read16_delegate func, uint64_t mask = 0); - address_map_entry &set_handler(write16_delegate func, uint64_t mask = 0); - address_map_entry &set_handler(read16_delegate rfunc, write16_delegate wfunc, uint64_t mask = 0); + address_map_entry &set_handler(read16_delegate func, u64 mask = 0); + address_map_entry &set_handler(write16_delegate func, u64 mask = 0); + address_map_entry &set_handler(read16_delegate rfunc, write16_delegate wfunc, u64 mask = 0); // handler setters for 32-bit functions - address_map_entry &set_handler(read32_delegate func, uint64_t mask = 0); - address_map_entry &set_handler(write32_delegate func, uint64_t mask = 0); - address_map_entry &set_handler(read32_delegate rfunc, write32_delegate wfunc, uint64_t mask = 0); + address_map_entry &set_handler(read32_delegate func, u64 mask = 0); + address_map_entry &set_handler(write32_delegate func, u64 mask = 0); + address_map_entry &set_handler(read32_delegate rfunc, write32_delegate wfunc, u64 mask = 0); // handler setters for 64-bit functions - address_map_entry &set_handler(read64_delegate func, uint64_t mask = 0); - address_map_entry &set_handler(write64_delegate func, uint64_t mask = 0); - address_map_entry &set_handler(read64_delegate rfunc, write64_delegate wfunc, uint64_t mask = 0); + address_map_entry &set_handler(read64_delegate func, u64 mask = 0); + address_map_entry &set_handler(write64_delegate func, u64 mask = 0); + address_map_entry &set_handler(read64_delegate rfunc, write64_delegate wfunc, u64 mask = 0); private: // helper functions - bool unitmask_is_appropriate(uint8_t width, uint64_t unitmask, const char *string); + bool unitmask_is_appropriate(u8 width, u64 unitmask, const char *string); }; // ======================> address_map @@ -195,28 +195,28 @@ public: // construction/destruction address_map(device_t &device, address_spacenum spacenum); address_map(device_t &device, address_map_entry *entry); - address_map(const address_space &space, offs_t start, offs_t end, int bits, uint64_t unitmask, device_t &device, address_map_delegate submap_delegate); + address_map(const address_space &space, offs_t start, offs_t end, int bits, u64 unitmask, device_t &device, address_map_delegate submap_delegate); ~address_map(); // configuration - void configure(address_spacenum _spacenum, uint8_t _databits); + void configure(address_spacenum _spacenum, u8 _databits); // setters void global_mask(offs_t mask); void unmap_value_low() { m_unmapval = 0; } void unmap_value_high() { m_unmapval = ~0; } - void unmap_value(uint8_t value) { m_unmapval = value; } + void unmap_value(u8 value) { m_unmapval = value; } // add a new entry of the given type address_map_entry &range(offs_t start, offs_t end); // public data - address_spacenum m_spacenum; // space number of the map - device_t * m_device; // associated device - uint8_t m_databits; // data bits represented by the map - uint8_t m_unmapval; // unmapped memory value - offs_t m_globalmask; // global mask - simple_list m_entrylist; // list of entries + address_spacenum m_spacenum; // space number of the map + device_t * m_device; // associated device + u8 m_databits; // data bits represented by the map + u8 m_unmapval; // unmapped memory value + offs_t m_globalmask; // global mask + simple_list m_entrylist; // list of entries void uplift_submaps(running_machine &machine, device_t &owner, endianness_t endian); void map_validity_check(validity_checker &valid, address_spacenum spacenum) const; diff --git a/src/emu/attotime.cpp b/src/emu/attotime.cpp index 6df7487dfc7..e756aa9653d 100644 --- a/src/emu/attotime.cpp +++ b/src/emu/attotime.cpp @@ -29,7 +29,7 @@ const attotime attotime::never(ATTOTIME_MAX_SECONDS, 0); // constant //------------------------------------------------- -attotime &attotime::operator*=(uint32_t factor) +attotime &attotime::operator*=(u32 factor) { // if one of the items is attotime::never, return attotime::never if (m_seconds >= ATTOTIME_MAX_SECONDS) @@ -40,17 +40,17 @@ attotime &attotime::operator*=(uint32_t factor) return *this = zero; // split attoseconds into upper and lower halves which fit into 32 bits - uint32_t attolo; - uint32_t attohi = divu_64x32_rem(m_attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo); + u32 attolo; + u32 attohi = divu_64x32_rem(m_attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo); // scale the lower half, then split into high/low parts - uint64_t temp = mulu_32x32(attolo, factor); - uint32_t reslo; + u64 temp = mulu_32x32(attolo, factor); + u32 reslo; temp = divu_64x32_rem(temp, ATTOSECONDS_PER_SECOND_SQRT, &reslo); // scale the upper half, then split into high/low parts temp += mulu_32x32(attohi, factor); - uint32_t reshi; + u32 reshi; temp = divu_64x32_rem(temp, ATTOSECONDS_PER_SECOND_SQRT, &reshi); // scale the seconds @@ -69,7 +69,7 @@ attotime &attotime::operator*=(uint32_t factor) // operator/= - divide an attotime by a constant //------------------------------------------------- -attotime &attotime::operator/=(uint32_t factor) +attotime &attotime::operator/=(u32 factor) { // if one of the items is attotime::never, return attotime::never if (m_seconds >= ATTOTIME_MAX_SECONDS) @@ -80,20 +80,20 @@ attotime &attotime::operator/=(uint32_t factor) return *this; // split attoseconds into upper and lower halves which fit into 32 bits - uint32_t attolo; - uint32_t attohi = divu_64x32_rem(m_attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo); + u32 attolo; + u32 attohi = divu_64x32_rem(m_attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo); // divide the seconds and get the remainder - uint32_t remainder; + u32 remainder; m_seconds = divu_64x32_rem(m_seconds, factor, &remainder); // combine the upper half of attoseconds with the remainder and divide that - uint64_t temp = (int64_t)attohi + mulu_32x32(remainder, ATTOSECONDS_PER_SECOND_SQRT); - uint32_t reshi = divu_64x32_rem(temp, factor, &remainder); + u64 temp = s64(attohi) + mulu_32x32(remainder, ATTOSECONDS_PER_SECOND_SQRT); + u32 reshi = divu_64x32_rem(temp, factor, &remainder); // combine the lower half of attoseconds with the remainder and divide that temp = attolo + mulu_32x32(remainder, ATTOSECONDS_PER_SECOND_SQRT); - uint32_t reslo = divu_64x32_rem(temp, factor, &remainder); + u32 reslo = divu_64x32_rem(temp, factor, &remainder); // round based on the remainder m_attoseconds = (attoseconds_t)reslo + mulu_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT); @@ -129,7 +129,7 @@ const char *attotime::as_string(int precision) const // case 2: we want 9 or fewer digits of precision else if (precision <= 9) { - uint32_t upper = m_attoseconds / ATTOSECONDS_PER_SECOND_SQRT; + u32 upper = m_attoseconds / ATTOSECONDS_PER_SECOND_SQRT; int temp = precision; while (temp < 9) { @@ -142,8 +142,8 @@ const char *attotime::as_string(int precision) const // case 3: more than 9 digits of precision else { - uint32_t lower; - uint32_t upper = divu_64x32_rem(m_attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &lower); + u32 lower; + u32 upper = divu_64x32_rem(m_attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &lower); int temp = precision; while (temp < 18) { diff --git a/src/emu/attotime.h b/src/emu/attotime.h index c99a1d953df..02c19465037 100644 --- a/src/emu/attotime.h +++ b/src/emu/attotime.h @@ -44,8 +44,8 @@ //************************************************************************** // core components of the attotime structure -typedef int64_t attoseconds_t; -typedef int32_t seconds_t; +typedef s64 attoseconds_t; +typedef s32 seconds_t; // core definitions const attoseconds_t ATTOSECONDS_PER_SECOND_SQRT = 1'000'000'000; @@ -110,7 +110,7 @@ public: // conversion to other forms constexpr double as_double() const { return double(m_seconds) + ATTOSECONDS_TO_DOUBLE(m_attoseconds); } constexpr attoseconds_t as_attoseconds() const; - uint64_t as_ticks(uint32_t frequency) const; + u64 as_ticks(u32 frequency) const; /** Convert to string using at @p precision */ const char *as_string(int precision = 9) const; @@ -120,23 +120,23 @@ public: constexpr seconds_t seconds() const { return m_seconds; } static attotime from_double(double _time); - static attotime from_ticks(uint64_t ticks, uint32_t frequency); + static attotime from_ticks(u64 ticks, u32 frequency); /** Create an attotime from a integer count of seconds @seconds */ - static constexpr attotime from_seconds(int32_t seconds) { return attotime(seconds, 0); } + static constexpr attotime from_seconds(s32 seconds) { return attotime(seconds, 0); } /** Create an attotime from a integer count of milliseconds @msec */ - static constexpr attotime from_msec(int64_t msec) { return attotime(msec / 1000, (msec % 1000) * (ATTOSECONDS_PER_SECOND / 1000)); } + static constexpr attotime from_msec(s64 msec) { return attotime(msec / 1000, (msec % 1000) * (ATTOSECONDS_PER_SECOND / 1000)); } /** Create an attotime from a integer count of microseconds @usec */ - static constexpr attotime from_usec(int64_t usec) { return attotime(usec / 1000000, (usec % 1000000) * (ATTOSECONDS_PER_SECOND / 1000000)); } + static constexpr attotime from_usec(s64 usec) { return attotime(usec / 1000000, (usec % 1000000) * (ATTOSECONDS_PER_SECOND / 1000000)); } /** Create an attotime from a integer count of nanoseconds @nsec */ - static constexpr attotime from_nsec(int64_t nsec) { return attotime(nsec / 1000000000, (nsec % 1000000000) * (ATTOSECONDS_PER_SECOND / 1000000000)); } + static constexpr attotime from_nsec(s64 nsec) { return attotime(nsec / 1000000000, (nsec % 1000000000) * (ATTOSECONDS_PER_SECOND / 1000000000)); } /** Create an attotime from at the given frequency @frequency */ static attotime from_hz(double frequency) { assert(frequency > 0); double d = 1 / frequency; return attotime(floor(d), modf(d, &d) * ATTOSECONDS_PER_SECOND); } // math attotime &operator+=(const attotime &right); attotime &operator-=(const attotime &right); - attotime &operator*=(uint32_t factor); - attotime &operator/=(uint32_t factor); + attotime &operator*=(u32 factor); + attotime &operator/=(u32 factor); // members seconds_t m_seconds; @@ -246,14 +246,14 @@ inline attotime &attotime::operator-=(const attotime &right) /** handle multiplication by an integral factor; defined in terms of the assignment operators */ -inline attotime operator*(const attotime &left, uint32_t factor) +inline attotime operator*(const attotime &left, u32 factor) { attotime result = left; result *= factor; return result; } -inline attotime operator*(uint32_t factor, const attotime &right) +inline attotime operator*(u32 factor, const attotime &right) { attotime result = right; result *= factor; @@ -261,7 +261,7 @@ inline attotime operator*(uint32_t factor, const attotime &right) } /** handle division by an integral factor; defined in terms of the assignment operators */ -inline attotime operator/(const attotime &left, uint32_t factor) +inline attotime operator/(const attotime &left, u32 factor) { attotime result = left; result /= factor; @@ -332,24 +332,24 @@ inline constexpr attoseconds_t attotime::as_attoseconds() const /** as_ticks - convert to ticks at @p frequency */ -inline uint64_t attotime::as_ticks(uint32_t frequency) const +inline u64 attotime::as_ticks(u32 frequency) const { - uint32_t fracticks = (attotime(0, m_attoseconds) * frequency).m_seconds; + u32 fracticks = (attotime(0, m_attoseconds) * frequency).m_seconds; return mulu_32x32(m_seconds, frequency) + fracticks; } /** Create an attotime from a tick count @ticks at the given frequency @frequency */ -inline attotime attotime::from_ticks(uint64_t ticks, uint32_t frequency) +inline attotime attotime::from_ticks(u64 ticks, u32 frequency) { attoseconds_t attos_per_tick = HZ_TO_ATTOSECONDS(frequency); if (ticks < frequency) return attotime(0, ticks * attos_per_tick); - uint32_t remainder; - int32_t secs = divu_64x32_rem(ticks, frequency, &remainder); - return attotime(secs, (uint64_t)remainder * attos_per_tick); + u32 remainder; + s32 secs = divu_64x32_rem(ticks, frequency, &remainder); + return attotime(secs, u64(remainder) * attos_per_tick); } /** Create an attotime from floating point count of seconds @p _time */ diff --git a/src/emu/bookkeeping.h b/src/emu/bookkeeping.h index 277501b5d2a..131ae6e8be4 100644 --- a/src/emu/bookkeeping.h +++ b/src/emu/bookkeeping.h @@ -8,20 +8,13 @@ *********************************************************************/ +#ifndef MAME_EMU_BOOKKEEPING_H +#define MAME_EMU_BOOKKEEPING_H + #pragma once -#ifndef __BOOKKEEPING_H__ -#define __BOOKKEEPING_H__ - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -/* total # of coin counters */ -#define COIN_COUNTERS 8 - //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -34,6 +27,9 @@ enum class config_type; class bookkeeping_manager { public: + // total # of coin counters + static constexpr size_t COIN_COUNTERS = 8; + // construction/destruction bookkeeping_manager(running_machine &machine); @@ -69,10 +65,10 @@ private: // internal state running_machine & m_machine; // reference to our machine - uint32_t m_dispensed_tickets; - uint32_t m_coin_count[COIN_COUNTERS]; - uint32_t m_coinlockedout[COIN_COUNTERS]; - uint32_t m_lastcoin[COIN_COUNTERS]; + u32 m_dispensed_tickets; + u32 m_coin_count[COIN_COUNTERS]; + u32 m_coinlockedout[COIN_COUNTERS]; + u32 m_lastcoin[COIN_COUNTERS]; }; -#endif /* __BOOKKEEPING_H__ */ +#endif /* MAME_EMU_BOOKKEEPING_H */ diff --git a/src/emu/crsshair.cpp b/src/emu/crsshair.cpp index 9c2f2dbd996..26d671ec479 100644 --- a/src/emu/crsshair.cpp +++ b/src/emu/crsshair.cpp @@ -29,7 +29,7 @@ ***************************************************************************/ /* raw bitmap */ -static const uint8_t crosshair_raw_top[] = +static const u8 crosshair_raw_top[] = { 0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00, 0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00, @@ -206,8 +206,8 @@ void render_crosshair::create_bitmap() for (y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++) { /* assume it is mirrored vertically */ - uint32_t *dest0 = &m_bitmap->pix32(y); - uint32_t *dest1 = &m_bitmap->pix32(CROSSHAIR_RAW_SIZE - 1 - y); + u32 *dest0 = &m_bitmap->pix32(y); + u32 *dest1 = &m_bitmap->pix32(CROSSHAIR_RAW_SIZE - 1 - y); /* extract to two rows simultaneously */ for (x = 0; x < CROSSHAIR_RAW_SIZE; x++) @@ -225,7 +225,7 @@ void render_crosshair::create_bitmap() // animate - update the crosshair state //------------------------------------------------- -void render_crosshair::animate(uint16_t auto_time) +void render_crosshair::animate(u16 auto_time) { // read all the port values if (m_used) @@ -263,7 +263,7 @@ void render_crosshair::animate(uint16_t auto_time) // draw - render the crosshair to the container //------------------------------------------------- -void render_crosshair::draw(render_container &container, uint8_t fade) +void render_crosshair::draw(render_container &container, u8 fade) { // add a quad assuming a 4:3 screen (this is not perfect) container.add_quad(m_x - 0.03f, m_y - 0.04f, m_x + 0.03f, m_y + 0.04f, @@ -414,7 +414,7 @@ void crosshair_manager::config_load(config_type cfg_type, xml_data_node *parentn mode = crosshairnode->get_attribute_int("mode", CROSSHAIR_VISIBILITY_DEFAULT); if (mode >= CROSSHAIR_VISIBILITY_OFF && mode <= CROSSHAIR_VISIBILITY_AUTO) { - crosshair.set_mode((uint8_t)mode); + crosshair.set_mode(u8(mode)); /* set visibility as specified by mode */ /* auto mode starts with visibility off */ crosshair.set_visible(mode == CROSSHAIR_VISIBILITY_ON); @@ -432,7 +432,7 @@ void crosshair_manager::config_load(config_type cfg_type, xml_data_node *parentn { auto_time = crosshairnode->get_attribute_int("val", CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT); if ((auto_time >= CROSSHAIR_VISIBILITY_AUTOTIME_MIN) && (auto_time <= CROSSHAIR_VISIBILITY_AUTOTIME_MAX)) - m_auto_time = (uint8_t)auto_time; + m_auto_time = u8(auto_time); } } diff --git a/src/emu/crsshair.h b/src/emu/crsshair.h index 609109d8b72..7981c249b98 100644 --- a/src/emu/crsshair.h +++ b/src/emu/crsshair.h @@ -7,10 +7,10 @@ Crosshair handling. ***************************************************************************/ -#pragma once +#ifndef MAME_EMU_CRSSHAIR_H +#define MAME_EMU_CRSSHAIR_H -#ifndef __CRSSHAIR_H__ -#define __CRSSHAIR_H__ +#pragma once /*************************************************************************** @@ -50,7 +50,7 @@ public: running_machine &machine() const { return m_machine; } int player() const { return m_player; } bool is_used() const { return m_used; } - uint8_t mode() const { return m_mode; } + u8 mode() const { return m_mode; } bool is_visible() const { return m_visible; } screen_device *screen() const { return m_screen; } float x() const { return m_x; } @@ -59,7 +59,7 @@ public: // setters void set_used(bool used) { m_used = used; } - void set_mode(uint8_t mode) { m_mode = mode; } + void set_mode(u8 mode) { m_mode = mode; } void set_visible(bool visible) { m_visible = visible; } void set_screen(screen_device *screen) { m_screen = screen; } //void setxy(float x, float y); @@ -67,8 +67,8 @@ public: void set_default_bitmap(); // updates - void animate(uint16_t auto_time); - void draw(render_container &container, uint8_t fade); + void animate(u16 auto_time); + void draw(render_container &container, u8 fade); private: // private helpers @@ -78,7 +78,7 @@ private: running_machine & m_machine; // reference to our machine int m_player; // player number bool m_used; // usage for this crosshair - uint8_t m_mode; // visibility mode for this crosshair + u8 m_mode; // visibility mode for this crosshair bool m_visible; // visibility for this crosshair std::unique_ptr m_bitmap; // bitmap for this crosshair render_texture * m_texture; // texture for this crosshair @@ -87,7 +87,7 @@ private: float m_y; // current Y position float m_last_x; // last X position float m_last_y; // last Y position - uint16_t m_time; // time since last movement + u16 m_time; // time since last movement std::string m_name; // name of png file }; @@ -109,8 +109,8 @@ public: // getters running_machine &machine() const { return m_machine; } render_crosshair &get_crosshair(int player) const { assert(player >= 0 && player < MAX_PLAYERS); assert(m_crosshair[player] != nullptr); return *m_crosshair[player]; } - uint16_t auto_time() const { return m_auto_time; } - void set_auto_time(uint16_t auto_time) { m_auto_time = auto_time; } + u16 auto_time() const { return m_auto_time; } + void set_auto_time(u16 auto_time) { m_auto_time = auto_time; } private: void exit(); @@ -124,9 +124,9 @@ private: bool m_usage; // true if any crosshairs are used std::unique_ptr m_crosshair[MAX_PLAYERS]; // per-player crosshair state - uint8_t m_fade; // color fading factor - uint8_t m_animation_counter; // animation frame index - uint16_t m_auto_time; // time in seconds to turn invisible + u8 m_fade; // color fading factor + u8 m_animation_counter; // animation frame index + u16 m_auto_time; // time in seconds to turn invisible }; -#endif /* __CRSSHAIR_H__ */ +#endif /* MAME_EMU_CRSSHAIR_H */ diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 620f83985b5..e2f175f9e1c 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -49,15 +49,15 @@ bool debugger_commands::cheat_address_is_valid(address_space &space, offs_t addr the current cheat width, if signed -------------------------------------------------*/ -uint64_t debugger_commands::cheat_sign_extend(const cheat_system *cheatsys, uint64_t value) +u64 debugger_commands::cheat_sign_extend(const cheat_system *cheatsys, u64 value) { if (cheatsys->signed_cheat) { switch (cheatsys->width) { - case 1: value = (int8_t)value; break; - case 2: value = (int16_t)value; break; - case 4: value = (int32_t)value; break; + case 1: value = s8(value); break; + case 2: value = s16(value); break; + case 4: value = s32(value); break; } } return value; @@ -67,7 +67,7 @@ uint64_t debugger_commands::cheat_sign_extend(const cheat_system *cheatsys, uint cheat_byte_swap - swap a value -------------------------------------------------*/ -uint64_t debugger_commands::cheat_byte_swap(const cheat_system *cheatsys, uint64_t value) +u64 debugger_commands::cheat_byte_swap(const cheat_system *cheatsys, u64 value) { if (cheatsys->swapped_cheat) { @@ -75,8 +75,8 @@ uint64_t debugger_commands::cheat_byte_swap(const cheat_system *cheatsys, uint64 { case 2: value = ((value >> 8) & 0x00ff) | ((value << 8) & 0xff00); break; case 4: value = ((value >> 24) & 0x000000ff) | ((value >> 8) & 0x0000ff00) | ((value << 8) & 0x00ff0000) | ((value << 24) & 0xff000000); break; - case 8: value = ((value >> 56) & U64(0x00000000000000ff)) | ((value >> 40) & U64(0x000000000000ff00)) | ((value >> 24) & U64(0x0000000000ff0000)) | ((value >> 8) & U64(0x00000000ff000000)) | - ((value << 8) & U64(0x000000ff00000000)) | ((value << 24) & U64(0x0000ff0000000000)) | ((value << 40) & U64(0x00ff000000000000)) | ((value << 56) & U64(0xff00000000000000)); break; + case 8: value = ((value >> 56) & 0x00000000000000ffU) | ((value >> 40) & 0x000000000000ff00U) | ((value >> 24) & 0x0000000000ff0000U) | ((value >> 8) & 0x00000000ff000000U) | + ((value << 8) & 0x000000ff00000000U) | ((value << 24) & 0x0000ff0000000000U) | ((value << 40) & 0x00ff000000000000U) | ((value << 56) & 0xff00000000000000U); break; } } return value; @@ -88,7 +88,7 @@ uint64_t debugger_commands::cheat_byte_swap(const cheat_system *cheatsys, uint64 and swapping if necessary -------------------------------------------------*/ -uint64_t debugger_commands::cheat_read_extended(const cheat_system *cheatsys, address_space &space, offs_t address) +u64 debugger_commands::cheat_read_extended(const cheat_system *cheatsys, address_space &space, offs_t address) { return cheat_sign_extend(cheatsys, cheat_byte_swap(cheatsys, m_cpu.read_memory(space, address, cheatsys->width, true))); } @@ -111,7 +111,7 @@ debugger_commands::debugger_commands(running_machine& machine, debugger_cpu& cpu /* add all single-entry save state globals */ for (int itemnum = 0; itemnum < MAX_GLOBALS; itemnum++) { - uint32_t valsize, valcount; + u32 valsize, valcount; void *base; /* stop when we run out of items */ @@ -281,7 +281,7 @@ debugger_commands::debugger_commands(running_machine& machine, debugger_cpu& cpu execute_min - return the minimum of two values -------------------------------------------------*/ -uint64_t debugger_commands::execute_min(symbol_table &table, void *ref, int params, const uint64_t *param) +u64 debugger_commands::execute_min(symbol_table &table, void *ref, int params, const u64 *param) { return (param[0] < param[1]) ? param[0] : param[1]; } @@ -291,7 +291,7 @@ uint64_t debugger_commands::execute_min(symbol_table &table, void *ref, int para execute_max - return the maximum of two values -------------------------------------------------*/ -uint64_t debugger_commands::execute_max(symbol_table &table, void *ref, int params, const uint64_t *param) +u64 debugger_commands::execute_max(symbol_table &table, void *ref, int params, const u64 *param) { return (param[0] > param[1]) ? param[0] : param[1]; } @@ -301,7 +301,7 @@ uint64_t debugger_commands::execute_max(symbol_table &table, void *ref, int para execute_if - if (a) return b; else return c; -------------------------------------------------*/ -uint64_t debugger_commands::execute_if(symbol_table &table, void *ref, int params, const uint64_t *param) +u64 debugger_commands::execute_if(symbol_table &table, void *ref, int params, const u64 *param) { return param[0] ? param[1] : param[2]; } @@ -316,15 +316,15 @@ uint64_t debugger_commands::execute_if(symbol_table &table, void *ref, int param global_get - symbol table getter for globals -------------------------------------------------*/ -uint64_t debugger_commands::global_get(symbol_table &table, void *ref) +u64 debugger_commands::global_get(symbol_table &table, void *ref) { global_entry *global = (global_entry *)ref; switch (global->size) { - case 1: return *(uint8_t *)global->base; - case 2: return *(uint16_t *)global->base; - case 4: return *(uint32_t *)global->base; - case 8: return *(uint64_t *)global->base; + case 1: return *(u8 *)global->base; + case 2: return *(u16 *)global->base; + case 4: return *(u32 *)global->base; + case 8: return *(u64 *)global->base; } return ~0; } @@ -334,15 +334,15 @@ uint64_t debugger_commands::global_get(symbol_table &table, void *ref) global_set - symbol table setter for globals -------------------------------------------------*/ -void debugger_commands::global_set(symbol_table &table, void *ref, uint64_t value) +void debugger_commands::global_set(symbol_table &table, void *ref, u64 value) { global_entry *global = (global_entry *)ref; switch (global->size) { - case 1: *(uint8_t *)global->base = value; break; - case 2: *(uint16_t *)global->base = value; break; - case 4: *(uint32_t *)global->base = value; break; - case 8: *(uint64_t *)global->base = value; break; + case 1: *(u8 *)global->base = value; break; + case 2: *(u16 *)global->base = value; break; + case 4: *(u32 *)global->base = value; break; + case 8: *(u64 *)global->base = value; break; } } @@ -357,7 +357,7 @@ void debugger_commands::global_set(symbol_table &table, void *ref, uint64_t valu number parameter -------------------------------------------------*/ -bool debugger_commands::validate_number_parameter(const char *param, uint64_t *result) +bool debugger_commands::validate_number_parameter(const char *param, u64 *result) { /* nullptr parameter does nothing and returns no error */ if (param == nullptr) @@ -432,7 +432,7 @@ bool debugger_commands::validate_cpu_parameter(const char *param, device_t **res return true; /* then evaluate as an expression; on an error assume it was a tag */ - uint64_t cpunum; + u64 cpunum; try { parsed_expression expression(m_cpu.get_visible_symtable(), param, &cpunum); @@ -552,7 +552,7 @@ void debugger_commands::execute_help(int ref, int params, const char *param[]) void debugger_commands::execute_print(int ref, int params, const char *param[]) { /* validate the other parameters */ - uint64_t values[MAX_COMMAND_PARAMS]; + u64 values[MAX_COMMAND_PARAMS]; for (int i = 0; i < params; i++) if (!validate_number_parameter(param[i], &values[i])) return; @@ -568,7 +568,7 @@ void debugger_commands::execute_print(int ref, int params, const char *param[]) mini_printf - safe printf to a buffer -------------------------------------------------*/ -int debugger_commands::mini_printf(char *buffer, const char *format, int params, uint64_t *param) +int debugger_commands::mini_printf(char *buffer, const char *format, int params, u64 *param) { const char *f = format; char *p = buffer; @@ -624,11 +624,11 @@ int debugger_commands::mini_printf(char *buffer, const char *format, int params, m_console.printf("Not enough parameters for format!\n"); return 0; } - if ((uint32_t)(*param >> 32) != 0) - p += sprintf(p, zerofill ? "%0*X" : "%*X", (width <= 8) ? 1 : width - 8, (uint32_t)(*param >> 32)); + if (u32(*param >> 32) != 0) + p += sprintf(p, zerofill ? "%0*X" : "%*X", (width <= 8) ? 1 : width - 8, u32(*param >> 32)); else if (width > 8) p += sprintf(p, zerofill ? "%0*X" : "%*X", width - 8, 0); - p += sprintf(p, zerofill ? "%0*X" : "%*X", (width < 8) ? width : 8, (uint32_t)*param); + p += sprintf(p, zerofill ? "%0*X" : "%*X", (width < 8) ? width : 8, u32(*param)); param++; params--; break; @@ -640,7 +640,7 @@ int debugger_commands::mini_printf(char *buffer, const char *format, int params, m_console.printf("Not enough parameters for format!\n"); return 0; } - p += sprintf(p, zerofill ? "%0*d" : "%*d", width, (uint32_t)*param); + p += sprintf(p, zerofill ? "%0*d" : "%*d", width, u32(*param)); param++; params--; break; @@ -665,7 +665,7 @@ int debugger_commands::mini_printf(char *buffer, const char *format, int params, void debugger_commands::execute_printf(int ref, int params, const char *param[]) { /* validate the other parameters */ - uint64_t values[MAX_COMMAND_PARAMS]; + u64 values[MAX_COMMAND_PARAMS]; for (int i = 1; i < params; i++) if (!validate_number_parameter(param[i], &values[i])) return; @@ -684,7 +684,7 @@ void debugger_commands::execute_printf(int ref, int params, const char *param[]) void debugger_commands::execute_logerror(int ref, int params, const char *param[]) { /* validate the other parameters */ - uint64_t values[MAX_COMMAND_PARAMS]; + u64 values[MAX_COMMAND_PARAMS]; for (int i = 1; i < params; i++) if (!validate_number_parameter(param[i], &values[i])) return; @@ -703,7 +703,7 @@ void debugger_commands::execute_logerror(int ref, int params, const char *param[ void debugger_commands::execute_tracelog(int ref, int params, const char *param[]) { /* validate the other parameters */ - uint64_t values[MAX_COMMAND_PARAMS]; + u64 values[MAX_COMMAND_PARAMS]; for (int i = 1; i < params; i++) if (!validate_number_parameter(param[i], &values[i])) return; @@ -732,7 +732,7 @@ void debugger_commands::execute_quit(int ref, int params, const char *param[]) void debugger_commands::execute_do(int ref, int params, const char *param[]) { - uint64_t dummy; + u64 dummy; validate_number_parameter(param[0], &dummy); } @@ -744,7 +744,7 @@ void debugger_commands::execute_do(int ref, int params, const char *param[]) void debugger_commands::execute_step(int ref, int params, const char *param[]) { /* if we have a parameter, use it */ - uint64_t steps = 1; + u64 steps = 1; if (!validate_number_parameter(param[0], &steps)) return; @@ -759,7 +759,7 @@ void debugger_commands::execute_step(int ref, int params, const char *param[]) void debugger_commands::execute_over(int ref, int params, const char *param[]) { /* if we have a parameter, use it */ - uint64_t steps = 1; + u64 steps = 1; if (!validate_number_parameter(param[0], &steps)) return; @@ -783,7 +783,7 @@ void debugger_commands::execute_out(int ref, int params, const char *param[]) void debugger_commands::execute_go(int ref, int params, const char *param[]) { - uint64_t addr = ~0; + u64 addr = ~0; /* if we have a parameter, use it instead */ if (!validate_number_parameter(param[0], &addr)) @@ -810,7 +810,7 @@ void debugger_commands::execute_go_vblank(int ref, int params, const char *param void debugger_commands::execute_go_interrupt(int ref, int params, const char *param[]) { - uint64_t irqline = -1; + u64 irqline = -1; /* if we have a parameter, use it instead */ if (!validate_number_parameter(param[0], &irqline)) @@ -826,7 +826,7 @@ void debugger_commands::execute_go_interrupt(int ref, int params, const char *pa void debugger_commands::execute_go_time(int ref, int params, const char *param[]) { - uint64_t milliseconds = -1; + u64 milliseconds = -1; /* if we have a parameter, use it instead */ if (!validate_number_parameter(param[0], &milliseconds)) @@ -987,7 +987,7 @@ void debugger_commands::execute_observe(int ref, int params, const char *param[] void debugger_commands::execute_comment_add(int ref, int params, const char *param[]) { device_t *cpu; - uint64_t address; + u64 address; /* param 1 is the address for the comment */ if (!validate_number_parameter(param[0], &address)) @@ -1017,7 +1017,7 @@ void debugger_commands::execute_comment_add(int ref, int params, const char *par void debugger_commands::execute_comment_del(int ref, int params, const char *param[]) { device_t *cpu; - uint64_t address; + u64 address; /* param 1 can either be a command or the address for the comment */ if (!validate_number_parameter(param[0], &address)) @@ -1093,7 +1093,7 @@ void debugger_commands::execute_bpset(int ref, int params, const char *param[]) { device_t *cpu; const char *action = nullptr; - uint64_t address; + u64 address; int bpnum; /* CPU is implicit */ @@ -1126,7 +1126,7 @@ void debugger_commands::execute_bpset(int ref, int params, const char *param[]) void debugger_commands::execute_bpclear(int ref, int params, const char *param[]) { - uint64_t bpindex; + u64 bpindex; /* if 0 parameters, clear all */ if (params == 0) @@ -1146,9 +1146,9 @@ void debugger_commands::execute_bpclear(int ref, int params, const char *param[] if (device.debug()->breakpoint_clear(bpindex)) found = true; if (found) - m_console.printf("Breakpoint %X cleared\n", (uint32_t)bpindex); + m_console.printf("Breakpoint %X cleared\n", u32(bpindex)); else - m_console.printf("Invalid breakpoint number %X\n", (uint32_t)bpindex); + m_console.printf("Invalid breakpoint number %X\n", u32(bpindex)); } } @@ -1160,7 +1160,7 @@ void debugger_commands::execute_bpclear(int ref, int params, const char *param[] void debugger_commands::execute_bpdisenable(int ref, int params, const char *param[]) { - uint64_t bpindex; + u64 bpindex; /* if 0 parameters, clear all */ if (params == 0) @@ -1183,9 +1183,9 @@ void debugger_commands::execute_bpdisenable(int ref, int params, const char *par if (device.debug()->breakpoint_enable(bpindex, ref)) found = true; if (found) - m_console.printf("Breakpoint %X %s\n", (uint32_t)bpindex, ref ? "enabled" : "disabled"); + m_console.printf("Breakpoint %X %s\n", u32(bpindex), ref ? "enabled" : "disabled"); else - m_console.printf("Invalid breakpoint number %X\n", (uint32_t)bpindex); + m_console.printf("Invalid breakpoint number %X\n", u32(bpindex)); } } @@ -1233,7 +1233,7 @@ void debugger_commands::execute_wpset(int ref, int params, const char *param[]) { address_space *space; const char *action = nullptr; - uint64_t address, length; + u64 address, length; int type; int wpnum; @@ -1284,7 +1284,7 @@ void debugger_commands::execute_wpset(int ref, int params, const char *param[]) void debugger_commands::execute_wpclear(int ref, int params, const char *param[]) { - uint64_t wpindex; + u64 wpindex; /* if 0 parameters, clear all */ if (params == 0) @@ -1304,9 +1304,9 @@ void debugger_commands::execute_wpclear(int ref, int params, const char *param[] if (device.debug()->watchpoint_clear(wpindex)) found = true; if (found) - m_console.printf("Watchpoint %X cleared\n", (uint32_t)wpindex); + m_console.printf("Watchpoint %X cleared\n", u32(wpindex)); else - m_console.printf("Invalid watchpoint number %X\n", (uint32_t)wpindex); + m_console.printf("Invalid watchpoint number %X\n", u32(wpindex)); } } @@ -1318,7 +1318,7 @@ void debugger_commands::execute_wpclear(int ref, int params, const char *param[] void debugger_commands::execute_wpdisenable(int ref, int params, const char *param[]) { - uint64_t wpindex; + u64 wpindex; /* if 0 parameters, clear all */ if (params == 0) @@ -1341,9 +1341,9 @@ void debugger_commands::execute_wpdisenable(int ref, int params, const char *par if (device.debug()->watchpoint_enable(wpindex, ref)) found = true; if (found) - m_console.printf("Watchpoint %X %s\n", (uint32_t)wpindex, ref ? "enabled" : "disabled"); + m_console.printf("Watchpoint %X %s\n", u32(wpindex), ref ? "enabled" : "disabled"); else - m_console.printf("Invalid watchpoint number %X\n", (uint32_t)wpindex); + m_console.printf("Invalid watchpoint number %X\n", u32(wpindex)); } } @@ -1426,7 +1426,7 @@ void debugger_commands::execute_rpset(int ref, int params, const char *param[]) void debugger_commands::execute_rpclear(int ref, int params, const char *param[]) { - uint64_t rpindex; + u64 rpindex; /* if 0 parameters, clear all */ if (params == 0) @@ -1446,9 +1446,9 @@ void debugger_commands::execute_rpclear(int ref, int params, const char *param[] if (device.debug()->registerpoint_clear(rpindex)) found = true; if (found) - m_console.printf("Registerpoint %X cleared\n", (uint32_t)rpindex); + m_console.printf("Registerpoint %X cleared\n", u32(rpindex)); else - m_console.printf("Invalid registerpoint number %X\n", (uint32_t)rpindex); + m_console.printf("Invalid registerpoint number %X\n", u32(rpindex)); } } @@ -1460,7 +1460,7 @@ void debugger_commands::execute_rpclear(int ref, int params, const char *param[] void debugger_commands::execute_rpdisenable(int ref, int params, const char *param[]) { - uint64_t rpindex; + u64 rpindex; /* if 0 parameters, clear all */ if (params == 0) @@ -1483,9 +1483,9 @@ void debugger_commands::execute_rpdisenable(int ref, int params, const char *par if (device.debug()->registerpoint_enable(rpindex, ref)) found = true; if (found) - m_console.printf("Registerpoint %X %s\n", (uint32_t)rpindex, ref ? "enabled" : "disabled"); + m_console.printf("Registerpoint %X %s\n", u32(rpindex), ref ? "enabled" : "disabled"); else - m_console.printf("Invalid registerpoint number %X\n", (uint32_t)rpindex); + m_console.printf("Invalid registerpoint number %X\n", u32(rpindex)); } } @@ -1552,10 +1552,10 @@ void debugger_commands::execute_hotspot(int ref, int params, const char *param[] device_t *device = nullptr; if (!validate_cpu_parameter((params > 0) ? param[0] : nullptr, &device)) return; - uint64_t count = 64; + u64 count = 64; if (!validate_number_parameter(param[1], &count)) return; - uint64_t threshhold = 250; + u64 threshhold = 250; if (!validate_number_parameter(param[2], &threshhold)) return; @@ -1602,10 +1602,10 @@ void debugger_commands::execute_stateload(int ref, int params, const char *param void debugger_commands::execute_save(int ref, int params, const char *param[]) { - uint64_t offset, endoffset, length; + u64 offset, endoffset, length; address_space *space; FILE *f; - uint64_t i; + u64 i; /* validate parameters */ if (!validate_number_parameter(param[1], &offset)) @@ -1630,7 +1630,7 @@ void debugger_commands::execute_save(int ref, int params, const char *param[]) /* now write the data out */ for (i = offset; i <= endoffset; i++) { - uint8_t byte = m_cpu.read_byte(*space, i, true); + u8 byte = m_cpu.read_byte(*space, i, true); fwrite(&byte, 1, 1, f); } @@ -1646,10 +1646,10 @@ void debugger_commands::execute_save(int ref, int params, const char *param[]) void debugger_commands::execute_load(int ref, int params, const char *param[]) { - uint64_t offset, endoffset, length; + u64 offset, endoffset, length; address_space *space; FILE *f; - uint64_t i; + u64 i; /* validate parameters */ if (!validate_number_parameter(param[1], &offset)) @@ -1672,7 +1672,7 @@ void debugger_commands::execute_load(int ref, int params, const char *param[]) } /* now read the data in, ignore endoffset and load entire file if length has been set to zero (offset-1) */ - uint8_t byte; + u8 byte; for (i = offset; i <= endoffset || endoffset == offset - 1 ; i++) { fread(&byte, 1, 1, f); @@ -1697,23 +1697,23 @@ void debugger_commands::execute_load(int ref, int params, const char *param[]) void debugger_commands::execute_dump(int ref, int params, const char *param[]) { /* validate parameters */ - uint64_t offset; + u64 offset; if (!validate_number_parameter(param[1], &offset)) return; - uint64_t length; + u64 length; if (!validate_number_parameter(param[2], &length)) return; - uint64_t width = 0; + u64 width = 0; if (!validate_number_parameter(param[3], &width)) return; - uint64_t ascii = 1; + u64 ascii = 1; if (!validate_number_parameter(param[4], &ascii)) return; - uint64_t rowsize = 16; + u64 rowsize = 16; if (!validate_number_parameter(param[5], &rowsize)) return; @@ -1737,7 +1737,7 @@ void debugger_commands::execute_dump(int ref, int params, const char *param[]) return; } - uint64_t endoffset = space->address_to_byte(offset + length - 1) & space->bytemask(); + u64 endoffset = space->address_to_byte(offset + length - 1) & space->bytemask(); offset = space->address_to_byte(offset) & space->bytemask(); /* open the file */ @@ -1751,23 +1751,23 @@ void debugger_commands::execute_dump(int ref, int params, const char *param[]) /* now write the data out */ util::ovectorstream output; output.reserve(200); - for (uint64_t i = offset; i <= endoffset; i += rowsize) + for (u64 i = offset; i <= endoffset; i += rowsize) { output.clear(); output.rdbuf()->clear(); /* print the address */ - util::stream_format(output, "%0*X: ", space->logaddrchars(), (uint32_t)space->byte_to_address(i)); + util::stream_format(output, "%0*X: ", space->logaddrchars(), u32(space->byte_to_address(i))); /* print the bytes */ - for (uint64_t j = 0; j < rowsize; j += width) + for (u64 j = 0; j < rowsize; j += width) { if (i + j <= endoffset) { offs_t curaddr = i + j; if (space->device().memory().translate(space->spacenum(), TRANSLATE_READ_DEBUG, curaddr)) { - uint64_t value = m_cpu.read_memory(*space, i + j, width, true); + u64 value = m_cpu.read_memory(*space, i + j, width, true); util::stream_format(output, " %0*X", width * 2, value); } else @@ -1783,12 +1783,12 @@ void debugger_commands::execute_dump(int ref, int params, const char *param[]) if (ascii) { util::stream_format(output, " "); - for (uint64_t j = 0; j < rowsize && (i + j) <= endoffset; j++) + for (u64 j = 0; j < rowsize && (i + j) <= endoffset; j++) { offs_t curaddr = i + j; if (space->device().memory().translate(space->spacenum(), TRANSLATE_READ_DEBUG, curaddr)) { - uint8_t byte = m_cpu.read_byte(*space, i + j, true); + u8 byte = m_cpu.read_byte(*space, i + j, true); util::stream_format(output, "%c", (byte >= 32 && byte < 127) ? byte : '.'); } else @@ -1815,11 +1815,11 @@ void debugger_commands::execute_dump(int ref, int params, const char *param[]) void debugger_commands::execute_cheatinit(int ref, int params, const char *param[]) { - uint64_t offset, length = 0, real_length = 0; + u64 offset, length = 0, real_length = 0; address_space *space; - uint32_t active_cheat = 0; - uint64_t curaddr; - uint8_t i, region_count = 0; + u32 active_cheat = 0; + u64 curaddr; + u8 i, region_count = 0; cheat_region_map cheat_region[100]; @@ -1969,10 +1969,10 @@ void debugger_commands::execute_cheatinit(int ref, int params, const char *param void debugger_commands::execute_cheatnext(int ref, int params, const char *param[]) { address_space *space; - uint64_t cheatindex; - uint32_t active_cheat = 0; - uint8_t condition; - uint64_t comp_value = 0; + u64 cheatindex; + u32 active_cheat = 0; + u8 condition; + u64 comp_value = 0; enum { @@ -2038,9 +2038,9 @@ void debugger_commands::execute_cheatnext(int ref, int params, const char *param for (cheatindex = 0; cheatindex < m_cheat.cheatmap.size(); cheatindex += 1) if (m_cheat.cheatmap[cheatindex].state == 1) { - uint64_t cheat_value = cheat_read_extended(&m_cheat, *space, m_cheat.cheatmap[cheatindex].offset); - uint64_t comp_byte = (ref == 0) ? m_cheat.cheatmap[cheatindex].previous_value : m_cheat.cheatmap[cheatindex].first_value; - uint8_t disable_byte = false; + u64 cheat_value = cheat_read_extended(&m_cheat, *space, m_cheat.cheatmap[cheatindex].offset); + u64 comp_byte = (ref == 0) ? m_cheat.cheatmap[cheatindex].previous_value : m_cheat.cheatmap[cheatindex].first_value; + u8 disable_byte = false; switch (condition) { @@ -2065,30 +2065,30 @@ void debugger_commands::execute_cheatnext(int ref, int params, const char *param case CHEAT_DECREASE: if (m_cheat.signed_cheat) - disable_byte = ((int64_t)cheat_value >= (int64_t)comp_byte); + disable_byte = (s64(cheat_value) >= s64(comp_byte)); else - disable_byte = ((uint64_t)cheat_value >= (uint64_t)comp_byte); + disable_byte = (u64(cheat_value) >= u64(comp_byte)); break; case CHEAT_INCREASE: if (m_cheat.signed_cheat) - disable_byte = ((int64_t)cheat_value <= (int64_t)comp_byte); + disable_byte = (s64(cheat_value) <= s64(comp_byte)); else - disable_byte = ((uint64_t)cheat_value <= (uint64_t)comp_byte); + disable_byte = (u64(cheat_value) <= u64(comp_byte)); break; case CHEAT_DECREASE_OR_EQUAL: if (m_cheat.signed_cheat) - disable_byte = ((int64_t)cheat_value > (int64_t)comp_byte); + disable_byte = (s64(cheat_value) > s64(comp_byte)); else - disable_byte = ((uint64_t)cheat_value > (uint64_t)comp_byte); + disable_byte = (u64(cheat_value) > u64(comp_byte)); break; case CHEAT_INCREASE_OR_EQUAL: if (m_cheat.signed_cheat) - disable_byte = ((int64_t)cheat_value < (int64_t)comp_byte); + disable_byte = (s64(cheat_value) < s64(comp_byte)); else - disable_byte = ((uint64_t)cheat_value < (uint64_t)comp_byte); + disable_byte = (u64(cheat_value) < u64(comp_byte)); break; case CHEAT_DECREASEOF: @@ -2101,16 +2101,16 @@ void debugger_commands::execute_cheatnext(int ref, int params, const char *param case CHEAT_SMALLEROF: if (m_cheat.signed_cheat) - disable_byte = ((int64_t)cheat_value >= (int64_t)comp_value); + disable_byte = (s64(cheat_value) >= s64(comp_value)); else - disable_byte = ((uint64_t)cheat_value >= (uint64_t)comp_value); + disable_byte = (u64(cheat_value) >= u64(comp_value)); break; case CHEAT_GREATEROF: if (m_cheat.signed_cheat) - disable_byte = ((int64_t)cheat_value <= (int64_t)comp_value); + disable_byte = (s64(cheat_value) <= s64(comp_value)); else - disable_byte = ((uint64_t)cheat_value <= (uint64_t)comp_value); + disable_byte = (u64(cheat_value) <= u64(comp_value)); break; case CHEAT_CHANGEDBY: if (cheat_value > comp_byte) @@ -2148,9 +2148,9 @@ void debugger_commands::execute_cheatlist(int ref, int params, const char *param char spaceletter, sizeletter; address_space *space; device_t *cpu; - uint32_t active_cheat = 0; - uint64_t cheatindex; - uint64_t sizemask; + u32 active_cheat = 0; + u64 cheatindex; + u64 sizemask; FILE *f = nullptr; if (!validate_cpu_space_parameter(m_cheat.cpu, AS_PROGRAM, space)) @@ -2173,10 +2173,10 @@ void debugger_commands::execute_cheatlist(int ref, int params, const char *param switch (m_cheat.width) { default: - case 1: sizeletter = 'b'; sizemask = 0xff; break; - case 2: sizeletter = 'w'; sizemask = 0xffff; break; - case 4: sizeletter = 'd'; sizemask = 0xffffffff; break; - case 8: sizeletter = 'q'; sizemask = U64(0xffffffffffffffff); break; + case 1: sizeletter = 'b'; sizemask = 0xffU; break; + case 2: sizeletter = 'w'; sizemask = 0xffffU; break; + case 4: sizeletter = 'd'; sizemask = 0xffffffffU; break; + case 8: sizeletter = 'q'; sizemask = 0xffffffffffffffffU; break; } /* write the cheat list */ @@ -2185,7 +2185,7 @@ void debugger_commands::execute_cheatlist(int ref, int params, const char *param { if (m_cheat.cheatmap[cheatindex].state == 1) { - uint64_t value = cheat_byte_swap(&m_cheat, cheat_read_extended(&m_cheat, *space, m_cheat.cheatmap[cheatindex].offset)) & sizemask; + u64 value = cheat_byte_swap(&m_cheat, cheat_read_extended(&m_cheat, *space, m_cheat.cheatmap[cheatindex].offset)) & sizemask; offs_t address = space->byte_to_address(m_cheat.cheatmap[cheatindex].offset); if (params > 0) @@ -2226,8 +2226,8 @@ void debugger_commands::execute_cheatlist(int ref, int params, const char *param void debugger_commands::execute_cheatundo(int ref, int params, const char *param[]) { - uint64_t cheatindex; - uint32_t undo_count = 0; + u64 cheatindex; + u32 undo_count = 0; if (m_cheat.undo > 0) { @@ -2255,10 +2255,10 @@ void debugger_commands::execute_cheatundo(int ref, int params, const char *param void debugger_commands::execute_find(int ref, int params, const char *param[]) { - uint64_t offset, endoffset, length; + u64 offset, endoffset, length; address_space *space; - uint64_t data_to_find[256]; - uint8_t data_size[256]; + u64 data_to_find[256]; + u8 data_size[256]; int cur_data_size; int data_count = 0; int found = 0; @@ -2300,10 +2300,10 @@ void debugger_commands::execute_find(int ref, int params, const char *param[]) { /* check for a 'b','w','d',or 'q' prefix */ data_size[data_count] = cur_data_size; - if (tolower((uint8_t)pdata[0]) == 'b' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 1; pdata += 2; } - if (tolower((uint8_t)pdata[0]) == 'w' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 2; pdata += 2; } - if (tolower((uint8_t)pdata[0]) == 'd' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 4; pdata += 2; } - if (tolower((uint8_t)pdata[0]) == 'q' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 8; pdata += 2; } + if (tolower(u8(pdata[0])) == 'b' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 1; pdata += 2; } + if (tolower(u8(pdata[0])) == 'w' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 2; pdata += 2; } + if (tolower(u8(pdata[0])) == 'd' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 4; pdata += 2; } + if (tolower(u8(pdata[0])) == 'q' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 8; pdata += 2; } /* look for a wildcard */ if (!strcmp(pdata, "?")) @@ -2316,7 +2316,7 @@ void debugger_commands::execute_find(int ref, int params, const char *param[]) } /* now search */ - for (uint64_t i = offset; i <= endoffset; i += data_size[0]) + for (u64 i = offset; i <= endoffset; i += data_size[0]) { int suboffset = 0; int match = 1; @@ -2326,10 +2326,10 @@ void debugger_commands::execute_find(int ref, int params, const char *param[]) { switch (data_size[j]) { - case 1: match = ((uint8_t)m_cpu.read_byte(*space, i + suboffset, true) == (uint8_t)data_to_find[j]); break; - case 2: match = ((uint16_t)m_cpu.read_word(*space, i + suboffset, true) == (uint16_t)data_to_find[j]); break; - case 4: match = ((uint32_t)m_cpu.read_dword(*space, i + suboffset, true) == (uint32_t)data_to_find[j]); break; - case 8: match = ((uint64_t)m_cpu.read_qword(*space, i + suboffset, true) == (uint64_t)data_to_find[j]); break; + case 1: match = (u8(m_cpu.read_byte(*space, i + suboffset, true)) == u8(data_to_find[j])); break; + case 2: match = (u16(m_cpu.read_word(*space, i + suboffset, true)) == u16(data_to_find[j])); break; + case 4: match = (u32(m_cpu.read_dword(*space, i + suboffset, true)) == u32(data_to_find[j])); break; + case 8: match = (u64(m_cpu.read_qword(*space, i + suboffset, true)) == u64(data_to_find[j])); break; default: /* all other cases are wildcards */ break; } suboffset += data_size[j] & 0x0f; @@ -2339,7 +2339,7 @@ void debugger_commands::execute_find(int ref, int params, const char *param[]) if (match) { found++; - m_console.printf("Found at %0*X\n", space->addrchars(), (uint32_t)space->byte_to_address(i)); + m_console.printf("Found at %0*X\n", space->addrchars(), u32(space->byte_to_address(i))); } } @@ -2355,7 +2355,7 @@ void debugger_commands::execute_find(int ref, int params, const char *param[]) void debugger_commands::execute_dasm(int ref, int params, const char *param[]) { - uint64_t offset, length, bytes = 1; + u64 offset, length, bytes = 1; int minbytes, maxbytes, byteswidth; address_space *space, *decrypted_space; FILE *f; @@ -2401,25 +2401,27 @@ void debugger_commands::execute_dasm(int ref, int params, const char *param[]) /* now write the data out */ util::ovectorstream output; + util::ovectorstream disasm; output.reserve(512); - for (uint64_t i = 0; i < length; ) + for (u64 i = 0; i < length; ) { int pcbyte = space->address_to_byte(offset + i) & space->bytemask(); - char disasm[200]; const char *comment; offs_t tempaddr; int numbytes = 0; output.clear(); output.rdbuf()->clear(); + disasm.clear(); + disasm.seekp(0); /* print the address */ - stream_format(output, "%0*X: ", space->logaddrchars(), (uint32_t)space->byte_to_address(pcbyte)); + stream_format(output, "%0*X: ", space->logaddrchars(), u32(space->byte_to_address(pcbyte))); /* make sure we can translate the address */ tempaddr = pcbyte; if (space->device().memory().translate(space->spacenum(), TRANSLATE_FETCH_DEBUG, tempaddr)) { - uint8_t opbuf[64], argbuf[64]; + u8 opbuf[64], argbuf[64]; /* fetch the bytes up to the maximum */ for (numbytes = 0; numbytes < maxbytes; numbytes++) @@ -2445,7 +2447,8 @@ void debugger_commands::execute_dasm(int ref, int params, const char *param[]) } /* add the disassembly */ - stream_format(output, "%s", disasm); + disasm.put('\0'); + stream_format(output, "%s", &disasm.vec()[0]); /* attempt to add the comment */ comment = space->device().debug()->comment_text(tempaddr); @@ -2573,7 +2576,7 @@ void debugger_commands::execute_history(int ref, int params, const char *param[] else decrypted_space = space; - uint64_t count = device_debug::HISTORY_SIZE; + u64 count = device_debug::HISTORY_SIZE; if (!validate_number_parameter(param[1], &count)) return; @@ -2597,17 +2600,18 @@ void debugger_commands::execute_history(int ref, int params, const char *param[] /* fetch the bytes up to the maximum */ offs_t pcbyte = space->address_to_byte(pc) & space->bytemask(); - uint8_t opbuf[64], argbuf[64]; + u8 opbuf[64], argbuf[64]; for (int numbytes = 0; numbytes < maxbytes; numbytes++) { opbuf[numbytes] = m_cpu.read_opcode(*decrypted_space, pcbyte + numbytes, 1); argbuf[numbytes] = m_cpu.read_opcode(*space, pcbyte + numbytes, 1); } - char buffer[200]; + util::ovectorstream buffer; dasmintf->disassemble(buffer, pc, opbuf, argbuf); + buffer.put('\0'); - m_console.printf("%0*X: %s\n", space->logaddrchars(), pc, buffer); + m_console.printf("%0*X: %s\n", space->logaddrchars(), pc, &buffer.vec()[0]); } } @@ -2619,7 +2623,7 @@ void debugger_commands::execute_history(int ref, int params, const char *param[] void debugger_commands::execute_trackpc(int ref, int params, const char *param[]) { // Gather the on/off switch (if present) - uint64_t turnOn = true; + u64 turnOn = true; if (!validate_number_parameter(param[0], &turnOn)) return; @@ -2629,7 +2633,7 @@ void debugger_commands::execute_trackpc(int ref, int params, const char *param[] return; // Should we clear the existing data? - uint64_t clear = false; + u64 clear = false; if (!validate_number_parameter(param[2], &clear)) return; @@ -2661,7 +2665,7 @@ void debugger_commands::execute_trackpc(int ref, int params, const char *param[] void debugger_commands::execute_trackmem(int ref, int params, const char *param[]) { // Gather the on/off switch (if present) - uint64_t turnOn = true; + u64 turnOn = true; if (!validate_number_parameter(param[0], &turnOn)) return; @@ -2671,7 +2675,7 @@ void debugger_commands::execute_trackmem(int ref, int params, const char *param[ return; // Should we clear the existing data? - uint64_t clear = false; + u64 clear = false; if (!validate_number_parameter(param[2], &clear)) return; @@ -2699,7 +2703,7 @@ void debugger_commands::execute_trackmem(int ref, int params, const char *param[ void debugger_commands::execute_pcatmem(int ref, int params, const char *param[]) { // Gather the required address parameter - uint64_t address; + u64 address; if (!validate_number_parameter(param[0], &address)) return; @@ -2715,7 +2719,7 @@ void debugger_commands::execute_pcatmem(int ref, int params, const char *param[] // Get the value of memory at the address const int native_data_width = space->data_width() / 8; - const uint64_t data = m_cpu.read_memory(*space, space->address_to_byte(address), native_data_width, true); + const u64 data = m_cpu.read_memory(*space, space->address_to_byte(address), native_data_width, true); // Recover the pc & print const address_spacenum space_num = (address_spacenum)ref; @@ -2791,7 +2795,7 @@ void debugger_commands::execute_map(int ref, int params, const char *param[]) { address_space *space; offs_t taddress; - uint64_t address; + u64 address; int intention; /* validate parameters */ @@ -2899,7 +2903,7 @@ void debugger_commands::execute_symlist(int ref, int params, const char **param) { const symbol_entry *entry = symtable->find(namelist[symnum]); assert(entry != nullptr); - uint64_t value = entry->value(); + u64 value = entry->value(); /* only display "register" type symbols */ m_console.printf("%s = %X", namelist[symnum], value); diff --git a/src/emu/debug/debugcmd.h b/src/emu/debug/debugcmd.h index b65b49b68ea..ac57622abd5 100644 --- a/src/emu/debug/debugcmd.h +++ b/src/emu/debug/debugcmd.h @@ -8,10 +8,10 @@ *********************************************************************/ -#pragma once +#ifndef MAME_EMU_DEBUG_DEBUGCMD_H +#define MAME_EMU_DEBUG_DEBUGCMD_H -#ifndef __DEBUGCMD_H__ -#define __DEBUGCMD_H__ +#pragma once #include "emu.h" #include "debugcpu.h" @@ -29,7 +29,7 @@ public: bool validate_boolean_parameter(const char *param, bool *result); /* validates a parameter as a numeric value */ - bool validate_number_parameter(const char *param, uint64_t *result); + bool validate_number_parameter(const char *param, u64 *result); /* validates a parameter as a cpu */ bool validate_cpu_parameter(const char *param, device_t **result); @@ -41,55 +41,55 @@ private: struct global_entry { void * base; - uint32_t size; + u32 size; }; struct cheat_map { - uint64_t offset; - uint64_t first_value; - uint64_t previous_value; - uint8_t state:1; - uint8_t undo:7; + u64 offset; + u64 first_value; + u64 previous_value; + u8 state:1; + u8 undo:7; }; // TODO [RH 31 May 2016]: Move this cheat stuff into its own class struct cheat_system { char cpu[2]; - uint8_t width; + u8 width; std::vector cheatmap; - uint8_t undo; - uint8_t signed_cheat; - uint8_t swapped_cheat; + u8 undo; + u8 signed_cheat; + u8 swapped_cheat; }; struct cheat_region_map { - uint64_t offset; - uint64_t endoffset; + u64 offset; + u64 endoffset; const char *share; - uint8_t disabled; + u8 disabled; }; bool debug_command_parameter_expression(const char *param, parsed_expression &result); bool debug_command_parameter_command(const char *param); bool cheat_address_is_valid(address_space &space, offs_t address); - uint64_t cheat_sign_extend(const cheat_system *cheatsys, uint64_t value); - uint64_t cheat_byte_swap(const cheat_system *cheatsys, uint64_t value); - uint64_t cheat_read_extended(const cheat_system *cheatsys, address_space &space, offs_t address); + u64 cheat_sign_extend(const cheat_system *cheatsys, u64 value); + u64 cheat_byte_swap(const cheat_system *cheatsys, u64 value); + u64 cheat_read_extended(const cheat_system *cheatsys, address_space &space, offs_t address); - uint64_t execute_min(symbol_table &table, void *ref, int params, const uint64_t *param); - uint64_t execute_max(symbol_table &table, void *ref, int params, const uint64_t *param); - uint64_t execute_if(symbol_table &table, void *ref, int params, const uint64_t *param); + u64 execute_min(symbol_table &table, void *ref, int params, const u64 *param); + u64 execute_max(symbol_table &table, void *ref, int params, const u64 *param); + u64 execute_if(symbol_table &table, void *ref, int params, const u64 *param); - uint64_t global_get(symbol_table &table, void *ref); - void global_set(symbol_table &table, void *ref, uint64_t value); + u64 global_get(symbol_table &table, void *ref); + void global_set(symbol_table &table, void *ref, u64 value); - int mini_printf(char *buffer, const char *format, int params, uint64_t *param); + int mini_printf(char *buffer, const char *format, int params, u64 *param); void execute_trace_internal(int ref, int params, const char *param[], bool trace_over); @@ -161,8 +161,8 @@ private: void execute_dumpkbd(int ref, int params, const char **param); running_machine& m_machine; - debugger_cpu& m_cpu; - debugger_console& m_console; + debugger_cpu& m_cpu; + debugger_console& m_console; global_entry *m_global_array; cheat_system m_cheat; @@ -170,4 +170,4 @@ private: static const size_t MAX_GLOBALS; }; -#endif +#endif // MAME_EMU_DEBUG_DEBUGCMD_H diff --git a/src/emu/debug/debugcon.cpp b/src/emu/debug/debugcon.cpp index b0a7e1dd2a4..8cd565cbfa1 100644 --- a/src/emu/debug/debugcon.cpp +++ b/src/emu/debug/debugcon.cpp @@ -165,12 +165,12 @@ CMDERR debugger_console::internal_execute_command(bool execute, int params, char return CMDERR_NONE; /* the first parameter has the command and the real first parameter; separate them */ - for (p = param[0]; *p && isspace((uint8_t)*p); p++) { } - for (command = p; *p && !isspace((uint8_t)*p); p++) { } + for (p = param[0]; *p && isspace(u8(*p)); p++) { } + for (command = p; *p && !isspace(u8(*p)); p++) { } if (*p != 0) { *p++ = 0; - for ( ; *p && isspace((uint8_t)*p); p++) { } + for ( ; *p && isspace(u8(*p)); p++) { } if (*p != 0) param[0] = p; else @@ -271,7 +271,7 @@ CMDERR debugger_console::internal_parse_command(const char *original_command, bo case '+': if (parendex == 0 && paramcount == 1 && p[1] == '+') isexpr = true; *p = c; break; case '=': if (parendex == 0 && paramcount == 1) isexpr = true; *p = c; break; case 0: foundend = true; break; - default: *p = tolower((uint8_t)c); break; + default: *p = tolower(u8(c)); break; } } } @@ -290,7 +290,7 @@ CMDERR debugger_console::internal_parse_command(const char *original_command, bo command_start = params[0]; /* allow for "do" commands */ - if (tolower((uint8_t)command_start[0] == 'd') && tolower((uint8_t)command_start[1] == 'o') && isspace((uint8_t)command_start[2])) + if (tolower(u8(command_start[0])) == 'd' && tolower(u8(command_start[1])) == 'o' && isspace(u8(command_start[2]))) { isexpr = true; command_start += 3; @@ -301,7 +301,7 @@ CMDERR debugger_console::internal_parse_command(const char *original_command, bo { try { - uint64_t expresult; + u64 expresult; parsed_expression expression(m_machine.debugger().cpu().get_visible_symtable(), command_start, &expresult); } catch (expression_error &err) @@ -368,7 +368,7 @@ CMDERR debugger_console::validate_command(const char *command) register_command - register a command handler -------------------------------------------------*/ -void debugger_console::register_command(const char *command, uint32_t flags, int ref, int minparams, int maxparams, std::function handler) +void debugger_console::register_command(const char *command, u32 flags, int ref, int minparams, int maxparams, std::function handler) { assert_always(m_machine.phase() == MACHINE_PHASE_INIT, "Can only call register_command() at init time!"); assert_always((m_machine.debug_flags & DEBUG_FLAG_ENABLED) != 0, "Cannot call register_command() when debugger is not running"); diff --git a/src/emu/debug/debugcon.h b/src/emu/debug/debugcon.h index 7a06c68c5f1..cd226c93866 100644 --- a/src/emu/debug/debugcon.h +++ b/src/emu/debug/debugcon.h @@ -67,7 +67,7 @@ ***************************************************************************/ /* CMDERR is an error code for command evaluation */ -typedef uint32_t CMDERR; +typedef u32 CMDERR; class debugger_console { @@ -77,7 +77,7 @@ public: /* command handling */ CMDERR execute_command(const char *command, bool echo); CMDERR validate_command(const char *command); - void register_command(const char *command, uint32_t flags, int ref, int minparams, int maxparams, std::function handler); + void register_command(const char *command, u32 flags, int ref, int minparams, int maxparams, std::function handler); /* console management */ void vprintf(util::format_argument_pack const &args); @@ -118,7 +118,7 @@ private: const char * params; const char * help; std::function handler; - uint32_t flags; + u32 flags; int ref; int minparams; int maxparams; diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index b8ef947b4f8..5bab1e3ec72 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -52,7 +52,7 @@ debugger_cpu::debugger_cpu(running_machine &machine) { screen_device *first_screen = m_machine.first_screen(); - m_tempvar = make_unique_clear(NUM_TEMP_VARIABLES); + m_tempvar = make_unique_clear(NUM_TEMP_VARIABLES); /* create a global symbol table */ m_symtable = std::make_unique(&m_machine); @@ -357,7 +357,7 @@ bool debugger_cpu::comment_load(bool is_inline) memory space -------------------------------------------------*/ -uint8_t debugger_cpu::read_byte(address_space &space, offs_t address, bool apply_translation) +u8 debugger_cpu::read_byte(address_space &space, offs_t address, bool apply_translation) { device_memory_interface &memory = space.device().memory(); @@ -369,8 +369,8 @@ uint8_t debugger_cpu::read_byte(address_space &space, offs_t address, bool apply space.set_debugger_access(true); /* translate if necessary; if not mapped, return 0xff */ - uint64_t custom; - uint8_t result; + u64 custom; + u8 result; if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_READ_DEBUG, address)) { result = 0xff; @@ -396,16 +396,16 @@ uint8_t debugger_cpu::read_byte(address_space &space, offs_t address, bool apply memory space -------------------------------------------------*/ -uint16_t debugger_cpu::read_word(address_space &space, offs_t address, bool apply_translation) +u16 debugger_cpu::read_word(address_space &space, offs_t address, bool apply_translation) { /* mask against the logical byte mask */ address &= space.logbytemask(); - uint16_t result; + u16 result; if (!WORD_ALIGNED(address)) { /* if this is misaligned read, or if there are no word readers, just read two bytes */ - uint8_t byte0 = read_byte(space, address + 0, apply_translation); - uint8_t byte1 = read_byte(space, address + 1, apply_translation); + u8 byte0 = read_byte(space, address + 0, apply_translation); + u8 byte1 = read_byte(space, address + 1, apply_translation); /* based on the endianness, the result is assembled differently */ if (space.endianness() == ENDIANNESS_LITTLE) @@ -422,7 +422,7 @@ uint16_t debugger_cpu::read_word(address_space &space, offs_t address, bool appl space.set_debugger_access(true); /* translate if necessary; if not mapped, return 0xffff */ - uint64_t custom; + u64 custom; if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_READ_DEBUG, address)) { result = 0xffff; @@ -450,16 +450,16 @@ uint16_t debugger_cpu::read_word(address_space &space, offs_t address, bool appl memory space -------------------------------------------------*/ -uint32_t debugger_cpu::read_dword(address_space &space, offs_t address, bool apply_translation) +u32 debugger_cpu::read_dword(address_space &space, offs_t address, bool apply_translation) { /* mask against the logical byte mask */ address &= space.logbytemask(); - uint32_t result; + u32 result; if (!DWORD_ALIGNED(address)) { /* if this is a misaligned read, or if there are no dword readers, just read two words */ - uint16_t word0 = read_word(space, address + 0, apply_translation); - uint16_t word1 = read_word(space, address + 2, apply_translation); + u16 word0 = read_word(space, address + 0, apply_translation); + u16 word1 = read_word(space, address + 2, apply_translation); /* based on the endianness, the result is assembled differently */ if (space.endianness() == ENDIANNESS_LITTLE) @@ -475,7 +475,7 @@ uint32_t debugger_cpu::read_dword(address_space &space, offs_t address, bool app m_debugger_access = true; space.set_debugger_access(true); - uint64_t custom; + u64 custom; if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_READ_DEBUG, address)) { /* translate if necessary; if not mapped, return 0xffffffff */ result = 0xffffffff; @@ -503,22 +503,22 @@ uint32_t debugger_cpu::read_dword(address_space &space, offs_t address, bool app memory space -------------------------------------------------*/ -uint64_t debugger_cpu::read_qword(address_space &space, offs_t address, bool apply_translation) +u64 debugger_cpu::read_qword(address_space &space, offs_t address, bool apply_translation) { /* mask against the logical byte mask */ address &= space.logbytemask(); - uint64_t result; + u64 result; if (!QWORD_ALIGNED(address)) { /* if this is a misaligned read, or if there are no qword readers, just read two dwords */ - uint32_t dword0 = read_dword(space, address + 0, apply_translation); - uint32_t dword1 = read_dword(space, address + 4, apply_translation); + u32 dword0 = read_dword(space, address + 0, apply_translation); + u32 dword1 = read_dword(space, address + 4, apply_translation); /* based on the endianness, the result is assembled differently */ if (space.endianness() == ENDIANNESS_LITTLE) - result = dword0 | ((uint64_t)dword1 << 32); + result = dword0 | (u64(dword1) << 32); else - result = dword1 | ((uint64_t)dword0 << 32); + result = dword1 | (u64(dword0) << 32); } else { /* otherwise, this proceeds like the byte case */ @@ -529,10 +529,10 @@ uint64_t debugger_cpu::read_qword(address_space &space, offs_t address, bool app space.set_debugger_access(true); /* translate if necessary; if not mapped, return 0xffffffffffffffff */ - uint64_t custom; + u64 custom; if (apply_translation && !memory.translate(space.spacenum(), TRANSLATE_READ_DEBUG, address)) { - result = ~(uint64_t)0; + result = ~u64(0); } else if (memory.read(space.spacenum(), address, 8, custom)) { /* if there is a custom read handler, and it returns true, use that value */ @@ -557,9 +557,9 @@ uint64_t debugger_cpu::read_qword(address_space &space, offs_t address, bool app from the specified memory space -------------------------------------------------*/ -uint64_t debugger_cpu::read_memory(address_space &space, offs_t address, int size, bool apply_translation) +u64 debugger_cpu::read_memory(address_space &space, offs_t address, int size, bool apply_translation) { - uint64_t result = ~(uint64_t)0 >> (64 - 8*size); + u64 result = ~u64(0) >> (64 - 8*size); switch (size) { case 1: result = read_byte(space, address, apply_translation); break; @@ -576,7 +576,7 @@ uint64_t debugger_cpu::read_memory(address_space &space, offs_t address, int siz memory space -------------------------------------------------*/ -void debugger_cpu::write_byte(address_space &space, offs_t address, uint8_t data, bool apply_translation) +void debugger_cpu::write_byte(address_space &space, offs_t address, u8 data, bool apply_translation) { device_memory_interface &memory = space.device().memory(); @@ -612,7 +612,7 @@ void debugger_cpu::write_byte(address_space &space, offs_t address, uint8_t data memory space -------------------------------------------------*/ -void debugger_cpu::write_word(address_space &space, offs_t address, uint16_t data, bool apply_translation) +void debugger_cpu::write_word(address_space &space, offs_t address, u16 data, bool apply_translation) { /* mask against the logical byte mask */ address &= space.logbytemask(); @@ -667,7 +667,7 @@ void debugger_cpu::write_word(address_space &space, offs_t address, uint16_t dat memory space -------------------------------------------------*/ -void debugger_cpu::write_dword(address_space &space, offs_t address, uint32_t data, bool apply_translation) +void debugger_cpu::write_dword(address_space &space, offs_t address, u32 data, bool apply_translation) { /* mask against the logical byte mask */ address &= space.logbytemask(); @@ -721,7 +721,7 @@ void debugger_cpu::write_dword(address_space &space, offs_t address, uint32_t da memory space -------------------------------------------------*/ -void debugger_cpu::write_qword(address_space &space, offs_t address, uint64_t data, bool apply_translation) +void debugger_cpu::write_qword(address_space &space, offs_t address, u64 data, bool apply_translation) { /* mask against the logical byte mask */ address &= space.logbytemask(); @@ -776,7 +776,7 @@ void debugger_cpu::write_qword(address_space &space, offs_t address, uint64_t da specified memory space -------------------------------------------------*/ -void debugger_cpu::write_memory(address_space &space, offs_t address, uint64_t data, int size, bool apply_translation) +void debugger_cpu::write_memory(address_space &space, offs_t address, u64 data, int size, bool apply_translation) { switch (size) { @@ -793,11 +793,11 @@ void debugger_cpu::write_memory(address_space &space, offs_t address, uint64_t d given offset from opcode space -------------------------------------------------*/ -uint64_t debugger_cpu::read_opcode(address_space &space, offs_t address, int size) +u64 debugger_cpu::read_opcode(address_space &space, offs_t address, int size) { device_memory_interface &memory = space.device().memory(); - uint64_t result = ~(uint64_t)0 & (~(uint64_t)0 >> (64 - 8*size)), result2; + u64 result = ~u64(0) & (~u64(0) >> (64 - 8*size)), result2; /* keep in logical range */ address &= space.logbytemask(); @@ -816,8 +816,8 @@ uint64_t debugger_cpu::read_opcode(address_space &space, offs_t address, int siz if (size > space.data_width() / 8) { int halfsize = size / 2; - uint64_t r0 = read_opcode(space, address + 0, halfsize); - uint64_t r1 = read_opcode(space, address + halfsize, halfsize); + u64 r0 = read_opcode(space, address + 0, halfsize); + u64 r1 = read_opcode(space, address + halfsize, halfsize); if (space.endianness() == ENDIANNESS_LITTLE) return r0 | (r1 << (8 * halfsize)); @@ -1005,7 +1005,7 @@ void debugger_cpu::process_source_file() /* strip whitespace */ int i = (int)strlen(buf); - while((i > 0) && (isspace((uint8_t)buf[i-1]))) + while((i > 0) && (isspace(u8(buf[i-1])))) buf[--i] = '\0'; /* execute the command */ @@ -1040,7 +1040,7 @@ device_t* debugger_cpu::expression_get_device(const char *tag) space -------------------------------------------------*/ -uint64_t debugger_cpu::expression_read_memory(void *param, const char *name, expression_space spacenum, uint32_t address, int size) +u64 debugger_cpu::expression_read_memory(void *param, const char *name, expression_space spacenum, u32 address, int size) { switch (spacenum) { @@ -1126,9 +1126,9 @@ uint64_t debugger_cpu::expression_read_memory(void *param, const char *name, exp directly from an opcode or RAM pointer -------------------------------------------------*/ -uint64_t debugger_cpu::expression_read_program_direct(address_space &space, int opcode, offs_t address, int size) +u64 debugger_cpu::expression_read_program_direct(address_space &space, int opcode, offs_t address, int size) { - uint8_t *base; + u8 *base; /* adjust the address into a byte address, but not if being called recursively */ if ((opcode & 2) == 0) @@ -1140,8 +1140,8 @@ uint64_t debugger_cpu::expression_read_program_direct(address_space &space, int int halfsize = size / 2; /* read each half, from lower address to upper address */ - uint64_t r0 = expression_read_program_direct(space, opcode | 2, address + 0, halfsize); - uint64_t r1 = expression_read_program_direct(space, opcode | 2, address + halfsize, halfsize); + u64 r0 = expression_read_program_direct(space, opcode | 2, address + 0, halfsize); + u64 r1 = expression_read_program_direct(space, opcode | 2, address + halfsize, halfsize); /* assemble based on the target endianness */ if (space.endianness() == ENDIANNESS_LITTLE) @@ -1157,7 +1157,7 @@ uint64_t debugger_cpu::expression_read_program_direct(address_space &space, int offs_t lowmask = space.data_width() / 8 - 1; /* get the base of memory, aligned to the address minus the lowbits */ - base = (uint8_t *)space.get_read_ptr(address & ~lowmask); + base = (u8 *)space.get_read_ptr(address & ~lowmask); /* if we have a valid base, return the appropriate byte */ if (base != nullptr) @@ -1178,10 +1178,10 @@ uint64_t debugger_cpu::expression_read_program_direct(address_space &space, int from a memory region -------------------------------------------------*/ -uint64_t debugger_cpu::expression_read_memory_region(const char *rgntag, offs_t address, int size) +u64 debugger_cpu::expression_read_memory_region(const char *rgntag, offs_t address, int size) { memory_region *region = m_machine.root_device().memregion(rgntag); - uint64_t result = ~(uint64_t)0 >> (64 - 8*size); + u64 result = ~u64(0) >> (64 - 8*size); /* make sure we get a valid base before proceeding */ if (region != nullptr) @@ -1190,7 +1190,7 @@ uint64_t debugger_cpu::expression_read_memory_region(const char *rgntag, offs_t if (size > 1) { int halfsize = size / 2; - uint64_t r0, r1; + u64 r0, r1; /* read each half, from lower address to upper address */ r0 = expression_read_memory_region(rgntag, address + 0, halfsize); @@ -1207,8 +1207,8 @@ uint64_t debugger_cpu::expression_read_memory_region(const char *rgntag, offs_t else if (address < region->bytes()) { /* lowmask specified which address bits are within the databus width */ - uint32_t lowmask = region->bytewidth() - 1; - uint8_t *base = region->base() + (address & ~lowmask); + u32 lowmask = region->bytewidth() - 1; + u8 *base = region->base() + (address & ~lowmask); /* if we have a valid base, return the appropriate byte */ if (region->endianness() == ENDIANNESS_LITTLE) @@ -1227,7 +1227,7 @@ uint64_t debugger_cpu::expression_read_memory_region(const char *rgntag, offs_t space -------------------------------------------------*/ -void debugger_cpu::expression_write_memory(void *param, const char *name, expression_space spacenum, uint32_t address, int size, uint64_t data) +void debugger_cpu::expression_write_memory(void *param, const char *name, expression_space spacenum, u32 address, int size, u64 data) { device_t *device = nullptr; device_memory_interface *memory; @@ -1299,7 +1299,7 @@ void debugger_cpu::expression_write_memory(void *param, const char *name, expres directly to an opcode or RAM pointer -------------------------------------------------*/ -void debugger_cpu::expression_write_program_direct(address_space &space, int opcode, offs_t address, int size, uint64_t data) +void debugger_cpu::expression_write_program_direct(address_space &space, int opcode, offs_t address, int size, u64 data) { /* adjust the address into a byte address, but not if being called recursively */ if ((opcode & 2) == 0) @@ -1311,8 +1311,8 @@ void debugger_cpu::expression_write_program_direct(address_space &space, int opc int halfsize = size / 2; /* break apart based on the target endianness */ - uint64_t halfmask = ~(uint64_t)0 >> (64 - 8 * halfsize); - uint64_t r0, r1; + u64 halfmask = ~u64(0) >> (64 - 8 * halfsize); + u64 r0, r1; if (space.endianness() == ENDIANNESS_LITTLE) { r0 = data & halfmask; @@ -1336,7 +1336,7 @@ void debugger_cpu::expression_write_program_direct(address_space &space, int opc offs_t lowmask = space.data_width() / 8 - 1; /* get the base of memory, aligned to the address minus the lowbits */ - uint8_t *base = (uint8_t *)space.get_read_ptr(address & ~lowmask); + u8 *base = (u8 *)space.get_read_ptr(address & ~lowmask); /* if we have a valid base, write the appropriate byte */ if (base != nullptr) @@ -1356,7 +1356,7 @@ void debugger_cpu::expression_write_program_direct(address_space &space, int opc from a memory region -------------------------------------------------*/ -void debugger_cpu::expression_write_memory_region(const char *rgntag, offs_t address, int size, uint64_t data) +void debugger_cpu::expression_write_memory_region(const char *rgntag, offs_t address, int size, u64 data) { memory_region *region = m_machine.root_device().memregion(rgntag); @@ -1369,8 +1369,8 @@ void debugger_cpu::expression_write_memory_region(const char *rgntag, offs_t add int halfsize = size / 2; /* break apart based on the target endianness */ - uint64_t halfmask = ~(uint64_t)0 >> (64 - 8 * halfsize); - uint64_t r0, r1; + u64 halfmask = ~u64(0) >> (64 - 8 * halfsize); + u64 r0, r1; if (region->endianness() == ENDIANNESS_LITTLE) { r0 = data & halfmask; @@ -1391,8 +1391,8 @@ void debugger_cpu::expression_write_memory_region(const char *rgntag, offs_t add else if (address < region->bytes()) { /* lowmask specified which address bits are within the databus width */ - uint32_t lowmask = region->bytewidth() - 1; - uint8_t *base = region->base() + (address & ~lowmask); + u32 lowmask = region->bytewidth() - 1; + u8 *base = region->base() + (address & ~lowmask); /* if we have a valid base, set the appropriate byte */ if (region->endianness() == ENDIANNESS_LITTLE) @@ -1491,7 +1491,7 @@ expression_error::error_code debugger_cpu::expression_validate(void *param, cons get_beamx - get beam horizontal position -------------------------------------------------*/ -uint64_t debugger_cpu::get_beamx(symbol_table &table, void *ref) +u64 debugger_cpu::get_beamx(symbol_table &table, void *ref) { screen_device *screen = reinterpret_cast(ref); return (screen != nullptr) ? screen->hpos() : 0; @@ -1502,7 +1502,7 @@ uint64_t debugger_cpu::get_beamx(symbol_table &table, void *ref) get_beamy - get beam vertical position -------------------------------------------------*/ -uint64_t debugger_cpu::get_beamy(symbol_table &table, void *ref) +u64 debugger_cpu::get_beamy(symbol_table &table, void *ref) { screen_device *screen = reinterpret_cast(ref); return (screen != nullptr) ? screen->vpos() : 0; @@ -1513,7 +1513,7 @@ uint64_t debugger_cpu::get_beamy(symbol_table &table, void *ref) get_frame - get current frame number -------------------------------------------------*/ -uint64_t debugger_cpu::get_frame(symbol_table &table, void *ref) +u64 debugger_cpu::get_frame(symbol_table &table, void *ref) { screen_device *screen = reinterpret_cast(ref); return (screen != nullptr) ? screen->frame_number() : 0; @@ -1525,7 +1525,7 @@ uint64_t debugger_cpu::get_frame(symbol_table &table, void *ref) 'cpunum' symbol -------------------------------------------------*/ -uint64_t debugger_cpu::get_cpunum(symbol_table &table, void *ref) +u64 debugger_cpu::get_cpunum(symbol_table &table, void *ref) { execute_interface_iterator iter(m_machine.root_device()); return iter.indexof(m_visiblecpu->execute()); @@ -1825,7 +1825,7 @@ void device_debug::instruction_hook(offs_t curpc) // are we tracking our recent pc visits? if (m_track_pc) { - const uint32_t crc = compute_opcode_crc32(curpc); + const u32 crc = compute_opcode_crc32(curpc); m_track_pc_set.insert(dasm_pc_tag(curpc, crc)); } @@ -1952,7 +1952,7 @@ void device_debug::instruction_hook(offs_t curpc) // memory read happens //------------------------------------------------- -void device_debug::memory_read_hook(address_space &space, offs_t address, uint64_t mem_mask) +void device_debug::memory_read_hook(address_space &space, offs_t address, u64 mem_mask) { // check watchpoints watchpoint_check(space, WATCHPOINT_READ, address, 0, mem_mask); @@ -1969,7 +1969,7 @@ void device_debug::memory_read_hook(address_space &space, offs_t address, uint64 // memory write happens //------------------------------------------------- -void device_debug::memory_write_hook(address_space &space, offs_t address, uint64_t data, uint64_t mem_mask) +void device_debug::memory_write_hook(address_space &space, offs_t address, u64 data, u64 mem_mask) { if (m_track_mem) { @@ -2134,7 +2134,7 @@ void device_debug::go_exception(int exception) // delay elapses //------------------------------------------------- -void device_debug::go_milliseconds(uint64_t milliseconds) +void device_debug::go_milliseconds(u64 milliseconds) { assert(m_exec != nullptr); @@ -2165,7 +2165,7 @@ void device_debug::halt_on_next_instruction_impl(util::format_argument_pack::iterator, bool> const inserted = m_comment_set.insert(newComment); if (!inserted.second) @@ -2553,7 +2553,7 @@ void device_debug::comment_add(offs_t addr, const char *comment, rgb_t color) bool device_debug::comment_remove(offs_t addr) { - const uint32_t crc = compute_opcode_crc32(addr); + const u32 crc = compute_opcode_crc32(addr); size_t const removed = m_comment_set.erase(dasm_comment(addr, crc, "", 0xffffffff)); if (removed != 0U) m_comment_change++; return removed != 0U; @@ -2566,7 +2566,7 @@ bool device_debug::comment_remove(offs_t addr) const char *device_debug::comment_text(offs_t addr) const { - const uint32_t crc = compute_opcode_crc32(addr); + const u32 crc = compute_opcode_crc32(addr); auto comment = m_comment_set.find(dasm_comment(addr, crc, "", 0)); if (comment == m_comment_set.end()) return nullptr; return comment->m_text.c_str(); @@ -2608,7 +2608,7 @@ bool device_debug::comment_import(xml_data_node const &cpunode, bool is_inline) offs_t address = datanode->get_attribute_int("address", 0); rgb_t color = datanode->get_attribute_int("color", 0); - uint32_t crc; + u32 crc; sscanf(datanode->get_attribute_string("crc", nullptr), "%08X", &crc); // add the new comment @@ -2626,7 +2626,7 @@ bool device_debug::comment_import(xml_data_node const &cpunode, bool is_inline) // the opcode bytes at the given address //------------------------------------------------- -uint32_t device_debug::compute_opcode_crc32(offs_t pc) const +u32 device_debug::compute_opcode_crc32(offs_t pc) const { // Basically the same thing as dasm_wrapped, but with some tiny savings assert(m_memory != nullptr); @@ -2637,7 +2637,7 @@ uint32_t device_debug::compute_opcode_crc32(offs_t pc) const offs_t pcbyte = space.address_to_byte(pc) & space.bytemask(); // fetch the bytes up to the maximum - uint8_t opbuf[64], argbuf[64]; + u8 opbuf[64], argbuf[64]; int maxbytes = (m_disasm != nullptr) ? m_disasm->max_opcode_bytes() : 1; for (int numbytes = 0; numbytes < maxbytes; numbytes++) { @@ -2645,12 +2645,11 @@ uint32_t device_debug::compute_opcode_crc32(offs_t pc) const argbuf[numbytes] = m_device.machine().debugger().cpu().read_opcode(space, pcbyte + numbytes, 1); } - uint32_t numbytes = maxbytes; + u32 numbytes = maxbytes; if (m_disasm != nullptr) { // disassemble to our buffer - char diasmbuf[200]; - memset(diasmbuf, 0x00, 200); + std::ostringstream diasmbuf; numbytes = m_disasm->disassemble(diasmbuf, pc, opbuf, argbuf) & DASMFLAG_LENGTHMASK; } @@ -2881,12 +2880,12 @@ void device_debug::watchpoint_update_flags(address_space &space) // for a given CPU and address space //------------------------------------------------- -void device_debug::watchpoint_check(address_space& space, int type, offs_t address, uint64_t value_to_write, uint64_t mem_mask) +void device_debug::watchpoint_check(address_space& space, int type, offs_t address, u64 value_to_write, u64 mem_mask) { space.machine().debugger().cpu().watchpoint_check(space, type, address, value_to_write, mem_mask, m_wplist); } -void debugger_cpu::watchpoint_check(address_space& space, int type, offs_t address, uint64_t value_to_write, uint64_t mem_mask, device_debug::watchpoint** wplist) +void debugger_cpu::watchpoint_check(address_space& space, int type, offs_t address, u64 value_to_write, u64 mem_mask, device_debug::watchpoint** wplist) { // if we're within debugger code, don't stop if (m_within_instruction_hook || m_debugger_access) @@ -2915,15 +2914,16 @@ void debugger_cpu::watchpoint_check(address_space& space, int type, offs_t addre } // (1<<(size*8))-1 won't work when size is 8; let's just use a lut - static const uint64_t masks[] = {0, - 0xff, - 0xffff, - 0xffffff, - 0xffffffff, - U64(0xffffffffff), - U64(0xffffffffffff), - U64(0xffffffffffffff), - U64(0xffffffffffffffff)}; + static const u64 masks[] = { + 0x0U, + 0xffU, + 0xffffU, + 0xffffffU, + 0xffffffffU, + 0xffffffffffU, + 0xffffffffffffU, + 0xffffffffffffffU, + 0xffffffffffffffffU}; value_to_write &= masks[size]; if (space.endianness() == ENDIANNESS_LITTLE) @@ -2962,9 +2962,9 @@ void debugger_cpu::watchpoint_check(address_space& space, int type, offs_t addre { buffer = string_format("Stopped at watchpoint %X writing %s to %08X (PC=%X)", wp->index(), sizes[size], space.byte_to_address(address), pc); if (value_to_write >> 32) - buffer.append(string_format(" (data=%X%08X)", (uint32_t)(value_to_write >> 32), (uint32_t)value_to_write)); + buffer.append(string_format(" (data=%X%08X)", u32(value_to_write >> 32), u32(value_to_write))); else - buffer.append(string_format(" (data=%X)", (uint32_t)value_to_write)); + buffer.append(string_format(" (data=%X)", u32(value_to_write))); } else buffer = string_format("Stopped at watchpoint %X reading %s from %08X (PC=%X)", wp->index(), sizes[size], space.byte_to_address(address), pc); @@ -3029,7 +3029,7 @@ void device_debug::hotspot_check(address_space &space, offs_t address) // buffer and then disassembling them //------------------------------------------------- -uint32_t device_debug::dasm_wrapped(std::string &buffer, offs_t pc) +u32 device_debug::dasm_wrapped(std::string &buffer, offs_t pc) { assert(m_memory != nullptr && m_disasm != nullptr); @@ -3039,7 +3039,7 @@ uint32_t device_debug::dasm_wrapped(std::string &buffer, offs_t pc) offs_t pcbyte = space.address_to_byte(pc) & space.bytemask(); // fetch the bytes up to the maximum - uint8_t opbuf[64], argbuf[64]; + u8 opbuf[64], argbuf[64]; int maxbytes = m_disasm->max_opcode_bytes(); for (int numbytes = 0; numbytes < maxbytes; numbytes++) { @@ -3048,10 +3048,9 @@ uint32_t device_debug::dasm_wrapped(std::string &buffer, offs_t pc) } // disassemble to our buffer - char diasmbuf[200]; - memset(diasmbuf, 0x00, 200); - uint32_t result = m_disasm->disassemble(diasmbuf, pc, opbuf, argbuf); - buffer.assign(diasmbuf); + std::ostringstream stream; + uint32_t result = m_disasm->disassemble(stream, pc, opbuf, argbuf); + buffer = stream.str(); return result; } @@ -3061,7 +3060,7 @@ uint32_t device_debug::dasm_wrapped(std::string &buffer, offs_t pc) // current instruction pointer //------------------------------------------------- -uint64_t device_debug::get_current_pc(symbol_table &table, void *ref) +u64 device_debug::get_current_pc(symbol_table &table, void *ref) { device_t *device = reinterpret_cast(table.globalref()); return device->safe_pcbase(); @@ -3073,7 +3072,7 @@ uint64_t device_debug::get_current_pc(symbol_table &table, void *ref) // 'cycles' symbol //------------------------------------------------- -uint64_t device_debug::get_cycles(symbol_table &table, void *ref) +u64 device_debug::get_cycles(symbol_table &table, void *ref) { device_t *device = reinterpret_cast(table.globalref()); return device->debug()->m_exec->cycles_remaining(); @@ -3085,7 +3084,7 @@ uint64_t device_debug::get_cycles(symbol_table &table, void *ref) // 'totalcycles' symbol //------------------------------------------------- -uint64_t device_debug::get_totalcycles(symbol_table &table, void *ref) +u64 device_debug::get_totalcycles(symbol_table &table, void *ref) { device_t *device = reinterpret_cast(table.globalref()); return device->debug()->m_total_cycles; @@ -3097,7 +3096,7 @@ uint64_t device_debug::get_totalcycles(symbol_table &table, void *ref) // 'lastinstructioncycles' symbol //------------------------------------------------- -uint64_t device_debug::get_lastinstructioncycles(symbol_table &table, void *ref) +u64 device_debug::get_lastinstructioncycles(symbol_table &table, void *ref) { device_t *device = reinterpret_cast(table.globalref()); device_debug *debug = device->debug(); @@ -3110,7 +3109,7 @@ uint64_t device_debug::get_lastinstructioncycles(symbol_table &table, void *ref) // symbols //------------------------------------------------- -uint64_t device_debug::get_logunmap(symbol_table &table, void *ref) +u64 device_debug::get_logunmap(symbol_table &table, void *ref) { address_space &space = *reinterpret_cast(table.globalref()); return space.log_unmap(); @@ -3122,7 +3121,7 @@ uint64_t device_debug::get_logunmap(symbol_table &table, void *ref) // symbols //------------------------------------------------- -void device_debug::set_logunmap(symbol_table &table, void *ref, uint64_t value) +void device_debug::set_logunmap(symbol_table &table, void *ref, u64 value) { address_space &space = *reinterpret_cast(table.globalref()); space.set_log_unmap(value ? true : false); @@ -3134,7 +3133,7 @@ void device_debug::set_logunmap(symbol_table &table, void *ref, uint64_t value) // state symbols //------------------------------------------------- -uint64_t device_debug::get_state(symbol_table &table, void *ref) +u64 device_debug::get_state(symbol_table &table, void *ref) { device_t *device = reinterpret_cast(table.globalref()); return device->debug()->m_state->state_int(reinterpret_cast(ref)); @@ -3146,7 +3145,7 @@ uint64_t device_debug::get_state(symbol_table &table, void *ref) // state symbols //------------------------------------------------- -void device_debug::set_state(symbol_table &table, void *ref, uint64_t value) +void device_debug::set_state(symbol_table &table, void *ref, u64 value) { device_t *device = reinterpret_cast(table.globalref()); device->debug()->m_state->set_state_int(reinterpret_cast(ref), value); @@ -3454,7 +3453,7 @@ void device_debug::tracer::flush() // dasm_pc_tag - constructor //------------------------------------------------- -device_debug::dasm_pc_tag::dasm_pc_tag(const offs_t& address, const uint32_t& crc) +device_debug::dasm_pc_tag::dasm_pc_tag(const offs_t& address, const u32& crc) : m_address(address), m_crc(crc) { @@ -3466,7 +3465,7 @@ device_debug::dasm_pc_tag::dasm_pc_tag(const offs_t& address, const uint32_t& cr device_debug::dasm_memory_access::dasm_memory_access(const address_spacenum& address_space, const offs_t& address, - const uint64_t& data, + const u64& data, const offs_t& pc) : m_address_space(address_space), m_address(address), @@ -3479,7 +3478,7 @@ device_debug::dasm_memory_access::dasm_memory_access(const address_spacenum& add // dasm_comment - constructor //------------------------------------------------- -device_debug::dasm_comment::dasm_comment(offs_t address, uint32_t crc, const char *text, rgb_t color) +device_debug::dasm_comment::dasm_comment(offs_t address, u32 crc, const char *text, rgb_t color) : dasm_pc_tag(address, crc), m_text(text), m_color(std::move(color)) diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index bc262e382ef..079b17d1fd0 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -10,8 +10,8 @@ #pragma once -#ifndef __DEBUGCPU_H__ -#define __DEBUGCPU_H__ +#ifndef MAME_EMU_DEBUG_DEBUGCPU_H +#define MAME_EMU_DEBUG_DEBUGCPU_H #include "express.h" @@ -22,11 +22,11 @@ // CONSTANTS //************************************************************************** -const uint8_t WATCHPOINT_READ = 1; -const uint8_t WATCHPOINT_WRITE = 2; -const uint8_t WATCHPOINT_READWRITE = WATCHPOINT_READ | WATCHPOINT_WRITE; +constexpr u8 WATCHPOINT_READ = 1; +constexpr u8 WATCHPOINT_WRITE = 2; +constexpr u8 WATCHPOINT_READWRITE = WATCHPOINT_READ | WATCHPOINT_WRITE; -const int COMMENT_VERSION = 1; +constexpr int COMMENT_VERSION = 1; @@ -127,7 +127,7 @@ public: address_space & m_space; // address space int m_index; // user reported index bool m_enabled; // enabled? - uint8_t m_type; // type (read/write) + u8 m_type; // type (read/write) offs_t m_address; // start address offs_t m_length; // length of watch area parsed_expression m_condition; // condition @@ -179,8 +179,8 @@ public: void interrupt_hook(int irqline); void exception_hook(int exception); void instruction_hook(offs_t curpc); - void memory_read_hook(address_space &space, offs_t address, uint64_t mem_mask); - void memory_write_hook(address_space &space, offs_t address, uint64_t data, uint64_t mem_mask); + void memory_read_hook(address_space &space, offs_t address, u64 mem_mask); + void memory_write_hook(address_space &space, offs_t address, u64 data, u64 mem_mask); // hooks into our operations void set_instruction_hook(debug_instruction_hook_func hook); @@ -199,7 +199,7 @@ public: void go_vblank(); void go_interrupt(int irqline = -1); void go_exception(int exception); - void go_milliseconds(uint64_t milliseconds); + void go_milliseconds(u64 milliseconds); void go_next_device(); template @@ -240,11 +240,11 @@ public: void comment_add(offs_t address, const char *comment, rgb_t color); bool comment_remove(offs_t addr); const char *comment_text(offs_t addr) const; - uint32_t comment_count() const { return m_comment_set.size(); } - uint32_t comment_change_count() const { return m_comment_change; } + u32 comment_count() const { return m_comment_set.size(); } + u32 comment_change_count() const { return m_comment_change; } bool comment_export(xml_data_node &node); bool comment_import(xml_data_node const &node, bool is_inline); - uint32_t compute_opcode_crc32(offs_t pc) const; + u32 compute_opcode_crc32(offs_t pc) const; // history offs_t history_pc(int index) const; @@ -259,7 +259,7 @@ public: void set_track_mem(bool value) { m_track_mem = value; } offs_t track_mem_pc_from_space_address_data(const address_spacenum& space, const offs_t& address, - const uint64_t& data) const; + const u64& data) const; void track_mem_data_clear() { m_track_mem_set.clear(); } // tracing @@ -279,24 +279,24 @@ private: // internal helpers void prepare_for_step_overout(offs_t pc); - uint32_t dasm_wrapped(std::string &buffer, offs_t pc); + u32 dasm_wrapped(std::string &buffer, offs_t pc); // breakpoint and watchpoint helpers void breakpoint_update_flags(); void breakpoint_check(offs_t pc); void watchpoint_update_flags(address_space &space); - void watchpoint_check(address_space &space, int type, offs_t address, uint64_t value_to_write, uint64_t mem_mask); + void watchpoint_check(address_space &space, int type, offs_t address, u64 value_to_write, u64 mem_mask); void hotspot_check(address_space &space, offs_t address); // symbol get/set callbacks - static uint64_t get_current_pc(symbol_table &table, void *ref); - static uint64_t get_cycles(symbol_table &table, void *ref); - static uint64_t get_totalcycles(symbol_table &table, void *ref); - static uint64_t get_lastinstructioncycles(symbol_table &table, void *ref); - static uint64_t get_logunmap(symbol_table &table, void *ref); - static void set_logunmap(symbol_table &table, void *ref, uint64_t value); - static uint64_t get_state(symbol_table &table, void *ref); - static void set_state(symbol_table &table, void *ref, uint64_t value); + static u64 get_current_pc(symbol_table &table, void *ref); + static u64 get_cycles(symbol_table &table, void *ref); + static u64 get_totalcycles(symbol_table &table, void *ref); + static u64 get_lastinstructioncycles(symbol_table &table, void *ref); + static u64 get_logunmap(symbol_table &table, void *ref); + static void set_logunmap(symbol_table &table, void *ref, u64 value); + static u64 get_state(symbol_table &table, void *ref); + static void set_state(symbol_table &table, void *ref, u64 value); // basic device information device_t & m_device; // device we are attached to @@ -306,7 +306,7 @@ private: device_disasm_interface * m_disasm; // disasm interface, if present // global state - uint32_t m_flags; // debugging flags for this CPU + u32 m_flags; // debugging flags for this CPU symbol_table m_symtable; // symbol table for expression evaluation debug_instruction_hook_func m_instrhook; // per-instruction callback hook @@ -320,12 +320,12 @@ private: int m_stopirq; // stop IRQ number for DEBUG_FLAG_STOP_INTERRUPT int m_stopexception; // stop exception number for DEBUG_FLAG_STOP_EXCEPTION attotime m_endexectime; // ending time of the current execution - uint64_t m_total_cycles; // current total cycles - uint64_t m_last_total_cycles; // last total cycles + u64 m_total_cycles; // current total cycles + u64 m_last_total_cycles; // last total cycles // history offs_t m_pc_history[HISTORY_SIZE]; // history of recent PCs - uint32_t m_pc_history_index; // current history index + u32 m_pc_history_index; // current history index // breakpoints and watchpoints breakpoint * m_bplist; // list of breakpoints @@ -366,7 +366,7 @@ private: offs_t m_access; // access address offs_t m_pc; // PC of the access address_space * m_space; // space where the access occurred - uint32_t m_count; // number of hits + u32 m_count; // number of hits }; std::vector m_hotspots; // hotspot list int m_hotspot_threshhold; // threshhold for the number of hits to print @@ -375,7 +375,7 @@ private: class dasm_pc_tag { public: - dasm_pc_tag(const offs_t& address, const uint32_t& crc); + dasm_pc_tag(const offs_t& address, const u32& crc); // required to be included in a set bool operator < (const dasm_pc_tag& rhs) const @@ -386,7 +386,7 @@ private: } offs_t m_address; // Stores [nothing] for a given address & crc32 - uint32_t m_crc; + u32 m_crc; }; std::set m_track_pc_set; bool m_track_pc; @@ -395,13 +395,13 @@ private: class dasm_comment : public dasm_pc_tag { public: - dasm_comment(offs_t address, uint32_t crc, const char *text, rgb_t color); + dasm_comment(offs_t address, u32 crc, const char *text, rgb_t color); std::string m_text; // Stores comment text & color for a given address & crc32 - rgb_t m_color; + rgb_t m_color; }; std::set m_comment_set; // collection of comments - uint32_t m_comment_change; // change counter for comments + u32 m_comment_change; // change counter for comments // memory tracking class dasm_memory_access @@ -409,7 +409,7 @@ private: public: dasm_memory_access(const address_spacenum& address_space, const offs_t& address, - const uint64_t& data, + const u64& data, const offs_t& pc); // required to be included in a set @@ -426,31 +426,31 @@ private: // Stores the PC for a given address, memory region, and data value address_spacenum m_address_space; offs_t m_address; - uint64_t m_data; + u64 m_data; mutable offs_t m_pc; }; std::set m_track_mem_set; bool m_track_mem; // internal flag values - static const uint32_t DEBUG_FLAG_OBSERVING = 0x00000001; // observing this CPU - static const uint32_t DEBUG_FLAG_HISTORY = 0x00000002; // tracking this CPU's history - static const uint32_t DEBUG_FLAG_TRACING = 0x00000004; // tracing this CPU - static const uint32_t DEBUG_FLAG_TRACING_OVER = 0x00000008; // tracing this CPU with step over behavior - static const uint32_t DEBUG_FLAG_HOOKED = 0x00000010; // per-instruction callback hook - static const uint32_t DEBUG_FLAG_STEPPING = 0x00000020; // CPU is single stepping - static const uint32_t DEBUG_FLAG_STEPPING_OVER = 0x00000040; // CPU is stepping over a function - static const uint32_t DEBUG_FLAG_STEPPING_OUT = 0x00000080; // CPU is stepping out of a function - static const uint32_t DEBUG_FLAG_STOP_PC = 0x00000100; // there is a pending stop at cpu->breakpc - static const uint32_t DEBUG_FLAG_STOP_INTERRUPT = 0x00000400; // there is a pending stop on the next interrupt - static const uint32_t DEBUG_FLAG_STOP_EXCEPTION = 0x00000800; // there is a pending stop on the next exception - static const uint32_t DEBUG_FLAG_STOP_VBLANK = 0x00001000; // there is a pending stop on the next VBLANK - static const uint32_t DEBUG_FLAG_STOP_TIME = 0x00002000; // there is a pending stop at cpu->stoptime - static const uint32_t DEBUG_FLAG_LIVE_BP = 0x00010000; // there are live breakpoints for this CPU + static constexpr u32 DEBUG_FLAG_OBSERVING = 0x00000001; // observing this CPU + static constexpr u32 DEBUG_FLAG_HISTORY = 0x00000002; // tracking this CPU's history + static constexpr u32 DEBUG_FLAG_TRACING = 0x00000004; // tracing this CPU + static constexpr u32 DEBUG_FLAG_TRACING_OVER = 0x00000008; // tracing this CPU with step over behavior + static constexpr u32 DEBUG_FLAG_HOOKED = 0x00000010; // per-instruction callback hook + static constexpr u32 DEBUG_FLAG_STEPPING = 0x00000020; // CPU is single stepping + static constexpr u32 DEBUG_FLAG_STEPPING_OVER = 0x00000040; // CPU is stepping over a function + static constexpr u32 DEBUG_FLAG_STEPPING_OUT = 0x00000080; // CPU is stepping out of a function + static constexpr u32 DEBUG_FLAG_STOP_PC = 0x00000100; // there is a pending stop at cpu->breakpc + static constexpr u32 DEBUG_FLAG_STOP_INTERRUPT = 0x00000400; // there is a pending stop on the next interrupt + static constexpr u32 DEBUG_FLAG_STOP_EXCEPTION = 0x00000800; // there is a pending stop on the next exception + static constexpr u32 DEBUG_FLAG_STOP_VBLANK = 0x00001000; // there is a pending stop on the next VBLANK + static constexpr u32 DEBUG_FLAG_STOP_TIME = 0x00002000; // there is a pending stop at cpu->stoptime + static constexpr u32 DEBUG_FLAG_LIVE_BP = 0x00010000; // there are live breakpoints for this CPU - static const uint32_t DEBUG_FLAG_STEPPING_ANY = DEBUG_FLAG_STEPPING | DEBUG_FLAG_STEPPING_OVER | DEBUG_FLAG_STEPPING_OUT; - static const uint32_t DEBUG_FLAG_TRACING_ANY = DEBUG_FLAG_TRACING | DEBUG_FLAG_TRACING_OVER; - static const uint32_t DEBUG_FLAG_TRANSIENT = DEBUG_FLAG_STEPPING_ANY | DEBUG_FLAG_STOP_PC | + static constexpr u32 DEBUG_FLAG_STEPPING_ANY = DEBUG_FLAG_STEPPING | DEBUG_FLAG_STEPPING_OVER | DEBUG_FLAG_STEPPING_OUT; + static constexpr u32 DEBUG_FLAG_TRACING_ANY = DEBUG_FLAG_TRACING | DEBUG_FLAG_TRACING_OVER; + static constexpr u32 DEBUG_FLAG_TRANSIENT = DEBUG_FLAG_STEPPING_ANY | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_STOP_INTERRUPT | DEBUG_FLAG_STOP_EXCEPTION | DEBUG_FLAG_STOP_VBLANK | DEBUG_FLAG_STOP_TIME; }; @@ -510,46 +510,46 @@ public: /* ----- debugger memory accessors ----- */ /* return a byte from the specified memory space */ - uint8_t read_byte(address_space &space, offs_t address, bool apply_translation); + u8 read_byte(address_space &space, offs_t address, bool apply_translation); /* return a word from the specified memory space */ - uint16_t read_word(address_space &space, offs_t address, bool apply_translation); + u16 read_word(address_space &space, offs_t address, bool apply_translation); /* return a dword from the specified memory space */ - uint32_t read_dword(address_space &space, offs_t address, bool apply_translation); + u32 read_dword(address_space &space, offs_t address, bool apply_translation); /* return a qword from the specified memory space */ - uint64_t read_qword(address_space &space, offs_t address, bool apply_translation); + u64 read_qword(address_space &space, offs_t address, bool apply_translation); /* return 1,2,4 or 8 bytes from the specified memory space */ - uint64_t read_memory(address_space &space, offs_t address, int size, bool apply_translation); + u64 read_memory(address_space &space, offs_t address, int size, bool apply_translation); /* write a byte to the specified memory space */ - void write_byte(address_space &space, offs_t address, uint8_t data, bool apply_translation); + void write_byte(address_space &space, offs_t address, u8 data, bool apply_translation); /* write a word to the specified memory space */ - void write_word(address_space &space, offs_t address, uint16_t data, bool apply_translation); + void write_word(address_space &space, offs_t address, u16 data, bool apply_translation); /* write a dword to the specified memory space */ - void write_dword(address_space &space, offs_t address, uint32_t data, bool apply_translation); + void write_dword(address_space &space, offs_t address, u32 data, bool apply_translation); /* write a qword to the specified memory space */ - void write_qword(address_space &space, offs_t address, uint64_t data, bool apply_translation); + void write_qword(address_space &space, offs_t address, u64 data, bool apply_translation); /* write 1,2,4 or 8 bytes to the specified memory space */ - void write_memory(address_space &space, offs_t address, uint64_t data, int size, bool apply_translation); + void write_memory(address_space &space, offs_t address, u64 data, int size, bool apply_translation); /* read 1,2,4 or 8 bytes at the given offset from opcode space */ - uint64_t read_opcode(address_space &space, offs_t offset, int size); + u64 read_opcode(address_space &space, offs_t offset, int size); // getters bool within_instruction_hook() const { return m_within_instruction_hook; } bool memory_modified() const { return m_memory_modified; } int execution_state() const { return m_execution_state; } device_t *live_cpu() { return m_livecpu; } - uint32_t get_breakpoint_index() { return m_bpindex++; } - uint32_t get_watchpoint_index() { return m_wpindex++; } - uint32_t get_registerpoint_index() { return m_rpindex++; } + u32 get_breakpoint_index() { return m_bpindex++; } + u32 get_watchpoint_index() { return m_wpindex++; } + u32 get_registerpoint_index() { return m_rpindex++; } // setters void set_visible_cpu(device_t * visiblecpu) { m_visiblecpu = visiblecpu; } @@ -568,26 +568,26 @@ public: void ensure_comments_loaded(); void reset_transient_flags(); void process_source_file(); - void watchpoint_check(address_space& space, int type, offs_t address, uint64_t value_to_write, uint64_t mem_mask, device_debug::watchpoint** wplist); + void watchpoint_check(address_space& space, int type, offs_t address, u64 value_to_write, u64 mem_mask, device_debug::watchpoint** wplist); private: static const size_t NUM_TEMP_VARIABLES; /* expression handlers */ - uint64_t expression_read_memory(void *param, const char *name, expression_space space, uint32_t address, int size); - uint64_t expression_read_program_direct(address_space &space, int opcode, offs_t address, int size); - uint64_t expression_read_memory_region(const char *rgntag, offs_t address, int size); - void expression_write_memory(void *param, const char *name, expression_space space, uint32_t address, int size, uint64_t data); - void expression_write_program_direct(address_space &space, int opcode, offs_t address, int size, uint64_t data); - void expression_write_memory_region(const char *rgntag, offs_t address, int size, uint64_t data); + u64 expression_read_memory(void *param, const char *name, expression_space space, u32 address, int size); + u64 expression_read_program_direct(address_space &space, int opcode, offs_t address, int size); + u64 expression_read_memory_region(const char *rgntag, offs_t address, int size); + void expression_write_memory(void *param, const char *name, expression_space space, u32 address, int size, u64 data); + void expression_write_program_direct(address_space &space, int opcode, offs_t address, int size, u64 data); + void expression_write_memory_region(const char *rgntag, offs_t address, int size, u64 data); expression_error::error_code expression_validate(void *param, const char *name, expression_space space); device_t* expression_get_device(const char *tag); /* variable getters/setters */ - uint64_t get_cpunum(symbol_table &table, void *ref); - uint64_t get_beamx(symbol_table &table, void *ref); - uint64_t get_beamy(symbol_table &table, void *ref); - uint64_t get_frame(symbol_table &table, void *ref); + u64 get_cpunum(symbol_table &table, void *ref); + u64 get_beamx(symbol_table &table, void *ref); + u64 get_beamy(symbol_table &table, void *ref); + u64 get_frame(symbol_table &table, void *ref); /* internal helpers */ void on_vblank(screen_device &device, bool vblank_state); @@ -602,25 +602,25 @@ private: std::unique_ptr m_symtable; // global symbol table - bool m_within_instruction_hook; - bool m_vblank_occurred; - bool m_memory_modified; - bool m_debugger_access; + bool m_within_instruction_hook; + bool m_vblank_occurred; + bool m_memory_modified; + bool m_debugger_access; int m_execution_state; device_t * m_stop_when_not_device; // stop execution when the device ceases to be this - uint32_t m_bpindex; - uint32_t m_wpindex; - uint32_t m_rpindex; + u32 m_bpindex; + u32 m_wpindex; + u32 m_rpindex; - uint64_t m_wpdata; - uint64_t m_wpaddr; - std::unique_ptr m_tempvar; + u64 m_wpdata; + u64 m_wpaddr; + std::unique_ptr m_tempvar; osd_ticks_t m_last_periodic_update_time; bool m_comments_loaded; }; -#endif +#endif // MAME_EMU_DEBUG_DEBUGCPU_H diff --git a/src/emu/debug/debughlp.cpp b/src/emu/debug/debughlp.cpp index 601bed4a440..ded8cafb993 100644 --- a/src/emu/debug/debughlp.cpp +++ b/src/emu/debug/debughlp.cpp @@ -1518,7 +1518,7 @@ const char *debug_get_help(const char *tag) /* make a lowercase copy of the tag */ for (i = 0; i <= taglen; i++) - tagcopy[i] = tolower((uint8_t)tag[i]); + tagcopy[i] = tolower(u8(tag[i])); /* find a match */ for (i = 0; i < ARRAY_LENGTH(static_help_list); i++) diff --git a/src/emu/debug/debughlp.h b/src/emu/debug/debughlp.h index 7f3eb6e4ad6..87881f6967f 100644 --- a/src/emu/debug/debughlp.h +++ b/src/emu/debug/debughlp.h @@ -8,8 +8,8 @@ *********************************************************************/ -#ifndef __DEBUGHLP_H__ -#define __DEBUGHLP_H__ +#ifndef MAME_EMU_DEBUG_DEBUGHLP_H +#define MAME_EMU_DEBUG_DEBUGHLP_H /*************************************************************************** @@ -19,4 +19,4 @@ /* help management */ const char * debug_get_help(const char *tag); -#endif +#endif // MAME_EMU_DEBUG_DEBUGHLP_H diff --git a/src/emu/debug/debugvw.cpp b/src/emu/debug/debugvw.cpp index c66034ef26b..f351896480e 100644 --- a/src/emu/debug/debugvw.cpp +++ b/src/emu/debug/debugvw.cpp @@ -506,7 +506,7 @@ bool debug_view_expression::recompute() // recompute the value of the expression try { - uint64_t newresult = m_parsed.execute(); + u64 newresult = m_parsed.execute(); if (newresult != m_result) { m_result = newresult; diff --git a/src/emu/debug/debugvw.h b/src/emu/debug/debugvw.h index 1dcdc9120c5..382f45e5e20 100644 --- a/src/emu/debug/debugvw.h +++ b/src/emu/debug/debugvw.h @@ -8,8 +8,8 @@ ***************************************************************************/ -#ifndef __DEBUGVIEW_H__ -#define __DEBUGVIEW_H__ +#ifndef MAME_EMU_DEBUG_DEBUGVIEW_H +#define MAME_EMU_DEBUG_DEBUGVIEW_H #include "express.h" @@ -43,36 +43,36 @@ enum debug_view_notification // attribute bits for debug_view_char.attrib -const uint8_t DCA_NORMAL = 0x00; // black on white -const uint8_t DCA_CHANGED = 0x01; // red foreground -const uint8_t DCA_SELECTED = 0x02; // light red background -const uint8_t DCA_INVALID = 0x04; // dark blue foreground -const uint8_t DCA_DISABLED = 0x08; // darker foreground -const uint8_t DCA_ANCILLARY = 0x10; // grey background -const uint8_t DCA_CURRENT = 0x20; // yellow background -const uint8_t DCA_COMMENT = 0x40; // green foreground -const uint8_t DCA_VISITED = 0x80; // light blue background +constexpr u8 DCA_NORMAL = 0x00; // black on white +constexpr u8 DCA_CHANGED = 0x01; // red foreground +constexpr u8 DCA_SELECTED = 0x02; // light red background +constexpr u8 DCA_INVALID = 0x04; // dark blue foreground +constexpr u8 DCA_DISABLED = 0x08; // darker foreground +constexpr u8 DCA_ANCILLARY = 0x10; // grey background +constexpr u8 DCA_CURRENT = 0x20; // yellow background +constexpr u8 DCA_COMMENT = 0x40; // green foreground +constexpr u8 DCA_VISITED = 0x80; // light blue background // special characters that can be passed to process_char() -const int DCH_UP = 1; // up arrow -const int DCH_DOWN = 2; // down arrow -const int DCH_LEFT = 3; // left arrow -const int DCH_RIGHT = 4; // right arrow -const int DCH_PUP = 5; // page up -const int DCH_PDOWN = 6; // page down -const int DCH_HOME = 7; // home -const int DCH_CTRLHOME = 8; // ctrl+home -const int DCH_END = 9; // end -const int DCH_CTRLEND = 10; // ctrl+end -const int DCH_CTRLRIGHT = 11; // ctrl+right -const int DCH_CTRLLEFT = 12; // ctrl+left +constexpr int DCH_UP = 1; // up arrow +constexpr int DCH_DOWN = 2; // down arrow +constexpr int DCH_LEFT = 3; // left arrow +constexpr int DCH_RIGHT = 4; // right arrow +constexpr int DCH_PUP = 5; // page up +constexpr int DCH_PDOWN = 6; // page down +constexpr int DCH_HOME = 7; // home +constexpr int DCH_CTRLHOME = 8; // ctrl+home +constexpr int DCH_END = 9; // end +constexpr int DCH_CTRLEND = 10; // ctrl+end +constexpr int DCH_CTRLRIGHT = 11; // ctrl+right +constexpr int DCH_CTRLLEFT = 12; // ctrl+left // special characters that can be passed to process_click() -const int DCK_LEFT_CLICK = 1; // left instantaneous click -const int DCK_RIGHT_CLICK = 2; // right instantaneous click -const int DCK_MIDDLE_CLICK = 3; // middle instantaneous click +constexpr int DCK_LEFT_CLICK = 1; // left instantaneous click +constexpr int DCK_RIGHT_CLICK = 2; // right instantaneous click +constexpr int DCK_MIDDLE_CLICK = 3; // middle instantaneous click //************************************************************************** @@ -90,8 +90,8 @@ typedef void (*debug_view_osd_update_func)(debug_view &view, void *osdprivate); // a single "character" in the debug view has an ASCII value and an attribute byte struct debug_view_char { - uint8_t byte; - uint8_t attrib; + u8 byte; + u8 attrib; }; @@ -101,8 +101,8 @@ class debug_view_xy public: debug_view_xy(int _x = 0, int _y = 0) : x(_x), y(_y) { } - int32_t x; - int32_t y; + s32 x; + s32 y; }; @@ -208,7 +208,7 @@ protected: // update info bool m_recompute; // does this view require a recomputation? - uint8_t m_update_level; // update level; updates when this hits 0 + u8 m_update_level; // update level; updates when this hits 0 bool m_update_pending; // true if there is a pending update bool m_osd_update_pending; // true if there is a pending update std::vector m_viewdata; // current array of view data @@ -259,8 +259,8 @@ public: // getters running_machine &machine() const { return m_machine; } bool dirty() const { return m_dirty; } - uint64_t last_value() const { return m_result; } - uint64_t value() { recompute(); return m_result; } + u64 last_value() const { return m_result; } + u64 value() { recompute(); return m_result; } const char *string() const { return m_string.c_str(); } symbol_table *context() const { return m_parsed.symbols(); } @@ -276,10 +276,10 @@ private: // internal state running_machine & m_machine; // reference to the machine bool m_dirty; // true if the expression needs to be re-evaluated - uint64_t m_result; // last result from the expression + u64 m_result; // last result from the expression parsed_expression m_parsed; // parsed expression data std::string m_string; // copy of the expression string }; -#endif +#endif // MAME_EMU_DEBUG_DEBUGVIEW_H diff --git a/src/emu/debug/dvbpoints.cpp b/src/emu/debug/dvbpoints.cpp index d7cd9527913..6bc4a008c5f 100644 --- a/src/emu/debug/dvbpoints.cpp +++ b/src/emu/debug/dvbpoints.cpp @@ -266,7 +266,7 @@ void debug_view_breakpoints::view_update() pad_ostream_to_length(linebuf, tableBreaks[5]); auto const &text(linebuf.vec()); - for (uint32_t i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) + for (u32 i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) { dest->byte = (i < text.size()) ? text[i] : ' '; dest->attrib = DCA_ANCILLARY; @@ -298,7 +298,7 @@ void debug_view_breakpoints::view_update() pad_ostream_to_length(linebuf, tableBreaks[5]); auto const &text(linebuf.vec()); - for (uint32_t i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) + for (u32 i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) { dest->byte = (i < text.size()) ? text[i] : ' '; dest->attrib = DCA_NORMAL; @@ -311,7 +311,7 @@ void debug_view_breakpoints::view_update() else { // Fill the remaining vertical space - for (uint32_t i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) + for (u32 i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) { dest->byte = ' '; dest->attrib = DCA_NORMAL; diff --git a/src/emu/debug/dvbpoints.h b/src/emu/debug/dvbpoints.h index 7e52e7d4cae..b7037e06b0f 100644 --- a/src/emu/debug/dvbpoints.h +++ b/src/emu/debug/dvbpoints.h @@ -8,8 +8,8 @@ ***************************************************************************/ -#ifndef __DVBPOINTS_H__ -#define __DVBPOINTS_H__ +#ifndef MAME_EMU_DEBUG_DVBPOINTS_H +#define MAME_EMU_DEBUG_DVBPOINTS_H #include "debugvw.h" #include "debugcpu.h" @@ -52,4 +52,4 @@ private: }; -#endif +#endif // MAME_EMU_DEBUG_DVBPOINTS_H diff --git a/src/emu/debug/dvdisasm.cpp b/src/emu/debug/dvdisasm.cpp index 3dab8d13dd3..37bb708027d 100644 --- a/src/emu/debug/dvdisasm.cpp +++ b/src/emu/debug/dvdisasm.cpp @@ -133,8 +133,8 @@ void debug_view_disasm::view_notify(debug_view_notification type) void debug_view_disasm::view_char(int chval) { debug_view_xy origcursor = m_cursor; - uint8_t end_buffer = 3; - int32_t temp; + u8 end_buffer = 3; + s32 temp; switch (chval) { @@ -250,7 +250,7 @@ offs_t debug_view_disasm::find_pc_backwards(offs_t targetpc, int numinstrs) { // fill the buffer up to the target offs_t curpcbyte = source.m_space.address_to_byte(curpc) & source.m_space.logbytemask(); - uint8_t opbuf[1024], argbuf[1024]; + u8 opbuf[1024], argbuf[1024]; while (curpcbyte < fillpcbyte) { fillpcbyte--; @@ -271,7 +271,7 @@ offs_t debug_view_disasm::find_pc_backwards(offs_t targetpc, int numinstrs) instlen = 1; if (source.m_space.device().memory().translate(source.m_space.spacenum(), TRANSLATE_FETCH, physpcbyte)) { - char dasmbuffer[100]; + std::ostringstream dasmbuffer; instlen = source.m_disasmintf->disassemble(dasmbuffer, scanpc, &opbuf[1000 + scanpcbyte - targetpcbyte], &argbuf[1000 + scanpcbyte - targetpcbyte]) & DASMFLAG_LENGTHMASK; } @@ -335,6 +335,7 @@ void debug_view_disasm::generate_bytes(offs_t pcbyte, int numbytes, int minbytes bool debug_view_disasm::recompute(offs_t pc, int startline, int lines) { + util::ovectorstream buffer; bool changed = false; const debug_view_disasm_source &source = downcast(*m_source); const int char_num = source.m_space.is_octal() ? 3 : 2; @@ -392,12 +393,13 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines) source.m_space.logaddrchars()/2*char_num, source.m_space.byte_to_address(pcbyte)); // make sure we can translate the address, and then disassemble the result - char buffer[100]; + buffer.clear(); + buffer.seekp(0); int numbytes = 0; offs_t physpcbyte = pcbyte; if (source.m_space.device().memory().translate(source.m_space.spacenum(), TRANSLATE_FETCH_DEBUG, physpcbyte)) { - uint8_t opbuf[64], argbuf[64]; + u8 opbuf[64], argbuf[64]; // fetch the bytes up to the maximum for (numbytes = 0; numbytes < maxbytes; numbytes++) @@ -410,10 +412,12 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines) pc += numbytes = source.m_disasmintf->disassemble(buffer, pc & source.m_space.logaddrmask(), opbuf, argbuf) & DASMFLAG_LENGTHMASK; } else - strcpy(buffer, ""); + buffer << ""; + + buffer.put('\0'); // append the disassembly to the buffer - util::stream_format(m_dasm.seekp(base + m_divider1 + 1), "%2$-*1$.*1$s ", m_dasm_width, buffer); + util::stream_format(m_dasm.seekp(base + m_divider1 + 1), "%2$-*1$.*1$s ", m_dasm_width, &buffer.vec()[0]); // output the right column if (m_right_column == DASM_RIGHTCOL_RAW || m_right_column == DASM_RIGHTCOL_ENCRYPTED) @@ -466,14 +470,14 @@ void debug_view_disasm::view_update() m_recompute = true; // if we're tracking a value, make sure it is visible - uint64_t previous = m_expression.last_value(); - uint64_t result = m_expression.value(); + u64 previous = m_expression.last_value(); + u64 result = m_expression.value(); if (result != previous) { offs_t resultbyte = source.m_space.address_to_byte(result) & source.m_space.logbytemask(); // see if the new result is an address we already have - uint32_t row; + u32 row; for (row = 0; row < m_byteaddress.size(); row++) if (m_byteaddress[row] == resultbyte) break; @@ -512,7 +516,7 @@ recompute: else { // determine the addresses of what we will display - offs_t backpc = find_pc_backwards((uint32_t)m_expression.value(), m_backwards_steps); + offs_t backpc = find_pc_backwards(u32(m_expression.value()), m_backwards_steps); // put ourselves back in the top left m_topleft.y = 0; @@ -527,9 +531,9 @@ recompute: if (pcbyte != m_last_pcbyte) { // find the row with the PC on it - for (uint32_t row = 0; row < m_visible.y; row++) + for (u32 row = 0; row < m_visible.y; row++) { - uint32_t effrow = m_topleft.y + row; + u32 effrow = m_topleft.y + row; if (effrow >= m_byteaddress.size()) break; if (pcbyte == m_byteaddress[effrow]) @@ -552,13 +556,13 @@ recompute: // loop over visible rows debug_view_char *dest = &m_viewdata[0]; - for (uint32_t row = 0; row < m_visible.y; row++) + for (u32 row = 0; row < m_visible.y; row++) { - uint32_t effrow = m_topleft.y + row; - uint32_t col = 0; + u32 effrow = m_topleft.y + row; + u32 col = 0; // if this visible row is valid, add it to the buffer - uint8_t attrib = DCA_NORMAL; + u8 attrib = DCA_NORMAL; if (effrow < m_byteaddress.size()) { // if we're on the line with the PC, recompute and hilight it @@ -583,10 +587,10 @@ recompute: // get the effective string const char *data = &m_dasm.vec()[effrow * m_total.x]; - uint32_t len = (uint32_t)strlen(data); + u32 len = u32(strlen(data)); // copy data - uint32_t effcol = m_topleft.x; + u32 effcol = m_topleft.x; while (col < m_visible.x && effcol < len) { dest->byte = data[effcol++]; @@ -658,7 +662,7 @@ void debug_view_disasm::set_right_column(disasm_right_column contents) // instructions displayed before the home address //------------------------------------------------- -void debug_view_disasm::set_backward_steps(uint32_t steps) +void debug_view_disasm::set_backward_steps(u32 steps) { begin_update(); m_backwards_steps = steps; @@ -672,7 +676,7 @@ void debug_view_disasm::set_backward_steps(uint32_t steps) // of the main disassembly section //------------------------------------------------- -void debug_view_disasm::set_disasm_width(uint32_t width) +void debug_view_disasm::set_disasm_width(u32 width) { begin_update(); m_dasm_width = width; diff --git a/src/emu/debug/dvdisasm.h b/src/emu/debug/dvdisasm.h index 32a4e70eba5..ef8ad581f70 100644 --- a/src/emu/debug/dvdisasm.h +++ b/src/emu/debug/dvdisasm.h @@ -8,8 +8,8 @@ ***************************************************************************/ -#ifndef __DVDISASM_H__ -#define __DVDISASM_H__ +#ifndef MAME_EMU_DEBUG_DVDISASM_H +#define MAME_EMU_DEBUG_DVDISASM_H #include "debugvw.h" @@ -69,15 +69,15 @@ public: // getters const char *expression() const { return m_expression.string(); } disasm_right_column right_column() const { return m_right_column; } - uint32_t backward_steps() const { return m_backwards_steps; } - uint32_t disasm_width() const { return m_dasm_width; } + u32 backward_steps() const { return m_backwards_steps; } + u32 disasm_width() const { return m_dasm_width; } offs_t selected_address(); // setters void set_expression(const char *expression); void set_right_column(disasm_right_column contents); - void set_backward_steps(uint32_t steps); - void set_disasm_width(uint32_t width); + void set_backward_steps(u32 steps); + void set_disasm_width(u32 width); void set_selected_address(offs_t address); protected: @@ -96,11 +96,11 @@ private: // internal state disasm_right_column m_right_column; // right column contents - uint32_t m_backwards_steps; // number of backwards steps - uint32_t m_dasm_width; // width of the disassembly area - uint8_t * m_last_direct_raw; // last direct raw value - uint8_t * m_last_direct_decrypted;// last direct decrypted value - uint32_t m_last_change_count; // last comment change count + u32 m_backwards_steps; // number of backwards steps + u32 m_dasm_width; // width of the disassembly area + u8 * m_last_direct_raw; // last direct raw value + u8 * m_last_direct_decrypted;// last direct decrypted value + u32 m_last_change_count; // last comment change count offs_t m_last_pcbyte; // last PC byte value int m_divider1, m_divider2; // left and right divider columns int m_divider3; // comment divider column @@ -115,4 +115,4 @@ private: }; -#endif +#endif // MAME_EMU_DEBUG_DVDISASM_H diff --git a/src/emu/debug/dvmemory.cpp b/src/emu/debug/dvmemory.cpp index 5b828c989bb..ca73f1ac986 100644 --- a/src/emu/debug/dvmemory.cpp +++ b/src/emu/debug/dvmemory.cpp @@ -67,7 +67,7 @@ debug_view_memory_source::debug_view_memory_source(const char *name, memory_regi m_length(region.bytes()), m_offsetxor(ENDIAN_VALUE_NE_NNE(region.endianness(), 0, region.bytewidth() - 1)), m_endianness(region.endianness()), - m_prefsize(std::min(region.bytewidth(), 8)) + m_prefsize(std::min(region.bytewidth(), 8)) { } @@ -156,7 +156,7 @@ void debug_view_memory::enumerate_sources() for (int itemnum = 0; itemnum < 10000; itemnum++) { // stop when we run out of items - uint32_t valsize, valcount; + u32 valsize, valcount; void *base; const char *itemname = machine().save().indexed_item(itemnum, base, valsize, valcount); if (itemname == nullptr) @@ -206,15 +206,15 @@ void debug_view_memory::view_notify(debug_view_notification type) //------------------------------------------------- -// uint32_to_float - return a floating point number +// u32_to_float - return a floating point number // whose 32 bit representation is value //------------------------------------------------- -static inline float uint32_to_float(uint32_t value) +static inline float u32_to_float(u32 value) { union { float f; - uint32_t i; + u32 i; } v; v.i = value; @@ -222,15 +222,15 @@ static inline float uint32_to_float(uint32_t value) } //------------------------------------------------- -// uint64_to_double - return a floating point number +// u64_to_double - return a floating point number // whose 64 bit representation is value //------------------------------------------------- -static inline float uint64_to_double(uint64_t value) +static inline float u64_to_double(u64 value) { union { double f; - uint64_t i; + u64 i; } v; v.i = value; @@ -254,18 +254,18 @@ void debug_view_memory::view_update() const memory_view_pos &posdata = s_memory_pos_table[m_data_format]; // loop over visible rows - for (uint32_t row = 0; row < m_visible.y; row++) + for (u32 row = 0; row < m_visible.y; row++) { debug_view_char *destmin = &m_viewdata[row * m_visible.x]; debug_view_char *destmax = destmin + m_visible.x; debug_view_char *destrow = destmin - m_topleft.x; - uint32_t effrow = m_topleft.y + row; + u32 effrow = m_topleft.y + row; // reset the line of data; section 1 is normal, others are ancillary, cursor is selected debug_view_char *dest = destmin; for (int ch = 0; ch < m_visible.x; ch++, dest++) { - uint32_t effcol = m_topleft.x + ch; + u32 effcol = m_topleft.x + ch; dest->byte = ' '; dest->attrib = DCA_ANCILLARY; if (m_section[1].contains(effcol)) @@ -297,13 +297,13 @@ void debug_view_memory::view_update() int spacing = posdata.m_spacing; if (m_data_format <= 8) { - uint64_t chunkdata; + u64 chunkdata; bool ismapped = read(m_bytes_per_chunk, addrbyte + chunknum * m_bytes_per_chunk, chunkdata); dest = destrow + m_section[1].m_pos + 1 + chunkindex * spacing; for (int ch = 0; ch < posdata.m_spacing; ch++, dest++) if (dest >= destmin && dest < destmax) { - uint8_t shift = posdata.m_shift[ch]; + u8 shift = posdata.m_shift[ch]; if (shift < 64) dest->byte = ismapped ? "0123456789ABCDEF"[(chunkdata >> shift) & 0x0f] : '*'; } @@ -311,7 +311,7 @@ void debug_view_memory::view_update() else { int ch; char valuetext[64]; - uint64_t chunkdata = 0; + u64 chunkdata = 0; floatx80 chunkdata80 = { 0, 0 }; bool ismapped; @@ -324,14 +324,14 @@ void debug_view_memory::view_update() switch (m_data_format) { case 9: - sprintf(valuetext, "%.8g", uint32_to_float((uint32_t)chunkdata)); + sprintf(valuetext, "%.8g", u32_to_float(u32(chunkdata))); break; case 10: - sprintf(valuetext, "%.24g", uint64_to_double(chunkdata)); + sprintf(valuetext, "%.24g", u64_to_double(chunkdata)); break; case 11: float64 f64 = floatx80_to_float64(chunkdata80); - sprintf(valuetext, "%.24g", uint64_to_double(f64)); + sprintf(valuetext, "%.24g", u64_to_double(f64)); break; } else { @@ -357,7 +357,7 @@ void debug_view_memory::view_update() for (int ch = 0; ch < m_bytes_per_row; ch++, dest++) if (dest >= destmin && dest < destmax) { - uint64_t chval; + u64 chval; bool ismapped = read(1, addrbyte + ch, chval); dest->byte = (ismapped && isprint(chval)) ? chval : '.'; } @@ -395,7 +395,7 @@ void debug_view_memory::view_char(int chval) break; case DCH_PUP: - for (uint32_t delta = (m_visible.y - 2) * m_bytes_per_row; delta > 0; delta -= m_bytes_per_row) + for (u32 delta = (m_visible.y - 2) * m_bytes_per_row; delta > 0; delta -= m_bytes_per_row) if (pos.m_address >= m_byte_offset + delta) { pos.m_address -= delta; @@ -404,7 +404,7 @@ void debug_view_memory::view_char(int chval) break; case DCH_PDOWN: - for (uint32_t delta = (m_visible.y - 2) * m_bytes_per_row; delta > 0; delta -= m_bytes_per_row) + for (u32 delta = (m_visible.y - 2) * m_bytes_per_row; delta > 0; delta -= m_bytes_per_row) if (pos.m_address <= m_maxaddr - delta) { pos.m_address += delta; @@ -449,13 +449,13 @@ void debug_view_memory::view_char(int chval) if (hexchar == nullptr) break; - uint64_t data; + u64 data; bool ismapped = read(m_bytes_per_chunk, pos.m_address, data); if (!ismapped) break; - data &= ~((uint64_t)0x0f << pos.m_shift); - data |= (uint64_t)(hexchar - hexvals) << pos.m_shift; + data &= ~(u64(0x0f) << pos.m_shift); + data |= u64(hexchar - hexvals) << pos.m_shift; write(m_bytes_per_chunk, pos.m_address, data); // fall through to the right-arrow press } @@ -549,7 +549,7 @@ void debug_view_memory::recompute() // if we are viewing a space with a minimum chunk size, clamp the bytes per chunk if (source.m_space != nullptr && source.m_space->byte_to_address(1) > 1) { - uint32_t min_bytes_per_chunk = source.m_space->byte_to_address(1); + u32 min_bytes_per_chunk = source.m_space->byte_to_address(1); while (m_bytes_per_chunk < min_bytes_per_chunk) { m_bytes_per_chunk *= 2; @@ -590,7 +590,7 @@ void debug_view_memory::recompute() } // derive total sizes from that - m_total.y = ((uint64_t)m_maxaddr - (uint64_t)m_byte_offset + (uint64_t)m_bytes_per_row /*- 1*/) / m_bytes_per_row; + m_total.y = (u64(m_maxaddr) - u64(m_byte_offset) + u64(m_bytes_per_row) /*- 1*/) / m_bytes_per_row; // reset the current cursor position set_cursor_pos(pos); @@ -732,7 +732,7 @@ void debug_view_memory::set_cursor_pos(cursor_pos pos) // read - generic memory view data reader //------------------------------------------------- -bool debug_view_memory::read(uint8_t size, offs_t offs, uint64_t &data) +bool debug_view_memory::read(u8 size, offs_t offs, u64 &data) { const debug_view_memory_source &source = downcast(*m_source); @@ -742,7 +742,7 @@ bool debug_view_memory::read(uint8_t size, offs_t offs, uint64_t &data) offs_t dummyaddr = offs; bool ismapped = m_no_translation ? true : source.m_memintf->translate(source.m_space->spacenum(), TRANSLATE_READ_DEBUG, dummyaddr); - data = ~(uint64_t)0; + data = ~u64(0); if (ismapped) { switch (size) @@ -761,7 +761,7 @@ bool debug_view_memory::read(uint8_t size, offs_t offs, uint64_t &data) { size /= 2; - uint64_t data0, data1; + u64 data0, data1; bool ismapped = read(size, offs + 0 * size, data0); ismapped |= read(size, offs + 1 * size, data1); @@ -776,7 +776,7 @@ bool debug_view_memory::read(uint8_t size, offs_t offs, uint64_t &data) offs ^= source.m_offsetxor; if (offs >= source.m_length) return false; - data = *((uint8_t *)source.m_base + offs); + data = *((u8 *)source.m_base + offs); return true; } @@ -785,9 +785,9 @@ bool debug_view_memory::read(uint8_t size, offs_t offs, uint64_t &data) // read - read a 80 bit value //------------------------------------------------- -bool debug_view_memory::read(uint8_t size, offs_t offs, floatx80 &data) +bool debug_view_memory::read(u8 size, offs_t offs, floatx80 &data) { - uint64_t t; + u64 t; bool mappedhi, mappedlo; const debug_view_memory_source &source = downcast(*m_source); @@ -810,7 +810,7 @@ bool debug_view_memory::read(uint8_t size, offs_t offs, floatx80 &data) // write - generic memory view data writer //------------------------------------------------- -void debug_view_memory::write(uint8_t size, offs_t offs, uint64_t data) +void debug_view_memory::write(u8 size, offs_t offs, u64 data) { const debug_view_memory_source &source = downcast(*m_source); @@ -848,7 +848,7 @@ void debug_view_memory::write(uint8_t size, offs_t offs, uint64_t data) offs ^= source.m_offsetxor; if (offs >= source.m_length) return; - *((uint8_t *)source.m_base + offs) = data; + *((u8 *)source.m_base + offs) = data; // hack for FD1094 editing #ifdef FD1094_HACK @@ -880,7 +880,7 @@ void debug_view_memory::set_expression(const char *expression) // chunks displayed across a row //------------------------------------------------- -void debug_view_memory::set_chunks_per_row(uint32_t rowchunks) +void debug_view_memory::set_chunks_per_row(u32 rowchunks) { if (rowchunks < 1) return; diff --git a/src/emu/debug/dvmemory.h b/src/emu/debug/dvmemory.h index 695ba5909b0..ca659b64bda 100644 --- a/src/emu/debug/dvmemory.h +++ b/src/emu/debug/dvmemory.h @@ -8,8 +8,8 @@ ***************************************************************************/ -#ifndef __DVMEMORY_H__ -#define __DVMEMORY_H__ +#ifndef MAME_EMU_DEBUG_DVMEMORY_H +#define MAME_EMU_DEBUG_DVMEMORY_H #include "softfloat/mamesf.h" #include "softfloat/softfloat.h" @@ -37,7 +37,7 @@ private: offs_t m_length; // length of memory offs_t m_offsetxor; // XOR to apply to offsets endianness_t m_endianness; // endianness of memory - uint8_t m_prefsize; // preferred bytes per chunk + u8 m_prefsize; // preferred bytes per chunk }; @@ -54,7 +54,7 @@ public: // getters const char *expression() const { return m_expression.string(); } int get_data_format() { flush_updates(); return m_data_format; } - uint32_t chunks_per_row() { flush_updates(); return m_chunks_per_row; } + u32 chunks_per_row() { flush_updates(); return m_chunks_per_row; } bool reverse() const { return m_reverse_view; } bool ascii() const { return m_ascii_view; } bool physical() const { return m_no_translation; } @@ -62,7 +62,7 @@ public: // setters void set_expression(const char *expression); - void set_chunks_per_row(uint32_t rowchunks); + void set_chunks_per_row(u32 rowchunks); void set_data_format(int format); // 1-8 current values 9 32bit floating point void set_reverse(bool reverse); void set_ascii(bool reverse); @@ -78,9 +78,9 @@ protected: private: struct cursor_pos { - cursor_pos(offs_t address = 0, uint8_t shift = 0) : m_address(address), m_shift(shift) { } + cursor_pos(offs_t address = 0, u8 shift = 0) : m_address(address), m_shift(shift) { } offs_t m_address; - uint8_t m_shift; + u8 m_shift; }; // internal helpers @@ -95,36 +95,36 @@ private: void end_update_and_set_cursor_pos(cursor_pos pos) { set_cursor_pos(pos); end_update(); } // memory access - bool read(uint8_t size, offs_t offs, uint64_t &data); - void write(uint8_t size, offs_t offs, uint64_t data); - bool read(uint8_t size, offs_t offs, floatx80 &data); + bool read(u8 size, offs_t offs, u64 &data); + void write(u8 size, offs_t offs, u64 data); + bool read(u8 size, offs_t offs, floatx80 &data); // internal state debug_view_expression m_expression; // expression describing the start address - uint32_t m_chunks_per_row; // number of chunks displayed per line - uint8_t m_bytes_per_chunk; // bytes per chunk + u32 m_chunks_per_row; // number of chunks displayed per line + u8 m_bytes_per_chunk; // bytes per chunk int m_data_format; // 1-8 current values 9 32bit floating point bool m_reverse_view; // reverse-endian view? bool m_ascii_view; // display ASCII characters? bool m_no_translation; // don't run addresses through the cpu translation hook bool m_edit_enabled; // can modify contents ? offs_t m_maxaddr; // (derived) maximum address to display - uint32_t m_bytes_per_row; // (derived) number of bytes displayed per line - uint32_t m_byte_offset; // (derived) offset of starting visible byte + u32 m_bytes_per_row; // (derived) number of bytes displayed per line + u32 m_byte_offset; // (derived) offset of starting visible byte std::string m_addrformat; // (derived) format string to use to print addresses struct section { bool contains(int x) const { return x >= m_pos && x < m_pos + m_width; } - int32_t m_pos; /* starting position */ - int32_t m_width; /* width of this section */ + s32 m_pos; /* starting position */ + s32 m_width; /* width of this section */ }; section m_section[3]; // (derived) 3 sections to manage struct memory_view_pos { - uint8_t m_spacing; /* spacing between each entry */ - uint8_t m_shift[24]; /* shift for each character */ + u8 m_spacing; /* spacing between each entry */ + u8 m_shift[24]; /* shift for each character */ }; static const memory_view_pos s_memory_pos_table[12]; // table for rendering at different data formats @@ -133,4 +133,4 @@ private: }; -#endif +#endif // MAME_EMU_DEBUG_DVMEMORY_H diff --git a/src/emu/debug/dvstate.cpp b/src/emu/debug/dvstate.cpp index fe3ea7d8082..a7a2215bd9e 100644 --- a/src/emu/debug/dvstate.cpp +++ b/src/emu/debug/dvstate.cpp @@ -142,7 +142,7 @@ void debug_view_state::recompute() // count the entries and determine the maximum tag and value sizes std::size_t count = 0; std::size_t maxtaglen = 0; - uint8_t maxvallen = 0; + u8 maxvallen = 0; for (auto const &item : m_state_list) { count++; @@ -152,8 +152,8 @@ void debug_view_state::recompute() // set the current divider and total cols m_divider = unsigned(1U + maxtaglen + 1U); - m_total.x = uint32_t(1U + maxtaglen + 2U + maxvallen + 1U); - m_total.y = uint32_t(count); + m_total.x = u32(1U + maxtaglen + 2U + maxvallen + 1U); + m_total.y = u32(count); m_topleft.x = 0; m_topleft.y = 0; @@ -187,17 +187,17 @@ void debug_view_state::view_update() // get cycle count if we have an execute interface debug_view_state_source const &source(downcast(*m_source)); - uint64_t const total_cycles(source.m_execintf ? source.m_execintf->total_cycles() : 0); + u64 const total_cycles(source.m_execintf ? source.m_execintf->total_cycles() : 0); bool const cycles_changed(m_last_update != total_cycles); // loop over rows auto it(m_state_list.begin()); screen_device const *const screen(machine().first_screen()); debug_view_char *dest(&m_viewdata[0]); - for (int32_t index = 0, limit = m_topleft.y + m_visible.y; (index < limit) || (it != m_state_list.end()); ++index) + for (s32 index = 0, limit = m_topleft.y + m_visible.y; (index < limit) || (it != m_state_list.end()); ++index) { bool const visible((index >= m_topleft.y) && (index < limit)); - uint32_t col(0); + u32 col(0); if (it != m_state_list.end()) { @@ -254,11 +254,11 @@ void debug_view_state::view_update() if (visible) { // see if we changed - const uint8_t attrib(curitem.changed() ? DCA_CHANGED: DCA_NORMAL); + const u8 attrib(curitem.changed() ? DCA_CHANGED: DCA_NORMAL); // build up a string char temp[256]; - uint32_t len(0); + u32 len(0); if (curitem.m_symbol.length() < (m_divider - 1)) { memset(&temp[len], ' ', m_divider - 1 - curitem.m_symbol.length()); @@ -278,7 +278,7 @@ void debug_view_state::view_update() temp[len] = 0; // copy data - for (uint32_t effcol = m_topleft.x; (col < m_visible.x) && (effcol < len); ++dest, ++col) + for (u32 effcol = m_topleft.x; (col < m_visible.x) && (effcol < len); ++dest, ++col) { dest->byte = temp[effcol++]; dest->attrib = attrib | ((effcol <= m_divider) ? DCA_ANCILLARY : DCA_NORMAL); @@ -305,7 +305,7 @@ void debug_view_state::view_update() // state_item - constructor //------------------------------------------------- -debug_view_state::state_item::state_item(int index, const char *name, uint8_t valuechars) +debug_view_state::state_item::state_item(int index, const char *name, u8 valuechars) : m_lastval(0) , m_currval(0) , m_index(index) @@ -319,7 +319,7 @@ debug_view_state::state_item::state_item(int index, const char *name, uint8_t va // update - update value and save previous //------------------------------------------------- -void debug_view_state::state_item::update(uint64_t newval, bool save) +void debug_view_state::state_item::update(u64 newval, bool save) { if (save) m_lastval = m_currval; diff --git a/src/emu/debug/dvstate.h b/src/emu/debug/dvstate.h index ffc24d6ba57..402ed09ec23 100644 --- a/src/emu/debug/dvstate.h +++ b/src/emu/debug/dvstate.h @@ -53,24 +53,24 @@ private: class state_item { public: - state_item(int index, const char *name, uint8_t valuechars); + state_item(int index, const char *name, u8 valuechars); state_item(const state_item &) = default; state_item(state_item &&) = default; state_item &operator=(const state_item &) = default; state_item &operator=(state_item &&) = default; - uint64_t value() const { return m_currval; } + u64 value() const { return m_currval; } bool changed() const { return m_lastval != m_currval; } int index() const { return m_index; } - uint8_t value_length() const { return m_vallen; } + u8 value_length() const { return m_vallen; } - void update(uint64_t newval, bool save); + void update(u64 newval, bool save); private: - uint64_t m_lastval; // last value - uint64_t m_currval; // current value + u64 m_lastval; // last value + u64 m_currval; // current value int m_index; // index - uint8_t m_vallen; // number of value chars + u8 m_vallen; // number of value chars public: std::string m_symbol; // symbol @@ -83,15 +83,15 @@ private: // internal state int m_divider; // dividing column - uint64_t m_last_update; // execution counter at last update + u64 m_last_update; // execution counter at last update std::vector m_state_list; // state data // constants - static const int REG_DIVIDER = -10; - static const int REG_CYCLES = -11; - static const int REG_BEAMX = -12; - static const int REG_BEAMY = -13; - static const int REG_FRAME = -14; + static constexpr int REG_DIVIDER = -10; + static constexpr int REG_CYCLES = -11; + static constexpr int REG_BEAMX = -12; + static constexpr int REG_BEAMY = -13; + static constexpr int REG_FRAME = -14; }; diff --git a/src/emu/debug/dvtext.cpp b/src/emu/debug/dvtext.cpp index 3a86e0eb877..e4672b81974 100644 --- a/src/emu/debug/dvtext.cpp +++ b/src/emu/debug/dvtext.cpp @@ -53,7 +53,7 @@ void debug_view_textbuf::view_update() m_total.x = 80; // determine the starting sequence number - uint32_t curseq = 0; + u32 curseq = 0; if (!m_at_bottom) { curseq = m_topseq; @@ -72,16 +72,16 @@ void debug_view_textbuf::view_update() // loop over visible rows debug_view_char *dest = &m_viewdata[0]; - for (uint32_t row = 0; row < m_visible.y; row++) + for (u32 row = 0; row < m_visible.y; row++) { const char *line = text_buffer_get_seqnum_line(&m_textbuf, curseq++); - uint32_t col = 0; + u32 col = 0; // if this visible row is valid, add it to the buffer if (line != nullptr) { size_t len = strlen(line); - uint32_t effcol = m_topleft.x; + u32 effcol = m_topleft.x; // copy data while (col < m_visible.x && effcol < len) diff --git a/src/emu/debug/dvtext.h b/src/emu/debug/dvtext.h index 7a0efbb9a61..01bd4ee5706 100644 --- a/src/emu/debug/dvtext.h +++ b/src/emu/debug/dvtext.h @@ -8,8 +8,8 @@ ***************************************************************************/ -#ifndef __DVTEXT_H__ -#define __DVTEXT_H__ +#ifndef MAME_EMU_DEBUG_DVTEXT_H +#define MAME_EMU_DEBUG_DVTEXT_H #include "debugvw.h" #include "textbuf.h" @@ -37,8 +37,8 @@ protected: private: // internal state text_buffer & m_textbuf; /* pointer to the text buffer */ - bool m_at_bottom; /* are we tracking new stuff being added? */ - uint32_t m_topseq; /* sequence number of the top line */ + bool m_at_bottom; /* are we tracking new stuff being added? */ + u32 m_topseq; /* sequence number of the top line */ }; @@ -58,4 +58,4 @@ class debug_view_log : public debug_view_textbuf }; -#endif +#endif // MAME_EMU_DEBUG_DVTEXT_H diff --git a/src/emu/debug/dvwpoints.cpp b/src/emu/debug/dvwpoints.cpp index 68f7d9d5389..d3eb7a00de7 100644 --- a/src/emu/debug/dvwpoints.cpp +++ b/src/emu/debug/dvwpoints.cpp @@ -300,7 +300,7 @@ void debug_view_watchpoints::view_update() pad_ostream_to_length(linebuf, tableBreaks[7]); auto const &text(linebuf.vec()); - for (uint32_t i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) + for (u32 i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) { dest->byte = (i < text.size()) ? text[i] : ' '; dest->attrib = DCA_ANCILLARY; @@ -339,7 +339,7 @@ void debug_view_watchpoints::view_update() pad_ostream_to_length(linebuf, tableBreaks[7]); auto const &text(linebuf.vec()); - for (uint32_t i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) + for (u32 i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) { dest->byte = (i < text.size()) ? text[i] : ' '; dest->attrib = DCA_NORMAL; diff --git a/src/emu/debug/express.cpp b/src/emu/debug/express.cpp index 7c3cc74b3d0..ebc7765ef31 100644 --- a/src/emu/debug/express.cpp +++ b/src/emu/debug/express.cpp @@ -112,24 +112,24 @@ class integer_symbol_entry : public symbol_entry { public: // construction/destruction - integer_symbol_entry(symbol_table &table, const char *name, symbol_table::read_write rw, uint64_t *ptr = nullptr); - integer_symbol_entry(symbol_table &table, const char *name, uint64_t constval); + integer_symbol_entry(symbol_table &table, const char *name, symbol_table::read_write rw, u64 *ptr = nullptr); + integer_symbol_entry(symbol_table &table, const char *name, u64 constval); integer_symbol_entry(symbol_table &table, const char *name, void *ref, symbol_table::getter_func getter, symbol_table::setter_func setter); // symbol access virtual bool is_lval() const override; - virtual uint64_t value() const override; - virtual void set_value(uint64_t newvalue) override; + virtual u64 value() const override; + virtual void set_value(u64 newvalue) override; private: // internal helpers - static uint64_t internal_getter(symbol_table &table, void *symref); - static void internal_setter(symbol_table &table, void *symref, uint64_t value); + static u64 internal_getter(symbol_table &table, void *symref); + static void internal_setter(symbol_table &table, void *symref, u64 value); // internal state symbol_table::getter_func m_getter; symbol_table::setter_func m_setter; - uint64_t m_value; + u64 m_value; }; @@ -142,16 +142,16 @@ public: // symbol access virtual bool is_lval() const override; - virtual uint64_t value() const override; - virtual void set_value(uint64_t newvalue) override; + virtual u64 value() const override; + virtual void set_value(u64 newvalue) override; // execution helper - virtual uint64_t execute(int numparams, const uint64_t *paramlist); + virtual u64 execute(int numparams, const u64 *paramlist); private: // internal state - uint16_t m_minparams; - uint16_t m_maxparams; + u16 m_minparams; + u16 m_maxparams; symbol_table::execute_func m_execute; }; @@ -231,7 +231,7 @@ symbol_entry::~symbol_entry() // integer_symbol_entry - constructor //------------------------------------------------- -integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name, symbol_table::read_write rw, uint64_t *ptr) +integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name, symbol_table::read_write rw, u64 *ptr) : symbol_entry(table, SMT_INTEGER, name, (ptr == nullptr) ? &m_value : ptr), m_getter(internal_getter), m_setter((rw == symbol_table::READ_ONLY) ? nullptr : internal_setter), @@ -240,7 +240,7 @@ integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name } -integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name, uint64_t constval) +integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name, u64 constval) : symbol_entry(table, SMT_INTEGER, name, &m_value), m_getter(internal_getter), m_setter(nullptr), @@ -272,7 +272,7 @@ bool integer_symbol_entry::is_lval() const // value - return the value of this symbol //------------------------------------------------- -uint64_t integer_symbol_entry::value() const +u64 integer_symbol_entry::value() const { return m_getter(m_table, m_ref); } @@ -282,7 +282,7 @@ uint64_t integer_symbol_entry::value() const // set_value - set the value of this symbol //------------------------------------------------- -void integer_symbol_entry::set_value(uint64_t newvalue) +void integer_symbol_entry::set_value(u64 newvalue) { if (m_setter != nullptr) m_setter(m_table, m_ref, newvalue); @@ -296,9 +296,9 @@ void integer_symbol_entry::set_value(uint64_t newvalue) // returning the value of a variable //------------------------------------------------- -uint64_t integer_symbol_entry::internal_getter(symbol_table &table, void *symref) +u64 integer_symbol_entry::internal_getter(symbol_table &table, void *symref) { - return *(uint64_t *)symref; + return *(u64 *)symref; } @@ -307,9 +307,9 @@ uint64_t integer_symbol_entry::internal_getter(symbol_table &table, void *symref // the value of a variable //------------------------------------------------- -void integer_symbol_entry::internal_setter(symbol_table &table, void *symref, uint64_t value) +void integer_symbol_entry::internal_setter(symbol_table &table, void *symref, u64 value) { - *(uint64_t *)symref = value; + *(u64 *)symref = value; } @@ -345,7 +345,7 @@ bool function_symbol_entry::is_lval() const // value - return the value of this symbol //------------------------------------------------- -uint64_t function_symbol_entry::value() const +u64 function_symbol_entry::value() const { throw emu_fatalerror("Symbol '%s' is a function and cannot be used in this context", m_name.c_str()); } @@ -355,7 +355,7 @@ uint64_t function_symbol_entry::value() const // set_value - set the value of this symbol //------------------------------------------------- -void function_symbol_entry::set_value(uint64_t newvalue) +void function_symbol_entry::set_value(u64 newvalue) { throw emu_fatalerror("Symbol '%s' is a function and cannot be written", m_name.c_str()); } @@ -365,7 +365,7 @@ void function_symbol_entry::set_value(uint64_t newvalue) // execute - execute the function //------------------------------------------------- -uint64_t function_symbol_entry::execute(int numparams, const uint64_t *paramlist) +u64 function_symbol_entry::execute(int numparams, const u64 *paramlist) { if (numparams < m_minparams) throw emu_fatalerror("Function '%s' requires at least %d parameters", m_name.c_str(), m_minparams); @@ -396,7 +396,7 @@ symbol_table::symbol_table(void *globalref, symbol_table *parent) //------------------------------------------------- -// add - add a new uint64_t pointer symbol +// add - add a new u64 pointer symbol //------------------------------------------------- void symbol_table::configure_memory(void *param, valid_func valid, read_func read, write_func write) @@ -409,10 +409,10 @@ void symbol_table::configure_memory(void *param, valid_func valid, read_func rea //------------------------------------------------- -// add - add a new uint64_t pointer symbol +// add - add a new u64 pointer symbol //------------------------------------------------- -void symbol_table::add(const char *name, read_write rw, uint64_t *ptr) +void symbol_table::add(const char *name, read_write rw, u64 *ptr) { m_symlist.erase(name); m_symlist.emplace(name, std::make_unique(*this, name, rw, ptr)); @@ -423,7 +423,7 @@ void symbol_table::add(const char *name, read_write rw, uint64_t *ptr) // add - add a new value symbol //------------------------------------------------- -void symbol_table::add(const char *name, uint64_t value) +void symbol_table::add(const char *name, u64 value) { m_symlist.erase(name); m_symlist.emplace(name, std::make_unique(*this, name, value)); @@ -474,7 +474,7 @@ symbol_entry *symbol_table::find_deep(const char *symbol) // value - return the value of a symbol //------------------------------------------------- -uint64_t symbol_table::value(const char *symbol) +u64 symbol_table::value(const char *symbol) { symbol_entry *entry = find_deep(symbol); return (entry != nullptr) ? entry->value() : 0; @@ -485,7 +485,7 @@ uint64_t symbol_table::value(const char *symbol) // set_value - set the value of a symbol //------------------------------------------------- -void symbol_table::set_value(const char *symbol, uint64_t value) +void symbol_table::set_value(const char *symbol, u64 value) { symbol_entry *entry = find_deep(symbol); if (entry != nullptr) @@ -516,7 +516,7 @@ expression_error::error_code symbol_table::memory_valid(const char *name, expres // memory_value - return a value read from memory //------------------------------------------------- -uint64_t symbol_table::memory_value(const char *name, expression_space space, uint32_t offset, int size) +u64 symbol_table::memory_value(const char *name, expression_space space, u32 offset, int size) { // walk up the table hierarchy to find the owner for (symbol_table *symtable = this; symtable != nullptr; symtable = symtable->m_parent) @@ -535,7 +535,7 @@ uint64_t symbol_table::memory_value(const char *name, expression_space space, ui // set_memory_value - write a value to memory //------------------------------------------------- -void symbol_table::set_memory_value(const char *name, expression_space space, uint32_t offset, int size, uint64_t value) +void symbol_table::set_memory_value(const char *name, expression_space space, u32 offset, int size, u64 value) { // walk up the table hierarchy to find the owner for (symbol_table *symtable = this; symtable != nullptr; symtable = symtable->m_parent) @@ -558,7 +558,7 @@ void symbol_table::set_memory_value(const char *name, expression_space space, ui // parsed_expression - constructor //------------------------------------------------- -parsed_expression::parsed_expression(symbol_table *symtable, const char *expression, uint64_t *result) +parsed_expression::parsed_expression(symbol_table *symtable, const char *expression, u64 *result) : m_symtable(symtable), m_token_stack_ptr(0) { @@ -627,7 +627,7 @@ void parsed_expression::print_tokens(FILE *out) break; case parse_token::NUMBER: - fprintf(out, "NUMBER: %08X%08X\n", (uint32_t)(token->value.i >> 32), (uint32_t)token->value.i); + fprintf(out, "NUMBER: %08X%08X\n", (u32)(token->value.i >> 32), u32(token->value.i)); break; case parse_token::STRING: @@ -635,7 +635,7 @@ void parsed_expression::print_tokens(FILE *out) break; case parse_token::SYMBOL: - fprintf(out, "SYMBOL: %08X%08X\n", (uint32_t)(token->value.i >> 32), (uint32_t)token->value.i); + fprintf(out, "SYMBOL: %08X%08X\n", u32(token->value.i >> 32), u32(token->value.i)); break; case parse_token::OPERATOR: @@ -708,7 +708,7 @@ void parsed_expression::parse_string_into_tokens() while (string[0] != 0) { // ignore any whitespace - while (string[0] != 0 && isspace((uint8_t)string[0])) + while (string[0] != 0 && isspace(u8(string[0]))) string++; if (string[0] == 0) break; @@ -717,7 +717,7 @@ void parsed_expression::parse_string_into_tokens() parse_token &token = m_tokenlist.append(*global_alloc(parse_token(string - stringstart))); // switch off the first character - switch (tolower((uint8_t)string[0])) + switch (tolower(u8(string[0]))) { case '(': string += 1, token.configure_operator(TVL_LPAREN, 0); @@ -865,7 +865,7 @@ void parsed_expression::parse_symbol_or_number(parse_token &token, const char *& while (1) { static const char valid[] = "abcdefghijklmnopqrstuvwxyz0123456789_$#.:"; - char val = tolower((uint8_t)string[0]); + char val = tolower(u8(string[0])); if (val == 0 || strchr(valid, val) == nullptr) break; buffer.append(&val, 1); @@ -965,12 +965,12 @@ void parsed_expression::parse_symbol_or_number(parse_token &token, const char *& void parsed_expression::parse_number(parse_token &token, const char *string, int base, expression_error::error_code errcode) { // parse the actual value - uint64_t value = 0; + u64 value = 0; while (*string != 0) { // look up the number's value, stopping if not valid static const char numbers[] = "0123456789abcdef"; - const char *ptr = strchr(numbers, tolower((uint8_t)*string)); + const char *ptr = strchr(numbers, tolower(u8(*string))); if (ptr == nullptr) break; @@ -980,7 +980,7 @@ void parsed_expression::parse_number(parse_token &token, const char *string, int break; // shift previous digits up and add in new digit - value = (value * (uint64_t)base) + digit; + value = (value * u64(base)) + digit; string++; } @@ -1001,7 +1001,7 @@ void parsed_expression::parse_quoted_char(parse_token &token, const char *&strin { // accumulate the value of the character token string++; - uint64_t value = 0; + u64 value = 0; while (string[0] != 0) { // allow '' to mean a nested single quote @@ -1011,7 +1011,7 @@ void parsed_expression::parse_quoted_char(parse_token &token, const char *&strin break; string++; } - value = (value << 8) | (uint8_t)*string++; + value = (value << 8) | u8(*string++); } // if we didn't find the ending quote, report an error @@ -1388,7 +1388,7 @@ inline void parsed_expression::pop_token_rval(parse_token &token) // of tokens //------------------------------------------------- -uint64_t parsed_expression::execute_tokens() +u64 parsed_expression::execute_tokens() { // reset the token stack m_token_stack_ptr = 0; @@ -1674,7 +1674,7 @@ parsed_expression::parse_token::parse_token(int offset) // for a SYMBOL token //------------------------------------------------- -uint64_t parsed_expression::parse_token::get_lval_value(symbol_table *table) +u64 parsed_expression::parse_token::get_lval_value(symbol_table *table) { // get the value of a symbol if (is_symbol()) @@ -1693,7 +1693,7 @@ uint64_t parsed_expression::parse_token::get_lval_value(symbol_table *table) // for a SYMBOL token //------------------------------------------------- -inline void parsed_expression::parse_token::set_lval_value(symbol_table *table, uint64_t value) +inline void parsed_expression::parse_token::set_lval_value(symbol_table *table, u64 value) { // set the value of a symbol if (is_symbol()) @@ -1713,7 +1713,7 @@ inline void parsed_expression::parse_token::set_lval_value(symbol_table *table, void parsed_expression::execute_function(parse_token &token) { // pop off all pushed parameters - uint64_t funcparams[MAX_FUNCTION_PARAMS]; + u64 funcparams[MAX_FUNCTION_PARAMS]; symbol_entry *symbol = nullptr; int paramcount = 0; while (paramcount < MAX_FUNCTION_PARAMS) diff --git a/src/emu/debug/express.h b/src/emu/debug/express.h index 7618bfada20..b9ddde14501 100644 --- a/src/emu/debug/express.h +++ b/src/emu/debug/express.h @@ -129,8 +129,8 @@ public: // symbol access virtual bool is_lval() const = 0; - virtual uint64_t value() const = 0; - virtual void set_value(uint64_t newvalue) = 0; + virtual u64 value() const = 0; + virtual void set_value(u64 newvalue) = 0; protected: // internal state @@ -150,16 +150,16 @@ class symbol_table { public: // callback functions for getting/setting a symbol value - typedef std::function getter_func; - typedef std::function setter_func; + typedef std::function getter_func; + typedef std::function setter_func; // callback functions for function execution - typedef std::function execute_func; + typedef std::function execute_func; // callback functions for memory reads/writes typedef std::function valid_func; - typedef std::function read_func; - typedef std::function write_func; + typedef std::function read_func; + typedef std::function write_func; enum read_write { @@ -179,21 +179,21 @@ public: void configure_memory(void *param, valid_func valid, read_func read, write_func write); // symbol access - void add(const char *name, read_write rw, uint64_t *ptr = nullptr); - void add(const char *name, uint64_t constvalue); + void add(const char *name, read_write rw, u64 *ptr = nullptr); + void add(const char *name, u64 constvalue); void add(const char *name, void *ref, getter_func getter, setter_func setter = nullptr); void add(const char *name, void *ref, int minparams, int maxparams, execute_func execute); symbol_entry *find(const char *name) const { if (name) { auto search = m_symlist.find(name); if (search != m_symlist.end()) return search->second.get(); else return nullptr; } else return nullptr; } symbol_entry *find_deep(const char *name); // value getter/setter - uint64_t value(const char *symbol); - void set_value(const char *symbol, uint64_t value); + u64 value(const char *symbol); + void set_value(const char *symbol, u64 value); // memory accessors expression_error::error_code memory_valid(const char *name, expression_space space); - uint64_t memory_value(const char *name, expression_space space, uint32_t offset, int size); - void set_memory_value(const char *name, expression_space space, uint32_t offset, int size, uint64_t value); + u64 memory_value(const char *name, expression_space space, u32 offset, int size); + void set_memory_value(const char *name, expression_space space, u32 offset, int size, u64 value); private: // internal state @@ -216,7 +216,7 @@ class parsed_expression public: // construction/destruction parsed_expression(const parsed_expression &src) { copy(src); } - parsed_expression(symbol_table *symtable = nullptr, const char *expression = nullptr, uint64_t *result = nullptr); + parsed_expression(symbol_table *symtable = nullptr, const char *expression = nullptr, u64 *result = nullptr); // operators parsed_expression &operator=(const parsed_expression &src) { copy(src); return *this; } @@ -231,7 +231,7 @@ public: // execution void parse(const char *string); - uint64_t execute() { return execute_tokens(); } + u64 execute() { return execute_tokens(); } private: // a single token @@ -279,15 +279,15 @@ private: bool is_memory() const { return (m_type == MEMORY); } bool is_symbol() const { return (m_type == SYMBOL); } bool is_operator() const { return (m_type == OPERATOR); } - bool is_operator(uint8_t type) const { return (m_type == OPERATOR && optype() == type); } + bool is_operator(u8 type) const { return (m_type == OPERATOR && optype() == type); } bool is_lval() const { return ((m_type == SYMBOL && m_symbol->is_lval()) || m_type == MEMORY); } - uint64_t value() const { assert(m_type == NUMBER); return m_value; } - uint32_t address() const { assert(m_type == MEMORY); return m_value; } + u64 value() const { assert(m_type == NUMBER); return m_value; } + u32 address() const { assert(m_type == MEMORY); return m_value; } symbol_entry *symbol() const { assert(m_type == SYMBOL); return m_symbol; } - uint8_t optype() const { assert(m_type == OPERATOR); return (m_flags & TIN_OPTYPE_MASK) >> TIN_OPTYPE_SHIFT; } - uint8_t precedence() const { assert(m_type == OPERATOR); return (m_flags & TIN_PRECEDENCE_MASK) >> TIN_PRECEDENCE_SHIFT; } + u8 optype() const { assert(m_type == OPERATOR); return (m_flags & TIN_OPTYPE_MASK) >> TIN_OPTYPE_SHIFT; } + u8 precedence() const { assert(m_type == OPERATOR); return (m_flags & TIN_PRECEDENCE_MASK) >> TIN_PRECEDENCE_SHIFT; } bool is_function_separator() const { assert(m_type == OPERATOR); return ((m_flags & TIN_FUNCTION_MASK) != 0); } bool right_to_left() const { assert(m_type == OPERATOR); return ((m_flags & TIN_RIGHT_TO_LEFT_MASK) != 0); } expression_space memory_space() const { assert(m_type == OPERATOR || m_type == MEMORY); return expression_space((m_flags & TIN_MEMORY_SPACE_MASK) >> TIN_MEMORY_SPACE_SHIFT); } @@ -297,11 +297,11 @@ private: parse_token &set_offset(int offset) { m_offset = offset; return *this; } parse_token &set_offset(const parse_token &src) { m_offset = src.m_offset; return *this; } parse_token &set_offset(const parse_token &src1, const parse_token &src2) { m_offset = std::min(src1.m_offset, src2.m_offset); return *this; } - parse_token &configure_number(uint64_t value) { m_type = NUMBER; m_value = value; return *this; } + parse_token &configure_number(u64 value) { m_type = NUMBER; m_value = value; return *this; } parse_token &configure_string(const char *string) { m_type = STRING; m_string = string; return *this; } - parse_token &configure_memory(uint32_t address, parse_token &memoryat) { m_type = MEMORY; m_value = address; m_flags = memoryat.m_flags; m_string = memoryat.m_string; return *this; } + parse_token &configure_memory(u32 address, parse_token &memoryat) { m_type = MEMORY; m_value = address; m_flags = memoryat.m_flags; m_string = memoryat.m_string; return *this; } parse_token &configure_symbol(symbol_entry &symbol) { m_type = SYMBOL; m_symbol = &symbol; return *this; } - parse_token &configure_operator(uint8_t optype, uint8_t precedence) + parse_token &configure_operator(u8 optype, u8 precedence) { m_type = OPERATOR; m_flags = ((optype << TIN_OPTYPE_SHIFT) & TIN_OPTYPE_MASK) | ((precedence << TIN_PRECEDENCE_SHIFT) & TIN_PRECEDENCE_MASK); return *this; } parse_token &set_function_separator() { assert(m_type == OPERATOR); m_flags |= TIN_FUNCTION_MASK; return *this; } @@ -311,16 +311,16 @@ private: parse_token &set_memory_source(const char *string) { assert(m_type == OPERATOR || m_type == MEMORY); m_string = string; return *this; } // access - uint64_t get_lval_value(symbol_table *symtable); - void set_lval_value(symbol_table *symtable, uint64_t value); + u64 get_lval_value(symbol_table *symtable); + void set_lval_value(symbol_table *symtable, u64 value); private: // internal state parse_token * m_next; // next token in list token_type m_type; // type of token int m_offset; // offset within the string - uint64_t m_value; // integral value - uint32_t m_flags; // additional flags/info + u64 m_value; // integral value + u32 m_flags; // additional flags/info const char * m_string; // associated string symbol_entry * m_symbol; // symbol pointer }; @@ -366,7 +366,7 @@ private: parse_token *peek_token(int count); void pop_token_lval(parse_token &token); void pop_token_rval(parse_token &token); - uint64_t execute_tokens(); + u64 execute_tokens(); void execute_function(parse_token &token); // constants diff --git a/src/emu/debug/textbuf.cpp b/src/emu/debug/textbuf.cpp index 3e5202476c4..279ce8dead6 100644 --- a/src/emu/debug/textbuf.cpp +++ b/src/emu/debug/textbuf.cpp @@ -27,16 +27,16 @@ struct text_buffer { - char * buffer; - int32_t * lineoffs; - int32_t bufsize; - int32_t bufstart; - int32_t bufend; - int32_t linesize; - int32_t linestart; - int32_t lineend; - uint32_t linestartseq; - int32_t maxwidth; + char * buffer; + s32 * lineoffs; + s32 bufsize; + s32 bufstart; + s32 bufend; + s32 linesize; + s32 linestart; + s32 lineend; + u32 linestartseq; + s32 maxwidth; }; @@ -50,9 +50,9 @@ struct text_buffer currently held in the buffer -------------------------------------------------*/ -static inline int32_t buffer_used(text_buffer *text) +static inline s32 buffer_used(text_buffer *text) { - int32_t used = text->bufend - text->bufstart; + s32 used = text->bufend - text->bufstart; if (used < 0) used += text->bufsize; return used; @@ -64,7 +64,7 @@ static inline int32_t buffer_used(text_buffer *text) available in the buffer -------------------------------------------------*/ -static inline int32_t buffer_space(text_buffer *text) +static inline s32 buffer_space(text_buffer *text) { return text->bufsize - buffer_used(text); } @@ -81,7 +81,7 @@ static inline int32_t buffer_space(text_buffer *text) text_buffer_alloc - allocate a new text buffer -------------------------------------------------*/ -text_buffer *text_buffer_alloc(uint32_t bytes, uint32_t lines) +text_buffer *text_buffer_alloc(u32 bytes, u32 lines) { text_buffer *text; @@ -99,7 +99,7 @@ text_buffer *text_buffer_alloc(uint32_t bytes, uint32_t lines) } /* allocate memory for the lines array */ - text->lineoffs = global_alloc_array_nothrow(int32_t, lines); + text->lineoffs = global_alloc_array_nothrow(s32, lines); if (!text->lineoffs) { global_free_array(text->buffer); @@ -179,11 +179,11 @@ void text_buffer_print(text_buffer *text, const char *data) void text_buffer_print_wrap(text_buffer *text, const char *data, int wrapcol) { - int32_t stopcol = (wrapcol < MAX_LINE_LENGTH) ? wrapcol : MAX_LINE_LENGTH; - int32_t needed_space; + s32 stopcol = (wrapcol < MAX_LINE_LENGTH) ? wrapcol : MAX_LINE_LENGTH; + s32 needed_space; /* we need to ensure there is enough space for this string plus enough for the max line length */ - needed_space = (int32_t)strlen(data) + MAX_LINE_LENGTH; + needed_space = s32(strlen(data)) + MAX_LINE_LENGTH; /* make space in the buffer if we need to */ while (buffer_space(text) < needed_space && text->linestart != text->lineend) @@ -278,7 +278,7 @@ void text_buffer_print_wrap(text_buffer *text, const char *data, int wrapcol) width of all lines seen so far -------------------------------------------------*/ -uint32_t text_buffer_max_width(text_buffer *text) +u32 text_buffer_max_width(text_buffer *text) { return text->maxwidth; } @@ -289,9 +289,9 @@ uint32_t text_buffer_max_width(text_buffer *text) lines in the text buffer -------------------------------------------------*/ -uint32_t text_buffer_num_lines(text_buffer *text) +u32 text_buffer_num_lines(text_buffer *text) { - int32_t lines = text->lineend + 1 - text->linestart; + s32 lines = text->lineend + 1 - text->linestart; if (lines <= 0) lines += text->linesize; return lines; @@ -303,7 +303,7 @@ uint32_t text_buffer_num_lines(text_buffer *text) line index into a sequence number -------------------------------------------------*/ -uint32_t text_buffer_line_index_to_seqnum(text_buffer *text, uint32_t index) +u32 text_buffer_line_index_to_seqnum(text_buffer *text, u32 index) { return text->linestartseq + index; } @@ -314,10 +314,10 @@ uint32_t text_buffer_line_index_to_seqnum(text_buffer *text, uint32_t index) an indexed line in the buffer -------------------------------------------------*/ -const char *text_buffer_get_seqnum_line(text_buffer *text, uint32_t seqnum) +const char *text_buffer_get_seqnum_line(text_buffer *text, u32 seqnum) { - uint32_t numlines = text_buffer_num_lines(text); - uint32_t index = seqnum - text->linestartseq; + u32 numlines = text_buffer_num_lines(text); + u32 index = seqnum - text->linestartseq; if (index >= numlines) return nullptr; return &text->buffer[text->lineoffs[(text->linestart + index) % text->linesize]]; diff --git a/src/emu/debug/textbuf.h b/src/emu/debug/textbuf.h index e9b65c503a7..9d42c3032ce 100644 --- a/src/emu/debug/textbuf.h +++ b/src/emu/debug/textbuf.h @@ -8,9 +8,10 @@ ***************************************************************************/ -#ifndef __TEXTBUF_H__ -#define __TEXTBUF_H__ +#ifndef MAME_EMU_DEBUG_TEXTBUF_H +#define MAME_EMU_DEBUG_TEXTBUF_H +#include "emucore.h" /*************************************************************************** TYPE DEFINITIONS @@ -25,7 +26,7 @@ struct text_buffer; ***************************************************************************/ /* allocate a new text buffer */ -text_buffer *text_buffer_alloc(uint32_t bytes, uint32_t lines); +text_buffer *text_buffer_alloc(u32 bytes, u32 lines); /* free a text buffer */ void text_buffer_free(text_buffer *text); @@ -40,16 +41,16 @@ void text_buffer_print(text_buffer *text, const char *data); void text_buffer_print_wrap(text_buffer *text, const char *data, int wrapcol); /* get the maximum width of lines seen so far */ -uint32_t text_buffer_max_width(text_buffer *text); +u32 text_buffer_max_width(text_buffer *text); /* get the current number of lines in the buffer */ -uint32_t text_buffer_num_lines(text_buffer *text); +u32 text_buffer_num_lines(text_buffer *text); /* get an absolute sequence number for a given line */ -uint32_t text_buffer_line_index_to_seqnum(text_buffer *text, uint32_t index); +u32 text_buffer_line_index_to_seqnum(text_buffer *text, u32 index); /* get a sequenced line from the text buffer */ -const char *text_buffer_get_seqnum_line(text_buffer *text, uint32_t seqnum); +const char *text_buffer_get_seqnum_line(text_buffer *text, u32 seqnum); -#endif /* __TEXTBUF_H__ */ +#endif /* MAME_EMU_DEBUG_TEXTBUF_H */ diff --git a/src/emu/devcb.cpp b/src/emu/devcb.cpp index 2b392ddcb93..3d851ee8e2a 100644 --- a/src/emu/devcb.cpp +++ b/src/emu/devcb.cpp @@ -20,7 +20,7 @@ // devcb_base - constructor //------------------------------------------------- -devcb_base::devcb_base(device_t &device, uint64_t defmask) +devcb_base::devcb_base(device_t &device, u64 defmask) : m_device(device), m_rshift(0), m_mask(defmask), @@ -44,7 +44,7 @@ void devcb_base::reset(callback_type type) m_space = nullptr; m_target.ptr = nullptr; m_rshift = 0; - m_mask = ~U64(0); + m_mask = ~u64(0); } @@ -107,7 +107,7 @@ void devcb_base::resolve_space() // devcb_read_base - constructor //------------------------------------------------- -devcb_read_base::devcb_read_base(device_t &device, uint64_t defmask) +devcb_read_base::devcb_read_base(device_t &device, u64 defmask) : devcb_base(device, defmask), m_adapter(nullptr) { @@ -221,7 +221,7 @@ void devcb_read_base::resolve() // the given value //------------------------------------------------- -void devcb_read_base::resolve_safe(uint64_t none_constant_value) +void devcb_read_base::resolve_safe(u64 none_constant_value) { // convert to a constant if none specified if (m_type == CALLBACK_NONE) @@ -238,7 +238,7 @@ void devcb_read_base::resolve_safe(uint64_t none_constant_value) // unresolved adapter //------------------------------------------------- -uint64_t devcb_read_base::read_unresolved_adapter(address_space &space, offs_t offset, uint64_t mask) +u64 devcb_read_base::read_unresolved_adapter(address_space &space, offs_t offset, u64 mask) { throw emu_fatalerror("Attempted to read through an unresolved devcb item"); } @@ -248,7 +248,7 @@ uint64_t devcb_read_base::read_unresolved_adapter(address_space &space, offs_t o // read_line_adapter - read from a line delegate //------------------------------------------------- -uint64_t devcb_read_base::read_line_adapter(address_space &space, offs_t offset, uint64_t mask) +u64 devcb_read_base::read_line_adapter(address_space &space, offs_t offset, u64 mask) { return shift_mask_xor(m_readline() & 1); } @@ -258,7 +258,7 @@ uint64_t devcb_read_base::read_line_adapter(address_space &space, offs_t offset, // read8_adapter - read from an 8-bit delegate //------------------------------------------------- -uint64_t devcb_read_base::read8_adapter(address_space &space, offs_t offset, uint64_t mask) +u64 devcb_read_base::read8_adapter(address_space &space, offs_t offset, u64 mask) { return shift_mask_xor(m_read8(space, offset, unshift_mask(mask))); } @@ -268,7 +268,7 @@ uint64_t devcb_read_base::read8_adapter(address_space &space, offs_t offset, uin // read16_adapter - read from a 16-bit delegate //------------------------------------------------- -uint64_t devcb_read_base::read16_adapter(address_space &space, offs_t offset, uint64_t mask) +u64 devcb_read_base::read16_adapter(address_space &space, offs_t offset, u64 mask) { return shift_mask_xor(m_read16(space, offset, unshift_mask(mask))); } @@ -278,7 +278,7 @@ uint64_t devcb_read_base::read16_adapter(address_space &space, offs_t offset, ui // read32_adapter - read from a 32-bit delegate //------------------------------------------------- -uint64_t devcb_read_base::read32_adapter(address_space &space, offs_t offset, uint64_t mask) +u64 devcb_read_base::read32_adapter(address_space &space, offs_t offset, u64 mask) { return shift_mask_xor(m_read32(space, offset, unshift_mask(mask))); } @@ -288,7 +288,7 @@ uint64_t devcb_read_base::read32_adapter(address_space &space, offs_t offset, ui // read64_adapter - read from a 64-bit delegate //------------------------------------------------- -uint64_t devcb_read_base::read64_adapter(address_space &space, offs_t offset, uint64_t mask) +u64 devcb_read_base::read64_adapter(address_space &space, offs_t offset, u64 mask) { return shift_mask_xor(m_read64(space, offset, unshift_mask(mask))); } @@ -298,7 +298,7 @@ uint64_t devcb_read_base::read64_adapter(address_space &space, offs_t offset, ui // read_ioport - read from an I/O port //------------------------------------------------- -uint64_t devcb_read_base::read_ioport_adapter(address_space &space, offs_t offset, uint64_t mask) +u64 devcb_read_base::read_ioport_adapter(address_space &space, offs_t offset, u64 mask) { return shift_mask_xor(m_target.ioport->read()); } @@ -309,7 +309,7 @@ uint64_t devcb_read_base::read_ioport_adapter(address_space &space, offs_t offse // constant //------------------------------------------------- -uint64_t devcb_read_base::read_logged_adapter(address_space &space, offs_t offset, uint64_t mask) +u64 devcb_read_base::read_logged_adapter(address_space &space, offs_t offset, u64 mask) { m_device.logerror("%s: read %s\n", m_device.machine().describe_context(), m_target_tag); return shift_mask_xor(m_target_int); @@ -320,7 +320,7 @@ uint64_t devcb_read_base::read_logged_adapter(address_space &space, offs_t offse // read_constant - read from a constant //------------------------------------------------- -uint64_t devcb_read_base::read_constant_adapter(address_space &space, offs_t offset, uint64_t mask) +u64 devcb_read_base::read_constant_adapter(address_space &space, offs_t offset, u64 mask) { return shift_mask_xor(m_target_int); } @@ -335,7 +335,7 @@ uint64_t devcb_read_base::read_constant_adapter(address_space &space, offs_t off // devcb_write_base - constructor //------------------------------------------------- -devcb_write_base::devcb_write_base(device_t &device, uint64_t defmask) +devcb_write_base::devcb_write_base(device_t &device, u64 defmask) : devcb_base(device, defmask), m_adapter(nullptr) { @@ -458,7 +458,7 @@ void devcb_write_base::resolve_safe() // unresolved adapter //------------------------------------------------- -void devcb_write_base::write_unresolved_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void devcb_write_base::write_unresolved_adapter(address_space &space, offs_t offset, u64 data, u64 mask) { throw emu_fatalerror("Attempted to write through an unresolved devcb item"); } @@ -468,7 +468,7 @@ void devcb_write_base::write_unresolved_adapter(address_space &space, offs_t off // write_line_adapter - write from a line delegate //------------------------------------------------- -void devcb_write_base::write_line_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void devcb_write_base::write_line_adapter(address_space &space, offs_t offset, u64 data, u64 mask) { m_writeline(unshift_mask_xor(data) & 1); } @@ -478,7 +478,7 @@ void devcb_write_base::write_line_adapter(address_space &space, offs_t offset, u // write8_adapter - write from an 8-bit delegate //------------------------------------------------- -void devcb_write_base::write8_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void devcb_write_base::write8_adapter(address_space &space, offs_t offset, u64 data, u64 mask) { m_write8(space, offset, unshift_mask_xor(data), unshift_mask(mask)); } @@ -488,7 +488,7 @@ void devcb_write_base::write8_adapter(address_space &space, offs_t offset, uint6 // write16_adapter - write from a 16-bit delegate //------------------------------------------------- -void devcb_write_base::write16_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void devcb_write_base::write16_adapter(address_space &space, offs_t offset, u64 data, u64 mask) { m_write16(space, offset, unshift_mask_xor(data), unshift_mask(mask)); } @@ -498,7 +498,7 @@ void devcb_write_base::write16_adapter(address_space &space, offs_t offset, uint // write32_adapter - write from a 32-bit delegate //------------------------------------------------- -void devcb_write_base::write32_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void devcb_write_base::write32_adapter(address_space &space, offs_t offset, u64 data, u64 mask) { m_write32(space, offset, unshift_mask_xor(data), unshift_mask(mask)); } @@ -508,7 +508,7 @@ void devcb_write_base::write32_adapter(address_space &space, offs_t offset, uint // write64_adapter - write from a 64-bit delegate //------------------------------------------------- -void devcb_write_base::write64_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void devcb_write_base::write64_adapter(address_space &space, offs_t offset, u64 data, u64 mask) { m_write64(space, offset, unshift_mask_xor(data), unshift_mask(mask)); } @@ -518,7 +518,7 @@ void devcb_write_base::write64_adapter(address_space &space, offs_t offset, uint // write_ioport - write from an I/O port //------------------------------------------------- -void devcb_write_base::write_ioport_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void devcb_write_base::write_ioport_adapter(address_space &space, offs_t offset, u64 data, u64 mask) { if (m_target.ioport) m_target.ioport->write(unshift_mask_xor(data)); @@ -530,7 +530,7 @@ void devcb_write_base::write_ioport_adapter(address_space &space, offs_t offset, // adapter //------------------------------------------------- -void devcb_write_base::write_logged_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void devcb_write_base::write_logged_adapter(address_space &space, offs_t offset, u64 data, u64 mask) { m_device.logerror("%s: unresolved devcb write\n", m_device.machine().describe_context()); } @@ -540,7 +540,7 @@ void devcb_write_base::write_logged_adapter(address_space &space, offs_t offset, // write_constant - write from a constant //------------------------------------------------- -void devcb_write_base::write_noop_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void devcb_write_base::write_noop_adapter(address_space &space, offs_t offset, u64 data, u64 mask) { // constant for writes is a no-op } @@ -551,7 +551,7 @@ void devcb_write_base::write_noop_adapter(address_space &space, offs_t offset, u // input line //------------------------------------------------- -void devcb_write_base::write_inputline_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void devcb_write_base::write_inputline_adapter(address_space &space, offs_t offset, u64 data, u64 mask) { m_target.device->execute().set_input_line(m_target_int, unshift_mask_xor(data) & 1); } diff --git a/src/emu/devcb.h b/src/emu/devcb.h index 0440413f417..c30f9db431b 100644 --- a/src/emu/devcb.h +++ b/src/emu/devcb.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DEVCB_H__ -#define __DEVCB_H__ +#ifndef MAME_EMU_DEVCB_H +#define MAME_EMU_DEVCB_H //************************************************************************** @@ -63,7 +63,7 @@ #define MCFG_DEVCB_RSHIFT(_shift) devcb->set_rshift(_shift); #define MCFG_DEVCB_MASK(_mask) devcb->set_mask(_mask); #define MCFG_DEVCB_XOR(_xor) devcb->set_xor(_xor); -#define MCFG_DEVCB_INVERT devcb->set_xor(~U64(0)); +#define MCFG_DEVCB_INVERT devcb->set_xor(~u64(0)); #define MCFG_DEVCB_ADDRESS_SPACE(_device, _spacenum) devcb->set_space(_device, _spacenum); @@ -98,7 +98,7 @@ protected: }; // construction/destruction - devcb_base(device_t &device, uint64_t defmask); + devcb_base(device_t &device, u64 defmask); public: // getters @@ -107,8 +107,8 @@ public: // additional configuration devcb_base &set_space(const char *device, address_spacenum space = AS_0) { m_space_tag = device; m_space_num = space; return *this; } devcb_base &set_rshift(int rshift) { m_rshift = rshift; return *this; } - devcb_base &set_mask(uint64_t mask) { m_mask = mask; return *this; } - devcb_base &set_xor(uint64_t xorval) { m_xor = xorval; return *this; } + devcb_base &set_mask(u64 mask) { m_mask = mask; return *this; } + devcb_base &set_xor(u64 xorval) { m_xor = xorval; return *this; } // construction helper classes class null_desc @@ -127,16 +127,16 @@ public: class constant_desc { public: - constant_desc(uint64_t value) { m_value = value; } - uint64_t m_value; + constant_desc(u64 value) { m_value = value; } + u64 m_value; }; class logger_desc { public: - logger_desc(const char *string, uint64_t value = 0) { m_string = string; m_value = value; } + logger_desc(const char *string, u64 value = 0) { m_string = string; m_value = value; } const char *m_string; - uint64_t m_value; + u64 m_value; }; class inputline_desc @@ -156,9 +156,9 @@ public: protected: // internal helpers - inline uint64_t shift_mask_xor(uint64_t value) const { return (((m_rshift < 0) ? (value << -m_rshift) : (value >> m_rshift)) ^ m_xor) & m_mask; } - inline uint64_t unshift_mask(uint64_t value) const { return (m_rshift < 0) ? ((value & m_mask) >> -m_rshift) : ((value & m_mask) << m_rshift); } - inline uint64_t unshift_mask_xor(uint64_t value) const { return (m_rshift < 0) ? (((value ^ m_xor) & m_mask) >> -m_rshift) : (((value ^ m_xor) & m_mask) << m_rshift); } + inline u64 shift_mask_xor(u64 value) const { return (((m_rshift < 0) ? (value << -m_rshift) : (value >> m_rshift)) ^ m_xor) & m_mask; } + inline u64 unshift_mask(u64 value) const { return (m_rshift < 0) ? ((value & m_mask) >> -m_rshift) : ((value & m_mask) << m_rshift); } + inline u64 unshift_mask_xor(u64 value) const { return (m_rshift < 0) ? (((value ^ m_xor) & m_mask) >> -m_rshift) : (((value ^ m_xor) & m_mask) << m_rshift); } void reset(callback_type type = CALLBACK_NONE); void resolve_ioport(); void resolve_inputline(); @@ -176,7 +176,7 @@ protected: device_t & m_device; // reference to our owning device callback_type m_type; // type of callback registered const char * m_target_tag; // tag of target object - uint64_t m_target_int; // integer value of target object + u64 m_target_int; // integer value of target object const char * m_space_tag; // tag of address space device address_spacenum m_space_num; // address space number of space device @@ -184,8 +184,8 @@ protected: address_space * m_space; // target address space callback_target m_target; // resolved pointer to target object int m_rshift; // right shift to apply to data read - uint64_t m_mask; // mask to apply to data read - uint64_t m_xor; // XOR to apply to data read + u64 m_mask; // mask to apply to data read + u64 m_xor; // XOR to apply to data read }; @@ -195,7 +195,7 @@ class devcb_read_base : public devcb_base { protected: // construction/destruction - devcb_read_base(device_t &device, uint64_t defmask); + devcb_read_base(device_t &device, u64 defmask); public: // callback configuration @@ -208,22 +208,22 @@ public: // resolution void resolve(); - void resolve_safe(uint64_t none_constant_value); + void resolve_safe(u64 none_constant_value); protected: // internal helpers void reset(callback_type type = CALLBACK_NONE); // adapters - uint64_t read_unresolved_adapter(address_space &space, offs_t offset, uint64_t mask); - uint64_t read_line_adapter(address_space &space, offs_t offset, uint64_t mask); - uint64_t read8_adapter(address_space &space, offs_t offset, uint64_t mask); - uint64_t read16_adapter(address_space &space, offs_t offset, uint64_t mask); - uint64_t read32_adapter(address_space &space, offs_t offset, uint64_t mask); - uint64_t read64_adapter(address_space &space, offs_t offset, uint64_t mask); - uint64_t read_ioport_adapter(address_space &space, offs_t offset, uint64_t mask); - uint64_t read_logged_adapter(address_space &space, offs_t offset, uint64_t mask); - uint64_t read_constant_adapter(address_space &space, offs_t offset, uint64_t mask); + u64 read_unresolved_adapter(address_space &space, offs_t offset, u64 mask); + u64 read_line_adapter(address_space &space, offs_t offset, u64 mask); + u64 read8_adapter(address_space &space, offs_t offset, u64 mask); + u64 read16_adapter(address_space &space, offs_t offset, u64 mask); + u64 read32_adapter(address_space &space, offs_t offset, u64 mask); + u64 read64_adapter(address_space &space, offs_t offset, u64 mask); + u64 read_ioport_adapter(address_space &space, offs_t offset, u64 mask); + u64 read_logged_adapter(address_space &space, offs_t offset, u64 mask); + u64 read_constant_adapter(address_space &space, offs_t offset, u64 mask); // configuration read_line_delegate m_readline; // copy of registered line reader @@ -233,7 +233,7 @@ protected: read64_delegate m_read64; // copy of registered 64-bit reader // derived state - typedef uint64_t (devcb_read_base::*adapter_func)(address_space &, offs_t, uint64_t); + typedef u64 (devcb_read_base::*adapter_func)(address_space &, offs_t, u64); adapter_func m_adapter; // actual callback to invoke }; @@ -244,7 +244,7 @@ class devcb_write_base : public devcb_base { protected: // construction/destruction - devcb_write_base(device_t &device, uint64_t defmask); + devcb_write_base(device_t &device, u64 defmask); public: // callback configuration @@ -264,16 +264,16 @@ protected: void reset(callback_type type = CALLBACK_NONE); // adapters - void write_unresolved_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask); - void write_line_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask); - void write8_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask); - void write16_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask); - void write32_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask); - void write64_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask); - void write_ioport_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask); - void write_logged_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask); - void write_noop_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask); - void write_inputline_adapter(address_space &space, offs_t offset, uint64_t data, uint64_t mask); + void write_unresolved_adapter(address_space &space, offs_t offset, u64 data, u64 mask); + void write_line_adapter(address_space &space, offs_t offset, u64 data, u64 mask); + void write8_adapter(address_space &space, offs_t offset, u64 data, u64 mask); + void write16_adapter(address_space &space, offs_t offset, u64 data, u64 mask); + void write32_adapter(address_space &space, offs_t offset, u64 data, u64 mask); + void write64_adapter(address_space &space, offs_t offset, u64 data, u64 mask); + void write_ioport_adapter(address_space &space, offs_t offset, u64 data, u64 mask); + void write_logged_adapter(address_space &space, offs_t offset, u64 data, u64 mask); + void write_noop_adapter(address_space &space, offs_t offset, u64 data, u64 mask); + void write_inputline_adapter(address_space &space, offs_t offset, u64 data, u64 mask); // configuration write_line_delegate m_writeline; // copy of registered line writer @@ -283,7 +283,7 @@ protected: write64_delegate m_write64; // copy of registered 64-bit writer // derived state - typedef void (devcb_write_base::*adapter_func)(address_space &, offs_t, uint64_t, uint64_t); + typedef void (devcb_write_base::*adapter_func)(address_space &, offs_t, u64, u64); adapter_func m_adapter; // actual callback to invoke }; @@ -294,8 +294,8 @@ class devcb_read_line : public devcb_read_base { public: devcb_read_line(device_t &device) : devcb_read_base(device, 0xff) { } - int operator()() { return (this->*m_adapter)(*m_space, 0, U64(0xff)) & 1; } - int operator()(address_space &space) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, 0, U64(0xff)) & 1; } + int operator()() { return (this->*m_adapter)(*m_space, 0, 0xffU) & 1; } + int operator()(address_space &space) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, 0, 0xffU) & 1; } }; @@ -305,8 +305,8 @@ class devcb_read8 : public devcb_read_base { public: devcb_read8(device_t &device) : devcb_read_base(device, 0xff) { } - uint8_t operator()(offs_t offset = 0, uint8_t mask = 0xff) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } - uint8_t operator()(address_space &space, offs_t offset = 0, uint8_t mask = 0xff) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } + u8 operator()(offs_t offset = 0, u8 mask = 0xff) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } + u8 operator()(address_space &space, offs_t offset = 0, u8 mask = 0xff) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } }; @@ -316,8 +316,8 @@ class devcb_read16 : public devcb_read_base { public: devcb_read16(device_t &device) : devcb_read_base(device, 0xffff) { } - uint16_t operator()(offs_t offset = 0, uint16_t mask = 0xffff) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } - uint16_t operator()(address_space &space, offs_t offset = 0, uint16_t mask = 0xffff) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } + u16 operator()(offs_t offset = 0, u16 mask = 0xffff) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } + u16 operator()(address_space &space, offs_t offset = 0, u16 mask = 0xffff) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } }; @@ -327,8 +327,8 @@ class devcb_read32 : public devcb_read_base { public: devcb_read32(device_t &device) : devcb_read_base(device, 0xffffffff) { } - uint32_t operator()(offs_t offset = 0, uint32_t mask = 0xffffffff) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } - uint32_t operator()(address_space &space, offs_t offset = 0, uint32_t mask = 0xffffffff) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } + u32 operator()(offs_t offset = 0, u32 mask = 0xffffffff) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } + u32 operator()(address_space &space, offs_t offset = 0, u32 mask = 0xffffffff) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } }; @@ -337,9 +337,9 @@ public: class devcb_read64 : public devcb_read_base { public: - devcb_read64(device_t &device) : devcb_read_base(device, U64(0xffffffffffffffff)) { } - uint64_t operator()(offs_t offset = 0, uint64_t mask = U64(0xffffffffffffffff)) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } - uint64_t operator()(address_space &space, offs_t offset = 0, uint64_t mask = U64(0xffffffffffffffff)) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } + devcb_read64(device_t &device) : devcb_read_base(device, 0xffffffffffffffffU) { } + u64 operator()(offs_t offset = 0, u64 mask = 0xffffffffffffffffU) { return (this->*m_adapter)(*m_space, offset, mask) & mask; } + u64 operator()(address_space &space, offs_t offset = 0, u64 mask = 0xffffffffffffffffU) { return (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, mask) & mask; } }; @@ -349,8 +349,8 @@ class devcb_write_line : public devcb_write_base { public: devcb_write_line(device_t &device) : devcb_write_base(device, 0xff) { } - void operator()(int state) { (this->*m_adapter)(*m_space, 0, state & 1, U64(0xff)); } - void operator()(address_space &space, int state) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, 0, state & 1, U64(0xff)); } + void operator()(int state) { (this->*m_adapter)(*m_space, 0, state & 1, 0xffU); } + void operator()(address_space &space, int state) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, 0, state & 1, 0xffU); } }; @@ -360,9 +360,9 @@ class devcb_write8 : public devcb_write_base { public: devcb_write8(device_t &device) : devcb_write_base(device, 0xff) { } - void operator()(uint8_t data, uint8_t mask = 0xff) { (this->*m_adapter)(*m_space, 0, data, mask); } - void operator()(offs_t offset, uint8_t data, uint8_t mask = 0xff) { (this->*m_adapter)(*m_space, offset, data, mask); } - void operator()(address_space &space, offs_t offset, uint8_t data, uint8_t mask = 0xff) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } + void operator()(u8 data, u8 mask = 0xff) { (this->*m_adapter)(*m_space, 0, data, mask); } + void operator()(offs_t offset, u8 data, u8 mask = 0xff) { (this->*m_adapter)(*m_space, offset, data, mask); } + void operator()(address_space &space, offs_t offset, u8 data, u8 mask = 0xff) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } }; @@ -372,9 +372,9 @@ class devcb_write16 : public devcb_write_base { public: devcb_write16(device_t &device) : devcb_write_base(device, 0xffff) { } - void operator()(uint16_t data, uint16_t mask = 0xffff) { (this->*m_adapter)(*m_space, 0, data, mask); } - void operator()(offs_t offset, uint16_t data, uint16_t mask = 0xffff) { (this->*m_adapter)(*m_space, offset, data, mask); } - void operator()(address_space &space, offs_t offset, uint16_t data, uint16_t mask = 0xffff) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } + void operator()(u16 data, u16 mask = 0xffff) { (this->*m_adapter)(*m_space, 0, data, mask); } + void operator()(offs_t offset, u16 data, u16 mask = 0xffff) { (this->*m_adapter)(*m_space, offset, data, mask); } + void operator()(address_space &space, offs_t offset, u16 data, u16 mask = 0xffff) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } }; @@ -384,9 +384,9 @@ class devcb_write32 : public devcb_write_base { public: devcb_write32(device_t &device) : devcb_write_base(device, 0xffffffff) { } - void operator()(uint32_t data, uint32_t mask = 0xffffffff) { (this->*m_adapter)(*m_space, 0, data, mask); } - void operator()(offs_t offset, uint32_t data, uint32_t mask = 0xffffffff) { (this->*m_adapter)(*m_space, offset, data, mask); } - void operator()(address_space &space, offs_t offset, uint32_t data, uint32_t mask = 0xffffffff) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } + void operator()(u32 data, u32 mask = 0xffffffff) { (this->*m_adapter)(*m_space, 0, data, mask); } + void operator()(offs_t offset, u32 data, u32 mask = 0xffffffff) { (this->*m_adapter)(*m_space, offset, data, mask); } + void operator()(address_space &space, offs_t offset, u32 data, u32 mask = 0xffffffff) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } }; @@ -395,11 +395,11 @@ public: class devcb_write64 : public devcb_write_base { public: - devcb_write64(device_t &device) : devcb_write_base(device, U64(0xffffffffffffffff)) { } - void operator()(uint64_t data, uint64_t mask = U64(0xffffffffffffffff)) { (this->*m_adapter)(*m_space, 0, data, mask); } - void operator()(offs_t offset, uint64_t data, uint64_t mask = U64(0xffffffffffffffff)) { (this->*m_adapter)(*m_space, offset, data, mask); } - void operator()(address_space &space, offs_t offset, uint64_t data, uint64_t mask = U64(0xffffffffffffffff)) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } + devcb_write64(device_t &device) : devcb_write_base(device, 0xffffffffffffffffU) { } + void operator()(u64 data, u64 mask = 0xffffffffffffffffU) { (this->*m_adapter)(*m_space, 0, data, mask); } + void operator()(offs_t offset, u64 data, u64 mask = 0xffffffffffffffffU) { (this->*m_adapter)(*m_space, offset, data, mask); } + void operator()(address_space &space, offs_t offset, u64 data, u64 mask = 0xffffffffffffffffU) { (this->*m_adapter)((m_space_tag != nullptr) ? *m_space : space, offset, data, mask); } }; -#endif /* __DEVCB_H__ */ +#endif /* MAME_EMU_DEVCB_H */ diff --git a/src/emu/devcpu.cpp b/src/emu/devcpu.cpp index 42e48ce588d..f07c8b4a885 100644 --- a/src/emu/devcpu.cpp +++ b/src/emu/devcpu.cpp @@ -21,7 +21,7 @@ // cpu_device - constructor //------------------------------------------------- -cpu_device::cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source) +cpu_device::cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source) : device_t(mconfig, type, name, tag, owner, clock, shortname, source), device_execute_interface(mconfig, *this), device_memory_interface(mconfig, *this), diff --git a/src/emu/devcpu.h b/src/emu/devcpu.h index bfd299ed5ff..3289678012b 100644 --- a/src/emu/devcpu.h +++ b/src/emu/devcpu.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DEVCPU_H__ -#define __DEVCPU_H__ +#ifndef MAME_EMU_DEVCPU_H +#define MAME_EMU_DEVCPU_H //************************************************************************** // CPU DEVICE CONFIGURATION MACROS @@ -54,8 +54,8 @@ //************************************************************************** #define CPU_DISASSEMBLE_NAME(name) cpu_disassemble_##name -#define CPU_DISASSEMBLE(name) offs_t CPU_DISASSEMBLE_NAME(name)(cpu_device *device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) -#define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(device, buffer, pc, oprom, opram, options) +#define CPU_DISASSEMBLE(name) offs_t CPU_DISASSEMBLE_NAME(name)(cpu_device *device, std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, int options) +#define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(device, stream, pc, oprom, opram, options) //************************************************************************** @@ -79,7 +79,7 @@ public: protected: // construction/destruction - cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source); + cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source); virtual ~cpu_device(); private: @@ -88,7 +88,7 @@ private: }; -typedef offs_t (*cpu_disassemble_func)(cpu_device *device, char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options); +typedef offs_t (*cpu_disassemble_func)(cpu_device *device, std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, int options); -#endif /* __CPUINTRF_H__ */ +#endif /* MAME_EMU_DEVCPU_H */ diff --git a/src/emu/devdelegate.h b/src/emu/devdelegate.h index f76116004aa..47af86d84c3 100644 --- a/src/emu/devdelegate.h +++ b/src/emu/devdelegate.h @@ -8,10 +8,10 @@ ***************************************************************************/ -#pragma once +#ifndef MAME_EMU_DEVDELEGATE_H +#define MAME_EMU_DEVDELEGATE_H -#ifndef __DEVDELEGATE_H__ -#define __DEVDELEGATE_H__ +#pragma once #include "delegate.h" @@ -104,4 +104,4 @@ public: }; -#endif /* __DEVDELEGATE_H__ */ +#endif /* MAME_EMU_DEVDELEGATE_H */ diff --git a/src/emu/devfind.cpp b/src/emu/devfind.cpp index 90daaa0a499..7eb309bbfd2 100644 --- a/src/emu/devfind.cpp +++ b/src/emu/devfind.cpp @@ -22,23 +22,23 @@ template class object_finder_base; template class object_finder_base; template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; -template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; +template class object_finder_base; template class memory_region_finder; template class memory_region_finder; @@ -49,41 +49,41 @@ template class memory_bank_finder; template class ioport_finder; template class ioport_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; -template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; +template class region_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; -template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; +template class shared_ptr_finder; @@ -119,7 +119,7 @@ finder_base::~finder_base() // find_memregion - find memory region //------------------------------------------------- -void *finder_base::find_memregion(uint8_t width, size_t &length, bool required) const +void *finder_base::find_memregion(u8 width, size_t &length, bool required) const { // look up the region and return nullptr if not found memory_region *const region = m_base.memregion(m_tag); @@ -194,7 +194,7 @@ bool finder_base::validate_memregion(size_t bytes, bool required) const // find_memshare - find memory share //------------------------------------------------- -void *finder_base::find_memshare(uint8_t width, size_t &bytes, bool required) const +void *finder_base::find_memshare(u8 width, size_t &bytes, bool required) const { // look up the share and return nullptr if not found memory_share *share = m_base.memshare(m_tag); diff --git a/src/emu/devfind.h b/src/emu/devfind.h index b68bea2d46a..094bb5a194c 100644 --- a/src/emu/devfind.h +++ b/src/emu/devfind.h @@ -205,7 +205,7 @@ protected: /// found. /// \return Base pointer of the memeroy region if a matching region /// is found, or nullptr otherwise. - void *find_memregion(uint8_t width, size_t &length, bool required) const; + void *find_memregion(u8 width, size_t &length, bool required) const; /// \brief Check that memory region exists /// @@ -240,7 +240,7 @@ protected: /// found. /// \return Pointer to base of memory share if a matching memory /// share is found, or nullptr otherwise. - void *find_memshare(uint8_t width, size_t &bytes, bool required) const; + void *find_memshare(u8 width, size_t &bytes, bool required) const; /// \brief Log if object was not found /// @@ -646,12 +646,12 @@ public: /// \brief Get length in units of elements /// \return Length in units of elements or zero if no matching /// memory region has been found. - uint32_t length() const { return m_length; } + u32 length() const { return m_length; } /// \brief Get length in units of bytes /// \return Length in units of bytes or zero if no matching memory /// region has been found. - uint32_t bytes() const { return m_length * sizeof(PointerType); } + u32 bytes() const { return m_length * sizeof(PointerType); } /// \brief Get index mask /// @@ -659,7 +659,7 @@ public: /// used as a mask for index values if the length is a power of two. /// Result is undefined if no matching memory region has been found. /// \return Length in units of elements minus one. - uint32_t mask() const { return m_length - 1; } + u32 mask() const { return m_length - 1; } private: /// \brief Find memory region base pointer @@ -726,7 +726,7 @@ class shared_ptr_finder : public object_finder_base { public: // construction/destruction - shared_ptr_finder(device_t &base, char const *tag, uint8_t width = sizeof(PointerType) * 8) + shared_ptr_finder(device_t &base, char const *tag, u8 width = sizeof(PointerType) * 8) : object_finder_base(base, tag) , m_width(width) , m_bytes(0) @@ -738,14 +738,14 @@ public: PointerType &operator[](int index) const { return this->m_target[index]; } // getter for explicit fetching - uint32_t bytes() const { return m_bytes; } - uint32_t mask() const { return m_bytes - 1; } // FIXME: wrong when sizeof(PointerType) != 1 + u32 bytes() const { return m_bytes; } + u32 mask() const { return m_bytes - 1; } // FIXME: wrong when sizeof(PointerType) != 1 // setter for setting the object void set_target(PointerType *target, size_t bytes) { this->m_target = target; m_bytes = bytes; } // dynamic allocation of a shared pointer - void allocate(uint32_t entries) + void allocate(u32 entries) { assert(m_allocated.empty()); m_allocated.resize(entries); @@ -764,7 +764,7 @@ private: } // internal state - uint8_t const m_width; + u8 const m_width; size_t m_bytes; std::vector m_allocated; }; @@ -788,23 +788,23 @@ extern template class object_finder_base; extern template class object_finder_base; extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; -extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; +extern template class object_finder_base; extern template class memory_region_finder; extern template class memory_region_finder; @@ -815,41 +815,41 @@ extern template class memory_bank_finder; extern template class ioport_finder; extern template class ioport_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; -extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; +extern template class region_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; -extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; +extern template class shared_ptr_finder; #endif // MAME_EMU_DEVFIND_H /** \} */ diff --git a/src/emu/device.cpp b/src/emu/device.cpp index 2e612694bd5..321c7b18390 100644 --- a/src/emu/device.cpp +++ b/src/emu/device.cpp @@ -23,7 +23,7 @@ // from the provided config //------------------------------------------------- -device_t::device_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source) +device_t::device_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source) : m_type(type), m_name(name), m_shortname(shortname), @@ -157,7 +157,7 @@ std::string device_t::parameter(const char *tag) const // a device //------------------------------------------------- -void device_t::static_set_clock(device_t &device, uint32_t clock) +void device_t::static_set_clock(device_t &device, u32 clock) { // derive the clock from our owner if requested if ((clock & 0xff000000) == 0xff000000) @@ -237,7 +237,7 @@ void device_t::reset() // unscaled clock //------------------------------------------------- -void device_t::set_unscaled_clock(uint32_t clock) +void device_t::set_unscaled_clock(u32 clock) { m_unscaled_clock = clock; m_clock = m_unscaled_clock * m_clock_scale; @@ -265,15 +265,15 @@ void device_t::set_clock_scale(double clockscale) // clock ticks to an attotime //------------------------------------------------- -attotime device_t::clocks_to_attotime(uint64_t numclocks) const +attotime device_t::clocks_to_attotime(u64 numclocks) const { if (numclocks < m_clock) return attotime(0, numclocks * m_attoseconds_per_clock); else { - uint32_t remainder; - uint32_t quotient = divu_64x32_rem(numclocks, m_clock, &remainder); - return attotime(quotient, (uint64_t)remainder * (uint64_t)m_attoseconds_per_clock); + u32 remainder; + u32 quotient = divu_64x32_rem(numclocks, m_clock, &remainder); + return attotime(quotient, u64(remainder) * u64(m_attoseconds_per_clock)); } } @@ -283,9 +283,9 @@ attotime device_t::clocks_to_attotime(uint64_t numclocks) const // attotime to CPU clock ticks //------------------------------------------------- -uint64_t device_t::attotime_to_clocks(const attotime &duration) const +u64 device_t::attotime_to_clocks(const attotime &duration) const { - return mulu_32x32(duration.seconds(), m_clock) + (uint64_t)duration.attoseconds() / (uint64_t)m_attoseconds_per_clock; + return mulu_32x32(duration.seconds(), m_clock) + u64(duration.attoseconds()) / u64(m_attoseconds_per_clock); } diff --git a/src/emu/device.h b/src/emu/device.h index efc389f1823..37cf6631e4a 100644 --- a/src/emu/device.h +++ b/src/emu/device.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DEVICE_H__ -#define __DEVICE_H__ +#ifndef MAME_EMU_DEVICE_H +#define MAME_EMU_DEVICE_H @@ -81,19 +81,19 @@ class device_missing_dependencies : public emu_exception { }; // a device_type is simply a pointer to its alloc function -typedef device_t *(*device_type)(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +typedef device_t *(*device_type)(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); // this template function creates a stub which constructs a device template -device_t *device_creator(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +device_t *device_creator(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) { return global_alloc_clear<_DeviceClass>(mconfig, tag, owner, clock); } // timer IDs for devices -typedef uint32_t device_timer_id; +typedef u32 device_timer_id; // ======================> device_t @@ -194,7 +194,7 @@ class device_t : public delegate_late_bind protected: // construction/destruction - device_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source); + device_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source); public: virtual ~device_t(); @@ -209,15 +209,15 @@ public: const char *source() const { return m_source.c_str(); } device_t *owner() const { return m_owner; } device_t *next() const { return m_next; } - uint32_t configured_clock() const { return m_configured_clock; } + u32 configured_clock() const { return m_configured_clock; } const machine_config &mconfig() const { return m_machine_config; } const input_device_default *input_ports_defaults() const { return m_input_defaults; } const std::vector &rom_region_vector() const; const rom_entry *rom_region() const { return rom_region_vector().data(); } machine_config_constructor machine_config_additions() const { return device_mconfig_additions(); } ioport_constructor input_ports() const { return device_input_ports(); } - uint8_t default_bios() const { return m_default_bios; } - uint8_t system_bios() const { return m_system_bios; } + u8 default_bios() const { return m_default_bios; } + u8 system_bios() const { return m_system_bios; } std::string default_bios_tag() const { return m_default_bios_tag; } // interface helpers @@ -255,7 +255,7 @@ public: std::string parameter(const char *tag) const; // configuration helpers - static void static_set_clock(device_t &device, uint32_t clock); + static void static_set_clock(device_t &device, u32 clock); static void static_set_input_default(device_t &device, const input_device_default *config) { device.m_input_defaults = config; } static void static_set_default_bios_tag(device_t &device, const char *tag) { std::string default_bios_tag(tag); device.m_default_bios_tag = default_bios_tag; } @@ -267,13 +267,13 @@ public: void reset(); // clock/timing accessors - uint32_t clock() const { return m_clock; } - uint32_t unscaled_clock() const { return m_unscaled_clock; } - void set_unscaled_clock(uint32_t clock); + u32 clock() const { return m_clock; } + u32 unscaled_clock() const { return m_unscaled_clock; } + void set_unscaled_clock(u32 clock); double clock_scale() const { return m_clock_scale; } void set_clock_scale(double clockscale); - attotime clocks_to_attotime(uint64_t clocks) const; - uint64_t attotime_to_clocks(const attotime &duration) const; + attotime clocks_to_attotime(u64 clocks) const; + u64 attotime_to_clocks(const attotime &duration) const; // timer interfaces emu_timer *timer_alloc(device_timer_id id = 0, void *ptr = nullptr); @@ -285,15 +285,15 @@ public: template void ATTR_COLD save_item(_ItemType &value, const char *valname, int index = 0) { assert(m_save != nullptr); m_save->save_item(this, name(), tag(), index, value, valname); } template - void ATTR_COLD save_pointer(_ItemType *value, const char *valname, uint32_t count, int index = 0) { assert(m_save != nullptr); m_save->save_pointer(this, name(), tag(), index, value, valname, count); } + void ATTR_COLD save_pointer(_ItemType *value, const char *valname, u32 count, int index = 0) { assert(m_save != nullptr); m_save->save_pointer(this, name(), tag(), index, value, valname, count); } // debugging device_debug *debug() const { return m_debug.get(); } offs_t safe_pc() const; offs_t safe_pcbase() const; - void set_default_bios(uint8_t bios) { m_default_bios = bios; } - void set_system_bios(uint8_t bios) { m_system_bios = bios; } + void set_default_bios(u8 bios) { m_default_bios = bios; } + void set_system_bios(u8 bios) { m_system_bios = bios; } bool findit(bool isvalidation = false) const; // misc @@ -345,9 +345,9 @@ protected: interface_list m_interfaces; // container for list of interfaces // device clocks - uint32_t m_configured_clock; // originally configured device clock - uint32_t m_unscaled_clock; // current unscaled device clock - uint32_t m_clock; // current device clock, after scaling + u32 m_configured_clock; // originally configured device clock + u32 m_unscaled_clock; // current unscaled device clock + u32 m_clock; // current device clock, after scaling double m_clock_scale; // clock scale factor attoseconds_t m_attoseconds_per_clock;// period in attoseconds @@ -355,8 +355,8 @@ protected: const machine_config & m_machine_config; // reference to the machine's configuration const input_device_default *m_input_defaults; // devices input ports default overrides - uint8_t m_system_bios; // the system BIOS we wish to load - uint8_t m_default_bios; // the default system BIOS + u8 m_system_bios; // the system BIOS we wish to load + u8 m_default_bios; // the default system BIOS std::string m_default_bios_tag; // tag of the default system BIOS private: @@ -792,4 +792,4 @@ inline device_t::interface_list::auto_iterator device_t::interface_list::auto_it } -#endif /* __DEVICE_H__ */ +#endif /* MAME_EMU_DEVICE_H */ diff --git a/src/emu/didisasm.cpp b/src/emu/didisasm.cpp index 33a4a0d002a..95353889a65 100644 --- a/src/emu/didisasm.cpp +++ b/src/emu/didisasm.cpp @@ -64,20 +64,15 @@ void device_disasm_interface::static_set_dasm_override(device_t &device, dasm_ov // disassemble - interface for disassembly //------------------------------------------------- -offs_t device_disasm_interface::disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t device_disasm_interface::disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) { offs_t result = 0; // check for disassembler override if (!m_dasm_override.isnull()) - { - std::ostringstream stream; result = m_dasm_override(device(), stream, pc, oprom, opram, options); - std::string stream_str = stream.str(); - strcpy(buffer, stream_str.c_str()); - } if (result == 0) - result = disasm_disassemble(buffer, pc, oprom, opram, options); + result = disasm_disassemble(stream, pc, oprom, opram, options); // make sure we get good results assert((result & DASMFLAG_LENGTHMASK) != 0); diff --git a/src/emu/didisasm.h b/src/emu/didisasm.h index d4064f6434d..c96fe3b9159 100644 --- a/src/emu/didisasm.h +++ b/src/emu/didisasm.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DIDISASM_H__ -#define __DIDISASM_H__ +#ifndef MAME_EMU_DIDISASM_H +#define MAME_EMU_DIDISASM_H //************************************************************************** @@ -23,12 +23,12 @@ //************************************************************************** // Disassembler constants -const uint32_t DASMFLAG_SUPPORTED = 0x80000000; // are disassembly flags supported? -const uint32_t DASMFLAG_STEP_OUT = 0x40000000; // this instruction should be the end of a step out sequence -const uint32_t DASMFLAG_STEP_OVER = 0x20000000; // this instruction should be stepped over by setting a breakpoint afterwards -const uint32_t DASMFLAG_OVERINSTMASK = 0x18000000; // number of extra instructions to skip when stepping over -const uint32_t DASMFLAG_OVERINSTSHIFT = 27; // bits to shift after masking to get the value -const uint32_t DASMFLAG_LENGTHMASK = 0x0000ffff; // the low 16-bits contain the actual length +const u32 DASMFLAG_SUPPORTED = 0x80000000; // are disassembly flags supported? +const u32 DASMFLAG_STEP_OUT = 0x40000000; // this instruction should be the end of a step out sequence +const u32 DASMFLAG_STEP_OVER = 0x20000000; // this instruction should be stepped over by setting a breakpoint afterwards +const u32 DASMFLAG_OVERINSTMASK = 0x18000000; // number of extra instructions to skip when stepping over +const u32 DASMFLAG_OVERINSTSHIFT = 27; // bits to shift after masking to get the value +const u32 DASMFLAG_LENGTHMASK = 0x0000ffff; // the low 16-bits contain the actual length @@ -53,7 +53,7 @@ const uint32_t DASMFLAG_LENGTHMASK = 0x0000ffff; // the low 16-bits contain // TYPE DEFINITIONS //************************************************************************** -typedef device_delegate dasm_override_delegate; +typedef device_delegate dasm_override_delegate; // ======================> device_disasm_interface @@ -66,20 +66,20 @@ public: virtual ~device_disasm_interface(); // configuration access - uint32_t min_opcode_bytes() const { return disasm_min_opcode_bytes(); } - uint32_t max_opcode_bytes() const { return disasm_max_opcode_bytes(); } + u32 min_opcode_bytes() const { return disasm_min_opcode_bytes(); } + u32 max_opcode_bytes() const { return disasm_max_opcode_bytes(); } // static inline configuration helpers static void static_set_dasm_override(device_t &device, dasm_override_delegate dasm_override); // interface for disassembly - offs_t disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options = 0); + offs_t disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options = 0); protected: // required operation overrides - virtual uint32_t disasm_min_opcode_bytes() const = 0; - virtual uint32_t disasm_max_opcode_bytes() const = 0; - virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) = 0; + virtual u32 disasm_min_opcode_bytes() const = 0; + virtual u32 disasm_max_opcode_bytes() const = 0; + virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) = 0; // interface-level overrides virtual void interface_pre_start() override; @@ -92,4 +92,4 @@ private: typedef device_interface_iterator disasm_interface_iterator; -#endif /* __DIDISASM_H__ */ +#endif /* MAME_EMU_DIDISASM_H */ diff --git a/src/emu/diexec.cpp b/src/emu/diexec.cpp index 02c46244c0a..ea20860c426 100644 --- a/src/emu/diexec.cpp +++ b/src/emu/diexec.cpp @@ -154,7 +154,7 @@ bool device_execute_interface::executing() const // remaining in this timeslice //------------------------------------------------- -int32_t device_execute_interface::cycles_remaining() const +s32 device_execute_interface::cycles_remaining() const { return executing() ? *m_icountptr : 0; } @@ -235,7 +235,7 @@ void device_execute_interface::suspend_resume_changed() // suspend - set a suspend reason for this device //------------------------------------------------- -void device_execute_interface::suspend(uint32_t reason, bool eatcycles) +void device_execute_interface::suspend(u32 reason, bool eatcycles) { if (TEMPLOG) printf("suspend %s (%X)\n", device().tag(), reason); // set the suspend reason and eat cycles flag @@ -250,7 +250,7 @@ if (TEMPLOG) printf("suspend %s (%X)\n", device().tag(), reason); // device //------------------------------------------------- -void device_execute_interface::resume(uint32_t reason) +void device_execute_interface::resume(u32 reason) { if (TEMPLOG) printf("resume %s (%X)\n", device().tag(), reason); // clear the suspend reason and eat cycles flag @@ -333,7 +333,7 @@ attotime device_execute_interface::local_time() const // cycles executed on this device //------------------------------------------------- -uint64_t device_execute_interface::total_cycles() const +u64 device_execute_interface::total_cycles() const { if (executing()) { @@ -350,7 +350,7 @@ uint64_t device_execute_interface::total_cycles() const // of clocks to cycles, rounding down if necessary //------------------------------------------------- -uint64_t device_execute_interface::execute_clocks_to_cycles(uint64_t clocks) const +u64 device_execute_interface::execute_clocks_to_cycles(u64 clocks) const { return clocks; } @@ -361,7 +361,7 @@ uint64_t device_execute_interface::execute_clocks_to_cycles(uint64_t clocks) con // of cycles to clocks, rounding down if necessary //------------------------------------------------- -uint64_t device_execute_interface::execute_cycles_to_clocks(uint64_t cycles) const +u64 device_execute_interface::execute_cycles_to_clocks(u64 cycles) const { return cycles; } @@ -373,7 +373,7 @@ uint64_t device_execute_interface::execute_cycles_to_clocks(uint64_t cycles) con // operation can take //------------------------------------------------- -uint32_t device_execute_interface::execute_min_cycles() const +u32 device_execute_interface::execute_min_cycles() const { return 1; } @@ -385,7 +385,7 @@ uint32_t device_execute_interface::execute_min_cycles() const // operation can take //------------------------------------------------- -uint32_t device_execute_interface::execute_max_cycles() const +u32 device_execute_interface::execute_max_cycles() const { return 1; } @@ -396,7 +396,7 @@ uint32_t device_execute_interface::execute_max_cycles() const // of input lines for the device //------------------------------------------------- -uint32_t device_execute_interface::execute_input_lines() const +u32 device_execute_interface::execute_input_lines() const { return 0; } @@ -407,7 +407,7 @@ uint32_t device_execute_interface::execute_input_lines() const // IRQ vector when an acknowledge is processed //------------------------------------------------- -uint32_t device_execute_interface::execute_default_irq_vector() const +u32 device_execute_interface::execute_default_irq_vector() const { return 0; } @@ -419,7 +419,7 @@ uint32_t device_execute_interface::execute_default_irq_vector() const // spinning devices for performance optimization) //------------------------------------------------- -void device_execute_interface::execute_burn(int32_t cycles) +void device_execute_interface::execute_burn(s32 cycles) { // by default, do nothing } @@ -584,7 +584,7 @@ void device_execute_interface::interface_clock_changed() m_attoseconds_per_cycle = HZ_TO_ATTOSECONDS(m_cycles_per_second); // update the device's divisor - int64_t attos = m_attoseconds_per_cycle; + s64 attos = m_attoseconds_per_cycle; m_divshift = 0; while (attos >= (1UL << 31)) { @@ -803,7 +803,7 @@ if (TEMPLOG) printf("empty_queue(%s,%d,%d)\n", m_execute->device().tag(), m_line // loop over all events for (int curevent = 0; curevent < m_qindex; curevent++) { - int32_t input_event = m_queue[curevent]; + s32 input_event = m_queue[curevent]; // set the input line state and vector m_curstate = input_event & 0xff; diff --git a/src/emu/diexec.h b/src/emu/diexec.h index 3a0f5bfa53a..daec1a98a0c 100644 --- a/src/emu/diexec.h +++ b/src/emu/diexec.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DIEXEC_H__ -#define __DIEXEC_H__ +#ifndef MAME_EMU_DIEXEC_H +#define MAME_EMU_DIEXEC_H //************************************************************************** @@ -23,14 +23,14 @@ //************************************************************************** // suspension reasons for executing devices -const uint32_t SUSPEND_REASON_HALT = 0x0001; // HALT line set (or equivalent) -const uint32_t SUSPEND_REASON_RESET = 0x0002; // RESET line set (or equivalent) -const uint32_t SUSPEND_REASON_SPIN = 0x0004; // currently spinning -const uint32_t SUSPEND_REASON_TRIGGER = 0x0008; // waiting for a trigger -const uint32_t SUSPEND_REASON_DISABLE = 0x0010; // disabled (due to disable flag) -const uint32_t SUSPEND_REASON_TIMESLICE = 0x0020; // waiting for the next timeslice -const uint32_t SUSPEND_REASON_CLOCK = 0x0040; // currently not clocked -const uint32_t SUSPEND_ANY_REASON = ~0; // all of the above +constexpr u32 SUSPEND_REASON_HALT = 0x0001; // HALT line set (or equivalent) +constexpr u32 SUSPEND_REASON_RESET = 0x0002; // RESET line set (or equivalent) +constexpr u32 SUSPEND_REASON_SPIN = 0x0004; // currently spinning +constexpr u32 SUSPEND_REASON_TRIGGER = 0x0008; // waiting for a trigger +constexpr u32 SUSPEND_REASON_DISABLE = 0x0010; // disabled (due to disable flag) +constexpr u32 SUSPEND_REASON_TIMESLICE = 0x0020; // waiting for the next timeslice +constexpr u32 SUSPEND_REASON_CLOCK = 0x0040; // currently not clocked +constexpr u32 SUSPEND_ANY_REASON = ~0; // all of the above // I/O line states @@ -71,7 +71,7 @@ enum // MACROS //************************************************************************** -#define TIMER_CALLBACK_MEMBER(name) void name(void *ptr, int32_t param) +#define TIMER_CALLBACK_MEMBER(name) void name(void *ptr, s32 param) // IRQ callback to be called by device implementations when an IRQ is actually taken #define IRQ_CALLBACK_MEMBER(func) int func(device_t &device, int irqline) @@ -138,14 +138,14 @@ public: // configuration access bool disabled() const { return m_disabled; } - uint64_t clocks_to_cycles(uint64_t clocks) const { return execute_clocks_to_cycles(clocks); } - uint64_t cycles_to_clocks(uint64_t cycles) const { return execute_cycles_to_clocks(cycles); } - uint32_t min_cycles() const { return execute_min_cycles(); } - uint32_t max_cycles() const { return execute_max_cycles(); } - attotime cycles_to_attotime(uint64_t cycles) const { return device().clocks_to_attotime(cycles_to_clocks(cycles)); } - uint64_t attotime_to_cycles(const attotime &duration) const { return clocks_to_cycles(device().attotime_to_clocks(duration)); } - uint32_t input_lines() const { return execute_input_lines(); } - uint32_t default_irq_vector() const { return execute_default_irq_vector(); } + u64 clocks_to_cycles(u64 clocks) const { return execute_clocks_to_cycles(clocks); } + u64 cycles_to_clocks(u64 cycles) const { return execute_cycles_to_clocks(cycles); } + u32 min_cycles() const { return execute_min_cycles(); } + u32 max_cycles() const { return execute_max_cycles(); } + attotime cycles_to_attotime(u64 cycles) const { return device().clocks_to_attotime(cycles_to_clocks(cycles)); } + u64 attotime_to_cycles(const attotime &duration) const { return clocks_to_cycles(device().attotime_to_clocks(duration)); } + u32 input_lines() const { return execute_input_lines(); } + u32 default_irq_vector() const { return execute_default_irq_vector(); } // static inline configuration helpers static void static_set_disable(device_t &device); @@ -156,7 +156,7 @@ public: // execution management device_scheduler &scheduler() const { assert(m_scheduler != nullptr); return *m_scheduler; } bool executing() const; - int32_t cycles_remaining() const; + s32 cycles_remaining() const; void eat_cycles(int cycles); void adjust_icount(int delta); void abort_timeslice(); @@ -168,9 +168,9 @@ public: int input_state(int linenum) const { return m_input[linenum].m_curstate; } // suspend/resume - void suspend(uint32_t reason, bool eatcycles); - void resume(uint32_t reason); - bool suspended(uint32_t reason = SUSPEND_ANY_REASON) const { return (m_nextsuspend & reason) != 0; } + void suspend(u32 reason, bool eatcycles); + void resume(u32 reason); + bool suspended(u32 reason = SUSPEND_ANY_REASON) const { return (m_nextsuspend & reason) != 0; } void yield() { suspend(SUSPEND_REASON_TIMESLICE, false); } void spin() { suspend(SUSPEND_REASON_TIMESLICE, true); } void spin_until_trigger(int trigid) { suspend_until_trigger(trigid, true); } @@ -184,7 +184,7 @@ public: // time and cycle accounting attotime local_time() const; - uint64_t total_cycles() const; + u64 total_cycles() const; // required operation overrides void run() { execute_run(); } @@ -195,18 +195,18 @@ public: protected: // clock and cycle information getters - virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const; - virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const; - virtual uint32_t execute_min_cycles() const; - virtual uint32_t execute_max_cycles() const; + virtual u64 execute_clocks_to_cycles(u64 clocks) const; + virtual u64 execute_cycles_to_clocks(u64 cycles) const; + virtual u32 execute_min_cycles() const; + virtual u32 execute_max_cycles() const; // input line information getters - virtual uint32_t execute_input_lines() const; - virtual uint32_t execute_default_irq_vector() const; + virtual u32 execute_input_lines() const; + virtual u32 execute_default_irq_vector() const; // optional operation overrides virtual void execute_run() = 0; - virtual void execute_burn(int32_t cycles); + virtual void execute_burn(s32 cycles); virtual void execute_set_input(int linenum, int state); // interface-level overrides @@ -239,10 +239,10 @@ protected: device_execute_interface *m_execute;// pointer to the execute interface int m_linenum; // which input line we are - int32_t m_stored_vector; // most recently written vector - int32_t m_curvector; // most recently processed vector - uint8_t m_curstate; // most recently processed state - int32_t m_queue[32]; // queue of pending events + s32 m_stored_vector; // most recently written vector + s32 m_curvector; // most recently processed vector + u8 m_curstate; // most recently processed state + s32 m_queue[32]; // queue of pending events int m_qindex; // index within the queue private: @@ -274,19 +274,19 @@ protected: int m_cycles_stolen; // number of cycles we artificially stole // suspend states - uint32_t m_suspend; // suspend reason mask (0 = not suspended) - uint32_t m_nextsuspend; // pending suspend reason mask - uint8_t m_eatcycles; // true if we eat cycles while suspended - uint8_t m_nexteatcycles; // pending value - int32_t m_trigger; // pending trigger to release a trigger suspension - int32_t m_inttrigger; // interrupt trigger index + u32 m_suspend; // suspend reason mask (0 = not suspended) + u32 m_nextsuspend; // pending suspend reason mask + u8 m_eatcycles; // true if we eat cycles while suspended + u8 m_nexteatcycles; // pending value + s32 m_trigger; // pending trigger to release a trigger suspension + s32 m_inttrigger; // interrupt trigger index // clock and timing information - uint64_t m_totalcycles; // total device cycles executed + u64 m_totalcycles; // total device cycles executed attotime m_localtime; // local time, relative to the timer system's global time - int32_t m_divisor; // 32-bit attoseconds_per_cycle divisor - uint8_t m_divshift; // right shift amount to fit the divisor into 32 bits - uint32_t m_cycles_per_second; // cycles per second, adjusted for multipliers + s32 m_divisor; // 32-bit attoseconds_per_cycle divisor + u8 m_divshift; // right shift amount to fit the divisor into 32 bits + u32 m_cycles_per_second; // cycles per second, adjusted for multipliers attoseconds_t m_attoseconds_per_cycle; // attoseconds per adjusted clock cycle private: @@ -305,4 +305,4 @@ private: typedef device_interface_iterator execute_interface_iterator; -#endif /* __DIEXEC_H__ */ +#endif /* MAME_EMU_DIEXEC_H */ diff --git a/src/emu/digfx.cpp b/src/emu/digfx.cpp index 56fe96865b9..e47d44036a8 100644 --- a/src/emu/digfx.cpp +++ b/src/emu/digfx.cpp @@ -124,23 +124,23 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) // local variables to hold mutable copies of gfx layout data gfx_layout glcopy; - std::vector extxoffs(0); - std::vector extyoffs(0); + std::vector extxoffs(0); + std::vector extyoffs(0); // loop over all elements - for (uint8_t curgfx = 0; curgfx < MAX_GFX_ELEMENTS && gfxdecodeinfo[curgfx].gfxlayout != nullptr; curgfx++) + for (u8 curgfx = 0; curgfx < MAX_GFX_ELEMENTS && gfxdecodeinfo[curgfx].gfxlayout != nullptr; curgfx++) { const gfx_decode_entry &gfx = gfxdecodeinfo[curgfx]; // extract the scale factors and xormask - uint32_t xscale = GFXENTRY_GETXSCALE(gfx.flags); - uint32_t yscale = GFXENTRY_GETYSCALE(gfx.flags); - uint32_t xormask = GFXENTRY_ISREVERSE(gfx.flags) ? 7 : 0; + u32 xscale = GFXENTRY_GETXSCALE(gfx.flags); + u32 yscale = GFXENTRY_GETYSCALE(gfx.flags); + u32 xormask = GFXENTRY_ISREVERSE(gfx.flags) ? 7 : 0; // resolve the region - uint32_t region_length; - const uint8_t *region_base; - uint8_t region_width; + u32 region_length; + const u8 *region_base; + u8 region_width; endianness_t region_endianness; if (gfx.memory_region != nullptr) @@ -151,7 +151,7 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) memory_share *share = basedevice.memshare(gfx.memory_region); assert(share != nullptr); region_length = 8 * share->bytes(); - region_base = reinterpret_cast(share->ptr()); + region_base = reinterpret_cast(share->ptr()); region_width = share->bytewidth(); region_endianness = share->endianness(); } @@ -205,8 +205,8 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) // copy the X and Y offsets into our temporary arrays extxoffs.resize(glcopy.width * xscale); extyoffs.resize(glcopy.height * yscale); - memcpy(&extxoffs[0], (glcopy.extxoffs != nullptr) ? glcopy.extxoffs : glcopy.xoffset, glcopy.width * sizeof(uint32_t)); - memcpy(&extyoffs[0], (glcopy.extyoffs != nullptr) ? glcopy.extyoffs : glcopy.yoffset, glcopy.height * sizeof(uint32_t)); + memcpy(&extxoffs[0], (glcopy.extxoffs != nullptr) ? glcopy.extxoffs : glcopy.xoffset, glcopy.width * sizeof(u32)); + memcpy(&extyoffs[0], (glcopy.extyoffs != nullptr) ? glcopy.extyoffs : glcopy.yoffset, glcopy.height * sizeof(u32)); // always use the extended offsets here glcopy.extxoffs = &extxoffs[0]; @@ -229,7 +229,7 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) // loop over all the planes, converting fractions for (int j = 0; j < glcopy.planes; j++) { - uint32_t value1 = glcopy.planeoffset[j]; + u32 value1 = glcopy.planeoffset[j]; if (IS_FRAC(value1)) { assert(region_length != 0); @@ -240,7 +240,7 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) // loop over all the X/Y offsets, converting fractions for (int j = 0; j < glcopy.width; j++) { - uint32_t value2 = extxoffs[j]; + u32 value2 = extxoffs[j]; if (IS_FRAC(value2)) { assert(region_length != 0); @@ -250,7 +250,7 @@ void device_gfx_interface::decode_gfx(const gfx_decode_entry *gfxdecodeinfo) for (int j = 0; j < glcopy.height; j++) { - uint32_t value3 = extyoffs[j]; + u32 value3 = extyoffs[j]; if (IS_FRAC(value3)) { assert(region_length != 0); @@ -328,7 +328,7 @@ void device_gfx_interface::interface_validity_check(validity_checker &valid) con else gfxregion = device().owner()->subtag(region); - uint32_t region_length = valid.region_length(gfxregion.c_str()); + u32 region_length = valid.region_length(gfxregion.c_str()); if (region_length == 0) osd_printf_error("gfx[%d] references nonexistent region '%s'\n", gfxnum, gfxregion.c_str()); diff --git a/src/emu/digfx.h b/src/emu/digfx.h index 9ce8c354db8..a8f8a80f672 100644 --- a/src/emu/digfx.h +++ b/src/emu/digfx.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DIGFX_H__ -#define __DIGFX_H__ +#ifndef MAME_EMU_DIGFX_H +#define MAME_EMU_DIGFX_H @@ -23,9 +23,9 @@ // CONSTANTS //************************************************************************** -const uint8_t MAX_GFX_ELEMENTS = 32; -const uint16_t MAX_GFX_PLANES = 8; -const uint16_t MAX_GFX_SIZE = 32; +constexpr u8 MAX_GFX_ELEMENTS = 32; +constexpr u16 MAX_GFX_PLANES = 8; +constexpr u16 MAX_GFX_SIZE = 32; @@ -160,29 +160,29 @@ class palette_device; struct gfx_layout { - uint32_t xoffs(int x) const { return (extxoffs != nullptr) ? extxoffs[x] : xoffset[x]; } - uint32_t yoffs(int y) const { return (extyoffs != nullptr) ? extyoffs[y] : yoffset[y]; } + u32 xoffs(int x) const { return (extxoffs != nullptr) ? extxoffs[x] : xoffset[x]; } + u32 yoffs(int y) const { return (extyoffs != nullptr) ? extyoffs[y] : yoffset[y]; } - uint16_t width; // pixel width of each element - uint16_t height; // pixel height of each element - uint32_t total; // total number of elements, or RGN_FRAC() - uint16_t planes; // number of bitplanes - uint32_t planeoffset[MAX_GFX_PLANES]; // bit offset of each bitplane - uint32_t xoffset[MAX_GFX_SIZE]; // bit offset of each horizontal pixel - uint32_t yoffset[MAX_GFX_SIZE]; // bit offset of each vertical pixel - uint32_t charincrement; // distance between two consecutive elements (in bits) - const uint32_t * extxoffs; // extended X offset array for really big layouts - const uint32_t * extyoffs; // extended Y offset array for really big layouts + u16 width; // pixel width of each element + u16 height; // pixel height of each element + u32 total; // total number of elements, or RGN_FRAC() + u16 planes; // number of bitplanes + u32 planeoffset[MAX_GFX_PLANES]; // bit offset of each bitplane + u32 xoffset[MAX_GFX_SIZE]; // bit offset of each horizontal pixel + u32 yoffset[MAX_GFX_SIZE]; // bit offset of each vertical pixel + u32 charincrement; // distance between two consecutive elements (in bits) + const u32 * extxoffs; // extended X offset array for really big layouts + const u32 * extyoffs; // extended Y offset array for really big layouts }; struct gfx_decode_entry { const char * memory_region; // memory region where the data resides - uint32_t start; // offset of beginning of data to decode + u32 start; // offset of beginning of data to decode const gfx_layout *gfxlayout; // pointer to gfx_layout describing the layout; nullptr marks the end of the array - uint16_t color_codes_start; // offset in the color lookup table where color codes start - uint16_t total_color_codes; // total number of color codes - uint32_t flags; // flags and optional scaling factors + u16 color_codes_start; // offset in the color lookup table where color codes start + u16 total_color_codes; // total number of color codes + u32 flags; // flags and optional scaling factors }; // ======================> device_gfx_interface @@ -201,13 +201,13 @@ public: // getters palette_device &palette() const { assert(m_palette != nullptr); return *m_palette; } - gfx_element *gfx(uint8_t index) const { assert(index < MAX_GFX_ELEMENTS); return m_gfx[index].get(); } + gfx_element *gfx(u8 index) const { assert(index < MAX_GFX_ELEMENTS); return m_gfx[index].get(); } // decoding void decode_gfx(const gfx_decode_entry *gfxdecodeinfo); void decode_gfx() { decode_gfx(m_gfxdecodeinfo); } - void set_gfx(uint8_t index, std::unique_ptr &&element) { assert(index < MAX_GFX_ELEMENTS); m_gfx[index] = std::move(element); } + void set_gfx(u8 index, std::unique_ptr &&element) { assert(index < MAX_GFX_ELEMENTS); m_gfx[index] = std::move(element); } protected: // interface-level overrides @@ -232,4 +232,4 @@ private: typedef device_interface_iterator gfx_interface_iterator; -#endif /* __DIGFX_H__ */ +#endif /* MAME_EMU_DIGFX_H */ diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp index cf945be1517..e4977f2de3d 100644 --- a/src/emu/diimage.cpp +++ b/src/emu/diimage.cpp @@ -177,7 +177,7 @@ void device_image_interface::device_compute_hash(util::hash_collection &hashes, if (partialhash) partialhash(hashes, (const unsigned char*)data, length, types); else - hashes.compute(reinterpret_cast(data), length, types); + hashes.compute(reinterpret_cast(data), length, types); } //------------------------------------------------- @@ -431,7 +431,7 @@ const std::string &device_image_interface::working_directory() // get_software_region //------------------------------------------------- -uint8_t *device_image_interface::get_software_region(const char *tag) +u8 *device_image_interface::get_software_region(const char *tag) { char full_tag[256]; @@ -448,7 +448,7 @@ uint8_t *device_image_interface::get_software_region(const char *tag) // image_get_software_region_length //------------------------------------------------- -uint32_t device_image_interface::get_software_region_length(const char *tag) +u32 device_image_interface::get_software_region_length(const char *tag) { char full_tag[256]; @@ -473,7 +473,7 @@ const char *device_image_interface::get_feature(const char *feature_name) // load_software_region - //------------------------------------------------- -bool device_image_interface::load_software_region(const char *tag, optional_shared_ptr &ptr) +bool device_image_interface::load_software_region(const char *tag, optional_shared_ptr &ptr) { size_t size = get_software_region_length(tag); @@ -498,11 +498,11 @@ bool device_image_interface::load_software_region(const char *tag, optional_shar void device_image_interface::run_hash(void (*partialhash)(util::hash_collection &, const unsigned char *, unsigned long, const char *), util::hash_collection &hashes, const char *types) { - uint32_t size; - std::vector buf; + u32 size; + std::vector buf; hashes.reset(); - size = (uint32_t) length(); + size = (u32) length(); buf.resize(size); memset(&buf[0], 0, size); @@ -527,7 +527,7 @@ void device_image_interface::image_checkhash() device_image_partialhash_func partialhash; // only calculate CRC if it hasn't been calculated, and the open_mode is read only - uint32_t crcval; + u32 crcval; if (!m_hash.crc(crcval) && is_readonly() && !m_created) { // do not cause a linear read of 600 megs please @@ -547,9 +547,9 @@ void device_image_interface::image_checkhash() return; } -uint32_t device_image_interface::crc() +u32 device_image_interface::crc() { - uint32_t crc = 0; + u32 crc = 0; image_checkhash(); m_hash.crc(crc); @@ -741,7 +741,7 @@ image_error_t device_image_interface::image_error_from_file_error(osd_file::erro // specific path //------------------------------------------------- -image_error_t device_image_interface::load_image_by_path(uint32_t open_flags, const std::string &path) +image_error_t device_image_interface::load_image_by_path(u32 open_flags, const std::string &path) { std::string revised_path; @@ -786,9 +786,9 @@ int device_image_interface::reopen_for_write(const std::string &path) // flags to use, and in what order //------------------------------------------------- -std::vector device_image_interface::determine_open_plan(bool is_create) +std::vector device_image_interface::determine_open_plan(bool is_create) { - std::vector open_plan; + std::vector open_plan; // emit flags into a vector if (!is_create && is_readable() && is_writeable()) @@ -822,13 +822,13 @@ static void dump_wrong_and_correct_checksums(const util::hash_collection &hashes // and hash signatures of a file //------------------------------------------------- -static int verify_length_and_hash(emu_file *file, const char *name, uint32_t explength, const util::hash_collection &hashes) +static int verify_length_and_hash(emu_file *file, const char *name, u32 explength, const util::hash_collection &hashes) { int retVal = 0; if (file==nullptr) return 0; // verify length - uint32_t actlength = file->size(); + u32 actlength = file->size(); if (explength != actlength) { osd_printf_error("%s WRONG LENGTH (expected: %d found: %d)\n", name, explength, actlength); @@ -879,14 +879,14 @@ bool device_image_interface::load_software(software_list_device &swlist, const c { osd_file::error filerr = osd_file::error::NOT_FOUND; - uint32_t crc = 0; + u32 crc = 0; bool has_crc = util::hash_collection(ROM_GETHASHDATA(romp)).crc(crc); const software_info *swinfo = swlist.find(swname); if (swinfo == nullptr) return false; - uint32_t supported = swinfo->supported(); + u32 supported = swinfo->supported(); if (supported == SOFTWARE_SUPPORTED_PARTIAL) osd_printf_error("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist.list_name().c_str()); if (supported == SOFTWARE_SUPPORTED_NO) @@ -984,7 +984,7 @@ image_init_result device_image_interface::load_internal(const std::string &path, if (core_opens_image_file()) { // determine open plan - std::vector open_plan = determine_open_plan(is_create); + std::vector open_plan = determine_open_plan(is_create); // attempt to open the file in various ways for (auto iter = open_plan.cbegin(); !m_file && iter != open_plan.cend(); iter++) @@ -1491,7 +1491,7 @@ std::string device_image_interface::software_get_default_slot(const char *defaul //---------------------------------------------------------------------------- -static int image_fseek_thunk(void *file, int64_t offset, int whence) +static int image_fseek_thunk(void *file, s64 offset, int whence) { device_image_interface *image = (device_image_interface *) file; return image->fseek(offset, whence); @@ -1509,7 +1509,7 @@ static size_t image_fwrite_thunk(void *file, const void *buffer, size_t length) return image->fwrite(buffer, length); } -static uint64_t image_fsize_thunk(void *file) +static u64 image_fsize_thunk(void *file) { device_image_interface *image = (device_image_interface *) file; return image->length(); diff --git a/src/emu/diimage.h b/src/emu/diimage.h index 8c9aaaf9e7f..3e25c1fb565 100644 --- a/src/emu/diimage.h +++ b/src/emu/diimage.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DIIMAGE_H__ -#define __DIIMAGE_H__ +#ifndef MAME_EMU_DIIMAGE_H +#define MAME_EMU_DIIMAGE_H #include #include @@ -179,16 +179,16 @@ public: bool is_filetype(const std::string &candidate_filetype) { return !core_stricmp(filetype().c_str(), candidate_filetype.c_str()); } bool is_open() const { return bool(m_file); } util::core_file &image_core_file() const { return *m_file; } - uint64_t length() { check_for_file(); return m_file->size(); } + u64 length() { check_for_file(); return m_file->size(); } bool is_readonly() const { return m_readonly; } - uint32_t fread(void *buffer, uint32_t length) { check_for_file(); return m_file->read(buffer, length); } - uint32_t fread(optional_shared_ptr &ptr, uint32_t length) { ptr.allocate(length); return fread(ptr.target(), length); } - uint32_t fread(optional_shared_ptr &ptr, uint32_t length, offs_t offset) { ptr.allocate(length); return fread(ptr + offset, length - offset); } - uint32_t fwrite(const void *buffer, uint32_t length) { check_for_file(); return m_file->write(buffer, length); } - int fseek(int64_t offset, int whence) { check_for_file(); return m_file->seek(offset, whence); } - uint64_t ftell() { check_for_file(); return m_file->tell(); } + u32 fread(void *buffer, u32 length) { check_for_file(); return m_file->read(buffer, length); } + u32 fread(optional_shared_ptr &ptr, u32 length) { ptr.allocate(length); return fread(ptr.target(), length); } + u32 fread(optional_shared_ptr &ptr, u32 length, offs_t offset) { ptr.allocate(length); return fread(ptr + offset, length - offset); } + u32 fwrite(const void *buffer, u32 length) { check_for_file(); return m_file->write(buffer, length); } + int fseek(s64 offset, int whence) { check_for_file(); return m_file->seek(offset, whence); } + u64 ftell() { check_for_file(); return m_file->tell(); } int fgetc() { char ch; if (fread(&ch, 1) != 1) ch = '\0'; return ch; } - char *fgets(char *buffer, uint32_t length) { check_for_file(); return m_file->gets(buffer, length); } + char *fgets(char *buffer, u32 length) { check_for_file(); return m_file->gets(buffer, length); } int image_feof() { check_for_file(); return m_file->eof(); } void *ptr() {check_for_file(); return const_cast(m_file->buffer()); } // configuration access @@ -197,7 +197,7 @@ public: const std::string &longname() const { return m_longname; } const std::string &manufacturer() const { return m_manufacturer; } const std::string &year() const { return m_year; } - uint32_t supported() const { return m_supported; } + u32 supported() const { return m_supported; } const software_info *software_entry() const { return m_software_info_ptr; } const software_part *part_entry() const { return m_software_part_ptr; } @@ -207,12 +207,12 @@ public: void set_working_directory(const char *working_directory) { m_working_directory = working_directory; } const std::string &working_directory(); - uint8_t *get_software_region(const char *tag); - uint32_t get_software_region_length(const char *tag); + u8 *get_software_region(const char *tag); + u32 get_software_region_length(const char *tag); const char *get_feature(const char *feature_name); - bool load_software_region(const char *tag, optional_shared_ptr &ptr); + bool load_software_region(const char *tag, optional_shared_ptr &ptr); - uint32_t crc(); + u32 crc(); util::hash_collection& hash() { return m_hash; } void battery_load(void *buffer, int length, int fill); @@ -255,7 +255,7 @@ protected: virtual const bool use_software_list_file_extension_for_filetype() const { return false; } image_init_result load_internal(const std::string &path, bool is_create, int create_format, util::option_resolution *create_args, bool just_load); - image_error_t load_image_by_path(uint32_t open_flags, const std::string &path); + image_error_t load_image_by_path(u32 open_flags, const std::string &path); void clear(); bool is_loaded(); @@ -308,7 +308,7 @@ protected: private: static image_error_t image_error_from_file_error(osd_file::error filerr); bool schedule_postload_hard_reset_if_needed(); - std::vector determine_open_plan(bool is_create); + std::vector determine_open_plan(bool is_create); // creation info formatlist_type m_formatlist; @@ -320,7 +320,7 @@ private: std::string m_longname; std::string m_manufacturer; std::string m_year; - uint32_t m_supported; + u32 m_supported; // flags bool m_readonly; @@ -346,4 +346,4 @@ private: // iterator typedef device_interface_iterator image_interface_iterator; -#endif /* __DIIMAGE_H__ */ +#endif /* MAME_EMU_DIIMAGE_H */ diff --git a/src/emu/dimemory.cpp b/src/emu/dimemory.cpp index 9d038af72d9..e42ad28e9d3 100644 --- a/src/emu/dimemory.cpp +++ b/src/emu/dimemory.cpp @@ -50,7 +50,7 @@ address_space_config::address_space_config() @param internal @param defmap */ -address_space_config::address_space_config(const char *name, endianness_t endian, uint8_t datawidth, uint8_t addrwidth, int8_t addrshift, address_map_constructor internal, address_map_constructor defmap) +address_space_config::address_space_config(const char *name, endianness_t endian, u8 datawidth, u8 addrwidth, s8 addrshift, address_map_constructor internal, address_map_constructor defmap) : m_name(name), m_endianness(endian), m_databus_width(datawidth), @@ -64,7 +64,7 @@ address_space_config::address_space_config(const char *name, endianness_t endian { } -address_space_config::address_space_config(const char *name, endianness_t endian, uint8_t datawidth, uint8_t addrwidth, int8_t addrshift, uint8_t logwidth, uint8_t pageshift, address_map_constructor internal, address_map_constructor defmap) +address_space_config::address_space_config(const char *name, endianness_t endian, u8 datawidth, u8 addrwidth, s8 addrshift, u8 logwidth, u8 pageshift, address_map_constructor internal, address_map_constructor defmap) : m_name(name), m_endianness(endian), m_databus_width(datawidth), @@ -78,7 +78,7 @@ address_space_config::address_space_config(const char *name, endianness_t endian { } -address_space_config::address_space_config(const char *name, endianness_t endian, uint8_t datawidth, uint8_t addrwidth, int8_t addrshift, address_map_delegate internal, address_map_delegate defmap) +address_space_config::address_space_config(const char *name, endianness_t endian, u8 datawidth, u8 addrwidth, s8 addrshift, address_map_delegate internal, address_map_delegate defmap) : m_name(name), m_endianness(endian), m_databus_width(datawidth), @@ -94,7 +94,7 @@ address_space_config::address_space_config(const char *name, endianness_t endian { } -address_space_config::address_space_config(const char *name, endianness_t endian, uint8_t datawidth, uint8_t addrwidth, int8_t addrshift, uint8_t logwidth, uint8_t pageshift, address_map_delegate internal, address_map_delegate defmap) +address_space_config::address_space_config(const char *name, endianness_t endian, u8 datawidth, u8 addrwidth, s8 addrshift, u8 logwidth, u8 pageshift, address_map_delegate internal, address_map_delegate defmap) : m_name(name), m_endianness(endian), m_databus_width(datawidth), @@ -189,7 +189,7 @@ bool device_memory_interface::memory_translate(address_spacenum spacenum, int in // handled by bypassing the memory system //------------------------------------------------- -bool device_memory_interface::memory_read(address_spacenum spacenum, offs_t offset, int size, uint64_t &value) +bool device_memory_interface::memory_read(address_spacenum spacenum, offs_t offset, int size, u64 &value) { // by default, we don't do anything return false; @@ -204,7 +204,7 @@ bool device_memory_interface::memory_read(address_spacenum spacenum, offs_t offs // handled by bypassing the memory system //------------------------------------------------- -bool device_memory_interface::memory_write(address_spacenum spacenum, offs_t offset, int size, uint64_t value) +bool device_memory_interface::memory_write(address_spacenum spacenum, offs_t offset, int size, u64 value) { // by default, we don't do anything return false; @@ -220,7 +220,7 @@ bool device_memory_interface::memory_write(address_spacenum spacenum, offs_t off // system //------------------------------------------------- -bool device_memory_interface::memory_readop(offs_t offset, int size, uint64_t &value) +bool device_memory_interface::memory_readop(offs_t offset, int size, u64 &value) { // by default, we don't do anything return false; diff --git a/src/emu/dimemory.h b/src/emu/dimemory.h index 67aef5abcd9..c5a3226c053 100644 --- a/src/emu/dimemory.h +++ b/src/emu/dimemory.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DIMEMORY_H__ -#define __DIMEMORY_H__ +#ifndef MAME_EMU_DIMEMORY_H +#define MAME_EMU_DIMEMORY_H //************************************************************************** @@ -23,19 +23,19 @@ //************************************************************************** // Translation intentions -const int TRANSLATE_TYPE_MASK = 0x03; // read write or fetch -const int TRANSLATE_USER_MASK = 0x04; // user mode or fully privileged -const int TRANSLATE_DEBUG_MASK = 0x08; // debug mode (no side effects) +constexpr int TRANSLATE_TYPE_MASK = 0x03; // read write or fetch +constexpr int TRANSLATE_USER_MASK = 0x04; // user mode or fully privileged +constexpr int TRANSLATE_DEBUG_MASK = 0x08; // debug mode (no side effects) -const int TRANSLATE_READ = 0; // translate for read -const int TRANSLATE_WRITE = 1; // translate for write -const int TRANSLATE_FETCH = 2; // translate for instruction fetch -const int TRANSLATE_READ_USER = (TRANSLATE_READ | TRANSLATE_USER_MASK); -const int TRANSLATE_WRITE_USER = (TRANSLATE_WRITE | TRANSLATE_USER_MASK); -const int TRANSLATE_FETCH_USER = (TRANSLATE_FETCH | TRANSLATE_USER_MASK); -const int TRANSLATE_READ_DEBUG = (TRANSLATE_READ | TRANSLATE_DEBUG_MASK); -const int TRANSLATE_WRITE_DEBUG = (TRANSLATE_WRITE | TRANSLATE_DEBUG_MASK); -const int TRANSLATE_FETCH_DEBUG = (TRANSLATE_FETCH | TRANSLATE_DEBUG_MASK); +constexpr int TRANSLATE_READ = 0; // translate for read +constexpr int TRANSLATE_WRITE = 1; // translate for write +constexpr int TRANSLATE_FETCH = 2; // translate for instruction fetch +constexpr int TRANSLATE_READ_USER = (TRANSLATE_READ | TRANSLATE_USER_MASK); +constexpr int TRANSLATE_WRITE_USER = (TRANSLATE_WRITE | TRANSLATE_USER_MASK); +constexpr int TRANSLATE_FETCH_USER = (TRANSLATE_FETCH | TRANSLATE_USER_MASK); +constexpr int TRANSLATE_READ_DEBUG = (TRANSLATE_READ | TRANSLATE_DEBUG_MASK); +constexpr int TRANSLATE_WRITE_DEBUG = (TRANSLATE_WRITE | TRANSLATE_DEBUG_MASK); +constexpr int TRANSLATE_FETCH_DEBUG = (TRANSLATE_FETCH | TRANSLATE_DEBUG_MASK); @@ -100,9 +100,9 @@ public: bool translate(address_spacenum spacenum, int intention, offs_t &address) { return memory_translate(spacenum, intention, address); } // read/write access - bool read(address_spacenum spacenum, offs_t offset, int size, uint64_t &value) { return memory_read(spacenum, offset, size, value); } - bool write(address_spacenum spacenum, offs_t offset, int size, uint64_t value) { return memory_write(spacenum, offset, size, value); } - bool readop(offs_t offset, int size, uint64_t &value) { return memory_readop(offset, size, value); } + bool read(address_spacenum spacenum, offs_t offset, int size, u64 &value) { return memory_read(spacenum, offset, size, value); } + bool write(address_spacenum spacenum, offs_t offset, int size, u64 value) { return memory_write(spacenum, offset, size, value); } + bool readop(offs_t offset, int size, u64 &value) { return memory_readop(offset, size, value); } // deliberately ambiguous functions; if you have the memory interface // just use it @@ -114,9 +114,9 @@ protected: // optional operation overrides virtual bool memory_translate(address_spacenum spacenum, int intention, offs_t &address); - virtual bool memory_read(address_spacenum spacenum, offs_t offset, int size, uint64_t &value); - virtual bool memory_write(address_spacenum spacenum, offs_t offset, int size, uint64_t value); - virtual bool memory_readop(offs_t offset, int size, uint64_t &value); + virtual bool memory_read(address_spacenum spacenum, offs_t offset, int size, u64 &value); + virtual bool memory_write(address_spacenum spacenum, offs_t offset, int size, u64 value); + virtual bool memory_readop(offs_t offset, int size, u64 &value); // interface-level overrides virtual void interface_validity_check(validity_checker &valid) const override; @@ -134,4 +134,4 @@ typedef device_interface_iterator memory_interface_iter -#endif /* __DIMEMORY_H__ */ +#endif /* MAME_EMU_DIMEMORY_H */ diff --git a/src/emu/dinetwork.cpp b/src/emu/dinetwork.cpp index 03bbd409721..841a7e2524a 100644 --- a/src/emu/dinetwork.cpp +++ b/src/emu/dinetwork.cpp @@ -16,13 +16,13 @@ device_network_interface::~device_network_interface() { } -int device_network_interface::send(uint8_t *buf, int len) const +int device_network_interface::send(u8 *buf, int len) const { if(!m_dev) return 0; return m_dev->send(buf, len); } -void device_network_interface::recv_cb(uint8_t *buf, int len) +void device_network_interface::recv_cb(u8 *buf, int len) { } diff --git a/src/emu/dinetwork.h b/src/emu/dinetwork.h index 44ca6113a22..8cf6ec9c5a7 100644 --- a/src/emu/dinetwork.h +++ b/src/emu/dinetwork.h @@ -1,7 +1,7 @@ // license:BSD-3-Clause // copyright-holders:Carl, Miodrag Milanovic -#ifndef __DINETWORK_H__ -#define __DINETWORK_H__ +#ifndef MAME_EMU_DINETWORK_H +#define MAME_EMU_DINETWORK_H class osd_netdev; @@ -19,8 +19,8 @@ public: bool get_promisc() const { return m_promisc; } int get_interface() const { return m_intf; } - int send(uint8_t *buf, int len) const; - virtual void recv_cb(uint8_t *buf, int len); + int send(u8 *buf, int len) const; + virtual void recv_cb(u8 *buf, int len); protected: bool m_promisc; @@ -34,4 +34,4 @@ protected: // iterator typedef device_interface_iterator network_interface_iterator; -#endif +#endif // MAME_EMU_DINETWORK_H diff --git a/src/emu/dinvram.h b/src/emu/dinvram.h index 90f5651f7de..d48889d29dd 100644 --- a/src/emu/dinvram.h +++ b/src/emu/dinvram.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DINVRAM_H__ -#define __DINVRAM_H__ +#ifndef MAME_EMU_DINVRAM +#define MAME_EMU_DINVRAM //************************************************************************** @@ -49,4 +49,4 @@ protected: typedef device_interface_iterator nvram_interface_iterator; -#endif /* __DINVRAM_H__ */ +#endif /* MAME_EMU_DINVRAM */ diff --git a/src/emu/dioutput.h b/src/emu/dioutput.h index 1ba6f9d9f81..70426a88509 100644 --- a/src/emu/dioutput.h +++ b/src/emu/dioutput.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DIOUTPUT_H__ -#define __DIOUTPUT_H__ +#ifndef MAME_EMU_DIOUTPUT_H +#define MAME_EMU_DIOUTPUT_H @@ -59,4 +59,4 @@ protected: -#endif /* __DIOUTPUT_H__ */ +#endif /* MAME_EMU_DIOUTPUT_H */ diff --git a/src/emu/dipty.cpp b/src/emu/dipty.cpp index 7fab9b53a32..2759b27078a 100644 --- a/src/emu/dipty.cpp +++ b/src/emu/dipty.cpp @@ -51,18 +51,18 @@ bool device_pty_interface::is_open() const return m_opened; } -ssize_t device_pty_interface::read(uint8_t *rx_chars , size_t count) const +ssize_t device_pty_interface::read(u8 *rx_chars , size_t count) const { - std::uint32_t actual_bytes; + u32 actual_bytes; if (m_opened && m_pty_master->read(rx_chars, 0, count, actual_bytes) == osd_file::error::NONE) return actual_bytes; else return -1; } -void device_pty_interface::write(uint8_t tx_char) const +void device_pty_interface::write(u8 tx_char) const { - std::uint32_t actual_bytes; + u32 actual_bytes; if (m_opened) m_pty_master->write(&tx_char, 0, 1, actual_bytes); } diff --git a/src/emu/dipty.h b/src/emu/dipty.h index f9b38232c80..4d13f9f8470 100644 --- a/src/emu/dipty.h +++ b/src/emu/dipty.h @@ -29,8 +29,8 @@ public: bool is_open() const; - ssize_t read(uint8_t *rx_chars , size_t count) const; - void write(uint8_t tx_char) const; + ssize_t read(u8 *rx_chars , size_t count) const; + void write(u8 tx_char) const; bool is_slave_connected() const; diff --git a/src/emu/dirom.cpp b/src/emu/dirom.cpp index 85cd3e3c6b3..a4a9aadc365 100644 --- a/src/emu/dirom.cpp +++ b/src/emu/dirom.cpp @@ -1,7 +1,7 @@ #include "emu.h" -device_rom_interface::device_rom_interface(const machine_config &mconfig, device_t &device, uint8_t addrwidth, endianness_t endian, uint8_t datawidth) : +device_rom_interface::device_rom_interface(const machine_config &mconfig, device_t &device, u8 addrwidth, endianness_t endian, u8 datawidth) : device_memory_interface(mconfig, device), m_rom_config("rom", endian, datawidth, addrwidth) { @@ -41,10 +41,10 @@ void device_rom_interface::reset_bank() m_bank->set_entry(m_cur_bank); } -void device_rom_interface::set_rom(const void *base, uint32_t size) +void device_rom_interface::set_rom(const void *base, u32 size) { - uint32_t mend = m_rom_config.addr_width() == 32 ? 0xffffffff : (1 << m_rom_config.addr_width()) - 1; - uint32_t rend = size-1; + u32 mend = m_rom_config.addr_width() == 32 ? 0xffffffff : (1 << m_rom_config.addr_width()) - 1; + u32 rend = size-1; m_bank_count = mend == 0xffffffff ? 1 : (rend+1) / (mend+1); if(m_bank_count < 1) m_bank_count = 1; @@ -57,7 +57,7 @@ void device_rom_interface::set_rom(const void *base, uint32_t size) } else { // Round up to the nearest power-of-two-minus-one - uint32_t rmask = rend; + u32 rmask = rend; rmask |= rmask >> 1; rmask |= rmask >> 2; rmask |= rmask >> 4; @@ -85,7 +85,7 @@ void device_rom_interface::interface_pre_start() if(reg) set_rom(reg->base(), reg->bytes()); else { - uint32_t end = m_rom_config.addr_width() == 32 ? 0xffffffff : (1 << m_rom_config.addr_width()) - 1; + u32 end = m_rom_config.addr_width() == 32 ? 0xffffffff : (1 << m_rom_config.addr_width()) - 1; space().unmap_read(0, end); } } diff --git a/src/emu/dirom.h b/src/emu/dirom.h index cc8ee590ea9..ddbf35c9946 100644 --- a/src/emu/dirom.h +++ b/src/emu/dirom.h @@ -14,21 +14,21 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DIROM_H__ -#define __DIROM_H__ +#ifndef MAME_EMU_DIROM_H +#define MAME_EMU_DIROM_H class device_rom_interface : public device_memory_interface { public: - device_rom_interface(const machine_config &mconfig, device_t &device, uint8_t addrwidth, endianness_t endian = ENDIANNESS_LITTLE, uint8_t datawidth = 8); + device_rom_interface(const machine_config &mconfig, device_t &device, u8 addrwidth, endianness_t endian = ENDIANNESS_LITTLE, u8 datawidth = 8); virtual ~device_rom_interface(); - inline uint8_t read_byte(offs_t byteaddress) { return m_rom_direct->read_byte(byteaddress); } - inline uint16_t read_word(offs_t byteaddress) { return m_rom_direct->read_word(byteaddress); } - inline uint32_t read_dword(offs_t byteaddress) { return m_rom_direct->read_dword(byteaddress); } - inline uint64_t read_qword(offs_t byteaddress) { return m_rom_direct->read_qword(byteaddress); } + inline u8 read_byte(offs_t byteaddress) { return m_rom_direct->read_byte(byteaddress); } + inline u16 read_word(offs_t byteaddress) { return m_rom_direct->read_word(byteaddress); } + inline u32 read_dword(offs_t byteaddress) { return m_rom_direct->read_dword(byteaddress); } + inline u64 read_qword(offs_t byteaddress) { return m_rom_direct->read_qword(byteaddress); } - void set_rom(const void *base, uint32_t size); + void set_rom(const void *base, u32 size); void set_rom_bank(int bank); protected: @@ -52,4 +52,4 @@ private: void reset_bank(); }; -#endif +#endif // MAME_EMU_DIROM_H diff --git a/src/emu/dirtc.cpp b/src/emu/dirtc.cpp index 12c7b5c1098..4243622822b 100644 --- a/src/emu/dirtc.cpp +++ b/src/emu/dirtc.cpp @@ -87,7 +87,7 @@ void device_rtc_interface::set_current_time(const system_time &systime) // convert_to_bcd - //------------------------------------------------- -uint8_t device_rtc_interface::convert_to_bcd(int val) +u8 device_rtc_interface::convert_to_bcd(int val) { return ((val / 10) << 4) | (val % 10); } @@ -97,7 +97,7 @@ uint8_t device_rtc_interface::convert_to_bcd(int val) // bcd_to_integer - //------------------------------------------------- -int device_rtc_interface::bcd_to_integer(uint8_t val) +int device_rtc_interface::bcd_to_integer(u8 val) { return (((val & 0xf0) >> 4) * 10) + (val & 0x0f); } diff --git a/src/emu/dirtc.h b/src/emu/dirtc.h index d486250ffac..acc4cfe4487 100644 --- a/src/emu/dirtc.h +++ b/src/emu/dirtc.h @@ -53,8 +53,8 @@ public: bool has_battery() const { return rtc_battery_backed(); } protected: - static uint8_t convert_to_bcd(int val); - static int bcd_to_integer(uint8_t val); + static u8 convert_to_bcd(int val); + static int bcd_to_integer(u8 val); void set_clock_register(int register, int value); int get_clock_register(int register); diff --git a/src/emu/diserial.cpp b/src/emu/diserial.cpp index 237d4ba7f67..9fae3f494f8 100644 --- a/src/emu/diserial.cpp +++ b/src/emu/diserial.cpp @@ -295,7 +295,7 @@ void device_serial_interface::receive_register_update_bit(int bit) void device_serial_interface::receive_register_extract() { - uint8_t data; + u8 data; receive_register_reset(); @@ -369,7 +369,7 @@ void device_serial_interface::transmit_register_add_bit(int bit) /* generate data in stream format ready for transfer */ -void device_serial_interface::transmit_register_setup(uint8_t data_byte) +void device_serial_interface::transmit_register_setup(u8 data_byte) { int i; unsigned char transmit_data; @@ -434,7 +434,7 @@ void device_serial_interface::transmit_register_setup(uint8_t data_byte) /* get a bit from the transmit register */ -uint8_t device_serial_interface::transmit_register_get_data_bit() +u8 device_serial_interface::transmit_register_get_data_bit() { int bit; diff --git a/src/emu/diserial.h b/src/emu/diserial.h index 4555c5a05b9..27c4cb00d74 100644 --- a/src/emu/diserial.h +++ b/src/emu/diserial.h @@ -92,20 +92,20 @@ protected: void set_rcv_rate(const attotime &rate); void set_tra_rate(const attotime &rate); - void set_rcv_rate(uint32_t clock, int div) { set_rcv_rate((clock && div) ? (attotime::from_hz(clock) * div) : attotime::never); } - void set_tra_rate(uint32_t clock, int div) { set_tra_rate((clock && div) ? (attotime::from_hz(clock) * div) : attotime::never); } + void set_rcv_rate(u32 clock, int div) { set_rcv_rate((clock && div) ? (attotime::from_hz(clock) * div) : attotime::never); } + void set_tra_rate(u32 clock, int div) { set_tra_rate((clock && div) ? (attotime::from_hz(clock) * div) : attotime::never); } void set_rcv_rate(int baud) { set_rcv_rate(baud ? attotime::from_hz(baud) : attotime::never); } void set_tra_rate(int baud) { set_tra_rate(baud ? attotime::from_hz(baud) : attotime::never); } void set_rate(const attotime &rate) { set_rcv_rate(rate); set_tra_rate(rate); } - void set_rate(uint32_t clock, int div) { set_rcv_rate(clock, div); set_tra_rate(clock, div); } + void set_rate(u32 clock, int div) { set_rcv_rate(clock, div); set_tra_rate(clock, div); } void set_rate(int baud) { set_rcv_rate(baud); set_tra_rate(baud); } void transmit_register_reset(); void transmit_register_add_bit(int bit); - void transmit_register_setup(uint8_t data_byte); - uint8_t transmit_register_get_data_bit(); + void transmit_register_setup(u8 data_byte); + u8 transmit_register_get_data_bit(); - uint8_t serial_helper_get_parity(uint8_t data) { return m_serial_parity_table[data]; } + u8 serial_helper_get_parity(u8 data) { return m_serial_parity_table[data]; } bool is_receive_register_full(); bool is_transmit_register_empty(); @@ -114,7 +114,7 @@ protected: bool is_receive_framing_error() const { return m_rcv_framing_error; } bool is_receive_parity_error() const { return m_rcv_parity_error; } - uint8_t get_received_char() const { return m_rcv_byte_received; } + u8 get_received_char() const { return m_rcv_byte_received; } virtual void tra_callback() { } virtual void rcv_callback() { receive_register_update_bit(m_rcv_line); } @@ -137,48 +137,48 @@ protected: private: enum { TRA_TIMER_ID = 10000, RCV_TIMER_ID }; - uint8_t m_serial_parity_table[256]; + u8 m_serial_parity_table[256]; // Data frame // number of start bits int m_df_start_bit_count; // length of word in bits - uint8_t m_df_word_length; + u8 m_df_word_length; // parity state - uint8_t m_df_parity; + u8 m_df_parity; // number of stop bits - uint8_t m_df_stop_bit_count; + u8 m_df_stop_bit_count; // Receive register /* data */ - uint16_t m_rcv_register_data; + u16 m_rcv_register_data; /* flags */ - uint8_t m_rcv_flags; + u8 m_rcv_flags; /* bit count received */ - uint8_t m_rcv_bit_count_received; + u8 m_rcv_bit_count_received; /* length of data to receive - includes data bits, parity bit and stop bit */ - uint8_t m_rcv_bit_count; + u8 m_rcv_bit_count; /* the byte of data received */ - uint8_t m_rcv_byte_received; + u8 m_rcv_byte_received; bool m_rcv_framing_error; bool m_rcv_parity_error; // Transmit register /* data */ - uint16_t m_tra_register_data; + u16 m_tra_register_data; /* flags */ - uint8_t m_tra_flags; + u8 m_tra_flags; /* number of bits transmitted */ - uint8_t m_tra_bit_count_transmitted; + u8 m_tra_bit_count_transmitted; /* length of data to send */ - uint8_t m_tra_bit_count; + u8 m_tra_bit_count; emu_timer *m_rcv_clock; emu_timer *m_tra_clock; attotime m_rcv_rate; attotime m_tra_rate; - uint8_t m_rcv_line; + u8 m_rcv_line; int m_tra_clock_state, m_rcv_clock_state; @@ -187,7 +187,7 @@ private: }; -template +template class device_buffered_serial_interface : public device_serial_interface { protected: @@ -219,7 +219,7 @@ protected: m_empty = 1U; } - void transmit_byte(uint8_t byte) + void transmit_byte(u8 byte) { assert(!m_empty || (m_head == m_tail)); assert(m_head < ARRAY_LENGTH(m_fifo)); @@ -260,11 +260,11 @@ protected: } private: - virtual void received_byte(uint8_t byte) = 0; + virtual void received_byte(u8 byte) = 0; - uint8_t m_fifo[FIFO_LENGTH]; - uint32_t m_head = 0U, m_tail = 0U; - uint8_t m_empty = 1U; + u8 m_fifo[FIFO_LENGTH]; + u32 m_head = 0U, m_tail = 0U; + u8 m_empty = 1U; }; #endif // MAME_EMU_DISERIAL_H diff --git a/src/emu/dislot.h b/src/emu/dislot.h index f7b404a635d..967442631de 100644 --- a/src/emu/dislot.h +++ b/src/emu/dislot.h @@ -6,8 +6,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DISLOT_H__ -#define __DISLOT_H__ +#ifndef MAME_EMU_DISLOT_H +#define MAME_EMU_DISLOT_H //************************************************************************** // LEGACY MACROS @@ -77,7 +77,7 @@ public: const char *default_bios() const { return m_default_bios; } machine_config_constructor machine_config() const { return m_machine_config; } const input_device_default *input_device_defaults() const { return m_input_device_defaults; } - uint32_t clock() const { return m_clock; } + u32 clock() const { return m_clock; } private: // internal state @@ -87,7 +87,7 @@ private: const char *m_default_bios; machine_config_constructor m_machine_config; const input_device_default *m_input_device_defaults; - uint32_t m_clock; + u32 m_clock; }; @@ -108,7 +108,7 @@ public: static void static_set_option_default_bios(device_t &device, const char *option, const char *default_bios) { static_option(device, option)->m_default_bios = default_bios; } static void static_set_option_machine_config(device_t &device, const char *option, const machine_config_constructor machine_config) { static_option(device, option)->m_machine_config = machine_config; } static void static_set_option_device_input_defaults(device_t &device, const char *option, const input_device_default *default_input) { static_option(device, option)->m_input_device_defaults = default_input; } - static void static_set_option_clock(device_t &device, const char *option, uint32_t default_clock) { static_option(device, option)->m_clock = default_clock; } + static void static_set_option_clock(device_t &device, const char *option, u32 default_clock) { static_option(device, option)->m_clock = default_clock; } bool fixed() const { return m_fixed; } const char *default_option() const { return m_default_option; } const std::unordered_map> &option_list() const { return m_options; } @@ -137,4 +137,4 @@ public: virtual ~device_slot_card_interface(); }; -#endif /* __DISLOT_H__ */ +#endif /* MAME_EMU_DISLOT_H */ diff --git a/src/emu/disound.cpp b/src/emu/disound.cpp index 1450d1a56c4..2cf4748530f 100644 --- a/src/emu/disound.cpp +++ b/src/emu/disound.cpp @@ -42,7 +42,7 @@ device_sound_interface::~device_sound_interface() // a new route to the device //------------------------------------------------- -void device_sound_interface::static_add_route(device_t &device, uint32_t output, const char *target, double gain, uint32_t input, uint32_t mixoutput) +void device_sound_interface::static_add_route(device_t &device, u32 output, const char *target, double gain, u32 input, u32 mixoutput) { // find our sound interface device_sound_interface *sound; @@ -357,7 +357,7 @@ void device_sound_interface::interface_pre_reset() // sound_route - constructor //------------------------------------------------- -device_sound_interface::sound_route::sound_route(int output, int input, float gain, const char *target, uint32_t mixoutput) +device_sound_interface::sound_route::sound_route(int output, int input, float gain, const char *target, u32 mixoutput) : m_output(output), m_input(input), m_mixoutput(mixoutput), @@ -461,7 +461,7 @@ void device_mixer_interface::sound_stream_update(sound_stream &stream, stream_sa memset(outputs[output], 0, samples * sizeof(outputs[0][0])); // loop over samples - const uint8_t *outmap = &m_outputmap[0]; + const u8 *outmap = &m_outputmap[0]; for (int pos = 0; pos < samples; pos++) { // for each input, add it to the appropriate output diff --git a/src/emu/disound.h b/src/emu/disound.h index a47ce6ba919..d5684fed1c5 100644 --- a/src/emu/disound.h +++ b/src/emu/disound.h @@ -14,16 +14,16 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DISOUND_H__ -#define __DISOUND_H__ +#ifndef MAME_EMU_DISOUND_H +#define MAME_EMU_DISOUND_H //************************************************************************** // CONSTANTS //************************************************************************** -const int ALL_OUTPUTS = 65535; // special value indicating all outputs for the current chip -const int AUTO_ALLOC_INPUT = 65535; +constexpr int ALL_OUTPUTS = 65535; // special value indicating all outputs for the current chip +constexpr int AUTO_ALLOC_INPUT = 65535; @@ -68,13 +68,13 @@ public: class sound_route { public: - sound_route(int output, int input, float gain, const char *target, uint32_t mixoutput); + sound_route(int output, int input, float gain, const char *target, u32 mixoutput); - uint32_t m_output; // output index, or ALL_OUTPUTS - uint32_t m_input; // target input index - uint32_t m_mixoutput; // target mixer output - float m_gain; // gain - std::string m_target; // target tag + u32 m_output; // output index, or ALL_OUTPUTS + u32 m_input; // target input index + u32 m_mixoutput; // target mixer output + float m_gain; // gain + std::string m_target; // target tag }; // construction/destruction @@ -87,7 +87,7 @@ public: const std::vector> &routes() const { return m_route_list; } // static inline configuration helpers - static void static_add_route(device_t &device, uint32_t output, const char *target, double gain, uint32_t input = AUTO_ALLOC_INPUT, uint32_t mixoutput = 0); + static void static_add_route(device_t &device, u32 output, const char *target, double gain, u32 input = AUTO_ALLOC_INPUT, u32 mixoutput = 0); static void static_reset_routes(device_t &device); // sound stream update overrides @@ -141,8 +141,8 @@ protected: virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; // internal state - uint8_t m_outputs; // number of outputs - std::vector m_outputmap; // map of inputs to outputs + u8 m_outputs; // number of outputs + std::vector m_outputmap; // map of inputs to outputs sound_stream * m_mixer_stream; // mixing stream }; @@ -150,4 +150,4 @@ protected: typedef device_interface_iterator mixer_interface_iterator; -#endif /* __DISOUND_H__ */ +#endif /* MAME_EMU_DISOUND_H */ diff --git a/src/emu/dispatch.cpp b/src/emu/dispatch.cpp index 61a786e5cb6..b82fb85daf8 100644 --- a/src/emu/dispatch.cpp +++ b/src/emu/dispatch.cpp @@ -9,31 +9,31 @@ const device_type DEVCB_LINE_DISPATCH_4 = &device_creator >; const device_type DEVCB_LINE_DISPATCH_6 = &device_creator >; -template<> devcb_line_dispatch_device<2>::devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : +template<> devcb_line_dispatch_device<2>::devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, DEVCB_LINE_DISPATCH_2, "Line dispatcher (2 slots)", tag, owner, clock, "devcb_line_dispatch", __FILE__) { init_fwd(); } -template<> devcb_line_dispatch_device<3>::devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : +template<> devcb_line_dispatch_device<3>::devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, DEVCB_LINE_DISPATCH_3, "Line dispatcher (3 slots)", tag, owner, clock, "devcb_line_dispatch", __FILE__) { init_fwd(); } -template<> devcb_line_dispatch_device<4>::devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : +template<> devcb_line_dispatch_device<4>::devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, DEVCB_LINE_DISPATCH_4, "Line dispatcher (4 slots)", tag, owner, clock, "devcb_line_dispatch", __FILE__) { init_fwd(); } -template<> devcb_line_dispatch_device<5>::devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : +template<> devcb_line_dispatch_device<5>::devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, DEVCB_LINE_DISPATCH_5, "Line dispatcher (5 slots)", tag, owner, clock, "devcb_line_dispatch", __FILE__) { init_fwd(); } -template<> devcb_line_dispatch_device<6>::devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : +template<> devcb_line_dispatch_device<6>::devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, DEVCB_LINE_DISPATCH_6, "Line dispatcher (6 slots)", tag, owner, clock, "devcb_line_dispatch", __FILE__) { init_fwd(); diff --git a/src/emu/dispatch.h b/src/emu/dispatch.h index e6409373295..26be42e345e 100644 --- a/src/emu/dispatch.h +++ b/src/emu/dispatch.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DISPATCH_H__ -#define __DISPATCH_H__ +#ifndef MAME_EMU_DISPATCH_H +#define MAME_EMU_DISPATCH_H #define MCFG_LINE_DISPATCH_ADD(_tag, _count) \ MCFG_DEVICE_ADD(_tag, DEVCB_LINE_DISPATCH_ ## _count, 0) @@ -31,7 +31,7 @@ extern const device_type DEVCB_LINE_DISPATCH_6; template class devcb_line_dispatch_device : public device_t { public: - devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + devcb_line_dispatch_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, DEVCB_LINE_DISPATCH_2, "DEVCB_LINE_DISPATCH_2", tag, owner, clock, "devcb_line_dispatch_2", __FILE__) { } void init_fwd() { @@ -61,4 +61,4 @@ private: devcb_write_line *fwd_cb[N]; }; -#endif +#endif // MAME_EMU_DISPATCH_H diff --git a/src/emu/distate.cpp b/src/emu/distate.cpp index 29730ec427b..2a1ed9b9ea9 100644 --- a/src/emu/distate.cpp +++ b/src/emu/distate.cpp @@ -15,28 +15,28 @@ // GLOBAL VARIABLES //************************************************************************** -const uint64_t device_state_entry::k_decimal_divisor[] = +const u64 device_state_entry::k_decimal_divisor[] = { - 1, - 10, - 100, - 1000, - 10000, - 100000, - 1000000, - 10000000, - 100000000, - 1000000000, - U64(10000000000), - U64(100000000000), - U64(1000000000000), - U64(10000000000000), - U64(100000000000000), - U64(1000000000000000), - U64(10000000000000000), - U64(100000000000000000), - U64(1000000000000000000), - U64(10000000000000000000) + 1U, + 10U, + 100U, + 1000U, + 10000U, + 100000U, + 1000000U, + 10000000U, + 100000000U, + 1000000000U, + 10000000000U, + 100000000000U, + 1000000000000U, + 10000000000000U, + 100000000000000U, + 1000000000000000U, + 10000000000000000U, + 100000000000000000U, + 1000000000000000000U, + 10000000000000000000U }; @@ -49,7 +49,7 @@ const uint64_t device_state_entry::k_decimal_divisor[] = // device_state_entry - constructor //------------------------------------------------- -device_state_entry::device_state_entry(int index, const char *symbol, void *dataptr, uint8_t size, device_state_interface *dev) +device_state_entry::device_state_entry(int index, const char *symbol, void *dataptr, u8 size, device_state_interface *dev) : m_device_state(dev), m_index(index), m_dataptr(dataptr), @@ -69,7 +69,7 @@ device_state_entry::device_state_entry(int index, const char *symbol, void *data else if (size == 4) m_sizemask = 0xffffffff; else - m_sizemask = ~U64(0); + m_sizemask = ~u64(0); // default the data mask to the same m_datamask = m_sizemask; @@ -128,27 +128,27 @@ void device_state_entry::format_from_mask() // make up a format based on the mask int width = 0; - for (uint64_t tempmask = m_datamask; tempmask != 0; tempmask >>= 4) + for (u64 tempmask = m_datamask; tempmask != 0; tempmask >>= 4) width++; m_format = string_format("%%0%dX", width); } //------------------------------------------------- -// value - return the current value as a uint64_t +// value - return the current value as a u64 //------------------------------------------------- -uint64_t device_state_entry::value() const +u64 device_state_entry::value() const { // pick up the value - uint64_t result; + u64 result; switch (m_datasize) { default: - case 1: result = *m_dataptr.u8; break; - case 2: result = *m_dataptr.u16; break; - case 4: result = *m_dataptr.u32; break; - case 8: result = *m_dataptr.u64; break; + case 1: result = *static_cast(m_dataptr); break; + case 2: result = *static_cast(m_dataptr); break; + case 4: result = *static_cast(m_dataptr); break; + case 8: result = *static_cast(m_dataptr); break; } return result & m_datamask; } @@ -162,7 +162,7 @@ uint64_t device_state_entry::value() const std::string device_state_entry::format(const char *string, bool maxout) const { std::string dest; - uint64_t result = value(); + u64 result = value(); // parse the format bool leadzero = false; @@ -344,10 +344,10 @@ std::string device_state_entry::format(const char *string, bool maxout) const //------------------------------------------------- -// set_value - set the value from a uint64_t +// set_value - set the value from a u64 //------------------------------------------------- -void device_state_entry::set_value(uint64_t value) const +void device_state_entry::set_value(u64 value) const { // apply the mask value &= m_datamask; @@ -360,10 +360,10 @@ void device_state_entry::set_value(uint64_t value) const switch (m_datasize) { default: - case 1: *m_dataptr.u8 = value; break; - case 2: *m_dataptr.u16 = value; break; - case 4: *m_dataptr.u32 = value; break; - case 8: *m_dataptr.u64 = value; break; + case 1: *static_cast(m_dataptr) = value; break; + case 2: *static_cast(m_dataptr) = value; break; + case 4: *static_cast(m_dataptr) = value; break; + case 8: *static_cast(m_dataptr) = value; break; } } @@ -408,10 +408,10 @@ device_state_interface::~device_state_interface() //------------------------------------------------- // state_int - return the value of the given piece -// of indexed state as a uint64_t +// of indexed state as a u64 //------------------------------------------------- -uint64_t device_state_interface::state_int(int index) +u64 device_state_interface::state_int(int index) { // nullptr or out-of-range entry returns 0 const device_state_entry *entry = state_find_entry(index); @@ -468,10 +468,10 @@ int device_state_interface::state_string_max_length(int index) //------------------------------------------------- // set_state_int - set the value of the given -// piece of indexed state from a uint64_t +// piece of indexed state from a u64 //------------------------------------------------- -void device_state_interface::set_state_int(int index, uint64_t value) +void device_state_interface::set_state_int(int index, u64 value) { // nullptr or out-of-range entry is a no-op const device_state_entry *entry = state_find_entry(index); @@ -510,10 +510,10 @@ void device_state_interface::set_state_string(int index, const char *string) //------------------------------------------------- // state_add - return the value of the given -// pieces of indexed state as a uint64_t +// pieces of indexed state as a u64 //------------------------------------------------- -device_state_entry &device_state_interface::state_add(int index, const char *symbol, void *data, uint8_t size) +device_state_entry &device_state_interface::state_add(int index, const char *symbol, void *data, u8 size) { // assert validity of incoming parameters assert(size == 1 || size == 2 || size == 4 || size == 8); diff --git a/src/emu/distate.h b/src/emu/distate.h index 67c706b390a..e10cdd1c16a 100644 --- a/src/emu/distate.h +++ b/src/emu/distate.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DISTATE_H__ -#define __DISTATE_H__ +#ifndef MAME_EMU_DISTATE_H +#define MAME_EMU_DISTATE_H //************************************************************************** @@ -46,13 +46,13 @@ class device_state_entry friend class device_state_interface; public: // construction/destruction - device_state_entry(int index, const char *symbol, void *dataptr, uint8_t size, device_state_interface *dev); + device_state_entry(int index, const char *symbol, void *dataptr, u8 size, device_state_interface *dev); device_state_entry(int index, device_state_interface *dev); public: // post-construction modifiers - device_state_entry &mask(uint64_t _mask) { m_datamask = _mask; format_from_mask(); return *this; } - device_state_entry &signed_mask(uint64_t _mask) { m_datamask = _mask; m_flags |= DSF_IMPORT_SEXT; format_from_mask(); return *this; } + device_state_entry &mask(u64 _mask) { m_datamask = _mask; format_from_mask(); return *this; } + device_state_entry &signed_mask(u64 _mask) { m_datamask = _mask; m_flags |= DSF_IMPORT_SEXT; format_from_mask(); return *this; } device_state_entry &formatstr(const char *_format); device_state_entry &callimport() { m_flags |= DSF_IMPORT; return *this; } device_state_entry &callexport() { m_flags |= DSF_EXPORT; return *this; } @@ -60,7 +60,7 @@ public: // query information int index() const { return m_index; } - void *dataptr() const { return m_dataptr.v; } + void *dataptr() const { return m_dataptr; } const char *symbol() const { return m_symbol.c_str(); } bool visible() const { return ((m_flags & DSF_NOSHOW) == 0); } bool divider() const { return m_flags & DSF_DIVIDER; } @@ -68,12 +68,12 @@ public: protected: // device state flags - static const uint8_t DSF_NOSHOW = 0x01; // don't display this entry in the registers view - static const uint8_t DSF_IMPORT = 0x02; // call the import function after writing new data - static const uint8_t DSF_IMPORT_SEXT = 0x04; // sign-extend the data when writing new data - static const uint8_t DSF_EXPORT = 0x08; // call the export function prior to fetching the data - static const uint8_t DSF_CUSTOM_STRING = 0x10; // set if the format has a custom string - static const uint8_t DSF_DIVIDER = 0x20; // set if this is a divider entry + static constexpr u8 DSF_NOSHOW = 0x01; // don't display this entry in the registers view + static constexpr u8 DSF_IMPORT = 0x02; // call the import function after writing new data + static constexpr u8 DSF_IMPORT_SEXT = 0x04; // sign-extend the data when writing new data + static constexpr u8 DSF_EXPORT = 0x08; // call the export function prior to fetching the data + static constexpr u8 DSF_CUSTOM_STRING = 0x10; // set if the format has a custom string + static constexpr u8 DSF_DIVIDER = 0x20; // set if this is a divider entry // helpers bool needs_custom_string() const { return ((m_flags & DSF_CUSTOM_STRING) != 0); } @@ -81,28 +81,28 @@ protected: // return the current value -- only for our friends who handle export bool needs_export() const { return ((m_flags & DSF_EXPORT) != 0); } - uint64_t value() const; + u64 value() const; std::string format(const char *string, bool maxout = false) const; // set the current value -- only for our friends who handle import bool needs_import() const { return ((m_flags & DSF_IMPORT) != 0); } - void set_value(uint64_t value) const; + void set_value(u64 value) const; void set_value(const char *string) const; // statics - static const uint64_t k_decimal_divisor[20]; // divisors for outputting decimal values + static const u64 k_decimal_divisor[20]; // divisors for outputting decimal values // public state description device_state_interface *m_device_state; // link to parent device state - uint32_t m_index; // index by which this item is referred - generic_ptr m_dataptr; // pointer to where the data lives - uint64_t m_datamask; // mask that applies to the data - uint8_t m_datasize; // size of the data - uint8_t m_flags; // flags for this data + u32 m_index; // index by which this item is referred + void * m_dataptr; // pointer to where the data lives + u64 m_datamask; // mask that applies to the data + u8 m_datasize; // size of the data + u8 m_flags; // flags for this data std::string m_symbol; // symbol for display; all lower-case version for expressions std::string m_format; // supported formats bool m_default_format; // true if we are still using default format - uint64_t m_sizemask; // mask derived from the data size + u64 m_sizemask; // mask derived from the data size }; @@ -121,16 +121,16 @@ public: const std::vector> &state_entries() const { return m_state_list; } // state getters - uint64_t state_int(int index); + u64 state_int(int index); std::string state_string(int index) const; int state_string_max_length(int index); offs_t pc() { return state_int(STATE_GENPC); } offs_t pcbase() { return state_int(STATE_GENPCBASE); } offs_t sp() { return state_int(STATE_GENSP); } - uint64_t flags() { return state_int(STATE_GENFLAGS); } + u64 flags() { return state_int(STATE_GENFLAGS); } // state setters - void set_state_int(int index, uint64_t value); + void set_state_int(int index, u64 value); void set_state_string(int index, const char *string); void set_pc(offs_t pc) { set_state_int(STATE_GENPC, pc); } @@ -147,7 +147,7 @@ public: // protected eventually { return state_add(index, symbol, &data, sizeof(data)); } - device_state_entry &state_add(int index, const char *symbol, void *data, uint8_t size); + device_state_entry &state_add(int index, const char *symbol, void *data, u8 size); // add a new divider entry device_state_entry &state_add_divider(int index); @@ -166,8 +166,8 @@ protected: const device_state_entry *state_find_entry(int index) const; // constants - static const int FAST_STATE_MIN = -4; // range for fast state - static const int FAST_STATE_MAX = 256; // lookups + static constexpr int FAST_STATE_MIN = -4; // range for fast state + static constexpr int FAST_STATE_MAX = 256; // lookups // state std::vector> m_state_list; // head of state list @@ -206,4 +206,4 @@ inline offs_t device_t::safe_pcbase() const } -#endif /* __DISTATE_H__ */ +#endif /* MAME_EMU_DISTATE_H */ diff --git a/src/emu/divideo.h b/src/emu/divideo.h index e50a1b5df08..8c449b9bddc 100644 --- a/src/emu/divideo.h +++ b/src/emu/divideo.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DIVIDEO_H__ -#define __DIVIDEO_H__ +#ifndef MAME_EMU_DIVIDEO_H +#define MAME_EMU_DIVIDEO_H //************************************************************************** @@ -65,4 +65,4 @@ protected: typedef device_interface_iterator video_interface_iterator; -#endif /* __DIVIDEO_H__ */ +#endif /* MAME_EMU_DIVIDEO_H */ diff --git a/src/emu/divtlb.cpp b/src/emu/divtlb.cpp index 2a3cad48bf3..b629ec81007 100644 --- a/src/emu/divtlb.cpp +++ b/src/emu/divtlb.cpp @@ -250,7 +250,7 @@ void device_vtlb_interface::vtlb_load(int entrynum, int numpages, offs_t address // vtlb_dynload - load a dynamic VTLB entry //------------------------------------------------- -void device_vtlb_interface::vtlb_dynload(uint32_t index, offs_t address, vtlb_entry value) +void device_vtlb_interface::vtlb_dynload(u32 index, offs_t address, vtlb_entry value) { vtlb_entry entry = m_table[index]; diff --git a/src/emu/divtlb.h b/src/emu/divtlb.h index 46746f91d60..d8614e593db 100644 --- a/src/emu/divtlb.h +++ b/src/emu/divtlb.h @@ -10,8 +10,8 @@ #pragma once -#ifndef __DIVTLB_H__ -#define __DIVTLB_H__ +#ifndef MAME_EMU_DIVTLB_H +#define MAME_EMU_DIVTLB_H @@ -19,16 +19,16 @@ CONSTANTS ***************************************************************************/ -#define VTLB_FLAGS_MASK 0xff +constexpr u32 VTLB_FLAGS_MASK = 0xff; -#define VTLB_READ_ALLOWED 0x01 /* (1 << TRANSLATE_READ) */ -#define VTLB_WRITE_ALLOWED 0x02 /* (1 << TRANSLATE_WRITE) */ -#define VTLB_FETCH_ALLOWED 0x04 /* (1 << TRANSLATE_FETCH) */ -#define VTLB_FLAG_VALID 0x08 -#define VTLB_USER_READ_ALLOWED 0x10 /* (1 << TRANSLATE_READ_USER) */ -#define VTLB_USER_WRITE_ALLOWED 0x20 /* (1 << TRANSLATE_WRITE_USER) */ -#define VTLB_USER_FETCH_ALLOWED 0x40 /* (1 << TRANSLATE_FETCH_USER) */ -#define VTLB_FLAG_FIXED 0x80 +constexpr u32 VTLB_READ_ALLOWED = 0x01; /* (1 << TRANSLATE_READ) */ +constexpr u32 VTLB_WRITE_ALLOWED = 0x02; /* (1 << TRANSLATE_WRITE) */ +constexpr u32 VTLB_FETCH_ALLOWED = 0x04; /* (1 << TRANSLATE_FETCH) */ +constexpr u32 VTLB_FLAG_VALID = 0x08; +constexpr u32 VTLB_USER_READ_ALLOWED = 0x10; /* (1 << TRANSLATE_READ_USER) */ +constexpr u32 VTLB_USER_WRITE_ALLOWED = 0x20; /* (1 << TRANSLATE_WRITE_USER) */ +constexpr u32 VTLB_USER_FETCH_ALLOWED = 0x40; /* (1 << TRANSLATE_FETCH_USER) */ +constexpr u32 VTLB_FLAG_FIXED = 0x80; @@ -37,7 +37,7 @@ ***************************************************************************/ /* represents an entry in the VTLB */ -typedef uint32_t vtlb_entry; +typedef u32 vtlb_entry; // ======================> device_vtlb_interface @@ -56,7 +56,7 @@ public: // filling bool vtlb_fill(offs_t address, int intention); void vtlb_load(int entrynum, int numpages, offs_t address, vtlb_entry value); - void vtlb_dynload(uint32_t index, offs_t address, vtlb_entry value); + void vtlb_dynload(u32 index, offs_t address, vtlb_entry value); // flushing void vtlb_flush_dynamic(); @@ -81,10 +81,10 @@ private: int m_pageshift; // bits to shift to get page index int m_addrwidth; // logical address bus width std::vector m_live; // array of live entries by table index - std::vector m_fixedpages; // number of pages each fixed entry covers + std::vector m_fixedpages; // number of pages each fixed entry covers std::vector m_table; // table of entries by address vtlb_entry *m_table_base; // pointer to m_table[0] }; -#endif /* __VTLB_H__ */ +#endif /* MAME_EMU_DIVTLB_H */ diff --git a/src/emu/drawgfx.cpp b/src/emu/drawgfx.cpp index bca40bb769b..b22576c59da 100644 --- a/src/emu/drawgfx.cpp +++ b/src/emu/drawgfx.cpp @@ -16,7 +16,7 @@ ***************************************************************************/ // if this line errors during compile, the size of NO_PRIORITY is wrong and I need to use something else -uint8_t no_priority_size_is_wrong[2 * (sizeof(NO_PRIORITY) == 3) - 1]; +u8 no_priority_size_is_wrong[2 * (sizeof(NO_PRIORITY) == 3) - 1]; bitmap_ind8 drawgfx_dummy_priority_bitmap; @@ -31,7 +31,7 @@ bitmap_ind8 drawgfx_dummy_priority_bitmap; offset -------------------------------------------------*/ -static inline int readbit(const uint8_t *src, unsigned int bitnum) +static inline int readbit(const u8 *src, unsigned int bitnum) { return src[bitnum / 8] & (0x80 >> (bitnum % 8)); } @@ -43,7 +43,7 @@ static inline int readbit(const uint8_t *src, unsigned int bitnum) than the width -------------------------------------------------*/ -static inline int32_t normalize_xscroll(const bitmap_t &bitmap, int32_t xscroll) +static inline s32 normalize_xscroll(const bitmap_t &bitmap, s32 xscroll) { return (xscroll >= 0) ? xscroll % bitmap.width() : (bitmap.width() - (-xscroll) % bitmap.width()); } @@ -55,7 +55,7 @@ static inline int32_t normalize_xscroll(const bitmap_t &bitmap, int32_t xscroll) than the height -------------------------------------------------*/ -static inline int32_t normalize_yscroll(const bitmap_t &bitmap, int32_t yscroll) +static inline s32 normalize_yscroll(const bitmap_t &bitmap, s32 yscroll) { return (yscroll >= 0) ? yscroll % bitmap.height() : (bitmap.height() - (-yscroll) % bitmap.height()); } @@ -68,7 +68,7 @@ static inline int32_t normalize_yscroll(const bitmap_t &bitmap, int32_t yscroll) const device_type GFXDECODE = &device_creator; -gfxdecode_device::gfxdecode_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : +gfxdecode_device::gfxdecode_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, GFXDECODE, "gfxdecode", tag, owner, clock, "gfxdecode", __FILE__), device_gfx_interface(mconfig, *this) { @@ -86,7 +86,7 @@ gfxdecode_device::gfxdecode_device(const machine_config &mconfig, const char *ta // gfx_element - constructor //------------------------------------------------- -gfx_element::gfx_element(palette_device &palette, uint8_t *base, uint16_t width, uint16_t height, uint32_t rowbytes, uint32_t total_colors, uint32_t color_base, uint32_t color_granularity) +gfx_element::gfx_element(palette_device &palette, u8 *base, u16 width, u16 height, u32 rowbytes, u32 total_colors, u32 color_base, u32 color_granularity) : m_palette(&palette), m_width(width), m_height(height), @@ -111,7 +111,7 @@ gfx_element::gfx_element(palette_device &palette, uint8_t *base, uint16_t width, { } -gfx_element::gfx_element(palette_device &palette, const gfx_layout &gl, const uint8_t *srcdata, uint32_t xormask, uint32_t total_colors, uint32_t color_base) +gfx_element::gfx_element(palette_device &palette, const gfx_layout &gl, const u8 *srcdata, u32 xormask, u32 total_colors, u32 color_base) : m_palette(&palette), m_width(0), m_height(0), @@ -143,7 +143,7 @@ gfx_element::gfx_element(palette_device &palette, const gfx_layout &gl, const ui // set_layout - set the layout for a gfx_element //------------------------------------------------- -void gfx_element::set_layout(const gfx_layout &gl, const uint8_t *srcdata) +void gfx_element::set_layout(const gfx_layout &gl, const u8 *srcdata) { m_srcdata = srcdata; @@ -174,7 +174,7 @@ void gfx_element::set_layout(const gfx_layout &gl, const uint8_t *srcdata) // RAW graphics must have a pointer up front assert(srcdata != nullptr); - m_gfxdata = const_cast(srcdata); + m_gfxdata = const_cast(srcdata); } // decoded graphics case @@ -217,7 +217,7 @@ void gfx_element::set_layout(const gfx_layout &gl, const uint8_t *srcdata) // set_raw_layout - set the layout for a gfx_element //------------------------------------------------- -void gfx_element::set_raw_layout(const uint8_t *srcdata, uint32_t width, uint32_t height, uint32_t total, uint32_t linemod, uint32_t charmod) +void gfx_element::set_raw_layout(const u8 *srcdata, u32 width, u32 height, u32 total, u32 linemod, u32 charmod) { gfx_layout layout = { 0 }; layout.width = width; @@ -235,11 +235,11 @@ void gfx_element::set_raw_layout(const uint8_t *srcdata, uint32_t width, uint32_ // set_source - set the source data for a gfx_element //------------------------------------------------- -void gfx_element::set_source(const uint8_t *source) +void gfx_element::set_source(const u8 *source) { m_srcdata = source; memset(&m_dirty[0], 1, elements()); - if (m_layout_is_raw) m_gfxdata = const_cast(source); + if (m_layout_is_raw) m_gfxdata = const_cast(source); } @@ -248,7 +248,7 @@ void gfx_element::set_source(const uint8_t *source) // and total elements for a gfx_element //------------------------------------------------- -void gfx_element::set_source_and_total(const uint8_t *source, uint32_t total) +void gfx_element::set_source_and_total(const u8 *source, u32 total) { m_srcdata = source; m_total_elements = total; @@ -263,7 +263,7 @@ void gfx_element::set_source_and_total(const uint8_t *source, uint32_t total) if (m_layout_is_raw) { - m_gfxdata = const_cast(source); + m_gfxdata = const_cast(source); } else { @@ -278,7 +278,7 @@ void gfx_element::set_source_and_total(const uint8_t *source, uint32_t total) // set_source_clip - set a source clipping rect //------------------------------------------------- -void gfx_element::set_source_clip(uint32_t xoffs, uint32_t width, uint32_t yoffs, uint32_t height) +void gfx_element::set_source_clip(u32 xoffs, u32 width, u32 yoffs, u32 height) { assert(xoffs < m_origwidth); assert(yoffs < m_origheight); @@ -296,13 +296,13 @@ void gfx_element::set_source_clip(uint32_t xoffs, uint32_t width, uint32_t yoffs // decode - decode a single character //------------------------------------------------- -void gfx_element::decode(uint32_t code) +void gfx_element::decode(u32 code) { // don't decode GFX_RAW if (!m_layout_is_raw) { // zap the data to 0 - uint8_t *decode_base = m_gfxdata + code * m_char_modulo; + u8 *decode_base = m_gfxdata + code * m_char_modulo; memset(decode_base, 0, m_char_modulo); // iterate over planes @@ -317,7 +317,7 @@ void gfx_element::decode(uint32_t code) for (int y = 0; y < m_origheight; y++) { int yoffs = planeoffs + m_layout_yoffset[y]; - uint8_t *dp = decode_base + y * m_line_modulo; + u8 *dp = decode_base + y * m_line_modulo; // iterate over columns for (int x = 0; x < m_origwidth; x++) @@ -331,8 +331,8 @@ void gfx_element::decode(uint32_t code) if (code < m_pen_usage.size()) { // iterate over data, creating a bitmask of live pens - const uint8_t *dp = m_gfxdata + code * m_char_modulo; - uint32_t usage = 0; + const u8 *dp = m_gfxdata + code * m_char_modulo; + u32 usage = 0; for (int y = 0; y < m_origheight; y++) { for (int x = 0; x < m_origwidth; x++) @@ -360,21 +360,21 @@ void gfx_element::decode(uint32_t code) -------------------------------------------------*/ void gfx_element::opaque(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty) { color = colorbase() + granularity() * (color % colors()); code %= elements(); DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint16_t, PIXEL_OP_REBASE_OPAQUE, NO_PRIORITY); + DRAWGFX_CORE(u16, PIXEL_OP_REBASE_OPAQUE, NO_PRIORITY); } void gfx_element::opaque(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty) { const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); code %= elements(); DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); } @@ -384,8 +384,8 @@ void gfx_element::opaque(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::transpen(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 trans_pen) { // special case invalid pens to opaque if (trans_pen > 0xff) @@ -396,7 +396,7 @@ void gfx_element::transpen(bitmap_ind16 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~(1 << trans_pen)) == 0) return; @@ -408,12 +408,12 @@ void gfx_element::transpen(bitmap_ind16 &dest, const rectangle &cliprect, // render color = colorbase() + granularity() * (color % colors()); DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint16_t, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); + DRAWGFX_CORE(u16, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); } void gfx_element::transpen(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 trans_pen) { // special case invalid pens to opaque if (trans_pen > 0xff) @@ -424,7 +424,7 @@ void gfx_element::transpen(bitmap_rgb32 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~(1 << trans_pen)) == 0) return; @@ -436,7 +436,7 @@ void gfx_element::transpen(bitmap_rgb32 &dest, const rectangle &cliprect, // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY); } @@ -447,8 +447,8 @@ void gfx_element::transpen(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 trans_pen) { // early out if completely transparent code %= elements(); @@ -457,12 +457,12 @@ void gfx_element::transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, // render DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint16_t, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); + DRAWGFX_CORE(u16, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); } void gfx_element::transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 trans_pen) { // early out if completely transparent code %= elements(); @@ -471,7 +471,7 @@ void gfx_element::transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, // render DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint32_t, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); + DRAWGFX_CORE(u32, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); } @@ -482,8 +482,8 @@ void gfx_element::transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::transmask(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t trans_mask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 trans_mask) { // special case 0 mask to opaque if (trans_mask == 0) @@ -494,7 +494,7 @@ void gfx_element::transmask(bitmap_ind16 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~trans_mask) == 0) return; @@ -506,12 +506,12 @@ void gfx_element::transmask(bitmap_ind16 &dest, const rectangle &cliprect, // render color = colorbase() + granularity() * (color % colors()); DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint16_t, PIXEL_OP_REBASE_TRANSMASK, NO_PRIORITY); + DRAWGFX_CORE(u16, PIXEL_OP_REBASE_TRANSMASK, NO_PRIORITY); } void gfx_element::transmask(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t trans_mask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 trans_mask) { // special case 0 mask to opaque if (trans_mask == 0) @@ -522,7 +522,7 @@ void gfx_element::transmask(bitmap_rgb32 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~trans_mask) == 0) return; @@ -534,7 +534,7 @@ void gfx_element::transmask(bitmap_rgb32 &dest, const rectangle &cliprect, // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY); } @@ -545,8 +545,8 @@ void gfx_element::transmask(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::transtable(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - const uint8_t *pentable) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + const u8 *pentable) { assert(pentable != nullptr); @@ -555,12 +555,12 @@ void gfx_element::transtable(bitmap_ind16 &dest, const rectangle &cliprect, const pen_t *shadowtable = m_palette->shadow_table(); code %= elements(); DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint16_t, PIXEL_OP_REBASE_TRANSTABLE16, NO_PRIORITY); + DRAWGFX_CORE(u16, PIXEL_OP_REBASE_TRANSTABLE16, NO_PRIORITY); } void gfx_element::transtable(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - const uint8_t *pentable) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + const u8 *pentable) { assert(pentable != nullptr); @@ -569,7 +569,7 @@ void gfx_element::transtable(bitmap_rgb32 &dest, const rectangle &cliprect, const pen_t *shadowtable = m_palette->shadow_table(); code %= elements(); DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANSTABLE32, NO_PRIORITY); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANSTABLE32, NO_PRIORITY); } @@ -580,8 +580,8 @@ void gfx_element::transtable(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::alpha(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t trans_pen, uint8_t alpha_val) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 trans_pen, u8 alpha_val) { // special case alpha = 0xff if (alpha_val == 0xff) @@ -595,7 +595,7 @@ void gfx_element::alpha(bitmap_rgb32 &dest, const rectangle &cliprect, // get final code and color, and grab lookup tables const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); DECLARE_NO_PRIORITY; - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANSPEN_ALPHA32, NO_PRIORITY); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32, NO_PRIORITY); } @@ -610,8 +610,8 @@ void gfx_element::alpha(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::zoom_opaque(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -621,12 +621,12 @@ void gfx_element::zoom_opaque(bitmap_ind16 &dest, const rectangle &cliprect, color = colorbase() + granularity() * (color % colors()); code %= elements(); DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint16_t, PIXEL_OP_REBASE_OPAQUE, NO_PRIORITY); + DRAWGFXZOOM_CORE(u16, PIXEL_OP_REBASE_OPAQUE, NO_PRIORITY); } void gfx_element::zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -636,7 +636,7 @@ void gfx_element::zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); code %= elements(); DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); } @@ -646,8 +646,8 @@ void gfx_element::zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::zoom_transpen(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, u32 trans_pen) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -662,7 +662,7 @@ void gfx_element::zoom_transpen(bitmap_ind16 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~(1 << trans_pen)) == 0) return; @@ -674,12 +674,12 @@ void gfx_element::zoom_transpen(bitmap_ind16 &dest, const rectangle &cliprect, // render color = colorbase() + granularity() * (color % colors()); DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint16_t, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); + DRAWGFXZOOM_CORE(u16, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); } void gfx_element::zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, u32 trans_pen) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -694,7 +694,7 @@ void gfx_element::zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~(1 << trans_pen)) == 0) return; @@ -706,7 +706,7 @@ void gfx_element::zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_TRANSPEN, NO_PRIORITY); } @@ -717,8 +717,8 @@ void gfx_element::zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::zoom_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, u32 trans_pen) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -731,12 +731,12 @@ void gfx_element::zoom_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprec // render DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint16_t, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); + DRAWGFXZOOM_CORE(u16, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); } void gfx_element::zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, u32 trans_pen) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -749,7 +749,7 @@ void gfx_element::zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprec // render DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REBASE_TRANSPEN, NO_PRIORITY); } @@ -760,8 +760,8 @@ void gfx_element::zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprec -------------------------------------------------*/ void gfx_element::zoom_transmask(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, uint32_t trans_mask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, u32 trans_mask) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -776,7 +776,7 @@ void gfx_element::zoom_transmask(bitmap_ind16 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~trans_mask) == 0) return; @@ -788,12 +788,12 @@ void gfx_element::zoom_transmask(bitmap_ind16 &dest, const rectangle &cliprect, // render color = colorbase() + granularity() * (color % colors()); DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint16_t, PIXEL_OP_REBASE_TRANSMASK, NO_PRIORITY); + DRAWGFXZOOM_CORE(u16, PIXEL_OP_REBASE_TRANSMASK, NO_PRIORITY); } void gfx_element::zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, uint32_t trans_mask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, u32 trans_mask) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -808,7 +808,7 @@ void gfx_element::zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~trans_mask) == 0) return; @@ -820,7 +820,7 @@ void gfx_element::zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_TRANSMASK, NO_PRIORITY); } @@ -831,8 +831,8 @@ void gfx_element::zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::zoom_transtable(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, const uint8_t *pentable) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, const u8 *pentable) { assert(pentable != nullptr); @@ -845,12 +845,12 @@ void gfx_element::zoom_transtable(bitmap_ind16 &dest, const rectangle &cliprect, const pen_t *shadowtable = m_palette->shadow_table(); code %= elements(); DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint16_t, PIXEL_OP_REBASE_TRANSTABLE16, NO_PRIORITY); + DRAWGFXZOOM_CORE(u16, PIXEL_OP_REBASE_TRANSTABLE16, NO_PRIORITY); } void gfx_element::zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, const uint8_t *pentable) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, const u8 *pentable) { assert(pentable != nullptr); @@ -863,7 +863,7 @@ void gfx_element::zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, const pen_t *shadowtable = m_palette->shadow_table(); code %= elements(); DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_TRANSTABLE32, NO_PRIORITY); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_TRANSTABLE32, NO_PRIORITY); } @@ -874,8 +874,8 @@ void gfx_element::zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, uint32_t trans_pen, uint8_t alpha_val) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, u32 trans_pen, u8 alpha_val) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -893,7 +893,7 @@ void gfx_element::zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); DECLARE_NO_PRIORITY; - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_TRANSPEN_ALPHA32, NO_PRIORITY); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32, NO_PRIORITY); } @@ -909,8 +909,8 @@ void gfx_element::zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::prio_opaque(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask) { // high bit of the mask is implicitly on pmask |= 1 << 31; @@ -918,12 +918,12 @@ void gfx_element::prio_opaque(bitmap_ind16 &dest, const rectangle &cliprect, // render color = colorbase() + granularity() * (color % colors()); code %= elements(); - DRAWGFX_CORE(uint16_t, PIXEL_OP_REBASE_OPAQUE_PRIORITY, uint8_t); + DRAWGFX_CORE(u16, PIXEL_OP_REBASE_OPAQUE_PRIORITY, u8); } void gfx_element::prio_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask) { // high bit of the mask is implicitly on pmask |= 1 << 31; @@ -931,7 +931,7 @@ void gfx_element::prio_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); code %= elements(); - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_OPAQUE_PRIORITY, uint8_t); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_OPAQUE_PRIORITY, u8); } @@ -942,8 +942,8 @@ void gfx_element::prio_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::prio_transpen(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask, uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask, u32 trans_pen) { // special case invalid pens to opaque if (trans_pen > 0xff) @@ -954,7 +954,7 @@ void gfx_element::prio_transpen(bitmap_ind16 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~(1 << trans_pen)) == 0) return; @@ -968,12 +968,12 @@ void gfx_element::prio_transpen(bitmap_ind16 &dest, const rectangle &cliprect, // render color = colorbase() + granularity() * (color % colors()); - DRAWGFX_CORE(uint16_t, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, uint8_t); + DRAWGFX_CORE(u16, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, u8); } void gfx_element::prio_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask, uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask, u32 trans_pen) { // special case invalid pens to opaque if (trans_pen > 0xff) @@ -984,7 +984,7 @@ void gfx_element::prio_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~(1 << trans_pen)) == 0) return; @@ -998,7 +998,7 @@ void gfx_element::prio_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, uint8_t); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, u8); } @@ -1009,8 +1009,8 @@ void gfx_element::prio_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::prio_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask, uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask, u32 trans_pen) { // early out if completely transparent code %= elements(); @@ -1021,12 +1021,12 @@ void gfx_element::prio_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprec pmask |= 1 << 31; // render - DRAWGFX_CORE(uint16_t, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, uint8_t); + DRAWGFX_CORE(u16, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, u8); } void gfx_element::prio_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask, uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask, u32 trans_pen) { // early out if completely transparent code %= elements(); @@ -1037,7 +1037,7 @@ void gfx_element::prio_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprec pmask |= 1 << 31; // render - DRAWGFX_CORE(uint32_t, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, uint8_t); + DRAWGFX_CORE(u32, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, u8); } @@ -1048,8 +1048,8 @@ void gfx_element::prio_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprec -------------------------------------------------*/ void gfx_element::prio_transmask(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask, uint32_t trans_mask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask, u32 trans_mask) { // special case 0 mask to opaque if (trans_mask == 0) @@ -1060,7 +1060,7 @@ void gfx_element::prio_transmask(bitmap_ind16 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~trans_mask) == 0) return; @@ -1074,12 +1074,12 @@ void gfx_element::prio_transmask(bitmap_ind16 &dest, const rectangle &cliprect, // render color = colorbase() + granularity() * (color % colors()); - DRAWGFX_CORE(uint16_t, PIXEL_OP_REBASE_TRANSMASK_PRIORITY, uint8_t); + DRAWGFX_CORE(u16, PIXEL_OP_REBASE_TRANSMASK_PRIORITY, u8); } void gfx_element::prio_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask, uint32_t trans_mask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask, u32 trans_mask) { // special case 0 mask to opaque if (trans_mask == 0) @@ -1090,7 +1090,7 @@ void gfx_element::prio_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~trans_mask) == 0) return; @@ -1104,7 +1104,7 @@ void gfx_element::prio_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, uint8_t); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, u8); } @@ -1116,8 +1116,8 @@ void gfx_element::prio_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::prio_transtable(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask, const uint8_t *pentable) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask, const u8 *pentable) { assert(pentable != nullptr); @@ -1128,12 +1128,12 @@ void gfx_element::prio_transtable(bitmap_ind16 &dest, const rectangle &cliprect, color = colorbase() + granularity() * (color % colors()); const pen_t *shadowtable = m_palette->shadow_table(); code %= elements(); - DRAWGFX_CORE(uint16_t, PIXEL_OP_REBASE_TRANSTABLE16_PRIORITY, uint8_t); + DRAWGFX_CORE(u16, PIXEL_OP_REBASE_TRANSTABLE16_PRIORITY, u8); } void gfx_element::prio_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask, const uint8_t *pentable) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask, const u8 *pentable) { assert(pentable != nullptr); @@ -1144,7 +1144,7 @@ void gfx_element::prio_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); const pen_t *shadowtable = m_palette->shadow_table(); code %= elements(); - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY, uint8_t); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY, u8); } @@ -1156,8 +1156,8 @@ void gfx_element::prio_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::prio_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask, uint32_t trans_pen, uint8_t alpha_val) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask, u32 trans_pen, u8 alpha_val) { // special case alpha = 0xff if (alpha_val == 0xff) @@ -1173,7 +1173,7 @@ void gfx_element::prio_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY, uint8_t); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY, u8); } @@ -1189,8 +1189,8 @@ void gfx_element::prio_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, -------------------------------------------------*/ void gfx_element::prio_zoom_opaque(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1202,12 +1202,12 @@ void gfx_element::prio_zoom_opaque(bitmap_ind16 &dest, const rectangle &cliprect // render color = colorbase() + granularity() * (color % colors()); code %= elements(); - DRAWGFXZOOM_CORE(uint16_t, PIXEL_OP_REBASE_OPAQUE_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u16, PIXEL_OP_REBASE_OPAQUE_PRIORITY, u8); } void gfx_element::prio_zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1219,7 +1219,7 @@ void gfx_element::prio_zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); code %= elements(); - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_OPAQUE_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_OPAQUE_PRIORITY, u8); } @@ -1230,9 +1230,9 @@ void gfx_element::prio_zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect -------------------------------------------------*/ void gfx_element::prio_zoom_transpen(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, - uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, + u32 trans_pen) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1247,7 +1247,7 @@ void gfx_element::prio_zoom_transpen(bitmap_ind16 &dest, const rectangle &clipre if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~(1 << trans_pen)) == 0) return; @@ -1261,13 +1261,13 @@ void gfx_element::prio_zoom_transpen(bitmap_ind16 &dest, const rectangle &clipre // render color = colorbase() + granularity() * (color % colors()); - DRAWGFXZOOM_CORE(uint16_t, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u16, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, u8); } void gfx_element::prio_zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, - uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, + u32 trans_pen) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1282,7 +1282,7 @@ void gfx_element::prio_zoom_transpen(bitmap_rgb32 &dest, const rectangle &clipre if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~(1 << trans_pen)) == 0) return; @@ -1296,7 +1296,7 @@ void gfx_element::prio_zoom_transpen(bitmap_rgb32 &dest, const rectangle &clipre // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_TRANSPEN_PRIORITY, u8); } @@ -1308,9 +1308,9 @@ void gfx_element::prio_zoom_transpen(bitmap_rgb32 &dest, const rectangle &clipre -------------------------------------------------*/ void gfx_element::prio_zoom_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, - uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, + u32 trans_pen) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1325,13 +1325,13 @@ void gfx_element::prio_zoom_transpen_raw(bitmap_ind16 &dest, const rectangle &cl pmask |= 1 << 31; // render - DRAWGFXZOOM_CORE(uint16_t, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u16, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, u8); } void gfx_element::prio_zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, - uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, + u32 trans_pen) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1346,7 +1346,7 @@ void gfx_element::prio_zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cl pmask |= 1 << 31; // render - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REBASE_TRANSPEN_PRIORITY, u8); } @@ -1358,9 +1358,9 @@ void gfx_element::prio_zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cl -------------------------------------------------*/ void gfx_element::prio_zoom_transmask(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, - uint32_t trans_mask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, + u32 trans_mask) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1375,7 +1375,7 @@ void gfx_element::prio_zoom_transmask(bitmap_ind16 &dest, const rectangle &clipr if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~trans_mask) == 0) return; @@ -1389,13 +1389,13 @@ void gfx_element::prio_zoom_transmask(bitmap_ind16 &dest, const rectangle &clipr // render color = colorbase() + granularity() * (color % colors()); - DRAWGFXZOOM_CORE(uint16_t, PIXEL_OP_REBASE_TRANSMASK_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u16, PIXEL_OP_REBASE_TRANSMASK_PRIORITY, u8); } void gfx_element::prio_zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, - uint32_t trans_mask) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, + u32 trans_mask) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1410,7 +1410,7 @@ void gfx_element::prio_zoom_transmask(bitmap_rgb32 &dest, const rectangle &clipr if (has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); if ((usage & ~trans_mask) == 0) return; @@ -1424,7 +1424,7 @@ void gfx_element::prio_zoom_transmask(bitmap_rgb32 &dest, const rectangle &clipr // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_TRANSMASK_PRIORITY, u8); } @@ -1436,9 +1436,9 @@ void gfx_element::prio_zoom_transmask(bitmap_rgb32 &dest, const rectangle &clipr -------------------------------------------------*/ void gfx_element::prio_zoom_transtable(bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, - const uint8_t *pentable) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, + const u8 *pentable) { assert(pentable != nullptr); @@ -1453,13 +1453,13 @@ void gfx_element::prio_zoom_transtable(bitmap_ind16 &dest, const rectangle &clip color = colorbase() + granularity() * (color % colors()); const pen_t *shadowtable = m_palette->shadow_table(); code %= elements(); - DRAWGFXZOOM_CORE(uint16_t, PIXEL_OP_REBASE_TRANSTABLE16_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u16, PIXEL_OP_REBASE_TRANSTABLE16_PRIORITY, u8); } void gfx_element::prio_zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, - const uint8_t *pentable) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, + const u8 *pentable) { assert(pentable != nullptr); @@ -1474,7 +1474,7 @@ void gfx_element::prio_zoom_transtable(bitmap_rgb32 &dest, const rectangle &clip const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); const pen_t *shadowtable = m_palette->shadow_table(); code %= elements(); - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY, u8); } @@ -1487,9 +1487,9 @@ void gfx_element::prio_zoom_transtable(bitmap_rgb32 &dest, const rectangle &clip -------------------------------------------------*/ void gfx_element::prio_zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, - uint32_t trans_pen, uint8_t alpha_val) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, + u32 trans_pen, u8 alpha_val) { // non-zoom case if (scalex == 0x10000 && scaley == 0x10000) @@ -1509,21 +1509,21 @@ void gfx_element::prio_zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, // render const pen_t *paldata = m_palette->pens() + colorbase() + granularity() * (color % colors()); - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY, uint8_t); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY, u8); } -#define PIXEL_OP_REMAP_TRANSPEN_PRIORITY_ADDIIVE32(DEST, PRIORITY, SOURCE) \ +#define PIXEL_OP_REMAP_TRANSPEN_PRIORITY_ADDIIVE32(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ - if (srcdata != trans_pen) \ + u32 srcdata = (SOURCE); \ + if (srcdata != trans_pen) \ { \ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \ { \ - uint32_t srcdata2 = paldata[srcdata]; \ + u32 srcdata2 = paldata[srcdata]; \ \ - uint32_t add; \ + u32 add; \ add = (srcdata2 & 0x00ff0000) + (DEST & 0x00ff0000); \ if (add & 0x01000000) DEST = (DEST & 0xff00ffff) | (0x00ff0000); \ else DEST = (DEST & 0xff00ffff) | (add & 0x00ff0000); \ @@ -1540,8 +1540,8 @@ do while (0) void gfx_element::prio_transpen_additive(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - bitmap_ind8 &priority, uint32_t pmask, uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + bitmap_ind8 &priority, u32 pmask, u32 trans_pen) { const pen_t *paldata; @@ -1556,7 +1556,7 @@ void gfx_element::prio_transpen_additive(bitmap_rgb32 &dest, const rectangle &cl /* use pen usage to optimize */ if (has_pen_usage()) { - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); /* fully transparent; do nothing */ if ((usage & ~(1 << trans_pen)) == 0) @@ -1567,14 +1567,14 @@ void gfx_element::prio_transpen_additive(bitmap_rgb32 &dest, const rectangle &cl pmask |= 1 << 31; /* render based on dest bitmap depth */ - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANSPEN_PRIORITY_ADDIIVE32, uint8_t); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANSPEN_PRIORITY_ADDIIVE32, u8); } void gfx_element::prio_zoom_transpen_additive(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, - uint32_t trans_pen) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, + u32 trans_pen) { const pen_t *paldata; @@ -1597,7 +1597,7 @@ void gfx_element::prio_zoom_transpen_additive(bitmap_rgb32 &dest, const rectangl /* use pen usage to optimize */ if (has_pen_usage()) { - uint32_t usage = pen_usage(code); + u32 usage = pen_usage(code); /* fully transparent; do nothing */ if ((usage & ~(1 << trans_pen)) == 0) @@ -1607,7 +1607,7 @@ void gfx_element::prio_zoom_transpen_additive(bitmap_rgb32 &dest, const rectangl /* high bit of the mask is implicitly on */ pmask |= 1 << 31; - DRAWGFXZOOM_CORE(uint32_t, PIXEL_OP_REMAP_TRANSPEN_PRIORITY_ADDIIVE32, uint8_t); + DRAWGFXZOOM_CORE(u32, PIXEL_OP_REMAP_TRANSPEN_PRIORITY_ADDIIVE32, u8); } //#define MAKE_ARGB_RGB(a, rgb) rgb_t(a, rgb.r(), rgb.g(), rgb.b()) @@ -1617,7 +1617,7 @@ void gfx_element::prio_zoom_transpen_additive(bitmap_rgb32 &dest, const rectangl #define PIXEL_OP_REMAP_TRANS0_ALPHASTORE32(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (srcdata != 0) \ (DEST) = MAKE_ARGB_RGB(alpha,paldata[srcdata]); \ } \ @@ -1626,7 +1626,7 @@ while (0) #define PIXEL_OP_REMAP_TRANS0_ALPHATABLESTORE32(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (srcdata != 0) \ (DEST) = MAKE_ARGB_RGB(alphatable[srcdata], paldata[srcdata]); \ } \ @@ -1635,7 +1635,7 @@ while (0) #define PIXEL_OP_REMAP_TRANS0_ALPHATABLE32(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (srcdata != 0) \ (DEST) = alpha_blend_r32((DEST), paldata[srcdata], alphatable[srcdata]); \ } \ @@ -1647,8 +1647,8 @@ while (0) in alpha field of ARGB32, negative alpha implies alphatable -------------------------------------------------*/ void gfx_element::alphastore(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - int fixedalpha, uint8_t *alphatable) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + int fixedalpha, u8 *alphatable) { DECLARE_NO_PRIORITY; const pen_t *paldata; @@ -1673,12 +1673,12 @@ void gfx_element::alphastore(bitmap_rgb32 &dest, const rectangle &cliprect, if (fixedalpha >= 0) { - uint8_t alpha = fixedalpha; - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANS0_ALPHASTORE32, NO_PRIORITY); + u8 alpha = fixedalpha; + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANS0_ALPHASTORE32, NO_PRIORITY); } else { - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANS0_ALPHATABLESTORE32, NO_PRIORITY); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANS0_ALPHATABLESTORE32, NO_PRIORITY); } } @@ -1688,8 +1688,8 @@ void gfx_element::alphastore(bitmap_rgb32 &dest, const rectangle &cliprect, the per-pen alphatable[] array -------------------------------------------------*/ void gfx_element::alphatable(bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, - int fixedalpha ,uint8_t *alphatable) + u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, + int fixedalpha ,u8 *alphatable) { DECLARE_NO_PRIORITY; @@ -1714,7 +1714,7 @@ void gfx_element::alphatable(bitmap_rgb32 &dest, const rectangle &cliprect, if (has_pen_usage() && (pen_usage(code) & ~(1 << 0)) == 0) return; - DRAWGFX_CORE(uint32_t, PIXEL_OP_REMAP_TRANS0_ALPHATABLE32, NO_PRIORITY); + DRAWGFX_CORE(u32, PIXEL_OP_REMAP_TRANS0_ALPHATABLE32, NO_PRIORITY); } @@ -1727,30 +1727,30 @@ void gfx_element::alphatable(bitmap_rgb32 &dest, const rectangle &cliprect, buffer to a single scanline of a bitmap -------------------------------------------------*/ -void draw_scanline8(bitmap_ind16 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint8_t *srcptr, const pen_t *paldata) +void draw_scanline8(bitmap_ind16 &bitmap, s32 destx, s32 desty, s32 length, const u8 *srcptr, const pen_t *paldata) { DECLARE_NO_PRIORITY; // palette lookup case if (paldata != nullptr) - DRAWSCANLINE_CORE(uint16_t, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case else - DRAWSCANLINE_CORE(uint16_t, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); } -void draw_scanline8(bitmap_rgb32 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint8_t *srcptr, const pen_t *paldata) +void draw_scanline8(bitmap_rgb32 &bitmap, s32 destx, s32 desty, s32 length, const u8 *srcptr, const pen_t *paldata) { DECLARE_NO_PRIORITY; // palette lookup case if (paldata != nullptr) - DRAWSCANLINE_CORE(uint32_t, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case else - DRAWSCANLINE_CORE(uint32_t, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); } @@ -1759,30 +1759,30 @@ void draw_scanline8(bitmap_rgb32 &bitmap, int32_t destx, int32_t desty, int32_t buffer to a single scanline of a bitmap -------------------------------------------------*/ -void draw_scanline16(bitmap_ind16 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint16_t *srcptr, const pen_t *paldata) +void draw_scanline16(bitmap_ind16 &bitmap, s32 destx, s32 desty, s32 length, const u16 *srcptr, const pen_t *paldata) { DECLARE_NO_PRIORITY; // palette lookup case if (paldata != nullptr) - DRAWSCANLINE_CORE(uint16_t, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case else - DRAWSCANLINE_CORE(uint16_t, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); } -void draw_scanline16(bitmap_rgb32 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint16_t *srcptr, const pen_t *paldata) +void draw_scanline16(bitmap_rgb32 &bitmap, s32 destx, s32 desty, s32 length, const u16 *srcptr, const pen_t *paldata) { DECLARE_NO_PRIORITY; // palette lookup case if (paldata != nullptr) - DRAWSCANLINE_CORE(uint32_t, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case else - DRAWSCANLINE_CORE(uint32_t, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); } @@ -1791,30 +1791,30 @@ void draw_scanline16(bitmap_rgb32 &bitmap, int32_t destx, int32_t desty, int32_t buffer to a single scanline of a bitmap -------------------------------------------------*/ -void draw_scanline32(bitmap_ind16 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint32_t *srcptr, const pen_t *paldata) +void draw_scanline32(bitmap_ind16 &bitmap, s32 destx, s32 desty, s32 length, const u32 *srcptr, const pen_t *paldata) { DECLARE_NO_PRIORITY; // palette lookup case if (paldata != nullptr) - DRAWSCANLINE_CORE(uint16_t, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u16, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case else - DRAWSCANLINE_CORE(uint16_t, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); } -void draw_scanline32(bitmap_rgb32 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint32_t *srcptr, const pen_t *paldata) +void draw_scanline32(bitmap_rgb32 &bitmap, s32 destx, s32 desty, s32 length, const u32 *srcptr, const pen_t *paldata) { DECLARE_NO_PRIORITY; // palette lookup case if (paldata != nullptr) - DRAWSCANLINE_CORE(uint32_t, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u32, PIXEL_OP_REMAP_OPAQUE, NO_PRIORITY); // raw copy case else - DRAWSCANLINE_CORE(uint32_t, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); + DRAWSCANLINE_CORE(u32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); } @@ -1828,14 +1828,14 @@ void draw_scanline32(bitmap_rgb32 &bitmap, int32_t destx, int32_t desty, int32_t scanline of a bitmap to an 8bpp buffer -------------------------------------------------*/ -void extract_scanline8(const bitmap_ind16 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint8_t *destptr) +void extract_scanline8(const bitmap_ind16 &bitmap, s32 srcx, s32 srcy, s32 length, u8 *destptr) { - EXTRACTSCANLINE_CORE(uint16_t); + EXTRACTSCANLINE_CORE(u16); } -void extract_scanline8(const bitmap_rgb32 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint8_t *destptr) +void extract_scanline8(const bitmap_rgb32 &bitmap, s32 srcx, s32 srcy, s32 length, u8 *destptr) { - EXTRACTSCANLINE_CORE(uint32_t); + EXTRACTSCANLINE_CORE(u32); } @@ -1844,14 +1844,14 @@ void extract_scanline8(const bitmap_rgb32 &bitmap, int32_t srcx, int32_t srcy, i scanline of a bitmap to a 16bpp buffer -------------------------------------------------*/ -void extract_scanline16(const bitmap_ind16 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint16_t *destptr) +void extract_scanline16(const bitmap_ind16 &bitmap, s32 srcx, s32 srcy, s32 length, u16 *destptr) { - EXTRACTSCANLINE_CORE(uint16_t); + EXTRACTSCANLINE_CORE(u16); } -void extract_scanline16(const bitmap_rgb32 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint16_t *destptr) +void extract_scanline16(const bitmap_rgb32 &bitmap, s32 srcx, s32 srcy, s32 length, u16 *destptr) { - EXTRACTSCANLINE_CORE(uint32_t); + EXTRACTSCANLINE_CORE(u32); } @@ -1860,14 +1860,14 @@ void extract_scanline16(const bitmap_rgb32 &bitmap, int32_t srcx, int32_t srcy, scanline of a bitmap to a 32bpp buffer -------------------------------------------------*/ -void extract_scanline32(const bitmap_ind16 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint32_t *destptr) +void extract_scanline32(const bitmap_ind16 &bitmap, s32 srcx, s32 srcy, s32 length, u32 *destptr) { - EXTRACTSCANLINE_CORE(uint16_t); + EXTRACTSCANLINE_CORE(u16); } -void extract_scanline32(const bitmap_rgb32 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint32_t *destptr) +void extract_scanline32(const bitmap_rgb32 &bitmap, s32 srcx, s32 srcy, s32 length, u32 *destptr) { - EXTRACTSCANLINE_CORE(uint32_t); + EXTRACTSCANLINE_CORE(u32); } @@ -1881,16 +1881,16 @@ void extract_scanline32(const bitmap_rgb32 &bitmap, int32_t srcx, int32_t srcy, copying all unclipped pixels -------------------------------------------------*/ -void copybitmap(bitmap_ind16 &dest, const bitmap_ind16 &src, int flipx, int flipy, int32_t destx, int32_t desty, const rectangle &cliprect) +void copybitmap(bitmap_ind16 &dest, const bitmap_ind16 &src, int flipx, int flipy, s32 destx, s32 desty, const rectangle &cliprect) { DECLARE_NO_PRIORITY; - COPYBITMAP_CORE(uint16_t, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); + COPYBITMAP_CORE(u16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); } -void copybitmap(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, int flipy, int32_t destx, int32_t desty, const rectangle &cliprect) +void copybitmap(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, int flipy, s32 destx, s32 desty, const rectangle &cliprect) { DECLARE_NO_PRIORITY; - COPYBITMAP_CORE(uint32_t, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); + COPYBITMAP_CORE(u32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); } @@ -1900,22 +1900,22 @@ void copybitmap(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, int flip those that match transpen -------------------------------------------------*/ -void copybitmap_trans(bitmap_ind16 &dest, const bitmap_ind16 &src, int flipx, int flipy, int32_t destx, int32_t desty, const rectangle &cliprect, uint32_t trans_pen) +void copybitmap_trans(bitmap_ind16 &dest, const bitmap_ind16 &src, int flipx, int flipy, s32 destx, s32 desty, const rectangle &cliprect, u32 trans_pen) { DECLARE_NO_PRIORITY; if (trans_pen > 0xffff) copybitmap(dest, src, flipx, flipy, destx, desty, cliprect); else - COPYBITMAP_CORE(uint16_t, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY); + COPYBITMAP_CORE(u16, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY); } -void copybitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, int flipy, int32_t destx, int32_t desty, const rectangle &cliprect, uint32_t trans_pen) +void copybitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, int flipy, s32 destx, s32 desty, const rectangle &cliprect, u32 trans_pen) { DECLARE_NO_PRIORITY; if (trans_pen == 0xffffffff) copybitmap(dest, src, flipx, flipy, destx, desty, cliprect); else - COPYBITMAP_CORE(uint32_t, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY); + COPYBITMAP_CORE(u32, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY); } @@ -1930,14 +1930,14 @@ void copybitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, in applying scrolling to one or more rows/columns -------------------------------------------------*/ -void copyscrollbitmap(bitmap_ind16 &dest, const bitmap_ind16 &src, uint32_t numrows, const int32_t *rowscroll, uint32_t numcols, const int32_t *colscroll, const rectangle &cliprect) +void copyscrollbitmap(bitmap_ind16 &dest, const bitmap_ind16 &src, u32 numrows, const s32 *rowscroll, u32 numcols, const s32 *colscroll, const rectangle &cliprect) { // just call through to the transparent case as the underlying copybitmap will // optimize for pen == 0xffffffff copyscrollbitmap_trans(dest, src, numrows, rowscroll, numcols, colscroll, cliprect, 0xffffffff); } -void copyscrollbitmap(bitmap_rgb32 &dest, const bitmap_rgb32 &src, uint32_t numrows, const int32_t *rowscroll, uint32_t numcols, const int32_t *colscroll, const rectangle &cliprect) +void copyscrollbitmap(bitmap_rgb32 &dest, const bitmap_rgb32 &src, u32 numrows, const s32 *rowscroll, u32 numcols, const s32 *colscroll, const rectangle &cliprect) { // just call through to the transparent case as the underlying copybitmap will // optimize for pen == 0xffffffff @@ -1953,7 +1953,7 @@ void copyscrollbitmap(bitmap_rgb32 &dest, const bitmap_rgb32 &src, uint32_t numr -------------------------------------------------*/ template -static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, const _BitmapClass &src, uint32_t numrows, const int32_t *rowscroll, uint32_t numcols, const int32_t *colscroll, const rectangle &cliprect, uint32_t trans_pen) +static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, const _BitmapClass &src, u32 numrows, const s32 *rowscroll, u32 numcols, const s32 *colscroll, const rectangle &cliprect, u32 trans_pen) { // no rowscroll and no colscroll means no scroll if (numrows == 0 && numcols == 0) @@ -1967,19 +1967,19 @@ static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, const _Bitm // fully scrolling X,Y playfield if (numrows <= 1 && numcols <= 1) { - int32_t xscroll = normalize_xscroll(src, (numrows == 0) ? 0 : rowscroll[0]); - int32_t yscroll = normalize_yscroll(src, (numcols == 0) ? 0 : colscroll[0]); + s32 xscroll = normalize_xscroll(src, (numrows == 0) ? 0 : rowscroll[0]); + s32 yscroll = normalize_yscroll(src, (numcols == 0) ? 0 : colscroll[0]); // iterate over all portions of the scroll that overlap the destination - for (int32_t sx = xscroll - src.width(); sx < dest.width(); sx += src.width()) - for (int32_t sy = yscroll - src.height(); sy < dest.height(); sy += src.height()) + for (s32 sx = xscroll - src.width(); sx < dest.width(); sx += src.width()) + for (s32 sy = yscroll - src.height(); sy < dest.height(); sy += src.height()) copybitmap_trans(dest, src, 0, 0, sx, sy, cliprect, trans_pen); } // scrolling columns plus horizontal scroll else if (numrows <= 1) { - int32_t xscroll = normalize_xscroll(src, (numrows == 0) ? 0 : rowscroll[0]); + s32 xscroll = normalize_xscroll(src, (numrows == 0) ? 0 : rowscroll[0]); rectangle subclip = cliprect; // determine width of each column @@ -1990,7 +1990,7 @@ static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, const _Bitm int groupcols; for (int col = 0; col < numcols; col += groupcols) { - int32_t yscroll = colscroll[col]; + s32 yscroll = colscroll[col]; // count consecutive columns scrolled by the same amount for (groupcols = 1; col + groupcols < numcols; groupcols++) @@ -1999,7 +1999,7 @@ static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, const _Bitm // iterate over reps of the columns in question yscroll = normalize_yscroll(src, yscroll); - for (int32_t sx = xscroll - src.width(); sx < dest.width(); sx += src.width()) + for (s32 sx = xscroll - src.width(); sx < dest.width(); sx += src.width()) { // compute the cliprect for this group subclip.min_x = col * colwidth + sx; @@ -2007,7 +2007,7 @@ static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, const _Bitm subclip &= cliprect; // iterate over all portions of the scroll that overlap the destination - for (int32_t sy = yscroll - src.height(); sy < dest.height(); sy += src.height()) + for (s32 sy = yscroll - src.height(); sy < dest.height(); sy += src.height()) copybitmap_trans(dest, src, 0, 0, sx, sy, subclip, trans_pen); } } @@ -2016,7 +2016,7 @@ static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, const _Bitm // scrolling rows plus vertical scroll else if (numcols <= 1) { - int32_t yscroll = normalize_yscroll(src, (numcols == 0) ? 0 : colscroll[0]); + s32 yscroll = normalize_yscroll(src, (numcols == 0) ? 0 : colscroll[0]); rectangle subclip = cliprect; // determine width of each rows @@ -2027,7 +2027,7 @@ static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, const _Bitm int grouprows; for (int row = 0; row < numrows; row += grouprows) { - int32_t xscroll = rowscroll[row]; + s32 xscroll = rowscroll[row]; // count consecutive rows scrolled by the same amount for (grouprows = 1; row + grouprows < numrows; grouprows++) @@ -2036,7 +2036,7 @@ static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, const _Bitm // iterate over reps of the rows in question xscroll = normalize_xscroll(src, xscroll); - for (int32_t sy = yscroll - src.height(); sy < dest.height(); sy += src.height()) + for (s32 sy = yscroll - src.height(); sy < dest.height(); sy += src.height()) { // compute the cliprect for this group subclip.min_y = row * rowheight + sy; @@ -2044,17 +2044,17 @@ static inline void copyscrollbitmap_trans_common(_BitmapClass &dest, const _Bitm subclip &= cliprect; // iterate over all portions of the scroll that overlap the destination - for (int32_t sx = xscroll - src.width(); sx < dest.width(); sx += src.width()) + for (s32 sx = xscroll - src.width(); sx < dest.width(); sx += src.width()) copybitmap_trans(dest, src, 0, 0, sx, sy, subclip, trans_pen); } } } } -void copyscrollbitmap_trans(bitmap_ind16 &dest, const bitmap_ind16 &src, uint32_t numrows, const int32_t *rowscroll, uint32_t numcols, const int32_t *colscroll, const rectangle &cliprect, uint32_t trans_pen) +void copyscrollbitmap_trans(bitmap_ind16 &dest, const bitmap_ind16 &src, u32 numrows, const s32 *rowscroll, u32 numcols, const s32 *colscroll, const rectangle &cliprect, u32 trans_pen) { copyscrollbitmap_trans_common(dest, src, numrows, rowscroll, numcols, colscroll, cliprect, trans_pen); } -void copyscrollbitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, uint32_t numrows, const int32_t *rowscroll, uint32_t numcols, const int32_t *colscroll, const rectangle &cliprect, uint32_t trans_pen) +void copyscrollbitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, u32 numrows, const s32 *rowscroll, u32 numcols, const s32 *colscroll, const rectangle &cliprect, u32 trans_pen) { copyscrollbitmap_trans_common(dest, src, numrows, rowscroll, numcols, colscroll, cliprect, trans_pen); } @@ -2069,16 +2069,16 @@ void copyscrollbitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, uint32_ pixels -------------------------------------------------*/ -void copyrozbitmap(bitmap_ind16 &dest, const rectangle &cliprect, const bitmap_ind16 &src, int32_t startx, int32_t starty, int32_t incxx, int32_t incxy, int32_t incyx, int32_t incyy, int wraparound) +void copyrozbitmap(bitmap_ind16 &dest, const rectangle &cliprect, const bitmap_ind16 &src, s32 startx, s32 starty, s32 incxx, s32 incxy, s32 incyx, s32 incyy, int wraparound) { DECLARE_NO_PRIORITY; - COPYROZBITMAP_CORE(uint16_t, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); + COPYROZBITMAP_CORE(u16, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); } -void copyrozbitmap(bitmap_rgb32 &dest, const rectangle &cliprect, const bitmap_rgb32 &src, int32_t startx, int32_t starty, int32_t incxx, int32_t incxy, int32_t incyx, int32_t incyy, int wraparound) +void copyrozbitmap(bitmap_rgb32 &dest, const rectangle &cliprect, const bitmap_rgb32 &src, s32 startx, s32 starty, s32 incxx, s32 incxy, s32 incyx, s32 incyy, int wraparound) { DECLARE_NO_PRIORITY; - COPYROZBITMAP_CORE(uint32_t, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); + COPYROZBITMAP_CORE(u32, PIXEL_OP_COPY_OPAQUE, NO_PRIORITY); } @@ -2089,16 +2089,16 @@ void copyrozbitmap(bitmap_rgb32 &dest, const rectangle &cliprect, const bitmap_r transpen -------------------------------------------------*/ -void copyrozbitmap_trans(bitmap_ind16 &dest, const rectangle &cliprect, const bitmap_ind16 &src, int32_t startx, int32_t starty, int32_t incxx, int32_t incxy, int32_t incyx, int32_t incyy, int wraparound, uint32_t trans_pen) +void copyrozbitmap_trans(bitmap_ind16 &dest, const rectangle &cliprect, const bitmap_ind16 &src, s32 startx, s32 starty, s32 incxx, s32 incxy, s32 incyx, s32 incyy, int wraparound, u32 trans_pen) { DECLARE_NO_PRIORITY; - COPYROZBITMAP_CORE(uint16_t, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY); + COPYROZBITMAP_CORE(u16, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY); } -void copyrozbitmap_trans(bitmap_rgb32 &dest, const rectangle &cliprect, const bitmap_rgb32 &src, int32_t startx, int32_t starty, int32_t incxx, int32_t incxy, int32_t incyx, int32_t incyy, int wraparound, uint32_t trans_pen) +void copyrozbitmap_trans(bitmap_rgb32 &dest, const rectangle &cliprect, const bitmap_rgb32 &src, s32 startx, s32 starty, s32 incxx, s32 incxy, s32 incyx, s32 incyy, int wraparound, u32 trans_pen) { DECLARE_NO_PRIORITY; - COPYROZBITMAP_CORE(uint32_t, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY); + COPYROZBITMAP_CORE(u32, PIXEL_OP_COPY_TRANSPEN, NO_PRIORITY); } GFXDECODE_START( empty ) diff --git a/src/emu/drawgfx.h b/src/emu/drawgfx.h index 762025b48c8..ca628114c3a 100644 --- a/src/emu/drawgfx.h +++ b/src/emu/drawgfx.h @@ -32,7 +32,7 @@ For example, to draw a sprite that appears over tilemap1, but under opaque pixels of tilemap2, tilemap3, and tilemap4: - uint32_t pmask = GFX_PMASK_2 | GFX_PMASK_4 | GFX_PMASK_8; + u32 pmask = GFX_PMASK_2 | GFX_PMASK_4 | GFX_PMASK_8; gfx->prio_transpen(bitmap, cliprect, code, color, flipx, flipy, @@ -74,7 +74,7 @@ a sprite over the first four tilemaps but under the higher numbered ones: - uint32_t pmask = (~1) << 4; + u32 pmask = (~1) << 4; gfx->prio_transpen(bitmap, cliprect, code, color, flipx, flipy, @@ -116,8 +116,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DRAWGFX_H__ -#define __DRAWGFX_H__ +#ifndef MAME_EMU_DRAWGFX_H +#define MAME_EMU_DRAWGFX_H /*************************************************************************** @@ -151,48 +151,48 @@ public: #ifdef UNUSED_FUNCTION gfx_element(); #endif - gfx_element(palette_device &palette, const gfx_layout &gl, const uint8_t *srcdata, uint32_t xormask, uint32_t total_colors, uint32_t color_base); - gfx_element(palette_device &palette, uint8_t *base, uint16_t width, uint16_t height, uint32_t rowbytes, uint32_t total_colors, uint32_t color_base, uint32_t color_granularity); + gfx_element(palette_device &palette, const gfx_layout &gl, const u8 *srcdata, u32 xormask, u32 total_colors, u32 color_base); + gfx_element(palette_device &palette, u8 *base, u16 width, u16 height, u32 rowbytes, u32 total_colors, u32 color_base, u32 color_granularity); // getters palette_device &palette() const { return *m_palette; } - uint16_t width() const { return m_width; } - uint16_t height() const { return m_height; } - uint32_t elements() const { return m_total_elements; } - uint32_t colorbase() const { return m_color_base; } - uint16_t depth() const { return m_color_depth; } - uint16_t granularity() const { return m_color_granularity; } - uint32_t colors() const { return m_total_colors; } - uint32_t rowbytes() const { return m_line_modulo; } + u16 width() const { return m_width; } + u16 height() const { return m_height; } + u32 elements() const { return m_total_elements; } + u32 colorbase() const { return m_color_base; } + u16 depth() const { return m_color_depth; } + u16 granularity() const { return m_color_granularity; } + u32 colors() const { return m_total_colors; } + u32 rowbytes() const { return m_line_modulo; } bool has_pen_usage() const { return !m_pen_usage.empty(); } // used by tilemaps - uint32_t dirtyseq() const { return m_dirtyseq; } + u32 dirtyseq() const { return m_dirtyseq; } // setters - void set_layout(const gfx_layout &gl, const uint8_t *srcdata); - void set_raw_layout(const uint8_t *srcdata, uint32_t width, uint32_t height, uint32_t total, uint32_t linemod, uint32_t charmod); - void set_source(const uint8_t *source); - void set_source_and_total(const uint8_t *source, uint32_t total); - void set_xormask(uint32_t xormask) { m_layout_xormask = xormask; } + void set_layout(const gfx_layout &gl, const u8 *srcdata); + void set_raw_layout(const u8 *srcdata, u32 width, u32 height, u32 total, u32 linemod, u32 charmod); + void set_source(const u8 *source); + void set_source_and_total(const u8 *source, u32 total); + void set_xormask(u32 xormask) { m_layout_xormask = xormask; } void set_palette(palette_device &palette) { m_palette = &palette; } - void set_colors(uint32_t colors) { m_total_colors = colors; } - void set_colorbase(uint16_t colorbase) { m_color_base = colorbase; } - void set_granularity(uint16_t granularity) { m_color_granularity = granularity; } - void set_source_clip(uint32_t xoffs, uint32_t width, uint32_t yoffs, uint32_t height); + void set_colors(u32 colors) { m_total_colors = colors; } + void set_colorbase(u16 colorbase) { m_color_base = colorbase; } + void set_granularity(u16 granularity) { m_color_granularity = granularity; } + void set_source_clip(u32 xoffs, u32 width, u32 yoffs, u32 height); // operations - void mark_dirty(uint32_t code) { if (code < elements()) { m_dirty[code] = 1; m_dirtyseq++; } } + void mark_dirty(u32 code) { if (code < elements()) { m_dirty[code] = 1; m_dirtyseq++; } } void mark_all_dirty() { memset(&m_dirty[0], 1, elements()); } - const uint8_t *get_data(uint32_t code) + const u8 *get_data(u32 code) { assert(code < elements()); if (code < m_dirty.size() && m_dirty[code]) decode(code); return m_gfxdata + code * m_char_modulo + m_starty * m_line_modulo + m_startx; } - uint32_t pen_usage(uint32_t code) + u32 pen_usage(u32 code) { assert(code < m_pen_usage.size()); if (m_dirty[code]) decode(code); @@ -202,106 +202,106 @@ public: // ----- core graphics drawing ----- // specific drawgfx implementations for each transparency type - void opaque(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty); - void opaque(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty); - void transpen(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t transpen); - void transpen(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t transpen); - void transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t transpen); - void transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t transpen); - void transmask(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t transmask); - void transmask(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t transmask); - void transtable(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, const uint8_t *pentable); - void transtable(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, const uint8_t *pentable); - void alpha(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t transpen, uint8_t alpha); + void opaque(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty); + void opaque(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty); + void transpen(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 transpen); + void transpen(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 transpen); + void transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 transpen); + void transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 transpen); + void transmask(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 transmask); + void transmask(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 transmask); + void transtable(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, const u8 *pentable); + void transtable(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, const u8 *pentable); + void alpha(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 transpen, u8 alpha); // ----- zoomed graphics drawing ----- // specific zoom implementations for each transparency type - void zoom_opaque(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley); - void zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley); - void zoom_transpen(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, uint32_t transpen); - void zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, uint32_t transpen); - void zoom_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, uint32_t transpen); - void zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, uint32_t transpen); - void zoom_transmask(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, uint32_t transmask); - void zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, uint32_t transmask); - void zoom_transtable(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, const uint8_t *pentable); - void zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, const uint8_t *pentable); - void zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, uint32_t transpen, uint8_t alpha); + void zoom_opaque(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley); + void zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley); + void zoom_transpen(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, u32 transpen); + void zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, u32 transpen); + void zoom_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, u32 transpen); + void zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, u32 transpen); + void zoom_transmask(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, u32 transmask); + void zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, u32 transmask); + void zoom_transtable(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, const u8 *pentable); + void zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, const u8 *pentable); + void zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, u32 transpen, u8 alpha); // ----- priority masked graphics drawing ----- // specific prio implementations for each transparency type - void prio_opaque(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask); - void prio_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask); - void prio_transpen(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask, uint32_t transpen); - void prio_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask, uint32_t transpen); - void prio_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask, uint32_t transpen); - void prio_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask, uint32_t transpen); - void prio_transmask(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask, uint32_t transmask); - void prio_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask, uint32_t transmask); - void prio_transtable(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask, const uint8_t *pentable); - void prio_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask, const uint8_t *pentable); - void prio_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask, uint32_t transpen, uint8_t alpha); + void prio_opaque(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask); + void prio_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask); + void prio_transpen(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask, u32 transpen); + void prio_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask, u32 transpen); + void prio_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask, u32 transpen); + void prio_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask, u32 transpen); + void prio_transmask(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask, u32 transmask); + void prio_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask, u32 transmask); + void prio_transtable(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask, const u8 *pentable); + void prio_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask, const u8 *pentable); + void prio_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask, u32 transpen, u8 alpha); // ----- priority masked zoomed graphics drawing ----- // specific prio_zoom implementations for each transparency type - void prio_zoom_opaque(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask); - void prio_zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask); - void prio_zoom_transpen(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, uint32_t transpen); - void prio_zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, uint32_t transpen); - void prio_zoom_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, uint32_t transpen); - void prio_zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, uint32_t transpen); - void prio_zoom_transmask(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, uint32_t transmask); - void prio_zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, uint32_t transmask); - void prio_zoom_transtable(bitmap_ind16 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, const uint8_t *pentable); - void prio_zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, const uint8_t *pentable); - void prio_zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask, uint32_t transpen, uint8_t alpha); + void prio_zoom_opaque(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask); + void prio_zoom_opaque(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask); + void prio_zoom_transpen(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, u32 transpen); + void prio_zoom_transpen(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, u32 transpen); + void prio_zoom_transpen_raw(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, u32 transpen); + void prio_zoom_transpen_raw(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, u32 transpen); + void prio_zoom_transmask(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, u32 transmask); + void prio_zoom_transmask(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, u32 transmask); + void prio_zoom_transtable(bitmap_ind16 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, const u8 *pentable); + void prio_zoom_transtable(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, const u8 *pentable); + void prio_zoom_alpha(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask, u32 transpen, u8 alpha); // implementations moved here from specific drivers - void prio_transpen_additive(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, bitmap_ind8 &priority, uint32_t pmask, uint32_t trans_pen); - void prio_zoom_transpen_additive(bitmap_rgb32 &dest, const rectangle &cliprect,uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty,uint32_t scalex, uint32_t scaley, bitmap_ind8 &priority, uint32_t pmask,uint32_t trans_pen); - void alphastore(bitmap_rgb32 &dest, const rectangle &cliprect,uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty,int fixedalpha, uint8_t *alphatable); - void alphatable(bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t code, uint32_t color, int flipx, int flipy, int32_t destx, int32_t desty, int fixedalpha ,uint8_t *alphatable); + void prio_transpen_additive(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, bitmap_ind8 &priority, u32 pmask, u32 trans_pen); + void prio_zoom_transpen_additive(bitmap_rgb32 &dest, const rectangle &cliprect,u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty,u32 scalex, u32 scaley, bitmap_ind8 &priority, u32 pmask,u32 trans_pen); + void alphastore(bitmap_rgb32 &dest, const rectangle &cliprect,u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty,int fixedalpha, u8 *alphatable); + void alphatable(bitmap_rgb32 &dest, const rectangle &cliprect, u32 code, u32 color, int flipx, int flipy, s32 destx, s32 desty, int fixedalpha ,u8 *alphatable); private: // internal helpers - void decode(uint32_t code); + void decode(u32 code); // internal state palette_device *m_palette; // palette used for drawing - uint16_t m_width; // current pixel width of each element (changeable with source clipping) - uint16_t m_height; // current pixel height of each element (changeable with source clipping) - uint16_t m_startx; // current source clip X offset - uint16_t m_starty; // current source clip Y offset + u16 m_width; // current pixel width of each element (changeable with source clipping) + u16 m_height; // current pixel height of each element (changeable with source clipping) + u16 m_startx; // current source clip X offset + u16 m_starty; // current source clip Y offset - uint16_t m_origwidth; // starting pixel width of each element - uint16_t m_origheight; // staring pixel height of each element - uint32_t m_total_elements; // total number of decoded elements + u16 m_origwidth; // starting pixel width of each element + u16 m_origheight; // staring pixel height of each element + u32 m_total_elements; // total number of decoded elements - uint32_t m_color_base; // base color for rendering - uint16_t m_color_depth; // number of colors each pixel can represent - uint16_t m_color_granularity; // number of colors for each color code - uint32_t m_total_colors; // number of color codes + u32 m_color_base; // base color for rendering + u16 m_color_depth; // number of colors each pixel can represent + u16 m_color_granularity; // number of colors for each color code + u32 m_total_colors; // number of color codes - uint32_t m_line_modulo; // bytes between each row of data - uint32_t m_char_modulo; // bytes between each element - const uint8_t * m_srcdata; // pointer to the source data for decoding - uint32_t m_dirtyseq; // sequence number; incremented each time a tile is dirtied + u32 m_line_modulo; // bytes between each row of data + u32 m_char_modulo; // bytes between each element + const u8 * m_srcdata; // pointer to the source data for decoding + u32 m_dirtyseq; // sequence number; incremented each time a tile is dirtied - uint8_t * m_gfxdata; // pointer to decoded pixel data, 8bpp - std::vector m_gfxdata_allocated; // allocated decoded pixel data, 8bpp - std::vector m_dirty; // dirty array for detecting chars that need decoding - std::vector m_pen_usage; // bitmask of pens that are used (pens 0-31 only) + u8 * m_gfxdata; // pointer to decoded pixel data, 8bpp + std::vector m_gfxdata_allocated; // allocated decoded pixel data, 8bpp + std::vector m_dirty; // dirty array for detecting chars that need decoding + std::vector m_pen_usage; // bitmask of pens that are used (pens 0-31 only) bool m_layout_is_raw; // raw layout? - uint8_t m_layout_planes; // bit planes in the layout - uint32_t m_layout_xormask; // xor mask applied to each bit offset - uint32_t m_layout_charincrement; // per-character increment in source data - std::vector m_layout_planeoffset;// plane offsets - std::vector m_layout_xoffset; // X offsets - std::vector m_layout_yoffset; // Y offsets + u8 m_layout_planes; // bit planes in the layout + u32 m_layout_xormask; // xor mask applied to each bit offset + u32 m_layout_charincrement; // per-character increment in source data + std::vector m_layout_planeoffset;// plane offsets + std::vector m_layout_xoffset; // X offsets + std::vector m_layout_yoffset; // Y offsets }; @@ -312,44 +312,44 @@ private: // ----- scanline copying ----- // copy pixels from an 8bpp buffer to a single scanline of a bitmap -void draw_scanline8(bitmap_ind16 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint8_t *srcptr, const pen_t *paldata); -void draw_scanline8(bitmap_rgb32 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint8_t *srcptr, const pen_t *paldata); +void draw_scanline8(bitmap_ind16 &bitmap, s32 destx, s32 desty, s32 length, const u8 *srcptr, const pen_t *paldata); +void draw_scanline8(bitmap_rgb32 &bitmap, s32 destx, s32 desty, s32 length, const u8 *srcptr, const pen_t *paldata); // copy pixels from a 16bpp buffer to a single scanline of a bitmap -void draw_scanline16(bitmap_ind16 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint16_t *srcptr, const pen_t *paldata); -void draw_scanline16(bitmap_rgb32 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint16_t *srcptr, const pen_t *paldata); +void draw_scanline16(bitmap_ind16 &bitmap, s32 destx, s32 desty, s32 length, const u16 *srcptr, const pen_t *paldata); +void draw_scanline16(bitmap_rgb32 &bitmap, s32 destx, s32 desty, s32 length, const u16 *srcptr, const pen_t *paldata); // copy pixels from a 32bpp buffer to a single scanline of a bitmap -void draw_scanline32(bitmap_ind16 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint32_t *srcptr, const pen_t *paldata); -void draw_scanline32(bitmap_rgb32 &bitmap, int32_t destx, int32_t desty, int32_t length, const uint32_t *srcptr, const pen_t *paldata); +void draw_scanline32(bitmap_ind16 &bitmap, s32 destx, s32 desty, s32 length, const u32 *srcptr, const pen_t *paldata); +void draw_scanline32(bitmap_rgb32 &bitmap, s32 destx, s32 desty, s32 length, const u32 *srcptr, const pen_t *paldata); // ----- scanline extraction ----- // copy pixels from a single scanline of a bitmap to an 8bpp buffer -void extract_scanline8(const bitmap_ind16 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint8_t *destptr); -void extract_scanline8(const bitmap_rgb32 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint8_t *destptr); +void extract_scanline8(const bitmap_ind16 &bitmap, s32 srcx, s32 srcy, s32 length, u8 *destptr); +void extract_scanline8(const bitmap_rgb32 &bitmap, s32 srcx, s32 srcy, s32 length, u8 *destptr); // copy pixels from a single scanline of a bitmap to a 16bpp buffer -void extract_scanline16(const bitmap_ind16 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint16_t *destptr); -void extract_scanline16(const bitmap_rgb32 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint16_t *destptr); +void extract_scanline16(const bitmap_ind16 &bitmap, s32 srcx, s32 srcy, s32 length, u16 *destptr); +void extract_scanline16(const bitmap_rgb32 &bitmap, s32 srcx, s32 srcy, s32 length, u16 *destptr); // copy pixels from a single scanline of a bitmap to a 32bpp buffer -void extract_scanline32(const bitmap_ind16 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint32_t *destptr); -void extract_scanline32(const bitmap_rgb32 &bitmap, int32_t srcx, int32_t srcy, int32_t length, uint32_t *destptr); +void extract_scanline32(const bitmap_ind16 &bitmap, s32 srcx, s32 srcy, s32 length, u32 *destptr); +void extract_scanline32(const bitmap_rgb32 &bitmap, s32 srcx, s32 srcy, s32 length, u32 *destptr); // ----- bitmap copying ----- // copy from one bitmap to another, copying all unclipped pixels -void copybitmap(bitmap_ind16 &dest, const bitmap_ind16 &src, int flipx, int flipy, int32_t destx, int32_t desty, const rectangle &cliprect); -void copybitmap(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, int flipy, int32_t destx, int32_t desty, const rectangle &cliprect); +void copybitmap(bitmap_ind16 &dest, const bitmap_ind16 &src, int flipx, int flipy, s32 destx, s32 desty, const rectangle &cliprect); +void copybitmap(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, int flipy, s32 destx, s32 desty, const rectangle &cliprect); // copy from one bitmap to another, copying all unclipped pixels except those that match transpen -void copybitmap_trans(bitmap_ind16 &dest, const bitmap_ind16 &src, int flipx, int flipy, int32_t destx, int32_t desty, const rectangle &cliprect, uint32_t transpen); -void copybitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, int flipy, int32_t destx, int32_t desty, const rectangle &cliprect, uint32_t transpen); +void copybitmap_trans(bitmap_ind16 &dest, const bitmap_ind16 &src, int flipx, int flipy, s32 destx, s32 desty, const rectangle &cliprect, u32 transpen); +void copybitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, int flipy, s32 destx, s32 desty, const rectangle &cliprect, u32 transpen); /* Copy a bitmap onto another with scroll and wraparound. @@ -364,12 +364,12 @@ void copybitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, int flipx, in */ // copy from one bitmap to another, copying all unclipped pixels, and applying scrolling to one or more rows/columns -void copyscrollbitmap(bitmap_ind16 &dest, const bitmap_ind16 &src, uint32_t numrows, const int32_t *rowscroll, uint32_t numcols, const int32_t *colscroll, const rectangle &cliprect); -void copyscrollbitmap(bitmap_rgb32 &dest, const bitmap_rgb32 &src, uint32_t numrows, const int32_t *rowscroll, uint32_t numcols, const int32_t *colscroll, const rectangle &cliprect); +void copyscrollbitmap(bitmap_ind16 &dest, const bitmap_ind16 &src, u32 numrows, const s32 *rowscroll, u32 numcols, const s32 *colscroll, const rectangle &cliprect); +void copyscrollbitmap(bitmap_rgb32 &dest, const bitmap_rgb32 &src, u32 numrows, const s32 *rowscroll, u32 numcols, const s32 *colscroll, const rectangle &cliprect); // copy from one bitmap to another, copying all unclipped pixels except those that match transpen, and applying scrolling to one or more rows/columns -void copyscrollbitmap_trans(bitmap_ind16 &dest, const bitmap_ind16 &src, uint32_t numrows, const int32_t *rowscroll, uint32_t numcols, const int32_t *colscroll, const rectangle &cliprect, uint32_t transpen); -void copyscrollbitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, uint32_t numrows, const int32_t *rowscroll, uint32_t numcols, const int32_t *colscroll, const rectangle &cliprect, uint32_t transpen); +void copyscrollbitmap_trans(bitmap_ind16 &dest, const bitmap_ind16 &src, u32 numrows, const s32 *rowscroll, u32 numcols, const s32 *colscroll, const rectangle &cliprect, u32 transpen); +void copyscrollbitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, u32 numrows, const s32 *rowscroll, u32 numcols, const s32 *colscroll, const rectangle &cliprect, u32 transpen); /* Copy a bitmap applying rotation, zooming, and arbitrary distortion. @@ -401,12 +401,12 @@ void copyscrollbitmap_trans(bitmap_rgb32 &dest, const bitmap_rgb32 &src, uint32_ */ // copy from one bitmap to another, with zoom and rotation, copying all unclipped pixels -void copyrozbitmap(bitmap_ind16 &dest, const rectangle &cliprect, const bitmap_ind16 &src, int32_t startx, int32_t starty, int32_t incxx, int32_t incxy, int32_t incyx, int32_t incyy, int wraparound); -void copyrozbitmap(bitmap_rgb32 &dest, const rectangle &cliprect, const bitmap_rgb32 &src, int32_t startx, int32_t starty, int32_t incxx, int32_t incxy, int32_t incyx, int32_t incyy, int wraparound); +void copyrozbitmap(bitmap_ind16 &dest, const rectangle &cliprect, const bitmap_ind16 &src, s32 startx, s32 starty, s32 incxx, s32 incxy, s32 incyx, s32 incyy, int wraparound); +void copyrozbitmap(bitmap_rgb32 &dest, const rectangle &cliprect, const bitmap_rgb32 &src, s32 startx, s32 starty, s32 incxx, s32 incxy, s32 incyx, s32 incyy, int wraparound); // copy from one bitmap to another, with zoom and rotation, copying all unclipped pixels whose values do not match transpen -void copyrozbitmap_trans(bitmap_ind16 &dest, const rectangle &cliprect, const bitmap_ind16 &src, int32_t startx, int32_t starty, int32_t incxx, int32_t incxy, int32_t incyx, int32_t incyy, int wraparound, uint32_t transparent_color); -void copyrozbitmap_trans(bitmap_rgb32 &dest, const rectangle &cliprect, const bitmap_rgb32 &src, int32_t startx, int32_t starty, int32_t incxx, int32_t incxy, int32_t incyx, int32_t incyy, int wraparound, uint32_t transparent_color); +void copyrozbitmap_trans(bitmap_ind16 &dest, const rectangle &cliprect, const bitmap_ind16 &src, s32 startx, s32 starty, s32 incxx, s32 incxy, s32 incyx, s32 incyy, int wraparound, u32 transparent_color); +void copyrozbitmap_trans(bitmap_rgb32 &dest, const rectangle &cliprect, const bitmap_rgb32 &src, s32 startx, s32 starty, s32 incxx, s32 incxy, s32 incyx, s32 incyy, int wraparound, u32 transparent_color); @@ -419,12 +419,11 @@ void copyrozbitmap_trans(bitmap_rgb32 &dest, const rectangle &cliprect, const bi // 5-5-5 RGB pixels //------------------------------------------------- -inline uint32_t alpha_blend_r16(uint32_t d, uint32_t s, uint8_t level) +constexpr u32 alpha_blend_r16(u32 d, u32 s, u8 level) { - int alphad = 256 - level; - return ((((s & 0x001f) * level + (d & 0x001f) * alphad) >> 8)) | - ((((s & 0x03e0) * level + (d & 0x03e0) * alphad) >> 8) & 0x03e0) | - ((((s & 0x7c00) * level + (d & 0x7c00) * alphad) >> 8) & 0x7c00); + return ((((s & 0x001f) * level + (d & 0x001f) * int(256 - level)) >> 8)) | + ((((s & 0x03e0) * level + (d & 0x03e0) * int(256 - level)) >> 8) & 0x03e0) | + ((((s & 0x7c00) * level + (d & 0x7c00) * int(256 - level)) >> 8) & 0x7c00); } @@ -433,12 +432,11 @@ inline uint32_t alpha_blend_r16(uint32_t d, uint32_t s, uint8_t level) // 8-8-8 RGB pixels //------------------------------------------------- -inline uint32_t alpha_blend_r32(uint32_t d, uint32_t s, uint8_t level) +constexpr u32 alpha_blend_r32(u32 d, u32 s, u8 level) { - int alphad = 256 - level; - return ((((s & 0x0000ff) * level + (d & 0x0000ff) * alphad) >> 8)) | - ((((s & 0x00ff00) * level + (d & 0x00ff00) * alphad) >> 8) & 0x00ff00) | - ((((s & 0xff0000) * level + (d & 0xff0000) * alphad) >> 8) & 0xff0000); + return ((((s & 0x0000ff) * level + (d & 0x0000ff) * int(256 - level)) >> 8)) | + ((((s & 0x00ff00) * level + (d & 0x00ff00) * int(256 - level)) >> 8) & 0x00ff00) | + ((((s & 0xff0000) * level + (d & 0xff0000) * int(256 - level)) >> 8) & 0xff0000); } //************************************************************************** @@ -454,7 +452,7 @@ class gfxdecode_device : public device_t, public device_gfx_interface { public: // construction/destruction - gfxdecode_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + gfxdecode_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); protected: virtual void device_start() override {}; @@ -462,4 +460,4 @@ protected: GFXDECODE_EXTERN(empty); -#endif // __DRAWGFX_H__ +#endif // MAME_EMU_DRAWGFX_H diff --git a/src/emu/drawgfxm.h b/src/emu/drawgfxm.h index 16af0e821b5..325ce0e974c 100644 --- a/src/emu/drawgfxm.h +++ b/src/emu/drawgfxm.h @@ -18,8 +18,8 @@ The second set of macros represents the core gfx/bitmap walking and rendering code. These macros generally take the target pixel - type (uint8_t, uint16_t, uint32_t), one of the PIXEL_OP* macros, - and a priority bitmap pixel type (uint8_t, uint16_t, uint32_t, or the + type (u8, u16, u32), one of the PIXEL_OP* macros, + and a priority bitmap pixel type (u8, u16, u32, or the special type NO_PRIORITY). Although the code may look inefficient at first, the compiler is @@ -88,7 +88,7 @@ while (0) #define PIXEL_OP_COPY_TRANSPEN(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (srcdata != trans_pen) \ (DEST) = SOURCE; \ } \ @@ -145,7 +145,7 @@ while (0) #define PIXEL_OP_REMAP_TRANSPEN(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (srcdata != trans_pen) \ (DEST) = paldata[srcdata]; \ } \ @@ -153,7 +153,7 @@ while (0) #define PIXEL_OP_REMAP_TRANSPEN_PRIORITY(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (srcdata != trans_pen) \ { \ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \ @@ -172,7 +172,7 @@ while (0) #define PIXEL_OP_REBASE_TRANSPEN(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (srcdata != trans_pen) \ (DEST) = color + srcdata; \ } \ @@ -180,7 +180,7 @@ while (0) #define PIXEL_OP_REBASE_TRANSPEN_PRIORITY(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (srcdata != trans_pen) \ { \ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \ @@ -199,7 +199,7 @@ while (0) #define PIXEL_OP_REMAP_TRANSMASK(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (((trans_mask >> srcdata) & 1) == 0) \ (DEST) = paldata[srcdata]; \ } \ @@ -207,7 +207,7 @@ while (0) #define PIXEL_OP_REMAP_TRANSMASK_PRIORITY(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (((trans_mask >> srcdata) & 1) == 0) \ { \ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \ @@ -226,7 +226,7 @@ while (0) #define PIXEL_OP_REBASE_TRANSMASK(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (((trans_mask >> srcdata) & 1) == 0) \ (DEST) = color + srcdata; \ } \ @@ -234,7 +234,7 @@ while (0) #define PIXEL_OP_REBASE_TRANSMASK_PRIORITY(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (((trans_mask >> srcdata) & 1) == 0) \ { \ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \ @@ -263,8 +263,8 @@ while (0) #define PIXEL_OP_REBASE_TRANSTABLE16(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ - uint32_t entry = pentable[srcdata]; \ + u32 srcdata = (SOURCE); \ + u32 entry = pentable[srcdata]; \ if (entry != DRAWMODE_NONE) \ { \ if (entry == DRAWMODE_SOURCE) \ @@ -277,8 +277,8 @@ while (0) #define PIXEL_OP_REMAP_TRANSTABLE32(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ - uint32_t entry = pentable[srcdata]; \ + u32 srcdata = (SOURCE); \ + u32 entry = pentable[srcdata]; \ if (entry != DRAWMODE_NONE) \ { \ if (entry == DRAWMODE_SOURCE) \ @@ -291,11 +291,11 @@ while (0) #define PIXEL_OP_REBASE_TRANSTABLE16_PRIORITY(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ - uint32_t entry = pentable[srcdata]; \ + u32 srcdata = (SOURCE); \ + u32 entry = pentable[srcdata]; \ if (entry != DRAWMODE_NONE) \ { \ - uint8_t pridata = (PRIORITY); \ + u8 pridata = (PRIORITY); \ if (entry == DRAWMODE_SOURCE) \ { \ if (((1 << (pridata & 0x1f)) & pmask) == 0) \ @@ -313,11 +313,11 @@ while (0) #define PIXEL_OP_REMAP_TRANSTABLE32_PRIORITY(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ - uint32_t entry = pentable[srcdata]; \ + u32 srcdata = (SOURCE); \ + u32 entry = pentable[srcdata]; \ if (entry != DRAWMODE_NONE) \ { \ - uint8_t pridata = (PRIORITY); \ + u8 pridata = (PRIORITY); \ if (entry == DRAWMODE_SOURCE) \ { \ if (((1 << (pridata & 0x1f)) & pmask) == 0) \ @@ -344,7 +344,7 @@ while (0) #define PIXEL_OP_REMAP_TRANSPEN_ALPHA32(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (srcdata != trans_pen) \ (DEST) = alpha_blend_r32((DEST), paldata[srcdata], alpha_val); \ } \ @@ -352,7 +352,7 @@ while (0) #define PIXEL_OP_REMAP_TRANSPEN_ALPHA32_PRIORITY(DEST, PRIORITY, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + u32 srcdata = (SOURCE); \ if (srcdata != trans_pen) \ { \ if (((1 << ((PRIORITY) & 0x1f)) & pmask) == 0) \ @@ -373,90 +373,90 @@ while (0) bitmap_t &dest - the bitmap to render to const rectangle &cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest') gfx_element *gfx - pointer to the gfx_element to render - uint32_t code - index of the entry within gfx_element - uint32_t color - index of the color within gfx_element + u32 code - index of the entry within gfx_element + u32 color - index of the color within gfx_element int flipx - non-zero means render right-to-left instead of left-to-right int flipy - non-zero means render bottom-to-top instead of top-to-bottom - int32_t destx - the top-left X coordinate to render to - int32_t desty - the top-left Y coordinate to render to + s32 destx - the top-left X coordinate to render to + s32 desty - the top-left Y coordinate to render to bitmap_t &priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy) */ -#define DRAWGFX_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \ -do { \ - g_profiler.start(PROFILER_DRAWGFX); \ - do { \ - const uint8_t *srcdata; \ - int32_t destendx, destendy; \ - int32_t srcx, srcy; \ - int32_t curx, cury; \ - int32_t dy; \ - \ - assert(dest.valid()); \ - assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ - assert(dest.cliprect().contains(cliprect)); \ - assert(code < elements()); \ - \ - /* ignore empty/invalid cliprects */ \ - if (cliprect.empty()) \ - break; \ - \ - /* compute final pixel in X and exit if we are entirely clipped */ \ - destendx = destx + width() - 1; \ - if (destx > cliprect.max_x || destendx < cliprect.min_x) \ - break; \ - \ - /* apply left clip */ \ - srcx = 0; \ - if (destx < cliprect.min_x) \ - { \ - srcx = cliprect.min_x - destx; \ - destx = cliprect.min_x; \ - } \ - \ - /* apply right clip */ \ - if (destendx > cliprect.max_x) \ - destendx = cliprect.max_x; \ - \ - /* compute final pixel in Y and exit if we are entirely clipped */ \ - destendy = desty + height() - 1; \ - if (desty > cliprect.max_y || destendy < cliprect.min_y) \ - break; \ - \ - /* apply top clip */ \ - srcy = 0; \ - if (desty < cliprect.min_y) \ - { \ - srcy = cliprect.min_y - desty; \ - desty = cliprect.min_y; \ - } \ - \ - /* apply bottom clip */ \ - if (destendy > cliprect.max_y) \ - destendy = cliprect.max_y; \ - \ - /* apply X flipping */ \ - if (flipx) \ - srcx = width() - 1 - srcx; \ - \ - /* apply Y flipping */ \ - dy = rowbytes(); \ - if (flipy) \ - { \ - srcy = height() - 1 - srcy; \ - dy = -dy; \ - } \ - \ - /* fetch the source data */ \ - srcdata = get_data(code); \ - \ +#define DRAWGFX_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \ +do { \ + g_profiler.start(PROFILER_DRAWGFX); \ + do { \ + const u8 *srcdata; \ + s32 destendx, destendy; \ + s32 srcx, srcy; \ + s32 curx, cury; \ + s32 dy; \ + \ + assert(dest.valid()); \ + assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ + assert(dest.cliprect().contains(cliprect)); \ + assert(code < elements()); \ + \ + /* ignore empty/invalid cliprects */ \ + if (cliprect.empty()) \ + break; \ + \ + /* compute final pixel in X and exit if we are entirely clipped */ \ + destendx = destx + width() - 1; \ + if (destx > cliprect.max_x || destendx < cliprect.min_x) \ + break; \ + \ + /* apply left clip */ \ + srcx = 0; \ + if (destx < cliprect.min_x) \ + { \ + srcx = cliprect.min_x - destx; \ + destx = cliprect.min_x; \ + } \ + \ + /* apply right clip */ \ + if (destendx > cliprect.max_x) \ + destendx = cliprect.max_x; \ + \ + /* compute final pixel in Y and exit if we are entirely clipped */ \ + destendy = desty + height() - 1; \ + if (desty > cliprect.max_y || destendy < cliprect.min_y) \ + break; \ + \ + /* apply top clip */ \ + srcy = 0; \ + if (desty < cliprect.min_y) \ + { \ + srcy = cliprect.min_y - desty; \ + desty = cliprect.min_y; \ + } \ + \ + /* apply bottom clip */ \ + if (destendy > cliprect.max_y) \ + destendy = cliprect.max_y; \ + \ + /* apply X flipping */ \ + if (flipx) \ + srcx = width() - 1 - srcx; \ + \ + /* apply Y flipping */ \ + dy = rowbytes(); \ + if (flipy) \ + { \ + srcy = height() - 1 - srcy; \ + dy = -dy; \ + } \ + \ + /* fetch the source data */ \ + srcdata = get_data(code); \ + \ /* compute how many blocks of 4 pixels we have */ \ - uint32_t numblocks = (destendx + 1 - destx) / 4; \ - uint32_t leftovers = (destendx + 1 - destx) - 4 * numblocks; \ + u32 numblocks = (destendx + 1 - destx) / 4; \ + u32 leftovers = (destendx + 1 - destx) - 4 * numblocks; \ \ /* adjust srcdata to point to the first source pixel of the row */ \ - srcdata += srcy * rowbytes() + srcx; \ + srcdata += srcy * rowbytes() + srcx; \ \ /* non-flipped 8bpp case */ \ if (!flipx) \ @@ -466,7 +466,7 @@ do { { \ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \ PIXEL_TYPE *destptr = &dest.pixt(cury, destx); \ - const uint8_t *srcptr = srcdata; \ + const u8 *srcptr = srcdata; \ srcdata += dy; \ \ /* iterate over unrolled blocks of 4 */ \ @@ -501,7 +501,7 @@ do { { \ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \ PIXEL_TYPE *destptr = &dest.pixt(cury, destx); \ - const uint8_t *srcptr = srcdata; \ + const u8 *srcptr = srcdata; \ srcdata += dy; \ \ /* iterate over unrolled blocks of 4 */ \ @@ -527,8 +527,8 @@ do { } \ } \ } \ - } while (0); \ - g_profiler.stop(); \ + } while (0); \ + g_profiler.stop(); \ } while (0) @@ -543,112 +543,112 @@ do { bitmap_t &dest - the bitmap to render to const rectangle &cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest') gfx_element *gfx - pointer to the gfx_element to render - uint32_t code - index of the entry within gfx_element - uint32_t color - index of the color within gfx_element + u32 code - index of the entry within gfx_element + u32 color - index of the color within gfx_element int flipx - non-zero means render right-to-left instead of left-to-right int flipy - non-zero means render bottom-to-top instead of top-to-bottom - int32_t destx - the top-left X coordinate to render to - int32_t desty - the top-left Y coordinate to render to - uint32_t scalex - the 16.16 scale factor in the X dimension - uint32_t scaley - the 16.16 scale factor in the Y dimension + s32 destx - the top-left X coordinate to render to + s32 desty - the top-left Y coordinate to render to + u32 scalex - the 16.16 scale factor in the X dimension + u32 scaley - the 16.16 scale factor in the Y dimension bitmap_t &priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy) */ -#define DRAWGFXZOOM_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \ -do { \ - g_profiler.start(PROFILER_DRAWGFX); \ - do { \ - const uint8_t *srcdata; \ - uint32_t dstwidth, dstheight; \ - int32_t destendx, destendy; \ - int32_t srcx, srcy; \ - int32_t curx, cury; \ - int32_t dx, dy; \ - \ - assert(dest.valid()); \ - assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ - assert(dest.cliprect().contains(cliprect)); \ - \ - /* ignore empty/invalid cliprects */ \ - if (cliprect.empty()) \ - break; \ - \ - /* compute scaled size */ \ - dstwidth = (scalex * width() + 0x8000) >> 16; \ - dstheight = (scaley * height() + 0x8000) >> 16; \ - if (dstwidth < 1 || dstheight < 1) \ - break; \ - \ - /* compute 16.16 source steps in dx and dy */ \ - dx = (width() << 16) / dstwidth; \ - dy = (height() << 16) / dstheight; \ - \ - /* compute final pixel in X and exit if we are entirely clipped */ \ - destendx = destx + dstwidth - 1; \ - if (destx > cliprect.max_x || destendx < cliprect.min_x) \ - break; \ - \ - /* apply left clip */ \ - srcx = 0; \ +#define DRAWGFXZOOM_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \ +do { \ + g_profiler.start(PROFILER_DRAWGFX); \ + do { \ + const u8 *srcdata; \ + u32 dstwidth, dstheight; \ + s32 destendx, destendy; \ + s32 srcx, srcy; \ + s32 curx, cury; \ + s32 dx, dy; \ + \ + assert(dest.valid()); \ + assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ + assert(dest.cliprect().contains(cliprect)); \ + \ + /* ignore empty/invalid cliprects */ \ + if (cliprect.empty()) \ + break; \ + \ + /* compute scaled size */ \ + dstwidth = (scalex * width() + 0x8000) >> 16; \ + dstheight = (scaley * height() + 0x8000) >> 16; \ + if (dstwidth < 1 || dstheight < 1) \ + break; \ + \ + /* compute 16.16 source steps in dx and dy */ \ + dx = (width() << 16) / dstwidth; \ + dy = (height() << 16) / dstheight; \ + \ + /* compute final pixel in X and exit if we are entirely clipped */ \ + destendx = destx + dstwidth - 1; \ + if (destx > cliprect.max_x || destendx < cliprect.min_x) \ + break; \ + \ + /* apply left clip */ \ + srcx = 0; \ if (destx < cliprect.min_x) \ - { \ - srcx = (cliprect.min_x - destx) * dx; \ + { \ + srcx = (cliprect.min_x - destx) * dx; \ destx = cliprect.min_x; \ - } \ - \ - /* apply right clip */ \ - if (destendx > cliprect.max_x) \ - destendx = cliprect.max_x; \ - \ - /* compute final pixel in Y and exit if we are entirely clipped */ \ - destendy = desty + dstheight - 1; \ - if (desty > cliprect.max_y || destendy < cliprect.min_y) \ - { \ - g_profiler.stop(); \ - return; \ - } \ - \ - /* apply top clip */ \ - srcy = 0; \ + } \ + \ + /* apply right clip */ \ + if (destendx > cliprect.max_x) \ + destendx = cliprect.max_x; \ + \ + /* compute final pixel in Y and exit if we are entirely clipped */ \ + destendy = desty + dstheight - 1; \ + if (desty > cliprect.max_y || destendy < cliprect.min_y) \ + { \ + g_profiler.stop(); \ + return; \ + } \ + \ + /* apply top clip */ \ + srcy = 0; \ if (desty < cliprect.min_y) \ - { \ - srcy = (cliprect.min_y - desty) * dy; \ + { \ + srcy = (cliprect.min_y - desty) * dy; \ desty = cliprect.min_y; \ - } \ - \ - /* apply bottom clip */ \ - if (destendy > cliprect.max_y) \ - destendy = cliprect.max_y; \ - \ - /* apply X flipping */ \ - if (flipx) \ - { \ - srcx = (dstwidth - 1) * dx - srcx; \ - dx = -dx; \ - } \ - \ - /* apply Y flipping */ \ - if (flipy) \ - { \ - srcy = (dstheight - 1) * dy - srcy; \ - dy = -dy; \ - } \ - \ - /* fetch the source data */ \ - srcdata = get_data(code); \ - \ + } \ + \ + /* apply bottom clip */ \ + if (destendy > cliprect.max_y) \ + destendy = cliprect.max_y; \ + \ + /* apply X flipping */ \ + if (flipx) \ + { \ + srcx = (dstwidth - 1) * dx - srcx; \ + dx = -dx; \ + } \ + \ + /* apply Y flipping */ \ + if (flipy) \ + { \ + srcy = (dstheight - 1) * dy - srcy; \ + dy = -dy; \ + } \ + \ + /* fetch the source data */ \ + srcdata = get_data(code); \ + \ /* compute how many blocks of 4 pixels we have */ \ - uint32_t numblocks = (destendx + 1 - destx) / 4; \ - uint32_t leftovers = (destendx + 1 - destx) - 4 * numblocks; \ + u32 numblocks = (destendx + 1 - destx) / 4; \ + u32 leftovers = (destendx + 1 - destx) - 4 * numblocks; \ \ /* iterate over pixels in Y */ \ for (cury = desty; cury <= destendy; cury++) \ { \ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \ PIXEL_TYPE *destptr = &dest.pixt(cury, destx); \ - const uint8_t *srcptr = srcdata + (srcy >> 16) * rowbytes(); \ - int32_t cursrcx = srcx; \ + const u8 *srcptr = srcdata + (srcy >> 16) * rowbytes(); \ + s32 cursrcx = srcx; \ srcy += dy; \ \ /* iterate over unrolled blocks of 4 */ \ @@ -676,8 +676,8 @@ do { PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \ } \ } \ - } while (0); \ - g_profiler.stop(); \ + } while (0); \ + g_profiler.stop(); \ } while (0) @@ -694,161 +694,161 @@ do { const rectangle &cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest') int flipx - non-zero means render right-to-left instead of left-to-right int flipy - non-zero means render bottom-to-top instead of top-to-bottom - int32_t destx - the top-left X coordinate to copy to - int32_t desty - the top-left Y coordinate to copy to + s32 destx - the top-left X coordinate to copy to + s32 desty - the top-left Y coordinate to copy to bitmap_t &priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy) */ -#define COPYBITMAP_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \ -do { \ - g_profiler.start(PROFILER_COPYBITMAP); \ - do { \ - const PIXEL_TYPE *srcdata; \ - uint32_t numblocks, leftovers; \ - int32_t destendx, destendy; \ - int32_t srcx, srcy; \ - int32_t curx, cury; \ - int32_t dx, dy; \ - \ - assert(dest.valid()); \ - assert(src.valid()); \ - assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ - assert(dest.cliprect().contains(cliprect)); \ - \ - /* ignore empty/invalid cliprects */ \ - if (cliprect.empty()) \ - break; \ - \ - /* standard setup; dx counts bytes in X, dy counts pixels in Y */ \ - dx = 1; \ - dy = src.rowpixels(); \ - \ - /* compute final pixel in X and exit if we are entirely clipped */ \ +#define COPYBITMAP_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \ +do { \ + g_profiler.start(PROFILER_COPYBITMAP); \ + do { \ + const PIXEL_TYPE *srcdata; \ + u32 numblocks, leftovers; \ + s32 destendx, destendy; \ + s32 srcx, srcy; \ + s32 curx, cury; \ + s32 dx, dy; \ + \ + assert(dest.valid()); \ + assert(src.valid()); \ + assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ + assert(dest.cliprect().contains(cliprect)); \ + \ + /* ignore empty/invalid cliprects */ \ + if (cliprect.empty()) \ + break; \ + \ + /* standard setup; dx counts bytes in X, dy counts pixels in Y */ \ + dx = 1; \ + dy = src.rowpixels(); \ + \ + /* compute final pixel in X and exit if we are entirely clipped */ \ destendx = destx + src.width() - 1; \ - if (destx > cliprect.max_x || destendx < cliprect.min_x) \ - break; \ - \ - /* apply left clip */ \ - srcx = 0; \ + if (destx > cliprect.max_x || destendx < cliprect.min_x) \ + break; \ + \ + /* apply left clip */ \ + srcx = 0; \ if (destx < cliprect.min_x) \ - { \ - srcx = cliprect.min_x - destx; \ + { \ + srcx = cliprect.min_x - destx; \ destx = cliprect.min_x; \ - } \ - \ - /* apply right clip */ \ - if (destendx > cliprect.max_x) \ - destendx = cliprect.max_x; \ - \ - /* compute final pixel in Y and exit if we are entirely clipped */ \ - destendy = desty + src.height() - 1; \ - if (desty > cliprect.max_y || destendy < cliprect.min_y) \ - break; \ - \ - /* apply top clip */ \ - srcy = 0; \ + } \ + \ + /* apply right clip */ \ + if (destendx > cliprect.max_x) \ + destendx = cliprect.max_x; \ + \ + /* compute final pixel in Y and exit if we are entirely clipped */ \ + destendy = desty + src.height() - 1; \ + if (desty > cliprect.max_y || destendy < cliprect.min_y) \ + break; \ + \ + /* apply top clip */ \ + srcy = 0; \ if (desty < cliprect.min_y) \ - { \ - srcy = cliprect.min_y - desty; \ + { \ + srcy = cliprect.min_y - desty; \ desty = cliprect.min_y; \ - } \ - \ - /* apply bottom clip */ \ - if (destendy > cliprect.max_y) \ - destendy = cliprect.max_y; \ - \ - /* apply X flipping */ \ - if (flipx) \ - { \ - srcx = src.width() - 1 - srcx; \ - dx = -dx; \ - } \ - \ - /* apply Y flipping */ \ - if (flipy) \ - { \ - srcy = src.height() - 1 - srcy; \ - dy = -dy; \ - } \ - \ - /* compute how many blocks of 4 pixels we have */ \ - numblocks = (destendx + 1 - destx) / 4; \ - leftovers = (destendx + 1 - destx) - 4 * numblocks; \ - \ - /* compute the address of the first source pixel of the first row */ \ - srcdata = &src.pixt(srcy, srcx); \ - \ - /* non-flipped case */ \ - if (!flipx) \ - { \ - /* iterate over pixels in Y */ \ - for (cury = desty; cury <= destendy; cury++) \ - { \ + } \ + \ + /* apply bottom clip */ \ + if (destendy > cliprect.max_y) \ + destendy = cliprect.max_y; \ + \ + /* apply X flipping */ \ + if (flipx) \ + { \ + srcx = src.width() - 1 - srcx; \ + dx = -dx; \ + } \ + \ + /* apply Y flipping */ \ + if (flipy) \ + { \ + srcy = src.height() - 1 - srcy; \ + dy = -dy; \ + } \ + \ + /* compute how many blocks of 4 pixels we have */ \ + numblocks = (destendx + 1 - destx) / 4; \ + leftovers = (destendx + 1 - destx) - 4 * numblocks; \ + \ + /* compute the address of the first source pixel of the first row */ \ + srcdata = &src.pixt(srcy, srcx); \ + \ + /* non-flipped case */ \ + if (!flipx) \ + { \ + /* iterate over pixels in Y */ \ + for (cury = desty; cury <= destendy; cury++) \ + { \ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \ - PIXEL_TYPE *destptr = &dest.pixt(cury, destx); \ - const PIXEL_TYPE *srcptr = srcdata; \ - srcdata += dy; \ - \ - /* iterate over unrolled blocks of 4 */ \ - for (curx = 0; curx < numblocks; curx++) \ - { \ - PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \ - PIXEL_OP(destptr[1], priptr[1], srcptr[1]); \ - PIXEL_OP(destptr[2], priptr[2], srcptr[2]); \ - PIXEL_OP(destptr[3], priptr[3], srcptr[3]); \ - \ - srcptr += 4; \ - destptr += 4; \ - PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \ - } \ - \ - /* iterate over leftover pixels */ \ - for (curx = 0; curx < leftovers; curx++) \ - { \ - PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \ - srcptr++; \ - destptr++; \ - PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \ - } \ - } \ - } \ - \ - /* flipped case */ \ - else \ - { \ - /* iterate over pixels in Y */ \ - for (cury = desty; cury <= destendy; cury++) \ - { \ + PIXEL_TYPE *destptr = &dest.pixt(cury, destx); \ + const PIXEL_TYPE *srcptr = srcdata; \ + srcdata += dy; \ + \ + /* iterate over unrolled blocks of 4 */ \ + for (curx = 0; curx < numblocks; curx++) \ + { \ + PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \ + PIXEL_OP(destptr[1], priptr[1], srcptr[1]); \ + PIXEL_OP(destptr[2], priptr[2], srcptr[2]); \ + PIXEL_OP(destptr[3], priptr[3], srcptr[3]); \ + \ + srcptr += 4; \ + destptr += 4; \ + PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \ + } \ + \ + /* iterate over leftover pixels */ \ + for (curx = 0; curx < leftovers; curx++) \ + { \ + PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \ + srcptr++; \ + destptr++; \ + PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \ + } \ + } \ + } \ + \ + /* flipped case */ \ + else \ + { \ + /* iterate over pixels in Y */ \ + for (cury = desty; cury <= destendy; cury++) \ + { \ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, destx); \ - PIXEL_TYPE *destptr = &dest.pixt(cury, destx); \ - const PIXEL_TYPE *srcptr = srcdata; \ - srcdata += dy; \ - \ - /* iterate over unrolled blocks of 4 */ \ - for (curx = 0; curx < numblocks; curx++) \ - { \ - PIXEL_OP(destptr[0], priptr[0], srcptr[ 0]); \ - PIXEL_OP(destptr[1], priptr[1], srcptr[-1]); \ - PIXEL_OP(destptr[2], priptr[2], srcptr[-2]); \ - PIXEL_OP(destptr[3], priptr[3], srcptr[-3]); \ - \ - srcptr -= 4; \ - destptr += 4; \ - PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \ - } \ - \ - /* iterate over leftover pixels */ \ - for (curx = 0; curx < leftovers; curx++) \ - { \ - PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \ - srcptr--; \ - destptr++; \ - PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \ - } \ - } \ - } \ - } while (0); \ - g_profiler.stop(); \ + PIXEL_TYPE *destptr = &dest.pixt(cury, destx); \ + const PIXEL_TYPE *srcptr = srcdata; \ + srcdata += dy; \ + \ + /* iterate over unrolled blocks of 4 */ \ + for (curx = 0; curx < numblocks; curx++) \ + { \ + PIXEL_OP(destptr[0], priptr[0], srcptr[ 0]); \ + PIXEL_OP(destptr[1], priptr[1], srcptr[-1]); \ + PIXEL_OP(destptr[2], priptr[2], srcptr[-2]); \ + PIXEL_OP(destptr[3], priptr[3], srcptr[-3]); \ + \ + srcptr -= 4; \ + destptr += 4; \ + PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 4); \ + } \ + \ + /* iterate over leftover pixels */ \ + for (curx = 0; curx < leftovers; curx++) \ + { \ + PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \ + srcptr--; \ + destptr++; \ + PRIORITY_ADVANCE(PRIORITY_TYPE, priptr, 1); \ + } \ + } \ + } \ + } while (0); \ + g_profiler.stop(); \ } while (0) @@ -863,21 +863,21 @@ do { bitmap_t &dest - the bitmap to copy to bitmap_t &src - the bitmap to copy from (must be same bpp as dest) const rectangle &cliprect - a clipping rectangle (assumed to be clipped to the size of 'dest') - int32_t destx - the 16.16 source X position at destination pixel (0,0) - int32_t desty - the 16.16 source Y position at destination pixel (0,0) - int32_t incxx - the 16.16 amount to increment in source X for each destination X pixel - int32_t incyx - the 16.16 amount to increment in source Y for each destination X pixel - int32_t incxy - the 16.16 amount to increment in source X for each destination Y pixel - int32_t incyy - the 16.16 amount to increment in source Y for each destination Y pixel + s32 destx - the 16.16 source X position at destination pixel (0,0) + s32 desty - the 16.16 source Y position at destination pixel (0,0) + s32 incxx - the 16.16 amount to increment in source X for each destination X pixel + s32 incyx - the 16.16 amount to increment in source Y for each destination X pixel + s32 incxy - the 16.16 amount to increment in source X for each destination Y pixel + s32 incyy - the 16.16 amount to increment in source Y for each destination Y pixel int wraparound - non-zero means wrap when hitting the edges of the source bitmap_t &priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy) */ #define COPYROZBITMAP_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE) \ do { \ - uint32_t srcfixwidth, srcfixheight; \ - uint32_t numblocks, leftovers; \ - int32_t curx, cury; \ + u32 srcfixwidth, srcfixheight; \ + u32 numblocks, leftovers; \ + s32 curx, cury; \ \ g_profiler.start(PROFILER_COPYBITMAP); \ \ @@ -911,37 +911,37 @@ do { if (!wraparound) \ { \ /* iterate over pixels in Y */ \ - for (cury = cliprect.min_y; cury <= cliprect.max_y; cury++) \ + for (cury = cliprect.min_y; cury <= cliprect.max_y; cury++) \ { \ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect.min_x); \ PIXEL_TYPE *destptr = &dest.pixt(cury, cliprect.min_x); \ const PIXEL_TYPE *srcptr; \ - int32_t srcx = startx; \ - int32_t srcy = starty; \ + s32 srcx = startx; \ + s32 srcy = starty; \ \ starty += incyy; \ \ /* check srcy for the whole row at once */ \ - if ((uint32_t)srcy < srcfixheight) \ + if ((u32)srcy < srcfixheight) \ { \ srcptr = &src.pixt(srcy >> 16); \ \ /* iterate over unrolled blocks of 4 */ \ for (curx = 0; curx < numblocks; curx++) \ { \ - if ((uint32_t)srcx < srcfixwidth) \ + if (u32(srcx) < srcfixwidth) \ PIXEL_OP(destptr[0], priptr[0], srcptr[srcx >> 16]); \ srcx += incxx; \ \ - if ((uint32_t)srcx < srcfixwidth) \ + if (u32(srcx) < srcfixwidth) \ PIXEL_OP(destptr[1], priptr[1], srcptr[srcx >> 16]); \ srcx += incxx; \ \ - if ((uint32_t)srcx < srcfixwidth) \ + if (u32(srcx) < srcfixwidth) \ PIXEL_OP(destptr[2], priptr[2], srcptr[srcx >> 16]); \ srcx += incxx; \ \ - if ((uint32_t)srcx < srcfixwidth) \ + if (u32(srcx) < srcfixwidth) \ PIXEL_OP(destptr[3], priptr[3], srcptr[srcx >> 16]); \ srcx += incxx; \ \ @@ -952,7 +952,7 @@ do { /* iterate over leftover pixels */ \ for (curx = 0; curx < leftovers; curx++) \ { \ - if ((uint32_t)srcx < srcfixwidth) \ + if (u32(srcx) < srcfixwidth) \ PIXEL_OP(destptr[0], priptr[0], srcptr[srcx >> 16]); \ srcx += incxx; \ destptr++; \ @@ -972,12 +972,12 @@ do { starty &= srcfixheight; \ \ /* iterate over pixels in Y */ \ - for (cury = cliprect.min_y; cury <= cliprect.max_y; cury++) \ + for (cury = cliprect.min_y; cury <= cliprect.max_y; cury++) \ { \ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect.min_x); \ PIXEL_TYPE *destptr = &dest.pixt(cury, cliprect.min_x); \ const PIXEL_TYPE *srcptr = &src.pixt(starty >> 16); \ - int32_t srcx = startx; \ + s32 srcx = startx; \ \ starty = (starty + incyy) & srcfixheight; \ \ @@ -1019,13 +1019,13 @@ do { if (!wraparound) \ { \ /* iterate over pixels in Y */ \ - for (cury = cliprect.min_y; cury <= cliprect.max_y; cury++) \ + for (cury = cliprect.min_y; cury <= cliprect.max_y; cury++) \ { \ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect.min_x); \ PIXEL_TYPE *destptr = &dest.pixt(cury, cliprect.min_x); \ const PIXEL_TYPE *srcptr; \ - int32_t srcx = startx; \ - int32_t srcy = starty; \ + s32 srcx = startx; \ + s32 srcy = starty; \ \ startx += incyx; \ starty += incyy; \ @@ -1033,7 +1033,7 @@ do { /* iterate over unrolled blocks of 4 */ \ for (curx = 0; curx < numblocks; curx++) \ { \ - if ((uint32_t)srcx < srcfixwidth && (uint32_t)srcy < srcfixheight) \ + if (u32(srcx) < srcfixwidth && (u32)srcy < srcfixheight) \ { \ srcptr = &src.pixt(srcy >> 16, srcx >> 16); \ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \ @@ -1041,7 +1041,7 @@ do { srcx += incxx; \ srcy += incxy; \ \ - if ((uint32_t)srcx < srcfixwidth && (uint32_t)srcy < srcfixheight) \ + if (u32(srcx) < srcfixwidth && u32(srcy) < srcfixheight) \ { \ srcptr = &src.pixt(srcy >> 16, srcx >> 16); \ PIXEL_OP(destptr[1], priptr[1], srcptr[0]); \ @@ -1049,7 +1049,7 @@ do { srcx += incxx; \ srcy += incxy; \ \ - if ((uint32_t)srcx < srcfixwidth && (uint32_t)srcy < srcfixheight) \ + if (u32(srcx) < srcfixwidth && u32(srcy) < srcfixheight) \ { \ srcptr = &src.pixt(srcy >> 16, srcx >> 16); \ PIXEL_OP(destptr[2], priptr[2], srcptr[0]); \ @@ -1057,7 +1057,7 @@ do { srcx += incxx; \ srcy += incxy; \ \ - if ((uint32_t)srcx < srcfixwidth && (uint32_t)srcy < srcfixheight) \ + if (u32(srcx) < srcfixwidth && u32(srcy) < srcfixheight) \ { \ srcptr = &src.pixt(srcy >> 16, srcx >> 16); \ PIXEL_OP(destptr[3], priptr[3], srcptr[0]); \ @@ -1072,7 +1072,7 @@ do { /* iterate over leftover pixels */ \ for (curx = 0; curx < leftovers; curx++) \ { \ - if ((uint32_t)srcx < srcfixwidth && (uint32_t)srcy < srcfixheight) \ + if (u32(srcx) < srcfixwidth && u32(srcy) < srcfixheight) \ { \ srcptr = &src.pixt(srcy >> 16, srcx >> 16); \ PIXEL_OP(destptr[0], priptr[0], srcptr[0]); \ @@ -1095,13 +1095,13 @@ do { starty &= srcfixheight; \ \ /* iterate over pixels in Y */ \ - for (cury = cliprect.min_y; cury <= cliprect.max_y; cury++) \ + for (cury = cliprect.min_y; cury <= cliprect.max_y; cury++) \ { \ PRIORITY_TYPE *priptr = PRIORITY_ADDR(priority, PRIORITY_TYPE, cury, cliprect.min_x); \ PIXEL_TYPE *destptr = &dest.pixt(cury, cliprect.min_x); \ const PIXEL_TYPE *srcptr; \ - int32_t srcx = startx; \ - int32_t srcy = starty; \ + s32 srcx = startx; \ + s32 srcy = starty; \ \ startx = (startx + incyx) & srcfixwidth; \ starty = (starty + incyy) & srcfixheight; \ @@ -1146,7 +1146,7 @@ do { } \ } \ } \ - g_profiler.stop(); \ + g_profiler.stop(); \ } while (0) @@ -1159,9 +1159,9 @@ do { Assumed input parameters or local variables: bitmap_t &bitmap - the bitmap to copy to - int32_t destx - the X coordinate to copy to - int32_t desty - the Y coordinate to copy to - int32_t length - the total number of pixels to copy + s32 destx - the X coordinate to copy to + s32 desty - the Y coordinate to copy to + s32 length - the total number of pixels to copy const UINTx *srcptr - pointer to memory containing the source pixels bitmap_t &priority - the priority bitmap (even if PRIORITY_TYPE is NO_PRIORITY, at least needs a dummy) */ @@ -1172,8 +1172,8 @@ do { assert(destx >= 0); \ assert(destx + length <= bitmap.width()); \ assert(desty >= 0); \ - assert(desty < bitmap.height()); \ - assert(srcptr != nullptr); \ + assert(desty < bitmap.height()); \ + assert(srcptr != nullptr); \ assert(!PRIORITY_VALID(PRIORITY_TYPE) || priority.valid()); \ \ { \ @@ -1215,9 +1215,9 @@ do { Assumed input parameters: bitmap_t &bitmap - the bitmap to extract from - int32_t srcx - the X coordinate to begin extraction - int32_t srcy - the Y coordinate to begin extraction - int32_t length - the total number of pixels to extract + s32 srcx - the X coordinate to begin extraction + s32 srcy - the Y coordinate to begin extraction + s32 length - the total number of pixels to extract UINTx *destptr - pointer to memory to receive the extracted pixels */ @@ -1227,8 +1227,8 @@ do { assert(srcx >= 0); \ assert(srcx + length <= bitmap.width()); \ assert(srcy >= 0); \ - assert(srcy < bitmap.height()); \ - assert(destptr != nullptr); \ + assert(srcy < bitmap.height()); \ + assert(destptr != nullptr); \ \ { \ const PIXEL_TYPE *srcptr = &bitmap.pixt(srcy, srcx); \ diff --git a/src/emu/drivenum.cpp b/src/emu/drivenum.cpp index 4f111d35f0f..a23db4c54bc 100644 --- a/src/emu/drivenum.cpp +++ b/src/emu/drivenum.cpp @@ -92,7 +92,7 @@ int driver_list::penalty_compare(const char *source, const char *target) for ( ; *source && *target; target++) { // do a case insensitive match - bool match = (tolower((uint8_t)*source) == tolower((uint8_t)*target)); + bool const match(tolower(u8(*source)) == tolower(u8(*target))); // if we matched, advance the source if (match) diff --git a/src/emu/driver.cpp b/src/emu/driver.cpp index a954738a557..51b6b629544 100644 --- a/src/emu/driver.cpp +++ b/src/emu/driver.cpp @@ -257,7 +257,7 @@ void driver_device::device_reset_after_children() // irq_pulse_clear - clear a "pulsed" IRQ line //------------------------------------------------- -void driver_device::irq_pulse_clear(void *ptr, int32_t param) +void driver_device::irq_pulse_clear(void *ptr, s32 param) { device_execute_interface *exec = reinterpret_cast(ptr); int irqline = param; @@ -366,7 +366,7 @@ void driver_device::updateflip() // flip_screen_set - set global flip //------------------------------------------------- -void driver_device::flip_screen_set(uint32_t on) +void driver_device::flip_screen_set(u32 on) { // normalize to all 1 if (on) @@ -386,7 +386,7 @@ void driver_device::flip_screen_set(uint32_t on) // do not call updateflip. //------------------------------------------------- -void driver_device::flip_screen_set_no_update(uint32_t on) +void driver_device::flip_screen_set_no_update(u32 on) { // flip_screen_y is not updated on purpose // this function is for drivers which @@ -402,7 +402,7 @@ void driver_device::flip_screen_set_no_update(uint32_t on) // flip_screen_x_set - set global horizontal flip //------------------------------------------------- -void driver_device::flip_screen_x_set(uint32_t on) +void driver_device::flip_screen_x_set(u32 on) { // normalize to all 1 if (on) @@ -421,7 +421,7 @@ void driver_device::flip_screen_x_set(uint32_t on) // flip_screen_y_set - set global vertical flip //------------------------------------------------- -void driver_device::flip_screen_y_set(uint32_t on) +void driver_device::flip_screen_y_set(u32 on) { // normalize to all 1 if (on) diff --git a/src/emu/driver.h b/src/emu/driver.h index 74205f57af3..f130b74d6bd 100644 --- a/src/emu/driver.h +++ b/src/emu/driver.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __DRIVER_H__ -#define __DRIVER_H__ +#ifndef MAME_EMU_DRIVER_H +#define MAME_EMU_DRIVER_H //************************************************************************** @@ -180,13 +180,13 @@ public: // generic video - void flip_screen_set(uint32_t on); - void flip_screen_set_no_update(uint32_t on); - void flip_screen_x_set(uint32_t on); - void flip_screen_y_set(uint32_t on); - uint32_t flip_screen() const { return m_flip_screen_x; } - uint32_t flip_screen_x() const { return m_flip_screen_x; } - uint32_t flip_screen_y() const { return m_flip_screen_y; } + void flip_screen_set(u32 on); + void flip_screen_set_no_update(u32 on); + void flip_screen_x_set(u32 on); + void flip_screen_y_set(u32 on); + u32 flip_screen() const { return m_flip_screen_x; } + u32 flip_screen_x() const { return m_flip_screen_x; } + u32 flip_screen_y() const { return m_flip_screen_y; } // generic input port helpers DECLARE_CUSTOM_INPUT_MEMBER( custom_port_read ); @@ -212,22 +212,22 @@ protected: private: // helpers - void irq_pulse_clear(void *ptr, int32_t param); + void irq_pulse_clear(void *ptr, s32 param); void updateflip(); // internal state - const game_driver * m_system; // pointer to the game driver - driver_callback_delegate m_callbacks[CB_COUNT]; // start/reset callbacks + const game_driver * m_system; // pointer to the game driver + driver_callback_delegate m_callbacks[CB_COUNT]; // start/reset callbacks // generic video - uint8_t m_flip_screen_x; - uint8_t m_flip_screen_y; + u8 m_flip_screen_x; + u8 m_flip_screen_y; }; // this template function creates a stub which constructs a device template -device_t *driver_device_creator(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +device_t *driver_device_creator(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) { assert(owner == nullptr); assert(clock == 0); @@ -235,4 +235,4 @@ device_t *driver_device_creator(const machine_config &mconfig, const char *tag, } -#endif /* __DRIVER_H__ */ +#endif /* MAME_EMU_DRIVER_H */ diff --git a/src/emu/drivers/empty.cpp b/src/emu/drivers/empty.cpp index 65e0821a8fa..074171074ce 100644 --- a/src/emu/drivers/empty.cpp +++ b/src/emu/drivers/empty.cpp @@ -30,7 +30,7 @@ public: emulator_info::display_ui_chooser(machine()); } - uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) + u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { bitmap.fill(rgb_t::black(), cliprect); return 0; diff --git a/src/emu/drivers/emudummy.cpp b/src/emu/drivers/emudummy.cpp deleted file mode 100644 index 948be2f2987..00000000000 --- a/src/emu/drivers/emudummy.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles -/*************************************************************************** - - emudummy.c - - Dummy driver file that references CPU devices which are in turn - referenced by devices in libemu.a. - - The reason we need this is due to link ordering issues with gcc - if the actual drivers being linked don't reference these CPU - devices. Since we link libcpu first, if libemu needs stuff from - libcpu that wasn't previously referenced, it will fail the link. - -***************************************************************************/ - -#include "emu.h" -#include "cpu/mcs48/mcs48.h" -#include "cpu/z80/z80.h" - - -MACHINE_CONFIG_START( __dummy, driver_device ) - MCFG_CPU_ADD("dummy1", I8049, 1000000) - MCFG_CPU_ADD("dummy2", I8748, 1000000) - MCFG_CPU_ADD("dummy3", Z80, 1000000) -MACHINE_CONFIG_END - - -ROM_START( __dummy ) - ROM_REGION( 0x1000, "dummy1", ROMREGION_ERASEFF ) - ROM_REGION( 0x1000, "dummy2", ROMREGION_ERASEFF ) - ROM_REGION( 0x1000, "dummy3", ROMREGION_ERASEFF ) -ROM_END - - -GAME( 1900, __dummy, 0, __dummy, 0, driver_device, 0, ROT0, "(none)", "Dummy", MACHINE_NO_SOUND ) diff --git a/src/emu/drivers/testcpu.cpp b/src/emu/drivers/testcpu.cpp index c52222f6e1a..963ce923fbb 100644 --- a/src/emu/drivers/testcpu.cpp +++ b/src/emu/drivers/testcpu.cpp @@ -40,7 +40,7 @@ public: // timer callback; used to wrest control of the system virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override { - static const uint32_t sample_instructions[] = + static const u32 sample_instructions[] = { 0x3d40f900, // li r10,0xf9000000 0x394af000, // addi r10,r10,-0x1000 @@ -108,7 +108,7 @@ public: void dump_state(bool disassemble) { char buffer[256]; - uint8_t instruction[32]; + u8 instruction[32]; buffer[0] = 0; int bytes = 0; if (disassemble) @@ -123,7 +123,7 @@ public: } // output the registers - printf("PC : %08X", uint32_t(m_cpu->state_int(PPC_PC))); + printf("PC : %08X", u32(m_cpu->state_int(PPC_PC))); if (disassemble && bytes > 0) { printf(" => "); @@ -134,12 +134,12 @@ public: printf("\n"); for (int regnum = 0; regnum < 32; regnum++) { - printf("R%-2d: %08X ", regnum, uint32_t(m_cpu->state_int(PPC_R0 + regnum))); + printf("R%-2d: %08X ", regnum, u32(m_cpu->state_int(PPC_R0 + regnum))); if (regnum % 4 == 3) printf("\n"); } printf("CR : %08X LR : %08X CTR: %08X XER: %08X\n", - uint32_t(m_cpu->state_int(PPC_CR)), uint32_t(m_cpu->state_int(PPC_LR)), - uint32_t(m_cpu->state_int(PPC_CTR)), uint32_t(m_cpu->state_int(PPC_XER))); + u32(m_cpu->state_int(PPC_CR)), u32(m_cpu->state_int(PPC_LR)), + u32(m_cpu->state_int(PPC_CTR)), u32(m_cpu->state_int(PPC_XER))); for (int regnum = 0; regnum < 32; regnum++) { printf("F%-2d: %10g ", regnum, u2d(m_cpu->state_int(PPC_F0 + regnum))); @@ -150,8 +150,8 @@ public: // report reads from anywhere READ64_MEMBER( general_r ) { - uint64_t fulloffs = offset; - uint64_t result = fulloffs + (fulloffs << 8) + (fulloffs << 16) + (fulloffs << 24) + (fulloffs << 32); + u64 fulloffs = offset; + u64 result = fulloffs + (fulloffs << 8) + (fulloffs << 16) + (fulloffs << 24) + (fulloffs << 32); printf("Read from %08X & %08X%08X = %08X%08X\n", offset * 8, (int)((mem_mask&0xffffffff00000000LL) >> 32) , (int)(mem_mask&0xffffffff), (int)((result&0xffffffff00000000LL) >> 32), (int)(result&0xffffffff)); return result; } @@ -165,7 +165,7 @@ public: private: // internal state required_device m_cpu; - required_shared_ptr m_ram; + required_shared_ptr m_ram; address_space *m_space; }; diff --git a/src/emu/drivers/xtal.h b/src/emu/drivers/xtal.h index 01c232cf2fa..4f370d315cd 100644 --- a/src/emu/drivers/xtal.h +++ b/src/emu/drivers/xtal.h @@ -39,6 +39,11 @@ **************************************************************************/ +#ifndef MAME_EMU_DRIVERS_XTAL_H +#define MAME_EMU_DRIVERS_XTAL_H + +#pragma once + enum { /* @@ -618,3 +623,5 @@ reveals the following shipping frequencies as of 1/1/2008: 100.00MHz */ + +#endif // MAME_EMU_DRIVERS_XTAL_H diff --git a/src/emu/emualloc.cpp b/src/emu/emualloc.cpp index 7d87dad0a28..3993121e9bc 100644 --- a/src/emu/emualloc.cpp +++ b/src/emu/emualloc.cpp @@ -23,7 +23,7 @@ // GLOBALS //************************************************************************** -uint64_t resource_pool::s_id = 0; +osd::u64 resource_pool::s_id = 0; @@ -75,7 +75,7 @@ void resource_pool::add(resource_pool_item &item, size_t size, const char *type) // before, so if we don't find it, check 4 bytes ahead item.m_id = ++s_id; if (LOG_ALLOCS) - fprintf(stderr, "#%06d, add %s, %d bytes\n", (uint32_t)item.m_id, type, uint32_t(size)); + fprintf(stderr, "#%06d, add %s, %d bytes\n", u32(item.m_id), type, u32(size)); // find the entry to insert after resource_pool_item *insert_after; @@ -143,7 +143,7 @@ void resource_pool::remove(void *ptr) // delete the object and break if (LOG_ALLOCS) - fprintf(stderr, "#%06d, delete %d bytes\n", (uint32_t)deleteme->m_id, static_cast(deleteme->m_size)); + fprintf(stderr, "#%06d, delete %d bytes\n", u32(deleteme->m_id), u32(deleteme->m_size)); global_free(deleteme); break; } @@ -177,8 +177,8 @@ resource_pool_item *resource_pool::find(void *ptr) bool resource_pool::contains(void *_ptrstart, void *_ptrend) { - uint8_t *ptrstart = reinterpret_cast(_ptrstart); - uint8_t *ptrend = reinterpret_cast(_ptrend); + u8 *ptrstart = reinterpret_cast(_ptrstart); + u8 *ptrend = reinterpret_cast(_ptrend); // search for the item std::lock_guard lock(m_listlock); @@ -186,8 +186,8 @@ bool resource_pool::contains(void *_ptrstart, void *_ptrend) resource_pool_item *item = nullptr; for (item = m_ordered_head; item != nullptr; item = item->m_ordered_next) { - uint8_t *objstart = reinterpret_cast(item->m_ptr); - uint8_t *objend = objstart + item->m_size; + u8 *objstart = reinterpret_cast(item->m_ptr); + u8 *objend = objstart + item->m_size; if (ptrstart >= objstart && ptrend <= objend) return true; } diff --git a/src/emu/emualloc.h b/src/emu/emualloc.h index 44e39e199ad..77fcd92c1b1 100644 --- a/src/emu/emualloc.h +++ b/src/emu/emualloc.h @@ -10,8 +10,8 @@ #pragma once -#ifndef __EMUALLOC_H__ -#define __EMUALLOC_H__ +#ifndef MAME_EMU_EMUALLOC_H +#define MAME_EMU_EMUALLOC_H #include #include @@ -49,7 +49,7 @@ public: m_ordered_prev(nullptr), m_ptr(ptr), m_size(size), - m_id(~(uint64_t)0) { } + m_id(~osd::u64(0)) { } virtual ~resource_pool_item() { } resource_pool_item * m_next; @@ -57,7 +57,7 @@ public: resource_pool_item * m_ordered_prev; void * m_ptr; size_t m_size; - uint64_t m_id; + osd::u64 m_id; }; @@ -129,8 +129,8 @@ private: std::vector m_hash; resource_pool_item * m_ordered_head; resource_pool_item * m_ordered_tail; - static uint64_t s_id; + static osd::u64 s_id; }; -#endif /* __EMUALLOC_H__ */ +#endif /* MAME_EMU_EMUALLOC_H */ diff --git a/src/emu/emucore.h b/src/emu/emucore.h index b3c4bebfbba..f1f5bbda2d4 100644 --- a/src/emu/emucore.h +++ b/src/emu/emucore.h @@ -55,14 +55,24 @@ // FUNDAMENTAL TYPES //************************************************************************** +// explicitly sized integers +using osd::u8; +using osd::u16; +using osd::u32; +using osd::u64; +using osd::s8; +using osd::s16; +using osd::s32; +using osd::s64; + // genf is a generic function pointer; cast function pointers to this instead of void * typedef void genf(void); // pen_t is used to represent pixel values in bitmaps -typedef uint32_t pen_t; +typedef u32 pen_t; // stream_sample_t is used to represent a single sample in a sound stream -typedef int32_t stream_sample_t; +typedef s32 stream_sample_t; // running_machine is core to pretty much everything class running_machine; @@ -73,38 +83,22 @@ class running_machine; // USEFUL COMPOSITE TYPES //************************************************************************** -// generic_ptr is a union of pointers to various sizes -union generic_ptr -{ - generic_ptr(void *value) { v = value; } - void * v; - int8_t * i8; - uint8_t * u8; - int16_t * i16; - uint16_t * u16; - int32_t * i32; - uint32_t * u32; - int64_t * i64; - uint64_t * u64; -}; - - // PAIR is an endian-safe union useful for representing 32-bit CPU registers union PAIR { #ifdef LSB_FIRST - struct { uint8_t l,h,h2,h3; } b; - struct { uint16_t l,h; } w; - struct { int8_t l,h,h2,h3; } sb; - struct { int16_t l,h; } sw; + struct { u8 l,h,h2,h3; } b; + struct { u16 l,h; } w; + struct { s8 l,h,h2,h3; } sb; + struct { s16 l,h; } sw; #else - struct { uint8_t h3,h2,h,l; } b; - struct { int8_t h3,h2,h,l; } sb; - struct { uint16_t h,l; } w; - struct { int16_t h,l; } sw; + struct { u8 h3,h2,h,l; } b; + struct { s8 h3,h2,h,l; } sb; + struct { u16 h,l; } w; + struct { s16 h,l; } sw; #endif - uint32_t d; - int32_t sd; + u32 d; + s32 sd; }; @@ -112,14 +106,14 @@ union PAIR union PAIR16 { #ifdef LSB_FIRST - struct { uint8_t l,h; } b; - struct { int8_t l,h; } sb; + struct { u8 l,h; } b; + struct { s8 l,h; } sb; #else - struct { uint8_t h,l; } b; - struct { int8_t h,l; } sb; + struct { u8 h,l; } b; + struct { s8 h,l; } sb; #endif - uint16_t w; - int16_t sw; + u16 w; + s16 sw; }; @@ -127,22 +121,22 @@ union PAIR16 union PAIR64 { #ifdef LSB_FIRST - struct { uint8_t l,h,h2,h3,h4,h5,h6,h7; } b; - struct { uint16_t l,h,h2,h3; } w; - struct { uint32_t l,h; } d; - struct { int8_t l,h,h2,h3,h4,h5,h6,h7; } sb; - struct { int16_t l,h,h2,h3; } sw; - struct { int32_t l,h; } sd; + struct { u8 l,h,h2,h3,h4,h5,h6,h7; } b; + struct { u16 l,h,h2,h3; } w; + struct { u32 l,h; } d; + struct { s8 l,h,h2,h3,h4,h5,h6,h7; } sb; + struct { s16 l,h,h2,h3; } sw; + struct { s32 l,h; } sd; #else - struct { uint8_t h7,h6,h5,h4,h3,h2,h,l; } b; - struct { uint16_t h3,h2,h,l; } w; - struct { uint32_t h,l; } d; - struct { int8_t h7,h6,h5,h4,h3,h2,h,l; } sb; - struct { int16_t h3,h2,h,l; } sw; - struct { int32_t h,l; } sd; + struct { u8 h7,h6,h5,h4,h3,h2,h,l; } b; + struct { u16 h3,h2,h,l; } w; + struct { u32 h,l; } d; + struct { s8 h7,h6,h5,h4,h3,h2,h,l; } sb; + struct { s16 h3,h2,h,l; } sw; + struct { s32 h,l; } sd; #endif - uint64_t q; - int64_t sq; + u64 q; + s64 sq; }; @@ -380,7 +374,7 @@ enum_value(T value) noexcept // population count #if !defined(__NetBSD__) -inline int popcount(uint32_t val) +inline int popcount(u32 val) { int count; @@ -392,11 +386,11 @@ inline int popcount(uint32_t val) // convert a series of 32 bits into a float -inline float u2f(uint32_t v) +inline float u2f(u32 v) { union { float ff; - uint32_t vv; + u32 vv; } u; u.vv = v; return u.ff; @@ -404,11 +398,11 @@ inline float u2f(uint32_t v) // convert a float into a series of 32 bits -inline uint32_t f2u(float f) +inline u32 f2u(float f) { union { float ff; - uint32_t vv; + u32 vv; } u; u.ff = f; return u.vv; @@ -416,11 +410,11 @@ inline uint32_t f2u(float f) // convert a series of 64 bits into a double -inline double u2d(uint64_t v) +inline double u2d(u64 v) { union { double dd; - uint64_t vv; + u64 vv; } u; u.vv = v; return u.dd; @@ -428,11 +422,11 @@ inline double u2d(uint64_t v) // convert a double into a series of 64 bits -inline uint64_t d2u(double d) +inline u64 d2u(double d) { union { double dd; - uint64_t vv; + u64 vv; } u; u.dd = d; return u.vv; diff --git a/src/emu/emumem.cpp b/src/emu/emumem.cpp index 0deab9d74a4..af4b1f8883d 100644 --- a/src/emu/emumem.cpp +++ b/src/emu/emumem.cpp @@ -198,14 +198,14 @@ core_i64_hex_format - i64 format printf helper -------------------------------------------------*/ -static char *core_i64_hex_format(uint64_t value, uint8_t mindigits) +static char *core_i64_hex_format(u64 value, u8 mindigits) { static char buffer[16][64]; // TODO: this can overflow - e.g. when a lot of unmapped writes are logged static int index; char *bufbase = &buffer[index++ % 16][0]; char *bufptr = bufbase; - int8_t curdigit; + s8 curdigit; for (curdigit = 15; curdigit >= 0; curdigit--) { @@ -263,7 +263,7 @@ class handler_entry protected: // construction/destruction - handler_entry(uint8_t width, endianness_t endianness, uint8_t **rambaseptr); + handler_entry(u8 width, endianness_t endianness, u8 **rambaseptr); virtual ~handler_entry(); public: @@ -282,7 +282,7 @@ public: offs_t byteoffset(offs_t byteaddress) const { return (byteaddress - m_bytestart) & m_bytemask; } // return a pointer to the backing RAM at the given offset - uint8_t *ramptr(offs_t offset = 0) const { return *m_rambaseptr + offset; } + u8 *ramptr(offs_t offset = 0) const { return *m_rambaseptr + offset; } // see if we are an exact match to the given parameters bool matches_exactly(offs_t bytestart, offs_t byteend, offs_t bytemask) const @@ -328,36 +328,36 @@ public: // apply a global mask void apply_mask(offs_t bytemask) { m_bytemask &= bytemask; } - void clear_conflicting_subunits(uint64_t handlermask); - bool overriden_by_mask(uint64_t handlermask); + void clear_conflicting_subunits(u64 handlermask); + bool overriden_by_mask(u64 handlermask); protected: // Subunit description information struct subunit_info { offs_t m_bytemask; // bytemask for this subunit - uint32_t m_mask; // mask (ff, ffff or ffffffff) - int32_t m_offset; // offset to add to the address - uint32_t m_multiplier; // multiplier to the pre-split address - uint8_t m_size; // size (8, 16 or 32) - uint8_t m_shift; // shift of the subunit + u32 m_mask; // mask (ff, ffff or ffffffff) + s32 m_offset; // offset to add to the address + u32 m_multiplier; // multiplier to the pre-split address + u8 m_size; // size (8, 16 or 32) + u8 m_shift; // shift of the subunit }; // internal helpers - void configure_subunits(uint64_t handlermask, int handlerbits, int &start_slot, int &end_slot); + void configure_subunits(u64 handlermask, int handlerbits, int &start_slot, int &end_slot); virtual void remove_subunit(int entry) = 0; // internal state bool m_populated; // populated? - uint8_t m_datawidth; + u8 m_datawidth; endianness_t m_endianness; offs_t m_bytestart; // byte-adjusted start address for handler offs_t m_byteend; // byte-adjusted end address for handler offs_t m_bytemask; // byte-adjusted mask against the final address - uint8_t ** m_rambaseptr; // pointer to the bank base - uint8_t m_subunits; // for width stubs, the number of subunits + u8 ** m_rambaseptr; // pointer to the bank base + u8 m_subunits; // for width stubs, the number of subunits subunit_info m_subunit_infos[8]; // for width stubs, the associated subunit info - uint64_t m_invsubmask; // inverted mask of the populated subunits + u64 m_invsubmask; // inverted mask of the populated subunits }; @@ -377,7 +377,7 @@ public: }; // construction/destruction - handler_entry_read(uint8_t width, endianness_t endianness, uint8_t **rambaseptr) + handler_entry_read(u8 width, endianness_t endianness, u8 **rambaseptr) : handler_entry(width, endianness, rambaseptr), m_ioport(nullptr) { @@ -390,25 +390,25 @@ public: virtual const char *subunit_name(int entry) const override; // configure delegate callbacks - void set_delegate(read8_delegate delegate, uint64_t mask = 0); - void set_delegate(read16_delegate delegate, uint64_t mask = 0); - void set_delegate(read32_delegate delegate, uint64_t mask = 0); - void set_delegate(read64_delegate delegate, uint64_t mask = 0); + void set_delegate(read8_delegate delegate, u64 mask = 0); + void set_delegate(read16_delegate delegate, u64 mask = 0); + void set_delegate(read32_delegate delegate, u64 mask = 0); + void set_delegate(read64_delegate delegate, u64 mask = 0); // configure I/O port access void set_ioport(ioport_port &ioport); // read via the underlying delegates - uint8_t read8(address_space &space, offs_t offset, uint8_t mask) const { return m_read.r8(space, offset, mask); } - uint16_t read16(address_space &space, offs_t offset, uint16_t mask) const { return m_read.r16(space, offset, mask); } - uint32_t read32(address_space &space, offs_t offset, uint32_t mask) const { return m_read.r32(space, offset, mask); } - uint64_t read64(address_space &space, offs_t offset, uint64_t mask) const { return m_read.r64(space, offset, mask); } + u8 read8(address_space &space, offs_t offset, u8 mask) const { return m_read.r8(space, offset, mask); } + u16 read16(address_space &space, offs_t offset, u16 mask) const { return m_read.r16(space, offset, mask); } + u32 read32(address_space &space, offs_t offset, u32 mask) const { return m_read.r32(space, offset, mask); } + u64 read64(address_space &space, offs_t offset, u64 mask) const { return m_read.r64(space, offset, mask); } private: // stubs for converting between address sizes - uint16_t read_stub_16(address_space &space, offs_t offset, uint16_t mask); - uint32_t read_stub_32(address_space &space, offs_t offset, uint32_t mask); - uint64_t read_stub_64(address_space &space, offs_t offset, uint64_t mask); + u16 read_stub_16(address_space &space, offs_t offset, u16 mask); + u32 read_stub_32(address_space &space, offs_t offset, u32 mask); + u64 read_stub_64(address_space &space, offs_t offset, u64 mask); // stubs for reading I/O ports template @@ -440,7 +440,7 @@ public: }; // construction/destruction - handler_entry_write(uint8_t width, endianness_t endianness, uint8_t **rambaseptr) + handler_entry_write(u8 width, endianness_t endianness, u8 **rambaseptr) : handler_entry(width, endianness, rambaseptr), m_ioport(nullptr) { @@ -453,25 +453,25 @@ public: virtual const char *subunit_name(int entry) const override; // configure delegate callbacks - void set_delegate(write8_delegate delegate, uint64_t mask = 0); - void set_delegate(write16_delegate delegate, uint64_t mask = 0); - void set_delegate(write32_delegate delegate, uint64_t mask = 0); - void set_delegate(write64_delegate delegate, uint64_t mask = 0); + void set_delegate(write8_delegate delegate, u64 mask = 0); + void set_delegate(write16_delegate delegate, u64 mask = 0); + void set_delegate(write32_delegate delegate, u64 mask = 0); + void set_delegate(write64_delegate delegate, u64 mask = 0); // configure I/O port access void set_ioport(ioport_port &ioport); // write via the underlying delegates - void write8(address_space &space, offs_t offset, uint8_t data, uint8_t mask) const { m_write.w8(space, offset, data, mask); } - void write16(address_space &space, offs_t offset, uint16_t data, uint16_t mask) const { m_write.w16(space, offset, data, mask); } - void write32(address_space &space, offs_t offset, uint32_t data, uint32_t mask) const { m_write.w32(space, offset, data, mask); } - void write64(address_space &space, offs_t offset, uint64_t data, uint64_t mask) const { m_write.w64(space, offset, data, mask); } + void write8(address_space &space, offs_t offset, u8 data, u8 mask) const { m_write.w8(space, offset, data, mask); } + void write16(address_space &space, offs_t offset, u16 data, u16 mask) const { m_write.w16(space, offset, data, mask); } + void write32(address_space &space, offs_t offset, u32 data, u32 mask) const { m_write.w32(space, offset, data, mask); } + void write64(address_space &space, offs_t offset, u64 data, u64 mask) const { m_write.w64(space, offset, data, mask); } private: // stubs for converting between address sizes - void write_stub_16(address_space &space, offs_t offset, uint16_t data, uint16_t mask); - void write_stub_32(address_space &space, offs_t offset, uint32_t data, uint32_t mask); - void write_stub_64(address_space &space, offs_t offset, uint64_t data, uint64_t mask); + void write_stub_16(address_space &space, offs_t offset, u16 data, u16 mask); + void write_stub_32(address_space &space, offs_t offset, u32 data, u32 mask); + void write_stub_64(address_space &space, offs_t offset, u64 data, u64 mask); // stubs for writing I/O ports template @@ -505,7 +505,7 @@ public: void setoffset(address_space &space, offs_t offset) const { if (m_setoffset.has_object()) m_setoffset(space, offset); } // configure delegate callbacks - void set_delegate(setoffset_delegate delegate, uint64_t mask = 0) { m_setoffset = delegate; } + void set_delegate(setoffset_delegate delegate, u64 mask = 0) { m_setoffset = delegate; } private: setoffset_delegate m_setoffset; @@ -522,7 +522,7 @@ template class handler_entry_proxy { public: - handler_entry_proxy(std::list<_HandlerEntry *> _handlers, uint64_t _mask) : handlers(std::move(_handlers)), mask(_mask) {} + handler_entry_proxy(std::list<_HandlerEntry *> _handlers, u64 _mask) : handlers(std::move(_handlers)), mask(_mask) {} handler_entry_proxy(const handler_entry_proxy<_HandlerEntry> &hep) : handlers(hep.handlers), mask(hep.mask) {} // forward delegate callbacks configuration @@ -539,7 +539,7 @@ public: private: std::list<_HandlerEntry *> handlers; - uint64_t mask; + u64 mask; }; @@ -564,35 +564,35 @@ public: virtual ~address_table(); // getters - virtual handler_entry &handler(uint32_t index) const = 0; + virtual handler_entry &handler(u32 index) const = 0; bool watchpoints_enabled() const { return (m_live_lookup == s_watchpoint_table); } // address lookups - uint32_t lookup_live(offs_t byteaddress) const { return m_large ? lookup_live_large(byteaddress) : lookup_live_small(byteaddress); } - uint32_t lookup_live_small(offs_t byteaddress) const { return m_live_lookup[byteaddress]; } + u32 lookup_live(offs_t byteaddress) const { return m_large ? lookup_live_large(byteaddress) : lookup_live_small(byteaddress); } + u32 lookup_live_small(offs_t byteaddress) const { return m_live_lookup[byteaddress]; } - uint32_t lookup_live_large(offs_t byteaddress) const + u32 lookup_live_large(offs_t byteaddress) const { - uint32_t entry = m_live_lookup[level1_index_large(byteaddress)]; + u32 entry = m_live_lookup[level1_index_large(byteaddress)]; if (entry >= SUBTABLE_BASE) entry = m_live_lookup[level2_index_large(entry, byteaddress)]; return entry; } - uint32_t lookup_live_nowp(offs_t byteaddress) const { return m_large ? lookup_live_large_nowp(byteaddress) : lookup_live_small_nowp(byteaddress); } - uint32_t lookup_live_small_nowp(offs_t byteaddress) const { return m_table[byteaddress]; } + u32 lookup_live_nowp(offs_t byteaddress) const { return m_large ? lookup_live_large_nowp(byteaddress) : lookup_live_small_nowp(byteaddress); } + u32 lookup_live_small_nowp(offs_t byteaddress) const { return m_table[byteaddress]; } - uint32_t lookup_live_large_nowp(offs_t byteaddress) const + u32 lookup_live_large_nowp(offs_t byteaddress) const { - uint32_t entry = m_table[level1_index_large(byteaddress)]; + u32 entry = m_table[level1_index_large(byteaddress)]; if (entry >= SUBTABLE_BASE) entry = m_table[level2_index_large(entry, byteaddress)]; return entry; } - uint32_t lookup(offs_t byteaddress) const + u32 lookup(offs_t byteaddress) const { - uint32_t entry = m_live_lookup[level1_index(byteaddress)]; + u32 entry = m_live_lookup[level1_index(byteaddress)]; if (entry >= SUBTABLE_BASE) entry = m_live_lookup[level2_index(entry, byteaddress)]; return entry; @@ -602,37 +602,37 @@ public: void enable_watchpoints(bool enable = true) { m_live_lookup = enable ? s_watchpoint_table : &m_table[0]; } // table mapping helpers - void map_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, uint16_t staticentry); - void setup_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, uint64_t mask, std::list &entries); - uint16_t derive_range(offs_t byteaddress, offs_t &bytestart, offs_t &byteend) const; + void map_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, u16 staticentry); + void setup_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, u64 mask, std::list &entries); + u16 derive_range(offs_t byteaddress, offs_t &bytestart, offs_t &byteend) const; // misc helpers void mask_all_handlers(offs_t mask); - const char *handler_name(uint16_t entry) const; + const char *handler_name(u16 entry) const; protected: // determine table indexes based on the address - uint32_t level1_index_large(offs_t address) const { return address >> LEVEL2_BITS; } - uint32_t level2_index_large(uint16_t l1entry, offs_t address) const { return (1 << LEVEL1_BITS) + ((l1entry - SUBTABLE_BASE) << LEVEL2_BITS) + (address & ((1 << LEVEL2_BITS) - 1)); } - uint32_t level1_index(offs_t address) const { return m_large ? level1_index_large(address) : address; } - uint32_t level2_index(uint16_t l1entry, offs_t address) const { return m_large ? level2_index_large(l1entry, address) : 0; } + u32 level1_index_large(offs_t address) const { return address >> LEVEL2_BITS; } + u32 level2_index_large(u16 l1entry, offs_t address) const { return (1 << LEVEL1_BITS) + ((l1entry - SUBTABLE_BASE) << LEVEL2_BITS) + (address & ((1 << LEVEL2_BITS) - 1)); } + u32 level1_index(offs_t address) const { return m_large ? level1_index_large(address) : address; } + u32 level2_index(u16 l1entry, offs_t address) const { return m_large ? level2_index_large(l1entry, address) : 0; } // table population/depopulation - void populate_range_mirrored(offs_t bytestart, offs_t byteend, offs_t bytemirror, uint16_t handler); - void populate_range(offs_t bytestart, offs_t byteend, uint16_t handler); + void populate_range_mirrored(offs_t bytestart, offs_t byteend, offs_t bytemirror, u16 handler); + void populate_range(offs_t bytestart, offs_t byteend, u16 handler); // subtable management - uint16_t subtable_alloc(); - void subtable_realloc(uint16_t subentry); + u16 subtable_alloc(); + void subtable_realloc(u16 subentry); int subtable_merge(); - void subtable_release(uint16_t subentry); - uint16_t *subtable_open(offs_t l1index); + void subtable_release(u16 subentry); + u16 *subtable_open(offs_t l1index); void subtable_close(offs_t l1index); - uint16_t *subtable_ptr(uint16_t entry) { return &m_table[level2_index(entry, 0)]; } + u16 *subtable_ptr(u16 entry) { return &m_table[level2_index(entry, 0)]; } // internal state - std::vector m_table; // pointer to base of table - uint16_t * m_live_lookup; // current lookup + std::vector m_table; // pointer to base of table + u16 * m_live_lookup; // current lookup address_space & m_space; // pointer back to the space bool m_large; // large memory model? @@ -646,32 +646,32 @@ protected: m_usecount(0) { } bool m_checksum_valid; // is the checksum valid - uint32_t m_checksum; // checksum over all the bytes - uint32_t m_usecount; // number of times this has been used + u32 m_checksum; // checksum over all the bytes + u32 m_usecount; // number of times this has been used }; std::vector m_subtable; // info about each subtable - uint16_t m_subtable_alloc; // number of subtables allocated + u16 m_subtable_alloc; // number of subtables allocated // static global read-only watchpoint table - static uint16_t s_watchpoint_table[1 << LEVEL1_BITS]; + static u16 s_watchpoint_table[1 << LEVEL1_BITS]; private: int handler_refcount[SUBTABLE_BASE-STATIC_COUNT]; - uint16_t handler_next_free[SUBTABLE_BASE-STATIC_COUNT]; - uint16_t handler_free; - uint16_t get_free_handler(); + u16 handler_next_free[SUBTABLE_BASE-STATIC_COUNT]; + u16 handler_free; + u16 get_free_handler(); void verify_reference_counts(); - void setup_range_solid(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, std::list &entries); - void setup_range_masked(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, uint64_t mask, std::list &entries); + void setup_range_solid(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, std::list &entries); + void setup_range_masked(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, u64 mask, std::list &entries); - void handler_ref(uint16_t entry, int count) + void handler_ref(u16 entry, int count) { assert(entry < SUBTABLE_BASE); if (entry >= STATIC_COUNT) handler_refcount[entry - STATIC_COUNT] += count; } - void handler_unref(uint16_t entry) + void handler_unref(u16 entry) { assert(entry < SUBTABLE_BASE); if (entry >= STATIC_COUNT) @@ -696,15 +696,15 @@ public: virtual ~address_table_read(); // getters - virtual handler_entry &handler(uint32_t index) const override; - handler_entry_read &handler_read(uint32_t index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } + virtual handler_entry &handler(u32 index) const override; + handler_entry_read &handler_read(u32 index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } // range getter - handler_entry_proxy handler_map_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, uint64_t mask = 0) { - std::list entries; + handler_entry_proxy handler_map_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, u64 mask = 0) { + std::list entries; setup_range(bytestart, byteend, bytemask, bytemirror, mask, entries); std::list handlers; - for (std::list::const_iterator i = entries.begin(); i != entries.end(); ++i) + for (std::list::const_iterator i = entries.begin(); i != entries.end(); ++i) handlers.push_back(&handler_read(*i)); return handler_entry_proxy(handlers, mask); } @@ -740,7 +740,7 @@ private: { m_space.device().debug()->memory_read_hook(m_space, offset * sizeof(_UintType), mask); - uint16_t *oldtable = m_live_lookup; + u16 *oldtable = m_live_lookup; m_live_lookup = &m_table[0]; _UintType result; if (sizeof(_UintType) == 1) result = m_space.read_byte(offset); @@ -767,15 +767,15 @@ public: virtual ~address_table_write(); // getters - virtual handler_entry &handler(uint32_t index) const override; - handler_entry_write &handler_write(uint32_t index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } + virtual handler_entry &handler(u32 index) const override; + handler_entry_write &handler_write(u32 index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } // range getter - handler_entry_proxy handler_map_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, uint64_t mask = 0) { - std::list entries; + handler_entry_proxy handler_map_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, u64 mask = 0) { + std::list entries; setup_range(bytestart, byteend, bytemask, bytemirror, mask, entries); std::list handlers; - for (std::list::const_iterator i = entries.begin(); i != entries.end(); ++i) + for (std::list::const_iterator i = entries.begin(); i != entries.end(); ++i) handlers.push_back(&handler_write(*i)); return handler_entry_proxy(handlers, mask); } @@ -808,7 +808,7 @@ private: { m_space.device().debug()->memory_write_hook(m_space, offset * sizeof(_UintType), data, mask); - uint16_t *oldtable = m_live_lookup; + u16 *oldtable = m_live_lookup; m_live_lookup = &m_table[0]; if (sizeof(_UintType) == 1) m_space.write_byte(offset, data); if (sizeof(_UintType) == 2) m_space.write_word(offset << 1, data, mask); @@ -843,15 +843,15 @@ public: { } - handler_entry &handler(uint32_t index) const override { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } - handler_entry_setoffset &handler_setoffset(uint32_t index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } + handler_entry &handler(u32 index) const override { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } + handler_entry_setoffset &handler_setoffset(u32 index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; } // range getter - handler_entry_proxy handler_map_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, uint64_t mask = 0) { - std::list entries; + handler_entry_proxy handler_map_range(offs_t bytestart, offs_t byteend, offs_t bytemask, offs_t bytemirror, u64 mask = 0) { + std::list entries; setup_range(bytestart, byteend, bytemask, bytemirror, mask, entries); std::list handlers; - for (std::list::const_iterator i = entries.begin(); i != entries.end(); ++i) + for (std::list::const_iterator i = entries.begin(); i != entries.end(); ++i) handlers.push_back(&handler_setoffset(*i)); return handler_entry_proxy(handlers, mask); } @@ -881,14 +881,14 @@ class address_space_specific : public address_space typedef address_space_specific<_NativeType, _Endian, _Large> this_type; // constants describing the native size - static const uint32_t NATIVE_BYTES = sizeof(_NativeType); - static const uint32_t NATIVE_MASK = NATIVE_BYTES - 1; - static const uint32_t NATIVE_BITS = 8 * NATIVE_BYTES; + static const u32 NATIVE_BYTES = sizeof(_NativeType); + static const u32 NATIVE_MASK = NATIVE_BYTES - 1; + static const u32 NATIVE_BITS = 8 * NATIVE_BYTES; // helpers to simplify core code - uint32_t read_lookup(offs_t byteaddress) const { return _Large ? m_read.lookup_live_large(byteaddress) : m_read.lookup_live_small(byteaddress); } - uint32_t write_lookup(offs_t byteaddress) const { return _Large ? m_write.lookup_live_large(byteaddress) : m_write.lookup_live_small(byteaddress); } - uint32_t setoffset_lookup(offs_t byteaddress) const { return _Large ? m_setoffset.lookup_live_large(byteaddress) : m_setoffset.lookup_live_small(byteaddress); } + u32 read_lookup(offs_t byteaddress) const { return _Large ? m_read.lookup_live_large(byteaddress) : m_read.lookup_live_small(byteaddress); } + u32 write_lookup(offs_t byteaddress) const { return _Large ? m_write.lookup_live_large(byteaddress) : m_write.lookup_live_small(byteaddress); } + u32 setoffset_lookup(offs_t byteaddress) const { return _Large ? m_setoffset.lookup_live_large(byteaddress) : m_setoffset.lookup_live_small(byteaddress); } public: // construction/destruction @@ -903,7 +903,7 @@ public: // and returning the correct results // install some dummy RAM for the first 16 bytes with well-known values - uint8_t buffer[16]; + u8 buffer[16]; for (int index = 0; index < 16; index++) buffer[index ^ ((_Endian == ENDIANNESS_NATIVE) ? 0 : (data_width()/8 - 1))] = index * 0x11; install_ram_generic(0x00, 0x0f, 0x0f, 0, ROW_READWRITE, buffer); @@ -913,22 +913,22 @@ public: for (int address = 0; address < 8; address++) { // determine expected values - uint64_t expected64 = ((uint64_t)((address + ((_Endian == ENDIANNESS_LITTLE) ? 7 : 0)) * 0x11) << 56) | - ((uint64_t)((address + ((_Endian == ENDIANNESS_LITTLE) ? 6 : 1)) * 0x11) << 48) | - ((uint64_t)((address + ((_Endian == ENDIANNESS_LITTLE) ? 5 : 2)) * 0x11) << 40) | - ((uint64_t)((address + ((_Endian == ENDIANNESS_LITTLE) ? 4 : 3)) * 0x11) << 32) | - ((uint64_t)((address + ((_Endian == ENDIANNESS_LITTLE) ? 3 : 4)) * 0x11) << 24) | - ((uint64_t)((address + ((_Endian == ENDIANNESS_LITTLE) ? 2 : 5)) * 0x11) << 16) | - ((uint64_t)((address + ((_Endian == ENDIANNESS_LITTLE) ? 1 : 6)) * 0x11) << 8) | - ((uint64_t)((address + ((_Endian == ENDIANNESS_LITTLE) ? 0 : 7)) * 0x11) << 0); - uint32_t expected32 = (_Endian == ENDIANNESS_LITTLE) ? expected64 : (expected64 >> 32); - uint16_t expected16 = (_Endian == ENDIANNESS_LITTLE) ? expected32 : (expected32 >> 16); - uint8_t expected8 = (_Endian == ENDIANNESS_LITTLE) ? expected16 : (expected16 >> 8); + u64 expected64 = (u64((address + ((_Endian == ENDIANNESS_LITTLE) ? 7 : 0)) * 0x11) << 56) | + (u64((address + ((_Endian == ENDIANNESS_LITTLE) ? 6 : 1)) * 0x11) << 48) | + (u64((address + ((_Endian == ENDIANNESS_LITTLE) ? 5 : 2)) * 0x11) << 40) | + (u64((address + ((_Endian == ENDIANNESS_LITTLE) ? 4 : 3)) * 0x11) << 32) | + (u64((address + ((_Endian == ENDIANNESS_LITTLE) ? 3 : 4)) * 0x11) << 24) | + (u64((address + ((_Endian == ENDIANNESS_LITTLE) ? 2 : 5)) * 0x11) << 16) | + (u64((address + ((_Endian == ENDIANNESS_LITTLE) ? 1 : 6)) * 0x11) << 8) | + (u64((address + ((_Endian == ENDIANNESS_LITTLE) ? 0 : 7)) * 0x11) << 0); + u32 expected32 = (_Endian == ENDIANNESS_LITTLE) ? expected64 : (expected64 >> 32); + u16 expected16 = (_Endian == ENDIANNESS_LITTLE) ? expected32 : (expected32 >> 16); + u8 expected8 = (_Endian == ENDIANNESS_LITTLE) ? expected16 : (expected16 >> 8); - uint64_t result64; - uint32_t result32; - uint16_t result16; - uint8_t result8; + u64 result64; + u32 result32; + u16 result16; + u8 result8; // validate byte accesses printf("\nAddress %d\n", address); @@ -968,69 +968,69 @@ public: // validate qword acceses (if aligned) if (QWORD_ALIGNED(address)) { printf(" read_qword = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address), 16)); assert(result64 == expected64); } - if (QWORD_ALIGNED(address)) { printf(" read_qword (0xff00000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0xff00000000000000)), 16)); assert((result64 & U64(0xff00000000000000)) == (expected64 & U64(0xff00000000000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x00ff000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x00ff000000000000)), 16)); assert((result64 & U64(0x00ff000000000000)) == (expected64 & U64(0x00ff000000000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x0000ff0000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x0000ff0000000000)), 16)); assert((result64 & U64(0x0000ff0000000000)) == (expected64 & U64(0x0000ff0000000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x000000ff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x000000ff00000000)), 16)); assert((result64 & U64(0x000000ff00000000)) == (expected64 & U64(0x000000ff00000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x00000000ff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x00000000ff000000)), 16)); assert((result64 & U64(0x00000000ff000000)) == (expected64 & U64(0x00000000ff000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x0000000000ff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x0000000000ff0000)), 16)); assert((result64 & U64(0x0000000000ff0000)) == (expected64 & U64(0x0000000000ff0000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x000000000000ff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x000000000000ff00)), 16)); assert((result64 & U64(0x000000000000ff00)) == (expected64 & U64(0x000000000000ff00))); } - if (QWORD_ALIGNED(address)) { printf(" (0x00000000000000ff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x00000000000000ff)), 16)); assert((result64 & U64(0x00000000000000ff)) == (expected64 & U64(0x00000000000000ff))); } - if (QWORD_ALIGNED(address)) { printf(" (0xffff000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0xffff000000000000)), 16)); assert((result64 & U64(0xffff000000000000)) == (expected64 & U64(0xffff000000000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x0000ffff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x0000ffff00000000)), 16)); assert((result64 & U64(0x0000ffff00000000)) == (expected64 & U64(0x0000ffff00000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x00000000ffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x00000000ffff0000)), 16)); assert((result64 & U64(0x00000000ffff0000)) == (expected64 & U64(0x00000000ffff0000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x000000000000ffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x000000000000ffff)), 16)); assert((result64 & U64(0x000000000000ffff)) == (expected64 & U64(0x000000000000ffff))); } - if (QWORD_ALIGNED(address)) { printf(" (0xffffff0000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0xffffff0000000000)), 16)); assert((result64 & U64(0xffffff0000000000)) == (expected64 & U64(0xffffff0000000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x0000ffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x0000ffffff000000)), 16)); assert((result64 & U64(0x0000ffffff000000)) == (expected64 & U64(0x0000ffffff000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x000000ffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x000000ffffff0000)), 16)); assert((result64 & U64(0x000000ffffff0000)) == (expected64 & U64(0x000000ffffff0000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x0000000000ffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x0000000000ffffff)), 16)); assert((result64 & U64(0x0000000000ffffff)) == (expected64 & U64(0x0000000000ffffff))); } - if (QWORD_ALIGNED(address)) { printf(" (0xffffffff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0xffffffff00000000)), 16)); assert((result64 & U64(0xffffffff00000000)) == (expected64 & U64(0xffffffff00000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x00ffffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x00ffffffff000000)), 16)); assert((result64 & U64(0x00ffffffff000000)) == (expected64 & U64(0x00ffffffff000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x0000ffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x0000ffffffff0000)), 16)); assert((result64 & U64(0x0000ffffffff0000)) == (expected64 & U64(0x0000ffffffff0000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x000000ffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x000000ffffffff00)), 16)); assert((result64 & U64(0x000000ffffffff00)) == (expected64 & U64(0x000000ffffffff00))); } - if (QWORD_ALIGNED(address)) { printf(" (0x00000000ffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x00000000ffffffff)), 16)); assert((result64 & U64(0x00000000ffffffff)) == (expected64 & U64(0x00000000ffffffff))); } - if (QWORD_ALIGNED(address)) { printf(" (0xffffffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0xffffffffff000000)), 16)); assert((result64 & U64(0xffffffffff000000)) == (expected64 & U64(0xffffffffff000000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x00ffffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x00ffffffffff0000)), 16)); assert((result64 & U64(0x00ffffffffff0000)) == (expected64 & U64(0x00ffffffffff0000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x0000ffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x0000ffffffffff00)), 16)); assert((result64 & U64(0x0000ffffffffff00)) == (expected64 & U64(0x0000ffffffffff00))); } - if (QWORD_ALIGNED(address)) { printf(" (0x000000ffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x000000ffffffffff)), 16)); assert((result64 & U64(0x000000ffffffffff)) == (expected64 & U64(0x000000ffffffffff))); } - if (QWORD_ALIGNED(address)) { printf(" (0xffffffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0xffffffffffff0000)), 16)); assert((result64 & U64(0xffffffffffff0000)) == (expected64 & U64(0xffffffffffff0000))); } - if (QWORD_ALIGNED(address)) { printf(" (0x00ffffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x00ffffffffffff00)), 16)); assert((result64 & U64(0x00ffffffffffff00)) == (expected64 & U64(0x00ffffffffffff00))); } - if (QWORD_ALIGNED(address)) { printf(" (0x0000ffffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x0000ffffffffffff)), 16)); assert((result64 & U64(0x0000ffffffffffff)) == (expected64 & U64(0x0000ffffffffffff))); } - if (QWORD_ALIGNED(address)) { printf(" (0xffffffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0xffffffffffffff00)), 16)); assert((result64 & U64(0xffffffffffffff00)) == (expected64 & U64(0xffffffffffffff00))); } - if (QWORD_ALIGNED(address)) { printf(" (0x00ffffffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, U64(0x00ffffffffffffff)), 16)); assert((result64 & U64(0x00ffffffffffffff)) == (expected64 & U64(0x00ffffffffffffff))); } + if (QWORD_ALIGNED(address)) { printf(" read_qword (0xff00000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0xff00000000000000U), 16)); assert((result64 & 0xff00000000000000U) == (expected64 & 0xff00000000000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x00ff000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x00ff000000000000U), 16)); assert((result64 & 0x00ff000000000000U) == (expected64 & 0x00ff000000000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x0000ff0000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x0000ff0000000000U), 16)); assert((result64 & 0x0000ff0000000000U) == (expected64 & 0x0000ff0000000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x000000ff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x000000ff00000000U), 16)); assert((result64 & 0x000000ff00000000U) == (expected64 & 0x000000ff00000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x00000000ff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x00000000ff000000U), 16)); assert((result64 & 0x00000000ff000000U) == (expected64 & 0x00000000ff000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x0000000000ff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x0000000000ff0000U), 16)); assert((result64 & 0x0000000000ff0000U) == (expected64 & 0x0000000000ff0000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x000000000000ff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x000000000000ff00U), 16)); assert((result64 & 0x000000000000ff00U) == (expected64 & 0x000000000000ff00U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x00000000000000ff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x00000000000000ffU), 16)); assert((result64 & 0x00000000000000ffU) == (expected64 & 0x00000000000000ffU)); } + if (QWORD_ALIGNED(address)) { printf(" (0xffff000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0xffff000000000000U), 16)); assert((result64 & 0xffff000000000000U) == (expected64 & 0xffff000000000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x0000ffff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x0000ffff00000000U), 16)); assert((result64 & 0x0000ffff00000000U) == (expected64 & 0x0000ffff00000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x00000000ffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x00000000ffff0000U), 16)); assert((result64 & 0x00000000ffff0000U) == (expected64 & 0x00000000ffff0000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x000000000000ffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x000000000000ffffU), 16)); assert((result64 & 0x000000000000ffffU) == (expected64 & 0x000000000000ffffU)); } + if (QWORD_ALIGNED(address)) { printf(" (0xffffff0000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0xffffff0000000000U), 16)); assert((result64 & 0xffffff0000000000U) == (expected64 & 0xffffff0000000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x0000ffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x0000ffffff000000U), 16)); assert((result64 & 0x0000ffffff000000U) == (expected64 & 0x0000ffffff000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x000000ffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x000000ffffff0000U), 16)); assert((result64 & 0x000000ffffff0000U) == (expected64 & 0x000000ffffff0000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x0000000000ffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x0000000000ffffffU), 16)); assert((result64 & 0x0000000000ffffffU) == (expected64 & 0x0000000000ffffffU)); } + if (QWORD_ALIGNED(address)) { printf(" (0xffffffff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0xffffffff00000000U), 16)); assert((result64 & 0xffffffff00000000U) == (expected64 & 0xffffffff00000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x00ffffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x00ffffffff000000U), 16)); assert((result64 & 0x00ffffffff000000U) == (expected64 & 0x00ffffffff000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x0000ffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x0000ffffffff0000U), 16)); assert((result64 & 0x0000ffffffff0000U) == (expected64 & 0x0000ffffffff0000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x000000ffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x000000ffffffff00U), 16)); assert((result64 & 0x000000ffffffff00U) == (expected64 & 0x000000ffffffff00U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x00000000ffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x00000000ffffffffU), 16)); assert((result64 & 0x00000000ffffffffU) == (expected64 & 0x00000000ffffffffU)); } + if (QWORD_ALIGNED(address)) { printf(" (0xffffffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0xffffffffff000000U), 16)); assert((result64 & 0xffffffffff000000U) == (expected64 & 0xffffffffff000000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x00ffffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x00ffffffffff0000U), 16)); assert((result64 & 0x00ffffffffff0000U) == (expected64 & 0x00ffffffffff0000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x0000ffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x0000ffffffffff00U), 16)); assert((result64 & 0x0000ffffffffff00U) == (expected64 & 0x0000ffffffffff00U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x000000ffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x000000ffffffffffU), 16)); assert((result64 & 0x000000ffffffffffU) == (expected64 & 0x000000ffffffffffU)); } + if (QWORD_ALIGNED(address)) { printf(" (0xffffffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0xffffffffffff0000U), 16)); assert((result64 & 0xffffffffffff0000U) == (expected64 & 0xffffffffffff0000U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x00ffffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x00ffffffffffff00U), 16)); assert((result64 & 0x00ffffffffffff00U) == (expected64 & 0x00ffffffffffff00U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x0000ffffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x0000ffffffffffffU), 16)); assert((result64 & 0x0000ffffffffffffU) == (expected64 & 0x0000ffffffffffffU)); } + if (QWORD_ALIGNED(address)) { printf(" (0xffffffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0xffffffffffffff00U), 16)); assert((result64 & 0xffffffffffffff00U) == (expected64 & 0xffffffffffffff00U)); } + if (QWORD_ALIGNED(address)) { printf(" (0x00ffffffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword(address, 0x00ffffffffffffffU), 16)); assert((result64 & 0x00ffffffffffffffU) == (expected64 & 0x00ffffffffffffffU)); } // validate unaligned qword accesses printf(" read_qword_unaligned = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address), 16)); assert(result64 == expected64); - printf(" read_qword_unaligned (0xff00000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0xff00000000000000)), 16)); assert((result64 & U64(0xff00000000000000)) == (expected64 & U64(0xff00000000000000))); - printf(" (0x00ff000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x00ff000000000000)), 16)); assert((result64 & U64(0x00ff000000000000)) == (expected64 & U64(0x00ff000000000000))); - printf(" (0x0000ff0000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x0000ff0000000000)), 16)); assert((result64 & U64(0x0000ff0000000000)) == (expected64 & U64(0x0000ff0000000000))); - printf(" (0x000000ff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x000000ff00000000)), 16)); assert((result64 & U64(0x000000ff00000000)) == (expected64 & U64(0x000000ff00000000))); - printf(" (0x00000000ff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x00000000ff000000)), 16)); assert((result64 & U64(0x00000000ff000000)) == (expected64 & U64(0x00000000ff000000))); - printf(" (0x0000000000ff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x0000000000ff0000)), 16)); assert((result64 & U64(0x0000000000ff0000)) == (expected64 & U64(0x0000000000ff0000))); - printf(" (0x000000000000ff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x000000000000ff00)), 16)); assert((result64 & U64(0x000000000000ff00)) == (expected64 & U64(0x000000000000ff00))); - printf(" (0x00000000000000ff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x00000000000000ff)), 16)); assert((result64 & U64(0x00000000000000ff)) == (expected64 & U64(0x00000000000000ff))); - printf(" (0xffff000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0xffff000000000000)), 16)); assert((result64 & U64(0xffff000000000000)) == (expected64 & U64(0xffff000000000000))); - printf(" (0x0000ffff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x0000ffff00000000)), 16)); assert((result64 & U64(0x0000ffff00000000)) == (expected64 & U64(0x0000ffff00000000))); - printf(" (0x00000000ffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x00000000ffff0000)), 16)); assert((result64 & U64(0x00000000ffff0000)) == (expected64 & U64(0x00000000ffff0000))); - printf(" (0x000000000000ffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x000000000000ffff)), 16)); assert((result64 & U64(0x000000000000ffff)) == (expected64 & U64(0x000000000000ffff))); - printf(" (0xffffff0000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0xffffff0000000000)), 16)); assert((result64 & U64(0xffffff0000000000)) == (expected64 & U64(0xffffff0000000000))); - printf(" (0x0000ffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x0000ffffff000000)), 16)); assert((result64 & U64(0x0000ffffff000000)) == (expected64 & U64(0x0000ffffff000000))); - printf(" (0x000000ffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x000000ffffff0000)), 16)); assert((result64 & U64(0x000000ffffff0000)) == (expected64 & U64(0x000000ffffff0000))); - printf(" (0x0000000000ffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x0000000000ffffff)), 16)); assert((result64 & U64(0x0000000000ffffff)) == (expected64 & U64(0x0000000000ffffff))); - printf(" (0xffffffff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0xffffffff00000000)), 16)); assert((result64 & U64(0xffffffff00000000)) == (expected64 & U64(0xffffffff00000000))); - printf(" (0x00ffffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x00ffffffff000000)), 16)); assert((result64 & U64(0x00ffffffff000000)) == (expected64 & U64(0x00ffffffff000000))); - printf(" (0x0000ffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x0000ffffffff0000)), 16)); assert((result64 & U64(0x0000ffffffff0000)) == (expected64 & U64(0x0000ffffffff0000))); - printf(" (0x000000ffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x000000ffffffff00)), 16)); assert((result64 & U64(0x000000ffffffff00)) == (expected64 & U64(0x000000ffffffff00))); - printf(" (0x00000000ffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x00000000ffffffff)), 16)); assert((result64 & U64(0x00000000ffffffff)) == (expected64 & U64(0x00000000ffffffff))); - printf(" (0xffffffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0xffffffffff000000)), 16)); assert((result64 & U64(0xffffffffff000000)) == (expected64 & U64(0xffffffffff000000))); - printf(" (0x00ffffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x00ffffffffff0000)), 16)); assert((result64 & U64(0x00ffffffffff0000)) == (expected64 & U64(0x00ffffffffff0000))); - printf(" (0x0000ffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x0000ffffffffff00)), 16)); assert((result64 & U64(0x0000ffffffffff00)) == (expected64 & U64(0x0000ffffffffff00))); - printf(" (0x000000ffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x000000ffffffffff)), 16)); assert((result64 & U64(0x000000ffffffffff)) == (expected64 & U64(0x000000ffffffffff))); - printf(" (0xffffffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0xffffffffffff0000)), 16)); assert((result64 & U64(0xffffffffffff0000)) == (expected64 & U64(0xffffffffffff0000))); - printf(" (0x00ffffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x00ffffffffffff00)), 16)); assert((result64 & U64(0x00ffffffffffff00)) == (expected64 & U64(0x00ffffffffffff00))); - printf(" (0x0000ffffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x0000ffffffffffff)), 16)); assert((result64 & U64(0x0000ffffffffffff)) == (expected64 & U64(0x0000ffffffffffff))); - printf(" (0xffffffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0xffffffffffffff00)), 16)); assert((result64 & U64(0xffffffffffffff00)) == (expected64 & U64(0xffffffffffffff00))); - printf(" (0x00ffffffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, U64(0x00ffffffffffffff)), 16)); assert((result64 & U64(0x00ffffffffffffff)) == (expected64 & U64(0x00ffffffffffffff))); + printf(" read_qword_unaligned (0xff00000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0xff00000000000000U), 16)); assert((result64 & 0xff00000000000000U) == (expected64 & 0xff00000000000000U)); + printf(" (0x00ff000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x00ff000000000000U), 16)); assert((result64 & 0x00ff000000000000U) == (expected64 & 0x00ff000000000000U)); + printf(" (0x0000ff0000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x0000ff0000000000U), 16)); assert((result64 & 0x0000ff0000000000U) == (expected64 & 0x0000ff0000000000U)); + printf(" (0x000000ff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x000000ff00000000U), 16)); assert((result64 & 0x000000ff00000000U) == (expected64 & 0x000000ff00000000U)); + printf(" (0x00000000ff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x00000000ff000000U), 16)); assert((result64 & 0x00000000ff000000U) == (expected64 & 0x00000000ff000000U)); + printf(" (0x0000000000ff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x0000000000ff0000U), 16)); assert((result64 & 0x0000000000ff0000U) == (expected64 & 0x0000000000ff0000U)); + printf(" (0x000000000000ff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x000000000000ff00U), 16)); assert((result64 & 0x000000000000ff00U) == (expected64 & 0x000000000000ff00U)); + printf(" (0x00000000000000ff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x00000000000000ffU), 16)); assert((result64 & 0x00000000000000ffU) == (expected64 & 0x00000000000000ffU)); + printf(" (0xffff000000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0xffff000000000000U), 16)); assert((result64 & 0xffff000000000000U) == (expected64 & 0xffff000000000000U)); + printf(" (0x0000ffff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x0000ffff00000000U), 16)); assert((result64 & 0x0000ffff00000000U) == (expected64 & 0x0000ffff00000000U)); + printf(" (0x00000000ffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x00000000ffff0000U), 16)); assert((result64 & 0x00000000ffff0000U) == (expected64 & 0x00000000ffff0000U)); + printf(" (0x000000000000ffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x000000000000ffffU), 16)); assert((result64 & 0x000000000000ffffU) == (expected64 & 0x000000000000ffffU)); + printf(" (0xffffff0000000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0xffffff0000000000U), 16)); assert((result64 & 0xffffff0000000000U) == (expected64 & 0xffffff0000000000U)); + printf(" (0x0000ffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x0000ffffff000000U), 16)); assert((result64 & 0x0000ffffff000000U) == (expected64 & 0x0000ffffff000000U)); + printf(" (0x000000ffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x000000ffffff0000U), 16)); assert((result64 & 0x000000ffffff0000U) == (expected64 & 0x000000ffffff0000U)); + printf(" (0x0000000000ffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x0000000000ffffffU), 16)); assert((result64 & 0x0000000000ffffffU) == (expected64 & 0x0000000000ffffffU)); + printf(" (0xffffffff00000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0xffffffff00000000U), 16)); assert((result64 & 0xffffffff00000000U) == (expected64 & 0xffffffff00000000U)); + printf(" (0x00ffffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x00ffffffff000000U), 16)); assert((result64 & 0x00ffffffff000000U) == (expected64 & 0x00ffffffff000000U)); + printf(" (0x0000ffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x0000ffffffff0000U), 16)); assert((result64 & 0x0000ffffffff0000U) == (expected64 & 0x0000ffffffff0000U)); + printf(" (0x000000ffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x000000ffffffff00U), 16)); assert((result64 & 0x000000ffffffff00U) == (expected64 & 0x000000ffffffff00U)); + printf(" (0x00000000ffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x00000000ffffffffU), 16)); assert((result64 & 0x00000000ffffffffU) == (expected64 & 0x00000000ffffffffU)); + printf(" (0xffffffffff000000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0xffffffffff000000U), 16)); assert((result64 & 0xffffffffff000000U) == (expected64 & 0xffffffffff000000U)); + printf(" (0x00ffffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x00ffffffffff0000U), 16)); assert((result64 & 0x00ffffffffff0000U) == (expected64 & 0x00ffffffffff0000U)); + printf(" (0x0000ffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x0000ffffffffff00U), 16)); assert((result64 & 0x0000ffffffffff00U) == (expected64 & 0x0000ffffffffff00U)); + printf(" (0x000000ffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x000000ffffffffffU), 16)); assert((result64 & 0x000000ffffffffffU) == (expected64 & 0x000000ffffffffffU)); + printf(" (0xffffffffffff0000) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0xffffffffffff0000U), 16)); assert((result64 & 0xffffffffffff0000U) == (expected64 & 0xffffffffffff0000U)); + printf(" (0x00ffffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x00ffffffffffff00U), 16)); assert((result64 & 0x00ffffffffffff00U) == (expected64 & 0x00ffffffffffff00U)); + printf(" (0x0000ffffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x0000ffffffffffffU), 16)); assert((result64 & 0x0000ffffffffffffU) == (expected64 & 0x0000ffffffffffffU)); + printf(" (0xffffffffffffff00) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0xffffffffffffff00U), 16)); assert((result64 & 0xffffffffffffff00U) == (expected64 & 0xffffffffffffff00U)); + printf(" (0x00ffffffffffffff) = "); printf("%s\n", core_i64_hex_format(result64 = read_qword_unaligned(address, 0x00ffffffffffffffU), 16)); assert((result64 & 0x00ffffffffffffffU) == (expected64 & 0x00ffffffffffffffU)); } #endif } @@ -1047,20 +1047,20 @@ public: // generate accessor table virtual void accessors(data_accessors &accessors) const override { - accessors.read_byte = reinterpret_cast(&read_byte_static); - accessors.read_word = reinterpret_cast(&read_word_static); - accessors.read_word_masked = reinterpret_cast(&read_word_masked_static); - accessors.read_dword = reinterpret_cast(&read_dword_static); - accessors.read_dword_masked = reinterpret_cast(&read_dword_masked_static); - accessors.read_qword = reinterpret_cast(&read_qword_static); - accessors.read_qword_masked = reinterpret_cast(&read_qword_masked_static); - accessors.write_byte = reinterpret_cast(&write_byte_static); - accessors.write_word = reinterpret_cast(&write_word_static); - accessors.write_word_masked = reinterpret_cast(&write_word_masked_static); - accessors.write_dword = reinterpret_cast(&write_dword_static); - accessors.write_dword_masked = reinterpret_cast(&write_dword_masked_static); - accessors.write_qword = reinterpret_cast(&write_qword_static); - accessors.write_qword_masked = reinterpret_cast(&write_qword_masked_static); + accessors.read_byte = reinterpret_cast(&read_byte_static); + accessors.read_word = reinterpret_cast(&read_word_static); + accessors.read_word_masked = reinterpret_cast(&read_word_masked_static); + accessors.read_dword = reinterpret_cast(&read_dword_static); + accessors.read_dword_masked = reinterpret_cast(&read_dword_masked_static); + accessors.read_qword = reinterpret_cast(&read_qword_static); + accessors.read_qword_masked = reinterpret_cast(&read_qword_masked_static); + accessors.write_byte = reinterpret_cast(&write_byte_static); + accessors.write_word = reinterpret_cast(&write_word_static); + accessors.write_word_masked = reinterpret_cast(&write_word_masked_static); + accessors.write_dword = reinterpret_cast(&write_dword_static); + accessors.write_dword_masked = reinterpret_cast(&write_dword_masked_static); + accessors.write_qword = reinterpret_cast(&write_qword_static); + accessors.write_qword_masked = reinterpret_cast(&write_qword_masked_static); } // return a pointer to the read bank, or nullptr if none @@ -1068,7 +1068,7 @@ public: { // perform the lookup byteaddress &= m_bytemask; - uint32_t entry = read_lookup(byteaddress); + u32 entry = read_lookup(byteaddress); const handler_entry_read &handler = m_read.handler_read(entry); // 8-bit case: RAM/ROM @@ -1082,7 +1082,7 @@ public: { // perform the lookup byteaddress &= m_bytemask; - uint32_t entry = write_lookup(byteaddress); + u32 entry = write_lookup(byteaddress); const handler_entry_write &handler = m_write.handler_write(entry); // 8-bit case: RAM/ROM @@ -1100,7 +1100,7 @@ public: // look up the handler offs_t byteaddress = offset & m_bytemask; - uint32_t entry = read_lookup(byteaddress); + u32 entry = read_lookup(byteaddress); const handler_entry_read &handler = m_read.handler_read(entry); // either read directly from RAM, or call the delegate @@ -1125,7 +1125,7 @@ public: // look up the handler offs_t byteaddress = offset & m_bytemask; - uint32_t entry = read_lookup(byteaddress); + u32 entry = read_lookup(byteaddress); const handler_entry_read &handler = m_read.handler_read(entry); // either read directly from RAM, or call the delegate @@ -1135,7 +1135,7 @@ public: else if (sizeof(_NativeType) == 1) result = handler.read8(*this, offset, 0xff); else if (sizeof(_NativeType) == 2) result = handler.read16(*this, offset >> 1, 0xffff); else if (sizeof(_NativeType) == 4) result = handler.read32(*this, offset >> 2, 0xffffffff); - else if (sizeof(_NativeType) == 8) result = handler.read64(*this, offset >> 3, U64(0xffffffffffffffff)); + else if (sizeof(_NativeType) == 8) result = handler.read64(*this, offset >> 3, 0xffffffffffffffffU); g_profiler.stop(); return result; @@ -1148,7 +1148,7 @@ public: // look up the handler offs_t byteaddress = offset & m_bytemask; - uint32_t entry = write_lookup(byteaddress); + u32 entry = write_lookup(byteaddress); const handler_entry_write &handler = m_write.handler_write(entry); // either write directly to RAM, or call the delegate @@ -1173,7 +1173,7 @@ public: // look up the handler offs_t byteaddress = offset & m_bytemask; - uint32_t entry = write_lookup(byteaddress); + u32 entry = write_lookup(byteaddress); const handler_entry_write &handler = m_write.handler_write(entry); // either write directly to RAM, or call the delegate @@ -1182,7 +1182,7 @@ public: else if (sizeof(_NativeType) == 1) handler.write8(*this, offset, data, 0xff); else if (sizeof(_NativeType) == 2) handler.write16(*this, offset >> 1, data, 0xffff); else if (sizeof(_NativeType) == 4) handler.write32(*this, offset >> 2, data, 0xffffffff); - else if (sizeof(_NativeType) == 8) handler.write64(*this, offset >> 3, data, U64(0xffffffffffffffff)); + else if (sizeof(_NativeType) == 8) handler.write64(*this, offset >> 3, data, 0xffffffffffffffffU); g_profiler.stop(); } @@ -1191,8 +1191,8 @@ public: template _TargetType read_direct(offs_t address, _TargetType mask) { - const uint32_t TARGET_BYTES = sizeof(_TargetType); - const uint32_t TARGET_BITS = 8 * TARGET_BYTES; + const u32 TARGET_BYTES = sizeof(_TargetType); + const u32 TARGET_BITS = 8 * TARGET_BYTES; // equal to native size and aligned; simple pass-through to the native reader if (NATIVE_BYTES == TARGET_BYTES && (_Aligned || (address & NATIVE_MASK) == 0)) @@ -1201,7 +1201,7 @@ public: // if native size is larger, see if we can do a single masked read (guaranteed if we're aligned) if (NATIVE_BYTES > TARGET_BYTES) { - uint32_t offsbits = 8 * (address & (NATIVE_BYTES - (_Aligned ? TARGET_BYTES : 1))); + u32 offsbits = 8 * (address & (NATIVE_BYTES - (_Aligned ? TARGET_BYTES : 1))); if (_Aligned || (offsbits + TARGET_BITS <= NATIVE_BITS)) { if (_Endian != ENDIANNESS_LITTLE) offsbits = NATIVE_BITS - TARGET_BITS - offsbits; @@ -1210,7 +1210,7 @@ public: } // determine our alignment against the native boundaries, and mask the address - uint32_t offsbits = 8 * (address & (NATIVE_BYTES - 1)); + u32 offsbits = 8 * (address & (NATIVE_BYTES - 1)); address &= ~NATIVE_MASK; // if we're here, and native size is larger or equal to the target, we need exactly 2 reads @@ -1235,7 +1235,7 @@ public: else { // left-justify the mask to the target type - const uint32_t LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT = ((NATIVE_BITS >= TARGET_BITS) ? (NATIVE_BITS - TARGET_BITS) : 0); + const u32 LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT = ((NATIVE_BITS >= TARGET_BITS) ? (NATIVE_BITS - TARGET_BITS) : 0); _NativeType result = 0; _NativeType ljmask = (_NativeType)mask << LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT; _NativeType curmask = ljmask >> offsbits; @@ -1258,7 +1258,7 @@ public: { // compute the maximum number of loops; we do it this way so that there are // a fixed number of loops for the compiler to unroll if it desires - const uint32_t MAX_SPLITS_MINUS_ONE = TARGET_BYTES / NATIVE_BYTES - 1; + const u32 MAX_SPLITS_MINUS_ONE = TARGET_BYTES / NATIVE_BYTES - 1; _TargetType result = 0; // little-endian case @@ -1270,7 +1270,7 @@ public: // read middle bits from subsequent addresses offsbits = NATIVE_BITS - offsbits; - for (uint32_t index = 0; index < MAX_SPLITS_MINUS_ONE; index++) + for (u32 index = 0; index < MAX_SPLITS_MINUS_ONE; index++) { address += NATIVE_BYTES; curmask = mask >> offsbits; @@ -1295,7 +1295,7 @@ public: if (curmask != 0) result = (_TargetType)read_native(address, curmask) << offsbits; // read middle bits from subsequent addresses - for (uint32_t index = 0; index < MAX_SPLITS_MINUS_ONE; index++) + for (u32 index = 0; index < MAX_SPLITS_MINUS_ONE; index++) { offsbits -= NATIVE_BITS; address += NATIVE_BYTES; @@ -1319,8 +1319,8 @@ public: template void write_direct(offs_t address, _TargetType data, _TargetType mask) { - const uint32_t TARGET_BYTES = sizeof(_TargetType); - const uint32_t TARGET_BITS = 8 * TARGET_BYTES; + const u32 TARGET_BYTES = sizeof(_TargetType); + const u32 TARGET_BITS = 8 * TARGET_BYTES; // equal to native size and aligned; simple pass-through to the native writer if (NATIVE_BYTES == TARGET_BYTES && (_Aligned || (address & NATIVE_MASK) == 0)) @@ -1329,7 +1329,7 @@ public: // if native size is larger, see if we can do a single masked write (guaranteed if we're aligned) if (NATIVE_BYTES > TARGET_BYTES) { - uint32_t offsbits = 8 * (address & (NATIVE_BYTES - (_Aligned ? TARGET_BYTES : 1))); + u32 offsbits = 8 * (address & (NATIVE_BYTES - (_Aligned ? TARGET_BYTES : 1))); if (_Aligned || (offsbits + TARGET_BITS <= NATIVE_BITS)) { if (_Endian != ENDIANNESS_LITTLE) offsbits = NATIVE_BITS - TARGET_BITS - offsbits; @@ -1338,7 +1338,7 @@ public: } // determine our alignment against the native boundaries, and mask the address - uint32_t offsbits = 8 * (address & (NATIVE_BYTES - 1)); + u32 offsbits = 8 * (address & (NATIVE_BYTES - 1)); address &= ~NATIVE_MASK; // if we're here, and native size is larger or equal to the target, we need exactly 2 writes @@ -1361,7 +1361,7 @@ public: else { // left-justify the mask and data to the target type - const uint32_t LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT = ((NATIVE_BITS >= TARGET_BITS) ? (NATIVE_BITS - TARGET_BITS) : 0); + const u32 LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT = ((NATIVE_BITS >= TARGET_BITS) ? (NATIVE_BITS - TARGET_BITS) : 0); _NativeType ljdata = (_NativeType)data << LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT; _NativeType ljmask = (_NativeType)mask << LEFT_JUSTIFY_TARGET_TO_NATIVE_SHIFT; @@ -1381,7 +1381,7 @@ public: { // compute the maximum number of loops; we do it this way so that there are // a fixed number of loops for the compiler to unroll if it desires - const uint32_t MAX_SPLITS_MINUS_ONE = TARGET_BYTES / NATIVE_BYTES - 1; + const u32 MAX_SPLITS_MINUS_ONE = TARGET_BYTES / NATIVE_BYTES - 1; // little-endian case if (_Endian == ENDIANNESS_LITTLE) @@ -1392,7 +1392,7 @@ public: // write middle bits to subsequent addresses offsbits = NATIVE_BITS - offsbits; - for (uint32_t index = 0; index < MAX_SPLITS_MINUS_ONE; index++) + for (u32 index = 0; index < MAX_SPLITS_MINUS_ONE; index++) { address += NATIVE_BYTES; curmask = mask >> offsbits; @@ -1417,7 +1417,7 @@ public: if (curmask != 0) write_native(address, data >> offsbits, curmask); // write middle bits to subsequent addresses - for (uint32_t index = 0; index < MAX_SPLITS_MINUS_ONE; index++) + for (u32 index = 0; index < MAX_SPLITS_MINUS_ONE; index++) { offsbits -= NATIVE_BITS; address += NATIVE_BYTES; @@ -1442,7 +1442,7 @@ public: void set_address(offs_t address) override { offs_t byteaddress = address & m_bytemask; - uint32_t entry = setoffset_lookup(byteaddress); + u32 entry = setoffset_lookup(byteaddress); const handler_entry_setoffset &handler = m_setoffset.handler_setoffset(entry); offs_t offset = handler.byteoffset(byteaddress); @@ -1450,72 +1450,72 @@ public: } // virtual access to these functions - uint8_t read_byte(offs_t address) override { return (NATIVE_BITS == 8) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xff); } - uint16_t read_word(offs_t address) override { return (NATIVE_BITS == 16) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xffff); } - uint16_t read_word(offs_t address, uint16_t mask) override { return read_direct(address, mask); } - uint16_t read_word_unaligned(offs_t address) override { return read_direct(address, 0xffff); } - uint16_t read_word_unaligned(offs_t address, uint16_t mask) override { return read_direct(address, mask); } - uint32_t read_dword(offs_t address) override { return (NATIVE_BITS == 32) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xffffffff); } - uint32_t read_dword(offs_t address, uint32_t mask) override { return read_direct(address, mask); } - uint32_t read_dword_unaligned(offs_t address) override { return read_direct(address, 0xffffffff); } - uint32_t read_dword_unaligned(offs_t address, uint32_t mask) override { return read_direct(address, mask); } - uint64_t read_qword(offs_t address) override { return (NATIVE_BITS == 64) ? read_native(address & ~NATIVE_MASK) : read_direct(address, U64(0xffffffffffffffff)); } - uint64_t read_qword(offs_t address, uint64_t mask) override { return read_direct(address, mask); } - uint64_t read_qword_unaligned(offs_t address) override { return read_direct(address, U64(0xffffffffffffffff)); } - uint64_t read_qword_unaligned(offs_t address, uint64_t mask) override { return read_direct(address, mask); } + u8 read_byte(offs_t address) override { return (NATIVE_BITS == 8) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xff); } + u16 read_word(offs_t address) override { return (NATIVE_BITS == 16) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xffff); } + u16 read_word(offs_t address, u16 mask) override { return read_direct(address, mask); } + u16 read_word_unaligned(offs_t address) override { return read_direct(address, 0xffff); } + u16 read_word_unaligned(offs_t address, u16 mask) override { return read_direct(address, mask); } + u32 read_dword(offs_t address) override { return (NATIVE_BITS == 32) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xffffffff); } + u32 read_dword(offs_t address, u32 mask) override { return read_direct(address, mask); } + u32 read_dword_unaligned(offs_t address) override { return read_direct(address, 0xffffffff); } + u32 read_dword_unaligned(offs_t address, u32 mask) override { return read_direct(address, mask); } + u64 read_qword(offs_t address) override { return (NATIVE_BITS == 64) ? read_native(address & ~NATIVE_MASK) : read_direct(address, 0xffffffffffffffffU); } + u64 read_qword(offs_t address, u64 mask) override { return read_direct(address, mask); } + u64 read_qword_unaligned(offs_t address) override { return read_direct(address, 0xffffffffffffffffU); } + u64 read_qword_unaligned(offs_t address, u64 mask) override { return read_direct(address, mask); } - void write_byte(offs_t address, uint8_t data) override { if (NATIVE_BITS == 8) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xff); } - void write_word(offs_t address, uint16_t data) override { if (NATIVE_BITS == 16) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xffff); } - void write_word(offs_t address, uint16_t data, uint16_t mask) override { write_direct(address, data, mask); } - void write_word_unaligned(offs_t address, uint16_t data) override { write_direct(address, data, 0xffff); } - void write_word_unaligned(offs_t address, uint16_t data, uint16_t mask) override { write_direct(address, data, mask); } - void write_dword(offs_t address, uint32_t data) override { if (NATIVE_BITS == 32) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xffffffff); } - void write_dword(offs_t address, uint32_t data, uint32_t mask) override { write_direct(address, data, mask); } - void write_dword_unaligned(offs_t address, uint32_t data) override { write_direct(address, data, 0xffffffff); } - void write_dword_unaligned(offs_t address, uint32_t data, uint32_t mask) override { write_direct(address, data, mask); } - void write_qword(offs_t address, uint64_t data) override { if (NATIVE_BITS == 64) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, U64(0xffffffffffffffff)); } - void write_qword(offs_t address, uint64_t data, uint64_t mask) override { write_direct(address, data, mask); } - void write_qword_unaligned(offs_t address, uint64_t data) override { write_direct(address, data, U64(0xffffffffffffffff)); } - void write_qword_unaligned(offs_t address, uint64_t data, uint64_t mask) override { write_direct(address, data, mask); } + void write_byte(offs_t address, u8 data) override { if (NATIVE_BITS == 8) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xff); } + void write_word(offs_t address, u16 data) override { if (NATIVE_BITS == 16) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xffff); } + void write_word(offs_t address, u16 data, u16 mask) override { write_direct(address, data, mask); } + void write_word_unaligned(offs_t address, u16 data) override { write_direct(address, data, 0xffff); } + void write_word_unaligned(offs_t address, u16 data, u16 mask) override { write_direct(address, data, mask); } + void write_dword(offs_t address, u32 data) override { if (NATIVE_BITS == 32) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xffffffff); } + void write_dword(offs_t address, u32 data, u32 mask) override { write_direct(address, data, mask); } + void write_dword_unaligned(offs_t address, u32 data) override { write_direct(address, data, 0xffffffff); } + void write_dword_unaligned(offs_t address, u32 data, u32 mask) override { write_direct(address, data, mask); } + void write_qword(offs_t address, u64 data) override { if (NATIVE_BITS == 64) write_native(address & ~NATIVE_MASK, data); else write_direct(address, data, 0xffffffffffffffffU); } + void write_qword(offs_t address, u64 data, u64 mask) override { write_direct(address, data, mask); } + void write_qword_unaligned(offs_t address, u64 data) override { write_direct(address, data, 0xffffffffffffffffU); } + void write_qword_unaligned(offs_t address, u64 data, u64 mask) override { write_direct(address, data, mask); } // static access to these functions - static uint8_t read_byte_static(this_type &space, offs_t address) { return (NATIVE_BITS == 8) ? space.read_native(address & ~NATIVE_MASK) : space.read_direct(address, 0xff); } - static uint16_t read_word_static(this_type &space, offs_t address) { return (NATIVE_BITS == 16) ? space.read_native(address & ~NATIVE_MASK) : space.read_direct(address, 0xffff); } - static uint16_t read_word_masked_static(this_type &space, offs_t address, uint16_t mask) { return space.read_direct(address, mask); } - static uint32_t read_dword_static(this_type &space, offs_t address) { return (NATIVE_BITS == 32) ? space.read_native(address & ~NATIVE_MASK) : space.read_direct(address, 0xffffffff); } - static uint32_t read_dword_masked_static(this_type &space, offs_t address, uint32_t mask) { return space.read_direct(address, mask); } - static uint64_t read_qword_static(this_type &space, offs_t address) { return (NATIVE_BITS == 64) ? space.read_native(address & ~NATIVE_MASK) : space.read_direct(address, U64(0xffffffffffffffff)); } - static uint64_t read_qword_masked_static(this_type &space, offs_t address, uint64_t mask) { return space.read_direct(address, mask); } - static void write_byte_static(this_type &space, offs_t address, uint8_t data) { if (NATIVE_BITS == 8) space.write_native(address & ~NATIVE_MASK, data); else space.write_direct(address, data, 0xff); } - static void write_word_static(this_type &space, offs_t address, uint16_t data) { if (NATIVE_BITS == 16) space.write_native(address & ~NATIVE_MASK, data); else space.write_direct(address, data, 0xffff); } - static void write_word_masked_static(this_type &space, offs_t address, uint16_t data, uint16_t mask) { space.write_direct(address, data, mask); } - static void write_dword_static(this_type &space, offs_t address, uint32_t data) { if (NATIVE_BITS == 32) space.write_native(address & ~NATIVE_MASK, data); else space.write_direct(address, data, 0xffffffff); } - static void write_dword_masked_static(this_type &space, offs_t address, uint32_t data, uint32_t mask) { space.write_direct(address, data, mask); } - static void write_qword_static(this_type &space, offs_t address, uint64_t data) { if (NATIVE_BITS == 64) space.write_native(address & ~NATIVE_MASK, data); else space.write_direct(address, data, U64(0xffffffffffffffff)); } - static void write_qword_masked_static(this_type &space, offs_t address, uint64_t data, uint64_t mask) { space.write_direct(address, data, mask); } + static u8 read_byte_static(this_type &space, offs_t address) { return (NATIVE_BITS == 8) ? space.read_native(address & ~NATIVE_MASK) : space.read_direct(address, 0xff); } + static u16 read_word_static(this_type &space, offs_t address) { return (NATIVE_BITS == 16) ? space.read_native(address & ~NATIVE_MASK) : space.read_direct(address, 0xffff); } + static u16 read_word_masked_static(this_type &space, offs_t address, u16 mask) { return space.read_direct(address, mask); } + static u32 read_dword_static(this_type &space, offs_t address) { return (NATIVE_BITS == 32) ? space.read_native(address & ~NATIVE_MASK) : space.read_direct(address, 0xffffffff); } + static u32 read_dword_masked_static(this_type &space, offs_t address, u32 mask) { return space.read_direct(address, mask); } + static u64 read_qword_static(this_type &space, offs_t address) { return (NATIVE_BITS == 64) ? space.read_native(address & ~NATIVE_MASK) : space.read_direct(address, 0xffffffffffffffffU); } + static u64 read_qword_masked_static(this_type &space, offs_t address, u64 mask) { return space.read_direct(address, mask); } + static void write_byte_static(this_type &space, offs_t address, u8 data) { if (NATIVE_BITS == 8) space.write_native(address & ~NATIVE_MASK, data); else space.write_direct(address, data, 0xff); } + static void write_word_static(this_type &space, offs_t address, u16 data) { if (NATIVE_BITS == 16) space.write_native(address & ~NATIVE_MASK, data); else space.write_direct(address, data, 0xffff); } + static void write_word_masked_static(this_type &space, offs_t address, u16 data, u16 mask) { space.write_direct(address, data, mask); } + static void write_dword_static(this_type &space, offs_t address, u32 data) { if (NATIVE_BITS == 32) space.write_native(address & ~NATIVE_MASK, data); else space.write_direct(address, data, 0xffffffff); } + static void write_dword_masked_static(this_type &space, offs_t address, u32 data, u32 mask) { space.write_direct(address, data, mask); } + static void write_qword_static(this_type &space, offs_t address, u64 data) { if (NATIVE_BITS == 64) space.write_native(address & ~NATIVE_MASK, data); else space.write_direct(address, data, 0xffffffffffffffffU); } + static void write_qword_masked_static(this_type &space, offs_t address, u64 data, u64 mask) { space.write_direct(address, data, mask); } address_table_read m_read; // memory read lookup table address_table_write m_write; // memory write lookup table address_table_setoffset m_setoffset; // memory setoffset lookup table }; -typedef address_space_specific address_space_8le_small; -typedef address_space_specific address_space_8be_small; -typedef address_space_specific address_space_16le_small; -typedef address_space_specific address_space_16be_small; -typedef address_space_specific address_space_32le_small; -typedef address_space_specific address_space_32be_small; -typedef address_space_specific address_space_64le_small; -typedef address_space_specific address_space_64be_small; +typedef address_space_specific address_space_8le_small; +typedef address_space_specific address_space_8be_small; +typedef address_space_specific address_space_16le_small; +typedef address_space_specific address_space_16be_small; +typedef address_space_specific address_space_32le_small; +typedef address_space_specific address_space_32be_small; +typedef address_space_specific address_space_64le_small; +typedef address_space_specific address_space_64be_small; -typedef address_space_specific address_space_8le_large; -typedef address_space_specific address_space_8be_large; -typedef address_space_specific address_space_16le_large; -typedef address_space_specific address_space_16be_large; -typedef address_space_specific address_space_32le_large; -typedef address_space_specific address_space_32be_large; -typedef address_space_specific address_space_64le_large; -typedef address_space_specific address_space_64be_large; +typedef address_space_specific address_space_8le_large; +typedef address_space_specific address_space_8be_large; +typedef address_space_specific address_space_16le_large; +typedef address_space_specific address_space_16be_large; +typedef address_space_specific address_space_32le_large; +typedef address_space_specific address_space_32be_large; +typedef address_space_specific address_space_64le_large; +typedef address_space_specific address_space_64be_large; @@ -1524,7 +1524,7 @@ typedef address_space_specific address_space_ //************************************************************************** // global watchpoint table -uint16_t address_table::s_watchpoint_table[1 << LEVEL1_BITS]; +u16 address_table::s_watchpoint_table[1 << LEVEL1_BITS]; @@ -1648,7 +1648,7 @@ void memory_manager::dump(FILE *file) // region_alloc - allocates memory for a region //------------------------------------------------- -memory_region *memory_manager::region_alloc(const char *name, uint32_t length, uint8_t width, endianness_t endian) +memory_region *memory_manager::region_alloc(const char *name, u32 length, u8 width, endianness_t endian) { osd_printf_verbose("Region '%s' created\n", name); // make sure we don't have a region of the same name; also find the end of the list @@ -1678,7 +1678,7 @@ void memory_manager::region_free(const char *name) memory_region *memory_manager::region_containing(const void *memory, offs_t bytes) const { - const uint8_t *data = reinterpret_cast(memory); + const u8 *data = reinterpret_cast(memory); // look through the region list and return the first match for (auto ®ion : m_regionlist) @@ -2005,7 +2005,7 @@ void address_space::check_address(const char *function, offs_t addrstart, offs_t void address_space::prepare_map() { memory_region *devregion = (m_spacenum == AS_0) ? machine().root_device().memregion(m_device.tag()) : nullptr; - uint32_t devregionsize = (devregion != nullptr) ? devregion->bytes() : 0; + u32 devregionsize = (devregion != nullptr) ? devregion->bytes() : 0; // allocate the address map m_map = std::make_unique(m_device, m_spacenum); @@ -2304,7 +2304,7 @@ void address_space::locate_memory() // intersecting blocks and assign their pointers //------------------------------------------------- -address_map_entry *address_space::block_assign_intersecting(offs_t bytestart, offs_t byteend, uint8_t *base) +address_map_entry *address_space::block_assign_intersecting(offs_t bytestart, offs_t byteend, u8 *base) { address_map_entry *unassigned = nullptr; @@ -2388,7 +2388,7 @@ void address_space::dump_map(FILE *file, read_or_write readorwrite) offs_t bytestart, byteend; for (offs_t byteaddress = 0; byteaddress <= m_bytemask; byteaddress = byteend) { - uint16_t entry = table.derive_range(byteaddress, bytestart, byteend); + u16 entry = table.derive_range(byteaddress, bytestart, byteend); fprintf(file, "%08X-%08X = %02X: %s [offset=%08X]\n", bytestart, byteend, entry, table.handler_name(entry), table.handler(entry).bytestart()); if (++byteend == 0) @@ -2431,7 +2431,7 @@ void address_space::unmap_generic(offs_t addrstart, offs_t addrend, offs_t addrm // of a live device into this address space //------------------------------------------------- -void address_space::install_device_delegate(offs_t addrstart, offs_t addrend, device_t &device, address_map_delegate &delegate, int bits, uint64_t unitmask) +void address_space::install_device_delegate(offs_t addrstart, offs_t addrend, device_t &device, address_map_delegate &delegate, int bits, u64 unitmask) { check_address("install_device_delegate", addrstart, addrend); address_map map(*this, addrstart, addrend, bits, unitmask, m_device, delegate); @@ -2630,7 +2630,7 @@ void address_space::install_ram_generic(offs_t addrstart, offs_t addrend, offs_t // delegate handlers for the space //------------------------------------------------- -void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read8_delegate handler, uint64_t unitmask) +void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read8_delegate handler, u64 unitmask) { VPRINTF(("address_space::install_read_handler(%s-%s mask=%s mirror=%s, %s, %s)\n", core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), @@ -2644,7 +2644,7 @@ void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_ generate_memdump(machine()); } -void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write8_delegate handler, uint64_t unitmask) +void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write8_delegate handler, u64 unitmask) { VPRINTF(("address_space::install_write_handler(%s-%s mask=%s mirror=%s, %s, %s)\n", core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), @@ -2658,7 +2658,7 @@ void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs generate_memdump(machine()); } -void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read8_delegate rhandler, write8_delegate whandler, uint64_t unitmask) +void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read8_delegate rhandler, write8_delegate whandler, u64 unitmask) { install_read_handler(addrstart, addrend, addrmask, addrmirror, addrselect, rhandler, unitmask); install_write_handler(addrstart, addrend, addrmask, addrmirror, addrselect, whandler, unitmask); @@ -2670,7 +2670,7 @@ void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, // delegate handlers for the space //------------------------------------------------- -void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read16_delegate handler, uint64_t unitmask) +void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read16_delegate handler, u64 unitmask) { offs_t nstart, nend, nmask, nmirror; check_optimize_all("install_read_handler", addrstart, addrend, addrmask, addrmirror, addrselect, nstart, nend, nmask, nmirror); @@ -2678,7 +2678,7 @@ void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_ generate_memdump(machine()); } -void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write16_delegate handler, uint64_t unitmask) +void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write16_delegate handler, u64 unitmask) { offs_t nstart, nend, nmask, nmirror; check_optimize_all("install_write_handler", addrstart, addrend, addrmask, addrmirror, addrselect, nstart, nend, nmask, nmirror); @@ -2686,7 +2686,7 @@ void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs generate_memdump(machine()); } -void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read16_delegate rhandler, write16_delegate whandler, uint64_t unitmask) +void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read16_delegate rhandler, write16_delegate whandler, u64 unitmask) { install_read_handler(addrstart, addrend, addrmask, addrmirror, addrselect, rhandler, unitmask); install_write_handler(addrstart, addrend, addrmask, addrmirror, addrselect, whandler, unitmask); @@ -2698,7 +2698,7 @@ void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, // delegate handlers for the space //------------------------------------------------- -void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read32_delegate handler, uint64_t unitmask) +void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read32_delegate handler, u64 unitmask) { offs_t nstart, nend, nmask, nmirror; check_optimize_all("install_read_handler", addrstart, addrend, addrmask, addrmirror, addrselect, nstart, nend, nmask, nmirror); @@ -2706,7 +2706,7 @@ void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_ generate_memdump(machine()); } -void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write32_delegate handler, uint64_t unitmask) +void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write32_delegate handler, u64 unitmask) { offs_t nstart, nend, nmask, nmirror; check_optimize_all("install_write_handler", addrstart, addrend, addrmask, addrmirror, addrselect, nstart, nend, nmask, nmirror); @@ -2714,7 +2714,7 @@ void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs generate_memdump(machine()); } -void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read32_delegate rhandler, write32_delegate whandler, uint64_t unitmask) +void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read32_delegate rhandler, write32_delegate whandler, u64 unitmask) { install_read_handler(addrstart, addrend, addrmask, addrmirror, addrselect, rhandler, unitmask); install_write_handler(addrstart, addrend, addrmask, addrmirror, addrselect, whandler, unitmask); @@ -2726,7 +2726,7 @@ void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, // delegate handlers for the space //------------------------------------------------- -void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read64_delegate handler, uint64_t unitmask) +void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read64_delegate handler, u64 unitmask) { offs_t nstart, nend, nmask, nmirror; check_optimize_all("install_read_handler", addrstart, addrend, addrmask, addrmirror, addrselect, nstart, nend, nmask, nmirror); @@ -2734,7 +2734,7 @@ void address_space::install_read_handler(offs_t addrstart, offs_t addrend, offs_ generate_memdump(machine()); } -void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write64_delegate handler, uint64_t unitmask) +void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write64_delegate handler, u64 unitmask) { offs_t nstart, nend, nmask, nmirror; check_optimize_all("install_write_handler", addrstart, addrend, addrmask, addrmirror, addrselect, nstart, nend, nmask, nmirror); @@ -2742,7 +2742,7 @@ void address_space::install_write_handler(offs_t addrstart, offs_t addrend, offs generate_memdump(machine()); } -void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read64_delegate rhandler, write64_delegate whandler, uint64_t unitmask) +void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read64_delegate rhandler, write64_delegate whandler, u64 unitmask) { install_read_handler(addrstart, addrend, addrmask, addrmirror, addrselect, rhandler, unitmask); install_write_handler(addrstart, addrend, addrmask, addrmirror, addrselect, whandler, unitmask); @@ -2753,7 +2753,7 @@ void address_space::install_readwrite_handler(offs_t addrstart, offs_t addrend, // install_setoffset_handler - install set_offset delegate handlers for the space //----------------------------------------------------------------------- -void address_space::install_setoffset_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, setoffset_delegate handler, uint64_t unitmask) +void address_space::install_setoffset_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, setoffset_delegate handler, u64 unitmask) { VPRINTF(("address_space::install_setoffset_handler(%s-%s mask=%s mirror=%s, %s, %s)\n", core_i64_hex_format(addrstart, m_addrchars), core_i64_hex_format(addrend, m_addrchars), @@ -2792,8 +2792,8 @@ void *address_space::find_backing_memory(offs_t addrstart, offs_t addrend) offs_t maskend = byteend & entry.m_bytemask; if (entry.m_memory != nullptr && maskstart >= entry.m_bytestart && maskend <= entry.m_byteend) { - VPRINTF(("found in entry %08X-%08X [%p]\n", entry.m_addrstart, entry.m_addrend, (uint8_t *)entry.m_memory + (maskstart - entry.m_bytestart))); - return (uint8_t *)entry.m_memory + (maskstart - entry.m_bytestart); + VPRINTF(("found in entry %08X-%08X [%p]\n", entry.m_addrstart, entry.m_addrend, (u8 *)entry.m_memory + (maskstart - entry.m_bytestart))); + return (u8 *)entry.m_memory + (maskstart - entry.m_bytestart); } } @@ -2970,7 +2970,7 @@ address_table::~address_table() // map //------------------------------------------------- -void address_table::map_range(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, uint16_t entry) +void address_table::map_range(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, u16 entry) { // convert addresses to bytes offs_t bytestart = addrstart; @@ -2998,12 +2998,12 @@ void address_table::map_range(offs_t addrstart, offs_t addrend, offs_t addrmask, // verify_reference_counts(); } -uint16_t address_table::get_free_handler() +u16 address_table::get_free_handler() { if (handler_free == STATIC_INVALID) throw emu_fatalerror("Out of handler entries in address table"); - uint16_t handler = handler_free; + u16 handler = handler_free; handler_free = handler_next_free[handler - STATIC_COUNT]; return handler; } @@ -3015,10 +3015,10 @@ uint16_t address_table::get_free_handler() // it //------------------------------------------------- -void address_table::setup_range(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, uint64_t mask, std::list &entries) +void address_table::setup_range(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, u64 mask, std::list &entries) { // Careful, you can't shift by 64 or more - uint64_t testmask = (1ULL << (m_space.data_width()-1) << 1) - 1; + u64 testmask = (1ULL << (m_space.data_width()-1) << 1) - 1; if((mask & testmask) == 0 || (mask & testmask) == testmask) setup_range_solid(addrstart, addrend, addrmask, addrmirror, entries); @@ -3032,10 +3032,10 @@ void address_table::setup_range(offs_t addrstart, offs_t addrend, offs_t addrmas // it. Replace what's there. //------------------------------------------------- -void address_table::setup_range_solid(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, std::list &entries) +void address_table::setup_range_solid(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, std::list &entries) { // Grab a free entry - uint16_t entry = get_free_handler(); + u16 entry = get_free_handler(); // Add it in the "to be setup" list entries.push_back(entry); @@ -3057,7 +3057,7 @@ namespace { }; } -void address_table::setup_range_masked(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, uint64_t mask, std::list &entries) +void address_table::setup_range_masked(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, u64 mask, std::list &entries) { // convert addresses to bytes offs_t bytestart = addrstart; @@ -3073,7 +3073,7 @@ void address_table::setup_range_masked(offs_t addrstart, offs_t addrend, offs_t // Scan the memory to see what has to be done std::list range_override; - std::map > range_partial; + std::map > range_partial; offs_t base_mirror = 0; do @@ -3084,8 +3084,8 @@ void address_table::setup_range_masked(offs_t addrstart, offs_t addrend, offs_t do { offs_t range_start, range_end; - uint16_t entry = derive_range(base_address, range_start, range_end); - uint32_t stop_address = range_end > end_address ? end_address : range_end; + u16 entry = derive_range(base_address, range_start, range_end); + u32 stop_address = range_end > end_address ? end_address : range_end; if (entry < STATIC_COUNT || handler(entry).overriden_by_mask(mask)) range_override.push_back(subrange(base_address, stop_address)); @@ -3105,7 +3105,7 @@ void address_table::setup_range_masked(offs_t addrstart, offs_t addrend, offs_t if (!range_override.empty()) { // Grab a free entry - uint16_t entry = get_free_handler(); + u16 entry = get_free_handler(); // configure the entry to our parameters handler_entry &curentry = handler(entry); @@ -3125,7 +3125,7 @@ void address_table::setup_range_masked(offs_t addrstart, offs_t addrend, offs_t // Ranges in range_partial must be duplicated then partially changed if (!range_partial.empty()) { - for (std::map >::const_iterator i = range_partial.begin(); i != range_partial.end(); ++i) + for (std::map >::const_iterator i = range_partial.begin(); i != range_partial.end(); ++i) { // Theorically, if the handler to change matches the // characteristics of ours, we can directly change it. In @@ -3141,7 +3141,7 @@ void address_table::setup_range_masked(offs_t addrstart, offs_t addrend, offs_t offs_t previous_bytemask = base_entry->bytemask(); // Grab a new handler and copy it there - uint16_t entry = get_free_handler(); + u16 entry = get_free_handler(); handler_entry &curentry = handler(entry); curentry.copy(base_entry); @@ -3184,7 +3184,7 @@ void address_table::verify_reference_counts() for (int level1 = 0; level1 != 1 << LEVEL1_BITS; level1++) { - uint16_t l1_entry = m_table[level1]; + u16 l1_entry = m_table[level1]; if (l1_entry >= SUBTABLE_BASE) { assert(m_large); @@ -3192,10 +3192,10 @@ void address_table::verify_reference_counts() continue; subtable_seen[l1_entry - SUBTABLE_BASE] = true; - const uint16_t *subtable = subtable_ptr(l1_entry); + const u16 *subtable = subtable_ptr(l1_entry); for (int level2 = 0; level2 != 1 << LEVEL2_BITS; level2++) { - uint16_t l2_entry = subtable[level2]; + u16 l2_entry = subtable[level2]; assert(l2_entry < SUBTABLE_BASE); if (l2_entry >= STATIC_COUNT) actual_refcounts[l2_entry - STATIC_COUNT]++; @@ -3220,7 +3220,7 @@ void address_table::verify_reference_counts() // range of addresses //------------------------------------------------- -void address_table::populate_range(offs_t bytestart, offs_t byteend, uint16_t handlerindex) +void address_table::populate_range(offs_t bytestart, offs_t byteend, u16 handlerindex) { offs_t l2mask = (1 << level2_bits()) - 1; offs_t l1start = bytestart >> level2_bits(); @@ -3235,7 +3235,7 @@ void address_table::populate_range(offs_t bytestart, offs_t byteend, uint16_t ha // handle the starting edge if it's not on a block boundary if (l2start != 0) { - uint16_t *subtable = subtable_open(l1start); + u16 *subtable = subtable_open(l1start); // if the start and stop end within the same block, handle that if (l1start == l1stop) @@ -3265,7 +3265,7 @@ void address_table::populate_range(offs_t bytestart, offs_t byteend, uint16_t ha // handle the trailing edge if it's not on a block boundary if (l2stop != l2mask) { - uint16_t *subtable = subtable_open(l1stop); + u16 *subtable = subtable_open(l1stop); // fill from the beginning handler_ref(handlerindex, l2stop+1); @@ -3287,7 +3287,7 @@ void address_table::populate_range(offs_t bytestart, offs_t byteend, uint16_t ha handler_ref(handlerindex, l1stop - l1start + 1); for (offs_t l1index = l1start; l1index <= l1stop; l1index++) { - uint16_t subindex = m_table[l1index]; + u16 subindex = m_table[l1index]; // if we have a subtable here, release it if (subindex >= SUBTABLE_BASE) @@ -3305,7 +3305,7 @@ void address_table::populate_range(offs_t bytestart, offs_t byteend, uint16_t ha // mirrors //------------------------------------------------- -void address_table::populate_range_mirrored(offs_t bytestart, offs_t byteend, offs_t bytemirror, uint16_t handlerindex) +void address_table::populate_range_mirrored(offs_t bytestart, offs_t byteend, offs_t bytemirror, u16 handlerindex) { // determine the mirror bits offs_t lmirrorbits = 0; @@ -3321,7 +3321,7 @@ void address_table::populate_range_mirrored(offs_t bytestart, offs_t byteend, of hmirrorbit[hmirrorbits++] = 1 << bit; // loop over mirrors in the level 2 table - uint16_t prev_entry = STATIC_INVALID; + u16 prev_entry = STATIC_INVALID; int prev_index = 0; for (offs_t hmirrorcount = 0; hmirrorcount < (1 << hmirrorbits); hmirrorcount++) { @@ -3394,11 +3394,11 @@ void address_table::populate_range_mirrored(offs_t bytestart, offs_t byteend, of // range based on the lookup tables //------------------------------------------------- -uint16_t address_table::derive_range(offs_t byteaddress, offs_t &bytestart, offs_t &byteend) const +u16 address_table::derive_range(offs_t byteaddress, offs_t &bytestart, offs_t &byteend) const { // look up the initial address to get the entry we care about - uint16_t l1entry; - uint16_t entry = l1entry = m_table[level1_index(byteaddress)]; + u16 l1entry; + u16 entry = l1entry = m_table[level1_index(byteaddress)]; if (l1entry >= SUBTABLE_BASE) entry = m_table[level2_index(l1entry, byteaddress)]; @@ -3407,16 +3407,16 @@ uint16_t address_table::derive_range(offs_t byteaddress, offs_t &bytestart, offs handler(entry).mirrored_start_end(byteaddress, minscan, maxscan); // first scan backwards to find the start address - uint16_t curl1entry = l1entry; - uint16_t curentry = entry; + u16 curl1entry = l1entry; + u16 curentry = entry; bytestart = byteaddress; while (1) { // if we need to scan the subtable, do it if (curentry != curl1entry) { - uint32_t minindex = level2_index(curl1entry, 0); - uint32_t index; + u32 minindex = level2_index(curl1entry, 0); + u32 index; // scan backwards from the current address, until the previous entry doesn't match for (index = level2_index(curl1entry, bytestart); index > minindex; index--, bytestart -= 1) @@ -3453,8 +3453,8 @@ uint16_t address_table::derive_range(offs_t byteaddress, offs_t &bytestart, offs // if we need to scan the subtable, do it if (curentry != curl1entry) { - uint32_t maxindex = level2_index(curl1entry, ~0); - uint32_t index; + u32 maxindex = level2_index(curl1entry, ~0); + u32 index; // scan forwards from the current address, until the next entry doesn't match for (index = level2_index(curl1entry, byteend); index < maxindex; index++, byteend += 1) @@ -3509,20 +3509,20 @@ void address_table::mask_all_handlers(offs_t mask) // and set its usecount to 1 //------------------------------------------------- -uint16_t address_table::subtable_alloc() +u16 address_table::subtable_alloc() { // loop while (1) { // find a subtable with a usecount of 0 - for (uint16_t subindex = 0; subindex < SUBTABLE_COUNT; subindex++) + for (u16 subindex = 0; subindex < SUBTABLE_COUNT; subindex++) if (m_subtable[subindex].m_usecount == 0) { // if this is past our allocation budget, allocate some more if (subindex >= m_subtable_alloc) { m_subtable_alloc += SUBTABLE_ALLOC; - uint32_t newsize = (1 << LEVEL1_BITS) + (m_subtable_alloc << level2_bits()); + u32 newsize = (1 << LEVEL1_BITS) + (m_subtable_alloc << level2_bits()); bool was_live = (m_live_lookup == &m_table[0]); int oldsize = m_table.size(); @@ -3548,9 +3548,9 @@ uint16_t address_table::subtable_alloc() // a subtable //------------------------------------------------- -void address_table::subtable_realloc(uint16_t subentry) +void address_table::subtable_realloc(u16 subentry) { - uint16_t subindex = subentry - SUBTABLE_BASE; + u16 subindex = subentry - SUBTABLE_BASE; // sanity check if (m_subtable[subindex].m_usecount <= 0) @@ -3569,7 +3569,7 @@ void address_table::subtable_realloc(uint16_t subentry) int address_table::subtable_merge() { int merged = 0; - uint16_t subindex; + u16 subindex; VPRINTF(("Merging subtables....\n")); @@ -3577,8 +3577,8 @@ int address_table::subtable_merge() for (subindex = 0; subindex < SUBTABLE_COUNT; subindex++) if (!m_subtable[subindex].m_checksum_valid && m_subtable[subindex].m_usecount != 0) { - uint32_t *subtable = reinterpret_cast(subtable_ptr(subindex + SUBTABLE_BASE)); - uint32_t checksum = 0; + u32 *subtable = reinterpret_cast(subtable_ptr(subindex + SUBTABLE_BASE)); + u32 checksum = 0; // update the checksum for (int l2index = 0; l2index < (1 << level2_bits())/4; l2index++) @@ -3591,9 +3591,9 @@ int address_table::subtable_merge() for (subindex = 0; subindex < SUBTABLE_COUNT; subindex++) if (m_subtable[subindex].m_usecount != 0) { - uint16_t *subtable = subtable_ptr(subindex + SUBTABLE_BASE); - uint32_t checksum = m_subtable[subindex].m_checksum; - uint16_t sumindex; + u16 *subtable = subtable_ptr(subindex + SUBTABLE_BASE); + u32 checksum = m_subtable[subindex].m_checksum; + u16 sumindex; for (sumindex = subindex + 1; sumindex < SUBTABLE_COUNT; sumindex++) if (m_subtable[sumindex].m_usecount != 0 && @@ -3625,9 +3625,9 @@ int address_table::subtable_merge() // a subtable and free it if we're done //------------------------------------------------- -void address_table::subtable_release(uint16_t subentry) +void address_table::subtable_release(u16 subentry) { - uint16_t subindex = subentry - SUBTABLE_BASE; + u16 subindex = subentry - SUBTABLE_BASE; // sanity check if (m_subtable[subindex].m_usecount <= 0) fatalerror("Called subtable_release on a table with a usecount of 0\n"); @@ -3638,7 +3638,7 @@ void address_table::subtable_release(uint16_t subentry) if (m_subtable[subindex].m_usecount == 0) { m_subtable[subindex].m_checksum = 0; - uint16_t *subtable = subtable_ptr(subentry); + u16 *subtable = subtable_ptr(subentry); for (int i = 0; i < (1 << LEVEL2_BITS); i++) handler_unref(subtable[i]); } @@ -3650,21 +3650,21 @@ void address_table::subtable_release(uint16_t subentry) // modification //------------------------------------------------- -uint16_t *address_table::subtable_open(offs_t l1index) +u16 *address_table::subtable_open(offs_t l1index) { - uint16_t subentry = m_table[l1index]; + u16 subentry = m_table[l1index]; // if we don't have a subtable yet, allocate a new one if (subentry < SUBTABLE_BASE) { int size = 1 << level2_bits(); - uint16_t newentry = subtable_alloc(); + u16 newentry = subtable_alloc(); handler_ref(subentry, size-1); - uint16_t *subptr = subtable_ptr(newentry); + u16 *subptr = subtable_ptr(newentry); for (int i=0; i 1) { - uint16_t newentry = subtable_alloc(); + u16 newentry = subtable_alloc(); // allocate may cause some additional merging -- look up the subentry again // when we're done; it should still require a split @@ -3681,7 +3681,7 @@ uint16_t *address_table::subtable_open(offs_t l1index) assert(m_subtable[subentry - SUBTABLE_BASE].m_usecount > 1); int size = 1 << level2_bits(); - uint16_t *src = subtable_ptr(subentry); + u16 *src = subtable_ptr(subentry); for(int i=0; i != size; i++) handler_ref(src[i], 1); @@ -3715,7 +3715,7 @@ void address_table::subtable_close(offs_t l1index) // description of a handler //------------------------------------------------- -const char *address_table::handler_name(uint16_t entry) const +const char *address_table::handler_name(u16 entry) const { // banks have names if (entry >= STATIC_BANK1 && entry <= STATIC_BANKMAX) @@ -3747,7 +3747,7 @@ address_table_read::address_table_read(address_space &space, bool large) // allocate handlers for each entry, prepopulating the bankptrs for banks for (int entrynum = 0; entrynum < ARRAY_LENGTH(m_handlers); entrynum++) { - uint8_t **bankptr = (entrynum >= STATIC_BANK1 && entrynum <= STATIC_BANKMAX) ? space.manager().bank_pointer_addr(entrynum) : nullptr; + u8 **bankptr = (entrynum >= STATIC_BANK1 && entrynum <= STATIC_BANKMAX) ? space.manager().bank_pointer_addr(entrynum) : nullptr; m_handlers[entrynum] = std::make_unique(space.data_width(), space.endianness(), bankptr); } @@ -3756,30 +3756,30 @@ address_table_read::address_table_read(address_space &space, bool large) { // 8-bit case case 8: - m_handlers[STATIC_UNMAP]->set_delegate(read8_delegate(FUNC(address_table_read::unmap_r), this)); - m_handlers[STATIC_NOP]->set_delegate(read8_delegate(FUNC(address_table_read::nop_r), this)); - m_handlers[STATIC_WATCHPOINT]->set_delegate(read8_delegate(FUNC(address_table_read::watchpoint_r), this)); + m_handlers[STATIC_UNMAP]->set_delegate(read8_delegate(FUNC(address_table_read::unmap_r), this)); + m_handlers[STATIC_NOP]->set_delegate(read8_delegate(FUNC(address_table_read::nop_r), this)); + m_handlers[STATIC_WATCHPOINT]->set_delegate(read8_delegate(FUNC(address_table_read::watchpoint_r), this)); break; // 16-bit case case 16: - m_handlers[STATIC_UNMAP]->set_delegate(read16_delegate(FUNC(address_table_read::unmap_r), this)); - m_handlers[STATIC_NOP]->set_delegate(read16_delegate(FUNC(address_table_read::nop_r), this)); - m_handlers[STATIC_WATCHPOINT]->set_delegate(read16_delegate(FUNC(address_table_read::watchpoint_r), this)); + m_handlers[STATIC_UNMAP]->set_delegate(read16_delegate(FUNC(address_table_read::unmap_r), this)); + m_handlers[STATIC_NOP]->set_delegate(read16_delegate(FUNC(address_table_read::nop_r), this)); + m_handlers[STATIC_WATCHPOINT]->set_delegate(read16_delegate(FUNC(address_table_read::watchpoint_r), this)); break; // 32-bit case case 32: - m_handlers[STATIC_UNMAP]->set_delegate(read32_delegate(FUNC(address_table_read::unmap_r), this)); - m_handlers[STATIC_NOP]->set_delegate(read32_delegate(FUNC(address_table_read::nop_r), this)); - m_handlers[STATIC_WATCHPOINT]->set_delegate(read32_delegate(FUNC(address_table_read::watchpoint_r), this)); + m_handlers[STATIC_UNMAP]->set_delegate(read32_delegate(FUNC(address_table_read::unmap_r), this)); + m_handlers[STATIC_NOP]->set_delegate(read32_delegate(FUNC(address_table_read::nop_r), this)); + m_handlers[STATIC_WATCHPOINT]->set_delegate(read32_delegate(FUNC(address_table_read::watchpoint_r), this)); break; // 64-bit case case 64: - m_handlers[STATIC_UNMAP]->set_delegate(read64_delegate(FUNC(address_table_read::unmap_r), this)); - m_handlers[STATIC_NOP]->set_delegate(read64_delegate(FUNC(address_table_read::nop_r), this)); - m_handlers[STATIC_WATCHPOINT]->set_delegate(read64_delegate(FUNC(address_table_read::watchpoint_r), this)); + m_handlers[STATIC_UNMAP]->set_delegate(read64_delegate(FUNC(address_table_read::unmap_r), this)); + m_handlers[STATIC_NOP]->set_delegate(read64_delegate(FUNC(address_table_read::nop_r), this)); + m_handlers[STATIC_WATCHPOINT]->set_delegate(read64_delegate(FUNC(address_table_read::watchpoint_r), this)); break; } @@ -3804,7 +3804,7 @@ address_table_read::~address_table_read() // this index //------------------------------------------------- -handler_entry &address_table_read::handler(uint32_t index) const +handler_entry &address_table_read::handler(u32 index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; @@ -3821,7 +3821,7 @@ address_table_write::address_table_write(address_space &space, bool large) // allocate handlers for each entry, prepopulating the bankptrs for banks for (int entrynum = 0; entrynum < ARRAY_LENGTH(m_handlers); entrynum++) { - uint8_t **bankptr = (entrynum >= STATIC_BANK1 && entrynum <= STATIC_BANKMAX) ? space.manager().bank_pointer_addr(entrynum) : nullptr; + u8 **bankptr = (entrynum >= STATIC_BANK1 && entrynum <= STATIC_BANKMAX) ? space.manager().bank_pointer_addr(entrynum) : nullptr; m_handlers[entrynum] = std::make_unique(space.data_width(), space.endianness(), bankptr); } @@ -3830,30 +3830,30 @@ address_table_write::address_table_write(address_space &space, bool large) { // 8-bit case case 8: - m_handlers[STATIC_UNMAP]->set_delegate(write8_delegate(FUNC(address_table_write::unmap_w), this)); - m_handlers[STATIC_NOP]->set_delegate(write8_delegate(FUNC(address_table_write::nop_w), this)); - m_handlers[STATIC_WATCHPOINT]->set_delegate(write8_delegate(FUNC(address_table_write::watchpoint_w), this)); + m_handlers[STATIC_UNMAP]->set_delegate(write8_delegate(FUNC(address_table_write::unmap_w), this)); + m_handlers[STATIC_NOP]->set_delegate(write8_delegate(FUNC(address_table_write::nop_w), this)); + m_handlers[STATIC_WATCHPOINT]->set_delegate(write8_delegate(FUNC(address_table_write::watchpoint_w), this)); break; // 16-bit case case 16: - m_handlers[STATIC_UNMAP]->set_delegate(write16_delegate(FUNC(address_table_write::unmap_w), this)); - m_handlers[STATIC_NOP]->set_delegate(write16_delegate(FUNC(address_table_write::nop_w), this)); - m_handlers[STATIC_WATCHPOINT]->set_delegate(write16_delegate(FUNC(address_table_write::watchpoint_w), this)); + m_handlers[STATIC_UNMAP]->set_delegate(write16_delegate(FUNC(address_table_write::unmap_w), this)); + m_handlers[STATIC_NOP]->set_delegate(write16_delegate(FUNC(address_table_write::nop_w), this)); + m_handlers[STATIC_WATCHPOINT]->set_delegate(write16_delegate(FUNC(address_table_write::watchpoint_w), this)); break; // 32-bit case case 32: - m_handlers[STATIC_UNMAP]->set_delegate(write32_delegate(FUNC(address_table_write::unmap_w), this)); - m_handlers[STATIC_NOP]->set_delegate(write32_delegate(FUNC(address_table_write::nop_w), this)); - m_handlers[STATIC_WATCHPOINT]->set_delegate(write32_delegate(FUNC(address_table_write::watchpoint_w), this)); + m_handlers[STATIC_UNMAP]->set_delegate(write32_delegate(FUNC(address_table_write::unmap_w), this)); + m_handlers[STATIC_NOP]->set_delegate(write32_delegate(FUNC(address_table_write::nop_w), this)); + m_handlers[STATIC_WATCHPOINT]->set_delegate(write32_delegate(FUNC(address_table_write::watchpoint_w), this)); break; // 64-bit case case 64: - m_handlers[STATIC_UNMAP]->set_delegate(write64_delegate(FUNC(address_table_write::unmap_w), this)); - m_handlers[STATIC_NOP]->set_delegate(write64_delegate(FUNC(address_table_write::nop_w), this)); - m_handlers[STATIC_WATCHPOINT]->set_delegate(write64_delegate(FUNC(address_table_write::watchpoint_w), this)); + m_handlers[STATIC_UNMAP]->set_delegate(write64_delegate(FUNC(address_table_write::unmap_w), this)); + m_handlers[STATIC_NOP]->set_delegate(write64_delegate(FUNC(address_table_write::nop_w), this)); + m_handlers[STATIC_WATCHPOINT]->set_delegate(write64_delegate(FUNC(address_table_write::watchpoint_w), this)); break; } @@ -3878,7 +3878,7 @@ address_table_write::~address_table_write() // this index //------------------------------------------------- -handler_entry &address_table_write::handler(uint32_t index) const +handler_entry &address_table_write::handler(u32 index) const { assert(index < ARRAY_LENGTH(m_handlers)); return *m_handlers[index]; @@ -3944,7 +3944,7 @@ bool direct_read_data::set_direct_region(offs_t &byteaddress) return false; } - uint8_t *base = *m_space.manager().bank_pointer_addr(m_entry); + u8 *base = *m_space.manager().bank_pointer_addr(m_entry); // compute the adjusted base offs_t maskedbits = overrideaddress & ~m_space.bytemask(); @@ -3961,7 +3961,7 @@ bool direct_read_data::set_direct_region(offs_t &byteaddress) // find_range - find a byte address in a range //------------------------------------------------- -direct_read_data::direct_range *direct_read_data::find_range(offs_t byteaddress, uint16_t &entry) +direct_read_data::direct_range *direct_read_data::find_range(offs_t byteaddress, u16 &entry) { // determine which entry byteaddress &= m_space.m_bytemask; @@ -4028,7 +4028,7 @@ void direct_read_data::explicit_configure(offs_t bytestart, offs_t byteend, offs m_bytestart = bytestart; m_byteend = byteend; m_bytemask = bytemask; - m_ptr = reinterpret_cast(ptr) - (bytestart & bytemask); + m_ptr = reinterpret_cast(ptr) - (bytestart & bytemask); } @@ -4046,7 +4046,7 @@ memory_block::memory_block(address_space &space, offs_t bytestart, offs_t byteen m_space(space), m_bytestart(bytestart), m_byteend(byteend), - m_data(reinterpret_cast(memory)) + m_data(reinterpret_cast(memory)) { offs_t const length = byteend + 1 - bytestart; VPRINTF(("block_allocate('%s',%s,%08X,%08X,%p)\n", space.device().tag(), space.name(), bytestart, byteend, memory)); @@ -4064,7 +4064,7 @@ memory_block::memory_block(address_space &space, offs_t bytestart, offs_t byteen { m_allocated.resize(length + 0xfff); memset(&m_allocated[0], 0, length + 0xfff); - m_data = reinterpret_cast((reinterpret_cast(&m_allocated[0]) + 0xfff) & ~0xfff); + m_data = reinterpret_cast((reinterpret_cast(&m_allocated[0]) + 0xfff) & ~0xfff); } } @@ -4075,7 +4075,7 @@ memory_block::memory_block(address_space &space, offs_t bytestart, offs_t byteen { int bytes_per_element = space.data_width() / 8; std::string name = string_format("%08x-%08x", bytestart, byteend); - space.machine().save().save_memory(nullptr, "memory", space.device().tag(), space.spacenum(), name.c_str(), m_data, bytes_per_element, (uint32_t)length / bytes_per_element); + space.machine().save().save_memory(nullptr, "memory", space.device().tag(), space.spacenum(), name.c_str(), m_data, bytes_per_element, (u32)length / bytes_per_element); } } @@ -4186,7 +4186,7 @@ void memory_bank::set_base(void *base) throw emu_fatalerror("memory_bank::set_base called nullptr base"); // set the base and invalidate any referencing spaces - *m_baseptr = reinterpret_cast(base); + *m_baseptr = reinterpret_cast(base); invalidate_references(); } @@ -4243,7 +4243,7 @@ void memory_bank::configure_entry(int entrynum, void *base) expand_entries(entrynum); // set the entry - m_entry[entrynum].m_ptr = reinterpret_cast(base); + m_entry[entrynum].m_ptr = reinterpret_cast(base); // if the bank base is not configured, and we're the first entry, set us up if (*m_baseptr == nullptr && entrynum == 0) @@ -4259,7 +4259,7 @@ void memory_bank::configure_entries(int startentry, int numentries, void *base, { // fill in the requested bank entries (backwards to improve allocation) for (int entrynum = startentry + numentries - 1; entrynum >= startentry; entrynum--) - configure_entry(entrynum, reinterpret_cast(base) + (entrynum - startentry) * stride); + configure_entry(entrynum, reinterpret_cast(base) + (entrynum - startentry) * stride); } @@ -4271,7 +4271,7 @@ void memory_bank::configure_entries(int startentry, int numentries, void *base, // memory_region - constructor //------------------------------------------------- -memory_region::memory_region(running_machine &machine, const char *name, uint32_t length, uint8_t width, endianness_t endian) +memory_region::memory_region(running_machine &machine, const char *name, u32 length, u8 width, endianness_t endian) : m_machine(machine), m_name(name), m_buffer(length), @@ -4292,7 +4292,7 @@ memory_region::memory_region(running_machine &machine, const char *name, uint32_ // handler_entry - constructor //------------------------------------------------- -handler_entry::handler_entry(uint8_t width, endianness_t endianness, uint8_t **rambaseptr) +handler_entry::handler_entry(u8 width, endianness_t endianness, u8 **rambaseptr) : m_populated(false), m_datawidth(width), m_endianness(endianness), @@ -4347,7 +4347,7 @@ void handler_entry::copy(handler_entry *entry) //------------------------------------------------- void handler_entry::reconfigure_subunits(offs_t bytestart) { - int32_t delta = bytestart - m_bytestart; + s32 delta = bytestart - m_bytestart; for (int i=0; i != m_subunits; i++) m_subunit_infos[i].m_offset += delta / (m_subunit_infos[i].m_size / 8); } @@ -4359,9 +4359,9 @@ void handler_entry::reconfigure_subunits(offs_t bytestart) // mask //------------------------------------------------- -void handler_entry::configure_subunits(uint64_t handlermask, int handlerbits, int &start_slot, int &end_slot) +void handler_entry::configure_subunits(u64 handlermask, int handlerbits, int &start_slot, int &end_slot) { - uint64_t unitmask = ((uint64_t)1 << handlerbits) - 1; + u64 unitmask = ((u64)1 << handlerbits) - 1; assert(handlermask != 0); // compute the maximum possible subunits @@ -4375,8 +4375,8 @@ void handler_entry::configure_subunits(uint64_t handlermask, int handlerbits, in int count = 0; for (int unitnum = 0; unitnum < maxunits; unitnum++) { - uint32_t shift = unitnum * handlerbits; - uint32_t scanmask = handlermask >> shift; + u32 shift = unitnum * handlerbits; + u32 scanmask = handlermask >> shift; assert((scanmask & unitmask) == 0 || (scanmask & unitmask) == unitmask); if ((scanmask & unitmask) != 0) count++; @@ -4387,7 +4387,7 @@ void handler_entry::configure_subunits(uint64_t handlermask, int handlerbits, in start_slot = m_subunits; for (int unitnum = 0; unitnum < maxunits; unitnum++) { - uint32_t shift = (unitnum^shift_xor_mask) * handlerbits; + u32 shift = (unitnum^shift_xor_mask) * handlerbits; if (((handlermask >> shift) & unitmask) != 0) { m_subunit_infos[m_subunits].m_bytemask = m_bytemask; @@ -4405,7 +4405,7 @@ void handler_entry::configure_subunits(uint64_t handlermask, int handlerbits, in // compute the inverse mask m_invsubmask = 0; for (int i = 0; i < m_subunits; i++) - m_invsubmask |= uint64_t(m_subunit_infos[i].m_mask) << m_subunit_infos[i].m_shift; + m_invsubmask |= u64(m_subunit_infos[i].m_mask) << m_subunit_infos[i].m_shift; m_invsubmask = ~m_invsubmask; } @@ -4415,7 +4415,7 @@ void handler_entry::configure_subunits(uint64_t handlermask, int handlerbits, in // conflicting with the provided mask //------------------------------------------------- -void handler_entry::clear_conflicting_subunits(uint64_t handlermask) +void handler_entry::clear_conflicting_subunits(u64 handlermask) { // A mask of 0 is in fact an alternative way of saying ~0 if (!handlermask) @@ -4436,7 +4436,7 @@ void handler_entry::clear_conflicting_subunits(uint64_t handlermask) // compute the inverse mask m_invsubmask = 0; for (int i = 0; i < m_subunits; i++) - m_invsubmask |= uint64_t(m_subunit_infos[i].m_mask) << m_subunit_infos[i].m_shift; + m_invsubmask |= u64(m_subunit_infos[i].m_mask) << m_subunit_infos[i].m_shift; m_invsubmask = ~m_invsubmask; } @@ -4447,7 +4447,7 @@ void handler_entry::clear_conflicting_subunits(uint64_t handlermask) // that's currently present //------------------------------------------------- -bool handler_entry::overriden_by_mask(uint64_t handlermask) +bool handler_entry::overriden_by_mask(u64 handlermask) { // A mask of 0 is in fact an alternative way of saying ~0 if (!handlermask) @@ -4580,7 +4580,7 @@ void handler_entry_read::remove_subunit(int entry) // configure a stub if necessary //------------------------------------------------- -void handler_entry_read::set_delegate(read8_delegate delegate, uint64_t mask) +void handler_entry_read::set_delegate(read8_delegate delegate, u64 mask) { // error if no object if (!delegate.has_object()) @@ -4617,7 +4617,7 @@ void handler_entry_read::set_delegate(read8_delegate delegate, uint64_t mask) // configure a stub if necessary //------------------------------------------------- -void handler_entry_read::set_delegate(read16_delegate delegate, uint64_t mask) +void handler_entry_read::set_delegate(read16_delegate delegate, u64 mask) { // error if no object if (!delegate.has_object()) @@ -4652,7 +4652,7 @@ void handler_entry_read::set_delegate(read16_delegate delegate, uint64_t mask) // configure a stub if necessary //------------------------------------------------- -void handler_entry_read::set_delegate(read32_delegate delegate, uint64_t mask) +void handler_entry_read::set_delegate(read32_delegate delegate, u64 mask) { // error if no object if (!delegate.has_object()) @@ -4684,7 +4684,7 @@ void handler_entry_read::set_delegate(read32_delegate delegate, uint64_t mask) // set_delegate - set a 64-bit delegate //------------------------------------------------- -void handler_entry_read::set_delegate(read64_delegate delegate, uint64_t mask) +void handler_entry_read::set_delegate(read64_delegate delegate, u64 mask) { // error if no object if (!delegate.has_object()) @@ -4705,13 +4705,13 @@ void handler_entry_read::set_ioport(ioport_port &ioport) { m_ioport = &ioport; if (m_datawidth == 8) - set_delegate(read8_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); + set_delegate(read8_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 16) - set_delegate(read16_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); + set_delegate(read16_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 32) - set_delegate(read32_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); + set_delegate(read32_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 64) - set_delegate(read64_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); + set_delegate(read64_delegate(&handler_entry_read::read_stub_ioport, ioport.tag(), this)); } @@ -4720,17 +4720,17 @@ void handler_entry_read::set_ioport(ioport_port &ioport) // 8-bit sources //------------------------------------------------- -uint16_t handler_entry_read::read_stub_16(address_space &space, offs_t offset, uint16_t mask) +u16 handler_entry_read::read_stub_16(address_space &space, offs_t offset, u16 mask) { - uint16_t result = space.unmap() & m_invsubmask; + u16 result = space.unmap() & m_invsubmask; for (int index = 0; index < m_subunits; index++) { const subunit_info &si = m_subunit_infos[index]; - uint32_t submask = (mask >> si.m_shift) & si.m_mask; + u32 submask = (mask >> si.m_shift) & si.m_mask; if (submask) { offs_t aoffset = offset * si.m_multiplier + si.m_offset; - uint8_t val; + u8 val; val = m_subread[index].r8(space, aoffset & si.m_bytemask, submask); result |= val << si.m_shift; } @@ -4744,17 +4744,17 @@ uint16_t handler_entry_read::read_stub_16(address_space &space, offs_t offset, u // 8-bit and 16-bit sources //------------------------------------------------- -uint32_t handler_entry_read::read_stub_32(address_space &space, offs_t offset, uint32_t mask) +u32 handler_entry_read::read_stub_32(address_space &space, offs_t offset, u32 mask) { - uint32_t result = space.unmap() & m_invsubmask; + u32 result = space.unmap() & m_invsubmask; for (int index = 0; index < m_subunits; index++) { const subunit_info &si = m_subunit_infos[index]; - uint32_t submask = (mask >> si.m_shift) & si.m_mask; + u32 submask = (mask >> si.m_shift) & si.m_mask; if (submask) { offs_t aoffset = offset * si.m_multiplier + si.m_offset; - uint16_t val = 0; + u16 val = 0; switch (si.m_size) { case 8: @@ -4776,17 +4776,17 @@ uint32_t handler_entry_read::read_stub_32(address_space &space, offs_t offset, u // 8-bit, 16-bit and 32-bit sources //------------------------------------------------- -uint64_t handler_entry_read::read_stub_64(address_space &space, offs_t offset, uint64_t mask) +u64 handler_entry_read::read_stub_64(address_space &space, offs_t offset, u64 mask) { - uint64_t result = space.unmap() & m_invsubmask; + u64 result = space.unmap() & m_invsubmask; for (int index = 0; index < m_subunits; index++) { const subunit_info &si = m_subunit_infos[index]; - uint32_t submask = (mask >> si.m_shift) & si.m_mask; + u32 submask = (mask >> si.m_shift) & si.m_mask; if (submask) { offs_t aoffset = offset * si.m_multiplier + si.m_offset; - uint32_t val = 0; + u32 val = 0; switch (si.m_size) { case 8: @@ -4799,7 +4799,7 @@ uint64_t handler_entry_read::read_stub_64(address_space &space, offs_t offset, u val = m_subread[index].r32(space, aoffset & si.m_bytemask, submask); break; } - result |= uint64_t(val) << si.m_shift; + result |= u64(val) << si.m_shift; } } return result; @@ -4894,7 +4894,7 @@ void handler_entry_write::remove_subunit(int entry) // configure a stub if necessary //------------------------------------------------- -void handler_entry_write::set_delegate(write8_delegate delegate, uint64_t mask) +void handler_entry_write::set_delegate(write8_delegate delegate, u64 mask) { assert(m_datawidth >= 8); @@ -4926,7 +4926,7 @@ void handler_entry_write::set_delegate(write8_delegate delegate, uint64_t mask) // configure a stub if necessary //------------------------------------------------- -void handler_entry_write::set_delegate(write16_delegate delegate, uint64_t mask) +void handler_entry_write::set_delegate(write16_delegate delegate, u64 mask) { assert(m_datawidth >= 16); @@ -4956,7 +4956,7 @@ void handler_entry_write::set_delegate(write16_delegate delegate, uint64_t mask) // configure a stub if necessary //------------------------------------------------- -void handler_entry_write::set_delegate(write32_delegate delegate, uint64_t mask) +void handler_entry_write::set_delegate(write32_delegate delegate, u64 mask) { assert(m_datawidth >= 32); @@ -4983,7 +4983,7 @@ void handler_entry_write::set_delegate(write32_delegate delegate, uint64_t mask) // set_delegate - set a 64-bit delegate //------------------------------------------------- -void handler_entry_write::set_delegate(write64_delegate delegate, uint64_t mask) +void handler_entry_write::set_delegate(write64_delegate delegate, u64 mask) { assert(m_datawidth >= 64); m_write.w64 = delegate; @@ -4999,13 +4999,13 @@ void handler_entry_write::set_ioport(ioport_port &ioport) { m_ioport = &ioport; if (m_datawidth == 8) - set_delegate(write8_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); + set_delegate(write8_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 16) - set_delegate(write16_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); + set_delegate(write16_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 32) - set_delegate(write32_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); + set_delegate(write32_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); else if (m_datawidth == 64) - set_delegate(write64_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); + set_delegate(write64_delegate(&handler_entry_write::write_stub_ioport, ioport.tag(), this)); } @@ -5014,16 +5014,16 @@ void handler_entry_write::set_ioport(ioport_port &ioport) // 8-bit sources //------------------------------------------------- -void handler_entry_write::write_stub_16(address_space &space, offs_t offset, uint16_t data, uint16_t mask) +void handler_entry_write::write_stub_16(address_space &space, offs_t offset, u16 data, u16 mask) { for (int index = 0; index < m_subunits; index++) { const subunit_info &si = m_subunit_infos[index]; - uint32_t submask = (mask >> si.m_shift) & si.m_mask; + u32 submask = (mask >> si.m_shift) & si.m_mask; if (submask) { offs_t aoffset = offset * si.m_multiplier + si.m_offset; - uint8_t adata = data >> si.m_shift; + u8 adata = data >> si.m_shift; m_subwrite[index].w8(space, aoffset & si.m_bytemask, adata, submask); } } @@ -5035,16 +5035,16 @@ void handler_entry_write::write_stub_16(address_space &space, offs_t offset, uin // 8-bit and 16-bit sources //------------------------------------------------- -void handler_entry_write::write_stub_32(address_space &space, offs_t offset, uint32_t data, uint32_t mask) +void handler_entry_write::write_stub_32(address_space &space, offs_t offset, u32 data, u32 mask) { for (int index = 0; index < m_subunits; index++) { const subunit_info &si = m_subunit_infos[index]; - uint32_t submask = (mask >> si.m_shift) & si.m_mask; + u32 submask = (mask >> si.m_shift) & si.m_mask; if (submask) { offs_t aoffset = offset * si.m_multiplier + si.m_offset; - uint16_t adata = data >> si.m_shift; + u16 adata = data >> si.m_shift; switch (si.m_size) { case 8: @@ -5064,16 +5064,16 @@ void handler_entry_write::write_stub_32(address_space &space, offs_t offset, uin // 8-bit, 16-bit and 32-bit sources //------------------------------------------------- -void handler_entry_write::write_stub_64(address_space &space, offs_t offset, uint64_t data, uint64_t mask) +void handler_entry_write::write_stub_64(address_space &space, offs_t offset, u64 data, u64 mask) { for (int index = 0; index < m_subunits; index++) { const subunit_info &si = m_subunit_infos[index]; - uint32_t submask = (mask >> si.m_shift) & si.m_mask; + u32 submask = (mask >> si.m_shift) & si.m_mask; if (submask) { offs_t aoffset = offset * si.m_multiplier + si.m_offset; - uint32_t adata = data >> si.m_shift; + u32 adata = data >> si.m_shift; switch (si.m_size) { case 8: diff --git a/src/emu/emumem.h b/src/emu/emumem.h index ccdc6c28335..6112bbdd5f5 100644 --- a/src/emu/emumem.h +++ b/src/emu/emumem.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __EMUMEM_H__ -#define __EMUMEM_H__ +#ifndef MAME_EMU_EMUMEM_H +#define MAME_EMU_EMUMEM_H @@ -77,7 +77,7 @@ class address_table_setoffset; // offsets and addresses are 32-bit (for now...) -typedef uint32_t offs_t; +typedef u32 offs_t; // address map constructors are functions that build up an address_map typedef void (*address_map_constructor)(address_map &map); @@ -88,21 +88,21 @@ typedef named_delegate address_map_delegate; // struct with function pointers for accessors; use is generally discouraged unless necessary struct data_accessors { - uint8_t (*read_byte)(address_space &space, offs_t byteaddress); - uint16_t (*read_word)(address_space &space, offs_t byteaddress); - uint16_t (*read_word_masked)(address_space &space, offs_t byteaddress, uint16_t mask); - uint32_t (*read_dword)(address_space &space, offs_t byteaddress); - uint32_t (*read_dword_masked)(address_space &space, offs_t byteaddress, uint32_t mask); - uint64_t (*read_qword)(address_space &space, offs_t byteaddress); - uint64_t (*read_qword_masked)(address_space &space, offs_t byteaddress, uint64_t mask); + u8 (*read_byte)(address_space &space, offs_t byteaddress); + u16 (*read_word)(address_space &space, offs_t byteaddress); + u16 (*read_word_masked)(address_space &space, offs_t byteaddress, u16 mask); + u32 (*read_dword)(address_space &space, offs_t byteaddress); + u32 (*read_dword_masked)(address_space &space, offs_t byteaddress, u32 mask); + u64 (*read_qword)(address_space &space, offs_t byteaddress); + u64 (*read_qword_masked)(address_space &space, offs_t byteaddress, u64 mask); - void (*write_byte)(address_space &space, offs_t byteaddress, uint8_t data); - void (*write_word)(address_space &space, offs_t byteaddress, uint16_t data); - void (*write_word_masked)(address_space &space, offs_t byteaddress, uint16_t data, uint16_t mask); - void (*write_dword)(address_space &space, offs_t byteaddress, uint32_t data); - void (*write_dword_masked)(address_space &space, offs_t byteaddress, uint32_t data, uint32_t mask); - void (*write_qword)(address_space &space, offs_t byteaddress, uint64_t data); - void (*write_qword_masked)(address_space &space, offs_t byteaddress, uint64_t data, uint64_t mask); + void (*write_byte)(address_space &space, offs_t byteaddress, u8 data); + void (*write_word)(address_space &space, offs_t byteaddress, u16 data); + void (*write_word_masked)(address_space &space, offs_t byteaddress, u16 data, u16 mask); + void (*write_dword)(address_space &space, offs_t byteaddress, u32 data); + void (*write_dword_masked)(address_space &space, offs_t byteaddress, u32 data, u32 mask); + void (*write_qword)(address_space &space, offs_t byteaddress, u64 data); + void (*write_qword_masked)(address_space &space, offs_t byteaddress, u64 data, u64 mask); }; @@ -115,19 +115,19 @@ typedef delegate direct_update_delegate; // ======================> read_delegate // declare delegates for each width -typedef device_delegate read8_delegate; -typedef device_delegate read16_delegate; -typedef device_delegate read32_delegate; -typedef device_delegate read64_delegate; +typedef device_delegate read8_delegate; +typedef device_delegate read16_delegate; +typedef device_delegate read32_delegate; +typedef device_delegate read64_delegate; // ======================> write_delegate // declare delegates for each width -typedef device_delegate write8_delegate; -typedef device_delegate write16_delegate; -typedef device_delegate write32_delegate; -typedef device_delegate write64_delegate; +typedef device_delegate write8_delegate; +typedef device_delegate write16_delegate; +typedef device_delegate write32_delegate; +typedef device_delegate write64_delegate; // ======================> setoffset_delegate @@ -165,14 +165,14 @@ public: // getters address_space &space() const { return m_space; } - uint8_t *ptr() const { return m_ptr; } + u8 *ptr() const { return m_ptr; } // see if an address is within bounds, or attempt to update it if not bool address_is_valid(offs_t byteaddress) { return EXPECTED(byteaddress >= m_bytestart && byteaddress <= m_byteend) || set_direct_region(byteaddress); } // force a recomputation on the next read void force_update() { m_byteend = 0; m_bytestart = 1; } - void force_update(uint16_t if_match) { if (m_entry == if_match) force_update(); } + void force_update(u16 if_match) { if (m_entry == if_match) force_update(); } // custom update callbacks and configuration direct_update_delegate set_direct_update(direct_update_delegate function); @@ -180,24 +180,24 @@ public: // accessor methods void *read_ptr(offs_t byteaddress, offs_t directxor = 0); - uint8_t read_byte(offs_t byteaddress, offs_t directxor = 0); - uint16_t read_word(offs_t byteaddress, offs_t directxor = 0); - uint32_t read_dword(offs_t byteaddress, offs_t directxor = 0); - uint64_t read_qword(offs_t byteaddress, offs_t directxor = 0); + u8 read_byte(offs_t byteaddress, offs_t directxor = 0); + u16 read_word(offs_t byteaddress, offs_t directxor = 0); + u32 read_dword(offs_t byteaddress, offs_t directxor = 0); + u64 read_qword(offs_t byteaddress, offs_t directxor = 0); private: // internal helpers bool set_direct_region(offs_t &byteaddress); - direct_range *find_range(offs_t byteaddress, uint16_t &entry); + direct_range *find_range(offs_t byteaddress, u16 &entry); void remove_intersecting_ranges(offs_t bytestart, offs_t byteend); // internal state address_space & m_space; - uint8_t * m_ptr; // direct access data pointer + u8 * m_ptr; // direct access data pointer offs_t m_bytemask; // byte address mask offs_t m_bytestart; // minimum valid byte address offs_t m_byteend; // maximum valid byte address - uint16_t m_entry; // live entry + u16 m_entry; // live entry std::list m_rangelist[TOTAL_MEMORY_BANKS]; // list of ranges for each entry direct_update_delegate m_directupdate; // fast direct-access update callback }; @@ -211,10 +211,10 @@ class address_space_config public: // construction/destruction address_space_config(); - address_space_config(const char *name, endianness_t endian, uint8_t datawidth, uint8_t addrwidth, int8_t addrshift = 0, address_map_constructor internal = nullptr, address_map_constructor defmap = nullptr); - address_space_config(const char *name, endianness_t endian, uint8_t datawidth, uint8_t addrwidth, int8_t addrshift, uint8_t logwidth, uint8_t pageshift, address_map_constructor internal = nullptr, address_map_constructor defmap = nullptr); - address_space_config(const char *name, endianness_t endian, uint8_t datawidth, uint8_t addrwidth, int8_t addrshift, address_map_delegate internal, address_map_delegate defmap = address_map_delegate()); - address_space_config(const char *name, endianness_t endian, uint8_t datawidth, uint8_t addrwidth, int8_t addrshift, uint8_t logwidth, uint8_t pageshift, address_map_delegate internal, address_map_delegate defmap = address_map_delegate()); + address_space_config(const char *name, endianness_t endian, u8 datawidth, u8 addrwidth, s8 addrshift = 0, address_map_constructor internal = nullptr, address_map_constructor defmap = nullptr); + address_space_config(const char *name, endianness_t endian, u8 datawidth, u8 addrwidth, s8 addrshift, u8 logwidth, u8 pageshift, address_map_constructor internal = nullptr, address_map_constructor defmap = nullptr); + address_space_config(const char *name, endianness_t endian, u8 datawidth, u8 addrwidth, s8 addrshift, address_map_delegate internal, address_map_delegate defmap = address_map_delegate()); + address_space_config(const char *name, endianness_t endian, u8 datawidth, u8 addrwidth, s8 addrshift, u8 logwidth, u8 pageshift, address_map_delegate internal, address_map_delegate defmap = address_map_delegate()); // getters const char *name() const { return m_name; } @@ -231,11 +231,11 @@ public: // state const char * m_name; endianness_t m_endianness; - uint8_t m_databus_width; - uint8_t m_addrbus_width; - int8_t m_addrbus_shift; - uint8_t m_logaddr_width; - uint8_t m_page_shift; + u8 m_databus_width; + u8 m_addrbus_width; + s8 m_addrbus_shift; + u8 m_logaddr_width; + u8 m_page_shift; bool m_is_octal; // to determine if messages/debugger will show octal or hex address_map_constructor m_internal_map; @@ -278,15 +278,15 @@ public: int data_width() const { return m_config.data_width(); } int addr_width() const { return m_config.addr_width(); } endianness_t endianness() const { return m_config.endianness(); } - uint64_t unmap() const { return m_unmap; } + u64 unmap() const { return m_unmap; } bool is_octal() const { return m_config.m_is_octal; } offs_t addrmask() const { return m_addrmask; } offs_t bytemask() const { return m_bytemask; } - uint8_t addrchars() const { return m_addrchars; } + u8 addrchars() const { return m_addrchars; } offs_t logaddrmask() const { return m_logaddrmask; } offs_t logbytemask() const { return m_logbytemask; } - uint8_t logaddrchars() const { return m_logaddrchars; } + u8 logaddrchars() const { return m_logaddrchars; } // debug helpers const char *get_handler_string(read_or_write readorwrite, offs_t byteaddress); @@ -306,34 +306,34 @@ public: virtual void *get_write_ptr(offs_t byteaddress) = 0; // read accessors - virtual uint8_t read_byte(offs_t byteaddress) = 0; - virtual uint16_t read_word(offs_t byteaddress) = 0; - virtual uint16_t read_word(offs_t byteaddress, uint16_t mask) = 0; - virtual uint16_t read_word_unaligned(offs_t byteaddress) = 0; - virtual uint16_t read_word_unaligned(offs_t byteaddress, uint16_t mask) = 0; - virtual uint32_t read_dword(offs_t byteaddress) = 0; - virtual uint32_t read_dword(offs_t byteaddress, uint32_t mask) = 0; - virtual uint32_t read_dword_unaligned(offs_t byteaddress) = 0; - virtual uint32_t read_dword_unaligned(offs_t byteaddress, uint32_t mask) = 0; - virtual uint64_t read_qword(offs_t byteaddress) = 0; - virtual uint64_t read_qword(offs_t byteaddress, uint64_t mask) = 0; - virtual uint64_t read_qword_unaligned(offs_t byteaddress) = 0; - virtual uint64_t read_qword_unaligned(offs_t byteaddress, uint64_t mask) = 0; + virtual u8 read_byte(offs_t byteaddress) = 0; + virtual u16 read_word(offs_t byteaddress) = 0; + virtual u16 read_word(offs_t byteaddress, u16 mask) = 0; + virtual u16 read_word_unaligned(offs_t byteaddress) = 0; + virtual u16 read_word_unaligned(offs_t byteaddress, u16 mask) = 0; + virtual u32 read_dword(offs_t byteaddress) = 0; + virtual u32 read_dword(offs_t byteaddress, u32 mask) = 0; + virtual u32 read_dword_unaligned(offs_t byteaddress) = 0; + virtual u32 read_dword_unaligned(offs_t byteaddress, u32 mask) = 0; + virtual u64 read_qword(offs_t byteaddress) = 0; + virtual u64 read_qword(offs_t byteaddress, u64 mask) = 0; + virtual u64 read_qword_unaligned(offs_t byteaddress) = 0; + virtual u64 read_qword_unaligned(offs_t byteaddress, u64 mask) = 0; // write accessors - virtual void write_byte(offs_t byteaddress, uint8_t data) = 0; - virtual void write_word(offs_t byteaddress, uint16_t data) = 0; - virtual void write_word(offs_t byteaddress, uint16_t data, uint16_t mask) = 0; - virtual void write_word_unaligned(offs_t byteaddress, uint16_t data) = 0; - virtual void write_word_unaligned(offs_t byteaddress, uint16_t data, uint16_t mask) = 0; - virtual void write_dword(offs_t byteaddress, uint32_t data) = 0; - virtual void write_dword(offs_t byteaddress, uint32_t data, uint32_t mask) = 0; - virtual void write_dword_unaligned(offs_t byteaddress, uint32_t data) = 0; - virtual void write_dword_unaligned(offs_t byteaddress, uint32_t data, uint32_t mask) = 0; - virtual void write_qword(offs_t byteaddress, uint64_t data) = 0; - virtual void write_qword(offs_t byteaddress, uint64_t data, uint64_t mask) = 0; - virtual void write_qword_unaligned(offs_t byteaddress, uint64_t data) = 0; - virtual void write_qword_unaligned(offs_t byteaddress, uint64_t data, uint64_t mask) = 0; + virtual void write_byte(offs_t byteaddress, u8 data) = 0; + virtual void write_word(offs_t byteaddress, u16 data) = 0; + virtual void write_word(offs_t byteaddress, u16 data, u16 mask) = 0; + virtual void write_word_unaligned(offs_t byteaddress, u16 data) = 0; + virtual void write_word_unaligned(offs_t byteaddress, u16 data, u16 mask) = 0; + virtual void write_dword(offs_t byteaddress, u32 data) = 0; + virtual void write_dword(offs_t byteaddress, u32 data, u32 mask) = 0; + virtual void write_dword_unaligned(offs_t byteaddress, u32 data) = 0; + virtual void write_dword_unaligned(offs_t byteaddress, u32 data, u32 mask) = 0; + virtual void write_qword(offs_t byteaddress, u64 data) = 0; + virtual void write_qword(offs_t byteaddress, u64 data, u64 mask) = 0; + virtual void write_qword_unaligned(offs_t byteaddress, u64 data) = 0; + virtual void write_qword_unaligned(offs_t byteaddress, u64 data, u64 mask) = 0; // Set address. This will invoke setoffset handlers for the respective entries. virtual void set_address(offs_t byteaddress) = 0; @@ -384,44 +384,44 @@ public: void install_ram(offs_t addrstart, offs_t addrend, offs_t addrmirror, void *baseptr = nullptr) { install_ram_generic(addrstart, addrend, addrmirror, ROW_READWRITE, baseptr); } // install device memory maps - template void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(address_map &map), int bits = 0, uint64_t unitmask = 0) { + template void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(address_map &map), int bits = 0, u64 unitmask = 0) { address_map_delegate delegate(map, "dynamic_device_install", &device); install_device_delegate(addrstart, addrend, device, delegate, bits, unitmask); } - void install_device_delegate(offs_t addrstart, offs_t addrend, device_t &device, address_map_delegate &map, int bits = 0, uint64_t unitmask = 0); + void install_device_delegate(offs_t addrstart, offs_t addrend, device_t &device, address_map_delegate &map, int bits = 0, u64 unitmask = 0); // install setoffset handler - void install_setoffset_handler(offs_t addrstart, offs_t addrend, setoffset_delegate sohandler, uint64_t unitmask = 0) { install_setoffset_handler(addrstart, addrend, 0, 0, 0, sohandler, unitmask); } - void install_setoffset_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, setoffset_delegate sohandler, uint64_t unitmask = 0); + void install_setoffset_handler(offs_t addrstart, offs_t addrend, setoffset_delegate sohandler, u64 unitmask = 0) { install_setoffset_handler(addrstart, addrend, 0, 0, 0, sohandler, unitmask); } + void install_setoffset_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, setoffset_delegate sohandler, u64 unitmask = 0); // install new-style delegate handlers (short form) - void install_read_handler(offs_t addrstart, offs_t addrend, read8_delegate rhandler, uint64_t unitmask = 0) { install_read_handler(addrstart, addrend, 0, 0, 0, rhandler, unitmask); } - void install_write_handler(offs_t addrstart, offs_t addrend, write8_delegate whandler, uint64_t unitmask = 0) { install_write_handler(addrstart, addrend, 0, 0, 0, whandler, unitmask); } - void install_readwrite_handler(offs_t addrstart, offs_t addrend, read8_delegate rhandler, write8_delegate whandler, uint64_t unitmask = 0) { return install_readwrite_handler(addrstart, addrend, 0, 0, 0, rhandler, whandler, unitmask); } - void install_read_handler(offs_t addrstart, offs_t addrend, read16_delegate rhandler, uint64_t unitmask = 0) { install_read_handler(addrstart, addrend, 0, 0, 0, rhandler, unitmask); } - void install_write_handler(offs_t addrstart, offs_t addrend, write16_delegate whandler, uint64_t unitmask = 0) { install_write_handler(addrstart, addrend, 0, 0, 0, whandler, unitmask); } - void install_readwrite_handler(offs_t addrstart, offs_t addrend, read16_delegate rhandler, write16_delegate whandler, uint64_t unitmask = 0) { return install_readwrite_handler(addrstart, addrend, 0, 0, 0, rhandler, whandler, unitmask); } - void install_read_handler(offs_t addrstart, offs_t addrend, read32_delegate rhandler, uint64_t unitmask = 0) { install_read_handler(addrstart, addrend, 0, 0, 0, rhandler, unitmask); } - void install_write_handler(offs_t addrstart, offs_t addrend, write32_delegate whandler, uint64_t unitmask = 0) { install_write_handler(addrstart, addrend, 0, 0, 0, whandler, unitmask); } - void install_readwrite_handler(offs_t addrstart, offs_t addrend, read32_delegate rhandler, write32_delegate whandler, uint64_t unitmask = 0) { return install_readwrite_handler(addrstart, addrend, 0, 0, 0, rhandler, whandler, unitmask); } - void install_read_handler(offs_t addrstart, offs_t addrend, read64_delegate rhandler, uint64_t unitmask = 0) { install_read_handler(addrstart, addrend, 0, 0, 0, rhandler, unitmask); } - void install_write_handler(offs_t addrstart, offs_t addrend, write64_delegate whandler, uint64_t unitmask = 0) { install_write_handler(addrstart, addrend, 0, 0, 0, whandler, unitmask); } - void install_readwrite_handler(offs_t addrstart, offs_t addrend, read64_delegate rhandler, write64_delegate whandler, uint64_t unitmask = 0) { install_readwrite_handler(addrstart, addrend, 0, 0, 0, rhandler, whandler, unitmask); } + void install_read_handler(offs_t addrstart, offs_t addrend, read8_delegate rhandler, u64 unitmask = 0) { install_read_handler(addrstart, addrend, 0, 0, 0, rhandler, unitmask); } + void install_write_handler(offs_t addrstart, offs_t addrend, write8_delegate whandler, u64 unitmask = 0) { install_write_handler(addrstart, addrend, 0, 0, 0, whandler, unitmask); } + void install_readwrite_handler(offs_t addrstart, offs_t addrend, read8_delegate rhandler, write8_delegate whandler, u64 unitmask = 0) { return install_readwrite_handler(addrstart, addrend, 0, 0, 0, rhandler, whandler, unitmask); } + void install_read_handler(offs_t addrstart, offs_t addrend, read16_delegate rhandler, u64 unitmask = 0) { install_read_handler(addrstart, addrend, 0, 0, 0, rhandler, unitmask); } + void install_write_handler(offs_t addrstart, offs_t addrend, write16_delegate whandler, u64 unitmask = 0) { install_write_handler(addrstart, addrend, 0, 0, 0, whandler, unitmask); } + void install_readwrite_handler(offs_t addrstart, offs_t addrend, read16_delegate rhandler, write16_delegate whandler, u64 unitmask = 0) { return install_readwrite_handler(addrstart, addrend, 0, 0, 0, rhandler, whandler, unitmask); } + void install_read_handler(offs_t addrstart, offs_t addrend, read32_delegate rhandler, u64 unitmask = 0) { install_read_handler(addrstart, addrend, 0, 0, 0, rhandler, unitmask); } + void install_write_handler(offs_t addrstart, offs_t addrend, write32_delegate whandler, u64 unitmask = 0) { install_write_handler(addrstart, addrend, 0, 0, 0, whandler, unitmask); } + void install_readwrite_handler(offs_t addrstart, offs_t addrend, read32_delegate rhandler, write32_delegate whandler, u64 unitmask = 0) { return install_readwrite_handler(addrstart, addrend, 0, 0, 0, rhandler, whandler, unitmask); } + void install_read_handler(offs_t addrstart, offs_t addrend, read64_delegate rhandler, u64 unitmask = 0) { install_read_handler(addrstart, addrend, 0, 0, 0, rhandler, unitmask); } + void install_write_handler(offs_t addrstart, offs_t addrend, write64_delegate whandler, u64 unitmask = 0) { install_write_handler(addrstart, addrend, 0, 0, 0, whandler, unitmask); } + void install_readwrite_handler(offs_t addrstart, offs_t addrend, read64_delegate rhandler, write64_delegate whandler, u64 unitmask = 0) { install_readwrite_handler(addrstart, addrend, 0, 0, 0, rhandler, whandler, unitmask); } // install new-style delegate handlers (with mirror/mask) - void install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read8_delegate rhandler, uint64_t unitmask = 0); - void install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write8_delegate whandler, uint64_t unitmask = 0); - void install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read8_delegate rhandler, write8_delegate whandler, uint64_t unitmask = 0); - void install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read16_delegate rhandler, uint64_t unitmask = 0); - void install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write16_delegate whandler, uint64_t unitmask = 0); - void install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read16_delegate rhandler, write16_delegate whandler, uint64_t unitmask = 0); - void install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read32_delegate rhandler, uint64_t unitmask = 0); - void install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write32_delegate whandler, uint64_t unitmask = 0); - void install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read32_delegate rhandler, write32_delegate whandler, uint64_t unitmask = 0); - void install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read64_delegate rhandler, uint64_t unitmask = 0); - void install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write64_delegate whandler, uint64_t unitmask = 0); - void install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read64_delegate rhandler, write64_delegate whandler, uint64_t unitmask = 0); + void install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read8_delegate rhandler, u64 unitmask = 0); + void install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write8_delegate whandler, u64 unitmask = 0); + void install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read8_delegate rhandler, write8_delegate whandler, u64 unitmask = 0); + void install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read16_delegate rhandler, u64 unitmask = 0); + void install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write16_delegate whandler, u64 unitmask = 0); + void install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read16_delegate rhandler, write16_delegate whandler, u64 unitmask = 0); + void install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read32_delegate rhandler, u64 unitmask = 0); + void install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write32_delegate whandler, u64 unitmask = 0); + void install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read32_delegate rhandler, write32_delegate whandler, u64 unitmask = 0); + void install_read_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read64_delegate rhandler, u64 unitmask = 0); + void install_write_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, write64_delegate whandler, u64 unitmask = 0); + void install_readwrite_handler(offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, read64_delegate rhandler, write64_delegate whandler, u64 unitmask = 0); // setup void prepare_map(); @@ -446,7 +446,7 @@ private: bool needs_backing_store(const address_map_entry &entry); memory_bank &bank_find_or_allocate(const char *tag, offs_t addrstart, offs_t addrend, offs_t addrmirror, read_or_write readorwrite); memory_bank *bank_find_anonymous(offs_t bytestart, offs_t byteend) const; - address_map_entry *block_assign_intersecting(offs_t bytestart, offs_t byteend, uint8_t *base); + address_map_entry *block_assign_intersecting(offs_t bytestart, offs_t byteend, u8 *base); void check_optimize_all(const char *function, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, offs_t addrselect, offs_t &nstart, offs_t &nend, offs_t &nmask, offs_t &nmirror); void check_optimize_mirror(const char *function, offs_t addrstart, offs_t addrend, offs_t addrmirror, offs_t &nstart, offs_t &nend, offs_t &nmask, offs_t &nmirror); void check_address(const char *function, offs_t addrstart, offs_t addrend); @@ -455,19 +455,19 @@ protected: // private state const address_space_config &m_config; // configuration of this space device_t & m_device; // reference to the owning device - std::unique_ptr m_map; // original memory map + std::unique_ptr m_map; // original memory map offs_t m_addrmask; // physical address mask offs_t m_bytemask; // byte-converted physical address mask offs_t m_logaddrmask; // logical address mask offs_t m_logbytemask; // byte-converted logical address mask - uint64_t m_unmap; // unmapped value + u64 m_unmap; // unmapped value address_spacenum m_spacenum; // address space index bool m_debugger_access; // treat accesses as coming from the debugger bool m_log_unmap; // log unmapped accesses in this space? std::unique_ptr m_direct; // fast direct-access read info const char * m_name; // friendly name of the address space - uint8_t m_addrchars; // number of characters to use for physical addresses - uint8_t m_logaddrchars; // number of characters to use for logical addresses + u8 m_addrchars; // number of characters to use for physical addresses + u8 m_logaddrchars; // number of characters to use for logical addresses private: memory_manager & m_manager; // reference to the owning manager @@ -518,7 +518,7 @@ public: running_machine &machine() const { return m_machine; } offs_t bytestart() const { return m_bytestart; } offs_t byteend() const { return m_byteend; } - uint8_t *data() const { return m_data; } + u8 *data() const { return m_data; } // is the given range contained by this memory block? bool contains(address_space &space, offs_t bytestart, offs_t byteend) const @@ -531,8 +531,8 @@ private: running_machine & m_machine; // need the machine to free our memory address_space & m_space; // which address space are we associated with? offs_t m_bytestart, m_byteend; // byte-normalized start/end for verifying a match - uint8_t * m_data; // pointer to the data for this block - std::vector m_allocated; // pointer to the actually allocated block + u8 * m_data; // pointer to the data for this block + std::vector m_allocated; // pointer to the actually allocated block }; @@ -568,7 +568,7 @@ class memory_bank // a bank_entry contains a pointer struct bank_entry { - uint8_t * m_ptr; + u8 * m_ptr; }; public: @@ -611,8 +611,8 @@ private: // internal state running_machine & m_machine; // need the machine to free our memory - uint8_t ** m_baseptr; // pointer to our base pointer in the global array - uint16_t m_index; // array index for this handler + u8 ** m_baseptr; // pointer to our base pointer in the global array + u16 m_index; // array index for this handler bool m_anonymous; // are we anonymous or explicit? offs_t m_bytestart; // byte-adjusted start offset offs_t m_byteend; // byte-adjusted end offset @@ -631,7 +631,7 @@ class memory_share { public: // construction/destruction - memory_share(uint8_t width, size_t bytes, endianness_t endianness, void *ptr = nullptr) + memory_share(u8 width, size_t bytes, endianness_t endianness, void *ptr = nullptr) : m_ptr(ptr), m_bytes(bytes), m_endianness(endianness), @@ -643,8 +643,8 @@ public: void *ptr() const { return m_ptr; } size_t bytes() const { return m_bytes; } endianness_t endianness() const { return m_endianness; } - uint8_t bitwidth() const { return m_bitwidth; } - uint8_t bytewidth() const { return m_bytewidth; } + u8 bitwidth() const { return m_bitwidth; } + u8 bytewidth() const { return m_bytewidth; } // setters void set_ptr(void *ptr) { m_ptr = ptr; } @@ -654,8 +654,8 @@ private: void * m_ptr; // pointer to the memory backing the region size_t m_bytes; // size of the shared region in bytes endianness_t m_endianness; // endianness of the memory - uint8_t m_bitwidth; // width of the shared region in bits - uint8_t m_bytewidth; // width in bytes, rounded up to a power of 2 + u8 m_bitwidth; // width of the shared region in bits + u8 m_bytewidth; // width in bytes, rounded up to a power of 2 }; @@ -670,34 +670,34 @@ class memory_region friend class memory_manager; public: // construction/destruction - memory_region(running_machine &machine, const char *name, uint32_t length, uint8_t width, endianness_t endian); + memory_region(running_machine &machine, const char *name, u32 length, u8 width, endianness_t endian); // getters running_machine &machine() const { return m_machine; } - uint8_t *base() { return (m_buffer.size() > 0) ? &m_buffer[0] : nullptr; } - uint8_t *end() { return base() + m_buffer.size(); } - uint32_t bytes() const { return m_buffer.size(); } + u8 *base() { return (m_buffer.size() > 0) ? &m_buffer[0] : nullptr; } + u8 *end() { return base() + m_buffer.size(); } + u32 bytes() const { return m_buffer.size(); } const char *name() const { return m_name.c_str(); } // flag expansion endianness_t endianness() const { return m_endianness; } - uint8_t bitwidth() const { return m_bitwidth; } - uint8_t bytewidth() const { return m_bytewidth; } + u8 bitwidth() const { return m_bitwidth; } + u8 bytewidth() const { return m_bytewidth; } // data access - uint8_t &u8(offs_t offset = 0) { return m_buffer[offset]; } - uint16_t &u16(offs_t offset = 0) { return reinterpret_cast(base())[offset]; } - uint32_t &u32(offs_t offset = 0) { return reinterpret_cast(base())[offset]; } - uint64_t &u64(offs_t offset = 0) { return reinterpret_cast(base())[offset]; } + u8 &as_u8(offs_t offset = 0) { return m_buffer[offset]; } + u16 &as_u16(offs_t offset = 0) { return reinterpret_cast(base())[offset]; } + u32 &as_u32(offs_t offset = 0) { return reinterpret_cast(base())[offset]; } + u64 &as_u64(offs_t offset = 0) { return reinterpret_cast(base())[offset]; } private: // internal data running_machine & m_machine; std::string m_name; - std::vector m_buffer; + std::vector m_buffer; endianness_t m_endianness; - uint8_t m_bitwidth; - uint8_t m_bytewidth; + u8 m_bitwidth; + u8 m_bytewidth; }; @@ -708,7 +708,7 @@ private: class memory_manager { friend class address_space; - friend memory_region::memory_region(running_machine &machine, const char *name, uint32_t length, uint8_t width, endianness_t endian); + friend memory_region::memory_region(running_machine &machine, const char *name, u32 length, u8 width, endianness_t endian); public: // construction/destruction memory_manager(running_machine &machine); @@ -724,10 +724,10 @@ public: void dump(FILE *file); // pointers to a bank pointer (internal usage only) - uint8_t **bank_pointer_addr(uint8_t index) { return &m_bank_ptr[index]; } + u8 **bank_pointer_addr(u8 index) { return &m_bank_ptr[index]; } // regions - memory_region *region_alloc(const char *name, uint32_t length, uint8_t width, endianness_t endian); + memory_region *region_alloc(const char *name, u32 length, u8 width, endianness_t endian); void region_free(const char *name); memory_region *region_containing(const void *memory, offs_t bytes) const; @@ -740,13 +740,13 @@ private: running_machine & m_machine; // reference to the machine bool m_initialized; // have we completed initialization? - uint8_t * m_bank_ptr[TOTAL_MEMORY_BANKS]; // array of bank pointers + u8 * m_bank_ptr[TOTAL_MEMORY_BANKS]; // array of bank pointers std::vector> m_spacelist; // list of address spaces std::vector> m_blocklist; // head of the list of memory blocks std::unordered_map> m_banklist; // data gathered for each bank - uint16_t m_banknext; // next bank to allocate + u16 m_banknext; // next bank to allocate std::unordered_map> m_sharelist; // map for share lookups @@ -760,32 +760,32 @@ private: //************************************************************************** // opcode base adjustment handler function macro -#define DIRECT_UPDATE_MEMBER(name) offs_t name(ATTR_UNUSED direct_read_data &direct, ATTR_UNUSED offs_t address) +#define DIRECT_UPDATE_MEMBER(name) offs_t name(ATTR_UNUSED direct_read_data &direct, ATTR_UNUSED offs_t address) #define DECLARE_DIRECT_UPDATE_MEMBER(name) offs_t name(ATTR_UNUSED direct_read_data &direct, ATTR_UNUSED offs_t address) // space read/write handler function macros -#define READ8_MEMBER(name) uint8_t name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint8_t mem_mask) -#define WRITE8_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint8_t data, ATTR_UNUSED uint8_t mem_mask) -#define READ16_MEMBER(name) uint16_t name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint16_t mem_mask) -#define WRITE16_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint16_t data, ATTR_UNUSED uint16_t mem_mask) -#define READ32_MEMBER(name) uint32_t name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint32_t mem_mask) -#define WRITE32_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint32_t data, ATTR_UNUSED uint32_t mem_mask) -#define READ64_MEMBER(name) uint64_t name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint64_t mem_mask) -#define WRITE64_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint64_t data, ATTR_UNUSED uint64_t mem_mask) +#define READ8_MEMBER(name) u8 name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u8 mem_mask) +#define WRITE8_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u8 data, ATTR_UNUSED u8 mem_mask) +#define READ16_MEMBER(name) u16 name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u16 mem_mask) +#define WRITE16_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u16 data, ATTR_UNUSED u16 mem_mask) +#define READ32_MEMBER(name) u32 name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u32 mem_mask) +#define WRITE32_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u32 data, ATTR_UNUSED u32 mem_mask) +#define READ64_MEMBER(name) u64 name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u64 mem_mask) +#define WRITE64_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u64 data, ATTR_UNUSED u64 mem_mask) -#define DECLARE_READ8_MEMBER(name) uint8_t name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint8_t mem_mask = 0xff) -#define DECLARE_WRITE8_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint8_t data, ATTR_UNUSED uint8_t mem_mask = 0xff) -#define DECLARE_READ16_MEMBER(name) uint16_t name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint16_t mem_mask = 0xffff) -#define DECLARE_WRITE16_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint16_t data, ATTR_UNUSED uint16_t mem_mask = 0xffff) -#define DECLARE_READ32_MEMBER(name) uint32_t name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint32_t mem_mask = 0xffffffff) -#define DECLARE_WRITE32_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint32_t data, ATTR_UNUSED uint32_t mem_mask = 0xffffffff) -#define DECLARE_READ64_MEMBER(name) uint64_t name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint64_t mem_mask = U64(0xffffffffffffffff)) -#define DECLARE_WRITE64_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED uint64_t data, ATTR_UNUSED uint64_t mem_mask = U64(0xffffffffffffffff)) +#define DECLARE_READ8_MEMBER(name) u8 name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u8 mem_mask = 0xff) +#define DECLARE_WRITE8_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u8 data, ATTR_UNUSED u8 mem_mask = 0xff) +#define DECLARE_READ16_MEMBER(name) u16 name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u16 mem_mask = 0xffff) +#define DECLARE_WRITE16_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u16 data, ATTR_UNUSED u16 mem_mask = 0xffff) +#define DECLARE_READ32_MEMBER(name) u32 name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u32 mem_mask = 0xffffffff) +#define DECLARE_WRITE32_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u32 data, ATTR_UNUSED u32 mem_mask = 0xffffffff) +#define DECLARE_READ64_MEMBER(name) u64 name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u64 mem_mask = 0xffffffffffffffffU) +#define DECLARE_WRITE64_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset, ATTR_UNUSED u64 data, ATTR_UNUSED u64 mem_mask = 0xffffffffffffffffU) -#define SETOFFSET_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset) -#define DECLARE_SETOFFSET_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset) +#define SETOFFSET_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset) +#define DECLARE_SETOFFSET_MEMBER(name) void name(ATTR_UNUSED address_space &space, ATTR_UNUSED offs_t offset) // device delegate macros #define READ8_DELEGATE(_class, _member) read8_delegate(FUNC(_class::_member), this) @@ -810,22 +810,22 @@ private: // helper macro for merging data with the memory mask #define COMBINE_DATA(varptr) (*(varptr) = (*(varptr) & ~mem_mask) | (data & mem_mask)) -#define ACCESSING_BITS_0_7 ((mem_mask & 0x000000ff) != 0) -#define ACCESSING_BITS_8_15 ((mem_mask & 0x0000ff00) != 0) -#define ACCESSING_BITS_16_23 ((mem_mask & 0x00ff0000) != 0) -#define ACCESSING_BITS_24_31 ((mem_mask & 0xff000000) != 0) -#define ACCESSING_BITS_32_39 ((mem_mask & U64(0x000000ff00000000)) != 0) -#define ACCESSING_BITS_40_47 ((mem_mask & U64(0x0000ff0000000000)) != 0) -#define ACCESSING_BITS_48_55 ((mem_mask & U64(0x00ff000000000000)) != 0) -#define ACCESSING_BITS_56_63 ((mem_mask & U64(0xff00000000000000)) != 0) +#define ACCESSING_BITS_0_7 ((mem_mask & 0x000000ffU) != 0) +#define ACCESSING_BITS_8_15 ((mem_mask & 0x0000ff00U) != 0) +#define ACCESSING_BITS_16_23 ((mem_mask & 0x00ff0000U) != 0) +#define ACCESSING_BITS_24_31 ((mem_mask & 0xff000000U) != 0) +#define ACCESSING_BITS_32_39 ((mem_mask & 0x000000ff00000000U) != 0) +#define ACCESSING_BITS_40_47 ((mem_mask & 0x0000ff0000000000U) != 0) +#define ACCESSING_BITS_48_55 ((mem_mask & 0x00ff000000000000U) != 0) +#define ACCESSING_BITS_56_63 ((mem_mask & 0xff00000000000000U) != 0) -#define ACCESSING_BITS_0_15 ((mem_mask & 0x0000ffff) != 0) -#define ACCESSING_BITS_16_31 ((mem_mask & 0xffff0000) != 0) -#define ACCESSING_BITS_32_47 ((mem_mask & U64(0x0000ffff00000000)) != 0) -#define ACCESSING_BITS_48_63 ((mem_mask & U64(0xffff000000000000)) != 0) +#define ACCESSING_BITS_0_15 ((mem_mask & 0x0000ffffU) != 0) +#define ACCESSING_BITS_16_31 ((mem_mask & 0xffff0000U) != 0) +#define ACCESSING_BITS_32_47 ((mem_mask & 0x0000ffff00000000U) != 0) +#define ACCESSING_BITS_48_63 ((mem_mask & 0xffff000000000000U) != 0) -#define ACCESSING_BITS_0_31 ((mem_mask & 0xffffffff) != 0) -#define ACCESSING_BITS_32_63 ((mem_mask & U64(0xffffffff00000000)) != 0) +#define ACCESSING_BITS_0_31 ((mem_mask & 0xffffffffU) != 0) +#define ACCESSING_BITS_32_63 ((mem_mask & 0xffffffff00000000U) != 0) // macros for accessing bytes and words within larger chunks @@ -885,7 +885,7 @@ inline void *direct_read_data::read_ptr(offs_t byteaddress, offs_t directxor) // direct_read_data class //------------------------------------------------- -inline uint8_t direct_read_data::read_byte(offs_t byteaddress, offs_t directxor) +inline u8 direct_read_data::read_byte(offs_t byteaddress, offs_t directxor) { if (address_is_valid(byteaddress)) return m_ptr[(byteaddress ^ directxor) & m_bytemask]; @@ -898,10 +898,10 @@ inline uint8_t direct_read_data::read_byte(offs_t byteaddress, offs_t directxor) // direct_read_data class //------------------------------------------------- -inline uint16_t direct_read_data::read_word(offs_t byteaddress, offs_t directxor) +inline u16 direct_read_data::read_word(offs_t byteaddress, offs_t directxor) { if (address_is_valid(byteaddress)) - return *reinterpret_cast(&m_ptr[(byteaddress ^ directxor) & m_bytemask]); + return *reinterpret_cast(&m_ptr[(byteaddress ^ directxor) & m_bytemask]); return m_space.read_word(byteaddress); } @@ -911,10 +911,10 @@ inline uint16_t direct_read_data::read_word(offs_t byteaddress, offs_t directxor // direct_read_data class //------------------------------------------------- -inline uint32_t direct_read_data::read_dword(offs_t byteaddress, offs_t directxor) +inline u32 direct_read_data::read_dword(offs_t byteaddress, offs_t directxor) { if (address_is_valid(byteaddress)) - return *reinterpret_cast(&m_ptr[(byteaddress ^ directxor) & m_bytemask]); + return *reinterpret_cast(&m_ptr[(byteaddress ^ directxor) & m_bytemask]); return m_space.read_dword(byteaddress); } @@ -924,11 +924,11 @@ inline uint32_t direct_read_data::read_dword(offs_t byteaddress, offs_t directxo // direct_read_data class //------------------------------------------------- -inline uint64_t direct_read_data::read_qword(offs_t byteaddress, offs_t directxor) +inline u64 direct_read_data::read_qword(offs_t byteaddress, offs_t directxor) { if (address_is_valid(byteaddress)) - return *reinterpret_cast(&m_ptr[(byteaddress ^ directxor) & m_bytemask]); + return *reinterpret_cast(&m_ptr[(byteaddress ^ directxor) & m_bytemask]); return m_space.read_qword(byteaddress); } -#endif /* __EMUMEM_H__ */ +#endif /* MAME_EMU_EMUMEM_H */ diff --git a/src/emu/emupal.cpp b/src/emu/emupal.cpp index 2b4393ee6be..d155d4d61ee 100644 --- a/src/emu/emupal.cpp +++ b/src/emu/emupal.cpp @@ -19,7 +19,7 @@ const device_type PALETTE = &device_creator; -palette_device::palette_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +palette_device::palette_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, PALETTE, "palette", tag, owner, clock, "palette", __FILE__), m_entries(0), m_indirect_entries(0), @@ -122,7 +122,7 @@ void palette_device::set_indirect_color(int index, rgb_t rgb) m_indirect_colors[index] = rgb; // update the palette for any colortable entries that reference it - for (uint32_t pen = 0; pen < m_indirect_pens.size(); pen++) + for (u32 pen = 0; pen < m_indirect_pens.size(); pen++) if (m_indirect_pens[pen] == index) m_palette->entry_set_color(pen, rgb); } @@ -150,9 +150,9 @@ void palette_device::set_pen_indirect(pen_t pen, indirect_pen_t index) // transcolor //------------------------------------------------- -uint32_t palette_device::transpen_mask(gfx_element &gfx, uint32_t color, indirect_pen_t transcolor) +u32 palette_device::transpen_mask(gfx_element &gfx, u32 color, indirect_pen_t transcolor) { - uint32_t entry = gfx.colorbase() + (color % gfx.colors()) * gfx.granularity(); + u32 entry = gfx.colorbase() + (color % gfx.colors()) * gfx.granularity(); // make sure we are in range assert(entry < m_indirect_pens.size()); @@ -162,7 +162,7 @@ uint32_t palette_device::transpen_mask(gfx_element &gfx, uint32_t color, indirec int count = std::min(size_t(gfx.depth()), m_indirect_pens.size() - entry); // set a bit anywhere the transcolor matches - uint32_t mask = 0; + u32 mask = 0; for (int bit = 0; bit < count; bit++) if (m_indirect_pens[entry++] == transcolor) mask |= 1 << bit; @@ -715,9 +715,9 @@ void palette_device::configure_rgb_shadows(int mode, float factor) int ifactor = int(factor * 256.0f); for (int rgb555 = 0; rgb555 < 32768; rgb555++) { - uint8_t r = rgb_t::clamp((pal5bit(rgb555 >> 10) * ifactor) >> 8); - uint8_t g = rgb_t::clamp((pal5bit(rgb555 >> 5) * ifactor) >> 8); - uint8_t b = rgb_t::clamp((pal5bit(rgb555 >> 0) * ifactor) >> 8); + u8 const r = rgb_t::clamp((pal5bit(rgb555 >> 10) * ifactor) >> 8); + u8 const g = rgb_t::clamp((pal5bit(rgb555 >> 5) * ifactor) >> 8); + u8 const b = rgb_t::clamp((pal5bit(rgb555 >> 0) * ifactor) >> 8); // store either 16 or 32 bit rgb_t final = rgb_t(r, g, b); @@ -859,7 +859,7 @@ void palette_device::palette_init_3bit_bgr(palette_device &palette) void palette_device::palette_init_RRRRGGGGBBBB_proms(palette_device &palette) { - const uint8_t *color_prom = machine().root_device().memregion("proms")->base(); + const u8 *color_prom = machine().root_device().memregion("proms")->base(); int i; for (i = 0; i < palette.entries(); i++) @@ -932,35 +932,35 @@ void palette_device::palette_init_RRRRRGGGGGGBBBBB(palette_device &palette) palette.set_pen_color(i, rgbexpand<5,6,5>(i, 11, 5, 0)); } -rgb_t raw_to_rgb_converter::IRRRRRGGGGGBBBBB_decoder(uint32_t raw) +rgb_t raw_to_rgb_converter::IRRRRRGGGGGBBBBB_decoder(u32 raw) { - uint8_t i = (raw >> 15) & 1; - uint8_t r = pal6bit(((raw >> 9) & 0x3e) | i); - uint8_t g = pal6bit(((raw >> 4) & 0x3e) | i); - uint8_t b = pal6bit(((raw << 1) & 0x3e) | i); + u8 const i = (raw >> 15) & 1; + u8 const r = pal6bit(((raw >> 9) & 0x3e) | i); + u8 const g = pal6bit(((raw >> 4) & 0x3e) | i); + u8 const b = pal6bit(((raw << 1) & 0x3e) | i); return rgb_t(r, g, b); } -rgb_t raw_to_rgb_converter::RRRRGGGGBBBBRGBx_decoder(uint32_t raw) +rgb_t raw_to_rgb_converter::RRRRGGGGBBBBRGBx_decoder(u32 raw) { - uint8_t r = pal5bit(((raw >> 11) & 0x1e) | ((raw >> 3) & 0x01)); - uint8_t g = pal5bit(((raw >> 7) & 0x1e) | ((raw >> 2) & 0x01)); - uint8_t b = pal5bit(((raw >> 3) & 0x1e) | ((raw >> 1) & 0x01)); + u8 const r = pal5bit(((raw >> 11) & 0x1e) | ((raw >> 3) & 0x01)); + u8 const g = pal5bit(((raw >> 7) & 0x1e) | ((raw >> 2) & 0x01)); + u8 const b = pal5bit(((raw >> 3) & 0x1e) | ((raw >> 1) & 0x01)); return rgb_t(r, g, b); } -rgb_t raw_to_rgb_converter::xRGBRRRRGGGGBBBB_bit0_decoder(uint32_t raw) +rgb_t raw_to_rgb_converter::xRGBRRRRGGGGBBBB_bit0_decoder(u32 raw) { - uint8_t r = pal5bit(((raw >> 7) & 0x1e) | ((raw >> 14) & 0x01)); - uint8_t g = pal5bit(((raw >> 3) & 0x1e) | ((raw >> 13) & 0x01)); - uint8_t b = pal5bit(((raw << 1) & 0x1e) | ((raw >> 12) & 0x01)); + u8 const r = pal5bit(((raw >> 7) & 0x1e) | ((raw >> 14) & 0x01)); + u8 const g = pal5bit(((raw >> 3) & 0x1e) | ((raw >> 13) & 0x01)); + u8 const b = pal5bit(((raw << 1) & 0x1e) | ((raw >> 12) & 0x01)); return rgb_t(r, g, b); } -rgb_t raw_to_rgb_converter::xRGBRRRRGGGGBBBB_bit4_decoder(uint32_t raw) +rgb_t raw_to_rgb_converter::xRGBRRRRGGGGBBBB_bit4_decoder(u32 raw) { - uint8_t r = pal5bit(((raw >> 8) & 0x0f) | ((raw >> 10) & 0x10)); - uint8_t g = pal5bit(((raw >> 4) & 0x0f) | ((raw >> 9) & 0x10)); - uint8_t b = pal5bit(((raw >> 0) & 0x0f) | ((raw >> 8) & 0x10)); + u8 const r = pal5bit(((raw >> 8) & 0x0f) | ((raw >> 10) & 0x10)); + u8 const g = pal5bit(((raw >> 4) & 0x0f) | ((raw >> 9) & 0x10)); + u8 const b = pal5bit(((raw >> 0) & 0x0f) | ((raw >> 8) & 0x10)); return rgb_t(r, g, b); } diff --git a/src/emu/emupal.h b/src/emu/emupal.h index fca513d8424..a8af7713b48 100644 --- a/src/emu/emupal.h +++ b/src/emu/emupal.h @@ -96,8 +96,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __EMUPAL_H__ -#define __EMUPAL_H__ +#ifndef MAME_EMU_EMUPAL_H +#define MAME_EMU_EMUPAL_H //************************************************************************** @@ -112,8 +112,8 @@ #define PALETTE_INIT_MEMBER(_Class, _Name) void _Class::PALETTE_INIT_NAME(_Name)(palette_device &palette) #define PALETTE_DECODER_NAME(_Name) _Name##_decoder -#define DECLARE_PALETTE_DECODER(_Name) static rgb_t PALETTE_DECODER_NAME(_Name)(uint32_t raw) -#define PALETTE_DECODER_MEMBER(_Class, _Name) rgb_t _Class::PALETTE_DECODER_NAME(_Name)(uint32_t raw) +#define DECLARE_PALETTE_DECODER(_Name) static rgb_t PALETTE_DECODER_NAME(_Name)(u32 raw) +#define PALETTE_DECODER_MEMBER(_Class, _Name) rgb_t _Class::PALETTE_DECODER_NAME(_Name)(u32 raw) // standard 3-3-2 formats #define PALETTE_FORMAT_BBGGGRRR raw_to_rgb_converter(1, &raw_to_rgb_converter::standard_rgb_decoder<3,3,2, 0,3,6>) @@ -290,7 +290,7 @@ typedef device_delegate palette_init_delegate; -typedef uint16_t indirect_pen_t; +typedef u16 indirect_pen_t; // ======================> raw_to_rgb_converter @@ -298,7 +298,7 @@ typedef uint16_t indirect_pen_t; class raw_to_rgb_converter { // helper function - typedef rgb_t (*raw_to_rgb_func)(uint32_t raw); + typedef rgb_t (*raw_to_rgb_func)(u32 raw); public: // constructor @@ -310,43 +310,43 @@ public: int bytes_per_entry() const { return m_bytes_per_entry; } // helpers - rgb_t operator()(uint32_t raw) const { return (*m_func)(raw); } + rgb_t operator()(u32 raw) const { return (*m_func)(raw); } // generic raw-to-RGB conversion helpers template - static rgb_t standard_rgb_decoder(uint32_t raw) + static rgb_t standard_rgb_decoder(u32 raw) { - uint8_t r = palexpand<_RedBits>(raw >> _RedShift); - uint8_t g = palexpand<_GreenBits>(raw >> _GreenShift); - uint8_t b = palexpand<_BlueBits>(raw >> _BlueShift); + u8 const r = palexpand<_RedBits>(raw >> _RedShift); + u8 const g = palexpand<_GreenBits>(raw >> _GreenShift); + u8 const b = palexpand<_BlueBits>(raw >> _BlueShift); return rgb_t(r, g, b); } // data-inverted generic raw-to-RGB conversion helpers template - static rgb_t inverted_rgb_decoder(uint32_t raw) + static rgb_t inverted_rgb_decoder(u32 raw) { - uint8_t r = palexpand<_RedBits>(~raw >> _RedShift); - uint8_t g = palexpand<_GreenBits>(~raw >> _GreenShift); - uint8_t b = palexpand<_BlueBits>(~raw >> _BlueShift); + u8 const r = palexpand<_RedBits>(~raw >> _RedShift); + u8 const g = palexpand<_GreenBits>(~raw >> _GreenShift); + u8 const b = palexpand<_BlueBits>(~raw >> _BlueShift); return rgb_t(r, g, b); } template - static rgb_t standard_irgb_decoder(uint32_t raw) + static rgb_t standard_irgb_decoder(u32 raw) { - uint8_t i = palexpand<_IntBits>(raw >> _IntShift); - uint8_t r = (i * palexpand<_RedBits>(raw >> _RedShift)) >> 8; - uint8_t g = (i * palexpand<_GreenBits>(raw >> _GreenShift)) >> 8; - uint8_t b = (i * palexpand<_BlueBits>(raw >> _BlueShift)) >> 8; + u8 const i = palexpand<_IntBits>(raw >> _IntShift); + u8 const r = (i * palexpand<_RedBits>(raw >> _RedShift)) >> 8; + u8 const g = (i * palexpand<_GreenBits>(raw >> _GreenShift)) >> 8; + u8 const b = (i * palexpand<_BlueBits>(raw >> _BlueShift)) >> 8; return rgb_t(r, g, b); } // other standard decoders - static rgb_t IRRRRRGGGGGBBBBB_decoder(uint32_t raw); - static rgb_t RRRRGGGGBBBBRGBx_decoder(uint32_t raw); // bits 3/2/1 are LSb - static rgb_t xRGBRRRRGGGGBBBB_bit0_decoder(uint32_t raw); // bits 14/13/12 are LSb - static rgb_t xRGBRRRRGGGGBBBB_bit4_decoder(uint32_t raw); // bits 14/13/12 are MSb + static rgb_t IRRRRRGGGGGBBBBB_decoder(u32 raw); + static rgb_t RRRRGGGGBBBBRGBx_decoder(u32 raw); // bits 3/2/1 are LSb + static rgb_t xRGBRRRRGGGGBBBB_bit0_decoder(u32 raw); // bits 14/13/12 are LSb + static rgb_t xRGBRRRRGGGGBBBB_bit4_decoder(u32 raw); // bits 14/13/12 are MSb private: // internal data @@ -366,7 +366,7 @@ class palette_device : public device_t public: // construction/destruction - palette_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + palette_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); // static configuration static void static_set_init(device_t &device, palette_init_delegate init); @@ -395,9 +395,9 @@ public: bool hilights_enabled() { return m_enable_hilights; } // raw entry reading - uint32_t read_entry(pen_t pen) const + u32 read_entry(pen_t pen) const { - uint32_t data = m_paletteram.read(pen); + u32 data = m_paletteram.read(pen); if (m_paletteram_ext.base() != nullptr) data |= m_paletteram_ext.read(pen) << (8 * m_paletteram.bytes_per_entry()); return data; @@ -405,10 +405,10 @@ public: // setters void set_pen_color(pen_t pen, rgb_t rgb) { m_palette->entry_set_color(pen, rgb); } - void set_pen_red_level(pen_t pen, uint8_t level) { m_palette->entry_set_red_level(pen, level); } - void set_pen_green_level(pen_t pen, uint8_t level) { m_palette->entry_set_green_level(pen, level); } - void set_pen_blue_level(pen_t pen, uint8_t level) { m_palette->entry_set_blue_level(pen, level); } - void set_pen_color(pen_t pen, uint8_t r, uint8_t g, uint8_t b) { m_palette->entry_set_color(pen, rgb_t(r, g, b)); } + void set_pen_red_level(pen_t pen, u8 level) { m_palette->entry_set_red_level(pen, level); } + void set_pen_green_level(pen_t pen, u8 level) { m_palette->entry_set_green_level(pen, level); } + void set_pen_blue_level(pen_t pen, u8 level) { m_palette->entry_set_blue_level(pen, level); } + void set_pen_color(pen_t pen, u8 r, u8 g, u8 b) { m_palette->entry_set_color(pen, rgb_t(r, g, b)); } void set_pen_colors(pen_t color_base, const rgb_t *colors, int color_count) { while (color_count--) set_pen_color(color_base++, *colors++); } void set_pen_colors(pen_t color_base, const std::vector &colors) { for(unsigned int i=0; i != colors.size(); i++) set_pen_color(color_base+i, colors[i]); } void set_pen_contrast(pen_t pen, double bright) { m_palette->entry_set_contrast(pen, bright); } @@ -418,7 +418,7 @@ public: rgb_t indirect_color(int index) const { return m_indirect_colors[index]; } void set_indirect_color(int index, rgb_t rgb); void set_pen_indirect(pen_t pen, indirect_pen_t index); - uint32_t transpen_mask(gfx_element &gfx, uint32_t color, indirect_pen_t transcolor); + u32 transpen_mask(gfx_element &gfx, u32 color, indirect_pen_t transcolor); // shadow config void set_shadow_factor(double factor) { assert(m_shadow_group != 0); m_palette->group_set_contrast(m_shadow_group, factor); } @@ -494,8 +494,8 @@ private: const pen_t * m_pens; // remapped palette pen numbers bitmap_format m_format; // format assumed for palette data pen_t * m_shadow_table; // table for looking up a shadowed pen - uint32_t m_shadow_group; // index of the shadow group, or 0 if none - uint32_t m_hilight_group; // index of the hilight group, or 0 if none + u32 m_shadow_group; // index of the shadow group, or 0 if none + u32 m_hilight_group; // index of the hilight group, or 0 if none pen_t m_white_pen; // precomputed white pen value pen_t m_black_pen; // precomputed black pen value @@ -506,9 +506,9 @@ private: struct shadow_table_data { pen_t * base; // pointer to the base of the table - int16_t dr; // delta red value - int16_t dg; // delta green value - int16_t db; // delta blue value + s16 dr; // delta red value + s16 dg; // delta green value + s16 db; // delta blue value bool noclip; // clip? }; shadow_table_data m_shadow_tables[MAX_SHADOW_PRESETS]; // array of shadow table data @@ -526,4 +526,4 @@ private: typedef device_type_iterator<&device_creator, palette_device> palette_device_iterator; -#endif // __EMUPAL_H__ +#endif // MAME_EMU_EMUPAL_H diff --git a/src/emu/fileio.cpp b/src/emu/fileio.cpp index 4670fd2b789..3ec686266c8 100644 --- a/src/emu/fileio.cpp +++ b/src/emu/fileio.cpp @@ -13,7 +13,7 @@ #include "fileio.h" -const uint32_t OPEN_FLAG_HAS_CRC = 0x10000; +const u32 OPEN_FLAG_HAS_CRC = 0x10000; @@ -164,7 +164,7 @@ const osd::directory::entry *file_enumerator::next() // emu_file - constructor //------------------------------------------------- -emu_file::emu_file(uint32_t openflags) +emu_file::emu_file(u32 openflags) : m_file() , m_iterator(std::string()) , m_mediapaths(std::string()) @@ -180,7 +180,7 @@ emu_file::emu_file(uint32_t openflags) throw emu_fatalerror("Attempted to open a file for write with OPEN_FLAG_HAS_CRC"); } -emu_file::emu_file(std::string &&searchpath, uint32_t openflags) +emu_file::emu_file(std::string &&searchpath, u32 openflags) : m_file() , m_iterator(searchpath) , m_mediapaths(std::move(searchpath)) @@ -257,7 +257,7 @@ util::hash_collection &emu_file::hashes(const char *types) } // read the data if we can - const uint8_t *filedata = (const uint8_t *)m_file->buffer(); + const u8 *filedata = (const u8 *)m_file->buffer(); if (filedata == nullptr) return m_hashes; @@ -301,7 +301,7 @@ osd_file::error emu_file::open(const std::string &name1, const std::string &name return open(name1 + name2 + name3 + name4); } -osd_file::error emu_file::open(const std::string &name, uint32_t crc) +osd_file::error emu_file::open(const std::string &name, u32 crc) { // remember the filename and CRC info m_filename = name; @@ -313,19 +313,19 @@ osd_file::error emu_file::open(const std::string &name, uint32_t crc) return open_next(); } -osd_file::error emu_file::open(const std::string &name1, const std::string &name2, uint32_t crc) +osd_file::error emu_file::open(const std::string &name1, const std::string &name2, u32 crc) { // concatenate the strings and do a standard open return open(name1 + name2, crc); } -osd_file::error emu_file::open(const std::string &name1, const std::string &name2, const std::string &name3, uint32_t crc) +osd_file::error emu_file::open(const std::string &name1, const std::string &name2, const std::string &name3, u32 crc) { // concatenate the strings and do a standard open return open(name1 + name2 + name3, crc); } -osd_file::error emu_file::open(const std::string &name1, const std::string &name2, const std::string &name3, const std::string &name4, uint32_t crc) +osd_file::error emu_file::open(const std::string &name1, const std::string &name2, const std::string &name3, const std::string &name4, u32 crc) { // concatenate the strings and do a standard open return open(name1 + name2 + name3 + name4, crc); @@ -369,7 +369,7 @@ osd_file::error emu_file::open_next() // just an array of data in RAM //------------------------------------------------- -osd_file::error emu_file::open_ram(const void *data, uint32_t length) +osd_file::error emu_file::open_ram(const void *data, u32 length) { // set a fake filename and CRC m_filename = "RAM"; @@ -433,7 +433,7 @@ bool emu_file::compressed_file_ready(void) // seek - seek within a file //------------------------------------------------- -int emu_file::seek(int64_t offset, int whence) +int emu_file::seek(s64 offset, int whence) { // load the ZIP file now if we haven't yet if (compressed_file_ready()) @@ -451,7 +451,7 @@ int emu_file::seek(int64_t offset, int whence) // tell - return the current file position //------------------------------------------------- -uint64_t emu_file::tell() +u64 emu_file::tell() { // load the ZIP file now if we haven't yet if (compressed_file_ready()) @@ -487,7 +487,7 @@ bool emu_file::eof() // size - returns the size of a file //------------------------------------------------- -uint64_t emu_file::size() +u64 emu_file::size() { // use the ZIP length if present if (m_zipfile != nullptr) @@ -505,7 +505,7 @@ uint64_t emu_file::size() // read - read from a file //------------------------------------------------- -uint32_t emu_file::read(void *buffer, uint32_t length) +u32 emu_file::read(void *buffer, u32 length) { // load the ZIP file now if we haven't yet if (compressed_file_ready()) @@ -577,7 +577,7 @@ char *emu_file::gets(char *s, int n) // write - write to a file //------------------------------------------------- -uint32_t emu_file::write(const void *buffer, uint32_t length) +u32 emu_file::write(const void *buffer, u32 length) { // write the data if we can if (m_file) diff --git a/src/emu/fileio.h b/src/emu/fileio.h index a121cafb66e..900cd5c8141 100644 --- a/src/emu/fileio.h +++ b/src/emu/fileio.h @@ -8,11 +8,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_EMU_FILEIO_H #define MAME_EMU_FILEIO_H +#pragma once + #include "corefile.h" #include "hash.h" @@ -88,8 +88,8 @@ class emu_file { public: // file open/creation - emu_file(uint32_t openflags); - emu_file(std::string &&searchpath, uint32_t openflags); + emu_file(u32 openflags); + emu_file(std::string &&searchpath, u32 openflags); virtual ~emu_file(); // getters @@ -97,14 +97,14 @@ public: bool is_open() const { return bool(m_file); } const char *filename() const { return m_filename.c_str(); } const char *fullpath() const { return m_fullpath.c_str(); } - uint32_t openflags() const { return m_openflags; } + u32 openflags() const { return m_openflags; } util::hash_collection &hashes(const char *types); bool restrict_to_mediapath() const { return m_restrict_to_mediapath; } bool part_of_mediapath(std::string path); // setters void remove_on_close() { m_remove_on_close = true; } - void set_openflags(uint32_t openflags) { assert(!m_file); m_openflags = openflags; } + void set_openflags(u32 openflags) { assert(!m_file); m_openflags = openflags; } void set_restrict_to_mediapath(bool rtmp = true) { m_restrict_to_mediapath = rtmp; } // open/close @@ -112,31 +112,31 @@ public: osd_file::error open(const std::string &name1, const std::string &name2); osd_file::error open(const std::string &name1, const std::string &name2, const std::string &name3); osd_file::error open(const std::string &name1, const std::string &name2, const std::string &name3, const std::string &name4); - osd_file::error open(const std::string &name, uint32_t crc); - osd_file::error open(const std::string &name1, const std::string &name2, uint32_t crc); - osd_file::error open(const std::string &name1, const std::string &name2, const std::string &name3, uint32_t crc); - osd_file::error open(const std::string &name1, const std::string &name2, const std::string &name3, const std::string &name4, uint32_t crc); + osd_file::error open(const std::string &name, u32 crc); + osd_file::error open(const std::string &name1, const std::string &name2, u32 crc); + osd_file::error open(const std::string &name1, const std::string &name2, const std::string &name3, u32 crc); + osd_file::error open(const std::string &name1, const std::string &name2, const std::string &name3, const std::string &name4, u32 crc); osd_file::error open_next(); - osd_file::error open_ram(const void *data, uint32_t length); + osd_file::error open_ram(const void *data, u32 length); void close(); // control osd_file::error compress(int compress); // position - int seek(int64_t offset, int whence); - uint64_t tell(); + int seek(s64 offset, int whence); + u64 tell(); bool eof(); - uint64_t size(); + u64 size(); // reading - uint32_t read(void *buffer, uint32_t length); + u32 read(void *buffer, u32 length); int getc(); int ungetc(int c); char *gets(char *s, int n); // writing - uint32_t write(const void *buffer, uint32_t length); + u32 write(const void *buffer, u32 length); int puts(const char *s); int vprintf(util::format_argument_pack const &args); template int printf(Format &&fmt, Params &&...args) @@ -155,21 +155,21 @@ private: osd_file::error load_zipped_file(); // internal state - std::string m_filename; // original filename provided - std::string m_fullpath; // full filename - util::core_file::ptr m_file; // core file pointer - path_iterator m_iterator; // iterator for paths - path_iterator m_mediapaths; // media-path iterator - uint32_t m_crc; // file's CRC - uint32_t m_openflags; // flags we used for the open - util::hash_collection m_hashes; // collection of hashes + std::string m_filename; // original filename provided + std::string m_fullpath; // full filename + util::core_file::ptr m_file; // core file pointer + path_iterator m_iterator; // iterator for paths + path_iterator m_mediapaths; // media-path iterator + u32 m_crc; // file's CRC + u32 m_openflags; // flags we used for the open + util::hash_collection m_hashes; // collection of hashes std::unique_ptr m_zipfile; // ZIP file pointer - std::vector m_zipdata; // ZIP file data - uint64_t m_ziplength; // ZIP file length + std::vector m_zipdata; // ZIP file data + u64 m_ziplength; // ZIP file length - bool m_remove_on_close; // flag: remove the file when closing - bool m_restrict_to_mediapath; // flag: restrict to paths inside the media-path + bool m_remove_on_close; // flag: remove the file when closing + bool m_restrict_to_mediapath; // flag: restrict to paths inside the media-path }; #endif // MAME_EMU_FILEIO_H diff --git a/src/emu/gamedrv.h b/src/emu/gamedrv.h index f6a14df64b1..09973005a57 100644 --- a/src/emu/gamedrv.h +++ b/src/emu/gamedrv.h @@ -8,10 +8,10 @@ ***************************************************************************/ -#pragma once +#ifndef MAME_EMU_GAMEDRV_H +#define MAME_EMU_GAMEDRV_H -#ifndef __GAMEDRV_H__ -#define __GAMEDRV_H__ +#pragma once //************************************************************************** @@ -19,44 +19,44 @@ //************************************************************************** // maxima -const int MAX_DRIVER_NAME_CHARS = 8; +constexpr int MAX_DRIVER_NAME_CHARS = 16; // flags for game drivers -const uint32_t ORIENTATION_MASK = 0x00000007; -const uint32_t MACHINE_NOT_WORKING = 0x00000008; -const uint32_t MACHINE_UNEMULATED_PROTECTION = 0x00000010; // game's protection not fully emulated -const uint32_t MACHINE_WRONG_COLORS = 0x00000020; // colors are totally wrong -const uint32_t MACHINE_IMPERFECT_COLORS = 0x00000040; // colors are not 100% accurate, but close -const uint32_t MACHINE_IMPERFECT_GRAPHICS = 0x00000080; // graphics are wrong/incomplete -const uint32_t MACHINE_NO_COCKTAIL = 0x00000100; // screen flip support is missing -const uint32_t MACHINE_NO_SOUND = 0x00000200; // sound is missing -const uint32_t MACHINE_IMPERFECT_SOUND = 0x00000400; // sound is known to be wrong -const uint32_t MACHINE_SUPPORTS_SAVE = 0x00000800; // game supports save states -const uint32_t MACHINE_IS_BIOS_ROOT = 0x00001000; // this driver entry is a BIOS root -const uint32_t MACHINE_NO_STANDALONE = 0x00002000; // this driver cannot stand alone -const uint32_t MACHINE_REQUIRES_ARTWORK = 0x00004000; // the driver requires external artwork for key elements of the game -const uint32_t MACHINE_UNOFFICIAL = 0x00008000; // unofficial hardware change -const uint32_t MACHINE_NO_SOUND_HW = 0x00010000; // sound hardware not available -const uint32_t MACHINE_MECHANICAL = 0x00020000; // contains mechanical parts (pinball, redemption games,...) -const uint32_t MACHINE_TYPE_ARCADE = 0x00040000; // arcade machine (coin operated machines) -const uint32_t MACHINE_TYPE_CONSOLE = 0x00080000; // console system -const uint32_t MACHINE_TYPE_COMPUTER = 0x00100000; // any kind of computer including home computers, minis, calcs,... -const uint32_t MACHINE_TYPE_OTHER = 0x00200000; // any other emulated system that doesn't fit above (ex. clock, satelite receiver,...) -const uint32_t MACHINE_IMPERFECT_KEYBOARD = 0x00400000; // keyboard is known to be wrong -const uint32_t MACHINE_CLICKABLE_ARTWORK = 0x00800000; // marking that artwork is clickable and require mouse cursor -const uint32_t MACHINE_IS_INCOMPLETE = 0x01000000; // any official game/system with blantantly incomplete HW or SW should be marked with this -const uint32_t MACHINE_NODEVICE_MICROPHONE = 0x02000000; // any game/system that has unemulated recording voice device peripheral -const uint32_t MACHINE_NODEVICE_CAMERA = 0x04000000; // any game/system that has unemulated capturing image device peripheral -const uint32_t MACHINE_NODEVICE_PRINTER = 0x08000000; // any game/system that has unemulated grabbing of screen content device -const uint32_t MACHINE_NODEVICE_LAN = 0x10000000; // any game/system that has unemulated multi-linking capability -const uint32_t MACHINE_NODEVICE_WAN = 0x20000000; // any game/system that has unemulated networking capability +constexpr u32 ORIENTATION_MASK = 0x00000007; +constexpr u32 MACHINE_NOT_WORKING = 0x00000008; +constexpr u32 MACHINE_UNEMULATED_PROTECTION = 0x00000010; // game's protection not fully emulated +constexpr u32 MACHINE_WRONG_COLORS = 0x00000020; // colors are totally wrong +constexpr u32 MACHINE_IMPERFECT_COLORS = 0x00000040; // colors are not 100% accurate, but close +constexpr u32 MACHINE_IMPERFECT_GRAPHICS = 0x00000080; // graphics are wrong/incomplete +constexpr u32 MACHINE_NO_COCKTAIL = 0x00000100; // screen flip support is missing +constexpr u32 MACHINE_NO_SOUND = 0x00000200; // sound is missing +constexpr u32 MACHINE_IMPERFECT_SOUND = 0x00000400; // sound is known to be wrong +constexpr u32 MACHINE_SUPPORTS_SAVE = 0x00000800; // game supports save states +constexpr u32 MACHINE_IS_BIOS_ROOT = 0x00001000; // this driver entry is a BIOS root +constexpr u32 MACHINE_NO_STANDALONE = 0x00002000; // this driver cannot stand alone +constexpr u32 MACHINE_REQUIRES_ARTWORK = 0x00004000; // the driver requires external artwork for key elements of the game +constexpr u32 MACHINE_UNOFFICIAL = 0x00008000; // unofficial hardware change +constexpr u32 MACHINE_NO_SOUND_HW = 0x00010000; // sound hardware not available +constexpr u32 MACHINE_MECHANICAL = 0x00020000; // contains mechanical parts (pinball, redemption games,...) +constexpr u32 MACHINE_TYPE_ARCADE = 0x00040000; // arcade machine (coin operated machines) +constexpr u32 MACHINE_TYPE_CONSOLE = 0x00080000; // console system +constexpr u32 MACHINE_TYPE_COMPUTER = 0x00100000; // any kind of computer including home computers, minis, calcs,... +constexpr u32 MACHINE_TYPE_OTHER = 0x00200000; // any other emulated system that doesn't fit above (ex. clock, satelite receiver,...) +constexpr u32 MACHINE_IMPERFECT_KEYBOARD = 0x00400000; // keyboard is known to be wrong +constexpr u32 MACHINE_CLICKABLE_ARTWORK = 0x00800000; // marking that artwork is clickable and require mouse cursor +constexpr u32 MACHINE_IS_INCOMPLETE = 0x01000000; // any official game/system with blantantly incomplete HW or SW should be marked with this +constexpr u32 MACHINE_NODEVICE_MICROPHONE = 0x02000000; // any game/system that has unemulated recording voice device peripheral +constexpr u32 MACHINE_NODEVICE_CAMERA = 0x04000000; // any game/system that has unemulated capturing image device peripheral +constexpr u32 MACHINE_NODEVICE_PRINTER = 0x08000000; // any game/system that has unemulated grabbing of screen content device +constexpr u32 MACHINE_NODEVICE_LAN = 0x10000000; // any game/system that has unemulated multi-linking capability +constexpr u32 MACHINE_NODEVICE_WAN = 0x20000000; // any game/system that has unemulated networking capability // useful combinations of flags -const uint32_t MACHINE_IS_SKELETON = MACHINE_NO_SOUND | MACHINE_NOT_WORKING; // mask for skelly games -const uint32_t MACHINE_IS_SKELETON_MECHANICAL = MACHINE_IS_SKELETON | MACHINE_MECHANICAL | MACHINE_REQUIRES_ARTWORK; // mask for skelly mechanical games -const uint32_t MACHINE_FATAL_FLAGS = MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION | MACHINE_MECHANICAL; // red disclaimer -const uint32_t MACHINE_WARNING_FLAGS = MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_COLORS | MACHINE_REQUIRES_ARTWORK | MACHINE_IMPERFECT_GRAPHICS | MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_KEYBOARD | MACHINE_NO_SOUND | MACHINE_NO_COCKTAIL | MACHINE_NODEVICE_MICROPHONE | MACHINE_NODEVICE_CAMERA | MACHINE_NODEVICE_PRINTER | MACHINE_NODEVICE_LAN | MACHINE_NODEVICE_WAN; // yellow disclaimer -const uint32_t MACHINE_BTANB_FLAGS = MACHINE_IS_INCOMPLETE | MACHINE_NO_SOUND_HW; // default disclaimer +constexpr u32 MACHINE_IS_SKELETON = MACHINE_NO_SOUND | MACHINE_NOT_WORKING; // mask for skelly games +constexpr u32 MACHINE_IS_SKELETON_MECHANICAL = MACHINE_IS_SKELETON | MACHINE_MECHANICAL | MACHINE_REQUIRES_ARTWORK; // mask for skelly mechanical games +constexpr u32 MACHINE_FATAL_FLAGS = MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION | MACHINE_MECHANICAL; // red disclaimer +constexpr u32 MACHINE_WARNING_FLAGS = MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_COLORS | MACHINE_REQUIRES_ARTWORK | MACHINE_IMPERFECT_GRAPHICS | MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_KEYBOARD | MACHINE_NO_SOUND | MACHINE_NO_COCKTAIL | MACHINE_NODEVICE_MICROPHONE | MACHINE_NODEVICE_CAMERA | MACHINE_NODEVICE_PRINTER | MACHINE_NODEVICE_LAN | MACHINE_NODEVICE_WAN; // yellow disclaimer +constexpr u32 MACHINE_BTANB_FLAGS = MACHINE_IS_INCOMPLETE | MACHINE_NO_SOUND_HW; // default disclaimer //************************************************************************** // TYPE DEFINITIONS @@ -79,7 +79,7 @@ struct game_driver void (*driver_init)(running_machine &machine); // DRIVER_INIT callback const tiny_rom_entry * rom; // pointer to list of ROMs for the game const char * compatible_with; - uint32_t flags; // orientation and other flags; see defines below + u32 flags; // orientation and other flags; see defines below const internal_layout * default_layout; // default internally defined layout }; @@ -195,4 +195,4 @@ extern const game_driver GAME_NAME(NAME) = \ }; -#endif +#endif // MAME_EMU_GAMEDRV_H diff --git a/src/emu/input.cpp b/src/emu/input.cpp index 91ff3350750..68882c2c3e4 100644 --- a/src/emu/input.cpp +++ b/src/emu/input.cpp @@ -27,7 +27,7 @@ //************************************************************************** // invalid memory value for axis polling -const int32_t INVALID_AXIS_VALUE = 0x7fffffff; +const s32 INVALID_AXIS_VALUE = 0x7fffffff; // additional expanded input codes for sequences const input_code input_seq::end_code(DEVICE_CLASS_INTERNAL, 0, ITEM_CLASS_INVALID, ITEM_MODIFIER_NONE, ITEM_ID_SEQ_END); @@ -49,7 +49,7 @@ const input_seq input_seq::empty_seq; // simple class to match codes to strings struct code_string_table { - uint32_t operator[](const char *string) const + u32 operator[](const char *string) const { for (const code_string_table *current = this; current->m_code != ~0; current++) if (strcmp(current->m_string, string) == 0) @@ -57,7 +57,7 @@ struct code_string_table return ~0; } - const char *operator[](uint32_t code) const + const char *operator[](u32 code) const { for (const code_string_table *current = this; current->m_code != ~0; current++) if (current->m_code == code) @@ -65,7 +65,7 @@ struct code_string_table return nullptr; } - uint32_t m_code; + u32 m_code; const char * m_string; }; @@ -594,10 +594,10 @@ input_manager::~input_manager() // input code //------------------------------------------------- -int32_t input_manager::code_value(input_code code) +s32 input_manager::code_value(input_code code) { g_profiler.start(PROFILER_INPUT); - int32_t result = 0; + s32 result = 0; // dummy loop to allow clean early exits do @@ -859,14 +859,14 @@ bool input_manager::code_check_axis(input_device_item &item, input_code code) // ignore min/max for lightguns // so the selection will not be affected by a gun going out of range - int32_t curval = code_value(code); + s32 curval = code_value(code); if (code.device_class() == DEVICE_CLASS_LIGHTGUN && (code.item_id() == ITEM_ID_XAXIS || code.item_id() == ITEM_ID_YAXIS) && (curval == INPUT_ABSOLUTE_MAX || curval == INPUT_ABSOLUTE_MIN)) return false; // compute the diff against memory - int32_t diff = curval - item.memory(); + s32 diff = curval - item.memory(); if (diff < 0) diff = -diff; @@ -1174,7 +1174,7 @@ input_code input_manager::code_from_token(const char *_token) // if we have another token, it is the item class if (curtok < numtokens) { - uint32_t temp = (*itemclass_token_table)[token[curtok].c_str()]; + u32 temp = (*itemclass_token_table)[token[curtok].c_str()]; if (temp != ~0) { curtok++; @@ -1259,14 +1259,14 @@ bool input_manager::seq_pressed(const input_seq &seq) // defined in an input sequence //------------------------------------------------- -int32_t input_manager::seq_axis_value(const input_seq &seq, input_item_class &itemclass) +s32 input_manager::seq_axis_value(const input_seq &seq, input_item_class &itemclass) { // start with no valid classes input_item_class itemclasszero = ITEM_CLASS_INVALID; itemclass = ITEM_CLASS_INVALID; // iterate over all of the codes - int32_t result = 0; + s32 result = 0; bool invert = false; bool enable = true; for (int codenum = 0; ; codenum++) @@ -1303,7 +1303,7 @@ int32_t input_manager::seq_axis_value(const input_seq &seq, input_item_class &it // non-switch codes are analog values else { - int32_t value = code_value(code); + s32 value = code_value(code); // if we got a 0 value, don't do anything except remember the first type if (value == 0) @@ -1565,7 +1565,7 @@ void input_manager::seq_from_tokens(input_seq &seq, const char *string) while (1) { // trim any leading spaces - while (*str != 0 && isspace((uint8_t)*str)) + while (*str != 0 && isspace(u8(*str))) str++; // bail if we're done @@ -1574,8 +1574,8 @@ void input_manager::seq_from_tokens(input_seq &seq, const char *string) // find the end of the token and make it upper-case along the way char *strtemp; - for (strtemp = str; *strtemp != 0 && !isspace((uint8_t)*strtemp); strtemp++) - *strtemp = toupper((uint8_t)*strtemp); + for (strtemp = str; *strtemp != 0 && !isspace(u8(*strtemp)); strtemp++) + *strtemp = toupper(u8(*strtemp)); char origspace = *strtemp; *strtemp = 0; diff --git a/src/emu/input.h b/src/emu/input.h index e8ed5aac5a3..f5bdcbbae18 100644 --- a/src/emu/input.h +++ b/src/emu/input.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __INPUT_H__ -#define __INPUT_H__ +#ifndef MAME_EMU_INPUT_H +#define MAME_EMU_INPUT_H //************************************************************************** @@ -23,19 +23,19 @@ //************************************************************************** // relative devices return ~512 units per onscreen pixel -const int32_t INPUT_RELATIVE_PER_PIXEL = 512; +constexpr s32 INPUT_RELATIVE_PER_PIXEL = 512; // absolute devices return values between -65536 and +65536 -const int32_t INPUT_ABSOLUTE_MIN = -65536; -const int32_t INPUT_ABSOLUTE_MAX = 65536; +constexpr s32 INPUT_ABSOLUTE_MIN = -65536; +constexpr s32 INPUT_ABSOLUTE_MAX = 65536; // maximum number of axis/buttons/hats with ITEM_IDs for use by osd layer -const int INPUT_MAX_AXIS = 8; -const int INPUT_MAX_BUTTONS = 32; -const int INPUT_MAX_HATS = 4; -const int INPUT_MAX_ADD_SWITCH = 16; -const int INPUT_MAX_ADD_ABSOLUTE = 16; -const int INPUT_MAX_ADD_RELATIVE = 16; +constexpr int INPUT_MAX_AXIS = 8; +constexpr int INPUT_MAX_BUTTONS = 32; +constexpr int INPUT_MAX_HATS = 4; +constexpr int INPUT_MAX_ADD_SWITCH = 16; +constexpr int INPUT_MAX_ADD_ABSOLUTE = 16; +constexpr int INPUT_MAX_ADD_RELATIVE = 16; // device classes @@ -395,7 +395,7 @@ public: private: // internal state - uint32_t m_internal; + u32 m_internal; }; @@ -459,7 +459,7 @@ public: input_class &device_class(input_device_class devclass) { assert(devclass >= DEVICE_CLASS_FIRST_VALID && devclass <= DEVICE_CLASS_LAST_VALID); return *m_class[devclass]; } // input code readers - int32_t code_value(input_code code); + s32 code_value(input_code code); bool code_pressed(input_code code) { return code_value(code) != 0; } bool code_pressed_once(input_code code); @@ -480,7 +480,7 @@ public: // input sequence readers bool seq_pressed(const input_seq &seq); - int32_t seq_axis_value(const input_seq &seq, input_item_class &itemclass); + s32 seq_axis_value(const input_seq &seq, input_item_class &itemclass); // input sequence polling void seq_poll_start(input_item_class itemclass, const input_seq *startseq = nullptr); @@ -962,4 +962,4 @@ private: -#endif // __INPUT_H__ +#endif // MAME_EMU_INPUT_H diff --git a/src/emu/inputdev.cpp b/src/emu/inputdev.cpp index ff58d63268b..380b42d9c3a 100644 --- a/src/emu/inputdev.cpp +++ b/src/emu/inputdev.cpp @@ -27,9 +27,9 @@ public: input_device_switch_item(input_device &device, const char *name, void *internal, input_item_id itemid, item_get_state_func getstate); // readers - virtual int32_t read_as_switch(input_item_modifier modifier) override; - virtual int32_t read_as_relative(input_item_modifier modifier) override; - virtual int32_t read_as_absolute(input_item_modifier modifier) override; + virtual s32 read_as_switch(input_item_modifier modifier) override; + virtual s32 read_as_relative(input_item_modifier modifier) override; + virtual s32 read_as_absolute(input_item_modifier modifier) override; // steadykey helper bool steadykey_changed(); @@ -37,8 +37,8 @@ public: private: // internal state - int32_t m_steadykey; // the live steadykey state - int32_t m_oldkey; // old live state + s32 m_steadykey; // the live steadykey state + s32 m_oldkey; // old live state }; @@ -52,9 +52,9 @@ public: input_device_relative_item(input_device &device, const char *name, void *internal, input_item_id itemid, item_get_state_func getstate); // readers - virtual int32_t read_as_switch(input_item_modifier modifier) override; - virtual int32_t read_as_relative(input_item_modifier modifier) override; - virtual int32_t read_as_absolute(input_item_modifier modifier) override; + virtual s32 read_as_switch(input_item_modifier modifier) override; + virtual s32 read_as_relative(input_item_modifier modifier) override; + virtual s32 read_as_absolute(input_item_modifier modifier) override; }; @@ -68,9 +68,9 @@ public: input_device_absolute_item(input_device &device, const char *name, void *internal, input_item_id itemid, item_get_state_func getstate); // readers - virtual int32_t read_as_switch(input_item_modifier modifier) override; - virtual int32_t read_as_relative(input_item_modifier modifier) override; - virtual int32_t read_as_absolute(input_item_modifier modifier) override; + virtual s32 read_as_switch(input_item_modifier modifier) override; + virtual s32 read_as_relative(input_item_modifier modifier) override; + virtual s32 read_as_absolute(input_item_modifier modifier) override; }; @@ -116,7 +116,7 @@ bool joystick_map::parse(const char *mapstring) if (*mapstring == 0 || *mapstring == '.') { bool symmetric = (rownum >= 5 && *mapstring == 0); - const uint8_t *srcrow = &m_map[symmetric ? (8 - rownum) : (rownum - 1)][0]; + const u8 *srcrow = &m_map[symmetric ? (8 - rownum) : (rownum - 1)][0]; // if this is row 0, we don't have a source row -- invalid if (rownum == 0) @@ -125,7 +125,7 @@ bool joystick_map::parse(const char *mapstring) // copy from the srcrow, applying up/down symmetry if in the bottom half for (int colnum = 0; colnum < 9; colnum++) { - uint8_t val = srcrow[colnum]; + u8 val = srcrow[colnum]; if (symmetric) val = (val & (JOYSTICK_MAP_LEFT | JOYSTICK_MAP_RIGHT)) | ((val & JOYSTICK_MAP_UP) << 1) | ((val & JOYSTICK_MAP_DOWN) >> 1); m_map[rownum][colnum] = val; @@ -141,7 +141,7 @@ bool joystick_map::parse(const char *mapstring) if (colnum > 0 && (*mapstring == 0 || *mapstring == '.')) { bool symmetric = (colnum >= 5); - uint8_t val = m_map[rownum][symmetric ? (8 - colnum) : (colnum - 1)]; + u8 val = m_map[rownum][symmetric ? (8 - colnum) : (colnum - 1)]; if (symmetric) val = (val & (JOYSTICK_MAP_UP | JOYSTICK_MAP_DOWN)) | ((val & JOYSTICK_MAP_LEFT) << 1) | ((val & JOYSTICK_MAP_RIGHT) >> 1); m_map[rownum][colnum] = val; @@ -150,7 +150,7 @@ bool joystick_map::parse(const char *mapstring) // otherwise, convert the character to its value else { - static const uint8_t charmap[] = + static const u8 charmap[] = { JOYSTICK_MAP_UP | JOYSTICK_MAP_LEFT, JOYSTICK_MAP_UP, @@ -221,12 +221,12 @@ std::string joystick_map::to_string() const // map based on the given X/Y axis values //------------------------------------------------- -uint8_t joystick_map::update(int32_t xaxisval, int32_t yaxisval) +u8 joystick_map::update(s32 xaxisval, s32 yaxisval) { // now map the X and Y axes to a 9x9 grid using the raw values xaxisval = ((xaxisval - INPUT_ABSOLUTE_MIN) * 9) / (INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN + 1); yaxisval = ((yaxisval - INPUT_ABSOLUTE_MIN) * 9) / (INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN + 1); - uint8_t mapval = m_map[yaxisval][xaxisval]; + u8 mapval = m_map[yaxisval][xaxisval]; // handle stickiness if (mapval == JOYSTICK_MAP_STICKY) @@ -406,8 +406,8 @@ input_device_lightgun::input_device_lightgun(input_manager &manager, const char input_device_joystick::input_device_joystick(input_manager &manager, const char *_name, const char *_id, void *_internal) : input_device(manager, _name, _id, _internal), - m_joystick_deadzone((int32_t)(manager.machine().options().joystick_deadzone() * INPUT_ABSOLUTE_MAX)), - m_joystick_saturation((int32_t)(manager.machine().options().joystick_saturation() * INPUT_ABSOLUTE_MAX)) + m_joystick_deadzone(s32(manager.machine().options().joystick_deadzone() * INPUT_ABSOLUTE_MAX)), + m_joystick_saturation(s32(manager.machine().options().joystick_saturation() * INPUT_ABSOLUTE_MAX)) { // get the default joystick map const char *mapstring = machine().options().joystick_map(); @@ -431,7 +431,7 @@ input_device_joystick::input_device_joystick(input_manager &manager, const char // absolute value //------------------------------------------------- -int32_t input_device_joystick::adjust_absolute_value(int32_t result) const +s32 input_device_joystick::adjust_absolute_value(s32 result) const { // properties are symmetric bool negative = false; @@ -451,7 +451,7 @@ int32_t input_device_joystick::adjust_absolute_value(int32_t result) const // otherwise, scale else - result = (int64_t)(result - m_joystick_deadzone) * (int64_t)INPUT_ABSOLUTE_MAX / (int64_t)(m_joystick_saturation - m_joystick_deadzone); + result = s64(result - m_joystick_deadzone) * s64(INPUT_ABSOLUTE_MAX) / s64(m_joystick_saturation - m_joystick_deadzone); // re-apply sign and return return negative ? -result : result; @@ -719,7 +719,7 @@ input_device_switch_item::input_device_switch_item(input_device &device, const c // modified as necessary //------------------------------------------------- -int32_t input_device_switch_item::read_as_switch(input_item_modifier modifier) +s32 input_device_switch_item::read_as_switch(input_item_modifier modifier) { // if we're doing a lightgun reload hack, button 1 and 2 operate differently input_device_class devclass = m_device.devclass(); @@ -752,7 +752,7 @@ int32_t input_device_switch_item::read_as_switch(input_item_modifier modifier) // a relative axis value //------------------------------------------------- -int32_t input_device_switch_item::read_as_relative(input_item_modifier modifier) +s32 input_device_switch_item::read_as_relative(input_item_modifier modifier) { // no translation to relative return 0; @@ -764,7 +764,7 @@ int32_t input_device_switch_item::read_as_relative(input_item_modifier modifier) // an absolute axis value //------------------------------------------------- -int32_t input_device_switch_item::read_as_absolute(input_item_modifier modifier) +s32 input_device_switch_item::read_as_absolute(input_item_modifier modifier) { // no translation to absolute return 0; @@ -779,7 +779,7 @@ int32_t input_device_switch_item::read_as_absolute(input_item_modifier modifier) bool input_device_switch_item::steadykey_changed() { - int32_t old = m_oldkey; + s32 old = m_oldkey; m_oldkey = update_value(); if (((m_current ^ old) & 1) == 0) return false; @@ -811,7 +811,7 @@ input_device_relative_item::input_device_relative_item(input_device &device, con // a switch result based on the modifier //------------------------------------------------- -int32_t input_device_relative_item::read_as_switch(input_item_modifier modifier) +s32 input_device_relative_item::read_as_switch(input_item_modifier modifier) { // process according to modifiers if (modifier == ITEM_MODIFIER_POS || modifier == ITEM_MODIFIER_RIGHT || modifier == ITEM_MODIFIER_DOWN) @@ -829,7 +829,7 @@ int32_t input_device_relative_item::read_as_switch(input_item_modifier modifier) // as a relative axis value //------------------------------------------------- -int32_t input_device_relative_item::read_as_relative(input_item_modifier modifier) +s32 input_device_relative_item::read_as_relative(input_item_modifier modifier) { // just return directly return update_value(); @@ -841,7 +841,7 @@ int32_t input_device_relative_item::read_as_relative(input_item_modifier modifie // as an absolute axis value //------------------------------------------------- -int32_t input_device_relative_item::read_as_absolute(input_item_modifier modifier) +s32 input_device_relative_item::read_as_absolute(input_item_modifier modifier) { // no translation to absolute return 0; @@ -868,10 +868,10 @@ input_device_absolute_item::input_device_absolute_item(input_device &device, con // a switch result based on the modifier //------------------------------------------------- -int32_t input_device_absolute_item::read_as_switch(input_item_modifier modifier) +s32 input_device_absolute_item::read_as_switch(input_item_modifier modifier) { // start with the current value - int32_t result = m_device.adjust_absolute(update_value()); + s32 result = m_device.adjust_absolute(update_value()); assert(result >= INPUT_ABSOLUTE_MIN && result <= INPUT_ABSOLUTE_MAX); // left/right/up/down: if this is a joystick, fetch the paired X/Y axis values and convert @@ -910,7 +910,7 @@ int32_t input_device_absolute_item::read_as_switch(input_item_modifier modifier) // as a relative axis value //------------------------------------------------- -int32_t input_device_absolute_item::read_as_relative(input_item_modifier modifier) +s32 input_device_absolute_item::read_as_relative(input_item_modifier modifier) { // no translation to relative return 0; @@ -923,10 +923,10 @@ int32_t input_device_absolute_item::read_as_relative(input_item_modifier modifie // tweaks //------------------------------------------------- -int32_t input_device_absolute_item::read_as_absolute(input_item_modifier modifier) +s32 input_device_absolute_item::read_as_absolute(input_item_modifier modifier) { // start with the current value - int32_t result = m_device.adjust_absolute(update_value()); + s32 result = m_device.adjust_absolute(update_value()); assert(result >= INPUT_ABSOLUTE_MIN && result <= INPUT_ABSOLUTE_MAX); // if we're doing a lightgun reload hack, override the value diff --git a/src/emu/inputdev.h b/src/emu/inputdev.h index 5b4adcd84f3..767e2b8978b 100644 --- a/src/emu/inputdev.h +++ b/src/emu/inputdev.h @@ -25,7 +25,7 @@ class input_manager; // callback for getting the value of an item on a device -typedef int32_t (*item_get_state_func)(void *device_internal, void *item_internal); +typedef s32 (*item_get_state_func)(void *device_internal, void *item_internal); // ======================> joystick_map @@ -47,15 +47,15 @@ public: std::string to_string() const; // update the state of a live map - uint8_t update(int32_t xaxisval, int32_t yaxisval); + u8 update(s32 xaxisval, s32 yaxisval); // joystick mapping codes - static const uint8_t JOYSTICK_MAP_NEUTRAL = 0x00; - static const uint8_t JOYSTICK_MAP_LEFT = 0x01; - static const uint8_t JOYSTICK_MAP_RIGHT = 0x02; - static const uint8_t JOYSTICK_MAP_UP = 0x04; - static const uint8_t JOYSTICK_MAP_DOWN = 0x08; - static const uint8_t JOYSTICK_MAP_STICKY = 0x0f; + static constexpr u8 JOYSTICK_MAP_NEUTRAL = 0x00; + static constexpr u8 JOYSTICK_MAP_LEFT = 0x01; + static constexpr u8 JOYSTICK_MAP_RIGHT = 0x02; + static constexpr u8 JOYSTICK_MAP_UP = 0x04; + static constexpr u8 JOYSTICK_MAP_DOWN = 0x08; + static constexpr u8 JOYSTICK_MAP_STICKY = 0x0f; private: // internal helpers @@ -67,8 +67,8 @@ private: } // internal state - uint8_t m_map[9][9]; // 9x9 grid - uint8_t m_lastmap; // last value returned (for sticky tracking) + u8 m_map[9][9]; // 9x9 grid + u8 m_lastmap; // last value returned (for sticky tracking) std::string m_origstring; // originally parsed string }; @@ -95,17 +95,17 @@ public: input_item_class itemclass() const { return m_itemclass; } input_code code() const; const char *token() const { return m_token.c_str(); } - int32_t current() const { return m_current; } - int32_t memory() const { return m_memory; } + s32 current() const { return m_current; } + s32 memory() const { return m_memory; } // helpers - int32_t update_value(); - void set_memory(int32_t value) { m_memory = value; } + s32 update_value(); + void set_memory(s32 value) { m_memory = value; } // readers - virtual int32_t read_as_switch(input_item_modifier modifier) = 0; - virtual int32_t read_as_relative(input_item_modifier modifier) = 0; - virtual int32_t read_as_absolute(input_item_modifier modifier) = 0; + virtual s32 read_as_switch(input_item_modifier modifier) = 0; + virtual s32 read_as_relative(input_item_modifier modifier) = 0; + virtual s32 read_as_absolute(input_item_modifier modifier) = 0; protected: // internal state @@ -118,8 +118,8 @@ protected: std::string m_token; // tokenized name for non-standard items // live state - int32_t m_current; // current raw value - int32_t m_memory; // "memory" value, to remember where we started during polling + s32 m_current; // current raw value + s32 m_memory; // "memory" value, to remember where we started during polling }; @@ -155,13 +155,13 @@ public: input_item_id add_item(const char *name, input_item_id itemid, item_get_state_func getstate, void *internal = nullptr); // helpers - int32_t adjust_absolute(int32_t value) const { return adjust_absolute_value(value); } + s32 adjust_absolute(s32 value) const { return adjust_absolute_value(value); } bool match_device_id(const char *deviceid); protected: // specific overrides virtual input_device_class device_class() const = 0; - virtual int32_t adjust_absolute_value(int32_t value) const { return value; } + virtual s32 adjust_absolute_value(s32 value) const { return value; } private: // internal state @@ -241,13 +241,13 @@ public: protected: // specific overrides virtual input_device_class device_class() const override { return DEVICE_CLASS_JOYSTICK; } - virtual int32_t adjust_absolute_value(int32_t value) const override; + virtual s32 adjust_absolute_value(s32 value) const override; private: // joystick information joystick_map m_joymap; // joystick map for this device - int32_t m_joystick_deadzone; // deadzone for joystick - int32_t m_joystick_saturation; // saturation position for joystick + s32 m_joystick_deadzone; // deadzone for joystick + s32 m_joystick_saturation; // saturation position for joystick }; @@ -393,7 +393,7 @@ protected: inline input_manager &input_device_item::manager() const { return m_device.manager(); } inline running_machine &input_device_item::machine() const { return m_device.machine(); } inline input_code input_device_item::code() const { return input_code(m_device.devclass(), m_device.devindex(), m_itemclass, ITEM_MODIFIER_NONE, m_itemid); } -inline int32_t input_device_item::update_value() { return m_current = (*m_getstate)(m_device.internal(), m_internal); } +inline s32 input_device_item::update_value() { return m_current = (*m_getstate)(m_device.internal(), m_internal); } diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index 7892225d817..5e268ffa750 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -129,9 +129,9 @@ const int SPACE_COUNT = 3; // from a numerator and a denominator //------------------------------------------------- -inline int64_t compute_scale(int32_t num, int32_t den) +inline s64 compute_scale(s32 num, s32 den) { - return (int64_t(num) << 24) / den; + return (s64(num) << 24) / den; } @@ -140,9 +140,9 @@ inline int64_t compute_scale(int32_t num, int32_t den) // an 8.24 scale value //------------------------------------------------- -inline int64_t recip_scale(int64_t scale) +inline s64 recip_scale(s64 scale) { - return (int64_t(1) << 48) / scale; + return (s64(1) << 48) / scale; } @@ -151,9 +151,9 @@ inline int64_t recip_scale(int64_t scale) // a 32-bit value //------------------------------------------------- -inline int32_t apply_scale(int32_t value, int64_t scale) +inline s32 apply_scale(s32 value, s64 scale) { - return (int64_t(value) * scale) >> 24; + return (s64(value) * scale) >> 24; } @@ -164,7 +164,7 @@ inline int32_t apply_scale(int32_t value, int64_t scale) const struct { - uint32_t id; + u32 id; const char *string; } input_port_default_strings[] = { @@ -296,7 +296,7 @@ const struct const char *const ioport_manager::seqtypestrings[] = { "standard", "increment", "decrement" }; -std::uint8_t const inp_header::MAGIC[inp_header::OFFS_BASETIME - inp_header::OFFS_MAGIC] = { 'M', 'A', 'M', 'E', 'I', 'N', 'P', 0 }; +u8 const inp_header::MAGIC[inp_header::OFFS_BASETIME - inp_header::OFFS_MAGIC] = { 'M', 'A', 'M', 'E', 'I', 'N', 'P', 0 }; @@ -573,7 +573,7 @@ ioport_setting::ioport_setting(ioport_field &field, ioport_value _value, const c // ioport_diplocation - constructor //------------------------------------------------- -ioport_diplocation::ioport_diplocation(const char *name, uint8_t swnum, bool invert) +ioport_diplocation::ioport_diplocation(const char *name, u8 swnum, bool invert) : m_next(nullptr), m_name(name), m_number(swnum), @@ -1151,7 +1151,7 @@ void ioport_field::frame_update(ioport_value &result) // additional logic to restrict digital joysticks if (curstate && !m_digital_value && m_live->joystick != nullptr && m_way != 16 && !machine().options().joystick_contradictory()) { - uint8_t mask = (m_way == 4) ? m_live->joystick->current4way() : m_live->joystick->current(); + u8 mask = (m_way == 4) ? m_live->joystick->current4way() : m_live->joystick->current(); if (!(mask & (1 << m_live->joydir))) curstate = false; } @@ -1852,7 +1852,7 @@ ioport_manager::~ioport_manager() // type/player //------------------------------------------------- -const char *ioport_manager::type_name(ioport_type type, uint8_t player) +const char *ioport_manager::type_name(ioport_type type, u8 player) { // if we have a machine, use the live state and quick lookup input_type_entry *entry = m_type_to_entry[type][player]; @@ -2063,7 +2063,7 @@ g_profiler.stop(); // values based on the time between frames //------------------------------------------------- -int32_t ioport_manager::frame_interpolate(int32_t oldval, int32_t newval) +s32 ioport_manager::frame_interpolate(s32 oldval, s32 newval) { // if no last delta, just use new value if (m_last_delta_nsec == 0) @@ -2071,7 +2071,7 @@ int32_t ioport_manager::frame_interpolate(int32_t oldval, int32_t newval) // otherwise, interpolate attoseconds_t nsec_since_last = (machine().time() - m_last_frame_time).as_attoseconds() / ATTOSECONDS_PER_NANOSECOND; - return oldval + (int64_t(newval - oldval) * nsec_since_last / m_last_delta_nsec); + return oldval + (s64(newval - oldval) * nsec_since_last / m_last_delta_nsec); } @@ -2504,7 +2504,7 @@ _Type ioport_manager::playback_read(_Type &result) template<> bool ioport_manager::playback_read(bool &result) { - uint8_t temp; + u8 temp; playback_read(temp); return result = bool(temp); } @@ -2571,8 +2571,8 @@ void ioport_manager::playback_end(const char *message) // display speed stats if (m_playback_accumulated_speed > 0) m_playback_accumulated_speed /= m_playback_accumulated_frames; - osd_printf_info("Total playback frames: %d\n", uint32_t(m_playback_accumulated_frames)); - osd_printf_info("Average recorded speed: %d%%\n", uint32_t((m_playback_accumulated_speed * 200 + 1) >> 21)); + osd_printf_info("Total playback frames: %d\n", u32(m_playback_accumulated_frames)); + osd_printf_info("Average recorded speed: %d%%\n", u32((m_playback_accumulated_speed * 200 + 1) >> 21)); // close the program at the end of inp file playback if (machine().options().exit_after_playback()) { @@ -2603,7 +2603,7 @@ void ioport_manager::playback_frame(const attotime &curtime) playback_end("Out of sync"); // then the speed - uint32_t curspeed; + u32 curspeed; m_playback_accumulated_speed += playback_read(curspeed); m_playback_accumulated_frames++; } @@ -2657,7 +2657,7 @@ void ioport_manager::record_write(_Type value) template<> void ioport_manager::record_write(bool value) { - uint8_t byte = uint8_t(value); + u8 byte = u8(value); record_write(byte); } @@ -2676,7 +2676,7 @@ void ioport_manager::timecode_write(_Type value) /*template<> void ioport_manager::timecode_write(bool value) { - uint8_t byte = uint8_t(value); + u8 byte = u8(value); timecode_write(byte); }*/ template<> @@ -2805,7 +2805,7 @@ void ioport_manager::record_frame(const attotime &curtime) record_write(curtime.attoseconds()); // then the current speed - record_write(uint32_t(machine().video().speed_percent() * double(1 << 20))); + record_write(u32(machine().video().speed_percent() * double(1 << 20))); } if (m_timecode_file.is_open() && machine().video().get_timecode_write()) @@ -3382,12 +3382,12 @@ analog_field::analog_field(ioport_field &field) // the appropriate min/max for the analog control //------------------------------------------------- -inline int32_t analog_field::apply_min_max(int32_t value) const +inline s32 analog_field::apply_min_max(s32 value) const { // take the analog minimum and maximum values and apply the inverse of the // sensitivity so that we can clamp against them before applying sensitivity - int32_t adjmin = apply_inverse_sensitivity(m_minimum); - int32_t adjmax = apply_inverse_sensitivity(m_maximum); + s32 adjmin = apply_inverse_sensitivity(m_minimum); + s32 adjmax = apply_inverse_sensitivity(m_maximum); // for absolute devices, clamp to the bounds absolutely if (!m_wraps) @@ -3401,7 +3401,7 @@ inline int32_t analog_field::apply_min_max(int32_t value) const // for relative devices, wrap around when we go past the edge else { - int32_t range = adjmax - adjmin; + s32 range = adjmax - adjmin; // rolls to other end when 1 position past end. value = (value - adjmin) % range; if (value < 0) @@ -3418,9 +3418,9 @@ inline int32_t analog_field::apply_min_max(int32_t value) const // adjustment for a current value //------------------------------------------------- -inline int32_t analog_field::apply_sensitivity(int32_t value) const +inline s32 analog_field::apply_sensitivity(s32 value) const { - return int32_t((int64_t(value) * m_sensitivity) / 100.0 + 0.5); + return s32((s64(value) * m_sensitivity) / 100.0 + 0.5); } @@ -3429,9 +3429,9 @@ inline int32_t analog_field::apply_sensitivity(int32_t value) const // sensitivity adjustment for a current value //------------------------------------------------- -inline int32_t analog_field::apply_inverse_sensitivity(int32_t value) const +inline s32 analog_field::apply_inverse_sensitivity(s32 value) const { - return int32_t((int64_t(value) * 100) / m_sensitivity); + return s32((s64(value) * 100) / m_sensitivity); } @@ -3440,7 +3440,7 @@ inline int32_t analog_field::apply_inverse_sensitivity(int32_t value) const // analog input //------------------------------------------------- -int32_t analog_field::apply_settings(int32_t value) const +s32 analog_field::apply_settings(s32 value) const { // apply the min/max and then the sensitivity value = apply_min_max(value); @@ -3477,7 +3477,7 @@ void analog_field::frame_update(running_machine &machine) // get the new raw analog value and its type input_item_class itemclass; - int32_t rawvalue = machine.input().seq_axis_value(m_field.seq(SEQ_TYPE_STANDARD), itemclass); + s32 rawvalue = machine.input().seq_axis_value(m_field.seq(SEQ_TYPE_STANDARD), itemclass); // if we got an absolute input, it overrides everything else if (itemclass == ITEM_CLASS_ABSOLUTE) @@ -3525,14 +3525,14 @@ void analog_field::frame_update(running_machine &machine) // if we got it from a relative device, use that as the starting delta // also note that the last input was not a digital one - int32_t delta = 0; + s32 delta = 0; if (itemclass == ITEM_CLASS_RELATIVE && rawvalue != 0) { delta = rawvalue; m_lastdigital = false; } - int64_t keyscale = (m_accum >= 0) ? m_keyscalepos : m_keyscaleneg; + s64 keyscale = (m_accum >= 0) ? m_keyscalepos : m_keyscaleneg; // if the decrement code sequence is pressed, add the key delta to // the accumulated delta; also note that the last input was a digital one @@ -3575,7 +3575,7 @@ void analog_field::frame_update(running_machine &machine) // was pressed, apply autocentering if (m_autocenter) { - int32_t center = apply_inverse_sensitivity(m_center); + s32 center = apply_inverse_sensitivity(m_center); if (m_lastdigital && !keypressed) { // autocenter from positive values @@ -3618,7 +3618,7 @@ void analog_field::read(ioport_value &result) return; // start with the raw value - int32_t value = m_accum; + s32 value = m_accum; // interpolate if appropriate and if time has passed since the last update if (m_interpolate) @@ -3647,7 +3647,7 @@ void analog_field::read(ioport_value &result) float analog_field::crosshair_read() { - int32_t rawvalue = apply_settings(m_accum) & (m_field.mask() >> m_shift); + s32 rawvalue = apply_settings(m_accum) & (m_field.mask() >> m_shift); return float(rawvalue - m_adjmin) / float(m_adjmax - m_adjmin); } diff --git a/src/emu/ioport.h b/src/emu/ioport.h index 8c46e38e3f4..2f266261698 100644 --- a/src/emu/ioport.h +++ b/src/emu/ioport.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __INPTPORT_H__ -#define __INPTPORT_H__ +#ifndef MAME_EMU_IOPORT_H +#define MAME_EMU_IOPORT_H #include #include @@ -27,7 +27,7 @@ //************************************************************************** // input ports support up to 32 bits each -typedef uint32_t ioport_value; +typedef u32 ioport_value; // active high/low values for input ports const ioport_value IP_ACTIVE_HIGH = 0x00000000; @@ -696,17 +696,17 @@ public: { return 0 == std::memcmp(MAGIC, m_data + OFFS_MAGIC, OFFS_BASETIME - OFFS_MAGIC); } - std::uint64_t get_basetime() const + u64 get_basetime() const { return - (std::uint64_t(m_data[OFFS_BASETIME + 0]) << (0 * 8)) | - (std::uint64_t(m_data[OFFS_BASETIME + 1]) << (1 * 8)) | - (std::uint64_t(m_data[OFFS_BASETIME + 2]) << (2 * 8)) | - (std::uint64_t(m_data[OFFS_BASETIME + 3]) << (3 * 8)) | - (std::uint64_t(m_data[OFFS_BASETIME + 4]) << (4 * 8)) | - (std::uint64_t(m_data[OFFS_BASETIME + 5]) << (5 * 8)) | - (std::uint64_t(m_data[OFFS_BASETIME + 6]) << (6 * 8)) | - (std::uint64_t(m_data[OFFS_BASETIME + 7]) << (7 * 8)); + (u64(m_data[OFFS_BASETIME + 0]) << (0 * 8)) | + (u64(m_data[OFFS_BASETIME + 1]) << (1 * 8)) | + (u64(m_data[OFFS_BASETIME + 2]) << (2 * 8)) | + (u64(m_data[OFFS_BASETIME + 3]) << (3 * 8)) | + (u64(m_data[OFFS_BASETIME + 4]) << (4 * 8)) | + (u64(m_data[OFFS_BASETIME + 5]) << (5 * 8)) | + (u64(m_data[OFFS_BASETIME + 6]) << (6 * 8)) | + (u64(m_data[OFFS_BASETIME + 7]) << (7 * 8)); } unsigned get_majversion() const { @@ -729,16 +729,16 @@ public: { std::memcpy(m_data + OFFS_MAGIC, MAGIC, OFFS_BASETIME - OFFS_MAGIC); } - void set_basetime(std::uint64_t time) + void set_basetime(u64 time) { - m_data[OFFS_BASETIME + 0] = std::uint8_t((time >> (0 * 8)) & 0x00ff); - m_data[OFFS_BASETIME + 1] = std::uint8_t((time >> (1 * 8)) & 0x00ff); - m_data[OFFS_BASETIME + 2] = std::uint8_t((time >> (2 * 8)) & 0x00ff); - m_data[OFFS_BASETIME + 3] = std::uint8_t((time >> (3 * 8)) & 0x00ff); - m_data[OFFS_BASETIME + 4] = std::uint8_t((time >> (4 * 8)) & 0x00ff); - m_data[OFFS_BASETIME + 5] = std::uint8_t((time >> (5 * 8)) & 0x00ff); - m_data[OFFS_BASETIME + 6] = std::uint8_t((time >> (6 * 8)) & 0x00ff); - m_data[OFFS_BASETIME + 7] = std::uint8_t((time >> (7 * 8)) & 0x00ff); + m_data[OFFS_BASETIME + 0] = u8((time >> (0 * 8)) & 0x00ff); + m_data[OFFS_BASETIME + 1] = u8((time >> (1 * 8)) & 0x00ff); + m_data[OFFS_BASETIME + 2] = u8((time >> (2 * 8)) & 0x00ff); + m_data[OFFS_BASETIME + 3] = u8((time >> (3 * 8)) & 0x00ff); + m_data[OFFS_BASETIME + 4] = u8((time >> (4 * 8)) & 0x00ff); + m_data[OFFS_BASETIME + 5] = u8((time >> (5 * 8)) & 0x00ff); + m_data[OFFS_BASETIME + 6] = u8((time >> (6 * 8)) & 0x00ff); + m_data[OFFS_BASETIME + 7] = u8((time >> (7 * 8)) & 0x00ff); } void set_version() { @@ -777,9 +777,9 @@ private: static constexpr std::size_t OFFS_APPDESC = 0x20; // 0x20 bytes (ASCII) static constexpr std::size_t OFFS_END = 0x40; - static std::uint8_t const MAGIC[OFFS_BASETIME - OFFS_MAGIC]; + static u8 const MAGIC[OFFS_BASETIME - OFFS_MAGIC]; - std::uint8_t m_data[OFFS_END]; + u8 m_data[OFFS_END]; }; @@ -811,7 +811,7 @@ public: input_type_entry *next() const { return m_next; } ioport_type type() const { return m_type; } ioport_group group() const { return m_group; } - uint8_t player() const { return m_player; } + u8 player() const { return m_player; } const char *token() const { return m_token; } const char *name() const { return m_name; } input_seq &defseq(input_seq_type seqtype = SEQ_TYPE_STANDARD) { return m_defseq[seqtype]; } @@ -826,7 +826,7 @@ private: input_type_entry * m_next; // next description in the list ioport_type m_type; // IPT_* for this entry ioport_group m_group; // which group the port belongs to - uint8_t m_player; // player number (0 is player 1) + u8 m_player; // player number (0 is player 1) const char * m_token; // token used to store settings const char * m_name; // user-friendly name input_seq m_defseq[SEQ_TYPE_TOTAL];// default input sequence @@ -854,10 +854,10 @@ public: }; // bit constants - static const uint8_t UP_BIT = 1 << JOYDIR_UP; - static const uint8_t DOWN_BIT = 1 << JOYDIR_DOWN; - static const uint8_t LEFT_BIT = 1 << JOYDIR_LEFT; - static const uint8_t RIGHT_BIT = 1 << JOYDIR_RIGHT; + static constexpr u8 UP_BIT = 1 << JOYDIR_UP; + static constexpr u8 DOWN_BIT = 1 << JOYDIR_DOWN; + static constexpr u8 LEFT_BIT = 1 << JOYDIR_LEFT; + static constexpr u8 RIGHT_BIT = 1 << JOYDIR_RIGHT; // construction/destruction digital_joystick(int player, int number); @@ -866,8 +866,8 @@ public: digital_joystick *next() const { return m_next; } int player() const { return m_player; } int number() const { return m_number; } - uint8_t current() const { return m_current; } - uint8_t current4way() const { return m_current4way; } + u8 current() const { return m_current; } + u8 current4way() const { return m_current4way; } // configuration direction_t add_axis(ioport_field &field); @@ -881,9 +881,9 @@ private: int m_player; // player number represented int m_number; // joystick number represented simple_list > m_field[JOYDIR_COUNT]; // potential input fields for each direction - uint8_t m_current; // current value - uint8_t m_current4way; // current 4-way value - uint8_t m_previous; // previous value + u8 m_current; // current value + u8 m_current4way; // current 4-way value + u8 m_previous; // previous value }; DECLARE_ENUM_OPERATORS(digital_joystick::direction_t) @@ -984,18 +984,18 @@ class ioport_diplocation public: // construction/destruction - ioport_diplocation(const char *name, uint8_t swnum, bool invert); + ioport_diplocation(const char *name, u8 swnum, bool invert); // getters ioport_diplocation *next() const { return m_next; } const char *name() const { return m_name.c_str(); } - uint8_t number() const { return m_number; } + u8 number() const { return m_number; } bool inverted() const { return m_invert; } private: ioport_diplocation * m_next; // pointer to the next bit std::string m_name; // name of the physical DIP switch - uint8_t m_number; // physical switch number + u8 m_number; // physical switch number bool m_invert; // is this an active-high DIP? }; @@ -1039,7 +1039,7 @@ public: ioport_value defvalue() const { return m_defvalue; } ioport_condition &condition() { return m_condition; } ioport_type type() const { return m_type; } - uint8_t player() const { return m_player; } + u8 player() const { return m_player; } bool digital_value() const { return m_digital_value; } void set_value(ioport_value value); @@ -1052,7 +1052,7 @@ public: bool analog_wraps() const { return ((m_flags & ANALOG_FLAG_WRAPS) != 0); } bool analog_invert() const { return ((m_flags & ANALOG_FLAG_INVERT) != 0); } - uint8_t impulse() const { return m_impulse; } + u8 impulse() const { return m_impulse; } const char *name() const; const char *specific_name() const { return m_name; } const input_seq &seq(input_seq_type seqtype = SEQ_TYPE_STANDARD) const; @@ -1063,16 +1063,16 @@ public: ioport_value minval() const { return m_min; } ioport_value maxval() const { return m_max; } - int32_t sensitivity() const { return m_sensitivity; } - int32_t delta() const { return m_delta; } - int32_t centerdelta() const { return m_centerdelta; } + s32 sensitivity() const { return m_sensitivity; } + s32 delta() const { return m_delta; } + s32 centerdelta() const { return m_centerdelta; } crosshair_axis_t crosshair_axis() const { return m_crosshair_axis; } double crosshair_scale() const { return m_crosshair_scale; } double crosshair_offset() const { return m_crosshair_offset; } - uint16_t full_turn_count() const { return m_full_turn_count; } + u16 full_turn_count() const { return m_full_turn_count; } const ioport_value *remap_table() const { return m_remap_table; } - uint8_t way() const { return m_way; } + u8 way() const { return m_way; } char32_t keyboard_code(int which) const; std::string key_name(int which) const; ioport_field_live &live() const { assert(m_live != nullptr); return *m_live; } @@ -1080,7 +1080,7 @@ public: // setters void set_crosshair_scale(double scale) { m_crosshair_scale = scale; } void set_crosshair_offset(double offset) { m_crosshair_offset = offset; } - void set_player(uint8_t player) { m_player = player; } + void set_player(u8 player) { m_player = player; } // derived getters ioport_type_class type_class() const; @@ -1105,9 +1105,9 @@ public: ioport_value value; // for DIP switches bool autofire; // for autofire settings input_seq seq[SEQ_TYPE_TOTAL]; // sequences of all types - int32_t sensitivity; // for analog controls - int32_t delta; // for analog controls - int32_t centerdelta; // for analog controls + s32 sensitivity; // for analog controls + s32 delta; // for analog controls + s32 centerdelta; // for analog controls bool reverse; // for analog controls bool toggle; // for non-analog controls }; @@ -1130,9 +1130,9 @@ private: ioport_value m_defvalue; // default value of these bits ioport_condition m_condition; // condition under which this field is relevant ioport_type m_type; // IPT_* type for this port - uint8_t m_player; // player number (0-based) - uint32_t m_flags; // combination of FIELD_FLAG_* and ANALOG_FLAG_* above - uint8_t m_impulse; // number of frames before reverting to defvalue + u8 m_player; // player number (0-based) + u32 m_flags; // combination of FIELD_FLAG_* and ANALOG_FLAG_* above + u8 m_impulse; // number of frames before reverting to defvalue const char * m_name; // user-friendly name to display input_seq m_seq[SEQ_TYPE_TOTAL];// sequences of all types ioport_field_read_delegate m_read; // read callback routine @@ -1146,20 +1146,20 @@ private: // data relevant to analog control types ioport_value m_min; // minimum value for absolute axes ioport_value m_max; // maximum value for absolute axes - int32_t m_sensitivity; // sensitivity (100=normal) - int32_t m_delta; // delta to apply each frame a digital inc/dec key is pressed - int32_t m_centerdelta; // delta to apply each frame no digital inputs are pressed + s32 m_sensitivity; // sensitivity (100=normal) + s32 m_delta; // delta to apply each frame a digital inc/dec key is pressed + s32 m_centerdelta; // delta to apply each frame no digital inputs are pressed crosshair_axis_t m_crosshair_axis; // crosshair axis double m_crosshair_scale; // crosshair scale double m_crosshair_offset; // crosshair offset double m_crosshair_altaxis;// crosshair alternate axis value ioport_field_crossmap_delegate m_crosshair_mapper; // crosshair mapping function - uint16_t m_full_turn_count; // number of optical counts for 1 full turn of the original control + u16 m_full_turn_count; // number of optical counts for 1 full turn of the original control const ioport_value * m_remap_table; // pointer to an array that remaps the port value // data relevant to other specific types - uint8_t m_way; // digital joystick 2/4/8-way descriptions - char32_t m_chars[4]; // unicode key data + u8 m_way; // digital joystick 2/4/8-way descriptions + char32_t m_chars[4]; // unicode key data }; @@ -1176,7 +1176,7 @@ struct ioport_field_live digital_joystick * joystick; // pointer to digital joystick information input_seq seq[SEQ_TYPE_TOTAL];// currently configured input sequences ioport_value value; // current value of this port - uint8_t impulse; // counter for impulse controls + u8 impulse; // counter for impulse controls bool last; // were we pressed last time? bool toggle; // current toggle setting digital_joystick::direction_t joydir; // digital joystick direction index @@ -1269,10 +1269,10 @@ public: analog_field *next() const { return m_next; } ioport_manager &manager() const { return m_field.manager(); } ioport_field &field() const { return m_field; } - int32_t sensitivity() const { return m_sensitivity; } + s32 sensitivity() const { return m_sensitivity; } bool reverse() const { return m_reverse; } - int32_t delta() const { return m_delta; } - int32_t centerdelta() const { return m_centerdelta; } + s32 delta() const { return m_delta; } + s32 centerdelta() const { return m_centerdelta; } // readers void read(ioport_value &value); @@ -1281,44 +1281,44 @@ public: private: // helpers - int32_t apply_min_max(int32_t value) const; - int32_t apply_settings(int32_t value) const; - int32_t apply_sensitivity(int32_t value) const; - int32_t apply_inverse_sensitivity(int32_t value) const; + s32 apply_min_max(s32 value) const; + s32 apply_settings(s32 value) const; + s32 apply_sensitivity(s32 value) const; + s32 apply_inverse_sensitivity(s32 value) const; // internal state analog_field * m_next; // link to the next analog state for this port ioport_field & m_field; // pointer to the input field referenced // adjusted values (right-justified and tweaked) - uint8_t m_shift; // shift to align final value in the port - int32_t m_adjdefvalue; // adjusted default value from the config - int32_t m_adjmin; // adjusted minimum value from the config - int32_t m_adjmax; // adjusted maximum value from the config + u8 m_shift; // shift to align final value in the port + s32 m_adjdefvalue; // adjusted default value from the config + s32 m_adjmin; // adjusted minimum value from the config + s32 m_adjmax; // adjusted maximum value from the config // live values of configurable parameters - int32_t m_sensitivity; // current live sensitivity (100=normal) + s32 m_sensitivity; // current live sensitivity (100=normal) bool m_reverse; // current live reverse flag - int32_t m_delta; // current live delta to apply each frame a digital inc/dec key is pressed - int32_t m_centerdelta; // current live delta to apply each frame no digital inputs are pressed + s32 m_delta; // current live delta to apply each frame a digital inc/dec key is pressed + s32 m_centerdelta; // current live delta to apply each frame no digital inputs are pressed // live analog value tracking - int32_t m_accum; // accumulated value (including relative adjustments) - int32_t m_previous; // previous adjusted value - int32_t m_previousanalog; // previous analog value + s32 m_accum; // accumulated value (including relative adjustments) + s32 m_previous; // previous adjusted value + s32 m_previousanalog; // previous analog value // parameters for modifying live values - int32_t m_minimum; // minimum adjusted value - int32_t m_maximum; // maximum adjusted value - int32_t m_center; // center adjusted value for autocentering - int32_t m_reverse_val; // value where we subtract from to reverse directions + s32 m_minimum; // minimum adjusted value + s32 m_maximum; // maximum adjusted value + s32 m_center; // center adjusted value for autocentering + s32 m_reverse_val; // value where we subtract from to reverse directions // scaling factors - int64_t m_scalepos; // scale factor to apply to positive adjusted values - int64_t m_scaleneg; // scale factor to apply to negative adjusted values - int64_t m_keyscalepos; // scale factor to apply to the key delta field when pos - int64_t m_keyscaleneg; // scale factor to apply to the key delta field when neg - int64_t m_positionalscale; // scale factor to divide a joystick into positions + s64 m_scalepos; // scale factor to apply to positive adjusted values + s64 m_scaleneg; // scale factor to apply to negative adjusted values + s64 m_keyscalepos; // scale factor to apply to the key delta field when pos + s64 m_keyscaleneg; // scale factor to apply to the key delta field when neg + s64 m_positionalscale; // scale factor to divide a joystick into positions // misc flags bool m_absolute; // is this an absolute or relative input? @@ -1353,7 +1353,7 @@ private: // internal state dynamic_field * m_next; // linked list of info for this port ioport_field & m_field; // reference to the input field - uint8_t m_shift; // shift to apply to the final result + u8 m_shift; // shift to apply to the final result ioport_value m_oldval; // last value }; @@ -1402,7 +1402,7 @@ public: // type helpers const simple_list &types() const { return m_typelist; } bool type_pressed(ioport_type type, int player = 0); - const char *type_name(ioport_type type, uint8_t player); + const char *type_name(ioport_type type, u8 player); ioport_group type_group(ioport_type type, int player); const input_seq &type_seq(ioport_type type, int player = 0, input_seq_type seqtype = SEQ_TYPE_STANDARD); void set_type_seq(ioport_type type, int player, input_seq_type seqtype, const input_seq &newseq); @@ -1413,7 +1413,7 @@ public: digital_joystick &digjoystick(int player, int joysticknum); int count_players() const; bool crosshair_position(int player, float &x, float &y); - int32_t frame_interpolate(int32_t oldval, int32_t newval); + s32 frame_interpolate(s32 oldval, s32 newval); ioport_type token_to_input_type(const char *string, int &player) const; std::string input_type_to_token(ioport_type type, int player); @@ -1483,8 +1483,8 @@ private: // playback/record information emu_file m_record_file; // recording file (nullptr if not recording) emu_file m_playback_file; // playback file (nullptr if not recording) - uint64_t m_playback_accumulated_speed; // accumulated speed during playback - uint32_t m_playback_accumulated_frames; // accumulated frames during playback + u64 m_playback_accumulated_speed; // accumulated speed during playback + u32 m_playback_accumulated_frames; // accumulated frames during playback emu_file m_timecode_file; // timecode/frames playback file (nullptr if not recording) int m_timecode_count; attotime m_timecode_last_time; @@ -1521,17 +1521,17 @@ public: ioport_configurer& field_set_player(int player) { m_curfield->m_player = player - 1; return *this; } ioport_configurer& field_set_cocktail() { m_curfield->m_flags |= ioport_field::FIELD_FLAG_COCKTAIL; field_set_player(2); return *this; } ioport_configurer& field_set_toggle() { m_curfield->m_flags |= ioport_field::FIELD_FLAG_TOGGLE; return *this; } - ioport_configurer& field_set_impulse(uint8_t impulse) { m_curfield->m_impulse = impulse; return *this; } + ioport_configurer& field_set_impulse(u8 impulse) { m_curfield->m_impulse = impulse; return *this; } ioport_configurer& field_set_analog_reverse() { m_curfield->m_flags |= ioport_field::ANALOG_FLAG_REVERSE; return *this; } ioport_configurer& field_set_analog_reset() { m_curfield->m_flags |= ioport_field::ANALOG_FLAG_RESET; return *this; } ioport_configurer& field_set_optional() { m_curfield->m_flags |= ioport_field::FIELD_FLAG_OPTIONAL; return *this; } ioport_configurer& field_set_min_max(ioport_value minval, ioport_value maxval) { m_curfield->m_min = minval; m_curfield->m_max = maxval; return *this; } - ioport_configurer& field_set_sensitivity(int32_t sensitivity) { m_curfield->m_sensitivity = sensitivity; return *this; } - ioport_configurer& field_set_delta(int32_t delta) { m_curfield->m_centerdelta = m_curfield->m_delta = delta; return *this; } - ioport_configurer& field_set_centerdelta(int32_t delta) { m_curfield->m_centerdelta = delta; return *this; } + ioport_configurer& field_set_sensitivity(s32 sensitivity) { m_curfield->m_sensitivity = sensitivity; return *this; } + ioport_configurer& field_set_delta(s32 delta) { m_curfield->m_centerdelta = m_curfield->m_delta = delta; return *this; } + ioport_configurer& field_set_centerdelta(s32 delta) { m_curfield->m_centerdelta = delta; return *this; } ioport_configurer& field_set_crosshair(crosshair_axis_t axis, double altaxis, double scale, double offset) { m_curfield->m_crosshair_axis = axis; m_curfield->m_crosshair_altaxis = altaxis; m_curfield->m_crosshair_scale = scale; m_curfield->m_crosshair_offset = offset; return *this; } ioport_configurer& field_set_crossmapper(ioport_field_crossmap_delegate callback) { m_curfield->m_crosshair_mapper = callback; return *this; } - ioport_configurer& field_set_full_turn_count(uint16_t count) { m_curfield->m_full_turn_count = count; return *this; } + ioport_configurer& field_set_full_turn_count(u16 count) { m_curfield->m_full_turn_count = count; return *this; } ioport_configurer& field_set_analog_wraps() { m_curfield->m_flags |= ioport_field::ANALOG_FLAG_WRAPS; return *this; } ioport_configurer& field_set_remap_table(const ioport_value *table) { m_curfield->m_remap_table = table; return *this; } ioport_configurer& field_set_analog_invert() { m_curfield->m_flags |= ioport_field::ANALOG_FLAG_INVERT; return *this; } @@ -1822,4 +1822,4 @@ inline device_t &ioport_setting::device() const { return m_field.device(); } inline running_machine &ioport_setting::machine() const { return m_field.machine(); } -#endif // __INPTPORT_H__ */ +#endif // MAME_EMU_IOPORT_H */ diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 5815dd9115a..91999a8307e 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -817,7 +817,7 @@ void running_machine::set_rtc_datetime(const system_time &systime) // rand - standardized random numbers //------------------------------------------------- -uint32_t running_machine::rand() +u32 running_machine::rand() { m_rand_seed = 1664525 * m_rand_seed + 1013904223; @@ -863,7 +863,7 @@ void running_machine::handle_saveload() } else { - uint32_t const openflags = (m_saveload_schedule == SLS_LOAD) ? OPEN_FLAG_READ : (OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); + u32 const openflags = (m_saveload_schedule == SLS_LOAD) ? OPEN_FLAG_READ : (OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); // open the file emu_file file(m_saveload_searchpath, openflags); @@ -927,7 +927,7 @@ void running_machine::handle_saveload() // of the system //------------------------------------------------- -void running_machine::soft_reset(void *ptr, int32_t param) +void running_machine::soft_reset(void *ptr, s32 param) { logerror("Soft reset\n"); @@ -1249,7 +1249,7 @@ ADDRESS_MAP_END const device_type DUMMY_SPACE = &device_creator; -dummy_space_device::dummy_space_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : +dummy_space_device::dummy_space_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, DUMMY_SPACE, "Dummy Space", tag, owner, clock, "dummy_space", __FILE__), device_memory_interface(mconfig, *this), m_space_config("dummy", ENDIANNESS_LITTLE, 8, 32, 0, nullptr, *ADDRESS_MAP_NAME(dummy)) diff --git a/src/emu/machine.h b/src/emu/machine.h index 6f9e26b24f5..cac9a3f38b6 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __MACHINE_H__ -#define __MACHINE_H__ +#ifndef MAME_EMU_MACHINE_H +#define MAME_EMU_MACHINE_H #include @@ -114,18 +114,18 @@ public: { void set(struct tm &t); - uint8_t second; // seconds (0-59) - uint8_t minute; // minutes (0-59) - uint8_t hour; // hours (0-23) - uint8_t mday; // day of month (1-31) - uint8_t month; // month (0-11) - int32_t year; // year (1=1 AD) - uint8_t weekday; // day of week (0-6) - uint16_t day; // day of year (0-365) - uint8_t is_dst; // is this daylight savings? + u8 second; // seconds (0-59) + u8 minute; // minutes (0-59) + u8 hour; // hours (0-23) + u8 mday; // day of month (1-31) + u8 month; // month (0-11) + s32 year; // year (1=1 AD) + u8 weekday; // day of week (0-6) + u16 day; // day of year (0-365) + u8 is_dst; // is this daylight savings? }; - int64_t time; // number of seconds elapsed since midnight, January 1 1970 UTC + s64 time; // number of seconds elapsed since midnight, January 1 1970 UTC full_time local_time; // local time full_time utc_time; // UTC coordinated time }; @@ -140,7 +140,7 @@ class dummy_space_device : public device_t, public device_memory_interface { public: - dummy_space_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + dummy_space_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); DECLARE_READ8_MEMBER(read); DECLARE_WRITE8_MEMBER(write); @@ -262,7 +262,7 @@ public: template void popmessage(Format &&fmt, Params &&... args) const; template void logerror(Format &&fmt, Params &&... args) const; void strlog(const char *str) const; - uint32_t rand(); + u32 rand(); const char *describe_context(); std::string compose_saveload_filename(const char *base_filename, const char **searchpath = nullptr); @@ -275,7 +275,7 @@ private: public: // debugger-related information - uint32_t debug_flags; // the current debug flags + u32 debug_flags; // the current debug flags private: // internal helpers @@ -285,7 +285,7 @@ private: void set_saveload_filename(const char *filename); std::string get_statename(const char *statename_opt) const; void handle_saveload(); - void soft_reset(void *ptr = nullptr, int32_t param = 0); + void soft_reset(void *ptr = nullptr, s32 param = 0); std::string nvram_filename(device_t &device) const; void nvram_load(); void nvram_save(); @@ -332,7 +332,7 @@ private: emu_timer * m_soft_reset_timer; // timer used to schedule a soft reset // misc state - uint32_t m_rand_seed; // current random number seed + u32 m_rand_seed; // current random number seed bool m_ui_active; // ui active or not (useful for games / systems with keyboard inputs) time_t m_base_time; // real time at initial emulation time std::string m_basename; // basename used for game-related paths @@ -436,4 +436,4 @@ inline void running_machine::logerror(Format &&fmt, Params &&... args) const } } -#endif /* __MACHINE_H__ */ +#endif /* MAME_EMU_MACHINE_H */ diff --git a/src/emu/main.h b/src/emu/main.h index efb5896f099..7b753dd167f 100644 --- a/src/emu/main.h +++ b/src/emu/main.h @@ -13,8 +13,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __MAIN_H__ -#define __MAIN_H__ +#ifndef MAME_EMU_MAIN_H +#define MAME_EMU_MAIN_H #include @@ -94,4 +94,4 @@ protected: }; -#endif /* __MAIN_H__ */ +#endif /* MAME_EMU_MAIN_H */ diff --git a/src/emu/mconfig.cpp b/src/emu/mconfig.cpp index 96ca495aa5a..0eb4532e543 100644 --- a/src/emu/mconfig.cpp +++ b/src/emu/mconfig.cpp @@ -103,7 +103,7 @@ screen_device *machine_config::first_screen() const // new device //------------------------------------------------- -device_t *machine_config::device_add(device_t *owner, const char *tag, device_type type, uint32_t clock) +device_t *machine_config::device_add(device_t *owner, const char *tag, device_type type, u32 clock) { const char *orig_tag = tag; @@ -149,7 +149,7 @@ device_t *machine_config::device_add(device_t *owner, const char *tag, device_ty // replace one device with a new device //------------------------------------------------- -device_t *machine_config::device_replace(device_t *owner, const char *tag, device_type type, uint32_t clock) +device_t *machine_config::device_replace(device_t *owner, const char *tag, device_type type, u32 clock) { // find the original device by relative tag (must exist) assert(owner != nullptr); diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h index 19f4e6faf91..8a3774b8725 100644 --- a/src/emu/mconfig.h +++ b/src/emu/mconfig.h @@ -15,8 +15,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __MCONFIG_H__ -#define __MCONFIG_H__ +#ifndef MAME_EMU_MCONFIG_H +#define MAME_EMU_MCONFIG_H //************************************************************************** // CONSTANTS @@ -38,8 +38,8 @@ struct internal_layout { size_t decompressed_size; size_t compressed_size; - uint8_t compression_type; - const uint8_t* data; + u8 compression_type; + const u8* data; }; @@ -73,8 +73,8 @@ public: const internal_layout * m_default_layout; // default layout for this machine // helpers during configuration; not for general use - device_t *device_add(device_t *owner, const char *tag, device_type type, uint32_t clock); - device_t *device_replace(device_t *owner, const char *tag, device_type type, uint32_t clock); + device_t *device_add(device_t *owner, const char *tag, device_type type, u32 clock); + device_t *device_replace(device_t *owner, const char *tag, device_type type, u32 clock); device_t *device_remove(device_t *owner, const char *tag); device_t *device_find(device_t *owner, const char *tag); @@ -211,5 +211,5 @@ References an external machine config. #define MCFG_DEVICE_MODIFY(_tag) \ device = config.device_find(owner, _tag); -#endif /* __MCONFIG_H__ */ - /** @} */ +#endif /* MAME_EMU_MCONFIG_H */ +/** @} */ diff --git a/src/emu/memarray.cpp b/src/emu/memarray.cpp index c1e615776e2..50bd270fd4f 100644 --- a/src/emu/memarray.cpp +++ b/src/emu/memarray.cpp @@ -35,7 +35,7 @@ memory_array::memory_array() // set - configure the parameters //------------------------------------------------- -void memory_array::set(void *base, uint32_t bytes, int membits, endianness_t endianness, int bpe) +void memory_array::set(void *base, u32 bytes, int membits, endianness_t endianness, int bpe) { // validate inputs assert(base != nullptr); @@ -89,7 +89,7 @@ void memory_array::set(void *base, uint32_t bytes, int membits, endianness_t end // set - additional setter variants //------------------------------------------------- -void memory_array::set(const address_space &space, void *base, uint32_t bytes, int bpe) +void memory_array::set(const address_space &space, void *base, u32 bytes, int bpe) { set(base, bytes, space.data_width(), space.endianness(), bpe); } @@ -125,23 +125,23 @@ void memory_array::set_endianness(endianness_t endianness) // heleprs for 1 byte-per-entry //------------------------------------------------- -uint32_t memory_array::read8_from_8(int index) const { return reinterpret_cast(m_base)[index]; } -void memory_array::write8_to_8(int index, uint32_t data) { reinterpret_cast(m_base)[index] = data; } +u32 memory_array::read8_from_8(int index) const { return reinterpret_cast(m_base)[index]; } +void memory_array::write8_to_8(int index, u32 data) { reinterpret_cast(m_base)[index] = data; } -uint32_t memory_array::read8_from_16le(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_LE(index)]; } -void memory_array::write8_to_16le(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE_XOR_LE(index)] = data; } -uint32_t memory_array::read8_from_16be(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_BE(index)]; } -void memory_array::write8_to_16be(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE_XOR_BE(index)] = data; } +u32 memory_array::read8_from_16le(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_LE(index)]; } +void memory_array::write8_to_16le(int index, u32 data) { reinterpret_cast(m_base)[BYTE_XOR_LE(index)] = data; } +u32 memory_array::read8_from_16be(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_BE(index)]; } +void memory_array::write8_to_16be(int index, u32 data) { reinterpret_cast(m_base)[BYTE_XOR_BE(index)] = data; } -uint32_t memory_array::read8_from_32le(int index) const { return reinterpret_cast(m_base)[BYTE4_XOR_LE(index)]; } -void memory_array::write8_to_32le(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE4_XOR_LE(index)] = data; } -uint32_t memory_array::read8_from_32be(int index) const { return reinterpret_cast(m_base)[BYTE4_XOR_BE(index)]; } -void memory_array::write8_to_32be(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE4_XOR_BE(index)] = data; } +u32 memory_array::read8_from_32le(int index) const { return reinterpret_cast(m_base)[BYTE4_XOR_LE(index)]; } +void memory_array::write8_to_32le(int index, u32 data) { reinterpret_cast(m_base)[BYTE4_XOR_LE(index)] = data; } +u32 memory_array::read8_from_32be(int index) const { return reinterpret_cast(m_base)[BYTE4_XOR_BE(index)]; } +void memory_array::write8_to_32be(int index, u32 data) { reinterpret_cast(m_base)[BYTE4_XOR_BE(index)] = data; } -uint32_t memory_array::read8_from_64le(int index) const { return reinterpret_cast(m_base)[BYTE8_XOR_BE(index)]; } -void memory_array::write8_to_64le(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE8_XOR_BE(index)] = data; } -uint32_t memory_array::read8_from_64be(int index) const { return reinterpret_cast(m_base)[BYTE8_XOR_BE(index)]; } -void memory_array::write8_to_64be(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE8_XOR_BE(index)] = data; } +u32 memory_array::read8_from_64le(int index) const { return reinterpret_cast(m_base)[BYTE8_XOR_BE(index)]; } +void memory_array::write8_to_64le(int index, u32 data) { reinterpret_cast(m_base)[BYTE8_XOR_BE(index)] = data; } +u32 memory_array::read8_from_64be(int index) const { return reinterpret_cast(m_base)[BYTE8_XOR_BE(index)]; } +void memory_array::write8_to_64be(int index, u32 data) { reinterpret_cast(m_base)[BYTE8_XOR_BE(index)] = data; } //------------------------------------------------- @@ -149,23 +149,23 @@ void memory_array::write8_to_64be(int index, uint32_t data) { reinterpret_cast> 8); } -uint32_t memory_array::read16_from_8be(int index) const { return (read8_from_8(index*2) << 8) | read8_from_8(index*2+1); } -void memory_array::write16_to_8be(int index, uint32_t data) { write8_to_8(index*2, data >> 8); write8_to_8(index*2+1, data); } +u32 memory_array::read16_from_8le(int index) const { return read8_from_8(index*2) | (read8_from_8(index*2+1) << 8); } +void memory_array::write16_to_8le(int index, u32 data) { write8_to_8(index*2, data); write8_to_8(index*2+1, data >> 8); } +u32 memory_array::read16_from_8be(int index) const { return (read8_from_8(index*2) << 8) | read8_from_8(index*2+1); } +void memory_array::write16_to_8be(int index, u32 data) { write8_to_8(index*2, data >> 8); write8_to_8(index*2+1, data); } -uint32_t memory_array::read16_from_16(int index) const { return reinterpret_cast(m_base)[index]; } -void memory_array::write16_to_16(int index, uint32_t data) { reinterpret_cast(m_base)[index] = data; } +u32 memory_array::read16_from_16(int index) const { return reinterpret_cast(m_base)[index]; } +void memory_array::write16_to_16(int index, u32 data) { reinterpret_cast(m_base)[index] = data; } -uint32_t memory_array::read16_from_32le(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_LE(index)]; } -void memory_array::write16_to_32le(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE_XOR_LE(index)] = data; } -uint32_t memory_array::read16_from_32be(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_BE(index)]; } -void memory_array::write16_to_32be(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE_XOR_BE(index)] = data; } +u32 memory_array::read16_from_32le(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_LE(index)]; } +void memory_array::write16_to_32le(int index, u32 data) { reinterpret_cast(m_base)[BYTE_XOR_LE(index)] = data; } +u32 memory_array::read16_from_32be(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_BE(index)]; } +void memory_array::write16_to_32be(int index, u32 data) { reinterpret_cast(m_base)[BYTE_XOR_BE(index)] = data; } -uint32_t memory_array::read16_from_64le(int index) const { return reinterpret_cast(m_base)[BYTE4_XOR_LE(index)]; } -void memory_array::write16_to_64le(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE4_XOR_LE(index)] = data; } -uint32_t memory_array::read16_from_64be(int index) const { return reinterpret_cast(m_base)[BYTE4_XOR_BE(index)]; } -void memory_array::write16_to_64be(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE4_XOR_BE(index)] = data; } +u32 memory_array::read16_from_64le(int index) const { return reinterpret_cast(m_base)[BYTE4_XOR_LE(index)]; } +void memory_array::write16_to_64le(int index, u32 data) { reinterpret_cast(m_base)[BYTE4_XOR_LE(index)] = data; } +u32 memory_array::read16_from_64be(int index) const { return reinterpret_cast(m_base)[BYTE4_XOR_BE(index)]; } +void memory_array::write16_to_64be(int index, u32 data) { reinterpret_cast(m_base)[BYTE4_XOR_BE(index)] = data; } //------------------------------------------------- @@ -173,20 +173,20 @@ void memory_array::write16_to_64be(int index, uint32_t data) { reinterpret_cast< // heleprs for 4 bytes-per-entry //------------------------------------------------- -uint32_t memory_array::read32_from_8le(int index) const { return read16_from_8le(index*2) | (read16_from_8le(index*2+1) << 16); } -void memory_array::write32_to_8le(int index, uint32_t data) { write16_to_8le(index*2, data); write16_to_8le(index*2+1, data >> 16); } -uint32_t memory_array::read32_from_8be(int index) const { return (read16_from_8be(index*2) << 16) | read16_from_8be(index*2+1); } -void memory_array::write32_to_8be(int index, uint32_t data) { write16_to_8be(index*2, data >> 16); write16_to_8be(index*2+1, data); } +u32 memory_array::read32_from_8le(int index) const { return read16_from_8le(index*2) | (read16_from_8le(index*2+1) << 16); } +void memory_array::write32_to_8le(int index, u32 data) { write16_to_8le(index*2, data); write16_to_8le(index*2+1, data >> 16); } +u32 memory_array::read32_from_8be(int index) const { return (read16_from_8be(index*2) << 16) | read16_from_8be(index*2+1); } +void memory_array::write32_to_8be(int index, u32 data) { write16_to_8be(index*2, data >> 16); write16_to_8be(index*2+1, data); } -uint32_t memory_array::read32_from_16le(int index) const { return read16_from_16(index*2) | (read16_from_16(index*2+1) << 16); } -void memory_array::write32_to_16le(int index, uint32_t data) { write16_to_16(index*2, data); write16_to_16(index*2+1, data >> 16); } -uint32_t memory_array::read32_from_16be(int index) const { return (read16_from_16(index*2) << 16) | read16_from_16(index*2+1); } -void memory_array::write32_to_16be(int index, uint32_t data) { write16_to_16(index*2, data >> 16); write16_to_16(index*2+1, data); } +u32 memory_array::read32_from_16le(int index) const { return read16_from_16(index*2) | (read16_from_16(index*2+1) << 16); } +void memory_array::write32_to_16le(int index, u32 data) { write16_to_16(index*2, data); write16_to_16(index*2+1, data >> 16); } +u32 memory_array::read32_from_16be(int index) const { return (read16_from_16(index*2) << 16) | read16_from_16(index*2+1); } +void memory_array::write32_to_16be(int index, u32 data) { write16_to_16(index*2, data >> 16); write16_to_16(index*2+1, data); } -uint32_t memory_array::read32_from_32(int index) const { return reinterpret_cast(m_base)[index]; } -void memory_array::write32_to_32(int index, uint32_t data) { reinterpret_cast(m_base)[index] = data; } +u32 memory_array::read32_from_32(int index) const { return reinterpret_cast(m_base)[index]; } +void memory_array::write32_to_32(int index, u32 data) { reinterpret_cast(m_base)[index] = data; } -uint32_t memory_array::read32_from_64le(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_LE(index)]; } -void memory_array::write32_to_64le(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE_XOR_LE(index)] = data; } -uint32_t memory_array::read32_from_64be(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_BE(index)]; } -void memory_array::write32_to_64be(int index, uint32_t data) { reinterpret_cast(m_base)[BYTE_XOR_BE(index)] = data; } +u32 memory_array::read32_from_64le(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_LE(index)]; } +void memory_array::write32_to_64le(int index, u32 data) { reinterpret_cast(m_base)[BYTE_XOR_LE(index)] = data; } +u32 memory_array::read32_from_64be(int index) const { return reinterpret_cast(m_base)[BYTE_XOR_BE(index)]; } +void memory_array::write32_to_64be(int index, u32 data) { reinterpret_cast(m_base)[BYTE_XOR_BE(index)] = data; } diff --git a/src/emu/memarray.h b/src/emu/memarray.h index fc6556b5389..d7bbd51df1c 100644 --- a/src/emu/memarray.h +++ b/src/emu/memarray.h @@ -27,8 +27,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __MEMARRAY_H__ -#define __MEMARRAY_H__ +#ifndef MAME_EMU_MEMARRAY_H +#define MAME_EMU_MEMARRAY_H //************************************************************************** @@ -44,16 +44,16 @@ class memory_array public: // construction/destruction memory_array(); - memory_array(void *base, uint32_t bytes, int membits, endianness_t endianness, int bpe) { set(base, bytes, membits, endianness, bpe); } + memory_array(void *base, u32 bytes, int membits, endianness_t endianness, int bpe) { set(base, bytes, membits, endianness, bpe); } template memory_array(std::vector<_Type> &array, endianness_t endianness, int bpe) { set(array, endianness, bpe); } - memory_array(const address_space &space, void *base, uint32_t bytes, int bpe) { set(space, base, bytes, bpe); } + memory_array(const address_space &space, void *base, u32 bytes, int bpe) { set(space, base, bytes, bpe); } memory_array(const memory_share &share, int bpe) { set(share, bpe); } memory_array(const memory_array &array) { set(array); } // configuration - void set(void *base, uint32_t bytes, int membits, endianness_t endianness, int bpe); + void set(void *base, u32 bytes, int membits, endianness_t endianness, int bpe); template void set(std::vector<_Type> &array, endianness_t endianness, int bpe) { set(&array[0], array.size(), 8*sizeof(_Type), endianness, bpe); } - void set(const address_space &space, void *base, uint32_t bytes, int bpe); + void set(const address_space &space, void *base, u32 bytes, int bpe); void set(const memory_share &share, int bpe); void set(const memory_array &array); @@ -63,63 +63,63 @@ public: // getters void *base() const { return m_base; } - uint32_t bytes() const { return m_bytes; } + u32 bytes() const { return m_bytes; } int membits() const { return m_membits; } endianness_t endianness() const { return m_endianness; } int bytes_per_entry() const { return m_bytes_per_entry; } // entry-level readers and writers - uint32_t read(int index) const { return (this->*m_read_entry)(index); } - void write(int index, uint32_t data) { (this->*m_write_entry)(index, data); } + u32 read(int index) const { return (this->*m_read_entry)(index); } + void write(int index, u32 data) { (this->*m_write_entry)(index, data); } // byte/word/dword-level readers and writers - uint8_t read8(offs_t offset) const { return reinterpret_cast(m_base)[offset]; } - uint16_t read16(offs_t offset) const { return reinterpret_cast(m_base)[offset]; } - uint32_t read32(offs_t offset) const { return reinterpret_cast(m_base)[offset]; } - uint64_t read64(offs_t offset) const { return reinterpret_cast(m_base)[offset]; } - void write8(offs_t offset, uint8_t data) { reinterpret_cast(m_base)[offset] = data; } - void write16(offs_t offset, uint16_t data, uint16_t mem_mask = 0xffff) { COMBINE_DATA(&reinterpret_cast(m_base)[offset]); } - void write32(offs_t offset, uint32_t data, uint32_t mem_mask = 0xffffffff) { COMBINE_DATA(&reinterpret_cast(m_base)[offset]); } - void write64(offs_t offset, uint64_t data, uint64_t mem_mask = U64(0xffffffffffffffff)) { COMBINE_DATA(&reinterpret_cast(m_base)[offset]); } + u8 read8(offs_t offset) const { return reinterpret_cast(m_base)[offset]; } + u16 read16(offs_t offset) const { return reinterpret_cast(m_base)[offset]; } + u32 read32(offs_t offset) const { return reinterpret_cast(m_base)[offset]; } + u64 read64(offs_t offset) const { return reinterpret_cast(m_base)[offset]; } + void write8(offs_t offset, u8 data) { reinterpret_cast(m_base)[offset] = data; } + void write16(offs_t offset, u16 data, u16 mem_mask = 0xffff) { COMBINE_DATA(&reinterpret_cast(m_base)[offset]); } + void write32(offs_t offset, u32 data, u32 mem_mask = 0xffffffff) { COMBINE_DATA(&reinterpret_cast(m_base)[offset]); } + void write64(offs_t offset, u64 data, u64 mem_mask = 0xffffffffffffffffU) { COMBINE_DATA(&reinterpret_cast(m_base)[offset]); } private: // internal read/write helpers for 1 byte entries - uint32_t read8_from_8(int index) const; void write8_to_8(int index, uint32_t data); - uint32_t read8_from_16le(int index) const; void write8_to_16le(int index, uint32_t data); - uint32_t read8_from_16be(int index) const; void write8_to_16be(int index, uint32_t data); - uint32_t read8_from_32le(int index) const; void write8_to_32le(int index, uint32_t data); - uint32_t read8_from_32be(int index) const; void write8_to_32be(int index, uint32_t data); - uint32_t read8_from_64le(int index) const; void write8_to_64le(int index, uint32_t data); - uint32_t read8_from_64be(int index) const; void write8_to_64be(int index, uint32_t data); + u32 read8_from_8(int index) const; void write8_to_8(int index, u32 data); + u32 read8_from_16le(int index) const; void write8_to_16le(int index, u32 data); + u32 read8_from_16be(int index) const; void write8_to_16be(int index, u32 data); + u32 read8_from_32le(int index) const; void write8_to_32le(int index, u32 data); + u32 read8_from_32be(int index) const; void write8_to_32be(int index, u32 data); + u32 read8_from_64le(int index) const; void write8_to_64le(int index, u32 data); + u32 read8_from_64be(int index) const; void write8_to_64be(int index, u32 data); // internal read/write helpers for 2 byte entries - uint32_t read16_from_8le(int index) const; void write16_to_8le(int index, uint32_t data); - uint32_t read16_from_8be(int index) const; void write16_to_8be(int index, uint32_t data); - uint32_t read16_from_16(int index) const; void write16_to_16(int index, uint32_t data); - uint32_t read16_from_32le(int index) const; void write16_to_32le(int index, uint32_t data); - uint32_t read16_from_32be(int index) const; void write16_to_32be(int index, uint32_t data); - uint32_t read16_from_64le(int index) const; void write16_to_64le(int index, uint32_t data); - uint32_t read16_from_64be(int index) const; void write16_to_64be(int index, uint32_t data); + u32 read16_from_8le(int index) const; void write16_to_8le(int index, u32 data); + u32 read16_from_8be(int index) const; void write16_to_8be(int index, u32 data); + u32 read16_from_16(int index) const; void write16_to_16(int index, u32 data); + u32 read16_from_32le(int index) const; void write16_to_32le(int index, u32 data); + u32 read16_from_32be(int index) const; void write16_to_32be(int index, u32 data); + u32 read16_from_64le(int index) const; void write16_to_64le(int index, u32 data); + u32 read16_from_64be(int index) const; void write16_to_64be(int index, u32 data); // internal read/write helpers for 4 byte entries - uint32_t read32_from_8le(int index) const; void write32_to_8le(int index, uint32_t data); - uint32_t read32_from_8be(int index) const; void write32_to_8be(int index, uint32_t data); - uint32_t read32_from_16le(int index) const; void write32_to_16le(int index, uint32_t data); - uint32_t read32_from_16be(int index) const; void write32_to_16be(int index, uint32_t data); - uint32_t read32_from_32(int index) const; void write32_to_32(int index, uint32_t data); - uint32_t read32_from_64le(int index) const; void write32_to_64le(int index, uint32_t data); - uint32_t read32_from_64be(int index) const; void write32_to_64be(int index, uint32_t data); + u32 read32_from_8le(int index) const; void write32_to_8le(int index, u32 data); + u32 read32_from_8be(int index) const; void write32_to_8be(int index, u32 data); + u32 read32_from_16le(int index) const; void write32_to_16le(int index, u32 data); + u32 read32_from_16be(int index) const; void write32_to_16be(int index, u32 data); + u32 read32_from_32(int index) const; void write32_to_32(int index, u32 data); + u32 read32_from_64le(int index) const; void write32_to_64le(int index, u32 data); + u32 read32_from_64be(int index) const; void write32_to_64be(int index, u32 data); // internal state void * m_base; - uint32_t m_bytes; + u32 m_bytes; int m_membits; endianness_t m_endianness; int m_bytes_per_entry; - uint32_t (memory_array::*m_read_entry)(int) const; - void (memory_array::*m_write_entry)(int, uint32_t); + u32 (memory_array::*m_read_entry)(int) const; + void (memory_array::*m_write_entry)(int, u32); }; -#endif // __MEMARRAY_H__ +#endif // MAME_EMU_MEMARRAY_H diff --git a/src/emu/natkeyboard.h b/src/emu/natkeyboard.h index 4cbdd04eab5..74bc9ac72d5 100644 --- a/src/emu/natkeyboard.h +++ b/src/emu/natkeyboard.h @@ -75,19 +75,19 @@ private: const keycode_map_entry *find_code(char32_t ch) const; // internal state - running_machine & m_machine; // reference to our machine - bool m_in_use; // is natural keyboard in use? - uint32_t m_bufbegin; // index of starting character - uint32_t m_bufend; // index of ending character - std::vector m_buffer; // actual buffer - bool m_status_keydown; // current keydown status - bool m_last_cr; // was the last char a CR? - emu_timer * m_timer; // timer for posting characters - attotime m_current_rate; // current rate for posting - ioport_queue_chars_delegate m_queue_chars; // queue characters callback - ioport_accept_char_delegate m_accept_char; // accept character callback - ioport_charqueue_empty_delegate m_charqueue_empty; // character queue empty callback - std::vector m_keycode_map; // keycode map + running_machine & m_machine; // reference to our machine + bool m_in_use; // is natural keyboard in use? + u32 m_bufbegin; // index of starting character + u32 m_bufend; // index of ending character + std::vector m_buffer; // actual buffer + bool m_status_keydown; // current keydown status + bool m_last_cr; // was the last char a CR? + emu_timer * m_timer; // timer for posting characters + attotime m_current_rate; // current rate for posting + ioport_queue_chars_delegate m_queue_chars; // queue characters callback + ioport_accept_char_delegate m_accept_char; // accept character callback + ioport_charqueue_empty_delegate m_charqueue_empty; // character queue empty callback + std::vector m_keycode_map; // keycode map }; #endif diff --git a/src/emu/network.cpp b/src/emu/network.cpp index ec1a876e117..8239949c958 100644 --- a/src/emu/network.cpp +++ b/src/emu/network.cpp @@ -84,7 +84,7 @@ void network_manager::config_save(config_type cfg_type, xml_data_node *parentnod node->set_attribute_int("interface", network.get_interface()); const char *mac = network.get_mac(); char mac_addr[6 * 3]; - sprintf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x", (uint8_t)mac[0], (uint8_t)mac[1], (uint8_t)mac[2], (uint8_t)mac[3], (uint8_t)mac[4], (uint8_t)mac[5]); + sprintf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x", u8(mac[0]), u8(mac[1]), u8(mac[2]), u8(mac[3]), u8(mac[4]), u8(mac[5])); node->set_attribute("mac", mac_addr); } } diff --git a/src/emu/output.cpp b/src/emu/output.cpp index 60489cae11e..d2ccf9d8cda 100644 --- a/src/emu/output.cpp +++ b/src/emu/output.cpp @@ -50,7 +50,7 @@ output_manager::output_item* output_manager::find_item(const char *string) create_new_item - create a new item -------------------------------------------------*/ -output_manager::output_item *output_manager::create_new_item(const char *outname, int32_t value) +output_manager::output_item *output_manager::create_new_item(const char *outname, s32 value) { output_item item; @@ -83,10 +83,10 @@ void output_manager::resume() output_set_value - set the value of an output -------------------------------------------------*/ -void output_manager::set_value(const char *outname, int32_t value) +void output_manager::set_value(const char *outname, s32 value) { output_item *item = find_item(outname); - int32_t oldval; + s32 oldval; /* if no item of that name, create a new one and send the item's state */ if (item == nullptr) @@ -150,7 +150,7 @@ void output_manager::set_indexed_value(const char *basename, int index, int valu output -------------------------------------------------*/ -int32_t output_manager::get_value(const char *outname) +s32 output_manager::get_value(const char *outname) { output_item *item = find_item(outname); @@ -166,7 +166,7 @@ int32_t output_manager::get_value(const char *outname) indexed output -------------------------------------------------*/ -int32_t output_manager::get_indexed_value(const char *basename, int index) +s32 output_manager::get_indexed_value(const char *basename, int index) { char buffer[100]; char *dest = buffer; @@ -229,7 +229,7 @@ void output_manager::notify_all(output_module *module) a given name -------------------------------------------------*/ -uint32_t output_manager::name_to_id(const char *outname) +u32 output_manager::name_to_id(const char *outname) { output_item *item = find_item(outname); @@ -245,7 +245,7 @@ uint32_t output_manager::name_to_id(const char *outname) to a given unique ID -------------------------------------------------*/ -const char *output_manager::id_to_name(uint32_t id) +const char *output_manager::id_to_name(u32 id) { for (auto &item : m_itemtable) if (item.second.id == id) diff --git a/src/emu/output.h b/src/emu/output.h index c2400639c43..20b5086db9a 100644 --- a/src/emu/output.h +++ b/src/emu/output.h @@ -13,8 +13,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __OUTPUT_H__ -#define __OUTPUT_H__ +#ifndef MAME_EMU_OUTPUT_H +#define MAME_EMU_OUTPUT_H /*************************************************************************** @@ -22,7 +22,7 @@ ***************************************************************************/ class output_module; -typedef void (*output_notifier_func)(const char *outname, int32_t value, void *param); +typedef void (*output_notifier_func)(const char *outname, s32 value, void *param); // ======================> output_manager @@ -44,9 +44,9 @@ class output_manager { public: std::string name; // string name of the item - uint32_t hash; // hash for this item name - uint32_t id; // unique ID for this item - int32_t value; // current value + u32 hash; // hash for this item name + u32 id; // unique ID for this item + s32 value; // current value std::vector notifylist; // list of notifier callbacks }; @@ -58,16 +58,16 @@ public: running_machine &machine() const { return m_machine; } // set the value for a given output - void set_value(const char *outname, int32_t value); + void set_value(const char *outname, s32 value); // set an indexed value for an output (concatenates basename + index) void set_indexed_value(const char *basename, int index, int value); // return the current value for a given output - int32_t get_value(const char *outname); + s32 get_value(const char *outname); // return the current value for a given indexed output - int32_t get_indexed_value(const char *outname, int index); + s32 get_indexed_value(const char *outname, int index); // set a notifier on a particular output, or globally if nullptr void set_notifier(const char *outname, output_notifier_func callback, void *param); @@ -76,31 +76,31 @@ public: void notify_all(output_module *module); // map a name to a unique ID - uint32_t name_to_id(const char *outname); + u32 name_to_id(const char *outname); // map a unique ID back to a name - const char *id_to_name(uint32_t id); + const char *id_to_name(u32 id); // helpers void set_led_value(int index, int value) { set_indexed_value("led", index, value ? 1 : 0); } void set_lamp_value(int index, int value) { set_indexed_value("lamp", index, value); } void set_digit_value(int index, int value) { set_indexed_value("digit", index, value); } - int32_t get_led_value(int index) { return get_indexed_value("led", index); } - int32_t get_lamp_value(int index) { return get_indexed_value("lamp", index); } - int32_t get_digit_value(int index) { return get_indexed_value("digit", index); } + s32 get_led_value(int index) { return get_indexed_value("led", index); } + s32 get_lamp_value(int index) { return get_indexed_value("lamp", index); } + s32 get_digit_value(int index) { return get_indexed_value("digit", index); } void pause(); void resume(); private: output_item *find_item(const char *string); - output_item *create_new_item(const char *outname, int32_t value); + output_item *create_new_item(const char *outname, s32 value); // internal state running_machine & m_machine; // reference to our machine std::unordered_map m_itemtable; std::vector m_global_notifylist; - uint32_t m_uniqueid; + u32 m_uniqueid; }; -#endif // __OUTPUT_H__ +#endif // MAME_EMU_OUTPUT_H diff --git a/src/emu/parameters.h b/src/emu/parameters.h index 23bdd010357..75e90391d1f 100644 --- a/src/emu/parameters.h +++ b/src/emu/parameters.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __PARAMETERS_H__ -#define __PARAMETERS_H__ +#ifndef MAME_EMU_PARAMETERS_H +#define MAME_EMU_PARAMETERS_H //************************************************************************** @@ -45,4 +45,4 @@ private: std::unordered_map m_parameters; }; -#endif // __INPTPORT_H__ */ +#endif // MAME_EMU_PARAMETERS_H diff --git a/src/emu/profiler.cpp b/src/emu/profiler.cpp index e9cb8f29fda..4e14d27ceec 100644 --- a/src/emu/profiler.cpp +++ b/src/emu/profiler.cpp @@ -173,18 +173,18 @@ void real_profiler_state::update_text(running_machine &machine) }; // compute the total time for all bits, not including profiler or idle - uint64_t computed = 0; + u64 computed = 0; profile_type curtype; for (curtype = PROFILER_DEVICE_FIRST; curtype < PROFILER_PROFILER; ++curtype) computed += m_data[curtype]; // save that result in normalize, and continue adding the rest - uint64_t normalize = computed; + u64 normalize = computed; for ( ; curtype < PROFILER_TOTAL; ++curtype) computed += m_data[curtype]; // this becomes the total; if we end up with 0 for anything, we were just started, so return empty - uint64_t total = computed; + u64 total = computed; m_text.clear(); if (total == 0 || normalize == 0) { diff --git a/src/emu/profiler.h b/src/emu/profiler.h index 9309b130df2..997c8c480e1 100644 --- a/src/emu/profiler.h +++ b/src/emu/profiler.h @@ -21,10 +21,10 @@ ***************************************************************************/ -#pragma once +#ifndef MAME_EMU_PROFILER_H +#define MAME_EMU_PROFILER_H -#ifndef __PROFILER_H__ -#define __PROFILER_H__ +#pragma once #include "attotime.h" @@ -212,4 +212,4 @@ typedef dummy_profiler_state profiler_state; extern profiler_state g_profiler; -#endif /* __PROFILER_H__ */ +#endif /* MAME_EMU_PROFILER_H */ diff --git a/src/emu/render.cpp b/src/emu/render.cpp index c4516a80726..d1ee1a600f7 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -434,7 +434,7 @@ void render_texture::hq_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const // get_scaled - get a scaled bitmap (if we can) //------------------------------------------------- -void render_texture::get_scaled(uint32_t dwidth, uint32_t dheight, render_texinfo &texinfo, render_primitive_list &primlist, uint32_t flags) +void render_texture::get_scaled(u32 dwidth, u32 dheight, render_texinfo &texinfo, render_primitive_list &primlist, u32 flags) { // source width/height come from the source bounds int swidth = m_sbounds.width(); @@ -636,7 +636,7 @@ void render_container::set_user_settings(const user_settings &settings) // add_line - add a line item to this container //------------------------------------------------- -void render_container::add_line(float x0, float y0, float x1, float y1, float width, rgb_t argb, uint32_t flags) +void render_container::add_line(float x0, float y0, float x1, float y1, float width, rgb_t argb, u32 flags) { item &newitem = add_generic(CONTAINER_ITEM_LINE, x0, y0, x1, y1, argb); newitem.m_width = width; @@ -648,7 +648,7 @@ void render_container::add_line(float x0, float y0, float x1, float y1, float wi // add_quad - add a quad item to this container //------------------------------------------------- -void render_container::add_quad(float x0, float y0, float x1, float y1, rgb_t argb, render_texture *texture, uint32_t flags) +void render_container::add_quad(float x0, float y0, float x1, float y1, rgb_t argb, render_texture *texture, u32 flags) { item &newitem = add_generic(CONTAINER_ITEM_QUAD, x0, y0, x1, y1, argb); newitem.m_texture = texture; @@ -660,7 +660,7 @@ void render_container::add_quad(float x0, float y0, float x1, float y1, rgb_t ar // add_char - add a char item to this container //------------------------------------------------- -void render_container::add_char(float x0, float y0, float height, float aspect, rgb_t argb, render_font &font, uint16_t ch) +void render_container::add_char(float x0, float y0, float height, float aspect, rgb_t argb, render_font &font, u16 ch) { // compute the bounds of the character cell and get the texture render_bounds bounds; @@ -682,7 +682,7 @@ void render_container::add_char(float x0, float y0, float height, float aspect, // an 8-bit value //------------------------------------------------- -uint8_t render_container::apply_brightness_contrast_gamma(uint8_t value) +u8 render_container::apply_brightness_contrast_gamma(u8 value) { return ::apply_brightness_contrast_gamma(value, m_user.m_brightness, m_user.m_contrast, m_user.m_gamma); } @@ -741,8 +741,8 @@ void render_container::overlay_scale(bitmap_argb32 &dest, bitmap_argb32 &source, // simply replicate the source bitmap over the target for (int y = 0; y < dest.height(); y++) { - uint32_t *src = &source.pix32(y % source.height()); - uint32_t *dst = &dest.pix32(y); + u32 *src = &source.pix32(y % source.height()); + u32 *dst = &dest.pix32(y); int sx = 0; // loop over columns @@ -761,7 +761,7 @@ void render_container::overlay_scale(bitmap_argb32 &dest, bitmap_argb32 &source, // container //------------------------------------------------- -render_container::item &render_container::add_generic(uint8_t type, float x0, float y0, float x1, float y1, rgb_t argb) +render_container::item &render_container::add_generic(u8 type, float x0, float y0, float x1, float y1, rgb_t argb) { item *newitem = m_item_allocator.alloc(); @@ -800,7 +800,7 @@ void render_container::recompute_lookups() // recompute the 256 entry lookup table for (int i = 0; i < 0x100; i++) { - uint8_t adjustedval = apply_brightness_contrast_gamma(i); + u8 adjustedval = apply_brightness_contrast_gamma(i); m_bcglookup256[i + 0x000] = adjustedval << 0; m_bcglookup256[i + 0x100] = adjustedval << 8; m_bcglookup256[i + 0x200] = adjustedval << 16; @@ -843,8 +843,8 @@ void render_container::update_palette() return; // get the dirty list - uint32_t mindirty, maxdirty; - const uint32_t *dirty = m_palclient->dirty_list(mindirty, maxdirty); + u32 mindirty, maxdirty; + const u32 *dirty = m_palclient->dirty_list(mindirty, maxdirty); // iterate over dirty items and update them if (dirty != nullptr) @@ -855,16 +855,16 @@ void render_container::update_palette() if (has_brightness_contrast_gamma_changes()) { // loop over chunks of 32 entries, since we can quickly examine 32 at a time - for (uint32_t entry32 = mindirty / 32; entry32 <= maxdirty / 32; entry32++) + for (u32 entry32 = mindirty / 32; entry32 <= maxdirty / 32; entry32++) { - uint32_t dirtybits = dirty[entry32]; + u32 dirtybits = dirty[entry32]; if (dirtybits != 0) // this chunk of 32 has dirty entries; fix them up - for (uint32_t entry = 0; entry < 32; entry++) + for (u32 entry = 0; entry < 32; entry++) if (dirtybits & (1 << entry)) { - uint32_t finalentry = entry32 * 32 + entry; + u32 finalentry = entry32 * 32 + entry; rgb_t newval = adjusted_palette[finalentry]; m_bcglookup[finalentry] = (newval & 0xff000000) | m_bcglookup256[0x200 + newval.r()] | @@ -905,7 +905,7 @@ render_container::user_settings::user_settings() // render_target - constructor //------------------------------------------------- -render_target::render_target(render_manager &manager, const internal_layout *layoutfile, uint32_t flags) +render_target::render_target(render_manager &manager, const internal_layout *layoutfile, u32 flags) : m_next(nullptr), m_manager(manager), m_curview(nullptr), @@ -1013,7 +1013,7 @@ int render_target::index() const // of a target //------------------------------------------------- -void render_target::set_bounds(int32_t width, int32_t height, float pixel_aspect) +void render_target::set_bounds(s32 width, s32 height, float pixel_aspect) { m_width = width; m_height = height; @@ -1156,7 +1156,7 @@ const render_screen_list &render_target::view_screens(int viewindex) // layout and proposed new parameters //------------------------------------------------- -void render_target::compute_visible_area(int32_t target_width, int32_t target_height, float target_pixel_aspect, int target_orientation, int32_t &visible_width, int32_t &visible_height) +void render_target::compute_visible_area(s32 target_width, s32 target_height, float target_pixel_aspect, int target_orientation, s32 &visible_width, s32 &visible_height) { switch (m_scale_mode) { @@ -1203,7 +1203,7 @@ void render_target::compute_visible_area(int32_t target_width, int32_t target_he default: { // get source size and aspect - int32_t src_width, src_height; + s32 src_width, src_height; compute_minimum_size(src_width, src_height); float src_aspect = m_curview->effective_aspect(m_layerconfig); @@ -1261,7 +1261,7 @@ void render_target::compute_visible_area(int32_t target_width, int32_t target_he // source pixel for all included screens //------------------------------------------------- -void render_target::compute_minimum_size(int32_t &minwidth, int32_t &minheight) +void render_target::compute_minimum_size(s32 &minwidth, s32 &minheight) { float maxxscale = 1.0f, maxyscale = 1.0f; int screens_considered = 0; @@ -1346,7 +1346,7 @@ render_primitive_list &render_target::get_primitives() list.release_all(); // compute the visible width/height - int32_t viswidth, visheight; + s32 viswidth, visheight; compute_visible_area(m_width, m_height, m_pixel_aspect, m_orientation, viswidth, visheight); // create a root transform for the target @@ -1467,7 +1467,7 @@ render_primitive_list &render_target::get_primitives() // specified container, if possible //------------------------------------------------- -bool render_target::map_point_container(int32_t target_x, int32_t target_y, render_container &container, float &container_x, float &container_y) +bool render_target::map_point_container(s32 target_x, s32 target_y, render_container &container, float &container_x, float &container_y) { ioport_port *input_port; ioport_value input_mask; @@ -1481,7 +1481,7 @@ bool render_target::map_point_container(int32_t target_x, int32_t target_y, rend // container, if possible //------------------------------------------------- -bool render_target::map_point_input(int32_t target_x, int32_t target_y, ioport_port *&input_port, ioport_value &input_mask, float &input_x, float &input_y) +bool render_target::map_point_input(s32 target_x, s32 target_y, ioport_port *&input_port, ioport_value &input_mask, float &input_x, float &input_y) { return map_point_internal(target_x, target_y, nullptr, input_x, input_y, input_port, input_mask);; } @@ -1653,7 +1653,7 @@ void render_target::load_layout_files(const internal_layout *layoutfile, bool si bool render_target::load_layout_file(const char *dirname, const internal_layout *layout_data) { // +1 to ensure data is terminated for XML parser - auto tempout = make_unique_clear(layout_data->decompressed_size+1); + auto tempout = make_unique_clear(layout_data->decompressed_size+1); z_stream stream; int zerr; @@ -2008,7 +2008,7 @@ void render_target::add_container_primitives(render_primitive_list &list, const // add the overlay if it exists if (container.overlay() != nullptr && m_layerconfig.screen_overlay_enabled()) { - int32_t width, height; + s32 width, height; // allocate a primitive render_primitive *prim = list.alloc(render_primitive::QUAD); @@ -2060,8 +2060,8 @@ void render_target::add_element_primitives(render_primitive_list &list, const ob prim->flags = PRIMFLAG_TEXORIENT(xform.orientation) | PRIMFLAG_BLENDMODE(blendmode) | PRIMFLAG_TEXFORMAT(texture->format()); // compute the bounds - int32_t width = render_round_nearest(xform.xscale); - int32_t height = render_round_nearest(xform.yscale); + s32 width = render_round_nearest(xform.xscale); + s32 height = render_round_nearest(xform.yscale); set_render_bounds_wh(&prim->bounds, render_round_nearest(xform.xoffs), render_round_nearest(xform.yoffs), (float) width, (float) height); prim->full_bounds = prim->bounds; if (xform.orientation & ORIENTATION_SWAP_XY) @@ -2096,10 +2096,10 @@ void render_target::add_element_primitives(render_primitive_list &list, const ob // mapping points //------------------------------------------------- -bool render_target::map_point_internal(int32_t target_x, int32_t target_y, render_container *container, float &mapped_x, float &mapped_y, ioport_port *&mapped_input_port, ioport_value &mapped_input_mask) +bool render_target::map_point_internal(s32 target_x, s32 target_y, render_container *container, float &mapped_x, float &mapped_y, ioport_port *&mapped_input_port, ioport_value &mapped_input_mask) { // compute the visible width/height - int32_t viswidth, visheight; + s32 viswidth, visheight; compute_visible_area(m_width, m_height, m_pixel_aspect, m_orientation, viswidth, visheight); // create a root transform for the target @@ -2356,19 +2356,19 @@ void render_target::init_clear_extents() bool render_target::remove_clear_extent(const render_bounds &bounds) { - int32_t *max = &m_clear_extents[MAX_CLEAR_EXTENTS]; - int32_t *last = &m_clear_extents[m_clear_extent_count]; - int32_t *ext = &m_clear_extents[0]; - int32_t boundsx0 = ceil(bounds.x0); - int32_t boundsx1 = floor(bounds.x1); - int32_t boundsy0 = ceil(bounds.y0); - int32_t boundsy1 = floor(bounds.y1); - int32_t y0, y1 = 0; + s32 *max = &m_clear_extents[MAX_CLEAR_EXTENTS]; + s32 *last = &m_clear_extents[m_clear_extent_count]; + s32 *ext = &m_clear_extents[0]; + s32 boundsx0 = ceil(bounds.x0); + s32 boundsx1 = floor(bounds.x1); + s32 boundsy0 = ceil(bounds.y0); + s32 boundsy1 = floor(bounds.y1); + s32 y0, y1 = 0; // loop over Y extents while (ext < last) { - int32_t *linelast; + s32 *linelast; // first entry of each line should always be negative assert(ext[0] < 0.0f); @@ -2378,8 +2378,8 @@ bool render_target::remove_clear_extent(const render_bounds &bounds) // do we intersect this extent? if (boundsy0 < y1 && boundsy1 > y0) { - int32_t *xext; - int32_t x0, x1 = 0; + s32 *xext; + s32 x0, x1 = 0; // split the top if (y0 < boundsy0) @@ -2491,16 +2491,16 @@ abort: void render_target::add_clear_extents(render_primitive_list &list) { simple_list clearlist; - int32_t *last = &m_clear_extents[m_clear_extent_count]; - int32_t *ext = &m_clear_extents[0]; - int32_t y0, y1 = 0; + s32 *last = &m_clear_extents[m_clear_extent_count]; + s32 *ext = &m_clear_extents[0]; + s32 y0, y1 = 0; // loop over all extents while (ext < last) { - int32_t *linelast = &ext[ext[1] + 2]; - int32_t *xext = &ext[2]; - int32_t x0, x1 = 0; + s32 *linelast = &ext[ext[1] + 2]; + s32 *xext = &ext[2]; + s32 x0, x1 = 0; // first entry should always be negative assert(ext[0] < 0); @@ -2681,7 +2681,7 @@ float render_manager::max_update_rate() const // target_alloc - allocate a new target //------------------------------------------------- -render_target *render_manager::target_alloc(const internal_layout *layoutfile, uint32_t flags) +render_target *render_manager::target_alloc(const internal_layout *layoutfile, u32 flags) { return &m_targetlist.append(*global_alloc(render_target(*this, layoutfile, flags))); } diff --git a/src/emu/render.h b/src/emu/render.h index 991b88a36d8..edffd769607 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -77,9 +77,9 @@ enum // render creation flags -const uint8_t RENDER_CREATE_NO_ART = 0x01; // ignore any views that have art in them -const uint8_t RENDER_CREATE_SINGLE_FILE = 0x02; // only load views from the file specified -const uint8_t RENDER_CREATE_HIDDEN = 0x04; // don't make this target visible +constexpr u8 RENDER_CREATE_NO_ART = 0x01; // ignore any views that have art in them +constexpr u8 RENDER_CREATE_SINGLE_FILE = 0x02; // only load views from the file specified +constexpr u8 RENDER_CREATE_HIDDEN = 0x04; // don't make this target visible // render scaling modes enum @@ -92,39 +92,39 @@ enum }; // flags for primitives -const int PRIMFLAG_TEXORIENT_SHIFT = 0; -const uint32_t PRIMFLAG_TEXORIENT_MASK = 15 << PRIMFLAG_TEXORIENT_SHIFT; +constexpr int PRIMFLAG_TEXORIENT_SHIFT = 0; +constexpr u32 PRIMFLAG_TEXORIENT_MASK = 15 << PRIMFLAG_TEXORIENT_SHIFT; -const int PRIMFLAG_TEXFORMAT_SHIFT = 4; -const uint32_t PRIMFLAG_TEXFORMAT_MASK = 15 << PRIMFLAG_TEXFORMAT_SHIFT; +constexpr int PRIMFLAG_TEXFORMAT_SHIFT = 4; +constexpr u32 PRIMFLAG_TEXFORMAT_MASK = 15 << PRIMFLAG_TEXFORMAT_SHIFT; -const int PRIMFLAG_BLENDMODE_SHIFT = 8; -const uint32_t PRIMFLAG_BLENDMODE_MASK = 15 << PRIMFLAG_BLENDMODE_SHIFT; +constexpr int PRIMFLAG_BLENDMODE_SHIFT = 8; +constexpr u32 PRIMFLAG_BLENDMODE_MASK = 15 << PRIMFLAG_BLENDMODE_SHIFT; -const int PRIMFLAG_ANTIALIAS_SHIFT = 12; -const uint32_t PRIMFLAG_ANTIALIAS_MASK = 1 << PRIMFLAG_ANTIALIAS_SHIFT; -const int PRIMFLAG_SCREENTEX_SHIFT = 13; -const uint32_t PRIMFLAG_SCREENTEX_MASK = 1 << PRIMFLAG_SCREENTEX_SHIFT; +constexpr int PRIMFLAG_ANTIALIAS_SHIFT = 12; +constexpr u32 PRIMFLAG_ANTIALIAS_MASK = 1 << PRIMFLAG_ANTIALIAS_SHIFT; +constexpr int PRIMFLAG_SCREENTEX_SHIFT = 13; +constexpr u32 PRIMFLAG_SCREENTEX_MASK = 1 << PRIMFLAG_SCREENTEX_SHIFT; -const int PRIMFLAG_TEXWRAP_SHIFT = 14; -const uint32_t PRIMFLAG_TEXWRAP_MASK = 1 << PRIMFLAG_TEXWRAP_SHIFT; +constexpr int PRIMFLAG_TEXWRAP_SHIFT = 14; +constexpr u32 PRIMFLAG_TEXWRAP_MASK = 1 << PRIMFLAG_TEXWRAP_SHIFT; -const int PRIMFLAG_TEXSHADE_SHIFT = 15; -const uint32_t PRIMFLAG_TEXSHADE_MASK = 3 << PRIMFLAG_TEXSHADE_SHIFT; +constexpr int PRIMFLAG_TEXSHADE_SHIFT = 15; +constexpr u32 PRIMFLAG_TEXSHADE_MASK = 3 << PRIMFLAG_TEXSHADE_SHIFT; -const int PRIMFLAG_VECTOR_SHIFT = 17; -const uint32_t PRIMFLAG_VECTOR_MASK = 1 << PRIMFLAG_VECTOR_SHIFT; +constexpr int PRIMFLAG_VECTOR_SHIFT = 17; +constexpr u32 PRIMFLAG_VECTOR_MASK = 1 << PRIMFLAG_VECTOR_SHIFT; -const int PRIMFLAG_VECTORBUF_SHIFT = 18; -const uint32_t PRIMFLAG_VECTORBUF_MASK = 1 << PRIMFLAG_VECTORBUF_SHIFT; +constexpr int PRIMFLAG_VECTORBUF_SHIFT = 18; +constexpr u32 PRIMFLAG_VECTORBUF_MASK = 1 << PRIMFLAG_VECTORBUF_SHIFT; -const int PRIMFLAG_TYPE_SHIFT = 19; -const uint32_t PRIMFLAG_TYPE_MASK = 3 << PRIMFLAG_TYPE_SHIFT; -const uint32_t PRIMFLAG_TYPE_LINE = 0 << PRIMFLAG_TYPE_SHIFT; -const uint32_t PRIMFLAG_TYPE_QUAD = 1 << PRIMFLAG_TYPE_SHIFT; +constexpr int PRIMFLAG_TYPE_SHIFT = 19; +constexpr u32 PRIMFLAG_TYPE_MASK = 3 << PRIMFLAG_TYPE_SHIFT; +constexpr u32 PRIMFLAG_TYPE_LINE = 0 << PRIMFLAG_TYPE_SHIFT; +constexpr u32 PRIMFLAG_TYPE_QUAD = 1 << PRIMFLAG_TYPE_SHIFT; -const int PRIMFLAG_PACKABLE_SHIFT = 21; -const uint32_t PRIMFLAG_PACKABLE = 1 << PRIMFLAG_PACKABLE_SHIFT; +constexpr int PRIMFLAG_PACKABLE_SHIFT = 21; +constexpr u32 PRIMFLAG_PACKABLE = 1 << PRIMFLAG_PACKABLE_SHIFT; //************************************************************************** // MACROS @@ -222,11 +222,11 @@ struct render_quad_texuv struct render_texinfo { void * base; // base of the data - uint32_t rowpixels; // pixels per row - uint32_t width; // width of the image - uint32_t height; // height of the image - uint32_t seqid; // sequence ID - uint64_t osddata; // aux data to pass to osd + u32 rowpixels; // pixels per row + u32 width; // width of the image + u32 height; // height of the image + u32 seqid; // sequence ID + u64 osddata; // aux data to pass to osd const rgb_t * palette; // palette for PALETTE16 textures, bcg lookup table for RGB32/YUY16 }; @@ -281,14 +281,14 @@ private: // render_layer_config - describes the state of layers class render_layer_config { - static const uint8_t ENABLE_BACKDROP = 0x01; // enable backdrop layers - static const uint8_t ENABLE_OVERLAY = 0x02; // enable overlay layers - static const uint8_t ENABLE_BEZEL = 0x04; // enable bezel layers - static const uint8_t ENABLE_CPANEL = 0x08; // enable cpanel layers - static const uint8_t ENABLE_MARQUEE = 0x10; // enable marquee layers - static const uint8_t ZOOM_TO_SCREEN = 0x20; // zoom to screen area by default - static const uint8_t ENABLE_SCREEN_OVERLAY = 0x40; // enable screen overlays - static const uint8_t DEFAULT = ENABLE_BACKDROP | ENABLE_OVERLAY | ENABLE_BEZEL | ENABLE_CPANEL | ENABLE_MARQUEE | ENABLE_SCREEN_OVERLAY; + static constexpr u8 ENABLE_BACKDROP = 0x01; // enable backdrop layers + static constexpr u8 ENABLE_OVERLAY = 0x02; // enable overlay layers + static constexpr u8 ENABLE_BEZEL = 0x04; // enable bezel layers + static constexpr u8 ENABLE_CPANEL = 0x08; // enable cpanel layers + static constexpr u8 ENABLE_MARQUEE = 0x10; // enable marquee layers + static constexpr u8 ZOOM_TO_SCREEN = 0x20; // zoom to screen area by default + static constexpr u8 ENABLE_SCREEN_OVERLAY = 0x40; // enable screen overlays + static constexpr u8 DEFAULT = ENABLE_BACKDROP | ENABLE_OVERLAY | ENABLE_BEZEL | ENABLE_CPANEL | ENABLE_MARQUEE | ENABLE_SCREEN_OVERLAY; public: render_layer_config() @@ -314,7 +314,7 @@ public: render_layer_config &set_zoom_to_screen(bool zoom) { if (zoom) m_state |= ZOOM_TO_SCREEN; else m_state &= ~ZOOM_TO_SCREEN; return *this; } private: - uint8_t m_state; + u8 m_state; }; @@ -344,7 +344,7 @@ public: // getters render_primitive *next() const { return m_next; } - bool packable(const int32_t pack_size) const { return (flags & PRIMFLAG_PACKABLE) && texture.base != nullptr && texture.width <= pack_size && texture.height <= pack_size; } + bool packable(const s32 pack_size) const { return (flags & PRIMFLAG_PACKABLE) && texture.base != nullptr && texture.width <= pack_size && texture.height <= pack_size; } float get_quad_width() const { return fabsf(bounds.x1 - bounds.x0); } float get_quad_height() const { return fabsf(bounds.y1 - bounds.y0); } float get_full_quad_width() const { return fabsf(full_bounds.x1 - full_bounds.x0); } @@ -358,7 +358,7 @@ public: render_bounds bounds; // bounds or positions render_bounds full_bounds; // bounds or positions (unclipped) render_color color; // RGBA values - uint32_t flags; // flags + u32 flags; // flags float width; // width (for line primitives) render_texinfo texture; // texture info (for quad primitives) render_quad_texuv texcoords; // texture coordinates (for quad primitives) @@ -455,14 +455,14 @@ public: void set_bitmap(bitmap_t &bitmap, const rectangle &sbounds, texture_format format); // set any necessary aux data - void set_osd_data(uint64_t data) { m_osddata = data; } + void set_osd_data(u64 data) { m_osddata = data; } // generic high-quality bitmap scaler static void hq_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param); private: // internal helpers - void get_scaled(uint32_t dwidth, uint32_t dheight, render_texinfo &texinfo, render_primitive_list &primlist, uint32_t flags = 0); + void get_scaled(u32 dwidth, u32 dheight, render_texinfo &texinfo, render_primitive_list &primlist, u32 flags = 0); const rgb_t *get_adjusted_palette(render_container &container); static const int MAX_TEXTURE_SCALES = 16; @@ -471,7 +471,7 @@ private: struct scaled_texture { bitmap_argb32 * bitmap; // final bitmap - uint32_t seqid; // sequence number + u32 seqid; // sequence number }; // internal state @@ -480,12 +480,12 @@ private: bitmap_t * m_bitmap; // pointer to the original bitmap rectangle m_sbounds; // source bounds within the bitmap texture_format m_format; // format of the texture data - uint64_t m_osddata; // aux data to pass to osd + u64 m_osddata; // aux data to pass to osd // scaling state (ARGB32 only) texture_scaler_func m_scaler; // scaling callback void * m_param; // scaling callback parameter - uint32_t m_curseq; // current sequence number + u32 m_curseq; // current sequence number scaled_texture m_scaled[MAX_TEXTURE_SCALES];// array of scaled variants of this texture }; @@ -543,15 +543,15 @@ public: void empty() { m_item_allocator.reclaim_all(m_itemlist); } // add items to the list - void add_line(float x0, float y0, float x1, float y1, float width, rgb_t argb, uint32_t flags); - void add_quad(float x0, float y0, float x1, float y1, rgb_t argb, render_texture *texture, uint32_t flags); - void add_char(float x0, float y0, float height, float aspect, rgb_t argb, render_font &font, uint16_t ch); - void add_point(float x0, float y0, float diameter, rgb_t argb, uint32_t flags) { add_line(x0, y0, x0, y0, diameter, argb, flags); } - void add_rect(float x0, float y0, float x1, float y1, rgb_t argb, uint32_t flags) { add_quad(x0, y0, x1, y1, argb, nullptr, flags); } + void add_line(float x0, float y0, float x1, float y1, float width, rgb_t argb, u32 flags); + void add_quad(float x0, float y0, float x1, float y1, rgb_t argb, render_texture *texture, u32 flags); + void add_char(float x0, float y0, float height, float aspect, rgb_t argb, render_font &font, u16 ch); + void add_point(float x0, float y0, float diameter, rgb_t argb, u32 flags) { add_line(x0, y0, x0, y0, diameter, argb, flags); } + void add_rect(float x0, float y0, float x1, float y1, rgb_t argb, u32 flags) { add_quad(x0, y0, x1, y1, argb, nullptr, flags); } // brightness/contrast/gamma helpers bool has_brightness_contrast_gamma_changes() const { return (m_user.m_brightness != 1.0f || m_user.m_contrast != 1.0f || m_user.m_gamma != 1.0f); } - uint8_t apply_brightness_contrast_gamma(uint8_t value); + u8 apply_brightness_contrast_gamma(u8 value); float apply_brightness_contrast_gamma_fp(float value); const rgb_t *bcg_lookup_table(int texformat, palette_t *palette = nullptr); @@ -567,22 +567,22 @@ private: // getters item *next() const { return m_next; } - uint8_t type() const { return m_type; } + u8 type() const { return m_type; } const render_bounds &bounds() const { return m_bounds; } const render_color &color() const { return m_color; } - uint32_t flags() const { return m_flags; } - uint32_t internal() const { return m_internal; } + u32 flags() const { return m_flags; } + u32 internal() const { return m_internal; } float width() const { return m_width; } render_texture *texture() const { return m_texture; } private: // internal state item * m_next; // pointer to the next element in the list - uint8_t m_type; // type of element + u8 m_type; // type of element render_bounds m_bounds; // bounds of the element render_color m_color; // RGBA factors - uint32_t m_flags; // option flags - uint32_t m_internal; // internal flags + u32 m_flags; // option flags + u32 m_internal; // internal flags float m_width; // width of the line (lines only) render_texture * m_texture; // pointer to the source texture (quads only) }; @@ -592,7 +592,7 @@ private: // internal helpers const simple_list &items() const { return m_itemlist; } - item &add_generic(uint8_t type, float x0, float y0, float x1, float y1, rgb_t argb); + item &add_generic(u8 type, float x0, float y0, float x1, float y1, rgb_t argb); void recompute_lookups(); void update_palette(); @@ -1083,15 +1083,15 @@ class render_target friend class render_manager; // construction/destruction - render_target(render_manager &manager, const internal_layout *layoutfile = nullptr, uint32_t flags = 0); + render_target(render_manager &manager, const internal_layout *layoutfile = nullptr, u32 flags = 0); ~render_target(); public: // getters render_target *next() const { return m_next; } render_manager &manager() const { return m_manager; } - uint32_t width() const { return m_width; } - uint32_t height() const { return m_height; } + u32 width() const { return m_width; } + u32 height() const { return m_height; } float pixel_aspect() const { return m_pixel_aspect; } int scale_mode() const { return m_scale_mode; } float max_update_rate() const { return m_max_refresh; } @@ -1104,7 +1104,7 @@ public: int index() const; // setters - void set_bounds(int32_t width, int32_t height, float pixel_aspect = 0); + void set_bounds(s32 width, s32 height, float pixel_aspect = 0); void set_max_update_rate(float updates_per_second) { m_max_refresh = updates_per_second; } void set_orientation(int orientation) { m_orientation = orientation; } void set_view(int viewindex); @@ -1139,15 +1139,15 @@ public: const render_screen_list &view_screens(int viewindex); // bounds computations - void compute_visible_area(int32_t target_width, int32_t target_height, float target_pixel_aspect, int target_orientation, int32_t &visible_width, int32_t &visible_height); - void compute_minimum_size(int32_t &minwidth, int32_t &minheight); + void compute_visible_area(s32 target_width, s32 target_height, float target_pixel_aspect, int target_orientation, s32 &visible_width, s32 &visible_height); + void compute_minimum_size(s32 &minwidth, s32 &minheight); // get a primitive list render_primitive_list &get_primitives(); // hit testing - bool map_point_container(int32_t target_x, int32_t target_y, render_container &container, float &container_x, float &container_y); - bool map_point_input(int32_t target_x, int32_t target_y, ioport_port *&input_port, ioport_value &input_mask, float &input_x, float &input_y); + bool map_point_container(s32 target_x, s32 target_y, render_container &container, float &container_x, float &container_y); + bool map_point_input(s32 target_x, s32 target_y, ioport_port *&input_port, ioport_value &input_mask, float &input_x, float &input_y); // reference tracking void invalidate_all(void *refptr); @@ -1168,7 +1168,7 @@ private: bool load_layout_file(const char *dirname, const internal_layout *layout_data); void add_container_primitives(render_primitive_list &list, const object_transform &root_xform, const object_transform &xform, render_container &container, int blendmode); void add_element_primitives(render_primitive_list &list, const object_transform &xform, layout_element &element, int state, int blendmode); - bool map_point_internal(int32_t target_x, int32_t target_y, render_container *container, float &mapped_x, float &mapped_y, ioport_port *&mapped_input_port, ioport_value &mapped_input_mask); + bool map_point_internal(s32 target_x, s32 target_y, render_container *container, float &mapped_x, float &mapped_y, ioport_port *&mapped_input_port, ioport_value &mapped_input_mask); // config callbacks void config_load(xml_data_node const &targetnode); @@ -1185,19 +1185,19 @@ private: void add_clear_and_optimize_primitive_list(render_primitive_list &list); // constants - static const int NUM_PRIMLISTS = 3; - static const int MAX_CLEAR_EXTENTS = 1000; + static constexpr int NUM_PRIMLISTS = 3; + static constexpr int MAX_CLEAR_EXTENTS = 1000; // internal state render_target * m_next; // link to next target render_manager & m_manager; // reference to our owning manager layout_view * m_curview; // current view simple_list m_filelist; // list of layout files - uint32_t m_flags; // creation flags + u32 m_flags; // creation flags render_primitive_list m_primlist[NUM_PRIMLISTS]; // list of primitives int m_listindex; // index of next primlist to use - int32_t m_width; // width in pixels - int32_t m_height; // height in pixels + s32 m_width; // width in pixels + s32 m_height; // height in pixels render_bounds m_bounds; // bounds of the target bool m_keepaspect; // constrain aspect ratio bool m_int_overscan; // allow overscan on integer scaled targets @@ -1214,8 +1214,8 @@ private: int m_maxtexwidth; // maximum width of a texture int m_maxtexheight; // maximum height of a texture simple_list m_debug_containers; // list of debug containers - int32_t m_clear_extent_count; // number of clear extents - int32_t m_clear_extents[MAX_CLEAR_EXTENTS]; // array of clear extents + s32 m_clear_extent_count; // number of clear extents + s32 m_clear_extents[MAX_CLEAR_EXTENTS]; // array of clear extents bool m_transform_container; // determines whether the screen container is transformed by the core renderer, // otherwise the respective render API will handle the transformation (scale, offset) @@ -1243,7 +1243,7 @@ public: float max_update_rate() const; // targets - render_target *target_alloc(const internal_layout *layoutfile = nullptr, uint32_t flags = 0); + render_target *target_alloc(const internal_layout *layoutfile = nullptr, u32 flags = 0); void target_free(render_target *target); const simple_list &targets() const { return m_targetlist; } render_target *first_target() const { return m_targetlist.first(); } @@ -1288,7 +1288,7 @@ private: render_target * m_ui_target; // current UI target // texture lists - uint32_t m_live_textures; // number of live textures + u32 m_live_textures; // number of live textures fixed_allocator m_texture_allocator;// texture allocator // containers for the UI and for screens diff --git a/src/emu/rendersw.hxx b/src/emu/rendersw.hxx index 911ac67a6f6..32df8b833ff 100644 --- a/src/emu/rendersw.hxx +++ b/src/emu/rendersw.hxx @@ -22,10 +22,10 @@ private: // internal structs struct quad_setup_data { - int32_t dudx, dvdx, dudy, dvdy; - int32_t startu, startv; - int32_t startx, starty; - int32_t endx, endy; + s32 dudx, dvdx, dudy, dvdy; + s32 startu, startv; + s32 startx, starty; + s32 endx, endy; }; // internal helpers @@ -35,21 +35,21 @@ private: static inline float round_nearest(float f) { return floor(f + 0.5f); } // destination pixels are written based on the values of the template parameters - static inline _PixelType dest_assemble_rgb(uint32_t r, uint32_t g, uint32_t b) { return (r << _DstShiftR) | (g << _DstShiftG) | (b << _DstShiftB); } - static inline _PixelType dest_rgb_to_pixel(uint32_t r, uint32_t g, uint32_t b) { return dest_assemble_rgb(r >> _SrcShiftR, g >> _SrcShiftG, b >> _SrcShiftB); } + static inline _PixelType dest_assemble_rgb(u32 r, u32 g, u32 b) { return (r << _DstShiftR) | (g << _DstShiftG) | (b << _DstShiftB); } + static inline _PixelType dest_rgb_to_pixel(u32 r, u32 g, u32 b) { return dest_assemble_rgb(r >> _SrcShiftR, g >> _SrcShiftG, b >> _SrcShiftB); } // source 32-bit pixels are in MAME standardized format - static inline uint32_t source32_r(uint32_t pixel) { return (pixel >> (16 + _SrcShiftR)) & (0xff >> _SrcShiftR); } - static inline uint32_t source32_g(uint32_t pixel) { return (pixel >> ( 8 + _SrcShiftG)) & (0xff >> _SrcShiftG); } - static inline uint32_t source32_b(uint32_t pixel) { return (pixel >> ( 0 + _SrcShiftB)) & (0xff >> _SrcShiftB); } + static inline u32 source32_r(u32 pixel) { return (pixel >> (16 + _SrcShiftR)) & (0xff >> _SrcShiftR); } + static inline u32 source32_g(u32 pixel) { return (pixel >> ( 8 + _SrcShiftG)) & (0xff >> _SrcShiftG); } + static inline u32 source32_b(u32 pixel) { return (pixel >> ( 0 + _SrcShiftB)) & (0xff >> _SrcShiftB); } // destination pixel masks are based on the template parameters as well - static inline uint32_t dest_r(_PixelType pixel) { return (pixel >> _DstShiftR) & (0xff >> _SrcShiftR); } - static inline uint32_t dest_g(_PixelType pixel) { return (pixel >> _DstShiftG) & (0xff >> _SrcShiftG); } - static inline uint32_t dest_b(_PixelType pixel) { return (pixel >> _DstShiftB) & (0xff >> _SrcShiftB); } + static inline u32 dest_r(_PixelType pixel) { return (pixel >> _DstShiftR) & (0xff >> _SrcShiftR); } + static inline u32 dest_g(_PixelType pixel) { return (pixel >> _DstShiftG) & (0xff >> _SrcShiftG); } + static inline u32 dest_b(_PixelType pixel) { return (pixel >> _DstShiftB) & (0xff >> _SrcShiftB); } // generic conversion with special optimization for destinations in the standard format - static inline _PixelType source32_to_dest(uint32_t pixel) + static inline _PixelType source32_to_dest(u32 pixel) { if (_SrcShiftR == 0 && _SrcShiftG == 0 && _SrcShiftB == 0 && _DstShiftR == 16 && _DstShiftG == 8 && _DstShiftB == 0) return pixel; @@ -67,12 +67,12 @@ private: // The document also contains the constants below as floats. //------------------------------------------------- - static inline uint32_t clamp16_shift8(uint32_t x) + static inline u32 clamp16_shift8(u32 x) { - return ((int32_t(x) < 0) ? 0 : (x > 65535 ? 255: x >> 8)); + return ((s32(x) < 0) ? 0 : (x > 65535 ? 255: x >> 8)); } - static inline uint32_t ycc_to_rgb(uint32_t ycc) + static inline u32 ycc_to_rgb(u32 ycc) { // original equations: // @@ -109,14 +109,14 @@ private: // B = clip(( common + 516 * Cb - 13696) >> 8) // - uint8_t y = ycc; - uint8_t cb = ycc >> 8; - uint8_t cr = ycc >> 16; + u8 y = ycc; + u8 cb = ycc >> 8; + u8 cr = ycc >> 16; - uint32_t common = 298 * y - 56992; - uint32_t r = (common + 409 * cr); - uint32_t g = (common - 100 * cb - 208 * cr + 91776); - uint32_t b = (common + 516 * cb - 13696); + u32 common = 298 * y - 56992; + u32 r = (common + 409 * cr); + u32 g = (common - 100 * cb - 208 * cr + 91776); + u32 b = (common + 516 * cb - 13696); // Now clamp and shift back return rgb_t(clamp16_shift8(r), clamp16_shift8(g), clamp16_shift8(b)); @@ -128,32 +128,32 @@ private: // palettized 16bpp source //------------------------------------------------- - static inline uint32_t get_texel_palette16(const render_texinfo &texture, int32_t curu, int32_t curv) + static inline u32 get_texel_palette16(const render_texinfo &texture, s32 curu, s32 curv) { const rgb_t *palbase = texture.palette; if (_BilinearFilter) { - int32_t u0 = curu >> 16; - int32_t u1 = 1; + s32 u0 = curu >> 16; + s32 u1 = 1; if (u0 < 0) u0 = u1 = 0; else if (u0 + 1 >= texture.width) u0 = texture.width - 1, u1 = 0; - int32_t v0 = curv >> 16; - int32_t v1 = texture.rowpixels; + s32 v0 = curv >> 16; + s32 v1 = texture.rowpixels; if (v0 < 0) v0 = v1 = 0; else if (v0 + 1 >= texture.height) v0 = texture.height - 1, v1 = 0; - const uint16_t *texbase = reinterpret_cast(texture.base); + const u16 *texbase = reinterpret_cast(texture.base); texbase += v0 * texture.rowpixels + u0; - uint32_t pix00 = palbase[texbase[0]]; - uint32_t pix01 = palbase[texbase[u1]]; - uint32_t pix10 = palbase[texbase[v1]]; - uint32_t pix11 = palbase[texbase[u1 + v1]]; + u32 pix00 = palbase[texbase[0]]; + u32 pix01 = palbase[texbase[u1]]; + u32 pix10 = palbase[texbase[v1]]; + u32 pix11 = palbase[texbase[u1 + v1]]; return rgbaint_t::bilinear_filter(pix00, pix01, pix10, pix11, curu >> 8, curv >> 8); } else { - const uint16_t *texbase = reinterpret_cast(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16); + const u16 *texbase = reinterpret_cast(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16); return palbase[texbase[0]]; } } @@ -164,28 +164,28 @@ private: // palettized 16bpp source with alpha //------------------------------------------------- - static inline uint32_t get_texel_palette16a(const render_texinfo &texture, int32_t curu, int32_t curv) + static inline u32 get_texel_palette16a(const render_texinfo &texture, s32 curu, s32 curv) { const rgb_t *palbase = texture.palette; if (_BilinearFilter) { - int32_t u0 = curu >> 16; - int32_t u1 = 1; + s32 u0 = curu >> 16; + s32 u1 = 1; if (u0 < 0) u0 = u1 = 0; else if (u0 + 1 >= texture.width) u0 = texture.width - 1, u1 = 0; - int32_t v0 = curv >> 16; - int32_t v1 = texture.rowpixels; + s32 v0 = curv >> 16; + s32 v1 = texture.rowpixels; if (v0 < 0) v0 = v1 = 0; else if (v0 + 1 >= texture.height) v0 = texture.height - 1, v1 = 0; - const uint16_t *texbase = reinterpret_cast(texture.base); + const u16 *texbase = reinterpret_cast(texture.base); texbase += v0 * texture.rowpixels + u0; return rgbaint_t::bilinear_filter(palbase[texbase[0]], palbase[texbase[u1]], palbase[texbase[v1]], palbase[texbase[u1 + v1]], curu >> 8, curv >> 8); } else { - const uint16_t *texbase = reinterpret_cast(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16); + const u16 *texbase = reinterpret_cast(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16); return palbase[texbase[0]]; } } @@ -196,26 +196,26 @@ private: // YCbCr source (pixel is returned as Cr-Cb-Y) //------------------------------------------------- - static inline uint32_t get_texel_yuy16(const render_texinfo &texture, int32_t curu, int32_t curv) + static inline u32 get_texel_yuy16(const render_texinfo &texture, s32 curu, s32 curv) { if (_BilinearFilter) { - int32_t u0 = curu >> 16; - int32_t u1 = 1; + s32 u0 = curu >> 16; + s32 u1 = 1; if (u0 < 0) u0 = u1 = 0; else if (u0 + 1 >= texture.width) u0 = texture.width - 1, u1 = 0; - int32_t v0 = curv >> 16; - int32_t v1 = texture.rowpixels; + s32 v0 = curv >> 16; + s32 v1 = texture.rowpixels; if (v0 < 0) v0 = v1 = 0; else if (v0 + 1 >= texture.height) v0 = texture.height - 1, v1 = 0; - const uint16_t *texbase = reinterpret_cast(texture.base); + const u16 *texbase = reinterpret_cast(texture.base); texbase += v0 * texture.rowpixels + (u0 & ~1); - uint32_t pix00, pix01, pix10, pix11; + u32 pix00, pix01, pix10, pix11; if ((curu & 0x10000) == 0) { - uint32_t cbcr = ((texbase[0] & 0xff) << 8) | ((texbase[1] & 0xff) << 16); + u32 cbcr = ((texbase[0] & 0xff) << 8) | ((texbase[1] & 0xff) << 16); pix00 = (texbase[0] >> 8) | cbcr; pix01 = (texbase[u1] >> 8) | cbcr; cbcr = ((texbase[v1 + 0] & 0xff) << 8) | ((texbase[v1 + 1] & 0xff) << 16); @@ -224,7 +224,7 @@ private: } else { - uint32_t cbcr = ((texbase[0] & 0xff) << 8) | ((texbase[1] & 0xff) << 16); + u32 cbcr = ((texbase[0] & 0xff) << 8) | ((texbase[1] & 0xff) << 16); pix00 = (texbase[1] >> 8) | cbcr; if (u1 != 0) { @@ -247,7 +247,7 @@ private: } else { - const uint16_t *texbase = reinterpret_cast(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 17) * 2; + const u16 *texbase = reinterpret_cast(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 17) * 2; return (texbase[(curu >> 16) & 1] >> 8) | ((texbase[0] & 0xff) << 8) | ((texbase[1] & 0xff) << 16); } } @@ -258,27 +258,27 @@ private: // RGB source //------------------------------------------------- - static inline uint32_t get_texel_rgb32(const render_texinfo &texture, int32_t curu, int32_t curv) + static inline u32 get_texel_rgb32(const render_texinfo &texture, s32 curu, s32 curv) { if (_BilinearFilter) { - int32_t u0 = curu >> 16; - int32_t u1 = 1; + s32 u0 = curu >> 16; + s32 u1 = 1; if (u0 < 0) u0 = u1 = 0; else if (u0 + 1 >= texture.width) u0 = texture.width - 1, u1 = 0; - int32_t v0 = curv >> 16; - int32_t v1 = texture.rowpixels; + s32 v0 = curv >> 16; + s32 v1 = texture.rowpixels; if (v0 < 0) v0 = v1 = 0; else if (v0 + 1 >= texture.height) v0 = texture.height - 1, v1 = 0; - const uint32_t *texbase = reinterpret_cast(texture.base); + const u32 *texbase = reinterpret_cast(texture.base); texbase += v0 * texture.rowpixels + u0; return rgbaint_t::bilinear_filter(texbase[0], texbase[u1], texbase[v1], texbase[u1 + v1], curu >> 8, curv >> 8); } else { - const uint32_t *texbase = reinterpret_cast(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16); + const u32 *texbase = reinterpret_cast(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16); return texbase[0]; } } @@ -289,27 +289,27 @@ private: // ARGB source //------------------------------------------------- - static inline uint32_t get_texel_argb32(const render_texinfo &texture, int32_t curu, int32_t curv) + static inline u32 get_texel_argb32(const render_texinfo &texture, s32 curu, s32 curv) { if (_BilinearFilter) { - int32_t u0 = curu >> 16; - int32_t u1 = 1; + s32 u0 = curu >> 16; + s32 u1 = 1; if (u0 < 0) u0 = u1 = 0; else if (u0 + 1 >= texture.width) u0 = texture.width - 1, u1 = 0; - int32_t v0 = curv >> 16; - int32_t v1 = texture.rowpixels; + s32 v0 = curv >> 16; + s32 v1 = texture.rowpixels; if (v0 < 0) v0 = v1 = 0; else if (v0 + 1 >= texture.height) v0 = texture.height - 1, v1 = 0; - const uint32_t *texbase = reinterpret_cast(texture.base); + const u32 *texbase = reinterpret_cast(texture.base); texbase += v0 * texture.rowpixels + u0; return rgbaint_t::bilinear_filter(texbase[0], texbase[u1], texbase[v1], texbase[u1 + v1], curu >> 8, curv >> 8); } else { - const uint32_t *texbase = reinterpret_cast(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16); + const u32 *texbase = reinterpret_cast(texture.base) + (curv >> 16) * texture.rowpixels + (curu >> 16); return texbase[0]; } } @@ -319,13 +319,13 @@ private: // draw_aa_pixel - draw an antialiased pixel //------------------------------------------------- - static inline void draw_aa_pixel(_PixelType *dstdata, uint32_t pitch, int x, int y, uint32_t col) + static inline void draw_aa_pixel(_PixelType *dstdata, u32 pitch, int x, int y, u32 col) { _PixelType *dest = dstdata + y * pitch + x; - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t dr = source32_r(col) + dest_r(dpix); - uint32_t dg = source32_g(col) + dest_g(dpix); - uint32_t db = source32_b(col) + dest_b(dpix); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 dr = source32_r(col) + dest_r(dpix); + u32 dg = source32_g(col) + dest_g(dpix); + u32 db = source32_b(col) + dest_b(dpix); dr = (dr | -(dr >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); dg = (dg | -(dg >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); db = (db | -(db >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -337,10 +337,10 @@ private: // draw_line - draw a line or point //------------------------------------------------- - static void draw_line(const render_primitive &prim, _PixelType *dstdata, int32_t width, int32_t height, uint32_t pitch) + static void draw_line(const render_primitive &prim, _PixelType *dstdata, s32 width, s32 height, u32 pitch) { // internal tables - static uint32_t s_cosine_table[2049]; + static u32 s_cosine_table[2049]; // compute the start/end coordinates int x1 = int(prim.bounds.x0 * 65536.0f); @@ -349,7 +349,7 @@ private: int y2 = int(prim.bounds.y1 * 65536.0f); // handle color and intensity - uint32_t col = rgb_t(int(255.0f * prim.color.r * prim.color.a), int(255.0f * prim.color.g * prim.color.a), int(255.0f * prim.color.b * prim.color.a)); + u32 col = rgb_t(int(255.0f * prim.color.r * prim.color.a), int(255.0f * prim.color.g * prim.color.a), int(255.0f * prim.color.b * prim.color.a)); if (PRIMFLAG_GET_ANTIALIAS(prim.flags)) { @@ -386,7 +386,7 @@ private: draw_aa_pixel(dstdata, pitch, x1, dy, apply_intensity(0xff & (~y1 >> 8), col)); dy++; dx -= 0x10000 - (0xffff & y1); // take off amount plotted - uint8_t a1 = (dx >> 8) & 0xff; // calc remainder pixel + u8 a1 = (dx >> 8) & 0xff; // calc remainder pixel dx >>= 16; // adjust to pixel (solid) count while (dx--) // plot rest of pixels { @@ -422,7 +422,7 @@ private: draw_aa_pixel(dstdata, pitch, dx, y1, apply_intensity(0xff & (~x1 >> 8), col)); dx++; dy -= 0x10000 - (0xffff & x1); // take off amount plotted - uint8_t a1 = (dy >> 8) & 0xff; // remainder pixel + u8 a1 = (dy >> 8) & 0xff; // remainder pixel dy >>= 16; // adjust to pixel (solid) count while (dy--) // plot rest of pixels { @@ -498,17 +498,17 @@ private: // draw_rect - draw a solid rectangle //------------------------------------------------- - static void draw_rect(const render_primitive &prim, _PixelType *dstdata, int32_t width, int32_t height, uint32_t pitch) + static void draw_rect(const render_primitive &prim, _PixelType *dstdata, s32 width, s32 height, u32 pitch) { render_bounds fpos = prim.bounds; assert(fpos.x0 <= fpos.x1); assert(fpos.y0 <= fpos.y1); // clamp to integers - int32_t startx = round_nearest(fpos.x0); - int32_t starty = round_nearest(fpos.y0); - int32_t endx = round_nearest(fpos.x1); - int32_t endy = round_nearest(fpos.y1); + s32 startx = round_nearest(fpos.x0); + s32 starty = round_nearest(fpos.y0); + s32 endx = round_nearest(fpos.x1); + s32 endy = round_nearest(fpos.y1); // ensure we fit if (startx < 0) startx = 0; @@ -531,24 +531,24 @@ private: // fast case: no alpha if (PRIMFLAG_GET_BLENDMODE(prim.flags) == BLENDMODE_NONE || is_opaque(prim.color.a)) { - uint32_t r = uint32_t(256.0f * prim.color.r); - uint32_t g = uint32_t(256.0f * prim.color.g); - uint32_t b = uint32_t(256.0f * prim.color.b); - uint32_t pix; + u32 r = u32(256.0f * prim.color.r); + u32 g = u32(256.0f * prim.color.g); + u32 b = u32(256.0f * prim.color.b); + u32 pix; // clamp R,G,B to 0-256 range - if (r > 0xff) { if (int32_t(r) < 0) r = 0; else r = 0xff; } - if (g > 0xff) { if (int32_t(g) < 0) g = 0; else g = 0xff; } - if (b > 0xff) { if (int32_t(b) < 0) b = 0; else b = 0xff; } + if (r > 0xff) { if (s32(r) < 0) r = 0; else r = 0xff; } + if (g > 0xff) { if (s32(g) < 0) g = 0; else g = 0xff; } + if (b > 0xff) { if (s32(b) < 0) b = 0; else b = 0xff; } pix = dest_rgb_to_pixel(r, g, b); // loop over rows - for (int32_t y = starty; y < endy; y++) + for (s32 y = starty; y < endy; y++) { _PixelType *dest = dstdata + y * pitch + startx; // loop over cols - for (int32_t x = startx; x < endx; x++) + for (s32 x = startx; x < endx; x++) *dest++ = pix; } } @@ -556,19 +556,19 @@ private: // alpha and/or coloring case else if (!is_transparent(prim.color.a)) { - uint32_t rmask = dest_rgb_to_pixel(0xff,0x00,0x00); - uint32_t gmask = dest_rgb_to_pixel(0x00,0xff,0x00); - uint32_t bmask = dest_rgb_to_pixel(0x00,0x00,0xff); - uint32_t r = uint32_t(256.0f * prim.color.r * prim.color.a); - uint32_t g = uint32_t(256.0f * prim.color.g * prim.color.a); - uint32_t b = uint32_t(256.0f * prim.color.b * prim.color.a); - uint32_t inva = uint32_t(256.0f * (1.0f - prim.color.a)); + u32 rmask = dest_rgb_to_pixel(0xff,0x00,0x00); + u32 gmask = dest_rgb_to_pixel(0x00,0xff,0x00); + u32 bmask = dest_rgb_to_pixel(0x00,0x00,0xff); + u32 r = u32(256.0f * prim.color.r * prim.color.a); + u32 g = u32(256.0f * prim.color.g * prim.color.a); + u32 b = u32(256.0f * prim.color.b * prim.color.a); + u32 inva = u32(256.0f * (1.0f - prim.color.a)); // clamp R,G,B and inverse A to 0-256 range - if (r > 0xff) { if (int32_t(r) < 0) r = 0; else r = 0xff; } - if (g > 0xff) { if (int32_t(g) < 0) g = 0; else g = 0xff; } - if (b > 0xff) { if (int32_t(b) < 0) b = 0; else b = 0xff; } - if (inva > 0x100) { if (int32_t(inva) < 0) inva = 0; else inva = 0x100; } + if (r > 0xff) { if (s32(r) < 0) r = 0; else r = 0xff; } + if (g > 0xff) { if (s32(g) < 0) g = 0; else g = 0xff; } + if (b > 0xff) { if (s32(b) < 0) b = 0; else b = 0xff; } + if (inva > 0x100) { if (s32(inva) < 0) inva = 0; else inva = 0x100; } // pre-shift the RGBA pieces r = dest_rgb_to_pixel(r, 0, 0) << 8; @@ -576,17 +576,17 @@ private: b = dest_rgb_to_pixel(0, 0, b) << 8; // loop over rows - for (int32_t y = starty; y < endy; y++) + for (s32 y = starty; y < endy; y++) { _PixelType *dest = dstdata + y * pitch + startx; // loop over cols - for (int32_t x = startx; x < endx; x++) + for (s32 x = startx; x < endx; x++) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t dr = (r + ((dpix & rmask) * inva)) & (rmask << 8); - uint32_t dg = (g + ((dpix & gmask) * inva)) & (gmask << 8); - uint32_t db = (b + ((dpix & bmask) * inva)) & (bmask << 8); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 dr = (r + ((dpix & rmask) * inva)) & (rmask << 8); + u32 dg = (g + ((dpix & gmask) * inva)) & (gmask << 8); + u32 db = (b + ((dpix & bmask) * inva)) & (bmask << 8); *dest++ = (dr | dg | db) >> 8; } } @@ -603,11 +603,11 @@ private: // rasterization of a 16bpp palettized texture //------------------------------------------------- - static void draw_quad_palette16_none(const render_primitive &prim, _PixelType *dstdata, uint32_t pitch, quad_setup_data &setup) + static void draw_quad_palette16_none(const render_primitive &prim, _PixelType *dstdata, u32 pitch, quad_setup_data &setup) { - int32_t dudx = setup.dudx; - int32_t dvdx = setup.dvdx; - int32_t endx = setup.endx; + s32 dudx = setup.dudx; + s32 dvdx = setup.dvdx; + s32 endx = setup.endx; // ensure all parameters are valid assert(prim.texture.palette != nullptr); @@ -616,16 +616,16 @@ private: if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) { // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_palette16(prim.texture, curu, curv); + u32 pix = get_texel_palette16(prim.texture, curu, curv); *dest++ = source32_to_dest(pix); curu += dudx; curv += dvdx; @@ -636,29 +636,29 @@ private: // coloring-only case else if (is_opaque(prim.color.a)) { - uint32_t sr = uint32_t(256.0f * prim.color.r); - uint32_t sg = uint32_t(256.0f * prim.color.g); - uint32_t sb = uint32_t(256.0f * prim.color.b); + u32 sr = u32(256.0f * prim.color.r); + u32 sg = u32(256.0f * prim.color.g); + u32 sb = u32(256.0f * prim.color.b); // clamp R,G,B to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_palette16(prim.texture, curu, curv); - uint32_t r = (source32_r(pix) * sr) >> 8; - uint32_t g = (source32_g(pix) * sg) >> 8; - uint32_t b = (source32_b(pix) * sb) >> 8; + u32 pix = get_texel_palette16(prim.texture, curu, curv); + u32 r = (source32_r(pix) * sr) >> 8; + u32 g = (source32_g(pix) * sg) >> 8; + u32 b = (source32_b(pix) * sb) >> 8; *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -670,32 +670,32 @@ private: // alpha and/or coloring case else if (!is_transparent(prim.color.a)) { - uint32_t sr = uint32_t(256.0f * prim.color.r * prim.color.a); - uint32_t sg = uint32_t(256.0f * prim.color.g * prim.color.a); - uint32_t sb = uint32_t(256.0f * prim.color.b * prim.color.a); - uint32_t invsa = uint32_t(256.0f * (1.0f - prim.color.a)); + u32 sr = u32(256.0f * prim.color.r * prim.color.a); + u32 sg = u32(256.0f * prim.color.g * prim.color.a); + u32 sb = u32(256.0f * prim.color.b * prim.color.a); + u32 invsa = u32(256.0f * (1.0f - prim.color.a)); // clamp R,G,B and inverse A to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } - if (invsa > 0x100) { if (int32_t(invsa) < 0) invsa = 0; else invsa = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } + if (invsa > 0x100) { if (s32(invsa) < 0) invsa = 0; else invsa = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_palette16(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = (source32_r(pix) * sr + dest_r(dpix) * invsa) >> 8; - uint32_t g = (source32_g(pix) * sg + dest_g(dpix) * invsa) >> 8; - uint32_t b = (source32_b(pix) * sb + dest_b(dpix) * invsa) >> 8; + u32 pix = get_texel_palette16(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = (source32_r(pix) * sr + dest_r(dpix) * invsa) >> 8; + u32 g = (source32_g(pix) * sg + dest_g(dpix) * invsa) >> 8; + u32 b = (source32_b(pix) * sb + dest_b(dpix) * invsa) >> 8; *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -711,11 +711,11 @@ private: // rasterization of a 16bpp palettized texture //------------------------------------------------- - static void draw_quad_palette16_add(const render_primitive &prim, _PixelType *dstdata, uint32_t pitch, quad_setup_data &setup) + static void draw_quad_palette16_add(const render_primitive &prim, _PixelType *dstdata, u32 pitch, quad_setup_data &setup) { - int32_t dudx = setup.dudx; - int32_t dvdx = setup.dvdx; - int32_t endx = setup.endx; + s32 dudx = setup.dudx; + s32 dvdx = setup.dvdx; + s32 endx = setup.endx; // ensure all parameters are valid assert(prim.texture.palette != nullptr); @@ -724,22 +724,22 @@ private: if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) { // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_palette16(prim.texture, curu, curv); + u32 pix = get_texel_palette16(prim.texture, curu, curv); if ((pix & 0xffffff) != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = source32_r(pix) + dest_r(dpix); - uint32_t g = source32_g(pix) + dest_g(dpix); - uint32_t b = source32_b(pix) + dest_b(dpix); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = source32_r(pix) + dest_r(dpix); + u32 g = source32_g(pix) + dest_g(dpix); + u32 b = source32_b(pix) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -755,32 +755,32 @@ private: // alpha and/or coloring case else { - uint32_t sr = uint32_t(256.0f * prim.color.r * prim.color.a); - uint32_t sg = uint32_t(256.0f * prim.color.g * prim.color.a); - uint32_t sb = uint32_t(256.0f * prim.color.b * prim.color.a); + u32 sr = u32(256.0f * prim.color.r * prim.color.a); + u32 sg = u32(256.0f * prim.color.g * prim.color.a); + u32 sb = u32(256.0f * prim.color.b * prim.color.a); // clamp R,G,B and inverse A to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_palette16(prim.texture, curu, curv); + u32 pix = get_texel_palette16(prim.texture, curu, curv); if ((pix & 0xffffff) != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = ((source32_r(pix) * sr) >> 8) + dest_r(dpix); - uint32_t g = ((source32_g(pix) * sg) >> 8) + dest_g(dpix); - uint32_t b = ((source32_b(pix) * sb) >> 8) + dest_b(dpix); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = ((source32_r(pix) * sr) >> 8) + dest_r(dpix); + u32 g = ((source32_g(pix) * sg) >> 8) + dest_g(dpix); + u32 b = ((source32_b(pix) * sb) >> 8) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -804,11 +804,11 @@ private: // rasterization using standard alpha blending //------------------------------------------------- - static void draw_quad_palettea16_alpha(const render_primitive &prim, _PixelType *dstdata, uint32_t pitch, quad_setup_data &setup) + static void draw_quad_palettea16_alpha(const render_primitive &prim, _PixelType *dstdata, u32 pitch, quad_setup_data &setup) { - int32_t dudx = setup.dudx; - int32_t dvdx = setup.dvdx; - int32_t endx = setup.endx; + s32 dudx = setup.dudx; + s32 dvdx = setup.dvdx; + s32 endx = setup.endx; // ensure all parameters are valid assert(prim.texture.palette != nullptr); @@ -817,24 +817,24 @@ private: if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) { // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_palette16a(prim.texture, curu, curv); - uint32_t ta = pix >> 24; + u32 pix = get_texel_palette16a(prim.texture, curu, curv); + u32 ta = pix >> 24; if (ta != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t invta = 0x100 - ta; - uint32_t r = (source32_r(pix) * ta + dest_r(dpix) * invta) >> 8; - uint32_t g = (source32_g(pix) * ta + dest_g(dpix) * invta) >> 8; - uint32_t b = (source32_b(pix) * ta + dest_b(dpix) * invta) >> 8; + u32 dpix = _NoDestRead ? 0 : *dest; + u32 invta = 0x100 - ta; + u32 r = (source32_r(pix) * ta + dest_r(dpix) * invta) >> 8; + u32 g = (source32_g(pix) * ta + dest_g(dpix) * invta) >> 8; + u32 b = (source32_b(pix) * ta + dest_b(dpix) * invta) >> 8; *dest = dest_assemble_rgb(r, g, b); } @@ -848,36 +848,36 @@ private: // alpha and/or coloring case else { - uint32_t sr = uint32_t(256.0f * prim.color.r); - uint32_t sg = uint32_t(256.0f * prim.color.g); - uint32_t sb = uint32_t(256.0f * prim.color.b); - uint32_t sa = uint32_t(256.0f * prim.color.a); + u32 sr = u32(256.0f * prim.color.r); + u32 sg = u32(256.0f * prim.color.g); + u32 sb = u32(256.0f * prim.color.b); + u32 sa = u32(256.0f * prim.color.a); // clamp R,G,B and inverse A to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } - if (sa > 0x100) { if (int32_t(sa) < 0) sa = 0; else sa = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } + if (sa > 0x100) { if (s32(sa) < 0) sa = 0; else sa = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_palette16a(prim.texture, curu, curv); - uint32_t ta = (pix >> 24) * sa; + u32 pix = get_texel_palette16a(prim.texture, curu, curv); + u32 ta = (pix >> 24) * sa; if (ta != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t invsta = (0x10000 - ta) << 8; - uint32_t r = (source32_r(pix) * sr * ta + dest_r(dpix) * invsta) >> 24; - uint32_t g = (source32_g(pix) * sg * ta + dest_g(dpix) * invsta) >> 24; - uint32_t b = (source32_b(pix) * sb * ta + dest_b(dpix) * invsta) >> 24; + u32 dpix = _NoDestRead ? 0 : *dest; + u32 invsta = (0x10000 - ta) << 8; + u32 r = (source32_r(pix) * sr * ta + dest_r(dpix) * invsta) >> 24; + u32 g = (source32_g(pix) * sg * ta + dest_g(dpix) * invsta) >> 24; + u32 b = (source32_b(pix) * sb * ta + dest_b(dpix) * invsta) >> 24; *dest = dest_assemble_rgb(r, g, b); } @@ -900,26 +900,26 @@ private: // rasterization of a 16bpp YUY image //------------------------------------------------- - static void draw_quad_yuy16_none(const render_primitive &prim, _PixelType *dstdata, uint32_t pitch, quad_setup_data &setup) + static void draw_quad_yuy16_none(const render_primitive &prim, _PixelType *dstdata, u32 pitch, quad_setup_data &setup) { - int32_t dudx = setup.dudx; - int32_t dvdx = setup.dvdx; - int32_t endx = setup.endx; + s32 dudx = setup.dudx; + s32 dvdx = setup.dvdx; + s32 endx = setup.endx; // fast case: no coloring, no alpha if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) { // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = ycc_to_rgb(get_texel_yuy16(prim.texture, curu, curv)); + u32 pix = ycc_to_rgb(get_texel_yuy16(prim.texture, curu, curv)); *dest++ = source32_to_dest(pix); curu += dudx; curv += dvdx; @@ -930,29 +930,29 @@ private: // coloring-only case else if (is_opaque(prim.color.a)) { - uint32_t sr = uint32_t(256.0f * prim.color.r); - uint32_t sg = uint32_t(256.0f * prim.color.g); - uint32_t sb = uint32_t(256.0f * prim.color.b); + u32 sr = u32(256.0f * prim.color.r); + u32 sg = u32(256.0f * prim.color.g); + u32 sb = u32(256.0f * prim.color.b); // clamp R,G,B to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = ycc_to_rgb(get_texel_yuy16(prim.texture, curu, curv)); - uint32_t r = (source32_r(pix) * sr) >> 8; - uint32_t g = (source32_g(pix) * sg) >> 8; - uint32_t b = (source32_b(pix) * sb) >> 8; + u32 pix = ycc_to_rgb(get_texel_yuy16(prim.texture, curu, curv)); + u32 r = (source32_r(pix) * sr) >> 8; + u32 g = (source32_g(pix) * sg) >> 8; + u32 b = (source32_b(pix) * sb) >> 8; *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -964,32 +964,32 @@ private: // alpha and/or coloring case else if (!is_transparent(prim.color.a)) { - uint32_t sr = uint32_t(256.0f * prim.color.r * prim.color.a); - uint32_t sg = uint32_t(256.0f * prim.color.g * prim.color.a); - uint32_t sb = uint32_t(256.0f * prim.color.b * prim.color.a); - uint32_t invsa = uint32_t(256.0f * (1.0f - prim.color.a)); + u32 sr = u32(256.0f * prim.color.r * prim.color.a); + u32 sg = u32(256.0f * prim.color.g * prim.color.a); + u32 sb = u32(256.0f * prim.color.b * prim.color.a); + u32 invsa = u32(256.0f * (1.0f - prim.color.a)); // clamp R,G,B and inverse A to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } - if (invsa > 0x100) { if (int32_t(invsa) < 0) invsa = 0; else invsa = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } + if (invsa > 0x100) { if (s32(invsa) < 0) invsa = 0; else invsa = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = ycc_to_rgb(get_texel_yuy16(prim.texture, curu, curv)); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = (source32_r(pix) * sr + dest_r(dpix) * invsa) >> 8; - uint32_t g = (source32_g(pix) * sg + dest_g(dpix) * invsa) >> 8; - uint32_t b = (source32_b(pix) * sb + dest_b(dpix) * invsa) >> 8; + u32 pix = ycc_to_rgb(get_texel_yuy16(prim.texture, curu, curv)); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = (source32_r(pix) * sr + dest_r(dpix) * invsa) >> 8; + u32 g = (source32_g(pix) * sg + dest_g(dpix) * invsa) >> 8; + u32 b = (source32_b(pix) * sb + dest_b(dpix) * invsa) >> 8; *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -1006,11 +1006,11 @@ private: // conversion //------------------------------------------------- - static void draw_quad_yuy16_add(const render_primitive &prim, _PixelType *dstdata, uint32_t pitch, quad_setup_data &setup) + static void draw_quad_yuy16_add(const render_primitive &prim, _PixelType *dstdata, u32 pitch, quad_setup_data &setup) { - int32_t dudx = setup.dudx; - int32_t dvdx = setup.dvdx; - int32_t endx = setup.endx; + s32 dudx = setup.dudx; + s32 dvdx = setup.dvdx; + s32 endx = setup.endx; // simply can't do this without reading from the dest if (_NoDestRead) @@ -1020,20 +1020,20 @@ private: if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) { // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = ycc_to_rgb(get_texel_yuy16(prim.texture, curu, curv)); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = source32_r(pix) + dest_r(dpix); - uint32_t g = source32_g(pix) + dest_g(dpix); - uint32_t b = source32_b(pix) + dest_b(dpix); + u32 pix = ycc_to_rgb(get_texel_yuy16(prim.texture, curu, curv)); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = source32_r(pix) + dest_r(dpix); + u32 g = source32_g(pix) + dest_g(dpix); + u32 b = source32_b(pix) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -1047,32 +1047,32 @@ private: // alpha and/or coloring case else { - uint32_t sr = uint32_t(256.0f * prim.color.r); - uint32_t sg = uint32_t(256.0f * prim.color.g); - uint32_t sb = uint32_t(256.0f * prim.color.b); - uint32_t sa = uint32_t(256.0f * prim.color.a); + u32 sr = u32(256.0f * prim.color.r); + u32 sg = u32(256.0f * prim.color.g); + u32 sb = u32(256.0f * prim.color.b); + u32 sa = u32(256.0f * prim.color.a); // clamp R,G,B and inverse A to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } - if (sa > 0x100) { if (int32_t(sa) < 0) sa = 0; else sa = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } + if (sa > 0x100) { if (s32(sa) < 0) sa = 0; else sa = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = ycc_to_rgb(get_texel_yuy16(prim.texture, curu, curv)); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = ((source32_r(pix) * sr * sa) >> 16) + dest_r(dpix); - uint32_t g = ((source32_g(pix) * sg * sa) >> 16) + dest_g(dpix); - uint32_t b = ((source32_b(pix) * sb * sa) >> 16) + dest_b(dpix); + u32 pix = ycc_to_rgb(get_texel_yuy16(prim.texture, curu, curv)); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = ((source32_r(pix) * sr * sa) >> 16) + dest_r(dpix); + u32 g = ((source32_g(pix) * sg * sa) >> 16) + dest_g(dpix); + u32 b = ((source32_b(pix) * sb * sa) >> 16) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -1094,30 +1094,30 @@ private: // a 32bpp RGB texture //------------------------------------------------- - static void draw_quad_rgb32(const render_primitive &prim, _PixelType *dstdata, uint32_t pitch, quad_setup_data &setup) + static void draw_quad_rgb32(const render_primitive &prim, _PixelType *dstdata, u32 pitch, quad_setup_data &setup) { const rgb_t *palbase = prim.texture.palette; - int32_t dudx = setup.dudx; - int32_t dvdx = setup.dvdx; - int32_t endx = setup.endx; + s32 dudx = setup.dudx; + s32 dvdx = setup.dvdx; + s32 endx = setup.endx; // fast case: no coloring, no alpha if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) { // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_rgb32(prim.texture, curu, curv); + u32 pix = get_texel_rgb32(prim.texture, curu, curv); *dest++ = source32_to_dest(pix); curu += dudx; curv += dvdx; @@ -1128,12 +1128,12 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_rgb32(prim.texture, curu, curv); - uint32_t r = palbase[(pix >> 16) & 0xff] >> _SrcShiftR; - uint32_t g = palbase[(pix >> 8) & 0xff] >> _SrcShiftG; - uint32_t b = palbase[(pix >> 0) & 0xff] >> _SrcShiftB; + u32 pix = get_texel_rgb32(prim.texture, curu, curv); + u32 r = palbase[(pix >> 16) & 0xff] >> _SrcShiftR; + u32 g = palbase[(pix >> 8) & 0xff] >> _SrcShiftG; + u32 b = palbase[(pix >> 0) & 0xff] >> _SrcShiftB; *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -1146,32 +1146,32 @@ private: // coloring-only case else if (is_opaque(prim.color.a)) { - uint32_t sr = uint32_t(256.0f * prim.color.r); - uint32_t sg = uint32_t(256.0f * prim.color.g); - uint32_t sb = uint32_t(256.0f * prim.color.b); + u32 sr = u32(256.0f * prim.color.r); + u32 sg = u32(256.0f * prim.color.g); + u32 sb = u32(256.0f * prim.color.b); // clamp R,G,B to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_rgb32(prim.texture, curu, curv); - uint32_t r = (source32_r(pix) * sr) >> 8; - uint32_t g = (source32_g(pix) * sg) >> 8; - uint32_t b = (source32_b(pix) * sb) >> 8; + u32 pix = get_texel_rgb32(prim.texture, curu, curv); + u32 r = (source32_r(pix) * sr) >> 8; + u32 g = (source32_g(pix) * sg) >> 8; + u32 b = (source32_b(pix) * sb) >> 8; *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -1183,12 +1183,12 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_rgb32(prim.texture, curu, curv); - uint32_t r = (palbase[(pix >> 16) & 0xff] * sr) >> (8 + _SrcShiftR); - uint32_t g = (palbase[(pix >> 8) & 0xff] * sg) >> (8 + _SrcShiftG); - uint32_t b = (palbase[(pix >> 0) & 0xff] * sb) >> (8 + _SrcShiftB); + u32 pix = get_texel_rgb32(prim.texture, curu, curv); + u32 r = (palbase[(pix >> 16) & 0xff] * sr) >> (8 + _SrcShiftR); + u32 g = (palbase[(pix >> 8) & 0xff] * sg) >> (8 + _SrcShiftG); + u32 b = (palbase[(pix >> 0) & 0xff] * sb) >> (8 + _SrcShiftB); *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -1201,35 +1201,35 @@ private: // alpha and/or coloring case else if (!is_transparent(prim.color.a)) { - uint32_t sr = uint32_t(256.0f * prim.color.r * prim.color.a); - uint32_t sg = uint32_t(256.0f * prim.color.g * prim.color.a); - uint32_t sb = uint32_t(256.0f * prim.color.b * prim.color.a); - uint32_t invsa = uint32_t(256.0f * (1.0f - prim.color.a)); + u32 sr = u32(256.0f * prim.color.r * prim.color.a); + u32 sg = u32(256.0f * prim.color.g * prim.color.a); + u32 sb = u32(256.0f * prim.color.b * prim.color.a); + u32 invsa = u32(256.0f * (1.0f - prim.color.a)); // clamp R,G,B and inverse A to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } - if (invsa > 0x100) { if (int32_t(invsa) < 0) invsa = 0; else invsa = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } + if (invsa > 0x100) { if (s32(invsa) < 0) invsa = 0; else invsa = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_rgb32(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = (source32_r(pix) * sr + dest_r(dpix) * invsa) >> 8; - uint32_t g = (source32_g(pix) * sg + dest_g(dpix) * invsa) >> 8; - uint32_t b = (source32_b(pix) * sb + dest_b(dpix) * invsa) >> 8; + u32 pix = get_texel_rgb32(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = (source32_r(pix) * sr + dest_r(dpix) * invsa) >> 8; + u32 g = (source32_g(pix) * sg + dest_g(dpix) * invsa) >> 8; + u32 b = (source32_b(pix) * sb + dest_b(dpix) * invsa) >> 8; *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -1241,13 +1241,13 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_rgb32(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = ((palbase[(pix >> 16) & 0xff] >> _SrcShiftR) * sr + dest_r(dpix) * invsa) >> 8; - uint32_t g = ((palbase[(pix >> 8) & 0xff] >> _SrcShiftG) * sg + dest_g(dpix) * invsa) >> 8; - uint32_t b = ((palbase[(pix >> 0) & 0xff] >> _SrcShiftB) * sb + dest_b(dpix) * invsa) >> 8; + u32 pix = get_texel_rgb32(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = ((palbase[(pix >> 16) & 0xff] >> _SrcShiftR) * sr + dest_r(dpix) * invsa) >> 8; + u32 g = ((palbase[(pix >> 8) & 0xff] >> _SrcShiftG) * sg + dest_g(dpix) * invsa) >> 8; + u32 b = ((palbase[(pix >> 0) & 0xff] >> _SrcShiftB) * sb + dest_b(dpix) * invsa) >> 8; *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -1264,12 +1264,12 @@ private: // rasterization by using RGB add //------------------------------------------------- - static void draw_quad_rgb32_add(const render_primitive &prim, _PixelType *dstdata, uint32_t pitch, quad_setup_data &setup) + static void draw_quad_rgb32_add(const render_primitive &prim, _PixelType *dstdata, u32 pitch, quad_setup_data &setup) { const rgb_t *palbase = prim.texture.palette; - int32_t dudx = setup.dudx; - int32_t dvdx = setup.dvdx; - int32_t endx = setup.endx; + s32 dudx = setup.dudx; + s32 dvdx = setup.dvdx; + s32 endx = setup.endx; // simply can't do this without reading from the dest if (_NoDestRead) @@ -1279,23 +1279,23 @@ private: if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) { // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = source32_r(pix) + dest_r(dpix); - uint32_t g = source32_g(pix) + dest_g(dpix); - uint32_t b = source32_b(pix) + dest_b(dpix); + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = source32_r(pix) + dest_r(dpix); + u32 g = source32_g(pix) + dest_g(dpix); + u32 b = source32_b(pix) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -1309,13 +1309,13 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = (palbase[(pix >> 16) & 0xff] >> _SrcShiftR) + dest_r(dpix); - uint32_t g = (palbase[(pix >> 8) & 0xff] >> _SrcShiftG) + dest_g(dpix); - uint32_t b = (palbase[(pix >> 0) & 0xff] >> _SrcShiftB) + dest_b(dpix); + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = (palbase[(pix >> 16) & 0xff] >> _SrcShiftR) + dest_r(dpix); + u32 g = (palbase[(pix >> 8) & 0xff] >> _SrcShiftG) + dest_g(dpix); + u32 b = (palbase[(pix >> 0) & 0xff] >> _SrcShiftB) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -1330,35 +1330,35 @@ private: // alpha and/or coloring case else { - uint32_t sr = uint32_t(256.0f * prim.color.r); - uint32_t sg = uint32_t(256.0f * prim.color.g); - uint32_t sb = uint32_t(256.0f * prim.color.b); - uint32_t sa = uint32_t(256.0f * prim.color.a); + u32 sr = u32(256.0f * prim.color.r); + u32 sg = u32(256.0f * prim.color.g); + u32 sb = u32(256.0f * prim.color.b); + u32 sa = u32(256.0f * prim.color.a); // clamp R,G,B and inverse A to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } - if (sa > 0x100) { if (int32_t(sa) < 0) sa = 0; else sa = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } + if (sa > 0x100) { if (s32(sa) < 0) sa = 0; else sa = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = ((source32_r(pix) * sr * sa) >> 16) + dest_r(dpix); - uint32_t g = ((source32_g(pix) * sg * sa) >> 16) + dest_g(dpix); - uint32_t b = ((source32_b(pix) * sb * sa) >> 16) + dest_b(dpix); + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = ((source32_r(pix) * sr * sa) >> 16) + dest_r(dpix); + u32 g = ((source32_g(pix) * sg * sa) >> 16) + dest_g(dpix); + u32 b = ((source32_b(pix) * sb * sa) >> 16) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -1372,13 +1372,13 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = ((palbase[(pix >> 16) & 0xff] * sr * sa) >> (16 + _SrcShiftR)) + dest_r(dpix); - uint32_t g = ((palbase[(pix >> 8) & 0xff] * sr * sa) >> (16 + _SrcShiftR)) + dest_g(dpix); - uint32_t b = ((palbase[(pix >> 0) & 0xff] * sr * sa) >> (16 + _SrcShiftR)) + dest_b(dpix); + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = ((palbase[(pix >> 16) & 0xff] * sr * sa) >> (16 + _SrcShiftR)) + dest_r(dpix); + u32 g = ((palbase[(pix >> 8) & 0xff] * sr * sa) >> (16 + _SrcShiftR)) + dest_g(dpix); + u32 b = ((palbase[(pix >> 0) & 0xff] * sr * sa) >> (16 + _SrcShiftR)) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -1402,38 +1402,38 @@ private: // rasterization using standard alpha blending //------------------------------------------------- - static void draw_quad_argb32_alpha(const render_primitive &prim, _PixelType *dstdata, uint32_t pitch, quad_setup_data &setup) + static void draw_quad_argb32_alpha(const render_primitive &prim, _PixelType *dstdata, u32 pitch, quad_setup_data &setup) { const rgb_t *palbase = prim.texture.palette; - int32_t dudx = setup.dudx; - int32_t dvdx = setup.dvdx; - int32_t endx = setup.endx; + s32 dudx = setup.dudx; + s32 dvdx = setup.dvdx; + s32 endx = setup.endx; // fast case: no coloring, no alpha if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) { // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t ta = pix >> 24; + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 ta = pix >> 24; if (ta != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t invta = 0x100 - ta; - uint32_t r = (source32_r(pix) * ta + dest_r(dpix) * invta) >> 8; - uint32_t g = (source32_g(pix) * ta + dest_g(dpix) * invta) >> 8; - uint32_t b = (source32_b(pix) * ta + dest_b(dpix) * invta) >> 8; + u32 dpix = _NoDestRead ? 0 : *dest; + u32 invta = 0x100 - ta; + u32 r = (source32_r(pix) * ta + dest_r(dpix) * invta) >> 8; + u32 g = (source32_g(pix) * ta + dest_g(dpix) * invta) >> 8; + u32 b = (source32_b(pix) * ta + dest_b(dpix) * invta) >> 8; *dest = dest_assemble_rgb(r, g, b); } @@ -1447,17 +1447,17 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t ta = pix >> 24; + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 ta = pix >> 24; if (ta != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t invta = 0x100 - ta; - uint32_t r = ((palbase[(pix >> 16) & 0xff] >> _SrcShiftR) * ta + dest_r(dpix) * invta) >> 8; - uint32_t g = ((palbase[(pix >> 8) & 0xff] >> _SrcShiftG) * ta + dest_g(dpix) * invta) >> 8; - uint32_t b = ((palbase[(pix >> 0) & 0xff] >> _SrcShiftB) * ta + dest_b(dpix) * invta) >> 8; + u32 dpix = _NoDestRead ? 0 : *dest; + u32 invta = 0x100 - ta; + u32 r = ((palbase[(pix >> 16) & 0xff] >> _SrcShiftR) * ta + dest_r(dpix) * invta) >> 8; + u32 g = ((palbase[(pix >> 8) & 0xff] >> _SrcShiftG) * ta + dest_g(dpix) * invta) >> 8; + u32 b = ((palbase[(pix >> 0) & 0xff] >> _SrcShiftB) * ta + dest_b(dpix) * invta) >> 8; *dest = dest_assemble_rgb(r, g, b); } @@ -1472,39 +1472,39 @@ private: // alpha and/or coloring case else { - uint32_t sr = uint32_t(256.0f * prim.color.r); - uint32_t sg = uint32_t(256.0f * prim.color.g); - uint32_t sb = uint32_t(256.0f * prim.color.b); - uint32_t sa = uint32_t(256.0f * prim.color.a); + u32 sr = u32(256.0f * prim.color.r); + u32 sg = u32(256.0f * prim.color.g); + u32 sb = u32(256.0f * prim.color.b); + u32 sa = u32(256.0f * prim.color.a); // clamp R,G,B and inverse A to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } - if (sa > 0x100) { if (int32_t(sa) < 0) sa = 0; else sa = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } + if (sa > 0x100) { if (s32(sa) < 0) sa = 0; else sa = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t ta = (pix >> 24) * sa; + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 ta = (pix >> 24) * sa; if (ta != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t invsta = (0x10000 - ta) << 8; - uint32_t r = (source32_r(pix) * sr * ta + dest_r(dpix) * invsta) >> 24; - uint32_t g = (source32_g(pix) * sg * ta + dest_g(dpix) * invsta) >> 24; - uint32_t b = (source32_b(pix) * sb * ta + dest_b(dpix) * invsta) >> 24; + u32 dpix = _NoDestRead ? 0 : *dest; + u32 invsta = (0x10000 - ta) << 8; + u32 r = (source32_r(pix) * sr * ta + dest_r(dpix) * invsta) >> 24; + u32 g = (source32_g(pix) * sg * ta + dest_g(dpix) * invsta) >> 24; + u32 b = (source32_b(pix) * sb * ta + dest_b(dpix) * invsta) >> 24; *dest = dest_assemble_rgb(r, g, b); } @@ -1519,17 +1519,17 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t ta = (pix >> 24) * sa; + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 ta = (pix >> 24) * sa; if (ta != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t invsta = (0x10000 - ta) << 8; - uint32_t r = ((palbase[(pix >> 16) & 0xff] >> _SrcShiftR) * sr * ta + dest_r(dpix) * invsta) >> 24; - uint32_t g = ((palbase[(pix >> 8) & 0xff] >> _SrcShiftG) * sg * ta + dest_g(dpix) * invsta) >> 24; - uint32_t b = ((palbase[(pix >> 0) & 0xff] >> _SrcShiftB) * sb * ta + dest_b(dpix) * invsta) >> 24; + u32 dpix = _NoDestRead ? 0 : *dest; + u32 invsta = (0x10000 - ta) << 8; + u32 r = ((palbase[(pix >> 16) & 0xff] >> _SrcShiftR) * sr * ta + dest_r(dpix) * invsta) >> 24; + u32 g = ((palbase[(pix >> 8) & 0xff] >> _SrcShiftG) * sg * ta + dest_g(dpix) * invsta) >> 24; + u32 b = ((palbase[(pix >> 0) & 0xff] >> _SrcShiftB) * sb * ta + dest_b(dpix) * invsta) >> 24; *dest = dest_assemble_rgb(r, g, b); } @@ -1548,12 +1548,12 @@ private: // rasterization using RGB multiply //------------------------------------------------- - static void draw_quad_argb32_multiply(const render_primitive &prim, _PixelType *dstdata, uint32_t pitch, quad_setup_data &setup) + static void draw_quad_argb32_multiply(const render_primitive &prim, _PixelType *dstdata, u32 pitch, quad_setup_data &setup) { const rgb_t *palbase = prim.texture.palette; - int32_t dudx = setup.dudx; - int32_t dvdx = setup.dvdx; - int32_t endx = setup.endx; + s32 dudx = setup.dudx; + s32 dvdx = setup.dvdx; + s32 endx = setup.endx; // simply can't do this without reading from the dest if (_NoDestRead) @@ -1563,23 +1563,23 @@ private: if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) { // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = (source32_r(pix) * dest_r(dpix)) >> (8 - _SrcShiftR); - uint32_t g = (source32_g(pix) * dest_g(dpix)) >> (8 - _SrcShiftG); - uint32_t b = (source32_b(pix) * dest_b(dpix)) >> (8 - _SrcShiftB); + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = (source32_r(pix) * dest_r(dpix)) >> (8 - _SrcShiftR); + u32 g = (source32_g(pix) * dest_g(dpix)) >> (8 - _SrcShiftG); + u32 b = (source32_b(pix) * dest_b(dpix)) >> (8 - _SrcShiftB); *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -1589,13 +1589,13 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = (palbase[(pix >> 16) & 0xff] * dest_r(dpix)) >> 8; - uint32_t g = (palbase[(pix >> 8) & 0xff] * dest_g(dpix)) >> 8; - uint32_t b = (palbase[(pix >> 0) & 0xff] * dest_b(dpix)) >> 8; + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = (palbase[(pix >> 16) & 0xff] * dest_r(dpix)) >> 8; + u32 g = (palbase[(pix >> 8) & 0xff] * dest_g(dpix)) >> 8; + u32 b = (palbase[(pix >> 0) & 0xff] * dest_b(dpix)) >> 8; *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -1608,33 +1608,33 @@ private: // alpha and/or coloring case else { - uint32_t sr = uint32_t(256.0f * prim.color.r * prim.color.a); - uint32_t sg = uint32_t(256.0f * prim.color.g * prim.color.a); - uint32_t sb = uint32_t(256.0f * prim.color.b * prim.color.a); + u32 sr = u32(256.0f * prim.color.r * prim.color.a); + u32 sg = u32(256.0f * prim.color.g * prim.color.a); + u32 sb = u32(256.0f * prim.color.b * prim.color.a); // clamp R,G,B and inverse A to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = (source32_r(pix) * sr * dest_r(dpix)) >> (16 - _SrcShiftR); - uint32_t g = (source32_g(pix) * sg * dest_g(dpix)) >> (16 - _SrcShiftG); - uint32_t b = (source32_b(pix) * sb * dest_b(dpix)) >> (16 - _SrcShiftB); + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = (source32_r(pix) * sr * dest_r(dpix)) >> (16 - _SrcShiftR); + u32 g = (source32_g(pix) * sg * dest_g(dpix)) >> (16 - _SrcShiftG); + u32 b = (source32_b(pix) * sb * dest_b(dpix)) >> (16 - _SrcShiftB); *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -1644,13 +1644,13 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = (palbase[(pix >> 16) & 0xff] * sr * dest_r(dpix)) >> 16; - uint32_t g = (palbase[(pix >> 8) & 0xff] * sg * dest_g(dpix)) >> 16; - uint32_t b = (palbase[(pix >> 0) & 0xff] * sb * dest_b(dpix)) >> 16; + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = (palbase[(pix >> 16) & 0xff] * sr * dest_r(dpix)) >> 16; + u32 g = (palbase[(pix >> 8) & 0xff] * sg * dest_g(dpix)) >> 16; + u32 b = (palbase[(pix >> 0) & 0xff] * sb * dest_b(dpix)) >> 16; *dest++ = dest_assemble_rgb(r, g, b); curu += dudx; @@ -1667,12 +1667,12 @@ private: // rasterization by using RGB add //------------------------------------------------- - static void draw_quad_argb32_add(const render_primitive &prim, _PixelType *dstdata, uint32_t pitch, quad_setup_data &setup) + static void draw_quad_argb32_add(const render_primitive &prim, _PixelType *dstdata, u32 pitch, quad_setup_data &setup) { const rgb_t *palbase = prim.texture.palette; - int32_t dudx = setup.dudx; - int32_t dvdx = setup.dvdx; - int32_t endx = setup.endx; + s32 dudx = setup.dudx; + s32 dvdx = setup.dvdx; + s32 endx = setup.endx; // simply can't do this without reading from the dest if (_NoDestRead) @@ -1682,26 +1682,26 @@ private: if (prim.color.r >= 1.0f && prim.color.g >= 1.0f && prim.color.b >= 1.0f && is_opaque(prim.color.a)) { // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t ta = pix >> 24; + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 ta = pix >> 24; if (ta != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = ((source32_r(pix) * ta) >> 8) + dest_r(dpix); - uint32_t g = ((source32_g(pix) * ta) >> 8) + dest_g(dpix); - uint32_t b = ((source32_b(pix) * ta) >> 8) + dest_b(dpix); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = ((source32_r(pix) * ta) >> 8) + dest_r(dpix); + u32 g = ((source32_g(pix) * ta) >> 8) + dest_g(dpix); + u32 b = ((source32_b(pix) * ta) >> 8) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -1717,16 +1717,16 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t ta = pix >> 24; + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 ta = pix >> 24; if (ta != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = ((palbase[(pix >> 16) & 0xff] * ta) >> (8 + _SrcShiftR)) + dest_r(dpix); - uint32_t g = ((palbase[(pix >> 8) & 0xff] * ta) >> (8 + _SrcShiftG)) + dest_g(dpix); - uint32_t b = ((palbase[(pix >> 0) & 0xff] * ta) >> (8 + _SrcShiftB)) + dest_b(dpix); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = ((palbase[(pix >> 16) & 0xff] * ta) >> (8 + _SrcShiftR)) + dest_r(dpix); + u32 g = ((palbase[(pix >> 8) & 0xff] * ta) >> (8 + _SrcShiftG)) + dest_g(dpix); + u32 b = ((palbase[(pix >> 0) & 0xff] * ta) >> (8 + _SrcShiftB)) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -1743,38 +1743,38 @@ private: // alpha and/or coloring case else { - uint32_t sr = uint32_t(256.0f * prim.color.r); - uint32_t sg = uint32_t(256.0f * prim.color.g); - uint32_t sb = uint32_t(256.0f * prim.color.b); - uint32_t sa = uint32_t(256.0f * prim.color.a); + u32 sr = u32(256.0f * prim.color.r); + u32 sg = u32(256.0f * prim.color.g); + u32 sb = u32(256.0f * prim.color.b); + u32 sa = u32(256.0f * prim.color.a); // clamp R,G,B and inverse A to 0-256 range - if (sr > 0x100) { if (int32_t(sr) < 0) sr = 0; else sr = 0x100; } - if (sg > 0x100) { if (int32_t(sg) < 0) sg = 0; else sg = 0x100; } - if (sb > 0x100) { if (int32_t(sb) < 0) sb = 0; else sb = 0x100; } - if (sa > 0x100) { if (int32_t(sa) < 0) sa = 0; else sa = 0x100; } + if (sr > 0x100) { if (s32(sr) < 0) sr = 0; else sr = 0x100; } + if (sg > 0x100) { if (s32(sg) < 0) sg = 0; else sg = 0x100; } + if (sb > 0x100) { if (s32(sb) < 0) sb = 0; else sb = 0x100; } + if (sa > 0x100) { if (s32(sa) < 0) sa = 0; else sa = 0x100; } // loop over rows - for (int32_t y = setup.starty; y < setup.endy; y++) + for (s32 y = setup.starty; y < setup.endy; y++) { _PixelType *dest = dstdata + y * pitch + setup.startx; - int32_t curu = setup.startu + (y - setup.starty) * setup.dudy; - int32_t curv = setup.startv + (y - setup.starty) * setup.dvdy; + s32 curu = setup.startu + (y - setup.starty) * setup.dudy; + s32 curv = setup.startv + (y - setup.starty) * setup.dvdy; // no lookup case if (palbase == nullptr) { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t ta = (pix >> 24) * sa; + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 ta = (pix >> 24) * sa; if (ta != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = ((source32_r(pix) * sr * ta) >> 24) + dest_r(dpix); - uint32_t g = ((source32_g(pix) * sg * ta) >> 24) + dest_g(dpix); - uint32_t b = ((source32_b(pix) * sb * ta) >> 24) + dest_b(dpix); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = ((source32_r(pix) * sr * ta) >> 24) + dest_r(dpix); + u32 g = ((source32_g(pix) * sg * ta) >> 24) + dest_g(dpix); + u32 b = ((source32_b(pix) * sb * ta) >> 24) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -1790,16 +1790,16 @@ private: else { // loop over cols - for (int32_t x = setup.startx; x < endx; x++) + for (s32 x = setup.startx; x < endx; x++) { - uint32_t pix = get_texel_argb32(prim.texture, curu, curv); - uint32_t ta = (pix >> 24) * sa; + u32 pix = get_texel_argb32(prim.texture, curu, curv); + u32 ta = (pix >> 24) * sa; if (ta != 0) { - uint32_t dpix = _NoDestRead ? 0 : *dest; - uint32_t r = ((palbase[(pix >> 16) & 0xff] * sr * ta) >> (24 + _SrcShiftR)) + dest_r(dpix); - uint32_t g = ((palbase[(pix >> 8) & 0xff] * sr * ta) >> (24 + _SrcShiftR)) + dest_g(dpix); - uint32_t b = ((palbase[(pix >> 0) & 0xff] * sr * ta) >> (24 + _SrcShiftR)) + dest_b(dpix); + u32 dpix = _NoDestRead ? 0 : *dest; + u32 r = ((palbase[(pix >> 16) & 0xff] * sr * ta) >> (24 + _SrcShiftR)) + dest_r(dpix); + u32 g = ((palbase[(pix >> 8) & 0xff] * sr * ta) >> (24 + _SrcShiftR)) + dest_g(dpix); + u32 b = ((palbase[(pix >> 0) & 0xff] * sr * ta) >> (24 + _SrcShiftR)) + dest_b(dpix); r = (r | -(r >> (8 - _SrcShiftR))) & (0xff >> _SrcShiftR); g = (g | -(g >> (8 - _SrcShiftG))) & (0xff >> _SrcShiftG); b = (b | -(b >> (8 - _SrcShiftB))) & (0xff >> _SrcShiftB); @@ -1825,7 +1825,7 @@ private: // drawing routine //------------------------------------------------- - static void setup_and_draw_textured_quad(const render_primitive &prim, _PixelType *dstdata, int32_t width, int32_t height, uint32_t pitch) + static void setup_and_draw_textured_quad(const render_primitive &prim, _PixelType *dstdata, s32 width, s32 height, u32 pitch) { assert(prim.bounds.x0 <= prim.bounds.x1); assert(prim.bounds.y0 <= prim.bounds.y1); @@ -1936,7 +1936,7 @@ private: //------------------------------------------------- public: - static void draw_primitives(const render_primitive_list &primlist, void *dstdata, uint32_t width, uint32_t height, uint32_t pitch) + static void draw_primitives(const render_primitive_list &primlist, void *dstdata, u32 width, u32 height, u32 pitch) { // loop over the list and render each element for (const render_primitive *prim = primlist.first(); prim != nullptr; prim = prim->next()) diff --git a/src/emu/rendfont.cpp b/src/emu/rendfont.cpp index aa43342958c..9adbbe2dc33 100644 --- a/src/emu/rendfont.cpp +++ b/src/emu/rendfont.cpp @@ -22,7 +22,7 @@ #include -const uint64_t render_font::CACHED_BDF_HASH_SIZE; +const u64 render_font::CACHED_BDF_HASH_SIZE; //************************************************************************** // INLINE FUNCTIONS @@ -234,11 +234,11 @@ void render_font::char_expand(char32_t chnum, glyph &gl) // extract the data const char *ptr = gl.rawdata; - uint8_t accum = 0, accumbit = 7; + u8 accum = 0, accumbit = 7; for (int y = 0; y < gl.bmheight; y++) { int desty = y + m_height_cmd + m_yoffs_cmd - gl.yoffs - gl.bmheight; - uint32_t *dest = (desty >= 0 && desty < m_height_cmd) ? &gl.bitmap.pix32(desty, 0) : nullptr; + u32 *dest = (desty >= 0 && desty < m_height_cmd) ? &gl.bitmap.pix32(desty, 0) : nullptr; { for (int x = 0; x < gl.bmwidth; x++) { @@ -283,11 +283,11 @@ void render_font::char_expand(char32_t chnum, glyph &gl) // extract the data const char *ptr = gl.rawdata; - uint8_t accum = 0, accumbit = 7; + u8 accum = 0, accumbit = 7; for (int y = 0; y < gl.bmheight; y++) { int desty = y + m_height + m_yoffs - gl.yoffs - gl.bmheight; - uint32_t *dest = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : nullptr; + u32 *dest = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : nullptr; // text format if (m_format == FF_TEXT) @@ -454,7 +454,7 @@ float render_font::utf8string_width(float height, float aspect, const char *utf8 // loop over the string and accumulate widths int count; - int32_t totwidth = 0; + s32 totwidth = 0; for (std::size_t offset = 0U; offset < length; offset += unsigned(count)) { char32_t uchar; @@ -490,12 +490,12 @@ bool render_font::load_cached_bdf(const char *filename) m_rawdata.resize(m_rawsize + 1); // read the first chunk - uint32_t bytes = file.read(&m_rawdata[0], std::min(CACHED_BDF_HASH_SIZE, m_rawsize)); + u32 bytes = file.read(&m_rawdata[0], std::min(CACHED_BDF_HASH_SIZE, m_rawsize)); if (bytes != std::min(CACHED_BDF_HASH_SIZE, m_rawsize)) return false; // has the chunk - uint32_t hash = core_crc32(0, (const uint8_t *)&m_rawdata[0], bytes) ^ (uint32_t)m_rawsize; + u32 hash = core_crc32(0, (const u8 *)&m_rawdata[0], bytes) ^ u32(m_rawsize); // create the cached filename, changing the 'F' to a 'C' on the extension std::string cachedname(filename); @@ -523,7 +523,7 @@ bool render_font::load_cached_bdf(const char *filename) // read in the rest of the font if (bytes < m_rawsize) { - uint32_t read = file.read(&m_rawdata[bytes], m_rawsize - bytes); + u32 read = file.read(&m_rawdata[bytes], m_rawsize - bytes); if (read != m_rawsize - bytes) { m_rawdata.clear(); @@ -664,26 +664,26 @@ bool render_font::load_bdf() // load_cached - load a font in cached format //------------------------------------------------- -bool render_font::load_cached(emu_file &file, uint32_t hash) +bool render_font::load_cached(emu_file &file, u32 hash) { // get the file size - uint64_t filesize = file.size(); + u64 filesize = file.size(); // first read the header - uint8_t header[CACHED_HEADER_SIZE]; - uint32_t bytes_read = file.read(header, CACHED_HEADER_SIZE); + u8 header[CACHED_HEADER_SIZE]; + u32 bytes_read = file.read(header, CACHED_HEADER_SIZE); if (bytes_read != CACHED_HEADER_SIZE) return false; // validate the header if (header[0] != 'f' || header[1] != 'o' || header[2] != 'n' || header[3] != 't') return false; - if (hash && (header[4] != (uint8_t)(hash >> 24) || header[5] != (uint8_t)(hash >> 16) || header[6] != (uint8_t)(hash >> 8) || header[7] != (uint8_t)hash)) + if (hash && (header[4] != u8(hash >> 24) || header[5] != u8(hash >> 16) || header[6] != u8(hash >> 8) || header[7] != u8(hash))) return false; m_height = (header[8] << 8) | header[9]; m_scale = 1.0f / (float)m_height; - m_yoffs = (int16_t)((header[10] << 8) | header[11]); - uint32_t numchars = (header[12] << 24) | (header[13] << 16) | (header[14] << 8) | header[15]; + m_yoffs = s16((header[10] << 8) | header[11]); + u32 numchars = (header[12] << 24) | (header[13] << 16) | (header[14] << 8) | header[15]; if (filesize - CACHED_HEADER_SIZE < numchars * CACHED_CHAR_SIZE) return false; @@ -697,10 +697,10 @@ bool render_font::load_cached(emu_file &file, uint32_t hash) } // extract the data from the data - uint64_t offset = numchars * CACHED_CHAR_SIZE; + u64 offset = numchars * CACHED_CHAR_SIZE; for (int chindex = 0; chindex < numchars; chindex++) { - const uint8_t *info = reinterpret_cast(&m_rawdata[chindex * CACHED_CHAR_SIZE]); + const u8 *info = reinterpret_cast(&m_rawdata[chindex * CACHED_CHAR_SIZE]); int chnum = (info[0] << 8) | info[1]; // if we don't have a subtable yet, make one @@ -710,8 +710,8 @@ bool render_font::load_cached(emu_file &file, uint32_t hash) // fill in the entry glyph &gl = m_glyphs[chnum / 256][chnum % 256]; gl.width = (info[2] << 8) | info[3]; - gl.xoffs = (int16_t)((info[4] << 8) | info[5]); - gl.yoffs = (int16_t)((info[6] << 8) | info[7]); + gl.xoffs = s16((info[4] << 8) | info[5]); + gl.yoffs = s16((info[6] << 8) | info[7]); gl.bmwidth = (info[8] << 8) | info[9]; gl.bmheight = (info[10] << 8) | info[11]; gl.rawdata = &m_rawdata[offset]; @@ -735,7 +735,7 @@ bool render_font::load_cached(emu_file &file, uint32_t hash) // save_cached - save a font in cached format //------------------------------------------------- -bool render_font::save_cached(const char *filename, uint32_t hash) +bool render_font::save_cached(const char *filename, u32 hash) { osd_printf_warning("Generating cached BDF font...\n"); @@ -760,13 +760,13 @@ bool render_font::save_cached(const char *filename, uint32_t hash) try { // allocate an array to hold the character data - std::vector chartable(numchars * CACHED_CHAR_SIZE, 0); + std::vector chartable(numchars * CACHED_CHAR_SIZE, 0); // allocate a temp buffer to compress into - std::vector tempbuffer(65536); + std::vector tempbuffer(65536); // write the header - uint8_t *dest = &tempbuffer[0]; + u8 *dest = &tempbuffer[0]; *dest++ = 'f'; *dest++ = 'o'; *dest++ = 'n'; @@ -784,7 +784,7 @@ bool render_font::save_cached(const char *filename, uint32_t hash) *dest++ = numchars >> 8; *dest++ = numchars & 0xff; assert(dest == &tempbuffer[CACHED_HEADER_SIZE]); - uint32_t bytes_written = file.write(&tempbuffer[0], CACHED_HEADER_SIZE); + u32 bytes_written = file.write(&tempbuffer[0], CACHED_HEADER_SIZE); if (bytes_written != dest - &tempbuffer[0]) throw emu_fatalerror("Error writing cached file"); @@ -805,14 +805,14 @@ bool render_font::save_cached(const char *filename, uint32_t hash) { // write the data to the tempbuffer dest = &tempbuffer[0]; - uint8_t accum = 0; - uint8_t accbit = 7; + u8 accum = 0; + u8 accbit = 7; // bit-encode the character data for (int y = 0; y < gl.bmheight; y++) { int desty = y + m_height + m_yoffs - gl.yoffs - gl.bmheight; - const uint32_t *src = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : nullptr; + const u32 *src = (desty >= 0 && desty < m_height) ? &gl.bitmap.pix32(desty) : nullptr; for (int x = 0; x < gl.bmwidth; x++) { if (src != nullptr && rgb_t(src[x]).a() != 0) diff --git a/src/emu/rendfont.h b/src/emu/rendfont.h index 7510efb8c0a..558b5c55aa5 100644 --- a/src/emu/rendfont.h +++ b/src/emu/rendfont.h @@ -38,7 +38,7 @@ public: render_manager &manager() const { return m_manager; } // size queries - int32_t pixel_height() const { return m_height; } + s32 pixel_height() const { return m_height; } float char_width(float height, float aspect, char32_t ch); float string_width(float height, float aspect, const char *string); float utf8string_width(float height, float aspect, const char *utf8string); @@ -59,9 +59,9 @@ private: rawdata(nullptr), texture(nullptr) { } - int32_t width; // width from this character to the next - int32_t xoffs, yoffs; // X and Y offset from baseline to top,left of bitmap - int32_t bmwidth, bmheight; // width and height of bitmap + s32 width; // width from this character to the next + s32 xoffs, yoffs; // X and Y offset from baseline to top,left of bitmap + s32 bmwidth, bmheight; // width and height of bitmap const char * rawdata; // pointer to the raw data for this one render_texture * texture; // pointer to a texture for rendering and sizing bitmap_argb32 bitmap; // pointer to the bitmap containing the raw data @@ -84,9 +84,9 @@ private: void char_expand(char32_t chnum, glyph &ch); bool load_cached_bdf(const char *filename); bool load_bdf(); - bool load_cached(emu_file &file, uint32_t hash); - bool load_cached_cmd(emu_file &file, uint32_t hash); - bool save_cached(const char *filename, uint32_t hash); + bool load_cached(emu_file &file, u32 hash); + bool load_cached_cmd(emu_file &file, u32 hash); + bool save_cached(const char *filename, u32 hash); void render_font_command_glyph(); @@ -98,7 +98,7 @@ private: float m_scale; // 1 / height precomputed glyph *m_glyphs[17*256]; // array of glyph subtables std::vector m_rawdata; // pointer to the raw data for the font - uint64_t m_rawsize; // size of the raw font data + u64 m_rawsize; // size of the raw font data std::unique_ptr m_osdfont; // handle to the OSD font int m_height_cmd; // height of the font, from ascent to descent @@ -109,7 +109,7 @@ private: // constants static const int CACHED_CHAR_SIZE = 12; static const int CACHED_HEADER_SIZE = 16; - static const uint64_t CACHED_BDF_HASH_SIZE = 1024; + static const u64 CACHED_BDF_HASH_SIZE = 1024; }; void convert_command_glyph(std::string &s); diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp index 3a606eeeac3..b917b958063 100644 --- a/src/emu/rendlay.cpp +++ b/src/emu/rendlay.cpp @@ -867,15 +867,15 @@ void layout_element::reel_component::draw(running_machine &machine, bitmap_argb3 int use_state = (state + m_stateoffset) % max_state_used; // compute premultiplied colors - uint32_t r = color().r * 255.0f; - uint32_t g = color().g * 255.0f; - uint32_t b = color().b * 255.0f; - uint32_t a = color().a * 255.0f; + u32 r = color().r * 255.0f; + u32 g = color().g * 255.0f; + u32 b = color().b * 255.0f; + u32 a = color().a * 255.0f; // get the width of the string render_font *font = machine.render().font_alloc("default"); float aspect = 1.0f; - int32_t width; + s32 width; int curry = 0; int num_shown = m_numsymbolsvisible; @@ -914,7 +914,7 @@ void layout_element::reel_component::draw(running_machine &machine, bitmap_argb3 aspect *= 0.9f; } - int32_t curx; + s32 curx; curx = bounds.min_x + (bounds.width() - width) / 2; if (m_file[fruit]) @@ -935,14 +935,14 @@ void layout_element::reel_component::draw(running_machine &machine, bitmap_argb3 if (effy >= bounds.min_y && effy <= bounds.max_y) { - uint32_t *src = &tempbitmap2.pix32(y); - uint32_t *d = &dest.pix32(effy); + u32 *src = &tempbitmap2.pix32(y); + u32 *d = &dest.pix32(effy); for (int x = 0; x < dest.width(); x++) { int effx = x; if (effx >= bounds.min_x && effx <= bounds.max_x) { - uint32_t spix = rgb_t(src[x]).a(); + u32 spix = rgb_t(src[x]).a(); if (spix != 0) { d[effx] = src[x]; @@ -982,21 +982,21 @@ void layout_element::reel_component::draw(running_machine &machine, bitmap_argb3 if (effy >= bounds.min_y && effy <= bounds.max_y) { - uint32_t *src = &tempbitmap.pix32(y); - uint32_t *d = &dest.pix32(effy); + u32 *src = &tempbitmap.pix32(y); + u32 *d = &dest.pix32(effy); for (int x = 0; x < chbounds.width(); x++) { int effx = curx + x + chbounds.min_x; if (effx >= bounds.min_x && effx <= bounds.max_x) { - uint32_t spix = rgb_t(src[x]).a(); + u32 spix = rgb_t(src[x]).a(); if (spix != 0) { rgb_t dpix = d[effx]; - uint32_t ta = (a * (spix + 1)) >> 8; - uint32_t tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8; - uint32_t tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8; - uint32_t tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8; + u32 ta = (a * (spix + 1)) >> 8; + u32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8; + u32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8; + u32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8; d[effx] = rgb_t(tr, tg, tb); } } @@ -1027,15 +1027,15 @@ void layout_element::reel_component::draw_beltreel(running_machine &machine, bit int use_state = (state + m_stateoffset) % max_state_used; // compute premultiplied colors - uint32_t r = color().r * 255.0f; - uint32_t g = color().g * 255.0f; - uint32_t b = color().b * 255.0f; - uint32_t a = color().a * 255.0f; + u32 r = color().r * 255.0f; + u32 g = color().g * 255.0f; + u32 b = color().b * 255.0f; + u32 a = color().a * 255.0f; // get the width of the string render_font *font = machine.render().font_alloc("default"); float aspect = 1.0f; - int32_t width; + s32 width; int currx = 0; int num_shown = m_numsymbolsvisible; @@ -1072,7 +1072,7 @@ void layout_element::reel_component::draw_beltreel(running_machine &machine, bit aspect *= 0.9f; } - int32_t curx; + s32 curx; curx = bounds.min_x; if (m_file[fruit]) @@ -1093,14 +1093,14 @@ void layout_element::reel_component::draw_beltreel(running_machine &machine, bit if (effy >= bounds.min_y && effy <= bounds.max_y) { - uint32_t *src = &tempbitmap2.pix32(y); - uint32_t *d = &dest.pix32(effy); + u32 *src = &tempbitmap2.pix32(y); + u32 *d = &dest.pix32(effy); for (int x = 0; x < ourwidth/num_shown; x++) { int effx = basex + x; if (effx >= bounds.min_x && effx <= bounds.max_x) { - uint32_t spix = rgb_t(src[x]).a(); + u32 spix = rgb_t(src[x]).a(); if (spix != 0) { d[effx] = src[x]; @@ -1142,21 +1142,21 @@ void layout_element::reel_component::draw_beltreel(running_machine &machine, bit if (effy >= bounds.min_y && effy <= bounds.max_y) { - uint32_t *src = &tempbitmap.pix32(y); - uint32_t *d = &dest.pix32(effy); + u32 *src = &tempbitmap.pix32(y); + u32 *d = &dest.pix32(effy); for (int x = 0; x < chbounds.width(); x++) { int effx = basex + curx + x; if (effx >= bounds.min_x && effx <= bounds.max_x) { - uint32_t spix = rgb_t(src[x]).a(); + u32 spix = rgb_t(src[x]).a(); if (spix != 0) { rgb_t dpix = d[effx]; - uint32_t ta = (a * (spix + 1)) >> 8; - uint32_t tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8; - uint32_t tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8; - uint32_t tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8; + u32 ta = (a * (spix + 1)) >> 8; + u32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8; + u32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8; + u32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8; d[effx] = rgb_t(tr, tg, tb); } } @@ -1825,19 +1825,19 @@ layout_element::rect_component::rect_component(running_machine &machine, xml_dat void layout_element::rect_component::draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) { // compute premultiplied colors - uint32_t r = color().r * color().a * 255.0f; - uint32_t g = color().g * color().a * 255.0f; - uint32_t b = color().b * color().a * 255.0f; - uint32_t inva = (1.0f - color().a) * 255.0f; + u32 r = color().r * color().a * 255.0f; + u32 g = color().g * color().a * 255.0f; + u32 b = color().b * color().a * 255.0f; + u32 inva = (1.0f - color().a) * 255.0f; // iterate over X and Y - for (uint32_t y = bounds.min_y; y <= bounds.max_y; y++) + for (u32 y = bounds.min_y; y <= bounds.max_y; y++) { - for (uint32_t x = bounds.min_x; x <= bounds.max_x; x++) + for (u32 x = bounds.min_x; x <= bounds.max_x; x++) { - uint32_t finalr = r; - uint32_t finalg = g; - uint32_t finalb = b; + u32 finalr = r; + u32 finalg = g; + u32 finalb = b; // if we're translucent, add in the destination pixel contribution if (inva > 0) @@ -1872,10 +1872,10 @@ layout_element::disk_component::disk_component(running_machine &machine, xml_dat void layout_element::disk_component::draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) { // compute premultiplied colors - uint32_t r = color().r * color().a * 255.0f; - uint32_t g = color().g * color().a * 255.0f; - uint32_t b = color().b * color().a * 255.0f; - uint32_t inva = (1.0f - color().a) * 255.0f; + u32 r = color().r * color().a * 255.0f; + u32 g = color().g * color().a * 255.0f; + u32 b = color().b * color().a * 255.0f; + u32 inva = (1.0f - color().a) * 255.0f; // find the center float xcenter = float(bounds.xcenter()); @@ -1885,21 +1885,21 @@ void layout_element::disk_component::draw(running_machine &machine, bitmap_argb3 float ooyradius2 = 1.0f / (yradius * yradius); // iterate over y - for (uint32_t y = bounds.min_y; y <= bounds.max_y; y++) + for (u32 y = bounds.min_y; y <= bounds.max_y; y++) { float ycoord = ycenter - ((float)y + 0.5f); float xval = xradius * sqrtf(1.0f - (ycoord * ycoord) * ooyradius2); // compute left/right coordinates - int32_t left = (int32_t)(xcenter - xval + 0.5f); - int32_t right = (int32_t)(xcenter + xval + 0.5f); + s32 left = s32(xcenter - xval + 0.5f); + s32 right = s32(xcenter + xval + 0.5f); // draw this scanline - for (uint32_t x = left; x < right; x++) + for (u32 x = left; x < right; x++) { - uint32_t finalr = r; - uint32_t finalg = g; - uint32_t finalb = b; + u32 finalr = r; + u32 finalg = g; + u32 finalb = b; // if we're translucent, add in the destination pixel contribution if (inva > 0) @@ -1924,14 +1924,14 @@ void layout_element::disk_component::draw(running_machine &machine, bitmap_argb3 void layout_element::component::draw_text(render_font &font, bitmap_argb32 &dest, const rectangle &bounds, const char *str, int align) { // compute premultiplied colors - uint32_t r = color().r * 255.0f; - uint32_t g = color().g * 255.0f; - uint32_t b = color().b * 255.0f; - uint32_t a = color().a * 255.0f; + u32 r = color().r * 255.0f; + u32 g = color().g * 255.0f; + u32 b = color().b * 255.0f; + u32 a = color().a * 255.0f; // get the width of the string float aspect = 1.0f; - int32_t width; + s32 width; while (1) { @@ -1942,7 +1942,7 @@ void layout_element::component::draw_text(render_font &font, bitmap_argb32 &dest } // get alignment - int32_t curx; + s32 curx; switch (align) { // left @@ -1988,21 +1988,21 @@ void layout_element::component::draw_text(render_font &font, bitmap_argb32 &dest int effy = bounds.min_y + y; if (effy >= bounds.min_y && effy <= bounds.max_y) { - uint32_t *src = &tempbitmap.pix32(y); - uint32_t *d = &dest.pix32(effy); + u32 *src = &tempbitmap.pix32(y); + u32 *d = &dest.pix32(effy); for (int x = 0; x < chbounds.width(); x++) { int effx = curx + x + chbounds.min_x; if (effx >= bounds.min_x && effx <= bounds.max_x) { - uint32_t spix = rgb_t(src[x]).a(); + u32 spix = rgb_t(src[x]).a(); if (spix != 0) { rgb_t dpix = d[effx]; - uint32_t ta = (a * (spix + 1)) >> 8; - uint32_t tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8; - uint32_t tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8; - uint32_t tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8; + u32 ta = (a * (spix + 1)) >> 8; + u32 tr = (r * ta + dpix.r() * (0x100 - ta)) >> 8; + u32 tg = (g * ta + dpix.g() * (0x100 - ta)) >> 8; + u32 tb = (b * ta + dpix.b() * (0x100 - ta)) >> 8; d[effx] = rgb_t(tr, tg, tb); } } @@ -2028,8 +2028,8 @@ void layout_element::component::draw_segment_horizontal_caps(bitmap_argb32 &dest // loop over the width of the segment for (int y = 0; y < width / 2; y++) { - uint32_t *d0 = &dest.pix32(midy - y); - uint32_t *d1 = &dest.pix32(midy + y); + u32 *d0 = &dest.pix32(midy - y); + u32 *d1 = &dest.pix32(midy + y); int ty = (y < width / 8) ? width / 8 : y; // loop over the length of the segment @@ -2061,8 +2061,8 @@ void layout_element::component::draw_segment_vertical_caps(bitmap_argb32 &dest, // loop over the width of the segment for (int x = 0; x < width / 2; x++) { - uint32_t *d0 = &dest.pix32(0, midx - x); - uint32_t *d1 = &dest.pix32(0, midx + x); + u32 *d0 = &dest.pix32(0, midx - x); + u32 *d1 = &dest.pix32(0, midx + x); int tx = (x < width / 8) ? width / 8 : x; // loop over the length of the segment @@ -2098,7 +2098,7 @@ void layout_element::component::draw_segment_diagonal_1(bitmap_argb32 &dest, int for (int x = minx; x < maxx; x++) if (x >= 0 && x < dest.width()) { - uint32_t *d = &dest.pix32(0, x); + u32 *d = &dest.pix32(0, x); int step = (x - minx) * ratio; for (int y = maxy - width - step; y < maxy - step; y++) @@ -2123,7 +2123,7 @@ void layout_element::component::draw_segment_diagonal_2(bitmap_argb32 &dest, int for (int x = minx; x < maxx; x++) if (x >= 0 && x < dest.width()) { - uint32_t *d = &dest.pix32(0, x); + u32 *d = &dest.pix32(0, x); int step = (x - minx) * ratio; for (int y = miny + step; y < miny + step + width; y++) @@ -2144,19 +2144,19 @@ void layout_element::component::draw_segment_decimal(bitmap_argb32 &dest, int mi float ooradius2 = 1.0f / (float)(width * width); // iterate over y - for (uint32_t y = 0; y <= width; y++) + for (u32 y = 0; y <= width; y++) { - uint32_t *d0 = &dest.pix32(midy - y); - uint32_t *d1 = &dest.pix32(midy + y); + u32 *d0 = &dest.pix32(midy - y); + u32 *d1 = &dest.pix32(midy + y); float xval = width * sqrt(1.0f - (float)(y * y) * ooradius2); - int32_t left, right; + s32 left, right; // compute left/right coordinates - left = midx - (int32_t)(xval + 0.5f); - right = midx + (int32_t)(xval + 0.5f); + left = midx - s32(xval + 0.5f); + right = midx + s32(xval + 0.5f); // draw this scanline - for (uint32_t x = left; x < right; x++) + for (u32 x = left; x < right; x++) d0[x] = d1[x] = color; } } @@ -2175,7 +2175,7 @@ void layout_element::component::draw_segment_comma(bitmap_argb32 &dest, int minx // draw line for (int x = minx; x < maxx; x++) { - uint32_t *d = &dest.pix32(0, x); + u32 *d = &dest.pix32(0, x); int step = (x - minx) * ratio; for (int y = maxy; y < maxy - width - step; y--) @@ -2192,7 +2192,7 @@ void layout_element::component::apply_skew(bitmap_argb32 &dest, int skewwidth) { for (int y = 0; y < dest.height(); y++) { - uint32_t *destrow = &dest.pix32(y); + u32 *destrow = &dest.pix32(y); int offs = skewwidth * (dest.height() - y) / dest.height(); for (int x = dest.width() - skewwidth - 1; x >= 0; x--) destrow[x + offs] = destrow[x]; diff --git a/src/emu/rendutil.cpp b/src/emu/rendutil.cpp index be1eed481d2..015a08e4e11 100644 --- a/src/emu/rendutil.cpp +++ b/src/emu/rendutil.cpp @@ -19,8 +19,8 @@ ***************************************************************************/ /* utilities */ -static void resample_argb_bitmap_average(uint32_t *dest, uint32_t drowpixels, uint32_t dwidth, uint32_t dheight, const uint32_t *source, uint32_t srowpixels, uint32_t swidth, uint32_t sheight, const render_color &color, uint32_t dx, uint32_t dy); -static void resample_argb_bitmap_bilinear(uint32_t *dest, uint32_t drowpixels, uint32_t dwidth, uint32_t dheight, const uint32_t *source, uint32_t srowpixels, uint32_t swidth, uint32_t sheight, const render_color &color, uint32_t dx, uint32_t dy); +static void resample_argb_bitmap_average(u32 *dest, u32 drowpixels, u32 dwidth, u32 dheight, const u32 *source, u32 srowpixels, u32 swidth, u32 sheight, const render_color &color, u32 dx, u32 dy); +static void resample_argb_bitmap_bilinear(u32 *dest, u32 drowpixels, u32 dwidth, u32 dheight, const u32 *source, u32 srowpixels, u32 swidth, u32 sheight, const render_color &color, u32 dx, u32 dy); static bool copy_png_to_bitmap(bitmap_argb32 &bitmap, const png_info *png); static bool copy_png_alpha_to_bitmap(bitmap_argb32 &bitmap, const png_info *png); @@ -41,15 +41,15 @@ void render_resample_argb_bitmap_hq(bitmap_argb32 &dest, bitmap_argb32 &source, return; /* adjust the source base */ - const uint32_t *sbase = &source.pix32(0); + const u32 *sbase = &source.pix32(0); /* determine the steppings */ - uint32_t swidth = source.width(); - uint32_t sheight = source.height(); - uint32_t dwidth = dest.width(); - uint32_t dheight = dest.height(); - uint32_t dx = (swidth << 12) / dwidth; - uint32_t dy = (sheight << 12) / dheight; + u32 swidth = source.width(); + u32 sheight = source.height(); + u32 dwidth = dest.width(); + u32 dheight = dest.height(); + u32 dx = (swidth << 12) / dwidth; + u32 dy = (sheight << 12) / dheight; /* if the source is higher res than the target, use full averaging */ if (dx > 0x1000 || dy > 0x1000 || force) @@ -65,11 +65,11 @@ void render_resample_argb_bitmap_hq(bitmap_argb32 &dest, bitmap_argb32 &source, all contributing pixels -------------------------------------------------*/ -static void resample_argb_bitmap_average(uint32_t *dest, uint32_t drowpixels, uint32_t dwidth, uint32_t dheight, const uint32_t *source, uint32_t srowpixels, uint32_t swidth, uint32_t sheight, const render_color &color, uint32_t dx, uint32_t dy) +static void resample_argb_bitmap_average(u32 *dest, u32 drowpixels, u32 dwidth, u32 dheight, const u32 *source, u32 srowpixels, u32 swidth, u32 sheight, const render_color &color, u32 dx, u32 dy) { - uint64_t sumscale = (uint64_t)dx * (uint64_t)dy; - uint32_t r, g, b, a; - uint32_t x, y; + u64 sumscale = u64(dx) * u64(dy); + u32 r, g, b, a; + u32 x, y; /* precompute premultiplied R/G/B/A factors */ r = color.r * color.a * 256.0f; @@ -80,22 +80,22 @@ static void resample_argb_bitmap_average(uint32_t *dest, uint32_t drowpixels, ui /* loop over the target vertically */ for (y = 0; y < dheight; y++) { - uint32_t starty = y * dy; + u32 starty = y * dy; /* loop over the target horizontally */ for (x = 0; x < dwidth; x++) { - uint64_t sumr = 0, sumg = 0, sumb = 0, suma = 0; - uint32_t startx = x * dx; - uint32_t xchunk, ychunk; - uint32_t curx, cury; + u64 sumr = 0, sumg = 0, sumb = 0, suma = 0; + u32 startx = x * dx; + u32 xchunk, ychunk; + u32 curx, cury; - uint32_t yremaining = dy; + u32 yremaining = dy; /* accumulate all source pixels that contribute to this pixel */ for (cury = starty; yremaining; cury += ychunk) { - uint32_t xremaining = dx; + u32 xremaining = dx; /* determine the Y contribution, clamping to the amount remaining */ ychunk = 0x1000 - (cury & 0xfff); @@ -106,7 +106,7 @@ static void resample_argb_bitmap_average(uint32_t *dest, uint32_t drowpixels, ui /* loop over all source pixels in the X direction */ for (curx = startx; xremaining; curx += xchunk) { - uint32_t factor; + u32 factor; /* determine the X contribution, clamping to the amount remaining */ xchunk = 0x1000 - (curx & 0xfff); @@ -156,11 +156,11 @@ static void resample_argb_bitmap_average(uint32_t *dest, uint32_t drowpixels, ui sampling via a bilinear filter -------------------------------------------------*/ -static void resample_argb_bitmap_bilinear(uint32_t *dest, uint32_t drowpixels, uint32_t dwidth, uint32_t dheight, const uint32_t *source, uint32_t srowpixels, uint32_t swidth, uint32_t sheight, const render_color &color, uint32_t dx, uint32_t dy) +static void resample_argb_bitmap_bilinear(u32 *dest, u32 drowpixels, u32 dwidth, u32 dheight, const u32 *source, u32 srowpixels, u32 swidth, u32 sheight, const render_color &color, u32 dx, u32 dy) { - uint32_t maxx = swidth << 12, maxy = sheight << 12; - uint32_t r, g, b, a; - uint32_t x, y; + u32 maxx = swidth << 12, maxy = sheight << 12; + u32 r, g, b, a; + u32 x, y; /* precompute premultiplied R/G/B/A factors */ r = color.r * color.a * 256.0f; @@ -171,17 +171,17 @@ static void resample_argb_bitmap_bilinear(uint32_t *dest, uint32_t drowpixels, u /* loop over the target vertically */ for (y = 0; y < dheight; y++) { - uint32_t starty = y * dy; + u32 starty = y * dy; /* loop over the target horizontally */ for (x = 0; x < dwidth; x++) { - uint32_t startx = x * dx; + u32 startx = x * dx; rgb_t pix0, pix1, pix2, pix3; - uint32_t sumr, sumg, sumb, suma; - uint32_t nextx, nexty; - uint32_t curx, cury; - uint32_t factor; + u32 sumr, sumg, sumb, suma; + u32 nextx, nexty; + u32 curx, cury; + u32 factor; /* adjust start to the center; note that this math will tend to produce */ /* negative results on the first pixel, which is why we clamp below */ @@ -194,13 +194,13 @@ static void resample_argb_bitmap_bilinear(uint32_t *dest, uint32_t drowpixels, u /* fetch the four relevant pixels */ pix0 = pix1 = pix2 = pix3 = 0; - if ((int32_t)cury >= 0 && cury < maxy && (int32_t)curx >= 0 && curx < maxx) + if (s32(cury) >= 0 && cury < maxy && s32(curx) >= 0 && curx < maxx) pix0 = source[(cury >> 12) * srowpixels + (curx >> 12)]; - if ((int32_t)cury >= 0 && cury < maxy && (int32_t)nextx >= 0 && nextx < maxx) + if (s32(cury) >= 0 && cury < maxy && s32(nextx) >= 0 && nextx < maxx) pix1 = source[(cury >> 12) * srowpixels + (nextx >> 12)]; - if ((int32_t)nexty >= 0 && nexty < maxy && (int32_t)curx >= 0 && curx < maxx) + if (s32(nexty) >= 0 && nexty < maxy && s32(curx) >= 0 && curx < maxx) pix2 = source[(nexty >> 12) * srowpixels + (curx >> 12)]; - if ((int32_t)nexty >= 0 && nexty < maxy && (int32_t)nextx >= 0 && nextx < maxx) + if (s32(nexty) >= 0 && nexty < maxy && s32(nextx) >= 0 && nextx < maxx) pix3 = source[(nexty >> 12) * srowpixels + (nextx >> 12)]; /* compute the x/y scaling factors */ @@ -267,8 +267,8 @@ bool render_clip_line(render_bounds *bounds, const render_bounds *clip) /* loop until we get a final result */ while (1) { - uint8_t code0 = 0, code1 = 0; - uint8_t thiscode; + u8 code0 = 0, code1 = 0; + u8 thiscode; float x, y; /* compute Cohen Sutherland bits for first coordinate */ @@ -569,7 +569,7 @@ void render_load_jpeg(bitmap_argb32 &bitmap, emu_file &file, const char *dirname jpeg_create_decompress(&cinfo); // allocates a buffer for the image - uint32_t jpg_size = file.size(); + u32 jpg_size = file.size(); std::unique_ptr jpg_buffer = std::make_unique(jpg_size); // read data from the file and set them in the buffer @@ -696,8 +696,8 @@ bool render_load_png(bitmap_argb32 &bitmap, emu_file &file, const char *dirname, static bool copy_png_to_bitmap(bitmap_argb32 &bitmap, const png_info *png) { - uint8_t accumalpha = 0xff; - uint8_t *src; + u8 accumalpha = 0xff; + u8 *src; int x, y; /* handle 8bpp palettized case */ @@ -709,7 +709,7 @@ static bool copy_png_to_bitmap(bitmap_argb32 &bitmap, const png_info *png) for (x = 0; x < png->width; x++, src++) { /* determine alpha and expand to 32bpp */ - uint8_t alpha = (*src < png->num_trans) ? png->trans[*src] : 0xff; + u8 alpha = (*src < png->num_trans) ? png->trans[*src] : 0xff; accumalpha &= alpha; bitmap.pix32(y, x) = rgb_t(alpha, png->palette[*src * 3], png->palette[*src * 3 + 1], png->palette[*src * 3 + 2]); } @@ -760,8 +760,8 @@ static bool copy_png_to_bitmap(bitmap_argb32 &bitmap, const png_info *png) static bool copy_png_alpha_to_bitmap(bitmap_argb32 &bitmap, const png_info *png) { - uint8_t accumalpha = 0xff; - uint8_t *src; + u8 accumalpha = 0xff; + u8 *src; int x, y; /* handle 8bpp palettized case */ @@ -773,7 +773,7 @@ static bool copy_png_alpha_to_bitmap(bitmap_argb32 &bitmap, const png_info *png) for (x = 0; x < png->width; x++, src++) { rgb_t pixel = bitmap.pix32(y, x); - uint8_t alpha = rgb_t(png->palette[*src * 3], png->palette[*src * 3 + 1], png->palette[*src * 3 + 2]).brightness(); + u8 alpha = rgb_t(png->palette[*src * 3], png->palette[*src * 3 + 1], png->palette[*src * 3 + 2]).brightness(); accumalpha &= alpha; bitmap.pix32(y, x) = rgb_t(alpha, pixel.r(), pixel.g(), pixel.b()); } @@ -802,7 +802,7 @@ static bool copy_png_alpha_to_bitmap(bitmap_argb32 &bitmap, const png_info *png) for (x = 0; x < png->width; x++, src += 3) { rgb_t pixel = bitmap.pix32(y, x); - uint8_t alpha = rgb_t(src[0], src[1], src[2]).brightness(); + u8 alpha = rgb_t(src[0], src[1], src[2]).brightness(); accumalpha &= alpha; bitmap.pix32(y, x) = rgb_t(alpha, pixel.r(), pixel.g(), pixel.b()); } @@ -817,7 +817,7 @@ static bool copy_png_alpha_to_bitmap(bitmap_argb32 &bitmap, const png_info *png) for (x = 0; x < png->width; x++, src += 4) { rgb_t pixel = bitmap.pix32(y, x); - uint8_t alpha = rgb_t(src[0], src[1], src[2]).brightness(); + u8 alpha = rgb_t(src[0], src[1], src[2]).brightness(); accumalpha &= alpha; bitmap.pix32(y, x) = rgb_t(alpha, pixel.r(), pixel.g(), pixel.b()); } diff --git a/src/emu/rendutil.h b/src/emu/rendutil.h index dd4d8f1edf3..d1908edbafe 100644 --- a/src/emu/rendutil.h +++ b/src/emu/rendutil.h @@ -190,11 +190,11 @@ static inline float apply_brightness_contrast_gamma_fp(float srcval, float brigh a single RGB component -------------------------------------------------*/ -static inline uint8_t apply_brightness_contrast_gamma(uint8_t src, float brightness, float contrast, float gamma) +static inline u8 apply_brightness_contrast_gamma(u8 src, float brightness, float contrast, float gamma) { float srcval = (float)src * (1.0f / 255.0f); float result = apply_brightness_contrast_gamma_fp(srcval, brightness, contrast, gamma); - return (uint8_t)(result * 255.0f); + return u8(result * 255.0f); } diff --git a/src/emu/romentry.cpp b/src/emu/romentry.cpp index 11a80b20254..01df77c344a 100644 --- a/src/emu/romentry.cpp +++ b/src/emu/romentry.cpp @@ -50,7 +50,7 @@ static std::string hashdata_from_tiny_rom_entry(const tiny_rom_entry &ent) // ctor (with move constructors) //------------------------------------------------- -rom_entry::rom_entry(std::string &&name, std::string &&hashdata, uint32_t offset, uint32_t length, uint32_t flags) +rom_entry::rom_entry(std::string &&name, std::string &&hashdata, u32 offset, u32 length, u32 flags) : m_name(std::move(name)) , m_hashdata(std::move(hashdata)) , m_offset(offset) diff --git a/src/emu/romentry.h b/src/emu/romentry.h index 37ef23c6202..eaa426da33a 100644 --- a/src/emu/romentry.h +++ b/src/emu/romentry.h @@ -8,11 +8,12 @@ *********************************************************************/ -#ifndef MAME_EMU_ROMENTRY_H_ -#define MAME_EMU_ROMENTRY_H_ +#ifndef MAME_EMU_ROMENTRY_H +#define MAME_EMU_ROMENTRY_H #include +#include "emucore.h" #include "osdcomm.h" /*************************************************************************** @@ -121,9 +122,9 @@ struct tiny_rom_entry { const char *name; const char *hashdata; - uint32_t offset; - uint32_t length; - uint32_t flags; + u32 offset; + u32 length; + u32 flags; }; @@ -133,7 +134,7 @@ class rom_entry { public: rom_entry(const tiny_rom_entry &ent); - rom_entry(std::string &&name, std::string &&hashdata, uint32_t offset, uint32_t length, uint32_t flags); + rom_entry(std::string &&name, std::string &&hashdata, u32 offset, u32 length, u32 flags); rom_entry(rom_entry const &) = default; rom_entry(rom_entry &&) = default; rom_entry &operator=(rom_entry const &) = default; @@ -142,18 +143,18 @@ public: // accessors const std::string &name() const { return m_name; } const std::string &hashdata() const { return m_hashdata; } - uint32_t offset() const { return m_offset; } - uint32_t length() const { return m_length; } - uint32_t flags() const { return m_flags; } - void set_flags(uint32_t flags) { m_flags = flags; } + u32 offset() const { return m_offset; } + u32 length() const { return m_length; } + u32 flags() const { return m_flags; } + void set_flags(u32 flags) { m_flags = flags; } private: std::string m_name; std::string m_hashdata; - uint32_t m_offset; - uint32_t m_length; - uint32_t m_flags; + u32 m_offset; + u32 m_length; + u32 m_flags; }; -#endif // MAME_EMU_ROMENTRY_H_ +#endif // MAME_EMU_ROMENTRY_H diff --git a/src/emu/romload.cpp b/src/emu/romload.cpp index 53d3ffb673d..f2ca54705a7 100644 --- a/src/emu/romload.cpp +++ b/src/emu/romload.cpp @@ -40,7 +40,7 @@ static osd_file::error common_process_file(emu_options &options, const char *loc return filerr; } -std::unique_ptr common_process_file(emu_options &options, const char *location, bool has_crc, uint32_t crc, const rom_entry *romp, osd_file::error &filerr) +std::unique_ptr common_process_file(emu_options &options, const char *location, bool has_crc, u32 crc, const rom_entry *romp, osd_file::error &filerr) { auto image_file = std::make_unique(options.media_path(), OPEN_FLAG_READ); @@ -184,14 +184,14 @@ std::string rom_parameter_value(const rom_entry *romp) file given the ROM description -------------------------------------------------*/ -uint32_t rom_file_size(const rom_entry *romp) +u32 rom_file_size(const rom_entry *romp) { - uint32_t maxlength = 0; + u32 maxlength = 0; /* loop until we run out of reloads */ do { - uint32_t curlength; + u32 curlength; /* loop until we run out of continues/ignores */ curlength = ROM_GETLENGTH(romp++); @@ -343,7 +343,7 @@ void rom_load_manager::count_roms() random data -------------------------------------------------*/ -void rom_load_manager::fill_random(uint8_t *base, uint32_t length) +void rom_load_manager::fill_random(u8 *base, u32 length) { while (length--) *base++ = machine().rand(); @@ -414,14 +414,14 @@ void rom_load_manager::dump_wrong_and_correct_checksums(const util::hash_collect and hash signatures of a file -------------------------------------------------*/ -void rom_load_manager::verify_length_and_hash(const char *name, uint32_t explength, const util::hash_collection &hashes) +void rom_load_manager::verify_length_and_hash(const char *name, u32 explength, const util::hash_collection &hashes) { /* we've already complained if there is no file */ if (m_file == nullptr) return; /* verify length */ - uint32_t actlength = m_file->size(); + u32 actlength = m_file->size(); if (explength != actlength) { m_errorstring.append(string_format("%s WRONG LENGTH (expected: %08x found: %08x)\n", name, explength, actlength)); @@ -462,7 +462,7 @@ void rom_load_manager::display_loading_rom_message(const char *name, bool from_l char buffer[200]; if (name != nullptr) - sprintf(buffer, "%s (%d%%)", from_list ? "Loading Software" : "Loading Machine", (uint32_t)(100 * (uint64_t)m_romsloadedsize / (uint64_t)m_romstotalsize)); + sprintf(buffer, "%s (%d%%)", from_list ? "Loading Software" : "Loading Machine", u32(100 * u64(m_romsloadedsize) / u64(m_romstotalsize))); else sprintf(buffer, "Loading Complete"); @@ -506,7 +506,7 @@ void rom_load_manager::display_rom_load_results(bool from_list) void rom_load_manager::region_post_process(const char *rgntag, bool invert) { memory_region *region = machine().root_device().memregion(rgntag); - uint8_t *base; + u8 *base; int i, j; // do nothing if no region @@ -531,7 +531,7 @@ void rom_load_manager::region_post_process(const char *rgntag, bool invert) int datawidth = region->bytewidth(); for (i = 0, base = region->base(); i < region->bytes(); i += datawidth) { - uint8_t temp[8]; + u8 temp[8]; memcpy(temp, base, datawidth); for (j = datawidth - 1; j >= 0; j--) *base++ = temp[j]; @@ -548,14 +548,14 @@ void rom_load_manager::region_post_process(const char *rgntag, bool invert) int rom_load_manager::open_rom_file(const char *regiontag, const rom_entry *romp, std::string &tried_file_names, bool from_list) { osd_file::error filerr = osd_file::error::NOT_FOUND; - uint32_t romsize = rom_file_size(romp); + u32 romsize = rom_file_size(romp); tried_file_names = ""; /* update status display */ display_loading_rom_message(ROM_GETNAME(romp), from_list); /* extract CRC to use for searching */ - uint32_t crc = 0; + u32 crc = 0; bool has_crc = util::hash_collection(ROM_GETHASHDATA(romp)).crc(crc); /* attempt reading up the chain through the parents. It automatically also @@ -663,7 +663,7 @@ int rom_load_manager::open_rom_file(const char *regiontag, const rom_entry *romp random data for a nullptr file -------------------------------------------------*/ -int rom_load_manager::rom_fread(uint8_t *buffer, int length, const rom_entry *parent_region) +int rom_load_manager::rom_fread(u8 *buffer, int length, const rom_entry *parent_region) { /* files just pass through */ if (m_file != nullptr) @@ -691,8 +691,8 @@ int rom_load_manager::read_rom_data(const rom_entry *parent_region, const rom_en int skip = ROM_GETSKIPCOUNT(romp); int reversed = ROM_ISREVERSED(romp); int numgroups = (numbytes + groupsize - 1) / groupsize; - uint8_t *base = m_region->base() + ROM_GETOFFSET(romp); - uint32_t tempbufsize; + u8 *base = m_region->base() + ROM_GETOFFSET(romp); + u32 tempbufsize; int i; LOG(("Loading ROM data: offs=%X len=%X mask=%02X group=%d skip=%d reverse=%d\n", ROM_GETOFFSET(romp), numbytes, datamask, groupsize, skip, reversed)); @@ -715,7 +715,7 @@ int rom_load_manager::read_rom_data(const rom_entry *parent_region, const rom_en /* use a temporary buffer for complex loads */ tempbufsize = std::min(TEMPBUFFER_MAX_SIZE, numbytes); - std::vector tempbuf(tempbufsize); + std::vector tempbuf(tempbufsize); /* chunky reads for complex loads */ skip += groupsize; @@ -723,7 +723,7 @@ int rom_load_manager::read_rom_data(const rom_entry *parent_region, const rom_en { int evengroupcount = (tempbufsize / groupsize) * groupsize; int bytesleft = (numbytes > evengroupcount) ? evengroupcount : numbytes; - uint8_t *bufptr = &tempbuf[0]; + u8 *bufptr = &tempbuf[0]; /* read as much as we can */ LOG((" Reading %X bytes into buffer\n", bytesleft)); @@ -799,9 +799,9 @@ int rom_load_manager::read_rom_data(const rom_entry *parent_region, const rom_en void rom_load_manager::fill_rom_data(const rom_entry *romp) { - uint32_t numbytes = ROM_GETLENGTH(romp); + u32 numbytes = ROM_GETLENGTH(romp); int skip = ROM_GETSKIPCOUNT(romp); - uint8_t *base = m_region->base() + ROM_GETOFFSET(romp); + u8 *base = m_region->base() + ROM_GETOFFSET(romp); // make sure we fill within the region space if (ROM_GETOFFSET(romp) + numbytes > m_region->bytes()) @@ -812,7 +812,7 @@ void rom_load_manager::fill_rom_data(const rom_entry *romp) fatalerror("Error in RomModule definition: FILL has an invalid length\n"); // for fill bytes, the byte that gets filled is the first byte of the hashdata string - uint8_t fill_byte = (uint8_t)strtol(ROM_GETHASHDATA(romp), nullptr, 0); + u8 fill_byte = u8(strtol(ROM_GETHASHDATA(romp), nullptr, 0)); // fill the data (filling value is stored in place of the hashdata) if(skip != 0) @@ -831,10 +831,10 @@ void rom_load_manager::fill_rom_data(const rom_entry *romp) void rom_load_manager::copy_rom_data(const rom_entry *romp) { - uint8_t *base = m_region->base() + ROM_GETOFFSET(romp); + u8 *base = m_region->base() + ROM_GETOFFSET(romp); const char *srcrgntag = ROM_GETNAME(romp); - uint32_t numbytes = ROM_GETLENGTH(romp); - uint32_t srcoffs = (uint32_t) strtol(ROM_GETHASHDATA(romp), nullptr, 0); /* srcoffset in place of hashdata */ + u32 numbytes = ROM_GETLENGTH(romp); + u32 srcoffs = u32(strtol(ROM_GETHASHDATA(romp), nullptr, 0)); /* srcoffset in place of hashdata */ /* make sure we copy within the region space */ if (ROM_GETOFFSET(romp) + numbytes > m_region->bytes()) @@ -865,7 +865,7 @@ void rom_load_manager::copy_rom_data(const rom_entry *romp) void rom_load_manager::process_rom_entries(const char *regiontag, const rom_entry *parent_region, const rom_entry *romp, device_t *device, bool from_list) { - uint32_t lastflags = 0; + u32 lastflags = 0; /* loop until we hit the end of this region */ while (!ROMENTRY_ISREGIONEND(romp)) @@ -1223,7 +1223,7 @@ void rom_load_manager::process_disk_entries(const char *regiontag, const rom_ent flags for the given device -------------------------------------------------*/ -void rom_load_manager::normalize_flags_for_device(running_machine &machine, const char *rgntag, uint8_t &width, endianness_t &endian) +void rom_load_manager::normalize_flags_for_device(running_machine &machine, const char *rgntag, u8 &width, endianness_t &endian) { device_t *device = machine.device(rgntag); device_memory_interface *memory; @@ -1280,7 +1280,7 @@ void rom_load_manager::load_software_part_region(device_t &device, software_list const software_info *swinfo = swlist.find(swname); if (swinfo != nullptr) { - uint32_t supported = swinfo->supported(); + u32 supported = swinfo->supported(); if (supported == SOFTWARE_SUPPORTED_PARTIAL) { m_errorstring.append(string_format("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist.list_name())); @@ -1311,7 +1311,7 @@ void rom_load_manager::load_software_part_region(device_t &device, software_list /* loop until we hit the end */ for (region = start_region; region != nullptr; region = rom_next_region(region)) { - uint32_t regionlength = ROMREGION_GETLENGTH(region); + u32 regionlength = ROMREGION_GETLENGTH(region); regiontag = device.subtag(ROMREGION_GETTAG(region)); LOG(("Processing region \"%s\" (length=%X)\n", regiontag.c_str(), regionlength)); @@ -1321,7 +1321,7 @@ void rom_load_manager::load_software_part_region(device_t &device, software_list /* if this is a device region, override with the device width and endianness */ endianness_t endianness = ROMREGION_ISBIGENDIAN(region) ? ENDIANNESS_BIG : ENDIANNESS_LITTLE; - uint8_t width = ROMREGION_GETWIDTH(region) / 8; + u8 width = ROMREGION_GETWIDTH(region) / 8; memory_region *memregion = machine().root_device().memregion(regiontag.c_str()); if (memregion != nullptr) { @@ -1389,7 +1389,7 @@ void rom_load_manager::process_region_list() for (device_t &device : deviter) for (const rom_entry *region = rom_first_region(device); region != nullptr; region = rom_next_region(region)) { - uint32_t regionlength = ROMREGION_GETLENGTH(region); + u32 regionlength = ROMREGION_GETLENGTH(region); regiontag = rom_region_name(device, region); LOG(("Processing region \"%s\" (length=%X)\n", regiontag.c_str(), regionlength)); @@ -1400,7 +1400,7 @@ void rom_load_manager::process_region_list() if (ROMREGION_ISROMDATA(region)) { /* if this is a device region, override with the device width and endianness */ - uint8_t width = ROMREGION_GETWIDTH(region) / 8; + u8 width = ROMREGION_GETWIDTH(region) / 8; endianness_t endianness = ROMREGION_ISBIGENDIAN(region) ? ENDIANNESS_BIG : ENDIANNESS_LITTLE; if (machine().device(regiontag.c_str()) != nullptr) normalize_flags_for_device(machine(), regiontag.c_str(), width, endianness); diff --git a/src/emu/romload.h b/src/emu/romload.h index 2d11cf7bfe7..41d02dbadae 100644 --- a/src/emu/romload.h +++ b/src/emu/romload.h @@ -111,35 +111,35 @@ class software_list_device; /* ----- specialized loading macros ----- */ -#define ROM_LOAD_NIB_HIGH(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI) -#define ROM_LOAD_NIB_LOW(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO) -#define ROM_LOAD16_BYTE(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_SKIP(1)) -#define ROM_LOAD16_WORD(name,offset,length,hash) ROM_LOAD(name, offset, length, hash) -#define ROM_LOAD16_WORD_SWAP(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_REVERSE) -#define ROM_LOAD32_BYTE(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_SKIP(3)) -#define ROM_LOAD32_WORD(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_SKIP(2)) -#define ROM_LOAD32_WORD_SWAP(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_REVERSE | ROM_SKIP(2)) -#define ROM_LOAD32_DWORD(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPDWORD) -#define ROM_LOAD64_WORD(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_SKIP(6)) -#define ROM_LOAD64_WORD_SWAP(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_REVERSE | ROM_SKIP(6)) -#define ROM_LOAD64_DWORD_SWAP(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPDWORD | ROM_REVERSE | ROM_SKIP(4)) +#define ROM_LOAD_NIB_HIGH(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI) +#define ROM_LOAD_NIB_LOW(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO) +#define ROM_LOAD16_BYTE(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_SKIP(1)) +#define ROM_LOAD16_WORD(name,offset,length,hash) ROM_LOAD(name, offset, length, hash) +#define ROM_LOAD16_WORD_SWAP(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_REVERSE) +#define ROM_LOAD32_BYTE(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_SKIP(3)) +#define ROM_LOAD32_WORD(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_SKIP(2)) +#define ROM_LOAD32_WORD_SWAP(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_REVERSE | ROM_SKIP(2)) +#define ROM_LOAD32_DWORD(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPDWORD) +#define ROM_LOAD64_WORD(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_SKIP(6)) +#define ROM_LOAD64_WORD_SWAP(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_REVERSE | ROM_SKIP(6)) +#define ROM_LOAD64_DWORD_SWAP(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPDWORD | ROM_REVERSE | ROM_SKIP(4)) /* ----- ROM_RELOAD related macros ----- */ #define ROM_RELOAD(offset,length) { nullptr, nullptr, offset, length, ROMENTRYTYPE_RELOAD | ROM_INHERITFLAGS }, -#define ROM_RELOAD_PLAIN(offset,length) { nullptr, nullptr, offset, length, ROMENTRYTYPE_RELOAD }, +#define ROM_RELOAD_PLAIN(offset,length) { nullptr, nullptr, offset, length, ROMENTRYTYPE_RELOAD }, /* ----- additional ROM-related macros ----- */ -#define ROM_CONTINUE(offset,length) { nullptr, nullptr, (offset), (length), ROMENTRYTYPE_CONTINUE | ROM_INHERITFLAGS }, -#define ROM_IGNORE(length) { nullptr, nullptr, 0, (length), ROMENTRYTYPE_IGNORE | ROM_INHERITFLAGS }, -#define ROM_FILL(offset,length,value) { nullptr, (const char *)(value), (offset), (length), ROMENTRYTYPE_FILL }, -#define ROMX_FILL(offset,length,value,flags) { nullptr, (const char *)(value), (offset), (length), ROMENTRYTYPE_FILL | flags }, +#define ROM_CONTINUE(offset,length) { nullptr, nullptr, (offset), (length), ROMENTRYTYPE_CONTINUE | ROM_INHERITFLAGS }, +#define ROM_IGNORE(length) { nullptr, nullptr, 0, (length), ROMENTRYTYPE_IGNORE | ROM_INHERITFLAGS }, +#define ROM_FILL(offset,length,value) { nullptr, (const char *)(value), (offset), (length), ROMENTRYTYPE_FILL }, +#define ROMX_FILL(offset,length,value,flags) { nullptr, (const char *)(value), (offset), (length), ROMENTRYTYPE_FILL | flags }, #define ROM_COPY(srctag,srcoffs,offset,length) { (srctag), (const char *)(srcoffs), (offset), (length), ROMENTRYTYPE_COPY }, /* ----- system BIOS macros ----- */ #define ROM_SYSTEM_BIOS(value,name,description) { name, description, 0, 0, ROMENTRYTYPE_SYSTEM_BIOS | ROM_BIOS(value+1) }, -#define ROM_DEFAULT_BIOS(name) { name, nullptr, 0, 0, ROMENTRYTYPE_DEFAULT_BIOS }, +#define ROM_DEFAULT_BIOS(name) { name, nullptr, 0, 0, ROMENTRYTYPE_DEFAULT_BIOS }, /* ----- game parameter macro ----- */ @@ -163,8 +163,7 @@ class rom_load_manager class open_chd { public: - open_chd(const char *region) - : m_region(region) { } + open_chd(const char *region) : m_region(region) { } const char *region() const { return m_region.c_str(); } chd_file &chd() { return m_diffchd.opened() ? m_diffchd : m_origchd; } @@ -205,50 +204,50 @@ public: private: void determine_bios_rom(device_t &device, const char *specbios); void count_roms(); - void fill_random(uint8_t *base, uint32_t length); + void fill_random(u8 *base, u32 length); void handle_missing_file(const rom_entry *romp, std::string tried_file_names, chd_error chderr); void dump_wrong_and_correct_checksums(const util::hash_collection &hashes, const util::hash_collection &acthashes); - void verify_length_and_hash(const char *name, uint32_t explength, const util::hash_collection &hashes); + void verify_length_and_hash(const char *name, u32 explength, const util::hash_collection &hashes); void display_loading_rom_message(const char *name, bool from_list); void display_rom_load_results(bool from_list); void region_post_process(const char *rgntag, bool invert); int open_rom_file(const char *regiontag, const rom_entry *romp, std::string &tried_file_names, bool from_list); - int rom_fread(uint8_t *buffer, int length, const rom_entry *parent_region); + int rom_fread(u8 *buffer, int length, const rom_entry *parent_region); int read_rom_data(const rom_entry *parent_region, const rom_entry *romp); void fill_rom_data(const rom_entry *romp); void copy_rom_data(const rom_entry *romp); void process_rom_entries(const char *regiontag, const rom_entry *parent_region, const rom_entry *romp, device_t *device, bool from_list); chd_error open_disk_diff(emu_options &options, const rom_entry *romp, chd_file &source, chd_file &diff_chd); void process_disk_entries(const char *regiontag, const rom_entry *parent_region, const rom_entry *romp, const char *locationtag); - void normalize_flags_for_device(running_machine &machine, const char *rgntag, uint8_t &width, endianness_t &endian); + void normalize_flags_for_device(running_machine &machine, const char *rgntag, u8 &width, endianness_t &endian); void process_region_list(); // internal state - running_machine & m_machine; // reference to our machine + running_machine & m_machine; // reference to our machine - int m_warnings; /* warning count during processing */ - int m_knownbad; /* BAD_DUMP/NO_DUMP count during processing */ - int m_errors; /* error count during processing */ + int m_warnings; // warning count during processing + int m_knownbad; // BAD_DUMP/NO_DUMP count during processing + int m_errors; // error count during processing - int m_romsloaded; /* current ROMs loaded count */ - int m_romstotal; /* total number of ROMs to read */ - uint32_t m_romsloadedsize; /* total size of ROMs loaded so far */ - uint32_t m_romstotalsize; /* total size of ROMs to read */ + int m_romsloaded; // current ROMs loaded count + int m_romstotal; // total number of ROMs to read + u32 m_romsloadedsize; // total size of ROMs loaded so far + u32 m_romstotalsize; // total size of ROMs to read std::unique_ptr m_file; /* current file */ std::vector> m_chd_list; /* disks */ - memory_region * m_region; /* info about current region */ + memory_region * m_region; // info about current region - std::string m_errorstring; /* error string */ - std::string m_softwarningstring; /* software warning string */ + std::string m_errorstring; // error string + std::string m_softwarningstring; // software warning string }; /* ----- Helpers ----- */ -std::unique_ptr common_process_file(emu_options &options, const char *location, bool has_crc, uint32_t crc, const rom_entry *romp, osd_file::error &filerr); +std::unique_ptr common_process_file(emu_options &options, const char *location, bool has_crc, u32 crc, const rom_entry *romp, osd_file::error &filerr); /* return pointer to the first ROM region within a source */ const rom_entry *rom_first_region(const device_t &device); @@ -263,7 +262,7 @@ const rom_entry *rom_first_file(const rom_entry *romp); const rom_entry *rom_next_file(const rom_entry *romp); /* return the expected size of a file given the ROM description */ -uint32_t rom_file_size(const rom_entry *romp); +u32 rom_file_size(const rom_entry *romp); /* return the appropriate name for a rom region */ std::string rom_region_name(const device_t &device, const rom_entry *romp); diff --git a/src/emu/save.cpp b/src/emu/save.cpp index 4a94c9baea1..c85f0d1b9ef 100644 --- a/src/emu/save.cpp +++ b/src/emu/save.cpp @@ -86,7 +86,7 @@ void save_manager::allow_registration(bool allowed) // index //------------------------------------------------- -const char *save_manager::indexed_item(int index, void *&base, uint32_t &valsize, uint32_t &valcount) const +const char *save_manager::indexed_item(int index, void *&base, u32 &valsize, u32 &valcount) const { if (index >= m_entry_list.size() || index < 0) return nullptr; @@ -147,7 +147,7 @@ void save_manager::register_postload(save_prepost_delegate func) // memory //------------------------------------------------- -void save_manager::save_memory(device_t *device, const char *module, const char *tag, uint32_t index, const char *name, void *val, uint32_t valsize, uint32_t valcount) +void save_manager::save_memory(device_t *device, const char *module, const char *tag, u32 index, const char *name, void *val, u32 valsize, u32 valcount) { assert(valsize == 1 || valsize == 2 || valsize == 4 || valsize == 8); @@ -195,13 +195,13 @@ void save_manager::save_memory(device_t *device, const char *module, const char save_error save_manager::check_file(running_machine &machine, emu_file &file, const char *gamename, void (CLIB_DECL *errormsg)(const char *fmt, ...)) { // if we want to validate the signature, compute it - uint32_t sig; + u32 sig; sig = machine.save().signature(); // seek to the beginning and read the header file.compress(FCOMPRESS_NONE); file.seek(0, SEEK_SET); - uint8_t header[HEADER_SIZE]; + u8 header[HEADER_SIZE]; if (file.read(header, sizeof(header)) != sizeof(header)) { if (errormsg != nullptr) @@ -238,13 +238,13 @@ save_error save_manager::read_file(emu_file &file) // read the header and turn on compression for the rest of the file file.compress(FCOMPRESS_NONE); file.seek(0, SEEK_SET); - uint8_t header[HEADER_SIZE]; + u8 header[HEADER_SIZE]; if (file.read(header, sizeof(header)) != sizeof(header)) return STATERR_READ_ERROR; file.compress(FCOMPRESS_MEDIUM); // verify the header and report an error if it doesn't match - uint32_t sig = signature(); + u32 sig = signature(); if (validate_header(header, machine().system().name, sig, nullptr, "Error: ") != STATERR_NONE) return STATERR_INVALID_HEADER; @@ -254,7 +254,7 @@ save_error save_manager::read_file(emu_file &file) // read all the data, flipping if necessary for (auto &entry : m_entry_list) { - uint32_t totalsize = entry->m_typesize * entry->m_typecount; + u32 totalsize = entry->m_typesize * entry->m_typecount; if (file.read(entry->m_data, totalsize) != totalsize) return STATERR_READ_ERROR; @@ -292,13 +292,13 @@ save_error save_manager::write_file(emu_file &file) return STATERR_ILLEGAL_REGISTRATIONS; // generate the header - uint8_t header[HEADER_SIZE]; + u8 header[HEADER_SIZE]; memcpy(&header[0], STATE_MAGIC_NUM, 8); header[8] = SAVE_VERSION; header[9] = NATIVE_ENDIAN_VALUE_LE_BE(0, SS_MSB_FIRST); strncpy((char *)&header[0x0a], machine().system().name, 0x1c - 0x0a); - uint32_t sig = signature(); - *(uint32_t *)&header[0x1c] = little_endianize_int32(sig); + u32 sig = signature(); + *(u32 *)&header[0x1c] = little_endianize_int32(sig); // write the header and turn on compression for the rest of the file file.compress(FCOMPRESS_NONE); @@ -313,7 +313,7 @@ save_error save_manager::write_file(emu_file &file) // then write all the data for (auto &entry : m_entry_list) { - uint32_t totalsize = entry->m_typesize * entry->m_typecount; + u32 totalsize = entry->m_typesize * entry->m_typecount; if (file.write(entry->m_data, totalsize) != totalsize) return STATERR_WRITE_ERROR; } @@ -326,20 +326,20 @@ save_error save_manager::write_file(emu_file &file) // is a CRC over the structure of the data //------------------------------------------------- -uint32_t save_manager::signature() const +u32 save_manager::signature() const { // iterate over entries - uint32_t crc = 0; + u32 crc = 0; for (auto &entry : m_entry_list) { // add the entry name to the CRC - crc = core_crc32(crc, (uint8_t *)entry->m_name.c_str(), entry->m_name.length()); + crc = core_crc32(crc, (u8 *)entry->m_name.c_str(), entry->m_name.length()); // add the type and size to the CRC - uint32_t temp[2]; + u32 temp[2]; temp[0] = little_endianize_int32(entry->m_typecount); temp[1] = little_endianize_int32(entry->m_typesize); - crc = core_crc32(crc, (uint8_t *)&temp[0], sizeof(temp)); + crc = core_crc32(crc, (u8 *)&temp[0], sizeof(temp)); } return crc; } @@ -362,7 +362,7 @@ void save_manager::dump_registry() const // header //------------------------------------------------- -save_error save_manager::validate_header(const uint8_t *header, const char *gamename, uint32_t signature, +save_error save_manager::validate_header(const u8 *header, const char *gamename, u32 signature, void (CLIB_DECL *errormsg)(const char *fmt, ...), const char *error_prefix) { // check magic number @@ -392,7 +392,7 @@ save_error save_manager::validate_header(const uint8_t *header, const char *game // check signature, if we were asked to if (signature != 0) { - uint32_t rawsig = *(uint32_t *)&header[0x1c]; + u32 rawsig = *(u32 *)&header[0x1c]; if (signature != little_endianize_int32(rawsig)) { if (errormsg != nullptr) @@ -418,7 +418,7 @@ save_manager::state_callback::state_callback(save_prepost_delegate callback) // state_entry - constructor //------------------------------------------------- -state_entry::state_entry(void *data, const char *name, device_t *device, const char *module, const char *tag, int index, uint8_t size, uint32_t count) +state_entry::state_entry(void *data, const char *name, device_t *device, const char *module, const char *tag, int index, u8 size, u32 count) : m_data(data), m_name(name), m_device(device), @@ -439,27 +439,27 @@ state_entry::state_entry(void *data, const char *name, device_t *device, const c void state_entry::flip_data() { - uint16_t *data16; - uint32_t *data32; - uint64_t *data64; + u16 *data16; + u32 *data32; + u64 *data64; int count; switch (m_typesize) { case 2: - data16 = (uint16_t *)m_data; + data16 = (u16 *)m_data; for (count = 0; count < m_typecount; count++) data16[count] = flipendian_int16(data16[count]); break; case 4: - data32 = (uint32_t *)m_data; + data32 = (u32 *)m_data; for (count = 0; count < m_typecount; count++) data32[count] = flipendian_int32(data32[count]); break; case 8: - data64 = (uint64_t *)m_data; + data64 = (u64 *)m_data; for (count = 0; count < m_typecount; count++) data64[count] = flipendian_int64(data64[count]); break; diff --git a/src/emu/save.h b/src/emu/save.h index 7c8c6ac5e32..59bf5f54a5e 100644 --- a/src/emu/save.h +++ b/src/emu/save.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __SAVE_H__ -#define __SAVE_H__ +#ifndef MAME_EMU_SAVE_H +#define MAME_EMU_SAVE_H @@ -62,21 +62,21 @@ class state_entry { public: // construction/destruction - state_entry(void *data, const char *name, device_t *device, const char *module, const char *tag, int index, uint8_t size, uint32_t count); + state_entry(void *data, const char *name, device_t *device, const char *module, const char *tag, int index, u8 size, u32 count); // helpers void flip_data(); // state - void * m_data; // pointer to the memory to save/restore - std::string m_name; // full name - device_t * m_device; // associated device, nullptr if none - std::string m_module; // module name - std::string m_tag; // tag name - int m_index; // index - uint8_t m_typesize; // size of the raw data type - uint32_t m_typecount; // number of items - uint32_t m_offset; // offset within the final structure + void * m_data; // pointer to the memory to save/restore + std::string m_name; // full name + device_t * m_device; // associated device, nullptr if none + std::string m_module; // module name + std::string m_tag; // tag name + int m_index; // index + u8 m_typesize; // size of the raw data type + u32 m_typecount; // number of items + u32 m_offset; // offset within the final structure }; class save_manager @@ -96,7 +96,7 @@ public: // registration control void allow_registration(bool allowed = true); - const char *indexed_item(int index, void *&base, uint32_t &valsize, uint32_t &valcount) const; + const char *indexed_item(int index, void *&base, u32 &valsize, u32 &valcount) const; // function registration void register_presave(save_prepost_delegate func); @@ -107,7 +107,7 @@ public: void dispatch_postload(); // generic memory registration - void save_memory(device_t *device, const char *module, const char *tag, uint32_t index, const char *name, void *val, uint32_t valsize, uint32_t valcount = 1); + void save_memory(device_t *device, const char *module, const char *tag, u32 index, const char *name, void *val, u32 valsize, u32 valcount = 1); // templatized wrapper for general objects template @@ -136,7 +136,7 @@ public: // templatized wrapper for pointers template - void save_pointer(device_t *device, const char *module, const char *tag, int index, _ItemType *value, const char *valname, uint32_t count) + void save_pointer(device_t *device, const char *module, const char *tag, int index, _ItemType *value, const char *valname, u32 count) { if (!type_checker<_ItemType>::is_atom) throw emu_fatalerror("Called save_item on a non-fundamental type!"); save_memory(device, module, tag, index, valname, value, sizeof(*value), count); @@ -146,7 +146,7 @@ public: template void save_item(_ItemType &value, const char *valname, int index = 0) { save_item(nullptr, "global", nullptr, index, value, valname); } template - void save_pointer(_ItemType *value, const char *valname, uint32_t count, int index = 0) { save_pointer(nullptr, "global", nullptr, index, value, valname, count); } + void save_pointer(_ItemType *value, const char *valname, u32 count, int index = 0) { save_pointer(nullptr, "global", nullptr, index, value, valname, count); } // file processing static save_error check_file(running_machine &machine, emu_file &file, const char *gamename, void (CLIB_DECL *errormsg)(const char *fmt, ...)); @@ -155,9 +155,9 @@ public: private: // internal helpers - uint32_t signature() const; + u32 signature() const; void dump_registry() const; - static save_error validate_header(const uint8_t *header, const char *gamename, uint32_t signature, void (CLIB_DECL *errormsg)(const char *fmt, ...), const char *error_prefix); + static save_error validate_header(const u8 *header, const char *gamename, u32 signature, void (CLIB_DECL *errormsg)(const char *fmt, ...), const char *error_prefix); // state callback item class state_callback @@ -183,14 +183,14 @@ private: // template specializations to enumerate the fundamental atomic types you are allowed to save ALLOW_SAVE_TYPE_AND_ARRAY(char) ALLOW_SAVE_TYPE (bool); // std::vector may be packed internally -ALLOW_SAVE_TYPE_AND_ARRAY(int8_t) -ALLOW_SAVE_TYPE_AND_ARRAY(uint8_t) -ALLOW_SAVE_TYPE_AND_ARRAY(int16_t) -ALLOW_SAVE_TYPE_AND_ARRAY(uint16_t) -ALLOW_SAVE_TYPE_AND_ARRAY(int32_t) -ALLOW_SAVE_TYPE_AND_ARRAY(uint32_t) -ALLOW_SAVE_TYPE_AND_ARRAY(int64_t) -ALLOW_SAVE_TYPE_AND_ARRAY(uint64_t) +ALLOW_SAVE_TYPE_AND_ARRAY(s8) +ALLOW_SAVE_TYPE_AND_ARRAY(u8) +ALLOW_SAVE_TYPE_AND_ARRAY(s16) +ALLOW_SAVE_TYPE_AND_ARRAY(u16) +ALLOW_SAVE_TYPE_AND_ARRAY(s32) +ALLOW_SAVE_TYPE_AND_ARRAY(u32) +ALLOW_SAVE_TYPE_AND_ARRAY(s64) +ALLOW_SAVE_TYPE_AND_ARRAY(u64) ALLOW_SAVE_TYPE_AND_ARRAY(PAIR) ALLOW_SAVE_TYPE_AND_ARRAY(PAIR64) ALLOW_SAVE_TYPE_AND_ARRAY(float) @@ -247,4 +247,4 @@ inline void save_manager::save_item(device_t *device, const char *module, const } -#endif /* __SAVE_H__ */ +#endif /* MAME_EMU_SAVE_H */ diff --git a/src/emu/schedule.cpp b/src/emu/schedule.cpp index e02ba15e142..16e880e8a58 100644 --- a/src/emu/schedule.cpp +++ b/src/emu/schedule.cpp @@ -174,7 +174,7 @@ bool emu_timer::enable(bool enable) // firings //------------------------------------------------- -void emu_timer::adjust(attotime start_delay, int32_t param, const attotime &period) +void emu_timer::adjust(attotime start_delay, s32 param, const attotime &period) { // if this is the callback timer, mark it modified device_scheduler &scheduler = machine().scheduler(); @@ -393,7 +393,7 @@ bool device_scheduler::can_save() const inline void device_scheduler::apply_suspend_changes() { - uint32_t suspendchanged = 0; + u32 suspendchanged = 0; for (device_execute_interface *exec = m_execute_list; exec != nullptr; exec = exec->m_nextexec) { suspendchanged |= exec->m_suspend ^ exec->m_nextsuspend; @@ -461,7 +461,7 @@ void device_scheduler::timeslice() if (delta >= exec->m_attoseconds_per_cycle) { // compute how many cycles we want to execute - int ran = exec->m_cycles_running = divu_64x32((uint64_t)delta >> exec->m_divshift, exec->m_divisor); + int ran = exec->m_cycles_running = divu_64x32(u64(delta) >> exec->m_divshift, exec->m_divisor); LOG((" cpu '%s': %d (%d cycles)\n", exec->device().tag(), delta, exec->m_cycles_running)); // if we're not suspended, actually execute @@ -498,7 +498,7 @@ void device_scheduler::timeslice() attotime deltatime(0, exec->m_attoseconds_per_cycle * ran); assert(deltatime >= attotime::zero); exec->m_localtime += deltatime; - LOG((" %d ran, %d total, time = %s\n", ran, (int32_t)exec->m_totalcycles, exec->m_localtime.as_string(PRECISION))); + LOG((" %d ran, %d total, time = %s\n", ran, s32(exec->m_totalcycles), exec->m_localtime.as_string(PRECISION))); // if the new local CPU time is less than our target, move the target up, but not before the base if (exec->m_localtime < target) @@ -642,7 +642,7 @@ void device_scheduler::eat_all_cycles() // given amount of time //------------------------------------------------- -void device_scheduler::timed_trigger(void *ptr, int32_t param) +void device_scheduler::timed_trigger(void *ptr, s32 param) { trigger(param); } diff --git a/src/emu/schedule.h b/src/emu/schedule.h index 56fb750c0aa..0bbffedc5b0 100644 --- a/src/emu/schedule.h +++ b/src/emu/schedule.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __SCHEDULE_H__ -#define __SCHEDULE_H__ +#ifndef MAME_EMU_SCHEDULE_H +#define MAME_EMU_SCHEDULE_H //************************************************************************** @@ -39,7 +39,7 @@ //************************************************************************** // timer callbacks look like this -typedef named_delegate timer_expired_delegate; +typedef named_delegate timer_expired_delegate; // ======================> emu_timer @@ -74,7 +74,7 @@ public: // control void reset(const attotime &duration = attotime::never) { adjust(duration, m_param, m_period); } - void adjust(attotime start_delay, int32_t param = 0, const attotime &periodicity = attotime::never); + void adjust(attotime start_delay, s32 param = 0, const attotime &periodicity = attotime::never); // timing queries attotime elapsed() const; @@ -93,7 +93,7 @@ private: emu_timer * m_next; // next timer in order in the list emu_timer * m_prev; // previous timer in order in the list timer_expired_delegate m_callback; // callback function - int32_t m_param; // integer parameter + s32 m_param; // integer parameter void * m_ptr; // pointer parameter bool m_enabled; // is the timer enabled? bool m_temporary; // is the timer temporary? @@ -149,7 +149,7 @@ public: private: // callbacks - void timed_trigger(void *ptr, int32_t param); + void timed_trigger(void *ptr, s32 param); void presave(); void postload(); @@ -199,4 +199,4 @@ private: }; -#endif // __SCHEDULE_H__ */ +#endif // MAME_EMU_SCHEDULE_H */ diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp index 4742963d9d3..f204b9c034e 100644 --- a/src/emu/screen.cpp +++ b/src/emu/screen.cpp @@ -35,7 +35,7 @@ const device_type SCREEN = &device_creator; const attotime screen_device::DEFAULT_FRAME_PERIOD(attotime::from_hz(DEFAULT_FRAME_RATE)); -uint32_t screen_device::m_id_counter = 0; +u32 screen_device::m_id_counter = 0; class screen_device_svg_renderer { public: @@ -47,7 +47,7 @@ public: int render(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - static void output_notifier(const char *outname, int32_t value, void *param); + static void output_notifier(const char *outname, s32 value, void *param); private: struct paired_entry { @@ -58,7 +58,7 @@ private: struct cached_bitmap { int x, y, sx, sy; - std::vector image; + std::vector image; std::vector pairs; }; @@ -75,16 +75,16 @@ private: int m_sx, m_sy; double m_scale; - std::vector m_background; + std::vector m_background; std::vector m_cache; - void output_change(const char *outname, int32_t value); - void render_state(std::vector &dest, const std::vector &state); + void output_change(const char *outname, s32 value); + void render_state(std::vector &dest, const std::vector &state); void compute_initial_bboxes(std::vector &bboxes); bool compute_mask_intersection_bbox(int key1, int key2, bbox &bb) const; - void compute_diff_image(const std::vector &rend, const bbox &bb, cached_bitmap &dest) const; - void compute_dual_diff_image(const std::vector &rend, const bbox &bb, const cached_bitmap &src1, const cached_bitmap &src2, cached_bitmap &dest) const; + void compute_diff_image(const std::vector &rend, const bbox &bb, cached_bitmap &dest) const; + void compute_dual_diff_image(const std::vector &rend, const bbox &bb, const cached_bitmap &src1, const cached_bitmap &src2, cached_bitmap &dest) const; void rebuild_cache(); void blit(bitmap_rgb32 &bitmap, const cached_bitmap &src) const; }; @@ -153,7 +153,7 @@ int screen_device_svg_renderer::height() const return int(m_image->height + 0.5); } -void screen_device_svg_renderer::render_state(std::vector &dest, const std::vector &state) +void screen_device_svg_renderer::render_state(std::vector &dest, const std::vector &state) { for(int key = 0; key != m_key_count; key++) { if (state[key]) @@ -170,30 +170,30 @@ void screen_device_svg_renderer::render_state(std::vector &dest, const // alpha to "blend" against a black background. Plus align the // channel order to what we do. - uint8_t *image = (uint8_t *)&dest[0]; + u8 *image = (u8 *)&dest[0]; for(unsigned int pixel=0; pixel != m_sy*m_sx; pixel++) { - uint8_t r = image[0]; - uint8_t g = image[1]; - uint8_t b = image[2]; - uint8_t a = image[3]; + u8 r = image[0]; + u8 g = image[1]; + u8 b = image[2]; + u8 a = image[3]; if(a != 0xff) { r = r*a/255; g = g*a/255; b = b*a/255; } - uint32_t color = 0xff000000 | (r << 16) | (g << 8) | (b << 0); - *(uint32_t *)image = color; + u32 color = 0xff000000 | (r << 16) | (g << 8) | (b << 0); + *(u32 *)image = color; image += 4; } } void screen_device_svg_renderer::blit(bitmap_rgb32 &bitmap, const cached_bitmap &src) const { - const uint32_t *s = &src.image[0]; + const u32 *s = &src.image[0]; for(int y=0; y(param)->output_change(outname, value); } -void screen_device_svg_renderer::output_change(const char *outname, int32_t value) +void screen_device_svg_renderer::output_change(const char *outname, s32 value) { auto l = m_key_ids.find(outname); if (l == m_key_ids.end()) @@ -300,13 +300,13 @@ void screen_device_svg_renderer::compute_initial_bboxes(std::vector &bboxe } } -void screen_device_svg_renderer::compute_diff_image(const std::vector &rend, const bbox &bb, cached_bitmap &dest) const +void screen_device_svg_renderer::compute_diff_image(const std::vector &rend, const bbox &bb, cached_bitmap &dest) const { int x0, y0, x1, y1; x0 = y0 = x1 = y1 = -1; for(int y = bb.y0; y != bb.y1; y++) { - const uint32_t *src1 = &m_background[bb.x0 + y * m_sx]; - const uint32_t *src2 = &rend[bb.x0 + y * m_sx]; + const u32 *src1 = &m_background[bb.x0 + y * m_sx]; + const u32 *src2 = &rend[bb.x0 + y * m_sx]; for(int x = bb.x0; x != bb.x1; x++) { if(*src1 != *src2) { if(x0 == -1) { @@ -337,10 +337,10 @@ void screen_device_svg_renderer::compute_diff_image(const std::vector dest.sx = x1+1-x0; dest.sy = y1+1-y0; dest.image.resize(dest.sx * dest.sy); - uint32_t *dst = &dest.image[0]; + u32 *dst = &dest.image[0]; for(int y = 0; y != dest.sy; y++) { - const uint32_t *src1 = &m_background[dest.x + (y + dest.y) * m_sx]; - const uint32_t *src2 = &rend[dest.x + (y + dest.y) * m_sx]; + const u32 *src1 = &m_background[dest.x + (y + dest.y) * m_sx]; + const u32 *src2 = &rend[dest.x + (y + dest.y) * m_sx]; for(int x = 0; x != dest.sx; x++) { if(*src1 != *src2) *dst = *src2; @@ -372,8 +372,8 @@ bool screen_device_svg_renderer::compute_mask_intersection_bbox(int key1, int ke x0 = y0 = x1 = y1 = -1; for(int y = cy0; y < cy1; y++) { - const uint32_t *src1 = &c1.image[(cx0 - c1.x) + c1.sx * (y - c1.y)]; - const uint32_t *src2 = &c2.image[(cx0 - c2.x) + c2.sx * (y - c2.y)]; + const u32 *src1 = &c1.image[(cx0 - c1.x) + c1.sx * (y - c1.y)]; + const u32 *src2 = &c2.image[(cx0 - c2.x) + c2.sx * (y - c2.y)]; for(int x = cx0; x < cx1; x++) { if(*src1 && *src2 && *src1 != *src2) { if(x0 == -1) { @@ -403,7 +403,7 @@ bool screen_device_svg_renderer::compute_mask_intersection_bbox(int key1, int ke return true; } -void screen_device_svg_renderer::compute_dual_diff_image(const std::vector &rend, const bbox &bb, const cached_bitmap &src1, const cached_bitmap &src2, cached_bitmap &dest) const +void screen_device_svg_renderer::compute_dual_diff_image(const std::vector &rend, const bbox &bb, const cached_bitmap &src1, const cached_bitmap &src2, cached_bitmap &dest) const { dest.x = bb.x0; dest.y = bb.y0; @@ -411,10 +411,10 @@ void screen_device_svg_renderer::compute_dual_diff_image(const std::vector rend(m_sx*m_sy); + std::vector rend(m_sx*m_sy); // Render the background, e.g. with everything off std::vector state(m_key_count); @@ -544,7 +544,7 @@ void screen_device_svg_renderer::rebuild_cache() // screen_device - constructor //------------------------------------------------- -screen_device::screen_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +screen_device::screen_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, SCREEN, "Video Screen", tag, owner, clock, "screen", __FILE__), m_type(SCREEN_TYPE_RASTER), m_oldstyle_vblank_supplied(false), @@ -619,7 +619,7 @@ void screen_device::static_set_svg_region(device_t &device, const char *region) // to set the raw screen parameters //------------------------------------------------- -void screen_device::static_set_raw(device_t &device, uint32_t pixclock, uint16_t htotal, uint16_t hbend, uint16_t hbstart, uint16_t vtotal, uint16_t vbend, uint16_t vbstart) +void screen_device::static_set_raw(device_t &device, u32 pixclock, u16 htotal, u16 hbend, u16 hbstart, u16 vtotal, u16 vbend, u16 vbstart) { screen_device &screen = downcast(device); screen.m_clock = pixclock; @@ -660,7 +660,7 @@ void screen_device::static_set_vblank_time(device_t &device, attoseconds_t time) // the width/height of the screen //------------------------------------------------- -void screen_device::static_set_size(device_t &device, uint16_t width, uint16_t height) +void screen_device::static_set_size(device_t &device, u16 width, u16 height) { screen_device &screen = downcast(device); screen.m_width = width; @@ -673,7 +673,7 @@ void screen_device::static_set_size(device_t &device, uint16_t width, uint16_t h // set the visible area of the screen //------------------------------------------------- -void screen_device::static_set_visarea(device_t &device, int16_t minx, int16_t maxx, int16_t miny, int16_t maxy) +void screen_device::static_set_visarea(device_t &device, s16 minx, s16 maxx, s16 miny, s16 maxy) { downcast(device).m_visarea.set(minx, maxx, miny, maxy); } @@ -743,7 +743,7 @@ void screen_device::static_set_palette(device_t &device, const char *tag) // video attributes //------------------------------------------------- -void screen_device::static_set_video_attributes(device_t &device, uint32_t flags) +void screen_device::static_set_video_attributes(device_t &device, u32 flags) { screen_device &screen = downcast(device); screen.m_video_attributes = flags; @@ -844,9 +844,9 @@ void screen_device::device_start() // allocate raw textures m_texture[0] = machine().render().texture_alloc(); - m_texture[0]->set_osd_data((uint64_t)((m_unique_id << 1) | 0)); + m_texture[0]->set_osd_data(u64((m_unique_id << 1) | 0)); m_texture[1] = machine().render().texture_alloc(); - m_texture[1]->set_osd_data((uint64_t)((m_unique_id << 1) | 1)); + m_texture[1]->set_osd_data(u64((m_unique_id << 1) | 1)); // configure the default cliparea render_container::user_settings settings; @@ -1091,8 +1091,8 @@ void screen_device::realloc_screen_bitmaps() return; // determine effective size to allocate - int32_t effwidth = std::max(m_width, m_visarea.max_x + 1); - int32_t effheight = std::max(m_height, m_visarea.max_y + 1); + s32 effwidth = std::max(m_width, m_visarea.max_x + 1); + s32 effheight = std::max(m_height, m_visarea.max_y + 1); // reize all registered screen bitmaps for (auto &item : m_auto_bitmap_list) @@ -1177,7 +1177,7 @@ bool screen_device::update_partial(int scanline) LOG_PARTIAL_UPDATES(("updating %d-%d\n", clip.min_y, clip.max_y)); g_profiler.start(PROFILER_VIDEO); - uint32_t flags; + u32 flags; if (m_type != SCREEN_TYPE_SVG) { screen_bitmap &curbitmap = m_bitmap[m_curbitmap]; @@ -1242,7 +1242,7 @@ void screen_device::update_now() // if the line before us was incomplete, we must do it in two pieces if (m_partial_scan_hpos > 0) { - int32_t save_scan = m_partial_scan_hpos; + s32 save_scan = m_partial_scan_hpos; update_partial(current_vpos - 2); m_partial_scan_hpos = save_scan; @@ -1301,7 +1301,7 @@ void screen_device::update_now() LOG_PARTIAL_UPDATES(("doing scanline partial draw: Y %d X %d-%d\n", clip.max_y, clip.min_x, clip.max_x)); - uint32_t flags; + u32 flags; screen_bitmap &curbitmap = m_bitmap[m_curbitmap]; switch (curbitmap.format()) { @@ -1585,8 +1585,8 @@ void screen_device::update_burnin() int dstheight = m_burnin.height(); int xstep = (srcwidth << 16) / dstwidth; int ystep = (srcheight << 16) / dstheight; - int xstart = ((uint32_t)rand() % 32767) * xstep / 32767; - int ystart = ((uint32_t)rand() % 32767) * ystep / 32767; + int xstart = (u32(rand()) % 32767) * xstep / 32767; + int ystart = (u32(rand()) % 32767) * ystep / 32767; int srcx, srcy; int x, y; @@ -1599,8 +1599,8 @@ void screen_device::update_burnin() bitmap_ind16 &srcbitmap = curbitmap.as_ind16(); for (y = 0, srcy = ystart; y < dstheight; y++, srcy += ystep) { - uint64_t *dst = &m_burnin.pix64(y); - const uint16_t *src = &srcbitmap.pix16(srcy >> 16); + u64 *dst = &m_burnin.pix64(y); + const u16 *src = &srcbitmap.pix16(srcy >> 16); const rgb_t *palette = m_palette->palette()->entry_list_adjusted(); for (x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep) { @@ -1617,8 +1617,8 @@ void screen_device::update_burnin() bitmap_rgb32 &srcbitmap = curbitmap.as_rgb32(); for (y = 0, srcy = ystart; y < dstheight; y++, srcy += ystep) { - uint64_t *dst = &m_burnin.pix64(y); - const uint32_t *src = &srcbitmap.pix32(srcy >> 16); + u64 *dst = &m_burnin.pix64(y); + const u32 *src = &srcbitmap.pix32(srcy >> 16); for (x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep) { rgb_t pixel = src[srcx >> 16]; @@ -1657,11 +1657,11 @@ void screen_device::finalize_burnin() int ystep = (srcheight << 16) / dstheight; // find the maximum value - uint64_t minval = ~(uint64_t)0; - uint64_t maxval = 0; + u64 minval = ~u64(0); + u64 maxval = 0; for (int y = 0; y < srcheight; y++) { - uint64_t *src = &m_burnin.pix64(y); + u64 *src = &m_burnin.pix64(y); for (int x = 0; x < srcwidth; x++) { minval = std::min(minval, src[x]); @@ -1675,11 +1675,11 @@ void screen_device::finalize_burnin() // now normalize and convert to RGB for (int y = 0, srcy = 0; y < dstheight; y++, srcy += ystep) { - uint64_t *src = &m_burnin.pix64(srcy >> 16); - uint32_t *dst = &finalmap.pix32(y); + u64 *src = &m_burnin.pix64(srcy >> 16); + u32 *dst = &finalmap.pix32(y); for (int x = 0, srcx = 0; x < dstwidth; x++, srcx += xstep) { - int brightness = (uint64_t)(maxval - src[srcx >> 16]) * 255 / (maxval - minval); + int brightness = u64(maxval - src[srcx >> 16]) * 255 / (maxval - minval); dst[x] = rgb_t(0xff, brightness, brightness, brightness); } } diff --git a/src/emu/screen.h b/src/emu/screen.h index 8e0b34d7a27..24dab4e7be4 100644 --- a/src/emu/screen.h +++ b/src/emu/screen.h @@ -16,8 +16,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __SCREEN_H__ -#define __SCREEN_H__ +#ifndef MAME_EMU_SCREEN_H +#define MAME_EMU_SCREEN_H //************************************************************************** @@ -46,7 +46,7 @@ enum texture_format }; // screen_update callback flags -const uint32_t UPDATE_HAS_NOT_CHANGED = 0x0001; // the video has not changed +constexpr u32 UPDATE_HAS_NOT_CHANGED = 0x0001; // the video has not changed /*! @defgroup flags for video_attributes @@ -72,12 +72,12 @@ const uint32_t UPDATE_HAS_NOT_CHANGED = 0x0001; // the video has not changed @} */ -#define VIDEO_UPDATE_BEFORE_VBLANK 0x0000 -#define VIDEO_UPDATE_AFTER_VBLANK 0x0004 +constexpr u32 VIDEO_UPDATE_BEFORE_VBLANK = 0x0000; +constexpr u32 VIDEO_UPDATE_AFTER_VBLANK = 0x0004; -#define VIDEO_SELF_RENDER 0x0008 -#define VIDEO_ALWAYS_UPDATE 0x0080 -#define VIDEO_UPDATE_SCANLINE 0x0100 +constexpr u32 VIDEO_SELF_RENDER = 0x0008; +constexpr u32 VIDEO_ALWAYS_UPDATE = 0x0080; +constexpr u32 VIDEO_UPDATE_SCANLINE = 0x0100; //************************************************************************** @@ -124,11 +124,11 @@ public: bitmap_rgb32 &as_rgb32() { assert(m_format == BITMAP_FORMAT_RGB32); return m_rgb32; } // getters - int32_t width() const { return live().width(); } - int32_t height() const { return live().height(); } - int32_t rowpixels() const { return live().rowpixels(); } - int32_t rowbytes() const { return live().rowbytes(); } - uint8_t bpp() const { return live().bpp(); } + s32 width() const { return live().width(); } + s32 height() const { return live().height(); } + s32 rowpixels() const { return live().rowpixels(); } + s32 rowbytes() const { return live().rowbytes(); } + u8 bpp() const { return live().bpp(); } bitmap_format format() const { return m_format; } texture_format texformat() const { return m_texformat; } bool valid() const { return live().valid(); } @@ -165,8 +165,8 @@ private: typedef delegate vblank_state_delegate; -typedef device_delegate screen_update_ind16_delegate; -typedef device_delegate screen_update_rgb32_delegate; +typedef device_delegate screen_update_ind16_delegate; +typedef device_delegate screen_update_rgb32_delegate; typedef device_delegate screen_vblank_delegate; @@ -181,7 +181,7 @@ class screen_device : public device_t public: // construction/destruction - screen_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + screen_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); ~screen_device(); // configuration readers @@ -202,17 +202,17 @@ public: // inline configuration helpers static void static_set_type(device_t &device, screen_type_enum type); - static void static_set_raw(device_t &device, uint32_t pixclock, uint16_t htotal, uint16_t hbend, uint16_t hbstart, uint16_t vtotal, uint16_t vbend, uint16_t vbstart); + static void static_set_raw(device_t &device, u32 pixclock, u16 htotal, u16 hbend, u16 hbstart, u16 vtotal, u16 vbend, u16 vbstart); static void static_set_refresh(device_t &device, attoseconds_t rate); static void static_set_vblank_time(device_t &device, attoseconds_t time); - static void static_set_size(device_t &device, uint16_t width, uint16_t height); - static void static_set_visarea(device_t &device, int16_t minx, int16_t maxx, int16_t miny, int16_t maxy); + static void static_set_size(device_t &device, u16 width, u16 height); + static void static_set_visarea(device_t &device, s16 minx, s16 maxx, s16 miny, s16 maxy); static void static_set_default_position(device_t &device, double xscale, double xoffs, double yscale, double yoffs); static void static_set_screen_update(device_t &device, screen_update_ind16_delegate callback); static void static_set_screen_update(device_t &device, screen_update_rgb32_delegate callback); static void static_set_screen_vblank(device_t &device, screen_vblank_delegate callback); static void static_set_palette(device_t &device, const char *tag); - static void static_set_video_attributes(device_t &device, uint32_t flags); + static void static_set_video_attributes(device_t &device, u32 flags); static void static_set_color(device_t &device, rgb_t color); static void static_set_svg_region(device_t &device, const char *region); @@ -226,7 +226,7 @@ public: void configure(int width, int height, const rectangle &visarea, attoseconds_t frame_period); void reset_origin(int beamy = 0, int beamx = 0); void set_visible_area(int min_x, int max_x, int min_y, int max_y); - void set_brightness(uint8_t brightness) { m_brightness = brightness; } + void set_brightness(u8 brightness) { m_brightness = brightness; } // beam positioning and state int vpos() const; @@ -242,7 +242,7 @@ public: attotime time_until_update() const { return (m_video_attributes & VIDEO_UPDATE_AFTER_VBLANK) ? time_until_vblank_end() : time_until_vblank_start(); } attotime scan_period() const { return attotime(0, m_scantime); } attotime frame_period() const { return attotime(0, m_frame_period); } - uint64_t frame_number() const { return m_frame_number; } + u64 frame_number() const { return m_frame_number; } // updating int partial_updates() const { return m_partial_updates_this_frame; } @@ -259,7 +259,7 @@ public: void update_burnin(); // globally accessible constants - static const int DEFAULT_FRAME_RATE = 60; + static constexpr int DEFAULT_FRAME_RATE = 60; static const attotime DEFAULT_FRAME_PERIOD; private: @@ -299,7 +299,7 @@ private: screen_update_rgb32_delegate m_screen_update_rgb32; // screen update callback (32-bit RGB) screen_vblank_delegate m_screen_vblank; // screen vblank callback optional_device m_palette; // our palette - uint32_t m_video_attributes; // flags describing the video system + u32 m_video_attributes; // flags describing the video system const char * m_svg_region; // the region in which the svg data is in // internal state @@ -316,15 +316,15 @@ private: screen_bitmap m_bitmap[2]; // 2x bitmaps for rendering bitmap_ind8 m_priority; // priority bitmap bitmap_ind64 m_burnin; // burn-in bitmap - uint8_t m_curbitmap; // current bitmap index - uint8_t m_curtexture; // current texture index + u8 m_curbitmap; // current bitmap index + u8 m_curtexture; // current texture index bool m_changed; // has this bitmap changed? - int32_t m_last_partial_scan; // scanline of last partial update - int32_t m_partial_scan_hpos; // horizontal pixel last rendered on this partial scanline + s32 m_last_partial_scan; // scanline of last partial update + s32 m_partial_scan_hpos; // horizontal pixel last rendered on this partial scanline bitmap_argb32 m_screen_overlay_bitmap; // screen overlay bitmap - uint32_t m_unique_id; // unique id for this screen_device + u32 m_unique_id; // unique id for this screen_device rgb_t m_color; // render color - uint8_t m_brightness; // global brightness + u8 m_brightness; // global brightness // screen timing attoseconds_t m_frame_period; // attoseconds per frame @@ -337,8 +337,8 @@ private: emu_timer * m_vblank_end_timer; // timer to signal VBLANK end emu_timer * m_scanline0_timer; // scanline 0 timer emu_timer * m_scanline_timer; // scanline timer - uint64_t m_frame_number; // the current frame number - uint32_t m_partial_updates_this_frame;// partial update counter this frame + u64 m_frame_number; // the current frame number + u32 m_partial_updates_this_frame;// partial update counter this frame // VBLANK callbacks class callback_item @@ -362,7 +362,7 @@ private: std::vector> m_auto_bitmap_list; // list of registered bitmaps // static data - static uint32_t m_id_counter; // incremented for each constructed screen_device, + static u32 m_id_counter; // incremented for each constructed screen_device, // used as a unique identifier during runtime }; @@ -524,16 +524,16 @@ typedef device_type_iterator<&device_creator, screen_device> scre //------------------------------------------------- template -inline screen_update_ind16_delegate screen_update_delegate_smart(uint32_t (_FunctionClass::*callback)(screen_device &, bitmap_ind16 &, const rectangle &), const char *name, const char *devname) +inline screen_update_ind16_delegate screen_update_delegate_smart(u32 (_FunctionClass::*callback)(screen_device &, bitmap_ind16 &, const rectangle &), const char *name, const char *devname) { return screen_update_ind16_delegate(callback, name, devname, (_FunctionClass *)nullptr); } template -inline screen_update_rgb32_delegate screen_update_delegate_smart(uint32_t (_FunctionClass::*callback)(screen_device &, bitmap_rgb32 &, const rectangle &), const char *name, const char *devname) +inline screen_update_rgb32_delegate screen_update_delegate_smart(u32 (_FunctionClass::*callback)(screen_device &, bitmap_rgb32 &, const rectangle &), const char *name, const char *devname) { return screen_update_rgb32_delegate(callback, name, devname, (_FunctionClass *)nullptr); } -#endif /* __SCREEN_H__ */ +#endif /* MAME_EMU_SCREEN_H */ diff --git a/src/emu/softlist.cpp b/src/emu/softlist.cpp index bb03a9e2800..5182881274a 100644 --- a/src/emu/softlist.cpp +++ b/src/emu/softlist.cpp @@ -204,7 +204,7 @@ softlist_parser::softlist_parser(util::core_file &file, const std::string &filen char buffer[1024]; while (!m_done) { - uint32_t length = m_file.read(buffer, sizeof(buffer)); + u32 length = m_file.read(buffer, sizeof(buffer)); m_done = m_file.eof(); if (XML_Parse(m_parser, buffer, length, m_done) == XML_STATUS_ERROR) { @@ -341,7 +341,7 @@ bool softlist_parser::parse_name_and_value(const char **attributes, std::string // current part's list //------------------------------------------------- -void softlist_parser::add_rom_entry(std::string &&name, std::string &&hashdata, uint32_t offset, uint32_t length, uint32_t flags) +void softlist_parser::add_rom_entry(std::string &&name, std::string &&hashdata, u32 offset, u32 length, u32 flags) { // get the current part if (m_current_part == nullptr) @@ -597,7 +597,7 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu // handle region attributes const std::string &width = attrvalues[2]; const std::string &endianness = attrvalues[3]; - uint32_t regionflags = ROMENTRYTYPE_REGION; + u32 regionflags = ROMENTRYTYPE_REGION; if (!width.empty()) { @@ -689,8 +689,8 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu const std::string &loadflag = attrvalues[7]; if (!sizestr.empty() && !offsetstr.empty()) { - uint32_t length = strtol(sizestr.c_str(), nullptr, 0); - uint32_t offset = strtol(offsetstr.c_str(), nullptr, 0); + u32 length = strtol(sizestr.c_str(), nullptr, 0); + u32 offset = strtol(offsetstr.c_str(), nullptr, 0); if (loadflag == "reload") add_rom_entry("", "", offset, length, ROMENTRYTYPE_RELOAD | ROM_INHERITFLAGS); @@ -740,7 +740,7 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu } else if (!sizestr.empty() && !loadflag.empty() && loadflag == "ignore") { - uint32_t length = strtol(sizestr.c_str(), nullptr, 0); + u32 length = strtol(sizestr.c_str(), nullptr, 0); add_rom_entry("", "", 0, length, ROMENTRYTYPE_IGNORE | ROM_INHERITFLAGS); } else diff --git a/src/emu/softlist.h b/src/emu/softlist.h index 84face381bd..ad430a5aa28 100644 --- a/src/emu/softlist.h +++ b/src/emu/softlist.h @@ -12,6 +12,7 @@ #define __SOFTLIST_H_ #include +#include "emucore.h" #include "romentry.h" #include "corefile.h" @@ -120,7 +121,7 @@ public: const std::string &publisher() const { return m_publisher; } const std::list &other_info() const { return m_other_info; } const std::list &shared_info() const { return m_shared_info; } - uint32_t supported() const { return m_supported; } + u32 supported() const { return m_supported; } const std::list &parts() const { return m_partdata; } // additional operations @@ -129,7 +130,7 @@ public: private: // internal state - uint32_t m_supported; + u32 m_supported; std::string m_shortname; std::string m_longname; std::string m_parentname; @@ -174,7 +175,7 @@ private: // internal helpers template std::vector parse_attributes(const char **attributes, const T &attrlist); bool parse_name_and_value(const char **attributes, std::string &name, std::string &value); - void add_rom_entry(std::string &&name, std::string &&hashdata, uint32_t offset, uint32_t length, uint32_t flags); + void add_rom_entry(std::string &&name, std::string &&hashdata, u32 offset, u32 length, u32 flags); // expat callbacks static void start_handler(void *data, const char *tagname, const char **attributes); diff --git a/src/emu/softlist_dev.cpp b/src/emu/softlist_dev.cpp index 8b3fe027cb0..9e492204643 100644 --- a/src/emu/softlist_dev.cpp +++ b/src/emu/softlist_dev.cpp @@ -78,7 +78,7 @@ bool image_software_list_loader::load_software(device_image_interface &device, s // software_list_device - constructor //------------------------------------------------- -software_list_device::software_list_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +software_list_device::software_list_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, SOFTWARE_LIST, "Software list", tag, owner, clock, "software_list", __FILE__), m_list_type(SOFTWARE_LIST_ORIGINAL_SYSTEM), m_filter(nullptr), @@ -505,7 +505,7 @@ void software_list_device::internal_validity_check(validity_checker &valid) // make sure the year is only digits, '?' or '+' for (char ch : swinfo.year()) - if (!isdigit(uint8_t(ch)) && (ch != '?') && (ch != '+')) + if (!isdigit(u8(ch)) && (ch != '?') && (ch != '+')) { osd_printf_error("%s: %s has an invalid year '%s'\n", filename(), shortname.c_str(), swinfo.year().c_str()); break; diff --git a/src/emu/softlist_dev.h b/src/emu/softlist_dev.h index 384f0b2a22e..1c4b493ad50 100644 --- a/src/emu/softlist_dev.h +++ b/src/emu/softlist_dev.h @@ -132,7 +132,7 @@ class software_list_device : public device_t public: // construction/destruction - software_list_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + software_list_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); // inline configuration helpers static void static_set_type(device_t &device, const char *list, softlist_type list_type); diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp index 06828789dc5..24fb330ebe4 100644 --- a/src/emu/sound.cpp +++ b/src/emu/sound.cpp @@ -265,7 +265,7 @@ void sound_stream::update() { // determine the number of samples since the start of this second attotime time = m_device.machine().time(); - int32_t update_sampindex = int32_t(time.attoseconds() / m_attoseconds_per_sample); + s32 update_sampindex = s32(time.attoseconds() / m_attoseconds_per_sample); // if we're ahead of the last update, then adjust upwards attotime last_update = m_device.machine().sound().last_update(); @@ -294,7 +294,7 @@ void sound_stream::update() } -void sound_stream::sync_update(void *, int32_t) +void sound_stream::sync_update(void *, s32) { update(); attotime time = m_device.machine().time(); @@ -384,7 +384,7 @@ void sound_stream::update_with_accounting(bool second_tick) // if we've ticked over another second, adjust all the counters that are relative to // the current second - int32_t output_bufindex = m_output_sampindex - m_output_base_sampindex; + s32 output_bufindex = m_output_sampindex - m_output_base_sampindex; if (second_tick) { m_output_sampindex -= m_sample_rate; @@ -398,7 +398,7 @@ void sound_stream::update_with_accounting(bool second_tick) // we need to shuffle things down if (m_output_bufalloc - output_bufindex < 2 * m_max_samples_per_update) { - int32_t samples_to_lose = output_bufindex - m_max_samples_per_update; + s32 samples_to_lose = output_bufindex - m_max_samples_per_update; if (samples_to_lose > 0) { // if we have samples to move, do so for each output @@ -427,7 +427,7 @@ void sound_stream::apply_sample_rate_changes() return; // update to the new rate and remember the old rate - uint32_t old_rate = m_sample_rate; + u32 old_rate = m_sample_rate; m_sample_rate = m_new_sample_rate; m_new_sample_rate = 0; @@ -435,8 +435,8 @@ void sound_stream::apply_sample_rate_changes() recompute_sample_rate_data(); // reset our sample indexes to the current time - m_output_sampindex = (int64_t)m_output_sampindex * (int64_t)m_sample_rate / old_rate; - m_output_update_sampindex = (int64_t)m_output_update_sampindex * (int64_t)m_sample_rate / old_rate; + m_output_sampindex = s64(m_output_sampindex) * s64(m_sample_rate) / old_rate; + m_output_update_sampindex = s64(m_output_update_sampindex) * s64(m_sample_rate) / old_rate; m_output_base_sampindex = m_output_sampindex - m_max_samples_per_update; // clear out the buffer @@ -527,7 +527,7 @@ void sound_stream::recompute_sample_rate_data() void sound_stream::allocate_resample_buffers() { // compute the target number of samples - int32_t bufsize = 2 * m_max_samples_per_update; + s32 bufsize = 2 * m_max_samples_per_update; // if we don't have enough room, allocate more if (m_resample_bufalloc < bufsize) @@ -553,7 +553,7 @@ void sound_stream::allocate_resample_buffers() void sound_stream::allocate_output_buffers() { // if we don't have enough room, allocate more - int32_t bufsize = OUTPUT_BUFFER_UPDATES * m_max_samples_per_update; + s32 bufsize = OUTPUT_BUFFER_UPDATES * m_max_samples_per_update; if (m_output_bufalloc < bufsize) { // this becomes the new allocation size @@ -647,7 +647,7 @@ void sound_stream::generate_samples(int samples) // resample buffer for a given input //------------------------------------------------- -stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, uint32_t numsamples) +stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, u32 numsamples) { // if we don't have an output to pull data from, generate silence stream_sample_t *dest = &input.m_resample[0]; @@ -660,14 +660,14 @@ stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, uint // grab data from the output stream_output &output = *input.m_source; sound_stream &input_stream = *output.m_stream; - int64_t gain = (input.m_gain * input.m_user_gain * output.m_gain) >> 16; + s64 gain = (input.m_gain * input.m_user_gain * output.m_gain) >> 16; // determine the time at which the current sample begins, accounting for the // latency we calculated between the input and output streams attoseconds_t basetime = m_output_sampindex * m_attoseconds_per_sample - input.m_latency_attoseconds; // now convert that time into a sample in the input stream - int32_t basesample; + s32 basesample; if (basetime >= 0) basesample = basetime / input_stream.m_attoseconds_per_sample; else @@ -679,11 +679,11 @@ stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, uint // determine the current fraction of a sample, expressed as a fraction of FRAC_ONE // (Note: this formula is valid as long as input_stream.m_attoseconds_per_sample signficantly exceeds FRAC_ONE > attoseconds = 4.2E-12 s) - uint32_t basefrac = (basetime - basesample * input_stream.m_attoseconds_per_sample) / ((input_stream.m_attoseconds_per_sample + FRAC_ONE - 1) >> FRAC_BITS); + u32 basefrac = (basetime - basesample * input_stream.m_attoseconds_per_sample) / ((input_stream.m_attoseconds_per_sample + FRAC_ONE - 1) >> FRAC_BITS); assert(basefrac < FRAC_ONE); // compute the stepping fraction - uint32_t step = (uint64_t(input_stream.m_sample_rate) << FRAC_BITS) / m_sample_rate; + u32 step = (u64(input_stream.m_sample_rate) << FRAC_BITS) / m_sample_rate; // if we have equal sample rates, we just need to copy if (step == FRAC_ONE) @@ -691,7 +691,7 @@ stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, uint while (numsamples--) { // compute the sample - int64_t sample = *source++; + s64 sample = *source++; *dest++ = (sample * gain) >> 8; } } @@ -710,7 +710,7 @@ stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, uint } // if we're done, we're done - if (int32_t(numsamples--) < 0) + if (s32(numsamples--) < 0) break; // compute starting and ending fractional positions @@ -718,7 +718,7 @@ stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, uint int endfrac = nextfrac >> (FRAC_BITS - 12); // blend between the two samples accordingly - int64_t sample = ((int64_t) source[0] * (0x1000 - startfrac) + (int64_t) source[1] * (endfrac - 0x1000)) / (endfrac - startfrac); + s64 sample = (s64(source[0]) * (0x1000 - startfrac) + s64(source[1]) * (endfrac - 0x1000)) / (endfrac - startfrac); *dest++ = (sample * gain) >> 8; // advance @@ -734,19 +734,19 @@ stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, uint int smallstep = step >> (FRAC_BITS - 8); while (numsamples--) { - int64_t remainder = smallstep; + s64 remainder = smallstep; int tpos = 0; // compute the sample - int64_t scale = (FRAC_ONE - basefrac) >> (FRAC_BITS - 8); - int64_t sample = (int64_t) source[tpos++] * scale; + s64 scale = (FRAC_ONE - basefrac) >> (FRAC_BITS - 8); + s64 sample = s64(source[tpos++]) * scale; remainder -= scale; while (remainder > 0x100) { - sample += (int64_t) source[tpos++] * (int64_t) 0x100; + sample += s64(source[tpos++]) * s64(0x100); remainder -= 0x100; } - sample += (int64_t) source[tpos] * remainder; + sample += s64(source[tpos]) * remainder; sample /= smallstep; *dest++ = (sample * gain) >> 8; @@ -941,7 +941,7 @@ bool sound_manager::indexed_mixer_input(int index, mixer_input &info) const // mute - mute sound output //------------------------------------------------- -void sound_manager::mute(bool mute, uint8_t reason) +void sound_manager::mute(bool mute, u8 reason) { if (mute) m_muted |= reason; @@ -1063,16 +1063,16 @@ void sound_manager::update(void *ptr, int param) speaker.mix(&m_leftmix[0], &m_rightmix[0], samples_this_update, (m_muted & MUTE_REASON_SYSTEM)); // now downmix the final result - uint32_t finalmix_step = machine().video().speed_factor(); - uint32_t finalmix_offset = 0; - int16_t *finalmix = &m_finalmix[0]; + u32 finalmix_step = machine().video().speed_factor(); + u32 finalmix_offset = 0; + s16 *finalmix = &m_finalmix[0]; int sample; for (sample = m_finalmix_leftover; sample < samples_this_update * 1000; sample += finalmix_step) { int sampindex = sample / 1000; // clamp the left side - int32_t samp = m_leftmix[sampindex]; + s32 samp = m_leftmix[sampindex]; if (samp < -32768) samp = -32768; else if (samp > 32767) diff --git a/src/emu/sound.h b/src/emu/sound.h index 7fe244b2694..d9b9a61b830 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __SOUND_H__ -#define __SOUND_H__ +#ifndef MAME_EMU_SOUND_H +#define MAME_EMU_SOUND_H //************************************************************************** @@ -68,7 +68,7 @@ class sound_stream sound_stream * m_stream; // owning stream std::vector m_buffer; // output buffer int m_dependents; // number of dependents - int16_t m_gain; // gain to apply to the output + s16 m_gain; // gain to apply to the output }; // stream input class @@ -83,15 +83,15 @@ class sound_stream stream_output * m_source; // pointer to the sound_output for this source std::vector m_resample; // buffer for resampling to the stream's sample rate attoseconds_t m_latency_attoseconds; // latency between this stream and the input stream - int16_t m_gain; // gain to apply to this input - int16_t m_user_gain; // user-controlled gain to apply to this input + s16 m_gain; // gain to apply to this input + s16 m_user_gain; // user-controlled gain to apply to this input }; // constants - static const int OUTPUT_BUFFER_UPDATES = 5; - static const uint32_t FRAC_BITS = 22; - static const uint32_t FRAC_ONE = 1 << FRAC_BITS; - static const uint32_t FRAC_MASK = FRAC_ONE - 1; + static constexpr int OUTPUT_BUFFER_UPDATES = 5; + static constexpr u32 FRAC_BITS = 22; + static constexpr u32 FRAC_ONE = 1 << FRAC_BITS; + static constexpr u32 FRAC_MASK = FRAC_ONE - 1; public: // construction/destruction @@ -134,21 +134,21 @@ private: void allocate_output_buffers(); void postload(); void generate_samples(int samples); - stream_sample_t *generate_resampled_data(stream_input &input, uint32_t numsamples); - void sync_update(void *, int32_t); + stream_sample_t *generate_resampled_data(stream_input &input, u32 numsamples); + void sync_update(void *, s32); // linking information device_t & m_device; // owning device sound_stream * m_next; // next stream in the chain // general information - uint32_t m_sample_rate; // sample rate of this stream - uint32_t m_new_sample_rate; // newly-set sample rate for the stream + u32 m_sample_rate; // sample rate of this stream + u32 m_new_sample_rate; // newly-set sample rate for the stream bool m_synchronous; // synchronous stream that runs at the rate of its input // timing information attoseconds_t m_attoseconds_per_sample; // number of attoseconds per sample - int32_t m_max_samples_per_update; // maximum samples per update + s32 m_max_samples_per_update; // maximum samples per update emu_timer * m_sync_timer; // update timer for synchronous streams // input information @@ -156,17 +156,17 @@ private: std::vector m_input_array; // array of inputs for passing to the callback // resample buffer information - uint32_t m_resample_bufalloc; // allocated size of each resample buffer + u32 m_resample_bufalloc; // allocated size of each resample buffer // output information std::vector m_output; // list of streams which directly depend upon us std::vector m_output_array; // array of outputs for passing to the callback // output buffer information - uint32_t m_output_bufalloc; // allocated size of each output buffer - int32_t m_output_sampindex; // current position within each output buffer - int32_t m_output_update_sampindex; // position at time of last global update - int32_t m_output_base_sampindex; // sample at base of buffer, relative to the current emulated second + u32 m_output_bufalloc; // allocated size of each output buffer + s32 m_output_sampindex; // current position within each output buffer + s32 m_output_update_sampindex; // position at time of last global update + s32 m_output_base_sampindex; // sample at base of buffer, relative to the current emulated second // callback information stream_update_delegate m_callback; // callback function @@ -180,16 +180,16 @@ class sound_manager friend class sound_stream; // reasons for muting - static const uint8_t MUTE_REASON_PAUSE = 0x01; - static const uint8_t MUTE_REASON_UI = 0x02; - static const uint8_t MUTE_REASON_DEBUGGER = 0x04; - static const uint8_t MUTE_REASON_SYSTEM = 0x08; + static constexpr u8 MUTE_REASON_PAUSE = 0x01; + static constexpr u8 MUTE_REASON_UI = 0x02; + static constexpr u8 MUTE_REASON_DEBUGGER = 0x04; + static constexpr u8 MUTE_REASON_SYSTEM = 0x08; // stream updates static const attotime STREAMS_UPDATE_ATTOTIME; public: - static const int STREAMS_UPDATE_FREQUENCY = 50; + static constexpr int STREAMS_UPDATE_FREQUENCY = 50; // construction/destruction sound_manager(running_machine &machine); @@ -219,25 +219,25 @@ public: private: // internal helpers - void mute(bool mute, uint8_t reason); + void mute(bool mute, u8 reason); void reset(); void pause(); void resume(); void config_load(config_type cfg_type, xml_data_node *parentnode); void config_save(config_type cfg_type, xml_data_node *parentnode); - void update(void *ptr = nullptr, int32_t param = 0); + void update(void *ptr = nullptr, s32 param = 0); // internal state running_machine & m_machine; // reference to our machine emu_timer * m_update_timer; // timer to drive periodic updates - uint32_t m_finalmix_leftover; - std::vector m_finalmix; - std::vector m_leftmix; - std::vector m_rightmix; + u32 m_finalmix_leftover; + std::vector m_finalmix; + std::vector m_leftmix; + std::vector m_rightmix; - uint8_t m_muted; + u8 m_muted; int m_attenuation; int m_nosound_mode; @@ -250,4 +250,4 @@ private: }; -#endif /* __SOUND_H__ */ +#endif /* MAME_EMU_SOUND_H */ diff --git a/src/emu/speaker.cpp b/src/emu/speaker.cpp index 23a29217922..0fb2fd55605 100644 --- a/src/emu/speaker.cpp +++ b/src/emu/speaker.cpp @@ -39,7 +39,7 @@ const device_type SPEAKER = &device_creator; // speaker_device - constructor //------------------------------------------------- -speaker_device::speaker_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +speaker_device::speaker_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, SPEAKER, "Speaker", tag, owner, clock, "speaker", __FILE__), device_mixer_interface(mconfig, *this), m_x(0.0), @@ -87,7 +87,7 @@ void speaker_device::static_set_position(device_t &device, double x, double y, d // mix - mix in samples from the speaker's stream //------------------------------------------------- -void speaker_device::mix(int32_t *leftmix, int32_t *rightmix, int &samples_this_update, bool suppress) +void speaker_device::mix(s32 *leftmix, s32 *rightmix, int &samples_this_update, bool suppress) { // skip if no stream if (m_mixer_stream == nullptr) diff --git a/src/emu/speaker.h b/src/emu/speaker.h index 0260b5fe2ac..93183370642 100644 --- a/src/emu/speaker.h +++ b/src/emu/speaker.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __SPEAKER_H__ -#define __SPEAKER_H__ +#ifndef MAME_EMU_SPEAKER_H +#define MAME_EMU_SPEAKER_H //************************************************************************** @@ -57,14 +57,14 @@ class speaker_device : public device_t, public: // construction/destruction - speaker_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + speaker_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); virtual ~speaker_device(); // inline configuration helpers static void static_set_position(device_t &device, double x, double y, double z); // internally for use by the sound system - void mix(int32_t *leftmix, int32_t *rightmix, int &samples_this_update, bool suppress); + void mix(s32 *leftmix, s32 *rightmix, int &samples_this_update, bool suppress); protected: // device-level overrides @@ -77,9 +77,9 @@ protected: // internal state #ifdef MAME_DEBUG - int32_t m_max_sample; // largest sample value we've seen - int32_t m_clipped_samples; // total number of clipped samples - int32_t m_total_samples; // total number of samples + s32 m_max_sample; // largest sample value we've seen + s32 m_clipped_samples; // total number of clipped samples + s32 m_total_samples; // total number of samples #endif }; @@ -88,4 +88,4 @@ protected: typedef device_type_iterator<&device_creator, speaker_device> speaker_device_iterator; -#endif /* __SOUND_H__ */ +#endif /* MAME_EMU_SPEAKER_H */ diff --git a/src/emu/tilemap.cpp b/src/emu/tilemap.cpp index d8e5d1b0ea0..13531985467 100644 --- a/src/emu/tilemap.cpp +++ b/src/emu/tilemap.cpp @@ -21,14 +21,14 @@ // account tilemap flip states //------------------------------------------------- -inline int32_t tilemap_t::effective_rowscroll(int index, uint32_t screen_width) +inline s32 tilemap_t::effective_rowscroll(int index, u32 screen_width) { // if we're flipping vertically, adjust the row number if (m_attributes & TILEMAP_FLIPY) index = m_scrollrows - 1 - index; // adjust final result based on the horizontal flip and dx values - int32_t value; + s32 value; if (!(m_attributes & TILEMAP_FLIPX)) value = m_dx - m_rowscroll[index]; else @@ -49,14 +49,14 @@ inline int32_t tilemap_t::effective_rowscroll(int index, uint32_t screen_width) // account tilemap flip states //------------------------------------------------- -inline int32_t tilemap_t::effective_colscroll(int index, uint32_t screen_height) +inline s32 tilemap_t::effective_colscroll(int index, u32 screen_height) { // if we're flipping horizontally, adjust the column number if (m_attributes & TILEMAP_FLIPX) index = m_scrollcols - 1 - index; // adjust final result based on the vertical flip and dx values - int32_t value; + s32 value; if (!(m_attributes & TILEMAP_FLIPY)) value = m_dy - m_colscroll[index]; else @@ -79,7 +79,7 @@ inline int32_t tilemap_t::effective_colscroll(int index, uint32_t screen_height) inline bool tilemap_t::gfx_elements_changed() { - uint32_t usedmask = m_gfx_used; + u32 usedmask = m_gfx_used; bool isdirty = false; // iterate over all used gfx types and set the dirty flag if any of them have changed @@ -104,7 +104,7 @@ inline bool tilemap_t::gfx_elements_changed() // bitmap, setting priority only //------------------------------------------------- -inline void tilemap_t::scanline_draw_opaque_null(int count, uint8_t *pri, uint32_t pcode) +inline void tilemap_t::scanline_draw_opaque_null(int count, u8 *pri, u32 pcode) { // skip entirely if not changing priority if (pcode == 0xff00) @@ -121,7 +121,7 @@ inline void tilemap_t::scanline_draw_opaque_null(int count, uint8_t *pri, uint32 // bitmap using a mask, setting priority only //------------------------------------------------- -inline void tilemap_t::scanline_draw_masked_null(const uint8_t *maskptr, int mask, int value, int count, uint8_t *pri, uint32_t pcode) +inline void tilemap_t::scanline_draw_masked_null(const u8 *maskptr, int mask, int value, int count, u8 *pri, u32 pcode) { // skip entirely if not changing priority if (pcode == 0xff00) @@ -140,7 +140,7 @@ inline void tilemap_t::scanline_draw_masked_null(const uint8_t *maskptr, int mas // indexed bitmap //------------------------------------------------- -inline void tilemap_t::scanline_draw_opaque_ind16(uint16_t *dest, const uint16_t *source, int count, uint8_t *pri, uint32_t pcode) +inline void tilemap_t::scanline_draw_opaque_ind16(u16 *dest, const u16 *source, int count, u8 *pri, u32 pcode) { // special case for no palette offset int pal = pcode >> 16; @@ -182,7 +182,7 @@ inline void tilemap_t::scanline_draw_opaque_ind16(uint16_t *dest, const uint16_t // indexed bitmap using a mask //------------------------------------------------- -inline void tilemap_t::scanline_draw_masked_ind16(uint16_t *dest, const uint16_t *source, const uint8_t *maskptr, int mask, int value, int count, uint8_t *pri, uint32_t pcode) +inline void tilemap_t::scanline_draw_masked_ind16(u16 *dest, const u16 *source, const u8 *maskptr, int mask, int value, int count, u8 *pri, u32 pcode) { int pal = pcode >> 16; @@ -213,7 +213,7 @@ inline void tilemap_t::scanline_draw_masked_ind16(uint16_t *dest, const uint16_t // RGB bitmap //------------------------------------------------- -inline void tilemap_t::scanline_draw_opaque_rgb32(uint32_t *dest, const uint16_t *source, int count, const rgb_t *pens, uint8_t *pri, uint32_t pcode) +inline void tilemap_t::scanline_draw_opaque_rgb32(u32 *dest, const u16 *source, int count, const rgb_t *pens, u8 *pri, u32 pcode) { const rgb_t *clut = &pens[pcode >> 16]; @@ -241,7 +241,7 @@ inline void tilemap_t::scanline_draw_opaque_rgb32(uint32_t *dest, const uint16_t // RGB bitmap using a mask //------------------------------------------------- -inline void tilemap_t::scanline_draw_masked_rgb32(uint32_t *dest, const uint16_t *source, const uint8_t *maskptr, int mask, int value, int count, const rgb_t *pens, uint8_t *pri, uint32_t pcode) +inline void tilemap_t::scanline_draw_masked_rgb32(u32 *dest, const u16 *source, const u8 *maskptr, int mask, int value, int count, const rgb_t *pens, u8 *pri, u32 pcode) { const rgb_t *clut = &pens[pcode >> 16]; @@ -271,7 +271,7 @@ inline void tilemap_t::scanline_draw_masked_rgb32(uint32_t *dest, const uint16_t // 32bpp RGB bitmap with alpha blending //------------------------------------------------- -inline void tilemap_t::scanline_draw_opaque_rgb32_alpha(uint32_t *dest, const uint16_t *source, int count, const rgb_t *pens, uint8_t *pri, uint32_t pcode, uint8_t alpha) +inline void tilemap_t::scanline_draw_opaque_rgb32_alpha(u32 *dest, const u16 *source, int count, const rgb_t *pens, u8 *pri, u32 pcode, u8 alpha) { const rgb_t *clut = &pens[pcode >> 16]; @@ -300,7 +300,7 @@ inline void tilemap_t::scanline_draw_opaque_rgb32_alpha(uint32_t *dest, const ui // blending //------------------------------------------------- -inline void tilemap_t::scanline_draw_masked_rgb32_alpha(uint32_t *dest, const uint16_t *source, const uint8_t *maskptr, int mask, int value, int count, const rgb_t *pens, uint8_t *pri, uint32_t pcode, uint8_t alpha) +inline void tilemap_t::scanline_draw_masked_rgb32_alpha(u32 *dest, const u16 *source, const u8 *maskptr, int mask, int value, int count, const rgb_t *pens, u8 *pri, u32 pcode, u8 alpha) { const rgb_t *clut = &pens[pcode >> 16]; @@ -343,7 +343,7 @@ tilemap_t::tilemap_t() // init - initialize the tilemap //------------------------------------------------- -tilemap_t &tilemap_t::init(tilemap_manager &manager, device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, uint16_t tilewidth, uint16_t tileheight, uint32_t cols, uint32_t rows) +tilemap_t &tilemap_t::init(tilemap_manager &manager, device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, u16 tilewidth, u16 tileheight, u32 cols, u32 rows) { // populate managers and devices m_manager = &manager; @@ -463,7 +463,7 @@ void tilemap_t::mark_tile_dirty(tilemap_memory_index memindex) // a layer //------------------------------------------------- -void tilemap_t::map_pens_to_layer(int group, pen_t pen, pen_t mask, uint8_t layermask) +void tilemap_t::map_pens_to_layer(int group, pen_t pen, pen_t mask, u8 layermask) { assert(group < TILEMAP_NUM_GROUPS); assert((layermask & TILEMAP_PIXEL_CATEGORY_MASK) == 0); @@ -478,7 +478,7 @@ void tilemap_t::map_pens_to_layer(int group, pen_t pen, pen_t mask, uint8_t laye stop = std::min(stop, MAX_PEN_TO_FLAGS - 1); // iterate and set - uint8_t *array = m_pen_to_flags + group * MAX_PEN_TO_FLAGS; + u8 *array = m_pen_to_flags + group * MAX_PEN_TO_FLAGS; bool changed = false; for (pen_t cur = start; cur <= stop; cur++) if ((cur & mask) == pen && array[cur] != layermask) @@ -515,13 +515,13 @@ void tilemap_t::set_transparent_pen(pen_t pen) // background mask (mapping to layer 1) //------------------------------------------------- -void tilemap_t::set_transmask(int group, uint32_t fgmask, uint32_t bgmask) +void tilemap_t::set_transmask(int group, u32 fgmask, u32 bgmask) { // iterate over all 32 pens specified for (pen_t pen = 0; pen < 32; pen++) { - uint8_t fgbits = ((fgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER0; - uint8_t bgbits = ((bgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER1; + u8 fgbits = ((fgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER0; + u8 bgbits = ((bgmask >> pen) & 1) ? TILEMAP_PIXEL_TRANSPARENT : TILEMAP_PIXEL_LAYER1; map_pen_to_layer(group, pen, fgbits | bgbits); } } @@ -538,7 +538,7 @@ void tilemap_t::configure_groups(gfx_element &gfx, indirect_pen_t transcolor) assert(gfx.colors() <= TILEMAP_NUM_GROUPS); // iterate over all colors in the tilemap - for (uint32_t color = 0; color < gfx.colors(); color++) + for (u32 color = 0; color < gfx.colors(); color++) set_transmask(color, m_palette->transpen_mask(gfx, color, transcolor), 0); } @@ -556,22 +556,22 @@ void tilemap_t::configure_groups(gfx_element &gfx, indirect_pen_t transcolor) // order with optional flipping //------------------------------------------------- -tilemap_memory_index tilemap_t::scan_rows(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows) +tilemap_memory_index tilemap_t::scan_rows(u32 col, u32 row, u32 num_cols, u32 num_rows) { return row * num_cols + col; } -tilemap_memory_index tilemap_t::scan_rows_flip_x(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows) +tilemap_memory_index tilemap_t::scan_rows_flip_x(u32 col, u32 row, u32 num_cols, u32 num_rows) { return row * num_cols + (num_cols - 1 - col); } -tilemap_memory_index tilemap_t::scan_rows_flip_y(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows) +tilemap_memory_index tilemap_t::scan_rows_flip_y(u32 col, u32 row, u32 num_cols, u32 num_rows) { return (num_rows - 1 - row) * num_cols + col; } -tilemap_memory_index tilemap_t::scan_rows_flip_xy(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows) +tilemap_memory_index tilemap_t::scan_rows_flip_xy(u32 col, u32 row, u32 num_cols, u32 num_rows) { return (num_rows - 1 - row) * num_cols + (num_cols - 1 - col); } @@ -585,22 +585,22 @@ tilemap_memory_index tilemap_t::scan_rows_flip_xy(uint32_t col, uint32_t row, ui // major order with optional flipping //------------------------------------------------- -tilemap_memory_index tilemap_t::scan_cols(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows) +tilemap_memory_index tilemap_t::scan_cols(u32 col, u32 row, u32 num_cols, u32 num_rows) { return col * num_rows + row; } -tilemap_memory_index tilemap_t::scan_cols_flip_x(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows) +tilemap_memory_index tilemap_t::scan_cols_flip_x(u32 col, u32 row, u32 num_cols, u32 num_rows) { return (num_cols - 1 - col) * num_rows + row; } -tilemap_memory_index tilemap_t::scan_cols_flip_y(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows) +tilemap_memory_index tilemap_t::scan_cols_flip_y(u32 col, u32 row, u32 num_cols, u32 num_rows) { return col * num_rows + (num_rows - 1 - row); } -tilemap_memory_index tilemap_t::scan_cols_flip_xy(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows) +tilemap_memory_index tilemap_t::scan_cols_flip_xy(u32 col, u32 row, u32 num_cols, u32 num_rows) { return (num_cols - 1 - col) * num_rows + (num_rows - 1 - row); } @@ -634,8 +634,8 @@ void tilemap_t::mappings_create() // compute the maximum memory index tilemap_memory_index max_memory_index = 0; - for (uint32_t row = 0; row < m_rows; row++) - for (uint32_t col = 0; col < m_cols; col++) + for (u32 row = 0; row < m_rows; row++) + for (u32 col = 0; col < m_cols; col++) { tilemap_memory_index memindex = memory_index(col, row); max_memory_index = std::max(max_memory_index, memindex); @@ -665,8 +665,8 @@ void tilemap_t::mappings_update() // now iterate over all logical indexes and populate the memory index for (logical_index logindex = 0; logindex < m_logical_to_memory.size(); logindex++) { - uint32_t logical_col = logindex % m_cols; - uint32_t logical_row = logindex / m_cols; + u32 logical_col = logindex % m_cols; + u32 logical_row = logindex / m_cols; tilemap_memory_index memindex = memory_index(logical_col, logical_row); // apply tilemap flip to get the final location to store @@ -674,7 +674,7 @@ void tilemap_t::mappings_update() logical_col = (m_cols - 1) - logical_col; if (m_attributes & TILEMAP_FLIPY) logical_row = (m_rows - 1) - logical_row; - uint32_t flipped_logindex = logical_row * m_cols + logical_col; + u32 flipped_logindex = logical_row * m_cols + logical_col; // fill in entries in both arrays m_memory_to_logical[memindex] = flipped_logindex; @@ -724,8 +724,8 @@ g_profiler.start(PROFILER_TILEMAP_DRAW); // iterate over rows and columns logical_index logindex = 0; - for (uint32_t row = 0; row < m_rows; row++) - for (uint32_t col = 0; col < m_cols; col++, logindex++) + for (u32 row = 0; row < m_rows; row++) + for (u32 col = 0; col < m_cols; col++, logindex++) if (m_tileflags[logindex] == TILE_FLAG_DIRTY) tile_update(logindex, col, row); @@ -740,7 +740,7 @@ g_profiler.stop(); // tile_update - update a single dirty tile //------------------------------------------------- -void tilemap_t::tile_update(logical_index logindex, uint32_t col, uint32_t row) +void tilemap_t::tile_update(logical_index logindex, u32 col, u32 row) { g_profiler.start(PROFILER_TILEMAP_UPDATE); @@ -749,11 +749,11 @@ g_profiler.start(PROFILER_TILEMAP_UPDATE); m_tile_get_info(*this, m_tileinfo, memindex); // apply the global tilemap flip to the returned flip flags - uint32_t flags = m_tileinfo.flags ^ (m_attributes & 0x03); + u32 flags = m_tileinfo.flags ^ (m_attributes & 0x03); // draw the tile, using either direct or transparent - uint32_t x0 = m_tilewidth * col; - uint32_t y0 = m_tileheight * row; + u32 x0 = m_tilewidth * col; + u32 y0 = m_tileheight * row; m_tileflags[logindex] = tile_draw(m_tileinfo.pen_data, x0, y0, m_tileinfo.palette_base, m_tileinfo.category, m_tileinfo.group, flags, m_tileinfo.pen_mask); @@ -779,7 +779,7 @@ g_profiler.stop(); // the palette_base //------------------------------------------------- -uint8_t tilemap_t::tile_draw(const uint8_t *pendata, uint32_t x0, uint32_t y0, uint32_t palette_base, uint8_t category, uint8_t group, uint8_t flags, uint8_t pen_mask) +u8 tilemap_t::tile_draw(const u8 *pendata, u32 x0, u32 y0, u32 palette_base, u8 category, u8 group, u8 flags, u8 pen_mask) { // OR in the force layer flags category |= flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2); @@ -801,22 +801,22 @@ uint8_t tilemap_t::tile_draw(const uint8_t *pendata, uint32_t x0, uint32_t y0, u } // iterate over rows - const uint8_t *penmap = m_pen_to_flags + group * MAX_PEN_TO_FLAGS; - uint8_t andmask = ~0, ormask = 0; - for (uint16_t ty = 0; ty < m_tileheight; ty++) + const u8 *penmap = m_pen_to_flags + group * MAX_PEN_TO_FLAGS; + u8 andmask = ~0, ormask = 0; + for (u16 ty = 0; ty < m_tileheight; ty++) { - uint16_t *pixptr = &m_pixmap.pix16(y0, x0); - uint8_t *flagsptr = &m_flagsmap.pix8(y0, x0); + u16 *pixptr = &m_pixmap.pix16(y0, x0); + u8 *flagsptr = &m_flagsmap.pix8(y0, x0); // pre-advance to the next row y0 += dy0; // 8bpp data int xoffs = 0; - for (uint16_t tx = 0; tx < m_tilewidth; tx++) + for (u16 tx = 0; tx < m_tilewidth; tx++) { - uint8_t pen = (*pendata++) & pen_mask; - uint8_t map = penmap[pen]; + u8 pen = (*pendata++) & pen_mask; + u8 map = penmap[pen]; pixptr[xoffs] = palette_base + pen; flagsptr[xoffs] = map | category; andmask &= map; @@ -834,7 +834,7 @@ uint8_t tilemap_t::tile_draw(const uint8_t *pendata, uint32_t x0, uint32_t y0, u // flagsmap appropriately //------------------------------------------------- -uint8_t tilemap_t::tile_apply_bitmask(const uint8_t *maskdata, uint32_t x0, uint32_t y0, uint8_t category, uint8_t flags) +u8 tilemap_t::tile_apply_bitmask(const u8 *maskdata, u32 x0, u32 y0, u8 category, u8 flags) { // if we're vertically flipped, point to the bottom row and work backwards int dy0 = 1; @@ -853,19 +853,19 @@ uint8_t tilemap_t::tile_apply_bitmask(const uint8_t *maskdata, uint32_t x0, uint } // iterate over rows - uint8_t andmask = ~0, ormask = 0; + u8 andmask = ~0, ormask = 0; int bitoffs = 0; - for (uint16_t ty = 0; ty < m_tileheight; ty++) + for (u16 ty = 0; ty < m_tileheight; ty++) { // pre-advance to the next row - uint8_t *flagsptr = &m_flagsmap.pix8(y0, x0); + u8 *flagsptr = &m_flagsmap.pix8(y0, x0); y0 += dy0; // anywhere the bitmask is 0 should be transparent int xoffs = 0; - for (uint16_t tx = 0; tx < m_tilewidth; tx++) + for (u16 tx = 0; tx < m_tilewidth; tx++) { - uint8_t map = flagsptr[xoffs]; + u8 map = flagsptr[xoffs]; if ((maskdata[bitoffs / 8] & (0x80 >> (bitoffs & 7))) == 0) map = flagsptr[xoffs] = TILEMAP_PIXEL_TRANSPARENT | category; @@ -891,7 +891,7 @@ uint8_t tilemap_t::tile_apply_bitmask(const uint8_t *maskdata, uint32_t x0, uint // and indexed drawing code //------------------------------------------------- -void tilemap_t::configure_blit_parameters(blit_parameters &blit, bitmap_ind8 &priority_bitmap, const rectangle &cliprect, uint32_t flags, uint8_t priority, uint8_t priority_mask) +void tilemap_t::configure_blit_parameters(blit_parameters &blit, bitmap_ind8 &priority_bitmap, const rectangle &cliprect, u32 flags, u8 priority, u8 priority_mask) { // set the target bitmap blit.priority = &priority_bitmap; @@ -936,7 +936,7 @@ void tilemap_t::configure_blit_parameters(blit_parameters &blit, bitmap_ind8 &pr //------------------------------------------------- template -void tilemap_t::draw_common(screen_device &screen, _BitmapClass &dest, const rectangle &cliprect, uint32_t flags, uint8_t priority, uint8_t priority_mask) +void tilemap_t::draw_common(screen_device &screen, _BitmapClass &dest, const rectangle &cliprect, u32 flags, u8 priority, u8 priority_mask) { // skip if disabled if (!m_enable) @@ -952,8 +952,8 @@ g_profiler.start(PROFILER_TILEMAP_DRAW); // flip the tilemap around the center of the visible area rectangle visarea = screen.visible_area(); - uint32_t width = visarea.min_x + visarea.max_x + 1; - uint32_t height = visarea.min_y + visarea.max_y + 1; + u32 width = visarea.min_x + visarea.max_x + 1; + u32 height = visarea.min_y + visarea.max_y + 1; // XY scrolling playfield if (m_scrollrows == 1 && m_scrollcols == 1) @@ -977,7 +977,7 @@ g_profiler.start(PROFILER_TILEMAP_DRAW); for (int ypos = scrolly - m_height; ypos <= original_cliprect.max_y; ypos += m_height) { int const firstrow = std::max((original_cliprect.min_y - ypos) / rowheight, 0); - int const lastrow = std::min((original_cliprect.max_y - ypos) / rowheight, int32_t(m_scrollrows) - 1); + int const lastrow = std::min((original_cliprect.max_y - ypos) / rowheight, s32(m_scrollrows) - 1); // iterate over rows in the tilemap int nextrow; @@ -1043,10 +1043,10 @@ g_profiler.start(PROFILER_TILEMAP_DRAW); g_profiler.stop(); } -void tilemap_t::draw(screen_device &screen, bitmap_ind16 &dest, const rectangle &cliprect, uint32_t flags, uint8_t priority, uint8_t priority_mask) +void tilemap_t::draw(screen_device &screen, bitmap_ind16 &dest, const rectangle &cliprect, u32 flags, u8 priority, u8 priority_mask) { draw_common(screen, dest, cliprect, flags, priority, priority_mask); } -void tilemap_t::draw(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t flags, uint8_t priority, uint8_t priority_mask) +void tilemap_t::draw(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, u32 flags, u8 priority, u8 priority_mask) { draw_common(screen, dest, cliprect, flags, priority, priority_mask); } @@ -1059,11 +1059,11 @@ void tilemap_t::draw(screen_device &screen, bitmap_rgb32 &dest, const rectangle template void tilemap_t::draw_roz_common(screen_device &screen, _BitmapClass &dest, const rectangle &cliprect, - uint32_t startx, uint32_t starty, int incxx, int incxy, int incyx, int incyy, - bool wraparound, uint32_t flags, uint8_t priority, uint8_t priority_mask) + u32 startx, u32 starty, int incxx, int incxy, int incyx, int incyy, + bool wraparound, u32 flags, u8 priority, u8 priority_mask) { // notes: -// - startx and starty MUST be uint32_t for calculations to work correctly +// - startx and starty MUST be u32 for calculations to work correctly // - srcbim_width and height are assumed to be a power of 2 to speed up wraparound // skip if disabled @@ -1093,13 +1093,13 @@ g_profiler.stop(); } void tilemap_t::draw_roz(screen_device &screen, bitmap_ind16 &dest, const rectangle &cliprect, - uint32_t startx, uint32_t starty, int incxx, int incxy, int incyx, int incyy, - bool wraparound, uint32_t flags, uint8_t priority, uint8_t priority_mask) + u32 startx, u32 starty, int incxx, int incxy, int incyx, int incyy, + bool wraparound, u32 flags, u8 priority, u8 priority_mask) { draw_roz_common(screen, dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); } void tilemap_t::draw_roz(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, - uint32_t startx, uint32_t starty, int incxx, int incxy, int incyx, int incyy, - bool wraparound, uint32_t flags, uint8_t priority, uint8_t priority_mask) + u32 startx, u32 starty, int incxx, int incxy, int incyx, int incyy, + bool wraparound, u32 flags, u8 priority, u8 priority_mask) { draw_roz_common(screen, dest, cliprect, startx, starty, incxx, incxy, incyx, incyy, wraparound, flags, priority, priority_mask); } @@ -1125,7 +1125,7 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b // look up priority and destination base addresses for y1 bitmap_ind8 &priority_bitmap = *blit.priority; - uint8_t *priority_baseaddr = &priority_bitmap.pix8(y1, xpos); + u8 *priority_baseaddr = &priority_bitmap.pix8(y1, xpos); typename _BitmapClass::pixel_t *dest_baseaddr = nullptr; int dest_rowpixels = 0; if (dest.valid()) @@ -1141,8 +1141,8 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b y2 -= ypos; // get tilemap pixels - const uint16_t *source_baseaddr = &m_pixmap.pix16(y1); - const uint8_t *mask_baseaddr = &m_flagsmap.pix8(y1); + const u16 *source_baseaddr = &m_pixmap.pix16(y1); + const u8 *mask_baseaddr = &m_flagsmap.pix8(y1); // get start/stop columns, rounding outward int mincol = x1 / m_tilewidth; @@ -1201,9 +1201,9 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b const rgb_t *clut = m_palette->palette()->entry_list_adjusted(); if (prev_trans != WHOLLY_TRANSPARENT) { - const uint16_t *source0 = source_baseaddr + x_start; + const u16 *source0 = source_baseaddr + x_start; typename _BitmapClass::pixel_t *dest0 = dest_baseaddr + x_start; - uint8_t *pmap0 = priority_baseaddr + x_start; + u8 *pmap0 = priority_baseaddr + x_start; // if we were opaque, use the opaque renderer if (prev_trans == WHOLLY_OPAQUE) @@ -1213,11 +1213,11 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b if (dest_baseaddr == nullptr) scanline_draw_opaque_null(x_end - x_start, pmap0, blit.tilemap_priority_code); else if (sizeof(*dest0) == 2) - scanline_draw_opaque_ind16(reinterpret_cast(dest0), source0, x_end - x_start, pmap0, blit.tilemap_priority_code); + scanline_draw_opaque_ind16(reinterpret_cast(dest0), source0, x_end - x_start, pmap0, blit.tilemap_priority_code); else if (sizeof(*dest0) == 4 && blit.alpha >= 0xff) - scanline_draw_opaque_rgb32(reinterpret_cast(dest0), source0, x_end - x_start, clut, pmap0, blit.tilemap_priority_code); + scanline_draw_opaque_rgb32(reinterpret_cast(dest0), source0, x_end - x_start, clut, pmap0, blit.tilemap_priority_code); else if (sizeof(*dest0) == 4) - scanline_draw_opaque_rgb32_alpha(reinterpret_cast(dest0), source0, x_end - x_start, clut, pmap0, blit.tilemap_priority_code, blit.alpha); + scanline_draw_opaque_rgb32_alpha(reinterpret_cast(dest0), source0, x_end - x_start, clut, pmap0, blit.tilemap_priority_code, blit.alpha); dest0 += dest_rowpixels; source0 += m_pixmap.rowpixels(); @@ -1228,17 +1228,17 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b // otherwise use the masked renderer else { - const uint8_t *mask0 = mask_baseaddr + x_start; + const u8 *mask0 = mask_baseaddr + x_start; for (int cury = y; cury < nexty; cury++) { if (dest_baseaddr == nullptr) scanline_draw_masked_null(mask0, blit.mask, blit.value, x_end - x_start, pmap0, blit.tilemap_priority_code); else if (sizeof(*dest0) == 2) - scanline_draw_masked_ind16(reinterpret_cast(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, pmap0, blit.tilemap_priority_code); + scanline_draw_masked_ind16(reinterpret_cast(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, pmap0, blit.tilemap_priority_code); else if (sizeof(*dest0) == 4 && blit.alpha >= 0xff) - scanline_draw_masked_rgb32(reinterpret_cast(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, clut, pmap0, blit.tilemap_priority_code); + scanline_draw_masked_rgb32(reinterpret_cast(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, clut, pmap0, blit.tilemap_priority_code); else if (sizeof(*dest0) == 4) - scanline_draw_masked_rgb32_alpha(reinterpret_cast(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, clut, pmap0, blit.tilemap_priority_code, blit.alpha); + scanline_draw_masked_rgb32_alpha(reinterpret_cast(dest0), source0, mask0, blit.mask, blit.value, x_end - x_start, clut, pmap0, blit.tilemap_priority_code, blit.alpha); dest0 += dest_rowpixels; source0 += m_pixmap.rowpixels(); @@ -1289,7 +1289,7 @@ do { \ template void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, const blit_parameters &blit, - uint32_t startx, uint32_t starty, int incxx, int incxy, int incyx, int incyy, bool wraparound) + u32 startx, u32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound) { // pre-cache all the inner loop values const rgb_t *clut = m_palette->palette()->entry_list_adjusted() + (blit.tilemap_priority_code >> 16); @@ -1298,10 +1298,10 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c const int ymask = m_pixmap.height() - 1; const int widthshifted = m_pixmap.width() << 16; const int heightshifted = m_pixmap.height() << 16; - uint32_t priority = blit.tilemap_priority_code; - uint8_t mask = blit.mask; - uint8_t value = blit.value; - uint8_t alpha = blit.alpha; + u32 priority = blit.tilemap_priority_code; + u8 mask = blit.mask; + u8 value = blit.value; + u8 alpha = blit.alpha; // pre-advance based on the cliprect startx += blit.cliprect.min_x * incxx + blit.cliprect.min_y * incyx; @@ -1335,13 +1335,13 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c { // initialize X counters int x = sx; - uint32_t cx = startx; - uint32_t cy = starty >> 16; + u32 cx = startx; + u32 cy = starty >> 16; // get source and priority pointers - uint8_t *pri = &priority_bitmap.pix8(sy, sx); - const uint16_t *src = &m_pixmap.pix16(cy); - const uint8_t *maskptr = &m_flagsmap.pix8(cy); + u8 *pri = &priority_bitmap.pix8(sy, sx); + const u16 *src = &m_pixmap.pix16(cy); + const u8 *maskptr = &m_flagsmap.pix8(cy); typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx); // loop over columns @@ -1376,12 +1376,12 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c { // initialize X counters int x = sx; - uint32_t cx = startx; - uint32_t cy = starty; + u32 cx = startx; + u32 cy = starty; // get dest and priority pointers typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx); - uint8_t *pri = &priority_bitmap.pix8(sy, sx); + u8 *pri = &priority_bitmap.pix8(sy, sx); // loop over columns while (x <= ex) @@ -1416,12 +1416,12 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c { // initialize X counters int x = sx; - uint32_t cx = startx; - uint32_t cy = starty; + u32 cx = startx; + u32 cy = starty; // get dest and priority pointers typename _BitmapClass::pixel_t *dest = &destbitmap.pix(sy, sx); - uint8_t *pri = &priority_bitmap.pix8(sy, sx); + u8 *pri = &priority_bitmap.pix8(sy, sx); // loop over columns while (x <= ex) @@ -1456,7 +1456,7 @@ void tilemap_t::draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, c // rowscroll and with fixed parameters //------------------------------------------------- -void tilemap_t::draw_debug(screen_device &screen, bitmap_rgb32 &dest, uint32_t scrollx, uint32_t scrolly) +void tilemap_t::draw_debug(screen_device &screen, bitmap_rgb32 &dest, u32 scrollx, u32 scrolly) { // set up for the blit, using hard-coded parameters (no priority, etc) blit_parameters blit; @@ -1481,7 +1481,7 @@ void tilemap_t::draw_debug(screen_device &screen, bitmap_rgb32 &dest, uint32_t s // get_info_debug - extract info for one tile //------------------------------------------------- -void tilemap_t::get_info_debug(uint32_t col, uint32_t row, uint8_t &gfxnum, uint32_t &code, uint32_t &color) +void tilemap_t::get_info_debug(u32 col, u32 row, u8 &gfxnum, u32 &code, u32 &color) { // first map to the memory index tilemap_memory_index memindex = memory_index(col, row); @@ -1542,14 +1542,14 @@ tilemap_manager::~tilemap_manager() // tilemaps //------------------------------------------------- -tilemap_t &tilemap_manager::create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, uint16_t tilewidth, uint16_t tileheight, uint32_t cols, uint32_t rows, tilemap_t *allocated) +tilemap_t &tilemap_manager::create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, u16 tilewidth, u16 tileheight, u32 cols, u32 rows, tilemap_t *allocated) { if (allocated == nullptr) allocated = global_alloc(tilemap_t); return m_tilemap_list.append(allocated->init(*this, decoder, tile_get_info, mapper, tilewidth, tileheight, cols, rows)); } -tilemap_t &tilemap_manager::create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_standard_mapper mapper, uint16_t tilewidth, uint16_t tileheight, uint32_t cols, uint32_t rows, tilemap_t *allocated) +tilemap_t &tilemap_manager::create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_standard_mapper mapper, u16 tilewidth, u16 tileheight, u32 cols, u32 rows, tilemap_t *allocated) { if (allocated == nullptr) allocated = global_alloc(tilemap_t); @@ -1574,7 +1574,7 @@ tilemap_t &tilemap_manager::create(device_gfx_interface &decoder, tilemap_get_in // tilemaps //------------------------------------------------- -void tilemap_manager::set_flip_all(uint32_t attributes) +void tilemap_manager::set_flip_all(u32 attributes) { for (tilemap_t &tmap : m_tilemap_list) tmap.set_flip(attributes); @@ -1605,7 +1605,7 @@ const device_type TILEMAP = &device_creator; // tilemap_device - constructor //------------------------------------------------- -tilemap_device::tilemap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +tilemap_device::tilemap_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, TILEMAP, "Tilemap", tag, owner, clock, "tilemap", __FILE__), m_gfxdecode(*this, finder_base::DUMMY_TAG), m_standard_mapper(TILEMAP_STANDARD_COUNT), @@ -1658,7 +1658,7 @@ void tilemap_device::static_set_info_callback(device_t &device, tilemap_get_info // layout //------------------------------------------------- -void tilemap_device::static_set_layout(device_t &device, tilemap_standard_mapper mapper, uint32_t columns, uint32_t rows) +void tilemap_device::static_set_layout(device_t &device, tilemap_standard_mapper mapper, u32 columns, u32 rows) { tilemap_device &target = downcast(device); target.m_standard_mapper = mapper; @@ -1666,7 +1666,7 @@ void tilemap_device::static_set_layout(device_t &device, tilemap_standard_mapper target.m_num_rows = rows; } -void tilemap_device::static_set_layout(device_t &device, tilemap_mapper_delegate mapper, uint32_t columns, uint32_t rows) +void tilemap_device::static_set_layout(device_t &device, tilemap_mapper_delegate mapper, u32 columns, u32 rows) { tilemap_device &target = downcast(device); target.m_standard_mapper = TILEMAP_STANDARD_COUNT; @@ -1680,7 +1680,7 @@ void tilemap_device::static_set_layout(device_t &device, tilemap_mapper_delegate // static_set_tile_size: Set the tile size //------------------------------------------------- -void tilemap_device::static_set_tile_size(device_t &device, uint16_t width, uint16_t height) +void tilemap_device::static_set_tile_size(device_t &device, u16 width, u16 height) { tilemap_device &target = downcast(device); target.m_tile_width = width; diff --git a/src/emu/tilemap.h b/src/emu/tilemap.h index 99e4b7c83ee..057cdca8c86 100644 --- a/src/emu/tilemap.h +++ b/src/emu/tilemap.h @@ -163,17 +163,17 @@ behind or in front of sprites. tilemap_t *tmap; - uint16_t *my_tmap_memory; + u16 *my_tmap_memory; required_device gfxdecode; TILE_GET_INFO_MEMBER( my_state::my_get_info ) { - uint16_t tiledata = my_tmap_memory[tile_index]; - uint8_t code = tiledata & 0xff; - uint8_t color = (tiledata >> 8) & 0x1f; - uint8_t flipx = (tiledata >> 13) & 1; - uint8_t flipy = (tiledata >> 14) & 1; - uint8_t category = (tiledata >> 15) & 1; + u16 tiledata = my_tmap_memory[tile_index]; + u8 code = tiledata & 0xff; + u8 color = (tiledata >> 8) & 0x1f; + u8 flipx = (tiledata >> 13) & 1; + u8 flipy = (tiledata >> 14) & 1; + u8 category = (tiledata >> 15) & 1; // set the common info for the tile tileinfo.set( @@ -204,7 +204,7 @@ tmap.set_transparent_pen(0); } - uint32_t my_state::screen_update_mydriver( + u32 my_state::screen_update_mydriver( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) @@ -304,8 +304,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __TILEMAP_H__ -#define __TILEMAP_H__ +#ifndef MAME_EMU_TILEMAP_H +#define MAME_EMU_TILEMAP_H //************************************************************************** @@ -313,38 +313,38 @@ //************************************************************************** // maximum number of groups -#define TILEMAP_NUM_GROUPS 256 +constexpr size_t TILEMAP_NUM_GROUPS = 256; // these flags control tilemap_t::draw() behavior -const uint32_t TILEMAP_DRAW_CATEGORY_MASK = 0x0f; // specify the category to draw -const uint32_t TILEMAP_DRAW_LAYER0 = 0x10; // draw layer 0 -const uint32_t TILEMAP_DRAW_LAYER1 = 0x20; // draw layer 1 -const uint32_t TILEMAP_DRAW_LAYER2 = 0x40; // draw layer 2 -const uint32_t TILEMAP_DRAW_OPAQUE = 0x80; // draw everything, even transparent stuff -const uint32_t TILEMAP_DRAW_ALPHA_FLAG = 0x100; // draw with alpha blending (in the upper 8 bits) -const uint32_t TILEMAP_DRAW_ALL_CATEGORIES = 0x200; // draw all categories +constexpr u32 TILEMAP_DRAW_CATEGORY_MASK = 0x0f; // specify the category to draw +constexpr u32 TILEMAP_DRAW_LAYER0 = 0x10; // draw layer 0 +constexpr u32 TILEMAP_DRAW_LAYER1 = 0x20; // draw layer 1 +constexpr u32 TILEMAP_DRAW_LAYER2 = 0x40; // draw layer 2 +constexpr u32 TILEMAP_DRAW_OPAQUE = 0x80; // draw everything, even transparent stuff +constexpr u32 TILEMAP_DRAW_ALPHA_FLAG = 0x100; // draw with alpha blending (in the upper 8 bits) +constexpr u32 TILEMAP_DRAW_ALL_CATEGORIES = 0x200; // draw all categories // per-pixel flags in the transparency_bitmap -const uint8_t TILEMAP_PIXEL_CATEGORY_MASK = 0x0f; // category is stored in the low 4 bits -const uint8_t TILEMAP_PIXEL_TRANSPARENT = 0x00; // transparent if in none of the layers below -const uint8_t TILEMAP_PIXEL_LAYER0 = 0x10; // pixel is opaque in layer 0 -const uint8_t TILEMAP_PIXEL_LAYER1 = 0x20; // pixel is opaque in layer 1 -const uint8_t TILEMAP_PIXEL_LAYER2 = 0x40; // pixel is opaque in layer 2 +constexpr u8 TILEMAP_PIXEL_CATEGORY_MASK = 0x0f; // category is stored in the low 4 bits +constexpr u8 TILEMAP_PIXEL_TRANSPARENT = 0x00; // transparent if in none of the layers below +constexpr u8 TILEMAP_PIXEL_LAYER0 = 0x10; // pixel is opaque in layer 0 +constexpr u8 TILEMAP_PIXEL_LAYER1 = 0x20; // pixel is opaque in layer 1 +constexpr u8 TILEMAP_PIXEL_LAYER2 = 0x40; // pixel is opaque in layer 2 // per-tile flags, set by get_tile_info callback -const uint8_t TILE_FLIPX = 0x01; // draw this tile horizontally flipped -const uint8_t TILE_FLIPY = 0x02; // draw this tile vertically flipped -const uint8_t TILE_FORCE_LAYER0 = TILEMAP_PIXEL_LAYER0; // force all pixels to be layer 0 (no transparency) -const uint8_t TILE_FORCE_LAYER1 = TILEMAP_PIXEL_LAYER1; // force all pixels to be layer 1 (no transparency) -const uint8_t TILE_FORCE_LAYER2 = TILEMAP_PIXEL_LAYER2; // force all pixels to be layer 2 (no transparency) +constexpr u8 TILE_FLIPX = 0x01; // draw this tile horizontally flipped +constexpr u8 TILE_FLIPY = 0x02; // draw this tile vertically flipped +constexpr u8 TILE_FORCE_LAYER0 = TILEMAP_PIXEL_LAYER0; // force all pixels to be layer 0 (no transparency) +constexpr u8 TILE_FORCE_LAYER1 = TILEMAP_PIXEL_LAYER1; // force all pixels to be layer 1 (no transparency) +constexpr u8 TILE_FORCE_LAYER2 = TILEMAP_PIXEL_LAYER2; // force all pixels to be layer 2 (no transparency) // tilemap global flags, used by tilemap_t::set_flip() -const uint32_t TILEMAP_FLIPX = TILE_FLIPX; // draw the tilemap horizontally flipped -const uint32_t TILEMAP_FLIPY = TILE_FLIPY; // draw the tilemap vertically flipped +constexpr u32 TILEMAP_FLIPX = TILE_FLIPX; // draw the tilemap horizontally flipped +constexpr u32 TILEMAP_FLIPY = TILE_FLIPY; // draw the tilemap vertically flipped // set this value for a scroll row/column to fully disable it -const uint32_t TILE_LINE_DISABLED = 0x80000000; +constexpr u32 TILE_LINE_DISABLED = 0x80000000; // standard mappers enum tilemap_standard_mapper @@ -433,24 +433,24 @@ class tilemap_device; // global types -typedef uint32_t tilemap_memory_index; +typedef u32 tilemap_memory_index; // tile_data is filled in by the get_tile_info callback struct tile_data { device_gfx_interface *decoder; // set in tilemap_t::init() - const uint8_t * pen_data; // required - const uint8_t * mask_data; // required + const u8 * pen_data; // required + const u8 * mask_data; // required pen_t palette_base; // defaults to 0 - uint8_t category; // defaults to 0; range from 0..15 - uint8_t group; // defaults to 0; range from 0..TILEMAP_NUM_GROUPS - uint8_t flags; // defaults to 0; one or more of TILE_* flags above - uint8_t pen_mask; // defaults to 0xff; mask to apply to pen_data while rendering the tile - uint8_t gfxnum; // defaults to 0xff; specify index of gfx for auto-invalidation on dirty - uint32_t code; + u8 category; // defaults to 0; range from 0..15 + u8 group; // defaults to 0; range from 0..TILEMAP_NUM_GROUPS + u8 flags; // defaults to 0; one or more of TILE_* flags above + u8 pen_mask; // defaults to 0xff; mask to apply to pen_data while rendering the tile + u8 gfxnum; // defaults to 0xff; specify index of gfx for auto-invalidation on dirty + u32 code; - void set(uint8_t _gfxnum, uint32_t rawcode, uint32_t rawcolor, uint8_t _flags) + void set(u8 _gfxnum, u32 rawcode, u32 rawcolor, u8 _flags) { gfx_element *gfx = decoder->gfx(_gfxnum); code = rawcode % gfx->elements(); @@ -464,7 +464,7 @@ struct tile_data // modern delegates typedef device_delegate tilemap_get_info_delegate; -typedef device_delegate tilemap_mapper_delegate; +typedef device_delegate tilemap_mapper_delegate; // ======================> tilemap_t @@ -480,10 +480,10 @@ class tilemap_t friend resource_pool_object::~resource_pool_object(); // logical index - typedef uint32_t logical_index; + typedef u32 logical_index; // internal usage to mark tiles dirty - static const uint8_t TILE_FLAG_DIRTY = 0xff; + static const u8 TILE_FLAG_DIRTY = 0xff; // invalid logical index static const logical_index INVALID_LOGICAL_INDEX = (logical_index)~0; @@ -496,7 +496,7 @@ protected: tilemap_t(); virtual ~tilemap_t(); - tilemap_t &init(tilemap_manager &manager, device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, uint16_t tilewidth, uint16_t tileheight, uint32_t cols, uint32_t rows); + tilemap_t &init(tilemap_manager &manager, device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, u16 tilewidth, u16 tileheight, u32 cols, u32 rows); public: // getters @@ -509,75 +509,75 @@ public: void *user_data() const { return m_user_data; } memory_array &basemem() { return m_basemem; } memory_array &extmem() { return m_extmem; } - uint32_t rows() const { return m_rows; } - uint32_t cols() const { return m_cols; } - uint16_t tilewidth() const { return m_tilewidth; } - uint16_t tileheight() const { return m_tileheight; } - uint32_t width() const { return m_width; } - uint32_t height() const { return m_height; } + u32 rows() const { return m_rows; } + u32 cols() const { return m_cols; } + u16 tilewidth() const { return m_tilewidth; } + u16 tileheight() const { return m_tileheight; } + u32 width() const { return m_width; } + u32 height() const { return m_height; } bool enabled() const { return m_enable; } - uint32_t palette_offset() const { return m_palette_offset; } + u32 palette_offset() const { return m_palette_offset; } int scrolldx() const { return (m_attributes & TILEMAP_FLIPX) ? m_dx_flipped : m_dx; } int scrolldy() const { return (m_attributes & TILEMAP_FLIPY) ? m_dy_flipped : m_dy; } int scrollx(int which = 0) const { return (which < m_scrollrows) ? m_rowscroll[which] : 0; } int scrolly(int which = 0) const { return (which < m_scrollcols) ? m_colscroll[which] : 0; } bitmap_ind16 &pixmap() { pixmap_update(); return m_pixmap; } bitmap_ind8 &flagsmap() { pixmap_update(); return m_flagsmap; } - uint8_t *tile_flags() { pixmap_update(); return &m_tileflags[0]; } - tilemap_memory_index memory_index(uint32_t col, uint32_t row) { return m_mapper(col, row, m_cols, m_rows); } - void get_info_debug(uint32_t col, uint32_t row, uint8_t &gfxnum, uint32_t &code, uint32_t &color); + u8 *tile_flags() { pixmap_update(); return &m_tileflags[0]; } + tilemap_memory_index memory_index(u32 col, u32 row) { return m_mapper(col, row, m_cols, m_rows); } + void get_info_debug(u32 col, u32 row, u8 &gfxnum, u32 &code, u32 &color); // setters void enable(bool enable = true) { m_enable = enable; } void set_user_data(void *user_data) { m_user_data = user_data; } void set_palette(palette_device &palette) { m_palette = &palette; } - void set_palette_offset(uint32_t offset) { m_palette_offset = offset; } + void set_palette_offset(u32 offset) { m_palette_offset = offset; } void set_scrolldx(int dx, int dx_flipped) { m_dx = dx; m_dx_flipped = dx_flipped; } void set_scrolldy(int dy, int dy_flipped) { m_dy = dy; m_dy_flipped = dy_flipped; } void set_scrollx(int which, int value) { if (which < m_scrollrows) m_rowscroll[which] = value; } void set_scrolly(int which, int value) { if (which < m_scrollcols) m_colscroll[which] = value; } void set_scrollx(int value) { set_scrollx(0, value); } void set_scrolly(int value) { set_scrolly(0, value); } - void set_scroll_rows(uint32_t scroll_rows) { assert(scroll_rows <= m_height); m_scrollrows = scroll_rows; } - void set_scroll_cols(uint32_t scroll_cols) { assert(scroll_cols <= m_width); m_scrollcols = scroll_cols; } - void set_flip(uint32_t attributes) { if (m_attributes != attributes) { m_attributes = attributes; mappings_update(); } } + void set_scroll_rows(u32 scroll_rows) { assert(scroll_rows <= m_height); m_scrollrows = scroll_rows; } + void set_scroll_cols(u32 scroll_cols) { assert(scroll_cols <= m_width); m_scrollcols = scroll_cols; } + void set_flip(u32 attributes) { if (m_attributes != attributes) { m_attributes = attributes; mappings_update(); } } // dirtying void mark_tile_dirty(tilemap_memory_index memindex); void mark_all_dirty() { m_all_tiles_dirty = true; m_all_tiles_clean = false; } // pen mapping - void map_pens_to_layer(int group, pen_t pen, pen_t mask, uint8_t layermask); - void map_pen_to_layer(int group, pen_t pen, uint8_t layermask) { map_pens_to_layer(group, pen, ~0, layermask); } + void map_pens_to_layer(int group, pen_t pen, pen_t mask, u8 layermask); + void map_pen_to_layer(int group, pen_t pen, u8 layermask) { map_pens_to_layer(group, pen, ~0, layermask); } void set_transparent_pen(pen_t pen); - void set_transmask(int group, uint32_t fgmask, uint32_t bgmask); + void set_transmask(int group, u32 fgmask, u32 bgmask); void configure_groups(gfx_element &gfx, indirect_pen_t transcolor); // drawing - void draw(screen_device &screen, bitmap_ind16 &dest, const rectangle &cliprect, uint32_t flags, uint8_t priority = 0, uint8_t priority_mask = 0xff); - void draw(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t flags, uint8_t priority = 0, uint8_t priority_mask = 0xff); - void draw_roz(screen_device &screen, bitmap_ind16 &dest, const rectangle &cliprect, uint32_t startx, uint32_t starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, uint32_t flags, uint8_t priority = 0, uint8_t priority_mask = 0xff); - void draw_roz(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, uint32_t startx, uint32_t starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, uint32_t flags, uint8_t priority = 0, uint8_t priority_mask = 0xff); - void draw_debug(screen_device &screen, bitmap_rgb32 &dest, uint32_t scrollx, uint32_t scrolly); + void draw(screen_device &screen, bitmap_ind16 &dest, const rectangle &cliprect, u32 flags, u8 priority = 0, u8 priority_mask = 0xff); + void draw(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, u32 flags, u8 priority = 0, u8 priority_mask = 0xff); + void draw_roz(screen_device &screen, bitmap_ind16 &dest, const rectangle &cliprect, u32 startx, u32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, u32 flags, u8 priority = 0, u8 priority_mask = 0xff); + void draw_roz(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, u32 startx, u32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, u32 flags, u8 priority = 0, u8 priority_mask = 0xff); + void draw_debug(screen_device &screen, bitmap_rgb32 &dest, u32 scrollx, u32 scrolly); // mappers // scan in row-major order with optional flipping - tilemap_memory_index scan_rows(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows); - tilemap_memory_index scan_rows_flip_x(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows); - tilemap_memory_index scan_rows_flip_y(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows); - tilemap_memory_index scan_rows_flip_xy(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows); + tilemap_memory_index scan_rows(u32 col, u32 row, u32 num_cols, u32 num_rows); + tilemap_memory_index scan_rows_flip_x(u32 col, u32 row, u32 num_cols, u32 num_rows); + tilemap_memory_index scan_rows_flip_y(u32 col, u32 row, u32 num_cols, u32 num_rows); + tilemap_memory_index scan_rows_flip_xy(u32 col, u32 row, u32 num_cols, u32 num_rows); // scan in column-major order with optional flipping - tilemap_memory_index scan_cols(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows); - tilemap_memory_index scan_cols_flip_x(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows); - tilemap_memory_index scan_cols_flip_y(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows); - tilemap_memory_index scan_cols_flip_xy(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows); + tilemap_memory_index scan_cols(u32 col, u32 row, u32 num_cols, u32 num_rows); + tilemap_memory_index scan_cols_flip_x(u32 col, u32 row, u32 num_cols, u32 num_rows); + tilemap_memory_index scan_cols_flip_y(u32 col, u32 row, u32 num_cols, u32 num_rows); + tilemap_memory_index scan_cols_flip_xy(u32 col, u32 row, u32 num_cols, u32 num_rows); // optional memory accessors - uint32_t basemem_read(int index) { return m_basemem.read(index); } - uint32_t extmem_read(int index) { return m_extmem.read(index); } - void basemem_write(int index, uint32_t data) { m_basemem.write(index, data); mark_tile_dirty(index); } - void extmem_write(int index, uint32_t data) { m_extmem.write(index, data); mark_tile_dirty(index); } + u32 basemem_read(int index) { return m_basemem.read(index); } + u32 extmem_read(int index) { return m_extmem.read(index); } + void basemem_write(int index, u32 data) { m_basemem.write(index, data); mark_tile_dirty(index); } + void extmem_write(int index, u32 data) { m_extmem.write(index, data); mark_tile_dirty(index); } private: // internal set of transparency states for rendering @@ -593,26 +593,26 @@ private: { bitmap_ind8 * priority; rectangle cliprect; - uint32_t tilemap_priority_code; - uint8_t mask; - uint8_t value; - uint8_t alpha; + u32 tilemap_priority_code; + u8 mask; + u8 value; + u8 alpha; }; // inline helpers - int32_t effective_rowscroll(int index, uint32_t screen_width); - int32_t effective_colscroll(int index, uint32_t screen_height); + s32 effective_rowscroll(int index, u32 screen_width); + s32 effective_colscroll(int index, u32 screen_height); bool gfx_elements_changed(); // inline scanline rasterizers - void scanline_draw_opaque_null(int count, uint8_t *pri, uint32_t pcode); - void scanline_draw_masked_null(const uint8_t *maskptr, int mask, int value, int count, uint8_t *pri, uint32_t pcode); - void scanline_draw_opaque_ind16(uint16_t *dest, const uint16_t *source, int count, uint8_t *pri, uint32_t pcode); - void scanline_draw_masked_ind16(uint16_t *dest, const uint16_t *source, const uint8_t *maskptr, int mask, int value, int count, uint8_t *pri, uint32_t pcode); - void scanline_draw_opaque_rgb32(uint32_t *dest, const uint16_t *source, int count, const rgb_t *pens, uint8_t *pri, uint32_t pcode); - void scanline_draw_masked_rgb32(uint32_t *dest, const uint16_t *source, const uint8_t *maskptr, int mask, int value, int count, const rgb_t *pens, uint8_t *pri, uint32_t pcode); - void scanline_draw_opaque_rgb32_alpha(uint32_t *dest, const uint16_t *source, int count, const rgb_t *pens, uint8_t *pri, uint32_t pcode, uint8_t alpha); - void scanline_draw_masked_rgb32_alpha(uint32_t *dest, const uint16_t *source, const uint8_t *maskptr, int mask, int value, int count, const rgb_t *pens, uint8_t *pri, uint32_t pcode, uint8_t alpha); + void scanline_draw_opaque_null(int count, u8 *pri, u32 pcode); + void scanline_draw_masked_null(const u8 *maskptr, int mask, int value, int count, u8 *pri, u32 pcode); + void scanline_draw_opaque_ind16(u16 *dest, const u16 *source, int count, u8 *pri, u32 pcode); + void scanline_draw_masked_ind16(u16 *dest, const u16 *source, const u8 *maskptr, int mask, int value, int count, u8 *pri, u32 pcode); + void scanline_draw_opaque_rgb32(u32 *dest, const u16 *source, int count, const rgb_t *pens, u8 *pri, u32 pcode); + void scanline_draw_masked_rgb32(u32 *dest, const u16 *source, const u8 *maskptr, int mask, int value, int count, const rgb_t *pens, u8 *pri, u32 pcode); + void scanline_draw_opaque_rgb32_alpha(u32 *dest, const u16 *source, int count, const rgb_t *pens, u8 *pri, u32 pcode, u8 alpha); + void scanline_draw_masked_rgb32_alpha(u32 *dest, const u16 *source, const u8 *maskptr, int mask, int value, int count, const rgb_t *pens, u8 *pri, u32 pcode, u8 alpha); // internal helpers void postload(); @@ -622,14 +622,14 @@ private: // internal drawing void pixmap_update(); - void tile_update(logical_index logindex, uint32_t col, uint32_t row); - uint8_t tile_draw(const uint8_t *pendata, uint32_t x0, uint32_t y0, uint32_t palette_base, uint8_t category, uint8_t group, uint8_t flags, uint8_t pen_mask); - uint8_t tile_apply_bitmask(const uint8_t *maskdata, uint32_t x0, uint32_t y0, uint8_t category, uint8_t flags); - void configure_blit_parameters(blit_parameters &blit, bitmap_ind8 &priority_bitmap, const rectangle &cliprect, uint32_t flags, uint8_t priority, uint8_t priority_mask); - template void draw_common(screen_device &screen, _BitmapClass &dest, const rectangle &cliprect, uint32_t flags, uint8_t priority, uint8_t priority_mask); - template void draw_roz_common(screen_device &screen, _BitmapClass &dest, const rectangle &cliprect, uint32_t startx, uint32_t starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, uint32_t flags, uint8_t priority, uint8_t priority_mask); + void tile_update(logical_index logindex, u32 col, u32 row); + u8 tile_draw(const u8 *pendata, u32 x0, u32 y0, u32 palette_base, u8 category, u8 group, u8 flags, u8 pen_mask); + u8 tile_apply_bitmask(const u8 *maskdata, u32 x0, u32 y0, u8 category, u8 flags); + void configure_blit_parameters(blit_parameters &blit, bitmap_ind8 &priority_bitmap, const rectangle &cliprect, u32 flags, u8 priority, u8 priority_mask); + template void draw_common(screen_device &screen, _BitmapClass &dest, const rectangle &cliprect, u32 flags, u8 priority, u8 priority_mask); + template void draw_roz_common(screen_device &screen, _BitmapClass &dest, const rectangle &cliprect, u32 startx, u32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound, u32 flags, u8 priority, u8 priority_mask); template void draw_instance(screen_device &screen, _BitmapClass &dest, const blit_parameters &blit, int xpos, int ypos); - template void draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, const blit_parameters &blit, uint32_t startx, uint32_t starty, int incxx, int incxy, int incyx, int incyy, bool wraparound); + template void draw_roz_core(screen_device &screen, _BitmapClass &destbitmap, const blit_parameters &blit, u32 startx, u32 starty, int incxx, int incxy, int incyx, int incyy, bool wraparound); // managers and devices tilemap_manager * m_manager; // reference to the owning manager @@ -643,16 +643,16 @@ private: memory_array m_extmem; // info about extension memory // basic tilemap metrics - uint32_t m_rows; // number of tile rows - uint32_t m_cols; // number of tile columns - uint16_t m_tilewidth; // width of a single tile in pixels - uint16_t m_tileheight; // height of a single tile in pixels - uint32_t m_width; // width of the full tilemap in pixels - uint32_t m_height; // height of the full tilemap in pixels + u32 m_rows; // number of tile rows + u32 m_cols; // number of tile columns + u16 m_tilewidth; // width of a single tile in pixels + u16 m_tileheight; // height of a single tile in pixels + u32 m_width; // width of the full tilemap in pixels + u32 m_height; // height of the full tilemap in pixels // logical <-> memory mappings - tilemap_mapper_delegate m_mapper; // callback to map a row/column to a memory index - std::vector m_memory_to_logical; // map from memory index to logical index + tilemap_mapper_delegate m_mapper; // callback to map a row/column to a memory index + std::vector m_memory_to_logical; // map from memory index to logical index std::vector m_logical_to_memory; // map from logical index to memory index // callback to interpret video RAM for the tilemap @@ -661,30 +661,30 @@ private: // global tilemap states bool m_enable; // true if we are enabled - uint8_t m_attributes; // global attributes (flipx/y) + u8 m_attributes; // global attributes (flipx/y) bool m_all_tiles_dirty; // true if all tiles are dirty bool m_all_tiles_clean; // true if all tiles are clean - uint32_t m_palette_offset; // palette offset - uint32_t m_gfx_used; // bitmask of gfx items used - uint32_t m_gfx_dirtyseq[MAX_GFX_ELEMENTS]; // dirtyseq values from last check + u32 m_palette_offset; // palette offset + u32 m_gfx_used; // bitmask of gfx items used + u32 m_gfx_dirtyseq[MAX_GFX_ELEMENTS]; // dirtyseq values from last check // scroll information - uint32_t m_scrollrows; // number of independently scrolled rows - uint32_t m_scrollcols; // number of independently scrolled columns - std::vector m_rowscroll; // array of rowscroll values - std::vector m_colscroll; // array of colscroll values - int32_t m_dx; // global horizontal scroll offset - int32_t m_dx_flipped; // global horizontal scroll offset when flipped - int32_t m_dy; // global vertical scroll offset - int32_t m_dy_flipped; // global vertical scroll offset when flipped + u32 m_scrollrows; // number of independently scrolled rows + u32 m_scrollcols; // number of independently scrolled columns + std::vector m_rowscroll; // array of rowscroll values + std::vector m_colscroll; // array of colscroll values + s32 m_dx; // global horizontal scroll offset + s32 m_dx_flipped; // global horizontal scroll offset when flipped + s32 m_dy; // global vertical scroll offset + s32 m_dy_flipped; // global vertical scroll offset when flipped // pixel data bitmap_ind16 m_pixmap; // cached pixel data // transparency mapping bitmap_ind8 m_flagsmap; // per-pixel flags - std::vector m_tileflags; // per-tile flags - uint8_t m_pen_to_flags[MAX_PEN_TO_FLAGS * TILEMAP_NUM_GROUPS]; // mapping of pens to flags + std::vector m_tileflags; // per-tile flags + u8 m_pen_to_flags[MAX_PEN_TO_FLAGS * TILEMAP_NUM_GROUPS]; // mapping of pens to flags }; @@ -704,8 +704,8 @@ public: running_machine &machine() const { return m_machine; } // tilemap creation - tilemap_t &create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, uint16_t tilewidth, uint16_t tileheight, uint32_t cols, uint32_t rows, tilemap_t *allocated = nullptr); - tilemap_t &create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_standard_mapper mapper, uint16_t tilewidth, uint16_t tileheight, uint32_t cols, uint32_t rows, tilemap_t *allocated = nullptr); + tilemap_t &create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, u16 tilewidth, u16 tileheight, u32 cols, u32 rows, tilemap_t *allocated = nullptr); + tilemap_t &create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_standard_mapper mapper, u16 tilewidth, u16 tileheight, u32 cols, u32 rows, tilemap_t *allocated = nullptr); // tilemap list information tilemap_t *find(int index) { return m_tilemap_list.find(index); } @@ -713,7 +713,7 @@ public: // global operations on all tilemaps void mark_all_dirty(); - void set_flip_all(uint32_t attributes); + void set_flip_all(u32 attributes); private: // allocate an instance index @@ -736,15 +736,15 @@ class tilemap_device : public device_t, { public: // construction/destruction - tilemap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + tilemap_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); // static configuration static void static_set_gfxdecode_tag(device_t &device, const char *tag); static void static_set_bytes_per_entry(device_t &device, int bpe); static void static_set_info_callback(device_t &device, tilemap_get_info_delegate tile_get_info); - static void static_set_layout(device_t &device, tilemap_standard_mapper mapper, uint32_t columns, uint32_t rows); - static void static_set_layout(device_t &device, tilemap_mapper_delegate mapper, uint32_t columns, uint32_t rows); - static void static_set_tile_size(device_t &device, uint16_t width, uint16_t height); + static void static_set_layout(device_t &device, tilemap_standard_mapper mapper, u32 columns, u32 rows); + static void static_set_layout(device_t &device, tilemap_mapper_delegate mapper, u32 columns, u32 rows); + static void static_set_tile_size(device_t &device, u16 width, u16 height); static void static_set_transparent_pen(device_t &device, pen_t pen); // write handlers @@ -767,16 +767,16 @@ private: required_device m_gfxdecode; // configuration state - tilemap_get_info_delegate m_get_info; - tilemap_standard_mapper m_standard_mapper; - tilemap_mapper_delegate m_mapper; - int m_bytes_per_entry; - uint16_t m_tile_width; - uint16_t m_tile_height; - uint32_t m_num_columns; - uint32_t m_num_rows; - bool m_transparent_pen_set; - pen_t m_transparent_pen; + tilemap_get_info_delegate m_get_info; + tilemap_standard_mapper m_standard_mapper; + tilemap_mapper_delegate m_mapper; + int m_bytes_per_entry; + u16 m_tile_width; + u16 m_tile_height; + u32 m_num_columns; + u32 m_num_rows; + bool m_transparent_pen_set; + pen_t m_transparent_pen; }; @@ -793,7 +793,7 @@ private: #define TILE_GET_INFO_MEMBER(_name) void _name(tilemap_t &tilemap, tile_data &tileinfo, tilemap_memory_index tile_index) // function definition for a logical-to-memory mapper -#define TILEMAP_MAPPER_MEMBER(_name) tilemap_memory_index _name(uint32_t col, uint32_t row, uint32_t num_cols, uint32_t num_rows) +#define TILEMAP_MAPPER_MEMBER(_name) tilemap_memory_index _name(u32 col, u32 row, u32 num_cols, u32 num_rows) // useful macro inside of a TILE_GET_INFO callback to set tile information #define SET_TILE_INFO_MEMBER(GFX,CODE,COLOR,FLAGS) tileinfo.set(GFX, CODE, COLOR, FLAGS) @@ -816,4 +816,4 @@ inline running_machine &tilemap_t::machine() const } -#endif // __TILEMAP_H__ +#endif // MAME_EMU_TILEMAP_H diff --git a/src/emu/timer.cpp b/src/emu/timer.cpp index 29583c25e0a..2e9eb0edfaa 100644 --- a/src/emu/timer.cpp +++ b/src/emu/timer.cpp @@ -32,7 +32,7 @@ const device_type TIMER = &device_creator; // timer_device - constructor //------------------------------------------------- -timer_device::timer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +timer_device::timer_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, TIMER, "Timer", tag, owner, clock, "timer", __FILE__), m_type(TIMER_TYPE_GENERIC), m_callback(timer_device_expired_delegate()), diff --git a/src/emu/timer.h b/src/emu/timer.h index c117c48084c..184131ca89c 100644 --- a/src/emu/timer.h +++ b/src/emu/timer.h @@ -14,8 +14,8 @@ #error Dont include this file directly; include emu.h instead. #endif -#ifndef __TIMER_H__ -#define __TIMER_H__ +#ifndef MAME_EMU_TIMER_H +#define MAME_EMU_TIMER_H @@ -24,7 +24,7 @@ //************************************************************************** // macros for a timer callback functions -#define TIMER_DEVICE_CALLBACK_MEMBER(name) void name(timer_device &timer, void *ptr, int32_t param) +#define TIMER_DEVICE_CALLBACK_MEMBER(name) void name(timer_device &timer, void *ptr, s32 param) //************************************************************************** // TIMER DEVICE CONFIGURATION MACROS @@ -73,7 +73,7 @@ class emu_timer; class timer_device; // a timer callbacks look like this -typedef device_delegate timer_device_expired_delegate; +typedef device_delegate timer_device_expired_delegate; // ======================> timer_device @@ -81,7 +81,7 @@ class timer_device : public device_t { public: // construction/destruction - timer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + timer_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); // inline configuration helpers static void static_configure_generic(device_t &device, timer_device_expired_delegate callback); @@ -104,7 +104,7 @@ public: // adjustments void reset() { adjust(attotime::never, 0, attotime::never); } - void adjust(const attotime &duration, int32_t param = 0, const attotime &period = attotime::never) const { assert(m_type == TIMER_TYPE_GENERIC); m_timer->adjust(duration, param, period); } + void adjust(const attotime &duration, s32 param = 0, const attotime &period = attotime::never) const { assert(m_type == TIMER_TYPE_GENERIC); m_timer->adjust(duration, param, period); } // timing information attotime time_elapsed() const { return m_timer->elapsed(); } @@ -135,13 +135,13 @@ private: // periodic timers only attotime m_start_delay; // delay before the timer fires for the first time attotime m_period; // period of repeated timer firings - int32_t m_param; // the integer parameter passed to the timer callback + s32 m_param; // the integer parameter passed to the timer callback // scanline timers only const char * m_screen_tag; // the tag of the screen this timer tracks screen_device * m_screen; // pointer to the screen device - uint32_t m_first_vpos; // the first vertical scanline position the timer fires on - uint32_t m_increment; // the number of scanlines between firings + u32 m_first_vpos; // the first vertical scanline position the timer fires on + u32 m_increment; // the number of scanlines between firings // internal state emu_timer * m_timer; // the backing timer @@ -157,4 +157,4 @@ private: extern const device_type TIMER; -#endif /* __TIMER_H__ */ +#endif /* MAME_EMU_TIMER_H */ diff --git a/src/emu/ui/cmdrender.h b/src/emu/ui/cmdrender.h index de9ca58747e..905b681f746 100644 --- a/src/emu/ui/cmdrender.h +++ b/src/emu/ui/cmdrender.h @@ -90,22 +90,22 @@ void render_font::render_font_command_glyph() load_cached_cmd(ramfile, 0); } -bool render_font::load_cached_cmd(emu_file &file, uint32_t hash) +bool render_font::load_cached_cmd(emu_file &file, u32 hash) { - uint64_t filesize = file.size(); - uint8_t header[CACHED_HEADER_SIZE]; - uint32_t bytes_read = file.read(header, CACHED_HEADER_SIZE); + u64 filesize = file.size(); + u8 header[CACHED_HEADER_SIZE]; + u32 bytes_read = file.read(header, CACHED_HEADER_SIZE); if (bytes_read != CACHED_HEADER_SIZE) return false; if (header[0] != 'f' || header[1] != 'o' || header[2] != 'n' || header[3] != 't') return false; - if (header[4] != (uint8_t)(hash >> 24) || header[5] != (uint8_t)(hash >> 16) || header[6] != (uint8_t)(hash >> 8) || header[7] != (uint8_t)hash) + if (header[4] != u8(hash >> 24) || header[5] != u8(hash >> 16) || header[6] != u8(hash >> 8) || header[7] != u8(hash)) return false; m_height_cmd = (header[8] << 8) | header[9]; - m_yoffs_cmd = (int16_t)((header[10] << 8) | header[11]); - uint32_t numchars = (header[12] << 24) | (header[13] << 16) | (header[14] << 8) | header[15]; + m_yoffs_cmd = s16((header[10] << 8) | header[11]); + u32 numchars = (header[12] << 24) | (header[13] << 16) | (header[14] << 8) | header[15]; if (filesize - CACHED_HEADER_SIZE < numchars * CACHED_CHAR_SIZE) return false; @@ -117,10 +117,10 @@ bool render_font::load_cached_cmd(emu_file &file, uint32_t hash) return false; } - uint64_t offset = numchars * CACHED_CHAR_SIZE; + u64 offset = numchars * CACHED_CHAR_SIZE; for (int chindex = 0; chindex < numchars; chindex++) { - const uint8_t *info = reinterpret_cast(&m_rawdata_cmd[chindex * CACHED_CHAR_SIZE]); + const u8 *info = reinterpret_cast(&m_rawdata_cmd[chindex * CACHED_CHAR_SIZE]); int chnum = (info[0] << 8) | info[1]; if (!m_glyphs_cmd[chnum / 256]) @@ -132,8 +132,8 @@ bool render_font::load_cached_cmd(emu_file &file, uint32_t hash) gl.color = color_table[chnum - COMMAND_UNICODE]; gl.width = (info[2] << 8) | info[3]; - gl.xoffs = (int16_t)((info[4] << 8) | info[5]); - gl.yoffs = (int16_t)((info[6] << 8) | info[7]); + gl.xoffs = s16((info[4] << 8) | info[5]); + gl.yoffs = s16((info[6] << 8) | info[7]); gl.bmwidth = (info[8] << 8) | info[9]; gl.bmheight = (info[10] << 8) | info[11]; gl.rawdata = &m_rawdata_cmd[offset]; diff --git a/src/emu/uiinput.cpp b/src/emu/uiinput.cpp index de4435298b6..952a5b371b3 100644 --- a/src/emu/uiinput.cpp +++ b/src/emu/uiinput.cpp @@ -183,7 +183,7 @@ void ui_input_manager::reset() location of the mouse -------------------------------------------------*/ -render_target *ui_input_manager::find_mouse(int32_t *x, int32_t *y, bool *button) const +render_target *ui_input_manager::find_mouse(s32 *x, s32 *y, bool *button) const { if (x != nullptr) *x = m_current_mouse_x; @@ -284,7 +284,7 @@ g_profiler.stop(); move event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_move_event(render_target* target, int32_t x, int32_t y) +void ui_input_manager::push_mouse_move_event(render_target* target, s32 x, s32 y) { ui_event event = { UI_EVENT_NONE }; event.event_type = UI_EVENT_MOUSE_MOVE; @@ -312,7 +312,7 @@ void ui_input_manager::push_mouse_leave_event(render_target* target) down event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_down_event(render_target* target, int32_t x, int32_t y) +void ui_input_manager::push_mouse_down_event(render_target* target, s32 x, s32 y) { ui_event event = { UI_EVENT_NONE }; event.event_type = UI_EVENT_MOUSE_DOWN; @@ -327,7 +327,7 @@ void ui_input_manager::push_mouse_down_event(render_target* target, int32_t x, i down event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_up_event(render_target* target, int32_t x, int32_t y) +void ui_input_manager::push_mouse_up_event(render_target* target, s32 x, s32 y) { ui_event event = { UI_EVENT_NONE }; event.event_type = UI_EVENT_MOUSE_UP; @@ -342,7 +342,7 @@ push_mouse_down_event - pushes a mouse down event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_rdown_event(render_target* target, int32_t x, int32_t y) +void ui_input_manager::push_mouse_rdown_event(render_target* target, s32 x, s32 y) { ui_event event = { UI_EVENT_NONE }; event.event_type = UI_EVENT_MOUSE_RDOWN; @@ -357,7 +357,7 @@ push_mouse_down_event - pushes a mouse down event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_rup_event(render_target* target, int32_t x, int32_t y) +void ui_input_manager::push_mouse_rup_event(render_target* target, s32 x, s32 y) { ui_event event = { UI_EVENT_NONE }; event.event_type = UI_EVENT_MOUSE_RUP; @@ -372,7 +372,7 @@ void ui_input_manager::push_mouse_rup_event(render_target* target, int32_t x, in a mouse double-click event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_double_click_event(render_target* target, int32_t x, int32_t y) +void ui_input_manager::push_mouse_double_click_event(render_target* target, s32 x, s32 y) { ui_event event = { UI_EVENT_NONE }; event.event_type = UI_EVENT_MOUSE_DOUBLE_CLICK; @@ -400,7 +400,7 @@ void ui_input_manager::push_char_event(render_target* target, char32_t ch) wheel event to the specified render_target -------------------------------------------------*/ -void ui_input_manager::push_mouse_wheel_event(render_target *target, int32_t x, int32_t y, short delta, int ucNumLines) +void ui_input_manager::push_mouse_wheel_event(render_target *target, s32 x, s32 y, short delta, int ucNumLines) { ui_event event = { UI_EVENT_NONE }; event.event_type = UI_EVENT_MOUSE_WHEEL; diff --git a/src/emu/uiinput.h b/src/emu/uiinput.h index 861ca07c632..66cdd1f80b5 100644 --- a/src/emu/uiinput.h +++ b/src/emu/uiinput.h @@ -7,10 +7,10 @@ Internal MAME user interface input state. ***************************************************************************/ -#pragma once +#ifndef MAME_EMU_UIINPUT_H +#define MAME_EMU_UIINPUT_H -#ifndef __UIINPUT_H__ -#define __UIINPUT_H__ +#pragma once /*************************************************************************** @@ -43,10 +43,10 @@ struct ui_event { ui_event_type event_type; render_target * target; - int32_t mouse_x; - int32_t mouse_y; + s32 mouse_x; + s32 mouse_y; input_item_id key; - char32_t ch; + char32_t ch; short zdelta; int num_lines; }; @@ -71,7 +71,7 @@ public: void reset(); /* retrieves the current location of the mouse */ - render_target *find_mouse(int32_t *x, int32_t *y, bool *button) const; + render_target *find_mouse(s32 *x, s32 *y, bool *button) const; ioport_field *find_mouse_field() const; /* return true if a key down for the given user interface sequence is detected */ @@ -85,15 +85,15 @@ public: running_machine &machine() const { return m_machine; } - void push_mouse_move_event(render_target* target, int32_t x, int32_t y); + void push_mouse_move_event(render_target* target, s32 x, s32 y); void push_mouse_leave_event(render_target* target); - void push_mouse_down_event(render_target* target, int32_t x, int32_t y); - void push_mouse_up_event(render_target* target, int32_t x, int32_t y); - void push_mouse_rdown_event(render_target* target, int32_t x, int32_t y); - void push_mouse_rup_event(render_target* target, int32_t x, int32_t y); - void push_mouse_double_click_event(render_target* target, int32_t x, int32_t y); + void push_mouse_down_event(render_target* target, s32 x, s32 y); + void push_mouse_up_event(render_target* target, s32 x, s32 y); + void push_mouse_rdown_event(render_target* target, s32 x, s32 y); + void push_mouse_rup_event(render_target* target, s32 x, s32 y); + void push_mouse_double_click_event(render_target* target, s32 x, s32 y); void push_char_event(render_target* target, char32_t ch); - void push_mouse_wheel_event(render_target *target, int32_t x, int32_t y, short delta, int ucNumLines); + void push_mouse_wheel_event(render_target *target, s32 x, s32 y, short delta, int ucNumLines); void mark_all_as_pressed(); @@ -104,12 +104,12 @@ private: /* pressed states; retrieved with ui_input_pressed() */ osd_ticks_t m_next_repeat[IPT_COUNT]; - uint8_t m_seqpressed[IPT_COUNT]; + u8 m_seqpressed[IPT_COUNT]; /* mouse position/info */ render_target * m_current_mouse_target; - int32_t m_current_mouse_x; - int32_t m_current_mouse_y; + s32 m_current_mouse_x; + s32 m_current_mouse_y; bool m_current_mouse_down; ioport_field * m_current_mouse_field; @@ -119,4 +119,4 @@ private: int m_events_end; }; -#endif /* __UIINPUT_H__ */ +#endif /* MAME_EMU_UIINPUT_H */ diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp index 740a9c6c6dd..c8201da63a1 100644 --- a/src/emu/validity.cpp +++ b/src/emu/validity.cpp @@ -30,7 +30,7 @@ // string from the I/O port system //------------------------------------------------- -inline const char *validity_checker::ioport_string_from_index(uint32_t index) +inline const char *validity_checker::ioport_string_from_index(u32 index) { return ioport_configurer::string_from_token((const char *)(uintptr_t)index); } @@ -59,10 +59,10 @@ inline int validity_checker::get_defstr_index(const char *string, bool suppress_ // random_s32 //------------------------------------------------- #undef rand -inline int32_t validity_checker::random_i32() { return int32_t(random_u32()); } -inline uint32_t validity_checker::random_u32() { return rand() ^ (rand() << 15); } -inline int64_t validity_checker::random_i64() { return int64_t(random_u64()); } -inline uint64_t validity_checker::random_u64() { return uint64_t(random_u32()) ^ (uint64_t(random_u32()) << 30); } +inline s32 validity_checker::random_i32() { return s32(random_u32()); } +inline u32 validity_checker::random_u32() { return rand() ^ (rand() << 15); } +inline s64 validity_checker::random_i64() { return s64(random_u64()); } +inline u64 validity_checker::random_u64() { return u64(random_u32()) ^ (u64(random_u32()) << 30); } @@ -82,7 +82,7 @@ void validity_checker::validate_tag(const char *tag) for (const char *p = tag; *p != 0; p++) { // only lower-case permitted - if (*p != tolower((uint8_t)*p)) + if (*p != tolower(u8(*p))) { osd_printf_error("Tag '%s' contains upper-case characters\n", tag); break; @@ -336,29 +336,29 @@ void validity_checker::validate_core() // basic system checks if (~0 != -1) osd_printf_error("Machine must be two's complement\n"); - uint8_t a = 0xff; - uint8_t b = a + 1; - if (b > a) osd_printf_error("uint8_t must be 8 bits\n"); + u8 a = 0xff; + u8 b = a + 1; + if (b > a) osd_printf_error("u8 must be 8 bits\n"); // check size of core integer types - if (sizeof(int8_t) != 1) osd_printf_error("int8_t must be 8 bits\n"); - if (sizeof(uint8_t) != 1) osd_printf_error("uint8_t must be 8 bits\n"); - if (sizeof(int16_t) != 2) osd_printf_error("int16_t must be 16 bits\n"); - if (sizeof(uint16_t) != 2) osd_printf_error("uint16_t must be 16 bits\n"); - if (sizeof(int32_t) != 4) osd_printf_error("int32_t must be 32 bits\n"); - if (sizeof(uint32_t) != 4) osd_printf_error("uint32_t must be 32 bits\n"); - if (sizeof(int64_t) != 8) osd_printf_error("int64_t must be 64 bits\n"); - if (sizeof(uint64_t) != 8) osd_printf_error("uint64_t must be 64 bits\n"); + if (sizeof(s8) != 1) osd_printf_error("s8 must be 8 bits\n"); + if (sizeof(u8) != 1) osd_printf_error("u8 must be 8 bits\n"); + if (sizeof(s16) != 2) osd_printf_error("s16 must be 16 bits\n"); + if (sizeof(u16) != 2) osd_printf_error("u16 must be 16 bits\n"); + if (sizeof(s32) != 4) osd_printf_error("s32 must be 32 bits\n"); + if (sizeof(u32) != 4) osd_printf_error("u32 must be 32 bits\n"); + if (sizeof(s64) != 8) osd_printf_error("s64 must be 64 bits\n"); + if (sizeof(u64) != 8) osd_printf_error("u64 must be 64 bits\n"); // check signed right shift - int8_t a8 = -3; - int16_t a16 = -3; - int32_t a32 = -3; - int64_t a64 = -3; - if (a8 >> 1 != -2) osd_printf_error("int8_t right shift must be arithmetic\n"); - if (a16 >> 1 != -2) osd_printf_error("int16_t right shift must be arithmetic\n"); - if (a32 >> 1 != -2) osd_printf_error("int32_t right shift must be arithmetic\n"); - if (a64 >> 1 != -2) osd_printf_error("int64_t right shift must be arithmetic\n"); + s8 a8 = -3; + s16 a16 = -3; + s32 a32 = -3; + s64 a64 = -3; + if (a8 >> 1 != -2) osd_printf_error("s8 right shift must be arithmetic\n"); + if (a16 >> 1 != -2) osd_printf_error("s16 right shift must be arithmetic\n"); + if (a32 >> 1 != -2) osd_printf_error("s32 right shift must be arithmetic\n"); + if (a64 >> 1 != -2) osd_printf_error("s64 right shift must be arithmetic\n"); // check pointer size #ifdef PTR64 @@ -369,8 +369,8 @@ void validity_checker::validate_core() // TODO: check if this is actually working // check endianness definition - uint16_t lsbtest = 0; - *(uint8_t *)&lsbtest = 0xff; + u16 lsbtest = 0; + *(u8 *)&lsbtest = 0xff; #ifdef LSB_FIRST if (lsbtest == 0xff00) osd_printf_error("LSB_FIRST specified, but running on a big-endian machine\n"); #else @@ -386,18 +386,18 @@ void validity_checker::validate_core() void validity_checker::validate_inlines() { - volatile uint64_t testu64a = random_u64(); - volatile int64_t testi64a = random_i64(); - volatile uint32_t testu32a = random_u32(); - volatile uint32_t testu32b = random_u32(); - volatile int32_t testi32a = random_i32(); - volatile int32_t testi32b = random_i32(); - int32_t resulti32, expectedi32; - uint32_t resultu32, expectedu32; - int64_t resulti64, expectedi64; - uint64_t resultu64, expectedu64; - int32_t remainder, expremainder; - uint32_t uremainder, expuremainder, bigu32 = 0xffffffff; + volatile u64 testu64a = random_u64(); + volatile s64 testi64a = random_i64(); + volatile u32 testu32a = random_u32(); + volatile u32 testu32b = random_u32(); + volatile s32 testi32a = random_i32(); + volatile s32 testi32b = random_i32(); + s32 resulti32, expectedi32; + u32 resultu32, expectedu32; + s64 resulti64, expectedi64; + u64 resultu64, expectedu64; + s32 remainder, expremainder; + u32 uremainder, expuremainder, bigu32 = 0xffffffff; // use only non-zero, positive numbers if (testu64a == 0) testu64a++; @@ -411,86 +411,86 @@ void validity_checker::validate_inlines() else if (testi32b < 0) testi32b = -testi32b; resulti64 = mul_32x32(testi32a, testi32b); - expectedi64 = (int64_t)testi32a * (int64_t)testi32b; + expectedi64 = s64(testi32a) * s64(testi32b); if (resulti64 != expectedi64) - osd_printf_error("Error testing mul_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testi32a, testi32b, (uint32_t)(resulti64 >> 32), (uint32_t)resulti64, (uint32_t)(expectedi64 >> 32), (uint32_t)expectedi64); + osd_printf_error("Error testing mul_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testi32a, testi32b, u32(resulti64 >> 32), u32(resulti64), u32(expectedi64 >> 32), u32(expectedi64)); resultu64 = mulu_32x32(testu32a, testu32b); - expectedu64 = (uint64_t)testu32a * (uint64_t)testu32b; + expectedu64 = u64(testu32a) * u64(testu32b); if (resultu64 != expectedu64) - osd_printf_error("Error testing mulu_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testu32a, testu32b, (uint32_t)(resultu64 >> 32), (uint32_t)resultu64, (uint32_t)(expectedu64 >> 32), (uint32_t)expectedu64); + osd_printf_error("Error testing mulu_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testu32a, testu32b, u32(resultu64 >> 32), u32(resultu64), u32(expectedu64 >> 32), u32(expectedu64)); resulti32 = mul_32x32_hi(testi32a, testi32b); - expectedi32 = ((int64_t)testi32a * (int64_t)testi32b) >> 32; + expectedi32 = (s64(testi32a) * s64(testi32b)) >> 32; if (resulti32 != expectedi32) osd_printf_error("Error testing mul_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); resultu32 = mulu_32x32_hi(testu32a, testu32b); - expectedu32 = ((int64_t)testu32a * (int64_t)testu32b) >> 32; + expectedu32 = (s64(testu32a) * s64(testu32b)) >> 32; if (resultu32 != expectedu32) osd_printf_error("Error testing mulu_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); resulti32 = mul_32x32_shift(testi32a, testi32b, 7); - expectedi32 = ((int64_t)testi32a * (int64_t)testi32b) >> 7; + expectedi32 = (s64(testi32a) * s64(testi32b)) >> 7; if (resulti32 != expectedi32) osd_printf_error("Error testing mul_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); resultu32 = mulu_32x32_shift(testu32a, testu32b, 7); - expectedu32 = ((int64_t)testu32a * (int64_t)testu32b) >> 7; + expectedu32 = (s64(testu32a) * s64(testu32b)) >> 7; if (resultu32 != expectedu32) osd_printf_error("Error testing mulu_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); - while ((int64_t)testi32a * (int64_t)0x7fffffff < testi64a) + while (s64(testi32a) * s64(0x7fffffff) < testi64a) testi64a /= 2; - while ((uint64_t)testu32a * (uint64_t)bigu32 < testu64a) + while (u64(testu32a) * u64(bigu32) < testu64a) testu64a /= 2; resulti32 = div_64x32(testi64a, testi32a); - expectedi32 = testi64a / (int64_t)testi32a; + expectedi32 = testi64a / s64(testi32a); if (resulti32 != expectedi32) - osd_printf_error("Error testing div_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (uint32_t)(testi64a >> 32), (uint32_t)testi64a, testi32a, resulti32, expectedi32); + osd_printf_error("Error testing div_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", u32(testi64a >> 32), u32(testi64a), testi32a, resulti32, expectedi32); resultu32 = divu_64x32(testu64a, testu32a); - expectedu32 = testu64a / (uint64_t)testu32a; + expectedu32 = testu64a / u64(testu32a); if (resultu32 != expectedu32) - osd_printf_error("Error testing divu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (uint32_t)(testu64a >> 32), (uint32_t)testu64a, testu32a, resultu32, expectedu32); + osd_printf_error("Error testing divu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", u32(testu64a >> 32), u32(testu64a), testu32a, resultu32, expectedu32); resulti32 = div_64x32_rem(testi64a, testi32a, &remainder); - expectedi32 = testi64a / (int64_t)testi32a; - expremainder = testi64a % (int64_t)testi32a; + expectedi32 = testi64a / s64(testi32a); + expremainder = testi64a % s64(testi32a); if (resulti32 != expectedi32 || remainder != expremainder) - osd_printf_error("Error testing div_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (uint32_t)(testi64a >> 32), (uint32_t)testi64a, testi32a, resulti32, remainder, expectedi32, expremainder); + osd_printf_error("Error testing div_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", u32(testi64a >> 32), u32(testi64a), testi32a, resulti32, remainder, expectedi32, expremainder); resultu32 = divu_64x32_rem(testu64a, testu32a, &uremainder); - expectedu32 = testu64a / (uint64_t)testu32a; - expuremainder = testu64a % (uint64_t)testu32a; + expectedu32 = testu64a / u64(testu32a); + expuremainder = testu64a % u64(testu32a); if (resultu32 != expectedu32 || uremainder != expuremainder) - osd_printf_error("Error testing divu_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (uint32_t)(testu64a >> 32), (uint32_t)testu64a, testu32a, resultu32, uremainder, expectedu32, expuremainder); + osd_printf_error("Error testing divu_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", u32(testu64a >> 32), u32(testu64a), testu32a, resultu32, uremainder, expectedu32, expuremainder); resulti32 = mod_64x32(testi64a, testi32a); - expectedi32 = testi64a % (int64_t)testi32a; + expectedi32 = testi64a % s64(testi32a); if (resulti32 != expectedi32) - osd_printf_error("Error testing mod_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (uint32_t)(testi64a >> 32), (uint32_t)testi64a, testi32a, resulti32, expectedi32); + osd_printf_error("Error testing mod_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", u32(testi64a >> 32), u32(testi64a), testi32a, resulti32, expectedi32); resultu32 = modu_64x32(testu64a, testu32a); - expectedu32 = testu64a % (uint64_t)testu32a; + expectedu32 = testu64a % u64(testu32a); if (resultu32 != expectedu32) - osd_printf_error("Error testing modu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (uint32_t)(testu64a >> 32), (uint32_t)testu64a, testu32a, resultu32, expectedu32); + osd_printf_error("Error testing modu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", u32(testu64a >> 32), u32(testu64a), testu32a, resultu32, expectedu32); - while ((int64_t)testi32a * (int64_t)0x7fffffff < ((int32_t)testi64a << 3)) + while (s64(testi32a) * s64(0x7fffffff) < (s32(testi64a) << 3)) testi64a /= 2; - while ((uint64_t)testu32a * (uint64_t)0xffffffff < ((uint32_t)testu64a << 3)) + while (u64(testu32a) * u64(0xffffffff) < (u32(testu64a) << 3)) testu64a /= 2; - resulti32 = div_32x32_shift((int32_t)testi64a, testi32a, 3); - expectedi32 = ((int64_t)(int32_t)testi64a << 3) / (int64_t)testi32a; + resulti32 = div_32x32_shift(s32(testi64a), testi32a, 3); + expectedi32 = (s64(s32(testi64a)) << 3) / s64(testi32a); if (resulti32 != expectedi32) - osd_printf_error("Error testing div_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (int32_t)testi64a, testi32a, resulti32, expectedi32); + osd_printf_error("Error testing div_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", s32(testi64a), testi32a, resulti32, expectedi32); - resultu32 = divu_32x32_shift((uint32_t)testu64a, testu32a, 3); - expectedu32 = ((uint64_t)(uint32_t)testu64a << 3) / (uint64_t)testu32a; + resultu32 = divu_32x32_shift(u32(testu64a), testu32a, 3); + expectedu32 = (u64(u32(testu64a)) << 3) / u64(testu32a); if (resultu32 != expectedu32) - osd_printf_error("Error testing divu_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (uint32_t)testu64a, testu32a, resultu32, expectedu32); + osd_printf_error("Error testing divu_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", u32(testu64a), testu32a, resultu32, expectedu32); if (fabsf(recip_approx(100.0f) - 0.01f) > 0.0001f) osd_printf_error("Error testing recip_approx\n"); @@ -527,38 +527,38 @@ void validity_checker::validate_rgb() The following functions are not tested yet: rgbaint_t() - clamp_and_clear(const uint32_t) - sign_extend(const uint32_t, const uint32_t) - min(const int32_t) - max(const int32_t) - blend(const rgbaint_t&, uint8_t) + clamp_and_clear(const u32) + sign_extend(const u32, const u32) + min(const s32) + max(const s32) + blend(const rgbaint_t&, u8) scale_and_clamp(const rgbaint_t&) - scale_imm_and_clamp(const int32_t) + scale_imm_and_clamp(const s32) scale2_add_and_clamp(const rgbaint_t&, const rgbaint_t&, const rgbaint_t&) scale_add_and_clamp(const rgbaint_t&, const rgbaint_t&); - scale_imm_add_and_clamp(const int32_t, const rgbaint_t&); - static bilinear_filter(uint32_t, uint32_t, uint32_t, uint32_t, uint8_t, uint8_t) - bilinear_filter_rgbaint(uint32_t, uint32_t, uint32_t, uint32_t, uint8_t, uint8_t) + scale_imm_add_and_clamp(const s32, const rgbaint_t&); + static bilinear_filter(u32, u32, u32, u32, u8, u8) + bilinear_filter_rgbaint(u32, u32, u32, u32, u8, u8) */ auto random_i32_nolimit = [this] { - int32_t result; - do { result = random_i32(); } while ((result == std::numeric_limits::min()) || (result == std::numeric_limits::max())); + s32 result; + do { result = random_i32(); } while ((result == std::numeric_limits::min()) || (result == std::numeric_limits::max())); return result; }; - volatile int32_t expected_a, expected_r, expected_g, expected_b; - volatile int32_t actual_a, actual_r, actual_g, actual_b; - volatile int32_t imm; + volatile s32 expected_a, expected_r, expected_g, expected_b; + volatile s32 actual_a, actual_r, actual_g, actual_b; + volatile s32 imm; rgbaint_t rgb, other; rgb_t packed; auto check_expected = [&] (const char *desc) { - const volatile int32_t a = rgb.get_a32(); - const volatile int32_t r = rgb.get_r32(); - const volatile int32_t g = rgb.get_g32(); - const volatile int32_t b = rgb.get_b32(); + const volatile s32 a = rgb.get_a32(); + const volatile s32 r = rgb.get_r32(); + const volatile s32 g = rgb.get_g32(); + const volatile s32 b = rgb.get_b32(); if (a != expected_a) osd_printf_error("Error testing %s get_a32() = %d (expected %d)\n", desc, a, expected_a); if (r != expected_r) osd_printf_error("Error testing %s get_r32() = %d (expected %d)\n", desc, r, expected_r); if (g != expected_g) osd_printf_error("Error testing %s get_g32() = %d (expected %d)\n", desc, g, expected_g); @@ -830,14 +830,14 @@ void validity_checker::validate_rgb() check_expected("rgbaint_t::xor_imm_rgba"); // test 8-bit get - expected_a = int32_t(uint32_t(expected_a) & 0x00ff); - expected_r = int32_t(uint32_t(expected_r) & 0x00ff); - expected_g = int32_t(uint32_t(expected_g) & 0x00ff); - expected_b = int32_t(uint32_t(expected_b) & 0x00ff); - actual_a = int32_t(uint32_t(rgb.get_a())); - actual_r = int32_t(uint32_t(rgb.get_r())); - actual_g = int32_t(uint32_t(rgb.get_g())); - actual_b = int32_t(uint32_t(rgb.get_b())); + expected_a = s32(u32(expected_a) & 0x00ff); + expected_r = s32(u32(expected_r) & 0x00ff); + expected_g = s32(u32(expected_g) & 0x00ff); + expected_b = s32(u32(expected_b) & 0x00ff); + actual_a = s32(u32(rgb.get_a())); + actual_r = s32(u32(rgb.get_r())); + actual_g = s32(u32(rgb.get_g())); + actual_b = s32(u32(rgb.get_b())); if (actual_a != expected_a) osd_printf_error("Error testing rgbaint_t::get_a() = %d (expected %d)\n", actual_a, expected_a); if (actual_r != expected_r) osd_printf_error("Error testing rgbaint_t::get_r() = %d (expected %d)\n", actual_r, expected_r); if (actual_g != expected_g) osd_printf_error("Error testing rgbaint_t::get_g() = %d (expected %d)\n", actual_g, expected_g); @@ -845,88 +845,88 @@ void validity_checker::validate_rgb() // test set from packed RGBA imm = random_i32(); - expected_a = int32_t((uint32_t(imm) >> 24) & 0x00ff); - expected_r = int32_t((uint32_t(imm) >> 16) & 0x00ff); - expected_g = int32_t((uint32_t(imm) >> 8) & 0x00ff); - expected_b = int32_t((uint32_t(imm) >> 0) & 0x00ff); - rgb.set(uint32_t(imm)); - check_expected("rgbaint_t::set(uint32_t)"); + expected_a = s32((u32(imm) >> 24) & 0x00ff); + expected_r = s32((u32(imm) >> 16) & 0x00ff); + expected_g = s32((u32(imm) >> 8) & 0x00ff); + expected_b = s32((u32(imm) >> 0) & 0x00ff); + rgb.set(u32(imm)); + check_expected("rgbaint_t::set(u32)"); // while we have a value loaded that we know doesn't exceed 8-bit range, check the non-clamping convert-to-rgba packed = rgb.to_rgba(); - if (uint32_t(imm) != uint32_t(packed)) - osd_printf_error("Error testing rgbaint_t::to_rgba() = %08x (expected %08x)\n", uint32_t(packed), uint32_t(imm)); + if (u32(imm) != u32(packed)) + osd_printf_error("Error testing rgbaint_t::to_rgba() = %08x (expected %08x)\n", u32(packed), u32(imm)); // test construct from packed RGBA and assign imm = random_i32(); - expected_a = int32_t((uint32_t(imm) >> 24) & 0x00ff); - expected_r = int32_t((uint32_t(imm) >> 16) & 0x00ff); - expected_g = int32_t((uint32_t(imm) >> 8) & 0x00ff); - expected_b = int32_t((uint32_t(imm) >> 0) & 0x00ff); - rgb = rgbaint_t(uint32_t(imm)); - check_expected("rgbaint_t(uint32_t)"); + expected_a = s32((u32(imm) >> 24) & 0x00ff); + expected_r = s32((u32(imm) >> 16) & 0x00ff); + expected_g = s32((u32(imm) >> 8) & 0x00ff); + expected_b = s32((u32(imm) >> 0) & 0x00ff); + rgb = rgbaint_t(u32(imm)); + check_expected("rgbaint_t(u32)"); // while we have a value loaded that we know doesn't exceed 8-bit range, check the non-clamping convert-to-rgba packed = rgb.to_rgba(); - if (uint32_t(imm) != uint32_t(packed)) - osd_printf_error("Error testing rgbaint_t::to_rgba() = %08x (expected %08x)\n", uint32_t(packed), uint32_t(imm)); + if (u32(imm) != u32(packed)) + osd_printf_error("Error testing rgbaint_t::to_rgba() = %08x (expected %08x)\n", u32(packed), u32(imm)); // test set with rgb_t packed = random_u32(); - expected_a = int32_t(uint32_t(packed.a())); - expected_r = int32_t(uint32_t(packed.r())); - expected_g = int32_t(uint32_t(packed.g())); - expected_b = int32_t(uint32_t(packed.b())); + expected_a = s32(u32(packed.a())); + expected_r = s32(u32(packed.r())); + expected_g = s32(u32(packed.g())); + expected_b = s32(u32(packed.b())); rgb.set(packed); check_expected("rgbaint_t::set(rgba_t)"); // test construct with rgb_t packed = random_u32(); - expected_a = int32_t(uint32_t(packed.a())); - expected_r = int32_t(uint32_t(packed.r())); - expected_g = int32_t(uint32_t(packed.g())); - expected_b = int32_t(uint32_t(packed.b())); + expected_a = s32(u32(packed.a())); + expected_r = s32(u32(packed.r())); + expected_g = s32(u32(packed.g())); + expected_b = s32(u32(packed.b())); rgb = rgbaint_t(packed); check_expected("rgbaint_t::set(rgba_t)"); // test clamping convert-to-rgba with hand-crafted values to catch edge cases - rgb.set(std::numeric_limits::min(), -1, 0, 1); + rgb.set(std::numeric_limits::min(), -1, 0, 1); packed = rgb.to_rgba_clamp(); - if (uint32_t(0x00000001) != uint32_t(packed)) - osd_printf_error("Error testing rgbaint_t::to_rgba_clamp() = %08x (expected 0x00000001)\n", uint32_t(packed)); - rgb.set(254, 255, 256, std::numeric_limits::max()); + if (u32(0x00000001) != u32(packed)) + osd_printf_error("Error testing rgbaint_t::to_rgba_clamp() = %08x (expected 0x00000001)\n", u32(packed)); + rgb.set(254, 255, 256, std::numeric_limits::max()); packed = rgb.to_rgba_clamp(); - if (uint32_t(0xfeffffff) != uint32_t(packed)) - osd_printf_error("Error testing rgbaint_t::to_rgba_clamp() = %08x (expected 0xfeffffff)\n", uint32_t(packed)); - rgb.set(std::numeric_limits::max(), std::numeric_limits::min(), 256, -1); + if (u32(0xfeffffff) != u32(packed)) + osd_printf_error("Error testing rgbaint_t::to_rgba_clamp() = %08x (expected 0xfeffffff)\n", u32(packed)); + rgb.set(std::numeric_limits::max(), std::numeric_limits::min(), 256, -1); packed = rgb.to_rgba_clamp(); - if (uint32_t(0xff00ff00) != uint32_t(packed)) - osd_printf_error("Error testing rgbaint_t::to_rgba_clamp() = %08x (expected 0xff00ff00)\n", uint32_t(packed)); + if (u32(0xff00ff00) != u32(packed)) + osd_printf_error("Error testing rgbaint_t::to_rgba_clamp() = %08x (expected 0xff00ff00)\n", u32(packed)); rgb.set(0, 255, 1, 254); packed = rgb.to_rgba_clamp(); - if (uint32_t(0x00ff01fe) != uint32_t(packed)) - osd_printf_error("Error testing rgbaint_t::to_rgba_clamp() = %08x (expected 0x00ff01fe)\n", uint32_t(packed)); + if (u32(0x00ff01fe) != u32(packed)) + osd_printf_error("Error testing rgbaint_t::to_rgba_clamp() = %08x (expected 0x00ff01fe)\n", u32(packed)); // test in-place clamping with hand-crafted values to catch edge cases expected_a = 0; expected_r = 0; expected_g = 0; expected_b = 1; - rgb.set(std::numeric_limits::min(), -1, 0, 1); + rgb.set(std::numeric_limits::min(), -1, 0, 1); rgb.clamp_to_uint8(); check_expected("rgbaint_t::clamp_to_uint8"); expected_a = 254; expected_r = 255; expected_g = 255; expected_b = 255; - rgb.set(254, 255, 256, std::numeric_limits::max()); + rgb.set(254, 255, 256, std::numeric_limits::max()); rgb.clamp_to_uint8(); check_expected("rgbaint_t::clamp_to_uint8"); expected_a = 255; expected_r = 0; expected_g = 255; expected_b = 0; - rgb.set(std::numeric_limits::max(), std::numeric_limits::min(), 256, -1); + rgb.set(std::numeric_limits::max(), std::numeric_limits::min(), 256, -1); rgb.clamp_to_uint8(); check_expected("rgbaint_t::clamp_to_uint8"); expected_a = 0; @@ -956,37 +956,37 @@ void validity_checker::validate_rgb() check_expected("rgbaint_t::shl_imm"); // test logical shift right - expected_a = int32_t(uint32_t(actual_a = random_i32()) >> 8); - expected_r = int32_t(uint32_t(actual_r = random_i32()) >> 18); - expected_g = int32_t(uint32_t(actual_g = random_i32()) >> 26); - expected_b = int32_t(uint32_t(actual_b = random_i32()) >> 4); + expected_a = s32(u32(actual_a = random_i32()) >> 8); + expected_r = s32(u32(actual_r = random_i32()) >> 18); + expected_g = s32(u32(actual_g = random_i32()) >> 26); + expected_b = s32(u32(actual_b = random_i32()) >> 4); rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.shr(rgbaint_t(8, 18, 26, 4)); check_expected("rgbaint_t::shr"); // test logical shift right with opposite signs - expected_a = int32_t(uint32_t(actual_a = -actual_a) >> 21); - expected_r = int32_t(uint32_t(actual_r = -actual_r) >> 13); - expected_g = int32_t(uint32_t(actual_g = -actual_g) >> 11); - expected_b = int32_t(uint32_t(actual_b = -actual_b) >> 17); + expected_a = s32(u32(actual_a = -actual_a) >> 21); + expected_r = s32(u32(actual_r = -actual_r) >> 13); + expected_g = s32(u32(actual_g = -actual_g) >> 11); + expected_b = s32(u32(actual_b = -actual_b) >> 17); rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.shr(rgbaint_t(21, 13, 11, 17)); check_expected("rgbaint_t::shr"); // test logical shift right immediate - expected_a = int32_t(uint32_t(actual_a = random_i32()) >> 5); - expected_r = int32_t(uint32_t(actual_r = random_i32()) >> 5); - expected_g = int32_t(uint32_t(actual_g = random_i32()) >> 5); - expected_b = int32_t(uint32_t(actual_b = random_i32()) >> 5); + expected_a = s32(u32(actual_a = random_i32()) >> 5); + expected_r = s32(u32(actual_r = random_i32()) >> 5); + expected_g = s32(u32(actual_g = random_i32()) >> 5); + expected_b = s32(u32(actual_b = random_i32()) >> 5); rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.shr_imm(5); check_expected("rgbaint_t::shr_imm"); // test logical shift right immediate with opposite signs - expected_a = int32_t(uint32_t(actual_a = -actual_a) >> 15); - expected_r = int32_t(uint32_t(actual_r = -actual_r) >> 15); - expected_g = int32_t(uint32_t(actual_g = -actual_g) >> 15); - expected_b = int32_t(uint32_t(actual_b = -actual_b) >> 15); + expected_a = s32(u32(actual_a = -actual_a) >> 15); + expected_r = s32(u32(actual_r = -actual_r) >> 15); + expected_g = s32(u32(actual_g = -actual_g) >> 15); + expected_b = s32(u32(actual_b = -actual_b) >> 15); rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.shr_imm(15); check_expected("rgbaint_t::shr_imm"); @@ -1050,19 +1050,19 @@ void validity_checker::validate_rgb() actual_r = random_i32_nolimit(); actual_g = random_i32_nolimit(); actual_b = random_i32_nolimit(); - expected_a = ~int32_t(0); + expected_a = ~s32(0); expected_r = 0; expected_g = 0; expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpeq(rgbaint_t(actual_a, actual_r - 1, actual_g + 1, std::numeric_limits::min())); + rgb.cmpeq(rgbaint_t(actual_a, actual_r - 1, actual_g + 1, std::numeric_limits::min())); check_expected("rgbaint_t::cmpeq"); expected_a = 0; - expected_r = ~int32_t(0); + expected_r = ~s32(0); expected_g = 0; expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpeq(rgbaint_t(std::numeric_limits::max(), actual_r, actual_g - 1, actual_b + 1)); + rgb.cmpeq(rgbaint_t(std::numeric_limits::max(), actual_r, actual_g - 1, actual_b + 1)); check_expected("rgbaint_t::cmpeq"); // test immediate equality comparison @@ -1070,31 +1070,31 @@ void validity_checker::validate_rgb() actual_r = random_i32_nolimit(); actual_g = random_i32_nolimit(); actual_b = random_i32_nolimit(); - expected_a = ~int32_t(0); - expected_r = (actual_r == actual_a) ? ~int32_t(0) : 0; - expected_g = (actual_g == actual_a) ? ~int32_t(0) : 0; - expected_b = (actual_b == actual_a) ? ~int32_t(0) : 0; + expected_a = ~s32(0); + expected_r = (actual_r == actual_a) ? ~s32(0) : 0; + expected_g = (actual_g == actual_a) ? ~s32(0) : 0; + expected_b = (actual_b == actual_a) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmpeq_imm(actual_a); check_expected("rgbaint_t::cmpeq_imm"); - expected_a = (actual_a == actual_r) ? ~int32_t(0) : 0; - expected_r = ~int32_t(0); - expected_g = (actual_g == actual_r) ? ~int32_t(0) : 0; - expected_b = (actual_b == actual_r) ? ~int32_t(0) : 0; + expected_a = (actual_a == actual_r) ? ~s32(0) : 0; + expected_r = ~s32(0); + expected_g = (actual_g == actual_r) ? ~s32(0) : 0; + expected_b = (actual_b == actual_r) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmpeq_imm(actual_r); check_expected("rgbaint_t::cmpeq_imm"); - expected_a = (actual_a == actual_g) ? ~int32_t(0) : 0; - expected_r = (actual_r == actual_g) ? ~int32_t(0) : 0; - expected_g = ~int32_t(0); - expected_b = (actual_b == actual_g) ? ~int32_t(0) : 0; + expected_a = (actual_a == actual_g) ? ~s32(0) : 0; + expected_r = (actual_r == actual_g) ? ~s32(0) : 0; + expected_g = ~s32(0); + expected_b = (actual_b == actual_g) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmpeq_imm(actual_g); check_expected("rgbaint_t::cmpeq_imm"); - expected_a = (actual_a == actual_b) ? ~int32_t(0) : 0; - expected_r = (actual_r == actual_b) ? ~int32_t(0) : 0; - expected_g = (actual_g == actual_b) ? ~int32_t(0) : 0; - expected_b = ~int32_t(0); + expected_a = (actual_a == actual_b) ? ~s32(0) : 0; + expected_r = (actual_r == actual_b) ? ~s32(0) : 0; + expected_g = (actual_g == actual_b) ? ~s32(0) : 0; + expected_b = ~s32(0); rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmpeq_imm(actual_b); check_expected("rgbaint_t::cmpeq_imm"); @@ -1103,12 +1103,12 @@ void validity_checker::validate_rgb() expected_g = 0; expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpeq_imm(std::numeric_limits::min()); + rgb.cmpeq_imm(std::numeric_limits::min()); check_expected("rgbaint_t::cmpeq_imm"); - expected_a = !actual_a ? ~int32_t(0) : 0; - expected_r = !actual_r ? ~int32_t(0) : 0; - expected_g = !actual_g ? ~int32_t(0) : 0; - expected_b = !actual_b ? ~int32_t(0) : 0; + expected_a = !actual_a ? ~s32(0) : 0; + expected_r = !actual_r ? ~s32(0) : 0; + expected_g = !actual_g ? ~s32(0) : 0; + expected_b = !actual_b ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmpeq_imm(0); check_expected("rgbaint_t::cmpeq_imm"); @@ -1117,7 +1117,7 @@ void validity_checker::validate_rgb() expected_g = 0; expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpeq_imm(std::numeric_limits::max()); + rgb.cmpeq_imm(std::numeric_limits::max()); check_expected("rgbaint_t::cmpeq_imm"); // test immediate RGB equality comparison @@ -1127,17 +1127,17 @@ void validity_checker::validate_rgb() actual_b = random_i32_nolimit(); expected_a = 0; expected_r = 0; - expected_g = ~int32_t(0); + expected_g = ~s32(0); expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpeq_imm_rgba(std::numeric_limits::min(), std::numeric_limits::max(), actual_g, actual_b - 1); + rgb.cmpeq_imm_rgba(std::numeric_limits::min(), std::numeric_limits::max(), actual_g, actual_b - 1); check_expected("rgbaint_t::cmpeq_imm_rgba"); expected_a = 0; expected_r = 0; expected_g = 0; - expected_b = ~int32_t(0); + expected_b = ~s32(0); rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpeq_imm_rgba(actual_a + 1, std::numeric_limits::min(), std::numeric_limits::max(), actual_b); + rgb.cmpeq_imm_rgba(actual_a + 1, std::numeric_limits::min(), std::numeric_limits::max(), actual_b); check_expected("rgbaint_t::cmpeq_imm_rgba"); // test RGB greater than comparison @@ -1146,18 +1146,18 @@ void validity_checker::validate_rgb() actual_g = random_i32_nolimit(); actual_b = random_i32_nolimit(); expected_a = 0; - expected_r = ~int32_t(0); + expected_r = ~s32(0); expected_g = 0; - expected_b = ~int32_t(0); + expected_b = ~s32(0); rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpgt(rgbaint_t(actual_a, actual_r - 1, actual_g + 1, std::numeric_limits::min())); + rgb.cmpgt(rgbaint_t(actual_a, actual_r - 1, actual_g + 1, std::numeric_limits::min())); check_expected("rgbaint_t::cmpgt"); expected_a = 0; expected_r = 0; - expected_g = ~int32_t(0); + expected_g = ~s32(0); expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpgt(rgbaint_t(std::numeric_limits::max(), actual_r, actual_g - 1, actual_b + 1)); + rgb.cmpgt(rgbaint_t(std::numeric_limits::max(), actual_r, actual_g - 1, actual_b + 1)); check_expected("rgbaint_t::cmpgt"); // test immediate greater than comparison @@ -1166,44 +1166,44 @@ void validity_checker::validate_rgb() actual_g = random_i32_nolimit(); actual_b = random_i32_nolimit(); expected_a = 0; - expected_r = (actual_r > actual_a) ? ~int32_t(0) : 0; - expected_g = (actual_g > actual_a) ? ~int32_t(0) : 0; - expected_b = (actual_b > actual_a) ? ~int32_t(0) : 0; + expected_r = (actual_r > actual_a) ? ~s32(0) : 0; + expected_g = (actual_g > actual_a) ? ~s32(0) : 0; + expected_b = (actual_b > actual_a) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmpgt_imm(actual_a); check_expected("rgbaint_t::cmpgt_imm"); - expected_a = (actual_a > actual_r) ? ~int32_t(0) : 0; + expected_a = (actual_a > actual_r) ? ~s32(0) : 0; expected_r = 0; - expected_g = (actual_g > actual_r) ? ~int32_t(0) : 0; - expected_b = (actual_b > actual_r) ? ~int32_t(0) : 0; + expected_g = (actual_g > actual_r) ? ~s32(0) : 0; + expected_b = (actual_b > actual_r) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmpgt_imm(actual_r); check_expected("rgbaint_t::cmpgt_imm"); - expected_a = (actual_a > actual_g) ? ~int32_t(0) : 0; - expected_r = (actual_r > actual_g) ? ~int32_t(0) : 0; + expected_a = (actual_a > actual_g) ? ~s32(0) : 0; + expected_r = (actual_r > actual_g) ? ~s32(0) : 0; expected_g =0; - expected_b = (actual_b > actual_g) ? ~int32_t(0) : 0; + expected_b = (actual_b > actual_g) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmpgt_imm(actual_g); check_expected("rgbaint_t::cmpgt_imm"); - expected_a = (actual_a > actual_b) ? ~int32_t(0) : 0; - expected_r = (actual_r > actual_b) ? ~int32_t(0) : 0; - expected_g = (actual_g > actual_b) ? ~int32_t(0) : 0; + expected_a = (actual_a > actual_b) ? ~s32(0) : 0; + expected_r = (actual_r > actual_b) ? ~s32(0) : 0; + expected_g = (actual_g > actual_b) ? ~s32(0) : 0; expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmpgt_imm(actual_b); check_expected("rgbaint_t::cmpgt_imm"); - expected_a = ~int32_t(0); - expected_r = ~int32_t(0); - expected_g = ~int32_t(0); - expected_b = ~int32_t(0); + expected_a = ~s32(0); + expected_r = ~s32(0); + expected_g = ~s32(0); + expected_b = ~s32(0); rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpgt_imm(std::numeric_limits::min()); + rgb.cmpgt_imm(std::numeric_limits::min()); check_expected("rgbaint_t::cmpgt_imm"); - expected_a = (actual_a > 0) ? ~int32_t(0) : 0; - expected_r = (actual_r > 0) ? ~int32_t(0) : 0; - expected_g = (actual_g > 0) ? ~int32_t(0) : 0; - expected_b = (actual_b > 0) ? ~int32_t(0) : 0; + expected_a = (actual_a > 0) ? ~s32(0) : 0; + expected_r = (actual_r > 0) ? ~s32(0) : 0; + expected_g = (actual_g > 0) ? ~s32(0) : 0; + expected_b = (actual_b > 0) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmpgt_imm(0); check_expected("rgbaint_t::cmpgt_imm"); @@ -1212,7 +1212,7 @@ void validity_checker::validate_rgb() expected_g = 0; expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpgt_imm(std::numeric_limits::max()); + rgb.cmpgt_imm(std::numeric_limits::max()); check_expected("rgbaint_t::cmpgt_imm"); // test immediate RGB greater than comparison @@ -1220,19 +1220,19 @@ void validity_checker::validate_rgb() actual_r = random_i32_nolimit(); actual_g = random_i32_nolimit(); actual_b = random_i32_nolimit(); - expected_a = ~int32_t(0); + expected_a = ~s32(0); expected_r = 0; expected_g = 0; - expected_b = ~int32_t(0); + expected_b = ~s32(0); rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpgt_imm_rgba(std::numeric_limits::min(), std::numeric_limits::max(), actual_g, actual_b - 1); + rgb.cmpgt_imm_rgba(std::numeric_limits::min(), std::numeric_limits::max(), actual_g, actual_b - 1); check_expected("rgbaint_t::cmpgt_imm_rgba"); expected_a = 0; - expected_r = ~int32_t(0); + expected_r = ~s32(0); expected_g = 0; expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmpgt_imm_rgba(actual_a + 1, std::numeric_limits::min(), std::numeric_limits::max(), actual_b); + rgb.cmpgt_imm_rgba(actual_a + 1, std::numeric_limits::min(), std::numeric_limits::max(), actual_b); check_expected("rgbaint_t::cmpgt_imm_rgba"); // test RGB less than comparison @@ -1242,17 +1242,17 @@ void validity_checker::validate_rgb() actual_b = random_i32_nolimit(); expected_a = 0; expected_r = 0; - expected_g = ~int32_t(0); + expected_g = ~s32(0); expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmplt(rgbaint_t(actual_a, actual_r - 1, actual_g + 1, std::numeric_limits::min())); + rgb.cmplt(rgbaint_t(actual_a, actual_r - 1, actual_g + 1, std::numeric_limits::min())); check_expected("rgbaint_t::cmplt"); - expected_a = ~int32_t(0); + expected_a = ~s32(0); expected_r = 0; expected_g = 0; - expected_b = ~int32_t(0); + expected_b = ~s32(0); rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmplt(rgbaint_t(std::numeric_limits::max(), actual_r, actual_g - 1, actual_b + 1)); + rgb.cmplt(rgbaint_t(std::numeric_limits::max(), actual_r, actual_g - 1, actual_b + 1)); check_expected("rgbaint_t::cmplt"); // test immediate less than comparison @@ -1261,29 +1261,29 @@ void validity_checker::validate_rgb() actual_g = random_i32_nolimit(); actual_b = random_i32_nolimit(); expected_a = 0; - expected_r = (actual_r < actual_a) ? ~int32_t(0) : 0; - expected_g = (actual_g < actual_a) ? ~int32_t(0) : 0; - expected_b = (actual_b < actual_a) ? ~int32_t(0) : 0; + expected_r = (actual_r < actual_a) ? ~s32(0) : 0; + expected_g = (actual_g < actual_a) ? ~s32(0) : 0; + expected_b = (actual_b < actual_a) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmplt_imm(actual_a); check_expected("rgbaint_t::cmplt_imm"); - expected_a = (actual_a < actual_r) ? ~int32_t(0) : 0; + expected_a = (actual_a < actual_r) ? ~s32(0) : 0; expected_r = 0; - expected_g = (actual_g < actual_r) ? ~int32_t(0) : 0; - expected_b = (actual_b < actual_r) ? ~int32_t(0) : 0; + expected_g = (actual_g < actual_r) ? ~s32(0) : 0; + expected_b = (actual_b < actual_r) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmplt_imm(actual_r); check_expected("rgbaint_t::cmplt_imm"); - expected_a = (actual_a < actual_g) ? ~int32_t(0) : 0; - expected_r = (actual_r < actual_g) ? ~int32_t(0) : 0; + expected_a = (actual_a < actual_g) ? ~s32(0) : 0; + expected_r = (actual_r < actual_g) ? ~s32(0) : 0; expected_g =0; - expected_b = (actual_b < actual_g) ? ~int32_t(0) : 0; + expected_b = (actual_b < actual_g) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmplt_imm(actual_g); check_expected("rgbaint_t::cmplt_imm"); - expected_a = (actual_a < actual_b) ? ~int32_t(0) : 0; - expected_r = (actual_r < actual_b) ? ~int32_t(0) : 0; - expected_g = (actual_g < actual_b) ? ~int32_t(0) : 0; + expected_a = (actual_a < actual_b) ? ~s32(0) : 0; + expected_r = (actual_r < actual_b) ? ~s32(0) : 0; + expected_g = (actual_g < actual_b) ? ~s32(0) : 0; expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmplt_imm(actual_b); @@ -1293,21 +1293,21 @@ void validity_checker::validate_rgb() expected_g = 0; expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmplt_imm(std::numeric_limits::min()); + rgb.cmplt_imm(std::numeric_limits::min()); check_expected("rgbaint_t::cmplt_imm"); - expected_a = (actual_a < 0) ? ~int32_t(0) : 0; - expected_r = (actual_r < 0) ? ~int32_t(0) : 0; - expected_g = (actual_g < 0) ? ~int32_t(0) : 0; - expected_b = (actual_b < 0) ? ~int32_t(0) : 0; + expected_a = (actual_a < 0) ? ~s32(0) : 0; + expected_r = (actual_r < 0) ? ~s32(0) : 0; + expected_g = (actual_g < 0) ? ~s32(0) : 0; + expected_b = (actual_b < 0) ? ~s32(0) : 0; rgb.set(actual_a, actual_r, actual_g, actual_b); rgb.cmplt_imm(0); check_expected("rgbaint_t::cmplt_imm"); - expected_a = ~int32_t(0); - expected_r = ~int32_t(0); - expected_g = ~int32_t(0); - expected_b = ~int32_t(0); + expected_a = ~s32(0); + expected_r = ~s32(0); + expected_g = ~s32(0); + expected_b = ~s32(0); rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmplt_imm(std::numeric_limits::max()); + rgb.cmplt_imm(std::numeric_limits::max()); check_expected("rgbaint_t::cmplt_imm"); // test immediate RGB less than comparison @@ -1316,18 +1316,18 @@ void validity_checker::validate_rgb() actual_g = random_i32_nolimit(); actual_b = random_i32_nolimit(); expected_a = 0; - expected_r = ~int32_t(0); + expected_r = ~s32(0); expected_g = 0; expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmplt_imm_rgba(std::numeric_limits::min(), std::numeric_limits::max(), actual_g, actual_b - 1); + rgb.cmplt_imm_rgba(std::numeric_limits::min(), std::numeric_limits::max(), actual_g, actual_b - 1); check_expected("rgbaint_t::cmplt_imm_rgba"); - expected_a = ~int32_t(0); + expected_a = ~s32(0); expected_r = 0; - expected_g = ~int32_t(0); + expected_g = ~s32(0); expected_b = 0; rgb.set(actual_a, actual_r, actual_g, actual_b); - rgb.cmplt_imm_rgba(actual_a + 1, std::numeric_limits::min(), std::numeric_limits::max(), actual_b); + rgb.cmplt_imm_rgba(actual_a + 1, std::numeric_limits::min(), std::numeric_limits::max(), actual_b); check_expected("rgbaint_t::cmplt_imm_rgba"); } @@ -1388,7 +1388,7 @@ void validity_checker::validate_driver() // make sure the year is only digits, '?' or '+' for (const char *s = m_current_driver->year; *s != 0; s++) - if (!isdigit((uint8_t)*s) && *s != '?' && *s != '+') + if (!isdigit(u8(*s)) && *s != '?' && *s != '+') { osd_printf_error("Driver has an invalid year '%s'\n", m_current_driver->year); break; @@ -1437,7 +1437,7 @@ void validity_checker::validate_roms() // scan the ROM entries for this device const char *last_region_name = "???"; const char *last_name = "???"; - uint32_t current_length = 0; + u32 current_length = 0; int items_since_region = 1; int last_bios = 0; int total_files = 0; @@ -1538,7 +1538,7 @@ void validity_checker::validate_analog_input_field(ioport_field &field) for (shift = 0; shift <= 31 && (~field.mask() & (1 << shift)) != 0; shift++) { } // convert the positional max value to be in the bitmask for testing - //int32_t analog_max = field.maxval(); + //s32 analog_max = field.maxval(); //analog_max = (analog_max - 1) << shift; // positional port size must fit in bits used @@ -1550,9 +1550,9 @@ void validity_checker::validate_analog_input_field(ioport_field &field) else if (field.type() > IPT_ANALOG_ABSOLUTE_FIRST && field.type() < IPT_ANALOG_ABSOLUTE_LAST) { // adjust for signed values - int32_t default_value = field.defvalue(); - int32_t analog_min = field.minval(); - int32_t analog_max = field.maxval(); + s32 default_value = field.defvalue(); + s32 analog_min = field.minval(); + s32 analog_max = field.maxval(); if (analog_min > analog_max) { analog_min = -analog_min; @@ -1606,7 +1606,7 @@ void validity_checker::validate_dip_settings(ioport_field &field) { const char *demo_sounds = ioport_string_from_index(INPUT_STRING_Demo_Sounds); const char *flipscreen = ioport_string_from_index(INPUT_STRING_Flip_Screen); - uint8_t coin_list[__input_string_coinage_end + 1 - __input_string_coinage_start] = { 0 }; + u8 coin_list[__input_string_coinage_end + 1 - __input_string_coinage_start] = { 0 }; bool coin_error = false; // iterate through the settings diff --git a/src/emu/validity.h b/src/emu/validity.h index f74b25599ff..7dcb741dc4c 100644 --- a/src/emu/validity.h +++ b/src/emu/validity.h @@ -64,7 +64,7 @@ private: typedef std::unordered_map int_map; // internal helpers - const char *ioport_string_from_index(uint32_t index); + const char *ioport_string_from_index(u32 index); int get_defstr_index(const char *string, bool suppress_error = false); // core helpers @@ -90,10 +90,10 @@ private: void output_indented_errors(std::string &text, const char *header); // random number generation - int32_t random_i32(); - uint32_t random_u32(); - int64_t random_i64(); - uint64_t random_u64(); + s32 random_i32(); + u32 random_u32(); + s64 random_i64(); + u64 random_u64(); // internal driver list driver_enumerator m_drivlist; diff --git a/src/emu/video.cpp b/src/emu/video.cpp index f25da887e03..a1c246f70f2 100644 --- a/src/emu/video.cpp +++ b/src/emu/video.cpp @@ -37,18 +37,18 @@ // frameskipping tables const bool video_manager::s_skiptable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS] = { - { false,false,false,false,false,false,false,false,false,false,false,false }, - { false,false,false,false,false,false,false,false,false,false,false,true }, - { false,false,false,false,false,true ,false,false,false,false,false,true }, - { false,false,false,true ,false,false,false,true ,false,false,false,true }, - { false,false,true ,false,false,true ,false,false,true ,false,false,true }, - { false,true ,false,false,true ,false,true ,false,false,true ,false,true }, - { false,true ,false,true ,false,true ,false,true ,false,true ,false,true }, - { false,true ,false,true ,true ,false,true ,false,true ,true ,false,true }, - { false,true ,true ,false,true ,true ,false,true ,true ,false,true ,true }, - { false,true ,true ,true ,false,true ,true ,true ,false,true ,true ,true }, - { false,true ,true ,true ,true ,true ,false,true ,true ,true ,true ,true }, - { false,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true } + { false, false, false, false, false, false, false, false, false, false, false, false }, + { false, false, false, false, false, false, false, false, false, false, false, true }, + { false, false, false, false, false, true , false, false, false, false, false, true }, + { false, false, false, true , false, false, false, true , false, false, false, true }, + { false, false, true , false, false, true , false, false, true , false, false, true }, + { false, true , false, false, true , false, true , false, false, true , false, true }, + { false, true , false, true , false, true , false, true , false, true , false, true }, + { false, true , false, true , true , false, true , false, true , true , false, true }, + { false, true , true , false, true , true , false, true , true , false, true , true }, + { false, true , true , true , false, true , true , true , false, true , true , true }, + { false, true , true , true , true , true , false, true , true , true , true , true }, + { false, true , true , true , true , true , true , true , true , true , true , true } }; @@ -57,7 +57,7 @@ const bool video_manager::s_skiptable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS] = // VIDEO MANAGER //************************************************************************** -static void video_notifier_callback(const char *outname, int32_t value, void *param) +static void video_notifier_callback(const char *outname, s32 value, void *param) { video_manager *vm = (video_manager *)param; @@ -553,7 +553,7 @@ void video_manager::end_recording(movie_format format) // recording //------------------------------------------------- -void video_manager::add_sound_to_recording(const int16_t *sound, int numsamples) +void video_manager::add_sound_to_recording(const s16 *sound, int numsamples) { // only record if we have a file if (m_avi_file != nullptr) @@ -770,7 +770,7 @@ void video_manager::update_throttle(attotime emutime) restoring from a saved state */ - static const uint8_t popcount[256] = + static const u8 popcount[256] = { 0,1,1,2,1,2,2,3, 1,2,2,3,2,3,3,4, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, @@ -1017,8 +1017,8 @@ void video_manager::update_refresh_speed() // compute a target speed as an integral percentage // note that we lop 0.25Hz off of the minrefresh when doing the computation to allow for // the fact that most refresh rates are not accurate to 10 digits... - uint32_t target_speed = floor((minrefresh - 0.25) * 1000.0 / ATTOSECONDS_TO_HZ(min_frame_period)); - uint32_t original_speed = original_speed_setting(); + u32 target_speed = floor((minrefresh - 0.25) * 1000.0 / ATTOSECONDS_TO_HZ(min_frame_period)); + u32 original_speed = original_speed_setting(); target_speed = std::min(target_speed, original_speed); // if we changed, log that verbosely @@ -1102,8 +1102,8 @@ void video_manager::recompute_speed(const attotime &emutime) // given screen //------------------------------------------------- -typedef software_renderer snap_renderer_bilinear; -typedef software_renderer snap_renderer; +typedef software_renderer snap_renderer_bilinear; +typedef software_renderer snap_renderer; void video_manager::create_snapshot_bitmap(screen_device *screen) { @@ -1117,8 +1117,8 @@ void video_manager::create_snapshot_bitmap(screen_device *screen) } // get the minimum width/height and set it on the target - int32_t width = m_snap_width; - int32_t height = m_snap_height; + s32 width = m_snap_width; + s32 height = m_snap_height; if (width == 0 || height == 0) m_snap_target->compute_minimum_size(width, height); m_snap_target->set_bounds(width, height); @@ -1146,7 +1146,7 @@ void video_manager::create_snapshot_bitmap(screen_device *screen) osd_file::error video_manager::open_next(emu_file &file, const char *extension) { - uint32_t origflags = file.openflags(); + u32 origflags = file.openflags(); // handle defaults const char *snapname = machine().options().snap_name(); diff --git a/src/emu/video.h b/src/emu/video.h index bd4ae3b0437..f783ed6b383 100644 --- a/src/emu/video.h +++ b/src/emu/video.h @@ -95,7 +95,7 @@ public: // movies void begin_recording(const char *name, movie_format format); void end_recording(movie_format format); - void add_sound_to_recording(const int16_t *sound, int numsamples); + void add_sound_to_recording(const s16 *sound, int numsamples); void set_timecode_enabled(bool value) { m_timecode_enabled = value; } bool get_timecode_enabled() { return m_timecode_enabled; } @@ -143,7 +143,7 @@ private: osd_ticks_t m_throttle_last_ticks; // osd_ticks the last call to throttle attotime m_throttle_realtime; // real time the last call to throttle attotime m_throttle_emutime; // emulated time the last call to throttle - uint32_t m_throttle_history; // history of frames where we were fast enough + u32 m_throttle_history; // history of frames where we were fast enough // dynamic speed computation osd_ticks_t m_speed_last_realtime; // real time at the last speed calculation @@ -151,24 +151,24 @@ private: double m_speed_percent; // most recent speed percentage // overall speed computation - uint32_t m_overall_real_seconds; // accumulated real seconds at normal speed + u32 m_overall_real_seconds; // accumulated real seconds at normal speed osd_ticks_t m_overall_real_ticks; // accumulated real ticks at normal speed attotime m_overall_emutime; // accumulated emulated time at normal speed - uint32_t m_overall_valid_counter; // number of consecutive valid time periods + u32 m_overall_valid_counter; // number of consecutive valid time periods // configuration bool m_throttled; // flag: true if we're currently throttled float m_throttle_rate; // target rate for throttling bool m_fastforward; // flag: true if we're currently fast-forwarding - uint32_t m_seconds_to_run; // number of seconds to run before quitting + u32 m_seconds_to_run; // number of seconds to run before quitting bool m_auto_frameskip; // flag: true if we're automatically frameskipping - uint32_t m_speed; // overall speed (*1000) + u32 m_speed; // overall speed (*1000) // frameskipping - uint8_t m_empty_skip_count; // number of empty frames we have skipped - uint8_t m_frameskip_level; // current frameskip level - uint8_t m_frameskip_counter; // counter that counts through the frameskip steps - int8_t m_frameskip_adjust; + u8 m_empty_skip_count; // number of empty frames we have skipped + u8 m_frameskip_level; // current frameskip level + u8 m_frameskip_counter; // counter that counts through the frameskip steps + s8 m_frameskip_adjust; bool m_skipping_this_frame; // flag: true if we are skipping the current frame osd_ticks_t m_average_oversleep; // average number of ticks the OSD oversleeps @@ -176,34 +176,34 @@ private: render_target * m_snap_target; // screen shapshot target bitmap_rgb32 m_snap_bitmap; // screen snapshot bitmap bool m_snap_native; // are we using native per-screen layouts? - int32_t m_snap_width; // width of snapshots (0 == auto) - int32_t m_snap_height; // height of snapshots (0 == auto) + s32 m_snap_width; // width of snapshots (0 == auto) + s32 m_snap_height; // height of snapshots (0 == auto) // movie recording - MNG std::unique_ptr m_mng_file; // handle to the open movie file attotime m_mng_frame_period; // period of a single movie frame attotime m_mng_next_frame_time; // time of next frame - uint32_t m_mng_frame; // current movie frame number + u32 m_mng_frame; // current movie frame number // movie recording - AVI avi_file::ptr m_avi_file; // handle to the open movie file attotime m_avi_frame_period; // period of a single movie frame attotime m_avi_next_frame_time; // time of next frame - uint32_t m_avi_frame; // current movie frame number + u32 m_avi_frame; // current movie frame number // movie recording - dummy bool m_dummy_recording; // indicates if snapshot should be created of every frame - static const bool s_skiptable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS]; + static const bool s_skiptable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS]; static const attoseconds_t ATTOSECONDS_PER_SPEED_UPDATE = ATTOSECONDS_PER_SECOND / 4; static const int PAUSED_REFRESH_RATE = 30; - bool m_timecode_enabled; // inp.timecode record enabled - bool m_timecode_write; // Show/hide timer at right (partial time) - std::string m_timecode_text; // Message for that video part (intro, gameplay, extra) - attotime m_timecode_start; // Starting timer for that video part (intro, gameplay, extra) - attotime m_timecode_total; // Show/hide timer at left (total elapsed on resulting video preview) + bool m_timecode_enabled; // inp.timecode record enabled + bool m_timecode_write; // Show/hide timer at right (partial time) + std::string m_timecode_text; // Message for that video part (intro, gameplay, extra) + attotime m_timecode_start; // Starting timer for that video part (intro, gameplay, extra) + attotime m_timecode_total; // Show/hide timer at left (total elapsed on resulting video preview) }; diff --git a/src/emu/video/generic.h b/src/emu/video/generic.h index 5f2ef27966c..3dbb717018d 100644 --- a/src/emu/video/generic.h +++ b/src/emu/video/generic.h @@ -8,10 +8,10 @@ *********************************************************************/ -#pragma once +#ifndef MAME_EMU_VIDEO_GENERIC_H +#define MAME_EMU_VIDEO_GENERIC_H -#ifndef __VIDEO_GENERIC_H__ -#define __VIDEO_GENERIC_H__ +#pragma once @@ -28,4 +28,4 @@ extern const gfx_layout gfx_8x8x6_planar; extern const gfx_layout gfx_16x16x4_planar; -#endif /* __VIDEO_GENERIC_H__ */ +#endif /* MAME_EMU_VIDEO_GENERIC_H */ diff --git a/src/emu/video/resnet.cpp b/src/emu/video/resnet.cpp index 1b467d016c4..f746f8448d6 100644 --- a/src/emu/video/resnet.cpp +++ b/src/emu/video/resnet.cpp @@ -449,7 +449,7 @@ int compute_res_net(int inputs, int channel, const res_net_info &di) { double rTotal=0.0; double v = 0; - int i; + int i; double vBias = di.rgb[channel].vBias; double vOH = di.vOH; @@ -459,7 +459,7 @@ int compute_res_net(int inputs, int channel, const res_net_info &di) double vcc = di.vcc; double ttlHRes = 0; double rGnd = di.rgb[channel].rGnd; - uint8_t OpenCol = di.OpenCol; + u8 OpenCol = di.OpenCol; /* Global options */ @@ -692,15 +692,15 @@ int compute_res_net(int inputs, int channel, const res_net_info &di) return (int) (v * 255 / vcc + 0.4); } -void compute_res_net_all(std::vector &rgb, const uint8_t *prom, const res_net_decode_info &rdi, const res_net_info &di) +void compute_res_net_all(std::vector &rgb, const u8 *prom, const res_net_decode_info &rdi, const res_net_info &di) { - uint8_t r,g,b; + u8 r,g,b; int i,j,k; rgb.resize(rdi.end - rdi.start + 1); for (i=rdi.start; i<=rdi.end; i++) { - uint8_t t[3] = {0,0,0}; + u8 t[3] = {0,0,0}; int s; for (j=0;j &rgb, const uint8_t *prom, const res_net_decode_info &rdi, const res_net_info &di); +void compute_res_net_all(std::vector &rgb, const u8 *prom, const res_net_decode_info &rdi, const res_net_info &di); /* legacy interface */ @@ -196,4 +196,4 @@ double compute_resistor_net_outputs( -#endif /*_RESNET_H_*/ +#endif /* MAME_EMU_VIDEO_RESNET_H */ diff --git a/src/emu/video/rgbgen.cpp b/src/emu/video/rgbgen.cpp index ef55504d90c..09b27090887 100644 --- a/src/emu/video/rgbgen.cpp +++ b/src/emu/video/rgbgen.cpp @@ -22,10 +22,10 @@ scale factor -------------------------------------------------*/ -void rgbaint_t::blend(const rgbaint_t& color2, uint8_t color1scale) +void rgbaint_t::blend(const rgbaint_t& color2, u8 color1scale) { - int32_t scale1 = (int32_t)color1scale; - int32_t scale2 = 256 - scale1; + s32 scale1 = s32(color1scale); + s32 scale2 = 256 - scale1; m_a = (m_a * scale1 + color2.m_a * scale2) >> 8; m_r = (m_r * scale1 + color2.m_r * scale2) >> 8; @@ -44,7 +44,7 @@ void rgbaint_t::blend(const rgbaint_t& color2, uint8_t color1scale) per channel, and clamp to byte values -------------------------------------------------*/ -void rgbaint_t::scale_imm_and_clamp(int32_t scale) +void rgbaint_t::scale_imm_and_clamp(s32 scale) { m_a = (m_a * scale) >> 8; m_r = (m_r * scale) >> 8; @@ -54,10 +54,10 @@ void rgbaint_t::scale_imm_and_clamp(int32_t scale) m_r |= (m_r & 0x00800000) ? 0xff000000 : 0; m_g |= (m_g & 0x00800000) ? 0xff000000 : 0; m_b |= (m_b & 0x00800000) ? 0xff000000 : 0; - if ((uint32_t)m_a > 255) { m_a = (m_a < 0) ? 0 : 255; } - if ((uint32_t)m_r > 255) { m_r = (m_r < 0) ? 0 : 255; } - if ((uint32_t)m_g > 255) { m_g = (m_g < 0) ? 0 : 255; } - if ((uint32_t)m_b > 255) { m_b = (m_b < 0) ? 0 : 255; } + if (u32(m_a) > 255) { m_a = (m_a < 0) ? 0 : 255; } + if (u32(m_r) > 255) { m_r = (m_r < 0) ? 0 : 255; } + if (u32(m_g) > 255) { m_g = (m_g < 0) ? 0 : 255; } + if (u32(m_b) > 255) { m_b = (m_b < 0) ? 0 : 255; } } void rgbaint_t::scale_and_clamp(const rgbaint_t& scale) @@ -70,14 +70,14 @@ void rgbaint_t::scale_and_clamp(const rgbaint_t& scale) m_r |= (m_r & 0x00800000) ? 0xff000000 : 0; m_g |= (m_g & 0x00800000) ? 0xff000000 : 0; m_b |= (m_b & 0x00800000) ? 0xff000000 : 0; - if ((uint32_t)m_a > 255) { m_a = (m_a < 0) ? 0 : 255; } - if ((uint32_t)m_r > 255) { m_r = (m_r < 0) ? 0 : 255; } - if ((uint32_t)m_g > 255) { m_g = (m_g < 0) ? 0 : 255; } - if ((uint32_t)m_b > 255) { m_b = (m_b < 0) ? 0 : 255; } + if (u32(m_a) > 255) { m_a = (m_a < 0) ? 0 : 255; } + if (u32(m_r) > 255) { m_r = (m_r < 0) ? 0 : 255; } + if (u32(m_g) > 255) { m_g = (m_g < 0) ? 0 : 255; } + if (u32(m_b) > 255) { m_b = (m_b < 0) ? 0 : 255; } } -void rgbaint_t::scale_imm_add_and_clamp(int32_t scale, const rgbaint_t& other) +void rgbaint_t::scale_imm_add_and_clamp(s32 scale, const rgbaint_t& other) { m_a = (m_a * scale) >> 8; m_r = (m_r * scale) >> 8; @@ -91,10 +91,10 @@ void rgbaint_t::scale_imm_add_and_clamp(int32_t scale, const rgbaint_t& other) m_r += other.m_r; m_g += other.m_g; m_b += other.m_b; - if ((uint32_t)m_a > 255) { m_a = (m_a < 0) ? 0 : 255; } - if ((uint32_t)m_r > 255) { m_r = (m_r < 0) ? 0 : 255; } - if ((uint32_t)m_g > 255) { m_g = (m_g < 0) ? 0 : 255; } - if ((uint32_t)m_b > 255) { m_b = (m_b < 0) ? 0 : 255; } + if (u32(m_a) > 255) { m_a = (m_a < 0) ? 0 : 255; } + if (u32(m_r) > 255) { m_r = (m_r < 0) ? 0 : 255; } + if (u32(m_g) > 255) { m_g = (m_g < 0) ? 0 : 255; } + if (u32(m_b) > 255) { m_b = (m_b < 0) ? 0 : 255; } } void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other) @@ -111,10 +111,10 @@ void rgbaint_t::scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& oth m_r += other.m_r; m_g += other.m_g; m_b += other.m_b; - if ((uint32_t)m_a > 255) { m_a = (m_a < 0) ? 0 : 255; } - if ((uint32_t)m_r > 255) { m_r = (m_r < 0) ? 0 : 255; } - if ((uint32_t)m_g > 255) { m_g = (m_g < 0) ? 0 : 255; } - if ((uint32_t)m_b > 255) { m_b = (m_b < 0) ? 0 : 255; } + if (u32(m_a) > 255) { m_a = (m_a < 0) ? 0 : 255; } + if (u32(m_r) > 255) { m_r = (m_r < 0) ? 0 : 255; } + if (u32(m_g) > 255) { m_g = (m_g < 0) ? 0 : 255; } + if (u32(m_b) > 255) { m_b = (m_b < 0) ? 0 : 255; } } void rgbaint_t::scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2) @@ -127,10 +127,10 @@ void rgbaint_t::scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& ot m_r |= (m_r & 0x00800000) ? 0xff000000 : 0; m_g |= (m_g & 0x00800000) ? 0xff000000 : 0; m_b |= (m_b & 0x00800000) ? 0xff000000 : 0; - if ((uint32_t)m_a > 255) { m_a = (m_a < 0) ? 0 : 255; } - if ((uint32_t)m_r > 255) { m_r = (m_r < 0) ? 0 : 255; } - if ((uint32_t)m_g > 255) { m_g = (m_g < 0) ? 0 : 255; } - if ((uint32_t)m_b > 255) { m_b = (m_b < 0) ? 0 : 255; } + if (u32(m_a) > 255) { m_a = (m_a < 0) ? 0 : 255; } + if (u32(m_r) > 255) { m_r = (m_r < 0) ? 0 : 255; } + if (u32(m_g) > 255) { m_g = (m_g < 0) ? 0 : 255; } + if (u32(m_b) > 255) { m_b = (m_b < 0) ? 0 : 255; } } #endif // !defined(__ALTIVEC__) diff --git a/src/emu/video/rgbgen.h b/src/emu/video/rgbgen.h index 66dac76aa53..197769946a8 100644 --- a/src/emu/video/rgbgen.h +++ b/src/emu/video/rgbgen.h @@ -20,16 +20,16 @@ class rgbaint_t { public: rgbaint_t(): m_a(0), m_r(0), m_g(0), m_b(0) { } - explicit rgbaint_t(uint32_t rgba) { set(rgba); } - rgbaint_t(int32_t a, int32_t r, int32_t g, int32_t b) { set(a, r, g, b); } + explicit rgbaint_t(u32 rgba) { set(rgba); } + rgbaint_t(s32 a, s32 r, s32 g, s32 b) { set(a, r, g, b); } explicit rgbaint_t(const rgb_t& rgba) { set(rgba); } rgbaint_t(const rgbaint_t& other) = default; rgbaint_t &operator=(const rgbaint_t& other) = default; void set(const rgbaint_t& other) { set(other.m_a, other.m_r, other.m_g, other.m_b); } - void set(uint32_t rgba) { set((rgba >> 24) & 0xff, (rgba >> 16) & 0xff, (rgba >> 8) & 0xff, rgba & 0xff); } - void set(int32_t a, int32_t r, int32_t g, int32_t b) + void set(u32 rgba) { set((rgba >> 24) & 0xff, (rgba >> 16) & 0xff, (rgba >> 8) & 0xff, rgba & 0xff); } + void set(s32 a, s32 r, s32 g, s32 b) { m_a = a; m_r = r; @@ -42,39 +42,39 @@ public: rgb_t to_rgba_clamp() const { - const uint8_t a = (m_a < 0) ? 0 : (m_a > 255) ? 255 : m_a; - const uint8_t r = (m_r < 0) ? 0 : (m_r > 255) ? 255 : m_r; - const uint8_t g = (m_g < 0) ? 0 : (m_g > 255) ? 255 : m_g; - const uint8_t b = (m_b < 0) ? 0 : (m_b > 255) ? 255 : m_b; + const u8 a = (m_a < 0) ? 0 : (m_a > 255) ? 255 : m_a; + const u8 r = (m_r < 0) ? 0 : (m_r > 255) ? 255 : m_r; + const u8 g = (m_g < 0) ? 0 : (m_g > 255) ? 255 : m_g; + const u8 b = (m_b < 0) ? 0 : (m_b > 255) ? 255 : m_b; return rgb_t(a, r, g, b); } - void set_a(const int32_t value) { m_a = value; } - void set_r(const int32_t value) { m_r = value; } - void set_g(const int32_t value) { m_g = value; } - void set_b(const int32_t value) { m_b = value; } + void set_a(const s32 value) { m_a = value; } + void set_r(const s32 value) { m_r = value; } + void set_g(const s32 value) { m_g = value; } + void set_b(const s32 value) { m_b = value; } - uint8_t get_a() const { return uint8_t(uint32_t(m_a)); } - uint8_t get_r() const { return uint8_t(uint32_t(m_r)); } - uint8_t get_g() const { return uint8_t(uint32_t(m_g)); } - uint8_t get_b() const { return uint8_t(uint32_t(m_b)); } + u8 get_a() const { return u8(u32(m_a)); } + u8 get_r() const { return u8(u32(m_r)); } + u8 get_g() const { return u8(u32(m_g)); } + u8 get_b() const { return u8(u32(m_b)); } - int32_t get_a32() const { return m_a; } - int32_t get_r32() const { return m_r; } - int32_t get_g32() const { return m_g; } - int32_t get_b32() const { return m_b; } + s32 get_a32() const { return m_a; } + s32 get_r32() const { return m_r; } + s32 get_g32() const { return m_g; } + s32 get_b32() const { return m_b; } inline void add(const rgbaint_t& color) { add_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b); } - inline void add_imm(const int32_t imm) + inline void add_imm(const s32 imm) { add_imm_rgba(imm, imm, imm, imm); } - inline void add_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void add_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { m_a += a; m_r += r; @@ -87,12 +87,12 @@ public: sub_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b); } - inline void sub_imm(const int32_t imm) + inline void sub_imm(const s32 imm) { sub_imm_rgba(imm, imm, imm, imm); } - inline void sub_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void sub_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { m_a -= a; m_r -= r; @@ -105,12 +105,12 @@ public: subr_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b); } - inline void subr_imm(const int32_t imm) + inline void subr_imm(const s32 imm) { subr_imm_rgba(imm, imm, imm, imm); } - inline void subr_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void subr_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { m_a = a - m_a; m_r = r - m_r; @@ -123,12 +123,12 @@ public: mul_imm_rgba(color.m_a, color.m_r, color.m_g, color.m_b); } - inline void mul_imm(const int32_t imm) + inline void mul_imm(const s32 imm) { mul_imm_rgba(imm, imm, imm, imm); } - inline void mul_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void mul_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { m_a *= a; m_r *= r; @@ -144,7 +144,7 @@ public: m_b <<= shift.m_b; } - inline void shl_imm(const uint8_t shift) + inline void shl_imm(const u8 shift) { if (shift == 0) return; @@ -157,21 +157,21 @@ public: inline void shr(const rgbaint_t& shift) { - m_a = int32_t(uint32_t(m_a) >> shift.m_a); - m_r = int32_t(uint32_t(m_r) >> shift.m_r); - m_g = int32_t(uint32_t(m_g) >> shift.m_g); - m_b = int32_t(uint32_t(m_b) >> shift.m_b); + m_a = s32(u32(m_a) >> shift.m_a); + m_r = s32(u32(m_r) >> shift.m_r); + m_g = s32(u32(m_g) >> shift.m_g); + m_b = s32(u32(m_b) >> shift.m_b); } - inline void shr_imm(const uint8_t shift) + inline void shr_imm(const u8 shift) { if (shift == 0) return; - m_a = int32_t(uint32_t(m_a) >> shift); - m_r = int32_t(uint32_t(m_r) >> shift); - m_g = int32_t(uint32_t(m_g) >> shift); - m_b = int32_t(uint32_t(m_b) >> shift); + m_a = s32(u32(m_a) >> shift); + m_r = s32(u32(m_r) >> shift); + m_g = s32(u32(m_g) >> shift); + m_b = s32(u32(m_b) >> shift); } inline void sra(const rgbaint_t& shift) @@ -193,10 +193,10 @@ public: m_b |= ~0 << (32 - shift.m_b); } - inline void sra_imm(const uint8_t shift) + inline void sra_imm(const u8 shift) { - const uint32_t high_bit = 1 << (31 - shift); - const uint32_t high_mask = ~0 << (32 - shift); + const u32 high_bit = 1 << (31 - shift); + const u32 high_mask = ~0 << (32 - shift); m_a >>= shift; if (m_a & high_bit) @@ -221,11 +221,11 @@ public: void andnot_reg(const rgbaint_t& color) { and_imm_rgba(~color.m_a, ~color.m_r, ~color.m_g, ~color.m_b); } - void or_imm(int32_t imm) { or_imm_rgba(imm, imm, imm, imm); } - void and_imm(int32_t imm) { and_imm_rgba(imm, imm, imm, imm); } - void xor_imm(int32_t imm) { xor_imm_rgba(imm, imm, imm, imm); } + void or_imm(s32 imm) { or_imm_rgba(imm, imm, imm, imm); } + void and_imm(s32 imm) { and_imm_rgba(imm, imm, imm, imm); } + void xor_imm(s32 imm) { xor_imm_rgba(imm, imm, imm, imm); } - inline void or_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void or_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { m_a |= a; m_r |= r; @@ -233,7 +233,7 @@ public: m_b |= b; } - inline void and_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void and_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { m_a &= a; m_r &= r; @@ -241,7 +241,7 @@ public: m_b &= b; } - inline void xor_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void xor_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { m_a ^= a; m_r ^= r; @@ -249,7 +249,7 @@ public: m_b ^= b; } - inline void clamp_and_clear(const uint32_t sign) + inline void clamp_and_clear(const u32 sign) { if (m_a & sign) m_a = 0; if (m_r & sign) m_r = 0; @@ -267,7 +267,7 @@ public: m_b = (m_b < 0) ? 0 : (m_b > 255) ? 255 : m_b; } - inline void sign_extend(const uint32_t compare, const uint32_t sign) + inline void sign_extend(const u32 compare, const u32 sign) { if ((m_a & compare) == compare) m_a |= sign; @@ -282,7 +282,7 @@ public: m_b |= sign; } - inline void min(const int32_t value) + inline void min(const s32 value) { m_a = (m_a > value) ? value : m_a; m_r = (m_r > value) ? value : m_r; @@ -290,7 +290,7 @@ public: m_b = (m_b > value) ? value : m_b; } - inline void max(const int32_t value) + inline void max(const s32 value) { m_a = (m_a < value) ? value : m_a; m_r = (m_r < value) ? value : m_r; @@ -298,23 +298,23 @@ public: m_b = (m_b < value) ? value : m_b; } - void blend(const rgbaint_t& other, uint8_t factor); + void blend(const rgbaint_t& other, u8 factor); void scale_and_clamp(const rgbaint_t& scale); - void scale_imm_and_clamp(const int32_t scale); + void scale_imm_and_clamp(const s32 scale); void scale2_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other, const rgbaint_t& scale2); void scale_add_and_clamp(const rgbaint_t& scale, const rgbaint_t& other); - void scale_imm_add_and_clamp(const int32_t scale, const rgbaint_t& other); + void scale_imm_add_and_clamp(const s32 scale, const rgbaint_t& other); void cmpeq(const rgbaint_t& value) { cmpeq_imm_rgba(value.m_a, value.m_r, value.m_g, value.m_b); } void cmpgt(const rgbaint_t& value) { cmpgt_imm_rgba(value.m_a, value.m_r, value.m_g, value.m_b); } void cmplt(const rgbaint_t& value) { cmplt_imm_rgba(value.m_a, value.m_r, value.m_g, value.m_b); } - void cmpeq_imm(int32_t value) { cmpeq_imm_rgba(value, value, value, value); } - void cmpgt_imm(int32_t value) { cmpgt_imm_rgba(value, value, value, value); } - void cmplt_imm(int32_t value) { cmplt_imm_rgba(value, value, value, value); } + void cmpeq_imm(s32 value) { cmpeq_imm_rgba(value, value, value, value); } + void cmpgt_imm(s32 value) { cmpgt_imm_rgba(value, value, value, value); } + void cmplt_imm(s32 value) { cmplt_imm_rgba(value, value, value, value); } - void cmpeq_imm_rgba(int32_t a, int32_t r, int32_t g, int32_t b) + void cmpeq_imm_rgba(s32 a, s32 r, s32 g, s32 b) { m_a = (m_a == a) ? 0xffffffff : 0; m_r = (m_r == r) ? 0xffffffff : 0; @@ -322,7 +322,7 @@ public: m_b = (m_b == b) ? 0xffffffff : 0; } - void cmpgt_imm_rgba(int32_t a, int32_t r, int32_t g, int32_t b) + void cmpgt_imm_rgba(s32 a, s32 r, s32 g, s32 b) { m_a = (m_a > a) ? 0xffffffff : 0; m_r = (m_r > r) ? 0xffffffff : 0; @@ -330,7 +330,7 @@ public: m_b = (m_b > b) ? 0xffffffff : 0; } - void cmplt_imm_rgba(int32_t a, int32_t r, int32_t g, int32_t b) + void cmplt_imm_rgba(s32 a, s32 r, s32 g, s32 b) { m_a = (m_a < a) ? 0xffffffff : 0; m_r = (m_r < r) ? 0xffffffff : 0; @@ -349,7 +349,7 @@ public: return *this; } - rgbaint_t& operator+=(const int32_t other) + rgbaint_t& operator+=(const s32 other) { add_imm_rgba(other, other, other, other); return *this; @@ -367,30 +367,30 @@ public: return *this; } - rgbaint_t& operator*=(const int32_t other) + rgbaint_t& operator*=(const s32 other) { mul_imm_rgba(other, other, other, other); return *this; } - rgbaint_t& operator>>=(const int32_t shift) + rgbaint_t& operator>>=(const s32 shift) { sra_imm(shift); return *this; } - static uint32_t bilinear_filter(uint32_t rgb00, uint32_t rgb01, uint32_t rgb10, uint32_t rgb11, uint8_t u, uint8_t v) + static u32 bilinear_filter(u32 rgb00, u32 rgb01, u32 rgb10, u32 rgb11, u8 u, u8 v) { - uint32_t rb0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); - uint32_t rb1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8); + u32 rb0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); + u32 rb1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8); rgb00 >>= 8; rgb01 >>= 8; rgb10 >>= 8; rgb11 >>= 8; - uint32_t ag0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); - uint32_t ag1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8); + u32 ag0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); + u32 ag1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8); rb0 = (rb0 & 0x00ff00ff) + ((((rb1 & 0x00ff00ff) - (rb0 & 0x00ff00ff)) * v) >> 8); ag0 = (ag0 & 0x00ff00ff) + ((((ag1 & 0x00ff00ff) - (ag0 & 0x00ff00ff)) * v) >> 8); @@ -398,31 +398,31 @@ public: return ((ag0 << 8) & 0xff00ff00) | (rb0 & 0x00ff00ff); } - void bilinear_filter_rgbaint(uint32_t rgb00, uint32_t rgb01, uint32_t rgb10, uint32_t rgb11, uint8_t u, uint8_t v) + void bilinear_filter_rgbaint(u32 rgb00, u32 rgb01, u32 rgb10, u32 rgb11, u8 u, u8 v) { - uint32_t rb0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); - uint32_t rb1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8); + u32 rb0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); + u32 rb1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8); rgb00 >>= 8; rgb01 >>= 8; rgb10 >>= 8; rgb11 >>= 8; - uint32_t ag0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); - uint32_t ag1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8); + u32 ag0 = (rgb00 & 0x00ff00ff) + ((((rgb01 & 0x00ff00ff) - (rgb00 & 0x00ff00ff)) * u) >> 8); + u32 ag1 = (rgb10 & 0x00ff00ff) + ((((rgb11 & 0x00ff00ff) - (rgb10 & 0x00ff00ff)) * u) >> 8); rb0 = (rb0 & 0x00ff00ff) + ((((rb1 & 0x00ff00ff) - (rb0 & 0x00ff00ff)) * v) >> 8); ag0 = (ag0 & 0x00ff00ff) + ((((ag1 & 0x00ff00ff) - (ag0 & 0x00ff00ff)) * v) >> 8); - uint32_t result = ((ag0 << 8) & 0xff00ff00) | (rb0 & 0x00ff00ff); + u32 result = ((ag0 << 8) & 0xff00ff00) | (rb0 & 0x00ff00ff); this->set(result); } protected: - int32_t m_a; - int32_t m_r; - int32_t m_g; - int32_t m_b; + s32 m_a; + s32 m_r; + s32 m_g; + s32 m_b; }; #endif // MAME_EMU_VIDEO_RGBGEN_H diff --git a/src/emu/video/rgbsse.cpp b/src/emu/video/rgbsse.cpp index 87c4f7b33e0..35ea6a1948f 100644 --- a/src/emu/video/rgbsse.cpp +++ b/src/emu/video/rgbsse.cpp @@ -164,7 +164,7 @@ const struct rgbaint_t::_statics rgbaint_t::statics = HIGHER LEVEL OPERATIONS ***************************************************************************/ -void rgbaint_t::blend(const rgbaint_t& other, uint8_t factor) +void rgbaint_t::blend(const rgbaint_t& other, u8 factor) { const __m128i scale1 = _mm_set1_epi32(factor); const rgbaint_t scale2(_mm_sub_epi32(_mm_set1_epi32(0x100), scale1)); @@ -184,7 +184,7 @@ void rgbaint_t::scale_and_clamp(const rgbaint_t& scale) clamp_to_uint8(); } -void rgbaint_t::scale_imm_and_clamp(const int32_t scale) +void rgbaint_t::scale_imm_and_clamp(const s32 scale) { mul_imm(scale); sra_imm(8); diff --git a/src/emu/video/rgbsse.h b/src/emu/video/rgbsse.h index 521000f4488..83028f894d2 100644 --- a/src/emu/video/rgbsse.h +++ b/src/emu/video/rgbsse.h @@ -29,8 +29,8 @@ class rgbaint_t { public: rgbaint_t() { } - explicit rgbaint_t(uint32_t rgba) { set(rgba); } - rgbaint_t(int32_t a, int32_t r, int32_t g, int32_t b) { set(a, r, g, b); } + explicit rgbaint_t(u32 rgba) { set(rgba); } + rgbaint_t(s32 a, s32 r, s32 g, s32 b) { set(a, r, g, b); } explicit rgbaint_t(const rgb_t& rgb) { set(rgb); } explicit rgbaint_t(__m128i rgba) { m_value = rgba; } @@ -38,8 +38,8 @@ public: rgbaint_t &operator=(const rgbaint_t& other) = default; void set(const rgbaint_t& other) { m_value = other.m_value; } - void set(uint32_t rgba) { m_value = _mm_and_si128(_mm_set1_epi32(0xff), _mm_set_epi32(rgba >> 24, rgba >> 16, rgba >> 8, rgba)); } - void set(int32_t a, int32_t r, int32_t g, int32_t b) { m_value = _mm_set_epi32(a, r, g, b); } + void set(u32 rgba) { m_value = _mm_and_si128(_mm_set1_epi32(0xff), _mm_set_epi32(rgba >> 24, rgba >> 16, rgba >> 8, rgba)); } + void set(s32 a, s32 r, s32 g, s32 b) { m_value = _mm_set_epi32(a, r, g, b); } void set(const rgb_t& rgb) { m_value = _mm_unpacklo_epi16(_mm_unpacklo_epi8(_mm_cvtsi32_si128(rgb), _mm_setzero_si128()), _mm_setzero_si128()); } inline rgb_t to_rgba() const @@ -53,32 +53,32 @@ public: } #ifdef __SSE4_1__ - void set_a(const int32_t value) { m_value = _mm_insert_epi32(m_value, value, 3); } - void set_r(const int32_t value) { m_value = _mm_insert_epi32(m_value, value, 2); } - void set_g(const int32_t value) { m_value = _mm_insert_epi32(m_value, value, 1); } - void set_b(const int32_t value) { m_value = _mm_insert_epi32(m_value, value, 0); } + void set_a(const s32 value) { m_value = _mm_insert_epi32(m_value, value, 3); } + void set_r(const s32 value) { m_value = _mm_insert_epi32(m_value, value, 2); } + void set_g(const s32 value) { m_value = _mm_insert_epi32(m_value, value, 1); } + void set_b(const s32 value) { m_value = _mm_insert_epi32(m_value, value, 0); } #else - void set_a(const int32_t value) { m_value = _mm_or_si128(_mm_and_si128(m_value, alpha_mask()), _mm_set_epi32(value, 0, 0, 0)); } - void set_r(const int32_t value) { m_value = _mm_or_si128(_mm_and_si128(m_value, red_mask()), _mm_set_epi32(0, value, 0, 0)); } - void set_g(const int32_t value) { m_value = _mm_or_si128(_mm_and_si128(m_value, green_mask()), _mm_set_epi32(0, 0, value, 0)); } - void set_b(const int32_t value) { m_value = _mm_or_si128(_mm_and_si128(m_value, blue_mask()), _mm_set_epi32(0, 0, 0, value)); } + void set_a(const s32 value) { m_value = _mm_or_si128(_mm_and_si128(m_value, alpha_mask()), _mm_set_epi32(value, 0, 0, 0)); } + void set_r(const s32 value) { m_value = _mm_or_si128(_mm_and_si128(m_value, red_mask()), _mm_set_epi32(0, value, 0, 0)); } + void set_g(const s32 value) { m_value = _mm_or_si128(_mm_and_si128(m_value, green_mask()), _mm_set_epi32(0, 0, value, 0)); } + void set_b(const s32 value) { m_value = _mm_or_si128(_mm_and_si128(m_value, blue_mask()), _mm_set_epi32(0, 0, 0, value)); } #endif - uint8_t get_a() const { return uint8_t(unsigned(_mm_extract_epi16(m_value, 6))); } - uint8_t get_r() const { return uint8_t(unsigned(_mm_extract_epi16(m_value, 4))); } - uint8_t get_g() const { return uint8_t(unsigned(_mm_extract_epi16(m_value, 2))); } - uint8_t get_b() const { return uint8_t(unsigned(_mm_extract_epi16(m_value, 0))); } + u8 get_a() const { return u8(unsigned(_mm_extract_epi16(m_value, 6))); } + u8 get_r() const { return u8(unsigned(_mm_extract_epi16(m_value, 4))); } + u8 get_g() const { return u8(unsigned(_mm_extract_epi16(m_value, 2))); } + u8 get_b() const { return u8(unsigned(_mm_extract_epi16(m_value, 0))); } #ifdef __SSE4_1__ - int32_t get_a32() const { return _mm_extract_epi32(m_value, 3); } - int32_t get_r32() const { return _mm_extract_epi32(m_value, 2); } - int32_t get_g32() const { return _mm_extract_epi32(m_value, 1); } - int32_t get_b32() const { return _mm_extract_epi32(m_value, 0); } + s32 get_a32() const { return _mm_extract_epi32(m_value, 3); } + s32 get_r32() const { return _mm_extract_epi32(m_value, 2); } + s32 get_g32() const { return _mm_extract_epi32(m_value, 1); } + s32 get_b32() const { return _mm_extract_epi32(m_value, 0); } #else - int32_t get_a32() const { return (_mm_extract_epi16(m_value, 7) << 16) | _mm_extract_epi16(m_value, 6); } - int32_t get_r32() const { return (_mm_extract_epi16(m_value, 5) << 16) | _mm_extract_epi16(m_value, 4); } - int32_t get_g32() const { return (_mm_extract_epi16(m_value, 3) << 16) | _mm_extract_epi16(m_value, 2); } - int32_t get_b32() const { return (_mm_extract_epi16(m_value, 1) << 16) | _mm_extract_epi16(m_value, 0); } + s32 get_a32() const { return (_mm_extract_epi16(m_value, 7) << 16) | _mm_extract_epi16(m_value, 6); } + s32 get_r32() const { return (_mm_extract_epi16(m_value, 5) << 16) | _mm_extract_epi16(m_value, 4); } + s32 get_g32() const { return (_mm_extract_epi16(m_value, 3) << 16) | _mm_extract_epi16(m_value, 2); } + s32 get_b32() const { return (_mm_extract_epi16(m_value, 1) << 16) | _mm_extract_epi16(m_value, 0); } #endif inline void add(const rgbaint_t& color2) @@ -86,12 +86,12 @@ public: m_value = _mm_add_epi32(m_value, color2.m_value); } - inline void add_imm(const int32_t imm) + inline void add_imm(const s32 imm) { m_value = _mm_add_epi32(m_value, _mm_set1_epi32(imm)); } - inline void add_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void add_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { m_value = _mm_add_epi32(m_value, _mm_set_epi32(a, r, g, b)); } @@ -101,12 +101,12 @@ public: m_value = _mm_sub_epi32(m_value, color2.m_value); } - inline void sub_imm(const int32_t imm) + inline void sub_imm(const s32 imm) { m_value = _mm_sub_epi32(m_value, _mm_set1_epi32(imm)); } - inline void sub_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void sub_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { m_value = _mm_sub_epi32(m_value, _mm_set_epi32(a, r, g, b)); } @@ -116,12 +116,12 @@ public: m_value = _mm_sub_epi32(color2.m_value, m_value); } - inline void subr_imm(const int32_t imm) + inline void subr_imm(const s32 imm) { m_value = _mm_sub_epi32(_mm_set1_epi32(imm), m_value); } - inline void subr_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void subr_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { m_value = _mm_sub_epi32(_mm_set_epi32(a, r, g, b), m_value); } @@ -133,7 +133,7 @@ public: m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(tmp2, _MM_SHUFFLE(0, 0, 2, 0))); } - inline void mul_imm(const int32_t imm) + inline void mul_imm(const s32 imm) { __m128i immv = _mm_set1_epi32(imm); __m128i tmp1 = _mm_mul_epu32(m_value, immv); @@ -141,7 +141,7 @@ public: m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(tmp2, _MM_SHUFFLE(0, 0, 2, 0))); } - inline void mul_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void mul_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { __m128i immv = _mm_set_epi32(a, r, g, b); __m128i tmp1 = _mm_mul_epu32(m_value, immv); @@ -166,7 +166,7 @@ public: set(areg.get_a32(), rreg.get_r32(), greg.get_g32(), breg.get_b32()); } - inline void shl_imm(const uint8_t shift) + inline void shl_imm(const u8 shift) { m_value = _mm_slli_epi32(m_value, shift); } @@ -188,7 +188,7 @@ public: set(areg.get_a32(), rreg.get_r32(), greg.get_g32(), breg.get_b32()); } - inline void shr_imm(const uint8_t shift) + inline void shr_imm(const u8 shift) { m_value = _mm_srli_epi32(m_value, shift); } @@ -210,7 +210,7 @@ public: set(areg.get_a32(), rreg.get_r32(), greg.get_g32(), breg.get_b32()); } - inline void sra_imm(const uint8_t shift) + inline void sra_imm(const u8 shift) { m_value = _mm_srai_epi32(m_value, shift); } @@ -221,15 +221,15 @@ public: void andnot_reg(const rgbaint_t& color2) { m_value = _mm_andnot_si128(color2.m_value, m_value); } - void or_imm(int32_t value) { m_value = _mm_or_si128(m_value, _mm_set1_epi32(value)); } - void and_imm(int32_t value) { m_value = _mm_and_si128(m_value, _mm_set1_epi32(value)); } - void xor_imm(int32_t value) { m_value = _mm_xor_si128(m_value, _mm_set1_epi32(value)); } + void or_imm(s32 value) { m_value = _mm_or_si128(m_value, _mm_set1_epi32(value)); } + void and_imm(s32 value) { m_value = _mm_and_si128(m_value, _mm_set1_epi32(value)); } + void xor_imm(s32 value) { m_value = _mm_xor_si128(m_value, _mm_set1_epi32(value)); } - void or_imm_rgba(int32_t a, int32_t r, int32_t g, int32_t b) { m_value = _mm_or_si128(m_value, _mm_set_epi32(a, r, g, b)); } - void and_imm_rgba(int32_t a, int32_t r, int32_t g, int32_t b) { m_value = _mm_and_si128(m_value, _mm_set_epi32(a, r, g, b)); } - void xor_imm_rgba(int32_t a, int32_t r, int32_t g, int32_t b) { m_value = _mm_xor_si128(m_value, _mm_set_epi32(a, r, g, b)); } + void or_imm_rgba(s32 a, s32 r, s32 g, s32 b) { m_value = _mm_or_si128(m_value, _mm_set_epi32(a, r, g, b)); } + void and_imm_rgba(s32 a, s32 r, s32 g, s32 b) { m_value = _mm_and_si128(m_value, _mm_set_epi32(a, r, g, b)); } + void xor_imm_rgba(s32 a, s32 r, s32 g, s32 b) { m_value = _mm_xor_si128(m_value, _mm_set_epi32(a, r, g, b)); } - inline void clamp_and_clear(const uint32_t sign) + inline void clamp_and_clear(const u32 sign) { __m128i vsign = _mm_set1_epi32(sign); m_value = _mm_and_si128(m_value, _mm_cmpeq_epi32(_mm_and_si128(m_value, vsign), _mm_setzero_si128())); @@ -247,7 +247,7 @@ public: m_value = _mm_unpacklo_epi16(m_value, _mm_setzero_si128()); } - inline void sign_extend(const uint32_t compare, const uint32_t sign) + inline void sign_extend(const u32 compare, const u32 sign) { __m128i compare_vec = _mm_set1_epi32(compare); __m128i compare_mask = _mm_cmpeq_epi32(_mm_and_si128(m_value, compare_vec), compare_vec); @@ -255,7 +255,7 @@ public: m_value = _mm_or_si128(m_value, compared); } - inline void min(const int32_t value) + inline void min(const s32 value) { __m128i val = _mm_set1_epi32(value); __m128i is_greater_than = _mm_cmpgt_epi32(m_value, val); @@ -267,7 +267,7 @@ public: m_value = _mm_or_si128(val_to_set, m_value); } - inline void max(const int32_t value) + inline void max(const s32 value) { __m128i val = _mm_set1_epi32(value); __m128i is_less_than = _mm_cmplt_epi32(m_value, val); @@ -279,12 +279,12 @@ public: m_value = _mm_or_si128(val_to_set, m_value); } - void blend(const rgbaint_t& other, uint8_t factor); + void blend(const rgbaint_t& other, u8 factor); void scale_and_clamp(const rgbaint_t& scale); - void scale_imm_and_clamp(const int32_t scale); + void scale_imm_and_clamp(const s32 scale); - inline void scale_imm_add_and_clamp(const int32_t scale, const rgbaint_t& other) + inline void scale_imm_add_and_clamp(const s32 scale, const rgbaint_t& other) { mul_imm(scale); sra_imm(8); @@ -315,13 +315,13 @@ public: void cmpgt(const rgbaint_t& value) { m_value = _mm_cmpgt_epi32(m_value, value.m_value); } void cmplt(const rgbaint_t& value) { m_value = _mm_cmplt_epi32(m_value, value.m_value); } - void cmpeq_imm(int32_t value) { m_value = _mm_cmpeq_epi32(m_value, _mm_set1_epi32(value)); } - void cmpgt_imm(int32_t value) { m_value = _mm_cmpgt_epi32(m_value, _mm_set1_epi32(value)); } - void cmplt_imm(int32_t value) { m_value = _mm_cmplt_epi32(m_value, _mm_set1_epi32(value)); } + void cmpeq_imm(s32 value) { m_value = _mm_cmpeq_epi32(m_value, _mm_set1_epi32(value)); } + void cmpgt_imm(s32 value) { m_value = _mm_cmpgt_epi32(m_value, _mm_set1_epi32(value)); } + void cmplt_imm(s32 value) { m_value = _mm_cmplt_epi32(m_value, _mm_set1_epi32(value)); } - void cmpeq_imm_rgba(int32_t a, int32_t r, int32_t g, int32_t b) { m_value = _mm_cmpeq_epi32(m_value, _mm_set_epi32(a, r, g, b)); } - void cmpgt_imm_rgba(int32_t a, int32_t r, int32_t g, int32_t b) { m_value = _mm_cmpgt_epi32(m_value, _mm_set_epi32(a, r, g, b)); } - void cmplt_imm_rgba(int32_t a, int32_t r, int32_t g, int32_t b) { m_value = _mm_cmplt_epi32(m_value, _mm_set_epi32(a, r, g, b)); } + void cmpeq_imm_rgba(s32 a, s32 r, s32 g, s32 b) { m_value = _mm_cmpeq_epi32(m_value, _mm_set_epi32(a, r, g, b)); } + void cmpgt_imm_rgba(s32 a, s32 r, s32 g, s32 b) { m_value = _mm_cmpgt_epi32(m_value, _mm_set_epi32(a, r, g, b)); } + void cmplt_imm_rgba(s32 a, s32 r, s32 g, s32 b) { m_value = _mm_cmplt_epi32(m_value, _mm_set_epi32(a, r, g, b)); } inline rgbaint_t& operator+=(const rgbaint_t& other) { @@ -329,7 +329,7 @@ public: return *this; } - inline rgbaint_t& operator+=(const int32_t other) + inline rgbaint_t& operator+=(const s32 other) { m_value = _mm_add_epi32(m_value, _mm_set1_epi32(other)); return *this; @@ -347,14 +347,14 @@ public: return *this; } - inline rgbaint_t& operator*=(const int32_t other) + inline rgbaint_t& operator*=(const s32 other) { const __m128i immv = _mm_set1_epi32(other); m_value = _mm_unpacklo_epi32(_mm_shuffle_epi32(_mm_mul_epu32(m_value, immv), _MM_SHUFFLE(0, 0, 2, 0)), _mm_shuffle_epi32(_mm_mul_epu32(_mm_srli_si128(m_value, 4), _mm_srli_si128(immv, 4)), _MM_SHUFFLE(0, 0, 2, 0))); return *this; } - inline rgbaint_t& operator>>=(const int32_t shift) + inline rgbaint_t& operator>>=(const s32 shift) { m_value = _mm_srai_epi32(m_value, shift); return *this; @@ -370,7 +370,7 @@ public: #endif } - static uint32_t bilinear_filter(uint32_t rgb00, uint32_t rgb01, uint32_t rgb10, uint32_t rgb11, uint8_t u, uint8_t v) + static u32 bilinear_filter(u32 rgb00, u32 rgb01, u32 rgb10, u32 rgb11, u8 u, u8 v) { __m128i color00 = _mm_cvtsi32_si128(rgb00); __m128i color01 = _mm_cvtsi32_si128(rgb01); @@ -394,7 +394,7 @@ public: return _mm_cvtsi128_si32(color01); } - void bilinear_filter_rgbaint(uint32_t rgb00, uint32_t rgb01, uint32_t rgb10, uint32_t rgb11, uint8_t u, uint8_t v) + void bilinear_filter_rgbaint(u32 rgb00, u32 rgb01, u32 rgb10, u32 rgb11, u8 u, u8 v) { __m128i color00 = _mm_cvtsi32_si128(rgb00); __m128i color01 = _mm_cvtsi32_si128(rgb01); @@ -419,18 +419,18 @@ protected: struct _statics { __m128 dummy_for_alignment; - uint16_t alpha_mask[8]; - uint16_t red_mask[8]; - uint16_t green_mask[8]; - uint16_t blue_mask[8]; - int16_t scale_table[256][8]; + u16 alpha_mask[8]; + u16 red_mask[8]; + u16 green_mask[8]; + u16 blue_mask[8]; + s16 scale_table[256][8]; }; static __m128i alpha_mask() { return *(__m128i *)&statics.alpha_mask[0]; } static __m128i red_mask() { return *(__m128i *)&statics.red_mask[0]; } static __m128i green_mask() { return *(__m128i *)&statics.green_mask[0]; } static __m128i blue_mask() { return *(__m128i *)&statics.blue_mask[0]; } - static __m128i scale_factor(uint8_t index) { return *(__m128i *)&statics.scale_table[index][0]; } + static __m128i scale_factor(u8 index) { return *(__m128i *)&statics.scale_table[index][0]; } __m128i m_value; @@ -438,4 +438,4 @@ protected: }; -#endif /* __RGBSSE__ */ +#endif /* MAME_EMU_VIDEO_RGBSSE_H */ diff --git a/src/emu/video/rgbvmx.cpp b/src/emu/video/rgbvmx.cpp index e7c035fa53c..5673e82a7bf 100644 --- a/src/emu/video/rgbvmx.cpp +++ b/src/emu/video/rgbvmx.cpp @@ -164,7 +164,7 @@ const rgbaint_t::VECS16 rgbaint_t::scale_table[256] = { HIGHER LEVEL OPERATIONS ***************************************************************************/ -void rgbaint_t::blend(const rgbaint_t& other, uint8_t factor) +void rgbaint_t::blend(const rgbaint_t& other, u8 factor) { const VECU32 shift = vec_splat_u32(-16); const VECS32 scale1 = { factor, factor, factor, factor }; @@ -189,7 +189,7 @@ void rgbaint_t::scale_and_clamp(const rgbaint_t& scale) clamp_to_uint8(); } -void rgbaint_t::scale_imm_and_clamp(const int32_t scale) +void rgbaint_t::scale_imm_and_clamp(const s32 scale) { mul_imm(scale); sra_imm(8); diff --git a/src/emu/video/rgbvmx.h b/src/emu/video/rgbvmx.h index 302e42af998..1686f0d0b6b 100644 --- a/src/emu/video/rgbvmx.h +++ b/src/emu/video/rgbvmx.h @@ -29,8 +29,8 @@ protected: public: rgbaint_t() { set(0, 0, 0, 0); } - explicit rgbaint_t(uint32_t rgba) { set(rgba); } - rgbaint_t(int32_t a, int32_t r, int32_t g, int32_t b) { set(a, r, g, b); } + explicit rgbaint_t(u32 rgba) { set(rgba); } + rgbaint_t(s32 a, s32 r, s32 g, s32 b) { set(a, r, g, b); } explicit rgbaint_t(const rgb_t& rgb) { set(rgb); } explicit rgbaint_t(VECS32 rgba) : m_value(rgba) { } @@ -39,7 +39,7 @@ public: void set(const rgbaint_t& other) { m_value = other.m_value; } - void set(uint32_t rgba) + void set(u32 rgba) { const VECU32 zero = { 0, 0, 0, 0 }; #ifdef __LITTLE_ENDIAN__ @@ -51,7 +51,7 @@ public: #endif } - void set(int32_t a, int32_t r, int32_t g, int32_t b) + void set(s32 a, s32 r, s32 g, s32 b) { #ifdef __LITTLE_ENDIAN__ const VECS32 result = { b, g, r, a }; @@ -77,7 +77,7 @@ public: { VECU32 temp = VECU32(vec_packs(m_value, m_value)); temp = VECU32(vec_packsu(VECS16(temp), VECS16(temp))); - uint32_t result; + u32 result; vec_ste(temp, 0, &result); return result; } @@ -86,38 +86,38 @@ public: { VECU32 temp = VECU32(vec_packs(m_value, m_value)); temp = VECU32(vec_packsu(VECS16(temp), VECS16(temp))); - uint32_t result; + u32 result; vec_ste(temp, 0, &result); return result; } - void set_a(const int32_t value) + void set_a(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = vec_perm(m_value, temp, alpha_perm); } - void set_r(const int32_t value) + void set_r(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = vec_perm(m_value, temp, red_perm); } - void set_g(const int32_t value) + void set_g(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = vec_perm(m_value, temp, green_perm); } - void set_b(const int32_t value) + void set_b(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = vec_perm(m_value, temp, blue_perm); } - uint8_t get_a() const + u8 get_a() const { - uint8_t result; + u8 result; #ifdef __LITTLE_ENDIAN__ vec_ste(vec_splat(VECU8(m_value), 12), 0, &result); #else @@ -126,9 +126,9 @@ public: return result; } - uint8_t get_r() const + u8 get_r() const { - uint8_t result; + u8 result; #ifdef __LITTLE_ENDIAN__ vec_ste(vec_splat(VECU8(m_value), 8), 0, &result); #else @@ -137,9 +137,9 @@ public: return result; } - uint8_t get_g() const + u8 get_g() const { - uint8_t result; + u8 result; #ifdef __LITTLE_ENDIAN__ vec_ste(vec_splat(VECU8(m_value), 4), 0, &result); #else @@ -148,9 +148,9 @@ public: return result; } - uint8_t get_b() const + u8 get_b() const { - uint8_t result; + u8 result; #ifdef __LITTLE_ENDIAN__ vec_ste(vec_splat(VECU8(m_value), 0), 0, &result); #else @@ -159,9 +159,9 @@ public: return result; } - int32_t get_a32() const + s32 get_a32() const { - int32_t result; + s32 result; #ifdef __LITTLE_ENDIAN__ vec_ste(vec_splat(m_value, 3), 0, &result); #else @@ -170,9 +170,9 @@ public: return result; } - int32_t get_r32() const + s32 get_r32() const { - int32_t result; + s32 result; #ifdef __LITTLE_ENDIAN__ vec_ste(vec_splat(m_value, 2), 0, &result); #else @@ -181,9 +181,9 @@ public: return result; } - int32_t get_g32() const + s32 get_g32() const { - int32_t result; + s32 result; #ifdef __LITTLE_ENDIAN__ vec_ste(vec_splat(m_value, 1), 0, &result); #else @@ -192,9 +192,9 @@ public: return result; } - int32_t get_b32() const + s32 get_b32() const { - int32_t result; + s32 result; #ifdef __LITTLE_ENDIAN__ vec_ste(vec_splat(m_value, 0), 0, &result); #else @@ -208,13 +208,13 @@ public: m_value = vec_add(m_value, color2.m_value); } - inline void add_imm(const int32_t imm) + inline void add_imm(const s32 imm) { const VECS32 temp = { imm, imm, imm, imm }; m_value = vec_add(m_value, temp); } - inline void add_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void add_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { #ifdef __LITTLE_ENDIAN__ const VECS32 temp = { b, g, r, a }; @@ -229,13 +229,13 @@ public: m_value = vec_sub(m_value, color2.m_value); } - inline void sub_imm(const int32_t imm) + inline void sub_imm(const s32 imm) { const VECS32 temp = { imm, imm, imm, imm }; m_value = vec_sub(m_value, temp); } - inline void sub_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void sub_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { #ifdef __LITTLE_ENDIAN__ const VECS32 temp = { b, g, r, a }; @@ -250,13 +250,13 @@ public: m_value = vec_sub(color2.m_value, m_value); } - inline void subr_imm(const int32_t imm) + inline void subr_imm(const s32 imm) { const VECS32 temp = { imm, imm, imm, imm }; m_value = vec_sub(temp, m_value); } - inline void subr_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void subr_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { #ifdef __LITTLE_ENDIAN__ const VECS32 temp = { b, g, r, a }; @@ -277,9 +277,9 @@ public: #endif } - inline void mul_imm(const int32_t imm) + inline void mul_imm(const s32 imm) { - const VECU32 value = { uint32_t(imm), uint32_t(imm), uint32_t(imm), uint32_t(imm) }; + const VECU32 value = { u32(imm), u32(imm), u32(imm), u32(imm) }; const VECU32 shift = vec_splat_u32(-16); const VECU32 temp = vec_msum(VECU16(m_value), VECU16(vec_rl(value, shift)), vec_splat_u32(0)); #ifdef __LITTLE_ENDIAN__ @@ -289,12 +289,12 @@ public: #endif } - inline void mul_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void mul_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { #ifdef __LITTLE_ENDIAN__ - const VECU32 value = { uint32_t(b), uint32_t(g), uint32_t(r), uint32_t(a) }; + const VECU32 value = { u32(b), u32(g), u32(r), u32(a) }; #else - const VECU32 value = { uint32_t(a), uint32_t(r), uint32_t(g), uint32_t(b) }; + const VECU32 value = { u32(a), u32(r), u32(g), u32(b) }; #endif const VECU32 shift = vec_splat_u32(-16); const VECU32 temp = vec_msum(VECU16(m_value), VECU16(vec_rl(value, shift)), vec_splat_u32(0)); @@ -311,7 +311,7 @@ public: m_value = vec_and(vec_sl(m_value, VECU32(shift.m_value)), vec_cmpgt(limit, VECU32(shift.m_value))); } - inline void shl_imm(const uint8_t shift) + inline void shl_imm(const u8 shift) { const VECU32 temp = { shift, shift, shift, shift }; m_value = vec_sl(m_value, temp); @@ -323,7 +323,7 @@ public: m_value = vec_and(vec_sr(m_value, VECU32(shift.m_value)), vec_cmpgt(limit, VECU32(shift.m_value))); } - inline void shr_imm(const uint8_t shift) + inline void shr_imm(const u8 shift) { const VECU32 temp = { shift, shift, shift, shift }; m_value = vec_sr(m_value, temp); @@ -335,7 +335,7 @@ public: m_value = vec_sra(m_value, vec_min(VECU32(shift.m_value), limit)); } - inline void sra_imm(const uint8_t shift) + inline void sra_imm(const u8 shift) { const VECU32 temp = { shift, shift, shift, shift }; m_value = vec_sra(m_value, temp); @@ -346,13 +346,13 @@ public: m_value = vec_or(m_value, color2.m_value); } - inline void or_imm(const int32_t value) + inline void or_imm(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = vec_or(m_value, temp); } - inline void or_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void or_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { #ifdef __LITTLE_ENDIAN__ const VECS32 temp = { b, g, r, a }; @@ -372,13 +372,13 @@ public: m_value = vec_andc(m_value, color.m_value); } - inline void and_imm(const int32_t value) + inline void and_imm(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = vec_and(m_value, temp); } - inline void and_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void and_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { #ifdef __LITTLE_ENDIAN__ const VECS32 temp = { b, g, r, a }; @@ -393,13 +393,13 @@ public: m_value = vec_xor(m_value, color2.m_value); } - inline void xor_imm(const int32_t value) + inline void xor_imm(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = vec_xor(m_value, temp); } - inline void xor_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void xor_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { #ifdef __LITTLE_ENDIAN__ const VECS32 temp = { b, g, r, a }; @@ -409,10 +409,10 @@ public: m_value = vec_xor(m_value, temp); } - inline void clamp_and_clear(const uint32_t sign) + inline void clamp_and_clear(const u32 sign) { const VECS32 vzero = { 0, 0, 0, 0 }; - VECS32 vsign = { int32_t(sign), int32_t(sign), int32_t(sign), int32_t(sign) }; + VECS32 vsign = { s32(sign), s32(sign), s32(sign), s32(sign) }; m_value = vec_and(m_value, vec_cmpeq(vec_and(m_value, vsign), vzero)); vsign = vec_nor(vec_sra(vsign, vec_splat_u32(1)), vzero); const VECS32 mask = VECS32(vec_cmpgt(m_value, vsign)); @@ -433,32 +433,32 @@ public: #endif } - inline void sign_extend(const uint32_t compare, const uint32_t sign) + inline void sign_extend(const u32 compare, const u32 sign) { - const VECS32 compare_vec = { int32_t(compare), int32_t(compare), int32_t(compare), int32_t(compare) }; + const VECS32 compare_vec = { s32(compare), s32(compare), s32(compare), s32(compare) }; const VECS32 compare_mask = VECS32(vec_cmpeq(vec_and(m_value, compare_vec), compare_vec)); - const VECS32 sign_vec = { int32_t(sign), int32_t(sign), int32_t(sign), int32_t(sign) }; + const VECS32 sign_vec = { s32(sign), s32(sign), s32(sign), s32(sign) }; m_value = vec_or(m_value, vec_and(sign_vec, compare_mask)); } - inline void min(const int32_t value) + inline void min(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = vec_min(m_value, temp); } - inline void max(const int32_t value) + inline void max(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = vec_max(m_value, temp); } - void blend(const rgbaint_t& other, uint8_t factor); + void blend(const rgbaint_t& other, u8 factor); void scale_and_clamp(const rgbaint_t& scale); - void scale_imm_and_clamp(const int32_t scale); + void scale_imm_and_clamp(const s32 scale); - void scale_imm_add_and_clamp(const int32_t scale, const rgbaint_t& other) + void scale_imm_add_and_clamp(const s32 scale, const rgbaint_t& other) { mul_imm(scale); sra_imm(8); @@ -490,13 +490,13 @@ public: m_value = VECS32(vec_cmpeq(m_value, value.m_value)); } - inline void cmpeq_imm(const int32_t value) + inline void cmpeq_imm(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = VECS32(vec_cmpeq(m_value, temp)); } - inline void cmpeq_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void cmpeq_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { #ifdef __LITTLE_ENDIAN__ const VECS32 temp = { b, g, r, a }; @@ -511,13 +511,13 @@ public: m_value = VECS32(vec_cmpgt(m_value, value.m_value)); } - inline void cmpgt_imm(const int32_t value) + inline void cmpgt_imm(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = VECS32(vec_cmpgt(m_value, temp)); } - inline void cmpgt_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void cmpgt_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { #ifdef __LITTLE_ENDIAN__ const VECS32 temp = { b, g, r, a }; @@ -532,13 +532,13 @@ public: m_value = VECS32(vec_cmplt(m_value, value.m_value)); } - inline void cmplt_imm(const int32_t value) + inline void cmplt_imm(const s32 value) { const VECS32 temp = { value, value, value, value }; m_value = VECS32(vec_cmplt(m_value, temp)); } - inline void cmplt_imm_rgba(const int32_t a, const int32_t r, const int32_t g, const int32_t b) + inline void cmplt_imm_rgba(const s32 a, const s32 r, const s32 g, const s32 b) { #ifdef __LITTLE_ENDIAN__ const VECS32 temp = { b, g, r, a }; @@ -554,7 +554,7 @@ public: return *this; } - inline rgbaint_t& operator+=(const int32_t other) + inline rgbaint_t& operator+=(const s32 other) { const VECS32 temp = { other, other, other, other }; m_value = vec_add(m_value, temp); @@ -579,7 +579,7 @@ public: return *this; } - inline rgbaint_t& operator*=(const int32_t other) + inline rgbaint_t& operator*=(const s32 other) { const VECS32 value = { other, other, other, other }; const VECU32 shift = vec_splat_u32(-16); @@ -592,9 +592,9 @@ public: return *this; } - inline rgbaint_t& operator>>=(const int32_t shift) + inline rgbaint_t& operator>>=(const s32 shift) { - const VECU32 temp = { uint32_t(shift), uint32_t(shift), uint32_t(shift), uint32_t(shift) }; + const VECU32 temp = { u32(shift), u32(shift), u32(shift), u32(shift) }; m_value = vec_sra(m_value, temp); return *this; } @@ -604,7 +604,7 @@ public: m_value = vec_perm(m_value, alpha.m_value, alpha_perm); } - static uint32_t bilinear_filter(const uint32_t &rgb00, const uint32_t &rgb01, const uint32_t &rgb10, const uint32_t &rgb11, uint8_t u, uint8_t v) + static u32 bilinear_filter(const u32 &rgb00, const u32 &rgb01, const u32 &rgb10, const u32 &rgb11, u8 u, u8 v) { const VECS32 zero = vec_splat_s32(0); @@ -642,12 +642,12 @@ public: color01 = VECS32(vec_packs(color01, color01)); color01 = VECS32(vec_packsu(VECS16(color01), VECS16(color01))); - uint32_t result; + u32 result; vec_ste(VECU32(color01), 0, &result); return result; } - void bilinear_filter_rgbaint(const uint32_t &rgb00, const uint32_t &rgb01, const uint32_t &rgb10, const uint32_t &rgb11, uint8_t u, uint8_t v) + void bilinear_filter_rgbaint(const u32 &rgb00, const u32 &rgb01, const u32 &rgb10, const u32 &rgb11, u8 u, u8 v) { const VECS32 zero = vec_splat_s32(0); diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index 274125b7775..6de0335fa77 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -428,9 +428,9 @@ T lua_engine::region_read(memory_region ®ion, offs_t address) continue; mem_content <<= 8; if(region.endianness() == ENDIANNESS_BIG) - mem_content |= region.u8((BYTE8_XOR_BE(addr) & lowmask) | (addr & ~lowmask)); + mem_content |= region.as_u8((BYTE8_XOR_BE(addr) & lowmask) | (addr & ~lowmask)); else - mem_content |= region.u8((BYTE8_XOR_LE(addr) & lowmask) | (addr & ~lowmask)); + mem_content |= region.as_u8((BYTE8_XOR_LE(addr) & lowmask) | (addr & ~lowmask)); } return mem_content; diff --git a/src/frontend/mame/ui/auditmenu.cpp b/src/frontend/mame/ui/auditmenu.cpp index c76d43da8db..9fbccdf55eb 100644 --- a/src/frontend/mame/ui/auditmenu.cpp +++ b/src/frontend/mame/ui/auditmenu.cpp @@ -166,7 +166,7 @@ void menu_audit::handle() // populate //------------------------------------------------- -void menu_audit::populate() +void menu_audit::populate(float &customtop, float &custombottom) { item_append("Dummy", "", 0, (void *)(uintptr_t)1); } diff --git a/src/frontend/mame/ui/auditmenu.h b/src/frontend/mame/ui/auditmenu.h index 4f630792023..aadebcbac9f 100644 --- a/src/frontend/mame/ui/auditmenu.h +++ b/src/frontend/mame/ui/auditmenu.h @@ -28,7 +28,7 @@ public: virtual ~menu_audit() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; void save_available_machines(); diff --git a/src/frontend/mame/ui/barcode.cpp b/src/frontend/mame/ui/barcode.cpp index 1c62f42a92b..7945e70fd07 100644 --- a/src/frontend/mame/ui/barcode.cpp +++ b/src/frontend/mame/ui/barcode.cpp @@ -50,7 +50,7 @@ menu_barcode_reader::~menu_barcode_reader() // populate - populates the barcode input menu //------------------------------------------------- -void menu_barcode_reader::populate() +void menu_barcode_reader::populate(float &customtop, float &custombottom) { if (current_device()) { @@ -89,8 +89,7 @@ void menu_barcode_reader::populate() void menu_barcode_reader::handle() { // rebuild the menu (so to update the selected device, if the user has pressed L or R) - reset(reset_options::REMEMBER_POSITION); - populate(); + repopulate(reset_options::REMEMBER_POSITION); // process the menu const event *event = process(PROCESS_LR_REPEAT); diff --git a/src/frontend/mame/ui/barcode.h b/src/frontend/mame/ui/barcode.h index b5573b4b3b5..7f48d4f78ed 100644 --- a/src/frontend/mame/ui/barcode.h +++ b/src/frontend/mame/ui/barcode.h @@ -8,11 +8,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_BARCODE_H #define MAME_FRONTEND_UI_BARCODE_H +#pragma once + #include "machine/bcreader.h" #include "ui/devctrl.h" @@ -23,7 +23,7 @@ public: virtual ~menu_barcode_reader() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; std::string m_barcode_buffer; diff --git a/src/frontend/mame/ui/cheatopt.cpp b/src/frontend/mame/ui/cheatopt.cpp index d04b4e2e289..0e911aa0972 100644 --- a/src/frontend/mame/ui/cheatopt.cpp +++ b/src/frontend/mame/ui/cheatopt.cpp @@ -126,7 +126,7 @@ menu_cheat::menu_cheat(mame_ui_manager &mui, render_container &container) : menu { } -void menu_cheat::populate() +void menu_cheat::populate(float &customtop, float &custombottom) { /* iterate over cheats */ std::string text; @@ -264,7 +264,7 @@ void menu_autofire::handle() menu -------------------------------------------------*/ -void menu_autofire::populate() +void menu_autofire::populate(float &customtop, float &custombottom) { char temp_text[64]; diff --git a/src/frontend/mame/ui/cheatopt.h b/src/frontend/mame/ui/cheatopt.h index 7c0b8973587..e95e765cb30 100644 --- a/src/frontend/mame/ui/cheatopt.h +++ b/src/frontend/mame/ui/cheatopt.h @@ -23,7 +23,7 @@ public: virtual ~menu_cheat() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; @@ -35,7 +35,7 @@ public: virtual ~menu_autofire() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; float refresh; diff --git a/src/frontend/mame/ui/custmenu.cpp b/src/frontend/mame/ui/custmenu.cpp index 4f91d8f2ebc..bdb6b5c9f9f 100644 --- a/src/frontend/mame/ui/custmenu.cpp +++ b/src/frontend/mame/ui/custmenu.cpp @@ -152,7 +152,7 @@ void menu_custom_filter::handle() //------------------------------------------------- // populate //------------------------------------------------- -void menu_custom_filter::populate() +void menu_custom_filter::populate(float &customtop, float &custombottom) { // add main filter uint32_t arrow_flags = get_arrow_flags(FILTER_ALL, FILTER_UNAVAILABLE, custfltr::main); @@ -439,7 +439,7 @@ void menu_swcustom_filter::handle() //------------------------------------------------- // populate //------------------------------------------------- -void menu_swcustom_filter::populate() +void menu_swcustom_filter::populate(float &customtop, float &custombottom) { // add main filter uint32_t arrow_flags = get_arrow_flags(UI_SW_ALL, UI_SW_UNAVAILABLE, sw_custfltr::main); diff --git a/src/frontend/mame/ui/custmenu.h b/src/frontend/mame/ui/custmenu.h index 8fef83c0cac..77a470cf621 100644 --- a/src/frontend/mame/ui/custmenu.h +++ b/src/frontend/mame/ui/custmenu.h @@ -95,7 +95,7 @@ private: OTHER_FILTER = LIST_FILTER + MAX_CUST_FILTER + 1 }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; void save_sw_custom_filters(); @@ -128,7 +128,7 @@ private: SCREEN_FILTER = YEAR_FILTER + MAX_CUST_FILTER + 1, OTHER_FILTER = SCREEN_FILTER + MAX_CUST_FILTER + 1 }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; void save_custom_filters(); diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp index 8aef30cc083..17a5c22539b 100644 --- a/src/frontend/mame/ui/custui.cpp +++ b/src/frontend/mame/ui/custui.cpp @@ -137,7 +137,7 @@ void menu_custom_ui::handle() // populate //------------------------------------------------- -void menu_custom_ui::populate() +void menu_custom_ui::populate(float &customtop, float &custombottom) { uint32_t arrow_flags; item_append(_("Fonts"), "", 0, (void *)(uintptr_t)FONT_MENU); @@ -338,7 +338,7 @@ void menu_font_ui::handle() // populate //------------------------------------------------- -void menu_font_ui::populate() +void menu_font_ui::populate(float &customtop, float &custombottom) { // set filter arrow uint32_t arrow_flags; @@ -485,7 +485,7 @@ void menu_colors_ui::handle() if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) { if ((uintptr_t)menu_event->itemref != MUI_RESTORE) - menu::stack_push(ui(), container(), &m_color_table[(uintptr_t)menu_event->itemref].color, item[selected].text); + menu::stack_push(ui(), container(), &m_color_table[(uintptr_t)menu_event->itemref].color, selected_item().text); else { changed = true; @@ -501,7 +501,7 @@ void menu_colors_ui::handle() // populate //------------------------------------------------- -void menu_colors_ui::populate() +void menu_colors_ui::populate(float &customtop, float &custombottom) { item_append(_("Normal text"), "", 0, (void *)(uintptr_t)MUI_TEXT_COLOR); item_append(_("Selected color"), "", 0, (void *)(uintptr_t)MUI_SELECTED_COLOR); @@ -824,7 +824,7 @@ void menu_rgb_ui::handle() // populate //------------------------------------------------- -void menu_rgb_ui::populate() +void menu_rgb_ui::populate(float &customtop, float &custombottom) { // set filter arrow uint32_t arrow_flags = FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; @@ -1024,7 +1024,7 @@ void menu_palette_sel::handle() { if (menu_event->iptkey == IPT_UI_SELECT) { - m_original = rgb_t((uint32_t)strtoul(item[selected].subtext.c_str(), nullptr, 16)); + m_original = rgb_t(uint32_t(strtoul(selected_item().subtext.c_str(), nullptr, 16))); reset_parent(reset_options::SELECT_FIRST); stack_pop(); } @@ -1035,7 +1035,7 @@ void menu_palette_sel::handle() // populate //------------------------------------------------- -void menu_palette_sel::populate() +void menu_palette_sel::populate(float &customtop, float &custombottom) { for (unsigned x = 0; x < ARRAY_LENGTH(s_palette); ++x) item_append(_(s_palette[x].first), s_palette[x].second, 0, (void *)(uintptr_t)(x + 1)); @@ -1060,19 +1060,18 @@ void menu_palette_sel::draw(uint32_t flags) auto line_height = ui().get_line_height(); auto lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect(); auto ud_arrow_width = line_height * machine().render().ui_aspect(); - auto gutter_width = lr_arrow_width * 1.3f; - int itemnum, linenum; + float const gutter_width = lr_arrow_width * 1.3f; if (&machine().system() == &GAME_NAME(___empty)) draw_background(); // compute the width and height of the full menu - auto visible_width = 0.0f; - auto visible_main_menu_height = 0.0f; - for (auto & pitem : item) + float visible_width = 0.0f; + float visible_main_menu_height = 0.0f; + for (auto &pitem : item) { // compute width of left hand side - auto total_width = gutter_width + ui().get_string_width(pitem.text.c_str()) + gutter_width; + float total_width = gutter_width + ui().get_string_width(pitem.text.c_str()) + gutter_width; // add in width of right hand side if (!pitem.subtext.empty()) @@ -1087,7 +1086,7 @@ void menu_palette_sel::draw(uint32_t flags) } // account for extra space at the top and bottom - auto visible_extra_menu_height = customtop + custombottom; + float const visible_extra_menu_height = get_customtop() + get_custombottom(); // add a little bit of slop for rounding visible_width += 0.01f; @@ -1109,17 +1108,17 @@ void menu_palette_sel::draw(uint32_t flags) float visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f; // if the menu is at the bottom of the extra, adjust - visible_top += customtop; + visible_top += get_customtop(); // first add us a box - float x1 = visible_left - UI_BOX_LR_BORDER; - float y1 = visible_top - UI_BOX_TB_BORDER; - float x2 = visible_left + visible_width + UI_BOX_LR_BORDER; - float y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER; + float const x1 = visible_left - UI_BOX_LR_BORDER; + float const y1 = visible_top - UI_BOX_TB_BORDER; + float const x2 = visible_left + visible_width + UI_BOX_LR_BORDER; + float const y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER; ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); // determine the first visible line based on the current selection - int top_line = selected - visible_lines / 2; + int top_line = selected_index() - visible_lines / 2; if (top_line < 0) top_line = 0; if (top_line + visible_lines >= item.size()) @@ -1130,43 +1129,37 @@ void menu_palette_sel::draw(uint32_t flags) float effective_left = visible_left + gutter_width; // locate mouse - mouse_hit = false; - mouse_button = false; - mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button); - if (mouse_target != nullptr) - if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, container(), mouse_x, mouse_y)) - mouse_hit = true; + map_mouse(); // loop over visible lines hover = item.size() + 1; - float line_x0 = x1 + 0.5f * UI_LINE_WIDTH; - float line_x1 = x2 - 0.5f * UI_LINE_WIDTH; + float const line_x0 = x1 + 0.5f * UI_LINE_WIDTH; + float const line_x1 = x2 - 0.5f * UI_LINE_WIDTH; - for (linenum = 0; linenum < visible_lines; linenum++) + for (int linenum = 0; linenum < visible_lines; linenum++) { - float line_y = visible_top + (float)linenum * line_height; - itemnum = top_line + linenum; - const menu_item &pitem = item[itemnum]; - const char *itemtext = pitem.text.c_str(); - rgb_t fgcolor = UI_TEXT_COLOR; - rgb_t bgcolor = UI_TEXT_BG_COLOR; - float line_y0 = line_y; - float line_y1 = line_y + line_height; + float const line_y = visible_top + float(linenum) * line_height; + int const itemnum = top_line + linenum; + menu_item const &pitem = item[itemnum]; + char const *const itemtext = pitem.text.c_str(); + float const line_y0 = line_y; + float const line_y1 = line_y + line_height; // set the hover if this is our item - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) + if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem)) hover = itemnum; - // if we're selected, draw with a different background - if (itemnum == selected) + rgb_t fgcolor = UI_TEXT_COLOR; + rgb_t bgcolor = UI_TEXT_BG_COLOR; + if (is_selected(itemnum)) { + // if we're selected, draw with a different background fgcolor = UI_SELECTED_COLOR; bgcolor = UI_SELECTED_BG_COLOR; } - - // else if the mouse is over this item, draw with a different background else if (itemnum == hover) { + // else if the mouse is over this item, draw with a different background fgcolor = UI_MOUSEOVER_COLOR; bgcolor = UI_MOUSEOVER_BG_COLOR; } @@ -1175,46 +1168,46 @@ void menu_palette_sel::draw(uint32_t flags) if (bgcolor != UI_TEXT_BG_COLOR) highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); - // if we're on the top line, display the up arrow if (linenum == 0 && top_line != 0) { + // if we're on the top line, display the up arrow draw_arrow( - 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, - line_y + 0.25f * line_height, - 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, - line_y + 0.75f * line_height, - fgcolor, - ROT0); + 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, + line_y + 0.25f * line_height, + 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, + line_y + 0.75f * line_height, + fgcolor, + ROT0); if (hover == itemnum) hover = HOVER_ARROW_UP; } - - // if we're on the bottom line, display the down arrow else if (linenum == visible_lines - 1 && itemnum != item.size() - 1) { + // if we're on the bottom line, display the down arrow draw_arrow( - 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, - line_y + 0.25f * line_height, - 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, - line_y + 0.75f * line_height, - fgcolor, - ROT0 ^ ORIENTATION_FLIP_Y); + 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, + line_y + 0.25f * line_height, + 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, + line_y + 0.75f * line_height, + fgcolor, + ROT0 ^ ORIENTATION_FLIP_Y); if (hover == itemnum) hover = HOVER_ARROW_DOWN; } - - // if we're just a divider, draw a line else if (pitem.type == menu_item_type::SEPARATOR) + { + // if we're just a divider, draw a line container().add_line(visible_left, line_y + 0.5f * line_height, visible_left + visible_width, line_y + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - - // if we don't have a subitem, just draw the string centered + } else if (pitem.subtext.empty()) + { + // if we don't have a subitem, just draw the string centered ui().draw_text_full(container(), itemtext, effective_left, line_y, effective_width, - ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr); - - // otherwise, draw the item on the left and the subitem text on the right + ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr); + } else { + // otherwise, draw the item on the left and the subitem text on the right const char *subitem_text = pitem.subtext.c_str(); rgb_t color = rgb_t((uint32_t)strtoul(subitem_text, nullptr, 16)); @@ -1231,7 +1224,7 @@ void menu_palette_sel::draw(uint32_t flags) } // if there is something special to add, do it by calling the virtual method - custom_render(get_selection_ref(), customtop, custombottom, x1, y1, x2, y2); + custom_render(get_selection_ref(), get_customtop(), get_custombottom(), x1, y1, x2, y2); // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow m_visible_items = visible_lines - (top_line != 0) - (top_line + visible_lines != item.size()); diff --git a/src/frontend/mame/ui/custui.h b/src/frontend/mame/ui/custui.h index ed4ebc12585..a7ac84680d5 100644 --- a/src/frontend/mame/ui/custui.h +++ b/src/frontend/mame/ui/custui.h @@ -8,11 +8,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_CUSTUI_H #define MAME_FRONTEND_UI_CUSTUI_H +#pragma once + #include "ui/menu.h" namespace ui { @@ -38,7 +38,7 @@ private: HIDE_MENU }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; static const char *const HIDE_STATUS[]; @@ -70,7 +70,7 @@ private: MUI_ITALIC }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; void list(); @@ -126,7 +126,7 @@ private: const char *option; }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; s_color_table m_color_table[MUI_RESTORE]; @@ -156,7 +156,7 @@ private: PALETTE_CHOOSE }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; void inkey_special(const event *menu_event); @@ -185,7 +185,7 @@ private: // draw palette menu virtual void draw(uint32_t flags) override; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; static std::pair const s_palette[]; diff --git a/src/frontend/mame/ui/datmenu.cpp b/src/frontend/mame/ui/datmenu.cpp index bd4e7a72865..e8bb21d1f3a 100644 --- a/src/frontend/mame/ui/datmenu.cpp +++ b/src/frontend/mame/ui/datmenu.cpp @@ -126,7 +126,7 @@ void menu_dats_view::handle() // populate //------------------------------------------------- -void menu_dats_view::populate() +void menu_dats_view::populate(float &customtop, float &custombottom) { bool paused = machine().paused(); if (!paused) @@ -151,7 +151,6 @@ void menu_dats_view::draw(uint32_t flags) auto line_height = ui().get_line_height(); auto ud_arrow_width = line_height * machine().render().ui_aspect(); auto gutter_width = 0.52f * line_height * machine().render().ui_aspect(); - mouse_x = -1, mouse_y = -1; float visible_width = 1.0f - 2.0f * UI_BOX_LR_BORDER; float visible_left = (1.0f - visible_width) * 0.5f; @@ -160,15 +159,10 @@ void menu_dats_view::draw(uint32_t flags) hover = item.size() + 1; visible_items = item.size() - 2; float extra_height = 2.0f * line_height; - float visible_extra_menu_height = customtop + custombottom + extra_height; + float visible_extra_menu_height = get_customtop() + get_custombottom() + extra_height; // locate mouse - mouse_hit = false; - mouse_button = false; - mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button); - if (mouse_target != nullptr) - if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, container(), mouse_x, mouse_y)) - mouse_hit = true; + map_mouse(); // account for extra space at the top and bottom float visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height; @@ -179,7 +173,7 @@ void menu_dats_view::draw(uint32_t flags) float visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f; // if the menu is at the bottom of the extra, adjust - visible_top += customtop; + visible_top += get_customtop(); // compute left box size float x1 = visible_left; @@ -216,30 +210,31 @@ void menu_dats_view::draw(uint32_t flags) // if we're on the top line, display the up arrow if (linenum == 0 && top_line != 0) { - draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height, - 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0); - - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y) + if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1)) { fgcolor = UI_MOUSEOVER_COLOR; bgcolor = UI_MOUSEOVER_BG_COLOR; highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); hover = HOVER_ARROW_UP; } + + draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height, + 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0); + } // if we're on the bottom line, display the down arrow else if (linenum == m_visible_lines - 1 && itemnum != visible_items - 1) { - draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height, - 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0 ^ ORIENTATION_FLIP_Y); - - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y) + if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1)) { fgcolor = UI_MOUSEOVER_COLOR; bgcolor = UI_MOUSEOVER_BG_COLOR; highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); hover = HOVER_ARROW_DOWN; } + + draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height, + 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0 ^ ORIENTATION_FLIP_Y); } // draw dats text @@ -261,7 +256,7 @@ void menu_dats_view::draw(uint32_t flags) rgb_t fgcolor = UI_SELECTED_COLOR; rgb_t bgcolor = UI_SELECTED_BG_COLOR; - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) + if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem)) hover = count; if (pitem.type == menu_item_type::SEPARATOR) @@ -277,7 +272,7 @@ void menu_dats_view::draw(uint32_t flags) } // if there is something special to add, do it by calling the virtual method - custom_render(get_selection_ref(), customtop, custombottom, x1, y1, x2, y2); + custom_render(get_selection_ref(), get_customtop(), get_custombottom(), x1, y1, x2, y2); // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow m_visible_items = m_visible_lines - (top_line != 0) - (top_line + m_visible_lines != visible_items); diff --git a/src/frontend/mame/ui/datmenu.h b/src/frontend/mame/ui/datmenu.h index ed16d276d3d..f12cd61e67d 100644 --- a/src/frontend/mame/ui/datmenu.h +++ b/src/frontend/mame/ui/datmenu.h @@ -9,11 +9,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_DATMENU_H #define MAME_FRONTEND_UI_DATMENU_H +#pragma once + #include "ui/menu.h" #include @@ -23,6 +23,7 @@ struct ui_software_info; namespace ui { + //------------------------------------------------- // class dats menu //------------------------------------------------- @@ -41,7 +42,7 @@ private: // draw dats menu virtual void draw(uint32_t flags) override; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; int visible_items; diff --git a/src/frontend/mame/ui/devopt.cpp b/src/frontend/mame/ui/devopt.cpp index 120ff1d774e..1d7f81036d6 100644 --- a/src/frontend/mame/ui/devopt.cpp +++ b/src/frontend/mame/ui/devopt.cpp @@ -26,7 +26,7 @@ menu_device_config::menu_device_config(mame_ui_manager &mui, render_container &c m_mounted = slot->device().subdevice(option->name()) != nullptr; } -void menu_device_config::populate() +void menu_device_config::populate(float &customtop, float &custombottom) { std::ostringstream str; device_t *dev; diff --git a/src/frontend/mame/ui/devopt.h b/src/frontend/mame/ui/devopt.h index bf6835f9df0..1bd3fafb627 100644 --- a/src/frontend/mame/ui/devopt.h +++ b/src/frontend/mame/ui/devopt.h @@ -23,7 +23,7 @@ public: virtual ~menu_device_config() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; device_slot_interface *m_owner; diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp index ed91853c5cf..1ef39925bfd 100644 --- a/src/frontend/mame/ui/dirmenu.cpp +++ b/src/frontend/mame/ui/dirmenu.cpp @@ -91,14 +91,14 @@ void menu_directory::handle() const event *menu_event = process(0); if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) - menu::stack_push(ui(), container(), selected); + menu::stack_push(ui(), container(), selected_index()); } //------------------------------------------------- // populate //------------------------------------------------- -void menu_directory::populate() +void menu_directory::populate(float &customtop, float &custombottom) { for (auto & elem : s_folders) item_append(_(elem.name), "", 0, (void *)(uintptr_t)elem.action); @@ -181,7 +181,7 @@ void menu_display_actual::handle() // populate //------------------------------------------------- -void menu_display_actual::populate() +void menu_display_actual::populate(float &customtop, float &custombottom) { m_tempbuf = string_format(_("Current %1$s Folders"), _(s_folders[m_ref].name)); if (ui().options().exists(s_folders[m_ref].option)) @@ -391,7 +391,7 @@ void menu_add_change_folder::handle() // check for entries which matches our search buffer if (update_selected) { - const int cur_selected = selected; + const int cur_selected = selected_index(); int entry, bestmatch = 0; // from current item to the end @@ -446,7 +446,7 @@ void menu_add_change_folder::handle() // populate //------------------------------------------------- -void menu_add_change_folder::populate() +void menu_add_change_folder::populate(float &customtop, float &custombottom) { // open a path const char *volume_name = nullptr; @@ -583,7 +583,7 @@ void menu_remove_folder::handle() if (menu_event != nullptr && menu_event->itemref != nullptr && menu_event->iptkey == IPT_UI_SELECT) { std::string tmppath, error_string; - m_folders.erase(m_folders.begin() + selected); + m_folders.erase(m_folders.begin() + selected_index()); for (int x = 0; x < m_folders.size(); ++x) { tmppath.append(m_folders[x]); @@ -608,7 +608,7 @@ void menu_remove_folder::handle() // populate menu //------------------------------------------------- -void menu_remove_folder::populate() +void menu_remove_folder::populate(float &customtop, float &custombottom) { int folders_count = 0; for (auto & elem : m_folders) diff --git a/src/frontend/mame/ui/dirmenu.h b/src/frontend/mame/ui/dirmenu.h index f23bcc44103..baff9bd1d52 100644 --- a/src/frontend/mame/ui/dirmenu.h +++ b/src/frontend/mame/ui/dirmenu.h @@ -33,7 +33,7 @@ protected: virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; @@ -57,7 +57,7 @@ private: REMOVE, }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; std::string m_tempbuf, m_searchpath; @@ -79,7 +79,7 @@ protected: virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; std::string m_searchpath; @@ -103,7 +103,7 @@ protected: virtual bool menu_has_search_active() override { return (m_search[0] != 0); } private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; int m_ref; diff --git a/src/frontend/mame/ui/filecreate.cpp b/src/frontend/mame/ui/filecreate.cpp index a1540e403a5..0cfef03b723 100644 --- a/src/frontend/mame/ui/filecreate.cpp +++ b/src/frontend/mame/ui/filecreate.cpp @@ -74,7 +74,7 @@ menu_confirm_save_as::~menu_confirm_save_as() // populate //------------------------------------------------- -void menu_confirm_save_as::populate() +void menu_confirm_save_as::populate(float &customtop, float &custombottom) { item_append(_("File Already Exists - Override?"), "", FLAG_DISABLE, nullptr); item_append(menu_item_type::SEPARATOR); @@ -152,7 +152,7 @@ void menu_file_create::custom_render(void *selectedref, float top, float bottom, // populate - populates the file creator menu //------------------------------------------------- -void menu_file_create::populate() +void menu_file_create::populate(float &customtop, float &custombottom) { std::string buffer; const image_device_format *format; @@ -261,7 +261,7 @@ menu_select_format::~menu_select_format() // populate //------------------------------------------------- -void menu_select_format::populate() +void menu_select_format::populate(float &customtop, float &custombottom) { item_append(_("Select image format"), "", FLAG_DISABLE, nullptr); for (int i = 0; i < m_total_usable; i++) diff --git a/src/frontend/mame/ui/filecreate.h b/src/frontend/mame/ui/filecreate.h index 9dfb50d7432..a97b4f53ef5 100644 --- a/src/frontend/mame/ui/filecreate.h +++ b/src/frontend/mame/ui/filecreate.h @@ -8,11 +8,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_FILECREATE_H #define MAME_FRONTEND_UI_FILECREATE_H +#pragma once + #include "ui/menu.h" class floppy_image_format_t; @@ -27,7 +27,7 @@ public: virtual ~menu_confirm_save_as() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; bool *m_yes; @@ -46,7 +46,7 @@ protected: virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; bool & m_ok; @@ -67,7 +67,7 @@ public: virtual ~menu_select_format() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; // internal state diff --git a/src/frontend/mame/ui/filemngr.cpp b/src/frontend/mame/ui/filemngr.cpp index a5ae3c84968..74916b46ac1 100644 --- a/src/frontend/mame/ui/filemngr.cpp +++ b/src/frontend/mame/ui/filemngr.cpp @@ -103,7 +103,7 @@ void menu_file_manager::fill_image_line(device_image_interface *img, std::string // populate //------------------------------------------------- -void menu_file_manager::populate() +void menu_file_manager::populate(float &customtop, float &custombottom) { std::string tmp_inst, tmp_name; bool first_entry = true; diff --git a/src/frontend/mame/ui/filemngr.h b/src/frontend/mame/ui/filemngr.h index 34cdb0a98ce..68da54f1d05 100644 --- a/src/frontend/mame/ui/filemngr.h +++ b/src/frontend/mame/ui/filemngr.h @@ -30,7 +30,7 @@ protected: virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; void fill_image_line(device_image_interface *img, std::string &instance, std::string &filename); diff --git a/src/frontend/mame/ui/filesel.cpp b/src/frontend/mame/ui/filesel.cpp index fe63b20d3a8..114fa317c74 100644 --- a/src/frontend/mame/ui/filesel.cpp +++ b/src/frontend/mame/ui/filesel.cpp @@ -89,8 +89,8 @@ void menu_file_selector::custom_render(void *selectedref, float top, float botto y1 += UI_BOX_TB_BORDER; size_t hit_start = 0, hit_span = 0; - if (mouse_hit - && layout.hit_test(mouse_x - x1, mouse_y - y1, hit_start, hit_span) + if (is_mouse_hit() + && layout.hit_test(get_mouse_x() - x1, get_mouse_y() - y1, hit_start, hit_span) && m_current_directory.substr(hit_start, hit_span) != PATH_SEPARATOR) { // we're hovering over a directory! highlight it @@ -288,7 +288,7 @@ void menu_file_selector::append_entry_menu_item(const file_selector_entry *entry // populate //------------------------------------------------- -void menu_file_selector::populate() +void menu_file_selector::populate(float &customtop, float &custombottom) { util::zippath_directory *directory = nullptr; osd_file::error err; @@ -507,7 +507,7 @@ menu_select_rw::~menu_select_rw() // populate //------------------------------------------------- -void menu_select_rw::populate() +void menu_select_rw::populate(float &customtop, float &custombottom) { item_append(_("Select access mode"), "", FLAG_DISABLE, nullptr); item_append(_("Read-only"), "", 0, itemref_from_result(result::READONLY)); diff --git a/src/frontend/mame/ui/filesel.h b/src/frontend/mame/ui/filesel.h index 7692a996124..a987e9f424b 100644 --- a/src/frontend/mame/ui/filesel.h +++ b/src/frontend/mame/ui/filesel.h @@ -8,11 +8,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_FILESEL_H #define MAME_FRONTEND_UI_FILESEL_H +#pragma once + #include "ui/menu.h" namespace ui { @@ -67,7 +67,7 @@ private: std::string m_hover_directory; std::string m_filename; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; // methods @@ -95,7 +95,7 @@ public: menu_select_rw(mame_ui_manager &mui, render_container &container, bool can_in_place, result &result); virtual ~menu_select_rw() override; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; static void *itemref_from_result(result result); diff --git a/src/frontend/mame/ui/imgcntrl.cpp b/src/frontend/mame/ui/imgcntrl.cpp index 7766099bf0f..793466f7d57 100644 --- a/src/frontend/mame/ui/imgcntrl.cpp +++ b/src/frontend/mame/ui/imgcntrl.cpp @@ -168,7 +168,7 @@ void menu_control_device_image::hook_load(const std::string &name) // populate //------------------------------------------------- -void menu_control_device_image::populate() +void menu_control_device_image::populate(float &customtop, float &custombottom) { } diff --git a/src/frontend/mame/ui/imgcntrl.h b/src/frontend/mame/ui/imgcntrl.h index 3b4188d65f3..a41a3f85f77 100644 --- a/src/frontend/mame/ui/imgcntrl.h +++ b/src/frontend/mame/ui/imgcntrl.h @@ -65,7 +65,7 @@ private: std::string m_software_info_name; // methods - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; void test_create(bool &can_create, bool &need_confirm); void load_software_part(); }; diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp index 69d47954558..9de81cef6ec 100644 --- a/src/frontend/mame/ui/info.cpp +++ b/src/frontend/mame/ui/info.cpp @@ -353,7 +353,7 @@ menu_game_info::~menu_game_info() { } -void menu_game_info::populate() +void menu_game_info::populate(float &customtop, float &custombottom) { std::string tempstring = ui().machine_info().game_info_string(); item_append(std::move(tempstring), "", FLAG_MULTILINE, nullptr); @@ -379,7 +379,7 @@ menu_image_info::~menu_image_info() { } -void menu_image_info::populate() +void menu_image_info::populate(float &customtop, float &custombottom) { item_append(machine().system().description, "", FLAG_DISABLE, nullptr); item_append("", "", FLAG_DISABLE, nullptr); diff --git a/src/frontend/mame/ui/info.h b/src/frontend/mame/ui/info.h index 51c81c807cd..21d920e4131 100644 --- a/src/frontend/mame/ui/info.h +++ b/src/frontend/mame/ui/info.h @@ -8,14 +8,15 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_INFO_H #define MAME_FRONTEND_UI_INFO_H +#pragma once + #include "ui/menu.h" namespace ui { + class machine_info { public: @@ -54,7 +55,7 @@ public: virtual ~menu_game_info() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; @@ -66,7 +67,7 @@ public: virtual ~menu_image_info() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; void image_info(device_image_interface *image); }; diff --git a/src/frontend/mame/ui/info_pty.cpp b/src/frontend/mame/ui/info_pty.cpp index cf7b6fb4f6f..7b85b090b10 100644 --- a/src/frontend/mame/ui/info_pty.cpp +++ b/src/frontend/mame/ui/info_pty.cpp @@ -23,7 +23,7 @@ menu_pty_info::~menu_pty_info() { } -void menu_pty_info::populate() +void menu_pty_info::populate(float &customtop, float &custombottom) { item_append(_("Pseudo terminals"), "", FLAG_DISABLE, nullptr); item_append("", "", FLAG_DISABLE, nullptr); diff --git a/src/frontend/mame/ui/info_pty.h b/src/frontend/mame/ui/info_pty.h index be112c003e4..55249a34d34 100644 --- a/src/frontend/mame/ui/info_pty.h +++ b/src/frontend/mame/ui/info_pty.h @@ -8,11 +8,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_INFO_PTY_H #define MAME_FRONTEND_UI_INFO_PTY_H +#pragma once + #include "ui/menu.h" namespace ui { @@ -23,7 +23,7 @@ public: virtual ~menu_pty_info() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp index c4071f503be..72568523e87 100644 --- a/src/frontend/mame/ui/inputmap.cpp +++ b/src/frontend/mame/ui/inputmap.cpp @@ -45,7 +45,7 @@ menu_input_groups::menu_input_groups(mame_ui_manager &mui, render_container &con { } -void menu_input_groups::populate() +void menu_input_groups::populate(float &customtop, float &custombottom) { int player; @@ -88,7 +88,7 @@ menu_input_general::menu_input_general(mame_ui_manager &mui, render_container &c group = _group; } -void menu_input_general::populate() +void menu_input_general::populate(float &customtop, float &custombottom) { input_item_data *itemlist = nullptr; int suborder[SEQ_TYPE_TOTAL]; @@ -151,7 +151,7 @@ menu_input_specific::menu_input_specific(mame_ui_manager &mui, render_container { } -void menu_input_specific::populate() +void menu_input_specific::populate(float &customtop, float &custombottom) { input_item_data *itemlist = nullptr; int suborder[SEQ_TYPE_TOTAL]; @@ -538,7 +538,7 @@ menu_settings::menu_settings(mame_ui_manager &mui, render_container &container, type = _type; } -void menu_settings::populate() +void menu_settings::populate(float &customtop, float &custombottom) { dip_descriptor **diplist_tailptr; std::string prev_owner; @@ -812,7 +812,7 @@ menu_analog::menu_analog(mame_ui_manager &mui, render_container &container) : me { } -void menu_analog::populate() +void menu_analog::populate(float &customtop, float &custombottom) { std::string prev_owner; bool first_entry = true; diff --git a/src/frontend/mame/ui/inputmap.h b/src/frontend/mame/ui/inputmap.h index b6934a1d4d6..5006cdffef2 100644 --- a/src/frontend/mame/ui/inputmap.h +++ b/src/frontend/mame/ui/inputmap.h @@ -8,11 +8,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_INPUTMAP_H #define MAME_FRONTEND_UI_INPUTMAP_H +#pragma once + #include "ui/menu.h" @@ -24,7 +24,7 @@ public: virtual ~menu_input_groups() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; @@ -83,7 +83,7 @@ public: virtual ~menu_input_general() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void update_input(struct input_item_data *seqchangeditem) override; int group; @@ -96,7 +96,7 @@ public: virtual ~menu_input_specific() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void update_input(struct input_item_data *seqchangeditem) override; }; @@ -121,7 +121,7 @@ protected: int type; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; @@ -169,7 +169,7 @@ private: int defvalue; }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; diff --git a/src/frontend/mame/ui/mainmenu.cpp b/src/frontend/mame/ui/mainmenu.cpp index 0b46e8fc2c7..bf796513e29 100644 --- a/src/frontend/mame/ui/mainmenu.cpp +++ b/src/frontend/mame/ui/mainmenu.cpp @@ -49,7 +49,7 @@ menu_main::menu_main(mame_ui_manager &mui, render_container &container) : menu(m { } -void menu_main::populate() +void menu_main::populate(float &customtop, float &custombottom) { /* add input menu items */ item_append(_("Input (general)"), "", 0, (void *)INPUT_GROUPS); diff --git a/src/frontend/mame/ui/mainmenu.h b/src/frontend/mame/ui/mainmenu.h index aab547e9d56..16ca2d1cde4 100644 --- a/src/frontend/mame/ui/mainmenu.h +++ b/src/frontend/mame/ui/mainmenu.h @@ -51,7 +51,7 @@ private: QUIT_GAME }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp index bac0b8a1c10..50703ac99e9 100644 --- a/src/frontend/mame/ui/menu.cpp +++ b/src/frontend/mame/ui/menu.cpp @@ -233,8 +233,14 @@ menu::menu(mame_ui_manager &mui, render_container &container) , m_parent() , m_event() , m_pool(nullptr) + , m_customtop(0.0f) + , m_custombottom(0.0f) , m_resetpos(0) , m_resetref(nullptr) + , m_mouse_hit(false) + , m_mouse_button(false) + , m_mouse_x(-1.0f) + , m_mouse_y(-1.0f) { assert(m_global_state); // not calling init is bad @@ -399,6 +405,17 @@ void menu::item_append(std::string &&text, std::string &&subtext, uint32_t flags } +//------------------------------------------------- +// repopulate - repopulate menu items +//------------------------------------------------- + +void menu::repopulate(reset_options options) +{ + reset(options); + populate(m_customtop, m_custombottom); +} + + //------------------------------------------------- // process - process a menu, drawing it // and returning any interesting events @@ -432,7 +449,7 @@ const menu::event *menu::process(uint32_t flags, float x0, float y0) // update the selected item in the event if ((m_event.iptkey != IPT_INVALID) && selection_valid()) { - m_event.itemref = item[selected].ref; + m_event.itemref = get_selection_ref(); m_event.type = item[selected].type; return &m_event; } @@ -541,7 +558,7 @@ void menu::draw(uint32_t flags) } // account for extra space at the top and bottom - float const visible_extra_menu_height = customtop + custombottom; + float const visible_extra_menu_height = m_customtop + m_custombottom; // add a little bit of slop for rounding visible_width += 0.01f; @@ -560,7 +577,7 @@ void menu::draw(uint32_t flags) // compute top/left of inner menu area by centering float const visible_left = (1.0f - visible_width) * 0.5f; - float const visible_top = ((1.0f - visible_main_menu_height - visible_extra_menu_height) * 0.5f) + customtop; + float const visible_top = ((1.0f - visible_main_menu_height - visible_extra_menu_height) * 0.5f) + m_customtop; // first add us a box float const x1 = visible_left - UI_BOX_LR_BORDER; @@ -574,7 +591,7 @@ void menu::draw(uint32_t flags) top_line = 0; if (selected >= (top_line + m_visible_lines)) top_line = selected - (m_visible_lines / 2); - if ((top_line > (item.size() - m_visible_lines)) || (selected == (item.size() - 1))) + if ((top_line > (item.size() - m_visible_lines)) || is_last_selected()) top_line = item.size() - m_visible_lines; // if scrolling, show arrows @@ -589,16 +606,10 @@ void menu::draw(uint32_t flags) float const effective_left = visible_left + gutter_width; // locate mouse - mouse_hit = false; - mouse_button = false; if (!customonly && !noinput) - { - int32_t mouse_target_x, mouse_target_y; - render_target *mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button); - if (mouse_target != nullptr) - if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, container(), mouse_x, mouse_y)) - mouse_hit = true; - } + map_mouse(); + else + ignore_mouse(); // loop over visible lines hover = item.size() + 1; @@ -620,11 +631,11 @@ void menu::draw(uint32_t flags) float const line_y1 = line_y0 + line_height; // set the hover if this is our item - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) + if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem)) hover = itemnum; // if we're selected, draw with a different background - if (itemnum == selected) + if (is_selected(itemnum)) { fgcolor = fgcolor2 = fgcolor3 = UI_SELECTED_COLOR; bgcolor = UI_SELECTED_BG_COLOR; @@ -702,7 +713,7 @@ void menu::draw(uint32_t flags) if (ui().get_string_width(subitem_text) > effective_width - item_width) { subitem_text = "..."; - if (itemnum == selected) + if (is_selected(itemnum)) selected_subitem_too_big = true; } @@ -721,7 +732,7 @@ void menu::draw(uint32_t flags) ui::text_layout::RIGHT, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, subitem_invert ? fgcolor3 : fgcolor2, bgcolor, &subitem_width, nullptr); // apply arrows - if (itemnum == selected && (pitem.flags & FLAG_LEFT_ARROW)) + if (is_selected(itemnum) && (pitem.flags & FLAG_LEFT_ARROW)) { draw_arrow( effective_left + effective_width - subitem_width - gutter_width, @@ -731,7 +742,7 @@ void menu::draw(uint32_t flags) fgcolor, ROT90 ^ ORIENTATION_FLIP_X); } - if (itemnum == selected && (pitem.flags & FLAG_RIGHT_ARROW)) + if (is_selected(itemnum) && (pitem.flags & FLAG_RIGHT_ARROW)) { draw_arrow( effective_left + effective_width + gutter_width - lr_arrow_width, @@ -748,7 +759,7 @@ void menu::draw(uint32_t flags) // if the selected subitem is too big, display it in a separate offset box if (selected_subitem_too_big) { - menu_item const &pitem = item[selected]; + menu_item const &pitem = selected_item(); bool const subitem_invert(pitem.flags & FLAG_INVERT); auto const linenum = selected - top_line; float const line_y = visible_top + (float)linenum * line_height; @@ -776,7 +787,7 @@ void menu::draw(uint32_t flags) } // if there is something special to add, do it by calling the virtual method - custom_render(get_selection_ref(), customtop, custombottom, x1, y1, x2, y2); + custom_render(get_selection_ref(), m_customtop, m_custombottom, x1, y1, x2, y2); } void menu::custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) @@ -848,6 +859,38 @@ void menu::draw_text_box() } +//------------------------------------------------- +// map_mouse - map mouse pointer location to menu +// coordinates +//------------------------------------------------- + +void menu::map_mouse() +{ + ignore_mouse(); + int32_t mouse_target_x, mouse_target_y; + render_target *const mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &m_mouse_button); + if (mouse_target) + { + if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, container(), m_mouse_x, m_mouse_y)) + m_mouse_hit = true; + } +} + + +//------------------------------------------------- +// ignore_mouse - set members to ignore mouse +// input +//------------------------------------------------- + +void menu::ignore_mouse() +{ + m_mouse_hit = false; + m_mouse_button = false; + m_mouse_x = -1.0f; + m_mouse_y = -1.0f; +} + + //------------------------------------------------- // handle_events - generically handle // input events for a menu @@ -891,7 +934,7 @@ void menu::handle_events(uint32_t flags, event &ev) top_line += m_visible_lines - 2; return; } - selected += m_visible_lines - 2 + (selected == 0); + selected += m_visible_lines - 2 + is_first_selected(); if (selected > item.size() - 1) selected = item.size() - 1; top_line += m_visible_lines - 2; @@ -1003,8 +1046,8 @@ void menu::handle_keys(uint32_t flags, int &iptkey) validate_selection(1); // swallow left/right keys if they are not appropriate - bool ignoreleft = ((item[selected].flags & FLAG_LEFT_ARROW) == 0); - bool ignoreright = ((item[selected].flags & FLAG_RIGHT_ARROW) == 0); + bool ignoreleft = ((selected_item().flags & FLAG_LEFT_ARROW) == 0); + bool ignoreright = ((selected_item().flags & FLAG_RIGHT_ARROW) == 0); if ((item[0].flags & FLAG_UI_DATS)) ignoreleft = ignoreright = false; @@ -1058,7 +1101,7 @@ void menu::handle_keys(uint32_t flags, int &iptkey) // page down advances by m_visible_items if (exclusive_input_pressed(iptkey, IPT_UI_PAGE_DOWN, 6)) { - selected += m_visible_lines - 2 + (selected == 0); + selected += m_visible_lines - 2 + is_first_selected(); top_line += m_visible_lines - 2; if (selected > item.size() - 1) @@ -1135,7 +1178,7 @@ void menu::validate_selection(int scandir) void menu::do_handle() { if (item.size() < 2) - populate(); + populate(m_customtop, m_custombottom); handle(); } diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h index 554a70fddd2..a4e4d8a7c26 100644 --- a/src/frontend/mame/ui/menu.h +++ b/src/frontend/mame/ui/menu.h @@ -50,11 +50,6 @@ public: virtual ~menu(); - int hover; // which item is being hovered over - float customtop; // amount of extra height to add at the top - float custombottom; // amount of extra height to add at the bottom - std::vector item; // array of items - // append a new item to the end of the menu void item_append(const std::string &text, const std::string &subtext, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN); void item_append(std::string &&text, std::string &&subtext, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN); @@ -99,13 +94,6 @@ private: virtual void draw(uint32_t flags); void draw_text_box(); -public: - // mouse handling - bool mouse_hit, mouse_button; - render_target *mouse_target; - int32_t mouse_target_x, mouse_target_y; - float mouse_x, mouse_y; - protected: using cleanup_callback = std::function; using bitmap_ptr = widgets_manager::bitmap_ptr; @@ -136,10 +124,13 @@ protected: void *itemref; // reference for the selected item menu_item_type type; // item type (eventually will go away when itemref is proper ui_menu_item class rather than void*) int iptkey; // one of the IPT_* values from inptport.h - char32_t unichar; // unicode character if iptkey == IPT_SPECIAL + char32_t unichar; // unicode character if iptkey == IPT_SPECIAL render_bounds mouse; // mouse position if iptkey == IPT_CUSTOM }; + int hover; // which item is being hovered over + std::vector item; // array of items + int top_line; // main box top line int l_sw_hover; int l_hover; @@ -170,13 +161,21 @@ protected: void add_cleanup_callback(cleanup_callback &&callback) { m_global_state->add_cleanup_callback(std::move(callback)); } + // repopulate the menu items + void repopulate(reset_options options); + // process a menu, drawing it and returning any interesting events const event *process(uint32_t flags, float x0 = 0.0f, float y0 = 0.0f); void process_parent() { m_parent->process(PROCESS_NOINPUT); } // retrieves the ref of the currently selected menu item or nullptr void *get_selection_ref() const { return selection_valid() ? item[selected].ref : nullptr; } + + menu_item &selected_item() { return item[selected]; } + menu_item const &selected_item() const { return item[selected]; } + int selected_index() const { return selected; } bool selection_valid() const { return (0 <= selected) && (item.size() > selected); } + bool is_selected(int index) const { return selection_valid() && (selected == index); } bool is_first_selected() const { return 0 == selected; } bool is_last_selected() const { return (item.size() - 1) == selected; } @@ -189,6 +188,10 @@ protected: // test if the given key is pressed and we haven't already reported a key bool exclusive_input_pressed(int &iptkey, int key, int repeat); + // layout + float get_customtop() const { return m_customtop; } + float get_custombottom() const { return m_custombottom; } + // highlight void highlight(float x0, float y0, float x1, float y1, rgb_t bgcolor); render_texture *hilight_main_texture() { return m_global_state->hilight_main_texture(); } @@ -206,6 +209,22 @@ protected: // configure the menu for custom rendering virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); + // map mouse to menu coordinates + void map_mouse(); + + // clear the mouse position + void ignore_mouse(); + + bool is_mouse_hit() const { return m_mouse_hit; } // is mouse pointer inside menu's render container? + float get_mouse_x() const { return m_mouse_x; } // mouse x location in menu coordinates + float get_mouse_y() const { return m_mouse_y; } // mouse y location in menu coordinates + + // mouse hit test - checks whether mouse_x is in [x0, x1) and mouse_y is in [y0, y1) + bool mouse_in_rect(float x0, float y0, float x1, float y1) const + { + return m_mouse_hit && (m_mouse_x >= x0) && (m_mouse_x < x1) && (m_mouse_y >= y0) && (m_mouse_y < y1); + } + // overridable event handling virtual void handle_events(uint32_t flags, event &ev); virtual void handle_keys(uint32_t flags, int &iptkey); @@ -221,13 +240,11 @@ protected: // get arrows status template - uint32_t get_arrow_flags(T min, T max, T actual) + static uint32_t get_arrow_flags(T min, T max, T actual) { return ((actual > min) ? FLAG_LEFT_ARROW : 0) | ((actual < max) ? FLAG_RIGHT_ARROW : 0); } - int right_visible_lines; // right box lines - private: class global_state : public widgets_manager { @@ -270,9 +287,9 @@ private: struct pool { - pool *next; // chain to next one - uint8_t *top; // top of the pool - uint8_t *end; // end of the pool + pool *next; // chain to next one + uint8_t *top; // top of the pool + uint8_t *end; // end of the pool }; // request the specific handling of the game selection main menu @@ -280,7 +297,7 @@ private: void set_special_main_menu(bool disable); // To be reimplemented in the menu subclass - virtual void populate() = 0; + virtual void populate(float &customtop, float &custombottom) = 0; // To be reimplemented in the menu subclass virtual void handle() = 0; @@ -304,9 +321,17 @@ private: event m_event; // the UI event that occurred pool *m_pool; // list of memory pools + float m_customtop; // amount of extra height to add at the top + float m_custombottom; // amount of extra height to add at the bottom + int m_resetpos; // reset position void *m_resetref; // reset reference + bool m_mouse_hit; + bool m_mouse_button; + float m_mouse_x; + float m_mouse_y; + static std::mutex s_global_state_guard; static global_state_map s_global_states; }; diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp index cdec8a2f5ac..25f57a61898 100644 --- a/src/frontend/mame/ui/miscmenu.cpp +++ b/src/frontend/mame/ui/miscmenu.cpp @@ -37,7 +37,7 @@ menu_keyboard_mode::menu_keyboard_mode(mame_ui_manager &mui, render_container &c { } -void menu_keyboard_mode::populate() +void menu_keyboard_mode::populate(float &customtop, float &custombottom) { bool natural = machine().ioport().natkeyboard().in_use(); item_append(_("Keyboard Mode:"), natural ? _("Natural") : _("Emulated"), natural ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, nullptr); @@ -74,7 +74,7 @@ menu_bios_selection::menu_bios_selection(mame_ui_manager &mui, render_container { } -void menu_bios_selection::populate() +void menu_bios_selection::populate(float &customtop, float &custombottom) { /* cycle through all devices for this system */ for (device_t &device : device_iterator(machine().root_device())) @@ -156,7 +156,7 @@ menu_network_devices::~menu_network_devices() network device menu -------------------------------------------------*/ -void menu_network_devices::populate() +void menu_network_devices::populate(float &customtop, float &custombottom) { /* cycle through all devices for this system */ for (device_network_interface &network : network_interface_iterator(machine().root_device())) @@ -211,9 +211,8 @@ void menu_bookkeeping::handle() curtime = machine().time(); if (prevtime.seconds() != curtime.seconds()) { - reset(reset_options::SELECT_FIRST); prevtime = curtime; - populate(); + repopulate(reset_options::SELECT_FIRST); } /* process the menu */ @@ -233,7 +232,7 @@ menu_bookkeeping::~menu_bookkeeping() { } -void menu_bookkeeping::populate() +void menu_bookkeeping::populate(float &customtop, float &custombottom) { int tickets = machine().bookkeeping().get_dispensed_tickets(); std::ostringstream tempstring; @@ -250,7 +249,7 @@ void menu_bookkeeping::populate() util::stream_format(tempstring, _("Tickets dispensed: %1$d\n\n"), tickets); /* loop over coin counters */ - for (ctrnum = 0; ctrnum < COIN_COUNTERS; ctrnum++) + for (ctrnum = 0; ctrnum < bookkeeping_manager::COIN_COUNTERS; ctrnum++) { int count = machine().bookkeeping().coin_counter_get_count(ctrnum); @@ -375,7 +374,7 @@ menu_crosshair::menu_crosshair(mame_ui_manager &mui, render_container &container { } -void menu_crosshair::populate() +void menu_crosshair::populate(float &customtop, float &custombottom) { crosshair_item_data *data; char temp_text[16]; @@ -532,7 +531,7 @@ menu_quit_game::~menu_quit_game() { } -void menu_quit_game::populate() +void menu_quit_game::populate(float &customtop, float &custombottom) { } @@ -662,7 +661,7 @@ void menu_export::handle() // populate //------------------------------------------------- -void menu_export::populate() +void menu_export::populate(float &customtop, float &custombottom) { // add options items item_append(_("Export list in XML format (like -listxml)"), "", 0, (void *)(uintptr_t)1); @@ -769,7 +768,7 @@ void menu_machine_configure::handle() // populate //------------------------------------------------- -void menu_machine_configure::populate() +void menu_machine_configure::populate(float &customtop, float &custombottom) { // add options items item_append(_("Bios"), "", FLAG_DISABLE | FLAG_UI_HEADING, nullptr); @@ -934,7 +933,7 @@ void menu_plugins_configure::handle() // populate //------------------------------------------------- -void menu_plugins_configure::populate() +void menu_plugins_configure::populate(float &customtop, float &custombottom) { plugin_options& plugins = mame_machine_manager::instance()->plugins(); diff --git a/src/frontend/mame/ui/miscmenu.h b/src/frontend/mame/ui/miscmenu.h index 11909f099f5..e96a7a2db97 100644 --- a/src/frontend/mame/ui/miscmenu.h +++ b/src/frontend/mame/ui/miscmenu.h @@ -8,11 +8,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_MISCMENU_H #define MAME_FRONTEND_UI_MISCMENU_H +#pragma once + #include "crsshair.h" #include "emuopts.h" @@ -28,7 +28,7 @@ public: virtual ~menu_keyboard_mode(); private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; @@ -39,7 +39,7 @@ public: virtual ~menu_network_devices(); private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; @@ -50,7 +50,7 @@ public: virtual ~menu_bookkeeping(); private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; attotime prevtime; @@ -84,7 +84,7 @@ private: char next_name[CROSSHAIR_PIC_NAME_LENGTH + 1]; }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; @@ -95,7 +95,7 @@ public: virtual ~menu_quit_game(); private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; @@ -106,7 +106,7 @@ public: virtual ~menu_bios_selection(); private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; }; @@ -122,7 +122,7 @@ public: virtual ~menu_export(); private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; std::vector m_list; @@ -156,7 +156,7 @@ private: LAST = ADVANCED }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; const game_driver *m_drv; @@ -179,7 +179,7 @@ public: virtual ~menu_plugins_configure(); protected: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; diff --git a/src/frontend/mame/ui/optsmenu.cpp b/src/frontend/mame/ui/optsmenu.cpp index bb29179d3e7..00a27353965 100644 --- a/src/frontend/mame/ui/optsmenu.cpp +++ b/src/frontend/mame/ui/optsmenu.cpp @@ -220,7 +220,7 @@ void menu_game_options::handle() // populate //------------------------------------------------- -void menu_game_options::populate() +void menu_game_options::populate(float &customtop, float &custombottom) { if (machine().options().ui() != emu_options::UI_SIMPLE) { diff --git a/src/frontend/mame/ui/optsmenu.h b/src/frontend/mame/ui/optsmenu.h index 96e951da6e4..769d0aa9ecf 100644 --- a/src/frontend/mame/ui/optsmenu.h +++ b/src/frontend/mame/ui/optsmenu.h @@ -46,7 +46,7 @@ private: SAVE_CONFIG }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; uint16_t m_main; diff --git a/src/frontend/mame/ui/pluginopt.cpp b/src/frontend/mame/ui/pluginopt.cpp index 11884b6be40..a2be9d5f530 100644 --- a/src/frontend/mame/ui/pluginopt.cpp +++ b/src/frontend/mame/ui/pluginopt.cpp @@ -34,7 +34,7 @@ menu_plugin::menu_plugin(mame_ui_manager &mui, render_container &container) : { } -void menu_plugin::populate() +void menu_plugin::populate(float &customtop, float &custombottom) { for (auto &curplugin : m_plugins) item_append(curplugin, "", 0, (void *)curplugin.c_str()); @@ -104,7 +104,7 @@ void menu_plugin_opt::handle() } } -void menu_plugin_opt::populate() +void menu_plugin_opt::populate(float &customtop, float &custombottom) { std::vector> menu_list; mame_machine_manager::instance()->lua()->menu_populate(m_menu, menu_list); diff --git a/src/frontend/mame/ui/pluginopt.h b/src/frontend/mame/ui/pluginopt.h index 2aac32a6ea6..8b7edd1e305 100644 --- a/src/frontend/mame/ui/pluginopt.h +++ b/src/frontend/mame/ui/pluginopt.h @@ -31,7 +31,7 @@ public: virtual ~menu_plugin(); private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; std::vector &m_plugins; @@ -44,7 +44,7 @@ public: virtual ~menu_plugin_opt(); private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; std::string m_menu; diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp index f2944791dbd..83af27c4b72 100644 --- a/src/frontend/mame/ui/selector.cpp +++ b/src/frontend/mame/ui/selector.cpp @@ -116,7 +116,7 @@ void menu_selector::handle() // populate //------------------------------------------------- -void menu_selector::populate() +void menu_selector::populate(float &customtop, float &custombottom) { if (!m_search.empty()) { diff --git a/src/frontend/mame/ui/selector.h b/src/frontend/mame/ui/selector.h index 8b3d4cac8e8..e111d69551c 100644 --- a/src/frontend/mame/ui/selector.h +++ b/src/frontend/mame/ui/selector.h @@ -42,7 +42,7 @@ protected: private: enum { VISIBLE_GAMES_IN_SEARCH = 200 }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; void find_matches(const char *str); diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp index 9351c028a06..440985aaccf 100644 --- a/src/frontend/mame/ui/selgame.cpp +++ b/src/frontend/mame/ui/selgame.cpp @@ -184,7 +184,7 @@ void menu_select_game::handle() // if i have to reselect a software, force software list submenu if (reselect_last::get()) { - const game_driver *driver = (const game_driver *)item[selected].ref; + const game_driver *const driver = reinterpret_cast(get_selection_ref()); menu::stack_push(ui(), container(), driver); return; } @@ -493,7 +493,7 @@ void menu_select_game::handle() // populate //------------------------------------------------- -void menu_select_game::populate() +void menu_select_game::populate(float &customtop, float &custombottom) { ui_globals::redraw_icon = true; ui_globals::switch_image = true; @@ -1559,12 +1559,12 @@ float menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2) rgb_t bgcolor = UI_TEXT_BG_COLOR; rgb_t fgcolor = UI_TEXT_COLOR; - if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y1 + line_height_max > mouse_y) + if (mouse_in_rect(x1, y1, x2, y1 + line_height_max)) { bgcolor = UI_MOUSEOVER_BG_COLOR; fgcolor = UI_MOUSEOVER_COLOR; hover = phover + filter; - menu::highlight(x1, y1, x2, y1+ line_height_max, bgcolor); + menu::highlight(x1, y1, x2, y1 + line_height_max, bgcolor); } if (highlight == filter && get_focus() == focused_menu::left) @@ -1626,7 +1626,7 @@ float menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2) ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B)); - if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y2 > mouse_y) + if (mouse_in_rect(x1, y1, x2, y2)) { fgcolor = UI_MOUSEOVER_COLOR; hover = HOVER_LPANEL_ARROW; @@ -1649,7 +1649,7 @@ float menu_select_game::draw_left_panel(float x1, float y1, float x2, float y2) ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B)); - if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y2 > mouse_y) + if (mouse_in_rect(x1, y1, x2, y2)) { fgcolor = UI_MOUSEOVER_COLOR; hover = HOVER_LPANEL_ARROW; diff --git a/src/frontend/mame/ui/selgame.h b/src/frontend/mame/ui/selgame.h index 9455acb90cf..7c745ab1d8d 100644 --- a/src/frontend/mame/ui/selgame.h +++ b/src/frontend/mame/ui/selgame.h @@ -50,7 +50,7 @@ private: const game_driver *m_searchlist[VISIBLE_GAMES_IN_SEARCH + 1]; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; // draw left panel diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp index 3ac345ff324..84c0300d628 100644 --- a/src/frontend/mame/ui/selmenu.cpp +++ b/src/frontend/mame/ui/selmenu.cpp @@ -163,6 +163,7 @@ menu_select_launch::menu_select_launch(mame_ui_manager &mui, render_container &c , m_focus(focused_menu::main) , m_pressed(false) , m_repeat(0) + , m_right_visible_lines(0) { // set up persistent cache for machine run { @@ -412,7 +413,7 @@ void menu_select_launch::inkey_navigation() case focused_menu::main: if (selected <= visible_items) { - m_prev_selected = item[selected].ref; + m_prev_selected = get_selection_ref(); selected = visible_items + 1; } else @@ -468,28 +469,28 @@ void menu_select_launch::draw_common_arrow(float origx1, float origy1, float ori auto gutter_width = lr_arrow_width * 1.3f; // set left-right arrows dimension - float ar_x0 = 0.5f * (origx2 + origx1) + 0.5f * title_size + gutter_width - lr_arrow_width; - float ar_y0 = origy1 + 0.1f * line_height; - float ar_x1 = 0.5f * (origx2 + origx1) + 0.5f * title_size + gutter_width; - float ar_y1 = origy1 + 0.9f * line_height; + float const ar_x0 = 0.5f * (origx2 + origx1) + 0.5f * title_size + gutter_width - lr_arrow_width; + float const ar_y0 = origy1 + 0.1f * line_height; + float const ar_x1 = 0.5f * (origx2 + origx1) + 0.5f * title_size + gutter_width; + float const ar_y1 = origy1 + 0.9f * line_height; - float al_x0 = 0.5f * (origx2 + origx1) - 0.5f * title_size - gutter_width; - float al_y0 = origy1 + 0.1f * line_height; - float al_x1 = 0.5f * (origx2 + origx1) - 0.5f * title_size - gutter_width + lr_arrow_width; - float al_y1 = origy1 + 0.9f * line_height; + float const al_x0 = 0.5f * (origx2 + origx1) - 0.5f * title_size - gutter_width; + float const al_y0 = origy1 + 0.1f * line_height; + float const al_x1 = 0.5f * (origx2 + origx1) - 0.5f * title_size - gutter_width + lr_arrow_width; + float const al_y1 = origy1 + 0.9f * line_height; rgb_t fgcolor_right, fgcolor_left; fgcolor_right = fgcolor_left = UI_TEXT_COLOR; // set hover - if (mouse_hit && ar_x0 <= mouse_x && ar_x1 > mouse_x && ar_y0 <= mouse_y && ar_y1 > mouse_y && current != dmax) + if (mouse_in_rect(ar_x0, ar_y0, ar_x1, ar_y1) && current != dmax) { ui().draw_textured_box(container(), ar_x0 + 0.01f, ar_y0, ar_x1 - 0.01f, ar_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); hover = HOVER_UI_RIGHT; fgcolor_right = UI_MOUSEOVER_COLOR; } - else if (mouse_hit && al_x0 <= mouse_x && al_x1 > mouse_x && al_y0 <= mouse_y && al_y1 > mouse_y && current != dmin) + else if (mouse_in_rect(al_x0, al_y0, al_x1, al_y1) && current != dmin) { ui().draw_textured_box(container(), al_x0 + 0.01f, al_y0, al_x1 - 0.01f, al_y1, UI_MOUSEOVER_BG_COLOR, rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); @@ -521,7 +522,7 @@ void menu_select_launch::draw_info_arrow(int ub, float origx1, float origx2, flo rgb_t fgcolor = UI_TEXT_COLOR; uint32_t orientation = (!ub) ? ROT0 : ROT0 ^ ORIENTATION_FLIP_Y; - if (mouse_hit && origx1 <= mouse_x && origx2 > mouse_x && oy1 <= mouse_y && oy1 + (line_height * text_size) > mouse_y) + if (mouse_in_rect(origx1, oy1, origx2, oy1 + (line_height * text_size))) { ui().draw_textured_box(container(), origx1 + 0.01f, oy1, origx2 - 0.01f, oy1 + (line_height * text_size), UI_MOUSEOVER_BG_COLOR, rgb_t(43, 43, 43), hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); @@ -530,7 +531,7 @@ void menu_select_launch::draw_info_arrow(int ub, float origx1, float origx2, flo } draw_arrow(0.5f * (origx1 + origx2) - 0.5f * (ud_arrow_width * text_size), oy1 + 0.25f * (line_height * text_size), - 0.5f * (origx1 + origx2) + 0.5f * (ud_arrow_width * text_size), oy1 + 0.75f * (line_height * text_size), fgcolor, orientation); + 0.5f * (origx1 + origx2) + 0.5f * (ud_arrow_width * text_size), oy1 + 0.75f * (line_height * text_size), fgcolor, orientation); } @@ -564,7 +565,7 @@ void menu_select_launch::draw_toolbar(float x1, float y1, float x2, float y2) if (t_bitmap[z] && t_bitmap[z]->valid()) { rgb_t color(0xEFEFEFEF); - if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y2 > mouse_y) + if (mouse_in_rect(x1, y1, x2, y2)) { hover = HOVER_B_FAV + z; color = rgb_t::white(); @@ -793,8 +794,8 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey) validate_selection(1); // swallow left/right keys if they are not appropriate - bool ignoreleft = ((item[selected].flags & FLAG_LEFT_ARROW) == 0); - bool ignoreright = ((item[selected].flags & FLAG_RIGHT_ARROW) == 0); + bool ignoreleft = ((selected_item().flags & FLAG_LEFT_ARROW) == 0); + bool ignoreright = ((selected_item().flags & FLAG_RIGHT_ARROW) == 0); bool leftclose = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_LEFT_PANEL); bool rightclose = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL); @@ -876,7 +877,7 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey) if (!rightclose && m_focus == focused_menu::rightbottom) { iptkey = IPT_UI_DOWN_PANEL; - m_topline_datsview -= right_visible_lines - 1; + m_topline_datsview -= m_right_visible_lines - 1; return; } @@ -898,7 +899,7 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey) if (!rightclose && m_focus == focused_menu::rightbottom) { iptkey = IPT_UI_DOWN_PANEL; - m_topline_datsview += right_visible_lines - 1; + m_topline_datsview += m_right_visible_lines - 1; return; } @@ -980,19 +981,19 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey) void menu_select_launch::handle_events(uint32_t flags, event &ev) { - auto stop = false; + bool stop = false; ui_event local_menu_event; if (m_pressed) { - bool pressed = mouse_pressed(); - int32_t m_target_x, m_target_y; - bool m_button; - auto mouse_target = machine().ui_input().find_mouse(&m_target_x, &m_target_y, &m_button); - if (mouse_target && m_button && (hover == HOVER_ARROW_DOWN || hover == HOVER_ARROW_UP)) + bool const pressed = mouse_pressed(); + int32_t target_x, target_y; + bool button; + render_target *const mouse_target = machine().ui_input().find_mouse(&target_x, &target_y, &button); + if (mouse_target && button && (hover == HOVER_ARROW_DOWN || hover == HOVER_ARROW_UP)) { if (pressed) - machine().ui_input().push_mouse_down_event(mouse_target, m_target_x, m_target_y); + machine().ui_input().push_mouse_down_event(mouse_target, target_x, target_y); } else reset_pressed(); @@ -1016,7 +1017,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev) if (hover >= 0 && hover < item.size()) { if (hover >= visible_items - 1 && selected < visible_items) - m_prev_selected = item[selected].ref; + m_prev_selected = get_selection_ref(); selected = hover; m_focus = focused_menu::main; } @@ -1041,9 +1042,9 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev) else if (hover == HOVER_UI_LEFT) ev.iptkey = IPT_UI_LEFT; else if (hover == HOVER_DAT_DOWN) - m_topline_datsview += right_visible_lines - 1; + m_topline_datsview += m_right_visible_lines - 1; else if (hover == HOVER_DAT_UP) - m_topline_datsview -= right_visible_lines - 1; + m_topline_datsview -= m_right_visible_lines - 1; else if (hover == HOVER_LPANEL_ARROW) { if (ui_globals::panels_status == HIDE_LEFT_PANEL) @@ -1110,7 +1111,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev) ev.iptkey = IPT_UI_SELECT; } - if (selected == item.size() - 1) + if (is_last_selected()) { ev.iptkey = IPT_UI_CANCEL; stack_pop(); @@ -1124,7 +1125,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev) { if (local_menu_event.zdelta > 0) { - if (selected >= visible_items || selected == 0 || m_ui_error) + if (selected >= visible_items || is_first_selected() || m_ui_error) break; selected -= local_menu_event.num_lines; if (selected < top_line + (top_line != 0)) @@ -1162,7 +1163,7 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev) if (hover >= 0 && hover < item.size() - skip_main_items - 1) { selected = hover; - m_prev_selected = item[selected].ref; + m_prev_selected = get_selection_ref(); m_focus = focused_menu::main; ev.iptkey = IPT_CUSTOM; ev.mouse.x0 = local_menu_event.mouse_x; @@ -1189,7 +1190,6 @@ void menu_select_launch::draw(uint32_t flags) float line_height = ui().get_line_height(); float ud_arrow_width = line_height * machine().render().ui_aspect(); float gutter_width = 0.52f * ud_arrow_width; - mouse_x = -1, mouse_y = -1; float right_panel_size = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL) ? 2.0f * UI_BOX_LR_BORDER : 0.3f; float visible_width = 1.0f - 4.0f * UI_BOX_LR_BORDER; float primary_left = (1.0f - visible_width) * 0.5f; @@ -1200,18 +1200,13 @@ void menu_select_launch::draw(uint32_t flags) hover = item.size() + 1; visible_items = (m_is_swlist) ? item.size() - 2 : item.size() - 2 - skip_main_items; float extra_height = (m_is_swlist) ? 2.0f * line_height : (2.0f + skip_main_items) * line_height; - float visible_extra_menu_height = customtop + custombottom + extra_height; + float visible_extra_menu_height = get_customtop() + get_custombottom() + extra_height; // locate mouse - mouse_hit = false; - mouse_button = false; - if (!noinput) - { - mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button); - if (mouse_target) - if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, container(), mouse_x, mouse_y)) - mouse_hit = true; - } + if (noinput) + ignore_mouse(); + else + map_mouse(); // account for extra space at the top and bottom float visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height; @@ -1228,7 +1223,7 @@ void menu_select_launch::draw(uint32_t flags) float visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f; // if the menu is at the bottom of the extra, adjust - visible_top += customtop; + visible_top += get_customtop(); // compute left box size float x1 = visible_left - UI_BOX_LR_BORDER; @@ -1276,11 +1271,11 @@ void menu_select_launch::draw(uint32_t flags) float line_y1 = line_y + line_height; // set the hover if this is our item - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) + if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem)) hover = itemnum; // if we're selected, draw with a different background - if (itemnum == selected && m_focus == focused_menu::main) + if (is_selected(itemnum) && m_focus == focused_menu::main) { fgcolor = rgb_t(0xff, 0xff, 0x00); bgcolor = rgb_t(0xff, 0xff, 0xff); @@ -1367,11 +1362,11 @@ void menu_select_launch::draw(uint32_t flags) rgb_t fgcolor = UI_TEXT_COLOR; rgb_t bgcolor = UI_TEXT_BG_COLOR; - if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem)) + if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem)) hover = count; // if we're selected, draw with a different background - if (count == selected && m_focus == focused_menu::main) + if (is_selected(count) && m_focus == focused_menu::main) { fgcolor = rgb_t(0xff, 0xff, 0x00); bgcolor = rgb_t(0xff, 0xff, 0xff); @@ -1408,7 +1403,7 @@ void menu_select_launch::draw(uint32_t flags) x2 = primary_left + primary_width + UI_BOX_LR_BORDER; // if there is something special to add, do it by calling the virtual method - custom_render(get_selection_ref(), customtop, custombottom, x1, y1, x2, y2); + custom_render(get_selection_ref(), get_customtop(), get_custombottom(), x1, y1, x2, y2); // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow m_visible_items = m_visible_lines - (top_line != 0) - (top_line + m_visible_lines != visible_items); @@ -1448,7 +1443,7 @@ void menu_select_launch::draw_right_panel(float origx1, float origy1, float orig ui().draw_outlined_box(container(), origx1, origy1, origx2, origy2, rgb_t(0xEF, 0x12, 0x47, 0x7B)); rgb_t fgcolor(UI_TEXT_COLOR); - if (mouse_hit && origx1 <= mouse_x && x2 > mouse_x && origy1 <= mouse_y && origy2 > mouse_y) + if (mouse_in_rect(origx1, origy1, x2, origy2)) { fgcolor = UI_MOUSEOVER_COLOR; hover = HOVER_RPANEL_ARROW; @@ -1477,7 +1472,7 @@ void menu_select_launch::draw_right_panel(float origx1, float origy1, float orig float menu_select_launch::draw_right_box_title(float x1, float y1, float x2, float y2) { auto line_height = ui().get_line_height(); - float midl = (x2 - x1) * 0.5f; + float const midl = (x2 - x1) * 0.5f; // add outlined box for options ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); @@ -1503,7 +1498,7 @@ float menu_select_launch::draw_right_box_title(float x1, float y1, float x2, flo rgb_t bgcolor = UI_TEXT_BG_COLOR; rgb_t fgcolor = UI_TEXT_COLOR; - if (mouse_hit && x1 <= mouse_x && x1 + midl > mouse_x && y1 <= mouse_y && y1 + line_height > mouse_y) + if (mouse_in_rect(x1, y1, x1 + midl, y1 + line_height)) { if (ui_globals::rpanel != cells) { @@ -2066,7 +2061,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2, oy1 += (line_height * text_size); } // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow - right_visible_lines = r_visible_lines - (m_topline_datsview != 0) - (m_topline_datsview + r_visible_lines != m_total_lines); + m_right_visible_lines = r_visible_lines - (m_topline_datsview != 0) - (m_topline_datsview + r_visible_lines != m_total_lines); } } // namespace ui diff --git a/src/frontend/mame/ui/selmenu.h b/src/frontend/mame/ui/selmenu.h index 7741cc8b2d5..7878f12fd54 100644 --- a/src/frontend/mame/ui/selmenu.h +++ b/src/frontend/mame/ui/selmenu.h @@ -182,9 +182,12 @@ private: cache_ptr m_cache; bool m_is_swlist; focused_menu m_focus; - bool m_pressed; // mouse button held down + bool m_pressed; // mouse button held down osd_ticks_t m_repeat; + int m_right_visible_lines; // right box lines + + render_texture *m_icons_texture[MAX_ICONS_RENDER]; bitmap_ptr m_icons_bitmap[MAX_ICONS_RENDER]; game_driver const *m_old_icons[MAX_ICONS_RENDER]; diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp index 8a1768afae8..7e267c98987 100644 --- a/src/frontend/mame/ui/selsoft.cpp +++ b/src/frontend/mame/ui/selsoft.cpp @@ -417,7 +417,7 @@ void menu_select_software::handle() // populate //------------------------------------------------- -void menu_select_software::populate() +void menu_select_software::populate(float &customtop, float &custombottom) { uint32_t flags_ui = FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW; m_has_empty_start = true; @@ -1139,7 +1139,7 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float rgb_t bgcolor = UI_TEXT_BG_COLOR; rgb_t fgcolor = UI_TEXT_COLOR; - if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y1 + line_height > mouse_y) + if (mouse_in_rect(x1, y1, x2, y1 + line_height)) { bgcolor = UI_MOUSEOVER_BG_COLOR; fgcolor = UI_MOUSEOVER_COLOR; @@ -1209,7 +1209,7 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B)); - if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y2 > mouse_y) + if (mouse_in_rect(x1, y1, x2, y2)) { fgcolor = UI_MOUSEOVER_COLOR; hover = HOVER_LPANEL_ARROW; @@ -1232,7 +1232,7 @@ float menu_select_software::draw_left_panel(float x1, float y1, float x2, float ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B)); - if (mouse_hit && x1 <= mouse_x && x2 > mouse_x && y1 <= mouse_y && y2 > mouse_y) + if (mouse_in_rect(x1, y1, x2, y2)) { fgcolor = UI_MOUSEOVER_COLOR; hover = HOVER_LPANEL_ARROW; @@ -1265,7 +1265,7 @@ software_parts::~software_parts() // populate //------------------------------------------------- -void software_parts::populate() +void software_parts::populate(float &customtop, float &custombottom) { for (auto & elem : m_parts) item_append(elem.first, elem.second, 0, (void *)&elem); @@ -1363,7 +1363,7 @@ bios_selection::~bios_selection() // populate //------------------------------------------------- -void bios_selection::populate() +void bios_selection::populate(float &customtop, float &custombottom) { for (auto & elem : m_bios) item_append(elem.first, "", 0, (void *)&elem.first); diff --git a/src/frontend/mame/ui/selsoft.h b/src/frontend/mame/ui/selsoft.h index 7eb6597279e..48a452b5c68 100644 --- a/src/frontend/mame/ui/selsoft.h +++ b/src/frontend/mame/ui/selsoft.h @@ -7,11 +7,11 @@ UI software menu. ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_SELSOFT_H #define MAME_FRONTEND_UI_SELSOFT_H +#pragma once + #include "ui/custmenu.h" #include "ui/selmenu.h" @@ -37,7 +37,7 @@ private: s_filter m_filter; int highlight; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; // draw left panel @@ -78,7 +78,7 @@ protected: virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; ui_software_info *m_uiinfo; @@ -95,7 +95,7 @@ protected: virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; void *m_driver; diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp index 1630c35c8f7..bfa8b91b205 100644 --- a/src/frontend/mame/ui/simpleselgame.cpp +++ b/src/frontend/mame/ui/simpleselgame.cpp @@ -214,7 +214,7 @@ void simple_menu_select_game::inkey_special(const event *menu_event) // populate - populate the game select menu //------------------------------------------------- -void simple_menu_select_game::populate() +void simple_menu_select_game::populate(float &customtop, float &custombottom) { int matchcount; int curitem; diff --git a/src/frontend/mame/ui/simpleselgame.h b/src/frontend/mame/ui/simpleselgame.h index a368e61b40e..a520165c340 100644 --- a/src/frontend/mame/ui/simpleselgame.h +++ b/src/frontend/mame/ui/simpleselgame.h @@ -8,11 +8,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_SIMPLESELGAME_H #define MAME_FRONTEND_UI_SIMPLESELGAME_H +#pragma once + #include "menu.h" class driver_enumerator; @@ -33,7 +33,7 @@ protected: private: enum { VISIBLE_GAMES_IN_LIST = 15 }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; // internal methods diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp index 00a51944680..8631fc47971 100644 --- a/src/frontend/mame/ui/sliders.cpp +++ b/src/frontend/mame/ui/sliders.cpp @@ -135,7 +135,7 @@ void menu_sliders::handle() // menu //------------------------------------------------- -void menu_sliders::populate() +void menu_sliders::populate(float &customtop, float &custombottom) { std::string tempstring; diff --git a/src/frontend/mame/ui/sliders.h b/src/frontend/mame/ui/sliders.h index 54b2af38f78..4ef399173e3 100644 --- a/src/frontend/mame/ui/sliders.h +++ b/src/frontend/mame/ui/sliders.h @@ -33,7 +33,7 @@ private: INPUT_SPECIFIC, }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; bool m_menuless_mode; diff --git a/src/frontend/mame/ui/slotopt.cpp b/src/frontend/mame/ui/slotopt.cpp index 9c68410f2ef..3c0353160c6 100644 --- a/src/frontend/mame/ui/slotopt.cpp +++ b/src/frontend/mame/ui/slotopt.cpp @@ -151,7 +151,7 @@ menu_slot_devices::menu_slot_devices(mame_ui_manager &mui, render_container &con { } -void menu_slot_devices::populate() +void menu_slot_devices::populate(float &customtop, float &custombottom) { /* cycle through all devices for this system */ for (device_slot_interface &slot : slot_interface_iterator(machine().root_device())) diff --git a/src/frontend/mame/ui/slotopt.h b/src/frontend/mame/ui/slotopt.h index faca9fc236f..2ef1477d74a 100644 --- a/src/frontend/mame/ui/slotopt.h +++ b/src/frontend/mame/ui/slotopt.h @@ -24,7 +24,7 @@ public: virtual ~menu_slot_devices() override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; device_slot_option *slot_get_current_option(device_slot_interface &slot); diff --git a/src/frontend/mame/ui/sndmenu.cpp b/src/frontend/mame/ui/sndmenu.cpp index 28fcc7909a4..0a0d1c019ed 100644 --- a/src/frontend/mame/ui/sndmenu.cpp +++ b/src/frontend/mame/ui/sndmenu.cpp @@ -124,7 +124,7 @@ void menu_sound_options::handle() // populate //------------------------------------------------- -void menu_sound_options::populate() +void menu_sound_options::populate(float &customtop, float &custombottom) { uint32_t arrow_flags = get_arrow_flags(uint16_t(0), uint16_t(ARRAY_LENGTH(m_sound_rate) - 1), m_cur_rates); m_sample_rate = m_sound_rate[m_cur_rates]; diff --git a/src/frontend/mame/ui/sndmenu.h b/src/frontend/mame/ui/sndmenu.h index 8cb78d47650..4cecc5dc165 100644 --- a/src/frontend/mame/ui/sndmenu.h +++ b/src/frontend/mame/ui/sndmenu.h @@ -8,11 +8,11 @@ ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_SNDMENU_H #define MAME_FRONTEND_UI_SNDMENU_H +#pragma once + #include "ui/menu.h" namespace ui { @@ -36,10 +36,10 @@ private: ENABLE_SAMPLES }; - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; - uint16_t m_cur_rates; + uint16_t m_cur_rates; static const int m_sound_rate[]; int m_sample_rate; bool m_samples, m_sound; diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp index d54724997fe..5a8cb83cd8b 100644 --- a/src/frontend/mame/ui/submenu.cpp +++ b/src/frontend/mame/ui/submenu.cpp @@ -313,13 +313,13 @@ void submenu::handle() // populate //------------------------------------------------- -void submenu::populate() +void submenu::populate(float &customtop, float &custombottom) { - uint32_t arrow_flags; - // add options for (auto sm_option = m_options.begin(); sm_option < m_options.end(); ++sm_option) { + uint32_t arrow_flags; + // skip first heading (is menu title) if (sm_option == m_options.begin() && sm_option->type == option_type::HEAD) continue; diff --git a/src/frontend/mame/ui/submenu.h b/src/frontend/mame/ui/submenu.h index 475abde7018..acaf28d90e4 100644 --- a/src/frontend/mame/ui/submenu.h +++ b/src/frontend/mame/ui/submenu.h @@ -7,11 +7,11 @@ UI options menu. ***************************************************************************/ -#pragma once - #ifndef MAME_FRONTEND_UI_SUBMENU_H #define MAME_FRONTEND_UI_SUBMENU_H +#pragma once + #include "emuopts.h" #include "ui/menu.h" @@ -67,7 +67,7 @@ protected: virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: - virtual void populate() override; + virtual void populate(float &customtop, float &custombottom) override; virtual void handle() override; std::vector