From 6f7e4141ea14acaaf9cb973c66788fabb3457023 Mon Sep 17 00:00:00 2001 From: AJR Date: Thu, 30 Mar 2023 20:23:35 -0400 Subject: API change for device_image_interface - Remove the seterror method for recording error messages and conditions. Condition codes have been made return values for call_load, call_create and various related callbacks. Error messages (which many devices weren't generating) are now displayed through osd_printf_error. - Eliminate the image_init_result and image_verify_result pass/fail enumeration types. Update many functions that were returning these enumerations or simply bools to return std::error_condition instead. In some cases, this type is now passed down from internal parsing/loading functions which were already returning it. In various other cases, the former default UNSPECIFIED has been used as a catchall for I/O errors; anticipated future refactorings should make these error returns more specific. - Expand the image_error categories to include INVALIDLENGTH, NOSOFTWARE and BADSOFTWARE. The first is largely self-explanatory. The second is generated by the core to indicate failure to find software items in lists. The third is provided for devices to indicate semantic errors in software list entries. - Change the return type of floppy_image_device::identify to a pair so the potential error condition can be passed along to the UI without storing it in a member variable. - Move device_image_interface::message down into snapshot_image_device and change its implementation to use string_format instead of printf. - Correct a typo in the shortname of the generic snapshot device. --- docs/source/techspecs/luareference.rst | 11 +- src/devices/bus/a7800/a78_slot.cpp | 18 +-- src/devices/bus/a7800/a78_slot.h | 4 +- src/devices/bus/a800/a800_slot.cpp | 4 +- src/devices/bus/a800/a800_slot.h | 2 +- src/devices/bus/acorn/system/8k.cpp | 8 +- src/devices/bus/acorn/system/8k.h | 2 +- src/devices/bus/adam/exp.cpp | 4 +- src/devices/bus/adam/exp.h | 2 +- src/devices/bus/apf/slot.cpp | 10 +- src/devices/bus/apf/slot.h | 2 +- src/devices/bus/aquarius/slot.cpp | 8 +- src/devices/bus/aquarius/slot.h | 2 +- src/devices/bus/arcadia/slot.cpp | 6 +- src/devices/bus/arcadia/slot.h | 2 +- src/devices/bus/astrocde/slot.cpp | 6 +- src/devices/bus/astrocde/slot.h | 2 +- src/devices/bus/bbc/1mhzbus/datacentre.cpp | 6 +- src/devices/bus/bbc/rom/slot.cpp | 8 +- src/devices/bus/bbc/rom/slot.h | 2 +- src/devices/bus/c64/exp.cpp | 8 +- src/devices/bus/c64/exp.h | 2 +- src/devices/bus/cbm2/exp.cpp | 4 +- src/devices/bus/cbm2/exp.h | 2 +- src/devices/bus/cgenie/expansion/floppy.cpp | 6 +- src/devices/bus/chanf/slot.cpp | 6 +- src/devices/bus/chanf/slot.h | 2 +- src/devices/bus/coco/cococart.cpp | 6 +- src/devices/bus/coco/cococart.h | 2 +- src/devices/bus/coleco/cartridge/exp.cpp | 4 +- src/devices/bus/coleco/cartridge/exp.h | 2 +- src/devices/bus/cpc/cpc_rom.cpp | 4 +- src/devices/bus/cpc/cpc_rom.h | 2 +- src/devices/bus/crvision/slot.cpp | 10 +- src/devices/bus/crvision/slot.h | 2 +- src/devices/bus/ekara/slot.cpp | 6 +- src/devices/bus/ekara/slot.h | 2 +- src/devices/bus/electron/cart/ap5.cpp | 8 +- src/devices/bus/electron/cart/ap5.h | 2 +- src/devices/bus/electron/cart/romp144.cpp | 8 +- src/devices/bus/electron/cart/romp144.h | 2 +- src/devices/bus/electron/cart/slot.cpp | 12 +- src/devices/bus/electron/cart/slot.h | 2 +- src/devices/bus/electron/plus1.cpp | 8 +- src/devices/bus/electron/plus1.h | 2 +- src/devices/bus/electron/plus2.cpp | 8 +- src/devices/bus/electron/plus2.h | 2 +- src/devices/bus/electron/rombox.cpp | 8 +- src/devices/bus/electron/rombox.h | 2 +- src/devices/bus/electron/romboxp.cpp | 8 +- src/devices/bus/electron/romboxp.h | 2 +- src/devices/bus/electron/sidewndr.cpp | 8 +- src/devices/bus/electron/sidewndr.h | 2 +- src/devices/bus/gamate/slot.cpp | 10 +- src/devices/bus/gamate/slot.h | 2 +- src/devices/bus/gameboy/camera.cpp | 8 +- src/devices/bus/gameboy/gbck003.cpp | 8 +- src/devices/bus/gameboy/gbslot.cpp | 28 ++-- src/devices/bus/gameboy/gbslot.h | 2 +- src/devices/bus/gameboy/huc1.cpp | 8 +- src/devices/bus/gameboy/huc3.cpp | 8 +- src/devices/bus/gameboy/liebao.cpp | 8 +- src/devices/bus/gameboy/mbc.cpp | 88 +++++------ src/devices/bus/gameboy/mbc2.cpp | 10 +- src/devices/bus/gameboy/mbc3.cpp | 37 ++--- src/devices/bus/gameboy/mbc6.cpp | 8 +- src/devices/bus/gameboy/mbc7.cpp | 8 +- src/devices/bus/gameboy/mdslot.cpp | 14 +- src/devices/bus/gameboy/mdslot.h | 2 +- src/devices/bus/gameboy/mmm01.cpp | 8 +- src/devices/bus/gameboy/ntnew.cpp | 8 +- src/devices/bus/gameboy/rom.cpp | 82 +++++----- src/devices/bus/gameboy/slmulti.cpp | 8 +- src/devices/bus/gameboy/slot.cpp | 16 +- src/devices/bus/gameboy/slot.h | 6 +- src/devices/bus/gameboy/tama5.cpp | 8 +- src/devices/bus/gba/gba_slot.cpp | 10 +- src/devices/bus/gba/gba_slot.h | 2 +- src/devices/bus/generic/slot.cpp | 6 +- src/devices/bus/generic/slot.h | 6 +- src/devices/bus/intellec4/insdatastor.cpp | 10 +- src/devices/bus/intellec4/prommemory.cpp | 10 +- src/devices/bus/intellec4/tapereader.cpp | 6 +- src/devices/bus/intv/slot.cpp | 16 +- src/devices/bus/intv/slot.h | 4 +- src/devices/bus/iq151/iq151.cpp | 6 +- src/devices/bus/iq151/iq151.h | 2 +- src/devices/bus/isa/omti8621.cpp | 8 +- src/devices/bus/isa/sc499.cpp | 6 +- src/devices/bus/isa/sc499.h | 2 +- src/devices/bus/jakks_gamekey/slot.cpp | 6 +- src/devices/bus/jakks_gamekey/slot.h | 2 +- src/devices/bus/kc/kc.cpp | 6 +- src/devices/bus/kc/kc.h | 2 +- src/devices/bus/m5/slot.cpp | 8 +- src/devices/bus/m5/slot.h | 2 +- src/devices/bus/mc10/mc10_cart.cpp | 20 +-- src/devices/bus/mc10/mc10_cart.h | 4 +- src/devices/bus/mc10/pak.cpp | 6 +- src/devices/bus/mc10/pak.h | 2 +- src/devices/bus/megadrive/md_slot.cpp | 16 +- src/devices/bus/megadrive/md_slot.h | 6 +- src/devices/bus/mononcol/slot.cpp | 16 +- src/devices/bus/mononcol/slot.h | 2 +- src/devices/bus/msx/beecard/beecard.cpp | 8 +- src/devices/bus/msx/cart/arc.cpp | 8 +- src/devices/bus/msx/cart/arc.h | 2 +- src/devices/bus/msx/cart/ascii.cpp | 40 ++--- src/devices/bus/msx/cart/ascii.h | 8 +- src/devices/bus/msx/cart/beepack.cpp | 22 +-- src/devices/bus/msx/cart/beepack.h | 4 +- src/devices/bus/msx/cart/crossblaim.cpp | 8 +- src/devices/bus/msx/cart/crossblaim.h | 2 +- src/devices/bus/msx/cart/disk.cpp | 90 +++++------ src/devices/bus/msx/cart/dooly.cpp | 8 +- src/devices/bus/msx/cart/dooly.h | 2 +- src/devices/bus/msx/cart/easi_speech.cpp | 8 +- src/devices/bus/msx/cart/easi_speech.h | 2 +- src/devices/bus/msx/cart/fmpac.cpp | 12 +- src/devices/bus/msx/cart/fmpac.h | 2 +- src/devices/bus/msx/cart/fs_sr022.cpp | 8 +- src/devices/bus/msx/cart/fs_sr022.h | 2 +- src/devices/bus/msx/cart/halnote.cpp | 12 +- src/devices/bus/msx/cart/halnote.h | 2 +- src/devices/bus/msx/cart/hfox.cpp | 8 +- src/devices/bus/msx/cart/hfox.h | 2 +- src/devices/bus/msx/cart/holy_quran.cpp | 8 +- src/devices/bus/msx/cart/holy_quran.h | 2 +- src/devices/bus/msx/cart/ink.cpp | 6 +- src/devices/bus/msx/cart/ink.h | 2 +- src/devices/bus/msx/cart/kanji.cpp | 28 ++-- src/devices/bus/msx/cart/kanji.h | 6 +- src/devices/bus/msx/cart/konami.cpp | 68 ++++---- src/devices/bus/msx/cart/konami.h | 18 +-- src/devices/bus/msx/cart/korean.cpp | 24 +-- src/devices/bus/msx/cart/korean.h | 6 +- src/devices/bus/msx/cart/majutsushi.cpp | 8 +- src/devices/bus/msx/cart/majutsushi.h | 2 +- src/devices/bus/msx/cart/msx_audio.cpp | 24 +-- src/devices/bus/msx/cart/msx_audio.h | 6 +- src/devices/bus/msx/cart/msxdos2.cpp | 36 ++--- src/devices/bus/msx/cart/nomapper.cpp | 10 +- src/devices/bus/msx/cart/nomapper.h | 2 +- src/devices/bus/msx/cart/rtype.cpp | 8 +- src/devices/bus/msx/cart/rtype.h | 2 +- src/devices/bus/msx/cart/softcard.cpp | 22 +-- src/devices/bus/msx/cart/softcard.h | 4 +- src/devices/bus/msx/cart/super_swangi.cpp | 8 +- src/devices/bus/msx/cart/super_swangi.h | 2 +- src/devices/bus/msx/cart/superloderunner.cpp | 8 +- src/devices/bus/msx/cart/superloderunner.h | 2 +- src/devices/bus/msx/slot/cartridge.cpp | 14 +- src/devices/bus/msx/slot/cartridge.h | 4 +- src/devices/bus/msx/softcard/softcard.cpp | 8 +- src/devices/bus/mtx/exp.cpp | 8 +- src/devices/bus/mtx/exp.h | 2 +- src/devices/bus/nabupc/adapter.cpp | 7 +- src/devices/bus/nabupc/adapter.h | 2 +- src/devices/bus/neogeo/slot.cpp | 7 +- src/devices/bus/neogeo/slot.h | 2 +- src/devices/bus/nes/aladdin.cpp | 12 +- src/devices/bus/nes/aladdin.h | 2 +- src/devices/bus/nes/datach.cpp | 12 +- src/devices/bus/nes/datach.h | 2 +- src/devices/bus/nes/karastudio.cpp | 10 +- src/devices/bus/nes/karastudio.h | 2 +- src/devices/bus/nes/nes_slot.cpp | 17 +- src/devices/bus/nes/nes_slot.h | 2 +- src/devices/bus/nes/sunsoft_dcs.cpp | 10 +- src/devices/bus/nes/sunsoft_dcs.h | 2 +- src/devices/bus/nubus/nubus_image.cpp | 8 +- src/devices/bus/odyssey2/slot.cpp | 6 +- src/devices/bus/odyssey2/slot.h | 2 +- src/devices/bus/pce/pce_slot.cpp | 6 +- src/devices/bus/pce/pce_slot.h | 2 +- src/devices/bus/plus4/exp.cpp | 8 +- src/devices/bus/plus4/exp.h | 2 +- src/devices/bus/pofo/ccm.cpp | 4 +- src/devices/bus/pofo/ccm.h | 2 +- src/devices/bus/psx/memcard.cpp | 16 +- src/devices/bus/psx/memcard.h | 4 +- src/devices/bus/qbus/pc11.cpp | 4 +- src/devices/bus/qbus/pc11.h | 2 +- src/devices/bus/ql/rom.cpp | 4 +- src/devices/bus/ql/rom.h | 2 +- src/devices/bus/saturn/sat_slot.cpp | 6 +- src/devices/bus/saturn/sat_slot.h | 2 +- src/devices/bus/scv/slot.cpp | 10 +- src/devices/bus/scv/slot.h | 2 +- src/devices/bus/sdk85/memexp.cpp | 6 +- src/devices/bus/sdk85/memexp.h | 2 +- src/devices/bus/sega8/sega8_slot.cpp | 22 +-- src/devices/bus/sega8/sega8_slot.h | 4 +- src/devices/bus/snes/snes_slot.cpp | 6 +- src/devices/bus/snes/snes_slot.h | 2 +- src/devices/bus/spectrum/intf2.cpp | 6 +- src/devices/bus/spectrum/intf2.h | 2 +- src/devices/bus/ti99/gromport/cartridges.cpp | 8 +- src/devices/bus/ti99/gromport/cartridges.h | 2 +- src/devices/bus/ti99/peb/ti_rs232.cpp | 8 +- src/devices/bus/ti99/peb/ti_rs232.h | 4 +- src/devices/bus/ti99/peb/tipi.cpp | 4 +- src/devices/bus/ti99/peb/tipi.h | 2 +- src/devices/bus/ti99x/990_hd.cpp | 8 +- src/devices/bus/ti99x/990_hd.h | 2 +- src/devices/bus/ti99x/990_tap.cpp | 6 +- src/devices/bus/vboy/rom.cpp | 12 +- src/devices/bus/vboy/rom.h | 4 +- src/devices/bus/vboy/slot.cpp | 16 +- src/devices/bus/vboy/slot.h | 4 +- src/devices/bus/vc4000/slot.cpp | 10 +- src/devices/bus/vc4000/slot.h | 2 +- src/devices/bus/vcs/vcs_slot.cpp | 10 +- src/devices/bus/vcs/vcs_slot.h | 2 +- src/devices/bus/vectrex/slot.cpp | 14 +- src/devices/bus/vectrex/slot.h | 2 +- src/devices/bus/vic10/exp.cpp | 4 +- src/devices/bus/vic10/exp.h | 2 +- src/devices/bus/vic20/exp.cpp | 6 +- src/devices/bus/vic20/exp.h | 2 +- src/devices/bus/vidbrain/exp.cpp | 4 +- src/devices/bus/vidbrain/exp.h | 2 +- src/devices/bus/vsmile/vsmile_slot.cpp | 10 +- src/devices/bus/vsmile/vsmile_slot.h | 2 +- src/devices/bus/wswan/slot.cpp | 4 +- src/devices/bus/wswan/slot.h | 2 +- src/devices/bus/z88/z88.cpp | 6 +- src/devices/bus/z88/z88.h | 2 +- src/devices/imagedev/avivideo.cpp | 6 +- src/devices/imagedev/avivideo.h | 2 +- src/devices/imagedev/bitbngr.cpp | 8 +- src/devices/imagedev/bitbngr.h | 4 +- src/devices/imagedev/cassette.cpp | 11 +- src/devices/imagedev/cassette.h | 8 +- src/devices/imagedev/chd_cd.cpp | 9 +- src/devices/imagedev/chd_cd.h | 2 +- src/devices/imagedev/diablo.cpp | 20 +-- src/devices/imagedev/diablo.h | 8 +- src/devices/imagedev/flopdrv.cpp | 15 +- src/devices/imagedev/flopdrv.h | 6 +- src/devices/imagedev/floppy.cpp | 36 ++--- src/devices/imagedev/floppy.h | 6 +- src/devices/imagedev/harddriv.cpp | 28 ++-- src/devices/imagedev/harddriv.h | 8 +- src/devices/imagedev/mfmhd.cpp | 15 +- src/devices/imagedev/mfmhd.h | 2 +- src/devices/imagedev/microdrv.cpp | 6 +- src/devices/imagedev/microdrv.h | 2 +- src/devices/imagedev/midiin.cpp | 20 +-- src/devices/imagedev/midiin.h | 4 +- src/devices/imagedev/midiout.cpp | 6 +- src/devices/imagedev/midiout.h | 2 +- src/devices/imagedev/picture.cpp | 7 +- src/devices/imagedev/picture.h | 2 +- src/devices/imagedev/printer.cpp | 6 +- src/devices/imagedev/printer.h | 4 +- src/devices/imagedev/snapquik.cpp | 21 ++- src/devices/imagedev/snapquik.h | 16 +- src/devices/imagedev/wafadrive.cpp | 4 +- src/devices/imagedev/wafadrive.h | 2 +- src/devices/machine/ds6417.cpp | 12 +- src/devices/machine/ds6417.h | 4 +- src/devices/machine/hp_dc100_tape.cpp | 18 +-- src/devices/machine/hp_dc100_tape.h | 6 +- src/devices/machine/i7220.cpp | 6 +- src/devices/machine/i7220.h | 2 +- src/devices/machine/pccard_sram.cpp | 32 ++-- src/devices/machine/pccard_sram.h | 8 +- src/devices/machine/smartmed.cpp | 24 +-- src/devices/machine/smartmed.h | 6 +- src/emu/debug/debugcmd.cpp | 5 +- src/emu/diimage.cpp | 189 +++++++---------------- src/emu/diimage.h | 46 +++--- src/emu/image.cpp | 16 +- src/emu/softlist_dev.cpp | 10 +- src/emu/softlist_dev.h | 8 +- src/frontend/mame/luaengine.cpp | 24 +-- src/frontend/mame/luaengine.ipp | 2 - src/frontend/mame/ui/floppycntrl.cpp | 25 +-- src/frontend/mame/ui/imgcntrl.cpp | 6 +- src/mame/acorn/atom.cpp | 10 +- src/mame/acorn/atom.h | 2 +- src/mame/acorn/electron.h | 2 +- src/mame/acorn/electron_m.cpp | 8 +- src/mame/acorn/z88_impexp.cpp | 10 +- src/mame/acorn/z88_impexp.h | 4 +- src/mame/altos/altos5.cpp | 8 +- src/mame/amstrad/amstrad_m.cpp | 18 +-- src/mame/amstrad/pda600.cpp | 6 +- src/mame/apollo/apollo.h | 4 +- src/mame/apollo/apollo_m.cpp | 12 +- src/mame/apple/apple1.cpp | 14 +- src/mame/appliedconcepts/ggm.cpp | 2 +- src/mame/atari/jaguar.cpp | 6 +- src/mame/atari/jaguar.h | 2 +- src/mame/atari/lynx.cpp | 15 +- src/mame/atari/lynx.h | 2 +- src/mame/atari/lynx_m.cpp | 15 +- src/mame/ausnz/aussiebyte.cpp | 8 +- src/mame/ausnz/binbug.cpp | 19 ++- src/mame/ausnz/d6800.cpp | 6 +- src/mame/ausnz/eti660.cpp | 6 +- src/mame/ausnz/mbee.h | 2 +- src/mame/ausnz/mbee_m.cpp | 41 ++--- src/mame/ausnz/pegasus.cpp | 20 +-- src/mame/ausnz/pipbug.cpp | 19 ++- src/mame/ausnz/super80_m.cpp | 7 +- src/mame/bandai/design_master.cpp | 2 +- src/mame/bandai/rx78.cpp | 6 +- src/mame/bandai/sv8000.cpp | 6 +- src/mame/booth/apexc_m.cpp | 4 +- src/mame/booth/apexc_m.h | 2 +- src/mame/canon/x07.cpp | 6 +- src/mame/cantab/jupace.cpp | 10 +- src/mame/casio/casio_rompack.cpp | 2 +- src/mame/casio/casloopy.cpp | 2 +- src/mame/casio/pv1000.cpp | 6 +- src/mame/casio/pv2000.cpp | 6 +- src/mame/chess/ave_arb.cpp | 2 +- src/mame/coleco/coleco.cpp | 8 +- src/mame/commodore/cbm2.cpp | 1 + src/mame/commodore/cbm_snqk.cpp | 19 +-- src/mame/commodore/cbm_snqk.h | 4 +- src/mame/commodore/vic20.cpp | 1 + src/mame/comx/comx35.cpp | 6 +- src/mame/cybiko/cybiko_m.cpp | 4 +- src/mame/ddr/jtc.cpp | 24 +-- src/mame/ddr/kc_m.cpp | 4 +- src/mame/ddr/sprachmg.cpp | 14 +- src/mame/dec/pdp1.cpp | 16 +- src/mame/dec/pdp1.h | 8 +- src/mame/entex/sag.cpp | 18 +-- src/mame/epson/hx20.cpp | 6 +- src/mame/epson/qx10.cpp | 8 +- src/mame/exidy/sorcerer_m.cpp | 14 +- src/mame/force/force68k.cpp | 10 +- src/mame/fujitsu/fmt_icmem.cpp | 12 +- src/mame/fujitsu/fmt_icmem.h | 4 +- src/mame/funtech/supracan.cpp | 6 +- src/mame/handheld/chessking.cpp | 2 +- src/mame/handheld/gameking.cpp | 6 +- src/mame/handheld/hh_tms1k.cpp | 22 +-- src/mame/handheld/lk3000.cpp | 2 +- src/mame/homebrew/phunsy.cpp | 7 +- src/mame/homebrew/ravens.cpp | 18 ++- src/mame/homebrew/uzebox.cpp | 2 +- src/mame/homebrew/z80clock.cpp | 6 +- src/mame/homelab/homelab.cpp | 24 ++- src/mame/hp/hp48_port.cpp | 12 +- src/mame/hp/hp48_port.h | 4 +- src/mame/hp/hp80_optrom.cpp | 14 +- src/mame/hp/hp80_optrom.h | 2 +- src/mame/hp/hp9825_optrom.cpp | 8 +- src/mame/hp/hp9825_optrom.h | 2 +- src/mame/hp/hp9845_optrom.cpp | 14 +- src/mame/hp/hp9845_optrom.h | 2 +- src/mame/hp/hp_ipc_optrom.cpp | 12 +- src/mame/hp/hp_ipc_optrom.h | 2 +- src/mame/igs/pgm2_memcard.cpp | 20 +-- src/mame/igs/pgm2_memcard.h | 4 +- src/mame/intel/imm6_76.cpp | 14 +- src/mame/intel/imm6_76.h | 4 +- src/mame/intel/rex6000.cpp | 10 +- src/mame/interton/vc4000.cpp | 30 ++-- src/mame/kaypro/kaypro_m.cpp | 8 +- src/mame/leapfrog/leapfrog_iquest.cpp | 2 +- src/mame/leapfrog/leapfrog_leappad.cpp | 2 +- src/mame/leapfrog/leapfrog_leapster_explorer.cpp | 2 +- src/mame/leapfrog/leapster.cpp | 2 +- src/mame/luxor/abc80.cpp | 2 +- src/mame/luxor/abc80x.cpp | 2 +- src/mame/matsushita/jr100.cpp | 10 +- src/mame/mchester/ssem.cpp | 10 +- src/mame/memotech/mtx_m.cpp | 47 +++--- src/mame/microkey/primo_m.cpp | 10 +- src/mame/miltonbradley/microvsn.cpp | 6 +- src/mame/misc/mtu130.cpp | 8 +- src/mame/mit/tx0.cpp | 28 ++-- src/mame/mits/altair.cpp | 6 +- src/mame/motorola/m68705prg.cpp | 12 +- src/mame/motorola/mekd2.cpp | 4 +- src/mame/nascom/nascom1.cpp | 16 +- src/mame/neogeo/ng_memcard.cpp | 14 +- src/mame/neogeo/ng_memcard.h | 4 +- src/mame/netronics/elf.cpp | 4 +- src/mame/nichibutsu/myvision.cpp | 6 +- src/mame/nintendo/n64.cpp | 8 +- src/mame/nintendo/nes_vt09.cpp | 2 +- src/mame/nintendo/pokemini.cpp | 10 +- src/mame/pc/ibmpcjr.cpp | 10 +- src/mame/pce/tourvis.cpp | 2 +- src/mame/pitronics/beta.cpp | 6 +- src/mame/poly88/poly88_m.cpp | 2 +- src/mame/psion/psion_pack.cpp | 10 +- src/mame/psion/psion_pack.h | 4 +- src/mame/psion/psion_ssd.cpp | 8 +- src/mame/psion/psion_ssd.h | 2 +- src/mame/rca/studio2.cpp | 18 +-- src/mame/rca/vip.cpp | 4 +- src/mame/robotron/z1013.cpp | 8 +- src/mame/rockwell/aim65.cpp | 15 +- src/mame/rockwell/aim65.h | 2 +- src/mame/roland/roland_cm32p.cpp | 6 +- src/mame/roland/roland_r8.cpp | 10 +- src/mame/roland/roland_tnsc1.cpp | 2 +- src/mame/sega/mdconsole.cpp | 2 +- src/mame/sega/megatech.cpp | 10 +- src/mame/sega/sega_beena.cpp | 3 +- src/mame/sega/stv.cpp | 6 +- src/mame/sega/stv.h | 2 +- src/mame/sega/svmu.cpp | 2 +- src/mame/sfrj/galaxy.cpp | 4 +- src/mame/sgi/iris3130.cpp | 4 +- src/mame/shared/z80bin.cpp | 24 +-- src/mame/shared/z80bin.h | 4 +- src/mame/sharp/pce220_ser.cpp | 8 +- src/mame/sharp/pce220_ser.h | 4 +- src/mame/sharp/wizard.cpp | 2 +- src/mame/sharp/x68k_hdc.cpp | 6 +- src/mame/sharp/x68k_hdc.h | 2 +- src/mame/sinclair/spec_snqk.cpp | 38 ++--- src/mame/sinclair/timex.cpp | 19 +-- src/mame/skeleton/c2color.cpp | 2 +- src/mame/skeleton/cd2650.cpp | 19 ++- src/mame/skeleton/cosmicos.cpp | 2 +- src/mame/skeleton/cp1.cpp | 4 +- src/mame/skeleton/digiblast.cpp | 2 +- src/mame/skeleton/dmv.cpp | 8 +- src/mame/skeleton/easy_karaoke.cpp | 2 +- src/mame/skeleton/i7000.cpp | 2 +- src/mame/skeleton/pockchal.cpp | 3 +- src/mame/skeleton/squale.cpp | 6 +- src/mame/snk/ngp.cpp | 6 +- src/mame/sony/pockstat.cpp | 6 +- src/mame/sony/psx.cpp | 4 +- src/mame/sony/psxcd.cpp | 6 +- src/mame/sony/psxcd.h | 2 +- src/mame/sony/smc777.cpp | 8 +- src/mame/svi/svi318.cpp | 2 +- src/mame/svision/svision.cpp | 6 +- src/mame/ta/alphatro.cpp | 10 +- src/mame/tangerine/microtan.h | 6 +- src/mame/tangerine/microtan_m.cpp | 40 ++--- src/mame/tatung/einstein.cpp | 6 +- src/mame/telercas/tmc1800.cpp | 4 +- src/mame/thomson/thomson_m.cpp | 20 +-- src/mame/ti/avigo.cpp | 4 +- src/mame/ti/cc40.cpp | 6 +- src/mame/ti/snspell.cpp | 6 +- src/mame/ti/snspellc.cpp | 6 +- src/mame/ti/ti74.cpp | 6 +- src/mame/ti/ti85_m.cpp | 4 +- src/mame/ti/tm990189.cpp | 6 +- src/mame/tiger/gamecom.h | 2 +- src/mame/tiger/gamecom_m.cpp | 8 +- src/mame/tiger/k28m2.cpp | 6 +- src/mame/trainer/instruct.cpp | 19 ++- src/mame/trainer/mk14.cpp | 8 +- src/mame/trs/coco_vhd.cpp | 4 +- src/mame/trs/coco_vhd.h | 2 +- src/mame/trs/trs80_m.cpp | 8 +- src/mame/trs/trs80m3_m.cpp | 8 +- src/mame/tvgames/elan_eu3a05.cpp | 6 +- src/mame/tvgames/generalplus_gpl16250_mobigo.cpp | 4 +- src/mame/tvgames/generalplus_gpl16250_nand.cpp | 2 +- src/mame/tvgames/generalplus_gpl16250_spi.cpp | 2 +- src/mame/tvgames/generalplus_gpl32612.cpp | 2 +- src/mame/tvgames/hyperscan_card.cpp | 6 +- src/mame/tvgames/hyperscan_card.h | 2 +- src/mame/tvgames/magiceyes_pollux_vr3520f.cpp | 2 +- src/mame/tvgames/pubint_storyreader.cpp | 2 +- src/mame/tvgames/spg110.cpp | 2 +- src/mame/tvgames/spg29x.cpp | 4 +- src/mame/tvgames/spg2xx_ican.cpp | 6 +- src/mame/tvgames/spg2xx_smarttv.cpp | 6 +- src/mame/tvgames/spg2xx_telestory.cpp | 6 +- src/mame/tvgames/spg2xx_tvgogo.cpp | 6 +- src/mame/tvgames/spg2xx_vii.cpp | 6 +- src/mame/usp/patinho_feio.cpp | 2 +- src/mame/ussr/lviv.h | 2 +- src/mame/ussr/lviv_m.cpp | 19 ++- src/mame/videoton/tvc.cpp | 4 +- src/mame/virtual/vgmplay.cpp | 10 +- src/mame/vtech/clickstart.cpp | 2 +- src/mame/vtech/geniusiq.cpp | 2 +- src/mame/vtech/innotv_innotabmax.cpp | 2 +- src/mame/vtech/iqunlim.cpp | 2 +- src/mame/vtech/pc2000.cpp | 2 +- src/mame/vtech/storio.cpp | 2 +- src/mame/vtech/vtech1.cpp | 16 +- src/mame/vtech/vtech2_m.cpp | 6 +- src/mame/vtech/vtech_innotab.cpp | 2 +- src/mame/xerox/xerox820.cpp | 8 +- src/osd/modules/debugger/debugimgui.cpp | 6 +- src/osd/modules/debugger/qt/mainwindow.cpp | 5 +- 495 files changed, 2091 insertions(+), 2160 deletions(-) diff --git a/docs/source/techspecs/luareference.rst b/docs/source/techspecs/luareference.rst index 2da9a2cd02d..ec7727916db 100644 --- a/docs/source/techspecs/luareference.rst +++ b/docs/source/techspecs/luareference.rst @@ -1207,16 +1207,17 @@ Methods ^^^^^^^ image:load(filename) - Loads the specified file as a media image. Returns ``"pass"`` or - ``"fail"``. + Loads the specified file as a media image. Returns ``nil`` if no error + or a string describing an error if an error occurred. image:load_software(name) - Loads a media image described in a software list. Returns ``"pass"`` or - ``"fail"``. + Loads a media image described in a software list. Returns ``nil`` if no + error or a string describing an error if an error occurred. image:unload() Unloads the mounted image. image:create(filename) Creates and mounts a media image file with the specified name. Returns - ``"pass"`` or ``"fail"``. + ``nil`` if no error or a string describing an error if an error + occurred. image:display() Returns a “front panel display” string for the device, if supported. This can be used to show status information, like the current head position or diff --git a/src/devices/bus/a7800/a78_slot.cpp b/src/devices/bus/a7800/a78_slot.cpp index cee7d3bd99f..96e43fcd3b3 100644 --- a/src/devices/bus/a7800/a78_slot.cpp +++ b/src/devices/bus/a7800/a78_slot.cpp @@ -332,7 +332,7 @@ static const char *a78_get_slot(int type) return "a78_rom"; } -image_init_result a78_cart_slot_device::call_load() +std::error_condition a78_cart_slot_device::call_load() { if (m_cart) { @@ -368,8 +368,9 @@ image_init_result a78_cart_slot_device::call_load() char head[128]; fread(head, 128); - if (verify_header((char *)head) != image_verify_result::PASS) - return image_init_result::FAIL; + std::error_condition err = verify_header(head); + if (err) + return err; len = (head[49] << 24) | (head[50] << 16) | (head[51] << 8) | head[52]; if (len + 128 > length()) @@ -463,7 +464,7 @@ image_init_result a78_cart_slot_device::call_load() //printf("Type: %s\n", a78_get_slot(m_type)); } - return image_init_result::PASS; + return std::error_condition(); } @@ -484,19 +485,18 @@ void a78_cart_slot_device::call_unload() has an admissible header -------------------------------------------------*/ -image_verify_result a78_cart_slot_device::verify_header(char *header) +std::error_condition a78_cart_slot_device::verify_header(const char *header) { const char *magic = "ATARI7800"; if (strncmp(magic, header + 1, 9)) { - logerror("Not a valid A7800 image\n"); - seterror(image_error::INVALIDIMAGE, "File is not a valid A7800 image"); - return image_verify_result::FAIL; + osd_printf_error("%s: Not a valid A7800 image\n", basename()); + return image_error::INVALIDIMAGE; } logerror("returning ID_OK\n"); - return image_verify_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/a7800/a78_slot.h b/src/devices/bus/a7800/a78_slot.h index cba0d6115fa..1298e4f502a 100644 --- a/src/devices/bus/a7800/a78_slot.h +++ b/src/devices/bus/a7800/a78_slot.h @@ -101,7 +101,7 @@ public: virtual ~a78_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } @@ -132,7 +132,7 @@ private: device_a78_cart_interface* m_cart; int m_type; - image_verify_result verify_header(char *header); + std::error_condition verify_header(const char *header); int validate_header(int head, bool log) const; void internal_header_logging(uint8_t *header, uint32_t len); }; diff --git a/src/devices/bus/a800/a800_slot.cpp b/src/devices/bus/a800/a800_slot.cpp index 089cd8778bb..db7315c970a 100644 --- a/src/devices/bus/a800/a800_slot.cpp +++ b/src/devices/bus/a800/a800_slot.cpp @@ -224,7 +224,7 @@ static const char *a800_get_slot(int type) return "a800_8k"; } -image_init_result a800_cart_slot_device::call_load() +std::error_condition a800_cart_slot_device::call_load() { if (m_cart) { @@ -285,7 +285,7 @@ image_init_result a800_cart_slot_device::call_load() logerror("%s loaded cartridge '%s' size %dK\n", machine().system().name, filename(), len/1024); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/a800/a800_slot.h b/src/devices/bus/a800/a800_slot.h index 71b79dbe1b5..71fd3545255 100644 --- a/src/devices/bus/a800/a800_slot.h +++ b/src/devices/bus/a800/a800_slot.h @@ -103,7 +103,7 @@ public: virtual ~a800_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/acorn/system/8k.cpp b/src/devices/bus/acorn/system/8k.cpp index b2e1c7bb3d2..7c718399cfc 100644 --- a/src/devices/bus/acorn/system/8k.cpp +++ b/src/devices/bus/acorn/system/8k.cpp @@ -137,15 +137,15 @@ void acorn_8k_device::device_reset() // IMPLEMENTATION //************************************************************************** -image_init_result acorn_8k_device::load_rom(device_image_interface &image, generic_slot_device *slot) +std::error_condition acorn_8k_device::load_rom(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); // socket accepts 2K and 4K ROM only if (size != 0x0800 && size != 0x1000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only 2K/4K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only 2K/4K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(0x1000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -155,5 +155,5 @@ image_init_result acorn_8k_device::load_rom(device_image_interface &image, gener uint8_t *rom = slot->get_rom_base(); if (size <= 0x0800) memcpy(rom + 0x0800, rom, 0x0800); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/acorn/system/8k.h b/src/devices/bus/acorn/system/8k.h index 09f089c1563..44f98e8e395 100644 --- a/src/devices/bus/acorn/system/8k.h +++ b/src/devices/bus/acorn/system/8k.h @@ -41,7 +41,7 @@ protected: virtual ioport_constructor device_input_ports() const override; private: - image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_rom(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom0_load) { return load_rom(image, m_rom[0]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1_load) { return load_rom(image, m_rom[1]); } diff --git a/src/devices/bus/adam/exp.cpp b/src/devices/bus/adam/exp.cpp index 5a2098b2cfe..ef218d59510 100644 --- a/src/devices/bus/adam/exp.cpp +++ b/src/devices/bus/adam/exp.cpp @@ -77,7 +77,7 @@ void adam_expansion_slot_device::device_start() // call_load - //------------------------------------------------- -image_init_result adam_expansion_slot_device::call_load() +std::error_condition adam_expansion_slot_device::call_load() { if (m_card) { @@ -95,7 +95,7 @@ image_init_result adam_expansion_slot_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/adam/exp.h b/src/devices/bus/adam/exp.h index 01d73774bdb..a200474ca65 100644 --- a/src/devices/bus/adam/exp.h +++ b/src/devices/bus/adam/exp.h @@ -54,7 +54,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "adam_rom"; } diff --git a/src/devices/bus/apf/slot.cpp b/src/devices/bus/apf/slot.cpp index 62c8c7c02e9..3f514f9559c 100644 --- a/src/devices/bus/apf/slot.cpp +++ b/src/devices/bus/apf/slot.cpp @@ -144,7 +144,7 @@ static const char *apf_get_slot(int type) call load -------------------------------------------------*/ -image_init_result apf_cart_slot_device::call_load() +std::error_condition apf_cart_slot_device::call_load() { if (m_cart) { @@ -152,8 +152,8 @@ image_init_result apf_cart_slot_device::call_load() if (size > 0x3800) { - seterror(image_error::INVALIDIMAGE, "Image extends beyond the expected size for an APF cart"); - return image_init_result::FAIL; + osd_printf_error("%s: Image extends beyond the expected size for an APF cart\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size); @@ -187,10 +187,10 @@ image_init_result apf_cart_slot_device::call_load() //printf("Type: %s\n", apf_get_slot(m_type)); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/apf/slot.h b/src/devices/bus/apf/slot.h index 886135cb62b..da8b2cfce23 100644 --- a/src/devices/bus/apf/slot.h +++ b/src/devices/bus/apf/slot.h @@ -73,7 +73,7 @@ public: virtual ~apf_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override {} virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/aquarius/slot.cpp b/src/devices/bus/aquarius/slot.cpp index 2deb6149e12..d0c114ee893 100644 --- a/src/devices/bus/aquarius/slot.cpp +++ b/src/devices/bus/aquarius/slot.cpp @@ -83,7 +83,7 @@ void aquarius_cartridge_slot_device::device_start() // call_load //------------------------------------------------- -image_init_result aquarius_cartridge_slot_device::call_load() +std::error_condition aquarius_cartridge_slot_device::call_load() { if (m_cart) { @@ -91,8 +91,8 @@ image_init_result aquarius_cartridge_slot_device::call_load() if (size % 0x1000) { - seterror(image_error::INVALIDIMAGE, "Invalid ROM size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid ROM size\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size); @@ -103,7 +103,7 @@ image_init_result aquarius_cartridge_slot_device::call_load() memcpy(m_cart->get_rom_base(), get_software_region("rom"), size); } - return image_init_result::PASS; + return std::error_condition(); } //------------------------------------------------- diff --git a/src/devices/bus/aquarius/slot.h b/src/devices/bus/aquarius/slot.h index 9ee7aaf6d2b..6a8abad1492 100644 --- a/src/devices/bus/aquarius/slot.h +++ b/src/devices/bus/aquarius/slot.h @@ -45,7 +45,7 @@ public: auto nmi_handler() { return m_nmi_handler.bind(); } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "aquarius_cart"; } diff --git a/src/devices/bus/arcadia/slot.cpp b/src/devices/bus/arcadia/slot.cpp index 1eaada68544..f56d24c195e 100644 --- a/src/devices/bus/arcadia/slot.cpp +++ b/src/devices/bus/arcadia/slot.cpp @@ -133,7 +133,7 @@ static const char *arcadia_get_slot(int type) call load -------------------------------------------------*/ -image_init_result arcadia_cart_slot_device::call_load() +std::error_condition arcadia_cart_slot_device::call_load() { if (m_cart) { @@ -194,10 +194,10 @@ image_init_result arcadia_cart_slot_device::call_load() //printf("Type: %s\n", arcadia_get_slot(m_type)); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/arcadia/slot.h b/src/devices/bus/arcadia/slot.h index e9a3ed8415e..86827b73c8d 100644 --- a/src/devices/bus/arcadia/slot.h +++ b/src/devices/bus/arcadia/slot.h @@ -62,7 +62,7 @@ public: virtual ~arcadia_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override {} virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/astrocde/slot.cpp b/src/devices/bus/astrocde/slot.cpp index 6581dee5d01..a98e0945bcf 100644 --- a/src/devices/bus/astrocde/slot.cpp +++ b/src/devices/bus/astrocde/slot.cpp @@ -134,7 +134,7 @@ static const char *astrocade_get_slot(int type) call load -------------------------------------------------*/ -image_init_result astrocade_cart_slot_device::call_load() +std::error_condition astrocade_cart_slot_device::call_load() { if (m_cart) { @@ -164,10 +164,10 @@ image_init_result astrocade_cart_slot_device::call_load() //printf("Type: %s\n", astrocade_get_slot(m_type)); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/astrocde/slot.h b/src/devices/bus/astrocde/slot.h index 49242f2c31d..10c1362c993 100644 --- a/src/devices/bus/astrocde/slot.h +++ b/src/devices/bus/astrocde/slot.h @@ -67,7 +67,7 @@ public: virtual ~astrocade_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override {} virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/bbc/1mhzbus/datacentre.cpp b/src/devices/bus/bbc/1mhzbus/datacentre.cpp index f21d5af1d54..4c00db74de5 100644 --- a/src/devices/bus/bbc/1mhzbus/datacentre.cpp +++ b/src/devices/bus/bbc/1mhzbus/datacentre.cpp @@ -328,9 +328,9 @@ QUICKLOAD_LOAD_MEMBER(bbc_datacentre_device::quickload_cb) } else { - image.seterror(image_error::INVALIDIMAGE, "Invalid filetype, must be SSD, DSD, or IMG"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid filetype, must be SSD, DSD, or IMG\n", image.basename()); + return image_error::INVALIDIMAGE; } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/bbc/rom/slot.cpp b/src/devices/bus/bbc/rom/slot.cpp index 1be895375c3..caac6da93f5 100644 --- a/src/devices/bus/bbc/rom/slot.cpp +++ b/src/devices/bus/bbc/rom/slot.cpp @@ -114,7 +114,7 @@ void bbc_romslot_device::device_start() // call load //------------------------------------------------- -image_init_result bbc_romslot_device::call_load() +std::error_condition bbc_romslot_device::call_load() { if (m_cart) { @@ -122,8 +122,8 @@ image_init_result bbc_romslot_device::call_load() if (size % 0x2000) { - seterror(image_error::INVALIDIMAGE, "Invalid ROM size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid ROM size\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, tag()); @@ -142,7 +142,7 @@ image_init_result bbc_romslot_device::call_load() m_cart->nvram_alloc(get_software_region_length("nvram")); } - return image_init_result::PASS; + return std::error_condition(); } //------------------------------------------------- diff --git a/src/devices/bus/bbc/rom/slot.h b/src/devices/bus/bbc/rom/slot.h index 986d796dd0d..1a659aab1e8 100644 --- a/src/devices/bus/bbc/rom/slot.h +++ b/src/devices/bus/bbc/rom/slot.h @@ -30,7 +30,7 @@ class bbc_romslot_device : public device_t, { public: // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return false; } diff --git a/src/devices/bus/c64/exp.cpp b/src/devices/bus/c64/exp.cpp index 72d66ce6f30..f7265a18939 100644 --- a/src/devices/bus/c64/exp.cpp +++ b/src/devices/bus/c64/exp.cpp @@ -101,7 +101,7 @@ void c64_expansion_slot_device::device_reset() // call_load - //------------------------------------------------- -image_init_result c64_expansion_slot_device::call_load() +std::error_condition c64_expansion_slot_device::call_load() { if (m_card) { @@ -191,12 +191,12 @@ image_init_result c64_expansion_slot_device::call_load() if ((m_card->m_roml_size & (m_card->m_roml_size - 1)) || (m_card->m_romh_size & (m_card->m_romh_size - 1))) { - seterror(image_error::INVALIDIMAGE, "ROM size must be power of 2"); - return image_init_result::FAIL; + osd_printf_error("%s: ROM size must be power of 2\n", basename()); + return image_error::INVALIDLENGTH; } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/c64/exp.h b/src/devices/bus/c64/exp.h index d5861b0c4a3..4ae0cc05f49 100644 --- a/src/devices/bus/c64/exp.h +++ b/src/devices/bus/c64/exp.h @@ -100,7 +100,7 @@ protected: virtual void device_reset() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "c64_cart,vic10_cart"; } diff --git a/src/devices/bus/cbm2/exp.cpp b/src/devices/bus/cbm2/exp.cpp index c43e540e181..2323053593b 100644 --- a/src/devices/bus/cbm2/exp.cpp +++ b/src/devices/bus/cbm2/exp.cpp @@ -83,7 +83,7 @@ void cbm2_expansion_slot_device::device_start() // call_load - //------------------------------------------------- -image_init_result cbm2_expansion_slot_device::call_load() +std::error_condition cbm2_expansion_slot_device::call_load() { size_t size; @@ -117,7 +117,7 @@ image_init_result cbm2_expansion_slot_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/cbm2/exp.h b/src/devices/bus/cbm2/exp.h index 19ed3d01dac..5a77de5df3f 100644 --- a/src/devices/bus/cbm2/exp.h +++ b/src/devices/bus/cbm2/exp.h @@ -70,7 +70,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "cbm2_cart"; } diff --git a/src/devices/bus/cgenie/expansion/floppy.cpp b/src/devices/bus/cgenie/expansion/floppy.cpp index a97c3d46e66..32bf7f8e1c7 100644 --- a/src/devices/bus/cgenie/expansion/floppy.cpp +++ b/src/devices/bus/cgenie/expansion/floppy.cpp @@ -181,14 +181,14 @@ DEVICE_IMAGE_LOAD_MEMBER( cgenie_fdc_device::socket_load ) if (size > 0x1000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported ROM size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported ROM size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_socket->rom_alloc(0x1000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_socket->common_load_rom(m_socket->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } WRITE_LINE_MEMBER( cgenie_fdc_device::intrq_w ) diff --git a/src/devices/bus/chanf/slot.cpp b/src/devices/bus/chanf/slot.cpp index e13dd1d0d82..9cf517fe8da 100644 --- a/src/devices/bus/chanf/slot.cpp +++ b/src/devices/bus/chanf/slot.cpp @@ -146,7 +146,7 @@ static const char *chanf_get_slot(int type) call load -------------------------------------------------*/ -image_init_result channelf_cart_slot_device::call_load() +std::error_condition channelf_cart_slot_device::call_load() { if (m_cart) { @@ -181,10 +181,10 @@ image_init_result channelf_cart_slot_device::call_load() //printf("Type: %s\n", chanf_get_slot(m_type)); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/chanf/slot.h b/src/devices/bus/chanf/slot.h index afad1a76065..035d483aa79 100644 --- a/src/devices/bus/chanf/slot.h +++ b/src/devices/bus/chanf/slot.h @@ -78,7 +78,7 @@ public: virtual ~channelf_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override { } virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/coco/cococart.cpp b/src/devices/bus/coco/cococart.cpp index 17ef39fe69d..2a54fef1aa5 100644 --- a/src/devices/bus/coco/cococart.cpp +++ b/src/devices/bus/coco/cococart.cpp @@ -574,7 +574,7 @@ static std::error_condition read_coco_rpk(std::unique_ptr &&s // call_load //------------------------------------------------- -image_init_result cococart_slot_device::call_load() +std::error_condition cococart_slot_device::call_load() { if (m_cart) { @@ -596,7 +596,7 @@ image_init_result cococart_slot_device::call_load() if (!err) err = read_coco_rpk(std::move(proxy), base, cart_length, read_length); if (err) - return image_init_result::FAIL; + return err; } else { @@ -611,7 +611,7 @@ image_init_result cococart_slot_device::call_load() read_length += len; } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/coco/cococart.h b/src/devices/bus/coco/cococart.h index 0335d03475f..2b81319d0d3 100644 --- a/src/devices/bus/coco/cococart.h +++ b/src/devices/bus/coco/cococart.h @@ -71,7 +71,7 @@ public: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "coco_cart"; } diff --git a/src/devices/bus/coleco/cartridge/exp.cpp b/src/devices/bus/coleco/cartridge/exp.cpp index 6a73d73efb6..060f4d1f1bf 100644 --- a/src/devices/bus/coleco/cartridge/exp.cpp +++ b/src/devices/bus/coleco/cartridge/exp.cpp @@ -76,7 +76,7 @@ void colecovision_cartridge_slot_device::device_start() // call_load - //------------------------------------------------- -image_init_result colecovision_cartridge_slot_device::call_load() +std::error_condition colecovision_cartridge_slot_device::call_load() { if (m_card) { @@ -94,7 +94,7 @@ image_init_result colecovision_cartridge_slot_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/coleco/cartridge/exp.h b/src/devices/bus/coleco/cartridge/exp.h index 5e7eaa252d2..9e51f1ebb1d 100644 --- a/src/devices/bus/coleco/cartridge/exp.h +++ b/src/devices/bus/coleco/cartridge/exp.h @@ -72,7 +72,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "coleco_cart"; } diff --git a/src/devices/bus/cpc/cpc_rom.cpp b/src/devices/bus/cpc/cpc_rom.cpp index 014d4600858..ff6edcd818b 100644 --- a/src/devices/bus/cpc/cpc_rom.cpp +++ b/src/devices/bus/cpc/cpc_rom.cpp @@ -101,7 +101,7 @@ void cpc_rom_image_device::device_start() /*------------------------------------------------- DEVICE_IMAGE_LOAD( rom ) -------------------------------------------------*/ -image_init_result cpc_rom_image_device::call_load() +std::error_condition cpc_rom_image_device::call_load() { device_image_interface* image = this; uint64_t size = image->length(); @@ -117,7 +117,7 @@ image_init_result cpc_rom_image_device::call_load() image->fread(m_base,16384); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/cpc/cpc_rom.h b/src/devices/bus/cpc/cpc_rom.h index a9932dd57a8..a89cd692a50 100644 --- a/src/devices/bus/cpc/cpc_rom.h +++ b/src/devices/bus/cpc/cpc_rom.h @@ -26,7 +26,7 @@ public: virtual ~cpc_rom_image_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/crvision/slot.cpp b/src/devices/bus/crvision/slot.cpp index 616ad6173b4..3711dc11fa5 100644 --- a/src/devices/bus/crvision/slot.cpp +++ b/src/devices/bus/crvision/slot.cpp @@ -137,7 +137,7 @@ static const char *crvision_get_slot(int type) call load -------------------------------------------------*/ -image_init_result crvision_cart_slot_device::call_load() +std::error_condition crvision_cart_slot_device::call_load() { if (m_cart) { @@ -145,8 +145,8 @@ image_init_result crvision_cart_slot_device::call_load() if (size > 0x4800) { - seterror(image_error::INVALIDIMAGE, "Image extends beyond the expected size for an APF cart"); - return image_init_result::FAIL; + osd_printf_error("%s: Image extends beyond the expected size for an APF cart\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size); @@ -194,10 +194,10 @@ image_init_result crvision_cart_slot_device::call_load() printf("Type: %s\n", crvision_get_slot(m_type)); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/crvision/slot.h b/src/devices/bus/crvision/slot.h index 41f86b117ae..80402802130 100644 --- a/src/devices/bus/crvision/slot.h +++ b/src/devices/bus/crvision/slot.h @@ -71,7 +71,7 @@ public: virtual ~crvision_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override { } virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/ekara/slot.cpp b/src/devices/bus/ekara/slot.cpp index 2cd33594edb..533615545ff 100644 --- a/src/devices/bus/ekara/slot.cpp +++ b/src/devices/bus/ekara/slot.cpp @@ -127,7 +127,7 @@ static const char *ekara_get_slot(int type) call load -------------------------------------------------*/ -image_init_result ekara_cart_slot_device::call_load() +std::error_condition ekara_cart_slot_device::call_load() { if (m_cart) { @@ -156,10 +156,10 @@ image_init_result ekara_cart_slot_device::call_load() m_type = ekara_get_pcb_id(pcb_name); } - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/ekara/slot.h b/src/devices/bus/ekara/slot.h index 29cdc7f81de..f766e35a49f 100644 --- a/src/devices/bus/ekara/slot.h +++ b/src/devices/bus/ekara/slot.h @@ -81,7 +81,7 @@ public: virtual ~ekara_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override {} virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/electron/cart/ap5.cpp b/src/devices/bus/electron/cart/ap5.cpp index 90c4188d7b1..587c0be8779 100644 --- a/src/devices/bus/electron/cart/ap5.cpp +++ b/src/devices/bus/electron/cart/ap5.cpp @@ -154,15 +154,15 @@ void electron_ap5_device::write(offs_t offset, uint8_t data, int infc, int infd, // IMPLEMENTATION //************************************************************************** -image_init_result electron_ap5_device::load_rom(device_image_interface &image, generic_slot_device *slot) +std::error_condition electron_ap5_device::load_rom(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); // socket accepts 8K and 16K ROM only if (size != 0x2000 && size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only 8K/16K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only 8K/16K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -172,5 +172,5 @@ image_init_result electron_ap5_device::load_rom(device_image_interface &image, g uint8_t *crt = slot->get_rom_base(); if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/electron/cart/ap5.h b/src/devices/bus/electron/cart/ap5.h index 9e69c775c63..153c7288d81 100644 --- a/src/devices/bus/electron/cart/ap5.h +++ b/src/devices/bus/electron/cart/ap5.h @@ -42,7 +42,7 @@ protected: virtual void write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) override; private: - image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_rom(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1_load) { return load_rom(image, m_romslot[0]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom2_load) { return load_rom(image, m_romslot[1]); } diff --git a/src/devices/bus/electron/cart/romp144.cpp b/src/devices/bus/electron/cart/romp144.cpp index 8bdeab7cc34..503824e9fe2 100644 --- a/src/devices/bus/electron/cart/romp144.cpp +++ b/src/devices/bus/electron/cart/romp144.cpp @@ -140,15 +140,15 @@ void electron_romp144_device::write(offs_t offset, uint8_t data, int infc, int i // IMPLEMENTATION //************************************************************************** -image_init_result electron_romp144_device::load_rom(device_image_interface &image, generic_slot_device *slot) +std::error_condition electron_romp144_device::load_rom(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); // socket accepts 8K and 16K ROM only if (size != 0x2000 && size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only 8K/16K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only 8K/16K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -158,5 +158,5 @@ image_init_result electron_romp144_device::load_rom(device_image_interface &imag uint8_t *crt = slot->get_rom_base(); if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/electron/cart/romp144.h b/src/devices/bus/electron/cart/romp144.h index 45916a3ab38..e76f5749faa 100644 --- a/src/devices/bus/electron/cart/romp144.h +++ b/src/devices/bus/electron/cart/romp144.h @@ -37,7 +37,7 @@ protected: virtual void write(offs_t offset, uint8_t data, int infc, int infd, int romqa, int oe, int oe2) override; private: - image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_rom(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom0) { return load_rom(image, m_romslot[0]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1) { return load_rom(image, m_romslot[1]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom2) { return load_rom(image, m_romslot[2]); } diff --git a/src/devices/bus/electron/cart/slot.cpp b/src/devices/bus/electron/cart/slot.cpp index bcdff13233d..f3bff23a79d 100644 --- a/src/devices/bus/electron/cart/slot.cpp +++ b/src/devices/bus/electron/cart/slot.cpp @@ -122,7 +122,7 @@ void electron_cartslot_device::device_start() // call load //------------------------------------------------- -image_init_result electron_cartslot_device::call_load() +std::error_condition electron_cartslot_device::call_load() { if (m_cart) { @@ -132,8 +132,8 @@ image_init_result electron_cartslot_device::call_load() if (size % 0x2000) { - seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, tag()); @@ -152,8 +152,8 @@ image_init_result electron_cartslot_device::call_load() if ((upsize % 0x2000 && upsize != 0) || (losize % 0x2000 && losize != 0) || (romsize % 0x2000 && romsize != 0)) { - seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", basename()); + return image_error::INVALIDLENGTH; } // load standard 2x16K ROM cartridges @@ -197,7 +197,7 @@ image_init_result electron_cartslot_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/electron/cart/slot.h b/src/devices/bus/electron/cart/slot.h index b71da09d5ae..f8ba73be27c 100644 --- a/src/devices/bus/electron/cart/slot.h +++ b/src/devices/bus/electron/cart/slot.h @@ -137,7 +137,7 @@ public: auto nmi_handler() { return m_nmi_handler.bind(); } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_writeable() const noexcept override { return true; } diff --git a/src/devices/bus/electron/plus1.cpp b/src/devices/bus/electron/plus1.cpp index e9aa67bb16b..02bf452e099 100644 --- a/src/devices/bus/electron/plus1.cpp +++ b/src/devices/bus/electron/plus1.cpp @@ -490,15 +490,15 @@ void electron_ap6_device::expbus_w(offs_t offset, uint8_t data) // IMPLEMENTATION //************************************************************************** -image_init_result electron_ap6_device::load_rom(device_image_interface &image, generic_slot_device *slot) +std::error_condition electron_ap6_device::load_rom(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); // socket accepts 8K and 16K ROM only if (size != 0x2000 && size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only 8K/16K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only 8K/16K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -508,5 +508,5 @@ image_init_result electron_ap6_device::load_rom(device_image_interface &image, g uint8_t *crt = slot->get_rom_base(); if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/electron/plus1.h b/src/devices/bus/electron/plus1.h index bdfd35808e7..b803352136f 100644 --- a/src/devices/bus/electron/plus1.h +++ b/src/devices/bus/electron/plus1.h @@ -88,7 +88,7 @@ protected: virtual void expbus_w(offs_t offset, uint8_t data) override; private: - image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_rom(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1_load) { return load_rom(image, m_rom[0]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom2_load) { return load_rom(image, m_rom[1]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom3_load) { return load_rom(image, m_rom[2]); } diff --git a/src/devices/bus/electron/plus2.cpp b/src/devices/bus/electron/plus2.cpp index 7a75524ed5c..38273e39155 100644 --- a/src/devices/bus/electron/plus2.cpp +++ b/src/devices/bus/electron/plus2.cpp @@ -224,15 +224,15 @@ void electron_plus2_device::expbus_w(offs_t offset, uint8_t data) // IMPLEMENTATION //************************************************************************** -image_init_result electron_plus2_device::load_rom(device_image_interface &image, generic_slot_device *slot) +std::error_condition electron_plus2_device::load_rom(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); // socket accepts 8K and 16K ROM only if (size != 0x2000 && size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only 8K/16K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only 8K/16K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -242,5 +242,5 @@ image_init_result electron_plus2_device::load_rom(device_image_interface &image, uint8_t *crt = slot->get_rom_base(); if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/electron/plus2.h b/src/devices/bus/electron/plus2.h index 04e3a280377..0e9e7683288 100644 --- a/src/devices/bus/electron/plus2.h +++ b/src/devices/bus/electron/plus2.h @@ -41,7 +41,7 @@ protected: virtual void expbus_w(offs_t offset, uint8_t data) override; private: - image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_rom(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1_load) { return load_rom(image, m_rom[0]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom2_load) { return load_rom(image, m_rom[1]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom3_load) { return load_rom(image, m_rom[2]); } diff --git a/src/devices/bus/electron/rombox.cpp b/src/devices/bus/electron/rombox.cpp index 47040271e7f..c94ff45b23e 100644 --- a/src/devices/bus/electron/rombox.cpp +++ b/src/devices/bus/electron/rombox.cpp @@ -178,15 +178,15 @@ void electron_rombox_device::expbus_w(offs_t offset, uint8_t data) // IMPLEMENTATION //************************************************************************** -image_init_result electron_rombox_device::load_rom(device_image_interface &image, generic_slot_device *slot) +std::error_condition electron_rombox_device::load_rom(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); // socket accepts 8K and 16K ROM only if (size != 0x2000 && size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only 8K/16K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only 8K/16K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -196,5 +196,5 @@ image_init_result electron_rombox_device::load_rom(device_image_interface &image uint8_t *crt = slot->get_rom_base(); if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/electron/rombox.h b/src/devices/bus/electron/rombox.h index 65ed2fa80d8..98e5126d713 100644 --- a/src/devices/bus/electron/rombox.h +++ b/src/devices/bus/electron/rombox.h @@ -39,7 +39,7 @@ protected: virtual void expbus_w(offs_t offset, uint8_t data) override; private: - image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_rom(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1_load) { return load_rom(image, m_rom[0]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom2_load) { return load_rom(image, m_rom[1]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom3_load) { return load_rom(image, m_rom[2]); } diff --git a/src/devices/bus/electron/romboxp.cpp b/src/devices/bus/electron/romboxp.cpp index 59d83bc4121..3a1e9f5b8a0 100644 --- a/src/devices/bus/electron/romboxp.cpp +++ b/src/devices/bus/electron/romboxp.cpp @@ -321,15 +321,15 @@ void electron_romboxp_device::expbus_w(offs_t offset, uint8_t data) // IMPLEMENTATION //************************************************************************** -image_init_result electron_romboxp_device::load_rom(device_image_interface &image, generic_slot_device *slot) +std::error_condition electron_romboxp_device::load_rom(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); // socket accepts 8K and 16K ROM only if (size != 0x2000 && size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only 8K/16K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only 8K/16K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -339,5 +339,5 @@ image_init_result electron_romboxp_device::load_rom(device_image_interface &imag uint8_t *crt = slot->get_rom_base(); if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/electron/romboxp.h b/src/devices/bus/electron/romboxp.h index 62b2124c913..c18c8577fa7 100644 --- a/src/devices/bus/electron/romboxp.h +++ b/src/devices/bus/electron/romboxp.h @@ -45,7 +45,7 @@ protected: virtual void expbus_w(offs_t offset, uint8_t data) override; private: - image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_rom(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1_load) { return load_rom(image, m_rom[0]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom2_load) { return load_rom(image, m_rom[1]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom3_load) { return load_rom(image, m_rom[2]); } diff --git a/src/devices/bus/electron/sidewndr.cpp b/src/devices/bus/electron/sidewndr.cpp index a2ab8011b09..1f23f89bf9b 100644 --- a/src/devices/bus/electron/sidewndr.cpp +++ b/src/devices/bus/electron/sidewndr.cpp @@ -167,15 +167,15 @@ void electron_sidewndr_device::expbus_w(offs_t offset, uint8_t data) // IMPLEMENTATION //************************************************************************** -image_init_result electron_sidewndr_device::load_rom(device_image_interface &image, generic_slot_device *slot) +std::error_condition electron_sidewndr_device::load_rom(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); // socket accepts 8K and 16K ROM only if (size != 0x2000 && size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only 8K/16K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only 8K/16K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -185,5 +185,5 @@ image_init_result electron_sidewndr_device::load_rom(device_image_interface &ima uint8_t *crt = slot->get_rom_base(); if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/electron/sidewndr.h b/src/devices/bus/electron/sidewndr.h index 2e1dea53087..d4558d2e202 100644 --- a/src/devices/bus/electron/sidewndr.h +++ b/src/devices/bus/electron/sidewndr.h @@ -39,7 +39,7 @@ protected: virtual void expbus_w(offs_t offset, uint8_t data) override; private: - image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_rom(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1_load) { return load_rom(image, m_rom[0]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom2_load) { return load_rom(image, m_rom[1]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom3_load) { return load_rom(image, m_rom[2]); } diff --git a/src/devices/bus/gamate/slot.cpp b/src/devices/bus/gamate/slot.cpp index d46ed1d0a65..87bf0f193c0 100644 --- a/src/devices/bus/gamate/slot.cpp +++ b/src/devices/bus/gamate/slot.cpp @@ -125,7 +125,7 @@ static const char *gamate_get_slot(int type) call load -------------------------------------------------*/ -image_init_result gamate_cart_slot_device::call_load() +std::error_condition gamate_cart_slot_device::call_load() { if (m_cart) { @@ -134,8 +134,8 @@ image_init_result gamate_cart_slot_device::call_load() if (len > 0x80000) { - seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(len); @@ -160,10 +160,10 @@ image_init_result gamate_cart_slot_device::call_load() m_type = gamate_get_pcb_id(pcb_name); } - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gamate/slot.h b/src/devices/bus/gamate/slot.h index b78fa012705..76add4051b6 100644 --- a/src/devices/bus/gamate/slot.h +++ b/src/devices/bus/gamate/slot.h @@ -65,7 +65,7 @@ public: virtual ~gamate_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override { } virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/gameboy/camera.cpp b/src/devices/bus/gameboy/camera.cpp index 2faacd2d424..baa03572af4 100644 --- a/src/devices/bus/gameboy/camera.cpp +++ b/src/devices/bus/gameboy/camera.cpp @@ -85,7 +85,7 @@ public: camera_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; @@ -316,13 +316,13 @@ camera_device::camera_device( } -image_init_result camera_device::load(std::string &message) +std::error_condition camera_device::load(std::string &message) { // set up ROM and RAM set_bank_bits_rom(6); set_bank_bits_ram(4); if (!check_rom(message) || !configure_bank_ram(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; install_rom(); // install memory map control handlers @@ -357,7 +357,7 @@ image_init_result camera_device::load(std::string &message) &m_threshold[0][0][0]); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/gbck003.cpp b/src/devices/bus/gameboy/gbck003.cpp index 6fd3239e19a..7142d4dd6e5 100644 --- a/src/devices/bus/gameboy/gbck003.cpp +++ b/src/devices/bus/gameboy/gbck003.cpp @@ -69,7 +69,7 @@ class gbck003_device : public flat_ram_device_base public: gbck003_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: virtual void device_start() override ATTR_COLD; @@ -113,12 +113,12 @@ gbck003_device::gbck003_device( } -image_init_result gbck003_device::load(std::string &message) +std::error_condition gbck003_device::load(std::string &message) { // set up ROM/RAM set_bank_bits_rom(9); if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; install_rom(); install_ram(); @@ -141,7 +141,7 @@ image_init_result gbck003_device::load(std::string &message) set_bank_rom_high(1); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/gbslot.cpp b/src/devices/bus/gameboy/gbslot.cpp index b00e9584cd1..11885662c97 100644 --- a/src/devices/bus/gameboy/gbslot.cpp +++ b/src/devices/bus/gameboy/gbslot.cpp @@ -1121,7 +1121,7 @@ void gb_cart_slot_device::device_reset_after_children() } -image_init_result gb_cart_slot_device::load_image_file(util::random_read &file) +std::error_condition gb_cart_slot_device::load_image_file(util::random_read &file) { using namespace bus::gameboy; @@ -1139,13 +1139,17 @@ image_init_result gb_cart_slot_device::load_image_file(util::random_read &file) std::unique_ptr const footer(new (std::nothrow) u8 [gbxtrailer.size]); if (!footer) { - seterror(image_error::UNSPECIFIED, "Error allocating memory to read GBX file footer"); - return image_init_result::FAIL; + osd_printf_error("%s: Error allocating memory to read GBX file footer\n", basename()); + return std::errc::not_enough_memory; } - if (file.read_at(len - gbxtrailer.size, footer.get(), gbxtrailer.size, actual) || (gbxtrailer.size != actual)) + std::error_condition const err = file.read_at(len - gbxtrailer.size, footer.get(), gbxtrailer.size, actual); + if (err || (gbxtrailer.size != actual)) { - seterror(image_error::UNSPECIFIED, "Error reading GBX file footer"); - return image_init_result::FAIL; + osd_printf_error("%s: Error reading GBX file footer\n", basename()); + if (err) + return err; + else + return std::errc::io_error; } if (1 != gbxtrailer.ver_maj) { @@ -1246,10 +1250,14 @@ image_init_result gb_cart_slot_device::load_image_file(util::random_read &file) { LOG("Allocating %u byte cartridge ROM region\n", len); memory_region *const romregion = machine().memory().region_alloc(subtag("rom"), len, 1, ENDIANNESS_LITTLE); - if (file.read_at(offset, romregion->base(), len, actual) || (len != actual)) + std::error_condition const err = file.read_at(offset, romregion->base(), len, actual); + if (err || (len != actual)) { - seterror(image_error::UNSPECIFIED, "Error reading ROM data from cartridge file"); - return image_init_result::FAIL; + osd_printf_error("%s: Error reading ROM data from cartridge file\n", basename()); + if (err) + return err; + else + return std::errc::io_error; } // allocate cartridge RAM based on header if necessary @@ -1264,7 +1272,7 @@ image_init_result gb_cart_slot_device::load_image_file(util::random_read &file) } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/gbslot.h b/src/devices/bus/gameboy/gbslot.h index c1444a7905d..9555fbdbfbd 100644 --- a/src/devices/bus/gameboy/gbslot.h +++ b/src/devices/bus/gameboy/gbslot.h @@ -76,7 +76,7 @@ protected: virtual void device_reset_after_children() override ATTR_COLD; // gb_cart_slot_device_base implementation - virtual image_init_result load_image_file(util::random_read &file) override ATTR_COLD; + virtual std::error_condition load_image_file(util::random_read &file) override ATTR_COLD; void allocate_cart_ram(u8 const *basepage) ATTR_COLD; }; diff --git a/src/devices/bus/gameboy/huc1.cpp b/src/devices/bus/gameboy/huc1.cpp index 4e6821b0b1d..5cb100b256f 100644 --- a/src/devices/bus/gameboy/huc1.cpp +++ b/src/devices/bus/gameboy/huc1.cpp @@ -64,7 +64,7 @@ public: huc1_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: virtual void device_reset() override ATTR_COLD; @@ -91,13 +91,13 @@ huc1_device::huc1_device( } -image_init_result huc1_device::load(std::string &message) +std::error_condition huc1_device::load(std::string &message) { // check for valid ROM/RAM regions set_bank_bits_rom(2, 6); set_bank_bits_ram(2); if (!check_rom(message) || !check_ram(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; // if that checked out, install memory install_rom(); @@ -124,7 +124,7 @@ image_init_result huc1_device::load(std::string &message) write8smo_delegate(*this, FUNC(huc1_device::write_ir))); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/huc3.cpp b/src/devices/bus/gameboy/huc3.cpp index e1326b3a9d1..338a7615e38 100644 --- a/src/devices/bus/gameboy/huc3.cpp +++ b/src/devices/bus/gameboy/huc3.cpp @@ -135,7 +135,7 @@ public: static constexpr feature_type unemulated_features() { return feature::SOUND | feature::COMMS; } huc3_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: virtual void device_start() override ATTR_COLD; @@ -263,7 +263,7 @@ huc3_device::huc3_device( } -image_init_result huc3_device::load(std::string &message) +std::error_condition huc3_device::load(std::string &message) { // check for backup battery if (loaded_through_softlist()) @@ -304,7 +304,7 @@ image_init_result huc3_device::load(std::string &message) set_bank_bits_rom(2, 7); set_bank_bits_ram(2); if (!check_rom(message) || !check_ram(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; // if that checked out, install memory cart_space()->install_view(0xa000, 0xbfff, m_view_io); @@ -343,7 +343,7 @@ image_init_result huc3_device::load(std::string &message) write8smo_delegate(*this, FUNC(huc3_device::write_ir))); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/liebao.cpp b/src/devices/bus/gameboy/liebao.cpp index df261921546..796214ece63 100644 --- a/src/devices/bus/gameboy/liebao.cpp +++ b/src/devices/bus/gameboy/liebao.cpp @@ -30,7 +30,7 @@ class liebao_device : public mbc_ram_device_base public: liebao_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: virtual void device_start() override ATTR_COLD; @@ -60,13 +60,13 @@ liebao_device::liebao_device( } -image_init_result liebao_device::load(std::string &message) +std::error_condition liebao_device::load(std::string &message) { // set up ROM and RAM set_bank_bits_rom(9); set_bank_bits_ram(4); if (!check_rom(message) || !check_ram(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; cart_space()->install_view(0xa000, 0xbfff, m_view_ram); install_rom(*cart_space(), *cart_space(), *cart_space()); install_ram(m_view_ram[0]); @@ -86,7 +86,7 @@ image_init_result liebao_device::load(std::string &message) write8sm_delegate(*this, FUNC(liebao_device::bank_switch_rom_high))); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/mbc.cpp b/src/devices/bus/gameboy/mbc.cpp index c8d67d0ada4..508a37c2fa7 100644 --- a/src/devices/bus/gameboy/mbc.cpp +++ b/src/devices/bus/gameboy/mbc.cpp @@ -95,7 +95,7 @@ protected: { } - bool install_memory(std::string &message, unsigned highbits, unsigned lowbits) ATTR_COLD + std::error_condition install_memory(std::string &message, unsigned highbits, unsigned lowbits) ATTR_COLD { // see if the cartridge shouldn't use all the low bank bits char const *const lowbitsfeature(get_feature("banklowbits")); @@ -110,7 +110,7 @@ protected: message = util::string_format( "Invalid 'banklowbits' value (must be a number from 0 to %u)\n", lowbits); - return false; + return image_error::BADSOFTWARE; } lowbits = b; } @@ -119,7 +119,7 @@ protected: set_bank_bits_rom(highbits, lowbits); set_bank_bits_ram(highbits); if (!check_rom(message) || !check_ram(message)) - return false; + return image_error::BADSOFTWARE; // everything checked out - install memory and return success m_bank_lines[0] = util::make_bitmask(lowbits); @@ -127,7 +127,7 @@ protected: cart_space()->install_view(0xa000, 0xbfff, m_view_ram); install_rom(); install_ram(m_view_ram[0]); - return true; + return std::error_condition(); } void set_bank_rom_fine(u16 entry) @@ -168,11 +168,12 @@ private: class mbc5_device_base : public rom_mbc_device_base { public: - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // set up ROM and RAM - if (!install_memory(message)) - return image_init_result::FAIL; + std::error_condition err = install_memory(message); + if (err) + return err; // install handlers cart_space()->install_write_handler( @@ -189,7 +190,7 @@ public: write8smo_delegate(*this, FUNC(mbc5_device_base::bank_switch_coarse))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -208,7 +209,7 @@ protected: set_bank_ram(0); } - bool install_memory(std::string &message) ATTR_COLD + std::error_condition install_memory(std::string &message) ATTR_COLD { return rom_mbc_device_base::install_memory(message, 4, 9); } @@ -238,11 +239,11 @@ protected: class mbc5_logo_spoof_device_base : public mbc5_device_base { public: - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // install regular MBC5 handlers - image_init_result const result(mbc5_device_base::load(message)); - if (image_init_result::PASS != result) + std::error_condition const result(mbc5_device_base::load(message)); + if (result) return result; // intercept ROM reads for logo spoofing @@ -251,7 +252,7 @@ public: read8sm_delegate(*this, FUNC(mbc5_logo_spoof_device_base::read_rom))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -404,12 +405,11 @@ private: class mbc5_scrambled_device_base : public mbc5_logo_spoof_device_base { - - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // install regular MBC5 handlers - image_init_result const result(mbc5_logo_spoof_device_base::load(message)); - if (image_init_result::PASS != result) + std::error_condition const result(mbc5_logo_spoof_device_base::load(message)); + if (result) return result; // bank numbers and ROM contents are scrambled for protection @@ -430,7 +430,7 @@ class mbc5_scrambled_device_base : public mbc5_logo_spoof_device_base write8smo_delegate(*this, FUNC(mbc5_scrambled_device_base::set_bank_scramble))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -548,7 +548,7 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // probe for "collection" cartridges wired for 4-bit fine bank number unsigned banklowbits(5U); @@ -556,8 +556,9 @@ public: banklowbits = 4U; // set up ROM and RAM - if (!install_memory(message, 2, banklowbits)) - return image_init_result::FAIL; + std::error_condition err = install_memory(message, 2, banklowbits); + if (err) + return err; // install handlers cart_space()->install_write_handler( @@ -574,7 +575,7 @@ public: write8smo_delegate(*this, FUNC(mbc1_device::bank_low_mask))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -692,7 +693,7 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // check whether rumble motor is present char const *const rumblefeature(get_feature("rumble")); @@ -712,7 +713,7 @@ public: else { message = "Invalid 'rumble' feature value (must be yes or no)"; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } } else if (loaded_through_softlist()) @@ -765,8 +766,8 @@ public: } // install base MBC5 handlers - image_init_result const result(mbc5_device_base::load(message)); - if (image_init_result::PASS != result) + std::error_condition const result(mbc5_device_base::load(message)); + if (result) return result; // install rumble-aware handler if appropriate @@ -778,7 +779,7 @@ public: } // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -928,11 +929,11 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // install regular MBC5 handlers - image_init_result const result(mbc5_logo_spoof_device_base::load(message)); - if (image_init_result::PASS != result) + std::error_condition const result(mbc5_logo_spoof_device_base::load(message)); + if (result) return result; // bank numbers and ROM contents are scrambled for protection @@ -953,7 +954,7 @@ public: write8sm_delegate(*this, FUNC(sintax_device::set_xor))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -1159,11 +1160,11 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // install regular MBC5 handlers - image_init_result const result(mbc5_logo_spoof_device_base::load(message)); - if (image_init_result::PASS != result) + std::error_condition const result(mbc5_logo_spoof_device_base::load(message)); + if (result) return result; // protection against using a standard MBC5 - actual ignored range uncertain @@ -1172,7 +1173,7 @@ public: cart_space()->unmap_write(0x2101, 0x2fff); // all good - return image_init_result::PASS; + return std::error_condition(); } }; @@ -1191,14 +1192,15 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // TODO: ROM addresses seem to be fully decoded with HK0819 (rather than mirroring) // set up ROM and RAM // TODO: how many RAM bank outputs are actually present? - if (!install_memory(message, 2, 7)) - return image_init_result::FAIL; + std::error_condition err = install_memory(message, 2, 7); + if (err) + return err; // install handlers cart_space()->install_write_handler( @@ -1221,7 +1223,7 @@ public: m_view_prot[0].unmap_read(0x5000, 0x7fff); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -1315,7 +1317,7 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // get the command preload value // TODO: add a way to specify this in software lists @@ -1334,8 +1336,8 @@ public: } // install regular MBC5 handlers - image_init_result const result(mbc5_logo_spoof_device_base::load(message)); - if (image_init_result::PASS != result) + std::error_condition const result(mbc5_logo_spoof_device_base::load(message)); + if (result) return result; // set up an additional bank for the upper part of the low bank when split @@ -1362,7 +1364,7 @@ public: write8sm_delegate(*this, FUNC(vf001_device::prot_cmd))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: diff --git a/src/devices/bus/gameboy/mbc2.cpp b/src/devices/bus/gameboy/mbc2.cpp index b28828e560a..f8942363305 100644 --- a/src/devices/bus/gameboy/mbc2.cpp +++ b/src/devices/bus/gameboy/mbc2.cpp @@ -46,7 +46,7 @@ class mbc2_device : public mbc_device_base public: mbc2_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; virtual void unload() override ATTR_COLD; protected: @@ -79,12 +79,12 @@ mbc2_device::mbc2_device( } -image_init_result mbc2_device::load(std::string &message) +std::error_condition mbc2_device::load(std::string &message) { // first check ROM set_bank_bits_rom(4); if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; // decide whether to enable battery backup memory_region *const nvramregion(cart_nvram_region()); @@ -93,7 +93,7 @@ image_init_result mbc2_device::load(std::string &message) if (nvramregion->bytes() != RAM_SIZE) { message = "Unsupported cartridge NVRAM size (only MBC2 internal 512 nybble RAM is supported)"; - return image_init_result::FAIL; + return std::error_condition(); } m_battery_present = true; logerror("Found 'nvram' region, battery backup enabled\n"); @@ -153,7 +153,7 @@ image_init_result mbc2_device::load(std::string &message) m_ram_mbc[i] &= 0x0f; // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/mbc3.cpp b/src/devices/bus/gameboy/mbc3.cpp index f1971c749e4..b3d5dd59e00 100644 --- a/src/devices/bus/gameboy/mbc3.cpp +++ b/src/devices/bus/gameboy/mbc3.cpp @@ -111,7 +111,7 @@ protected: virtual bool nvram_write(util::write_stream &file) override ATTR_COLD; virtual bool nvram_can_write() const override ATTR_COLD; - bool install_memory(std::string &message, unsigned highbits, unsigned lowbits) ATTR_COLD; + std::error_condition install_memory(std::string &message, unsigned highbits, unsigned lowbits) ATTR_COLD; protected: u8 const rtc_select() const { return BIT(m_rtc_select, 3); } @@ -158,7 +158,7 @@ class mbc3_device : public mbc3_device_base public: mbc3_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; }; @@ -167,7 +167,7 @@ class mbc30_device : public mbc3_device_base public: mbc30_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; }; @@ -176,7 +176,7 @@ class tfboot_device : public mbc3_device_base public: tfboot_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: virtual void device_start() override ATTR_COLD; @@ -216,7 +216,7 @@ mbc3_device_base::mbc3_device_base( } -bool mbc3_device_base::install_memory( +std::error_condition mbc3_device_base::install_memory( std::string &message, unsigned highbits, unsigned lowbits) @@ -242,7 +242,7 @@ bool mbc3_device_base::install_memory( else { message = "Invalid 'rtc' feature value (must be yes or no)"; - return false; + return image_error::BADSOFTWARE; } } else @@ -321,7 +321,7 @@ bool mbc3_device_base::install_memory( set_bank_bits_rom(highbits, lowbits); set_bank_bits_ram(highbits); if (!check_rom(message) || !check_ram(message)) - return false; + return image_error::BADSOFTWARE; // set up ROM and RAM cart_space()->install_view(0xa000, 0xbfff, m_view_ram); @@ -358,7 +358,7 @@ bool mbc3_device_base::install_memory( } // all good - return true; + return std::error_condition(); } @@ -717,12 +717,9 @@ mbc3_device::mbc3_device( } -image_init_result mbc3_device::load(std::string &message) +std::error_condition mbc3_device::load(std::string &message) { - if (!install_memory(message, 2, 7)) - return image_init_result::FAIL; - else - return image_init_result::PASS; + return install_memory(message, 2, 7); } @@ -741,12 +738,9 @@ mbc30_device::mbc30_device( } -image_init_result mbc30_device::load(std::string &message) +std::error_condition mbc30_device::load(std::string &message) { - if (!install_memory(message, 3, 8)) - return image_init_result::FAIL; - else - return image_init_result::PASS; + return install_memory(message, 3, 8); } @@ -766,12 +760,9 @@ tfboot_device::tfboot_device( } -image_init_result tfboot_device::load(std::string &message) +std::error_condition tfboot_device::load(std::string &message) { - if (!install_memory(message, 2, 7)) - return image_init_result::FAIL; - else - return image_init_result::PASS; + return install_memory(message, 2, 7); } diff --git a/src/devices/bus/gameboy/mbc6.cpp b/src/devices/bus/gameboy/mbc6.cpp index 9bfe0900ca8..66551678200 100644 --- a/src/devices/bus/gameboy/mbc6.cpp +++ b/src/devices/bus/gameboy/mbc6.cpp @@ -78,7 +78,7 @@ public: mbc6_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; virtual void unload() override ATTR_COLD; protected: @@ -137,12 +137,12 @@ mbc6_device::mbc6_device( } -image_init_result mbc6_device::load(std::string &message) +std::error_condition mbc6_device::load(std::string &message) { // first check that ROM/RAM regions are supportable set_bank_bits_rom(7); if (!check_rom(message) || !check_ram(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; // install views for ROM/flash and RAM cart_space()->install_view(0x4000, 0x5fff, m_view_rom_low); @@ -187,7 +187,7 @@ image_init_result mbc6_device::load(std::string &message) write8sm_delegate(*this, FUNC(mbc6_device::write_flash<1>))); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/mbc7.cpp b/src/devices/bus/gameboy/mbc7.cpp index 4e88004996e..2c4a225d61f 100644 --- a/src/devices/bus/gameboy/mbc7.cpp +++ b/src/devices/bus/gameboy/mbc7.cpp @@ -73,7 +73,7 @@ namespace { class mbc7_device_base : public mbc_device_base { public: - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: mbc7_device_base(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock); @@ -157,12 +157,12 @@ INPUT_PORTS_END // mbc7_device_base //************************************************************************** -image_init_result mbc7_device_base::load(std::string &message) +std::error_condition mbc7_device_base::load(std::string &message) { // first check ROM set_bank_bits_rom(7); if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; // install ROM and handlers install_rom(); @@ -199,7 +199,7 @@ image_init_result mbc7_device_base::load(std::string &message) write8smo_delegate(*this, FUNC(mbc7_device_base::write_eeprom))); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/mdslot.cpp b/src/devices/bus/gameboy/mdslot.cpp index 8a59c50b774..0e42321de0e 100644 --- a/src/devices/bus/gameboy/mdslot.cpp +++ b/src/devices/bus/gameboy/mdslot.cpp @@ -116,7 +116,7 @@ std::string megaduck_cart_slot_device::get_default_card_software(get_default_car } -image_init_result megaduck_cart_slot_device::load_image_file(util::random_read &file) +std::error_condition megaduck_cart_slot_device::load_image_file(util::random_read &file) { auto const len = length(); size_t actual; @@ -125,14 +125,18 @@ image_init_result megaduck_cart_slot_device::load_image_file(util::random_read & { LOG("Allocating %u byte cartridge ROM region\n", len); memory_region *const romregion = machine().memory().region_alloc(subtag("rom"), len, 1, ENDIANNESS_LITTLE); - if (file.read_at(0, romregion->base(), len, actual) || (len != actual)) + std::error_condition const err = file.read_at(0, romregion->base(), len, actual); + if (err || (len != actual)) { - seterror(image_error::UNSPECIFIED, "Error reading cartridge file"); - return image_init_result::FAIL; + osd_printf_error("%s: Error reading cartridge file\n", basename()); + if (err) + return err; + else + return std::errc::io_error; } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/mdslot.h b/src/devices/bus/gameboy/mdslot.h index 03652f1dd5a..de0c6d907ae 100644 --- a/src/devices/bus/gameboy/mdslot.h +++ b/src/devices/bus/gameboy/mdslot.h @@ -61,7 +61,7 @@ public: protected: // gb_cart_slot_device_base implementation - virtual image_init_result load_image_file(util::random_read &file) override ATTR_COLD; + virtual std::error_condition load_image_file(util::random_read &file) override ATTR_COLD; }; diff --git a/src/devices/bus/gameboy/mmm01.cpp b/src/devices/bus/gameboy/mmm01.cpp index 8eece6bd2c4..b4f41b1cfa0 100644 --- a/src/devices/bus/gameboy/mmm01.cpp +++ b/src/devices/bus/gameboy/mmm01.cpp @@ -68,7 +68,7 @@ class mmm01_device : public mbc_ram_device_base public: mmm01_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: virtual void device_start() override ATTR_COLD; @@ -162,13 +162,13 @@ mmm01_device::mmm01_device( } -image_init_result mmm01_device::load(std::string &message) +std::error_condition mmm01_device::load(std::string &message) { // set up ROM and RAM set_bank_bits_rom(9); set_bank_bits_ram(4); if (!check_rom(message) || !check_ram(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; cart_space()->install_view(0xa000, 0xbfff, m_view_ram); install_rom(); install_ram(m_view_ram[0]); @@ -188,7 +188,7 @@ image_init_result mmm01_device::load(std::string &message) write8smo_delegate(*this, FUNC(mmm01_device::enable_bank_low_mid))); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/ntnew.cpp b/src/devices/bus/gameboy/ntnew.cpp index 44fc3394c20..e669e107231 100644 --- a/src/devices/bus/gameboy/ntnew.cpp +++ b/src/devices/bus/gameboy/ntnew.cpp @@ -38,7 +38,7 @@ class ntnew_device : public mbc_ram_device_base public: ntnew_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: virtual void device_start() override ATTR_COLD; @@ -67,13 +67,13 @@ ntnew_device::ntnew_device( } -image_init_result ntnew_device::load(std::string &message) +std::error_condition ntnew_device::load(std::string &message) { // set up ROM and RAM set_bank_bits_rom(8); set_bank_bits_ram(4); if (!check_rom(message) || !check_ram(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; cart_space()->install_view(0xa000, 0xbfff, m_view_ram); install_rom(*cart_space(), *cart_space(), *cart_space()); install_ram(m_view_ram[0]); @@ -90,7 +90,7 @@ image_init_result ntnew_device::load(std::string &message) write8smo_delegate(*this, FUNC(ntnew_device::bank_switch_ram))); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/rom.cpp b/src/devices/bus/gameboy/rom.cpp index cf593b95c8a..c3dfeeb68bb 100644 --- a/src/devices/bus/gameboy/rom.cpp +++ b/src/devices/bus/gameboy/rom.cpp @@ -310,19 +310,19 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // if there's no ROM region, there's nothing to do memory_region *const romregion(cart_rom_region()); if (!romregion || !romregion->bytes()) - return image_init_result::PASS; + return std::error_condition(); // check for supported size auto const bytes(romregion->bytes()); if (0x8000 < bytes) { message = "Unsupported cartridge ROM size (must be no larger than 32 KiB)"; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } // install ROM @@ -345,7 +345,7 @@ public: }); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -378,7 +378,7 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // if there's no ROM region, there's nothing to do memory_region *const romregion(cart_rom_region()); @@ -386,7 +386,7 @@ public: { // setting default bank on reset causes a fatal error when no banks are configured message = "No ROM data found"; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } // work out whether a fixed bank is required @@ -407,7 +407,7 @@ public: else { message = "Invalid 'fixedbank' feature value (must be yes or no)"; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } } else if (bytes & 0x7fff) @@ -425,7 +425,7 @@ public: if ((bytes & 0x3fff) || ((0x8000 * 0x100) < bytes) || (fixedbank && (*fixedbank ? ((0x4000 * 0x100) < bytes) : (bytes & 0x7fff)))) { message = "Unsupported cartridge ROM size (must be a multiple of bank size and no larger than 256 entries)"; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } // configure banks - low bank has 32 KiB entries, high bank has 16 KiB entries @@ -480,7 +480,7 @@ public: } // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -547,20 +547,20 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // first set up cartridge RAM if any if (!check_ram(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; // ROM is installed the same way as a Mega Duck flat ROM cartridge - image_init_result const romresult(megaduck_flat_device::load(message)); - if (image_init_result::PASS != romresult) + std::error_condition const romresult(megaduck_flat_device::load(message)); + if (romresult) return romresult; install_ram(); // all good - return image_init_result::PASS; + return std::error_condition(); } }; @@ -579,12 +579,12 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // set up ROM set_bank_bits_rom(8); // 74HC161A - 3-bit bank, 1-bit lockout if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; install_rom(); install_ram(); @@ -592,7 +592,7 @@ public: cart_space()->install_write_handler(0x0000, 0x7fff, write8sm_delegate(*this, FUNC(m161_device::bank_rom_switch))); // all good - return image_init_result::PASS; + return std::error_condition(); } private: @@ -638,12 +638,12 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // set up ROM set_bank_bits_rom(8); // 8 MiB real-world limit with 74LS377 - change to 14 for 512 MiB theoretical limit if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; install_rom(); install_ram(); set_bank_rom(0); @@ -652,7 +652,7 @@ public: cart_space()->install_write_handler(0x0000, 0x3fff, write8sm_delegate(*this, FUNC(wisdom_device::bank_rom_switch))); // all good - return image_init_result::PASS; + return std::error_condition(); } private: @@ -676,12 +676,12 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // set up ROM/RAM set_bank_bits_rom(8); if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; install_rom(); install_ram(); @@ -689,7 +689,7 @@ public: cart_space()->install_write_handler(0x2000, 0x2000, write8smo_delegate(*this, FUNC(yong_device::bank_rom_switch))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -721,12 +721,12 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // set up ROM/RAM set_bank_bits_rom(5); if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; install_rom(); install_ram(); @@ -734,7 +734,7 @@ public: cart_space()->install_write_handler(0x2000, 0x3fff, write8smo_delegate(*this, FUNC(rockman8_device::bank_rom_switch))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -787,12 +787,12 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // set up ROM/RAM set_bank_bits_rom(5); if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; install_rom(); install_ram(); @@ -801,7 +801,7 @@ public: cart_space()->install_write_handler(0x5000, 0x5fff, write8smo_delegate(*this, FUNC(sm3sp_device::bank_rom_mode))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -904,11 +904,11 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // configure ROM banks but don't install directly if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; configure_bank_rom(); // actually install ROM and bank switch handlers @@ -917,7 +917,7 @@ public: install_bank_switch_handlers(); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -967,11 +967,11 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // configure ROM banks but don't install directly if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; configure_bank_rom(); // actually install ROM and bank switch handlers @@ -980,7 +980,7 @@ public: install_bank_switch_handlers(); // all good - return image_init_result::PASS; + return std::error_condition(); } private: @@ -1005,12 +1005,12 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // configure ROM banks but don't install directly set_bank_bits_rom(8, 4); if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; configure_bank_rom(); install_ram(); @@ -1021,7 +1021,7 @@ public: cart_space()->install_write_handler(0x3fc0, 0x3fc0, write8smo_delegate(*this, FUNC(rocket_device::bank_rom_switch_coarse))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: @@ -1080,12 +1080,12 @@ public: { } - virtual image_init_result load(std::string &message) override ATTR_COLD + virtual std::error_condition load(std::string &message) override ATTR_COLD { // set up ROM/RAM set_bank_bits_rom(1, 2); if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; install_rom(); install_ram(); @@ -1094,7 +1094,7 @@ public: cart_space()->install_write_handler(0x6000, 0x6000, write8smo_delegate(*this, FUNC(lasama_device::ctrl_6000_w))); // all good - return image_init_result::PASS; + return std::error_condition(); } protected: diff --git a/src/devices/bus/gameboy/slmulti.cpp b/src/devices/bus/gameboy/slmulti.cpp index 5a58d9c734c..a2d4686b047 100644 --- a/src/devices/bus/gameboy/slmulti.cpp +++ b/src/devices/bus/gameboy/slmulti.cpp @@ -98,7 +98,7 @@ class slmulti_device : public mbc_ram_device_base public: slmulti_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: virtual void device_start() override ATTR_COLD; @@ -185,13 +185,13 @@ slmulti_device::slmulti_device( } -image_init_result slmulti_device::load(std::string &message) +std::error_condition slmulti_device::load(std::string &message) { // set up ROM and RAM set_bank_bits_rom(10); set_bank_bits_ram(4); if (!check_rom(message) || !check_ram(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; cart_space()->install_view(0xa000, 0xbfff, m_view_ram); install_rom(); install_ram(m_view_ram[0]); @@ -229,7 +229,7 @@ image_init_result slmulti_device::load(std::string &message) m_view_ctrl.select(1); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gameboy/slot.cpp b/src/devices/bus/gameboy/slot.cpp index 1ae0ab90f67..fce20d34d33 100644 --- a/src/devices/bus/gameboy/slot.cpp +++ b/src/devices/bus/gameboy/slot.cpp @@ -47,22 +47,26 @@ void gb_cart_slot_device_base::device_start() } -image_init_result gb_cart_slot_device_base::call_load() +std::error_condition gb_cart_slot_device_base::call_load() { if (!m_cart) - return image_init_result::PASS; + return std::error_condition(); - image_init_result result; + std::error_condition result; if (!loaded_through_softlist()) { result = load_image_file(image_core_file()); - if (image_init_result::PASS != result) + if (result) return result; } std::string message; result = m_cart->load(message); - if (image_init_result::PASS != result) - seterror(image_error::INVALIDIMAGE, message.c_str()); + if (result) + { + if (result == image_error::BADSOFTWARE && !loaded_through_softlist()) + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: %s\n", basename(), message); + } return result; } diff --git a/src/devices/bus/gameboy/slot.h b/src/devices/bus/gameboy/slot.h index 921c742f4ba..4cb037680a9 100644 --- a/src/devices/bus/gameboy/slot.h +++ b/src/devices/bus/gameboy/slot.h @@ -38,7 +38,7 @@ public: template void set_space(T &&... args) { m_space.set_tag(std::forward(args)...); } // device_image_interface implementation - virtual image_init_result call_load() override ATTR_COLD; + virtual std::error_condition call_load() override ATTR_COLD; virtual void call_unload() override ATTR_COLD; virtual bool is_reset_on_load() const noexcept override { return true; } @@ -48,7 +48,7 @@ protected: // device_t implementation virtual void device_start() override ATTR_COLD; - virtual image_init_result load_image_file(util::random_read &file) = 0; + virtual std::error_condition load_image_file(util::random_read &file) = 0; address_space &cart_space() noexcept { return *m_space; } @@ -64,7 +64,7 @@ private: class device_gb_cart_interface : public device_interface { public: - virtual image_init_result load(std::string &message) ATTR_COLD = 0; + virtual std::error_condition load(std::string &message) ATTR_COLD = 0; virtual void unload() ATTR_COLD; protected: diff --git a/src/devices/bus/gameboy/tama5.cpp b/src/devices/bus/gameboy/tama5.cpp index 7db552b9de4..da20671fd2a 100644 --- a/src/devices/bus/gameboy/tama5.cpp +++ b/src/devices/bus/gameboy/tama5.cpp @@ -101,7 +101,7 @@ public: tama5_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result load(std::string &message) override ATTR_COLD; + virtual std::error_condition load(std::string &message) override ATTR_COLD; protected: virtual void device_start() override ATTR_COLD; @@ -137,12 +137,12 @@ tama5_device::tama5_device( } -image_init_result tama5_device::load(std::string &message) +std::error_condition tama5_device::load(std::string &message) { // set up ROM set_bank_bits_rom(5); if (!check_rom(message)) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; install_rom(); // install I/O @@ -151,7 +151,7 @@ image_init_result tama5_device::load(std::string &message) cart_space()->install_write_handler(0xa001, 0xa001, 0x0000, 0x1ffe, 0x0000, write8smo_delegate(*this, FUNC(tama5_device::command_w))); // all good - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gba/gba_slot.cpp b/src/devices/bus/gba/gba_slot.cpp index bb5ad11048e..124b28b3e96 100644 --- a/src/devices/bus/gba/gba_slot.cpp +++ b/src/devices/bus/gba/gba_slot.cpp @@ -617,7 +617,7 @@ static const char *gba_get_slot(int type) call load -------------------------------------------------*/ -image_init_result gba_cart_slot_device::call_load() +std::error_condition gba_cart_slot_device::call_load() { if (m_cart) { @@ -625,8 +625,8 @@ image_init_result gba_cart_slot_device::call_load() uint32_t size = loaded_through_softlist() ? get_software_region_length("rom") : length(); if (size > 0x4000000) { - seterror(image_error::INVALIDIMAGE, "Attempted loading a cart larger than 64MB"); - return image_init_result::FAIL; + osd_printf_error("%s: Attempted loading a cart larger than 64MB\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, tag()); @@ -683,10 +683,10 @@ image_init_result gba_cart_slot_device::call_load() if (m_cart->get_nvram_size()) battery_load(m_cart->get_nvram_base(), m_cart->get_nvram_size(), 0x00); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/gba/gba_slot.h b/src/devices/bus/gba/gba_slot.h index 70fad8e4581..45cea852b82 100644 --- a/src/devices/bus/gba/gba_slot.h +++ b/src/devices/bus/gba/gba_slot.h @@ -98,7 +98,7 @@ public: virtual ~gba_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/generic/slot.cpp b/src/devices/bus/generic/slot.cpp index 8827706e657..df00b06328b 100644 --- a/src/devices/bus/generic/slot.cpp +++ b/src/devices/bus/generic/slot.cpp @@ -160,7 +160,7 @@ void generic_slot_device::device_start() call load -------------------------------------------------*/ -image_init_result generic_slot_device::call_load() +std::error_condition generic_slot_device::call_load() { if (m_cart) { @@ -173,11 +173,11 @@ image_init_result generic_slot_device::call_load() rom_alloc(len, m_width, m_endianness); common_load_rom(get_rom_base(), len, "rom"); - return image_init_result::PASS; + return std::error_condition(); } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/generic/slot.h b/src/devices/bus/generic/slot.h index c6c5c7d0b1f..85deeb74316 100644 --- a/src/devices/bus/generic/slot.h +++ b/src/devices/bus/generic/slot.h @@ -14,7 +14,7 @@ // MACROS //************************************************************************** -#define DEVICE_IMAGE_LOAD_MEMBER(_name) image_init_result _name(device_image_interface &image) +#define DEVICE_IMAGE_LOAD_MEMBER(_name) std::error_condition _name(device_image_interface &image) #define DECLARE_DEVICE_IMAGE_LOAD_MEMBER(_name) DEVICE_IMAGE_LOAD_MEMBER(_name) #define DEVICE_IMAGE_UNLOAD_MEMBER(_name) void _name(device_image_interface &image) @@ -149,7 +149,7 @@ class generic_slot_device : public device_t, public device_single_card_slot_interface { public: - typedef device_delegate load_delegate; + typedef device_delegate load_delegate; typedef device_delegate unload_delegate; virtual ~generic_slot_device(); @@ -164,7 +164,7 @@ public: void set_endian(endianness_t end) { m_endianness = end; } // device_image_interface implementation - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual char const *image_interface() const noexcept override { return m_interface; } diff --git a/src/devices/bus/intellec4/insdatastor.cpp b/src/devices/bus/intellec4/insdatastor.cpp index 81bbf713db7..444553232e7 100644 --- a/src/devices/bus/intellec4/insdatastor.cpp +++ b/src/devices/bus/intellec4/insdatastor.cpp @@ -168,7 +168,7 @@ class imm4_22_device public: imm4_22_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_readable() const noexcept override { return true; } @@ -222,18 +222,18 @@ imm4_22_device::imm4_22_device(machine_config const &mconfig, char const *tag, d } -image_init_result imm4_22_device::call_load() +std::error_condition imm4_22_device::call_load() { if ((length() > 1024U) || (length() % 256U)) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; allocate(); if (fread(m_prom.get(), length()) != length()) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; map_prom(); - return image_init_result::PASS; + return std::error_condition(); } void imm4_22_device::call_unload() diff --git a/src/devices/bus/intellec4/prommemory.cpp b/src/devices/bus/intellec4/prommemory.cpp index 7af8a5757f2..59e353fe61c 100644 --- a/src/devices/bus/intellec4/prommemory.cpp +++ b/src/devices/bus/intellec4/prommemory.cpp @@ -97,7 +97,7 @@ class imm6_26_device public: imm6_26_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_readable() const noexcept override { return true; } @@ -128,20 +128,20 @@ imm6_26_device::imm6_26_device(machine_config const &mconfig, char const *tag, d } -image_init_result imm6_26_device::call_load() +std::error_condition imm6_26_device::call_load() { if ((length() > 4096U) || (length() % 256U)) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; unmap(); allocate(); if (fread(m_data.get(), length()) != length()) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; // FIXME: gimme a cookie! rom_space().install_rom(0x1000U, offs_t(0x1000U + length()), m_data.get()); - return image_init_result::PASS; + return std::error_condition(); } void imm6_26_device::call_unload() diff --git a/src/devices/bus/intellec4/tapereader.cpp b/src/devices/bus/intellec4/tapereader.cpp index aa1acd9e963..191294ead1f 100644 --- a/src/devices/bus/intellec4/tapereader.cpp +++ b/src/devices/bus/intellec4/tapereader.cpp @@ -28,7 +28,7 @@ class imm4_90_device public: imm4_90_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual char const *file_extensions() const noexcept override { return "bnpf,hex,lst,txt"; } @@ -65,13 +65,13 @@ imm4_90_device::imm4_90_device(machine_config const &mconfig, char const *tag, d } -image_init_result imm4_90_device::call_load() +std::error_condition imm4_90_device::call_load() { m_step_timer->reset(); m_data = 0x00U; m_ready = false; m_stepping = false; - return image_init_result::PASS; + return std::error_condition(); } void imm4_90_device::call_unload() diff --git a/src/devices/bus/intv/slot.cpp b/src/devices/bus/intv/slot.cpp index 97d5b9ee308..aa09742020c 100644 --- a/src/devices/bus/intv/slot.cpp +++ b/src/devices/bus/intv/slot.cpp @@ -222,7 +222,7 @@ static const char *intv_get_slot(int type) call load -------------------------------------------------*/ -image_init_result intv_cart_slot_device::load_fullpath() +std::error_condition intv_cart_slot_device::load_fullpath() { uint8_t temp; uint8_t num_segments; @@ -243,13 +243,13 @@ image_init_result intv_cart_slot_device::load_fullpath() // header fread(&temp, 1); if (temp != 0xa8) - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; fread(&num_segments, 1); fread(&temp, 1); if (temp != (num_segments ^ 0xff)) - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; m_cart->rom_alloc(0x20000); ROM = (uint8_t *)m_cart->get_rom_base(); @@ -281,7 +281,7 @@ image_init_result intv_cart_slot_device::load_fullpath() { fread(&temp, 1); } - return image_init_result::PASS; + return std::error_condition(); } /* otherwise, we load it as a .bin file, using extrainfo from intv.hsi in place of .cfg */ else @@ -372,11 +372,11 @@ image_init_result intv_cart_slot_device::load_fullpath() } } - return image_init_result::PASS; + return std::error_condition(); } } -image_init_result intv_cart_slot_device::call_load() +std::error_condition intv_cart_slot_device::call_load() { if (m_cart) { @@ -424,11 +424,11 @@ image_init_result intv_cart_slot_device::call_load() m_cart->ram_alloc(get_software_region_length("ram")); //printf("Type: %s\n", intv_get_slot(m_type)); - return image_init_result::PASS; + return std::error_condition(); } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/intv/slot.h b/src/devices/bus/intv/slot.h index 4e4bc130730..526996fd969 100644 --- a/src/devices/bus/intv/slot.h +++ b/src/devices/bus/intv/slot.h @@ -112,7 +112,7 @@ public: virtual ~intv_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override {} virtual bool is_reset_on_load() const noexcept override { return true; } @@ -123,7 +123,7 @@ public: virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override; int get_type() { return m_type; } - image_init_result load_fullpath(); + std::error_condition load_fullpath(); void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } diff --git a/src/devices/bus/iq151/iq151.cpp b/src/devices/bus/iq151/iq151.cpp index d4ad9a8a865..d21234d4931 100644 --- a/src/devices/bus/iq151/iq151.cpp +++ b/src/devices/bus/iq151/iq151.cpp @@ -155,7 +155,7 @@ void iq151cart_slot_device::video_update(bitmap_ind16 &bitmap, const rectangle & call load -------------------------------------------------*/ -image_init_result iq151cart_slot_device::call_load() +std::error_condition iq151cart_slot_device::call_load() { if (m_cart) { @@ -176,10 +176,10 @@ image_init_result iq151cart_slot_device::call_load() } } else - return image_init_result::FAIL; + return image_error::INTERNAL; } - return image_init_result::PASS; + return std::error_condition(); } /*------------------------------------------------- diff --git a/src/devices/bus/iq151/iq151.h b/src/devices/bus/iq151/iq151.h index ff3992c7585..135473512b0 100644 --- a/src/devices/bus/iq151/iq151.h +++ b/src/devices/bus/iq151/iq151.h @@ -109,7 +109,7 @@ public: auto out_drq_callback() { return m_out_drq_cb.bind(); } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "iq151_cart"; } diff --git a/src/devices/bus/isa/omti8621.cpp b/src/devices/bus/isa/omti8621.cpp index 186e398c411..4b0f2ef4f8b 100644 --- a/src/devices/bus/isa/omti8621.cpp +++ b/src/devices/bus/isa/omti8621.cpp @@ -59,7 +59,7 @@ public: virtual const char *image_type_name() const noexcept override { return "winchester"; } virtual const char *image_brief_type_name() const noexcept override { return "disk"; } - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; protected: // device-level overrides @@ -1469,7 +1469,7 @@ void omti_disk_image_device::device_reset() disk image create callback -------------------------------------------------*/ -image_init_result omti_disk_image_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition omti_disk_image_device::call_create(int format_type, util::option_resolution *format_options) { logerror("device_create_omti_disk: creating OMTI Disk with %d blocks\n", m_sector_count); @@ -1481,9 +1481,9 @@ image_init_result omti_disk_image_device::call_create(int format_type, util::opt if (fwrite(sectordata, OMTI_DISK_SECTOR_SIZE) < OMTI_DISK_SECTOR_SIZE) { - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/isa/sc499.cpp b/src/devices/bus/isa/sc499.cpp index a670bb38aa4..5a52450441c 100644 --- a/src/devices/bus/isa/sc499.cpp +++ b/src/devices/bus/isa/sc499.cpp @@ -1295,19 +1295,19 @@ void sc499_ctape_image_device::write_block(int block_num, uint8_t *ptr) memcpy(&m_ctape_data[block_num * SC499_CTAPE_BLOCK_SIZE], ptr, SC499_CTAPE_BLOCK_SIZE); } -image_init_result sc499_ctape_image_device::call_load() +std::error_condition sc499_ctape_image_device::call_load() { try { auto const size = length(); m_ctape_data.resize(size); if (!fseek(0, SEEK_SET) && (fread(m_ctape_data.data(), size) == size)) - return image_init_result::PASS; + return std::error_condition(); } catch (...) { } - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } void sc499_ctape_image_device::call_unload() diff --git a/src/devices/bus/isa/sc499.h b/src/devices/bus/isa/sc499.h index ffcd8c37a85..93d814d656c 100644 --- a/src/devices/bus/isa/sc499.h +++ b/src/devices/bus/isa/sc499.h @@ -30,7 +30,7 @@ public: sc499_ctape_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool support_command_line_image_creation() const noexcept override { return true; } diff --git a/src/devices/bus/jakks_gamekey/slot.cpp b/src/devices/bus/jakks_gamekey/slot.cpp index 40fd58b0713..9c33451bd26 100644 --- a/src/devices/bus/jakks_gamekey/slot.cpp +++ b/src/devices/bus/jakks_gamekey/slot.cpp @@ -125,7 +125,7 @@ static const char *jakks_gamekey_get_slot(int type) call load -------------------------------------------------*/ -image_init_result jakks_gamekey_slot_device::call_load() +std::error_condition jakks_gamekey_slot_device::call_load() { if (m_cart) { @@ -154,10 +154,10 @@ image_init_result jakks_gamekey_slot_device::call_load() m_type = jakks_gamekey_get_pcb_id(pcb_name); } - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/jakks_gamekey/slot.h b/src/devices/bus/jakks_gamekey/slot.h index 0f02ca86e43..7949b339802 100644 --- a/src/devices/bus/jakks_gamekey/slot.h +++ b/src/devices/bus/jakks_gamekey/slot.h @@ -69,7 +69,7 @@ public: virtual ~jakks_gamekey_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override { } virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/kc/kc.cpp b/src/devices/bus/kc/kc.cpp index 5e2b67cdab3..7adf302c3ff 100644 --- a/src/devices/bus/kc/kc.cpp +++ b/src/devices/bus/kc/kc.cpp @@ -316,7 +316,7 @@ kccart_slot_device::~kccart_slot_device() call load -------------------------------------------------*/ -image_init_result kccart_slot_device::call_load() +std::error_condition kccart_slot_device::call_load() { if (m_cart) { @@ -337,10 +337,10 @@ image_init_result kccart_slot_device::call_load() } } else - return image_init_result::FAIL; + return image_error::INTERNAL; } - return image_init_result::PASS; + return std::error_condition(); } /*------------------------------------------------- diff --git a/src/devices/bus/kc/kc.h b/src/devices/bus/kc/kc.h index fdb9cd467ce..a9b45793938 100644 --- a/src/devices/bus/kc/kc.h +++ b/src/devices/bus/kc/kc.h @@ -111,7 +111,7 @@ public: virtual ~kccart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "kc_cart"; } diff --git a/src/devices/bus/m5/slot.cpp b/src/devices/bus/m5/slot.cpp index f82ba409d1e..ac5edfaa055 100644 --- a/src/devices/bus/m5/slot.cpp +++ b/src/devices/bus/m5/slot.cpp @@ -145,7 +145,7 @@ static const char *m5_get_slot(int type) call load -------------------------------------------------*/ -image_init_result m5_cart_slot_device::call_load() +std::error_condition m5_cart_slot_device::call_load() { if (m_cart) { @@ -166,8 +166,8 @@ image_init_result m5_cart_slot_device::call_load() if (size > 0x5000 && m_type == M5_STD) { - seterror(image_error::INVALIDIMAGE, "Image extends beyond the expected size for an M5 cart"); - return image_init_result::FAIL; + osd_printf_error("%s: Image extends beyond the expected size for an M5 cart\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, tag()); @@ -186,7 +186,7 @@ image_init_result m5_cart_slot_device::call_load() //printf("Type: %s\n", m5_get_slot(m_type)); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/m5/slot.h b/src/devices/bus/m5/slot.h index 4f0d578cf1b..6a19ab83b53 100644 --- a/src/devices/bus/m5/slot.h +++ b/src/devices/bus/m5/slot.h @@ -80,7 +80,7 @@ public: virtual ~m5_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override { } virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/mc10/mc10_cart.cpp b/src/devices/bus/mc10/mc10_cart.cpp index cd10e800410..d02314cdf93 100644 --- a/src/devices/bus/mc10/mc10_cart.cpp +++ b/src/devices/bus/mc10/mc10_cart.cpp @@ -88,23 +88,23 @@ void mc10cart_slot_device::set_nmi_line(int state) // call_load //------------------------------------------------- -image_init_result mc10cart_slot_device::call_load() +std::error_condition mc10cart_slot_device::call_load() { if (!m_cart) - return image_init_result::PASS; + return std::error_condition(); memory_region *romregion(loaded_through_softlist() ? memregion("rom") : nullptr); if (loaded_through_softlist() && !romregion) { - seterror(image_error::INVALIDIMAGE, "Software list item has no 'rom' data area"); - return image_init_result::FAIL; + osd_printf_error("%s: Software list item has no 'rom' data area\n", basename()); + return image_error::BADSOFTWARE; } u32 const len(loaded_through_softlist() ? romregion->bytes() : length()); if (len > m_cart->max_rom_length()) { - seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", basename()); + return image_error::INVALIDLENGTH; } if (!loaded_through_softlist()) @@ -114,8 +114,8 @@ image_init_result mc10cart_slot_device::call_load() u32 const cnt(fread(romregion->base(), len)); if (cnt != len) { - seterror(image_error::UNSPECIFIED, "Error reading cartridge file"); - return image_init_result::FAIL; + osd_printf_error("%s: Error reading cartridge file\n", basename()); + return image_error::UNSPECIFIED; } } @@ -189,9 +189,9 @@ int device_mc10cart_interface::max_rom_length() const load -------------------------------------------------*/ -image_init_result device_mc10cart_interface::load() +std::error_condition device_mc10cart_interface::load() { - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } //------------------------------------------------- diff --git a/src/devices/bus/mc10/mc10_cart.h b/src/devices/bus/mc10/mc10_cart.h index 4a4fc02df7c..8bfe283a6f5 100644 --- a/src/devices/bus/mc10/mc10_cart.h +++ b/src/devices/bus/mc10/mc10_cart.h @@ -53,7 +53,7 @@ public: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "mc10_cart"; } @@ -85,7 +85,7 @@ public: virtual ~device_mc10cart_interface(); virtual int max_rom_length() const; - virtual image_init_result load(); + virtual std::error_condition load(); protected: void raise_cart_nmi() { m_owning_slot->set_nmi_line(ASSERT_LINE); } diff --git a/src/devices/bus/mc10/pak.cpp b/src/devices/bus/mc10/pak.cpp index 8e27d58ab8b..2d7be4aa07e 100644 --- a/src/devices/bus/mc10/pak.cpp +++ b/src/devices/bus/mc10/pak.cpp @@ -56,14 +56,14 @@ void mc10_pak_device::device_start() // load - install rom region //------------------------------------------------- -image_init_result mc10_pak_device::load() +std::error_condition mc10_pak_device::load() { // if the host has supplied a ROM space, install it memory_region *const romregion(memregion("^rom")); if (romregion) owning_slot().memspace().install_rom(0x5000, 0x5000 + romregion->bytes(), romregion->base()); else - return image_init_result::FAIL; + return image_error::INTERNAL; - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/mc10/pak.h b/src/devices/bus/mc10/pak.h index 797cea2f691..fa2a9fd8c7b 100644 --- a/src/devices/bus/mc10/pak.h +++ b/src/devices/bus/mc10/pak.h @@ -22,7 +22,7 @@ public: mc10_pak_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); virtual int max_rom_length() const override; - virtual image_init_result load() override; + virtual std::error_condition load() override; protected: mc10_pak_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); diff --git a/src/devices/bus/megadrive/md_slot.cpp b/src/devices/bus/megadrive/md_slot.cpp index b62209d549e..1052d07ba88 100644 --- a/src/devices/bus/megadrive/md_slot.cpp +++ b/src/devices/bus/megadrive/md_slot.cpp @@ -309,12 +309,12 @@ static const char *md_get_slot(int type) -------------------------------------------------*/ -image_init_result base_md_cart_slot_device::call_load() +std::error_condition base_md_cart_slot_device::call_load() { if (m_cart) { m_type = SEGA_STD; - image_init_result res; + std::error_condition res; // STEP 1: load the file image and keep a copy for later banking // STEP 2: identify the cart type @@ -326,7 +326,7 @@ image_init_result base_md_cart_slot_device::call_load() //printf("cart type: %d\n", m_type); - if (res == image_init_result::PASS) + if (!res) { //speed-up rom access from SVP add-on, if present if (m_type == SEGA_SVP) @@ -347,11 +347,11 @@ image_init_result base_md_cart_slot_device::call_load() return res; } - return image_init_result::PASS; + return std::error_condition(); } -image_init_result base_md_cart_slot_device::load_list() +std::error_condition base_md_cart_slot_device::load_list() { uint16_t *ROM; uint32_t length = get_software_region_length("rom"); @@ -377,7 +377,7 @@ image_init_result base_md_cart_slot_device::load_list() if (m_type != SSF2 && m_type != PSOLAR && m_type != CM_2IN1) m_cart->rom_map_setup(length); - return image_init_result::PASS; + return std::error_condition(); } @@ -453,7 +453,7 @@ static int genesis_is_SMD(unsigned char *buf, unsigned int len) * softlist *************************************/ -image_init_result base_md_cart_slot_device::load_nonlist() +std::error_condition base_md_cart_slot_device::load_nonlist() { unsigned char *ROM; bool is_smd, is_md; @@ -533,7 +533,7 @@ image_init_result base_md_cart_slot_device::load_nonlist() } #endif - return image_init_result::PASS; + return std::error_condition(); } /*------------------------------------------------- diff --git a/src/devices/bus/megadrive/md_slot.h b/src/devices/bus/megadrive/md_slot.h index ede1a032c2e..3918de51d50 100644 --- a/src/devices/bus/megadrive/md_slot.h +++ b/src/devices/bus/megadrive/md_slot.h @@ -157,7 +157,7 @@ public: virtual ~base_md_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } @@ -167,8 +167,8 @@ public: int get_type() { return m_type; } - image_init_result load_list(); - image_init_result load_nonlist(); + std::error_condition load_list(); + std::error_condition load_nonlist(); static int get_cart_type(const uint8_t *ROM, uint32_t len); void setup_custom_mappers(); diff --git a/src/devices/bus/mononcol/slot.cpp b/src/devices/bus/mononcol/slot.cpp index c0129f0f1cc..171de417142 100644 --- a/src/devices/bus/mononcol/slot.cpp +++ b/src/devices/bus/mononcol/slot.cpp @@ -62,22 +62,22 @@ void mononcol_cartslot_device::device_start() call load -------------------------------------------------*/ -image_init_result mononcol_cartslot_device::call_load() +std::error_condition mononcol_cartslot_device::call_load() { if (m_cart) { memory_region *romregion(loaded_through_softlist() ? memregion("rom") : nullptr); if (loaded_through_softlist() && !romregion) { - seterror(image_error::INVALIDIMAGE, "Software list item has no 'rom' data area"); - return image_init_result::FAIL; + osd_printf_error("%s: Software list item has no 'rom' data area\n", basename()); + return image_error::BADSOFTWARE; } const u32 len = loaded_through_softlist() ? get_software_region_length("rom") : length(); if (!len || ((len - 1) & len)) { - seterror(image_error::INVALIDIMAGE, "Cartridge ROM size is not a power of 2"); - return image_init_result::FAIL; + osd_printf_error("%s: Cartridge ROM size is not a power of 2\n", basename()); + return image_error::INVALIDLENGTH; } if (!loaded_through_softlist()) @@ -87,14 +87,14 @@ image_init_result mononcol_cartslot_device::call_load() const u32 cnt = fread(romregion->base(), len); if (cnt != len) { - seterror(image_error::UNSPECIFIED, "Error reading cartridge file"); - return image_init_result::FAIL; + osd_printf_error("%s: Error reading cartridge file\n", basename()); + return image_error::UNSPECIFIED; } } m_cart->set_spi_region(romregion->base(), romregion->bytes()); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/mononcol/slot.h b/src/devices/bus/mononcol/slot.h index aa44b74b7a4..9e8567dbcf2 100644 --- a/src/devices/bus/mononcol/slot.h +++ b/src/devices/bus/mononcol/slot.h @@ -52,7 +52,7 @@ public: virtual ~mononcol_cartslot_device(); // device_image_interface implementation - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual char const *image_interface() const noexcept override { return "monon_color_cart"; } virtual char const *file_extensions() const noexcept override { return "bin"; } diff --git a/src/devices/bus/msx/beecard/beecard.cpp b/src/devices/bus/msx/beecard/beecard.cpp index bdba157d5da..1f20318e0d8 100644 --- a/src/devices/bus/msx/beecard/beecard.cpp +++ b/src/devices/bus/msx/beecard/beecard.cpp @@ -27,7 +27,7 @@ protected: // device-level overrides virtual void device_start() override { } - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; }; @@ -38,19 +38,19 @@ bee_card_nomapper_device::bee_card_nomapper_device(const machine_config &mconfig { } -image_init_result bee_card_nomapper_device::initialize_cartridge(std::string &message) +std::error_condition bee_card_nomapper_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "bee_card_nomapper_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); if (cart_rom_region()->bytes() == 0x8000) page(2)->install_rom(0x8000, 0xbfff, cart_rom_region()->base() + 0x4000); - return image_init_result::PASS; + return std::error_condition(); } } // anonymous namespace diff --git a/src/devices/bus/msx/cart/arc.cpp b/src/devices/bus/msx/cart/arc.cpp index 04f77d11677..80f012ad374 100644 --- a/src/devices/bus/msx/cart/arc.cpp +++ b/src/devices/bus/msx/cart/arc.cpp @@ -28,24 +28,24 @@ void msx_cart_arc_device::device_reset() m_7f = 0; } -image_init_result msx_cart_arc_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_arc_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_arc_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x8000) { message = "msx_cart_arc_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); page(2)->install_rom(0x8000, 0xbfff, cart_rom_region()->base() + 0x4000); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_arc_device::io_7f_w(u8 data) diff --git a/src/devices/bus/msx/cart/arc.h b/src/devices/bus/msx/cart/arc.h index 1ca0829b708..4f27b4d9e0c 100644 --- a/src/devices/bus/msx/cart/arc.h +++ b/src/devices/bus/msx/cart/arc.h @@ -16,7 +16,7 @@ class msx_cart_arc_device : public device_t, public msx_cart_interface public: msx_cart_arc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/ascii.cpp b/src/devices/bus/msx/cart/ascii.cpp index 7faa12f3c55..d887de4996e 100644 --- a/src/devices/bus/msx/cart/ascii.cpp +++ b/src/devices/bus/msx/cart/ascii.cpp @@ -24,12 +24,12 @@ void msx_cart_ascii8_device::device_reset() m_rombank[i]->set_entry(0); } -image_init_result msx_cart_ascii8_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_ascii8_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_ascii8_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -38,7 +38,7 @@ image_init_result msx_cart_ascii8_device::initialize_cartridge(std::string &mess if (size > 256 * BANK_SIZE || size != banks * BANK_SIZE || (~(banks - 1) % banks)) { message = "msx_cart_ascii8_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bank_mask = banks - 1; @@ -55,7 +55,7 @@ image_init_result msx_cart_ascii8_device::initialize_cartridge(std::string &mess page(2)->install_read_bank(0x8000, 0x9fff, m_rombank[2]); page(2)->install_read_bank(0xa000, 0xbfff, m_rombank[3]); - return image_init_result::PASS; + return std::error_condition(); } template @@ -80,12 +80,12 @@ void msx_cart_ascii16_device::device_reset() m_rombank[1]->set_entry(0); } -image_init_result msx_cart_ascii16_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_ascii16_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_ascii16_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -94,7 +94,7 @@ image_init_result msx_cart_ascii16_device::initialize_cartridge(std::string &mes if (size > 256 * BANK_SIZE || size != banks * BANK_SIZE || (~(banks - 1) % banks)) { message = "msx_cart_ascii16_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bank_mask = banks - 1; @@ -107,7 +107,7 @@ image_init_result msx_cart_ascii16_device::initialize_cartridge(std::string &mes page(1)->install_write_handler(0x7000, 0x77ff, write8smo_delegate(*this, FUNC(msx_cart_ascii16_device::bank_w<1>))); page(2)->install_read_bank(0x8000, 0xbfff, m_rombank[1]); - return image_init_result::PASS; + return std::error_condition(); } template @@ -139,18 +139,18 @@ void msx_cart_ascii8_sram_device::device_reset() m_view3.select(0); } -image_init_result msx_cart_ascii8_sram_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_ascii8_sram_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_ascii8_sram_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (!cart_sram_region()) { message = "msx_cart_ascii8_sram_device: Required region 'sram' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -159,13 +159,13 @@ image_init_result msx_cart_ascii8_sram_device::initialize_cartridge(std::string if (size > 128 * BANK_SIZE || size != banks * BANK_SIZE || (~(banks - 1) % banks)) { message = "msx_cart_ascii8_sram_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } if (cart_sram_region()->bytes() < 0x2000) { message = "msx_cart_ascii8_sram_device: Region 'sram' has unsupported size."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } m_bank_mask = banks - 1; @@ -184,7 +184,7 @@ image_init_result msx_cart_ascii8_sram_device::initialize_cartridge(std::string m_view3[0].install_read_bank(0xa000, 0xbfff, m_rombank[3]); m_view3[1].install_ram(0xa000, 0xbfff, cart_sram_region()->base()); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_ascii8_sram_device::mapper_write(offs_t offset, u8 data) @@ -232,18 +232,18 @@ void msx_cart_ascii16_sram_device::device_reset() m_rombank[1]->set_entry(0); } -image_init_result msx_cart_ascii16_sram_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_ascii16_sram_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_ascii16_sram_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (!cart_sram_region()) { message = "msx_cart_ascii16_sram_device: Required region 'sram' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -252,13 +252,13 @@ image_init_result msx_cart_ascii16_sram_device::initialize_cartridge(std::string if (size > 128 * BANK_SIZE || size != banks * BANK_SIZE || (~(banks - 1) % banks)) { message = "msx_cart_ascii16_sram_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } if (cart_sram_region()->bytes() < 0x800) { message = "msx_cart_ascii16_sram_device: Region 'sram' has unsupported size."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } m_bank_mask = banks - 1; @@ -274,7 +274,7 @@ image_init_result msx_cart_ascii16_sram_device::initialize_cartridge(std::string m_view[0].install_read_bank(0x8000, 0xbfff, m_rombank[1]); m_view[1].install_ram(0x8000, 0x87ff, 0x3800, cart_sram_region()->base()); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_ascii16_sram_device::mapper_write_6000(u8 data) diff --git a/src/devices/bus/msx/cart/ascii.h b/src/devices/bus/msx/cart/ascii.h index b6dd2e6a54e..28522bce9fc 100644 --- a/src/devices/bus/msx/cart/ascii.h +++ b/src/devices/bus/msx/cart/ascii.h @@ -19,7 +19,7 @@ class msx_cart_ascii8_device : public device_t, public msx_cart_interface public: msx_cart_ascii8_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -41,7 +41,7 @@ class msx_cart_ascii16_device : public device_t, public msx_cart_interface public: msx_cart_ascii16_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -63,7 +63,7 @@ class msx_cart_ascii8_sram_device : public device_t, public msx_cart_interface public: msx_cart_ascii8_sram_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -88,7 +88,7 @@ class msx_cart_ascii16_sram_device : public device_t, public msx_cart_interface public: msx_cart_ascii16_sram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/beepack.cpp b/src/devices/bus/msx/cart/beepack.cpp index e370c66ca81..88314493c77 100644 --- a/src/devices/bus/msx/cart/beepack.cpp +++ b/src/devices/bus/msx/cart/beepack.cpp @@ -40,7 +40,7 @@ void msx_cart_beepack_device::device_add_mconfig(machine_config &config) SOFTWARE_LIST(config, "bee_card_list").set_original("msx1_bee_card"); } -image_init_result msx_cart_beepack_device::call_load() +std::error_condition msx_cart_beepack_device::call_load() { if (m_beecard) { @@ -50,8 +50,8 @@ image_init_result msx_cart_beepack_device::call_load() // Only 16KB or 32KB images are supported if (length != 0x4000 && length != 0x8000) { - seterror(image_error::UNSPECIFIED, "Invalid file size for a bee card"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid file size for a bee card\n", basename()); + return image_error::BADSOFTWARE; } } else @@ -60,26 +60,26 @@ image_init_result msx_cart_beepack_device::call_load() // Only 16KB or 32KB images are supported if (length != 0x4000 && length != 0x8000) { - seterror(image_error::UNSPECIFIED, "Invalid file size for a bee card"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid file size for a bee card\n", basename()); + return image_error::INVALIDLENGTH; } memory_region *const romregion = machine().memory().region_alloc(subtag("rom"), length, 1, ENDIANNESS_LITTLE); if (fread(romregion->base(), length) != length) { - seterror(image_error::UNSPECIFIED, "Unable to fully read file"); - return image_init_result::FAIL; + osd_printf_error("%s: Unable to fully read file\n", basename()); + return image_error::UNSPECIFIED; } } std::string message; - image_init_result result = m_beecard->initialize_cartridge(message); - if (image_init_result::PASS != result) - seterror(image_error::INVALIDIMAGE, message.c_str()); + std::error_condition result = m_beecard->initialize_cartridge(message); + if (result) + osd_printf_error("%s: %s\n", basename(), message); return result; } - return image_init_result::PASS; + return std::error_condition(); } std::string msx_cart_beepack_device::get_default_card_software(get_default_card_software_hook &hook) const diff --git a/src/devices/bus/msx/cart/beepack.h b/src/devices/bus/msx/cart/beepack.h index 1dd4368b7bb..f2ef30644b6 100644 --- a/src/devices/bus/msx/cart/beepack.h +++ b/src/devices/bus/msx/cart/beepack.h @@ -23,7 +23,7 @@ public: msx_cart_beepack_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "bee_card"; } virtual const char *file_extensions() const noexcept override { return "bin,rom"; } @@ -41,7 +41,7 @@ protected: class bee_card_interface : public device_interface { public: - virtual image_init_result initialize_cartridge(std::string &message) { return image_init_result::PASS; } + virtual std::error_condition initialize_cartridge(std::string &message) { return std::error_condition(); } void set_views(memory_view::memory_view_entry *page0, memory_view::memory_view_entry *page1, memory_view::memory_view_entry *page2, memory_view::memory_view_entry *page3); protected: diff --git a/src/devices/bus/msx/cart/crossblaim.cpp b/src/devices/bus/msx/cart/crossblaim.cpp index 2c3dedfd91c..e783bda086b 100644 --- a/src/devices/bus/msx/cart/crossblaim.cpp +++ b/src/devices/bus/msx/cart/crossblaim.cpp @@ -13,18 +13,18 @@ msx_cart_crossblaim_device::msx_cart_crossblaim_device(const machine_config &mco { } -image_init_result msx_cart_crossblaim_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_crossblaim_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_crossblaim_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x10000) { message = "msx_cart_crossblaim_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_rombank->configure_entries(0, 4, cart_rom_region()->base(), 0x4000); @@ -33,7 +33,7 @@ image_init_result msx_cart_crossblaim_device::initialize_cartridge(std::string & page(1)->install_write_handler(0x4045, 0x4045, write8smo_delegate(*this, FUNC(msx_cart_crossblaim_device::mapper_write))); page(2)->install_read_bank(0x8000, 0xbfff, m_rombank); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_crossblaim_device::mapper_write(u8 data) diff --git a/src/devices/bus/msx/cart/crossblaim.h b/src/devices/bus/msx/cart/crossblaim.h index 5f484f6a304..1c8e96511b9 100644 --- a/src/devices/bus/msx/cart/crossblaim.h +++ b/src/devices/bus/msx/cart/crossblaim.h @@ -16,7 +16,7 @@ class msx_cart_crossblaim_device : public device_t, public msx_cart_interface public: msx_cart_crossblaim_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/disk.cpp b/src/devices/bus/msx/cart/disk.cpp index 227b8d48b19..7074b5828dc 100644 --- a/src/devices/bus/msx/cart/disk.cpp +++ b/src/devices/bus/msx/cart/disk.cpp @@ -175,7 +175,7 @@ void msx_floppies(device_slot_interface &device) class msx_cart_disk_device : public device_t, public msx_cart_interface { public: - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: msx_cart_disk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int fdc_regs_start_page, int fdc_regs_end_page) @@ -217,21 +217,21 @@ void msx_cart_disk_device::floppy_formats(format_registration &fr) fr.add(FLOPPY_DMK_FORMAT); } -image_init_result msx_cart_disk_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_disk_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_disk_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x4000) { message = "msx_cart_disk_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_disk_device::softlist_35(machine_config &config) @@ -310,7 +310,7 @@ protected: class disk_type1_device : public disk_wd_device { public: - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: disk_type1_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int fdc_regs_start_page = PAGE1, int fdc_regs_end_page = PAGE2) @@ -343,10 +343,10 @@ void disk_type1_device::device_start() save_item(NAME(m_control)); } -image_init_result disk_type1_device::initialize_cartridge(std::string &message) +std::error_condition disk_type1_device::initialize_cartridge(std::string &message) { - image_init_result result = disk_wd_device::initialize_cartridge(message); - if (image_init_result::PASS != result) + std::error_condition result = disk_wd_device::initialize_cartridge(message); + if (result) return result; page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); @@ -368,7 +368,7 @@ image_init_result disk_type1_device::initialize_cartridge(std::string &message) page(i)->install_write_handler(base + 0x3ffd, base + 0x3ffd, write8smo_delegate(*this, FUNC(disk_type1_device::set_control))); } - return image_init_result::PASS; + return std::error_condition(); } void disk_type1_device::device_post_load() @@ -588,7 +588,7 @@ protected: class disk_type2_device : public disk_wd_device { public: - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: disk_type2_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, int fdc_regs_start_page = PAGE1, int fdc_regs_end_page = PAGE2) @@ -620,10 +620,10 @@ void disk_type2_device::device_post_load() set_control(m_control); } -image_init_result disk_type2_device::initialize_cartridge(std::string &message) +std::error_condition disk_type2_device::initialize_cartridge(std::string &message) { - image_init_result result = disk_wd_device::initialize_cartridge(message); - if (image_init_result::PASS != result) + std::error_condition result = disk_wd_device::initialize_cartridge(message); + if (result) return result; page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); @@ -642,7 +642,7 @@ image_init_result disk_type2_device::initialize_cartridge(std::string &message) page(i)->install_write_handler(base + 0x3fbc, base + 0x3fbc, write8smo_delegate(*this, FUNC(disk_type2_device::set_control))); } - return image_init_result::PASS; + return std::error_condition(); } void disk_type2_device::set_control(u8 data) @@ -723,7 +723,7 @@ protected: class disk_type5_device : public disk_wd_device { public: - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: disk_type5_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) @@ -746,10 +746,10 @@ void disk_type5_device::device_start() save_item(NAME(m_control)); } -image_init_result disk_type5_device::initialize_cartridge(std::string &message) +std::error_condition disk_type5_device::initialize_cartridge(std::string &message) { - image_init_result result = disk_wd_device::initialize_cartridge(message); - if (image_init_result::PASS != result) + std::error_condition result = disk_wd_device::initialize_cartridge(message); + if (result) return result; page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); @@ -766,7 +766,7 @@ image_init_result disk_type5_device::initialize_cartridge(std::string &message) io_space().install_read_handler(0xd3, 0xd3, read8smo_delegate(*m_fdc, FUNC(wd_fdc_analog_device_base::data_r))); io_space().install_read_handler(0xd4, 0xd4, read8smo_delegate(*this, FUNC(disk_type5_device::status_r))); - return image_init_result::PASS; + return std::error_condition(); } void disk_type5_device::device_post_load() @@ -846,7 +846,7 @@ public: : disk_tc8566_device(mconfig, MSX_CART_FSFD1A, tag, owner, clock) { } - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -858,10 +858,10 @@ protected: } }; -image_init_result fsfd1a_device::initialize_cartridge(std::string &message) +std::error_condition fsfd1a_device::initialize_cartridge(std::string &message) { - image_init_result result = disk_tc8566_device::initialize_cartridge(message); - if (image_init_result::PASS != result) + std::error_condition result = disk_tc8566_device::initialize_cartridge(message); + if (result) return result; page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); @@ -875,7 +875,7 @@ image_init_result fsfd1a_device::initialize_cartridge(std::string &message) page(i)->install_write_handler(base + 0x3ffb, base + 0x3ffb, write8smo_delegate(*m_fdc, FUNC(tc8566af_device::fifo_w))); } - return image_init_result::PASS; + return std::error_condition(); } @@ -889,7 +889,7 @@ public: , m_control(0) { } - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -918,18 +918,18 @@ void fd03_device::device_start() save_item(NAME(m_control)); } -image_init_result fd03_device::initialize_cartridge(std::string &message) +std::error_condition fd03_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "fd03_device:: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x4000 && cart_rom_region()->bytes() != 0x8000) { message = "fd03_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); @@ -953,7 +953,7 @@ image_init_result fd03_device::initialize_cartridge(std::string &message) page(i)->install_write_handler(base + 0x3ff0, base + 0x3fff, write8smo_delegate(*this, FUNC(fd03_device::dskchg_w))); } - return image_init_result::PASS; + return std::error_condition(); } void fd03_device::device_post_load() @@ -1040,7 +1040,7 @@ public: , m_drive_select1(0) { } - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -1075,10 +1075,10 @@ void hxf101pe_device::device_start() save_item(NAME(m_drive_select1)); } -image_init_result hxf101pe_device::initialize_cartridge(std::string &message) +std::error_condition hxf101pe_device::initialize_cartridge(std::string &message) { - image_init_result result = disk_wd_device::initialize_cartridge(message); - if (image_init_result::PASS != result) + std::error_condition result = disk_wd_device::initialize_cartridge(message); + if (result) return result; page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); @@ -1098,7 +1098,7 @@ image_init_result hxf101pe_device::initialize_cartridge(std::string &message) page(1)->install_write_handler(0x7ff5, 0x7ff5, 0, 0x0008, 0, write8smo_delegate(*this, FUNC(hxf101pe_device::select0_w))); page(1)->install_write_handler(0x7ff6, 0x7ff6, 0, 0x0008, 0, write8smo_delegate(*this, FUNC(hxf101pe_device::select1_w))); - return image_init_result::PASS; + return std::error_condition(); } void hxf101pe_device::device_post_load() @@ -1193,7 +1193,7 @@ public: , m_control(0) { } - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -1214,10 +1214,10 @@ void mfd001_device::device_add_mconfig(machine_config &config) add_mconfig(config, MB8877); } -image_init_result mfd001_device::initialize_cartridge(std::string &message) +std::error_condition mfd001_device::initialize_cartridge(std::string &message) { - image_init_result result = disk_wd_device::initialize_cartridge(message); - if (image_init_result::PASS != result) + std::error_condition result = disk_wd_device::initialize_cartridge(message); + if (result) return result; page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); @@ -1237,7 +1237,7 @@ image_init_result mfd001_device::initialize_cartridge(std::string &message) page(i)->install_write_handler(base + 0x3ffc, base + 0x3ffc, write8smo_delegate(*this, FUNC(mfd001_device::control_w))); } - return image_init_result::PASS; + return std::error_condition(); } void mfd001_device::device_start() @@ -1296,7 +1296,7 @@ public: , m_control(0) { } - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -1321,10 +1321,10 @@ void avdpf550_device::device_start() save_item(NAME(m_control)); } -image_init_result avdpf550_device::initialize_cartridge(std::string &message) +std::error_condition avdpf550_device::initialize_cartridge(std::string &message) { - image_init_result result = disk_wd_device::initialize_cartridge(message); - if (image_init_result::PASS != result) + std::error_condition result = disk_wd_device::initialize_cartridge(message); + if (result) return result; page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); @@ -1341,7 +1341,7 @@ image_init_result avdpf550_device::initialize_cartridge(std::string &message) io_space().install_read_handler(0xd3, 0xd3, read8smo_delegate(*m_fdc, FUNC(wd_fdc_analog_device_base::data_r))); io_space().install_read_handler(0xd4, 0xd4, read8smo_delegate(*this, FUNC(avdpf550_device::status_r))); - return image_init_result::PASS; + return std::error_condition(); } void avdpf550_device::device_post_load() diff --git a/src/devices/bus/msx/cart/dooly.cpp b/src/devices/bus/msx/cart/dooly.cpp index b46df578034..8c7fe5e4f3d 100644 --- a/src/devices/bus/msx/cart/dooly.cpp +++ b/src/devices/bus/msx/cart/dooly.cpp @@ -21,18 +21,18 @@ void msx_cart_dooly_device::device_reset() m_view2.select(0); } -image_init_result msx_cart_dooly_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_dooly_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_dooly_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x8000) { message = "msx_cart_dooly_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } page(1)->install_view(0x4000, 0x7fff, m_view1); @@ -45,7 +45,7 @@ image_init_result msx_cart_dooly_device::initialize_cartridge(std::string &messa page(1)->install_write_handler(0x4000, 0x7fff, write8smo_delegate(*this, FUNC(msx_cart_dooly_device::prot_w))); page(2)->install_write_handler(0x8000, 0xbfff, write8smo_delegate(*this, FUNC(msx_cart_dooly_device::prot_w))); - return image_init_result::PASS; + return std::error_condition(); } u8 msx_cart_dooly_device::mode4_page1_r(offs_t offset) diff --git a/src/devices/bus/msx/cart/dooly.h b/src/devices/bus/msx/cart/dooly.h index f509a6dad65..39f4f08b7c1 100644 --- a/src/devices/bus/msx/cart/dooly.h +++ b/src/devices/bus/msx/cart/dooly.h @@ -16,7 +16,7 @@ class msx_cart_dooly_device : public device_t, public msx_cart_interface public: msx_cart_dooly_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/easi_speech.cpp b/src/devices/bus/msx/cart/easi_speech.cpp index d89e7e68457..533c44bbee1 100644 --- a/src/devices/bus/msx/cart/easi_speech.cpp +++ b/src/devices/bus/msx/cart/easi_speech.cpp @@ -45,25 +45,25 @@ void msx_cart_easispeech_device::device_add_mconfig(machine_config &config) m_speech->add_route(ALL_OUTPUTS, ":speaker", 1.00); } -image_init_result msx_cart_easispeech_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_easispeech_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_easispeech_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x2000) { message = "msx_cart_easispeech_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } page(1)->install_rom(0x4000, 0x5fff, 0x2000, cart_rom_region()->base()); page(2)->install_read_handler(0x8000, 0x8000, read8smo_delegate(*this, FUNC(msx_cart_easispeech_device::speech_r))); page(2)->install_write_handler(0x8000, 0x8000, write8smo_delegate(*this, FUNC(msx_cart_easispeech_device::speech_w))); - return image_init_result::PASS; + return std::error_condition(); } u8 msx_cart_easispeech_device::speech_r() diff --git a/src/devices/bus/msx/cart/easi_speech.h b/src/devices/bus/msx/cart/easi_speech.h index b07b46e920f..dfbe9c62614 100644 --- a/src/devices/bus/msx/cart/easi_speech.h +++ b/src/devices/bus/msx/cart/easi_speech.h @@ -17,7 +17,7 @@ class msx_cart_easispeech_device : public device_t, public msx_cart_interface public: msx_cart_easispeech_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/fmpac.cpp b/src/devices/bus/msx/cart/fmpac.cpp index 7a223e986fc..d393310e451 100644 --- a/src/devices/bus/msx/cart/fmpac.cpp +++ b/src/devices/bus/msx/cart/fmpac.cpp @@ -59,30 +59,30 @@ void msx_cart_fmpac_device::device_reset() } -image_init_result msx_cart_fmpac_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_fmpac_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_fmpac_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (!cart_sram_region()) { message = "msx_cart_fmpac_device: Required region 'sram' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x10000) { message = "msx_cart_fmpac_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } if (cart_sram_region()->bytes() < 0x2000) { message = "msx_cart_fmpac_device: Region 'sram' has unsupported size."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } m_rombank->configure_entries(0, 4, cart_rom_region()->base(), 0x4000); @@ -104,7 +104,7 @@ image_init_result msx_cart_fmpac_device::initialize_cartridge(std::string &messa m_view[1].install_read_handler(0x7ff7, 0x7ff7, read8smo_delegate(*this, FUNC(msx_cart_fmpac_device::bank_r))); m_view[1].install_write_handler(0x7ff7, 0x7ff7, write8smo_delegate(*this, FUNC(msx_cart_fmpac_device::bank_w))); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_fmpac_device::sram_unlock(offs_t offset, u8 data) diff --git a/src/devices/bus/msx/cart/fmpac.h b/src/devices/bus/msx/cart/fmpac.h index f63e517780c..451d621f86e 100644 --- a/src/devices/bus/msx/cart/fmpac.h +++ b/src/devices/bus/msx/cart/fmpac.h @@ -17,7 +17,7 @@ class msx_cart_fmpac_device : public device_t, public msx_cart_interface public: msx_cart_fmpac_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: virtual void device_start() override; diff --git a/src/devices/bus/msx/cart/fs_sr022.cpp b/src/devices/bus/msx/cart/fs_sr022.cpp index 4c5ab2d98d4..85afe3a9ef2 100644 --- a/src/devices/bus/msx/cart/fs_sr022.cpp +++ b/src/devices/bus/msx/cart/fs_sr022.cpp @@ -25,18 +25,18 @@ void msx_cart_fs_sr022_device::device_reset() m_bunsetsu_address = 0; } -image_init_result msx_cart_fs_sr022_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_fs_sr022_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_fs_sr022_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x40000) { message = "msx_cart_fs_sr022_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bunsetsu_rom = cart_rom_region()->base() + 0x20000; @@ -46,7 +46,7 @@ image_init_result msx_cart_fs_sr022_device::initialize_cartridge(std::string &me page(2)->install_read_handler(0xbfff, 0xbfff, read8smo_delegate(*this, FUNC(msx_cart_fs_sr022_device::buns_r))); page(2)->install_write_handler(0xbffc, 0xbffe, write8sm_delegate(*this, FUNC(msx_cart_fs_sr022_device::buns_w))); - return image_init_result::PASS; + return std::error_condition(); } u8 msx_cart_fs_sr022_device::buns_r() diff --git a/src/devices/bus/msx/cart/fs_sr022.h b/src/devices/bus/msx/cart/fs_sr022.h index 22bb0c72c5a..1a4f9692fc7 100644 --- a/src/devices/bus/msx/cart/fs_sr022.h +++ b/src/devices/bus/msx/cart/fs_sr022.h @@ -16,7 +16,7 @@ class msx_cart_fs_sr022_device : public device_t, public msx_cart_interface public: msx_cart_fs_sr022_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/halnote.cpp b/src/devices/bus/msx/cart/halnote.cpp index c7e42401d8c..a9e8cf69f11 100644 --- a/src/devices/bus/msx/cart/halnote.cpp +++ b/src/devices/bus/msx/cart/halnote.cpp @@ -25,30 +25,30 @@ void msx_cart_halnote_device::device_reset() m_view1.select(0); } -image_init_result msx_cart_halnote_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_halnote_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_halnote_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (!cart_sram_region()) { message = "msx_cart_halnote_device: Required region 'sram' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x100000) { message = "msx_cart_halnote_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } if (cart_sram_region()->bytes() < 0x4000) { message = "msx_cart_halnote_device: Region 'sram' has unsupported size."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } for (int i = 0; i < 4; i++) @@ -79,7 +79,7 @@ image_init_result msx_cart_halnote_device::initialize_cartridge(std::string &mes page(2)->install_read_bank(0xa000, 0xbfff, m_rombank[3]); page(2)->install_write_handler(0xafff, 0xafff, write8smo_delegate(*this, FUNC(msx_cart_halnote_device::bank3_w))); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_halnote_device::bank0_w(u8 data) diff --git a/src/devices/bus/msx/cart/halnote.h b/src/devices/bus/msx/cart/halnote.h index 87a3d584f81..79fb328045b 100644 --- a/src/devices/bus/msx/cart/halnote.h +++ b/src/devices/bus/msx/cart/halnote.h @@ -16,7 +16,7 @@ class msx_cart_halnote_device : public device_t, public msx_cart_interface public: msx_cart_halnote_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/hfox.cpp b/src/devices/bus/msx/cart/hfox.cpp index 9a749614d3c..7c91778ed10 100644 --- a/src/devices/bus/msx/cart/hfox.cpp +++ b/src/devices/bus/msx/cart/hfox.cpp @@ -20,12 +20,12 @@ void msx_cart_hfox_device::device_reset() m_rombank[1]->set_entry(0); } -image_init_result msx_cart_hfox_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_hfox_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_hfox_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -34,7 +34,7 @@ image_init_result msx_cart_hfox_device::initialize_cartridge(std::string &messag if (size > 256 * 0x8000 || size < 0x10000 || size != banks * 0x8000 || (~(banks - 1) % banks)) { message = "msx_cart_hfox_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bank_mask = banks - 1; @@ -47,7 +47,7 @@ image_init_result msx_cart_hfox_device::initialize_cartridge(std::string &messag page(1)->install_write_handler(0x7000, 0x7000, write8smo_delegate(*this, FUNC(msx_cart_hfox_device::bank_w<1>))); page(2)->install_read_bank(0x8000, 0xbfff, m_rombank[1]); - return image_init_result::PASS; + return std::error_condition(); } template diff --git a/src/devices/bus/msx/cart/hfox.h b/src/devices/bus/msx/cart/hfox.h index 2b500629e1f..bbc485d3ec7 100644 --- a/src/devices/bus/msx/cart/hfox.h +++ b/src/devices/bus/msx/cart/hfox.h @@ -16,7 +16,7 @@ class msx_cart_hfox_device : public device_t, public msx_cart_interface public: msx_cart_hfox_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/holy_quran.cpp b/src/devices/bus/msx/cart/holy_quran.cpp index b9e178f4694..f63247e3cf7 100644 --- a/src/devices/bus/msx/cart/holy_quran.cpp +++ b/src/devices/bus/msx/cart/holy_quran.cpp @@ -25,12 +25,12 @@ msx_cart_holy_quran_device::msx_cart_holy_quran_device(const machine_config &mco { } -image_init_result msx_cart_holy_quran_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_holy_quran_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_holy_quran_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -39,7 +39,7 @@ image_init_result msx_cart_holy_quran_device::initialize_cartridge(std::string & if (size > 256 * BANK_SIZE || size < 0x10000 || size != banks * BANK_SIZE || (~(banks - 1) % banks)) { message = "msx_cart_holy_quran_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bank_mask = banks - 1; @@ -72,7 +72,7 @@ image_init_result msx_cart_holy_quran_device::initialize_cartridge(std::string & m_view2[1].install_read_bank(0x8000, 0x9fff, m_rombank[2]); m_view2[1].install_read_bank(0xa000, 0xbfff, m_rombank[3]); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_holy_quran_device::device_reset() diff --git a/src/devices/bus/msx/cart/holy_quran.h b/src/devices/bus/msx/cart/holy_quran.h index 0cd66a2dd97..5a2fe58ffa2 100644 --- a/src/devices/bus/msx/cart/holy_quran.h +++ b/src/devices/bus/msx/cart/holy_quran.h @@ -16,7 +16,7 @@ class msx_cart_holy_quran_device : public device_t, public msx_cart_interface public: msx_cart_holy_quran_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/ink.cpp b/src/devices/bus/msx/cart/ink.cpp index 45b77f77034..b4571495ad3 100644 --- a/src/devices/bus/msx/cart/ink.cpp +++ b/src/devices/bus/msx/cart/ink.cpp @@ -36,12 +36,12 @@ void msx_cart_ink_device::device_add_mconfig(machine_config &config) AMD_29F040(config, m_flash); } -image_init_result msx_cart_ink_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_ink_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_ink_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const size_t size = std::min(0x80000, cart_rom_region()->bytes()); @@ -58,7 +58,7 @@ image_init_result msx_cart_ink_device::initialize_cartridge(std::string &message page(2)->install_write_handler(0x8000, 0xbfff, write8sm_delegate(*this, FUNC(msx_cart_ink_device::write_page<2>))); page(3)->install_write_handler(0xc000, 0xffff, write8sm_delegate(*this, FUNC(msx_cart_ink_device::write_page<3>))); - return image_init_result::PASS; + return std::error_condition(); } template diff --git a/src/devices/bus/msx/cart/ink.h b/src/devices/bus/msx/cart/ink.h index c8c6c2d0104..9c191a340c4 100644 --- a/src/devices/bus/msx/cart/ink.h +++ b/src/devices/bus/msx/cart/ink.h @@ -17,7 +17,7 @@ class msx_cart_ink_device : public device_t, public msx_cart_interface public: msx_cart_ink_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/kanji.cpp b/src/devices/bus/msx/cart/kanji.cpp index 6b28136727f..97c5a60c8ee 100644 --- a/src/devices/bus/msx/cart/kanji.cpp +++ b/src/devices/bus/msx/cart/kanji.cpp @@ -46,21 +46,21 @@ void msx_cart_kanji_device::device_start() save_item(NAME(m_kanji_address)); } -image_init_result msx_cart_kanji_device::validate_kanji_regions(std::string &message) +std::error_condition msx_cart_kanji_device::validate_kanji_regions(std::string &message) { if (!cart_kanji_region()) { message = "msx_cart_kanji_device: Required region 'kanji' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_kanji_region()->bytes() != 0x20000) { message = "msx_cart_kanji_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_kanji_device::install_kanji_handlers() @@ -72,15 +72,15 @@ void msx_cart_kanji_device::install_kanji_handlers() io_space().install_read_handler(0xd9, 0xd9, read8sm_delegate(*this, FUNC(msx_cart_kanji_device::kanji_r))); } -image_init_result msx_cart_kanji_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_kanji_device::initialize_cartridge(std::string &message) { - image_init_result result = validate_kanji_regions(message); - if (image_init_result::PASS != result) + std::error_condition result = validate_kanji_regions(message); + if (result) return result; install_kanji_handlers(); - return image_init_result::PASS; + return std::error_condition(); } u8 msx_cart_kanji_device::kanji_r(offs_t offset) @@ -138,16 +138,16 @@ void msx_cart_msxwrite_device::device_reset() install_kanji_handlers(); } -image_init_result msx_cart_msxwrite_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_msxwrite_device::initialize_cartridge(std::string &message) { - image_init_result result = validate_kanji_regions(message); - if (image_init_result::PASS != result) + std::error_condition result = validate_kanji_regions(message); + if (result) return result; if (!cart_rom_region()) { message = "msx_cart_msxwrite_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -156,7 +156,7 @@ image_init_result msx_cart_msxwrite_device::initialize_cartridge(std::string &me if (size > 256 * BANK_SIZE || size != banks * BANK_SIZE || (~(banks - 1) % banks)) { message = "msx_cart_msxwrite_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bank_mask = banks - 1; @@ -171,7 +171,7 @@ image_init_result msx_cart_msxwrite_device::initialize_cartridge(std::string &me page(1)->install_write_handler(0x7fff, 0x7fff, write8smo_delegate(*this, FUNC(msx_cart_msxwrite_device::bank_w<1>))); page(2)->install_read_bank(0x8000, 0xbfff, m_rombank[1]); - return image_init_result::PASS; + return std::error_condition(); } template diff --git a/src/devices/bus/msx/cart/kanji.h b/src/devices/bus/msx/cart/kanji.h index 15e3bd6cd03..f3620455771 100644 --- a/src/devices/bus/msx/cart/kanji.h +++ b/src/devices/bus/msx/cart/kanji.h @@ -17,7 +17,7 @@ class msx_cart_kanji_device : public device_t, public msx_cart_interface public: msx_cart_kanji_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: msx_cart_kanji_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); @@ -26,7 +26,7 @@ protected: virtual void device_start() override; virtual void device_reset() override; - image_init_result validate_kanji_regions(std::string &message); + std::error_condition validate_kanji_regions(std::string &message); void install_kanji_handlers(); u8 kanji_r(offs_t offset); @@ -42,7 +42,7 @@ class msx_cart_msxwrite_device : public msx_cart_kanji_device public: msx_cart_msxwrite_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/konami.cpp b/src/devices/bus/msx/cart/konami.cpp index 7742dda5540..5dc358cb4a9 100644 --- a/src/devices/bus/msx/cart/konami.cpp +++ b/src/devices/bus/msx/cart/konami.cpp @@ -30,12 +30,12 @@ void msx_cart_konami_device::device_reset() m_rombank[i]->set_entry(i); } -image_init_result msx_cart_konami_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_konami_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_konami_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -44,7 +44,7 @@ image_init_result msx_cart_konami_device::initialize_cartridge(std::string &mess if (size > 256 * 0x2000 || size < 4 * 0x2000 || size != banks * 0x2000 || (~(banks - 1) % banks)) { message = "msx_cart_konami_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bank_mask = banks - 1; @@ -65,7 +65,7 @@ image_init_result msx_cart_konami_device::initialize_cartridge(std::string &mess page(3)->install_read_bank(0xc000, 0xdfff, m_rombank[2]); page(3)->install_read_bank(0xe000, 0xffff, m_rombank[3]); - return image_init_result::PASS; + return std::error_condition(); } template @@ -101,12 +101,12 @@ void msx_cart_konami_scc_device::device_reset() m_rombank[i]->set_entry(i); } -image_init_result msx_cart_konami_scc_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_konami_scc_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_konami_scc_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -115,7 +115,7 @@ image_init_result msx_cart_konami_scc_device::initialize_cartridge(std::string & if (size > 256 * 0x2000 || size < 0x8000 || size != banks * 0x2000 || (~(banks - 1) % banks)) { message = "msx_cart_konami_scc_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bank_mask = banks - 1; @@ -148,7 +148,7 @@ image_init_result msx_cart_konami_scc_device::initialize_cartridge(std::string & page(3)->install_read_bank(0xc000, 0xdfff, m_rombank[0]); page(3)->install_read_bank(0xe000, 0xffff, m_rombank[1]); - return image_init_result::PASS; + return std::error_condition(); } template @@ -187,18 +187,18 @@ void msx_cart_gamemaster2_device::device_reset() m_view2.select(0); } -image_init_result msx_cart_gamemaster2_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_gamemaster2_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_gamemaster2_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (!cart_sram_region()) { message = "msx_cart_gamemaster2_device: Required region 'sram' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -207,13 +207,13 @@ image_init_result msx_cart_gamemaster2_device::initialize_cartridge(std::string if (size != 0x20000) { message = "msx_cart_gamemaster2_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } if (cart_sram_region()->bytes() != 0x2000) { message = "msx_cart_gamemaster2_device: Region 'sram' has unsupported size."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } for (int i = 0; i < 3; i++) @@ -243,7 +243,7 @@ image_init_result msx_cart_gamemaster2_device::initialize_cartridge(std::string m_view2[1].install_write_handler(0xa000, 0xafff, write8smo_delegate(*this, FUNC(msx_cart_gamemaster2_device::bank_w<2>))); m_view2[1].install_readwrite_bank(0xb000, 0xbfff, m_rambank[2]); - return image_init_result::PASS; + return std::error_condition(); } template @@ -277,25 +277,25 @@ void msx_cart_synthesizer_device::device_add_mconfig(machine_config &config) DAC_8BIT_R2R(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.3); // unknown DAC } -image_init_result msx_cart_synthesizer_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_synthesizer_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_synthesizer_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x8000) { message = "msx_cart_synthesizer_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); page(1)->install_write_handler(0x4000, 0x4000, 0, 0x3fef, 0, write8smo_delegate(m_dac, FUNC(dac_byte_interface::write))); page(2)->install_rom(0x8000, 0xbfff, cart_rom_region()->base() + 0x4000); - return image_init_result::PASS; + return std::error_condition(); } @@ -343,7 +343,7 @@ void msx_cart_konami_sound_device::device_reset() switch_bank<3>(); } -image_init_result msx_cart_konami_sound_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_konami_sound_device::initialize_cartridge(std::string &message) { for (int i = 0; i < 4; i++) { @@ -428,7 +428,7 @@ image_init_result msx_cart_konami_sound_device::initialize_cartridge(std::string page(2)->install_write_handler(0xbffe, 0xbfff, write8smo_delegate(*this, FUNC(msx_cart_konami_sound_device::control_w))); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_konami_sound_device::control_w(u8 data) @@ -488,18 +488,18 @@ msx_cart_konami_sound_snatcher_device::msx_cart_konami_sound_snatcher_device(con { } -image_init_result msx_cart_konami_sound_snatcher_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_konami_sound_snatcher_device::initialize_cartridge(std::string &message) { if (!cart_ram_region()) { message = "msx_cart_konami_sound_snatcher_device: Required region 'ram' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_ram_region()->bytes() != 0x10000) { message = "msx_cart_konami_sound_snatcher_device: Region 'ram' has unsupported size."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } return msx_cart_konami_sound_device::initialize_cartridge(message); @@ -512,18 +512,18 @@ msx_cart_konami_sound_sdsnatcher_device::msx_cart_konami_sound_sdsnatcher_device { } -image_init_result msx_cart_konami_sound_sdsnatcher_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_konami_sound_sdsnatcher_device::initialize_cartridge(std::string &message) { if (!cart_ram_region()) { message = "msx_cart_konami_sound_sdsnatcher_device: Required region 'ram' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_ram_region()->bytes() != 0x10000) { message = "msx_cart_konami_sound_sdsnatcher_device: Region 'ram' has unsupported size."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } return msx_cart_konami_sound_device::initialize_cartridge(message); @@ -560,29 +560,29 @@ void msx_cart_keyboard_master_device::device_start() io_space().install_read_handler(0x00, 0x00, read8smo_delegate(*this, FUNC(msx_cart_keyboard_master_device::io_00_r))); } -image_init_result msx_cart_keyboard_master_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_keyboard_master_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_keyboard_master_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (!cart_vlm5030_region()) { message = "msx_cart_keyboard_master_device: Required region 'vlm5030' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x4000) { message = "msx_cart_keyboard_master_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); - return image_init_result::PASS; + return std::error_condition(); } uint8_t msx_cart_keyboard_master_device::read_vlm(offs_t offset) @@ -620,12 +620,12 @@ void msx_cart_ec701_device::device_reset() m_view.select(0); } -image_init_result msx_cart_ec701_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_ec701_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_ec701_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } m_rombank->configure_entries(0, 24, cart_rom_region()->base() + 0x20000, 0x4000); @@ -638,7 +638,7 @@ image_init_result msx_cart_ec701_device::initialize_cartridge(std::string &messa page(2)->install_rom(0x8000, 0xbfff, cart_rom_region()->base() + 0x4000); page(2)->install_write_handler(0xbff8, 0xbfff, write8smo_delegate(*this, FUNC(msx_cart_ec701_device::bank_w))); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_ec701_device::bank_w(u8 data) diff --git a/src/devices/bus/msx/cart/konami.h b/src/devices/bus/msx/cart/konami.h index d35e58c794e..ef96b097b5a 100644 --- a/src/devices/bus/msx/cart/konami.h +++ b/src/devices/bus/msx/cart/konami.h @@ -26,7 +26,7 @@ class msx_cart_konami_device : public device_t, public msx_cart_interface public: msx_cart_konami_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -46,7 +46,7 @@ class msx_cart_konami_scc_device : public device_t, public msx_cart_interface public: msx_cart_konami_scc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -71,7 +71,7 @@ class msx_cart_gamemaster2_device : public device_t, public msx_cart_interface public: msx_cart_gamemaster2_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -94,7 +94,7 @@ class msx_cart_synthesizer_device : public device_t, public msx_cart_interface public: msx_cart_synthesizer_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -110,7 +110,7 @@ private: class msx_cart_konami_sound_device : public device_t, public msx_cart_interface { public: - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: msx_cart_konami_sound_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 min_rambank, u8 max_rambank); @@ -151,7 +151,7 @@ class msx_cart_konami_sound_snatcher_device : public msx_cart_konami_sound_devic public: msx_cart_konami_sound_snatcher_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; }; @@ -160,7 +160,7 @@ class msx_cart_konami_sound_sdsnatcher_device : public msx_cart_konami_sound_dev public: msx_cart_konami_sound_sdsnatcher_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; }; @@ -176,7 +176,7 @@ protected: virtual void device_add_mconfig(machine_config &config) override; - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; private: required_device m_vlm5030; @@ -200,7 +200,7 @@ protected: virtual void device_start() override { } virtual void device_reset() override; - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; private: void bank_w(u8 data); diff --git a/src/devices/bus/msx/cart/korean.cpp b/src/devices/bus/msx/cart/korean.cpp index 243e6d14084..b502221791e 100644 --- a/src/devices/bus/msx/cart/korean.cpp +++ b/src/devices/bus/msx/cart/korean.cpp @@ -22,12 +22,12 @@ void msx_cart_korean_80in1_device::device_reset() m_rombank[i]->set_entry(i); } -image_init_result msx_cart_korean_80in1_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_korean_80in1_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_korean_80in1_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -36,7 +36,7 @@ image_init_result msx_cart_korean_80in1_device::initialize_cartridge(std::string if (size > 256 * 0x2000 || size < 0x8000 || size != banks * 0x2000 || (~(banks - 1) % banks)) { message = "msx_cart_korean_80in1_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bank_mask = banks - 1; @@ -50,7 +50,7 @@ image_init_result msx_cart_korean_80in1_device::initialize_cartridge(std::string page(2)->install_read_bank(0x8000, 0x9fff, m_rombank[2]); page(2)->install_read_bank(0xa000, 0xbfff, m_rombank[3]); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_korean_80in1_device::bank_w(offs_t offset, u8 data) @@ -85,12 +85,12 @@ void msx_cart_korean_90in1_device::device_reset() m_rombank[2]->set_entry(0); } -image_init_result msx_cart_korean_90in1_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_korean_90in1_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_korean_90in1_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -99,7 +99,7 @@ image_init_result msx_cart_korean_90in1_device::initialize_cartridge(std::string if (size > 64 * 0x4000 || size < 0x8000 || size != banks * 0x4000 || (~(banks - 1) % banks)) { message = "msx_cart_korean_90in1_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bank_mask = banks - 1; @@ -116,7 +116,7 @@ image_init_result msx_cart_korean_90in1_device::initialize_cartridge(std::string m_view[1].install_read_bank(0x8000, 0x9fff, m_rombank[2]); m_view[1].install_read_bank(0xa000, 0xbfff, m_rombank[1]); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_korean_90in1_device::banking(u8 data) @@ -149,12 +149,12 @@ void msx_cart_korean_126in1_device::device_reset() m_rombank[1]->set_entry(1); } -image_init_result msx_cart_korean_126in1_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_korean_126in1_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_korean_126in1_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -163,7 +163,7 @@ image_init_result msx_cart_korean_126in1_device::initialize_cartridge(std::strin if (size > 256 * 0x4000 || size < 0x8000 || size != banks * 0x4000 || (~(banks - 1) % banks)) { message = "msx_cart_korean_126in1_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_bank_mask = banks - 1; @@ -175,7 +175,7 @@ image_init_result msx_cart_korean_126in1_device::initialize_cartridge(std::strin page(1)->install_write_handler(0x4000, 0x4001, write8sm_delegate(*this, FUNC(msx_cart_korean_126in1_device::bank_w))); page(2)->install_read_bank(0x8000, 0xbfff, m_rombank[1]); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_korean_126in1_device::bank_w(offs_t offset, uint8_t data) diff --git a/src/devices/bus/msx/cart/korean.h b/src/devices/bus/msx/cart/korean.h index 8f8026478af..841319dee47 100644 --- a/src/devices/bus/msx/cart/korean.h +++ b/src/devices/bus/msx/cart/korean.h @@ -18,7 +18,7 @@ class msx_cart_korean_80in1_device : public device_t, public msx_cart_interface public: msx_cart_korean_80in1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -39,7 +39,7 @@ class msx_cart_korean_90in1_device : public device_t, public msx_cart_interface public: msx_cart_korean_90in1_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides @@ -60,7 +60,7 @@ class msx_cart_korean_126in1_device : public device_t, public msx_cart_interface public: msx_cart_korean_126in1_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/majutsushi.cpp b/src/devices/bus/msx/cart/majutsushi.cpp index 8e1c7cfe875..3c916534685 100644 --- a/src/devices/bus/msx/cart/majutsushi.cpp +++ b/src/devices/bus/msx/cart/majutsushi.cpp @@ -24,18 +24,18 @@ void msx_cart_majutsushi_device::device_add_mconfig(machine_config &config) DAC_8BIT_R2R(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.05); // unknown DAC } -image_init_result msx_cart_majutsushi_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_majutsushi_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_majutsushi_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x20000) { message = "msx_cart_majutsushi_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } for (int i = 0; i < 3; i++) @@ -54,7 +54,7 @@ image_init_result msx_cart_majutsushi_device::initialize_cartridge(std::string & page(3)->install_read_bank(0xc000, 0xdfff, m_rombank[1]); page(3)->install_read_bank(0xe000, 0xffff, m_rombank[2]); - return image_init_result::PASS; + return std::error_condition(); } template diff --git a/src/devices/bus/msx/cart/majutsushi.h b/src/devices/bus/msx/cart/majutsushi.h index 0d3090827e5..da57f4003ed 100644 --- a/src/devices/bus/msx/cart/majutsushi.h +++ b/src/devices/bus/msx/cart/majutsushi.h @@ -17,7 +17,7 @@ class msx_cart_majutsushi_device : public device_t, public msx_cart_interface public: msx_cart_majutsushi_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/msx_audio.cpp b/src/devices/bus/msx/cart/msx_audio.cpp index 2ff9580d101..ad3f59b833d 100644 --- a/src/devices/bus/msx/cart/msx_audio.cpp +++ b/src/devices/bus/msx/cart/msx_audio.cpp @@ -98,24 +98,24 @@ void msx_cart_msx_audio_hxmu900_device::device_start() io_space().install_read_handler(0xc0, 0xc1, read8sm_delegate(*m_y8950, FUNC(y8950_device::read))); } -image_init_result msx_cart_msx_audio_hxmu900_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_msx_audio_hxmu900_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_msx_audio_hxmu900_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() < 0x8000) { message = "msx_cart_msx_audio_hxmu900_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); page(2)->install_rom(0x8000, 0xbfff, cart_rom_region()->base() + 0x4000); - return image_init_result::PASS; + return std::error_condition(); } ROM_START(msx_hxmu) @@ -197,24 +197,24 @@ void msx_cart_msx_audio_nms1205_device::device_start() io_space().install_read_handler(0x04, 0x05, read8sm_delegate(*m_acia6850, FUNC(acia6850_device::read))); } -image_init_result msx_cart_msx_audio_nms1205_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_msx_audio_nms1205_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_msx_audio_nms1205_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() < 0x8000) { message = "msx_cart_msx_audio_nms1205_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); page(2)->install_rom(0x8000, 0xbfff, cart_rom_region()->base() + 0x4000); - return image_init_result::PASS; + return std::error_condition(); } @@ -288,18 +288,18 @@ void msx_cart_msx_audio_fsca1_device::device_reset() m_rombank[1]->set_entry(0); } -image_init_result msx_cart_msx_audio_fsca1_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_msx_audio_fsca1_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_msx_audio_fsca1_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() < 0x20000) { message = "msx_cart_msx_audio_fsca1_device: Region 'rom' has unsupported size"; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_rombank[0]->configure_entries(0, 4, cart_rom_region()->base(), 0x8000); @@ -320,7 +320,7 @@ image_init_result msx_cart_msx_audio_fsca1_device::initialize_cartridge(std::str page(2)->install_read_bank(0x8000, 0xbfff, m_rombank[0]); page(3)->install_read_bank(0xc000, 0xffff, m_rombank[1]); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_msx_audio_fsca1_device::bank_w(u8 data) diff --git a/src/devices/bus/msx/cart/msx_audio.h b/src/devices/bus/msx/cart/msx_audio.h index 7bd6434d7eb..43fdd5f3fd6 100644 --- a/src/devices/bus/msx/cart/msx_audio.h +++ b/src/devices/bus/msx/cart/msx_audio.h @@ -21,7 +21,7 @@ class msx_cart_msx_audio_hxmu900_device : public device_t, public msx_cart_inter public: msx_cart_msx_audio_hxmu900_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: virtual void device_start() override; @@ -40,7 +40,7 @@ class msx_cart_msx_audio_nms1205_device : public device_t, public msx_cart_inter public: msx_cart_msx_audio_nms1205_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: virtual void device_start() override; @@ -65,7 +65,7 @@ class msx_cart_msx_audio_fsca1_device : public device_t, public msx_cart_interfa public: msx_cart_msx_audio_fsca1_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: virtual void device_start() override; diff --git a/src/devices/bus/msx/cart/msxdos2.cpp b/src/devices/bus/msx/cart/msxdos2.cpp index e747be583e4..155bc6b0f07 100644 --- a/src/devices/bus/msx/cart/msxdos2.cpp +++ b/src/devices/bus/msx/cart/msxdos2.cpp @@ -35,7 +35,7 @@ protected: virtual void device_start() override { } virtual void device_reset() override; - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; void bank_w(u8 data); @@ -50,36 +50,36 @@ void msx_cart_msxdos2_base_device::device_reset() m_rombank->set_entry(0); } -image_init_result msx_cart_msxdos2_base_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_msxdos2_base_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_msxdos2: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x10000) { message = "msx_cart_msxdos2: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } const char *bank_address_str = get_feature("bank_address"); if (!bank_address_str) { message = "msx_cart_msxdos2: Feature 'bank_address' was not found."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } m_bank_address = strtol(bank_address_str, nullptr, 0); if (m_bank_address < 0x4000 || m_bank_address > 0x7fff) { message = "msx_cart_msxdos2: bank_address must be between 0x4000 and 0x7fff."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } m_rombank->configure_entries(0, 4, cart_rom_region()->base(), PAGE_SIZE); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_msxdos2_base_device::bank_w(u8 data) @@ -103,7 +103,7 @@ public: , m_bank_mask(0) { } - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: virtual void device_start() override; @@ -129,17 +129,17 @@ void msx_cart_msxdos2j_device::device_start() save_item(NAME(m_secondary_slot)); } -image_init_result msx_cart_msxdos2j_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_msxdos2j_device::initialize_cartridge(std::string &message) { - image_init_result result = msx_cart_msxdos2_base_device::initialize_cartridge(message); - if (result != image_init_result::PASS) + std::error_condition result = msx_cart_msxdos2_base_device::initialize_cartridge(message); + if (result) return result; u32 ram_size = cart_ram_region() ? cart_ram_region()->bytes() : 0; if (ram_size > 256 * PAGE_SIZE || (ram_size & (PAGE_SIZE - 1)) != 0) { message = "msx_cart_msxdos2: Region 'ram' size must be a multiple of 0x4000 and at most 0x400000."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } page(0)->install_view(0x0000, 0x3fff, m_view_page0); @@ -187,7 +187,7 @@ image_init_result msx_cart_msxdos2j_device::initialize_cartridge(std::string &me io_space().install_write_tap(0xff, 0xff, "bank3", [this] (offs_t, u8& data, u8){ this->mm_bank_w<3>(data); }); } - return image_init_result::PASS; + return std::error_condition(); } u8 msx_cart_msxdos2j_device::secondary_slot_r() @@ -219,19 +219,19 @@ public: : msx_cart_msxdos2_base_device(mconfig, MSX_CART_MSXDOS2E, tag, owner, clock) { } - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; }; -image_init_result msx_cart_msxdos2e_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_msxdos2e_device::initialize_cartridge(std::string &message) { - image_init_result result = msx_cart_msxdos2_base_device::initialize_cartridge(message); - if (result != image_init_result::PASS) + std::error_condition result = msx_cart_msxdos2_base_device::initialize_cartridge(message); + if (result) return result; page(1)->install_read_bank(0x4000, 0x7fff, m_rombank); page(1)->install_write_handler(m_bank_address, m_bank_address, write8smo_delegate(*this, FUNC(msx_cart_msxdos2e_device::bank_w))); - return image_init_result::PASS; + return std::error_condition(); } } // anonymous namespace diff --git a/src/devices/bus/msx/cart/nomapper.cpp b/src/devices/bus/msx/cart/nomapper.cpp index 2781c58d611..1ca7b18d34e 100644 --- a/src/devices/bus/msx/cart/nomapper.cpp +++ b/src/devices/bus/msx/cart/nomapper.cpp @@ -39,12 +39,12 @@ void msx_cart_nomapper_device::install_memory() } } -image_init_result msx_cart_nomapper_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_nomapper_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_nomapper_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } const u32 size = cart_rom_region()->bytes(); @@ -61,13 +61,13 @@ image_init_result msx_cart_nomapper_device::initialize_cartridge(std::string &me if (!start_page_str) { message = "msx_cart_nomapper_device: Feature 'start_page' was not found."; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } u32 start_page = strtol(start_page_str, nullptr, 0); if (start_page > 2) { message = "msx_cart_nomapper_device: Invalid value for 'start_page', allowed values are 0, 1, and 2"; - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } m_start_address = start_page * 0x4000; @@ -131,5 +131,5 @@ image_init_result msx_cart_nomapper_device::initialize_cartridge(std::string &me install_memory(); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/msx/cart/nomapper.h b/src/devices/bus/msx/cart/nomapper.h index f479216d7ae..a6ae31033c5 100644 --- a/src/devices/bus/msx/cart/nomapper.h +++ b/src/devices/bus/msx/cart/nomapper.h @@ -19,7 +19,7 @@ public: // device-level overrides virtual void device_start() override { } - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; private: uint32_t m_start_address; diff --git a/src/devices/bus/msx/cart/rtype.cpp b/src/devices/bus/msx/cart/rtype.cpp index 2fdf17e24ed..2b4d8cb053c 100644 --- a/src/devices/bus/msx/cart/rtype.cpp +++ b/src/devices/bus/msx/cart/rtype.cpp @@ -13,18 +13,18 @@ msx_cart_rtype_device::msx_cart_rtype_device(const machine_config &mconfig, cons { } -image_init_result msx_cart_rtype_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_rtype_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_rtype_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x80000 && cart_rom_region()->bytes() != 0x60000) { message = "msx_cart_rtype_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_rombank->configure_entries(0, 24, cart_rom_region()->base(), 0x4000); @@ -33,7 +33,7 @@ image_init_result msx_cart_rtype_device::initialize_cartridge(std::string &messa page(1)->install_write_handler(0x7000, 0x7fff, write8smo_delegate(*this, FUNC(msx_cart_rtype_device::bank_w))); page(2)->install_read_bank(0x8000, 0xbfff, m_rombank); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_rtype_device::bank_w(u8 data) diff --git a/src/devices/bus/msx/cart/rtype.h b/src/devices/bus/msx/cart/rtype.h index c844b2ad107..c629b30a709 100644 --- a/src/devices/bus/msx/cart/rtype.h +++ b/src/devices/bus/msx/cart/rtype.h @@ -16,7 +16,7 @@ class msx_cart_rtype_device : public device_t, public msx_cart_interface public: msx_cart_rtype_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/softcard.cpp b/src/devices/bus/msx/cart/softcard.cpp index 7ab27a3eb4d..7a8576b1184 100644 --- a/src/devices/bus/msx/cart/softcard.cpp +++ b/src/devices/bus/msx/cart/softcard.cpp @@ -40,7 +40,7 @@ void msx_cart_softcard_device::device_add_mconfig(machine_config &config) SOFTWARE_LIST(config, "softcard_list").set_original("msx_softcard"); } -image_init_result msx_cart_softcard_device::call_load() +std::error_condition msx_cart_softcard_device::call_load() { if (m_softcard) { @@ -50,8 +50,8 @@ image_init_result msx_cart_softcard_device::call_load() // Only 32KB images are supported if (length != 0x8000) { - seterror(image_error::UNSPECIFIED, "Invalid file size for a softcard"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid file size for a softcard\n", basename()); + return image_error::BADSOFTWARE; } } else @@ -60,26 +60,26 @@ image_init_result msx_cart_softcard_device::call_load() // Only 32KB images are supported if (length != 0x8000) { - seterror(image_error::UNSPECIFIED, "Invalid file size for a softcard"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid file size for a softcard\n", basename()); + return image_error::INVALIDLENGTH; } memory_region *const romregion = machine().memory().region_alloc(subtag("rom"), length, 1, ENDIANNESS_LITTLE); if (fread(romregion->base(), length) != length) { - seterror(image_error::UNSPECIFIED, "Unable to fully read file"); - return image_init_result::FAIL; + osd_printf_error("%s: Unable to fully read file\n", basename()); + return image_error::UNSPECIFIED; } } std::string message; - image_init_result result = m_softcard->initialize_cartridge(message); - if (image_init_result::PASS != result) - seterror(image_error::INVALIDIMAGE, message.c_str()); + std::error_condition result = m_softcard->initialize_cartridge(message); + if (result) + osd_printf_error("%s: %s\n", basename(), message); return result; } - return image_init_result::PASS; + return std::error_condition(); } std::string msx_cart_softcard_device::get_default_card_software(get_default_card_software_hook &hook) const diff --git a/src/devices/bus/msx/cart/softcard.h b/src/devices/bus/msx/cart/softcard.h index cc53184a4cc..3229371b2e6 100644 --- a/src/devices/bus/msx/cart/softcard.h +++ b/src/devices/bus/msx/cart/softcard.h @@ -23,7 +23,7 @@ public: msx_cart_softcard_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "softcard"; } virtual const char *file_extensions() const noexcept override { return "bin,rom"; } @@ -41,7 +41,7 @@ protected: class softcard_interface : public device_interface { public: - virtual image_init_result initialize_cartridge(std::string &message) { return image_init_result::PASS; } + virtual std::error_condition initialize_cartridge(std::string &message) { return std::error_condition(); } void set_views(memory_view::memory_view_entry *page0, memory_view::memory_view_entry *page1, memory_view::memory_view_entry *page2, memory_view::memory_view_entry *page3); protected: diff --git a/src/devices/bus/msx/cart/super_swangi.cpp b/src/devices/bus/msx/cart/super_swangi.cpp index aaf418e0f5f..34194ce3ba0 100644 --- a/src/devices/bus/msx/cart/super_swangi.cpp +++ b/src/devices/bus/msx/cart/super_swangi.cpp @@ -14,18 +14,18 @@ msx_cart_super_swangi_device::msx_cart_super_swangi_device(const machine_config { } -image_init_result msx_cart_super_swangi_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_super_swangi_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_super_swangi_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() < 0x10000) { message = "msx_cart_super_swangi_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_rombank->configure_entries(0, 4, cart_rom_region()->base(), 0x4000); @@ -34,7 +34,7 @@ image_init_result msx_cart_super_swangi_device::initialize_cartridge(std::string page(2)->install_read_bank(0x8000, 0xbfff, m_rombank); page(2)->install_write_handler(0x8000, 0x8000, write8smo_delegate(*this, FUNC(msx_cart_super_swangi_device::bank_w))); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_super_swangi_device::bank_w(u8 data) diff --git a/src/devices/bus/msx/cart/super_swangi.h b/src/devices/bus/msx/cart/super_swangi.h index cbf141bb892..673178ab1a9 100644 --- a/src/devices/bus/msx/cart/super_swangi.h +++ b/src/devices/bus/msx/cart/super_swangi.h @@ -16,7 +16,7 @@ class msx_cart_super_swangi_device : public device_t, public msx_cart_interface public: msx_cart_super_swangi_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/cart/superloderunner.cpp b/src/devices/bus/msx/cart/superloderunner.cpp index 23d3ebf44b0..dcae1ace95a 100644 --- a/src/devices/bus/msx/cart/superloderunner.cpp +++ b/src/devices/bus/msx/cart/superloderunner.cpp @@ -19,25 +19,25 @@ void msx_cart_superloderunner_device::device_start() memory_space().install_write_handler(0x0000, 0x0000, write8smo_delegate(*this, FUNC(msx_cart_superloderunner_device::bank_w))); } -image_init_result msx_cart_superloderunner_device::initialize_cartridge(std::string &message) +std::error_condition msx_cart_superloderunner_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "msx_cart_superloderunner_device: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } if (cart_rom_region()->bytes() != 0x20000) { message = "msx_cart_superloderunner_device: Region 'rom' has unsupported size."; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_rombank->configure_entries(0, 8, cart_rom_region()->base(), 0x4000); page(2)->install_read_bank(0x8000, 0xbfff, m_rombank); - return image_init_result::PASS; + return std::error_condition(); } void msx_cart_superloderunner_device::bank_w(u8 data) diff --git a/src/devices/bus/msx/cart/superloderunner.h b/src/devices/bus/msx/cart/superloderunner.h index a248da9267a..f933de72ffe 100644 --- a/src/devices/bus/msx/cart/superloderunner.h +++ b/src/devices/bus/msx/cart/superloderunner.h @@ -16,7 +16,7 @@ class msx_cart_superloderunner_device : public device_t, public msx_cart_interfa public: msx_cart_superloderunner_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; protected: // device-level overrides diff --git a/src/devices/bus/msx/slot/cartridge.cpp b/src/devices/bus/msx/slot/cartridge.cpp index 673e1b40328..0703d3cc402 100644 --- a/src/devices/bus/msx/slot/cartridge.cpp +++ b/src/devices/bus/msx/slot/cartridge.cpp @@ -32,7 +32,7 @@ void msx_slot_cartridge_base_device::device_start() } -image_init_result msx_slot_cartridge_base_device::call_load() +std::error_condition msx_slot_cartridge_base_device::call_load() { if (m_cartridge) { @@ -60,16 +60,16 @@ image_init_result msx_slot_cartridge_base_device::call_load() memory_region *const romregion = machine().memory().region_alloc(subtag("rom"), length_aligned, 1, ENDIANNESS_LITTLE); if (fread(romregion->base(), length) != length) { - seterror(image_error::UNSPECIFIED, "Unable to fully read file"); - return image_init_result::FAIL; + osd_printf_error("%s: Unable to fully read file\n", basename()); + return image_error::UNSPECIFIED; } } std::string message; - image_init_result result = m_cartridge->initialize_cartridge(message); - if (image_init_result::PASS != result) + std::error_condition result = m_cartridge->initialize_cartridge(message); + if (result) { - seterror(image_error::INVALIDIMAGE, message.c_str()); + osd_printf_error("%s: %s\n", basename(), message); return result; } @@ -78,7 +78,7 @@ image_init_result msx_slot_cartridge_base_device::call_load() battery_load(m_cartridge->cart_sram_region()->base(), m_cartridge->cart_sram_region()->bytes(), 0x00); } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/msx/slot/cartridge.h b/src/devices/bus/msx/slot/cartridge.h index 6aa4e0a7886..85d8ddaa4a4 100644 --- a/src/devices/bus/msx/slot/cartridge.h +++ b/src/devices/bus/msx/slot/cartridge.h @@ -51,7 +51,7 @@ class msx_slot_cartridge_base_device : public device_t public: auto irq_handler() { return m_irq_handler.bind(); } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "msx_cart"; } @@ -81,7 +81,7 @@ public: // This is called after loading cartridge contents and allows the cartridge // implementation to perform some additional initialization based on the // cartridge contents. - virtual image_init_result initialize_cartridge(std::string &message) { return image_init_result::PASS; } + virtual std::error_condition initialize_cartridge(std::string &message) { return std::error_condition(); } virtual void interface_pre_start() override { assert(m_exp != nullptr); } void set_views(memory_view::memory_view_entry *page0, memory_view::memory_view_entry *page1, memory_view::memory_view_entry *page2, memory_view::memory_view_entry *page3); diff --git a/src/devices/bus/msx/softcard/softcard.cpp b/src/devices/bus/msx/softcard/softcard.cpp index b9f9a890227..bd0b5847f9d 100644 --- a/src/devices/bus/msx/softcard/softcard.cpp +++ b/src/devices/bus/msx/softcard/softcard.cpp @@ -26,7 +26,7 @@ protected: // device-level overrides virtual void device_start() override { } - virtual image_init_result initialize_cartridge(std::string &message) override; + virtual std::error_condition initialize_cartridge(std::string &message) override; }; @@ -37,18 +37,18 @@ softcard_nomapper_device::softcard_nomapper_device(const machine_config &mconfig { } -image_init_result softcard_nomapper_device::initialize_cartridge(std::string &message) +std::error_condition softcard_nomapper_device::initialize_cartridge(std::string &message) { if (!cart_rom_region()) { message = "softcard_nomapper: Required region 'rom' was not found."; - return image_init_result::FAIL; + return image_error::INTERNAL; } page(1)->install_rom(0x4000, 0x7fff, cart_rom_region()->base()); page(2)->install_rom(0x8000, 0xbfff, cart_rom_region()->base() + 0x4000); - return image_init_result::PASS; + return std::error_condition(); } } // anonymous namespace diff --git a/src/devices/bus/mtx/exp.cpp b/src/devices/bus/mtx/exp.cpp index e2a4f9c8ed0..86085d3f389 100644 --- a/src/devices/bus/mtx/exp.cpp +++ b/src/devices/bus/mtx/exp.cpp @@ -89,7 +89,7 @@ void mtx_exp_slot_device::device_start() // call_load //------------------------------------------------- -image_init_result mtx_exp_slot_device::call_load() +std::error_condition mtx_exp_slot_device::call_load() { if (m_card) { @@ -97,8 +97,8 @@ image_init_result mtx_exp_slot_device::call_load() if (size % 0x2000) { - seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", basename()); + return image_error::INVALIDLENGTH; } m_card->rom_alloc(size, tag()); @@ -109,7 +109,7 @@ image_init_result mtx_exp_slot_device::call_load() memcpy(m_card->get_rom_base(), get_software_region("rom"), size); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/mtx/exp.h b/src/devices/bus/mtx/exp.h index dd23586c05e..f99181c2927 100644 --- a/src/devices/bus/mtx/exp.h +++ b/src/devices/bus/mtx/exp.h @@ -60,7 +60,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "mtx_cart"; } diff --git a/src/devices/bus/nabupc/adapter.cpp b/src/devices/bus/nabupc/adapter.cpp index 07eda4f1b83..5f2272be5c2 100644 --- a/src/devices/bus/nabupc/adapter.cpp +++ b/src/devices/bus/nabupc/adapter.cpp @@ -211,13 +211,12 @@ void network_adapter::postload() } } -image_init_result network_adapter::call_load() +std::error_condition network_adapter::call_load() { if (is_filetype("pak")) { - return image_init_result::PASS; + return std::error_condition(); } - seterror(image_error::INVALIDIMAGE); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } //************************************************************************** diff --git a/src/devices/bus/nabupc/adapter.h b/src/devices/bus/nabupc/adapter.h index 258b0169036..6dbf4bdfb96 100644 --- a/src/devices/bus/nabupc/adapter.h +++ b/src/devices/bus/nabupc/adapter.h @@ -43,7 +43,7 @@ public: virtual const char *file_extensions() const noexcept override { return "pak"; } virtual const char *image_type_name() const noexcept override { return "Segment Pak"; } virtual const char *image_brief_type_name() const noexcept override { return "hcca"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual DECLARE_WRITE_LINE_MEMBER(input_txd) override; diff --git a/src/devices/bus/neogeo/slot.cpp b/src/devices/bus/neogeo/slot.cpp index f5cd7bf80b8..573584f5a08 100644 --- a/src/devices/bus/neogeo/slot.cpp +++ b/src/devices/bus/neogeo/slot.cpp @@ -224,8 +224,7 @@ void neogeo_cart_slot_device::set_cart_type(const char *slot) call load -------------------------------------------------*/ - -image_init_result neogeo_cart_slot_device::call_load() +std::error_condition neogeo_cart_slot_device::call_load() { if (m_cart) { @@ -305,11 +304,11 @@ image_init_result neogeo_cart_slot_device::call_load() // a different format (we then always access such alt format for drawing) m_cart->optimize_sprites(m_cart->get_sprites_base(), m_cart->get_sprites_size()); - return image_init_result::PASS; + return std::error_condition(); } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/neogeo/slot.h b/src/devices/bus/neogeo/slot.h index 4c86456ff61..037ac77294d 100644 --- a/src/devices/bus/neogeo/slot.h +++ b/src/devices/bus/neogeo/slot.h @@ -204,7 +204,7 @@ public: virtual ~neogeo_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/nes/aladdin.cpp b/src/devices/bus/nes/aladdin.cpp index 00b444cd395..0d0e94d50b6 100644 --- a/src/devices/bus/nes/aladdin.cpp +++ b/src/devices/bus/nes/aladdin.cpp @@ -93,7 +93,7 @@ uint8_t nes_aladdin_slot_device::read(offs_t offset) } // 128K for Dizzy The Adventurer, 256K for the others -image_init_result nes_aladdin_slot_device::call_load() +std::error_condition nes_aladdin_slot_device::call_load() { if (m_cart) { @@ -101,12 +101,12 @@ image_init_result nes_aladdin_slot_device::call_load() uint32_t size; if (!ROM) - return image_init_result::FAIL; + return image_error::INTERNAL; if (!loaded_through_softlist()) { if (length() != 0x20010 && length() != 0x40010) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; uint8_t temp[0x40010]; size = length() - 0x10; @@ -118,13 +118,13 @@ image_init_result nes_aladdin_slot_device::call_load() uint8_t mapper = (temp[6] & 0xf0) >> 4; mapper |= temp[7] & 0xf0; if (mapper != 71 && mapper != 232) - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } } else { if (get_software_region_length("rom") != 0x20000 && get_software_region_length("rom") != 0x40000) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; size = get_software_region_length("rom"); memcpy(ROM, get_software_region("rom"), size); @@ -133,7 +133,7 @@ image_init_result nes_aladdin_slot_device::call_load() m_cart->set_cart_size(size); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/nes/aladdin.h b/src/devices/bus/nes/aladdin.h index 170649fdd30..da3567f11a6 100644 --- a/src/devices/bus/nes/aladdin.h +++ b/src/devices/bus/nes/aladdin.h @@ -64,7 +64,7 @@ public: virtual ~nes_aladdin_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "ade_cart"; } diff --git a/src/devices/bus/nes/datach.cpp b/src/devices/bus/nes/datach.cpp index 5e71e0af6bc..9b8376f534e 100644 --- a/src/devices/bus/nes/datach.cpp +++ b/src/devices/bus/nes/datach.cpp @@ -92,20 +92,20 @@ uint8_t nes_datach_slot_device::read(offs_t offset) return 0xff; } -image_init_result nes_datach_slot_device::call_load() +std::error_condition nes_datach_slot_device::call_load() { if (m_cart) { uint8_t *ROM = m_cart->get_cart_base(); if (!ROM) - return image_init_result::FAIL; + return image_error::INTERNAL; // Existing Datach carts are all 256K, so we only load files of this size if (!loaded_through_softlist()) { if (length() != 0x40000 && length() != 0x40010) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; int shift = length() - 0x40000; uint8_t temp[0x40010]; @@ -120,20 +120,20 @@ image_init_result nes_datach_slot_device::call_load() mapper |= temp[7] & 0xf0; if (mapper != 157 && mapper != 16) { - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } } } else { if (get_software_region_length("rom") != 0x40000) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; memcpy(ROM, get_software_region("rom"), 0x40000); } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/nes/datach.h b/src/devices/bus/nes/datach.h index 80770904596..c5bff489077 100644 --- a/src/devices/bus/nes/datach.h +++ b/src/devices/bus/nes/datach.h @@ -65,7 +65,7 @@ public: virtual ~nes_datach_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "datach_cart"; } diff --git a/src/devices/bus/nes/karastudio.cpp b/src/devices/bus/nes/karastudio.cpp index 3b8801bbf52..28d682064ba 100644 --- a/src/devices/bus/nes/karastudio.cpp +++ b/src/devices/bus/nes/karastudio.cpp @@ -96,33 +96,33 @@ uint8_t nes_kstudio_slot_device::read(offs_t offset) return 0xff; } -image_init_result nes_kstudio_slot_device::call_load() +std::error_condition nes_kstudio_slot_device::call_load() { if (m_cart) { uint8_t *ROM = m_cart->get_cart_base(); if (!ROM) - return image_init_result::FAIL; + return image_error::INTERNAL; // Existing expansion carts are all 128K, so we only load files of this size if (!loaded_through_softlist()) { if (length() != 0x20000) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; fread(&ROM, 0x20000); } else { if (get_software_region_length("rom") != 0x20000) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; memcpy(ROM, get_software_region("rom"), 0x20000); } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/nes/karastudio.h b/src/devices/bus/nes/karastudio.h index 95ea9b14881..cfb48c6cd30 100644 --- a/src/devices/bus/nes/karastudio.h +++ b/src/devices/bus/nes/karastudio.h @@ -63,7 +63,7 @@ public: virtual ~nes_kstudio_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "ks_cart"; } diff --git a/src/devices/bus/nes/nes_slot.cpp b/src/devices/bus/nes/nes_slot.cpp index aae391d27c9..1c930ba23aa 100644 --- a/src/devices/bus/nes/nes_slot.cpp +++ b/src/devices/bus/nes/nes_slot.cpp @@ -725,7 +725,7 @@ void nes_cart_slot_device::pcb_reset() #include "nes_ines.hxx" -image_init_result nes_cart_slot_device::call_load() +std::error_condition nes_cart_slot_device::call_load() { if (m_cart) { @@ -741,8 +741,8 @@ image_init_result nes_cart_slot_device::call_load() { if (length() <= 0x10) { - logerror("%s only contains the iNES header and no data.\n", filename()); - return image_init_result::FAIL; + osd_printf_error("%s only contains the iNES header and no data.\n", filename()); + return image_error::INVALIDLENGTH; } call_load_ines(); @@ -751,24 +751,23 @@ image_init_result nes_cart_slot_device::call_load() { if (length() <= 0x20) { - logerror("%s only contains the UNIF header and no data.\n", filename()); - return image_init_result::FAIL; + osd_printf_error("%s only contains the UNIF header and no data.\n", filename()); + return image_error::INVALIDLENGTH; } call_load_unif(); } else { - logerror("%s is NOT a file in either iNES or UNIF format.\n", filename()); - seterror(image_error::INVALIDIMAGE, "File is neither iNES or UNIF format"); - return image_init_result::FAIL; + osd_printf_error("%s is NOT a file in either iNES or UNIF format.\n", filename()); + return image_error::INVALIDIMAGE; } } else call_load_pcb(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/nes/nes_slot.h b/src/devices/bus/nes/nes_slot.h index b135f957afe..f9ed0b16494 100644 --- a/src/devices/bus/nes/nes_slot.h +++ b/src/devices/bus/nes/nes_slot.h @@ -399,7 +399,7 @@ public: virtual ~nes_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/nes/sunsoft_dcs.cpp b/src/devices/bus/nes/sunsoft_dcs.cpp index 7f291e741ed..7dd47973acc 100644 --- a/src/devices/bus/nes/sunsoft_dcs.cpp +++ b/src/devices/bus/nes/sunsoft_dcs.cpp @@ -77,32 +77,32 @@ uint8_t nes_ntb_slot_device::read(offs_t offset) } -image_init_result nes_ntb_slot_device::call_load() +std::error_condition nes_ntb_slot_device::call_load() { if (m_cart) { uint8_t *ROM = m_cart->get_cart_base(); if (!ROM) - return image_init_result::FAIL; + return image_error::INTERNAL; if (!loaded_through_softlist()) { if (length() != 0x4000) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; fread(&ROM, 0x4000); } else { if (get_software_region_length("rom") != 0x4000) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; memcpy(ROM, get_software_region("rom"), 0x4000); } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/nes/sunsoft_dcs.h b/src/devices/bus/nes/sunsoft_dcs.h index e9f6594a452..4cc550ffbd9 100644 --- a/src/devices/bus/nes/sunsoft_dcs.h +++ b/src/devices/bus/nes/sunsoft_dcs.h @@ -60,7 +60,7 @@ public: virtual ~nes_ntb_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "ntb_cart"; } diff --git a/src/devices/bus/nubus/nubus_image.cpp b/src/devices/bus/nubus/nubus_image.cpp index 577411e3ff6..4df7d96e4d6 100644 --- a/src/devices/bus/nubus/nubus_image.cpp +++ b/src/devices/bus/nubus/nubus_image.cpp @@ -49,7 +49,7 @@ public: virtual const char *image_type_name() const noexcept override { return "disk"; } virtual const char *image_brief_type_name() const noexcept override { return "disk"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; protected: @@ -89,7 +89,7 @@ void nubus_image_device::messimg_disk_image_device::device_start() } } -image_init_result nubus_image_device::messimg_disk_image_device::call_load() +std::error_condition nubus_image_device::messimg_disk_image_device::call_load() { fseek(0, SEEK_END); m_size = uint32_t(ftell()); @@ -97,14 +97,14 @@ image_init_result nubus_image_device::messimg_disk_image_device::call_load() { osd_printf_error("Mac image too large: must be 256MB or less!\n"); m_size = 0; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } fseek(0, SEEK_SET); fread(m_data, m_size); m_ejected = false; - return image_init_result::PASS; + return std::error_condition(); } void nubus_image_device::messimg_disk_image_device::call_unload() diff --git a/src/devices/bus/odyssey2/slot.cpp b/src/devices/bus/odyssey2/slot.cpp index 1e85ca3d4fa..29617552f94 100644 --- a/src/devices/bus/odyssey2/slot.cpp +++ b/src/devices/bus/odyssey2/slot.cpp @@ -130,7 +130,7 @@ static const char *o2_get_slot(int type) call load -------------------------------------------------*/ -image_init_result o2_cart_slot_device::call_load() +std::error_condition o2_cart_slot_device::call_load() { if (m_cart) { @@ -166,11 +166,11 @@ image_init_result o2_cart_slot_device::call_load() if (m_cart->get_rom_size() > 0) { m_cart->cart_init(); - return image_init_result::PASS; + return std::error_condition(); } } - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } diff --git a/src/devices/bus/odyssey2/slot.h b/src/devices/bus/odyssey2/slot.h index 09fcd34891e..f0c2f3db666 100644 --- a/src/devices/bus/odyssey2/slot.h +++ b/src/devices/bus/odyssey2/slot.h @@ -113,7 +113,7 @@ public: virtual ~o2_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override { } virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/pce/pce_slot.cpp b/src/devices/bus/pce/pce_slot.cpp index e49642447de..5b2cc285c46 100644 --- a/src/devices/bus/pce/pce_slot.cpp +++ b/src/devices/bus/pce/pce_slot.cpp @@ -210,7 +210,7 @@ static const char *pce_get_slot(int type) call load -------------------------------------------------*/ -image_init_result pce_cart_slot_device::call_load() +std::error_condition pce_cart_slot_device::call_load() { if (m_cart) { @@ -266,10 +266,10 @@ image_init_result pce_cart_slot_device::call_load() if (m_type == PCE_CDSYS3J || m_type == PCE_CDSYS3U) m_cart->ram_alloc(0x30000); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/pce/pce_slot.h b/src/devices/bus/pce/pce_slot.h index 3770002ca5c..a702c2f4f7d 100644 --- a/src/devices/bus/pce/pce_slot.h +++ b/src/devices/bus/pce/pce_slot.h @@ -81,7 +81,7 @@ public: virtual ~pce_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/plus4/exp.cpp b/src/devices/bus/plus4/exp.cpp index 1086683c02a..55eb589032c 100644 --- a/src/devices/bus/plus4/exp.cpp +++ b/src/devices/bus/plus4/exp.cpp @@ -97,7 +97,7 @@ void plus4_expansion_slot_device::device_start() // call_load - //------------------------------------------------- -image_init_result plus4_expansion_slot_device::call_load() +std::error_condition plus4_expansion_slot_device::call_load() { if (m_card) { @@ -118,13 +118,13 @@ image_init_result plus4_expansion_slot_device::call_load() if ((m_card->m_c1l_size & (m_card->m_c1l_size - 1)) || (m_card->m_c1h_size & (m_card->m_c1h_size - 1)) || (m_card->m_c2l_size & (m_card->m_c2l_size - 1)) || (m_card->m_c2h_size & (m_card->m_c2h_size - 1))) { - seterror(image_error::INVALIDIMAGE, "ROM size must be power of 2"); - return image_init_result::FAIL; + osd_printf_error("%s: ROM size must be power of 2\n", basename()); + return image_error::INVALIDLENGTH; } } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/plus4/exp.h b/src/devices/bus/plus4/exp.h index bac19750c2d..1af9968899d 100644 --- a/src/devices/bus/plus4/exp.h +++ b/src/devices/bus/plus4/exp.h @@ -88,7 +88,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "plus4_cart"; } diff --git a/src/devices/bus/pofo/ccm.cpp b/src/devices/bus/pofo/ccm.cpp index d491af7266f..50bbb0e9384 100644 --- a/src/devices/bus/pofo/ccm.cpp +++ b/src/devices/bus/pofo/ccm.cpp @@ -68,7 +68,7 @@ void portfolio_memory_card_slot_device::device_start() // call_load - //------------------------------------------------- -image_init_result portfolio_memory_card_slot_device::call_load() +std::error_condition portfolio_memory_card_slot_device::call_load() { if (m_card) { @@ -78,7 +78,7 @@ image_init_result portfolio_memory_card_slot_device::call_load() load_software_region("rom", m_card->m_rom); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/pofo/ccm.h b/src/devices/bus/pofo/ccm.h index 53e3c7a65ea..4cc32777dc7 100644 --- a/src/devices/bus/pofo/ccm.h +++ b/src/devices/bus/pofo/ccm.h @@ -119,7 +119,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual const software_list_loader &get_software_list_loader() const override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/psx/memcard.cpp b/src/devices/bus/psx/memcard.cpp index 682439ff76e..acfabc5a7ba 100644 --- a/src/devices/bus/psx/memcard.cpp +++ b/src/devices/bus/psx/memcard.cpp @@ -295,20 +295,20 @@ unsigned char psxcard_device::checksum_data(const unsigned char *buf, const unsi return chk; } -image_init_result psxcard_device::call_load() +std::error_condition psxcard_device::call_load() { if(m_disabled) { logerror("psxcard: port disabled\n"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } if(length() != card_size) - return image_init_result::FAIL; - return image_init_result::PASS; + return image_error::INVALIDLENGTH; + return std::error_condition(); } -image_init_result psxcard_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition psxcard_device::call_create(int format_type, util::option_resolution *format_options) { uint8_t block[block_size]; int i, ret; @@ -316,7 +316,7 @@ image_init_result psxcard_device::call_create(int format_type, util::option_reso if(m_disabled) { logerror("psxcard: port disabled\n"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } memset(block, '\0', block_size); @@ -324,9 +324,9 @@ image_init_result psxcard_device::call_create(int format_type, util::option_reso { ret = fwrite(block, block_size); if(ret != block_size) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } - return image_init_result::PASS; + return std::error_condition(); } void psxcard_device::do_card() diff --git a/src/devices/bus/psx/memcard.h b/src/devices/bus/psx/memcard.h index a558f07164c..a8a28081b88 100644 --- a/src/devices/bus/psx/memcard.h +++ b/src/devices/bus/psx/memcard.h @@ -20,8 +20,8 @@ public: virtual bool is_reset_on_load() const noexcept override { return false; } virtual const char *file_extensions() const noexcept override { return "mc"; } - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; void disable(bool state) { m_disabled = state; if(state) unload(); } diff --git a/src/devices/bus/qbus/pc11.cpp b/src/devices/bus/qbus/pc11.cpp index 2fc73ada4df..b812a155c47 100644 --- a/src/devices/bus/qbus/pc11.cpp +++ b/src/devices/bus/qbus/pc11.cpp @@ -136,7 +136,7 @@ void pc11_device::z80daisy_irq_reti() } -image_init_result pc11_device::call_load() +std::error_condition pc11_device::call_load() { /* reader unit */ m_fd = this; @@ -144,7 +144,7 @@ image_init_result pc11_device::call_load() LOG("call_load filename %s is_open %d\n", m_fd->filename(), m_fd->is_open()); - return image_init_result::PASS; + return std::error_condition(); } void pc11_device::call_unload() diff --git a/src/devices/bus/qbus/pc11.h b/src/devices/bus/qbus/pc11.h index cbc0d134f47..2421e7de9b6 100644 --- a/src/devices/bus/qbus/pc11.h +++ b/src/devices/bus/qbus/pc11.h @@ -40,7 +40,7 @@ public: virtual const char *image_interface() const noexcept override { return "pdp11_ptap"; } virtual const char *file_extensions() const noexcept override { return "bin,bim,lda"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; uint16_t read(offs_t offset); diff --git a/src/devices/bus/ql/rom.cpp b/src/devices/bus/ql/rom.cpp index a3186b9a5b8..3d73fbb9698 100644 --- a/src/devices/bus/ql/rom.cpp +++ b/src/devices/bus/ql/rom.cpp @@ -85,7 +85,7 @@ void ql_rom_cartridge_slot_device::device_start() // call_load - //------------------------------------------------- -image_init_result ql_rom_cartridge_slot_device::call_load() +std::error_condition ql_rom_cartridge_slot_device::call_load() { if (m_card) { @@ -99,7 +99,7 @@ image_init_result ql_rom_cartridge_slot_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/ql/rom.h b/src/devices/bus/ql/rom.h index 690b3c231bc..6e8cb6765e8 100644 --- a/src/devices/bus/ql/rom.h +++ b/src/devices/bus/ql/rom.h @@ -96,7 +96,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "ql_cart"; } diff --git a/src/devices/bus/saturn/sat_slot.cpp b/src/devices/bus/saturn/sat_slot.cpp index 975a67403f0..dff115f5f5f 100644 --- a/src/devices/bus/saturn/sat_slot.cpp +++ b/src/devices/bus/saturn/sat_slot.cpp @@ -135,7 +135,7 @@ void sat_cart_slot_device::device_start() -------------------------------------------------*/ -image_init_result sat_cart_slot_device::call_load() +std::error_condition sat_cart_slot_device::call_load() { if (m_cart) { @@ -177,10 +177,10 @@ image_init_result sat_cart_slot_device::call_load() if (get_software_region("dram1")) m_cart->dram1_alloc(get_software_region_length("dram1")); } - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/saturn/sat_slot.h b/src/devices/bus/saturn/sat_slot.h index 0a501866374..1776501a038 100644 --- a/src/devices/bus/saturn/sat_slot.h +++ b/src/devices/bus/saturn/sat_slot.h @@ -80,7 +80,7 @@ public: virtual ~sat_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/scv/slot.cpp b/src/devices/bus/scv/slot.cpp index b3ca1e08873..c6833ecee55 100644 --- a/src/devices/bus/scv/slot.cpp +++ b/src/devices/bus/scv/slot.cpp @@ -147,7 +147,7 @@ static const char *scv_get_slot(int type) call load -------------------------------------------------*/ -image_init_result scv_cart_slot_device::call_load() +std::error_condition scv_cart_slot_device::call_load() { if (m_cart) { @@ -157,8 +157,8 @@ image_init_result scv_cart_slot_device::call_load() if (len > 0x20000) { - seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(len); @@ -190,10 +190,10 @@ image_init_result scv_cart_slot_device::call_load() //printf("Type: %s\n", scv_get_slot(m_type)); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/scv/slot.h b/src/devices/bus/scv/slot.h index 24ce208ab3d..baa1821286f 100644 --- a/src/devices/bus/scv/slot.h +++ b/src/devices/bus/scv/slot.h @@ -80,7 +80,7 @@ public: virtual ~scv_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override { } virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/sdk85/memexp.cpp b/src/devices/bus/sdk85/memexp.cpp index a5a752c4339..366d1aa83cc 100644 --- a/src/devices/bus/sdk85/memexp.cpp +++ b/src/devices/bus/sdk85/memexp.cpp @@ -22,14 +22,14 @@ sdk85_romexp_device::sdk85_romexp_device(const machine_config &mconfig, const ch { } -image_init_result sdk85_romexp_device::call_load() +std::error_condition sdk85_romexp_device::call_load() { if (get_card_device() != nullptr) { u32 size = loaded_through_softlist() ? get_software_region_length("rom") : length(); u8 *base = get_card_device()->get_rom_base(size); if (base == nullptr) - return image_init_result::FAIL; + return image_error::INTERNAL; if (loaded_through_softlist()) memcpy(base, get_software_region("rom"), size); @@ -37,7 +37,7 @@ image_init_result sdk85_romexp_device::call_load() fread(base, size); } - return image_init_result::PASS; + return std::error_condition(); } std::string sdk85_romexp_device::get_default_card_software(get_default_card_software_hook &hook) const diff --git a/src/devices/bus/sdk85/memexp.h b/src/devices/bus/sdk85/memexp.h index fbd005c48c2..058df8eada4 100644 --- a/src/devices/bus/sdk85/memexp.h +++ b/src/devices/bus/sdk85/memexp.h @@ -56,7 +56,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override { } virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/sega8/sega8_slot.cpp b/src/devices/bus/sega8/sega8_slot.cpp index f2ac85c896e..0106f28d572 100644 --- a/src/devices/bus/sega8/sega8_slot.cpp +++ b/src/devices/bus/sega8/sega8_slot.cpp @@ -264,16 +264,18 @@ static const char *sega8_get_slot(int type) call load -------------------------------------------------*/ -image_verify_result sega8_cart_slot_device::verify_cart( uint8_t *magic, int size ) +std::error_condition sega8_cart_slot_device::verify_cart( const uint8_t *magic, int size ) { - image_verify_result retval(image_verify_result::FAIL); + std::error_condition retval; // Verify the file is a valid image - check $7ff0 for "TMR SEGA" if (size >= 0x8000) { - if (!strncmp((char*)&magic[0x7ff0], "TMR SEGA", 8)) - retval = image_verify_result::PASS; + if (strncmp((const char*)&magic[0x7ff0], "TMR SEGA", 8)) + retval = image_error::INVALIDIMAGE; } + else + retval = image_error::INVALIDLENGTH; return retval; } @@ -388,7 +390,7 @@ void sega8_cart_slot_device::setup_ram() } } -image_init_result sega8_cart_slot_device::call_load() +std::error_condition sega8_cart_slot_device::call_load() { if (m_cart) { @@ -398,8 +400,8 @@ image_init_result sega8_cart_slot_device::call_load() if (m_is_card && len > 0x8000) { - seterror(image_error::INVALIDIMAGE, "Attempted loading a card larger than 32KB"); - return image_init_result::FAIL; + osd_printf_error("%s: Attempted loading a card larger than 32KB\n", basename()); + return image_error::INVALIDLENGTH; } // check for header @@ -425,7 +427,7 @@ image_init_result sega8_cart_slot_device::call_load() memcpy(ROM, get_software_region("rom"), get_software_region_length("rom")); /* check the image */ - if (verify_cart(ROM, len) != image_verify_result::PASS) + if (verify_cart(ROM, len)) logerror("Warning loading image: verify_cart failed\n"); if (loaded_through_softlist()) @@ -454,10 +456,10 @@ image_init_result sega8_cart_slot_device::call_load() internal_header_logging(ROM + offset, len, m_cart->get_ram_size()); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/sega8/sega8_slot.h b/src/devices/bus/sega8/sega8_slot.h index 01f34842343..d29f268bda0 100644 --- a/src/devices/bus/sega8/sega8_slot.h +++ b/src/devices/bus/sega8/sega8_slot.h @@ -117,7 +117,7 @@ public: virtual ~sega8_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } @@ -132,7 +132,7 @@ public: void setup_ram(); void internal_header_logging(uint8_t *ROM, uint32_t len, uint32_t nvram_len); - image_verify_result verify_cart(uint8_t *magic, int size); + std::error_condition verify_cart(const uint8_t *magic, int size); void set_lphaser_xoffset(uint8_t *rom, int size); void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } diff --git a/src/devices/bus/snes/snes_slot.cpp b/src/devices/bus/snes/snes_slot.cpp index 7b2e6b7c9a4..0bdd131a80b 100644 --- a/src/devices/bus/snes/snes_slot.cpp +++ b/src/devices/bus/snes/snes_slot.cpp @@ -649,7 +649,7 @@ static int snes_find_addon_chip(const uint8_t *buffer, uint32_t start_offs, uint -------------------------------------------------*/ -image_init_result base_sns_cart_slot_device::call_load() +std::error_condition base_sns_cart_slot_device::call_load() { if (m_cart) { @@ -726,10 +726,10 @@ image_init_result base_sns_cart_slot_device::call_load() internal_header_logging(ROM, len); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/snes/snes_slot.h b/src/devices/bus/snes/snes_slot.h index ec777ee8cc1..10c750960ae 100644 --- a/src/devices/bus/snes/snes_slot.h +++ b/src/devices/bus/snes/snes_slot.h @@ -178,7 +178,7 @@ public: void set_address(offs_t address) { m_address = address; } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/spectrum/intf2.cpp b/src/devices/bus/spectrum/intf2.cpp index 5b407d88df3..f60147176f2 100644 --- a/src/devices/bus/spectrum/intf2.cpp +++ b/src/devices/bus/spectrum/intf2.cpp @@ -100,14 +100,14 @@ DEVICE_IMAGE_LOAD_MEMBER(spectrum_intf2_device::cart_load) if (size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } READ_LINE_MEMBER(spectrum_intf2_device::romcs) diff --git a/src/devices/bus/spectrum/intf2.h b/src/devices/bus/spectrum/intf2.h index 4faecbae93a..af34e4fd7f9 100644 --- a/src/devices/bus/spectrum/intf2.h +++ b/src/devices/bus/spectrum/intf2.h @@ -39,7 +39,7 @@ protected: virtual uint8_t iorq_r(offs_t offset) override; private: - image_init_result load_cart(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_cart(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart_load); required_device m_cart; diff --git a/src/devices/bus/ti99/gromport/cartridges.cpp b/src/devices/bus/ti99/gromport/cartridges.cpp index 6ed6d19366f..eac2577e21a 100644 --- a/src/devices/bus/ti99/gromport/cartridges.cpp +++ b/src/devices/bus/ti99/gromport/cartridges.cpp @@ -271,10 +271,9 @@ int ti99_cartridge_device::get_index_from_tagname() return atoi(mytag+i+1)-1; } -image_init_result ti99_cartridge_device::call_load() +std::error_condition ti99_cartridge_device::call_load() { // File name is in m_basename - // return true = error LOGMASKED(LOG_CHANGE, "Loading %s in slot %s\n", basename()); if (loaded_through_softlist()) @@ -304,8 +303,7 @@ image_init_result ti99_cartridge_device::call_load() { LOGMASKED(LOG_WARN, "Failed to load cartridge '%s': %s\n", basename(), err.message().c_str()); m_rpk.reset(); - m_err = image_error::INVALIDIMAGE; - return image_init_result::FAIL; + return err; } m_pcbtype = m_rpk->get_type(); } @@ -367,7 +365,7 @@ image_init_result ti99_cartridge_device::call_load() m_pcb->set_tag(tag()); m_slot = get_index_from_tagname(); m_connector->insert(m_slot, this); - return image_init_result::PASS; + return std::error_condition(); } void ti99_cartridge_device::call_unload() diff --git a/src/devices/bus/ti99/gromport/cartridges.h b/src/devices/bus/ti99/gromport/cartridges.h index 68593bf1ac8..00aba4d3797 100644 --- a/src/devices/bus/ti99/gromport/cartridges.h +++ b/src/devices/bus/ti99/gromport/cartridges.h @@ -51,7 +51,7 @@ protected: virtual const tiny_rom_entry* device_rom_region() const override; // Image handling: implementation of methods which are abstract in the parent - image_init_result call_load() override; + std::error_condition call_load() override; void call_unload() override; void prepare_cartridge(); diff --git a/src/devices/bus/ti99/peb/ti_rs232.cpp b/src/devices/bus/ti99/peb/ti_rs232.cpp index 841acf44ac7..aa74804b1a0 100644 --- a/src/devices/bus/ti99/peb/ti_rs232.cpp +++ b/src/devices/bus/ti99/peb/ti_rs232.cpp @@ -186,14 +186,14 @@ ti_pio_attached_device::ti_pio_attached_device(const machine_config &mconfig, co /* Initialize rs232 unit and open image */ -image_init_result ti_rs232_attached_device::call_load() +std::error_condition ti_rs232_attached_device::call_load() { m_uart->set_clock(true); // The following line may cause trouble in the init phase // card->incoming_dtr(devnumber, (m_file!=nullptr)? ASSERT_LINE : CLEAR_LINE); - return image_init_result::PASS; // OK + return std::error_condition(); // OK } void ti_rs232_attached_device::call_unload() @@ -204,7 +204,7 @@ void ti_rs232_attached_device::call_unload() /* Initialize pio unit and open image */ -image_init_result ti_pio_attached_device::call_load() +std::error_condition ti_pio_attached_device::call_load() { ti_rs232_pio_device* card = static_cast(owner()); @@ -218,7 +218,7 @@ image_init_result ti_pio_attached_device::call_load() else card->m_pio_handshakein = true; - return image_init_result::PASS; // OK + return std::error_condition(); // OK } /* diff --git a/src/devices/bus/ti99/peb/ti_rs232.h b/src/devices/bus/ti99/peb/ti_rs232.h index e7970538504..43d04013b64 100644 --- a/src/devices/bus/ti99/peb/ti_rs232.h +++ b/src/devices/bus/ti99/peb/ti_rs232.h @@ -146,7 +146,7 @@ public: protected: void device_start() override { } - image_init_result call_load() override; + std::error_condition call_load() override; void call_unload() override; private: @@ -174,7 +174,7 @@ public: protected: void device_start() override { } - image_init_result call_load() override; + std::error_condition call_load() override; void call_unload() override; }; diff --git a/src/devices/bus/ti99/peb/tipi.cpp b/src/devices/bus/ti99/peb/tipi.cpp index 92f45710d33..61ad7b61e12 100644 --- a/src/devices/bus/ti99/peb/tipi.cpp +++ b/src/devices/bus/ti99/peb/tipi.cpp @@ -675,9 +675,9 @@ tipi_attached_device::tipi_attached_device(const machine_config &mconfig, const /* Initialize connection */ -image_init_result tipi_attached_device::call_load() +std::error_condition tipi_attached_device::call_load() { - return image_init_result::PASS; // OK + return std::error_condition(); // OK } void tipi_attached_device::call_unload() diff --git a/src/devices/bus/ti99/peb/tipi.h b/src/devices/bus/ti99/peb/tipi.h index 3703e246599..814a0f435ce 100644 --- a/src/devices/bus/ti99/peb/tipi.h +++ b/src/devices/bus/ti99/peb/tipi.h @@ -116,7 +116,7 @@ public: protected: void device_start() override { } void call_unload() override; - image_init_result call_load() override; + std::error_condition call_load() override; }; diff --git a/src/devices/bus/ti99x/990_hd.cpp b/src/devices/bus/ti99x/990_hd.cpp index c3b3300e1d7..9912d86e28c 100644 --- a/src/devices/bus/ti99x/990_hd.cpp +++ b/src/devices/bus/ti99x/990_hd.cpp @@ -162,7 +162,7 @@ int ti990_hdc_device::get_id_from_device( device_t *device ) /* Initialize hard disk unit and open a hard disk image */ -image_init_result ti990_hdc_device::load_hd(device_image_interface &image) +std::error_condition ti990_hdc_device::load_hd(device_image_interface &image) { int id = get_id_from_device( &image.device() ); hd_unit_t *d; @@ -206,7 +206,7 @@ image_init_result ti990_hdc_device::load_hd(device_image_interface &image) d->format = format_mame; /* don't care */ d->wp = 1; d->unsafe = 1; - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } d->cylinders = get_UINT32BE(custom_header.cylinders); @@ -221,7 +221,7 @@ image_init_result ti990_hdc_device::load_hd(device_image_interface &image) d->hd_handle = nullptr; d->wp = 1; d->unsafe = 1; - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } /* tell whether the image is writable */ @@ -231,7 +231,7 @@ image_init_result ti990_hdc_device::load_hd(device_image_interface &image) /* set attention line */ m_w[0] |= (0x80 >> id); - return image_init_result::PASS; + return std::error_condition(); } /* diff --git a/src/devices/bus/ti99x/990_hd.h b/src/devices/bus/ti99x/990_hd.h index 32322b20965..bb5519a9474 100644 --- a/src/devices/bus/ti99x/990_hd.h +++ b/src/devices/bus/ti99x/990_hd.h @@ -18,7 +18,7 @@ public: uint16_t read(offs_t offset); void write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - image_init_result load_hd(device_image_interface &image); + std::error_condition load_hd(device_image_interface &image); void unload_hd(device_image_interface &image); template void set_memory_space(T &&tag, int spacenum) { m_memory_space.set_tag(std::forward(tag), spacenum); } diff --git a/src/devices/bus/ti99x/990_tap.cpp b/src/devices/bus/ti99x/990_tap.cpp index dff4f68a7a0..83bab21a682 100644 --- a/src/devices/bus/ti99x/990_tap.cpp +++ b/src/devices/bus/ti99x/990_tap.cpp @@ -898,7 +898,7 @@ public: // image-level overrides virtual const char *file_extensions() const noexcept override { return "tap"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; protected: @@ -935,12 +935,12 @@ int ti990_tape_image_device::tape_get_id() /* Open a tape image */ -image_init_result ti990_tape_image_device::call_load() +std::error_condition ti990_tape_image_device::call_load() { tap_990_device* tpc = downcast(owner()); tpc->set_tape(tape_get_id(), this, true, false, is_readonly()); - return image_init_result::PASS; + return std::error_condition(); } /* diff --git a/src/devices/bus/vboy/rom.cpp b/src/devices/bus/vboy/rom.cpp index d2ee88d09e8..65724108b41 100644 --- a/src/devices/bus/vboy/rom.cpp +++ b/src/devices/bus/vboy/rom.cpp @@ -39,7 +39,7 @@ vboy_flat_rom_device::vboy_flat_rom_device(machine_config const &mconfig, device } -image_init_result vboy_flat_rom_device::load() +std::error_condition vboy_flat_rom_device::load() { // if the host has supplied a ROM space, install with appropriate mirroring memory_region *const romregion(memregion("^rom")); @@ -77,7 +77,7 @@ image_init_result vboy_flat_rom_device::load() }); } - return image_init_result::PASS; + return std::error_condition(); } @@ -97,10 +97,10 @@ vboy_flat_rom_sram_device::vboy_flat_rom_sram_device(machine_config const &mconf } -image_init_result vboy_flat_rom_sram_device::load() +std::error_condition vboy_flat_rom_sram_device::load() { - image_init_result const result(vboy_flat_rom_device::load()); - if (image_init_result::PASS != result) + std::error_condition const result(vboy_flat_rom_device::load()); + if (result) return result; memory_region *const sramregion(memregion("^sram")); @@ -184,7 +184,7 @@ image_init_result vboy_flat_rom_sram_device::load() battery_load(sramregion->base(), sramregion->bytes(), nullptr); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/vboy/rom.h b/src/devices/bus/vboy/rom.h index 79ad95f2e9a..5e369783a10 100644 --- a/src/devices/bus/vboy/rom.h +++ b/src/devices/bus/vboy/rom.h @@ -18,7 +18,7 @@ public: vboy_flat_rom_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); // device_vboy_cart_interface implementation - virtual image_init_result load() override ATTR_COLD; + virtual std::error_condition load() override ATTR_COLD; protected: vboy_flat_rom_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock); @@ -34,7 +34,7 @@ public: vboy_flat_rom_sram_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock); // device_vboy_cart_interface implementation - virtual image_init_result load() override ATTR_COLD; + virtual std::error_condition load() override ATTR_COLD; virtual void unload() override ATTR_COLD; }; diff --git a/src/devices/bus/vboy/slot.cpp b/src/devices/bus/vboy/slot.cpp index 65ecdfa8f88..6b71c47f162 100644 --- a/src/devices/bus/vboy/slot.cpp +++ b/src/devices/bus/vboy/slot.cpp @@ -49,23 +49,23 @@ vboy_cart_slot_device::vboy_cart_slot_device(machine_config const &mconfig, char } -image_init_result vboy_cart_slot_device::call_load() +std::error_condition vboy_cart_slot_device::call_load() { if (!m_cart) - return image_init_result::PASS; + return std::error_condition(); memory_region *romregion(loaded_through_softlist() ? memregion("rom") : nullptr); if (loaded_through_softlist() && !romregion) { - seterror(image_error::INVALIDIMAGE, "Software list item has no 'rom' data area"); - return image_init_result::FAIL; + osd_printf_error("%s: Software list item has no 'rom' data area\n", basename()); + return image_error::BADSOFTWARE; } u32 const len(loaded_through_softlist() ? romregion->bytes() : length()); if ((0x0000'0003 & len) || (0x0100'0000 < len)) { - seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size (must be a multiple of 4 bytes no larger than 16 MiB)"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size (must be a multiple of 4 bytes no larger than 16 MiB)\n", basename()); + return image_error::INVALIDLENGTH; } if (!loaded_through_softlist()) @@ -75,8 +75,8 @@ image_init_result vboy_cart_slot_device::call_load() u32 const cnt(fread(romregion->base(), len)); if (cnt != len) { - seterror(image_error::UNSPECIFIED, "Error reading cartridge file"); - return image_init_result::FAIL; + osd_printf_error("%s: Error reading cartridge file\n", basename()); + return image_error::UNSPECIFIED; } } diff --git a/src/devices/bus/vboy/slot.h b/src/devices/bus/vboy/slot.h index b628db8af0d..267264ce113 100644 --- a/src/devices/bus/vboy/slot.h +++ b/src/devices/bus/vboy/slot.h @@ -105,7 +105,7 @@ public: template void set_rom(T &&tag, int no, offs_t base) { m_rom_space.set_tag(std::forward(tag), no); m_rom_base = base; } // device_image_interface implementation - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual char const *image_interface() const noexcept override { return "vboy_cart"; } @@ -138,7 +138,7 @@ private: class device_vboy_cart_interface : public device_interface { public: - virtual image_init_result load() ATTR_COLD = 0; + virtual std::error_condition load() ATTR_COLD = 0; virtual void unload() ATTR_COLD; protected: diff --git a/src/devices/bus/vc4000/slot.cpp b/src/devices/bus/vc4000/slot.cpp index 4c8f2dd77c4..6a97f444418 100644 --- a/src/devices/bus/vc4000/slot.cpp +++ b/src/devices/bus/vc4000/slot.cpp @@ -168,7 +168,7 @@ static const char *vc4000_get_slot(int type) call load -------------------------------------------------*/ -image_init_result vc4000_cart_slot_device::call_load() +std::error_condition vc4000_cart_slot_device::call_load() { if (m_cart) { @@ -176,8 +176,8 @@ image_init_result vc4000_cart_slot_device::call_load() if (size > 0x1800) { - seterror(image_error::INVALIDIMAGE, "Image extends beyond the expected size for a VC4000 cart"); - return image_init_result::FAIL; + osd_printf_error("%s: Image extends beyond the expected size for a VC4000 cart\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size); @@ -211,10 +211,10 @@ image_init_result vc4000_cart_slot_device::call_load() //printf("Type: %s\n", vc4000_get_slot(m_type)); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/vc4000/slot.h b/src/devices/bus/vc4000/slot.h index 90f75232699..9da3d6d4d32 100644 --- a/src/devices/bus/vc4000/slot.h +++ b/src/devices/bus/vc4000/slot.h @@ -70,7 +70,7 @@ public: virtual ~vc4000_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override { } virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/vcs/vcs_slot.cpp b/src/devices/bus/vcs/vcs_slot.cpp index 7b9e620c740..d55f94df8ec 100644 --- a/src/devices/bus/vcs/vcs_slot.cpp +++ b/src/devices/bus/vcs/vcs_slot.cpp @@ -199,7 +199,7 @@ static const char *vcs_get_slot(int type) return "a26_2k_4k"; } -image_init_result vcs_cart_slot_device::call_load() +std::error_condition vcs_cart_slot_device::call_load() { if (m_cart) { @@ -221,8 +221,8 @@ image_init_result vcs_cart_slot_device::call_load() break; default: - seterror(image_error::INVALIDIMAGE, "Invalid ROM file size" ); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid ROM file size\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(len, tag()); @@ -311,10 +311,10 @@ image_init_result vcs_cart_slot_device::call_load() m_cart->install_memory_handlers(m_address_space.target()); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/vcs/vcs_slot.h b/src/devices/bus/vcs/vcs_slot.h index 4595602961a..c5c075ee706 100644 --- a/src/devices/bus/vcs/vcs_slot.h +++ b/src/devices/bus/vcs/vcs_slot.h @@ -32,7 +32,7 @@ public: template void set_address_space(T &&tag, int no) { m_address_space.set_tag(std::forward(tag), no); } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/vectrex/slot.cpp b/src/devices/bus/vectrex/slot.cpp index 0b527eaeb27..d7785f98eff 100644 --- a/src/devices/bus/vectrex/slot.cpp +++ b/src/devices/bus/vectrex/slot.cpp @@ -136,7 +136,7 @@ static const char *vectrex_get_slot(int type) call load -------------------------------------------------*/ -image_init_result vectrex_cart_slot_device::call_load() +std::error_condition vectrex_cart_slot_device::call_load() { if (m_cart) { @@ -145,8 +145,8 @@ image_init_result vectrex_cart_slot_device::call_load() if (size > 0x10000) { - seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc((size < 0x1000) ? 0x1000 : size); @@ -160,8 +160,8 @@ image_init_result vectrex_cart_slot_device::call_load() // Verify the file is accepted by the Vectrex bios if (memcmp(ROM, "g GCE", 5)) { - seterror(image_error::INVALIDIMAGE, "Invalid image"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid image\n", basename()); + return image_error::INVALIDIMAGE; } // determine type @@ -183,10 +183,10 @@ image_init_result vectrex_cart_slot_device::call_load() if (!memcmp(ROM + 0x11, "3D MINE STORM", 13)) m_vec3d = VEC3D_MINEST; - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/vectrex/slot.h b/src/devices/bus/vectrex/slot.h index 577338f80fa..b90d3903777 100644 --- a/src/devices/bus/vectrex/slot.h +++ b/src/devices/bus/vectrex/slot.h @@ -68,7 +68,7 @@ public: virtual ~vectrex_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override { } virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/vic10/exp.cpp b/src/devices/bus/vic10/exp.cpp index c09651066ba..5c37878153e 100644 --- a/src/devices/bus/vic10/exp.cpp +++ b/src/devices/bus/vic10/exp.cpp @@ -86,7 +86,7 @@ void vic10_expansion_slot_device::device_start() // call_load - //------------------------------------------------- -image_init_result vic10_expansion_slot_device::call_load() +std::error_condition vic10_expansion_slot_device::call_load() { if (m_card) { @@ -139,7 +139,7 @@ image_init_result vic10_expansion_slot_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/vic10/exp.h b/src/devices/bus/vic10/exp.h index 36098dfc2cf..961b4305f12 100644 --- a/src/devices/bus/vic10/exp.h +++ b/src/devices/bus/vic10/exp.h @@ -87,7 +87,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "vic10_cart"; } diff --git a/src/devices/bus/vic20/exp.cpp b/src/devices/bus/vic20/exp.cpp index 0746b3092da..5c26c7c28e3 100644 --- a/src/devices/bus/vic20/exp.cpp +++ b/src/devices/bus/vic20/exp.cpp @@ -92,7 +92,7 @@ void vic20_expansion_slot_device::device_reset() // call_load - //------------------------------------------------- -image_init_result vic20_expansion_slot_device::call_load() +std::error_condition vic20_expansion_slot_device::call_load() { if (m_card) { @@ -119,7 +119,7 @@ image_init_result vic20_expansion_slot_device::call_load() case 0x7000: fread(m_card->m_blk3, 0x2000, 0x1000); break; case 0xa000: fread(m_card->m_blk5, 0x2000); break; case 0xb000: fread(m_card->m_blk5, 0x2000, 0x1000); break; - default: return image_init_result::FAIL; + default: return image_error::INVALIDIMAGE; } } } @@ -132,7 +132,7 @@ image_init_result vic20_expansion_slot_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/vic20/exp.h b/src/devices/bus/vic20/exp.h index 124bc7bb9c1..202ca79e453 100644 --- a/src/devices/bus/vic20/exp.h +++ b/src/devices/bus/vic20/exp.h @@ -85,7 +85,7 @@ protected: virtual void device_reset() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "vic1001_cart"; } diff --git a/src/devices/bus/vidbrain/exp.cpp b/src/devices/bus/vidbrain/exp.cpp index 42cd7ebe9ba..eddd384d511 100644 --- a/src/devices/bus/vidbrain/exp.cpp +++ b/src/devices/bus/vidbrain/exp.cpp @@ -105,7 +105,7 @@ void videobrain_expansion_slot_device::device_start() // call_load - //------------------------------------------------- -image_init_result videobrain_expansion_slot_device::call_load() +std::error_condition videobrain_expansion_slot_device::call_load() { if (m_cart) { @@ -127,7 +127,7 @@ image_init_result videobrain_expansion_slot_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/vidbrain/exp.h b/src/devices/bus/vidbrain/exp.h index a72cc410adc..8cbaad2e274 100644 --- a/src/devices/bus/vidbrain/exp.h +++ b/src/devices/bus/vidbrain/exp.h @@ -120,7 +120,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_reset_on_load() const noexcept override { return true; } virtual const char *image_interface() const noexcept override { return "vidbrain_cart"; } diff --git a/src/devices/bus/vsmile/vsmile_slot.cpp b/src/devices/bus/vsmile/vsmile_slot.cpp index 5be96466c64..95ec9da38f8 100644 --- a/src/devices/bus/vsmile/vsmile_slot.cpp +++ b/src/devices/bus/vsmile/vsmile_slot.cpp @@ -132,15 +132,15 @@ static int vsmile_get_pcb_id(const char *slot) call load -------------------------------------------------*/ -image_init_result vsmile_cart_slot_device::call_load() +std::error_condition vsmile_cart_slot_device::call_load() { if (m_cart) { uint32_t size = loaded_through_softlist() ? get_software_region_length("rom") : length(); if (size > 0x1000000) { - seterror(image_error::INVALIDIMAGE, "Attempted loading a cart larger than 16MB"); - return image_init_result::FAIL; + osd_printf_error("%s: Attempted loading a cart larger than 16MB\n", basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size); @@ -173,10 +173,10 @@ image_init_result vsmile_cart_slot_device::call_load() battery_load(m_cart->get_nvram_base(), m_cart->get_nvram_size(), 0x00); } - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/vsmile/vsmile_slot.h b/src/devices/bus/vsmile/vsmile_slot.h index 5313abe092b..5585f663329 100644 --- a/src/devices/bus/vsmile/vsmile_slot.h +++ b/src/devices/bus/vsmile/vsmile_slot.h @@ -80,7 +80,7 @@ public: virtual ~vsmile_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/wswan/slot.cpp b/src/devices/bus/wswan/slot.cpp index 959f43f4bd0..d5dc5125876 100644 --- a/src/devices/bus/wswan/slot.cpp +++ b/src/devices/bus/wswan/slot.cpp @@ -150,7 +150,7 @@ static const char *ws_get_slot(int type) call load -------------------------------------------------*/ -image_init_result ws_cart_slot_device::call_load() +std::error_condition ws_cart_slot_device::call_load() { if (m_cart) { @@ -203,7 +203,7 @@ image_init_result ws_cart_slot_device::call_load() internal_header_logging(ROM, ((size >> 16) - 1) << 16, size); } - return image_init_result::PASS; + return std::error_condition(); } /*------------------------------------------------- diff --git a/src/devices/bus/wswan/slot.h b/src/devices/bus/wswan/slot.h index fd9d1928b92..5ae7cb809ee 100644 --- a/src/devices/bus/wswan/slot.h +++ b/src/devices/bus/wswan/slot.h @@ -146,7 +146,7 @@ public: virtual ~ws_cart_slot_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/devices/bus/z88/z88.cpp b/src/devices/bus/z88/z88.cpp index 8a12bb47b82..040d0f99a4e 100644 --- a/src/devices/bus/z88/z88.cpp +++ b/src/devices/bus/z88/z88.cpp @@ -95,7 +95,7 @@ TIMER_CALLBACK_MEMBER(z88cart_slot_device::close_flap) call load -------------------------------------------------*/ -image_init_result z88cart_slot_device::call_load() +std::error_condition z88cart_slot_device::call_load() { if (m_cart) { @@ -116,7 +116,7 @@ image_init_result z88cart_slot_device::call_load() } else { - return image_init_result::FAIL; + return image_error::INTERNAL; } } @@ -126,7 +126,7 @@ image_init_result z88cart_slot_device::call_load() // setup the timer to close the flap m_flp_timer->adjust(CLOSE_FLAP_TIME); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/bus/z88/z88.h b/src/devices/bus/z88/z88.h index bece08cbf72..349534aab00 100644 --- a/src/devices/bus/z88/z88.h +++ b/src/devices/bus/z88/z88.h @@ -105,7 +105,7 @@ public: auto out_flp_callback() { return m_out_flp_cb.bind(); } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return false; } diff --git a/src/devices/imagedev/avivideo.cpp b/src/devices/imagedev/avivideo.cpp index f1a2b7e1cdc..d366785661c 100644 --- a/src/devices/imagedev/avivideo.cpp +++ b/src/devices/imagedev/avivideo.cpp @@ -80,7 +80,7 @@ TIMER_CALLBACK_MEMBER(avivideo_image_device::frame_timer) } } -image_init_result avivideo_image_device::call_load() +std::error_condition avivideo_image_device::call_load() { m_frame = new bitmap_argb32; avi_file::error avierr = avi_file::open(filename(), m_avi); @@ -88,7 +88,7 @@ image_init_result avivideo_image_device::call_load() { delete m_frame; m_frame = nullptr; - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } const avi_file::movie_info &aviinfo = m_avi->get_movie_info(); @@ -97,7 +97,7 @@ image_init_result avivideo_image_device::call_load() m_frame_timer->adjust(frame_time, 0, frame_time); m_frame_count = aviinfo.video_numsamples; m_frame_num = 0; - return image_init_result::PASS; + return std::error_condition(); } void avivideo_image_device::call_unload() diff --git a/src/devices/imagedev/avivideo.h b/src/devices/imagedev/avivideo.h index 5af11df4187..d03396f8b52 100644 --- a/src/devices/imagedev/avivideo.h +++ b/src/devices/imagedev/avivideo.h @@ -30,7 +30,7 @@ public: virtual ~avivideo_image_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_readable() const noexcept override { return true; } diff --git a/src/devices/imagedev/bitbngr.cpp b/src/devices/imagedev/bitbngr.cpp index dc31c4ccb83..07b88f41386 100644 --- a/src/devices/imagedev/bitbngr.cpp +++ b/src/devices/imagedev/bitbngr.cpp @@ -85,16 +85,16 @@ const software_list_loader &bitbanger_device::get_software_list_loader() const call_load -------------------------------------------------*/ -image_init_result bitbanger_device::call_load() +std::error_condition bitbanger_device::call_load() { // we don't need to do anything special - return image_init_result::PASS; + return std::error_condition(); } -image_init_result bitbanger_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition bitbanger_device::call_create(int format_type, util::option_resolution *format_options) { // we don't need to do anything special - return image_init_result::PASS; + return std::error_condition(); } /*------------------------------------------------- diff --git a/src/devices/imagedev/bitbngr.h b/src/devices/imagedev/bitbngr.h index 5b02417cfc3..351d41c2e3a 100644 --- a/src/devices/imagedev/bitbngr.h +++ b/src/devices/imagedev/bitbngr.h @@ -20,8 +20,8 @@ public: bitbanger_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // image-level overrides - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; // image device diff --git a/src/devices/imagedev/cassette.cpp b/src/devices/imagedev/cassette.cpp index 2bf7c2a4808..ff1d0a8ca84 100644 --- a/src/devices/imagedev/cassette.cpp +++ b/src/devices/imagedev/cassette.cpp @@ -248,17 +248,17 @@ const software_list_loader &cassette_image_device::get_software_list_loader() co return image_software_list_loader::instance(); } -image_init_result cassette_image_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition cassette_image_device::call_create(int format_type, util::option_resolution *format_options) { return internal_load(true); } -image_init_result cassette_image_device::call_load() +std::error_condition cassette_image_device::call_load() { return internal_load(false); } -image_init_result cassette_image_device::internal_load(bool is_create) +std::error_condition cassette_image_device::internal_load(bool is_create) { cassette_image::error err; device_image_interface *image = nullptr; @@ -335,7 +335,7 @@ image_init_result cassette_image_device::internal_load(bool is_create) m_speed = 1; m_direction = 1; - return image_init_result::PASS; + return std::error_condition(); } else { @@ -358,8 +358,7 @@ image_init_result cassette_image_device::internal_load(bool is_create) imgerr = image_error::UNSPECIFIED; break; } - image->seterror(imgerr, nullptr); - return image_init_result::FAIL; + return imgerr; } } diff --git a/src/devices/imagedev/cassette.h b/src/devices/imagedev/cassette.h index b35b351599b..56fd8f79b1f 100644 --- a/src/devices/imagedev/cassette.h +++ b/src/devices/imagedev/cassette.h @@ -58,8 +58,8 @@ public: void set_interface(const char *interface) { m_interface = interface; } // image-level overrides - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; virtual std::string call_display() override; @@ -108,7 +108,7 @@ protected: // device-level overrides virtual void device_config_complete() override; virtual void device_start() override; - virtual bool use_software_list_file_extension_for_filetype() const override { return true; } + virtual bool use_software_list_file_extension_for_filetype() const noexcept override { return true; } // device_image_interface implementation virtual const software_list_loader &get_software_list_loader() const override; @@ -130,7 +130,7 @@ private: cassette_state m_default_state; const char * m_interface; - image_init_result internal_load(bool is_create); + std::error_condition internal_load(bool is_create); bool m_stereo; std::vector m_samples; }; diff --git a/src/devices/imagedev/chd_cd.cpp b/src/devices/imagedev/chd_cd.cpp index cf87d17b5ef..d33689b2d27 100644 --- a/src/devices/imagedev/chd_cd.cpp +++ b/src/devices/imagedev/chd_cd.cpp @@ -81,7 +81,7 @@ void cdrom_image_device::device_stop() m_self_chd.close(); } -image_init_result cdrom_image_device::call_load() +std::error_condition cdrom_image_device::call_load() { std::error_condition err; chd_file *chd = nullptr; @@ -112,14 +112,15 @@ image_init_result cdrom_image_device::call_load() if (!m_cdrom_handle) goto error; - return image_init_result::PASS; + return std::error_condition(); error: if (chd && chd == &m_self_chd) m_self_chd.close(); if (err) - seterror(err, nullptr); - return image_init_result::FAIL; + return err; + else + return image_error::UNSPECIFIED; } void cdrom_image_device::call_unload() diff --git a/src/devices/imagedev/chd_cd.h b/src/devices/imagedev/chd_cd.h index e93b7969c62..6eb3504c6a3 100644 --- a/src/devices/imagedev/chd_cd.h +++ b/src/devices/imagedev/chd_cd.h @@ -33,7 +33,7 @@ public: void set_interface(const char *interface) { m_interface = interface; } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_readable() const noexcept override { return true; } diff --git a/src/devices/imagedev/diablo.cpp b/src/devices/imagedev/diablo.cpp index 5f8b45e4064..a50a58448c0 100644 --- a/src/devices/imagedev/diablo.cpp +++ b/src/devices/imagedev/diablo.cpp @@ -97,9 +97,9 @@ void diablo_image_device::device_stop() delete m_hard_disk_handle; } -image_init_result diablo_image_device::call_load() +std::error_condition diablo_image_device::call_load() { - image_init_result our_result; + std::error_condition our_result; our_result = internal_load_dsk(); /* Check if there is an image_load callback defined */ @@ -112,7 +112,7 @@ image_init_result diablo_image_device::call_load() } -image_init_result diablo_image_device::call_create(int create_format, util::option_resolution *create_args) +std::error_condition diablo_image_device::call_create(int create_format, util::option_resolution *create_args) { if (!create_args) throw emu_fatalerror("diablo_image_device::call_create: Expected create_args to not be nullptr"); @@ -132,14 +132,14 @@ image_init_result diablo_image_device::call_create(int create_format, util::opti if (!err) m_origchd.create(std::move(proxy), uint64_t(totalsectors) * uint64_t(sectorsize), hunksize, sectorsize, compression); if (err) - return image_init_result::FAIL; + return err; /* if we created the image and hence, have metadata to set, set the metadata */ err = m_origchd.write_metadata(HARD_DISK_METADATA_TAG, 0, string_format(HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize)); m_origchd.close(); if (err) - return image_init_result::FAIL; + return err; return internal_load_dsk(); } @@ -206,7 +206,7 @@ static std::error_condition open_disk_diff(emu_options &options, const char *nam return std::errc::no_such_file_or_directory; } -image_init_result diablo_image_device::internal_load_dsk() +std::error_condition diablo_image_device::internal_load_dsk() { std::error_condition err; @@ -251,14 +251,16 @@ image_init_result diablo_image_device::internal_load_dsk() /* open the hard disk file */ m_hard_disk_handle = new hard_disk_file(m_chd); if (m_hard_disk_handle != nullptr) - return image_init_result::PASS; + return std::error_condition(); } /* if we had an error, close out the CHD */ m_origchd.close(); m_diffchd.close(); m_chd = nullptr; - seterror(err, nullptr); - return image_init_result::FAIL; + if (err) + return err; + else + return image_error::UNSPECIFIED; } diff --git a/src/devices/imagedev/diablo.h b/src/devices/imagedev/diablo.h index d1eaaa2908e..158ef26d326 100644 --- a/src/devices/imagedev/diablo.h +++ b/src/devices/imagedev/diablo.h @@ -23,7 +23,7 @@ class diablo_image_device : public harddisk_image_base_device { public: - typedef device_delegate load_delegate; + typedef device_delegate load_delegate; typedef device_delegate unload_delegate; // construction/destruction @@ -35,8 +35,8 @@ public: void set_interface(const char *interface) { m_interface = interface; } // image-level overrides - virtual image_init_result call_load() override; - virtual image_init_result call_create(int create_format, util::option_resolution *create_args) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int create_format, util::option_resolution *create_args) override; virtual void call_unload() override; virtual bool image_is_chd_type() const noexcept override { return true; } @@ -56,7 +56,7 @@ protected: // device_image_interface implementation virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); } - image_init_result internal_load_dsk(); + std::error_condition internal_load_dsk(); chd_file *m_chd; chd_file m_origchd; /* handle to the original CHD */ diff --git a/src/devices/imagedev/flopdrv.cpp b/src/devices/imagedev/flopdrv.cpp index eba391f966e..aeac08466c6 100644 --- a/src/devices/imagedev/flopdrv.cpp +++ b/src/devices/imagedev/flopdrv.cpp @@ -40,7 +40,6 @@ struct floppy_error_map { floperr_t ferr; std::error_condition ierr; - const char *message; }; @@ -422,7 +421,7 @@ void legacy_floppy_image_device::floppy_drive_set_controller(device_t *controlle m_controller = controller; } -image_init_result legacy_floppy_image_device::internal_floppy_device_load(bool is_create, int create_format, util::option_resolution *create_args) +std::error_condition legacy_floppy_image_device::internal_floppy_device_load(bool is_create, int create_format, util::option_resolution *create_args) { const struct FloppyFormat *floppy_options = m_config->formats; @@ -459,16 +458,16 @@ image_init_result legacy_floppy_image_device::internal_floppy_device_load(bool i if (m_load_proc) m_load_proc(*this, is_create); - return image_init_result::PASS; + return std::error_condition(); } else { for (int i = 0; i < std::size(errmap); i++) { if (err == errmap[i].ferr) - seterror(errmap[i].ierr, errmap[i].message); + return errmap[i].ierr; } - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } } @@ -728,14 +727,14 @@ const software_list_loader &legacy_floppy_image_device::get_software_list_loader return image_software_list_loader::instance(); } -image_init_result legacy_floppy_image_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition legacy_floppy_image_device::call_create(int format_type, util::option_resolution *format_options) { return internal_floppy_device_load(true, format_type, format_options); } -image_init_result legacy_floppy_image_device::call_load() +std::error_condition legacy_floppy_image_device::call_load() { - image_init_result retVal = internal_floppy_device_load(false, -1, nullptr); + std::error_condition retVal = internal_floppy_device_load(false, -1, nullptr); /* push disk halfway into drive */ m_wpt = CLEAR_LINE; diff --git a/src/devices/imagedev/flopdrv.h b/src/devices/imagedev/flopdrv.h index a3241cc4b89..78d986ff9f4 100644 --- a/src/devices/imagedev/flopdrv.h +++ b/src/devices/imagedev/flopdrv.h @@ -102,8 +102,8 @@ public: void set_floppy_config(const floppy_interface *config) { m_config = config; } auto out_idx_cb() { return m_out_idx_func.bind(); } - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; virtual bool is_readable() const noexcept override { return true; } @@ -159,7 +159,7 @@ private: TIMER_CALLBACK_MEMBER(floppy_drive_index_callback); void floppy_drive_init(); void floppy_drive_index_func(); - image_init_result internal_floppy_device_load(bool is_create, int create_format, util::option_resolution *create_args); + std::error_condition internal_floppy_device_load(bool is_create, int create_format, util::option_resolution *create_args); TIMER_CALLBACK_MEMBER( set_wpt ); protected: diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index 6af8df55f15..e28b59734c3 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -272,7 +272,6 @@ floppy_image_device::floppy_image_device(const machine_config &mconfig, device_t m_flux_screen(*this, "flux") { extension_list[0] = '\0'; - m_err = image_error::INVALIDIMAGE; } //------------------------------------------------- @@ -526,21 +525,17 @@ void floppy_image_device::device_reset() cache_clear(); } -const floppy_image_format_t *floppy_image_device::identify(std::string_view filename) +std::pair floppy_image_device::identify(std::string_view filename) { util::core_file::ptr fd; std::string revised_path; std::error_condition err = util::zippath_fopen(filename, OPEN_FLAG_READ, fd, revised_path); - if(err) { - seterror(err, nullptr); - return nullptr; - } + if(err) + return{ err, nullptr }; auto io = util::random_read_fill(std::move(fd), 0xff); - if(!io) { - seterror(std::errc::not_enough_memory, nullptr); - return nullptr; - } + if(!io) + return{ std::errc::not_enough_memory, nullptr }; int best = 0; const floppy_image_format_t *best_format = nullptr; @@ -552,7 +547,7 @@ const floppy_image_format_t *floppy_image_device::identify(std::string_view file } } - return best_format; + return{ std::error_condition(), best_format }; } void floppy_image_device::init_floppy_load(bool write_supported) @@ -581,13 +576,12 @@ void floppy_image_device::init_floppy_load(bool write_supported) dskchg = 1; } -image_init_result floppy_image_device::call_load() +std::error_condition floppy_image_device::call_load() { check_for_file(); auto io = util::random_read_fill(image_core_file(), 0xff); if(!io) { - seterror(std::errc::not_enough_memory, nullptr); - return image_init_result::FAIL; + return std::errc::not_enough_memory; } int best = 0; @@ -603,15 +597,15 @@ image_init_result floppy_image_device::call_load() } if (!best_format) { - seterror(image_error::INVALIDIMAGE, "Unable to identify the image format"); - return image_init_result::FAIL; + osd_printf_error("%s: Unable to identify the image format\n", filename()); + return image_error::INVALIDIMAGE; } image = std::make_unique(tracks, sides, form_factor); if (!best_format->load(*io, form_factor, variants, image.get())) { - seterror(image_error::UNSUPPORTED, "Incompatible image format or corrupted data"); + osd_printf_error("%s: Incompatible image format or corrupted data\n", filename()); image.reset(); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } output_format = is_readonly() ? nullptr : best_format; @@ -624,7 +618,7 @@ image_init_result floppy_image_device::call_load() flux_image_prepare(); - return image_init_result::PASS; + return std::error_condition(); } void floppy_image_device::flux_image_prepare() @@ -793,7 +787,7 @@ void floppy_image_device::call_unload() set_ready(true); } -image_init_result floppy_image_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition floppy_image_device::call_create(int format_type, util::option_resolution *format_options) { image = std::make_unique(tracks, sides, form_factor); output_format = nullptr; @@ -820,7 +814,7 @@ image_init_result floppy_image_device::call_create(int format_type, util::option flux_image_prepare(); - return image_init_result::PASS; + return std::error_condition(); } void floppy_image_device::init_fs(const fs_info *fs, const fs::meta_data &meta) diff --git a/src/devices/imagedev/floppy.h b/src/devices/imagedev/floppy.h index a76346fd692..ac087aceb83 100644 --- a/src/devices/imagedev/floppy.h +++ b/src/devices/imagedev/floppy.h @@ -82,15 +82,15 @@ public: const std::vector &get_formats() const; const std::vector &get_fs() const { return m_fs; } const floppy_image_format_t *get_load_format() const; - const floppy_image_format_t *identify(std::string_view filename); + std::pair identify(std::string_view filename); void set_rpm(float rpm); void init_fs(const fs_info *fs, const fs::meta_data &meta); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual const char *image_interface() const noexcept override = 0; virtual bool is_readable() const noexcept override { return true; } diff --git a/src/devices/imagedev/harddriv.cpp b/src/devices/imagedev/harddriv.cpp index decb4e09909..8269c586213 100644 --- a/src/devices/imagedev/harddriv.cpp +++ b/src/devices/imagedev/harddriv.cpp @@ -128,14 +128,12 @@ void harddisk_image_device::device_stop() } } -image_init_result harddisk_image_device::call_load() +std::error_condition harddisk_image_device::call_load() { - image_init_result our_result; - - our_result = internal_load_hd(); + std::error_condition our_result = internal_load_hd(); /* Check if there is an image_load callback defined */ - if (!m_device_image_load.isnull()) + if (!our_result && !m_device_image_load.isnull()) { /* Let the override do some additional work/checks */ our_result = m_device_image_load(*this); @@ -144,7 +142,7 @@ image_init_result harddisk_image_device::call_load() } -image_init_result harddisk_image_device::call_create(int create_format, util::option_resolution *create_args) +std::error_condition harddisk_image_device::call_create(int create_format, util::option_resolution *create_args) { if (!create_args) throw emu_fatalerror("harddisk_image_device::call_create: Expected create_args to not be nullptr"); @@ -164,14 +162,14 @@ image_init_result harddisk_image_device::call_create(int create_format, util::op if (!err) err = m_origchd.create(std::move(proxy), uint64_t(totalsectors) * uint64_t(sectorsize), hunksize, sectorsize, compression); if (err) - return image_init_result::FAIL; + return err; /* if we created the image and hence, have metadata to set, set the metadata */ err = m_origchd.write_metadata(HARD_DISK_METADATA_TAG, 0, string_format(HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize)); m_origchd.close(); if (err) - return image_init_result::FAIL; + return err; return internal_load_hd(); } @@ -239,7 +237,7 @@ static std::error_condition open_disk_diff(emu_options &options, const char *nam return std::errc::no_such_file_or_directory; } -image_init_result harddisk_image_device::internal_load_hd() +std::error_condition harddisk_image_device::internal_load_hd() { std::error_condition err; m_chd = nullptr; @@ -296,7 +294,7 @@ image_init_result harddisk_image_device::internal_load_hd() /* open the hard disk file */ m_hard_disk_handle = new hard_disk_file(m_chd); if (m_hard_disk_handle) - return image_init_result::PASS; + return std::error_condition(); } else { @@ -327,17 +325,19 @@ image_init_result harddisk_image_device::internal_load_hd() m_hard_disk_handle = new hard_disk_file(image_core_file(), skip); if (m_hard_disk_handle) - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } /* if we had an error, close out the CHD */ m_origchd.close(); m_diffchd.close(); m_chd = nullptr; - seterror(err, nullptr); - return image_init_result::FAIL; + if (err) + return err; + else + return image_error::UNSPECIFIED; } diff --git a/src/devices/imagedev/harddriv.h b/src/devices/imagedev/harddriv.h index 0b043e48cee..0d93a0259f5 100644 --- a/src/devices/imagedev/harddriv.h +++ b/src/devices/imagedev/harddriv.h @@ -41,7 +41,7 @@ protected: class harddisk_image_device : public harddisk_image_base_device { public: - typedef device_delegate load_delegate; + typedef device_delegate load_delegate; typedef device_delegate unload_delegate; // construction/destruction @@ -58,8 +58,8 @@ public: void set_interface(const char *interface) { m_interface = interface; } // image-level overrides - virtual image_init_result call_load() override; - virtual image_init_result call_create(int create_format, util::option_resolution *create_args) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int create_format, util::option_resolution *create_args) override; virtual void call_unload() override; virtual bool image_is_chd_type() const noexcept override { return true; } @@ -81,7 +81,7 @@ protected: // device_image_interface implementation virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); } - image_init_result internal_load_hd(); + std::error_condition internal_load_hd(); chd_file *m_chd; chd_file m_origchd; /* handle to the original CHD */ diff --git a/src/devices/imagedev/mfmhd.cpp b/src/devices/imagedev/mfmhd.cpp index 7bbab1e97da..f2c04c7d273 100644 --- a/src/devices/imagedev/mfmhd.cpp +++ b/src/devices/imagedev/mfmhd.cpp @@ -413,7 +413,7 @@ void mfm_harddisk_device::device_stop() because we need the number of cylinders, and for generic drives we get them from the CHD. */ -image_init_result mfm_harddisk_device::call_load() +std::error_condition mfm_harddisk_device::call_load() { std::error_condition err; @@ -426,8 +426,7 @@ image_init_result mfm_harddisk_device::call_load() { auto io = util::random_read_write_fill(image_core_file(), 0xff); if(!io) { - seterror(std::errc::not_enough_memory, nullptr); - return image_init_result::FAIL; + return std::errc::not_enough_memory; } m_chd = new chd_file; err = m_chd->open(std::move(io), true); @@ -445,7 +444,7 @@ image_init_result mfm_harddisk_device::call_load() if (m_chd==nullptr) { LOG("m_chd is null\n"); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } // Read the hard disk metadata @@ -453,7 +452,7 @@ image_init_result mfm_harddisk_device::call_load() if (state) { LOG("Failed to read CHD metadata\n"); - return image_init_result::FAIL; + return state; } LOGMASKED(LOG_CONFIG, "CHD metadata: %s\n", metadata.c_str()); @@ -466,7 +465,7 @@ image_init_result mfm_harddisk_device::call_load() if (sscanf(metadata.c_str(), HARD_DISK_METADATA_FORMAT, ¶m.cylinders, ¶m.heads, ¶m.sectors_per_track, ¶m.sector_size) != 4) { LOG("Invalid CHD metadata\n"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } LOGMASKED(LOG_CONFIG, "CHD image has geometry cyl=%d, head=%d, sect=%d, size=%d\n", param.cylinders, param.heads, param.sectors_per_track, param.sector_size); @@ -549,9 +548,9 @@ image_init_result mfm_harddisk_device::call_load() else { LOGMASKED(LOG_WARN, "Could not load CHD\n"); - return image_init_result::FAIL; + return err; } - return image_init_result::PASS; + return std::error_condition(); } const char *MFMHD_REC_METADATA_FORMAT = "IL:%d,CSKEW:%d,HSKEW:%d,WPCOM:%d,RWC:%d"; diff --git a/src/devices/imagedev/mfmhd.h b/src/devices/imagedev/mfmhd.h index ce66a43fa3b..f3dade1a792 100644 --- a/src/devices/imagedev/mfmhd.h +++ b/src/devices/imagedev/mfmhd.h @@ -99,7 +99,7 @@ public: // Head select void headsel_w(int head) { m_current_head = head & 0x0f; } - image_init_result call_load() override; + std::error_condition call_load() override; void call_unload() override; // Tells us the time when the track ends (next index pulse). Needed by the controller. diff --git a/src/devices/imagedev/microdrv.cpp b/src/devices/imagedev/microdrv.cpp index 02168270523..51bbae324fa 100644 --- a/src/devices/imagedev/microdrv.cpp +++ b/src/devices/imagedev/microdrv.cpp @@ -79,10 +79,10 @@ void microdrive_image_device::device_start() m_comms_out = 0; } -image_init_result microdrive_image_device::call_load() +std::error_condition microdrive_image_device::call_load() { if (length() != MDV_IMAGE_LENGTH) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; // huh for (int i = 0; i < MDV_IMAGE_LENGTH / 2; i++) @@ -94,7 +94,7 @@ image_init_result microdrive_image_device::call_load() m_bit_offset = 0; m_byte_offset = 0; - return image_init_result::PASS; + return std::error_condition(); } void microdrive_image_device::call_unload() diff --git a/src/devices/imagedev/microdrv.h b/src/devices/imagedev/microdrv.h index 5bd7d6a37da..efa55c8968f 100644 --- a/src/devices/imagedev/microdrv.h +++ b/src/devices/imagedev/microdrv.h @@ -40,7 +40,7 @@ public: auto comms_out_wr_callback() { return m_write_comms_out.bind(); } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_creatable() const noexcept override { return false; } diff --git a/src/devices/imagedev/midiin.cpp b/src/devices/imagedev/midiin.cpp index 59211d06f88..b5a5e06b197 100644 --- a/src/devices/imagedev/midiin.cpp +++ b/src/devices/imagedev/midiin.cpp @@ -165,11 +165,11 @@ TIMER_CALLBACK_MEMBER(midiin_device::midi_update) call_load -------------------------------------------------*/ -image_init_result midiin_device::call_load() +std::error_condition midiin_device::call_load() { // attempt to load if it's a real file - m_err = load_image_by_path(OPEN_FLAG_READ, filename()); - if (!m_err) + std::error_condition err = load_image_by_path(OPEN_FLAG_READ, filename()); + if (!err) { // if the parsing succeeds, schedule the start to happen at least // 10 seconds after starting to allow the keyboards to initialize @@ -178,9 +178,9 @@ image_init_result midiin_device::call_load() { m_sequence_start = std::max(machine().time(), attotime(10, 0)); m_timer->adjust(attotime::zero); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } else { @@ -189,11 +189,11 @@ image_init_result midiin_device::call_load() if (!m_midi->open_input(filename())) { m_midi.reset(); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } m_timer->adjust(attotime::from_hz(1500), 0, attotime::from_hz(1500)); - return image_init_result::PASS; + return std::error_condition(); } } @@ -460,7 +460,7 @@ midiin_device::midi_event &midiin_device::midi_sequence::event_at(u32 tick) // parse - parse a MIDI sequence from a buffer //------------------------------------------------- -bool midiin_device::midi_sequence::parse(util::random_read &stream, u32 length) +std::error_condition midiin_device::midi_sequence::parse(util::random_read &stream, u32 length) { // start with an empty list of events m_list.clear(); @@ -497,14 +497,14 @@ bool midiin_device::midi_sequence::parse(util::random_read &stream, u32 length) } } m_iterator = m_list.begin(); - return true; + return std::error_condition(); } catch (midi_parser::error &err) { osd_printf_error("MIDI file error: %s\n", err.description()); m_list.clear(); m_iterator = m_list.begin(); - return false; + return image_error::UNSPECIFIED; } } diff --git a/src/devices/imagedev/midiin.h b/src/devices/imagedev/midiin.h index aed7d3b15a9..a95fde1570d 100644 --- a/src/devices/imagedev/midiin.h +++ b/src/devices/imagedev/midiin.h @@ -32,7 +32,7 @@ public: auto input_callback() { return m_input_cb.bind(); } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; // image device @@ -155,7 +155,7 @@ private: void clear() { m_list.clear(); } // parse a new sequence - bool parse(util::random_read &stream, u32 length); + std::error_condition parse(util::random_read &stream, u32 length); // rewind to the start of time void rewind(attotime const &basetime); diff --git a/src/devices/imagedev/midiout.cpp b/src/devices/imagedev/midiout.cpp index 026b6520143..7b44dde0c95 100644 --- a/src/devices/imagedev/midiout.cpp +++ b/src/devices/imagedev/midiout.cpp @@ -55,17 +55,17 @@ void midiout_device::device_reset() call_load -------------------------------------------------*/ -image_init_result midiout_device::call_load() +std::error_condition midiout_device::call_load() { m_midi = machine().osd().create_midi_device(); if (!m_midi->open_output(filename())) { m_midi.reset(); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } - return image_init_result::PASS; + return std::error_condition(); } /*------------------------------------------------- diff --git a/src/devices/imagedev/midiout.h b/src/devices/imagedev/midiout.h index 7b39e4fff5e..c52c79a3e55 100644 --- a/src/devices/imagedev/midiout.h +++ b/src/devices/imagedev/midiout.h @@ -30,7 +30,7 @@ public: ~midiout_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; // image device diff --git a/src/devices/imagedev/picture.cpp b/src/devices/imagedev/picture.cpp index b617cd2eeba..e0d569d0922 100644 --- a/src/devices/imagedev/picture.cpp +++ b/src/devices/imagedev/picture.cpp @@ -42,7 +42,7 @@ void picture_image_device::device_start() { } -image_init_result picture_image_device::call_load() +std::error_condition picture_image_device::call_load() { switch (render_detect_image(image_core_file())) { @@ -62,7 +62,10 @@ image_init_result picture_image_device::call_load() m_picture.reset(); } - return m_picture.valid() ? image_init_result::PASS : image_init_result::FAIL; + if (m_picture.valid()) + return std::error_condition(); + else + return image_error::UNSPECIFIED; } void picture_image_device::call_unload() diff --git a/src/devices/imagedev/picture.h b/src/devices/imagedev/picture.h index b53dab22062..2e88a4b4de5 100644 --- a/src/devices/imagedev/picture.h +++ b/src/devices/imagedev/picture.h @@ -30,7 +30,7 @@ public: virtual ~picture_image_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_readable() const noexcept override { return true; } diff --git a/src/devices/imagedev/printer.cpp b/src/devices/imagedev/printer.cpp index 2eb187d843a..3189bd86d01 100644 --- a/src/devices/imagedev/printer.cpp +++ b/src/devices/imagedev/printer.cpp @@ -68,7 +68,7 @@ void printer_image_device::output(uint8_t data) DEVICE_IMAGE_CREATE( printer ) -------------------------------------------------*/ -image_init_result printer_image_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition printer_image_device::call_create(int format_type, util::option_resolution *format_options) { return call_load(); } @@ -76,14 +76,14 @@ image_init_result printer_image_device::call_create(int format_type, util::optio /*------------------------------------------------- DEVICE_IMAGE_LOAD( printer ) -------------------------------------------------*/ -image_init_result printer_image_device::call_load() +std::error_condition printer_image_device::call_load() { /* send notify that the printer is now online */ if (!m_online_cb.isnull()) m_online_cb(true); /* we don't need to do anything special */ - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/imagedev/printer.h b/src/devices/imagedev/printer.h index f509527a014..a4183a3f767 100644 --- a/src/devices/imagedev/printer.h +++ b/src/devices/imagedev/printer.h @@ -30,8 +30,8 @@ public: auto online_callback() { return m_online_cb.bind(); } // image-level overrides - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; // image device diff --git a/src/devices/imagedev/snapquik.cpp b/src/devices/imagedev/snapquik.cpp index 53c682827ea..5ceb095d2de 100644 --- a/src/devices/imagedev/snapquik.cpp +++ b/src/devices/imagedev/snapquik.cpp @@ -12,9 +12,10 @@ #include "snapquik.h" #include "softlist_dev.h" +#include "ui/uimain.h" // device type definition -DEFINE_DEVICE_TYPE(SNAPSHOT, snapshot_image_device, "snapsot_image", "Snapshot") +DEFINE_DEVICE_TYPE(SNAPSHOT, snapshot_image_device, "snapshot_image", "Snapshot") //------------------------------------------------- // snapshot_image_device - constructor @@ -51,7 +52,7 @@ TIMER_CALLBACK_MEMBER(snapshot_image_device::process_snapshot_or_quickload) { check_for_file(); - /* invoke the load */ + // invoke the load (FIXME: don't swallow errors) m_load(*this); } @@ -70,11 +71,11 @@ void snapshot_image_device::device_start() /*------------------------------------------------- call_load -------------------------------------------------*/ -image_init_result snapshot_image_device::call_load() +std::error_condition snapshot_image_device::call_load() { /* adjust the timer */ m_timer->adjust(m_delay, 0); - return image_init_result::PASS; + return std::error_condition(); } const software_list_loader &snapshot_image_device::get_software_list_loader() const @@ -83,6 +84,18 @@ const software_list_loader &snapshot_image_device::get_software_list_loader() co } +//------------------------------------------------- +// show_message - used to display a message while +// loading +//------------------------------------------------- + +void snapshot_image_device::show_message(util::format_argument_pack const &args) +{ + // display the popup for a standard amount of time + machine().ui().popup_time(5, "%s: %s", basename(), util::string_format(args)); +} + + // device type definition DEFINE_DEVICE_TYPE(QUICKLOAD, quickload_image_device, "quickload", "Quickload") diff --git a/src/devices/imagedev/snapquik.h b/src/devices/imagedev/snapquik.h index f312e4d4f39..9c090cdf36d 100644 --- a/src/devices/imagedev/snapquik.h +++ b/src/devices/imagedev/snapquik.h @@ -18,7 +18,7 @@ class snapshot_image_device : public device_t, public device_image_interface { public: - typedef device_delegate load_delegate; + typedef device_delegate load_delegate; // construction/destruction snapshot_image_device(const machine_config &mconfig, const char *tag, device_t *owner, const char* extensions, attotime delay = attotime::zero) @@ -33,7 +33,7 @@ public: void set_interface(const char *interface) { m_interface = interface; } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_readable() const noexcept override { return true; } virtual bool is_writeable() const noexcept override { return false; } @@ -48,6 +48,12 @@ public: void set_delay(attotime delay) { m_delay = delay; } template void set_load_callback(T &&... args) { m_load.set(std::forward(args)...); } + template void message(Format &&fmt, Params &&...args) + { + // format the message + show_message(util::make_format_argument_pack(std::forward(fmt), std::forward(args)...)); + } + protected: snapshot_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); @@ -59,6 +65,8 @@ protected: TIMER_CALLBACK_MEMBER(process_snapshot_or_quickload); + void show_message(util::format_argument_pack const &args); + load_delegate m_load; /* loading function */ const char * m_file_extensions; /* file extensions */ const char * m_interface; @@ -93,10 +101,10 @@ DECLARE_DEVICE_TYPE(QUICKLOAD, quickload_image_device) /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define SNAPSHOT_LOAD_MEMBER(_name) image_init_result _name(device_image_interface &image) +#define SNAPSHOT_LOAD_MEMBER(_name) std::error_condition _name(snapshot_image_device &image) #define DECLARE_SNAPSHOT_LOAD_MEMBER(_name) SNAPSHOT_LOAD_MEMBER(_name) -#define QUICKLOAD_LOAD_MEMBER(_name) image_init_result _name(device_image_interface &image) +#define QUICKLOAD_LOAD_MEMBER(_name) std::error_condition _name(snapshot_image_device &image) #define DECLARE_QUICKLOAD_LOAD_MEMBER(_name) QUICKLOAD_LOAD_MEMBER(_name) #endif // MAME_DEVICES_IMAGEDEV_SNAPQUIK_H diff --git a/src/devices/imagedev/wafadrive.cpp b/src/devices/imagedev/wafadrive.cpp index 237e809075b..342efe093d1 100644 --- a/src/devices/imagedev/wafadrive.cpp +++ b/src/devices/imagedev/wafadrive.cpp @@ -41,9 +41,9 @@ void wafadrive_image_device::device_start() { } -image_init_result wafadrive_image_device::call_load() +std::error_condition wafadrive_image_device::call_load() { - return image_init_result::PASS; + return std::error_condition(); } void wafadrive_image_device::call_unload() diff --git a/src/devices/imagedev/wafadrive.h b/src/devices/imagedev/wafadrive.h index 532288dcba9..00203f4cded 100644 --- a/src/devices/imagedev/wafadrive.h +++ b/src/devices/imagedev/wafadrive.h @@ -30,7 +30,7 @@ public: virtual ~wafadrive_image_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_creatable() const noexcept override { return false; } // should be (although would need a way to specify size) diff --git a/src/devices/machine/ds6417.cpp b/src/devices/machine/ds6417.cpp index 51ae6e7a201..75905ef80a9 100644 --- a/src/devices/machine/ds6417.cpp +++ b/src/devices/machine/ds6417.cpp @@ -37,19 +37,19 @@ void ds6417_device::device_reset() m_command = 0; } -image_init_result ds6417_device::call_load() +std::error_condition ds6417_device::call_load() { if(length() != 32768) - return image_init_result::FAIL; - return image_init_result::PASS; + return image_error::INVALIDLENGTH; + return std::error_condition(); } -image_init_result ds6417_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition ds6417_device::call_create(int format_type, util::option_resolution *format_options) { u8 buffer[32768] = {0}; if(fwrite(buffer, 32768) != 32768) - return image_init_result::FAIL; - return image_init_result::PASS; + return std::errc::io_error; + return std::error_condition(); } uint8_t ds6417_device::calccrc(uint8_t bit, uint8_t crc) const diff --git a/src/devices/machine/ds6417.h b/src/devices/machine/ds6417.h index 94d5e109426..beccdbe3c60 100644 --- a/src/devices/machine/ds6417.h +++ b/src/devices/machine/ds6417.h @@ -21,8 +21,8 @@ public: virtual bool is_reset_on_load() const noexcept override { return false; } virtual const char *file_extensions() const noexcept override { return "bin"; } - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; DECLARE_WRITE_LINE_MEMBER(data_w) { if(!m_read) m_data = state; } DECLARE_WRITE_LINE_MEMBER(clock_w); diff --git a/src/devices/machine/hp_dc100_tape.cpp b/src/devices/machine/hp_dc100_tape.cpp index 2afd9d78beb..8e735834e6c 100644 --- a/src/devices/machine/hp_dc100_tape.cpp +++ b/src/devices/machine/hp_dc100_tape.cpp @@ -85,12 +85,12 @@ hp_dc100_tape_device::hp_dc100_tape_device(const machine_config &mconfig, const { } -image_init_result hp_dc100_tape_device::call_load() +std::error_condition hp_dc100_tape_device::call_load() { return internal_load(false); } -image_init_result hp_dc100_tape_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition hp_dc100_tape_device::call_create(int format_type, util::option_resolution *format_options) { return internal_load(true); } @@ -596,7 +596,7 @@ void hp_dc100_tape_device::clear_state() set_tape_present(is_loaded()); } -image_init_result hp_dc100_tape_device::internal_load(bool is_create) +std::error_condition hp_dc100_tape_device::internal_load(bool is_create) { LOG("load %d\n", is_create); @@ -607,9 +607,8 @@ image_init_result hp_dc100_tape_device::internal_load(bool is_create) auto io = util::random_read_write_fill(image_core_file(), 0); if (!io) { LOG("out of memory\n"); - seterror(std::errc::not_enough_memory, nullptr); set_tape_present(false); - return image_init_result::FAIL; + return std::errc::not_enough_memory; } m_image.clear_tape(); m_image.save_tape(*io); @@ -617,15 +616,14 @@ image_init_result hp_dc100_tape_device::internal_load(bool is_create) auto io = util::random_read_fill(image_core_file(), 0); if (!io) { LOG("out of memory\n"); - seterror(std::errc::not_enough_memory, nullptr); set_tape_present(false); - return image_init_result::FAIL; + return std::errc::not_enough_memory; } if (!m_image.load_tape(*io)) { LOG("load failed\n"); - seterror(image_error::INVALIDIMAGE, "Wrong format"); + //seterror(image_error::INVALIDIMAGE, "Wrong format"); set_tape_present(false); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } } LOG("load OK\n"); @@ -633,7 +631,7 @@ image_init_result hp_dc100_tape_device::internal_load(bool is_create) m_image_dirty = false; set_tape_present(true); - return image_init_result::PASS; + return std::error_condition(); } void hp_dc100_tape_device::set_tape_present(bool present) diff --git a/src/devices/machine/hp_dc100_tape.h b/src/devices/machine/hp_dc100_tape.h index fd8ff3b5425..1642149211a 100644 --- a/src/devices/machine/hp_dc100_tape.h +++ b/src/devices/machine/hp_dc100_tape.h @@ -24,8 +24,8 @@ public: hp_dc100_tape_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // device_image_interface overrides - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; virtual std::string call_display() override; virtual const char *file_extensions() const noexcept override; @@ -157,7 +157,7 @@ private: bool m_image_dirty; void clear_state(); - image_init_result internal_load(bool is_create); + std::error_condition internal_load(bool is_create); void set_tape_present(bool present); double compute_set_point(tape_speed_t speed , bool fwd) const; void start_tape(); diff --git a/src/devices/machine/i7220.cpp b/src/devices/machine/i7220.cpp index 9d9c788759f..dcb8697f936 100644 --- a/src/devices/machine/i7220.cpp +++ b/src/devices/machine/i7220.cpp @@ -108,13 +108,13 @@ void i7220_device::device_reset() memset(&m_regs, 0, sizeof(m_regs)); } -image_init_result i7220_device::call_load() +std::error_condition i7220_device::call_load() { if (length() != (m_data_size * I7110_MBM_SIZE)) { - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/devices/machine/i7220.h b/src/devices/machine/i7220.h index f961d64559e..eb0068927db 100644 --- a/src/devices/machine/i7220.h +++ b/src/devices/machine/i7220.h @@ -50,7 +50,7 @@ public: void set_data_size(int data_size) { m_data_size = data_size; } // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_readable() const noexcept override { return true; } virtual bool is_writeable() const noexcept override { return true; } diff --git a/src/devices/machine/pccard_sram.cpp b/src/devices/machine/pccard_sram.cpp index 1a4f652a814..432b64e84fd 100644 --- a/src/devices/machine/pccard_sram.cpp +++ b/src/devices/machine/pccard_sram.cpp @@ -173,22 +173,22 @@ pccard_mitsubishi_sram_device::pccard_mitsubishi_sram_device(const machine_confi { } -image_init_result pccard_mitsubishi_sram_device::call_load() +std::error_condition pccard_mitsubishi_sram_device::call_load() { card_inserted(false); if (length() != m_sram.bytes()) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; if (fread(&m_sram[0], m_sram.bytes()) != m_sram.bytes()) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; card_inserted(true); - return image_init_result::PASS; + return std::error_condition(); } -image_init_result pccard_mitsubishi_sram_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition pccard_mitsubishi_sram_device::call_create(int format_type, util::option_resolution *format_options) { card_inserted(false); @@ -196,11 +196,11 @@ image_init_result pccard_mitsubishi_sram_device::call_create(int format_type, ut std::fill_n(&m_sram[0], m_sram.length(), 0); if (fwrite(&m_sram[0], m_sram.bytes()) != m_sram.bytes()) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; card_inserted(true); - return image_init_result::PASS; + return std::error_condition(); } void pccard_mitsubishi_sram_device::call_unload() @@ -255,25 +255,25 @@ pccard_centennial_sram_device::pccard_centennial_sram_device(const machine_confi { } -image_init_result pccard_centennial_sram_device::call_load() +std::error_condition pccard_centennial_sram_device::call_load() { card_inserted(false); if (length() != m_sram.bytes() + m_eeprom.bytes()) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; if (fread(&m_sram[0], m_sram.bytes()) != m_sram.bytes()) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; if (fread(&m_eeprom[0], m_eeprom.bytes()) != m_eeprom.bytes()) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; card_inserted(true); - return image_init_result::PASS; + return std::error_condition(); } -image_init_result pccard_centennial_sram_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition pccard_centennial_sram_device::call_create(int format_type, util::option_resolution *format_options) { card_inserted(false); @@ -284,14 +284,14 @@ image_init_result pccard_centennial_sram_device::call_create(int format_type, ut std::copy_n(m_eeprom_default->base(), m_eeprom.length(), &m_eeprom[0]); if (fwrite(&m_sram[0], m_sram.bytes()) != m_sram.bytes()) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; if (fwrite(&m_eeprom[0], m_eeprom.bytes()) != m_eeprom.bytes()) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; card_inserted(true); - return image_init_result::PASS; + return std::error_condition(); } void pccard_centennial_sram_device::call_unload() diff --git a/src/devices/machine/pccard_sram.h b/src/devices/machine/pccard_sram.h index 2cc43e335c1..dc17aded95a 100644 --- a/src/devices/machine/pccard_sram.h +++ b/src/devices/machine/pccard_sram.h @@ -77,8 +77,8 @@ protected: protected: // device_image_interface overrides - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; private: @@ -102,8 +102,8 @@ protected: protected: // device_image_interface overrides - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; private: diff --git a/src/devices/machine/smartmed.cpp b/src/devices/machine/smartmed.cpp index 1c54d36d174..27492fd8b31 100644 --- a/src/devices/machine/smartmed.cpp +++ b/src/devices/machine/smartmed.cpp @@ -121,19 +121,19 @@ void nand_device::device_start() /* Load a SmartMedia image */ -image_init_result smartmedia_image_device::smartmedia_format_1() +std::error_condition smartmedia_image_device::smartmedia_format_1() { SM_disk_image_header custom_header; const int bytes_read = fread(&custom_header, sizeof(custom_header)); if (bytes_read != sizeof(custom_header)) { - return image_init_result::FAIL; + return std::errc::io_error; } if (custom_header.version > 1) { - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } m_page_data_size = get_UINT32BE(custom_header.page_data_size); @@ -177,7 +177,7 @@ image_init_result smartmedia_image_device::smartmedia_format_1() m_image_format = 1; #endif - return image_init_result::PASS; + return std::error_condition(); } int smartmedia_image_device::detect_geometry( uint8_t id1, uint8_t id2) @@ -216,24 +216,24 @@ int smartmedia_image_device::detect_geometry( uint8_t id1, uint8_t id2) return result; } -image_init_result smartmedia_image_device::smartmedia_format_2() +std::error_condition smartmedia_image_device::smartmedia_format_2() { disk_image_format_2_header custom_header; const int bytes_read = fread(&custom_header, sizeof(custom_header)); if (bytes_read != sizeof(custom_header)) { - return image_init_result::FAIL; + return std::errc::io_error; } if ((custom_header.data1[0] != 0xEC) && (custom_header.data1[0] != 0x98)) { - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } if (!detect_geometry(custom_header.data1[0], custom_header.data1[1])) { - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } m_feeprom_data_alloc = std::make_unique(m_page_total_size*m_num_pages); @@ -269,17 +269,17 @@ image_init_result smartmedia_image_device::smartmedia_format_2() m_image_format = 2; #endif - return image_init_result::PASS; + return std::error_condition(); } -image_init_result smartmedia_image_device::call_load() +std::error_condition smartmedia_image_device::call_load() { - image_init_result result; + std::error_condition result; uint64_t position; // try format 1 position = ftell(); result = smartmedia_format_1(); - if (result != image_init_result::PASS) + if (result) { // try format 2 fseek(position, SEEK_SET); diff --git a/src/devices/machine/smartmed.h b/src/devices/machine/smartmed.h index 77c7d53b209..c44c106c14b 100644 --- a/src/devices/machine/smartmed.h +++ b/src/devices/machine/smartmed.h @@ -207,14 +207,14 @@ public: virtual const char *image_interface() const noexcept override { return "sm_memc"; } virtual const char *file_extensions() const noexcept override { return "smc"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; protected: virtual const software_list_loader &get_software_list_loader() const override; - image_init_result smartmedia_format_1(); - image_init_result smartmedia_format_2(); + std::error_condition smartmedia_format_1(); + std::error_condition smartmedia_format_2(); int detect_geometry(uint8_t id1, uint8_t id2); }; diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 0a069f183c5..10756496382 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -3990,8 +3990,9 @@ void debugger_commands::execute_mount(const std::vector ¶m { if ((img.instance_name() == params[0]) || (img.brief_instance_name() == params[0])) { - if (img.load(params[1]) != image_init_result::PASS) - m_console.printf("Unable to mount file %s on %s\n", params[1], params[0]); + std::error_condition err = img.load(params[1]); + if (err) + m_console.printf("Unable to mount file %s on %s: %s\n", params[1], params[0], err.message()); else m_console.printf("File %s mounted on %s\n", params[1], params[0]); return; diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp index 9aafaeb26c7..00002b3ceac 100644 --- a/src/emu/diimage.cpp +++ b/src/emu/diimage.cpp @@ -16,15 +16,12 @@ #include "softlist.h" #include "softlist_dev.h" -#include "ui/uimain.h" - #include "corestr.h" #include "opresolv.h" #include "path.h" #include "zippath.h" #include -#include #include #include #include @@ -68,7 +65,6 @@ image_device_format::~image_device_format() device_image_interface::device_image_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "image") - , m_err() , m_file() , m_mame_file() , m_software_part_ptr(nullptr) @@ -145,9 +141,9 @@ bool device_image_interface::is_filetype(std::string_view candidate_filetype) co } -/**************************************************************************** - CREATION FORMATS -****************************************************************************/ +//*************************************************************************** +// CREATION FORMATS +//*************************************************************************** //------------------------------------------------- // device_get_named_creatable_format - @@ -185,21 +181,9 @@ void device_image_interface::add_format(std::string &&name, std::string &&descri } -/**************************************************************************** - ERROR HANDLING -****************************************************************************/ - -//------------------------------------------------- -// clear_error - clear out any specified error -//------------------------------------------------- - -void device_image_interface::clear_error() noexcept -{ - m_err.clear(); - m_err_message.clear(); -} - - +//*************************************************************************** +// ERROR HANDLING +//*************************************************************************** //------------------------------------------------- // error - returns the error text for an image @@ -221,7 +205,10 @@ std::error_category const &image_category() noexcept "Internal error"sv, "Unsupported operation"sv, "Invalid image"sv, + "Invalid image length"sv, "File already open"sv, + "Unrecognized software item"sv, + "Invalid software item"sv, "Unspecified error"sv }; if ((0 <= condition) && (std::size(s_messages) > condition)) return std::string(s_messages[condition]); @@ -233,50 +220,6 @@ std::error_category const &image_category() noexcept return s_image_category_instance; } -std::string_view device_image_interface::error() -{ - if (m_err && m_err_message.empty()) - m_err_message = m_err.message(); - return m_err_message; -} - - - -//------------------------------------------------- -// seterror - specifies an error on an image -//------------------------------------------------- - -void device_image_interface::seterror(std::error_condition err, const char *message) -{ - clear_error(); - m_err = err; - if (message) - m_err_message = message; -} - - - -//------------------------------------------------- -// message - used to display a message while -// loading -//------------------------------------------------- - -void device_image_interface::message(const char *format, ...) -{ - va_list args; - char buffer[256]; - - /* format the message */ - va_start(args, format); - vsnprintf(buffer, std::size(buffer), format, args); - va_end(args); - - /* display the popup for a standard amount of time */ - device().machine().ui().popup_time(5, "%s: %s", - basename(), - buffer); -} - //------------------------------------------------- // software_entry - return a pointer to the @@ -330,7 +273,7 @@ const char *device_image_interface::get_feature(std::string_view feature_name) c // load_software_region - //------------------------------------------------- -bool device_image_interface::load_software_region(std::string_view tag, std::unique_ptr &ptr) +std::error_condition device_image_interface::load_software_region(std::string_view tag, std::unique_ptr &ptr) { size_t size = get_software_region_length(tag); @@ -338,9 +281,10 @@ bool device_image_interface::load_software_region(std::string_view tag, std::uni { ptr = std::make_unique(size); memcpy(ptr.get(), get_software_region(tag), size); + return std::error_condition(); } - - return size > 0; + else + return image_error::UNSUPPORTED; } @@ -374,7 +318,7 @@ std::error_condition device_image_interface::run_hash(util::random_read &file, u -bool device_image_interface::image_checkhash() +std::error_condition device_image_interface::image_checkhash() { // only calculate CRC if it hasn't been calculated, and the open_mode is read only u32 crcval; @@ -383,17 +327,16 @@ bool device_image_interface::image_checkhash() // do not cause a linear read of 600 megs please // TODO: use SHA1 in the CHD header as the hash if (image_is_chd_type()) - return true; + return std::error_condition(); // Skip calculating the hash when we have an image mounted through a software list if (loaded_through_softlist()) - return true; + return std::error_condition(); // run the hash - if (run_hash(*m_file, unhashed_header_length(), m_hash, util::hash_collection::HASH_TYPES_ALL)) - return false; + return run_hash(*m_file, unhashed_header_length(), m_hash, util::hash_collection::HASH_TYPES_ALL); } - return true; + return std::error_condition(); } @@ -627,9 +570,9 @@ static int verify_length_and_hash(emu_file *file, std::string_view name, u32 exp // load_software - software image loading //------------------------------------------------- -bool device_image_interface::load_software(software_list_device &swlist, std::string_view swname, const rom_entry *start) +std::error_condition device_image_interface::load_software(software_list_device &swlist, std::string_view swname, const rom_entry *start) { - bool retval = false; + std::error_condition retval; int warningcount = 0; for (const rom_entry *region = start; region; region = rom_next_region(region)) { @@ -641,7 +584,7 @@ bool device_image_interface::load_software(software_list_device &swlist, std::st { const software_info *const swinfo = swlist.find(std::string(swname)); if (!swinfo) - return false; + return image_error::NOSOFTWARE; if (swinfo->supported() == software_support::PARTIALLY_SUPPORTED) osd_printf_error("WARNING: support for software %s (in list %s) is only partial\n", swname, swlist.list_name()); @@ -694,8 +637,8 @@ bool device_image_interface::load_software(software_list_device &swlist, std::st if (!filerr) filerr = util::core_file::open_proxy(*m_mame_file, m_file); - if (!filerr) - retval = true; + if (filerr) + retval = filerr; break; // load first item for start } @@ -713,14 +656,13 @@ bool device_image_interface::load_software(software_list_device &swlist, std::st // load_internal - core image loading //------------------------------------------------- -image_init_result device_image_interface::load_internal(std::string_view path, bool is_create, int create_format, util::option_resolution *create_args) +std::error_condition device_image_interface::load_internal(std::string_view path, bool is_create, int create_format, util::option_resolution *create_args) { + std::error_condition err; + // first unload the image unload(); - // clear any possible error messages - clear_error(); - // we are now loading m_is_loading = true; @@ -736,15 +678,15 @@ image_init_result device_image_interface::load_internal(std::string_view path, b for (auto iter = open_plan.cbegin(); !m_file && iter != open_plan.cend(); iter++) { // open the file - m_err = load_image_by_path(*iter, path); - if (m_err && (m_err != std::errc::no_such_file_or_directory) && (m_err != std::errc::permission_denied)) + err = load_image_by_path(*iter, path); + if (err && (err != std::errc::no_such_file_or_directory) && (err != std::errc::permission_denied)) goto done; } // did we fail to find the file? if (!m_file) { - m_err = std::errc::no_such_file_or_directory; + err = std::errc::no_such_file_or_directory; goto done; } } @@ -754,26 +696,21 @@ image_init_result device_image_interface::load_internal(std::string_view path, b m_create_args = create_args; if (!init_phase()) - { - m_err = (finish_load() == image_init_result::PASS) ? std::error_condition() : image_error::INTERNAL; - if (m_err) - goto done; - } - // success! + err = finish_load(); done: - if (m_err) + if (err) { if (!init_phase()) { if (device().machine().phase() == machine_phase::RUNNING) - device().popmessage("Error: Unable to %s image '%s': %s", is_create ? "create" : "load", path, error()); + device().popmessage("Error: Unable to %s image '%s': %s", is_create ? "create" : "load", path, err.message()); else - osd_printf_error("Error: Unable to %s image '%s': %s\n", is_create ? "create" : "load", path, error()); + osd_printf_error("Error: Unable to %s image '%s': %s\n", is_create ? "create" : "load", path, err.message()); } clear(); } - return m_err ? image_init_result::FAIL : image_init_result::PASS; + return err; } @@ -781,13 +718,13 @@ done: // load - load an image into MAME //------------------------------------------------- -image_init_result device_image_interface::load(std::string_view path) +std::error_condition device_image_interface::load(std::string_view path) { // is this a reset on load item? if (is_reset_on_load() && !init_phase()) { reset_and_load(path); - return image_init_result::PASS; + return std::error_condition(); } return load_internal(path, false, 0, nullptr); @@ -798,26 +735,25 @@ image_init_result device_image_interface::load(std::string_view path) // load_software - loads a softlist item by name //------------------------------------------------- -image_init_result device_image_interface::load_software(std::string_view software_identifier) +std::error_condition device_image_interface::load_software(std::string_view software_identifier) { // Is this a software part that forces a reset and we're at runtime? If so, get this loaded through reset_and_load if (is_reset_on_load() && !init_phase()) { reset_and_load(software_identifier); - return image_init_result::PASS; + return std::error_condition(); } // Prepare to load unload(); - clear_error(); m_is_loading = true; // Check if there's a software list defined for this device and use that if we're not creating an image - bool softload = load_software_part(software_identifier); - if (!softload) + std::error_condition err = load_software_part(software_identifier); + if (err) { m_is_loading = false; - return image_init_result::FAIL; + return err; } // set up softlist stuff @@ -845,10 +781,10 @@ image_init_result device_image_interface::load_software(std::string_view softwar m_filetype = core_filename_extract_extension(filename, true); // call finish_load if necessary - if (init_phase() == false && (finish_load() != image_init_result::PASS)) - return image_init_result::FAIL; - - return image_init_result::PASS; + if (!init_phase()) + return finish_load(); + else + return std::error_condition(); } @@ -857,38 +793,24 @@ image_init_result device_image_interface::load_software(std::string_view softwar // from core //------------------------------------------------- -image_init_result device_image_interface::finish_load() +std::error_condition device_image_interface::finish_load() { - image_init_result err = image_init_result::PASS; + std::error_condition err; if (m_is_loading) { - if (!image_checkhash()) - { - m_err = image_error::INVALIDIMAGE; - err = image_init_result::FAIL; - } + err = image_checkhash(); - if (err == image_init_result::PASS) + if (!err) { if (m_created) { err = call_create(m_create_format, m_create_args); - if (err != image_init_result::PASS) - { - if (!m_err) - m_err = image_error::UNSPECIFIED; - } } else { // using device load err = call_load(); - if (err != image_init_result::PASS) - { - if (!m_err) - m_err = image_error::UNSPECIFIED; - } } } } @@ -903,7 +825,7 @@ image_init_result device_image_interface::finish_load() // create - create a image //------------------------------------------------- -image_init_result device_image_interface::create(std::string_view path) +std::error_condition device_image_interface::create(std::string_view path) { return create(path, nullptr, nullptr); } @@ -913,7 +835,7 @@ image_init_result device_image_interface::create(std::string_view path) // create - create a image //------------------------------------------------- -image_init_result device_image_interface::create(std::string_view path, const image_device_format *create_format, util::option_resolution *create_args) +std::error_condition device_image_interface::create(std::string_view path, const image_device_format *create_format, util::option_resolution *create_args) { int format_index = 0; int cnt = 0; @@ -953,7 +875,7 @@ void device_image_interface::reset_and_load(std::string_view path) // to an image //------------------------------------------------- -void device_image_interface::clear() +void device_image_interface::clear() noexcept { m_mame_file.reset(); m_file.reset(); @@ -987,7 +909,6 @@ void device_image_interface::unload() call_unload(); } clear(); - clear_error(); } @@ -1128,7 +1049,7 @@ const software_list_loader &device_image_interface::get_software_list_loader() c // sw_info and sw_part are also set. //------------------------------------------------- -bool device_image_interface::load_software_part(std::string_view identifier) +std::error_condition device_image_interface::load_software_part(std::string_view identifier) { // if no match has been found, we suggest similar shortnames software_list_device *swlist; @@ -1136,14 +1057,14 @@ bool device_image_interface::load_software_part(std::string_view identifier) if (m_software_part_ptr == nullptr) { software_list_device::display_matches(device().machine().config(), image_interface(), identifier); - return false; + return image_error::NOSOFTWARE; } // Load the software part const std::string &swname = m_software_part_ptr->info().shortname(); const rom_entry *start_entry = m_software_part_ptr->romdata().data(); const software_list_loader &loader = get_software_list_loader(); - bool result = loader.load_software(*this, *swlist, swname, start_entry); + std::error_condition result = loader.load_software(*this, *swlist, swname, start_entry); // check compatibility switch (swlist->is_compatible(*m_software_part_ptr)) diff --git a/src/emu/diimage.h b/src/emu/diimage.h index 6c010b812b0..643c3d30dd8 100644 --- a/src/emu/diimage.h +++ b/src/emu/diimage.h @@ -34,7 +34,10 @@ enum class image_error : int INTERNAL = 1, UNSUPPORTED, INVALIDIMAGE, + INVALIDLENGTH, ALREADYOPEN, + NOSOFTWARE, + BADSOFTWARE, UNSPECIFIED }; @@ -61,9 +64,6 @@ private: }; -enum class image_init_result { PASS, FAIL }; -enum class image_verify_result { PASS, FAIL }; - // ======================> device_image_interface // class representing interface-specific live image @@ -76,8 +76,8 @@ public: device_image_interface(const machine_config &mconfig, device_t &device); virtual ~device_image_interface(); - virtual image_init_result call_load() { return image_init_result::PASS; } - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) { return image_init_result::PASS; } + virtual std::error_condition call_load() { return std::error_condition(); } + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) { return std::error_condition(); } virtual void call_unload() { } virtual std::string call_display() { return std::string(); } virtual u32 unhashed_header_length() const noexcept { return 0; } @@ -98,10 +98,6 @@ public: const image_device_format *device_get_named_creatable_format(std::string_view format_name) const noexcept; const util::option_guide &device_get_creation_option_guide() const { return create_option_guide(); } - std::string_view error(); - void seterror(std::error_condition err, const char *message = nullptr); - void message(const char *format, ...) ATTR_PRINTF(2,3); - bool exists() const noexcept { return !m_image_name.empty(); } // get image file path/name @@ -176,7 +172,7 @@ public: u8 *get_software_region(std::string_view tag); u32 get_software_region_length(std::string_view tag); const char *get_feature(std::string_view feature_name) const; - bool load_software_region(std::string_view tag, std::unique_ptr &ptr); + std::error_condition load_software_region(std::string_view tag, std::unique_ptr &ptr); u32 crc(); util::hash_collection& hash() { return m_hash; } @@ -192,16 +188,16 @@ public: const formatlist_type &formatlist() const { return m_formatlist; } // loads an image file - image_init_result load(std::string_view path); + std::error_condition load(std::string_view path); // loads a softlist item by name - image_init_result load_software(std::string_view software_identifier); + std::error_condition load_software(std::string_view software_identifier); - image_init_result finish_load(); + std::error_condition finish_load(); void unload(); - image_init_result create(std::string_view path, const image_device_format *create_format, util::option_resolution *create_args); - image_init_result create(std::string_view path); - bool load_software(software_list_device &swlist, std::string_view swname, const rom_entry *entry); + std::error_condition create(std::string_view path, const image_device_format *create_format, util::option_resolution *create_args); + std::error_condition create(std::string_view path); + std::error_condition load_software(software_list_device &swlist, std::string_view swname, const rom_entry *entry); std::error_condition reopen_for_write(std::string_view path); void set_user_loadable(bool user_loadable) noexcept { m_user_loadable = user_loadable; } @@ -217,22 +213,20 @@ protected: virtual void interface_config_complete() override; virtual const software_list_loader &get_software_list_loader() const; - virtual bool use_software_list_file_extension_for_filetype() const { return false; } + virtual bool use_software_list_file_extension_for_filetype() const noexcept { return false; } - image_init_result load_internal(std::string_view path, bool is_create, int create_format, util::option_resolution *create_args); + std::error_condition load_internal(std::string_view path, bool is_create, int create_format, util::option_resolution *create_args); std::error_condition load_image_by_path(u32 open_flags, std::string_view path); - void clear(); - bool is_loaded() const { return m_file != nullptr; } + void clear() noexcept; + bool is_loaded() const noexcept { return m_file != nullptr; } void set_image_filename(std::string_view filename); - void clear_error() noexcept; - void check_for_file() const { if (!m_file) throw emu_fatalerror("%s(%s): Illegal operation on unmounted image", device().shortname(), device().tag()); } void make_readonly() noexcept { m_readonly = true; } - bool image_checkhash(); + std::error_condition image_checkhash(); const software_part *find_software_item(std::string_view identifier, bool restrict_to_interface, software_list_device **device = nullptr) const; std::string software_get_default_slot(std::string_view default_card_slot) const; @@ -240,10 +234,6 @@ protected: void add_format(std::unique_ptr &&format); void add_format(std::string &&name, std::string &&description, std::string &&extensions, std::string &&optspec); - // error related info - std::error_condition m_err; - std::string m_err_message; - private: // variables that are only non-zero when an image is mounted util::core_file::ptr m_file; @@ -260,7 +250,7 @@ private: std::vector determine_open_plan(bool is_create); void update_names(); - bool load_software_part(std::string_view identifier); + std::error_condition load_software_part(std::string_view identifier); bool init_phase() const; static std::error_condition run_hash(util::random_read &file, u32 skip_bytes, util::hash_collection &hashes, const char *types); diff --git a/src/emu/image.cpp b/src/emu/image.cpp index cca54bee10f..241b117f12f 100644 --- a/src/emu/image.cpp +++ b/src/emu/image.cpp @@ -51,25 +51,25 @@ image_manager::image_manager(running_machine &machine) if (!startup_image.empty()) { // we do have a startup image specified - load it - image_init_result result = image_init_result::FAIL; + std::error_condition result = image_error::UNSPECIFIED; // try as a softlist if (software_name_parse(startup_image)) result = image.load_software(startup_image); // failing that, try as an image - if (result != image_init_result::PASS) + if (result) result = image.load(startup_image); // failing that, try creating it (if appropriate) - if (result != image_init_result::PASS && image.support_command_line_image_creation()) + if (result && image.support_command_line_image_creation()) result = image.create(startup_image); // did the image load fail? - if (result != image_init_result::PASS) + if (result) { // retrieve image error message - std::string image_err = std::string(image.error()); + std::string image_err = std::string(result.message()); std::string startup_image_name = startup_image; // unload the bad image @@ -243,13 +243,13 @@ void image_manager::postdevice_init() /* make sure that any required devices have been allocated */ for (device_image_interface &image : image_interface_enumerator(machine().root_device())) { - image_init_result result = image.finish_load(); + std::error_condition result = image.finish_load(); /* did the image load fail? */ - if (result != image_init_result::PASS) + if (result) { /* retrieve image error message */ - std::string image_err = std::string(image.error()); + std::string image_err = std::string(result.message()); /* unload all images */ unload_all(); diff --git a/src/emu/softlist_dev.cpp b/src/emu/softlist_dev.cpp index 6db85f917cf..731b7e94db4 100644 --- a/src/emu/softlist_dev.cpp +++ b/src/emu/softlist_dev.cpp @@ -50,9 +50,9 @@ image_software_list_loader image_software_list_loader::s_instance; // false_software_list_loader::load_software //------------------------------------------------- -bool false_software_list_loader::load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const +std::error_condition false_software_list_loader::load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const { - return false; + return image_error::UNSUPPORTED; } @@ -60,10 +60,10 @@ bool false_software_list_loader::load_software(device_image_interface &image, so // rom_software_list_loader::load_software //------------------------------------------------- -bool rom_software_list_loader::load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const +std::error_condition rom_software_list_loader::load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const { swlist.machine().rom_load().load_software_part_region(image.device(), swlist, swname, start_entry); - return true; + return std::error_condition(); } @@ -71,7 +71,7 @@ bool rom_software_list_loader::load_software(device_image_interface &image, soft // image_software_list_loader::load_software //------------------------------------------------- -bool image_software_list_loader::load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const +std::error_condition image_software_list_loader::load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const { return image.load_software(swlist, swname, start_entry); } diff --git a/src/emu/softlist_dev.h b/src/emu/softlist_dev.h index 9e919dabe78..772bb970c99 100644 --- a/src/emu/softlist_dev.h +++ b/src/emu/softlist_dev.h @@ -43,7 +43,7 @@ enum software_compatibility class software_list_loader { public: - virtual bool load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const = 0; + virtual std::error_condition load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const = 0; }; @@ -52,7 +52,7 @@ public: class false_software_list_loader : public software_list_loader { public: - virtual bool load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const override; + virtual std::error_condition load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const override; static const software_list_loader &instance() { return s_instance; } private: @@ -65,7 +65,7 @@ private: class rom_software_list_loader : public software_list_loader { public: - virtual bool load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const override; + virtual std::error_condition load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const override; static const software_list_loader &instance() { return s_instance; } private: @@ -78,7 +78,7 @@ private: class image_software_list_loader : public software_list_loader { public: - virtual bool load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const override; + virtual std::error_condition load_software(device_image_interface &image, software_list_device &swlist, std::string_view swname, const rom_entry *start_entry) const override; static const software_list_loader &instance() { return s_instance; } private: diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index ebf2f701e15..a4ff31b7a59 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -417,26 +417,6 @@ int sol_lua_push(sol::types, lua_State *L, screen_type_enum && return sol::stack::push(L, "unknown"); } -int sol_lua_push(sol::types, lua_State *L, image_init_result &&value) -{ - switch (value) - { - case image_init_result::PASS: return sol::stack::push(L, "pass"); - case image_init_result::FAIL: return sol::stack::push(L, "fail"); - } - return sol::stack::push(L, "invalid"); -} - -int sol_lua_push(sol::types, lua_State *L, image_verify_result &&value) -{ - switch (value) - { - case image_verify_result::PASS: return sol::stack::push(L, "pass"); - case image_verify_result::FAIL: return sol::stack::push(L, "fail"); - } - return sol::stack::push(L, "invalid"); -} - //------------------------------------------------- // process_snapshot_filename - processes a snapshot @@ -1761,9 +1741,9 @@ void lua_engine::initialize() auto image_type = sol().registry().new_usertype("image", sol::no_constructor); image_type["load"] = &device_image_interface::load; - image_type["load_software"] = static_cast(&device_image_interface::load_software); + image_type["load_software"] = static_cast(&device_image_interface::load_software); image_type["unload"] = &device_image_interface::unload; - image_type["create"] = static_cast(&device_image_interface::create); + image_type["create"] = static_cast(&device_image_interface::create); image_type["display"] = &device_image_interface::call_display; image_type["is_readable"] = sol::property(&device_image_interface::is_readable); image_type["is_writeable"] = sol::property(&device_image_interface::is_writeable); diff --git a/src/frontend/mame/luaengine.ipp b/src/frontend/mame/luaengine.ipp index 38b564d5de2..f21c4edbf66 100644 --- a/src/frontend/mame/luaengine.ipp +++ b/src/frontend/mame/luaengine.ipp @@ -360,8 +360,6 @@ int sol_lua_push(sol::types, lua_State &L, std::error_cond // enums to automatically convert to strings int sol_lua_push(sol::types, lua_State *L, map_handler_type &&value); -int sol_lua_push(sol::types, lua_State *L, image_init_result &&value); -int sol_lua_push(sol::types, lua_State *L, image_verify_result &&value); int sol_lua_push(sol::types, lua_State *L, endianness_t &&value); diff --git a/src/frontend/mame/ui/floppycntrl.cpp b/src/frontend/mame/ui/floppycntrl.cpp index 9b85992a923..ee4916bd737 100644 --- a/src/frontend/mame/ui/floppycntrl.cpp +++ b/src/frontend/mame/ui/floppycntrl.cpp @@ -14,6 +14,8 @@ #include "zippath.h" +#include + namespace ui { @@ -39,25 +41,25 @@ menu_control_floppy_image::~menu_control_floppy_image() void menu_control_floppy_image::do_load_create() { if(input_filename.compare("")==0) { - image_init_result err = fd.create(output_filename, nullptr, nullptr); - if (err != image_init_result::PASS) { - machine().popmessage("Error: %s", fd.error()); + std::error_condition err = fd.create(output_filename, nullptr, nullptr); + if (err) { + machine().popmessage("Error: %s", err.message()); return; } if (create_fs) { // HACK: ensure the floppy_image structure is created since device_image_interface may not otherwise do so during "init phase" err = fd.finish_load(); - if (err == image_init_result::PASS) { + if (!err) { fs::meta_data meta; fd.init_fs(create_fs, meta); } } } else { - image_init_result err = fd.load(input_filename); - if ((err == image_init_result::PASS) && (output_filename.compare("") != 0)) - err = fd.reopen_for_write(output_filename) ? image_init_result::FAIL : image_init_result::PASS; - if (err != image_init_result::PASS) { - machine().popmessage("Error: %s", fd.error()); + std::error_condition err = fd.load(input_filename); + if (!err && (output_filename.compare("") != 0)) + err = fd.reopen_for_write(output_filename); + if (err) { + machine().popmessage("Error: %s", err.message()); return; } } @@ -67,12 +69,13 @@ void menu_control_floppy_image::do_load_create() void menu_control_floppy_image::hook_load(const std::string &filename) { + std::error_condition err; input_filename = filename; - input_format = static_cast(m_image).identify(filename); + std::tie(err, input_format) = static_cast(m_image).identify(filename); if (!input_format) { - machine().popmessage("Error: %s\n", m_image.error()); + machine().popmessage("Error: %s", err.message()); stack_pop(); } else diff --git a/src/frontend/mame/ui/imgcntrl.cpp b/src/frontend/mame/ui/imgcntrl.cpp index 053da006a43..04542167200 100644 --- a/src/frontend/mame/ui/imgcntrl.cpp +++ b/src/frontend/mame/ui/imgcntrl.cpp @@ -370,9 +370,9 @@ void menu_control_device_image::menu_activated() case DO_CREATE: { auto path = util::zippath_combine(m_current_directory, m_current_file); - image_init_result err = m_image.create(path, nullptr, nullptr); - if (err != image_init_result::PASS) - machine().popmessage("Error: %s", m_image.error()); + std::error_condition err = m_image.create(path, nullptr, nullptr); + if (err) + machine().popmessage("Error: %s", err.message()); stack_pop(); } break; diff --git a/src/mame/acorn/atom.cpp b/src/mame/acorn/atom.cpp index 59e2dc01809..9b58b8ab571 100644 --- a/src/mame/acorn/atom.cpp +++ b/src/mame/acorn/atom.cpp @@ -187,7 +187,7 @@ QUICKLOAD_LOAD_MEMBER(atom_state::quickload_cb) else m_maincpu->set_state_int(M6502_PC, run_address); // if not basic, autostart program (set_pc doesn't work) - return image_init_result::PASS; + return std::error_condition(); } /*************************************************************************** @@ -679,20 +679,20 @@ void atomeb_state::machine_reset() MACHINE DRIVERS ***************************************************************************/ -image_init_result atom_state::load_cart(device_image_interface &image, generic_slot_device &slot) +std::error_condition atom_state::load_cart(device_image_interface &image, generic_slot_device &slot) { uint32_t size = slot.common_get_size("rom"); if (size > 0x1000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported ROM size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported ROM size\n", image.basename()); + return image_error::INVALIDIMAGE; } slot.rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); slot.common_load_rom(slot.get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static void atom_floppies(device_slot_interface &device) diff --git a/src/mame/acorn/atom.h b/src/mame/acorn/atom.h index 57d672a0caa..16c5b246385 100644 --- a/src/mame/acorn/atom.h +++ b/src/mame/acorn/atom.h @@ -100,7 +100,7 @@ protected: static void floppy_formats(format_registration &fr); DECLARE_WRITE_LINE_MEMBER(cassette_output_tick); - image_init_result load_cart(device_image_interface &image, generic_slot_device &slot); + std::error_condition load_cart(device_image_interface &image, generic_slot_device &slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart_load) { return load_cart(image, *m_cart); } DECLARE_QUICKLOAD_LOAD_MEMBER(quickload_cb); void atom_mem(address_map &map); diff --git a/src/mame/acorn/electron.h b/src/mame/acorn/electron.h index 90ce43665a6..004bb6f28dd 100644 --- a/src/mame/acorn/electron.h +++ b/src/mame/acorn/electron.h @@ -181,7 +181,7 @@ private: uint8_t m_sp64_bank = 0; std::unique_ptr m_sp64_ram; - image_init_result load_rom(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_rom(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom1_load) { return load_rom(image, m_romi[0]); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(rom2_load) { return load_rom(image, m_romi[1]); } }; diff --git a/src/mame/acorn/electron_m.cpp b/src/mame/acorn/electron_m.cpp index c09ea888341..fc4c468b76c 100644 --- a/src/mame/acorn/electron_m.cpp +++ b/src/mame/acorn/electron_m.cpp @@ -627,15 +627,15 @@ void electronsp_state::machine_start() } -image_init_result electronsp_state::load_rom(device_image_interface &image, generic_slot_device *slot) +std::error_condition electronsp_state::load_rom(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); // socket accepts 8K and 16K ROM only if (size != 0x2000 && size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only 8K/16K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only 8K/16K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -645,5 +645,5 @@ image_init_result electronsp_state::load_rom(device_image_interface &image, gene uint8_t *crt = slot->get_rom_base(); if (size <= 0x2000) memcpy(crt + 0x2000, crt, 0x2000); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/acorn/z88_impexp.cpp b/src/mame/acorn/z88_impexp.cpp index fbbdf8f80ad..5669deb85ca 100644 --- a/src/mame/acorn/z88_impexp.cpp +++ b/src/mame/acorn/z88_impexp.cpp @@ -136,7 +136,7 @@ void z88_impexp_device::check_filename(std::string &filename) } -image_init_result z88_impexp_device::call_load() +std::error_condition z88_impexp_device::call_load() { m_mode = MODE_SEND; m_queue = std::queue(); @@ -180,7 +180,7 @@ image_init_result z88_impexp_device::call_load() { uint8_t b; if (fread(&b, 1) != 1) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; // Escape non printable characters if ((b < 0x20 || b >= 0x7f) && b != 0x0a && b != 0x0d && b != 0x09) @@ -205,15 +205,15 @@ image_init_result z88_impexp_device::call_load() m_queue.push('E'); queue(); - return image_init_result::PASS; + return std::error_condition(); } -image_init_result z88_impexp_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition z88_impexp_device::call_create(int format_type, util::option_resolution *format_options) { m_queue = std::queue(); m_mode = MODE_RECV; - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/acorn/z88_impexp.h b/src/mame/acorn/z88_impexp.h index afba9947383..6918e0df69d 100644 --- a/src/mame/acorn/z88_impexp.h +++ b/src/mame/acorn/z88_impexp.h @@ -34,9 +34,9 @@ protected: virtual void rcv_complete() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual bool is_readable() const noexcept override { return true; } virtual bool is_writeable() const noexcept override { return true; } diff --git a/src/mame/altos/altos5.cpp b/src/mame/altos/altos5.cpp index a662e4fcbc5..998488fd4a7 100644 --- a/src/mame/altos/altos5.cpp +++ b/src/mame/altos/altos5.cpp @@ -307,7 +307,7 @@ QUICKLOAD_LOAD_MEMBER(altos5_state::quickload_cb) address_space& prog_space = m_maincpu->space(AS_PROGRAM); if (image.length() >= 0xfd00) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; setup_banks(2); @@ -315,7 +315,7 @@ QUICKLOAD_LOAD_MEMBER(altos5_state::quickload_cb) if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) { machine_reset(); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } /* Load image to the TPA (Transient Program Area) */ @@ -325,7 +325,7 @@ QUICKLOAD_LOAD_MEMBER(altos5_state::quickload_cb) uint8_t data; if (image.fread( &data, 1) != 1) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; prog_space.write_byte(i+0x100, data); } @@ -336,7 +336,7 @@ QUICKLOAD_LOAD_MEMBER(altos5_state::quickload_cb) m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 300); m_maincpu->set_pc(0x100); // start program - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/amstrad/amstrad_m.cpp b/src/mame/amstrad/amstrad_m.cpp index 72d7c6b0fd6..10c7703edf1 100644 --- a/src/mame/amstrad/amstrad_m.cpp +++ b/src/mame/amstrad/amstrad_m.cpp @@ -3251,7 +3251,7 @@ SNAPSHOT_LOAD_MEMBER(amstrad_state::snapshot_cb) { /* get file size */ if (image.length() < 8) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; std::vector snapshot(image.length()); @@ -3260,11 +3260,11 @@ SNAPSHOT_LOAD_MEMBER(amstrad_state::snapshot_cb) if (memcmp(&snapshot[0], "MV - SNA", 8)) { - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } amstrad_handle_snapshot(&snapshot[0]); - return image_init_result::PASS; + return std::error_condition(); } @@ -3306,8 +3306,8 @@ DEVICE_IMAGE_LOAD_MEMBER(amstrad_state::amstrad_plus_cartridge) logerror("IMG: raw CPC+ cartridge file\n"); if (size % 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Attempt to load a raw binary with some block smaller than 16kB in size"); - return image_init_result::FAIL; + osd_printf_error("%s: Attempt to load a raw binary with some block smaller than 16kB in size\n", image.basename()); + return image_error::INVALIDLENGTH; } else image.fread(m_cart->get_rom_base(), size); @@ -3335,10 +3335,10 @@ DEVICE_IMAGE_LOAD_MEMBER(amstrad_state::amstrad_plus_cartridge) unsigned int bytes_to_read; // total bytes to read, as mame_feof doesn't react to EOF without trying to go past it. // Is RIFF format (*.cpr) - if (strncmp((char*)(header + 8), "AMS!", 4) != 0) + if (strncmp((const char*)(header + 8), "AMS!", 4) != 0) { - image.seterror(image_error::INVALIDIMAGE, "Not an Amstrad CPC cartridge image (despite RIFF header)"); - return image_init_result::FAIL; + osd_printf_error("%s: Not an Amstrad CPC cartridge image (despite RIFF header)\n", image.basename()); + return image_error::INVALIDIMAGE; } bytes_to_read = header[4] + (header[5] << 8) + (header[6] << 16)+ (header[7] << 24); @@ -3390,5 +3390,5 @@ DEVICE_IMAGE_LOAD_MEMBER(amstrad_state::amstrad_plus_cartridge) } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/amstrad/pda600.cpp b/src/mame/amstrad/pda600.cpp index 024b5316f51..69dd3d324d8 100644 --- a/src/mame/amstrad/pda600.cpp +++ b/src/mame/amstrad/pda600.cpp @@ -486,7 +486,7 @@ DEVICE_IMAGE_LOAD_MEMBER(pda600_state::card_load) m_card->ram_alloc(size); if (size != image.fread(m_card->get_ram_base(), size)) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; m_card_size = size; } @@ -495,14 +495,14 @@ DEVICE_IMAGE_LOAD_MEMBER(pda600_state::card_load) m_card_size = image.get_software_region_length("rom"); if (m_card_size == 0) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; m_card->ram_alloc(m_card_size); memcpy(m_card->get_ram_base(), image.get_software_region("rom"), m_card_size); } m_card->battery_load(m_card->get_ram_base(), m_card_size, nullptr); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/apollo/apollo.h b/src/mame/apollo/apollo.h index 1cbbb9dfe56..69644d87ed6 100644 --- a/src/mame/apollo/apollo.h +++ b/src/mame/apollo/apollo.h @@ -387,8 +387,8 @@ public: virtual bool support_command_line_image_creation() const noexcept override { return true; } virtual const char *file_extensions() const noexcept override { return "ani,bin"; } - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; virtual const char *image_type_name() const noexcept override { return "node_id"; } virtual const char *image_brief_type_name() const noexcept override { return "ni"; } diff --git a/src/mame/apollo/apollo_m.cpp b/src/mame/apollo/apollo_m.cpp index 554fd9e3db4..7912544ccbd 100644 --- a/src/mame/apollo/apollo_m.cpp +++ b/src/mame/apollo/apollo_m.cpp @@ -929,7 +929,7 @@ uint16_t apollo_ni::read(offs_t offset, uint16_t mem_mask) /*------------------------------------------------- DEVICE_IMAGE_LOAD( rom ) -------------------------------------------------*/ -image_init_result apollo_ni::call_load() +std::error_condition apollo_ni::call_load() { CLOG1(("apollo_ni::call_load: %s", filename())); @@ -952,17 +952,17 @@ image_init_result apollo_ni::call_load() { m_node_id = (((data[2] << 8) | data[4]) << 8) | (data[6]); CLOG1(("apollo_ni::call_load: node ID is %x", m_node_id)); - return image_init_result::PASS; + return std::error_condition(); } } - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } /*------------------------------------------------- DEVICE_IMAGE_CREATE( rom ) -------------------------------------------------*/ -image_init_result apollo_ni::call_create(int format_type, util::option_resolution *format_options) +std::error_condition apollo_ni::call_create(int format_type, util::option_resolution *format_options) { CLOG1(("apollo_ni::call_create:")); @@ -989,10 +989,10 @@ image_init_result apollo_ni::call_create(int format_type, util::option_resolutio fwrite(data, sizeof(data)); CLOG(("apollo_ni::call_create: created %s with node ID %x", filename(), node_id)); set_node_id(node_id); - return image_init_result::PASS; + return std::error_condition(); } } - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } /*------------------------------------------------- diff --git a/src/mame/apple/apple1.cpp b/src/mame/apple/apple1.cpp index e0413d4c36e..20e56734544 100644 --- a/src/mame/apple/apple1.cpp +++ b/src/mame/apple/apple1.cpp @@ -186,26 +186,26 @@ SNAPSHOT_LOAD_MEMBER(apple1_state::snapshot_cb) if (snapsize < 12) { logerror("Snapshot is too short\n"); - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } if ((snapsize - 12) > 65535) { logerror("Snapshot is too long\n"); - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } auto data = std::make_unique(snapsize); if (image.fread(data.get(), snapsize) != snapsize) { logerror("Internal error loading snapshot\n"); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } if ((memcmp(hd1, &data[0], 5)) || (memcmp(hd2, &data[7], 5))) { logerror("Snapshot is invalid\n"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } uint16_t start = (data[5]<<8) | data[6]; @@ -216,7 +216,7 @@ SNAPSHOT_LOAD_MEMBER(apple1_state::snapshot_cb) if (((start < 0xe000) && (end > (m_ram_size - 1))) || (end > 0xefff)) { logerror("Snapshot can't fit in RAM\n"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } if (start < 0xe000) @@ -230,10 +230,10 @@ SNAPSHOT_LOAD_MEMBER(apple1_state::snapshot_cb) else { logerror("Snapshot has invalid load address %04x\n", start); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } - return image_init_result::PASS; + return std::error_condition(); } void apple1_state::poll_keyboard() diff --git a/src/mame/appliedconcepts/ggm.cpp b/src/mame/appliedconcepts/ggm.cpp index 208befc3d43..197c53ca046 100644 --- a/src/mame/appliedconcepts/ggm.cpp +++ b/src/mame/appliedconcepts/ggm.cpp @@ -238,7 +238,7 @@ DEVICE_IMAGE_LOAD_MEMBER(ggm_state::load_cart) memset(m_extram, 0, m_extram.bytes()); m_extram_enabled = image.get_feature("ram") != nullptr; - return image_init_result::PASS; + return std::error_condition(); } DEVICE_IMAGE_UNLOAD_MEMBER(ggm_state::unload_cart) diff --git a/src/mame/atari/jaguar.cpp b/src/mame/atari/jaguar.cpp index ad976b33e6d..c40cfe3b639 100644 --- a/src/mame/atari/jaguar.cpp +++ b/src/mame/atari/jaguar.cpp @@ -1927,7 +1927,7 @@ void jaguarcd_state::init_jaguarcd() save_item(NAME(m_joystick_data)); } -image_init_result jaguar_state::quickload_cb(device_image_interface &image) +std::error_condition jaguar_state::quickload_cb(snapshot_image_device &image) { offs_t quickload_begin = 0x4000, start = quickload_begin, skip = 0; @@ -1992,7 +1992,7 @@ image_init_result jaguar_state::quickload_cb(device_image_interface &image) /* Transfer control to image */ m_maincpu->set_pc(quickload_begin); m_shared_ram[1]=quickload_begin; - return image_init_result::PASS; + return std::error_condition(); } DEVICE_IMAGE_LOAD_MEMBER( jaguar_state::cart_load ) @@ -2029,7 +2029,7 @@ DEVICE_IMAGE_LOAD_MEMBER( jaguar_state::cart_load ) /* Transfer control to the bios */ m_maincpu->reset(); - return image_init_result::PASS; + return std::error_condition(); } /************************************* diff --git a/src/mame/atari/jaguar.h b/src/mame/atari/jaguar.h index e035f98068d..3faebd8c3b2 100644 --- a/src/mame/atari/jaguar.h +++ b/src/mame/atari/jaguar.h @@ -272,7 +272,7 @@ private: DECLARE_WRITE_LINE_MEMBER( dsp_cpu_int ); DECLARE_WRITE_LINE_MEMBER( external_int ); - image_init_result quickload_cb(device_image_interface &image); + std::error_condition quickload_cb(snapshot_image_device &image); DECLARE_DEVICE_IMAGE_LOAD_MEMBER( cart_load ); void cpu_space_map(address_map &map); void dsp_map(address_map &map); diff --git a/src/mame/atari/lynx.cpp b/src/mame/atari/lynx.cpp index 2f781a2a5a1..9af858bbe89 100644 --- a/src/mame/atari/lynx.cpp +++ b/src/mame/atari/lynx.cpp @@ -159,13 +159,14 @@ QUICKLOAD_LOAD_MEMBER(lynx_state::quickload_cb) int i; if (image.fread( header, sizeof(header)) != sizeof(header)) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; /* Check the image */ - if (verify_cart((char*)header, LYNX_QUICKLOAD) != image_verify_result::PASS) + std::error_condition err = verify_cart((const char*)header, LYNX_QUICKLOAD); + if (err) { - image.seterror(image_error::INVALIDIMAGE, "Not a valid Lynx file"); - return image_init_result::FAIL; + osd_printf_error("%s: Not a valid Lynx file\n", image.basename()); + return err; } start = header[3] | (header[2]<<8); //! big endian format in file format for little endian cpu @@ -176,8 +177,8 @@ QUICKLOAD_LOAD_MEMBER(lynx_state::quickload_cb) if (image.fread( &data[0], length) != length) { - image.seterror(image_error::INVALIDIMAGE, "Invalid length in file header"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid length in file header\n", image.basename()); + return image_error::INVALIDIMAGE; } for (i = 0; i < length; i++) @@ -190,7 +191,7 @@ QUICKLOAD_LOAD_MEMBER(lynx_state::quickload_cb) m_maincpu->set_pc(start); - return image_init_result::PASS; + return std::error_condition(); } /*************************************************************************** diff --git a/src/mame/atari/lynx.h b/src/mame/atari/lynx.h index 3d3005062e9..3b7d8409bf3 100644 --- a/src/mame/atari/lynx.h +++ b/src/mame/atari/lynx.h @@ -302,7 +302,7 @@ private: void uart_reset(); void interrupt_set(u8 line); void interrupt_update(); - image_verify_result verify_cart(char *header, int kind); + std::error_condition verify_cart(const char *header, int kind); DECLARE_QUICKLOAD_LOAD_MEMBER(quickload_cb); }; diff --git a/src/mame/atari/lynx_m.cpp b/src/mame/atari/lynx_m.cpp index 984faaaf49f..9fdc0c5c0e1 100644 --- a/src/mame/atari/lynx_m.cpp +++ b/src/mame/atari/lynx_m.cpp @@ -2001,14 +2001,14 @@ void lynx_state::machine_start() ****************************************/ -image_verify_result lynx_state::verify_cart(char *header, int kind) +std::error_condition lynx_state::verify_cart(const char *header, int kind) { if (kind) { if (strncmp("BS93", &header[6], 4)) { logerror("This is not a valid Lynx image\n"); - return image_verify_result::FAIL; + return image_error::INVALIDIMAGE; } } else @@ -2022,11 +2022,11 @@ image_verify_result lynx_state::verify_cart(char *header, int kind) } else logerror("This is not a valid Lynx image\n"); - return image_verify_result::FAIL; + return image_error::INVALIDIMAGE; } } - return image_verify_result::PASS; + return std::error_condition(); } DEVICE_IMAGE_LOAD_MEMBER(lynx_state::cart_load) @@ -2052,8 +2052,9 @@ DEVICE_IMAGE_LOAD_MEMBER(lynx_state::cart_load) image.fread(header, 0x40); // Check the image - if (verify_cart((char*)header, LYNX_CART) != image_verify_result::PASS) - return image_init_result::FAIL; + std::error_condition err = verify_cart((const char*)header, LYNX_CART); + if (err) + return err; /* 2008-10 FP: According to Handy source these should be page_size_bank0. Are we using it correctly in MAME? Moreover, the next two values should be page_size_bank1. We should @@ -2118,5 +2119,5 @@ DEVICE_IMAGE_LOAD_MEMBER(lynx_state::cart_load) } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/ausnz/aussiebyte.cpp b/src/mame/ausnz/aussiebyte.cpp index 3d452580ed7..353a219a2c1 100644 --- a/src/mame/ausnz/aussiebyte.cpp +++ b/src/mame/ausnz/aussiebyte.cpp @@ -408,7 +408,7 @@ QUICKLOAD_LOAD_MEMBER(aussiebyte_state::quickload_cb) address_space& prog_space = m_maincpu->space(AS_PROGRAM); if (image.length() >= 0xfd00) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; /* RAM must be banked in */ m_port15 = true; // disable boot rom @@ -420,7 +420,7 @@ QUICKLOAD_LOAD_MEMBER(aussiebyte_state::quickload_cb) if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) { machine_reset(); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } /* Load image to the TPA (Transient Program Area) */ @@ -429,7 +429,7 @@ QUICKLOAD_LOAD_MEMBER(aussiebyte_state::quickload_cb) { u8 data; if (image.fread( &data, 1) != 1) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; prog_space.write_byte(i+0x100, data); } @@ -440,7 +440,7 @@ QUICKLOAD_LOAD_MEMBER(aussiebyte_state::quickload_cb) m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 0x400); m_maincpu->set_pc(0x100); // start program - return image_init_result::PASS; + return std::error_condition(); } /*********************************************************** diff --git a/src/mame/ausnz/binbug.cpp b/src/mame/ausnz/binbug.cpp index ca84929c952..39d3527a9a6 100644 --- a/src/mame/ausnz/binbug.cpp +++ b/src/mame/ausnz/binbug.cpp @@ -186,17 +186,19 @@ QUICKLOAD_LOAD_MEMBER(binbug_state::quickload_cb) int quick_length; std::vector quick_data; int read_; - image_init_result result = image_init_result::FAIL; + std::error_condition result = image_error::UNSPECIFIED; quick_length = image.length(); if (quick_length < 0x0444) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too short\n", image.basename()); image.message(" File too short"); } else if (quick_length > 0x8000) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too long\n", image.basename()); image.message(" File too long"); } else @@ -205,12 +207,14 @@ QUICKLOAD_LOAD_MEMBER(binbug_state::quickload_cb) read_ = image.fread( &quick_data[0], quick_length); if (read_ != quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Cannot read the file"); + result = image_error::UNSPECIFIED; + osd_printf_error("%s: Cannot read the file\n", image.basename()); image.message(" Cannot read the file"); } else if (quick_data[0] != 0xc4) { - image.seterror(image_error::INVALIDIMAGE, "Invalid header"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Invalid header\n", image.basename()); image.message(" Invalid header"); } else @@ -219,7 +223,8 @@ QUICKLOAD_LOAD_MEMBER(binbug_state::quickload_cb) if (exec_addr >= quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Exec address beyond end of file"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Exec adress beyond end of file\n", image.basename()); image.message(" Exec address beyond end of file"); } else @@ -233,7 +238,7 @@ QUICKLOAD_LOAD_MEMBER(binbug_state::quickload_cb) // Start the quickload m_maincpu->set_state_int(S2650_PC, exec_addr); - result = image_init_result::PASS; + result = std::error_condition(); } } } diff --git a/src/mame/ausnz/d6800.cpp b/src/mame/ausnz/d6800.cpp index 28b886a8e49..7fd586858e5 100644 --- a/src/mame/ausnz/d6800.cpp +++ b/src/mame/ausnz/d6800.cpp @@ -349,9 +349,9 @@ QUICKLOAD_LOAD_MEMBER(d6800_state::quickload_cb) u32 quick_length = image.length(); if (quick_length > 0xe00) { - image.seterror(image_error::INVALIDIMAGE, "File exceeds 3584 bytes"); + osd_printf_error("%s: File exceeds 3854 bytes\n", image.basename()); image.message(" File exceeds 3584 bytes"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } for (u32 i = 0; i < quick_length; i++) @@ -369,7 +369,7 @@ QUICKLOAD_LOAD_MEMBER(d6800_state::quickload_cb) // Start the quickload m_maincpu->set_pc(exec_addr); - return image_init_result::PASS; + return std::error_condition(); } void d6800_state::d6800(machine_config &config) diff --git a/src/mame/ausnz/eti660.cpp b/src/mame/ausnz/eti660.cpp index ef631e104b5..23fe35727df 100644 --- a/src/mame/ausnz/eti660.cpp +++ b/src/mame/ausnz/eti660.cpp @@ -322,14 +322,14 @@ QUICKLOAD_LOAD_MEMBER(eti660_state::quickload_cb) int quick_length; std::vector quick_data; int read_; - image_init_result result = image_init_result::FAIL; + std::error_condition result = image_error::UNSPECIFIED; quick_length = image.length(); quick_data.resize(quick_length); read_ = image.fread( &quick_data[0], quick_length); if (read_ != quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Cannot read the file"); + result = image_error::INVALIDIMAGE; image.message(" Cannot read the file"); } else @@ -344,7 +344,7 @@ QUICKLOAD_LOAD_MEMBER(eti660_state::quickload_cb) else image.message(" Quickload: size=%04X : start=%04X : end=%04X : Press 8 to start",quick_length,quick_addr,quick_addr+quick_length); - result = image_init_result::PASS; + result = std::error_condition(); } return result; diff --git a/src/mame/ausnz/mbee.h b/src/mame/ausnz/mbee.h index 82687732546..d09f79bb029 100644 --- a/src/mame/ausnz/mbee.h +++ b/src/mame/ausnz/mbee.h @@ -125,7 +125,7 @@ private: void premium_palette(palette_device &palette) const; uint32_t screen_update_mbee(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); TIMER_DEVICE_CALLBACK_MEMBER(newkb_timer); - image_init_result load_cart(device_image_interface &image, generic_slot_device *slot, u8); + std::error_condition load_cart(device_image_interface &image, generic_slot_device *slot, u8); void unload_cart(u8); DECLARE_QUICKLOAD_LOAD_MEMBER(quickload_cb); template DECLARE_DEVICE_IMAGE_LOAD_MEMBER(pak_load) { return load_cart(image, m_pak[T], T); } diff --git a/src/mame/ausnz/mbee_m.cpp b/src/mame/ausnz/mbee_m.cpp index b26b127d645..208f1b45ac6 100644 --- a/src/mame/ausnz/mbee_m.cpp +++ b/src/mame/ausnz/mbee_m.cpp @@ -608,8 +608,9 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) uint16_t execute_address, start_addr, end_addr; /* load the binary into memory */ - if (z80bin_load_file(image, space, execute_address, start_addr, end_addr) != image_init_result::PASS) - return image_init_result::FAIL; + std::error_condition err = z80bin_load_file(image, space, execute_address, start_addr, end_addr); + if (err) + return err; /* is this file executable? */ if (execute_address != 0xffff) @@ -627,7 +628,7 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) } } - return image_init_result::PASS; + return std::error_condition(); } uint16_t i, j; @@ -644,7 +645,7 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) if (image.fread(&data, 1) != 1) { image.message("Unexpected EOF"); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } if ((j < m_size) || (j > 0xefff)) @@ -652,7 +653,7 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) else { image.message("Not enough memory in this microbee"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } } @@ -675,7 +676,7 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) if (image.fread(&data, 1) != 1) { image.message("Unexpected EOF"); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } if ((j < m_size) || (j > 0xefff)) @@ -683,7 +684,7 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) else { image.message("Not enough memory in this microbee"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } } @@ -701,7 +702,7 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) if (image.fread(&data, 1) != 1) { image.message("Unexpected EOF"); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } if ((j < m_size) || (j > 0xefff)) @@ -709,7 +710,7 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) else { image.message("Not enough memory in this microbee"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } } @@ -717,11 +718,11 @@ QUICKLOAD_LOAD_MEMBER(mbee_state::quickload_cb) m_maincpu->set_pc(0x900); } - return image_init_result::PASS; + return std::error_condition(); } // Index usage: 0 = not used; 1 = net rom; 2-7 = pak roms -image_init_result mbee_state::load_cart(device_image_interface &image, generic_slot_device *slot, u8 pak_index) +std::error_condition mbee_state::load_cart(device_image_interface &image, generic_slot_device *slot, u8 pak_index) { u32 size = slot->common_get_size("rom"); @@ -730,8 +731,8 @@ image_init_result mbee_state::load_cart(device_image_interface &image, generic_s // "mbp" roms if ((size == 0) || (size > 0x4000)) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported ROM size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported ROM size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_pak_extended[pak_index] = (size > 0x2000) ? true : false; @@ -743,9 +744,9 @@ image_init_result mbee_state::load_cart(device_image_interface &image, generic_s logerror ("Rom header = %02X %02X %02X\n", slot->read_rom(0), slot->read_rom(1), slot->read_rom(2)); if ((slot->read_rom(0) != 0xc3) || ((slot->read_rom(2) & 0xe0) != 0xc0)) { - image.seterror(image_error::INVALIDIMAGE, "Not a PAK rom"); + osd_printf_error("%s: Not a PAK rom\n", image.basename()); slot->call_unload(); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } } else @@ -753,8 +754,8 @@ image_init_result mbee_state::load_cart(device_image_interface &image, generic_s // "mbn" roms if ((size == 0) || (size > 0x2000)) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported ROM size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported ROM size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_pak_extended[pak_index] = (size > 0x1000) ? true : false; @@ -767,14 +768,14 @@ image_init_result mbee_state::load_cart(device_image_interface &image, generic_s { if ((slot->read_rom(0) != 0xc3) || ((slot->read_rom(2) & 0xf0) != 0xe0)) { - image.seterror(image_error::INVALIDIMAGE, "Not a NET rom"); + osd_printf_error("%s: Not a NET rom\n", image.basename()); slot->call_unload(); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } } } - return image_init_result::PASS; + return std::error_condition(); } void mbee_state::unload_cart(u8 pak_index) diff --git a/src/mame/ausnz/pegasus.cpp b/src/mame/ausnz/pegasus.cpp index 0ad7221646f..7182dabd8a3 100644 --- a/src/mame/ausnz/pegasus.cpp +++ b/src/mame/ausnz/pegasus.cpp @@ -94,7 +94,7 @@ private: DECLARE_WRITE_LINE_MEMBER(pegasus_firq_clr); u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); TIMER_DEVICE_CALLBACK_MEMBER(pegasus_firq); - image_init_result load_cart(device_image_interface &image, generic_slot_device *slot, const char *reg_tag); + std::error_condition load_cart(device_image_interface &image, generic_slot_device *slot, const char *reg_tag); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(exp00_load) { return load_cart(image, m_exp_00, "0000"); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(exp01_load) { return load_cart(image, m_exp_01, "1000"); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(exp02_load) { return load_cart(image, m_exp_02, "2000"); } @@ -416,15 +416,15 @@ void pegasus_state::pegasus_decrypt_rom(u8 *ROM) } } -image_init_result pegasus_state::load_cart(device_image_interface &image, generic_slot_device *slot, const char *reg_tag) +std::error_condition pegasus_state::load_cart(device_image_interface &image, generic_slot_device *slot, const char *reg_tag) { u32 size = slot->common_get_size(reg_tag); bool any_socket = false; if (size > 0x1000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } if (image.loaded_through_softlist() && size == 0) @@ -436,11 +436,11 @@ image_init_result pegasus_state::load_cart(device_image_interface &image, generi if (size == 0) { - std::string errmsg = string_format( - "Attempted to load a file that does not work in this socket.\n" - "Please check \"Usage\" field in the software list for the correct socket(s) to use."); - image.seterror(image_error::INVALIDIMAGE, errmsg.c_str()); - return image_init_result::FAIL; + osd_printf_error( + "%s: Attempted to load a file that does not work in this socket.\n" + "Please check \"Usage\" field in the software list for the correct socket(s) to use.\n", + image.basename()); + return image_error::INVALIDIMAGE; } } @@ -450,7 +450,7 @@ image_init_result pegasus_state::load_cart(device_image_interface &image, generi // raw images have to be decrypted (in particular the ones from softlist) pegasus_decrypt_rom(slot->get_rom_base()); - return image_init_result::PASS; + return std::error_condition(); } void pegasus_state::machine_start() diff --git a/src/mame/ausnz/pipbug.cpp b/src/mame/ausnz/pipbug.cpp index f59c1b84339..d79603e37ce 100644 --- a/src/mame/ausnz/pipbug.cpp +++ b/src/mame/ausnz/pipbug.cpp @@ -157,17 +157,19 @@ QUICKLOAD_LOAD_MEMBER(pipbug_state::quickload_cb) int quick_length; std::vector quick_data; int read_; - image_init_result result = image_init_result::FAIL; + std::error_condition result = image_error::UNSPECIFIED; quick_length = image.length(); if (quick_length < 0x0444) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too short\n", image.basename()); image.message(" File too short"); } else if (quick_length > 0x8000) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too long\n", image.basename()); image.message(" File too long"); } else @@ -176,12 +178,14 @@ QUICKLOAD_LOAD_MEMBER(pipbug_state::quickload_cb) read_ = image.fread( &quick_data[0], quick_length); if (read_ != quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Cannot read the file"); + result = image_error::UNSPECIFIED; + osd_printf_error("%s: Cannot read the file\n"); image.message(" Cannot read the file"); } else if (quick_data[0] != 0xc4) { - image.seterror(image_error::INVALIDIMAGE, "Invalid header"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Invalid header\n"); image.message(" Invalid header"); } else @@ -190,7 +194,8 @@ QUICKLOAD_LOAD_MEMBER(pipbug_state::quickload_cb) if (exec_addr >= quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Exec address beyond end of file"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Exec address beyond end of file\n", image.basename()); image.message(" Exec address beyond end of file"); } else @@ -204,7 +209,7 @@ QUICKLOAD_LOAD_MEMBER(pipbug_state::quickload_cb) // Start the quickload m_maincpu->set_state_int(S2650_PC, exec_addr); - result = image_init_result::PASS; + result = std::error_condition(); } } } diff --git a/src/mame/ausnz/super80_m.cpp b/src/mame/ausnz/super80_m.cpp index 5b14c8cb6d3..3172100c61a 100644 --- a/src/mame/ausnz/super80_m.cpp +++ b/src/mame/ausnz/super80_m.cpp @@ -271,8 +271,9 @@ QUICKLOAD_LOAD_MEMBER(super80_state::quickload_cb) uint16_t exec_addr, start_addr, end_addr; // load the binary into memory - if (z80bin_load_file(image, m_maincpu->space(AS_PROGRAM), exec_addr, start_addr, end_addr) != image_init_result::PASS) - return image_init_result::FAIL; + std::error_condition err = z80bin_load_file(image, m_maincpu->space(AS_PROGRAM), exec_addr, start_addr, end_addr); + if (err) + return err; // is this file executable? if (exec_addr != 0xffff) @@ -280,5 +281,5 @@ QUICKLOAD_LOAD_MEMBER(super80_state::quickload_cb) if (BIT(m_io_config->read(), 0)) m_maincpu->set_pc(exec_addr); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/bandai/design_master.cpp b/src/mame/bandai/design_master.cpp index 5d1e34e8b88..0468b85e8ca 100644 --- a/src/mame/bandai/design_master.cpp +++ b/src/mame/bandai/design_master.cpp @@ -101,7 +101,7 @@ DEVICE_IMAGE_LOAD_MEMBER(bdsm_state::cart_load_bdesignm) m_cartslot->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_BIG); m_cartslot->common_load_rom(m_cartslot->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void bdsm_state::mem_map(address_map &map) diff --git a/src/mame/bandai/rx78.cpp b/src/mame/bandai/rx78.cpp index edeecc99116..5e6397d7f4c 100644 --- a/src/mame/bandai/rx78.cpp +++ b/src/mame/bandai/rx78.cpp @@ -492,14 +492,14 @@ DEVICE_IMAGE_LOAD_MEMBER( rx78_state::cart_load ) if (size != 0x2000 && size != 0x4000 && size != 0x8000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } /* F4 Character Displayer */ diff --git a/src/mame/bandai/sv8000.cpp b/src/mame/bandai/sv8000.cpp index 7d7c61471e5..77479189ed4 100644 --- a/src/mame/bandai/sv8000.cpp +++ b/src/mame/bandai/sv8000.cpp @@ -210,14 +210,14 @@ DEVICE_IMAGE_LOAD_MEMBER( sv8000_state::cart_load ) if (size != 0x1000) { - image.seterror(image_error::INVALIDIMAGE, "Incorrect or not support cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Incorrect or not supported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/booth/apexc_m.cpp b/src/mame/booth/apexc_m.cpp index 6c7c23fb42b..e54fc39519f 100644 --- a/src/mame/booth/apexc_m.cpp +++ b/src/mame/booth/apexc_m.cpp @@ -24,7 +24,7 @@ apexc_cylinder_image_device::apexc_cylinder_image_device(const machine_config &m /* Open cylinder image and read RAM */ -image_init_result apexc_cylinder_image_device::call_load() +std::error_condition apexc_cylinder_image_device::call_load() { /* load RAM contents */ m_writable = !is_readonly(); @@ -39,7 +39,7 @@ image_init_result apexc_cylinder_image_device::call_load() } #endif - return image_init_result::PASS; + return std::error_condition(); } /* diff --git a/src/mame/booth/apexc_m.h b/src/mame/booth/apexc_m.h index 75a26db18f9..380634ad25d 100644 --- a/src/mame/booth/apexc_m.h +++ b/src/mame/booth/apexc_m.h @@ -43,7 +43,7 @@ public: virtual const char *image_type_name() const noexcept override { return "cylinder"; } virtual const char *image_brief_type_name() const noexcept override { return "cyln"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual const char *image_interface() const noexcept override { return "apexc_cyl"; } virtual const software_list_loader &get_software_list_loader() const override { return image_software_list_loader::instance(); } diff --git a/src/mame/canon/x07.cpp b/src/mame/canon/x07.cpp index c8ef2b404a7..082f3709fb6 100644 --- a/src/mame/canon/x07.cpp +++ b/src/mame/canon/x07.cpp @@ -1063,8 +1063,8 @@ DEVICE_IMAGE_LOAD_MEMBER( x07_state::card_load ) if (strcmp(card_type, "xp140")) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported card type"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported card type\n", image.basename()); + return image_error::BADSOFTWARE; } } @@ -1073,7 +1073,7 @@ DEVICE_IMAGE_LOAD_MEMBER( x07_state::card_load ) m_card->ram_alloc(0x1000); - return image_init_result::PASS; + return std::error_condition(); } void x07_state::x07_palette(palette_device &palette) const diff --git a/src/mame/cantab/jupace.cpp b/src/mame/cantab/jupace.cpp index 6896b7d47cd..297f3ffc724 100644 --- a/src/mame/cantab/jupace.cpp +++ b/src/mame/cantab/jupace.cpp @@ -181,9 +181,9 @@ SNAPSHOT_LOAD_MEMBER(ace_state::snapshot_cb) if (m_ram->size() < 16*1024) { - image.seterror(image_error::INVALIDIMAGE, "At least 16KB RAM expansion required"); + osd_printf_error("%s: At least 16KB RAM expansion required\n", image.basename()); image.message("At least 16KB RAM expansion required"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } logerror("Loading file %s.\r\n", image.filename()); @@ -218,9 +218,9 @@ SNAPSHOT_LOAD_MEMBER(ace_state::snapshot_cb) if (!done) { - image.seterror(image_error::INVALIDIMAGE, "EOF marker not found"); + osd_printf_error("%s: EOF marker not found\n", image.basename()); image.message("EOF marker not found"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } // patch CPU registers @@ -258,7 +258,7 @@ SNAPSHOT_LOAD_MEMBER(ace_state::snapshot_cb) for (ace_index = 0x2000; ace_index < 0x8000; ace_index++) space.write_byte(ace_index, RAM[ace_index]); - return image_init_result::PASS; + return std::error_condition(); } //************************************************************************** diff --git a/src/mame/casio/casio_rompack.cpp b/src/mame/casio/casio_rompack.cpp index 6757d846570..acf862fb5c5 100644 --- a/src/mame/casio/casio_rompack.cpp +++ b/src/mame/casio/casio_rompack.cpp @@ -43,7 +43,7 @@ DEVICE_IMAGE_LOAD_MEMBER(casiorom_state::cart_load) uint32_t size = m_cart->common_get_size("rom"); m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void casiorom_state::casiorom(machine_config &config) diff --git a/src/mame/casio/casloopy.cpp b/src/mame/casio/casloopy.cpp index 0cd13ab76ef..3cd3325d3a8 100644 --- a/src/mame/casio/casloopy.cpp +++ b/src/mame/casio/casloopy.cpp @@ -506,7 +506,7 @@ DEVICE_IMAGE_LOAD_MEMBER( casloopy_state::cart_load ) DST[i + 3] = tempb; } - return image_init_result::PASS; + return std::error_condition(); } void casloopy_state::casloopy(machine_config &config) diff --git a/src/mame/casio/pv1000.cpp b/src/mame/casio/pv1000.cpp index a100a0776db..ee5fa094a89 100644 --- a/src/mame/casio/pv1000.cpp +++ b/src/mame/casio/pv1000.cpp @@ -307,14 +307,14 @@ DEVICE_IMAGE_LOAD_MEMBER( pv1000_state::cart_load ) if (size != 0x2000 && size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/casio/pv2000.cpp b/src/mame/casio/pv2000.cpp index 9ac899e3451..dd35c62f170 100644 --- a/src/mame/casio/pv2000.cpp +++ b/src/mame/casio/pv2000.cpp @@ -376,14 +376,14 @@ DEVICE_IMAGE_LOAD_MEMBER( pv2000_state::cart_load ) if (size != 0x2000 && size != 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } /* Machine Drivers */ diff --git a/src/mame/chess/ave_arb.cpp b/src/mame/chess/ave_arb.cpp index 2291331b417..c5ecf4700e0 100644 --- a/src/mame/chess/ave_arb.cpp +++ b/src/mame/chess/ave_arb.cpp @@ -174,7 +174,7 @@ DEVICE_IMAGE_LOAD_MEMBER(arb_state::cart_load) m_altboard = bool(image.get_feature("altboard")); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/coleco/coleco.cpp b/src/mame/coleco/coleco.cpp index 6c2e215e097..0af7fb2cb5c 100644 --- a/src/mame/coleco/coleco.cpp +++ b/src/mame/coleco/coleco.cpp @@ -549,15 +549,15 @@ void bit90_state::machine_reset() m_bank->set_entry(0); } -//static image_verify_result coleco_cart_verify(const uint8_t *cartdata, size_t size) +//static std::error_condition coleco_cart_verify(const uint8_t *cartdata, size_t size) //{ -// int retval = image_verify_result::FAIL; +// std::error_condition retval = image_error::INVALIDIMAGE; // // /* Verify the file is in Colecovision format */ // if ((cartdata[0] == 0xAA) && (cartdata[1] == 0x55)) /* Production Cartridge */ -// retval = image_verify_result::PASS; +// retval = std::error_condition(); // if ((cartdata[0] == 0x55) && (cartdata[1] == 0xAA)) /* "Test" Cartridge. Some games use this method to skip ColecoVision title screen and delay */ -// retval = image_verify_result::PASS; +// retval = std::error_condition(); // // return retval; //} diff --git a/src/mame/commodore/cbm2.cpp b/src/mame/commodore/cbm2.cpp index 0d92bacc087..9ed828e6e0b 100644 --- a/src/mame/commodore/cbm2.cpp +++ b/src/mame/commodore/cbm2.cpp @@ -21,6 +21,7 @@ #include "cpu/m6502/m6509.h" #include "cpu/i86/i86.h" #include "cbm_snqk.h" +#include "imagedev/snapquik.h" #include "machine/6525tpi.h" #include "machine/ds75160a.h" #include "machine/ds75161a.h" diff --git a/src/mame/commodore/cbm_snqk.cpp b/src/mame/commodore/cbm_snqk.cpp index ecf9f2cf1b1..71b32f474ed 100644 --- a/src/mame/commodore/cbm_snqk.cpp +++ b/src/mame/commodore/cbm_snqk.cpp @@ -24,7 +24,7 @@ * 0x001c data */ -image_init_result general_cbm_loadsnap( device_image_interface &image, address_space &space, offs_t offset, +std::error_condition general_cbm_loadsnap( device_image_interface &image, address_space &space, offs_t offset, void (*cbm_sethiaddress)(address_space &space, uint16_t hiaddress) ) { char buffer[7]; @@ -43,9 +43,9 @@ image_init_result general_cbm_loadsnap( device_image_interface &image, address_s { /* p00 files */ if (image.fread( buffer, sizeof(buffer)) != sizeof(buffer)) - goto error; + return image_error::UNSPECIFIED; if (memcmp(buffer, "C64File", sizeof(buffer))) - goto error; + return image_error::INVALIDIMAGE; image.fseek(26, SEEK_SET); snapshot_size -= 26; } @@ -53,15 +53,15 @@ image_init_result general_cbm_loadsnap( device_image_interface &image, address_s { /* t64 files - for GB64 Single T64s loading to x0801 - header is always the same size */ if (image.fread( buffer, sizeof(buffer)) != sizeof(buffer)) - goto error; + return image_error::UNSPECIFIED; if (memcmp(buffer, "C64 tape image file", sizeof(buffer))) - goto error; + return image_error::INVALIDIMAGE; image.fseek(94, SEEK_SET); snapshot_size -= 94; } else { - goto error; + return image_error::UNSUPPORTED; } image.fread( &address, 2); @@ -74,16 +74,13 @@ image_init_result general_cbm_loadsnap( device_image_interface &image, address_s bytesread = image.fread( &data[0], snapshot_size); if (bytesread != snapshot_size) - goto error; + return image_error::UNSPECIFIED; for (i = 0; i < snapshot_size; i++) space.write_byte(address + i + offset, data[i]); cbm_sethiaddress(space, address + snapshot_size); - return image_init_result::PASS; - -error: - return image_init_result::FAIL; + return std::error_condition(); } void cbm_quick_sethiaddress( address_space &space, uint16_t hiaddress ) diff --git a/src/mame/commodore/cbm_snqk.h b/src/mame/commodore/cbm_snqk.h index 70ed094fc58..3921def18ea 100644 --- a/src/mame/commodore/cbm_snqk.h +++ b/src/mame/commodore/cbm_snqk.h @@ -11,11 +11,9 @@ #pragma once -#include "imagedev/snapquik.h" - #define CBM_QUICKLOAD_DELAY (attotime::from_seconds(3)) -image_init_result general_cbm_loadsnap( +std::error_condition general_cbm_loadsnap( device_image_interface &image, address_space &space, offs_t offset, diff --git a/src/mame/commodore/vic20.cpp b/src/mame/commodore/vic20.cpp index 827e6b9a78c..fa9c4fe7ef5 100644 --- a/src/mame/commodore/vic20.cpp +++ b/src/mame/commodore/vic20.cpp @@ -21,6 +21,7 @@ #include "cpu/m6502/m6510.h" #include "machine/6522via.h" #include "cbm_snqk.h" +#include "imagedev/snapquik.h" #include "machine/ram.h" #include "sound/mos6560.h" diff --git a/src/mame/comx/comx35.cpp b/src/mame/comx/comx35.cpp index 6aa3d71d827..67efaa095f0 100644 --- a/src/mame/comx/comx35.cpp +++ b/src/mame/comx/comx35.cpp @@ -66,14 +66,14 @@ QUICKLOAD_LOAD_MEMBER(comx35_state::quickload_cb) if (size > m_ram->size()) { - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } image.fread( header, 5); if (header[1] != 'C' || header[2] != 'O' || header[3] != 'M' || header[4] != 'X' ) { - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } switch (header[0]) @@ -200,7 +200,7 @@ QUICKLOAD_LOAD_MEMBER(comx35_state::quickload_cb) break; } - return image_init_result::PASS; + return std::error_condition(); } //************************************************************************** diff --git a/src/mame/cybiko/cybiko_m.cpp b/src/mame/cybiko/cybiko_m.cpp index 54225b51c06..650667550b6 100644 --- a/src/mame/cybiko/cybiko_m.cpp +++ b/src/mame/cybiko/cybiko_m.cpp @@ -41,7 +41,7 @@ QUICKLOAD_LOAD_MEMBER(cybiko_state::quickload_cybiko) { image.fread(m_flash1->get_ptr(), std::min(image.length(), uint64_t(0x84000))); - return image_init_result::PASS; + return std::error_condition(); } QUICKLOAD_LOAD_MEMBER(cybiko_state::quickload_cybikoxt) @@ -54,7 +54,7 @@ QUICKLOAD_LOAD_MEMBER(cybiko_state::quickload_cybikoxt) for (int byte = 0; byte < size; byte++) dest.write_byte(0x400000 + byte, buffer[byte]); - return image_init_result::PASS; + return std::error_condition(); } /////////////////// diff --git a/src/mame/ddr/jtc.cpp b/src/mame/ddr/jtc.cpp index 88a0d12bfb9..f079e96ffe7 100644 --- a/src/mame/ddr/jtc.cpp +++ b/src/mame/ddr/jtc.cpp @@ -594,20 +594,22 @@ QUICKLOAD_LOAD_MEMBER(jtc_state::quickload_cb) address_space &space = m_maincpu->space(AS_PROGRAM); u16 i, quick_addr, quick_length; std::vector quick_data; - image_init_result result = image_init_result::FAIL; + std::error_condition result = image_error::UNSUPPORTED; quick_length = image.length(); if (image.is_filetype("jtc")) { if (quick_length < 0x0088) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too short\n", image.basename()); image.message(" File too short"); } else if (quick_length > 0x8000) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too long\n", image.basename()); image.message(" File too long"); } else @@ -616,7 +618,8 @@ QUICKLOAD_LOAD_MEMBER(jtc_state::quickload_cb) u16 read_ = image.fread(&quick_data[0], quick_length); if (read_ != quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Cannot read the file"); + result = image_error::UNSPECIFIED; + osd_printf_error("%s: Cannot read the file\n", image.basename()); image.message(" Cannot read the file"); } else @@ -625,7 +628,8 @@ QUICKLOAD_LOAD_MEMBER(jtc_state::quickload_cb) quick_length = quick_data[0x14] * 256 + quick_data[0x13] - quick_addr + 0x81; if (image.length() != quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Invalid file header"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Invalid file header\n", image.basename()); image.message(" Invalid file header"); } else @@ -636,7 +640,7 @@ QUICKLOAD_LOAD_MEMBER(jtc_state::quickload_cb) /* display a message about the loaded quickload */ image.message(" Quickload: size=%04X : loaded at %04X",quick_length,quick_addr); - result = image_init_result::PASS; + result = std::error_condition(); } } } @@ -647,7 +651,8 @@ QUICKLOAD_LOAD_MEMBER(jtc_state::quickload_cb) quick_addr = 0xe000; if (quick_length > 0x8000) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too long\n", image.basename()); image.message(" File too long"); } else @@ -656,7 +661,8 @@ QUICKLOAD_LOAD_MEMBER(jtc_state::quickload_cb) u16 read_ = image.fread( &quick_data[0], quick_length); if (read_ != quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Cannot read the file"); + result = image_error::UNSPECIFIED; + osd_printf_error("%s: Cannot read the file\n", image.basename()); image.message(" Cannot read the file"); } else @@ -667,7 +673,7 @@ QUICKLOAD_LOAD_MEMBER(jtc_state::quickload_cb) /* display a message about the loaded quickload */ image.message(" Quickload: size=%04X : loaded at %04X",quick_length,quick_addr); - result = image_init_result::PASS; + result = std::error_condition(); m_maincpu->set_pc(quick_addr); } } diff --git a/src/mame/ddr/kc_m.cpp b/src/mame/ddr/kc_m.cpp index 986037c0fbd..7a04e766c44 100644 --- a/src/mame/ddr/kc_m.cpp +++ b/src/mame/ddr/kc_m.cpp @@ -39,7 +39,7 @@ QUICKLOAD_LOAD_MEMBER(kc_state::quickload_cb) uint64_t size = image.length(); if (size == 0) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; std::vector data(size); image.fread( &data[0], size); @@ -68,7 +68,7 @@ QUICKLOAD_LOAD_MEMBER(kc_state::quickload_cb) logerror("Snapshot loaded at: 0x%04x-0x%04x, execution address: 0x%04x\n", addr, addr + datasize - 1, execution_address); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/ddr/sprachmg.cpp b/src/mame/ddr/sprachmg.cpp index b6c7d6d5fc9..b367a56a07f 100644 --- a/src/mame/ddr/sprachmg.cpp +++ b/src/mame/ddr/sprachmg.cpp @@ -270,16 +270,16 @@ DEVICE_IMAGE_LOAD_MEMBER( sprachmg_state::module_load ) { if (!image.loaded_through_softlist()) { - image.seterror(image_error::UNSUPPORTED, "Speech modules can only be loaded using a software list"); - return image_init_result::FAIL; + osd_printf_error("Speech modules can only be loaded using a software list\n"); + return image_error::UNSUPPORTED; } uint32_t pcb1_size = image.get_software_region_length("pcb1"); if (pcb1_size != 0xc000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid pcb1 region length"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid pcb1 region length\n", image.basename()); + return image_error::BADSOFTWARE; } m_speech_module_pcb1 = image.get_software_region("pcb1"); @@ -288,13 +288,13 @@ DEVICE_IMAGE_LOAD_MEMBER( sprachmg_state::module_load ) if (pcb2_size > 0 && pcb2_size != 0xc000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid pcb2 region length"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid pcb2 region length\n", image.basename()); + return image_error::BADSOFTWARE; } m_speech_module_pcb2 = image.get_software_region("pcb2"); - return image_init_result::PASS; + return std::error_condition(); } uint8_t sprachmg_state::speech_r(offs_t offset) diff --git a/src/mame/dec/pdp1.cpp b/src/mame/dec/pdp1.cpp index fd719ce63b0..996411fd846 100644 --- a/src/mame/dec/pdp1.cpp +++ b/src/mame/dec/pdp1.cpp @@ -696,7 +696,7 @@ void pdp1_cylinder_image_device::device_start() /* Open a perforated tape image */ -image_init_result pdp1_readtape_image_device::call_load() +std::error_condition pdp1_readtape_image_device::call_load() { // start motor m_motor_on = 1; @@ -718,7 +718,7 @@ image_init_result pdp1_readtape_image_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } void pdp1_readtape_image_device::call_unload() @@ -908,9 +908,9 @@ void pdp1_readtape_image_device::iot_rrb(int op2, int nac, int mb, int &io, int } -image_init_result pdp1_punchtape_image_device::call_load() +std::error_condition pdp1_punchtape_image_device::call_load() { - return image_init_result::PASS; + return std::error_condition(); } void pdp1_punchtape_image_device::call_unload() @@ -1008,11 +1008,11 @@ void pdp1_punchtape_image_device::iot_ppb(int op2, int nac, int mb, int &io, int /* Open a file for typewriter output */ -image_init_result pdp1_typewriter_device::call_load() +std::error_condition pdp1_typewriter_device::call_load() { m_st_tyo(1); - return image_init_result::PASS; + return std::error_condition(); } void pdp1_typewriter_device::call_unload() @@ -1326,9 +1326,9 @@ void pdp1_cylinder_image_device::parallel_drum_init() /* Open a file for drum */ -image_init_result pdp1_cylinder_image_device::call_load() +std::error_condition pdp1_cylinder_image_device::call_load() { - return image_init_result::PASS; + return std::error_condition(); } void pdp1_cylinder_image_device::call_unload() diff --git a/src/mame/dec/pdp1.h b/src/mame/dec/pdp1.h index 203bee6e168..4b626049307 100644 --- a/src/mame/dec/pdp1.h +++ b/src/mame/dec/pdp1.h @@ -195,7 +195,7 @@ protected: // image-level overrides virtual const char *file_extensions() const noexcept override { return "tap,rim"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; public: @@ -245,7 +245,7 @@ protected: virtual bool is_reset_on_load() const noexcept override { return false; } virtual const char *file_extensions() const noexcept override { return "tap,rim"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; public: @@ -291,7 +291,7 @@ protected: virtual const char *image_type_name() const noexcept override { return "printout"; } virtual const char *image_brief_type_name() const noexcept override { return "prin"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; public: @@ -348,7 +348,7 @@ protected: virtual const char *image_brief_type_name() const noexcept override { return "cyln"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; public: diff --git a/src/mame/entex/sag.cpp b/src/mame/entex/sag.cpp index 494252a5c3c..82b26914032 100644 --- a/src/mame/entex/sag.cpp +++ b/src/mame/entex/sag.cpp @@ -101,8 +101,8 @@ DEVICE_IMAGE_LOAD_MEMBER(sag_state::cart_load) if (size != 0x1000 && size != 0x1100 && size != 0x2000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid ROM file size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid ROM file size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -114,8 +114,8 @@ DEVICE_IMAGE_LOAD_MEMBER(sag_state::cart_load) // TMS1670 MCU if (!image.loaded_through_softlist()) { - image.seterror(image_error::INVALIDIMAGE, "Can only load TMS1670 type through softwarelist"); - return image_init_result::FAIL; + osd_printf_error("Can only load TMS1670 type through softwarelist\n"); + return image_error::UNSUPPORTED; } memcpy(memregion("tms1k_cpu")->base(), m_cart->get_rom_base(), size); @@ -125,16 +125,16 @@ DEVICE_IMAGE_LOAD_MEMBER(sag_state::cart_load) size = image.get_software_region_length("rom:mpla"); if (size != 867) { - image.seterror(image_error::INVALIDIMAGE, "Invalid MPLA file size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid MPLA file size\n", image.basename()); + return image_error::BADSOFTWARE; } memcpy(memregion("tms1k_cpu:mpla")->base(), image.get_software_region("rom:mpla"), size); size = image.get_software_region_length("rom:opla"); if (size != 557) { - image.seterror(image_error::INVALIDIMAGE, "Invalid OPLA file size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid OPLA file size\n", image.basename()); + return image_error::BADSOFTWARE; } memcpy(memregion("tms1k_cpu:opla")->base(), image.get_software_region("rom:opla"), size); @@ -154,7 +154,7 @@ DEVICE_IMAGE_LOAD_MEMBER(sag_state::cart_load) m_hmcs40_cpu->set_clock(450000); // from main PCB } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/epson/hx20.cpp b/src/mame/epson/hx20.cpp index 22297641210..c7337cf1be0 100644 --- a/src/mame/epson/hx20.cpp +++ b/src/mame/epson/hx20.cpp @@ -836,14 +836,14 @@ DEVICE_IMAGE_LOAD_MEMBER(hx20_state::optrom_load) if (size != 0x2000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported ROM size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported ROM size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_optrom->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_optrom->common_load_rom(m_optrom->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } uint8_t hx20_state::optrom_r(offs_t offset) diff --git a/src/mame/epson/qx10.cpp b/src/mame/epson/qx10.cpp index 656bafbd4b1..46338ae131a 100644 --- a/src/mame/epson/qx10.cpp +++ b/src/mame/epson/qx10.cpp @@ -431,7 +431,7 @@ QUICKLOAD_LOAD_MEMBER(qx10_state::quickload_cb) address_space& prog_space = m_maincpu->space(AS_PROGRAM); if (image.length() >= 0xfd00) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; /* The right RAM bank must be active */ m_membank = 0; @@ -441,7 +441,7 @@ QUICKLOAD_LOAD_MEMBER(qx10_state::quickload_cb) if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) { machine_reset(); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } /* Load image to the TPA (Transient Program Area) */ @@ -450,7 +450,7 @@ QUICKLOAD_LOAD_MEMBER(qx10_state::quickload_cb) { uint8_t data; if (image.fread( &data, 1) != 1) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; prog_space.write_byte(i+0x100, data); } @@ -461,7 +461,7 @@ QUICKLOAD_LOAD_MEMBER(qx10_state::quickload_cb) m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 300); m_maincpu->set_pc(0x100); // start program - return image_init_result::PASS; + return std::error_condition(); } /* diff --git a/src/mame/exidy/sorcerer_m.cpp b/src/mame/exidy/sorcerer_m.cpp index 86b0616bbe4..2359f4867f2 100644 --- a/src/mame/exidy/sorcerer_m.cpp +++ b/src/mame/exidy/sorcerer_m.cpp @@ -533,15 +533,15 @@ QUICKLOAD_LOAD_MEMBER(sorcerer_state::quickload_cb) u16 execute_address, start_address, end_address; // load the binary into memory - if (z80bin_load_file(image, space, execute_address, start_address, end_address) != image_init_result::PASS) - return image_init_result::FAIL; + std::error_condition err = z80bin_load_file(image, space, execute_address, start_address, end_address); + if (err) + return err; // is this file executable? if (execute_address != 0xffff) { - if ((execute_address >= 0xc000) && (execute_address <= 0xdfff) && (space.read_byte(0xdffa) != 0xc3)) - return image_init_result::FAIL; // can't run a program if the cartridge isn't in + return image_error::UNSUPPORTED; // can't run a program if the cartridge isn't in /* Since Exidy Basic is by Microsoft, it needs some preprocessing before it can be run. 1. A start address of 01D5 indicates a basic program which needs its pointers fixed up. @@ -588,9 +588,9 @@ QUICKLOAD_LOAD_MEMBER(sorcerer_state::quickload_cb) // check size if (image.length() != 0x1001c) { - image.seterror(image_error::INVALIDIMAGE, "Snapshot must be 65564 bytes"); + osd_printf_error("%s: Snapshot must be 65564 bytes\n", image.basename()); image.message("Snapshot must be 65564 bytes"); - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } /* get the header */ @@ -651,6 +651,6 @@ QUICKLOAD_LOAD_MEMBER(sorcerer_state::quickload_cb) m_maincpu->set_pc(0xe000); // SNP destroys workspace, so do cold start. } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/force/force68k.cpp b/src/mame/force/force68k.cpp index 7e4068bc239..8f28c6d1861 100644 --- a/src/mame/force/force68k.cpp +++ b/src/mame/force/force68k.cpp @@ -196,7 +196,7 @@ private: DECLARE_WRITE_LINE_MEMBER (centronics_select_w); // User EPROM/SRAM slot(s) - image_init_result force68k_load_cart(device_image_interface &image, generic_slot_device *slot); + std::error_condition force68k_load_cart(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER (exp1_load) { return force68k_load_cart(image, m_cart); } uint16_t read16_rom(offs_t offset); @@ -510,21 +510,21 @@ void force68k_state::fccpu1_eprom_sockets(machine_config &config) /*************************** Rom loading functions ****************************/ -image_init_result force68k_state::force68k_load_cart(device_image_interface &image, generic_slot_device *slot) +std::error_condition force68k_state::force68k_load_cart(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); if (size > 0x20000) // Max 128Kb { LOG("Cartridge size exceeding max size (128Kb): %d\n", size); - image.seterror(image_error::INVALIDIMAGE, "Cartridge size exceeding max size (128Kb)"); - return image_init_result::FAIL; + osd_printf_error("%s: Cartridge size exceeding max size (128Kb)\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_BIG); slot->common_load_rom(slot->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/fujitsu/fmt_icmem.cpp b/src/mame/fujitsu/fmt_icmem.cpp index b38c3057eb7..4cfad33fbfe 100644 --- a/src/mame/fujitsu/fmt_icmem.cpp +++ b/src/mame/fujitsu/fmt_icmem.cpp @@ -60,18 +60,18 @@ ioport_constructor fmt_icmem_device::device_input_ports() const return INPUT_PORTS_NAME(fmt_icmem); } -image_init_result fmt_icmem_device::call_load() +std::error_condition fmt_icmem_device::call_load() { memset(m_memcard_ram.get(), 0xff, 0x1000000); fseek(0, SEEK_SET); size_t ret = fread(m_memcard_ram.get(), 0x1000000); if(ret != length()) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; m_change = true; m_detect = true; - return image_init_result::PASS; + return std::error_condition(); } void fmt_icmem_device::call_unload() @@ -83,17 +83,17 @@ void fmt_icmem_device::call_unload() m_detect = false; } -image_init_result fmt_icmem_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition fmt_icmem_device::call_create(int format_type, util::option_resolution *format_options) { memset(m_memcard_ram.get(), 0xff, 0x1000000); size_t ret = fwrite(m_memcard_ram.get(), 0x1000000); if(ret != 0x1000000) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; m_change = true; m_detect = true; - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/fujitsu/fmt_icmem.h b/src/mame/fujitsu/fmt_icmem.h index 3f6afead325..a42abe77a02 100644 --- a/src/mame/fujitsu/fmt_icmem.h +++ b/src/mame/fujitsu/fmt_icmem.h @@ -29,9 +29,9 @@ public: virtual bool is_reset_on_load() const noexcept override { return false; } virtual const char *file_extensions() const noexcept override { return "icm"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; uint8_t static_mem_read(offs_t offset); void static_mem_write(offs_t offset, uint8_t data); diff --git a/src/mame/funtech/supracan.cpp b/src/mame/funtech/supracan.cpp index 53224ccfc30..64efd11b924 100644 --- a/src/mame/funtech/supracan.cpp +++ b/src/mame/funtech/supracan.cpp @@ -1922,14 +1922,14 @@ DEVICE_IMAGE_LOAD_MEMBER(supracan_state::cart_load) if (size > 0x400000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_BIG); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/handheld/chessking.cpp b/src/mame/handheld/chessking.cpp index 5b355d3ec5a..2c955ff002e 100644 --- a/src/mame/handheld/chessking.cpp +++ b/src/mame/handheld/chessking.cpp @@ -185,7 +185,7 @@ DEVICE_IMAGE_LOAD_MEMBER(chessking_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } uint8_t chessking_state::cartridge_r(offs_t offset) diff --git a/src/mame/handheld/gameking.cpp b/src/mame/handheld/gameking.cpp index c6c59de70ef..8c23a8bdce1 100644 --- a/src/mame/handheld/gameking.cpp +++ b/src/mame/handheld/gameking.cpp @@ -258,14 +258,14 @@ DEVICE_IMAGE_LOAD_MEMBER(gameking_state::cart_load) if (size > 0x100000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void gameking_state::machine_start() diff --git a/src/mame/handheld/hh_tms1k.cpp b/src/mame/handheld/hh_tms1k.cpp index eb7560ff076..2c49ae17e6b 100644 --- a/src/mame/handheld/hh_tms1k.cpp +++ b/src/mame/handheld/hh_tms1k.cpp @@ -2908,8 +2908,8 @@ DEVICE_IMAGE_LOAD_MEMBER(quizwizc_state::cart_load) { if (!image.loaded_through_softlist()) { - image.seterror(image_error::UNSUPPORTED, "Can only load through softwarelist"); - return image_init_result::FAIL; + osd_printf_error("Can only load through softwarelist\n"); + return image_error::UNSUPPORTED; } // get cartridge pinout K1 to R connections @@ -2919,11 +2919,11 @@ DEVICE_IMAGE_LOAD_MEMBER(quizwizc_state::cart_load) if (m_pinout == 0) { - image.seterror(image_error::INVALIDIMAGE, "Invalid cartridge pinout"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid cartridge pinout\n", image.basename()); + return image_error::BADSOFTWARE; } - return image_init_result::PASS; + return std::error_condition(); } void quizwizc_state::update_display() @@ -3103,15 +3103,15 @@ DEVICE_IMAGE_LOAD_MEMBER(tc4_state::cart_load) { if (!image.loaded_through_softlist()) { - image.seterror(image_error::UNSUPPORTED, "Can only load through softwarelist"); - return image_init_result::FAIL; + osd_printf_error("Can only load through softwarelist\n"); + return image_error::UNSUPPORTED; } // get cartridge pinout R9 to K connections const char *pinout = image.get_feature("pinout"); m_pinout = pinout ? strtoul(pinout, nullptr, 0) & 0xf : 0xf; - return image_init_result::PASS; + return std::error_condition(); } void tc4_state::update_display() @@ -13971,15 +13971,15 @@ DEVICE_IMAGE_LOAD_MEMBER(playmaker_state::cart_load) { if (!image.loaded_through_softlist()) { - image.seterror(image_error::UNSUPPORTED, "Can only load through softwarelist"); - return image_init_result::FAIL; + osd_printf_error("Can only load through softwarelist\n"); + return image_error::UNSUPPORTED; } // get cartridge notch const char *notch = image.get_feature("notch"); m_notch = notch ? strtoul(notch, nullptr, 0) & 3 : 0; - return image_init_result::PASS; + return std::error_condition(); } void playmaker_state::update_display() diff --git a/src/mame/handheld/lk3000.cpp b/src/mame/handheld/lk3000.cpp index e781c9e6d9a..5c14ff40de4 100644 --- a/src/mame/handheld/lk3000.cpp +++ b/src/mame/handheld/lk3000.cpp @@ -124,7 +124,7 @@ DEVICE_IMAGE_LOAD_MEMBER(lk3000_state::cart_load) // extra ram (optional) m_has_ram = image.get_feature("ram") != nullptr; - return image_init_result::PASS; + return std::error_condition(); } template diff --git a/src/mame/homebrew/phunsy.cpp b/src/mame/homebrew/phunsy.cpp index cdd5f55e7ec..66ca5278932 100644 --- a/src/mame/homebrew/phunsy.cpp +++ b/src/mame/homebrew/phunsy.cpp @@ -289,11 +289,12 @@ QUICKLOAD_LOAD_MEMBER(phunsy_state::quickload_cb) uint16_t i; uint16_t quick_addr = 0x1800; std::vector quick_data; - image_init_result result = image_init_result::FAIL; + std::error_condition result = image_error::UNSPECIFIED; int quick_length = image.length(); if (quick_length > 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too long\n", image.basename()); image.message(" File too long"); } else @@ -316,7 +317,7 @@ QUICKLOAD_LOAD_MEMBER(phunsy_state::quickload_cb) m_maincpu->set_state_int(S2650_R3, 0x83); m_maincpu->set_state_int(S2650_PC, exec_addr); - result = image_init_result::PASS; + result = std::error_condition(); } return result; diff --git a/src/mame/homebrew/ravens.cpp b/src/mame/homebrew/ravens.cpp index 6ffcac24b3a..3cae68c0b2d 100644 --- a/src/mame/homebrew/ravens.cpp +++ b/src/mame/homebrew/ravens.cpp @@ -319,17 +319,19 @@ QUICKLOAD_LOAD_MEMBER(ravens_base::quickload_cb) int quick_length; std::vector quick_data; int read_; - image_init_result result = image_init_result::FAIL; + std::error_condition result = image_error::UNSPECIFIED; quick_length = image.length(); if (quick_length < 0x0900) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too short\n", image.basename()); image.message(" File too short"); } else if (quick_length > 0x8000) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too long\n", image.basename()); image.message(" File too long"); } else @@ -338,12 +340,13 @@ QUICKLOAD_LOAD_MEMBER(ravens_base::quickload_cb) read_ = image.fread( &quick_data[0], quick_length); if (read_ != quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Cannot read the file"); + osd_printf_error("%s: Cannot read the file\n", image.basename()); image.message(" Cannot read the file"); } else if (quick_data[0] != 0xc6) { - image.seterror(image_error::INVALIDIMAGE, "Invalid header"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Invalid header\n", image.basename()); image.message(" Invalid header"); } else @@ -352,7 +355,8 @@ QUICKLOAD_LOAD_MEMBER(ravens_base::quickload_cb) if (exec_addr >= quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Exec address beyond end of file"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Exec address beyond end of file\n", image.basename()); image.message(" Exec address beyond end of file"); } else @@ -366,7 +370,7 @@ QUICKLOAD_LOAD_MEMBER(ravens_base::quickload_cb) // Start the quickload m_maincpu->set_state_int(S2650_PC, exec_addr); - result = image_init_result::PASS; + result = std::error_condition(); } } } diff --git a/src/mame/homebrew/uzebox.cpp b/src/mame/homebrew/uzebox.cpp index ebc5a0ff72a..ffb96a01d18 100644 --- a/src/mame/homebrew/uzebox.cpp +++ b/src/mame/homebrew/uzebox.cpp @@ -270,7 +270,7 @@ DEVICE_IMAGE_LOAD_MEMBER(uzebox_state::cart_load) else memcpy(m_cart->get_rom_base(), image.get_software_region("rom"), size); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/homebrew/z80clock.cpp b/src/mame/homebrew/z80clock.cpp index a06c5c1e1b4..d2157904541 100644 --- a/src/mame/homebrew/z80clock.cpp +++ b/src/mame/homebrew/z80clock.cpp @@ -321,13 +321,13 @@ private: { auto length = image.length(); if (length > m_u13.bytes()) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; if (image.fread(m_u13, length) != length) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; m_maincpu->set_pc(0x6000); - return image_init_result::PASS; + return std::error_condition(); } }; diff --git a/src/mame/homelab/homelab.cpp b/src/mame/homelab/homelab.cpp index 63eba19be6d..5f7b4b91b0c 100644 --- a/src/mame/homelab/homelab.cpp +++ b/src/mame/homelab/homelab.cpp @@ -688,18 +688,18 @@ QUICKLOAD_LOAD_MEMBER(homelab_state::quickload_cb) u32 bytes = image.fread(&ch, 1); if (bytes != 1 || ch != 0xA5) { - image.seterror(image_error::INVALIDIMAGE, "Invalid header"); + osd_printf_error("%s: Invalid header\n", image.basename()); image.message(" Invalid header"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } while ((bytes = image.fread(&ch, 1)) != 0 && ch != 0) { if (i >= (std::size(pgmname) - 1)) { - image.seterror(image_error::INVALIDIMAGE, "File name too long"); + osd_printf_error("File name too long\n"); image.message(" File name too long"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } // image.message treats characters with bit 7 as nulls, so replace with question mark @@ -711,9 +711,9 @@ QUICKLOAD_LOAD_MEMBER(homelab_state::quickload_cb) if (image.fread(args, sizeof(args)) != sizeof(args)) { - image.seterror(image_error::INVALIDIMAGE, "Unexpected EOF while getting file size"); + osd_printf_error("%s: Unexpected EOF while getting file size\n", image.basename()); image.message(" Unexpected EOF while getting file size"); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } u16 quick_addr = little_endianize_int16(args[0]); @@ -722,9 +722,9 @@ QUICKLOAD_LOAD_MEMBER(homelab_state::quickload_cb) if (quick_end > 0x7fff) { - image.seterror(image_error::INVALIDIMAGE, "File too large"); + osd_printf_error("%s: File too large\n", image.basename()); image.message(" File too large"); - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } /* display a message about the loaded quickload */ @@ -735,16 +735,14 @@ QUICKLOAD_LOAD_MEMBER(homelab_state::quickload_cb) int j = (quick_addr + i); if (image.fread(&ch, 1) != 1) { - char message[512]; - snprintf(message, std::size(message), "%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j); - image.seterror(image_error::INVALIDIMAGE, message); + osd_printf_error("%s: Unexpected EOF while writing byte to %04X\n", image.basename(), j); image.message("%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } space.write_byte(j, ch); } - return image_init_result::PASS; + return std::error_condition(); } /* Machine driver */ diff --git a/src/mame/hp/hp48_port.cpp b/src/mame/hp/hp48_port.cpp index cacc61f3297..e63e711851b 100644 --- a/src/mame/hp/hp48_port.cpp +++ b/src/mame/hp/hp48_port.cpp @@ -45,7 +45,7 @@ void hp48_port_image_device::unfill_port() } -image_init_result hp48_port_image_device::call_load() +std::error_condition hp48_port_image_device::call_load() { int size = length(); if (size == 0) size = m_max_size; /* default size */ @@ -55,7 +55,7 @@ image_init_result hp48_port_image_device::call_load() if ((size < 32*1024) || (size > m_max_size) || (size & (size-1))) { logerror("hp48: image size for %s should be a power of two between %i and %i\n", tag(), 32*1024, m_max_size); - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_port_size = size; @@ -63,10 +63,10 @@ image_init_result hp48_port_image_device::call_load() fill_port(); fread(m_port_data.get(), m_port_size); m_hp48->decode_nibble(m_port_data.get(), m_port_data.get(), m_port_size); - return image_init_result::PASS; + return std::error_condition(); } -image_init_result hp48_port_image_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition hp48_port_image_device::call_create(int format_type, util::option_resolution *format_options) { int size = m_max_size; LOG("hp48_port_image create: size=%i\n", size); @@ -77,13 +77,13 @@ image_init_result hp48_port_image_device::call_create(int format_type, util::opt if ( (size < 32*1024) || (size > m_max_size) || (size & (size-1)) ) { logerror( "hp48: image size for %s should be a power of two between %i and %i\n", tag(), 32*1024, m_max_size ); - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_port_size = size; m_port_write = true; fill_port(); - return image_init_result::PASS; + return std::error_condition(); } void hp48_port_image_device::call_unload() diff --git a/src/mame/hp/hp48_port.h b/src/mame/hp/hp48_port.h index aae56b7f964..e668bd85cc1 100644 --- a/src/mame/hp/hp48_port.h +++ b/src/mame/hp/hp48_port.h @@ -43,9 +43,9 @@ public: virtual const char *image_type_name() const noexcept override { return "port"; } virtual const char *image_brief_type_name() const noexcept override { return "p"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; uint32_t port_size() const { return m_port_size; } bool port_write() const { return m_port_write; } diff --git a/src/mame/hp/hp80_optrom.cpp b/src/mame/hp/hp80_optrom.cpp index 0dc0cec1022..dadb40ed742 100644 --- a/src/mame/hp/hp80_optrom.cpp +++ b/src/mame/hp/hp80_optrom.cpp @@ -44,42 +44,42 @@ void hp80_optrom_device::device_start() { } -image_init_result hp80_optrom_device::call_load() +std::error_condition hp80_optrom_device::call_load() { LOG("hp80_optrom: call_load\n"); if (!loaded_through_softlist()) { LOG("hp80_optrom: must be loaded from sw list\n"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } const char *sc_feature = get_feature("sc"); if (sc_feature == nullptr) { LOG("hp80_optrom: no 'sc' feature\n"); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } unsigned sc; if (sc_feature[ 0 ] != '0' || sc_feature[ 1 ] != 'x' || sscanf(&sc_feature[ 2 ] , "%x" , &sc) != 1) { LOG("hp80_optrom: can't parse 'sc' feature\n"); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } // Valid SC values: 0x01..0xff if (sc < 1 || sc > 0xff) { LOG("hp80_optrom: illegal select code (%x)\n" , sc); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } auto length = get_software_region_length("rom"); if (length != HP80_OPTROM_SIZE) { LOG("hp80_optrom: illegal region length (%x)\n" , length); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } LOG("hp80_optrom: loaded SC=0x%02x\n" , sc); m_select_code = sc; - return image_init_result::PASS; + return std::error_condition(); } void hp80_optrom_device::call_unload() diff --git a/src/mame/hp/hp80_optrom.h b/src/mame/hp/hp80_optrom.h index 43bab5bf2fc..f98f4d538e8 100644 --- a/src/mame/hp/hp80_optrom.h +++ b/src/mame/hp/hp80_optrom.h @@ -38,7 +38,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/mame/hp/hp9825_optrom.cpp b/src/mame/hp/hp9825_optrom.cpp index b3ad2b115ed..67df198a2c5 100644 --- a/src/mame/hp/hp9825_optrom.cpp +++ b/src/mame/hp/hp9825_optrom.cpp @@ -105,23 +105,23 @@ void hp9825_optrom_device::device_start() { } -image_init_result hp9825_optrom_device::call_load() +std::error_condition hp9825_optrom_device::call_load() { LOG("hp9825_optrom: call_load\n"); if (!loaded_through_softlist()) { LOG("hp9825_optrom: must be loaded from sw list\n"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } for (const struct optrom_region& reg : region_tab) { auto len = get_software_region_length(reg.m_tag) / 2; if (len != 0 && len != reg.m_size) { LOG("Region %s: wrong size (%u should be %u)\n" , reg.m_tag , len , reg.m_size); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } } - return image_init_result::PASS; + return std::error_condition(); } void hp9825_optrom_device::call_unload() diff --git a/src/mame/hp/hp9825_optrom.h b/src/mame/hp/hp9825_optrom.h index f9db1db1323..00e95b7f899 100644 --- a/src/mame/hp/hp9825_optrom.h +++ b/src/mame/hp/hp9825_optrom.h @@ -34,7 +34,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/mame/hp/hp9845_optrom.cpp b/src/mame/hp/hp9845_optrom.cpp index c33b8b8ab16..637437332d1 100644 --- a/src/mame/hp/hp9845_optrom.cpp +++ b/src/mame/hp/hp9845_optrom.cpp @@ -34,24 +34,24 @@ void hp9845_optrom_device::device_start() { } -image_init_result hp9845_optrom_device::call_load() +std::error_condition hp9845_optrom_device::call_load() { logerror("hp9845_optrom: call_load\n"); if (!loaded_through_softlist()) { logerror("hp9845_optrom: must be loaded from sw list\n"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } const char *base_feature = get_feature("base"); if (base_feature == nullptr) { logerror("hp9845_optrom: no 'base' feature\n"); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } offs_t base_addr; if (base_feature[ 0 ] != '0' || base_feature[ 1 ] != 'x' || sscanf(&base_feature[ 2 ] , "%x" , &base_addr) != 1) { logerror("hp9845_optrom: can't parse 'base' feature\n"); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } // Valid BSC values for ROMs on LPU drawer: 0x07 0x0b .... 0x3b @@ -61,14 +61,14 @@ image_init_result hp9845_optrom_device::call_load() // Base address must be multiple of 0x1000 if ((base_addr & ~0x3f7000UL) != 0 || ((base_addr & 0x30000) != 0x10000 && (base_addr & 0x30000) != 0x30000) || base_addr < 0x70000) { logerror("hp9845_optrom: illegal base address (%x)\n" , base_addr); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } auto length = get_software_region_length("rom") / 2; if (length < 0x1000 || length > 0x8000 || (length & 0xfff) != 0 || ((base_addr & 0x7000) + length) > 0x8000) { logerror("hp9845_optrom: illegal region length (%x)\n" , length); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } offs_t end_addr = base_addr + length - 1; @@ -83,7 +83,7 @@ image_init_result hp9845_optrom_device::call_load() m_base_addr = base_addr; m_end_addr = end_addr; - return image_init_result::PASS; + return std::error_condition(); } void hp9845_optrom_device::call_unload() diff --git a/src/mame/hp/hp9845_optrom.h b/src/mame/hp/hp9845_optrom.h index 193858faa1b..1764c1a8edd 100644 --- a/src/mame/hp/hp9845_optrom.h +++ b/src/mame/hp/hp9845_optrom.h @@ -28,7 +28,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/mame/hp/hp_ipc_optrom.cpp b/src/mame/hp/hp_ipc_optrom.cpp index 045b420b6ef..76eec5f30e5 100644 --- a/src/mame/hp/hp_ipc_optrom.cpp +++ b/src/mame/hp/hp_ipc_optrom.cpp @@ -49,33 +49,33 @@ void hp_ipc_optrom_device::device_start() { } -image_init_result hp_ipc_optrom_device::call_load() +std::error_condition hp_ipc_optrom_device::call_load() { LOG("hp_ipc_optrom: call_load\n"); if (!loaded_through_softlist()) { LOG("hp_ipc_optrom: must be loaded from sw list\n"); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } const char *base_feature = get_feature("base"); if (base_feature == nullptr) { LOG("hp_ipc_optrom: no 'base' feature\n"); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } if (base_feature[ 0 ] != '0' || base_feature[ 1 ] != 'x' || sscanf(&base_feature[ 2 ] , "%x" , &m_base) != 1) { LOG("hp_ipc_optrom: can't parse 'base' feature\n"); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } // Valid base values: multiple of 1M, [0x100000..0x4fffff] if ((m_base & 0xfffffU) != 0 || m_base < 0x100000U || m_base > 0x400000U) { LOG("hp_ipc_optrom: illegal base (%x)\n" , m_base); - return image_init_result::FAIL; + return image_error::BADSOFTWARE; } LOG("hp_ipc_optrom: loaded base=0x%06x\n" , m_base); - return image_init_result::PASS; + return std::error_condition(); } void hp_ipc_optrom_device::call_unload() diff --git a/src/mame/hp/hp_ipc_optrom.h b/src/mame/hp/hp_ipc_optrom.h index c41d8e2391b..bc4b246f7db 100644 --- a/src/mame/hp/hp_ipc_optrom.h +++ b/src/mame/hp/hp_ipc_optrom.h @@ -35,7 +35,7 @@ protected: virtual void device_start() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return true; } diff --git a/src/mame/igs/pgm2_memcard.cpp b/src/mame/igs/pgm2_memcard.cpp index f50c8b9e07b..a269d823d9e 100644 --- a/src/mame/igs/pgm2_memcard.cpp +++ b/src/mame/igs/pgm2_memcard.cpp @@ -43,24 +43,24 @@ void pgm2_memcard_device::device_start() with the given index -------------------------------------------------*/ -image_init_result pgm2_memcard_device::call_load() +std::error_condition pgm2_memcard_device::call_load() { m_authenticated = false; if(length() != 0x108) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; fseek(0, SEEK_SET); size_t ret = fread(m_memcard_data, 0x100); if(ret != 0x100) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; ret = fread(m_protection_data, 4); if (ret != 4) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; ret = fread(m_security_data, 4); if (ret != 4) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; - return image_init_result::PASS; + return std::error_condition(); } void pgm2_memcard_device::call_unload() @@ -72,14 +72,14 @@ void pgm2_memcard_device::call_unload() fwrite(m_security_data, 4); } -image_init_result pgm2_memcard_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition pgm2_memcard_device::call_create(int format_type, util::option_resolution *format_options) { m_authenticated = false; // cards must contain valid defaults for each game / region or they don't work? memory_region *rgn = memregion("^default_card"); if (!rgn) - return image_init_result::FAIL; + return image_error::INTERNAL; memcpy(m_memcard_data, rgn->base(), 0x100); memcpy(m_protection_data, rgn->base() + 0x100, 4); @@ -87,9 +87,9 @@ image_init_result pgm2_memcard_device::call_create(int format_type, util::option size_t ret = fwrite(rgn->base(), 0x108); if(ret != 0x108) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; - return image_init_result::PASS; + return std::error_condition(); } void pgm2_memcard_device::auth(u8 p1, u8 p2, u8 p3) diff --git a/src/mame/igs/pgm2_memcard.h b/src/mame/igs/pgm2_memcard.h index 3403e91694c..23b55a61956 100644 --- a/src/mame/igs/pgm2_memcard.h +++ b/src/mame/igs/pgm2_memcard.h @@ -32,9 +32,9 @@ public: virtual bool is_reset_on_load() const noexcept override { return false; } virtual const char *file_extensions() const noexcept override { return "pg2,bin,mem"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; // device-level overrides virtual void device_start() override; diff --git a/src/mame/intel/imm6_76.cpp b/src/mame/intel/imm6_76.cpp index 19a8d4ad5c8..1ecb6c09c97 100644 --- a/src/mame/intel/imm6_76.cpp +++ b/src/mame/intel/imm6_76.cpp @@ -48,23 +48,23 @@ void intel_imm6_76_device::device_start() } -image_init_result intel_imm6_76_device::call_load() +std::error_condition intel_imm6_76_device::call_load() { if (length() != std::size(m_data)) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; else if (fread(m_data, std::size(m_data)) != std::size(m_data)) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; else - return image_init_result::PASS; + return std::error_condition(); } -image_init_result intel_imm6_76_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition intel_imm6_76_device::call_create(int format_type, util::option_resolution *format_options) { std::fill(std::begin(m_data), std::end(m_data), 0U); if (fwrite(m_data, std::size(m_data)) != std::size(m_data)) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; else - return image_init_result::PASS; + return std::error_condition(); } void intel_imm6_76_device::call_unload() diff --git a/src/mame/intel/imm6_76.h b/src/mame/intel/imm6_76.h index 88e0fc44048..f2b10bc6750 100644 --- a/src/mame/intel/imm6_76.h +++ b/src/mame/intel/imm6_76.h @@ -152,8 +152,8 @@ public: intel_imm6_76_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock); // device_image_interface implementation - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; // device_image_interface static info diff --git a/src/mame/intel/rex6000.cpp b/src/mame/intel/rex6000.cpp index 8db67bc115d..b482b0ab26a 100644 --- a/src/mame/intel/rex6000.cpp +++ b/src/mame/intel/rex6000.cpp @@ -739,7 +739,7 @@ QUICKLOAD_LOAD_MEMBER(rex6000_state::quickload_rex6000) image.fread(&data[0], image.length()); if(strncmp((const char*)&data[0], magic, 21)) - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; img_start = strlen((const char*)&data[0]) + 5; img_start += 0xa0; //skip the icon (40x32 pixel) @@ -747,7 +747,7 @@ QUICKLOAD_LOAD_MEMBER(rex6000_state::quickload_rex6000) for (uint32_t i=0; iwrite_raw(i, data[img_start + i]); - return image_init_result::PASS; + return std::error_condition(); } int oz750_state::oz_wzd_extract_tag(const std::vector &data, const char *tag, char *dest_buf) @@ -795,7 +795,7 @@ QUICKLOAD_LOAD_MEMBER(oz750_state::quickload_oz750) oz_wzd_extract_tag(data, "", data_type); if (strcmp(data_type, "MY PROGRAMS")) - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; oz_wzd_extract_tag(data, "", app_name); oz_wzd_extract_tag(data, "<DATA>", file_name); @@ -805,7 +805,7 @@ QUICKLOAD_LOAD_MEMBER(oz750_state::quickload_oz750) uint32_t img_start = oz_wzd_extract_tag(data, "<BIN>", nullptr); if (img_start == 0) - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; uint16_t icon_size = data[img_start++]; @@ -845,7 +845,7 @@ QUICKLOAD_LOAD_MEMBER(oz750_state::quickload_oz750) for (int i=img_start; i<image.length(); i++) flash->write_byte(pos++, data[i]); // data - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/interton/vc4000.cpp b/src/mame/interton/vc4000.cpp index 4adf96c3718..f29f7da806e 100644 --- a/src/mame/interton/vc4000.cpp +++ b/src/mame/interton/vc4000.cpp @@ -403,14 +403,15 @@ QUICKLOAD_LOAD_MEMBER(vc4000_state::quickload_cb) int quick_length; std::vector<uint8_t> quick_data; int read_; - image_init_result result = image_init_result::FAIL; + std::error_condition result = image_error::UNSUPPORTED; quick_length = image.length(); quick_data.resize(quick_length); read_ = image.fread( &quick_data[0], quick_length); if (read_ != quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Cannot read the file"); + result = image_error::UNSPECIFIED; + osd_printf_error("%s: Cannot read the file\n", image.basename()); image.message(" Cannot read the file"); } else @@ -419,7 +420,8 @@ QUICKLOAD_LOAD_MEMBER(vc4000_state::quickload_cb) { if (quick_data[0] != 2) { - image.seterror(image_error::INVALIDIMAGE, "Invalid header"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Invalid header\n", image.basename()); image.message(" Invalid header"); } else @@ -429,13 +431,15 @@ QUICKLOAD_LOAD_MEMBER(vc4000_state::quickload_cb) if (quick_length < 0x5) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too short\n", image.basename()); image.message(" File too short"); } else if ((quick_length + quick_addr - 5) > 0x1600) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too long\n", image.basename()); image.message(" File too long"); } else @@ -451,7 +455,7 @@ QUICKLOAD_LOAD_MEMBER(vc4000_state::quickload_cb) // Start the quickload m_maincpu->set_state_int(S2650_PC, exec_addr); - result = image_init_result::PASS; + result = std::error_condition(); } } } @@ -460,7 +464,8 @@ QUICKLOAD_LOAD_MEMBER(vc4000_state::quickload_cb) { if (quick_data[0] != 0) { - image.seterror(image_error::INVALIDIMAGE, "Invalid header"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Invalid header\n", image.basename()); image.message(" Invalid header"); } else @@ -469,19 +474,22 @@ QUICKLOAD_LOAD_MEMBER(vc4000_state::quickload_cb) if (exec_addr >= quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Exec address beyond end of file"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Exec address beyond end of file\n", image.basename()); image.message(" Exec address beyond end of file"); } else if (quick_length < 0x904) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too short\n", image.basename()); image.message(" File too short"); } else if (quick_length > 0x2000) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too long\n", image.basename()); image.message(" File too long"); } else @@ -509,7 +517,7 @@ QUICKLOAD_LOAD_MEMBER(vc4000_state::quickload_cb) // Start the quickload m_maincpu->set_state_int(S2650_PC, exec_addr); - result = image_init_result::PASS; + result = std::error_condition(); } } } diff --git a/src/mame/kaypro/kaypro_m.cpp b/src/mame/kaypro/kaypro_m.cpp index 17045eda92c..743874d2ecc 100644 --- a/src/mame/kaypro/kaypro_m.cpp +++ b/src/mame/kaypro/kaypro_m.cpp @@ -273,10 +273,10 @@ QUICKLOAD_LOAD_MEMBER(kaypro_state::quickload_cb) /* Avoid loading a program if CP/M-80 is not in memory */ if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) - return image_init_result::FAIL; + return image_error::UNSUPPORTED; if (image.length() >= 0xfd00) - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; /* Load image to the TPA (Transient Program Area) */ u16 quickload_size = image.length(); @@ -284,7 +284,7 @@ QUICKLOAD_LOAD_MEMBER(kaypro_state::quickload_cb) { u8 data; if (image.fread( &data, 1) != 1) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; prog_space.write_byte(i+0x100, data); } @@ -293,5 +293,5 @@ QUICKLOAD_LOAD_MEMBER(kaypro_state::quickload_cb) m_maincpu->set_pc(0x100); // start program m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 300); // put the stack a bit before BDOS - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/leapfrog/leapfrog_iquest.cpp b/src/mame/leapfrog/leapfrog_iquest.cpp index 853cbe270ae..22ff5248d55 100644 --- a/src/mame/leapfrog/leapfrog_iquest.cpp +++ b/src/mame/leapfrog/leapfrog_iquest.cpp @@ -509,7 +509,7 @@ DEVICE_IMAGE_LOAD_MEMBER(leapfrog_iquest_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( leapfrog_iquest ) diff --git a/src/mame/leapfrog/leapfrog_leappad.cpp b/src/mame/leapfrog/leapfrog_leappad.cpp index 6990d1fd311..15ab6dd43c4 100644 --- a/src/mame/leapfrog/leapfrog_leappad.cpp +++ b/src/mame/leapfrog/leapfrog_leappad.cpp @@ -141,7 +141,7 @@ DEVICE_IMAGE_LOAD_MEMBER(leapfrog_leappad_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( leapfrog_leappad ) diff --git a/src/mame/leapfrog/leapfrog_leapster_explorer.cpp b/src/mame/leapfrog/leapfrog_leapster_explorer.cpp index 4acecc8896c..160e4da5e44 100644 --- a/src/mame/leapfrog/leapfrog_leapster_explorer.cpp +++ b/src/mame/leapfrog/leapfrog_leapster_explorer.cpp @@ -75,7 +75,7 @@ DEVICE_IMAGE_LOAD_MEMBER(leapfrog_leapster_explorer_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( leapfrog_leapster_explorer ) diff --git a/src/mame/leapfrog/leapster.cpp b/src/mame/leapfrog/leapster.cpp index b73e959cd6d..0c34e2a6849 100644 --- a/src/mame/leapfrog/leapster.cpp +++ b/src/mame/leapfrog/leapster.cpp @@ -428,7 +428,7 @@ DEVICE_IMAGE_LOAD_MEMBER( leapster_state::cart_load ) m_cart->rom_alloc(size, GENERIC_ROM32_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void leapster_state::machine_start() diff --git a/src/mame/luxor/abc80.cpp b/src/mame/luxor/abc80.cpp index 2f2fe5fc2af..66eb4a45d55 100644 --- a/src/mame/luxor/abc80.cpp +++ b/src/mame/luxor/abc80.cpp @@ -483,7 +483,7 @@ QUICKLOAD_LOAD_MEMBER(abc80_state::quickload_cb) space.write_byte(HEAD + 1, head >> 8); if (LOG) logerror("HEAD %04x\n",address); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/luxor/abc80x.cpp b/src/mame/luxor/abc80x.cpp index b2f974b966b..d219bab822a 100644 --- a/src/mame/luxor/abc80x.cpp +++ b/src/mame/luxor/abc80x.cpp @@ -2016,7 +2016,7 @@ QUICKLOAD_LOAD_MEMBER(abc800_state::quickload_cb) space.write_byte(0xff32, comcs & 0xff); space.write_byte(0xff33, comcs >> 8); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/matsushita/jr100.cpp b/src/mame/matsushita/jr100.cpp index a19c8fe71ab..6665c04199a 100644 --- a/src/mame/matsushita/jr100.cpp +++ b/src/mame/matsushita/jr100.cpp @@ -341,19 +341,19 @@ QUICKLOAD_LOAD_MEMBER(jr100_state::quickload_cb) int read_; quick_length = image.length(); if (quick_length >= 0xffff) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; read_ = image.fread(buf, quick_length); if (read_ != quick_length) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; if (buf[0]!=0x50 || buf[1]!=0x52 || buf[2]!=0x4F || buf[3]!=0x47) // this is not PRG - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; int pos = 4; if (readByLittleEndian(buf,pos)!=1) // not version 1 of PRG file - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; pos += 4; uint32_t len =readByLittleEndian(buf,pos); pos+= 4; @@ -380,7 +380,7 @@ QUICKLOAD_LOAD_MEMBER(jr100_state::quickload_cb) m_ram[13] = ((end_address + 3) & 0xFF); } - return image_init_result::PASS; + return std::error_condition(); } void jr100_state::jr100(machine_config &config) diff --git a/src/mame/mchester/ssem.cpp b/src/mame/mchester/ssem.cpp index ada168260a7..0e5272eb6f2 100644 --- a/src/mame/mchester/ssem.cpp +++ b/src/mame/mchester/ssem.cpp @@ -556,7 +556,7 @@ QUICKLOAD_LOAD_MEMBER(ssem_state::quickload_cb) if (image_line.empty()) { image.message("No data in line 1"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } sscanf(image_line.c_str(), "%d", &num_lines); //num_lines = std::stoul(image_line); @@ -564,7 +564,7 @@ QUICKLOAD_LOAD_MEMBER(ssem_state::quickload_cb) if (num_lines < 1) { image.message("No data to process"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } for (u32 i = 0; i < num_lines; i++) @@ -576,7 +576,7 @@ QUICKLOAD_LOAD_MEMBER(ssem_state::quickload_cb) if (length < 8) { image.message("Bad data (%s) in line %d",image_line.c_str(),i+2); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } // Isolate and convert 4-digit decimal address @@ -588,7 +588,7 @@ QUICKLOAD_LOAD_MEMBER(ssem_state::quickload_cb) if (length < 37) { image.message("Bad data (%s) in line %d",image_line.c_str(),i+2); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } // Parse a line such as: 0000:00000110101001000100000100000100 @@ -646,7 +646,7 @@ QUICKLOAD_LOAD_MEMBER(ssem_state::quickload_cb) space.write_byte((line << 2) + 3, BIT(word, 0, 8)); } - return image_init_result::PASS; + return std::error_condition(); } /****************************************************\ diff --git a/src/mame/memotech/mtx_m.cpp b/src/mame/memotech/mtx_m.cpp index 1de6bc7b0df..76c7b6f0a0f 100644 --- a/src/mame/memotech/mtx_m.cpp +++ b/src/mame/memotech/mtx_m.cpp @@ -403,14 +403,14 @@ DEVICE_IMAGE_LOAD_MEMBER( mtx_state::extrom_load ) if (size > 0x80000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported rom size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported rom size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_extrom->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_extrom->common_load_rom(m_extrom->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } /*************************************************************************** @@ -425,29 +425,26 @@ SNAPSHOT_LOAD_MEMBER(mtx_state::snapshot_cb) if (length < 18) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); - return image_init_result::FAIL; + osd_printf_error("%s: File too short\n", image.basename()); + return image_error::INVALIDLENGTH; } if (length >= 0x10000 - 0x4000 + 18) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); - return image_init_result::FAIL; + osd_printf_error("%s: File too long\n", image.basename()); + return image_error::INVALIDLENGTH; } auto data = std::make_unique<uint8_t []>(length); if (image.fread(data.get(), length) != length) { - image.seterror(image_error::UNSPECIFIED, "Error reading file"); - return image_init_result::FAIL; + osd_printf_error("%s: Error reading file\n", image.basename()); + return image_error::UNSPECIFIED; } // verify first byte if (data[0] != 0xff) - { - image.seterror(image_error::INVALIDIMAGE, nullptr); - return image_init_result::FAIL; - } + return image_error::INVALIDIMAGE; // get tape name char tape_name[16]; @@ -480,7 +477,7 @@ SNAPSHOT_LOAD_MEMBER(mtx_state::snapshot_cb) logerror("snapshot name = '%s', system_size = 0x%04x, data_size = 0x%04x\n", tape_name, system_variables_size, data_size); - return image_init_result::PASS; + return std::error_condition(); } /*************************************************************************** @@ -493,21 +490,21 @@ QUICKLOAD_LOAD_MEMBER(mtx_state::quickload_cb) if (length < 4) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); - return image_init_result::FAIL; + osd_printf_error("%s: File too short\n", image.basename()); + return image_error::INVALIDLENGTH; } if (length >= 0x10000 - 0x4000 + 4) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); - return image_init_result::FAIL; + osd_printf_error("%s: File too long\n", image.basename()); + return image_error::INVALIDLENGTH; } auto data = std::make_unique<uint8_t []>(length); if (image.fread(data.get(), length) != length) { - image.seterror(image_error::UNSPECIFIED, "Error reading file"); - return image_init_result::FAIL; + osd_printf_error("%s: Error reading file\n", image.basename()); + return image_error::UNSPECIFIED; } uint16_t code_base = pick_integer_le(data.get(), 0, 2); @@ -515,14 +512,14 @@ QUICKLOAD_LOAD_MEMBER(mtx_state::quickload_cb) if (length < code_length) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); - return image_init_result::FAIL; + osd_printf_error("%s: File too short\n", image.basename()); + return image_error::INVALIDIMAGE; } if (code_base < 0x4000 || (code_base + code_length) >= 0x10000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid code base and length"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid code base and length\n", image.basename()); + return image_error::INVALIDIMAGE; } // reset memory map @@ -535,7 +532,7 @@ QUICKLOAD_LOAD_MEMBER(mtx_state::quickload_cb) m_maincpu->set_pc(code_base); - return image_init_result::PASS; + return std::error_condition(); } /*************************************************************************** diff --git a/src/mame/microkey/primo_m.cpp b/src/mame/microkey/primo_m.cpp index 908aec94374..8fb72d18e8d 100644 --- a/src/mame/microkey/primo_m.cpp +++ b/src/mame/microkey/primo_m.cpp @@ -287,17 +287,17 @@ SNAPSHOT_LOAD_MEMBER(primo_state::snapshot_cb) if (image.fread(&snapshot_data[0], image.length()) != image.length()) { - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } if (strncmp((char *)&snapshot_data[0], "PS01", 4)) { - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } setup_pss(&snapshot_data[0], image.length()); - return image_init_result::PASS; + return std::error_condition(); } /******************************************************************************* @@ -327,12 +327,12 @@ QUICKLOAD_LOAD_MEMBER(primo_state::quickload_cb) if (image.fread(&quickload_data[0], quickload_size) != quickload_size) { - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } setup_pp(&quickload_data[0], quickload_size); - return image_init_result::PASS; + return std::error_condition(); } u32 primo_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) diff --git a/src/mame/miltonbradley/microvsn.cpp b/src/mame/miltonbradley/microvsn.cpp index d562095d656..42bcc8bd2c1 100644 --- a/src/mame/miltonbradley/microvsn.cpp +++ b/src/mame/miltonbradley/microvsn.cpp @@ -191,8 +191,8 @@ DEVICE_IMAGE_LOAD_MEMBER(microvision_state::cart_load) if (size != 0x400 && size != 0x800) { - image.seterror(image_error::INVALIDIMAGE, "Invalid ROM file size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid ROM file size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -236,7 +236,7 @@ DEVICE_IMAGE_LOAD_MEMBER(microvision_state::cart_load) m_tms1100->set_clock(clock); } - return image_init_result::PASS; + return std::error_condition(); } void microvision_state::apply_settings() diff --git a/src/mame/misc/mtu130.cpp b/src/mame/misc/mtu130.cpp index 47a4a27ad79..b24b260b866 100644 --- a/src/mame/misc/mtu130.cpp +++ b/src/mame/misc/mtu130.cpp @@ -54,7 +54,7 @@ public: protected: virtual void device_start() override; - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; private: @@ -237,11 +237,11 @@ void mtu130_rom_device::device_start() memset(m_romdata + m_load_offset, 0xff, 4096); } -image_init_result mtu130_rom_device::call_load() +std::error_condition mtu130_rom_device::call_load() { u32 len = !loaded_through_softlist() ? length() : get_software_region_length("rom"); if(!len || len > 4096 || (4096 % len)) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; if (!loaded_through_softlist()) fread(m_romdata + m_load_offset, len); @@ -256,7 +256,7 @@ image_init_result mtu130_rom_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } void mtu130_rom_device::call_unload() diff --git a/src/mame/mit/tx0.cpp b/src/mame/mit/tx0.cpp index 89362ffbea7..06e8ccf17bf 100644 --- a/src/mame/mit/tx0.cpp +++ b/src/mame/mit/tx0.cpp @@ -369,7 +369,7 @@ public: // image-level overrides virtual const char *file_extensions() const noexcept override { return "tap,rim"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual const char *image_interface() const noexcept override { return "tx0_ptp"; } @@ -398,8 +398,8 @@ public: // image-level overrides virtual const char *file_extensions() const noexcept override { return "tap,rim"; } - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_load() override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; protected: @@ -436,7 +436,7 @@ public: virtual const char *image_type_name() const noexcept override { return "printout"; } virtual const char *image_brief_type_name() const noexcept override { return "prin"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; protected: @@ -465,7 +465,7 @@ public: // image-level overrides virtual const char *file_extensions() const noexcept override { return "tap"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; protected: @@ -489,7 +489,7 @@ tx0_magtape_image_device::tx0_magtape_image_device(const machine_config &mconfig unit 0 is reader (read-only), unit 1 is puncher (write-only) */ -image_init_result tx0_readtape_image_device::call_load() +std::error_condition tx0_readtape_image_device::call_load() { if (m_tx0) { @@ -518,7 +518,7 @@ image_init_result tx0_readtape_image_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } void tx0_readtape_image_device::call_unload() @@ -630,16 +630,16 @@ TIMER_CALLBACK_MEMBER(tx0_state::reader_callback) /* timer callback to generate punch completion pulse */ -image_init_result tx0_punchtape_image_device::call_load() +std::error_condition tx0_punchtape_image_device::call_load() { /* punch unit */ if (m_tx0) m_tx0->m_tape_puncher.fd = this; - return image_init_result::PASS; + return std::error_condition(); } -image_init_result tx0_punchtape_image_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition tx0_punchtape_image_device::call_create(int format_type, util::option_resolution *format_options) { return call_load(); } @@ -713,13 +713,13 @@ WRITE_LINE_MEMBER( tx0_state::tx0_io_p7h ) /* Open a file for typewriter output */ -image_init_result tx0_printer_image_device::call_load() +std::error_condition tx0_printer_image_device::call_load() { /* open file */ if (m_tx0) m_tx0->m_typewriter.fd = this; - return image_init_result::PASS; + return std::error_condition(); } void tx0_printer_image_device::call_unload() @@ -852,7 +852,7 @@ void tx0_magtape_image_device::device_start() /* Open a magnetic tape image */ -image_init_result tx0_magtape_image_device::call_load() +std::error_condition tx0_magtape_image_device::call_load() { if (m_tx0) { @@ -871,7 +871,7 @@ image_init_result tx0_magtape_image_device::call_load() } } - return image_init_result::PASS; + return std::error_condition(); } void tx0_magtape_image_device::call_unload() diff --git a/src/mame/mits/altair.cpp b/src/mame/mits/altair.cpp index 4254598a72a..65c5e417720 100644 --- a/src/mame/mits/altair.cpp +++ b/src/mame/mits/altair.cpp @@ -100,12 +100,12 @@ QUICKLOAD_LOAD_MEMBER(altair_state::quickload_cb) int read_; quick_length = image.length(); if (quick_length >= 0xfd00) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; read_ = image.fread(m_ram, quick_length); if (read_ != quick_length) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; - return image_init_result::PASS; + return std::error_condition(); } void altair_state::machine_reset() diff --git a/src/mame/motorola/m68705prg.cpp b/src/mame/motorola/m68705prg.cpp index 96e09fdb913..2c28364638d 100644 --- a/src/mame/motorola/m68705prg.cpp +++ b/src/mame/motorola/m68705prg.cpp @@ -62,14 +62,14 @@ protected: auto const actual(m_eprom_image->common_get_size("rom")); if (desired > actual) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported EPROM size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported EPROM size\n", image.basename()); + return image_error::INVALIDLENGTH; } else { m_eprom_image->rom_alloc(desired, GENERIC_ROM8_WIDTH, ENDIANNESS_BIG); m_eprom_image->common_load_rom(m_eprom_image->get_rom_base(), desired, "rom"); - return image_init_result::PASS; + return std::error_condition(); } } @@ -79,13 +79,13 @@ protected: auto const actual(m_mcu_image->common_get_size("rom")); if (desired != actual) { - image.seterror(image_error::INVALIDIMAGE, "Incorrect internal MCU EPROM size"); - return image_init_result::FAIL; + osd_printf_error("%s: Incorrect internal MCU EPROM size\n", image.basename()); + return image_error::INVALIDLENGTH; } else { m_mcu_image->common_load_rom(&m_mcu_region[0], actual, "rom"); - return image_init_result::PASS; + return std::error_condition(); } } diff --git a/src/mame/motorola/mekd2.cpp b/src/mame/motorola/mekd2.cpp index ce80de0f710..0e5a839f480 100644 --- a/src/mame/motorola/mekd2.cpp +++ b/src/mame/motorola/mekd2.cpp @@ -305,7 +305,7 @@ QUICKLOAD_LOAD_MEMBER(mekd2_state::quickload_cb) if (memcmp(buff, magic, sizeof (buff))) { logerror("mekd2 rom load: magic '%s' not found\n", magic); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } image.fread(&addr, 2); addr = little_endianize_int16(addr); @@ -316,7 +316,7 @@ QUICKLOAD_LOAD_MEMBER(mekd2_state::quickload_cb) while (size-- > 0) image.fread(&RAM[addr++], 1); - return image_init_result::PASS; + return std::error_condition(); } TIMER_DEVICE_CALLBACK_MEMBER(mekd2_state::kansas_w) diff --git a/src/mame/nascom/nascom1.cpp b/src/mame/nascom/nascom1.cpp index 8c7cd0a940b..da1e3f3a200 100644 --- a/src/mame/nascom/nascom1.cpp +++ b/src/mame/nascom/nascom1.cpp @@ -152,7 +152,7 @@ private: DECLARE_WRITE_LINE_MEMBER(ram_disable_cpm_w); uint32_t screen_update_nascom(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - image_init_result load_cart(device_image_interface &image, generic_slot_device *slot, int slot_id); + std::error_condition load_cart(device_image_interface &image, generic_slot_device *slot, int slot_id); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(socket1_load) { return load_cart(image, m_socket1, 1); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(socket2_load) { return load_cart(image, m_socket2, 2); } @@ -343,8 +343,8 @@ SNAPSHOT_LOAD_MEMBER(nascom_state::snapshot_cb) } else { - image.seterror(image_error::INVALIDIMAGE, "Unsupported file format"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported file format\n", image.basename()); + return image_error::INVALIDIMAGE; } dummy = 0x00; while (!image.image_feof() && dummy != 0x0a && dummy != 0x1f) @@ -353,7 +353,7 @@ SNAPSHOT_LOAD_MEMBER(nascom_state::snapshot_cb) } } - return image_init_result::PASS; + return std::error_condition(); } @@ -361,15 +361,15 @@ SNAPSHOT_LOAD_MEMBER(nascom_state::snapshot_cb) // SOCKETS //************************************************************************** -image_init_result nascom2_state::load_cart(device_image_interface &image, generic_slot_device *slot, int slot_id) +std::error_condition nascom2_state::load_cart(device_image_interface &image, generic_slot_device *slot, int slot_id) { // loading directly from file if (!image.loaded_through_softlist()) { if (slot->length() > 0x1000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported file size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported file size\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(slot->length(), GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -413,7 +413,7 @@ image_init_result nascom2_state::load_cart(device_image_interface &image, generi } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/neogeo/ng_memcard.cpp b/src/mame/neogeo/ng_memcard.cpp index c82549cba7c..861ccd8adf6 100644 --- a/src/mame/neogeo/ng_memcard.cpp +++ b/src/mame/neogeo/ng_memcard.cpp @@ -42,17 +42,17 @@ void ng_memcard_device::device_start() with the given index -------------------------------------------------*/ -image_init_result ng_memcard_device::call_load() +std::error_condition ng_memcard_device::call_load() { if(length() != 0x800) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; fseek(0, SEEK_SET); size_t ret = fread(m_memcard_data, 0x800); if(ret != 0x800) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; - return image_init_result::PASS; + return std::error_condition(); } void ng_memcard_device::call_unload() @@ -61,15 +61,15 @@ void ng_memcard_device::call_unload() fwrite(m_memcard_data, 0x800); } -image_init_result ng_memcard_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition ng_memcard_device::call_create(int format_type, util::option_resolution *format_options) { memset(m_memcard_data, 0, 0x800); size_t ret = fwrite(m_memcard_data, 0x800); if(ret != 0x800) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/neogeo/ng_memcard.h b/src/mame/neogeo/ng_memcard.h index 32d6a93a9dc..77cafd221e1 100644 --- a/src/mame/neogeo/ng_memcard.h +++ b/src/mame/neogeo/ng_memcard.h @@ -27,9 +27,9 @@ public: virtual bool is_reset_on_load() const noexcept override { return false; } virtual const char *file_extensions() const noexcept override { return "neo"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; // bus interface uint8_t read(offs_t offset); diff --git a/src/mame/netronics/elf.cpp b/src/mame/netronics/elf.cpp index dad9f1667f6..0b70008c0d6 100644 --- a/src/mame/netronics/elf.cpp +++ b/src/mame/netronics/elf.cpp @@ -227,12 +227,12 @@ QUICKLOAD_LOAD_MEMBER(elf2_state::quickload_cb) if (size > m_ram->size()) { - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } image.fread(m_ram->pointer(), size); - return image_init_result::PASS; + return std::error_condition(); } void elf2_state::elf2(machine_config &config) diff --git a/src/mame/nichibutsu/myvision.cpp b/src/mame/nichibutsu/myvision.cpp index 61d9927dc8d..c05a73ba8e8 100644 --- a/src/mame/nichibutsu/myvision.cpp +++ b/src/mame/nichibutsu/myvision.cpp @@ -160,14 +160,14 @@ DEVICE_IMAGE_LOAD_MEMBER( myvision_state::cart_load ) if (size != 0x4000 && size != 0x6000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/nintendo/n64.cpp b/src/mame/nintendo/n64.cpp index 480b42e4902..ab619db63a4 100644 --- a/src/mame/nintendo/n64.cpp +++ b/src/mame/nintendo/n64.cpp @@ -39,7 +39,7 @@ private: INTERRUPT_GEN_MEMBER(n64_reset_poll); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart_load); void mempak_format(uint8_t* pak); - image_init_result disk_load(device_image_interface &image); + std::error_condition disk_load(device_image_interface &image); void disk_unload(device_image_interface &image); void n64_map(address_map &map); void n64dd_map(address_map &map); @@ -378,7 +378,7 @@ DEVICE_IMAGE_LOAD_MEMBER(n64_mess_state::cart_load) mempak_format(m_rcp_periphs->m_save_data.mempak[1]); } - return image_init_result::PASS; + return std::error_condition(); } MACHINE_START_MEMBER(n64_mess_state,n64dd) @@ -400,12 +400,12 @@ MACHINE_START_MEMBER(n64_mess_state,n64dd) } } -image_init_result n64_mess_state::disk_load(device_image_interface &image) +std::error_condition n64_mess_state::disk_load(device_image_interface &image) { image.fseek(0, SEEK_SET); image.fread(memregion("disk")->base(), image.length()); m_rcp_periphs->disk_present = true; - return image_init_result::PASS; + return std::error_condition(); } void n64_mess_state::disk_unload(device_image_interface &image) diff --git a/src/mame/nintendo/nes_vt09.cpp b/src/mame/nintendo/nes_vt09.cpp index e12ca16de5b..796c033f804 100644 --- a/src/mame/nintendo/nes_vt09.cpp +++ b/src/mame/nintendo/nes_vt09.cpp @@ -161,7 +161,7 @@ DEVICE_IMAGE_LOAD_MEMBER(nes_vt09_cart_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/nintendo/pokemini.cpp b/src/mame/nintendo/pokemini.cpp index e4ee6ef8bd6..240f843cdb5 100644 --- a/src/mame/nintendo/pokemini.cpp +++ b/src/mame/nintendo/pokemini.cpp @@ -1502,21 +1502,21 @@ DEVICE_IMAGE_LOAD_MEMBER( pokemini_state::cart_load ) /* Verify that the image is big enough */ if (size <= 0x2100) { - image.seterror(image_error::INVALIDIMAGE, "Invalid ROM image: ROM image is too small"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid ROM image: ROM image is too small\n", image.basename()); + return image_error::INVALIDLENGTH; } /* Verify that the image is not too big */ if (size > 0x1fffff) { - image.seterror(image_error::INVALIDIMAGE, "Invalid ROM image: ROM image is too big"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid ROM image: ROM image is too big\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/pc/ibmpcjr.cpp b/src/mame/pc/ibmpcjr.cpp index 847c70feb10..e57502b4698 100644 --- a/src/mame/pc/ibmpcjr.cpp +++ b/src/mame/pc/ibmpcjr.cpp @@ -89,7 +89,7 @@ private: void pcjx_port_1ff_w(uint8_t data); void pcjx_set_bank(int unk1, int unk2, int unk3); - image_init_result load_cart(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_cart(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart1_load) { return load_cart(image, m_cart1); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart2_load) { return load_cart(image, m_cart2); } void pc_speaker_set_spkrdata(uint8_t data); @@ -446,7 +446,7 @@ uint8_t pcjr_state::pcjx_port_1ff_r() return 0x60; // expansion? } -image_init_result pcjr_state::load_cart(device_image_interface &image, generic_slot_device *slot) +std::error_condition pcjr_state::load_cart(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); bool imagic_hack = false; @@ -465,8 +465,8 @@ image_init_result pcjr_state::load_cart(device_image_interface &image, generic_s header_size = 0x200; break; default: - image.seterror(image_error::INVALIDIMAGE, "Invalid header size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid header size\n", image.basename()); + return image_error::INVALIDIMAGE; } if (size - header_size == 0xa000) { @@ -497,7 +497,7 @@ image_init_result pcjr_state::load_cart(device_image_interface &image, generic_s memcpy(ROM + 0x4000, ROM, 0x2000); memcpy(ROM + 0x2000, ROM, 0x2000); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/pce/tourvis.cpp b/src/mame/pce/tourvis.cpp index c7f8793c74e..aa59086ce77 100644 --- a/src/mame/pce/tourvis.cpp +++ b/src/mame/pce/tourvis.cpp @@ -265,7 +265,7 @@ DEVICE_IMAGE_LOAD_MEMBER( tourvision_state::cart_load ) } #endif - return image_init_result::PASS; + return std::error_condition(); } // Note from system11: This system actually supports 2 players diff --git a/src/mame/pitronics/beta.cpp b/src/mame/pitronics/beta.cpp index 5bdd1c47e0c..3412df75fcc 100644 --- a/src/mame/pitronics/beta.cpp +++ b/src/mame/pitronics/beta.cpp @@ -300,14 +300,14 @@ DEVICE_IMAGE_LOAD_MEMBER(beta_state::load_beta_eprom) if (size != 0x800) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_eprom->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_eprom->common_load_rom(m_eprom->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } DEVICE_IMAGE_UNLOAD_MEMBER(beta_state::unload_beta_eprom) diff --git a/src/mame/poly88/poly88_m.cpp b/src/mame/poly88/poly88_m.cpp index 37d4eb6a4bc..77060425046 100644 --- a/src/mame/poly88/poly88_m.cpp +++ b/src/mame/poly88/poly88_m.cpp @@ -310,5 +310,5 @@ SNAPSHOT_LOAD_MEMBER(poly88_state::snapshot_cb) pos+=recordLen; } m_usart->reset(); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/psion/psion_pack.cpp b/src/mame/psion/psion_pack.cpp index 104da5ceae9..bf046f1f32c 100644 --- a/src/mame/psion/psion_pack.cpp +++ b/src/mame/psion/psion_pack.cpp @@ -267,7 +267,7 @@ void datapack_device::control_w(uint8_t data) DEVICE_IMAGE_LOAD( datapack ) -------------------------------------------------*/ -image_init_result datapack_device::call_load() +std::error_condition datapack_device::call_load() { uint8_t data[0x10]; @@ -275,13 +275,13 @@ image_init_result datapack_device::call_load() // check the OPK head if(strncmp((const char*)data, "OPK", 3)) - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; // get datapack ID and size m_id = data[OPK_HEAD_SIZE + 0]; m_size = data[OPK_HEAD_SIZE + 1]; - return image_init_result::PASS; + return std::error_condition(); } @@ -289,7 +289,7 @@ image_init_result datapack_device::call_load() DEVICE_IMAGE_CREATE( datapack ) -------------------------------------------------*/ -image_init_result datapack_device::call_create(int format_type, util::option_resolution *create_args) +std::error_condition datapack_device::call_create(int format_type, util::option_resolution *create_args) { static const uint8_t opk_head[6] = {'O', 'P', 'K', 0x00, 0x00, 0x00}; @@ -314,7 +314,7 @@ image_init_result datapack_device::call_create(int format_type, util::option_res fwrite(&m_id, 1); fwrite(&m_size, 1); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/psion/psion_pack.h b/src/mame/psion/psion_pack.h index a00a3ceac7f..0f63de1c146 100644 --- a/src/mame/psion/psion_pack.h +++ b/src/mame/psion/psion_pack.h @@ -27,9 +27,9 @@ public: virtual ~datapack_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; - virtual image_init_result call_create(int format_type, util::option_resolution *create_args) override; + virtual std::error_condition call_create(int format_type, util::option_resolution *create_args) override; virtual bool is_reset_on_load() const noexcept override { return false; } virtual const char *image_interface() const noexcept override { return "psion_pack"; } diff --git a/src/mame/psion/psion_ssd.cpp b/src/mame/psion/psion_ssd.cpp index ab59d210f5b..bf1857828af 100644 --- a/src/mame/psion/psion_ssd.cpp +++ b/src/mame/psion/psion_ssd.cpp @@ -169,7 +169,7 @@ TIMER_CALLBACK_MEMBER(psion_ssd_device::close_door) } -image_init_result psion_ssd_device::call_load() +std::error_condition psion_ssd_device::call_load() { device_image_interface *image = nullptr; interface(image); @@ -178,8 +178,8 @@ image_init_result psion_ssd_device::call_load() if (size < 0x10000 || size > 0x800000 || (size & (size - 1)) != 0) { - image->seterror(image_error::INVALIDIMAGE, "Invalid size, must be 64K, 128K, 256K, 512K, 1M, 2M, 4M, 8M"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size, must be 64K, 128K, 256K, 512K, 1M, 2M, 4M, 8M\n", image->basename()); + return image_error::INVALIDLENGTH; } image->fread(m_ssd_data.get(), size); @@ -196,7 +196,7 @@ image_init_result psion_ssd_device::call_load() // setup the timer to close the door m_door_timer->adjust(attotime::from_msec(200)); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/psion/psion_ssd.h b/src/mame/psion/psion_ssd.h index c7df0b8f033..d1def9f2508 100644 --- a/src/mame/psion/psion_ssd.h +++ b/src/mame/psion/psion_ssd.h @@ -41,7 +41,7 @@ protected: virtual void device_add_mconfig(machine_config &config) override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_reset_on_load() const noexcept override { return false; } diff --git a/src/mame/rca/studio2.cpp b/src/mame/rca/studio2.cpp index e8f73f478b3..935dcf879d2 100644 --- a/src/mame/rca/studio2.cpp +++ b/src/mame/rca/studio2.cpp @@ -606,8 +606,8 @@ DEVICE_IMAGE_LOAD_MEMBER( studio2_state::cart_load ) if (image.length() < 0x200) { - image.seterror(image_error::INVALIDIMAGE, "Invalid ROM file"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid ROM file\n", image.basename()); + return image_error::INVALIDLENGTH; } image.fread(&header, 0x100); @@ -615,15 +615,15 @@ DEVICE_IMAGE_LOAD_MEMBER( studio2_state::cart_load ) // validate if (strncmp((const char *)header, "RCA2", 4)) { - image.seterror(image_error::INVALIDIMAGE, "Not an .ST2 file"); - return image_init_result::FAIL; + osd_printf_error("%s: Not an .ST2 file\n", image.basename()); + return image_error::INVALIDIMAGE; } blocks = header[4]; if ((blocks < 2) || (blocks > 11)) { - image.seterror(image_error::INVALIDIMAGE, "Invalid .ST2 file"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid .ST2 file\n", image.basename()); + return image_error::INVALIDIMAGE; } if (image.length() != (blocks << 8)) @@ -656,8 +656,8 @@ DEVICE_IMAGE_LOAD_MEMBER( studio2_state::cart_load ) size = image.length(); if (size > 0x400) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDIMAGE; } else image.fread(m_cart->get_rom_base(), size); @@ -675,7 +675,7 @@ DEVICE_IMAGE_LOAD_MEMBER( studio2_state::cart_load ) } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/rca/vip.cpp b/src/mame/rca/vip.cpp index 30a32c79ce7..a05463073ff 100644 --- a/src/mame/rca/vip.cpp +++ b/src/mame/rca/vip.cpp @@ -688,7 +688,7 @@ QUICKLOAD_LOAD_MEMBER(vip_state::quickload_cb) if ((size + chip8_size) > m_ram->size()) { - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } if (chip8_size > 0) @@ -700,7 +700,7 @@ QUICKLOAD_LOAD_MEMBER(vip_state::quickload_cb) /* load image to RAM */ image.fread(ram + chip8_size, size); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/robotron/z1013.cpp b/src/mame/robotron/z1013.cpp index c58e5719474..bd37a8c9448 100644 --- a/src/mame/robotron/z1013.cpp +++ b/src/mame/robotron/z1013.cpp @@ -417,9 +417,9 @@ SNAPSHOT_LOAD_MEMBER(z1013_state::snapshot_cb) { } else { - image.seterror(image_error::INVALIDIMAGE, "Not a Z1013 image"); + osd_printf_error("%s: Not a Z1013 image\n", image.basename()); image.message(" Not a Z1013 image"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } memcpy (m_maincpu->space(AS_PROGRAM).get_read_ptr(startaddr), @@ -429,11 +429,11 @@ SNAPSHOT_LOAD_MEMBER(z1013_state::snapshot_cb) m_maincpu->set_state_int(Z80_PC, runaddr); else { - image.seterror(image_error::INVALIDIMAGE, "Loaded but cannot run"); + osd_printf_error("%s: Loaded but cannot run\n", image.basename()); image.message(" Loaded but cannot run"); } - return image_init_result::PASS; + return std::error_condition(); } /* F4 Character Displayer */ diff --git a/src/mame/rockwell/aim65.cpp b/src/mame/rockwell/aim65.cpp index b3f158e8a1f..bbaff225e1a 100644 --- a/src/mame/rockwell/aim65.cpp +++ b/src/mame/rockwell/aim65.cpp @@ -178,29 +178,28 @@ void aim65_state::aim65_palette(palette_device &palette) const MACHINE DRIVERS ***************************************************************************/ -image_init_result aim65_state::load_cart(device_image_interface &image, generic_slot_device *slot, const char *slot_tag) +std::error_condition aim65_state::load_cart(device_image_interface &image, generic_slot_device *slot, const char *slot_tag) { uint32_t size = slot->common_get_size(slot_tag); if (size > 0x1000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported ROM size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported ROM size\n", image.basename()); + return image_error::INVALIDLENGTH; } if (image.loaded_through_softlist() && image.get_software_region(slot_tag) == nullptr) { - std::string errmsg = string_format( - "Attempted to load file with wrong extension\nSocket '%s' only accepts files with '.%s' extension", + osd_printf_error( + "Attempted to load file with wrong extension\nSocket '%s' only accepts files with '.%s' extension\n", slot_tag, slot_tag); - image.seterror(image_error::INVALIDIMAGE, errmsg.c_str()); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); slot->common_load_rom(slot->get_rom_base(), size, slot_tag); - return image_init_result::PASS; + return std::error_condition(); } // TTY terminal settings. To use, turn KB/TTY switch to TTY, reset, press DEL. All input to be in UPPERCASE. diff --git a/src/mame/rockwell/aim65.h b/src/mame/rockwell/aim65.h index 14907a10ee9..ea207c4e536 100644 --- a/src/mame/rockwell/aim65.h +++ b/src/mame/rockwell/aim65.h @@ -92,7 +92,7 @@ private: TIMER_CALLBACK_MEMBER(printer_timer); uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - image_init_result load_cart(device_image_interface &image, generic_slot_device *slot, const char *slot_tag); + std::error_condition load_cart(device_image_interface &image, generic_slot_device *slot, const char *slot_tag); void mem_map(address_map &map); diff --git a/src/mame/roland/roland_cm32p.cpp b/src/mame/roland/roland_cm32p.cpp index c664bc8ce28..8d216229fdb 100644 --- a/src/mame/roland/roland_cm32p.cpp +++ b/src/mame/roland/roland_cm32p.cpp @@ -429,8 +429,8 @@ DEVICE_IMAGE_LOAD_MEMBER(cm32p_state::card_load) uint32_t size = pcmcard->common_get_size("rom"); if (size > 0x080000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only up to 512K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only up to 512K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } pcmcard->rom_alloc(0x080000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); // cards are up to 512K @@ -452,7 +452,7 @@ DEVICE_IMAGE_LOAD_MEMBER(cm32p_state::card_load) descramble_rom_external(&dst[0x080000], &src[0x080000]); pcmard_loaded = true; - return image_init_result::PASS; + return std::error_condition(); } DEVICE_IMAGE_UNLOAD_MEMBER(cm32p_state::card_unload) diff --git a/src/mame/roland/roland_r8.cpp b/src/mame/roland/roland_r8.cpp index 55925622f47..edb0cbf4eca 100644 --- a/src/mame/roland/roland_r8.cpp +++ b/src/mame/roland/roland_r8.cpp @@ -118,7 +118,7 @@ protected: void mk1_map(address_map &map); void mk2_map(address_map &map); - image_init_result pcmrom_load(generic_slot_device* pcmcard, int card_id, device_image_interface &image); + std::error_condition pcmrom_load(generic_slot_device* pcmcard, int card_id, device_image_interface &image); void pcmrom_unload(int card_id); void descramble_rom_external(u8* dst, const u8* src); @@ -186,13 +186,13 @@ private: }; -image_init_result roland_r8_base_state::pcmrom_load(generic_slot_device *pcmcard, int card_id, device_image_interface &image) +std::error_condition roland_r8_base_state::pcmrom_load(generic_slot_device *pcmcard, int card_id, device_image_interface &image) { uint32_t size = pcmcard->common_get_size("rom"); if (size > PCMCARD_SIZE) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only up to 512K is supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size: Only up to 512K is supported\n", image.basename()); + return image_error::INVALIDLENGTH; } pcmcard->rom_alloc(PCMCARD_SIZE, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -215,7 +215,7 @@ image_init_result roland_r8_base_state::pcmrom_load(generic_slot_device *pcmcard descramble_rom_external(&dst[pcm_addr], &src[pcm_addr]); //pcmard_loaded[card_id] = true; - return image_init_result::PASS; + return std::error_condition(); } void roland_r8_base_state::pcmrom_unload(int card_id) diff --git a/src/mame/roland/roland_tnsc1.cpp b/src/mame/roland/roland_tnsc1.cpp index d501d7afaf8..18d45b87f89 100644 --- a/src/mame/roland/roland_tnsc1.cpp +++ b/src/mame/roland/roland_tnsc1.cpp @@ -52,7 +52,7 @@ DEVICE_IMAGE_LOAD_MEMBER(rlndtnsc1_state::cart_load) uint32_t size = m_cart->common_get_size("rom"); m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void rlndtnsc1_state::rlndtnsc1(machine_config &config) diff --git a/src/mame/sega/mdconsole.cpp b/src/mame/sega/mdconsole.cpp index 6024b5dca25..349409ae186 100644 --- a/src/mame/sega/mdconsole.cpp +++ b/src/mame/sega/mdconsole.cpp @@ -423,7 +423,7 @@ DEVICE_IMAGE_LOAD_MEMBER( md_cons_state::_32x_cart ) for (i = 0x00; i < length; i += 2) ROM16[i / 2] = pick_integer_be(&temp_copy[0], i, 2); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/sega/megatech.cpp b/src/mame/sega/megatech.cpp index 70b13811916..631309fbefb 100644 --- a/src/mame/sega/megatech.cpp +++ b/src/mame/sega/megatech.cpp @@ -146,7 +146,7 @@ private: uint8_t sms_ioport_dd_r(); void mt_sms_standard_rom_bank_w(address_space &space, offs_t offset, uint8_t data); - image_init_result load_cart(device_image_interface &image, generic_slot_device *slot, int gameno); + std::error_condition load_cart(device_image_interface &image, generic_slot_device *slot, int gameno); DECLARE_DEVICE_IMAGE_LOAD_MEMBER( mt_cart1 ) { return load_cart(image, m_cart1, 0); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER( mt_cart2 ) { return load_cart(image, m_cart2, 1); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER( mt_cart3 ) { return load_cart(image, m_cart3, 2); } @@ -749,21 +749,21 @@ void mtech_state::megatech(machine_config &config) } -image_init_result mtech_state::load_cart(device_image_interface &image, generic_slot_device *slot, int gameno) +std::error_condition mtech_state::load_cart(device_image_interface &image, generic_slot_device *slot, int gameno) { uint8_t *ROM; const char *pcb_name; uint32_t size = slot->common_get_size("rom"); if (!image.loaded_through_softlist()) - return image_init_result::FAIL; + return image_error::UNSUPPORTED; slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); ROM = slot->get_rom_base(); memcpy(ROM, image.get_software_region("rom"), size); if ((pcb_name = image.get_feature("pcb_type")) == nullptr) - return image_init_result::FAIL; + return image_error::BADSOFTWARE; else { if (!strcmp("genesis", pcb_name)) @@ -780,7 +780,7 @@ image_init_result mtech_state::load_cart(device_image_interface &image, generic_ osd_printf_debug("cart%d is invalid\n", gameno + 1); } - return image_init_result::PASS; + return std::error_condition(); } #define MEGATECH_CARTSLOT(_tag, _load) \ diff --git a/src/mame/sega/sega_beena.cpp b/src/mame/sega/sega_beena.cpp index fc7f10ef2da..928d81a0b04 100644 --- a/src/mame/sega/sega_beena.cpp +++ b/src/mame/sega/sega_beena.cpp @@ -154,8 +154,7 @@ DEVICE_IMAGE_LOAD_MEMBER(sega_beena_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( sega_beena ) diff --git a/src/mame/sega/stv.cpp b/src/mame/sega/stv.cpp index edeac07ee8c..c0b5ce79fcf 100644 --- a/src/mame/sega/stv.cpp +++ b/src/mame/sega/stv.cpp @@ -1330,13 +1330,13 @@ void stv_state::machine_reset() m_vdp2.old_tvmd = -1; } -image_init_result stv_state::load_cart(device_image_interface &image, generic_slot_device *slot) +std::error_condition stv_state::load_cart(device_image_interface &image, generic_slot_device *slot) { uint8_t *ROM; uint32_t size = slot->common_get_size("rom"); if (!image.loaded_through_softlist()) - return image_init_result::FAIL; + return image_error::UNSUPPORTED; slot->rom_alloc(size, GENERIC_ROM32_WIDTH, ENDIANNESS_BIG); ROM = slot->get_rom_base(); @@ -1359,7 +1359,7 @@ image_init_result stv_state::load_cart(device_image_interface &image, generic_sl } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/sega/stv.h b/src/mame/sega/stv.h index d06338cb62e..d0ee79ec1f1 100644 --- a/src/mame/sega/stv.h +++ b/src/mame/sega/stv.h @@ -114,7 +114,7 @@ private: uint32_t magzun_rx_hack_r(); void hop_ioga_w(offs_t offset, uint8_t data); - image_init_result load_cart(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_cart(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER( stv_cart1 ) { return load_cart(image, m_cart1); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER( stv_cart2 ) { return load_cart(image, m_cart2); } DECLARE_DEVICE_IMAGE_LOAD_MEMBER( stv_cart3 ) { return load_cart(image, m_cart3); } diff --git a/src/mame/sega/svmu.cpp b/src/mame/sega/svmu.cpp index b91f75cffc7..f7862325224 100644 --- a/src/mame/sega/svmu.cpp +++ b/src/mame/sega/svmu.cpp @@ -327,7 +327,7 @@ QUICKLOAD_LOAD_MEMBER(svmu_state::quickload_cb) vmufat_write_word(flash, 253, 0x1a, 0x0001); // offset of header (in blocks) from file start } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/sfrj/galaxy.cpp b/src/mame/sfrj/galaxy.cpp index 1e93d53e0a1..116e761db1b 100644 --- a/src/mame/sfrj/galaxy.cpp +++ b/src/mame/sfrj/galaxy.cpp @@ -203,7 +203,7 @@ SNAPSHOT_LOAD_MEMBER(galaxy_state::snapshot_cb) case GALAXY_SNAPSHOT_V2_SIZE: break; default: - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } std::vector<uint8_t> snapshot_data(snapshot_size); @@ -211,7 +211,7 @@ SNAPSHOT_LOAD_MEMBER(galaxy_state::snapshot_cb) setup_snapshot(&snapshot_data[0], snapshot_size); - return image_init_result::PASS; + return std::error_condition(); } /*************************************************************************** diff --git a/src/mame/sgi/iris3130.cpp b/src/mame/sgi/iris3130.cpp index 79f4a842176..6e71e9c369e 100644 --- a/src/mame/sgi/iris3130.cpp +++ b/src/mame/sgi/iris3130.cpp @@ -224,9 +224,9 @@ QUICKLOAD_LOAD_MEMBER(iris3000_state::load_romboard) if (image.length() == 0 || image.fread(&m_file_data[0], image.length()) != image.length()) { m_file_data.clear(); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } - return image_init_result::PASS; + return std::error_condition(); } /*************************************************************************** diff --git a/src/mame/shared/z80bin.cpp b/src/mame/shared/z80bin.cpp index c76f256e7f2..2d62c457c24 100644 --- a/src/mame/shared/z80bin.cpp +++ b/src/mame/shared/z80bin.cpp @@ -3,18 +3,19 @@ #include "emu.h" #include "z80bin.h" +#include "imagedev/snapquik.h" + /*------------------------------------------------- z80bin_load_file - load a z80bin file into memory -------------------------------------------------*/ -image_init_result z80bin_load_file(device_image_interface &image, address_space &space, uint16_t &exec_addr, uint16_t &start_addr, uint16_t &end_addr) +std::error_condition z80bin_load_file(snapshot_image_device &image, address_space &space, uint16_t &exec_addr, uint16_t &start_addr, uint16_t &end_addr) { uint16_t args[3]{}; uint16_t i = 0U, j = 0U, size = 0U; uint8_t data = 0U; char pgmname[256]{}; - char message[512]{}; image.fseek(7, SEEK_SET); @@ -26,9 +27,9 @@ image_init_result z80bin_load_file(device_image_interface &image, address_space { if (i >= (std::size(pgmname) - 1)) { - image.seterror(image_error::INVALIDIMAGE, "File name too long"); + osd_printf_error("File name too long\n"); image.message(" File name too long"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } pgmname[i] = ch; /* build program name */ @@ -38,18 +39,18 @@ image_init_result z80bin_load_file(device_image_interface &image, address_space if (bytes == 0) { - image.seterror(image_error::INVALIDIMAGE, "Unexpected EOF while getting file name"); + osd_printf_error("%s: Unexpected EOF while getting file name\n", image.basename()); image.message(" Unexpected EOF while getting file name"); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } pgmname[i] = '\0'; /* terminate string with a null */ if (image.fread(args, sizeof(args)) != sizeof(args)) { - image.seterror(image_error::INVALIDIMAGE, "Unexpected EOF while getting file size"); + osd_printf_error("%s: Unexpected EOF while getting file size\n", image.basename()); image.message(" Unexpected EOF while getting file size"); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } exec_addr = little_endianize_int16(args[0]); @@ -66,13 +67,12 @@ image_init_result z80bin_load_file(device_image_interface &image, address_space j = (start_addr + i) & 0xffff; if (image.fread(&data, 1) != 1) { - snprintf(message, std::size(message), "%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j); - image.seterror(image_error::INVALIDIMAGE, message); + osd_printf_error("%s: Unexpected EOF while writing byte to %04X\n", image.basename(), j); image.message("%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } space.write_byte(j, data); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/shared/z80bin.h b/src/mame/shared/z80bin.h index 64ba18150a2..629cb97dda9 100644 --- a/src/mame/shared/z80bin.h +++ b/src/mame/shared/z80bin.h @@ -13,6 +13,8 @@ #pragma once -image_init_result z80bin_load_file(device_image_interface &image, address_space &space, uint16_t &exec_addr, uint16_t &start_addr, uint16_t &end_addr); +class snapshot_image_device; + +std::error_condition z80bin_load_file(snapshot_image_device &image, address_space &space, uint16_t &exec_addr, uint16_t &start_addr, uint16_t &end_addr); #endif // MAME_SHARED_Z80BIN_H diff --git a/src/mame/sharp/pce220_ser.cpp b/src/mame/sharp/pce220_ser.cpp index b88088fcafd..9c5646076b9 100644 --- a/src/mame/sharp/pce220_ser.cpp +++ b/src/mame/sharp/pce220_ser.cpp @@ -217,7 +217,7 @@ TIMER_CALLBACK_MEMBER(pce220_serial_device::receive_tick) DEVICE_IMAGE_LOAD( pce220_serial ) -------------------------------------------------*/ -image_init_result pce220_serial_device::call_load() +std::error_condition pce220_serial_device::call_load() { m_state = SIO_WAIT; m_bytes_count = 0; @@ -226,21 +226,21 @@ image_init_result pce220_serial_device::call_load() //read the first byte fread(&m_current_byte, 1); - return image_init_result::PASS; + return std::error_condition(); } /*------------------------------------------------- DEVICE_IMAGE_CREATE( pce220_serial ) -------------------------------------------------*/ -image_init_result pce220_serial_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition pce220_serial_device::call_create(int format_type, util::option_resolution *format_options) { m_state = SIO_WAIT; m_bytes_count = 0; m_current_byte = 0; m_receive_timer->adjust(attotime::from_hz(SIO_BAUD_RATE), 0, attotime::from_hz(SIO_BAUD_RATE)); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/sharp/pce220_ser.h b/src/mame/sharp/pce220_ser.h index 17607ec74fb..fd4afbbf4e7 100644 --- a/src/mame/sharp/pce220_ser.h +++ b/src/mame/sharp/pce220_ser.h @@ -29,9 +29,9 @@ public: virtual ~pce220_serial_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual bool is_readable() const noexcept override { return true; } virtual bool is_writeable() const noexcept override { return true; } diff --git a/src/mame/sharp/wizard.cpp b/src/mame/sharp/wizard.cpp index 877f14aed7b..8dd38639153 100644 --- a/src/mame/sharp/wizard.cpp +++ b/src/mame/sharp/wizard.cpp @@ -121,7 +121,7 @@ DEVICE_IMAGE_LOAD_MEMBER(wizard_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( iq7000 ) diff --git a/src/mame/sharp/x68k_hdc.cpp b/src/mame/sharp/x68k_hdc.cpp index f4e74b08c22..063a29cd2ba 100644 --- a/src/mame/sharp/x68k_hdc.cpp +++ b/src/mame/sharp/x68k_hdc.cpp @@ -55,7 +55,7 @@ void x68k_hdc_image_device::device_start() save_item(NAME(m_transfer_byte_total)); } -image_init_result x68k_hdc_image_device::call_create(int format_type, util::option_resolution *format_options) +std::error_condition x68k_hdc_image_device::call_create(int format_type, util::option_resolution *format_options) { // create 20MB HD int x; @@ -67,10 +67,10 @@ image_init_result x68k_hdc_image_device::call_create(int format_type, util::opti { ret = fwrite(sectordata,256); if(ret < 256) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } - return image_init_result::PASS; + return std::error_condition(); } void x68k_hdc_image_device::hdc_w(offs_t offset, u16 data) diff --git a/src/mame/sharp/x68k_hdc.h b/src/mame/sharp/x68k_hdc.h index 6ca1c74b19c..e1659681561 100644 --- a/src/mame/sharp/x68k_hdc.h +++ b/src/mame/sharp/x68k_hdc.h @@ -101,7 +101,7 @@ public: virtual const char *file_extensions() const noexcept override { return "hdf"; } virtual const char *image_type_name() const noexcept override { return "sasihd"; } virtual const char *image_brief_type_name() const noexcept override { return "sasi"; } - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; void hdc_w(offs_t offset, u16 data); u16 hdc_r(offs_t offset); diff --git a/src/mame/sinclair/spec_snqk.cpp b/src/mame/sinclair/spec_snqk.cpp index d137e1adcbc..9c68812a204 100644 --- a/src/mame/sinclair/spec_snqk.cpp +++ b/src/mame/sinclair/spec_snqk.cpp @@ -121,7 +121,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if ((snapshot_size != SNA48_SIZE) && (snapshot_size != SNA128_SIZE_1) && (snapshot_size != SNA128_SIZE_2)) { logerror("Invalid .SNA file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } setup_sna(&snapshot_data[0], snapshot_size); } @@ -132,7 +132,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if (snapshot_size != SP_OLD_SIZE) { logerror("Invalid .SP file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } } setup_sp(&snapshot_data[0], snapshot_size); @@ -142,7 +142,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if (snapshot_size != ACH_SIZE) { logerror("Invalid .ACH file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } setup_ach(&snapshot_data[0], snapshot_size); } @@ -151,7 +151,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if (snapshot_size != PRG_SIZE) { logerror("Invalid .PRG file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } setup_prg(&snapshot_data[0], snapshot_size); } @@ -160,7 +160,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if ((snapshot_size != PLUSD48_SIZE) && (snapshot_size != PLUSD128_SIZE)) { logerror("Invalid .PLUSD file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } setup_plusd(&snapshot_data[0], snapshot_size); } @@ -173,7 +173,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if (snapshot_size != SEM_SIZE) { logerror("Invalid .SEM file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } } setup_sem(&snapshot_data[0], snapshot_size); @@ -183,7 +183,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if (snapshot_size != SIT_SIZE) { logerror("Invalid .SIT file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } setup_sit(&snapshot_data[0], snapshot_size); } @@ -192,7 +192,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if (snapshot_size != ZX_SIZE) { logerror("Invalid .ZX file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } setup_zx(&snapshot_data[0], snapshot_size); } @@ -201,7 +201,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if (snapshot_size != SNP_SIZE) { logerror("Invalid .SNP file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } setup_snp(&snapshot_data[0], snapshot_size); } @@ -210,8 +210,8 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if (snapshot_data[0] != 'X' && snapshot_data[1] != 'S' && \ snapshot_data[2] != 'N' && snapshot_data[3] != 'A') { - logerror("Invalid .SNX file size.\n"); - goto error; + logerror("Invalid .SNX file header.\n"); + return image_error::INVALIDIMAGE; } setup_snx(&snapshot_data[0], snapshot_size); } @@ -220,7 +220,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) if (snapshot_size != FRZ_SIZE) { logerror("Invalid .FRZ file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } setup_frz(&snapshot_data[0], snapshot_size); } @@ -229,10 +229,7 @@ SNAPSHOT_LOAD_MEMBER(spectrum_state::snapshot_cb) setup_z80(&snapshot_data[0], snapshot_size); } - return image_init_result::PASS; - -error: - return image_init_result::FAIL; + return std::error_condition(); } /******************************************************************* @@ -2431,7 +2428,7 @@ QUICKLOAD_LOAD_MEMBER(spectrum_state::quickload_cb) if ((quickload_size != SCR_SIZE) && (quickload_size != SCR_BITMAP)) { logerror("Invalid .SCR file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } setup_scr(&quickload_data[0], quickload_size); } @@ -2440,15 +2437,12 @@ QUICKLOAD_LOAD_MEMBER(spectrum_state::quickload_cb) if (quickload_size != RAW_SIZE) { logerror("Invalid .RAW file size.\n"); - goto error; + return image_error::INVALIDLENGTH; } setup_raw(&quickload_data[0], quickload_size); } - return image_init_result::PASS; - -error: - return image_init_result::FAIL; + return std::error_condition(); } /******************************************************************* diff --git a/src/mame/sinclair/timex.cpp b/src/mame/sinclair/timex.cpp index 50a59cd3df7..c0670efb38d 100644 --- a/src/mame/sinclair/timex.cpp +++ b/src/mame/sinclair/timex.cpp @@ -606,13 +606,8 @@ DEVICE_IMAGE_LOAD_MEMBER( ts2068_state::cart_load ) if (size % 0x2000 != 9) { - image.seterror(image_error::INVALIDIMAGE, "File corrupted"); - return image_init_result::FAIL; - } - if (!image.loaded_through_softlist()) - { - image.seterror(image_error::UNSUPPORTED, "Loading from softlist is not supported yet"); - return image_init_result::FAIL; + osd_printf_error("%s: File corrupted\n", image.basename()); + return image_error::INVALIDLENGTH; } m_dock->rom_alloc(0x10000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); @@ -626,8 +621,8 @@ DEVICE_IMAGE_LOAD_MEMBER( ts2068_state::cart_load ) if (chunks_in_file * 0x2000 + 0x09 != size) { - image.seterror(image_error::INVALIDIMAGE, "File corrupted"); - return image_init_result::FAIL; + osd_printf_error("%s: File corrupted\n", image.basename()); + return image_error::INVALIDIMAGE; } switch (header[0]) @@ -650,8 +645,8 @@ DEVICE_IMAGE_LOAD_MEMBER( ts2068_state::cart_load ) break; default: - image.seterror(image_error::INVALIDIMAGE, "Cart type not supported"); - return image_init_result::FAIL; + osd_printf_error("%s: Cart type not supported\n", image.basename()); + return image_error::INVALIDIMAGE; } logerror ("Cart loaded [Chunks %02x]\n", m_ram_chunks); @@ -662,7 +657,7 @@ DEVICE_IMAGE_LOAD_MEMBER( ts2068_state::cart_load ) memcpy(m_dock->get_rom_base(), image.get_software_region("rom"), size); } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/skeleton/c2color.cpp b/src/mame/skeleton/c2color.cpp index 43f3b65d15b..684356e941d 100644 --- a/src/mame/skeleton/c2color.cpp +++ b/src/mame/skeleton/c2color.cpp @@ -105,7 +105,7 @@ DEVICE_IMAGE_LOAD_MEMBER(c2_color_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } u8 c2_color_state::cart_r(offs_t offset) diff --git a/src/mame/skeleton/cd2650.cpp b/src/mame/skeleton/cd2650.cpp index 66445bacb5f..62fbbee2563 100644 --- a/src/mame/skeleton/cd2650.cpp +++ b/src/mame/skeleton/cd2650.cpp @@ -257,18 +257,20 @@ void cd2650_state::kbd_put(u8 data) QUICKLOAD_LOAD_MEMBER(cd2650_state::quickload_cb) { int i; - image_init_result result = image_init_result::FAIL; + std::error_condition result = image_error::UNSPECIFIED; int quick_length = image.length(); if (quick_length < 0x1500) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too short\n", image.basename()); image.message(" File too short"); } else if (quick_length > 0x8000) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too long\n", image.basename()); image.message(" File too long"); } else @@ -277,13 +279,15 @@ QUICKLOAD_LOAD_MEMBER(cd2650_state::quickload_cb) int read_ = image.fread( &quick_data[0], quick_length); if (read_ != quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Cannot read the file"); + result = image_error::UNSPECIFIED; + osd_printf_error("%s: Cannot read the file\n", image.basename()); image.message(" Cannot read the file"); } else if (quick_data[0] != 0x40) { - image.seterror(image_error::INVALIDIMAGE, "Invalid header"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Invalid header\n", image.basename()); image.message(" Invalid header"); } else @@ -292,7 +296,8 @@ QUICKLOAD_LOAD_MEMBER(cd2650_state::quickload_cb) if (exec_addr >= quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Exec address beyond end of file"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Exec address beyond end of file\n", image.basename()); image.message(" Exec address beyond end of file"); } else @@ -315,7 +320,7 @@ QUICKLOAD_LOAD_MEMBER(cd2650_state::quickload_cb) // Start the quickload m_maincpu->set_state_int(S2650_PC, exec_addr); - result = image_init_result::PASS; + result = std::error_condition(); } } } diff --git a/src/mame/skeleton/cosmicos.cpp b/src/mame/skeleton/cosmicos.cpp index 395e1b666ae..cf66198a6d9 100644 --- a/src/mame/skeleton/cosmicos.cpp +++ b/src/mame/skeleton/cosmicos.cpp @@ -503,7 +503,7 @@ QUICKLOAD_LOAD_MEMBER(cosmicos_state::quickload_cb) /* load image to RAM */ image.fread(ptr, size); - return image_init_result::PASS; + return std::error_condition(); } /* Machine Driver */ diff --git a/src/mame/skeleton/cp1.cpp b/src/mame/skeleton/cp1.cpp index 53f544c41fb..142a01dbf97 100644 --- a/src/mame/skeleton/cp1.cpp +++ b/src/mame/skeleton/cp1.cpp @@ -262,11 +262,11 @@ QUICKLOAD_LOAD_MEMBER(cp1_state::quickload_cb) } else { - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } } - return image_init_result::PASS; + return std::error_condition(); } void cp1_state::cp1(machine_config &config) diff --git a/src/mame/skeleton/digiblast.cpp b/src/mame/skeleton/digiblast.cpp index ca5f6bc5edd..0fccebc5682 100644 --- a/src/mame/skeleton/digiblast.cpp +++ b/src/mame/skeleton/digiblast.cpp @@ -74,7 +74,7 @@ DEVICE_IMAGE_LOAD_MEMBER(digiblast_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/skeleton/dmv.cpp b/src/mame/skeleton/dmv.cpp index 73801ee5177..a59ed257059 100644 --- a/src/mame/skeleton/dmv.cpp +++ b/src/mame/skeleton/dmv.cpp @@ -404,10 +404,10 @@ QUICKLOAD_LOAD_MEMBER(dmv_state::quickload_cb) { /* Avoid loading a program if CP/M-80 is not in memory */ if ((m_ram->base()[0] != 0xc3) || (m_ram->base()[5] != 0xc3)) - return image_init_result::FAIL; + return image_error::UNSUPPORTED; if (image.length() >= 0xfd00) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; /* Load image to the TPA (Transient Program Area) */ uint16_t quickload_size = image.length(); @@ -415,7 +415,7 @@ QUICKLOAD_LOAD_MEMBER(dmv_state::quickload_cb) { uint8_t data; if (image.fread( &data, 1) != 1) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; m_ram->base()[i+0x100] = data; } @@ -424,7 +424,7 @@ QUICKLOAD_LOAD_MEMBER(dmv_state::quickload_cb) m_maincpu->set_pc(0x100); // start program m_maincpu->set_state_int(Z80_SP, 256 * m_ram->base()[7] - 300); // put the stack a bit before BDOS - return image_init_result::PASS; + return std::error_condition(); } static void dmv_floppies(device_slot_interface &device) diff --git a/src/mame/skeleton/easy_karaoke.cpp b/src/mame/skeleton/easy_karaoke.cpp index 1244daea595..89f9bc4e7e5 100644 --- a/src/mame/skeleton/easy_karaoke.cpp +++ b/src/mame/skeleton/easy_karaoke.cpp @@ -128,7 +128,7 @@ DEVICE_IMAGE_LOAD_MEMBER(easy_karaoke_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( easy_karaoke ) diff --git a/src/mame/skeleton/i7000.cpp b/src/mame/skeleton/i7000.cpp index 6be4df63856..a642bea9dc8 100644 --- a/src/mame/skeleton/i7000.cpp +++ b/src/mame/skeleton/i7000.cpp @@ -288,7 +288,7 @@ DEVICE_IMAGE_LOAD_MEMBER(i7000_state::card_load) m_card->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_BIG); m_card->common_load_rom(m_card->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static const gfx_layout i7000_charlayout = diff --git a/src/mame/skeleton/pockchal.cpp b/src/mame/skeleton/pockchal.cpp index a8062d81a36..d926abe4cc5 100644 --- a/src/mame/skeleton/pockchal.cpp +++ b/src/mame/skeleton/pockchal.cpp @@ -67,8 +67,9 @@ DEVICE_IMAGE_LOAD_MEMBER( pockchalv1_state::cart_load ) m_cart->rom_alloc(m_rom_size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), m_rom_size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } + void pockchalv1_state::video_start() { } diff --git a/src/mame/skeleton/squale.cpp b/src/mame/skeleton/squale.cpp index 0cdc7128411..d091a4411f2 100644 --- a/src/mame/skeleton/squale.cpp +++ b/src/mame/skeleton/squale.cpp @@ -633,14 +633,14 @@ DEVICE_IMAGE_LOAD_MEMBER( squale_state::cart_load ) if ( ! size || size > 0x10000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } TIMER_DEVICE_CALLBACK_MEMBER( squale_state::squale_scanline ) diff --git a/src/mame/snk/ngp.cpp b/src/mame/snk/ngp.cpp index 79bf9c1a1fa..440123956bb 100644 --- a/src/mame/snk/ngp.cpp +++ b/src/mame/snk/ngp.cpp @@ -757,8 +757,8 @@ DEVICE_IMAGE_LOAD_MEMBER(ngp_state::load_ngp_cart) if (size != 0x8000 && size != 0x80000 && size != 0x100000 && size != 0x200000 && size != 0x400000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("Unsupported cartridge size\n"); + return image_error::INVALIDLENGTH; } // alloc 0x400000 ROM to simplify mapping in the address map @@ -794,7 +794,7 @@ DEVICE_IMAGE_LOAD_MEMBER(ngp_state::load_ngp_cart) m_flash_chip[1].state = F_READ; } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/sony/pockstat.cpp b/src/mame/sony/pockstat.cpp index 1a7f70d7b21..21dd8bf6e1c 100644 --- a/src/mame/sony/pockstat.cpp +++ b/src/mame/sony/pockstat.cpp @@ -968,20 +968,20 @@ DEVICE_IMAGE_LOAD_MEMBER(pockstat_state::flash_load) uint32_t size = image.length(); if (size != 0x20f40) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; image.fread(cart_id, 0xf40); for (int i = 0; i < strlen(gme_id); i++) { if (cart_id[i] != gme_id[i]) - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } m_cart->rom_alloc(0x20000, GENERIC_ROM32_WIDTH, ENDIANNESS_LITTLE); image.fread(m_cart->get_rom_base(), 0x20000); - return image_init_result::PASS; + return std::error_condition(); } void pockstat_state::pockstat(machine_config &config) diff --git a/src/mame/sony/psx.cpp b/src/mame/sony/psx.cpp index 0bf399e84c1..91a7282e51b 100644 --- a/src/mame/sony/psx.cpp +++ b/src/mame/sony/psx.cpp @@ -466,10 +466,10 @@ QUICKLOAD_LOAD_MEMBER(psx1_state::quickload_exe) if (image.fread(reinterpret_cast<void *>(&m_exe_buffer[0]), image.length()) != image.length()) { m_exe_buffer.resize(0); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } - return image_init_result::PASS; + return std::error_condition(); } void psx1_state::cd_dma_read( uint32_t *p_n_psxram, uint32_t n_address, int32_t n_size ) diff --git a/src/mame/sony/psxcd.cpp b/src/mame/sony/psxcd.cpp index f5385897857..ff6de46b026 100644 --- a/src/mame/sony/psxcd.cpp +++ b/src/mame/sony/psxcd.cpp @@ -186,11 +186,11 @@ void psxcd_device::device_reset() curpos.w = 0; } -image_init_result psxcd_device::call_load() +std::error_condition psxcd_device::call_load() { - image_init_result ret = cdrom_image_device::call_load(); + std::error_condition ret = cdrom_image_device::call_load(); open = true; - if (ret == image_init_result::PASS) + if (!ret) add_system_event(EVENT_CHANGE_DISK, m_sysclock, nullptr); // 1 sec to spin up the disk return ret; } diff --git a/src/mame/sony/psxcd.h b/src/mame/sony/psxcd.h index 0d8e5a1bf6e..10d6e335f5a 100644 --- a/src/mame/sony/psxcd.h +++ b/src/mame/sony/psxcd.h @@ -24,7 +24,7 @@ public: // configuration helpers auto irq_handler() { return m_irq_handler.bind(); } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; void write(offs_t offset, uint8_t data); diff --git a/src/mame/sony/smc777.cpp b/src/mame/sony/smc777.cpp index 5466b0012cf..29567ce87a0 100644 --- a/src/mame/sony/smc777.cpp +++ b/src/mame/sony/smc777.cpp @@ -411,7 +411,7 @@ QUICKLOAD_LOAD_MEMBER(smc777_state::quickload_cb) address_space& prog_space = m_maincpu->space(AS_PROGRAM); if (image.length() >= 0xfd00) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; /* The right RAM bank must be active */ @@ -419,7 +419,7 @@ QUICKLOAD_LOAD_MEMBER(smc777_state::quickload_cb) if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) { machine_reset(); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } /* Load image to the TPA (Transient Program Area) */ @@ -428,7 +428,7 @@ QUICKLOAD_LOAD_MEMBER(smc777_state::quickload_cb) { uint8_t data; if (image.fread( &data, 1) != 1) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; prog_space.write_byte(i+0x100, data); } @@ -439,7 +439,7 @@ QUICKLOAD_LOAD_MEMBER(smc777_state::quickload_cb) m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 300); m_maincpu->set_pc(0x100); // start program - return image_init_result::PASS; + return std::error_condition(); } uint8_t smc777_state::fdc_r(offs_t offset) diff --git a/src/mame/svi/svi318.cpp b/src/mame/svi/svi318.cpp index cba9216caa5..fb37a14da08 100644 --- a/src/mame/svi/svi318.cpp +++ b/src/mame/svi/svi318.cpp @@ -508,7 +508,7 @@ DEVICE_IMAGE_LOAD_MEMBER( svi3x8_state::cart_load ) m_cart_rom->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart_rom->common_load_rom(m_cart_rom->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/svision/svision.cpp b/src/mame/svision/svision.cpp index cdf811e779a..526c91e8a9c 100644 --- a/src/mame/svision/svision.cpp +++ b/src/mame/svision/svision.cpp @@ -620,14 +620,14 @@ DEVICE_IMAGE_LOAD_MEMBER(svision_state::cart_load) if (size > 0x80000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void svision_state::machine_start() diff --git a/src/mame/ta/alphatro.cpp b/src/mame/ta/alphatro.cpp index 66828e05577..d74844460ee 100644 --- a/src/mame/ta/alphatro.cpp +++ b/src/mame/ta/alphatro.cpp @@ -104,7 +104,7 @@ private: DECLARE_WRITE_LINE_MEMBER(kansas_w); MC6845_UPDATE_ROW(crtc_update_row); - image_init_result load_cart(device_image_interface &image, generic_slot_device *slot); + std::error_condition load_cart(device_image_interface &image, generic_slot_device *slot); DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart_load) { return load_cart(image, m_cart); } void alphatro_io(address_map &map); @@ -696,14 +696,14 @@ void alphatro_state::machine_reset() m_bicom_en = 0; } -image_init_result alphatro_state::load_cart(device_image_interface &image, generic_slot_device *slot) +std::error_condition alphatro_state::load_cart(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); if ((size != 0x4000) && (size != 0x2000)) { - image.seterror(image_error::INVALIDIMAGE, "Invalid size, must be 8 or 16 K" ); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid size, must be 8 or 16 K\n", image.basename()); + return image_error::INVALIDLENGTH; } slot->rom_alloc(0x4000, GENERIC_ROM8_WIDTH, ENDIANNESS_BIG); @@ -717,7 +717,7 @@ image_init_result alphatro_state::load_cart(device_image_interface &image, gener slot->common_load_rom(slot->get_rom_base()+0x2000, size, "rom"); } - return image_init_result::PASS; + return std::error_condition(); } void alphatro_state::alphatro_palette(palette_device &palette) const diff --git a/src/mame/tangerine/microtan.h b/src/mame/tangerine/microtan.h index 16a9af5966c..208f704efb6 100644 --- a/src/mame/tangerine/microtan.h +++ b/src/mame/tangerine/microtan.h @@ -79,9 +79,9 @@ private: uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); TIMER_CALLBACK_MEMBER(pulse_nmi); - image_verify_result verify_snapshot(uint8_t *data, int size); - image_init_result parse_intel_hex(uint8_t *snapshot_buff, char *src); - image_init_result parse_zillion_hex(uint8_t *snapshot_buff, char *src); + std::error_condition verify_snapshot(const uint8_t *data, int size); + std::error_condition parse_intel_hex(uint8_t *snapshot_buff, const char *src); + std::error_condition parse_zillion_hex(uint8_t *snapshot_buff, const char *src); void set_cpu_regs(const uint8_t *snapshot_buff, int base); void snapshot_copy(uint8_t *snapshot_buff, int snapshot_size); DECLARE_SNAPSHOT_LOAD_MEMBER(snapshot_cb); diff --git a/src/mame/tangerine/microtan_m.cpp b/src/mame/tangerine/microtan_m.cpp index f09a3b24217..f117d3c9818 100644 --- a/src/mame/tangerine/microtan_m.cpp +++ b/src/mame/tangerine/microtan_m.cpp @@ -177,26 +177,26 @@ void mt6809_state::machine_start() } -image_verify_result microtan_state::verify_snapshot(uint8_t *data, int size) +std::error_condition microtan_state::verify_snapshot(const uint8_t *data, int size) { if (size == 8263) { logerror("snapshot_id: magic size %d found\n", size); - return image_verify_result::PASS; + return std::error_condition(); } else { if (4 + data[2] + 256 * data[3] + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 == size) { logerror("snapshot_id: header RAM size + structures matches filesize %d\n", size); - return image_verify_result::PASS; + return std::error_condition(); } } - return image_verify_result::FAIL; + return image_error::INVALIDIMAGE; } -image_init_result microtan_state::parse_intel_hex(uint8_t *snapshot_buff, char *src) +std::error_condition microtan_state::parse_intel_hex(uint8_t *snapshot_buff, const char *src) { char line[128]; int /*row = 0,*/ column = 0, last_addr = 0, last_size = 0; @@ -266,10 +266,10 @@ image_init_result microtan_state::parse_intel_hex(uint8_t *snapshot_buff, char * logerror("parse_intel_hex: registers (?) at %04X\n", last_addr); memcpy(&snapshot_buff[8192+64], &snapshot_buff[last_addr], last_size); } - return image_init_result::PASS; + return std::error_condition(); } -image_init_result microtan_state::parse_zillion_hex(uint8_t *snapshot_buff, char *src) +std::error_condition microtan_state::parse_zillion_hex(uint8_t *snapshot_buff, const char *src) { char line[128]; int parsing = 0, /*row = 0,*/ column = 0; @@ -341,7 +341,7 @@ image_init_result microtan_state::parse_zillion_hex(uint8_t *snapshot_buff, char } src++; } - return image_init_result::PASS; + return std::error_condition(); } void microtan_state::set_cpu_regs(const uint8_t *snapshot_buff, int base) @@ -456,26 +456,18 @@ SNAPSHOT_LOAD_MEMBER(microtan_state::snapshot_cb) { uint64_t snapshot_len = image.length(); if (snapshot_len < 4 || snapshot_len >= 66000) - { - //image.seterror(image_error::INVALIDIMAGE); - return image_init_result::FAIL; - } + return image_error::INVALIDLENGTH; auto snapshot_buff = std::make_unique<uint8_t []>(snapshot_len); if (image.fread(snapshot_buff.get(), snapshot_len) != snapshot_len) - { - //image.seterror(image_error::UNSPECIFIED); - return image_init_result::FAIL; - } + return image_error::UNSPECIFIED; - if (verify_snapshot(snapshot_buff.get(), snapshot_len) != image_verify_result::PASS) - { - //image.seterror(image_error::INVALIDIMAGE); - return image_init_result::FAIL; - } + std::error_condition err = verify_snapshot(snapshot_buff.get(), snapshot_len); + if (err) + return err; snapshot_copy(snapshot_buff.get(), snapshot_len); - return image_init_result::PASS; + return std::error_condition(); } QUICKLOAD_LOAD_MEMBER(microtan_state::quickload_cb) @@ -483,7 +475,7 @@ QUICKLOAD_LOAD_MEMBER(microtan_state::quickload_cb) int snapshot_size = 8263; /* magic size */ std::vector<uint8_t> snapshot_buff(snapshot_size, 0); std::vector<char> buff(image.length() + 1); - image_init_result rc; + std::error_condition rc; image.fread(&buff[0], image.length()); @@ -493,7 +485,7 @@ QUICKLOAD_LOAD_MEMBER(microtan_state::quickload_cb) rc = parse_intel_hex(&snapshot_buff[0], &buff[0]); else rc = parse_zillion_hex(&snapshot_buff[0], &buff[0]); - if (rc == image_init_result::PASS) + if (!rc) snapshot_copy(&snapshot_buff[0], snapshot_size); return rc; } diff --git a/src/mame/tatung/einstein.cpp b/src/mame/tatung/einstein.cpp index 9bb3ca54af6..376414162e8 100644 --- a/src/mame/tatung/einstein.cpp +++ b/src/mame/tatung/einstein.cpp @@ -843,7 +843,7 @@ QUICKLOAD_LOAD_MEMBER(einstein_state::quickload_cb) address_space& prog_space = m_maincpu->space(AS_PROGRAM); if (image.length() >= 0xfd00) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; /* disable rom */ m_rom_enabled = 0; @@ -856,14 +856,14 @@ QUICKLOAD_LOAD_MEMBER(einstein_state::quickload_cb) uint8_t data; if (image.fread(&data, 1) != 1) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; prog_space.write_byte(i + 0x100, data); } /* start program */ m_maincpu->set_pc(0x100); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/telercas/tmc1800.cpp b/src/mame/telercas/tmc1800.cpp index 26b92dc1abd..d8104715d32 100644 --- a/src/mame/telercas/tmc1800.cpp +++ b/src/mame/telercas/tmc1800.cpp @@ -771,12 +771,12 @@ QUICKLOAD_LOAD_MEMBER(tmc1800_base_state::quickload_cb) if (size > m_ram->size()) { - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } image.fread( ptr, size); - return image_init_result::PASS; + return std::error_condition(); } void tmc1800_state::tmc1800(machine_config &config) diff --git a/src/mame/thomson/thomson_m.cpp b/src/mame/thomson/thomson_m.cpp index c65cf29c522..05d41c2f9c3 100644 --- a/src/mame/thomson/thomson_m.cpp +++ b/src/mame/thomson/thomson_m.cpp @@ -263,16 +263,16 @@ DEVICE_IMAGE_LOAD_MEMBER( thomson_state::to7_cartridge ) m_thom_cart_nb_banks = 4; else { - image.seterror(image_error::INVALIDIMAGE, string_format("Invalid cartridge size %u", size).c_str()); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid cartridge size %u\n", image.basename(), size); + return image_error::INVALIDLENGTH; } if (!image.loaded_through_softlist()) { if ( image.fread( pos, size ) != size ) { - image.seterror(image_error::INVALIDIMAGE, "Read error"); - return image_init_result::FAIL; + osd_printf_error("%s: Read error\n", image.basename()); + return image_error::UNSPECIFIED; } } else @@ -295,7 +295,7 @@ DEVICE_IMAGE_LOAD_MEMBER( thomson_state::to7_cartridge ) PRINT (( "to7_cartridge_load: cartridge \"%s\" banks=%i, size=%i\n", name, m_thom_cart_nb_banks, size )); - return image_init_result::PASS; + return std::error_condition(); } @@ -1088,16 +1088,16 @@ DEVICE_IMAGE_LOAD_MEMBER( thomson_state::mo5_cartridge ) m_thom_cart_nb_banks = 4; else { - image.seterror(image_error::INVALIDIMAGE, string_format("Invalid cartridge size %d", size).c_str()); - return image_init_result::FAIL; + osd_printf_error("Invalid cartridge size %d\n", size); + return image_error::INVALIDLENGTH; } if (!image.loaded_through_softlist()) { if ( image.fread(pos, size ) != size ) { - image.seterror(image_error::INVALIDIMAGE, "Read error"); - return image_init_result::FAIL; + osd_printf_error("Read error\n"); + return image_error::UNSPECIFIED; } } else @@ -1120,7 +1120,7 @@ DEVICE_IMAGE_LOAD_MEMBER( thomson_state::mo5_cartridge ) PRINT (( "mo5_cartridge_load: cartridge \"%s\" banks=%i, size=%u\n", name, m_thom_cart_nb_banks, (unsigned) size )); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/ti/avigo.cpp b/src/mame/ti/avigo.cpp index abbb5a1af1b..b65a862c6af 100644 --- a/src/mame/ti/avigo.cpp +++ b/src/mame/ti/avigo.cpp @@ -733,10 +733,10 @@ QUICKLOAD_LOAD_MEMBER(avigo_state::quickload_cb) m_warm_start = 1; m_maincpu->reset(); - return image_init_result::PASS; + return std::error_condition(); } - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } void avigo_state::nvram_init(nvram_device &nvram, void *base, size_t size) diff --git a/src/mame/ti/cc40.cpp b/src/mame/ti/cc40.cpp index 171e46db833..f7732c720e4 100644 --- a/src/mame/ti/cc40.cpp +++ b/src/mame/ti/cc40.cpp @@ -196,14 +196,14 @@ DEVICE_IMAGE_LOAD_MEMBER(cc40_state::cart_load) // max size is 4*32KB if (size > 0x20000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid file size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid file size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(0x20000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); // allocate a larger ROM region to have 4x32K banks m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/ti/snspell.cpp b/src/mame/ti/snspell.cpp index cbb330ccbed..1f5e378f973 100644 --- a/src/mame/ti/snspell.cpp +++ b/src/mame/ti/snspell.cpp @@ -368,12 +368,12 @@ DEVICE_IMAGE_LOAD_MEMBER(snspell_state::cart_load) if (size > m_cart_max_size) { - image.seterror(image_error::INVALIDIMAGE, "Invalid file size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid file size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->common_load_rom(m_cart_base, size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void snspell_state::init_snspell() diff --git a/src/mame/ti/snspellc.cpp b/src/mame/ti/snspellc.cpp index fe70b66ee7c..206e8cd89f8 100644 --- a/src/mame/ti/snspellc.cpp +++ b/src/mame/ti/snspellc.cpp @@ -313,12 +313,12 @@ DEVICE_IMAGE_LOAD_MEMBER(snspellc_state::cart_load) if (size > 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid file size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid file size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->common_load_rom(m_cart_base, size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void snspellc_state::init_snspellc() diff --git a/src/mame/ti/ti74.cpp b/src/mame/ti/ti74.cpp index 27a1c8f058e..39c05c21972 100644 --- a/src/mame/ti/ti74.cpp +++ b/src/mame/ti/ti74.cpp @@ -149,14 +149,14 @@ DEVICE_IMAGE_LOAD_MEMBER(ti74_state::cart_load) // max size is 32KB if (size > 0x8000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid file size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid file size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/ti/ti85_m.cpp b/src/mame/ti/ti85_m.cpp index 71c414c9a7e..eee9988984b 100644 --- a/src/mame/ti/ti85_m.cpp +++ b/src/mame/ti/ti85_m.cpp @@ -1195,7 +1195,7 @@ SNAPSHOT_LOAD_MEMBER(ti85_state::snapshot_cb) if (image.length() != expected_snapshot_size) { logerror("Incomplete snapshot file\n"); - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } std::vector<uint8_t> ti8x_snapshot_data(image.length()); @@ -1206,5 +1206,5 @@ SNAPSHOT_LOAD_MEMBER(ti85_state::snapshot_cb) else if (!strncmp(machine().system().name, "ti86", 4)) ti86_setup_snapshot(&ti8x_snapshot_data[0]); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/ti/tm990189.cpp b/src/mame/ti/tm990189.cpp index f00984d158e..8112e217671 100644 --- a/src/mame/ti/tm990189.cpp +++ b/src/mame/ti/tm990189.cpp @@ -422,7 +422,7 @@ public: virtual const char *image_type_name() const noexcept override { return "serial"; } virtual const char *image_brief_type_name() const noexcept override { return "serl"; } - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; protected: @@ -459,11 +459,11 @@ TIMER_CALLBACK_MEMBER(tm990_189_rs232_image_device::rs232_input_tick) } } -image_init_result tm990_189_rs232_image_device::call_load() +std::error_condition tm990_189_rs232_image_device::call_load() { m_tms9902->rcv_dsr(ASSERT_LINE); m_rs232_input_timer->adjust(attotime::zero, 0, attotime::from_msec(10)); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/tiger/gamecom.h b/src/mame/tiger/gamecom.h index 6fcbbdcf549..edb5bacc019 100644 --- a/src/mame/tiger/gamecom.h +++ b/src/mame/tiger/gamecom.h @@ -279,7 +279,7 @@ private: void handle_stylus_press(int column); void recompute_lcd_params(); void handle_input_press(uint16_t mux_data); - image_init_result common_load(device_image_interface &image, generic_slot_device *slot); + std::error_condition common_load(device_image_interface &image, generic_slot_device *slot); virtual void machine_reset() override; virtual void video_start() override; required_shared_ptr<uint8_t> m_p_videoram; diff --git a/src/mame/tiger/gamecom_m.cpp b/src/mame/tiger/gamecom_m.cpp index b37a7d8d0c5..095d2306b98 100644 --- a/src/mame/tiger/gamecom_m.cpp +++ b/src/mame/tiger/gamecom_m.cpp @@ -621,7 +621,7 @@ void gamecom_state::init_gamecom() m_p_ram = m_share_maincpu; // required here because pio_w gets called before machine_reset } -image_init_result gamecom_state::common_load(device_image_interface &image, generic_slot_device *slot) +std::error_condition gamecom_state::common_load(device_image_interface &image, generic_slot_device *slot) { uint32_t size = slot->common_get_size("rom"); uint32_t load_offset = 0; @@ -629,8 +629,8 @@ image_init_result gamecom_state::common_load(device_image_interface &image, gene if (size != 0x008000 && size != 0x040000 && size != 0x080000 && size != 0x100000 && size != 0x1c0000 && size != 0x200000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } if (size == 0x1c0000) @@ -649,7 +649,7 @@ image_init_result gamecom_state::common_load(device_image_interface &image, gene if (size < 0x100000) { memcpy(crt + 0x080000, crt, 0x080000); } /* ->1MB */ if (size < 0x1c0000) { memcpy(crt + 0x100000, crt, 0x100000); } /* -> >=1.8MB */ - return image_init_result::PASS; + return std::error_condition(); } DEVICE_IMAGE_LOAD_MEMBER( gamecom_state::cart1_load ) diff --git a/src/mame/tiger/k28m2.cpp b/src/mame/tiger/k28m2.cpp index 3ab151d7d85..fb4f0ab4839 100644 --- a/src/mame/tiger/k28m2.cpp +++ b/src/mame/tiger/k28m2.cpp @@ -124,14 +124,14 @@ DEVICE_IMAGE_LOAD_MEMBER(k28m2_state::cart_load) if (size > 0x4000) { - image.seterror(image_error::INVALIDIMAGE, "Invalid file size"); - return image_init_result::FAIL; + osd_printf_error("%s: Invalid file size\n", image.basename()); + return image_error::INVALIDLENGTH; } u8 *base = memregion("tms6100")->base() + 0x8000; m_cart->common_load_rom(base, size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/trainer/instruct.cpp b/src/mame/trainer/instruct.cpp index 353882e64b4..d939ac90311 100644 --- a/src/mame/trainer/instruct.cpp +++ b/src/mame/trainer/instruct.cpp @@ -353,18 +353,20 @@ void instruct_state::machine_start() QUICKLOAD_LOAD_MEMBER(instruct_state::quickload_cb) { uint16_t i, exec_addr, quick_length, read_; - image_init_result result = image_init_result::FAIL; + std::error_condition result = image_error::UNSPECIFIED; quick_length = image.length(); if (quick_length < 0x0100) { - image.seterror(image_error::INVALIDIMAGE, "File too short"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too short\n", image.basename()); image.message(" File too short"); } else if (quick_length > 0x8000) { - image.seterror(image_error::INVALIDIMAGE, "File too long"); + result = image_error::INVALIDLENGTH; + osd_printf_error("%s: File too long\n", image.basename()); image.message(" File too long"); } else @@ -373,12 +375,14 @@ QUICKLOAD_LOAD_MEMBER(instruct_state::quickload_cb) read_ = image.fread( &quick_data[0], quick_length); if (read_ != quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Cannot read the file"); + result = image_error::UNSPECIFIED; + osd_printf_error("%s: Cannot read the file\n", image.basename()); image.message(" Cannot read the file"); } else if (quick_data[0] != 0xc5) { - image.seterror(image_error::INVALIDIMAGE, "Invalid header"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Invalid header\n", image.basename()); image.message(" Invalid header"); } else @@ -387,7 +391,8 @@ QUICKLOAD_LOAD_MEMBER(instruct_state::quickload_cb) if (exec_addr >= quick_length) { - image.seterror(image_error::INVALIDIMAGE, "Exec address beyond end of file"); + result = image_error::INVALIDIMAGE; + osd_printf_error("%s: Exec address beyond end of file\n", image.basename()); image.message(" Exec address beyond end of file"); } else @@ -423,7 +428,7 @@ QUICKLOAD_LOAD_MEMBER(instruct_state::quickload_cb) // Start the quickload - JP exec_addr m_maincpu->set_state_int(S2650_PC, 0); - result = image_init_result::PASS; + result = std::error_condition(); } } } diff --git a/src/mame/trainer/mk14.cpp b/src/mame/trainer/mk14.cpp index e18f595a223..31d3688a9f7 100644 --- a/src/mame/trainer/mk14.cpp +++ b/src/mame/trainer/mk14.cpp @@ -371,8 +371,8 @@ QUICKLOAD_LOAD_MEMBER(mk14_state::quickload_cb) { if (image.software_entry() == nullptr) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported quickload format"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported quickload format", image.basename()); + return image_error::UNSUPPORTED; } else { @@ -386,13 +386,13 @@ QUICKLOAD_LOAD_MEMBER(mk14_state::quickload_cb) uint8_t data; if (image.fread(&data, 1) != 1) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; m_maincpu->space(AS_PROGRAM).write_byte(load_addr + i, data); } m_maincpu->set_pc(exec_addr); } - return image_init_result::PASS; + return std::error_condition(); } void mk14_state::mk14(machine_config &config) diff --git a/src/mame/trs/coco_vhd.cpp b/src/mame/trs/coco_vhd.cpp index b2b95e30830..b63d106f227 100644 --- a/src/mame/trs/coco_vhd.cpp +++ b/src/mame/trs/coco_vhd.cpp @@ -104,12 +104,12 @@ void coco_vhd_image_device::device_start() // call_load //------------------------------------------------- -image_init_result coco_vhd_image_device::call_load() +std::error_condition coco_vhd_image_device::call_load() { m_status = VHDSTATUS_POWER_ON_STATE; m_logical_record_number = 0; m_buffer_address = 0; - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/trs/coco_vhd.h b/src/mame/trs/coco_vhd.h index 14769df91b7..89ce2cb7bb5 100644 --- a/src/mame/trs/coco_vhd.h +++ b/src/mame/trs/coco_vhd.h @@ -34,7 +34,7 @@ public: virtual ~coco_vhd_image_device(); // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual bool is_readable() const noexcept override { return true; } virtual bool is_writeable() const noexcept override { return true; } diff --git a/src/mame/trs/trs80_m.cpp b/src/mame/trs/trs80_m.cpp index 2d704a16fb1..9371a232055 100644 --- a/src/mame/trs/trs80_m.cpp +++ b/src/mame/trs/trs80_m.cpp @@ -402,7 +402,7 @@ QUICKLOAD_LOAD_MEMBER(trs80_state::quickload_cb) if (!ptr) { image.message("Attempting to write outside of RAM"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } image.fread( ptr, block_length); } @@ -415,7 +415,7 @@ QUICKLOAD_LOAD_MEMBER(trs80_state::quickload_cb) if (LOG) logerror("/CMD transfer address %04x\n", address); m_maincpu->set_state_int(Z80_PC, address); } - return image_init_result::PASS; + return std::error_condition(); case CMD_TYPE_LOAD_MODULE_HEADER: // 05 - name image.fread( &data, length); @@ -431,9 +431,9 @@ QUICKLOAD_LOAD_MEMBER(trs80_state::quickload_cb) image.fread( &data, length); logerror("/CMD unsupported block type %u!\n", type); image.message("Unsupported or invalid block type"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/trs/trs80m3_m.cpp b/src/mame/trs/trs80m3_m.cpp index 922222ddd54..3d9c1e91d32 100644 --- a/src/mame/trs/trs80m3_m.cpp +++ b/src/mame/trs/trs80m3_m.cpp @@ -691,7 +691,7 @@ QUICKLOAD_LOAD_MEMBER(trs80m3_state::quickload_cb) if (!ptr) { image.message("Attempting to write outside of RAM"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } image.fread( ptr, block_length); } @@ -704,7 +704,7 @@ QUICKLOAD_LOAD_MEMBER(trs80m3_state::quickload_cb) if (LOG) logerror("/CMD transfer address %04x\n", address); m_maincpu->set_state_int(Z80_PC, address); } - return image_init_result::PASS; + return std::error_condition(); case CMD_TYPE_LOAD_MODULE_HEADER: // 05 - name image.fread( &data, length); @@ -720,9 +720,9 @@ QUICKLOAD_LOAD_MEMBER(trs80m3_state::quickload_cb) image.fread( &data, length); logerror("/CMD unsupported block type %u!\n", type); image.message("Unsupported or invalid block type"); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/tvgames/elan_eu3a05.cpp b/src/mame/tvgames/elan_eu3a05.cpp index 0cf4b87ba56..a7374f53567 100644 --- a/src/mame/tvgames/elan_eu3a05.cpp +++ b/src/mame/tvgames/elan_eu3a05.cpp @@ -366,14 +366,14 @@ DEVICE_IMAGE_LOAD_MEMBER(elan_eu3a05_buzztime_state::cart_load) if (size != 0x200000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_NATIVE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void elan_eu3a05_buzztime_state::elan_buzztime(machine_config &config) diff --git a/src/mame/tvgames/generalplus_gpl16250_mobigo.cpp b/src/mame/tvgames/generalplus_gpl16250_mobigo.cpp index f9ba2ed7c12..7496dc62f5b 100644 --- a/src/mame/tvgames/generalplus_gpl16250_mobigo.cpp +++ b/src/mame/tvgames/generalplus_gpl16250_mobigo.cpp @@ -75,7 +75,7 @@ DEVICE_IMAGE_LOAD_MEMBER(mobigo2_state::cart_load) uint32_t size = m_cart->common_get_size("rom"); m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } DEVICE_IMAGE_LOAD_MEMBER(mobigo_state::cart_load) @@ -83,7 +83,7 @@ DEVICE_IMAGE_LOAD_MEMBER(mobigo_state::cart_load) uint32_t size = m_cart->common_get_size("rom"); m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/tvgames/generalplus_gpl16250_nand.cpp b/src/mame/tvgames/generalplus_gpl16250_nand.cpp index e90e15c04d6..c55db6559e9 100644 --- a/src/mame/tvgames/generalplus_gpl16250_nand.cpp +++ b/src/mame/tvgames/generalplus_gpl16250_nand.cpp @@ -108,7 +108,7 @@ DEVICE_IMAGE_LOAD_MEMBER(generalplus_gpac800_vbaby_game_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void generalplus_gpac800_vbaby_game_state::generalplus_gpac800_vbaby(machine_config &config) diff --git a/src/mame/tvgames/generalplus_gpl16250_spi.cpp b/src/mame/tvgames/generalplus_gpl16250_spi.cpp index baa9957a56d..ea0e3d600bb 100644 --- a/src/mame/tvgames/generalplus_gpl16250_spi.cpp +++ b/src/mame/tvgames/generalplus_gpl16250_spi.cpp @@ -113,7 +113,7 @@ DEVICE_IMAGE_LOAD_MEMBER(generalplus_gpspispi_bkrankp_game_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void generalplus_gpspispi_bkrankp_game_state::generalplus_gpspispi_bkrankp(machine_config &config) diff --git a/src/mame/tvgames/generalplus_gpl32612.cpp b/src/mame/tvgames/generalplus_gpl32612.cpp index ce516986ffb..07a95ea1fe0 100644 --- a/src/mame/tvgames/generalplus_gpl32612.cpp +++ b/src/mame/tvgames/generalplus_gpl32612.cpp @@ -206,7 +206,7 @@ DEVICE_IMAGE_LOAD_MEMBER(generalplus_zippity_game_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/tvgames/hyperscan_card.cpp b/src/mame/tvgames/hyperscan_card.cpp index ad9642fec3a..61e33bc9b70 100644 --- a/src/mame/tvgames/hyperscan_card.cpp +++ b/src/mame/tvgames/hyperscan_card.cpp @@ -65,14 +65,14 @@ void hyperscan_card_device::device_reset() call_load() -------------------------------------------------*/ -image_init_result hyperscan_card_device::call_load() +std::error_condition hyperscan_card_device::call_load() { if (fread(m_memory, sizeof(m_memory)) != sizeof(m_memory)) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; battery_load(m_memory, sizeof(m_memory), nullptr); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/tvgames/hyperscan_card.h b/src/mame/tvgames/hyperscan_card.h index b2f8d66b97a..068e8d1e9c1 100644 --- a/src/mame/tvgames/hyperscan_card.h +++ b/src/mame/tvgames/hyperscan_card.h @@ -23,7 +23,7 @@ protected: virtual void device_reset() override; // image-level overrides - virtual image_init_result call_load() override; + virtual std::error_condition call_load() override; virtual void call_unload() override; virtual bool is_creatable() const noexcept override { return false; } virtual bool is_reset_on_load() const noexcept override { return false; } diff --git a/src/mame/tvgames/magiceyes_pollux_vr3520f.cpp b/src/mame/tvgames/magiceyes_pollux_vr3520f.cpp index 6f44af2d9e6..a14dca0e3b3 100644 --- a/src/mame/tvgames/magiceyes_pollux_vr3520f.cpp +++ b/src/mame/tvgames/magiceyes_pollux_vr3520f.cpp @@ -76,7 +76,7 @@ DEVICE_IMAGE_LOAD_MEMBER(magiceyes_vr3520f_game_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( leapfrog_didj ) diff --git a/src/mame/tvgames/pubint_storyreader.cpp b/src/mame/tvgames/pubint_storyreader.cpp index 81293e2515e..7e3831c06b2 100644 --- a/src/mame/tvgames/pubint_storyreader.cpp +++ b/src/mame/tvgames/pubint_storyreader.cpp @@ -123,7 +123,7 @@ DEVICE_IMAGE_LOAD_MEMBER(pi_storyreader_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( pi_storyreader ) diff --git a/src/mame/tvgames/spg110.cpp b/src/mame/tvgames/spg110.cpp index 143a8d0fc6f..dc53bf9cf14 100644 --- a/src/mame/tvgames/spg110.cpp +++ b/src/mame/tvgames/spg110.cpp @@ -568,7 +568,7 @@ DEVICE_IMAGE_LOAD_MEMBER(spg110_sstarkar_game_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/tvgames/spg29x.cpp b/src/mame/tvgames/spg29x.cpp index 7c139b91f2c..42e9003d1cc 100644 --- a/src/mame/tvgames/spg29x.cpp +++ b/src/mame/tvgames/spg29x.cpp @@ -436,7 +436,7 @@ QUICKLOAD_LOAD_MEMBER(spg29x_game_state::quickload_hyper_exe) std::unique_ptr<u8 []> ptr; if (image.fread(ptr, length) != length) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; auto &space = m_maincpu->space(AS_PROGRAM); for (uint32_t i = 0; i < length; i++) @@ -444,7 +444,7 @@ QUICKLOAD_LOAD_MEMBER(spg29x_game_state::quickload_hyper_exe) m_maincpu->set_state_int(SCORE_PC, 0xa0091000); // Game entry point - return image_init_result::PASS; + return std::error_condition(); } void spg29x_game_state::spg29x(machine_config &config) diff --git a/src/mame/tvgames/spg2xx_ican.cpp b/src/mame/tvgames/spg2xx_ican.cpp index 1f22c07a410..cbb68987c73 100644 --- a/src/mame/tvgames/spg2xx_ican.cpp +++ b/src/mame/tvgames/spg2xx_ican.cpp @@ -433,14 +433,14 @@ DEVICE_IMAGE_LOAD_MEMBER(icanguit_state::cart_load_icanguit) if (size < 0x800000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/tvgames/spg2xx_smarttv.cpp b/src/mame/tvgames/spg2xx_smarttv.cpp index cb9aa4eb439..b1a4f510743 100644 --- a/src/mame/tvgames/spg2xx_smarttv.cpp +++ b/src/mame/tvgames/spg2xx_smarttv.cpp @@ -196,14 +196,14 @@ DEVICE_IMAGE_LOAD_MEMBER(smarttv_state::cart_load_smarttv) if (size > 0x800000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(0x800000, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void smarttv_state::smarttv(machine_config &config) diff --git a/src/mame/tvgames/spg2xx_telestory.cpp b/src/mame/tvgames/spg2xx_telestory.cpp index de78c09e3b4..844673c31ec 100644 --- a/src/mame/tvgames/spg2xx_telestory.cpp +++ b/src/mame/tvgames/spg2xx_telestory.cpp @@ -260,14 +260,14 @@ DEVICE_IMAGE_LOAD_MEMBER(telestory_state::cart_load_telestory) if (size > 0x800000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(0x800000, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void telestory_state::telestory(machine_config &config) diff --git a/src/mame/tvgames/spg2xx_tvgogo.cpp b/src/mame/tvgames/spg2xx_tvgogo.cpp index 91dc7c075b0..132e72d7941 100644 --- a/src/mame/tvgames/spg2xx_tvgogo.cpp +++ b/src/mame/tvgames/spg2xx_tvgogo.cpp @@ -213,14 +213,14 @@ DEVICE_IMAGE_LOAD_MEMBER(tvgogo_state::cart_load_tvgogo) if (size > 0x800000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(0x800000, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/tvgames/spg2xx_vii.cpp b/src/mame/tvgames/spg2xx_vii.cpp index 897f8895f06..3713c18e7c0 100644 --- a/src/mame/tvgames/spg2xx_vii.cpp +++ b/src/mame/tvgames/spg2xx_vii.cpp @@ -140,14 +140,14 @@ DEVICE_IMAGE_LOAD_MEMBER(vii_state::cart_load_vii) if (size < 0x800000) { - image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size"); - return image_init_result::FAIL; + osd_printf_error("%s: Unsupported cartridge size\n", image.basename()); + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void vii_state::vii(machine_config &config) diff --git a/src/mame/usp/patinho_feio.cpp b/src/mame/usp/patinho_feio.cpp index aebd744ad92..dcf269890c1 100644 --- a/src/mame/usp/patinho_feio.cpp +++ b/src/mame/usp/patinho_feio.cpp @@ -182,7 +182,7 @@ DEVICE_IMAGE_LOAD_MEMBER( patinho_feio_state::tape_load ) paper_tape_address = 0; } - return image_init_result::PASS; + return std::error_condition(); } void patinho_feio_state::machine_start(){ diff --git a/src/mame/ussr/lviv.h b/src/mame/ussr/lviv.h index de42e0ffec4..cb3cad90b68 100644 --- a/src/mame/ussr/lviv.h +++ b/src/mame/ussr/lviv.h @@ -71,7 +71,7 @@ private: void update_memory(); void setup_snapshot(uint8_t * data); void dump_registers(); - image_verify_result verify_snapshot(uint8_t * data, uint32_t size); + std::error_condition verify_snapshot(const uint8_t * data, uint32_t size); void io_map(address_map &map); void mem_map(address_map &map); diff --git a/src/mame/ussr/lviv_m.cpp b/src/mame/ussr/lviv_m.cpp index ab44ec2683d..9bd16428f94 100644 --- a/src/mame/ussr/lviv_m.cpp +++ b/src/mame/ussr/lviv_m.cpp @@ -271,24 +271,24 @@ void lviv_state::dump_registers() logerror("HL = %04x\n", (unsigned) m_maincpu->state_int(i8080_cpu_device::I8085_HL)); } -image_verify_result lviv_state::verify_snapshot(uint8_t * data, uint32_t size) +std::error_condition lviv_state::verify_snapshot(const uint8_t * data, uint32_t size) { const char* tag = "LVOV/DUMP/2.0/"; - if (strncmp(tag, (char*)data, strlen(tag))) + if (strncmp(tag, (const char*)data, strlen(tag))) { logerror("Not a Lviv snapshot\n"); - return image_verify_result::FAIL; + return image_error::INVALIDIMAGE; } if (size != LVIV_SNAPSHOT_SIZE) { logerror ("Incomplete snapshot file\n"); - return image_verify_result::FAIL; + return image_error::INVALIDLENGTH; } logerror("returning ID_OK\n"); - return image_verify_result::PASS; + return std::error_condition(); } SNAPSHOT_LOAD_MEMBER(lviv_state::snapshot_cb) @@ -297,15 +297,14 @@ SNAPSHOT_LOAD_MEMBER(lviv_state::snapshot_cb) image.fread(&snapshot_data[0], LVIV_SNAPSHOT_SIZE); - if (verify_snapshot(&snapshot_data[0], image.length()) != image_verify_result::PASS) - { - return image_init_result::FAIL; - } + std::error_condition err = verify_snapshot(&snapshot_data[0], image.length()); + if (err) + return err; setup_snapshot(&snapshot_data[0]); dump_registers(); logerror("Snapshot file loaded\n"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/videoton/tvc.cpp b/src/mame/videoton/tvc.cpp index d08cac1fad1..03af49152d7 100644 --- a/src/mame/videoton/tvc.cpp +++ b/src/mame/videoton/tvc.cpp @@ -746,11 +746,11 @@ QUICKLOAD_LOAD_MEMBER(tvc_state::quickload_cb) { image.fseek(0x90, SEEK_SET); image.fread(m_ram->pointer() + 0x19ef, image.length() - 0x90); - return image_init_result::PASS; + return std::error_condition(); } else { - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } } diff --git a/src/mame/virtual/vgmplay.cpp b/src/mame/virtual/vgmplay.cpp index 24965086b06..f57e4590e8a 100644 --- a/src/mame/virtual/vgmplay.cpp +++ b/src/mame/virtual/vgmplay.cpp @@ -2771,7 +2771,7 @@ QUICKLOAD_LOAD_MEMBER(vgmplay_state::load_file) image.fread(&m_file_data[0], image.length()) != image.length()) { m_file_data.clear(); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } else { @@ -2795,7 +2795,7 @@ QUICKLOAD_LOAD_MEMBER(vgmplay_state::load_file) { logerror("gzip header but not a gzip file\n"); m_file_data.clear(); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } do { @@ -2810,7 +2810,7 @@ QUICKLOAD_LOAD_MEMBER(vgmplay_state::load_file) { logerror("broken gzip file\n"); m_file_data.clear(); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } m_file_data.resize(str.total_out); memcpy(&m_file_data[0], &decomp[0], str.total_out); @@ -2820,7 +2820,7 @@ QUICKLOAD_LOAD_MEMBER(vgmplay_state::load_file) { logerror("Not a vgm/vgz file\n"); m_file_data.clear(); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } uint32_t version = r32(8); @@ -3070,7 +3070,7 @@ QUICKLOAD_LOAD_MEMBER(vgmplay_state::load_file) machine().schedule_soft_reset(); - return image_init_result::PASS; + return std::error_condition(); } } diff --git a/src/mame/vtech/clickstart.cpp b/src/mame/vtech/clickstart.cpp index f22f4865854..71c05dd5c64 100644 --- a/src/mame/vtech/clickstart.cpp +++ b/src/mame/vtech/clickstart.cpp @@ -201,7 +201,7 @@ DEVICE_IMAGE_LOAD_MEMBER(clickstart_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } TIMER_CALLBACK_MEMBER(clickstart_state::handle_uart_tx) diff --git a/src/mame/vtech/geniusiq.cpp b/src/mame/vtech/geniusiq.cpp index b9520c6441b..8276742d269 100644 --- a/src/mame/vtech/geniusiq.cpp +++ b/src/mame/vtech/geniusiq.cpp @@ -692,7 +692,7 @@ DEVICE_IMAGE_LOAD_MEMBER(geniusiq_state::cart_load) } } - return image_init_result::PASS; + return std::error_condition(); } DEVICE_IMAGE_UNLOAD_MEMBER(geniusiq_state::cart_unload) diff --git a/src/mame/vtech/innotv_innotabmax.cpp b/src/mame/vtech/innotv_innotabmax.cpp index 5e342b05ab7..70e679a64f4 100644 --- a/src/mame/vtech/innotv_innotabmax.cpp +++ b/src/mame/vtech/innotv_innotabmax.cpp @@ -124,7 +124,7 @@ DEVICE_IMAGE_LOAD_MEMBER(vtech_innotv_innotabmax_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( vtech_innotv_innotabmax ) diff --git a/src/mame/vtech/iqunlim.cpp b/src/mame/vtech/iqunlim.cpp index 92a4b7fc297..a57aa59a2a7 100644 --- a/src/mame/vtech/iqunlim.cpp +++ b/src/mame/vtech/iqunlim.cpp @@ -174,7 +174,7 @@ DEVICE_IMAGE_LOAD_MEMBER(iqunlim_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_BIG); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/vtech/pc2000.cpp b/src/mame/vtech/pc2000.cpp index d09e729e61f..8e90199dbe1 100644 --- a/src/mame/vtech/pc2000.cpp +++ b/src/mame/vtech/pc2000.cpp @@ -908,7 +908,7 @@ DEVICE_IMAGE_LOAD_MEMBER( pc2000_state::cart_load ) m_cart->rom_alloc(0x40000, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void pc2000_state::pc2000gen(machine_config &config) diff --git a/src/mame/vtech/storio.cpp b/src/mame/vtech/storio.cpp index 637327b34d0..f1a724595be 100644 --- a/src/mame/vtech/storio.cpp +++ b/src/mame/vtech/storio.cpp @@ -92,7 +92,7 @@ DEVICE_IMAGE_LOAD_MEMBER(vtech_storio_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( vtech_storio ) diff --git a/src/mame/vtech/vtech1.cpp b/src/mame/vtech/vtech1.cpp index d314ef19df4..0dafd488d6f 100644 --- a/src/mame/vtech/vtech1.cpp +++ b/src/mame/vtech/vtech1.cpp @@ -163,8 +163,7 @@ SNAPSHOT_LOAD_MEMBER(vtech1_base_state::snapshot_cb) uint8_t header[24]; if (image.fread(&header, sizeof(header)) != sizeof(header)) { - //image.seterror(image_error::UNSPECIFIED); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } // get image name @@ -182,8 +181,7 @@ SNAPSHOT_LOAD_MEMBER(vtech1_base_state::snapshot_cb) auto buf = std::make_unique<uint8_t []>(size); if (image.fread(buf.get(), size) != size) { - //image.seterror(image_error::UNSPECIFIED); - return image_init_result::FAIL; + return image_error::UNSPECIFIED; } uint8_t *ptr = &buf[0]; @@ -196,10 +194,10 @@ SNAPSHOT_LOAD_MEMBER(vtech1_base_state::snapshot_cb) // verify if (space.read_byte(addr) != to_write) { - image.seterror(image_error::INVALIDIMAGE, "Insufficient RAM to load snapshot"); + osd_printf_error("%s: Insufficient RAM to load snapshot\n", image.basename()); image.message("Insufficient RAM to load snapshot (%d bytes needed) [%s]", size, pgmname); - return image_init_result::FAIL; + return image_error::INVALIDIMAGE; } } @@ -226,12 +224,12 @@ SNAPSHOT_LOAD_MEMBER(vtech1_base_state::snapshot_cb) break; default: - image.seterror(image_error::INVALIDIMAGE, "Snapshot format not supported."); + osd_printf_error("%s: Snapshot format not supported.\n", image.basename()); image.message("Snapshot format not supported."); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/mame/vtech/vtech2_m.cpp b/src/mame/vtech/vtech2_m.cpp index 48bd075a1b5..1311efe3db3 100644 --- a/src/mame/vtech/vtech2_m.cpp +++ b/src/mame/vtech/vtech2_m.cpp @@ -54,15 +54,15 @@ DEVICE_IMAGE_LOAD_MEMBER( vtech2_state::cart_load ) if (m_cart_size > 0x10000) { - image.seterror(image_error::INVALIDIMAGE, "Cartridge bigger than 64k"); + osd_printf_error("%s: Cartridge bigger than 64k\n", image.basename()); m_cart_size = 0; - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; } m_cart->rom_alloc(m_cart_size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), m_cart_size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } void vtech2_state::machine_reset() diff --git a/src/mame/vtech/vtech_innotab.cpp b/src/mame/vtech/vtech_innotab.cpp index c529b00cc24..790d76dbfc4 100644 --- a/src/mame/vtech/vtech_innotab.cpp +++ b/src/mame/vtech/vtech_innotab.cpp @@ -75,7 +75,7 @@ DEVICE_IMAGE_LOAD_MEMBER(vtech_innotab_state::cart_load) m_cart->rom_alloc(size, GENERIC_ROM16_WIDTH, ENDIANNESS_LITTLE); m_cart->common_load_rom(m_cart->get_rom_base(), size, "rom"); - return image_init_result::PASS; + return std::error_condition(); } static INPUT_PORTS_START( vtech_innotab ) diff --git a/src/mame/xerox/xerox820.cpp b/src/mame/xerox/xerox820.cpp index 157dfccf239..00c2e14b98e 100644 --- a/src/mame/xerox/xerox820.cpp +++ b/src/mame/xerox/xerox820.cpp @@ -381,7 +381,7 @@ QUICKLOAD_LOAD_MEMBER(xerox820_state::quickload_cb) address_space& prog_space = m_maincpu->space(AS_PROGRAM); if (image.length() >= 0xfd00) - return image_init_result::FAIL; + return image_error::INVALIDLENGTH; m_view.select(0); @@ -389,7 +389,7 @@ QUICKLOAD_LOAD_MEMBER(xerox820_state::quickload_cb) if ((prog_space.read_byte(0) != 0xc3) || (prog_space.read_byte(5) != 0xc3)) { machine_reset(); - return image_init_result::FAIL; + return image_error::UNSUPPORTED; } /* Load image to the TPA (Transient Program Area) */ @@ -398,7 +398,7 @@ QUICKLOAD_LOAD_MEMBER(xerox820_state::quickload_cb) { uint8_t data; if (image.fread( &data, 1) != 1) - return image_init_result::FAIL; + return image_error::UNSPECIFIED; prog_space.write_byte(i+0x100, data); } @@ -409,7 +409,7 @@ QUICKLOAD_LOAD_MEMBER(xerox820_state::quickload_cb) m_maincpu->set_state_int(Z80_SP, 256 * prog_space.read_byte(7) - 300); m_maincpu->set_pc(0x100); // start program - return image_init_result::PASS; + return std::error_condition(); } diff --git a/src/osd/modules/debugger/debugimgui.cpp b/src/osd/modules/debugger/debugimgui.cpp index 2368352c6f3..a6f4554f75a 100644 --- a/src/osd/modules/debugger/debugimgui.cpp +++ b/src/osd/modules/debugger/debugimgui.cpp @@ -995,18 +995,18 @@ void debug_imgui::mount_image() void debug_imgui::create_image() { - image_init_result res; + std::error_condition res; auto *fd = dynamic_cast<floppy_image_device *>(m_dialog_image); if(fd != nullptr) { res = fd->create(m_path,nullptr,nullptr); - if(res == image_init_result::PASS) + if(!res) fd->setup_write(m_typelist.at(m_format_sel).format); } else res = m_dialog_image->create(m_path,nullptr,nullptr); - if(res == image_init_result::PASS) + if(!res) ImGui::CloseCurrentPopup(); // TODO: add a messagebox to display on an error } diff --git a/src/osd/modules/debugger/qt/mainwindow.cpp b/src/osd/modules/debugger/qt/mainwindow.cpp index 92be2c04b31..f707804537d 100644 --- a/src/osd/modules/debugger/qt/mainwindow.cpp +++ b/src/osd/modules/debugger/qt/mainwindow.cpp @@ -375,9 +375,10 @@ void MainWindow::mountImage(bool changedTo) QDir::currentPath(), tr("All files (*.*)")); - if (img->load(filename.toUtf8().data()) != image_init_result::PASS) + std::error_condition err = img->load(filename.toUtf8().data()); + if (err) { - m_machine.debugger().console().printf("Image could not be mounted.\n"); + m_machine.debugger().console().printf("Image could not be mounted: %s\n", err.message()); return; } -- cgit v1.2.3